From 2a39260b023b864759c1a0e4fe515a19c80d039a Mon Sep 17 00:00:00 2001 From: Daco Harkes Date: Tue, 31 May 2022 11:04:03 +0200 Subject: [PATCH 001/139] [jnigen] Initial commit --- .github/workflows/test-package.yml | 67 ++++++++++++++++++++++++++++++ pkgs/.gitignore | 35 ++++++++++++++++ pkgs/CONTRIBUTING.md | 29 +++++++++++++ pkgs/analysis_options.yaml | 5 +++ pkgs/jnigen/README.md | 6 +++ pkgs/lib/jnigen.dart | 5 +++ pkgs/lib/src/my_sum.dart | 6 +++ pkgs/pubspec.yaml | 17 ++++++++ pkgs/test/my_test.dart | 13 ++++++ pkgs/tool/coverage.sh | 15 +++++++ 10 files changed, 198 insertions(+) create mode 100644 .github/workflows/test-package.yml create mode 100644 pkgs/.gitignore create mode 100644 pkgs/CONTRIBUTING.md create mode 100644 pkgs/analysis_options.yaml create mode 100644 pkgs/jnigen/README.md create mode 100644 pkgs/lib/jnigen.dart create mode 100644 pkgs/lib/src/my_sum.dart create mode 100644 pkgs/pubspec.yaml create mode 100644 pkgs/test/my_test.dart create mode 100755 pkgs/tool/coverage.sh diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml new file mode 100644 index 000000000..6052b0639 --- /dev/null +++ b/.github/workflows/test-package.yml @@ -0,0 +1,67 @@ +# 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 +# BSD-style license that can be found in the LICENSE file. + +name: Dart CI + +on: + # Run on PRs and pushes to the default branch. + push: + branches: [ main ] + pull_request: + branches: [ main ] + schedule: + - cron: "0 0 * * 0" + +env: + PUB_ENVIRONMENT: bot.github + +jobs: + # Check code formatting and static analysis on a single OS (linux) + # against Dart stable. + analyze: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + sdk: [stable] + steps: + - uses: actions/checkout@v2 + - uses: dart-lang/setup-dart@v1.0 + 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' + + test: + needs: analyze + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + # Add macos-latest and/or windows-latest if relevant for this package. + os: [ubuntu-latest] + sdk: [2.17.0, dev] + steps: + - uses: actions/checkout@v2 + - uses: dart-lang/setup-dart@v1.0 + with: + sdk: stable + - name: Install dependencies + run: dart pub get + - name: Run VM tests + run: dart test --platform vm + - name: Collect coverage + run: ./tool/coverage.sh + - name: Upload coverage + uses: coverallsapp/github-action@v1.1.2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + path-to-lcov: lcov.info diff --git a/pkgs/.gitignore b/pkgs/.gitignore new file mode 100644 index 000000000..93533a59a --- /dev/null +++ b/pkgs/.gitignore @@ -0,0 +1,35 @@ +# See https://www.dartlang.org/guides/libraries/private-files + +# Files and directories created by pub. +.dart_tool/ +.packages +build/ +pubspec.lock + +# Directory created by dartdoc. +doc/api/ + +# Avoid committing generated Javascript files: +*.dart.js +*.info.json # Produced by the --dump-info flag. +*.js # When generated by dart2js. Don't specify *.js if your + # project includes source files written in JavaScript. +*.js_ +*.js.deps +*.js.map + +# IDE and debugger files. +.clangd +.gdb_history +.history +.vscode +compile_commands.json + +# IntelliJ +*.iml +*.ipr +*.iws +.idea/ + +# Mac +.DS_Store diff --git a/pkgs/CONTRIBUTING.md b/pkgs/CONTRIBUTING.md new file mode 100644 index 000000000..5dadc7447 --- /dev/null +++ b/pkgs/CONTRIBUTING.md @@ -0,0 +1,29 @@ +# How to Contribute + +We'd love to accept your patches and contributions to this project. There are +just a few small guidelines you need to follow. + +## Contributor License Agreement + +Contributions to this project must be accompanied by a Contributor License +Agreement. You (or your employer) retain the copyright to your contribution; +this simply gives us permission to use and redistribute your contributions as +part of the project. Head over to to see +your current agreements on file or to sign a new one. + +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. + +## Code reviews + +All submissions, including submissions by project members, require review. We +use GitHub pull requests for this purpose. Consult +[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more +information on using pull requests. + +## Community Guidelines + +This project follows [Google's Open Source Community +Guidelines](https://opensource.google/conduct/) and the [Dart code of +conduct](https://dart.dev/code-of-conduct). diff --git a/pkgs/analysis_options.yaml b/pkgs/analysis_options.yaml new file mode 100644 index 000000000..9c8e2c5cd --- /dev/null +++ b/pkgs/analysis_options.yaml @@ -0,0 +1,5 @@ +# 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 +# BSD-style license that can be found in the LICENSE file. + +include: package:lints/recommended.yaml diff --git a/pkgs/jnigen/README.md b/pkgs/jnigen/README.md new file mode 100644 index 000000000..d0f047461 --- /dev/null +++ b/pkgs/jnigen/README.md @@ -0,0 +1,6 @@ +# Experimental generator for FFI+JNI bindings. + +This package will generate JNI code to invoke Java from C, and Dart FFI bindings to invoke this C code. +This enables calling Java code from Dart. + +This is a GSoC 2022 project. diff --git a/pkgs/lib/jnigen.dart b/pkgs/lib/jnigen.dart new file mode 100644 index 000000000..34a82ddc3 --- /dev/null +++ b/pkgs/lib/jnigen.dart @@ -0,0 +1,5 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +export 'src/my_sum.dart'; diff --git a/pkgs/lib/src/my_sum.dart b/pkgs/lib/src/my_sum.dart new file mode 100644 index 000000000..5e21504e8 --- /dev/null +++ b/pkgs/lib/src/my_sum.dart @@ -0,0 +1,6 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +/// Computes the sum of its arguments. +int mySum(int a, int b) => a + b; diff --git a/pkgs/pubspec.yaml b/pkgs/pubspec.yaml new file mode 100644 index 000000000..a649b6aa8 --- /dev/null +++ b/pkgs/pubspec.yaml @@ -0,0 +1,17 @@ +# 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 +# BSD-style license that can be found in the LICENSE file. + +name: jnigen +version: 0.0.1 +homepage: https://github.com/google/jnigen.dart +description: Experimental generator for FFI+JNI bindings. + +environment: + sdk: '>=2.17.0 <3.0.0' + +dependencies: + +dev_dependencies: + lints: ^2.0.0 + test: ^1.17.5 diff --git a/pkgs/test/my_test.dart b/pkgs/test/my_test.dart new file mode 100644 index 000000000..bcf2b68c9 --- /dev/null +++ b/pkgs/test/my_test.dart @@ -0,0 +1,13 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +import 'package:test/test.dart'; +import 'package:jnigen/jnigen.dart'; + +void main() { + test('dummy test', () { + final result = mySum(2, 40); + expect(result, 42); + }); +} diff --git a/pkgs/tool/coverage.sh b/pkgs/tool/coverage.sh new file mode 100755 index 000000000..24fbaf2cf --- /dev/null +++ b/pkgs/tool/coverage.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# Copyright (c) 2020, 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. + +# Fast fail the script on failures. +set -e + +# Gather coverage. +dart pub global activate coverage +# Generate coverage report. +dart run --pause-isolates-on-exit --disable-service-auth-codes --enable-vm-service=3000 test & +dart pub global run coverage:collect_coverage --wait-paused --uri=http://127.0.0.1:3000/ -o coverage.json --resume-isolates --scope-output=jnigen +dart pub global run coverage:format_coverage --packages=.dart_tool/package_config.json --lcov -i coverage.json -o lcov.info From 3742faa3d7707bce0edf5e72f70a44c07924fd85 Mon Sep 17 00:00:00 2001 From: Daco Harkes Date: Tue, 7 Jun 2022 11:52:31 +0200 Subject: [PATCH 002/139] [jnigen] Add build badge (https://github.com/dart-lang/jnigen/issues/1) --- pkgs/jnigen/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/jnigen/README.md b/pkgs/jnigen/README.md index d0f047461..c8b9f3eb8 100644 --- a/pkgs/jnigen/README.md +++ b/pkgs/jnigen/README.md @@ -1,3 +1,5 @@ +[![Build Status](https://github.com/dart-lang/jnigen/workflows/Dart%20CI/badge.svg)](https://github.com/dart-lang/jnigen/actions?query=workflow%3A%22Dart+CI%22+branch%3Amain) + # Experimental generator for FFI+JNI bindings. This package will generate JNI code to invoke Java from C, and Dart FFI bindings to invoke this C code. From 982a26795531dbe21942ebf29edc359ab4fdd769 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Fri, 1 Jul 2022 09:47:08 -0700 Subject: [PATCH 003/139] [jnigen] Delete CONTRIBUTING.md (https://github.com/dart-lang/jnigen/issues/4) --- pkgs/CONTRIBUTING.md | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 pkgs/CONTRIBUTING.md diff --git a/pkgs/CONTRIBUTING.md b/pkgs/CONTRIBUTING.md deleted file mode 100644 index 5dadc7447..000000000 --- a/pkgs/CONTRIBUTING.md +++ /dev/null @@ -1,29 +0,0 @@ -# How to Contribute - -We'd love to accept your patches and contributions to this project. There are -just a few small guidelines you need to follow. - -## Contributor License Agreement - -Contributions to this project must be accompanied by a Contributor License -Agreement. You (or your employer) retain the copyright to your contribution; -this simply gives us permission to use and redistribute your contributions as -part of the project. Head over to to see -your current agreements on file or to sign a new one. - -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. - -## Code reviews - -All submissions, including submissions by project members, require review. We -use GitHub pull requests for this purpose. Consult -[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more -information on using pull requests. - -## Community Guidelines - -This project follows [Google's Open Source Community -Guidelines](https://opensource.google/conduct/) and the [Dart code of -conduct](https://dart.dev/code-of-conduct). From 837ceb41cbf040004d00cb8f5b384cb2b1149e30 Mon Sep 17 00:00:00 2001 From: Mahesh Hegde <46179734+mahesh-hegde@users.noreply.github.com> Date: Fri, 1 Jul 2022 23:17:49 +0530 Subject: [PATCH 004/139] [jnigen] Move stub package to its own folder (https://github.com/dart-lang/jnigen/issues/2) --- .github/workflows/test-package.yml | 18 ++++++++---- pkgs/{ => jni_gen}/.gitignore | 0 pkgs/jni_gen/AUTHORS | 6 ++++ pkgs/jni_gen/CONTRIBUTING.md | 29 +++++++++++++++++++ pkgs/jni_gen/LICENSE | 27 +++++++++++++++++ pkgs/{jnigen => jni_gen}/README.md | 2 +- pkgs/{ => jni_gen}/analysis_options.yaml | 0 .../jnigen.dart => jni_gen/lib/jni_gen.dart} | 0 pkgs/{ => jni_gen}/lib/src/my_sum.dart | 0 pkgs/{ => jni_gen}/pubspec.yaml | 4 +-- pkgs/{ => jni_gen}/test/my_test.dart | 2 +- pkgs/tool/coverage.sh | 15 ---------- 12 files changed, 79 insertions(+), 24 deletions(-) rename pkgs/{ => jni_gen}/.gitignore (100%) create mode 100644 pkgs/jni_gen/AUTHORS create mode 100644 pkgs/jni_gen/CONTRIBUTING.md create mode 100644 pkgs/jni_gen/LICENSE rename pkgs/{jnigen => jni_gen}/README.md (55%) rename pkgs/{ => jni_gen}/analysis_options.yaml (100%) rename pkgs/{lib/jnigen.dart => jni_gen/lib/jni_gen.dart} (100%) rename pkgs/{ => jni_gen}/lib/src/my_sum.dart (100%) rename pkgs/{ => jni_gen}/pubspec.yaml (86%) rename pkgs/{ => jni_gen}/test/my_test.dart (90%) delete mode 100755 pkgs/tool/coverage.sh diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 6052b0639..b4cae730a 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -19,8 +19,11 @@ env: jobs: # Check code formatting and static analysis on a single OS (linux) # against Dart stable. - analyze: + analyze_jni_gen: runs-on: ubuntu-latest + defaults: + run: + working-directory: ./pkgs/jni_gen strategy: fail-fast: false matrix: @@ -40,9 +43,12 @@ jobs: run: dart analyze --fatal-infos if: always() && steps.install.outcome == 'success' - test: - needs: analyze + test_jni_gen: + needs: analyze_jni_gen runs-on: ${{ matrix.os }} + defaults: + run: + working-directory: ./pkgs/jni_gen strategy: fail-fast: false matrix: @@ -58,10 +64,12 @@ jobs: run: dart pub get - name: Run VM tests run: dart test --platform vm + - name: Install coverage + run: dart pub global activate coverage - name: Collect coverage - run: ./tool/coverage.sh + run: dart pub global run coverage:test_with_coverage - name: Upload coverage uses: coverallsapp/github-action@v1.1.2 with: github-token: ${{ secrets.GITHUB_TOKEN }} - path-to-lcov: lcov.info + path-to-lcov: ./pkgs/jni_gen/coverage/lcov.info diff --git a/pkgs/.gitignore b/pkgs/jni_gen/.gitignore similarity index 100% rename from pkgs/.gitignore rename to pkgs/jni_gen/.gitignore diff --git a/pkgs/jni_gen/AUTHORS b/pkgs/jni_gen/AUTHORS new file mode 100644 index 000000000..846e4a156 --- /dev/null +++ b/pkgs/jni_gen/AUTHORS @@ -0,0 +1,6 @@ +# Below is a list of people and organizations that have contributed +# to the Dart project. Names should be added to the list like so: +# +# Name/Organization + +Google LLC diff --git a/pkgs/jni_gen/CONTRIBUTING.md b/pkgs/jni_gen/CONTRIBUTING.md new file mode 100644 index 000000000..5dadc7447 --- /dev/null +++ b/pkgs/jni_gen/CONTRIBUTING.md @@ -0,0 +1,29 @@ +# How to Contribute + +We'd love to accept your patches and contributions to this project. There are +just a few small guidelines you need to follow. + +## Contributor License Agreement + +Contributions to this project must be accompanied by a Contributor License +Agreement. You (or your employer) retain the copyright to your contribution; +this simply gives us permission to use and redistribute your contributions as +part of the project. Head over to to see +your current agreements on file or to sign a new one. + +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. + +## Code reviews + +All submissions, including submissions by project members, require review. We +use GitHub pull requests for this purpose. Consult +[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more +information on using pull requests. + +## Community Guidelines + +This project follows [Google's Open Source Community +Guidelines](https://opensource.google/conduct/) and the [Dart code of +conduct](https://dart.dev/code-of-conduct). diff --git a/pkgs/jni_gen/LICENSE b/pkgs/jni_gen/LICENSE new file mode 100644 index 000000000..33474aad6 --- /dev/null +++ b/pkgs/jni_gen/LICENSE @@ -0,0 +1,27 @@ +Copyright 2022, the Dart project authors. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google LLC nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/pkgs/jnigen/README.md b/pkgs/jni_gen/README.md similarity index 55% rename from pkgs/jnigen/README.md rename to pkgs/jni_gen/README.md index c8b9f3eb8..6aa341789 100644 --- a/pkgs/jnigen/README.md +++ b/pkgs/jni_gen/README.md @@ -1,4 +1,4 @@ -[![Build Status](https://github.com/dart-lang/jnigen/workflows/Dart%20CI/badge.svg)](https://github.com/dart-lang/jnigen/actions?query=workflow%3A%22Dart+CI%22+branch%3Amain) +[![Build Status](https://github.com/dart-lang/jni_gen/workflows/Dart%20CI/badge.svg)](https://github.com/dart-lang/jni_gen/actions?query=workflow%3A%22Dart+CI%22+branch%3Amain) # Experimental generator for FFI+JNI bindings. diff --git a/pkgs/analysis_options.yaml b/pkgs/jni_gen/analysis_options.yaml similarity index 100% rename from pkgs/analysis_options.yaml rename to pkgs/jni_gen/analysis_options.yaml diff --git a/pkgs/lib/jnigen.dart b/pkgs/jni_gen/lib/jni_gen.dart similarity index 100% rename from pkgs/lib/jnigen.dart rename to pkgs/jni_gen/lib/jni_gen.dart diff --git a/pkgs/lib/src/my_sum.dart b/pkgs/jni_gen/lib/src/my_sum.dart similarity index 100% rename from pkgs/lib/src/my_sum.dart rename to pkgs/jni_gen/lib/src/my_sum.dart diff --git a/pkgs/pubspec.yaml b/pkgs/jni_gen/pubspec.yaml similarity index 86% rename from pkgs/pubspec.yaml rename to pkgs/jni_gen/pubspec.yaml index a649b6aa8..f60652b5b 100644 --- a/pkgs/pubspec.yaml +++ b/pkgs/jni_gen/pubspec.yaml @@ -2,9 +2,9 @@ # 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. -name: jnigen +name: jni_gen version: 0.0.1 -homepage: https://github.com/google/jnigen.dart +homepage: https://github.com/dart-lang/jni_gen description: Experimental generator for FFI+JNI bindings. environment: diff --git a/pkgs/test/my_test.dart b/pkgs/jni_gen/test/my_test.dart similarity index 90% rename from pkgs/test/my_test.dart rename to pkgs/jni_gen/test/my_test.dart index bcf2b68c9..647cfd35b 100644 --- a/pkgs/test/my_test.dart +++ b/pkgs/jni_gen/test/my_test.dart @@ -3,7 +3,7 @@ // BSD-style license that can be found in the LICENSE file. import 'package:test/test.dart'; -import 'package:jnigen/jnigen.dart'; +import 'package:jni_gen/jni_gen.dart'; void main() { test('dummy test', () { diff --git a/pkgs/tool/coverage.sh b/pkgs/tool/coverage.sh deleted file mode 100755 index 24fbaf2cf..000000000 --- a/pkgs/tool/coverage.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -# Copyright (c) 2020, 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. - -# Fast fail the script on failures. -set -e - -# Gather coverage. -dart pub global activate coverage -# Generate coverage report. -dart run --pause-isolates-on-exit --disable-service-auth-codes --enable-vm-service=3000 test & -dart pub global run coverage:collect_coverage --wait-paused --uri=http://127.0.0.1:3000/ -o coverage.json --resume-isolates --scope-output=jnigen -dart pub global run coverage:format_coverage --packages=.dart_tool/package_config.json --lcov -i coverage.json -o lcov.info From 63534577f48891b2765fb72181f2ba6caee68a11 Mon Sep 17 00:00:00 2001 From: Mahesh Hegde <46179734+mahesh-hegde@users.noreply.github.com> Date: Mon, 4 Jul 2022 17:44:07 +0530 Subject: [PATCH 005/139] [jnigen] Top level project information files (https://github.com/dart-lang/jnigen/issues/6) --- pkgs/jni_gen/AUTHORS | 6 ------ pkgs/jni_gen/CONTRIBUTING.md | 29 ----------------------------- pkgs/jni_gen/README.md | 2 -- pkgs/jnigen/README.md | 13 +++++++++++++ 4 files changed, 13 insertions(+), 37 deletions(-) delete mode 100644 pkgs/jni_gen/AUTHORS delete mode 100644 pkgs/jni_gen/CONTRIBUTING.md create mode 100644 pkgs/jnigen/README.md diff --git a/pkgs/jni_gen/AUTHORS b/pkgs/jni_gen/AUTHORS deleted file mode 100644 index 846e4a156..000000000 --- a/pkgs/jni_gen/AUTHORS +++ /dev/null @@ -1,6 +0,0 @@ -# Below is a list of people and organizations that have contributed -# to the Dart project. Names should be added to the list like so: -# -# Name/Organization - -Google LLC diff --git a/pkgs/jni_gen/CONTRIBUTING.md b/pkgs/jni_gen/CONTRIBUTING.md deleted file mode 100644 index 5dadc7447..000000000 --- a/pkgs/jni_gen/CONTRIBUTING.md +++ /dev/null @@ -1,29 +0,0 @@ -# How to Contribute - -We'd love to accept your patches and contributions to this project. There are -just a few small guidelines you need to follow. - -## Contributor License Agreement - -Contributions to this project must be accompanied by a Contributor License -Agreement. You (or your employer) retain the copyright to your contribution; -this simply gives us permission to use and redistribute your contributions as -part of the project. Head over to to see -your current agreements on file or to sign a new one. - -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. - -## Code reviews - -All submissions, including submissions by project members, require review. We -use GitHub pull requests for this purpose. Consult -[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more -information on using pull requests. - -## Community Guidelines - -This project follows [Google's Open Source Community -Guidelines](https://opensource.google/conduct/) and the [Dart code of -conduct](https://dart.dev/code-of-conduct). diff --git a/pkgs/jni_gen/README.md b/pkgs/jni_gen/README.md index 6aa341789..d0f047461 100644 --- a/pkgs/jni_gen/README.md +++ b/pkgs/jni_gen/README.md @@ -1,5 +1,3 @@ -[![Build Status](https://github.com/dart-lang/jni_gen/workflows/Dart%20CI/badge.svg)](https://github.com/dart-lang/jni_gen/actions?query=workflow%3A%22Dart+CI%22+branch%3Amain) - # Experimental generator for FFI+JNI bindings. This package will generate JNI code to invoke Java from C, and Dart FFI bindings to invoke this C code. diff --git a/pkgs/jnigen/README.md b/pkgs/jnigen/README.md new file mode 100644 index 000000000..c27482615 --- /dev/null +++ b/pkgs/jnigen/README.md @@ -0,0 +1,13 @@ +[![Build Status](https://github.com/dart-lang/jni_gen/workflows/Dart%20CI/badge.svg)](https://github.com/dart-lang/jni_gen/actions?query=workflow%3A%22Dart+CI%22+branch%3Amain) + +## jni_gen + +This project intends to provide 2 packages to enable JNI interop from Dart & Flutter. + +| Package | Description | +| ------- | --------- | +| [jni](jni/) | Ergonomic C bindings to JNI C API and several helper methods | +| [jni_gen](jni_gen/) | Tool to generate Dart bindings to Java code using FFI | + +This is a work-in-progress project under Google Summer of Code 2022 program. + From 3dee1d86e68d1f6f023b4aed6eead70f988e39e6 Mon Sep 17 00:00:00 2001 From: Mahesh Hegde <46179734+mahesh-hegde@users.noreply.github.com> Date: Wed, 6 Jul 2022 19:03:08 +0530 Subject: [PATCH 006/139] [jnigen] Create FFI plugin (https://github.com/dart-lang/jnigen/issues/8) Stub from `flutter create --template plugin_ffi` with GitHub workflow support. --- .github/workflows/test-package.yml | 65 ++ pkgs/jni/.gitignore | 30 + pkgs/jni/.metadata | 39 ++ pkgs/jni/CHANGELOG.md | 3 + pkgs/jni/LICENSE | 27 + pkgs/jni/README.md | 92 +++ pkgs/jni/analysis_options.yaml | 4 + pkgs/jni/android/.gitignore | 9 + pkgs/jni/android/build.gradle | 65 ++ pkgs/jni/android/settings.gradle | 1 + pkgs/jni/android/src/main/AndroidManifest.xml | 3 + pkgs/jni/example/.gitignore | 47 ++ pkgs/jni/example/README.md | 16 + pkgs/jni/example/analysis_options.yaml | 29 + pkgs/jni/example/android/.gitignore | 13 + pkgs/jni/example/android/app/build.gradle | 71 +++ .../android/app/src/debug/AndroidManifest.xml | 8 + .../android/app/src/main/AndroidManifest.xml | 34 ++ .../dev/dart/jni_example/MainActivity.kt | 6 + .../res/drawable-v21/launch_background.xml | 12 + .../main/res/drawable/launch_background.xml | 12 + .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 544 bytes .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 442 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 721 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 1031 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 1443 bytes .../app/src/main/res/values-night/styles.xml | 18 + .../app/src/main/res/values/styles.xml | 18 + .../app/src/profile/AndroidManifest.xml | 8 + pkgs/jni/example/android/build.gradle | 31 + pkgs/jni/example/android/gradle.properties | 3 + .../gradle/wrapper/gradle-wrapper.properties | 6 + pkgs/jni/example/android/settings.gradle | 11 + pkgs/jni/example/lib/main.dart | 74 +++ pkgs/jni/example/linux/.gitignore | 1 + pkgs/jni/example/linux/CMakeLists.txt | 138 +++++ pkgs/jni/example/linux/flutter/CMakeLists.txt | 88 +++ .../flutter/generated_plugin_registrant.cc | 11 + .../flutter/generated_plugin_registrant.h | 15 + .../linux/flutter/generated_plugins.cmake | 24 + pkgs/jni/example/linux/main.cc | 6 + pkgs/jni/example/linux/my_application.cc | 104 ++++ pkgs/jni/example/linux/my_application.h | 18 + pkgs/jni/example/macos/.gitignore | 7 + .../macos/Flutter/Flutter-Debug.xcconfig | 1 + .../macos/Flutter/Flutter-Release.xcconfig | 1 + .../Flutter/GeneratedPluginRegistrant.swift | 10 + .../macos/Runner.xcodeproj/project.pbxproj | 572 ++++++++++++++++++ .../xcshareddata/IDEWorkspaceChecks.plist | 8 + .../xcshareddata/xcschemes/Runner.xcscheme | 87 +++ .../contents.xcworkspacedata | 7 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + .../example/macos/Runner/AppDelegate.swift | 9 + .../AppIcon.appiconset/Contents.json | 68 +++ .../AppIcon.appiconset/app_icon_1024.png | Bin 0 -> 46993 bytes .../AppIcon.appiconset/app_icon_128.png | Bin 0 -> 3276 bytes .../AppIcon.appiconset/app_icon_16.png | Bin 0 -> 1429 bytes .../AppIcon.appiconset/app_icon_256.png | Bin 0 -> 5933 bytes .../AppIcon.appiconset/app_icon_32.png | Bin 0 -> 1243 bytes .../AppIcon.appiconset/app_icon_512.png | Bin 0 -> 14800 bytes .../AppIcon.appiconset/app_icon_64.png | Bin 0 -> 1874 bytes .../macos/Runner/Base.lproj/MainMenu.xib | 343 +++++++++++ .../macos/Runner/Configs/AppInfo.xcconfig | 14 + .../macos/Runner/Configs/Debug.xcconfig | 2 + .../macos/Runner/Configs/Release.xcconfig | 2 + .../macos/Runner/Configs/Warnings.xcconfig | 13 + .../macos/Runner/DebugProfile.entitlements | 12 + pkgs/jni/example/macos/Runner/Info.plist | 32 + .../macos/Runner/MainFlutterWindow.swift | 15 + .../example/macos/Runner/Release.entitlements | 8 + pkgs/jni/example/pubspec.lock | 182 ++++++ pkgs/jni/example/pubspec.yaml | 96 +++ pkgs/jni/example/windows/.gitignore | 17 + pkgs/jni/example/windows/CMakeLists.txt | 101 ++++ .../example/windows/flutter/CMakeLists.txt | 104 ++++ .../flutter/generated_plugin_registrant.cc | 11 + .../flutter/generated_plugin_registrant.h | 15 + .../windows/flutter/generated_plugins.cmake | 24 + .../jni/example/windows/runner/CMakeLists.txt | 32 + pkgs/jni/example/windows/runner/Runner.rc | 121 ++++ .../example/windows/runner/flutter_window.cpp | 61 ++ .../example/windows/runner/flutter_window.h | 33 + pkgs/jni/example/windows/runner/main.cpp | 43 ++ pkgs/jni/example/windows/runner/resource.h | 16 + .../windows/runner/resources/app_icon.ico | Bin 0 -> 33772 bytes .../windows/runner/runner.exe.manifest | 20 + pkgs/jni/example/windows/runner/utils.cpp | 64 ++ pkgs/jni/example/windows/runner/utils.h | 19 + .../example/windows/runner/win32_window.cpp | 245 ++++++++ .../jni/example/windows/runner/win32_window.h | 98 +++ pkgs/jni/ffigen.yaml | 19 + pkgs/jni/lib/jni.dart | 131 ++++ pkgs/jni/lib/jni_bindings_generated.dart | 69 +++ pkgs/jni/linux/CMakeLists.txt | 22 + pkgs/jni/macos/Classes/jni.c | 3 + pkgs/jni/macos/jni.podspec | 27 + pkgs/jni/pubspec.yaml | 79 +++ pkgs/jni/src/CMakeLists.txt | 17 + pkgs/jni/src/jni.c | 23 + pkgs/jni/src/jni.h | 30 + pkgs/jni/windows/.gitignore | 17 + pkgs/jni/windows/CMakeLists.txt | 23 + 102 files changed, 4141 insertions(+) create mode 100644 pkgs/jni/.gitignore create mode 100644 pkgs/jni/.metadata create mode 100644 pkgs/jni/CHANGELOG.md create mode 100644 pkgs/jni/LICENSE create mode 100644 pkgs/jni/README.md create mode 100644 pkgs/jni/analysis_options.yaml create mode 100644 pkgs/jni/android/.gitignore create mode 100644 pkgs/jni/android/build.gradle create mode 100644 pkgs/jni/android/settings.gradle create mode 100644 pkgs/jni/android/src/main/AndroidManifest.xml create mode 100644 pkgs/jni/example/.gitignore create mode 100644 pkgs/jni/example/README.md create mode 100644 pkgs/jni/example/analysis_options.yaml create mode 100644 pkgs/jni/example/android/.gitignore create mode 100644 pkgs/jni/example/android/app/build.gradle create mode 100644 pkgs/jni/example/android/app/src/debug/AndroidManifest.xml create mode 100644 pkgs/jni/example/android/app/src/main/AndroidManifest.xml create mode 100644 pkgs/jni/example/android/app/src/main/kotlin/dev/dart/jni_example/MainActivity.kt create mode 100644 pkgs/jni/example/android/app/src/main/res/drawable-v21/launch_background.xml create mode 100644 pkgs/jni/example/android/app/src/main/res/drawable/launch_background.xml create mode 100644 pkgs/jni/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 pkgs/jni/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 pkgs/jni/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 pkgs/jni/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 pkgs/jni/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 pkgs/jni/example/android/app/src/main/res/values-night/styles.xml create mode 100644 pkgs/jni/example/android/app/src/main/res/values/styles.xml create mode 100644 pkgs/jni/example/android/app/src/profile/AndroidManifest.xml create mode 100644 pkgs/jni/example/android/build.gradle create mode 100644 pkgs/jni/example/android/gradle.properties create mode 100644 pkgs/jni/example/android/gradle/wrapper/gradle-wrapper.properties create mode 100644 pkgs/jni/example/android/settings.gradle create mode 100644 pkgs/jni/example/lib/main.dart create mode 100644 pkgs/jni/example/linux/.gitignore create mode 100644 pkgs/jni/example/linux/CMakeLists.txt create mode 100644 pkgs/jni/example/linux/flutter/CMakeLists.txt create mode 100644 pkgs/jni/example/linux/flutter/generated_plugin_registrant.cc create mode 100644 pkgs/jni/example/linux/flutter/generated_plugin_registrant.h create mode 100644 pkgs/jni/example/linux/flutter/generated_plugins.cmake create mode 100644 pkgs/jni/example/linux/main.cc create mode 100644 pkgs/jni/example/linux/my_application.cc create mode 100644 pkgs/jni/example/linux/my_application.h create mode 100644 pkgs/jni/example/macos/.gitignore create mode 100644 pkgs/jni/example/macos/Flutter/Flutter-Debug.xcconfig create mode 100644 pkgs/jni/example/macos/Flutter/Flutter-Release.xcconfig create mode 100644 pkgs/jni/example/macos/Flutter/GeneratedPluginRegistrant.swift create mode 100644 pkgs/jni/example/macos/Runner.xcodeproj/project.pbxproj create mode 100644 pkgs/jni/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 pkgs/jni/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme create mode 100644 pkgs/jni/example/macos/Runner.xcworkspace/contents.xcworkspacedata create mode 100644 pkgs/jni/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 pkgs/jni/example/macos/Runner/AppDelegate.swift create mode 100644 pkgs/jni/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 pkgs/jni/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png create mode 100644 pkgs/jni/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png create mode 100644 pkgs/jni/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png create mode 100644 pkgs/jni/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png create mode 100644 pkgs/jni/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png create mode 100644 pkgs/jni/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png create mode 100644 pkgs/jni/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png create mode 100644 pkgs/jni/example/macos/Runner/Base.lproj/MainMenu.xib create mode 100644 pkgs/jni/example/macos/Runner/Configs/AppInfo.xcconfig create mode 100644 pkgs/jni/example/macos/Runner/Configs/Debug.xcconfig create mode 100644 pkgs/jni/example/macos/Runner/Configs/Release.xcconfig create mode 100644 pkgs/jni/example/macos/Runner/Configs/Warnings.xcconfig create mode 100644 pkgs/jni/example/macos/Runner/DebugProfile.entitlements create mode 100644 pkgs/jni/example/macos/Runner/Info.plist create mode 100644 pkgs/jni/example/macos/Runner/MainFlutterWindow.swift create mode 100644 pkgs/jni/example/macos/Runner/Release.entitlements create mode 100644 pkgs/jni/example/pubspec.lock create mode 100644 pkgs/jni/example/pubspec.yaml create mode 100644 pkgs/jni/example/windows/.gitignore create mode 100644 pkgs/jni/example/windows/CMakeLists.txt create mode 100644 pkgs/jni/example/windows/flutter/CMakeLists.txt create mode 100644 pkgs/jni/example/windows/flutter/generated_plugin_registrant.cc create mode 100644 pkgs/jni/example/windows/flutter/generated_plugin_registrant.h create mode 100644 pkgs/jni/example/windows/flutter/generated_plugins.cmake create mode 100644 pkgs/jni/example/windows/runner/CMakeLists.txt create mode 100644 pkgs/jni/example/windows/runner/Runner.rc create mode 100644 pkgs/jni/example/windows/runner/flutter_window.cpp create mode 100644 pkgs/jni/example/windows/runner/flutter_window.h create mode 100644 pkgs/jni/example/windows/runner/main.cpp create mode 100644 pkgs/jni/example/windows/runner/resource.h create mode 100644 pkgs/jni/example/windows/runner/resources/app_icon.ico create mode 100644 pkgs/jni/example/windows/runner/runner.exe.manifest create mode 100644 pkgs/jni/example/windows/runner/utils.cpp create mode 100644 pkgs/jni/example/windows/runner/utils.h create mode 100644 pkgs/jni/example/windows/runner/win32_window.cpp create mode 100644 pkgs/jni/example/windows/runner/win32_window.h create mode 100644 pkgs/jni/ffigen.yaml create mode 100644 pkgs/jni/lib/jni.dart create mode 100644 pkgs/jni/lib/jni_bindings_generated.dart create mode 100644 pkgs/jni/linux/CMakeLists.txt create mode 100644 pkgs/jni/macos/Classes/jni.c create mode 100644 pkgs/jni/macos/jni.podspec create mode 100644 pkgs/jni/pubspec.yaml create mode 100644 pkgs/jni/src/CMakeLists.txt create mode 100644 pkgs/jni/src/jni.c create mode 100644 pkgs/jni/src/jni.h create mode 100644 pkgs/jni/windows/.gitignore create mode 100644 pkgs/jni/windows/CMakeLists.txt diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index b4cae730a..aa9eccbb4 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -73,3 +73,68 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} path-to-lcov: ./pkgs/jni_gen/coverage/lcov.info + + build_jni_example_linux: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./pkgs/jni/example + steps: + - uses: actions/checkout@v3 + - uses: subosito/flutter-action@v2 + with: + channel: 'stable' + - run: | + sudo apt-get update -y + sudo apt-get install -y ninja-build libgtk-3-dev + - run: flutter config --enable-linux-desktop + - run: flutter pub get + - run: flutter build linux + + build_jni_example_windows: + runs-on: windows-latest + defaults: + run: + working-directory: ./pkgs/jni/example + steps: + - uses: actions/checkout@v3 + - uses: subosito/flutter-action@v2 + with: + channel: 'stable' + - run: flutter config --enable-windows-desktop + - run: flutter pub get + - run: flutter build windows + + build_jni_example_macos: + runs-on: macos-latest + defaults: + run: + working-directory: ./pkgs/jni/example + steps: + - uses: actions/checkout@v3 + - uses: subosito/flutter-action@v2 + with: + channel: 'stable' + architecture: x64 + - run: flutter config --enable-macos-desktop + - run: flutter pub get + - run: flutter build macos + + build_jni_example_android: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./pkgs/jni/example + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v2 + with: + distribution: 'zulu' + java-version: '11' + - uses: subosito/flutter-action@v2 + with: + channel: 'stable' + - run: flutter pub get + - run: flutter build apk + - run: flutter build appbundle + diff --git a/pkgs/jni/.gitignore b/pkgs/jni/.gitignore new file mode 100644 index 000000000..96486fd93 --- /dev/null +++ b/pkgs/jni/.gitignore @@ -0,0 +1,30 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +.packages +build/ diff --git a/pkgs/jni/.metadata b/pkgs/jni/.metadata new file mode 100644 index 000000000..26fc23fe6 --- /dev/null +++ b/pkgs/jni/.metadata @@ -0,0 +1,39 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled. + +version: + revision: 676cefaaff197f27424942307668886253e1ec35 + channel: stable + +project_type: plugin_ffi + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 676cefaaff197f27424942307668886253e1ec35 + base_revision: 676cefaaff197f27424942307668886253e1ec35 + - platform: android + create_revision: 676cefaaff197f27424942307668886253e1ec35 + base_revision: 676cefaaff197f27424942307668886253e1ec35 + - platform: linux + create_revision: 676cefaaff197f27424942307668886253e1ec35 + base_revision: 676cefaaff197f27424942307668886253e1ec35 + - platform: macos + create_revision: 676cefaaff197f27424942307668886253e1ec35 + base_revision: 676cefaaff197f27424942307668886253e1ec35 + - platform: windows + create_revision: 676cefaaff197f27424942307668886253e1ec35 + base_revision: 676cefaaff197f27424942307668886253e1ec35 + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/pkgs/jni/CHANGELOG.md b/pkgs/jni/CHANGELOG.md new file mode 100644 index 000000000..41cc7d819 --- /dev/null +++ b/pkgs/jni/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.0.1 + +* TODO: Describe initial release. diff --git a/pkgs/jni/LICENSE b/pkgs/jni/LICENSE new file mode 100644 index 000000000..33474aad6 --- /dev/null +++ b/pkgs/jni/LICENSE @@ -0,0 +1,27 @@ +Copyright 2022, the Dart project authors. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google LLC nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/pkgs/jni/README.md b/pkgs/jni/README.md new file mode 100644 index 000000000..45ee1cf70 --- /dev/null +++ b/pkgs/jni/README.md @@ -0,0 +1,92 @@ +# jni + +A new Flutter FFI plugin project. + +## Getting Started + +This project is a starting point for a Flutter +[FFI plugin](https://docs.flutter.dev/development/platform-integration/c-interop), +a specialized package that includes native code directly invoked with Dart FFI. + +## Project stucture + +This template uses the following structure: + +* `src`: Contains the native source code, and a CmakeFile.txt file for building + that source code into a dynamic library. + +* `lib`: Contains the Dart code that defines the API of the plugin, and which + calls into the native code using `dart:ffi`. + +* platform folders (`android`, `ios`, `windows`, etc.): Contains the build files + for building and bundling the native code library with the platform application. + +## Buidling and bundling native code + +The `pubspec.yaml` specifies FFI plugins as follows: + +```yaml + plugin: + platforms: + some_platform: + ffiPlugin: true +``` + +This configuration invokes the native build for the various target platforms +and bundles the binaries in Flutter applications using these FFI plugins. + +This can be combined with dartPluginClass, such as when FFI is used for the +implementation of one platform in a federated plugin: + +```yaml + plugin: + implements: some_other_plugin + platforms: + some_platform: + dartPluginClass: SomeClass + ffiPlugin: true +``` + +A plugin can have both FFI and method channels: + +```yaml + plugin: + platforms: + some_platform: + pluginClass: SomeName + ffiPlugin: true +``` + +The native build systems that are invoked by FFI (and method channel) plugins are: + +* For Android: Gradle, which invokes the Android NDK for native builds. + * See the documentation in android/build.gradle. +* For iOS and MacOS: Xcode, via CocoaPods. + * See the documentation in ios/jni.podspec. + * See the documentation in macos/jni.podspec. +* For Linux and Windows: CMake. + * See the documentation in linux/CMakeLists.txt. + * See the documentation in windows/CMakeLists.txt. + +## Binding to native code + +To use the native code, bindings in Dart are needed. +To avoid writing these by hand, they are generated from the header file +(`src/jni.h`) by `package:ffigen`. +Regenerate the bindings by running `flutter pub run ffigen --config ffigen.yaml`. + +## Invoking native code + +Very short-running native functions can be directly invoked from any isolate. +For example, see `sum` in `lib/jni.dart`. + +Longer-running functions should be invoked on a helper isolate to avoid +dropping frames in Flutter applications. +For example, see `sumAsync` in `lib/jni.dart`. + +## Flutter help + +For help getting started with Flutter, view our +[online documentation](https://flutter.dev/docs), which offers tutorials, +samples, guidance on mobile development, and a full API reference. + diff --git a/pkgs/jni/analysis_options.yaml b/pkgs/jni/analysis_options.yaml new file mode 100644 index 000000000..a5744c1cf --- /dev/null +++ b/pkgs/jni/analysis_options.yaml @@ -0,0 +1,4 @@ +include: package:flutter_lints/flutter.yaml + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/pkgs/jni/android/.gitignore b/pkgs/jni/android/.gitignore new file mode 100644 index 000000000..161bdcdaf --- /dev/null +++ b/pkgs/jni/android/.gitignore @@ -0,0 +1,9 @@ +*.iml +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures +.cxx diff --git a/pkgs/jni/android/build.gradle b/pkgs/jni/android/build.gradle new file mode 100644 index 000000000..1fe097a40 --- /dev/null +++ b/pkgs/jni/android/build.gradle @@ -0,0 +1,65 @@ +// The Android Gradle Plugin builds the native code with the Android NDK. + +group 'dev.dart.jni' +version '1.0' + +buildscript { + repositories { + google() + mavenCentral() + } + + dependencies { + // The Android Gradle Plugin knows how to build native code with the NDK. + classpath 'com.android.tools.build:gradle:7.1.2' + } +} + +rootProject.allprojects { + repositories { + google() + mavenCentral() + } +} + +apply plugin: 'com.android.library' + +android { + // Bumping the plugin compileSdkVersion requires all clients of this plugin + // to bump the version in their app. + compileSdkVersion 31 + + // Bumping the plugin ndkVersion requires all clients of this plugin to bump + // the version in their app and to download a newer version of the NDK. + + // Note(MaheshH): Seems 22 is lowest one can get through SDKManager now? + // + // It's more of a logistic issue, I can't download NDK 21, so keeping it + // 22. You might get a warning to bump some versions. + ndkVersion "22.1.7171670" + // ndkVersion "21.1.6352462" + + // Invoke the shared CMake build with the Android Gradle Plugin. + externalNativeBuild { + cmake { + path "../src/CMakeLists.txt" + + // The default CMake version for the Android Gradle Plugin is 3.10.2. + // https://developer.android.com/studio/projects/install-ndk#vanilla_cmake + // + // The Flutter tooling requires that developers have CMake 3.10 or later + // installed. You should not increase this version, as doing so will cause + // the plugin to fail to compile for some customers of the plugin. + // version "3.10.2" + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + defaultConfig { + minSdkVersion 16 + } +} diff --git a/pkgs/jni/android/settings.gradle b/pkgs/jni/android/settings.gradle new file mode 100644 index 000000000..ac55455a7 --- /dev/null +++ b/pkgs/jni/android/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'jni' diff --git a/pkgs/jni/android/src/main/AndroidManifest.xml b/pkgs/jni/android/src/main/AndroidManifest.xml new file mode 100644 index 000000000..8055f584a --- /dev/null +++ b/pkgs/jni/android/src/main/AndroidManifest.xml @@ -0,0 +1,3 @@ + + diff --git a/pkgs/jni/example/.gitignore b/pkgs/jni/example/.gitignore new file mode 100644 index 000000000..a8e938c08 --- /dev/null +++ b/pkgs/jni/example/.gitignore @@ -0,0 +1,47 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ +/build/ + +# Web related +lib/generated_plugin_registrant.dart + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/pkgs/jni/example/README.md b/pkgs/jni/example/README.md new file mode 100644 index 000000000..80af081ac --- /dev/null +++ b/pkgs/jni/example/README.md @@ -0,0 +1,16 @@ +# jni_example + +Demonstrates how to use the jni plugin. + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) + +For help getting started with Flutter development, view the +[online documentation](https://docs.flutter.dev/), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/pkgs/jni/example/analysis_options.yaml b/pkgs/jni/example/analysis_options.yaml new file mode 100644 index 000000000..61b6c4de1 --- /dev/null +++ b/pkgs/jni/example/analysis_options.yaml @@ -0,0 +1,29 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at + # https://dart-lang.github.io/linter/lints/index.html. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/pkgs/jni/example/android/.gitignore b/pkgs/jni/example/android/.gitignore new file mode 100644 index 000000000..6f568019d --- /dev/null +++ b/pkgs/jni/example/android/.gitignore @@ -0,0 +1,13 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +key.properties +**/*.keystore +**/*.jks diff --git a/pkgs/jni/example/android/app/build.gradle b/pkgs/jni/example/android/app/build.gradle new file mode 100644 index 000000000..468be1348 --- /dev/null +++ b/pkgs/jni/example/android/app/build.gradle @@ -0,0 +1,71 @@ +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterRoot = localProperties.getProperty('flutter.sdk') +if (flutterRoot == null) { + throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" + +android { + compileSdkVersion flutter.compileSdkVersion + ndkVersion flutter.ndkVersion + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId "dev.dart.jni_example" + // You can update the following values to match your application needs. + // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. + minSdkVersion flutter.minSdkVersion + targetSdkVersion flutter.targetSdkVersion + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.debug + } + } +} + +flutter { + source '../..' +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" +} diff --git a/pkgs/jni/example/android/app/src/debug/AndroidManifest.xml b/pkgs/jni/example/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 000000000..2b66dc274 --- /dev/null +++ b/pkgs/jni/example/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,8 @@ + + + + diff --git a/pkgs/jni/example/android/app/src/main/AndroidManifest.xml b/pkgs/jni/example/android/app/src/main/AndroidManifest.xml new file mode 100644 index 000000000..21d2c5cbd --- /dev/null +++ b/pkgs/jni/example/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/pkgs/jni/example/android/app/src/main/kotlin/dev/dart/jni_example/MainActivity.kt b/pkgs/jni/example/android/app/src/main/kotlin/dev/dart/jni_example/MainActivity.kt new file mode 100644 index 000000000..494cfa0e8 --- /dev/null +++ b/pkgs/jni/example/android/app/src/main/kotlin/dev/dart/jni_example/MainActivity.kt @@ -0,0 +1,6 @@ +package dev.dart.jni_example + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() { +} diff --git a/pkgs/jni/example/android/app/src/main/res/drawable-v21/launch_background.xml b/pkgs/jni/example/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 000000000..f74085f3f --- /dev/null +++ b/pkgs/jni/example/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/pkgs/jni/example/android/app/src/main/res/drawable/launch_background.xml b/pkgs/jni/example/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 000000000..304732f88 --- /dev/null +++ b/pkgs/jni/example/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/pkgs/jni/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/pkgs/jni/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..db77bb4b7b0906d62b1847e87f15cdcacf6a4f29 GIT binary patch literal 544 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY3?!3`olAj~WQl7;NpOBzNqJ&XDuZK6ep0G} zXKrG8YEWuoN@d~6R2!h8bpbvhu0Wd6uZuB!w&u2PAxD2eNXD>P5D~Wn-+_Wa#27Xc zC?Zj|6r#X(-D3u$NCt}(Ms06KgJ4FxJVv{GM)!I~&n8Bnc94O7-Hd)cjDZswgC;Qs zO=b+9!WcT8F?0rF7!Uys2bs@gozCP?z~o%U|N3vA*22NaGQG zlg@K`O_XuxvZ&Ks^m&R!`&1=spLvfx7oGDKDwpwW`#iqdw@AL`7MR}m`rwr|mZgU`8P7SBkL78fFf!WnuYWm$5Z0 zNXhDbCv&49sM544K|?c)WrFfiZvCi9h0O)B3Pgg&ebxsLQ05GG~ AQ2+n{ literal 0 HcmV?d00001 diff --git a/pkgs/jni/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/pkgs/jni/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..17987b79bb8a35cc66c3c1fd44f5a5526c1b78be GIT binary patch literal 442 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA3?vioaBc-sk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5Xx&nMcT!A!W`0S9QKQy;}1Cl^CgaH=;G9cpY;r$Q>i*pfB zP2drbID<_#qf;rPZx^FqH)F_D#*k@@q03KywUtLX8Ua?`H+NMzkczFPK3lFz@i_kW%1NOn0|D2I9n9wzH8m|-tHjsw|9>@K=iMBhxvkv6m8Y-l zytQ?X=U+MF$@3 zt`~i=@j|6y)RWMK--}M|=T`o&^Ni>IoWKHEbBXz7?A@mgWoL>!*SXo`SZH-*HSdS+ yn*9;$7;m`l>wYBC5bq;=U}IMqLzqbYCidGC!)_gkIk_C@Uy!y&wkt5C($~2D>~)O*cj@FGjOCM)M>_ixfudOh)?xMu#Fs z#}Y=@YDTwOM)x{K_j*Q;dPdJ?Mz0n|pLRx{4n|)f>SXlmV)XB04CrSJn#dS5nK2lM zrZ9#~WelCp7&e13Y$jvaEXHskn$2V!!DN-nWS__6T*l;H&Fopn?A6HZ-6WRLFP=R` zqG+CE#d4|IbyAI+rJJ`&x9*T`+a=p|0O(+s{UBcyZdkhj=yS1>AirP+0R;mf2uMgM zC}@~JfByORAh4SyRgi&!(cja>F(l*O+nd+@4m$|6K6KDn_&uvCpV23&>G9HJp{xgg zoq1^2_p9@|WEo z*X_Uko@K)qYYv~>43eQGMdbiGbo>E~Q& zrYBH{QP^@Sti!`2)uG{irBBq@y*$B zi#&(U-*=fp74j)RyIw49+0MRPMRU)+a2r*PJ$L5roHt2$UjExCTZSbq%V!HeS7J$N zdG@vOZB4v_lF7Plrx+hxo7(fCV&}fHq)$ literal 0 HcmV?d00001 diff --git a/pkgs/jni/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/pkgs/jni/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..d5f1c8d34e7a88e3f88bea192c3a370d44689c3c GIT binary patch literal 1031 zcmeAS@N?(olHy`uVBq!ia0vp^6F``Q8Ax83A=Cw=BuiW)N`mv#O3D+9QW+dm@{>{( zJaZG%Q-e|yQz{EjrrIztFa`(sgt!6~Yi|1%a`XoT0ojZ}lNrNjb9xjc(B0U1_% zz5^97Xt*%oq$rQy4?0GKNfJ44uvxI)gC`h-NZ|&0-7(qS@?b!5r36oQ}zyZrNO3 zMO=Or+<~>+A&uN&E!^Sl+>xE!QC-|oJv`ApDhqC^EWD|@=#J`=d#Xzxs4ah}w&Jnc z$|q_opQ^2TrnVZ0o~wh<3t%W&flvYGe#$xqda2bR_R zvPYgMcHgjZ5nSA^lJr%;<&0do;O^tDDh~=pIxA#coaCY>&N%M2^tq^U%3DB@ynvKo}b?yu-bFc-u0JHzced$sg7S3zqI(2 z#Km{dPr7I=pQ5>FuK#)QwK?Y`E`B?nP+}U)I#c1+FM*1kNvWG|a(TpksZQ3B@sD~b zpQ2)*V*TdwjFOtHvV|;OsiDqHi=6%)o4b!)x$)%9pGTsE z-JL={-Ffv+T87W(Xpooq<`r*VzWQcgBN$$`u}f>-ZQI1BB8ykN*=e4rIsJx9>z}*o zo~|9I;xof literal 0 HcmV?d00001 diff --git a/pkgs/jni/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/pkgs/jni/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..4d6372eebdb28e45604e46eeda8dd24651419bc0 GIT binary patch literal 1443 zcmb`G{WsKk6vsdJTdFg%tJav9_E4vzrOaqkWF|A724Nly!y+?N9`YV6wZ}5(X(D_N(?!*n3`|_r0Hc?=PQw&*vnU?QTFY zB_MsH|!j$PP;I}?dppoE_gA(4uc!jV&0!l7_;&p2^pxNo>PEcNJv za5_RT$o2Mf!<+r?&EbHH6nMoTsDOa;mN(wv8RNsHpG)`^ymG-S5By8=l9iVXzN_eG%Xg2@Xeq76tTZ*dGh~Lo9vl;Zfs+W#BydUw zCkZ$o1LqWQO$FC9aKlLl*7x9^0q%0}$OMlp@Kk_jHXOjofdePND+j!A{q!8~Jn+s3 z?~~w@4?egS02}8NuulUA=L~QQfm;MzCGd)XhiftT;+zFO&JVyp2mBww?;QByS_1w! zrQlx%{^cMj0|Bo1FjwY@Q8?Hx0cIPF*@-ZRFpPc#bBw{5@tD(5%sClzIfl8WU~V#u zm5Q;_F!wa$BSpqhN>W@2De?TKWR*!ujY;Yylk_X5#~V!L*Gw~;$%4Q8~Mad z@`-kG?yb$a9cHIApZDVZ^U6Xkp<*4rU82O7%}0jjHlK{id@?-wpN*fCHXyXh(bLt* zPc}H-x0e4E&nQ>y%B-(EL=9}RyC%MyX=upHuFhAk&MLbsF0LP-q`XnH78@fT+pKPW zu72MW`|?8ht^tz$iC}ZwLp4tB;Q49K!QCF3@!iB1qOI=?w z7In!}F~ij(18UYUjnbmC!qKhPo%24?8U1x{7o(+?^Zu0Hx81|FuS?bJ0jgBhEMzf< zCgUq7r2OCB(`XkKcN-TL>u5y#dD6D!)5W?`O5)V^>jb)P)GBdy%t$uUMpf$SNV31$ zb||OojAbvMP?T@$h_ZiFLFVHDmbyMhJF|-_)HX3%m=CDI+ID$0^C>kzxprBW)hw(v zr!Gmda);ICoQyhV_oP5+C%?jcG8v+D@9f?Dk*!BxY}dazmrT@64UrP3hlslANK)bq z$67n83eh}OeW&SV@HG95P|bjfqJ7gw$e+`Hxo!4cx`jdK1bJ>YDSpGKLPZ^1cv$ek zIB?0S<#tX?SJCLWdMd{-ME?$hc7A$zBOdIJ)4!KcAwb=VMov)nK;9z>x~rfT1>dS+ zZ6#`2v@`jgbqq)P22H)Tx2CpmM^o1$B+xT6`(v%5xJ(?j#>Q$+rx_R|7TzDZe{J6q zG1*EcU%tE?!kO%^M;3aM6JN*LAKUVb^xz8-Pxo#jR5(-KBeLJvA@-gxNHx0M-ZJLl z;#JwQoh~9V?`UVo#}{6ka@II>++D@%KqGpMdlQ}?9E*wFcf5(#XQnP$Dk5~%iX^>f z%$y;?M0BLp{O3a(-4A?ewryHrrD%cx#Q^%KY1H zNre$ve+vceSLZcNY4U(RBX&)oZn*Py()h)XkE?PL$!bNb{N5FVI2Y%LKEm%yvpyTP z(1P?z~7YxD~Rf<(a@_y` literal 0 HcmV?d00001 diff --git a/pkgs/jni/example/android/app/src/main/res/values-night/styles.xml b/pkgs/jni/example/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 000000000..06952be74 --- /dev/null +++ b/pkgs/jni/example/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/pkgs/jni/example/android/app/src/main/res/values/styles.xml b/pkgs/jni/example/android/app/src/main/res/values/styles.xml new file mode 100644 index 000000000..cb1ef8805 --- /dev/null +++ b/pkgs/jni/example/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/pkgs/jni/example/android/app/src/profile/AndroidManifest.xml b/pkgs/jni/example/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 000000000..2b66dc274 --- /dev/null +++ b/pkgs/jni/example/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,8 @@ + + + + diff --git a/pkgs/jni/example/android/build.gradle b/pkgs/jni/example/android/build.gradle new file mode 100644 index 000000000..83ae22004 --- /dev/null +++ b/pkgs/jni/example/android/build.gradle @@ -0,0 +1,31 @@ +buildscript { + ext.kotlin_version = '1.6.10' + repositories { + google() + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:7.1.2' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = '../build' +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(':app') +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/pkgs/jni/example/android/gradle.properties b/pkgs/jni/example/android/gradle.properties new file mode 100644 index 000000000..94adc3a3f --- /dev/null +++ b/pkgs/jni/example/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx1536M +android.useAndroidX=true +android.enableJetifier=true diff --git a/pkgs/jni/example/android/gradle/wrapper/gradle-wrapper.properties b/pkgs/jni/example/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..cc5527d78 --- /dev/null +++ b/pkgs/jni/example/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Fri Jun 23 08:50:38 CEST 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip diff --git a/pkgs/jni/example/android/settings.gradle b/pkgs/jni/example/android/settings.gradle new file mode 100644 index 000000000..44e62bcf0 --- /dev/null +++ b/pkgs/jni/example/android/settings.gradle @@ -0,0 +1,11 @@ +include ':app' + +def localPropertiesFile = new File(rootProject.projectDir, "local.properties") +def properties = new Properties() + +assert localPropertiesFile.exists() +localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + +def flutterSdkPath = properties.getProperty("flutter.sdk") +assert flutterSdkPath != null, "flutter.sdk not set in local.properties" +apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" diff --git a/pkgs/jni/example/lib/main.dart b/pkgs/jni/example/lib/main.dart new file mode 100644 index 000000000..9f4f90381 --- /dev/null +++ b/pkgs/jni/example/lib/main.dart @@ -0,0 +1,74 @@ +import 'package:flutter/material.dart'; +import 'dart:async'; + +import 'package:jni/jni.dart' as jni; + +void main() { + runApp(const MyApp()); +} + +class MyApp extends StatefulWidget { + const MyApp({Key? key}) : super(key: key); + + @override + _MyAppState createState() => _MyAppState(); +} + +class _MyAppState extends State { + late int sumResult; + late Future sumAsyncResult; + + @override + void initState() { + super.initState(); + sumResult = jni.sum(1, 2); + sumAsyncResult = jni.sumAsync(3, 4); + } + + @override + Widget build(BuildContext context) { + const textStyle = TextStyle(fontSize: 25); + const spacerSmall = SizedBox(height: 10); + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('Native Packages'), + ), + body: SingleChildScrollView( + child: Container( + padding: const EdgeInsets.all(10), + child: Column( + children: [ + const Text( + 'This calls a native function through FFI that is shipped as source in the package. ' + 'The native code is built as part of the Flutter Runner build.', + style: textStyle, + textAlign: TextAlign.center, + ), + spacerSmall, + Text( + 'sum(1, 2) = $sumResult', + style: textStyle, + textAlign: TextAlign.center, + ), + spacerSmall, + FutureBuilder( + future: sumAsyncResult, + builder: (BuildContext context, AsyncSnapshot value) { + final displayValue = + (value.hasData) ? value.data : 'loading'; + return Text( + 'await sumAsync(3, 4) = $displayValue', + style: textStyle, + textAlign: TextAlign.center, + ); + }, + ), + ], + ), + ), + ), + ), + ); + } +} diff --git a/pkgs/jni/example/linux/.gitignore b/pkgs/jni/example/linux/.gitignore new file mode 100644 index 000000000..d3896c984 --- /dev/null +++ b/pkgs/jni/example/linux/.gitignore @@ -0,0 +1 @@ +flutter/ephemeral diff --git a/pkgs/jni/example/linux/CMakeLists.txt b/pkgs/jni/example/linux/CMakeLists.txt new file mode 100644 index 000000000..edcebfd5d --- /dev/null +++ b/pkgs/jni/example/linux/CMakeLists.txt @@ -0,0 +1,138 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.10) +project(runner LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "jni_example") +# The unique GTK application identifier for this application. See: +# https://wiki.gnome.org/HowDoI/ChooseApplicationID +set(APPLICATION_ID "dev.dart.jni") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(SET CMP0063 NEW) + +# Load bundled libraries from the lib/ directory relative to the binary. +set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") + +# Root filesystem for cross-building. +if(FLUTTER_TARGET_PLATFORM_SYSROOT) + set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endif() + +# Define build configuration options. +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") +endif() + +# Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_14) + target_compile_options(${TARGET} PRIVATE -Wall -Werror) + target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") + target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) + +add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") + +# Define the application target. To change its name, change BINARY_NAME above, +# not the value here, or `flutter run` will no longer work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} + "main.cc" + "my_application.cc" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add dependency libraries. Add any application-specific dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter) +target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) + +# Only the install-generated bundle's copy of the executable will launch +# correctly, since the resources must in the right relative locations. To avoid +# people trying to run the unbundled copy, put it in a subdirectory instead of +# the default top-level location. +set_target_properties(${BINARY_NAME} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" +) + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# By default, "installing" just makes a relocatable bundle in the build +# directory. +set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +# Start with a clean build bundle directory every time. +install(CODE " + file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") + " COMPONENT Runtime) + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) + install(FILES "${bundled_library}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endforeach(bundled_library) + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") + install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() diff --git a/pkgs/jni/example/linux/flutter/CMakeLists.txt b/pkgs/jni/example/linux/flutter/CMakeLists.txt new file mode 100644 index 000000000..d5bd01648 --- /dev/null +++ b/pkgs/jni/example/linux/flutter/CMakeLists.txt @@ -0,0 +1,88 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.10) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. + +# Serves the same purpose as list(TRANSFORM ... PREPEND ...), +# which isn't available in 3.10. +function(list_prepend LIST_NAME PREFIX) + set(NEW_LIST "") + foreach(element ${${LIST_NAME}}) + list(APPEND NEW_LIST "${PREFIX}${element}") + endforeach(element) + set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) +endfunction() + +# === Flutter Library === +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) +pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) +pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) + +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "fl_basic_message_channel.h" + "fl_binary_codec.h" + "fl_binary_messenger.h" + "fl_dart_project.h" + "fl_engine.h" + "fl_json_message_codec.h" + "fl_json_method_codec.h" + "fl_message_codec.h" + "fl_method_call.h" + "fl_method_channel.h" + "fl_method_codec.h" + "fl_method_response.h" + "fl_plugin_registrar.h" + "fl_plugin_registry.h" + "fl_standard_message_codec.h" + "fl_standard_method_codec.h" + "fl_string_codec.h" + "fl_value.h" + "fl_view.h" + "flutter_linux.h" +) +list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") +target_link_libraries(flutter INTERFACE + PkgConfig::GTK + PkgConfig::GLIB + PkgConfig::GIO +) +add_dependencies(flutter flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CMAKE_CURRENT_BINARY_DIR}/_phony_ + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" + ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} +) diff --git a/pkgs/jni/example/linux/flutter/generated_plugin_registrant.cc b/pkgs/jni/example/linux/flutter/generated_plugin_registrant.cc new file mode 100644 index 000000000..e71a16d23 --- /dev/null +++ b/pkgs/jni/example/linux/flutter/generated_plugin_registrant.cc @@ -0,0 +1,11 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + + +void fl_register_plugins(FlPluginRegistry* registry) { +} diff --git a/pkgs/jni/example/linux/flutter/generated_plugin_registrant.h b/pkgs/jni/example/linux/flutter/generated_plugin_registrant.h new file mode 100644 index 000000000..e0f0a47bc --- /dev/null +++ b/pkgs/jni/example/linux/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void fl_register_plugins(FlPluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/pkgs/jni/example/linux/flutter/generated_plugins.cmake b/pkgs/jni/example/linux/flutter/generated_plugins.cmake new file mode 100644 index 000000000..be1ee3e5b --- /dev/null +++ b/pkgs/jni/example/linux/flutter/generated_plugins.cmake @@ -0,0 +1,24 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST + jni +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/pkgs/jni/example/linux/main.cc b/pkgs/jni/example/linux/main.cc new file mode 100644 index 000000000..e7c5c5437 --- /dev/null +++ b/pkgs/jni/example/linux/main.cc @@ -0,0 +1,6 @@ +#include "my_application.h" + +int main(int argc, char** argv) { + g_autoptr(MyApplication) app = my_application_new(); + return g_application_run(G_APPLICATION(app), argc, argv); +} diff --git a/pkgs/jni/example/linux/my_application.cc b/pkgs/jni/example/linux/my_application.cc new file mode 100644 index 000000000..342054282 --- /dev/null +++ b/pkgs/jni/example/linux/my_application.cc @@ -0,0 +1,104 @@ +#include "my_application.h" + +#include +#ifdef GDK_WINDOWING_X11 +#include +#endif + +#include "flutter/generated_plugin_registrant.h" + +struct _MyApplication { + GtkApplication parent_instance; + char** dart_entrypoint_arguments; +}; + +G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) + +// Implements GApplication::activate. +static void my_application_activate(GApplication* application) { + MyApplication* self = MY_APPLICATION(application); + GtkWindow* window = + GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); + + // Use a header bar when running in GNOME as this is the common style used + // by applications and is the setup most users will be using (e.g. Ubuntu + // desktop). + // If running on X and not using GNOME then just use a traditional title bar + // in case the window manager does more exotic layout, e.g. tiling. + // If running on Wayland assume the header bar will work (may need changing + // if future cases occur). + gboolean use_header_bar = TRUE; +#ifdef GDK_WINDOWING_X11 + GdkScreen* screen = gtk_window_get_screen(window); + if (GDK_IS_X11_SCREEN(screen)) { + const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); + if (g_strcmp0(wm_name, "GNOME Shell") != 0) { + use_header_bar = FALSE; + } + } +#endif + if (use_header_bar) { + GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); + gtk_widget_show(GTK_WIDGET(header_bar)); + gtk_header_bar_set_title(header_bar, "jni_example"); + gtk_header_bar_set_show_close_button(header_bar, TRUE); + gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); + } else { + gtk_window_set_title(window, "jni_example"); + } + + gtk_window_set_default_size(window, 1280, 720); + gtk_widget_show(GTK_WIDGET(window)); + + g_autoptr(FlDartProject) project = fl_dart_project_new(); + fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); + + FlView* view = fl_view_new(project); + gtk_widget_show(GTK_WIDGET(view)); + gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); + + fl_register_plugins(FL_PLUGIN_REGISTRY(view)); + + gtk_widget_grab_focus(GTK_WIDGET(view)); +} + +// Implements GApplication::local_command_line. +static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { + MyApplication* self = MY_APPLICATION(application); + // Strip out the first argument as it is the binary name. + self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); + + g_autoptr(GError) error = nullptr; + if (!g_application_register(application, nullptr, &error)) { + g_warning("Failed to register: %s", error->message); + *exit_status = 1; + return TRUE; + } + + g_application_activate(application); + *exit_status = 0; + + return TRUE; +} + +// Implements GObject::dispose. +static void my_application_dispose(GObject* object) { + MyApplication* self = MY_APPLICATION(object); + g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); + G_OBJECT_CLASS(my_application_parent_class)->dispose(object); +} + +static void my_application_class_init(MyApplicationClass* klass) { + G_APPLICATION_CLASS(klass)->activate = my_application_activate; + G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; + G_OBJECT_CLASS(klass)->dispose = my_application_dispose; +} + +static void my_application_init(MyApplication* self) {} + +MyApplication* my_application_new() { + return MY_APPLICATION(g_object_new(my_application_get_type(), + "application-id", APPLICATION_ID, + "flags", G_APPLICATION_NON_UNIQUE, + nullptr)); +} diff --git a/pkgs/jni/example/linux/my_application.h b/pkgs/jni/example/linux/my_application.h new file mode 100644 index 000000000..72271d5e4 --- /dev/null +++ b/pkgs/jni/example/linux/my_application.h @@ -0,0 +1,18 @@ +#ifndef FLUTTER_MY_APPLICATION_H_ +#define FLUTTER_MY_APPLICATION_H_ + +#include + +G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, + GtkApplication) + +/** + * my_application_new: + * + * Creates a new Flutter-based application. + * + * Returns: a new #MyApplication. + */ +MyApplication* my_application_new(); + +#endif // FLUTTER_MY_APPLICATION_H_ diff --git a/pkgs/jni/example/macos/.gitignore b/pkgs/jni/example/macos/.gitignore new file mode 100644 index 000000000..746adbb6b --- /dev/null +++ b/pkgs/jni/example/macos/.gitignore @@ -0,0 +1,7 @@ +# Flutter-related +**/Flutter/ephemeral/ +**/Pods/ + +# Xcode-related +**/dgph +**/xcuserdata/ diff --git a/pkgs/jni/example/macos/Flutter/Flutter-Debug.xcconfig b/pkgs/jni/example/macos/Flutter/Flutter-Debug.xcconfig new file mode 100644 index 000000000..c2efd0b60 --- /dev/null +++ b/pkgs/jni/example/macos/Flutter/Flutter-Debug.xcconfig @@ -0,0 +1 @@ +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/pkgs/jni/example/macos/Flutter/Flutter-Release.xcconfig b/pkgs/jni/example/macos/Flutter/Flutter-Release.xcconfig new file mode 100644 index 000000000..c2efd0b60 --- /dev/null +++ b/pkgs/jni/example/macos/Flutter/Flutter-Release.xcconfig @@ -0,0 +1 @@ +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/pkgs/jni/example/macos/Flutter/GeneratedPluginRegistrant.swift b/pkgs/jni/example/macos/Flutter/GeneratedPluginRegistrant.swift new file mode 100644 index 000000000..cccf817a5 --- /dev/null +++ b/pkgs/jni/example/macos/Flutter/GeneratedPluginRegistrant.swift @@ -0,0 +1,10 @@ +// +// Generated file. Do not edit. +// + +import FlutterMacOS +import Foundation + + +func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { +} diff --git a/pkgs/jni/example/macos/Runner.xcodeproj/project.pbxproj b/pkgs/jni/example/macos/Runner.xcodeproj/project.pbxproj new file mode 100644 index 000000000..79f7a2099 --- /dev/null +++ b/pkgs/jni/example/macos/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,572 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 51; + objects = { + +/* Begin PBXAggregateTarget section */ + 33CC111A2044C6BA0003C045 /* Flutter Assemble */ = { + isa = PBXAggregateTarget; + buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */; + buildPhases = ( + 33CC111E2044C6BF0003C045 /* ShellScript */, + ); + dependencies = ( + ); + name = "Flutter Assemble"; + productName = FLX; + }; +/* End PBXAggregateTarget section */ + +/* Begin PBXBuildFile section */ + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; }; + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; }; + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 33CC10E52044A3C60003C045 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 33CC111A2044C6BA0003C045; + remoteInfo = FLX; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 33CC110E2044A8840003C045 /* Bundle Framework */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Bundle Framework"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; + 33CC10ED2044A3C60003C045 /* jni_example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "jni_example.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; + 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; + 33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = ""; }; + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = ""; }; + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; + 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; + 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; + 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 33CC10EA2044A3C60003C045 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 33BA886A226E78AF003329D5 /* Configs */ = { + isa = PBXGroup; + children = ( + 33E5194F232828860026EE4D /* AppInfo.xcconfig */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */, + ); + path = Configs; + sourceTree = ""; + }; + 33CC10E42044A3C60003C045 = { + isa = PBXGroup; + children = ( + 33FAB671232836740065AC1E /* Runner */, + 33CEB47122A05771004F2AC0 /* Flutter */, + 33CC10EE2044A3C60003C045 /* Products */, + D73912EC22F37F3D000D13A0 /* Frameworks */, + ); + sourceTree = ""; + }; + 33CC10EE2044A3C60003C045 /* Products */ = { + isa = PBXGroup; + children = ( + 33CC10ED2044A3C60003C045 /* jni_example.app */, + ); + name = Products; + sourceTree = ""; + }; + 33CC11242044D66E0003C045 /* Resources */ = { + isa = PBXGroup; + children = ( + 33CC10F22044A3C60003C045 /* Assets.xcassets */, + 33CC10F42044A3C60003C045 /* MainMenu.xib */, + 33CC10F72044A3C60003C045 /* Info.plist */, + ); + name = Resources; + path = ..; + sourceTree = ""; + }; + 33CEB47122A05771004F2AC0 /* Flutter */ = { + isa = PBXGroup; + children = ( + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */, + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, + ); + path = Flutter; + sourceTree = ""; + }; + 33FAB671232836740065AC1E /* Runner */ = { + isa = PBXGroup; + children = ( + 33CC10F02044A3C60003C045 /* AppDelegate.swift */, + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */, + 33E51913231747F40026EE4D /* DebugProfile.entitlements */, + 33E51914231749380026EE4D /* Release.entitlements */, + 33CC11242044D66E0003C045 /* Resources */, + 33BA886A226E78AF003329D5 /* Configs */, + ); + path = Runner; + sourceTree = ""; + }; + D73912EC22F37F3D000D13A0 /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 33CC10EC2044A3C60003C045 /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 33CC10E92044A3C60003C045 /* Sources */, + 33CC10EA2044A3C60003C045 /* Frameworks */, + 33CC10EB2044A3C60003C045 /* Resources */, + 33CC110E2044A8840003C045 /* Bundle Framework */, + 3399D490228B24CF009A79C7 /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + 33CC11202044C79F0003C045 /* PBXTargetDependency */, + ); + name = Runner; + productName = Runner; + productReference = 33CC10ED2044A3C60003C045 /* jni_example.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 33CC10E52044A3C60003C045 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0920; + LastUpgradeCheck = 1300; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 33CC10EC2044A3C60003C045 = { + CreatedOnToolsVersion = 9.2; + LastSwiftMigration = 1100; + ProvisioningStyle = Automatic; + SystemCapabilities = { + com.apple.Sandbox = { + enabled = 1; + }; + }; + }; + 33CC111A2044C6BA0003C045 = { + CreatedOnToolsVersion = 9.2; + ProvisioningStyle = Manual; + }; + }; + }; + buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 33CC10E42044A3C60003C045; + productRefGroup = 33CC10EE2044A3C60003C045 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 33CC10EC2044A3C60003C045 /* Runner */, + 33CC111A2044C6BA0003C045 /* Flutter Assemble */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 33CC10EB2044A3C60003C045 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */, + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3399D490228B24CF009A79C7 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; + }; + 33CC111E2044C6BF0003C045 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + Flutter/ephemeral/FlutterInputs.xcfilelist, + ); + inputPaths = ( + Flutter/ephemeral/tripwire, + ); + outputFileListPaths = ( + Flutter/ephemeral/FlutterOutputs.xcfilelist, + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 33CC10E92044A3C60003C045 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */, + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */, + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 33CC11202044C79F0003C045 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */; + targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 33CC10F42044A3C60003C045 /* MainMenu.xib */ = { + isa = PBXVariantGroup; + children = ( + 33CC10F52044A3C60003C045 /* Base */, + ); + name = MainMenu.xib; + path = Runner; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 338D0CE9231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Profile; + }; + 338D0CEA231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Profile; + }; + 338D0CEB231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Profile; + }; + 33CC10F92044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 33CC10FA2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + 33CC10FC2044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 33CC10FD2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + 33CC111C2044C6BA0003C045 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 33CC111D2044C6BA0003C045 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10F92044A3C60003C045 /* Debug */, + 33CC10FA2044A3C60003C045 /* Release */, + 338D0CE9231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10FC2044A3C60003C045 /* Debug */, + 33CC10FD2044A3C60003C045 /* Release */, + 338D0CEA231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC111C2044C6BA0003C045 /* Debug */, + 33CC111D2044C6BA0003C045 /* Release */, + 338D0CEB231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 33CC10E52044A3C60003C045 /* Project object */; +} diff --git a/pkgs/jni/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/pkgs/jni/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000..18d981003 --- /dev/null +++ b/pkgs/jni/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/pkgs/jni/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/pkgs/jni/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 000000000..2b12d610f --- /dev/null +++ b/pkgs/jni/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pkgs/jni/example/macos/Runner.xcworkspace/contents.xcworkspacedata b/pkgs/jni/example/macos/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..1d526a16e --- /dev/null +++ b/pkgs/jni/example/macos/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/pkgs/jni/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/pkgs/jni/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000..18d981003 --- /dev/null +++ b/pkgs/jni/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/pkgs/jni/example/macos/Runner/AppDelegate.swift b/pkgs/jni/example/macos/Runner/AppDelegate.swift new file mode 100644 index 000000000..d53ef6437 --- /dev/null +++ b/pkgs/jni/example/macos/Runner/AppDelegate.swift @@ -0,0 +1,9 @@ +import Cocoa +import FlutterMacOS + +@NSApplicationMain +class AppDelegate: FlutterAppDelegate { + override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { + return true + } +} diff --git a/pkgs/jni/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/pkgs/jni/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 000000000..a2ec33f19 --- /dev/null +++ b/pkgs/jni/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,68 @@ +{ + "images" : [ + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_16.png", + "scale" : "1x" + }, + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "2x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "1x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_64.png", + "scale" : "2x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_128.png", + "scale" : "1x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "2x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "1x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "2x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "1x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_1024.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/pkgs/jni/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png b/pkgs/jni/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png new file mode 100644 index 0000000000000000000000000000000000000000..3c4935a7ca84f0976aca34b7f2895d65fb94d1ea GIT binary patch literal 46993 zcmZ5|3p`X?`~OCwR3s6~xD(})N~M}fiXn6%NvKp3QYhuNN0*apqmfHdR7#ShNQ99j zQi+P9nwlXbmnktZ_WnO>bl&&<{m*;O=RK!cd#$zCdM@AR`#jH%+2~+BeX7b-48x|= zZLBt9*d+MZNtpCx_&asa{+CselLUV<<&ceQ5QfRjLjQDSL-t4eq}5znmIXDtfA|D+VRV$*2jxU)JopC)!37FtD<6L^&{ia zgVf1p(e;c3|HY;%uD5<-oSFkC2JRh- z&2RTL)HBG`)j5di8ys|$z_9LSm^22*uH-%MmUJs|nHKLHxy4xTmG+)JoA`BN7#6IN zK-ylvs+~KN#4NWaH~o5Wuwd@W?H@diExdcTl0!JJq9ZOA24b|-TkkeG=Q(pJw7O;i z`@q+n|@eeW7@ z&*NP+)wOyu^5oNJ=yi4~s_+N)#M|@8nfw=2#^BpML$~dJ6yu}2JNuq!)!;Uwxic(z zM@Wa-v|U{v|GX4;P+s#=_1PD7h<%8ey$kxVsS1xt&%8M}eOF98&Rx7W<)gY(fCdmo{y*FPC{My!t`i=PS1cdV7DD=3S1J?b2<5BevW7!rWJ%6Q?D9UljULd*7SxX05PP^5AklWu^y` z-m9&Oq-XNSRjd|)hZ44DK?3>G%kFHSJ8|ZXbAcRb`gH~jk}Iwkl$@lqg!vu)ihSl= zjhBh%%Hq|`Vm>T7+SYyf4bI-MgiBq4mZlZmsKv+S>p$uAOoNxPT)R6owU%t*#aV}B z5@)X8nhtaBhH=={w;Du=-S*xvcPz26EI!gt{(hf;TllHrvku`^8wMj7-9=By>n{b= zHzQ?Wn|y=;)XM#St@o%#8idxfc`!oVz@Lv_=y(t-kUC`W)c0H2TX}Lop4121;RHE(PPHKfe_e_@DoHiPbVP%JzNudGc$|EnIv`qww1F5HwF#@l(=V zyM!JQO>Rt_PTRF1hI|u^2Uo#w*rdF*LXJky0?|fhl4-M%zN_2RP#HFhSATE3&{sos zIE_?MdIn!sUH*vjs(teJ$7^7#|M_7m`T>r>qHw>TQh?yhhc8=TJk2B;KNXw3HhnQs za(Uaz2VwP;82rTy(T3FJNKA86Y7;L(K=~BW_Q=jjRh=-k_=wh-$`nY+#au+v^C4VV z)U?X(v-_#i=3bAylP1S*pM_y*DB z2fR!imng6Dk$>dl*K@AIj<~zw_f$T!-xLO8r{OkE(l?W#W<={460Y02*K#)O4xp?W zAN+isO}!*|mN7B#jUt&!KNyFOpUxv&ybM>jmkfn8z^llBslztv!!`TBEPwu;#eR3d z@_VDa)|ByvXx1V=^Up4{;M8ji3FC7gm(C7Ty-#1gs+U<{Ouc(iV67{< zam#KwvR&s=k4W<13`}DxzJ9{TUa97N-cgWkCDc+C339)EEnC@^HQK6OvKDSCvNz(S zOFAF_6omgG!+zaPC8fBO3kH8YVBx9_AoM?->pv~@$saf(Myo|e@onD`a=;kO*Utem ze=eUH&;JB2I4}?Pm@=VnE+yb$PD~sA5+)|iH3bi|s?ExIePeoAMd(Z4Z%$mCu{t;B9(sgdG~Q}0ShAwe!l8nw0tJn zJ+m?ogrgty$3=T&6+JJa!1oS3AtQQ1gJ z3gR1<=hXU>{SB-zq!okl4c+V9N;vo4{fyGeqtgBIt%TPC1P&k!pR-GZ7O8b}9=%>3 zQrV%FQdB+CcCRKK)0}v>U25rbQk(1^9Ax|WcAo5?L(H&H@%zAoT2RH$iN6boyXpsYqME}WJZI6T%OMlkWXK>R`^7AHG&31 z&MIU}igQ7$;)7AEm#dXA+!I&6ymb7n6D;F7c$tO3Ql(`ht z1sFrzIk_q5#=!#D(e~#SdWz5K;tPF*R883Yu>*@jTeOGUjQekw zM+7HlfP{y8p}jA9bLfyKC_Ti8k#;AVp@RML^9MQp-E+Ns-Y zKA!aAZV-sfm<23fy#@TZZlQVQxH%R7rD}00LxHPUF!Yg3%OX ziDe4m<4fp{7ivBS?*AlJz$~vw5m)Ei8`|+~xOSqJ$waA0+Yys$z$9iN9TIXu8 zaYacjd09uRAsU|)g|03w`F|b1Xg#K~*Mp2X^K^)r3P^juoc}-me&YhkW3#G|H<~jK zoKD?lE@jOw7>4cpKkh!8qU!bF(i~Oa8a!EGy-j46eZYbKUvF=^^nq`EtWFK}gwrsB zeu<6~?mk+;+$whP)8ud8vjqh+NofU+Nu`~|pb&CN1y_idxxf6cGbT=fBZR_hl&G)GgnW$*oDrN-zz;cKs18n+dAn95w z)Y>l6!5eYpebJGw7it~Q5m}8$7@%p&KS=VtydFj4HPJ{xqUVS_Ih}c(^4nUdwG|0% zw8Fnm{IT`8MqoL(1BNtu_#7alS@3WSUUOFT@U*`V!zrPIeCbbO=pE%|g92$EU|lw; z^;^AqMVWVf-R5^OI79TzIyYf}HX%0Y)=aYH;EKo}?=R~ZM&s&F;W>u%hFUfNafb;- z8OkmkK3k||J#3`xdLuMJAhj9oPI?Cjt}cDN7hw26n7irWS0hsy`fs&Y?Y&(QF*Nu! z!p`NggHXaBU6$P42LkqnKsPG@363DHYGXg{!|z6VMAQt??>FK1B4x4{j;iY8A+7o% z*!0qt&w+w#Ob@pQp;q)u0;v^9FlY=AK>2!qku)!%TO<^lNBr!6R8X)iXgXi^1p`T8 z6sU@Y_Fsp6E89E1*jz~Tm2kF=mjYz_q99r^v0h-l7SP6azzL%woM6!7>IFWyizrNwAqoia3nN0q343q zFztMPh0)?ugQg5Izbk{5$EGcMzt*|=S8ZFK%O&^YV@V;ZRL>f!iG?s5z{(*Xq20c^ z(hkk~PljBo%U`$q>mz!ir7chKlE-oHA2&0i@hn4O5scsI&nIWsM>sYg;Ph5IO~VpT z%c-3_{^N>4kECzk?2~Z@V|jWio&a&no;boiNxqXOpS;ph)gEDFJ6E=zPJ$>y5w`U0 z;h9_6ncIEY?#j1+IDUuixRg&(hw+QSSEmFi%_$ua$^K%(*jUynGU@FlvsyThxqMRw z7_ALpqTj~jOSu2_(@wc_Z?>X&(5jezB6w-@0X_34f&cZ=cA-t%#}>L7Q3QRx1$qyh zG>NF=Ts>)wA)fZIlk-kz%Xa;)SE(PLu(oEC8>9GUBgd$(^_(G6Y((Hi{fsV; zt*!IBWx_$5D4D&ezICAdtEU!WS3`YmC_?+o&1RDSfTbuOx<*v`G<2SP;5Q4TqFV&q zJL=90Lcm^TL7a9xck}XPMRnQ`l0%w-fi@bRI&c*VDj!W4nj=qaQd$2U?^9RTT{*qS_)Q9OL>s}2P3&da^Pf(*?> z#&2bt;Q7N2`P{{KH@>)Tf5&za?crRmQ%8xZi<9f=EV3={K zwMet=oA0-@`8F;u`8j-!8G~0TiH5yKemY+HU@Zw3``1nT>D ziK465-m?Nm^~@G@RW2xH&*C#PrvCWU)#M4jQ`I*>_^BZB_c!z5Wn9W&eCBE(oc1pw zmMr)iu74Xl5>pf&D7Ml>%uhpFGJGyj6Mx=t#`}Mt3tDZQDn~K`gp0d)P>>4{FGiP$sPK*ExVs!1)aGgAX z6eA;-9@@Muti3xYv$8U{?*NxlHxs?)(6%!Iw&&l79K86h+Z8;)m9+(zzX?cS zH*~)yk)X^H1?AfL!xctY-8T0G0Vh~kcP=8%Wg*zZxm*;eb)TEh&lGuNkqJib_}i;l z*35qQ@}I#v;EwCGM2phE1{=^T4gT63m`;UEf5x2Get-WSWmt6%T6NJM`|tk-~4<#HHwCXuduB4+vW!BywlH8murH@|32CNxx7} zAoF?Gu02vpSl|q1IFO0tNEvKwyH5V^3ZtEO(su1sIYOr{t@Tr-Ot@&N*enq;Je38} zOY+C1bZ?P~1=Qb%oStI-HcO#|WHrpgIDR0GY|t)QhhTg*pMA|%C~>;R4t_~H1J3!i zyvQeDi&|930wZlA$`Wa9)m(cB!lPKD>+Ag$5v-}9%87`|7mxoNbq7r^U!%%ctxiNS zM6pV6?m~jCQEKtF3vLnpag``|bx+eJ8h=(8b;R+8rzueQvXgFhAW*9y$!DgSJgJj% zWIm~}9(R6LdlXEg{Y3g_i7dP^98=-3qa z$*j&xC_$5btF!80{D&2*mp(`rNLAM$JhkB@3al3s=1k^Ud6HHontlcZw&y?`uPT#a za8$RD%e8!ph8Ow7kqI@_vd7lgRhkMvpzp@4XJ`9dA@+Xk1wYf`0Dk!hIrBxhnRR(_ z%jd(~x^oqA>r>`~!TEyhSyrwNA(i}={W+feUD^8XtX^7^Z#c7att{ot#q6B;;t~oq zct7WAa?UK0rj0yhRuY$7RPVoO29JV$o1Z|sJzG5<%;7pCu%L-deUon-X_wAtzY@_d z6S}&5xXBtsf8TZ13chR&vOMYs0F1?SJcvPn>SFe#+P3r=6=VIqcCU7<6-vxR*BZUm zO^DkE{(r8!e56)2U;+8jH4tuD2c(ptk0R{@wWK?%Wz?fJckr9vpIU27^UN*Q$}VyHWx)reWgmEls}t+2#Zm z_I5?+htcQl)}OTqF<`wht89>W*2f6e)-ewk^XU5!sW2A2VtaI=lggR&I z;Rw{xd)WMqw`VUPbhrx!!1Eg_*O0Si6t@ny)~X^Gu8wZZDockr)5)6tm+<=z+rYu? zCof+;!nq6r9MAfh zp4|^2w^-3vFK~{JFX|F5BIWecBJkkEuE%iP8AZ z^&e|C+VEH&i(4Y|oWPCa#C3T$129o5xaJa=y8f(!k&q+x=M|rq{?Zw_n?1X-bt&bP zD{*>Io`F4(i+5eE2oEo6iF}jNAZ52VN&Cp>LD{MyB=mCeiwP+v#gRvr%W)}?JBTMY z_hc2r8*SksC%(pp$KGmWSa|fx;r^9c;~Q(Jqw1%;$#azZf}#Fca9NZOh{*YxV9(1ivVA^2Wz>!A&Xvmm-~{y8n!^Jdl8c>`J#=2~!P{ zC1g_5Ye3={{fB`R%Q|%9<1p1;XmPo5lH5PHvX$bCIYzQhGqj7hZ?@P4M0^mkejD|H zVzARm7LRy|8`jSG^GpxRIs=aD>Y{Cb>^IwGEKCMd5LAoI;b{Q<-G}x*e>86R8dNAV z<@jb1q%@QQanW1S72kOQ$9_E#O?o}l{mHd=%Dl{WQcPio$baXZN!j{2m)TH1hfAp{ zM`EQ=4J`fMj4c&T+xKT!I0CfT^UpcgJK22vC962ulgV7FrUrII5!rx1;{@FMg(dIf zAC}stNqooiVol%%TegMuWnOkWKKA}hg6c)ssp~EnTUVUI98;a}_8UeTgT|<%G3J=n zKL;GzAhIQ_@$rDqqc1PljwpfUwiB)w!#cLAkgR_af;>}(BhnC9N zqL|q8-?jsO&Srv54TxVuJ=rfcX=C7{JNV zSmW@s0;$(#!hNuU0|YyXLs{9$_y2^fRmM&g#toh}!K8P}tlJvYyrs6yjTtHU>TB0} zNy9~t5F47ocE_+%V1(D!mKNBQc{bnrAbfPC2KO?qdnCv8DJzEBeDbW}gd!g2pyRyK`H6TVU^~K# z488@^*&{foHKthLu?AF6l-wEE&g1CTKV|hN7nP+KJnkd0sagHm&k{^SE-woW9^fYD z7y?g*jh+ELt;$OgP>Se3o#~w9qS}!%#vBvB?|I-;GM63oYrJ}HFRW6D+{54v@PN8K z2kG8`!VVc+DHl^8y#cevo4VCnTaPTzCB%*)sr&+=p{Hh#(MwaJbeuvvd!5fd67J_W za`oKxTR=mtM7P}i2qHG8=A(39l)_rHHKduDVA@^_Ueb7bq1A5#zHAi**|^H@fD`_W z#URdSG86hhQ#&S-Vf_8b`TIAmM55XhaHX7}Ci-^(ZDs*yb-WrWV&(oAQu3vMv%u$5 zc;!ADkeNBN_@47r!;%G3iFzo;?k)xTS-;1D-YeS5QXN7`p2PzGK~e6ib;8COBa5)p zfMn}dA--&A12~zr&GVk?qnBGfIEo`5yir;-Q;ZLn{Fimdrk;e!)q`sAkYh^~^>4Q@ zN5RT>s38+`V{|6@k&vZW!W0*BEqV&~34d+Ev8h)ObYL7Bd_hgbUzjdJaXP=S@Dp6X z)i013q3K4Gr5d%2YIp>218pYK!xwH;k)j?uUrT-yVKLg*L3y~=a+qd!RWGTL`z>29 z-Zb4Y{%pT%`R-iA#?T58c-i@?jf-Ckol9O>HAZPUxN%Z=<4ad9BL7n`_kH0i#E(m& zaNb039+z~ONUCLsf_a|x*&ptU?`=R*n}rm-tOdCDrS!@>>xBg)B3Sy8?x^e=U=i8< zy7H-^BPfM}$hf*d_`Qhk_V$dRYZw<)_mbC~gPPxf0$EeXhl-!(ZH3rkDnf`Nrf4$+ zh?jsRS+?Zc9Cx7Vzg?q53ffpp43po22^8i1Obih&$oBufMR;cT2bHlSZ#fDMZZr~u zXIfM5SRjBj4N1}#0Ez|lHjSPQoL&QiT4mZn=SxHJg~R`ZjP!+hJ?&~tf$N!spvKPi zfY;x~laI9X`&#i#Z}RJ`0+MO_j^3#3TQJu2r;A-maLD8xfI+2Y*iDf4LsQ$9xiu?~ z?^wHEf^qlgtjdj(u_(W5sbGx1;maVPDHvI-76u2uUywf;>()=e>0le;bO0LIvs)iy z*lJTO+7gyf^)2uS-PhS_O-+RToQmc6VT>ej^y^stNkwIxUg?E|YMAAwQ}U!dC&cXL ziXKU?zT~xbh6C};rICGbdX~;8Z%L~Jdg|`senVEJo-CiDsX47Kc`;EiXWO<9o)(`4 zGj(9@c+Me=F~y(HUehcAy!tkoM&e1y#(qqCkE(0lik_U>wg8vOhGR(=gBGFSbR`mh zn-%j3VTD4 zwA1Kqw!OSgi_v0;6?=Bk4Z{l-7Fl4`ZT535OC{73{rBwpNHMPH>((4G`sh zZhr!v{zM@4Q$5?8)Jm;v$A2v$Yp9qFG7y`9j7O-zhzC+7wr3Cb8sS$O{yOFOODdL) zV2pU{=nHne51{?^kh%a$WEro~o(rKQmM!p?#>5Pt`;!{0$2jkmVzsl|Nr^UF^IHxG z8?HmZEVMY~ec%Ow6hjfg6!9hCC4xY?V;5Ipo-myV=3TmfT^@XkKME`+=_inm4h7ki z->K~a+20?)zic^zc&7h=0)T{Aa24FU_}(O|9DMW3Bf>MW=O%~8{unFxp4}B+>>_KN zU%rKs3Va&&27&OX4-o&y2ie|sN2p-=S^V<2wa2NUQ4)?0e|hgna*1R7(#R_ys3xmG zE#(ry+q=O~&t|RX@ZMD`-)0QmE*x%SBc(Yvq60JtCQ4RL(gdA(@=}0rYo5yKz36bW zkvLOosP6I?7qH!rce(}q@cH-{oM2ThKV2RZe+{{25hkc?T>=Tky12xHr0jmfH@SZi zLHPJ@^Oo^Zo%`gZk_hrbCzS+t|=O!Bt zWi|>M8mz~sD|Z>C1ZPf_Cs&R!S5E2qK+@j*UpP>;5_|+h+y{gb=zub7#QKSUabet# zFH2H0ul;zO+uc+V=W_W@_Ig-791T7J9&=5)wrBE?JEHS_A6P~VQ)u6s1)Pu|VxP(aYJV*(e<)(42R zm3AK>dr1QLbC1RMoQ|M5k+TWBjY9q+_vY=K-tUte35m4RWl51A<4O0ptqV3)KzL7U z0gpp-I1)|zvtA8V7-e-o9H)lB_Rx6;Bu7A2yE)6)SuDqWDs}~Ojfk?DFwI% z3E1(>LbbB7I(&E@B7nlulhvY=Wa1mGXD@ijD7WF^y@L1e55h)-hzoq}eWe!fh9m3V{)x^6F8?ed1z>+4;qW6A4hYYj zZCYP=c#I8+$pAIVyiY*#%!j3ySAnH`tp|=^lh{)#JimWaP_rXK40A0WcsEUj`G1}O zG?XQ~qK4F!lqauv6-BL_Up3+-l1=kVfD;D*C)yr>o9>W=%mIyATtn_OBLK+h@p)j5jRAb;m&Ok?TZH-5Q)~#UwdYFp~rEE{judWa9E)z zE>135C-xMdHYY&AZGR)tb`K}s0CK9 z1!))p^ZaUC*e50t`sL+)@`)#kJ}?C_cCMH@k{f4wh~0`OFnGQ2nzUuuu;=r4BYRcI z){G#a6Y$S(mIc6B#YS;jFcU{0`c)Raa$nG+hV(K|2|^ZWOI566zlF0N;t~$jD<_AX zjnD?HN-G>xRmHwtL3BcJX7)Q^YGfc?cS4Nj=yYl5MB(uBD?r@VTB|mIYs=au$e)e{ zLHWd!+EN*v2*(=y%G1JzyQdY&%|?~R5NPb)`S2dw1AJW8O;L=p?yVxJs=X?U#-l1O zk6xh8yyY;OTR7aF{P=kQ>y`*EFivnw%rQioA-I67WS+~hVamG4_sI)(Jo4vHS|@F@ zqrBHbxHd_Y8+?8Gfq=Z1O^Fs5moGayCHVUHY^8)^j)Aj*RB!S2-FA?4#-`puwBW`` zJ_6OQj(FGo8DotHYRKq;;$4xDn9=4rgw}5xvxhi)?n?W5{*%4%h9Tg)zlQl&fN~Z1)gL(Dn7X!P428I zwA+U-x5!cQ57g1N=2bLqAWF z!&cbvsD)dvYoqP5vaQz%rL@kv*J>0AMzWAKn~Mxi5g2GlI7qvVZo)Z5oj=#O!M&*O z`3O3)uvrjNTeremC}nW@(m%#E-sITB>j-!yBM#(=FN`~c#@XjL3e)SjR9&%QO%tUg zzGv=SLH()`ZIt?Ayym;9VG1Muq+a+7Zo+59?SuRu_`k>@S4!yS3roMnq+SDO?`C7V#2 z8vHf4&0k;{kLT)fa==7EILSu3e|ZnxtFO;1 zGqP-;Xo(>_QKcYUhsi-X72BqH#7Zb-TsiNIF>G9xOHT3XoA*qX^10+#XCU0)UO4_%A_s_vO=uDd3_Q%D{OsvLMW9wGvuuRnF52{2vH06D~7N672!bIMt@it_D}& zwjZ7gV!RzZ86*wbEB5cnMJRbEqMM{G!K)bfJjyPH^9nGnrOI9S{~!dm4~P#&b*~)h zCMwM8mR+y5i~E5*JAopwZ>F`=ORfA&IF%O8(aS<}^H6wcY1g^=lYLPtFpyvW9F z3;FCS-TGFYPr#Y$ue>}?rTYrmWr^VbUu>!eL$cEdh1e>5_UDnZ@Mu$l*KVo_NDEu^ zBn*!qVnzYv>t|<(>nt8%CoNPhN!qGP|sANRN^#+2YSSYHa>R1mss->c0f=#g@U58@? zA4sUbrA7)&KrTddS0M6pTSRaz)wqUgsT3&8-0eG|d;ULOUztdaiD3~>!10H`rRHWY z1iNu6=UaA8LUBoaH9G*;m`Mzm6d1d+A#I8sdkl*zfvbmV0}+u` zDMv=HJJm?IOwbP;f~yn|AI_J7`~+5&bPq6Iv?ILo2kk$%vIlGsI0%nf1z9Mth8cy! zWumMn=RL1O9^~bVEFJ}QVvss?tHIwci#ldC`~&KFS~DU5K5zzneq_Q91T~%-SVU4S zJ6nVI5jeqfh~*2{AY#b(R*Ny95RQBGIp^fxDK{I9nG0uHCqc-Ib;pUUh$t0-4wX*< z=RzW~;iR3xfRnW<>5Jr5O1MP)brA3+ei@H8Hjkt7yuYIpd7c-4j%U=8vn8HD#TPJo zSe+7~Db}4U3Y^4dl1)4XuKZ67f(ZP;?TYg9te>hbAr4R_0K$oq3y5m-gb?fR$UtF9 zS~S^=aDyFSE}9W2;Okj%uoG-Um^&Qo^bB#!W?|%=6+P>``bumeA2E7ti7Aj%Fr~qm z2gbOY{WTyX$!s5_0jPGPQQ0#&zQ0Zj0=_74X8|(#FMzl`&9G_zX*j$NMf?i3M;FCU z6EUr4vnUOnZd`*)Uw#6yI!hSIXr%OF5H z5QlF8$-|yjc^Y89Qfl!Er_H$@khM6&N*VKjIZ15?&DB?);muI`r;7r0{mI03v9#31 z#4O*vNqb=1b}TjLY`&ww@u^SE{4ZiO=jOP3!|6cKUV2*@kI9Aw0ASwn-OAV~0843$1_FGl7}eF6C57dJb3grW)*jtoUd zpqXvfJSCIv4G*_@XZE?> z4Lt=jTSc*hG3`qVq!PVMR2~G-1P{%amYoIg!8Odf4~nv6wnEVrBt-R5Au=g~4=X|n zHRJGVd|$>4@y#w;g!wz>+z%x?XM^xY%iw%QoqY@`vSqg0c>n_}g^lrV))+9n$zGOP zs%d&JWT2Jjxaz`_V%XtANP$#kLLlW=OG2?!Q%#ThY#Sj}*XzMsYis2HiU2OlfeC>d z8n8j-{Npr1ri$Jv2E_QqKsbc$6vedBiugD~S`_0QjTTtX(mS}j6)6e;xdh*sp5U0aMpuN}qTP=^_Qn zh~0padPWs&aXmf6b~}{7Raglc)$~p?G89N4)&a}`izf|bA)IUmFLQ8UM$T!6siQxr z=%)pPsWYXWCNdGMS3fK6cxVuhp7>mug|>DVtxGd~O8v@NFz<+l`8^#e^KS3})bovWb^ zILp4a_9#%Y*b6m$VH8#)2NL@6a9|q!@#XOXyU-oAe)RR$Auj6?p2LEp*lD!KP{%(- z@5}`S$R)Kxf@m68b}Tr7eUTO=dh2wBjlx;PuO~gbbS2~9KK1szxbz$R|Frl8NqGn= z2RDp@$u5Obk&sxp!<;h=C=ZKPZB+jk zBxrCc_gxabNnh6Gl;RR6>Yt8c$vkv>_o@KDMFW1bM-3krWm|>RG>U`VedjCz2lAB1 zg(qb_C@Z~^cR=_BmGB@f;-Is3Z=*>wR2?r({x}qymVe?YnczkKG%k?McZ2v3OVpT* z(O$vnv}*Tle9WVK_@X@%tR^Z!3?FT_3s@jb3KBVf#)4!p~AFGgmn%1fBbZe3T53$_+UX_A!@Kz63qSLeH@8(augJDJ;RA>6rNxQYkd6t(sqK=*zv4j;O#N(%*2cdD z3FjN6`owjbF%UFbCO=haP<;Y1KozVgUy(nnnoV7{_l5OYK>DKEgy%~)Rjb0meL49X z7Fg;d!~;Wh63AcY--x{1XWn^J%DQMg*;dLKxs$;db`_0so$qO!>~yPDNd-CrdN!ea zMgHt24mD%(w>*7*z-@bNFaTJlz;N0SU4@J(zDH*@!0V00y{QfFTt>Vx7y5o2Mv9*( z1J#J27gHPEI3{!^cbKr^;T8 z{knt%bS@nrExJq1{mz2x~tc$Dm+yw=~vZD|A3q>d534za^{X9e7qF29H5yu};J)vlJkKq}< zXObu*@ioXGp!F=WVG3eUtfIA$GGgv0N?d&3C47`Zo)ms*qO}A9BAEke!nh#AfQ0d_ z&_N)E>5BsoR0rPqZb)YN}b~6Ppjyev;MMis-HkWF!az%G? z#&it84hv!%_Q>bnwch!nZKxB05M=jgiFaB^M=e-sj1xR?dPYUzZ#jua`ggyCAcWY> z-L$r#a{=;JP5X}9(ZPC&PdG~h5>_8SueX($_)Qu(;()N3*ZQH(VGnkWq^C}0r)~G3_?a10y*LsFz zokU5AKsW9DUr-ylK61shLS#4@vPcteK-Ga9xvRnPq=xSD_zC=Q_%6IuM?GpL(9aDx z|8d_;^6_D4{IQ1ndMAcFz5ZaT+Ww0wWN`xP(U#^=POs(BpKm;(H(lmYp+XCb7Kaw0 z;LT945Ev3IkhP6$lQBiMgr+vAL}{8xO&IObqJBEP4Y^x&V?iGC=1lVIbH^Z!eXxr@ zz)D7Fon`z~N|Pq>Bsue&_T9d;G+d8#@k^cq~F^I8ETsZ*cGOf*gZ4ghlAzW|aZ;WA13^B!Tlr0sWA zosgXD-%zvO-*GLU@hVV(bbQ`s@f~Ux=4}(@7O)%o5EH((gYflccBC@jbLF3IgPozv zglX2IL}kL1rtn4mu~`J(MMY83Rz6gc1}cX4RB+tZO2~;3FI# z@dU(xa5J_KvL0)oSkvwz9|!QcEA$jKR@a-4^SU3O449TrO+x$1fkBU<<=E_IHnF6> zPmZ7I2E+9A_>j6og$>Nih~b2F_^@6ef|Hm-K2(>`6ag{Vpd`g35n`yW|Jme78-cSy z2Jz7V#5=~u#0eLSh3U4uM3Smk31>xEh^-Os%&5tK6hSAX83jJi%5l!MmL4E?=FerNG#3lj^;-F1VISY!4E)__J~gY zP{o~Xo!8DW{5lsBFKL~OJiQoH>yBZ+b^};UL&UUs!Hbu7Gsf<9sLAsOPD4?-3CP{Q zIDu8jLk6(U3VQPyTP{Esf)1-trW5Mi#zfpgoc-!H>F$J#8uDRwDwOaohB(_I%SuHg zGP)11((V9rRAG>80NrW}d`=G(Kh>nzPa1M?sP;UNfGQaOMG1@_D0EMIWhIn#$u2_$ zlG-ED(PU+v<1Dd?q-O#bsA)LwrwL>q#_&75H)_X4sJK{n%SGvVsWH7@1QZqq|LM`l zDhX8m%Pe5`p1qR{^wuQ&>A+{{KWhXs<4RD< z=qU6)+btESL>kZWH8w}Q%=>NJTj=b%SKV3q%jSW>r*Qv1j$bX>}sQ%KO7Il zm?7>4%Q6Nk!2^z})Kchu%6lv-7i=rS26q7)-02q?2$yNt7Y={z<^<+wy6ja-_X6P4 zoqZ1PW#`qSqD4qH&UR57+z0-hm1lRO2-*(xN-42|%wl2i^h8I{d8lS+b=v9_>2C2> zz(-(%#s*fpe18pFi+EIHHeQvxJT*^HFj2QyP0cHJw?Kg+hC?21K&4>=jmwcu-dOqEs{%c+yaQ z2z6rB>nPdwuUR*j{BvM-)_XMd^S1U|6kOQ$rR`lHO3z~*QZ71(y(42g`csRZ1M@K7 zGeZ27hWA%v`&zQExDnc@cm9?ZO?$?0mWaO7E(Js|3_MAlXFB$^4#Zpo;x~xOEbay( zq=N;ZD9RVV7`dZNzz+p@YqH@dW*ij8g053Cbd=Mo!Ad8*L<5m1c4Kk ziuca5CyQ05z7gOMecqu!vU=y93p+$+;m=;s-(45taf_P(2%vER<8q3}actBuhfk)( zf7nccmO{8zL?N5oynmJM4T?8E))e;;+HfHZHr` zdK}~!JG}R#5Bk%M5FlTSPv}Eb9qs1r0ZH{tSk@I{KB|$|16@&`0h3m7S+)$k*3QbQ zasW2`9>hwc)dVNgx46{Io zZ}aJHHNf1?!K|P;>g7(>TefcLJk%!vM`gH8V3!b= z>YS+)1nw9U(G&;7;PV4eIl{=6DT^Vw<2Elnox;u@xF5ad*9Fo|yKgq<>*?C$jaG2j z|29>K)fI^U!v?55+kQ*d2#3}*libC4>Dl4 zIo3Jvsk?)edMnpH<|*l<*0Pf{2#KedIt>~-QiB{4+KEpSjUAYOhGDpn3H_N9$lxaP ztZwagSRY~x@81bqe^3fb;|_A7{FmMBvwHN*Xu006qKo{1i!RbN__2q!Q*A;U*g-Mz zg)-3FZ`VJdognZ~WrWW^2J$ArQAr1&jl~kWhn+osG5wAlE5W&V%GI{8iMQ!5lmV~# zeb3SKZ@?7p;?7{uviY6`Oz16t0=B70`im=`D@xJa16j2eHoCtElU*~7={YUzN41sE z#Th>DvJq-#UwEpJGKx;;wfDhShgO0cM|e!Ej){RX#~>a?)c2|7Hjhh2d=)VUVJL<^Aq|>_df4DX>b9W2$_DM zTjF#j(9?Co`yor?pK<16@{h#F&F8~1PG|qQNZPX^b!L*L&?PH#W8za0c~v6I2W($Jderl%4gufl z#s;C*7APQJP46xHqw;mUyKp3}W^hjJ-Dj>h%`^XS7WAab^C^aRu1?*vh-k2df&y9E z=0p*sn0<83UL4w30FqnZ0EvXCBIMVSY9Zf?H1%IrwQybOvn~4*NKYubcyVkBZ4F$z zkqcP*S>k6!_MiTKIdGlG+pfw>o{ni`;Z7pup#g z4tDx3Kl$)-msHd1r(YpVz7`VW=fx9{ zP}U8rJ-IP)m}~5t&0Y$~Quyjflm!-eXC?_LMGCkZtNDZf0?w<{f^zp&@U@sQxcPOZ zBbfQTFDWL_>HytC*QQG_=K7ZRbL!`q{m8IjE0cz(t`V0Ee}v!C74^!Fy~-~?@}rdn zABORRmgOLz8{r!anhFgghZc>0l7EpqWKU|tG$`VM=141@!EQ$=@Zmjc zTs`)!A&yNGY6WfKa?)h>zHn!)=Jd73@T^(m_j|Z;f?avJ{EOr~O~Q2gox6dkyY@%M zBU+#=T?P8tvGG|D5JTR}XXwjgbH(uwnW%W?9<-OQU9|6H{09v#+jmnxwaQ-V;q{v% zA8srmJX7Fn@7mr*ZQ@)haPjWVN@e3K z_`+@X$k*ocx*uF^_mTqJpwpuhBX~CSu=zPE(Sy%fYz&lzZmz3xo4~-xBBvU0Ao?;I-81*Z%8Do+*}pqg>bt^{w-`V6Sj>{Znj+ z70GS2evXinf|S#9=NNoXoS;$BTW*G0!xuTSZUY45yPE+~*&a-XC+3_YPqhd*&aQ>f z$oMUq^jjA;x#?iJKrpAqa<2<21h*_lx9a}VMib;a6c$~=PJOj6XJXJ|+rc7O7PEN5uE7!4n9nllo@BI4$VW2Nf_jqnkz%cvU4O4umV z#n6oXGWOt3tuIjmX*b!!$t~94@a@QgybLpQo3icAyU`iNbY~XNAArFAn$nFJ()d-U zFaO#nxxVF-%J{UB**uRo0*+?S>=^il)1m7v-u`PDy*ln%|3E-{3U~R=QcE&zhiG_c zDnGMgf1}3h1gWz8IV0Oc7FmEt>6W?Eva;J`(!;IIny}PvD?vztz`F6su_tUO`M%K5 z%C#=nXbX})#uE!zcq2mB;hPUVU1!`9^2K303XfOIVS{mlnMqJyt}FV=$&fgoquO+N zU6!gWoL%3N1kyrhd^3!u>?l6|cIl*t4$Z$=ihyzD7FFY~U~{RaZmfyO4+$kC7+m zo+-*f-VwpUjTi_Idyl~efx)!$GpE!h+in4G1WQkoUr<#2BtxLNn*2A>a-2BL#z%QO@w0v^{s=`*I6=ew2nUj1=mvi%^U@2#Wf& zs1@q6l8WqrqGm!)Yr|*``||#A+4#du6`mR^_#?CymIr}O!8Zm?(XY$u-RGH;?HFMGIEYVuA1& z`3RlG_y0%Mo5w@-_W$E&#>g6j5|y1)2$hg(6k<{&NsACgQQ0c8&8Tdth-{@srKE*I zAW64%AvJJ+Z-|I~8`+eWv&+k8vhdJk5%jolc%e`^%_vul0~U8t)>=bU&^ z6qXW&GDP%~1{L1-nKK>IsFgDJrh>!wr3?Vu-cmi#wn`;F`$GNc_>D|>RSuC8Vh21N z|G;J1%1YxwLZDD400Ggw+FirsoXVWYtOwg-srm}6woBb!8@OIc`P$!?kH>E55zbMB z8rdpODYfVmf>cF`1;>9N>Fl(Rov!pm=okW>I(GNJoNZ6jfIunKna-h6zXZPoZ9E2PythpyYk3HRN%xhq2c?gT$?4}Ybl42kip$QiA+ab zf-!EqBXkT1OLW>C4;|irG4sMfh;hYVSD_t6!MISn-IW)w#8kgY0cI>A`yl?j@x)hc z=wMU^=%71lcELG|Q-og8R{RC9cZ%6f7a#815zaPmyWPN*LS3co#vcvJ%G+>a3sYE`9Xc&ucfU0bB}c_3*W#V7btcG|iC>LctSZUfMOK zlIUt>NBmx6Ed}w_WQARG+9fLiRjS1;g49srN1Xi&DRd|r+zz*OPLWOu>M?V>@!i49 zPLZ3Q(99%(t|l%5=+9=t$slX0Pq(K@S`^n|MKTZL_Sj+DUZY?GU8sG=*6xu)k5V3v zd-flrufs*;j-rU9;qM zyJMlz(uBh0IkV<(HkUxJ747~|gDR6xFu?QvXn`Kr|IWY-Y!UsDCEqsE#Jp*RQpnc# z8y3RX%c2lY9D*aL!VS`xgQ^u0rvl#61yjg03CBER7-#t7Z++5h_4pw{ZZ~j0n_S_g zR=eVrlZDiH4y2}EZMq2(0#uU|XHnU!+}(H*l~J&)BUDN~&$ju@&a=s$tH5L`_wLeB z944k;)JIH^T9GEFlXiNJ6JRymqtLGZc?#Mqk2XIWMuGIt#z#*kJtnk+uS;Gp}zp$(O%LOC|U4ibw%ce-6>id$j5^y?wv zp1At~Sp7Fp_z24oIbOREU!Mji-M;a|15$#ZnBpa^h+HS&4TCU-ul0{^n1aPzkSi1i zuGcMSC@(3Ac6tdQ&TkMI|5n7(6P4(qUTCr)vt5F&iIj9_%tlb|fQ{DyVu!X(gn<3c zCN6?RwFjgCJ2EfV&6mjcfgKQ^rpUedLTsEu8z7=q;WsYb>)E}8qeLhxjhj9K**-Ti z9Z2A=gg+}6%r9HXF!Z~du|jPz&{zgWHpcE+j@p0WhyHpkA6`@q{wXl6g6rL5Z|j~G zbBS~X7QXr3Pq0$@mUH1Snk^1WJ0Fx2nTyCGkWKok$bJZV0*W?kjT|mkUpK<)_!_K^OoTjMc+CWc^~{ZP8vgm`f&=ppzKtw}cxwV^gppu}^df1|va7Q?@=(076-( z4KJVmu?l(aQwmQ*y_mke>YLW^^Rsj@diLY$uUBHL3yGMwNwb7OR3VD%%4tDW(nC984jBWCd90yY(GEdE8s(j>(uPfknLwh!i6*LX}@vvrRCG`c?EdB8uYU zqgsI4=akCeC+&iMNpVu56Fj2xZQHs6SdWssIF#Q@u@f9kab0&y*PlG+PynjHy`}GT zg%aTjRs2+7CknhTQKI%YZhFq1quSM{u24Oy2As@4g(bpbi%y1i0^TwI)%1Whpa~qE zX4MD(PgFEK@jZBPXkFd437aL6#COs$WrNT#U=er-X1FX{{v9!0AS$HR{!_u;zldwY zKko!`w2u@($c&k_3uLFE0Z*2vms?uw1A{AqZw^jwg$|D7jAY20j`s*l##=4Ne_K5) zOtu6_kziEF@vPsS7+@UwqOW6>OUwF$j{r4=nOSf-{UC(rEKidie7IUn>5`UoNJ9k) zxJXXEBQifng+Pte3mPQ76pVlZ<`jnI##F1*YFA*)ZCEncvgF-%)0dUXV*pXTT^L`n zL=?A5Vty#{R9W4K)m$`me~*_(&a88M?Eon$P-YdVG}#Gq4=hh#w=`>8f`9}}zhv;~ za?I=Gb3v$Ln?-SDTBow0J5Tt&xPlw|%`*VTyVee1Oh<-&;mA|;$ zoPl;^f7Q~}km#_#HT2|!;LEqORn%~KJaM)r#x_{PstSGOiZ!zX2c}^!ea3+HSWrwE z=6SJ!7sNDPdbVr#vnUf}hr&g@7_Yj&=sY=q(v^BwLKQm|oSB}172GpPlj?a3GqX#B zJko4zRRttIY>Fv#2b#A<_DLx=T@eUj+f}!u?p)hmN)u4(Jp(`9j58ze{&~rV?WVbP z%A=|J96mQjtD037%>=yk3lkF5EOIYwcE;uQ5J6wRfI^P3{9U$(b>BlcJF$2O;>-{+a1l4;FSlb z_LRpoy$L%S<&ATf#SE z;L?-lQlUDX_s&jz;Q1Lr@5>p_RPPReGnBNxgpD!5R#3)#thAI3ufgc^L)u%Rr+Hlb zT(pLDt%wP7<%z(utq=l%1M78jveI@T$dF#su(&>JkE(#=f4;D54l*%(-^(nfbCUQe)FV9non9F%K+KZ(4_`uOciy82CO)OolxisUd0m^cqueIRnY< z;BgA4S1&XC3uUP?U$}4o&r|0VCC7fkuMZBa|2n4asR>*5`zBaOJPWT$bNn(W_CK%L$c2AsfSlwq?A8Q6 zhK&USSV=^-4vZ^5<}pnAOb&IKseHNxv_!|B{g@d^&w%{?x;i3iSo)+vt^VnMmS!v) zM)W)05vXqzH5^hOWWw~$#&7HoIw}}DD3bCQgc=I8Rv|G5fM8O^58?--_-*>%Nwk)j zIfvfok0n05!w%tZ=-dpffezI7(+}yX5XhwYk#0@KW%PkR;%#t|P6Ze_K*N6ns%jOt zNeW(bRsv0BK7ah~9U~UBAVA_L34F+;14x6-;I|o=%>?sS3@dpRv|GKxilsa#7N#@! z!RX~>&JX&r{A^^>S~n_hPKkPR_(~~g>SuPj5Kx6VI%8BOa(Iit&xSMU8B#EY-Wr?9 zOaRPw0PEbVSW@Wk{8kkVn34;D1pV2mUXnXWp{V-M9+d}|qfb6F`!a9JQO_-wlH?zf z4Sn0F4-q-tzkaJ?1fV0+cJBF$f0g6*DL6U3y`Tr`1wzCiwY#muw7Q-Ki)uN}{MoCWP%tQ@~J4}tyr1^_bV9PScNKQHK=BZFV!`0gRe?mVxhcA4hW5?p0B<5oK+?vG^NM%B%NDOvu0FMq#)u&zt_-g&2 z7?z%~p&32OAUSQV{<=pc_j2^<;)`8$zxCEomh=rvMiliShS?ahdYI1grE-M&+qkK_ zD=5Hexi<&8qb4hgtgj81OD(tfX3EJSqy9KFcxpeBerG`apI4!#93xpEFT??vLt>kf zac28;86CpMu=BWIe$NOT~+Es!y#+$ zvm2s*c`J9Gy*ERvLSI<9<=j*O=0xUG>7rYh^R4bGsvz;j-SBO|P^OQ1>G9_akF}D; zlRmB@k3c5!s|Vz3OMZ8M*n0AMTiSt5ZpRy+R1|ckna&w`UQjklt9f&0Z~=->XImVA zLXizO2h=<|wM~w>%}3q1!E{oSq7LBPwQ~93p-peDq-W?wCm8NOKgTSz-P)|cm}S5&HBsx#C@Ba5;hzi#Yw@y-kC~)@u4}Rf?KV0$lPjv}} zcFpNy=YJfsS||9&!-JFjw=@NU96ESzU^gme0_oNy?})II`>Sy>bUCHs_(m&)vn^&isCl+`F~qu8elAO z)-ZP7`gYE2H(1)5tKalz&NJbcutAU&&JFV~$Jrai31^j>vZ|HV1f}#C1<5>F8 zS1RWIzM%b{@2dAF^$+i4p>TC8-weiLAPN+Aa#(bxXo9%Vz2NEkgF&s#_>V?YPye^_ z`` z-h3Cv^m6K%28I$e2i=cFdhZN?JTWhqJC{Q9mg0Vg|FiPEWDl&K)_;Bz_K`jH7W7QX^d$WQF*iF@#4_P*D36w9&iJr2E{w?LRFapwZIIVHGH ziTp*5>T{=;(E}z{1VL4;_H`BAXA~&zpeWX!gN9m|AfcJ{`!XVz48O^&+0Gd|w;udP zzU|DbGTS|7qZoEoDZEH9Kb0%DZvCaWDzuJ=8jZz}pqPn+I!c_+*~>m>BQqN2560*< z$6sx_y8WRqj$SugYGip+et$;iJ!SQAx=HgVSh_3e)MOFHuXD@sg>Yi_p8Sh`{lP=5 zo?AFv1h;KqR`Yj!8Pjji3lr+qae2|a1GmlxE*su%_V)K0Xu0(#2LcO!*k11w*V12$ z;f~i{kI#9PzvFLZ3pz@d558HeK2BTvk*JvS^J8L^_?q4q z);;4Z!DsV!P*M>F>FiF*{|p_nUgy;pDh?J8vwO;emgOAAcxrgDXiSDS5ag?0l*jj< z(khZ3-)>eiwPwpb6T9meeL)!2C-K@z9fF`0j|t@;^f5+dx86R3ZM{bnx9Hm1O$s)N zk$OvZR0u2`Z^QP8V%{8sEhW~_xbZMad2jtz&0+ekxmp;9`ae;_f%-ltk5E%)VT*a6 zRbMnpCLPnalu+1TafJ4M0xNV8g}U4Mjk{le6MA|0y0rk)is}M%Z9tUU22SvIAh7`w zTysd{Pztfkk=jD^*!lA+rBcqb)Fx`A5iaU2tl&XdL1D)U@pLEXdu%#YB*ol1N?4ti zHBQcU#_%UqiQ1)J^u-ovU@-7l?`YzYFvA2#tM0mEh3?CpyEh_NUuVajD16t zyg$C*5du9R=K~6mCJ`W+dFI$9WZZauO)p2H)*SKpHVsIu2CxfJvi2>; zcit#57RP7DpSwMF-VBm|4V5d=tRgX7RM9%KQ0JRo6d<)RmiIPWe2zh6tmswP`fs^) zwy};#jk|NXMqCSfwIR3QZ#W2`(%sJ>qvk=53CYoLmQt9q|2Gm$sB;rEuBqGJA1OUM zoyl4Wy-HYn0J6L=cad8o)R!Ea^;`rSMg9hYo3?Fw6B9dUq75a-MSb56n8~AAsS(JP zZ!1khPu}!GRpsj+jvl`N1tDD8m1myJCI3c-c<9U-1Vg`xJO~}5_wvPXYh^=Boo^|V z3Tp}|lH!9m4Ipa_$p;b8fjUd=zc4iO7vr)M&Xs0_m$fgY@+hB9%K~4*9$p0d)m2bO ze5JH`W0fnIKdcW!oO#^g1YceSQ4u->{>u@>tLi!fky)o&$h(=he?Fe_6?}O~iSf(F zV&(P~*5h>BW{3e1H%8*7#_%L1#>W97b0@jHtliES^w6w5oldI7QL+?I(Pl$DaN>~d5nXx z;CO1E+S?3E2PLq~)-?ygkHAO1m&hOYmj7?;2XM!$D^f0l9K4P{n}mgb{CoYH6RJ8o ztydc6dNqA)`CG?=Gd~EIbi`UM)eyzGF^+i?&TOdyW~mFH_^Gye(D}clDVFQ@V2Tvy z7rQIaq8Xx`kC;AO-_{k%VI2e6X@bIy^mupEX%{u0=KDUGu~r6lS*7GOeppy{&I&Ly zjOTz=9~jC|qWXznRbrfjg!1`cE!Hzyjzw6l{%>X)TK(UEGi9Uy3f9D6bbn0gT-s`< z8%$Msh!^8WidX7S;)n2jh_n1-QCtSyOAKcPQc(Xlf0*Q|5CSBjo(I-u!R0GJgzTkL z|6QdQRrUMbUO|q0dQ%+d^4)*Mjbm$R}RUcz(7|E0Bq-bAYY@)OsM<+2>}CV zzPBgeD~kBHE(Y+@l2orJrdtV7XXq_V8IETas%7OCYo`oi)+h&v#YN!Qpp7drXFS>6 z?r-q7px+(rIy+bo1uU#I2A5s@ASe01FgGMbouFkhbkm-9yZ8Q2@Q1vuhDQ3D3L+zA z(uz8^rc24VmE5r0Gbd;yOrXnQKAEBfa3@T7fcF$#QYv^00)VZPYehpSc@?^8we}o{ zlX0~o_I<`xSfI8xF(WXO-DX1>wJ`XN?4rw@}_RLD*${$}UaXL=oM(=SDMIxZj1Ji#jAcrH7nYG`r z#ewodj>F5Bf9j(j`a;>)=*2j_ZN}vf!~Hq`2Eyt;9UH1_(yjq1OUO(1M0lI3FZ2j-fU9)L59v&OiQ>5$;d!jg?Fo{Svf5t5FCZbb?)* zJN=Q!?2BztV$7)CWtG0MO~Lr4E5>aoHD5N4(+@~gQEbZTc4s3HrIl_G23PCng4Y3f zbLZK1A-x9x!)WwuI=UBkQ5QyE^&Nrw?@fsRKK41G9-xq=#VyO%CEo`{_eioDj%M!3x=>I zfOPFiFX{1t-|+3E@?UuK=0miGN04hW0=JnJrEyWw{Bg-jMvAA}cg<5LN1c5BQdrIZ z#+bxj9Jbu`11@IUjU|RKfL(UzRlVB4XT ze|(WaxL$KiRqkgCr3^Al(19!_Y7b=E(4Xm7LCO$y5+k;Fu6B#=OSzW`-7p{zRv-_) zPr!|km?8aF}+3hm)QG92YaI+jctX&5IrvTUGf{Y$)TK6)s9v!SMhU=HIpEC~2 z4>o14mG$El2sTA(Ct?xS!l*x7^)oo}|3+BF8QNe;bBHcqdHVmb?#cbS*NqZ%mYS~z z`KLoq7B#KULt%9a#DE%VTEo4TV03T2nr`FK5jUTA$FP0JH6F9oD*|0z1Yf2b5?H0_ zD|K|_5Zk`uu?ZN0U! z_mL>>F;mnHU=@to!Vv*s4;TQr9y)L@1BXXz^a85NSifPTL4h6I>+m_S3~FkXB{N?E zS<3ue_(wqaIS5;4e9{HB`Okl9Y}iFiju+oTqb)BY)QT?~3Oag7nGu-NB5VCOFsiRs zs@m%Ruwl^FuJ1b}g^=*_R?=SYJQ@7o>c9j>)1HgB zyN9LI9ifwu{Shlb6QO2#MWhxq~IG!U^I!6%5}(sbi>=bq8!8@s;4Iaun#kvh7NPwX34Rjbp2f!D)cF&sNIO%9~;C`cs&ZY2=d@c3PpN$YZjUT}X7rY`dlWX$yc znw(7=fzWapI=KzQnJ(6!o0K_aDk!^dZ#)pSTif+jQtQXga$bPApM z=);jZ5c*?*GoeGMnV0=RrZucRRYBjx>tx`A3OuY)#tp2w7mh}&kj)SKoAvbbf;uO! z?+RItUow0xc*6StuO4D--+qY!o}Isy}s;ts5aM5X~eJUZoLOq@dGv=a4hHJD<* z5q{dZSN{bv_(Vj#pFm7Q<$C;MwL|Qizm~QCFx~xQyJoCOZ$`sYD}}q>PwRZjb<=E< zAeMP?qVfM>xu2}Il2xT6={KBdDIstxY-`5IWXN zUiWV&Oiy5R_=2X9Y$ug9Ee=ZSCaza!>dWBMYWrq7uqp>25`btLn^@ydwz?+v?-?2V z?yVwD=rAO!JEABUU1hQ|cY+_OZ14Hb-Ef`qemxp+ZSK?Z;r!gDkJ}&ayJBx+7>#~^ zTm<>LzxR^t-P;1x3$h;-xzQgveY$^C28?jNM6@8$uJiY81sCwNi~+F=78qJZ@bIsz1CO! zgtPM~p6kaCR~-M>zpRCpQI}kUfaiZS`ez6%P6%*!$YCfF=sn}dg!593GFRw>OV2nQ ztTF6uB&}1J`r>gJuBP(z%KW{I^Uz%(^r5#$SK~%w1agl)Gg9Zy9fSK0kyLE24Z(34 zYtihZMQO^*=eY=<5R6LztHaB1AcuIrXoFuQ=7&C}L{c?Z$rto$%n=!whqoqG>#vvC z2%J5LVkU%Ta8hoM($p1WqN}wurA!d@#mQGU5Nb>~#XC84EYH)Zf&DZR!uY+-;VqS< z@q?$ggdX#auS#%%%oS^EN)?JhSR4JYpSgGRQZD<9!YvvF+zp0>C#$!x*x}l8U|Bb& zv?v*im5Bq_(5Wi40b1^nKun$XTST(a8yOAcqQZmKTgGLo)Ig6JuEh5J9NnqJXin@Gxzz-k6xXWYJ&@=JZw=$+ zFPGde%HsR`gI+y`rtiPaMYwbtyp!sVb!pX~;c3zLoPO0eaZSV+O_z z%9H@UhqNowzBTPcMfL6kC>LRaFF6KVaSv1R@%4}rtleX!EMnL`rethYrhTLj1x$tj z;)H!fKo08&T(;i|FT&rPgZ*D0d=B2dXuO_(Uaoi9+vEhs4%{AD{Fl@4^|`X=PvH(s zI7$6bWJiWndP$;&!kSCIR1l57F2?yzmZm~lA5%JKVb;1rQwj*O=^WW~`+n*+fQkK0 zydInOU1Be2`jhA!rnk1iRWR=1SOZpzFoU5{OPpc&A#j6Oc?D&>fAw=>x@H7?SN;d^ z-o&}WR;E|OR`QKItu(y4mT)%Pgqju-3uyH?Y@5>oSLO2Y(0(P!?_xOL=@5+R7rWw# z3J8%Hb@%Pzf^`=J6fEJ_aG6+e7>OUnhaO1(R1<6>f}L z?d@Wnqw9?^;2?q(b@?Wd=T6r_8a@Z4)*_@Q7A`+ zW3w?j!HW0KbhxF%D`9d2HpvIrBxM!36W3Yh5=8_0qYfnHm*yiLB?Ay|V10N%F9XYq zanaDtDk$rS+|_H_r|a${C}C7b{E)Ii20-a?Grff$E?&|gWF<#Ern2GqhCiS0~Y%knIi8zY^lE4qLaR-3M;_Rkz(s;wu z9207W1PXIe#4h4Zw}dvdV&FYcnUlD5_C4hzJ@bPSBVBLpl$&52mi+wwH;svyVIzAB zoA+NQ;Hpqh?A}^Et~xhl>YQNQwh20!muW{ zq}|Pg3jHZWnDBN?r1KhiVG$%Sm-4+=Q2MZzlNr3{#Abqb9j}KK%sHZj{Vr2y4~GIQ zA3Mz1DjQ3q(CC~OyCaZn0M2!){)S!!L~t>-wA&%01?-*H5?nzW?LJB`{r&)vLB4!K zrSm({8SeZ0w(bL9%ZZAZ*^jf=8mAjK^ZR0q9004|3%73z#`-Npqx*X^Ozbja!C1MW z-M~84#=rU1r>p{+h9JU<#K_x$eWqJ+aP%e?7KTSK&1>dlxwhQmkr69uG~0iD@y|L- zlY0vSR2|IhZoS6PpfUai_AhKo2HfdD&mhv#k51CX;T z*sU)XbDyfKjxYC$*_^(U)2-c0>GJ(zVm$CihHKlFSw&1A$mq$vsRt-!$jJe3GTaZ6 z3GcVvmwZ0D>`U+f3i*pQ>${p1UeyF~G9g~g-n{ThVOuC#9=ok`Zgz@qKCSN!1&P`N z=pdlGNwal%9;)ujwWH*#K6CQG*fJDAQiKlO2vKJHeA1lj&WQC+VU^@ea8$#~UOX$*Q!V^8L- zL0$W5(Y3=??%&j_WUq6*x>=?BfmI*d8fmDF*-!XVvxL8p7$r+}Igd_(&`|D*;Z#GE zqm{tHx&aHBpXw&~l6>7-FlyiSPJtTJblAjLU5Ho$FeN0mDguFAq?r+6^~o6|b+rfE zGVcZ&O-X~tE3liGcdI~hHSCT+&F&uH8rr&f{6pr^1y5061`fu~=^_|Idrgti5+*U7 zQOb9G?Rz$j-G0Y}x+i{HB0!4ZmKzykB<0;Rbmo2)T4|VdcwujI_otLG@@8OOKg3kw zP|0ST0D4@zT?O=(0Pikp)Rpwxw_VsmW4!^j^sFd6r5l zw}SG_HQPs>ae%Bq{sye_SaBX%|F-}&^)Wz@Xi<)YNbO?lPs7z@3c;$b^Aw@>E%mOj zW^c%IdtC(Kk@s*}9NbKxEf8SZtP+32ZTxjnrNWS7;W&D~ft{QY?oqOmxlV7JP!kW!Yj`Ur{QbbM1h=0KMaIAmWiISb7TKd4=gMeo+Tcz2>e#NihnOV%iNdx` zeiuoOK^{}D+M+p(Y7EC=&-`$B0F< zQ=zHaM;&QQR4jM$sG=N&sqOvD_Bx*drQ6c@u0()g05cwl`Xm{!S_Nuaa2KlL*rmmk z51yPE)q?Bl$sNM474Y!=zZ zc{EVGpdJ!Su{Qq%llR5O6#zK8l(ld*UVl87@|iaH@C3+*;XBxjEg&fsQrzpMo3EEG zv*Tpms7a;7!|iz8WY7={0a$0ItO-(ajXl;wX_$$yzEF5k9nc>L3wv!p{8h2)G0W?h z{v6vH=7+>$Ho^+)9hDtCd+S_yh8pzS9$)hYev-=eDu?lGIR;-fgz+dr+wcmM-^dZp z9}`&kAf$~z1ovF)>Hgxc!Xe3cju-jQRluCm;c_1=PYQygb?Oxe z!QG0L3sT_k=WpfOPL#|EPlD^t;ENCC39O?tHd<(kfx7SOcxl+E#;ff19_+{vbkZSvbS$I{#>31KZj^$n%ayX0jj}EvsgnHg16P z_A6Y)pdp>kLW<;PtR*Vs#mVb%)ao7AXw{O&hBDmD;?mc3iMH;Ac@rZZ_BQa8CQ~|0 z&d1L{in-z--lBO|pxqc%bqy^~LAGv=E*eaVU~OeuVV{d`Vv#-_W7EYdTDzVraG9H+LC_dWcgZMn~KcP)XvKWbcr5&d+=a>{*(Ha6Y1$==bR z{O-?$7H;`2dt0B%Vm?6`_?ZOjJkyu9ZJsh^WH*+es&^@KDcR%Zej%3PJ*XovgyhTbaH(!H1H_OF~=*f55Jr8A%uW zz5IoAB~1e2-tDGp9}`MnavAMy?jgPM5F%y`%$}dFLrz_* zIrO=afT8+AkK5B1s3{ZDVP$g6y$-*U*=?-fh!cNyn3q6YhNhfRxW&GLIJ2#>9bYMD7-F%{|Iw%@a=DoAAU;3k9p$`V zImKm{5HU~wq|nQFwab)_7lNckW#1z2$|oW5x7vDbBURVjw8674P?L1ogMKpHoV>;# zO%*1OwI|($UOr#hL(*M~qsn3PF%_|15uc%Hy9@D>_~N|?<%lig6yKX0a#1s$o(^Laj8bF#5fGPOFMGmMiUaxSwE}Qf#SG_f79d2Iv=TFBXzTpr$^avJ?=|arh2<+ce}&248Kw0} zhlva`wD6X~s7|37la4FnFOgIHhBiFo`lw~?lSbk{>)P(3jyVhM4O)a=GX3(sW1vIC zz0mJ>;J{!eN5#nf2>$u=3Kq>`7u9QnChi8>CjONBN-b+W_UQIuN#{N$Q<$}IOvpQP zB&5ZrY{V&D=4)voh;6<1U`PFA>V%XUW73S9D^J>cQYfzIyIV5i35WNb5K9c^|M}=* zN_C3rnjCZP1^v{;EaGK7Tp5z~B#?f5NZaAsFUOLK)mI~bJTaL8DF_eRikE{%^J?y9-n_U32EKHPCkB^ZN2*zk{bC=GM%_I z61}nkr+Plg6S0V=mY>H_KQU&)P~=y3$#$*U8FunXkb_e1O-7t@m$5re%u!_G%^?_| zRIJzg+lX$}+ba|qx)Ec6c^ip;`_QfQrD~SPa4MoyRUOtX&~^XWcO^a}KBkXK9J{ZFOA~rovYa0!7btTC*=xNQrwJ)$Eu`TT$;%V&2@y@$ISdNn ztbM7|nO+U9r;ae{{;QiNEYpe4nrFq_x3 z4Tvf^b(I@_3odwhVe!aC0X&~inrYFu# zh)+eF__8ly&nLr4KlLWl%B_ZMo=zCH2QfO^$lJ zBvU*LQ#M(5HQ}2Z9_^y~i@C#h)1C*?N3v68pY+7DD09nxowdG#_AAM5z&*|-9NcB{ z_xKUY>Ya7>TO#Bat}yM}o(~8Ck^!QHnIj8N9}c*uyIs}IEqGn`xP;q3vhW6gsqUe>`m1 z)~ad@y1=?H`1SNl?ANCs5ZD`8tG&Hi=j|R%pP(%gB8pd)Q--E?hWU@)e?>SLV4s(- z!_I^oVC0x97@I(;cnEm$ttKBnI3gXE>>`K?vAq~SK?0YSBsx{@s1ZdiKfFb|zf}ju z7@rJb3mC{U`$R`YS(Z#KyxQx_*nU`kf;}QL%bw17%5~6!mMao^-{FFmX}|ItFuR~F zAAvTF%f4XKYo>2-PJ~ro@Ly#t@Sf69CrA+rmMRpihqH7V&SXX+$Sw`HZF`I*_3Vjz z%kPMyN0J3sl>X{-h12)j&XRhAAI;Aou%%z}gI>G+32z*qpZg{m`CezFrzg#&yc<1` z%j~}PN!F5Ddq(>R{+t0v{j6v^0XwWGu@5+`-$m`_>pCzM`r}wz*8Qv=$|P0R$%tJp z>D+N4GZ|Tg>XL<6XP9_wQRGDs^1icY*5GP4>*7mGMr;V zI%kT_^_SQml6$#uRE4Ps>}?ES)_XI8m-%GN{o^itb^S7e_bM$-wo_Ws)W? zx4_6#*X;T$n2N==N0#xzb~BQU#%^NF6|~898JGDbQxjK(ex;Q}_Qn@?Y>!kkUYUeY z&VclG1#eDPU78K@^p3tAUvZi1(nFfk6AAVHWt)Wbi7dPbjA4isOY~?*1&asp!wg#Q zSpSI6*!TGn3|-%vuJE<9V_1EKkz_0%z}Mb7;E!uz)+0^k;@x+<5tzj5 z!InbRtc`YwNCbCac{plY&Y}hWp#PC{o@5UsBj#tv3f^ns^`;$MVN?>q!pW+MYeC7= zkWr1kAX(0xVQ<{qny&CO*|g1{Mk_yE>1t}_YT<5#p8P7QXf;o|s>XQ#SoA&!ddE+8 zOM&VsxsRGS(Spli?P$^pK7Ty{v86RP_6h|MU^J z`J>vn0|BG3Vf!uR0zM|GwtiTPZNb;a@@1+V5+$P4GI_&$%6m!YRGL=lz5kh?z#5f55 z76COi1`R(5p69;ThuQnJ$R3w?I?jigai2arApagd=^tT~oMUWp^u|H_@zXBjpI)Dv zEFc^_`mVu5U*;ClT?x-t9{#fto_+92GF^dotz0sFWTDwZ`s40AY@mv+Qh5c-Ts8Zp z!(v7!zPvFhUZ-xkR!IvaW`{PqN|k)L4*anbtmK+UU&K*awl?DhxRalbtmDw`$#VzK zYFaG}?$F)1j`Qx7wbn|XzMJ&g@3Ai#u5M?%CLPghk;lD^)-|21{Sr+M(suBU4}6CMTMxc_tD;X;z<1-{FeHte=kh1B9O6Hl z!v2i$d1VFC&z&58zU0`G#7^K3Cs@9LYN16O%Vz)?-iQL!G6&sg6aaX>DBZmm@lFrRJpcL{K3(;+`$9GDFDw62Mud@LZjabzVC=w$dx>TQa}U z-{dhKYTYx*C=Fio`ez@wrzx+p%Fk3i&v?6ENXMb3p^?;_&huLLueDwr zpRqHbU%i;9TmexFxCS8F1rPo-ea3!}!ew7{(($76Rdnfa`~$9{8H@f7U&0&HjZ3TZ zuBc||%FljS_e&wNZ$1ezT$*})XAfm??$_cY_?13vM^tT0EKY2ptb+v5P10}a%aTk_ zh8@_T{ns2@jTFhv`)-Vxh}u(0DiL0MUi(We_eic$;gCoqj(T_S{jDo^PahnKJUp3@ zMOk+%weP*c%K6VFXR2icY`J~-&fVMYUg6fsFI->jlA|9`+07y~$Fsz}^;w;mNk$ms zu?y)VA@QH__tvYDudhEWuDD20H&uvrf_boY{($?5{s-SDjyRxSC%%2Xs5d2dpjdk$ zU*NURD#ovwIfd^H{fXR@UuaooJtQr7$d0+(K+1UEwtG9_T?sb$ExV$e-bpf}a@YUe zuzInI59w!x;<)>Be;a7ukLW>V=8~J6nKU<0@H+SQ!Be;1Za_pw#hiuW_PMPBo8W2G z*WDtiIAN<>HQOmh)DMi{s-0H^GmV3QMf4Zu(zXT!-c;2)uv4gUwt(-}-N*|KUOo$h z+Ak^R)h8yB5UD8 zsSjHgY}KguNi?xV=tdCWqJR!~dDpFQoRJOwxrWH^vfRq4%)v;sDfIjsLXF^)uy>!i z*S8Njd7yfa`+7(|8H9j73Rh|TwFpF(8H-p;RLLIU>k<*qI%A*SL{u$%<=X@Jm1QFe zVkQ(X8P4Tohl?_tSO__^aqaI?k$CC8uNLv2mp_zD@4oDaZfEN5;3#XY!L{8B!;Dtt zb~Zge@JF|#Gsk^5$-|(OPI73po|WZh<`UxaH#Y2!&p05Ph?H)d3Bc3J4sDi$f(6K`?&D&~eHVuE@_Prkt>_&8&aq=OzoN!ANkvho;qIX(g|d#EKQbJ@;-%_iARmgSF1fEK z@B4W@5mDME7AzfL**c&2#B7xO9>rA4x$rM{N=%0=goumK1kL{TF@CSk0yvqR2oo&m z)?nyiL$9~Jt(qnEuWt9Hc_duim%|zJQYiaF*~orVNDvJB;`%ZW_2x%Uu01LeX-JP& zD&fas6d3=igAgcfeki79{5!XPHHYR#nfLYRKv^wkv~cnEbLHMwQ8%yCZI^rK!D2qT zk40Vg;e!_!3d56&umIuidN?6MTZFzHot}AdqKzDh#w0s`)cV!2A74RSH1@lDXtC38 z+UhO4A9?oZEOV{bIgGd1{2qMR&xT+}q!=I8m)W23v!W2WPC?Tf!F!e%_(m^lQZtq* zYwi}gY(KZ*Y^OWRNj$Ph#uEEBM+wtN8QFQ@^`GDOln^ioNrmtvzNNi*qS5lPHxI96#sMil*teLVaa%$msF>@5p#SjT%q8|<4ZOUB#!-kG+|eFSED z!|3c8fXaym9qH`L;pmqTWcG}WE$(h1sZ3seM>)E3ptoP<;~h~qe6XA)lGVanf&->P zjZwi;_;Dt+bYdAeD_XSQ-DgXRXqLv`3Wcgl}myA-JlzBBIh zWq4Q*9#(zjAk_H8VS_AJ`?OS*^gB-rp|~qt;v(C5ef=SErv;~zL64hW`#g!UZQcvZ zF6Ra@S@YhVSkSWVAY=Z1w)w-hfJDRwKTUH0o-OG5TlW0HDH36hIjnP=?A+8u1)Qyy5U8Gi$! zt^!vy|f=YHfQ`ZRK?D zXXn*kItRg50vr2+_hV5kjOleg#s~z(J2p#`=1Tq4#JS`MC^e4p&s7Ir=3m(K$LW#` z=ULCoWtna!so+QQ*JHb~6Ps9_&Ag>9qsUskp0pKbi`n?(u3&@QT!?}N}rXn z>1eHi6(@LicU*AR1obe+nbzTCD#VTJ`PFLRT(nc$NWrhsgRwFni*D(#?W^x=J6?|b zENSc^D}s>Y55)PzFs2d_2;yh89E0ZIgs&>6JV=pL6k9g_(`$04EoY+Zjn}}8e#n83 zJ=zB>BU<253Erdo$wE4^+@QQJFZyAj#(InFlN;!UGg96R@{Y&%OlGG;dM)^X8=Ddw@&2Vx?zui$tO z-{zgaU7&F!xs=e`Mn}r+xrdIAmkraRN_7P1?qu1|TZ%1QR(Mn?k+pq`Xys2v9Gs=a z?r@g&;UKcM#?36r9k*eVD(}9qe8?irotsn0+eHH8*4 zPX@Lusr)$J%8jarx5ssEJ?twFyu4kAbrf`96_z{6at^&UkyDzFa69RXP>PeK+dAWqE5<5P+aHa zs<<*+OO_2ObTXau%y)Nn{(p5`XIPWlvi|asjYcui;E@)Ig{YKBXi}spqC!-P5owwL z3L*+9;0C0G!xoN;4KNfDaElv>1#DMDglI&MAVoK2+c2Pr8&sl*1dYj=^>NRS`{O&%YV25@5*eoOvpD_(xdKsnqb^`T}bm;n0BN9ben1Ynyi*OOf;qLpf^ z!T{}GzkXSszN_Xqzp>}S*Im)_Y8~2|B*ybw(U=Q)5_NcMkT;)1&52YQJB)Tn%kPK! z@3;^AI){B(&UOv<{v9KKJrInkdcXV0%O1%1=7vYV*j?v(Kp~arZio$#(A@$kYB3aM zRdm4!^Je15%66($EkCIWGhi@=kNAyLJ3ydlJnCpPuxH0+OA}J)+t8d7nT->##Nz4w-L=S7ExQt=Rx}S*mpT91(>t~qe7tM%e|O)TIO^dP zfo61GNS=cJbLutqUh84?7X#bq)bv57s&D_zm{+xNv7vHjb=_}j-Lrj-Ss*pcD@ts$ z)5Dol8Z_&*1@JdAQE7SL$*!TXI|YE7q=YGkIiUeLvT0)14Q-ivs|+cqeT6DTi9eQ)h?Pu9pqmH51B* zFMd|;l2@D4*56|EhMFlDxl2i<8qq=c+AhMYS3(A28#3DZ;_Ln>RA3q#IAdJq7M#N> zTZ8t=_>lq0=W&w|bdQ^sy&m^@KR)mNi3|1<6|OL(0KLtP#I6ix$2b{-Y9GP5I7 z8AJUSCnlia5vWawX%ZLWTC2UV$cn^sfv68W!6)QO;ZjnX=7#`$ZPRG~irfl)ZUJ^D z{lUk?(*SU7XIiS^H{Lpxn%542#PgxdeG)Ociej#(uvX)z;Z3)<16Yhd z-sv?qQ5D4a)ZYoYPRep2Zvom@U)HKq*54ZEwdaEq^FZG#(CyG!=Vw(0j8CCmP~`_z z=OR^i&WkDCf2cLvWm@d?)mEgme{hA(o#xAL023LZ3(82SGRg6jJF7$kZ4! z6*FTm4y6v~CP!3$+fxg{QeFo24<3iucgI!oyjV|9Dsx}r~4X@lt^VaH$u zD?87}1Jh=?G8OYg*ts2k;X9{f*Za?yu8IUUfyuQ**wbcWT+KncjD^qQ3h&w2+S(Mj zZM~?Ot%ggTIHwkBkL-4&jI5R=B+MCOR42bKzC2M>l?1%x2Iv7amIfQ1B#wwfD`z|m z+E?G+o(tde*Ws?;Wo4p#Yy>Nnf|*b<nj@-s(rZ)-U@ z(Xe(qZ1(_dH|J3yWu|bAPINK}DwF(kZ>FKx(?ZmU^KFC6*bh$;FKGh~pH1 zozA+kgcIk9@2aAwEJ=VYizT!sxDXX$N?XDiGKaaT-OU@Ib=~4DmgEk&{2D@IvyjF* zuF@sDcuuqx_FAgx;B@@8gqjMh!kQeEKA*y4+q+^4&uc0|>M;$Xb+ z@X%eUx1m%$WSP}Qchx68NQ?dO!h`6;Quq+A1(RORsQ-;6bZ90vj#^0(7>cLR+-_;9 zCd@b~B5V>$tpjkQU#BD%9^zu7-l>U8nzt+XuX5cYDCHYaX5t~~3?lpa;)Mr>q;5XW zu(Th;fr}-GkP`K)u97(#UB|L3f;H7Cd#Pox+auV`=m?a=mSv1v)(V!E=$%gkIJZ;` zZj{Lb@bhs%bRa znZw9cD$cDFVHPtpXwY1K)wys@LS~;!qdqkR>@&RtP>?M^>xe{4N#EtZy4zZ5Ar$ZF zV=X=(!xin-58MC<+b~;jk8Q|3B3THGIA$cM8Bg)Yd6ygP#i?4VrX3OvP_k5i{Cppw z-{$XwrJ-+X$ccJ(Q{|?T@U9=-?qlsfA43%8t247KZn?`+C4e`b-e^(df*iW66=Oc2 z3w9UhohfdY@pH1MZ}vc<1osV(2CGG)Ree$E-T;8>$zw*>x-505b&4(shMGIjbAfLS zEZ3ys(`SmCWc(75)^=aKer}>67qj^nGKtCK{35I|tA}wQa!uM!suX%Gb~ylORGGc( ze^|m|N!}G0#Ph|;wSXz`SByQM>lPM#8>mdSQs`7RxkXaSAADYA24u6xWqkIXY?o%z z%TEFL+wNW^&nrvaA1_#P%&Hbzrjl!*hIft>F0@g0IVydUU4MJgS3_3Js8{*>|G2jC z4%n#cOy9b2Xf&Pw=14;0Dtf00C^Z$I-v05OqtvN9>sAC&oV1Tk;;ku7VR`sQK4oFq zQ8)yoZNuTwV$t13|GCUIC{ID_r7M5&R*zhsxbrkg;EgMtL|9ne=^}BM!dxV!KDeXkWA^MfQTkQEt8~t>JznNh%ULvn@dbQ2cyf} z|C%ns#NJU}SHU(7Pg$<&8uDK>d5GZJ&`;CcfGP(~b-#UusXevc^q!km1X6_wVMqGk z^m&ZS6#42?p4c_t1TA$_+}h1L2c<<=$k%;v+D!<@j5hs|{>d18>~~v#oq4yGyS@QP zgTX2oJbEy@eJbo-f{ZQ>-nmB-#AqWcHbMQXFi*T)0n!(HIexz=pp<(O*DMh7CMupX z)ei1ZYuIW~E={-ND*nD;okiZdm!?^|LjLZhs*FHZvWld5TDj zcvWB)`-1Me9bu`*4M=CO6ye=pMgxlgYvsh2rV#5Z$hFKw0GX30%oufb=hJ0BFIJH` z+Fii4gQ+7!)8K^yc*PVEW^#f!|BW0Q5*`IewQ5YDFh?{x1L7tlaUAX@3Y+D>6FPVf zJzOGex~H34`8eq+TL$FsHm+27RS>3$CG;>0Jj4*1ukX$za})*b^S5p}I2jbFCHLsA zzYwAyftMz`uo2c8ieQcy-p&9iP3fMk(uRw+OlBPm`KCLei6g!|Vnk*-kjs>A25MTE z5GLDMV$70AC0j-tx*0sCruvKh{fSM)3X}13U>m|KeaOb`9^}v^44!$`06-JHf@L4EKyxV)M!8cL zi5p9kF97RiAT92!e?%9CP=qX3wyv^A8q!w%07d(9f-U))uDgsr4FDVL;|%r)fw}-@ zlB$F79X^EKYF%8J7mU?3VzJoYQ0<;NczW1jH4=4kEh_)q|^9wj zIsn-SsmRx0_EJ7(6WypwptIwZ)-T<__UgUu?BXt zoIf|a!5`?&JEb$w2PZSqhA>J;GIA^rJ-Cpz8MKX~bcqZNOUzPtu|NMvEP>+cO;V*W zNQ8YPENkr!)lN+tlxB79RUD20$)+_P6Jc`+4q@%Kno{F+#1qR*zrj%T>nTSceO?a5 zyqGDa59#G6k*RXu6+#=e=e!~i1Y&15!cHmE6sLh_K%Ppv$tFE-Le3RQs-nx5LB>gy z5A))kwkxWSy73{@I{%{DY8X+2o{CLJb~R$3r=oT^P~Xo$2lKz8?Z!3QLn$5l#L2k2 zb1=?UT&c<8!&9gW1M&jI!5%dhJbD3nQXpaeNJ>=zR+EL!4iY(nMBQI+|2J+Hw-WMr z08Mt9h8(PGbY?zKtk=cqw(yW}1A#htn* z8&}5Y>$uc>Lv!bSuWQ5UB&ct7*jiZAFpxz|%xO&5kg zzlf?6xy7H3G^*wvP5scW*Wf(<&eP!YIUf%&HT?K)RWmKg$G^=mSoi~;&9dU%{o}WV z#BX;9+q)fpVU`>Vdo~AtYK)`7z*H;dc-e|q6Qt;3J0APUL!~g&Q literal 0 HcmV?d00001 diff --git a/pkgs/jni/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png b/pkgs/jni/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png new file mode 100644 index 0000000000000000000000000000000000000000..ed4cc16421680a50164ba74381b4b35ceaa0ccfc GIT binary patch literal 3276 zcmZ`*X*|?x8~)E?#xi3t91%vcMKbnsIy2_j%QE2ziLq8HEtbf{7%?Q-9a%z_Y^9`> zEHh*&vUG%uWkg7pKTS-`$veH@-Vg8ZdG7oAJ@<88AMX3Z{d}TU-4*=KI1-hF6u>DKF2moPt09c{` zfN3rO$X+gJI&oA$AbgKoTL8PiPI1eFOhHBDvW+$&oPl1s$+O5y3$30Jx9nC_?fg%8Om)@;^P;Ee~8ibejUNlSR{FL7-+ zCzU}3UT98m{kYI^@`mgCOJ))+D#erb#$UWt&((j-5*t1id2Zak{`aS^W*K5^gM02# zUAhZn-JAUK>i+SNuFbWWd*7n1^!}>7qZ1CqCl*T+WoAy&z9pm~0AUt1cCV24f z3M@&G~UKrjVHa zjcE@a`2;M>eV&ocly&W3h{`Kt`1Fpp?_h~9!Uj5>0eXw@$opV(@!pixIux}s5pvEqF5$OEMG0;c zAfMxC(-;nx_`}8!F?OqK19MeaswOomKeifCG-!9PiHSU$yamJhcjXiq)-}9`M<&Au|H!nKY(0`^x16f205i2i;E%(4!?0lLq0sH_%)Wzij)B{HZxYWRl3DLaN5`)L zx=x=|^RA?d*TRCwF%`zN6wn_1C4n;lZG(9kT;2Uhl&2jQYtC1TbwQlP^BZHY!MoHm zjQ9)uu_K)ObgvvPb}!SIXFCtN!-%sBQe{6NU=&AtZJS%}eE$i}FIll!r>~b$6gt)V z7x>OFE}YetHPc-tWeu!P@qIWb@Z$bd!*!*udxwO6&gJ)q24$RSU^2Mb%-_`dR2`nW z)}7_4=iR`Tp$TPfd+uieo)8B}Q9#?Szmy!`gcROB@NIehK|?!3`r^1>av?}e<$Qo` zo{Qn#X4ktRy<-+f#c@vILAm;*sfS}r(3rl+{op?Hx|~DU#qsDcQDTvP*!c>h*nXU6 zR=Un;i9D!LcnC(AQ$lTUv^pgv4Z`T@vRP3{&xb^drmjvOruIBJ%3rQAFLl7d9_S64 zN-Uv?R`EzkbYIo)af7_M=X$2p`!u?nr?XqQ_*F-@@(V zFbNeVEzbr;i2fefJ@Gir3-s`syC93he_krL1eb;r(}0yUkuEK34aYvC@(yGi`*oq? zw5g_abg=`5Fdh1Z+clSv*N*Jifmh&3Ghm0A=^s4be*z5N!i^FzLiShgkrkwsHfMjf z*7&-G@W>p6En#dk<^s@G?$7gi_l)y7k`ZY=?ThvvVKL~kM{ehG7-q6=#%Q8F&VsB* zeW^I zUq+tV(~D&Ii_=gn-2QbF3;Fx#%ajjgO05lfF8#kIllzHc=P}a3$S_XsuZI0?0__%O zjiL!@(C0$Nr+r$>bHk(_oc!BUz;)>Xm!s*C!32m1W<*z$^&xRwa+AaAG= z9t4X~7UJht1-z88yEKjJ68HSze5|nKKF9(Chw`{OoG{eG0mo`^93gaJmAP_i_jF8a z({|&fX70PXVE(#wb11j&g4f{_n>)wUYIY#vo>Rit(J=`A-NYYowTnl(N6&9XKIV(G z1aD!>hY!RCd^Sy#GL^0IgYF~)b-lczn+X}+eaa)%FFw41P#f8n2fm9=-4j7}ULi@Z zm=H8~9;)ShkOUAitb!1fvv%;2Q+o)<;_YA1O=??ie>JmIiTy6g+1B-1#A(NAr$JNL znVhfBc8=aoz&yqgrN|{VlpAniZVM?>0%bwB6>}S1n_OURps$}g1t%)YmCA6+5)W#B z=G^KX>C7x|X|$~;K;cc2x8RGO2{{zmjPFrfkr6AVEeW2$J9*~H-4~G&}~b+Pb}JJdODU|$n1<7GPa_>l>;{NmA^y_eXTiv z)T61teOA9Q$_5GEA_ox`1gjz>3lT2b?YY_0UJayin z64qq|Nb7^UhikaEz3M8BKhNDhLIf};)NMeS8(8?3U$ThSMIh0HG;;CW$lAp0db@s0 zu&jbmCCLGE*NktXVfP3NB;MQ>p?;*$-|htv>R`#4>OG<$_n)YvUN7bwzbWEsxAGF~ zn0Vfs?Dn4}Vd|Cf5T-#a52Knf0f*#2D4Lq>-Su4g`$q={+5L$Ta|N8yfZ}rgQm;&b z0A4?$Hg5UkzI)29=>XSzdH4wH8B@_KE{mSc>e3{yGbeiBY_+?^t_a#2^*x_AmN&J$ zf9@<5N15~ty+uwrz0g5k$sL9*mKQazK2h19UW~#H_X83ap-GAGf#8Q5b8n@B8N2HvTiZu&Mg+xhthyG3#0uIny33r?t&kzBuyI$igd`%RIcO8{s$$R3+Z zt{ENUO)pqm_&<(vPf*$q1FvC}W&G)HQOJd%x4PbxogX2a4eW-%KqA5+x#x`g)fN&@ zLjG8|!rCj3y0%N)NkbJVJgDu5tOdMWS|y|Tsb)Z04-oAVZ%Mb311P}}SG#!q_ffMV z@*L#25zW6Ho?-x~8pKw4u9X)qFI7TRC)LlEL6oQ9#!*0k{=p?Vf_^?4YR(M z`uD+8&I-M*`sz5af#gd$8rr|oRMVgeI~soPKB{Q{FwV-FW)>BlS?inI8girWs=mo5b18{#~CJz!miCgQYU>KtCPt()StN;x)c2P3bMVB$o(QUh z$cRQlo_?#k`7A{Tw z!~_YKSd(%1dBM+KE!5I2)ZZsGz|`+*fB*n}yxtKVyx14Ba#1H&(%P{RubhEf9thF1v;3|2E37{m+a>GbI`Jdw*pGcA%L+*Q#&*YQOJ$_%U#(BDn``;rKxi&&)LfRxIZ*98z8UWRslDo@Xu)QVh}rB>bKwe@Bjzwg%m$hd zG)gFMgHZlPxGcm3paLLb44yHI|Ag0wdp!_yD5R<|B29Ui~27`?vfy#ktk_KyHWMDA42{J=Uq-o}i z*%kZ@45mQ-Rw?0?K+z{&5KFc}xc5Q%1PFAbL_xCmpj?JNAm>L6SjrCMpiK}5LG0ZE zO>_%)r1c48n{Iv*t(u1=&kH zeO=ifbFy+6aSK)V_5t;NKhE#$Iz=+Oii|KDJ}W>g}0%`Svgra*tnS6TRU4iTH*e=dj~I` zym|EM*}I1?pT2#3`oZ(|3I-Y$DkeHMN=8~%YSR?;>=X?(Emci*ZIz9+t<|S1>hE8$ zVa1LmTh{DZv}x6@Wz!a}+qZDz%AHHMuHCzM^XlEpr!QPzf9QzkS_0!&1MPx*ICxe}RFdTH+c}l9E`G zYL#4+3Zxi}3=A!G4S>ir#L(2r)WFKnP}jiR%D`ZOPH`@ZhTQy=%(P0}8ZH)|z6jL7 N;OXk;vd$@?2>?>Ex^Vyi literal 0 HcmV?d00001 diff --git a/pkgs/jni/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png b/pkgs/jni/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png new file mode 100644 index 0000000000000000000000000000000000000000..bcbf36df2f2aaaa0a63c7dabc94e600184229d0d GIT binary patch literal 5933 zcmZ{Idpwix|Np(&m_yAF>K&UIn{t*2ZOdsShYs(MibU!|=pZCJq~7E>B$QJr)hC5| zmk?V?ES039lQ~RC!kjkl-TU4?|NZ{>J$CPLUH9vHy`Hbhhnc~SD_vpzBp6Xw4`$%jfmPw(;etLCccvfU-s)1A zLl8-RiSx!#?Kwzd0E&>h;Fc z^;S84cUH7gMe#2}MHYcDXgbkI+Qh^X4BV~6y<@s`gMSNX!4@g8?ojjj5hZj5X4g9D zavr_NoeZ=4vim%!Y`GnF-?2_Gb)g$xAo>#zCOLB-jPww8a%c|r&DC=eVdE;y+HwH@ zy`JK(oq+Yw^-hLvWO4B8orWwLiKT!hX!?xw`kz%INd5f)>k1PZ`ZfM&&Ngw)HiXA| ze=+%KkiLe1hd>h!ZO2O$45alH0O|E+>G2oCiJ|3y2c$;XedBozx93BprOr$#d{W5sb*hQQ~M@+v_m!8s?9+{Q0adM?ip3qQ*P5$R~dFvP+5KOH_^A+l-qu5flE*KLJp!rtjqTVqJsmpc1 zo>T>*ja-V&ma7)K?CE9RTsKQKk7lhx$L`9d6-Gq`_zKDa6*>csToQ{&0rWf$mD7x~S3{oA z1wUZl&^{qbX>y*T71~3NWd1Wfgjg)<~BnK96Ro#om&~8mU{}D!Fu# zTrKKSM8gY^*47b2Vr|ZZe&m9Y`n+Y8lHvtlBbIjNl3pGxU{!#Crl5RPIO~!L5Y({ym~8%Ox-9g>IW8 zSz2G6D#F|L^lcotrZx4cFdfw6f){tqITj6>HSW&ijlgTJTGbc7Q#=)*Be0-s0$fCk z^YaG;7Q1dfJq#p|EJ~YYmqjs`M0jPl=E`Id{+h%Lo*|8xp6K7yfgjqiH7{61$4x~A zNnH+65?QCtL;_w(|mDNJXybin=rOy-i7A@lXEu z&jY(5jhjlP{TsjMe$*b^2kp8LeAXu~*q&5;|3v|4w4Ij_4c{4GG8={;=K#lh{#C8v z&t9d7bf{@9aUaE94V~4wtQ|LMT*Ruuu0Ndjj*vh2pWW@|KeeXi(vt!YXi~I6?r5PG z$_{M*wrccE6x42nPaJUO#tBu$l#MInrZhej_Tqki{;BT0VZeb$Ba%;>L!##cvieb2 zwn(_+o!zhMk@l~$$}hivyebloEnNQmOy6biopy`GL?=hN&2)hsA0@fj=A^uEv~TFE z<|ZJIWplBEmufYI)<>IXMv(c+I^y6qBthESbAnk?0N(PI>4{ASayV1ErZ&dsM4Z@E-)F&V0>tIF+Oubl zin^4Qx@`Un4kRiPq+LX5{4*+twI#F~PE7g{FpJ`{)K()FH+VG^>)C-VgK>S=PH!m^ zE$+Cfz!Ja`s^Vo(fd&+U{W|K$e(|{YG;^9{D|UdadmUW;j;&V!rU)W_@kqQj*Frp~ z7=kRxk)d1$$38B03-E_|v=<*~p3>)2w*eXo(vk%HCXeT5lf_Z+D}(Uju=(WdZ4xa( zg>98lC^Z_`s-=ra9ZC^lAF?rIvQZpAMz8-#EgX;`lc6*53ckpxG}(pJp~0XBd9?RP zq!J-f`h0dC*nWxKUh~8YqN{SjiJ6vLBkMRo?;|eA(I!akhGm^}JXoL_sHYkGEQWWf zTR_u*Ga~Y!hUuqb`h|`DS-T)yCiF#s<KR}hC~F%m)?xjzj6w#Za%~XsXFS@P0E3t*qs)tR43%!OUxs(|FTR4Sjz(N zppN>{Ip2l3esk9rtB#+To92s~*WGK`G+ECt6D>Bvm|0`>Img`jUr$r@##&!1Ud{r| zgC@cPkNL_na`74%fIk)NaP-0UGq`|9gB}oHRoRU7U>Uqe!U61fY7*Nj(JiFa-B7Av z;VNDv7Xx&CTwh(C2ZT{ot`!E~1i1kK;VtIh?;a1iLWifv8121n6X!{C%kw|h-Z8_U z9Y8M38M2QG^=h+dW*$CJFmuVcrvD*0hbFOD=~wU?C5VqNiIgAs#4axofE*WFYd|K;Et18?xaI|v-0hN#D#7j z5I{XH)+v0)ZYF=-qloGQ>!)q_2S(Lg3<=UsLn%O)V-mhI-nc_cJZu(QWRY)*1il%n zOR5Kdi)zL-5w~lOixilSSF9YQ29*H+Br2*T2lJ?aSLKBwv7}*ZfICEb$t>z&A+O3C z^@_rpf0S7MO<3?73G5{LWrDWfhy-c7%M}E>0!Q(Iu71MYB(|gk$2`jH?!>ND0?xZu z1V|&*VsEG9U zm)!4#oTcgOO6Hqt3^vcHx>n}%pyf|NSNyTZX*f+TODT`F%IyvCpY?BGELP#s<|D{U z9lUTj%P6>^0Y$fvIdSj5*=&VVMy&nms=!=2y<5DP8x;Z13#YXf7}G)sc$_TQQ=4BD zQ1Le^y+BwHl7T6)`Q&9H&A2fJ@IPa;On5n!VNqWUiA*XXOnvoSjEIKW<$V~1?#zts>enlSTQaG2A|Ck4WkZWQoeOu(te znV;souKbA2W=)YWldqW@fV^$6EuB`lFmXYm%WqI}X?I1I7(mQ8U-pm+Ya* z|7o6wac&1>GuQfIvzU7YHIz_|V;J*CMLJolXMx^9CI;I+{Nph?sf2pX@%OKT;N@Uz9Y zzuNq11Ccdwtr(TDLx}N!>?weLLkv~i!xfI0HGWff*!12E*?7QzzZT%TX{5b7{8^*A z3ut^C4uxSDf=~t4wZ%L%gO_WS7SR4Ok7hJ;tvZ9QBfVE%2)6hE>xu9y*2%X5y%g$8 z*8&(XxwN?dO?2b4VSa@On~5A?zZZ{^s3rXm54Cfi-%4hBFSk|zY9u(3d1ButJuZ1@ zfOHtpSt)uJnL`zg9bBvUkjbPO0xNr{^{h0~$I$XQzel_OIEkgT5L!dW1uSnKsEMVp z9t^dfkxq=BneR9`%b#nWSdj)u1G=Ehv0$L@xe_eG$Ac%f7 zy`*X(p0r3FdCTa1AX^BtmPJNR4%S1nyu-AM-8)~t-KII9GEJU)W^ng7C@3%&3lj$2 z4niLa8)fJ2g>%`;;!re+Vh{3V^}9osx@pH8>b0#d8p`Dgm{I?y@dUJ4QcSB<+FAuT)O9gMlwrERIy z6)DFLaEhJkQ7S4^Qr!JA6*SYni$THFtE)0@%!vAw%X7y~!#k0?-|&6VIpFY9>5GhK zr;nM-Z`Omh>1>7;&?VC5JQoKi<`!BU_&GLzR%92V$kMohNpMDB=&NzMB&w-^SF~_# zNsTca>J{Y555+z|IT75yW;wi5A1Z zyzv|4l|xZ-Oy8r8_c8X)h%|a8#(oWcgS5P6gtuCA_vA!t=)IFTL{nnh8iW!B$i=Kd zj1ILrL;ht_4aRKF(l1%^dUyVxgK!2QsL)-{x$`q5wWjjN6B!Cj)jB=bii;9&Ee-;< zJfVk(8EOrbM&5mUciP49{Z43|TLoE#j(nQN_MaKt16dp#T6jF7z?^5*KwoT-Y`rs$ z?}8)#5Dg-Rx!PTa2R5; zx0zhW{BOpx_wKPlTu;4ev-0dUwp;g3qqIi|UMC@A?zEb3RXY`z_}gbwju zzlNht0WR%g@R5CVvg#+fb)o!I*Zpe?{_+oGq*wOmCWQ=(Ra-Q9mx#6SsqWAp*-Jzb zKvuPthpH(Fn_k>2XPu!=+C{vZsF8<9p!T}U+ICbNtO}IAqxa57*L&T>M6I0ogt&l> z^3k#b#S1--$byAaU&sZL$6(6mrf)OqZXpUPbVW%T|4T}20q9SQ&;3?oRz6rSDP4`b z(}J^?+mzbp>MQDD{ziSS0K(2^V4_anz9JV|Y_5{kF3spgW%EO6JpJ(rnnIN%;xkKf zn~;I&OGHKII3ZQ&?sHlEy)jqCyfeusjPMo7sLVr~??NAknqCbuDmo+7tp8vrKykMb z(y`R)pVp}ZgTErmi+z`UyQU*G5stQRsx*J^XW}LHi_af?(bJ8DPho0b)^PT|(`_A$ zFCYCCF={BknK&KYTAVaHE{lqJs4g6B@O&^5oTPLkmqAB#T#m!l9?wz!C}#a6w)Z~Z z6jx{dsXhI(|D)x%Yu49%ioD-~4}+hCA8Q;w_A$79%n+X84jbf?Nh?kRNRzyAi{_oV zU)LqH-yRdPxp;>vBAWqH4E z(WL)}-rb<_R^B~fI%ddj?Qxhp^5_~)6-aB`D~Nd$S`LY_O&&Fme>Id)+iI>%9V-68 z3crl=15^%0qA~}ksw@^dpZ`p;m=ury;-OV63*;zQyRs4?1?8lbUL!bR+C~2Zz1O+E@6ZQW!wvv z|NLqSP0^*J2Twq@yws%~V0^h05B8BMNHv_ZZT+=d%T#i{faiqN+ut5Bc`uQPM zgO+b1uj;)i!N94RJ>5RjTNXN{gAZel|L8S4r!NT{7)_=|`}D~ElU#2er}8~UE$Q>g zZryBhOd|J-U72{1q;Lb!^3mf+H$x6(hJHn$ZJRqCp^In_PD+>6KWnCnCXA35(}g!X z;3YI1luR&*1IvESL~*aF8(?4deU`9!cxB{8IO?PpZ{O5&uY<0DIERh2wEoAP@bayv z#$WTjR*$bN8^~AGZu+85uHo&AulFjmh*pupai?o?+>rZ7@@Xk4muI}ZqH`n&<@_Vn zvT!GF-_Ngd$B7kLge~&3qC;TE=tEid(nQB*qzXI0m46ma*2d(Sd*M%@Zc{kCFcs;1 zky%U)Pyg3wm_g12J`lS4n+Sg=L)-Y`bU705E5wk&zVEZw`eM#~AHHW96@D>bz#7?- zV`xlac^e`Zh_O+B5-kO=$04{<cKUG?R&#bnF}-?4(Jq+?Ph!9g zx@s~F)Uwub>Ratv&v85!6}3{n$bYb+p!w(l8Na6cSyEx#{r7>^YvIj8L?c*{mcB^x zqnv*lu-B1ORFtrmhfe}$I8~h*3!Ys%FNQv!P2tA^wjbH f$KZHO*s&vt|9^w-6P?|#0pRK8NSwWJ?9znhg z3{`3j3=J&|48MRv4KElNN(~qoUL`OvSj}Ky5HFasE6@fg!ItFh?!xdN1Q+aGJ{c&& zS>O>_%)r1c48n{Iv*t(u1=&kHeO=ifbFy+6aSK)V_AxLppYn8Z42d|rc6w}vOsL55 z`t&mC&y2@JTEyg!eDiFX^k#CC!jq%>erB=yHqUP0XcDOTw6ko}L zX;EmMrq(fKk*eygEuA616;0)>@A{TK|55PV@70 z$OfzS*(VJxQev3J?yY?O=ul(v`fp}?u9z`JK3ugibK>)DyCwImZOF4d{xK%%Ks1*} zv$oa)9anR%lXIBUqYnhLmT>VOzHfNP?ZwJNZ!5$s9M08RynIvaXw>@G^T9@r9^KH1 zVy??F&uuk)bH9Y4pQY!hP58i_H6 znl-NcuCpLV6ZWU;4C zu@9exF&OZi`Bovq_m%T+WhU2kvkz@^_LpycBvqm3bMpLw8X-Or5sL>0AKE1$(k_L=_Zc=CUq#=x1-QZf)G7nHu@fmsQ1eN_N3+nTEz`4HI4Z6uVlE zJH+X&det8JU?tO?upcM4Z=cV!JV;yF>FfL5Q$M|W_2Z!P`S=}Wzp|_1^#d%e?_H`> zV@%vA$+bFVqhw9`U;TfP|5|PD{||OiYdor8P*i??|NJcb%kzT_73*7WE?Ua5hAnR2 z=7WE=PhTlJ#ZeRznjTUb;`E(wkMZrj4e|Hilz-mK>9cZHQY**5TUPw~u}k;u73KI}xAx!0m-)GVia|x^d3p~s_9gh83jA&Ra<8rM%`>U3x69t&NzbwWY}7Ar?)FK#IZ0z|d0H0EkRO w3{9;}4Xg|ebq&m|3=9_N6z8I7$jwj5OsmAL;bP(Gi$Dzwp00i_>zopr02+f8CIA2c literal 0 HcmV?d00001 diff --git a/pkgs/jni/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png b/pkgs/jni/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png new file mode 100644 index 0000000000000000000000000000000000000000..e71a726136a47ed24125c7efc79d68a4a01961b4 GIT binary patch literal 14800 zcmZ{Lc|26@`~R6Crm_qwyCLMMh!)vm)F@HWt|+6V6lE=CaHfcnn4;2x(VilEl9-V} zsce-cGK|WaF}4{T=lt&J`Fy_L-|vs#>v^7+XU=`!*L|PszSj43o%o$Dj`9mM7C;ar z@3hrnHw59q|KcHn4EQr~{_70*BYk4yj*SqM&s>NcnFoIBdT-sm1A@YrK@dF#f+SPu z{Sb8441xx|AjtYQ1gQq5z1g(^49Fba=I8)nl7BMGpQeB(^8>dY41u79Dw6+j(A_jO z@K83?X~$;S-ud$gYZfZg5|bdvlI`TMaqs!>e}3%9HXev<6;dZZT8Yx`&;pKnN*iCJ z&x_ycWo9{*O}Gc$JHU`%s*$C%@v73hd+Mf%%9ph_Y1juXamcTAHd9tkwoua7yBu?V zgROzw>LbxAw3^;bZU~ZGnnHW?=7r9ZAK#wxT;0O<*z~_>^uV+VCU9B@)|r z*z^v>$!oH7%WZYrwf)zjGU|(8I%9PoktcsH8`z^%$48u z(O_}1U25s@Q*9{-3O!+t?w*QHo;~P99;6-KTGO{Cb#ADDYWF!eATsx{xh-!YMBiuE z%bJc7j^^B$Sa|27XRxg(XTaxWoFI}VFfV>0py8mMM;b^vH}49j;kwCA+Lw=q8lptk z?Pe`{wHI39A&xYkltf5*y%;-DF>5v`-lm0vydYtmqo0sClh5ueHCLJ+6$0y67Z zO-_LCT|JXi3tN7fB-!0_Kn#I+=tyUj87uR5*0>|SZ zy3x2;aql87`{aPZ@UbBwY0;Z-a*lYL90YApOAMKur7YgOiqA~Cne6%b&{V-t>Am2c z{eyEuKl!GsA*jF2H_gvX?bP~v46%3ax$r~B$HnZQ;UiCmRl`ROK8v>;Zs~upH9}qu1ZA3kn-AY2k2@CaH=Qh7K6`nU z3ib(Bk%H*^_omL6N4_G5NpY20UXGi}a$!}#lf<&J4~nhRwRM5cCB3Zvv#6+N1$g@W zj9?qmQ`zz-G9HTpoNl~bCOaEQqlTVYi7G0WmB5E34;f{SGcLvFpOb`+Zm)C(wjqLA z2;+nmB6~QDXbxZGWKLt38I%X$Q!;h zup9S~byxKv=$x|^YEV;l0l67jH~E8BU45ft_7xomac-48oq4PZpSNJbw<7DTM4mmz z!$)z#04cy%b8w@cOvjmb36o;gwYIOLwy+{I#3dJj#W4QdOWwJQ2#20AL49`hSFUa7 zFNAN3OD==G3_kbr1d96>l`_cI`<=thKNh5>hgg7FV>5TfC6d#u)9BNXi@p1K*;2Is zz+x;l4GbSt#*%>1iq}jGIebXYJY5;PGG0y(^{>SSuZY89aL`sDghOM&&pyP6ABJ#w zYwK~4^1eUQD)4!GL>`zrWeHV z-W!6JZbW*Ngo;Edhp_cOysYr!uhKS}vIg_UC}x z=jXxQfV@4B3`5 z!u#byBVXV5GtrSx_8bnT@iKv=Uc6n)Zpa`<9N>+!J~Loxptl5$Z`!u<3a)-+P)say z#=jc7^mJzPMI2;yMhCmN7YN78E7-^S(t8E}FklC;z|4PL{bO|JieM#p1mBjwyZMEm zkX^A1RXPGeS2YqtPMX~~t^$~oeFfWAU#jVLi%Z@l2hle^3|e(q?(uS=BVauF?VF{j z(owKLJuze;_@5p1OtRyrT`EFXf)NfMYb-)E8RVVdr<@}M>4R&~P=;B`c1L%o|8YfB z-a(LB-i8jc5!&B5cowyI2~M^YID&@Xt(D9v{|DB z959W z*vEA77fh3*w*UJ`4Y(bxsoEy6hm7_Wc5gT0^cvso%Ow>9<&@9Q>mxb6-^pv)5yc>n zQ~^!qY(lPQ1EDGkr%_*y*D8T^YbCa52^MVqYpTLhgJ;N5PfCQ{SXk|plD#Sm+g4c- zFeL2Dih35W4{_qb75U`4Rb#S0FEo%F85dOhXSX0huPOxdAid{&p6P;+9}I)XU7^=3RZu9M(g0dLyz_7$8K{`AddBLOfU&B_QNHtmsnNXq`hy~% zvJ{vtz~Yt9X|o}5vXX)9ZCHaRq8iAb zUDj8%(MpzJN39LferYKvIc!)z^5T-eW@j3h9a6d%WZ!%@2^@4+6%Z9W1GHZbOj|sb z0cU$}*~G$fYvDC|XulSC_;m}?KC2jg5pxES$Bt!hA|@EX*2+O!UEb5sn_^d>z;>;r~ zmO3BivdXboPY*}amsO&`xk|e)S*u=`o67MC(1WTB;OwG+ua4UV7T5Wvy%?U{Pa5cO zMoLG>#@chO{Oc72XPyX8f3jC7P`$j4$)0wc(b50COaDP3_Cm}aPAglUa7kRXAqmo5 z0KDD7G>Gmnpons40WJNYn+pxko92GXy@PvSErKE-Ou3)3UiRr7!L4+0%+5}sD{bf)uj^ounQ-Yn2%%JoZ%FjUv%yjS?Ks4u_88Jh%tNliYW~817IV@fqd1T zi(?;Fv-s3rQEn=9G*E-QzSl%YS|^fe*yn}Aqh!&P<5%#oB?*{wZMa5$PYa*A{VA8! zbOfS1W!W}cTo%g~iP$>WhE_x7#O4?h$jq=>{M77>bTAK_ z6uU0tl6HARboGi}=4krr6WP`9`aAt&P5ON1v(+H{T?jZuJ}B{L-=z3VX)}mZwzrqH zpf?T!k&$?{&{0_p>b`kdJbSb(p~tFcuG4zh6}hfl@ues6CfJu<-P+!>FlYMlD_3!E z9$6VE==tlxNYe(s;@8@+4c4jQ$R2g8t0QwE>Et|)5)@kJj6^yaqFYY?0LEM2C!+7+ z+FN|UxR1GCy1KA`{T_%24U+Vserchr5h`;U7TZPr@43x#MMN{@vV?KSII}R@5k`7cVK}E;c)$f~_{ZLDOoL|-01p~oafxi4F zG$?Wha&a*rTnz-nTI-bAJ*SLb!5(L!#iRdvLEyo>7D_=H78-qZrm=6{hkUR{tR{H! z`ZTOV$Oi6^qX5=_{f}V9h}WJAO%h9)kEUF#*-JyYDbOGZ>Nfs%7L}4p zopIul&&Bbn!C9o83ypC6W4F$X=_|pex$V4!Whm#48Wfm3*oAW0Gc&#&b+oq<8>aZR z2BLpouQQwyf$aHpQUK3pMRj(mS^^t#s$IC3{j*m9&l7sQt@RU{o_}N-xI_lh`rND^ zX~-8$o(;p^wf3_5-WZ^qgW`e8T@37{`J)e2KJdSSCUpX6KZu0Ga&U*+u3*PDAs1uK zpl)40+fROA@Vo#vK?^@Pq%w8DO9HdfmH+~vNinZ$5GRz?sD|k246NepqZd`>81P^P z#x#3kUS-}x4k%&~iEUrsb&-X#_;;?y9oCP4crMkC`=q58#NxQ| z*NXNA;GR4X=GiGXwab5=&M3j04fQw%2UxM`S(aE)_PlgJttBX96$$lY@Q%0xV^IbcHqzw^Uk&E=vFB;EQ@kzVIeM8lDIW_Q_ zrfy)l6s2QBApF;J2xTD_@wuNMlwDfsdfMyzRq)<>qG{M)Yt}9F1{1HaI_X7=F=7>& zYB54VaKlxu0lIgS;Ac&25Aw(tcf@K~(cvPi8(OChzhlYp6}#<_MVhU95sD&)n0FtL zmxm4w$~s(S9jmHOgyovpG!x4uLfJsMsJn^QMraKAa1Ix?{zkV!a7{f%-!u2{NqZ&) zo+^XB`eFQ4 zk-(;_>T#pTKyvW${yL|XXbcv?CE2Tp<3(PjeXhu^Jrp6^Mj}lg_)jamK{g;C+q^Da ztb!gV!q5)B7G1%lVanA2b>Xs?%hzCgJ{Hc!ldr9dnz7k^xG#4pDpr|0ZmxxiUVl}j zbD_rg3yAFQ>nnc)0>71D==715jRj4XsRb2#_lJoSOwky&c4957V-|m)@>b^Nak1!8 z@DsIOS8>Oe^T>tgB)WX3Y^I^65Uae+2M;$RxX_C)Aoo0dltvoRRIVQkpnegWj;D#G z+TwFIRUN%bZW3(K{8yN8!(1i0O!X3YN?Zo08L5D~)_tWQA8&|CvuQb8Od?p_x=GMF z-B@v9iNLYS1lUsbb`!%f5+1ev8RFPk7xyx5*G;ybRw(PW*yEZ$unu2`wpH)7b@ZXEz4Jr{?KZKYl!+3^)Q z)~^g?KlPGtT!{yQU&(Z&^rVjPu>ueeZN86AnhRwc)m|;5NvM&W3xD%n`+Hjg5$e8M zKh1Ju82L~&^ z-IQ5bYhsjqJfr38iwi~8<{oeREh|3l)*Enj4&Q$+mM$15YqwXeufK9P^(O=pj=F-1 zD+&REgwY~!W#ZPccSEi(*jiKJ5)Q|zX;hP}S2T9j_);epH9JQs{n>RG}{Nak)vIbfa zFQm?H;D+tzrBN2)6{?Mo%fzN6;6d_h0Qyn61)+XT63=!T*WQyRUoB_x0_)Ir`$FtS zak07C(mOaWN5m%bk?F9X&@mEVKN%{R6obt(9qw&p>w&p;R*l2th9$D^*`pC}NmB+v z>bk;OJ(C8p$G;jNvRsBbt=a!!tKnjJ`9*yQFgjEN1HcC<&>u9aStT3>Oq=MOQV!#WOZ6{cv$YVmlJdovPRV}<=IZUPeBVh5DC z91-?kimq3JUr;UMQ@0?h52gupvG=~(5AVdP(2(%*sL8!#K1-L$9B7MrWGdt(h&whR@vz~0oEHF8u3U1Q zdGdaIytJj4x@eF*E+^zgi{nPCA8tkjN}UoR8WhDzM3-zLqx0z?2tTdDKyENM={fp8VC@3Dt`AiK$;K#H$K2{08mrHG%jgEOLX3MCsG>afZm_0mLPS4jmYUJp~Dm! z5AUe_vEaOAT3zWdwl#cLvqwd1^lwW?gt7(92wEsOE6c#<0}{szFV4(uO70?3>=((! zQr}1{J?Wx2ZmjxYL_8OB*m&mimfojzYn~PiJ2g8R&ZRx-i^yF#sdhEWXAUIZ@J?T$ zs3PgT2<&Ki>Bob_n(@S>kUIvE+nY~ti9~6j;O9VAG#{oZ!DZCW)}i6iA!Tgsyz+hC z1VVyvbQ_nwgdZSEP=U4d#U`2*`e~d4y8uM4Bcmm%!jidaee#4WqN!ZnlBmbYpuaO! z!rU3`Kl2 z0O7PD&fQ|_b)Ub!g9^s;C2e>1i*2&?1$6yEn?~Y zI)-WIN8N(5s9;grW+J@K@I%g#?G&hzmlgV=L}ZA{f>3YCMx^P{u@c5Z;U1qmdk#)L zvX6z1!sL>+@vxO8qVn#k3YxYi?8ggV){?Rn@j$+Fd4-QkuH1@)j#3-=f82GZ!nl~{ zzZ(?kO`ANttVeHSo%xmH!NmNZECh*{s!-8S>ALoe5xOPs>|P5BbUmP@rlV8`d(c=7 zypcpLaI*FM^;GM%@q`GAb8kO`$oE|R48yn)?p(c1t>5;Wwn5r6ck&uw4}TnT80jI`IS~J%q8CpaVgIze<8IykSpVBg8~E! zW_tGqB;GO47r_er05y+Kwrcn{VLxL*1;HMv@*sd}MB6DH4zaP~u4Y;>@Nw7?F8S?c zfVIY(^ntnGgWlD|idzGz$Y+Oh(Ra=&VIf4!K2W*a)(%5%78s}8qxOknAGtDAq+HMO zM+Nu;0OgQRn36 zA@~a8`uVQ~v9?d!BxnsVaB-z-djypO44BjQAmg7&eVoaew|~)wH$SgefJ2$7_RiY+ z_7ACGoFM6Lhvho+eUG@pU&0X(Uy(*j;9pr?ET?FHTXadlfXC|MReZoU5>AG`mTM<% zc~*I@E*u0|hwVTdFA~4^b2VT7_~}~tCueNY{de3og=ASFQ`)0dhC2~Ne<}}Rc?ptA zi}+bQE%N9o*hpSUMH)9xt%Zlz&^p&5=cW}{m#f85iVX64^{!(vhClT<I)+c)RuiyrZqIw4v`z%YK&;_Fh4_+0B?qAGxMfAM`LzG_bjD>ib4;KGT4_1I>sxvL&&qp40ajgQOqIE^9=Az4w#ymo)bW-Vg{T!n=l&|nR_ zw+wcH|FxUH63)~{M;goHepmD{Fe?W9sO|eJP9L$G<{e_7FxxuXQ+)(Z^@;X8I1=%k zTK$gbHA1^4W<`q~ubQ0M_C^CA5#Z&*nGc(T?4Y_2jLu&FJDQYpCSiRny->$+nC9Jl z?avTW`ZXYT51%SrEq!}dXNM&!pM6nmL^lce=%S7{_TS)ckN8;{p*LT~LMgmlE~dpL zEBQy-jDj%cSK6N3)|CCR0LQ$N6iDM~+-1Oz|LAdkip(VZcO`gqCuJ+(Mm{m6@P%_; zBtF|MMVMP;E`5NJ{&@4j^JE5j&}(Jq{lCGL(P^#uqvbD`2)FVyfNgy|pvT!XY;02Z zZWbgGsvi6#!*$Zxwd{Xk6_M{+^yV_K@%_SAW(x)Lg|*AuG-%g2#GQYk8F?W&8|2dU z;00ppzrQnnYXnT`(S%_qF2#QNz&@Y$zcq+O8p>Gto2&4z8(^#cY?DuQwBQP4Fe?qUK_-yh4xT{8O@gb`uh` z>Q%jrgPAnANn4_)->n;w{Mei#J)F+`12&+-MLKSRzF6bL3;4O~oy~v7 zL0K-=m?>>(^qDCgvFRLBI@`04EGdTxe5}xBg#7#Wb!aUED;?5BLDEvZ@tai4*Rh8& z4V)cOr}DJ0&(FjWH%50Y+&=WtB42^eEVsmaHG)Il#j265oK&Bot(+-IIn`6InmuE# z;)qXs+X{fSb8^rYb#46X5?KCzH9X0>ppBQi(aKS--;4yA%0N|D<#8RZlOS(8n26=u zv~y;KC>`ypW=aqj`&x9 z0Zm>NKp}hPJu1+QDo(_U(Gt0SZ`IJWnp%QK`pye>Bm!w{sG>;VU^2 z4lZhV1}tCE8(?zu#j99|l3-qRBcz3bG+DlyxPGB$^6B^ssc_qYQ6lG0q~EAI?1$?( zahfn%etVvuKwB7R=>JDQluP97nLDM6*5;b0Ox#b{4nIgZA*+?IvyDN{K9WGnlA=Ju z+)6hjr}{;GxQQIDr3*lf32lRp{nHP8uiz^Fa|K+dUc@wD4Kf5RPxVkUZFCdtZH{+=c$AC)G2T-Qn@BPbr zZigIhKhKrVYy`!Mlc#HVr=CURVrhUjExhI~gZ%a=WM9BwvnN?=z!_ZQ$(sP?X;2Jy zyI$}H^^SvH2tf6+Uk$pJww@ngzPp856-l9g6WtW+%Yf>N^A}->#1W2n=WJ%sZ0<){Z&#% z^Kzl$>Km)sIxKLFjtc;}bZeoaZSpL4>`jCmAeRM-NP9sQ&-mi@p0j7Iq>1n&z@8?M z%dM7K^SgE5z)@i5w#rLE4+8%|^J`a6wYr`3BlvdD>7xW?Dd>`0HC0o{w7r_ot~h*G z2gI7Y!AUZ6YN+z$=GNzns@Tu7BxgAb3MBha30-ZG7a%rckU5}y{df`lj@^+34kr5> z988PPbWYdHye~=?>uZ4N&MN@4RBLk_?9W*b$}jqt0j%>yO9QOV(*!#cX~=wRdVL&S zhPQ{${0CGU-rfdS&b@u|IK{hV2Z=(*B2d0?&jwWfT=?Gk`4T9TfMQ)CfNgpLQa#>Q z%6A$w#QNc&qOtrHAbqY>J782@!X{9Y@N(HMSr;PP^;0DlJNxfC`oMB%Ocg zC*hnEsF|p*=CVe^dT)>BTL0yff)uo!U<+_2o3p)CE8quU1JI(=6)9$KxVdJYD*S*~ zzNeSkzFIQyqK}578+qq6X8rrRdgX z4k&R=AGex~a)MoB0pK&|yA<(*J#P&tR?ImBVD)ZTA4VH5L5DxXe<-*s`Aox%H1{-^Qa`kG_DGXD%QX-;l1#&#IVQP6>kir ztO@~ZvJDPnTvKt>fc*(j$W^)JhWk{4kWwbpFIXzuPt2V%M4H19-i5Gn*6(D`4_c1+ zYoI1@yT^~9JF~t>2eVM6p=GP3b*;daJpQOhAMNO|LKnwE2B5n8y9mf;q=)-L_FfD0 z<}YIRBO{k)6AHAn8iG>pYT+3bJ7jvP9}LSMR1nZW$5HR%PD1rFz z{4XE^Vmi-QX#?|Farz=CYS_8!%$E#G%4j2+;Avz|9QBj|YIExYk?y-1(j}0h{$$MnC_*F0U2*ExSi1ZCb_S9aV zTgyGP0Cl=m`emxM4Qih1E{`J{4oJo8K}WnH`@js^pR7Z-vTBK5F5JIFCDN}7pU^_nV>NTz@2$|Kcc5o+L&^Db_AQ);F?)X5BF*QJRCdLI-a%gW z++DZM)x=6*fNrSaUA&hf&CUqC$F*y^CJC-MAm9gd*5#^mh;-dR1?a&<3-hp3@}XN! z&8dcwo6=MQua%0KFvYbi>O{j)RrbDQo3S*y!oEJ~2=}^-v%zn~@hnmKGOvX6JLr;>DNC3)={8OM9n5Zs*(DlS*|%JTniJX2Uav7sOFT0vdIiUOC5pEtY?EF)@Fh9pCfD%N zXskZ8b^ldI{HHj{-l?iWo@IW6Nr`hAS>f8S*8FGc*gmcK^f2JS+>I&r#Gcewy=-JM zv0*w<5qBa6UQB@`esOG*4*t@7c9AkrTpM`v=eY?cO#z17H9B%Xy4m!}LhW}*iZ27w1?HrevgB1SZ1q2X$mm@FK@Qt7o z!s~Lio^IRdwzyvQ80{5iYeTV@mAo=2o5>KepRH0d{*Szlg~n%w2)S5v2|K8}pj;c{ zoDRLvYJO1@?x-=mq+LVhD{l-1-Dw4`7M?3@+ z`fu7?1#9W++6Y46N=H0+bD|CJH~q*CdEBm8D##VS7`cXy4~+x=ZC17rJeBh zI~qW^&FU`+e!{AKO3(>z5Ghh14bUT$=4B>@DVm(cj* zSLA*j!?z!=SLuVvAPh_EFKx}JE8T8;Gx)LH^H136=#Jn3Bo*@?=S`5M{WJPY&~ODs z+^V57DhJ2kD^Z|&;H}eoN~sxS8~cN5u1eW{t&y{!ouH`%p4(yDZaqw$%dlm4A0f0| z8H}XZFDs?3QuqI^PEy}T;r!5+QpfKEt&V|D)Z*xoJ?XXZ+k!sU2X!rcTF4tg8vWPM zr-JE>iu9DZK`#R5gQO{nyGDALY!l@M&eZsc*j*H~l4lD)8S?R*nrdxn?ELUR4kxK? zH(t9IM~^mfPs9WxR>J{agadQg@N6%=tUQ8Bn++TC|Hbqn*q;WydeNIS@gt|3j!P`w zxCKoeKQ*WBlF%l4-apIhERKl(hXS1vVk$U?Wifi)&lL6vF@bmFXmQEe{=$iG)Zt*l z0df@_)B-P_^K2P7h=>OIQ6f0Q-E@|M?$Z5n^oN>2_sBCpN>q(LnqUoef{tm^5^L$# z{<SL zKmH78cHX`4cBKIY8u1x*lwrgP^fJ%E&&AmHrRY7^hH*=2OA9K?!+|~Aeia=nAA`5~ z#zI=h#I>@FXaGk(n)0uqelNY;A5I9obE~OjsuW!%^NxK*52CfBPWYuw--v<1v|B>h z8R=#$TS-Pt3?d@P+xqmYpL4oB8- z>w99}%xqy9W!A^ODfLq8iA@z}10u?o#nG#MXumSaybi(S{`wIM z&nE3n2gWWMu93EvtofWzvG2{v;$ysuw^8q?3n}y=pB1vUr5gi++PjiyBH3jzKBRny zSO~O++1ZLdy7v7VzS&$yY;^Z7*j_#BI`PK`dAzJa9G1{9ahPqPi1C}ti+L)WHii*= z+RZ^+at-tlatc4|akPa&9H;%gn9aS`X_kfb>n>#NTyUVM6m4NCIfLm(28>qaYv7}t zn`M;XcONtXoa3#u3{L-ytd_&g z2mO$8CnE?460w#eSm|smlnNwFHM;A&IxSKLzVkV7nNVqZ*A`)eI{Nbg6WxsarAFuc=FFf1z|%#eTvBgUhY}N zsCT>`_YO>14i^vFX0KXbARLItzT{TeD%N~=ovGtZ6j{>PxkuYlHNTe0!u>rgw#?td z{)n=QrGvgCDE6BUem$Rh(1y!$@(Bn!k3E0|>PQ(8O==zN`?yBhAqlWyq+c%+h?p^- zE&OtLind}^_=>pbhxOgOIC0q9{cLK6p6*eg_|S+p9$W~_u4wzx@N?$QmFg2S)m~^R znni$X{U*!lHgdS@fI;|Owl=9Gwi?dr0m#>yL<8<}bLW_Kpl| zSGesADX&n?qmHC`2GyIev^hi~ka}ISZ^Y4w-yUzyPxaJB0mm%ww^>if3<;P^U+L5=s+cifT-ct*;!dOOk#SOZNv@a^J|DrS3YtSn8EEAlabX1NV3RfHwZn_41Xa z4;$taa6JJR()-FQ<#0G~WlML<l5I+IPnqDpW(PP>hRcQ+S2zU?tbG^(y z1K_?1R){jF;OKGw0WYjnm>aPxnmr5?bP?^B-|Fv`TT4ecH3O`Z3`X_r;vgFn>t1tE zGE6W2PODPKUj+@a%3lB;lS?srE5lp(tZ;uvzrPb){f~n7v_^z! z=16!Vdm!Q0q#?jy0qY%#0d^J8D9o)A;Rj!~j%u>KPs-tB08{4s1ry9VS>gW~5o^L; z7vyjmfXDGRVFa@-mis2!a$GI@9kE*pe3y_C3-$iVGUTQzZE+%>vT0=r|2%xMDBC@>WlkGU4CjoWs@D(rZ zS1NB#e69fvI^O#5r$Hj;bhHPEE4)4q5*t5Gyjzyc{)o459VkEhJ$%hJUC&67k z7gdo`Q*Jm3R&?ueqBezPTa}OI9wqcc;FRTcfVXob^z|dNIB0hMkHV26$zA%YgR$sM zTKM61S}#wJ#u+0UDE3N+U*~Tz1nnV;W<8Akz&6M7-6mIF(Pq`wJ1A%loYL( zIS;&2((xbyL7zoyaY2Sa%BBYBxo6Aa*53`~e@|RA`MP+?iI4KZ+y4EU&I zS_|(#*&j2hxpELa3r0O7ok&5!ijRiRu9i-_3cdnydZU9Mp6Y);skv%!$~`i-J7e-g zj@EoHf+gtcrKf;tY5`4iLnWSHa)9brUM$XmEzG3T0BXTG_+0}p7uGLs^(uYh0j$;~ zT1&~S%_Y5VImvf1EkD7vP-@F%hRlBe{a@T!SW(4WEQd1!O47*Crf@u-TS==48iR5x z!*`Ul4AJI^vIVaN3u5UifXBX{fJ@z>4Q2#1?jpcdLocwymBgKrZ+^Cb@QuIxl58B* zD{t-W3;M;{MGHm_@&n(6A-AsD;JO#>J3o4ru{hy;k;8?=rkp0tadEEcHNECoTI(W31`El-CI0eWQ zWD4&2ehvACkLCjG`82T`L^cNNC4Oo2IH(T4e;C75IwkJ&`|ArqSKD}TX_-E*eeiU& ziUuAC)A?d>-;@9Jcmsdca>@q1`6vzo^3etEH%1Gco&gvC{;Y-qyJ$Re`#A!5Kd((5 z6sSiKnA20uPX0**Mu&6tNgTunUR1sodoNmDst1&wz8v7AG3=^huypTi`S7+GrO$D6 z)0Ja-y5r?QQ+&jVQBjitIZ`z2Ia}iXWf#=#>nU+ zL29$)Q>f#o<#4deo!Kuo@WX{G(`eLaf%(_Nc}E`q=BXHMS(Os{!g%(|&tTDIczE_# z5y%wjCp9S?&*8bS3imJi_9_COC)-_;6D9~8Om@?U2PGQpM^7LKG7Q~(AoSRgP#tZfVDF_zr;_U*!F9qsbVQ@un9O2>T4M5tr0B~~v_@a=w^8h510a#=L z;8+9zhV}57uajb+9DbZm1G`_NqOuKN`bQ2fw9A*v*Kdb_E-SA`?2 z)OFIY-%uD`JZUZg?D4lHtNegKgWr!1m%hOpu5`R+bZ2K#&)*R-7ElKYo0$0xYxIL8 zLg%u|4oZixz}ILB-@aS4=XOe)z!VL6@?dX{LW^YCPjKtyw44)xT=H;h(fmFr>R?p%r5*}W z7_bo0drVDRq9V9QL4_!dazughK6t}tVVvBq={T0+3(1zmb>f+|;{D%J?^xnZcqio5 z%H?@L+L-CIdO=x6QrALL9&PwvjrZi5NS)1e<*%V8ntw~S2PF}zH}B5f_DHyB=I3m@ z_;^TpN|sesCU}qxQ`~jIwF>#8wGvxg9kdMT$}us8BM&W>OzZ|ry2BB)+UY*_yH+&L zl_=Jy9BNzIZs}D~Yv_H%HPjVGNV=xT3xpIW!Np1F^G#9Y8X zl)c_V1(DhYu-v%H3-m&n%M_}}c{E5Wu+6*>R24gW_A7$(U=9D|H$r;;;@o zJ)c_CmVf9l*;4SyJ}E{+4)}^C>SIJ*_bul7OJ{v&0oO>jG(5xzYP0$I%*YH|Mwu#r zubNW5VZ9^X#Phw<;?=^G?Kg&C)^x1FVsKGZ*n+{C1znj~YHSP?6PS(k5e9qGvS4X* z=1kA_27(iV65a(i+Sicmd@Vzf^2@*Wed-`aYQ~em=-h%Pu`gHfz)&@$hpr<&mNO={ zl^kI0HP0wTbbh{d(>5a#;zT2_=ppef?;D4;2^}&kZjB^yl%LBJ;|> zkLc)JEg*5rpQ;_)w?PnKynWtv!@ z>}+am{@(g$KKM+e$ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pkgs/jni/example/macos/Runner/Configs/AppInfo.xcconfig b/pkgs/jni/example/macos/Runner/Configs/AppInfo.xcconfig new file mode 100644 index 000000000..92a02bdec --- /dev/null +++ b/pkgs/jni/example/macos/Runner/Configs/AppInfo.xcconfig @@ -0,0 +1,14 @@ +// Application-level settings for the Runner target. +// +// This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the +// future. If not, the values below would default to using the project name when this becomes a +// 'flutter create' template. + +// The application's name. By default this is also the title of the Flutter window. +PRODUCT_NAME = jni_example + +// The application's bundle identifier +PRODUCT_BUNDLE_IDENTIFIER = dev.dart.jniExample + +// The copyright displayed in application information +PRODUCT_COPYRIGHT = Copyright © 2022 dev.dart. All rights reserved. diff --git a/pkgs/jni/example/macos/Runner/Configs/Debug.xcconfig b/pkgs/jni/example/macos/Runner/Configs/Debug.xcconfig new file mode 100644 index 000000000..36b0fd946 --- /dev/null +++ b/pkgs/jni/example/macos/Runner/Configs/Debug.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Debug.xcconfig" +#include "Warnings.xcconfig" diff --git a/pkgs/jni/example/macos/Runner/Configs/Release.xcconfig b/pkgs/jni/example/macos/Runner/Configs/Release.xcconfig new file mode 100644 index 000000000..dff4f4956 --- /dev/null +++ b/pkgs/jni/example/macos/Runner/Configs/Release.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Release.xcconfig" +#include "Warnings.xcconfig" diff --git a/pkgs/jni/example/macos/Runner/Configs/Warnings.xcconfig b/pkgs/jni/example/macos/Runner/Configs/Warnings.xcconfig new file mode 100644 index 000000000..42bcbf478 --- /dev/null +++ b/pkgs/jni/example/macos/Runner/Configs/Warnings.xcconfig @@ -0,0 +1,13 @@ +WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings +GCC_WARN_UNDECLARED_SELECTOR = YES +CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES +CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE +CLANG_WARN__DUPLICATE_METHOD_MATCH = YES +CLANG_WARN_PRAGMA_PACK = YES +CLANG_WARN_STRICT_PROTOTYPES = YES +CLANG_WARN_COMMA = YES +GCC_WARN_STRICT_SELECTOR_MATCH = YES +CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES +CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES +GCC_WARN_SHADOW = YES +CLANG_WARN_UNREACHABLE_CODE = YES diff --git a/pkgs/jni/example/macos/Runner/DebugProfile.entitlements b/pkgs/jni/example/macos/Runner/DebugProfile.entitlements new file mode 100644 index 000000000..dddb8a30c --- /dev/null +++ b/pkgs/jni/example/macos/Runner/DebugProfile.entitlements @@ -0,0 +1,12 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.cs.allow-jit + + com.apple.security.network.server + + + diff --git a/pkgs/jni/example/macos/Runner/Info.plist b/pkgs/jni/example/macos/Runner/Info.plist new file mode 100644 index 000000000..4789daa6a --- /dev/null +++ b/pkgs/jni/example/macos/Runner/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + $(PRODUCT_COPYRIGHT) + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/pkgs/jni/example/macos/Runner/MainFlutterWindow.swift b/pkgs/jni/example/macos/Runner/MainFlutterWindow.swift new file mode 100644 index 000000000..2722837ec --- /dev/null +++ b/pkgs/jni/example/macos/Runner/MainFlutterWindow.swift @@ -0,0 +1,15 @@ +import Cocoa +import FlutterMacOS + +class MainFlutterWindow: NSWindow { + override func awakeFromNib() { + let flutterViewController = FlutterViewController.init() + let windowFrame = self.frame + self.contentViewController = flutterViewController + self.setFrame(windowFrame, display: true) + + RegisterGeneratedPlugins(registry: flutterViewController) + + super.awakeFromNib() + } +} diff --git a/pkgs/jni/example/macos/Runner/Release.entitlements b/pkgs/jni/example/macos/Runner/Release.entitlements new file mode 100644 index 000000000..852fa1a47 --- /dev/null +++ b/pkgs/jni/example/macos/Runner/Release.entitlements @@ -0,0 +1,8 @@ + + + + + com.apple.security.app-sandbox + + + diff --git a/pkgs/jni/example/pubspec.lock b/pkgs/jni/example/pubspec.lock new file mode 100644 index 000000000..77442b507 --- /dev/null +++ b/pkgs/jni/example/pubspec.lock @@ -0,0 +1,182 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + async: + dependency: transitive + description: + name: async + url: "https://pub.dartlang.org" + source: hosted + version: "2.8.2" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + charcode: + dependency: transitive + description: + name: charcode + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.1" + clock: + dependency: transitive + description: + name: clock + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + collection: + dependency: transitive + description: + name: collection + url: "https://pub.dartlang.org" + source: hosted + version: "1.16.0" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.5" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.0" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + jni: + dependency: "direct main" + description: + path: ".." + relative: true + source: path + version: "0.0.1" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + matcher: + dependency: transitive + description: + name: matcher + url: "https://pub.dartlang.org" + source: hosted + version: "0.12.11" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.4" + meta: + dependency: transitive + description: + name: meta + url: "https://pub.dartlang.org" + source: hosted + version: "1.7.0" + path: + dependency: transitive + description: + name: path + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.1" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.2" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_span: + dependency: transitive + description: + name: source_span + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.2" + stack_trace: + dependency: transitive + description: + name: stack_trace + url: "https://pub.dartlang.org" + source: hosted + version: "1.10.0" + stream_channel: + dependency: transitive + description: + name: stream_channel + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + string_scanner: + dependency: transitive + description: + name: string_scanner + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + test_api: + dependency: transitive + description: + name: test_api + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.9" + vector_math: + dependency: transitive + description: + name: vector_math + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.2" +sdks: + dart: ">=2.17.5 <3.0.0" + flutter: ">=2.11.0" diff --git a/pkgs/jni/example/pubspec.yaml b/pkgs/jni/example/pubspec.yaml new file mode 100644 index 000000000..1569e63a1 --- /dev/null +++ b/pkgs/jni/example/pubspec.yaml @@ -0,0 +1,96 @@ +name: jni_example +description: Demonstrates how to use the jni plugin. + +# The following line prevents the package from being accidentally published to +# pub.dev using `flutter pub publish`. This is preferred for private packages. +publish_to: 'none' # Remove this line if you wish to publish to pub.dev + +# The following defines the version and build number for your application. +# A version number is three numbers separated by dots, like 1.2.43 +# followed by an optional build number separated by a +. +# Both the version and the builder number may be overridden in flutter +# build by specifying --build-name and --build-number, respectively. +# In Android, build-name is used as versionName while build-number used as versionCode. +# Read more about Android versioning at https://developer.android.com/studio/publish/versioning +# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. +# Read more about iOS versioning at +# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html +version: 1.0.0+1 + +environment: + sdk: ">=2.17.5 <3.0.0" + +# Dependencies specify other packages that your package needs in order to work. +# To automatically upgrade your package dependencies to the latest versions +# consider running `flutter pub upgrade --major-versions`. Alternatively, +# dependencies can be manually updated by changing the version numbers below to +# the latest version available on pub.dev. To see which dependencies have newer +# versions available, run `flutter pub outdated`. +dependencies: + flutter: + sdk: flutter + + jni: + # When depending on this package from a real application you should use: + # jni: ^x.y.z + # See https://dart.dev/tools/pub/dependencies#version-constraints + # The example app is bundled with the plugin so we use a path dependency on + # the parent directory to use the current plugin's version. + path: ../ + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^1.0.2 + +dev_dependencies: + flutter_test: + sdk: flutter + + # The "flutter_lints" package below contains a set of recommended lints to + # encourage good coding practices. The lint set provided by the package is + # activated in the `analysis_options.yaml` file located at the root of your + # package. See that file for information about deactivating specific lint + # rules and activating additional ones. + flutter_lints: ^2.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + + # To add assets to your application, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/assets-and-images/#from-packages + + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/custom-fonts/#from-packages diff --git a/pkgs/jni/example/windows/.gitignore b/pkgs/jni/example/windows/.gitignore new file mode 100644 index 000000000..d492d0d98 --- /dev/null +++ b/pkgs/jni/example/windows/.gitignore @@ -0,0 +1,17 @@ +flutter/ephemeral/ + +# Visual Studio user-specific files. +*.suo +*.user +*.userosscache +*.sln.docstates + +# Visual Studio build-related files. +x64/ +x86/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ diff --git a/pkgs/jni/example/windows/CMakeLists.txt b/pkgs/jni/example/windows/CMakeLists.txt new file mode 100644 index 000000000..19488923e --- /dev/null +++ b/pkgs/jni/example/windows/CMakeLists.txt @@ -0,0 +1,101 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.14) +project(jni_example LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "jni_example") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(SET CMP0063 NEW) + +# Define build configuration option. +get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(IS_MULTICONFIG) + set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" + CACHE STRING "" FORCE) +else() + if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") + endif() +endif() +# Define settings for the Profile build mode. +set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") +set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") +set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") +set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") + +# Use Unicode for all projects. +add_definitions(-DUNICODE -D_UNICODE) + +# Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_17) + target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") + target_compile_options(${TARGET} PRIVATE /EHsc) + target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") + target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# Application build; see runner/CMakeLists.txt. +add_subdirectory("runner") + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# Support files are copied into place next to the executable, so that it can +# run in place. This is done instead of making a separate bundle (as on Linux) +# so that building and running from within Visual Studio will work. +set(BUILD_BUNDLE_DIR "$") +# Make the "install" step default, as it's required to run. +set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +if(PLUGIN_BUNDLED_LIBRARIES) + install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + CONFIGURATIONS Profile;Release + COMPONENT Runtime) diff --git a/pkgs/jni/example/windows/flutter/CMakeLists.txt b/pkgs/jni/example/windows/flutter/CMakeLists.txt new file mode 100644 index 000000000..930d2071a --- /dev/null +++ b/pkgs/jni/example/windows/flutter/CMakeLists.txt @@ -0,0 +1,104 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.14) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. +set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") + +# === Flutter Library === +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "flutter_export.h" + "flutter_windows.h" + "flutter_messenger.h" + "flutter_plugin_registrar.h" + "flutter_texture_registrar.h" +) +list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") +add_dependencies(flutter flutter_assemble) + +# === Wrapper === +list(APPEND CPP_WRAPPER_SOURCES_CORE + "core_implementations.cc" + "standard_codec.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_PLUGIN + "plugin_registrar.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_APP + "flutter_engine.cc" + "flutter_view_controller.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") + +# Wrapper sources needed for a plugin. +add_library(flutter_wrapper_plugin STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} +) +apply_standard_settings(flutter_wrapper_plugin) +set_target_properties(flutter_wrapper_plugin PROPERTIES + POSITION_INDEPENDENT_CODE ON) +set_target_properties(flutter_wrapper_plugin PROPERTIES + CXX_VISIBILITY_PRESET hidden) +target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) +target_include_directories(flutter_wrapper_plugin PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_plugin flutter_assemble) + +# Wrapper sources needed for the runner. +add_library(flutter_wrapper_app STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_APP} +) +apply_standard_settings(flutter_wrapper_app) +target_link_libraries(flutter_wrapper_app PUBLIC flutter) +target_include_directories(flutter_wrapper_app PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_app flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") +set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} + ${PHONY_OUTPUT} + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" + windows-x64 $ + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} +) diff --git a/pkgs/jni/example/windows/flutter/generated_plugin_registrant.cc b/pkgs/jni/example/windows/flutter/generated_plugin_registrant.cc new file mode 100644 index 000000000..8b6d4680a --- /dev/null +++ b/pkgs/jni/example/windows/flutter/generated_plugin_registrant.cc @@ -0,0 +1,11 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + + +void RegisterPlugins(flutter::PluginRegistry* registry) { +} diff --git a/pkgs/jni/example/windows/flutter/generated_plugin_registrant.h b/pkgs/jni/example/windows/flutter/generated_plugin_registrant.h new file mode 100644 index 000000000..dc139d85a --- /dev/null +++ b/pkgs/jni/example/windows/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void RegisterPlugins(flutter::PluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/pkgs/jni/example/windows/flutter/generated_plugins.cmake b/pkgs/jni/example/windows/flutter/generated_plugins.cmake new file mode 100644 index 000000000..3ad69c612 --- /dev/null +++ b/pkgs/jni/example/windows/flutter/generated_plugins.cmake @@ -0,0 +1,24 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST + jni +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/pkgs/jni/example/windows/runner/CMakeLists.txt b/pkgs/jni/example/windows/runner/CMakeLists.txt new file mode 100644 index 000000000..b9e550fba --- /dev/null +++ b/pkgs/jni/example/windows/runner/CMakeLists.txt @@ -0,0 +1,32 @@ +cmake_minimum_required(VERSION 3.14) +project(runner LANGUAGES CXX) + +# Define the application target. To change its name, change BINARY_NAME in the +# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer +# work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} WIN32 + "flutter_window.cpp" + "main.cpp" + "utils.cpp" + "win32_window.cpp" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" + "Runner.rc" + "runner.exe.manifest" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Disable Windows macros that collide with C++ standard library functions. +target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") + +# Add dependency libraries and include directories. Add any application-specific +# dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) +target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) diff --git a/pkgs/jni/example/windows/runner/Runner.rc b/pkgs/jni/example/windows/runner/Runner.rc new file mode 100644 index 000000000..a4c901a09 --- /dev/null +++ b/pkgs/jni/example/windows/runner/Runner.rc @@ -0,0 +1,121 @@ +// Microsoft Visual C++ generated resource script. +// +#pragma code_page(65001) +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_APP_ICON ICON "resources\\app_icon.ico" + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +#ifdef FLUTTER_BUILD_NUMBER +#define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER +#else +#define VERSION_AS_NUMBER 1,0,0 +#endif + +#ifdef FLUTTER_BUILD_NAME +#define VERSION_AS_STRING #FLUTTER_BUILD_NAME +#else +#define VERSION_AS_STRING "1.0.0" +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION VERSION_AS_NUMBER + PRODUCTVERSION VERSION_AS_NUMBER + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904e4" + BEGIN + VALUE "CompanyName", "dev.dart" "\0" + VALUE "FileDescription", "jni_example" "\0" + VALUE "FileVersion", VERSION_AS_STRING "\0" + VALUE "InternalName", "jni_example" "\0" + VALUE "LegalCopyright", "Copyright (C) 2022 dev.dart. All rights reserved." "\0" + VALUE "OriginalFilename", "jni_example.exe" "\0" + VALUE "ProductName", "jni_example" "\0" + VALUE "ProductVersion", VERSION_AS_STRING "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END +END + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED diff --git a/pkgs/jni/example/windows/runner/flutter_window.cpp b/pkgs/jni/example/windows/runner/flutter_window.cpp new file mode 100644 index 000000000..b43b9095e --- /dev/null +++ b/pkgs/jni/example/windows/runner/flutter_window.cpp @@ -0,0 +1,61 @@ +#include "flutter_window.h" + +#include + +#include "flutter/generated_plugin_registrant.h" + +FlutterWindow::FlutterWindow(const flutter::DartProject& project) + : project_(project) {} + +FlutterWindow::~FlutterWindow() {} + +bool FlutterWindow::OnCreate() { + if (!Win32Window::OnCreate()) { + return false; + } + + RECT frame = GetClientArea(); + + // The size here must match the window dimensions to avoid unnecessary surface + // creation / destruction in the startup path. + flutter_controller_ = std::make_unique( + frame.right - frame.left, frame.bottom - frame.top, project_); + // Ensure that basic setup of the controller was successful. + if (!flutter_controller_->engine() || !flutter_controller_->view()) { + return false; + } + RegisterPlugins(flutter_controller_->engine()); + SetChildContent(flutter_controller_->view()->GetNativeWindow()); + return true; +} + +void FlutterWindow::OnDestroy() { + if (flutter_controller_) { + flutter_controller_ = nullptr; + } + + Win32Window::OnDestroy(); +} + +LRESULT +FlutterWindow::MessageHandler(HWND hwnd, UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + // Give Flutter, including plugins, an opportunity to handle window messages. + if (flutter_controller_) { + std::optional result = + flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, + lparam); + if (result) { + return *result; + } + } + + switch (message) { + case WM_FONTCHANGE: + flutter_controller_->engine()->ReloadSystemFonts(); + break; + } + + return Win32Window::MessageHandler(hwnd, message, wparam, lparam); +} diff --git a/pkgs/jni/example/windows/runner/flutter_window.h b/pkgs/jni/example/windows/runner/flutter_window.h new file mode 100644 index 000000000..6da0652f0 --- /dev/null +++ b/pkgs/jni/example/windows/runner/flutter_window.h @@ -0,0 +1,33 @@ +#ifndef RUNNER_FLUTTER_WINDOW_H_ +#define RUNNER_FLUTTER_WINDOW_H_ + +#include +#include + +#include + +#include "win32_window.h" + +// A window that does nothing but host a Flutter view. +class FlutterWindow : public Win32Window { + public: + // Creates a new FlutterWindow hosting a Flutter view running |project|. + explicit FlutterWindow(const flutter::DartProject& project); + virtual ~FlutterWindow(); + + protected: + // Win32Window: + bool OnCreate() override; + void OnDestroy() override; + LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, + LPARAM const lparam) noexcept override; + + private: + // The project to run. + flutter::DartProject project_; + + // The Flutter instance hosted by this window. + std::unique_ptr flutter_controller_; +}; + +#endif // RUNNER_FLUTTER_WINDOW_H_ diff --git a/pkgs/jni/example/windows/runner/main.cpp b/pkgs/jni/example/windows/runner/main.cpp new file mode 100644 index 000000000..fa17f9e18 --- /dev/null +++ b/pkgs/jni/example/windows/runner/main.cpp @@ -0,0 +1,43 @@ +#include +#include +#include + +#include "flutter_window.h" +#include "utils.h" + +int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, + _In_ wchar_t *command_line, _In_ int show_command) { + // Attach to console when present (e.g., 'flutter run') or create a + // new console when running with a debugger. + if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { + CreateAndAttachConsole(); + } + + // Initialize COM, so that it is available for use in the library and/or + // plugins. + ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); + + flutter::DartProject project(L"data"); + + std::vector command_line_arguments = + GetCommandLineArguments(); + + project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); + + FlutterWindow window(project); + Win32Window::Point origin(10, 10); + Win32Window::Size size(1280, 720); + if (!window.CreateAndShow(L"jni_example", origin, size)) { + return EXIT_FAILURE; + } + window.SetQuitOnClose(true); + + ::MSG msg; + while (::GetMessage(&msg, nullptr, 0, 0)) { + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + } + + ::CoUninitialize(); + return EXIT_SUCCESS; +} diff --git a/pkgs/jni/example/windows/runner/resource.h b/pkgs/jni/example/windows/runner/resource.h new file mode 100644 index 000000000..66a65d1e4 --- /dev/null +++ b/pkgs/jni/example/windows/runner/resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Runner.rc +// +#define IDI_APP_ICON 101 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/pkgs/jni/example/windows/runner/resources/app_icon.ico b/pkgs/jni/example/windows/runner/resources/app_icon.ico new file mode 100644 index 0000000000000000000000000000000000000000..c04e20caf6370ebb9253ad831cc31de4a9c965f6 GIT binary patch literal 33772 zcmeHQc|26z|35SKE&G-*mXah&B~fFkXr)DEO&hIfqby^T&>|8^_Ub8Vp#`BLl3lbZ zvPO!8k!2X>cg~Elr=IVxo~J*a`+9wR=A83c-k-DFd(XM&UI1VKCqM@V;DDtJ09WB} zRaHKiW(GT00brH|0EeTeKVbpbGZg?nK6-j827q-+NFM34gXjqWxJ*a#{b_apGN<-L_m3#8Z26atkEn& ze87Bvv^6vVmM+p+cQ~{u%=NJF>#(d;8{7Q{^rWKWNtf14H}>#&y7$lqmY6xmZryI& z($uy?c5-+cPnt2%)R&(KIWEXww>Cnz{OUpT>W$CbO$h1= z#4BPMkFG1Y)x}Ui+WXr?Z!w!t_hjRq8qTaWpu}FH{MsHlU{>;08goVLm{V<&`itk~ zE_Ys=D(hjiy+5=?=$HGii=Y5)jMe9|wWoD_K07(}edAxh`~LBorOJ!Cf@f{_gNCC| z%{*04ViE!#>@hc1t5bb+NO>ncf@@Dv01K!NxH$3Eg1%)|wLyMDF8^d44lV!_Sr}iEWefOaL z8f?ud3Q%Sen39u|%00W<#!E=-RpGa+H8}{ulxVl4mwpjaU+%2pzmi{3HM)%8vb*~-M9rPUAfGCSos8GUXp02|o~0BTV2l#`>>aFV&_P$ejS;nGwSVP8 zMbOaG7<7eKD>c12VdGH;?2@q7535sa7MN*L@&!m?L`ASG%boY7(&L5imY#EQ$KrBB z4@_tfP5m50(T--qv1BJcD&aiH#b-QC>8#7Fx@3yXlonJI#aEIi=8&ChiVpc#N=5le zM*?rDIdcpawoc5kizv$GEjnveyrp3sY>+5_R5;>`>erS%JolimF=A^EIsAK zsPoVyyUHCgf0aYr&alx`<)eb6Be$m&`JYSuBu=p8j%QlNNp$-5C{b4#RubPb|CAIS zGE=9OFLP7?Hgc{?k45)84biT0k&-C6C%Q}aI~q<(7BL`C#<6HyxaR%!dFx7*o^laG z=!GBF^cwK$IA(sn9y6>60Rw{mYRYkp%$jH z*xQM~+bp)G$_RhtFPYx2HTsWk80+p(uqv9@I9)y{b$7NK53rYL$ezbmRjdXS?V}fj zWxX_feWoLFNm3MG7pMUuFPs$qrQWO9!l2B(SIuy2}S|lHNbHzoE+M2|Zxhjq9+Ws8c{*}x^VAib7SbxJ*Q3EnY5lgI9 z=U^f3IW6T=TWaVj+2N%K3<%Un;CF(wUp`TC&Y|ZjyFu6co^uqDDB#EP?DV5v_dw~E zIRK*BoY9y-G_ToU2V_XCX4nJ32~`czdjT!zwme zGgJ0nOk3U4@IE5JwtM}pwimLjk{ln^*4HMU%Fl4~n(cnsLB}Ja-jUM>xIB%aY;Nq8 z)Fp8dv1tkqKanv<68o@cN|%thj$+f;zGSO7H#b+eMAV8xH$hLggtt?O?;oYEgbq@= zV(u9bbd12^%;?nyk6&$GPI%|+<_mEpJGNfl*`!KV;VfmZWw{n{rnZ51?}FDh8we_L z8OI9nE31skDqJ5Oa_ybn7|5@ui>aC`s34p4ZEu6-s!%{uU45$Zd1=p$^^dZBh zu<*pDDPLW+c>iWO$&Z_*{VSQKg7=YEpS3PssPn1U!lSm6eZIho*{@&20e4Y_lRklKDTUCKI%o4Pc<|G^Xgu$J^Q|B87U;`c1zGwf^-zH*VQ^x+i^OUWE0yd z;{FJq)2w!%`x7yg@>uGFFf-XJl4H`YtUG%0slGKOlXV`q?RP>AEWg#x!b{0RicxGhS!3$p7 zij;{gm!_u@D4$Ox%>>bPtLJ> zwKtYz?T_DR1jN>DkkfGU^<#6sGz|~p*I{y`aZ>^Di#TC|Z!7j_O1=Wo8thuit?WxR zh9_S>kw^{V^|g}HRUF=dcq>?q(pHxw!8rx4dC6vbQVmIhmICF#zU!HkHpQ>9S%Uo( zMw{eC+`&pb=GZRou|3;Po1}m46H6NGd$t<2mQh}kaK-WFfmj_66_17BX0|j-E2fe3Jat}ijpc53 zJV$$;PC<5aW`{*^Z6e5##^`Ed#a0nwJDT#Qq~^e8^JTA=z^Kl>La|(UQ!bI@#ge{Dzz@61p-I)kc2?ZxFt^QQ}f%ldLjO*GPj(5)V9IyuUakJX=~GnTgZ4$5!3E=V#t`yOG4U z(gphZB6u2zsj=qNFLYShhg$}lNpO`P9xOSnO*$@@UdMYES*{jJVj|9z-}F^riksLK zbsU+4-{281P9e2UjY6tse^&a)WM1MFw;p#_dHhWI7p&U*9TR0zKdVuQed%6{otTsq z$f~S!;wg#Bd9kez=Br{m|66Wv z#g1xMup<0)H;c2ZO6su_ii&m8j&+jJz4iKnGZ&wxoQX|5a>v&_e#6WA!MB_4asTxLRGQCC5cI(em z%$ZfeqP>!*q5kU>a+BO&ln=4Jm>Ef(QE8o&RgLkk%2}4Tf}U%IFP&uS7}&|Q-)`5< z+e>;s#4cJ-z%&-^&!xsYx777Wt(wZY9(3(avmr|gRe4cD+a8&!LY`1^T?7x{E<=kdY9NYw>A;FtTvQ=Y&1M%lyZPl$ss1oY^Sl8we}n}Aob#6 zl4jERwnt9BlSoWb@3HxYgga(752Vu6Y)k4yk9u~Kw>cA5&LHcrvn1Y-HoIuFWg~}4 zEw4bR`mXZQIyOAzo)FYqg?$5W<;^+XX%Uz61{-L6@eP|lLH%|w?g=rFc;OvEW;^qh z&iYXGhVt(G-q<+_j}CTbPS_=K>RKN0&;dubh0NxJyDOHFF;<1k!{k#7b{|Qok9hac z;gHz}6>H6C6RnB`Tt#oaSrX0p-j-oRJ;_WvS-qS--P*8}V943RT6kou-G=A+7QPGQ z!ze^UGxtW3FC0$|(lY9^L!Lx^?Q8cny(rR`es5U;-xBhphF%_WNu|aO<+e9%6LuZq zt(0PoagJG<%hyuf;te}n+qIl_Ej;czWdc{LX^pS>77s9t*2b4s5dvP_!L^3cwlc)E!(!kGrg~FescVT zZCLeua3f4;d;Tk4iXzt}g}O@nlK3?_o91_~@UMIl?@77Qc$IAlLE95#Z=TES>2E%z zxUKpK{_HvGF;5%Q7n&vA?`{%8ohlYT_?(3A$cZSi)MvIJygXD}TS-3UwyUxGLGiJP znblO~G|*uA^|ac8E-w#}uBtg|s_~s&t>-g0X%zIZ@;o_wNMr_;{KDg^O=rg`fhDZu zFp(VKd1Edj%F zWHPl+)FGj%J1BO3bOHVfH^3d1F{)*PL&sRX`~(-Zy3&9UQX)Z;c51tvaI2E*E7!)q zcz|{vpK7bjxix(k&6=OEIBJC!9lTkUbgg?4-yE{9+pFS)$Ar@vrIf`D0Bnsed(Cf? zObt2CJ>BKOl>q8PyFO6w)+6Iz`LW%T5^R`U_NIW0r1dWv6OY=TVF?N=EfA(k(~7VBW(S;Tu5m4Lg8emDG-(mOSSs=M9Q&N8jc^Y4&9RqIsk(yO_P(mcCr}rCs%1MW1VBrn=0-oQN(Xj!k%iKV zb%ricBF3G4S1;+8lzg5PbZ|$Se$)I=PwiK=cDpHYdov2QO1_a-*dL4KUi|g&oh>(* zq$<`dQ^fat`+VW?m)?_KLn&mp^-@d=&7yGDt<=XwZZC=1scwxO2^RRI7n@g-1o8ps z)&+et_~)vr8aIF1VY1Qrq~Xe``KJrQSnAZ{CSq3yP;V*JC;mmCT6oRLSs7=GA?@6g zUooM}@tKtx(^|aKK8vbaHlUQqwE0}>j&~YlN3H#vKGm@u)xxS?n9XrOWUfCRa< z`20Fld2f&;gg7zpo{Adh+mqNntMc-D$N^yWZAZRI+u1T1zWHPxk{+?vcS1D>08>@6 zLhE@`gt1Y9mAK6Z4p|u(5I%EkfU7rKFSM=E4?VG9tI;a*@?6!ey{lzN5=Y-!$WFSe z&2dtO>^0@V4WRc#L&P%R(?@KfSblMS+N+?xUN$u3K4Ys%OmEh+tq}fnU}i>6YHM?< zlnL2gl~sF!j!Y4E;j3eIU-lfa`RsOL*Tt<%EFC0gPzoHfNWAfKFIKZN8}w~(Yi~=q z>=VNLO2|CjkxP}RkutxjV#4fWYR1KNrPYq5ha9Wl+u>ipsk*I(HS@iLnmGH9MFlTU zaFZ*KSR0px>o+pL7BbhB2EC1%PJ{67_ z#kY&#O4@P=OV#-79y_W>Gv2dxL*@G7%LksNSqgId9v;2xJ zrh8uR!F-eU$NMx@S*+sk=C~Dxr9Qn7TfWnTupuHKuQ$;gGiBcU>GF5sWx(~4IP3`f zWE;YFO*?jGwYh%C3X<>RKHC-DZ!*r;cIr}GLOno^3U4tFSSoJp%oHPiSa%nh=Zgn% z14+8v@ygy0>UgEN1bczD6wK45%M>psM)y^)IfG*>3ItX|TzV*0i%@>L(VN!zdKb8S?Qf7BhjNpziA zR}?={-eu>9JDcl*R=OP9B8N$IcCETXah9SUDhr{yrld{G;PnCWRsPD7!eOOFBTWUQ=LrA_~)mFf&!zJX!Oc-_=kT<}m|K52 z)M=G#;p;Rdb@~h5D{q^K;^fX-m5V}L%!wVC2iZ1uu401Ll}#rocTeK|7FAeBRhNdQ zCc2d^aQnQp=MpOmak60N$OgS}a;p(l9CL`o4r(e-nN}mQ?M&isv-P&d$!8|1D1I(3-z!wi zTgoo)*Mv`gC?~bm?S|@}I|m-E2yqPEvYybiD5azInexpK8?9q*$9Yy9-t%5jU8~ym zgZDx>!@ujQ=|HJnwp^wv-FdD{RtzO9SnyfB{mH_(c!jHL*$>0o-(h(eqe*ZwF6Lvu z{7rkk%PEqaA>o+f{H02tzZ@TWy&su?VNw43! z-X+rN`6llvpUms3ZiSt)JMeztB~>9{J8SPmYs&qohxdYFi!ra8KR$35Zp9oR)eFC4 zE;P31#3V)n`w$fZ|4X-|%MX`xZDM~gJyl2W;O$H25*=+1S#%|53>|LyH za@yh+;325%Gq3;J&a)?%7X%t@WXcWL*BaaR*7UEZad4I8iDt7^R_Fd`XeUo256;sAo2F!HcIQKk;h})QxEsPE5BcKc7WyerTchgKmrfRX z!x#H_%cL#B9TWAqkA4I$R^8{%do3Y*&(;WFmJ zU7Dih{t1<{($VtJRl9|&EB?|cJ)xse!;}>6mSO$o5XIx@V|AA8ZcoD88ZM?C*;{|f zZVmf94_l1OmaICt`2sTyG!$^UeTHx9YuUP!omj(r|7zpm5475|yXI=rR>>fteLI+| z)MoiGho0oEt=*J(;?VY0QzwCqw@cVm?d7Y!z0A@u#H?sCJ*ecvyhj& z-F77lO;SH^dmf?L>3i>?Z*U}Em4ZYV_CjgfvzYsRZ+1B!Uo6H6mbS<-FFL`ytqvb& zE7+)2ahv-~dz(Hs+f})z{*4|{)b=2!RZK;PWwOnO=hG7xG`JU5>bAvUbdYd_CjvtHBHgtGdlO+s^9ca^Bv3`t@VRX2_AD$Ckg36OcQRF zXD6QtGfHdw*hx~V(MV-;;ZZF#dJ-piEF+s27z4X1qi5$!o~xBnvf=uopcn7ftfsZc zy@(PuOk`4GL_n(H9(E2)VUjqRCk9kR?w)v@xO6Jm_Mx})&WGEl=GS0#)0FAq^J*o! zAClhvoTsNP*-b~rN{8Yym3g{01}Ep^^Omf=SKqvN?{Q*C4HNNAcrowIa^mf+3PRy! z*_G-|3i8a;+q;iP@~Of_$(vtFkB8yOyWt2*K)vAn9El>=D;A$CEx6b*XF@4y_6M+2 zpeW`RHoI_p(B{%(&jTHI->hmNmZjHUj<@;7w0mx3&koy!2$@cfX{sN19Y}euYJFn& z1?)+?HCkD0MRI$~uB2UWri})0bru_B;klFdwsLc!ne4YUE;t41JqfG# zZJq6%vbsdx!wYeE<~?>o4V`A3?lN%MnKQ`z=uUivQN^vzJ|C;sdQ37Qn?;lpzg})y z)_2~rUdH}zNwX;Tp0tJ78+&I=IwOQ-fl30R79O8@?Ub8IIA(6I`yHn%lARVL`%b8+ z4$8D-|MZZWxc_)vu6@VZN!HsI$*2NOV&uMxBNzIbRgy%ob_ zhwEH{J9r$!dEix9XM7n&c{S(h>nGm?el;gaX0@|QnzFD@bne`el^CO$yXC?BDJ|Qg z+y$GRoR`?ST1z^e*>;!IS@5Ovb7*RlN>BV_UC!7E_F;N#ky%1J{+iixp(dUJj93aK zzHNN>R-oN7>kykHClPnoPTIj7zc6KM(Pnlb(|s??)SMb)4!sMHU^-ntJwY5Big7xv zb1Ew`Xj;|D2kzGja*C$eS44(d&RMU~c_Y14V9_TLTz0J#uHlsx`S6{nhsA0dWZ#cG zJ?`fO50E>*X4TQLv#nl%3GOk*UkAgt=IY+u0LNXqeln3Z zv$~&Li`ZJOKkFuS)dJRA>)b_Da%Q~axwA_8zNK{BH{#}#m}zGcuckz}riDE-z_Ms> zR8-EqAMcfyGJCtvTpaUVQtajhUS%c@Yj}&6Zz;-M7MZzqv3kA7{SuW$oW#=0az2wQ zg-WG@Vb4|D`pl~Il54N7Hmsauc_ne-a!o5#j3WaBBh@Wuefb!QJIOn5;d)%A#s+5% zuD$H=VNux9bE-}1&bcYGZ+>1Fo;3Z@e&zX^n!?JK*adSbONm$XW9z;Q^L>9U!}Toj2WdafJ%oL#h|yWWwyAGxzfrAWdDTtaKl zK4`5tDpPg5>z$MNv=X0LZ0d6l%D{(D8oT@+w0?ce$DZ6pv>{1&Ok67Ix1 zH}3=IEhPJEhItCC8E=`T`N5(k?G=B4+xzZ?<4!~ ze~z6Wk9!CHTI(0rLJ4{JU?E-puc;xusR?>G?;4vt;q~iI9=kDL=z0Rr%O$vU`30X$ zDZRFyZ`(omOy@u|i6h;wtJlP;+}$|Ak|k2dea7n?U1*$T!sXqqOjq^NxLPMmk~&qI zYg0W?yK8T(6+Ea+$YyspKK?kP$+B`~t3^Pib_`!6xCs32!i@pqXfFV6PmBIR<-QW= zN8L{pt0Vap0x`Gzn#E@zh@H)0FfVfA_Iu4fjYZ+umO1LXIbVc$pY+E234u)ttcrl$ z>s92z4vT%n6cMb>=XT6;l0+9e(|CZG)$@C7t7Z7Ez@a)h)!hyuV&B5K%%)P5?Lk|C zZZSVzdXp{@OXSP0hoU-gF8s8Um(#xzjP2Vem zec#-^JqTa&Y#QJ>-FBxd7tf`XB6e^JPUgagB8iBSEps;92KG`!#mvVcPQ5yNC-GEG zTiHEDYfH+0O15}r^+ z#jxj=@x8iNHWALe!P3R67TwmhItn**0JwnzSV2O&KE8KcT+0hWH^OPD1pwiuyx=b@ zNf5Jh0{9X)8;~Es)$t@%(3!OnbY+`@?i{mGX7Yy}8T_*0a6g;kaFPq;*=px5EhO{Cp%1kI<0?*|h8v!6WnO3cCJRF2-CRrU3JiLJnj@6;L)!0kWYAc_}F{2P))3HmCrz zQ&N&gE70;`!6*eJ4^1IR{f6j4(-l&X!tjHxkbHA^Zhrnhr9g{exN|xrS`5Pq=#Xf& zG%P=#ra-TyVFfgW%cZo5OSIwFL9WtXAlFOa+ubmI5t*3=g#Y zF%;70p5;{ZeFL}&}yOY1N1*Q;*<(kTB!7vM$QokF)yr2FlIU@$Ph58$Bz z0J?xQG=MlS4L6jA22eS42g|9*9pX@$#*sUeM(z+t?hr@r5J&D1rx}2pW&m*_`VDCW zUYY@v-;bAO0HqoAgbbiGGC<=ryf96}3pouhy3XJrX+!!u*O_>Si38V{uJmQ&USptX zKp#l(?>%^7;2%h(q@YWS#9;a!JhKlkR#Vd)ERILlgu!Hr@jA@V;sk4BJ-H#p*4EqC zDGjC*tl=@3Oi6)Bn^QwFpul18fpkbpg0+peH$xyPBqb%`$OUhPKyWb32o7clB*9Z< zN=i~NLjavrLtwgJ01bufP+>p-jR2I95|TpmKpQL2!oV>g(4RvS2pK4*ou%m(h6r3A zX#s&`9LU1ZG&;{CkOK!4fLDTnBys`M!vuz>Q&9OZ0hGQl!~!jSDg|~s*w52opC{sB ze|Cf2luD(*G13LcOAGA!s2FjSK8&IE5#W%J25w!vM0^VyQM!t)inj&RTiJ!wXzFgz z3^IqzB7I0L$llljsGq})thBy9UOyjtFO_*hYM_sgcMk>44jeH0V1FDyELc{S1F-;A zS;T^k^~4biG&V*Irq}O;e}j$$+E_#G?HKIn05iP3j|87TkGK~SqG!-KBg5+mN(aLm z8ybhIM`%C19UX$H$KY6JgXbY$0AT%rEpHC;u`rQ$Y=rxUdsc5*Kvc8jaYaO$^)cI6){P6K0r)I6DY4Wr4&B zLQUBraey#0HV|&c4v7PVo3n$zHj99(TZO^3?Ly%C4nYvJTL9eLBLHsM3WKKD>5!B` zQ=BsR3aR6PD(Fa>327E2HAu5TM~Wusc!)>~(gM)+3~m;92Jd;FnSib=M5d6;;5{%R zb4V7DEJ0V!CP-F*oU?gkc>ksUtAYP&V4ND5J>J2^jt*vcFflQWCrB&fLdT%O59PVJ zhid#toR=FNgD!q3&r8#wEBr`!wzvQu5zX?Q>nlSJ4i@WC*CN*-xU66F^V5crWevQ9gsq$I@z1o(a=k7LL~ z7m_~`o;_Ozha1$8Q}{WBehvAlO4EL60y5}8GDrZ< zXh&F}71JbW2A~8KfEWj&UWV#4+Z4p`b{uAj4&WC zha`}X@3~+Iz^WRlOHU&KngK>#j}+_o@LdBC1H-`gT+krWX3-;!)6?{FBp~%20a}FL zFP9%Emqcwa#(`=G>BBZ0qZDQhmZKJg_g8<=bBFKWr!dyg(YkpE+|R*SGpDVU!+VlU zFC54^DLv}`qa%49T>nNiA9Q7Ips#!Xx90tCU2gvK`(F+GPcL=J^>No{)~we#o@&mUb6c$ zCc*<|NJBk-#+{j9xkQ&ujB zI~`#kN~7W!f*-}wkG~Ld!JqZ@tK}eeSnsS5J1fMFXm|`LJx&}5`@dK3W^7#Wnm+_P zBZkp&j1fa2Y=eIjJ0}gh85jt43kaIXXv?xmo@eHrka!Z|vQv12HN#+!I5E z`(fbuW>gFiJL|uXJ!vKt#z3e3HlVdboH7;e#i3(2<)Fg-I@BR!qY#eof3MFZ&*Y@l zI|KJf&ge@p2Dq09Vu$$Qxb7!}{m-iRk@!)%KL)txi3;~Z4Pb}u@GsW;ELiWeG9V51 znX#}B&4Y2E7-H=OpNE@q{%hFLxwIpBF2t{vPREa8_{linXT;#1vMRWjOzLOP$-hf( z>=?$0;~~PnkqY;~K{EM6Vo-T(0K{A0}VUGmu*hR z{tw3hvBN%N3G3Yw`X5Te+F{J`(3w1s3-+1EbnFQKcrgrX1Jqvs@ADGe%M0s$EbK$$ zK)=y=upBc6SjGYAACCcI=Y*6Fi8_jgwZlLxD26fnQfJmb8^gHRN5(TemhX@0e=vr> zg`W}6U>x6VhoA3DqsGGD9uL1DhB3!OXO=k}59TqD@(0Nb{)Ut_luTioK_>7wjc!5C zIr@w}b`Fez3)0wQfKl&bae7;PcTA7%?f2xucM0G)wt_KO!Ewx>F~;=BI0j=Fb4>pp zv}0R^xM4eti~+^+gE$6b81p(kwzuDti(-K9bc|?+pJEl@H+jSYuxZQV8rl8 zjp@M{#%qItIUFN~KcO9Hed*`$5A-2~pAo~K&<-Q+`9`$CK>rzqAI4w~$F%vs9s{~x zg4BP%Gy*@m?;D6=SRX?888Q6peF@_4Z->8wAH~Cn!R$|Hhq2cIzFYqT_+cDourHbY z0qroxJnrZ4Gh+Ay+F`_c%+KRT>y3qw{)89?=hJ@=KO=@ep)aBJ$c!JHfBMJpsP*3G za7|)VJJ8B;4?n{~ldJF7%jmb`-ftIvNd~ekoufG(`K(3=LNc;HBY& z(lp#q8XAD#cIf}k49zX_i`*fO+#!zKA&%T3j@%)R+#yag067CU%yUEe47>wzGU8^` z1EXFT^@I!{J!F8!X?S6ph8J=gUi5tl93*W>7}_uR<2N2~e}FaG?}KPyugQ=-OGEZs z!GBoyYY+H*ANn4?Z)X4l+7H%`17i5~zRlRIX?t)6_eu=g2Q`3WBhxSUeea+M-S?RL zX9oBGKn%a!H+*hx4d2(I!gsi+@SQK%<{X22M~2tMulJoa)0*+z9=-YO+;DFEm5eE1U9b^B(Z}2^9!Qk`!A$wUE z7$Ar5?NRg2&G!AZqnmE64eh^Anss3i!{}%6@Et+4rr!=}!SBF8eZ2*J3ujCWbl;3; z48H~goPSv(8X61fKKdpP!Z7$88NL^Z?j`!^*I?-P4X^pMxyWz~@$(UeAcTSDd(`vO z{~rc;9|GfMJcApU3k}22a!&)k4{CU!e_ny^Y3cO;tOvOMKEyWz!vG(Kp*;hB?d|R3`2X~=5a6#^o5@qn?J-bI8Ppip{-yG z!k|VcGsq!jF~}7DMr49Wap-s&>o=U^T0!Lcy}!(bhtYsPQy z4|EJe{12QL#=c(suQ89Mhw9<`bui%nx7Nep`C&*M3~vMEACmcRYYRGtANq$F%zh&V zc)cEVeHz*Z1N)L7k-(k3np#{GcDh2Q@ya0YHl*n7fl*ZPAsbU-a94MYYtA#&!c`xGIaV;yzsmrjfieTEtqB_WgZp2*NplHx=$O{M~2#i_vJ{ps-NgK zQsxKK_CBM2PP_je+Xft`(vYfXXgIUr{=PA=7a8`2EHk)Ym2QKIforz# tySWtj{oF3N9@_;i*Fv5S)9x^z=nlWP>jpp-9)52ZmLVA=i*%6g{{fxOO~wEK literal 0 HcmV?d00001 diff --git a/pkgs/jni/example/windows/runner/runner.exe.manifest b/pkgs/jni/example/windows/runner/runner.exe.manifest new file mode 100644 index 000000000..c977c4a42 --- /dev/null +++ b/pkgs/jni/example/windows/runner/runner.exe.manifest @@ -0,0 +1,20 @@ + + + + + PerMonitorV2 + + + + + + + + + + + + + + + diff --git a/pkgs/jni/example/windows/runner/utils.cpp b/pkgs/jni/example/windows/runner/utils.cpp new file mode 100644 index 000000000..f5bf9fa0f --- /dev/null +++ b/pkgs/jni/example/windows/runner/utils.cpp @@ -0,0 +1,64 @@ +#include "utils.h" + +#include +#include +#include +#include + +#include + +void CreateAndAttachConsole() { + if (::AllocConsole()) { + FILE *unused; + if (freopen_s(&unused, "CONOUT$", "w", stdout)) { + _dup2(_fileno(stdout), 1); + } + if (freopen_s(&unused, "CONOUT$", "w", stderr)) { + _dup2(_fileno(stdout), 2); + } + std::ios::sync_with_stdio(); + FlutterDesktopResyncOutputStreams(); + } +} + +std::vector GetCommandLineArguments() { + // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. + int argc; + wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); + if (argv == nullptr) { + return std::vector(); + } + + std::vector command_line_arguments; + + // Skip the first argument as it's the binary name. + for (int i = 1; i < argc; i++) { + command_line_arguments.push_back(Utf8FromUtf16(argv[i])); + } + + ::LocalFree(argv); + + return command_line_arguments; +} + +std::string Utf8FromUtf16(const wchar_t* utf16_string) { + if (utf16_string == nullptr) { + return std::string(); + } + int target_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + -1, nullptr, 0, nullptr, nullptr); + std::string utf8_string; + if (target_length == 0 || target_length > utf8_string.max_size()) { + return utf8_string; + } + utf8_string.resize(target_length); + int converted_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + -1, utf8_string.data(), + target_length, nullptr, nullptr); + if (converted_length == 0) { + return std::string(); + } + return utf8_string; +} diff --git a/pkgs/jni/example/windows/runner/utils.h b/pkgs/jni/example/windows/runner/utils.h new file mode 100644 index 000000000..3879d5475 --- /dev/null +++ b/pkgs/jni/example/windows/runner/utils.h @@ -0,0 +1,19 @@ +#ifndef RUNNER_UTILS_H_ +#define RUNNER_UTILS_H_ + +#include +#include + +// Creates a console for the process, and redirects stdout and stderr to +// it for both the runner and the Flutter library. +void CreateAndAttachConsole(); + +// Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string +// encoded in UTF-8. Returns an empty std::string on failure. +std::string Utf8FromUtf16(const wchar_t* utf16_string); + +// Gets the command line arguments passed in as a std::vector, +// encoded in UTF-8. Returns an empty std::vector on failure. +std::vector GetCommandLineArguments(); + +#endif // RUNNER_UTILS_H_ diff --git a/pkgs/jni/example/windows/runner/win32_window.cpp b/pkgs/jni/example/windows/runner/win32_window.cpp new file mode 100644 index 000000000..c10f08dc7 --- /dev/null +++ b/pkgs/jni/example/windows/runner/win32_window.cpp @@ -0,0 +1,245 @@ +#include "win32_window.h" + +#include + +#include "resource.h" + +namespace { + +constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; + +// The number of Win32Window objects that currently exist. +static int g_active_window_count = 0; + +using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); + +// Scale helper to convert logical scaler values to physical using passed in +// scale factor +int Scale(int source, double scale_factor) { + return static_cast(source * scale_factor); +} + +// Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. +// This API is only needed for PerMonitor V1 awareness mode. +void EnableFullDpiSupportIfAvailable(HWND hwnd) { + HMODULE user32_module = LoadLibraryA("User32.dll"); + if (!user32_module) { + return; + } + auto enable_non_client_dpi_scaling = + reinterpret_cast( + GetProcAddress(user32_module, "EnableNonClientDpiScaling")); + if (enable_non_client_dpi_scaling != nullptr) { + enable_non_client_dpi_scaling(hwnd); + FreeLibrary(user32_module); + } +} + +} // namespace + +// Manages the Win32Window's window class registration. +class WindowClassRegistrar { + public: + ~WindowClassRegistrar() = default; + + // Returns the singleton registar instance. + static WindowClassRegistrar* GetInstance() { + if (!instance_) { + instance_ = new WindowClassRegistrar(); + } + return instance_; + } + + // Returns the name of the window class, registering the class if it hasn't + // previously been registered. + const wchar_t* GetWindowClass(); + + // Unregisters the window class. Should only be called if there are no + // instances of the window. + void UnregisterWindowClass(); + + private: + WindowClassRegistrar() = default; + + static WindowClassRegistrar* instance_; + + bool class_registered_ = false; +}; + +WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; + +const wchar_t* WindowClassRegistrar::GetWindowClass() { + if (!class_registered_) { + WNDCLASS window_class{}; + window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); + window_class.lpszClassName = kWindowClassName; + window_class.style = CS_HREDRAW | CS_VREDRAW; + window_class.cbClsExtra = 0; + window_class.cbWndExtra = 0; + window_class.hInstance = GetModuleHandle(nullptr); + window_class.hIcon = + LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); + window_class.hbrBackground = 0; + window_class.lpszMenuName = nullptr; + window_class.lpfnWndProc = Win32Window::WndProc; + RegisterClass(&window_class); + class_registered_ = true; + } + return kWindowClassName; +} + +void WindowClassRegistrar::UnregisterWindowClass() { + UnregisterClass(kWindowClassName, nullptr); + class_registered_ = false; +} + +Win32Window::Win32Window() { + ++g_active_window_count; +} + +Win32Window::~Win32Window() { + --g_active_window_count; + Destroy(); +} + +bool Win32Window::CreateAndShow(const std::wstring& title, + const Point& origin, + const Size& size) { + Destroy(); + + const wchar_t* window_class = + WindowClassRegistrar::GetInstance()->GetWindowClass(); + + const POINT target_point = {static_cast(origin.x), + static_cast(origin.y)}; + HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); + UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); + double scale_factor = dpi / 96.0; + + HWND window = CreateWindow( + window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE, + Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), + Scale(size.width, scale_factor), Scale(size.height, scale_factor), + nullptr, nullptr, GetModuleHandle(nullptr), this); + + if (!window) { + return false; + } + + return OnCreate(); +} + +// static +LRESULT CALLBACK Win32Window::WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + if (message == WM_NCCREATE) { + auto window_struct = reinterpret_cast(lparam); + SetWindowLongPtr(window, GWLP_USERDATA, + reinterpret_cast(window_struct->lpCreateParams)); + + auto that = static_cast(window_struct->lpCreateParams); + EnableFullDpiSupportIfAvailable(window); + that->window_handle_ = window; + } else if (Win32Window* that = GetThisFromHandle(window)) { + return that->MessageHandler(window, message, wparam, lparam); + } + + return DefWindowProc(window, message, wparam, lparam); +} + +LRESULT +Win32Window::MessageHandler(HWND hwnd, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + switch (message) { + case WM_DESTROY: + window_handle_ = nullptr; + Destroy(); + if (quit_on_close_) { + PostQuitMessage(0); + } + return 0; + + case WM_DPICHANGED: { + auto newRectSize = reinterpret_cast(lparam); + LONG newWidth = newRectSize->right - newRectSize->left; + LONG newHeight = newRectSize->bottom - newRectSize->top; + + SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, + newHeight, SWP_NOZORDER | SWP_NOACTIVATE); + + return 0; + } + case WM_SIZE: { + RECT rect = GetClientArea(); + if (child_content_ != nullptr) { + // Size and position the child window. + MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, + rect.bottom - rect.top, TRUE); + } + return 0; + } + + case WM_ACTIVATE: + if (child_content_ != nullptr) { + SetFocus(child_content_); + } + return 0; + } + + return DefWindowProc(window_handle_, message, wparam, lparam); +} + +void Win32Window::Destroy() { + OnDestroy(); + + if (window_handle_) { + DestroyWindow(window_handle_); + window_handle_ = nullptr; + } + if (g_active_window_count == 0) { + WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); + } +} + +Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { + return reinterpret_cast( + GetWindowLongPtr(window, GWLP_USERDATA)); +} + +void Win32Window::SetChildContent(HWND content) { + child_content_ = content; + SetParent(content, window_handle_); + RECT frame = GetClientArea(); + + MoveWindow(content, frame.left, frame.top, frame.right - frame.left, + frame.bottom - frame.top, true); + + SetFocus(child_content_); +} + +RECT Win32Window::GetClientArea() { + RECT frame; + GetClientRect(window_handle_, &frame); + return frame; +} + +HWND Win32Window::GetHandle() { + return window_handle_; +} + +void Win32Window::SetQuitOnClose(bool quit_on_close) { + quit_on_close_ = quit_on_close; +} + +bool Win32Window::OnCreate() { + // No-op; provided for subclasses. + return true; +} + +void Win32Window::OnDestroy() { + // No-op; provided for subclasses. +} diff --git a/pkgs/jni/example/windows/runner/win32_window.h b/pkgs/jni/example/windows/runner/win32_window.h new file mode 100644 index 000000000..17ba43112 --- /dev/null +++ b/pkgs/jni/example/windows/runner/win32_window.h @@ -0,0 +1,98 @@ +#ifndef RUNNER_WIN32_WINDOW_H_ +#define RUNNER_WIN32_WINDOW_H_ + +#include + +#include +#include +#include + +// A class abstraction for a high DPI-aware Win32 Window. Intended to be +// inherited from by classes that wish to specialize with custom +// rendering and input handling +class Win32Window { + public: + struct Point { + unsigned int x; + unsigned int y; + Point(unsigned int x, unsigned int y) : x(x), y(y) {} + }; + + struct Size { + unsigned int width; + unsigned int height; + Size(unsigned int width, unsigned int height) + : width(width), height(height) {} + }; + + Win32Window(); + virtual ~Win32Window(); + + // Creates and shows a win32 window with |title| and position and size using + // |origin| and |size|. New windows are created on the default monitor. Window + // sizes are specified to the OS in physical pixels, hence to ensure a + // consistent size to will treat the width height passed in to this function + // as logical pixels and scale to appropriate for the default monitor. Returns + // true if the window was created successfully. + bool CreateAndShow(const std::wstring& title, + const Point& origin, + const Size& size); + + // Release OS resources associated with window. + void Destroy(); + + // Inserts |content| into the window tree. + void SetChildContent(HWND content); + + // Returns the backing Window handle to enable clients to set icon and other + // window properties. Returns nullptr if the window has been destroyed. + HWND GetHandle(); + + // If true, closing this window will quit the application. + void SetQuitOnClose(bool quit_on_close); + + // Return a RECT representing the bounds of the current client area. + RECT GetClientArea(); + + protected: + // Processes and route salient window messages for mouse handling, + // size change and DPI. Delegates handling of these to member overloads that + // inheriting classes can handle. + virtual LRESULT MessageHandler(HWND window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Called when CreateAndShow is called, allowing subclass window-related + // setup. Subclasses should return false if setup fails. + virtual bool OnCreate(); + + // Called when Destroy is called. + virtual void OnDestroy(); + + private: + friend class WindowClassRegistrar; + + // OS callback called by message pump. Handles the WM_NCCREATE message which + // is passed when the non-client area is being created and enables automatic + // non-client DPI scaling so that the non-client area automatically + // responsponds to changes in DPI. All other messages are handled by + // MessageHandler. + static LRESULT CALLBACK WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Retrieves a class instance pointer for |window| + static Win32Window* GetThisFromHandle(HWND const window) noexcept; + + bool quit_on_close_ = false; + + // window handle for top level window. + HWND window_handle_ = nullptr; + + // window handle for hosted content. + HWND child_content_ = nullptr; +}; + +#endif // RUNNER_WIN32_WINDOW_H_ diff --git a/pkgs/jni/ffigen.yaml b/pkgs/jni/ffigen.yaml new file mode 100644 index 000000000..7626d28a8 --- /dev/null +++ b/pkgs/jni/ffigen.yaml @@ -0,0 +1,19 @@ +# Run with `dart run ffigen --config ffigen.yaml`. +name: JniBindings +description: | + Bindings for `src/jni.h`. + + Regenerate bindings with `dart run ffigen --config ffigen.yaml`. +output: 'lib/jni_bindings_generated.dart' +headers: + entry-points: + - 'src/jni.h' + include-directives: + - 'src/jni.h' +preamble: | + // ignore_for_file: always_specify_types + // ignore_for_file: camel_case_types + // ignore_for_file: non_constant_identifier_names +comments: + style: any + length: full diff --git a/pkgs/jni/lib/jni.dart b/pkgs/jni/lib/jni.dart new file mode 100644 index 000000000..f9a759f1d --- /dev/null +++ b/pkgs/jni/lib/jni.dart @@ -0,0 +1,131 @@ + +import 'dart:async'; +import 'dart:ffi'; +import 'dart:io'; +import 'dart:isolate'; + +import 'jni_bindings_generated.dart'; + +/// A very short-lived native function. +/// +/// For very short-lived functions, it is fine to call them on the main isolate. +/// They will block the Dart execution while running the native function, so +/// only do this for native functions which are guaranteed to be short-lived. +int sum(int a, int b) => _bindings.sum(a, b); + +/// A longer lived native function, which occupies the thread calling it. +/// +/// Do not call these kind of native functions in the main isolate. They will +/// block Dart execution. This will cause dropped frames in Flutter applications. +/// Instead, call these native functions on a separate isolate. +/// +/// Modify this to suit your own use case. Example use cases: +/// +/// 1. Reuse a single isolate for various different kinds of requests. +/// 2. Use multiple helper isolates for parallel execution. +Future sumAsync(int a, int b) async { + final SendPort helperIsolateSendPort = await _helperIsolateSendPort; + final int requestId = _nextSumRequestId++; + final _SumRequest request = _SumRequest(requestId, a, b); + final Completer completer = Completer(); + _sumRequests[requestId] = completer; + helperIsolateSendPort.send(request); + return completer.future; +} + +const String _libName = 'jni'; + +/// The dynamic library in which the symbols for [JniBindings] can be found. +final DynamicLibrary _dylib = () { + if (Platform.isMacOS || Platform.isIOS) { + return DynamicLibrary.open('$_libName.framework/$_libName'); + } + if (Platform.isAndroid || Platform.isLinux) { + return DynamicLibrary.open('lib$_libName.so'); + } + if (Platform.isWindows) { + return DynamicLibrary.open('$_libName.dll'); + } + throw UnsupportedError('Unknown platform: ${Platform.operatingSystem}'); +}(); + +/// The bindings to the native functions in [_dylib]. +final JniBindings _bindings = JniBindings(_dylib); + + +/// A request to compute `sum`. +/// +/// Typically sent from one isolate to another. +class _SumRequest { + final int id; + final int a; + final int b; + + const _SumRequest(this.id, this.a, this.b); +} + +/// A response with the result of `sum`. +/// +/// Typically sent from one isolate to another. +class _SumResponse { + final int id; + final int result; + + const _SumResponse(this.id, this.result); +} + +/// Counter to identify [_SumRequest]s and [_SumResponse]s. +int _nextSumRequestId = 0; + +/// Mapping from [_SumRequest] `id`s to the completers corresponding to the correct future of the pending request. +final Map> _sumRequests = >{}; + +/// The SendPort belonging to the helper isolate. +Future _helperIsolateSendPort = () async { + // The helper isolate is going to send us back a SendPort, which we want to + // wait for. + final Completer completer = Completer(); + + // Receive port on the main isolate to receive messages from the helper. + // We receive two types of messages: + // 1. A port to send messages on. + // 2. Responses to requests we sent. + final ReceivePort receivePort = ReceivePort() + ..listen((dynamic data) { + if (data is SendPort) { + // The helper isolate sent us the port on which we can sent it requests. + completer.complete(data); + return; + } + if (data is _SumResponse) { + // The helper isolate sent us a response to a request we sent. + final Completer completer = _sumRequests[data.id]!; + _sumRequests.remove(data.id); + completer.complete(data.result); + return; + } + throw UnsupportedError('Unsupported message type: ${data.runtimeType}'); + }); + + // Start the helper isolate. + await Isolate.spawn((SendPort sendPort) async { + final ReceivePort helperReceivePort = ReceivePort() + ..listen((dynamic data) { + // On the helper isolate listen to requests and respond to them. + if (data is _SumRequest) { + final int result = _bindings.sum_long_running(data.a, data.b); + final _SumResponse response = _SumResponse(data.id, result); + sendPort.send(response); + return; + } + throw UnsupportedError('Unsupported message type: ${data.runtimeType}'); + }); + + // Send the the port to the main isolate on which we can receive requests. + sendPort.send(helperReceivePort.sendPort); + }, receivePort.sendPort); + + // Wait until the helper isolate has sent us back the SendPort on which we + // can start sending requests. + return completer.future; +}(); diff --git a/pkgs/jni/lib/jni_bindings_generated.dart b/pkgs/jni/lib/jni_bindings_generated.dart new file mode 100644 index 000000000..1ec49c942 --- /dev/null +++ b/pkgs/jni/lib/jni_bindings_generated.dart @@ -0,0 +1,69 @@ +// ignore_for_file: always_specify_types +// ignore_for_file: camel_case_types +// ignore_for_file: non_constant_identifier_names + +// AUTO GENERATED FILE, DO NOT EDIT. +// +// Generated by `package:ffigen`. +import 'dart:ffi' as ffi; + +/// Bindings for `src/jni.h`. +/// +/// Regenerate bindings with `dart run ffigen --config ffigen.yaml`. +/// +class JniBindings { + /// Holds the symbol lookup function. + final ffi.Pointer Function(String symbolName) + _lookup; + + /// The symbols are looked up in [dynamicLibrary]. + JniBindings(ffi.DynamicLibrary dynamicLibrary) + : _lookup = dynamicLibrary.lookup; + + /// The symbols are looked up with [lookup]. + JniBindings.fromLookup( + ffi.Pointer Function(String symbolName) + lookup) + : _lookup = lookup; + + /// A very short-lived native function. + /// + /// For very short-lived functions, it is fine to call them on the main isolate. + /// They will block the Dart execution while running the native function, so + /// only do this for native functions which are guaranteed to be short-lived. + int sum( + int a, + int b, + ) { + return _sum( + a, + b, + ); + } + + late final _sumPtr = + _lookup>( + 'sum'); + late final _sum = _sumPtr.asFunction(); + + /// A longer lived native function, which occupies the thread calling it. + /// + /// Calling these kind of native functions in the main isolate will + /// block Dart execution and cause dropped frames in Flutter applications. + /// Consider calling such native functions from a separate isolate. + int sum_long_running( + int a, + int b, + ) { + return _sum_long_running( + a, + b, + ); + } + + late final _sum_long_runningPtr = + _lookup>( + 'sum_long_running'); + late final _sum_long_running = + _sum_long_runningPtr.asFunction(); +} diff --git a/pkgs/jni/linux/CMakeLists.txt b/pkgs/jni/linux/CMakeLists.txt new file mode 100644 index 000000000..953cb0f7f --- /dev/null +++ b/pkgs/jni/linux/CMakeLists.txt @@ -0,0 +1,22 @@ +# The Flutter tooling requires that developers have CMake 3.10 or later +# installed. You should not increase this version, as doing so will cause +# the plugin to fail to compile for some customers of the plugin. +cmake_minimum_required(VERSION 3.10) + +# Project-level configuration. +set(PROJECT_NAME "jni") +project(${PROJECT_NAME} LANGUAGES CXX) + +# Invoke the build for native code shared with the other target platforms. +# This can be changed to accomodate different builds. +add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../src" "${CMAKE_CURRENT_BINARY_DIR}/shared") + +# List of absolute paths to libraries that should be bundled with the plugin. +# This list could contain prebuilt libraries, or libraries created by an +# external build triggered from this build file. +set(jni_bundled_libraries + # Defined in ../src/CMakeLists.txt. + # This can be changed to accomodate different builds. + $ + PARENT_SCOPE +) diff --git a/pkgs/jni/macos/Classes/jni.c b/pkgs/jni/macos/Classes/jni.c new file mode 100644 index 000000000..28e68ae51 --- /dev/null +++ b/pkgs/jni/macos/Classes/jni.c @@ -0,0 +1,3 @@ +// Relative import to be able to reuse the C sources. +// See the comment in ../{projectName}}.podspec for more information. +#include "../../src/jni.c" diff --git a/pkgs/jni/macos/jni.podspec b/pkgs/jni/macos/jni.podspec new file mode 100644 index 000000000..582861a93 --- /dev/null +++ b/pkgs/jni/macos/jni.podspec @@ -0,0 +1,27 @@ +# +# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. +# Run `pod lib lint jni.podspec` to validate before publishing. +# +Pod::Spec.new do |s| + s.name = 'jni' + s.version = '0.0.1' + s.summary = 'A new Flutter FFI plugin project.' + s.description = <<-DESC +A new Flutter FFI plugin project. + DESC + s.homepage = 'http://example.com' + s.license = { :file => '../LICENSE' } + s.author = { 'Your Company' => 'email@example.com' } + + # This will ensure the source files in Classes/ are included in the native + # builds of apps using this FFI plugin. Podspec does not support relative + # paths, so Classes contains a forwarder C file that relatively imports + # `../src/*` so that the C sources can be shared among all target platforms. + s.source = { :path => '.' } + s.source_files = 'Classes/**/*' + s.dependency 'FlutterMacOS' + + s.platform = :osx, '10.11' + s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' } + s.swift_version = '5.0' +end diff --git a/pkgs/jni/pubspec.yaml b/pkgs/jni/pubspec.yaml new file mode 100644 index 000000000..e1c13147e --- /dev/null +++ b/pkgs/jni/pubspec.yaml @@ -0,0 +1,79 @@ +name: jni +description: A new Flutter FFI plugin project. +version: 0.0.1 +homepage: + +environment: + sdk: ">=2.17.5 <3.0.0" + flutter: ">=2.11.0" + +dependencies: + flutter: + sdk: flutter + plugin_platform_interface: ^2.0.2 + +dev_dependencies: + ffi: ^1.1.2 + ffigen: ^4.1.2 + flutter_test: + sdk: flutter + flutter_lints: ^2.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + # This section identifies this Flutter project as a plugin project. + # The 'pluginClass' specifies the class (in Java, Kotlin, Swift, Objective-C, etc.) + # which should be registered in the plugin registry. This is required for + # using method channels. + # The Android 'package' specifies package in which the registered class is. + # This is required for using method channels on Android. + # The 'ffiPlugin' specifies that native code should be built and bundled. + # This is required for using `dart:ffi`. + # All these are used by the tooling to maintain consistency when + # adding or updating assets for this project. + # + # Please refer to README.md for a detailed explanation. + plugin: + platforms: + android: + ffiPlugin: true + linux: + ffiPlugin: true + macos: + ffiPlugin: true + windows: + ffiPlugin: true + + # To add assets to your plugin package, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + # + # For details regarding assets in packages, see + # https://flutter.dev/assets-and-images/#from-packages + # + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware + + # To add custom fonts to your plugin package, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts in packages, see + # https://flutter.dev/custom-fonts/#from-packages diff --git a/pkgs/jni/src/CMakeLists.txt b/pkgs/jni/src/CMakeLists.txt new file mode 100644 index 000000000..c9ab651c1 --- /dev/null +++ b/pkgs/jni/src/CMakeLists.txt @@ -0,0 +1,17 @@ +# The Flutter tooling requires that developers have CMake 3.10 or later +# installed. You should not increase this version, as doing so will cause +# the plugin to fail to compile for some customers of the plugin. +cmake_minimum_required(VERSION 3.10) + +project(jni_library VERSION 0.0.1 LANGUAGES C) + +add_library(jni SHARED + "jni.c" +) + +set_target_properties(jni PROPERTIES + PUBLIC_HEADER jni.h + OUTPUT_NAME "jni" +) + +target_compile_definitions(jni PUBLIC DART_SHARED_LIB) diff --git a/pkgs/jni/src/jni.c b/pkgs/jni/src/jni.c new file mode 100644 index 000000000..d87e04ea3 --- /dev/null +++ b/pkgs/jni/src/jni.c @@ -0,0 +1,23 @@ +#include "jni.h" + +// A very short-lived native function. +// +// For very short-lived functions, it is fine to call them on the main isolate. +// They will block the Dart execution while running the native function, so +// only do this for native functions which are guaranteed to be short-lived. +FFI_PLUGIN_EXPORT intptr_t sum(intptr_t a, intptr_t b) { return a + b; } + +// A longer-lived native function, which occupies the thread calling it. +// +// Do not call these kind of native functions in the main isolate. They will +// block Dart execution. This will cause dropped frames in Flutter applications. +// Instead, call these native functions on a separate isolate. +FFI_PLUGIN_EXPORT intptr_t sum_long_running(intptr_t a, intptr_t b) { + // Simulate work. +#if _WIN32 + Sleep(5000); +#else + usleep(5000 * 1000); +#endif + return a + b; +} diff --git a/pkgs/jni/src/jni.h b/pkgs/jni/src/jni.h new file mode 100644 index 000000000..084c64228 --- /dev/null +++ b/pkgs/jni/src/jni.h @@ -0,0 +1,30 @@ +#include +#include +#include + +#if _WIN32 +#include +#else +#include +#include +#endif + +#if _WIN32 +#define FFI_PLUGIN_EXPORT __declspec(dllexport) +#else +#define FFI_PLUGIN_EXPORT +#endif + +// A very short-lived native function. +// +// For very short-lived functions, it is fine to call them on the main isolate. +// They will block the Dart execution while running the native function, so +// only do this for native functions which are guaranteed to be short-lived. +FFI_PLUGIN_EXPORT intptr_t sum(intptr_t a, intptr_t b); + +// A longer lived native function, which occupies the thread calling it. +// +// Do not call these kind of native functions in the main isolate. They will +// block Dart execution. This will cause dropped frames in Flutter applications. +// Instead, call these native functions on a separate isolate. +FFI_PLUGIN_EXPORT intptr_t sum_long_running(intptr_t a, intptr_t b); diff --git a/pkgs/jni/windows/.gitignore b/pkgs/jni/windows/.gitignore new file mode 100644 index 000000000..b3eb2be16 --- /dev/null +++ b/pkgs/jni/windows/.gitignore @@ -0,0 +1,17 @@ +flutter/ + +# Visual Studio user-specific files. +*.suo +*.user +*.userosscache +*.sln.docstates + +# Visual Studio build-related files. +x64/ +x86/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ diff --git a/pkgs/jni/windows/CMakeLists.txt b/pkgs/jni/windows/CMakeLists.txt new file mode 100644 index 000000000..67bbdc687 --- /dev/null +++ b/pkgs/jni/windows/CMakeLists.txt @@ -0,0 +1,23 @@ +# The Flutter tooling requires that developers have a version of Visual Studio +# installed that includes CMake 3.14 or later. You should not increase this +# version, as doing so will cause the plugin to fail to compile for some +# customers of the plugin. +cmake_minimum_required(VERSION 3.14) + +# Project-level configuration. +set(PROJECT_NAME "jni") +project(${PROJECT_NAME} LANGUAGES CXX) + +# Invoke the build for native code shared with the other target platforms. +# This can be changed to accomodate different builds. +add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../src" "${CMAKE_CURRENT_BINARY_DIR}/shared") + +# List of absolute paths to libraries that should be bundled with the plugin. +# This list could contain prebuilt libraries, or libraries created by an +# external build triggered from this build file. +set(jni_bundled_libraries + # Defined in ../src/CMakeLists.txt. + # This can be changed to accomodate different builds. + $ + PARENT_SCOPE +) From a06690e86090aec5757ca24f4e4e4e9eae7d6b15 Mon Sep 17 00:00:00 2001 From: Mahesh Hegde <46179734+mahesh-hegde@users.noreply.github.com> Date: Sat, 23 Jul 2022 19:51:45 +0530 Subject: [PATCH 007/139] [jnigen] Initial JNI support (https://github.com/dart-lang/jnigen/issues/11) --- .github/workflows/test-package.yml | 82 +- pkgs/jni/README.md | 95 +- pkgs/jni/analysis_options.yaml | 9 + .../src/main/java/dev/dart/jni/JniPlugin.java | 61 + pkgs/jni/bin/setup.dart | 163 + pkgs/jni/example/analysis_options.yaml | 7 + pkgs/jni/example/android/app/build.gradle | 1 - .../java/dev/dart/jni_example/AnyToast.java | 28 + .../integration_test/jni_object_test.dart | 227 ++ pkgs/jni/example/lib/main.dart | 236 +- pkgs/jni/example/pubspec.lock | 100 +- pkgs/jni/example/pubspec.yaml | 4 + pkgs/jni/example/test/widget_test.dart | 43 + pkgs/jni/ffigen.yaml | 104 +- pkgs/jni/lib/jni.dart | 181 +- pkgs/jni/lib/jni_bindings_generated.dart | 69 - pkgs/jni/lib/jni_object.dart | 14 + .../jni/lib/src/direct_methods_generated.dart | 630 ++++ pkgs/jni/lib/src/extensions.dart | 97 + pkgs/jni/lib/src/jni.dart | 269 ++ pkgs/jni/lib/src/jni_class.dart | 153 + .../lib/src/jni_class_methods_generated.dart | 408 +++ pkgs/jni/lib/src/jni_exceptions.dart | 49 + pkgs/jni/lib/src/jni_object.dart | 180 + .../lib/src/jni_object_methods_generated.dart | 402 +++ pkgs/jni/lib/src/jvalues.dart | 137 + .../third_party/jni_bindings_generated.dart | 3086 +++++++++++++++++ pkgs/jni/pubspec.yaml | 90 +- pkgs/jni/src/.gitignore | 8 + pkgs/jni/src/CMakeLists.txt | 20 +- pkgs/jni/src/README.md | 27 + pkgs/jni/src/dartjni.c | 139 + pkgs/jni/src/dartjni.h | 123 + pkgs/jni/src/jni.c | 23 - pkgs/jni/src/jni.h | 30 - pkgs/jni/test/exception_test.dart | 58 + pkgs/jni/test/jni_object_test.dart | 222 ++ pkgs/jni/test/jni_test.dart | 123 + pkgs/jni/third_party/jni.h | 1146 ++++++ pkgs/jni/tool/gen_aux_methods.dart | 129 + .../templates/invoke_static_methods.dart.tmpl | 29 + .../templates/jni_object_fields.dart.tmpl | 16 + .../templates/jni_object_methods.dart.tmpl | 23 + .../retrieve_static_fields.dart.tmpl | 28 + 44 files changed, 8622 insertions(+), 447 deletions(-) create mode 100644 pkgs/jni/android/src/main/java/dev/dart/jni/JniPlugin.java create mode 100644 pkgs/jni/bin/setup.dart create mode 100644 pkgs/jni/example/android/app/src/main/java/dev/dart/jni_example/AnyToast.java create mode 100644 pkgs/jni/example/integration_test/jni_object_test.dart create mode 100644 pkgs/jni/example/test/widget_test.dart delete mode 100644 pkgs/jni/lib/jni_bindings_generated.dart create mode 100644 pkgs/jni/lib/jni_object.dart create mode 100644 pkgs/jni/lib/src/direct_methods_generated.dart create mode 100644 pkgs/jni/lib/src/extensions.dart create mode 100644 pkgs/jni/lib/src/jni.dart create mode 100644 pkgs/jni/lib/src/jni_class.dart create mode 100644 pkgs/jni/lib/src/jni_class_methods_generated.dart create mode 100644 pkgs/jni/lib/src/jni_exceptions.dart create mode 100644 pkgs/jni/lib/src/jni_object.dart create mode 100644 pkgs/jni/lib/src/jni_object_methods_generated.dart create mode 100644 pkgs/jni/lib/src/jvalues.dart create mode 100644 pkgs/jni/lib/src/third_party/jni_bindings_generated.dart create mode 100644 pkgs/jni/src/.gitignore create mode 100644 pkgs/jni/src/README.md create mode 100644 pkgs/jni/src/dartjni.c create mode 100644 pkgs/jni/src/dartjni.h delete mode 100644 pkgs/jni/src/jni.c delete mode 100644 pkgs/jni/src/jni.h create mode 100644 pkgs/jni/test/exception_test.dart create mode 100644 pkgs/jni/test/jni_object_test.dart create mode 100644 pkgs/jni/test/jni_test.dart create mode 100644 pkgs/jni/third_party/jni.h create mode 100644 pkgs/jni/tool/gen_aux_methods.dart create mode 100644 pkgs/jni/tool/templates/invoke_static_methods.dart.tmpl create mode 100644 pkgs/jni/tool/templates/jni_object_fields.dart.tmpl create mode 100644 pkgs/jni/tool/templates/jni_object_methods.dart.tmpl create mode 100644 pkgs/jni/tool/templates/retrieve_static_fields.dart.tmpl diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index aa9eccbb4..24e7d5e51 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -72,27 +72,58 @@ jobs: uses: coverallsapp/github-action@v1.1.2 with: github-token: ${{ secrets.GITHUB_TOKEN }} + flag-name: jni_gen_tests + parallel: true path-to-lcov: ./pkgs/jni_gen/coverage/lcov.info - build_jni_example_linux: + ## TODO: More minimal test on windows after fixing dev dependency. + ## i.e do not rerun analyze and format steps, and do not require flutter. + ## IssueRef: https://github.com/dart-lang/jni_gen/issues/15 + + test_jni: runs-on: ubuntu-latest defaults: run: - working-directory: ./pkgs/jni/example + working-directory: ./pkgs/jni steps: - uses: actions/checkout@v3 + ## Requires flutter to analyze example. + ## Using dart alone doesn't work. - uses: subosito/flutter-action@v2 with: channel: 'stable' + - uses: actions/setup-java@v2 + with: + distribution: 'zulu' + java-version: '11' - run: | sudo apt-get update -y sudo apt-get install -y ninja-build libgtk-3-dev - - run: flutter config --enable-linux-desktop + - run: dart pub get + - run: dart run bin/setup.dart - run: flutter pub get - - run: flutter build linux + - name: Check formatting + run: flutter format --output=none --set-exit-if-changed . + - name: Run lints + run: flutter analyze --fatal-infos + - name: Get dependencies + run: dart pub get + - name: Run tests + run: dart test + - name: Install coverage + run: dart pub global activate coverage + - name: Collect coverage + run: dart pub global run coverage:test_with_coverage + - name: Upload coverage + uses: coverallsapp/github-action@v1.1.2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + flag-name: jni_tests + parallel: true + path-to-lcov: ./pkgs/jni/coverage/lcov.info - build_jni_example_windows: - runs-on: windows-latest + build_jni_example_linux: + runs-on: ubuntu-latest defaults: run: working-directory: ./pkgs/jni/example @@ -101,12 +132,24 @@ jobs: - uses: subosito/flutter-action@v2 with: channel: 'stable' - - run: flutter config --enable-windows-desktop + - uses: actions/setup-java@v2 + with: + distribution: 'zulu' + java-version: '11' + - run: | + sudo apt-get update -y + sudo apt-get install -y ninja-build libgtk-3-dev + - run: dart pub get + working-directory: ./pkgs/jni + - run: dart run bin/setup.dart + working-directory: ./pkgs/jni + - run: flutter config --enable-linux-desktop - run: flutter pub get - - run: flutter build windows + - run: flutter test + - run: flutter build linux - build_jni_example_macos: - runs-on: macos-latest + build_jni_example_windows: + runs-on: windows-latest defaults: run: working-directory: ./pkgs/jni/example @@ -115,10 +158,13 @@ jobs: - uses: subosito/flutter-action@v2 with: channel: 'stable' - architecture: x64 - - run: flutter config --enable-macos-desktop + - uses: actions/setup-java@v2 + with: + distribution: 'zulu' + java-version: '11' + - run: flutter config --enable-windows-desktop - run: flutter pub get - - run: flutter build macos + - run: flutter build windows build_jni_example_android: runs-on: ubuntu-latest @@ -138,3 +184,13 @@ jobs: - run: flutter build apk - run: flutter build appbundle + coveralls_finish: + needs: [test_jni_gen, test_jni] + runs-on: ubuntu-latest + steps: + - name: Coveralls finished + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.github_token }} + parallel-finished: true + diff --git a/pkgs/jni/README.md b/pkgs/jni/README.md index 45ee1cf70..73f122a9b 100644 --- a/pkgs/jni/README.md +++ b/pkgs/jni/README.md @@ -1,92 +1,37 @@ -# jni +# jni (experimental module) -A new Flutter FFI plugin project. +This is a utility library to access JNI from Dart / Flutter code, intended as a supplement for `jnigen` code generator, as well as provide the common base components (such as managing the JVM instance) to the code generated by `jni_gen`. -## Getting Started +This library contains: -This project is a starting point for a Flutter -[FFI plugin](https://docs.flutter.dev/development/platform-integration/c-interop), -a specialized package that includes native code directly invoked with Dart FFI. +* functions to access the JNIEnv and JavaVM variables from JNI, and wrapper functions to those provided by JNI. (`Jni.getEnv`, `Jni.getJavaVM`). -## Project stucture +* Functions to spawn a JVM on desktop platforms (`Jni.spawn`). -This template uses the following structure: +* Some utility functions to make it easier to work with JNI in Dart; eg: To convert a java string object to Dart string (mostly as extension methods on `Pointer`). -* `src`: Contains the native source code, and a CmakeFile.txt file for building - that source code into a dynamic library. +* Some Android-specific helpers (get application context and current activity references). -* `lib`: Contains the Dart code that defines the API of the plugin, and which - calls into the native code using `dart:ffi`. +* Some helper classes and functions to simplify one-off uses (`JniObject` and `JniClass` intended for calling functions by specifying the name and arguments. It will reduce some boilerplate when you're debugging. Note: this API is slightly incomplete). -* platform folders (`android`, `ios`, `windows`, etc.): Contains the build files - for building and bundling the native code library with the platform application. +This is intended for one-off / debugging uses of JNI, as well as providing a base library for code generated by jni_gen. -## Buidling and bundling native code +__To interface a complete java library, look forward for `jni_gen`.__ -The `pubspec.yaml` specifies FFI plugins as follows: +## Platform support +The focus of this project is Flutter Android, since Flutter Android apps already have a JVM, and JNI enables interop with existing Java code and Android Platform APIs. This project also (partially) supports Linux desktop by spawning a JVM through JNI. -```yaml - plugin: - platforms: - some_platform: - ffiPlugin: true -``` +## Version note +This library is at an early stage of development and we do not provide backwards compatibility of the API at this point. -This configuration invokes the native build for the various target platforms -and bundles the binaries in Flutter applications using these FFI plugins. +## Documentation +The test/ directory contains files with comments explaining the basics of this module, and the example/ directory contains a flutter example which also touches some Android-specifics. -This can be combined with dartPluginClass, such as when FFI is used for the -implementation of one platform in a federated plugin: +Using this library assumes some familiarity with JNI - it's threading model and object references, among other things. -```yaml - plugin: - implements: some_other_plugin - platforms: - some_platform: - dartPluginClass: SomeClass - ffiPlugin: true -``` +## jni_gen -A plugin can have both FFI and method channels: +This library is a part of `jni_gen` - a 2022 GSoC project. -```yaml - plugin: - platforms: - some_platform: - pluginClass: SomeName - ffiPlugin: true -``` - -The native build systems that are invoked by FFI (and method channel) plugins are: - -* For Android: Gradle, which invokes the Android NDK for native builds. - * See the documentation in android/build.gradle. -* For iOS and MacOS: Xcode, via CocoaPods. - * See the documentation in ios/jni.podspec. - * See the documentation in macos/jni.podspec. -* For Linux and Windows: CMake. - * See the documentation in linux/CMakeLists.txt. - * See the documentation in windows/CMakeLists.txt. - -## Binding to native code - -To use the native code, bindings in Dart are needed. -To avoid writing these by hand, they are generated from the header file -(`src/jni.h`) by `package:ffigen`. -Regenerate the bindings by running `flutter pub run ffigen --config ffigen.yaml`. - -## Invoking native code - -Very short-running native functions can be directly invoked from any isolate. -For example, see `sum` in `lib/jni.dart`. - -Longer-running functions should be invoked on a helper isolate to avoid -dropping frames in Flutter applications. -For example, see `sumAsync` in `lib/jni.dart`. - -## Flutter help - -For help getting started with Flutter, view our -[online documentation](https://flutter.dev/docs), which offers tutorials, -samples, guidance on mobile development, and a full API reference. +The broader aim of jni_gen is making Java APIs accessible from dart in an idiomatic way. diff --git a/pkgs/jni/analysis_options.yaml b/pkgs/jni/analysis_options.yaml index a5744c1cf..89f8ee95f 100644 --- a/pkgs/jni/analysis_options.yaml +++ b/pkgs/jni/analysis_options.yaml @@ -1,4 +1,13 @@ include: package:flutter_lints/flutter.yaml +analyzer: + exclude: [build/**] + language: + strict-raw-types: true + +linter: + rules: + - prefer_final_locals + - prefer_const_declarations # Additional information about this file can be found at # https://dart.dev/guides/language/analysis-options diff --git a/pkgs/jni/android/src/main/java/dev/dart/jni/JniPlugin.java b/pkgs/jni/android/src/main/java/dev/dart/jni/JniPlugin.java new file mode 100644 index 000000000..dbf872745 --- /dev/null +++ b/pkgs/jni/android/src/main/java/dev/dart/jni/JniPlugin.java @@ -0,0 +1,61 @@ +package dev.dart.jni; + +import androidx.annotation.Keep; +import androidx.annotation.NonNull; +import android.util.Log; +import android.app.Activity; +import io.flutter.plugin.common.PluginRegistry.Registrar; +import io.flutter.embedding.engine.plugins.FlutterPlugin; +import io.flutter.embedding.engine.plugins.activity.ActivityAware; +import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding; + +import android.content.Context; + +@Keep +public class JniPlugin implements FlutterPlugin, ActivityAware { + + @Override + public void + onAttachedToEngine(@NonNull FlutterPluginBinding binding) { + setup(binding.getApplicationContext()); + } + + public static void registerWith(Registrar registrar) { + JniPlugin plugin = new JniPlugin(); + plugin.setup(registrar.activeContext()); + } + + private void setup(Context context) { + initializeJni(context, getClass().getClassLoader()); + } + + @Override + public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {} + + // Activity handling methods + @Override + public void onAttachedToActivity(@NonNull ActivityPluginBinding binding) { + Activity activity = binding.getActivity(); + setJniActivity(activity, activity.getApplicationContext()); + } + + @Override + public void onDetachedFromActivityForConfigChanges() {} + + @Override + public void onReattachedToActivityForConfigChanges(@NonNull ActivityPluginBinding binding) { + Activity activity = binding.getActivity(); + setJniActivity(activity, activity.getApplicationContext()); + } + + @Override + public void onDetachedFromActivity() {} + + native void initializeJni(Context context, ClassLoader classLoader); + native void setJniActivity(Activity activity, Context context); + + static { + System.loadLibrary("dartjni"); + } +} + diff --git a/pkgs/jni/bin/setup.dart b/pkgs/jni/bin/setup.dart new file mode 100644 index 000000000..508f5e294 --- /dev/null +++ b/pkgs/jni/bin/setup.dart @@ -0,0 +1,163 @@ +import 'dart:io'; + +import 'package:args/args.dart'; +import 'package:package_config/package_config.dart'; + +const _buildDir = "build-dir"; +const _srcDir = "source-dir"; +const _verbose = "verbose"; +const _cmakeArgs = "cmake-args"; +const _clean = "clean"; + +// Sets up input output channels and maintains state. +class CommandRunner { + CommandRunner({this.printCmds = false}); + bool printCmds = false; + int? time; + // TODO: time commands + // TODO: Run all commands in single shell instance + // IssueRef: https://github.com/dart-lang/jni_gen/issues/14 + Future run( + String exec, List args, String workingDir) async { + if (printCmds) { + final cmd = "$exec ${args.join(" ")}"; + stderr.writeln("\n+ [$workingDir] $cmd"); + } + final process = await Process.start(exec, args, + workingDirectory: workingDir, + runInShell: Platform.isWindows, + mode: ProcessStartMode.inheritStdio); + final exitCode = await process.exitCode; + if (exitCode != 0) { + stderr.writeln("command exited with $exitCode"); + } + return this; + } +} + +class Options { + Options(ArgResults arg) + : buildDir = arg[_buildDir], + srcDir = arg[_srcDir], + cmakeArgs = arg[_cmakeArgs], + verbose = arg[_verbose] ?? false, + clean = arg[_clean] ?? false; + + String? buildDir, srcDir, cmakeArgs; + bool verbose, clean; +} + +late Options options; +void log(String msg) { + if (options.verbose) { + stderr.writeln(msg); + } +} + +/// tries to find package:jni's source folder in pub cache +/// if not possible, returns null. +Future findSources() async { + final packageConfig = await findPackageConfig(Directory.current); + if (packageConfig == null) { + return null; + } + final packages = packageConfig.packages; + for (var package in packages) { + if (package.name == 'jni') { + return package.root.resolve("src/").toFilePath(); + } + } + return null; +} + +void main(List arguments) async { + final parser = ArgParser() + ..addOption(_buildDir, + abbr: 'B', help: 'Directory to place built artifacts') + ..addOption(_srcDir, + abbr: 'S', help: 'alternative path to package:jni sources') + ..addFlag(_verbose, abbr: 'v', help: 'Enable verbose output') + ..addFlag(_clean, + negatable: false, + abbr: 'C', + help: 'Clear built artifacts instead of running a build') + ..addOption(_cmakeArgs, + abbr: 'm', + help: 'additional space separated arguments to pass to CMake'); + final cli = parser.parse(arguments); + options = Options(cli); + final rest = cli.rest; + + if (rest.isNotEmpty) { + stderr.writeln("one or more unrecognized arguments: $rest"); + stderr.writeln("usage: dart run jni:setup "); + stderr.writeln(parser.usage); + exitCode = 1; + return; + } + + final srcPath = options.srcDir ?? await findSources(); + + if (srcPath == null) { + stderr.writeln("No sources specified and current directory is not a " + "package root."); + exitCode = 1; + return; + } + + final srcDir = Directory(srcPath); + if (!await srcDir.exists() && !options.clean) { + throw 'Directory $srcPath does not exist'; + } + + log("srcPath: $srcPath"); + + final currentDirUri = Uri.file("."); + final buildPath = + options.buildDir ?? currentDirUri.resolve("src/build").toFilePath(); + final buildDir = Directory(buildPath); + await buildDir.create(recursive: true); + log("buildPath: $buildPath"); + + if (buildDir.absolute.uri == srcDir.absolute.uri) { + stderr.writeln("Please build in a directory different than source."); + exit(2); + } + + if (options.clean) { + await cleanup(options, srcDir.absolute.path, buildDir.absolute.path); + } else { + // pass srcDir absolute path because it will be passed to CMake as arg + // which will be running in different directory + await build(options, srcDir.absolute.path, buildDir.path); + } +} + +Future build(Options options, String srcPath, String buildPath) async { + final runner = CommandRunner(printCmds: true); + final cmakeArgs = []; + if (options.cmakeArgs != null) { + cmakeArgs.addAll(options.cmakeArgs!.split(" ")); + } + cmakeArgs.add(srcPath); + await runner.run("cmake", cmakeArgs, buildPath); + await runner.run("cmake", ["--build", "."], buildPath); + if (Platform.isWindows) { + await runner.run("move", ["Debug\\dartjni.dll", "."], buildPath); + } +} + +Future cleanup(Options options, String srcPath, String buildPath) async { + if (srcPath == buildPath) { + stderr.writeln('Error: build path is same as source path.'); + } + + stderr.writeln("deleting $buildPath"); + + try { + await Directory(buildPath).delete(recursive: true); + } catch (e) { + stderr.writeln("Error: cannot be deleted"); + stderr.writeln(e); + } +} diff --git a/pkgs/jni/example/analysis_options.yaml b/pkgs/jni/example/analysis_options.yaml index 61b6c4de1..7f0b15f4f 100644 --- a/pkgs/jni/example/analysis_options.yaml +++ b/pkgs/jni/example/analysis_options.yaml @@ -9,6 +9,11 @@ # packages, and plugins designed to encourage good coding practices. include: package:flutter_lints/flutter.yaml +analyzer: + exclude: [build/**] + language: + strict-raw-types: true + linter: # The lint rules applied to this project can be customized in the # section below to disable rules from the `package:flutter_lints/flutter.yaml` @@ -22,6 +27,8 @@ linter: # `// ignore_for_file: name_of_lint` syntax on the line or in the file # producing the lint. rules: + - prefer_final_locals + - prefer_const_declarations # avoid_print: false # Uncomment to disable the `avoid_print` rule # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule diff --git a/pkgs/jni/example/android/app/build.gradle b/pkgs/jni/example/android/app/build.gradle index 468be1348..ec132990b 100644 --- a/pkgs/jni/example/android/app/build.gradle +++ b/pkgs/jni/example/android/app/build.gradle @@ -43,7 +43,6 @@ android { } defaultConfig { - // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "dev.dart.jni_example" // You can update the following values to match your application needs. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. diff --git a/pkgs/jni/example/android/app/src/main/java/dev/dart/jni_example/AnyToast.java b/pkgs/jni/example/android/app/src/main/java/dev/dart/jni_example/AnyToast.java new file mode 100644 index 000000000..59f07f715 --- /dev/null +++ b/pkgs/jni/example/android/app/src/main/java/dev/dart/jni_example/AnyToast.java @@ -0,0 +1,28 @@ +package dev.dart.jni_example; + +import android.app.Activity; +import android.os.Handler; +import android.content.Context; +import android.widget.Toast; +import androidx.annotation.Keep; + +@Keep +class AnyToast { + static AnyToast makeText(Activity mainActivity, Context context, CharSequence text, int duration) { + AnyToast toast = new AnyToast(); + toast.mainActivity = mainActivity; + toast.context = context; + toast.text = text; + toast.duration = duration; + return toast; + } + + void show() { + mainActivity.runOnUiThread(() -> Toast.makeText(context, text, duration).show()); + } + + Activity mainActivity; + Context context; + CharSequence text; + int duration; +} diff --git a/pkgs/jni/example/integration_test/jni_object_test.dart b/pkgs/jni/example/integration_test/jni_object_test.dart new file mode 100644 index 000000000..85086d944 --- /dev/null +++ b/pkgs/jni/example/integration_test/jni_object_test.dart @@ -0,0 +1,227 @@ +import 'dart:io'; +import 'dart:ffi'; +import 'dart:isolate'; + +import 'package:flutter_test/flutter_test.dart'; +import 'package:ffi/ffi.dart'; + +import 'package:jni/jni.dart'; +import 'package:jni/jni_object.dart'; + +void main() { + if (!Platform.isAndroid) { + Jni.spawn(); + } + + final jni = Jni.getInstance(); + testWidgets('get JNI Version', (tester) async { + final env = jni.getEnv(); + expect(env.GetVersion(), isNot(equals(0))); + }); + + testWidgets('Manually lookup & call Long.toHexString static method', + (tester) async { + final arena = Arena(); + final env = jni.getEnv(); + final longClass = env.FindClass("java/lang/Long".toNativeChars(arena)); + final hexMethod = env.GetStaticMethodID( + longClass, + "toHexString".toNativeChars(arena), + "(J)Ljava/lang/String;".toNativeChars(arena)); + + for (var i in [1, 80, 13, 76, 1134453224145]) { + final jres = env.CallStaticObjectMethodA( + longClass, hexMethod, Jni.jvalues([JValueLong(i)], allocator: arena)); + + final res = env.asDartString(jres); + expect(res, equals(i.toRadixString(16))); + env.DeleteLocalRef(jres); + } + env.DeleteLocalRef(longClass); + arena.releaseAll(); + }); + + testWidgets("asJString extension method", (tester) async { + final env = jni.getEnv(); + const str = "QWERTY QWERTY"; + final jstr = env.asJString(str); + expect(str, equals(env.asDartString(jstr))); + env.DeleteLocalRef(jstr); + }); + + testWidgets("Convert back and forth between dart and java string", + (tester) async { + final arena = Arena(); + final env = jni.getEnv(); + const str = "ABCD EFGH"; + final jstr = env.NewStringUTF(str.toNativeChars(arena)); + final jchars = env.GetStringUTFChars(jstr, nullptr); + final dstr = jchars.toDartString(); + env.ReleaseStringUTFChars(jstr, jchars); + expect(str, equals(dstr)); + + env.deleteAllLocalRefs([jstr]); + arena.releaseAll(); + }); + + testWidgets("Print something from Java", (tester) async { + final arena = Arena(); + final env = jni.getEnv(); + final system = env.FindClass("java/lang/System".toNativeChars(arena)); + final field = env.GetStaticFieldID(system, "out".toNativeChars(arena), + "Ljava/io/PrintStream;".toNativeChars(arena)); + final out = env.GetStaticObjectField(system, field); + final printStream = env.GetObjectClass(out); + /* + final println = env.GetMethodID(printStream, "println".toNativeChars(arena), + "(Ljava/lang/String;)V".toNativeChars(arena)); + */ + const str = "\nHello JNI!"; + final jstr = env.asJString(str); + env.deleteAllLocalRefs([system, printStream, jstr]); + arena.releaseAll(); + }); + + testWidgets("Long.intValue() using JniObject", (tester) async { + final longClass = jni.findJniClass("java/lang/Long"); + + final longCtor = longClass.getConstructorID("(J)V"); + + final long = longClass.newObject(longCtor, [176]); + + final intValue = long.callIntMethodByName("intValue", "()I", []); + expect(intValue, equals(176)); + + long.delete(); + longClass.delete(); + }); + + testWidgets("call a static method using JniClass APIs", (tester) async { + final integerClass = jni.wrapClass(jni.findClass("java/lang/Integer")); + final result = integerClass.callStaticObjectMethodByName( + "toHexString", "(I)Ljava/lang/String;", [31]); + + final resultString = result.asDartString(); + + result.delete(); + expect(resultString, equals("1f")); + + integerClass.delete(); + }); + + testWidgets("Example for using getMethodID", (tester) async { + final longClass = jni.findJniClass("java/lang/Long"); + final bitCountMethod = longClass.getStaticMethodID("bitCount", "(J)I"); + + final random = jni.newInstance("java/util/Random", "()V", []); + + final nextIntMethod = random.getMethodID("nextInt", "(I)I"); + + for (int i = 0; i < 100; i++) { + int r = random.callIntMethod(nextIntMethod, [256 * 256]); + int bits = 0; + final jbc = + longClass.callStaticIntMethod(bitCountMethod, [JValueLong(r)]); + while (r != 0) { + bits += r % 2; + r = (r / 2).floor(); + } + expect(jbc, equals(bits)); + } + + random.delete(); + longClass.delete(); + }); + + testWidgets("invoke_", (tester) async { + final m = jni.invokeLongMethod( + "java/lang/Long", "min", "(JJ)J", [JValueLong(1234), JValueLong(1324)]); + expect(m, equals(1234)); + }); + + testWidgets("retrieve_", (tester) async { + final maxLong = jni.retrieveShortField("java/lang/Short", "MAX_VALUE", "S"); + expect(maxLong, equals(32767)); + }); + + testWidgets("callStaticStringMethod", (tester) async { + final longClass = jni.findJniClass("java/lang/Long"); + const n = 1223334444; + final strFromJava = longClass.callStaticStringMethodByName( + "toOctalString", "(J)Ljava/lang/String;", [JValueLong(n)]); + expect(strFromJava, equals(n.toRadixString(8))); + longClass.delete(); + }); + + testWidgets("Passing strings in arguments", (tester) async { + final out = jni.retrieveObjectField( + "java/lang/System", "out", "Ljava/io/PrintStream;"); + // uncomment next line to see output + // (\n because test runner prints first char at end of the line) + //out.callVoidMethodByName( + // "println", "(Ljava/lang/Object;)V", ["\nWorks (Apparently)"]); + out.delete(); + }); + + testWidgets("Passing strings in arguments 2", (tester) async { + final twelve = jni.invokeByteMethod( + "java/lang/Byte", "parseByte", "(Ljava/lang/String;)B", ["12"]); + expect(twelve, equals(12)); + }); + + testWidgets("use() method", (tester) async { + final randomInt = jni.newInstance("java/util/Random", "()V", []).use( + (random) => random.callIntMethodByName("nextInt", "(I)I", [15])); + expect(randomInt, lessThan(15)); + }); + + testWidgets("enums", (tester) async { + final ordinal = jni + .retrieveObjectField( + "java/net/Proxy\$Type", "HTTP", "Ljava/net/Proxy\$Type;") + .use((f) => f.callIntMethodByName("ordinal", "()I", [])); + expect(ordinal, equals(1)); + }); + + testWidgets("Isolate", (tester) async { + Isolate.spawn(doSomeWorkInIsolate, null); + }); + + testWidgets("JniGlobalRef", (tester) async { + final uri = jni.invokeObjectMethod( + "java/net/URI", + "create", + "(Ljava/lang/String;)Ljava/net/URI;", + ["https://www.google.com/search"]); + final rg = uri.getGlobalRef(); + await Future.delayed(const Duration(seconds: 1), () { + final env = jni.getEnv(); + // Now comment this line & try to directly use uri local ref + // in outer scope. + // + // You will likely get a segfault, because Future computation is running + // in different thread. + // + // Therefore, don't share JniObjects across functions that can be + // scheduled across threads, including async callbacks. + final uri = JniObject.fromGlobalRef(env, rg); + final scheme = + uri.callStringMethodByName("getScheme", "()Ljava/lang/String;", []); + expect(scheme, "https"); + uri.delete(); + rg.deleteIn(env); + }); + uri.delete(); + }); +} + +void doSomeWorkInIsolate(Void? _) { + final jni = Jni.getInstance(); + final random = jni.newInstance("java/util/Random", "()V", []); + // var r = random.callIntMethodByName("nextInt", "(I)I", [256]); + // expect(r, lessThan(256)); + // Expect throws an OutsideTestException + // but you can uncomment below print and see it works + // print("\n$r"); + random.delete(); +} diff --git a/pkgs/jni/example/lib/main.dart b/pkgs/jni/example/lib/main.dart index 9f4f90381..c21802b92 100644 --- a/pkgs/jni/example/lib/main.dart +++ b/pkgs/jni/example/lib/main.dart @@ -1,74 +1,218 @@ +// ignore_for_file: library_private_types_in_public_api + import 'package:flutter/material.dart'; -import 'dart:async'; -import 'package:jni/jni.dart' as jni; +import 'dart:io'; +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; +import 'package:jni/jni.dart'; +import 'package:jni/jni_object.dart'; + +late Jni jni; + +String localToJavaString(int n) { + final jniEnv = jni.getEnv(); + final arena = Arena(); + final cls = jniEnv.FindClass("java/lang/String".toNativeChars(arena)); + final mId = jniEnv.GetStaticMethodID(cls, "valueOf".toNativeChars(), + "(I)Ljava/lang/String;".toNativeChars(arena)); + final i = arena(); + i.ref.i = n; + final res = jniEnv.CallStaticObjectMethodA(cls, mId, i); + final str = jniEnv.asDartString(res); + jniEnv.deleteAllLocalRefs([res, cls]); + arena.releaseAll(); + return str; +} + +int random(int n) { + final arena = Arena(); + final jniEnv = jni.getEnv(); + final randomCls = jniEnv.FindClass("java/util/Random".toNativeChars(arena)); + final ctor = jniEnv.GetMethodID( + randomCls, "".toNativeChars(arena), "()V".toNativeChars(arena)); + final random = jniEnv.NewObject(randomCls, ctor); + final nextInt = jniEnv.GetMethodID( + randomCls, "nextInt".toNativeChars(arena), "(I)I".toNativeChars(arena)); + final res = jniEnv.CallIntMethodA(random, nextInt, Jni.jvalues([n])); + jniEnv.deleteAllLocalRefs([randomCls, random]); + return res; +} + +double randomDouble() { + final math = jni.findJniClass("java/lang/Math"); + final random = math.callStaticDoubleMethodByName("random", "()D", []); + math.delete(); + return random; +} + +int uptime() { + final systemClock = jni.findJniClass("android/os/SystemClock"); + final uptime = + systemClock.callStaticLongMethodByName("uptimeMillis", "()J", []); + systemClock.delete(); + return uptime; +} + +void quit() { + jni + .wrap(jni.getCurrentActivity()) + .use((ac) => ac.callVoidMethodByName("finish", "()V", [])); +} + +void showToast(String text) { + // This is example for calling you app's custom java code. + // You place the AnyToast class in you app's android/ source + // Folder, with a Keep annotation or appropriate proguard rules + // to retain the class in release mode. + // In this example, AnyToast class is just a type of `Toast` that + // can be called from any thread. See + // android/app/src/main/java/dev/dart/jni_example/AnyToast.java + jni.invokeObjectMethod( + "dev/dart/jni_example/AnyToast", + "makeText", + "(Landroid/app/Activity;Landroid/content/Context;" + "Ljava/lang/CharSequence;I)" + "Ldev/dart/jni_example/AnyToast;", + [ + jni.getCurrentActivity(), + jni.getCachedApplicationContext(), + ":-)", + 0 + ]).callVoidMethodByName("show", "()V", []); +} void main() { - runApp(const MyApp()); + if (!Platform.isAndroid) { + Jni.spawn(); + } + jni = Jni.getInstance(); + final examples = [ + Example("String.valueOf(1332)", () => localToJavaString(1332)), + Example("Generate random number", () => random(180), runInitially: false), + Example("Math.random()", () => randomDouble(), runInitially: false), + if (Platform.isAndroid) ...[ + Example("Minutes of usage since reboot", + () => (uptime() / (60 * 1000)).floor()), + Example( + "Device name", + () => jni.retrieveStringField( + "android/os/Build", "DEVICE", "Ljava/lang/String;")), + Example( + "Package name", + () => jni.wrap(jni.getCurrentActivity()).use((activity) => activity + .callStringMethodByName( + "getPackageName", "()Ljava/lang/String;", [])), + ), + Example("Show toast", () => showToast("Hello from JNI!"), + runInitially: false), + Example( + "Quit", + quit, + runInitially: false, + ), + ] + ]; + runApp(MyApp(examples)); +} + +class Example { + String title; + dynamic Function() callback; + bool runInitially; + Example(this.title, this.callback, {this.runInitially = true}); } class MyApp extends StatefulWidget { - const MyApp({Key? key}) : super(key: key); + const MyApp(this.examples, {Key? key}) : super(key: key); + final List examples; @override _MyAppState createState() => _MyAppState(); } class _MyAppState extends State { - late int sumResult; - late Future sumAsyncResult; - @override void initState() { super.initState(); - sumResult = jni.sum(1, 2); - sumAsyncResult = jni.sumAsync(3, 4); } @override Widget build(BuildContext context) { - const textStyle = TextStyle(fontSize: 25); - const spacerSmall = SizedBox(height: 10); return MaterialApp( home: Scaffold( appBar: AppBar( - title: const Text('Native Packages'), - ), - body: SingleChildScrollView( - child: Container( - padding: const EdgeInsets.all(10), - child: Column( - children: [ - const Text( - 'This calls a native function through FFI that is shipped as source in the package. ' - 'The native code is built as part of the Flutter Runner build.', - style: textStyle, - textAlign: TextAlign.center, - ), - spacerSmall, - Text( - 'sum(1, 2) = $sumResult', - style: textStyle, - textAlign: TextAlign.center, - ), - spacerSmall, - FutureBuilder( - future: sumAsyncResult, - builder: (BuildContext context, AsyncSnapshot value) { - final displayValue = - (value.hasData) ? value.data : 'loading'; - return Text( - 'await sumAsync(3, 4) = $displayValue', - style: textStyle, - textAlign: TextAlign.center, - ); - }, - ), - ], - ), - ), + title: const Text('JNI Examples'), ), + body: ListView.builder( + itemCount: widget.examples.length, + itemBuilder: (context, i) { + final eg = widget.examples[i]; + return ExampleCard(eg); + }), ), ); } } + +class ExampleCard extends StatefulWidget { + const ExampleCard(this.example, {Key? key}) : super(key: key); + final Example example; + + @override + _ExampleCardState createState() => _ExampleCardState(); +} + +class _ExampleCardState extends State { + Widget _pad(Widget w, double h, double v) { + return Padding( + padding: EdgeInsets.symmetric(horizontal: h, vertical: v), child: w); + } + + bool _run = false; + + @override + void initState() { + super.initState(); + _run = widget.example.runInitially; + } + + @override + Widget build(BuildContext context) { + final eg = widget.example; + var result = ""; + var hasError = false; + if (_run) { + try { + result = eg.callback().toString(); + } on Exception catch (e) { + hasError = true; + result = e.toString(); + } on Error catch (e) { + hasError = true; + result = e.toString(); + } + } + var resultStyle = const TextStyle(fontFamily: "Monospace"); + if (hasError) { + resultStyle = const TextStyle(fontFamily: "Monospace", color: Colors.red); + } + return Card( + child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + Text(eg.title, + softWrap: true, + style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600)), + _pad( + Text(result.toString(), softWrap: true, style: resultStyle), 8, 16), + _pad( + ElevatedButton( + child: Text(_run ? "Run again" : "Run"), + onPressed: () => setState(() => _run = true), + ), + 8, + 8), + ]), + ); + } +} diff --git a/pkgs/jni/example/pubspec.lock b/pkgs/jni/example/pubspec.lock index 77442b507..2f0d348e5 100644 --- a/pkgs/jni/example/pubspec.lock +++ b/pkgs/jni/example/pubspec.lock @@ -1,6 +1,20 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + archive: + dependency: transitive + description: + name: archive + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.11" + args: + dependency: transitive + description: + name: args + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.1" async: dependency: transitive description: @@ -43,6 +57,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.16.0" + crypto: + dependency: transitive + description: + name: crypto + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.1" cupertino_icons: dependency: "direct main" description: @@ -57,11 +78,30 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.3.0" + ffi: + dependency: "direct main" + description: + name: ffi + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + file: + dependency: transitive + description: + name: file + url: "https://pub.dartlang.org" + source: hosted + version: "6.1.2" flutter: dependency: "direct main" description: flutter source: sdk version: "0.0.0" + flutter_driver: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" flutter_lints: dependency: "direct dev" description: @@ -74,6 +114,16 @@ packages: description: flutter source: sdk version: "0.0.0" + fuchsia_remote_debug_protocol: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + integration_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" jni: dependency: "direct main" description: @@ -109,6 +159,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.7.0" + package_config: + dependency: transitive + description: + name: package_config + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" path: dependency: transitive description: @@ -116,6 +173,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.1" + platform: + dependency: transitive + description: + name: platform + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.0" plugin_platform_interface: dependency: transitive description: @@ -123,6 +187,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.2" + process: + dependency: transitive + description: + name: process + url: "https://pub.dartlang.org" + source: hosted + version: "4.2.4" sky_engine: dependency: transitive description: flutter @@ -156,6 +227,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.0" + sync_http: + dependency: transitive + description: + name: sync_http + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.0" term_glyph: dependency: transitive description: @@ -170,6 +248,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.4.9" + typed_data: + dependency: transitive + description: + name: typed_data + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.0" vector_math: dependency: transitive description: @@ -177,6 +262,19 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.2" + vm_service: + dependency: transitive + description: + name: vm_service + url: "https://pub.dartlang.org" + source: hosted + version: "8.2.2" + webdriver: + dependency: transitive + description: + name: webdriver + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.0" sdks: dart: ">=2.17.5 <3.0.0" - flutter: ">=2.11.0" diff --git a/pkgs/jni/example/pubspec.yaml b/pkgs/jni/example/pubspec.yaml index 1569e63a1..1ff0ae2de 100644 --- a/pkgs/jni/example/pubspec.yaml +++ b/pkgs/jni/example/pubspec.yaml @@ -30,6 +30,8 @@ dependencies: flutter: sdk: flutter + ffi: ^2.0.0 + jni: # When depending on this package from a real application you should use: # jni: ^x.y.z @@ -45,6 +47,8 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter + integration_test: + sdk: flutter # The "flutter_lints" package below contains a set of recommended lints to # encourage good coding practices. The lint set provided by the package is diff --git a/pkgs/jni/example/test/widget_test.dart b/pkgs/jni/example/test/widget_test.dart new file mode 100644 index 000000000..c2336a068 --- /dev/null +++ b/pkgs/jni/example/test/widget_test.dart @@ -0,0 +1,43 @@ +import 'dart:io'; + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'package:jni/jni.dart'; +import 'package:jni/jni_object.dart'; +import 'package:jni_example/main.dart'; + +// This test exists just to verify that +// when everything is correct, JNI actually runs +// However it's also kind of meaningless, because test environment +// differs substantially from the device. + +void main() { + if (!Platform.isAndroid) { + Jni.spawn(helperDir: "../src/build"); + } + final jni = Jni.getInstance(); + testWidgets("simple toString example", (tester) async { + await tester.pumpWidget(ExampleForTest(ExampleCard(Example( + "toString", + () => jni.findJniClass("java/lang/Long").use((long) => long + .callStaticStringMethodByName( + "toHexString", "(J)Ljava/lang/String;", [0x1876])))))); + expect(find.text("1876"), findsOneWidget); + }); +} + +class ExampleForTest extends StatelessWidget { + const ExampleForTest(this.widget, {Key? key}) : super(key: key); + final Widget widget; + @override + Widget build(BuildContext context) { + return MaterialApp( + title: '__TEST__', + home: Scaffold( + appBar: AppBar(title: const Text("__test__")), + body: Center(child: widget), + ), + ); + } +} diff --git a/pkgs/jni/ffigen.yaml b/pkgs/jni/ffigen.yaml index 7626d28a8..f43903c57 100644 --- a/pkgs/jni/ffigen.yaml +++ b/pkgs/jni/ffigen.yaml @@ -1,19 +1,113 @@ # Run with `dart run ffigen --config ffigen.yaml`. name: JniBindings description: | - Bindings for `src/jni.h`. + Bindings for libdartjni.so which is part of jni plugin. - Regenerate bindings with `dart run ffigen --config ffigen.yaml`. -output: 'lib/jni_bindings_generated.dart' + It also transitively includes type definitions such as JNIEnv from third_party/jni.h; + + However, functions prefixed JNI_ are not usable because they are in a different shared library. + + Regenerate bindings with `flutter pub run ffigen.dart --config ffigen.yaml`. +output: 'lib/src/third_party/jni_bindings_generated.dart' headers: entry-points: - - 'src/jni.h' + - 'src/dartjni.h' include-directives: - - 'src/jni.h' + - 'src/dartjni.h' + - 'third_party/jni.h' +compiler-opts: + - '-Ithird_party/' +functions: + exclude: # Exclude init functions supposed to be defined in loaded DLL, not JNI + - 'JNI_OnLoad' + - 'JNI_OnUnload' + - 'JNI_OnLoad_L' + - 'JNI_OnUnload_L' +structs: + exclude: + - 'jni_context' + rename: + ## opaque struct definitions, base types of jfieldID and jmethodID + '_jfieldID': 'jfieldID_' + '_jmethodID': 'jmethodID_' + #'JNI(.*)': 'Jni$1' +unions: + rename: + 'jvalue': 'JValue' +enums: + rename: + 'DartJniLogLevel': 'JniLogLevel' +globals: + exclude: + - 'jni' + - 'jniEnv' +typedefs: + rename: + 'JNI(.*)': 'Jni$1' + 'jint': 'JInt' + 'jclass': 'JClass' + 'jobject': 'JObject' + 'jbyte': 'JByte' + 'jsize': 'JSize' + 'jmethodID': 'JMethodID' + 'jfieldID': 'JFieldID' + 'jboolean': 'JBoolean' + 'jthrowable': 'JThrowable' + 'jchar': 'JChar' + 'jshort': 'JShort' + 'jlong': 'JLong' + 'jfloat': 'JFloat' + 'jdouble': 'JDouble' + 'jstring': 'JString' + 'jarray': 'JArray' + 'jobjectArray': 'JObjectArray' + 'jbooleanArray': 'JBooleanArray' + 'jbyteArray': 'JByteArray' + 'jcharArray': 'JCharArray' + 'jshortArray': 'JShortArray' + 'jintArray': 'JIntArray' + 'jlongArray': 'JLongArray' + 'jfloatArray': 'JFloatArray' + 'jdoubleArray': 'JDoubleArray' + 'jweak': 'JWeak' + 'jvalue': 'JValue' preamble: | + // Autogenerated file. Do not edit. + // Generated from an annotated version of jni.h provided in Android NDK + // (NDK Version 23.1.7779620) + // The license for original file is provided below: + + /* + * Copyright (C) 2006 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + /* + * JNI specification, as defined by Sun: + * http://java.sun.com/javase/6/docs/technotes/guides/jni/spec/jniTOC.html + * + * Everything here is expected to be VM-neutral. + */ + // ignore_for_file: always_specify_types // ignore_for_file: camel_case_types // ignore_for_file: non_constant_identifier_names + // ignore_for_file: constant_identifier_names + // ignore_for_file: unused_field + // ignore_for_file: unused_element + // coverage:ignore-file comments: style: any length: full + diff --git a/pkgs/jni/lib/jni.dart b/pkgs/jni/lib/jni.dart index f9a759f1d..b604a5bae 100644 --- a/pkgs/jni/lib/jni.dart +++ b/pkgs/jni/lib/jni.dart @@ -1,131 +1,66 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. -import 'dart:async'; -import 'dart:ffi'; -import 'dart:io'; -import 'dart:isolate'; - -import 'jni_bindings_generated.dart'; - -/// A very short-lived native function. +/// Package jni provides dart bindings for the Java Native Interface (JNI) on +/// Android and desktop platforms. /// -/// For very short-lived functions, it is fine to call them on the main isolate. -/// They will block the Dart execution while running the native function, so -/// only do this for native functions which are guaranteed to be short-lived. -int sum(int a, int b) => _bindings.sum(a, b); - -/// A longer lived native function, which occupies the thread calling it. +/// It's intended as a supplement to the (planned) jnigen tool, a Java wrapper +/// generator using JNI. The goal is to provide sufficiently complete +/// and ergonomic access to underlying JNI APIs. /// -/// Do not call these kind of native functions in the main isolate. They will -/// block Dart execution. This will cause dropped frames in Flutter applications. -/// Instead, call these native functions on a separate isolate. +/// Therefore, some understanding of JNI is required to use this module. /// -/// Modify this to suit your own use case. Example use cases: +/// __Java VM:__ +/// On Android, the existing JVM is used, a new JVM needs to be spawned on +/// flutter desktop & standalone targets. /// -/// 1. Reuse a single isolate for various different kinds of requests. -/// 2. Use multiple helper isolates for parallel execution. -Future sumAsync(int a, int b) async { - final SendPort helperIsolateSendPort = await _helperIsolateSendPort; - final int requestId = _nextSumRequestId++; - final _SumRequest request = _SumRequest(requestId, a, b); - final Completer completer = Completer(); - _sumRequests[requestId] = completer; - helperIsolateSendPort.send(request); - return completer.future; -} - -const String _libName = 'jni'; - -/// The dynamic library in which the symbols for [JniBindings] can be found. -final DynamicLibrary _dylib = () { - if (Platform.isMacOS || Platform.isIOS) { - return DynamicLibrary.open('$_libName.framework/$_libName'); - } - if (Platform.isAndroid || Platform.isLinux) { - return DynamicLibrary.open('lib$_libName.so'); - } - if (Platform.isWindows) { - return DynamicLibrary.open('$_libName.dll'); - } - throw UnsupportedError('Unknown platform: ${Platform.operatingSystem}'); -}(); - -/// The bindings to the native functions in [_dylib]. -final JniBindings _bindings = JniBindings(_dylib); - - -/// A request to compute `sum`. +/// ```dart +/// if (!Platform.isAndroid) { +/// // Spin up a JVM instance with custom classpath etc.. +/// Jni.spawn(/* options */); +/// } +/// Jni jni = Jni.getInstance(); +/// ``` /// -/// Typically sent from one isolate to another. -class _SumRequest { - final int id; - final int a; - final int b; - - const _SumRequest(this.id, this.a, this.b); -} - -/// A response with the result of `sum`. +/// __Dart standalone support:__ +/// On dart standalone target, we unfortunately have no mechanism to bundle +/// the wrapper libraries with the executable. Thus it needs to be explicitly +/// placed in a accessible directory and provided as an argument to Jni.spawn. +/// +/// This module depends on a shared library written in C. Therefore on dart +/// standalone: +/// +/// * Build the library `libdartjni.so` in src/ directory of this plugin. +/// * Bundle it appropriately with dart application. +/// * Pass the path to library as a parameter to `Jni.spawn()`. +/// +/// __JNIEnv:__ +/// The types `JNIEnv` and `JavaVM` in JNI are available as `JniEnv` and +/// `JavaVM` respectively, with extension methods to conveniently invoke the +/// function pointer members. Therefore the calling syntax will be similar to +/// JNI in C++. The first `JniEnv *` parameter is implicit. +/// +/// __Debugging__: +/// Debugging JNI errors hard in general. +/// +/// * On desktop platforms you can use JniEnv.ExceptionDescribe to print any +/// pending exception to stdout. +/// * On Android, things are slightly easier since CheckJNI is usually enabled +/// in debug builds. If you are not getting clear stack traces on JNI errors, +/// check the Android NDK page on how to enable CheckJNI using ADB. +/// * As a rule of thumb, when there's a NoClassDefFound / NoMethodFound error, +/// first check your class and method signatures for typos. /// -/// Typically sent from one isolate to another. -class _SumResponse { - final int id; - final int result; - - const _SumResponse(this.id, this.result); -} - -/// Counter to identify [_SumRequest]s and [_SumResponse]s. -int _nextSumRequestId = 0; - -/// Mapping from [_SumRequest] `id`s to the completers corresponding to the correct future of the pending request. -final Map> _sumRequests = >{}; - -/// The SendPort belonging to the helper isolate. -Future _helperIsolateSendPort = () async { - // The helper isolate is going to send us back a SendPort, which we want to - // wait for. - final Completer completer = Completer(); - - // Receive port on the main isolate to receive messages from the helper. - // We receive two types of messages: - // 1. A port to send messages on. - // 2. Responses to requests we sent. - final ReceivePort receivePort = ReceivePort() - ..listen((dynamic data) { - if (data is SendPort) { - // The helper isolate sent us the port on which we can sent it requests. - completer.complete(data); - return; - } - if (data is _SumResponse) { - // The helper isolate sent us a response to a request we sent. - final Completer completer = _sumRequests[data.id]!; - _sumRequests.remove(data.id); - completer.complete(data.result); - return; - } - throw UnsupportedError('Unsupported message type: ${data.runtimeType}'); - }); - - // Start the helper isolate. - await Isolate.spawn((SendPort sendPort) async { - final ReceivePort helperReceivePort = ReceivePort() - ..listen((dynamic data) { - // On the helper isolate listen to requests and respond to them. - if (data is _SumRequest) { - final int result = _bindings.sum_long_running(data.a, data.b); - final _SumResponse response = _SumResponse(data.id, result); - sendPort.send(response); - return; - } - throw UnsupportedError('Unsupported message type: ${data.runtimeType}'); - }); - - // Send the the port to the main isolate on which we can receive requests. - sendPort.send(helperReceivePort.sendPort); - }, receivePort.sendPort); - // Wait until the helper isolate has sent us back the SendPort on which we - // can start sending requests. - return completer.future; -}(); +/// This file exports the minimum foundations of JNI. +/// +/// For a higher level API, import `'package:jni/jni_object.dart'`. +library jni; + +export 'src/third_party/jni_bindings_generated.dart' hide JNI_LOG_TAG; +export 'src/jni.dart'; +export 'src/jvalues.dart' hide JValueArgs, toJValues; +export 'src/extensions.dart' + show StringMethodsForJni, CharPtrMethodsForJni, AdditionalJniEnvMethods; +export 'src/jni_exceptions.dart'; diff --git a/pkgs/jni/lib/jni_bindings_generated.dart b/pkgs/jni/lib/jni_bindings_generated.dart deleted file mode 100644 index 1ec49c942..000000000 --- a/pkgs/jni/lib/jni_bindings_generated.dart +++ /dev/null @@ -1,69 +0,0 @@ -// ignore_for_file: always_specify_types -// ignore_for_file: camel_case_types -// ignore_for_file: non_constant_identifier_names - -// AUTO GENERATED FILE, DO NOT EDIT. -// -// Generated by `package:ffigen`. -import 'dart:ffi' as ffi; - -/// Bindings for `src/jni.h`. -/// -/// Regenerate bindings with `dart run ffigen --config ffigen.yaml`. -/// -class JniBindings { - /// Holds the symbol lookup function. - final ffi.Pointer Function(String symbolName) - _lookup; - - /// The symbols are looked up in [dynamicLibrary]. - JniBindings(ffi.DynamicLibrary dynamicLibrary) - : _lookup = dynamicLibrary.lookup; - - /// The symbols are looked up with [lookup]. - JniBindings.fromLookup( - ffi.Pointer Function(String symbolName) - lookup) - : _lookup = lookup; - - /// A very short-lived native function. - /// - /// For very short-lived functions, it is fine to call them on the main isolate. - /// They will block the Dart execution while running the native function, so - /// only do this for native functions which are guaranteed to be short-lived. - int sum( - int a, - int b, - ) { - return _sum( - a, - b, - ); - } - - late final _sumPtr = - _lookup>( - 'sum'); - late final _sum = _sumPtr.asFunction(); - - /// A longer lived native function, which occupies the thread calling it. - /// - /// Calling these kind of native functions in the main isolate will - /// block Dart execution and cause dropped frames in Flutter applications. - /// Consider calling such native functions from a separate isolate. - int sum_long_running( - int a, - int b, - ) { - return _sum_long_running( - a, - b, - ); - } - - late final _sum_long_runningPtr = - _lookup>( - 'sum_long_running'); - late final _sum_long_running = - _sum_long_runningPtr.asFunction(); -} diff --git a/pkgs/jni/lib/jni_object.dart b/pkgs/jni/lib/jni_object.dart new file mode 100644 index 000000000..f12a8fd53 --- /dev/null +++ b/pkgs/jni/lib/jni_object.dart @@ -0,0 +1,14 @@ +/// jni_object library provides an easier interface to JNI's object references, +/// providing various helper methods for one-off uses. +/// +/// It consists of generated methods to access java objects and call functions +/// on them, abstracting away most error checking and string conversions etc.. +/// +/// The important types are JniClass and JniObject, which are high level +/// wrappers around JClass and JObject. +/// +/// Import this library along with `jni.dart`. +library jni_object; + +export 'src/jni_class.dart'; +export 'src/jni_object.dart'; diff --git a/pkgs/jni/lib/src/direct_methods_generated.dart b/pkgs/jni/lib/src/direct_methods_generated.dart new file mode 100644 index 000000000..fc04c0f69 --- /dev/null +++ b/pkgs/jni/lib/src/direct_methods_generated.dart @@ -0,0 +1,630 @@ +// Autogenerated; DO NOT EDIT +// Generated by running the script in tool/gen_aux_methods.dart +// coverage:ignore-file +part of 'jni.dart'; + +extension JniInvokeMethods on Jni { + String invokeStringMethod(String className, String methodName, + String signature, List args) { + return using((Arena arena) { + final env = getEnv(); + final classNameChars = className.toNativeChars(arena); + final methodNameChars = methodName.toNativeChars(arena); + final signatureChars = signature.toNativeChars(arena); + final cls = _bindings.LoadClass(classNameChars); + if (cls == nullptr) { + env.checkException(); + } + final methodID = + env.GetStaticMethodID(cls, methodNameChars, signatureChars); + if (methodID == nullptr) { + try { + env.checkException(); + } catch (e) { + env.DeleteLocalRef(cls); + rethrow; + } + } + final jvArgs = JValueArgs(args, env, arena); + final result = env.CallStaticObjectMethodA(cls, methodID, jvArgs.values); + jvArgs.disposeIn(env); + + final strRes = env.asDartString(result, deleteOriginal: true); + env.checkException(); + return strRes; + }); + } + + String retrieveStringField( + String className, String fieldName, String signature) { + return using((Arena arena) { + final arena = Arena(); + final env = getEnv(); + final classNameChars = className.toNativeChars(arena); + final fieldNameChars = fieldName.toNativeChars(arena); + final signatueChars = signature.toNativeChars(arena); + final cls = _bindings.LoadClass(classNameChars); + if (cls == nullptr) { + env.checkException(); + } + final fieldID = env.GetStaticFieldID(cls, fieldNameChars, signatueChars); + if (fieldID == nullptr) { + try { + env.checkException(); + } catch (e) { + env.DeleteLocalRef(cls); + rethrow; + } + } + final result = env.GetStaticObjectField(cls, fieldID); + + final strRes = env.asDartString(result, deleteOriginal: true); + env.checkException(); + return strRes; + }); + } + + JniObject invokeObjectMethod(String className, String methodName, + String signature, List args) { + return using((Arena arena) { + final env = getEnv(); + final classNameChars = className.toNativeChars(arena); + final methodNameChars = methodName.toNativeChars(arena); + final signatureChars = signature.toNativeChars(arena); + final cls = _bindings.LoadClass(classNameChars); + if (cls == nullptr) { + env.checkException(); + } + final methodID = + env.GetStaticMethodID(cls, methodNameChars, signatureChars); + if (methodID == nullptr) { + try { + env.checkException(); + } catch (e) { + env.DeleteLocalRef(cls); + rethrow; + } + } + final jvArgs = JValueArgs(args, env, arena); + final result = env.CallStaticObjectMethodA(cls, methodID, jvArgs.values); + jvArgs.disposeIn(env); + + env.checkException(); + return JniObject.of(env, result, nullptr); + }); + } + + JniObject retrieveObjectField( + String className, String fieldName, String signature) { + return using((Arena arena) { + final arena = Arena(); + final env = getEnv(); + final classNameChars = className.toNativeChars(arena); + final fieldNameChars = fieldName.toNativeChars(arena); + final signatueChars = signature.toNativeChars(arena); + final cls = _bindings.LoadClass(classNameChars); + if (cls == nullptr) { + env.checkException(); + } + final fieldID = env.GetStaticFieldID(cls, fieldNameChars, signatueChars); + if (fieldID == nullptr) { + try { + env.checkException(); + } catch (e) { + env.DeleteLocalRef(cls); + rethrow; + } + } + final result = env.GetStaticObjectField(cls, fieldID); + + env.checkException(); + return JniObject.of(env, result, nullptr); + }); + } + + bool invokeBooleanMethod(String className, String methodName, + String signature, List args) { + return using((Arena arena) { + final env = getEnv(); + final classNameChars = className.toNativeChars(arena); + final methodNameChars = methodName.toNativeChars(arena); + final signatureChars = signature.toNativeChars(arena); + final cls = _bindings.LoadClass(classNameChars); + if (cls == nullptr) { + env.checkException(); + } + final methodID = + env.GetStaticMethodID(cls, methodNameChars, signatureChars); + if (methodID == nullptr) { + try { + env.checkException(); + } catch (e) { + env.DeleteLocalRef(cls); + rethrow; + } + } + final jvArgs = JValueArgs(args, env, arena); + final result = env.CallStaticBooleanMethodA(cls, methodID, jvArgs.values); + jvArgs.disposeIn(env); + env.DeleteLocalRef(cls); + + env.checkException(); + return result != 0; + }); + } + + bool retrieveBooleanField( + String className, String fieldName, String signature) { + return using((Arena arena) { + final arena = Arena(); + final env = getEnv(); + final classNameChars = className.toNativeChars(arena); + final fieldNameChars = fieldName.toNativeChars(arena); + final signatueChars = signature.toNativeChars(arena); + final cls = _bindings.LoadClass(classNameChars); + if (cls == nullptr) { + env.checkException(); + } + final fieldID = env.GetStaticFieldID(cls, fieldNameChars, signatueChars); + if (fieldID == nullptr) { + try { + env.checkException(); + } catch (e) { + env.DeleteLocalRef(cls); + rethrow; + } + } + final result = env.GetStaticBooleanField(cls, fieldID); + env.DeleteLocalRef(cls); + + env.checkException(); + return result != 0; + }); + } + + int invokeByteMethod(String className, String methodName, String signature, + List args) { + return using((Arena arena) { + final env = getEnv(); + final classNameChars = className.toNativeChars(arena); + final methodNameChars = methodName.toNativeChars(arena); + final signatureChars = signature.toNativeChars(arena); + final cls = _bindings.LoadClass(classNameChars); + if (cls == nullptr) { + env.checkException(); + } + final methodID = + env.GetStaticMethodID(cls, methodNameChars, signatureChars); + if (methodID == nullptr) { + try { + env.checkException(); + } catch (e) { + env.DeleteLocalRef(cls); + rethrow; + } + } + final jvArgs = JValueArgs(args, env, arena); + final result = env.CallStaticByteMethodA(cls, methodID, jvArgs.values); + jvArgs.disposeIn(env); + env.DeleteLocalRef(cls); + + env.checkException(); + return result; + }); + } + + int retrieveByteField(String className, String fieldName, String signature) { + return using((Arena arena) { + final arena = Arena(); + final env = getEnv(); + final classNameChars = className.toNativeChars(arena); + final fieldNameChars = fieldName.toNativeChars(arena); + final signatueChars = signature.toNativeChars(arena); + final cls = _bindings.LoadClass(classNameChars); + if (cls == nullptr) { + env.checkException(); + } + final fieldID = env.GetStaticFieldID(cls, fieldNameChars, signatueChars); + if (fieldID == nullptr) { + try { + env.checkException(); + } catch (e) { + env.DeleteLocalRef(cls); + rethrow; + } + } + final result = env.GetStaticByteField(cls, fieldID); + env.DeleteLocalRef(cls); + + env.checkException(); + return result; + }); + } + + int invokeCharMethod(String className, String methodName, String signature, + List args) { + return using((Arena arena) { + final env = getEnv(); + final classNameChars = className.toNativeChars(arena); + final methodNameChars = methodName.toNativeChars(arena); + final signatureChars = signature.toNativeChars(arena); + final cls = _bindings.LoadClass(classNameChars); + if (cls == nullptr) { + env.checkException(); + } + final methodID = + env.GetStaticMethodID(cls, methodNameChars, signatureChars); + if (methodID == nullptr) { + try { + env.checkException(); + } catch (e) { + env.DeleteLocalRef(cls); + rethrow; + } + } + final jvArgs = JValueArgs(args, env, arena); + final result = env.CallStaticCharMethodA(cls, methodID, jvArgs.values); + jvArgs.disposeIn(env); + env.DeleteLocalRef(cls); + + env.checkException(); + return result; + }); + } + + int retrieveCharField(String className, String fieldName, String signature) { + return using((Arena arena) { + final arena = Arena(); + final env = getEnv(); + final classNameChars = className.toNativeChars(arena); + final fieldNameChars = fieldName.toNativeChars(arena); + final signatueChars = signature.toNativeChars(arena); + final cls = _bindings.LoadClass(classNameChars); + if (cls == nullptr) { + env.checkException(); + } + final fieldID = env.GetStaticFieldID(cls, fieldNameChars, signatueChars); + if (fieldID == nullptr) { + try { + env.checkException(); + } catch (e) { + env.DeleteLocalRef(cls); + rethrow; + } + } + final result = env.GetStaticCharField(cls, fieldID); + env.DeleteLocalRef(cls); + + env.checkException(); + return result; + }); + } + + int invokeShortMethod(String className, String methodName, String signature, + List args) { + return using((Arena arena) { + final env = getEnv(); + final classNameChars = className.toNativeChars(arena); + final methodNameChars = methodName.toNativeChars(arena); + final signatureChars = signature.toNativeChars(arena); + final cls = _bindings.LoadClass(classNameChars); + if (cls == nullptr) { + env.checkException(); + } + final methodID = + env.GetStaticMethodID(cls, methodNameChars, signatureChars); + if (methodID == nullptr) { + try { + env.checkException(); + } catch (e) { + env.DeleteLocalRef(cls); + rethrow; + } + } + final jvArgs = JValueArgs(args, env, arena); + final result = env.CallStaticShortMethodA(cls, methodID, jvArgs.values); + jvArgs.disposeIn(env); + env.DeleteLocalRef(cls); + + env.checkException(); + return result; + }); + } + + int retrieveShortField(String className, String fieldName, String signature) { + return using((Arena arena) { + final arena = Arena(); + final env = getEnv(); + final classNameChars = className.toNativeChars(arena); + final fieldNameChars = fieldName.toNativeChars(arena); + final signatueChars = signature.toNativeChars(arena); + final cls = _bindings.LoadClass(classNameChars); + if (cls == nullptr) { + env.checkException(); + } + final fieldID = env.GetStaticFieldID(cls, fieldNameChars, signatueChars); + if (fieldID == nullptr) { + try { + env.checkException(); + } catch (e) { + env.DeleteLocalRef(cls); + rethrow; + } + } + final result = env.GetStaticShortField(cls, fieldID); + env.DeleteLocalRef(cls); + + env.checkException(); + return result; + }); + } + + int invokeIntMethod(String className, String methodName, String signature, + List args) { + return using((Arena arena) { + final env = getEnv(); + final classNameChars = className.toNativeChars(arena); + final methodNameChars = methodName.toNativeChars(arena); + final signatureChars = signature.toNativeChars(arena); + final cls = _bindings.LoadClass(classNameChars); + if (cls == nullptr) { + env.checkException(); + } + final methodID = + env.GetStaticMethodID(cls, methodNameChars, signatureChars); + if (methodID == nullptr) { + try { + env.checkException(); + } catch (e) { + env.DeleteLocalRef(cls); + rethrow; + } + } + final jvArgs = JValueArgs(args, env, arena); + final result = env.CallStaticIntMethodA(cls, methodID, jvArgs.values); + jvArgs.disposeIn(env); + env.DeleteLocalRef(cls); + + env.checkException(); + return result; + }); + } + + int retrieveIntField(String className, String fieldName, String signature) { + return using((Arena arena) { + final arena = Arena(); + final env = getEnv(); + final classNameChars = className.toNativeChars(arena); + final fieldNameChars = fieldName.toNativeChars(arena); + final signatueChars = signature.toNativeChars(arena); + final cls = _bindings.LoadClass(classNameChars); + if (cls == nullptr) { + env.checkException(); + } + final fieldID = env.GetStaticFieldID(cls, fieldNameChars, signatueChars); + if (fieldID == nullptr) { + try { + env.checkException(); + } catch (e) { + env.DeleteLocalRef(cls); + rethrow; + } + } + final result = env.GetStaticIntField(cls, fieldID); + env.DeleteLocalRef(cls); + + env.checkException(); + return result; + }); + } + + int invokeLongMethod(String className, String methodName, String signature, + List args) { + return using((Arena arena) { + final env = getEnv(); + final classNameChars = className.toNativeChars(arena); + final methodNameChars = methodName.toNativeChars(arena); + final signatureChars = signature.toNativeChars(arena); + final cls = _bindings.LoadClass(classNameChars); + if (cls == nullptr) { + env.checkException(); + } + final methodID = + env.GetStaticMethodID(cls, methodNameChars, signatureChars); + if (methodID == nullptr) { + try { + env.checkException(); + } catch (e) { + env.DeleteLocalRef(cls); + rethrow; + } + } + final jvArgs = JValueArgs(args, env, arena); + final result = env.CallStaticLongMethodA(cls, methodID, jvArgs.values); + jvArgs.disposeIn(env); + env.DeleteLocalRef(cls); + + env.checkException(); + return result; + }); + } + + int retrieveLongField(String className, String fieldName, String signature) { + return using((Arena arena) { + final arena = Arena(); + final env = getEnv(); + final classNameChars = className.toNativeChars(arena); + final fieldNameChars = fieldName.toNativeChars(arena); + final signatueChars = signature.toNativeChars(arena); + final cls = _bindings.LoadClass(classNameChars); + if (cls == nullptr) { + env.checkException(); + } + final fieldID = env.GetStaticFieldID(cls, fieldNameChars, signatueChars); + if (fieldID == nullptr) { + try { + env.checkException(); + } catch (e) { + env.DeleteLocalRef(cls); + rethrow; + } + } + final result = env.GetStaticLongField(cls, fieldID); + env.DeleteLocalRef(cls); + + env.checkException(); + return result; + }); + } + + double invokeFloatMethod(String className, String methodName, + String signature, List args) { + return using((Arena arena) { + final env = getEnv(); + final classNameChars = className.toNativeChars(arena); + final methodNameChars = methodName.toNativeChars(arena); + final signatureChars = signature.toNativeChars(arena); + final cls = _bindings.LoadClass(classNameChars); + if (cls == nullptr) { + env.checkException(); + } + final methodID = + env.GetStaticMethodID(cls, methodNameChars, signatureChars); + if (methodID == nullptr) { + try { + env.checkException(); + } catch (e) { + env.DeleteLocalRef(cls); + rethrow; + } + } + final jvArgs = JValueArgs(args, env, arena); + final result = env.CallStaticFloatMethodA(cls, methodID, jvArgs.values); + jvArgs.disposeIn(env); + env.DeleteLocalRef(cls); + + env.checkException(); + return result; + }); + } + + double retrieveFloatField( + String className, String fieldName, String signature) { + return using((Arena arena) { + final arena = Arena(); + final env = getEnv(); + final classNameChars = className.toNativeChars(arena); + final fieldNameChars = fieldName.toNativeChars(arena); + final signatueChars = signature.toNativeChars(arena); + final cls = _bindings.LoadClass(classNameChars); + if (cls == nullptr) { + env.checkException(); + } + final fieldID = env.GetStaticFieldID(cls, fieldNameChars, signatueChars); + if (fieldID == nullptr) { + try { + env.checkException(); + } catch (e) { + env.DeleteLocalRef(cls); + rethrow; + } + } + final result = env.GetStaticFloatField(cls, fieldID); + env.DeleteLocalRef(cls); + + env.checkException(); + return result; + }); + } + + double invokeDoubleMethod(String className, String methodName, + String signature, List args) { + return using((Arena arena) { + final env = getEnv(); + final classNameChars = className.toNativeChars(arena); + final methodNameChars = methodName.toNativeChars(arena); + final signatureChars = signature.toNativeChars(arena); + final cls = _bindings.LoadClass(classNameChars); + if (cls == nullptr) { + env.checkException(); + } + final methodID = + env.GetStaticMethodID(cls, methodNameChars, signatureChars); + if (methodID == nullptr) { + try { + env.checkException(); + } catch (e) { + env.DeleteLocalRef(cls); + rethrow; + } + } + final jvArgs = JValueArgs(args, env, arena); + final result = env.CallStaticDoubleMethodA(cls, methodID, jvArgs.values); + jvArgs.disposeIn(env); + env.DeleteLocalRef(cls); + + env.checkException(); + return result; + }); + } + + double retrieveDoubleField( + String className, String fieldName, String signature) { + return using((Arena arena) { + final arena = Arena(); + final env = getEnv(); + final classNameChars = className.toNativeChars(arena); + final fieldNameChars = fieldName.toNativeChars(arena); + final signatueChars = signature.toNativeChars(arena); + final cls = _bindings.LoadClass(classNameChars); + if (cls == nullptr) { + env.checkException(); + } + final fieldID = env.GetStaticFieldID(cls, fieldNameChars, signatueChars); + if (fieldID == nullptr) { + try { + env.checkException(); + } catch (e) { + env.DeleteLocalRef(cls); + rethrow; + } + } + final result = env.GetStaticDoubleField(cls, fieldID); + env.DeleteLocalRef(cls); + + env.checkException(); + return result; + }); + } + + void invokeVoidMethod(String className, String methodName, String signature, + List args) { + return using((Arena arena) { + final env = getEnv(); + final classNameChars = className.toNativeChars(arena); + final methodNameChars = methodName.toNativeChars(arena); + final signatureChars = signature.toNativeChars(arena); + final cls = _bindings.LoadClass(classNameChars); + if (cls == nullptr) { + env.checkException(); + } + final methodID = + env.GetStaticMethodID(cls, methodNameChars, signatureChars); + if (methodID == nullptr) { + try { + env.checkException(); + } catch (e) { + env.DeleteLocalRef(cls); + rethrow; + } + } + final jvArgs = JValueArgs(args, env, arena); + final result = env.CallStaticVoidMethodA(cls, methodID, jvArgs.values); + jvArgs.disposeIn(env); + env.DeleteLocalRef(cls); + + env.checkException(); + return result; + }); + } +} diff --git a/pkgs/jni/lib/src/extensions.dart b/pkgs/jni/lib/src/extensions.dart new file mode 100644 index 000000000..d749e3e2e --- /dev/null +++ b/pkgs/jni/lib/src/extensions.dart @@ -0,0 +1,97 @@ +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; + +import 'third_party/jni_bindings_generated.dart'; + +import 'jni_exceptions.dart'; + +extension StringMethodsForJni on String { + /// Returns a Utf-8 encoded Pointer with contents same as this string. + Pointer toNativeChars([Allocator allocator = malloc]) { + return toNativeUtf8(allocator: allocator).cast(); + } +} + +extension CharPtrMethodsForJni on Pointer { + /// Same as calling `cast` followed by `toDartString`. + String toDartString() { + return cast().toDartString(); + } +} + +extension AdditionalJniEnvMethods on Pointer { + /// Convenience method for converting a [JString] + /// to dart string. + /// if [deleteOriginal] is specified, jstring passed will be deleted using + /// DeleteLocalRef. + String asDartString(JString jstring, {bool deleteOriginal = false}) { + final chars = GetStringUTFChars(jstring, nullptr); + if (chars == nullptr) { + checkException(); + } + final result = chars.cast().toDartString(); + ReleaseStringUTFChars(jstring, chars); + if (deleteOriginal) { + DeleteLocalRef(jstring); + } + return result; + } + + /// Return a new [JString] from contents of [s]. + JString asJString(String s) { + final utf = s.toNativeUtf8().cast(); + final result = NewStringUTF(utf); + malloc.free(utf); + return result; + } + + /// Deletes all local references in [refs]. + void deleteAllLocalRefs(List refs) { + for (final ref in refs) { + DeleteLocalRef(ref); + } + } + + /// If any exception is pending in JNI, throw it in Dart. + /// + /// If [describe] is true, a description is printed to screen. + /// To access actual exception object, use `ExceptionOccurred`. + void checkException({bool describe = false}) { + final exc = ExceptionOccurred(); + if (exc != nullptr) { + // TODO: Doing this every time is expensive. + // Should lookup and cache method reference, + // and keep it alive by keeping a reference to Exception class. + // IssueRef: https://github.com/dart-lang/jni_gen/issues/13 + final ecls = GetObjectClass(exc); + final toStr = GetMethodID(ecls, _toString, _toStringSig); + final jstr = CallObjectMethod(exc, toStr); + final dstr = asDartString(jstr); + for (final i in [jstr, ecls]) { + DeleteLocalRef(i); + } + if (describe) { + ExceptionDescribe(); + } else { + ExceptionClear(); + } + throw JniException(exc, dstr); + } + } + + /// Calls the printStackTrace on exception object + /// obtained by java + void printStackTrace(JniException je) { + final ecls = GetObjectClass(je.err); + final printStackTrace = + GetMethodID(ecls, _printStackTrace, _printStackTraceSig); + CallVoidMethod(je.err, printStackTrace); + DeleteLocalRef(ecls); + } +} + +final _toString = "toString".toNativeChars(); +final _toStringSig = "()Ljava/lang/String;".toNativeChars(); +final _printStackTrace = "printStackTrace".toNativeChars(); +final _printStackTraceSig = "()V".toNativeChars(); diff --git a/pkgs/jni/lib/src/jni.dart b/pkgs/jni/lib/src/jni.dart new file mode 100644 index 000000000..beac5f784 --- /dev/null +++ b/pkgs/jni/lib/src/jni.dart @@ -0,0 +1,269 @@ +import 'dart:ffi'; +import 'dart:io'; + +import 'package:ffi/ffi.dart'; +import 'package:path/path.dart'; + +import 'third_party/jni_bindings_generated.dart'; +import 'extensions.dart'; +import 'jvalues.dart'; +import 'jni_exceptions.dart'; + +import 'jni_object.dart'; +import 'jni_class.dart'; + +part 'direct_methods_generated.dart'; + +String _getLibraryFileName(String base) { + if (Platform.isLinux || Platform.isAndroid) { + return "lib$base.so"; + } else if (Platform.isWindows) { + return "$base.dll"; + } else if (Platform.isMacOS) { + return "$base.framework/$base"; + } else { + throw UnsupportedError("cannot derive library name: unsupported platform"); + } +} + +/// Load Dart-JNI Helper library. +/// +/// If path is provided, it's used to load the library. +/// Else just the platform-specific filename is passed to DynamicLibrary.open +DynamicLibrary _loadJniHelpersLibrary( + {String? dir, String baseName = "dartjni"}) { + final fileName = _getLibraryFileName(baseName); + final libPath = (dir != null) ? join(dir, fileName) : fileName; + try { + final dylib = DynamicLibrary.open(libPath); + return dylib; + } on Error { + throw HelperNotFoundException(libPath); + } +} + +/// Jni represents a single running JNI instance. +/// +/// It provides convenience functions for looking up and invoking functions +/// without several FFI conversions. +/// +/// You can also get access to instance of underlying JavaVM and JniEnv, and +/// then use them in a way similar to JNI C++ API. +class Jni { + final JniBindings _bindings; + + Jni._(this._bindings); + + static Jni? _instance; + + /// Returns the existing Jni object. + /// + /// If not running on Android and no Jni is spawned + /// using Jni.spawn(), throws an exception. + /// + /// On Dart standalone, when calling for the first time from + /// a new isolate, make sure to pass the library path. + static Jni getInstance() { + if (_instance == null) { + final inst = Jni._(JniBindings(_loadJniHelpersLibrary())); + if (inst.getJavaVM() == nullptr) { + throw StateError("Fatal: No JVM associated with this process!" + " Did you call Jni.spawn?"); + } + // If no error, save this singleton. + _instance = inst; + } + return _instance!; + } + + /// Initialize instance from custom helper library path. + /// + /// On dart standalone, call this in new isolate before + /// doing getInstance(). + /// + /// (The reason is that dylibs need to be loaded in every isolate. + /// On flutter it's done by library. On dart standalone we don't + /// know the library path.) + static void load({required String helperDir}) { + if (_instance != null) { + throw StateError('Fatal: a JNI instance already exists in this isolate'); + } + final inst = Jni._(JniBindings(_loadJniHelpersLibrary(dir: helperDir))); + if (inst.getJavaVM() == nullptr) { + throw StateError("Fatal: No JVM associated with this process"); + } + _instance = inst; + } + + /// Spawn an instance of JVM using JNI. + /// This instance will be returned by future calls to [getInstance] + /// + /// [helperDir] is path of the directory where the wrapper library is found. + /// This parameter needs to be passed manually on __Dart standalone target__, + /// since we have no reliable way to bundle it with the package. + /// + /// [jvmOptions], [ignoreUnrecognized], & [jniVersion] are passed to the JVM. + /// Strings in [classPath], if any, are used to construct an additional + /// JVM option of the form "-Djava.class.path={paths}". + static Jni spawn({ + String? helperDir, + int logLevel = JniLogLevel.JNI_INFO, + List jvmOptions = const [], + List classPath = const [], + bool ignoreUnrecognized = false, + int jniVersion = JNI_VERSION_1_6, + }) { + if (_instance != null) { + throw UnsupportedError("Currently only 1 VM is supported."); + } + final dylib = _loadJniHelpersLibrary(dir: helperDir); + final inst = Jni._(JniBindings(dylib)); + _instance = inst; + inst._bindings.SetJNILogging(logLevel); + final jArgs = _createVMArgs( + options: jvmOptions, + classPath: classPath, + version: jniVersion, + ignoreUnrecognized: ignoreUnrecognized, + ); + inst._bindings.SpawnJvm(jArgs); + _freeVMArgs(jArgs); + return inst; + } + + static Pointer _createVMArgs({ + List options = const [], + List classPath = const [], + bool ignoreUnrecognized = false, + int version = JNI_VERSION_1_6, + }) { + final args = calloc(); + if (options.isNotEmpty || classPath.isNotEmpty) { + final count = options.length + (classPath.isNotEmpty ? 1 : 0); + + final optsPtr = (count != 0) ? calloc(count) : nullptr; + args.ref.options = optsPtr; + for (int i = 0; i < options.length; i++) { + optsPtr.elementAt(i).ref.optionString = options[i].toNativeChars(); + } + if (classPath.isNotEmpty) { + final classPathString = classPath.join(Platform.isWindows ? ';' : ":"); + optsPtr.elementAt(count - 1).ref.optionString = + "-Djava.class.path=$classPathString".toNativeChars(); + } + args.ref.nOptions = count; + } + args.ref.ignoreUnrecognized = ignoreUnrecognized ? 1 : 0; + args.ref.version = version; + return args; + } + + static void _freeVMArgs(Pointer argPtr) { + final nOptions = argPtr.ref.nOptions; + final options = argPtr.ref.options; + if (nOptions != 0) { + for (var i = 0; i < nOptions; i++) { + calloc.free(options.elementAt(i).ref.optionString); + } + calloc.free(argPtr.ref.options); + } + calloc.free(argPtr); + } + + /// Returns pointer to current JNI JavaVM instance + Pointer getJavaVM() { + return _bindings.GetJavaVM(); + } + + /// Returns JniEnv* associated with current thread. + /// + /// Do not reuse JniEnv between threads, it's only valid + /// in the thread it is obtained. + Pointer getEnv() { + return _bindings.GetJniEnv(); + } + + void setJniLogging(int loggingLevel) { + _bindings.SetJNILogging(loggingLevel); + } + + /// Returns current application context on Android. + JObject getCachedApplicationContext() { + return _bindings.GetApplicationContext(); + } + + /// Returns current activity + JObject getCurrentActivity() { + return _bindings.GetCurrentActivity(); + } + + /// Get the initial classLoader of the application. + /// + /// This is especially useful on Android, where + /// JNI threads cannot access application classes using + /// the usual `JniEnv.FindClass` method. + JObject getApplicationClassLoader() { + return _bindings.GetClassLoader(); + } + + /// Returns class reference found through system-specific mechanism + JClass findClass(String qualifiedName) { + final nameChars = qualifiedName.toNativeChars(); + final cls = _bindings.LoadClass(nameChars); + calloc.free(nameChars); + if (cls == nullptr) { + getEnv().checkException(); + } + return cls; + } + + /// Returns class for [qualifiedName] found by platform-specific mechanism, + /// wrapped in a `JniClass`. + JniClass findJniClass(String qualifiedName) { + return JniClass.of(getEnv(), findClass(qualifiedName)); + } + + /// Constructs an instance of class with given args. + /// + /// Use it when you only need one instance, but not the actual class + /// nor any constructor / static methods. + JniObject newInstance( + String qualifiedName, String ctorSignature, List args) { + final cls = findJniClass(qualifiedName); + final ctor = cls.getMethodID("", ctorSignature); + final obj = cls.newObject(ctor, args); + cls.delete(); + return obj; + } + + /// Wraps a JObject ref in a JniObject. + /// The original ref is stored in JniObject, and + /// deleted with the latter's [delete] method. + /// + /// It takes the ownership of the jobject so that it can be used like this: + /// + /// ```dart + /// final result = jni.wrap(long_expr_returning_jobject) + /// ``` + JniObject wrap(JObject obj) { + return JniObject.of(getEnv(), obj, nullptr); + } + + /// Wraps a JObject ref in a JniObject. + /// The original ref is stored in JniObject, and + /// deleted with the latter's [delete] method. + JniClass wrapClass(JClass cls) { + return JniClass.of(getEnv(), cls); + } + + /// Converts passed arguments to JValue array + /// for use in methods that take arguments. + /// + /// int, bool, double and JObject types are converted out of the box. + /// wrap values in types such as [JValueLong] + /// to convert to other primitive types instead. + static Pointer jvalues(List args, + {Allocator allocator = calloc}) { + return toJValues(args, allocator: allocator); + } +} diff --git a/pkgs/jni/lib/src/jni_class.dart b/pkgs/jni/lib/src/jni_class.dart new file mode 100644 index 000000000..b4a676304 --- /dev/null +++ b/pkgs/jni/lib/src/jni_class.dart @@ -0,0 +1,153 @@ +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; + +import 'third_party/jni_bindings_generated.dart'; +import 'extensions.dart'; +import 'jvalues.dart'; +import 'jni_exceptions.dart'; +import 'jni_object.dart'; + +part 'jni_class_methods_generated.dart'; + +final ctorLookupChars = "".toNativeChars(); + +/// Convenience wrapper around a JNI local class reference. +/// +/// Reference lifetime semantics are same as [JniObject]. +class JniClass { + final JClass _cls; + final Pointer _env; + bool _deleted = false; + JniClass.of(this._env, this._cls); + + JniClass.fromJClass(Pointer env, JClass cls) + : _env = env, + _cls = cls; + + JniClass.fromGlobalRef(Pointer env, JniGlobalClassRef r) + : _env = env, + _cls = env.NewLocalRef(r._cls) { + if (r._deleted) { + throw UseAfterFreeException(r, r._cls); + } + } + + @pragma('vm:prefer-inline') + void _checkDeleted() { + if (_deleted) { + throw UseAfterFreeException(this, _cls); + } + } + + JMethodID getConstructorID(String signature) { + return _getMethodID("", signature, false); + } + + /// Construct new object using [ctor]. + JniObject newObject(JMethodID ctor, List args) { + _checkDeleted(); + final jvArgs = JValueArgs(args, _env); + final newObj = _env.NewObjectA(_cls, ctor, jvArgs.values); + jvArgs.disposeIn(_env); + calloc.free(jvArgs.values); + _env.checkException(); + return JniObject.of(_env, newObj, nullptr); + } + + JMethodID _getMethodID(String name, String signature, bool isStatic) { + _checkDeleted(); + final methodName = name.toNativeChars(); + final methodSig = signature.toNativeChars(); + final result = isStatic + ? _env.GetStaticMethodID(_cls, methodName, methodSig) + : _env.GetMethodID(_cls, methodName, methodSig); + calloc.free(methodName); + calloc.free(methodSig); + _env.checkException(); + return result; + } + + JFieldID _getFieldID(String name, String signature, bool isStatic) { + _checkDeleted(); + final methodName = name.toNativeChars(); + final methodSig = signature.toNativeChars(); + final result = isStatic + ? _env.GetStaticFieldID(_cls, methodName, methodSig) + : _env.GetFieldID(_cls, methodName, methodSig); + calloc.free(methodName); + calloc.free(methodSig); + _env.checkException(); + return result; + } + + @pragma('vm:prefer-inline') + JMethodID getMethodID(String name, String signature) { + return _getMethodID(name, signature, false); + } + + @pragma('vm:prefer-inline') + JMethodID getStaticMethodID(String name, String signature) { + return _getMethodID(name, signature, true); + } + + @pragma('vm:prefer-inline') + JFieldID getFieldID(String name, String signature) { + return _getFieldID(name, signature, false); + } + + @pragma('vm:prefer-inline') + JFieldID getStaticFieldID(String name, String signature) { + return _getFieldID(name, signature, true); + } + + /// Returns the underlying [JClass]. + JClass get jclass { + _checkDeleted(); + return _cls; + } + + JniGlobalClassRef getGlobalRef() { + _checkDeleted(); + return JniGlobalClassRef._(_env.NewGlobalRef(_cls)); + } + + void delete() { + if (_deleted) { + throw DoubleFreeException(this, _cls); + } + _env.DeleteLocalRef(_cls); + _deleted = true; + } + + /// Use this [JniClass] to execute callback, then delete. + /// + /// Useful in expression chains. + T use(T Function(JniClass) callback) { + _checkDeleted(); + final result = callback(this); + delete(); + return result; + } +} + +/// Global reference type for JniClasses +/// +/// Instead of passing local references between functions +/// that may be run on different threads, convert it +/// using [JniClass.getGlobalRef] and reconstruct using +/// [JniClass.fromGlobalRef] +class JniGlobalClassRef { + JniGlobalClassRef._(this._cls); + final JClass _cls; + JClass get jclass => _cls; + bool _deleted = false; + + void deleteIn(Pointer env) { + if (_deleted) { + throw DoubleFreeException(this, _cls); + } + env.DeleteGlobalRef(_cls); + _deleted = true; + } +} diff --git a/pkgs/jni/lib/src/jni_class_methods_generated.dart b/pkgs/jni/lib/src/jni_class_methods_generated.dart new file mode 100644 index 000000000..3e3a7ca10 --- /dev/null +++ b/pkgs/jni/lib/src/jni_class_methods_generated.dart @@ -0,0 +1,408 @@ +// Autogenerated; DO NOT EDIT +// Generated by running the script in tool/gen_aux_methods.dart +// coverage:ignore-file +part of 'jni_class.dart'; + +extension JniClassCallMethods on JniClass { + /// Calls method pointed to by [methodID] with [args] as arguments + String callStaticStringMethod(JMethodID methodID, List args) { + _checkDeleted(); + final jvArgs = JValueArgs(args, _env); + final result = _env.CallStaticObjectMethodA(_cls, methodID, jvArgs.values); + jvArgs.disposeIn(_env); + calloc.free(jvArgs.values); + final strRes = _env.asDartString(result, deleteOriginal: true); + _env.checkException(); + return strRes; + } + + /// Looks up method with [name] and [signature], calls it with [args] as arguments. + /// If calling the same method multiple times, consider using [getStaticMethodID] + /// and [callStaticStringMethod]. + String callStaticStringMethodByName( + String name, String signature, List args) { + final mID = getStaticMethodID(name, signature); + final result = callStaticStringMethod(mID, args); + return result; + } + + /// Retrieves the value of the field denoted by [fieldID] + String getStaticStringField(JFieldID fieldID) { + _checkDeleted(); + final result = _env.GetStaticObjectField(_cls, fieldID); + final strRes = _env.asDartString(result, deleteOriginal: true); + _env.checkException(); + return strRes; + } + + /// Retrieve field of given [name] and [signature] + String getStaticStringFieldByName(String name, String signature) { + final fID = getStaticFieldID(name, signature); + final result = getStaticStringField(fID); + return result; + } + + /// Calls method pointed to by [methodID] with [args] as arguments + JniObject callStaticObjectMethod(JMethodID methodID, List args) { + _checkDeleted(); + final jvArgs = JValueArgs(args, _env); + final result = _env.CallStaticObjectMethodA(_cls, methodID, jvArgs.values); + jvArgs.disposeIn(_env); + calloc.free(jvArgs.values); + + _env.checkException(); + return JniObject.of(_env, result, nullptr); + } + + /// Looks up method with [name] and [signature], calls it with [args] as arguments. + /// If calling the same method multiple times, consider using [getStaticMethodID] + /// and [callStaticObjectMethod]. + JniObject callStaticObjectMethodByName( + String name, String signature, List args) { + final mID = getStaticMethodID(name, signature); + final result = callStaticObjectMethod(mID, args); + return result; + } + + /// Retrieves the value of the field denoted by [fieldID] + JniObject getStaticObjectField(JFieldID fieldID) { + _checkDeleted(); + final result = _env.GetStaticObjectField(_cls, fieldID); + + _env.checkException(); + return JniObject.of(_env, result, nullptr); + } + + /// Retrieve field of given [name] and [signature] + JniObject getStaticObjectFieldByName(String name, String signature) { + final fID = getStaticFieldID(name, signature); + final result = getStaticObjectField(fID); + return result; + } + + /// Calls method pointed to by [methodID] with [args] as arguments + bool callStaticBooleanMethod(JMethodID methodID, List args) { + _checkDeleted(); + final jvArgs = JValueArgs(args, _env); + final result = _env.CallStaticBooleanMethodA(_cls, methodID, jvArgs.values); + jvArgs.disposeIn(_env); + calloc.free(jvArgs.values); + + _env.checkException(); + return result != 0; + } + + /// Looks up method with [name] and [signature], calls it with [args] as arguments. + /// If calling the same method multiple times, consider using [getStaticMethodID] + /// and [callStaticBooleanMethod]. + bool callStaticBooleanMethodByName( + String name, String signature, List args) { + final mID = getStaticMethodID(name, signature); + final result = callStaticBooleanMethod(mID, args); + return result; + } + + /// Retrieves the value of the field denoted by [fieldID] + bool getStaticBooleanField(JFieldID fieldID) { + _checkDeleted(); + final result = _env.GetStaticBooleanField(_cls, fieldID); + + _env.checkException(); + return result != 0; + } + + /// Retrieve field of given [name] and [signature] + bool getStaticBooleanFieldByName(String name, String signature) { + final fID = getStaticFieldID(name, signature); + final result = getStaticBooleanField(fID); + return result; + } + + /// Calls method pointed to by [methodID] with [args] as arguments + int callStaticByteMethod(JMethodID methodID, List args) { + _checkDeleted(); + final jvArgs = JValueArgs(args, _env); + final result = _env.CallStaticByteMethodA(_cls, methodID, jvArgs.values); + jvArgs.disposeIn(_env); + calloc.free(jvArgs.values); + + _env.checkException(); + return result; + } + + /// Looks up method with [name] and [signature], calls it with [args] as arguments. + /// If calling the same method multiple times, consider using [getStaticMethodID] + /// and [callStaticByteMethod]. + int callStaticByteMethodByName( + String name, String signature, List args) { + final mID = getStaticMethodID(name, signature); + final result = callStaticByteMethod(mID, args); + return result; + } + + /// Retrieves the value of the field denoted by [fieldID] + int getStaticByteField(JFieldID fieldID) { + _checkDeleted(); + final result = _env.GetStaticByteField(_cls, fieldID); + + _env.checkException(); + return result; + } + + /// Retrieve field of given [name] and [signature] + int getStaticByteFieldByName(String name, String signature) { + final fID = getStaticFieldID(name, signature); + final result = getStaticByteField(fID); + return result; + } + + /// Calls method pointed to by [methodID] with [args] as arguments + int callStaticCharMethod(JMethodID methodID, List args) { + _checkDeleted(); + final jvArgs = JValueArgs(args, _env); + final result = _env.CallStaticCharMethodA(_cls, methodID, jvArgs.values); + jvArgs.disposeIn(_env); + calloc.free(jvArgs.values); + + _env.checkException(); + return result; + } + + /// Looks up method with [name] and [signature], calls it with [args] as arguments. + /// If calling the same method multiple times, consider using [getStaticMethodID] + /// and [callStaticCharMethod]. + int callStaticCharMethodByName( + String name, String signature, List args) { + final mID = getStaticMethodID(name, signature); + final result = callStaticCharMethod(mID, args); + return result; + } + + /// Retrieves the value of the field denoted by [fieldID] + int getStaticCharField(JFieldID fieldID) { + _checkDeleted(); + final result = _env.GetStaticCharField(_cls, fieldID); + + _env.checkException(); + return result; + } + + /// Retrieve field of given [name] and [signature] + int getStaticCharFieldByName(String name, String signature) { + final fID = getStaticFieldID(name, signature); + final result = getStaticCharField(fID); + return result; + } + + /// Calls method pointed to by [methodID] with [args] as arguments + int callStaticShortMethod(JMethodID methodID, List args) { + _checkDeleted(); + final jvArgs = JValueArgs(args, _env); + final result = _env.CallStaticShortMethodA(_cls, methodID, jvArgs.values); + jvArgs.disposeIn(_env); + calloc.free(jvArgs.values); + + _env.checkException(); + return result; + } + + /// Looks up method with [name] and [signature], calls it with [args] as arguments. + /// If calling the same method multiple times, consider using [getStaticMethodID] + /// and [callStaticShortMethod]. + int callStaticShortMethodByName( + String name, String signature, List args) { + final mID = getStaticMethodID(name, signature); + final result = callStaticShortMethod(mID, args); + return result; + } + + /// Retrieves the value of the field denoted by [fieldID] + int getStaticShortField(JFieldID fieldID) { + _checkDeleted(); + final result = _env.GetStaticShortField(_cls, fieldID); + + _env.checkException(); + return result; + } + + /// Retrieve field of given [name] and [signature] + int getStaticShortFieldByName(String name, String signature) { + final fID = getStaticFieldID(name, signature); + final result = getStaticShortField(fID); + return result; + } + + /// Calls method pointed to by [methodID] with [args] as arguments + int callStaticIntMethod(JMethodID methodID, List args) { + _checkDeleted(); + final jvArgs = JValueArgs(args, _env); + final result = _env.CallStaticIntMethodA(_cls, methodID, jvArgs.values); + jvArgs.disposeIn(_env); + calloc.free(jvArgs.values); + + _env.checkException(); + return result; + } + + /// Looks up method with [name] and [signature], calls it with [args] as arguments. + /// If calling the same method multiple times, consider using [getStaticMethodID] + /// and [callStaticIntMethod]. + int callStaticIntMethodByName( + String name, String signature, List args) { + final mID = getStaticMethodID(name, signature); + final result = callStaticIntMethod(mID, args); + return result; + } + + /// Retrieves the value of the field denoted by [fieldID] + int getStaticIntField(JFieldID fieldID) { + _checkDeleted(); + final result = _env.GetStaticIntField(_cls, fieldID); + + _env.checkException(); + return result; + } + + /// Retrieve field of given [name] and [signature] + int getStaticIntFieldByName(String name, String signature) { + final fID = getStaticFieldID(name, signature); + final result = getStaticIntField(fID); + return result; + } + + /// Calls method pointed to by [methodID] with [args] as arguments + int callStaticLongMethod(JMethodID methodID, List args) { + _checkDeleted(); + final jvArgs = JValueArgs(args, _env); + final result = _env.CallStaticLongMethodA(_cls, methodID, jvArgs.values); + jvArgs.disposeIn(_env); + calloc.free(jvArgs.values); + + _env.checkException(); + return result; + } + + /// Looks up method with [name] and [signature], calls it with [args] as arguments. + /// If calling the same method multiple times, consider using [getStaticMethodID] + /// and [callStaticLongMethod]. + int callStaticLongMethodByName( + String name, String signature, List args) { + final mID = getStaticMethodID(name, signature); + final result = callStaticLongMethod(mID, args); + return result; + } + + /// Retrieves the value of the field denoted by [fieldID] + int getStaticLongField(JFieldID fieldID) { + _checkDeleted(); + final result = _env.GetStaticLongField(_cls, fieldID); + + _env.checkException(); + return result; + } + + /// Retrieve field of given [name] and [signature] + int getStaticLongFieldByName(String name, String signature) { + final fID = getStaticFieldID(name, signature); + final result = getStaticLongField(fID); + return result; + } + + /// Calls method pointed to by [methodID] with [args] as arguments + double callStaticFloatMethod(JMethodID methodID, List args) { + _checkDeleted(); + final jvArgs = JValueArgs(args, _env); + final result = _env.CallStaticFloatMethodA(_cls, methodID, jvArgs.values); + jvArgs.disposeIn(_env); + calloc.free(jvArgs.values); + + _env.checkException(); + return result; + } + + /// Looks up method with [name] and [signature], calls it with [args] as arguments. + /// If calling the same method multiple times, consider using [getStaticMethodID] + /// and [callStaticFloatMethod]. + double callStaticFloatMethodByName( + String name, String signature, List args) { + final mID = getStaticMethodID(name, signature); + final result = callStaticFloatMethod(mID, args); + return result; + } + + /// Retrieves the value of the field denoted by [fieldID] + double getStaticFloatField(JFieldID fieldID) { + _checkDeleted(); + final result = _env.GetStaticFloatField(_cls, fieldID); + + _env.checkException(); + return result; + } + + /// Retrieve field of given [name] and [signature] + double getStaticFloatFieldByName(String name, String signature) { + final fID = getStaticFieldID(name, signature); + final result = getStaticFloatField(fID); + return result; + } + + /// Calls method pointed to by [methodID] with [args] as arguments + double callStaticDoubleMethod(JMethodID methodID, List args) { + _checkDeleted(); + final jvArgs = JValueArgs(args, _env); + final result = _env.CallStaticDoubleMethodA(_cls, methodID, jvArgs.values); + jvArgs.disposeIn(_env); + calloc.free(jvArgs.values); + + _env.checkException(); + return result; + } + + /// Looks up method with [name] and [signature], calls it with [args] as arguments. + /// If calling the same method multiple times, consider using [getStaticMethodID] + /// and [callStaticDoubleMethod]. + double callStaticDoubleMethodByName( + String name, String signature, List args) { + final mID = getStaticMethodID(name, signature); + final result = callStaticDoubleMethod(mID, args); + return result; + } + + /// Retrieves the value of the field denoted by [fieldID] + double getStaticDoubleField(JFieldID fieldID) { + _checkDeleted(); + final result = _env.GetStaticDoubleField(_cls, fieldID); + + _env.checkException(); + return result; + } + + /// Retrieve field of given [name] and [signature] + double getStaticDoubleFieldByName(String name, String signature) { + final fID = getStaticFieldID(name, signature); + final result = getStaticDoubleField(fID); + return result; + } + + /// Calls method pointed to by [methodID] with [args] as arguments + void callStaticVoidMethod(JMethodID methodID, List args) { + _checkDeleted(); + final jvArgs = JValueArgs(args, _env); + final result = _env.CallStaticVoidMethodA(_cls, methodID, jvArgs.values); + jvArgs.disposeIn(_env); + calloc.free(jvArgs.values); + + _env.checkException(); + return result; + } + + /// Looks up method with [name] and [signature], calls it with [args] as arguments. + /// If calling the same method multiple times, consider using [getStaticMethodID] + /// and [callStaticVoidMethod]. + void callStaticVoidMethodByName( + String name, String signature, List args) { + final mID = getStaticMethodID(name, signature); + final result = callStaticVoidMethod(mID, args); + return result; + } +} diff --git a/pkgs/jni/lib/src/jni_exceptions.dart b/pkgs/jni/lib/src/jni_exceptions.dart new file mode 100644 index 000000000..153343788 --- /dev/null +++ b/pkgs/jni/lib/src/jni_exceptions.dart @@ -0,0 +1,49 @@ +import 'dart:ffi'; + +import 'third_party/jni_bindings_generated.dart'; + +class UseAfterFreeException implements Exception { + dynamic object; + Pointer ptr; + UseAfterFreeException(this.object, this.ptr); + + @override + String toString() { + return "use after free on $ptr through $object"; + } +} + +class DoubleFreeException implements Exception { + dynamic object; + Pointer ptr; + DoubleFreeException(this.object, this.ptr); + + @override + String toString() { + return "double on $ptr through $object"; + } +} + +class JniException implements Exception { + /// Exception object pointer from JNI. + final JObject err; + + /// brief description, usually initialized with error message from Java. + final String msg; + JniException(this.err, this.msg); + + @override + String toString() => msg; + + void deleteIn(Pointer env) => env.DeleteLocalRef(err); +} + +class HelperNotFoundException implements Exception { + HelperNotFoundException(this.path); + final String path; + + @override + String toString() => "Lookup for helper library $path failed.\n" + "Please ensure that `dartjni` shared library is built.\n" + "If the library is already built, double check the path."; +} diff --git a/pkgs/jni/lib/src/jni_object.dart b/pkgs/jni/lib/src/jni_object.dart new file mode 100644 index 000000000..217c8323c --- /dev/null +++ b/pkgs/jni/lib/src/jni_object.dart @@ -0,0 +1,180 @@ +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; + +import 'third_party/jni_bindings_generated.dart'; +import 'extensions.dart'; +import 'jni_class.dart'; +import 'jvalues.dart'; +import 'jni_exceptions.dart'; + +part 'jni_object_methods_generated.dart'; + +/// JniObject is a convenience wrapper around a JNI local object reference. +/// +/// It holds the object, its associated associated jniEnv etc.. +/// It should be distroyed with [delete] method after done. +/// +/// It's valid only in the thread it was created. +/// When passing to code that might run in a different thread (eg: a callback), +/// consider obtaining a global reference and reconstructing the object. +class JniObject { + JClass _cls; + final JObject _obj; + final Pointer _env; + bool _deleted = false; + JniObject.of(this._env, this._obj, this._cls); + + @pragma('vm:prefer-inline') + void _checkDeleted() { + if (_deleted) { + throw UseAfterFreeException(this, _obj); + } + } + + JniObject.fromJObject(Pointer env, JObject obj) + : _env = env, + _obj = obj, + _cls = nullptr; + + /// Reconstructs a JniObject from [r] + /// + /// [r] still needs to be explicitly deleted when + /// it's no longer needed to construct any JniObjects. + JniObject.fromGlobalRef(Pointer env, JniGlobalObjectRef r) + : _env = env, + _obj = env.NewLocalRef(r._obj), + _cls = env.NewLocalRef(r._cls) { + if (r._deleted) { + throw UseAfterFreeException(r, r._obj); + } + } + + /// Delete the local reference contained by this object. + /// + /// Do not use a JniObject after calling [delete]. + void delete() { + if (_deleted == true) { + throw DoubleFreeException(this, _obj); + } + _env.DeleteLocalRef(_obj); + if (_cls != nullptr) { + _env.DeleteLocalRef(_cls); + } + _deleted = true; + } + + /// Returns underlying [JObject] of this [JniObject]. + JObject get jobject { + _checkDeleted(); + return _obj; + } + + /// Returns underlying [JClass] of this [JniObject]. + JObject get jclass { + _checkDeleted(); + if (_cls == nullptr) { + _cls = _env.GetObjectClass(_obj); + } + return _cls; + } + + /// Get a JniClass of this object's class. + JniClass getClass() { + _checkDeleted(); + if (_cls == nullptr) { + return JniClass.of(_env, _env.GetObjectClass(_obj)); + } + return JniClass.of(_env, _env.NewLocalRef(_cls)); + } + + /// if the underlying JObject is string + /// converts it to string representation. + String asDartString() { + _checkDeleted(); + return _env.asDartString(_obj); + } + + /// Returns method id for [name] on this object. + JMethodID getMethodID(String name, String signature) { + _checkDeleted(); + if (_cls == nullptr) { + _cls = _env.GetObjectClass(_obj); + } + final methodName = name.toNativeChars(); + final methodSig = signature.toNativeChars(); + final result = _env.GetMethodID(_cls, methodName, methodSig); + calloc.free(methodName); + calloc.free(methodSig); + _env.checkException(); + return result; + } + + /// Returns field id for [name] on this object. + JFieldID getFieldID(String name, String signature) { + _checkDeleted(); + if (_cls == nullptr) { + _cls = _env.GetObjectClass(_obj); + } + final methodName = name.toNativeChars(); + final methodSig = signature.toNativeChars(); + final result = _env.GetFieldID(_cls, methodName, methodSig); + calloc.free(methodName); + calloc.free(methodSig); + _env.checkException(); + return result; + } + + /// Get a global reference. + /// + /// This is useful for passing a JniObject between threads. + JniGlobalObjectRef getGlobalRef() { + _checkDeleted(); + return JniGlobalObjectRef._( + _env.NewGlobalRef(_obj), + _env.NewGlobalRef(_cls), + ); + } + + /// Use this [JniObject] to execute callback, then delete. + /// + /// Useful in expression chains. + T use(T Function(JniObject) callback) { + _checkDeleted(); + try { + final result = callback(this); + delete(); + return result; + } catch (e) { + delete(); + rethrow; + } + } +} + +/// High level wrapper to a JNI global reference. +/// which is safe to be passed through threads. +/// +/// In a different thread, actual object can be reconstructed +/// using [JniObject.fromGlobalRef] +/// +/// It should be explicitly deleted after done, using +/// [deleteIn] method, passing some env, eg: obtained using [Jni.getEnv]. +class JniGlobalObjectRef { + final JObject _obj; + final JClass _cls; + bool _deleted = false; + JniGlobalObjectRef._(this._obj, this._cls); + + JObject get jobject => _obj; + JObject get jclass => _cls; + + void deleteIn(Pointer env) { + if (_deleted == true) { + throw DoubleFreeException(this, _obj); + } + env.DeleteGlobalRef(_obj); + env.DeleteGlobalRef(_cls); + _deleted = true; + } +} diff --git a/pkgs/jni/lib/src/jni_object_methods_generated.dart b/pkgs/jni/lib/src/jni_object_methods_generated.dart new file mode 100644 index 000000000..490f8fc74 --- /dev/null +++ b/pkgs/jni/lib/src/jni_object_methods_generated.dart @@ -0,0 +1,402 @@ +// Autogenerated; DO NOT EDIT +// Generated by running the script in tool/gen_aux_methods.dart +// coverage:ignore-file +part of 'jni_object.dart'; + +extension JniObjectCallMethods on JniObject { + /// Calls method pointed to by [methodID] with [args] as arguments + String callStringMethod(JMethodID methodID, List args) { + _checkDeleted(); + final jvArgs = JValueArgs(args, _env); + final result = _env.CallObjectMethodA(_obj, methodID, jvArgs.values); + jvArgs.disposeIn(_env); + calloc.free(jvArgs.values); + final strRes = _env.asDartString(result, deleteOriginal: true); + _env.checkException(); + return strRes; + } + + /// Looks up method with [name] and [signature], calls it with [args] as arguments. + /// If calling the same method multiple times, consider using [getMethodID] + /// and [callStringMethod]. + String callStringMethodByName( + String name, String signature, List args) { + final mID = getMethodID(name, signature); + final result = callStringMethod(mID, args); + return result; + } + + /// Retrieves the value of the field denoted by [fieldID] + String getStringField(JFieldID fieldID) { + _checkDeleted(); + final result = _env.GetObjectField(_obj, fieldID); + final strRes = _env.asDartString(result, deleteOriginal: true); + _env.checkException(); + return strRes; + } + + /// Retrieve field of given [name] and [signature] + String getStringFieldByName(String name, String signature) { + final fID = getFieldID(name, signature); + final result = getStringField(fID); + return result; + } + + /// Calls method pointed to by [methodID] with [args] as arguments + JniObject callObjectMethod(JMethodID methodID, List args) { + _checkDeleted(); + final jvArgs = JValueArgs(args, _env); + final result = _env.CallObjectMethodA(_obj, methodID, jvArgs.values); + jvArgs.disposeIn(_env); + calloc.free(jvArgs.values); + + _env.checkException(); + return JniObject.of(_env, result, nullptr); + } + + /// Looks up method with [name] and [signature], calls it with [args] as arguments. + /// If calling the same method multiple times, consider using [getMethodID] + /// and [callObjectMethod]. + JniObject callObjectMethodByName( + String name, String signature, List args) { + final mID = getMethodID(name, signature); + final result = callObjectMethod(mID, args); + return result; + } + + /// Retrieves the value of the field denoted by [fieldID] + JniObject getObjectField(JFieldID fieldID) { + _checkDeleted(); + final result = _env.GetObjectField(_obj, fieldID); + + _env.checkException(); + return JniObject.of(_env, result, nullptr); + } + + /// Retrieve field of given [name] and [signature] + JniObject getObjectFieldByName(String name, String signature) { + final fID = getFieldID(name, signature); + final result = getObjectField(fID); + return result; + } + + /// Calls method pointed to by [methodID] with [args] as arguments + bool callBooleanMethod(JMethodID methodID, List args) { + _checkDeleted(); + final jvArgs = JValueArgs(args, _env); + final result = _env.CallBooleanMethodA(_obj, methodID, jvArgs.values); + jvArgs.disposeIn(_env); + calloc.free(jvArgs.values); + + _env.checkException(); + return result != 0; + } + + /// Looks up method with [name] and [signature], calls it with [args] as arguments. + /// If calling the same method multiple times, consider using [getMethodID] + /// and [callBooleanMethod]. + bool callBooleanMethodByName( + String name, String signature, List args) { + final mID = getMethodID(name, signature); + final result = callBooleanMethod(mID, args); + return result; + } + + /// Retrieves the value of the field denoted by [fieldID] + bool getBooleanField(JFieldID fieldID) { + _checkDeleted(); + final result = _env.GetBooleanField(_obj, fieldID); + + _env.checkException(); + return result != 0; + } + + /// Retrieve field of given [name] and [signature] + bool getBooleanFieldByName(String name, String signature) { + final fID = getFieldID(name, signature); + final result = getBooleanField(fID); + return result; + } + + /// Calls method pointed to by [methodID] with [args] as arguments + int callByteMethod(JMethodID methodID, List args) { + _checkDeleted(); + final jvArgs = JValueArgs(args, _env); + final result = _env.CallByteMethodA(_obj, methodID, jvArgs.values); + jvArgs.disposeIn(_env); + calloc.free(jvArgs.values); + + _env.checkException(); + return result; + } + + /// Looks up method with [name] and [signature], calls it with [args] as arguments. + /// If calling the same method multiple times, consider using [getMethodID] + /// and [callByteMethod]. + int callByteMethodByName(String name, String signature, List args) { + final mID = getMethodID(name, signature); + final result = callByteMethod(mID, args); + return result; + } + + /// Retrieves the value of the field denoted by [fieldID] + int getByteField(JFieldID fieldID) { + _checkDeleted(); + final result = _env.GetByteField(_obj, fieldID); + + _env.checkException(); + return result; + } + + /// Retrieve field of given [name] and [signature] + int getByteFieldByName(String name, String signature) { + final fID = getFieldID(name, signature); + final result = getByteField(fID); + return result; + } + + /// Calls method pointed to by [methodID] with [args] as arguments + int callCharMethod(JMethodID methodID, List args) { + _checkDeleted(); + final jvArgs = JValueArgs(args, _env); + final result = _env.CallCharMethodA(_obj, methodID, jvArgs.values); + jvArgs.disposeIn(_env); + calloc.free(jvArgs.values); + + _env.checkException(); + return result; + } + + /// Looks up method with [name] and [signature], calls it with [args] as arguments. + /// If calling the same method multiple times, consider using [getMethodID] + /// and [callCharMethod]. + int callCharMethodByName(String name, String signature, List args) { + final mID = getMethodID(name, signature); + final result = callCharMethod(mID, args); + return result; + } + + /// Retrieves the value of the field denoted by [fieldID] + int getCharField(JFieldID fieldID) { + _checkDeleted(); + final result = _env.GetCharField(_obj, fieldID); + + _env.checkException(); + return result; + } + + /// Retrieve field of given [name] and [signature] + int getCharFieldByName(String name, String signature) { + final fID = getFieldID(name, signature); + final result = getCharField(fID); + return result; + } + + /// Calls method pointed to by [methodID] with [args] as arguments + int callShortMethod(JMethodID methodID, List args) { + _checkDeleted(); + final jvArgs = JValueArgs(args, _env); + final result = _env.CallShortMethodA(_obj, methodID, jvArgs.values); + jvArgs.disposeIn(_env); + calloc.free(jvArgs.values); + + _env.checkException(); + return result; + } + + /// Looks up method with [name] and [signature], calls it with [args] as arguments. + /// If calling the same method multiple times, consider using [getMethodID] + /// and [callShortMethod]. + int callShortMethodByName(String name, String signature, List args) { + final mID = getMethodID(name, signature); + final result = callShortMethod(mID, args); + return result; + } + + /// Retrieves the value of the field denoted by [fieldID] + int getShortField(JFieldID fieldID) { + _checkDeleted(); + final result = _env.GetShortField(_obj, fieldID); + + _env.checkException(); + return result; + } + + /// Retrieve field of given [name] and [signature] + int getShortFieldByName(String name, String signature) { + final fID = getFieldID(name, signature); + final result = getShortField(fID); + return result; + } + + /// Calls method pointed to by [methodID] with [args] as arguments + int callIntMethod(JMethodID methodID, List args) { + _checkDeleted(); + final jvArgs = JValueArgs(args, _env); + final result = _env.CallIntMethodA(_obj, methodID, jvArgs.values); + jvArgs.disposeIn(_env); + calloc.free(jvArgs.values); + + _env.checkException(); + return result; + } + + /// Looks up method with [name] and [signature], calls it with [args] as arguments. + /// If calling the same method multiple times, consider using [getMethodID] + /// and [callIntMethod]. + int callIntMethodByName(String name, String signature, List args) { + final mID = getMethodID(name, signature); + final result = callIntMethod(mID, args); + return result; + } + + /// Retrieves the value of the field denoted by [fieldID] + int getIntField(JFieldID fieldID) { + _checkDeleted(); + final result = _env.GetIntField(_obj, fieldID); + + _env.checkException(); + return result; + } + + /// Retrieve field of given [name] and [signature] + int getIntFieldByName(String name, String signature) { + final fID = getFieldID(name, signature); + final result = getIntField(fID); + return result; + } + + /// Calls method pointed to by [methodID] with [args] as arguments + int callLongMethod(JMethodID methodID, List args) { + _checkDeleted(); + final jvArgs = JValueArgs(args, _env); + final result = _env.CallLongMethodA(_obj, methodID, jvArgs.values); + jvArgs.disposeIn(_env); + calloc.free(jvArgs.values); + + _env.checkException(); + return result; + } + + /// Looks up method with [name] and [signature], calls it with [args] as arguments. + /// If calling the same method multiple times, consider using [getMethodID] + /// and [callLongMethod]. + int callLongMethodByName(String name, String signature, List args) { + final mID = getMethodID(name, signature); + final result = callLongMethod(mID, args); + return result; + } + + /// Retrieves the value of the field denoted by [fieldID] + int getLongField(JFieldID fieldID) { + _checkDeleted(); + final result = _env.GetLongField(_obj, fieldID); + + _env.checkException(); + return result; + } + + /// Retrieve field of given [name] and [signature] + int getLongFieldByName(String name, String signature) { + final fID = getFieldID(name, signature); + final result = getLongField(fID); + return result; + } + + /// Calls method pointed to by [methodID] with [args] as arguments + double callFloatMethod(JMethodID methodID, List args) { + _checkDeleted(); + final jvArgs = JValueArgs(args, _env); + final result = _env.CallFloatMethodA(_obj, methodID, jvArgs.values); + jvArgs.disposeIn(_env); + calloc.free(jvArgs.values); + + _env.checkException(); + return result; + } + + /// Looks up method with [name] and [signature], calls it with [args] as arguments. + /// If calling the same method multiple times, consider using [getMethodID] + /// and [callFloatMethod]. + double callFloatMethodByName( + String name, String signature, List args) { + final mID = getMethodID(name, signature); + final result = callFloatMethod(mID, args); + return result; + } + + /// Retrieves the value of the field denoted by [fieldID] + double getFloatField(JFieldID fieldID) { + _checkDeleted(); + final result = _env.GetFloatField(_obj, fieldID); + + _env.checkException(); + return result; + } + + /// Retrieve field of given [name] and [signature] + double getFloatFieldByName(String name, String signature) { + final fID = getFieldID(name, signature); + final result = getFloatField(fID); + return result; + } + + /// Calls method pointed to by [methodID] with [args] as arguments + double callDoubleMethod(JMethodID methodID, List args) { + _checkDeleted(); + final jvArgs = JValueArgs(args, _env); + final result = _env.CallDoubleMethodA(_obj, methodID, jvArgs.values); + jvArgs.disposeIn(_env); + calloc.free(jvArgs.values); + + _env.checkException(); + return result; + } + + /// Looks up method with [name] and [signature], calls it with [args] as arguments. + /// If calling the same method multiple times, consider using [getMethodID] + /// and [callDoubleMethod]. + double callDoubleMethodByName( + String name, String signature, List args) { + final mID = getMethodID(name, signature); + final result = callDoubleMethod(mID, args); + return result; + } + + /// Retrieves the value of the field denoted by [fieldID] + double getDoubleField(JFieldID fieldID) { + _checkDeleted(); + final result = _env.GetDoubleField(_obj, fieldID); + + _env.checkException(); + return result; + } + + /// Retrieve field of given [name] and [signature] + double getDoubleFieldByName(String name, String signature) { + final fID = getFieldID(name, signature); + final result = getDoubleField(fID); + return result; + } + + /// Calls method pointed to by [methodID] with [args] as arguments + void callVoidMethod(JMethodID methodID, List args) { + _checkDeleted(); + final jvArgs = JValueArgs(args, _env); + final result = _env.CallVoidMethodA(_obj, methodID, jvArgs.values); + jvArgs.disposeIn(_env); + calloc.free(jvArgs.values); + + _env.checkException(); + return result; + } + + /// Looks up method with [name] and [signature], calls it with [args] as arguments. + /// If calling the same method multiple times, consider using [getMethodID] + /// and [callVoidMethod]. + void callVoidMethodByName(String name, String signature, List args) { + final mID = getMethodID(name, signature); + final result = callVoidMethod(mID, args); + return result; + } +} diff --git a/pkgs/jni/lib/src/jvalues.dart b/pkgs/jni/lib/src/jvalues.dart new file mode 100644 index 000000000..63945b01c --- /dev/null +++ b/pkgs/jni/lib/src/jvalues.dart @@ -0,0 +1,137 @@ +import 'dart:ffi'; +import 'package:ffi/ffi.dart'; + +import 'third_party/jni_bindings_generated.dart'; +import 'extensions.dart'; +import 'jni_object.dart'; + +void _fillJValue(Pointer pos, dynamic arg) { + // switch on runtimeType is not guaranteed to work? + switch (arg.runtimeType) { + case int: + pos.ref.i = arg; + break; + case bool: + pos.ref.z = arg ? 1 : 0; + break; + case Pointer: + case Pointer: + pos.ref.l = arg; + break; + case double: + pos.ref.d = arg; + break; + case JValueFloat: + pos.ref.f = (arg as JValueFloat).value; + break; + case JValueLong: + pos.ref.j = (arg as JValueLong).value; + break; + case JValueShort: + pos.ref.s = (arg as JValueShort).value; + break; + case JValueChar: + pos.ref.c = (arg as JValueChar).value; + break; + case JValueByte: + pos.ref.b = (arg as JValueByte).value; + break; + default: + throw "cannot convert ${arg.runtimeType} to jvalue"; + } +} + +/// Converts passed arguments to JValue array +/// for use in methods that take arguments. +/// +/// int, bool, double and JObject types are converted out of the box. +/// wrap values in types such as [JValueLong] +/// to convert to other primitive types instead. +Pointer toJValues(List args, {Allocator allocator = calloc}) { + final result = allocator(args.length); + for (int i = 0; i < args.length; i++) { + final arg = args[i]; + final pos = result.elementAt(i); + _fillJValue(pos, arg); + } + return result; +} + +/// Use this class as wrapper to convert an integer +/// to Java `long` in jvalues method. +class JValueLong { + int value; + JValueLong(this.value); +} + +/// Use this class as wrapper to convert an integer +/// to Java `short` in jvalues method. +class JValueShort { + int value; + JValueShort(this.value); +} + +/// Use this class as wrapper to convert an integer +/// to Java `byte` in jvalues method. +class JValueByte { + int value; + JValueByte(this.value); +} + +/// Use this class as wrapper to convert an double +/// to Java `float` in jvalues method. +class JValueFloat { + double value; + JValueFloat(this.value); +} + +/// Use this class as wrapper to convert an integer +/// to Java `char` in jvalues method. +class JValueChar { + int value; + JValueChar(this.value); + JValueChar.fromString(String s) : value = 0 { + if (s.length != 1) { + throw "Expected string of length 1"; + } + value = s.codeUnitAt(0).toInt(); + } +} + +/// class used to convert dart types passed to convenience methods +/// into their corresponding Java values. +/// +/// Similar to Jni.jvalues, but instead of a pointer, an instance +/// with a dispose method is returned. +/// This allows us to take dart strings. +/// +/// Returned value is allocated using provided allocator. +/// But default allocator may be used for string conversions. +class JValueArgs { + late Pointer values; + final List createdRefs = []; + + JValueArgs(List args, Pointer env, + [Allocator allocator = malloc]) { + values = allocator(args.length); + for (int i = 0; i < args.length; i++) { + final arg = args[i]; + final ptr = values.elementAt(i); + if (arg is String) { + final jstr = env.asJString(arg); + ptr.ref.l = jstr; + createdRefs.add(jstr); + } else if (arg is JniObject) { + ptr.ref.l = arg.jobject; + } else { + _fillJValue(ptr, arg); + } + } + } + + void disposeIn(Pointer env) { + for (var ref in createdRefs) { + env.DeleteLocalRef(ref); + } + } +} diff --git a/pkgs/jni/lib/src/third_party/jni_bindings_generated.dart b/pkgs/jni/lib/src/third_party/jni_bindings_generated.dart new file mode 100644 index 000000000..005029c42 --- /dev/null +++ b/pkgs/jni/lib/src/third_party/jni_bindings_generated.dart @@ -0,0 +1,3086 @@ +// Autogenerated file. Do not edit. +// Generated from an annotated version of jni.h provided in Android NDK +// (NDK Version 23.1.7779620) +// The license for original file is provided below: + +/* + * Copyright (C) 2006 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * JNI specification, as defined by Sun: + * http://java.sun.com/javase/6/docs/technotes/guides/jni/spec/jniTOC.html + * + * Everything here is expected to be VM-neutral. + */ + +// ignore_for_file: always_specify_types +// ignore_for_file: camel_case_types +// ignore_for_file: non_constant_identifier_names +// ignore_for_file: constant_identifier_names +// ignore_for_file: unused_field +// ignore_for_file: unused_element +// coverage:ignore-file + +// AUTO GENERATED FILE, DO NOT EDIT. +// +// Generated by `package:ffigen`. +import 'dart:ffi' as ffi; + +/// Bindings for libdartjni.so which is part of jni plugin. +/// +/// It also transitively includes type definitions such as JNIEnv from third_party/jni.h; +/// +/// However, functions prefixed JNI_ are not usable because they are in a different shared library. +/// +/// Regenerate bindings with `flutter pub run ffigen.dart --config ffigen.yaml`. +/// +class JniBindings { + /// Holds the symbol lookup function. + final ffi.Pointer Function(String symbolName) + _lookup; + + /// The symbols are looked up in [dynamicLibrary]. + JniBindings(ffi.DynamicLibrary dynamicLibrary) + : _lookup = dynamicLibrary.lookup; + + /// The symbols are looked up with [lookup]. + JniBindings.fromLookup( + ffi.Pointer Function(String symbolName) + lookup) + : _lookup = lookup; + + /// VM initialization functions. + /// + /// Note these are the only symbols exported for JNI by the VM. + int JNI_GetDefaultJavaVMInitArgs( + ffi.Pointer arg0, + ) { + return _JNI_GetDefaultJavaVMInitArgs( + arg0, + ); + } + + late final _JNI_GetDefaultJavaVMInitArgsPtr = + _lookup)>>( + 'JNI_GetDefaultJavaVMInitArgs'); + late final _JNI_GetDefaultJavaVMInitArgs = _JNI_GetDefaultJavaVMInitArgsPtr + .asFunction)>(); + + int JNI_CreateJavaVM( + ffi.Pointer> arg0, + ffi.Pointer> arg1, + ffi.Pointer arg2, + ) { + return _JNI_CreateJavaVM( + arg0, + arg1, + arg2, + ); + } + + late final _JNI_CreateJavaVMPtr = _lookup< + ffi.NativeFunction< + JInt Function( + ffi.Pointer>, + ffi.Pointer>, + ffi.Pointer)>>('JNI_CreateJavaVM'); + late final _JNI_CreateJavaVM = _JNI_CreateJavaVMPtr.asFunction< + int Function(ffi.Pointer>, + ffi.Pointer>, ffi.Pointer)>(); + + int JNI_GetCreatedJavaVMs( + ffi.Pointer> arg0, + int arg1, + ffi.Pointer arg2, + ) { + return _JNI_GetCreatedJavaVMs( + arg0, + arg1, + arg2, + ); + } + + late final _JNI_GetCreatedJavaVMsPtr = _lookup< + ffi.NativeFunction< + JInt Function(ffi.Pointer>, JSize, + ffi.Pointer)>>('JNI_GetCreatedJavaVMs'); + late final _JNI_GetCreatedJavaVMs = _JNI_GetCreatedJavaVMsPtr.asFunction< + int Function( + ffi.Pointer>, int, ffi.Pointer)>(); + + ffi.Pointer GetJavaVM() { + return _GetJavaVM(); + } + + late final _GetJavaVMPtr = + _lookup Function()>>('GetJavaVM'); + late final _GetJavaVM = + _GetJavaVMPtr.asFunction Function()>(); + + ffi.Pointer GetJniEnv() { + return _GetJniEnv(); + } + + late final _GetJniEnvPtr = + _lookup Function()>>('GetJniEnv'); + late final _GetJniEnv = + _GetJniEnvPtr.asFunction Function()>(); + + ffi.Pointer SpawnJvm( + ffi.Pointer args, + ) { + return _SpawnJvm( + args, + ); + } + + late final _SpawnJvmPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer)>>('SpawnJvm'); + late final _SpawnJvm = _SpawnJvmPtr.asFunction< + ffi.Pointer Function(ffi.Pointer)>(); + + JClass LoadClass( + ffi.Pointer name, + ) { + return _LoadClass( + name, + ); + } + + late final _LoadClassPtr = + _lookup)>>( + 'LoadClass'); + late final _LoadClass = + _LoadClassPtr.asFunction)>(); + + JObject GetClassLoader() { + return _GetClassLoader(); + } + + late final _GetClassLoaderPtr = + _lookup>('GetClassLoader'); + late final _GetClassLoader = + _GetClassLoaderPtr.asFunction(); + + JObject GetApplicationContext() { + return _GetApplicationContext(); + } + + late final _GetApplicationContextPtr = + _lookup>('GetApplicationContext'); + late final _GetApplicationContext = + _GetApplicationContextPtr.asFunction(); + + JObject GetCurrentActivity() { + return _GetCurrentActivity(); + } + + late final _GetCurrentActivityPtr = + _lookup>('GetCurrentActivity'); + late final _GetCurrentActivity = + _GetCurrentActivityPtr.asFunction(); + + void SetJNILogging( + int level, + ) { + return _SetJNILogging( + level, + ); + } + + late final _SetJNILoggingPtr = + _lookup>('SetJNILogging'); + late final _SetJNILogging = + _SetJNILoggingPtr.asFunction(); +} + +class jfieldID_ extends ffi.Opaque {} + +class jmethodID_ extends ffi.Opaque {} + +/// JNI invocation interface. +class JNIInvokeInterface extends ffi.Struct { + external ffi.Pointer reserved0; + + external ffi.Pointer reserved1; + + external ffi.Pointer reserved2; + + external ffi.Pointer)>> + DestroyJavaVM; + + external ffi.Pointer< + ffi.NativeFunction< + JInt Function(ffi.Pointer, ffi.Pointer>, + ffi.Pointer)>> AttachCurrentThread; + + external ffi.Pointer)>> + DetachCurrentThread; + + external ffi.Pointer< + ffi.NativeFunction< + JInt Function(ffi.Pointer, ffi.Pointer>, + JInt)>> GetEnv; + + external ffi.Pointer< + ffi.NativeFunction< + JInt Function(ffi.Pointer, ffi.Pointer>, + ffi.Pointer)>> AttachCurrentThreadAsDaemon; +} + +extension JNIInvokeInterfaceExtension on ffi.Pointer { + @pragma('vm:prefer-inline') + int DestroyJavaVM() { + return value.ref.DestroyJavaVM + .asFunction)>()(this); + } + + @pragma('vm:prefer-inline') + int AttachCurrentThread( + ffi.Pointer> p_env, ffi.Pointer thr_args) { + return value.ref.AttachCurrentThread.asFunction< + int Function(ffi.Pointer, ffi.Pointer>, + ffi.Pointer)>()(this, p_env, thr_args); + } + + @pragma('vm:prefer-inline') + int DetachCurrentThread() { + return value.ref.DetachCurrentThread + .asFunction)>()(this); + } + + @pragma('vm:prefer-inline') + int GetEnv(ffi.Pointer> p_env, int version) { + return value.ref.GetEnv.asFunction< + int Function(ffi.Pointer, ffi.Pointer>, + int)>()(this, p_env, version); + } + + @pragma('vm:prefer-inline') + int AttachCurrentThreadAsDaemon( + ffi.Pointer> p_env, ffi.Pointer thr_args) { + return value.ref.AttachCurrentThreadAsDaemon.asFunction< + int Function(ffi.Pointer, ffi.Pointer>, + ffi.Pointer)>()(this, p_env, thr_args); + } +} + +typedef JInt = ffi.Int32; +typedef JavaVM = ffi.Pointer; +typedef JniEnv = ffi.Pointer; + +/// Table of interface function pointers. +class JNINativeInterface extends ffi.Struct { + external ffi.Pointer reserved0; + + external ffi.Pointer reserved1; + + external ffi.Pointer reserved2; + + external ffi.Pointer reserved3; + + external ffi.Pointer)>> + GetVersion; + + external ffi.Pointer< + ffi.NativeFunction< + JClass Function(ffi.Pointer, ffi.Pointer, JObject, + ffi.Pointer, JSize)>> DefineClass; + + external ffi.Pointer< + ffi.NativeFunction< + JClass Function(ffi.Pointer, ffi.Pointer)>> + FindClass; + + external ffi.Pointer< + ffi.NativeFunction, JObject)>> + FromReflectedMethod; + + external ffi.Pointer< + ffi.NativeFunction, JObject)>> + FromReflectedField; + + /// spec doesn't show jboolean parameter + external ffi.Pointer< + ffi.NativeFunction< + JObject Function( + ffi.Pointer, JClass, JMethodID, JBoolean)>> + ToReflectedMethod; + + external ffi.Pointer< + ffi.NativeFunction, JClass)>> + GetSuperclass; + + external ffi.Pointer< + ffi.NativeFunction< + JBoolean Function(ffi.Pointer, JClass, JClass)>> + IsAssignableFrom; + + /// spec doesn't show jboolean parameter + external ffi.Pointer< + ffi.NativeFunction< + JObject Function( + ffi.Pointer, JClass, JFieldID, JBoolean)>> + ToReflectedField; + + external ffi.Pointer< + ffi.NativeFunction, JThrowable)>> + Throw; + + external ffi.Pointer< + ffi.NativeFunction< + JInt Function( + ffi.Pointer, JClass, ffi.Pointer)>> ThrowNew; + + external ffi.Pointer< + ffi.NativeFunction)>> + ExceptionOccurred; + + external ffi + .Pointer)>> + ExceptionDescribe; + + external ffi + .Pointer)>> + ExceptionClear; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer)>> + FatalError; + + external ffi.Pointer< + ffi.NativeFunction, JInt)>> + PushLocalFrame; + + external ffi.Pointer< + ffi.NativeFunction, JObject)>> + PopLocalFrame; + + external ffi.Pointer< + ffi.NativeFunction, JObject)>> + NewGlobalRef; + + external ffi.Pointer< + ffi.NativeFunction, JObject)>> + DeleteGlobalRef; + + external ffi.Pointer< + ffi.NativeFunction, JObject)>> + DeleteLocalRef; + + external ffi.Pointer< + ffi.NativeFunction< + JBoolean Function(ffi.Pointer, JObject, JObject)>> + IsSameObject; + + external ffi.Pointer< + ffi.NativeFunction, JObject)>> + NewLocalRef; + + external ffi.Pointer< + ffi.NativeFunction, JInt)>> + EnsureLocalCapacity; + + external ffi.Pointer< + ffi.NativeFunction, JClass)>> + AllocObject; + + external ffi.Pointer< + ffi.NativeFunction< + JObject Function(ffi.Pointer, JClass, JMethodID)>> NewObject; + + external ffi.Pointer< + ffi.NativeFunction< + JObject Function(ffi.Pointer, JClass, JMethodID, + ffi.Pointer<__va_list_tag>)>> _NewObjectV; + + external ffi.Pointer< + ffi.NativeFunction< + JObject Function(ffi.Pointer, JClass, JMethodID, + ffi.Pointer)>> NewObjectA; + + external ffi.Pointer< + ffi.NativeFunction, JObject)>> + GetObjectClass; + + external ffi.Pointer< + ffi.NativeFunction< + JBoolean Function(ffi.Pointer, JObject, JClass)>> + IsInstanceOf; + + external ffi.Pointer< + ffi.NativeFunction< + JMethodID Function(ffi.Pointer, JClass, + ffi.Pointer, ffi.Pointer)>> GetMethodID; + + external ffi.Pointer< + ffi.NativeFunction< + JObject Function(ffi.Pointer, JObject, JMethodID)>> + CallObjectMethod; + + external ffi.Pointer< + ffi.NativeFunction< + JObject Function(ffi.Pointer, JObject, JMethodID, + ffi.Pointer<__va_list_tag>)>> _CallObjectMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JObject Function(ffi.Pointer, JObject, JMethodID, + ffi.Pointer)>> CallObjectMethodA; + + external ffi.Pointer< + ffi.NativeFunction< + JBoolean Function(ffi.Pointer, JObject, JMethodID)>> + CallBooleanMethod; + + external ffi.Pointer< + ffi.NativeFunction< + JBoolean Function(ffi.Pointer, JObject, JMethodID, + ffi.Pointer<__va_list_tag>)>> _CallBooleanMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JBoolean Function(ffi.Pointer, JObject, JMethodID, + ffi.Pointer)>> CallBooleanMethodA; + + external ffi.Pointer< + ffi.NativeFunction< + JByte Function(ffi.Pointer, JObject, JMethodID)>> + CallByteMethod; + + external ffi.Pointer< + ffi.NativeFunction< + JByte Function(ffi.Pointer, JObject, JMethodID, + ffi.Pointer<__va_list_tag>)>> _CallByteMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JByte Function(ffi.Pointer, JObject, JMethodID, + ffi.Pointer)>> CallByteMethodA; + + external ffi.Pointer< + ffi.NativeFunction< + JChar Function(ffi.Pointer, JObject, JMethodID)>> + CallCharMethod; + + external ffi.Pointer< + ffi.NativeFunction< + JChar Function(ffi.Pointer, JObject, JMethodID, + ffi.Pointer<__va_list_tag>)>> _CallCharMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JChar Function(ffi.Pointer, JObject, JMethodID, + ffi.Pointer)>> CallCharMethodA; + + external ffi.Pointer< + ffi.NativeFunction< + JShort Function(ffi.Pointer, JObject, JMethodID)>> + CallShortMethod; + + external ffi.Pointer< + ffi.NativeFunction< + JShort Function(ffi.Pointer, JObject, JMethodID, + ffi.Pointer<__va_list_tag>)>> _CallShortMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JShort Function(ffi.Pointer, JObject, JMethodID, + ffi.Pointer)>> CallShortMethodA; + + external ffi.Pointer< + ffi.NativeFunction< + JInt Function(ffi.Pointer, JObject, JMethodID)>> + CallIntMethod; + + external ffi.Pointer< + ffi.NativeFunction< + JInt Function(ffi.Pointer, JObject, JMethodID, + ffi.Pointer<__va_list_tag>)>> _CallIntMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JInt Function(ffi.Pointer, JObject, JMethodID, + ffi.Pointer)>> CallIntMethodA; + + external ffi.Pointer< + ffi.NativeFunction< + JLong Function(ffi.Pointer, JObject, JMethodID)>> + CallLongMethod; + + external ffi.Pointer< + ffi.NativeFunction< + JLong Function(ffi.Pointer, JObject, JMethodID, + ffi.Pointer<__va_list_tag>)>> _CallLongMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JLong Function(ffi.Pointer, JObject, JMethodID, + ffi.Pointer)>> CallLongMethodA; + + external ffi.Pointer< + ffi.NativeFunction< + JFloat Function(ffi.Pointer, JObject, JMethodID)>> + CallFloatMethod; + + external ffi.Pointer< + ffi.NativeFunction< + JFloat Function(ffi.Pointer, JObject, JMethodID, + ffi.Pointer<__va_list_tag>)>> _CallFloatMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JFloat Function(ffi.Pointer, JObject, JMethodID, + ffi.Pointer)>> CallFloatMethodA; + + external ffi.Pointer< + ffi.NativeFunction< + JDouble Function(ffi.Pointer, JObject, JMethodID)>> + CallDoubleMethod; + + external ffi.Pointer< + ffi.NativeFunction< + JDouble Function(ffi.Pointer, JObject, JMethodID, + ffi.Pointer<__va_list_tag>)>> _CallDoubleMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JDouble Function(ffi.Pointer, JObject, JMethodID, + ffi.Pointer)>> CallDoubleMethodA; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JObject, JMethodID)>> + CallVoidMethod; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JObject, JMethodID, + ffi.Pointer<__va_list_tag>)>> _CallVoidMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JObject, JMethodID, + ffi.Pointer)>> CallVoidMethodA; + + external ffi.Pointer< + ffi.NativeFunction< + JObject Function( + ffi.Pointer, JObject, JClass, JMethodID)>> + CallNonvirtualObjectMethod; + + external ffi.Pointer< + ffi.NativeFunction< + JObject Function(ffi.Pointer, JObject, JClass, JMethodID, + ffi.Pointer<__va_list_tag>)>> _CallNonvirtualObjectMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JObject Function(ffi.Pointer, JObject, JClass, JMethodID, + ffi.Pointer)>> CallNonvirtualObjectMethodA; + + external ffi.Pointer< + ffi.NativeFunction< + JBoolean Function( + ffi.Pointer, JObject, JClass, JMethodID)>> + CallNonvirtualBooleanMethod; + + external ffi.Pointer< + ffi.NativeFunction< + JBoolean Function(ffi.Pointer, JObject, JClass, JMethodID, + ffi.Pointer<__va_list_tag>)>> _CallNonvirtualBooleanMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JBoolean Function(ffi.Pointer, JObject, JClass, JMethodID, + ffi.Pointer)>> CallNonvirtualBooleanMethodA; + + external ffi.Pointer< + ffi.NativeFunction< + JByte Function(ffi.Pointer, JObject, JClass, JMethodID)>> + CallNonvirtualByteMethod; + + external ffi.Pointer< + ffi.NativeFunction< + JByte Function(ffi.Pointer, JObject, JClass, JMethodID, + ffi.Pointer<__va_list_tag>)>> _CallNonvirtualByteMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JByte Function(ffi.Pointer, JObject, JClass, JMethodID, + ffi.Pointer)>> CallNonvirtualByteMethodA; + + external ffi.Pointer< + ffi.NativeFunction< + JChar Function(ffi.Pointer, JObject, JClass, JMethodID)>> + CallNonvirtualCharMethod; + + external ffi.Pointer< + ffi.NativeFunction< + JChar Function(ffi.Pointer, JObject, JClass, JMethodID, + ffi.Pointer<__va_list_tag>)>> _CallNonvirtualCharMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JChar Function(ffi.Pointer, JObject, JClass, JMethodID, + ffi.Pointer)>> CallNonvirtualCharMethodA; + + external ffi.Pointer< + ffi.NativeFunction< + JShort Function( + ffi.Pointer, JObject, JClass, JMethodID)>> + CallNonvirtualShortMethod; + + external ffi.Pointer< + ffi.NativeFunction< + JShort Function(ffi.Pointer, JObject, JClass, JMethodID, + ffi.Pointer<__va_list_tag>)>> _CallNonvirtualShortMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JShort Function(ffi.Pointer, JObject, JClass, JMethodID, + ffi.Pointer)>> CallNonvirtualShortMethodA; + + external ffi.Pointer< + ffi.NativeFunction< + JInt Function(ffi.Pointer, JObject, JClass, JMethodID)>> + CallNonvirtualIntMethod; + + external ffi.Pointer< + ffi.NativeFunction< + JInt Function(ffi.Pointer, JObject, JClass, JMethodID, + ffi.Pointer<__va_list_tag>)>> _CallNonvirtualIntMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JInt Function(ffi.Pointer, JObject, JClass, JMethodID, + ffi.Pointer)>> CallNonvirtualIntMethodA; + + external ffi.Pointer< + ffi.NativeFunction< + JLong Function(ffi.Pointer, JObject, JClass, JMethodID)>> + CallNonvirtualLongMethod; + + external ffi.Pointer< + ffi.NativeFunction< + JLong Function(ffi.Pointer, JObject, JClass, JMethodID, + ffi.Pointer<__va_list_tag>)>> _CallNonvirtualLongMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JLong Function(ffi.Pointer, JObject, JClass, JMethodID, + ffi.Pointer)>> CallNonvirtualLongMethodA; + + external ffi.Pointer< + ffi.NativeFunction< + JFloat Function( + ffi.Pointer, JObject, JClass, JMethodID)>> + CallNonvirtualFloatMethod; + + external ffi.Pointer< + ffi.NativeFunction< + JFloat Function(ffi.Pointer, JObject, JClass, JMethodID, + ffi.Pointer<__va_list_tag>)>> _CallNonvirtualFloatMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JFloat Function(ffi.Pointer, JObject, JClass, JMethodID, + ffi.Pointer)>> CallNonvirtualFloatMethodA; + + external ffi.Pointer< + ffi.NativeFunction< + JDouble Function( + ffi.Pointer, JObject, JClass, JMethodID)>> + CallNonvirtualDoubleMethod; + + external ffi.Pointer< + ffi.NativeFunction< + JDouble Function(ffi.Pointer, JObject, JClass, JMethodID, + ffi.Pointer<__va_list_tag>)>> _CallNonvirtualDoubleMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JDouble Function(ffi.Pointer, JObject, JClass, JMethodID, + ffi.Pointer)>> CallNonvirtualDoubleMethodA; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, JObject, JClass, JMethodID)>> + CallNonvirtualVoidMethod; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JObject, JClass, JMethodID, + ffi.Pointer<__va_list_tag>)>> _CallNonvirtualVoidMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JObject, JClass, JMethodID, + ffi.Pointer)>> CallNonvirtualVoidMethodA; + + external ffi.Pointer< + ffi.NativeFunction< + JFieldID Function(ffi.Pointer, JClass, ffi.Pointer, + ffi.Pointer)>> GetFieldID; + + external ffi.Pointer< + ffi.NativeFunction< + JObject Function(ffi.Pointer, JObject, JFieldID)>> + GetObjectField; + + external ffi.Pointer< + ffi.NativeFunction< + JBoolean Function(ffi.Pointer, JObject, JFieldID)>> + GetBooleanField; + + external ffi.Pointer< + ffi.NativeFunction< + JByte Function(ffi.Pointer, JObject, JFieldID)>> + GetByteField; + + external ffi.Pointer< + ffi.NativeFunction< + JChar Function(ffi.Pointer, JObject, JFieldID)>> + GetCharField; + + external ffi.Pointer< + ffi.NativeFunction< + JShort Function(ffi.Pointer, JObject, JFieldID)>> + GetShortField; + + external ffi.Pointer< + ffi.NativeFunction< + JInt Function(ffi.Pointer, JObject, JFieldID)>> GetIntField; + + external ffi.Pointer< + ffi.NativeFunction< + JLong Function(ffi.Pointer, JObject, JFieldID)>> + GetLongField; + + external ffi.Pointer< + ffi.NativeFunction< + JFloat Function(ffi.Pointer, JObject, JFieldID)>> + GetFloatField; + + external ffi.Pointer< + ffi.NativeFunction< + JDouble Function(ffi.Pointer, JObject, JFieldID)>> + GetDoubleField; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, JObject, JFieldID, JObject)>> + SetObjectField; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, JObject, JFieldID, JBoolean)>> + SetBooleanField; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, JObject, JFieldID, JByte)>> SetByteField; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, JObject, JFieldID, JChar)>> SetCharField; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, JObject, JFieldID, JShort)>> SetShortField; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JObject, JFieldID, JInt)>> + SetIntField; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, JObject, JFieldID, JLong)>> SetLongField; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, JObject, JFieldID, JFloat)>> SetFloatField; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, JObject, JFieldID, JDouble)>> + SetDoubleField; + + external ffi.Pointer< + ffi.NativeFunction< + JMethodID Function(ffi.Pointer, JClass, + ffi.Pointer, ffi.Pointer)>> GetStaticMethodID; + + external ffi.Pointer< + ffi.NativeFunction< + JObject Function(ffi.Pointer, JClass, JMethodID)>> + CallStaticObjectMethod; + + external ffi.Pointer< + ffi.NativeFunction< + JObject Function(ffi.Pointer, JClass, JMethodID, + ffi.Pointer<__va_list_tag>)>> _CallStaticObjectMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JObject Function(ffi.Pointer, JClass, JMethodID, + ffi.Pointer)>> CallStaticObjectMethodA; + + external ffi.Pointer< + ffi.NativeFunction< + JBoolean Function(ffi.Pointer, JClass, JMethodID)>> + CallStaticBooleanMethod; + + external ffi.Pointer< + ffi.NativeFunction< + JBoolean Function(ffi.Pointer, JClass, JMethodID, + ffi.Pointer<__va_list_tag>)>> _CallStaticBooleanMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JBoolean Function(ffi.Pointer, JClass, JMethodID, + ffi.Pointer)>> CallStaticBooleanMethodA; + + external ffi.Pointer< + ffi.NativeFunction< + JByte Function(ffi.Pointer, JClass, JMethodID)>> + CallStaticByteMethod; + + external ffi.Pointer< + ffi.NativeFunction< + JByte Function(ffi.Pointer, JClass, JMethodID, + ffi.Pointer<__va_list_tag>)>> _CallStaticByteMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JByte Function(ffi.Pointer, JClass, JMethodID, + ffi.Pointer)>> CallStaticByteMethodA; + + external ffi.Pointer< + ffi.NativeFunction< + JChar Function(ffi.Pointer, JClass, JMethodID)>> + CallStaticCharMethod; + + external ffi.Pointer< + ffi.NativeFunction< + JChar Function(ffi.Pointer, JClass, JMethodID, + ffi.Pointer<__va_list_tag>)>> _CallStaticCharMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JChar Function(ffi.Pointer, JClass, JMethodID, + ffi.Pointer)>> CallStaticCharMethodA; + + external ffi.Pointer< + ffi.NativeFunction< + JShort Function(ffi.Pointer, JClass, JMethodID)>> + CallStaticShortMethod; + + external ffi.Pointer< + ffi.NativeFunction< + JShort Function(ffi.Pointer, JClass, JMethodID, + ffi.Pointer<__va_list_tag>)>> _CallStaticShortMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JShort Function(ffi.Pointer, JClass, JMethodID, + ffi.Pointer)>> CallStaticShortMethodA; + + external ffi.Pointer< + ffi.NativeFunction< + JInt Function(ffi.Pointer, JClass, JMethodID)>> + CallStaticIntMethod; + + external ffi.Pointer< + ffi.NativeFunction< + JInt Function(ffi.Pointer, JClass, JMethodID, + ffi.Pointer<__va_list_tag>)>> _CallStaticIntMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JInt Function(ffi.Pointer, JClass, JMethodID, + ffi.Pointer)>> CallStaticIntMethodA; + + external ffi.Pointer< + ffi.NativeFunction< + JLong Function(ffi.Pointer, JClass, JMethodID)>> + CallStaticLongMethod; + + external ffi.Pointer< + ffi.NativeFunction< + JLong Function(ffi.Pointer, JClass, JMethodID, + ffi.Pointer<__va_list_tag>)>> _CallStaticLongMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JLong Function(ffi.Pointer, JClass, JMethodID, + ffi.Pointer)>> CallStaticLongMethodA; + + external ffi.Pointer< + ffi.NativeFunction< + JFloat Function(ffi.Pointer, JClass, JMethodID)>> + CallStaticFloatMethod; + + external ffi.Pointer< + ffi.NativeFunction< + JFloat Function(ffi.Pointer, JClass, JMethodID, + ffi.Pointer<__va_list_tag>)>> _CallStaticFloatMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JFloat Function(ffi.Pointer, JClass, JMethodID, + ffi.Pointer)>> CallStaticFloatMethodA; + + external ffi.Pointer< + ffi.NativeFunction< + JDouble Function(ffi.Pointer, JClass, JMethodID)>> + CallStaticDoubleMethod; + + external ffi.Pointer< + ffi.NativeFunction< + JDouble Function(ffi.Pointer, JClass, JMethodID, + ffi.Pointer<__va_list_tag>)>> _CallStaticDoubleMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JDouble Function(ffi.Pointer, JClass, JMethodID, + ffi.Pointer)>> CallStaticDoubleMethodA; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JClass, JMethodID)>> + CallStaticVoidMethod; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JClass, JMethodID, + ffi.Pointer<__va_list_tag>)>> _CallStaticVoidMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JClass, JMethodID, + ffi.Pointer)>> CallStaticVoidMethodA; + + external ffi.Pointer< + ffi.NativeFunction< + JFieldID Function(ffi.Pointer, JClass, ffi.Pointer, + ffi.Pointer)>> GetStaticFieldID; + + external ffi.Pointer< + ffi.NativeFunction< + JObject Function(ffi.Pointer, JClass, JFieldID)>> + GetStaticObjectField; + + external ffi.Pointer< + ffi.NativeFunction< + JBoolean Function(ffi.Pointer, JClass, JFieldID)>> + GetStaticBooleanField; + + external ffi.Pointer< + ffi.NativeFunction< + JByte Function(ffi.Pointer, JClass, JFieldID)>> + GetStaticByteField; + + external ffi.Pointer< + ffi.NativeFunction< + JChar Function(ffi.Pointer, JClass, JFieldID)>> + GetStaticCharField; + + external ffi.Pointer< + ffi.NativeFunction< + JShort Function(ffi.Pointer, JClass, JFieldID)>> + GetStaticShortField; + + external ffi.Pointer< + ffi.NativeFunction< + JInt Function(ffi.Pointer, JClass, JFieldID)>> + GetStaticIntField; + + external ffi.Pointer< + ffi.NativeFunction< + JLong Function(ffi.Pointer, JClass, JFieldID)>> + GetStaticLongField; + + external ffi.Pointer< + ffi.NativeFunction< + JFloat Function(ffi.Pointer, JClass, JFieldID)>> + GetStaticFloatField; + + external ffi.Pointer< + ffi.NativeFunction< + JDouble Function(ffi.Pointer, JClass, JFieldID)>> + GetStaticDoubleField; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, JClass, JFieldID, JObject)>> + SetStaticObjectField; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, JClass, JFieldID, JBoolean)>> + SetStaticBooleanField; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JClass, JFieldID, JByte)>> + SetStaticByteField; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JClass, JFieldID, JChar)>> + SetStaticCharField; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, JClass, JFieldID, JShort)>> + SetStaticShortField; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JClass, JFieldID, JInt)>> + SetStaticIntField; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JClass, JFieldID, JLong)>> + SetStaticLongField; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, JClass, JFieldID, JFloat)>> + SetStaticFloatField; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, JClass, JFieldID, JDouble)>> + SetStaticDoubleField; + + external ffi.Pointer< + ffi.NativeFunction< + JString Function( + ffi.Pointer, ffi.Pointer, JSize)>> NewString; + + external ffi.Pointer< + ffi.NativeFunction, JString)>> + GetStringLength; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, JString, ffi.Pointer)>> + GetStringChars; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, JString, ffi.Pointer)>> + ReleaseStringChars; + + external ffi.Pointer< + ffi.NativeFunction< + JString Function(ffi.Pointer, ffi.Pointer)>> + NewStringUTF; + + external ffi.Pointer< + ffi.NativeFunction, JString)>> + GetStringUTFLength; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, JString, ffi.Pointer)>> + GetStringUTFChars; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, JString, ffi.Pointer)>> + ReleaseStringUTFChars; + + external ffi.Pointer< + ffi.NativeFunction, JArray)>> + GetArrayLength; + + external ffi.Pointer< + ffi.NativeFunction< + JObjectArray Function( + ffi.Pointer, JSize, JClass, JObject)>> NewObjectArray; + + external ffi.Pointer< + ffi.NativeFunction< + JObject Function(ffi.Pointer, JObjectArray, JSize)>> + GetObjectArrayElement; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, JObjectArray, JSize, JObject)>> + SetObjectArrayElement; + + external ffi.Pointer< + ffi.NativeFunction< + JBooleanArray Function(ffi.Pointer, JSize)>> NewBooleanArray; + + external ffi.Pointer< + ffi.NativeFunction, JSize)>> + NewByteArray; + + external ffi.Pointer< + ffi.NativeFunction, JSize)>> + NewCharArray; + + external ffi.Pointer< + ffi.NativeFunction, JSize)>> + NewShortArray; + + external ffi.Pointer< + ffi.NativeFunction, JSize)>> + NewIntArray; + + external ffi.Pointer< + ffi.NativeFunction, JSize)>> + NewLongArray; + + external ffi.Pointer< + ffi.NativeFunction, JSize)>> + NewFloatArray; + + external ffi.Pointer< + ffi.NativeFunction< + JDoubleArray Function(ffi.Pointer, JSize)>> NewDoubleArray; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, JBooleanArray, ffi.Pointer)>> + GetBooleanArrayElements; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, JByteArray, ffi.Pointer)>> + GetByteArrayElements; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, JCharArray, ffi.Pointer)>> + GetCharArrayElements; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, JShortArray, ffi.Pointer)>> + GetShortArrayElements; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, JIntArray, ffi.Pointer)>> + GetIntArrayElements; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, JLongArray, ffi.Pointer)>> + GetLongArrayElements; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, JFloatArray, ffi.Pointer)>> + GetFloatArrayElements; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, JDoubleArray, ffi.Pointer)>> + GetDoubleArrayElements; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JBooleanArray, + ffi.Pointer, JInt)>> ReleaseBooleanArrayElements; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, JByteArray, ffi.Pointer, JInt)>> + ReleaseByteArrayElements; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, JCharArray, ffi.Pointer, JInt)>> + ReleaseCharArrayElements; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JShortArray, + ffi.Pointer, JInt)>> ReleaseShortArrayElements; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, JIntArray, ffi.Pointer, JInt)>> + ReleaseIntArrayElements; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, JLongArray, ffi.Pointer, JInt)>> + ReleaseLongArrayElements; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JFloatArray, + ffi.Pointer, JInt)>> ReleaseFloatArrayElements; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JDoubleArray, + ffi.Pointer, JInt)>> ReleaseDoubleArrayElements; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JBooleanArray, JSize, JSize, + ffi.Pointer)>> GetBooleanArrayRegion; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JByteArray, JSize, JSize, + ffi.Pointer)>> GetByteArrayRegion; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JCharArray, JSize, JSize, + ffi.Pointer)>> GetCharArrayRegion; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JShortArray, JSize, JSize, + ffi.Pointer)>> GetShortArrayRegion; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JIntArray, JSize, JSize, + ffi.Pointer)>> GetIntArrayRegion; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JLongArray, JSize, JSize, + ffi.Pointer)>> GetLongArrayRegion; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JFloatArray, JSize, JSize, + ffi.Pointer)>> GetFloatArrayRegion; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JDoubleArray, JSize, JSize, + ffi.Pointer)>> GetDoubleArrayRegion; + + /// spec shows these without const; some jni.h do, some don't + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JBooleanArray, JSize, JSize, + ffi.Pointer)>> SetBooleanArrayRegion; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JByteArray, JSize, JSize, + ffi.Pointer)>> SetByteArrayRegion; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JCharArray, JSize, JSize, + ffi.Pointer)>> SetCharArrayRegion; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JShortArray, JSize, JSize, + ffi.Pointer)>> SetShortArrayRegion; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JIntArray, JSize, JSize, + ffi.Pointer)>> SetIntArrayRegion; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JLongArray, JSize, JSize, + ffi.Pointer)>> SetLongArrayRegion; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JFloatArray, JSize, JSize, + ffi.Pointer)>> SetFloatArrayRegion; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JDoubleArray, JSize, JSize, + ffi.Pointer)>> SetDoubleArrayRegion; + + external ffi.Pointer< + ffi.NativeFunction< + JInt Function(ffi.Pointer, JClass, + ffi.Pointer, JInt)>> RegisterNatives; + + external ffi.Pointer< + ffi.NativeFunction, JClass)>> + UnregisterNatives; + + external ffi.Pointer< + ffi.NativeFunction, JObject)>> + MonitorEnter; + + external ffi.Pointer< + ffi.NativeFunction, JObject)>> + MonitorExit; + + external ffi.Pointer< + ffi.NativeFunction< + JInt Function( + ffi.Pointer, ffi.Pointer>)>> + GetJavaVM; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JString, JSize, JSize, + ffi.Pointer)>> GetStringRegion; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JString, JSize, JSize, + ffi.Pointer)>> GetStringUTFRegion; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, JArray, ffi.Pointer)>> + GetPrimitiveArrayCritical; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, JArray, ffi.Pointer, JInt)>> + ReleasePrimitiveArrayCritical; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, JString, ffi.Pointer)>> + GetStringCritical; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, JString, ffi.Pointer)>> + ReleaseStringCritical; + + external ffi.Pointer< + ffi.NativeFunction, JObject)>> + NewWeakGlobalRef; + + external ffi.Pointer< + ffi.NativeFunction, JWeak)>> + DeleteWeakGlobalRef; + + external ffi + .Pointer)>> + ExceptionCheck; + + external ffi.Pointer< + ffi.NativeFunction< + JObject Function( + ffi.Pointer, ffi.Pointer, JLong)>> + NewDirectByteBuffer; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, JObject)>> + GetDirectBufferAddress; + + external ffi.Pointer< + ffi.NativeFunction, JObject)>> + GetDirectBufferCapacity; + + /// added in JNI 1.6 + external ffi.Pointer< + ffi.NativeFunction, JObject)>> + GetObjectRefType; +} + +extension JNINativeInterfaceExtension on ffi.Pointer { + @pragma('vm:prefer-inline') + int GetVersion() { + return value.ref.GetVersion + .asFunction)>()(this); + } + + @pragma('vm:prefer-inline') + JClass DefineClass(ffi.Pointer name, JObject loader, + ffi.Pointer buf, int bufLen) { + return value.ref.DefineClass.asFunction< + JClass Function(ffi.Pointer, ffi.Pointer, JObject, + ffi.Pointer, int)>()(this, name, loader, buf, bufLen); + } + + @pragma('vm:prefer-inline') + JClass FindClass(ffi.Pointer name) { + return value.ref.FindClass.asFunction< + JClass Function( + ffi.Pointer, ffi.Pointer)>()(this, name); + } + + @pragma('vm:prefer-inline') + JMethodID FromReflectedMethod(JObject method) { + return value.ref.FromReflectedMethod + .asFunction, JObject)>()( + this, method); + } + + @pragma('vm:prefer-inline') + JFieldID FromReflectedField(JObject field) { + return value.ref.FromReflectedField + .asFunction, JObject)>()( + this, field); + } + + /// spec doesn't show jboolean parameter + /// + /// This is an automatically generated extension method + @pragma('vm:prefer-inline') + JObject ToReflectedMethod(JClass cls, JMethodID methodId, int isStatic) { + return value.ref.ToReflectedMethod.asFunction< + JObject Function(ffi.Pointer, JClass, JMethodID, int)>()( + this, cls, methodId, isStatic); + } + + @pragma('vm:prefer-inline') + JClass GetSuperclass(JClass clazz) { + return value.ref.GetSuperclass + .asFunction, JClass)>()( + this, clazz); + } + + @pragma('vm:prefer-inline') + int IsAssignableFrom(JClass clazz1, JClass clazz2) { + return value.ref.IsAssignableFrom + .asFunction, JClass, JClass)>()( + this, clazz1, clazz2); + } + + /// spec doesn't show jboolean parameter + /// + /// This is an automatically generated extension method + @pragma('vm:prefer-inline') + JObject ToReflectedField(JClass cls, JFieldID fieldID, int isStatic) { + return value.ref.ToReflectedField.asFunction< + JObject Function(ffi.Pointer, JClass, JFieldID, int)>()( + this, cls, fieldID, isStatic); + } + + @pragma('vm:prefer-inline') + int Throw(JThrowable obj) { + return value.ref.Throw + .asFunction, JThrowable)>()( + this, obj); + } + + @pragma('vm:prefer-inline') + int ThrowNew(JClass clazz, ffi.Pointer message) { + return value.ref.ThrowNew.asFunction< + int Function(ffi.Pointer, JClass, + ffi.Pointer)>()(this, clazz, message); + } + + @pragma('vm:prefer-inline') + JThrowable ExceptionOccurred() { + return value.ref.ExceptionOccurred + .asFunction)>()(this); + } + + @pragma('vm:prefer-inline') + void ExceptionDescribe() { + return value.ref.ExceptionDescribe + .asFunction)>()(this); + } + + @pragma('vm:prefer-inline') + void ExceptionClear() { + return value.ref.ExceptionClear + .asFunction)>()(this); + } + + @pragma('vm:prefer-inline') + void FatalError(ffi.Pointer msg) { + return value.ref.FatalError.asFunction< + void Function( + ffi.Pointer, ffi.Pointer)>()(this, msg); + } + + @pragma('vm:prefer-inline') + int PushLocalFrame(int capacity) { + return value.ref.PushLocalFrame + .asFunction, int)>()(this, capacity); + } + + @pragma('vm:prefer-inline') + JObject PopLocalFrame(JObject result) { + return value.ref.PopLocalFrame + .asFunction, JObject)>()( + this, result); + } + + @pragma('vm:prefer-inline') + JObject NewGlobalRef(JObject obj) { + return value.ref.NewGlobalRef + .asFunction, JObject)>()( + this, obj); + } + + @pragma('vm:prefer-inline') + void DeleteGlobalRef(JObject globalRef) { + return value.ref.DeleteGlobalRef + .asFunction, JObject)>()( + this, globalRef); + } + + @pragma('vm:prefer-inline') + void DeleteLocalRef(JObject localRef) { + return value.ref.DeleteLocalRef + .asFunction, JObject)>()( + this, localRef); + } + + @pragma('vm:prefer-inline') + int IsSameObject(JObject ref1, JObject ref2) { + return value.ref.IsSameObject + .asFunction, JObject, JObject)>()( + this, ref1, ref2); + } + + @pragma('vm:prefer-inline') + JObject NewLocalRef(JObject ref) { + return value.ref.NewLocalRef + .asFunction, JObject)>()( + this, ref); + } + + @pragma('vm:prefer-inline') + int EnsureLocalCapacity(int capacity) { + return value.ref.EnsureLocalCapacity + .asFunction, int)>()(this, capacity); + } + + @pragma('vm:prefer-inline') + JObject AllocObject(JClass clazz) { + return value.ref.AllocObject + .asFunction, JClass)>()( + this, clazz); + } + + @pragma('vm:prefer-inline') + JObject NewObject(JClass arg0, JMethodID arg1) { + return value.ref.NewObject.asFunction< + JObject Function( + ffi.Pointer, JClass, JMethodID)>()(this, arg0, arg1); + } + + @pragma('vm:prefer-inline') + JObject NewObjectA( + JClass clazz, JMethodID methodID, ffi.Pointer args) { + return value.ref.NewObjectA.asFunction< + JObject Function(ffi.Pointer, JClass, JMethodID, + ffi.Pointer)>()(this, clazz, methodID, args); + } + + @pragma('vm:prefer-inline') + JClass GetObjectClass(JObject obj) { + return value.ref.GetObjectClass + .asFunction, JObject)>()( + this, obj); + } + + @pragma('vm:prefer-inline') + int IsInstanceOf(JObject obj, JClass clazz) { + return value.ref.IsInstanceOf + .asFunction, JObject, JClass)>()( + this, obj, clazz); + } + + @pragma('vm:prefer-inline') + JMethodID GetMethodID( + JClass clazz, ffi.Pointer name, ffi.Pointer sig) { + return value.ref.GetMethodID.asFunction< + JMethodID Function(ffi.Pointer, JClass, ffi.Pointer, + ffi.Pointer)>()(this, clazz, name, sig); + } + + @pragma('vm:prefer-inline') + JObject CallObjectMethod(JObject arg0, JMethodID arg1) { + return value.ref.CallObjectMethod.asFunction< + JObject Function( + ffi.Pointer, JObject, JMethodID)>()(this, arg0, arg1); + } + + @pragma('vm:prefer-inline') + JObject CallObjectMethodA( + JObject obj, JMethodID methodID, ffi.Pointer args) { + return value.ref.CallObjectMethodA.asFunction< + JObject Function(ffi.Pointer, JObject, JMethodID, + ffi.Pointer)>()(this, obj, methodID, args); + } + + @pragma('vm:prefer-inline') + int CallBooleanMethod(JObject arg0, JMethodID arg1) { + return value.ref.CallBooleanMethod.asFunction< + int Function( + ffi.Pointer, JObject, JMethodID)>()(this, arg0, arg1); + } + + @pragma('vm:prefer-inline') + int CallBooleanMethodA( + JObject obj, JMethodID methodId, ffi.Pointer args) { + return value.ref.CallBooleanMethodA.asFunction< + int Function(ffi.Pointer, JObject, JMethodID, + ffi.Pointer)>()(this, obj, methodId, args); + } + + @pragma('vm:prefer-inline') + int CallByteMethod(JObject arg0, JMethodID arg1) { + return value.ref.CallByteMethod.asFunction< + int Function( + ffi.Pointer, JObject, JMethodID)>()(this, arg0, arg1); + } + + @pragma('vm:prefer-inline') + int CallByteMethodA( + JObject obj, JMethodID methodID, ffi.Pointer args) { + return value.ref.CallByteMethodA.asFunction< + int Function(ffi.Pointer, JObject, JMethodID, + ffi.Pointer)>()(this, obj, methodID, args); + } + + @pragma('vm:prefer-inline') + int CallCharMethod(JObject arg0, JMethodID arg1) { + return value.ref.CallCharMethod.asFunction< + int Function( + ffi.Pointer, JObject, JMethodID)>()(this, arg0, arg1); + } + + @pragma('vm:prefer-inline') + int CallCharMethodA( + JObject obj, JMethodID methodID, ffi.Pointer args) { + return value.ref.CallCharMethodA.asFunction< + int Function(ffi.Pointer, JObject, JMethodID, + ffi.Pointer)>()(this, obj, methodID, args); + } + + @pragma('vm:prefer-inline') + int CallShortMethod(JObject arg0, JMethodID arg1) { + return value.ref.CallShortMethod.asFunction< + int Function( + ffi.Pointer, JObject, JMethodID)>()(this, arg0, arg1); + } + + @pragma('vm:prefer-inline') + int CallShortMethodA( + JObject obj, JMethodID methodID, ffi.Pointer args) { + return value.ref.CallShortMethodA.asFunction< + int Function(ffi.Pointer, JObject, JMethodID, + ffi.Pointer)>()(this, obj, methodID, args); + } + + @pragma('vm:prefer-inline') + int CallIntMethod(JObject arg0, JMethodID arg1) { + return value.ref.CallIntMethod.asFunction< + int Function( + ffi.Pointer, JObject, JMethodID)>()(this, arg0, arg1); + } + + @pragma('vm:prefer-inline') + int CallIntMethodA( + JObject obj, JMethodID methodID, ffi.Pointer args) { + return value.ref.CallIntMethodA.asFunction< + int Function(ffi.Pointer, JObject, JMethodID, + ffi.Pointer)>()(this, obj, methodID, args); + } + + @pragma('vm:prefer-inline') + int CallLongMethod(JObject arg0, JMethodID arg1) { + return value.ref.CallLongMethod.asFunction< + int Function( + ffi.Pointer, JObject, JMethodID)>()(this, arg0, arg1); + } + + @pragma('vm:prefer-inline') + int CallLongMethodA( + JObject obj, JMethodID methodID, ffi.Pointer args) { + return value.ref.CallLongMethodA.asFunction< + int Function(ffi.Pointer, JObject, JMethodID, + ffi.Pointer)>()(this, obj, methodID, args); + } + + @pragma('vm:prefer-inline') + double CallFloatMethod(JObject arg0, JMethodID arg1) { + return value.ref.CallFloatMethod.asFunction< + double Function( + ffi.Pointer, JObject, JMethodID)>()(this, arg0, arg1); + } + + @pragma('vm:prefer-inline') + double CallFloatMethodA( + JObject obj, JMethodID methodID, ffi.Pointer args) { + return value.ref.CallFloatMethodA.asFunction< + double Function(ffi.Pointer, JObject, JMethodID, + ffi.Pointer)>()(this, obj, methodID, args); + } + + @pragma('vm:prefer-inline') + double CallDoubleMethod(JObject arg0, JMethodID arg1) { + return value.ref.CallDoubleMethod.asFunction< + double Function( + ffi.Pointer, JObject, JMethodID)>()(this, arg0, arg1); + } + + @pragma('vm:prefer-inline') + double CallDoubleMethodA( + JObject obj, JMethodID methodID, ffi.Pointer args) { + return value.ref.CallDoubleMethodA.asFunction< + double Function(ffi.Pointer, JObject, JMethodID, + ffi.Pointer)>()(this, obj, methodID, args); + } + + @pragma('vm:prefer-inline') + void CallVoidMethod(JObject arg0, JMethodID arg1) { + return value.ref.CallVoidMethod.asFunction< + void Function( + ffi.Pointer, JObject, JMethodID)>()(this, arg0, arg1); + } + + @pragma('vm:prefer-inline') + void CallVoidMethodA( + JObject obj, JMethodID methodID, ffi.Pointer args) { + return value.ref.CallVoidMethodA.asFunction< + void Function(ffi.Pointer, JObject, JMethodID, + ffi.Pointer)>()(this, obj, methodID, args); + } + + @pragma('vm:prefer-inline') + JObject CallNonvirtualObjectMethod( + JObject arg0, JClass arg1, JMethodID arg2) { + return value.ref.CallNonvirtualObjectMethod.asFunction< + JObject Function(ffi.Pointer, JObject, JClass, + JMethodID)>()(this, arg0, arg1, arg2); + } + + @pragma('vm:prefer-inline') + JObject CallNonvirtualObjectMethodA( + JObject obj, JClass clazz, JMethodID methodID, ffi.Pointer args) { + return value.ref.CallNonvirtualObjectMethodA.asFunction< + JObject Function(ffi.Pointer, JObject, JClass, JMethodID, + ffi.Pointer)>()(this, obj, clazz, methodID, args); + } + + @pragma('vm:prefer-inline') + int CallNonvirtualBooleanMethod(JObject arg0, JClass arg1, JMethodID arg2) { + return value.ref.CallNonvirtualBooleanMethod.asFunction< + int Function(ffi.Pointer, JObject, JClass, JMethodID)>()( + this, arg0, arg1, arg2); + } + + @pragma('vm:prefer-inline') + int CallNonvirtualBooleanMethodA( + JObject obj, JClass clazz, JMethodID methodID, ffi.Pointer args) { + return value.ref.CallNonvirtualBooleanMethodA.asFunction< + int Function(ffi.Pointer, JObject, JClass, JMethodID, + ffi.Pointer)>()(this, obj, clazz, methodID, args); + } + + @pragma('vm:prefer-inline') + int CallNonvirtualByteMethod(JObject arg0, JClass arg1, JMethodID arg2) { + return value.ref.CallNonvirtualByteMethod.asFunction< + int Function(ffi.Pointer, JObject, JClass, JMethodID)>()( + this, arg0, arg1, arg2); + } + + @pragma('vm:prefer-inline') + int CallNonvirtualByteMethodA( + JObject obj, JClass clazz, JMethodID methodID, ffi.Pointer args) { + return value.ref.CallNonvirtualByteMethodA.asFunction< + int Function(ffi.Pointer, JObject, JClass, JMethodID, + ffi.Pointer)>()(this, obj, clazz, methodID, args); + } + + @pragma('vm:prefer-inline') + int CallNonvirtualCharMethod(JObject arg0, JClass arg1, JMethodID arg2) { + return value.ref.CallNonvirtualCharMethod.asFunction< + int Function(ffi.Pointer, JObject, JClass, JMethodID)>()( + this, arg0, arg1, arg2); + } + + @pragma('vm:prefer-inline') + int CallNonvirtualCharMethodA( + JObject obj, JClass clazz, JMethodID methodID, ffi.Pointer args) { + return value.ref.CallNonvirtualCharMethodA.asFunction< + int Function(ffi.Pointer, JObject, JClass, JMethodID, + ffi.Pointer)>()(this, obj, clazz, methodID, args); + } + + @pragma('vm:prefer-inline') + int CallNonvirtualShortMethod(JObject arg0, JClass arg1, JMethodID arg2) { + return value.ref.CallNonvirtualShortMethod.asFunction< + int Function(ffi.Pointer, JObject, JClass, JMethodID)>()( + this, arg0, arg1, arg2); + } + + @pragma('vm:prefer-inline') + int CallNonvirtualShortMethodA( + JObject obj, JClass clazz, JMethodID methodID, ffi.Pointer args) { + return value.ref.CallNonvirtualShortMethodA.asFunction< + int Function(ffi.Pointer, JObject, JClass, JMethodID, + ffi.Pointer)>()(this, obj, clazz, methodID, args); + } + + @pragma('vm:prefer-inline') + int CallNonvirtualIntMethod(JObject arg0, JClass arg1, JMethodID arg2) { + return value.ref.CallNonvirtualIntMethod.asFunction< + int Function(ffi.Pointer, JObject, JClass, JMethodID)>()( + this, arg0, arg1, arg2); + } + + @pragma('vm:prefer-inline') + int CallNonvirtualIntMethodA( + JObject obj, JClass clazz, JMethodID methodID, ffi.Pointer args) { + return value.ref.CallNonvirtualIntMethodA.asFunction< + int Function(ffi.Pointer, JObject, JClass, JMethodID, + ffi.Pointer)>()(this, obj, clazz, methodID, args); + } + + @pragma('vm:prefer-inline') + int CallNonvirtualLongMethod(JObject arg0, JClass arg1, JMethodID arg2) { + return value.ref.CallNonvirtualLongMethod.asFunction< + int Function(ffi.Pointer, JObject, JClass, JMethodID)>()( + this, arg0, arg1, arg2); + } + + @pragma('vm:prefer-inline') + int CallNonvirtualLongMethodA( + JObject obj, JClass clazz, JMethodID methodID, ffi.Pointer args) { + return value.ref.CallNonvirtualLongMethodA.asFunction< + int Function(ffi.Pointer, JObject, JClass, JMethodID, + ffi.Pointer)>()(this, obj, clazz, methodID, args); + } + + @pragma('vm:prefer-inline') + double CallNonvirtualFloatMethod(JObject arg0, JClass arg1, JMethodID arg2) { + return value.ref.CallNonvirtualFloatMethod.asFunction< + double Function(ffi.Pointer, JObject, JClass, + JMethodID)>()(this, arg0, arg1, arg2); + } + + @pragma('vm:prefer-inline') + double CallNonvirtualFloatMethodA( + JObject obj, JClass clazz, JMethodID methodID, ffi.Pointer args) { + return value.ref.CallNonvirtualFloatMethodA.asFunction< + double Function(ffi.Pointer, JObject, JClass, JMethodID, + ffi.Pointer)>()(this, obj, clazz, methodID, args); + } + + @pragma('vm:prefer-inline') + double CallNonvirtualDoubleMethod(JObject arg0, JClass arg1, JMethodID arg2) { + return value.ref.CallNonvirtualDoubleMethod.asFunction< + double Function(ffi.Pointer, JObject, JClass, + JMethodID)>()(this, arg0, arg1, arg2); + } + + @pragma('vm:prefer-inline') + double CallNonvirtualDoubleMethodA( + JObject obj, JClass clazz, JMethodID methodID, ffi.Pointer args) { + return value.ref.CallNonvirtualDoubleMethodA.asFunction< + double Function(ffi.Pointer, JObject, JClass, JMethodID, + ffi.Pointer)>()(this, obj, clazz, methodID, args); + } + + @pragma('vm:prefer-inline') + void CallNonvirtualVoidMethod(JObject arg0, JClass arg1, JMethodID arg2) { + return value.ref.CallNonvirtualVoidMethod.asFunction< + void Function(ffi.Pointer, JObject, JClass, JMethodID)>()( + this, arg0, arg1, arg2); + } + + @pragma('vm:prefer-inline') + void CallNonvirtualVoidMethodA( + JObject obj, JClass clazz, JMethodID methodID, ffi.Pointer args) { + return value.ref.CallNonvirtualVoidMethodA.asFunction< + void Function(ffi.Pointer, JObject, JClass, JMethodID, + ffi.Pointer)>()(this, obj, clazz, methodID, args); + } + + @pragma('vm:prefer-inline') + JFieldID GetFieldID( + JClass clazz, ffi.Pointer name, ffi.Pointer sig) { + return value.ref.GetFieldID.asFunction< + JFieldID Function(ffi.Pointer, JClass, ffi.Pointer, + ffi.Pointer)>()(this, clazz, name, sig); + } + + @pragma('vm:prefer-inline') + JObject GetObjectField(JObject obj, JFieldID fieldID) { + return value.ref.GetObjectField.asFunction< + JObject Function( + ffi.Pointer, JObject, JFieldID)>()(this, obj, fieldID); + } + + @pragma('vm:prefer-inline') + int GetBooleanField(JObject obj, JFieldID fieldID) { + return value.ref.GetBooleanField.asFunction< + int Function( + ffi.Pointer, JObject, JFieldID)>()(this, obj, fieldID); + } + + @pragma('vm:prefer-inline') + int GetByteField(JObject obj, JFieldID fieldID) { + return value.ref.GetByteField.asFunction< + int Function( + ffi.Pointer, JObject, JFieldID)>()(this, obj, fieldID); + } + + @pragma('vm:prefer-inline') + int GetCharField(JObject obj, JFieldID fieldID) { + return value.ref.GetCharField.asFunction< + int Function( + ffi.Pointer, JObject, JFieldID)>()(this, obj, fieldID); + } + + @pragma('vm:prefer-inline') + int GetShortField(JObject obj, JFieldID fieldID) { + return value.ref.GetShortField.asFunction< + int Function( + ffi.Pointer, JObject, JFieldID)>()(this, obj, fieldID); + } + + @pragma('vm:prefer-inline') + int GetIntField(JObject obj, JFieldID fieldID) { + return value.ref.GetIntField.asFunction< + int Function( + ffi.Pointer, JObject, JFieldID)>()(this, obj, fieldID); + } + + @pragma('vm:prefer-inline') + int GetLongField(JObject obj, JFieldID fieldID) { + return value.ref.GetLongField.asFunction< + int Function( + ffi.Pointer, JObject, JFieldID)>()(this, obj, fieldID); + } + + @pragma('vm:prefer-inline') + double GetFloatField(JObject obj, JFieldID fieldID) { + return value.ref.GetFloatField.asFunction< + double Function( + ffi.Pointer, JObject, JFieldID)>()(this, obj, fieldID); + } + + @pragma('vm:prefer-inline') + double GetDoubleField(JObject obj, JFieldID fieldID) { + return value.ref.GetDoubleField.asFunction< + double Function( + ffi.Pointer, JObject, JFieldID)>()(this, obj, fieldID); + } + + @pragma('vm:prefer-inline') + void SetObjectField(JObject obj, JFieldID fieldID, JObject val) { + return value.ref.SetObjectField.asFunction< + void Function(ffi.Pointer, JObject, JFieldID, JObject)>()( + this, obj, fieldID, val); + } + + @pragma('vm:prefer-inline') + void SetBooleanField(JObject obj, JFieldID fieldID, int val) { + return value.ref.SetBooleanField.asFunction< + void Function(ffi.Pointer, JObject, JFieldID, int)>()( + this, obj, fieldID, val); + } + + @pragma('vm:prefer-inline') + void SetByteField(JObject obj, JFieldID fieldID, int val) { + return value.ref.SetByteField.asFunction< + void Function(ffi.Pointer, JObject, JFieldID, int)>()( + this, obj, fieldID, val); + } + + @pragma('vm:prefer-inline') + void SetCharField(JObject obj, JFieldID fieldID, int val) { + return value.ref.SetCharField.asFunction< + void Function(ffi.Pointer, JObject, JFieldID, int)>()( + this, obj, fieldID, val); + } + + @pragma('vm:prefer-inline') + void SetShortField(JObject obj, JFieldID fieldID, int val) { + return value.ref.SetShortField.asFunction< + void Function(ffi.Pointer, JObject, JFieldID, int)>()( + this, obj, fieldID, val); + } + + @pragma('vm:prefer-inline') + void SetIntField(JObject obj, JFieldID fieldID, int val) { + return value.ref.SetIntField.asFunction< + void Function(ffi.Pointer, JObject, JFieldID, int)>()( + this, obj, fieldID, val); + } + + @pragma('vm:prefer-inline') + void SetLongField(JObject obj, JFieldID fieldID, int val) { + return value.ref.SetLongField.asFunction< + void Function(ffi.Pointer, JObject, JFieldID, int)>()( + this, obj, fieldID, val); + } + + @pragma('vm:prefer-inline') + void SetFloatField(JObject obj, JFieldID fieldID, double val) { + return value.ref.SetFloatField.asFunction< + void Function(ffi.Pointer, JObject, JFieldID, double)>()( + this, obj, fieldID, val); + } + + @pragma('vm:prefer-inline') + void SetDoubleField(JObject obj, JFieldID fieldID, double val) { + return value.ref.SetDoubleField.asFunction< + void Function(ffi.Pointer, JObject, JFieldID, double)>()( + this, obj, fieldID, val); + } + + @pragma('vm:prefer-inline') + JMethodID GetStaticMethodID( + JClass clazz, ffi.Pointer name, ffi.Pointer sig) { + return value.ref.GetStaticMethodID.asFunction< + JMethodID Function(ffi.Pointer, JClass, ffi.Pointer, + ffi.Pointer)>()(this, clazz, name, sig); + } + + @pragma('vm:prefer-inline') + JObject CallStaticObjectMethod(JClass arg0, JMethodID arg1) { + return value.ref.CallStaticObjectMethod.asFunction< + JObject Function( + ffi.Pointer, JClass, JMethodID)>()(this, arg0, arg1); + } + + @pragma('vm:prefer-inline') + JObject CallStaticObjectMethodA( + JClass clazz, JMethodID methodID, ffi.Pointer args) { + return value.ref.CallStaticObjectMethodA.asFunction< + JObject Function(ffi.Pointer, JClass, JMethodID, + ffi.Pointer)>()(this, clazz, methodID, args); + } + + @pragma('vm:prefer-inline') + int CallStaticBooleanMethod(JClass arg0, JMethodID arg1) { + return value.ref.CallStaticBooleanMethod.asFunction< + int Function( + ffi.Pointer, JClass, JMethodID)>()(this, arg0, arg1); + } + + @pragma('vm:prefer-inline') + int CallStaticBooleanMethodA( + JClass clazz, JMethodID methodID, ffi.Pointer args) { + return value.ref.CallStaticBooleanMethodA.asFunction< + int Function(ffi.Pointer, JClass, JMethodID, + ffi.Pointer)>()(this, clazz, methodID, args); + } + + @pragma('vm:prefer-inline') + int CallStaticByteMethod(JClass arg0, JMethodID arg1) { + return value.ref.CallStaticByteMethod.asFunction< + int Function( + ffi.Pointer, JClass, JMethodID)>()(this, arg0, arg1); + } + + @pragma('vm:prefer-inline') + int CallStaticByteMethodA( + JClass clazz, JMethodID methodID, ffi.Pointer args) { + return value.ref.CallStaticByteMethodA.asFunction< + int Function(ffi.Pointer, JClass, JMethodID, + ffi.Pointer)>()(this, clazz, methodID, args); + } + + @pragma('vm:prefer-inline') + int CallStaticCharMethod(JClass arg0, JMethodID arg1) { + return value.ref.CallStaticCharMethod.asFunction< + int Function( + ffi.Pointer, JClass, JMethodID)>()(this, arg0, arg1); + } + + @pragma('vm:prefer-inline') + int CallStaticCharMethodA( + JClass clazz, JMethodID methodID, ffi.Pointer args) { + return value.ref.CallStaticCharMethodA.asFunction< + int Function(ffi.Pointer, JClass, JMethodID, + ffi.Pointer)>()(this, clazz, methodID, args); + } + + @pragma('vm:prefer-inline') + int CallStaticShortMethod(JClass arg0, JMethodID arg1) { + return value.ref.CallStaticShortMethod.asFunction< + int Function( + ffi.Pointer, JClass, JMethodID)>()(this, arg0, arg1); + } + + @pragma('vm:prefer-inline') + int CallStaticShortMethodA( + JClass clazz, JMethodID methodID, ffi.Pointer args) { + return value.ref.CallStaticShortMethodA.asFunction< + int Function(ffi.Pointer, JClass, JMethodID, + ffi.Pointer)>()(this, clazz, methodID, args); + } + + @pragma('vm:prefer-inline') + int CallStaticIntMethod(JClass arg0, JMethodID arg1) { + return value.ref.CallStaticIntMethod.asFunction< + int Function( + ffi.Pointer, JClass, JMethodID)>()(this, arg0, arg1); + } + + @pragma('vm:prefer-inline') + int CallStaticIntMethodA( + JClass clazz, JMethodID methodID, ffi.Pointer args) { + return value.ref.CallStaticIntMethodA.asFunction< + int Function(ffi.Pointer, JClass, JMethodID, + ffi.Pointer)>()(this, clazz, methodID, args); + } + + @pragma('vm:prefer-inline') + int CallStaticLongMethod(JClass arg0, JMethodID arg1) { + return value.ref.CallStaticLongMethod.asFunction< + int Function( + ffi.Pointer, JClass, JMethodID)>()(this, arg0, arg1); + } + + @pragma('vm:prefer-inline') + int CallStaticLongMethodA( + JClass clazz, JMethodID methodID, ffi.Pointer args) { + return value.ref.CallStaticLongMethodA.asFunction< + int Function(ffi.Pointer, JClass, JMethodID, + ffi.Pointer)>()(this, clazz, methodID, args); + } + + @pragma('vm:prefer-inline') + double CallStaticFloatMethod(JClass arg0, JMethodID arg1) { + return value.ref.CallStaticFloatMethod.asFunction< + double Function( + ffi.Pointer, JClass, JMethodID)>()(this, arg0, arg1); + } + + @pragma('vm:prefer-inline') + double CallStaticFloatMethodA( + JClass clazz, JMethodID methodID, ffi.Pointer args) { + return value.ref.CallStaticFloatMethodA.asFunction< + double Function(ffi.Pointer, JClass, JMethodID, + ffi.Pointer)>()(this, clazz, methodID, args); + } + + @pragma('vm:prefer-inline') + double CallStaticDoubleMethod(JClass arg0, JMethodID arg1) { + return value.ref.CallStaticDoubleMethod.asFunction< + double Function( + ffi.Pointer, JClass, JMethodID)>()(this, arg0, arg1); + } + + @pragma('vm:prefer-inline') + double CallStaticDoubleMethodA( + JClass clazz, JMethodID methodID, ffi.Pointer args) { + return value.ref.CallStaticDoubleMethodA.asFunction< + double Function(ffi.Pointer, JClass, JMethodID, + ffi.Pointer)>()(this, clazz, methodID, args); + } + + @pragma('vm:prefer-inline') + void CallStaticVoidMethod(JClass arg0, JMethodID arg1) { + return value.ref.CallStaticVoidMethod.asFunction< + void Function( + ffi.Pointer, JClass, JMethodID)>()(this, arg0, arg1); + } + + @pragma('vm:prefer-inline') + void CallStaticVoidMethodA( + JClass clazz, JMethodID methodID, ffi.Pointer args) { + return value.ref.CallStaticVoidMethodA.asFunction< + void Function(ffi.Pointer, JClass, JMethodID, + ffi.Pointer)>()(this, clazz, methodID, args); + } + + @pragma('vm:prefer-inline') + JFieldID GetStaticFieldID( + JClass clazz, ffi.Pointer name, ffi.Pointer sig) { + return value.ref.GetStaticFieldID.asFunction< + JFieldID Function(ffi.Pointer, JClass, ffi.Pointer, + ffi.Pointer)>()(this, clazz, name, sig); + } + + @pragma('vm:prefer-inline') + JObject GetStaticObjectField(JClass clazz, JFieldID fieldID) { + return value.ref.GetStaticObjectField.asFunction< + JObject Function( + ffi.Pointer, JClass, JFieldID)>()(this, clazz, fieldID); + } + + @pragma('vm:prefer-inline') + int GetStaticBooleanField(JClass clazz, JFieldID fieldID) { + return value.ref.GetStaticBooleanField + .asFunction, JClass, JFieldID)>()( + this, clazz, fieldID); + } + + @pragma('vm:prefer-inline') + int GetStaticByteField(JClass clazz, JFieldID fieldID) { + return value.ref.GetStaticByteField + .asFunction, JClass, JFieldID)>()( + this, clazz, fieldID); + } + + @pragma('vm:prefer-inline') + int GetStaticCharField(JClass clazz, JFieldID fieldID) { + return value.ref.GetStaticCharField + .asFunction, JClass, JFieldID)>()( + this, clazz, fieldID); + } + + @pragma('vm:prefer-inline') + int GetStaticShortField(JClass clazz, JFieldID fieldID) { + return value.ref.GetStaticShortField + .asFunction, JClass, JFieldID)>()( + this, clazz, fieldID); + } + + @pragma('vm:prefer-inline') + int GetStaticIntField(JClass clazz, JFieldID fieldID) { + return value.ref.GetStaticIntField + .asFunction, JClass, JFieldID)>()( + this, clazz, fieldID); + } + + @pragma('vm:prefer-inline') + int GetStaticLongField(JClass clazz, JFieldID fieldID) { + return value.ref.GetStaticLongField + .asFunction, JClass, JFieldID)>()( + this, clazz, fieldID); + } + + @pragma('vm:prefer-inline') + double GetStaticFloatField(JClass clazz, JFieldID fieldID) { + return value.ref.GetStaticFloatField.asFunction< + double Function( + ffi.Pointer, JClass, JFieldID)>()(this, clazz, fieldID); + } + + @pragma('vm:prefer-inline') + double GetStaticDoubleField(JClass clazz, JFieldID fieldID) { + return value.ref.GetStaticDoubleField.asFunction< + double Function( + ffi.Pointer, JClass, JFieldID)>()(this, clazz, fieldID); + } + + @pragma('vm:prefer-inline') + void SetStaticObjectField(JClass clazz, JFieldID fieldID, JObject val) { + return value.ref.SetStaticObjectField.asFunction< + void Function(ffi.Pointer, JClass, JFieldID, JObject)>()( + this, clazz, fieldID, val); + } + + @pragma('vm:prefer-inline') + void SetStaticBooleanField(JClass clazz, JFieldID fieldID, int val) { + return value.ref.SetStaticBooleanField.asFunction< + void Function(ffi.Pointer, JClass, JFieldID, int)>()( + this, clazz, fieldID, val); + } + + @pragma('vm:prefer-inline') + void SetStaticByteField(JClass clazz, JFieldID fieldID, int val) { + return value.ref.SetStaticByteField.asFunction< + void Function(ffi.Pointer, JClass, JFieldID, int)>()( + this, clazz, fieldID, val); + } + + @pragma('vm:prefer-inline') + void SetStaticCharField(JClass clazz, JFieldID fieldID, int val) { + return value.ref.SetStaticCharField.asFunction< + void Function(ffi.Pointer, JClass, JFieldID, int)>()( + this, clazz, fieldID, val); + } + + @pragma('vm:prefer-inline') + void SetStaticShortField(JClass clazz, JFieldID fieldID, int val) { + return value.ref.SetStaticShortField.asFunction< + void Function(ffi.Pointer, JClass, JFieldID, int)>()( + this, clazz, fieldID, val); + } + + @pragma('vm:prefer-inline') + void SetStaticIntField(JClass clazz, JFieldID fieldID, int val) { + return value.ref.SetStaticIntField.asFunction< + void Function(ffi.Pointer, JClass, JFieldID, int)>()( + this, clazz, fieldID, val); + } + + @pragma('vm:prefer-inline') + void SetStaticLongField(JClass clazz, JFieldID fieldID, int val) { + return value.ref.SetStaticLongField.asFunction< + void Function(ffi.Pointer, JClass, JFieldID, int)>()( + this, clazz, fieldID, val); + } + + @pragma('vm:prefer-inline') + void SetStaticFloatField(JClass clazz, JFieldID fieldID, double val) { + return value.ref.SetStaticFloatField.asFunction< + void Function(ffi.Pointer, JClass, JFieldID, double)>()( + this, clazz, fieldID, val); + } + + @pragma('vm:prefer-inline') + void SetStaticDoubleField(JClass clazz, JFieldID fieldID, double val) { + return value.ref.SetStaticDoubleField.asFunction< + void Function(ffi.Pointer, JClass, JFieldID, double)>()( + this, clazz, fieldID, val); + } + + @pragma('vm:prefer-inline') + JString NewString(ffi.Pointer unicodeChars, int len) { + return value.ref.NewString.asFunction< + JString Function(ffi.Pointer, ffi.Pointer, int)>()( + this, unicodeChars, len); + } + + @pragma('vm:prefer-inline') + int GetStringLength(JString string) { + return value.ref.GetStringLength + .asFunction, JString)>()( + this, string); + } + + @pragma('vm:prefer-inline') + ffi.Pointer GetStringChars( + JString string, ffi.Pointer isCopy) { + return value.ref.GetStringChars.asFunction< + ffi.Pointer Function(ffi.Pointer, JString, + ffi.Pointer)>()(this, string, isCopy); + } + + @pragma('vm:prefer-inline') + void ReleaseStringChars(JString string, ffi.Pointer isCopy) { + return value.ref.ReleaseStringChars.asFunction< + void Function(ffi.Pointer, JString, ffi.Pointer)>()( + this, string, isCopy); + } + + @pragma('vm:prefer-inline') + JString NewStringUTF(ffi.Pointer bytes) { + return value.ref.NewStringUTF.asFunction< + JString Function( + ffi.Pointer, ffi.Pointer)>()(this, bytes); + } + + @pragma('vm:prefer-inline') + int GetStringUTFLength(JString string) { + return value.ref.GetStringUTFLength + .asFunction, JString)>()( + this, string); + } + + @pragma('vm:prefer-inline') + ffi.Pointer GetStringUTFChars( + JString string, ffi.Pointer isCopy) { + return value.ref.GetStringUTFChars.asFunction< + ffi.Pointer Function(ffi.Pointer, JString, + ffi.Pointer)>()(this, string, isCopy); + } + + @pragma('vm:prefer-inline') + void ReleaseStringUTFChars(JString string, ffi.Pointer utf) { + return value.ref.ReleaseStringUTFChars.asFunction< + void Function(ffi.Pointer, JString, + ffi.Pointer)>()(this, string, utf); + } + + @pragma('vm:prefer-inline') + int GetArrayLength(JArray array) { + return value.ref.GetArrayLength + .asFunction, JArray)>()(this, array); + } + + @pragma('vm:prefer-inline') + JObjectArray NewObjectArray( + int length, JClass elementClass, JObject initialElement) { + return value.ref.NewObjectArray.asFunction< + JObjectArray Function(ffi.Pointer, int, JClass, + JObject)>()(this, length, elementClass, initialElement); + } + + @pragma('vm:prefer-inline') + JObject GetObjectArrayElement(JObjectArray array, int index) { + return value.ref.GetObjectArrayElement.asFunction< + JObject Function( + ffi.Pointer, JObjectArray, int)>()(this, array, index); + } + + @pragma('vm:prefer-inline') + void SetObjectArrayElement(JObjectArray array, int index, JObject val) { + return value.ref.SetObjectArrayElement.asFunction< + void Function(ffi.Pointer, JObjectArray, int, JObject)>()( + this, array, index, val); + } + + @pragma('vm:prefer-inline') + JBooleanArray NewBooleanArray(int length) { + return value.ref.NewBooleanArray + .asFunction, int)>()( + this, length); + } + + @pragma('vm:prefer-inline') + JByteArray NewByteArray(int length) { + return value.ref.NewByteArray + .asFunction, int)>()( + this, length); + } + + @pragma('vm:prefer-inline') + JCharArray NewCharArray(int length) { + return value.ref.NewCharArray + .asFunction, int)>()( + this, length); + } + + @pragma('vm:prefer-inline') + JShortArray NewShortArray(int length) { + return value.ref.NewShortArray + .asFunction, int)>()( + this, length); + } + + @pragma('vm:prefer-inline') + JIntArray NewIntArray(int length) { + return value.ref.NewIntArray + .asFunction, int)>()( + this, length); + } + + @pragma('vm:prefer-inline') + JLongArray NewLongArray(int length) { + return value.ref.NewLongArray + .asFunction, int)>()( + this, length); + } + + @pragma('vm:prefer-inline') + JFloatArray NewFloatArray(int length) { + return value.ref.NewFloatArray + .asFunction, int)>()( + this, length); + } + + @pragma('vm:prefer-inline') + JDoubleArray NewDoubleArray(int length) { + return value.ref.NewDoubleArray + .asFunction, int)>()( + this, length); + } + + @pragma('vm:prefer-inline') + ffi.Pointer GetBooleanArrayElements( + JBooleanArray array, ffi.Pointer isCopy) { + return value.ref.GetBooleanArrayElements.asFunction< + ffi.Pointer Function(ffi.Pointer, JBooleanArray, + ffi.Pointer)>()(this, array, isCopy); + } + + @pragma('vm:prefer-inline') + ffi.Pointer GetByteArrayElements( + JByteArray array, ffi.Pointer isCopy) { + return value.ref.GetByteArrayElements.asFunction< + ffi.Pointer Function(ffi.Pointer, JByteArray, + ffi.Pointer)>()(this, array, isCopy); + } + + @pragma('vm:prefer-inline') + ffi.Pointer GetCharArrayElements( + JCharArray array, ffi.Pointer isCopy) { + return value.ref.GetCharArrayElements.asFunction< + ffi.Pointer Function(ffi.Pointer, JCharArray, + ffi.Pointer)>()(this, array, isCopy); + } + + @pragma('vm:prefer-inline') + ffi.Pointer GetShortArrayElements( + JShortArray array, ffi.Pointer isCopy) { + return value.ref.GetShortArrayElements.asFunction< + ffi.Pointer Function(ffi.Pointer, JShortArray, + ffi.Pointer)>()(this, array, isCopy); + } + + @pragma('vm:prefer-inline') + ffi.Pointer GetIntArrayElements( + JIntArray array, ffi.Pointer isCopy) { + return value.ref.GetIntArrayElements.asFunction< + ffi.Pointer Function(ffi.Pointer, JIntArray, + ffi.Pointer)>()(this, array, isCopy); + } + + @pragma('vm:prefer-inline') + ffi.Pointer GetLongArrayElements( + JLongArray array, ffi.Pointer isCopy) { + return value.ref.GetLongArrayElements.asFunction< + ffi.Pointer Function(ffi.Pointer, JLongArray, + ffi.Pointer)>()(this, array, isCopy); + } + + @pragma('vm:prefer-inline') + ffi.Pointer GetFloatArrayElements( + JFloatArray array, ffi.Pointer isCopy) { + return value.ref.GetFloatArrayElements.asFunction< + ffi.Pointer Function(ffi.Pointer, JFloatArray, + ffi.Pointer)>()(this, array, isCopy); + } + + @pragma('vm:prefer-inline') + ffi.Pointer GetDoubleArrayElements( + JDoubleArray array, ffi.Pointer isCopy) { + return value.ref.GetDoubleArrayElements.asFunction< + ffi.Pointer Function(ffi.Pointer, JDoubleArray, + ffi.Pointer)>()(this, array, isCopy); + } + + @pragma('vm:prefer-inline') + void ReleaseBooleanArrayElements( + JBooleanArray array, ffi.Pointer elems, int mode) { + return value.ref.ReleaseBooleanArrayElements.asFunction< + void Function(ffi.Pointer, JBooleanArray, + ffi.Pointer, int)>()(this, array, elems, mode); + } + + @pragma('vm:prefer-inline') + void ReleaseByteArrayElements( + JByteArray array, ffi.Pointer elems, int mode) { + return value.ref.ReleaseByteArrayElements.asFunction< + void Function(ffi.Pointer, JByteArray, ffi.Pointer, + int)>()(this, array, elems, mode); + } + + @pragma('vm:prefer-inline') + void ReleaseCharArrayElements( + JCharArray array, ffi.Pointer elems, int mode) { + return value.ref.ReleaseCharArrayElements.asFunction< + void Function(ffi.Pointer, JCharArray, ffi.Pointer, + int)>()(this, array, elems, mode); + } + + @pragma('vm:prefer-inline') + void ReleaseShortArrayElements( + JShortArray array, ffi.Pointer elems, int mode) { + return value.ref.ReleaseShortArrayElements.asFunction< + void Function(ffi.Pointer, JShortArray, ffi.Pointer, + int)>()(this, array, elems, mode); + } + + @pragma('vm:prefer-inline') + void ReleaseIntArrayElements( + JIntArray array, ffi.Pointer elems, int mode) { + return value.ref.ReleaseIntArrayElements.asFunction< + void Function(ffi.Pointer, JIntArray, ffi.Pointer, + int)>()(this, array, elems, mode); + } + + @pragma('vm:prefer-inline') + void ReleaseLongArrayElements( + JLongArray array, ffi.Pointer elems, int mode) { + return value.ref.ReleaseLongArrayElements.asFunction< + void Function(ffi.Pointer, JLongArray, ffi.Pointer, + int)>()(this, array, elems, mode); + } + + @pragma('vm:prefer-inline') + void ReleaseFloatArrayElements( + JFloatArray array, ffi.Pointer elems, int mode) { + return value.ref.ReleaseFloatArrayElements.asFunction< + void Function(ffi.Pointer, JFloatArray, ffi.Pointer, + int)>()(this, array, elems, mode); + } + + @pragma('vm:prefer-inline') + void ReleaseDoubleArrayElements( + JDoubleArray array, ffi.Pointer elems, int mode) { + return value.ref.ReleaseDoubleArrayElements.asFunction< + void Function(ffi.Pointer, JDoubleArray, ffi.Pointer, + int)>()(this, array, elems, mode); + } + + @pragma('vm:prefer-inline') + void GetBooleanArrayRegion( + JBooleanArray array, int start, int len, ffi.Pointer buf) { + return value.ref.GetBooleanArrayRegion.asFunction< + void Function(ffi.Pointer, JBooleanArray, int, int, + ffi.Pointer)>()(this, array, start, len, buf); + } + + @pragma('vm:prefer-inline') + void GetByteArrayRegion( + JByteArray array, int start, int len, ffi.Pointer buf) { + return value.ref.GetByteArrayRegion.asFunction< + void Function(ffi.Pointer, JByteArray, int, int, + ffi.Pointer)>()(this, array, start, len, buf); + } + + @pragma('vm:prefer-inline') + void GetCharArrayRegion( + JCharArray array, int start, int len, ffi.Pointer buf) { + return value.ref.GetCharArrayRegion.asFunction< + void Function(ffi.Pointer, JCharArray, int, int, + ffi.Pointer)>()(this, array, start, len, buf); + } + + @pragma('vm:prefer-inline') + void GetShortArrayRegion( + JShortArray array, int start, int len, ffi.Pointer buf) { + return value.ref.GetShortArrayRegion.asFunction< + void Function(ffi.Pointer, JShortArray, int, int, + ffi.Pointer)>()(this, array, start, len, buf); + } + + @pragma('vm:prefer-inline') + void GetIntArrayRegion( + JIntArray array, int start, int len, ffi.Pointer buf) { + return value.ref.GetIntArrayRegion.asFunction< + void Function(ffi.Pointer, JIntArray, int, int, + ffi.Pointer)>()(this, array, start, len, buf); + } + + @pragma('vm:prefer-inline') + void GetLongArrayRegion( + JLongArray array, int start, int len, ffi.Pointer buf) { + return value.ref.GetLongArrayRegion.asFunction< + void Function(ffi.Pointer, JLongArray, int, int, + ffi.Pointer)>()(this, array, start, len, buf); + } + + @pragma('vm:prefer-inline') + void GetFloatArrayRegion( + JFloatArray array, int start, int len, ffi.Pointer buf) { + return value.ref.GetFloatArrayRegion.asFunction< + void Function(ffi.Pointer, JFloatArray, int, int, + ffi.Pointer)>()(this, array, start, len, buf); + } + + @pragma('vm:prefer-inline') + void GetDoubleArrayRegion( + JDoubleArray array, int start, int len, ffi.Pointer buf) { + return value.ref.GetDoubleArrayRegion.asFunction< + void Function(ffi.Pointer, JDoubleArray, int, int, + ffi.Pointer)>()(this, array, start, len, buf); + } + + /// spec shows these without const; some jni.h do, some don't + /// + /// This is an automatically generated extension method + @pragma('vm:prefer-inline') + void SetBooleanArrayRegion( + JBooleanArray array, int start, int len, ffi.Pointer buf) { + return value.ref.SetBooleanArrayRegion.asFunction< + void Function(ffi.Pointer, JBooleanArray, int, int, + ffi.Pointer)>()(this, array, start, len, buf); + } + + @pragma('vm:prefer-inline') + void SetByteArrayRegion( + JByteArray array, int start, int len, ffi.Pointer buf) { + return value.ref.SetByteArrayRegion.asFunction< + void Function(ffi.Pointer, JByteArray, int, int, + ffi.Pointer)>()(this, array, start, len, buf); + } + + @pragma('vm:prefer-inline') + void SetCharArrayRegion( + JCharArray array, int start, int len, ffi.Pointer buf) { + return value.ref.SetCharArrayRegion.asFunction< + void Function(ffi.Pointer, JCharArray, int, int, + ffi.Pointer)>()(this, array, start, len, buf); + } + + @pragma('vm:prefer-inline') + void SetShortArrayRegion( + JShortArray array, int start, int len, ffi.Pointer buf) { + return value.ref.SetShortArrayRegion.asFunction< + void Function(ffi.Pointer, JShortArray, int, int, + ffi.Pointer)>()(this, array, start, len, buf); + } + + @pragma('vm:prefer-inline') + void SetIntArrayRegion( + JIntArray array, int start, int len, ffi.Pointer buf) { + return value.ref.SetIntArrayRegion.asFunction< + void Function(ffi.Pointer, JIntArray, int, int, + ffi.Pointer)>()(this, array, start, len, buf); + } + + @pragma('vm:prefer-inline') + void SetLongArrayRegion( + JLongArray array, int start, int len, ffi.Pointer buf) { + return value.ref.SetLongArrayRegion.asFunction< + void Function(ffi.Pointer, JLongArray, int, int, + ffi.Pointer)>()(this, array, start, len, buf); + } + + @pragma('vm:prefer-inline') + void SetFloatArrayRegion( + JFloatArray array, int start, int len, ffi.Pointer buf) { + return value.ref.SetFloatArrayRegion.asFunction< + void Function(ffi.Pointer, JFloatArray, int, int, + ffi.Pointer)>()(this, array, start, len, buf); + } + + @pragma('vm:prefer-inline') + void SetDoubleArrayRegion( + JDoubleArray array, int start, int len, ffi.Pointer buf) { + return value.ref.SetDoubleArrayRegion.asFunction< + void Function(ffi.Pointer, JDoubleArray, int, int, + ffi.Pointer)>()(this, array, start, len, buf); + } + + @pragma('vm:prefer-inline') + int RegisterNatives( + JClass clazz, ffi.Pointer methods, int nMethods) { + return value.ref.RegisterNatives.asFunction< + int Function(ffi.Pointer, JClass, ffi.Pointer, + int)>()(this, clazz, methods, nMethods); + } + + @pragma('vm:prefer-inline') + int UnregisterNatives(JClass clazz) { + return value.ref.UnregisterNatives + .asFunction, JClass)>()(this, clazz); + } + + @pragma('vm:prefer-inline') + int MonitorEnter(JObject obj) { + return value.ref.MonitorEnter + .asFunction, JObject)>()(this, obj); + } + + @pragma('vm:prefer-inline') + int MonitorExit(JObject obj) { + return value.ref.MonitorExit + .asFunction, JObject)>()(this, obj); + } + + @pragma('vm:prefer-inline') + int GetJavaVM(ffi.Pointer> vm) { + return value.ref.GetJavaVM.asFunction< + int Function(ffi.Pointer, + ffi.Pointer>)>()(this, vm); + } + + @pragma('vm:prefer-inline') + void GetStringRegion( + JString str, int start, int len, ffi.Pointer buf) { + return value.ref.GetStringRegion.asFunction< + void Function(ffi.Pointer, JString, int, int, + ffi.Pointer)>()(this, str, start, len, buf); + } + + @pragma('vm:prefer-inline') + void GetStringUTFRegion( + JString str, int start, int len, ffi.Pointer buf) { + return value.ref.GetStringUTFRegion.asFunction< + void Function(ffi.Pointer, JString, int, int, + ffi.Pointer)>()(this, str, start, len, buf); + } + + @pragma('vm:prefer-inline') + ffi.Pointer GetPrimitiveArrayCritical( + JArray array, ffi.Pointer isCopy) { + return value.ref.GetPrimitiveArrayCritical.asFunction< + ffi.Pointer Function(ffi.Pointer, JArray, + ffi.Pointer)>()(this, array, isCopy); + } + + @pragma('vm:prefer-inline') + void ReleasePrimitiveArrayCritical( + JArray array, ffi.Pointer carray, int mode) { + return value.ref.ReleasePrimitiveArrayCritical.asFunction< + void Function(ffi.Pointer, JArray, ffi.Pointer, + int)>()(this, array, carray, mode); + } + + @pragma('vm:prefer-inline') + ffi.Pointer GetStringCritical( + JString str, ffi.Pointer isCopy) { + return value.ref.GetStringCritical.asFunction< + ffi.Pointer Function(ffi.Pointer, JString, + ffi.Pointer)>()(this, str, isCopy); + } + + @pragma('vm:prefer-inline') + void ReleaseStringCritical(JString str, ffi.Pointer carray) { + return value.ref.ReleaseStringCritical.asFunction< + void Function(ffi.Pointer, JString, ffi.Pointer)>()( + this, str, carray); + } + + @pragma('vm:prefer-inline') + JWeak NewWeakGlobalRef(JObject obj) { + return value.ref.NewWeakGlobalRef + .asFunction, JObject)>()(this, obj); + } + + @pragma('vm:prefer-inline') + void DeleteWeakGlobalRef(JWeak obj) { + return value.ref.DeleteWeakGlobalRef + .asFunction, JWeak)>()(this, obj); + } + + @pragma('vm:prefer-inline') + int ExceptionCheck() { + return value.ref.ExceptionCheck + .asFunction)>()(this); + } + + @pragma('vm:prefer-inline') + JObject NewDirectByteBuffer(ffi.Pointer address, int capacity) { + return value.ref.NewDirectByteBuffer.asFunction< + JObject Function(ffi.Pointer, ffi.Pointer, + int)>()(this, address, capacity); + } + + @pragma('vm:prefer-inline') + ffi.Pointer GetDirectBufferAddress(JObject buf) { + return value.ref.GetDirectBufferAddress.asFunction< + ffi.Pointer Function( + ffi.Pointer, JObject)>()(this, buf); + } + + @pragma('vm:prefer-inline') + int GetDirectBufferCapacity(JObject buf) { + return value.ref.GetDirectBufferCapacity + .asFunction, JObject)>()(this, buf); + } + + /// added in JNI 1.6 + /// + /// This is an automatically generated extension method + @pragma('vm:prefer-inline') + int GetObjectRefType(JObject obj) { + return value.ref.GetObjectRefType + .asFunction, JObject)>()(this, obj); + } +} + +typedef JniEnv1 = ffi.Pointer; +typedef JClass = JObject; + +/// Reference types, in C. +typedef JObject = ffi.Pointer; +typedef JByte = ffi.Int8; + +/// "cardinal indices and sizes" +typedef JSize = JInt; +typedef JMethodID = ffi.Pointer; +typedef JFieldID = ffi.Pointer; + +/// Primitive types that match up with Java equivalents. +typedef JBoolean = ffi.Uint8; +typedef JThrowable = JObject; + +class __va_list_tag extends ffi.Struct { + @ffi.UnsignedInt() + external int gp_offset; + + @ffi.UnsignedInt() + external int fp_offset; + + external ffi.Pointer overflow_arg_area; + + external ffi.Pointer reg_save_area; +} + +class JValue extends ffi.Union { + @JBoolean() + external int z; + + @JByte() + external int b; + + @JChar() + external int c; + + @JShort() + external int s; + + @JInt() + external int i; + + @JLong() + external int j; + + @JFloat() + external double f; + + @JDouble() + external double d; + + external JObject l; +} + +typedef JChar = ffi.Uint16; +typedef JShort = ffi.Int16; +typedef JLong = ffi.Int64; +typedef JFloat = ffi.Float; +typedef JDouble = ffi.Double; +typedef JString = JObject; +typedef JArray = JObject; +typedef JObjectArray = JArray; +typedef JBooleanArray = JArray; +typedef JByteArray = JArray; +typedef JCharArray = JArray; +typedef JShortArray = JArray; +typedef JIntArray = JArray; +typedef JLongArray = JArray; +typedef JFloatArray = JArray; +typedef JDoubleArray = JArray; + +class JNINativeMethod extends ffi.Struct { + external ffi.Pointer name; + + external ffi.Pointer signature; + + external ffi.Pointer fnPtr; +} + +typedef JWeak = JObject; + +abstract class jobjectRefType { + static const int JNIInvalidRefType = 0; + static const int JNILocalRefType = 1; + static const int JNIGlobalRefType = 2; + static const int JNIWeakGlobalRefType = 3; +} + +/// C++ object wrapper. +/// +/// This is usually overlaid on a C struct whose first element is a +/// JNINativeInterface*. We rely somewhat on compiler behavior. +class _JNIEnv extends ffi.Struct { + /// do not rename this; it does not seem to be entirely opaque + external ffi.Pointer functions; +} + +/// C++ version. +class _JavaVM extends ffi.Struct { + external ffi.Pointer functions; +} + +class JavaVMAttachArgs extends ffi.Struct { + /// must be >= JNI_VERSION_1_2 + @JInt() + external int version; + + /// NULL or name of thread as modified UTF-8 str + external ffi.Pointer name; + + /// global ref of a ThreadGroup object, or NULL + external JObject group; +} + +/// JNI 1.2+ initialization. (As of 1.6, the pre-1.2 structures are no +/// longer supported.) +class JavaVMOption extends ffi.Struct { + external ffi.Pointer optionString; + + external ffi.Pointer extraInfo; +} + +class JavaVMInitArgs extends ffi.Struct { + /// use JNI_VERSION_1_2 or later + @JInt() + external int version; + + @JInt() + external int nOptions; + + external ffi.Pointer options; + + @JBoolean() + external int ignoreUnrecognized; +} + +abstract class JniLogLevel { + static const int JNI_VERBOSE = 2; + static const int JNI_DEBUG = 3; + static const int JNI_INFO = 4; + static const int JNI_WARN = 5; + static const int JNI_ERROR = 6; +} + +const int JNI_FALSE = 0; + +const int JNI_TRUE = 1; + +const int JNI_VERSION_1_1 = 65537; + +const int JNI_VERSION_1_2 = 65538; + +const int JNI_VERSION_1_4 = 65540; + +const int JNI_VERSION_1_6 = 65542; + +const int JNI_OK = 0; + +const int JNI_ERR = -1; + +const int JNI_EDETACHED = -2; + +const int JNI_EVERSION = -3; + +const int JNI_ENOMEM = -4; + +const int JNI_EEXIST = -5; + +const int JNI_EINVAL = -6; + +const int JNI_COMMIT = 1; + +const int JNI_ABORT = 2; + +const String JNI_LOG_TAG = 'Dart-JNI'; diff --git a/pkgs/jni/pubspec.yaml b/pkgs/jni/pubspec.yaml index e1c13147e..5d057a4bb 100644 --- a/pkgs/jni/pubspec.yaml +++ b/pkgs/jni/pubspec.yaml @@ -1,79 +1,53 @@ name: jni -description: A new Flutter FFI plugin project. +description: Library to access JNI from dart and flutter version: 0.0.1 -homepage: +homepage: https://github.com/dart-lang/jnigen environment: - sdk: ">=2.17.5 <3.0.0" - flutter: ">=2.11.0" + sdk: ">=2.17.1 <3.0.0" + #flutter: ">=2.11.0" dependencies: - flutter: - sdk: flutter + ## Commented out to support dart standalone + # flutter: + # sdk: flutter plugin_platform_interface: ^2.0.2 + ffi: ^2.0.0 + path: ^1.8.0 + package_config: ^2.1.0 + args: ^2.3.1 dev_dependencies: - ffi: ^1.1.2 - ffigen: ^4.1.2 - flutter_test: - sdk: flutter + ## Temporarily linking to a personal fork of ffigen + ## so that changes in FFIGen can be reviewed. + # + ## If this is vendored directly, it will not be possible to + ## review changes in ffigen. + # + ## Will be removed in a later PR by vendoring the patched ffigen. + # + ## After running `dart run ffigen --config ffigen.yaml` there + ## should be no changes. + ## + ## TODO: vendor ffigen fork + ffigen: + git: https://github.com/mahesh-hegde/ffigen_patch_jni.git + #path: third_party/ffigen_patch flutter_lints: ^2.0.0 - -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec + test: ^1.21.1 # The following section is specific to Flutter packages. flutter: - # This section identifies this Flutter project as a plugin project. - # The 'pluginClass' specifies the class (in Java, Kotlin, Swift, Objective-C, etc.) - # which should be registered in the plugin registry. This is required for - # using method channels. - # The Android 'package' specifies package in which the registered class is. - # This is required for using method channels on Android. - # The 'ffiPlugin' specifies that native code should be built and bundled. - # This is required for using `dart:ffi`. - # All these are used by the tooling to maintain consistency when - # adding or updating assets for this project. - # - # Please refer to README.md for a detailed explanation. plugin: platforms: - android: - ffiPlugin: true linux: ffiPlugin: true + windows: + ffiPlugin: true macos: ffiPlugin: true - windows: + android: ffiPlugin: true + package: dev.dart.jni + pluginClass: JniPlugin - # To add assets to your plugin package, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - # - # For details regarding assets in packages, see - # https://flutter.dev/assets-and-images/#from-packages - # - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware - - # To add custom fonts to your plugin package, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts in packages, see - # https://flutter.dev/custom-fonts/#from-packages diff --git a/pkgs/jni/src/.gitignore b/pkgs/jni/src/.gitignore new file mode 100644 index 000000000..22707436b --- /dev/null +++ b/pkgs/jni/src/.gitignore @@ -0,0 +1,8 @@ +CMakeFiles/ +Makefile +cmake_install.cmake +libdartjni.so +CMakeCache.txt +.cache +compile_commands.json + diff --git a/pkgs/jni/src/CMakeLists.txt b/pkgs/jni/src/CMakeLists.txt index c9ab651c1..e9cfd8034 100644 --- a/pkgs/jni/src/CMakeLists.txt +++ b/pkgs/jni/src/CMakeLists.txt @@ -6,12 +6,26 @@ cmake_minimum_required(VERSION 3.10) project(jni_library VERSION 0.0.1 LANGUAGES C) add_library(jni SHARED - "jni.c" + "dartjni.c" ) set_target_properties(jni PROPERTIES - PUBLIC_HEADER jni.h - OUTPUT_NAME "jni" + PUBLIC_HEADER dartjni.h + OUTPUT_NAME "dartjni" ) target_compile_definitions(jni PUBLIC DART_SHARED_LIB) + +if(WIN32) + set_target_properties(${TARGET_NAME} PROPERTIES + LINK_FLAGS "/DELAYLOAD:jvm.dll") +endif() + +if (ANDROID) + target_link_libraries(jni log) +else() + find_package(Java REQUIRED) + find_package(JNI REQUIRED) + include_directories(${JNI_INCLUDE_DIRS}) + target_link_libraries(jni ${JNI_LIBRARIES}) +endif() diff --git a/pkgs/jni/src/README.md b/pkgs/jni/src/README.md new file mode 100644 index 000000000..c0c3119ba --- /dev/null +++ b/pkgs/jni/src/README.md @@ -0,0 +1,27 @@ +## LSP instructions + +If using an LSP based editor plugin and the syntax highlighting / code completion is not working, there are 2 ways to fix that. + +* __Create a compile_flags.txt with following content__: + +`-I` + +This might need the OS specific include folder as well, so that transitively included headers can be found. Example: + +``` +-I/usr/lib/jvm/java-11-openjdk-amd64/include +-I/usr/lib/jvm/java-11-openjdk-amd64/include/linux +``` + +Note that this file should contain one compilation flag per line. + +* __create a compilation database by prefixing `bear` to your cmake build__. + +Run `cmake --build` command from your source, prefixed with `bear`. + +`bear -- cmake --build ` + +On some distro versions of `bear` command, the `--` needs to be omitted. + +`bear cmake --build ` + diff --git a/pkgs/jni/src/dartjni.c b/pkgs/jni/src/dartjni.c new file mode 100644 index 000000000..cf4e7d555 --- /dev/null +++ b/pkgs/jni/src/dartjni.c @@ -0,0 +1,139 @@ +#include +#include + +#include "dartjni.h" + +struct jni_context jni = {NULL, NULL, NULL, NULL, NULL}; + +thread_local JNIEnv *jniEnv = NULL; + +int jni_log_level = JNI_INFO; + +FFI_PLUGIN_EXPORT +void SetJNILogging(int level) { + jni_log_level = level; +} + +void jni_log(int level, const char *format, ...) { + // TODO: Not working + // IssueRef: https://github.com/dart-lang/jni_gen/issues/16 + if (level >= jni_log_level) { + va_list args; + va_start(args, format); +#ifdef __ANDROID__ + __android_log_print(level, JNI_LOG_TAG, format, args); +#else + // fprintf(stderr, "%s: ", JNI_LOG_TAG); + vfprintf(stderr, format, args); +#endif + va_end(args); + } +} + +/// Get JVM associated with current process. +/// Returns NULL if no JVM is running. +FFI_PLUGIN_EXPORT +JavaVM *GetJavaVM() { return jni.jvm; } + +/// Returns Application classLoader (on Android), +/// which can be used to load application and platform classes. +/// ... +/// On other platforms, NULL is returned. +FFI_PLUGIN_EXPORT +jobject GetClassLoader() { + attach_thread(); + return (*jniEnv)->NewLocalRef(jniEnv, jni.classLoader); +} + + +/// Load class through platform-specific mechanism +/// ... +/// Currently uses application classloader on android, +/// and JNIEnv->FindClass on other platforms. +FFI_PLUGIN_EXPORT +jclass LoadClass(const char *name) { + jclass cls = NULL; + attach_thread(); + load_class(&cls, name); + return cls; +}; + +FFI_PLUGIN_EXPORT +JNIEnv *GetJniEnv() { + if (jni.jvm == NULL) { + return NULL; + } + attach_thread(); + return jniEnv; +} + +/// Returns application context on Android. +/// +/// On other platforms, NULL is returned. +FFI_PLUGIN_EXPORT +jobject GetApplicationContext() { + // Any publicly callable method + // can be called from an unattached thread. + // I Learned this the hard way. + attach_thread(); + return (*jniEnv)->NewLocalRef(jniEnv, jni.appContext); +} + +/// Returns current activity of the app +FFI_PLUGIN_EXPORT +jobject GetCurrentActivity() { + attach_thread(); + return (*jniEnv)->NewLocalRef(jniEnv, jni.currentActivity); +} + +#ifdef __ANDROID__ +JNIEXPORT void JNICALL Java_dev_dart_jni_JniPlugin_initializeJni( + JNIEnv *env, jobject obj, jobject appContext, jobject classLoader) { + jniEnv = env; + (*env)->GetJavaVM(env, &jni.jvm); + jni.classLoader = (*env)->NewGlobalRef(env, classLoader); + jni.appContext = (*env)->NewGlobalRef(env, appContext); + jclass classLoaderClass = (*env)->GetObjectClass(env, classLoader); + jni.loadClassMethod = + (*env)->GetMethodID(env, classLoaderClass, "loadClass", + "(Ljava/lang/String;)Ljava/lang/Class;"); +} + +JNIEXPORT void JNICALL Java_dev_dart_jni_JniPlugin_setJniActivity(JNIEnv *env, jobject obj, jobject activity, jobject context) { + jniEnv = env; + if (jni.currentActivity != NULL) { + (*env)->DeleteGlobalRef(env, jni.currentActivity); + } + jni.currentActivity = (*env)->NewGlobalRef(env, activity); + if (jni.appContext != NULL) { + (*env)->DeleteGlobalRef(env, jni.appContext); + } + jni.appContext = (*env)->NewGlobalRef(env, context); +} + +// Sometimes you may get linker error trying to link JNI_CreateJavaVM APIs +// on Android NDK. So IFDEF is required. +#else +FFI_PLUGIN_EXPORT +JNIEnv *SpawnJvm(JavaVMInitArgs *initArgs) { + JavaVMOption jvmopt[1]; + char class_path[] = "-Djava.class.path=."; + jvmopt[0].optionString = class_path; + JavaVMInitArgs vmArgs; + if (!initArgs) { + vmArgs.version = JNI_VERSION_1_2; + vmArgs.nOptions = 1; + vmArgs.options = jvmopt; + vmArgs.ignoreUnrecognized = JNI_TRUE; + initArgs = &vmArgs; + } + jni_log(JNI_DEBUG, "JNI Version: %d\n", initArgs->version); + const long flag = + JNI_CreateJavaVM(&jni.jvm, __ENVP_CAST &jniEnv, initArgs); + if (flag == JNI_ERR) { + return NULL; + } + return jniEnv; +} +#endif + diff --git a/pkgs/jni/src/dartjni.h b/pkgs/jni/src/dartjni.h new file mode 100644 index 000000000..5b7fb5be7 --- /dev/null +++ b/pkgs/jni/src/dartjni.h @@ -0,0 +1,123 @@ +#include +#include +#include +#include + +#if _WIN32 +#include +#else +#include +#include +#endif + +#if _WIN32 +#define FFI_PLUGIN_EXPORT __declspec(dllexport) +#else +#define FFI_PLUGIN_EXPORT +#endif + +#if defined _WIN32 +#define thread_local __declspec(thread) +#else +#define thread_local __thread +#endif + +#ifdef __ANDROID__ +#include +#endif + +#define JNI_LOG_TAG "Dart-JNI" + +#ifdef __ANDROID__ +#define __ENVP_CAST (JNIEnv **) +#else +#define __ENVP_CAST (void **) +#endif + +struct jni_context { + JavaVM *jvm; + jobject classLoader; + jmethodID loadClassMethod; + jobject currentActivity; + jobject appContext; +}; + +extern thread_local JNIEnv *jniEnv; +extern struct jni_context jni; + +enum DartJniLogLevel { + JNI_VERBOSE = 2, JNI_DEBUG, JNI_INFO, JNI_WARN, JNI_ERROR +}; + +FFI_PLUGIN_EXPORT JavaVM *GetJavaVM(void); + +FFI_PLUGIN_EXPORT JNIEnv *GetJniEnv(void); + +FFI_PLUGIN_EXPORT JNIEnv *SpawnJvm(JavaVMInitArgs *args); + +FFI_PLUGIN_EXPORT jclass LoadClass(const char *name); + +FFI_PLUGIN_EXPORT jobject GetClassLoader(void); + +FFI_PLUGIN_EXPORT jobject GetApplicationContext(void); + +FFI_PLUGIN_EXPORT jobject GetCurrentActivity(void); + +FFI_PLUGIN_EXPORT void SetJNILogging(int level); + +/// For use by jni_gen's generated code +/// don't use these. + +// `static inline` because `inline` doesn't work, it may still not +// inline the function in which case a linker error may be produced. +// +// There has to be a better way to do this. Either to force inlining on target +// platforms, or just leave it as normal function. + +static inline void __load_class_into(jclass *cls, const char *name) { +#ifdef __ANDROID__ + jstring className = (*jniEnv)->NewStringUTF(jniEnv, name); + *cls = (*jniEnv)->CallObjectMethod( + jniEnv, jni.classLoader, jni.loadClassMethod, className); + (*jniEnv)->DeleteLocalRef(jniEnv, className); +#else + *cls = (*jniEnv)->FindClass(jniEnv, name); +#endif +} + +static inline void load_class(jclass *cls, const char *name) { + if (*cls == NULL) { + __load_class_into(cls, name); + } +} + +static inline void load_class_gr(jclass *cls, const char *name) { + if (*cls == NULL) { + jclass tmp; + __load_class_into(&tmp, name); + *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); + (*jniEnv)->DeleteLocalRef(jniEnv, tmp); + } +} + +static inline void attach_thread() { + if (jniEnv == NULL) { + (*jni.jvm)->AttachCurrentThread(jni.jvm, __ENVP_CAST &jniEnv, + NULL); + } +} + +static inline void load_method(jclass cls, jmethodID *res, const char *name, + const char *sig) { + if (*res == NULL) { + *res = (*jniEnv)->GetMethodID(jniEnv, cls, name, sig); + } +} + +static inline void load_static_method(jclass cls, jmethodID *res, + const char *name, const char *sig) { + if (*res == NULL) { + *res = (*jniEnv)->GetStaticMethodID(jniEnv, cls, name, sig); + } +} + diff --git a/pkgs/jni/src/jni.c b/pkgs/jni/src/jni.c deleted file mode 100644 index d87e04ea3..000000000 --- a/pkgs/jni/src/jni.c +++ /dev/null @@ -1,23 +0,0 @@ -#include "jni.h" - -// A very short-lived native function. -// -// For very short-lived functions, it is fine to call them on the main isolate. -// They will block the Dart execution while running the native function, so -// only do this for native functions which are guaranteed to be short-lived. -FFI_PLUGIN_EXPORT intptr_t sum(intptr_t a, intptr_t b) { return a + b; } - -// A longer-lived native function, which occupies the thread calling it. -// -// Do not call these kind of native functions in the main isolate. They will -// block Dart execution. This will cause dropped frames in Flutter applications. -// Instead, call these native functions on a separate isolate. -FFI_PLUGIN_EXPORT intptr_t sum_long_running(intptr_t a, intptr_t b) { - // Simulate work. -#if _WIN32 - Sleep(5000); -#else - usleep(5000 * 1000); -#endif - return a + b; -} diff --git a/pkgs/jni/src/jni.h b/pkgs/jni/src/jni.h deleted file mode 100644 index 084c64228..000000000 --- a/pkgs/jni/src/jni.h +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include -#include - -#if _WIN32 -#include -#else -#include -#include -#endif - -#if _WIN32 -#define FFI_PLUGIN_EXPORT __declspec(dllexport) -#else -#define FFI_PLUGIN_EXPORT -#endif - -// A very short-lived native function. -// -// For very short-lived functions, it is fine to call them on the main isolate. -// They will block the Dart execution while running the native function, so -// only do this for native functions which are guaranteed to be short-lived. -FFI_PLUGIN_EXPORT intptr_t sum(intptr_t a, intptr_t b); - -// A longer lived native function, which occupies the thread calling it. -// -// Do not call these kind of native functions in the main isolate. They will -// block Dart execution. This will cause dropped frames in Flutter applications. -// Instead, call these native functions on a separate isolate. -FFI_PLUGIN_EXPORT intptr_t sum_long_running(intptr_t a, intptr_t b); diff --git a/pkgs/jni/test/exception_test.dart b/pkgs/jni/test/exception_test.dart new file mode 100644 index 000000000..9a3194c86 --- /dev/null +++ b/pkgs/jni/test/exception_test.dart @@ -0,0 +1,58 @@ +import 'dart:io'; + +import 'package:test/test.dart'; + +import 'package:jni/jni.dart'; +import 'package:jni/jni_object.dart'; + +void main() { + if (!Platform.isAndroid) { + bool caught = false; + try { + // If library does not exist, a helpful exception should be thrown. + // we can't test this directly because + // `test` schedules functions asynchronously + Jni.spawn(helperDir: "wrong_dir"); + } on HelperNotFoundException catch (_) { + // stderr.write("\n$_\n"); + Jni.spawn(helperDir: "src/build"); + caught = true; + } + if (!caught) { + throw "Expected HelperNotFoundException\n" + "Read exception_test.dart for details."; + } + } + final jni = Jni.getInstance(); + + test("double free throws exception", () { + final r = jni.newInstance("java/util/Random", "()V", []); + r.delete(); + expect(r.delete, throwsA(isA())); + }); + + test("Use after free throws exception", () { + final r = jni.newInstance("java/util/Random", "()V", []); + r.delete(); + expect(() => r.callIntMethodByName("nextInt", "(I)I", [256]), + throwsA(isA())); + }); + + test("An exception in JNI throws JniException in Dart", () { + final r = jni.newInstance("java/util/Random", "()V", []); + expect(() => r.callIntMethodByName("nextInt", "(I)I", [-1]), + throwsA(isA())); + }); + // Using printStackTrace from env + /* + test("uncommented to print java stack trace", () { + final r = jni.newInstance("java/util/Random", "()V", []); + try { + r.callIntMethodByName("nextInt", "(I)I", [-1]); + } on JniException catch (e) { + jni.getEnv().printStackTrace(e); + // optionally rethrow error + } + }); + */ +} diff --git a/pkgs/jni/test/jni_object_test.dart b/pkgs/jni/test/jni_object_test.dart new file mode 100644 index 000000000..c67132308 --- /dev/null +++ b/pkgs/jni/test/jni_object_test.dart @@ -0,0 +1,222 @@ +import 'dart:io'; +import 'dart:ffi'; +import 'dart:isolate'; + +import 'package:test/test.dart'; + +import 'package:jni/jni.dart'; +import 'package:jni/jni_object.dart'; + +void main() { + // Don't forget to initialize JNI. + if (!Platform.isAndroid) { + Jni.spawn(helperDir: "src/build"); + } + + final jni = Jni.getInstance(); + + // The API based on JniEnv is intended to closely mimic C API + // And thus can be too verbose for simple experimenting and one-off uses + // JniObject API provides an easier way to perform some common operations. + // + // However, this is only meant for experimenting and very simple uses. + // For anything complicated, use JNIGen (The main part of this GSoC project) + // which will be both more efficient and ergonomic. + test("Long.intValue() using JniObject", () { + // findJniClass on a Jni object returns a JniClass + // which wraps a local class reference and env, and + // provides convenience functions. + final longClass = jni.findJniClass("java/lang/Long"); + + // looks for a constructor with given signature. + // equivalently you can lookup a method with name + final longCtor = longClass.getConstructorID("(J)V"); + + // note that the arguments are just passed as a list + final long = longClass.newObject(longCtor, [176]); + + final intValue = long.callIntMethodByName("intValue", "()I", []); + expect(intValue, equals(176)); + + // delete any JniObject and JniClass instances using .delete() after use. + long.delete(); + longClass.delete(); + }); + + test("call a static method using JniClass APIs", () { + // you can use wrapClass to wrap a raw JClass (which is basically void*) + // Original ref is saved & will be deleted when you delete the + // wrapped JniClass. + final integerClass = jni.wrapClass(jni.findClass("java/lang/Integer")); + final result = integerClass.callStaticObjectMethodByName( + "toHexString", "(I)Ljava/lang/String;", [31]); + + // if the object is supposed to be a Java string + // you can call asDartString on it. + final resultString = result.asDartString(); + + // Dart string is a copy, original object can be deleted. + result.delete(); + expect(resultString, equals("1f")); + + // Also don't forget to delete the class + integerClass.delete(); + }); + + test("Call method with null argument, expect exception", () { + final integerClass = jni.findJniClass("java/lang/Integer"); + expect( + () => integerClass.callStaticIntMethodByName( + "parseInt", "(Ljava/lang/String;)I", [nullptr]), + throwsException); + integerClass.delete(); + }); + + test("Try to find a non-exisiting class, expect exception", () { + expect(() => jni.findJniClass("java/lang/NotExists"), throwsException); + }); + + /// callMethodByName will be expensive if making same call many times + /// Use getMethodID to get a method ID and use it in subsequent calls + test("Example for using getMethodID", () { + final longClass = jni.findJniClass("java/lang/Long"); + final bitCountMethod = longClass.getStaticMethodID("bitCount", "(J)I"); + + // Use newInstance if you want only one instance. + // It finds the class, gets constructor ID and constructs an instance. + final random = jni.newInstance("java/util/Random", "()V", []); + + // You don't need a JniClass reference to get instance method IDs + final nextIntMethod = random.getMethodID("nextInt", "(I)I"); + + for (int i = 0; i < 100; i++) { + int r = random.callIntMethod(nextIntMethod, [256 * 256]); + int bits = 0; + final jbc = + longClass.callStaticIntMethod(bitCountMethod, [JValueLong(r)]); + while (r != 0) { + bits += r % 2; + r = (r / 2).floor(); + } + expect(jbc, equals(bits)); + } + + random.delete(); + longClass.delete(); + }); + + // Actually it's not even required to get a reference to class + test("invoke_", () { + final m = jni.invokeLongMethod( + "java/lang/Long", "min", "(JJ)J", [JValueLong(1234), JValueLong(1324)]); + expect(m, equals(1234)); + }); + + test("retrieve_", () { + final maxLong = jni.retrieveShortField("java/lang/Short", "MAX_VALUE", "S"); + expect(maxLong, equals(32767)); + }); + + // Use callStringMethod if all you care about is a string result + test("callStaticStringMethod", () { + final longClass = jni.findJniClass("java/lang/Long"); + const n = 1223334444; + final strFromJava = longClass.callStaticStringMethodByName( + "toOctalString", "(J)Ljava/lang/String;", [JValueLong(n)]); + expect(strFromJava, equals(n.toRadixString(8))); + longClass.delete(); + }); + + // In JniObject, JniClass, and retrieve_/invoke_ methods + // you can also pass Dart strings, apart from range of types + // allowed by Jni.jvalues + // They will be converted automatically. + test("Passing strings in arguments", () { + final out = jni.retrieveObjectField( + "java/lang/System", "out", "Ljava/io/PrintStream;"); + // uncomment next line to see output + // (\n because test runner prints first char at end of the line) + //out.callVoidMethodByName( + // "println", "(Ljava/lang/Object;)V", ["\nWorks (Apparently)"]); + out.delete(); + }); + + test("Passing strings in arguments 2", () { + final twelve = jni.invokeByteMethod( + "java/lang/Byte", "parseByte", "(Ljava/lang/String;)B", ["12"]); + expect(twelve, equals(12)); + }); + + // You can use() method on JniObject for using once and deleting + test("use() method", () { + final randomInt = jni.newInstance("java/util/Random", "()V", []).use( + (random) => random.callIntMethodByName("nextInt", "(I)I", [15])); + expect(randomInt, lessThan(15)); + }); + + test("enums", () { + // Don't forget to escape $ in nested type names + final ordinal = jni + .retrieveObjectField( + "java/net/Proxy\$Type", "HTTP", "Ljava/net/Proxy\$Type;") + .use((f) => f.callIntMethodByName("ordinal", "()I", [])); + expect(ordinal, equals(1)); + }); + + test("Isolate", () { + Isolate.spawn(doSomeWorkInIsolate, null); + }); + + // JniObject is valid only in thread it is obtained + // so it can be safely shared with a function that can run in + // different thread. + // + // Eg: Dart has a thread pool, which means async methods may get scheduled + // in different thread. + // + // In that case, convert the JniObject into `JniGlobalObjectRef` using + // getGlobalRef() and reconstruct the object in use site using fromJniObject + // constructor. + test("JniGlobalRef", () async { + final uri = jni.invokeObjectMethod( + "java/net/URI", + "create", + "(Ljava/lang/String;)Ljava/net/URI;", + ["https://www.google.com/search"]); + final rg = uri.getGlobalRef(); + await Future.delayed(const Duration(seconds: 1), () { + final env = jni.getEnv(); + // Now comment this line & try to directly use uri local ref + // in outer scope. + // + // You will likely get a segfault, because Future computation is running + // in different thread. + // + // Therefore, don't share JniObjects across functions that can be + // scheduled across threads, including async callbacks. + final uri = JniObject.fromGlobalRef(env, rg); + final scheme = + uri.callStringMethodByName("getScheme", "()Ljava/lang/String;", []); + expect(scheme, "https"); + uri.delete(); + rg.deleteIn(env); + }); + uri.delete(); + }); +} + +void doSomeWorkInIsolate(Void? _) { + // On standalone target, make sure to call load + // when doing getInstance first time in a new isolate. + // + // otherwise getInstance will throw a "library not found" exception. + Jni.load(helperDir: "src/build"); + final jni = Jni.getInstance(); + final random = jni.newInstance("java/util/Random", "()V", []); + // final r = random.callIntMethodByName("nextInt", "(I)I", [256]); + // expect(r, lessThan(256)); + // Expect throws an OutsideTestException + // but you can uncomment below print and see it works + // print("\n$r"); + random.delete(); +} diff --git a/pkgs/jni/test/jni_test.dart b/pkgs/jni/test/jni_test.dart new file mode 100644 index 000000000..9982cf1b0 --- /dev/null +++ b/pkgs/jni/test/jni_test.dart @@ -0,0 +1,123 @@ +import 'dart:io'; +import 'dart:ffi'; + +import 'package:test/test.dart'; +import 'package:ffi/ffi.dart'; +import 'package:jni/jni.dart'; + +void main() { + // Running on Android through flutter, this plugin + // will bind to Android runtime's JVM. + // On other platforms eg Flutter desktop or Dart standalone + // You need to manually create a JVM at beginning. + // + // On flutter desktop, the C wrappers are bundled, and helperPath param + // is not required. + // + // On dart standalone, however, there's no way to bundle the wrappers. + // You have to manually pass the path to the `dartjni` dynamic library. + + if (!Platform.isAndroid) { + Jni.spawn(helperDir: "src/build"); + } + + final jni = Jni.getInstance(); + + test('get JNI Version', () { + // get a dart binding of JNIEnv object + // It's a thin wrapper over C's JNIEnv*, and provides + // all methods of it (without need to pass the first self parameter), + // plus few extension methods to make working in dart easier. + final env = jni.getEnv(); + expect(env.GetVersion(), isNot(equals(0))); + }); + + test('Manually lookup & call Long.toHexString static method', () { + // create an arena for allocating anything native + // it's convenient way to release all natively allocated strings + // and values at once. + final arena = Arena(); + final env = jni.getEnv(); + + // Method names on JniEnv* from C JNI API are capitalized + // like in original, while other extension methods + // follow Dart naming conventions. + final longClass = env.FindClass("java/lang/Long".toNativeChars(arena)); + // Refer JNI spec on how to construct method signatures + // Passing wrong signature leads to a segfault + final hexMethod = env.GetStaticMethodID( + longClass, + "toHexString".toNativeChars(arena), + "(J)Ljava/lang/String;".toNativeChars(arena)); + + for (var i in [1, 80, 13, 76, 1134453224145]) { + // Use Jni.jvalues method to easily construct native argument arrays + // if your argument is int, bool, or JObject (`Pointer`) + // it can be directly placed in the list. To convert into different primitive + // types, use JValue wrappers. + final jres = env.CallStaticObjectMethodA( + longClass, hexMethod, Jni.jvalues([JValueLong(i)], allocator: arena)); + + // use asDartString extension method on Pointer + // to convert a String jobject result to string + final res = env.asDartString(jres); + expect(res, equals(i.toRadixString(16))); + + // Any object or class result from java is a local reference + // and needs to be deleted explicitly. + // Note that method and field IDs aren't local references. + // But they are valid only until a reference to corresponding + // java class exists. + env.DeleteLocalRef(jres); + } + env.DeleteLocalRef(longClass); + arena.releaseAll(); + }); + + test("asJString extension method", () { + final env = jni.getEnv(); + const str = "QWERTY QWERTY"; + // convenience method that wraps + // converting dart string to native string, + // instantiating java string, and freeing the native string + final jstr = env.asJString(str); + expect(str, equals(env.asDartString(jstr))); + env.DeleteLocalRef(jstr); + }); + + test("Convert back and forth between dart and java string", () { + final arena = Arena(); + final env = jni.getEnv(); + const str = "ABCD EFGH"; + // This is what asJString and asDartString do internally + final jstr = env.NewStringUTF(str.toNativeChars(arena)); + final jchars = env.GetStringUTFChars(jstr, nullptr); + final dstr = jchars.toDartString(); + env.ReleaseStringUTFChars(jstr, jchars); + expect(str, equals(dstr)); + + // delete multiple local references using this method + env.deleteAllLocalRefs([jstr]); + arena.releaseAll(); + }); + + test("Print something from Java", () { + final arena = Arena(); + final env = jni.getEnv(); + final system = env.FindClass("java/lang/System".toNativeChars(arena)); + final field = env.GetStaticFieldID(system, "out".toNativeChars(arena), + "Ljava/io/PrintStream;".toNativeChars(arena)); + final out = env.GetStaticObjectField(system, field); + final printStream = env.GetObjectClass(out); + /* + final println = env.GetMethodID(printStream, "println".toNativeChars(arena), + "(Ljava/lang/String;)V".toNativeChars(arena)); + */ + const str = "\nHello JNI!"; + final jstr = env.asJString(str); + // test runner can't compare what's printed by Java, leaving it + // env.CallVoidMethodA(out, println, Jni.jvalues([jstr])); + env.deleteAllLocalRefs([system, printStream, jstr]); + arena.releaseAll(); + }); +} diff --git a/pkgs/jni/third_party/jni.h b/pkgs/jni/third_party/jni.h new file mode 100644 index 000000000..1e46927b4 --- /dev/null +++ b/pkgs/jni/third_party/jni.h @@ -0,0 +1,1146 @@ +/* + * Copyright (C) 2006 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * JNI specification, as defined by Sun: + * http://java.sun.com/javase/6/docs/technotes/guides/jni/spec/jniTOC.html + * + * Everything here is expected to be VM-neutral. + */ + +/* ANNOTATED COPY FOR DART JNI LIBRARY */ + +#pragma once + +#include +#include + +/* Primitive types that match up with Java equivalents. */ +typedef uint8_t jboolean; /* unsigned 8 bits */ +typedef int8_t jbyte; /* signed 8 bits */ +typedef uint16_t jchar; /* unsigned 16 bits */ +typedef int16_t jshort; /* signed 16 bits */ +typedef int32_t jint; /* signed 32 bits */ +typedef int64_t jlong; /* signed 64 bits */ +typedef float jfloat; /* 32-bit IEEE 754 */ +typedef double jdouble; /* 64-bit IEEE 754 */ + +/* "cardinal indices and sizes" */ +typedef jint jsize; + +#ifdef __cplusplus +/* + * Reference types, in C++ + */ +class _jobject {}; +class _jclass : public _jobject {}; +class _jstring : public _jobject {}; +class _jarray : public _jobject {}; +class _jobjectArray : public _jarray {}; +class _jbooleanArray : public _jarray {}; +class _jbyteArray : public _jarray {}; +class _jcharArray : public _jarray {}; +class _jshortArray : public _jarray {}; +class _jintArray : public _jarray {}; +class _jlongArray : public _jarray {}; +class _jfloatArray : public _jarray {}; +class _jdoubleArray : public _jarray {}; +class _jthrowable : public _jobject {}; + +typedef _jobject* jobject; +typedef _jclass* jclass; +typedef _jstring* jstring; +typedef _jarray* jarray; +typedef _jobjectArray* jobjectArray; +typedef _jbooleanArray* jbooleanArray; +typedef _jbyteArray* jbyteArray; +typedef _jcharArray* jcharArray; +typedef _jshortArray* jshortArray; +typedef _jintArray* jintArray; +typedef _jlongArray* jlongArray; +typedef _jfloatArray* jfloatArray; +typedef _jdoubleArray* jdoubleArray; +typedef _jthrowable* jthrowable; +typedef _jobject* jweak; + + +#else /* not __cplusplus */ + +/* + * Reference types, in C. + */ +typedef void* jobject; +typedef jobject jclass; +typedef jobject jstring; +typedef jobject jarray; +typedef jarray jobjectArray; +typedef jarray jbooleanArray; +typedef jarray jbyteArray; +typedef jarray jcharArray; +typedef jarray jshortArray; +typedef jarray jintArray; +typedef jarray jlongArray; +typedef jarray jfloatArray; +typedef jarray jdoubleArray; +typedef jobject jthrowable; +typedef jobject jweak; + +#endif /* not __cplusplus */ + +struct _jfieldID; /* opaque structure */ +typedef struct _jfieldID* jfieldID; /* field IDs */ + +struct _jmethodID; /* opaque structure */ +typedef struct _jmethodID* jmethodID; /* method IDs */ + +struct JNIInvokeInterface; + +typedef union jvalue { + jboolean z; + jbyte b; + jchar c; + jshort s; + jint i; + jlong j; + jfloat f; + jdouble d; + jobject l; +} jvalue; + +typedef enum jobjectRefType { + JNIInvalidRefType = 0, + JNILocalRefType = 1, + JNIGlobalRefType = 2, + JNIWeakGlobalRefType = 3 +} jobjectRefType; + +typedef struct { + const char* name; + const char* signature; + void* fnPtr; +} JNINativeMethod; + +struct _JNIEnv; +struct _JavaVM; +typedef const struct JNINativeInterface* C_JNIEnv; + +#if defined(__cplusplus) +typedef _JNIEnv JNIEnv; +typedef _JavaVM JavaVM; +#else +typedef const struct JNINativeInterface* JNIEnv; +typedef const struct JNIInvokeInterface* JavaVM; +#endif + +/* + * Table of interface function pointers. + */ +struct JNINativeInterface { + void* reserved0; + void* reserved1; + void* reserved2; + void* reserved3; + + jint (*GetVersion)(JNIEnv *env); + + jclass (*DefineClass)(JNIEnv *env, const char* name, jobject loader, const jbyte* buf, + jsize bufLen); + jclass (*FindClass)(JNIEnv* env, const char* name); + + jmethodID (*FromReflectedMethod)(JNIEnv* env, jobject method); + jfieldID (*FromReflectedField)(JNIEnv* env, jobject field); + + /* spec doesn't show jboolean parameter */ + + jobject (*ToReflectedMethod)(JNIEnv* env, jclass cls, jmethodID methodId, jboolean isStatic); + + jclass (*GetSuperclass)(JNIEnv* env, jclass clazz); + jboolean (*IsAssignableFrom)(JNIEnv* env, jclass clazz1, jclass clazz2); + + /* spec doesn't show jboolean parameter */ + + jobject (*ToReflectedField)(JNIEnv* env, jclass cls, jfieldID fieldID, jboolean isStatic); + + jint (*Throw)(JNIEnv* env, jthrowable obj); + jint (*ThrowNew)(JNIEnv *env, jclass clazz, const char *message); + jthrowable (*ExceptionOccurred)(JNIEnv* env); + void (*ExceptionDescribe)(JNIEnv* env); + void (*ExceptionClear)(JNIEnv* env); + void (*FatalError)(JNIEnv* env, const char* msg); + + jint (*PushLocalFrame)(JNIEnv* env, jint capacity); + jobject (*PopLocalFrame)(JNIEnv* env, jobject result); + + jobject (*NewGlobalRef)(JNIEnv* env, jobject obj); + void (*DeleteGlobalRef)(JNIEnv* env, jobject globalRef); + void (*DeleteLocalRef)(JNIEnv* env, jobject localRef); + jboolean (*IsSameObject)(JNIEnv* env, jobject ref1, jobject ref2); + + jobject (*NewLocalRef)(JNIEnv* env, jobject ref); + jint (*EnsureLocalCapacity)(JNIEnv* env, jint capacity); + + jobject (*AllocObject)(JNIEnv* env, jclass clazz); + jobject (*NewObject)(JNIEnv*, jclass, jmethodID, ...); + jobject (*NewObjectV)(JNIEnv*, jclass, jmethodID, va_list); + jobject (*NewObjectA)(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args); + + jclass (*GetObjectClass)(JNIEnv* env, jobject obj); + jboolean (*IsInstanceOf)(JNIEnv* env, jobject obj, jclass clazz); + jmethodID (*GetMethodID)(JNIEnv* env, jclass clazz, const char* name, const char* sig); + + jobject (*CallObjectMethod)(JNIEnv*, jobject, jmethodID, ...); + jobject (*CallObjectMethodV)(JNIEnv*, jobject, jmethodID, va_list); + jobject (*CallObjectMethodA)(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args); + jboolean (*CallBooleanMethod)(JNIEnv*, jobject, jmethodID, ...); + jboolean (*CallBooleanMethodV)(JNIEnv*, jobject, jmethodID, va_list); + jboolean (*CallBooleanMethodA)(JNIEnv* env, jobject obj, jmethodID methodId, const jvalue* args); + jbyte (*CallByteMethod)(JNIEnv*, jobject, jmethodID, ...); + jbyte (*CallByteMethodV)(JNIEnv*, jobject, jmethodID, va_list); + jbyte (*CallByteMethodA)(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args); + jchar (*CallCharMethod)(JNIEnv*, jobject, jmethodID, ...); + jchar (*CallCharMethodV)(JNIEnv*, jobject, jmethodID, va_list); + jchar (*CallCharMethodA)(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args); + jshort (*CallShortMethod)(JNIEnv*, jobject, jmethodID, ...); + jshort (*CallShortMethodV)(JNIEnv*, jobject, jmethodID, va_list); + jshort (*CallShortMethodA)(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args); + jint (*CallIntMethod)(JNIEnv*, jobject, jmethodID, ...); + jint (*CallIntMethodV)(JNIEnv*, jobject, jmethodID, va_list); + jint (*CallIntMethodA)(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args); + jlong (*CallLongMethod)(JNIEnv*, jobject, jmethodID, ...); + jlong (*CallLongMethodV)(JNIEnv*, jobject, jmethodID, va_list); + jlong (*CallLongMethodA)(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args); + jfloat (*CallFloatMethod)(JNIEnv*, jobject, jmethodID, ...); + jfloat (*CallFloatMethodV)(JNIEnv*, jobject, jmethodID, va_list); + jfloat (*CallFloatMethodA)(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args); + jdouble (*CallDoubleMethod)(JNIEnv*, jobject, jmethodID, ...); + jdouble (*CallDoubleMethodV)(JNIEnv*, jobject, jmethodID, va_list); + jdouble (*CallDoubleMethodA)(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args); + void (*CallVoidMethod)(JNIEnv*, jobject, jmethodID, ...); + void (*CallVoidMethodV)(JNIEnv*, jobject, jmethodID, va_list); + void (*CallVoidMethodA)(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args); + + jobject (*CallNonvirtualObjectMethod)(JNIEnv*, jobject, jclass, + jmethodID, ...); + jobject (*CallNonvirtualObjectMethodV)(JNIEnv*, jobject, jclass, + jmethodID, va_list); + jobject (*CallNonvirtualObjectMethodA)(JNIEnv* env, jobject obj, jclass clazz, + jmethodID methodID, const jvalue* args); + jboolean (*CallNonvirtualBooleanMethod)(JNIEnv*, jobject, jclass, + jmethodID, ...); + jboolean (*CallNonvirtualBooleanMethodV)(JNIEnv*, jobject, jclass, + jmethodID, va_list); + jboolean (*CallNonvirtualBooleanMethodA)(JNIEnv* env, jobject obj, jclass clazz, + jmethodID methodID, const jvalue* args); + jbyte (*CallNonvirtualByteMethod)(JNIEnv*, jobject, jclass, + jmethodID, ...); + jbyte (*CallNonvirtualByteMethodV)(JNIEnv*, jobject, jclass, + jmethodID, va_list); + jbyte (*CallNonvirtualByteMethodA)(JNIEnv* env, jobject obj, jclass clazz, + jmethodID methodID, const jvalue* args); + jchar (*CallNonvirtualCharMethod)(JNIEnv*, jobject, jclass, + jmethodID, ...); + jchar (*CallNonvirtualCharMethodV)(JNIEnv*, jobject, jclass, + jmethodID, va_list); + jchar (*CallNonvirtualCharMethodA)(JNIEnv* env, jobject obj, jclass clazz, + jmethodID methodID, const jvalue* args); + jshort (*CallNonvirtualShortMethod)(JNIEnv*, jobject, jclass, + jmethodID, ...); + jshort (*CallNonvirtualShortMethodV)(JNIEnv*, jobject, jclass, + jmethodID, va_list); + jshort (*CallNonvirtualShortMethodA)(JNIEnv* env, jobject obj, jclass clazz, + jmethodID methodID, const jvalue* args); + jint (*CallNonvirtualIntMethod)(JNIEnv*, jobject, jclass, + jmethodID, ...); + jint (*CallNonvirtualIntMethodV)(JNIEnv*, jobject, jclass, + jmethodID, va_list); + jint (*CallNonvirtualIntMethodA)(JNIEnv* env, jobject obj, jclass clazz, + jmethodID methodID, const jvalue* args); + jlong (*CallNonvirtualLongMethod)(JNIEnv*, jobject, jclass, + jmethodID, ...); + jlong (*CallNonvirtualLongMethodV)(JNIEnv*, jobject, jclass, + jmethodID, va_list); + jlong (*CallNonvirtualLongMethodA)(JNIEnv* env, jobject obj, jclass clazz, + jmethodID methodID, const jvalue* args); + jfloat (*CallNonvirtualFloatMethod)(JNIEnv*, jobject, jclass, + jmethodID, ...); + jfloat (*CallNonvirtualFloatMethodV)(JNIEnv*, jobject, jclass, + jmethodID, va_list); + jfloat (*CallNonvirtualFloatMethodA)(JNIEnv* env, jobject obj, jclass clazz, + jmethodID methodID, const jvalue* args); + jdouble (*CallNonvirtualDoubleMethod)(JNIEnv*, jobject, jclass, + jmethodID, ...); + jdouble (*CallNonvirtualDoubleMethodV)(JNIEnv*, jobject, jclass, + jmethodID, va_list); + jdouble (*CallNonvirtualDoubleMethodA)(JNIEnv* env, jobject obj, jclass clazz, + jmethodID methodID, const jvalue* args); + void (*CallNonvirtualVoidMethod)(JNIEnv*, jobject, jclass, + jmethodID, ...); + void (*CallNonvirtualVoidMethodV)(JNIEnv*, jobject, jclass, + jmethodID, va_list); + void (*CallNonvirtualVoidMethodA)(JNIEnv* env, jobject obj, jclass clazz, + jmethodID methodID, const jvalue* args); + + jfieldID (*GetFieldID)(JNIEnv* env, jclass clazz, const char* name, const char* sig); + + jobject (*GetObjectField)(JNIEnv* env, jobject obj, jfieldID fieldID); + jboolean (*GetBooleanField)(JNIEnv* env, jobject obj, jfieldID fieldID); + jbyte (*GetByteField)(JNIEnv* env, jobject obj, jfieldID fieldID); + jchar (*GetCharField)(JNIEnv* env, jobject obj, jfieldID fieldID); + jshort (*GetShortField)(JNIEnv* env, jobject obj, jfieldID fieldID); + jint (*GetIntField)(JNIEnv* env, jobject obj, jfieldID fieldID); + jlong (*GetLongField)(JNIEnv* env, jobject obj, jfieldID fieldID); + jfloat (*GetFloatField)(JNIEnv* env, jobject obj, jfieldID fieldID); + jdouble (*GetDoubleField)(JNIEnv* env, jobject obj, jfieldID fieldID); + + void (*SetObjectField)(JNIEnv* env, jobject obj, jfieldID fieldID, jobject val); + void (*SetBooleanField)(JNIEnv* env, jobject obj, jfieldID fieldID, jboolean val); + void (*SetByteField)(JNIEnv* env, jobject obj, jfieldID fieldID, jbyte val); + void (*SetCharField)(JNIEnv* env, jobject obj, jfieldID fieldID, jchar val); + void (*SetShortField)(JNIEnv* env, jobject obj, jfieldID fieldID, jshort val); + void (*SetIntField)(JNIEnv* env, jobject obj, jfieldID fieldID, jint val); + void (*SetLongField)(JNIEnv* env, jobject obj, jfieldID fieldID, jlong val); + void (*SetFloatField)(JNIEnv* env, jobject obj, jfieldID fieldID, jfloat val); + void (*SetDoubleField)(JNIEnv* env, jobject obj, jfieldID fieldID, jdouble val); + + jmethodID (*GetStaticMethodID)(JNIEnv* env, jclass clazz, const char* name, const char* sig); + + jobject (*CallStaticObjectMethod)(JNIEnv*, jclass, jmethodID, ...); + jobject (*CallStaticObjectMethodV)(JNIEnv*, jclass, jmethodID, va_list); + jobject (*CallStaticObjectMethodA)(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args); + jboolean (*CallStaticBooleanMethod)(JNIEnv*, jclass, jmethodID, ...); + jboolean (*CallStaticBooleanMethodV)(JNIEnv*, jclass, jmethodID, + va_list); + jboolean (*CallStaticBooleanMethodA)(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args); + jbyte (*CallStaticByteMethod)(JNIEnv*, jclass, jmethodID, ...); + jbyte (*CallStaticByteMethodV)(JNIEnv*, jclass, jmethodID, va_list); + jbyte (*CallStaticByteMethodA)(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args); + jchar (*CallStaticCharMethod)(JNIEnv*, jclass, jmethodID, ...); + jchar (*CallStaticCharMethodV)(JNIEnv*, jclass, jmethodID, va_list); + jchar (*CallStaticCharMethodA)(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args); + jshort (*CallStaticShortMethod)(JNIEnv*, jclass, jmethodID, ...); + jshort (*CallStaticShortMethodV)(JNIEnv*, jclass, jmethodID, va_list); + jshort (*CallStaticShortMethodA)(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args); + jint (*CallStaticIntMethod)(JNIEnv*, jclass, jmethodID, ...); + jint (*CallStaticIntMethodV)(JNIEnv*, jclass, jmethodID, va_list); + jint (*CallStaticIntMethodA)(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args); + jlong (*CallStaticLongMethod)(JNIEnv*, jclass, jmethodID, ...); + jlong (*CallStaticLongMethodV)(JNIEnv*, jclass, jmethodID, va_list); + jlong (*CallStaticLongMethodA)(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args); + jfloat (*CallStaticFloatMethod)(JNIEnv*, jclass, jmethodID, ...); + jfloat (*CallStaticFloatMethodV)(JNIEnv*, jclass, jmethodID, va_list); + jfloat (*CallStaticFloatMethodA)(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args); + jdouble (*CallStaticDoubleMethod)(JNIEnv*, jclass, jmethodID, ...); + jdouble (*CallStaticDoubleMethodV)(JNIEnv*, jclass, jmethodID, va_list); + jdouble (*CallStaticDoubleMethodA)(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args); + void (*CallStaticVoidMethod)(JNIEnv*, jclass, jmethodID, ...); + void (*CallStaticVoidMethodV)(JNIEnv*, jclass, jmethodID, va_list); + void (*CallStaticVoidMethodA)(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args); + + jfieldID (*GetStaticFieldID)(JNIEnv* env, jclass clazz, const char* name, + const char* sig); + + jobject (*GetStaticObjectField)(JNIEnv* env, jclass clazz, jfieldID fieldID); + jboolean (*GetStaticBooleanField)(JNIEnv* env, jclass clazz, jfieldID fieldID); + jbyte (*GetStaticByteField)(JNIEnv* env, jclass clazz, jfieldID fieldID); + jchar (*GetStaticCharField)(JNIEnv* env, jclass clazz, jfieldID fieldID); + jshort (*GetStaticShortField)(JNIEnv* env, jclass clazz, jfieldID fieldID); + jint (*GetStaticIntField)(JNIEnv* env, jclass clazz, jfieldID fieldID); + jlong (*GetStaticLongField)(JNIEnv* env, jclass clazz, jfieldID fieldID); + jfloat (*GetStaticFloatField)(JNIEnv* env, jclass clazz, jfieldID fieldID); + jdouble (*GetStaticDoubleField)(JNIEnv* env, jclass clazz, jfieldID fieldID); + + void (*SetStaticObjectField)(JNIEnv* env, jclass clazz, jfieldID fieldID, jobject val); + void (*SetStaticBooleanField)(JNIEnv* env, jclass clazz, jfieldID fieldID, jboolean val); + void (*SetStaticByteField)(JNIEnv* env, jclass clazz, jfieldID fieldID, jbyte val); + void (*SetStaticCharField)(JNIEnv* env, jclass clazz, jfieldID fieldID, jchar val); + void (*SetStaticShortField)(JNIEnv* env, jclass clazz, jfieldID fieldID, jshort val); + void (*SetStaticIntField)(JNIEnv* env, jclass clazz, jfieldID fieldID, jint val); + void (*SetStaticLongField)(JNIEnv* env, jclass clazz, jfieldID fieldID, jlong val); + void (*SetStaticFloatField)(JNIEnv* env, jclass clazz, jfieldID fieldID, jfloat val); + void (*SetStaticDoubleField)(JNIEnv* env, jclass clazz, jfieldID fieldID, jdouble val); + + jstring (*NewString)(JNIEnv* env, const jchar* unicodeChars, jsize len); + jsize (*GetStringLength)(JNIEnv* env, jstring string); + const jchar* (*GetStringChars)(JNIEnv* env, jstring string, jboolean* isCopy); + void (*ReleaseStringChars)(JNIEnv* env, jstring string, const jchar* isCopy); + jstring (*NewStringUTF)(JNIEnv* env, const char* bytes); + jsize (*GetStringUTFLength)(JNIEnv* env, jstring string); + const char* (*GetStringUTFChars)(JNIEnv* env, jstring string, jboolean* isCopy); + void (*ReleaseStringUTFChars)(JNIEnv* env, jstring string, const char* utf); + jsize (*GetArrayLength)(JNIEnv* env, jarray array); + jobjectArray (*NewObjectArray)(JNIEnv* env, jsize length, jclass elementClass, jobject initialElement); + jobject (*GetObjectArrayElement)(JNIEnv* env, jobjectArray array, jsize index); + void (*SetObjectArrayElement)(JNIEnv* env, jobjectArray array, jsize index, jobject val); + + jbooleanArray (*NewBooleanArray)(JNIEnv* env, jsize length); + jbyteArray (*NewByteArray)(JNIEnv* env, jsize length); + jcharArray (*NewCharArray)(JNIEnv* env, jsize length); + jshortArray (*NewShortArray)(JNIEnv* env, jsize length); + jintArray (*NewIntArray)(JNIEnv* env, jsize length); + jlongArray (*NewLongArray)(JNIEnv* env, jsize length); + jfloatArray (*NewFloatArray)(JNIEnv* env, jsize length); + jdoubleArray (*NewDoubleArray)(JNIEnv* env, jsize length); + + jboolean* (*GetBooleanArrayElements)(JNIEnv* env, jbooleanArray array, jboolean* isCopy); + jbyte* (*GetByteArrayElements)(JNIEnv* env, jbyteArray array, jboolean* isCopy); + jchar* (*GetCharArrayElements)(JNIEnv* env, jcharArray array, jboolean* isCopy); + jshort* (*GetShortArrayElements)(JNIEnv* env, jshortArray array, jboolean* isCopy); + jint* (*GetIntArrayElements)(JNIEnv* env, jintArray array, jboolean* isCopy); + jlong* (*GetLongArrayElements)(JNIEnv* env, jlongArray array, jboolean* isCopy); + jfloat* (*GetFloatArrayElements)(JNIEnv* env, jfloatArray array, jboolean* isCopy); + jdouble* (*GetDoubleArrayElements)(JNIEnv* env, jdoubleArray array, jboolean* isCopy); + + void (*ReleaseBooleanArrayElements)(JNIEnv* env, jbooleanArray array, + jboolean* elems, jint mode); + void (*ReleaseByteArrayElements)(JNIEnv* env, jbyteArray array, + jbyte* elems, jint mode); + void (*ReleaseCharArrayElements)(JNIEnv* env, jcharArray array, + jchar* elems, jint mode); + void (*ReleaseShortArrayElements)(JNIEnv* env, jshortArray array, + jshort* elems, jint mode); + void (*ReleaseIntArrayElements)(JNIEnv* env, jintArray array, + jint* elems, jint mode); + void (*ReleaseLongArrayElements)(JNIEnv* env, jlongArray array, + jlong* elems, jint mode); + void (*ReleaseFloatArrayElements)(JNIEnv* env, jfloatArray array, + jfloat* elems, jint mode); + void (*ReleaseDoubleArrayElements)(JNIEnv* env, jdoubleArray array, + jdouble* elems, jint mode); + + void (*GetBooleanArrayRegion)(JNIEnv* env, jbooleanArray array, + jsize start, jsize len, jboolean* buf); + void (*GetByteArrayRegion)(JNIEnv* env, jbyteArray array, + jsize start, jsize len, jbyte* buf); + void (*GetCharArrayRegion)(JNIEnv* env, jcharArray array, + jsize start, jsize len, jchar* buf); + void (*GetShortArrayRegion)(JNIEnv* env, jshortArray array, + jsize start, jsize len, jshort* buf); + void (*GetIntArrayRegion)(JNIEnv* env, jintArray array, + jsize start, jsize len, jint* buf); + void (*GetLongArrayRegion)(JNIEnv* env, jlongArray array, + jsize start, jsize len, jlong* buf); + void (*GetFloatArrayRegion)(JNIEnv* env, jfloatArray array, + jsize start, jsize len, jfloat* buf); + void (*GetDoubleArrayRegion)(JNIEnv* env, jdoubleArray array, + jsize start, jsize len, jdouble* buf); + + /* spec shows these without const; some jni.h do, some don't */ + void (*SetBooleanArrayRegion)(JNIEnv* env, jbooleanArray array, + jsize start, jsize len, const jboolean* buf); + void (*SetByteArrayRegion)(JNIEnv* env, jbyteArray array, + jsize start, jsize len, const jbyte* buf); + void (*SetCharArrayRegion)(JNIEnv* env, jcharArray array, + jsize start, jsize len, const jchar* buf); + void (*SetShortArrayRegion)(JNIEnv* env, jshortArray array, + jsize start, jsize len, const jshort* buf); + void (*SetIntArrayRegion)(JNIEnv* env, jintArray array, + jsize start, jsize len, const jint* buf); + void (*SetLongArrayRegion)(JNIEnv* env, jlongArray array, + jsize start, jsize len, const jlong* buf); + void (*SetFloatArrayRegion)(JNIEnv* env, jfloatArray array, + jsize start, jsize len, const jfloat* buf); + void (*SetDoubleArrayRegion)(JNIEnv* env, jdoubleArray array, + jsize start, jsize len, const jdouble* buf); + + jint (*RegisterNatives)(JNIEnv* env, jclass clazz, const JNINativeMethod* methods, + jint nMethods); + jint (*UnregisterNatives)(JNIEnv* env, jclass clazz); + jint (*MonitorEnter)(JNIEnv* env, jobject obj); + jint (*MonitorExit)(JNIEnv* env, jobject obj); + jint (*GetJavaVM)(JNIEnv* env, JavaVM** vm); + + void (*GetStringRegion)(JNIEnv* env, jstring str, jsize start, jsize len, jchar* buf); + void (*GetStringUTFRegion)(JNIEnv* env, jstring str, jsize start, jsize len, char* buf); + + void* (*GetPrimitiveArrayCritical)(JNIEnv* env, jarray array, jboolean* isCopy); + void (*ReleasePrimitiveArrayCritical)(JNIEnv* env, jarray array, void* carray, jint mode); + + const jchar* (*GetStringCritical)(JNIEnv* env, jstring str, jboolean* isCopy); + void (*ReleaseStringCritical)(JNIEnv* env, jstring str, const jchar* carray); + + jweak (*NewWeakGlobalRef)(JNIEnv* env, jobject obj); + void (*DeleteWeakGlobalRef)(JNIEnv* env, jweak obj); + + jboolean (*ExceptionCheck)(JNIEnv* env); + + jobject (*NewDirectByteBuffer)(JNIEnv* env, void* address, jlong capacity); + void* (*GetDirectBufferAddress)(JNIEnv* env, jobject buf); + jlong (*GetDirectBufferCapacity)(JNIEnv* env, jobject buf); + + /* added in JNI 1.6 */ + jobjectRefType (*GetObjectRefType)(JNIEnv* env, jobject obj); +}; + +/* + * C++ object wrapper. + * + * This is usually overlaid on a C struct whose first element is a + * JNINativeInterface*. We rely somewhat on compiler behavior. + */ +struct _JNIEnv { + /* do not rename this; it does not seem to be entirely opaque */ + const struct JNINativeInterface* functions; + +#if defined(__cplusplus) + + jint GetVersion() + { return functions->GetVersion(this); } + + jclass DefineClass(const char *name, jobject loader, const jbyte* buf, + jsize bufLen) + { return functions->DefineClass(this, name, loader, buf, bufLen); } + + jclass FindClass(const char* name) + { return functions->FindClass(this, name); } + + jmethodID FromReflectedMethod(jobject method) + { return functions->FromReflectedMethod(this, method); } + + jfieldID FromReflectedField(jobject field) + { return functions->FromReflectedField(this, field); } + + jobject ToReflectedMethod(jclass cls, jmethodID methodID, jboolean isStatic) + { return functions->ToReflectedMethod(this, cls, methodID, isStatic); } + + jclass GetSuperclass(jclass clazz) + { return functions->GetSuperclass(this, clazz); } + + jboolean IsAssignableFrom(jclass clazz1, jclass clazz2) + { return functions->IsAssignableFrom(this, clazz1, clazz2); } + + jobject ToReflectedField(jclass cls, jfieldID fieldID, jboolean isStatic) + { return functions->ToReflectedField(this, cls, fieldID, isStatic); } + + jint Throw(jthrowable obj) + { return functions->Throw(this, obj); } + + jint ThrowNew(jclass clazz, const char* message) + { return functions->ThrowNew(this, clazz, message); } + + jthrowable ExceptionOccurred() + { return functions->ExceptionOccurred(this); } + + void ExceptionDescribe() + { functions->ExceptionDescribe(this); } + + void ExceptionClear() + { functions->ExceptionClear(this); } + + void FatalError(const char* msg) + { functions->FatalError(this, msg); } + + jint PushLocalFrame(jint capacity) + { return functions->PushLocalFrame(this, capacity); } + + jobject PopLocalFrame(jobject result) + { return functions->PopLocalFrame(this, result); } + + jobject NewGlobalRef(jobject obj) + { return functions->NewGlobalRef(this, obj); } + + void DeleteGlobalRef(jobject globalRef) + { functions->DeleteGlobalRef(this, globalRef); } + + void DeleteLocalRef(jobject localRef) + { functions->DeleteLocalRef(this, localRef); } + + jboolean IsSameObject(jobject ref1, jobject ref2) + { return functions->IsSameObject(this, ref1, ref2); } + + jobject NewLocalRef(jobject ref) + { return functions->NewLocalRef(this, ref); } + + jint EnsureLocalCapacity(jint capacity) + { return functions->EnsureLocalCapacity(this, capacity); } + + jobject AllocObject(jclass clazz) + { return functions->AllocObject(this, clazz); } + + jobject NewObject(jclass clazz, jmethodID methodID, ...) + { + va_list args; + va_start(args, methodID); + jobject result = functions->NewObjectV(this, clazz, methodID, args); + va_end(args); + return result; + } + + jobject NewObjectV(jclass clazz, jmethodID methodID, va_list args) + { return functions->NewObjectV(this, clazz, methodID, args); } + + jobject NewObjectA(jclass clazz, jmethodID methodID, const jvalue* args) + { return functions->NewObjectA(this, clazz, methodID, args); } + + jclass GetObjectClass(jobject obj) + { return functions->GetObjectClass(this, obj); } + + jboolean IsInstanceOf(jobject obj, jclass clazz) + { return functions->IsInstanceOf(this, obj, clazz); } + + jmethodID GetMethodID(jclass clazz, const char* name, const char* sig) + { return functions->GetMethodID(this, clazz, name, sig); } + +#define CALL_TYPE_METHOD(_jtype, _jname) \ + _jtype Call##_jname##Method(jobject obj, jmethodID methodID, ...) \ + { \ + _jtype result; \ + va_list args; \ + va_start(args, methodID); \ + result = functions->Call##_jname##MethodV(this, obj, methodID, \ + args); \ + va_end(args); \ + return result; \ + } +#define CALL_TYPE_METHODV(_jtype, _jname) \ + _jtype Call##_jname##MethodV(jobject obj, jmethodID methodID, \ + va_list args) \ + { return functions->Call##_jname##MethodV(this, obj, methodID, args); } +#define CALL_TYPE_METHODA(_jtype, _jname) \ + _jtype Call##_jname##MethodA(jobject obj, jmethodID methodID, \ + const jvalue* args) \ + { return functions->Call##_jname##MethodA(this, obj, methodID, args); } + +#define CALL_TYPE(_jtype, _jname) \ + CALL_TYPE_METHOD(_jtype, _jname) \ + CALL_TYPE_METHODV(_jtype, _jname) \ + CALL_TYPE_METHODA(_jtype, _jname) + + CALL_TYPE(jobject, Object) + CALL_TYPE(jboolean, Boolean) + CALL_TYPE(jbyte, Byte) + CALL_TYPE(jchar, Char) + CALL_TYPE(jshort, Short) + CALL_TYPE(jint, Int) + CALL_TYPE(jlong, Long) + CALL_TYPE(jfloat, Float) + CALL_TYPE(jdouble, Double) + + void CallVoidMethod(jobject obj, jmethodID methodID, ...) + { + va_list args; + va_start(args, methodID); + functions->CallVoidMethodV(this, obj, methodID, args); + va_end(args); + } + void CallVoidMethodV(jobject obj, jmethodID methodID, va_list args) + { functions->CallVoidMethodV(this, obj, methodID, args); } + void CallVoidMethodA(jobject obj, jmethodID methodID, const jvalue* args) + { functions->CallVoidMethodA(this, obj, methodID, args); } + +#define CALL_NONVIRT_TYPE_METHOD(_jtype, _jname) \ + _jtype CallNonvirtual##_jname##Method(jobject obj, jclass clazz, \ + jmethodID methodID, ...) \ + { \ + _jtype result; \ + va_list args; \ + va_start(args, methodID); \ + result = functions->CallNonvirtual##_jname##MethodV(this, obj, \ + clazz, methodID, args); \ + va_end(args); \ + return result; \ + } +#define CALL_NONVIRT_TYPE_METHODV(_jtype, _jname) \ + _jtype CallNonvirtual##_jname##MethodV(jobject obj, jclass clazz, \ + jmethodID methodID, va_list args) \ + { return functions->CallNonvirtual##_jname##MethodV(this, obj, clazz, \ + methodID, args); } +#define CALL_NONVIRT_TYPE_METHODA(_jtype, _jname) \ + _jtype CallNonvirtual##_jname##MethodA(jobject obj, jclass clazz, \ + jmethodID methodID, const jvalue* args) \ + { return functions->CallNonvirtual##_jname##MethodA(this, obj, clazz, \ + methodID, args); } + +#define CALL_NONVIRT_TYPE(_jtype, _jname) \ + CALL_NONVIRT_TYPE_METHOD(_jtype, _jname) \ + CALL_NONVIRT_TYPE_METHODV(_jtype, _jname) \ + CALL_NONVIRT_TYPE_METHODA(_jtype, _jname) + + CALL_NONVIRT_TYPE(jobject, Object) + CALL_NONVIRT_TYPE(jboolean, Boolean) + CALL_NONVIRT_TYPE(jbyte, Byte) + CALL_NONVIRT_TYPE(jchar, Char) + CALL_NONVIRT_TYPE(jshort, Short) + CALL_NONVIRT_TYPE(jint, Int) + CALL_NONVIRT_TYPE(jlong, Long) + CALL_NONVIRT_TYPE(jfloat, Float) + CALL_NONVIRT_TYPE(jdouble, Double) + + void CallNonvirtualVoidMethod(jobject obj, jclass clazz, + jmethodID methodID, ...) + { + va_list args; + va_start(args, methodID); + functions->CallNonvirtualVoidMethodV(this, obj, clazz, methodID, args); + va_end(args); + } + void CallNonvirtualVoidMethodV(jobject obj, jclass clazz, + jmethodID methodID, va_list args) + { functions->CallNonvirtualVoidMethodV(this, obj, clazz, methodID, args); } + void CallNonvirtualVoidMethodA(jobject obj, jclass clazz, + jmethodID methodID, const jvalue* args) + { functions->CallNonvirtualVoidMethodA(this, obj, clazz, methodID, args); } + + jfieldID GetFieldID(jclass clazz, const char* name, const char* sig) + { return functions->GetFieldID(this, clazz, name, sig); } + + jobject GetObjectField(jobject obj, jfieldID fieldID) + { return functions->GetObjectField(this, obj, fieldID); } + jboolean GetBooleanField(jobject obj, jfieldID fieldID) + { return functions->GetBooleanField(this, obj, fieldID); } + jbyte GetByteField(jobject obj, jfieldID fieldID) + { return functions->GetByteField(this, obj, fieldID); } + jchar GetCharField(jobject obj, jfieldID fieldID) + { return functions->GetCharField(this, obj, fieldID); } + jshort GetShortField(jobject obj, jfieldID fieldID) + { return functions->GetShortField(this, obj, fieldID); } + jint GetIntField(jobject obj, jfieldID fieldID) + { return functions->GetIntField(this, obj, fieldID); } + jlong GetLongField(jobject obj, jfieldID fieldID) + { return functions->GetLongField(this, obj, fieldID); } + jfloat GetFloatField(jobject obj, jfieldID fieldID) + { return functions->GetFloatField(this, obj, fieldID); } + jdouble GetDoubleField(jobject obj, jfieldID fieldID) + { return functions->GetDoubleField(this, obj, fieldID); } + + void SetObjectField(jobject obj, jfieldID fieldID, jobject val) + { functions->SetObjectField(this, obj, fieldID, val); } + void SetBooleanField(jobject obj, jfieldID fieldID, jboolean val) + { functions->SetBooleanField(this, obj, fieldID, val); } + void SetByteField(jobject obj, jfieldID fieldID, jbyte val) + { functions->SetByteField(this, obj, fieldID, val); } + void SetCharField(jobject obj, jfieldID fieldID, jchar val) + { functions->SetCharField(this, obj, fieldID, val); } + void SetShortField(jobject obj, jfieldID fieldID, jshort val) + { functions->SetShortField(this, obj, fieldID, val); } + void SetIntField(jobject obj, jfieldID fieldID, jint val) + { functions->SetIntField(this, obj, fieldID, val); } + void SetLongField(jobject obj, jfieldID fieldID, jlong val) + { functions->SetLongField(this, obj, fieldID, val); } + void SetFloatField(jobject obj, jfieldID fieldID, jfloat val) + { functions->SetFloatField(this, obj, fieldID, val); } + void SetDoubleField(jobject obj, jfieldID fieldID, jdouble val) + { functions->SetDoubleField(this, obj, fieldID, val); } + + jmethodID GetStaticMethodID(jclass clazz, const char* name, const char* sig) + { return functions->GetStaticMethodID(this, clazz, name, sig); } + +#define CALL_STATIC_TYPE_METHOD(_jtype, _jname) \ + _jtype CallStatic##_jname##Method(jclass clazz, jmethodID methodID, \ + ...) \ + { \ + _jtype result; \ + va_list args; \ + va_start(args, methodID); \ + result = functions->CallStatic##_jname##MethodV(this, clazz, \ + methodID, args); \ + va_end(args); \ + return result; \ + } +#define CALL_STATIC_TYPE_METHODV(_jtype, _jname) \ + _jtype CallStatic##_jname##MethodV(jclass clazz, jmethodID methodID, \ + va_list args) \ + { return functions->CallStatic##_jname##MethodV(this, clazz, methodID, \ + args); } +#define CALL_STATIC_TYPE_METHODA(_jtype, _jname) \ + _jtype CallStatic##_jname##MethodA(jclass clazz, jmethodID methodID, \ + const jvalue* args) \ + { return functions->CallStatic##_jname##MethodA(this, clazz, methodID, \ + args); } + +#define CALL_STATIC_TYPE(_jtype, _jname) \ + CALL_STATIC_TYPE_METHOD(_jtype, _jname) \ + CALL_STATIC_TYPE_METHODV(_jtype, _jname) \ + CALL_STATIC_TYPE_METHODA(_jtype, _jname) + + CALL_STATIC_TYPE(jobject, Object) + CALL_STATIC_TYPE(jboolean, Boolean) + CALL_STATIC_TYPE(jbyte, Byte) + CALL_STATIC_TYPE(jchar, Char) + CALL_STATIC_TYPE(jshort, Short) + CALL_STATIC_TYPE(jint, Int) + CALL_STATIC_TYPE(jlong, Long) + CALL_STATIC_TYPE(jfloat, Float) + CALL_STATIC_TYPE(jdouble, Double) + + void CallStaticVoidMethod(jclass clazz, jmethodID methodID, ...) + { + va_list args; + va_start(args, methodID); + functions->CallStaticVoidMethodV(this, clazz, methodID, args); + va_end(args); + } + void CallStaticVoidMethodV(jclass clazz, jmethodID methodID, va_list args) + { functions->CallStaticVoidMethodV(this, clazz, methodID, args); } + void CallStaticVoidMethodA(jclass clazz, jmethodID methodID, const jvalue* args) + { functions->CallStaticVoidMethodA(this, clazz, methodID, args); } + + jfieldID GetStaticFieldID(jclass clazz, const char* name, const char* sig) + { return functions->GetStaticFieldID(this, clazz, name, sig); } + + jobject GetStaticObjectField(jclass clazz, jfieldID fieldID) + { return functions->GetStaticObjectField(this, clazz, fieldID); } + jboolean GetStaticBooleanField(jclass clazz, jfieldID fieldID) + { return functions->GetStaticBooleanField(this, clazz, fieldID); } + jbyte GetStaticByteField(jclass clazz, jfieldID fieldID) + { return functions->GetStaticByteField(this, clazz, fieldID); } + jchar GetStaticCharField(jclass clazz, jfieldID fieldID) + { return functions->GetStaticCharField(this, clazz, fieldID); } + jshort GetStaticShortField(jclass clazz, jfieldID fieldID) + { return functions->GetStaticShortField(this, clazz, fieldID); } + jint GetStaticIntField(jclass clazz, jfieldID fieldID) + { return functions->GetStaticIntField(this, clazz, fieldID); } + jlong GetStaticLongField(jclass clazz, jfieldID fieldID) + { return functions->GetStaticLongField(this, clazz, fieldID); } + jfloat GetStaticFloatField(jclass clazz, jfieldID fieldID) + { return functions->GetStaticFloatField(this, clazz, fieldID); } + jdouble GetStaticDoubleField(jclass clazz, jfieldID fieldID) + { return functions->GetStaticDoubleField(this, clazz, fieldID); } + + void SetStaticObjectField(jclass clazz, jfieldID fieldID, jobject val) + { functions->SetStaticObjectField(this, clazz, fieldID, val); } + void SetStaticBooleanField(jclass clazz, jfieldID fieldID, jboolean val) + { functions->SetStaticBooleanField(this, clazz, fieldID, val); } + void SetStaticByteField(jclass clazz, jfieldID fieldID, jbyte val) + { functions->SetStaticByteField(this, clazz, fieldID, val); } + void SetStaticCharField(jclass clazz, jfieldID fieldID, jchar val) + { functions->SetStaticCharField(this, clazz, fieldID, val); } + void SetStaticShortField(jclass clazz, jfieldID fieldID, jshort val) + { functions->SetStaticShortField(this, clazz, fieldID, val); } + void SetStaticIntField(jclass clazz, jfieldID fieldID, jint val) + { functions->SetStaticIntField(this, clazz, fieldID, val); } + void SetStaticLongField(jclass clazz, jfieldID fieldID, jlong val) + { functions->SetStaticLongField(this, clazz, fieldID, val); } + void SetStaticFloatField(jclass clazz, jfieldID fieldID, jfloat val) + { functions->SetStaticFloatField(this, clazz, fieldID, val); } + void SetStaticDoubleField(jclass clazz, jfieldID fieldID, jdouble val) + { functions->SetStaticDoubleField(this, clazz, fieldID, val); } + + jstring NewString(const jchar* unicodeChars, jsize len) + { return functions->NewString(this, unicodeChars, len); } + + jsize GetStringLength(jstring string) + { return functions->GetStringLength(this, string); } + + const jchar* GetStringChars(jstring string, jboolean* isCopy) + { return functions->GetStringChars(this, string, isCopy); } + + void ReleaseStringChars(jstring string, const jchar* chars) + { functions->ReleaseStringChars(this, string, chars); } + + jstring NewStringUTF(const char* bytes) + { return functions->NewStringUTF(this, bytes); } + + jsize GetStringUTFLength(jstring string) + { return functions->GetStringUTFLength(this, string); } + + const char* GetStringUTFChars(jstring string, jboolean* isCopy) + { return functions->GetStringUTFChars(this, string, isCopy); } + + void ReleaseStringUTFChars(jstring string, const char* utf) + { functions->ReleaseStringUTFChars(this, string, utf); } + + jsize GetArrayLength(jarray array) + { return functions->GetArrayLength(this, array); } + + jobjectArray NewObjectArray(jsize length, jclass elementClass, + jobject initialElement) + { return functions->NewObjectArray(this, length, elementClass, + initialElement); } + + jobject GetObjectArrayElement(jobjectArray array, jsize index) + { return functions->GetObjectArrayElement(this, array, index); } + + void SetObjectArrayElement(jobjectArray array, jsize index, jobject val) + { functions->SetObjectArrayElement(this, array, index, val); } + + jbooleanArray NewBooleanArray(jsize length) + { return functions->NewBooleanArray(this, length); } + jbyteArray NewByteArray(jsize length) + { return functions->NewByteArray(this, length); } + jcharArray NewCharArray(jsize length) + { return functions->NewCharArray(this, length); } + jshortArray NewShortArray(jsize length) + { return functions->NewShortArray(this, length); } + jintArray NewIntArray(jsize length) + { return functions->NewIntArray(this, length); } + jlongArray NewLongArray(jsize length) + { return functions->NewLongArray(this, length); } + jfloatArray NewFloatArray(jsize length) + { return functions->NewFloatArray(this, length); } + jdoubleArray NewDoubleArray(jsize length) + { return functions->NewDoubleArray(this, length); } + + jboolean* GetBooleanArrayElements(jbooleanArray array, jboolean* isCopy) + { return functions->GetBooleanArrayElements(this, array, isCopy); } + jbyte* GetByteArrayElements(jbyteArray array, jboolean* isCopy) + { return functions->GetByteArrayElements(this, array, isCopy); } + jchar* GetCharArrayElements(jcharArray array, jboolean* isCopy) + { return functions->GetCharArrayElements(this, array, isCopy); } + jshort* GetShortArrayElements(jshortArray array, jboolean* isCopy) + { return functions->GetShortArrayElements(this, array, isCopy); } + jint* GetIntArrayElements(jintArray array, jboolean* isCopy) + { return functions->GetIntArrayElements(this, array, isCopy); } + jlong* GetLongArrayElements(jlongArray array, jboolean* isCopy) + { return functions->GetLongArrayElements(this, array, isCopy); } + jfloat* GetFloatArrayElements(jfloatArray array, jboolean* isCopy) + { return functions->GetFloatArrayElements(this, array, isCopy); } + jdouble* GetDoubleArrayElements(jdoubleArray array, jboolean* isCopy) + { return functions->GetDoubleArrayElements(this, array, isCopy); } + + void ReleaseBooleanArrayElements(jbooleanArray array, jboolean* elems, + jint mode) + { functions->ReleaseBooleanArrayElements(this, array, elems, mode); } + void ReleaseByteArrayElements(jbyteArray array, jbyte* elems, + jint mode) + { functions->ReleaseByteArrayElements(this, array, elems, mode); } + void ReleaseCharArrayElements(jcharArray array, jchar* elems, + jint mode) + { functions->ReleaseCharArrayElements(this, array, elems, mode); } + void ReleaseShortArrayElements(jshortArray array, jshort* elems, + jint mode) + { functions->ReleaseShortArrayElements(this, array, elems, mode); } + void ReleaseIntArrayElements(jintArray array, jint* elems, + jint mode) + { functions->ReleaseIntArrayElements(this, array, elems, mode); } + void ReleaseLongArrayElements(jlongArray array, jlong* elems, + jint mode) + { functions->ReleaseLongArrayElements(this, array, elems, mode); } + void ReleaseFloatArrayElements(jfloatArray array, jfloat* elems, + jint mode) + { functions->ReleaseFloatArrayElements(this, array, elems, mode); } + void ReleaseDoubleArrayElements(jdoubleArray array, jdouble* elems, + jint mode) + { functions->ReleaseDoubleArrayElements(this, array, elems, mode); } + + void GetBooleanArrayRegion(jbooleanArray array, jsize start, jsize len, + jboolean* buf) + { functions->GetBooleanArrayRegion(this, array, start, len, buf); } + void GetByteArrayRegion(jbyteArray array, jsize start, jsize len, + jbyte* buf) + { functions->GetByteArrayRegion(this, array, start, len, buf); } + void GetCharArrayRegion(jcharArray array, jsize start, jsize len, + jchar* buf) + { functions->GetCharArrayRegion(this, array, start, len, buf); } + void GetShortArrayRegion(jshortArray array, jsize start, jsize len, + jshort* buf) + { functions->GetShortArrayRegion(this, array, start, len, buf); } + void GetIntArrayRegion(jintArray array, jsize start, jsize len, + jint* buf) + { functions->GetIntArrayRegion(this, array, start, len, buf); } + void GetLongArrayRegion(jlongArray array, jsize start, jsize len, + jlong* buf) + { functions->GetLongArrayRegion(this, array, start, len, buf); } + void GetFloatArrayRegion(jfloatArray array, jsize start, jsize len, + jfloat* buf) + { functions->GetFloatArrayRegion(this, array, start, len, buf); } + void GetDoubleArrayRegion(jdoubleArray array, jsize start, jsize len, + jdouble* buf) + { functions->GetDoubleArrayRegion(this, array, start, len, buf); } + + void SetBooleanArrayRegion(jbooleanArray array, jsize start, jsize len, + const jboolean* buf) + { functions->SetBooleanArrayRegion(this, array, start, len, buf); } + void SetByteArrayRegion(jbyteArray array, jsize start, jsize len, + const jbyte* buf) + { functions->SetByteArrayRegion(this, array, start, len, buf); } + void SetCharArrayRegion(jcharArray array, jsize start, jsize len, + const jchar* buf) + { functions->SetCharArrayRegion(this, array, start, len, buf); } + void SetShortArrayRegion(jshortArray array, jsize start, jsize len, + const jshort* buf) + { functions->SetShortArrayRegion(this, array, start, len, buf); } + void SetIntArrayRegion(jintArray array, jsize start, jsize len, + const jint* buf) + { functions->SetIntArrayRegion(this, array, start, len, buf); } + void SetLongArrayRegion(jlongArray array, jsize start, jsize len, + const jlong* buf) + { functions->SetLongArrayRegion(this, array, start, len, buf); } + void SetFloatArrayRegion(jfloatArray array, jsize start, jsize len, + const jfloat* buf) + { functions->SetFloatArrayRegion(this, array, start, len, buf); } + void SetDoubleArrayRegion(jdoubleArray array, jsize start, jsize len, + const jdouble* buf) + { functions->SetDoubleArrayRegion(this, array, start, len, buf); } + + jint RegisterNatives(jclass clazz, const JNINativeMethod* methods, + jint nMethods) + { return functions->RegisterNatives(this, clazz, methods, nMethods); } + + jint UnregisterNatives(jclass clazz) + { return functions->UnregisterNatives(this, clazz); } + + jint MonitorEnter(jobject obj) + { return functions->MonitorEnter(this, obj); } + + jint MonitorExit(jobject obj) + { return functions->MonitorExit(this, obj); } + + jint GetJavaVM(JavaVM** vm) + { return functions->GetJavaVM(this, vm); } + + void GetStringRegion(jstring str, jsize start, jsize len, jchar* buf) + { functions->GetStringRegion(this, str, start, len, buf); } + + void GetStringUTFRegion(jstring str, jsize start, jsize len, char* buf) + { return functions->GetStringUTFRegion(this, str, start, len, buf); } + + void* GetPrimitiveArrayCritical(jarray array, jboolean* isCopy) + { return functions->GetPrimitiveArrayCritical(this, array, isCopy); } + + void ReleasePrimitiveArrayCritical(jarray array, void* carray, jint mode) + { functions->ReleasePrimitiveArrayCritical(this, array, carray, mode); } + + const jchar* GetStringCritical(jstring string, jboolean* isCopy) + { return functions->GetStringCritical(this, string, isCopy); } + + void ReleaseStringCritical(jstring string, const jchar* carray) + { functions->ReleaseStringCritical(this, string, carray); } + + jweak NewWeakGlobalRef(jobject obj) + { return functions->NewWeakGlobalRef(this, obj); } + + void DeleteWeakGlobalRef(jweak obj) + { functions->DeleteWeakGlobalRef(this, obj); } + + jboolean ExceptionCheck() + { return functions->ExceptionCheck(this); } + + jobject NewDirectByteBuffer(void* address, jlong capacity) + { return functions->NewDirectByteBuffer(this, address, capacity); } + + void* GetDirectBufferAddress(jobject buf) + { return functions->GetDirectBufferAddress(this, buf); } + + jlong GetDirectBufferCapacity(jobject buf) + { return functions->GetDirectBufferCapacity(this, buf); } + + /* added in JNI 1.6 */ + jobjectRefType GetObjectRefType(jobject obj) + { return functions->GetObjectRefType(this, obj); } +#endif /*__cplusplus*/ +}; + + +/* + * JNI invocation interface. + */ +struct JNIInvokeInterface { + void* reserved0; + void* reserved1; + void* reserved2; + + jint (*DestroyJavaVM)(JavaVM* vm); + jint (*AttachCurrentThread)(JavaVM* vm, JNIEnv** p_env, void* thr_args); + jint (*DetachCurrentThread)(JavaVM* vm); + jint (*GetEnv)(JavaVM* vm, void** p_env, jint version); + jint (*AttachCurrentThreadAsDaemon)(JavaVM* vm, JNIEnv** p_env, void* thr_args); +}; + +/* + * C++ version. + */ +struct _JavaVM { + const struct JNIInvokeInterface* functions; + +#if defined(__cplusplus) + jint DestroyJavaVM() + { return functions->DestroyJavaVM(this); } + jint AttachCurrentThread(JNIEnv** p_env, void* thr_args) + { return functions->AttachCurrentThread(this, p_env, thr_args); } + jint DetachCurrentThread() + { return functions->DetachCurrentThread(this); } + jint GetEnv(void** env, jint version) + { return functions->GetEnv(this, env, version); } + jint AttachCurrentThreadAsDaemon(JNIEnv** p_env, void* thr_args) + { return functions->AttachCurrentThreadAsDaemon(this, p_env, thr_args); } +#endif /*__cplusplus*/ +}; + +struct JavaVMAttachArgs { + jint version; /* must be >= JNI_VERSION_1_2 */ + const char* name; /* NULL or name of thread as modified UTF-8 str */ + jobject group; /* global ref of a ThreadGroup object, or NULL */ +}; +typedef struct JavaVMAttachArgs JavaVMAttachArgs; + +/* + * JNI 1.2+ initialization. (As of 1.6, the pre-1.2 structures are no + * longer supported.) + */ +typedef struct JavaVMOption { + const char* optionString; + void* extraInfo; +} JavaVMOption; + +typedef struct JavaVMInitArgs { + jint version; /* use JNI_VERSION_1_2 or later */ + + jint nOptions; + JavaVMOption* options; + jboolean ignoreUnrecognized; +} JavaVMInitArgs; + +#ifdef __cplusplus +extern "C" { +#endif +/* + * VM initialization functions. + * + * Note these are the only symbols exported for JNI by the VM. + */ + +jint JNI_GetDefaultJavaVMInitArgs(void*); +jint JNI_CreateJavaVM(JavaVM**, JNIEnv**, void*); +jint JNI_GetCreatedJavaVMs(JavaVM**, jsize, jsize*); + +#define JNIIMPORT +#define JNIEXPORT __attribute__ ((visibility ("default"))) +#define JNICALL + +/* + * Prototypes for functions exported by loadable shared libs. These are + * called by JNI, not provided by JNI. + */ +JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved); +JNIEXPORT void JNI_OnUnload(JavaVM* vm, void* reserved); + +#ifdef __cplusplus +} +#endif + + +/* + * Manifest constants. + */ +#define JNI_FALSE 0 +#define JNI_TRUE 1 + +#define JNI_VERSION_1_1 0x00010001 +#define JNI_VERSION_1_2 0x00010002 +#define JNI_VERSION_1_4 0x00010004 +#define JNI_VERSION_1_6 0x00010006 + +#define JNI_OK (0) /* no error */ +#define JNI_ERR (-1) /* generic error */ +#define JNI_EDETACHED (-2) /* thread detached from the VM */ +#define JNI_EVERSION (-3) /* JNI version error */ +#define JNI_ENOMEM (-4) /* Out of memory */ +#define JNI_EEXIST (-5) /* VM already created */ +#define JNI_EINVAL (-6) /* Invalid argument */ + +#define JNI_COMMIT 1 /* copy content, do not free buffer */ +#define JNI_ABORT 2 /* free buffer w/o copying back */ + diff --git a/pkgs/jni/tool/gen_aux_methods.dart b/pkgs/jni/tool/gen_aux_methods.dart new file mode 100644 index 000000000..0c7ae586e --- /dev/null +++ b/pkgs/jni/tool/gen_aux_methods.dart @@ -0,0 +1,129 @@ +/// Run from templates directory + +import 'dart:io' as io; +import 'package:path/path.dart'; + +final targetTypes = { + "String": "String", + "Object": "JniObject", + "Boolean": "bool", + "Byte": "int", + "Char": "int", + "Short": "int", + "Int": "int", + "Long": "int", + "Float": "double", + "Double": "double", + "Void": "void" +}; + +final resultConverters = { + "String": (String resultVar) => "return strRes", + "Object": (String resultVar) => + "return JniObject.of(_env, $resultVar, nullptr)", + "Boolean": (String resultVar) => "return $resultVar != 0", +}; + +final invokeResultConverters = { + "String": (String resultVar) => "return strRes", + "Object": (String resultVar) => + "return JniObject.of(env, $resultVar, nullptr)", + "Boolean": (String resultVar) => "return $resultVar != 0", +}; + +void main(List args) { + final script = io.Platform.script; + final scriptDir = dirname(script.toFilePath(windows: io.Platform.isWindows)); + String getTemplate(String name) { + return io.File(join(scriptDir, 'templates', name)).readAsStringSync(); + } + + final methodTemplates = getTemplate('jni_object_methods.dart.tmpl'); + final fieldTemplates = getTemplate('jni_object_fields.dart.tmpl'); + final invokeTemplates = getTemplate('invoke_static_methods.dart.tmpl'); + final retrieveTemplates = getTemplate('retrieve_static_fields.dart.tmpl'); + + final outputDir = join("lib", "src"); + final sInst = StringBuffer(); + final sStatic = StringBuffer(); + final sInvoke = StringBuffer(); + final outPutPaths = { + sInst: join(outputDir, "jni_object_methods_generated.dart"), + sStatic: join(outputDir, "jni_class_methods_generated.dart"), + sInvoke: join(outputDir, "direct_methods_generated.dart") + }; + for (final s in [sInst, sStatic, sInvoke]) { + s.write("// Autogenerated; DO NOT EDIT\n" + "// Generated by running the script in tool/gen_aux_methods.dart\n"); + s.write("// coverage:ignore-file\n"); + } + + sInst.write("part of 'jni_object.dart';\n\n"); + sStatic.write("part of 'jni_class.dart';\n\n"); + sInvoke.write("part of 'jni.dart';\n\n"); + + sInst.write("extension JniObjectCallMethods on JniObject {"); + sStatic.write("extension JniClassCallMethods on JniClass {"); + sInvoke.write("extension JniInvokeMethods on Jni {"); + + for (final t in targetTypes.keys) { + void write(String template) { + final resultConverter = + resultConverters[t] ?? (resultVar) => "return $resultVar"; + final skel = template + .replaceAll("{TYPE}", t == "String" ? "Object" : t) + .replaceAll("{PTYPE}", t) + .replaceAll("{TARGET_TYPE}", targetTypes[t]!) + .replaceAll("{RESULT}", resultConverter("result")) + .replaceAll( + "{STR_REF_DEL}", + t == "String" + ? "final strRes = _env.asDartString(result, " + "deleteOriginal: true);" + : ""); + final inst_ = + skel.replaceAll("{STATIC}", "").replaceAll("{THIS}", "_obj"); + final static_ = + skel.replaceAll("{STATIC}", "Static").replaceAll("{THIS}", "_cls"); + sInst.write(inst_); + sStatic.write(static_); + } + + write(methodTemplates); + if (t != "Void") { + write(fieldTemplates); + } + final invokeResultConverter = + (invokeResultConverters[t] ?? (String r) => "return $r"); + void writeI(String template) { + final replaced = template + .replaceAll("{TYPE}", t == "String" ? "Object" : t) + .replaceAll("{PTYPE}", t) + .replaceAll("{TARGET_TYPE}", targetTypes[t]!) + .replaceAll("{CLS_REF_DEL}", + t == "Object" || t == "String" ? "" : "env.DeleteLocalRef(cls);") + .replaceAll( + "{STR_REF_DEL}", + t == "String" + ? "final strRes = env.asDartString(result, " + "deleteOriginal: true);" + : "") + .replaceAll("{INVOKE_RESULT}", invokeResultConverter("result")); + sInvoke.write(replaced); + } + + writeI(invokeTemplates); + if (t != "Void") { + writeI(retrieveTemplates); + } + } + sInst.write("}"); + sStatic.write("}"); + sInvoke.write("}"); + for (final s in [sInst, sStatic, sInvoke]) { + final outputFile = io.File(outPutPaths[s]!); + outputFile.writeAsStringSync(s.toString(), flush: true); + } + io.stderr.write("Running dart format..\n"); + io.Process.run("dart", ["format", ...outPutPaths.values]); +} diff --git a/pkgs/jni/tool/templates/invoke_static_methods.dart.tmpl b/pkgs/jni/tool/templates/invoke_static_methods.dart.tmpl new file mode 100644 index 000000000..7372d4c0d --- /dev/null +++ b/pkgs/jni/tool/templates/invoke_static_methods.dart.tmpl @@ -0,0 +1,29 @@ + {TARGET_TYPE} invoke{PTYPE}Method(String className, String methodName, String signature, List args) { + return using((Arena arena) { + final env = getEnv(); + final classNameChars = className.toNativeChars(arena); + final methodNameChars = methodName.toNativeChars(arena); + final signatureChars = signature.toNativeChars(arena); + final cls = _bindings.LoadClass(classNameChars); + if (cls == nullptr) { + env.checkException(); + } + final methodID = env.GetStaticMethodID(cls, methodNameChars, signatureChars); + if (methodID == nullptr) { + try { + env.checkException(); + } catch (e) { + env.DeleteLocalRef(cls); + rethrow; + } + } + final jvArgs = JValueArgs(args, env, arena); + final result = env.CallStatic{TYPE}MethodA(cls, methodID, jvArgs.values); + jvArgs.disposeIn(env); + {CLS_REF_DEL} + {STR_REF_DEL} + env.checkException(); + {INVOKE_RESULT}; + }); + } + diff --git a/pkgs/jni/tool/templates/jni_object_fields.dart.tmpl b/pkgs/jni/tool/templates/jni_object_fields.dart.tmpl new file mode 100644 index 000000000..e7ea50b3c --- /dev/null +++ b/pkgs/jni/tool/templates/jni_object_fields.dart.tmpl @@ -0,0 +1,16 @@ + /// Retrieves the value of the field denoted by [fieldID] + {TARGET_TYPE} get{STATIC}{PTYPE}Field(JFieldID fieldID) { + _checkDeleted(); + final result = _env.Get{STATIC}{TYPE}Field({THIS}, fieldID); + {STR_REF_DEL} + _env.checkException(); + {RESULT}; + } + + /// Retrieve field of given [name] and [signature] + {TARGET_TYPE} get{STATIC}{PTYPE}FieldByName(String name, String signature) { + final fID = get{STATIC}FieldID(name, signature); + final result = get{STATIC}{PTYPE}Field(fID); + return result; + } + diff --git a/pkgs/jni/tool/templates/jni_object_methods.dart.tmpl b/pkgs/jni/tool/templates/jni_object_methods.dart.tmpl new file mode 100644 index 000000000..462a0d440 --- /dev/null +++ b/pkgs/jni/tool/templates/jni_object_methods.dart.tmpl @@ -0,0 +1,23 @@ + /// Calls method pointed to by [methodID] with [args] as arguments + {TARGET_TYPE} call{STATIC}{PTYPE}Method(JMethodID methodID, List args) { + _checkDeleted(); + final jvArgs = JValueArgs(args, _env); + final result = _env.Call{STATIC}{TYPE}MethodA({THIS}, methodID, jvArgs.values); + jvArgs.disposeIn(_env); + calloc.free(jvArgs.values); + {STR_REF_DEL} + _env.checkException(); + {RESULT}; + } + + /// Looks up method with [name] and [signature], calls it with [args] as arguments. + /// If calling the same method multiple times, consider using [get{STATIC}MethodID] + /// and [call{STATIC}{PTYPE}Method]. + {TARGET_TYPE} call{STATIC}{PTYPE}MethodByName( + String name, String signature, List args) { + final mID = get{STATIC}MethodID(name, signature); + final result = call{STATIC}{PTYPE}Method(mID, args); + return result; + } + + diff --git a/pkgs/jni/tool/templates/retrieve_static_fields.dart.tmpl b/pkgs/jni/tool/templates/retrieve_static_fields.dart.tmpl new file mode 100644 index 000000000..b83e94c55 --- /dev/null +++ b/pkgs/jni/tool/templates/retrieve_static_fields.dart.tmpl @@ -0,0 +1,28 @@ + {TARGET_TYPE} retrieve{PTYPE}Field(String className, String fieldName, String signature) { + return using((Arena arena) { + final arena = Arena(); + final env = getEnv(); + final classNameChars = className.toNativeChars(arena); + final fieldNameChars = fieldName.toNativeChars(arena); + final signatueChars = signature.toNativeChars(arena); + final cls = _bindings.LoadClass(classNameChars); + if (cls == nullptr) { + env.checkException(); + } + final fieldID = env.GetStaticFieldID(cls, fieldNameChars, signatueChars); + if (fieldID == nullptr) { + try { + env.checkException(); + } catch (e) { + env.DeleteLocalRef(cls); + rethrow; + } + } + final result = env.GetStatic{TYPE}Field(cls, fieldID); + {CLS_REF_DEL} + {STR_REF_DEL} + env.checkException(); + {INVOKE_RESULT}; + }); + } + From b5160496ab83e57bcce2ac198178bc93deb30687 Mon Sep 17 00:00:00 2001 From: Mahesh Hegde <46179734+mahesh-hegde@users.noreply.github.com> Date: Thu, 25 Aug 2022 12:41:28 +0530 Subject: [PATCH 008/139] [jnigen] Initial code generator support (https://github.com/dart-lang/jnigen/issues/19) --- .github/workflows/test-package.yml | 34 +- pkgs/jni/android/build.gradle | 9 +- .../src/main/java/dev/dart/jni/JniPlugin.java | 31 +- pkgs/jni/bin/setup.dart | 44 +- .../java/dev/dart/jni_example/AnyToast.java | 32 +- pkgs/jni/example/test/widget_test.dart | 2 +- pkgs/jni/lib/jni.dart | 1 + pkgs/jni/lib/src/jl_object.dart | 61 + pkgs/jni/lib/src/jni.dart | 44 +- pkgs/jni/lib/src/jni_exceptions.dart | 5 + .../third_party/jni_bindings_generated.dart | 45 + pkgs/jni/src/dartjni.c | 25 +- pkgs/jni/src/dartjni.h | 76 +- pkgs/jni/test/exception_test.dart | 2 +- pkgs/jni/test/jni_object_test.dart | 4 +- pkgs/jni/test/jni_test.dart | 2 +- pkgs/jni_gen/.gitignore | 7 + pkgs/jni_gen/README.md | 1 + pkgs/jni_gen/analysis_options.yaml | 12 + pkgs/jni_gen/bin/setup.dart | 68 + pkgs/jni_gen/cmake/CMakeLists.txt.tmpl | 30 + pkgs/jni_gen/java/.gitignore | 10 + pkgs/jni_gen/java/README.md | 46 + pkgs/jni_gen/java/pom.xml | 77 + .../dart_lang/jni_gen/apisummarizer/Main.java | 205 + .../disasm/AsmAnnotatedElementVisitor.java | 24 + .../disasm/AsmAnnotationVisitor.java | 86 + .../apisummarizer/disasm/AsmClassVisitor.java | 144 + .../apisummarizer/disasm/AsmConstants.java | 11 + .../apisummarizer/disasm/AsmFieldVisitor.java | 29 + .../disasm/AsmMethodVisitor.java | 61 + .../apisummarizer/disasm/AsmSummarizer.java | 84 + .../apisummarizer/disasm/TypeUtils.java | 118 + .../doclet/AnnotationVisitor.java | 100 + .../jni_gen/apisummarizer/doclet/AstEnv.java | 27 + .../apisummarizer/doclet/ElementBuilders.java | 211 + .../doclet/SummarizerDoclet.java | 17 + .../doclet/SummarizerDocletBase.java | 161 + .../apisummarizer/elements/ClassDecl.java | 47 + .../apisummarizer/elements/DeclKind.java | 12 + .../jni_gen/apisummarizer/elements/Field.java | 20 + .../elements/JavaAnnotation.java | 24 + .../elements/JavaDocComment.java | 15 + .../apisummarizer/elements/Method.java | 21 + .../apisummarizer/elements/Package.java | 9 + .../jni_gen/apisummarizer/elements/Param.java | 16 + .../apisummarizer/elements/TypeParam.java | 12 + .../apisummarizer/elements/TypeUsage.java | 79 + .../jni_gen/apisummarizer/util/Log.java | 33 + .../apisummarizer/util/SkipException.java | 13 + .../apisummarizer/util/StreamUtil.java | 20 + .../apisummarizer/DocletSummarizerTests.java | 58 + .../jni_gen/apisummarizer/TestDoclet.java | 21 + .../test/resources/com/example/Example.java | 33 + pkgs/jni_gen/lib/jni_gen.dart | 9 +- pkgs/jni_gen/lib/src/bindings/bindings.dart | 8 + pkgs/jni_gen/lib/src/bindings/c_bindings.dart | 361 ++ pkgs/jni_gen/lib/src/bindings/common.dart | 67 + .../lib/src/bindings/dart_bindings.dart | 379 ++ .../lib/src/bindings/preprocessor.dart | 90 + .../lib/src/bindings/symbol_resolver.dart | 136 + pkgs/jni_gen/lib/src/config/config.dart | 8 + pkgs/jni_gen/lib/src/config/errors.dart | 6 + .../lib/src/config/summary_source.dart | 87 + pkgs/jni_gen/lib/src/config/task.dart | 59 + .../lib/src/config/wrapper_options.dart | 148 + pkgs/jni_gen/lib/src/elements/elements.dart | 363 ++ pkgs/jni_gen/lib/src/elements/elements.g.dart | 261 ++ pkgs/jni_gen/lib/src/my_sum.dart | 6 - pkgs/jni_gen/lib/src/tools/maven_utils.dart | 134 + pkgs/jni_gen/lib/src/util/command_output.dart | 13 + pkgs/jni_gen/lib/src/util/find_package.dart | 48 + pkgs/jni_gen/lib/src/util/name_utils.dart | 30 + .../jni_gen/lib/src/util/rename_conflict.dart | 87 + .../lib/src/writers/bindings_writer.dart | 11 + .../lib/src/writers/callback_writer.dart | 20 + .../jni_gen/lib/src/writers/files_writer.dart | 132 + pkgs/jni_gen/lib/src/writers/writers.dart | 7 + pkgs/jni_gen/lib/tools.dart | 7 + pkgs/jni_gen/pubspec.yaml | 8 + pkgs/jni_gen/test/bindings_test.dart | 94 + .../jni_gen/test/jackson_core_test/.gitignore | 5 + .../test/jackson_core_test/generate.dart | 61 + .../generated_files_test.dart | 52 + .../lib/com/fasterxml/jackson/core.dart | 4117 +++++++++++++++++ .../third_party/lib/init.dart | 5 + .../third_party/src/CMakeLists.txt | 30 + .../third_party/src/dartjni.h | 173 + .../third_party/src/jackson_core_test.c | 2207 +++++++++ pkgs/jni_gen/test/my_test.dart | 13 - pkgs/jni_gen/test/package_resolver_test.dart | 63 + .../test/simple_package_test/.gitignore | 5 + .../test/simple_package_test/generate.dart | 47 + .../generated_files_test.dart | 18 + .../java/dev/dart/pkg2/C2.java | 5 + .../java/dev/dart/simple_package/Example.java | 50 + .../lib/dev/dart/pkg2.dart | 41 + .../lib/dev/dart/simple_package.dart | 159 + .../test/simple_package_test/lib/init.dart | 5 + .../simple_package_test/src/CMakeLists.txt | 30 + .../test/simple_package_test/src/dartjni.h | 173 + .../simple_package_test/src/simple_package.c | 189 + pkgs/jni_gen/test/test_util/test_util.dart | 107 + pkgs/jnigen/README.md | 2 +- 104 files changed, 12414 insertions(+), 101 deletions(-) create mode 100644 pkgs/jni/lib/src/jl_object.dart create mode 100644 pkgs/jni_gen/bin/setup.dart create mode 100644 pkgs/jni_gen/cmake/CMakeLists.txt.tmpl create mode 100644 pkgs/jni_gen/java/.gitignore create mode 100644 pkgs/jni_gen/java/README.md create mode 100644 pkgs/jni_gen/java/pom.xml create mode 100644 pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/Main.java create mode 100644 pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmAnnotatedElementVisitor.java create mode 100644 pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmAnnotationVisitor.java create mode 100644 pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmClassVisitor.java create mode 100644 pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmConstants.java create mode 100644 pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmFieldVisitor.java create mode 100644 pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmMethodVisitor.java create mode 100644 pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmSummarizer.java create mode 100644 pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/TypeUtils.java create mode 100644 pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/doclet/AnnotationVisitor.java create mode 100644 pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/doclet/AstEnv.java create mode 100644 pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/doclet/ElementBuilders.java create mode 100644 pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/doclet/SummarizerDoclet.java create mode 100644 pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/doclet/SummarizerDocletBase.java create mode 100644 pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/ClassDecl.java create mode 100644 pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/DeclKind.java create mode 100644 pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/Field.java create mode 100644 pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/JavaAnnotation.java create mode 100644 pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/JavaDocComment.java create mode 100644 pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/Method.java create mode 100644 pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/Package.java create mode 100644 pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/Param.java create mode 100644 pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/TypeParam.java create mode 100644 pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/TypeUsage.java create mode 100644 pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/util/Log.java create mode 100644 pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/util/SkipException.java create mode 100644 pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/util/StreamUtil.java create mode 100644 pkgs/jni_gen/java/src/test/java/com/github/dart_lang/jni_gen/apisummarizer/DocletSummarizerTests.java create mode 100644 pkgs/jni_gen/java/src/test/java/com/github/dart_lang/jni_gen/apisummarizer/TestDoclet.java create mode 100644 pkgs/jni_gen/java/src/test/resources/com/example/Example.java create mode 100644 pkgs/jni_gen/lib/src/bindings/bindings.dart create mode 100644 pkgs/jni_gen/lib/src/bindings/c_bindings.dart create mode 100644 pkgs/jni_gen/lib/src/bindings/common.dart create mode 100644 pkgs/jni_gen/lib/src/bindings/dart_bindings.dart create mode 100644 pkgs/jni_gen/lib/src/bindings/preprocessor.dart create mode 100644 pkgs/jni_gen/lib/src/bindings/symbol_resolver.dart create mode 100644 pkgs/jni_gen/lib/src/config/config.dart create mode 100644 pkgs/jni_gen/lib/src/config/errors.dart create mode 100644 pkgs/jni_gen/lib/src/config/summary_source.dart create mode 100644 pkgs/jni_gen/lib/src/config/task.dart create mode 100644 pkgs/jni_gen/lib/src/config/wrapper_options.dart create mode 100644 pkgs/jni_gen/lib/src/elements/elements.dart create mode 100644 pkgs/jni_gen/lib/src/elements/elements.g.dart delete mode 100644 pkgs/jni_gen/lib/src/my_sum.dart create mode 100644 pkgs/jni_gen/lib/src/tools/maven_utils.dart create mode 100644 pkgs/jni_gen/lib/src/util/command_output.dart create mode 100644 pkgs/jni_gen/lib/src/util/find_package.dart create mode 100644 pkgs/jni_gen/lib/src/util/name_utils.dart create mode 100644 pkgs/jni_gen/lib/src/util/rename_conflict.dart create mode 100644 pkgs/jni_gen/lib/src/writers/bindings_writer.dart create mode 100644 pkgs/jni_gen/lib/src/writers/callback_writer.dart create mode 100644 pkgs/jni_gen/lib/src/writers/files_writer.dart create mode 100644 pkgs/jni_gen/lib/src/writers/writers.dart create mode 100644 pkgs/jni_gen/lib/tools.dart create mode 100644 pkgs/jni_gen/test/bindings_test.dart create mode 100644 pkgs/jni_gen/test/jackson_core_test/.gitignore create mode 100644 pkgs/jni_gen/test/jackson_core_test/generate.dart create mode 100644 pkgs/jni_gen/test/jackson_core_test/generated_files_test.dart create mode 100644 pkgs/jni_gen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core.dart create mode 100644 pkgs/jni_gen/test/jackson_core_test/third_party/lib/init.dart create mode 100644 pkgs/jni_gen/test/jackson_core_test/third_party/src/CMakeLists.txt create mode 100644 pkgs/jni_gen/test/jackson_core_test/third_party/src/dartjni.h create mode 100644 pkgs/jni_gen/test/jackson_core_test/third_party/src/jackson_core_test.c delete mode 100644 pkgs/jni_gen/test/my_test.dart create mode 100644 pkgs/jni_gen/test/package_resolver_test.dart create mode 100644 pkgs/jni_gen/test/simple_package_test/.gitignore create mode 100644 pkgs/jni_gen/test/simple_package_test/generate.dart create mode 100644 pkgs/jni_gen/test/simple_package_test/generated_files_test.dart create mode 100644 pkgs/jni_gen/test/simple_package_test/java/dev/dart/pkg2/C2.java create mode 100644 pkgs/jni_gen/test/simple_package_test/java/dev/dart/simple_package/Example.java create mode 100644 pkgs/jni_gen/test/simple_package_test/lib/dev/dart/pkg2.dart create mode 100644 pkgs/jni_gen/test/simple_package_test/lib/dev/dart/simple_package.dart create mode 100644 pkgs/jni_gen/test/simple_package_test/lib/init.dart create mode 100644 pkgs/jni_gen/test/simple_package_test/src/CMakeLists.txt create mode 100644 pkgs/jni_gen/test/simple_package_test/src/dartjni.h create mode 100644 pkgs/jni_gen/test/simple_package_test/src/simple_package.c create mode 100644 pkgs/jni_gen/test/test_util/test_util.dart diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 24e7d5e51..f35e0bb78 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -17,8 +17,14 @@ env: PUB_ENVIRONMENT: bot.github jobs: - # Check code formatting and static analysis on a single OS (linux) - # against Dart stable. + check_java_format: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 # v2 minimum required + - uses: axel-op/googlejavaformat-action@v3 + with: + args: "--set-exit-if-changed" + analyze_jni_gen: runs-on: ubuntu-latest defaults: @@ -60,6 +66,11 @@ jobs: - uses: dart-lang/setup-dart@v1.0 with: sdk: stable + - uses: actions/setup-java@v2 + with: + distribution: 'zulu' + java-version: '11' + cache: maven - name: Install dependencies run: dart pub get - name: Run VM tests @@ -80,6 +91,20 @@ jobs: ## i.e do not rerun analyze and format steps, and do not require flutter. ## IssueRef: https://github.com/dart-lang/jni_gen/issues/15 + test_summarizer: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./pkgs/jni_gen/java + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v2 + with: + distribution: 'zulu' + java-version: '11' + - name: run tests using maven surefire + run: mvn surefire:test + test_jni: runs-on: ubuntu-latest defaults: @@ -139,12 +164,9 @@ jobs: - run: | sudo apt-get update -y sudo apt-get install -y ninja-build libgtk-3-dev - - run: dart pub get - working-directory: ./pkgs/jni - - run: dart run bin/setup.dart - working-directory: ./pkgs/jni - run: flutter config --enable-linux-desktop - run: flutter pub get + - run: dart run jni:setup - run: flutter test - run: flutter build linux diff --git a/pkgs/jni/android/build.gradle b/pkgs/jni/android/build.gradle index 1fe097a40..b91cb7bb9 100644 --- a/pkgs/jni/android/build.gradle +++ b/pkgs/jni/android/build.gradle @@ -31,12 +31,9 @@ android { // Bumping the plugin ndkVersion requires all clients of this plugin to bump // the version in their app and to download a newer version of the NDK. - - // Note(MaheshH): Seems 22 is lowest one can get through SDKManager now? - // - // It's more of a logistic issue, I can't download NDK 21, so keeping it - // 22. You might get a warning to bump some versions. - ndkVersion "22.1.7171670" + // Note(MaheshH) - Flutter seems to download minimum NDK of flutter when + // below line is commented out. + // How about leaving it? // ndkVersion "21.1.6352462" // Invoke the shared CMake build with the Android Gradle Plugin. diff --git a/pkgs/jni/android/src/main/java/dev/dart/jni/JniPlugin.java b/pkgs/jni/android/src/main/java/dev/dart/jni/JniPlugin.java index dbf872745..589ba8539 100644 --- a/pkgs/jni/android/src/main/java/dev/dart/jni/JniPlugin.java +++ b/pkgs/jni/android/src/main/java/dev/dart/jni/JniPlugin.java @@ -1,32 +1,29 @@ package dev.dart.jni; +import android.app.Activity; +import android.content.Context; import androidx.annotation.Keep; import androidx.annotation.NonNull; -import android.util.Log; -import android.app.Activity; -import io.flutter.plugin.common.PluginRegistry.Registrar; import io.flutter.embedding.engine.plugins.FlutterPlugin; import io.flutter.embedding.engine.plugins.activity.ActivityAware; import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding; - -import android.content.Context; +import io.flutter.plugin.common.PluginRegistry.Registrar; @Keep public class JniPlugin implements FlutterPlugin, ActivityAware { - + @Override - public void - onAttachedToEngine(@NonNull FlutterPluginBinding binding) { - setup(binding.getApplicationContext()); + public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) { + setup(binding.getApplicationContext()); } public static void registerWith(Registrar registrar) { JniPlugin plugin = new JniPlugin(); - plugin.setup(registrar.activeContext()); + plugin.setup(registrar.activeContext()); } private void setup(Context context) { - initializeJni(context, getClass().getClassLoader()); + initializeJni(context, getClass().getClassLoader()); } @Override @@ -35,8 +32,8 @@ public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {} // Activity handling methods @Override public void onAttachedToActivity(@NonNull ActivityPluginBinding binding) { - Activity activity = binding.getActivity(); - setJniActivity(activity, activity.getApplicationContext()); + Activity activity = binding.getActivity(); + setJniActivity(activity, activity.getApplicationContext()); } @Override @@ -44,18 +41,18 @@ public void onDetachedFromActivityForConfigChanges() {} @Override public void onReattachedToActivityForConfigChanges(@NonNull ActivityPluginBinding binding) { - Activity activity = binding.getActivity(); - setJniActivity(activity, activity.getApplicationContext()); + Activity activity = binding.getActivity(); + setJniActivity(activity, activity.getApplicationContext()); } @Override public void onDetachedFromActivity() {} native void initializeJni(Context context, ClassLoader classLoader); + native void setJniActivity(Activity activity, Context context); static { - System.loadLibrary("dartjni"); + System.loadLibrary("dartjni"); } } - diff --git a/pkgs/jni/bin/setup.dart b/pkgs/jni/bin/setup.dart index 508f5e294..67d9f9639 100644 --- a/pkgs/jni/bin/setup.dart +++ b/pkgs/jni/bin/setup.dart @@ -5,10 +5,27 @@ import 'package:package_config/package_config.dart'; const _buildDir = "build-dir"; const _srcDir = "source-dir"; +const _packageName = 'package-name'; const _verbose = "verbose"; const _cmakeArgs = "cmake-args"; const _clean = "clean"; +const _cmakeTemporaryFiles = [ + 'CMakeCache.txt', + 'CMakeFiles/', + 'cmake_install.cmake', + 'Makefile' +]; + +void deleteCMakeTemps(Uri buildDir) async { + for (var filename in _cmakeTemporaryFiles) { + if (options.verbose) { + stderr.writeln('remove $filename'); + } + await File(buildDir.resolve(filename).toFilePath()).delete(recursive: true); + } +} + // Sets up input output channels and maintains state. class CommandRunner { CommandRunner({this.printCmds = false}); @@ -25,7 +42,7 @@ class CommandRunner { } final process = await Process.start(exec, args, workingDirectory: workingDir, - runInShell: Platform.isWindows, + runInShell: true, mode: ProcessStartMode.inheritStdio); final exitCode = await process.exitCode; if (exitCode != 0) { @@ -39,11 +56,14 @@ class Options { Options(ArgResults arg) : buildDir = arg[_buildDir], srcDir = arg[_srcDir], + packageName = arg[_packageName] ?? 'jni', cmakeArgs = arg[_cmakeArgs], verbose = arg[_verbose] ?? false, clean = arg[_clean] ?? false; - String? buildDir, srcDir, cmakeArgs; + String? buildDir, srcDir; + String packageName; + List cmakeArgs; bool verbose, clean; } @@ -63,7 +83,7 @@ Future findSources() async { } final packages = packageConfig.packages; for (var package in packages) { - if (package.name == 'jni') { + if (package.name == options.packageName) { return package.root.resolve("src/").toFilePath(); } } @@ -76,14 +96,18 @@ void main(List arguments) async { abbr: 'B', help: 'Directory to place built artifacts') ..addOption(_srcDir, abbr: 'S', help: 'alternative path to package:jni sources') + ..addOption(_packageName, + abbr: 'p', + help: 'package for which native' + 'library should be built', + defaultsTo: 'jni') ..addFlag(_verbose, abbr: 'v', help: 'Enable verbose output') ..addFlag(_clean, negatable: false, abbr: 'C', help: 'Clear built artifacts instead of running a build') - ..addOption(_cmakeArgs, - abbr: 'm', - help: 'additional space separated arguments to pass to CMake'); + ..addMultiOption(_cmakeArgs, + abbr: 'm', help: 'additional argument to pass to CMake'); final cli = parser.parse(arguments); options = Options(cli); final rest = cli.rest; @@ -114,7 +138,7 @@ void main(List arguments) async { final currentDirUri = Uri.file("."); final buildPath = - options.buildDir ?? currentDirUri.resolve("src/build").toFilePath(); + options.buildDir ?? currentDirUri.resolve("build/jni_libs").toFilePath(); final buildDir = Directory(buildPath); await buildDir.create(recursive: true); log("buildPath: $buildPath"); @@ -136,15 +160,15 @@ void main(List arguments) async { Future build(Options options, String srcPath, String buildPath) async { final runner = CommandRunner(printCmds: true); final cmakeArgs = []; - if (options.cmakeArgs != null) { - cmakeArgs.addAll(options.cmakeArgs!.split(" ")); - } + cmakeArgs.addAll(options.cmakeArgs); cmakeArgs.add(srcPath); await runner.run("cmake", cmakeArgs, buildPath); await runner.run("cmake", ["--build", "."], buildPath); if (Platform.isWindows) { await runner.run("move", ["Debug\\dartjni.dll", "."], buildPath); } + // delete cmakeTemporaryArtifacts + deleteCMakeTemps(Uri.directory(buildPath)); } Future cleanup(Options options, String srcPath, String buildPath) async { diff --git a/pkgs/jni/example/android/app/src/main/java/dev/dart/jni_example/AnyToast.java b/pkgs/jni/example/android/app/src/main/java/dev/dart/jni_example/AnyToast.java index 59f07f715..7de08d3bc 100644 --- a/pkgs/jni/example/android/app/src/main/java/dev/dart/jni_example/AnyToast.java +++ b/pkgs/jni/example/android/app/src/main/java/dev/dart/jni_example/AnyToast.java @@ -1,28 +1,28 @@ package dev.dart.jni_example; import android.app.Activity; -import android.os.Handler; import android.content.Context; import android.widget.Toast; import androidx.annotation.Keep; @Keep class AnyToast { - static AnyToast makeText(Activity mainActivity, Context context, CharSequence text, int duration) { - AnyToast toast = new AnyToast(); - toast.mainActivity = mainActivity; - toast.context = context; - toast.text = text; - toast.duration = duration; - return toast; - } + static AnyToast makeText( + Activity mainActivity, Context context, CharSequence text, int duration) { + AnyToast toast = new AnyToast(); + toast.mainActivity = mainActivity; + toast.context = context; + toast.text = text; + toast.duration = duration; + return toast; + } - void show() { - mainActivity.runOnUiThread(() -> Toast.makeText(context, text, duration).show()); - } + void show() { + mainActivity.runOnUiThread(() -> Toast.makeText(context, text, duration).show()); + } - Activity mainActivity; - Context context; - CharSequence text; - int duration; + Activity mainActivity; + Context context; + CharSequence text; + int duration; } diff --git a/pkgs/jni/example/test/widget_test.dart b/pkgs/jni/example/test/widget_test.dart index c2336a068..2607462f9 100644 --- a/pkgs/jni/example/test/widget_test.dart +++ b/pkgs/jni/example/test/widget_test.dart @@ -14,7 +14,7 @@ import 'package:jni_example/main.dart'; void main() { if (!Platform.isAndroid) { - Jni.spawn(helperDir: "../src/build"); + Jni.spawn(helperDir: "build/jni_libs"); } final jni = Jni.getInstance(); testWidgets("simple toString example", (tester) async { diff --git a/pkgs/jni/lib/jni.dart b/pkgs/jni/lib/jni.dart index b604a5bae..87049cb84 100644 --- a/pkgs/jni/lib/jni.dart +++ b/pkgs/jni/lib/jni.dart @@ -64,3 +64,4 @@ export 'src/jvalues.dart' hide JValueArgs, toJValues; export 'src/extensions.dart' show StringMethodsForJni, CharPtrMethodsForJni, AdditionalJniEnvMethods; export 'src/jni_exceptions.dart'; +export 'src/jl_object.dart'; diff --git a/pkgs/jni/lib/src/jl_object.dart b/pkgs/jni/lib/src/jl_object.dart new file mode 100644 index 000000000..36558f44f --- /dev/null +++ b/pkgs/jni/lib/src/jl_object.dart @@ -0,0 +1,61 @@ +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; + +import 'third_party/jni_bindings_generated.dart'; +import 'jni_exceptions.dart'; +import 'jni.dart'; + +/// A container for a global [JObject] reference. +class JlObject { + /// Constructs a `JlObject` from JNI reference. + JlObject.fromRef(this.reference); + + /// Stored JNI global reference to the object. + JObject reference; + + bool _deleted = false; + + /// Deletes the underlying JNI reference. + /// + /// Must be called after this object is no longer needed. + void delete() { + if (_deleted) { + throw DoubleFreeException(this, reference); + } + _deleted = true; + // TODO(#12): this should be done in jni-thread-safe way + // will be solved when #12 is implemented. + Jni.getInstance().getEnv().DeleteGlobalRef(reference); + } +} + +/// A container for JNI strings, with convertion to & from dart strings. +class JlString extends JlObject { + JlString.fromRef(JString reference) : super.fromRef(reference); + + static JString _toJavaString(String s) { + final chars = s.toNativeUtf8().cast(); + final jstr = Jni.getInstance().toJavaString(chars); + malloc.free(chars); + return jstr; + } + + JlString.fromString(String s) : super.fromRef(_toJavaString(s)); + + String toDartString() { + final jni = Jni.getInstance(); + if (reference == nullptr) { + throw NullJlStringException(); + } + final chars = jni.getJavaStringChars(reference); + final result = chars.cast().toDartString(); + jni.releaseJavaStringChars(reference, chars); + return result; + } + + late final _dartString = toDartString(); + + @override + String toString() => _dartString; +} diff --git a/pkgs/jni/lib/src/jni.dart b/pkgs/jni/lib/src/jni.dart index beac5f784..b3ce6df39 100644 --- a/pkgs/jni/lib/src/jni.dart +++ b/pkgs/jni/lib/src/jni.dart @@ -7,10 +7,10 @@ import 'package:path/path.dart'; import 'third_party/jni_bindings_generated.dart'; import 'extensions.dart'; import 'jvalues.dart'; -import 'jni_exceptions.dart'; import 'jni_object.dart'; import 'jni_class.dart'; +import 'jni_exceptions.dart'; part 'direct_methods_generated.dart'; @@ -52,10 +52,16 @@ DynamicLibrary _loadJniHelpersLibrary( class Jni { final JniBindings _bindings; - Jni._(this._bindings); + Jni._(DynamicLibrary library, [this._helperDir]) + : _bindings = JniBindings(library), + _getJniEnvFn = library.lookup('GetJniEnv'), + _getJniContextFn = library.lookup('GetJniContext'); static Jni? _instance; + /// Stores helperDir if any was used. + final String? _helperDir; + /// Returns the existing Jni object. /// /// If not running on Android and no Jni is spawned @@ -63,9 +69,12 @@ class Jni { /// /// On Dart standalone, when calling for the first time from /// a new isolate, make sure to pass the library path. + final Pointer _getJniEnvFn, _getJniContextFn; + static Jni getInstance() { if (_instance == null) { - final inst = Jni._(JniBindings(_loadJniHelpersLibrary())); + final dylib = _loadJniHelpersLibrary(); + final inst = Jni._(dylib); if (inst.getJavaVM() == nullptr) { throw StateError("Fatal: No JVM associated with this process!" " Did you call Jni.spawn?"); @@ -88,7 +97,7 @@ class Jni { if (_instance != null) { throw StateError('Fatal: a JNI instance already exists in this isolate'); } - final inst = Jni._(JniBindings(_loadJniHelpersLibrary(dir: helperDir))); + final inst = Jni._(_loadJniHelpersLibrary(dir: helperDir), helperDir); if (inst.getJavaVM() == nullptr) { throw StateError("Fatal: No JVM associated with this process"); } @@ -117,7 +126,7 @@ class Jni { throw UnsupportedError("Currently only 1 VM is supported."); } final dylib = _loadJniHelpersLibrary(dir: helperDir); - final inst = Jni._(JniBindings(dylib)); + final inst = Jni._(dylib, helperDir); _instance = inst; inst._bindings.SetJNILogging(logLevel); final jArgs = _createVMArgs( @@ -256,6 +265,21 @@ class Jni { return JniClass.of(getEnv(), cls); } + Pointer Function(String) initGeneratedLibrary( + String name) { + var path = _getLibraryFileName(name); + if (_helperDir != null) { + path = join(_helperDir!, path); + } + final dl = DynamicLibrary.open(path); + final setJniGetters = + dl.lookupFunction( + 'setJniGetters'); + setJniGetters(_getJniContextFn, _getJniEnvFn); + final lookup = dl.lookup; + return lookup; + } + /// Converts passed arguments to JValue array /// for use in methods that take arguments. /// @@ -266,4 +290,14 @@ class Jni { {Allocator allocator = calloc}) { return toJValues(args, allocator: allocator); } + + // Temporarily for JlString. + // A future idea is to unify JlObject and JniObject, and use global refs + // everywhere for simplicity. + late final toJavaString = _bindings.ToJavaString; + late final getJavaStringChars = _bindings.GetJavaStringChars; + late final releaseJavaStringChars = _bindings.ReleaseJavaStringChars; } + +typedef SetJniGettersNativeType = Void Function(Pointer, Pointer); +typedef SetJniGettersDartType = void Function(Pointer, Pointer); diff --git a/pkgs/jni/lib/src/jni_exceptions.dart b/pkgs/jni/lib/src/jni_exceptions.dart index 153343788..c765ec4b1 100644 --- a/pkgs/jni/lib/src/jni_exceptions.dart +++ b/pkgs/jni/lib/src/jni_exceptions.dart @@ -13,6 +13,11 @@ class UseAfterFreeException implements Exception { } } +class NullJlStringException implements Exception { + @override + String toString() => 'toDartString called on null JlString reference'; +} + class DoubleFreeException implements Exception { dynamic object; Pointer ptr; 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 005029c42..77a170081 100644 --- a/pkgs/jni/lib/src/third_party/jni_bindings_generated.dart +++ b/pkgs/jni/lib/src/third_party/jni_bindings_generated.dart @@ -207,6 +207,51 @@ class JniBindings { _lookup>('SetJNILogging'); late final _SetJNILogging = _SetJNILoggingPtr.asFunction(); + + JString ToJavaString( + ffi.Pointer str, + ) { + return _ToJavaString( + str, + ); + } + + late final _ToJavaStringPtr = + _lookup)>>( + 'ToJavaString'); + late final _ToJavaString = + _ToJavaStringPtr.asFunction)>(); + + ffi.Pointer GetJavaStringChars( + JString jstr, + ) { + return _GetJavaStringChars( + jstr, + ); + } + + late final _GetJavaStringCharsPtr = + _lookup Function(JString)>>( + 'GetJavaStringChars'); + late final _GetJavaStringChars = _GetJavaStringCharsPtr.asFunction< + ffi.Pointer Function(JString)>(); + + void ReleaseJavaStringChars( + JString jstr, + ffi.Pointer buf, + ) { + return _ReleaseJavaStringChars( + jstr, + buf, + ); + } + + late final _ReleaseJavaStringCharsPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + JString, ffi.Pointer)>>('ReleaseJavaStringChars'); + late final _ReleaseJavaStringChars = _ReleaseJavaStringCharsPtr.asFunction< + void Function(JString, ffi.Pointer)>(); } class jfieldID_ extends ffi.Opaque {} diff --git a/pkgs/jni/src/dartjni.c b/pkgs/jni/src/dartjni.c index cf4e7d555..82f159758 100644 --- a/pkgs/jni/src/dartjni.c +++ b/pkgs/jni/src/dartjni.c @@ -15,8 +15,7 @@ void SetJNILogging(int level) { } void jni_log(int level, const char *format, ...) { - // TODO: Not working - // IssueRef: https://github.com/dart-lang/jni_gen/issues/16 + // TODO(#16): This is not working. if (level >= jni_log_level) { va_list args; va_start(args, format); @@ -30,6 +29,8 @@ void jni_log(int level, const char *format, ...) { } } +FFI_PLUGIN_EXPORT struct jni_context GetJniContext() { return jni; } + /// Get JVM associated with current process. /// Returns NULL if no JVM is running. FFI_PLUGIN_EXPORT @@ -86,6 +87,26 @@ jobject GetCurrentActivity() { return (*jniEnv)->NewLocalRef(jniEnv, jni.currentActivity); } +FFI_PLUGIN_EXPORT +jstring ToJavaString(char *str) { + attach_thread(); + jstring s = (*jniEnv)->NewStringUTF(jniEnv, str); + jstring g = (*jniEnv)->NewGlobalRef(jniEnv, s); + (*jniEnv)->DeleteLocalRef(jniEnv, s); + return g; +} + +FFI_PLUGIN_EXPORT +const char *GetJavaStringChars(jstring jstr) { + const char *buf = (*jniEnv)->GetStringUTFChars(jniEnv, jstr, NULL); + return buf; +} + +FFI_PLUGIN_EXPORT +void ReleaseJavaStringChars(jstring jstr, const char *buf) { + (*jniEnv)->ReleaseStringUTFChars(jniEnv, jstr, buf); +} + #ifdef __ANDROID__ JNIEXPORT void JNICALL Java_dev_dart_jni_JniPlugin_initializeJni( JNIEnv *env, jobject obj, jobject appContext, jobject classLoader) { diff --git a/pkgs/jni/src/dartjni.h b/pkgs/jni/src/dartjni.h index 5b7fb5be7..407312bbe 100644 --- a/pkgs/jni/src/dartjni.h +++ b/pkgs/jni/src/dartjni.h @@ -1,6 +1,6 @@ +#include #include #include -#include #include #if _WIN32 @@ -23,7 +23,7 @@ #endif #ifdef __ANDROID__ -#include +#include #endif #define JNI_LOG_TAG "Dart-JNI" @@ -43,12 +43,19 @@ struct jni_context { }; extern thread_local JNIEnv *jniEnv; + extern struct jni_context jni; enum DartJniLogLevel { - JNI_VERBOSE = 2, JNI_DEBUG, JNI_INFO, JNI_WARN, JNI_ERROR + JNI_VERBOSE = 2, + JNI_DEBUG, + JNI_INFO, + JNI_WARN, + JNI_ERROR }; +FFI_PLUGIN_EXPORT struct jni_context GetJniContext(); + FFI_PLUGIN_EXPORT JavaVM *GetJavaVM(void); FFI_PLUGIN_EXPORT JNIEnv *GetJniEnv(void); @@ -65,23 +72,39 @@ FFI_PLUGIN_EXPORT jobject GetCurrentActivity(void); FFI_PLUGIN_EXPORT void SetJNILogging(int level); -/// For use by jni_gen's generated code -/// don't use these. +FFI_PLUGIN_EXPORT jstring ToJavaString(char *str); + +FFI_PLUGIN_EXPORT const char *GetJavaStringChars(jstring jstr); + +FFI_PLUGIN_EXPORT void ReleaseJavaStringChars(jstring jstr, const char *buf); -// `static inline` because `inline` doesn't work, it may still not +// These 2 are the function pointer variables defined and exported by +// the generated C files. +// +// initGeneratedLibrary function in Jni class will set these to +// corresponding functions to the implementations from `dartjni` base library +// which initializes and manages the JNI. +extern struct jni_context (*context_getter)(void); +extern JNIEnv *(*env_getter)(void); + +// This function will be exported by generated code library and will set the +// above 2 variables. +FFI_PLUGIN_EXPORT void setJniGetters(struct jni_context (*cg)(void), + JNIEnv *(*eg)(void)); + +// `static inline` because `inline` doesn't work, it may still not // inline the function in which case a linker error may be produced. // // There has to be a better way to do this. Either to force inlining on target // platforms, or just leave it as normal function. - static inline void __load_class_into(jclass *cls, const char *name) { #ifdef __ANDROID__ - jstring className = (*jniEnv)->NewStringUTF(jniEnv, name); - *cls = (*jniEnv)->CallObjectMethod( - jniEnv, jni.classLoader, jni.loadClassMethod, className); - (*jniEnv)->DeleteLocalRef(jniEnv, className); + jstring className = (*jniEnv)->NewStringUTF(jniEnv, name); + *cls = (*jniEnv)->CallObjectMethod(jniEnv, jni.classLoader, + jni.loadClassMethod, className); + (*jniEnv)->DeleteLocalRef(jniEnv, className); #else - *cls = (*jniEnv)->FindClass(jniEnv, name); + *cls = (*jniEnv)->FindClass(jniEnv, name); #endif } @@ -102,11 +125,18 @@ static inline void load_class_gr(jclass *cls, const char *name) { static inline void attach_thread() { if (jniEnv == NULL) { - (*jni.jvm)->AttachCurrentThread(jni.jvm, __ENVP_CAST &jniEnv, + (*jni.jvm)->AttachCurrentThread(jni.jvm, __ENVP_CAST & jniEnv, NULL); } } +static inline void load_env() { + if (jniEnv == NULL) { + jni = context_getter(); + jniEnv = env_getter(); + } +} + static inline void load_method(jclass cls, jmethodID *res, const char *name, const char *sig) { if (*res == NULL) { @@ -121,3 +151,23 @@ static inline void load_static_method(jclass cls, jmethodID *res, } } +static inline void load_field(jclass cls, jfieldID *res, const char *name, + const char *sig) { + if (*res == NULL) { + *res = (*jniEnv)->GetFieldID(jniEnv, cls, name, sig); + } +} + +static inline void load_static_field(jclass cls, jfieldID *res, + const char *name, const char *sig) { + if (*res == NULL) { + *res = (*jniEnv)->GetStaticFieldID(jniEnv, cls, name, sig); + } +} + +static inline jobject to_global_ref(jobject ref) { + jobject g = (*jniEnv)->NewGlobalRef(jniEnv, ref); + (*jniEnv)->DeleteLocalRef(jniEnv, ref); + return g; +} + diff --git a/pkgs/jni/test/exception_test.dart b/pkgs/jni/test/exception_test.dart index 9a3194c86..109a7e6fb 100644 --- a/pkgs/jni/test/exception_test.dart +++ b/pkgs/jni/test/exception_test.dart @@ -15,7 +15,7 @@ void main() { Jni.spawn(helperDir: "wrong_dir"); } on HelperNotFoundException catch (_) { // stderr.write("\n$_\n"); - Jni.spawn(helperDir: "src/build"); + Jni.spawn(helperDir: "build/jni_libs"); caught = true; } if (!caught) { diff --git a/pkgs/jni/test/jni_object_test.dart b/pkgs/jni/test/jni_object_test.dart index c67132308..6124d1fd7 100644 --- a/pkgs/jni/test/jni_object_test.dart +++ b/pkgs/jni/test/jni_object_test.dart @@ -10,7 +10,7 @@ import 'package:jni/jni_object.dart'; void main() { // Don't forget to initialize JNI. if (!Platform.isAndroid) { - Jni.spawn(helperDir: "src/build"); + Jni.spawn(helperDir: "build/jni_libs"); } final jni = Jni.getInstance(); @@ -210,7 +210,7 @@ void doSomeWorkInIsolate(Void? _) { // when doing getInstance first time in a new isolate. // // otherwise getInstance will throw a "library not found" exception. - Jni.load(helperDir: "src/build"); + Jni.load(helperDir: "build/jni_libs"); final jni = Jni.getInstance(); final random = jni.newInstance("java/util/Random", "()V", []); // final r = random.callIntMethodByName("nextInt", "(I)I", [256]); diff --git a/pkgs/jni/test/jni_test.dart b/pkgs/jni/test/jni_test.dart index 9982cf1b0..29f536b64 100644 --- a/pkgs/jni/test/jni_test.dart +++ b/pkgs/jni/test/jni_test.dart @@ -18,7 +18,7 @@ void main() { // You have to manually pass the path to the `dartjni` dynamic library. if (!Platform.isAndroid) { - Jni.spawn(helperDir: "src/build"); + Jni.spawn(helperDir: "build/jni_libs"); } final jni = Jni.getInstance(); diff --git a/pkgs/jni_gen/.gitignore b/pkgs/jni_gen/.gitignore index 93533a59a..2c6760333 100644 --- a/pkgs/jni_gen/.gitignore +++ b/pkgs/jni_gen/.gitignore @@ -6,6 +6,9 @@ build/ pubspec.lock +# created by maven +/target/ + # Directory created by dartdoc. doc/api/ @@ -33,3 +36,7 @@ compile_commands.json # Mac .DS_Store + +# Vim +.*.swp + diff --git a/pkgs/jni_gen/README.md b/pkgs/jni_gen/README.md index d0f047461..373127b27 100644 --- a/pkgs/jni_gen/README.md +++ b/pkgs/jni_gen/README.md @@ -4,3 +4,4 @@ This package will generate JNI code to invoke Java from C, and Dart FFI bindings This enables calling Java code from Dart. This is a GSoC 2022 project. + diff --git a/pkgs/jni_gen/analysis_options.yaml b/pkgs/jni_gen/analysis_options.yaml index 9c8e2c5cd..3fa121aee 100644 --- a/pkgs/jni_gen/analysis_options.yaml +++ b/pkgs/jni_gen/analysis_options.yaml @@ -3,3 +3,15 @@ # BSD-style license that can be found in the LICENSE file. include: package:lints/recommended.yaml + +analyzer: + exclude: [build/**] + language: + strict-raw-types: true + strict-inference: true + +linter: + rules: + - prefer_final_locals + - prefer_const_declarations + diff --git a/pkgs/jni_gen/bin/setup.dart b/pkgs/jni_gen/bin/setup.dart new file mode 100644 index 000000000..656b5daf8 --- /dev/null +++ b/pkgs/jni_gen/bin/setup.dart @@ -0,0 +1,68 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +// This script gets the java sources using the copy of this package, and builds +// ApiSummarizer jar using Maven. +import 'dart:io'; + +import 'package:path/path.dart'; + +import 'package:jni_gen/src/util/find_package.dart'; + +final toolPath = join('.', '.dart_tool', 'jni_gen'); +final mvnTargetDir = join(toolPath, 'target'); +final jarFile = join(toolPath, 'ApiSummarizer.jar'); +final targetJarFile = join(mvnTargetDir, 'ApiSummarizer.jar'); + +Future buildApiSummarizer() async { + final pkg = await findPackageRoot('jni_gen'); + if (pkg == null) { + stderr.writeln('package jni_gen not found!'); + exitCode = 2; + return; + } + final pom = pkg.resolve('java/pom.xml'); + await Directory(toolPath).create(recursive: true); + final mvnProc = await Process.start( + 'mvn', + [ + '--batch-mode', + '--update-snapshots', + '-f', + pom.toFilePath(), + 'assembly:assembly' + ], + workingDirectory: toolPath, + mode: ProcessStartMode.inheritStdio); + await mvnProc.exitCode; + // move ApiSummarizer.jar from target to current directory + File(targetJarFile).renameSync(jarFile); + Directory(mvnTargetDir).deleteSync(recursive: true); +} + +void main(List args) async { + bool force = false; + if (args.isNotEmpty) { + if (args.length != 1 || args[0] != '-f') { + stderr.writeln('usage: dart run jni_gen:setup [-f]'); + stderr.writeln('use -f option to rebuild ApiSummarizer jar ' + 'even if it already exists.'); + } else { + force = true; + } + } + final jarExists = await File(jarFile).exists(); + final isJarStale = jarExists && + await isPackageModifiedAfter( + 'jni_gen', await File(jarFile).lastModified(), 'java/'); + if (isJarStale) { + stderr.writeln('Rebuilding ApiSummarizer component since sources ' + 'have changed. This might take some time.'); + } + if (!jarExists || isJarStale || force) { + await buildApiSummarizer(); + } else { + stderr.writeln('ApiSummarizer.jar exists. Skipping build..'); + } +} diff --git a/pkgs/jni_gen/cmake/CMakeLists.txt.tmpl b/pkgs/jni_gen/cmake/CMakeLists.txt.tmpl new file mode 100644 index 000000000..21d0d807e --- /dev/null +++ b/pkgs/jni_gen/cmake/CMakeLists.txt.tmpl @@ -0,0 +1,30 @@ +# The Flutter tooling requires that developers have CMake 3.10 or later +# installed. You should not increase this version, as doing so will cause +# the plugin to fail to compile for some customers of the plugin. +cmake_minimum_required(VERSION 3.10) + +project({{LIBRARY_NAME}} VERSION 0.0.1 LANGUAGES C) + +add_library({{LIBRARY_NAME}} SHARED + "{{LIBRARY_NAME}}.c" +) + +set_target_properties({{LIBRARY_NAME}} PROPERTIES + OUTPUT_NAME "{{LIBRARY_NAME}}" +) + +target_compile_definitions({{LIBRARY_NAME}} PUBLIC DART_SHARED_LIB) + +if(WIN32) + set_target_properties(${TARGET_NAME} PROPERTIES + LINK_FLAGS "/DELAYLOAD:jvm.dll") +endif() + +if (ANDROID) + target_link_libraries({{LIBRARY_NAME}} log) +else() + find_package(Java REQUIRED) + find_package(JNI REQUIRED) + include_directories(${JNI_INCLUDE_DIRS}) + target_link_libraries({{LIBRARY_NAME}} ${JNI_LIBRARIES}) +endif() diff --git a/pkgs/jni_gen/java/.gitignore b/pkgs/jni_gen/java/.gitignore new file mode 100644 index 000000000..fe41dfd15 --- /dev/null +++ b/pkgs/jni_gen/java/.gitignore @@ -0,0 +1,10 @@ +target/* +*.class +*.jar + +.idea/compiler.xml +.idea/dictionaries +.idea/inspectionProfiles/ +.idea/jarRepositories.xml +.idea/misc.xml +.idea/runConfigurations.xml diff --git a/pkgs/jni_gen/java/README.md b/pkgs/jni_gen/java/README.md new file mode 100644 index 000000000..25a04b319 --- /dev/null +++ b/pkgs/jni_gen/java/README.md @@ -0,0 +1,46 @@ +## ApiSummarizer +An early version of ApiSummarizer. + +It analyzes java source code / jars and outputs a JSON representation of the public API. + +It's currently used in `jni_gen` to get the information of the Java API. + +## Build +When using it via `jni_gen`, the `jni_gen:setup` script will take care of building the jar in appropriate location. + +To build the jar manually, run `mvn assembly:assembly` in project root. The jar will be created in `target/` directory. + +## Command line +``` +usage: java -jar [-s ] [-c ] + +Class or package names should be fully qualified. + +-b,--backend backend to use for summary generation ('doclet' +or 'asm'). +-c,--classes paths to search for compiled classes +-D,--doctool-args Arguments to pass to the documentation tool +-M,--use-modules use Java modules +-m,--module-names comma separated list of module names +-r,--recursive Include dependencies of classes +-s,--sources paths to search for source files +-v,--verbose Enable verbose output +``` + +Here class or package names are specified as fully qualified names, for example `org.apache.pdfbox.pdmodel.PDDocument` will load `org/apache/pdfbox/pdmodel/PDDocument.java`. It assumes the package naming reflects directory structure. If such mapping results in a directory, for example `android.os` is given and a directory `android/os` is found under the source path, it is considered as a package and all Java source files under that directory are loaded recursively. + +Note that some options are directly forwarded to the underlying tool. + +ApiSummarizer's current use is in `jni_gen` for obtaining public API of java packages. Only the features strictly required for that purpose are focused upon. + +## Running tests +Run `mvn surefire:test` + +There are not many tests at the moment. We plan to add some later. + +## ASM backend + +The main backend is based on javadoc API and generates summary based on java sources. A more experimental ASM backend also exists, and works somewhat okay-ish. It can summarize the compiled JARs. However, compiled jars without debug information do not include method parameter names. Some basic renaming is applied, i.e If type is `Object`, the parameter name will be output as `object` if an actual name is absent. + +## TODO +See issue #23. \ No newline at end of file diff --git a/pkgs/jni_gen/java/pom.xml b/pkgs/jni_gen/java/pom.xml new file mode 100644 index 000000000..a36c78f73 --- /dev/null +++ b/pkgs/jni_gen/java/pom.xml @@ -0,0 +1,77 @@ + + + 4.0.0 + + com.github.dart_lang.jni_gen + ApiSummarizer + Summarize public APIs of java packages in JSON or protobuf. + 0.0.1-SNAPSHOT + + + 11 + 11 + 2.13.3 + UTF-8 + ${user.dir} + + + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + commons-cli + commons-cli + 1.5.0 + + + org.ow2.asm + asm-tree + 9.3 + + + junit + junit + 4.13.2 + test + + + + + ${buildDir}/target + ApiSummarizer + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M7 + + + org.apache.maven.plugins + maven-assembly-plugin + + jar-with-dependencies + false + + + com.github.dart_lang.jni_gen.apisummarizer.Main + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.10.1 + + 11 + 11 + + + + + diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/Main.java b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/Main.java new file mode 100644 index 000000000..f733c8e05 --- /dev/null +++ b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/Main.java @@ -0,0 +1,205 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jni_gen.apisummarizer; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.github.dart_lang.jni_gen.apisummarizer.disasm.AsmSummarizer; +import com.github.dart_lang.jni_gen.apisummarizer.doclet.SummarizerDoclet; +import com.github.dart_lang.jni_gen.apisummarizer.elements.ClassDecl; +import com.github.dart_lang.jni_gen.apisummarizer.util.Log; +import java.io.File; +import java.io.FileFilter; +import java.io.IOException; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; +import javax.tools.DocumentationTool; +import javax.tools.ToolProvider; +import jdk.javadoc.doclet.Doclet; +import org.apache.commons.cli.*; + +public class Main { + private static final CommandLineParser parser = new DefaultParser(); + static SummarizerOptions config; + + public static void writeAll(List decls) { + var mapper = new ObjectMapper(); + Log.timed("Writing JSON"); + mapper.enable(SerializationFeature.INDENT_OUTPUT); + mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); + try { + mapper.writeValue(System.out, decls); + } catch (IOException e) { + e.printStackTrace(); + } + Log.timed("Finished"); + } + + public static void runDoclet(List qualifiedNames, SummarizerOptions options) { + runDocletWithClass(SummarizerDoclet.class, qualifiedNames, options); + } + + public static void runDocletWithClass( + Class docletClass, List qualifiedNames, SummarizerOptions options) { + List javaFilePaths = + qualifiedNames.stream() + .map(s -> findSourceLocation(s, options.sourcePaths.split(File.pathSeparator))) + .collect(Collectors.toList()); + Log.setVerbose(options.verbose); + + var files = + javaFilePaths.stream() + .flatMap( + path -> recursiveListFiles(path, file -> file.getName().endsWith(".java")).stream()) + .map(File::getPath) + .toArray(String[]::new); + + DocumentationTool javadoc = ToolProvider.getSystemDocumentationTool(); + var fileManager = javadoc.getStandardFileManager(null, null, null); + var fileObjects = fileManager.getJavaFileObjects(files); + + var cli = new ArrayList(); + cli.add((options.useModules ? "--module-" : "--") + "source-path=" + options.sourcePaths); + if (options.classPaths != null) { + cli.add("--class-path=" + options.classPaths); + } + if (options.addDependencies) { + cli.add("--expand-requires=all"); + } + if (options.toolOptions != null) { + cli.addAll(List.of(options.toolOptions.split(" "))); + } + + javadoc.getTask(null, fileManager, System.err::println, docletClass, cli, fileObjects).call(); + } + + public static void main(String[] args) { + CommandLine cl = parseArgs(args); + config = SummarizerOptions.fromCommandLine(cl); + if (config.useAsm) { + System.err.println("use-asm: ignoring all flags other than --classes (-c)"); + try { + writeAll(AsmSummarizer.run(config.classPaths.split(File.pathSeparator), cl.getArgs())); + } catch (IOException e) { + e.printStackTrace(); + } + return; + } + runDoclet(List.of(cl.getArgs()), config); + } + + public static File findSourceLocation(String qualifiedName, String[] paths) { + var s = qualifiedName.replace(".", "/"); + for (var folder : paths) { + var f = new File(folder, s + ".java"); + if (f.exists() && f.isFile()) { + return f; + } + var d = new File(folder, s); + if (d.exists() && d.isDirectory()) { + return d; + } + } + throw new RuntimeException("cannot find class: " + s); + } + + public static List recursiveListFiles(File file, FileFilter filter) { + if (!file.isDirectory()) { + return List.of(file); + } + var files = new ArrayList(); + var queue = new ArrayDeque(); + queue.add(file); + while (!queue.isEmpty()) { + var dir = queue.poll(); + var list = dir.listFiles(entry -> entry.isDirectory() || filter.accept(entry)); + if (list == null) { + throw new IllegalArgumentException(); + } + for (var path : list) { + if (path.isDirectory()) { + queue.add(path); + } else { + files.add(path); + } + } + } + return files; + } + + public static CommandLine parseArgs(String[] args) { + var options = new Options(); + Option sources = new Option("s", "sources", true, "paths to search for source files"); + Option classes = new Option("c", "classes", true, "paths to search for compiled classes"); + Option backend = + new Option( + "b", "backend", true, "backend to use for summary generation ('doclet' or 'asm')."); + Option useModules = new Option("M", "use-modules", false, "use Java modules"); + Option recursive = new Option("r", "recursive", false, "Include dependencies of classes"); + Option moduleNames = + new Option("m", "module-names", true, "comma separated list of module names"); + Option doctoolArgs = + new Option("D", "doctool-args", true, "Arguments to pass to the documentation tool"); + Option verbose = new Option("v", "verbose", false, "Enable verbose output"); + for (Option opt : + new Option[] { + sources, classes, backend, useModules, recursive, moduleNames, doctoolArgs, verbose + }) { + options.addOption(opt); + } + + HelpFormatter help = new HelpFormatter(); + + CommandLine cmd; + + try { + cmd = parser.parse(options, args); + if (cmd.getArgs().length < 1) { + throw new ParseException("Need to specify paths to source files"); + } + } catch (ParseException e) { + System.out.println(e.getMessage()); + help.printHelp( + "java -jar [-s ] " + + "[-c ] \n" + + "Class or package names should be fully qualified.\n\n", + options); + System.exit(1); + return null; + } + return cmd; + } + + public static class SummarizerOptions { + String sourcePaths, classPaths; + boolean useModules, useAsm; + String modulesList; + boolean addDependencies; + String toolOptions; + boolean verbose; + + public static SummarizerOptions fromCommandLine(CommandLine cmd) { + var opts = new SummarizerOptions(); + opts.sourcePaths = cmd.getOptionValue("sources", "."); + var backend = cmd.getOptionValue("backend", "doclet"); + if (backend.equalsIgnoreCase("asm")) { + opts.useAsm = true; + } else if (!backend.equalsIgnoreCase("doclet")) { + System.err.println("supported backends: asm, doclet"); + System.exit(1); + } + opts.classPaths = cmd.getOptionValue("classes", null); + opts.useModules = cmd.hasOption("use-modules"); + opts.modulesList = cmd.getOptionValue("module-names", null); + opts.addDependencies = cmd.hasOption("recursive"); + opts.toolOptions = cmd.getOptionValue("doctool-args", null); + opts.verbose = cmd.hasOption("verbose"); + return opts; + } + } +} diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmAnnotatedElementVisitor.java b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmAnnotatedElementVisitor.java new file mode 100644 index 000000000..8938ed7ab --- /dev/null +++ b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmAnnotatedElementVisitor.java @@ -0,0 +1,24 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jni_gen.apisummarizer.disasm; + +import com.github.dart_lang.jni_gen.apisummarizer.elements.JavaAnnotation; +import org.objectweb.asm.AnnotationVisitor; +import org.objectweb.asm.Type; + +// This interface removes some repetitive code using default methods + +public interface AsmAnnotatedElementVisitor { + void addAnnotation(JavaAnnotation annotation); + + default AnnotationVisitor visitAnnotationDefault(String descriptor, boolean visible) { + var annotation = new JavaAnnotation(); + var aType = Type.getType(descriptor); + annotation.binaryName = aType.getClassName(); + annotation.simpleName = TypeUtils.simpleName(aType); + addAnnotation(annotation); + return new AsmAnnotationVisitor(annotation); + } +} diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmAnnotationVisitor.java b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmAnnotationVisitor.java new file mode 100644 index 000000000..7496fc7ad --- /dev/null +++ b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmAnnotationVisitor.java @@ -0,0 +1,86 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jni_gen.apisummarizer.disasm; + +import com.github.dart_lang.jni_gen.apisummarizer.elements.JavaAnnotation; +import java.util.ArrayList; +import java.util.List; +import org.objectweb.asm.AnnotationVisitor; +import org.objectweb.asm.Type; + +public class AsmAnnotationVisitor extends AnnotationVisitor { + + JavaAnnotation annotation; + + protected AsmAnnotationVisitor(JavaAnnotation annotation) { + super(AsmConstants.API); + this.annotation = annotation; + } + + @Override + public void visit(String name, Object value) { + annotation.properties.put(name, value); + } + + @Override + public void visitEnum(String name, String descriptor, String value) { + annotation.properties.put( + name, new JavaAnnotation.EnumVal(Type.getType(descriptor).getClassName(), value)); + } + + @Override + public AnnotationVisitor visitAnnotation(String name, String descriptor) { + var type = Type.getType(descriptor); + var nested = new JavaAnnotation(); + nested.binaryName = type.getClassName(); + nested.simpleName = TypeUtils.simpleName(type); + annotation.properties.put(name, nested); + return new AsmAnnotationVisitor(nested); + } + + @Override + public AnnotationVisitor visitArray(String name) { + List list = new ArrayList<>(); + annotation.properties.put(name, list); + return new AnnotationArrayVisitor(list); + } + + public static class AnnotationArrayVisitor extends AnnotationVisitor { + List list; + + protected AnnotationArrayVisitor(List list) { + super(AsmConstants.API); + this.list = list; + } + + @Override + public void visit(String unused, Object value) { + list.add(value); + } + + @Override + public void visitEnum(String unused, String descriptor, String value) { + var type = Type.getType(descriptor); + list.add(new JavaAnnotation.EnumVal(type.getClassName(), value)); + } + + @Override + public AnnotationVisitor visitAnnotation(String unused, String descriptor) { + var type = Type.getType(descriptor); + var nested = new JavaAnnotation(); + nested.binaryName = type.getClassName(); + nested.simpleName = TypeUtils.simpleName(type); + list.add(nested); + return new AsmAnnotationVisitor(nested); + } + + @Override + public AnnotationVisitor visitArray(String unused) { + List nested = new ArrayList<>(); + list.add(nested); + return new AnnotationArrayVisitor(nested); + } + } +} diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmClassVisitor.java b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmClassVisitor.java new file mode 100644 index 000000000..faed8312e --- /dev/null +++ b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmClassVisitor.java @@ -0,0 +1,144 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jni_gen.apisummarizer.disasm; + +import static org.objectweb.asm.Opcodes.ACC_PROTECTED; +import static org.objectweb.asm.Opcodes.ACC_PUBLIC; + +import com.github.dart_lang.jni_gen.apisummarizer.elements.*; +import com.github.dart_lang.jni_gen.apisummarizer.util.SkipException; +import com.github.dart_lang.jni_gen.apisummarizer.util.StreamUtil; +import java.util.*; +import org.objectweb.asm.*; + +public class AsmClassVisitor extends ClassVisitor implements AsmAnnotatedElementVisitor { + private static Param param( + Type type, String name, @SuppressWarnings("SameParameterValue") String signature) { + var param = new Param(); + param.name = name; + param.type = TypeUtils.typeUsage(type, signature); + return param; + } + + public List getVisited() { + return visited; + } + + List visited = new ArrayList<>(); + Stack visiting = new Stack<>(); + + public AsmClassVisitor() { + super(AsmConstants.API); + } + + @Override + public void visit( + int version, + int access, + String name, + String signature, + String superName, + String[] interfaces) { + var current = new ClassDecl(); + visiting.push(current); + var type = Type.getObjectType(name); + current.binaryName = type.getClassName(); + current.modifiers = TypeUtils.access(access); + current.parentName = TypeUtils.parentName(type); + current.packageName = TypeUtils.packageName(type); + current.declKind = TypeUtils.declKind(access); + current.simpleName = TypeUtils.simpleName(type); + current.superclass = TypeUtils.typeUsage(Type.getObjectType(superName), null); + current.interfaces = + StreamUtil.map(interfaces, i -> TypeUtils.typeUsage(Type.getObjectType(i), null)); + super.visit(version, access, name, signature, superName, interfaces); + } + + private static boolean isPrivate(int access) { + return ((access & ACC_PUBLIC) == 0) && ((access & ACC_PROTECTED) == 0); + } + + @Override + public FieldVisitor visitField( + int access, String name, String descriptor, String signature, Object value) { + if (name.contains("$") || isPrivate(access)) { + return null; + } + var field = new Field(); + field.name = name; + field.type = TypeUtils.typeUsage(Type.getType(descriptor), signature); + field.defaultValue = value; + field.modifiers = TypeUtils.access(access); + peekVisiting().fields.add(field); + return new AsmFieldVisitor(field); + } + + @Override + public MethodVisitor visitMethod( + int access, String name, String descriptor, String signature, String[] exceptions) { + var method = new Method(); + if (name.contains("$") || isPrivate(access)) { + return null; + } + method.name = name; + var type = Type.getType(descriptor); + var params = new ArrayList(); + var paramTypes = type.getArgumentTypes(); + var paramNames = new HashMap(); + for (var pt : paramTypes) { + var paramName = TypeUtils.defaultParamName(pt); + if (paramNames.containsKey(paramName)) { + var nth = paramNames.get(paramName); + paramNames.put(paramName, nth + 1); + paramName = paramName + nth; + } else { + paramNames.put(paramName, 1); + } + params.add(param(pt, paramName, null)); + } + method.returnType = TypeUtils.typeUsage(type.getReturnType(), signature); + method.modifiers = TypeUtils.access(access); + method.params = params; + peekVisiting().methods.add(method); + return new AsmMethodVisitor(method); + } + + @Override + public void addAnnotation(JavaAnnotation annotation) { + peekVisiting().annotations.add(annotation); + } + + @Override + public AnnotationVisitor visitAnnotationDefault(String descriptor, boolean visible) { + return super.visitAnnotation(descriptor, visible); + } + + @Override + public AnnotationVisitor visitTypeAnnotation( + int typeRef, TypePath typePath, String descriptor, boolean visible) { + return super.visitTypeAnnotation(typeRef, typePath, descriptor, visible); + } + + @Override + public void visitEnd() { + visited.add(popVisiting()); + } + + private ClassDecl peekVisiting() { + try { + return visiting.peek(); + } catch (EmptyStackException e) { + throw new SkipException("Error: stack was empty when visitEnd was called."); + } + } + + private ClassDecl popVisiting() { + try { + return visiting.pop(); + } catch (EmptyStackException e) { + throw new SkipException("Error: stack was empty when visitEnd was called."); + } + } +} diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmConstants.java b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmConstants.java new file mode 100644 index 000000000..668db64d8 --- /dev/null +++ b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmConstants.java @@ -0,0 +1,11 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jni_gen.apisummarizer.disasm; + +import static org.objectweb.asm.Opcodes.ASM9; + +public class AsmConstants { + static final int API = ASM9; +} diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmFieldVisitor.java b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmFieldVisitor.java new file mode 100644 index 000000000..5c91cb678 --- /dev/null +++ b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmFieldVisitor.java @@ -0,0 +1,29 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jni_gen.apisummarizer.disasm; + +import com.github.dart_lang.jni_gen.apisummarizer.elements.Field; +import com.github.dart_lang.jni_gen.apisummarizer.elements.JavaAnnotation; +import org.objectweb.asm.AnnotationVisitor; +import org.objectweb.asm.FieldVisitor; + +public class AsmFieldVisitor extends FieldVisitor implements AsmAnnotatedElementVisitor { + Field field; + + public AsmFieldVisitor(Field field) { + super(AsmConstants.API); + this.field = field; + } + + @Override + public void addAnnotation(JavaAnnotation annotation) { + field.annotations.add(annotation); + } + + @Override + public AnnotationVisitor visitAnnotation(String descriptor, boolean visible) { + return AsmAnnotatedElementVisitor.super.visitAnnotationDefault(descriptor, visible); + } +} diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmMethodVisitor.java b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmMethodVisitor.java new file mode 100644 index 000000000..02f56cfa8 --- /dev/null +++ b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmMethodVisitor.java @@ -0,0 +1,61 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jni_gen.apisummarizer.disasm; + +import com.github.dart_lang.jni_gen.apisummarizer.elements.JavaAnnotation; +import com.github.dart_lang.jni_gen.apisummarizer.elements.Method; +import java.util.ArrayList; +import java.util.List; +import org.objectweb.asm.AnnotationVisitor; +import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.TypePath; + +public class AsmMethodVisitor extends MethodVisitor implements AsmAnnotatedElementVisitor { + Method method; + List paramNames = new ArrayList<>(); + + protected AsmMethodVisitor(Method method) { + super(AsmConstants.API); + this.method = method; + } + + @Override + public void visitParameter(String name, int access) { + paramNames.add(name); + } + + @Override + public void addAnnotation(JavaAnnotation annotation) { + method.annotations.add(annotation); + } + + @Override + public AnnotationVisitor visitAnnotationDefault(String descriptor, boolean visible) { + return AsmAnnotatedElementVisitor.super.visitAnnotationDefault(descriptor, visible); + } + + @Override + public AnnotationVisitor visitTypeAnnotation( + int typeRef, TypePath typePath, String descriptor, boolean visible) { + // TODO(#23): Collect annotation on type parameter + return super.visitTypeAnnotation(typeRef, typePath, descriptor, visible); + } + + @Override + public AnnotationVisitor visitParameterAnnotation( + int parameter, String descriptor, boolean visible) { + // TODO(#23): collect and attach it to parameters + return super.visitParameterAnnotation(parameter, descriptor, visible); + } + + @Override + public void visitEnd() { + if (paramNames.size() == method.params.size()) { + for (int i = 0; i < paramNames.size(); i++) { + method.params.get(i).name = paramNames.get(i); + } + } + } +} diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmSummarizer.java b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmSummarizer.java new file mode 100644 index 000000000..af89a0ba7 --- /dev/null +++ b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmSummarizer.java @@ -0,0 +1,84 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jni_gen.apisummarizer.disasm; + +import com.github.dart_lang.jni_gen.apisummarizer.elements.ClassDecl; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import java.util.jar.JarFile; +import java.util.stream.Collectors; +import java.util.zip.ZipEntry; +import org.objectweb.asm.ClassReader; + +/** Class that summarizes Java APIs in compiled JARs using ASM not working yet. */ +public class AsmSummarizer { + + private static class JarClass { + JarFile jar; + ZipEntry entry; + + public JarClass(JarFile jar, ZipEntry entry) { + this.jar = jar; + this.entry = entry; + } + } + + public static List findJarLocation( + String binaryName, List jars, String suffix) { + String path = binaryName.replace(".", "/"); + for (var jar : jars) { + var classEntry = jar.getEntry(path + suffix); + if (classEntry != null) { + return List.of(new JarClass(jar, classEntry)); + } + var dirPath = path.endsWith("/") ? path : path + "/"; + var dirEntry = jar.getEntry(dirPath); + if (dirEntry != null && dirEntry.isDirectory()) { + return jar.stream() + .map(je -> (ZipEntry) je) + .filter( + entry -> { + var name = entry.getName(); + return name.endsWith(suffix) && name.startsWith(dirPath); + }) + .map(entry -> new JarClass(jar, entry)) + .collect(Collectors.toList()); + } + } + throw new RuntimeException("Cannot find class"); + } + + public static List run(String[] jarPaths, String[] classes) throws IOException { + var jars = + Arrays.stream(jarPaths) + .map( + filename -> { + try { + return new JarFile(filename); + } catch (IOException e) { + throw new RuntimeException(e); + } + }) + .collect(Collectors.toList()); + return Arrays.stream(classes) + .flatMap(c -> findJarLocation(c, jars, ".class").stream()) + .map( + classFile -> { + try { + return new ClassReader(classFile.jar.getInputStream(classFile.entry)); + } catch (IOException e) { + throw new RuntimeException(e); + } + }) + .flatMap( + reader -> { + var visitor = new AsmClassVisitor(); + reader.accept(visitor, 0); + return visitor.getVisited().stream(); + }) + .collect(Collectors.toList()); + } +} diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/TypeUtils.java b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/TypeUtils.java new file mode 100644 index 000000000..17dd46e42 --- /dev/null +++ b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/TypeUtils.java @@ -0,0 +1,118 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jni_gen.apisummarizer.disasm; + +import static org.objectweb.asm.Opcodes.*; +import static org.objectweb.asm.Type.ARRAY; +import static org.objectweb.asm.Type.OBJECT; + +import com.github.dart_lang.jni_gen.apisummarizer.elements.DeclKind; +import com.github.dart_lang.jni_gen.apisummarizer.elements.TypeUsage; +import com.github.dart_lang.jni_gen.apisummarizer.util.SkipException; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import org.objectweb.asm.Type; + +class TypeUtils { + + public static String parentName(Type type) { + return type.getClassName().split("\\$")[0]; + } + + public static String packageName(Type type) { + var className = type.getClassName(); + var last = className.lastIndexOf("."); + if (last != -1) { + return className.substring(0, last); + } + return null; + } + + public static String simpleName(Type type) { + var internalName = type.getInternalName(); + if (type.getInternalName().length() == 1) { + return type.getClassName(); + } + var components = internalName.split("[/$]"); + if (components.length == 0) { + throw new SkipException("Cannot derive simple name: " + internalName); + } + return components[components.length - 1]; + } + + public static TypeUsage typeUsage(Type type, @SuppressWarnings("unused") String signature) { + var usage = new TypeUsage(); + usage.shorthand = type.getClassName(); + switch (type.getSort()) { + case OBJECT: + usage.kind = TypeUsage.Kind.DECLARED; + usage.type = + new TypeUsage.DeclaredType(type.getClassName(), TypeUtils.simpleName(type), null); + break; + case ARRAY: + usage.kind = TypeUsage.Kind.ARRAY; + usage.type = new TypeUsage.Array(TypeUtils.typeUsage(type.getElementType(), null)); + break; + default: + usage.kind = TypeUsage.Kind.PRIMITIVE; + usage.type = new TypeUsage.PrimitiveType(type.getClassName()); + } + // TODO(#23): generics + return usage; + } + + public static Set access(int access) { + var result = new HashSet(); + for (var ac : acc.entrySet()) { + if ((ac.getValue() & access) != 0) { + result.add(ac.getKey()); + } + } + return result; + } + + private static final Map acc = new HashMap<>(); + + static { + acc.put("static", ACC_STATIC); + acc.put("private", ACC_PRIVATE); + acc.put("protected", ACC_PROTECTED); + acc.put("public", ACC_PUBLIC); + acc.put("abstract", ACC_ABSTRACT); + acc.put("final", ACC_FINAL); + acc.put("native", ACC_NATIVE); + } + + static DeclKind declKind(int access) { + if ((access & ACC_ENUM) != 0) return DeclKind.ENUM; + if ((access & ACC_INTERFACE) != 0) return DeclKind.INTERFACE; + if ((access & ACC_ANNOTATION) != 0) return DeclKind.ANNOTATION_TYPE; + return DeclKind.CLASS; + } + + static String defaultParamName(Type type) { + switch (type.getSort()) { + case ARRAY: + return defaultParamName(type.getElementType()) + 's'; + case OBJECT: + return unCapitalize(simpleName(type)); + case Type.METHOD: + throw new SkipException("unexpected method type" + type); + default: // Primitive type + var typeCh = type.getInternalName().charAt(0); + return String.valueOf(Character.toLowerCase(typeCh)); + } + } + + private static String unCapitalize(String s) { + var first = Character.toLowerCase(s.charAt(0)); + if (s.length() == 1) { + return String.valueOf(first); + } + return first + s.substring(1); + } +} diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/doclet/AnnotationVisitor.java b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/doclet/AnnotationVisitor.java new file mode 100644 index 000000000..442a9443e --- /dev/null +++ b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/doclet/AnnotationVisitor.java @@ -0,0 +1,100 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jni_gen.apisummarizer.doclet; + +import java.util.List; +import java.util.stream.Collectors; +import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.AnnotationValue; +import javax.lang.model.element.AnnotationValueVisitor; +import javax.lang.model.element.VariableElement; +import javax.lang.model.type.TypeMirror; + +public class AnnotationVisitor implements AnnotationValueVisitor { + private final ElementBuilders builders; + AstEnv env; + + public AnnotationVisitor(ElementBuilders builders) { + this.builders = builders; + this.env = builders.env; + } + + @Override + public Object visit(AnnotationValue annotationValue, Void unused) { + return null; + } + + @Override + public Object visitBoolean(boolean b, Void unused) { + return b; + } + + @Override + public Object visitByte(byte b, Void unused) { + return b; + } + + @Override + public Object visitChar(char c, Void unused) { + return c; + } + + @Override + public Object visitDouble(double v, Void unused) { + return v; + } + + @Override + public Object visitFloat(float v, Void unused) { + return v; + } + + @Override + public Object visitInt(int i, Void unused) { + return i; + } + + @Override + public Object visitLong(long l, Void unused) { + return l; + } + + @Override + public Object visitShort(short i, Void unused) { + return i; + } + + @Override + public Object visitString(String s, Void unused) { + return s; + } + + @Override + public Object visitType(TypeMirror typeMirror, Void unused) { + return builders.typeUsage(typeMirror); + } + + @Override + public Object visitEnumConstant(VariableElement variableElement, Void unused) { + // TODO(#23): Perhaps simple name is not enough. We need to return qualified + // name + enum constant name for completeness. + return variableElement.getSimpleName(); + } + + @Override + public Object visitAnnotation(AnnotationMirror mirror, Void unused) { + return builders.annotation(mirror); + } + + @Override + public Object visitArray(List list, Void unused) { + return list.stream().map(x -> x.accept(this, null)).collect(Collectors.toList()); + } + + @Override + public Object visitUnknown(AnnotationValue annotationValue, Void unused) { + return null; + } +} diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/doclet/AstEnv.java b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/doclet/AstEnv.java new file mode 100644 index 000000000..2358a161e --- /dev/null +++ b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/doclet/AstEnv.java @@ -0,0 +1,27 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jni_gen.apisummarizer.doclet; + +import com.sun.source.util.DocTrees; +import javax.lang.model.util.Elements; +import javax.lang.model.util.Types; +import jdk.javadoc.doclet.DocletEnvironment; + +/** Class to hold utility classes initialized from DocletEnvironment. */ +public class AstEnv { + public final Types types; + public final Elements elements; + public final DocTrees trees; + + public AstEnv(Types types, Elements elements, DocTrees trees) { + this.types = types; + this.elements = elements; + this.trees = trees; + } + + public static AstEnv fromEnvironment(DocletEnvironment env) { + return new AstEnv(env.getTypeUtils(), env.getElementUtils(), env.getDocTrees()); + } +} diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/doclet/ElementBuilders.java b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/doclet/ElementBuilders.java new file mode 100644 index 000000000..809174f6a --- /dev/null +++ b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/doclet/ElementBuilders.java @@ -0,0 +1,211 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jni_gen.apisummarizer.doclet; + +import com.github.dart_lang.jni_gen.apisummarizer.elements.*; +import com.github.dart_lang.jni_gen.apisummarizer.util.StreamUtil; +import com.sun.source.doctree.DocCommentTree; +import java.util.HashMap; +import java.util.List; +import java.util.stream.Collectors; +import javax.lang.model.element.*; +import javax.lang.model.type.*; + +public class ElementBuilders { + AstEnv env; + + public ElementBuilders(AstEnv env) { + this.env = env; + } + + private void fillInFromTypeElement(TypeElement e, ClassDecl c) { + c.modifiers = e.getModifiers().stream().map(Modifier::toString).collect(Collectors.toSet()); + c.simpleName = e.getSimpleName().toString(); + c.binaryName = env.elements.getBinaryName(e).toString(); + switch (e.getKind()) { + case INTERFACE: + c.declKind = DeclKind.INTERFACE; + break; + case CLASS: + c.declKind = DeclKind.CLASS; + break; + case ENUM: + c.declKind = DeclKind.ENUM; + break; + case ANNOTATION_TYPE: + c.declKind = DeclKind.ANNOTATION_TYPE; + break; + default: + throw new RuntimeException( + "Unexpected element kind " + e.getKind() + " on " + c.binaryName); + } + var parent = e.getEnclosingElement(); + if (parent instanceof TypeElement) { + c.parentName = env.elements.getBinaryName((TypeElement) parent).toString(); + } + c.packageName = env.elements.getPackageOf(e).getQualifiedName().toString(); + c.javadoc = docComment(env.trees.getDocCommentTree(e)); + c.typeParams = StreamUtil.map(e.getTypeParameters(), this::typeParam); + var superclass = e.getSuperclass(); + if (superclass instanceof DeclaredType) { + c.superclass = typeUsage(superclass); + } + c.annotations = StreamUtil.map(e.getAnnotationMirrors(), this::annotation); + c.interfaces = StreamUtil.map(e.getInterfaces(), this::typeUsage); + } + + public ClassDecl classDecl(TypeElement e) { + var c = new ClassDecl(); + fillInFromTypeElement(e, c); + return c; + } + + public Field field(VariableElement e) { + assert e.getKind() == ElementKind.FIELD; + var field = new Field(); + field.name = e.getSimpleName().toString(); + field.modifiers = e.getModifiers().stream().map(Modifier::toString).collect(Collectors.toSet()); + field.defaultValue = e.getConstantValue(); + field.type = typeUsage(e.asType()); + field.javadoc = docComment(env.trees.getDocCommentTree(e)); + field.annotations = annotations(e.getAnnotationMirrors()); + return field; + } + + public List annotations(List mirrors) { + return mirrors.stream().map(this::annotation).collect(Collectors.toList()); + } + + public JavaAnnotation annotation(AnnotationMirror mirror) { + var annotation = new JavaAnnotation(); + var type = mirror.getAnnotationType(); + var typeElement = (TypeElement) (env.types.asElement(type)); + annotation.simpleName = typeElement.getSimpleName().toString(); + annotation.binaryName = env.elements.getBinaryName(typeElement).toString(); + var values = env.elements.getElementValuesWithDefaults(mirror); + if (values.isEmpty()) { + return annotation; + } + + // This is not perfect, but some metadata is better than none. + annotation.properties = new HashMap<>(); + for (var key : values.keySet()) { + var val = values.get(key); + var obj = val.getValue(); + // TODO(#23): Accurately represent more complex annotation values + if (obj instanceof String || obj instanceof Number) { + annotation.properties.put(key.getSimpleName().toString(), obj); + } else { + annotation.properties.put( + key.getSimpleName().toString(), val.accept(new AnnotationVisitor(this), null)); + } + } + return annotation; + } + + public JavaDocComment docComment(DocCommentTree tree) { + if (tree == null) { + return null; + } + // Leave it as is, for now + // tree.accept(new TreeScanner(), j); + return new JavaDocComment(tree.toString()); + } + + public TypeParam typeParam(TypeParameterElement tpe) { + var tp = new TypeParam(); + tp.name = tpe.getSimpleName().toString(); + tp.bounds = tpe.getBounds().stream().map(this::typeUsage).collect(Collectors.toList()); + return tp; + } + + public Param param(VariableElement e) { + var param = new Param(); + param.javadoc = docComment(env.trees.getDocCommentTree(e)); + param.name = e.getSimpleName().toString(); + param.type = typeUsage(e.asType()); + param.annotations = annotations(e.getAnnotationMirrors()); + return param; + } + + public TypeUsage typeUsage(TypeMirror type) { + var u = new TypeUsage(); + u.shorthand = type.toString(); + var element = env.types.asElement(type); + switch (type.getKind()) { + case DECLARED: + // Unique name that's binary name not qualified name + // (It's somewhat confusing but qualified name does not need to be unique, + // because of nesting) + u.kind = TypeUsage.Kind.DECLARED; + var name = + element instanceof TypeElement + ? env.elements.getBinaryName((TypeElement) element).toString() + : element.getSimpleName().toString(); + List params = null; + if (type instanceof DeclaredType) { // it will be + params = + ((DeclaredType) type) + .getTypeArguments().stream().map(this::typeUsage).collect(Collectors.toList()); + } + u.type = new TypeUsage.DeclaredType(name, element.getSimpleName().toString(), params); + break; + case TYPEVAR: + u.kind = TypeUsage.Kind.TYPE_VARIABLE; + // TODO(#23): Encode bounds of type variable. + // A straightforward approach will cause infinite recursion very + // easily. Another approach I can think of is only encoding the + // erasure of the type variable per JLS. + u.type = new TypeUsage.TypeVar(element.getSimpleName().toString()); + break; + case ARRAY: + u.kind = TypeUsage.Kind.ARRAY; + var arr = ((ArrayType) type); + u.type = new TypeUsage.Array(typeUsage(arr.getComponentType())); + break; + case VOID: + u.type = new TypeUsage.PrimitiveType("void"); + u.kind = TypeUsage.Kind.PRIMITIVE; + break; + case WILDCARD: + u.kind = TypeUsage.Kind.WILDCARD; + var wildcard = ((WildcardType) type); + var extendsBound = wildcard.getExtendsBound(); + var superBound = wildcard.getSuperBound(); + u.type = + new TypeUsage.Wildcard( + extendsBound != null ? typeUsage(extendsBound) : null, + superBound != null ? typeUsage(superBound) : null); + break; + case INTERSECTION: + u.kind = TypeUsage.Kind.INTERSECTION; + u.type = + new TypeUsage.Intersection( + ((IntersectionType) type) + .getBounds().stream().map(this::typeUsage).collect(Collectors.toList())); + break; + default: + u.kind = TypeUsage.Kind.PRIMITIVE; + if (type instanceof PrimitiveType) { + u.type = new TypeUsage.PrimitiveType(type.toString()); + } else { + System.out.println("Unsupported type: " + type); + // throw exception. + } + } + return u; + } + + public Method method(ExecutableElement e) { + var m = new Method(); + m.name = e.getSimpleName().toString(); + m.modifiers = e.getModifiers().stream().map(Modifier::toString).collect(Collectors.toSet()); + m.typeParams = e.getTypeParameters().stream().map(this::typeParam).collect(Collectors.toList()); + m.returnType = typeUsage(e.getReturnType()); + m.javadoc = docComment(env.trees.getDocCommentTree(e)); + m.annotations = annotations(e.getAnnotationMirrors()); + return m; + } +} diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/doclet/SummarizerDoclet.java b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/doclet/SummarizerDoclet.java new file mode 100644 index 000000000..b0dfd7547 --- /dev/null +++ b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/doclet/SummarizerDoclet.java @@ -0,0 +1,17 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jni_gen.apisummarizer.doclet; + +import com.github.dart_lang.jni_gen.apisummarizer.Main; +import jdk.javadoc.doclet.DocletEnvironment; + +public class SummarizerDoclet extends SummarizerDocletBase { + @Override + public boolean run(DocletEnvironment docletEnvironment) { + var result = super.run(docletEnvironment); + Main.writeAll(types); + return result; + } +} diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/doclet/SummarizerDocletBase.java b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/doclet/SummarizerDocletBase.java new file mode 100644 index 000000000..8e6067d31 --- /dev/null +++ b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/doclet/SummarizerDocletBase.java @@ -0,0 +1,161 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jni_gen.apisummarizer.doclet; + +import com.github.dart_lang.jni_gen.apisummarizer.elements.ClassDecl; +import com.github.dart_lang.jni_gen.apisummarizer.elements.Method; +import com.github.dart_lang.jni_gen.apisummarizer.elements.Package; +import com.github.dart_lang.jni_gen.apisummarizer.util.Log; +import com.github.dart_lang.jni_gen.apisummarizer.util.SkipException; +import java.util.*; +import javax.lang.model.SourceVersion; +import javax.lang.model.element.*; +import javax.lang.model.util.ElementScanner9; +import jdk.javadoc.doclet.Doclet; +import jdk.javadoc.doclet.DocletEnvironment; +import jdk.javadoc.doclet.Reporter; + +public class SummarizerDocletBase implements Doclet { + private AstEnv utils; + + @Override + public void init(Locale locale, Reporter reporter) {} + + @Override + public String getName() { + return "ApiSummarizer"; + } + + @Override + public Set getSupportedOptions() { + return Collections.emptySet(); + } + + @Override + public SourceVersion getSupportedSourceVersion() { + return SourceVersion.RELEASE_11; + } + + public static List types; + + @Override + public boolean run(DocletEnvironment docletEnvironment) { + Log.timed("Initializing doclet"); + utils = AstEnv.fromEnvironment(docletEnvironment); + SummarizingScanner p = new SummarizingScanner(); + docletEnvironment.getSpecifiedElements().forEach(e -> p.scan(e, new SummaryCollector())); + types = p.types; + return true; + } + + public static class SummaryCollector { + Stack packages = new Stack<>(); + Stack types = new Stack<>(); + Method method; + } + + public class SummarizingScanner extends ElementScanner9 { + List packages = new ArrayList<>(); + List types = new ArrayList<>(); + ElementBuilders builders = new ElementBuilders(utils); + + // Each element in collector is a stack + // which is used to get topmost element + // and append the child to it. + // Eg: A variable element is always appended to topmost + // class + @Override + public Void scan(Element e, SummaryCollector collector) { + return super.scan(e, collector); + } + + @Override + public Void visitPackage(PackageElement e, SummaryCollector collector) { + Log.verbose("Visiting package: %s", e.getQualifiedName()); + collector.packages.push(new Package()); + System.out.println("package: " + e.getQualifiedName()); + var result = super.visitPackage(e, collector); + var collectedPackage = collector.packages.pop(); + packages.add(collectedPackage); + return result; + } + + @Override + public Void visitType(TypeElement e, SummaryCollector collector) { + if (!collector.types.isEmpty()) { + return null; + } + Log.verbose("Visiting class: %s, %s", e.getQualifiedName(), collector.types); + switch (e.getKind()) { + case CLASS: + case INTERFACE: + case ENUM: + try { + var cls = builders.classDecl(e); + collector.types.push(cls); + super.visitType(e, collector); + types.add(collector.types.pop()); + } catch (SkipException skip) { + Log.always("Skip type: %s", e.getQualifiedName()); + } + break; + case ANNOTATION_TYPE: + Log.always("Skip annotation type: %s", e.getQualifiedName()); + break; + } + return null; + } + + @Override + public Void visitVariable(VariableElement e, SummaryCollector collector) { + var vk = e.getKind(); + var cls = collector.types.peek(); + switch (vk) { + case ENUM_CONSTANT: + cls.values.add(e.getSimpleName().toString()); + break; + case FIELD: + cls.fields.add(builders.field(e)); + break; + case PARAMETER: + if (collector.method == null) { + throw new RuntimeException("Parameter encountered outside executable element"); + } + var method = collector.method; + method.params.add(builders.param(e)); + break; + default: + System.out.println("Unknown type of variable element: " + vk); + } + return null; + } + + @Override + public Void visitExecutable(ExecutableElement element, SummaryCollector collector) { + var cls = collector.types.peek(); + switch (element.getKind()) { + case METHOD: + case CONSTRUCTOR: + try { + var method = builders.method(element); + collector.method = method; + super.visitExecutable(element, collector); + collector.method = null; + cls.methods.add(method); + } catch (SkipException skip) { + Log.always("Skip method: %s", element.getSimpleName()); + } + break; + case STATIC_INIT: + cls.hasStaticInit = true; + break; + case INSTANCE_INIT: + cls.hasInstanceInit = true; + break; + } + return null; + } + } +} diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/ClassDecl.java b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/ClassDecl.java new file mode 100644 index 000000000..f838d9c80 --- /dev/null +++ b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/ClassDecl.java @@ -0,0 +1,47 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jni_gen.apisummarizer.elements; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +/** + * A class or interface declaration. + * + *

Here's an example for various kinds of names stored in this structure: { simpleName : + * "Example", binaryName : "dev.dart.sample.Example", parentName : null, packageName : + * "dev.dart.sample", } + */ +public class ClassDecl { + public DeclKind declKind; + + /** Modifiers eg: static, public and abstract. */ + public Set modifiers; + + /** Unqualified name of the class. For example `ClassDecl` */ + public String simpleName; + + /** + * Unique, fully qualified name of the class, it's like a qualified name used in a program but + * uses $ instead of dot (.) before nested classes. + */ + public String binaryName; + + public String parentName; + public String packageName; + public List typeParams; + public List methods = new ArrayList<>(); + public List fields = new ArrayList<>(); + public TypeUsage superclass; + public List interfaces; + public boolean hasStaticInit; + public boolean hasInstanceInit; + public JavaDocComment javadoc; + public List annotations; + + /** In case of enum, names of enum constants */ + public List values = new ArrayList<>(); +} diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/DeclKind.java b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/DeclKind.java new file mode 100644 index 000000000..376782d41 --- /dev/null +++ b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/DeclKind.java @@ -0,0 +1,12 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jni_gen.apisummarizer.elements; + +public enum DeclKind { + CLASS, + ENUM, + INTERFACE, + ANNOTATION_TYPE +} diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/Field.java b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/Field.java new file mode 100644 index 000000000..c39c3012d --- /dev/null +++ b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/Field.java @@ -0,0 +1,20 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jni_gen.apisummarizer.elements; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class Field { + public Set modifiers = new HashSet<>(); + public String name; + public TypeUsage type; + public Object defaultValue; + + public JavaDocComment javadoc; + public List annotations = new ArrayList<>(); +} diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/JavaAnnotation.java b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/JavaAnnotation.java new file mode 100644 index 000000000..d45ab0a32 --- /dev/null +++ b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/JavaAnnotation.java @@ -0,0 +1,24 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jni_gen.apisummarizer.elements; + +import java.util.HashMap; +import java.util.Map; + +public class JavaAnnotation { + public String simpleName; + public String binaryName; + public Map properties = new HashMap<>(); + + public static class EnumVal { + String enumClass; + String value; + + public EnumVal(String enumClass, String value) { + this.enumClass = enumClass; + this.value = value; + } + } +} diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/JavaDocComment.java b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/JavaDocComment.java new file mode 100644 index 000000000..3f8d55e0c --- /dev/null +++ b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/JavaDocComment.java @@ -0,0 +1,15 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jni_gen.apisummarizer.elements; + +public class JavaDocComment { + // TODO(#28): Build a detailed tree representation of JavaDocComment + // which can be processed by tools in other languages as well. + public String comment; + + public JavaDocComment(String comment) { + this.comment = comment; + } +} diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/Method.java b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/Method.java new file mode 100644 index 000000000..d1c3cca71 --- /dev/null +++ b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/Method.java @@ -0,0 +1,21 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jni_gen.apisummarizer.elements; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class Method { + public Set modifiers = new HashSet<>(); + public String name; + public List typeParams; + public List params = new ArrayList<>(); + public TypeUsage returnType; + + public JavaDocComment javadoc; + public List annotations = new ArrayList<>(); +} diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/Package.java b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/Package.java new file mode 100644 index 000000000..8e2cc908b --- /dev/null +++ b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/Package.java @@ -0,0 +1,9 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jni_gen.apisummarizer.elements; + +public class Package { + public String name; +} diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/Param.java b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/Param.java new file mode 100644 index 000000000..5e50e7311 --- /dev/null +++ b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/Param.java @@ -0,0 +1,16 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jni_gen.apisummarizer.elements; + +import java.util.ArrayList; +import java.util.List; + +public class Param { + public String name; + public TypeUsage type; + + public JavaDocComment javadoc; + public List annotations = new ArrayList<>(); +} diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/TypeParam.java b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/TypeParam.java new file mode 100644 index 000000000..17186e55d --- /dev/null +++ b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/TypeParam.java @@ -0,0 +1,12 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jni_gen.apisummarizer.elements; + +import java.util.List; + +public class TypeParam { + public String name; + public List bounds; +} diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/TypeUsage.java b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/TypeUsage.java new file mode 100644 index 000000000..53419ce08 --- /dev/null +++ b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/TypeUsage.java @@ -0,0 +1,79 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jni_gen.apisummarizer.elements; + +import java.util.List; + +public class TypeUsage { + public enum Kind { + DECLARED, + TYPE_VARIABLE, + WILDCARD, + ARRAY, + INTERSECTION, + PRIMITIVE, + } + + // Could've made it just a type hierarchy, but client code parsing JSON + // needs to know the type beforehand, before it can deserialize the `type` field. + public String shorthand; + public Kind kind; + public ReferredType type; + + public abstract static class ReferredType {} + + public static class PrimitiveType extends ReferredType { + public String name; + + public PrimitiveType(String name) { + this.name = name; + } + } + + public static class DeclaredType extends ReferredType { + public String binaryName; + public String simpleName; + public List params; + + public DeclaredType(String binaryName, String simpleName, List params) { + this.binaryName = binaryName; + this.simpleName = simpleName; + this.params = params; + } + } + + public static class TypeVar extends ReferredType { + public String name; + + public TypeVar(String name) { + this.name = name; + } + } + + public static class Wildcard extends ReferredType { + public TypeUsage extendsBound, superBound; + + public Wildcard(TypeUsage extendsBound, TypeUsage superBound) { + this.extendsBound = extendsBound; + this.superBound = superBound; + } + } + + public static class Intersection extends ReferredType { + public List types; + + public Intersection(List types) { + this.types = types; + } + } + + public static class Array extends ReferredType { + public TypeUsage type; + + public Array(TypeUsage type) { + this.type = type; + } + } +} diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/util/Log.java b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/util/Log.java new file mode 100644 index 000000000..7add36bd3 --- /dev/null +++ b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/util/Log.java @@ -0,0 +1,33 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jni_gen.apisummarizer.util; + +public class Log { + private static long lastPrinted = System.currentTimeMillis(); + + public static void setVerbose(boolean verbose) { + Log.verboseLogs = verbose; + } + + private static boolean verboseLogs = false; + + public static void verbose(String format, Object... args) { + if (!verboseLogs) { + return; + } + System.err.printf(format + "\n", args); + } + + public static void timed(String format, Object... args) { + long now = System.currentTimeMillis(); + System.err.printf("[%6d ms] ", now - lastPrinted); + lastPrinted = now; + System.err.printf(format + "\n", args); + } + + public static void always(String format, Object... args) { + System.err.printf(format + "\n", args); + } +} diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/util/SkipException.java b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/util/SkipException.java new file mode 100644 index 000000000..158d819f6 --- /dev/null +++ b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/util/SkipException.java @@ -0,0 +1,13 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jni_gen.apisummarizer.util; + +// Generic skip exception when the code cannot decide how to handle an element. +// The caller in some above layer can catch this and skip to appropriate extent. +public class SkipException extends RuntimeException { + public SkipException(String message) { + super(message); + } +} diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/util/StreamUtil.java b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/util/StreamUtil.java new file mode 100644 index 000000000..2fd2b79b9 --- /dev/null +++ b/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/util/StreamUtil.java @@ -0,0 +1,20 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jni_gen.apisummarizer.util; + +import java.util.Arrays; +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; + +public class StreamUtil { + public static List map(List list, Function function) { + return list.stream().map(function).collect(Collectors.toList()); + } + + public static List map(T[] array, Function function) { + return Arrays.stream(array).map(function).collect(Collectors.toList()); + } +} diff --git a/pkgs/jni_gen/java/src/test/java/com/github/dart_lang/jni_gen/apisummarizer/DocletSummarizerTests.java b/pkgs/jni_gen/java/src/test/java/com/github/dart_lang/jni_gen/apisummarizer/DocletSummarizerTests.java new file mode 100644 index 000000000..afc7a05f6 --- /dev/null +++ b/pkgs/jni_gen/java/src/test/java/com/github/dart_lang/jni_gen/apisummarizer/DocletSummarizerTests.java @@ -0,0 +1,58 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jni_gen.apisummarizer; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import com.github.dart_lang.jni_gen.apisummarizer.elements.ClassDecl; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class DocletSummarizerTests { + private List parsedDecls; + private final Map classesByName = new HashMap<>(); + + @Before + public void setUp() { + var opts = new Main.SummarizerOptions(); + opts.sourcePaths = "src/test/resources/"; + // javadoc tool API is quite inflexible, in that we cannot pass an doclet object, but a class + // So any state we want to access from it has to be either serialized or saved in static fields. + // This means we lose lot of control over loading of files etc.. + // Here, TestDoclet simply stores the result in a static variable which we can get and check + // later. + Main.runDocletWithClass(TestDoclet.class, List.of("com.example.Example"), opts); + parsedDecls = TestDoclet.getClassDecls(); + for (var decl : parsedDecls) { + classesByName.put(decl.binaryName, decl); + } + } + + @Test + public void checkNumberOfClasses() { + Assert.assertEquals(2, parsedDecls.size()); + } + + @Test + public void checkNamesOfClasses() { + var names = parsedDecls.stream().map(decl -> decl.binaryName).collect(Collectors.toSet()); + assertTrue(names.contains("com.example.Example")); + assertTrue(names.contains("com.example.Example$Aux")); + } + + @Test + public void checkNumberOfFieldsAndMethods() { + var example = classesByName.get("com.example.Example"); + assertEquals("Example", example.simpleName); + assertEquals(3, example.fields.size()); + assertEquals(3, example.methods.size()); + } +} diff --git a/pkgs/jni_gen/java/src/test/java/com/github/dart_lang/jni_gen/apisummarizer/TestDoclet.java b/pkgs/jni_gen/java/src/test/java/com/github/dart_lang/jni_gen/apisummarizer/TestDoclet.java new file mode 100644 index 000000000..188cd19ce --- /dev/null +++ b/pkgs/jni_gen/java/src/test/java/com/github/dart_lang/jni_gen/apisummarizer/TestDoclet.java @@ -0,0 +1,21 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jni_gen.apisummarizer; + +import com.github.dart_lang.jni_gen.apisummarizer.doclet.SummarizerDocletBase; +import com.github.dart_lang.jni_gen.apisummarizer.elements.ClassDecl; +import java.util.List; +import jdk.javadoc.doclet.DocletEnvironment; + +public class TestDoclet extends SummarizerDocletBase { + @Override + public boolean run(DocletEnvironment docletEnvironment) { + return super.run(docletEnvironment); + } + + public static List getClassDecls() { + return types; + } +} diff --git a/pkgs/jni_gen/java/src/test/resources/com/example/Example.java b/pkgs/jni_gen/java/src/test/resources/com/example/Example.java new file mode 100644 index 000000000..98896acde --- /dev/null +++ b/pkgs/jni_gen/java/src/test/resources/com/example/Example.java @@ -0,0 +1,33 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +package com.example; + +public class Example { + static final boolean staticFinalField = true; + + Example(int instanceField) { + this.instanceField = instanceField; + } + + static String staticField = "hello"; + + static String getStaticField() { + return staticField; + } + + int instanceField; + + int getInstanceField() { + return instanceField; + } + + public static class Aux extends Example { + static int nothing = 0; + + static Example getAnExample() { + return new Example(); + } + } +} diff --git a/pkgs/jni_gen/lib/jni_gen.dart b/pkgs/jni_gen/lib/jni_gen.dart index 34a82ddc3..0bc7895cb 100644 --- a/pkgs/jni_gen/lib/jni_gen.dart +++ b/pkgs/jni_gen/lib/jni_gen.dart @@ -2,4 +2,11 @@ // 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/my_sum.dart'; +/// This library exports a high level programmatic API to jni_gen, the entry +/// point of which is runJniGenTask function, which takes run configuration as +/// a JniGenTask. +library jni_gen; + +export 'src/elements/elements.dart'; +export 'src/config/config.dart'; +export 'src/writers/writers.dart'; diff --git a/pkgs/jni_gen/lib/src/bindings/bindings.dart b/pkgs/jni_gen/lib/src/bindings/bindings.dart new file mode 100644 index 000000000..9aa6a08c5 --- /dev/null +++ b/pkgs/jni_gen/lib/src/bindings/bindings.dart @@ -0,0 +1,8 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +export 'preprocessor.dart'; +export 'c_bindings.dart'; +export 'dart_bindings.dart'; +export 'symbol_resolver.dart'; diff --git a/pkgs/jni_gen/lib/src/bindings/c_bindings.dart b/pkgs/jni_gen/lib/src/bindings/c_bindings.dart new file mode 100644 index 000000000..71be9c113 --- /dev/null +++ b/pkgs/jni_gen/lib/src/bindings/c_bindings.dart @@ -0,0 +1,361 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +import 'package:jni_gen/src/elements/elements.dart'; +import 'package:jni_gen/src/config/wrapper_options.dart'; + +import 'common.dart'; + +// fullName / mangled name = +// binaryName with replace('.', '_'), replace('$', '__'); + +class CBindingGenerator { + static const _classVarPrefix = '_c'; + static const _methodVarPrefix = '_m'; + static const _fieldVarPrefix = '_f'; + static const _indent = ' '; + + static const _cTypeKeywords = { + 'short', + 'char', + 'int', + 'long', + 'float', + 'double', + }; + + String _cParamRename(String paramName) => + _cTypeKeywords.contains(paramName) ? '${paramName}0' : paramName; + + CBindingGenerator(this.options); + WrapperOptions options; + + String generateBinding(ClassDecl c) { + return _class(c); + } + + String _class(ClassDecl c) { + final s = StringBuffer(); + + final fullName = mangledClassName(c); + + // global variable in C that holds the reference to class + final classVar = '${_classVarPrefix}_$fullName'; + s.write('// ${c.binaryName}\n'); + s.write('jclass $classVar = NULL;\n\n'); + + for (var m in c.methods) { + if (!m.isIncluded) { + continue; + } + s.write(_method(c, m)); + s.writeln(); + } + + for (var f in c.fields) { + if (!f.isIncluded) { + continue; + } + final fieldBinding = _field(c, f); + s.write(fieldBinding); + // Fields are skipped if they're static final. In that case + // do not write too much whitespace. + if (fieldBinding.isNotEmpty) s.writeln(); + } + return s.toString(); + } + + String _method(ClassDecl c, Method m) { + final cClassName = mangledClassName(c); + final isACtor = isCtor(m); + final isStatic = isStaticMethod(m); + + final s = StringBuffer(); + final name = m.finalName; + + final methodVar = '${_methodVarPrefix}_${cClassName}_$name'; + s.write('jmethodID $methodVar = NULL;\n'); + + final returnType = isCtor(m) ? 'jobject' : m.returnType.name; + final cReturnType = cType(returnType); + final cMethodName = '${cClassName}_$name'; + final cParams = _formalArgs(m); + s.write('FFI_PLUGIN_EXPORT\n'); + s.write('$cReturnType $cMethodName($cParams) {\n'); + + final classVar = '${_classVarPrefix}_$cClassName'; + final signature = _signature(m); + + s.write(_loadEnvCall); + s.write(_loadClassCall(classVar, _internalName(c.binaryName))); + + final ifStatic = isStatic ? 'static_' : ''; + s.write('${_indent}load_${ifStatic}method($classVar, ' + '&$methodVar, "${m.name}", "$signature");\n'); + + s.write(_initParams(m)); + + var returnTypeName = m.returnType.name; + if (isACtor) { + returnTypeName = c.binaryName; + } + + s.write(_indent); + if (returnTypeName != 'void') { + s.write('${cType(returnTypeName)} _result = '); + } + + final callType = _typeNameAtCallSite(m.returnType); + final callArgs = _callArgs(m, classVar, methodVar); + if (isACtor) { + s.write('(*jniEnv)->NewObject($callArgs);\n'); + } else { + final ifStatic = isStatic ? 'Static' : ''; + s.write('(*jniEnv)->Call$ifStatic${callType}Method($callArgs);\n'); + } + s.write(_destroyParams(m)); + if (returnTypeName != 'void') { + s.write(_result(m)); + } + s.write('}\n'); + return s.toString(); + } + + String _field(ClassDecl c, Field f) { + final cClassName = mangledClassName(c); + final isStatic = isStaticField(f); + + // If the field is final and default is assigned, then no need to wrap + // this field. It should then be a constant in dart code. + if (isStatic && isFinalField(f) && f.defaultValue != null) { + return ""; + } + + final s = StringBuffer(); + + final fieldName = f.finalName; + final fieldVar = "${_fieldVarPrefix}_${cClassName}_$fieldName"; + + s.write('jfieldID $fieldVar = NULL;\n'); + final classVar = '${_classVarPrefix}_$cClassName'; + + void writeAccessor({bool isSetter = false}) { + final ct = isSetter ? 'void' : cType(f.type.name); + // Getter + final prefix = isSetter ? 'set' : 'get'; + s.write('$ct ${prefix}_${memberNameInC(c, fieldName)}('); + final formalArgs = [ + if (!isStatic) 'jobject self_', + if (isSetter) '${cType(f.type.name)} value', + ]; + s.write(formalArgs.join(', ')); + s.write(') {\n'); + s.write(_loadEnvCall); + s.write(_loadClassCall(classVar, _internalName(c.binaryName))); + + var ifStatic = isStatic ? 'static_' : ''; + s.write( + '${_indent}load_${ifStatic}field($classVar, &$fieldVar, "$fieldName",' + '"${_fieldSignature(f)}");\n'); + + ifStatic = isStatic ? 'Static' : ''; + final callType = _typeNameAtCallSite(f.type); + final acc = isSetter ? 'Set' : 'Get'; + final ret = isSetter ? '' : 'return '; + final conv = !isSetter && !isPrimitive(f.type) ? 'to_global_ref' : ''; + s.write('$_indent$ret$conv((*jniEnv)->$acc$ifStatic${callType}Field'); + final secondArg = isStatic ? classVar : 'self_'; + s.write('(jniEnv, $secondArg, $fieldVar'); + if (isSetter) { + s.write(', value'); + } + s.write('));\n'); + // TODO(#25): Check Exceptions. + s.write('}\n\n'); + } + + writeAccessor(isSetter: false); + if (isFinalField(f)) { + return s.toString(); + } + writeAccessor(isSetter: true); + return s.toString(); + } + + final String _loadEnvCall = '${_indent}load_env();\n'; + + String _loadClassCall(String classVar, String internalName) { + return '${_indent}load_class_gr(&$classVar, ' + '"$internalName");\n'; + } + + String _formalArgs(Method m) { + final args = []; + if (hasSelfParam(m)) { + // The underscore-suffixed name prevents accidental collision with + // parameter named self, if any. + args.add('jobject self_'); + } + + for (var param in m.params) { + final paramName = _cParamRename(param.name); + args.add('${cType(param.type.name)} $paramName'); + } + + return args.join(", "); + } + + bool _needsTemporaries(String binaryName) { + // currently no type needs temporaries. + return false; + } + + // arguments at call site + String _callArgs(Method m, String classVar, String methodVar) { + final args = ['jniEnv']; + if (hasSelfParam(m)) { + args.add('self_'); + } else { + args.add(classVar); + } + args.add(methodVar); + for (var param in m.params) { + final paramName = _cParamRename(param.name); + if (_needsTemporaries(param.type.name)) { + args.add('_$paramName'); + } else { + args.add(paramName); + } + } + return args.join(', '); + } + + String _initParams(Method m) { + // currently no type needs temporaries, but in future we may add + // some options that require temporaries. + return ''; + } + + String _destroyParams(Method m) { + final s = StringBuffer(); + for (var param in m.params) { + final paramName = _cParamRename(param.name); + if (_needsTemporaries(param.type.name)) { + s.write('$_indent(*jniEnv)->DeleteLocalRef(jniEnv, _$paramName);\n'); + } + } + return s.toString(); + } + + String _result(Method m) { + final cReturnType = cType(m.returnType.name); + if (cReturnType == 'jobject' || isCtor(m)) { + return '${_indent}return to_global_ref(_result);\n'; + } else { + return '${_indent}return _result;\n'; + } + } + + String _fieldSignature(Field f) { + final iname = _internalNameOf(f.type); + if (iname.length == 1) { + return iname; + } + return 'L$iname;'; + } + + String _internalName(String binaryName) { + switch (binaryName) { + case "void": + return "V"; + case "byte": + return "B"; + case "char": + return "C"; + case "double": + return "D"; + case "float": + return "F"; + case "int": + return "I"; + case "long": + return "J"; + case "short": + return "S"; + case "boolean": + return "Z"; + default: + return binaryName.replaceAll(".", "/"); + } + } + + String _internalNameOf(TypeUsage usage) { + switch (usage.kind) { + case Kind.declared: + return _internalName((usage.type as DeclaredType).binaryName); + case Kind.primitive: + return _internalName((usage.type as PrimitiveType).name); + case Kind.typeVariable: + // It should be possible to compute the erasure of a type + // in parser itself. + // TODO(#23): Use erasure of the type variable here. + // This is just a (wrong) placeholder + return "java/lang/Object"; + case Kind.array: + final inner = _internalNameOf((usage.type as ArrayType).type); + return "[$inner"; + case Kind.wildcard: + final extendsBound = (usage.type as Wildcard).extendsBound; + if (extendsBound != null) { + return _internalNameOf(extendsBound); + } + return 'java/lang/Object'; + } + } + + /// Returns the JNI signature of the method. + String _signature(Method m) { + final s = StringBuffer(); + s.write('('); + for (var param in m.params) { + final type = _internalNameOf(param.type); + s.write(type.length == 1 ? type : 'L$type;'); + } + s.write(')'); + final returnType = _internalNameOf(m.returnType); + s.write(returnType.length == 1 ? returnType : 'L$returnType;'); + return s.toString(); + } + + // For callMethod or getfield calls in JNI. + String _typeNameAtCallSite(TypeUsage t) { + if (isPrimitive(t)) { + return t.name.substring(0, 1).toUpperCase() + t.name.substring(1); + } + return "Object"; + } +} + +class CPreludes { + static const autoGeneratedNotice = '// Autogenerated by jni_gen. ' + 'DO NOT EDIT!\n\n'; + static const includes = '#include \n' + '#include "jni.h"\n' + '#include "dartjni.h"\n' + '\n'; + static const defines = 'thread_local JNIEnv *jniEnv;\n' + 'struct jni_context jni;\n\n' + 'struct jni_context (*context_getter)(void);\n' + 'JNIEnv *(*env_getter)(void);\n' + '\n'; + static const initializers = + 'void setJniGetters(struct jni_context (*cg)(void),\n' + ' JNIEnv *(*eg)(void)) {\n' + ' context_getter = cg;\n' + ' env_getter = eg;\n' + '}\n' + '\n'; + static const prelude = + autoGeneratedNotice + includes + defines + initializers; +} diff --git a/pkgs/jni_gen/lib/src/bindings/common.dart b/pkgs/jni_gen/lib/src/bindings/common.dart new file mode 100644 index 000000000..dd46b6bdc --- /dev/null +++ b/pkgs/jni_gen/lib/src/bindings/common.dart @@ -0,0 +1,67 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +import 'package:jni_gen/src/elements/elements.dart'; + +String mangledClassName(ClassDecl decl) => + decl.binaryName.replaceAll('.', '_').replaceAll('\$', '__'); + +String memberNameInC(ClassDecl decl, String name) => + "${mangledClassName(decl)}_$name"; + +String cType(String binaryName) { + switch (binaryName) { + case "void": + return "void"; + case "byte": + return "int8_t"; + case "char": + return "char"; + case "double": + return "double"; + case "float": + return "float"; + case "int": + return "int32_t"; + case "long": + return "int64_t"; + case "short": + return "int16_t"; + case "boolean": + return "uint8_t"; + default: + return "jobject"; + } +} + +bool isPrimitive(TypeUsage t) => t.kind == Kind.primitive; + +bool isStaticField(Field f) => f.modifiers.contains('static'); +bool isStaticMethod(Method m) => m.modifiers.contains('static'); + +bool isFinalField(Field f) => f.modifiers.contains('final'); +bool isFinalMethod(Method m) => m.modifiers.contains('final'); + +bool isCtor(Method m) => m.name == ''; +bool hasSelfParam(Method m) => !isStaticMethod(m) && !isCtor(m); + +bool isObjectField(Field f) => !isPrimitive(f.type); +bool isObjectMethod(Method m) => !isPrimitive(m.returnType); + +const ctorNameC = 'new'; +const ctorNameDart = 'ctor'; + +// Marker exception when a method or class cannot be translated +// The inner functions may not know how much context has to be skipped in case +// of an error or unknown element. They throw SkipException. +class SkipException implements Exception { + SkipException(this.message, [this.element]); + String message; + dynamic element; + + @override + String toString() { + return '$message;'; + } +} diff --git a/pkgs/jni_gen/lib/src/bindings/dart_bindings.dart b/pkgs/jni_gen/lib/src/bindings/dart_bindings.dart new file mode 100644 index 000000000..b9944418d --- /dev/null +++ b/pkgs/jni_gen/lib/src/bindings/dart_bindings.dart @@ -0,0 +1,379 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +import 'dart:io'; + +import 'package:jni_gen/src/elements/elements.dart'; +import 'package:jni_gen/src/config/wrapper_options.dart'; +import 'package:jni_gen/src/util/rename_conflict.dart'; + +import 'symbol_resolver.dart'; +import 'common.dart'; + +final _indent = ' ' * 2; + +class DartBindingsGenerator { + // Name for reference in base class. + static const _self = 'reference'; + // symbol lookup function for generated code. + static const _jlookup = 'jlookup'; + + // import prefixes + static const ffi = 'ffi.'; + static const jni = 'jni.'; + + static const String _voidPtr = '${ffi}Pointer<${ffi}Void>'; + + static const String _void = '${ffi}Void'; + + static const String _jlObject = '${jni}JlObject'; + + DartBindingsGenerator(this.options, this.resolver); + WrapperOptions options; + SymbolResolver resolver; + + String generateBinding(ClassDecl decl) { + if (!decl.isPreprocessed) { + throw StateError('Java class declaration must be preprocessed before' + 'being passed to bindings generator'); + } + if (!decl.isIncluded) { + return ''; + } + return _class(decl); + } + + String _class(ClassDecl decl) { + final s = StringBuffer(); + + s.write('/// from: ${decl.binaryName}\n'); + s.write(_breakDocComment(decl.javadoc, depth: '')); + final name = _getSimpleName(decl.binaryName); + + var superName = _jlObject; + if (decl.superclass != null) { + superName = resolver + .resolve((decl.superclass!.type as DeclaredType).binaryName) ?? + _jlObject; + } + + s.write('class $name extends $superName {\n'); + s.write('$_indent$name.fromRef($_voidPtr ref) : ' + 'super.fromRef(ref);\n'); + + s.writeln(); + + for (var field in decl.fields) { + if (!field.isIncluded) { + continue; + } + try { + s.write(_field(decl, field)); + s.writeln(); + } on SkipException catch (e) { + stderr.writeln('skip field ${decl.binaryName}#${field.name}: ' + '${e.message}'); + } + } + + for (var method in decl.methods) { + if (!method.isIncluded) { + continue; + } + try { + s.write(_method(decl, method)); + s.writeln(); + } on SkipException catch (e) { + stderr.writeln('skip field ${decl.binaryName}#${method.name}: ' + '${e.message}'); + } + } + s.write("}\n"); + return s.toString(); + } + + static final _deleteInstruction = + '$_indent/// The returned object must be deleted after use, ' + 'by calling the `delete` method.\n'; + + String _method(ClassDecl c, Method m) { + final name = m.finalName; + final cName = memberNameInC(c, name); + final s = StringBuffer(); + final sym = '_$name'; + final ffiSig = dartSigForMethod(m, isFfiSig: true); + final dartSig = dartSigForMethod(m, isFfiSig: false); + s.write('${_indent}static final $sym = $_jlookup' + '<${ffi}NativeFunction<$ffiSig>>("$cName")\n' + '.asFunction<$dartSig>();\n'); + // Different logic for constructor and method; + // For constructor, we want return type to be new object. + final returnType = dartOuterType(m.returnType); + s.write('$_indent/// from: ${_originalMethodHeader(m)}\n'); + if (!isPrimitive(m.returnType)) { + s.write(_deleteInstruction); + } + s.write(_breakDocComment(m.javadoc)); + s.write(_indent); + + if (isStaticMethod(m)) { + s.write('static '); + } + + if (isCtor(m)) { + final wrapperExpr = '$sym(${_actualArgs(m)})'; + final className = _getSimpleName(c.binaryName); + final ctorFnName = name == 'ctor' ? className : '$className.$name'; + s.write('$ctorFnName(${_formalArgs(m)}) : ' + 'super.fromRef($wrapperExpr);\n'); + return s.toString(); + } + + var wrapperExpr = '$sym(${_actualArgs(m)})'; + wrapperExpr = _toDartResult(wrapperExpr, m.returnType, returnType); + s.write('$returnType $name(${_formalArgs(m)}) ' + '=> $wrapperExpr;\n'); + + return s.toString(); + } + + String _formalArgs(Method m) { + final List args = []; + for (var param in m.params) { + args.add('${dartOuterType(param.type)} ${kwRename(param.name)}'); + } + return args.join(', '); + } + + String _actualArgs(Method m) { + final List args = [if (hasSelfParam(m)) _self]; + for (var param in m.params) { + final paramName = kwRename(param.name); + args.add(_toCArg(paramName, param.type)); + } + return args.join(', '); + } + + String _field(ClassDecl c, Field f) { + final name = f.finalName; + final s = StringBuffer(); + + void _writeDocs({bool writeDeleteInstruction = true}) { + s.write('$_indent/// from: ${_originalFieldDecl(f)}\n'); + if (!isPrimitive(f.type) && writeDeleteInstruction) { + s.write(_deleteInstruction); + } + s.write(_breakDocComment(f.javadoc)); + } + + if (isStaticField(f) && isFinalField(f) && f.defaultValue != null) { + _writeDocs(writeDeleteInstruction: false); + s.write('${_indent}static const $name = ${_literal(f.defaultValue)};\n'); + return s.toString(); + } + final cName = memberNameInC(c, name); + + void writeAccessor({bool isSetter = false}) { + final symPrefix = isSetter ? 'set' : 'get'; + final sym = '_$symPrefix$name'; + final ffiSig = dartSigForField(f, isSetter: isSetter, isFfiSig: true); + final dartSig = dartSigForField(f, isSetter: isSetter, isFfiSig: false); + s.write('${_indent}static final $sym = $_jlookup' + '<${ffi}NativeFunction<$ffiSig>>("${symPrefix}_$cName")\n' + '.asFunction<$dartSig>();\n'); + // write original type + _writeDocs(); + s.write(_indent); + if (isStaticField(f)) s.write('static '); + if (isSetter) { + s.write('set $name(${dartOuterType(f.type)} value) => $sym('); + if (!isStaticField(f)) { + s.write('$_self, '); + } + s.write(_toCArg('value', f.type)); + s.write(');\n'); + } else { + // getter + final self = isStaticField(f) ? '' : _self; + final outer = dartOuterType(f.type); + final callExpr = '$sym($self)'; + final resultExpr = _toDartResult(callExpr, f.type, outer); + s.write('$outer get $name => $resultExpr;\n'); + } + } + + writeAccessor(isSetter: false); + if (!isFinalField(f)) writeAccessor(isSetter: true); + return s.toString(); + } + + String _getSimpleName(String binaryName) { + final components = binaryName.split("."); + return components.last.replaceAll("\$", "_"); + } + + String dartSigForField(Field f, + {bool isSetter = false, required bool isFfiSig}) { + final conv = isFfiSig ? dartFfiType : dartInnerType; + final voidType = isFfiSig ? _void : 'void'; + final ref = f.modifiers.contains('static') ? '' : '$_voidPtr, '; + if (isSetter) { + return '$voidType Function($ref${conv(f.type)})'; + } + return '${conv(f.type)} Function($ref)'; + } + + String dartSigForMethod(Method m, {required bool isFfiSig}) { + final conv = isFfiSig ? dartFfiType : dartInnerType; + final argTypes = [if (hasSelfParam(m)) _voidPtr]; + for (var param in m.params) { + argTypes.add(conv(param.type)); + } + final retType = isCtor(m) ? _voidPtr : conv(m.returnType); + return '$retType Function (${argTypes.join(", ")})'; + } + + // Type for FFI Function signature + String dartFfiType(TypeUsage t) { + const primitives = { + 'byte': 'Int8', + 'short': 'Int16', + 'char': 'Int16', + 'int': 'Int32', + 'long': 'Int64', + 'float': 'Float', + 'double': 'Double', + 'void': 'Void', + 'boolean': 'Uint8', + }; + switch (t.kind) { + case Kind.primitive: + return ffi + primitives[(t.type as PrimitiveType).name]!; + case Kind.typeVariable: + case Kind.wildcard: + throw SkipException( + 'Generic type parameters are not supported', t.toJson()); + case Kind.array: + case Kind.declared: + return _voidPtr; + } + } + + String _dartType(TypeUsage t, {SymbolResolver? resolver}) { + // if resolver == null, looking for inner fn type, type of fn reference + // else looking for outer fn type, that's what user of the library sees. + const primitives = { + 'byte': 'int', + 'short': 'int', + 'char': 'int', + 'int': 'int', + 'long': 'int', + 'float': 'double', + 'double': 'double', + 'void': 'void', + 'boolean': 'bool', + }; + switch (t.kind) { + case Kind.primitive: + if (t.name == 'boolean' && resolver == null) return 'int'; + return primitives[(t.type as PrimitiveType).name]!; + case Kind.typeVariable: + case Kind.wildcard: + throw SkipException('Not supported: generics'); + case Kind.array: + if (resolver != null) { + return _jlObject; + } + return _voidPtr; + case Kind.declared: + if (resolver != null) { + return resolver.resolve((t.type as DeclaredType).binaryName) ?? + _jlObject; + } + return _voidPtr; + } + } + + String dartInnerType(TypeUsage t) => _dartType(t); + String dartOuterType(TypeUsage t) => _dartType(t, resolver: resolver); + + String _literal(dynamic value) { + if (value is String) { + return '"$value"'; + } + if (value is int || value is double || value is bool) { + return value.toString(); + } + throw SkipException('Not a constant of a known type.'); + } + + String _originalFieldDecl(Field f) { + final declStmt = '${f.type.shorthand} ${f.name}'; + return [...f.modifiers, declStmt].join(' '); + } + + String _originalMethodHeader(Method m) { + final args = []; + for (var p in m.params) { + args.add('${p.type.shorthand} ${p.name}'); + } + final declStmt = '${m.returnType.shorthand} ${m.name}' + '(${args.join(', ')})'; + return [...m.modifiers, declStmt].join(' '); + } + + String _toCArg(String name, TypeUsage type) { + if (isPrimitive(type)) { + return type.name == 'boolean' ? '$name ? 1 : 0' : name; + } + return '$name.$_self'; + } + + String _toDartResult(String expr, TypeUsage type, String dartType) { + if (isPrimitive(type)) { + return type.name == 'boolean' ? '$expr != 0' : expr; + } + return '$dartType.fromRef($expr)'; + } + + static String _breakDocComment(JavaDocComment? javadoc, + {String depth = ' '}) { + final link = RegExp('{@link ([^{}]+)}'); + if (javadoc == null) return ''; + final comment = javadoc.comment + .replaceAllMapped(link, (match) => match.group(1) ?? '') + .replaceAll('#', '\\#') + .replaceAll('

', '') + .replaceAll('

', '\n') + .replaceAll('', '__') + .replaceAll('', '__') + .replaceAll('', '_') + .replaceAll('', '_'); + return '$depth///\n' + '$depth/// ${comment.replaceAll('\n', '\n$depth///')}\n'; + } +} + +class DartPreludes { + static String initFile(String libraryName) => 'import "dart:ffi";\n' + 'import "package:jni/jni.dart";\n' + '\n' + 'final Pointer Function(String sym) ' + 'jlookup = Jni.getInstance().initGeneratedLibrary("$libraryName");\n' + '\n'; + static const autoGeneratedNotice = '// Autogenerated by jni_gen. ' + 'DO NOT EDIT!\n\n'; + static const defaultImports = 'import "dart:ffi" as ffi;\n\n' + 'import "package:jni/jni.dart" as jni;\n\n'; + static const defaultLintSuppressions = + '// ignore_for_file: camel_case_types\n' + '// ignore_for_file: non_constant_identifier_names\n' + '// ignore_for_file: constant_identifier_names\n' + '// ignore_for_file: annotate_overrides\n' + '// ignore_for_file: no_leading_underscores_for_local_identifiers\n' + '// ignore_for_file: unused_element\n' + '\n'; + static const bindingFileHeaders = + autoGeneratedNotice + defaultLintSuppressions + defaultImports; +} diff --git a/pkgs/jni_gen/lib/src/bindings/preprocessor.dart b/pkgs/jni_gen/lib/src/bindings/preprocessor.dart new file mode 100644 index 000000000..6fd1ee3d9 --- /dev/null +++ b/pkgs/jni_gen/lib/src/bindings/preprocessor.dart @@ -0,0 +1,90 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +import 'dart:io'; + +import 'package:jni_gen/src/elements/elements.dart'; +import 'package:jni_gen/src/config/wrapper_options.dart'; +import 'package:jni_gen/src/util/rename_conflict.dart'; +import 'common.dart'; + +/// Preprocessor which fills information needed by both Dart and C generators. +class ApiPreprocessor { + ApiPreprocessor(this.classes, this.options); + final Map classes; + final WrapperOptions options; + + void preprocessAll() { + for (var c in classes.values) { + _preprocess(c); + } + } + + void _preprocess(ClassDecl decl) { + if (decl.isPreprocessed) return; + if (!_isClassIncluded(decl)) { + decl.isIncluded = false; + stdout.writeln('exclude class ${decl.binaryName}'); + decl.isPreprocessed = true; + return; + } + ClassDecl? superclass; + if (decl.superclass != null && classes.containsKey(decl.superclass?.name)) { + superclass = classes[decl.superclass!.name]!; + _preprocess(superclass); + // again, un-consider superclass if it was excluded through config + if (!superclass.isIncluded) { + superclass = null; + } else { + decl.nameCounts.addAll(superclass.nameCounts); + } + } + + for (var field in decl.fields) { + if (!_isFieldIncluded(decl, field)) { + field.isIncluded = false; + stderr.writeln('exclude ${decl.binaryName}#${field.name}'); + continue; + } + field.finalName = renameConflict(decl.nameCounts, field.name); + } + + for (var method in decl.methods) { + if (!_isMethodIncluded(decl, method)) { + method.isIncluded = false; + stderr.writeln('exclude method ${decl.binaryName}#${method.name}'); + continue; + } + var realName = method.name; + if (isCtor(method)) { + realName = 'ctor'; + } + final sig = method.javaSig; + // if method already in super class, assign its number, overriding it. + final superNum = superclass?.methodNumsAfterRenaming[sig]; + if (superNum != null) { + // don't rename if superNum == 0 + final superNumText = superNum == 0 ? '' : '$superNum'; + // well, unless the method name is a keyword & superNum == 0. + // TODO(#29): this logic would better live in a dedicated renamer class. + final methodName = superNum == 0 ? kwRename(realName) : realName; + method.finalName = '$methodName$superNumText'; + decl.methodNumsAfterRenaming[sig] = superNum; + } else { + method.finalName = renameConflict(decl.nameCounts, realName); + // TODO(#29): This is too much coupled with renameConflict impl. + // see the above todo. + decl.methodNumsAfterRenaming[sig] = decl.nameCounts[realName]! - 1; + } + } + decl.isPreprocessed = true; + } + + bool _isFieldIncluded(ClassDecl decl, Field field) => + options.fieldFilter?.included(decl, field) != false; + bool _isMethodIncluded(ClassDecl decl, Method method) => + options.methodFilter?.included(decl, method) != false; + bool _isClassIncluded(ClassDecl decl) => + options.classFilter?.included(decl) != false; +} diff --git a/pkgs/jni_gen/lib/src/bindings/symbol_resolver.dart b/pkgs/jni_gen/lib/src/bindings/symbol_resolver.dart new file mode 100644 index 000000000..bfaaab4e3 --- /dev/null +++ b/pkgs/jni_gen/lib/src/bindings/symbol_resolver.dart @@ -0,0 +1,136 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +// A symbol resolver is useful mainly to convert a fully qualified name to +// a locally meaningful name, when creating dart bindings + +import 'dart:math'; +import 'package:jni_gen/src/util/name_utils.dart'; + +abstract class SymbolResolver { + /// Resolve the binary name to a String which can be used in dart code. + String? resolve(String binaryName); + List getImportStrings(); +} + +// TODO(#24): resolve all included classes without requiring import mappings. + +class PackagePathResolver implements SymbolResolver { + PackagePathResolver(this.packages, this.currentPackage, this.inputClassNames, + {this.predefined = const {}}); + + final String currentPackage; + final Map packages; + final Map predefined; + final Set inputClassNames; + + final List importStrings = []; + + final Map _importedNameToPackage = {}; + final Map _packageToImportedName = {}; + + // return null if type's package cannot be resolved + // else return the fully qualified name of type + @override + String? resolve(String binaryName) { + if (predefined.containsKey(binaryName)) { + return predefined[binaryName]; + } + final parts = cutFromLast(binaryName, '.'); + final package = parts[0]; + final typename = parts[1]; + final simpleTypeName = typename.replaceAll('\$', '_'); + + if (package == currentPackage && inputClassNames.contains(binaryName)) { + return simpleTypeName; + } + + if (_packageToImportedName.containsKey(package)) { + // This package was already resolved + final importedName = _packageToImportedName[package]; + return '$importedName.$simpleTypeName'; + } + + final packageImport = getImport(package, binaryName); + if (packageImport == null) { + return null; + } + + final pkgName = cutFromLast(package, '.')[1]; + if (pkgName.isEmpty) { + throw UnsupportedError('No package could be deduced from ' + 'qualified binaryName'); + } + + var importedName = '${pkgName}_'; + int suffix = 0; + while (_importedNameToPackage.containsKey(importedName)) { + suffix++; + importedName = '$pkgName${suffix}_'; + } + + _importedNameToPackage[importedName] = package; + _packageToImportedName[package] = importedName; + importStrings.add('import "$packageImport" as $importedName;\n'); + return '$importedName.$simpleTypeName'; + } + + /// Returns import string, or `null` if package not found. + String? getImport(String packageToResolve, String binaryName) { + final right = []; + var prefix = packageToResolve; + + if (prefix.isEmpty) { + throw UnsupportedError('unexpected: empty package name.'); + } + + final dest = packageToResolve.split('.'); + final src = currentPackage.split('.'); + if (inputClassNames.contains(binaryName)) { + int common = 0; + for (int i = 0; i < src.length && i < dest.length; i++) { + if (src[i] == dest[i]) { + common++; + } + } + // a.b.c => a/b/c.dart + // from there + // a/b.dart => ../b.dart + // a.b.d => d.dart + // a.b.c.d => c/d.dart + var pathToCommon = ''; + if (common < src.length) { + pathToCommon = '../' * (src.length - common); + } + final pathToPackage = dest.skip(max(common - 1, 0)).join('/'); + return '$pathToCommon$pathToPackage.dart'; + } + + while (prefix.isNotEmpty) { + final split = cutFromLast(prefix, '.'); + final left = split[0]; + right.add(split[1]); + // eg: packages[org.apache.pdfbox]/org/apache/pdfbox.dart + if (packages.containsKey(prefix)) { + final sub = packageToResolve.replaceAll('.', '/'); + final pkg = _suffix(packages[prefix]!, '/'); + return '$pkg$sub.dart'; + } + prefix = left; + } + return null; + } + + String _suffix(String str, String suffix) { + if (str.endsWith(suffix)) { + return str; + } + return str + suffix; + } + + @override + List getImportStrings() { + return importStrings; + } +} diff --git a/pkgs/jni_gen/lib/src/config/config.dart b/pkgs/jni_gen/lib/src/config/config.dart new file mode 100644 index 000000000..03ce6f2b5 --- /dev/null +++ b/pkgs/jni_gen/lib/src/config/config.dart @@ -0,0 +1,8 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +export 'summary_source.dart'; +export 'task.dart'; +export 'wrapper_options.dart'; +export 'errors.dart'; diff --git a/pkgs/jni_gen/lib/src/config/errors.dart b/pkgs/jni_gen/lib/src/config/errors.dart new file mode 100644 index 000000000..516e8f8bf --- /dev/null +++ b/pkgs/jni_gen/lib/src/config/errors.dart @@ -0,0 +1,6 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +/// Base class for all unexpected errors in JniGen (Except Skip) +abstract class JniGenException implements Exception {} diff --git a/pkgs/jni_gen/lib/src/config/summary_source.dart b/pkgs/jni_gen/lib/src/config/summary_source.dart new file mode 100644 index 000000000..622c36b73 --- /dev/null +++ b/pkgs/jni_gen/lib/src/config/summary_source.dart @@ -0,0 +1,87 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +import 'dart:io'; +import 'package:jni_gen/src/util/command_output.dart'; + +abstract class SummarySource { + Future>> getInputStream(); +} + +/// 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 +/// names of classes or packages included in the generated summary. when a +/// package is specified, its contents are included recursively. +/// +/// When the default summarizer scans the [sourcePaths], it assumes that +/// the directory names reflect actual package paths. For example, a class name +/// com.example.pkg.Cls will be mapped to com/example/pkg/Cls.java. +/// +/// The default summarizer needs to be built with `jni_gen:setup` +/// script before this API is used. +class SummarizerCommand extends SummarySource { + SummarizerCommand({ + this.command = "java -jar .dart_tool/jni_gen/ApiSummarizer.jar", + required this.sourcePaths, + this.classPaths = const [], + this.extraArgs = const [], + required this.classes, + this.workingDirectory, + }); + + static const sourcePathsOption = '-s'; + static const classPathsOption = '-c'; + + String command; + List sourcePaths, classPaths; + List extraArgs; + List classes; + + Uri? workingDirectory; + + void _addPathParam(List args, String option, List paths) { + if (paths.isNotEmpty) { + final joined = paths + .map((uri) => uri.toFilePath()) + .join(Platform.isWindows ? ';' : ':'); + if (option.endsWith("=")) { + args.add(option + joined); + } else { + args.addAll([option, joined]); + } + } + } + + @override + Future>> getInputStream() async { + final commandSplit = command.split(" "); + final exec = commandSplit[0]; + final List args = commandSplit.sublist(1); + + _addPathParam(args, sourcePathsOption, sourcePaths); + _addPathParam(args, classPathsOption, classPaths); + args.addAll(extraArgs); + args.addAll(classes); + + stderr.writeln('[exec] $exec ${args.join(' ')}'); + final proc = await Process.start(exec, args, + workingDirectory: workingDirectory?.toFilePath() ?? '.'); + prefixedCommandOutputStream('[ApiSummarizer]', proc.stderr) + .forEach(stderr.writeln); + return proc.stdout; + } +} + +/// A JSON file based summary source. +// (Did not test it yet) +class SummaryFile extends SummarySource { + Uri path; + SummaryFile(this.path); + SummaryFile.fromPath(String path) : path = Uri.file(path); + + @override + Future>> getInputStream() async => + File.fromUri(path).openRead(); +} diff --git a/pkgs/jni_gen/lib/src/config/task.dart b/pkgs/jni_gen/lib/src/config/task.dart new file mode 100644 index 000000000..a5e015ddf --- /dev/null +++ b/pkgs/jni_gen/lib/src/config/task.dart @@ -0,0 +1,59 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +import 'dart:io'; +import 'dart:convert'; + +import 'package:jni_gen/src/writers/bindings_writer.dart'; +import 'package:jni_gen/src/config/config.dart'; +import 'package:jni_gen/src/elements/elements.dart'; + +/// Represents a complete jni_gen binding generation configuration. +/// * [summarySource] handles the API summary generation. +/// * [options] specify any semantic options regarding generated code. +/// * [outputWriter] handles the output configuration. +class JniGenTask { + JniGenTask({ + required this.summarySource, + this.options = const WrapperOptions(), + required this.outputWriter, + }); + BindingsWriter outputWriter; + SummarySource summarySource; + WrapperOptions options; + + // execute this task + Future run({bool dumpJson = false}) async { + Stream> input; + try { + input = await summarySource.getInputStream(); + } on Exception catch (e) { + stderr.writeln('error obtaining API summary: $e'); + return; + } + final stream = JsonDecoder().bind(Utf8Decoder().bind(input)); + dynamic json; + try { + json = await stream.single; + } on Exception catch (e) { + stderr.writeln('error while parsing summary: $e'); + return; + } + if (json == null) { + stderr.writeln('error: expected JSON element from summarizer.'); + return; + } + if (dumpJson) { + stderr.writeln(json); + } + final list = json as List; + try { + await outputWriter.writeBindings( + list.map((c) => ClassDecl.fromJson(c)), options); + } on Exception catch (e, trace) { + stderr.writeln(trace); + stderr.writeln('error writing bindings: $e'); + } + } +} diff --git a/pkgs/jni_gen/lib/src/config/wrapper_options.dart b/pkgs/jni_gen/lib/src/config/wrapper_options.dart new file mode 100644 index 000000000..7f1101da8 --- /dev/null +++ b/pkgs/jni_gen/lib/src/config/wrapper_options.dart @@ -0,0 +1,148 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +import 'package:jni_gen/src/elements/elements.dart'; + +/// A filter which tells if bindings for given [ClassDecl] are generated. +abstract class ClassFilter { + bool included(ClassDecl decl); +} + +/// This filter includes the declarations for which [predicate] returns true. +class CustomClassFilter implements ClassFilter { + CustomClassFilter(this.predicate); + final bool Function(ClassDecl) predicate; + @override + bool included(ClassDecl decl) { + return predicate(decl); + } +} + +bool _matchesCompletely(String string, Pattern pattern) { + final match = pattern.matchAsPrefix(string); + return match != null && match.group(0) == string; +} + +/// Filter to include / exclude classes by matching on the binary name. +/// A binary name is like qualified name but with a `$` used to indicate nested +/// class instead of `.`, guaranteeing a unique name. +class ClassNameFilter implements ClassFilter { + ClassNameFilter.include(this.pattern) : onMatch = true; + ClassNameFilter.exclude(this.pattern) : onMatch = false; + final bool onMatch; + final Pattern pattern; + @override + bool included(ClassDecl decl) { + if (_matchesCompletely(decl.binaryName, pattern)) { + return onMatch; + } + return !onMatch; + } +} + +abstract class MemberFilter { + bool included(ClassDecl classDecl, T member); +} + +class MemberNameFilter implements MemberFilter { + MemberNameFilter.include(this.classPattern, this.namePattern) + : onMatch = true; + MemberNameFilter.exclude(this.classPattern, this.namePattern) + : onMatch = false; + final bool onMatch; + final Pattern classPattern, namePattern; + @override + bool included(ClassDecl classDecl, T member) { + final matches = _matchesCompletely(classDecl.binaryName, classPattern) && + _matchesCompletely(member.name, namePattern); + return matches ? onMatch : !onMatch; + } +} + +class CustomMemberFilter implements MemberFilter { + CustomMemberFilter(this.predicate); + bool Function(ClassDecl, T) predicate; + @override + bool included(ClassDecl classDecl, T member) => predicate(classDecl, member); +} + +class CombinedClassFilter implements ClassFilter { + CombinedClassFilter.all(this.filters); + final List filters; + @override + bool included(ClassDecl decl) => filters.every((f) => f.included(decl)); +} + +class CombinedMemberFilter implements MemberFilter { + CombinedMemberFilter(this.filters); + + final List> filters; + + @override + bool included(ClassDecl decl, T member) { + return filters.every((f) => f.included(decl, member)); + } +} + +typedef FieldFilter = MemberFilter; +typedef MethodFilter = MemberFilter; + +/// Filter using binary name of the class and name of the field. +typedef FieldNameFilter = MemberNameFilter; + +/// Filter using binary name of the class and name of the method. +typedef MethodNameFilter = MemberNameFilter; + +/// Predicate based filter for field, which can access class declaration +/// and the field. +typedef CustomFieldFilter = CustomMemberFilter; + +/// Predicate based filter for method, which can access class declaration +/// and the method. +typedef CustomMethodFilter = CustomMemberFilter; + +/// This filter excludes fields if any one of sub-filters returns false. +typedef CombinedFieldFilter = CombinedMemberFilter; + +/// This filter excludes methods if any one of sub-filters returns false. +typedef CombinedMethodFilter = CombinedMemberFilter; + +MemberFilter excludeAll(List> names) { + return CombinedMemberFilter( + names.map((p) => MemberNameFilter.exclude(p[0], p[1])).toList()); +} + +/// Options that affect the semantics of the generated code. +class WrapperOptions { + const WrapperOptions({ + this.classFilter, + this.fieldFilter, + this.methodFilter, + this.classTransformer, + this.methodTransformer, + this.fieldTransformer, + this.importPaths = const {}, + }); + + /// Mapping from java package names to dart packages. + /// A mapping `a.b` -> `package:a_b/' means that + /// any import `a.b.C` will be resolved as `package:a_b/a/b.dart` in dart. + /// Note that dart bindings use the same hierarchy as the java packages. + final Map importPaths; + + /// [ClassFilter] to decide if bindings for a class should be generated. + final ClassFilter? classFilter; + + /// [FieldFilter] to decide if bindings for a field should be generated. + final FieldFilter? fieldFilter; + + /// [MethodFilter] to decide if bindings for a method should be generated. + final MethodFilter? methodFilter; + + // TODO(#26): This allows us to implement flexible renaming and more customization + // via the dart API. + final ClassDecl? Function(ClassDecl decl)? classTransformer; + final Method? Function(Method method)? methodTransformer; + final Field? Function(Field field)? fieldTransformer; +} diff --git a/pkgs/jni_gen/lib/src/elements/elements.dart b/pkgs/jni_gen/lib/src/elements/elements.dart new file mode 100644 index 000000000..2673a4b44 --- /dev/null +++ b/pkgs/jni_gen/lib/src/elements/elements.dart @@ -0,0 +1,363 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +// Types to describe java API elements + +import 'package:json_annotation/json_annotation.dart'; + +part 'elements.g.dart'; + +@JsonEnum() + +/// A kind describes the type of a declaration. +enum DeclKind { + @JsonValue('CLASS') + classKind, + @JsonValue('INTERFACE') + interfaceKind, + @JsonValue('ENUM') + enumKind, +} + +// Note: We give default values in constructor, if the field is nullable in +// JSON. this allows us to reduce JSON size by providing Include.NON_NULL +// option in java. + +@JsonSerializable(explicitToJson: true) +class ClassDecl { + /// Methods & properties already defined by dart JlObject base class. + static const Map _definedSyms = { + 'equals': 1, + 'toString': 1, + 'hashCode': 1, + 'runtimeType': 1, + 'noSuchMethod': 1, + 'reference': 1, + 'delete': 1, + }; + + ClassDecl({ + this.annotations = const [], + this.javadoc, + this.modifiers = const {}, + required this.simpleName, + required this.binaryName, + this.parentName, + this.packageName, + this.typeParams = const [], + this.methods = const [], + this.fields = const [], + this.superclass, + this.interfaces = const [], + this.hasStaticInit = false, + this.hasInstanceInit = false, + this.values, + }); + + List annotations; + JavaDocComment? javadoc; + + Set modifiers; + String simpleName, binaryName; + String? parentName, packageName; + List typeParams; + List methods; + List fields; + TypeUsage? superclass; + List interfaces; + bool hasStaticInit, hasInstanceInit; + + // Contains enum constant names if class is an enum, + // as obtained by `.values()` method in Java. + List? values; + + factory ClassDecl.fromJson(Map json) => + _$ClassDeclFromJson(json); + Map toJson() => _$ClassDeclToJson(this); + + // synthesized attributes + @JsonKey(ignore: true) + late String finalName; + + @JsonKey(ignore: true) + bool isPreprocessed = false; + @JsonKey(ignore: true) + bool isIncluded = true; + + /// Contains number with which certain overload of a method is renamed to, + /// so the overriding method in subclass can be renamed to same final name. + @JsonKey(ignore: true) + Map methodNumsAfterRenaming = {}; + + /// Name counts map, it's a field so that it can be later used by subclasses. + @JsonKey(ignore: true) + Map nameCounts = {..._definedSyms}; + + @override + String toString() { + return 'Java class declaration for $binaryName'; + } +} + +@JsonEnum() +enum Kind { + @JsonValue('PRIMITIVE') + primitive, + @JsonValue('TYPE_VARIABLE') + typeVariable, + @JsonValue('WILDCARD') + wildcard, + @JsonValue('DECLARED') + declared, + @JsonValue('ARRAY') + array, +} + +@JsonSerializable(explicitToJson: true) +class TypeUsage { + TypeUsage({ + required this.shorthand, + required this.kind, + required this.typeJson, + }); + + String shorthand; + Kind kind; + @JsonKey(ignore: true) + late ReferredType type; + @JsonKey(name: "type") + Map typeJson; + + String get name => type.name; + + // Since json_serializable doesn't directly support union types, + // we have to temporarily store `type` in a JSON map, and switch on the + // enum value received. + factory TypeUsage.fromJson(Map json) { + final t = _$TypeUsageFromJson(json); + switch (t.kind) { + case Kind.primitive: + t.type = PrimitiveType.fromJson(t.typeJson); + break; + case Kind.typeVariable: + t.type = TypeVar.fromJson(t.typeJson); + break; + case Kind.wildcard: + t.type = Wildcard.fromJson(t.typeJson); + break; + case Kind.declared: + t.type = DeclaredType.fromJson(t.typeJson); + break; + case Kind.array: + t.type = ArrayType.fromJson(t.typeJson); + break; + } + return t; + } + Map toJson() => _$TypeUsageToJson(this); +} + +abstract class ReferredType { + String get name; +} + +@JsonSerializable(explicitToJson: true) +class PrimitiveType implements ReferredType { + PrimitiveType({required this.name}); + + @override + String name; + + factory PrimitiveType.fromJson(Map json) => + _$PrimitiveTypeFromJson(json); + Map toJson() => _$PrimitiveTypeToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class DeclaredType implements ReferredType { + DeclaredType({ + required this.binaryName, + required this.simpleName, + this.params = const [], + }); + String binaryName, simpleName; + List params; + + @override + String get name => binaryName; + + factory DeclaredType.fromJson(Map json) => + _$DeclaredTypeFromJson(json); + Map toJson() => _$DeclaredTypeToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class TypeVar implements ReferredType { + TypeVar({required this.name}); + @override + String name; + + factory TypeVar.fromJson(Map json) => + _$TypeVarFromJson(json); + Map toJson() => _$TypeVarToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class Wildcard implements ReferredType { + Wildcard({this.extendsBound, this.superBound}); + TypeUsage? extendsBound, superBound; + + @override + String get name => "?"; + + factory Wildcard.fromJson(Map json) => + _$WildcardFromJson(json); + Map toJson() => _$WildcardToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class ArrayType implements ReferredType { + ArrayType({required this.type}); + TypeUsage type; + + @override + String get name => "[${type.name}"; + + factory ArrayType.fromJson(Map json) => + _$ArrayTypeFromJson(json); + Map toJson() => _$ArrayTypeToJson(this); +} + +abstract class ClassMember { + String get name; +} + +@JsonSerializable(explicitToJson: true) +class Method implements ClassMember { + Method( + {this.annotations = const [], + this.javadoc, + this.modifiers = const {}, + required this.name, + this.typeParams = const [], + this.params = const [], + required this.returnType}); + List annotations; + JavaDocComment? javadoc; + Set modifiers; + + @override + String name; + + List typeParams; + List params; + TypeUsage returnType; + + @JsonKey(ignore: true) + late String finalName; + @JsonKey(ignore: true) + late bool isOverridden; + @JsonKey(ignore: true) + bool isIncluded = true; + + @JsonKey(ignore: true) + late String javaSig = _javaSig(); + + String _javaSig() { + final paramNames = params.map((p) => p.type.name).join(', '); + return '${returnType.name} $name($paramNames)'; + } + + factory Method.fromJson(Map json) => _$MethodFromJson(json); + Map toJson() => _$MethodToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class Param { + Param( + {this.annotations = const [], + this.javadoc, + required this.name, + required this.type}); + List annotations; + JavaDocComment? javadoc; + + String name; + TypeUsage type; + + factory Param.fromJson(Map json) => _$ParamFromJson(json); + Map toJson() => _$ParamToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class Field implements ClassMember { + Field( + {this.annotations = const [], + this.javadoc, + this.modifiers = const {}, + required this.name, + required this.type, + this.defaultValue}); + + List annotations; + JavaDocComment? javadoc; + + Set modifiers; + + @override + String name; + + TypeUsage type; + Object? defaultValue; + + @JsonKey(ignore: true) + late String finalName; + @JsonKey(ignore: true) + bool isIncluded = true; + + factory Field.fromJson(Map json) => _$FieldFromJson(json); + Map toJson() => _$FieldToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class TypeParam { + TypeParam({required this.name, this.bounds = const []}); + String name; + List bounds; + + @JsonKey(ignore: true) + late String erasure; + + factory TypeParam.fromJson(Map json) => + _$TypeParamFromJson(json); + Map toJson() => _$TypeParamToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class JavaDocComment { + JavaDocComment({String? comment}) : comment = comment ?? ''; + String comment; + + @JsonKey(ignore: true) + late String dartDoc; + + factory JavaDocComment.fromJson(Map json) => + _$JavaDocCommentFromJson(json); + Map toJson() => _$JavaDocCommentToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class Annotation { + Annotation( + {required this.simpleName, + required this.binaryName, + this.properties = const {}}); + String simpleName; + String binaryName; + Map properties; + + factory Annotation.fromJson(Map json) => + _$AnnotationFromJson(json); + Map toJson() => _$AnnotationToJson(this); +} diff --git a/pkgs/jni_gen/lib/src/elements/elements.g.dart b/pkgs/jni_gen/lib/src/elements/elements.g.dart new file mode 100644 index 000000000..95944de1e --- /dev/null +++ b/pkgs/jni_gen/lib/src/elements/elements.g.dart @@ -0,0 +1,261 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'elements.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +ClassDecl _$ClassDeclFromJson(Map json) => ClassDecl( + annotations: (json['annotations'] as List?) + ?.map((e) => Annotation.fromJson(e as Map)) + .toList() ?? + const [], + javadoc: json['javadoc'] == null + ? null + : JavaDocComment.fromJson(json['javadoc'] as Map), + modifiers: (json['modifiers'] as List?) + ?.map((e) => e as String) + .toSet() ?? + const {}, + simpleName: json['simpleName'] as String, + binaryName: json['binaryName'] as String, + parentName: json['parentName'] as String?, + packageName: json['packageName'] as String?, + typeParams: (json['typeParams'] as List?) + ?.map((e) => TypeParam.fromJson(e as Map)) + .toList() ?? + const [], + methods: (json['methods'] as List?) + ?.map((e) => Method.fromJson(e as Map)) + .toList() ?? + const [], + fields: (json['fields'] as List?) + ?.map((e) => Field.fromJson(e as Map)) + .toList() ?? + const [], + superclass: json['superclass'] == null + ? null + : TypeUsage.fromJson(json['superclass'] as Map), + interfaces: (json['interfaces'] as List?) + ?.map((e) => TypeUsage.fromJson(e as Map)) + .toList() ?? + const [], + hasStaticInit: json['hasStaticInit'] as bool? ?? false, + hasInstanceInit: json['hasInstanceInit'] as bool? ?? false, + values: + (json['values'] as List?)?.map((e) => e as String).toList(), + ); + +Map _$ClassDeclToJson(ClassDecl instance) => { + 'annotations': instance.annotations.map((e) => e.toJson()).toList(), + 'javadoc': instance.javadoc?.toJson(), + 'modifiers': instance.modifiers.toList(), + 'simpleName': instance.simpleName, + 'binaryName': instance.binaryName, + 'parentName': instance.parentName, + 'packageName': instance.packageName, + 'typeParams': instance.typeParams.map((e) => e.toJson()).toList(), + 'methods': instance.methods.map((e) => e.toJson()).toList(), + 'fields': instance.fields.map((e) => e.toJson()).toList(), + 'superclass': instance.superclass?.toJson(), + 'interfaces': instance.interfaces.map((e) => e.toJson()).toList(), + 'hasStaticInit': instance.hasStaticInit, + 'hasInstanceInit': instance.hasInstanceInit, + 'values': instance.values, + }; + +TypeUsage _$TypeUsageFromJson(Map json) => TypeUsage( + shorthand: json['shorthand'] as String, + kind: $enumDecode(_$KindEnumMap, json['kind']), + typeJson: json['type'] as Map, + ); + +Map _$TypeUsageToJson(TypeUsage instance) => { + 'shorthand': instance.shorthand, + 'kind': _$KindEnumMap[instance.kind]!, + 'type': instance.typeJson, + }; + +const _$KindEnumMap = { + Kind.primitive: 'PRIMITIVE', + Kind.typeVariable: 'TYPE_VARIABLE', + Kind.wildcard: 'WILDCARD', + Kind.declared: 'DECLARED', + Kind.array: 'ARRAY', +}; + +PrimitiveType _$PrimitiveTypeFromJson(Map json) => + PrimitiveType( + name: json['name'] as String, + ); + +Map _$PrimitiveTypeToJson(PrimitiveType instance) => + { + 'name': instance.name, + }; + +DeclaredType _$DeclaredTypeFromJson(Map json) => DeclaredType( + binaryName: json['binaryName'] as String, + simpleName: json['simpleName'] as String, + params: (json['params'] as List?) + ?.map((e) => TypeUsage.fromJson(e as Map)) + .toList() ?? + const [], + ); + +Map _$DeclaredTypeToJson(DeclaredType instance) => + { + 'binaryName': instance.binaryName, + 'simpleName': instance.simpleName, + 'params': instance.params.map((e) => e.toJson()).toList(), + }; + +TypeVar _$TypeVarFromJson(Map json) => TypeVar( + name: json['name'] as String, + ); + +Map _$TypeVarToJson(TypeVar instance) => { + 'name': instance.name, + }; + +Wildcard _$WildcardFromJson(Map json) => Wildcard( + extendsBound: json['extendsBound'] == null + ? null + : TypeUsage.fromJson(json['extendsBound'] as Map), + superBound: json['superBound'] == null + ? null + : TypeUsage.fromJson(json['superBound'] as Map), + ); + +Map _$WildcardToJson(Wildcard instance) => { + 'extendsBound': instance.extendsBound?.toJson(), + 'superBound': instance.superBound?.toJson(), + }; + +ArrayType _$ArrayTypeFromJson(Map json) => ArrayType( + type: TypeUsage.fromJson(json['type'] as Map), + ); + +Map _$ArrayTypeToJson(ArrayType instance) => { + 'type': instance.type.toJson(), + }; + +Method _$MethodFromJson(Map json) => Method( + annotations: (json['annotations'] as List?) + ?.map((e) => Annotation.fromJson(e as Map)) + .toList() ?? + const [], + javadoc: json['javadoc'] == null + ? null + : JavaDocComment.fromJson(json['javadoc'] as Map), + modifiers: (json['modifiers'] as List?) + ?.map((e) => e as String) + .toSet() ?? + const {}, + name: json['name'] as String, + typeParams: (json['typeParams'] as List?) + ?.map((e) => TypeParam.fromJson(e as Map)) + .toList() ?? + const [], + params: (json['params'] as List?) + ?.map((e) => Param.fromJson(e as Map)) + .toList() ?? + const [], + returnType: + TypeUsage.fromJson(json['returnType'] as Map), + ); + +Map _$MethodToJson(Method instance) => { + 'annotations': instance.annotations.map((e) => e.toJson()).toList(), + 'javadoc': instance.javadoc?.toJson(), + 'modifiers': instance.modifiers.toList(), + 'name': instance.name, + 'typeParams': instance.typeParams.map((e) => e.toJson()).toList(), + 'params': instance.params.map((e) => e.toJson()).toList(), + 'returnType': instance.returnType.toJson(), + }; + +Param _$ParamFromJson(Map json) => Param( + annotations: (json['annotations'] as List?) + ?.map((e) => Annotation.fromJson(e as Map)) + .toList() ?? + const [], + javadoc: json['javadoc'] == null + ? null + : JavaDocComment.fromJson(json['javadoc'] as Map), + name: json['name'] as String, + type: TypeUsage.fromJson(json['type'] as Map), + ); + +Map _$ParamToJson(Param instance) => { + 'annotations': instance.annotations.map((e) => e.toJson()).toList(), + 'javadoc': instance.javadoc?.toJson(), + 'name': instance.name, + 'type': instance.type.toJson(), + }; + +Field _$FieldFromJson(Map json) => Field( + annotations: (json['annotations'] as List?) + ?.map((e) => Annotation.fromJson(e as Map)) + .toList() ?? + const [], + javadoc: json['javadoc'] == null + ? null + : JavaDocComment.fromJson(json['javadoc'] as Map), + modifiers: (json['modifiers'] as List?) + ?.map((e) => e as String) + .toSet() ?? + const {}, + name: json['name'] as String, + type: TypeUsage.fromJson(json['type'] as Map), + defaultValue: json['defaultValue'], + ); + +Map _$FieldToJson(Field instance) => { + 'annotations': instance.annotations.map((e) => e.toJson()).toList(), + 'javadoc': instance.javadoc?.toJson(), + 'modifiers': instance.modifiers.toList(), + 'name': instance.name, + 'type': instance.type.toJson(), + 'defaultValue': instance.defaultValue, + }; + +TypeParam _$TypeParamFromJson(Map json) => TypeParam( + name: json['name'] as String, + bounds: (json['bounds'] as List?) + ?.map((e) => TypeUsage.fromJson(e as Map)) + .toList() ?? + const [], + ); + +Map _$TypeParamToJson(TypeParam instance) => { + 'name': instance.name, + 'bounds': instance.bounds.map((e) => e.toJson()).toList(), + }; + +JavaDocComment _$JavaDocCommentFromJson(Map json) => + JavaDocComment( + comment: json['comment'] as String?, + ); + +Map _$JavaDocCommentToJson(JavaDocComment instance) => + { + 'comment': instance.comment, + }; + +Annotation _$AnnotationFromJson(Map json) => Annotation( + simpleName: json['simpleName'] as String, + binaryName: json['binaryName'] as String, + properties: (json['properties'] as Map?)?.map( + (k, e) => MapEntry(k, e as Object), + ) ?? + const {}, + ); + +Map _$AnnotationToJson(Annotation instance) => + { + 'simpleName': instance.simpleName, + 'binaryName': instance.binaryName, + 'properties': instance.properties, + }; diff --git a/pkgs/jni_gen/lib/src/my_sum.dart b/pkgs/jni_gen/lib/src/my_sum.dart deleted file mode 100644 index 5e21504e8..000000000 --- a/pkgs/jni_gen/lib/src/my_sum.dart +++ /dev/null @@ -1,6 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -/// Computes the sum of its arguments. -int mySum(int a, int b) => a + b; diff --git a/pkgs/jni_gen/lib/src/tools/maven_utils.dart b/pkgs/jni_gen/lib/src/tools/maven_utils.dart new file mode 100644 index 000000000..2c28657fb --- /dev/null +++ b/pkgs/jni_gen/lib/src/tools/maven_utils.dart @@ -0,0 +1,134 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +import 'dart:io'; + +/// This class provides some utility methods to download a sources / jars +/// using maven along with transitive dependencies. +class MvnTools { + static const _tempPom = '__temp_pom.xml'; + static const _tempClassPath = '__temp_classpath.xml'; + static const _tempTarget = '__mvn_target'; + + static bool _verbose = false; + static void setVerbose(bool enabled) => _verbose = enabled; + + static void _verboseLog(Object? value) { + if (_verbose) { + stderr.writeln(value); + } + } + + /// Helper method since we can't pass inheritStdio option to [Process.run]. + static Future _runCmd(String exec, List args, + [String? workingDirectory]) async { + _verboseLog('[exec] $exec ${args.join(" ")}'); + final proc = await Process.start(exec, args, + workingDirectory: workingDirectory, + mode: ProcessStartMode.inheritStdio); + return proc.exitCode; + } + + static Future _runMavenCommand( + List deps, List mvnArgs) async { + final pom = _getStubPom(deps); + _verboseLog('using POM stub:\n$pom'); + await File(_tempPom).writeAsString(pom); + await Directory(_tempTarget).create(); + await _runCmd( + 'mvn', ['-f', _tempPom, '-DbuildDirectory=$_tempTarget', ...mvnArgs]); + await File(_tempPom).delete(); + await Directory(_tempTarget).delete(recursive: true); + } + + /// Create a list of [MvnDep] objects from maven coordinates in string form. + static List makeDependencyList(List depNames) => + depNames.map(MvnDep.fromString).toList(); + + /// Downloads and unpacks source files of [deps] into [targetDir]. + static Future downloadMavenSources( + List deps, String targetDir) async { + await _runMavenCommand(deps, [ + 'dependency:unpack-dependencies', + '-DoutputDirectory=$targetDir', + '-Dclassifier=sources' + ]); + } + + /// Downloads JAR files of all [deps] transitively into [targetDir]. + static Future downloadMavenJars( + List deps, String targetDir) async { + await _runMavenCommand(deps, [ + 'dependency:copy-dependencies', + '-DoutputDirectory=$targetDir', + ]); + } + + /// Get classpath string using JARs in maven's local repository. + static Future getMavenClassPath(List deps) async { + await _runMavenCommand(deps, [ + 'dependency:build-classpath', + '-Dmdep.outputFile=$_tempClassPath', + ]); + final classPathFile = File(_tempClassPath); + final classpath = await classPathFile.readAsString(); + await classPathFile.delete(); + return classpath; + } + + static String _getStubPom(List deps, {String javaVersion = '11'}) { + final i2 = ' ' * 2; + final i4 = ' ' * 4; + final i6 = ' ' * 6; + final i8 = ' ' * 8; + final depDecls = []; + + for (var dep in deps) { + final otherTags = StringBuffer(); + for (var entry in dep.otherTags.entries) { + otherTags.write('$i6<${entry.key}>\n' + '$i8${entry.value}\n' + '$i6\n'); + } + depDecls.add('$i4\n' + '$i6${dep.groupID}\n' + '$i6${dep.artifactID}\n' + '$i6${dep.version}\n' + '${otherTags.toString()}\n' + '$i4\n'); + } + + return '\n' + '$i24.0.0\n' + '$i2com.mycompany.app\n' + '$i2my-app\n' + '$i21.0-SNAPSHOT\n' + '$i2\n' + '$i4$javaVersion\n' + '$i4$javaVersion\n' + '$i2\n' + '$i4\n' + '${depDecls.join("\n")}' + '$i2\n' + ''; + } +} + +/// Maven dependency with group ID, artifact ID, and version. +class MvnDep { + MvnDep(this.groupID, this.artifactID, this.version, + {this.otherTags = const {}}); + factory MvnDep.fromString(String fullName) { + final components = fullName.split(':'); + if (components.length != 3) { + throw ArgumentError('invalid name for maven dependency: $fullName'); + } + return MvnDep(components[0], components[1], components[2]); + } + String groupID, artifactID, version; + Map otherTags; +} diff --git a/pkgs/jni_gen/lib/src/util/command_output.dart b/pkgs/jni_gen/lib/src/util/command_output.dart new file mode 100644 index 000000000..ba9366ac2 --- /dev/null +++ b/pkgs/jni_gen/lib/src/util/command_output.dart @@ -0,0 +1,13 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +import 'dart:convert'; + +Stream commandOutputStream( + String Function(String) lineMapper, Stream> input) => + input.transform(Utf8Decoder()).transform(LineSplitter()).map(lineMapper); + +Stream prefixedCommandOutputStream( + String prefix, Stream> input) => + commandOutputStream((line) => '$prefix $line', input); diff --git a/pkgs/jni_gen/lib/src/util/find_package.dart b/pkgs/jni_gen/lib/src/util/find_package.dart new file mode 100644 index 000000000..5c1650c0f --- /dev/null +++ b/pkgs/jni_gen/lib/src/util/find_package.dart @@ -0,0 +1,48 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +import 'dart:io'; + +import 'package:package_config/package_config.dart'; + +Future findPackage(String packageName) async { + final packageConfig = await findPackageConfig(Directory.current); + if (packageConfig == null) { + return null; + } + return packageConfig[packageName]; +} + +Future findPackageRoot(String packageName) async { + return (await findPackage(packageName))?.root; +} + +Future isPackageModifiedAfter(String packageName, DateTime time, + [String? subDir]) async { + final root = await findPackageRoot(packageName); + if (root == null) { + throw UnsupportedError('package $packageName does not exist'); + } + var checkRoot = root; + if (subDir != null) { + checkRoot = root.resolve(subDir); + } + final dir = Directory.fromUri(checkRoot); + if (!await dir.exists()) { + throw UnsupportedError('can not resolve $subDir in $packageName'); + } + // A directory's modification time is not helpful because one of + // internal files may be modified later. + // In case of git / pub package we might be able to check pubspec, but no + // such technique applies for path packages. + await for (final entry in dir.list(recursive: true)) { + final stat = await entry.stat(); + if (stat.modified.isAfter(time)) { + return true; + } + } + return false; +} + +Future findPackageJni() => findPackageRoot('jni'); diff --git a/pkgs/jni_gen/lib/src/util/name_utils.dart b/pkgs/jni_gen/lib/src/util/name_utils.dart new file mode 100644 index 000000000..f75d2db56 --- /dev/null +++ b/pkgs/jni_gen/lib/src/util/name_utils.dart @@ -0,0 +1,30 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +import 'package:jni_gen/src/elements/elements.dart'; + +String getPackageName(String binaryName) => cutFromLast(binaryName, '.')[0]; + +/// splits [str] into 2 from last occurence of [sep] +List cutFromLast(String str, String sep) { + final li = str.lastIndexOf(sep); + if (li == -1) { + return ['', str]; + } + return [str.substring(0, li), str.substring(li + 1)]; +} + +String getLastName(String binaryName) => binaryName.split('.').last; + +String getSimpleNameOf(ClassDecl cls) => cls.simpleName; + +/// Returns class name as useful in dart. +/// +/// Eg -> a.b.X.Y -> X_Y +String simplifiedClassName(String binaryName) => + getLastName(binaryName).replaceAll('\$', '_'); + +// Utilities to operate on package names. + +List getComponents(String packageName) => packageName.split('.'); diff --git a/pkgs/jni_gen/lib/src/util/rename_conflict.dart b/pkgs/jni_gen/lib/src/util/rename_conflict.dart new file mode 100644 index 000000000..7971d504a --- /dev/null +++ b/pkgs/jni_gen/lib/src/util/rename_conflict.dart @@ -0,0 +1,87 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +String renameConflict(Map counts, String name) { + if (counts.containsKey(name)) { + final count = counts[name]!; + final renamed = '$name$count'; + counts[name] = count + 1; + return renamed; + } + counts[name] = 1; + return kwRename(name); +} + +/// Appends 0 to [name] if [name] is a keyword. +/// +/// Examples: +/// * `int` -> `int0` +/// * `i` -> `i` +String kwRename(String name) => _keywords.contains(name) ? '${name}0' : name; + +const Set _keywords = { + 'abstract', + 'as', + 'assert', + 'async', + 'await', + 'break', + 'case', + 'catch', + 'class', + 'const', + 'continue', + 'covariant', + 'default', + 'deferred', + 'do', + 'dynamic', + 'else', + 'enum', + 'export', + 'extends', + 'extension', + 'external', + 'factory', + 'false', + 'final', + 'finally', + 'for', + 'Function', + 'get', + 'hide', + 'if', + 'implements', + 'import', + 'in', + 'interface', + 'is', + 'late', + 'library', + 'mixin', + 'new', + 'null', + 'on', + 'operator', + 'part', + 'required', + 'rethrow', + 'return', + 'set', + 'show', + 'static', + 'super', + 'switch', + 'sync', + 'this', + 'throw', + 'true', + 'try', + 'typedef', + 'var', + 'void', + 'while', + 'with', + 'yield', +}; diff --git a/pkgs/jni_gen/lib/src/writers/bindings_writer.dart b/pkgs/jni_gen/lib/src/writers/bindings_writer.dart new file mode 100644 index 000000000..ed50a412c --- /dev/null +++ b/pkgs/jni_gen/lib/src/writers/bindings_writer.dart @@ -0,0 +1,11 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +import 'package:jni_gen/src/elements/elements.dart'; +import 'package:jni_gen/src/config/wrapper_options.dart'; + +abstract class BindingsWriter { + Future writeBindings( + Iterable classes, WrapperOptions options); +} diff --git a/pkgs/jni_gen/lib/src/writers/callback_writer.dart b/pkgs/jni_gen/lib/src/writers/callback_writer.dart new file mode 100644 index 000000000..0ab7ed02b --- /dev/null +++ b/pkgs/jni_gen/lib/src/writers/callback_writer.dart @@ -0,0 +1,20 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +import 'package:jni_gen/src/elements/elements.dart'; +import 'package:jni_gen/src/config/wrapper_options.dart'; + +import 'bindings_writer.dart'; + +/// A writer for debugging purpose. +class CallbackWriter extends BindingsWriter { + CallbackWriter(this.callback); + Future Function(Iterable, WrapperOptions) callback; + + @override + Future writeBindings( + Iterable classes, WrapperOptions options) async { + callback(classes, options); + } +} diff --git a/pkgs/jni_gen/lib/src/writers/files_writer.dart b/pkgs/jni_gen/lib/src/writers/files_writer.dart new file mode 100644 index 000000000..0e8a6ad71 --- /dev/null +++ b/pkgs/jni_gen/lib/src/writers/files_writer.dart @@ -0,0 +1,132 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +import 'dart:io'; + +import 'package:jni_gen/src/bindings/bindings.dart'; + +import 'package:jni_gen/src/elements/elements.dart'; +import 'package:jni_gen/src/config/wrapper_options.dart'; +import 'package:jni_gen/src/util/find_package.dart'; + +import 'bindings_writer.dart'; + +/// Writer which takes writes C and Dart bindings to specified directories. +/// +/// The structure of dart files is determined by package structure of java. +/// One dart file corresponds to one java package, and it's path is decided by +/// fully qualified name of the package. +/// +/// Example: +/// `android.os` -> `$dartWrappersRoot`/`android/os.dart` +class FilesWriter extends BindingsWriter { + static const _initFileName = 'init.dart'; + + FilesWriter( + {required this.cWrapperDir, + required this.dartWrappersRoot, + this.javaWrappersRoot, + this.preamble, + required this.libraryName}); + Uri cWrapperDir, dartWrappersRoot; + Uri? javaWrappersRoot; + String? preamble; + String libraryName; + @override + Future writeBindings( + Iterable classes, WrapperOptions options) async { + // If the file already exists, show warning. + // sort classes so that all classes get written at once. + final Map> packages = {}; + final Map classesByName = {}; + for (var c in classes) { + classesByName.putIfAbsent(c.binaryName, () => c); + packages.putIfAbsent(c.packageName!, () => []); + packages[c.packageName!]!.add(c); + } + final classNames = classesByName.keys.toSet(); + + stderr.writeln('Creating dart init file ...'); + final initFileUri = dartWrappersRoot.resolve(_initFileName); + final initFile = await File.fromUri(initFileUri).create(recursive: true); + await initFile.writeAsString(DartPreludes.initFile(libraryName), + flush: true); + + final cFile = await File.fromUri(cWrapperDir.resolve('$libraryName.c')) + .create(recursive: true); + final cFileStream = cFile.openWrite(); + if (preamble != null) { + cFileStream.writeln(preamble); + } + cFileStream.write(CPreludes.prelude); + final preprocessor = ApiPreprocessor(classesByName, options); + preprocessor.preprocessAll(); + for (var packageName in packages.keys) { + final relativeFileName = '${packageName.replaceAll('.', '/')}.dart'; + final dartFileUri = dartWrappersRoot.resolve(relativeFileName); + stderr.writeln('Writing bindings for $packageName...'); + final dartFile = await File.fromUri(dartFileUri).create(recursive: true); + final resolver = PackagePathResolver( + options.importPaths, packageName, classNames, + predefined: {'java.lang.String': 'jni.JlString'}); + final cgen = CBindingGenerator(options); + final dgen = DartBindingsGenerator(options, resolver); + + final package = packages[packageName]!; + final cBindings = package.map(cgen.generateBinding).toList(); + final dartBindings = package.map(dgen.generateBinding).toList(); + // write imports from bindings + final dartFileStream = dartFile.openWrite(); + final initImportPath = ('../' * + relativeFileName.codeUnits + .where((cu) => '/'.codeUnitAt(0) == cu) + .length) + + _initFileName; + if (preamble != null) { + dartFileStream.writeln(preamble); + } + dartFileStream + ..write(DartPreludes.bindingFileHeaders) + ..write(resolver.getImportStrings().join('\n')) + ..write('import "$initImportPath" show jlookup;\n\n'); + // write dart bindings only after all imports are figured out + dartBindings.forEach(dartFileStream.write); + cBindings.forEach(cFileStream.write); + await dartFileStream.close(); + } + await cFileStream.close(); + stderr.writeln('Running dart format...'); + final formatRes = + await Process.run('dart', ['format', dartWrappersRoot.toFilePath()]); + if (formatRes.exitCode != 0) { + stderr.writeln('ERROR: dart format completed with ' + 'exit code ${formatRes.exitCode}'); + } + + stderr.writeln('Copying auxiliary files...'); + await _copyFileFromPackage( + 'jni', 'src/dartjni.h', cWrapperDir.resolve('dartjni.h')); + await _copyFileFromPackage('jni_gen', 'cmake/CMakeLists.txt.tmpl', + cWrapperDir.resolve('CMakeLists.txt'), + transform: (s) => s.replaceAll('{{LIBRARY_NAME}}', libraryName)); + stderr.writeln('Completed.'); + } + + Future _copyFileFromPackage(String package, String relPath, Uri target, + {String Function(String)? transform}) async { + final packagePath = await findPackageRoot(package); + if (packagePath != null) { + final sourceFile = File.fromUri(packagePath.resolve(relPath)); + final targetFile = await File.fromUri(target).create(); + var source = await sourceFile.readAsString(); + if (transform != null) { + source = transform(source); + } + await targetFile.writeAsString(source); + } else { + stderr.writeln('package $package not found! ' + 'skipped copying ${target.toFilePath()}'); + } + } +} diff --git a/pkgs/jni_gen/lib/src/writers/writers.dart b/pkgs/jni_gen/lib/src/writers/writers.dart new file mode 100644 index 000000000..887e6a9ba --- /dev/null +++ b/pkgs/jni_gen/lib/src/writers/writers.dart @@ -0,0 +1,7 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +export 'bindings_writer.dart'; +export 'files_writer.dart'; +export 'callback_writer.dart'; diff --git a/pkgs/jni_gen/lib/tools.dart b/pkgs/jni_gen/lib/tools.dart new file mode 100644 index 000000000..19e0eab54 --- /dev/null +++ b/pkgs/jni_gen/lib/tools.dart @@ -0,0 +1,7 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +library jni_gen_tools; + +export 'src/tools/maven_utils.dart'; diff --git a/pkgs/jni_gen/pubspec.yaml b/pkgs/jni_gen/pubspec.yaml index f60652b5b..c75369b49 100644 --- a/pkgs/jni_gen/pubspec.yaml +++ b/pkgs/jni_gen/pubspec.yaml @@ -11,7 +11,15 @@ environment: sdk: '>=2.17.0 <3.0.0' dependencies: + json_annotation: ^4.6.0 + package_config: ^2.1.0 + path: dev_dependencies: lints: ^2.0.0 + jni: + path: ../jni test: ^1.17.5 + build_runner: ^2.2.0 + json_serializable: ^6.3.1 + diff --git a/pkgs/jni_gen/test/bindings_test.dart b/pkgs/jni_gen/test/bindings_test.dart new file mode 100644 index 000000000..be93be283 --- /dev/null +++ b/pkgs/jni_gen/test/bindings_test.dart @@ -0,0 +1,94 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +// Tests on generated code. +// +// Both the simple java example & jackson core classes example have tests in +// same file, because the test runner will reuse the process, which leads to +// reuse of the old JVM with old classpath if we have separate tests with +// different classpaths. + +import 'dart:io'; + +import 'package:jni/jni.dart'; +import 'package:path/path.dart' hide equals; +import 'package:test/test.dart'; + +// ignore_for_file: avoid_relative_lib_imports +import 'simple_package_test/lib/dev/dart/simple_package.dart'; +import 'simple_package_test/lib/dev/dart/pkg2.dart'; +import 'jackson_core_test/third_party/lib/com/fasterxml/jackson/core.dart'; + +import 'test_util/test_util.dart'; + +final simplePackagePath = join('test', 'simple_package_test'); +final jacksonCorePath = join('test', 'jackson_core_test'); +final simplePackageJavaPath = join(simplePackagePath, 'java'); + +Future setupDylibsAndClasses() async { + await runCmd('dart', ['run', 'jni:setup']); + await runCmd( + 'dart', ['run', 'jni:setup', '-S', join(simplePackagePath, 'src')]); + await runCmd('dart', + ['run', 'jni:setup', '-S', join(jacksonCorePath, 'third_party', 'src')]); + await runCmd('javac', + ['dev/dart/simple_package/Example.java', 'dev/dart/pkg2/C2.java'], + workingDirectory: simplePackageJavaPath); + + final jacksonJars = await getJarPaths(join(jacksonCorePath, 'third_party')); + + if (!Platform.isAndroid) { + Jni.spawn( + helperDir: 'build/jni_libs', + classPath: [simplePackageJavaPath, ...jacksonJars]); + } +} + +void main() async { + await setupDylibsAndClasses(); + + test('static final fields', () { + expect(Example.ON, equals(1)); + expect(Example.OFF, equals(0)); + }); + + test('static & instance fields', () { + expect(Example.num, equals(121)); + final aux = Example.aux; + expect(aux.value, equals(true)); + aux.delete(); + expect(C2.CONSTANT, equals(12)); + }); + + test('static methods', () { + expect(Example.addInts(10, 15), equals(25)); + }); + + test('instance methods', () { + final ex = Example(); + expect(ex.getNum(), equals(Example.num)); + final aux = Example.getAux(); + expect(aux.getValue(), equals(true)); + aux.setValue(false); + expect(aux.getValue(), equals(false)); + aux.delete(); + ex.delete(); + }); + test('simple json parsing test', () { + final json = JlString.fromString('[1, true, false, 2, 4]'); + final factory = JsonFactory(); + final parser = factory.createParser6(json); + final values = []; + while (!parser.isClosed()) { + final next = parser.nextToken(); + values.add(next.isNumeric()); + next.delete(); + } + expect( + values, equals([false, true, false, false, true, true, false, false])); + parser.delete(); + factory.delete(); + json.delete(); + }); +} diff --git a/pkgs/jni_gen/test/jackson_core_test/.gitignore b/pkgs/jni_gen/test/jackson_core_test/.gitignore new file mode 100644 index 000000000..02158123c --- /dev/null +++ b/pkgs/jni_gen/test/jackson_core_test/.gitignore @@ -0,0 +1,5 @@ +*.jar +third_party/jar/** +third_party/java/** +third_party/test_lib/ +third_party/test_src/ diff --git a/pkgs/jni_gen/test/jackson_core_test/generate.dart b/pkgs/jni_gen/test/jackson_core_test/generate.dart new file mode 100644 index 000000000..5d6259233 --- /dev/null +++ b/pkgs/jni_gen/test/jackson_core_test/generate.dart @@ -0,0 +1,61 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +import 'package:jni_gen/jni_gen.dart'; +import '../test_util/test_util.dart'; + +const jacksonPreamble = '// Generated from jackson-core which is licensed under' + ' the Apache License 2.0.\n' + '// The following copyright from the original authors applies.\n' + '// See https://github.com/FasterXML/jackson-core/blob/2.14/LICENSE\n' + '//\n' + '// Copyright (c) 2007 - The Jackson Project Authors\n' + '// Licensed under the Apache License, Version 2.0 (the "License")\n' + '// you may not use this file except in compliance with the License.\n' + '// You may obtain a copy of the License at\n' + '//\n' + '// http://www.apache.org/licenses/LICENSE-2.0\n' + '//\n' + '// Unless required by applicable law or agreed to in writing, software\n' + '// distributed under the License is distributed on an "AS IS" BASIS,\n' + '// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n' + '// See the License for the specific language governing permissions and\n' + '// limitations under the License.\n'; + +Future generate( + {bool isTest = false, + bool generateFullVersion = false, + bool useAsm = false}) async { + final deps = ['com.fasterxml.jackson.core:jackson-core:2.13.3']; + await generateBindings( + testName: 'jackson_core_test', + sourceDepNames: deps, + jarDepNames: deps, + useAsmBackend: useAsm, + preamble: jacksonPreamble, + isThirdParty: true, + classes: (generateFullVersion) + ? ['com.fasterxml.jackson.core'] + : [ + 'com.fasterxml.jackson.core.JsonFactory', + 'com.fasterxml.jackson.core.JsonParser', + 'com.fasterxml.jackson.core.JsonToken', + ], + isGeneratedFileTest: isTest, + options: WrapperOptions( + fieldFilter: CombinedFieldFilter([ + excludeAll([ + ['com.fasterxml.jackson.core.JsonFactory', 'DEFAULT_QUOTE_CHAR'], + ['com.fasterxml.jackson.core.Base64Variant', 'PADDING_CHAR_NONE'], + ['com.fasterxml.jackson.core.base.ParserMinimalBase', 'CHAR_NULL'], + ['com.fasterxml.jackson.core.io.UTF32Reader', 'NC'], + ]), + CustomFieldFilter((decl, field) => !field.name.startsWith("_")), + ]), + methodFilter: + CustomMethodFilter((decl, method) => !method.name.startsWith('_'))), + ); +} + +void main() => generate(isTest: false); diff --git a/pkgs/jni_gen/test/jackson_core_test/generated_files_test.dart b/pkgs/jni_gen/test/jackson_core_test/generated_files_test.dart new file mode 100644 index 000000000..b9edc1bf2 --- /dev/null +++ b/pkgs/jni_gen/test/jackson_core_test/generated_files_test.dart @@ -0,0 +1,52 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +import 'dart:io'; + +import 'package:path/path.dart' hide equals; + +import 'package:test/test.dart'; + +import '../test_util/test_util.dart'; +import 'generate.dart'; + +const packageTestsDir = 'test'; +const testName = 'jackson_core_test'; + +void main() async { + final generatedFilesRoot = join(packageTestsDir, testName, 'third_party'); + await generate(isTest: true); + test("compare generated bindings for jackson_core", () { + compareDirs( + join(generatedFilesRoot, 'lib'), join(generatedFilesRoot, 'test_lib')); + compareDirs( + join(generatedFilesRoot, 'src'), join(generatedFilesRoot, 'test_src')); + }); + Future analyze() async { + final analyzeProc = await Process.start( + 'dart', ['analyze', join('test', testName, 'third_party', 'test_lib')], + mode: ProcessStartMode.inheritStdio); + final exitCode = await analyzeProc.exitCode; + expect(exitCode, 0); + } + + test( + 'generate and analyze bindings for complete library, ' + 'not just required classes', () async { + await generate(isTest: true, generateFullVersion: true); + await analyze(); + }, timeout: Timeout(Duration(minutes: 2))); + test('generate and analyze bindings using ASM', () async { + await generate(isTest: true, generateFullVersion: true, useAsm: true); + await analyze(); + }, timeout: Timeout(Duration(minutes: 2))); + tearDown(() async { + for (var dirName in ['test_lib', 'test_src']) { + final dir = Directory(join('test', testName, 'third_party', dirName)); + if (await dir.exists()) { + await dir.delete(recursive: true); + } + } + }); +} diff --git a/pkgs/jni_gen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core.dart b/pkgs/jni_gen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core.dart new file mode 100644 index 000000000..ee2de7190 --- /dev/null +++ b/pkgs/jni_gen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core.dart @@ -0,0 +1,4117 @@ +// Generated from jackson-core which is licensed under the Apache License 2.0. +// The following copyright from the original authors applies. +// See https://github.com/FasterXML/jackson-core/blob/2.14/LICENSE +// +// Copyright (c) 2007 - The Jackson Project Authors +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Autogenerated by jni_gen. DO NOT EDIT! + +// ignore_for_file: camel_case_types +// ignore_for_file: non_constant_identifier_names +// ignore_for_file: constant_identifier_names +// ignore_for_file: annotate_overrides +// ignore_for_file: no_leading_underscores_for_local_identifiers +// ignore_for_file: unused_element + +import "dart:ffi" as ffi; + +import "package:jni/jni.dart" as jni; + +import "../../../init.dart" show jlookup; + +/// from: com.fasterxml.jackson.core.JsonFactory +/// +/// The main factory class of Jackson package, used to configure and +/// construct reader (aka parser, JsonParser) +/// and writer (aka generator, JsonGenerator) +/// instances. +/// +/// Factory instances are thread-safe and reusable after configuration +/// (if any). Typically applications and services use only a single +/// globally shared factory instance, unless they need differently +/// configured factories. Factory reuse is important if efficiency matters; +/// most recycling of expensive construct is done on per-factory basis. +/// +/// Creation of a factory instance is a light-weight operation, +/// and since there is no need for pluggable alternative implementations +/// (as there is no "standard" JSON processor API to implement), +/// the default constructor is used for constructing factory +/// instances. +///@author Tatu Saloranta +class JsonFactory extends jni.JlObject { + JsonFactory.fromRef(ffi.Pointer ref) : super.fromRef(ref); + + /// from: private static final long serialVersionUID + static const serialVersionUID = 2; + + /// from: static public final java.lang.String FORMAT_NAME_JSON + /// + /// Name used to identify JSON format + /// (and returned by \#getFormatName() + static const FORMAT_NAME_JSON = "JSON"; + + static final _getDEFAULT_FACTORY_FEATURE_FLAGS = jlookup< + ffi.NativeFunction>( + "get_com_fasterxml_jackson_core_JsonFactory_DEFAULT_FACTORY_FEATURE_FLAGS") + .asFunction(); + + /// from: static protected final int DEFAULT_FACTORY_FEATURE_FLAGS + /// + /// Bitfield (set of flags) of all factory features that are enabled by default. + static int get DEFAULT_FACTORY_FEATURE_FLAGS => + _getDEFAULT_FACTORY_FEATURE_FLAGS(); + + static final _getDEFAULT_PARSER_FEATURE_FLAGS = jlookup< + ffi.NativeFunction>( + "get_com_fasterxml_jackson_core_JsonFactory_DEFAULT_PARSER_FEATURE_FLAGS") + .asFunction(); + + /// from: static protected final int DEFAULT_PARSER_FEATURE_FLAGS + /// + /// Bitfield (set of flags) of all parser features that are enabled + /// by default. + static int get DEFAULT_PARSER_FEATURE_FLAGS => + _getDEFAULT_PARSER_FEATURE_FLAGS(); + + static final _getDEFAULT_GENERATOR_FEATURE_FLAGS = jlookup< + ffi.NativeFunction>( + "get_com_fasterxml_jackson_core_JsonFactory_DEFAULT_GENERATOR_FEATURE_FLAGS") + .asFunction(); + + /// from: static protected final int DEFAULT_GENERATOR_FEATURE_FLAGS + /// + /// Bitfield (set of flags) of all generator features that are enabled + /// by default. + static int get DEFAULT_GENERATOR_FEATURE_FLAGS => + _getDEFAULT_GENERATOR_FEATURE_FLAGS(); + + static final _getDEFAULT_ROOT_VALUE_SEPARATOR = jlookup< + ffi.NativeFunction Function()>>( + "get_com_fasterxml_jackson_core_JsonFactory_DEFAULT_ROOT_VALUE_SEPARATOR") + .asFunction Function()>(); + + /// from: static public final com.fasterxml.jackson.core.SerializableString DEFAULT_ROOT_VALUE_SEPARATOR + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JlObject get DEFAULT_ROOT_VALUE_SEPARATOR => + jni.JlObject.fromRef(_getDEFAULT_ROOT_VALUE_SEPARATOR()); + + static final _ctor = + jlookup Function()>>( + "com_fasterxml_jackson_core_JsonFactory_ctor") + .asFunction Function()>(); + + /// from: public void () + /// + /// Default constructor used to create factory instances. + /// Creation of a factory instance is a light-weight operation, + /// but it is still a good idea to reuse limited number of + /// factory instances (and quite often just a single instance): + /// factories are used as context for storing some reused + /// processing objects (such as symbol tables parsers use) + /// and this reuse only works within context of a single + /// factory instance. + JsonFactory() : super.fromRef(_ctor()); + + static final _ctor1 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_ctor1") + .asFunction Function(ffi.Pointer)>(); + + /// from: public void (com.fasterxml.jackson.core.ObjectCodec oc) + JsonFactory.ctor1(jni.JlObject oc) : super.fromRef(_ctor1(oc.reference)); + + static final _ctor2 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_ctor2") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: protected void (com.fasterxml.jackson.core.JsonFactory src, com.fasterxml.jackson.core.ObjectCodec codec) + /// + /// Constructor used when copy()ing a factory instance. + ///@param src Original factory to copy settings from + ///@param codec Databinding-level codec to use, if any + ///@since 2.2.1 + JsonFactory.ctor2(JsonFactory src, jni.JlObject codec) + : super.fromRef(_ctor2(src.reference, codec.reference)); + + static final _ctor3 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_ctor3") + .asFunction Function(ffi.Pointer)>(); + + /// from: public void (com.fasterxml.jackson.core.JsonFactoryBuilder b) + /// + /// Constructor used by JsonFactoryBuilder for instantiation. + ///@param b Builder that contains settings to use + ///@since 2.10 + JsonFactory.ctor3(jni.JlObject b) : super.fromRef(_ctor3(b.reference)); + + static final _ctor4 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Uint8)>>("com_fasterxml_jackson_core_JsonFactory_ctor4") + .asFunction Function(ffi.Pointer, int)>(); + + /// from: protected void (com.fasterxml.jackson.core.TSFBuilder b, boolean bogus) + /// + /// Constructor for subtypes; needed to work around the fact that before 3.0, + /// this factory has cumbersome dual role as generic type as well as actual + /// implementation for json. + ///@param b Builder that contains settings to use + ///@param bogus Argument only needed to separate constructor signature; ignored + JsonFactory.ctor4(jni.JlObject b, bool bogus) + : super.fromRef(_ctor4(b.reference, bogus ? 1 : 0)); + + static final _rebuild = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_rebuild") + .asFunction Function(ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.TSFBuilder rebuild() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that allows construction of differently configured factory, starting + /// with settings of this factory. + ///@return Builder instance to use + ///@since 2.10 + jni.JlObject rebuild() => jni.JlObject.fromRef(_rebuild(reference)); + + static final _builder = + jlookup Function()>>( + "com_fasterxml_jackson_core_JsonFactory_builder") + .asFunction Function()>(); + + /// from: static public com.fasterxml.jackson.core.TSFBuilder builder() + /// The returned object must be deleted after use, by calling the `delete` 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. + ///@return Builder instance to use + static jni.JlObject builder() => jni.JlObject.fromRef(_builder()); + + static final _copy = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_copy") + .asFunction Function(ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonFactory copy() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing a new JsonFactory that has + /// the same settings as this instance, but is otherwise + /// independent (i.e. nothing is actually shared, symbol tables + /// are separate). + /// Note that ObjectCodec reference is not copied but is + /// set to null; caller typically needs to set it after calling + /// this method. Reason for this is that the codec is used for + /// callbacks, and assumption is that there is strict 1-to-1 + /// mapping between codec, factory. Caller has to, then, explicitly + /// set codec after making the copy. + ///@return Copy of this factory instance + ///@since 2.1 + JsonFactory copy() => JsonFactory.fromRef(_copy(reference)); + + static final _readResolve = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_readResolve") + .asFunction Function(ffi.Pointer)>(); + + /// from: protected java.lang.Object readResolve() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that we need to override to actually make restoration go + /// through constructors etc: needed to allow JDK serializability of + /// factory instances. + /// + /// Note: must be overridden by sub-classes as well. + ///@return Newly constructed instance + jni.JlObject readResolve() => jni.JlObject.fromRef(_readResolve(reference)); + + static final _requiresPropertyOrdering = + jlookup)>>( + "com_fasterxml_jackson_core_JsonFactory_requiresPropertyOrdering") + .asFunction)>(); + + /// from: public boolean requiresPropertyOrdering() + /// + /// Introspection method that higher-level functionality may call + /// to see whether underlying data format requires a stable ordering + /// of object properties or not. + /// This is usually used for determining + /// whether to force a stable ordering (like alphabetic ordering by name) + /// if no ordering if explicitly specified. + /// + /// Default implementation returns false as JSON does NOT + /// require stable ordering. Formats that require ordering include positional + /// textual formats like CSV, and schema-based binary formats + /// like Avro. + ///@return Whether format supported by this factory + /// requires Object properties to be ordered. + ///@since 2.3 + bool requiresPropertyOrdering() => _requiresPropertyOrdering(reference) != 0; + + static final _canHandleBinaryNatively = + jlookup)>>( + "com_fasterxml_jackson_core_JsonFactory_canHandleBinaryNatively") + .asFunction)>(); + + /// from: public boolean canHandleBinaryNatively() + /// + /// Introspection method that higher-level functionality may call + /// to see whether underlying data format can read and write binary + /// data natively; that is, embeded it as-is without using encodings + /// such as Base64. + /// + /// Default implementation returns false as JSON does not + /// support native access: all binary content must use Base64 encoding. + /// Most binary formats (like Smile and Avro) support native binary content. + ///@return Whether format supported by this factory + /// supports native binary content + ///@since 2.3 + bool canHandleBinaryNatively() => _canHandleBinaryNatively(reference) != 0; + + static final _canUseCharArrays = + jlookup)>>( + "com_fasterxml_jackson_core_JsonFactory_canUseCharArrays") + .asFunction)>(); + + /// from: public boolean canUseCharArrays() + /// + /// Introspection method that can be used by base factory to check + /// whether access using char[] is something that actual + /// parser implementations can take advantage of, over having to + /// use java.io.Reader. Sub-types are expected to override + /// definition; default implementation (suitable for JSON) alleges + /// that optimization are possible; and thereby is likely to try + /// to access java.lang.String content by first copying it into + /// recyclable intermediate buffer. + ///@return Whether access to decoded textual content can be efficiently + /// accessed using parser method {@code getTextCharacters()}. + ///@since 2.4 + bool canUseCharArrays() => _canUseCharArrays(reference) != 0; + + static final _canParseAsync = + jlookup)>>( + "com_fasterxml_jackson_core_JsonFactory_canParseAsync") + .asFunction)>(); + + /// from: public boolean canParseAsync() + /// + /// Introspection method that can be used to check whether this + /// factory can create non-blocking parsers: parsers that do not + /// use blocking I/O abstractions but instead use a + /// com.fasterxml.jackson.core.async.NonBlockingInputFeeder. + ///@return Whether this factory supports non-blocking ("async") parsing or + /// not (and consequently whether {@code createNonBlockingXxx()} method(s) work) + ///@since 2.9 + bool canParseAsync() => _canParseAsync(reference) != 0; + + static final _getFormatReadFeatureType = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_getFormatReadFeatureType") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.lang.Class getFormatReadFeatureType() + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JlObject getFormatReadFeatureType() => + jni.JlObject.fromRef(_getFormatReadFeatureType(reference)); + + static final _getFormatWriteFeatureType = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_getFormatWriteFeatureType") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.lang.Class getFormatWriteFeatureType() + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JlObject getFormatWriteFeatureType() => + jni.JlObject.fromRef(_getFormatWriteFeatureType(reference)); + + static final _canUseSchema = jlookup< + ffi.NativeFunction< + ffi.Uint8 Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_canUseSchema") + .asFunction, ffi.Pointer)>(); + + /// from: public boolean canUseSchema(com.fasterxml.jackson.core.FormatSchema schema) + /// + /// Method that can be used to quickly check whether given schema + /// is something that parsers and/or generators constructed by this + /// factory could use. Note that this means possible use, at the level + /// of data format (i.e. schema is for same data format as parsers and + /// generators this factory constructs); individual schema instances + /// may have further usage restrictions. + ///@param schema Schema instance to check + ///@return Whether parsers and generators constructed by this factory + /// can use specified format schema instance + bool canUseSchema(jni.JlObject schema) => + _canUseSchema(reference, schema.reference) != 0; + + static final _getFormatName = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_getFormatName") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.lang.String getFormatName() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that returns short textual id identifying format + /// this factory supports. + /// + /// Note: sub-classes should override this method; default + /// implementation will return null for all sub-classes + ///@return Name of the format handled by parsers, generators this factory creates + jni.JlString getFormatName() => + jni.JlString.fromRef(_getFormatName(reference)); + + static final _hasFormat = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_hasFormat") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.format.MatchStrength hasFormat(com.fasterxml.jackson.core.format.InputAccessor acc) + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JlObject hasFormat(jni.JlObject acc) => + jni.JlObject.fromRef(_hasFormat(reference, acc.reference)); + + static final _requiresCustomCodec = + jlookup)>>( + "com_fasterxml_jackson_core_JsonFactory_requiresCustomCodec") + .asFunction)>(); + + /// from: public boolean requiresCustomCodec() + /// + /// Method that can be called to determine if a custom + /// ObjectCodec is needed for binding data parsed + /// using JsonParser constructed by this factory + /// (which typically also implies the same for serialization + /// with JsonGenerator). + ///@return True if custom codec is needed with parsers and + /// generators created by this factory; false if a general + /// ObjectCodec is enough + ///@since 2.1 + bool requiresCustomCodec() => _requiresCustomCodec(reference) != 0; + + static final _hasJSONFormat = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_hasJSONFormat") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: protected com.fasterxml.jackson.core.format.MatchStrength hasJSONFormat(com.fasterxml.jackson.core.format.InputAccessor acc) + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JlObject hasJSONFormat(jni.JlObject acc) => + jni.JlObject.fromRef(_hasJSONFormat(reference, acc.reference)); + + static final _version = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_version") + .asFunction Function(ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.Version version() + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JlObject version() => jni.JlObject.fromRef(_version(reference)); + + static final _configure = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Uint8)>>( + "com_fasterxml_jackson_core_JsonFactory_configure") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, int)>(); + + /// from: public final com.fasterxml.jackson.core.JsonFactory configure(com.fasterxml.jackson.core.JsonFactory.Feature f, boolean state) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for enabling or disabling specified parser feature + /// (check JsonParser.Feature for list of features) + ///@param f Feature to enable/disable + ///@param state Whether to enable or disable the feature + ///@return This factory instance (to allow call chaining) + ///@deprecated since 2.10 use JsonFactoryBuilder\#configure(JsonFactory.Feature, boolean) instead + JsonFactory configure(JsonFactory_Feature f, bool state) => + JsonFactory.fromRef(_configure(reference, f.reference, state ? 1 : 0)); + + static final _enable = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_enable") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonFactory enable(com.fasterxml.jackson.core.JsonFactory.Feature f) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for enabling specified parser feature + /// (check JsonFactory.Feature for list of features) + ///@param f Feature to enable + ///@return This factory instance (to allow call chaining) + ///@deprecated since 2.10 use JsonFactoryBuilder\#configure(JsonFactory.Feature, boolean) instead + JsonFactory enable(JsonFactory_Feature f) => + JsonFactory.fromRef(_enable(reference, f.reference)); + + static final _disable = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_disable") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonFactory disable(com.fasterxml.jackson.core.JsonFactory.Feature f) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for disabling specified parser features + /// (check JsonFactory.Feature for list of features) + ///@param f Feature to disable + ///@return This factory instance (to allow call chaining) + ///@deprecated since 2.10 use JsonFactoryBuilder\#configure(JsonFactory.Feature, boolean) instead + JsonFactory disable(JsonFactory_Feature f) => + JsonFactory.fromRef(_disable(reference, f.reference)); + + static final _isEnabled = jlookup< + ffi.NativeFunction< + ffi.Uint8 Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_isEnabled") + .asFunction, ffi.Pointer)>(); + + /// from: public final boolean isEnabled(com.fasterxml.jackson.core.JsonFactory.Feature f) + /// + /// Checked whether specified parser feature is enabled. + ///@param f Feature to check + ///@return True if the specified feature is enabled + bool isEnabled(JsonFactory_Feature f) => + _isEnabled(reference, f.reference) != 0; + + static final _getParserFeatures = + jlookup)>>( + "com_fasterxml_jackson_core_JsonFactory_getParserFeatures") + .asFunction)>(); + + /// from: public final int getParserFeatures() + int getParserFeatures() => _getParserFeatures(reference); + + static final _getGeneratorFeatures = + jlookup)>>( + "com_fasterxml_jackson_core_JsonFactory_getGeneratorFeatures") + .asFunction)>(); + + /// from: public final int getGeneratorFeatures() + int getGeneratorFeatures() => _getGeneratorFeatures(reference); + + static final _getFormatParserFeatures = + jlookup)>>( + "com_fasterxml_jackson_core_JsonFactory_getFormatParserFeatures") + .asFunction)>(); + + /// from: public int getFormatParserFeatures() + int getFormatParserFeatures() => _getFormatParserFeatures(reference); + + static final _getFormatGeneratorFeatures = jlookup< + ffi.NativeFunction)>>( + "com_fasterxml_jackson_core_JsonFactory_getFormatGeneratorFeatures") + .asFunction)>(); + + /// from: public int getFormatGeneratorFeatures() + int getFormatGeneratorFeatures() => _getFormatGeneratorFeatures(reference); + + static final _configure1 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Uint8)>>( + "com_fasterxml_jackson_core_JsonFactory_configure1") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, int)>(); + + /// from: public final com.fasterxml.jackson.core.JsonFactory configure(com.fasterxml.jackson.core.JsonParser.Feature f, boolean state) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for enabling or disabling specified parser feature + /// (check JsonParser.Feature for list of features) + ///@param f Feature to enable/disable + ///@param state Whether to enable or disable the feature + ///@return This factory instance (to allow call chaining) + JsonFactory configure1(JsonParser_Feature f, bool state) => + JsonFactory.fromRef(_configure1(reference, f.reference, state ? 1 : 0)); + + static final _enable1 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_enable1") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonFactory enable(com.fasterxml.jackson.core.JsonParser.Feature f) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for enabling specified parser feature + /// (check JsonParser.Feature for list of features) + ///@param f Feature to enable + ///@return This factory instance (to allow call chaining) + JsonFactory enable1(JsonParser_Feature f) => + JsonFactory.fromRef(_enable1(reference, f.reference)); + + static final _disable1 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_disable1") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonFactory disable(com.fasterxml.jackson.core.JsonParser.Feature f) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for disabling specified parser features + /// (check JsonParser.Feature for list of features) + ///@param f Feature to disable + ///@return This factory instance (to allow call chaining) + JsonFactory disable1(JsonParser_Feature f) => + JsonFactory.fromRef(_disable1(reference, f.reference)); + + static final _isEnabled1 = jlookup< + ffi.NativeFunction< + ffi.Uint8 Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_isEnabled1") + .asFunction, ffi.Pointer)>(); + + /// from: public final boolean isEnabled(com.fasterxml.jackson.core.JsonParser.Feature f) + /// + /// Method for checking if the specified parser feature is enabled. + ///@param f Feature to check + ///@return True if specified feature is enabled + bool isEnabled1(JsonParser_Feature f) => + _isEnabled1(reference, f.reference) != 0; + + static final _isEnabled2 = jlookup< + ffi.NativeFunction< + ffi.Uint8 Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_isEnabled2") + .asFunction, ffi.Pointer)>(); + + /// from: public final boolean isEnabled(com.fasterxml.jackson.core.StreamReadFeature f) + /// + /// Method for checking if the specified stream read feature is enabled. + ///@param f Feature to check + ///@return True if specified feature is enabled + ///@since 2.10 + bool isEnabled2(jni.JlObject f) => _isEnabled2(reference, f.reference) != 0; + + static final _getInputDecorator = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_getInputDecorator") + .asFunction Function(ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.io.InputDecorator getInputDecorator() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for getting currently configured input decorator (if any; + /// there is no default decorator). + ///@return InputDecorator configured, if any + jni.JlObject getInputDecorator() => + jni.JlObject.fromRef(_getInputDecorator(reference)); + + static final _setInputDecorator = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_setInputDecorator") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonFactory setInputDecorator(com.fasterxml.jackson.core.io.InputDecorator d) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for overriding currently configured input decorator + ///@param d Decorator to configure for this factory, if any ({@code null} if none) + ///@return This factory instance (to allow call chaining) + ///@deprecated Since 2.10 use JsonFactoryBuilder\#inputDecorator(InputDecorator) instead + JsonFactory setInputDecorator(jni.JlObject d) => + JsonFactory.fromRef(_setInputDecorator(reference, d.reference)); + + static final _configure2 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Uint8)>>( + "com_fasterxml_jackson_core_JsonFactory_configure2") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, int)>(); + + /// from: public final com.fasterxml.jackson.core.JsonFactory configure(com.fasterxml.jackson.core.JsonGenerator.Feature f, boolean state) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for enabling or disabling specified generator feature + /// (check JsonGenerator.Feature for list of features) + ///@param f Feature to enable/disable + ///@param state Whether to enable or disable the feature + ///@return This factory instance (to allow call chaining) + JsonFactory configure2(jni.JlObject f, bool state) => + JsonFactory.fromRef(_configure2(reference, f.reference, state ? 1 : 0)); + + static final _enable2 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_enable2") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonFactory enable(com.fasterxml.jackson.core.JsonGenerator.Feature f) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for enabling specified generator features + /// (check JsonGenerator.Feature for list of features) + ///@param f Feature to enable + ///@return This factory instance (to allow call chaining) + JsonFactory enable2(jni.JlObject f) => + JsonFactory.fromRef(_enable2(reference, f.reference)); + + static final _disable2 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_disable2") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonFactory disable(com.fasterxml.jackson.core.JsonGenerator.Feature f) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for disabling specified generator feature + /// (check JsonGenerator.Feature for list of features) + ///@param f Feature to disable + ///@return This factory instance (to allow call chaining) + JsonFactory disable2(jni.JlObject f) => + JsonFactory.fromRef(_disable2(reference, f.reference)); + + static final _isEnabled3 = jlookup< + ffi.NativeFunction< + ffi.Uint8 Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_isEnabled3") + .asFunction, ffi.Pointer)>(); + + /// from: public final boolean isEnabled(com.fasterxml.jackson.core.JsonGenerator.Feature f) + /// + /// Check whether specified generator feature is enabled. + ///@param f Feature to check + ///@return Whether specified feature is enabled + bool isEnabled3(jni.JlObject f) => _isEnabled3(reference, f.reference) != 0; + + static final _isEnabled4 = jlookup< + ffi.NativeFunction< + ffi.Uint8 Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_isEnabled4") + .asFunction, ffi.Pointer)>(); + + /// from: public final boolean isEnabled(com.fasterxml.jackson.core.StreamWriteFeature f) + /// + /// Check whether specified stream write feature is enabled. + ///@param f Feature to check + ///@return Whether specified feature is enabled + ///@since 2.10 + bool isEnabled4(jni.JlObject f) => _isEnabled4(reference, f.reference) != 0; + + static final _getCharacterEscapes = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_getCharacterEscapes") + .asFunction Function(ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.io.CharacterEscapes getCharacterEscapes() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for accessing custom escapes factory uses for JsonGenerators + /// it creates. + ///@return Configured {@code CharacterEscapes}, if any; {@code null} if none + jni.JlObject getCharacterEscapes() => + jni.JlObject.fromRef(_getCharacterEscapes(reference)); + + static final _setCharacterEscapes = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_setCharacterEscapes") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonFactory setCharacterEscapes(com.fasterxml.jackson.core.io.CharacterEscapes esc) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for defining custom escapes factory uses for JsonGenerators + /// it creates. + ///@param esc CharaterEscapes to set (or {@code null} for "none") + ///@return This factory instance (to allow call chaining) + JsonFactory setCharacterEscapes(jni.JlObject esc) => + JsonFactory.fromRef(_setCharacterEscapes(reference, esc.reference)); + + static final _getOutputDecorator = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_getOutputDecorator") + .asFunction Function(ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.io.OutputDecorator getOutputDecorator() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for getting currently configured output decorator (if any; + /// there is no default decorator). + ///@return OutputDecorator configured for generators factory creates, if any; + /// {@code null} if none. + jni.JlObject getOutputDecorator() => + jni.JlObject.fromRef(_getOutputDecorator(reference)); + + static final _setOutputDecorator = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_setOutputDecorator") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonFactory setOutputDecorator(com.fasterxml.jackson.core.io.OutputDecorator d) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for overriding currently configured output decorator + ///@return This factory instance (to allow call chaining) + ///@param d Output decorator to use, if any + ///@deprecated Since 2.10 use JsonFactoryBuilder\#outputDecorator(OutputDecorator) instead + JsonFactory setOutputDecorator(jni.JlObject d) => + JsonFactory.fromRef(_setOutputDecorator(reference, d.reference)); + + static final _setRootValueSeparator = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_setRootValueSeparator") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonFactory setRootValueSeparator(java.lang.String sep) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that allows overriding String used for separating root-level + /// JSON values (default is single space character) + ///@param sep Separator to use, if any; null means that no separator is + /// automatically added + ///@return This factory instance (to allow call chaining) + JsonFactory setRootValueSeparator(jni.JlString sep) => + JsonFactory.fromRef(_setRootValueSeparator(reference, sep.reference)); + + static final _getRootValueSeparator = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_getRootValueSeparator") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.lang.String getRootValueSeparator() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// @return Root value separator configured, if any + jni.JlString getRootValueSeparator() => + jni.JlString.fromRef(_getRootValueSeparator(reference)); + + static final _setCodec = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_setCodec") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonFactory setCodec(com.fasterxml.jackson.core.ObjectCodec oc) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for associating a ObjectCodec (typically + /// a com.fasterxml.jackson.databind.ObjectMapper) + /// with this factory (and more importantly, parsers and generators + /// it constructs). This is needed to use data-binding methods + /// of JsonParser and JsonGenerator instances. + ///@param oc Codec to use + ///@return This factory instance (to allow call chaining) + JsonFactory setCodec(jni.JlObject oc) => + JsonFactory.fromRef(_setCodec(reference, oc.reference)); + + static final _getCodec = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_getCodec") + .asFunction Function(ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.ObjectCodec getCodec() + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JlObject getCodec() => jni.JlObject.fromRef(_getCodec(reference)); + + static final _createParser = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_createParser") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.io.File f) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing JSON parser instance to parse + /// contents of specified file. + /// + /// + /// Encoding is auto-detected from contents according to JSON + /// specification recommended mechanism. Json specification + /// supports only UTF-8, UTF-16 and UTF-32 as valid encodings, + /// so auto-detection implemented only for this charsets. + /// For other charsets use \#createParser(java.io.Reader). + /// + /// + /// Underlying input stream (needed for reading contents) + /// will be __owned__ (and managed, i.e. closed as need be) by + /// the parser, since caller has no access to it. + ///@param f File that contains JSON content to parse + ///@since 2.1 + JsonParser createParser(jni.JlObject f) => + JsonParser.fromRef(_createParser(reference, f.reference)); + + static final _createParser1 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_createParser1") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.net.URL url) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing JSON parser instance to parse + /// contents of resource reference by given URL. + /// + /// Encoding is auto-detected from contents according to JSON + /// specification recommended mechanism. Json specification + /// supports only UTF-8, UTF-16 and UTF-32 as valid encodings, + /// so auto-detection implemented only for this charsets. + /// For other charsets use \#createParser(java.io.Reader). + /// + /// Underlying input stream (needed for reading contents) + /// will be __owned__ (and managed, i.e. closed as need be) by + /// the parser, since caller has no access to it. + ///@param url URL pointing to resource that contains JSON content to parse + ///@since 2.1 + JsonParser createParser1(jni.JlObject url) => + JsonParser.fromRef(_createParser1(reference, url.reference)); + + static final _createParser2 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_createParser2") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.io.InputStream in) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing JSON parser instance to parse + /// the contents accessed via specified input stream. + /// + /// The input stream will __not be owned__ by + /// the parser, it will still be managed (i.e. closed if + /// end-of-stream is reacher, or parser close method called) + /// if (and only if) com.fasterxml.jackson.core.StreamReadFeature\#AUTO_CLOSE_SOURCE + /// is enabled. + /// + /// + /// Note: no encoding argument is taken since it can always be + /// auto-detected as suggested by JSON RFC. Json specification + /// supports only UTF-8, UTF-16 and UTF-32 as valid encodings, + /// so auto-detection implemented only for this charsets. + /// For other charsets use \#createParser(java.io.Reader). + ///@param in InputStream to use for reading JSON content to parse + ///@since 2.1 + JsonParser createParser2(jni.JlObject in0) => + JsonParser.fromRef(_createParser2(reference, in0.reference)); + + static final _createParser3 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_createParser3") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.io.Reader r) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing parser for parsing + /// the contents accessed via specified Reader. + /// + /// The read stream will __not be owned__ by + /// the parser, it will still be managed (i.e. closed if + /// end-of-stream is reacher, or parser close method called) + /// if (and only if) com.fasterxml.jackson.core.StreamReadFeature\#AUTO_CLOSE_SOURCE + /// is enabled. + ///@param r Reader to use for reading JSON content to parse + ///@since 2.1 + JsonParser createParser3(jni.JlObject r) => + JsonParser.fromRef(_createParser3(reference, r.reference)); + + static final _createParser4 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_createParser4") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser createParser(byte[] data) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing parser for parsing + /// the contents of given byte array. + ///@since 2.1 + JsonParser createParser4(jni.JlObject data) => + JsonParser.fromRef(_createParser4(reference, data.reference)); + + static final _createParser5 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Int32, ffi.Int32)>>( + "com_fasterxml_jackson_core_JsonFactory_createParser5") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, int, int)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser createParser(byte[] data, int offset, int len) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing parser for parsing + /// the contents of given byte array. + ///@param data Buffer that contains data to parse + ///@param offset Offset of the first data byte within buffer + ///@param len Length of contents to parse within buffer + ///@since 2.1 + JsonParser createParser5(jni.JlObject data, int offset, int len) => + JsonParser.fromRef( + _createParser5(reference, data.reference, offset, len)); + + static final _createParser6 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_createParser6") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.lang.String content) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing parser for parsing + /// contents of given String. + ///@since 2.1 + JsonParser createParser6(jni.JlString content) => + JsonParser.fromRef(_createParser6(reference, content.reference)); + + static final _createParser7 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_createParser7") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser createParser(char[] content) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing parser for parsing + /// contents of given char array. + ///@since 2.4 + JsonParser createParser7(jni.JlObject content) => + JsonParser.fromRef(_createParser7(reference, content.reference)); + + static final _createParser8 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Int32, ffi.Int32)>>( + "com_fasterxml_jackson_core_JsonFactory_createParser8") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, int, int)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser createParser(char[] content, int offset, int len) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing parser for parsing contents of given char array. + ///@since 2.4 + JsonParser createParser8(jni.JlObject content, int offset, int len) => + JsonParser.fromRef( + _createParser8(reference, content.reference, offset, len)); + + static final _createParser9 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_createParser9") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.io.DataInput in) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Optional method for constructing parser for reading contents from specified DataInput + /// instance. + /// + /// If this factory does not support DataInput as source, + /// will throw UnsupportedOperationException + ///@since 2.8 + JsonParser createParser9(jni.JlObject in0) => + JsonParser.fromRef(_createParser9(reference, in0.reference)); + + static final _createNonBlockingByteArrayParser = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_createNonBlockingByteArrayParser") + .asFunction Function(ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser createNonBlockingByteArrayParser() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Optional method for constructing parser for non-blocking parsing + /// via com.fasterxml.jackson.core.async.ByteArrayFeeder + /// interface (accessed using JsonParser\#getNonBlockingInputFeeder() + /// from constructed instance). + /// + /// If this factory does not support non-blocking parsing (either at all, + /// or from byte array), + /// will throw UnsupportedOperationException. + /// + /// Note that JSON-backed factory only supports parsing of UTF-8 encoded JSON content + /// (and US-ASCII since it is proper subset); other encodings are not supported + /// at this point. + ///@since 2.9 + JsonParser createNonBlockingByteArrayParser() => + JsonParser.fromRef(_createNonBlockingByteArrayParser(reference)); + + static final _createGenerator = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_createGenerator") + .asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.OutputStream out, com.fasterxml.jackson.core.JsonEncoding enc) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing JSON generator for writing JSON content + /// using specified output stream. + /// Encoding to use must be specified, and needs to be one of available + /// types (as per JSON specification). + /// + /// Underlying stream __is NOT owned__ by the generator constructed, + /// so that generator will NOT close the output stream when + /// JsonGenerator\#close is called (unless auto-closing + /// feature, + /// com.fasterxml.jackson.core.JsonGenerator.Feature\#AUTO_CLOSE_TARGET + /// is enabled). + /// Using application needs to close it explicitly if this is the case. + /// + /// Note: there are formats that use fixed encoding (like most binary data formats) + /// and that ignore passed in encoding. + ///@param out OutputStream to use for writing JSON content + ///@param enc Character encoding to use + ///@since 2.1 + jni.JlObject createGenerator(jni.JlObject out, jni.JlObject enc) => + jni.JlObject.fromRef( + _createGenerator(reference, out.reference, enc.reference)); + + static final _createGenerator1 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_createGenerator1") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.OutputStream out) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Convenience method for constructing generator that uses default + /// encoding of the format (UTF-8 for JSON and most other data formats). + /// + /// Note: there are formats that use fixed encoding (like most binary data formats). + ///@since 2.1 + jni.JlObject createGenerator1(jni.JlObject out) => + jni.JlObject.fromRef(_createGenerator1(reference, out.reference)); + + static final _createGenerator2 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_createGenerator2") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.Writer w) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing JSON generator for writing JSON content + /// using specified Writer. + /// + /// Underlying stream __is NOT owned__ by the generator constructed, + /// so that generator will NOT close the Reader when + /// JsonGenerator\#close is called (unless auto-closing + /// feature, + /// com.fasterxml.jackson.core.JsonGenerator.Feature\#AUTO_CLOSE_TARGET is enabled). + /// Using application needs to close it explicitly. + ///@since 2.1 + ///@param w Writer to use for writing JSON content + jni.JlObject createGenerator2(jni.JlObject w) => + jni.JlObject.fromRef(_createGenerator2(reference, w.reference)); + + static final _createGenerator3 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_createGenerator3") + .asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.File f, com.fasterxml.jackson.core.JsonEncoding enc) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing JSON generator for writing JSON content + /// to specified file, overwriting contents it might have (or creating + /// it if such file does not yet exist). + /// Encoding to use must be specified, and needs to be one of available + /// types (as per JSON specification). + /// + /// Underlying stream __is owned__ by the generator constructed, + /// i.e. generator will handle closing of file when + /// JsonGenerator\#close is called. + ///@param f File to write contents to + ///@param enc Character encoding to use + ///@since 2.1 + jni.JlObject createGenerator3(jni.JlObject f, jni.JlObject enc) => + jni.JlObject.fromRef( + _createGenerator3(reference, f.reference, enc.reference)); + + static final _createGenerator4 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_createGenerator4") + .asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.DataOutput out, com.fasterxml.jackson.core.JsonEncoding enc) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing generator for writing content using specified + /// DataOutput instance. + ///@since 2.8 + jni.JlObject createGenerator4(jni.JlObject out, jni.JlObject enc) => + jni.JlObject.fromRef( + _createGenerator4(reference, out.reference, enc.reference)); + + static final _createGenerator5 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_createGenerator5") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.DataOutput out) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Convenience method for constructing generator that uses default + /// encoding of the format (UTF-8 for JSON and most other data formats). + /// + /// Note: there are formats that use fixed encoding (like most binary data formats). + ///@since 2.8 + jni.JlObject createGenerator5(jni.JlObject out) => + jni.JlObject.fromRef(_createGenerator5(reference, out.reference)); + + static final _createJsonParser = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_createJsonParser") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(java.io.File f) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing JSON parser instance to parse + /// contents of specified file. + /// + /// Encoding is auto-detected from contents according to JSON + /// specification recommended mechanism. Json specification + /// supports only UTF-8, UTF-16 and UTF-32 as valid encodings, + /// so auto-detection implemented only for this charsets. + /// For other charsets use \#createParser(java.io.Reader). + /// + /// + /// Underlying input stream (needed for reading contents) + /// will be __owned__ (and managed, i.e. closed as need be) by + /// the parser, since caller has no access to it. + ///@param f File that contains JSON content to parse + ///@return Parser constructed + ///@throws IOException if parser initialization fails due to I/O (read) problem + ///@throws JsonParseException if parser initialization fails due to content decoding problem + ///@deprecated Since 2.2, use \#createParser(File) instead. + JsonParser createJsonParser(jni.JlObject f) => + JsonParser.fromRef(_createJsonParser(reference, f.reference)); + + static final _createJsonParser1 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_createJsonParser1") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(java.net.URL url) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing JSON parser instance to parse + /// contents of resource reference by given URL. + /// + /// Encoding is auto-detected from contents according to JSON + /// specification recommended mechanism. Json specification + /// supports only UTF-8, UTF-16 and UTF-32 as valid encodings, + /// so auto-detection implemented only for this charsets. + /// For other charsets use \#createParser(java.io.Reader). + /// + /// Underlying input stream (needed for reading contents) + /// will be __owned__ (and managed, i.e. closed as need be) by + /// the parser, since caller has no access to it. + ///@param url URL pointing to resource that contains JSON content to parse + ///@return Parser constructed + ///@throws IOException if parser initialization fails due to I/O (read) problem + ///@throws JsonParseException if parser initialization fails due to content decoding problem + ///@deprecated Since 2.2, use \#createParser(URL) instead. + JsonParser createJsonParser1(jni.JlObject url) => + JsonParser.fromRef(_createJsonParser1(reference, url.reference)); + + static final _createJsonParser2 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_createJsonParser2") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(java.io.InputStream in) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing JSON parser instance to parse + /// the contents accessed via specified input stream. + /// + /// The input stream will __not be owned__ by + /// the parser, it will still be managed (i.e. closed if + /// end-of-stream is reacher, or parser close method called) + /// if (and only if) com.fasterxml.jackson.core.JsonParser.Feature\#AUTO_CLOSE_SOURCE + /// is enabled. + /// + /// + /// Note: no encoding argument is taken since it can always be + /// auto-detected as suggested by JSON RFC. Json specification + /// supports only UTF-8, UTF-16 and UTF-32 as valid encodings, + /// so auto-detection implemented only for this charsets. + /// For other charsets use \#createParser(java.io.Reader). + ///@param in InputStream to use for reading JSON content to parse + ///@return Parser constructed + ///@throws IOException if parser initialization fails due to I/O (read) problem + ///@throws JsonParseException if parser initialization fails due to content decoding problem + ///@deprecated Since 2.2, use \#createParser(InputStream) instead. + JsonParser createJsonParser2(jni.JlObject in0) => + JsonParser.fromRef(_createJsonParser2(reference, in0.reference)); + + static final _createJsonParser3 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_createJsonParser3") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(java.io.Reader r) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing parser for parsing + /// the contents accessed via specified Reader. + /// + /// The read stream will __not be owned__ by + /// the parser, it will still be managed (i.e. closed if + /// end-of-stream is reacher, or parser close method called) + /// if (and only if) com.fasterxml.jackson.core.JsonParser.Feature\#AUTO_CLOSE_SOURCE + /// is enabled. + ///@param r Reader to use for reading JSON content to parse + ///@return Parser constructed + ///@throws IOException if parser initialization fails due to I/O (read) problem + ///@throws JsonParseException if parser initialization fails due to content decoding problem + ///@deprecated Since 2.2, use \#createParser(Reader) instead. + JsonParser createJsonParser3(jni.JlObject r) => + JsonParser.fromRef(_createJsonParser3(reference, r.reference)); + + static final _createJsonParser4 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_createJsonParser4") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(byte[] data) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing parser for parsing the contents of given byte array. + ///@param data Input content to parse + ///@return Parser constructed + ///@throws IOException if parser initialization fails due to I/O (read) problem + ///@throws JsonParseException if parser initialization fails due to content decoding problem + ///@deprecated Since 2.2, use \#createParser(byte[]) instead. + JsonParser createJsonParser4(jni.JlObject data) => + JsonParser.fromRef(_createJsonParser4(reference, data.reference)); + + static final _createJsonParser5 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Int32, ffi.Int32)>>( + "com_fasterxml_jackson_core_JsonFactory_createJsonParser5") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, int, int)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(byte[] data, int offset, int len) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing parser for parsing + /// the contents of given byte array. + ///@param data Buffer that contains data to parse + ///@param offset Offset of the first data byte within buffer + ///@param len Length of contents to parse within buffer + ///@return Parser constructed + ///@throws IOException if parser initialization fails due to I/O (read) problem + ///@throws JsonParseException if parser initialization fails due to content decoding problem + ///@deprecated Since 2.2, use \#createParser(byte[],int,int) instead. + JsonParser createJsonParser5(jni.JlObject data, int offset, int len) => + JsonParser.fromRef( + _createJsonParser5(reference, data.reference, offset, len)); + + static final _createJsonParser6 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_createJsonParser6") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(java.lang.String content) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing parser for parsing + /// contents of given String. + ///@param content Input content to parse + ///@return Parser constructed + ///@throws IOException if parser initialization fails due to I/O (read) problem + ///@throws JsonParseException if parser initialization fails due to content decoding problem + ///@deprecated Since 2.2, use \#createParser(String) instead. + JsonParser createJsonParser6(jni.JlString content) => + JsonParser.fromRef(_createJsonParser6(reference, content.reference)); + + static final _createJsonGenerator = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_createJsonGenerator") + .asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonGenerator createJsonGenerator(java.io.OutputStream out, com.fasterxml.jackson.core.JsonEncoding enc) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing JSON generator for writing JSON content + /// using specified output stream. + /// Encoding to use must be specified, and needs to be one of available + /// types (as per JSON specification). + /// + /// Underlying stream __is NOT owned__ by the generator constructed, + /// so that generator will NOT close the output stream when + /// JsonGenerator\#close is called (unless auto-closing + /// feature, + /// com.fasterxml.jackson.core.JsonGenerator.Feature\#AUTO_CLOSE_TARGET + /// is enabled). + /// Using application needs to close it explicitly if this is the case. + /// + /// Note: there are formats that use fixed encoding (like most binary data formats) + /// and that ignore passed in encoding. + ///@param out OutputStream to use for writing JSON content + ///@param enc Character encoding to use + ///@return Generator constructed + ///@throws IOException if parser initialization fails due to I/O (write) problem + ///@deprecated Since 2.2, use \#createGenerator(OutputStream, JsonEncoding) instead. + jni.JlObject createJsonGenerator(jni.JlObject out, jni.JlObject enc) => + jni.JlObject.fromRef( + _createJsonGenerator(reference, out.reference, enc.reference)); + + static final _createJsonGenerator1 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_createJsonGenerator1") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonGenerator createJsonGenerator(java.io.Writer out) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing JSON generator for writing JSON content + /// using specified Writer. + /// + /// Underlying stream __is NOT owned__ by the generator constructed, + /// so that generator will NOT close the Reader when + /// JsonGenerator\#close is called (unless auto-closing + /// feature, + /// com.fasterxml.jackson.core.JsonGenerator.Feature\#AUTO_CLOSE_TARGET is enabled). + /// Using application needs to close it explicitly. + ///@param out Writer to use for writing JSON content + ///@return Generator constructed + ///@throws IOException if parser initialization fails due to I/O (write) problem + ///@deprecated Since 2.2, use \#createGenerator(Writer) instead. + jni.JlObject createJsonGenerator1(jni.JlObject out) => + jni.JlObject.fromRef(_createJsonGenerator1(reference, out.reference)); + + static final _createJsonGenerator2 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory_createJsonGenerator2") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonGenerator createJsonGenerator(java.io.OutputStream out) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Convenience method for constructing generator that uses default + /// encoding of the format (UTF-8 for JSON and most other data formats). + /// + /// Note: there are formats that use fixed encoding (like most binary data formats). + ///@param out OutputStream to use for writing JSON content + ///@return Generator constructed + ///@throws IOException if parser initialization fails due to I/O (write) problem + ///@deprecated Since 2.2, use \#createGenerator(OutputStream) instead. + jni.JlObject createJsonGenerator2(jni.JlObject out) => + jni.JlObject.fromRef(_createJsonGenerator2(reference, out.reference)); +} + +/// from: com.fasterxml.jackson.core.JsonFactory$Feature +/// +/// Enumeration that defines all on/off features that can only be +/// changed for JsonFactory. +class JsonFactory_Feature extends jni.JlObject { + JsonFactory_Feature.fromRef(ffi.Pointer ref) : super.fromRef(ref); + + static final _values = + jlookup Function()>>( + "com_fasterxml_jackson_core_JsonFactory__Feature_values") + .asFunction Function()>(); + + /// from: static public com.fasterxml.jackson.core.JsonFactory.Feature[] values() + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JlObject values() => jni.JlObject.fromRef(_values()); + + static final _valueOf = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonFactory__Feature_valueOf") + .asFunction Function(ffi.Pointer)>(); + + /// from: static public com.fasterxml.jackson.core.JsonFactory.Feature valueOf(java.lang.String name) + /// The returned object must be deleted after use, by calling the `delete` method. + static JsonFactory_Feature valueOf(jni.JlString name) => + JsonFactory_Feature.fromRef(_valueOf(name.reference)); + + static final _collectDefaults = + jlookup>( + "com_fasterxml_jackson_core_JsonFactory__Feature_collectDefaults") + .asFunction(); + + /// from: static public int collectDefaults() + /// + /// Method that calculates bit set (flags) of all features that + /// are enabled by default. + ///@return Bit field of features enabled by default + static int collectDefaults() => _collectDefaults(); + + static final _ctor = + jlookup Function(ffi.Uint8)>>( + "com_fasterxml_jackson_core_JsonFactory__Feature_ctor") + .asFunction Function(int)>(); + + /// from: private void (boolean defaultState) + JsonFactory_Feature(bool defaultState) + : super.fromRef(_ctor(defaultState ? 1 : 0)); + + static final _enabledByDefault = jlookup< + ffi.NativeFunction)>>( + "com_fasterxml_jackson_core_JsonFactory__Feature_enabledByDefault") + .asFunction)>(); + + /// from: public boolean enabledByDefault() + bool enabledByDefault() => _enabledByDefault(reference) != 0; + + static final _enabledIn = jlookup< + ffi.NativeFunction< + ffi.Uint8 Function(ffi.Pointer, ffi.Int32)>>( + "com_fasterxml_jackson_core_JsonFactory__Feature_enabledIn") + .asFunction, int)>(); + + /// from: public boolean enabledIn(int flags) + bool enabledIn(int flags) => _enabledIn(reference, flags) != 0; + + static final _getMask = + jlookup)>>( + "com_fasterxml_jackson_core_JsonFactory__Feature_getMask") + .asFunction)>(); + + /// from: public int getMask() + int getMask() => _getMask(reference); +} + +/// from: com.fasterxml.jackson.core.JsonParser +/// +/// Base class that defines public API for reading JSON content. +/// Instances are created using factory methods of +/// a JsonFactory instance. +///@author Tatu Saloranta +class JsonParser extends jni.JlObject { + JsonParser.fromRef(ffi.Pointer ref) : super.fromRef(ref); + + /// from: private static final int MIN_BYTE_I + static const MIN_BYTE_I = -128; + + /// from: private static final int MAX_BYTE_I + static const MAX_BYTE_I = 255; + + /// from: private static final int MIN_SHORT_I + static const MIN_SHORT_I = -32768; + + /// from: private static final int MAX_SHORT_I + static const MAX_SHORT_I = 32767; + + static final _getDEFAULT_READ_CAPABILITIES = jlookup< + ffi.NativeFunction Function()>>( + "get_com_fasterxml_jackson_core_JsonParser_DEFAULT_READ_CAPABILITIES") + .asFunction Function()>(); + + /// from: static protected final com.fasterxml.jackson.core.util.JacksonFeatureSet DEFAULT_READ_CAPABILITIES + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Default set of StreamReadCapabilityies that may be used as + /// basis for format-specific readers (or as bogus instance if non-null + /// set needs to be passed). + ///@since 2.12 + static jni.JlObject get DEFAULT_READ_CAPABILITIES => + jni.JlObject.fromRef(_getDEFAULT_READ_CAPABILITIES()); + + static final _ctor = + jlookup Function()>>( + "com_fasterxml_jackson_core_JsonParser_ctor") + .asFunction Function()>(); + + /// from: protected void () + JsonParser() : super.fromRef(_ctor()); + + static final _ctor1 = + jlookup Function(ffi.Int32)>>( + "com_fasterxml_jackson_core_JsonParser_ctor1") + .asFunction Function(int)>(); + + /// from: protected void (int features) + JsonParser.ctor1(int features) : super.fromRef(_ctor1(features)); + + static final _getCodec = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_getCodec") + .asFunction Function(ffi.Pointer)>(); + + /// from: public abstract com.fasterxml.jackson.core.ObjectCodec getCodec() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Accessor for ObjectCodec associated with this + /// parser, if any. Codec is used by \#readValueAs(Class) + /// method (and its variants). + ///@return Codec assigned to this parser, if any; {@code null} if none + jni.JlObject getCodec() => jni.JlObject.fromRef(_getCodec(reference)); + + static final _setCodec = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_setCodec") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: public abstract void setCodec(com.fasterxml.jackson.core.ObjectCodec oc) + /// + /// Setter that allows defining ObjectCodec associated with this + /// parser, if any. Codec is used by \#readValueAs(Class) + /// method (and its variants). + ///@param oc Codec to assign, if any; {@code null} if none + void setCodec(jni.JlObject oc) => _setCodec(reference, oc.reference); + + static final _getInputSource = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_getInputSource") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.lang.Object getInputSource() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that can be used to get access to object that is used + /// to access input being parsed; this is usually either + /// InputStream or Reader, depending on what + /// parser was constructed with. + /// Note that returned value may be null in some cases; including + /// case where parser implementation does not want to exposed raw + /// source to caller. + /// In cases where input has been decorated, object returned here + /// is the decorated version; this allows some level of interaction + /// between users of parser and decorator object. + /// + /// In general use of this accessor should be considered as + /// "last effort", i.e. only used if no other mechanism is applicable. + ///@return Input source this parser was configured with + jni.JlObject getInputSource() => + jni.JlObject.fromRef(_getInputSource(reference)); + + static final _setRequestPayloadOnError = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_setRequestPayloadOnError") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: public void setRequestPayloadOnError(com.fasterxml.jackson.core.util.RequestPayload payload) + /// + /// Sets the payload to be passed if JsonParseException is thrown. + ///@param payload Payload to pass + ///@since 2.8 + void setRequestPayloadOnError(jni.JlObject payload) => + _setRequestPayloadOnError(reference, payload.reference); + + static final _setRequestPayloadOnError1 = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_setRequestPayloadOnError1") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + /// from: public void setRequestPayloadOnError(byte[] payload, java.lang.String charset) + /// + /// Sets the byte[] request payload and the charset + ///@param payload Payload to pass + ///@param charset Character encoding for (lazily) decoding payload + ///@since 2.8 + void setRequestPayloadOnError1(jni.JlObject payload, jni.JlString charset) => + _setRequestPayloadOnError1( + reference, payload.reference, charset.reference); + + static final _setRequestPayloadOnError2 = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_setRequestPayloadOnError2") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: public void setRequestPayloadOnError(java.lang.String payload) + /// + /// Sets the String request payload + ///@param payload Payload to pass + ///@since 2.8 + void setRequestPayloadOnError2(jni.JlString payload) => + _setRequestPayloadOnError2(reference, payload.reference); + + static final _setSchema = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_setSchema") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: public void setSchema(com.fasterxml.jackson.core.FormatSchema schema) + /// + /// Method to call to make this parser use specified schema. Method must + /// be called before trying to parse any content, right after parser instance + /// has been created. + /// Note that not all parsers support schemas; and those that do usually only + /// accept specific types of schemas: ones defined for data format parser can read. + /// + /// If parser does not support specified schema, UnsupportedOperationException + /// is thrown. + ///@param schema Schema to use + ///@throws UnsupportedOperationException if parser does not support schema + void setSchema(jni.JlObject schema) => + _setSchema(reference, schema.reference); + + static final _getSchema = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_getSchema") + .asFunction Function(ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.FormatSchema getSchema() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for accessing Schema that this parser uses, if any. + /// Default implementation returns null. + ///@return Schema in use by this parser, if any; {@code null} if none + ///@since 2.1 + jni.JlObject getSchema() => jni.JlObject.fromRef(_getSchema(reference)); + + static final _canUseSchema = jlookup< + ffi.NativeFunction< + ffi.Uint8 Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_canUseSchema") + .asFunction, ffi.Pointer)>(); + + /// from: public boolean canUseSchema(com.fasterxml.jackson.core.FormatSchema schema) + /// + /// Method that can be used to verify that given schema can be used with + /// this parser (using \#setSchema). + ///@param schema Schema to check + ///@return True if this parser can use given schema; false if not + bool canUseSchema(jni.JlObject schema) => + _canUseSchema(reference, schema.reference) != 0; + + static final _requiresCustomCodec = + jlookup)>>( + "com_fasterxml_jackson_core_JsonParser_requiresCustomCodec") + .asFunction)>(); + + /// from: public boolean requiresCustomCodec() + /// + /// Method that can be called to determine if a custom + /// ObjectCodec is needed for binding data parsed + /// using JsonParser constructed by this factory + /// (which typically also implies the same for serialization + /// with JsonGenerator). + ///@return True if format-specific codec is needed with this parser; false if a general + /// ObjectCodec is enough + ///@since 2.1 + bool requiresCustomCodec() => _requiresCustomCodec(reference) != 0; + + static final _canParseAsync = + jlookup)>>( + "com_fasterxml_jackson_core_JsonParser_canParseAsync") + .asFunction)>(); + + /// from: public boolean canParseAsync() + /// + /// Method that can be called to determine if this parser instance + /// uses non-blocking ("asynchronous") input access for decoding or not. + /// Access mode is determined by earlier calls via JsonFactory; + /// it may not be changed after construction. + /// + /// If non-blocking decoding is (@code true}, it is possible to call + /// \#getNonBlockingInputFeeder() to obtain object to use + /// for feeding input; otherwise (false returned) + /// input is read by blocking + ///@return True if this is a non-blocking ("asynchronous") parser + ///@since 2.9 + bool canParseAsync() => _canParseAsync(reference) != 0; + + static final _getNonBlockingInputFeeder = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_getNonBlockingInputFeeder") + .asFunction Function(ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.async.NonBlockingInputFeeder getNonBlockingInputFeeder() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that will either return a feeder instance (if parser uses + /// non-blocking, aka asynchronous access); or null for + /// parsers that use blocking I/O. + ///@return Input feeder to use with non-blocking (async) parsing + ///@since 2.9 + jni.JlObject getNonBlockingInputFeeder() => + jni.JlObject.fromRef(_getNonBlockingInputFeeder(reference)); + + static final _getReadCapabilities = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_getReadCapabilities") + .asFunction Function(ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.util.JacksonFeatureSet getReadCapabilities() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Accessor for getting metadata on capabilities of this parser, based on + /// underlying data format being read (directly or indirectly). + ///@return Set of read capabilities for content to read via this parser + ///@since 2.12 + jni.JlObject getReadCapabilities() => + jni.JlObject.fromRef(_getReadCapabilities(reference)); + + static final _version = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_version") + .asFunction Function(ffi.Pointer)>(); + + /// from: public abstract com.fasterxml.jackson.core.Version version() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Accessor for getting version of the core package, given a parser instance. + /// Left for sub-classes to implement. + ///@return Version of this generator (derived from version declared for + /// {@code jackson-core} jar that contains the class + jni.JlObject version() => jni.JlObject.fromRef(_version(reference)); + + static final _close = + jlookup)>>( + "com_fasterxml_jackson_core_JsonParser_close") + .asFunction)>(); + + /// from: public abstract void close() + /// + /// Closes the parser so that no further iteration or data access + /// can be made; will also close the underlying input source + /// if parser either __owns__ the input source, or feature + /// Feature\#AUTO_CLOSE_SOURCE is enabled. + /// Whether parser owns the input source depends on factory + /// method that was used to construct instance (so check + /// com.fasterxml.jackson.core.JsonFactory for details, + /// but the general + /// idea is that if caller passes in closable resource (such + /// as InputStream or Reader) parser does NOT + /// own the source; but if it passes a reference (such as + /// java.io.File or java.net.URL and creates + /// stream or reader it does own them. + ///@throws IOException if there is either an underlying I/O problem + void close() => _close(reference); + + static final _isClosed = + jlookup)>>( + "com_fasterxml_jackson_core_JsonParser_isClosed") + .asFunction)>(); + + /// from: public abstract boolean isClosed() + /// + /// Method that can be called to determine whether this parser + /// is closed or not. If it is closed, no new tokens can be + /// retrieved by calling \#nextToken (and the underlying + /// stream may be closed). Closing may be due to an explicit + /// call to \#close or because parser has encountered + /// end of input. + ///@return {@code True} if this parser instance has been closed + bool isClosed() => _isClosed(reference) != 0; + + static final _getParsingContext = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_getParsingContext") + .asFunction Function(ffi.Pointer)>(); + + /// from: public abstract com.fasterxml.jackson.core.JsonStreamContext getParsingContext() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that can be used to access current parsing context reader + /// is in. There are 3 different types: root, array and object contexts, + /// with slightly different available information. Contexts are + /// hierarchically nested, and can be used for example for figuring + /// out part of the input document that correspond to specific + /// array or object (for highlighting purposes, or error reporting). + /// Contexts can also be used for simple xpath-like matching of + /// input, if so desired. + ///@return Stream input context (JsonStreamContext) associated with this parser + jni.JlObject getParsingContext() => + jni.JlObject.fromRef(_getParsingContext(reference)); + + static final _currentLocation = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_currentLocation") + .asFunction Function(ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonLocation currentLocation() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that returns location of the last processed input unit (character + /// or byte) from the input; + /// usually for error reporting purposes. + /// + /// Note that the location is not guaranteed to be accurate (although most + /// implementation will try their best): some implementations may only + /// report specific boundary locations (start or end locations of tokens) + /// and others only return JsonLocation\#NA due to not having access + /// to input location information (when delegating actual decoding work + /// to other library) + ///@return Location of the last processed input unit (byte or character) + ///@since 2.13 + jni.JlObject currentLocation() => + jni.JlObject.fromRef(_currentLocation(reference)); + + static final _currentTokenLocation = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_currentTokenLocation") + .asFunction Function(ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonLocation currentTokenLocation() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that return the __starting__ location of the current + /// (most recently returned) + /// token; that is, the position of the first input unit (character or byte) from input + /// that starts the current token. + /// + /// Note that the location is not guaranteed to be accurate (although most + /// implementation will try their best): some implementations may only + /// return JsonLocation\#NA due to not having access + /// to input location information (when delegating actual decoding work + /// to other library) + ///@return Starting location of the token parser currently points to + ///@since 2.13 (will eventually replace \#getTokenLocation) + jni.JlObject currentTokenLocation() => + jni.JlObject.fromRef(_currentTokenLocation(reference)); + + static final _getCurrentLocation = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_getCurrentLocation") + .asFunction Function(ffi.Pointer)>(); + + /// from: public abstract com.fasterxml.jackson.core.JsonLocation getCurrentLocation() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Alias for \#currentLocation(), to be deprecated in later + /// Jackson 2.x versions (and removed from Jackson 3.0). + ///@return Location of the last processed input unit (byte or character) + jni.JlObject getCurrentLocation() => + jni.JlObject.fromRef(_getCurrentLocation(reference)); + + static final _getTokenLocation = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_getTokenLocation") + .asFunction Function(ffi.Pointer)>(); + + /// from: public abstract com.fasterxml.jackson.core.JsonLocation getTokenLocation() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Alias for \#currentTokenLocation(), to be deprecated in later + /// Jackson 2.x versions (and removed from Jackson 3.0). + ///@return Starting location of the token parser currently points to + jni.JlObject getTokenLocation() => + jni.JlObject.fromRef(_getTokenLocation(reference)); + + static final _currentValue = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_currentValue") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.lang.Object currentValue() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Helper method, usually equivalent to: + /// + /// getParsingContext().getCurrentValue(); + /// + /// + /// Note that "current value" is NOT populated (or used) by Streaming parser; + /// it is only used by higher-level data-binding functionality. + /// The reason it is included here is that it can be stored and accessed hierarchically, + /// and gets passed through data-binding. + ///@return "Current value" associated with the current input context (state) of this parser + ///@since 2.13 (added as replacement for older \#getCurrentValue() + jni.JlObject currentValue() => jni.JlObject.fromRef(_currentValue(reference)); + + static final _assignCurrentValue = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_assignCurrentValue") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: public void assignCurrentValue(java.lang.Object v) + /// + /// Helper method, usually equivalent to: + /// + /// getParsingContext().setCurrentValue(v); + /// + ///@param v Current value to assign for the current input context of this parser + ///@since 2.13 (added as replacement for older \#setCurrentValue + void assignCurrentValue(jni.JlObject v) => + _assignCurrentValue(reference, v.reference); + + static final _getCurrentValue = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_getCurrentValue") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.lang.Object getCurrentValue() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Alias for \#currentValue(), to be deprecated in later + /// Jackson 2.x versions (and removed from Jackson 3.0). + ///@return Location of the last processed input unit (byte or character) + jni.JlObject getCurrentValue() => + jni.JlObject.fromRef(_getCurrentValue(reference)); + + static final _setCurrentValue = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_setCurrentValue") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: public void setCurrentValue(java.lang.Object v) + /// + /// Alias for \#assignCurrentValue, to be deprecated in later + /// Jackson 2.x versions (and removed from Jackson 3.0). + ///@param v Current value to assign for the current input context of this parser + void setCurrentValue(jni.JlObject v) => + _setCurrentValue(reference, v.reference); + + static final _releaseBuffered = jlookup< + ffi.NativeFunction< + ffi.Int32 Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_releaseBuffered") + .asFunction, ffi.Pointer)>(); + + /// from: public int releaseBuffered(java.io.OutputStream out) + /// + /// Method that can be called to push back any content that + /// has been read but not consumed by the parser. This is usually + /// done after reading all content of interest using parser. + /// Content is released by writing it to given stream if possible; + /// if underlying input is byte-based it can released, if not (char-based) + /// it can not. + ///@param out OutputStream to which buffered, undecoded content is written to + ///@return -1 if the underlying content source is not byte based + /// (that is, input can not be sent to OutputStream; + /// otherwise number of bytes released (0 if there was nothing to release) + ///@throws IOException if write to stream threw exception + int releaseBuffered(jni.JlObject out) => + _releaseBuffered(reference, out.reference); + + static final _releaseBuffered1 = jlookup< + ffi.NativeFunction< + ffi.Int32 Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_releaseBuffered1") + .asFunction, ffi.Pointer)>(); + + /// from: public int releaseBuffered(java.io.Writer w) + /// + /// Method that can be called to push back any content that + /// has been read but not consumed by the parser. + /// This is usually + /// done after reading all content of interest using parser. + /// Content is released by writing it to given writer if possible; + /// if underlying input is char-based it can released, if not (byte-based) + /// it can not. + ///@param w Writer to which buffered but unprocessed content is written to + ///@return -1 if the underlying content source is not char-based + /// (that is, input can not be sent to Writer; + /// otherwise number of chars released (0 if there was nothing to release) + ///@throws IOException if write using Writer threw exception + int releaseBuffered1(jni.JlObject w) => + _releaseBuffered1(reference, w.reference); + + static final _enable = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_enable") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser enable(com.fasterxml.jackson.core.JsonParser.Feature f) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for enabling specified parser feature + /// (check Feature for list of features) + ///@param f Feature to enable + ///@return This parser, to allow call chaining + JsonParser enable(JsonParser_Feature f) => + JsonParser.fromRef(_enable(reference, f.reference)); + + static final _disable = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_disable") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser disable(com.fasterxml.jackson.core.JsonParser.Feature f) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for disabling specified feature + /// (check Feature for list of features) + ///@param f Feature to disable + ///@return This parser, to allow call chaining + JsonParser disable(JsonParser_Feature f) => + JsonParser.fromRef(_disable(reference, f.reference)); + + static final _configure = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Uint8)>>( + "com_fasterxml_jackson_core_JsonParser_configure") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, int)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser configure(com.fasterxml.jackson.core.JsonParser.Feature f, boolean state) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for enabling or disabling specified feature + /// (check Feature for list of features) + ///@param f Feature to enable or disable + ///@param state Whether to enable feature ({@code true}) or disable ({@code false}) + ///@return This parser, to allow call chaining + JsonParser configure(JsonParser_Feature f, bool state) => + JsonParser.fromRef(_configure(reference, f.reference, state ? 1 : 0)); + + static final _isEnabled = jlookup< + ffi.NativeFunction< + ffi.Uint8 Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_isEnabled") + .asFunction, ffi.Pointer)>(); + + /// from: public boolean isEnabled(com.fasterxml.jackson.core.JsonParser.Feature f) + /// + /// Method for checking whether specified Feature is enabled. + ///@param f Feature to check + ///@return {@code True} if feature is enabled; {@code false} otherwise + bool isEnabled(JsonParser_Feature f) => + _isEnabled(reference, f.reference) != 0; + + static final _isEnabled1 = jlookup< + ffi.NativeFunction< + ffi.Uint8 Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_isEnabled1") + .asFunction, ffi.Pointer)>(); + + /// from: public boolean isEnabled(com.fasterxml.jackson.core.StreamReadFeature f) + /// + /// Method for checking whether specified Feature is enabled. + ///@param f Feature to check + ///@return {@code True} if feature is enabled; {@code false} otherwise + ///@since 2.10 + bool isEnabled1(jni.JlObject f) => _isEnabled1(reference, f.reference) != 0; + + static final _getFeatureMask = + jlookup)>>( + "com_fasterxml_jackson_core_JsonParser_getFeatureMask") + .asFunction)>(); + + /// from: public int getFeatureMask() + /// + /// Bulk access method for getting state of all standard Features. + ///@return Bit mask that defines current states of all standard Features. + ///@since 2.3 + int getFeatureMask() => _getFeatureMask(reference); + + static final _setFeatureMask = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Int32)>>( + "com_fasterxml_jackson_core_JsonParser_setFeatureMask") + .asFunction Function(ffi.Pointer, int)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser setFeatureMask(int mask) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Bulk set method for (re)setting states of all standard Features + ///@param mask Bit mask that defines set of features to enable + ///@return This parser, to allow call chaining + ///@since 2.3 + ///@deprecated Since 2.7, use \#overrideStdFeatures(int, int) instead + JsonParser setFeatureMask(int mask) => + JsonParser.fromRef(_setFeatureMask(reference, mask)); + + static final _overrideStdFeatures = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Int32, ffi.Int32)>>( + "com_fasterxml_jackson_core_JsonParser_overrideStdFeatures") + .asFunction< + ffi.Pointer Function(ffi.Pointer, int, int)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser overrideStdFeatures(int values, int mask) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Bulk set method for (re)setting states of features specified by mask. + /// Functionally equivalent to + /// + /// int oldState = getFeatureMask(); + /// int newState = (oldState & ~mask) | (values & mask); + /// setFeatureMask(newState); + /// + /// but preferred as this lets caller more efficiently specify actual changes made. + ///@param values Bit mask of set/clear state for features to change + ///@param mask Bit mask of features to change + ///@return This parser, to allow call chaining + ///@since 2.6 + JsonParser overrideStdFeatures(int values, int mask) => + JsonParser.fromRef(_overrideStdFeatures(reference, values, mask)); + + static final _getFormatFeatures = + jlookup)>>( + "com_fasterxml_jackson_core_JsonParser_getFormatFeatures") + .asFunction)>(); + + /// from: public int getFormatFeatures() + /// + /// Bulk access method for getting state of all FormatFeatures, format-specific + /// on/off configuration settings. + ///@return Bit mask that defines current states of all standard FormatFeatures. + ///@since 2.6 + int getFormatFeatures() => _getFormatFeatures(reference); + + static final _overrideFormatFeatures = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Int32, ffi.Int32)>>( + "com_fasterxml_jackson_core_JsonParser_overrideFormatFeatures") + .asFunction< + ffi.Pointer Function(ffi.Pointer, int, int)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser overrideFormatFeatures(int values, int mask) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Bulk set method for (re)setting states of FormatFeatures, + /// by specifying values (set / clear) along with a mask, to determine + /// which features to change, if any. + /// + /// Default implementation will simply throw an exception to indicate that + /// the parser implementation does not support any FormatFeatures. + ///@param values Bit mask of set/clear state for features to change + ///@param mask Bit mask of features to change + ///@return This parser, to allow call chaining + ///@since 2.6 + JsonParser overrideFormatFeatures(int values, int mask) => + JsonParser.fromRef(_overrideFormatFeatures(reference, values, mask)); + + static final _nextToken = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_nextToken") + .asFunction Function(ffi.Pointer)>(); + + /// from: public abstract com.fasterxml.jackson.core.JsonToken nextToken() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Main iteration method, which will advance stream enough + /// to determine type of the next token, if any. If none + /// remaining (stream has no content other than possible + /// white space before ending), null will be returned. + ///@return Next token from the stream, if any found, or null + /// to indicate end-of-input + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + JsonToken nextToken() => JsonToken.fromRef(_nextToken(reference)); + + static final _nextValue = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_nextValue") + .asFunction Function(ffi.Pointer)>(); + + /// from: public abstract com.fasterxml.jackson.core.JsonToken nextValue() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Iteration method that will advance stream enough + /// to determine type of the next token that is a value type + /// (including JSON Array and Object start/end markers). + /// Or put another way, nextToken() will be called once, + /// and if JsonToken\#FIELD_NAME is returned, another + /// time to get the value for the field. + /// Method is most useful for iterating over value entries + /// of JSON objects; field name will still be available + /// by calling \#getCurrentName when parser points to + /// the value. + ///@return Next non-field-name token from the stream, if any found, + /// or null to indicate end-of-input (or, for non-blocking + /// parsers, JsonToken\#NOT_AVAILABLE if no tokens were + /// available yet) + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + JsonToken nextValue() => JsonToken.fromRef(_nextValue(reference)); + + static final _nextFieldName = jlookup< + ffi.NativeFunction< + ffi.Uint8 Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_nextFieldName") + .asFunction, ffi.Pointer)>(); + + /// from: public boolean nextFieldName(com.fasterxml.jackson.core.SerializableString str) + /// + /// Method that fetches next token (as if calling \#nextToken) and + /// verifies whether it is JsonToken\#FIELD_NAME with specified name + /// and returns result of that comparison. + /// It is functionally equivalent to: + ///
+  ///  return (nextToken() == JsonToken.FIELD_NAME) && str.getValue().equals(getCurrentName());
+  ///
+ /// but may be faster for parser to verify, and can therefore be used if caller + /// expects to get such a property name from input next. + ///@param str Property name to compare next token to (if next token is + /// JsonToken.FIELD_NAME) + ///@return {@code True} if parser advanced to {@code JsonToken.FIELD_NAME} with + /// specified name; {@code false} otherwise (different token or non-matching name) + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + bool nextFieldName(jni.JlObject str) => + _nextFieldName(reference, str.reference) != 0; + + static final _nextFieldName1 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_nextFieldName1") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.lang.String nextFieldName() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that fetches next token (as if calling \#nextToken) and + /// verifies whether it is JsonToken\#FIELD_NAME; if it is, + /// returns same as \#getCurrentName(), otherwise null. + ///@return Name of the the {@code JsonToken.FIELD_NAME} parser advanced to, if any; + /// {@code null} if next token is of some other type + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + ///@since 2.5 + jni.JlString nextFieldName1() => + jni.JlString.fromRef(_nextFieldName1(reference)); + + static final _nextTextValue = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_nextTextValue") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.lang.String nextTextValue() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that fetches next token (as if calling \#nextToken) and + /// if it is JsonToken\#VALUE_STRING returns contained String value; + /// otherwise returns null. + /// It is functionally equivalent to: + ///
+  ///  return (nextToken() == JsonToken.VALUE_STRING) ? getText() : null;
+  ///
+ /// but may be faster for parser to process, and can therefore be used if caller + /// expects to get a String value next from input. + ///@return Text value of the {@code JsonToken.VALUE_STRING} token parser advanced + /// to; or {@code null} if next token is of some other type + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + jni.JlString nextTextValue() => + jni.JlString.fromRef(_nextTextValue(reference)); + + static final _nextIntValue = jlookup< + ffi.NativeFunction< + ffi.Int32 Function(ffi.Pointer, ffi.Int32)>>( + "com_fasterxml_jackson_core_JsonParser_nextIntValue") + .asFunction, int)>(); + + /// from: public int nextIntValue(int defaultValue) + /// + /// Method that fetches next token (as if calling \#nextToken) and + /// if it is JsonToken\#VALUE_NUMBER_INT returns 32-bit int value; + /// otherwise returns specified default value + /// It is functionally equivalent to: + ///
+  ///  return (nextToken() == JsonToken.VALUE_NUMBER_INT) ? getIntValue() : defaultValue;
+  ///
+ /// but may be faster for parser to process, and can therefore be used if caller + /// expects to get an int value next from input. + /// + /// NOTE: value checks are performed similar to \#getIntValue() + ///@param defaultValue Value to return if next token is NOT of type {@code JsonToken.VALUE_NUMBER_INT} + ///@return Integer ({@code int}) value of the {@code JsonToken.VALUE_NUMBER_INT} token parser advanced + /// to; or {@code defaultValue} if next token is of some other type + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + ///@throws InputCoercionException if integer number does not fit in Java {@code int} + int nextIntValue(int defaultValue) => _nextIntValue(reference, defaultValue); + + static final _nextLongValue = jlookup< + ffi.NativeFunction< + ffi.Int64 Function(ffi.Pointer, ffi.Int64)>>( + "com_fasterxml_jackson_core_JsonParser_nextLongValue") + .asFunction, int)>(); + + /// from: public long nextLongValue(long defaultValue) + /// + /// Method that fetches next token (as if calling \#nextToken) and + /// if it is JsonToken\#VALUE_NUMBER_INT returns 64-bit long value; + /// otherwise returns specified default value + /// It is functionally equivalent to: + ///
+  ///  return (nextToken() == JsonToken.VALUE_NUMBER_INT) ? getLongValue() : defaultValue;
+  ///
+ /// but may be faster for parser to process, and can therefore be used if caller + /// expects to get a long value next from input. + /// + /// NOTE: value checks are performed similar to \#getLongValue() + ///@param defaultValue Value to return if next token is NOT of type {@code JsonToken.VALUE_NUMBER_INT} + ///@return {@code long} value of the {@code JsonToken.VALUE_NUMBER_INT} token parser advanced + /// to; or {@code defaultValue} if next token is of some other type + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + ///@throws InputCoercionException if integer number does not fit in Java {@code long} + int nextLongValue(int defaultValue) => + _nextLongValue(reference, defaultValue); + + static final _nextBooleanValue = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_nextBooleanValue") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.lang.Boolean nextBooleanValue() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that fetches next token (as if calling \#nextToken) and + /// if it is JsonToken\#VALUE_TRUE or JsonToken\#VALUE_FALSE + /// returns matching Boolean value; otherwise return null. + /// It is functionally equivalent to: + ///
+  ///  JsonToken t = nextToken();
+  ///  if (t == JsonToken.VALUE_TRUE) return Boolean.TRUE;
+  ///  if (t == JsonToken.VALUE_FALSE) return Boolean.FALSE;
+  ///  return null;
+  ///
+ /// but may be faster for parser to process, and can therefore be used if caller + /// expects to get a Boolean value next from input. + ///@return {@code Boolean} value of the {@code JsonToken.VALUE_TRUE} or {@code JsonToken.VALUE_FALSE} + /// token parser advanced to; or {@code null} if next token is of some other type + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + jni.JlObject nextBooleanValue() => + jni.JlObject.fromRef(_nextBooleanValue(reference)); + + static final _skipChildren = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_skipChildren") + .asFunction Function(ffi.Pointer)>(); + + /// from: public abstract com.fasterxml.jackson.core.JsonParser skipChildren() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that will skip all child tokens of an array or + /// object token that the parser currently points to, + /// iff stream points to + /// JsonToken\#START_OBJECT or JsonToken\#START_ARRAY. + /// If not, it will do nothing. + /// After skipping, stream will point to __matching__ + /// JsonToken\#END_OBJECT or JsonToken\#END_ARRAY + /// (possibly skipping nested pairs of START/END OBJECT/ARRAY tokens + /// as well as value tokens). + /// The idea is that after calling this method, application + /// will call \#nextToken to point to the next + /// available token, if any. + ///@return This parser, to allow call chaining + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + JsonParser skipChildren() => JsonParser.fromRef(_skipChildren(reference)); + + static final _finishToken = + jlookup)>>( + "com_fasterxml_jackson_core_JsonParser_finishToken") + .asFunction)>(); + + /// from: public void finishToken() + /// + /// Method that may be used to force full handling of the current token + /// so that even if lazy processing is enabled, the whole contents are + /// read for possible retrieval. This is usually used to ensure that + /// the token end location is available, as well as token contents + /// (similar to what calling, say \#getTextCharacters(), would + /// achieve). + /// + /// Note that for many dataformat implementations this method + /// will not do anything; this is the default implementation unless + /// overridden by sub-classes. + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + ///@since 2.8 + void finishToken() => _finishToken(reference); + + static final _currentToken = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_currentToken") + .asFunction Function(ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonToken currentToken() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Accessor to find which token parser currently points to, if any; + /// null will be returned if none. + /// If return value is non-null, data associated with the token + /// is available via other accessor methods. + ///@return Type of the token this parser currently points to, + /// if any: null before any tokens have been read, and + /// after end-of-input has been encountered, as well as + /// if the current token has been explicitly cleared. + ///@since 2.8 + JsonToken currentToken() => JsonToken.fromRef(_currentToken(reference)); + + static final _currentTokenId = + jlookup)>>( + "com_fasterxml_jackson_core_JsonParser_currentTokenId") + .asFunction)>(); + + /// from: public int currentTokenId() + /// + /// Method similar to \#getCurrentToken() but that returns an + /// int instead of JsonToken (enum value). + /// + /// Use of int directly is typically more efficient on switch statements, + /// so this method may be useful when building low-overhead codecs. + /// Note, however, that effect may not be big enough to matter: make sure + /// to profile performance before deciding to use this method. + ///@since 2.8 + ///@return {@code int} matching one of constants from JsonTokenId. + int currentTokenId() => _currentTokenId(reference); + + static final _getCurrentToken = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_getCurrentToken") + .asFunction Function(ffi.Pointer)>(); + + /// from: public abstract com.fasterxml.jackson.core.JsonToken getCurrentToken() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Alias for \#currentToken(), may be deprecated sometime after + /// Jackson 2.13 (will be removed from 3.0). + ///@return Type of the token this parser currently points to, + /// if any: null before any tokens have been read, and + JsonToken getCurrentToken() => JsonToken.fromRef(_getCurrentToken(reference)); + + static final _getCurrentTokenId = + jlookup)>>( + "com_fasterxml_jackson_core_JsonParser_getCurrentTokenId") + .asFunction)>(); + + /// from: public abstract int getCurrentTokenId() + /// + /// Deprecated alias for \#currentTokenId(). + ///@return {@code int} matching one of constants from JsonTokenId. + ///@deprecated Since 2.12 use \#currentTokenId instead + int getCurrentTokenId() => _getCurrentTokenId(reference); + + static final _hasCurrentToken = + jlookup)>>( + "com_fasterxml_jackson_core_JsonParser_hasCurrentToken") + .asFunction)>(); + + /// from: public abstract boolean hasCurrentToken() + /// + /// Method for checking whether parser currently points to + /// a token (and data for that token is available). + /// Equivalent to check for parser.getCurrentToken() != null. + ///@return True if the parser just returned a valid + /// token via \#nextToken; false otherwise (parser + /// was just constructed, encountered end-of-input + /// and returned null from \#nextToken, or the token + /// has been consumed) + bool hasCurrentToken() => _hasCurrentToken(reference) != 0; + + static final _hasTokenId = jlookup< + ffi.NativeFunction< + ffi.Uint8 Function(ffi.Pointer, ffi.Int32)>>( + "com_fasterxml_jackson_core_JsonParser_hasTokenId") + .asFunction, int)>(); + + /// from: public abstract boolean hasTokenId(int id) + /// + /// Method that is functionally equivalent to: + /// + /// return currentTokenId() == id + /// + /// but may be more efficiently implemented. + /// + /// Note that no traversal or conversion is performed; so in some + /// cases calling method like \#isExpectedStartArrayToken() + /// is necessary instead. + ///@param id Token id to match (from (@link JsonTokenId}) + ///@return {@code True} if the parser current points to specified token + ///@since 2.5 + bool hasTokenId(int id) => _hasTokenId(reference, id) != 0; + + static final _hasToken = jlookup< + ffi.NativeFunction< + ffi.Uint8 Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_hasToken") + .asFunction, ffi.Pointer)>(); + + /// from: public abstract boolean hasToken(com.fasterxml.jackson.core.JsonToken t) + /// + /// Method that is functionally equivalent to: + /// + /// return currentToken() == t + /// + /// but may be more efficiently implemented. + /// + /// Note that no traversal or conversion is performed; so in some + /// cases calling method like \#isExpectedStartArrayToken() + /// is necessary instead. + ///@param t Token to match + ///@return {@code True} if the parser current points to specified token + ///@since 2.6 + bool hasToken(JsonToken t) => _hasToken(reference, t.reference) != 0; + + static final _isExpectedStartArrayToken = + jlookup)>>( + "com_fasterxml_jackson_core_JsonParser_isExpectedStartArrayToken") + .asFunction)>(); + + /// from: public boolean isExpectedStartArrayToken() + /// + /// Specialized accessor that can be used to verify that the current + /// token indicates start array (usually meaning that current token + /// is JsonToken\#START_ARRAY) when start array is expected. + /// For some specialized parsers this can return true for other cases + /// as well; this is usually done to emulate arrays in cases underlying + /// format is ambiguous (XML, for example, has no format-level difference + /// between Objects and Arrays; it just has elements). + /// + /// Default implementation is equivalent to: + ///
+  ///   currentToken() == JsonToken.START_ARRAY
+  ///
+ /// but may be overridden by custom parser implementations. + ///@return True if the current token can be considered as a + /// start-array marker (such JsonToken\#START_ARRAY); + /// {@code false} if not + bool isExpectedStartArrayToken() => + _isExpectedStartArrayToken(reference) != 0; + + static final _isExpectedStartObjectToken = jlookup< + ffi.NativeFunction)>>( + "com_fasterxml_jackson_core_JsonParser_isExpectedStartObjectToken") + .asFunction)>(); + + /// from: public boolean isExpectedStartObjectToken() + /// + /// Similar to \#isExpectedStartArrayToken(), but checks whether stream + /// currently points to JsonToken\#START_OBJECT. + ///@return True if the current token can be considered as a + /// start-array marker (such JsonToken\#START_OBJECT); + /// {@code false} if not + ///@since 2.5 + bool isExpectedStartObjectToken() => + _isExpectedStartObjectToken(reference) != 0; + + static final _isExpectedNumberIntToken = + jlookup)>>( + "com_fasterxml_jackson_core_JsonParser_isExpectedNumberIntToken") + .asFunction)>(); + + /// from: public boolean isExpectedNumberIntToken() + /// + /// Similar to \#isExpectedStartArrayToken(), but checks whether stream + /// currently points to JsonToken\#VALUE_NUMBER_INT. + /// + /// The initial use case is for XML backend to efficiently (attempt to) coerce + /// textual content into numbers. + ///@return True if the current token can be considered as a + /// start-array marker (such JsonToken\#VALUE_NUMBER_INT); + /// {@code false} if not + ///@since 2.12 + bool isExpectedNumberIntToken() => _isExpectedNumberIntToken(reference) != 0; + + static final _isNaN = + jlookup)>>( + "com_fasterxml_jackson_core_JsonParser_isNaN") + .asFunction)>(); + + /// from: public boolean isNaN() + /// + /// Access for checking whether current token is a numeric value token, but + /// one that is of "not-a-number" (NaN) variety (including both "NaN" AND + /// positive/negative infinity!): not supported by all formats, + /// but often supported for JsonToken\#VALUE_NUMBER_FLOAT. + /// NOTE: roughly equivalent to calling !Double.isFinite() + /// on value you would get from calling \#getDoubleValue(). + ///@return {@code True} if the current token is of type JsonToken\#VALUE_NUMBER_FLOAT + /// but represents a "Not a Number"; {@code false} for other tokens and regular + /// floating-point numbers + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + ///@since 2.9 + bool isNaN() => _isNaN(reference) != 0; + + static final _clearCurrentToken = + jlookup)>>( + "com_fasterxml_jackson_core_JsonParser_clearCurrentToken") + .asFunction)>(); + + /// from: public abstract void clearCurrentToken() + /// + /// Method called to "consume" the current token by effectively + /// removing it so that \#hasCurrentToken returns false, and + /// \#getCurrentToken null). + /// Cleared token value can still be accessed by calling + /// \#getLastClearedToken (if absolutely needed), but + /// usually isn't. + /// + /// Method was added to be used by the optional data binder, since + /// it has to be able to consume last token used for binding (so that + /// it will not be used again). + void clearCurrentToken() => _clearCurrentToken(reference); + + static final _getLastClearedToken = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_getLastClearedToken") + .asFunction Function(ffi.Pointer)>(); + + /// from: public abstract com.fasterxml.jackson.core.JsonToken getLastClearedToken() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that can be called to get the last token that was + /// cleared using \#clearCurrentToken. This is not necessarily + /// the latest token read. + /// Will return null if no tokens have been cleared, + /// or if parser has been closed. + ///@return Last cleared token, if any; {@code null} otherwise + JsonToken getLastClearedToken() => + JsonToken.fromRef(_getLastClearedToken(reference)); + + static final _overrideCurrentName = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_overrideCurrentName") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: public abstract void overrideCurrentName(java.lang.String name) + /// + /// Method that can be used to change what is considered to be + /// the current (field) name. + /// May be needed to support non-JSON data formats or unusual binding + /// conventions; not needed for typical processing. + /// + /// Note that use of this method should only be done as sort of last + /// resort, as it is a work-around for regular operation. + ///@param name Name to use as the current name; may be null. + void overrideCurrentName(jni.JlString name) => + _overrideCurrentName(reference, name.reference); + + static final _getCurrentName = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_getCurrentName") + .asFunction Function(ffi.Pointer)>(); + + /// from: public abstract java.lang.String getCurrentName() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Alias of \#currentName(). + ///@return Name of the current field in the parsing context + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + jni.JlString getCurrentName() => + jni.JlString.fromRef(_getCurrentName(reference)); + + static final _currentName = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_currentName") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.lang.String currentName() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that can be called to get the name associated with + /// the current token: for JsonToken\#FIELD_NAMEs it will + /// be the same as what \#getText returns; + /// for field values it will be preceding field name; + /// and for others (array values, root-level values) null. + ///@return Name of the current field in the parsing context + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + ///@since 2.10 + jni.JlString currentName() => jni.JlString.fromRef(_currentName(reference)); + + static final _getText = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_getText") + .asFunction Function(ffi.Pointer)>(); + + /// from: public abstract java.lang.String getText() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for accessing textual representation of the current token; + /// if no current token (before first call to \#nextToken, or + /// after encountering end-of-input), returns null. + /// Method can be called for any token type. + ///@return Textual value associated with the current token (one returned + /// by \#nextToken() or other iteration methods) + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + jni.JlString getText() => jni.JlString.fromRef(_getText(reference)); + + static final _getText1 = jlookup< + ffi.NativeFunction< + ffi.Int32 Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_getText1") + .asFunction, ffi.Pointer)>(); + + /// from: public int getText(java.io.Writer writer) + /// + /// Method to read the textual representation of the current token in chunks and + /// pass it to the given Writer. + /// Conceptually same as calling: + ///
+  ///  writer.write(parser.getText());
+  ///
+ /// but should typically be more efficient as longer content does need to + /// be combined into a single String to return, and write + /// can occur directly from intermediate buffers Jackson uses. + ///@param writer Writer to write textual content to + ///@return The number of characters written to the Writer + ///@throws IOException for low-level read issues or writes using passed + /// {@code writer}, or + /// JsonParseException for decoding problems + ///@since 2.8 + int getText1(jni.JlObject writer) => _getText1(reference, writer.reference); + + static final _getTextCharacters = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_getTextCharacters") + .asFunction Function(ffi.Pointer)>(); + + /// from: public abstract char[] getTextCharacters() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method similar to \#getText, but that will return + /// underlying (unmodifiable) character array that contains + /// textual value, instead of constructing a String object + /// to contain this information. + /// Note, however, that: + ///
    + ///
  • Textual contents are not guaranteed to start at + /// index 0 (rather, call \#getTextOffset) to + /// know the actual offset + ///
  • + ///
  • Length of textual contents may be less than the + /// length of returned buffer: call \#getTextLength + /// for actual length of returned content. + ///
  • + ///
+ /// + /// Note that caller __MUST NOT__ modify the returned + /// character array in any way -- doing so may corrupt + /// current parser state and render parser instance useless. + /// + /// The only reason to call this method (over \#getText) + /// is to avoid construction of a String object (which + /// will make a copy of contents). + ///@return Buffer that contains the current textual value (but not necessarily + /// at offset 0, and not necessarily until the end of buffer) + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + jni.JlObject getTextCharacters() => + jni.JlObject.fromRef(_getTextCharacters(reference)); + + static final _getTextLength = + jlookup)>>( + "com_fasterxml_jackson_core_JsonParser_getTextLength") + .asFunction)>(); + + /// from: public abstract int getTextLength() + /// + /// Accessor used with \#getTextCharacters, to know length + /// of String stored in returned buffer. + ///@return Number of characters within buffer returned + /// by \#getTextCharacters that are part of + /// textual content of the current token. + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + int getTextLength() => _getTextLength(reference); + + static final _getTextOffset = + jlookup)>>( + "com_fasterxml_jackson_core_JsonParser_getTextOffset") + .asFunction)>(); + + /// from: public abstract int getTextOffset() + /// + /// Accessor used with \#getTextCharacters, to know offset + /// of the first text content character within buffer. + ///@return Offset of the first character within buffer returned + /// by \#getTextCharacters that is part of + /// textual content of the current token. + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + int getTextOffset() => _getTextOffset(reference); + + static final _hasTextCharacters = + jlookup)>>( + "com_fasterxml_jackson_core_JsonParser_hasTextCharacters") + .asFunction)>(); + + /// from: public abstract boolean hasTextCharacters() + /// + /// Method that can be used to determine whether calling of + /// \#getTextCharacters would be the most efficient + /// way to access textual content for the event parser currently + /// points to. + /// + /// Default implementation simply returns false since only actual + /// implementation class has knowledge of its internal buffering + /// state. + /// Implementations are strongly encouraged to properly override + /// this method, to allow efficient copying of content by other + /// code. + ///@return True if parser currently has character array that can + /// be efficiently returned via \#getTextCharacters; false + /// means that it may or may not exist + bool hasTextCharacters() => _hasTextCharacters(reference) != 0; + + static final _getNumberValue = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_getNumberValue") + .asFunction Function(ffi.Pointer)>(); + + /// from: public abstract java.lang.Number getNumberValue() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Generic number value accessor method that will work for + /// all kinds of numeric values. It will return the optimal + /// (simplest/smallest possible) wrapper object that can + /// express the numeric value just parsed. + ///@return Numeric value of the current token in its most optimal + /// representation + ///@throws IOException Problem with access: JsonParseException if + /// the current token is not numeric, or if decoding of the value fails + /// (invalid format for numbers); plain IOException if underlying + /// content read fails (possible if values are extracted lazily) + jni.JlObject getNumberValue() => + jni.JlObject.fromRef(_getNumberValue(reference)); + + static final _getNumberValueExact = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_getNumberValueExact") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.lang.Number getNumberValueExact() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method similar to \#getNumberValue with the difference that + /// for floating-point numbers value returned may be BigDecimal + /// if the underlying format does not store floating-point numbers using + /// native representation: for example, textual formats represent numbers + /// as Strings (which are 10-based), and conversion to java.lang.Double + /// is potentially lossy operation. + /// + /// Default implementation simply returns \#getNumberValue() + ///@return Numeric value of the current token using most accurate representation + ///@throws IOException Problem with access: JsonParseException if + /// the current token is not numeric, or if decoding of the value fails + /// (invalid format for numbers); plain IOException if underlying + /// content read fails (possible if values are extracted lazily) + ///@since 2.12 + jni.JlObject getNumberValueExact() => + jni.JlObject.fromRef(_getNumberValueExact(reference)); + + static final _getNumberType = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_getNumberType") + .asFunction Function(ffi.Pointer)>(); + + /// from: public abstract com.fasterxml.jackson.core.JsonParser.NumberType getNumberType() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// If current token is of type + /// JsonToken\#VALUE_NUMBER_INT or + /// JsonToken\#VALUE_NUMBER_FLOAT, returns + /// one of NumberType constants; otherwise returns null. + ///@return Type of current number, if parser points to numeric token; {@code null} otherwise + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + JsonParser_NumberType getNumberType() => + JsonParser_NumberType.fromRef(_getNumberType(reference)); + + static final _getByteValue = + jlookup)>>( + "com_fasterxml_jackson_core_JsonParser_getByteValue") + .asFunction)>(); + + /// from: public byte getByteValue() + /// + /// Numeric accessor that can be called when the current + /// token is of type JsonToken\#VALUE_NUMBER_INT and + /// it can be expressed as a value of Java byte primitive type. + /// Note that in addition to "natural" input range of {@code [-128, 127]}, + /// this also allows "unsigned 8-bit byte" values {@code [128, 255]}: + /// but for this range value will be translated by truncation, leading + /// to sign change. + /// + /// It can also be called for JsonToken\#VALUE_NUMBER_FLOAT; + /// if so, it is equivalent to calling \#getDoubleValue + /// and then casting; except for possible overflow/underflow + /// exception. + /// + /// Note: if the resulting integer value falls outside range of + /// {@code [-128, 255]}, + /// a InputCoercionException + /// will be thrown to indicate numeric overflow/underflow. + ///@return Current number value as {@code byte} (if numeric token within + /// range of {@code [-128, 255]}); otherwise exception thrown + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + int getByteValue() => _getByteValue(reference); + + static final _getShortValue = + jlookup)>>( + "com_fasterxml_jackson_core_JsonParser_getShortValue") + .asFunction)>(); + + /// from: public short getShortValue() + /// + /// Numeric accessor that can be called when the current + /// token is of type JsonToken\#VALUE_NUMBER_INT and + /// it can be expressed as a value of Java short primitive type. + /// It can also be called for JsonToken\#VALUE_NUMBER_FLOAT; + /// if so, it is equivalent to calling \#getDoubleValue + /// and then casting; except for possible overflow/underflow + /// exception. + /// + /// Note: if the resulting integer value falls outside range of + /// Java short, a InputCoercionException + /// will be thrown to indicate numeric overflow/underflow. + ///@return Current number value as {@code short} (if numeric token within + /// Java 16-bit signed {@code short} range); otherwise exception thrown + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + int getShortValue() => _getShortValue(reference); + + static final _getIntValue = + jlookup)>>( + "com_fasterxml_jackson_core_JsonParser_getIntValue") + .asFunction)>(); + + /// from: public abstract int getIntValue() + /// + /// Numeric accessor that can be called when the current + /// token is of type JsonToken\#VALUE_NUMBER_INT and + /// it can be expressed as a value of Java int primitive type. + /// It can also be called for JsonToken\#VALUE_NUMBER_FLOAT; + /// if so, it is equivalent to calling \#getDoubleValue + /// and then casting; except for possible overflow/underflow + /// exception. + /// + /// Note: if the resulting integer value falls outside range of + /// Java {@code int}, a InputCoercionException + /// may be thrown to indicate numeric overflow/underflow. + ///@return Current number value as {@code int} (if numeric token within + /// Java 32-bit signed {@code int} range); otherwise exception thrown + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + int getIntValue() => _getIntValue(reference); + + static final _getLongValue = + jlookup)>>( + "com_fasterxml_jackson_core_JsonParser_getLongValue") + .asFunction)>(); + + /// from: public abstract long getLongValue() + /// + /// Numeric accessor that can be called when the current + /// token is of type JsonToken\#VALUE_NUMBER_INT and + /// it can be expressed as a Java long primitive type. + /// It can also be called for JsonToken\#VALUE_NUMBER_FLOAT; + /// if so, it is equivalent to calling \#getDoubleValue + /// and then casting to int; except for possible overflow/underflow + /// exception. + /// + /// Note: if the token is an integer, but its value falls + /// outside of range of Java long, a InputCoercionException + /// may be thrown to indicate numeric overflow/underflow. + ///@return Current number value as {@code long} (if numeric token within + /// Java 32-bit signed {@code long} range); otherwise exception thrown + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + int getLongValue() => _getLongValue(reference); + + static final _getBigIntegerValue = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_getBigIntegerValue") + .asFunction Function(ffi.Pointer)>(); + + /// from: public abstract java.math.BigInteger getBigIntegerValue() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Numeric accessor that can be called when the current + /// token is of type JsonToken\#VALUE_NUMBER_INT and + /// it can not be used as a Java long primitive type due to its + /// magnitude. + /// It can also be called for JsonToken\#VALUE_NUMBER_FLOAT; + /// if so, it is equivalent to calling \#getDecimalValue + /// and then constructing a BigInteger from that value. + ///@return Current number value as BigInteger (if numeric token); + /// otherwise exception thrown + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + jni.JlObject getBigIntegerValue() => + jni.JlObject.fromRef(_getBigIntegerValue(reference)); + + static final _getFloatValue = + jlookup)>>( + "com_fasterxml_jackson_core_JsonParser_getFloatValue") + .asFunction)>(); + + /// from: public abstract float getFloatValue() + /// + /// Numeric accessor that can be called when the current + /// token is of type JsonToken\#VALUE_NUMBER_FLOAT and + /// it can be expressed as a Java float primitive type. + /// It can also be called for JsonToken\#VALUE_NUMBER_INT; + /// if so, it is equivalent to calling \#getLongValue + /// and then casting; except for possible overflow/underflow + /// exception. + /// + /// Note: if the value falls + /// outside of range of Java float, a InputCoercionException + /// will be thrown to indicate numeric overflow/underflow. + ///@return Current number value as {@code float} (if numeric token within + /// Java {@code float} range); otherwise exception thrown + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + double getFloatValue() => _getFloatValue(reference); + + static final _getDoubleValue = + jlookup)>>( + "com_fasterxml_jackson_core_JsonParser_getDoubleValue") + .asFunction)>(); + + /// from: public abstract double getDoubleValue() + /// + /// Numeric accessor that can be called when the current + /// token is of type JsonToken\#VALUE_NUMBER_FLOAT and + /// it can be expressed as a Java double primitive type. + /// It can also be called for JsonToken\#VALUE_NUMBER_INT; + /// if so, it is equivalent to calling \#getLongValue + /// and then casting; except for possible overflow/underflow + /// exception. + /// + /// Note: if the value falls + /// outside of range of Java double, a InputCoercionException + /// will be thrown to indicate numeric overflow/underflow. + ///@return Current number value as {@code double} (if numeric token within + /// Java {@code double} range); otherwise exception thrown + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + double getDoubleValue() => _getDoubleValue(reference); + + static final _getDecimalValue = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_getDecimalValue") + .asFunction Function(ffi.Pointer)>(); + + /// from: public abstract java.math.BigDecimal getDecimalValue() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Numeric accessor that can be called when the current + /// token is of type JsonToken\#VALUE_NUMBER_FLOAT or + /// JsonToken\#VALUE_NUMBER_INT. No under/overflow exceptions + /// are ever thrown. + ///@return Current number value as BigDecimal (if numeric token); + /// otherwise exception thrown + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + jni.JlObject getDecimalValue() => + jni.JlObject.fromRef(_getDecimalValue(reference)); + + static final _getBooleanValue = + jlookup)>>( + "com_fasterxml_jackson_core_JsonParser_getBooleanValue") + .asFunction)>(); + + /// from: public boolean getBooleanValue() + /// + /// Convenience accessor that can be called when the current + /// token is JsonToken\#VALUE_TRUE or + /// JsonToken\#VALUE_FALSE, to return matching {@code boolean} + /// value. + /// If the current token is of some other type, JsonParseException + /// will be thrown + ///@return {@code True} if current token is {@code JsonToken.VALUE_TRUE}, + /// {@code false} if current token is {@code JsonToken.VALUE_FALSE}; + /// otherwise throws JsonParseException + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + bool getBooleanValue() => _getBooleanValue(reference) != 0; + + static final _getEmbeddedObject = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_getEmbeddedObject") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.lang.Object getEmbeddedObject() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Accessor that can be called if (and only if) the current token + /// is JsonToken\#VALUE_EMBEDDED_OBJECT. For other token types, + /// null is returned. + /// + /// Note: only some specialized parser implementations support + /// embedding of objects (usually ones that are facades on top + /// of non-streaming sources, such as object trees). One exception + /// is access to binary content (whether via base64 encoding or not) + /// which typically is accessible using this method, as well as + /// \#getBinaryValue(). + ///@return Embedded value (usually of "native" type supported by format) + /// for the current token, if any; {@code null otherwise} + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + jni.JlObject getEmbeddedObject() => + jni.JlObject.fromRef(_getEmbeddedObject(reference)); + + static final _getBinaryValue = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_getBinaryValue") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public abstract byte[] getBinaryValue(com.fasterxml.jackson.core.Base64Variant bv) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that can be used to read (and consume -- results + /// may not be accessible using other methods after the call) + /// base64-encoded binary data + /// included in the current textual JSON value. + /// It works similar to getting String value via \#getText + /// and decoding result (except for decoding part), + /// but should be significantly more performant. + /// + /// Note that non-decoded textual contents of the current token + /// are not guaranteed to be accessible after this method + /// is called. Current implementation, for example, clears up + /// textual content during decoding. + /// Decoded binary content, however, will be retained until + /// parser is advanced to the next event. + ///@param bv Expected variant of base64 encoded + /// content (see Base64Variants for definitions + /// of "standard" variants). + ///@return Decoded binary data + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + jni.JlObject getBinaryValue(jni.JlObject bv) => + jni.JlObject.fromRef(_getBinaryValue(reference, bv.reference)); + + static final _getBinaryValue1 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_getBinaryValue1") + .asFunction Function(ffi.Pointer)>(); + + /// from: public byte[] getBinaryValue() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Convenience alternative to \#getBinaryValue(Base64Variant) + /// that defaults to using + /// Base64Variants\#getDefaultVariant as the default encoding. + ///@return Decoded binary data + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + jni.JlObject getBinaryValue1() => + jni.JlObject.fromRef(_getBinaryValue1(reference)); + + static final _readBinaryValue = jlookup< + ffi.NativeFunction< + ffi.Int32 Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_readBinaryValue") + .asFunction, ffi.Pointer)>(); + + /// from: public int readBinaryValue(java.io.OutputStream out) + /// + /// Method that can be used as an alternative to \#getBigIntegerValue(), + /// especially when value can be large. The main difference (beyond method + /// of returning content using OutputStream instead of as byte array) + /// is that content will NOT remain accessible after method returns: any content + /// processed will be consumed and is not buffered in any way. If caller needs + /// buffering, it has to implement it. + ///@param out Output stream to use for passing decoded binary data + ///@return Number of bytes that were decoded and written via OutputStream + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + ///@since 2.1 + int readBinaryValue(jni.JlObject out) => + _readBinaryValue(reference, out.reference); + + static final _readBinaryValue1 = jlookup< + ffi.NativeFunction< + ffi.Int32 Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_readBinaryValue1") + .asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + /// from: public int readBinaryValue(com.fasterxml.jackson.core.Base64Variant bv, java.io.OutputStream out) + /// + /// Similar to \#readBinaryValue(OutputStream) but allows explicitly + /// specifying base64 variant to use. + ///@param bv base64 variant to use + ///@param out Output stream to use for passing decoded binary data + ///@return Number of bytes that were decoded and written via OutputStream + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + ///@since 2.1 + int readBinaryValue1(jni.JlObject bv, jni.JlObject out) => + _readBinaryValue1(reference, bv.reference, out.reference); + + static final _getValueAsInt = + jlookup)>>( + "com_fasterxml_jackson_core_JsonParser_getValueAsInt") + .asFunction)>(); + + /// from: public int getValueAsInt() + /// + /// Method that will try to convert value of current token to a + /// Java {@code int} value. + /// Numbers are coerced using default Java rules; booleans convert to 0 (false) + /// and 1 (true), and Strings are parsed using default Java language integer + /// parsing rules. + /// + /// If representation can not be converted to an int (including structured type + /// markers like start/end Object/Array) + /// default value of __0__ will be returned; no exceptions are thrown. + ///@return {@code int} value current token is converted to, if possible; exception thrown + /// otherwise + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + int getValueAsInt() => _getValueAsInt(reference); + + static final _getValueAsInt1 = jlookup< + ffi.NativeFunction< + ffi.Int32 Function(ffi.Pointer, ffi.Int32)>>( + "com_fasterxml_jackson_core_JsonParser_getValueAsInt1") + .asFunction, int)>(); + + /// from: public int getValueAsInt(int def) + /// + /// Method that will try to convert value of current token to a + /// __int__. + /// Numbers are coerced using default Java rules; booleans convert to 0 (false) + /// and 1 (true), and Strings are parsed using default Java language integer + /// parsing rules. + /// + /// If representation can not be converted to an int (including structured type + /// markers like start/end Object/Array) + /// specified __def__ will be returned; no exceptions are thrown. + ///@param def Default value to return if conversion to {@code int} is not possible + ///@return {@code int} value current token is converted to, if possible; {@code def} otherwise + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + int getValueAsInt1(int def) => _getValueAsInt1(reference, def); + + static final _getValueAsLong = + jlookup)>>( + "com_fasterxml_jackson_core_JsonParser_getValueAsLong") + .asFunction)>(); + + /// from: public long getValueAsLong() + /// + /// Method that will try to convert value of current token to a + /// __long__. + /// Numbers are coerced using default Java rules; booleans convert to 0 (false) + /// and 1 (true), and Strings are parsed using default Java language integer + /// parsing rules. + /// + /// If representation can not be converted to a long (including structured type + /// markers like start/end Object/Array) + /// default value of __0L__ will be returned; no exceptions are thrown. + ///@return {@code long} value current token is converted to, if possible; exception thrown + /// otherwise + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + int getValueAsLong() => _getValueAsLong(reference); + + static final _getValueAsLong1 = jlookup< + ffi.NativeFunction< + ffi.Int64 Function(ffi.Pointer, ffi.Int64)>>( + "com_fasterxml_jackson_core_JsonParser_getValueAsLong1") + .asFunction, int)>(); + + /// from: public long getValueAsLong(long def) + /// + /// Method that will try to convert value of current token to a + /// __long__. + /// Numbers are coerced using default Java rules; booleans convert to 0 (false) + /// and 1 (true), and Strings are parsed using default Java language integer + /// parsing rules. + /// + /// If representation can not be converted to a long (including structured type + /// markers like start/end Object/Array) + /// specified __def__ will be returned; no exceptions are thrown. + ///@param def Default value to return if conversion to {@code long} is not possible + ///@return {@code long} value current token is converted to, if possible; {@code def} otherwise + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + int getValueAsLong1(int def) => _getValueAsLong1(reference, def); + + static final _getValueAsDouble = + jlookup)>>( + "com_fasterxml_jackson_core_JsonParser_getValueAsDouble") + .asFunction)>(); + + /// from: public double getValueAsDouble() + /// + /// Method that will try to convert value of current token to a Java + /// __double__. + /// Numbers are coerced using default Java rules; booleans convert to 0.0 (false) + /// and 1.0 (true), and Strings are parsed using default Java language floating + /// point parsing rules. + /// + /// If representation can not be converted to a double (including structured types + /// like Objects and Arrays), + /// default value of __0.0__ will be returned; no exceptions are thrown. + ///@return {@code double} value current token is converted to, if possible; exception thrown + /// otherwise + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + double getValueAsDouble() => _getValueAsDouble(reference); + + static final _getValueAsDouble1 = jlookup< + ffi.NativeFunction< + ffi.Double Function(ffi.Pointer, ffi.Double)>>( + "com_fasterxml_jackson_core_JsonParser_getValueAsDouble1") + .asFunction, double)>(); + + /// from: public double getValueAsDouble(double def) + /// + /// Method that will try to convert value of current token to a + /// Java __double__. + /// Numbers are coerced using default Java rules; booleans convert to 0.0 (false) + /// and 1.0 (true), and Strings are parsed using default Java language floating + /// point parsing rules. + /// + /// If representation can not be converted to a double (including structured types + /// like Objects and Arrays), + /// specified __def__ will be returned; no exceptions are thrown. + ///@param def Default value to return if conversion to {@code double} is not possible + ///@return {@code double} value current token is converted to, if possible; {@code def} otherwise + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + double getValueAsDouble1(double def) => _getValueAsDouble1(reference, def); + + static final _getValueAsBoolean = + jlookup)>>( + "com_fasterxml_jackson_core_JsonParser_getValueAsBoolean") + .asFunction)>(); + + /// from: public boolean getValueAsBoolean() + /// + /// Method that will try to convert value of current token to a + /// __boolean__. + /// JSON booleans map naturally; integer numbers other than 0 map to true, and + /// 0 maps to false + /// and Strings 'true' and 'false' map to corresponding values. + /// + /// If representation can not be converted to a boolean value (including structured types + /// like Objects and Arrays), + /// default value of __false__ will be returned; no exceptions are thrown. + ///@return {@code boolean} value current token is converted to, if possible; exception thrown + /// otherwise + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + bool getValueAsBoolean() => _getValueAsBoolean(reference) != 0; + + static final _getValueAsBoolean1 = jlookup< + ffi.NativeFunction< + ffi.Uint8 Function(ffi.Pointer, ffi.Uint8)>>( + "com_fasterxml_jackson_core_JsonParser_getValueAsBoolean1") + .asFunction, int)>(); + + /// from: public boolean getValueAsBoolean(boolean def) + /// + /// Method that will try to convert value of current token to a + /// __boolean__. + /// JSON booleans map naturally; integer numbers other than 0 map to true, and + /// 0 maps to false + /// and Strings 'true' and 'false' map to corresponding values. + /// + /// If representation can not be converted to a boolean value (including structured types + /// like Objects and Arrays), + /// specified __def__ will be returned; no exceptions are thrown. + ///@param def Default value to return if conversion to {@code boolean} is not possible + ///@return {@code boolean} value current token is converted to, if possible; {@code def} otherwise + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + bool getValueAsBoolean1(bool def) => + _getValueAsBoolean1(reference, def ? 1 : 0) != 0; + + static final _getValueAsString = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_getValueAsString") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.lang.String getValueAsString() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that will try to convert value of current token to a + /// java.lang.String. + /// JSON Strings map naturally; scalar values get converted to + /// their textual representation. + /// If representation can not be converted to a String value (including structured types + /// like Objects and Arrays and {@code null} token), default value of + /// __null__ will be returned; no exceptions are thrown. + ///@return String value current token is converted to, if possible; {@code null} otherwise + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + ///@since 2.1 + jni.JlString getValueAsString() => + jni.JlString.fromRef(_getValueAsString(reference)); + + static final _getValueAsString1 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_getValueAsString1") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public abstract java.lang.String getValueAsString(java.lang.String def) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that will try to convert value of current token to a + /// java.lang.String. + /// JSON Strings map naturally; scalar values get converted to + /// their textual representation. + /// If representation can not be converted to a String value (including structured types + /// like Objects and Arrays and {@code null} token), specified default value + /// will be returned; no exceptions are thrown. + ///@param def Default value to return if conversion to {@code String} is not possible + ///@return String value current token is converted to, if possible; {@code def} otherwise + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + ///@since 2.1 + jni.JlString getValueAsString1(jni.JlString def) => + jni.JlString.fromRef(_getValueAsString1(reference, def.reference)); + + static final _canReadObjectId = + jlookup)>>( + "com_fasterxml_jackson_core_JsonParser_canReadObjectId") + .asFunction)>(); + + /// from: public boolean canReadObjectId() + /// + /// Introspection method that may be called to see if the underlying + /// data format supports some kind of Object Ids natively (many do not; + /// for example, JSON doesn't). + /// + /// Default implementation returns true; overridden by data formats + /// that do support native Object Ids. Caller is expected to either + /// use a non-native notation (explicit property or such), or fail, + /// in case it can not use native object ids. + ///@return {@code True} if the format being read supports native Object Ids; + /// {@code false} if not + ///@since 2.3 + bool canReadObjectId() => _canReadObjectId(reference) != 0; + + static final _canReadTypeId = + jlookup)>>( + "com_fasterxml_jackson_core_JsonParser_canReadTypeId") + .asFunction)>(); + + /// from: public boolean canReadTypeId() + /// + /// Introspection method that may be called to see if the underlying + /// data format supports some kind of Type Ids natively (many do not; + /// for example, JSON doesn't). + /// + /// Default implementation returns true; overridden by data formats + /// that do support native Type Ids. Caller is expected to either + /// use a non-native notation (explicit property or such), or fail, + /// in case it can not use native type ids. + ///@return {@code True} if the format being read supports native Type Ids; + /// {@code false} if not + ///@since 2.3 + bool canReadTypeId() => _canReadTypeId(reference) != 0; + + static final _getObjectId = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_getObjectId") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.lang.Object getObjectId() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that can be called to check whether current token + /// (one that was just read) has an associated Object id, and if + /// so, return it. + /// Note that while typically caller should check with \#canReadObjectId + /// first, it is not illegal to call this method even if that method returns + /// true; but if so, it will return null. This may be used to simplify calling + /// code. + /// + /// Default implementation will simply return null. + ///@return Native Object id associated with the current token, if any; {@code null} if none + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + ///@since 2.3 + jni.JlObject getObjectId() => jni.JlObject.fromRef(_getObjectId(reference)); + + static final _getTypeId = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_getTypeId") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.lang.Object getTypeId() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that can be called to check whether current token + /// (one that was just read) has an associated type id, and if + /// so, return it. + /// Note that while typically caller should check with \#canReadTypeId + /// first, it is not illegal to call this method even if that method returns + /// true; but if so, it will return null. This may be used to simplify calling + /// code. + /// + /// Default implementation will simply return null. + ///@return Native Type Id associated with the current token, if any; {@code null} if none + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + ///@since 2.3 + jni.JlObject getTypeId() => jni.JlObject.fromRef(_getTypeId(reference)); + + static final _readValuesAs = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_readValuesAs") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public java.util.Iterator readValuesAs(java.lang.Class valueType) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for reading sequence of Objects from parser stream, + /// all with same specified value type. + ///@param Nominal type parameter for value type + ///@param valueType Java type to read content as (passed to ObjectCodec that + /// deserializes content) + ///@return Iterator for reading multiple Java values from content + ///@throws IOException if there is either an underlying I/O problem or decoding + /// issue at format layer + jni.JlObject readValuesAs(jni.JlObject valueType) => + jni.JlObject.fromRef(_readValuesAs(reference, valueType.reference)); + + static final _readValuesAs1 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser_readValuesAs1") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public java.util.Iterator readValuesAs(com.fasterxml.jackson.core.type.TypeReference valueTypeRef) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for reading sequence of Objects from parser stream, + /// all with same specified value type. + ///@param Nominal type parameter for value type + ///@param valueTypeRef Java type to read content as (passed to ObjectCodec that + /// deserializes content) + ///@return Iterator for reading multiple Java values from content + ///@throws IOException if there is either an underlying I/O problem or decoding + /// issue at format layer + jni.JlObject readValuesAs1(jni.JlObject valueTypeRef) => + jni.JlObject.fromRef(_readValuesAs1(reference, valueTypeRef.reference)); +} + +/// from: com.fasterxml.jackson.core.JsonParser$Feature +/// +/// Enumeration that defines all on/off features for parsers. +class JsonParser_Feature extends jni.JlObject { + JsonParser_Feature.fromRef(ffi.Pointer ref) : super.fromRef(ref); + + static final _values = + jlookup Function()>>( + "com_fasterxml_jackson_core_JsonParser__Feature_values") + .asFunction Function()>(); + + /// from: static public com.fasterxml.jackson.core.JsonParser.Feature[] values() + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JlObject values() => jni.JlObject.fromRef(_values()); + + static final _valueOf = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser__Feature_valueOf") + .asFunction Function(ffi.Pointer)>(); + + /// from: static public com.fasterxml.jackson.core.JsonParser.Feature valueOf(java.lang.String name) + /// The returned object must be deleted after use, by calling the `delete` method. + static JsonParser_Feature valueOf(jni.JlString name) => + JsonParser_Feature.fromRef(_valueOf(name.reference)); + + static final _collectDefaults = + jlookup>( + "com_fasterxml_jackson_core_JsonParser__Feature_collectDefaults") + .asFunction(); + + /// from: static public int collectDefaults() + /// + /// Method that calculates bit set (flags) of all features that + /// are enabled by default. + ///@return Bit mask of all features that are enabled by default + static int collectDefaults() => _collectDefaults(); + + static final _ctor = + jlookup Function(ffi.Uint8)>>( + "com_fasterxml_jackson_core_JsonParser__Feature_ctor") + .asFunction Function(int)>(); + + /// from: private void (boolean defaultState) + JsonParser_Feature(bool defaultState) + : super.fromRef(_ctor(defaultState ? 1 : 0)); + + static final _enabledByDefault = + jlookup)>>( + "com_fasterxml_jackson_core_JsonParser__Feature_enabledByDefault") + .asFunction)>(); + + /// from: public boolean enabledByDefault() + bool enabledByDefault() => _enabledByDefault(reference) != 0; + + static final _enabledIn = jlookup< + ffi.NativeFunction< + ffi.Uint8 Function(ffi.Pointer, ffi.Int32)>>( + "com_fasterxml_jackson_core_JsonParser__Feature_enabledIn") + .asFunction, int)>(); + + /// from: public boolean enabledIn(int flags) + bool enabledIn(int flags) => _enabledIn(reference, flags) != 0; + + static final _getMask = + jlookup)>>( + "com_fasterxml_jackson_core_JsonParser__Feature_getMask") + .asFunction)>(); + + /// from: public int getMask() + int getMask() => _getMask(reference); +} + +/// from: com.fasterxml.jackson.core.JsonParser$NumberType +/// +/// Enumeration of possible "native" (optimal) types that can be +/// used for numbers. +class JsonParser_NumberType extends jni.JlObject { + JsonParser_NumberType.fromRef(ffi.Pointer ref) : super.fromRef(ref); + + static final _values = + jlookup Function()>>( + "com_fasterxml_jackson_core_JsonParser__NumberType_values") + .asFunction Function()>(); + + /// from: static public com.fasterxml.jackson.core.JsonParser.NumberType[] values() + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JlObject values() => jni.JlObject.fromRef(_values()); + + static final _valueOf = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonParser__NumberType_valueOf") + .asFunction Function(ffi.Pointer)>(); + + /// from: static public com.fasterxml.jackson.core.JsonParser.NumberType valueOf(java.lang.String name) + /// The returned object must be deleted after use, by calling the `delete` method. + static JsonParser_NumberType valueOf(jni.JlString name) => + JsonParser_NumberType.fromRef(_valueOf(name.reference)); + + static final _ctor = + jlookup Function()>>( + "com_fasterxml_jackson_core_JsonParser__NumberType_ctor") + .asFunction Function()>(); + + /// from: private void () + JsonParser_NumberType() : super.fromRef(_ctor()); +} + +/// from: com.fasterxml.jackson.core.JsonToken +/// +/// Enumeration for basic token types used for returning results +/// of parsing JSON content. +class JsonToken extends jni.JlObject { + JsonToken.fromRef(ffi.Pointer ref) : super.fromRef(ref); + + static final _values = + jlookup Function()>>( + "com_fasterxml_jackson_core_JsonToken_values") + .asFunction Function()>(); + + /// from: static public com.fasterxml.jackson.core.JsonToken[] values() + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JlObject values() => jni.JlObject.fromRef(_values()); + + static final _valueOf = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonToken_valueOf") + .asFunction Function(ffi.Pointer)>(); + + /// from: static public com.fasterxml.jackson.core.JsonToken valueOf(java.lang.String name) + /// The returned object must be deleted after use, by calling the `delete` method. + static JsonToken valueOf(jni.JlString name) => + JsonToken.fromRef(_valueOf(name.reference)); + + static final _ctor = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Int32)>>("com_fasterxml_jackson_core_JsonToken_ctor") + .asFunction Function(ffi.Pointer, int)>(); + + /// from: private void (java.lang.String token, int id) + /// + /// @param token representation for this token, if there is a + /// single static representation; null otherwise + ///@param id Numeric id from JsonTokenId + JsonToken(jni.JlString token, int id) + : super.fromRef(_ctor(token.reference, id)); + + static final _id = + jlookup)>>( + "com_fasterxml_jackson_core_JsonToken_id") + .asFunction)>(); + + /// from: public final int id() + int id() => _id(reference); + + static final _asString = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonToken_asString") + .asFunction Function(ffi.Pointer)>(); + + /// from: public final java.lang.String asString() + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JlString asString() => jni.JlString.fromRef(_asString(reference)); + + static final _asCharArray = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonToken_asCharArray") + .asFunction Function(ffi.Pointer)>(); + + /// from: public final char[] asCharArray() + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JlObject asCharArray() => jni.JlObject.fromRef(_asCharArray(reference)); + + static final _asByteArray = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "com_fasterxml_jackson_core_JsonToken_asByteArray") + .asFunction Function(ffi.Pointer)>(); + + /// from: public final byte[] asByteArray() + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JlObject asByteArray() => jni.JlObject.fromRef(_asByteArray(reference)); + + static final _isNumeric = + jlookup)>>( + "com_fasterxml_jackson_core_JsonToken_isNumeric") + .asFunction)>(); + + /// from: public final boolean isNumeric() + /// + /// @return {@code True} if this token is {@code VALUE_NUMBER_INT} or {@code VALUE_NUMBER_FLOAT}, + /// {@code false} otherwise + bool isNumeric() => _isNumeric(reference) != 0; + + static final _isStructStart = + jlookup)>>( + "com_fasterxml_jackson_core_JsonToken_isStructStart") + .asFunction)>(); + + /// from: public final boolean isStructStart() + /// + /// Accessor that is functionally equivalent to: + /// + /// this == JsonToken.START_OBJECT || this == JsonToken.START_ARRAY + /// + ///@return {@code True} if this token is {@code START_OBJECT} or {@code START_ARRAY}, + /// {@code false} otherwise + ///@since 2.3 + bool isStructStart() => _isStructStart(reference) != 0; + + static final _isStructEnd = + jlookup)>>( + "com_fasterxml_jackson_core_JsonToken_isStructEnd") + .asFunction)>(); + + /// from: public final boolean isStructEnd() + /// + /// Accessor that is functionally equivalent to: + /// + /// this == JsonToken.END_OBJECT || this == JsonToken.END_ARRAY + /// + ///@return {@code True} if this token is {@code END_OBJECT} or {@code END_ARRAY}, + /// {@code false} otherwise + ///@since 2.3 + bool isStructEnd() => _isStructEnd(reference) != 0; + + static final _isScalarValue = + jlookup)>>( + "com_fasterxml_jackson_core_JsonToken_isScalarValue") + .asFunction)>(); + + /// from: public final boolean isScalarValue() + /// + /// Method that can be used to check whether this token represents + /// a valid non-structured value. This means all {@code VALUE_xxx} tokens; + /// excluding {@code START_xxx} and {@code END_xxx} tokens as well + /// {@code FIELD_NAME}. + ///@return {@code True} if this token is a scalar value token (one of + /// {@code VALUE_xxx} tokens), {@code false} otherwise + bool isScalarValue() => _isScalarValue(reference) != 0; + + static final _isBoolean = + jlookup)>>( + "com_fasterxml_jackson_core_JsonToken_isBoolean") + .asFunction)>(); + + /// from: public final boolean isBoolean() + /// + /// @return {@code True} if this token is {@code VALUE_TRUE} or {@code VALUE_FALSE}, + /// {@code false} otherwise + bool isBoolean() => _isBoolean(reference) != 0; +} diff --git a/pkgs/jni_gen/test/jackson_core_test/third_party/lib/init.dart b/pkgs/jni_gen/test/jackson_core_test/third_party/lib/init.dart new file mode 100644 index 000000000..062c5a8a9 --- /dev/null +++ b/pkgs/jni_gen/test/jackson_core_test/third_party/lib/init.dart @@ -0,0 +1,5 @@ +import "dart:ffi"; +import "package:jni/jni.dart"; + +final Pointer Function(String sym) jlookup = + Jni.getInstance().initGeneratedLibrary("jackson_core_test"); diff --git a/pkgs/jni_gen/test/jackson_core_test/third_party/src/CMakeLists.txt b/pkgs/jni_gen/test/jackson_core_test/third_party/src/CMakeLists.txt new file mode 100644 index 000000000..657e00105 --- /dev/null +++ b/pkgs/jni_gen/test/jackson_core_test/third_party/src/CMakeLists.txt @@ -0,0 +1,30 @@ +# The Flutter tooling requires that developers have CMake 3.10 or later +# installed. You should not increase this version, as doing so will cause +# the plugin to fail to compile for some customers of the plugin. +cmake_minimum_required(VERSION 3.10) + +project(jackson_core_test VERSION 0.0.1 LANGUAGES C) + +add_library(jackson_core_test SHARED + "jackson_core_test.c" +) + +set_target_properties(jackson_core_test PROPERTIES + OUTPUT_NAME "jackson_core_test" +) + +target_compile_definitions(jackson_core_test PUBLIC DART_SHARED_LIB) + +if(WIN32) + set_target_properties(${TARGET_NAME} PROPERTIES + LINK_FLAGS "/DELAYLOAD:jvm.dll") +endif() + +if (ANDROID) + target_link_libraries(jackson_core_test log) +else() + find_package(Java REQUIRED) + find_package(JNI REQUIRED) + include_directories(${JNI_INCLUDE_DIRS}) + target_link_libraries(jackson_core_test ${JNI_LIBRARIES}) +endif() diff --git a/pkgs/jni_gen/test/jackson_core_test/third_party/src/dartjni.h b/pkgs/jni_gen/test/jackson_core_test/third_party/src/dartjni.h new file mode 100644 index 000000000..407312bbe --- /dev/null +++ b/pkgs/jni_gen/test/jackson_core_test/third_party/src/dartjni.h @@ -0,0 +1,173 @@ +#include +#include +#include +#include + +#if _WIN32 +#include +#else +#include +#include +#endif + +#if _WIN32 +#define FFI_PLUGIN_EXPORT __declspec(dllexport) +#else +#define FFI_PLUGIN_EXPORT +#endif + +#if defined _WIN32 +#define thread_local __declspec(thread) +#else +#define thread_local __thread +#endif + +#ifdef __ANDROID__ +#include +#endif + +#define JNI_LOG_TAG "Dart-JNI" + +#ifdef __ANDROID__ +#define __ENVP_CAST (JNIEnv **) +#else +#define __ENVP_CAST (void **) +#endif + +struct jni_context { + JavaVM *jvm; + jobject classLoader; + jmethodID loadClassMethod; + jobject currentActivity; + jobject appContext; +}; + +extern thread_local JNIEnv *jniEnv; + +extern struct jni_context jni; + +enum DartJniLogLevel { + JNI_VERBOSE = 2, + JNI_DEBUG, + JNI_INFO, + JNI_WARN, + JNI_ERROR +}; + +FFI_PLUGIN_EXPORT struct jni_context GetJniContext(); + +FFI_PLUGIN_EXPORT JavaVM *GetJavaVM(void); + +FFI_PLUGIN_EXPORT JNIEnv *GetJniEnv(void); + +FFI_PLUGIN_EXPORT JNIEnv *SpawnJvm(JavaVMInitArgs *args); + +FFI_PLUGIN_EXPORT jclass LoadClass(const char *name); + +FFI_PLUGIN_EXPORT jobject GetClassLoader(void); + +FFI_PLUGIN_EXPORT jobject GetApplicationContext(void); + +FFI_PLUGIN_EXPORT jobject GetCurrentActivity(void); + +FFI_PLUGIN_EXPORT void SetJNILogging(int level); + +FFI_PLUGIN_EXPORT jstring ToJavaString(char *str); + +FFI_PLUGIN_EXPORT const char *GetJavaStringChars(jstring jstr); + +FFI_PLUGIN_EXPORT void ReleaseJavaStringChars(jstring jstr, const char *buf); + +// These 2 are the function pointer variables defined and exported by +// the generated C files. +// +// initGeneratedLibrary function in Jni class will set these to +// corresponding functions to the implementations from `dartjni` base library +// which initializes and manages the JNI. +extern struct jni_context (*context_getter)(void); +extern JNIEnv *(*env_getter)(void); + +// This function will be exported by generated code library and will set the +// above 2 variables. +FFI_PLUGIN_EXPORT void setJniGetters(struct jni_context (*cg)(void), + JNIEnv *(*eg)(void)); + +// `static inline` because `inline` doesn't work, it may still not +// inline the function in which case a linker error may be produced. +// +// There has to be a better way to do this. Either to force inlining on target +// platforms, or just leave it as normal function. +static inline void __load_class_into(jclass *cls, const char *name) { +#ifdef __ANDROID__ + jstring className = (*jniEnv)->NewStringUTF(jniEnv, name); + *cls = (*jniEnv)->CallObjectMethod(jniEnv, jni.classLoader, + jni.loadClassMethod, className); + (*jniEnv)->DeleteLocalRef(jniEnv, className); +#else + *cls = (*jniEnv)->FindClass(jniEnv, name); +#endif +} + +static inline void load_class(jclass *cls, const char *name) { + if (*cls == NULL) { + __load_class_into(cls, name); + } +} + +static inline void load_class_gr(jclass *cls, const char *name) { + if (*cls == NULL) { + jclass tmp; + __load_class_into(&tmp, name); + *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); + (*jniEnv)->DeleteLocalRef(jniEnv, tmp); + } +} + +static inline void attach_thread() { + if (jniEnv == NULL) { + (*jni.jvm)->AttachCurrentThread(jni.jvm, __ENVP_CAST & jniEnv, + NULL); + } +} + +static inline void load_env() { + if (jniEnv == NULL) { + jni = context_getter(); + jniEnv = env_getter(); + } +} + +static inline void load_method(jclass cls, jmethodID *res, const char *name, + const char *sig) { + if (*res == NULL) { + *res = (*jniEnv)->GetMethodID(jniEnv, cls, name, sig); + } +} + +static inline void load_static_method(jclass cls, jmethodID *res, + const char *name, const char *sig) { + if (*res == NULL) { + *res = (*jniEnv)->GetStaticMethodID(jniEnv, cls, name, sig); + } +} + +static inline void load_field(jclass cls, jfieldID *res, const char *name, + const char *sig) { + if (*res == NULL) { + *res = (*jniEnv)->GetFieldID(jniEnv, cls, name, sig); + } +} + +static inline void load_static_field(jclass cls, jfieldID *res, + const char *name, const char *sig) { + if (*res == NULL) { + *res = (*jniEnv)->GetStaticFieldID(jniEnv, cls, name, sig); + } +} + +static inline jobject to_global_ref(jobject ref) { + jobject g = (*jniEnv)->NewGlobalRef(jniEnv, ref); + (*jniEnv)->DeleteLocalRef(jniEnv, ref); + return g; +} + diff --git a/pkgs/jni_gen/test/jackson_core_test/third_party/src/jackson_core_test.c b/pkgs/jni_gen/test/jackson_core_test/third_party/src/jackson_core_test.c new file mode 100644 index 000000000..f91f6c00f --- /dev/null +++ b/pkgs/jni_gen/test/jackson_core_test/third_party/src/jackson_core_test.c @@ -0,0 +1,2207 @@ +// Generated from jackson-core which is licensed under the Apache License 2.0. +// The following copyright from the original authors applies. +// See https://github.com/FasterXML/jackson-core/blob/2.14/LICENSE +// +// Copyright (c) 2007 - The Jackson Project Authors +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Autogenerated by jni_gen. DO NOT EDIT! + +#include +#include "jni.h" +#include "dartjni.h" + +thread_local JNIEnv *jniEnv; +struct jni_context jni; + +struct jni_context (*context_getter)(void); +JNIEnv *(*env_getter)(void); + +void setJniGetters(struct jni_context (*cg)(void), + JNIEnv *(*eg)(void)) { + context_getter = cg; + env_getter = eg; +} + +// com.fasterxml.jackson.core.JsonFactory +jclass _c_com_fasterxml_jackson_core_JsonFactory = NULL; + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_ctor = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_ctor() { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_ctor, "", "()V"); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_com_fasterxml_jackson_core_JsonFactory, _m_com_fasterxml_jackson_core_JsonFactory_ctor); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_ctor1 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_ctor1(jobject oc) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_ctor1, "", "(Lcom/fasterxml/jackson/core/ObjectCodec;)V"); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_com_fasterxml_jackson_core_JsonFactory, _m_com_fasterxml_jackson_core_JsonFactory_ctor1, oc); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_ctor2 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_ctor2(jobject src, jobject codec) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_ctor2, "", "(Lcom/fasterxml/jackson/core/JsonFactory;Lcom/fasterxml/jackson/core/ObjectCodec;)V"); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_com_fasterxml_jackson_core_JsonFactory, _m_com_fasterxml_jackson_core_JsonFactory_ctor2, src, codec); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_ctor3 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_ctor3(jobject b) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_ctor3, "", "(Lcom/fasterxml/jackson/core/JsonFactoryBuilder;)V"); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_com_fasterxml_jackson_core_JsonFactory, _m_com_fasterxml_jackson_core_JsonFactory_ctor3, b); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_ctor4 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_ctor4(jobject b, uint8_t bogus) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_ctor4, "", "(Lcom/fasterxml/jackson/core/TSFBuilder;Z)V"); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_com_fasterxml_jackson_core_JsonFactory, _m_com_fasterxml_jackson_core_JsonFactory_ctor4, b, bogus); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_rebuild = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_rebuild(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_rebuild, "rebuild", "()Lcom/fasterxml/jackson/core/TSFBuilder;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_rebuild); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_builder = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_builder() { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_static_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_builder, "builder", "()Lcom/fasterxml/jackson/core/TSFBuilder;"); + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_com_fasterxml_jackson_core_JsonFactory, _m_com_fasterxml_jackson_core_JsonFactory_builder); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_copy = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_copy(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_copy, "copy", "()Lcom/fasterxml/jackson/core/JsonFactory;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_copy); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_readResolve = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_readResolve(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_readResolve, "readResolve", "()Ljava/lang/Object;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_readResolve); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_requiresPropertyOrdering = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonFactory_requiresPropertyOrdering(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_requiresPropertyOrdering, "requiresPropertyOrdering", "()Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_requiresPropertyOrdering); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_canHandleBinaryNatively = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonFactory_canHandleBinaryNatively(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_canHandleBinaryNatively, "canHandleBinaryNatively", "()Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_canHandleBinaryNatively); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_canUseCharArrays = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonFactory_canUseCharArrays(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_canUseCharArrays, "canUseCharArrays", "()Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_canUseCharArrays); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_canParseAsync = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonFactory_canParseAsync(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_canParseAsync, "canParseAsync", "()Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_canParseAsync); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_getFormatReadFeatureType = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_getFormatReadFeatureType(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_getFormatReadFeatureType, "getFormatReadFeatureType", "()Ljava/lang/Class;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_getFormatReadFeatureType); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_getFormatWriteFeatureType = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_getFormatWriteFeatureType(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_getFormatWriteFeatureType, "getFormatWriteFeatureType", "()Ljava/lang/Class;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_getFormatWriteFeatureType); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_canUseSchema = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonFactory_canUseSchema(jobject self_, jobject schema) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_canUseSchema, "canUseSchema", "(Lcom/fasterxml/jackson/core/FormatSchema;)Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_canUseSchema, schema); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_getFormatName = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_getFormatName(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_getFormatName, "getFormatName", "()Ljava/lang/String;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_getFormatName); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_hasFormat = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_hasFormat(jobject self_, jobject acc) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_hasFormat, "hasFormat", "(Lcom/fasterxml/jackson/core/format/InputAccessor;)Lcom/fasterxml/jackson/core/format/MatchStrength;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_hasFormat, acc); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_requiresCustomCodec = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonFactory_requiresCustomCodec(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_requiresCustomCodec, "requiresCustomCodec", "()Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_requiresCustomCodec); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_hasJSONFormat = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_hasJSONFormat(jobject self_, jobject acc) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_hasJSONFormat, "hasJSONFormat", "(Lcom/fasterxml/jackson/core/format/InputAccessor;)Lcom/fasterxml/jackson/core/format/MatchStrength;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_hasJSONFormat, acc); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_version = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_version(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_version, "version", "()Lcom/fasterxml/jackson/core/Version;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_version); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_configure = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_configure(jobject self_, jobject f, uint8_t state) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_configure, "configure", "(Lcom/fasterxml/jackson/core/JsonFactory$Feature;Z)Lcom/fasterxml/jackson/core/JsonFactory;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_configure, f, state); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_enable = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_enable(jobject self_, jobject f) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_enable, "enable", "(Lcom/fasterxml/jackson/core/JsonFactory$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_enable, f); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_disable = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_disable(jobject self_, jobject f) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_disable, "disable", "(Lcom/fasterxml/jackson/core/JsonFactory$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_disable, f); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_isEnabled = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonFactory_isEnabled(jobject self_, jobject f) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_isEnabled, "isEnabled", "(Lcom/fasterxml/jackson/core/JsonFactory$Feature;)Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_isEnabled, f); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_getParserFeatures = NULL; +FFI_PLUGIN_EXPORT +int32_t com_fasterxml_jackson_core_JsonFactory_getParserFeatures(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_getParserFeatures, "getParserFeatures", "()I"); + int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_getParserFeatures); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_getGeneratorFeatures = NULL; +FFI_PLUGIN_EXPORT +int32_t com_fasterxml_jackson_core_JsonFactory_getGeneratorFeatures(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_getGeneratorFeatures, "getGeneratorFeatures", "()I"); + int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_getGeneratorFeatures); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_getFormatParserFeatures = NULL; +FFI_PLUGIN_EXPORT +int32_t com_fasterxml_jackson_core_JsonFactory_getFormatParserFeatures(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_getFormatParserFeatures, "getFormatParserFeatures", "()I"); + int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_getFormatParserFeatures); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_getFormatGeneratorFeatures = NULL; +FFI_PLUGIN_EXPORT +int32_t com_fasterxml_jackson_core_JsonFactory_getFormatGeneratorFeatures(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_getFormatGeneratorFeatures, "getFormatGeneratorFeatures", "()I"); + int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_getFormatGeneratorFeatures); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_configure1 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_configure1(jobject self_, jobject f, uint8_t state) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_configure1, "configure", "(Lcom/fasterxml/jackson/core/JsonParser$Feature;Z)Lcom/fasterxml/jackson/core/JsonFactory;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_configure1, f, state); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_enable1 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_enable1(jobject self_, jobject f) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_enable1, "enable", "(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_enable1, f); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_disable1 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_disable1(jobject self_, jobject f) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_disable1, "disable", "(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_disable1, f); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_isEnabled1 = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonFactory_isEnabled1(jobject self_, jobject f) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_isEnabled1, "isEnabled", "(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_isEnabled1, f); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_isEnabled2 = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonFactory_isEnabled2(jobject self_, jobject f) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_isEnabled2, "isEnabled", "(Lcom/fasterxml/jackson/core/StreamReadFeature;)Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_isEnabled2, f); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_getInputDecorator = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_getInputDecorator(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_getInputDecorator, "getInputDecorator", "()Lcom/fasterxml/jackson/core/io/InputDecorator;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_getInputDecorator); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_setInputDecorator = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_setInputDecorator(jobject self_, jobject d) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_setInputDecorator, "setInputDecorator", "(Lcom/fasterxml/jackson/core/io/InputDecorator;)Lcom/fasterxml/jackson/core/JsonFactory;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_setInputDecorator, d); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_configure2 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_configure2(jobject self_, jobject f, uint8_t state) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_configure2, "configure", "(Lcom/fasterxml/jackson/core/JsonGenerator$Feature;Z)Lcom/fasterxml/jackson/core/JsonFactory;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_configure2, f, state); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_enable2 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_enable2(jobject self_, jobject f) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_enable2, "enable", "(Lcom/fasterxml/jackson/core/JsonGenerator$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_enable2, f); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_disable2 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_disable2(jobject self_, jobject f) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_disable2, "disable", "(Lcom/fasterxml/jackson/core/JsonGenerator$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_disable2, f); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_isEnabled3 = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonFactory_isEnabled3(jobject self_, jobject f) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_isEnabled3, "isEnabled", "(Lcom/fasterxml/jackson/core/JsonGenerator$Feature;)Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_isEnabled3, f); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_isEnabled4 = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonFactory_isEnabled4(jobject self_, jobject f) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_isEnabled4, "isEnabled", "(Lcom/fasterxml/jackson/core/StreamWriteFeature;)Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_isEnabled4, f); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_getCharacterEscapes = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_getCharacterEscapes(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_getCharacterEscapes, "getCharacterEscapes", "()Lcom/fasterxml/jackson/core/io/CharacterEscapes;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_getCharacterEscapes); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_setCharacterEscapes = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_setCharacterEscapes(jobject self_, jobject esc) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_setCharacterEscapes, "setCharacterEscapes", "(Lcom/fasterxml/jackson/core/io/CharacterEscapes;)Lcom/fasterxml/jackson/core/JsonFactory;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_setCharacterEscapes, esc); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_getOutputDecorator = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_getOutputDecorator(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_getOutputDecorator, "getOutputDecorator", "()Lcom/fasterxml/jackson/core/io/OutputDecorator;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_getOutputDecorator); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_setOutputDecorator = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_setOutputDecorator(jobject self_, jobject d) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_setOutputDecorator, "setOutputDecorator", "(Lcom/fasterxml/jackson/core/io/OutputDecorator;)Lcom/fasterxml/jackson/core/JsonFactory;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_setOutputDecorator, d); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_setRootValueSeparator = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_setRootValueSeparator(jobject self_, jobject sep) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_setRootValueSeparator, "setRootValueSeparator", "(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonFactory;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_setRootValueSeparator, sep); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_getRootValueSeparator = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_getRootValueSeparator(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_getRootValueSeparator, "getRootValueSeparator", "()Ljava/lang/String;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_getRootValueSeparator); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_setCodec = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_setCodec(jobject self_, jobject oc) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_setCodec, "setCodec", "(Lcom/fasterxml/jackson/core/ObjectCodec;)Lcom/fasterxml/jackson/core/JsonFactory;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_setCodec, oc); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_getCodec = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_getCodec(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_getCodec, "getCodec", "()Lcom/fasterxml/jackson/core/ObjectCodec;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_getCodec); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_createParser = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_createParser(jobject self_, jobject f) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_createParser, "createParser", "(Ljava/io/File;)Lcom/fasterxml/jackson/core/JsonParser;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_createParser, f); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_createParser1 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_createParser1(jobject self_, jobject url) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_createParser1, "createParser", "(Ljava/net/URL;)Lcom/fasterxml/jackson/core/JsonParser;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_createParser1, url); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_createParser2 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_createParser2(jobject self_, jobject in) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_createParser2, "createParser", "(Ljava/io/InputStream;)Lcom/fasterxml/jackson/core/JsonParser;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_createParser2, in); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_createParser3 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_createParser3(jobject self_, jobject r) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_createParser3, "createParser", "(Ljava/io/Reader;)Lcom/fasterxml/jackson/core/JsonParser;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_createParser3, r); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_createParser4 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_createParser4(jobject self_, jobject data) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_createParser4, "createParser", "(L[B;)Lcom/fasterxml/jackson/core/JsonParser;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_createParser4, data); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_createParser5 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_createParser5(jobject self_, jobject data, int32_t offset, int32_t len) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_createParser5, "createParser", "(L[B;II)Lcom/fasterxml/jackson/core/JsonParser;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_createParser5, data, offset, len); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_createParser6 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_createParser6(jobject self_, jobject content) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_createParser6, "createParser", "(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonParser;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_createParser6, content); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_createParser7 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_createParser7(jobject self_, jobject content) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_createParser7, "createParser", "(L[C;)Lcom/fasterxml/jackson/core/JsonParser;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_createParser7, content); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_createParser8 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_createParser8(jobject self_, jobject content, int32_t offset, int32_t len) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_createParser8, "createParser", "(L[C;II)Lcom/fasterxml/jackson/core/JsonParser;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_createParser8, content, offset, len); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_createParser9 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_createParser9(jobject self_, jobject in) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_createParser9, "createParser", "(Ljava/io/DataInput;)Lcom/fasterxml/jackson/core/JsonParser;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_createParser9, in); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_createNonBlockingByteArrayParser = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_createNonBlockingByteArrayParser(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_createNonBlockingByteArrayParser, "createNonBlockingByteArrayParser", "()Lcom/fasterxml/jackson/core/JsonParser;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_createNonBlockingByteArrayParser); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_createGenerator = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_createGenerator(jobject self_, jobject out, jobject enc) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_createGenerator, "createGenerator", "(Ljava/io/OutputStream;Lcom/fasterxml/jackson/core/JsonEncoding;)Lcom/fasterxml/jackson/core/JsonGenerator;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_createGenerator, out, enc); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_createGenerator1 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_createGenerator1(jobject self_, jobject out) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_createGenerator1, "createGenerator", "(Ljava/io/OutputStream;)Lcom/fasterxml/jackson/core/JsonGenerator;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_createGenerator1, out); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_createGenerator2 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_createGenerator2(jobject self_, jobject w) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_createGenerator2, "createGenerator", "(Ljava/io/Writer;)Lcom/fasterxml/jackson/core/JsonGenerator;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_createGenerator2, w); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_createGenerator3 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_createGenerator3(jobject self_, jobject f, jobject enc) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_createGenerator3, "createGenerator", "(Ljava/io/File;Lcom/fasterxml/jackson/core/JsonEncoding;)Lcom/fasterxml/jackson/core/JsonGenerator;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_createGenerator3, f, enc); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_createGenerator4 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_createGenerator4(jobject self_, jobject out, jobject enc) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_createGenerator4, "createGenerator", "(Ljava/io/DataOutput;Lcom/fasterxml/jackson/core/JsonEncoding;)Lcom/fasterxml/jackson/core/JsonGenerator;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_createGenerator4, out, enc); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_createGenerator5 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_createGenerator5(jobject self_, jobject out) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_createGenerator5, "createGenerator", "(Ljava/io/DataOutput;)Lcom/fasterxml/jackson/core/JsonGenerator;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_createGenerator5, out); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_createJsonParser = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_createJsonParser(jobject self_, jobject f) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_createJsonParser, "createJsonParser", "(Ljava/io/File;)Lcom/fasterxml/jackson/core/JsonParser;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_createJsonParser, f); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_createJsonParser1 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_createJsonParser1(jobject self_, jobject url) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_createJsonParser1, "createJsonParser", "(Ljava/net/URL;)Lcom/fasterxml/jackson/core/JsonParser;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_createJsonParser1, url); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_createJsonParser2 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_createJsonParser2(jobject self_, jobject in) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_createJsonParser2, "createJsonParser", "(Ljava/io/InputStream;)Lcom/fasterxml/jackson/core/JsonParser;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_createJsonParser2, in); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_createJsonParser3 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_createJsonParser3(jobject self_, jobject r) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_createJsonParser3, "createJsonParser", "(Ljava/io/Reader;)Lcom/fasterxml/jackson/core/JsonParser;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_createJsonParser3, r); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_createJsonParser4 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_createJsonParser4(jobject self_, jobject data) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_createJsonParser4, "createJsonParser", "(L[B;)Lcom/fasterxml/jackson/core/JsonParser;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_createJsonParser4, data); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_createJsonParser5 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_createJsonParser5(jobject self_, jobject data, int32_t offset, int32_t len) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_createJsonParser5, "createJsonParser", "(L[B;II)Lcom/fasterxml/jackson/core/JsonParser;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_createJsonParser5, data, offset, len); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_createJsonParser6 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_createJsonParser6(jobject self_, jobject content) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_createJsonParser6, "createJsonParser", "(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonParser;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_createJsonParser6, content); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_createJsonGenerator = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_createJsonGenerator(jobject self_, jobject out, jobject enc) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_createJsonGenerator, "createJsonGenerator", "(Ljava/io/OutputStream;Lcom/fasterxml/jackson/core/JsonEncoding;)Lcom/fasterxml/jackson/core/JsonGenerator;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_createJsonGenerator, out, enc); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_createJsonGenerator1 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_createJsonGenerator1(jobject self_, jobject out) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_createJsonGenerator1, "createJsonGenerator", "(Ljava/io/Writer;)Lcom/fasterxml/jackson/core/JsonGenerator;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_createJsonGenerator1, out); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory_createJsonGenerator2 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory_createJsonGenerator2(jobject self_, jobject out) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory, &_m_com_fasterxml_jackson_core_JsonFactory_createJsonGenerator2, "createJsonGenerator", "(Ljava/io/OutputStream;)Lcom/fasterxml/jackson/core/JsonGenerator;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory_createJsonGenerator2, out); + return to_global_ref(_result); +} + +jfieldID _f_com_fasterxml_jackson_core_JsonFactory_DEFAULT_FACTORY_FEATURE_FLAGS = NULL; +int32_t get_com_fasterxml_jackson_core_JsonFactory_DEFAULT_FACTORY_FEATURE_FLAGS() { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_static_field(_c_com_fasterxml_jackson_core_JsonFactory, &_f_com_fasterxml_jackson_core_JsonFactory_DEFAULT_FACTORY_FEATURE_FLAGS, "DEFAULT_FACTORY_FEATURE_FLAGS","I"); + return ((*jniEnv)->GetStaticIntField(jniEnv, _c_com_fasterxml_jackson_core_JsonFactory, _f_com_fasterxml_jackson_core_JsonFactory_DEFAULT_FACTORY_FEATURE_FLAGS)); +} + + +jfieldID _f_com_fasterxml_jackson_core_JsonFactory_DEFAULT_PARSER_FEATURE_FLAGS = NULL; +int32_t get_com_fasterxml_jackson_core_JsonFactory_DEFAULT_PARSER_FEATURE_FLAGS() { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_static_field(_c_com_fasterxml_jackson_core_JsonFactory, &_f_com_fasterxml_jackson_core_JsonFactory_DEFAULT_PARSER_FEATURE_FLAGS, "DEFAULT_PARSER_FEATURE_FLAGS","I"); + return ((*jniEnv)->GetStaticIntField(jniEnv, _c_com_fasterxml_jackson_core_JsonFactory, _f_com_fasterxml_jackson_core_JsonFactory_DEFAULT_PARSER_FEATURE_FLAGS)); +} + + +jfieldID _f_com_fasterxml_jackson_core_JsonFactory_DEFAULT_GENERATOR_FEATURE_FLAGS = NULL; +int32_t get_com_fasterxml_jackson_core_JsonFactory_DEFAULT_GENERATOR_FEATURE_FLAGS() { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_static_field(_c_com_fasterxml_jackson_core_JsonFactory, &_f_com_fasterxml_jackson_core_JsonFactory_DEFAULT_GENERATOR_FEATURE_FLAGS, "DEFAULT_GENERATOR_FEATURE_FLAGS","I"); + return ((*jniEnv)->GetStaticIntField(jniEnv, _c_com_fasterxml_jackson_core_JsonFactory, _f_com_fasterxml_jackson_core_JsonFactory_DEFAULT_GENERATOR_FEATURE_FLAGS)); +} + + +jfieldID _f_com_fasterxml_jackson_core_JsonFactory_DEFAULT_ROOT_VALUE_SEPARATOR = NULL; +jobject get_com_fasterxml_jackson_core_JsonFactory_DEFAULT_ROOT_VALUE_SEPARATOR() { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); + load_static_field(_c_com_fasterxml_jackson_core_JsonFactory, &_f_com_fasterxml_jackson_core_JsonFactory_DEFAULT_ROOT_VALUE_SEPARATOR, "DEFAULT_ROOT_VALUE_SEPARATOR","Lcom/fasterxml/jackson/core/SerializableString;"); + return to_global_ref((*jniEnv)->GetStaticObjectField(jniEnv, _c_com_fasterxml_jackson_core_JsonFactory, _f_com_fasterxml_jackson_core_JsonFactory_DEFAULT_ROOT_VALUE_SEPARATOR)); +} + + +// com.fasterxml.jackson.core.JsonFactory$Feature +jclass _c_com_fasterxml_jackson_core_JsonFactory__Feature = NULL; + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory__Feature_values = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory__Feature_values() { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory__Feature, "com/fasterxml/jackson/core/JsonFactory$Feature"); + load_static_method(_c_com_fasterxml_jackson_core_JsonFactory__Feature, &_m_com_fasterxml_jackson_core_JsonFactory__Feature_values, "values", "()L[com/fasterxml/jackson/core/JsonFactory$Feature;"); + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_com_fasterxml_jackson_core_JsonFactory__Feature, _m_com_fasterxml_jackson_core_JsonFactory__Feature_values); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory__Feature_valueOf = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory__Feature_valueOf(jobject name) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory__Feature, "com/fasterxml/jackson/core/JsonFactory$Feature"); + load_static_method(_c_com_fasterxml_jackson_core_JsonFactory__Feature, &_m_com_fasterxml_jackson_core_JsonFactory__Feature_valueOf, "valueOf", "(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonFactory$Feature;"); + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_com_fasterxml_jackson_core_JsonFactory__Feature, _m_com_fasterxml_jackson_core_JsonFactory__Feature_valueOf, name); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory__Feature_collectDefaults = NULL; +FFI_PLUGIN_EXPORT +int32_t com_fasterxml_jackson_core_JsonFactory__Feature_collectDefaults() { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory__Feature, "com/fasterxml/jackson/core/JsonFactory$Feature"); + load_static_method(_c_com_fasterxml_jackson_core_JsonFactory__Feature, &_m_com_fasterxml_jackson_core_JsonFactory__Feature_collectDefaults, "collectDefaults", "()I"); + int32_t _result = (*jniEnv)->CallStaticIntMethod(jniEnv, _c_com_fasterxml_jackson_core_JsonFactory__Feature, _m_com_fasterxml_jackson_core_JsonFactory__Feature_collectDefaults); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory__Feature_ctor = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonFactory__Feature_ctor(uint8_t defaultState) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory__Feature, "com/fasterxml/jackson/core/JsonFactory$Feature"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory__Feature, &_m_com_fasterxml_jackson_core_JsonFactory__Feature_ctor, "", "(Z)V"); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_com_fasterxml_jackson_core_JsonFactory__Feature, _m_com_fasterxml_jackson_core_JsonFactory__Feature_ctor, defaultState); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory__Feature_enabledByDefault = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonFactory__Feature_enabledByDefault(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory__Feature, "com/fasterxml/jackson/core/JsonFactory$Feature"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory__Feature, &_m_com_fasterxml_jackson_core_JsonFactory__Feature_enabledByDefault, "enabledByDefault", "()Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory__Feature_enabledByDefault); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory__Feature_enabledIn = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonFactory__Feature_enabledIn(jobject self_, int32_t flags) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory__Feature, "com/fasterxml/jackson/core/JsonFactory$Feature"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory__Feature, &_m_com_fasterxml_jackson_core_JsonFactory__Feature_enabledIn, "enabledIn", "(I)Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory__Feature_enabledIn, flags); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonFactory__Feature_getMask = NULL; +FFI_PLUGIN_EXPORT +int32_t com_fasterxml_jackson_core_JsonFactory__Feature_getMask(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonFactory__Feature, "com/fasterxml/jackson/core/JsonFactory$Feature"); + load_method(_c_com_fasterxml_jackson_core_JsonFactory__Feature, &_m_com_fasterxml_jackson_core_JsonFactory__Feature_getMask, "getMask", "()I"); + int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonFactory__Feature_getMask); + return _result; +} + +// com.fasterxml.jackson.core.JsonParser +jclass _c_com_fasterxml_jackson_core_JsonParser = NULL; + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_ctor = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_ctor() { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_ctor, "", "()V"); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_com_fasterxml_jackson_core_JsonParser, _m_com_fasterxml_jackson_core_JsonParser_ctor); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_ctor1 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_ctor1(int32_t features) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_ctor1, "", "(I)V"); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_com_fasterxml_jackson_core_JsonParser, _m_com_fasterxml_jackson_core_JsonParser_ctor1, features); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getCodec = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_getCodec(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getCodec, "getCodec", "()Lcom/fasterxml/jackson/core/ObjectCodec;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getCodec); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_setCodec = NULL; +FFI_PLUGIN_EXPORT +void com_fasterxml_jackson_core_JsonParser_setCodec(jobject self_, jobject oc) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_setCodec, "setCodec", "(Lcom/fasterxml/jackson/core/ObjectCodec;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_setCodec, oc); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getInputSource = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_getInputSource(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getInputSource, "getInputSource", "()Ljava/lang/Object;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getInputSource); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_setRequestPayloadOnError = NULL; +FFI_PLUGIN_EXPORT +void com_fasterxml_jackson_core_JsonParser_setRequestPayloadOnError(jobject self_, jobject payload) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_setRequestPayloadOnError, "setRequestPayloadOnError", "(Lcom/fasterxml/jackson/core/util/RequestPayload;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_setRequestPayloadOnError, payload); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_setRequestPayloadOnError1 = NULL; +FFI_PLUGIN_EXPORT +void com_fasterxml_jackson_core_JsonParser_setRequestPayloadOnError1(jobject self_, jobject payload, jobject charset) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_setRequestPayloadOnError1, "setRequestPayloadOnError", "(L[B;Ljava/lang/String;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_setRequestPayloadOnError1, payload, charset); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_setRequestPayloadOnError2 = NULL; +FFI_PLUGIN_EXPORT +void com_fasterxml_jackson_core_JsonParser_setRequestPayloadOnError2(jobject self_, jobject payload) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_setRequestPayloadOnError2, "setRequestPayloadOnError", "(Ljava/lang/String;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_setRequestPayloadOnError2, payload); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_setSchema = NULL; +FFI_PLUGIN_EXPORT +void com_fasterxml_jackson_core_JsonParser_setSchema(jobject self_, jobject schema) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_setSchema, "setSchema", "(Lcom/fasterxml/jackson/core/FormatSchema;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_setSchema, schema); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getSchema = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_getSchema(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getSchema, "getSchema", "()Lcom/fasterxml/jackson/core/FormatSchema;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getSchema); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_canUseSchema = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonParser_canUseSchema(jobject self_, jobject schema) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_canUseSchema, "canUseSchema", "(Lcom/fasterxml/jackson/core/FormatSchema;)Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_canUseSchema, schema); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_requiresCustomCodec = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonParser_requiresCustomCodec(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_requiresCustomCodec, "requiresCustomCodec", "()Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_requiresCustomCodec); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_canParseAsync = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonParser_canParseAsync(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_canParseAsync, "canParseAsync", "()Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_canParseAsync); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getNonBlockingInputFeeder = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_getNonBlockingInputFeeder(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getNonBlockingInputFeeder, "getNonBlockingInputFeeder", "()Lcom/fasterxml/jackson/core/async/NonBlockingInputFeeder;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getNonBlockingInputFeeder); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getReadCapabilities = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_getReadCapabilities(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getReadCapabilities, "getReadCapabilities", "()Lcom/fasterxml/jackson/core/util/JacksonFeatureSet;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getReadCapabilities); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_version = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_version(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_version, "version", "()Lcom/fasterxml/jackson/core/Version;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_version); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_close = NULL; +FFI_PLUGIN_EXPORT +void com_fasterxml_jackson_core_JsonParser_close(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_close, "close", "()V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_close); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_isClosed = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonParser_isClosed(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_isClosed, "isClosed", "()Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_isClosed); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getParsingContext = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_getParsingContext(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getParsingContext, "getParsingContext", "()Lcom/fasterxml/jackson/core/JsonStreamContext;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getParsingContext); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_currentLocation = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_currentLocation(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_currentLocation, "currentLocation", "()Lcom/fasterxml/jackson/core/JsonLocation;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_currentLocation); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_currentTokenLocation = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_currentTokenLocation(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_currentTokenLocation, "currentTokenLocation", "()Lcom/fasterxml/jackson/core/JsonLocation;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_currentTokenLocation); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getCurrentLocation = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_getCurrentLocation(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getCurrentLocation, "getCurrentLocation", "()Lcom/fasterxml/jackson/core/JsonLocation;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getCurrentLocation); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getTokenLocation = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_getTokenLocation(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getTokenLocation, "getTokenLocation", "()Lcom/fasterxml/jackson/core/JsonLocation;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getTokenLocation); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_currentValue = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_currentValue(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_currentValue, "currentValue", "()Ljava/lang/Object;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_currentValue); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_assignCurrentValue = NULL; +FFI_PLUGIN_EXPORT +void com_fasterxml_jackson_core_JsonParser_assignCurrentValue(jobject self_, jobject v) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_assignCurrentValue, "assignCurrentValue", "(Ljava/lang/Object;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_assignCurrentValue, v); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getCurrentValue = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_getCurrentValue(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getCurrentValue, "getCurrentValue", "()Ljava/lang/Object;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getCurrentValue); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_setCurrentValue = NULL; +FFI_PLUGIN_EXPORT +void com_fasterxml_jackson_core_JsonParser_setCurrentValue(jobject self_, jobject v) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_setCurrentValue, "setCurrentValue", "(Ljava/lang/Object;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_setCurrentValue, v); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_releaseBuffered = NULL; +FFI_PLUGIN_EXPORT +int32_t com_fasterxml_jackson_core_JsonParser_releaseBuffered(jobject self_, jobject out) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_releaseBuffered, "releaseBuffered", "(Ljava/io/OutputStream;)I"); + int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_releaseBuffered, out); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_releaseBuffered1 = NULL; +FFI_PLUGIN_EXPORT +int32_t com_fasterxml_jackson_core_JsonParser_releaseBuffered1(jobject self_, jobject w) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_releaseBuffered1, "releaseBuffered", "(Ljava/io/Writer;)I"); + int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_releaseBuffered1, w); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_enable = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_enable(jobject self_, jobject f) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_enable, "enable", "(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/core/JsonParser;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_enable, f); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_disable = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_disable(jobject self_, jobject f) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_disable, "disable", "(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/core/JsonParser;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_disable, f); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_configure = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_configure(jobject self_, jobject f, uint8_t state) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_configure, "configure", "(Lcom/fasterxml/jackson/core/JsonParser$Feature;Z)Lcom/fasterxml/jackson/core/JsonParser;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_configure, f, state); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_isEnabled = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonParser_isEnabled(jobject self_, jobject f) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_isEnabled, "isEnabled", "(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_isEnabled, f); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_isEnabled1 = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonParser_isEnabled1(jobject self_, jobject f) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_isEnabled1, "isEnabled", "(Lcom/fasterxml/jackson/core/StreamReadFeature;)Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_isEnabled1, f); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getFeatureMask = NULL; +FFI_PLUGIN_EXPORT +int32_t com_fasterxml_jackson_core_JsonParser_getFeatureMask(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getFeatureMask, "getFeatureMask", "()I"); + int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getFeatureMask); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_setFeatureMask = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_setFeatureMask(jobject self_, int32_t mask) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_setFeatureMask, "setFeatureMask", "(I)Lcom/fasterxml/jackson/core/JsonParser;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_setFeatureMask, mask); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_overrideStdFeatures = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_overrideStdFeatures(jobject self_, int32_t values, int32_t mask) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_overrideStdFeatures, "overrideStdFeatures", "(II)Lcom/fasterxml/jackson/core/JsonParser;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_overrideStdFeatures, values, mask); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getFormatFeatures = NULL; +FFI_PLUGIN_EXPORT +int32_t com_fasterxml_jackson_core_JsonParser_getFormatFeatures(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getFormatFeatures, "getFormatFeatures", "()I"); + int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getFormatFeatures); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_overrideFormatFeatures = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_overrideFormatFeatures(jobject self_, int32_t values, int32_t mask) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_overrideFormatFeatures, "overrideFormatFeatures", "(II)Lcom/fasterxml/jackson/core/JsonParser;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_overrideFormatFeatures, values, mask); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_nextToken = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_nextToken(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_nextToken, "nextToken", "()Lcom/fasterxml/jackson/core/JsonToken;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_nextToken); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_nextValue = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_nextValue(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_nextValue, "nextValue", "()Lcom/fasterxml/jackson/core/JsonToken;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_nextValue); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_nextFieldName = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonParser_nextFieldName(jobject self_, jobject str) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_nextFieldName, "nextFieldName", "(Lcom/fasterxml/jackson/core/SerializableString;)Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_nextFieldName, str); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_nextFieldName1 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_nextFieldName1(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_nextFieldName1, "nextFieldName", "()Ljava/lang/String;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_nextFieldName1); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_nextTextValue = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_nextTextValue(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_nextTextValue, "nextTextValue", "()Ljava/lang/String;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_nextTextValue); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_nextIntValue = NULL; +FFI_PLUGIN_EXPORT +int32_t com_fasterxml_jackson_core_JsonParser_nextIntValue(jobject self_, int32_t defaultValue) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_nextIntValue, "nextIntValue", "(I)I"); + int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_nextIntValue, defaultValue); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_nextLongValue = NULL; +FFI_PLUGIN_EXPORT +int64_t com_fasterxml_jackson_core_JsonParser_nextLongValue(jobject self_, int64_t defaultValue) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_nextLongValue, "nextLongValue", "(J)J"); + int64_t _result = (*jniEnv)->CallLongMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_nextLongValue, defaultValue); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_nextBooleanValue = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_nextBooleanValue(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_nextBooleanValue, "nextBooleanValue", "()Ljava/lang/Boolean;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_nextBooleanValue); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_skipChildren = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_skipChildren(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_skipChildren, "skipChildren", "()Lcom/fasterxml/jackson/core/JsonParser;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_skipChildren); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_finishToken = NULL; +FFI_PLUGIN_EXPORT +void com_fasterxml_jackson_core_JsonParser_finishToken(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_finishToken, "finishToken", "()V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_finishToken); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_currentToken = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_currentToken(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_currentToken, "currentToken", "()Lcom/fasterxml/jackson/core/JsonToken;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_currentToken); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_currentTokenId = NULL; +FFI_PLUGIN_EXPORT +int32_t com_fasterxml_jackson_core_JsonParser_currentTokenId(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_currentTokenId, "currentTokenId", "()I"); + int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_currentTokenId); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getCurrentToken = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_getCurrentToken(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getCurrentToken, "getCurrentToken", "()Lcom/fasterxml/jackson/core/JsonToken;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getCurrentToken); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getCurrentTokenId = NULL; +FFI_PLUGIN_EXPORT +int32_t com_fasterxml_jackson_core_JsonParser_getCurrentTokenId(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getCurrentTokenId, "getCurrentTokenId", "()I"); + int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getCurrentTokenId); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_hasCurrentToken = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonParser_hasCurrentToken(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_hasCurrentToken, "hasCurrentToken", "()Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_hasCurrentToken); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_hasTokenId = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonParser_hasTokenId(jobject self_, int32_t id) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_hasTokenId, "hasTokenId", "(I)Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_hasTokenId, id); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_hasToken = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonParser_hasToken(jobject self_, jobject t) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_hasToken, "hasToken", "(Lcom/fasterxml/jackson/core/JsonToken;)Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_hasToken, t); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_isExpectedStartArrayToken = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonParser_isExpectedStartArrayToken(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_isExpectedStartArrayToken, "isExpectedStartArrayToken", "()Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_isExpectedStartArrayToken); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_isExpectedStartObjectToken = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonParser_isExpectedStartObjectToken(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_isExpectedStartObjectToken, "isExpectedStartObjectToken", "()Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_isExpectedStartObjectToken); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_isExpectedNumberIntToken = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonParser_isExpectedNumberIntToken(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_isExpectedNumberIntToken, "isExpectedNumberIntToken", "()Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_isExpectedNumberIntToken); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_isNaN = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonParser_isNaN(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_isNaN, "isNaN", "()Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_isNaN); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_clearCurrentToken = NULL; +FFI_PLUGIN_EXPORT +void com_fasterxml_jackson_core_JsonParser_clearCurrentToken(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_clearCurrentToken, "clearCurrentToken", "()V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_clearCurrentToken); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getLastClearedToken = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_getLastClearedToken(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getLastClearedToken, "getLastClearedToken", "()Lcom/fasterxml/jackson/core/JsonToken;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getLastClearedToken); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_overrideCurrentName = NULL; +FFI_PLUGIN_EXPORT +void com_fasterxml_jackson_core_JsonParser_overrideCurrentName(jobject self_, jobject name) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_overrideCurrentName, "overrideCurrentName", "(Ljava/lang/String;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_overrideCurrentName, name); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getCurrentName = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_getCurrentName(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getCurrentName, "getCurrentName", "()Ljava/lang/String;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getCurrentName); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_currentName = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_currentName(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_currentName, "currentName", "()Ljava/lang/String;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_currentName); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getText = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_getText(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getText, "getText", "()Ljava/lang/String;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getText); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getText1 = NULL; +FFI_PLUGIN_EXPORT +int32_t com_fasterxml_jackson_core_JsonParser_getText1(jobject self_, jobject writer) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getText1, "getText", "(Ljava/io/Writer;)I"); + int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getText1, writer); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getTextCharacters = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_getTextCharacters(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getTextCharacters, "getTextCharacters", "()L[C;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getTextCharacters); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getTextLength = NULL; +FFI_PLUGIN_EXPORT +int32_t com_fasterxml_jackson_core_JsonParser_getTextLength(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getTextLength, "getTextLength", "()I"); + int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getTextLength); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getTextOffset = NULL; +FFI_PLUGIN_EXPORT +int32_t com_fasterxml_jackson_core_JsonParser_getTextOffset(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getTextOffset, "getTextOffset", "()I"); + int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getTextOffset); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_hasTextCharacters = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonParser_hasTextCharacters(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_hasTextCharacters, "hasTextCharacters", "()Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_hasTextCharacters); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getNumberValue = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_getNumberValue(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getNumberValue, "getNumberValue", "()Ljava/lang/Number;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getNumberValue); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getNumberValueExact = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_getNumberValueExact(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getNumberValueExact, "getNumberValueExact", "()Ljava/lang/Number;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getNumberValueExact); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getNumberType = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_getNumberType(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getNumberType, "getNumberType", "()Lcom/fasterxml/jackson/core/JsonParser$NumberType;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getNumberType); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getByteValue = NULL; +FFI_PLUGIN_EXPORT +int8_t com_fasterxml_jackson_core_JsonParser_getByteValue(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getByteValue, "getByteValue", "()B"); + int8_t _result = (*jniEnv)->CallByteMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getByteValue); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getShortValue = NULL; +FFI_PLUGIN_EXPORT +int16_t com_fasterxml_jackson_core_JsonParser_getShortValue(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getShortValue, "getShortValue", "()S"); + int16_t _result = (*jniEnv)->CallShortMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getShortValue); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getIntValue = NULL; +FFI_PLUGIN_EXPORT +int32_t com_fasterxml_jackson_core_JsonParser_getIntValue(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getIntValue, "getIntValue", "()I"); + int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getIntValue); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getLongValue = NULL; +FFI_PLUGIN_EXPORT +int64_t com_fasterxml_jackson_core_JsonParser_getLongValue(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getLongValue, "getLongValue", "()J"); + int64_t _result = (*jniEnv)->CallLongMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getLongValue); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getBigIntegerValue = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_getBigIntegerValue(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getBigIntegerValue, "getBigIntegerValue", "()Ljava/math/BigInteger;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getBigIntegerValue); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getFloatValue = NULL; +FFI_PLUGIN_EXPORT +float com_fasterxml_jackson_core_JsonParser_getFloatValue(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getFloatValue, "getFloatValue", "()F"); + float _result = (*jniEnv)->CallFloatMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getFloatValue); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getDoubleValue = NULL; +FFI_PLUGIN_EXPORT +double com_fasterxml_jackson_core_JsonParser_getDoubleValue(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getDoubleValue, "getDoubleValue", "()D"); + double _result = (*jniEnv)->CallDoubleMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getDoubleValue); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getDecimalValue = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_getDecimalValue(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getDecimalValue, "getDecimalValue", "()Ljava/math/BigDecimal;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getDecimalValue); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getBooleanValue = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonParser_getBooleanValue(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getBooleanValue, "getBooleanValue", "()Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getBooleanValue); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getEmbeddedObject = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_getEmbeddedObject(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getEmbeddedObject, "getEmbeddedObject", "()Ljava/lang/Object;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getEmbeddedObject); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getBinaryValue = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_getBinaryValue(jobject self_, jobject bv) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getBinaryValue, "getBinaryValue", "(Lcom/fasterxml/jackson/core/Base64Variant;)L[B;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getBinaryValue, bv); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getBinaryValue1 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_getBinaryValue1(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getBinaryValue1, "getBinaryValue", "()L[B;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getBinaryValue1); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_readBinaryValue = NULL; +FFI_PLUGIN_EXPORT +int32_t com_fasterxml_jackson_core_JsonParser_readBinaryValue(jobject self_, jobject out) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_readBinaryValue, "readBinaryValue", "(Ljava/io/OutputStream;)I"); + int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_readBinaryValue, out); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_readBinaryValue1 = NULL; +FFI_PLUGIN_EXPORT +int32_t com_fasterxml_jackson_core_JsonParser_readBinaryValue1(jobject self_, jobject bv, jobject out) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_readBinaryValue1, "readBinaryValue", "(Lcom/fasterxml/jackson/core/Base64Variant;Ljava/io/OutputStream;)I"); + int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_readBinaryValue1, bv, out); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getValueAsInt = NULL; +FFI_PLUGIN_EXPORT +int32_t com_fasterxml_jackson_core_JsonParser_getValueAsInt(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getValueAsInt, "getValueAsInt", "()I"); + int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getValueAsInt); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getValueAsInt1 = NULL; +FFI_PLUGIN_EXPORT +int32_t com_fasterxml_jackson_core_JsonParser_getValueAsInt1(jobject self_, int32_t def) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getValueAsInt1, "getValueAsInt", "(I)I"); + int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getValueAsInt1, def); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getValueAsLong = NULL; +FFI_PLUGIN_EXPORT +int64_t com_fasterxml_jackson_core_JsonParser_getValueAsLong(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getValueAsLong, "getValueAsLong", "()J"); + int64_t _result = (*jniEnv)->CallLongMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getValueAsLong); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getValueAsLong1 = NULL; +FFI_PLUGIN_EXPORT +int64_t com_fasterxml_jackson_core_JsonParser_getValueAsLong1(jobject self_, int64_t def) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getValueAsLong1, "getValueAsLong", "(J)J"); + int64_t _result = (*jniEnv)->CallLongMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getValueAsLong1, def); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getValueAsDouble = NULL; +FFI_PLUGIN_EXPORT +double com_fasterxml_jackson_core_JsonParser_getValueAsDouble(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getValueAsDouble, "getValueAsDouble", "()D"); + double _result = (*jniEnv)->CallDoubleMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getValueAsDouble); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getValueAsDouble1 = NULL; +FFI_PLUGIN_EXPORT +double com_fasterxml_jackson_core_JsonParser_getValueAsDouble1(jobject self_, double def) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getValueAsDouble1, "getValueAsDouble", "(D)D"); + double _result = (*jniEnv)->CallDoubleMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getValueAsDouble1, def); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getValueAsBoolean = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonParser_getValueAsBoolean(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getValueAsBoolean, "getValueAsBoolean", "()Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getValueAsBoolean); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getValueAsBoolean1 = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonParser_getValueAsBoolean1(jobject self_, uint8_t def) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getValueAsBoolean1, "getValueAsBoolean", "(Z)Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getValueAsBoolean1, def); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getValueAsString = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_getValueAsString(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getValueAsString, "getValueAsString", "()Ljava/lang/String;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getValueAsString); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getValueAsString1 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_getValueAsString1(jobject self_, jobject def) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getValueAsString1, "getValueAsString", "(Ljava/lang/String;)Ljava/lang/String;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getValueAsString1, def); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_canReadObjectId = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonParser_canReadObjectId(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_canReadObjectId, "canReadObjectId", "()Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_canReadObjectId); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_canReadTypeId = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonParser_canReadTypeId(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_canReadTypeId, "canReadTypeId", "()Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_canReadTypeId); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getObjectId = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_getObjectId(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getObjectId, "getObjectId", "()Ljava/lang/Object;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getObjectId); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_getTypeId = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_getTypeId(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_getTypeId, "getTypeId", "()Ljava/lang/Object;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_getTypeId); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_readValueAs = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_readValueAs(jobject self_, jobject valueType) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_readValueAs, "readValueAs", "(Ljava/lang/Class;)Ljava/lang/Object;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_readValueAs, valueType); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_readValueAs1 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_readValueAs1(jobject self_, jobject valueTypeRef) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_readValueAs1, "readValueAs", "(Lcom/fasterxml/jackson/core/type/TypeReference;)Ljava/lang/Object;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_readValueAs1, valueTypeRef); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_readValuesAs = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_readValuesAs(jobject self_, jobject valueType) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_readValuesAs, "readValuesAs", "(Ljava/lang/Class;)Ljava/util/Iterator;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_readValuesAs, valueType); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_readValuesAs1 = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_readValuesAs1(jobject self_, jobject valueTypeRef) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_readValuesAs1, "readValuesAs", "(Lcom/fasterxml/jackson/core/type/TypeReference;)Ljava/util/Iterator;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_readValuesAs1, valueTypeRef); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser_readValueAsTree = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser_readValueAsTree(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_method(_c_com_fasterxml_jackson_core_JsonParser, &_m_com_fasterxml_jackson_core_JsonParser_readValueAsTree, "readValueAsTree", "()Ljava/lang/Object;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser_readValueAsTree); + return to_global_ref(_result); +} + +jfieldID _f_com_fasterxml_jackson_core_JsonParser_DEFAULT_READ_CAPABILITIES = NULL; +jobject get_com_fasterxml_jackson_core_JsonParser_DEFAULT_READ_CAPABILITIES() { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser, "com/fasterxml/jackson/core/JsonParser"); + load_static_field(_c_com_fasterxml_jackson_core_JsonParser, &_f_com_fasterxml_jackson_core_JsonParser_DEFAULT_READ_CAPABILITIES, "DEFAULT_READ_CAPABILITIES","Lcom/fasterxml/jackson/core/util/JacksonFeatureSet;"); + return to_global_ref((*jniEnv)->GetStaticObjectField(jniEnv, _c_com_fasterxml_jackson_core_JsonParser, _f_com_fasterxml_jackson_core_JsonParser_DEFAULT_READ_CAPABILITIES)); +} + + +// com.fasterxml.jackson.core.JsonParser$Feature +jclass _c_com_fasterxml_jackson_core_JsonParser__Feature = NULL; + +jmethodID _m_com_fasterxml_jackson_core_JsonParser__Feature_values = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser__Feature_values() { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser__Feature, "com/fasterxml/jackson/core/JsonParser$Feature"); + load_static_method(_c_com_fasterxml_jackson_core_JsonParser__Feature, &_m_com_fasterxml_jackson_core_JsonParser__Feature_values, "values", "()L[com/fasterxml/jackson/core/JsonParser$Feature;"); + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_com_fasterxml_jackson_core_JsonParser__Feature, _m_com_fasterxml_jackson_core_JsonParser__Feature_values); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser__Feature_valueOf = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser__Feature_valueOf(jobject name) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser__Feature, "com/fasterxml/jackson/core/JsonParser$Feature"); + load_static_method(_c_com_fasterxml_jackson_core_JsonParser__Feature, &_m_com_fasterxml_jackson_core_JsonParser__Feature_valueOf, "valueOf", "(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonParser$Feature;"); + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_com_fasterxml_jackson_core_JsonParser__Feature, _m_com_fasterxml_jackson_core_JsonParser__Feature_valueOf, name); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser__Feature_collectDefaults = NULL; +FFI_PLUGIN_EXPORT +int32_t com_fasterxml_jackson_core_JsonParser__Feature_collectDefaults() { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser__Feature, "com/fasterxml/jackson/core/JsonParser$Feature"); + load_static_method(_c_com_fasterxml_jackson_core_JsonParser__Feature, &_m_com_fasterxml_jackson_core_JsonParser__Feature_collectDefaults, "collectDefaults", "()I"); + int32_t _result = (*jniEnv)->CallStaticIntMethod(jniEnv, _c_com_fasterxml_jackson_core_JsonParser__Feature, _m_com_fasterxml_jackson_core_JsonParser__Feature_collectDefaults); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser__Feature_ctor = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser__Feature_ctor(uint8_t defaultState) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser__Feature, "com/fasterxml/jackson/core/JsonParser$Feature"); + load_method(_c_com_fasterxml_jackson_core_JsonParser__Feature, &_m_com_fasterxml_jackson_core_JsonParser__Feature_ctor, "", "(Z)V"); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_com_fasterxml_jackson_core_JsonParser__Feature, _m_com_fasterxml_jackson_core_JsonParser__Feature_ctor, defaultState); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser__Feature_enabledByDefault = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonParser__Feature_enabledByDefault(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser__Feature, "com/fasterxml/jackson/core/JsonParser$Feature"); + load_method(_c_com_fasterxml_jackson_core_JsonParser__Feature, &_m_com_fasterxml_jackson_core_JsonParser__Feature_enabledByDefault, "enabledByDefault", "()Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser__Feature_enabledByDefault); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser__Feature_enabledIn = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonParser__Feature_enabledIn(jobject self_, int32_t flags) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser__Feature, "com/fasterxml/jackson/core/JsonParser$Feature"); + load_method(_c_com_fasterxml_jackson_core_JsonParser__Feature, &_m_com_fasterxml_jackson_core_JsonParser__Feature_enabledIn, "enabledIn", "(I)Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser__Feature_enabledIn, flags); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser__Feature_getMask = NULL; +FFI_PLUGIN_EXPORT +int32_t com_fasterxml_jackson_core_JsonParser__Feature_getMask(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser__Feature, "com/fasterxml/jackson/core/JsonParser$Feature"); + load_method(_c_com_fasterxml_jackson_core_JsonParser__Feature, &_m_com_fasterxml_jackson_core_JsonParser__Feature_getMask, "getMask", "()I"); + int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonParser__Feature_getMask); + return _result; +} + +// com.fasterxml.jackson.core.JsonParser$NumberType +jclass _c_com_fasterxml_jackson_core_JsonParser__NumberType = NULL; + +jmethodID _m_com_fasterxml_jackson_core_JsonParser__NumberType_values = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser__NumberType_values() { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser__NumberType, "com/fasterxml/jackson/core/JsonParser$NumberType"); + load_static_method(_c_com_fasterxml_jackson_core_JsonParser__NumberType, &_m_com_fasterxml_jackson_core_JsonParser__NumberType_values, "values", "()L[com/fasterxml/jackson/core/JsonParser$NumberType;"); + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_com_fasterxml_jackson_core_JsonParser__NumberType, _m_com_fasterxml_jackson_core_JsonParser__NumberType_values); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser__NumberType_valueOf = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser__NumberType_valueOf(jobject name) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser__NumberType, "com/fasterxml/jackson/core/JsonParser$NumberType"); + load_static_method(_c_com_fasterxml_jackson_core_JsonParser__NumberType, &_m_com_fasterxml_jackson_core_JsonParser__NumberType_valueOf, "valueOf", "(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonParser$NumberType;"); + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_com_fasterxml_jackson_core_JsonParser__NumberType, _m_com_fasterxml_jackson_core_JsonParser__NumberType_valueOf, name); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonParser__NumberType_ctor = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonParser__NumberType_ctor() { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonParser__NumberType, "com/fasterxml/jackson/core/JsonParser$NumberType"); + load_method(_c_com_fasterxml_jackson_core_JsonParser__NumberType, &_m_com_fasterxml_jackson_core_JsonParser__NumberType_ctor, "", "()V"); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_com_fasterxml_jackson_core_JsonParser__NumberType, _m_com_fasterxml_jackson_core_JsonParser__NumberType_ctor); + return to_global_ref(_result); +} + +// com.fasterxml.jackson.core.JsonToken +jclass _c_com_fasterxml_jackson_core_JsonToken = NULL; + +jmethodID _m_com_fasterxml_jackson_core_JsonToken_values = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonToken_values() { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonToken, "com/fasterxml/jackson/core/JsonToken"); + load_static_method(_c_com_fasterxml_jackson_core_JsonToken, &_m_com_fasterxml_jackson_core_JsonToken_values, "values", "()L[com/fasterxml/jackson/core/JsonToken;"); + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_com_fasterxml_jackson_core_JsonToken, _m_com_fasterxml_jackson_core_JsonToken_values); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonToken_valueOf = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonToken_valueOf(jobject name) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonToken, "com/fasterxml/jackson/core/JsonToken"); + load_static_method(_c_com_fasterxml_jackson_core_JsonToken, &_m_com_fasterxml_jackson_core_JsonToken_valueOf, "valueOf", "(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonToken;"); + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_com_fasterxml_jackson_core_JsonToken, _m_com_fasterxml_jackson_core_JsonToken_valueOf, name); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonToken_ctor = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonToken_ctor(jobject token, int32_t id) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonToken, "com/fasterxml/jackson/core/JsonToken"); + load_method(_c_com_fasterxml_jackson_core_JsonToken, &_m_com_fasterxml_jackson_core_JsonToken_ctor, "", "(Ljava/lang/String;I)V"); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_com_fasterxml_jackson_core_JsonToken, _m_com_fasterxml_jackson_core_JsonToken_ctor, token, id); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonToken_id = NULL; +FFI_PLUGIN_EXPORT +int32_t com_fasterxml_jackson_core_JsonToken_id(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonToken, "com/fasterxml/jackson/core/JsonToken"); + load_method(_c_com_fasterxml_jackson_core_JsonToken, &_m_com_fasterxml_jackson_core_JsonToken_id, "id", "()I"); + int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonToken_id); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonToken_asString = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonToken_asString(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonToken, "com/fasterxml/jackson/core/JsonToken"); + load_method(_c_com_fasterxml_jackson_core_JsonToken, &_m_com_fasterxml_jackson_core_JsonToken_asString, "asString", "()Ljava/lang/String;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonToken_asString); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonToken_asCharArray = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonToken_asCharArray(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonToken, "com/fasterxml/jackson/core/JsonToken"); + load_method(_c_com_fasterxml_jackson_core_JsonToken, &_m_com_fasterxml_jackson_core_JsonToken_asCharArray, "asCharArray", "()L[C;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonToken_asCharArray); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonToken_asByteArray = NULL; +FFI_PLUGIN_EXPORT +jobject com_fasterxml_jackson_core_JsonToken_asByteArray(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonToken, "com/fasterxml/jackson/core/JsonToken"); + load_method(_c_com_fasterxml_jackson_core_JsonToken, &_m_com_fasterxml_jackson_core_JsonToken_asByteArray, "asByteArray", "()L[B;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonToken_asByteArray); + return to_global_ref(_result); +} + +jmethodID _m_com_fasterxml_jackson_core_JsonToken_isNumeric = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonToken_isNumeric(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonToken, "com/fasterxml/jackson/core/JsonToken"); + load_method(_c_com_fasterxml_jackson_core_JsonToken, &_m_com_fasterxml_jackson_core_JsonToken_isNumeric, "isNumeric", "()Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonToken_isNumeric); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonToken_isStructStart = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonToken_isStructStart(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonToken, "com/fasterxml/jackson/core/JsonToken"); + load_method(_c_com_fasterxml_jackson_core_JsonToken, &_m_com_fasterxml_jackson_core_JsonToken_isStructStart, "isStructStart", "()Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonToken_isStructStart); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonToken_isStructEnd = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonToken_isStructEnd(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonToken, "com/fasterxml/jackson/core/JsonToken"); + load_method(_c_com_fasterxml_jackson_core_JsonToken, &_m_com_fasterxml_jackson_core_JsonToken_isStructEnd, "isStructEnd", "()Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonToken_isStructEnd); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonToken_isScalarValue = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonToken_isScalarValue(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonToken, "com/fasterxml/jackson/core/JsonToken"); + load_method(_c_com_fasterxml_jackson_core_JsonToken, &_m_com_fasterxml_jackson_core_JsonToken_isScalarValue, "isScalarValue", "()Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonToken_isScalarValue); + return _result; +} + +jmethodID _m_com_fasterxml_jackson_core_JsonToken_isBoolean = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_fasterxml_jackson_core_JsonToken_isBoolean(jobject self_) { + load_env(); + load_class_gr(&_c_com_fasterxml_jackson_core_JsonToken, "com/fasterxml/jackson/core/JsonToken"); + load_method(_c_com_fasterxml_jackson_core_JsonToken, &_m_com_fasterxml_jackson_core_JsonToken_isBoolean, "isBoolean", "()Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_fasterxml_jackson_core_JsonToken_isBoolean); + return _result; +} + diff --git a/pkgs/jni_gen/test/my_test.dart b/pkgs/jni_gen/test/my_test.dart deleted file mode 100644 index 647cfd35b..000000000 --- a/pkgs/jni_gen/test/my_test.dart +++ /dev/null @@ -1,13 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -import 'package:test/test.dart'; -import 'package:jni_gen/jni_gen.dart'; - -void main() { - test('dummy test', () { - final result = mySum(2, 40); - expect(result, 42); - }); -} diff --git a/pkgs/jni_gen/test/package_resolver_test.dart b/pkgs/jni_gen/test/package_resolver_test.dart new file mode 100644 index 000000000..ac5809031 --- /dev/null +++ b/pkgs/jni_gen/test/package_resolver_test.dart @@ -0,0 +1,63 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +import 'package:jni_gen/src/bindings/symbol_resolver.dart'; +import 'package:jni_gen/src/util/name_utils.dart'; +import 'package:test/test.dart'; + +class ResolverTest { + ResolverTest(this.binaryName, this.expectedImport, this.expectedName); + String binaryName; + String expectedImport; + String expectedName; +} + +void main() { + final resolver = PackagePathResolver( + { + 'org.apache.pdfbox': 'package:pdfbox', + 'org.apache.fontbox': 'package:fontbox', + 'java.lang': 'package:java_lang', + 'java.util': 'package:java_util', + 'org.me.package': 'package:my_package/src/', + }, + 'a.b', + {'a.b.C', 'a.b.c.D', 'a.b.c.d.E', 'a.X', 'a.g.Y'}); + + final tests = [ + // Simple example + ResolverTest('org.apache.pdfbox.PDF', + 'package:pdfbox/org/apache/pdfbox.dart', 'pdfbox_.PDF'), + // Nested classes + ResolverTest('org.apache.fontbox.Font\$FontFile', + 'package:fontbox/org/apache/fontbox.dart', 'fontbox_.Font_FontFile'), + // slightly deeper package + ResolverTest('java.lang.ref.WeakReference', + 'package:java_lang/java/lang/ref.dart', 'ref_.WeakReference'), + // Renaming + ResolverTest('java.util.U', 'package:java_util/java/util.dart', 'util_.U'), + ResolverTest('org.me.package.util.U', + 'package:my_package/src/org/me/package/util.dart', 'util1_.U'), + // Relative imports + ResolverTest('a.b.c.D', 'b/c.dart', 'c_.D'), + ResolverTest('a.b.c.d.E', 'b/c/d.dart', 'd_.E'), + ResolverTest('a.X', '../a.dart', 'a_.X'), + ResolverTest('a.g.Y', '../a/g.dart', 'g_.Y'), + ]; + + for (var testCase in tests) { + final binaryName = testCase.binaryName; + final packageName = cutFromLast(binaryName, '.')[0]; + test( + 'getImport $binaryName', + () => expect(resolver.getImport(packageName, binaryName), + equals(testCase.expectedImport))); + test( + 'resolve $binaryName', + () => expect( + resolver.resolve(binaryName), equals(testCase.expectedName))); + } + test('resolve in same package', + () => expect(resolver.resolve('a.b.C'), equals('C'))); +} diff --git a/pkgs/jni_gen/test/simple_package_test/.gitignore b/pkgs/jni_gen/test/simple_package_test/.gitignore new file mode 100644 index 000000000..cbd7ab37c --- /dev/null +++ b/pkgs/jni_gen/test/simple_package_test/.gitignore @@ -0,0 +1,5 @@ +build/ +*.class +test_lib/ +test_src/ + diff --git a/pkgs/jni_gen/test/simple_package_test/generate.dart b/pkgs/jni_gen/test/simple_package_test/generate.dart new file mode 100644 index 000000000..427098de3 --- /dev/null +++ b/pkgs/jni_gen/test/simple_package_test/generate.dart @@ -0,0 +1,47 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +import 'dart:io'; + +import 'package:path/path.dart'; +import 'package:jni_gen/jni_gen.dart'; + +import '../test_util/test_util.dart'; + +const testName = 'simple_package_test'; +final testRoot = join('test', testName); +final javaPath = join(testRoot, 'java'); + +var javaFiles = ['dev/dart/$testName/Example.java', 'dev/dart/pkg2/C2.java']; + +Future compileJavaSources(String workingDir, List files) async { + await runCmd('javac', files, workingDirectory: workingDir); +} + +Future generateSources(String lib, String src) async { + await runCmd('dart', ['run', 'jni_gen:setup']); + await compileJavaSources(javaPath, javaFiles); + final cWrapperDir = Uri.directory(join(testRoot, src)); + final dartWrappersRoot = Uri.directory(join(testRoot, lib)); + final cDir = Directory.fromUri(cWrapperDir); + final dartDir = Directory.fromUri(dartWrappersRoot); + for (var dir in [cDir, dartDir]) { + if (await dir.exists()) { + await dir.delete(recursive: true); + } + } + await JniGenTask( + summarySource: SummarizerCommand( + sourcePaths: [Uri.directory(javaPath)], + classPaths: [Uri.directory(javaPath)], + classes: ['dev.dart.simple_package', 'dev.dart.pkg2'], + ), + outputWriter: FilesWriter( + cWrapperDir: cWrapperDir, + dartWrappersRoot: dartWrappersRoot, + libraryName: 'simple_package'), + ).run(); +} + +void main() async => await generateSources('lib', 'src'); diff --git a/pkgs/jni_gen/test/simple_package_test/generated_files_test.dart b/pkgs/jni_gen/test/simple_package_test/generated_files_test.dart new file mode 100644 index 000000000..c77a89889 --- /dev/null +++ b/pkgs/jni_gen/test/simple_package_test/generated_files_test.dart @@ -0,0 +1,18 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +import 'package:test/test.dart'; +import 'package:path/path.dart' hide equals; + +import 'generate.dart'; +import '../test_util/test_util.dart'; + +void main() async { + await generateSources('test_lib', 'test_src'); + // test if generated file == expected file + test('compare generated files', () { + compareDirs(join(testRoot, 'lib'), join(testRoot, 'test_lib')); + compareDirs(join(testRoot, 'src'), join(testRoot, 'test_src')); + }); +} diff --git a/pkgs/jni_gen/test/simple_package_test/java/dev/dart/pkg2/C2.java b/pkgs/jni_gen/test/simple_package_test/java/dev/dart/pkg2/C2.java new file mode 100644 index 000000000..67f543ea8 --- /dev/null +++ b/pkgs/jni_gen/test/simple_package_test/java/dev/dart/pkg2/C2.java @@ -0,0 +1,5 @@ +package dev.dart.pkg2; + +public class C2 { + public static int CONSTANT = 12; +} diff --git a/pkgs/jni_gen/test/simple_package_test/java/dev/dart/simple_package/Example.java b/pkgs/jni_gen/test/simple_package_test/java/dev/dart/simple_package/Example.java new file mode 100644 index 000000000..116deedbf --- /dev/null +++ b/pkgs/jni_gen/test/simple_package_test/java/dev/dart/simple_package/Example.java @@ -0,0 +1,50 @@ +package dev.dart.simple_package; + +public class Example { + public static final int ON = 1; + public static final int OFF = 0; + + public static Aux aux; + public static int num; + + static { + aux = new Aux(true); + num = 121; + } + + public static Aux getAux() { + return aux; + } + + public static int addInts(int a, int b) { + return a + b; + } + + public Example getSelf() { + return this; + } + + public int getNum() { + return num; + } + + public void setNum(int num) { + this.num = num; + } + + public static class Aux { + public boolean value; + + public Aux(boolean value) { + this.value = value; + } + + public boolean getValue() { + return value; + } + + public void setValue(boolean value) { + this.value = value; + } + } +} diff --git a/pkgs/jni_gen/test/simple_package_test/lib/dev/dart/pkg2.dart b/pkgs/jni_gen/test/simple_package_test/lib/dev/dart/pkg2.dart new file mode 100644 index 000000000..618b1750c --- /dev/null +++ b/pkgs/jni_gen/test/simple_package_test/lib/dev/dart/pkg2.dart @@ -0,0 +1,41 @@ +// Autogenerated by jni_gen. DO NOT EDIT! + +// ignore_for_file: camel_case_types +// ignore_for_file: non_constant_identifier_names +// ignore_for_file: constant_identifier_names +// ignore_for_file: annotate_overrides +// ignore_for_file: no_leading_underscores_for_local_identifiers +// ignore_for_file: unused_element + +import "dart:ffi" as ffi; + +import "package:jni/jni.dart" as jni; + +import "../../init.dart" show jlookup; + +/// from: dev.dart.pkg2.C2 +class C2 extends jni.JlObject { + C2.fromRef(ffi.Pointer ref) : super.fromRef(ref); + + static final _getCONSTANT = jlookup>( + "get_dev_dart_pkg2_C2_CONSTANT") + .asFunction(); + + /// from: static public int CONSTANT + static int get CONSTANT => _getCONSTANT(); + static final _setCONSTANT = + jlookup>( + "set_dev_dart_pkg2_C2_CONSTANT") + .asFunction(); + + /// from: static public int CONSTANT + static set CONSTANT(int value) => _setCONSTANT(value); + + static final _ctor = + jlookup Function()>>( + "dev_dart_pkg2_C2_ctor") + .asFunction Function()>(); + + /// from: public void () + C2() : super.fromRef(_ctor()); +} diff --git a/pkgs/jni_gen/test/simple_package_test/lib/dev/dart/simple_package.dart b/pkgs/jni_gen/test/simple_package_test/lib/dev/dart/simple_package.dart new file mode 100644 index 000000000..da6ec32fb --- /dev/null +++ b/pkgs/jni_gen/test/simple_package_test/lib/dev/dart/simple_package.dart @@ -0,0 +1,159 @@ +// Autogenerated by jni_gen. DO NOT EDIT! + +// ignore_for_file: camel_case_types +// ignore_for_file: non_constant_identifier_names +// ignore_for_file: constant_identifier_names +// ignore_for_file: annotate_overrides +// ignore_for_file: no_leading_underscores_for_local_identifiers +// ignore_for_file: unused_element + +import "dart:ffi" as ffi; + +import "package:jni/jni.dart" as jni; + +import "../../init.dart" show jlookup; + +/// from: dev.dart.simple_package.Example +class Example extends jni.JlObject { + Example.fromRef(ffi.Pointer ref) : super.fromRef(ref); + + /// from: static public final int ON + static const ON = 1; + + /// from: static public final int OFF + static const OFF = 0; + + static final _getaux = + jlookup Function()>>( + "get_dev_dart_simple_package_Example_aux") + .asFunction Function()>(); + + /// from: static public dev.dart.simple_package.Example.Aux aux + /// The returned object must be deleted after use, by calling the `delete` method. + static Example_Aux get aux => Example_Aux.fromRef(_getaux()); + static final _setaux = + jlookup)>>( + "set_dev_dart_simple_package_Example_aux") + .asFunction)>(); + + /// from: static public dev.dart.simple_package.Example.Aux aux + /// The returned object must be deleted after use, by calling the `delete` method. + static set aux(Example_Aux value) => _setaux(value.reference); + + static final _getnum = jlookup>( + "get_dev_dart_simple_package_Example_num") + .asFunction(); + + /// from: static public int num + static int get num => _getnum(); + static final _setnum = + jlookup>( + "set_dev_dart_simple_package_Example_num") + .asFunction(); + + /// from: static public int num + static set num(int value) => _setnum(value); + + static final _ctor = + jlookup Function()>>( + "dev_dart_simple_package_Example_ctor") + .asFunction Function()>(); + + /// from: public void () + Example() : super.fromRef(_ctor()); + + static final _getAux = + jlookup Function()>>( + "dev_dart_simple_package_Example_getAux") + .asFunction Function()>(); + + /// from: static public dev.dart.simple_package.Example.Aux getAux() + /// The returned object must be deleted after use, by calling the `delete` method. + static Example_Aux getAux() => Example_Aux.fromRef(_getAux()); + + static final _addInts = + jlookup>( + "dev_dart_simple_package_Example_addInts") + .asFunction(); + + /// from: static public int addInts(int a, int b) + static int addInts(int a, int b) => _addInts(a, b); + + static final _getSelf = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "dev_dart_simple_package_Example_getSelf") + .asFunction Function(ffi.Pointer)>(); + + /// from: public dev.dart.simple_package.Example getSelf() + /// The returned object must be deleted after use, by calling the `delete` method. + Example getSelf() => Example.fromRef(_getSelf(reference)); + + static final _getNum = + jlookup)>>( + "dev_dart_simple_package_Example_getNum") + .asFunction)>(); + + /// from: public int getNum() + int getNum() => _getNum(reference); + + static final _setNum = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, + ffi.Int32)>>("dev_dart_simple_package_Example_setNum") + .asFunction, int)>(); + + /// from: public void setNum(int num) + void setNum(int num) => _setNum(reference, num); +} + +/// from: dev.dart.simple_package.Example$Aux +class Example_Aux extends jni.JlObject { + Example_Aux.fromRef(ffi.Pointer ref) : super.fromRef(ref); + + static final _getvalue = jlookup< + ffi.NativeFunction< + ffi.Uint8 Function( + ffi.Pointer, + )>>("get_dev_dart_simple_package_Example__Aux_value") + .asFunction< + int Function( + ffi.Pointer, + )>(); + + /// from: public boolean value + bool get value => _getvalue(reference) != 0; + static final _setvalue = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, + ffi.Uint8)>>("set_dev_dart_simple_package_Example__Aux_value") + .asFunction, int)>(); + + /// from: public boolean value + set value(bool value) => _setvalue(reference, value ? 1 : 0); + + static final _ctor = + jlookup Function(ffi.Uint8)>>( + "dev_dart_simple_package_Example__Aux_ctor") + .asFunction Function(int)>(); + + /// from: public void (boolean value) + Example_Aux(bool value) : super.fromRef(_ctor(value ? 1 : 0)); + + static final _getValue = + jlookup)>>( + "dev_dart_simple_package_Example__Aux_getValue") + .asFunction)>(); + + /// from: public boolean getValue() + bool getValue() => _getValue(reference) != 0; + + static final _setValue = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, + ffi.Uint8)>>("dev_dart_simple_package_Example__Aux_setValue") + .asFunction, int)>(); + + /// from: public void setValue(boolean value) + void setValue(bool value) => _setValue(reference, value ? 1 : 0); +} diff --git a/pkgs/jni_gen/test/simple_package_test/lib/init.dart b/pkgs/jni_gen/test/simple_package_test/lib/init.dart new file mode 100644 index 000000000..4b5537c60 --- /dev/null +++ b/pkgs/jni_gen/test/simple_package_test/lib/init.dart @@ -0,0 +1,5 @@ +import "dart:ffi"; +import "package:jni/jni.dart"; + +final Pointer Function(String sym) jlookup = + Jni.getInstance().initGeneratedLibrary("simple_package"); diff --git a/pkgs/jni_gen/test/simple_package_test/src/CMakeLists.txt b/pkgs/jni_gen/test/simple_package_test/src/CMakeLists.txt new file mode 100644 index 000000000..ef0660ba7 --- /dev/null +++ b/pkgs/jni_gen/test/simple_package_test/src/CMakeLists.txt @@ -0,0 +1,30 @@ +# The Flutter tooling requires that developers have CMake 3.10 or later +# installed. You should not increase this version, as doing so will cause +# the plugin to fail to compile for some customers of the plugin. +cmake_minimum_required(VERSION 3.10) + +project(simple_package VERSION 0.0.1 LANGUAGES C) + +add_library(simple_package SHARED + "simple_package.c" +) + +set_target_properties(simple_package PROPERTIES + OUTPUT_NAME "simple_package" +) + +target_compile_definitions(simple_package PUBLIC DART_SHARED_LIB) + +if(WIN32) + set_target_properties(${TARGET_NAME} PROPERTIES + LINK_FLAGS "/DELAYLOAD:jvm.dll") +endif() + +if (ANDROID) + target_link_libraries(simple_package log) +else() + find_package(Java REQUIRED) + find_package(JNI REQUIRED) + include_directories(${JNI_INCLUDE_DIRS}) + target_link_libraries(simple_package ${JNI_LIBRARIES}) +endif() diff --git a/pkgs/jni_gen/test/simple_package_test/src/dartjni.h b/pkgs/jni_gen/test/simple_package_test/src/dartjni.h new file mode 100644 index 000000000..407312bbe --- /dev/null +++ b/pkgs/jni_gen/test/simple_package_test/src/dartjni.h @@ -0,0 +1,173 @@ +#include +#include +#include +#include + +#if _WIN32 +#include +#else +#include +#include +#endif + +#if _WIN32 +#define FFI_PLUGIN_EXPORT __declspec(dllexport) +#else +#define FFI_PLUGIN_EXPORT +#endif + +#if defined _WIN32 +#define thread_local __declspec(thread) +#else +#define thread_local __thread +#endif + +#ifdef __ANDROID__ +#include +#endif + +#define JNI_LOG_TAG "Dart-JNI" + +#ifdef __ANDROID__ +#define __ENVP_CAST (JNIEnv **) +#else +#define __ENVP_CAST (void **) +#endif + +struct jni_context { + JavaVM *jvm; + jobject classLoader; + jmethodID loadClassMethod; + jobject currentActivity; + jobject appContext; +}; + +extern thread_local JNIEnv *jniEnv; + +extern struct jni_context jni; + +enum DartJniLogLevel { + JNI_VERBOSE = 2, + JNI_DEBUG, + JNI_INFO, + JNI_WARN, + JNI_ERROR +}; + +FFI_PLUGIN_EXPORT struct jni_context GetJniContext(); + +FFI_PLUGIN_EXPORT JavaVM *GetJavaVM(void); + +FFI_PLUGIN_EXPORT JNIEnv *GetJniEnv(void); + +FFI_PLUGIN_EXPORT JNIEnv *SpawnJvm(JavaVMInitArgs *args); + +FFI_PLUGIN_EXPORT jclass LoadClass(const char *name); + +FFI_PLUGIN_EXPORT jobject GetClassLoader(void); + +FFI_PLUGIN_EXPORT jobject GetApplicationContext(void); + +FFI_PLUGIN_EXPORT jobject GetCurrentActivity(void); + +FFI_PLUGIN_EXPORT void SetJNILogging(int level); + +FFI_PLUGIN_EXPORT jstring ToJavaString(char *str); + +FFI_PLUGIN_EXPORT const char *GetJavaStringChars(jstring jstr); + +FFI_PLUGIN_EXPORT void ReleaseJavaStringChars(jstring jstr, const char *buf); + +// These 2 are the function pointer variables defined and exported by +// the generated C files. +// +// initGeneratedLibrary function in Jni class will set these to +// corresponding functions to the implementations from `dartjni` base library +// which initializes and manages the JNI. +extern struct jni_context (*context_getter)(void); +extern JNIEnv *(*env_getter)(void); + +// This function will be exported by generated code library and will set the +// above 2 variables. +FFI_PLUGIN_EXPORT void setJniGetters(struct jni_context (*cg)(void), + JNIEnv *(*eg)(void)); + +// `static inline` because `inline` doesn't work, it may still not +// inline the function in which case a linker error may be produced. +// +// There has to be a better way to do this. Either to force inlining on target +// platforms, or just leave it as normal function. +static inline void __load_class_into(jclass *cls, const char *name) { +#ifdef __ANDROID__ + jstring className = (*jniEnv)->NewStringUTF(jniEnv, name); + *cls = (*jniEnv)->CallObjectMethod(jniEnv, jni.classLoader, + jni.loadClassMethod, className); + (*jniEnv)->DeleteLocalRef(jniEnv, className); +#else + *cls = (*jniEnv)->FindClass(jniEnv, name); +#endif +} + +static inline void load_class(jclass *cls, const char *name) { + if (*cls == NULL) { + __load_class_into(cls, name); + } +} + +static inline void load_class_gr(jclass *cls, const char *name) { + if (*cls == NULL) { + jclass tmp; + __load_class_into(&tmp, name); + *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); + (*jniEnv)->DeleteLocalRef(jniEnv, tmp); + } +} + +static inline void attach_thread() { + if (jniEnv == NULL) { + (*jni.jvm)->AttachCurrentThread(jni.jvm, __ENVP_CAST & jniEnv, + NULL); + } +} + +static inline void load_env() { + if (jniEnv == NULL) { + jni = context_getter(); + jniEnv = env_getter(); + } +} + +static inline void load_method(jclass cls, jmethodID *res, const char *name, + const char *sig) { + if (*res == NULL) { + *res = (*jniEnv)->GetMethodID(jniEnv, cls, name, sig); + } +} + +static inline void load_static_method(jclass cls, jmethodID *res, + const char *name, const char *sig) { + if (*res == NULL) { + *res = (*jniEnv)->GetStaticMethodID(jniEnv, cls, name, sig); + } +} + +static inline void load_field(jclass cls, jfieldID *res, const char *name, + const char *sig) { + if (*res == NULL) { + *res = (*jniEnv)->GetFieldID(jniEnv, cls, name, sig); + } +} + +static inline void load_static_field(jclass cls, jfieldID *res, + const char *name, const char *sig) { + if (*res == NULL) { + *res = (*jniEnv)->GetStaticFieldID(jniEnv, cls, name, sig); + } +} + +static inline jobject to_global_ref(jobject ref) { + jobject g = (*jniEnv)->NewGlobalRef(jniEnv, ref); + (*jniEnv)->DeleteLocalRef(jniEnv, ref); + return g; +} + diff --git a/pkgs/jni_gen/test/simple_package_test/src/simple_package.c b/pkgs/jni_gen/test/simple_package_test/src/simple_package.c new file mode 100644 index 000000000..4cc5e4296 --- /dev/null +++ b/pkgs/jni_gen/test/simple_package_test/src/simple_package.c @@ -0,0 +1,189 @@ +// Autogenerated by jni_gen. DO NOT EDIT! + +#include +#include "jni.h" +#include "dartjni.h" + +thread_local JNIEnv *jniEnv; +struct jni_context jni; + +struct jni_context (*context_getter)(void); +JNIEnv *(*env_getter)(void); + +void setJniGetters(struct jni_context (*cg)(void), + JNIEnv *(*eg)(void)) { + context_getter = cg; + env_getter = eg; +} + +// dev.dart.simple_package.Example +jclass _c_dev_dart_simple_package_Example = NULL; + +jmethodID _m_dev_dart_simple_package_Example_ctor = NULL; +FFI_PLUGIN_EXPORT +jobject dev_dart_simple_package_Example_ctor() { + load_env(); + load_class_gr(&_c_dev_dart_simple_package_Example, "dev/dart/simple_package/Example"); + load_method(_c_dev_dart_simple_package_Example, &_m_dev_dart_simple_package_Example_ctor, "", "()V"); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_dev_dart_simple_package_Example, _m_dev_dart_simple_package_Example_ctor); + return to_global_ref(_result); +} + +jmethodID _m_dev_dart_simple_package_Example_getAux = NULL; +FFI_PLUGIN_EXPORT +jobject dev_dart_simple_package_Example_getAux() { + load_env(); + load_class_gr(&_c_dev_dart_simple_package_Example, "dev/dart/simple_package/Example"); + load_static_method(_c_dev_dart_simple_package_Example, &_m_dev_dart_simple_package_Example_getAux, "getAux", "()Ldev/dart/simple_package/Example$Aux;"); + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_dev_dart_simple_package_Example, _m_dev_dart_simple_package_Example_getAux); + return to_global_ref(_result); +} + +jmethodID _m_dev_dart_simple_package_Example_addInts = NULL; +FFI_PLUGIN_EXPORT +int32_t dev_dart_simple_package_Example_addInts(int32_t a, int32_t b) { + load_env(); + load_class_gr(&_c_dev_dart_simple_package_Example, "dev/dart/simple_package/Example"); + load_static_method(_c_dev_dart_simple_package_Example, &_m_dev_dart_simple_package_Example_addInts, "addInts", "(II)I"); + int32_t _result = (*jniEnv)->CallStaticIntMethod(jniEnv, _c_dev_dart_simple_package_Example, _m_dev_dart_simple_package_Example_addInts, a, b); + return _result; +} + +jmethodID _m_dev_dart_simple_package_Example_getSelf = NULL; +FFI_PLUGIN_EXPORT +jobject dev_dart_simple_package_Example_getSelf(jobject self_) { + load_env(); + load_class_gr(&_c_dev_dart_simple_package_Example, "dev/dart/simple_package/Example"); + load_method(_c_dev_dart_simple_package_Example, &_m_dev_dart_simple_package_Example_getSelf, "getSelf", "()Ldev/dart/simple_package/Example;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_dev_dart_simple_package_Example_getSelf); + return to_global_ref(_result); +} + +jmethodID _m_dev_dart_simple_package_Example_getNum = NULL; +FFI_PLUGIN_EXPORT +int32_t dev_dart_simple_package_Example_getNum(jobject self_) { + load_env(); + load_class_gr(&_c_dev_dart_simple_package_Example, "dev/dart/simple_package/Example"); + load_method(_c_dev_dart_simple_package_Example, &_m_dev_dart_simple_package_Example_getNum, "getNum", "()I"); + int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_dev_dart_simple_package_Example_getNum); + return _result; +} + +jmethodID _m_dev_dart_simple_package_Example_setNum = NULL; +FFI_PLUGIN_EXPORT +void dev_dart_simple_package_Example_setNum(jobject self_, int32_t num) { + load_env(); + load_class_gr(&_c_dev_dart_simple_package_Example, "dev/dart/simple_package/Example"); + load_method(_c_dev_dart_simple_package_Example, &_m_dev_dart_simple_package_Example_setNum, "setNum", "(I)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_dev_dart_simple_package_Example_setNum, num); +} + +jfieldID _f_dev_dart_simple_package_Example_aux = NULL; +jobject get_dev_dart_simple_package_Example_aux() { + load_env(); + load_class_gr(&_c_dev_dart_simple_package_Example, "dev/dart/simple_package/Example"); + load_static_field(_c_dev_dart_simple_package_Example, &_f_dev_dart_simple_package_Example_aux, "aux","Ldev/dart/simple_package/Example$Aux;"); + return to_global_ref((*jniEnv)->GetStaticObjectField(jniEnv, _c_dev_dart_simple_package_Example, _f_dev_dart_simple_package_Example_aux)); +} + +void set_dev_dart_simple_package_Example_aux(jobject value) { + load_env(); + load_class_gr(&_c_dev_dart_simple_package_Example, "dev/dart/simple_package/Example"); + load_static_field(_c_dev_dart_simple_package_Example, &_f_dev_dart_simple_package_Example_aux, "aux","Ldev/dart/simple_package/Example$Aux;"); + ((*jniEnv)->SetStaticObjectField(jniEnv, _c_dev_dart_simple_package_Example, _f_dev_dart_simple_package_Example_aux, value)); +} + + +jfieldID _f_dev_dart_simple_package_Example_num = NULL; +int32_t get_dev_dart_simple_package_Example_num() { + load_env(); + load_class_gr(&_c_dev_dart_simple_package_Example, "dev/dart/simple_package/Example"); + load_static_field(_c_dev_dart_simple_package_Example, &_f_dev_dart_simple_package_Example_num, "num","I"); + return ((*jniEnv)->GetStaticIntField(jniEnv, _c_dev_dart_simple_package_Example, _f_dev_dart_simple_package_Example_num)); +} + +void set_dev_dart_simple_package_Example_num(int32_t value) { + load_env(); + load_class_gr(&_c_dev_dart_simple_package_Example, "dev/dart/simple_package/Example"); + load_static_field(_c_dev_dart_simple_package_Example, &_f_dev_dart_simple_package_Example_num, "num","I"); + ((*jniEnv)->SetStaticIntField(jniEnv, _c_dev_dart_simple_package_Example, _f_dev_dart_simple_package_Example_num, value)); +} + + +// dev.dart.simple_package.Example$Aux +jclass _c_dev_dart_simple_package_Example__Aux = NULL; + +jmethodID _m_dev_dart_simple_package_Example__Aux_ctor = NULL; +FFI_PLUGIN_EXPORT +jobject dev_dart_simple_package_Example__Aux_ctor(uint8_t value) { + load_env(); + load_class_gr(&_c_dev_dart_simple_package_Example__Aux, "dev/dart/simple_package/Example$Aux"); + load_method(_c_dev_dart_simple_package_Example__Aux, &_m_dev_dart_simple_package_Example__Aux_ctor, "", "(Z)V"); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_dev_dart_simple_package_Example__Aux, _m_dev_dart_simple_package_Example__Aux_ctor, value); + return to_global_ref(_result); +} + +jmethodID _m_dev_dart_simple_package_Example__Aux_getValue = NULL; +FFI_PLUGIN_EXPORT +uint8_t dev_dart_simple_package_Example__Aux_getValue(jobject self_) { + load_env(); + load_class_gr(&_c_dev_dart_simple_package_Example__Aux, "dev/dart/simple_package/Example$Aux"); + load_method(_c_dev_dart_simple_package_Example__Aux, &_m_dev_dart_simple_package_Example__Aux_getValue, "getValue", "()Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_dev_dart_simple_package_Example__Aux_getValue); + return _result; +} + +jmethodID _m_dev_dart_simple_package_Example__Aux_setValue = NULL; +FFI_PLUGIN_EXPORT +void dev_dart_simple_package_Example__Aux_setValue(jobject self_, uint8_t value) { + load_env(); + load_class_gr(&_c_dev_dart_simple_package_Example__Aux, "dev/dart/simple_package/Example$Aux"); + load_method(_c_dev_dart_simple_package_Example__Aux, &_m_dev_dart_simple_package_Example__Aux_setValue, "setValue", "(Z)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_dev_dart_simple_package_Example__Aux_setValue, value); +} + +jfieldID _f_dev_dart_simple_package_Example__Aux_value = NULL; +uint8_t get_dev_dart_simple_package_Example__Aux_value(jobject self_) { + load_env(); + load_class_gr(&_c_dev_dart_simple_package_Example__Aux, "dev/dart/simple_package/Example$Aux"); + load_field(_c_dev_dart_simple_package_Example__Aux, &_f_dev_dart_simple_package_Example__Aux_value, "value","Z"); + return ((*jniEnv)->GetBooleanField(jniEnv, self_, _f_dev_dart_simple_package_Example__Aux_value)); +} + +void set_dev_dart_simple_package_Example__Aux_value(jobject self_, uint8_t value) { + load_env(); + load_class_gr(&_c_dev_dart_simple_package_Example__Aux, "dev/dart/simple_package/Example$Aux"); + load_field(_c_dev_dart_simple_package_Example__Aux, &_f_dev_dart_simple_package_Example__Aux_value, "value","Z"); + ((*jniEnv)->SetBooleanField(jniEnv, self_, _f_dev_dart_simple_package_Example__Aux_value, value)); +} + + +// dev.dart.pkg2.C2 +jclass _c_dev_dart_pkg2_C2 = NULL; + +jmethodID _m_dev_dart_pkg2_C2_ctor = NULL; +FFI_PLUGIN_EXPORT +jobject dev_dart_pkg2_C2_ctor() { + load_env(); + load_class_gr(&_c_dev_dart_pkg2_C2, "dev/dart/pkg2/C2"); + load_method(_c_dev_dart_pkg2_C2, &_m_dev_dart_pkg2_C2_ctor, "", "()V"); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_dev_dart_pkg2_C2, _m_dev_dart_pkg2_C2_ctor); + return to_global_ref(_result); +} + +jfieldID _f_dev_dart_pkg2_C2_CONSTANT = NULL; +int32_t get_dev_dart_pkg2_C2_CONSTANT() { + load_env(); + load_class_gr(&_c_dev_dart_pkg2_C2, "dev/dart/pkg2/C2"); + load_static_field(_c_dev_dart_pkg2_C2, &_f_dev_dart_pkg2_C2_CONSTANT, "CONSTANT","I"); + return ((*jniEnv)->GetStaticIntField(jniEnv, _c_dev_dart_pkg2_C2, _f_dev_dart_pkg2_C2_CONSTANT)); +} + +void set_dev_dart_pkg2_C2_CONSTANT(int32_t value) { + load_env(); + load_class_gr(&_c_dev_dart_pkg2_C2, "dev/dart/pkg2/C2"); + load_static_field(_c_dev_dart_pkg2_C2, &_f_dev_dart_pkg2_C2_CONSTANT, "CONSTANT","I"); + ((*jniEnv)->SetStaticIntField(jniEnv, _c_dev_dart_pkg2_C2, _f_dev_dart_pkg2_C2_CONSTANT, value)); +} + + diff --git a/pkgs/jni_gen/test/test_util/test_util.dart b/pkgs/jni_gen/test/test_util/test_util.dart new file mode 100644 index 000000000..c0a168195 --- /dev/null +++ b/pkgs/jni_gen/test/test_util/test_util.dart @@ -0,0 +1,107 @@ +import 'dart:io'; + +import 'package:path/path.dart' hide equals; +import 'package:jni_gen/jni_gen.dart'; +import 'package:jni_gen/tools.dart'; +import 'package:test/test.dart'; + +const packageTestsDir = 'test'; + +Future isEmptyDir(String path) async { + final dir = Directory(path); + return (!await dir.exists()) || (await dir.list().length == 0); +} + +Future runCmd(String exec, List args, + {String? workingDirectory}) async { + stderr.writeln('[exec] $exec ${args.join(" ")}'); + final proc = await Process.start(exec, args, + workingDirectory: workingDirectory, + runInShell: true, + mode: ProcessStartMode.inheritStdio); + return proc.exitCode; +} + +Future buildNativeLibs(String testName) async { + final testRoot = join(packageTestsDir, testName); + await runCmd('dart', ['run', 'jni:setup']); + await runCmd('dart', ['run', 'jni:setup', '-S', join(testRoot, 'src')]); +} + +Future> getJarPaths(String testRoot) { + final jarPath = join(testRoot, 'jar'); + return Directory(jarPath) + .list() + .map((entry) => entry.path) + .where((path) => path.endsWith('jar')) + .toList(); +} + +/// Download dependencies using maven and generate bindings. +Future generateBindings({ + required String testName, + required List sourceDepNames, + required List jarDepNames, + required List classes, + required WrapperOptions options, + required bool isGeneratedFileTest, + bool useAsmBackend = false, + bool isThirdParty = false, + String? preamble, +}) async { + final testRoot = + join(packageTestsDir, testName, isThirdParty ? 'third_party' : ''); + final jarPath = join(testRoot, 'jar'); + final javaPath = join(testRoot, 'java'); + final src = join(testRoot, isGeneratedFileTest ? 'test_src' : 'src'); + final lib = join(testRoot, isGeneratedFileTest ? 'test_lib' : 'lib'); + + final sourceDeps = MvnTools.makeDependencyList(sourceDepNames); + final jarDeps = MvnTools.makeDependencyList(jarDepNames); + + await runCmd('dart', ['run', 'jni_gen:setup']); + + MvnTools.setVerbose(true); + if (await isEmptyDir(jarPath)) { + await Directory(jarPath).create(recursive: true); + await MvnTools.downloadMavenJars(jarDeps, jarPath); + } + if (await isEmptyDir(javaPath)) { + await Directory(javaPath).create(recursive: true); + await MvnTools.downloadMavenSources(sourceDeps, javaPath); + } + final jars = await getJarPaths(testRoot); + stderr.writeln('using classpath: $jars'); + await JniGenTask( + summarySource: SummarizerCommand( + sourcePaths: [Uri.directory(javaPath)], + classPaths: jars.map(Uri.file).toList(), + classes: classes, + extraArgs: useAsmBackend ? ['--backend', 'asm'] : [], + ), + options: options, + outputWriter: FilesWriter( + cWrapperDir: Uri.directory(src), + dartWrappersRoot: Uri.directory(lib), + preamble: preamble, + libraryName: testName)) + .run(); +} + +/// compares 2 hierarchies, with and without prefix 'test_' +void compareDirs(String path1, String path2) { + final list1 = Directory(path1).listSync(recursive: true); + final list2 = Directory(path2).listSync(recursive: true); + expect(list1.length, equals(list2.length)); + for (var list in [list1, list2]) { + list.sort((a, b) => a.path.compareTo(b.path)); + } + for (int i = 0; i < list1.length; i++) { + if (list1[i].statSync().type != FileSystemEntityType.file) { + continue; + } + final a = File(list1[i].path); + final b = File(list2[i].path); + expect(a.readAsStringSync(), equals(b.readAsStringSync())); + } +} diff --git a/pkgs/jnigen/README.md b/pkgs/jnigen/README.md index c27482615..a9be65606 100644 --- a/pkgs/jnigen/README.md +++ b/pkgs/jnigen/README.md @@ -2,7 +2,7 @@ ## jni_gen -This project intends to provide 2 packages to enable JNI interop from Dart & Flutter. +This project intends to provide 2 packages to enable JNI interop from Dart & Flutter. Currently this package is highly experimental. | Package | Description | | ------- | --------- | From 0f7ced710c6b2dfacd0b27c8b7305e5cb45d27d5 Mon Sep 17 00:00:00 2001 From: Mahesh Hegde <46179734+mahesh-hegde@users.noreply.github.com> Date: Mon, 29 Aug 2022 16:33:21 +0530 Subject: [PATCH 009/139] [jnigen] Add basic YAML config support (https://github.com/dart-lang/jnigen/issues/32) --- .../src/main/java/dev/dart/jni/JniPlugin.java | 4 + pkgs/jni/bin/setup.dart | 4 + pkgs/jni/example/lib/main.dart | 4 + pkgs/jni/example/test/widget_test.dart | 4 + pkgs/jni/lib/jni_object.dart | 4 + .../jni/lib/src/direct_methods_generated.dart | 4 + pkgs/jni/lib/src/extensions.dart | 4 + pkgs/jni/lib/src/jl_object.dart | 4 + pkgs/jni/lib/src/jni.dart | 4 + pkgs/jni/lib/src/jni_class.dart | 4 + .../lib/src/jni_class_methods_generated.dart | 4 + pkgs/jni/lib/src/jni_exceptions.dart | 4 + pkgs/jni/lib/src/jni_object.dart | 4 + .../lib/src/jni_object_methods_generated.dart | 4 + pkgs/jni/lib/src/jvalues.dart | 4 + pkgs/jni/src/dartjni.c | 4 + pkgs/jni/src/dartjni.h | 4 + pkgs/jni/test/exception_test.dart | 4 + pkgs/jni/test/jni_object_test.dart | 4 + pkgs/jni/test/jni_test.dart | 4 + pkgs/jni/tool/gen_aux_methods.dart | 11 +- pkgs/jni_gen/README.md | 24 ++ pkgs/jni_gen/bin/jni_gen.dart | 10 + pkgs/jni_gen/bin/setup.dart | 55 +--- pkgs/jni_gen/lib/jni_gen.dart | 3 +- pkgs/jni_gen/lib/src/bindings/c_bindings.dart | 6 +- .../lib/src/bindings/dart_bindings.dart | 9 +- .../lib/src/bindings/preprocessor.dart | 35 ++- .../lib/src/bindings/symbol_resolver.dart | 2 - pkgs/jni_gen/lib/src/config/config.dart | 289 +++++++++++++++++- .../{wrapper_options.dart => filters.dart} | 48 +-- pkgs/jni_gen/lib/src/config/task.dart | 59 ---- pkgs/jni_gen/lib/src/config/yaml_reader.dart | 141 +++++++++ pkgs/jni_gen/lib/src/generate_bindings.dart | 92 ++++++ .../summary.dart} | 44 +-- .../lib/src/tools/android_sdk_tools.dart | 45 +++ .../lib/src/tools/build_summarizer.dart | 60 ++++ .../{maven_utils.dart => maven_tools.dart} | 95 +++--- .../{config/errors.dart => tools/tools.dart} | 5 +- .../lib/src/writers/bindings_writer.dart | 11 - .../lib/src/writers/callback_writer.dart | 20 -- .../jni_gen/lib/src/writers/files_writer.dart | 132 -------- pkgs/jni_gen/lib/src/writers/writers.dart | 141 ++++++++- pkgs/jni_gen/lib/tools.dart | 2 +- pkgs/jni_gen/pubspec.yaml | 4 +- pkgs/jni_gen/test/config_test.dart | 74 +++++ .../test/jackson_core_test/generate.dart | 60 ++-- .../test/jackson_core_test/jnigen.yaml | 36 +++ .../lib/com/fasterxml/jackson/core.dart | 20 +- .../third_party/src/dartjni.h | 4 + .../test/simple_package_test/generate.dart | 21 +- .../lib/dev/dart/pkg2.dart | 13 +- .../lib/dev/dart/simple_package.dart | 24 +- .../test/simple_package_test/src/dartjni.h | 4 + pkgs/jni_gen/test/test_util/test_util.dart | 65 +--- pkgs/jni_gen/test/yaml_config_test.dart | 42 +++ 56 files changed, 1241 insertions(+), 545 deletions(-) create mode 100644 pkgs/jni_gen/bin/jni_gen.dart rename pkgs/jni_gen/lib/src/config/{wrapper_options.dart => filters.dart} (76%) delete mode 100644 pkgs/jni_gen/lib/src/config/task.dart create mode 100644 pkgs/jni_gen/lib/src/config/yaml_reader.dart create mode 100644 pkgs/jni_gen/lib/src/generate_bindings.dart rename pkgs/jni_gen/lib/src/{config/summary_source.dart => summary/summary.dart} (81%) create mode 100644 pkgs/jni_gen/lib/src/tools/android_sdk_tools.dart create mode 100644 pkgs/jni_gen/lib/src/tools/build_summarizer.dart rename pkgs/jni_gen/lib/src/tools/{maven_utils.dart => maven_tools.dart} (56%) rename pkgs/jni_gen/lib/src/{config/errors.dart => tools/tools.dart} (64%) delete mode 100644 pkgs/jni_gen/lib/src/writers/bindings_writer.dart delete mode 100644 pkgs/jni_gen/lib/src/writers/callback_writer.dart delete mode 100644 pkgs/jni_gen/lib/src/writers/files_writer.dart create mode 100644 pkgs/jni_gen/test/config_test.dart create mode 100644 pkgs/jni_gen/test/jackson_core_test/jnigen.yaml create mode 100644 pkgs/jni_gen/test/yaml_config_test.dart diff --git a/pkgs/jni/android/src/main/java/dev/dart/jni/JniPlugin.java b/pkgs/jni/android/src/main/java/dev/dart/jni/JniPlugin.java index 589ba8539..ffda30a03 100644 --- a/pkgs/jni/android/src/main/java/dev/dart/jni/JniPlugin.java +++ b/pkgs/jni/android/src/main/java/dev/dart/jni/JniPlugin.java @@ -1,3 +1,7 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + package dev.dart.jni; import android.app.Activity; diff --git a/pkgs/jni/bin/setup.dart b/pkgs/jni/bin/setup.dart index 67d9f9639..c4befc633 100644 --- a/pkgs/jni/bin/setup.dart +++ b/pkgs/jni/bin/setup.dart @@ -1,3 +1,7 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + import 'dart:io'; import 'package:args/args.dart'; diff --git a/pkgs/jni/example/lib/main.dart b/pkgs/jni/example/lib/main.dart index c21802b92..0303900ef 100644 --- a/pkgs/jni/example/lib/main.dart +++ b/pkgs/jni/example/lib/main.dart @@ -1,3 +1,7 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + // ignore_for_file: library_private_types_in_public_api import 'package:flutter/material.dart'; diff --git a/pkgs/jni/example/test/widget_test.dart b/pkgs/jni/example/test/widget_test.dart index 2607462f9..ec585ec4b 100644 --- a/pkgs/jni/example/test/widget_test.dart +++ b/pkgs/jni/example/test/widget_test.dart @@ -1,3 +1,7 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + import 'dart:io'; import 'package:flutter/material.dart'; diff --git a/pkgs/jni/lib/jni_object.dart b/pkgs/jni/lib/jni_object.dart index f12a8fd53..e0916f0d3 100644 --- a/pkgs/jni/lib/jni_object.dart +++ b/pkgs/jni/lib/jni_object.dart @@ -1,3 +1,7 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + /// jni_object library provides an easier interface to JNI's object references, /// providing various helper methods for one-off uses. /// diff --git a/pkgs/jni/lib/src/direct_methods_generated.dart b/pkgs/jni/lib/src/direct_methods_generated.dart index fc04c0f69..d1f01915e 100644 --- a/pkgs/jni/lib/src/direct_methods_generated.dart +++ b/pkgs/jni/lib/src/direct_methods_generated.dart @@ -1,3 +1,7 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + // Autogenerated; DO NOT EDIT // Generated by running the script in tool/gen_aux_methods.dart // coverage:ignore-file diff --git a/pkgs/jni/lib/src/extensions.dart b/pkgs/jni/lib/src/extensions.dart index d749e3e2e..995eb58b3 100644 --- a/pkgs/jni/lib/src/extensions.dart +++ b/pkgs/jni/lib/src/extensions.dart @@ -1,3 +1,7 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + import 'dart:ffi'; import 'package:ffi/ffi.dart'; diff --git a/pkgs/jni/lib/src/jl_object.dart b/pkgs/jni/lib/src/jl_object.dart index 36558f44f..2778dfc53 100644 --- a/pkgs/jni/lib/src/jl_object.dart +++ b/pkgs/jni/lib/src/jl_object.dart @@ -1,3 +1,7 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + import 'dart:ffi'; import 'package:ffi/ffi.dart'; diff --git a/pkgs/jni/lib/src/jni.dart b/pkgs/jni/lib/src/jni.dart index b3ce6df39..a188d8625 100644 --- a/pkgs/jni/lib/src/jni.dart +++ b/pkgs/jni/lib/src/jni.dart @@ -1,3 +1,7 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + import 'dart:ffi'; import 'dart:io'; diff --git a/pkgs/jni/lib/src/jni_class.dart b/pkgs/jni/lib/src/jni_class.dart index b4a676304..308981a1a 100644 --- a/pkgs/jni/lib/src/jni_class.dart +++ b/pkgs/jni/lib/src/jni_class.dart @@ -1,3 +1,7 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + import 'dart:ffi'; import 'package:ffi/ffi.dart'; diff --git a/pkgs/jni/lib/src/jni_class_methods_generated.dart b/pkgs/jni/lib/src/jni_class_methods_generated.dart index 3e3a7ca10..195deef29 100644 --- a/pkgs/jni/lib/src/jni_class_methods_generated.dart +++ b/pkgs/jni/lib/src/jni_class_methods_generated.dart @@ -1,3 +1,7 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + // Autogenerated; DO NOT EDIT // Generated by running the script in tool/gen_aux_methods.dart // coverage:ignore-file diff --git a/pkgs/jni/lib/src/jni_exceptions.dart b/pkgs/jni/lib/src/jni_exceptions.dart index c765ec4b1..a9cb63929 100644 --- a/pkgs/jni/lib/src/jni_exceptions.dart +++ b/pkgs/jni/lib/src/jni_exceptions.dart @@ -1,3 +1,7 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + import 'dart:ffi'; import 'third_party/jni_bindings_generated.dart'; diff --git a/pkgs/jni/lib/src/jni_object.dart b/pkgs/jni/lib/src/jni_object.dart index 217c8323c..47d480ab4 100644 --- a/pkgs/jni/lib/src/jni_object.dart +++ b/pkgs/jni/lib/src/jni_object.dart @@ -1,3 +1,7 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + import 'dart:ffi'; import 'package:ffi/ffi.dart'; diff --git a/pkgs/jni/lib/src/jni_object_methods_generated.dart b/pkgs/jni/lib/src/jni_object_methods_generated.dart index 490f8fc74..3c417077c 100644 --- a/pkgs/jni/lib/src/jni_object_methods_generated.dart +++ b/pkgs/jni/lib/src/jni_object_methods_generated.dart @@ -1,3 +1,7 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + // Autogenerated; DO NOT EDIT // Generated by running the script in tool/gen_aux_methods.dart // coverage:ignore-file diff --git a/pkgs/jni/lib/src/jvalues.dart b/pkgs/jni/lib/src/jvalues.dart index 63945b01c..94a9cbe4d 100644 --- a/pkgs/jni/lib/src/jvalues.dart +++ b/pkgs/jni/lib/src/jvalues.dart @@ -1,3 +1,7 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + import 'dart:ffi'; import 'package:ffi/ffi.dart'; diff --git a/pkgs/jni/src/dartjni.c b/pkgs/jni/src/dartjni.c index 82f159758..8ba5a8913 100644 --- a/pkgs/jni/src/dartjni.c +++ b/pkgs/jni/src/dartjni.c @@ -1,3 +1,7 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + #include #include diff --git a/pkgs/jni/src/dartjni.h b/pkgs/jni/src/dartjni.h index 407312bbe..cd94b1532 100644 --- a/pkgs/jni/src/dartjni.h +++ b/pkgs/jni/src/dartjni.h @@ -1,3 +1,7 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + #include #include #include diff --git a/pkgs/jni/test/exception_test.dart b/pkgs/jni/test/exception_test.dart index 109a7e6fb..0e86ec962 100644 --- a/pkgs/jni/test/exception_test.dart +++ b/pkgs/jni/test/exception_test.dart @@ -1,3 +1,7 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + import 'dart:io'; import 'package:test/test.dart'; diff --git a/pkgs/jni/test/jni_object_test.dart b/pkgs/jni/test/jni_object_test.dart index 6124d1fd7..d2341016a 100644 --- a/pkgs/jni/test/jni_object_test.dart +++ b/pkgs/jni/test/jni_object_test.dart @@ -1,3 +1,7 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + import 'dart:io'; import 'dart:ffi'; import 'dart:isolate'; diff --git a/pkgs/jni/test/jni_test.dart b/pkgs/jni/test/jni_test.dart index 29f536b64..ce31fc471 100644 --- a/pkgs/jni/test/jni_test.dart +++ b/pkgs/jni/test/jni_test.dart @@ -1,3 +1,7 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + import 'dart:io'; import 'dart:ffi'; diff --git a/pkgs/jni/tool/gen_aux_methods.dart b/pkgs/jni/tool/gen_aux_methods.dart index 0c7ae586e..a30f54db3 100644 --- a/pkgs/jni/tool/gen_aux_methods.dart +++ b/pkgs/jni/tool/gen_aux_methods.dart @@ -1,8 +1,16 @@ -/// Run from templates directory +// 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 +// BSD-style license that can be found in the LICENSE file. import 'dart:io' as io; import 'package:path/path.dart'; +const _license = ''' +// 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 +// BSD-style license that can be found in the LICENSE file. + +'''; final targetTypes = { "String": "String", "Object": "JniObject", @@ -53,6 +61,7 @@ void main(List args) { sInvoke: join(outputDir, "direct_methods_generated.dart") }; for (final s in [sInst, sStatic, sInvoke]) { + s.write(_license); s.write("// Autogenerated; DO NOT EDIT\n" "// Generated by running the script in tool/gen_aux_methods.dart\n"); s.write("// coverage:ignore-file\n"); diff --git a/pkgs/jni_gen/README.md b/pkgs/jni_gen/README.md index 373127b27..1ae735d3e 100644 --- a/pkgs/jni_gen/README.md +++ b/pkgs/jni_gen/README.md @@ -5,3 +5,27 @@ This enables calling Java code from Dart. This is a GSoC 2022 project. +Currently this package is highly experimental and proof-of-concept. See `test/jackson_core_test` for an example of generating bindings for a library. It is possible to specify some dependencies to be downloaded automatically through `maven`. + +## Basics +### Running `jni_gen` +There are 2 ways to use `jni_gen`: + +* Import `package:jni_gen/jni_gen.dart` from a script in `tool/` directory of your project. +* Run as command line tool with a YAML config. + +Both approaches are almost identical. If using YAML, it's possible to selectively override configuration properties with command line, using `-Dproperty.name=value` syntax. + +### Generated bindings +Generated bindings will consist of 2 parts - C bindings which call JNI, and Dart bindings which call C bindings. The generated bindings will depend on `package:jni` for instantiating / obtaining a JVM instance. + +The following properties must be specified in yaml. + +* `c_root`: root folder to write generated C bindings. +* `dart_root`: root folder to write generated Dart bindings (see below). +* `library_name`: specifies name of the generated library in CMakeFiles.txt. + +The generated C file has to be linked to JNI libraries. Therefore a CMake configuration is always generated which builds the generated code as shared library. The `init.dart` in generated dart code loads the library on first time a method is accessed. On dart standalone, it will be loaded from the same directory specified in `Jni.spawn` call. + +## Examples +See [jackson_core_test](test/jackson_core_test) folder for an example how bindings are generated. Runnable examples will be added soon. diff --git a/pkgs/jni_gen/bin/jni_gen.dart b/pkgs/jni_gen/bin/jni_gen.dart new file mode 100644 index 000000000..855ae6e68 --- /dev/null +++ b/pkgs/jni_gen/bin/jni_gen.dart @@ -0,0 +1,10 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +import 'package:jni_gen/jni_gen.dart'; + +void main(List args) async { + final config = Config.parseArgs(args); + await generateJniBindings(config); +} diff --git a/pkgs/jni_gen/bin/setup.dart b/pkgs/jni_gen/bin/setup.dart index 656b5daf8..18e7a8d02 100644 --- a/pkgs/jni_gen/bin/setup.dart +++ b/pkgs/jni_gen/bin/setup.dart @@ -2,67 +2,20 @@ // 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 script gets the java sources using the copy of this package, and builds -// ApiSummarizer jar using Maven. import 'dart:io'; -import 'package:path/path.dart'; - -import 'package:jni_gen/src/util/find_package.dart'; - -final toolPath = join('.', '.dart_tool', 'jni_gen'); -final mvnTargetDir = join(toolPath, 'target'); -final jarFile = join(toolPath, 'ApiSummarizer.jar'); -final targetJarFile = join(mvnTargetDir, 'ApiSummarizer.jar'); - -Future buildApiSummarizer() async { - final pkg = await findPackageRoot('jni_gen'); - if (pkg == null) { - stderr.writeln('package jni_gen not found!'); - exitCode = 2; - return; - } - final pom = pkg.resolve('java/pom.xml'); - await Directory(toolPath).create(recursive: true); - final mvnProc = await Process.start( - 'mvn', - [ - '--batch-mode', - '--update-snapshots', - '-f', - pom.toFilePath(), - 'assembly:assembly' - ], - workingDirectory: toolPath, - mode: ProcessStartMode.inheritStdio); - await mvnProc.exitCode; - // move ApiSummarizer.jar from target to current directory - File(targetJarFile).renameSync(jarFile); - Directory(mvnTargetDir).deleteSync(recursive: true); -} +import 'package:jni_gen/src/tools/tools.dart'; void main(List args) async { bool force = false; if (args.isNotEmpty) { if (args.length != 1 || args[0] != '-f') { stderr.writeln('usage: dart run jni_gen:setup [-f]'); - stderr.writeln('use -f option to rebuild ApiSummarizer jar ' - 'even if it already exists.'); + stderr.writeln('* -f\trebuild ApiSummarizer jar even if it already ' + 'exists.'); } else { force = true; } } - final jarExists = await File(jarFile).exists(); - final isJarStale = jarExists && - await isPackageModifiedAfter( - 'jni_gen', await File(jarFile).lastModified(), 'java/'); - if (isJarStale) { - stderr.writeln('Rebuilding ApiSummarizer component since sources ' - 'have changed. This might take some time.'); - } - if (!jarExists || isJarStale || force) { - await buildApiSummarizer(); - } else { - stderr.writeln('ApiSummarizer.jar exists. Skipping build..'); - } + buildSummarizerIfNotExists(force: force); } diff --git a/pkgs/jni_gen/lib/jni_gen.dart b/pkgs/jni_gen/lib/jni_gen.dart index 0bc7895cb..33068f404 100644 --- a/pkgs/jni_gen/lib/jni_gen.dart +++ b/pkgs/jni_gen/lib/jni_gen.dart @@ -9,4 +9,5 @@ library jni_gen; export 'src/elements/elements.dart'; export 'src/config/config.dart'; -export 'src/writers/writers.dart'; +export 'src/config/filters.dart'; +export 'src/generate_bindings.dart'; diff --git a/pkgs/jni_gen/lib/src/bindings/c_bindings.dart b/pkgs/jni_gen/lib/src/bindings/c_bindings.dart index 71be9c113..f6b7ddf6d 100644 --- a/pkgs/jni_gen/lib/src/bindings/c_bindings.dart +++ b/pkgs/jni_gen/lib/src/bindings/c_bindings.dart @@ -3,7 +3,7 @@ // BSD-style license that can be found in the LICENSE file. import 'package:jni_gen/src/elements/elements.dart'; -import 'package:jni_gen/src/config/wrapper_options.dart'; +import 'package:jni_gen/src/config/config.dart'; import 'common.dart'; @@ -28,8 +28,8 @@ class CBindingGenerator { String _cParamRename(String paramName) => _cTypeKeywords.contains(paramName) ? '${paramName}0' : paramName; - CBindingGenerator(this.options); - WrapperOptions options; + CBindingGenerator(this.config); + Config config; String generateBinding(ClassDecl c) { return _class(c); diff --git a/pkgs/jni_gen/lib/src/bindings/dart_bindings.dart b/pkgs/jni_gen/lib/src/bindings/dart_bindings.dart index b9944418d..7a27303a9 100644 --- a/pkgs/jni_gen/lib/src/bindings/dart_bindings.dart +++ b/pkgs/jni_gen/lib/src/bindings/dart_bindings.dart @@ -5,7 +5,7 @@ import 'dart:io'; import 'package:jni_gen/src/elements/elements.dart'; -import 'package:jni_gen/src/config/wrapper_options.dart'; +import 'package:jni_gen/src/config/config.dart'; import 'package:jni_gen/src/util/rename_conflict.dart'; import 'symbol_resolver.dart'; @@ -29,8 +29,8 @@ class DartBindingsGenerator { static const String _jlObject = '${jni}JlObject'; - DartBindingsGenerator(this.options, this.resolver); - WrapperOptions options; + DartBindingsGenerator(this.config, this.resolver); + Config config; SymbolResolver resolver; String generateBinding(ClassDecl decl) { @@ -176,7 +176,7 @@ class DartBindingsGenerator { void writeAccessor({bool isSetter = false}) { final symPrefix = isSetter ? 'set' : 'get'; - final sym = '_$symPrefix$name'; + final sym = '_${symPrefix}_$name'; final ffiSig = dartSigForField(f, isSetter: isSetter, isFfiSig: true); final dartSig = dartSigForField(f, isSetter: isSetter, isFfiSig: false); s.write('${_indent}static final $sym = $_jlookup' @@ -300,6 +300,7 @@ class DartBindingsGenerator { String _literal(dynamic value) { if (value is String) { + // TODO(#31): escape string literal. return '"$value"'; } if (value is int || value is double || value is bool) { diff --git a/pkgs/jni_gen/lib/src/bindings/preprocessor.dart b/pkgs/jni_gen/lib/src/bindings/preprocessor.dart index 6fd1ee3d9..21771236b 100644 --- a/pkgs/jni_gen/lib/src/bindings/preprocessor.dart +++ b/pkgs/jni_gen/lib/src/bindings/preprocessor.dart @@ -5,25 +5,22 @@ import 'dart:io'; import 'package:jni_gen/src/elements/elements.dart'; -import 'package:jni_gen/src/config/wrapper_options.dart'; +import 'package:jni_gen/src/config/config.dart'; import 'package:jni_gen/src/util/rename_conflict.dart'; import 'common.dart'; /// Preprocessor which fills information needed by both Dart and C generators. class ApiPreprocessor { - ApiPreprocessor(this.classes, this.options); - final Map classes; - final WrapperOptions options; - - void preprocessAll() { + static void preprocessAll(Map classes, Config config) { for (var c in classes.values) { - _preprocess(c); + _preprocess(c, classes, config); } } - void _preprocess(ClassDecl decl) { + static void _preprocess( + ClassDecl decl, Map classes, Config config) { if (decl.isPreprocessed) return; - if (!_isClassIncluded(decl)) { + if (!_isClassIncluded(decl, config)) { decl.isIncluded = false; stdout.writeln('exclude class ${decl.binaryName}'); decl.isPreprocessed = true; @@ -32,7 +29,7 @@ class ApiPreprocessor { ClassDecl? superclass; if (decl.superclass != null && classes.containsKey(decl.superclass?.name)) { superclass = classes[decl.superclass!.name]!; - _preprocess(superclass); + _preprocess(superclass, classes, config); // again, un-consider superclass if it was excluded through config if (!superclass.isIncluded) { superclass = null; @@ -42,7 +39,7 @@ class ApiPreprocessor { } for (var field in decl.fields) { - if (!_isFieldIncluded(decl, field)) { + if (!_isFieldIncluded(decl, field, config)) { field.isIncluded = false; stderr.writeln('exclude ${decl.binaryName}#${field.name}'); continue; @@ -51,7 +48,7 @@ class ApiPreprocessor { } for (var method in decl.methods) { - if (!_isMethodIncluded(decl, method)) { + if (!_isMethodIncluded(decl, method, config)) { method.isIncluded = false; stderr.writeln('exclude method ${decl.binaryName}#${method.name}'); continue; @@ -81,10 +78,12 @@ class ApiPreprocessor { decl.isPreprocessed = true; } - bool _isFieldIncluded(ClassDecl decl, Field field) => - options.fieldFilter?.included(decl, field) != false; - bool _isMethodIncluded(ClassDecl decl, Method method) => - options.methodFilter?.included(decl, method) != false; - bool _isClassIncluded(ClassDecl decl) => - options.classFilter?.included(decl) != false; + static bool _isFieldIncluded(ClassDecl decl, Field field, Config config) => + !field.name.startsWith('_') && + config.exclude?.fields?.included(decl, field) != false; + static bool _isMethodIncluded(ClassDecl decl, Method method, Config config) => + !method.name.startsWith('_') && + config.exclude?.methods?.included(decl, method) != false; + static bool _isClassIncluded(ClassDecl decl, Config config) => + config.exclude?.classes?.included(decl) != false; } diff --git a/pkgs/jni_gen/lib/src/bindings/symbol_resolver.dart b/pkgs/jni_gen/lib/src/bindings/symbol_resolver.dart index bfaaab4e3..43b928f14 100644 --- a/pkgs/jni_gen/lib/src/bindings/symbol_resolver.dart +++ b/pkgs/jni_gen/lib/src/bindings/symbol_resolver.dart @@ -14,8 +14,6 @@ abstract class SymbolResolver { List getImportStrings(); } -// TODO(#24): resolve all included classes without requiring import mappings. - class PackagePathResolver implements SymbolResolver { PackagePathResolver(this.packages, this.currentPackage, this.inputClassNames, {this.predefined = const {}}); diff --git a/pkgs/jni_gen/lib/src/config/config.dart b/pkgs/jni_gen/lib/src/config/config.dart index 03ce6f2b5..a0272f31a 100644 --- a/pkgs/jni_gen/lib/src/config/config.dart +++ b/pkgs/jni_gen/lib/src/config/config.dart @@ -2,7 +2,288 @@ // 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 'summary_source.dart'; -export 'task.dart'; -export 'wrapper_options.dart'; -export 'errors.dart'; +import 'dart:io'; + +import 'package:jni_gen/src/elements/elements.dart'; + +import 'yaml_reader.dart'; +import 'filters.dart'; + +/// Configuration for dependencies to be downloaded using maven. +/// +/// Dependency names should be listed in groupId:artifactId:version format. +/// For [sourceDeps], sources will be unpacked to [sourceDir] root and JAR files +/// will also be downloaded. For the packages in jarOnlyDeps, only JAR files +/// will be downloaded. +/// +/// When passed as a parameter to [Config], the downloaded sources and +/// JAR files will be automatically added to source path and class path +/// respectively. +class MavenDownloads { + static const defaultMavenSourceDir = 'mvn_java'; + static const defaultMavenJarDir = 'mvn_jar'; + + MavenDownloads({ + this.sourceDeps = const [], + // ASK: Should this be changed to a gitignore'd directory like build ? + this.sourceDir = defaultMavenSourceDir, + this.jarOnlyDeps = const [], + this.jarDir = defaultMavenJarDir, + }); + List sourceDeps; + String sourceDir; + List jarOnlyDeps; + String jarDir; +} + +/// Configuration for Android SDK sources and stub JAR files. +/// +/// The SDK directories for platform stub JARs and sources are searched in the +/// same order in which [versions] are specified. +/// +/// If [sdkRoot] is not provided, an attempt is made to discover it +/// using the environment variable `ANDROID_SDK_ROOT`, which will fail if the +/// environment variable is not set. +/// +/// If [includeSources] is true, `jni_gen` searches for Android SDK sources +/// as well in the SDK directory and adds them to the source path. +class AndroidSdkConfig { + AndroidSdkConfig( + {required this.versions, this.sdkRoot, this.includeSources = false}); + List versions; + String? sdkRoot; + bool includeSources; +} + +/// Additional options to pass to the summary generator component. +class SummarizerOptions { + SummarizerOptions( + {this.extraArgs = const [], this.workingDirectory, this.backend}); + List extraArgs; + Uri? workingDirectory; + String? backend; +} + +/// Backend for reading summary of Java libraries +enum SummarizerBackend { + /// Generate Java API summaries using JARs in provided `classPath`s. + asm, + + /// Generate Java API summaries using source files in provided `sourcePath`s. + doclet, +} + +class BindingExclusions { + BindingExclusions({this.methods, this.fields, this.classes}); + MethodFilter? methods; + FieldFilter? fields; + ClassFilter? classes; +} + +/// Configuration for jni_gen binding generation. +class Config { + Config({ + required this.classes, + required this.libraryName, + required this.cRoot, + required this.dartRoot, + this.exclude, + this.sourcePath, + this.classPath, + this.preamble, + this.importMap, + this.androidSdkConfig, + this.mavenDownloads, + this.summarizerOptions, + this.dumpJsonTo, + }); + + /// List of classes or packages for which bindings have to be generated. + /// + /// The names must be fully qualified, and it's assumed that the directory + /// structure corresponds to package naming. For example, com.abc.MyClass + /// should be resolvable as `com/abc/MyClass.java` from one of the provided + /// source paths. Same applies if ASM backend is used, except that the file + /// name suffix is `.class`. + List classes; + + /// Name of generated library in CMakeLists.txt configuration. + /// + /// This will also determine the name of shared object file. + String libraryName; + + /// Directory to write JNI C Bindings. + Uri cRoot; + + /// Directory to write Dart bindings. + Uri dartRoot; + + /// Methods and fields to be excluded from generated bindings. + BindingExclusions? exclude; + + /// Paths to search for java source files. + /// + /// If a source package is downloaded through [mavenDownloads] option, + /// the corresponding source folder is automatically added and does not + /// need to be explicitly specified. + List? sourcePath; + + /// class path for scanning java libraries. If [backend] is `asm`, the + /// specified classpath is used to search for [classes], otherwise it's + /// merely used by the doclet API to find transitively referenced classes, + /// but not the specified classes / packages themselves. + List? classPath; + + /// Common text to be pasted on top of generated C and Dart files. + String? preamble; + + /// Additional java package -> dart package mappings (Experimental). + Map? importMap; + + /// Configuration to search for Android SDK libraries (Experimental). + AndroidSdkConfig? androidSdkConfig; + + /// Configuration for auto-downloading JAR / source packages using maven, + /// along with their transitive dependencies. + MavenDownloads? mavenDownloads; + + /// Additional options for the summarizer component + SummarizerOptions? summarizerOptions; + + String? dumpJsonTo; + + static Uri? _toDirUri(String? path) => + path != null ? Uri.directory(path) : null; + static List? _toUris(List? paths) => + paths?.map(Uri.file).toList(); + + static Config parseArgs(List args) { + final prov = YamlReader.parseArgs(args); + + final List missingValues = []; + T must(T? Function(String) f, T ifNull, String property) { + final res = f(property); + if (res == null) { + missingValues.add(property); + return ifNull; + } + return res; + } + + MemberFilter? regexFilter(String property) { + final exclusions = prov.getStringList(property); + if (exclusions == null) return null; + final List> filters = []; + for (var exclusion in exclusions) { + final split = exclusion.split('#'); + if (split.length != 2) { + throw FormatException('Error parsing exclusion: "$exclusion"; ' + 'expected to be in binaryName#member format.'); + } + filters.add(MemberNameFilter.exclude( + RegExp(split[0]), + RegExp(split[1]), + )); + } + return CombinedMemberFilter(filters); + } + + String getSdkRoot() { + final root = prov.getString(_Props.androidSdkRoot) ?? + Platform.environment['ANDROID_SDK_ROOT']; + if (root == null) { + missingValues.add(_Props.androidSdkRoot); + return '?'; + } + return root; + } + + final config = Config( + sourcePath: _toUris(prov.getStringList(_Props.sourcePath)), + classPath: _toUris(prov.getStringList(_Props.classPath)), + classes: must(prov.getStringList, [], _Props.classes), + summarizerOptions: SummarizerOptions( + extraArgs: prov.getStringList(_Props.summarizerArgs) ?? const [], + backend: prov.getString(_Props.backend), + workingDirectory: + _toDirUri(prov.getString(_Props.summarizerWorkingDir)), + ), + exclude: BindingExclusions( + methods: regexFilter(_Props.excludeMethods), + fields: regexFilter(_Props.excludeFields), + ), + cRoot: Uri.directory(must(prov.getString, '', _Props.cRoot)), + dartRoot: Uri.directory(must(prov.getString, '', _Props.dartRoot)), + preamble: prov.getString(_Props.preamble), + libraryName: must(prov.getString, '', _Props.libraryName), + importMap: prov.getStringMap(_Props.importMap), + mavenDownloads: prov.hasValue(_Props.mavenDownloads) + ? MavenDownloads( + sourceDeps: prov.getStringList(_Props.sourceDeps) ?? const [], + sourceDir: prov.getString(_Props.mavenSourceDir) ?? + MavenDownloads.defaultMavenSourceDir, + jarOnlyDeps: prov.getStringList(_Props.jarOnlyDeps) ?? const [], + jarDir: prov.getString(_Props.mavenJarDir) ?? + MavenDownloads.defaultMavenJarDir, + ) + : null, + androidSdkConfig: prov.hasValue(_Props.androidSdkConfig) + ? AndroidSdkConfig( + versions: must>( + prov.getStringList, [], _Props.androidSdkVersions) + .map(int.parse) + .toList(), + sdkRoot: getSdkRoot(), + includeSources: + prov.getBool(_Props.includeAndroidSources) ?? false, + ) + : null, + ); + if (missingValues.isNotEmpty) { + stderr.write('Following config values are required but not provided\n' + 'Please provide these properties through YAML ' + 'or use the command line switch -D=.\n'); + for (var missing in missingValues) { + stderr.writeln('* $missing'); + } + if (missingValues.contains(_Props.androidSdkRoot)) { + stderr.writeln('Please specify ${_Props.androidSdkRoot} through ' + 'command line or ensure that the ANDROID_SDK_ROOT environment ' + 'variable is set.'); + } + exit(1); + } + return config; + } +} + +class _Props { + static const summarizer = 'summarizer'; + static const summarizerArgs = '$summarizer.extra_args'; + static const summarizerWorkingDir = '$summarizer.working_dir'; + static const backend = '$summarizer.backend'; + + static const sourcePath = 'source_path'; + static const classPath = 'class_path'; + static const classes = 'classes'; + static const exclude = 'exclude'; + static const excludeMethods = '$exclude.methods'; + static const excludeFields = '$exclude.fields'; + + static const importMap = 'import_map'; + static const cRoot = 'c_root'; + static const dartRoot = 'dart_root'; + static const preamble = 'preamble'; + static const libraryName = 'library_name'; + + static const mavenDownloads = 'maven_downloads'; + static const sourceDeps = '$mavenDownloads.source_deps'; + static const mavenSourceDir = '$mavenDownloads.source_dir'; + static const jarOnlyDeps = '$mavenDownloads.jar_only_deps'; + static const mavenJarDir = '$mavenDownloads.jar_dir'; + + static const androidSdkConfig = 'android_sdk_config'; + static const androidSdkRoot = '$androidSdkConfig.sdk_root'; + static const androidSdkVersions = '$androidSdkConfig.versions'; + static const includeAndroidSources = '$androidSdkConfig.include_sources'; +} diff --git a/pkgs/jni_gen/lib/src/config/wrapper_options.dart b/pkgs/jni_gen/lib/src/config/filters.dart similarity index 76% rename from pkgs/jni_gen/lib/src/config/wrapper_options.dart rename to pkgs/jni_gen/lib/src/config/filters.dart index 7f1101da8..66f161297 100644 --- a/pkgs/jni_gen/lib/src/config/wrapper_options.dart +++ b/pkgs/jni_gen/lib/src/config/filters.dart @@ -4,6 +4,11 @@ import 'package:jni_gen/src/elements/elements.dart'; +bool _matchesCompletely(String string, Pattern pattern) { + final match = pattern.matchAsPrefix(string); + return match != null && match.group(0) == string; +} + /// A filter which tells if bindings for given [ClassDecl] are generated. abstract class ClassFilter { bool included(ClassDecl decl); @@ -19,11 +24,6 @@ class CustomClassFilter implements ClassFilter { } } -bool _matchesCompletely(String string, Pattern pattern) { - final match = pattern.matchAsPrefix(string); - return match != null && match.group(0) == string; -} - /// Filter to include / exclude classes by matching on the binary name. /// A binary name is like qualified name but with a `$` used to indicate nested /// class instead of `.`, guaranteeing a unique name. @@ -45,6 +45,7 @@ abstract class MemberFilter { bool included(ClassDecl classDecl, T member); } +/// Filter that excludes or includes members based on class and member name. class MemberNameFilter implements MemberFilter { MemberNameFilter.include(this.classPattern, this.namePattern) : onMatch = true; @@ -60,6 +61,7 @@ class MemberNameFilter implements MemberFilter { } } +/// Filter that includes or excludes a member based on a custom callback. class CustomMemberFilter implements MemberFilter { CustomMemberFilter(this.predicate); bool Function(ClassDecl, T) predicate; @@ -67,6 +69,7 @@ class CustomMemberFilter implements MemberFilter { bool included(ClassDecl classDecl, T member) => predicate(classDecl, member); } +/// Filter which excludes classes excluded by any one filter in [filters]. class CombinedClassFilter implements ClassFilter { CombinedClassFilter.all(this.filters); final List filters; @@ -74,6 +77,7 @@ class CombinedClassFilter implements ClassFilter { bool included(ClassDecl decl) => filters.every((f) => f.included(decl)); } +/// Filter which excludes members excluded by any one filter in [filters]. class CombinedMemberFilter implements MemberFilter { CombinedMemberFilter(this.filters); @@ -112,37 +116,3 @@ MemberFilter excludeAll(List> names) { return CombinedMemberFilter( names.map((p) => MemberNameFilter.exclude(p[0], p[1])).toList()); } - -/// Options that affect the semantics of the generated code. -class WrapperOptions { - const WrapperOptions({ - this.classFilter, - this.fieldFilter, - this.methodFilter, - this.classTransformer, - this.methodTransformer, - this.fieldTransformer, - this.importPaths = const {}, - }); - - /// Mapping from java package names to dart packages. - /// A mapping `a.b` -> `package:a_b/' means that - /// any import `a.b.C` will be resolved as `package:a_b/a/b.dart` in dart. - /// Note that dart bindings use the same hierarchy as the java packages. - final Map importPaths; - - /// [ClassFilter] to decide if bindings for a class should be generated. - final ClassFilter? classFilter; - - /// [FieldFilter] to decide if bindings for a field should be generated. - final FieldFilter? fieldFilter; - - /// [MethodFilter] to decide if bindings for a method should be generated. - final MethodFilter? methodFilter; - - // TODO(#26): This allows us to implement flexible renaming and more customization - // via the dart API. - final ClassDecl? Function(ClassDecl decl)? classTransformer; - final Method? Function(Method method)? methodTransformer; - final Field? Function(Field field)? fieldTransformer; -} diff --git a/pkgs/jni_gen/lib/src/config/task.dart b/pkgs/jni_gen/lib/src/config/task.dart deleted file mode 100644 index a5e015ddf..000000000 --- a/pkgs/jni_gen/lib/src/config/task.dart +++ /dev/null @@ -1,59 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -import 'dart:io'; -import 'dart:convert'; - -import 'package:jni_gen/src/writers/bindings_writer.dart'; -import 'package:jni_gen/src/config/config.dart'; -import 'package:jni_gen/src/elements/elements.dart'; - -/// Represents a complete jni_gen binding generation configuration. -/// * [summarySource] handles the API summary generation. -/// * [options] specify any semantic options regarding generated code. -/// * [outputWriter] handles the output configuration. -class JniGenTask { - JniGenTask({ - required this.summarySource, - this.options = const WrapperOptions(), - required this.outputWriter, - }); - BindingsWriter outputWriter; - SummarySource summarySource; - WrapperOptions options; - - // execute this task - Future run({bool dumpJson = false}) async { - Stream> input; - try { - input = await summarySource.getInputStream(); - } on Exception catch (e) { - stderr.writeln('error obtaining API summary: $e'); - return; - } - final stream = JsonDecoder().bind(Utf8Decoder().bind(input)); - dynamic json; - try { - json = await stream.single; - } on Exception catch (e) { - stderr.writeln('error while parsing summary: $e'); - return; - } - if (json == null) { - stderr.writeln('error: expected JSON element from summarizer.'); - return; - } - if (dumpJson) { - stderr.writeln(json); - } - final list = json as List; - try { - await outputWriter.writeBindings( - list.map((c) => ClassDecl.fromJson(c)), options); - } on Exception catch (e, trace) { - stderr.writeln(trace); - stderr.writeln('error writing bindings: $e'); - } - } -} diff --git a/pkgs/jni_gen/lib/src/config/yaml_reader.dart b/pkgs/jni_gen/lib/src/config/yaml_reader.dart new file mode 100644 index 000000000..3d12dae32 --- /dev/null +++ b/pkgs/jni_gen/lib/src/config/yaml_reader.dart @@ -0,0 +1,141 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +import 'dart:io'; + +import 'package:args/args.dart'; +import 'package:yaml/yaml.dart'; + +class ConfigError extends Error { + ConfigError(this.message); + final String message; + @override + String toString() => message; +} + +/// YAML Reader which enables to override specific values from command line. +class YamlReader { + YamlReader.of(this.cli, this.yaml); + YamlReader.fromYaml(this.yaml) : cli = const {}; + YamlReader.fromMap(this.cli) : yaml = const {}; + Map cli; + Map yaml; + + /// Parses the provided command line arguments and returns a [YamlReader]. + /// + /// This is a utility function which does all things a program would do when + /// parsing command line arguments, including exiting from the program when + /// arguments are invalid. + static YamlReader parseArgs(List args, + {bool allowYamlConfig = true}) { + final parser = ArgParser(); + parser.addFlag('help', abbr: 'h', help: 'Show this help.'); + + // Sometimes it's required to change a config value for a single invocation, + // then this option can be used. Conventionally in -D switch is used in + // C to set preprocessor variable & in java to override a config property. + + parser.addMultiOption('override', + abbr: 'D', + help: 'Override or assign a config property from command line.'); + if (allowYamlConfig) { + parser.addOption('config', abbr: 'c', help: 'Path to YAML config.'); + } + + final results = parser.parse(args); + if (results['help']) { + stderr.writeln(parser.usage); + exit(1); + } + final configFile = results['config'] as String?; + Map yamlMap = {}; + if (configFile != null) { + try { + final yamlInput = loadYaml(File(configFile).readAsStringSync(), + sourceUrl: Uri.file(configFile)); + if (yamlInput is Map) { + yamlMap = yamlInput; + } else { + throw ConfigError('YAML config must be set of key value pairs'); + } + } on Exception catch (e) { + stderr.writeln('cannot read $configFile: $e'); + } + } + final regex = RegExp('([a-z-_.]+)=(.*)'); + final properties = {}; + for (var prop in results['override']) { + final match = regex.matchAsPrefix(prop as String); + if (match != null && match.group(0) == prop) { + final propertyName = match.group(1); + final propertyValue = match.group(2); + properties[propertyName!] = propertyValue!; + } else { + throw ConfigError('override does not match expected pattern'); + } + } + return YamlReader.of(properties, yamlMap); + } + + bool? getBool(String property) { + if (cli.containsKey(property)) { + final v = cli[property]!; + if (v == 'true') { + return true; + } + if (v == 'false') { + return false; + } + throw ConfigError('expected boolean value for $property, got $v'); + } + return null; + } + + String? getString(String property) { + final configValue = cli[property] ?? getYamlValue(property); + return configValue; + } + + List? getStringList(String property) { + final configValue = cli[property]?.split(',') ?? + getYamlValue(property)?.cast(); + return configValue; + } + + String? getOneOf(String property, Set values) { + final value = cli[property] ?? getYamlValue(property); + if (value == null || values.contains(value)) { + return value; + } + throw ConfigError('expected one of $values for $property'); + } + + Map? getStringMap(String property) { + final value = getYamlValue(property); + return value?.cast(); + } + + bool hasValue(String property) => getYamlValue(property) != null; + + T? getYamlValue(String property) { + final path = property.split('.'); + dynamic cursor = yaml; + String current = ''; + for (var i in path) { + if (cursor is YamlMap || cursor is Map) { + cursor = cursor[i]; + } else { + throw ConfigError('expected $current to be a YAML map'); + } + current = [if (current != '') current, i].join('.'); + if (cursor == null) { + return null; + } + } + if (cursor is! T) { + throw ConfigError('expected $T for $property, got ${cursor.runtimeType}'); + } + return cursor; + } +} diff --git a/pkgs/jni_gen/lib/src/generate_bindings.dart b/pkgs/jni_gen/lib/src/generate_bindings.dart new file mode 100644 index 000000000..b939f9c49 --- /dev/null +++ b/pkgs/jni_gen/lib/src/generate_bindings.dart @@ -0,0 +1,92 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +import 'dart:io'; +import 'dart:convert'; + +import 'elements/elements.dart'; +import 'summary/summary.dart'; +import 'config/config.dart'; +import 'tools/tools.dart'; +import 'writers/writers.dart'; + +Future generateJniBindings(Config config) async { + await buildSummarizerIfNotExists(); + + final summarizer = SummarizerCommand( + sourcePath: config.sourcePath, + classPath: config.classPath, + classes: config.classes, + workingDirectory: config.summarizerOptions?.workingDirectory, + extraArgs: config.summarizerOptions?.extraArgs ?? const [], + backend: config.summarizerOptions?.backend, + ); + + final extraSources = []; + final extraJars = []; + final mavenDl = config.mavenDownloads; + if (mavenDl != null) { + final sourcePath = mavenDl.sourceDir; + Directory(sourcePath).create(recursive: true); + await MavenTools.downloadMavenSources( + MavenTools.deps(mavenDl.sourceDeps), sourcePath); + extraSources.add(Uri.directory(sourcePath)); + final jarPath = mavenDl.jarDir; + Directory(jarPath).create(recursive: true); + await MavenTools.downloadMavenJars( + MavenTools.deps(mavenDl.sourceDeps + mavenDl.jarOnlyDeps), jarPath); + extraJars.addAll(await Directory(jarPath) + .list() + .where((entry) => entry.path.endsWith('.jar')) + .map((entry) => entry.uri) + .toList()); + } + + final androidConfig = config.androidSdkConfig; + if (androidConfig != null) { + final androidJar = await AndroidSdkTools.getAndroidJarPath( + sdkRoot: androidConfig.sdkRoot, versionOrder: androidConfig.versions); + if (androidJar != null) { + extraJars.add(Uri.directory(androidJar)); + } + if (androidConfig.includeSources) { + final androidSources = await AndroidSdkTools.getAndroidSourcesPath( + sdkRoot: androidConfig.sdkRoot, versionOrder: androidConfig.versions); + if (androidSources != null) { + extraSources.add(Uri.directory(androidSources)); + } + } + } + + summarizer.addSourcePaths(extraSources); + summarizer.addClassPaths(extraJars); + + Stream> input; + try { + input = await summarizer.getInputStream(); + } on Exception catch (e) { + stderr.writeln('error obtaining API summary: $e'); + return; + } + final stream = JsonDecoder().bind(Utf8Decoder().bind(input)); + dynamic json; + try { + json = await stream.single; + } on Exception catch (e) { + stderr.writeln('error while parsing summary: $e'); + return; + } + if (json == null) { + stderr.writeln('error: expected JSON element from summarizer.'); + return; + } + final list = json as List; + final outputWriter = FilesWriter(config); + try { + await outputWriter.writeBindings(list.map((c) => ClassDecl.fromJson(c))); + } on Exception catch (e, trace) { + stderr.writeln(trace); + stderr.writeln('error writing bindings: $e'); + } +} diff --git a/pkgs/jni_gen/lib/src/config/summary_source.dart b/pkgs/jni_gen/lib/src/summary/summary.dart similarity index 81% rename from pkgs/jni_gen/lib/src/config/summary_source.dart rename to pkgs/jni_gen/lib/src/summary/summary.dart index 622c36b73..a259f277c 100644 --- a/pkgs/jni_gen/lib/src/config/summary_source.dart +++ b/pkgs/jni_gen/lib/src/summary/summary.dart @@ -5,10 +5,6 @@ import 'dart:io'; import 'package:jni_gen/src/util/command_output.dart'; -abstract class SummarySource { - Future>> getInputStream(); -} - /// 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 @@ -21,25 +17,41 @@ abstract class SummarySource { /// /// The default summarizer needs to be built with `jni_gen:setup` /// script before this API is used. -class SummarizerCommand extends SummarySource { +class SummarizerCommand { SummarizerCommand({ this.command = "java -jar .dart_tool/jni_gen/ApiSummarizer.jar", - required this.sourcePaths, - this.classPaths = const [], + List? sourcePath, + List? classPath, this.extraArgs = const [], required this.classes, this.workingDirectory, - }); + this.backend, + }) : sourcePaths = sourcePath ?? [], + classPaths = classPath ?? [] { + if (backend != null && !{'asm', 'doclet'}.contains(backend)) { + throw ArgumentError('Supported backends: asm, doclet'); + } + } static const sourcePathsOption = '-s'; static const classPathsOption = '-c'; String command; List sourcePaths, classPaths; + List extraArgs; List classes; Uri? workingDirectory; + String? backend; + + void addSourcePaths(List paths) { + sourcePaths.addAll(paths); + } + + void addClassPaths(List paths) { + classPaths.addAll(paths); + } void _addPathParam(List args, String option, List paths) { if (paths.isNotEmpty) { @@ -54,7 +66,6 @@ class SummarizerCommand extends SummarySource { } } - @override Future>> getInputStream() async { final commandSplit = command.split(" "); final exec = commandSplit[0]; @@ -62,6 +73,9 @@ class SummarizerCommand extends SummarySource { _addPathParam(args, sourcePathsOption, sourcePaths); _addPathParam(args, classPathsOption, classPaths); + if (backend != null) { + args.addAll(['--backend', backend!]); + } args.addAll(extraArgs); args.addAll(classes); @@ -73,15 +87,3 @@ class SummarizerCommand extends SummarySource { return proc.stdout; } } - -/// A JSON file based summary source. -// (Did not test it yet) -class SummaryFile extends SummarySource { - Uri path; - SummaryFile(this.path); - SummaryFile.fromPath(String path) : path = Uri.file(path); - - @override - Future>> getInputStream() async => - File.fromUri(path).openRead(); -} diff --git a/pkgs/jni_gen/lib/src/tools/android_sdk_tools.dart b/pkgs/jni_gen/lib/src/tools/android_sdk_tools.dart new file mode 100644 index 000000000..e1092b2c0 --- /dev/null +++ b/pkgs/jni_gen/lib/src/tools/android_sdk_tools.dart @@ -0,0 +1,45 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +import 'dart:io'; +import 'package:path/path.dart'; + +class AndroidSdkTools { + /// get path for android API sources + static Future _getVersionDir( + String relative, String? sdkRoot, List versionOrder) async { + sdkRoot ??= Platform.environment['ANDROID_SDK_ROOT']; + if (sdkRoot == null) { + throw ArgumentError('SDK Root not provided and ANDROID_SDK_ROOT not set'); + } + final parent = join(sdkRoot, relative); + for (var version in versionOrder) { + final dir = Directory(join(parent, 'android-$version')); + if (await dir.exists()) { + return dir.path; + } + } + return null; + } + + static Future getAndroidSourcesPath( + {String? sdkRoot, required List versionOrder}) async { + return _getVersionDir('sources', sdkRoot, versionOrder); + } + + static Future _getFile(String relative, String file, String? sdkRoot, + List versionOrder) async { + final platform = await _getVersionDir(relative, sdkRoot, versionOrder); + if (platform == null) return null; + final filePath = join(platform, file); + if (await File(filePath).exists()) { + return filePath; + } + return null; + } + + static Future getAndroidJarPath( + {String? sdkRoot, required List versionOrder}) async => + await _getFile('platforms', 'android.jar', sdkRoot, versionOrder); +} diff --git a/pkgs/jni_gen/lib/src/tools/build_summarizer.dart b/pkgs/jni_gen/lib/src/tools/build_summarizer.dart new file mode 100644 index 000000000..46847fb68 --- /dev/null +++ b/pkgs/jni_gen/lib/src/tools/build_summarizer.dart @@ -0,0 +1,60 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +import 'dart:io'; + +import 'package:path/path.dart'; + +import 'package:jni_gen/src/util/find_package.dart'; + +final toolPath = join('.', '.dart_tool', 'jni_gen'); +final mvnTargetDir = join(toolPath, 'target'); +final jarFile = join(toolPath, 'ApiSummarizer.jar'); +final targetJarFile = join(mvnTargetDir, 'ApiSummarizer.jar'); + +Future buildApiSummarizer() async { + final pkg = await findPackageRoot('jni_gen'); + if (pkg == null) { + stderr.writeln('package jni_gen not found!'); + exitCode = 2; + return; + } + final pom = pkg.resolve('java/pom.xml'); + await Directory(toolPath).create(recursive: true); + final mvnProc = await Process.start( + 'mvn', + [ + '--batch-mode', + '--update-snapshots', + '-f', + pom.toFilePath(), + 'assembly:assembly' + ], + workingDirectory: toolPath, + mode: ProcessStartMode.inheritStdio); + await mvnProc.exitCode; + File(targetJarFile).renameSync(jarFile); + Directory(mvnTargetDir).deleteSync(recursive: true); +} + +Future buildSummarizerIfNotExists({bool force = false}) async { + final jarExists = await File(jarFile).exists(); + final isJarStale = jarExists && + await isPackageModifiedAfter( + 'jni_gen', await File(jarFile).lastModified(), 'java/'); + if (isJarStale) { + stderr.writeln('Rebuilding ApiSummarizer component since sources ' + 'have changed. This might take some time.'); + } + if (!jarExists) { + stderr.write('Building ApiSummarizer component. ' + 'This might take some time. \n' + 'The build will be cached for subsequent runs\n'); + } + if (!jarExists || isJarStale || force) { + await buildApiSummarizer(); + } else { + stderr.writeln('ApiSummarizer.jar exists. Skipping build..'); + } +} diff --git a/pkgs/jni_gen/lib/src/tools/maven_utils.dart b/pkgs/jni_gen/lib/src/tools/maven_tools.dart similarity index 56% rename from pkgs/jni_gen/lib/src/tools/maven_utils.dart rename to pkgs/jni_gen/lib/src/tools/maven_tools.dart index 2c28657fb..52835d996 100644 --- a/pkgs/jni_gen/lib/src/tools/maven_utils.dart +++ b/pkgs/jni_gen/lib/src/tools/maven_tools.dart @@ -6,7 +6,7 @@ import 'dart:io'; /// This class provides some utility methods to download a sources / jars /// using maven along with transitive dependencies. -class MvnTools { +class MavenTools { static const _tempPom = '__temp_pom.xml'; static const _tempClassPath = '__temp_classpath.xml'; static const _tempTarget = '__mvn_target'; @@ -31,34 +31,34 @@ class MvnTools { } static Future _runMavenCommand( - List deps, List mvnArgs) async { + List deps, List mvnArgs) async { final pom = _getStubPom(deps); _verboseLog('using POM stub:\n$pom'); await File(_tempPom).writeAsString(pom); await Directory(_tempTarget).create(); - await _runCmd( - 'mvn', ['-f', _tempPom, '-DbuildDirectory=$_tempTarget', ...mvnArgs]); + await _runCmd('mvn', ['-f', _tempPom, ...mvnArgs]); await File(_tempPom).delete(); await Directory(_tempTarget).delete(recursive: true); } - /// Create a list of [MvnDep] objects from maven coordinates in string form. - static List makeDependencyList(List depNames) => - depNames.map(MvnDep.fromString).toList(); + /// Create a list of [MavenDependency] objects from maven coordinates in string form. + static List deps(List depNames) => + depNames.map(MavenDependency.fromString).toList(); /// Downloads and unpacks source files of [deps] into [targetDir]. static Future downloadMavenSources( - List deps, String targetDir) async { + List deps, String targetDir) async { await _runMavenCommand(deps, [ 'dependency:unpack-dependencies', + '-DexcludeTransitive=true', '-DoutputDirectory=$targetDir', - '-Dclassifier=sources' + '-Dclassifier=sources', ]); } /// Downloads JAR files of all [deps] transitively into [targetDir]. static Future downloadMavenJars( - List deps, String targetDir) async { + List deps, String targetDir) async { await _runMavenCommand(deps, [ 'dependency:copy-dependencies', '-DoutputDirectory=$targetDir', @@ -66,7 +66,7 @@ class MvnTools { } /// Get classpath string using JARs in maven's local repository. - static Future getMavenClassPath(List deps) async { + static Future getMavenClassPath(List deps) async { await _runMavenCommand(deps, [ 'dependency:build-classpath', '-Dmdep.outputFile=$_tempClassPath', @@ -77,57 +77,60 @@ class MvnTools { return classpath; } - static String _getStubPom(List deps, {String javaVersion = '11'}) { - final i2 = ' ' * 2; - final i4 = ' ' * 4; - final i6 = ' ' * 6; - final i8 = ' ' * 8; + static String _getStubPom(List deps, + {String javaVersion = '11'}) { final depDecls = []; - for (var dep in deps) { final otherTags = StringBuffer(); for (var entry in dep.otherTags.entries) { - otherTags.write('$i6<${entry.key}>\n' - '$i8${entry.value}\n' - '$i6\n'); + otherTags.write(''' + <${entry.key}> + ${entry.value} + + '''); } - depDecls.add('$i4\n' - '$i6${dep.groupID}\n' - '$i6${dep.artifactID}\n' - '$i6${dep.version}\n' - '${otherTags.toString()}\n' - '$i4\n'); + depDecls.add(''' + + ${dep.groupID} + ${dep.artifactID} + ${dep.version} + ${otherTags.toString()} + '''); } - return '\n' - '$i24.0.0\n' - '$i2com.mycompany.app\n' - '$i2my-app\n' - '$i21.0-SNAPSHOT\n' - '$i2\n' - '$i4$javaVersion\n' - '$i4$javaVersion\n' - '$i2\n' - '$i4\n' - '${depDecls.join("\n")}' - '$i2\n' - ''; + return ''' + + 4.0.0 + com.mycompany.app + jnigen_maven_stub + 1.0-SNAPSHOT + + $javaVersion + $javaVersion + + +${depDecls.join("\n")} + + + $_tempTarget + +'''; } } /// Maven dependency with group ID, artifact ID, and version. -class MvnDep { - MvnDep(this.groupID, this.artifactID, this.version, +class MavenDependency { + MavenDependency(this.groupID, this.artifactID, this.version, {this.otherTags = const {}}); - factory MvnDep.fromString(String fullName) { + factory MavenDependency.fromString(String fullName) { final components = fullName.split(':'); if (components.length != 3) { throw ArgumentError('invalid name for maven dependency: $fullName'); } - return MvnDep(components[0], components[1], components[2]); + return MavenDependency(components[0], components[1], components[2]); } String groupID, artifactID, version; Map otherTags; diff --git a/pkgs/jni_gen/lib/src/config/errors.dart b/pkgs/jni_gen/lib/src/tools/tools.dart similarity index 64% rename from pkgs/jni_gen/lib/src/config/errors.dart rename to pkgs/jni_gen/lib/src/tools/tools.dart index 516e8f8bf..9677a3e48 100644 --- a/pkgs/jni_gen/lib/src/config/errors.dart +++ b/pkgs/jni_gen/lib/src/tools/tools.dart @@ -2,5 +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. -/// Base class for all unexpected errors in JniGen (Except Skip) -abstract class JniGenException implements Exception {} +export 'android_sdk_tools.dart'; +export 'maven_tools.dart'; +export 'build_summarizer.dart'; diff --git a/pkgs/jni_gen/lib/src/writers/bindings_writer.dart b/pkgs/jni_gen/lib/src/writers/bindings_writer.dart deleted file mode 100644 index ed50a412c..000000000 --- a/pkgs/jni_gen/lib/src/writers/bindings_writer.dart +++ /dev/null @@ -1,11 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -import 'package:jni_gen/src/elements/elements.dart'; -import 'package:jni_gen/src/config/wrapper_options.dart'; - -abstract class BindingsWriter { - Future writeBindings( - Iterable classes, WrapperOptions options); -} diff --git a/pkgs/jni_gen/lib/src/writers/callback_writer.dart b/pkgs/jni_gen/lib/src/writers/callback_writer.dart deleted file mode 100644 index 0ab7ed02b..000000000 --- a/pkgs/jni_gen/lib/src/writers/callback_writer.dart +++ /dev/null @@ -1,20 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -import 'package:jni_gen/src/elements/elements.dart'; -import 'package:jni_gen/src/config/wrapper_options.dart'; - -import 'bindings_writer.dart'; - -/// A writer for debugging purpose. -class CallbackWriter extends BindingsWriter { - CallbackWriter(this.callback); - Future Function(Iterable, WrapperOptions) callback; - - @override - Future writeBindings( - Iterable classes, WrapperOptions options) async { - callback(classes, options); - } -} diff --git a/pkgs/jni_gen/lib/src/writers/files_writer.dart b/pkgs/jni_gen/lib/src/writers/files_writer.dart deleted file mode 100644 index 0e8a6ad71..000000000 --- a/pkgs/jni_gen/lib/src/writers/files_writer.dart +++ /dev/null @@ -1,132 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -import 'dart:io'; - -import 'package:jni_gen/src/bindings/bindings.dart'; - -import 'package:jni_gen/src/elements/elements.dart'; -import 'package:jni_gen/src/config/wrapper_options.dart'; -import 'package:jni_gen/src/util/find_package.dart'; - -import 'bindings_writer.dart'; - -/// Writer which takes writes C and Dart bindings to specified directories. -/// -/// The structure of dart files is determined by package structure of java. -/// One dart file corresponds to one java package, and it's path is decided by -/// fully qualified name of the package. -/// -/// Example: -/// `android.os` -> `$dartWrappersRoot`/`android/os.dart` -class FilesWriter extends BindingsWriter { - static const _initFileName = 'init.dart'; - - FilesWriter( - {required this.cWrapperDir, - required this.dartWrappersRoot, - this.javaWrappersRoot, - this.preamble, - required this.libraryName}); - Uri cWrapperDir, dartWrappersRoot; - Uri? javaWrappersRoot; - String? preamble; - String libraryName; - @override - Future writeBindings( - Iterable classes, WrapperOptions options) async { - // If the file already exists, show warning. - // sort classes so that all classes get written at once. - final Map> packages = {}; - final Map classesByName = {}; - for (var c in classes) { - classesByName.putIfAbsent(c.binaryName, () => c); - packages.putIfAbsent(c.packageName!, () => []); - packages[c.packageName!]!.add(c); - } - final classNames = classesByName.keys.toSet(); - - stderr.writeln('Creating dart init file ...'); - final initFileUri = dartWrappersRoot.resolve(_initFileName); - final initFile = await File.fromUri(initFileUri).create(recursive: true); - await initFile.writeAsString(DartPreludes.initFile(libraryName), - flush: true); - - final cFile = await File.fromUri(cWrapperDir.resolve('$libraryName.c')) - .create(recursive: true); - final cFileStream = cFile.openWrite(); - if (preamble != null) { - cFileStream.writeln(preamble); - } - cFileStream.write(CPreludes.prelude); - final preprocessor = ApiPreprocessor(classesByName, options); - preprocessor.preprocessAll(); - for (var packageName in packages.keys) { - final relativeFileName = '${packageName.replaceAll('.', '/')}.dart'; - final dartFileUri = dartWrappersRoot.resolve(relativeFileName); - stderr.writeln('Writing bindings for $packageName...'); - final dartFile = await File.fromUri(dartFileUri).create(recursive: true); - final resolver = PackagePathResolver( - options.importPaths, packageName, classNames, - predefined: {'java.lang.String': 'jni.JlString'}); - final cgen = CBindingGenerator(options); - final dgen = DartBindingsGenerator(options, resolver); - - final package = packages[packageName]!; - final cBindings = package.map(cgen.generateBinding).toList(); - final dartBindings = package.map(dgen.generateBinding).toList(); - // write imports from bindings - final dartFileStream = dartFile.openWrite(); - final initImportPath = ('../' * - relativeFileName.codeUnits - .where((cu) => '/'.codeUnitAt(0) == cu) - .length) + - _initFileName; - if (preamble != null) { - dartFileStream.writeln(preamble); - } - dartFileStream - ..write(DartPreludes.bindingFileHeaders) - ..write(resolver.getImportStrings().join('\n')) - ..write('import "$initImportPath" show jlookup;\n\n'); - // write dart bindings only after all imports are figured out - dartBindings.forEach(dartFileStream.write); - cBindings.forEach(cFileStream.write); - await dartFileStream.close(); - } - await cFileStream.close(); - stderr.writeln('Running dart format...'); - final formatRes = - await Process.run('dart', ['format', dartWrappersRoot.toFilePath()]); - if (formatRes.exitCode != 0) { - stderr.writeln('ERROR: dart format completed with ' - 'exit code ${formatRes.exitCode}'); - } - - stderr.writeln('Copying auxiliary files...'); - await _copyFileFromPackage( - 'jni', 'src/dartjni.h', cWrapperDir.resolve('dartjni.h')); - await _copyFileFromPackage('jni_gen', 'cmake/CMakeLists.txt.tmpl', - cWrapperDir.resolve('CMakeLists.txt'), - transform: (s) => s.replaceAll('{{LIBRARY_NAME}}', libraryName)); - stderr.writeln('Completed.'); - } - - Future _copyFileFromPackage(String package, String relPath, Uri target, - {String Function(String)? transform}) async { - final packagePath = await findPackageRoot(package); - if (packagePath != null) { - final sourceFile = File.fromUri(packagePath.resolve(relPath)); - final targetFile = await File.fromUri(target).create(); - var source = await sourceFile.readAsString(); - if (transform != null) { - source = transform(source); - } - await targetFile.writeAsString(source); - } else { - stderr.writeln('package $package not found! ' - 'skipped copying ${target.toFilePath()}'); - } - } -} diff --git a/pkgs/jni_gen/lib/src/writers/writers.dart b/pkgs/jni_gen/lib/src/writers/writers.dart index 887e6a9ba..38b202e47 100644 --- a/pkgs/jni_gen/lib/src/writers/writers.dart +++ b/pkgs/jni_gen/lib/src/writers/writers.dart @@ -2,6 +2,141 @@ // 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 'bindings_writer.dart'; -export 'files_writer.dart'; -export 'callback_writer.dart'; +import 'dart:io'; + +import 'package:jni_gen/src/bindings/bindings.dart'; + +import 'package:jni_gen/src/elements/elements.dart'; +import 'package:jni_gen/src/config/config.dart'; +import 'package:jni_gen/src/util/find_package.dart'; + +abstract class BindingsWriter { + Future writeBindings(Iterable classes); +} + +/// Writer which executes custom callback on passed class elements. +/// +/// This class is provided for debugging purposes. +class CallbackWriter implements BindingsWriter { + CallbackWriter(this.callback); + Future Function(Iterable) callback; + @override + Future writeBindings(Iterable classes) async { + await callback(classes); + } +} + +/// Writer which takes writes C and Dart bindings to specified directories. +/// +/// The structure of dart files is determined by package structure of java. +/// One dart file corresponds to one java package, and it's path is decided by +/// fully qualified name of the package. +/// +/// Example: +/// `android.os` -> `$dartWrappersRoot`/`android/os.dart` +class FilesWriter extends BindingsWriter { + static const _initFileName = 'init.dart'; + + FilesWriter(this.config); + Config config; + + @override + Future writeBindings(Iterable classes) async { + // If the file already exists, show warning. + // sort classes so that all classes get written at once. + final cRoot = config.cRoot; + final dartRoot = config.dartRoot; + final libraryName = config.libraryName; + final preamble = config.preamble; + + final Map> packages = {}; + final Map classesByName = {}; + for (var c in classes) { + classesByName.putIfAbsent(c.binaryName, () => c); + packages.putIfAbsent(c.packageName!, () => []); + packages[c.packageName!]!.add(c); + } + final classNames = classesByName.keys.toSet(); + + stderr.writeln('Creating dart init file ...'); + final initFileUri = dartRoot.resolve(_initFileName); + final initFile = await File.fromUri(initFileUri).create(recursive: true); + await initFile.writeAsString(DartPreludes.initFile(config.libraryName), + flush: true); + + final cFile = await File.fromUri(cRoot.resolve('$libraryName.c')) + .create(recursive: true); + final cFileStream = cFile.openWrite(); + if (preamble != null) { + cFileStream.writeln(preamble); + } + cFileStream.write(CPreludes.prelude); + ApiPreprocessor.preprocessAll(classesByName, config); + for (var packageName in packages.keys) { + final relativeFileName = '${packageName.replaceAll('.', '/')}.dart'; + final dartFileUri = dartRoot.resolve(relativeFileName); + stderr.writeln('Writing bindings for $packageName...'); + final dartFile = await File.fromUri(dartFileUri).create(recursive: true); + final resolver = PackagePathResolver( + config.importMap ?? const {}, packageName, classNames, + predefined: {'java.lang.String': 'jni.JlString'}); + final cgen = CBindingGenerator(config); + final dgen = DartBindingsGenerator(config, resolver); + + final package = packages[packageName]!; + final cBindings = package.map(cgen.generateBinding).toList(); + final dartBindings = package.map(dgen.generateBinding).toList(); + // write imports from bindings + final dartFileStream = dartFile.openWrite(); + final initImportPath = ('../' * + relativeFileName.codeUnits + .where((cu) => '/'.codeUnitAt(0) == cu) + .length) + + _initFileName; + if (preamble != null) { + dartFileStream.writeln(preamble); + } + dartFileStream + ..write(DartPreludes.bindingFileHeaders) + ..write(resolver.getImportStrings().join('\n')) + ..write('import "$initImportPath" show jlookup;\n\n'); + // write dart bindings only after all imports are figured out + dartBindings.forEach(dartFileStream.write); + cBindings.forEach(cFileStream.write); + await dartFileStream.close(); + } + await cFileStream.close(); + stderr.writeln('Running dart format...'); + final formatRes = + await Process.run('dart', ['format', dartRoot.toFilePath()]); + if (formatRes.exitCode != 0) { + stderr.writeln('ERROR: dart format completed with ' + 'exit code ${formatRes.exitCode}'); + } + + stderr.writeln('Copying auxiliary files...'); + await _copyFileFromPackage( + 'jni', 'src/dartjni.h', cRoot.resolve('dartjni.h')); + await _copyFileFromPackage( + 'jni_gen', 'cmake/CMakeLists.txt.tmpl', cRoot.resolve('CMakeLists.txt'), + transform: (s) => s.replaceAll('{{LIBRARY_NAME}}', libraryName)); + stderr.writeln('Completed.'); + } + + Future _copyFileFromPackage(String package, String relPath, Uri target, + {String Function(String)? transform}) async { + final packagePath = await findPackageRoot(package); + if (packagePath != null) { + final sourceFile = File.fromUri(packagePath.resolve(relPath)); + final targetFile = await File.fromUri(target).create(); + var source = await sourceFile.readAsString(); + if (transform != null) { + source = transform(source); + } + await targetFile.writeAsString(source); + } else { + stderr.writeln('package $package not found! ' + 'skipped copying ${target.toFilePath()}'); + } + } +} diff --git a/pkgs/jni_gen/lib/tools.dart b/pkgs/jni_gen/lib/tools.dart index 19e0eab54..91934d3f3 100644 --- a/pkgs/jni_gen/lib/tools.dart +++ b/pkgs/jni_gen/lib/tools.dart @@ -4,4 +4,4 @@ library jni_gen_tools; -export 'src/tools/maven_utils.dart'; +export 'src/tools/tools.dart'; diff --git a/pkgs/jni_gen/pubspec.yaml b/pkgs/jni_gen/pubspec.yaml index c75369b49..f347657bb 100644 --- a/pkgs/jni_gen/pubspec.yaml +++ b/pkgs/jni_gen/pubspec.yaml @@ -13,7 +13,9 @@ environment: dependencies: json_annotation: ^4.6.0 package_config: ^2.1.0 - path: + path: ^1.8.0 + args: ^2.3.0 + yaml: ^3.1.0 dev_dependencies: lints: ^2.0.0 diff --git a/pkgs/jni_gen/test/config_test.dart b/pkgs/jni_gen/test/config_test.dart new file mode 100644 index 000000000..e7b8c2536 --- /dev/null +++ b/pkgs/jni_gen/test/config_test.dart @@ -0,0 +1,74 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +import 'package:jni_gen/src/config/config.dart'; +import 'package:test/test.dart'; +import 'package:path/path.dart' hide equals; + +import 'jackson_core_test/generate.dart'; + +const packageTests = 'test'; +final jacksonCoreTests = join(packageTests, 'jackson_core_test'); +final thirdParty = join(jacksonCoreTests, 'third_party'); +final lib = join(thirdParty, 'lib'); +final src = join(thirdParty, 'src'); +final testLib = join(thirdParty, 'test_lib'); +final testSrc = join(thirdParty, 'test_src'); + +/// Compares 2 [Config] objects using [expect] to give useful errors when +/// two fields are not equal. +void expectConfigsAreEqual(Config a, Config b) { + expect(a.classes, equals(b.classes)); + expect(a.libraryName, equals(b.libraryName)); + expect(a.cRoot, equals(b.cRoot)); + expect(a.dartRoot, equals(b.dartRoot)); + expect(a.sourcePath, equals(b.sourcePath)); + expect(a.classPath, equals(b.classPath)); + expect(a.preamble, equals(b.preamble)); + expect(a.importMap, equals(b.importMap)); + final am = a.mavenDownloads; + final bm = b.mavenDownloads; + if (am != null) { + expect(bm, isNotNull); + expect(am.sourceDeps, bm!.sourceDeps); + expect(am.sourceDir, bm.sourceDir); + expect(am.jarOnlyDeps, bm.jarOnlyDeps); + expect(am.jarDir, bm.jarDir); + } else { + expect(bm, isNull); + } + final aa = a.androidSdkConfig; + final ba = b.androidSdkConfig; + if (aa != null) { + expect(ba, isNotNull); + expect(aa.versions, ba!.versions); + expect(aa.sdkRoot, ba.sdkRoot); + expect(aa.includeSources, ba.includeSources); + } else { + expect(ba, isNull); + } + final aso = a.summarizerOptions; + final bso = b.summarizerOptions; + if (aso != null) { + expect(bso, isNotNull); + expect(aso.extraArgs, bso!.extraArgs); + expect(aso.workingDirectory, bso.workingDirectory); + expect(aso.backend, bso.backend); + } else { + expect(bso, isNull); + } +} + +void main() { + final config = Config.parseArgs([ + '--config', + join(jacksonCoreTests, 'jnigen.yaml'), + '-Dc_root=$testSrc', + '-Ddart_root=$testLib', + ]); + + test('compare configuration values', () { + expectConfigsAreEqual(config, getConfig(isTest: true)); + }); +} diff --git a/pkgs/jni_gen/test/jackson_core_test/generate.dart b/pkgs/jni_gen/test/jackson_core_test/generate.dart index 5d6259233..919fadb14 100644 --- a/pkgs/jni_gen/test/jackson_core_test/generate.dart +++ b/pkgs/jni_gen/test/jackson_core_test/generate.dart @@ -3,7 +3,7 @@ // BSD-style license that can be found in the LICENSE file. import 'package:jni_gen/jni_gen.dart'; -import '../test_util/test_util.dart'; +import 'package:path/path.dart' hide equals; const jacksonPreamble = '// Generated from jackson-core which is licensed under' ' the Apache License 2.0.\n' @@ -23,18 +23,27 @@ const jacksonPreamble = '// Generated from jackson-core which is licensed under' '// See the License for the specific language governing permissions and\n' '// limitations under the License.\n'; -Future generate( +const testName = 'jackson_core_test'; +final thirdParty = join('test', testName, 'third_party'); +const deps = ['com.fasterxml.jackson.core:jackson-core:2.13.3']; + +Config getConfig( {bool isTest = false, bool generateFullVersion = false, - bool useAsm = false}) async { - final deps = ['com.fasterxml.jackson.core:jackson-core:2.13.3']; - await generateBindings( - testName: 'jackson_core_test', - sourceDepNames: deps, - jarDepNames: deps, - useAsmBackend: useAsm, + bool useAsm = false}) { + final config = Config( + mavenDownloads: MavenDownloads( + sourceDeps: deps, + sourceDir: join(thirdParty, 'java'), + jarDir: join(thirdParty, 'jar'), + ), + summarizerOptions: SummarizerOptions( + backend: useAsm ? 'asm' : null, + ), preamble: jacksonPreamble, - isThirdParty: true, + libraryName: testName, + cRoot: Uri.directory(join(thirdParty, isTest ? 'test_src' : 'src')), + dartRoot: Uri.directory(join(thirdParty, isTest ? 'test_lib' : 'lib')), classes: (generateFullVersion) ? ['com.fasterxml.jackson.core'] : [ @@ -42,20 +51,25 @@ Future generate( 'com.fasterxml.jackson.core.JsonParser', 'com.fasterxml.jackson.core.JsonToken', ], - isGeneratedFileTest: isTest, - options: WrapperOptions( - fieldFilter: CombinedFieldFilter([ - excludeAll([ - ['com.fasterxml.jackson.core.JsonFactory', 'DEFAULT_QUOTE_CHAR'], - ['com.fasterxml.jackson.core.Base64Variant', 'PADDING_CHAR_NONE'], - ['com.fasterxml.jackson.core.base.ParserMinimalBase', 'CHAR_NULL'], - ['com.fasterxml.jackson.core.io.UTF32Reader', 'NC'], - ]), - CustomFieldFilter((decl, field) => !field.name.startsWith("_")), - ]), - methodFilter: - CustomMethodFilter((decl, method) => !method.name.startsWith('_'))), + exclude: BindingExclusions( + fields: excludeAll([ + ['com.fasterxml.jackson.core.JsonFactory', 'DEFAULT_QUOTE_CHAR'], + ['com.fasterxml.jackson.core.Base64Variant', 'PADDING_CHAR_NONE'], + ['com.fasterxml.jackson.core.base.ParserMinimalBase', 'CHAR_NULL'], + ['com.fasterxml.jackson.core.io.UTF32Reader', 'NC'], + ]), + ), ); + return config; +} + +Future generate( + {bool isTest = false, + bool generateFullVersion = false, + bool useAsm = false}) async { + final config = getConfig( + isTest: isTest, generateFullVersion: generateFullVersion, useAsm: useAsm); + await generateJniBindings(config); } void main() => generate(isTest: false); diff --git a/pkgs/jni_gen/test/jackson_core_test/jnigen.yaml b/pkgs/jni_gen/test/jackson_core_test/jnigen.yaml new file mode 100644 index 000000000..96988bd1a --- /dev/null +++ b/pkgs/jni_gen/test/jackson_core_test/jnigen.yaml @@ -0,0 +1,36 @@ +maven_downloads: + source_deps: + - 'com.fasterxml.jackson.core:jackson-core:2.13.3' + source_dir: test/jackson_core_test/third_party/java + jar_dir: test/jackson_core_test/third_party/jar + +dart_root: test/jackson_core_test/third_party/lib +c_root: test/jackson_core_test/third_party/src +library_name: jackson_core_test +classes: + - 'com.fasterxml.jackson.core.JsonFactory' + - 'com.fasterxml.jackson.core.JsonParser' + - 'com.fasterxml.jackson.core.JsonToken' + +exclude: + fields: + - 'com.fasterxml.jackson.core.JsonFactory#DEFAULT_QUOTE_CHAR' + +preamble: | + // Generated from jackson-core which is licensed under the Apache License 2.0. + // The following copyright from the original authors applies. + // See https://github.com/FasterXML/jackson-core/blob/2.14/LICENSE + // + // Copyright (c) 2007 - The Jackson Project Authors + // Licensed under the Apache License, Version 2.0 (the "License") + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + diff --git a/pkgs/jni_gen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core.dart b/pkgs/jni_gen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core.dart index ee2de7190..6ecc806d3 100644 --- a/pkgs/jni_gen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core.dart +++ b/pkgs/jni_gen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core.dart @@ -61,7 +61,7 @@ class JsonFactory extends jni.JlObject { /// (and returned by \#getFormatName() static const FORMAT_NAME_JSON = "JSON"; - static final _getDEFAULT_FACTORY_FEATURE_FLAGS = jlookup< + static final _get_DEFAULT_FACTORY_FEATURE_FLAGS = jlookup< ffi.NativeFunction>( "get_com_fasterxml_jackson_core_JsonFactory_DEFAULT_FACTORY_FEATURE_FLAGS") .asFunction(); @@ -70,9 +70,9 @@ class JsonFactory extends jni.JlObject { /// /// Bitfield (set of flags) of all factory features that are enabled by default. static int get DEFAULT_FACTORY_FEATURE_FLAGS => - _getDEFAULT_FACTORY_FEATURE_FLAGS(); + _get_DEFAULT_FACTORY_FEATURE_FLAGS(); - static final _getDEFAULT_PARSER_FEATURE_FLAGS = jlookup< + static final _get_DEFAULT_PARSER_FEATURE_FLAGS = jlookup< ffi.NativeFunction>( "get_com_fasterxml_jackson_core_JsonFactory_DEFAULT_PARSER_FEATURE_FLAGS") .asFunction(); @@ -82,9 +82,9 @@ class JsonFactory extends jni.JlObject { /// Bitfield (set of flags) of all parser features that are enabled /// by default. static int get DEFAULT_PARSER_FEATURE_FLAGS => - _getDEFAULT_PARSER_FEATURE_FLAGS(); + _get_DEFAULT_PARSER_FEATURE_FLAGS(); - static final _getDEFAULT_GENERATOR_FEATURE_FLAGS = jlookup< + static final _get_DEFAULT_GENERATOR_FEATURE_FLAGS = jlookup< ffi.NativeFunction>( "get_com_fasterxml_jackson_core_JsonFactory_DEFAULT_GENERATOR_FEATURE_FLAGS") .asFunction(); @@ -94,9 +94,9 @@ class JsonFactory extends jni.JlObject { /// Bitfield (set of flags) of all generator features that are enabled /// by default. static int get DEFAULT_GENERATOR_FEATURE_FLAGS => - _getDEFAULT_GENERATOR_FEATURE_FLAGS(); + _get_DEFAULT_GENERATOR_FEATURE_FLAGS(); - static final _getDEFAULT_ROOT_VALUE_SEPARATOR = jlookup< + static final _get_DEFAULT_ROOT_VALUE_SEPARATOR = jlookup< ffi.NativeFunction Function()>>( "get_com_fasterxml_jackson_core_JsonFactory_DEFAULT_ROOT_VALUE_SEPARATOR") .asFunction Function()>(); @@ -104,7 +104,7 @@ class JsonFactory extends jni.JlObject { /// from: static public final com.fasterxml.jackson.core.SerializableString DEFAULT_ROOT_VALUE_SEPARATOR /// The returned object must be deleted after use, by calling the `delete` method. static jni.JlObject get DEFAULT_ROOT_VALUE_SEPARATOR => - jni.JlObject.fromRef(_getDEFAULT_ROOT_VALUE_SEPARATOR()); + jni.JlObject.fromRef(_get_DEFAULT_ROOT_VALUE_SEPARATOR()); static final _ctor = jlookup Function()>>( @@ -1682,7 +1682,7 @@ class JsonParser extends jni.JlObject { /// from: private static final int MAX_SHORT_I static const MAX_SHORT_I = 32767; - static final _getDEFAULT_READ_CAPABILITIES = jlookup< + static final _get_DEFAULT_READ_CAPABILITIES = jlookup< ffi.NativeFunction Function()>>( "get_com_fasterxml_jackson_core_JsonParser_DEFAULT_READ_CAPABILITIES") .asFunction Function()>(); @@ -1695,7 +1695,7 @@ class JsonParser extends jni.JlObject { /// set needs to be passed). ///@since 2.12 static jni.JlObject get DEFAULT_READ_CAPABILITIES => - jni.JlObject.fromRef(_getDEFAULT_READ_CAPABILITIES()); + jni.JlObject.fromRef(_get_DEFAULT_READ_CAPABILITIES()); static final _ctor = jlookup Function()>>( diff --git a/pkgs/jni_gen/test/jackson_core_test/third_party/src/dartjni.h b/pkgs/jni_gen/test/jackson_core_test/third_party/src/dartjni.h index 407312bbe..cd94b1532 100644 --- a/pkgs/jni_gen/test/jackson_core_test/third_party/src/dartjni.h +++ b/pkgs/jni_gen/test/jackson_core_test/third_party/src/dartjni.h @@ -1,3 +1,7 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + #include #include #include diff --git a/pkgs/jni_gen/test/simple_package_test/generate.dart b/pkgs/jni_gen/test/simple_package_test/generate.dart index 427098de3..dd6eeca9d 100644 --- a/pkgs/jni_gen/test/simple_package_test/generate.dart +++ b/pkgs/jni_gen/test/simple_package_test/generate.dart @@ -20,7 +20,6 @@ Future compileJavaSources(String workingDir, List files) async { } Future generateSources(String lib, String src) async { - await runCmd('dart', ['run', 'jni_gen:setup']); await compileJavaSources(javaPath, javaFiles); final cWrapperDir = Uri.directory(join(testRoot, src)); final dartWrappersRoot = Uri.directory(join(testRoot, lib)); @@ -31,17 +30,15 @@ Future generateSources(String lib, String src) async { await dir.delete(recursive: true); } } - await JniGenTask( - summarySource: SummarizerCommand( - sourcePaths: [Uri.directory(javaPath)], - classPaths: [Uri.directory(javaPath)], - classes: ['dev.dart.simple_package', 'dev.dart.pkg2'], - ), - outputWriter: FilesWriter( - cWrapperDir: cWrapperDir, - dartWrappersRoot: dartWrappersRoot, - libraryName: 'simple_package'), - ).run(); + final config = Config( + sourcePath: [Uri.directory(javaPath)], + classPath: [Uri.directory(javaPath)], + classes: ['dev.dart.simple_package', 'dev.dart.pkg2'], + cRoot: cWrapperDir, + dartRoot: dartWrappersRoot, + libraryName: 'simple_package', + ); + await generateJniBindings(config); } void main() async => await generateSources('lib', 'src'); diff --git a/pkgs/jni_gen/test/simple_package_test/lib/dev/dart/pkg2.dart b/pkgs/jni_gen/test/simple_package_test/lib/dev/dart/pkg2.dart index 618b1750c..0fa32cd82 100644 --- a/pkgs/jni_gen/test/simple_package_test/lib/dev/dart/pkg2.dart +++ b/pkgs/jni_gen/test/simple_package_test/lib/dev/dart/pkg2.dart @@ -17,19 +17,20 @@ import "../../init.dart" show jlookup; class C2 extends jni.JlObject { C2.fromRef(ffi.Pointer ref) : super.fromRef(ref); - static final _getCONSTANT = jlookup>( - "get_dev_dart_pkg2_C2_CONSTANT") - .asFunction(); + static final _get_CONSTANT = + jlookup>( + "get_dev_dart_pkg2_C2_CONSTANT") + .asFunction(); /// from: static public int CONSTANT - static int get CONSTANT => _getCONSTANT(); - static final _setCONSTANT = + static int get CONSTANT => _get_CONSTANT(); + static final _set_CONSTANT = jlookup>( "set_dev_dart_pkg2_C2_CONSTANT") .asFunction(); /// from: static public int CONSTANT - static set CONSTANT(int value) => _setCONSTANT(value); + static set CONSTANT(int value) => _set_CONSTANT(value); static final _ctor = jlookup Function()>>( diff --git a/pkgs/jni_gen/test/simple_package_test/lib/dev/dart/simple_package.dart b/pkgs/jni_gen/test/simple_package_test/lib/dev/dart/simple_package.dart index da6ec32fb..173c49304 100644 --- a/pkgs/jni_gen/test/simple_package_test/lib/dev/dart/simple_package.dart +++ b/pkgs/jni_gen/test/simple_package_test/lib/dev/dart/simple_package.dart @@ -23,36 +23,36 @@ class Example extends jni.JlObject { /// from: static public final int OFF static const OFF = 0; - static final _getaux = + static final _get_aux = jlookup Function()>>( "get_dev_dart_simple_package_Example_aux") .asFunction Function()>(); /// from: static public dev.dart.simple_package.Example.Aux aux /// The returned object must be deleted after use, by calling the `delete` method. - static Example_Aux get aux => Example_Aux.fromRef(_getaux()); - static final _setaux = + static Example_Aux get aux => Example_Aux.fromRef(_get_aux()); + static final _set_aux = jlookup)>>( "set_dev_dart_simple_package_Example_aux") .asFunction)>(); /// from: static public dev.dart.simple_package.Example.Aux aux /// The returned object must be deleted after use, by calling the `delete` method. - static set aux(Example_Aux value) => _setaux(value.reference); + static set aux(Example_Aux value) => _set_aux(value.reference); - static final _getnum = jlookup>( + static final _get_num = jlookup>( "get_dev_dart_simple_package_Example_num") .asFunction(); /// from: static public int num - static int get num => _getnum(); - static final _setnum = + static int get num => _get_num(); + static final _set_num = jlookup>( "set_dev_dart_simple_package_Example_num") .asFunction(); /// from: static public int num - static set num(int value) => _setnum(value); + static set num(int value) => _set_num(value); static final _ctor = jlookup Function()>>( @@ -111,7 +111,7 @@ class Example extends jni.JlObject { class Example_Aux extends jni.JlObject { Example_Aux.fromRef(ffi.Pointer ref) : super.fromRef(ref); - static final _getvalue = jlookup< + static final _get_value = jlookup< ffi.NativeFunction< ffi.Uint8 Function( ffi.Pointer, @@ -122,15 +122,15 @@ class Example_Aux extends jni.JlObject { )>(); /// from: public boolean value - bool get value => _getvalue(reference) != 0; - static final _setvalue = jlookup< + bool get value => _get_value(reference) != 0; + static final _set_value = jlookup< ffi.NativeFunction< ffi.Void Function(ffi.Pointer, ffi.Uint8)>>("set_dev_dart_simple_package_Example__Aux_value") .asFunction, int)>(); /// from: public boolean value - set value(bool value) => _setvalue(reference, value ? 1 : 0); + set value(bool value) => _set_value(reference, value ? 1 : 0); static final _ctor = jlookup Function(ffi.Uint8)>>( diff --git a/pkgs/jni_gen/test/simple_package_test/src/dartjni.h b/pkgs/jni_gen/test/simple_package_test/src/dartjni.h index 407312bbe..cd94b1532 100644 --- a/pkgs/jni_gen/test/simple_package_test/src/dartjni.h +++ b/pkgs/jni_gen/test/simple_package_test/src/dartjni.h @@ -1,3 +1,7 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + #include #include #include diff --git a/pkgs/jni_gen/test/test_util/test_util.dart b/pkgs/jni_gen/test/test_util/test_util.dart index c0a168195..49bc5ff72 100644 --- a/pkgs/jni_gen/test/test_util/test_util.dart +++ b/pkgs/jni_gen/test/test_util/test_util.dart @@ -1,13 +1,9 @@ import 'dart:io'; import 'package:path/path.dart' hide equals; -import 'package:jni_gen/jni_gen.dart'; -import 'package:jni_gen/tools.dart'; import 'package:test/test.dart'; -const packageTestsDir = 'test'; - -Future isEmptyDir(String path) async { +Future hasNoFilesInDir(String path) async { final dir = Directory(path); return (!await dir.exists()) || (await dir.list().length == 0); } @@ -22,72 +18,15 @@ Future runCmd(String exec, List args, return proc.exitCode; } -Future buildNativeLibs(String testName) async { - final testRoot = join(packageTestsDir, testName); - await runCmd('dart', ['run', 'jni:setup']); - await runCmd('dart', ['run', 'jni:setup', '-S', join(testRoot, 'src')]); -} - Future> getJarPaths(String testRoot) { final jarPath = join(testRoot, 'jar'); return Directory(jarPath) .list() .map((entry) => entry.path) - .where((path) => path.endsWith('jar')) + .where((path) => path.endsWith('.jar')) .toList(); } -/// Download dependencies using maven and generate bindings. -Future generateBindings({ - required String testName, - required List sourceDepNames, - required List jarDepNames, - required List classes, - required WrapperOptions options, - required bool isGeneratedFileTest, - bool useAsmBackend = false, - bool isThirdParty = false, - String? preamble, -}) async { - final testRoot = - join(packageTestsDir, testName, isThirdParty ? 'third_party' : ''); - final jarPath = join(testRoot, 'jar'); - final javaPath = join(testRoot, 'java'); - final src = join(testRoot, isGeneratedFileTest ? 'test_src' : 'src'); - final lib = join(testRoot, isGeneratedFileTest ? 'test_lib' : 'lib'); - - final sourceDeps = MvnTools.makeDependencyList(sourceDepNames); - final jarDeps = MvnTools.makeDependencyList(jarDepNames); - - await runCmd('dart', ['run', 'jni_gen:setup']); - - MvnTools.setVerbose(true); - if (await isEmptyDir(jarPath)) { - await Directory(jarPath).create(recursive: true); - await MvnTools.downloadMavenJars(jarDeps, jarPath); - } - if (await isEmptyDir(javaPath)) { - await Directory(javaPath).create(recursive: true); - await MvnTools.downloadMavenSources(sourceDeps, javaPath); - } - final jars = await getJarPaths(testRoot); - stderr.writeln('using classpath: $jars'); - await JniGenTask( - summarySource: SummarizerCommand( - sourcePaths: [Uri.directory(javaPath)], - classPaths: jars.map(Uri.file).toList(), - classes: classes, - extraArgs: useAsmBackend ? ['--backend', 'asm'] : [], - ), - options: options, - outputWriter: FilesWriter( - cWrapperDir: Uri.directory(src), - dartWrappersRoot: Uri.directory(lib), - preamble: preamble, - libraryName: testName)) - .run(); -} - /// compares 2 hierarchies, with and without prefix 'test_' void compareDirs(String path1, String path2) { final list1 = Directory(path1).listSync(recursive: true); diff --git a/pkgs/jni_gen/test/yaml_config_test.dart b/pkgs/jni_gen/test/yaml_config_test.dart new file mode 100644 index 000000000..2f180a60f --- /dev/null +++ b/pkgs/jni_gen/test/yaml_config_test.dart @@ -0,0 +1,42 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +// End-to-end test confirming yaml config works as expected. + +import 'dart:io'; + +import 'package:path/path.dart' hide equals; +import 'package:test/test.dart'; + +import 'test_util/test_util.dart'; + +void main() { + final thirdParty = join('test', 'jackson_core_test', 'third_party'); + final testLib = join(thirdParty, 'test_lib'); + final testSrc = join(thirdParty, 'test_src'); + final lib = join(thirdParty, 'lib'); + final src = join(thirdParty, 'src'); + final config = join('test', 'jackson_core_test', 'jnigen.yaml'); + test('generate and compare bindings using YAML config', () { + final jnigenProc = Process.runSync('dart', [ + 'run', + 'jni_gen', + '--config', + config, + '-Dc_root=$testSrc', + '-Ddart_root=$testLib' + ]); + expect(jnigenProc.exitCode, equals(0)); + + final analyzeProc = Process.runSync('dart', ['analyze', testLib]); + expect(analyzeProc.exitCode, equals(0)); + + compareDirs(lib, testLib); + compareDirs(src, testSrc); + + for (var dir in [testLib, testSrc]) { + Directory(dir).deleteSync(recursive: true); + } + }, timeout: Timeout.factor(4)); +} From 91a41f6d31119cdeb3c7a9c5e9e665bd44d268c5 Mon Sep 17 00:00:00 2001 From: Mahesh Hegde <46179734+mahesh-hegde@users.noreply.github.com> Date: Mon, 29 Aug 2022 18:13:25 +0530 Subject: [PATCH 010/139] [jnigen] Rename java package of simple_test to com.github.dart_lang.... (https://github.com/dart-lang/jnigen/issues/35) --- pkgs/jni_gen/test/bindings_test.dart | 4 +- .../test/simple_package_test/generate.dart | 12 +- .../generated_files_test.dart | 8 + .../github/dart_lang/jni_gen}/pkg2/C2.java | 2 +- .../jni_gen}/simple_package/Example.java | 2 +- .../github/dart_lang/jni_gen}/pkg2.dart | 10 +- .../dart_lang/jni_gen}/simple_package.dart | 62 +++--- .../simple_package_test/src/simple_package.c | 184 +++++++++--------- 8 files changed, 150 insertions(+), 134 deletions(-) rename pkgs/jni_gen/test/simple_package_test/java/{dev/dart => com/github/dart_lang/jni_gen}/pkg2/C2.java (56%) rename pkgs/jni_gen/test/simple_package_test/java/{dev/dart => com/github/dart_lang/jni_gen}/simple_package/Example.java (93%) rename pkgs/jni_gen/test/simple_package_test/lib/{dev/dart => com/github/dart_lang/jni_gen}/pkg2.dart (80%) rename pkgs/jni_gen/test/simple_package_test/lib/{dev/dart => com/github/dart_lang/jni_gen}/simple_package.dart (67%) diff --git a/pkgs/jni_gen/test/bindings_test.dart b/pkgs/jni_gen/test/bindings_test.dart index be93be283..fd8a1967b 100644 --- a/pkgs/jni_gen/test/bindings_test.dart +++ b/pkgs/jni_gen/test/bindings_test.dart @@ -16,8 +16,8 @@ import 'package:path/path.dart' hide equals; import 'package:test/test.dart'; // ignore_for_file: avoid_relative_lib_imports -import 'simple_package_test/lib/dev/dart/simple_package.dart'; -import 'simple_package_test/lib/dev/dart/pkg2.dart'; +import 'simple_package_test/lib/com/github/dart_lang/jni_gen/simple_package.dart'; +import 'simple_package_test/lib/com/github/dart_lang/jni_gen/pkg2.dart'; import 'jackson_core_test/third_party/lib/com/fasterxml/jackson/core.dart'; import 'test_util/test_util.dart'; diff --git a/pkgs/jni_gen/test/simple_package_test/generate.dart b/pkgs/jni_gen/test/simple_package_test/generate.dart index dd6eeca9d..2673a0f99 100644 --- a/pkgs/jni_gen/test/simple_package_test/generate.dart +++ b/pkgs/jni_gen/test/simple_package_test/generate.dart @@ -13,7 +13,12 @@ const testName = 'simple_package_test'; final testRoot = join('test', testName); final javaPath = join(testRoot, 'java'); -var javaFiles = ['dev/dart/$testName/Example.java', 'dev/dart/pkg2/C2.java']; +var javaPrefix = join('com', 'github', 'dart_lang', 'jni_gen'); + +var javaFiles = [ + join(javaPrefix, 'simple_package', 'Example.java'), + join(javaPrefix, 'pkg2', 'C2.java'), +]; Future compileJavaSources(String workingDir, List files) async { await runCmd('javac', files, workingDirectory: workingDir); @@ -33,7 +38,10 @@ Future generateSources(String lib, String src) async { final config = Config( sourcePath: [Uri.directory(javaPath)], classPath: [Uri.directory(javaPath)], - classes: ['dev.dart.simple_package', 'dev.dart.pkg2'], + classes: [ + 'com.github.dart_lang.jni_gen.simple_package', + 'com.github.dart_lang.jni_gen.pkg2', + ], cRoot: cWrapperDir, dartRoot: dartWrappersRoot, libraryName: 'simple_package', diff --git a/pkgs/jni_gen/test/simple_package_test/generated_files_test.dart b/pkgs/jni_gen/test/simple_package_test/generated_files_test.dart index c77a89889..1efa35ce3 100644 --- a/pkgs/jni_gen/test/simple_package_test/generated_files_test.dart +++ b/pkgs/jni_gen/test/simple_package_test/generated_files_test.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 'dart:io'; + import 'package:test/test.dart'; import 'package:path/path.dart' hide equals; @@ -15,4 +17,10 @@ void main() async { compareDirs(join(testRoot, 'lib'), join(testRoot, 'test_lib')); compareDirs(join(testRoot, 'src'), join(testRoot, 'test_src')); }); + for (var path in ['test_lib', 'test_src']) { + final folder = Directory(path); + if (await folder.exists()) { + await folder.delete(recursive: true); + } + } } diff --git a/pkgs/jni_gen/test/simple_package_test/java/dev/dart/pkg2/C2.java b/pkgs/jni_gen/test/simple_package_test/java/com/github/dart_lang/jni_gen/pkg2/C2.java similarity index 56% rename from pkgs/jni_gen/test/simple_package_test/java/dev/dart/pkg2/C2.java rename to pkgs/jni_gen/test/simple_package_test/java/com/github/dart_lang/jni_gen/pkg2/C2.java index 67f543ea8..2c999c59d 100644 --- a/pkgs/jni_gen/test/simple_package_test/java/dev/dart/pkg2/C2.java +++ b/pkgs/jni_gen/test/simple_package_test/java/com/github/dart_lang/jni_gen/pkg2/C2.java @@ -1,4 +1,4 @@ -package dev.dart.pkg2; +package com.github.dart_lang.jni_gen.pkg2; public class C2 { public static int CONSTANT = 12; diff --git a/pkgs/jni_gen/test/simple_package_test/java/dev/dart/simple_package/Example.java b/pkgs/jni_gen/test/simple_package_test/java/com/github/dart_lang/jni_gen/simple_package/Example.java similarity index 93% rename from pkgs/jni_gen/test/simple_package_test/java/dev/dart/simple_package/Example.java rename to pkgs/jni_gen/test/simple_package_test/java/com/github/dart_lang/jni_gen/simple_package/Example.java index 116deedbf..0133b8f9d 100644 --- a/pkgs/jni_gen/test/simple_package_test/java/dev/dart/simple_package/Example.java +++ b/pkgs/jni_gen/test/simple_package_test/java/com/github/dart_lang/jni_gen/simple_package/Example.java @@ -1,4 +1,4 @@ -package dev.dart.simple_package; +package com.github.dart_lang.jni_gen.simple_package; public class Example { public static final int ON = 1; diff --git a/pkgs/jni_gen/test/simple_package_test/lib/dev/dart/pkg2.dart b/pkgs/jni_gen/test/simple_package_test/lib/com/github/dart_lang/jni_gen/pkg2.dart similarity index 80% rename from pkgs/jni_gen/test/simple_package_test/lib/dev/dart/pkg2.dart rename to pkgs/jni_gen/test/simple_package_test/lib/com/github/dart_lang/jni_gen/pkg2.dart index 0fa32cd82..4f3bea46f 100644 --- a/pkgs/jni_gen/test/simple_package_test/lib/dev/dart/pkg2.dart +++ b/pkgs/jni_gen/test/simple_package_test/lib/com/github/dart_lang/jni_gen/pkg2.dart @@ -11,22 +11,22 @@ import "dart:ffi" as ffi; import "package:jni/jni.dart" as jni; -import "../../init.dart" show jlookup; +import "../../../../init.dart" show jlookup; -/// from: dev.dart.pkg2.C2 +/// from: com.github.dart_lang.jni_gen.pkg2.C2 class C2 extends jni.JlObject { C2.fromRef(ffi.Pointer ref) : super.fromRef(ref); static final _get_CONSTANT = jlookup>( - "get_dev_dart_pkg2_C2_CONSTANT") + "get_com_github_dart_lang_jni_gen_pkg2_C2_CONSTANT") .asFunction(); /// from: static public int CONSTANT static int get CONSTANT => _get_CONSTANT(); static final _set_CONSTANT = jlookup>( - "set_dev_dart_pkg2_C2_CONSTANT") + "set_com_github_dart_lang_jni_gen_pkg2_C2_CONSTANT") .asFunction(); /// from: static public int CONSTANT @@ -34,7 +34,7 @@ class C2 extends jni.JlObject { static final _ctor = jlookup Function()>>( - "dev_dart_pkg2_C2_ctor") + "com_github_dart_lang_jni_gen_pkg2_C2_ctor") .asFunction Function()>(); /// from: public void () diff --git a/pkgs/jni_gen/test/simple_package_test/lib/dev/dart/simple_package.dart b/pkgs/jni_gen/test/simple_package_test/lib/com/github/dart_lang/jni_gen/simple_package.dart similarity index 67% rename from pkgs/jni_gen/test/simple_package_test/lib/dev/dart/simple_package.dart rename to pkgs/jni_gen/test/simple_package_test/lib/com/github/dart_lang/jni_gen/simple_package.dart index 173c49304..370bad814 100644 --- a/pkgs/jni_gen/test/simple_package_test/lib/dev/dart/simple_package.dart +++ b/pkgs/jni_gen/test/simple_package_test/lib/com/github/dart_lang/jni_gen/simple_package.dart @@ -11,9 +11,9 @@ import "dart:ffi" as ffi; import "package:jni/jni.dart" as jni; -import "../../init.dart" show jlookup; +import "../../../../init.dart" show jlookup; -/// from: dev.dart.simple_package.Example +/// from: com.github.dart_lang.jni_gen.simple_package.Example class Example extends jni.JlObject { Example.fromRef(ffi.Pointer ref) : super.fromRef(ref); @@ -25,30 +25,30 @@ class Example extends jni.JlObject { static final _get_aux = jlookup Function()>>( - "get_dev_dart_simple_package_Example_aux") + "get_com_github_dart_lang_jni_gen_simple_package_Example_aux") .asFunction Function()>(); - /// from: static public dev.dart.simple_package.Example.Aux aux + /// from: static public com.github.dart_lang.jni_gen.simple_package.Example.Aux aux /// The returned object must be deleted after use, by calling the `delete` method. static Example_Aux get aux => Example_Aux.fromRef(_get_aux()); static final _set_aux = jlookup)>>( - "set_dev_dart_simple_package_Example_aux") + "set_com_github_dart_lang_jni_gen_simple_package_Example_aux") .asFunction)>(); - /// from: static public dev.dart.simple_package.Example.Aux aux + /// from: static public com.github.dart_lang.jni_gen.simple_package.Example.Aux aux /// The returned object must be deleted after use, by calling the `delete` method. static set aux(Example_Aux value) => _set_aux(value.reference); static final _get_num = jlookup>( - "get_dev_dart_simple_package_Example_num") + "get_com_github_dart_lang_jni_gen_simple_package_Example_num") .asFunction(); /// from: static public int num static int get num => _get_num(); static final _set_num = jlookup>( - "set_dev_dart_simple_package_Example_num") + "set_com_github_dart_lang_jni_gen_simple_package_Example_num") .asFunction(); /// from: static public int num @@ -56,7 +56,7 @@ class Example extends jni.JlObject { static final _ctor = jlookup Function()>>( - "dev_dart_simple_package_Example_ctor") + "com_github_dart_lang_jni_gen_simple_package_Example_ctor") .asFunction Function()>(); /// from: public void () @@ -64,16 +64,16 @@ class Example extends jni.JlObject { static final _getAux = jlookup Function()>>( - "dev_dart_simple_package_Example_getAux") + "com_github_dart_lang_jni_gen_simple_package_Example_getAux") .asFunction Function()>(); - /// from: static public dev.dart.simple_package.Example.Aux getAux() + /// from: static public com.github.dart_lang.jni_gen.simple_package.Example.Aux getAux() /// The returned object must be deleted after use, by calling the `delete` method. static Example_Aux getAux() => Example_Aux.fromRef(_getAux()); static final _addInts = jlookup>( - "dev_dart_simple_package_Example_addInts") + "com_github_dart_lang_jni_gen_simple_package_Example_addInts") .asFunction(); /// from: static public int addInts(int a, int b) @@ -82,32 +82,32 @@ class Example extends jni.JlObject { static final _getSelf = jlookup< ffi.NativeFunction< ffi.Pointer Function(ffi.Pointer)>>( - "dev_dart_simple_package_Example_getSelf") + "com_github_dart_lang_jni_gen_simple_package_Example_getSelf") .asFunction Function(ffi.Pointer)>(); - /// from: public dev.dart.simple_package.Example getSelf() + /// from: public com.github.dart_lang.jni_gen.simple_package.Example getSelf() /// The returned object must be deleted after use, by calling the `delete` method. Example getSelf() => Example.fromRef(_getSelf(reference)); static final _getNum = jlookup)>>( - "dev_dart_simple_package_Example_getNum") + "com_github_dart_lang_jni_gen_simple_package_Example_getNum") .asFunction)>(); /// from: public int getNum() int getNum() => _getNum(reference); static final _setNum = jlookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Int32)>>("dev_dart_simple_package_Example_setNum") + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Int32)>>( + "com_github_dart_lang_jni_gen_simple_package_Example_setNum") .asFunction, int)>(); /// from: public void setNum(int num) void setNum(int num) => _setNum(reference, num); } -/// from: dev.dart.simple_package.Example$Aux +/// from: com.github.dart_lang.jni_gen.simple_package.Example$Aux class Example_Aux extends jni.JlObject { Example_Aux.fromRef(ffi.Pointer ref) : super.fromRef(ref); @@ -115,7 +115,7 @@ class Example_Aux extends jni.JlObject { ffi.NativeFunction< ffi.Uint8 Function( ffi.Pointer, - )>>("get_dev_dart_simple_package_Example__Aux_value") + )>>("get_com_github_dart_lang_jni_gen_simple_package_Example__Aux_value") .asFunction< int Function( ffi.Pointer, @@ -124,9 +124,9 @@ class Example_Aux extends jni.JlObject { /// from: public boolean value bool get value => _get_value(reference) != 0; static final _set_value = jlookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Uint8)>>("set_dev_dart_simple_package_Example__Aux_value") + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Uint8)>>( + "set_com_github_dart_lang_jni_gen_simple_package_Example__Aux_value") .asFunction, int)>(); /// from: public boolean value @@ -134,24 +134,24 @@ class Example_Aux extends jni.JlObject { static final _ctor = jlookup Function(ffi.Uint8)>>( - "dev_dart_simple_package_Example__Aux_ctor") + "com_github_dart_lang_jni_gen_simple_package_Example__Aux_ctor") .asFunction Function(int)>(); /// from: public void (boolean value) Example_Aux(bool value) : super.fromRef(_ctor(value ? 1 : 0)); - static final _getValue = - jlookup)>>( - "dev_dart_simple_package_Example__Aux_getValue") - .asFunction)>(); + static final _getValue = jlookup< + ffi.NativeFunction)>>( + "com_github_dart_lang_jni_gen_simple_package_Example__Aux_getValue") + .asFunction)>(); /// from: public boolean getValue() bool getValue() => _getValue(reference) != 0; static final _setValue = jlookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Uint8)>>("dev_dart_simple_package_Example__Aux_setValue") + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Uint8)>>( + "com_github_dart_lang_jni_gen_simple_package_Example__Aux_setValue") .asFunction, int)>(); /// from: public void setValue(boolean value) diff --git a/pkgs/jni_gen/test/simple_package_test/src/simple_package.c b/pkgs/jni_gen/test/simple_package_test/src/simple_package.c index 4cc5e4296..b19daa69d 100644 --- a/pkgs/jni_gen/test/simple_package_test/src/simple_package.c +++ b/pkgs/jni_gen/test/simple_package_test/src/simple_package.c @@ -16,174 +16,174 @@ void setJniGetters(struct jni_context (*cg)(void), env_getter = eg; } -// dev.dart.simple_package.Example -jclass _c_dev_dart_simple_package_Example = NULL; +// com.github.dart_lang.jni_gen.simple_package.Example +jclass _c_com_github_dart_lang_jni_gen_simple_package_Example = NULL; -jmethodID _m_dev_dart_simple_package_Example_ctor = NULL; +jmethodID _m_com_github_dart_lang_jni_gen_simple_package_Example_ctor = NULL; FFI_PLUGIN_EXPORT -jobject dev_dart_simple_package_Example_ctor() { +jobject com_github_dart_lang_jni_gen_simple_package_Example_ctor() { load_env(); - load_class_gr(&_c_dev_dart_simple_package_Example, "dev/dart/simple_package/Example"); - load_method(_c_dev_dart_simple_package_Example, &_m_dev_dart_simple_package_Example_ctor, "", "()V"); - jobject _result = (*jniEnv)->NewObject(jniEnv, _c_dev_dart_simple_package_Example, _m_dev_dart_simple_package_Example_ctor); + load_class_gr(&_c_com_github_dart_lang_jni_gen_simple_package_Example, "com/github/dart_lang/jni_gen/simple_package/Example"); + load_method(_c_com_github_dart_lang_jni_gen_simple_package_Example, &_m_com_github_dart_lang_jni_gen_simple_package_Example_ctor, "", "()V"); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_com_github_dart_lang_jni_gen_simple_package_Example, _m_com_github_dart_lang_jni_gen_simple_package_Example_ctor); return to_global_ref(_result); } -jmethodID _m_dev_dart_simple_package_Example_getAux = NULL; +jmethodID _m_com_github_dart_lang_jni_gen_simple_package_Example_getAux = NULL; FFI_PLUGIN_EXPORT -jobject dev_dart_simple_package_Example_getAux() { +jobject com_github_dart_lang_jni_gen_simple_package_Example_getAux() { load_env(); - load_class_gr(&_c_dev_dart_simple_package_Example, "dev/dart/simple_package/Example"); - load_static_method(_c_dev_dart_simple_package_Example, &_m_dev_dart_simple_package_Example_getAux, "getAux", "()Ldev/dart/simple_package/Example$Aux;"); - jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_dev_dart_simple_package_Example, _m_dev_dart_simple_package_Example_getAux); + load_class_gr(&_c_com_github_dart_lang_jni_gen_simple_package_Example, "com/github/dart_lang/jni_gen/simple_package/Example"); + load_static_method(_c_com_github_dart_lang_jni_gen_simple_package_Example, &_m_com_github_dart_lang_jni_gen_simple_package_Example_getAux, "getAux", "()Lcom/github/dart_lang/jni_gen/simple_package/Example$Aux;"); + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_com_github_dart_lang_jni_gen_simple_package_Example, _m_com_github_dart_lang_jni_gen_simple_package_Example_getAux); return to_global_ref(_result); } -jmethodID _m_dev_dart_simple_package_Example_addInts = NULL; +jmethodID _m_com_github_dart_lang_jni_gen_simple_package_Example_addInts = NULL; FFI_PLUGIN_EXPORT -int32_t dev_dart_simple_package_Example_addInts(int32_t a, int32_t b) { +int32_t com_github_dart_lang_jni_gen_simple_package_Example_addInts(int32_t a, int32_t b) { load_env(); - load_class_gr(&_c_dev_dart_simple_package_Example, "dev/dart/simple_package/Example"); - load_static_method(_c_dev_dart_simple_package_Example, &_m_dev_dart_simple_package_Example_addInts, "addInts", "(II)I"); - int32_t _result = (*jniEnv)->CallStaticIntMethod(jniEnv, _c_dev_dart_simple_package_Example, _m_dev_dart_simple_package_Example_addInts, a, b); + load_class_gr(&_c_com_github_dart_lang_jni_gen_simple_package_Example, "com/github/dart_lang/jni_gen/simple_package/Example"); + load_static_method(_c_com_github_dart_lang_jni_gen_simple_package_Example, &_m_com_github_dart_lang_jni_gen_simple_package_Example_addInts, "addInts", "(II)I"); + int32_t _result = (*jniEnv)->CallStaticIntMethod(jniEnv, _c_com_github_dart_lang_jni_gen_simple_package_Example, _m_com_github_dart_lang_jni_gen_simple_package_Example_addInts, a, b); return _result; } -jmethodID _m_dev_dart_simple_package_Example_getSelf = NULL; +jmethodID _m_com_github_dart_lang_jni_gen_simple_package_Example_getSelf = NULL; FFI_PLUGIN_EXPORT -jobject dev_dart_simple_package_Example_getSelf(jobject self_) { +jobject com_github_dart_lang_jni_gen_simple_package_Example_getSelf(jobject self_) { load_env(); - load_class_gr(&_c_dev_dart_simple_package_Example, "dev/dart/simple_package/Example"); - load_method(_c_dev_dart_simple_package_Example, &_m_dev_dart_simple_package_Example_getSelf, "getSelf", "()Ldev/dart/simple_package/Example;"); - jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_dev_dart_simple_package_Example_getSelf); + load_class_gr(&_c_com_github_dart_lang_jni_gen_simple_package_Example, "com/github/dart_lang/jni_gen/simple_package/Example"); + load_method(_c_com_github_dart_lang_jni_gen_simple_package_Example, &_m_com_github_dart_lang_jni_gen_simple_package_Example_getSelf, "getSelf", "()Lcom/github/dart_lang/jni_gen/simple_package/Example;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_github_dart_lang_jni_gen_simple_package_Example_getSelf); return to_global_ref(_result); } -jmethodID _m_dev_dart_simple_package_Example_getNum = NULL; +jmethodID _m_com_github_dart_lang_jni_gen_simple_package_Example_getNum = NULL; FFI_PLUGIN_EXPORT -int32_t dev_dart_simple_package_Example_getNum(jobject self_) { +int32_t com_github_dart_lang_jni_gen_simple_package_Example_getNum(jobject self_) { load_env(); - load_class_gr(&_c_dev_dart_simple_package_Example, "dev/dart/simple_package/Example"); - load_method(_c_dev_dart_simple_package_Example, &_m_dev_dart_simple_package_Example_getNum, "getNum", "()I"); - int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_dev_dart_simple_package_Example_getNum); + load_class_gr(&_c_com_github_dart_lang_jni_gen_simple_package_Example, "com/github/dart_lang/jni_gen/simple_package/Example"); + load_method(_c_com_github_dart_lang_jni_gen_simple_package_Example, &_m_com_github_dart_lang_jni_gen_simple_package_Example_getNum, "getNum", "()I"); + int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_com_github_dart_lang_jni_gen_simple_package_Example_getNum); return _result; } -jmethodID _m_dev_dart_simple_package_Example_setNum = NULL; +jmethodID _m_com_github_dart_lang_jni_gen_simple_package_Example_setNum = NULL; FFI_PLUGIN_EXPORT -void dev_dart_simple_package_Example_setNum(jobject self_, int32_t num) { +void com_github_dart_lang_jni_gen_simple_package_Example_setNum(jobject self_, int32_t num) { load_env(); - load_class_gr(&_c_dev_dart_simple_package_Example, "dev/dart/simple_package/Example"); - load_method(_c_dev_dart_simple_package_Example, &_m_dev_dart_simple_package_Example_setNum, "setNum", "(I)V"); - (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_dev_dart_simple_package_Example_setNum, num); + load_class_gr(&_c_com_github_dart_lang_jni_gen_simple_package_Example, "com/github/dart_lang/jni_gen/simple_package/Example"); + load_method(_c_com_github_dart_lang_jni_gen_simple_package_Example, &_m_com_github_dart_lang_jni_gen_simple_package_Example_setNum, "setNum", "(I)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_com_github_dart_lang_jni_gen_simple_package_Example_setNum, num); } -jfieldID _f_dev_dart_simple_package_Example_aux = NULL; -jobject get_dev_dart_simple_package_Example_aux() { +jfieldID _f_com_github_dart_lang_jni_gen_simple_package_Example_aux = NULL; +jobject get_com_github_dart_lang_jni_gen_simple_package_Example_aux() { load_env(); - load_class_gr(&_c_dev_dart_simple_package_Example, "dev/dart/simple_package/Example"); - load_static_field(_c_dev_dart_simple_package_Example, &_f_dev_dart_simple_package_Example_aux, "aux","Ldev/dart/simple_package/Example$Aux;"); - return to_global_ref((*jniEnv)->GetStaticObjectField(jniEnv, _c_dev_dart_simple_package_Example, _f_dev_dart_simple_package_Example_aux)); + load_class_gr(&_c_com_github_dart_lang_jni_gen_simple_package_Example, "com/github/dart_lang/jni_gen/simple_package/Example"); + load_static_field(_c_com_github_dart_lang_jni_gen_simple_package_Example, &_f_com_github_dart_lang_jni_gen_simple_package_Example_aux, "aux","Lcom/github/dart_lang/jni_gen/simple_package/Example$Aux;"); + return to_global_ref((*jniEnv)->GetStaticObjectField(jniEnv, _c_com_github_dart_lang_jni_gen_simple_package_Example, _f_com_github_dart_lang_jni_gen_simple_package_Example_aux)); } -void set_dev_dart_simple_package_Example_aux(jobject value) { +void set_com_github_dart_lang_jni_gen_simple_package_Example_aux(jobject value) { load_env(); - load_class_gr(&_c_dev_dart_simple_package_Example, "dev/dart/simple_package/Example"); - load_static_field(_c_dev_dart_simple_package_Example, &_f_dev_dart_simple_package_Example_aux, "aux","Ldev/dart/simple_package/Example$Aux;"); - ((*jniEnv)->SetStaticObjectField(jniEnv, _c_dev_dart_simple_package_Example, _f_dev_dart_simple_package_Example_aux, value)); + load_class_gr(&_c_com_github_dart_lang_jni_gen_simple_package_Example, "com/github/dart_lang/jni_gen/simple_package/Example"); + load_static_field(_c_com_github_dart_lang_jni_gen_simple_package_Example, &_f_com_github_dart_lang_jni_gen_simple_package_Example_aux, "aux","Lcom/github/dart_lang/jni_gen/simple_package/Example$Aux;"); + ((*jniEnv)->SetStaticObjectField(jniEnv, _c_com_github_dart_lang_jni_gen_simple_package_Example, _f_com_github_dart_lang_jni_gen_simple_package_Example_aux, value)); } -jfieldID _f_dev_dart_simple_package_Example_num = NULL; -int32_t get_dev_dart_simple_package_Example_num() { +jfieldID _f_com_github_dart_lang_jni_gen_simple_package_Example_num = NULL; +int32_t get_com_github_dart_lang_jni_gen_simple_package_Example_num() { load_env(); - load_class_gr(&_c_dev_dart_simple_package_Example, "dev/dart/simple_package/Example"); - load_static_field(_c_dev_dart_simple_package_Example, &_f_dev_dart_simple_package_Example_num, "num","I"); - return ((*jniEnv)->GetStaticIntField(jniEnv, _c_dev_dart_simple_package_Example, _f_dev_dart_simple_package_Example_num)); + load_class_gr(&_c_com_github_dart_lang_jni_gen_simple_package_Example, "com/github/dart_lang/jni_gen/simple_package/Example"); + load_static_field(_c_com_github_dart_lang_jni_gen_simple_package_Example, &_f_com_github_dart_lang_jni_gen_simple_package_Example_num, "num","I"); + return ((*jniEnv)->GetStaticIntField(jniEnv, _c_com_github_dart_lang_jni_gen_simple_package_Example, _f_com_github_dart_lang_jni_gen_simple_package_Example_num)); } -void set_dev_dart_simple_package_Example_num(int32_t value) { +void set_com_github_dart_lang_jni_gen_simple_package_Example_num(int32_t value) { load_env(); - load_class_gr(&_c_dev_dart_simple_package_Example, "dev/dart/simple_package/Example"); - load_static_field(_c_dev_dart_simple_package_Example, &_f_dev_dart_simple_package_Example_num, "num","I"); - ((*jniEnv)->SetStaticIntField(jniEnv, _c_dev_dart_simple_package_Example, _f_dev_dart_simple_package_Example_num, value)); + load_class_gr(&_c_com_github_dart_lang_jni_gen_simple_package_Example, "com/github/dart_lang/jni_gen/simple_package/Example"); + load_static_field(_c_com_github_dart_lang_jni_gen_simple_package_Example, &_f_com_github_dart_lang_jni_gen_simple_package_Example_num, "num","I"); + ((*jniEnv)->SetStaticIntField(jniEnv, _c_com_github_dart_lang_jni_gen_simple_package_Example, _f_com_github_dart_lang_jni_gen_simple_package_Example_num, value)); } -// dev.dart.simple_package.Example$Aux -jclass _c_dev_dart_simple_package_Example__Aux = NULL; +// com.github.dart_lang.jni_gen.simple_package.Example$Aux +jclass _c_com_github_dart_lang_jni_gen_simple_package_Example__Aux = NULL; -jmethodID _m_dev_dart_simple_package_Example__Aux_ctor = NULL; +jmethodID _m_com_github_dart_lang_jni_gen_simple_package_Example__Aux_ctor = NULL; FFI_PLUGIN_EXPORT -jobject dev_dart_simple_package_Example__Aux_ctor(uint8_t value) { +jobject com_github_dart_lang_jni_gen_simple_package_Example__Aux_ctor(uint8_t value) { load_env(); - load_class_gr(&_c_dev_dart_simple_package_Example__Aux, "dev/dart/simple_package/Example$Aux"); - load_method(_c_dev_dart_simple_package_Example__Aux, &_m_dev_dart_simple_package_Example__Aux_ctor, "", "(Z)V"); - jobject _result = (*jniEnv)->NewObject(jniEnv, _c_dev_dart_simple_package_Example__Aux, _m_dev_dart_simple_package_Example__Aux_ctor, value); + load_class_gr(&_c_com_github_dart_lang_jni_gen_simple_package_Example__Aux, "com/github/dart_lang/jni_gen/simple_package/Example$Aux"); + load_method(_c_com_github_dart_lang_jni_gen_simple_package_Example__Aux, &_m_com_github_dart_lang_jni_gen_simple_package_Example__Aux_ctor, "", "(Z)V"); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_com_github_dart_lang_jni_gen_simple_package_Example__Aux, _m_com_github_dart_lang_jni_gen_simple_package_Example__Aux_ctor, value); return to_global_ref(_result); } -jmethodID _m_dev_dart_simple_package_Example__Aux_getValue = NULL; +jmethodID _m_com_github_dart_lang_jni_gen_simple_package_Example__Aux_getValue = NULL; FFI_PLUGIN_EXPORT -uint8_t dev_dart_simple_package_Example__Aux_getValue(jobject self_) { +uint8_t com_github_dart_lang_jni_gen_simple_package_Example__Aux_getValue(jobject self_) { load_env(); - load_class_gr(&_c_dev_dart_simple_package_Example__Aux, "dev/dart/simple_package/Example$Aux"); - load_method(_c_dev_dart_simple_package_Example__Aux, &_m_dev_dart_simple_package_Example__Aux_getValue, "getValue", "()Z"); - uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_dev_dart_simple_package_Example__Aux_getValue); + load_class_gr(&_c_com_github_dart_lang_jni_gen_simple_package_Example__Aux, "com/github/dart_lang/jni_gen/simple_package/Example$Aux"); + load_method(_c_com_github_dart_lang_jni_gen_simple_package_Example__Aux, &_m_com_github_dart_lang_jni_gen_simple_package_Example__Aux_getValue, "getValue", "()Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_github_dart_lang_jni_gen_simple_package_Example__Aux_getValue); return _result; } -jmethodID _m_dev_dart_simple_package_Example__Aux_setValue = NULL; +jmethodID _m_com_github_dart_lang_jni_gen_simple_package_Example__Aux_setValue = NULL; FFI_PLUGIN_EXPORT -void dev_dart_simple_package_Example__Aux_setValue(jobject self_, uint8_t value) { +void com_github_dart_lang_jni_gen_simple_package_Example__Aux_setValue(jobject self_, uint8_t value) { load_env(); - load_class_gr(&_c_dev_dart_simple_package_Example__Aux, "dev/dart/simple_package/Example$Aux"); - load_method(_c_dev_dart_simple_package_Example__Aux, &_m_dev_dart_simple_package_Example__Aux_setValue, "setValue", "(Z)V"); - (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_dev_dart_simple_package_Example__Aux_setValue, value); + load_class_gr(&_c_com_github_dart_lang_jni_gen_simple_package_Example__Aux, "com/github/dart_lang/jni_gen/simple_package/Example$Aux"); + load_method(_c_com_github_dart_lang_jni_gen_simple_package_Example__Aux, &_m_com_github_dart_lang_jni_gen_simple_package_Example__Aux_setValue, "setValue", "(Z)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_com_github_dart_lang_jni_gen_simple_package_Example__Aux_setValue, value); } -jfieldID _f_dev_dart_simple_package_Example__Aux_value = NULL; -uint8_t get_dev_dart_simple_package_Example__Aux_value(jobject self_) { +jfieldID _f_com_github_dart_lang_jni_gen_simple_package_Example__Aux_value = NULL; +uint8_t get_com_github_dart_lang_jni_gen_simple_package_Example__Aux_value(jobject self_) { load_env(); - load_class_gr(&_c_dev_dart_simple_package_Example__Aux, "dev/dart/simple_package/Example$Aux"); - load_field(_c_dev_dart_simple_package_Example__Aux, &_f_dev_dart_simple_package_Example__Aux_value, "value","Z"); - return ((*jniEnv)->GetBooleanField(jniEnv, self_, _f_dev_dart_simple_package_Example__Aux_value)); + load_class_gr(&_c_com_github_dart_lang_jni_gen_simple_package_Example__Aux, "com/github/dart_lang/jni_gen/simple_package/Example$Aux"); + load_field(_c_com_github_dart_lang_jni_gen_simple_package_Example__Aux, &_f_com_github_dart_lang_jni_gen_simple_package_Example__Aux_value, "value","Z"); + return ((*jniEnv)->GetBooleanField(jniEnv, self_, _f_com_github_dart_lang_jni_gen_simple_package_Example__Aux_value)); } -void set_dev_dart_simple_package_Example__Aux_value(jobject self_, uint8_t value) { +void set_com_github_dart_lang_jni_gen_simple_package_Example__Aux_value(jobject self_, uint8_t value) { load_env(); - load_class_gr(&_c_dev_dart_simple_package_Example__Aux, "dev/dart/simple_package/Example$Aux"); - load_field(_c_dev_dart_simple_package_Example__Aux, &_f_dev_dart_simple_package_Example__Aux_value, "value","Z"); - ((*jniEnv)->SetBooleanField(jniEnv, self_, _f_dev_dart_simple_package_Example__Aux_value, value)); + load_class_gr(&_c_com_github_dart_lang_jni_gen_simple_package_Example__Aux, "com/github/dart_lang/jni_gen/simple_package/Example$Aux"); + load_field(_c_com_github_dart_lang_jni_gen_simple_package_Example__Aux, &_f_com_github_dart_lang_jni_gen_simple_package_Example__Aux_value, "value","Z"); + ((*jniEnv)->SetBooleanField(jniEnv, self_, _f_com_github_dart_lang_jni_gen_simple_package_Example__Aux_value, value)); } -// dev.dart.pkg2.C2 -jclass _c_dev_dart_pkg2_C2 = NULL; +// com.github.dart_lang.jni_gen.pkg2.C2 +jclass _c_com_github_dart_lang_jni_gen_pkg2_C2 = NULL; -jmethodID _m_dev_dart_pkg2_C2_ctor = NULL; +jmethodID _m_com_github_dart_lang_jni_gen_pkg2_C2_ctor = NULL; FFI_PLUGIN_EXPORT -jobject dev_dart_pkg2_C2_ctor() { +jobject com_github_dart_lang_jni_gen_pkg2_C2_ctor() { load_env(); - load_class_gr(&_c_dev_dart_pkg2_C2, "dev/dart/pkg2/C2"); - load_method(_c_dev_dart_pkg2_C2, &_m_dev_dart_pkg2_C2_ctor, "", "()V"); - jobject _result = (*jniEnv)->NewObject(jniEnv, _c_dev_dart_pkg2_C2, _m_dev_dart_pkg2_C2_ctor); + load_class_gr(&_c_com_github_dart_lang_jni_gen_pkg2_C2, "com/github/dart_lang/jni_gen/pkg2/C2"); + load_method(_c_com_github_dart_lang_jni_gen_pkg2_C2, &_m_com_github_dart_lang_jni_gen_pkg2_C2_ctor, "", "()V"); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_com_github_dart_lang_jni_gen_pkg2_C2, _m_com_github_dart_lang_jni_gen_pkg2_C2_ctor); return to_global_ref(_result); } -jfieldID _f_dev_dart_pkg2_C2_CONSTANT = NULL; -int32_t get_dev_dart_pkg2_C2_CONSTANT() { +jfieldID _f_com_github_dart_lang_jni_gen_pkg2_C2_CONSTANT = NULL; +int32_t get_com_github_dart_lang_jni_gen_pkg2_C2_CONSTANT() { load_env(); - load_class_gr(&_c_dev_dart_pkg2_C2, "dev/dart/pkg2/C2"); - load_static_field(_c_dev_dart_pkg2_C2, &_f_dev_dart_pkg2_C2_CONSTANT, "CONSTANT","I"); - return ((*jniEnv)->GetStaticIntField(jniEnv, _c_dev_dart_pkg2_C2, _f_dev_dart_pkg2_C2_CONSTANT)); + load_class_gr(&_c_com_github_dart_lang_jni_gen_pkg2_C2, "com/github/dart_lang/jni_gen/pkg2/C2"); + load_static_field(_c_com_github_dart_lang_jni_gen_pkg2_C2, &_f_com_github_dart_lang_jni_gen_pkg2_C2_CONSTANT, "CONSTANT","I"); + return ((*jniEnv)->GetStaticIntField(jniEnv, _c_com_github_dart_lang_jni_gen_pkg2_C2, _f_com_github_dart_lang_jni_gen_pkg2_C2_CONSTANT)); } -void set_dev_dart_pkg2_C2_CONSTANT(int32_t value) { +void set_com_github_dart_lang_jni_gen_pkg2_C2_CONSTANT(int32_t value) { load_env(); - load_class_gr(&_c_dev_dart_pkg2_C2, "dev/dart/pkg2/C2"); - load_static_field(_c_dev_dart_pkg2_C2, &_f_dev_dart_pkg2_C2_CONSTANT, "CONSTANT","I"); - ((*jniEnv)->SetStaticIntField(jniEnv, _c_dev_dart_pkg2_C2, _f_dev_dart_pkg2_C2_CONSTANT, value)); + load_class_gr(&_c_com_github_dart_lang_jni_gen_pkg2_C2, "com/github/dart_lang/jni_gen/pkg2/C2"); + load_static_field(_c_com_github_dart_lang_jni_gen_pkg2_C2, &_f_com_github_dart_lang_jni_gen_pkg2_C2_CONSTANT, "CONSTANT","I"); + ((*jniEnv)->SetStaticIntField(jniEnv, _c_com_github_dart_lang_jni_gen_pkg2_C2, _f_com_github_dart_lang_jni_gen_pkg2_C2_CONSTANT, value)); } From ef4a9f83b820c471b0eb71a85c05a81df8037cf6 Mon Sep 17 00:00:00 2001 From: Mahesh Hegde <46179734+mahesh-hegde@users.noreply.github.com> Date: Fri, 2 Sep 2022 19:51:30 +0530 Subject: [PATCH 011/139] [jnigen] Jni_gen Examples (https://github.com/dart-lang/jnigen/issues/36) --- .github/workflows/test-package.yml | 83 +- pkgs/jni/example/pubspec.lock | 41 +- pkgs/jni/example/test/widget_test.dart | 3 + pkgs/jni_gen/README.md | 3 +- pkgs/jni_gen/analysis_options.yaml | 2 +- pkgs/jni_gen/bin/download_maven_jars.dart | 29 + pkgs/jni_gen/cmake/CMakeLists.txt.tmpl | 2 +- pkgs/jni_gen/examples/README.md | 11 + pkgs/jni_gen/examples/in_app_java/.gitignore | 50 + pkgs/jni_gen/examples/in_app_java/.metadata | 30 + pkgs/jni_gen/examples/in_app_java/README.md | 24 + .../in_app_java/analysis_options.yaml | 29 + .../examples/in_app_java/android/.gitignore | 13 + .../in_app_java/android/app/build.gradle | 77 + .../android/app/src/debug/AndroidManifest.xml | 8 + .../android/app/src/main/AndroidManifest.xml | 34 + .../com/example/in_app_java/AndroidUtils.java | 12 + .../com/example/in_app_java/MainActivity.kt | 6 + .../res/drawable-v21/launch_background.xml | 12 + .../main/res/drawable/launch_background.xml | 12 + .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 544 bytes .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 442 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 721 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 1031 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 1443 bytes .../app/src/main/res/values-night/styles.xml | 18 + .../app/src/main/res/values/styles.xml | 18 + .../app/src/profile/AndroidManifest.xml | 8 + .../examples/in_app_java/android/build.gradle | 33 + .../in_app_java/android/gradle.properties | 3 + .../gradle/wrapper/gradle-wrapper.properties | 6 + .../in_app_java/android/settings.gradle | 11 + pkgs/jni_gen/examples/in_app_java/jnigen.yaml | 11 + .../com/example/in_app_java.dart | 39 + .../in_app_java/lib/android_utils/init.dart | 5 + .../examples/in_app_java/lib/main.dart | 60 + .../jni_gen/examples/in_app_java/pubspec.yaml | 67 + .../src/android_utils/CMakeLists.txt | 30 + .../src/android_utils/android_utils.c | 40 + .../in_app_java/src/android_utils/dartjni.h | 177 ++ .../in_app_java/test/widget_test.dart | 30 + .../in_app_java/tool/generate_bindings.dart | 15 + .../jni_gen/examples/pdfbox_plugin/.gitignore | 37 + pkgs/jni_gen/examples/pdfbox_plugin/.metadata | 36 + pkgs/jni_gen/examples/pdfbox_plugin/README.md | 8 + .../pdfbox_plugin/analysis_options.yaml | 4 + .../examples/pdfbox_plugin/android/.gitignore | 9 + .../pdfbox_plugin/android/build.gradle | 59 + .../pdfbox_plugin/android/settings.gradle | 1 + .../android/src/main/AndroidManifest.xml | 3 + .../pdfbox_plugin/dart_example/.gitignore | 12 + .../pdfbox_plugin/dart_example/CHANGELOG.md | 3 + .../pdfbox_plugin/dart_example/README.md | 10 + .../dart_example/analysis_options.yaml | 30 + .../dart_example/bin/pdf_info.dart | 72 + .../pdfbox_plugin/dart_example/pubspec.yaml | 19 + .../examples/pdfbox_plugin/example/.gitignore | 47 + .../examples/pdfbox_plugin/example/README.md | 18 + .../example/analysis_options.yaml | 29 + .../pdfbox_plugin/example/android/.gitignore | 13 + .../example/android/app/build.gradle | 71 + .../android/app/src/debug/AndroidManifest.xml | 8 + .../android/app/src/main/AndroidManifest.xml | 34 + .../pdfbox_plugin_example/MainActivity.kt | 6 + .../res/drawable-v21/launch_background.xml | 12 + .../main/res/drawable/launch_background.xml | 12 + .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 544 bytes .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 442 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 721 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 1031 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 1443 bytes .../app/src/main/res/values-night/styles.xml | 18 + .../app/src/main/res/values/styles.xml | 18 + .../app/src/profile/AndroidManifest.xml | 8 + .../example/android/build.gradle | 31 + .../example/android/gradle.properties | 3 + .../gradle/wrapper/gradle-wrapper.properties | 6 + .../example/android/settings.gradle | 11 + .../pdfbox_plugin/example/lib/main.dart | 212 ++ .../pdfbox_plugin/example/linux/.gitignore | 1 + .../example/linux/CMakeLists.txt | 138 + .../example/linux/flutter/CMakeLists.txt | 88 + .../flutter/generated_plugin_registrant.cc | 11 + .../flutter/generated_plugin_registrant.h | 15 + .../linux/flutter/generated_plugins.cmake | 25 + .../pdfbox_plugin/example/linux/main.cc | 6 + .../example/linux/my_application.cc | 104 + .../example/linux/my_application.h | 18 + .../pdfbox_plugin/example/pubspec.yaml | 99 + .../pdfbox_plugin/example/windows/.gitignore | 17 + .../example/windows/CMakeLists.txt | 101 + .../example/windows/flutter/CMakeLists.txt | 104 + .../flutter/generated_plugin_registrant.cc | 11 + .../flutter/generated_plugin_registrant.h | 15 + .../windows/flutter/generated_plugins.cmake | 25 + .../example/windows/runner/CMakeLists.txt | 32 + .../example/windows/runner/Runner.rc | 121 + .../example/windows/runner/flutter_window.cpp | 61 + .../example/windows/runner/flutter_window.h | 33 + .../example/windows/runner/main.cpp | 43 + .../example/windows/runner/resource.h | 16 + .../windows/runner/resources/app_icon.ico | Bin 0 -> 33772 bytes .../windows/runner/runner.exe.manifest | 20 + .../example/windows/runner/utils.cpp | 64 + .../example/windows/runner/utils.h | 19 + .../example/windows/runner/win32_window.cpp | 245 ++ .../example/windows/runner/win32_window.h | 98 + .../examples/pdfbox_plugin/jnigen.yaml | 64 + .../examples/pdfbox_plugin/jnigen_full.yaml | 63 + .../pdfbox_plugin/lib/third_party/init.dart | 5 + .../org/apache/pdfbox/pdmodel.dart | 2196 ++++++++++++++ .../third_party/org/apache/pdfbox/text.dart | 2223 ++++++++++++++ .../pdfbox_plugin/linux/CMakeLists.txt | 22 + .../examples/pdfbox_plugin/pubspec.yaml | 38 + .../examples/pdfbox_plugin/src/CMakeLists.txt | 30 + .../pdfbox_plugin/src/third_party/dartjni.h | 177 ++ .../src/third_party/pdfbox_plugin.c | 2548 +++++++++++++++++ .../pdfbox_plugin/tool/generate_bindings.dart | 38 + .../examples/pdfbox_plugin/windows/.gitignore | 17 + .../pdfbox_plugin/windows/CMakeLists.txt | 23 + .../lib/src/bindings/dart_bindings.dart | 6 +- .../lib/src/bindings/symbol_resolver.dart | 21 +- pkgs/jni_gen/lib/src/config/config.dart | 49 +- pkgs/jni_gen/lib/src/config/yaml_reader.dart | 2 +- pkgs/jni_gen/lib/src/generate_bindings.dart | 11 +- .../lib/src/tools/android_sdk_tools.dart | 47 + pkgs/jni_gen/lib/src/writers/writers.dart | 13 +- pkgs/jni_gen/test/bindings_test.dart | 6 + .../third_party/src/CMakeLists.txt | 2 +- .../simple_package_test/src/CMakeLists.txt | 2 +- 130 files changed, 10986 insertions(+), 59 deletions(-) create mode 100644 pkgs/jni_gen/bin/download_maven_jars.dart create mode 100644 pkgs/jni_gen/examples/README.md create mode 100644 pkgs/jni_gen/examples/in_app_java/.gitignore create mode 100644 pkgs/jni_gen/examples/in_app_java/.metadata create mode 100644 pkgs/jni_gen/examples/in_app_java/README.md create mode 100644 pkgs/jni_gen/examples/in_app_java/analysis_options.yaml create mode 100644 pkgs/jni_gen/examples/in_app_java/android/.gitignore create mode 100644 pkgs/jni_gen/examples/in_app_java/android/app/build.gradle create mode 100644 pkgs/jni_gen/examples/in_app_java/android/app/src/debug/AndroidManifest.xml create mode 100644 pkgs/jni_gen/examples/in_app_java/android/app/src/main/AndroidManifest.xml create mode 100644 pkgs/jni_gen/examples/in_app_java/android/app/src/main/java/com/example/in_app_java/AndroidUtils.java create mode 100644 pkgs/jni_gen/examples/in_app_java/android/app/src/main/kotlin/com/example/in_app_java/MainActivity.kt create mode 100644 pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/drawable-v21/launch_background.xml create mode 100644 pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/drawable/launch_background.xml create mode 100644 pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/values-night/styles.xml create mode 100644 pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/values/styles.xml create mode 100644 pkgs/jni_gen/examples/in_app_java/android/app/src/profile/AndroidManifest.xml create mode 100644 pkgs/jni_gen/examples/in_app_java/android/build.gradle create mode 100644 pkgs/jni_gen/examples/in_app_java/android/gradle.properties create mode 100644 pkgs/jni_gen/examples/in_app_java/android/gradle/wrapper/gradle-wrapper.properties create mode 100644 pkgs/jni_gen/examples/in_app_java/android/settings.gradle create mode 100644 pkgs/jni_gen/examples/in_app_java/jnigen.yaml create mode 100644 pkgs/jni_gen/examples/in_app_java/lib/android_utils/com/example/in_app_java.dart create mode 100644 pkgs/jni_gen/examples/in_app_java/lib/android_utils/init.dart create mode 100644 pkgs/jni_gen/examples/in_app_java/lib/main.dart create mode 100644 pkgs/jni_gen/examples/in_app_java/pubspec.yaml create mode 100644 pkgs/jni_gen/examples/in_app_java/src/android_utils/CMakeLists.txt create mode 100644 pkgs/jni_gen/examples/in_app_java/src/android_utils/android_utils.c create mode 100644 pkgs/jni_gen/examples/in_app_java/src/android_utils/dartjni.h create mode 100644 pkgs/jni_gen/examples/in_app_java/test/widget_test.dart create mode 100644 pkgs/jni_gen/examples/in_app_java/tool/generate_bindings.dart create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/.gitignore create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/.metadata create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/README.md create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/analysis_options.yaml create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/android/.gitignore create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/android/build.gradle create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/android/settings.gradle create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/android/src/main/AndroidManifest.xml create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/dart_example/.gitignore create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/dart_example/CHANGELOG.md create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/dart_example/README.md create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/dart_example/analysis_options.yaml create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/dart_example/bin/pdf_info.dart create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/dart_example/pubspec.yaml create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/.gitignore create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/README.md create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/analysis_options.yaml create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/android/.gitignore create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/build.gradle create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/debug/AndroidManifest.xml create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/AndroidManifest.xml create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/kotlin/com/example/pdfbox_plugin_example/MainActivity.kt create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/drawable-v21/launch_background.xml create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/drawable/launch_background.xml create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/values-night/styles.xml create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/values/styles.xml create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/profile/AndroidManifest.xml create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/android/build.gradle create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/android/gradle.properties create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/android/gradle/wrapper/gradle-wrapper.properties create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/android/settings.gradle create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/lib/main.dart create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/linux/.gitignore create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/linux/CMakeLists.txt create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/linux/flutter/CMakeLists.txt create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/linux/flutter/generated_plugin_registrant.cc create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/linux/flutter/generated_plugin_registrant.h create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/linux/flutter/generated_plugins.cmake create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/linux/main.cc create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/linux/my_application.cc create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/linux/my_application.h create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/pubspec.yaml create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/windows/.gitignore create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/windows/CMakeLists.txt create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/windows/flutter/CMakeLists.txt create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/windows/flutter/generated_plugin_registrant.cc create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/windows/flutter/generated_plugin_registrant.h create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/windows/flutter/generated_plugins.cmake create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/CMakeLists.txt create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/Runner.rc create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/flutter_window.cpp create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/flutter_window.h create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/main.cpp create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/resource.h create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/resources/app_icon.ico create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/runner.exe.manifest create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/utils.cpp create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/utils.h create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/win32_window.cpp create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/win32_window.h create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/jnigen.yaml create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/jnigen_full.yaml create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/lib/third_party/init.dart create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/lib/third_party/org/apache/pdfbox/pdmodel.dart create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/lib/third_party/org/apache/pdfbox/text.dart create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/linux/CMakeLists.txt create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/pubspec.yaml create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/src/CMakeLists.txt create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/src/third_party/dartjni.h create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/src/third_party/pdfbox_plugin.c create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/tool/generate_bindings.dart create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/windows/.gitignore create mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/windows/CMakeLists.txt diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index f35e0bb78..0b4123f5f 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -117,6 +117,8 @@ jobs: - uses: subosito/flutter-action@v2 with: channel: 'stable' + cache: true + cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - uses: actions/setup-java@v2 with: distribution: 'zulu' @@ -157,6 +159,8 @@ jobs: - uses: subosito/flutter-action@v2 with: channel: 'stable' + cache: true + cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - uses: actions/setup-java@v2 with: distribution: 'zulu' @@ -167,7 +171,6 @@ jobs: - run: flutter config --enable-linux-desktop - run: flutter pub get - run: dart run jni:setup - - run: flutter test - run: flutter build linux build_jni_example_windows: @@ -180,6 +183,8 @@ jobs: - uses: subosito/flutter-action@v2 with: channel: 'stable' + cache: true + cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - uses: actions/setup-java@v2 with: distribution: 'zulu' @@ -202,9 +207,36 @@ jobs: - uses: subosito/flutter-action@v2 with: channel: 'stable' + cache: true + cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - run: flutter pub get - run: flutter build apk - - run: flutter build appbundle + + build_in_app_java_example: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./pkgs/jni_gen/examples/in_app_java + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v2 + with: + distribution: 'zulu' + java-version: '11' + - uses: subosito/flutter-action@v2 + with: + channel: 'stable' + cache: true + cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' + - run: flutter pub get + - run: flutter analyze + - run: flutter build apk + - name: re-generate bindings + run: flutter pub run jni_gen -Ddart_root=_dart -Dc_root=_c --config jnigen.yaml + - name: compare generated dart bindings + run: diff -qr lib/android_utils _dart + - name: compare generated C bindings + run: diff -qr src/android_utils _c coveralls_finish: needs: [test_jni_gen, test_jni] @@ -216,3 +248,50 @@ jobs: github-token: ${{ secrets.github_token }} parallel-finished: true + run_pdfbox_example_linux: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./pkgs/jni_gen/examples/pdfbox_plugin + steps: + - uses: actions/checkout@v3 + - uses: subosito/flutter-action@v2 + with: + channel: 'stable' + cache: true + cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' + - uses: actions/setup-java@v2 + with: + distribution: 'zulu' + java-version: '11' + - run: | + sudo apt-get update -y + sudo apt-get install -y ninja-build libgtk-3-dev + - run: flutter config --enable-linux-desktop + - run: dart pub get + - name: Generate bindings + run: | + dart run jni_gen -Dc_root=_c -Ddart_root=_dart --config jnigen.yaml + - name: Compare generated bindings + run: | + diff -qr _c src/ + diff -qr _dart lib/third_party + - name: Generate full bindings + run: dart run jni_gen --config jnigen_full.yaml + - name: Analyze generated bindings + run: | + flutter pub get # dart-analyze errors on flutter example + flutter analyze + - name: Run standalone example + run: | + dart pub get + dart run jni:setup && dart run jni:setup -p pdfbox_plugin + wget 'https://dart.dev/guides/language/specifications/DartLangSpec-v2.2.pdf' + dart run bin/pdf_info.dart DartLangSpec-v2.2.pdf + working-directory: ./pkgs/jni_gen/examples/pdfbox_plugin/dart_example + - name: Build flutter example for pdfbox_plugin + run: | + flutter pub get + flutter build linux + working-directory: ./pkgs/jni_gen/examples/pdfbox_plugin/example + diff --git a/pkgs/jni/example/pubspec.lock b/pkgs/jni/example/pubspec.lock index 2f0d348e5..43745f045 100644 --- a/pkgs/jni/example/pubspec.lock +++ b/pkgs/jni/example/pubspec.lock @@ -7,7 +7,7 @@ packages: name: archive url: "https://pub.dartlang.org" source: hosted - version: "3.1.11" + version: "3.3.0" args: dependency: transitive description: @@ -21,7 +21,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.8.2" + version: "2.9.0" boolean_selector: dependency: transitive description: @@ -35,21 +35,14 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" + version: "1.2.1" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: @@ -63,7 +56,7 @@ packages: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "3.0.1" + version: "3.0.2" cupertino_icons: dependency: "direct main" description: @@ -77,7 +70,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.3.1" ffi: dependency: "direct main" description: @@ -144,21 +137,21 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.11" + version: "0.12.12" material_color_utilities: dependency: transitive description: name: material_color_utilities url: "https://pub.dartlang.org" source: hosted - version: "0.1.4" + version: "0.1.5" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0" package_config: dependency: transitive description: @@ -172,7 +165,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" platform: dependency: transitive description: @@ -205,7 +198,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.2" + version: "1.9.0" stack_trace: dependency: transitive description: @@ -226,35 +219,35 @@ packages: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" sync_http: dependency: transitive description: name: sync_http url: "https://pub.dartlang.org" source: hosted - version: "0.3.0" + version: "0.3.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.9" + version: "0.4.12" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.3.1" vector_math: dependency: transitive description: @@ -268,7 +261,7 @@ packages: name: vm_service url: "https://pub.dartlang.org" source: hosted - version: "8.2.2" + version: "9.0.0" webdriver: dependency: transitive description: diff --git a/pkgs/jni/example/test/widget_test.dart b/pkgs/jni/example/test/widget_test.dart index ec585ec4b..def4482b9 100644 --- a/pkgs/jni/example/test/widget_test.dart +++ b/pkgs/jni/example/test/widget_test.dart @@ -11,6 +11,9 @@ import 'package:jni/jni.dart'; import 'package:jni/jni_object.dart'; import 'package:jni_example/main.dart'; +// TODO(#38): This test is skipped because it broke for unknown reason in +// in flutter 3.3.0 + // This test exists just to verify that // when everything is correct, JNI actually runs // However it's also kind of meaningless, because test environment diff --git a/pkgs/jni_gen/README.md b/pkgs/jni_gen/README.md index 1ae735d3e..1ba01931c 100644 --- a/pkgs/jni_gen/README.md +++ b/pkgs/jni_gen/README.md @@ -28,4 +28,5 @@ The following properties must be specified in yaml. The generated C file has to be linked to JNI libraries. Therefore a CMake configuration is always generated which builds the generated code as shared library. The `init.dart` in generated dart code loads the library on first time a method is accessed. On dart standalone, it will be loaded from the same directory specified in `Jni.spawn` call. ## Examples -See [jackson_core_test](test/jackson_core_test) folder for an example how bindings are generated. Runnable examples will be added soon. +Few runnable examples are provided in [examples/](examples/) directory. These directories do not include generated code. Generate the bindings by running `dart run jni_gen --config jnigen.yaml` in the example project root. See the respective READMEs for more details. + diff --git a/pkgs/jni_gen/analysis_options.yaml b/pkgs/jni_gen/analysis_options.yaml index 3fa121aee..e714a827b 100644 --- a/pkgs/jni_gen/analysis_options.yaml +++ b/pkgs/jni_gen/analysis_options.yaml @@ -5,7 +5,7 @@ include: package:lints/recommended.yaml analyzer: - exclude: [build/**] + exclude: [build/**, examples/**] language: strict-raw-types: true strict-inference: true diff --git a/pkgs/jni_gen/bin/download_maven_jars.dart b/pkgs/jni_gen/bin/download_maven_jars.dart new file mode 100644 index 000000000..a4ada5bdc --- /dev/null +++ b/pkgs/jni_gen/bin/download_maven_jars.dart @@ -0,0 +1,29 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +import 'dart:io'; + +import 'package:jni_gen/jni_gen.dart'; +import 'package:jni_gen/tools.dart'; + +/// Downloads maven dependencies downloaded by equivalent jni_gen invocation. +/// +/// Useful for running standalone examples on already generated sources. +void main(List args) async { + final config = Config.parseArgs(args); + final mavenDownloads = config.mavenDownloads; + if (mavenDownloads != null) { + await MavenTools.downloadMavenJars( + MavenTools.deps(mavenDownloads.jarOnlyDeps + mavenDownloads.sourceDeps), + mavenDownloads.jarDir); + await Directory(mavenDownloads.jarDir) + .list() + .map((entry) => entry.path) + .where((path) => path.endsWith('.jar')) + .forEach(stdout.writeln); + } else { + stderr.writeln('No maven dependencies found in config.'); + exitCode = 2; + } +} diff --git a/pkgs/jni_gen/cmake/CMakeLists.txt.tmpl b/pkgs/jni_gen/cmake/CMakeLists.txt.tmpl index 21d0d807e..cf7b53d02 100644 --- a/pkgs/jni_gen/cmake/CMakeLists.txt.tmpl +++ b/pkgs/jni_gen/cmake/CMakeLists.txt.tmpl @@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.10) project({{LIBRARY_NAME}} VERSION 0.0.1 LANGUAGES C) add_library({{LIBRARY_NAME}} SHARED - "{{LIBRARY_NAME}}.c" + "{{SUBDIR}}/{{LIBRARY_NAME}}.c" ) set_target_properties({{LIBRARY_NAME}} PROPERTIES diff --git a/pkgs/jni_gen/examples/README.md b/pkgs/jni_gen/examples/README.md new file mode 100644 index 000000000..11e3fc01d --- /dev/null +++ b/pkgs/jni_gen/examples/README.md @@ -0,0 +1,11 @@ +## jni_gen examples + +This directory contains examples on how to use jni_gen. + +| Directory | Description | +| ------- | --------- | +| [in_app_java](in_app_java/) | Demonstrates how to include custom Java code in Flutter application and call that using jni_gen | +| [pdfbox_plugin](pdfbox_plugin/) | Example of a flutter plugin which provides bindings to Apache PDFBox library. Currently works on Flutter desktop and Dart standalone on linux. | + +We intend to cover few more use cases in future. + diff --git a/pkgs/jni_gen/examples/in_app_java/.gitignore b/pkgs/jni_gen/examples/in_app_java/.gitignore new file mode 100644 index 000000000..8c640484a --- /dev/null +++ b/pkgs/jni_gen/examples/in_app_java/.gitignore @@ -0,0 +1,50 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ +/build/ + +# Web related +lib/generated_plugin_registrant.dart + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release + +## Generated by build process +android/app/.cxx diff --git a/pkgs/jni_gen/examples/in_app_java/.metadata b/pkgs/jni_gen/examples/in_app_java/.metadata new file mode 100644 index 000000000..2544bab1f --- /dev/null +++ b/pkgs/jni_gen/examples/in_app_java/.metadata @@ -0,0 +1,30 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled. + +version: + revision: f1875d570e39de09040c8f79aa13cc56baab8db1 + channel: stable + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 + base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 + - platform: android + create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 + base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/pkgs/jni_gen/examples/in_app_java/README.md b/pkgs/jni_gen/examples/in_app_java/README.md new file mode 100644 index 000000000..f910deba1 --- /dev/null +++ b/pkgs/jni_gen/examples/in_app_java/README.md @@ -0,0 +1,24 @@ +# In-App Java Example + +This example shows how to write custom java code in `android/app/src` and call it using `jni_gen` generated bindings. + +#### How to run this example: +* Run `flutter run` to run the app. + +* To regenerate bindings after changing Java code, run `flutter pub run jni_gen --config jnigen.yaml`. This requires at least one APK build to have been run before, so that it's possible for `jni_gen` to obtain classpaths of Android Gradle libraries. Therefore, once run `flutter build apk` before generating bindings for the first time, or after a `flutter clean`. + +#### General steps +These are general steps to integrate Java code into a flutter project using `jni_gen`. + +* Write Java code in suitable package folder, under `android/` subproject of the flutter app. + +* Create A jnigen config like `jnigen.yaml` in this example. + +* Generate bindings using jnigen config. + +* Add an `externalNativeBuild` to gradle script (see `android/app/build.gradle` in this example). + +* Add proguard rules to exclude your custom classes from tree shaking, since they are always accessed reflectively in JNI. + +* Build and run the app. + diff --git a/pkgs/jni_gen/examples/in_app_java/analysis_options.yaml b/pkgs/jni_gen/examples/in_app_java/analysis_options.yaml new file mode 100644 index 000000000..61b6c4de1 --- /dev/null +++ b/pkgs/jni_gen/examples/in_app_java/analysis_options.yaml @@ -0,0 +1,29 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at + # https://dart-lang.github.io/linter/lints/index.html. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/pkgs/jni_gen/examples/in_app_java/android/.gitignore b/pkgs/jni_gen/examples/in_app_java/android/.gitignore new file mode 100644 index 000000000..6f568019d --- /dev/null +++ b/pkgs/jni_gen/examples/in_app_java/android/.gitignore @@ -0,0 +1,13 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +key.properties +**/*.keystore +**/*.jks diff --git a/pkgs/jni_gen/examples/in_app_java/android/app/build.gradle b/pkgs/jni_gen/examples/in_app_java/android/app/build.gradle new file mode 100644 index 000000000..784c65997 --- /dev/null +++ b/pkgs/jni_gen/examples/in_app_java/android/app/build.gradle @@ -0,0 +1,77 @@ +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterRoot = localProperties.getProperty('flutter.sdk') +if (flutterRoot == null) { + throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" + +android { + compileSdkVersion flutter.compileSdkVersion + ndkVersion flutter.ndkVersion + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId "com.example.in_app_java" + // You can update the following values to match your application needs. + // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. + minSdkVersion flutter.minSdkVersion + targetSdkVersion flutter.targetSdkVersion + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.debug + } + } + +externalNativeBuild { + cmake { + path "../../src/android_utils/CMakeLists.txt" + } + } +} + +flutter { + source '../..' +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" +} diff --git a/pkgs/jni_gen/examples/in_app_java/android/app/src/debug/AndroidManifest.xml b/pkgs/jni_gen/examples/in_app_java/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 000000000..a09603034 --- /dev/null +++ b/pkgs/jni_gen/examples/in_app_java/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,8 @@ + + + + diff --git a/pkgs/jni_gen/examples/in_app_java/android/app/src/main/AndroidManifest.xml b/pkgs/jni_gen/examples/in_app_java/android/app/src/main/AndroidManifest.xml new file mode 100644 index 000000000..e674e57c3 --- /dev/null +++ b/pkgs/jni_gen/examples/in_app_java/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/pkgs/jni_gen/examples/in_app_java/android/app/src/main/java/com/example/in_app_java/AndroidUtils.java b/pkgs/jni_gen/examples/in_app_java/android/app/src/main/java/com/example/in_app_java/AndroidUtils.java new file mode 100644 index 000000000..4c297bf3a --- /dev/null +++ b/pkgs/jni_gen/examples/in_app_java/android/app/src/main/java/com/example/in_app_java/AndroidUtils.java @@ -0,0 +1,12 @@ +package com.example.in_app_java; + +import android.app.Activity; +import android.widget.Toast; +import androidx.annotation.Keep; + +@Keep +public class AndroidUtils { + static void showToast(Activity mainActivity, CharSequence text, int duration) { + mainActivity.runOnUiThread(() -> Toast.makeText(mainActivity, text, duration).show()); + } +} diff --git a/pkgs/jni_gen/examples/in_app_java/android/app/src/main/kotlin/com/example/in_app_java/MainActivity.kt b/pkgs/jni_gen/examples/in_app_java/android/app/src/main/kotlin/com/example/in_app_java/MainActivity.kt new file mode 100644 index 000000000..c8fde0cc8 --- /dev/null +++ b/pkgs/jni_gen/examples/in_app_java/android/app/src/main/kotlin/com/example/in_app_java/MainActivity.kt @@ -0,0 +1,6 @@ +package com.example.in_app_java + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() { +} diff --git a/pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/drawable-v21/launch_background.xml b/pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 000000000..f74085f3f --- /dev/null +++ b/pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/drawable/launch_background.xml b/pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 000000000..304732f88 --- /dev/null +++ b/pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..db77bb4b7b0906d62b1847e87f15cdcacf6a4f29 GIT binary patch literal 544 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY3?!3`olAj~WQl7;NpOBzNqJ&XDuZK6ep0G} zXKrG8YEWuoN@d~6R2!h8bpbvhu0Wd6uZuB!w&u2PAxD2eNXD>P5D~Wn-+_Wa#27Xc zC?Zj|6r#X(-D3u$NCt}(Ms06KgJ4FxJVv{GM)!I~&n8Bnc94O7-Hd)cjDZswgC;Qs zO=b+9!WcT8F?0rF7!Uys2bs@gozCP?z~o%U|N3vA*22NaGQG zlg@K`O_XuxvZ&Ks^m&R!`&1=spLvfx7oGDKDwpwW`#iqdw@AL`7MR}m`rwr|mZgU`8P7SBkL78fFf!WnuYWm$5Z0 zNXhDbCv&49sM544K|?c)WrFfiZvCi9h0O)B3Pgg&ebxsLQ05GG~ AQ2+n{ literal 0 HcmV?d00001 diff --git a/pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..17987b79bb8a35cc66c3c1fd44f5a5526c1b78be GIT binary patch literal 442 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA3?vioaBc-sk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5Xx&nMcT!A!W`0S9QKQy;}1Cl^CgaH=;G9cpY;r$Q>i*pfB zP2drbID<_#qf;rPZx^FqH)F_D#*k@@q03KywUtLX8Ua?`H+NMzkczFPK3lFz@i_kW%1NOn0|D2I9n9wzH8m|-tHjsw|9>@K=iMBhxvkv6m8Y-l zytQ?X=U+MF$@3 zt`~i=@j|6y)RWMK--}M|=T`o&^Ni>IoWKHEbBXz7?A@mgWoL>!*SXo`SZH-*HSdS+ yn*9;$7;m`l>wYBC5bq;=U}IMqLzqbYCidGC!)_gkIk_C@Uy!y&wkt5C($~2D>~)O*cj@FGjOCM)M>_ixfudOh)?xMu#Fs z#}Y=@YDTwOM)x{K_j*Q;dPdJ?Mz0n|pLRx{4n|)f>SXlmV)XB04CrSJn#dS5nK2lM zrZ9#~WelCp7&e13Y$jvaEXHskn$2V!!DN-nWS__6T*l;H&Fopn?A6HZ-6WRLFP=R` zqG+CE#d4|IbyAI+rJJ`&x9*T`+a=p|0O(+s{UBcyZdkhj=yS1>AirP+0R;mf2uMgM zC}@~JfByORAh4SyRgi&!(cja>F(l*O+nd+@4m$|6K6KDn_&uvCpV23&>G9HJp{xgg zoq1^2_p9@|WEo z*X_Uko@K)qYYv~>43eQGMdbiGbo>E~Q& zrYBH{QP^@Sti!`2)uG{irBBq@y*$B zi#&(U-*=fp74j)RyIw49+0MRPMRU)+a2r*PJ$L5roHt2$UjExCTZSbq%V!HeS7J$N zdG@vOZB4v_lF7Plrx+hxo7(fCV&}fHq)$ literal 0 HcmV?d00001 diff --git a/pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..d5f1c8d34e7a88e3f88bea192c3a370d44689c3c GIT binary patch literal 1031 zcmeAS@N?(olHy`uVBq!ia0vp^6F``Q8Ax83A=Cw=BuiW)N`mv#O3D+9QW+dm@{>{( zJaZG%Q-e|yQz{EjrrIztFa`(sgt!6~Yi|1%a`XoT0ojZ}lNrNjb9xjc(B0U1_% zz5^97Xt*%oq$rQy4?0GKNfJ44uvxI)gC`h-NZ|&0-7(qS@?b!5r36oQ}zyZrNO3 zMO=Or+<~>+A&uN&E!^Sl+>xE!QC-|oJv`ApDhqC^EWD|@=#J`=d#Xzxs4ah}w&Jnc z$|q_opQ^2TrnVZ0o~wh<3t%W&flvYGe#$xqda2bR_R zvPYgMcHgjZ5nSA^lJr%;<&0do;O^tDDh~=pIxA#coaCY>&N%M2^tq^U%3DB@ynvKo}b?yu-bFc-u0JHzced$sg7S3zqI(2 z#Km{dPr7I=pQ5>FuK#)QwK?Y`E`B?nP+}U)I#c1+FM*1kNvWG|a(TpksZQ3B@sD~b zpQ2)*V*TdwjFOtHvV|;OsiDqHi=6%)o4b!)x$)%9pGTsE z-JL={-Ffv+T87W(Xpooq<`r*VzWQcgBN$$`u}f>-ZQI1BB8ykN*=e4rIsJx9>z}*o zo~|9I;xof literal 0 HcmV?d00001 diff --git a/pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..4d6372eebdb28e45604e46eeda8dd24651419bc0 GIT binary patch literal 1443 zcmb`G{WsKk6vsdJTdFg%tJav9_E4vzrOaqkWF|A724Nly!y+?N9`YV6wZ}5(X(D_N(?!*n3`|_r0Hc?=PQw&*vnU?QTFY zB_MsH|!j$PP;I}?dppoE_gA(4uc!jV&0!l7_;&p2^pxNo>PEcNJv za5_RT$o2Mf!<+r?&EbHH6nMoTsDOa;mN(wv8RNsHpG)`^ymG-S5By8=l9iVXzN_eG%Xg2@Xeq76tTZ*dGh~Lo9vl;Zfs+W#BydUw zCkZ$o1LqWQO$FC9aKlLl*7x9^0q%0}$OMlp@Kk_jHXOjofdePND+j!A{q!8~Jn+s3 z?~~w@4?egS02}8NuulUA=L~QQfm;MzCGd)XhiftT;+zFO&JVyp2mBww?;QByS_1w! zrQlx%{^cMj0|Bo1FjwY@Q8?Hx0cIPF*@-ZRFpPc#bBw{5@tD(5%sClzIfl8WU~V#u zm5Q;_F!wa$BSpqhN>W@2De?TKWR*!ujY;Yylk_X5#~V!L*Gw~;$%4Q8~Mad z@`-kG?yb$a9cHIApZDVZ^U6Xkp<*4rU82O7%}0jjHlK{id@?-wpN*fCHXyXh(bLt* zPc}H-x0e4E&nQ>y%B-(EL=9}RyC%MyX=upHuFhAk&MLbsF0LP-q`XnH78@fT+pKPW zu72MW`|?8ht^tz$iC}ZwLp4tB;Q49K!QCF3@!iB1qOI=?w z7In!}F~ij(18UYUjnbmC!qKhPo%24?8U1x{7o(+?^Zu0Hx81|FuS?bJ0jgBhEMzf< zCgUq7r2OCB(`XkKcN-TL>u5y#dD6D!)5W?`O5)V^>jb)P)GBdy%t$uUMpf$SNV31$ zb||OojAbvMP?T@$h_ZiFLFVHDmbyMhJF|-_)HX3%m=CDI+ID$0^C>kzxprBW)hw(v zr!Gmda);ICoQyhV_oP5+C%?jcG8v+D@9f?Dk*!BxY}dazmrT@64UrP3hlslANK)bq z$67n83eh}OeW&SV@HG95P|bjfqJ7gw$e+`Hxo!4cx`jdK1bJ>YDSpGKLPZ^1cv$ek zIB?0S<#tX?SJCLWdMd{-ME?$hc7A$zBOdIJ)4!KcAwb=VMov)nK;9z>x~rfT1>dS+ zZ6#`2v@`jgbqq)P22H)Tx2CpmM^o1$B+xT6`(v%5xJ(?j#>Q$+rx_R|7TzDZe{J6q zG1*EcU%tE?!kO%^M;3aM6JN*LAKUVb^xz8-Pxo#jR5(-KBeLJvA@-gxNHx0M-ZJLl z;#JwQoh~9V?`UVo#}{6ka@II>++D@%KqGpMdlQ}?9E*wFcf5(#XQnP$Dk5~%iX^>f z%$y;?M0BLp{O3a(-4A?ewryHrrD%cx#Q^%KY1H zNre$ve+vceSLZcNY4U(RBX&)oZn*Py()h)XkE?PL$!bNb{N5FVI2Y%LKEm%yvpyTP z(1P?z~7YxD~Rf<(a@_y` literal 0 HcmV?d00001 diff --git a/pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/values-night/styles.xml b/pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 000000000..06952be74 --- /dev/null +++ b/pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/values/styles.xml b/pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/values/styles.xml new file mode 100644 index 000000000..cb1ef8805 --- /dev/null +++ b/pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/pkgs/jni_gen/examples/in_app_java/android/app/src/profile/AndroidManifest.xml b/pkgs/jni_gen/examples/in_app_java/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 000000000..a09603034 --- /dev/null +++ b/pkgs/jni_gen/examples/in_app_java/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,8 @@ + + + + diff --git a/pkgs/jni_gen/examples/in_app_java/android/build.gradle b/pkgs/jni_gen/examples/in_app_java/android/build.gradle new file mode 100644 index 000000000..e42825f6f --- /dev/null +++ b/pkgs/jni_gen/examples/in_app_java/android/build.gradle @@ -0,0 +1,33 @@ +buildscript { + ext.kotlin_version = '1.6.10' + repositories { + google() + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:7.1.2' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = '../build' +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} + +subprojects { + project.evaluationDependsOn(':app') +} + +task clean(type: Delete) { + delete rootProject.buildDir +} + diff --git a/pkgs/jni_gen/examples/in_app_java/android/gradle.properties b/pkgs/jni_gen/examples/in_app_java/android/gradle.properties new file mode 100644 index 000000000..94adc3a3f --- /dev/null +++ b/pkgs/jni_gen/examples/in_app_java/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx1536M +android.useAndroidX=true +android.enableJetifier=true diff --git a/pkgs/jni_gen/examples/in_app_java/android/gradle/wrapper/gradle-wrapper.properties b/pkgs/jni_gen/examples/in_app_java/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..cc5527d78 --- /dev/null +++ b/pkgs/jni_gen/examples/in_app_java/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Fri Jun 23 08:50:38 CEST 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip diff --git a/pkgs/jni_gen/examples/in_app_java/android/settings.gradle b/pkgs/jni_gen/examples/in_app_java/android/settings.gradle new file mode 100644 index 000000000..44e62bcf0 --- /dev/null +++ b/pkgs/jni_gen/examples/in_app_java/android/settings.gradle @@ -0,0 +1,11 @@ +include ':app' + +def localPropertiesFile = new File(rootProject.projectDir, "local.properties") +def properties = new Properties() + +assert localPropertiesFile.exists() +localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + +def flutterSdkPath = properties.getProperty("flutter.sdk") +assert flutterSdkPath != null, "flutter.sdk not set in local.properties" +apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" diff --git a/pkgs/jni_gen/examples/in_app_java/jnigen.yaml b/pkgs/jni_gen/examples/in_app_java/jnigen.yaml new file mode 100644 index 000000000..52b63cd6d --- /dev/null +++ b/pkgs/jni_gen/examples/in_app_java/jnigen.yaml @@ -0,0 +1,11 @@ +android_sdk_config: + add_gradle_deps: true + +library_name: android_utils +source_path: + - 'android/app/src/main/java' +classes: + - 'com.example.in_app_java.AndroidUtils' +c_root: src/android_utils +dart_root: lib/android_utils + diff --git a/pkgs/jni_gen/examples/in_app_java/lib/android_utils/com/example/in_app_java.dart b/pkgs/jni_gen/examples/in_app_java/lib/android_utils/com/example/in_app_java.dart new file mode 100644 index 000000000..6f6a01031 --- /dev/null +++ b/pkgs/jni_gen/examples/in_app_java/lib/android_utils/com/example/in_app_java.dart @@ -0,0 +1,39 @@ +// Autogenerated by jni_gen. DO NOT EDIT! + +// ignore_for_file: camel_case_types +// ignore_for_file: non_constant_identifier_names +// ignore_for_file: constant_identifier_names +// ignore_for_file: annotate_overrides +// ignore_for_file: no_leading_underscores_for_local_identifiers +// ignore_for_file: unused_element + +import "dart:ffi" as ffi; + +import "package:jni/jni.dart" as jni; + +import "../../init.dart" show jlookup; + +/// from: com.example.in_app_java.AndroidUtils +class AndroidUtils extends jni.JlObject { + AndroidUtils.fromRef(ffi.Pointer ref) : super.fromRef(ref); + + static final _ctor = + jlookup Function()>>( + "com_example_in_app_java_AndroidUtils_ctor") + .asFunction Function()>(); + + /// from: public void () + AndroidUtils() : super.fromRef(_ctor()); + + static final _showToast = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Int32)>>("com_example_in_app_java_AndroidUtils_showToast") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer, int)>(); + + /// from: static void showToast(android.app.Activity mainActivity, java.lang.CharSequence text, int duration) + static void showToast( + jni.JlObject mainActivity, jni.JlObject text, int duration) => + _showToast(mainActivity.reference, text.reference, duration); +} diff --git a/pkgs/jni_gen/examples/in_app_java/lib/android_utils/init.dart b/pkgs/jni_gen/examples/in_app_java/lib/android_utils/init.dart new file mode 100644 index 000000000..5642f98d5 --- /dev/null +++ b/pkgs/jni_gen/examples/in_app_java/lib/android_utils/init.dart @@ -0,0 +1,5 @@ +import "dart:ffi"; +import "package:jni/jni.dart"; + +final Pointer Function(String sym) jlookup = + Jni.getInstance().initGeneratedLibrary("android_utils"); diff --git a/pkgs/jni_gen/examples/in_app_java/lib/main.dart b/pkgs/jni_gen/examples/in_app_java/lib/main.dart new file mode 100644 index 000000000..b47cb3117 --- /dev/null +++ b/pkgs/jni_gen/examples/in_app_java/lib/main.dart @@ -0,0 +1,60 @@ +import 'package:flutter/material.dart'; +import 'package:jni/jni.dart'; + +// The hierarchy created in generated code will mirror the java package +// structure. This is an implementation convenience and we may allow +// more customization in future. +import 'android_utils/com/example/in_app_java.dart'; + +JlObject activity = JlObject.fromRef(Jni.getInstance().getCurrentActivity()); + +void showToast(String text) { + final jstr = JlString.fromString(text); + AndroidUtils.showToast(activity, jstr, 0); + jstr.delete(); +} + +void main() { + runApp(const MyApp()); +} + +class MyApp extends StatelessWidget { + const MyApp({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return MaterialApp( + title: 'Flutter Demo', + theme: ThemeData( + primarySwatch: Colors.teal, + ), + home: const MyHomePage(title: 'Flutter Demo Home Page'), + ); + } +} + +class MyHomePage extends StatelessWidget { + const MyHomePage({Key? key, required this.title}) : super(key: key); + + final String title; + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text(title), + ), + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + ElevatedButton( + child: const Text('Show toast'), + onPressed: () => showToast('😀'), + ), + ], + ), + ), + ); + } +} diff --git a/pkgs/jni_gen/examples/in_app_java/pubspec.yaml b/pkgs/jni_gen/examples/in_app_java/pubspec.yaml new file mode 100644 index 000000000..aef5291ea --- /dev/null +++ b/pkgs/jni_gen/examples/in_app_java/pubspec.yaml @@ -0,0 +1,67 @@ +name: in_app_java +description: | + Example on how to use jnigen to bridge between java and dart in a flutter + project. + +publish_to: 'none' # Remove this line if you wish to publish to pub.dev + +version: 1.0.0+1 + +environment: + sdk: ">=2.17.6 <3.0.0" + +dependencies: + flutter: + sdk: flutter + jni: + path: ../../../jni/ + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^1.0.2 + +dev_dependencies: + flutter_test: + sdk: flutter + jni_gen: + path: ../../ + + flutter_lints: ^2.0.0 + +flutter: + + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + + # To add assets to your application, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/assets-and-images/#from-packages + + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/custom-fonts/#from-packages diff --git a/pkgs/jni_gen/examples/in_app_java/src/android_utils/CMakeLists.txt b/pkgs/jni_gen/examples/in_app_java/src/android_utils/CMakeLists.txt new file mode 100644 index 000000000..fe6f9254d --- /dev/null +++ b/pkgs/jni_gen/examples/in_app_java/src/android_utils/CMakeLists.txt @@ -0,0 +1,30 @@ +# The Flutter tooling requires that developers have CMake 3.10 or later +# installed. You should not increase this version, as doing so will cause +# the plugin to fail to compile for some customers of the plugin. +cmake_minimum_required(VERSION 3.10) + +project(android_utils VERSION 0.0.1 LANGUAGES C) + +add_library(android_utils SHARED + "./android_utils.c" +) + +set_target_properties(android_utils PROPERTIES + OUTPUT_NAME "android_utils" +) + +target_compile_definitions(android_utils PUBLIC DART_SHARED_LIB) + +if(WIN32) + set_target_properties(${TARGET_NAME} PROPERTIES + LINK_FLAGS "/DELAYLOAD:jvm.dll") +endif() + +if (ANDROID) + target_link_libraries(android_utils log) +else() + find_package(Java REQUIRED) + find_package(JNI REQUIRED) + include_directories(${JNI_INCLUDE_DIRS}) + target_link_libraries(android_utils ${JNI_LIBRARIES}) +endif() diff --git a/pkgs/jni_gen/examples/in_app_java/src/android_utils/android_utils.c b/pkgs/jni_gen/examples/in_app_java/src/android_utils/android_utils.c new file mode 100644 index 000000000..d9c365ce4 --- /dev/null +++ b/pkgs/jni_gen/examples/in_app_java/src/android_utils/android_utils.c @@ -0,0 +1,40 @@ +// Autogenerated by jni_gen. DO NOT EDIT! + +#include +#include "jni.h" +#include "dartjni.h" + +thread_local JNIEnv *jniEnv; +struct jni_context jni; + +struct jni_context (*context_getter)(void); +JNIEnv *(*env_getter)(void); + +void setJniGetters(struct jni_context (*cg)(void), + JNIEnv *(*eg)(void)) { + context_getter = cg; + env_getter = eg; +} + +// com.example.in_app_java.AndroidUtils +jclass _c_com_example_in_app_java_AndroidUtils = NULL; + +jmethodID _m_com_example_in_app_java_AndroidUtils_ctor = NULL; +FFI_PLUGIN_EXPORT +jobject com_example_in_app_java_AndroidUtils_ctor() { + load_env(); + load_class_gr(&_c_com_example_in_app_java_AndroidUtils, "com/example/in_app_java/AndroidUtils"); + load_method(_c_com_example_in_app_java_AndroidUtils, &_m_com_example_in_app_java_AndroidUtils_ctor, "", "()V"); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_com_example_in_app_java_AndroidUtils, _m_com_example_in_app_java_AndroidUtils_ctor); + return to_global_ref(_result); +} + +jmethodID _m_com_example_in_app_java_AndroidUtils_showToast = NULL; +FFI_PLUGIN_EXPORT +void com_example_in_app_java_AndroidUtils_showToast(jobject mainActivity, jobject text, int32_t duration) { + load_env(); + load_class_gr(&_c_com_example_in_app_java_AndroidUtils, "com/example/in_app_java/AndroidUtils"); + load_static_method(_c_com_example_in_app_java_AndroidUtils, &_m_com_example_in_app_java_AndroidUtils_showToast, "showToast", "(Landroid/app/Activity;Ljava/lang/CharSequence;I)V"); + (*jniEnv)->CallStaticVoidMethod(jniEnv, _c_com_example_in_app_java_AndroidUtils, _m_com_example_in_app_java_AndroidUtils_showToast, mainActivity, text, duration); +} + diff --git a/pkgs/jni_gen/examples/in_app_java/src/android_utils/dartjni.h b/pkgs/jni_gen/examples/in_app_java/src/android_utils/dartjni.h new file mode 100644 index 000000000..cd94b1532 --- /dev/null +++ b/pkgs/jni_gen/examples/in_app_java/src/android_utils/dartjni.h @@ -0,0 +1,177 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +#include +#include +#include +#include + +#if _WIN32 +#include +#else +#include +#include +#endif + +#if _WIN32 +#define FFI_PLUGIN_EXPORT __declspec(dllexport) +#else +#define FFI_PLUGIN_EXPORT +#endif + +#if defined _WIN32 +#define thread_local __declspec(thread) +#else +#define thread_local __thread +#endif + +#ifdef __ANDROID__ +#include +#endif + +#define JNI_LOG_TAG "Dart-JNI" + +#ifdef __ANDROID__ +#define __ENVP_CAST (JNIEnv **) +#else +#define __ENVP_CAST (void **) +#endif + +struct jni_context { + JavaVM *jvm; + jobject classLoader; + jmethodID loadClassMethod; + jobject currentActivity; + jobject appContext; +}; + +extern thread_local JNIEnv *jniEnv; + +extern struct jni_context jni; + +enum DartJniLogLevel { + JNI_VERBOSE = 2, + JNI_DEBUG, + JNI_INFO, + JNI_WARN, + JNI_ERROR +}; + +FFI_PLUGIN_EXPORT struct jni_context GetJniContext(); + +FFI_PLUGIN_EXPORT JavaVM *GetJavaVM(void); + +FFI_PLUGIN_EXPORT JNIEnv *GetJniEnv(void); + +FFI_PLUGIN_EXPORT JNIEnv *SpawnJvm(JavaVMInitArgs *args); + +FFI_PLUGIN_EXPORT jclass LoadClass(const char *name); + +FFI_PLUGIN_EXPORT jobject GetClassLoader(void); + +FFI_PLUGIN_EXPORT jobject GetApplicationContext(void); + +FFI_PLUGIN_EXPORT jobject GetCurrentActivity(void); + +FFI_PLUGIN_EXPORT void SetJNILogging(int level); + +FFI_PLUGIN_EXPORT jstring ToJavaString(char *str); + +FFI_PLUGIN_EXPORT const char *GetJavaStringChars(jstring jstr); + +FFI_PLUGIN_EXPORT void ReleaseJavaStringChars(jstring jstr, const char *buf); + +// These 2 are the function pointer variables defined and exported by +// the generated C files. +// +// initGeneratedLibrary function in Jni class will set these to +// corresponding functions to the implementations from `dartjni` base library +// which initializes and manages the JNI. +extern struct jni_context (*context_getter)(void); +extern JNIEnv *(*env_getter)(void); + +// This function will be exported by generated code library and will set the +// above 2 variables. +FFI_PLUGIN_EXPORT void setJniGetters(struct jni_context (*cg)(void), + JNIEnv *(*eg)(void)); + +// `static inline` because `inline` doesn't work, it may still not +// inline the function in which case a linker error may be produced. +// +// There has to be a better way to do this. Either to force inlining on target +// platforms, or just leave it as normal function. +static inline void __load_class_into(jclass *cls, const char *name) { +#ifdef __ANDROID__ + jstring className = (*jniEnv)->NewStringUTF(jniEnv, name); + *cls = (*jniEnv)->CallObjectMethod(jniEnv, jni.classLoader, + jni.loadClassMethod, className); + (*jniEnv)->DeleteLocalRef(jniEnv, className); +#else + *cls = (*jniEnv)->FindClass(jniEnv, name); +#endif +} + +static inline void load_class(jclass *cls, const char *name) { + if (*cls == NULL) { + __load_class_into(cls, name); + } +} + +static inline void load_class_gr(jclass *cls, const char *name) { + if (*cls == NULL) { + jclass tmp; + __load_class_into(&tmp, name); + *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); + (*jniEnv)->DeleteLocalRef(jniEnv, tmp); + } +} + +static inline void attach_thread() { + if (jniEnv == NULL) { + (*jni.jvm)->AttachCurrentThread(jni.jvm, __ENVP_CAST & jniEnv, + NULL); + } +} + +static inline void load_env() { + if (jniEnv == NULL) { + jni = context_getter(); + jniEnv = env_getter(); + } +} + +static inline void load_method(jclass cls, jmethodID *res, const char *name, + const char *sig) { + if (*res == NULL) { + *res = (*jniEnv)->GetMethodID(jniEnv, cls, name, sig); + } +} + +static inline void load_static_method(jclass cls, jmethodID *res, + const char *name, const char *sig) { + if (*res == NULL) { + *res = (*jniEnv)->GetStaticMethodID(jniEnv, cls, name, sig); + } +} + +static inline void load_field(jclass cls, jfieldID *res, const char *name, + const char *sig) { + if (*res == NULL) { + *res = (*jniEnv)->GetFieldID(jniEnv, cls, name, sig); + } +} + +static inline void load_static_field(jclass cls, jfieldID *res, + const char *name, const char *sig) { + if (*res == NULL) { + *res = (*jniEnv)->GetStaticFieldID(jniEnv, cls, name, sig); + } +} + +static inline jobject to_global_ref(jobject ref) { + jobject g = (*jniEnv)->NewGlobalRef(jniEnv, ref); + (*jniEnv)->DeleteLocalRef(jniEnv, ref); + return g; +} + diff --git a/pkgs/jni_gen/examples/in_app_java/test/widget_test.dart b/pkgs/jni_gen/examples/in_app_java/test/widget_test.dart new file mode 100644 index 000000000..0c153ccbd --- /dev/null +++ b/pkgs/jni_gen/examples/in_app_java/test/widget_test.dart @@ -0,0 +1,30 @@ +// This is a basic Flutter widget test. +// +// To perform an interaction with a widget in your test, use the WidgetTester +// utility in the flutter_test package. For example, you can send tap and scroll +// gestures. You can also use WidgetTester to find child widgets in the widget +// tree, read text, and verify that the values of widget properties are correct. + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'package:in_app_java/main.dart'; + +void main() { + testWidgets('Counter increments smoke test', (WidgetTester tester) async { + // Build our app and trigger a frame. + await tester.pumpWidget(const MyApp()); + + // Verify that our counter starts at 0. + expect(find.text('0'), findsOneWidget); + expect(find.text('1'), findsNothing); + + // Tap the '+' icon and trigger a frame. + await tester.tap(find.byIcon(Icons.add)); + await tester.pump(); + + // Verify that our counter has incremented. + expect(find.text('0'), findsNothing); + expect(find.text('1'), findsOneWidget); + }); +} diff --git a/pkgs/jni_gen/examples/in_app_java/tool/generate_bindings.dart b/pkgs/jni_gen/examples/in_app_java/tool/generate_bindings.dart new file mode 100644 index 000000000..2628d9901 --- /dev/null +++ b/pkgs/jni_gen/examples/in_app_java/tool/generate_bindings.dart @@ -0,0 +1,15 @@ +import 'package:jni_gen/jni_gen.dart'; + +void main(List args) async { + final config = Config( + sourcePath: [Uri.directory('android/app/src/main/java')], + classes: ['com.example.in_app_java.AndroidUtils'], + cRoot: Uri.directory('src/android_utils'), + dartRoot: Uri.directory('lib/android_utils'), + libraryName: 'android_utils', + androidSdkConfig: AndroidSdkConfig( + versions: [31], + ), + ); + await generateJniBindings(config); +} diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/.gitignore b/pkgs/jni_gen/examples/pdfbox_plugin/.gitignore new file mode 100644 index 000000000..4080544e7 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/.gitignore @@ -0,0 +1,37 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +.packages +build/ + +## Downloaded by jni_gen +/mvn_java/ +/mvn_jar/ +## Sometimes generated by maven. +## TODO(#34) This is unwanted. +/target/ diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/.metadata b/pkgs/jni_gen/examples/pdfbox_plugin/.metadata new file mode 100644 index 000000000..9d23aa995 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/.metadata @@ -0,0 +1,36 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled. + +version: + revision: f1875d570e39de09040c8f79aa13cc56baab8db1 + channel: stable + +project_type: plugin_ffi + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 + base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 + - platform: android + create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 + base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 + - platform: linux + create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 + base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 + - platform: windows + create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 + base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/README.md b/pkgs/jni_gen/examples/pdfbox_plugin/README.md new file mode 100644 index 000000000..5fa64ea67 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/README.md @@ -0,0 +1,8 @@ +# pdfbox_plugin + +Example of a JNI plugin using `jni_gen` to auto-generate bindings for PDFBox java library. + +Bindings can be generated by running `dart run jni_gen --config jnigen.yaml`. Required source code and JARs will be downloaded using maven (requires `mvn` command). + +`jni_gen` is also available as an API which tooling scripts can use. See `tool/generate_bindings.dart` for the script equivalent of the YAML file. + diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/analysis_options.yaml b/pkgs/jni_gen/examples/pdfbox_plugin/analysis_options.yaml new file mode 100644 index 000000000..198e7e069 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/analysis_options.yaml @@ -0,0 +1,4 @@ +#include: package:flutter_lints/flutter.yaml + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/android/.gitignore b/pkgs/jni_gen/examples/pdfbox_plugin/android/.gitignore new file mode 100644 index 000000000..161bdcdaf --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/android/.gitignore @@ -0,0 +1,9 @@ +*.iml +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures +.cxx diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/android/build.gradle b/pkgs/jni_gen/examples/pdfbox_plugin/android/build.gradle new file mode 100644 index 000000000..9c3bca816 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/android/build.gradle @@ -0,0 +1,59 @@ +// The Android Gradle Plugin builds the native code with the Android NDK. + +group 'com.example.pdfbox_plugin' +version '1.0' + +buildscript { + repositories { + google() + mavenCentral() + } + + dependencies { + // The Android Gradle Plugin knows how to build native code with the NDK. + classpath 'com.android.tools.build:gradle:7.1.2' + } +} + +rootProject.allprojects { + repositories { + google() + mavenCentral() + } +} + +apply plugin: 'com.android.library' + +android { + // Bumping the plugin compileSdkVersion requires all clients of this plugin + // to bump the version in their app. + compileSdkVersion 31 + + // Bumping the plugin ndkVersion requires all clients of this plugin to bump + // the version in their app and to download a newer version of the NDK. + ndkVersion "21.1.6352462" + + // Invoke the shared CMake build with the Android Gradle Plugin. + externalNativeBuild { + cmake { + path "../src/CMakeLists.txt" + + // The default CMake version for the Android Gradle Plugin is 3.10.2. + // https://developer.android.com/studio/projects/install-ndk#vanilla_cmake + // + // The Flutter tooling requires that developers have CMake 3.10 or later + // installed. You should not increase this version, as doing so will cause + // the plugin to fail to compile for some customers of the plugin. + // version "3.10.2" + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + defaultConfig { + minSdkVersion 16 + } +} diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/android/settings.gradle b/pkgs/jni_gen/examples/pdfbox_plugin/android/settings.gradle new file mode 100644 index 000000000..84ca2f9e4 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/android/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'pdfbox_plugin' diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/android/src/main/AndroidManifest.xml b/pkgs/jni_gen/examples/pdfbox_plugin/android/src/main/AndroidManifest.xml new file mode 100644 index 000000000..ae0f6a3f4 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/android/src/main/AndroidManifest.xml @@ -0,0 +1,3 @@ + + diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/dart_example/.gitignore b/pkgs/jni_gen/examples/pdfbox_plugin/dart_example/.gitignore new file mode 100644 index 000000000..96449441d --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/dart_example/.gitignore @@ -0,0 +1,12 @@ +# Files and directories created by pub. +.dart_tool/ +.packages + +# Conventional directory for build output. +build/ + +# PDF files +*.pdf + +# AOT compiled +*.exe diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/dart_example/CHANGELOG.md b/pkgs/jni_gen/examples/pdfbox_plugin/dart_example/CHANGELOG.md new file mode 100644 index 000000000..effe43c82 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/dart_example/CHANGELOG.md @@ -0,0 +1,3 @@ +## 1.0.0 + +- Initial version. diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/dart_example/README.md b/pkgs/jni_gen/examples/pdfbox_plugin/dart_example/README.md new file mode 100644 index 000000000..f11149376 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/dart_example/README.md @@ -0,0 +1,10 @@ +## Running +After generating `pdfbox_plugin` bindings in the parent directory + +* setup native libraries: `dart run jni:setup && dart run jni:setup -p pdfbox_plugin` + +* `dart run bin/pdf_info.dart ` + +Alternatively, it's possible to compile `bin/pdf_info.dart` and then run it. + +To run it from other directories, the `helperDir` and `classpath` parameters in `Jni.spawn` call should be adjusted appropriately. diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/dart_example/analysis_options.yaml b/pkgs/jni_gen/examples/pdfbox_plugin/dart_example/analysis_options.yaml new file mode 100644 index 000000000..dee8927aa --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/dart_example/analysis_options.yaml @@ -0,0 +1,30 @@ +# This file configures the static analysis results for your project (errors, +# warnings, and lints). +# +# This enables the 'recommended' set of lints from `package:lints`. +# This set helps identify many issues that may lead to problems when running +# or consuming Dart code, and enforces writing Dart using a single, idiomatic +# style and format. +# +# If you want a smaller set of lints you can change this to specify +# 'package:lints/core.yaml'. These are just the most critical lints +# (the recommended set includes the core lints). +# The core lints are also what is used by pub.dev for scoring packages. + +include: package:lints/recommended.yaml + +# Uncomment the following section to specify additional rules. + +# linter: +# rules: +# - camel_case_types + +# analyzer: +# exclude: +# - path/to/excluded/files/** + +# For more information about the core and recommended set of lints, see +# https://dart.dev/go/core-lints + +# For additional information about configuring this file, see +# https://dart.dev/guides/language/analysis-options diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/dart_example/bin/pdf_info.dart b/pkgs/jni_gen/examples/pdfbox_plugin/dart_example/bin/pdf_info.dart new file mode 100644 index 000000000..f8756ff55 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/dart_example/bin/pdf_info.dart @@ -0,0 +1,72 @@ +import 'dart:io'; + +import 'package:path/path.dart'; +import 'package:jni/jni.dart'; +import 'dart:ffi'; + +import 'package:pdfbox_plugin/third_party/org/apache/pdfbox/pdmodel.dart'; + +void writeInfo(String file) { + var jni = Jni.getInstance(); + + var inputFile = jni + .newInstance("java/io/FileInputStream", "(Ljava/lang/String;)V", [file]); + var inputJl = JlObject.fromRef(inputFile.jobject); + + var pdDoc = PDDocument.load7(inputJl); + int pages = pdDoc.getNumberOfPages(); + final info = pdDoc.getDocumentInformation(); + final title = info.getTitle(); + final subject = info.getSubject(); + final author = info.getAuthor(); + stderr.writeln('Number of pages: $pages'); + if (title.reference != nullptr) { + stderr.writeln('Title: ${title.toDartString()}'); + } + if (subject.reference != nullptr) { + stderr.writeln('Subject: ${subject.toDartString()}'); + } + if (author.reference != nullptr) { + stderr.writeln('Author: ${author.toDartString()}'); + } + stderr.writeln('PDF Version: ${pdDoc.getVersion()}'); + + for (JlObject jr in [pdDoc, info, title, author, subject]) { + jr.delete(); + } + inputFile.delete(); +} + +final jniLibsDir = join('build', 'jni_libs'); + +const jarError = 'No JAR files were found.\n' + 'Run `dart run jni_gen:download_maven_jars --config jnigen.yaml` ' + 'in plugin directory.\n' + 'Alternatively, regenerate JNI bindings in plugin directory, which will ' + 'automatically download the JAR files.'; + +void main(List arguments) { + final jarDir = join('..', 'mvn_jar'); + List jars; + try { + jars = Directory(jarDir) + .listSync() + .map((e) => e.path) + .where((path) => path.endsWith('.jar')) + .toList(); + } on OSError catch (_) { + stderr.writeln(jarError); + return; + } + if (jars.isEmpty) { + stderr.writeln(jarError); + return; + } + Jni.spawn(helperDir: jniLibsDir, classPath: jars); + if (arguments.length != 1) { + stderr.writeln('usage: dart run pdf_info:pdf_info '); + exitCode = 1; + return; + } + writeInfo(arguments[0]); +} diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/dart_example/pubspec.yaml b/pkgs/jni_gen/examples/pdfbox_plugin/dart_example/pubspec.yaml new file mode 100644 index 000000000..b694b73eb --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/dart_example/pubspec.yaml @@ -0,0 +1,19 @@ +name: pdf_info +description: Dart standalone example using jni_gen PDFBox bindings +version: 1.0.0 +publish_to: none +# homepage: https://www.example.com + +environment: + sdk: '>=2.17.6 <3.0.0' + +dependencies: + path: ^1.8.0 + jni: + path: ../../../../jni/ + pdfbox_plugin: + path: ../ + +dev_dependencies: + lints: ^2.0.0 + test: ^1.16.0 diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/.gitignore b/pkgs/jni_gen/examples/pdfbox_plugin/example/.gitignore new file mode 100644 index 000000000..a8e938c08 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/.gitignore @@ -0,0 +1,47 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ +/build/ + +# Web related +lib/generated_plugin_registrant.dart + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/README.md b/pkgs/jni_gen/examples/pdfbox_plugin/example/README.md new file mode 100644 index 000000000..697559cbc --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/README.md @@ -0,0 +1,18 @@ +# pdfbox_plugin_example + +Demonstrates how to use the PDFBox bindings generated using `jni_gen`. This is a Linux Flutter application. The sample application lists the PDF files in a directory with number of pages and title, also allowing to navigate between directories. + +First, it's required to have generated the dart and C bindings in the plugin directory, which also downloads the required JARs using maven. The bindings are not committed because generated code is several thousands of lines. + +On a Linux machine, following commands can be used to run the example application. + +``` +cd .. ## From this folder +dart run jni_gen --config jnigen.yaml ## Downloads PDFBox JARs and generates bindings. +cd example/ +flutter run --release ## Opens the files list from home directory +``` + +It may take some time for PDFBox to process all PDFs in a directory. In the interest of simplicity, this example application displays the list after all PDFs are processed. + +Follow along the code in `lib/main.dart` to see how generated bindings are used. diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/analysis_options.yaml b/pkgs/jni_gen/examples/pdfbox_plugin/example/analysis_options.yaml new file mode 100644 index 000000000..61b6c4de1 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/analysis_options.yaml @@ -0,0 +1,29 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at + # https://dart-lang.github.io/linter/lints/index.html. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/.gitignore b/pkgs/jni_gen/examples/pdfbox_plugin/example/android/.gitignore new file mode 100644 index 000000000..6f568019d --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/android/.gitignore @@ -0,0 +1,13 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +key.properties +**/*.keystore +**/*.jks diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/build.gradle b/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/build.gradle new file mode 100644 index 000000000..162ad5b01 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/build.gradle @@ -0,0 +1,71 @@ +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterRoot = localProperties.getProperty('flutter.sdk') +if (flutterRoot == null) { + throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" + +android { + compileSdkVersion flutter.compileSdkVersion + ndkVersion flutter.ndkVersion + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId "com.example.pdfbox_plugin_example" + // You can update the following values to match your application needs. + // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. + minSdkVersion flutter.minSdkVersion + targetSdkVersion flutter.targetSdkVersion + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.debug + } + } +} + +flutter { + source '../..' +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" +} diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/debug/AndroidManifest.xml b/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 000000000..3789e50b1 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,8 @@ + + + + diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/AndroidManifest.xml b/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/AndroidManifest.xml new file mode 100644 index 000000000..a46900acc --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/kotlin/com/example/pdfbox_plugin_example/MainActivity.kt b/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/kotlin/com/example/pdfbox_plugin_example/MainActivity.kt new file mode 100644 index 000000000..68d076ced --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/kotlin/com/example/pdfbox_plugin_example/MainActivity.kt @@ -0,0 +1,6 @@ +package com.example.pdfbox_plugin_example + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() { +} diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/drawable-v21/launch_background.xml b/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 000000000..f74085f3f --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/drawable/launch_background.xml b/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 000000000..304732f88 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..db77bb4b7b0906d62b1847e87f15cdcacf6a4f29 GIT binary patch literal 544 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY3?!3`olAj~WQl7;NpOBzNqJ&XDuZK6ep0G} zXKrG8YEWuoN@d~6R2!h8bpbvhu0Wd6uZuB!w&u2PAxD2eNXD>P5D~Wn-+_Wa#27Xc zC?Zj|6r#X(-D3u$NCt}(Ms06KgJ4FxJVv{GM)!I~&n8Bnc94O7-Hd)cjDZswgC;Qs zO=b+9!WcT8F?0rF7!Uys2bs@gozCP?z~o%U|N3vA*22NaGQG zlg@K`O_XuxvZ&Ks^m&R!`&1=spLvfx7oGDKDwpwW`#iqdw@AL`7MR}m`rwr|mZgU`8P7SBkL78fFf!WnuYWm$5Z0 zNXhDbCv&49sM544K|?c)WrFfiZvCi9h0O)B3Pgg&ebxsLQ05GG~ AQ2+n{ literal 0 HcmV?d00001 diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..17987b79bb8a35cc66c3c1fd44f5a5526c1b78be GIT binary patch literal 442 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA3?vioaBc-sk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5Xx&nMcT!A!W`0S9QKQy;}1Cl^CgaH=;G9cpY;r$Q>i*pfB zP2drbID<_#qf;rPZx^FqH)F_D#*k@@q03KywUtLX8Ua?`H+NMzkczFPK3lFz@i_kW%1NOn0|D2I9n9wzH8m|-tHjsw|9>@K=iMBhxvkv6m8Y-l zytQ?X=U+MF$@3 zt`~i=@j|6y)RWMK--}M|=T`o&^Ni>IoWKHEbBXz7?A@mgWoL>!*SXo`SZH-*HSdS+ yn*9;$7;m`l>wYBC5bq;=U}IMqLzqbYCidGC!)_gkIk_C@Uy!y&wkt5C($~2D>~)O*cj@FGjOCM)M>_ixfudOh)?xMu#Fs z#}Y=@YDTwOM)x{K_j*Q;dPdJ?Mz0n|pLRx{4n|)f>SXlmV)XB04CrSJn#dS5nK2lM zrZ9#~WelCp7&e13Y$jvaEXHskn$2V!!DN-nWS__6T*l;H&Fopn?A6HZ-6WRLFP=R` zqG+CE#d4|IbyAI+rJJ`&x9*T`+a=p|0O(+s{UBcyZdkhj=yS1>AirP+0R;mf2uMgM zC}@~JfByORAh4SyRgi&!(cja>F(l*O+nd+@4m$|6K6KDn_&uvCpV23&>G9HJp{xgg zoq1^2_p9@|WEo z*X_Uko@K)qYYv~>43eQGMdbiGbo>E~Q& zrYBH{QP^@Sti!`2)uG{irBBq@y*$B zi#&(U-*=fp74j)RyIw49+0MRPMRU)+a2r*PJ$L5roHt2$UjExCTZSbq%V!HeS7J$N zdG@vOZB4v_lF7Plrx+hxo7(fCV&}fHq)$ literal 0 HcmV?d00001 diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..d5f1c8d34e7a88e3f88bea192c3a370d44689c3c GIT binary patch literal 1031 zcmeAS@N?(olHy`uVBq!ia0vp^6F``Q8Ax83A=Cw=BuiW)N`mv#O3D+9QW+dm@{>{( zJaZG%Q-e|yQz{EjrrIztFa`(sgt!6~Yi|1%a`XoT0ojZ}lNrNjb9xjc(B0U1_% zz5^97Xt*%oq$rQy4?0GKNfJ44uvxI)gC`h-NZ|&0-7(qS@?b!5r36oQ}zyZrNO3 zMO=Or+<~>+A&uN&E!^Sl+>xE!QC-|oJv`ApDhqC^EWD|@=#J`=d#Xzxs4ah}w&Jnc z$|q_opQ^2TrnVZ0o~wh<3t%W&flvYGe#$xqda2bR_R zvPYgMcHgjZ5nSA^lJr%;<&0do;O^tDDh~=pIxA#coaCY>&N%M2^tq^U%3DB@ynvKo}b?yu-bFc-u0JHzced$sg7S3zqI(2 z#Km{dPr7I=pQ5>FuK#)QwK?Y`E`B?nP+}U)I#c1+FM*1kNvWG|a(TpksZQ3B@sD~b zpQ2)*V*TdwjFOtHvV|;OsiDqHi=6%)o4b!)x$)%9pGTsE z-JL={-Ffv+T87W(Xpooq<`r*VzWQcgBN$$`u}f>-ZQI1BB8ykN*=e4rIsJx9>z}*o zo~|9I;xof literal 0 HcmV?d00001 diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..4d6372eebdb28e45604e46eeda8dd24651419bc0 GIT binary patch literal 1443 zcmb`G{WsKk6vsdJTdFg%tJav9_E4vzrOaqkWF|A724Nly!y+?N9`YV6wZ}5(X(D_N(?!*n3`|_r0Hc?=PQw&*vnU?QTFY zB_MsH|!j$PP;I}?dppoE_gA(4uc!jV&0!l7_;&p2^pxNo>PEcNJv za5_RT$o2Mf!<+r?&EbHH6nMoTsDOa;mN(wv8RNsHpG)`^ymG-S5By8=l9iVXzN_eG%Xg2@Xeq76tTZ*dGh~Lo9vl;Zfs+W#BydUw zCkZ$o1LqWQO$FC9aKlLl*7x9^0q%0}$OMlp@Kk_jHXOjofdePND+j!A{q!8~Jn+s3 z?~~w@4?egS02}8NuulUA=L~QQfm;MzCGd)XhiftT;+zFO&JVyp2mBww?;QByS_1w! zrQlx%{^cMj0|Bo1FjwY@Q8?Hx0cIPF*@-ZRFpPc#bBw{5@tD(5%sClzIfl8WU~V#u zm5Q;_F!wa$BSpqhN>W@2De?TKWR*!ujY;Yylk_X5#~V!L*Gw~;$%4Q8~Mad z@`-kG?yb$a9cHIApZDVZ^U6Xkp<*4rU82O7%}0jjHlK{id@?-wpN*fCHXyXh(bLt* zPc}H-x0e4E&nQ>y%B-(EL=9}RyC%MyX=upHuFhAk&MLbsF0LP-q`XnH78@fT+pKPW zu72MW`|?8ht^tz$iC}ZwLp4tB;Q49K!QCF3@!iB1qOI=?w z7In!}F~ij(18UYUjnbmC!qKhPo%24?8U1x{7o(+?^Zu0Hx81|FuS?bJ0jgBhEMzf< zCgUq7r2OCB(`XkKcN-TL>u5y#dD6D!)5W?`O5)V^>jb)P)GBdy%t$uUMpf$SNV31$ zb||OojAbvMP?T@$h_ZiFLFVHDmbyMhJF|-_)HX3%m=CDI+ID$0^C>kzxprBW)hw(v zr!Gmda);ICoQyhV_oP5+C%?jcG8v+D@9f?Dk*!BxY}dazmrT@64UrP3hlslANK)bq z$67n83eh}OeW&SV@HG95P|bjfqJ7gw$e+`Hxo!4cx`jdK1bJ>YDSpGKLPZ^1cv$ek zIB?0S<#tX?SJCLWdMd{-ME?$hc7A$zBOdIJ)4!KcAwb=VMov)nK;9z>x~rfT1>dS+ zZ6#`2v@`jgbqq)P22H)Tx2CpmM^o1$B+xT6`(v%5xJ(?j#>Q$+rx_R|7TzDZe{J6q zG1*EcU%tE?!kO%^M;3aM6JN*LAKUVb^xz8-Pxo#jR5(-KBeLJvA@-gxNHx0M-ZJLl z;#JwQoh~9V?`UVo#}{6ka@II>++D@%KqGpMdlQ}?9E*wFcf5(#XQnP$Dk5~%iX^>f z%$y;?M0BLp{O3a(-4A?ewryHrrD%cx#Q^%KY1H zNre$ve+vceSLZcNY4U(RBX&)oZn*Py()h)XkE?PL$!bNb{N5FVI2Y%LKEm%yvpyTP z(1P?z~7YxD~Rf<(a@_y` literal 0 HcmV?d00001 diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/values-night/styles.xml b/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 000000000..06952be74 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/values/styles.xml b/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/values/styles.xml new file mode 100644 index 000000000..cb1ef8805 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/profile/AndroidManifest.xml b/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 000000000..3789e50b1 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,8 @@ + + + + diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/build.gradle b/pkgs/jni_gen/examples/pdfbox_plugin/example/android/build.gradle new file mode 100644 index 000000000..83ae22004 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/android/build.gradle @@ -0,0 +1,31 @@ +buildscript { + ext.kotlin_version = '1.6.10' + repositories { + google() + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:7.1.2' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = '../build' +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(':app') +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/gradle.properties b/pkgs/jni_gen/examples/pdfbox_plugin/example/android/gradle.properties new file mode 100644 index 000000000..94adc3a3f --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx1536M +android.useAndroidX=true +android.enableJetifier=true diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/gradle/wrapper/gradle-wrapper.properties b/pkgs/jni_gen/examples/pdfbox_plugin/example/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..cc5527d78 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Fri Jun 23 08:50:38 CEST 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/settings.gradle b/pkgs/jni_gen/examples/pdfbox_plugin/example/android/settings.gradle new file mode 100644 index 000000000..44e62bcf0 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/android/settings.gradle @@ -0,0 +1,11 @@ +include ':app' + +def localPropertiesFile = new File(rootProject.projectDir, "local.properties") +def properties = new Properties() + +assert localPropertiesFile.exists() +localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + +def flutterSdkPath = properties.getProperty("flutter.sdk") +assert flutterSdkPath != null, "flutter.sdk not set in local.properties" +apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/lib/main.dart b/pkgs/jni_gen/examples/pdfbox_plugin/example/lib/main.dart new file mode 100644 index 000000000..1557b842b --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/lib/main.dart @@ -0,0 +1,212 @@ +import 'package:flutter/material.dart'; +import 'dart:io'; +import 'dart:async'; + +import 'dart:ffi'; // for nullptr := +import 'package:jni/jni.dart'; +import 'package:path/path.dart'; + +// Import the generated bindings. +// Note: the structure generated bindings corresponds to Java package's +// structure. Therefore, `org.apache.pdfbox.pdmodel` package becomes +// `org/apache/pdfbox/pdmodel.dart` +import 'package:pdfbox_plugin/third_party/org/apache/pdfbox/pdmodel.dart'; + +Stream files(String dir) => Directory(dir).list().map((e) => e.path); + +late Jni jni; +const jarError = 'No JAR files were found.\n' + 'Run `dart run jni_gen:download_maven_jars --config jnigen.yaml` ' + 'in plugin directory.\n' + 'Alternatively, regenerate JNI bindings in plugin directory, which will ' + 'automatically download the JAR files.'; + +void main() { + if (!Platform.isAndroid) { + // Assuming application is run from example/ folder + // It's required to manually provide the JAR files as classpath when + // spawning the JVM. + const jarDir = '../mvn_jar/'; + List jars; + try { + jars = Directory(jarDir) + .listSync() + .map((e) => e.path) + .where((path) => path.endsWith('.jar')) + .toList(); + } on OSError catch (_) { + stderr.writeln(jarError); + return; + } + if (jars.isEmpty) { + stderr.writeln(jarError); + return; + } + Jni.spawn(classPath: jars); + } + jni = Jni.getInstance(); + runApp(const PDFInfoApp()); +} + +class PDFInfoApp extends StatefulWidget { + const PDFInfoApp({super.key}); + + @override + PDFInfoAppState createState() => PDFInfoAppState(); +} + +class PDFInfoAppState extends State { + bool _isLoading = true; + String _dir = '.'; + List _pdfs = []; + List _dirs = []; + + void setDir(String dir) async { + final pdfs = []; + final dirs = []; + + setState(() => _isLoading = true); + + await for (var item in Directory(dir).list()) { + final isDir = (await item.stat()).type == FileSystemEntityType.directory; + if (item.path.endsWith('.pdf') && !isDir) { + pdfs.add(item.path); + } else if (isDir) { + dirs.add(item.path); + } + } + setState(() { + _isLoading = false; + _dir = dir; + _pdfs = pdfs; + _dirs = dirs; + }); + } + + @override + void initState() { + super.initState(); + final dir = Platform.environment['HOME'] ?? '.'; + setDir(dir); + } + + @override + Widget build(BuildContext context) { + final dirBaseName = basename(_dir); + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: Text('PDF Info: $dirBaseName'), + ), + body: SingleChildScrollView( + child: Container( + padding: const EdgeInsets.all(10), + child: _isLoading + ? const Text('loading...') + : Table(border: TableBorder.all(), children: [ + TableRow(children: [ + for (var heading in ['File', 'Title', 'Pages']) + TableCell( + child: _pad(Text(heading, + style: const TextStyle( + fontSize: 16, + decoration: TextDecoration.underline)))), + ]), + TableRow(children: [ + TableCell( + child: _pad( + InkWell( + child: const Text('..'), + onTap: () => setDir(dirname(_dir)), + ), + ), + ), + const TableCell(child: Text('')), + const TableCell(child: Text('')), + ]), + for (var dir in _dirs) _dirTile(basename(dir)), + for (var pdfname in _pdfs) + _pdfInfo(PDFFileInfo.usingPDFBox(pdfname)), + ])), + ), + ), + ); + } + + TableRow _dirTile(String target) { + return TableRow(children: [ + TableCell( + child: _pad( + InkWell( + onTap: () => setDir(join(_dir, target)), + child: Text( + target, + style: const TextStyle(fontWeight: FontWeight.bold), + ), + ), + ), + ), + const TableCell(child: Text('-')), + const TableCell(child: Text('-')), + ]); + } +} + +// It's generally a good practice to separate JNI calls from UI / model code. +class PDFFileInfo { + String filename; + late String author, subject, title; + late int numPages; + + /// Converts JlString to dart string and deletes the original. + String _fromJavaStr(JlString jstr) { + if (jstr.reference == nullptr) { + return '(null)'; + } + final result = jstr.toDartString(); + jstr.delete(); + return result; + } + + PDFFileInfo.usingPDFBox(this.filename) { + // Since java.io is not directly available, use package:jni API to + // create a java.io.File object. + final inputFile = + jni.newInstance("java/io/File", "(Ljava/lang/String;)V", [filename]); + final inputJl = JlObject.fromRef(inputFile.jobject); + + // Static method call PDDocument.load -> PDDocument + final pdf = PDDocument.load(inputJl); + // Instance method call getNumberOfPages() -> int + numPages = pdf.getNumberOfPages(); + // Instance method that returns an object + final info = pdf.getDocumentInformation(); + + /// java.lang.String is a special case and is mapped to JlString which is + /// a subclass of JlObject. + author = _fromJavaStr(info.getAuthor()); + title = _fromJavaStr(info.getTitle()); + subject = _fromJavaStr(info.getSubject()); + + /// Delete objects after done. + info.delete(); + pdf.close(); + pdf.delete(); + inputFile.delete(); + } +} + +Padding _pad(Widget w) => Padding( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), child: w); + +TableRow _pdfInfo(PDFFileInfo info) { + return TableRow(children: [ + TableCell( + child: _pad(Text(basename(info.filename), + style: const TextStyle(fontWeight: FontWeight.bold)))), + TableCell(child: _pad(Text(info.title))), + TableCell( + child: _pad(Text(info.numPages.toString(), + style: const TextStyle(color: Colors.grey)))), + ]); +} diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/linux/.gitignore b/pkgs/jni_gen/examples/pdfbox_plugin/example/linux/.gitignore new file mode 100644 index 000000000..d3896c984 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/linux/.gitignore @@ -0,0 +1 @@ +flutter/ephemeral diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/linux/CMakeLists.txt b/pkgs/jni_gen/examples/pdfbox_plugin/example/linux/CMakeLists.txt new file mode 100644 index 000000000..f36768d83 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/linux/CMakeLists.txt @@ -0,0 +1,138 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.10) +project(runner LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "pdfbox_plugin_example") +# The unique GTK application identifier for this application. See: +# https://wiki.gnome.org/HowDoI/ChooseApplicationID +set(APPLICATION_ID "com.example.pdfbox_plugin") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(SET CMP0063 NEW) + +# Load bundled libraries from the lib/ directory relative to the binary. +set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") + +# Root filesystem for cross-building. +if(FLUTTER_TARGET_PLATFORM_SYSROOT) + set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endif() + +# Define build configuration options. +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") +endif() + +# Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_14) + target_compile_options(${TARGET} PRIVATE -Wall -Werror) + target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") + target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) + +add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") + +# Define the application target. To change its name, change BINARY_NAME above, +# not the value here, or `flutter run` will no longer work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} + "main.cc" + "my_application.cc" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add dependency libraries. Add any application-specific dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter) +target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) + +# Only the install-generated bundle's copy of the executable will launch +# correctly, since the resources must in the right relative locations. To avoid +# people trying to run the unbundled copy, put it in a subdirectory instead of +# the default top-level location. +set_target_properties(${BINARY_NAME} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" +) + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# By default, "installing" just makes a relocatable bundle in the build +# directory. +set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +# Start with a clean build bundle directory every time. +install(CODE " + file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") + " COMPONENT Runtime) + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) + install(FILES "${bundled_library}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endforeach(bundled_library) + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") + install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/linux/flutter/CMakeLists.txt b/pkgs/jni_gen/examples/pdfbox_plugin/example/linux/flutter/CMakeLists.txt new file mode 100644 index 000000000..d5bd01648 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/linux/flutter/CMakeLists.txt @@ -0,0 +1,88 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.10) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. + +# Serves the same purpose as list(TRANSFORM ... PREPEND ...), +# which isn't available in 3.10. +function(list_prepend LIST_NAME PREFIX) + set(NEW_LIST "") + foreach(element ${${LIST_NAME}}) + list(APPEND NEW_LIST "${PREFIX}${element}") + endforeach(element) + set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) +endfunction() + +# === Flutter Library === +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) +pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) +pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) + +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "fl_basic_message_channel.h" + "fl_binary_codec.h" + "fl_binary_messenger.h" + "fl_dart_project.h" + "fl_engine.h" + "fl_json_message_codec.h" + "fl_json_method_codec.h" + "fl_message_codec.h" + "fl_method_call.h" + "fl_method_channel.h" + "fl_method_codec.h" + "fl_method_response.h" + "fl_plugin_registrar.h" + "fl_plugin_registry.h" + "fl_standard_message_codec.h" + "fl_standard_method_codec.h" + "fl_string_codec.h" + "fl_value.h" + "fl_view.h" + "flutter_linux.h" +) +list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") +target_link_libraries(flutter INTERFACE + PkgConfig::GTK + PkgConfig::GLIB + PkgConfig::GIO +) +add_dependencies(flutter flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CMAKE_CURRENT_BINARY_DIR}/_phony_ + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" + ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} +) diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/linux/flutter/generated_plugin_registrant.cc b/pkgs/jni_gen/examples/pdfbox_plugin/example/linux/flutter/generated_plugin_registrant.cc new file mode 100644 index 000000000..e71a16d23 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/linux/flutter/generated_plugin_registrant.cc @@ -0,0 +1,11 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + + +void fl_register_plugins(FlPluginRegistry* registry) { +} diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/linux/flutter/generated_plugin_registrant.h b/pkgs/jni_gen/examples/pdfbox_plugin/example/linux/flutter/generated_plugin_registrant.h new file mode 100644 index 000000000..e0f0a47bc --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/linux/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void fl_register_plugins(FlPluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/linux/flutter/generated_plugins.cmake b/pkgs/jni_gen/examples/pdfbox_plugin/example/linux/flutter/generated_plugins.cmake new file mode 100644 index 000000000..d2cbe738d --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/linux/flutter/generated_plugins.cmake @@ -0,0 +1,25 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST + jni + pdfbox_plugin +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/linux/main.cc b/pkgs/jni_gen/examples/pdfbox_plugin/example/linux/main.cc new file mode 100644 index 000000000..e7c5c5437 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/linux/main.cc @@ -0,0 +1,6 @@ +#include "my_application.h" + +int main(int argc, char** argv) { + g_autoptr(MyApplication) app = my_application_new(); + return g_application_run(G_APPLICATION(app), argc, argv); +} diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/linux/my_application.cc b/pkgs/jni_gen/examples/pdfbox_plugin/example/linux/my_application.cc new file mode 100644 index 000000000..b13351b69 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/linux/my_application.cc @@ -0,0 +1,104 @@ +#include "my_application.h" + +#include +#ifdef GDK_WINDOWING_X11 +#include +#endif + +#include "flutter/generated_plugin_registrant.h" + +struct _MyApplication { + GtkApplication parent_instance; + char** dart_entrypoint_arguments; +}; + +G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) + +// Implements GApplication::activate. +static void my_application_activate(GApplication* application) { + MyApplication* self = MY_APPLICATION(application); + GtkWindow* window = + GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); + + // Use a header bar when running in GNOME as this is the common style used + // by applications and is the setup most users will be using (e.g. Ubuntu + // desktop). + // If running on X and not using GNOME then just use a traditional title bar + // in case the window manager does more exotic layout, e.g. tiling. + // If running on Wayland assume the header bar will work (may need changing + // if future cases occur). + gboolean use_header_bar = TRUE; +#ifdef GDK_WINDOWING_X11 + GdkScreen* screen = gtk_window_get_screen(window); + if (GDK_IS_X11_SCREEN(screen)) { + const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); + if (g_strcmp0(wm_name, "GNOME Shell") != 0) { + use_header_bar = FALSE; + } + } +#endif + if (use_header_bar) { + GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); + gtk_widget_show(GTK_WIDGET(header_bar)); + gtk_header_bar_set_title(header_bar, "pdfbox_plugin_example"); + gtk_header_bar_set_show_close_button(header_bar, TRUE); + gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); + } else { + gtk_window_set_title(window, "pdfbox_plugin_example"); + } + + gtk_window_set_default_size(window, 1280, 720); + gtk_widget_show(GTK_WIDGET(window)); + + g_autoptr(FlDartProject) project = fl_dart_project_new(); + fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); + + FlView* view = fl_view_new(project); + gtk_widget_show(GTK_WIDGET(view)); + gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); + + fl_register_plugins(FL_PLUGIN_REGISTRY(view)); + + gtk_widget_grab_focus(GTK_WIDGET(view)); +} + +// Implements GApplication::local_command_line. +static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { + MyApplication* self = MY_APPLICATION(application); + // Strip out the first argument as it is the binary name. + self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); + + g_autoptr(GError) error = nullptr; + if (!g_application_register(application, nullptr, &error)) { + g_warning("Failed to register: %s", error->message); + *exit_status = 1; + return TRUE; + } + + g_application_activate(application); + *exit_status = 0; + + return TRUE; +} + +// Implements GObject::dispose. +static void my_application_dispose(GObject* object) { + MyApplication* self = MY_APPLICATION(object); + g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); + G_OBJECT_CLASS(my_application_parent_class)->dispose(object); +} + +static void my_application_class_init(MyApplicationClass* klass) { + G_APPLICATION_CLASS(klass)->activate = my_application_activate; + G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; + G_OBJECT_CLASS(klass)->dispose = my_application_dispose; +} + +static void my_application_init(MyApplication* self) {} + +MyApplication* my_application_new() { + return MY_APPLICATION(g_object_new(my_application_get_type(), + "application-id", APPLICATION_ID, + "flags", G_APPLICATION_NON_UNIQUE, + nullptr)); +} diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/linux/my_application.h b/pkgs/jni_gen/examples/pdfbox_plugin/example/linux/my_application.h new file mode 100644 index 000000000..72271d5e4 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/linux/my_application.h @@ -0,0 +1,18 @@ +#ifndef FLUTTER_MY_APPLICATION_H_ +#define FLUTTER_MY_APPLICATION_H_ + +#include + +G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, + GtkApplication) + +/** + * my_application_new: + * + * Creates a new Flutter-based application. + * + * Returns: a new #MyApplication. + */ +MyApplication* my_application_new(); + +#endif // FLUTTER_MY_APPLICATION_H_ diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/pubspec.yaml b/pkgs/jni_gen/examples/pdfbox_plugin/example/pubspec.yaml new file mode 100644 index 000000000..ce5dd42ee --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/pubspec.yaml @@ -0,0 +1,99 @@ +name: pdfbox_example +description: Demonstrates how to use the pdfbox_plugin plugin. + +# The following line prevents the package from being accidentally published to +# pub.dev using `flutter pub publish`. This is preferred for private packages. +publish_to: 'none' # Remove this line if you wish to publish to pub.dev + +# The following defines the version and build number for your application. +# A version number is three numbers separated by dots, like 1.2.43 +# followed by an optional build number separated by a +. +# Both the version and the builder number may be overridden in flutter +# build by specifying --build-name and --build-number, respectively. +# In Android, build-name is used as versionName while build-number used as versionCode. +# Read more about Android versioning at https://developer.android.com/studio/publish/versioning +# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. +# Read more about iOS versioning at +# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html +version: 1.0.0+1 + +environment: + sdk: ">=2.17.6 <3.0.0" + +# Dependencies specify other packages that your package needs in order to work. +# To automatically upgrade your package dependencies to the latest versions +# consider running `flutter pub upgrade --major-versions`. Alternatively, +# dependencies can be manually updated by changing the version numbers below to +# the latest version available on pub.dev. To see which dependencies have newer +# versions available, run `flutter pub outdated`. +dependencies: + flutter: + sdk: flutter + + jni: + path: ../../../../jni/ + path: ^1.8.0 + pdfbox_plugin: + # When depending on this package from a real application you should use: + # pdfbox_plugin: ^x.y.z + # See https://dart.dev/tools/pub/dependencies#version-constraints + # The example app is bundled with the plugin so we use a path dependency on + # the parent directory to use the current plugin's version. + path: ../ + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^1.0.2 + +dev_dependencies: + flutter_test: + sdk: flutter + + # The "flutter_lints" package below contains a set of recommended lints to + # encourage good coding practices. The lint set provided by the package is + # activated in the `analysis_options.yaml` file located at the root of your + # package. See that file for information about deactivating specific lint + # rules and activating additional ones. + flutter_lints: ^2.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + + # To add assets to your application, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/assets-and-images/#from-packages + + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/custom-fonts/#from-packages diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/.gitignore b/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/.gitignore new file mode 100644 index 000000000..d492d0d98 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/.gitignore @@ -0,0 +1,17 @@ +flutter/ephemeral/ + +# Visual Studio user-specific files. +*.suo +*.user +*.userosscache +*.sln.docstates + +# Visual Studio build-related files. +x64/ +x86/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/CMakeLists.txt b/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/CMakeLists.txt new file mode 100644 index 000000000..c23339761 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/CMakeLists.txt @@ -0,0 +1,101 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.14) +project(pdfbox_plugin_example LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "pdfbox_plugin_example") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(SET CMP0063 NEW) + +# Define build configuration option. +get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(IS_MULTICONFIG) + set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" + CACHE STRING "" FORCE) +else() + if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") + endif() +endif() +# Define settings for the Profile build mode. +set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") +set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") +set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") +set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") + +# Use Unicode for all projects. +add_definitions(-DUNICODE -D_UNICODE) + +# Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_17) + target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") + target_compile_options(${TARGET} PRIVATE /EHsc) + target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") + target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# Application build; see runner/CMakeLists.txt. +add_subdirectory("runner") + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# Support files are copied into place next to the executable, so that it can +# run in place. This is done instead of making a separate bundle (as on Linux) +# so that building and running from within Visual Studio will work. +set(BUILD_BUNDLE_DIR "$") +# Make the "install" step default, as it's required to run. +set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +if(PLUGIN_BUNDLED_LIBRARIES) + install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + CONFIGURATIONS Profile;Release + COMPONENT Runtime) diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/flutter/CMakeLists.txt b/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/flutter/CMakeLists.txt new file mode 100644 index 000000000..930d2071a --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/flutter/CMakeLists.txt @@ -0,0 +1,104 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.14) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. +set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") + +# === Flutter Library === +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "flutter_export.h" + "flutter_windows.h" + "flutter_messenger.h" + "flutter_plugin_registrar.h" + "flutter_texture_registrar.h" +) +list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") +add_dependencies(flutter flutter_assemble) + +# === Wrapper === +list(APPEND CPP_WRAPPER_SOURCES_CORE + "core_implementations.cc" + "standard_codec.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_PLUGIN + "plugin_registrar.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_APP + "flutter_engine.cc" + "flutter_view_controller.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") + +# Wrapper sources needed for a plugin. +add_library(flutter_wrapper_plugin STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} +) +apply_standard_settings(flutter_wrapper_plugin) +set_target_properties(flutter_wrapper_plugin PROPERTIES + POSITION_INDEPENDENT_CODE ON) +set_target_properties(flutter_wrapper_plugin PROPERTIES + CXX_VISIBILITY_PRESET hidden) +target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) +target_include_directories(flutter_wrapper_plugin PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_plugin flutter_assemble) + +# Wrapper sources needed for the runner. +add_library(flutter_wrapper_app STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_APP} +) +apply_standard_settings(flutter_wrapper_app) +target_link_libraries(flutter_wrapper_app PUBLIC flutter) +target_include_directories(flutter_wrapper_app PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_app flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") +set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} + ${PHONY_OUTPUT} + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" + windows-x64 $ + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} +) diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/flutter/generated_plugin_registrant.cc b/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/flutter/generated_plugin_registrant.cc new file mode 100644 index 000000000..8b6d4680a --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/flutter/generated_plugin_registrant.cc @@ -0,0 +1,11 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + + +void RegisterPlugins(flutter::PluginRegistry* registry) { +} diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/flutter/generated_plugin_registrant.h b/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/flutter/generated_plugin_registrant.h new file mode 100644 index 000000000..dc139d85a --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void RegisterPlugins(flutter::PluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/flutter/generated_plugins.cmake b/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/flutter/generated_plugins.cmake new file mode 100644 index 000000000..facaded73 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/flutter/generated_plugins.cmake @@ -0,0 +1,25 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST + jni + pdfbox_plugin +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/CMakeLists.txt b/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/CMakeLists.txt new file mode 100644 index 000000000..b9e550fba --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/CMakeLists.txt @@ -0,0 +1,32 @@ +cmake_minimum_required(VERSION 3.14) +project(runner LANGUAGES CXX) + +# Define the application target. To change its name, change BINARY_NAME in the +# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer +# work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} WIN32 + "flutter_window.cpp" + "main.cpp" + "utils.cpp" + "win32_window.cpp" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" + "Runner.rc" + "runner.exe.manifest" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Disable Windows macros that collide with C++ standard library functions. +target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") + +# Add dependency libraries and include directories. Add any application-specific +# dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) +target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/Runner.rc b/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/Runner.rc new file mode 100644 index 000000000..05d079f5f --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/Runner.rc @@ -0,0 +1,121 @@ +// Microsoft Visual C++ generated resource script. +// +#pragma code_page(65001) +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_APP_ICON ICON "resources\\app_icon.ico" + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +#ifdef FLUTTER_BUILD_NUMBER +#define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER +#else +#define VERSION_AS_NUMBER 1,0,0 +#endif + +#ifdef FLUTTER_BUILD_NAME +#define VERSION_AS_STRING #FLUTTER_BUILD_NAME +#else +#define VERSION_AS_STRING "1.0.0" +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION VERSION_AS_NUMBER + PRODUCTVERSION VERSION_AS_NUMBER + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904e4" + BEGIN + VALUE "CompanyName", "com.example" "\0" + VALUE "FileDescription", "pdfbox_plugin_example" "\0" + VALUE "FileVersion", VERSION_AS_STRING "\0" + VALUE "InternalName", "pdfbox_plugin_example" "\0" + VALUE "LegalCopyright", "Copyright (C) 2022 com.example. All rights reserved." "\0" + VALUE "OriginalFilename", "pdfbox_plugin_example.exe" "\0" + VALUE "ProductName", "pdfbox_plugin_example" "\0" + VALUE "ProductVersion", VERSION_AS_STRING "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END +END + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/flutter_window.cpp b/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/flutter_window.cpp new file mode 100644 index 000000000..b43b9095e --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/flutter_window.cpp @@ -0,0 +1,61 @@ +#include "flutter_window.h" + +#include + +#include "flutter/generated_plugin_registrant.h" + +FlutterWindow::FlutterWindow(const flutter::DartProject& project) + : project_(project) {} + +FlutterWindow::~FlutterWindow() {} + +bool FlutterWindow::OnCreate() { + if (!Win32Window::OnCreate()) { + return false; + } + + RECT frame = GetClientArea(); + + // The size here must match the window dimensions to avoid unnecessary surface + // creation / destruction in the startup path. + flutter_controller_ = std::make_unique( + frame.right - frame.left, frame.bottom - frame.top, project_); + // Ensure that basic setup of the controller was successful. + if (!flutter_controller_->engine() || !flutter_controller_->view()) { + return false; + } + RegisterPlugins(flutter_controller_->engine()); + SetChildContent(flutter_controller_->view()->GetNativeWindow()); + return true; +} + +void FlutterWindow::OnDestroy() { + if (flutter_controller_) { + flutter_controller_ = nullptr; + } + + Win32Window::OnDestroy(); +} + +LRESULT +FlutterWindow::MessageHandler(HWND hwnd, UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + // Give Flutter, including plugins, an opportunity to handle window messages. + if (flutter_controller_) { + std::optional result = + flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, + lparam); + if (result) { + return *result; + } + } + + switch (message) { + case WM_FONTCHANGE: + flutter_controller_->engine()->ReloadSystemFonts(); + break; + } + + return Win32Window::MessageHandler(hwnd, message, wparam, lparam); +} diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/flutter_window.h b/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/flutter_window.h new file mode 100644 index 000000000..6da0652f0 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/flutter_window.h @@ -0,0 +1,33 @@ +#ifndef RUNNER_FLUTTER_WINDOW_H_ +#define RUNNER_FLUTTER_WINDOW_H_ + +#include +#include + +#include + +#include "win32_window.h" + +// A window that does nothing but host a Flutter view. +class FlutterWindow : public Win32Window { + public: + // Creates a new FlutterWindow hosting a Flutter view running |project|. + explicit FlutterWindow(const flutter::DartProject& project); + virtual ~FlutterWindow(); + + protected: + // Win32Window: + bool OnCreate() override; + void OnDestroy() override; + LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, + LPARAM const lparam) noexcept override; + + private: + // The project to run. + flutter::DartProject project_; + + // The Flutter instance hosted by this window. + std::unique_ptr flutter_controller_; +}; + +#endif // RUNNER_FLUTTER_WINDOW_H_ diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/main.cpp b/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/main.cpp new file mode 100644 index 000000000..44bdbc6f5 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/main.cpp @@ -0,0 +1,43 @@ +#include +#include +#include + +#include "flutter_window.h" +#include "utils.h" + +int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, + _In_ wchar_t *command_line, _In_ int show_command) { + // Attach to console when present (e.g., 'flutter run') or create a + // new console when running with a debugger. + if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { + CreateAndAttachConsole(); + } + + // Initialize COM, so that it is available for use in the library and/or + // plugins. + ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); + + flutter::DartProject project(L"data"); + + std::vector command_line_arguments = + GetCommandLineArguments(); + + project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); + + FlutterWindow window(project); + Win32Window::Point origin(10, 10); + Win32Window::Size size(1280, 720); + if (!window.CreateAndShow(L"pdfbox_plugin_example", origin, size)) { + return EXIT_FAILURE; + } + window.SetQuitOnClose(true); + + ::MSG msg; + while (::GetMessage(&msg, nullptr, 0, 0)) { + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + } + + ::CoUninitialize(); + return EXIT_SUCCESS; +} diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/resource.h b/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/resource.h new file mode 100644 index 000000000..66a65d1e4 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Runner.rc +// +#define IDI_APP_ICON 101 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/resources/app_icon.ico b/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/resources/app_icon.ico new file mode 100644 index 0000000000000000000000000000000000000000..c04e20caf6370ebb9253ad831cc31de4a9c965f6 GIT binary patch literal 33772 zcmeHQc|26z|35SKE&G-*mXah&B~fFkXr)DEO&hIfqby^T&>|8^_Ub8Vp#`BLl3lbZ zvPO!8k!2X>cg~Elr=IVxo~J*a`+9wR=A83c-k-DFd(XM&UI1VKCqM@V;DDtJ09WB} zRaHKiW(GT00brH|0EeTeKVbpbGZg?nK6-j827q-+NFM34gXjqWxJ*a#{b_apGN<-L_m3#8Z26atkEn& ze87Bvv^6vVmM+p+cQ~{u%=NJF>#(d;8{7Q{^rWKWNtf14H}>#&y7$lqmY6xmZryI& z($uy?c5-+cPnt2%)R&(KIWEXww>Cnz{OUpT>W$CbO$h1= z#4BPMkFG1Y)x}Ui+WXr?Z!w!t_hjRq8qTaWpu}FH{MsHlU{>;08goVLm{V<&`itk~ zE_Ys=D(hjiy+5=?=$HGii=Y5)jMe9|wWoD_K07(}edAxh`~LBorOJ!Cf@f{_gNCC| z%{*04ViE!#>@hc1t5bb+NO>ncf@@Dv01K!NxH$3Eg1%)|wLyMDF8^d44lV!_Sr}iEWefOaL z8f?ud3Q%Sen39u|%00W<#!E=-RpGa+H8}{ulxVl4mwpjaU+%2pzmi{3HM)%8vb*~-M9rPUAfGCSos8GUXp02|o~0BTV2l#`>>aFV&_P$ejS;nGwSVP8 zMbOaG7<7eKD>c12VdGH;?2@q7535sa7MN*L@&!m?L`ASG%boY7(&L5imY#EQ$KrBB z4@_tfP5m50(T--qv1BJcD&aiH#b-QC>8#7Fx@3yXlonJI#aEIi=8&ChiVpc#N=5le zM*?rDIdcpawoc5kizv$GEjnveyrp3sY>+5_R5;>`>erS%JolimF=A^EIsAK zsPoVyyUHCgf0aYr&alx`<)eb6Be$m&`JYSuBu=p8j%QlNNp$-5C{b4#RubPb|CAIS zGE=9OFLP7?Hgc{?k45)84biT0k&-C6C%Q}aI~q<(7BL`C#<6HyxaR%!dFx7*o^laG z=!GBF^cwK$IA(sn9y6>60Rw{mYRYkp%$jH z*xQM~+bp)G$_RhtFPYx2HTsWk80+p(uqv9@I9)y{b$7NK53rYL$ezbmRjdXS?V}fj zWxX_feWoLFNm3MG7pMUuFPs$qrQWO9!l2B(SIuy2}S|lHNbHzoE+M2|Zxhjq9+Ws8c{*}x^VAib7SbxJ*Q3EnY5lgI9 z=U^f3IW6T=TWaVj+2N%K3<%Un;CF(wUp`TC&Y|ZjyFu6co^uqDDB#EP?DV5v_dw~E zIRK*BoY9y-G_ToU2V_XCX4nJ32~`czdjT!zwme zGgJ0nOk3U4@IE5JwtM}pwimLjk{ln^*4HMU%Fl4~n(cnsLB}Ja-jUM>xIB%aY;Nq8 z)Fp8dv1tkqKanv<68o@cN|%thj$+f;zGSO7H#b+eMAV8xH$hLggtt?O?;oYEgbq@= zV(u9bbd12^%;?nyk6&$GPI%|+<_mEpJGNfl*`!KV;VfmZWw{n{rnZ51?}FDh8we_L z8OI9nE31skDqJ5Oa_ybn7|5@ui>aC`s34p4ZEu6-s!%{uU45$Zd1=p$^^dZBh zu<*pDDPLW+c>iWO$&Z_*{VSQKg7=YEpS3PssPn1U!lSm6eZIho*{@&20e4Y_lRklKDTUCKI%o4Pc<|G^Xgu$J^Q|B87U;`c1zGwf^-zH*VQ^x+i^OUWE0yd z;{FJq)2w!%`x7yg@>uGFFf-XJl4H`YtUG%0slGKOlXV`q?RP>AEWg#x!b{0RicxGhS!3$p7 zij;{gm!_u@D4$Ox%>>bPtLJ> zwKtYz?T_DR1jN>DkkfGU^<#6sGz|~p*I{y`aZ>^Di#TC|Z!7j_O1=Wo8thuit?WxR zh9_S>kw^{V^|g}HRUF=dcq>?q(pHxw!8rx4dC6vbQVmIhmICF#zU!HkHpQ>9S%Uo( zMw{eC+`&pb=GZRou|3;Po1}m46H6NGd$t<2mQh}kaK-WFfmj_66_17BX0|j-E2fe3Jat}ijpc53 zJV$$;PC<5aW`{*^Z6e5##^`Ed#a0nwJDT#Qq~^e8^JTA=z^Kl>La|(UQ!bI@#ge{Dzz@61p-I)kc2?ZxFt^QQ}f%ldLjO*GPj(5)V9IyuUakJX=~GnTgZ4$5!3E=V#t`yOG4U z(gphZB6u2zsj=qNFLYShhg$}lNpO`P9xOSnO*$@@UdMYES*{jJVj|9z-}F^riksLK zbsU+4-{281P9e2UjY6tse^&a)WM1MFw;p#_dHhWI7p&U*9TR0zKdVuQed%6{otTsq z$f~S!;wg#Bd9kez=Br{m|66Wv z#g1xMup<0)H;c2ZO6su_ii&m8j&+jJz4iKnGZ&wxoQX|5a>v&_e#6WA!MB_4asTxLRGQCC5cI(em z%$ZfeqP>!*q5kU>a+BO&ln=4Jm>Ef(QE8o&RgLkk%2}4Tf}U%IFP&uS7}&|Q-)`5< z+e>;s#4cJ-z%&-^&!xsYx777Wt(wZY9(3(avmr|gRe4cD+a8&!LY`1^T?7x{E<=kdY9NYw>A;FtTvQ=Y&1M%lyZPl$ss1oY^Sl8we}n}Aob#6 zl4jERwnt9BlSoWb@3HxYgga(752Vu6Y)k4yk9u~Kw>cA5&LHcrvn1Y-HoIuFWg~}4 zEw4bR`mXZQIyOAzo)FYqg?$5W<;^+XX%Uz61{-L6@eP|lLH%|w?g=rFc;OvEW;^qh z&iYXGhVt(G-q<+_j}CTbPS_=K>RKN0&;dubh0NxJyDOHFF;<1k!{k#7b{|Qok9hac z;gHz}6>H6C6RnB`Tt#oaSrX0p-j-oRJ;_WvS-qS--P*8}V943RT6kou-G=A+7QPGQ z!ze^UGxtW3FC0$|(lY9^L!Lx^?Q8cny(rR`es5U;-xBhphF%_WNu|aO<+e9%6LuZq zt(0PoagJG<%hyuf;te}n+qIl_Ej;czWdc{LX^pS>77s9t*2b4s5dvP_!L^3cwlc)E!(!kGrg~FescVT zZCLeua3f4;d;Tk4iXzt}g}O@nlK3?_o91_~@UMIl?@77Qc$IAlLE95#Z=TES>2E%z zxUKpK{_HvGF;5%Q7n&vA?`{%8ohlYT_?(3A$cZSi)MvIJygXD}TS-3UwyUxGLGiJP znblO~G|*uA^|ac8E-w#}uBtg|s_~s&t>-g0X%zIZ@;o_wNMr_;{KDg^O=rg`fhDZu zFp(VKd1Edj%F zWHPl+)FGj%J1BO3bOHVfH^3d1F{)*PL&sRX`~(-Zy3&9UQX)Z;c51tvaI2E*E7!)q zcz|{vpK7bjxix(k&6=OEIBJC!9lTkUbgg?4-yE{9+pFS)$Ar@vrIf`D0Bnsed(Cf? zObt2CJ>BKOl>q8PyFO6w)+6Iz`LW%T5^R`U_NIW0r1dWv6OY=TVF?N=EfA(k(~7VBW(S;Tu5m4Lg8emDG-(mOSSs=M9Q&N8jc^Y4&9RqIsk(yO_P(mcCr}rCs%1MW1VBrn=0-oQN(Xj!k%iKV zb%ricBF3G4S1;+8lzg5PbZ|$Se$)I=PwiK=cDpHYdov2QO1_a-*dL4KUi|g&oh>(* zq$<`dQ^fat`+VW?m)?_KLn&mp^-@d=&7yGDt<=XwZZC=1scwxO2^RRI7n@g-1o8ps z)&+et_~)vr8aIF1VY1Qrq~Xe``KJrQSnAZ{CSq3yP;V*JC;mmCT6oRLSs7=GA?@6g zUooM}@tKtx(^|aKK8vbaHlUQqwE0}>j&~YlN3H#vKGm@u)xxS?n9XrOWUfCRa< z`20Fld2f&;gg7zpo{Adh+mqNntMc-D$N^yWZAZRI+u1T1zWHPxk{+?vcS1D>08>@6 zLhE@`gt1Y9mAK6Z4p|u(5I%EkfU7rKFSM=E4?VG9tI;a*@?6!ey{lzN5=Y-!$WFSe z&2dtO>^0@V4WRc#L&P%R(?@KfSblMS+N+?xUN$u3K4Ys%OmEh+tq}fnU}i>6YHM?< zlnL2gl~sF!j!Y4E;j3eIU-lfa`RsOL*Tt<%EFC0gPzoHfNWAfKFIKZN8}w~(Yi~=q z>=VNLO2|CjkxP}RkutxjV#4fWYR1KNrPYq5ha9Wl+u>ipsk*I(HS@iLnmGH9MFlTU zaFZ*KSR0px>o+pL7BbhB2EC1%PJ{67_ z#kY&#O4@P=OV#-79y_W>Gv2dxL*@G7%LksNSqgId9v;2xJ zrh8uR!F-eU$NMx@S*+sk=C~Dxr9Qn7TfWnTupuHKuQ$;gGiBcU>GF5sWx(~4IP3`f zWE;YFO*?jGwYh%C3X<>RKHC-DZ!*r;cIr}GLOno^3U4tFSSoJp%oHPiSa%nh=Zgn% z14+8v@ygy0>UgEN1bczD6wK45%M>psM)y^)IfG*>3ItX|TzV*0i%@>L(VN!zdKb8S?Qf7BhjNpziA zR}?={-eu>9JDcl*R=OP9B8N$IcCETXah9SUDhr{yrld{G;PnCWRsPD7!eOOFBTWUQ=LrA_~)mFf&!zJX!Oc-_=kT<}m|K52 z)M=G#;p;Rdb@~h5D{q^K;^fX-m5V}L%!wVC2iZ1uu401Ll}#rocTeK|7FAeBRhNdQ zCc2d^aQnQp=MpOmak60N$OgS}a;p(l9CL`o4r(e-nN}mQ?M&isv-P&d$!8|1D1I(3-z!wi zTgoo)*Mv`gC?~bm?S|@}I|m-E2yqPEvYybiD5azInexpK8?9q*$9Yy9-t%5jU8~ym zgZDx>!@ujQ=|HJnwp^wv-FdD{RtzO9SnyfB{mH_(c!jHL*$>0o-(h(eqe*ZwF6Lvu z{7rkk%PEqaA>o+f{H02tzZ@TWy&su?VNw43! z-X+rN`6llvpUms3ZiSt)JMeztB~>9{J8SPmYs&qohxdYFi!ra8KR$35Zp9oR)eFC4 zE;P31#3V)n`w$fZ|4X-|%MX`xZDM~gJyl2W;O$H25*=+1S#%|53>|LyH za@yh+;325%Gq3;J&a)?%7X%t@WXcWL*BaaR*7UEZad4I8iDt7^R_Fd`XeUo256;sAo2F!HcIQKk;h})QxEsPE5BcKc7WyerTchgKmrfRX z!x#H_%cL#B9TWAqkA4I$R^8{%do3Y*&(;WFmJ zU7Dih{t1<{($VtJRl9|&EB?|cJ)xse!;}>6mSO$o5XIx@V|AA8ZcoD88ZM?C*;{|f zZVmf94_l1OmaICt`2sTyG!$^UeTHx9YuUP!omj(r|7zpm5475|yXI=rR>>fteLI+| z)MoiGho0oEt=*J(;?VY0QzwCqw@cVm?d7Y!z0A@u#H?sCJ*ecvyhj& z-F77lO;SH^dmf?L>3i>?Z*U}Em4ZYV_CjgfvzYsRZ+1B!Uo6H6mbS<-FFL`ytqvb& zE7+)2ahv-~dz(Hs+f})z{*4|{)b=2!RZK;PWwOnO=hG7xG`JU5>bAvUbdYd_CjvtHBHgtGdlO+s^9ca^Bv3`t@VRX2_AD$Ckg36OcQRF zXD6QtGfHdw*hx~V(MV-;;ZZF#dJ-piEF+s27z4X1qi5$!o~xBnvf=uopcn7ftfsZc zy@(PuOk`4GL_n(H9(E2)VUjqRCk9kR?w)v@xO6Jm_Mx})&WGEl=GS0#)0FAq^J*o! zAClhvoTsNP*-b~rN{8Yym3g{01}Ep^^Omf=SKqvN?{Q*C4HNNAcrowIa^mf+3PRy! z*_G-|3i8a;+q;iP@~Of_$(vtFkB8yOyWt2*K)vAn9El>=D;A$CEx6b*XF@4y_6M+2 zpeW`RHoI_p(B{%(&jTHI->hmNmZjHUj<@;7w0mx3&koy!2$@cfX{sN19Y}euYJFn& z1?)+?HCkD0MRI$~uB2UWri})0bru_B;klFdwsLc!ne4YUE;t41JqfG# zZJq6%vbsdx!wYeE<~?>o4V`A3?lN%MnKQ`z=uUivQN^vzJ|C;sdQ37Qn?;lpzg})y z)_2~rUdH}zNwX;Tp0tJ78+&I=IwOQ-fl30R79O8@?Ub8IIA(6I`yHn%lARVL`%b8+ z4$8D-|MZZWxc_)vu6@VZN!HsI$*2NOV&uMxBNzIbRgy%ob_ zhwEH{J9r$!dEix9XM7n&c{S(h>nGm?el;gaX0@|QnzFD@bne`el^CO$yXC?BDJ|Qg z+y$GRoR`?ST1z^e*>;!IS@5Ovb7*RlN>BV_UC!7E_F;N#ky%1J{+iixp(dUJj93aK zzHNN>R-oN7>kykHClPnoPTIj7zc6KM(Pnlb(|s??)SMb)4!sMHU^-ntJwY5Big7xv zb1Ew`Xj;|D2kzGja*C$eS44(d&RMU~c_Y14V9_TLTz0J#uHlsx`S6{nhsA0dWZ#cG zJ?`fO50E>*X4TQLv#nl%3GOk*UkAgt=IY+u0LNXqeln3Z zv$~&Li`ZJOKkFuS)dJRA>)b_Da%Q~axwA_8zNK{BH{#}#m}zGcuckz}riDE-z_Ms> zR8-EqAMcfyGJCtvTpaUVQtajhUS%c@Yj}&6Zz;-M7MZzqv3kA7{SuW$oW#=0az2wQ zg-WG@Vb4|D`pl~Il54N7Hmsauc_ne-a!o5#j3WaBBh@Wuefb!QJIOn5;d)%A#s+5% zuD$H=VNux9bE-}1&bcYGZ+>1Fo;3Z@e&zX^n!?JK*adSbONm$XW9z;Q^L>9U!}Toj2WdafJ%oL#h|yWWwyAGxzfrAWdDTtaKl zK4`5tDpPg5>z$MNv=X0LZ0d6l%D{(D8oT@+w0?ce$DZ6pv>{1&Ok67Ix1 zH}3=IEhPJEhItCC8E=`T`N5(k?G=B4+xzZ?<4!~ ze~z6Wk9!CHTI(0rLJ4{JU?E-puc;xusR?>G?;4vt;q~iI9=kDL=z0Rr%O$vU`30X$ zDZRFyZ`(omOy@u|i6h;wtJlP;+}$|Ak|k2dea7n?U1*$T!sXqqOjq^NxLPMmk~&qI zYg0W?yK8T(6+Ea+$YyspKK?kP$+B`~t3^Pib_`!6xCs32!i@pqXfFV6PmBIR<-QW= zN8L{pt0Vap0x`Gzn#E@zh@H)0FfVfA_Iu4fjYZ+umO1LXIbVc$pY+E234u)ttcrl$ z>s92z4vT%n6cMb>=XT6;l0+9e(|CZG)$@C7t7Z7Ez@a)h)!hyuV&B5K%%)P5?Lk|C zZZSVzdXp{@OXSP0hoU-gF8s8Um(#xzjP2Vem zec#-^JqTa&Y#QJ>-FBxd7tf`XB6e^JPUgagB8iBSEps;92KG`!#mvVcPQ5yNC-GEG zTiHEDYfH+0O15}r^+ z#jxj=@x8iNHWALe!P3R67TwmhItn**0JwnzSV2O&KE8KcT+0hWH^OPD1pwiuyx=b@ zNf5Jh0{9X)8;~Es)$t@%(3!OnbY+`@?i{mGX7Yy}8T_*0a6g;kaFPq;*=px5EhO{Cp%1kI<0?*|h8v!6WnO3cCJRF2-CRrU3JiLJnj@6;L)!0kWYAc_}F{2P))3HmCrz zQ&N&gE70;`!6*eJ4^1IR{f6j4(-l&X!tjHxkbHA^Zhrnhr9g{exN|xrS`5Pq=#Xf& zG%P=#ra-TyVFfgW%cZo5OSIwFL9WtXAlFOa+ubmI5t*3=g#Y zF%;70p5;{ZeFL}&}yOY1N1*Q;*<(kTB!7vM$QokF)yr2FlIU@$Ph58$Bz z0J?xQG=MlS4L6jA22eS42g|9*9pX@$#*sUeM(z+t?hr@r5J&D1rx}2pW&m*_`VDCW zUYY@v-;bAO0HqoAgbbiGGC<=ryf96}3pouhy3XJrX+!!u*O_>Si38V{uJmQ&USptX zKp#l(?>%^7;2%h(q@YWS#9;a!JhKlkR#Vd)ERILlgu!Hr@jA@V;sk4BJ-H#p*4EqC zDGjC*tl=@3Oi6)Bn^QwFpul18fpkbpg0+peH$xyPBqb%`$OUhPKyWb32o7clB*9Z< zN=i~NLjavrLtwgJ01bufP+>p-jR2I95|TpmKpQL2!oV>g(4RvS2pK4*ou%m(h6r3A zX#s&`9LU1ZG&;{CkOK!4fLDTnBys`M!vuz>Q&9OZ0hGQl!~!jSDg|~s*w52opC{sB ze|Cf2luD(*G13LcOAGA!s2FjSK8&IE5#W%J25w!vM0^VyQM!t)inj&RTiJ!wXzFgz z3^IqzB7I0L$llljsGq})thBy9UOyjtFO_*hYM_sgcMk>44jeH0V1FDyELc{S1F-;A zS;T^k^~4biG&V*Irq}O;e}j$$+E_#G?HKIn05iP3j|87TkGK~SqG!-KBg5+mN(aLm z8ybhIM`%C19UX$H$KY6JgXbY$0AT%rEpHC;u`rQ$Y=rxUdsc5*Kvc8jaYaO$^)cI6){P6K0r)I6DY4Wr4&B zLQUBraey#0HV|&c4v7PVo3n$zHj99(TZO^3?Ly%C4nYvJTL9eLBLHsM3WKKD>5!B` zQ=BsR3aR6PD(Fa>327E2HAu5TM~Wusc!)>~(gM)+3~m;92Jd;FnSib=M5d6;;5{%R zb4V7DEJ0V!CP-F*oU?gkc>ksUtAYP&V4ND5J>J2^jt*vcFflQWCrB&fLdT%O59PVJ zhid#toR=FNgD!q3&r8#wEBr`!wzvQu5zX?Q>nlSJ4i@WC*CN*-xU66F^V5crWevQ9gsq$I@z1o(a=k7LL~ z7m_~`o;_Ozha1$8Q}{WBehvAlO4EL60y5}8GDrZ< zXh&F}71JbW2A~8KfEWj&UWV#4+Z4p`b{uAj4&WC zha`}X@3~+Iz^WRlOHU&KngK>#j}+_o@LdBC1H-`gT+krWX3-;!)6?{FBp~%20a}FL zFP9%Emqcwa#(`=G>BBZ0qZDQhmZKJg_g8<=bBFKWr!dyg(YkpE+|R*SGpDVU!+VlU zFC54^DLv}`qa%49T>nNiA9Q7Ips#!Xx90tCU2gvK`(F+GPcL=J^>No{)~we#o@&mUb6c$ zCc*<|NJBk-#+{j9xkQ&ujB zI~`#kN~7W!f*-}wkG~Ld!JqZ@tK}eeSnsS5J1fMFXm|`LJx&}5`@dK3W^7#Wnm+_P zBZkp&j1fa2Y=eIjJ0}gh85jt43kaIXXv?xmo@eHrka!Z|vQv12HN#+!I5E z`(fbuW>gFiJL|uXJ!vKt#z3e3HlVdboH7;e#i3(2<)Fg-I@BR!qY#eof3MFZ&*Y@l zI|KJf&ge@p2Dq09Vu$$Qxb7!}{m-iRk@!)%KL)txi3;~Z4Pb}u@GsW;ELiWeG9V51 znX#}B&4Y2E7-H=OpNE@q{%hFLxwIpBF2t{vPREa8_{linXT;#1vMRWjOzLOP$-hf( z>=?$0;~~PnkqY;~K{EM6Vo-T(0K{A0}VUGmu*hR z{tw3hvBN%N3G3Yw`X5Te+F{J`(3w1s3-+1EbnFQKcrgrX1Jqvs@ADGe%M0s$EbK$$ zK)=y=upBc6SjGYAACCcI=Y*6Fi8_jgwZlLxD26fnQfJmb8^gHRN5(TemhX@0e=vr> zg`W}6U>x6VhoA3DqsGGD9uL1DhB3!OXO=k}59TqD@(0Nb{)Ut_luTioK_>7wjc!5C zIr@w}b`Fez3)0wQfKl&bae7;PcTA7%?f2xucM0G)wt_KO!Ewx>F~;=BI0j=Fb4>pp zv}0R^xM4eti~+^+gE$6b81p(kwzuDti(-K9bc|?+pJEl@H+jSYuxZQV8rl8 zjp@M{#%qItIUFN~KcO9Hed*`$5A-2~pAo~K&<-Q+`9`$CK>rzqAI4w~$F%vs9s{~x zg4BP%Gy*@m?;D6=SRX?888Q6peF@_4Z->8wAH~Cn!R$|Hhq2cIzFYqT_+cDourHbY z0qroxJnrZ4Gh+Ay+F`_c%+KRT>y3qw{)89?=hJ@=KO=@ep)aBJ$c!JHfBMJpsP*3G za7|)VJJ8B;4?n{~ldJF7%jmb`-ftIvNd~ekoufG(`K(3=LNc;HBY& z(lp#q8XAD#cIf}k49zX_i`*fO+#!zKA&%T3j@%)R+#yag067CU%yUEe47>wzGU8^` z1EXFT^@I!{J!F8!X?S6ph8J=gUi5tl93*W>7}_uR<2N2~e}FaG?}KPyugQ=-OGEZs z!GBoyYY+H*ANn4?Z)X4l+7H%`17i5~zRlRIX?t)6_eu=g2Q`3WBhxSUeea+M-S?RL zX9oBGKn%a!H+*hx4d2(I!gsi+@SQK%<{X22M~2tMulJoa)0*+z9=-YO+;DFEm5eE1U9b^B(Z}2^9!Qk`!A$wUE z7$Ar5?NRg2&G!AZqnmE64eh^Anss3i!{}%6@Et+4rr!=}!SBF8eZ2*J3ujCWbl;3; z48H~goPSv(8X61fKKdpP!Z7$88NL^Z?j`!^*I?-P4X^pMxyWz~@$(UeAcTSDd(`vO z{~rc;9|GfMJcApU3k}22a!&)k4{CU!e_ny^Y3cO;tOvOMKEyWz!vG(Kp*;hB?d|R3`2X~=5a6#^o5@qn?J-bI8Ppip{-yG z!k|VcGsq!jF~}7DMr49Wap-s&>o=U^T0!Lcy}!(bhtYsPQy z4|EJe{12QL#=c(suQ89Mhw9<`bui%nx7Nep`C&*M3~vMEACmcRYYRGtANq$F%zh&V zc)cEVeHz*Z1N)L7k-(k3np#{GcDh2Q@ya0YHl*n7fl*ZPAsbU-a94MYYtA#&!c`xGIaV;yzsmrjfieTEtqB_WgZp2*NplHx=$O{M~2#i_vJ{ps-NgK zQsxKK_CBM2PP_je+Xft`(vYfXXgIUr{=PA=7a8`2EHk)Ym2QKIforz# tySWtj{oF3N9@_;i*Fv5S)9x^z=nlWP>jpp-9)52ZmLVA=i*%6g{{fxOO~wEK literal 0 HcmV?d00001 diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/runner.exe.manifest b/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/runner.exe.manifest new file mode 100644 index 000000000..c977c4a42 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/runner.exe.manifest @@ -0,0 +1,20 @@ + + + + + PerMonitorV2 + + + + + + + + + + + + + + + diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/utils.cpp b/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/utils.cpp new file mode 100644 index 000000000..f5bf9fa0f --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/utils.cpp @@ -0,0 +1,64 @@ +#include "utils.h" + +#include +#include +#include +#include + +#include + +void CreateAndAttachConsole() { + if (::AllocConsole()) { + FILE *unused; + if (freopen_s(&unused, "CONOUT$", "w", stdout)) { + _dup2(_fileno(stdout), 1); + } + if (freopen_s(&unused, "CONOUT$", "w", stderr)) { + _dup2(_fileno(stdout), 2); + } + std::ios::sync_with_stdio(); + FlutterDesktopResyncOutputStreams(); + } +} + +std::vector GetCommandLineArguments() { + // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. + int argc; + wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); + if (argv == nullptr) { + return std::vector(); + } + + std::vector command_line_arguments; + + // Skip the first argument as it's the binary name. + for (int i = 1; i < argc; i++) { + command_line_arguments.push_back(Utf8FromUtf16(argv[i])); + } + + ::LocalFree(argv); + + return command_line_arguments; +} + +std::string Utf8FromUtf16(const wchar_t* utf16_string) { + if (utf16_string == nullptr) { + return std::string(); + } + int target_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + -1, nullptr, 0, nullptr, nullptr); + std::string utf8_string; + if (target_length == 0 || target_length > utf8_string.max_size()) { + return utf8_string; + } + utf8_string.resize(target_length); + int converted_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + -1, utf8_string.data(), + target_length, nullptr, nullptr); + if (converted_length == 0) { + return std::string(); + } + return utf8_string; +} diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/utils.h b/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/utils.h new file mode 100644 index 000000000..3879d5475 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/utils.h @@ -0,0 +1,19 @@ +#ifndef RUNNER_UTILS_H_ +#define RUNNER_UTILS_H_ + +#include +#include + +// Creates a console for the process, and redirects stdout and stderr to +// it for both the runner and the Flutter library. +void CreateAndAttachConsole(); + +// Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string +// encoded in UTF-8. Returns an empty std::string on failure. +std::string Utf8FromUtf16(const wchar_t* utf16_string); + +// Gets the command line arguments passed in as a std::vector, +// encoded in UTF-8. Returns an empty std::vector on failure. +std::vector GetCommandLineArguments(); + +#endif // RUNNER_UTILS_H_ diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/win32_window.cpp b/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/win32_window.cpp new file mode 100644 index 000000000..c10f08dc7 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/win32_window.cpp @@ -0,0 +1,245 @@ +#include "win32_window.h" + +#include + +#include "resource.h" + +namespace { + +constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; + +// The number of Win32Window objects that currently exist. +static int g_active_window_count = 0; + +using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); + +// Scale helper to convert logical scaler values to physical using passed in +// scale factor +int Scale(int source, double scale_factor) { + return static_cast(source * scale_factor); +} + +// Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. +// This API is only needed for PerMonitor V1 awareness mode. +void EnableFullDpiSupportIfAvailable(HWND hwnd) { + HMODULE user32_module = LoadLibraryA("User32.dll"); + if (!user32_module) { + return; + } + auto enable_non_client_dpi_scaling = + reinterpret_cast( + GetProcAddress(user32_module, "EnableNonClientDpiScaling")); + if (enable_non_client_dpi_scaling != nullptr) { + enable_non_client_dpi_scaling(hwnd); + FreeLibrary(user32_module); + } +} + +} // namespace + +// Manages the Win32Window's window class registration. +class WindowClassRegistrar { + public: + ~WindowClassRegistrar() = default; + + // Returns the singleton registar instance. + static WindowClassRegistrar* GetInstance() { + if (!instance_) { + instance_ = new WindowClassRegistrar(); + } + return instance_; + } + + // Returns the name of the window class, registering the class if it hasn't + // previously been registered. + const wchar_t* GetWindowClass(); + + // Unregisters the window class. Should only be called if there are no + // instances of the window. + void UnregisterWindowClass(); + + private: + WindowClassRegistrar() = default; + + static WindowClassRegistrar* instance_; + + bool class_registered_ = false; +}; + +WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; + +const wchar_t* WindowClassRegistrar::GetWindowClass() { + if (!class_registered_) { + WNDCLASS window_class{}; + window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); + window_class.lpszClassName = kWindowClassName; + window_class.style = CS_HREDRAW | CS_VREDRAW; + window_class.cbClsExtra = 0; + window_class.cbWndExtra = 0; + window_class.hInstance = GetModuleHandle(nullptr); + window_class.hIcon = + LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); + window_class.hbrBackground = 0; + window_class.lpszMenuName = nullptr; + window_class.lpfnWndProc = Win32Window::WndProc; + RegisterClass(&window_class); + class_registered_ = true; + } + return kWindowClassName; +} + +void WindowClassRegistrar::UnregisterWindowClass() { + UnregisterClass(kWindowClassName, nullptr); + class_registered_ = false; +} + +Win32Window::Win32Window() { + ++g_active_window_count; +} + +Win32Window::~Win32Window() { + --g_active_window_count; + Destroy(); +} + +bool Win32Window::CreateAndShow(const std::wstring& title, + const Point& origin, + const Size& size) { + Destroy(); + + const wchar_t* window_class = + WindowClassRegistrar::GetInstance()->GetWindowClass(); + + const POINT target_point = {static_cast(origin.x), + static_cast(origin.y)}; + HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); + UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); + double scale_factor = dpi / 96.0; + + HWND window = CreateWindow( + window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE, + Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), + Scale(size.width, scale_factor), Scale(size.height, scale_factor), + nullptr, nullptr, GetModuleHandle(nullptr), this); + + if (!window) { + return false; + } + + return OnCreate(); +} + +// static +LRESULT CALLBACK Win32Window::WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + if (message == WM_NCCREATE) { + auto window_struct = reinterpret_cast(lparam); + SetWindowLongPtr(window, GWLP_USERDATA, + reinterpret_cast(window_struct->lpCreateParams)); + + auto that = static_cast(window_struct->lpCreateParams); + EnableFullDpiSupportIfAvailable(window); + that->window_handle_ = window; + } else if (Win32Window* that = GetThisFromHandle(window)) { + return that->MessageHandler(window, message, wparam, lparam); + } + + return DefWindowProc(window, message, wparam, lparam); +} + +LRESULT +Win32Window::MessageHandler(HWND hwnd, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + switch (message) { + case WM_DESTROY: + window_handle_ = nullptr; + Destroy(); + if (quit_on_close_) { + PostQuitMessage(0); + } + return 0; + + case WM_DPICHANGED: { + auto newRectSize = reinterpret_cast(lparam); + LONG newWidth = newRectSize->right - newRectSize->left; + LONG newHeight = newRectSize->bottom - newRectSize->top; + + SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, + newHeight, SWP_NOZORDER | SWP_NOACTIVATE); + + return 0; + } + case WM_SIZE: { + RECT rect = GetClientArea(); + if (child_content_ != nullptr) { + // Size and position the child window. + MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, + rect.bottom - rect.top, TRUE); + } + return 0; + } + + case WM_ACTIVATE: + if (child_content_ != nullptr) { + SetFocus(child_content_); + } + return 0; + } + + return DefWindowProc(window_handle_, message, wparam, lparam); +} + +void Win32Window::Destroy() { + OnDestroy(); + + if (window_handle_) { + DestroyWindow(window_handle_); + window_handle_ = nullptr; + } + if (g_active_window_count == 0) { + WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); + } +} + +Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { + return reinterpret_cast( + GetWindowLongPtr(window, GWLP_USERDATA)); +} + +void Win32Window::SetChildContent(HWND content) { + child_content_ = content; + SetParent(content, window_handle_); + RECT frame = GetClientArea(); + + MoveWindow(content, frame.left, frame.top, frame.right - frame.left, + frame.bottom - frame.top, true); + + SetFocus(child_content_); +} + +RECT Win32Window::GetClientArea() { + RECT frame; + GetClientRect(window_handle_, &frame); + return frame; +} + +HWND Win32Window::GetHandle() { + return window_handle_; +} + +void Win32Window::SetQuitOnClose(bool quit_on_close) { + quit_on_close_ = quit_on_close; +} + +bool Win32Window::OnCreate() { + // No-op; provided for subclasses. + return true; +} + +void Win32Window::OnDestroy() { + // No-op; provided for subclasses. +} diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/win32_window.h b/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/win32_window.h new file mode 100644 index 000000000..17ba43112 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/win32_window.h @@ -0,0 +1,98 @@ +#ifndef RUNNER_WIN32_WINDOW_H_ +#define RUNNER_WIN32_WINDOW_H_ + +#include + +#include +#include +#include + +// A class abstraction for a high DPI-aware Win32 Window. Intended to be +// inherited from by classes that wish to specialize with custom +// rendering and input handling +class Win32Window { + public: + struct Point { + unsigned int x; + unsigned int y; + Point(unsigned int x, unsigned int y) : x(x), y(y) {} + }; + + struct Size { + unsigned int width; + unsigned int height; + Size(unsigned int width, unsigned int height) + : width(width), height(height) {} + }; + + Win32Window(); + virtual ~Win32Window(); + + // Creates and shows a win32 window with |title| and position and size using + // |origin| and |size|. New windows are created on the default monitor. Window + // sizes are specified to the OS in physical pixels, hence to ensure a + // consistent size to will treat the width height passed in to this function + // as logical pixels and scale to appropriate for the default monitor. Returns + // true if the window was created successfully. + bool CreateAndShow(const std::wstring& title, + const Point& origin, + const Size& size); + + // Release OS resources associated with window. + void Destroy(); + + // Inserts |content| into the window tree. + void SetChildContent(HWND content); + + // Returns the backing Window handle to enable clients to set icon and other + // window properties. Returns nullptr if the window has been destroyed. + HWND GetHandle(); + + // If true, closing this window will quit the application. + void SetQuitOnClose(bool quit_on_close); + + // Return a RECT representing the bounds of the current client area. + RECT GetClientArea(); + + protected: + // Processes and route salient window messages for mouse handling, + // size change and DPI. Delegates handling of these to member overloads that + // inheriting classes can handle. + virtual LRESULT MessageHandler(HWND window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Called when CreateAndShow is called, allowing subclass window-related + // setup. Subclasses should return false if setup fails. + virtual bool OnCreate(); + + // Called when Destroy is called. + virtual void OnDestroy(); + + private: + friend class WindowClassRegistrar; + + // OS callback called by message pump. Handles the WM_NCCREATE message which + // is passed when the non-client area is being created and enables automatic + // non-client DPI scaling so that the non-client area automatically + // responsponds to changes in DPI. All other messages are handled by + // MessageHandler. + static LRESULT CALLBACK WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Retrieves a class instance pointer for |window| + static Win32Window* GetThisFromHandle(HWND const window) noexcept; + + bool quit_on_close_ = false; + + // window handle for top level window. + HWND window_handle_ = nullptr; + + // window handle for hosted content. + HWND child_content_ = nullptr; +}; + +#endif // RUNNER_WIN32_WINDOW_H_ diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/jnigen.yaml b/pkgs/jni_gen/examples/pdfbox_plugin/jnigen.yaml new file mode 100644 index 000000000..1e98f4cf8 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/jnigen.yaml @@ -0,0 +1,64 @@ +## Name of the generated library, this is required and used as the name of +## shared library which contains C bindings +library_name: pdfbox_plugin + +## String to be pasted verbatim into generated bindings +preamble: | + // Generated from Apache PDFBox library which is licensed under the Apache License 2.0. + // The following copyright from the original authors applies. + // + // Licensed to the Apache Software Foundation (ASF) under one or more + // contributor license agreements. See the NOTICE file distributed with + // this work for additional information regarding copyright ownership. + // The ASF licenses this file to You under the Apache License, Version 2.0 + // (the "License"); you may not use this file except in compliance with + // the License. You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + +## Root for generated C bindings. +c_root: 'src/' + +## C files can be stored in a different sub-directory inside c_root. +## +## We have a guideline to keep all generated code in third_party/ since original +## project's license applies to generated code. So we specify third_party/ as +## c_subdir while keeping generated CMakeLists.txt in src/. +c_subdir: 'third_party/' + +## Root for generated Dart bindings. +dart_root: 'lib/third_party/' + +## Classes / packages for which bindings need to be generated. +classes: + - 'org.apache.pdfbox.pdmodel.PDDocument' + - 'org.apache.pdfbox.pdmodel.PDDocumentInformation' + - 'org.apache.pdfbox.text.PDFTextStripper' + +## Dependencies to be downloaded using Maven (Invokes `mvn` command). These +## dependencies are always downloaded along with their transitive dependencies. +## +## Dependencies should be specified using groupID:artifactID:version format +## The downloaded dependencies are automatically added to classpath of the +## Java API scanning process. There's no need to specify these again in +## sourcepath and classpath. +## +## Note that when maven based tooling is used, the first run often has to fetch +## all the dependencies and might take some time. However, maven caches most +## artifacts in local repository, thus subsequent runs will be faster. +maven_downloads: + ## For these dependencies, both source and JARs are downloaded. + source_deps: + - 'org.apache.pdfbox:pdfbox:2.0.26' + ## Runtime dependencies for which bindings aren't generated directly. + ## Only JARs are downloaded. + jar_only_deps: + - 'org.bouncycastle:bcmail-jdk15on:1.70' + - 'org.bouncycastle:bcprov-jdk15on:1.70' + diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/jnigen_full.yaml b/pkgs/jni_gen/examples/pdfbox_plugin/jnigen_full.yaml new file mode 100644 index 000000000..2652756ac --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/jnigen_full.yaml @@ -0,0 +1,63 @@ +## Name of the generated library, this is required and used as the name of +## shared library which contains C bindings +library_name: pdfbox_plugin + +## String to be pasted verbatim into generated bindings +preamble: | + // Generated from Apache PDFBox library which is licensed under the Apache License 2.0. + // The following copyright from the original authors applies. + // + // Licensed to the Apache Software Foundation (ASF) under one or more + // contributor license agreements. See the NOTICE file distributed with + // this work for additional information regarding copyright ownership. + // The ASF licenses this file to You under the Apache License, Version 2.0 + // (the "License"); you may not use this file except in compliance with + // the License. You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + +## Root for generated C bindings. +c_root: 'src/' + +## C files can be stored in a different sub-directory inside c_root. +## +## We have a guideline to keep all generated code in third_party/ since original +## project's license applies to generated code. So we specify third_party/ as +## c_subdir while keeping generated CMakeLists.txt in src/. +c_subdir: 'third_party/' + +## Root for generated Dart bindings. +dart_root: 'lib/third_party/' + +## Classes / packages for which bindings need to be generated. +classes: + - 'org.apache.pdfbox.pdmodel' + - 'org.apache.pdfbox.text' + +## Dependencies to be downloaded using Maven (Invokes `mvn` command). These +## dependencies are always downloaded along with their transitive dependencies. +## +## Dependencies should be specified using groupID:artifactID:version format +## The downloaded dependencies are automatically added to classpath of the +## Java API scanning process. There's no need to specify these again in +## sourcepath and classpath. +## +## Note that when maven based tooling is used, the first run often has to fetch +## all the dependencies and might take some time. However, maven caches most +## artifacts in local repository, thus subsequent runs will be faster. +maven_downloads: + ## For these dependencies, both source and JARs are downloaded. + source_deps: + - 'org.apache.pdfbox:pdfbox:2.0.26' + ## Runtime dependencies for which bindings aren't generated directly. + ## Only JARs are downloaded. + jar_only_deps: + - 'org.bouncycastle:bcmail-jdk15on:1.70' + - 'org.bouncycastle:bcprov-jdk15on:1.70' + diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/lib/third_party/init.dart b/pkgs/jni_gen/examples/pdfbox_plugin/lib/third_party/init.dart new file mode 100644 index 000000000..4e8808139 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/lib/third_party/init.dart @@ -0,0 +1,5 @@ +import "dart:ffi"; +import "package:jni/jni.dart"; + +final Pointer Function(String sym) jlookup = + Jni.getInstance().initGeneratedLibrary("pdfbox_plugin"); diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/lib/third_party/org/apache/pdfbox/pdmodel.dart b/pkgs/jni_gen/examples/pdfbox_plugin/lib/third_party/org/apache/pdfbox/pdmodel.dart new file mode 100644 index 000000000..2eeee3070 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/lib/third_party/org/apache/pdfbox/pdmodel.dart @@ -0,0 +1,2196 @@ +// Generated from Apache PDFBox library which is licensed under the Apache License 2.0. +// The following copyright from the original authors applies. +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Autogenerated by jni_gen. DO NOT EDIT! + +// ignore_for_file: camel_case_types +// ignore_for_file: non_constant_identifier_names +// ignore_for_file: constant_identifier_names +// ignore_for_file: annotate_overrides +// ignore_for_file: no_leading_underscores_for_local_identifiers +// ignore_for_file: unused_element + +import "dart:ffi" as ffi; + +import "package:jni/jni.dart" as jni; + +import "../../../init.dart" show jlookup; + +/// from: org.apache.pdfbox.pdmodel.PDDocument +/// +/// 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.JlObject { + PDDocument.fromRef(ffi.Pointer ref) : super.fromRef(ref); + + static final _get_RESERVE_BYTE_RANGE = + jlookup Function()>>( + "get_org_apache_pdfbox_pdmodel_PDDocument_RESERVE_BYTE_RANGE") + .asFunction Function()>(); + + /// from: private static final int[] RESERVE_BYTE_RANGE + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// For signing: large reserve byte range used as placeholder in the saved PDF until the actual + /// length of the PDF is known. You'll need to fetch (with + /// PDSignature\#getByteRange() ) and reassign this yourself (with + /// PDSignature\#setByteRange(int[]) ) only if you call + /// \#saveIncrementalForExternalSigning(java.io.OutputStream) saveIncrementalForExternalSigning() + /// twice. + static jni.JlObject get RESERVE_BYTE_RANGE => + jni.JlObject.fromRef(_get_RESERVE_BYTE_RANGE()); + + static final _get_LOG = + jlookup Function()>>( + "get_org_apache_pdfbox_pdmodel_PDDocument_LOG") + .asFunction Function()>(); + + /// from: private static final org.apache.commons.logging.Log LOG + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JlObject get LOG => jni.JlObject.fromRef(_get_LOG()); + + static final _get_document = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_pdmodel_PDDocument_document") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + )>(); + + /// from: private final org.apache.pdfbox.cos.COSDocument document + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JlObject get document => jni.JlObject.fromRef(_get_document(reference)); + + static final _get_documentInformation = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_pdmodel_PDDocument_documentInformation") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + )>(); + + /// from: private org.apache.pdfbox.pdmodel.PDDocumentInformation documentInformation + /// The returned object must be deleted after use, by calling the `delete` method. + PDDocumentInformation get documentInformation => + PDDocumentInformation.fromRef(_get_documentInformation(reference)); + static final _set_documentInformation = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "set_org_apache_pdfbox_pdmodel_PDDocument_documentInformation") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: private org.apache.pdfbox.pdmodel.PDDocumentInformation documentInformation + /// The returned object must be deleted after use, by calling the `delete` method. + set documentInformation(PDDocumentInformation value) => + _set_documentInformation(reference, value.reference); + + static final _get_documentCatalog = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_pdmodel_PDDocument_documentCatalog") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + )>(); + + /// from: private org.apache.pdfbox.pdmodel.PDDocumentCatalog documentCatalog + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JlObject get documentCatalog => + jni.JlObject.fromRef(_get_documentCatalog(reference)); + static final _set_documentCatalog = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "set_org_apache_pdfbox_pdmodel_PDDocument_documentCatalog") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: private org.apache.pdfbox.pdmodel.PDDocumentCatalog documentCatalog + /// The returned object must be deleted after use, by calling the `delete` method. + set documentCatalog(jni.JlObject value) => + _set_documentCatalog(reference, value.reference); + + static final _get_encryption = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_pdmodel_PDDocument_encryption") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + )>(); + + /// from: private org.apache.pdfbox.pdmodel.encryption.PDEncryption encryption + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JlObject get encryption => + jni.JlObject.fromRef(_get_encryption(reference)); + static final _set_encryption = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "set_org_apache_pdfbox_pdmodel_PDDocument_encryption") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: private org.apache.pdfbox.pdmodel.encryption.PDEncryption encryption + /// The returned object must be deleted after use, by calling the `delete` method. + set encryption(jni.JlObject value) => + _set_encryption(reference, value.reference); + + static final _get_allSecurityToBeRemoved = jlookup< + ffi.NativeFunction< + ffi.Uint8 Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_pdmodel_PDDocument_allSecurityToBeRemoved") + .asFunction< + int Function( + ffi.Pointer, + )>(); + + /// from: private boolean allSecurityToBeRemoved + bool get allSecurityToBeRemoved => + _get_allSecurityToBeRemoved(reference) != 0; + static final _set_allSecurityToBeRemoved = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Uint8)>>( + "set_org_apache_pdfbox_pdmodel_PDDocument_allSecurityToBeRemoved") + .asFunction, int)>(); + + /// from: private boolean allSecurityToBeRemoved + set allSecurityToBeRemoved(bool value) => + _set_allSecurityToBeRemoved(reference, value ? 1 : 0); + + static final _get_documentId = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_pdmodel_PDDocument_documentId") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + )>(); + + /// from: private java.lang.Long documentId + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JlObject get documentId => + jni.JlObject.fromRef(_get_documentId(reference)); + static final _set_documentId = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "set_org_apache_pdfbox_pdmodel_PDDocument_documentId") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: private java.lang.Long documentId + /// The returned object must be deleted after use, by calling the `delete` method. + set documentId(jni.JlObject value) => + _set_documentId(reference, value.reference); + + static final _get_pdfSource = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_pdmodel_PDDocument_pdfSource") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + )>(); + + /// from: private final org.apache.pdfbox.io.RandomAccessRead pdfSource + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JlObject get pdfSource => jni.JlObject.fromRef(_get_pdfSource(reference)); + + static final _get_accessPermission = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_pdmodel_PDDocument_accessPermission") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + )>(); + + /// from: private org.apache.pdfbox.pdmodel.encryption.AccessPermission accessPermission + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JlObject get accessPermission => + jni.JlObject.fromRef(_get_accessPermission(reference)); + static final _set_accessPermission = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "set_org_apache_pdfbox_pdmodel_PDDocument_accessPermission") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: private org.apache.pdfbox.pdmodel.encryption.AccessPermission accessPermission + /// The returned object must be deleted after use, by calling the `delete` method. + set accessPermission(jni.JlObject value) => + _set_accessPermission(reference, value.reference); + + static final _get_fontsToSubset = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_pdmodel_PDDocument_fontsToSubset") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + )>(); + + /// from: private final java.util.Set fontsToSubset + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JlObject get fontsToSubset => + jni.JlObject.fromRef(_get_fontsToSubset(reference)); + + static final _get_fontsToClose = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_pdmodel_PDDocument_fontsToClose") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + )>(); + + /// from: private final java.util.Set fontsToClose + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JlObject get fontsToClose => + jni.JlObject.fromRef(_get_fontsToClose(reference)); + + static final _get_signInterface = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_pdmodel_PDDocument_signInterface") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + )>(); + + /// from: private org.apache.pdfbox.pdmodel.interactive.digitalsignature.SignatureInterface signInterface + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JlObject get signInterface => + jni.JlObject.fromRef(_get_signInterface(reference)); + static final _set_signInterface = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "set_org_apache_pdfbox_pdmodel_PDDocument_signInterface") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: private org.apache.pdfbox.pdmodel.interactive.digitalsignature.SignatureInterface signInterface + /// The returned object must be deleted after use, by calling the `delete` method. + set signInterface(jni.JlObject value) => + _set_signInterface(reference, value.reference); + + static final _get_signingSupport = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_pdmodel_PDDocument_signingSupport") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + )>(); + + /// from: private org.apache.pdfbox.pdmodel.interactive.digitalsignature.SigningSupport signingSupport + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JlObject get signingSupport => + jni.JlObject.fromRef(_get_signingSupport(reference)); + static final _set_signingSupport = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "set_org_apache_pdfbox_pdmodel_PDDocument_signingSupport") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: private org.apache.pdfbox.pdmodel.interactive.digitalsignature.SigningSupport signingSupport + /// The returned object must be deleted after use, by calling the `delete` method. + set signingSupport(jni.JlObject value) => + _set_signingSupport(reference, value.reference); + + static final _get_resourceCache = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_pdmodel_PDDocument_resourceCache") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + )>(); + + /// from: private org.apache.pdfbox.pdmodel.ResourceCache resourceCache + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JlObject get resourceCache => + jni.JlObject.fromRef(_get_resourceCache(reference)); + static final _set_resourceCache = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "set_org_apache_pdfbox_pdmodel_PDDocument_resourceCache") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: private org.apache.pdfbox.pdmodel.ResourceCache resourceCache + /// The returned object must be deleted after use, by calling the `delete` method. + set resourceCache(jni.JlObject value) => + _set_resourceCache(reference, value.reference); + + static final _get_signatureAdded = jlookup< + ffi.NativeFunction< + ffi.Uint8 Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_pdmodel_PDDocument_signatureAdded") + .asFunction< + int Function( + ffi.Pointer, + )>(); + + /// from: private boolean signatureAdded + bool get signatureAdded => _get_signatureAdded(reference) != 0; + static final _set_signatureAdded = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Uint8)>>( + "set_org_apache_pdfbox_pdmodel_PDDocument_signatureAdded") + .asFunction, int)>(); + + /// from: private boolean signatureAdded + set signatureAdded(bool value) => + _set_signatureAdded(reference, value ? 1 : 0); + + static final _ctor = + jlookup Function()>>( + "org_apache_pdfbox_pdmodel_PDDocument_ctor") + .asFunction Function()>(); + + /// from: public void () + /// + /// Creates an empty PDF document. + /// You need to add at least one page for the document to be valid. + PDDocument() : super.fromRef(_ctor()); + + static final _ctor1 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_ctor1") + .asFunction Function(ffi.Pointer)>(); + + /// from: public void (org.apache.pdfbox.io.MemoryUsageSetting memUsageSetting) + /// + /// Creates an empty PDF document. + /// You need to add at least one page for the document to be valid. + ///@param memUsageSetting defines how memory is used for buffering PDF streams + PDDocument.ctor1(jni.JlObject memUsageSetting) + : super.fromRef(_ctor1(memUsageSetting.reference)); + + static final _ctor2 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_ctor2") + .asFunction Function(ffi.Pointer)>(); + + /// from: public void (org.apache.pdfbox.cos.COSDocument doc) + /// + /// Constructor that uses an existing document. The COSDocument that is passed in must be valid. + ///@param doc The COSDocument that this document wraps. + PDDocument.ctor2(jni.JlObject doc) : super.fromRef(_ctor2(doc.reference)); + + static final _ctor3 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_ctor3") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public void (org.apache.pdfbox.cos.COSDocument doc, org.apache.pdfbox.io.RandomAccessRead source) + /// + /// Constructor that uses an existing document. The COSDocument that is passed in must be valid. + ///@param doc The COSDocument that this document wraps. + ///@param source the parser which is used to read the pdf + PDDocument.ctor3(jni.JlObject doc, jni.JlObject source) + : super.fromRef(_ctor3(doc.reference, source.reference)); + + static final _ctor4 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_ctor4") + .asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + /// from: public void (org.apache.pdfbox.cos.COSDocument doc, org.apache.pdfbox.io.RandomAccessRead source, org.apache.pdfbox.pdmodel.encryption.AccessPermission permission) + /// + /// Constructor that uses an existing document. The COSDocument that is passed in must be valid. + ///@param doc The COSDocument that this document wraps. + ///@param source the parser which is used to read the pdf + ///@param permission he access permissions of the pdf + PDDocument.ctor4( + jni.JlObject doc, jni.JlObject source, jni.JlObject permission) + : super.fromRef( + _ctor4(doc.reference, source.reference, permission.reference)); + + static final _addPage = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_addPage") + .asFunction< + void Function(ffi.Pointer, ffi.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.JlObject page) => _addPage(reference, page.reference); + + static final _addSignature = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_addSignature") + .asFunction< + void Function(ffi.Pointer, ffi.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.JlObject sigObject) => + _addSignature(reference, sigObject.reference); + + static final _addSignature1 = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_addSignature1") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.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. + /// + /// 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 addSignature1(jni.JlObject sigObject, jni.JlObject options) => + _addSignature1(reference, sigObject.reference, options.reference); + + static final _addSignature2 = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_addSignature2") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.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. + /// + /// 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 addSignature2(jni.JlObject sigObject, jni.JlObject signatureInterface) => + _addSignature2( + reference, sigObject.reference, signatureInterface.reference); + + static final _addSignature3 = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_addSignature3") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.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. + /// + /// 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 addSignature3(jni.JlObject sigObject, jni.JlObject signatureInterface, + jni.JlObject options) => + _addSignature3(reference, sigObject.reference, + signatureInterface.reference, options.reference); + + static final _findSignatureField = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_findSignatureField") + .asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + /// from: private org.apache.pdfbox.pdmodel.interactive.form.PDSignatureField findSignatureField(java.util.Iterator fieldIterator, org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature sigObject) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Search acroform fields for signature field with specific signature dictionary. + ///@param fieldIterator iterator on all fields. + ///@param sigObject signature object (the /V part). + ///@return a signature field if found, or null if none was found. + jni.JlObject findSignatureField( + jni.JlObject fieldIterator, jni.JlObject sigObject) => + jni.JlObject.fromRef(_findSignatureField( + reference, fieldIterator.reference, sigObject.reference)); + + static final _checkSignatureField = jlookup< + ffi.NativeFunction< + ffi.Uint8 Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_checkSignatureField") + .asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + /// from: private boolean checkSignatureField(java.util.Iterator fieldIterator, org.apache.pdfbox.pdmodel.interactive.form.PDSignatureField signatureField) + /// + /// Check if the field already exists in the field list. + ///@param fieldIterator iterator on all fields. + ///@param signatureField the signature field. + ///@return true if the field already existed in the field list, false if not. + bool checkSignatureField( + jni.JlObject fieldIterator, jni.JlObject signatureField) => + _checkSignatureField( + reference, fieldIterator.reference, signatureField.reference) != + 0; + + static final _checkSignatureAnnotation = jlookup< + ffi.NativeFunction< + ffi.Uint8 Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_checkSignatureAnnotation") + .asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + /// from: private boolean checkSignatureAnnotation(java.util.List annotations, org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationWidget widget) + /// + /// Check if the widget already exists in the annotation list + ///@param annotations the list of PDAnnotation fields. + ///@param widget the annotation widget. + ///@return true if the widget already existed in the annotation list, false if not. + bool checkSignatureAnnotation( + jni.JlObject annotations, jni.JlObject widget) => + _checkSignatureAnnotation( + reference, annotations.reference, widget.reference) != + 0; + + static final _prepareVisibleSignature = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_prepareVisibleSignature") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + /// from: private void prepareVisibleSignature(org.apache.pdfbox.pdmodel.interactive.form.PDSignatureField signatureField, org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm acroForm, org.apache.pdfbox.cos.COSDocument visualSignature) + void prepareVisibleSignature(jni.JlObject signatureField, + jni.JlObject acroForm, jni.JlObject visualSignature) => + _prepareVisibleSignature(reference, signatureField.reference, + acroForm.reference, visualSignature.reference); + + static final _assignSignatureRectangle = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_assignSignatureRectangle") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + /// from: private void assignSignatureRectangle(org.apache.pdfbox.pdmodel.interactive.form.PDSignatureField signatureField, org.apache.pdfbox.cos.COSDictionary annotDict) + void assignSignatureRectangle( + jni.JlObject signatureField, jni.JlObject annotDict) => + _assignSignatureRectangle( + reference, signatureField.reference, annotDict.reference); + + static final _assignAppearanceDictionary = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_assignAppearanceDictionary") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + /// from: private void assignAppearanceDictionary(org.apache.pdfbox.pdmodel.interactive.form.PDSignatureField signatureField, org.apache.pdfbox.cos.COSDictionary apDict) + void assignAppearanceDictionary( + jni.JlObject signatureField, jni.JlObject apDict) => + _assignAppearanceDictionary( + reference, signatureField.reference, apDict.reference); + + static final _assignAcroFormDefaultResource = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_assignAcroFormDefaultResource") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + /// from: private void assignAcroFormDefaultResource(org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm acroForm, org.apache.pdfbox.cos.COSDictionary newDict) + void assignAcroFormDefaultResource( + jni.JlObject acroForm, jni.JlObject newDict) => + _assignAcroFormDefaultResource( + reference, acroForm.reference, newDict.reference); + + static final _prepareNonVisibleSignature = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_prepareNonVisibleSignature") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: private void prepareNonVisibleSignature(org.apache.pdfbox.pdmodel.interactive.form.PDSignatureField signatureField) + void prepareNonVisibleSignature(jni.JlObject signatureField) => + _prepareNonVisibleSignature(reference, signatureField.reference); + + static final _addSignatureField = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_addSignatureField") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.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) + /// + /// 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.JlObject sigFields, + jni.JlObject signatureInterface, jni.JlObject options) => + _addSignatureField(reference, sigFields.reference, + signatureInterface.reference, options.reference); + + static final _removePage = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_removePage") + .asFunction< + void Function(ffi.Pointer, ffi.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.JlObject page) => _removePage(reference, page.reference); + + static final _removePage1 = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Int32)>>( + "org_apache_pdfbox_pdmodel_PDDocument_removePage1") + .asFunction, int)>(); + + /// from: public void removePage(int pageNumber) + /// + /// Remove the page from the document. + ///@param pageNumber 0 based index to page number. + void removePage1(int pageNumber) => _removePage1(reference, pageNumber); + + static final _importPage = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_importPage") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public org.apache.pdfbox.pdmodel.PDPage importPage(org.apache.pdfbox.pdmodel.PDPage page) + /// The returned object must be deleted after use, by calling the `delete` 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.JlObject importPage(jni.JlObject page) => + jni.JlObject.fromRef(_importPage(reference, page.reference)); + + static final _getDocument = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_getDocument") + .asFunction Function(ffi.Pointer)>(); + + /// from: public org.apache.pdfbox.cos.COSDocument getDocument() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// This will get the low level document. + ///@return The document that this layer sits on top of. + jni.JlObject getDocument() => jni.JlObject.fromRef(_getDocument(reference)); + + static final _getDocumentInformation = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_getDocumentInformation") + .asFunction Function(ffi.Pointer)>(); + + /// from: public org.apache.pdfbox.pdmodel.PDDocumentInformation getDocumentInformation() + /// The returned object must be deleted after use, by calling the `delete` 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 getDocumentInformation() => + PDDocumentInformation.fromRef(_getDocumentInformation(reference)); + + static final _setDocumentInformation = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_setDocumentInformation") + .asFunction< + void Function(ffi.Pointer, ffi.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 info) => + _setDocumentInformation(reference, info.reference); + + static final _getDocumentCatalog = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_getDocumentCatalog") + .asFunction Function(ffi.Pointer)>(); + + /// from: public org.apache.pdfbox.pdmodel.PDDocumentCatalog getDocumentCatalog() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// This will get the document CATALOG. This is guaranteed to not return null. + ///@return The documents /Root dictionary + jni.JlObject getDocumentCatalog() => + jni.JlObject.fromRef(_getDocumentCatalog(reference)); + + static final _isEncrypted = + jlookup)>>( + "org_apache_pdfbox_pdmodel_PDDocument_isEncrypted") + .asFunction)>(); + + /// from: public boolean isEncrypted() + /// + /// This will tell if this document is encrypted or not. + ///@return true If this document is encrypted. + bool isEncrypted() => _isEncrypted(reference) != 0; + + static final _getEncryption = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_getEncryption") + .asFunction Function(ffi.Pointer)>(); + + /// from: public org.apache.pdfbox.pdmodel.encryption.PDEncryption getEncryption() + /// The returned object must be deleted after use, by calling the `delete` 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.JlObject getEncryption() => + jni.JlObject.fromRef(_getEncryption(reference)); + + static final _setEncryptionDictionary = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_setEncryptionDictionary") + .asFunction< + void Function(ffi.Pointer, ffi.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.JlObject encryption) => + _setEncryptionDictionary(reference, encryption.reference); + + static final _getLastSignatureDictionary = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_getLastSignatureDictionary") + .asFunction Function(ffi.Pointer)>(); + + /// from: public org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature getLastSignatureDictionary() + /// The returned object must be deleted after use, by calling the `delete` 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.JlObject getLastSignatureDictionary() => + jni.JlObject.fromRef(_getLastSignatureDictionary(reference)); + + static final _getSignatureFields = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_getSignatureFields") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.util.List getSignatureFields() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Retrieve all signature fields from the document. + ///@return a List of PDSignatureFields + ///@throws IOException if no document catalog can be found. + jni.JlObject getSignatureFields() => + jni.JlObject.fromRef(_getSignatureFields(reference)); + + static final _getSignatureDictionaries = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_getSignatureDictionaries") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.util.List getSignatureDictionaries() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Retrieve all signature dictionaries from the document. + ///@return a List of PDSignatureFields + ///@throws IOException if no document catalog can be found. + jni.JlObject getSignatureDictionaries() => + jni.JlObject.fromRef(_getSignatureDictionaries(reference)); + + static final _registerTrueTypeFontForClosing = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_registerTrueTypeFontForClosing") + .asFunction< + void Function(ffi.Pointer, ffi.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.JlObject ttf) => + _registerTrueTypeFontForClosing(reference, ttf.reference); + + static final _getFontsToSubset = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_getFontsToSubset") + .asFunction Function(ffi.Pointer)>(); + + /// from: java.util.Set getFontsToSubset() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Returns the list of fonts which will be subset before the document is saved. + jni.JlObject getFontsToSubset() => + jni.JlObject.fromRef(_getFontsToSubset(reference)); + + static final _load = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_load") + .asFunction Function(ffi.Pointer)>(); + + /// from: static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.File file) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// 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.JlObject file) => + PDDocument.fromRef(_load(file.reference)); + + static final _load1 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_load1") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.File file, org.apache.pdfbox.io.MemoryUsageSetting memUsageSetting) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// 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 load1(jni.JlObject file, jni.JlObject memUsageSetting) => + PDDocument.fromRef(_load1(file.reference, memUsageSetting.reference)); + + static final _load2 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_load2") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.File file, java.lang.String password) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// 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 load2(jni.JlObject file, jni.JlString password) => + PDDocument.fromRef(_load2(file.reference, password.reference)); + + static final _load3 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_load3") + .asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.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 deleted after use, by calling the `delete` method. + /// + /// 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 load3(jni.JlObject file, jni.JlString password, + jni.JlObject memUsageSetting) => + PDDocument.fromRef(_load3( + file.reference, password.reference, memUsageSetting.reference)); + + static final _load4 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_load4") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.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 deleted after use, by calling the `delete` method. + /// + /// 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 load4(jni.JlObject file, jni.JlString password, + jni.JlObject keyStore, jni.JlString alias) => + PDDocument.fromRef(_load4(file.reference, password.reference, + keyStore.reference, alias.reference)); + + static final _load5 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_load5") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.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 deleted after use, by calling the `delete` method. + /// + /// 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 load5( + jni.JlObject file, + jni.JlString password, + jni.JlObject keyStore, + jni.JlString alias, + jni.JlObject memUsageSetting) => + PDDocument.fromRef(_load5(file.reference, password.reference, + keyStore.reference, alias.reference, memUsageSetting.reference)); + + static final _load6 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_load6") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + /// from: private static org.apache.pdfbox.pdmodel.PDDocument load(org.apache.pdfbox.io.RandomAccessBufferedFileInputStream raFile, java.lang.String password, java.io.InputStream keyStore, java.lang.String alias, org.apache.pdfbox.io.MemoryUsageSetting memUsageSetting) + /// The returned object must be deleted after use, by calling the `delete` method. + static PDDocument load6( + jni.JlObject raFile, + jni.JlString password, + jni.JlObject keyStore, + jni.JlString alias, + jni.JlObject memUsageSetting) => + PDDocument.fromRef(_load6(raFile.reference, password.reference, + keyStore.reference, alias.reference, memUsageSetting.reference)); + + static final _load7 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_load7") + .asFunction Function(ffi.Pointer)>(); + + /// from: static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.InputStream input) + /// The returned object must be deleted after use, by calling the `delete` 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 load7(jni.JlObject input) => + PDDocument.fromRef(_load7(input.reference)); + + static final _load8 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_load8") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.InputStream input, org.apache.pdfbox.io.MemoryUsageSetting memUsageSetting) + /// The returned object must be deleted after use, by calling the `delete` 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 load8(jni.JlObject input, jni.JlObject memUsageSetting) => + PDDocument.fromRef(_load8(input.reference, memUsageSetting.reference)); + + static final _load9 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_load9") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.InputStream input, java.lang.String password) + /// The returned object must be deleted after use, by calling the `delete` 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 + ///@return loaded document + ///@throws InvalidPasswordException If the password is incorrect. + ///@throws IOException In case of a reading or parsing error. + static PDDocument load9(jni.JlObject input, jni.JlString password) => + PDDocument.fromRef(_load9(input.reference, password.reference)); + + static final _load10 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_load10") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + /// 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 deleted after use, by calling the `delete` 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 load10(jni.JlObject input, jni.JlString password, + jni.JlObject keyStore, jni.JlString alias) => + PDDocument.fromRef(_load10(input.reference, password.reference, + keyStore.reference, alias.reference)); + + static final _load11 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_load11") + .asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + /// 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 deleted after use, by calling the `delete` 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 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 load11(jni.JlObject input, jni.JlString password, + jni.JlObject memUsageSetting) => + PDDocument.fromRef(_load11( + input.reference, password.reference, memUsageSetting.reference)); + + static final _load12 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_load12") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + /// 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 deleted after use, by calling the `delete` 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 load12( + jni.JlObject input, + jni.JlString password, + jni.JlObject keyStore, + jni.JlString alias, + jni.JlObject memUsageSetting) => + PDDocument.fromRef(_load12(input.reference, password.reference, + keyStore.reference, alias.reference, memUsageSetting.reference)); + + static final _load13 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_load13") + .asFunction Function(ffi.Pointer)>(); + + /// from: static public org.apache.pdfbox.pdmodel.PDDocument load(byte[] input) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// 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 load13(jni.JlObject input) => + PDDocument.fromRef(_load13(input.reference)); + + static final _load14 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_load14") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: static public org.apache.pdfbox.pdmodel.PDDocument load(byte[] input, java.lang.String password) + /// The returned object must be deleted after use, by calling the `delete` 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 load14(jni.JlObject input, jni.JlString password) => + PDDocument.fromRef(_load14(input.reference, password.reference)); + + static final _load15 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_load15") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + /// 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 deleted after use, by calling the `delete` 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 load15(jni.JlObject input, jni.JlString password, + jni.JlObject keyStore, jni.JlString alias) => + PDDocument.fromRef(_load15(input.reference, password.reference, + keyStore.reference, alias.reference)); + + static final _load16 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_load16") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + /// 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 deleted after use, by calling the `delete` 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 load16( + jni.JlObject input, + jni.JlString password, + jni.JlObject keyStore, + jni.JlString alias, + jni.JlObject memUsageSetting) => + PDDocument.fromRef(_load16(input.reference, password.reference, + keyStore.reference, alias.reference, memUsageSetting.reference)); + + static final _save = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_save") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: public void save(java.lang.String fileName) + /// + /// Save the document to a file. + /// + /// If encryption has been activated (with + /// \#protect(org.apache.pdfbox.pdmodel.encryption.ProtectionPolicy) protect(ProtectionPolicy)), + /// do not use the document after saving because the contents are now encrypted. + ///@param fileName The file to save as. + ///@throws IOException if the output could not be written + void save(jni.JlString fileName) => _save(reference, fileName.reference); + + static final _save1 = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_save1") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: public void save(java.io.File file) + /// + /// Save the document to a file. + /// + /// If encryption has been activated (with + /// \#protect(org.apache.pdfbox.pdmodel.encryption.ProtectionPolicy) protect(ProtectionPolicy)), + /// do not use the document after saving because the contents are now encrypted. + ///@param file The file to save as. + ///@throws IOException if the output could not be written + void save1(jni.JlObject file) => _save1(reference, file.reference); + + static final _save2 = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_save2") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: public void save(java.io.OutputStream output) + /// + /// This will save the document to an output stream. + /// + /// If encryption has been activated (with + /// \#protect(org.apache.pdfbox.pdmodel.encryption.ProtectionPolicy) protect(ProtectionPolicy)), + /// do not use the document after saving because the contents are now encrypted. + ///@param output The stream to write to. It will be closed when done. It is recommended to wrap + /// it in a java.io.BufferedOutputStream, unless it is already buffered. + ///@throws IOException if the output could not be written + void save2(jni.JlObject output) => _save2(reference, output.reference); + + static final _saveIncremental = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_saveIncremental") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: public void saveIncremental(java.io.OutputStream output) + /// + /// Save the PDF as an incremental update. This is only possible if the PDF was loaded from a + /// file or a stream, not if the document was created in PDFBox itself. There must be a path of + /// objects that have COSUpdateInfo\#isNeedToBeUpdated() set, starting from the document + /// catalog. For signatures this is taken care by PDFBox itself. + /// + /// Other usages of this method are for experienced users only. You will usually never need it. + /// It is useful only if you are required to keep the current revision and append the changes. A + /// typical use case is changing a signed file without invalidating the signature. + ///@param output stream to write to. It will be closed when done. It + /// __must never__ point to the source file or that one will be + /// harmed! + ///@throws IOException if the output could not be written + ///@throws IllegalStateException if the document was not loaded from a file or a stream. + void saveIncremental(jni.JlObject output) => + _saveIncremental(reference, output.reference); + + static final _saveIncremental1 = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_saveIncremental1") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + /// from: public void saveIncremental(java.io.OutputStream output, java.util.Set objectsToWrite) + /// + /// Save the PDF as an incremental update. This is only possible if the PDF was loaded from a + /// file or a stream, not if the document was created in PDFBox itself. This allows to include + /// objects even if there is no path of objects that have + /// COSUpdateInfo\#isNeedToBeUpdated() set so the incremental update gets smaller. Only + /// dictionaries are supported; if you need to update other objects classes, then add their + /// parent dictionary. + /// + /// This method is for experienced users only. You will usually never need it. It is useful only + /// if you are required to keep the current revision and append the changes. A typical use case + /// is changing a signed file without invalidating the signature. To know which objects are + /// getting changed, you need to have some understanding of the PDF specification, and look at + /// the saved file with an editor to verify that you are updating the correct objects. You should + /// also inspect the page and document structures of the file with PDFDebugger. + ///@param output stream to write to. It will be closed when done. It + /// __must never__ point to the source file or that one will be harmed! + ///@param objectsToWrite objects that __must__ be part of the incremental saving. + ///@throws IOException if the output could not be written + ///@throws IllegalStateException if the document was not loaded from a file or a stream. + void saveIncremental1(jni.JlObject output, jni.JlObject objectsToWrite) => + _saveIncremental1(reference, output.reference, objectsToWrite.reference); + + static final _saveIncrementalForExternalSigning = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_saveIncrementalForExternalSigning") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public org.apache.pdfbox.pdmodel.interactive.digitalsignature.ExternalSigningSupport saveIncrementalForExternalSigning(java.io.OutputStream output) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// + /// __(This is a new feature for 2.0.3. The API for external signing might change based on feedback after release!)__ + /// + /// Save PDF incrementally without closing for external signature creation scenario. The general + /// sequence is: + ///
+  ///    PDDocument pdDocument = ...;
+  ///    OutputStream outputStream = ...;
+  ///    SignatureOptions signatureOptions = ...; // options to specify fine tuned signature options or null for defaults
+  ///    PDSignature pdSignature = ...;
+  ///
+  ///    // add signature parameters to be used when creating signature dictionary
+  ///    pdDocument.addSignature(pdSignature, signatureOptions);
+  ///    // prepare PDF for signing and obtain helper class to be used
+  ///    ExternalSigningSupport externalSigningSupport = pdDocument.saveIncrementalForExternalSigning(outputStream);
+  ///    // get data to be signed
+  ///    InputStream dataToBeSigned = externalSigningSupport.getContent();
+  ///    // invoke signature service
+  ///    byte[] signature = sign(dataToBeSigned);
+  ///    // set resulted CMS signature
+  ///    externalSigningSupport.setSignature(signature);
+  ///
+  ///    // last step is to close the document
+  ///    pdDocument.close();
+  /// 
+ /// + /// Note that after calling this method, only {@code close()} method may invoked for + /// {@code PDDocument} instance and only AFTER ExternalSigningSupport instance is used. + /// + /// + ///@param output stream to write the final PDF. It will be closed when the + /// document is closed. It __must never__ point to the source file + /// or that one will be harmed! + ///@return instance to be used for external signing and setting CMS signature + ///@throws IOException if the output could not be written + ///@throws IllegalStateException if the document was not loaded from a file or a stream or + /// signature options were not set. + jni.JlObject saveIncrementalForExternalSigning(jni.JlObject output) => + jni.JlObject.fromRef( + _saveIncrementalForExternalSigning(reference, output.reference)); + + static final _getPage = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Int32)>>("org_apache_pdfbox_pdmodel_PDDocument_getPage") + .asFunction Function(ffi.Pointer, int)>(); + + /// from: public org.apache.pdfbox.pdmodel.PDPage getPage(int pageIndex) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Returns the page at the given 0-based index. + /// + /// This method is too slow to get all the pages from a large PDF document + /// (1000 pages or more). For such documents, use the iterator of + /// PDDocument\#getPages() instead. + ///@param pageIndex the 0-based page index + ///@return the page at the given index. + jni.JlObject getPage(int pageIndex) => + jni.JlObject.fromRef(_getPage(reference, pageIndex)); + + static final _getPages = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_getPages") + .asFunction Function(ffi.Pointer)>(); + + /// from: public org.apache.pdfbox.pdmodel.PDPageTree getPages() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Returns the page tree. + ///@return the page tree + jni.JlObject getPages() => jni.JlObject.fromRef(_getPages(reference)); + + static final _getNumberOfPages = + jlookup)>>( + "org_apache_pdfbox_pdmodel_PDDocument_getNumberOfPages") + .asFunction)>(); + + /// from: public int getNumberOfPages() + /// + /// This will return the total page count of the PDF document. + ///@return The total number of pages in the PDF document. + int getNumberOfPages() => _getNumberOfPages(reference); + + static final _close = + jlookup)>>( + "org_apache_pdfbox_pdmodel_PDDocument_close") + .asFunction)>(); + + /// from: public void close() + /// + /// This will close the underlying COSDocument object. + ///@throws IOException If there is an error releasing resources. + void close() => _close(reference); + + static final _protect = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_protect") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: public void protect(org.apache.pdfbox.pdmodel.encryption.ProtectionPolicy policy) + /// + /// Protects the document with a protection policy. The document content will be really + /// encrypted when it will be saved. This method only marks the document for encryption. It also + /// calls \#setAllSecurityToBeRemoved(boolean) with a false argument if it was set to true + /// previously and logs a warning. + /// + /// Do not use the document after saving, because the structures are encrypted. + ///@see org.apache.pdfbox.pdmodel.encryption.StandardProtectionPolicy + ///@see org.apache.pdfbox.pdmodel.encryption.PublicKeyProtectionPolicy + ///@param policy The protection policy. + ///@throws IOException if there isn't any suitable security handler. + void protect(jni.JlObject policy) => _protect(reference, policy.reference); + + static final _getCurrentAccessPermission = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_getCurrentAccessPermission") + .asFunction Function(ffi.Pointer)>(); + + /// from: public org.apache.pdfbox.pdmodel.encryption.AccessPermission getCurrentAccessPermission() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Returns the access permissions granted when the document was decrypted. If the document was not decrypted this + /// method returns the access permission for a document owner (ie can do everything). The returned object is in read + /// only mode so that permissions cannot be changed. Methods providing access to content should rely on this object + /// to verify if the current user is allowed to proceed. + ///@return the access permissions for the current user on the document. + jni.JlObject getCurrentAccessPermission() => + jni.JlObject.fromRef(_getCurrentAccessPermission(reference)); + + static final _isAllSecurityToBeRemoved = + jlookup)>>( + "org_apache_pdfbox_pdmodel_PDDocument_isAllSecurityToBeRemoved") + .asFunction)>(); + + /// from: public boolean isAllSecurityToBeRemoved() + /// + /// Indicates if all security is removed or not when writing the pdf. + ///@return returns true if all security shall be removed otherwise false + bool isAllSecurityToBeRemoved() => _isAllSecurityToBeRemoved(reference) != 0; + + static final _setAllSecurityToBeRemoved = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Uint8)>>( + "org_apache_pdfbox_pdmodel_PDDocument_setAllSecurityToBeRemoved") + .asFunction, int)>(); + + /// from: public void setAllSecurityToBeRemoved(boolean removeAllSecurity) + /// + /// Activates/Deactivates the removal of all security when writing the pdf. + ///@param removeAllSecurity remove all security if set to true + void setAllSecurityToBeRemoved(bool removeAllSecurity) => + _setAllSecurityToBeRemoved(reference, removeAllSecurity ? 1 : 0); + + static final _getDocumentId = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_getDocumentId") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.lang.Long getDocumentId() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Provides the document ID. + ///@return the document ID + jni.JlObject getDocumentId() => + jni.JlObject.fromRef(_getDocumentId(reference)); + + static final _setDocumentId = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_setDocumentId") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: public void setDocumentId(java.lang.Long docId) + /// + /// Sets the document ID to the given value. + ///@param docId the new document ID + void setDocumentId(jni.JlObject docId) => + _setDocumentId(reference, docId.reference); + + static final _getVersion = + jlookup)>>( + "org_apache_pdfbox_pdmodel_PDDocument_getVersion") + .asFunction)>(); + + /// from: public float getVersion() + /// + /// Returns the PDF specification version this document conforms to. + ///@return the PDF version (e.g. 1.4f) + double getVersion() => _getVersion(reference); + + static final _setVersion = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Float)>>( + "org_apache_pdfbox_pdmodel_PDDocument_setVersion") + .asFunction, double)>(); + + /// from: public void setVersion(float newVersion) + /// + /// Sets the PDF specification version for this document. + ///@param newVersion the new PDF version (e.g. 1.4f) + void setVersion(double newVersion) => _setVersion(reference, newVersion); + + static final _getResourceCache = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_getResourceCache") + .asFunction Function(ffi.Pointer)>(); + + /// from: public org.apache.pdfbox.pdmodel.ResourceCache getResourceCache() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Returns the resource cache associated with this document, or null if there is none. + ///@return the resource cache or null. + jni.JlObject getResourceCache() => + jni.JlObject.fromRef(_getResourceCache(reference)); + + static final _setResourceCache = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocument_setResourceCache") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: public void setResourceCache(org.apache.pdfbox.pdmodel.ResourceCache resourceCache) + /// + /// Sets the resource cache associated with this document. + ///@param resourceCache A resource cache, or null. + void setResourceCache(jni.JlObject resourceCache) => + _setResourceCache(reference, resourceCache.reference); +} + +/// from: org.apache.pdfbox.pdmodel.PDDocumentInformation +/// +/// This is the document metadata. Each getXXX method will return the entry if +/// it exists or null if it does not exist. If you pass in null for the setXXX +/// method then it will clear the value. +///@author Ben Litchfield +///@author Gerardo Ortiz +class PDDocumentInformation extends jni.JlObject { + PDDocumentInformation.fromRef(ffi.Pointer ref) : super.fromRef(ref); + + static final _get_info = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_pdmodel_PDDocumentInformation_info") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + )>(); + + /// from: private final org.apache.pdfbox.cos.COSDictionary info + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JlObject get info => jni.JlObject.fromRef(_get_info(reference)); + + static final _ctor = + jlookup Function()>>( + "org_apache_pdfbox_pdmodel_PDDocumentInformation_ctor") + .asFunction Function()>(); + + /// from: public void () + /// + /// Default Constructor. + PDDocumentInformation() : super.fromRef(_ctor()); + + static final _ctor1 = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocumentInformation_ctor1") + .asFunction Function(ffi.Pointer)>(); + + /// from: public void (org.apache.pdfbox.cos.COSDictionary dic) + /// + /// Constructor that is used for a preexisting dictionary. + ///@param dic The underlying dictionary. + PDDocumentInformation.ctor1(jni.JlObject dic) + : super.fromRef(_ctor1(dic.reference)); + + static final _getCOSObject = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocumentInformation_getCOSObject") + .asFunction Function(ffi.Pointer)>(); + + /// from: public org.apache.pdfbox.cos.COSDictionary getCOSObject() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// This will get the underlying dictionary that this object wraps. + ///@return The underlying info dictionary. + jni.JlObject getCOSObject() => jni.JlObject.fromRef(_getCOSObject(reference)); + + static final _getPropertyStringValue = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocumentInformation_getPropertyStringValue") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public java.lang.Object getPropertyStringValue(java.lang.String propertyKey) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Return the properties String value. + /// + /// Allows to retrieve the + /// low level date for validation purposes. + /// + /// + ///@param propertyKey the dictionaries key + ///@return the properties value + jni.JlObject getPropertyStringValue(jni.JlString propertyKey) => + jni.JlObject.fromRef( + _getPropertyStringValue(reference, propertyKey.reference)); + + static final _getTitle = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocumentInformation_getTitle") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.lang.String getTitle() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// This will get the title of the document. This will return null if no title exists. + ///@return The title of the document. + jni.JlString getTitle() => jni.JlString.fromRef(_getTitle(reference)); + + static final _setTitle = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocumentInformation_setTitle") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: public void setTitle(java.lang.String title) + /// + /// This will set the title of the document. + ///@param title The new title for the document. + void setTitle(jni.JlString title) => _setTitle(reference, title.reference); + + static final _getAuthor = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocumentInformation_getAuthor") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.lang.String getAuthor() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// This will get the author of the document. This will return null if no author exists. + ///@return The author of the document. + jni.JlString getAuthor() => jni.JlString.fromRef(_getAuthor(reference)); + + static final _setAuthor = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocumentInformation_setAuthor") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: public void setAuthor(java.lang.String author) + /// + /// This will set the author of the document. + ///@param author The new author for the document. + void setAuthor(jni.JlString author) => + _setAuthor(reference, author.reference); + + static final _getSubject = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocumentInformation_getSubject") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.lang.String getSubject() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// This will get the subject of the document. This will return null if no subject exists. + ///@return The subject of the document. + jni.JlString getSubject() => jni.JlString.fromRef(_getSubject(reference)); + + static final _setSubject = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocumentInformation_setSubject") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: public void setSubject(java.lang.String subject) + /// + /// This will set the subject of the document. + ///@param subject The new subject for the document. + void setSubject(jni.JlString subject) => + _setSubject(reference, subject.reference); + + static final _getKeywords = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocumentInformation_getKeywords") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.lang.String getKeywords() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// This will get the keywords of the document. This will return null if no keywords exists. + ///@return The keywords of the document. + jni.JlString getKeywords() => jni.JlString.fromRef(_getKeywords(reference)); + + static final _setKeywords = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocumentInformation_setKeywords") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: public void setKeywords(java.lang.String keywords) + /// + /// This will set the keywords of the document. + ///@param keywords The new keywords for the document. + void setKeywords(jni.JlString keywords) => + _setKeywords(reference, keywords.reference); + + static final _getCreator = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocumentInformation_getCreator") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.lang.String getCreator() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// This will get the creator of the document. This will return null if no creator exists. + ///@return The creator of the document. + jni.JlString getCreator() => jni.JlString.fromRef(_getCreator(reference)); + + static final _setCreator = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocumentInformation_setCreator") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: public void setCreator(java.lang.String creator) + /// + /// This will set the creator of the document. + ///@param creator The new creator for the document. + void setCreator(jni.JlString creator) => + _setCreator(reference, creator.reference); + + static final _getProducer = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocumentInformation_getProducer") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.lang.String getProducer() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// This will get the producer of the document. This will return null if no producer exists. + ///@return The producer of the document. + jni.JlString getProducer() => jni.JlString.fromRef(_getProducer(reference)); + + static final _setProducer = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocumentInformation_setProducer") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: public void setProducer(java.lang.String producer) + /// + /// This will set the producer of the document. + ///@param producer The new producer for the document. + void setProducer(jni.JlString producer) => + _setProducer(reference, producer.reference); + + static final _getCreationDate = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocumentInformation_getCreationDate") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.util.Calendar getCreationDate() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// 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.JlObject getCreationDate() => + jni.JlObject.fromRef(_getCreationDate(reference)); + + static final _setCreationDate = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocumentInformation_setCreationDate") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: public void setCreationDate(java.util.Calendar date) + /// + /// This will set the creation date of the document. + ///@param date The new creation date for the document. + void setCreationDate(jni.JlObject date) => + _setCreationDate(reference, date.reference); + + static final _getModificationDate = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocumentInformation_getModificationDate") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.util.Calendar getModificationDate() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// This will get the modification date of the document. This will return null if no modification date exists. + ///@return The modification date of the document. + jni.JlObject getModificationDate() => + jni.JlObject.fromRef(_getModificationDate(reference)); + + static final _setModificationDate = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocumentInformation_setModificationDate") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: public void setModificationDate(java.util.Calendar date) + /// + /// This will set the modification date of the document. + ///@param date The new modification date for the document. + void setModificationDate(jni.JlObject date) => + _setModificationDate(reference, date.reference); + + static final _getTrapped = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocumentInformation_getTrapped") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.lang.String getTrapped() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// This will get the trapped value for the document. + /// This will return null if one is not found. + ///@return The trapped value for the document. + jni.JlString getTrapped() => jni.JlString.fromRef(_getTrapped(reference)); + + static final _getMetadataKeys = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocumentInformation_getMetadataKeys") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.util.Set getMetadataKeys() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// This will get the keys of all metadata information fields for the document. + ///@return all metadata key strings. + ///@since Apache PDFBox 1.3.0 + jni.JlObject getMetadataKeys() => + jni.JlObject.fromRef(_getMetadataKeys(reference)); + + static final _getCustomMetadataValue = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocumentInformation_getCustomMetadataValue") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public java.lang.String getCustomMetadataValue(java.lang.String fieldName) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// This will get the value of a custom metadata information field for the document. + /// This will return null if one is not found. + ///@param fieldName Name of custom metadata field from pdf document. + ///@return String Value of metadata field + jni.JlString getCustomMetadataValue(jni.JlString fieldName) => + jni.JlString.fromRef( + _getCustomMetadataValue(reference, fieldName.reference)); + + static final _setCustomMetadataValue = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocumentInformation_setCustomMetadataValue") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + /// from: public void setCustomMetadataValue(java.lang.String fieldName, java.lang.String fieldValue) + /// + /// Set the custom metadata value. + ///@param fieldName The name of the custom metadata field. + ///@param fieldValue The value to the custom metadata field. + void setCustomMetadataValue( + jni.JlString fieldName, jni.JlString fieldValue) => + _setCustomMetadataValue( + reference, fieldName.reference, fieldValue.reference); + + static final _setTrapped = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_pdmodel_PDDocumentInformation_setTrapped") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: public void setTrapped(java.lang.String value) + /// + /// This will set the trapped of the document. This will be + /// 'True', 'False', or 'Unknown'. + ///@param value The new trapped value for the document. + ///@throws IllegalArgumentException if the parameter is invalid. + void setTrapped(jni.JlString value) => + _setTrapped(reference, value.reference); +} diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/lib/third_party/org/apache/pdfbox/text.dart b/pkgs/jni_gen/examples/pdfbox_plugin/lib/third_party/org/apache/pdfbox/text.dart new file mode 100644 index 000000000..0b8fe1eaa --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/lib/third_party/org/apache/pdfbox/text.dart @@ -0,0 +1,2223 @@ +// Generated from Apache PDFBox library which is licensed under the Apache License 2.0. +// The following copyright from the original authors applies. +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Autogenerated by jni_gen. DO NOT EDIT! + +// ignore_for_file: camel_case_types +// ignore_for_file: non_constant_identifier_names +// ignore_for_file: constant_identifier_names +// ignore_for_file: annotate_overrides +// ignore_for_file: no_leading_underscores_for_local_identifiers +// ignore_for_file: unused_element + +import "dart:ffi" as ffi; + +import "package:jni/jni.dart" as jni; + +import "../pdfbox/pdmodel.dart" as pdmodel_; +import "../../../init.dart" show jlookup; + +/// from: org.apache.pdfbox.text.PDFTextStripper +/// +/// This class will take a pdf document and strip out all of the text and ignore the formatting and such. Please note; it +/// is up to clients of this class to verify that a specific user has the correct permissions to extract text from the +/// PDF document. +/// +/// 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.JlObject { + PDFTextStripper.fromRef(ffi.Pointer ref) : super.fromRef(ref); + + static final _get_defaultIndentThreshold = jlookup< + ffi.NativeFunction>( + "get_org_apache_pdfbox_text_PDFTextStripper_defaultIndentThreshold") + .asFunction(); + + /// from: private static float defaultIndentThreshold + static double get defaultIndentThreshold => _get_defaultIndentThreshold(); + static final _set_defaultIndentThreshold = jlookup< + ffi.NativeFunction>( + "set_org_apache_pdfbox_text_PDFTextStripper_defaultIndentThreshold") + .asFunction(); + + /// from: private static float defaultIndentThreshold + static set defaultIndentThreshold(double value) => + _set_defaultIndentThreshold(value); + + static final _get_defaultDropThreshold = + jlookup>( + "get_org_apache_pdfbox_text_PDFTextStripper_defaultDropThreshold") + .asFunction(); + + /// from: private static float defaultDropThreshold + static double get defaultDropThreshold => _get_defaultDropThreshold(); + static final _set_defaultDropThreshold = + jlookup>( + "set_org_apache_pdfbox_text_PDFTextStripper_defaultDropThreshold") + .asFunction(); + + /// from: private static float defaultDropThreshold + static set defaultDropThreshold(double value) => + _set_defaultDropThreshold(value); + + static final _get_LOG = + jlookup Function()>>( + "get_org_apache_pdfbox_text_PDFTextStripper_LOG") + .asFunction Function()>(); + + /// from: private static final org.apache.commons.logging.Log LOG + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JlObject get LOG => jni.JlObject.fromRef(_get_LOG()); + + static final _get_LINE_SEPARATOR = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_text_PDFTextStripper_LINE_SEPARATOR") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + )>(); + + /// from: protected final java.lang.String LINE_SEPARATOR + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// The platform's line separator. + jni.JlString get LINE_SEPARATOR => + jni.JlString.fromRef(_get_LINE_SEPARATOR(reference)); + + static final _get_lineSeparator = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_text_PDFTextStripper_lineSeparator") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + )>(); + + /// from: private java.lang.String lineSeparator + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JlString get lineSeparator => + jni.JlString.fromRef(_get_lineSeparator(reference)); + static final _set_lineSeparator = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "set_org_apache_pdfbox_text_PDFTextStripper_lineSeparator") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: private java.lang.String lineSeparator + /// The returned object must be deleted after use, by calling the `delete` method. + set lineSeparator(jni.JlString value) => + _set_lineSeparator(reference, value.reference); + + static final _get_wordSeparator = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_text_PDFTextStripper_wordSeparator") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + )>(); + + /// from: private java.lang.String wordSeparator + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JlString get wordSeparator => + jni.JlString.fromRef(_get_wordSeparator(reference)); + static final _set_wordSeparator = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "set_org_apache_pdfbox_text_PDFTextStripper_wordSeparator") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: private java.lang.String wordSeparator + /// The returned object must be deleted after use, by calling the `delete` method. + set wordSeparator(jni.JlString value) => + _set_wordSeparator(reference, value.reference); + + static final _get_paragraphStart = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_text_PDFTextStripper_paragraphStart") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + )>(); + + /// from: private java.lang.String paragraphStart + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JlString get paragraphStart => + jni.JlString.fromRef(_get_paragraphStart(reference)); + static final _set_paragraphStart = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "set_org_apache_pdfbox_text_PDFTextStripper_paragraphStart") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: private java.lang.String paragraphStart + /// The returned object must be deleted after use, by calling the `delete` method. + set paragraphStart(jni.JlString value) => + _set_paragraphStart(reference, value.reference); + + static final _get_paragraphEnd = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_text_PDFTextStripper_paragraphEnd") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + )>(); + + /// from: private java.lang.String paragraphEnd + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JlString get paragraphEnd => + jni.JlString.fromRef(_get_paragraphEnd(reference)); + static final _set_paragraphEnd = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "set_org_apache_pdfbox_text_PDFTextStripper_paragraphEnd") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: private java.lang.String paragraphEnd + /// The returned object must be deleted after use, by calling the `delete` method. + set paragraphEnd(jni.JlString value) => + _set_paragraphEnd(reference, value.reference); + + static final _get_pageStart = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_text_PDFTextStripper_pageStart") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + )>(); + + /// from: private java.lang.String pageStart + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JlString get pageStart => jni.JlString.fromRef(_get_pageStart(reference)); + static final _set_pageStart = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "set_org_apache_pdfbox_text_PDFTextStripper_pageStart") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: private java.lang.String pageStart + /// The returned object must be deleted after use, by calling the `delete` method. + set pageStart(jni.JlString value) => + _set_pageStart(reference, value.reference); + + static final _get_pageEnd = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_text_PDFTextStripper_pageEnd") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + )>(); + + /// from: private java.lang.String pageEnd + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JlString get pageEnd => jni.JlString.fromRef(_get_pageEnd(reference)); + static final _set_pageEnd = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "set_org_apache_pdfbox_text_PDFTextStripper_pageEnd") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: private java.lang.String pageEnd + /// The returned object must be deleted after use, by calling the `delete` method. + set pageEnd(jni.JlString value) => _set_pageEnd(reference, value.reference); + + static final _get_articleStart = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_text_PDFTextStripper_articleStart") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + )>(); + + /// from: private java.lang.String articleStart + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JlString get articleStart => + jni.JlString.fromRef(_get_articleStart(reference)); + static final _set_articleStart = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "set_org_apache_pdfbox_text_PDFTextStripper_articleStart") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: private java.lang.String articleStart + /// The returned object must be deleted after use, by calling the `delete` method. + set articleStart(jni.JlString value) => + _set_articleStart(reference, value.reference); + + static final _get_articleEnd = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_text_PDFTextStripper_articleEnd") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + )>(); + + /// from: private java.lang.String articleEnd + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JlString get articleEnd => + jni.JlString.fromRef(_get_articleEnd(reference)); + static final _set_articleEnd = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "set_org_apache_pdfbox_text_PDFTextStripper_articleEnd") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: private java.lang.String articleEnd + /// The returned object must be deleted after use, by calling the `delete` method. + set articleEnd(jni.JlString value) => + _set_articleEnd(reference, value.reference); + + static final _get_currentPageNo = jlookup< + ffi.NativeFunction< + ffi.Int32 Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_text_PDFTextStripper_currentPageNo") + .asFunction< + int Function( + ffi.Pointer, + )>(); + + /// from: private int currentPageNo + int get currentPageNo => _get_currentPageNo(reference); + static final _set_currentPageNo = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Int32)>>( + "set_org_apache_pdfbox_text_PDFTextStripper_currentPageNo") + .asFunction, int)>(); + + /// from: private int currentPageNo + set currentPageNo(int value) => _set_currentPageNo(reference, value); + + static final _get_startPage = jlookup< + ffi.NativeFunction< + ffi.Int32 Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_text_PDFTextStripper_startPage") + .asFunction< + int Function( + ffi.Pointer, + )>(); + + /// from: private int startPage + int get startPage => _get_startPage(reference); + static final _set_startPage = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Int32)>>( + "set_org_apache_pdfbox_text_PDFTextStripper_startPage") + .asFunction, int)>(); + + /// from: private int startPage + set startPage(int value) => _set_startPage(reference, value); + + static final _get_endPage = jlookup< + ffi.NativeFunction< + ffi.Int32 Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_text_PDFTextStripper_endPage") + .asFunction< + int Function( + ffi.Pointer, + )>(); + + /// from: private int endPage + int get endPage => _get_endPage(reference); + static final _set_endPage = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Int32)>>( + "set_org_apache_pdfbox_text_PDFTextStripper_endPage") + .asFunction, int)>(); + + /// from: private int endPage + set endPage(int value) => _set_endPage(reference, value); + + static final _get_startBookmark = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_text_PDFTextStripper_startBookmark") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + )>(); + + /// from: private org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem startBookmark + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JlObject get startBookmark => + jni.JlObject.fromRef(_get_startBookmark(reference)); + static final _set_startBookmark = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "set_org_apache_pdfbox_text_PDFTextStripper_startBookmark") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: private org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem startBookmark + /// The returned object must be deleted after use, by calling the `delete` method. + set startBookmark(jni.JlObject value) => + _set_startBookmark(reference, value.reference); + + static final _get_startBookmarkPageNumber = jlookup< + ffi.NativeFunction< + ffi.Int32 Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_text_PDFTextStripper_startBookmarkPageNumber") + .asFunction< + int Function( + ffi.Pointer, + )>(); + + /// from: private int startBookmarkPageNumber + int get startBookmarkPageNumber => _get_startBookmarkPageNumber(reference); + static final _set_startBookmarkPageNumber = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Int32)>>( + "set_org_apache_pdfbox_text_PDFTextStripper_startBookmarkPageNumber") + .asFunction, int)>(); + + /// from: private int startBookmarkPageNumber + set startBookmarkPageNumber(int value) => + _set_startBookmarkPageNumber(reference, value); + + static final _get_endBookmarkPageNumber = jlookup< + ffi.NativeFunction< + ffi.Int32 Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_text_PDFTextStripper_endBookmarkPageNumber") + .asFunction< + int Function( + ffi.Pointer, + )>(); + + /// from: private int endBookmarkPageNumber + int get endBookmarkPageNumber => _get_endBookmarkPageNumber(reference); + static final _set_endBookmarkPageNumber = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Int32)>>( + "set_org_apache_pdfbox_text_PDFTextStripper_endBookmarkPageNumber") + .asFunction, int)>(); + + /// from: private int endBookmarkPageNumber + set endBookmarkPageNumber(int value) => + _set_endBookmarkPageNumber(reference, value); + + static final _get_endBookmark = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_text_PDFTextStripper_endBookmark") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + )>(); + + /// from: private org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem endBookmark + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JlObject get endBookmark => + jni.JlObject.fromRef(_get_endBookmark(reference)); + static final _set_endBookmark = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "set_org_apache_pdfbox_text_PDFTextStripper_endBookmark") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: private org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem endBookmark + /// The returned object must be deleted after use, by calling the `delete` method. + set endBookmark(jni.JlObject value) => + _set_endBookmark(reference, value.reference); + + static final _get_suppressDuplicateOverlappingText = jlookup< + ffi.NativeFunction< + ffi.Uint8 Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_text_PDFTextStripper_suppressDuplicateOverlappingText") + .asFunction< + int Function( + ffi.Pointer, + )>(); + + /// from: private boolean suppressDuplicateOverlappingText + bool get suppressDuplicateOverlappingText => + _get_suppressDuplicateOverlappingText(reference) != 0; + static final _set_suppressDuplicateOverlappingText = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Uint8)>>( + "set_org_apache_pdfbox_text_PDFTextStripper_suppressDuplicateOverlappingText") + .asFunction, int)>(); + + /// from: private boolean suppressDuplicateOverlappingText + set suppressDuplicateOverlappingText(bool value) => + _set_suppressDuplicateOverlappingText(reference, value ? 1 : 0); + + static final _get_shouldSeparateByBeads = jlookup< + ffi.NativeFunction< + ffi.Uint8 Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_text_PDFTextStripper_shouldSeparateByBeads") + .asFunction< + int Function( + ffi.Pointer, + )>(); + + /// from: private boolean shouldSeparateByBeads + bool get shouldSeparateByBeads => _get_shouldSeparateByBeads(reference) != 0; + static final _set_shouldSeparateByBeads = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Uint8)>>( + "set_org_apache_pdfbox_text_PDFTextStripper_shouldSeparateByBeads") + .asFunction, int)>(); + + /// from: private boolean shouldSeparateByBeads + set shouldSeparateByBeads(bool value) => + _set_shouldSeparateByBeads(reference, value ? 1 : 0); + + static final _get_sortByPosition = jlookup< + ffi.NativeFunction< + ffi.Uint8 Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_text_PDFTextStripper_sortByPosition") + .asFunction< + int Function( + ffi.Pointer, + )>(); + + /// from: private boolean sortByPosition + bool get sortByPosition => _get_sortByPosition(reference) != 0; + static final _set_sortByPosition = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Uint8)>>( + "set_org_apache_pdfbox_text_PDFTextStripper_sortByPosition") + .asFunction, int)>(); + + /// from: private boolean sortByPosition + set sortByPosition(bool value) => + _set_sortByPosition(reference, value ? 1 : 0); + + static final _get_addMoreFormatting = jlookup< + ffi.NativeFunction< + ffi.Uint8 Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_text_PDFTextStripper_addMoreFormatting") + .asFunction< + int Function( + ffi.Pointer, + )>(); + + /// from: private boolean addMoreFormatting + bool get addMoreFormatting => _get_addMoreFormatting(reference) != 0; + static final _set_addMoreFormatting = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Uint8)>>( + "set_org_apache_pdfbox_text_PDFTextStripper_addMoreFormatting") + .asFunction, int)>(); + + /// from: private boolean addMoreFormatting + set addMoreFormatting(bool value) => + _set_addMoreFormatting(reference, value ? 1 : 0); + + static final _get_indentThreshold = jlookup< + ffi.NativeFunction< + ffi.Float Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_text_PDFTextStripper_indentThreshold") + .asFunction< + double Function( + ffi.Pointer, + )>(); + + /// from: private float indentThreshold + double get indentThreshold => _get_indentThreshold(reference); + static final _set_indentThreshold = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Float)>>( + "set_org_apache_pdfbox_text_PDFTextStripper_indentThreshold") + .asFunction, double)>(); + + /// from: private float indentThreshold + set indentThreshold(double value) => _set_indentThreshold(reference, value); + + static final _get_dropThreshold = jlookup< + ffi.NativeFunction< + ffi.Float Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_text_PDFTextStripper_dropThreshold") + .asFunction< + double Function( + ffi.Pointer, + )>(); + + /// from: private float dropThreshold + double get dropThreshold => _get_dropThreshold(reference); + static final _set_dropThreshold = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Float)>>( + "set_org_apache_pdfbox_text_PDFTextStripper_dropThreshold") + .asFunction, double)>(); + + /// from: private float dropThreshold + set dropThreshold(double value) => _set_dropThreshold(reference, value); + + static final _get_spacingTolerance = jlookup< + ffi.NativeFunction< + ffi.Float Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_text_PDFTextStripper_spacingTolerance") + .asFunction< + double Function( + ffi.Pointer, + )>(); + + /// from: private float spacingTolerance + double get spacingTolerance => _get_spacingTolerance(reference); + static final _set_spacingTolerance = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Float)>>( + "set_org_apache_pdfbox_text_PDFTextStripper_spacingTolerance") + .asFunction, double)>(); + + /// from: private float spacingTolerance + set spacingTolerance(double value) => _set_spacingTolerance(reference, value); + + static final _get_averageCharTolerance = jlookup< + ffi.NativeFunction< + ffi.Float Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_text_PDFTextStripper_averageCharTolerance") + .asFunction< + double Function( + ffi.Pointer, + )>(); + + /// from: private float averageCharTolerance + double get averageCharTolerance => _get_averageCharTolerance(reference); + static final _set_averageCharTolerance = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Float)>>( + "set_org_apache_pdfbox_text_PDFTextStripper_averageCharTolerance") + .asFunction, double)>(); + + /// from: private float averageCharTolerance + set averageCharTolerance(double value) => + _set_averageCharTolerance(reference, value); + + static final _get_beadRectangles = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_text_PDFTextStripper_beadRectangles") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + )>(); + + /// from: private java.util.List beadRectangles + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JlObject get beadRectangles => + jni.JlObject.fromRef(_get_beadRectangles(reference)); + static final _set_beadRectangles = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "set_org_apache_pdfbox_text_PDFTextStripper_beadRectangles") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: private java.util.List beadRectangles + /// The returned object must be deleted after use, by calling the `delete` method. + set beadRectangles(jni.JlObject value) => + _set_beadRectangles(reference, value.reference); + + static final _get_charactersByArticle = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_text_PDFTextStripper_charactersByArticle") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + )>(); + + /// from: protected java.util.ArrayList> charactersByArticle + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// The charactersByArticle is used to extract text by article divisions. For example a PDF that has two columns like + /// a newspaper, we want to extract the first column and then the second column. In this example the PDF would have 2 + /// beads(or articles), one for each column. The size of the charactersByArticle would be 5, because not all text on + /// the screen will fall into one of the articles. The five divisions are shown below + /// + /// Text before first article + /// first article text + /// text between first article and second article + /// second article text + /// text after second article + /// + /// Most PDFs won't have any beads, so charactersByArticle will contain a single entry. + jni.JlObject get charactersByArticle => + jni.JlObject.fromRef(_get_charactersByArticle(reference)); + static final _set_charactersByArticle = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "set_org_apache_pdfbox_text_PDFTextStripper_charactersByArticle") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: protected java.util.ArrayList> charactersByArticle + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// The charactersByArticle is used to extract text by article divisions. For example a PDF that has two columns like + /// a newspaper, we want to extract the first column and then the second column. In this example the PDF would have 2 + /// beads(or articles), one for each column. The size of the charactersByArticle would be 5, because not all text on + /// the screen will fall into one of the articles. The five divisions are shown below + /// + /// Text before first article + /// first article text + /// text between first article and second article + /// second article text + /// text after second article + /// + /// Most PDFs won't have any beads, so charactersByArticle will contain a single entry. + set charactersByArticle(jni.JlObject value) => + _set_charactersByArticle(reference, value.reference); + + static final _get_characterListMapping = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_text_PDFTextStripper_characterListMapping") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + )>(); + + /// from: private java.util.Map>> characterListMapping + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JlObject get characterListMapping => + jni.JlObject.fromRef(_get_characterListMapping(reference)); + static final _set_characterListMapping = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "set_org_apache_pdfbox_text_PDFTextStripper_characterListMapping") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: private java.util.Map>> characterListMapping + /// The returned object must be deleted after use, by calling the `delete` method. + set characterListMapping(jni.JlObject value) => + _set_characterListMapping(reference, value.reference); + + static final _get_document = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_text_PDFTextStripper_document") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + )>(); + + /// from: protected org.apache.pdfbox.pdmodel.PDDocument document + /// The returned object must be deleted after use, by calling the `delete` method. + pdmodel_.PDDocument get document => + pdmodel_.PDDocument.fromRef(_get_document(reference)); + static final _set_document = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "set_org_apache_pdfbox_text_PDFTextStripper_document") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: protected org.apache.pdfbox.pdmodel.PDDocument document + /// The returned object must be deleted after use, by calling the `delete` method. + set document(pdmodel_.PDDocument value) => + _set_document(reference, value.reference); + + static final _get_output = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_text_PDFTextStripper_output") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + )>(); + + /// from: protected java.io.Writer output + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JlObject get output => jni.JlObject.fromRef(_get_output(reference)); + static final _set_output = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "set_org_apache_pdfbox_text_PDFTextStripper_output") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: protected java.io.Writer output + /// The returned object must be deleted after use, by calling the `delete` method. + set output(jni.JlObject value) => _set_output(reference, value.reference); + + static final _get_inParagraph = jlookup< + ffi.NativeFunction< + ffi.Uint8 Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_text_PDFTextStripper_inParagraph") + .asFunction< + int Function( + ffi.Pointer, + )>(); + + /// from: private boolean inParagraph + /// + /// True if we started a paragraph but haven't ended it yet. + bool get inParagraph => _get_inParagraph(reference) != 0; + static final _set_inParagraph = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Uint8)>>( + "set_org_apache_pdfbox_text_PDFTextStripper_inParagraph") + .asFunction, int)>(); + + /// from: private boolean inParagraph + /// + /// True if we started a paragraph but haven't ended it yet. + set inParagraph(bool value) => _set_inParagraph(reference, value ? 1 : 0); + + /// from: private static final float END_OF_LAST_TEXT_X_RESET_VALUE + static const END_OF_LAST_TEXT_X_RESET_VALUE = -1.0; + + /// from: private static final float MAX_Y_FOR_LINE_RESET_VALUE + static const MAX_Y_FOR_LINE_RESET_VALUE = -3.4028235e+38; + + /// from: private static final float EXPECTED_START_OF_NEXT_WORD_X_RESET_VALUE + static const EXPECTED_START_OF_NEXT_WORD_X_RESET_VALUE = -3.4028235e+38; + + /// from: private static final float MAX_HEIGHT_FOR_LINE_RESET_VALUE + static const MAX_HEIGHT_FOR_LINE_RESET_VALUE = -1.0; + + /// from: private static final float MIN_Y_TOP_FOR_LINE_RESET_VALUE + static const MIN_Y_TOP_FOR_LINE_RESET_VALUE = 3.4028235e+38; + + /// from: private static final float LAST_WORD_SPACING_RESET_VALUE + static const LAST_WORD_SPACING_RESET_VALUE = -1.0; + + static final _get_LIST_ITEM_EXPRESSIONS = jlookup< + ffi.NativeFunction Function()>>( + "get_org_apache_pdfbox_text_PDFTextStripper_LIST_ITEM_EXPRESSIONS") + .asFunction Function()>(); + + /// from: private static final java.lang.String[] LIST_ITEM_EXPRESSIONS + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// a list of regular expressions that match commonly used list item formats, i.e. bullets, numbers, letters, Roman + /// numerals, etc. Not meant to be comprehensive. + static jni.JlObject get LIST_ITEM_EXPRESSIONS => + jni.JlObject.fromRef(_get_LIST_ITEM_EXPRESSIONS()); + + static final _get_listOfPatterns = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + )>>("get_org_apache_pdfbox_text_PDFTextStripper_listOfPatterns") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + )>(); + + /// from: private java.util.List listOfPatterns + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JlObject get listOfPatterns => + jni.JlObject.fromRef(_get_listOfPatterns(reference)); + static final _set_listOfPatterns = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "set_org_apache_pdfbox_text_PDFTextStripper_listOfPatterns") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: private java.util.List listOfPatterns + /// The returned object must be deleted after use, by calling the `delete` method. + set listOfPatterns(jni.JlObject value) => + _set_listOfPatterns(reference, value.reference); + + static final _get_MIRRORING_CHAR_MAP = + jlookup Function()>>( + "get_org_apache_pdfbox_text_PDFTextStripper_MIRRORING_CHAR_MAP") + .asFunction Function()>(); + + /// from: private static java.util.Map MIRRORING_CHAR_MAP + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JlObject get MIRRORING_CHAR_MAP => + jni.JlObject.fromRef(_get_MIRRORING_CHAR_MAP()); + static final _set_MIRRORING_CHAR_MAP = + jlookup)>>( + "set_org_apache_pdfbox_text_PDFTextStripper_MIRRORING_CHAR_MAP") + .asFunction)>(); + + /// from: private static java.util.Map MIRRORING_CHAR_MAP + /// The returned object must be deleted after use, by calling the `delete` method. + static set MIRRORING_CHAR_MAP(jni.JlObject value) => + _set_MIRRORING_CHAR_MAP(value.reference); + + static final _ctor = + jlookup Function()>>( + "org_apache_pdfbox_text_PDFTextStripper_ctor") + .asFunction Function()>(); + + /// from: public void () + /// + /// Instantiate a new PDFTextStripper object. + ///@throws IOException If there is an error loading the properties. + PDFTextStripper() : super.fromRef(_ctor()); + + static final _getText = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_getText") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public java.lang.String getText(org.apache.pdfbox.pdmodel.PDDocument doc) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// This will return the text of a document. See writeText.
+ /// NOTE: The document must not be encrypted when coming into this method. + /// + /// IMPORTANT: By default, text extraction is done in the same sequence as the text in the PDF page content stream. + /// PDF is a graphic format, not a text format, and unlike HTML, it has no requirements that text one on page + /// be rendered in a certain order. The order is the one that was determined by the software that created the + /// PDF. To get text sorted from left to right and top to botton, use \#setSortByPosition(boolean). + ///@param doc The document to get the text from. + ///@return The text of the PDF document. + ///@throws IOException if the doc state is invalid or it is encrypted. + jni.JlString getText(pdmodel_.PDDocument doc) => + jni.JlString.fromRef(_getText(reference, doc.reference)); + + static final _resetEngine = + jlookup)>>( + "org_apache_pdfbox_text_PDFTextStripper_resetEngine") + .asFunction)>(); + + /// from: private void resetEngine() + void resetEngine() => _resetEngine(reference); + + static final _writeText = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_writeText") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + /// from: public void writeText(org.apache.pdfbox.pdmodel.PDDocument doc, java.io.Writer outputStream) + /// + /// This will take a PDDocument and write the text of that document to the print writer. + ///@param doc The document to get the data from. + ///@param outputStream The location to put the text. + ///@throws IOException If the doc is in an invalid state. + void writeText(pdmodel_.PDDocument doc, jni.JlObject outputStream) => + _writeText(reference, doc.reference, outputStream.reference); + + static final _processPages = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_processPages") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: protected void processPages(org.apache.pdfbox.pdmodel.PDPageTree pages) + /// + /// This will process all of the pages and the text that is in them. + ///@param pages The pages object in the document. + ///@throws IOException If there is an error parsing the text. + void processPages(jni.JlObject pages) => + _processPages(reference, pages.reference); + + static final _startDocument = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_startDocument") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: protected void startDocument(org.apache.pdfbox.pdmodel.PDDocument document) + /// + /// This method is available for subclasses of this class. It will be called before processing of the document start. + ///@param document The PDF document that is being processed. + ///@throws IOException If an IO error occurs. + void startDocument(pdmodel_.PDDocument document) => + _startDocument(reference, document.reference); + + static final _endDocument = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_endDocument") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: protected void endDocument(org.apache.pdfbox.pdmodel.PDDocument document) + /// + /// This method is available for subclasses of this class. It will be called after processing of the document + /// finishes. + ///@param document The PDF document that is being processed. + ///@throws IOException If an IO error occurs. + void endDocument(pdmodel_.PDDocument document) => + _endDocument(reference, document.reference); + + static final _processPage = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_processPage") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: public void processPage(org.apache.pdfbox.pdmodel.PDPage page) + /// + /// This will process the contents of a page. + ///@param page The page to process. + ///@throws IOException If there is an error processing the page. + void processPage(jni.JlObject page) => + _processPage(reference, page.reference); + + static final _fillBeadRectangles = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_fillBeadRectangles") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: private void fillBeadRectangles(org.apache.pdfbox.pdmodel.PDPage page) + void fillBeadRectangles(jni.JlObject page) => + _fillBeadRectangles(reference, page.reference); + + static final _startArticle = + jlookup)>>( + "org_apache_pdfbox_text_PDFTextStripper_startArticle") + .asFunction)>(); + + /// from: protected void startArticle() + /// + /// Start a new article, which is typically defined as a column on a single page (also referred to as a bead). This + /// assumes that the primary direction of text is left to right. Default implementation is to do nothing. Subclasses + /// may provide additional information. + ///@throws IOException If there is any error writing to the stream. + void startArticle() => _startArticle(reference); + + static final _startArticle1 = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Uint8)>>( + "org_apache_pdfbox_text_PDFTextStripper_startArticle1") + .asFunction, int)>(); + + /// from: protected void startArticle(boolean isLTR) + /// + /// Start a new article, which is typically defined as a column on a single page (also referred to as a bead). + /// Default implementation is to do nothing. Subclasses may provide additional information. + ///@param isLTR true if primary direction of text is left to right. + ///@throws IOException If there is any error writing to the stream. + void startArticle1(bool isLTR) => _startArticle1(reference, isLTR ? 1 : 0); + + static final _endArticle = + jlookup)>>( + "org_apache_pdfbox_text_PDFTextStripper_endArticle") + .asFunction)>(); + + /// from: protected void endArticle() + /// + /// End an article. Default implementation is to do nothing. Subclasses may provide additional information. + ///@throws IOException If there is any error writing to the stream. + void endArticle() => _endArticle(reference); + + static final _startPage1 = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_startPage1") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: protected void startPage(org.apache.pdfbox.pdmodel.PDPage page) + /// + /// Start a new page. Default implementation is to do nothing. Subclasses may provide additional information. + ///@param page The page we are about to process. + ///@throws IOException If there is any error writing to the stream. + void startPage1(jni.JlObject page) => _startPage1(reference, page.reference); + + static final _endPage1 = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_endPage1") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: protected void endPage(org.apache.pdfbox.pdmodel.PDPage page) + /// + /// End a page. Default implementation is to do nothing. Subclasses may provide additional information. + ///@param page The page we are about to process. + ///@throws IOException If there is any error writing to the stream. + void endPage1(jni.JlObject page) => _endPage1(reference, page.reference); + + static final _writePage = + jlookup)>>( + "org_apache_pdfbox_text_PDFTextStripper_writePage") + .asFunction)>(); + + /// from: protected void writePage() + /// + /// This will print the text of the processed page to "output". It will estimate, based on the coordinates of the + /// text, where newlines and word spacings should be placed. The text will be sorted only if that feature was + /// enabled. + ///@throws IOException If there is an error writing the text. + void writePage() => _writePage(reference); + + static final _overlap = jlookup< + ffi.NativeFunction< + ffi.Uint8 Function( + ffi.Pointer, + ffi.Float, + ffi.Float, + ffi.Float, + ffi.Float)>>("org_apache_pdfbox_text_PDFTextStripper_overlap") + .asFunction< + int Function( + ffi.Pointer, double, double, double, double)>(); + + /// from: private boolean overlap(float y1, float height1, float y2, float height2) + bool overlap(double y1, double height1, double y2, double height2) => + _overlap(reference, y1, height1, y2, height2) != 0; + + static final _writeLineSeparator = + jlookup)>>( + "org_apache_pdfbox_text_PDFTextStripper_writeLineSeparator") + .asFunction)>(); + + /// from: protected void writeLineSeparator() + /// + /// Write the line separator value to the output stream. + ///@throws IOException If there is a problem writing out the line separator to the document. + void writeLineSeparator() => _writeLineSeparator(reference); + + static final _writeWordSeparator = + jlookup)>>( + "org_apache_pdfbox_text_PDFTextStripper_writeWordSeparator") + .asFunction)>(); + + /// from: protected void writeWordSeparator() + /// + /// Write the word separator value to the output stream. + ///@throws IOException If there is a problem writing out the word separator to the document. + void writeWordSeparator() => _writeWordSeparator(reference); + + static final _writeCharacters = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_writeCharacters") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: protected void writeCharacters(org.apache.pdfbox.text.TextPosition text) + /// + /// Write the string in TextPosition to the output stream. + ///@param text The text to write to the stream. + ///@throws IOException If there is an error when writing the text. + void writeCharacters(jni.JlObject text) => + _writeCharacters(reference, text.reference); + + static final _writeString = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_writeString") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + /// from: protected void writeString(java.lang.String text, java.util.List textPositions) + /// + /// Write a Java string to the output stream. The default implementation will ignore the textPositions + /// and just calls \#writeString(String). + ///@param text The text to write to the stream. + ///@param textPositions The TextPositions belonging to the text. + ///@throws IOException If there is an error when writing the text. + void writeString(jni.JlString text, jni.JlObject textPositions) => + _writeString(reference, text.reference, textPositions.reference); + + static final _writeString1 = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_writeString1") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: protected void writeString(java.lang.String text) + /// + /// Write a Java string to the output stream. + ///@param text The text to write to the stream. + ///@throws IOException If there is an error when writing the text. + void writeString1(jni.JlString text) => + _writeString1(reference, text.reference); + + static final _within = jlookup< + ffi.NativeFunction< + ffi.Uint8 Function(ffi.Pointer, ffi.Float, ffi.Float, + ffi.Float)>>("org_apache_pdfbox_text_PDFTextStripper_within") + .asFunction< + int Function(ffi.Pointer, double, double, double)>(); + + /// from: private boolean within(float first, float second, float variance) + /// + /// This will determine of two floating point numbers are within a specified variance. + ///@param first The first number to compare to. + ///@param second The second number to compare to. + ///@param variance The allowed variance. + bool within(double first, double second, double variance) => + _within(reference, first, second, variance) != 0; + + static final _processTextPosition = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_processTextPosition") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: protected void processTextPosition(org.apache.pdfbox.text.TextPosition text) + /// + /// This will process a TextPosition object and add the text to the list of characters on a page. It takes care of + /// overlapping text. + ///@param text The text to process. + void processTextPosition(jni.JlObject text) => + _processTextPosition(reference, text.reference); + + static final _getStartPage = + jlookup)>>( + "org_apache_pdfbox_text_PDFTextStripper_getStartPage") + .asFunction)>(); + + /// from: public int getStartPage() + /// + /// This is the page that the text extraction will start on. The pages start at page 1. For example in a 5 page PDF + /// document, if the start page is 1 then all pages will be extracted. If the start page is 4 then pages 4 and 5 will + /// be extracted. The default value is 1. + ///@return Value of property startPage. + int getStartPage() => _getStartPage(reference); + + static final _setStartPage = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Int32)>>( + "org_apache_pdfbox_text_PDFTextStripper_setStartPage") + .asFunction, int)>(); + + /// from: public void setStartPage(int startPageValue) + /// + /// This will set the first page to be extracted by this class. + ///@param startPageValue New value of 1-based startPage property. + void setStartPage(int startPageValue) => + _setStartPage(reference, startPageValue); + + static final _getEndPage = + jlookup)>>( + "org_apache_pdfbox_text_PDFTextStripper_getEndPage") + .asFunction)>(); + + /// from: public int getEndPage() + /// + /// This will get the last page that will be extracted. This is inclusive, for example if a 5 page PDF an endPage + /// value of 5 would extract the entire document, an end page of 2 would extract pages 1 and 2. This defaults to + /// Integer.MAX_VALUE such that all pages of the pdf will be extracted. + ///@return Value of property endPage. + int getEndPage() => _getEndPage(reference); + + static final _setEndPage = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Int32)>>( + "org_apache_pdfbox_text_PDFTextStripper_setEndPage") + .asFunction, int)>(); + + /// from: public void setEndPage(int endPageValue) + /// + /// This will set the last page to be extracted by this class. + ///@param endPageValue New value of 1-based endPage property. + void setEndPage(int endPageValue) => _setEndPage(reference, endPageValue); + + static final _setLineSeparator = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_setLineSeparator") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: public void setLineSeparator(java.lang.String separator) + /// + /// Set the desired line separator for output text. The line.separator system property is used if the line separator + /// preference is not set explicitly using this method. + ///@param separator The desired line separator string. + void setLineSeparator(jni.JlString separator) => + _setLineSeparator(reference, separator.reference); + + static final _getLineSeparator = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_getLineSeparator") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.lang.String getLineSeparator() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// This will get the line separator. + ///@return The desired line separator string. + jni.JlString getLineSeparator() => + jni.JlString.fromRef(_getLineSeparator(reference)); + + static final _getWordSeparator = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_getWordSeparator") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.lang.String getWordSeparator() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// This will get the word separator. + ///@return The desired word separator string. + jni.JlString getWordSeparator() => + jni.JlString.fromRef(_getWordSeparator(reference)); + + static final _setWordSeparator = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_setWordSeparator") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: public void setWordSeparator(java.lang.String separator) + /// + /// Set the desired word separator for output text. The PDFBox text extraction algorithm will output a space + /// character if there is enough space between two words. By default a space character is used. If you need and + /// accurate count of characters that are found in a PDF document then you might want to set the word separator to + /// the empty string. + ///@param separator The desired page separator string. + void setWordSeparator(jni.JlString separator) => + _setWordSeparator(reference, separator.reference); + + static final _getSuppressDuplicateOverlappingText = jlookup< + ffi.NativeFunction)>>( + "org_apache_pdfbox_text_PDFTextStripper_getSuppressDuplicateOverlappingText") + .asFunction)>(); + + /// from: public boolean getSuppressDuplicateOverlappingText() + /// + /// @return Returns the suppressDuplicateOverlappingText. + bool getSuppressDuplicateOverlappingText() => + _getSuppressDuplicateOverlappingText(reference) != 0; + + static final _getCurrentPageNo = + jlookup)>>( + "org_apache_pdfbox_text_PDFTextStripper_getCurrentPageNo") + .asFunction)>(); + + /// from: protected int getCurrentPageNo() + /// + /// Get the current page number that is being processed. + ///@return A 1 based number representing the current page. + int getCurrentPageNo() => _getCurrentPageNo(reference); + + static final _getOutput = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_getOutput") + .asFunction Function(ffi.Pointer)>(); + + /// from: protected java.io.Writer getOutput() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// The output stream that is being written to. + ///@return The stream that output is being written to. + jni.JlObject getOutput() => jni.JlObject.fromRef(_getOutput(reference)); + + static final _getCharactersByArticle = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_getCharactersByArticle") + .asFunction Function(ffi.Pointer)>(); + + /// from: protected java.util.List> getCharactersByArticle() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Character strings are grouped by articles. It is quite common that there will only be a single article. This + /// returns a List that contains List objects, the inner lists will contain TextPosition objects. + ///@return A double List of TextPositions for all text strings on the page. + jni.JlObject getCharactersByArticle() => + jni.JlObject.fromRef(_getCharactersByArticle(reference)); + + static final _setSuppressDuplicateOverlappingText = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Uint8)>>( + "org_apache_pdfbox_text_PDFTextStripper_setSuppressDuplicateOverlappingText") + .asFunction, int)>(); + + /// from: public void setSuppressDuplicateOverlappingText(boolean suppressDuplicateOverlappingTextValue) + /// + /// By default the text stripper will attempt to remove text that overlapps each other. Word paints the same + /// character several times in order to make it look bold. By setting this to false all text will be extracted, which + /// means that certain sections will be duplicated, but better performance will be noticed. + ///@param suppressDuplicateOverlappingTextValue The suppressDuplicateOverlappingText to set. + void setSuppressDuplicateOverlappingText( + bool suppressDuplicateOverlappingTextValue) => + _setSuppressDuplicateOverlappingText( + reference, suppressDuplicateOverlappingTextValue ? 1 : 0); + + static final _getSeparateByBeads = + jlookup)>>( + "org_apache_pdfbox_text_PDFTextStripper_getSeparateByBeads") + .asFunction)>(); + + /// from: public boolean getSeparateByBeads() + /// + /// This will tell if the text stripper should separate by beads. + ///@return If the text will be grouped by beads. + bool getSeparateByBeads() => _getSeparateByBeads(reference) != 0; + + static final _setShouldSeparateByBeads = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Uint8)>>( + "org_apache_pdfbox_text_PDFTextStripper_setShouldSeparateByBeads") + .asFunction, int)>(); + + /// from: public void setShouldSeparateByBeads(boolean aShouldSeparateByBeads) + /// + /// Set if the text stripper should group the text output by a list of beads. The default value is true! + ///@param aShouldSeparateByBeads The new grouping of beads. + void setShouldSeparateByBeads(bool aShouldSeparateByBeads) => + _setShouldSeparateByBeads(reference, aShouldSeparateByBeads ? 1 : 0); + + static final _getEndBookmark = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_getEndBookmark") + .asFunction Function(ffi.Pointer)>(); + + /// from: public org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem getEndBookmark() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Get the bookmark where text extraction should end, inclusive. Default is null. + ///@return The ending bookmark. + jni.JlObject getEndBookmark() => + jni.JlObject.fromRef(_getEndBookmark(reference)); + + static final _setEndBookmark = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_setEndBookmark") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: public void setEndBookmark(org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem aEndBookmark) + /// + /// Set the bookmark where the text extraction should stop. + ///@param aEndBookmark The ending bookmark. + void setEndBookmark(jni.JlObject aEndBookmark) => + _setEndBookmark(reference, aEndBookmark.reference); + + static final _getStartBookmark = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_getStartBookmark") + .asFunction Function(ffi.Pointer)>(); + + /// from: public org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem getStartBookmark() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Get the bookmark where text extraction should start, inclusive. Default is null. + ///@return The starting bookmark. + jni.JlObject getStartBookmark() => + jni.JlObject.fromRef(_getStartBookmark(reference)); + + static final _setStartBookmark = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_setStartBookmark") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: public void setStartBookmark(org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem aStartBookmark) + /// + /// Set the bookmark where text extraction should start, inclusive. + ///@param aStartBookmark The starting bookmark. + void setStartBookmark(jni.JlObject aStartBookmark) => + _setStartBookmark(reference, aStartBookmark.reference); + + static final _getAddMoreFormatting = + jlookup)>>( + "org_apache_pdfbox_text_PDFTextStripper_getAddMoreFormatting") + .asFunction)>(); + + /// from: public boolean getAddMoreFormatting() + /// + /// This will tell if the text stripper should add some more text formatting. + ///@return true if some more text formatting will be added + bool getAddMoreFormatting() => _getAddMoreFormatting(reference) != 0; + + static final _setAddMoreFormatting = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Uint8)>>( + "org_apache_pdfbox_text_PDFTextStripper_setAddMoreFormatting") + .asFunction, int)>(); + + /// from: public void setAddMoreFormatting(boolean newAddMoreFormatting) + /// + /// There will some additional text formatting be added if addMoreFormatting is set to true. Default is false. + ///@param newAddMoreFormatting Tell PDFBox to add some more text formatting + void setAddMoreFormatting(bool newAddMoreFormatting) => + _setAddMoreFormatting(reference, newAddMoreFormatting ? 1 : 0); + + static final _getSortByPosition = + jlookup)>>( + "org_apache_pdfbox_text_PDFTextStripper_getSortByPosition") + .asFunction)>(); + + /// from: public boolean getSortByPosition() + /// + /// 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. + bool getSortByPosition() => _getSortByPosition(reference) != 0; + + static final _setSortByPosition = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Uint8)>>( + "org_apache_pdfbox_text_PDFTextStripper_setSortByPosition") + .asFunction, int)>(); + + /// from: public void setSortByPosition(boolean newSortByPosition) + /// + /// The order of the text tokens in a PDF file may not be in the same as they appear visually on the screen. For + /// example, a PDF writer may write out all text by font, so all bold or larger text, then make a second pass and + /// write out the normal text.
+ /// The default is to __not__ sort by position.
+ ///
+ /// A PDF writer could choose to write each character in a different order. By default PDFBox does __not__ sort + /// the text tokens before processing them due to performance reasons. + ///@param newSortByPosition Tell PDFBox to sort the text positions. + void setSortByPosition(bool newSortByPosition) => + _setSortByPosition(reference, newSortByPosition ? 1 : 0); + + static final _getSpacingTolerance = + jlookup)>>( + "org_apache_pdfbox_text_PDFTextStripper_getSpacingTolerance") + .asFunction)>(); + + /// from: public float getSpacingTolerance() + /// + /// Get the current space width-based tolerance value that is being used to estimate where spaces in text should be + /// added. Note that the default value for this has been determined from trial and error. + ///@return The current tolerance / scaling factor + double getSpacingTolerance() => _getSpacingTolerance(reference); + + static final _setSpacingTolerance = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Float)>>( + "org_apache_pdfbox_text_PDFTextStripper_setSpacingTolerance") + .asFunction, double)>(); + + /// from: public void setSpacingTolerance(float spacingToleranceValue) + /// + /// Set the space width-based tolerance value that is used to estimate where spaces in text should be added. Note + /// that the default value for this has been determined from trial and error. Setting this value larger will reduce + /// the number of spaces added. + ///@param spacingToleranceValue tolerance / scaling factor to use + void setSpacingTolerance(double spacingToleranceValue) => + _setSpacingTolerance(reference, spacingToleranceValue); + + static final _getAverageCharTolerance = + jlookup)>>( + "org_apache_pdfbox_text_PDFTextStripper_getAverageCharTolerance") + .asFunction)>(); + + /// from: public float getAverageCharTolerance() + /// + /// Get the current character width-based tolerance value that is being used to estimate where spaces in text should + /// be added. Note that the default value for this has been determined from trial and error. + ///@return The current tolerance / scaling factor + double getAverageCharTolerance() => _getAverageCharTolerance(reference); + + static final _setAverageCharTolerance = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Float)>>( + "org_apache_pdfbox_text_PDFTextStripper_setAverageCharTolerance") + .asFunction, double)>(); + + /// from: public void setAverageCharTolerance(float averageCharToleranceValue) + /// + /// Set the character width-based tolerance value that is used to estimate where spaces in text should be added. Note + /// that the default value for this has been determined from trial and error. Setting this value larger will reduce + /// the number of spaces added. + ///@param averageCharToleranceValue average tolerance / scaling factor to use + void setAverageCharTolerance(double averageCharToleranceValue) => + _setAverageCharTolerance(reference, averageCharToleranceValue); + + static final _getIndentThreshold = + jlookup)>>( + "org_apache_pdfbox_text_PDFTextStripper_getIndentThreshold") + .asFunction)>(); + + /// from: public float getIndentThreshold() + /// + /// returns the multiple of whitespace character widths for the current text which the current line start can be + /// indented from the previous line start beyond which the current line start is considered to be a paragraph start. + ///@return the number of whitespace character widths to use when detecting paragraph indents. + double getIndentThreshold() => _getIndentThreshold(reference); + + static final _setIndentThreshold = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Float)>>( + "org_apache_pdfbox_text_PDFTextStripper_setIndentThreshold") + .asFunction, double)>(); + + /// from: public void setIndentThreshold(float indentThresholdValue) + /// + /// sets the multiple of whitespace character widths for the current text which the current line start can be + /// indented from the previous line start beyond which the current line start is considered to be a paragraph start. + /// The default value is 2.0. + ///@param indentThresholdValue the number of whitespace character widths to use when detecting paragraph indents. + void setIndentThreshold(double indentThresholdValue) => + _setIndentThreshold(reference, indentThresholdValue); + + static final _getDropThreshold = + jlookup)>>( + "org_apache_pdfbox_text_PDFTextStripper_getDropThreshold") + .asFunction)>(); + + /// from: public float getDropThreshold() + /// + /// the minimum whitespace, as a multiple of the max height of the current characters beyond which the current line + /// 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() => _getDropThreshold(reference); + + static final _setDropThreshold = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Float)>>( + "org_apache_pdfbox_text_PDFTextStripper_setDropThreshold") + .asFunction, double)>(); + + /// from: public void setDropThreshold(float dropThresholdValue) + /// + /// sets the minimum whitespace, as a multiple of the max height of the current characters beyond which the current + /// line start is considered to be a paragraph start. The default value is 2.5. + ///@param dropThresholdValue the character height multiple for max allowed whitespace between lines in the same + /// paragraph. + void setDropThreshold(double dropThresholdValue) => + _setDropThreshold(reference, dropThresholdValue); + + static final _getParagraphStart = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_getParagraphStart") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.lang.String getParagraphStart() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Returns the string which will be used at the beginning of a paragraph. + ///@return the paragraph start string + jni.JlString getParagraphStart() => + jni.JlString.fromRef(_getParagraphStart(reference)); + + static final _setParagraphStart = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_setParagraphStart") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: public void setParagraphStart(java.lang.String s) + /// + /// Sets the string which will be used at the beginning of a paragraph. + ///@param s the paragraph start string + void setParagraphStart(jni.JlString s) => + _setParagraphStart(reference, s.reference); + + static final _getParagraphEnd = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_getParagraphEnd") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.lang.String getParagraphEnd() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Returns the string which will be used at the end of a paragraph. + ///@return the paragraph end string + jni.JlString getParagraphEnd() => + jni.JlString.fromRef(_getParagraphEnd(reference)); + + static final _setParagraphEnd = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_setParagraphEnd") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: public void setParagraphEnd(java.lang.String s) + /// + /// Sets the string which will be used at the end of a paragraph. + ///@param s the paragraph end string + void setParagraphEnd(jni.JlString s) => + _setParagraphEnd(reference, s.reference); + + static final _getPageStart = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_getPageStart") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.lang.String getPageStart() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Returns the string which will be used at the beginning of a page. + ///@return the page start string + jni.JlString getPageStart() => jni.JlString.fromRef(_getPageStart(reference)); + + static final _setPageStart = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_setPageStart") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: public void setPageStart(java.lang.String pageStartValue) + /// + /// Sets the string which will be used at the beginning of a page. + ///@param pageStartValue the page start string + void setPageStart(jni.JlString pageStartValue) => + _setPageStart(reference, pageStartValue.reference); + + static final _getPageEnd = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_getPageEnd") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.lang.String getPageEnd() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Returns the string which will be used at the end of a page. + ///@return the page end string + jni.JlString getPageEnd() => jni.JlString.fromRef(_getPageEnd(reference)); + + static final _setPageEnd = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_setPageEnd") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: public void setPageEnd(java.lang.String pageEndValue) + /// + /// Sets the string which will be used at the end of a page. + ///@param pageEndValue the page end string + void setPageEnd(jni.JlString pageEndValue) => + _setPageEnd(reference, pageEndValue.reference); + + static final _getArticleStart = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_getArticleStart") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.lang.String getArticleStart() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Returns the string which will be used at the beginning of an article. + ///@return the article start string + jni.JlString getArticleStart() => + jni.JlString.fromRef(_getArticleStart(reference)); + + static final _setArticleStart = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_setArticleStart") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: public void setArticleStart(java.lang.String articleStartValue) + /// + /// Sets the string which will be used at the beginning of an article. + ///@param articleStartValue the article start string + void setArticleStart(jni.JlString articleStartValue) => + _setArticleStart(reference, articleStartValue.reference); + + static final _getArticleEnd = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_getArticleEnd") + .asFunction Function(ffi.Pointer)>(); + + /// from: public java.lang.String getArticleEnd() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Returns the string which will be used at the end of an article. + ///@return the article end string + jni.JlString getArticleEnd() => + jni.JlString.fromRef(_getArticleEnd(reference)); + + static final _setArticleEnd = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_setArticleEnd") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: public void setArticleEnd(java.lang.String articleEndValue) + /// + /// Sets the string which will be used at the end of an article. + ///@param articleEndValue the article end string + void setArticleEnd(jni.JlString articleEndValue) => + _setArticleEnd(reference, articleEndValue.reference); + + static final _handleLineSeparation = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Float)>>( + "org_apache_pdfbox_text_PDFTextStripper_handleLineSeparation") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + double)>(); + + /// from: private org.apache.pdfbox.text.PDFTextStripper.PositionWrapper handleLineSeparation(org.apache.pdfbox.text.PDFTextStripper.PositionWrapper current, org.apache.pdfbox.text.PDFTextStripper.PositionWrapper lastPosition, org.apache.pdfbox.text.PDFTextStripper.PositionWrapper lastLineStartPosition, float maxHeightForLine) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// handles the line separator for a new line given the specified current and previous TextPositions. + ///@param current the current text position + ///@param lastPosition the previous text position + ///@param lastLineStartPosition the last text position that followed a line separator. + ///@param maxHeightForLine max height for positions since lastLineStartPosition + ///@return start position of the last line + ///@throws IOException if something went wrong + jni.JlObject handleLineSeparation( + jni.JlObject current, + jni.JlObject lastPosition, + jni.JlObject lastLineStartPosition, + double maxHeightForLine) => + jni.JlObject.fromRef(_handleLineSeparation( + reference, + current.reference, + lastPosition.reference, + lastLineStartPosition.reference, + maxHeightForLine)); + + static final _isParagraphSeparation = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Float)>>( + "org_apache_pdfbox_text_PDFTextStripper_isParagraphSeparation") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer, double)>(); + + /// from: private void isParagraphSeparation(org.apache.pdfbox.text.PDFTextStripper.PositionWrapper position, org.apache.pdfbox.text.PDFTextStripper.PositionWrapper lastPosition, org.apache.pdfbox.text.PDFTextStripper.PositionWrapper lastLineStartPosition, float maxHeightForLine) + /// + /// tests the relationship between the last text position, the current text position and the last text position that + /// followed a line separator to decide if the gap represents a paragraph separation. This should only be + /// called for consecutive text positions that first pass the line separation test. + /// + /// This base implementation tests to see if the lastLineStartPosition is null OR if the current vertical position + /// has dropped below the last text vertical position by at least 2.5 times the current text height OR if the current + /// horizontal position is indented by at least 2 times the current width of a space character. + /// + /// + /// + /// This also attempts to identify text that is indented under a hanging indent. + /// + /// + /// + /// This method sets the isParagraphStart and isHangingIndent flags on the current position object. + /// + /// + ///@param position the current text position. This may have its isParagraphStart or isHangingIndent flags set upon + /// return. + ///@param lastPosition the previous text position (should not be null). + ///@param lastLineStartPosition the last text position that followed a line separator, or null. + ///@param maxHeightForLine max height for text positions since lasLineStartPosition. + void isParagraphSeparation(jni.JlObject position, jni.JlObject lastPosition, + jni.JlObject lastLineStartPosition, double maxHeightForLine) => + _isParagraphSeparation( + reference, + position.reference, + lastPosition.reference, + lastLineStartPosition.reference, + maxHeightForLine); + + static final _multiplyFloat = jlookup< + ffi.NativeFunction< + ffi.Float Function( + ffi.Pointer, ffi.Float, ffi.Float)>>( + "org_apache_pdfbox_text_PDFTextStripper_multiplyFloat") + .asFunction, double, double)>(); + + /// from: private float multiplyFloat(float value1, float value2) + double multiplyFloat(double value1, double value2) => + _multiplyFloat(reference, value1, value2); + + static final _writeParagraphSeparator = + jlookup)>>( + "org_apache_pdfbox_text_PDFTextStripper_writeParagraphSeparator") + .asFunction)>(); + + /// from: protected void writeParagraphSeparator() + /// + /// writes the paragraph separator string to the output. + ///@throws IOException if something went wrong + void writeParagraphSeparator() => _writeParagraphSeparator(reference); + + static final _writeParagraphStart = + jlookup)>>( + "org_apache_pdfbox_text_PDFTextStripper_writeParagraphStart") + .asFunction)>(); + + /// from: protected void writeParagraphStart() + /// + /// Write something (if defined) at the start of a paragraph. + ///@throws IOException if something went wrong + void writeParagraphStart() => _writeParagraphStart(reference); + + static final _writeParagraphEnd = + jlookup)>>( + "org_apache_pdfbox_text_PDFTextStripper_writeParagraphEnd") + .asFunction)>(); + + /// from: protected void writeParagraphEnd() + /// + /// Write something (if defined) at the end of a paragraph. + ///@throws IOException if something went wrong + void writeParagraphEnd() => _writeParagraphEnd(reference); + + static final _writePageStart = + jlookup)>>( + "org_apache_pdfbox_text_PDFTextStripper_writePageStart") + .asFunction)>(); + + /// from: protected void writePageStart() + /// + /// Write something (if defined) at the start of a page. + ///@throws IOException if something went wrong + void writePageStart() => _writePageStart(reference); + + static final _writePageEnd = + jlookup)>>( + "org_apache_pdfbox_text_PDFTextStripper_writePageEnd") + .asFunction)>(); + + /// from: protected void writePageEnd() + /// + /// Write something (if defined) at the end of a page. + ///@throws IOException if something went wrong + void writePageEnd() => _writePageEnd(reference); + + static final _matchListItemPattern = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_matchListItemPattern") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: private java.util.regex.Pattern matchListItemPattern(org.apache.pdfbox.text.PDFTextStripper.PositionWrapper pw) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// returns the list item Pattern object that matches the text at the specified PositionWrapper or null if the text + /// does not match such a pattern. The list of Patterns tested against is given by the \#getListItemPatterns() + /// method. To add to the list, simply override that method (if sub-classing) or explicitly supply your own list + /// using \#setListItemPatterns(List). + ///@param pw position + ///@return the matching pattern + jni.JlObject matchListItemPattern(jni.JlObject pw) => + jni.JlObject.fromRef(_matchListItemPattern(reference, pw.reference)); + + static final _setListItemPatterns = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_setListItemPatterns") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: protected void setListItemPatterns(java.util.List patterns) + /// + /// use to supply a different set of regular expression patterns for matching list item starts. + ///@param patterns list of patterns + void setListItemPatterns(jni.JlObject patterns) => + _setListItemPatterns(reference, patterns.reference); + + static final _getListItemPatterns = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_getListItemPatterns") + .asFunction Function(ffi.Pointer)>(); + + /// from: protected java.util.List getListItemPatterns() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// returns a list of regular expression Patterns representing different common list item formats. For example + /// numbered items of form: + ///
    + ///
  1. some text
  2. + ///
  3. more text
  4. + ///
+ /// or + ///
    + ///
  • some text
  • + ///
  • more text
  • + ///
+ /// etc., all begin with some character pattern. The pattern "\\d+\." (matches "1.", "2.", ...) or "\[\\d+\]" + /// (matches "[1]", "[2]", ...). + /// + /// This method returns a list of such regular expression Patterns. + ///@return a list of Pattern objects. + jni.JlObject getListItemPatterns() => + jni.JlObject.fromRef(_getListItemPatterns(reference)); + + static final _matchPattern = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_matchPattern") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: static protected java.util.regex.Pattern matchPattern(java.lang.String string, java.util.List patterns) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// iterates over the specified list of Patterns until it finds one that matches the specified string. Then returns + /// the Pattern. + /// + /// Order of the supplied list of patterns is important as most common patterns should come first. Patterns should be + /// strict in general, and all will be used with case sensitivity on. + /// + /// + ///@param string the string to be searched + ///@param patterns list of patterns + ///@return matching pattern + static jni.JlObject matchPattern( + jni.JlString string, jni.JlObject patterns) => + jni.JlObject.fromRef(_matchPattern(string.reference, patterns.reference)); + + static final _writeLine = jlookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_writeLine") + .asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + /// from: private void writeLine(java.util.List line) + /// + /// Write a list of string containing a whole line of a document. + ///@param line a list with the words of the given line + ///@throws IOException if something went wrong + void writeLine(jni.JlObject line) => _writeLine(reference, line.reference); + + static final _normalize = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_normalize") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: private java.util.List normalize(java.util.List line) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Normalize the given list of TextPositions. + ///@param line list of TextPositions + ///@return a list of strings, one string for every word + jni.JlObject normalize(jni.JlObject line) => + jni.JlObject.fromRef(_normalize(reference, line.reference)); + + static final _handleDirection = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_handleDirection") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: private java.lang.String handleDirection(java.lang.String word) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Handles the LTR and RTL direction of the given words. The whole implementation stands and falls with the given + /// word. If the word is a full line, the results will be the best. If the word contains of single words or + /// characters, the order of the characters in a word or words in a line may wrong, due to RTL and LTR marks and + /// characters! + /// + /// Based on http://www.nesterovsky-bros.com/weblog/2013/07/28/VisualToLogicalConversionInJava.aspx + ///@param word The word that shall be processed + ///@return new word with the correct direction of the containing characters + jni.JlString handleDirection(jni.JlString word) => + jni.JlString.fromRef(_handleDirection(reference, word.reference)); + + static final _parseBidiFile = + jlookup)>>( + "org_apache_pdfbox_text_PDFTextStripper_parseBidiFile") + .asFunction)>(); + + /// from: private static void parseBidiFile(java.io.InputStream inputStream) + /// + /// This method parses the bidi file provided as inputstream. + ///@param inputStream - The bidi file as inputstream + ///@throws IOException if any line could not be read by the LineNumberReader + static void parseBidiFile(jni.JlObject inputStream) => + _parseBidiFile(inputStream.reference); + + static final _createWord = jlookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_createWord") + .asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + /// from: private org.apache.pdfbox.text.PDFTextStripper.WordWithTextPositions createWord(java.lang.String word, java.util.List wordPositions) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Used within \#normalize(List) to create a single WordWithTextPositions entry. + jni.JlObject createWord(jni.JlString word, jni.JlObject wordPositions) => + jni.JlObject.fromRef( + _createWord(reference, word.reference, wordPositions.reference)); + + static final _normalizeWord = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_normalizeWord") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: private java.lang.String normalizeWord(java.lang.String word) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Normalize certain Unicode characters. For example, convert the single "fi" ligature to "f" and "i". Also + /// normalises Arabic and Hebrew presentation forms. + ///@param word Word to normalize + ///@return Normalized word + jni.JlString normalizeWord(jni.JlString word) => + jni.JlString.fromRef(_normalizeWord(reference, word.reference)); + + static final _normalizeAdd = jlookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>( + "org_apache_pdfbox_text_PDFTextStripper_normalizeAdd") + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + /// from: private java.lang.StringBuilder normalizeAdd(java.util.List normalized, java.lang.StringBuilder lineBuilder, java.util.List wordPositions, org.apache.pdfbox.text.PDFTextStripper.LineItem item) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Used within \#normalize(List) to handle a TextPosition. + ///@return The StringBuilder that must be used when calling this method. + jni.JlObject normalizeAdd(jni.JlObject normalized, jni.JlObject lineBuilder, + jni.JlObject wordPositions, jni.JlObject item) => + jni.JlObject.fromRef(_normalizeAdd(reference, normalized.reference, + lineBuilder.reference, wordPositions.reference, item.reference)); +} diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/linux/CMakeLists.txt b/pkgs/jni_gen/examples/pdfbox_plugin/linux/CMakeLists.txt new file mode 100644 index 000000000..986e388aa --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/linux/CMakeLists.txt @@ -0,0 +1,22 @@ +# The Flutter tooling requires that developers have CMake 3.10 or later +# installed. You should not increase this version, as doing so will cause +# the plugin to fail to compile for some customers of the plugin. +cmake_minimum_required(VERSION 3.10) + +# Project-level configuration. +set(PROJECT_NAME "pdfbox_plugin") +project(${PROJECT_NAME} LANGUAGES CXX) + +# Invoke the build for native code shared with the other target platforms. +# This can be changed to accomodate different builds. +add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../src" "${CMAKE_CURRENT_BINARY_DIR}/shared") + +# List of absolute paths to libraries that should be bundled with the plugin. +# This list could contain prebuilt libraries, or libraries created by an +# external build triggered from this build file. +set(pdfbox_plugin_bundled_libraries + # Defined in ../src/CMakeLists.txt. + # This can be changed to accomodate different builds. + $ + PARENT_SCOPE +) diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/pubspec.yaml b/pkgs/jni_gen/examples/pdfbox_plugin/pubspec.yaml new file mode 100644 index 000000000..7ec1e1f87 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/pubspec.yaml @@ -0,0 +1,38 @@ +name: pdfbox_plugin +description: | + Example of using jni_gen to generate bindings for a non-trivial library +version: 0.0.1 +publish_to: none +homepage: https://github.com/dart-lang/jni_gen + +environment: + sdk: ">=2.17.6 <3.0.0" + #flutter: ">=2.11.0" + +dependencies: + jni: + path: ../../../jni/ + #flutter: + #sdk: flutter + plugin_platform_interface: ^2.0.2 + +dev_dependencies: + ## Path dependency for sake of the example + jni_gen: + path: ../../ + test: any + lints: ^2.0.0 + +flutter: + # A JNI plugin uses FFI for calling into C code. Thus the relevant shared + # library artifacts must be bundled with final application. + # Please refer to README.md for a detailed explanation. + plugin: + platforms: + android: + ffiPlugin: true + linux: + ffiPlugin: true + windows: + ffiPlugin: true + diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/src/CMakeLists.txt b/pkgs/jni_gen/examples/pdfbox_plugin/src/CMakeLists.txt new file mode 100644 index 000000000..4ed5b3dd0 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/src/CMakeLists.txt @@ -0,0 +1,30 @@ +# The Flutter tooling requires that developers have CMake 3.10 or later +# installed. You should not increase this version, as doing so will cause +# the plugin to fail to compile for some customers of the plugin. +cmake_minimum_required(VERSION 3.10) + +project(pdfbox_plugin VERSION 0.0.1 LANGUAGES C) + +add_library(pdfbox_plugin SHARED + "third_party//pdfbox_plugin.c" +) + +set_target_properties(pdfbox_plugin PROPERTIES + OUTPUT_NAME "pdfbox_plugin" +) + +target_compile_definitions(pdfbox_plugin PUBLIC DART_SHARED_LIB) + +if(WIN32) + set_target_properties(${TARGET_NAME} PROPERTIES + LINK_FLAGS "/DELAYLOAD:jvm.dll") +endif() + +if (ANDROID) + target_link_libraries(pdfbox_plugin log) +else() + find_package(Java REQUIRED) + find_package(JNI REQUIRED) + include_directories(${JNI_INCLUDE_DIRS}) + target_link_libraries(pdfbox_plugin ${JNI_LIBRARIES}) +endif() diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/src/third_party/dartjni.h b/pkgs/jni_gen/examples/pdfbox_plugin/src/third_party/dartjni.h new file mode 100644 index 000000000..cd94b1532 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/src/third_party/dartjni.h @@ -0,0 +1,177 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +#include +#include +#include +#include + +#if _WIN32 +#include +#else +#include +#include +#endif + +#if _WIN32 +#define FFI_PLUGIN_EXPORT __declspec(dllexport) +#else +#define FFI_PLUGIN_EXPORT +#endif + +#if defined _WIN32 +#define thread_local __declspec(thread) +#else +#define thread_local __thread +#endif + +#ifdef __ANDROID__ +#include +#endif + +#define JNI_LOG_TAG "Dart-JNI" + +#ifdef __ANDROID__ +#define __ENVP_CAST (JNIEnv **) +#else +#define __ENVP_CAST (void **) +#endif + +struct jni_context { + JavaVM *jvm; + jobject classLoader; + jmethodID loadClassMethod; + jobject currentActivity; + jobject appContext; +}; + +extern thread_local JNIEnv *jniEnv; + +extern struct jni_context jni; + +enum DartJniLogLevel { + JNI_VERBOSE = 2, + JNI_DEBUG, + JNI_INFO, + JNI_WARN, + JNI_ERROR +}; + +FFI_PLUGIN_EXPORT struct jni_context GetJniContext(); + +FFI_PLUGIN_EXPORT JavaVM *GetJavaVM(void); + +FFI_PLUGIN_EXPORT JNIEnv *GetJniEnv(void); + +FFI_PLUGIN_EXPORT JNIEnv *SpawnJvm(JavaVMInitArgs *args); + +FFI_PLUGIN_EXPORT jclass LoadClass(const char *name); + +FFI_PLUGIN_EXPORT jobject GetClassLoader(void); + +FFI_PLUGIN_EXPORT jobject GetApplicationContext(void); + +FFI_PLUGIN_EXPORT jobject GetCurrentActivity(void); + +FFI_PLUGIN_EXPORT void SetJNILogging(int level); + +FFI_PLUGIN_EXPORT jstring ToJavaString(char *str); + +FFI_PLUGIN_EXPORT const char *GetJavaStringChars(jstring jstr); + +FFI_PLUGIN_EXPORT void ReleaseJavaStringChars(jstring jstr, const char *buf); + +// These 2 are the function pointer variables defined and exported by +// the generated C files. +// +// initGeneratedLibrary function in Jni class will set these to +// corresponding functions to the implementations from `dartjni` base library +// which initializes and manages the JNI. +extern struct jni_context (*context_getter)(void); +extern JNIEnv *(*env_getter)(void); + +// This function will be exported by generated code library and will set the +// above 2 variables. +FFI_PLUGIN_EXPORT void setJniGetters(struct jni_context (*cg)(void), + JNIEnv *(*eg)(void)); + +// `static inline` because `inline` doesn't work, it may still not +// inline the function in which case a linker error may be produced. +// +// There has to be a better way to do this. Either to force inlining on target +// platforms, or just leave it as normal function. +static inline void __load_class_into(jclass *cls, const char *name) { +#ifdef __ANDROID__ + jstring className = (*jniEnv)->NewStringUTF(jniEnv, name); + *cls = (*jniEnv)->CallObjectMethod(jniEnv, jni.classLoader, + jni.loadClassMethod, className); + (*jniEnv)->DeleteLocalRef(jniEnv, className); +#else + *cls = (*jniEnv)->FindClass(jniEnv, name); +#endif +} + +static inline void load_class(jclass *cls, const char *name) { + if (*cls == NULL) { + __load_class_into(cls, name); + } +} + +static inline void load_class_gr(jclass *cls, const char *name) { + if (*cls == NULL) { + jclass tmp; + __load_class_into(&tmp, name); + *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); + (*jniEnv)->DeleteLocalRef(jniEnv, tmp); + } +} + +static inline void attach_thread() { + if (jniEnv == NULL) { + (*jni.jvm)->AttachCurrentThread(jni.jvm, __ENVP_CAST & jniEnv, + NULL); + } +} + +static inline void load_env() { + if (jniEnv == NULL) { + jni = context_getter(); + jniEnv = env_getter(); + } +} + +static inline void load_method(jclass cls, jmethodID *res, const char *name, + const char *sig) { + if (*res == NULL) { + *res = (*jniEnv)->GetMethodID(jniEnv, cls, name, sig); + } +} + +static inline void load_static_method(jclass cls, jmethodID *res, + const char *name, const char *sig) { + if (*res == NULL) { + *res = (*jniEnv)->GetStaticMethodID(jniEnv, cls, name, sig); + } +} + +static inline void load_field(jclass cls, jfieldID *res, const char *name, + const char *sig) { + if (*res == NULL) { + *res = (*jniEnv)->GetFieldID(jniEnv, cls, name, sig); + } +} + +static inline void load_static_field(jclass cls, jfieldID *res, + const char *name, const char *sig) { + if (*res == NULL) { + *res = (*jniEnv)->GetStaticFieldID(jniEnv, cls, name, sig); + } +} + +static inline jobject to_global_ref(jobject ref) { + jobject g = (*jniEnv)->NewGlobalRef(jniEnv, ref); + (*jniEnv)->DeleteLocalRef(jniEnv, ref); + return g; +} + diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/src/third_party/pdfbox_plugin.c b/pkgs/jni_gen/examples/pdfbox_plugin/src/third_party/pdfbox_plugin.c new file mode 100644 index 000000000..a4f00dac5 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/src/third_party/pdfbox_plugin.c @@ -0,0 +1,2548 @@ +// Generated from Apache PDFBox library which is licensed under the Apache License 2.0. +// The following copyright from the original authors applies. +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Autogenerated by jni_gen. DO NOT EDIT! + +#include +#include "jni.h" +#include "dartjni.h" + +thread_local JNIEnv *jniEnv; +struct jni_context jni; + +struct jni_context (*context_getter)(void); +JNIEnv *(*env_getter)(void); + +void setJniGetters(struct jni_context (*cg)(void), + JNIEnv *(*eg)(void)) { + context_getter = cg; + env_getter = eg; +} + +// org.apache.pdfbox.pdmodel.PDDocument +jclass _c_org_apache_pdfbox_pdmodel_PDDocument = NULL; + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_ctor = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_ctor() { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_ctor, "", "()V"); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_org_apache_pdfbox_pdmodel_PDDocument, _m_org_apache_pdfbox_pdmodel_PDDocument_ctor); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_ctor1 = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_ctor1(jobject memUsageSetting) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_ctor1, "", "(Lorg/apache/pdfbox/io/MemoryUsageSetting;)V"); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_org_apache_pdfbox_pdmodel_PDDocument, _m_org_apache_pdfbox_pdmodel_PDDocument_ctor1, memUsageSetting); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_ctor2 = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_ctor2(jobject doc) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_ctor2, "", "(Lorg/apache/pdfbox/cos/COSDocument;)V"); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_org_apache_pdfbox_pdmodel_PDDocument, _m_org_apache_pdfbox_pdmodel_PDDocument_ctor2, doc); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_ctor3 = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_ctor3(jobject doc, jobject source) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_ctor3, "", "(Lorg/apache/pdfbox/cos/COSDocument;Lorg/apache/pdfbox/io/RandomAccessRead;)V"); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_org_apache_pdfbox_pdmodel_PDDocument, _m_org_apache_pdfbox_pdmodel_PDDocument_ctor3, doc, source); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_ctor4 = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_ctor4(jobject doc, jobject source, jobject permission) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_ctor4, "", "(Lorg/apache/pdfbox/cos/COSDocument;Lorg/apache/pdfbox/io/RandomAccessRead;Lorg/apache/pdfbox/pdmodel/encryption/AccessPermission;)V"); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_org_apache_pdfbox_pdmodel_PDDocument, _m_org_apache_pdfbox_pdmodel_PDDocument_ctor4, doc, source, permission); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_addPage = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocument_addPage(jobject self_, jobject page) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_addPage, "addPage", "(Lorg/apache/pdfbox/pdmodel/PDPage;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_addPage, page); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_addSignature = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocument_addSignature(jobject self_, jobject sigObject) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_addSignature, "addSignature", "(Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSignature;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_addSignature, sigObject); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_addSignature1 = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocument_addSignature1(jobject self_, jobject sigObject, jobject options) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_addSignature1, "addSignature", "(Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSignature;Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/SignatureOptions;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_addSignature1, sigObject, options); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_addSignature2 = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocument_addSignature2(jobject self_, jobject sigObject, jobject signatureInterface) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_addSignature2, "addSignature", "(Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSignature;Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/SignatureInterface;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_addSignature2, sigObject, signatureInterface); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_addSignature3 = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocument_addSignature3(jobject self_, jobject sigObject, jobject signatureInterface, jobject options) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_addSignature3, "addSignature", "(Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSignature;Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/SignatureInterface;Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/SignatureOptions;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_addSignature3, sigObject, signatureInterface, options); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_findSignatureField = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_findSignatureField(jobject self_, jobject fieldIterator, jobject sigObject) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_findSignatureField, "findSignatureField", "(Ljava/util/Iterator;Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSignature;)Lorg/apache/pdfbox/pdmodel/interactive/form/PDSignatureField;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_findSignatureField, fieldIterator, sigObject); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_checkSignatureField = NULL; +FFI_PLUGIN_EXPORT +uint8_t org_apache_pdfbox_pdmodel_PDDocument_checkSignatureField(jobject self_, jobject fieldIterator, jobject signatureField) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_checkSignatureField, "checkSignatureField", "(Ljava/util/Iterator;Lorg/apache/pdfbox/pdmodel/interactive/form/PDSignatureField;)Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_checkSignatureField, fieldIterator, signatureField); + return _result; +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_checkSignatureAnnotation = NULL; +FFI_PLUGIN_EXPORT +uint8_t org_apache_pdfbox_pdmodel_PDDocument_checkSignatureAnnotation(jobject self_, jobject annotations, jobject widget) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_checkSignatureAnnotation, "checkSignatureAnnotation", "(Ljava/util/List;Lorg/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotationWidget;)Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_checkSignatureAnnotation, annotations, widget); + return _result; +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_prepareVisibleSignature = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocument_prepareVisibleSignature(jobject self_, jobject signatureField, jobject acroForm, jobject visualSignature) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_prepareVisibleSignature, "prepareVisibleSignature", "(Lorg/apache/pdfbox/pdmodel/interactive/form/PDSignatureField;Lorg/apache/pdfbox/pdmodel/interactive/form/PDAcroForm;Lorg/apache/pdfbox/cos/COSDocument;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_prepareVisibleSignature, signatureField, acroForm, visualSignature); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_assignSignatureRectangle = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocument_assignSignatureRectangle(jobject self_, jobject signatureField, jobject annotDict) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_assignSignatureRectangle, "assignSignatureRectangle", "(Lorg/apache/pdfbox/pdmodel/interactive/form/PDSignatureField;Lorg/apache/pdfbox/cos/COSDictionary;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_assignSignatureRectangle, signatureField, annotDict); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_assignAppearanceDictionary = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocument_assignAppearanceDictionary(jobject self_, jobject signatureField, jobject apDict) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_assignAppearanceDictionary, "assignAppearanceDictionary", "(Lorg/apache/pdfbox/pdmodel/interactive/form/PDSignatureField;Lorg/apache/pdfbox/cos/COSDictionary;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_assignAppearanceDictionary, signatureField, apDict); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_assignAcroFormDefaultResource = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocument_assignAcroFormDefaultResource(jobject self_, jobject acroForm, jobject newDict) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_assignAcroFormDefaultResource, "assignAcroFormDefaultResource", "(Lorg/apache/pdfbox/pdmodel/interactive/form/PDAcroForm;Lorg/apache/pdfbox/cos/COSDictionary;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_assignAcroFormDefaultResource, acroForm, newDict); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_prepareNonVisibleSignature = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocument_prepareNonVisibleSignature(jobject self_, jobject signatureField) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_prepareNonVisibleSignature, "prepareNonVisibleSignature", "(Lorg/apache/pdfbox/pdmodel/interactive/form/PDSignatureField;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_prepareNonVisibleSignature, signatureField); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_addSignatureField = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocument_addSignatureField(jobject self_, jobject sigFields, jobject signatureInterface, jobject options) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_addSignatureField, "addSignatureField", "(Ljava/util/List;Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/SignatureInterface;Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/SignatureOptions;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_addSignatureField, sigFields, signatureInterface, options); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_removePage = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocument_removePage(jobject self_, jobject page) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_removePage, "removePage", "(Lorg/apache/pdfbox/pdmodel/PDPage;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_removePage, page); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_removePage1 = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocument_removePage1(jobject self_, int32_t pageNumber) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_removePage1, "removePage", "(I)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_removePage1, pageNumber); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_importPage = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_importPage(jobject self_, jobject page) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_importPage, "importPage", "(Lorg/apache/pdfbox/pdmodel/PDPage;)Lorg/apache/pdfbox/pdmodel/PDPage;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_importPage, page); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_getDocument = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_getDocument(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_getDocument, "getDocument", "()Lorg/apache/pdfbox/cos/COSDocument;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_getDocument); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_getDocumentInformation = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_getDocumentInformation(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_getDocumentInformation, "getDocumentInformation", "()Lorg/apache/pdfbox/pdmodel/PDDocumentInformation;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_getDocumentInformation); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_setDocumentInformation = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocument_setDocumentInformation(jobject self_, jobject info) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_setDocumentInformation, "setDocumentInformation", "(Lorg/apache/pdfbox/pdmodel/PDDocumentInformation;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_setDocumentInformation, info); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_getDocumentCatalog = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_getDocumentCatalog(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_getDocumentCatalog, "getDocumentCatalog", "()Lorg/apache/pdfbox/pdmodel/PDDocumentCatalog;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_getDocumentCatalog); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_isEncrypted = NULL; +FFI_PLUGIN_EXPORT +uint8_t org_apache_pdfbox_pdmodel_PDDocument_isEncrypted(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_isEncrypted, "isEncrypted", "()Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_isEncrypted); + return _result; +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_getEncryption = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_getEncryption(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_getEncryption, "getEncryption", "()Lorg/apache/pdfbox/pdmodel/encryption/PDEncryption;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_getEncryption); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_setEncryptionDictionary = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocument_setEncryptionDictionary(jobject self_, jobject encryption) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_setEncryptionDictionary, "setEncryptionDictionary", "(Lorg/apache/pdfbox/pdmodel/encryption/PDEncryption;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_setEncryptionDictionary, encryption); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_getLastSignatureDictionary = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_getLastSignatureDictionary(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_getLastSignatureDictionary, "getLastSignatureDictionary", "()Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSignature;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_getLastSignatureDictionary); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_getSignatureFields = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_getSignatureFields(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_getSignatureFields, "getSignatureFields", "()Ljava/util/List;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_getSignatureFields); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_getSignatureDictionaries = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_getSignatureDictionaries(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_getSignatureDictionaries, "getSignatureDictionaries", "()Ljava/util/List;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_getSignatureDictionaries); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_registerTrueTypeFontForClosing = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocument_registerTrueTypeFontForClosing(jobject self_, jobject ttf) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_registerTrueTypeFontForClosing, "registerTrueTypeFontForClosing", "(Lorg/apache/fontbox/ttf/TrueTypeFont;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_registerTrueTypeFontForClosing, ttf); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_getFontsToSubset = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_getFontsToSubset(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_getFontsToSubset, "getFontsToSubset", "()Ljava/util/Set;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_getFontsToSubset); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_load = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_load(jobject file) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_static_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_load, "load", "(Ljava/io/File;)Lorg/apache/pdfbox/pdmodel/PDDocument;"); + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_org_apache_pdfbox_pdmodel_PDDocument, _m_org_apache_pdfbox_pdmodel_PDDocument_load, file); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_load1 = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_load1(jobject file, jobject memUsageSetting) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_static_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_load1, "load", "(Ljava/io/File;Lorg/apache/pdfbox/io/MemoryUsageSetting;)Lorg/apache/pdfbox/pdmodel/PDDocument;"); + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_org_apache_pdfbox_pdmodel_PDDocument, _m_org_apache_pdfbox_pdmodel_PDDocument_load1, file, memUsageSetting); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_load2 = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_load2(jobject file, jobject password) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_static_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_load2, "load", "(Ljava/io/File;Ljava/lang/String;)Lorg/apache/pdfbox/pdmodel/PDDocument;"); + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_org_apache_pdfbox_pdmodel_PDDocument, _m_org_apache_pdfbox_pdmodel_PDDocument_load2, file, password); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_load3 = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_load3(jobject file, jobject password, jobject memUsageSetting) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_static_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_load3, "load", "(Ljava/io/File;Ljava/lang/String;Lorg/apache/pdfbox/io/MemoryUsageSetting;)Lorg/apache/pdfbox/pdmodel/PDDocument;"); + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_org_apache_pdfbox_pdmodel_PDDocument, _m_org_apache_pdfbox_pdmodel_PDDocument_load3, file, password, memUsageSetting); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_load4 = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_load4(jobject file, jobject password, jobject keyStore, jobject alias) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_static_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_load4, "load", "(Ljava/io/File;Ljava/lang/String;Ljava/io/InputStream;Ljava/lang/String;)Lorg/apache/pdfbox/pdmodel/PDDocument;"); + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_org_apache_pdfbox_pdmodel_PDDocument, _m_org_apache_pdfbox_pdmodel_PDDocument_load4, file, password, keyStore, alias); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_load5 = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_load5(jobject file, jobject password, jobject keyStore, jobject alias, jobject memUsageSetting) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_static_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_load5, "load", "(Ljava/io/File;Ljava/lang/String;Ljava/io/InputStream;Ljava/lang/String;Lorg/apache/pdfbox/io/MemoryUsageSetting;)Lorg/apache/pdfbox/pdmodel/PDDocument;"); + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_org_apache_pdfbox_pdmodel_PDDocument, _m_org_apache_pdfbox_pdmodel_PDDocument_load5, file, password, keyStore, alias, memUsageSetting); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_load6 = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_load6(jobject raFile, jobject password, jobject keyStore, jobject alias, jobject memUsageSetting) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_static_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_load6, "load", "(Lorg/apache/pdfbox/io/RandomAccessBufferedFileInputStream;Ljava/lang/String;Ljava/io/InputStream;Ljava/lang/String;Lorg/apache/pdfbox/io/MemoryUsageSetting;)Lorg/apache/pdfbox/pdmodel/PDDocument;"); + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_org_apache_pdfbox_pdmodel_PDDocument, _m_org_apache_pdfbox_pdmodel_PDDocument_load6, raFile, password, keyStore, alias, memUsageSetting); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_load7 = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_load7(jobject input) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_static_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_load7, "load", "(Ljava/io/InputStream;)Lorg/apache/pdfbox/pdmodel/PDDocument;"); + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_org_apache_pdfbox_pdmodel_PDDocument, _m_org_apache_pdfbox_pdmodel_PDDocument_load7, input); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_load8 = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_load8(jobject input, jobject memUsageSetting) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_static_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_load8, "load", "(Ljava/io/InputStream;Lorg/apache/pdfbox/io/MemoryUsageSetting;)Lorg/apache/pdfbox/pdmodel/PDDocument;"); + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_org_apache_pdfbox_pdmodel_PDDocument, _m_org_apache_pdfbox_pdmodel_PDDocument_load8, input, memUsageSetting); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_load9 = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_load9(jobject input, jobject password) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_static_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_load9, "load", "(Ljava/io/InputStream;Ljava/lang/String;)Lorg/apache/pdfbox/pdmodel/PDDocument;"); + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_org_apache_pdfbox_pdmodel_PDDocument, _m_org_apache_pdfbox_pdmodel_PDDocument_load9, input, password); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_load10 = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_load10(jobject input, jobject password, jobject keyStore, jobject alias) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_static_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_load10, "load", "(Ljava/io/InputStream;Ljava/lang/String;Ljava/io/InputStream;Ljava/lang/String;)Lorg/apache/pdfbox/pdmodel/PDDocument;"); + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_org_apache_pdfbox_pdmodel_PDDocument, _m_org_apache_pdfbox_pdmodel_PDDocument_load10, input, password, keyStore, alias); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_load11 = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_load11(jobject input, jobject password, jobject memUsageSetting) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_static_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_load11, "load", "(Ljava/io/InputStream;Ljava/lang/String;Lorg/apache/pdfbox/io/MemoryUsageSetting;)Lorg/apache/pdfbox/pdmodel/PDDocument;"); + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_org_apache_pdfbox_pdmodel_PDDocument, _m_org_apache_pdfbox_pdmodel_PDDocument_load11, input, password, memUsageSetting); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_load12 = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_load12(jobject input, jobject password, jobject keyStore, jobject alias, jobject memUsageSetting) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_static_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_load12, "load", "(Ljava/io/InputStream;Ljava/lang/String;Ljava/io/InputStream;Ljava/lang/String;Lorg/apache/pdfbox/io/MemoryUsageSetting;)Lorg/apache/pdfbox/pdmodel/PDDocument;"); + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_org_apache_pdfbox_pdmodel_PDDocument, _m_org_apache_pdfbox_pdmodel_PDDocument_load12, input, password, keyStore, alias, memUsageSetting); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_load13 = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_load13(jobject input) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_static_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_load13, "load", "(L[B;)Lorg/apache/pdfbox/pdmodel/PDDocument;"); + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_org_apache_pdfbox_pdmodel_PDDocument, _m_org_apache_pdfbox_pdmodel_PDDocument_load13, input); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_load14 = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_load14(jobject input, jobject password) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_static_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_load14, "load", "(L[B;Ljava/lang/String;)Lorg/apache/pdfbox/pdmodel/PDDocument;"); + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_org_apache_pdfbox_pdmodel_PDDocument, _m_org_apache_pdfbox_pdmodel_PDDocument_load14, input, password); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_load15 = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_load15(jobject input, jobject password, jobject keyStore, jobject alias) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_static_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_load15, "load", "(L[B;Ljava/lang/String;Ljava/io/InputStream;Ljava/lang/String;)Lorg/apache/pdfbox/pdmodel/PDDocument;"); + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_org_apache_pdfbox_pdmodel_PDDocument, _m_org_apache_pdfbox_pdmodel_PDDocument_load15, input, password, keyStore, alias); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_load16 = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_load16(jobject input, jobject password, jobject keyStore, jobject alias, jobject memUsageSetting) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_static_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_load16, "load", "(L[B;Ljava/lang/String;Ljava/io/InputStream;Ljava/lang/String;Lorg/apache/pdfbox/io/MemoryUsageSetting;)Lorg/apache/pdfbox/pdmodel/PDDocument;"); + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_org_apache_pdfbox_pdmodel_PDDocument, _m_org_apache_pdfbox_pdmodel_PDDocument_load16, input, password, keyStore, alias, memUsageSetting); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_save = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocument_save(jobject self_, jobject fileName) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_save, "save", "(Ljava/lang/String;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_save, fileName); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_save1 = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocument_save1(jobject self_, jobject file) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_save1, "save", "(Ljava/io/File;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_save1, file); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_save2 = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocument_save2(jobject self_, jobject output) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_save2, "save", "(Ljava/io/OutputStream;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_save2, output); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_saveIncremental = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocument_saveIncremental(jobject self_, jobject output) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_saveIncremental, "saveIncremental", "(Ljava/io/OutputStream;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_saveIncremental, output); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_saveIncremental1 = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocument_saveIncremental1(jobject self_, jobject output, jobject objectsToWrite) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_saveIncremental1, "saveIncremental", "(Ljava/io/OutputStream;Ljava/util/Set;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_saveIncremental1, output, objectsToWrite); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_saveIncrementalForExternalSigning = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_saveIncrementalForExternalSigning(jobject self_, jobject output) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_saveIncrementalForExternalSigning, "saveIncrementalForExternalSigning", "(Ljava/io/OutputStream;)Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/ExternalSigningSupport;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_saveIncrementalForExternalSigning, output); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_getPage = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_getPage(jobject self_, int32_t pageIndex) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_getPage, "getPage", "(I)Lorg/apache/pdfbox/pdmodel/PDPage;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_getPage, pageIndex); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_getPages = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_getPages(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_getPages, "getPages", "()Lorg/apache/pdfbox/pdmodel/PDPageTree;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_getPages); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_getNumberOfPages = NULL; +FFI_PLUGIN_EXPORT +int32_t org_apache_pdfbox_pdmodel_PDDocument_getNumberOfPages(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_getNumberOfPages, "getNumberOfPages", "()I"); + int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_getNumberOfPages); + return _result; +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_close = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocument_close(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_close, "close", "()V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_close); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_protect = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocument_protect(jobject self_, jobject policy) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_protect, "protect", "(Lorg/apache/pdfbox/pdmodel/encryption/ProtectionPolicy;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_protect, policy); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_getCurrentAccessPermission = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_getCurrentAccessPermission(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_getCurrentAccessPermission, "getCurrentAccessPermission", "()Lorg/apache/pdfbox/pdmodel/encryption/AccessPermission;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_getCurrentAccessPermission); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_isAllSecurityToBeRemoved = NULL; +FFI_PLUGIN_EXPORT +uint8_t org_apache_pdfbox_pdmodel_PDDocument_isAllSecurityToBeRemoved(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_isAllSecurityToBeRemoved, "isAllSecurityToBeRemoved", "()Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_isAllSecurityToBeRemoved); + return _result; +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_setAllSecurityToBeRemoved = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocument_setAllSecurityToBeRemoved(jobject self_, uint8_t removeAllSecurity) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_setAllSecurityToBeRemoved, "setAllSecurityToBeRemoved", "(Z)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_setAllSecurityToBeRemoved, removeAllSecurity); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_getDocumentId = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_getDocumentId(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_getDocumentId, "getDocumentId", "()Ljava/lang/Long;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_getDocumentId); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_setDocumentId = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocument_setDocumentId(jobject self_, jobject docId) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_setDocumentId, "setDocumentId", "(Ljava/lang/Long;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_setDocumentId, docId); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_getVersion = NULL; +FFI_PLUGIN_EXPORT +float org_apache_pdfbox_pdmodel_PDDocument_getVersion(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_getVersion, "getVersion", "()F"); + float _result = (*jniEnv)->CallFloatMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_getVersion); + return _result; +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_setVersion = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocument_setVersion(jobject self_, float newVersion) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_setVersion, "setVersion", "(F)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_setVersion, newVersion); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_getResourceCache = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocument_getResourceCache(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_getResourceCache, "getResourceCache", "()Lorg/apache/pdfbox/pdmodel/ResourceCache;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_getResourceCache); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocument_setResourceCache = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocument_setResourceCache(jobject self_, jobject resourceCache) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocument, &_m_org_apache_pdfbox_pdmodel_PDDocument_setResourceCache, "setResourceCache", "(Lorg/apache/pdfbox/pdmodel/ResourceCache;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocument_setResourceCache, resourceCache); +} + +jfieldID _f_org_apache_pdfbox_pdmodel_PDDocument_RESERVE_BYTE_RANGE = NULL; +jobject get_org_apache_pdfbox_pdmodel_PDDocument_RESERVE_BYTE_RANGE() { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_static_field(_c_org_apache_pdfbox_pdmodel_PDDocument, &_f_org_apache_pdfbox_pdmodel_PDDocument_RESERVE_BYTE_RANGE, "RESERVE_BYTE_RANGE","L[I;"); + return to_global_ref((*jniEnv)->GetStaticObjectField(jniEnv, _c_org_apache_pdfbox_pdmodel_PDDocument, _f_org_apache_pdfbox_pdmodel_PDDocument_RESERVE_BYTE_RANGE)); +} + + +jfieldID _f_org_apache_pdfbox_pdmodel_PDDocument_LOG = NULL; +jobject get_org_apache_pdfbox_pdmodel_PDDocument_LOG() { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_static_field(_c_org_apache_pdfbox_pdmodel_PDDocument, &_f_org_apache_pdfbox_pdmodel_PDDocument_LOG, "LOG","Lorg/apache/commons/logging/Log;"); + return to_global_ref((*jniEnv)->GetStaticObjectField(jniEnv, _c_org_apache_pdfbox_pdmodel_PDDocument, _f_org_apache_pdfbox_pdmodel_PDDocument_LOG)); +} + + +jfieldID _f_org_apache_pdfbox_pdmodel_PDDocument_document = NULL; +jobject get_org_apache_pdfbox_pdmodel_PDDocument_document(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_field(_c_org_apache_pdfbox_pdmodel_PDDocument, &_f_org_apache_pdfbox_pdmodel_PDDocument_document, "document","Lorg/apache/pdfbox/cos/COSDocument;"); + return to_global_ref((*jniEnv)->GetObjectField(jniEnv, self_, _f_org_apache_pdfbox_pdmodel_PDDocument_document)); +} + + +jfieldID _f_org_apache_pdfbox_pdmodel_PDDocument_documentInformation = NULL; +jobject get_org_apache_pdfbox_pdmodel_PDDocument_documentInformation(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_field(_c_org_apache_pdfbox_pdmodel_PDDocument, &_f_org_apache_pdfbox_pdmodel_PDDocument_documentInformation, "documentInformation","Lorg/apache/pdfbox/pdmodel/PDDocumentInformation;"); + return to_global_ref((*jniEnv)->GetObjectField(jniEnv, self_, _f_org_apache_pdfbox_pdmodel_PDDocument_documentInformation)); +} + +void set_org_apache_pdfbox_pdmodel_PDDocument_documentInformation(jobject self_, jobject value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_field(_c_org_apache_pdfbox_pdmodel_PDDocument, &_f_org_apache_pdfbox_pdmodel_PDDocument_documentInformation, "documentInformation","Lorg/apache/pdfbox/pdmodel/PDDocumentInformation;"); + ((*jniEnv)->SetObjectField(jniEnv, self_, _f_org_apache_pdfbox_pdmodel_PDDocument_documentInformation, value)); +} + + +jfieldID _f_org_apache_pdfbox_pdmodel_PDDocument_documentCatalog = NULL; +jobject get_org_apache_pdfbox_pdmodel_PDDocument_documentCatalog(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_field(_c_org_apache_pdfbox_pdmodel_PDDocument, &_f_org_apache_pdfbox_pdmodel_PDDocument_documentCatalog, "documentCatalog","Lorg/apache/pdfbox/pdmodel/PDDocumentCatalog;"); + return to_global_ref((*jniEnv)->GetObjectField(jniEnv, self_, _f_org_apache_pdfbox_pdmodel_PDDocument_documentCatalog)); +} + +void set_org_apache_pdfbox_pdmodel_PDDocument_documentCatalog(jobject self_, jobject value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_field(_c_org_apache_pdfbox_pdmodel_PDDocument, &_f_org_apache_pdfbox_pdmodel_PDDocument_documentCatalog, "documentCatalog","Lorg/apache/pdfbox/pdmodel/PDDocumentCatalog;"); + ((*jniEnv)->SetObjectField(jniEnv, self_, _f_org_apache_pdfbox_pdmodel_PDDocument_documentCatalog, value)); +} + + +jfieldID _f_org_apache_pdfbox_pdmodel_PDDocument_encryption = NULL; +jobject get_org_apache_pdfbox_pdmodel_PDDocument_encryption(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_field(_c_org_apache_pdfbox_pdmodel_PDDocument, &_f_org_apache_pdfbox_pdmodel_PDDocument_encryption, "encryption","Lorg/apache/pdfbox/pdmodel/encryption/PDEncryption;"); + return to_global_ref((*jniEnv)->GetObjectField(jniEnv, self_, _f_org_apache_pdfbox_pdmodel_PDDocument_encryption)); +} + +void set_org_apache_pdfbox_pdmodel_PDDocument_encryption(jobject self_, jobject value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_field(_c_org_apache_pdfbox_pdmodel_PDDocument, &_f_org_apache_pdfbox_pdmodel_PDDocument_encryption, "encryption","Lorg/apache/pdfbox/pdmodel/encryption/PDEncryption;"); + ((*jniEnv)->SetObjectField(jniEnv, self_, _f_org_apache_pdfbox_pdmodel_PDDocument_encryption, value)); +} + + +jfieldID _f_org_apache_pdfbox_pdmodel_PDDocument_allSecurityToBeRemoved = NULL; +uint8_t get_org_apache_pdfbox_pdmodel_PDDocument_allSecurityToBeRemoved(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_field(_c_org_apache_pdfbox_pdmodel_PDDocument, &_f_org_apache_pdfbox_pdmodel_PDDocument_allSecurityToBeRemoved, "allSecurityToBeRemoved","Z"); + return ((*jniEnv)->GetBooleanField(jniEnv, self_, _f_org_apache_pdfbox_pdmodel_PDDocument_allSecurityToBeRemoved)); +} + +void set_org_apache_pdfbox_pdmodel_PDDocument_allSecurityToBeRemoved(jobject self_, uint8_t value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_field(_c_org_apache_pdfbox_pdmodel_PDDocument, &_f_org_apache_pdfbox_pdmodel_PDDocument_allSecurityToBeRemoved, "allSecurityToBeRemoved","Z"); + ((*jniEnv)->SetBooleanField(jniEnv, self_, _f_org_apache_pdfbox_pdmodel_PDDocument_allSecurityToBeRemoved, value)); +} + + +jfieldID _f_org_apache_pdfbox_pdmodel_PDDocument_documentId = NULL; +jobject get_org_apache_pdfbox_pdmodel_PDDocument_documentId(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_field(_c_org_apache_pdfbox_pdmodel_PDDocument, &_f_org_apache_pdfbox_pdmodel_PDDocument_documentId, "documentId","Ljava/lang/Long;"); + return to_global_ref((*jniEnv)->GetObjectField(jniEnv, self_, _f_org_apache_pdfbox_pdmodel_PDDocument_documentId)); +} + +void set_org_apache_pdfbox_pdmodel_PDDocument_documentId(jobject self_, jobject value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_field(_c_org_apache_pdfbox_pdmodel_PDDocument, &_f_org_apache_pdfbox_pdmodel_PDDocument_documentId, "documentId","Ljava/lang/Long;"); + ((*jniEnv)->SetObjectField(jniEnv, self_, _f_org_apache_pdfbox_pdmodel_PDDocument_documentId, value)); +} + + +jfieldID _f_org_apache_pdfbox_pdmodel_PDDocument_pdfSource = NULL; +jobject get_org_apache_pdfbox_pdmodel_PDDocument_pdfSource(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_field(_c_org_apache_pdfbox_pdmodel_PDDocument, &_f_org_apache_pdfbox_pdmodel_PDDocument_pdfSource, "pdfSource","Lorg/apache/pdfbox/io/RandomAccessRead;"); + return to_global_ref((*jniEnv)->GetObjectField(jniEnv, self_, _f_org_apache_pdfbox_pdmodel_PDDocument_pdfSource)); +} + + +jfieldID _f_org_apache_pdfbox_pdmodel_PDDocument_accessPermission = NULL; +jobject get_org_apache_pdfbox_pdmodel_PDDocument_accessPermission(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_field(_c_org_apache_pdfbox_pdmodel_PDDocument, &_f_org_apache_pdfbox_pdmodel_PDDocument_accessPermission, "accessPermission","Lorg/apache/pdfbox/pdmodel/encryption/AccessPermission;"); + return to_global_ref((*jniEnv)->GetObjectField(jniEnv, self_, _f_org_apache_pdfbox_pdmodel_PDDocument_accessPermission)); +} + +void set_org_apache_pdfbox_pdmodel_PDDocument_accessPermission(jobject self_, jobject value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_field(_c_org_apache_pdfbox_pdmodel_PDDocument, &_f_org_apache_pdfbox_pdmodel_PDDocument_accessPermission, "accessPermission","Lorg/apache/pdfbox/pdmodel/encryption/AccessPermission;"); + ((*jniEnv)->SetObjectField(jniEnv, self_, _f_org_apache_pdfbox_pdmodel_PDDocument_accessPermission, value)); +} + + +jfieldID _f_org_apache_pdfbox_pdmodel_PDDocument_fontsToSubset = NULL; +jobject get_org_apache_pdfbox_pdmodel_PDDocument_fontsToSubset(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_field(_c_org_apache_pdfbox_pdmodel_PDDocument, &_f_org_apache_pdfbox_pdmodel_PDDocument_fontsToSubset, "fontsToSubset","Ljava/util/Set;"); + return to_global_ref((*jniEnv)->GetObjectField(jniEnv, self_, _f_org_apache_pdfbox_pdmodel_PDDocument_fontsToSubset)); +} + + +jfieldID _f_org_apache_pdfbox_pdmodel_PDDocument_fontsToClose = NULL; +jobject get_org_apache_pdfbox_pdmodel_PDDocument_fontsToClose(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_field(_c_org_apache_pdfbox_pdmodel_PDDocument, &_f_org_apache_pdfbox_pdmodel_PDDocument_fontsToClose, "fontsToClose","Ljava/util/Set;"); + return to_global_ref((*jniEnv)->GetObjectField(jniEnv, self_, _f_org_apache_pdfbox_pdmodel_PDDocument_fontsToClose)); +} + + +jfieldID _f_org_apache_pdfbox_pdmodel_PDDocument_signInterface = NULL; +jobject get_org_apache_pdfbox_pdmodel_PDDocument_signInterface(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_field(_c_org_apache_pdfbox_pdmodel_PDDocument, &_f_org_apache_pdfbox_pdmodel_PDDocument_signInterface, "signInterface","Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/SignatureInterface;"); + return to_global_ref((*jniEnv)->GetObjectField(jniEnv, self_, _f_org_apache_pdfbox_pdmodel_PDDocument_signInterface)); +} + +void set_org_apache_pdfbox_pdmodel_PDDocument_signInterface(jobject self_, jobject value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_field(_c_org_apache_pdfbox_pdmodel_PDDocument, &_f_org_apache_pdfbox_pdmodel_PDDocument_signInterface, "signInterface","Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/SignatureInterface;"); + ((*jniEnv)->SetObjectField(jniEnv, self_, _f_org_apache_pdfbox_pdmodel_PDDocument_signInterface, value)); +} + + +jfieldID _f_org_apache_pdfbox_pdmodel_PDDocument_signingSupport = NULL; +jobject get_org_apache_pdfbox_pdmodel_PDDocument_signingSupport(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_field(_c_org_apache_pdfbox_pdmodel_PDDocument, &_f_org_apache_pdfbox_pdmodel_PDDocument_signingSupport, "signingSupport","Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/SigningSupport;"); + return to_global_ref((*jniEnv)->GetObjectField(jniEnv, self_, _f_org_apache_pdfbox_pdmodel_PDDocument_signingSupport)); +} + +void set_org_apache_pdfbox_pdmodel_PDDocument_signingSupport(jobject self_, jobject value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_field(_c_org_apache_pdfbox_pdmodel_PDDocument, &_f_org_apache_pdfbox_pdmodel_PDDocument_signingSupport, "signingSupport","Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/SigningSupport;"); + ((*jniEnv)->SetObjectField(jniEnv, self_, _f_org_apache_pdfbox_pdmodel_PDDocument_signingSupport, value)); +} + + +jfieldID _f_org_apache_pdfbox_pdmodel_PDDocument_resourceCache = NULL; +jobject get_org_apache_pdfbox_pdmodel_PDDocument_resourceCache(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_field(_c_org_apache_pdfbox_pdmodel_PDDocument, &_f_org_apache_pdfbox_pdmodel_PDDocument_resourceCache, "resourceCache","Lorg/apache/pdfbox/pdmodel/ResourceCache;"); + return to_global_ref((*jniEnv)->GetObjectField(jniEnv, self_, _f_org_apache_pdfbox_pdmodel_PDDocument_resourceCache)); +} + +void set_org_apache_pdfbox_pdmodel_PDDocument_resourceCache(jobject self_, jobject value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_field(_c_org_apache_pdfbox_pdmodel_PDDocument, &_f_org_apache_pdfbox_pdmodel_PDDocument_resourceCache, "resourceCache","Lorg/apache/pdfbox/pdmodel/ResourceCache;"); + ((*jniEnv)->SetObjectField(jniEnv, self_, _f_org_apache_pdfbox_pdmodel_PDDocument_resourceCache, value)); +} + + +jfieldID _f_org_apache_pdfbox_pdmodel_PDDocument_signatureAdded = NULL; +uint8_t get_org_apache_pdfbox_pdmodel_PDDocument_signatureAdded(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_field(_c_org_apache_pdfbox_pdmodel_PDDocument, &_f_org_apache_pdfbox_pdmodel_PDDocument_signatureAdded, "signatureAdded","Z"); + return ((*jniEnv)->GetBooleanField(jniEnv, self_, _f_org_apache_pdfbox_pdmodel_PDDocument_signatureAdded)); +} + +void set_org_apache_pdfbox_pdmodel_PDDocument_signatureAdded(jobject self_, uint8_t value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_field(_c_org_apache_pdfbox_pdmodel_PDDocument, &_f_org_apache_pdfbox_pdmodel_PDDocument_signatureAdded, "signatureAdded","Z"); + ((*jniEnv)->SetBooleanField(jniEnv, self_, _f_org_apache_pdfbox_pdmodel_PDDocument_signatureAdded, value)); +} + + +// org.apache.pdfbox.pdmodel.PDDocumentInformation +jclass _c_org_apache_pdfbox_pdmodel_PDDocumentInformation = NULL; + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_ctor = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocumentInformation_ctor() { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, &_m_org_apache_pdfbox_pdmodel_PDDocumentInformation_ctor, "", "()V"); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_org_apache_pdfbox_pdmodel_PDDocumentInformation, _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_ctor); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_ctor1 = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocumentInformation_ctor1(jobject dic) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, &_m_org_apache_pdfbox_pdmodel_PDDocumentInformation_ctor1, "", "(Lorg/apache/pdfbox/cos/COSDictionary;)V"); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_org_apache_pdfbox_pdmodel_PDDocumentInformation, _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_ctor1, dic); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getCOSObject = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocumentInformation_getCOSObject(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, &_m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getCOSObject, "getCOSObject", "()Lorg/apache/pdfbox/cos/COSDictionary;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getCOSObject); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getPropertyStringValue = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocumentInformation_getPropertyStringValue(jobject self_, jobject propertyKey) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, &_m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getPropertyStringValue, "getPropertyStringValue", "(Ljava/lang/String;)Ljava/lang/Object;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getPropertyStringValue, propertyKey); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getTitle = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocumentInformation_getTitle(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, &_m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getTitle, "getTitle", "()Ljava/lang/String;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getTitle); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_setTitle = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocumentInformation_setTitle(jobject self_, jobject title) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, &_m_org_apache_pdfbox_pdmodel_PDDocumentInformation_setTitle, "setTitle", "(Ljava/lang/String;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_setTitle, title); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getAuthor = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocumentInformation_getAuthor(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, &_m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getAuthor, "getAuthor", "()Ljava/lang/String;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getAuthor); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_setAuthor = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocumentInformation_setAuthor(jobject self_, jobject author) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, &_m_org_apache_pdfbox_pdmodel_PDDocumentInformation_setAuthor, "setAuthor", "(Ljava/lang/String;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_setAuthor, author); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getSubject = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocumentInformation_getSubject(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, &_m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getSubject, "getSubject", "()Ljava/lang/String;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getSubject); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_setSubject = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocumentInformation_setSubject(jobject self_, jobject subject) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, &_m_org_apache_pdfbox_pdmodel_PDDocumentInformation_setSubject, "setSubject", "(Ljava/lang/String;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_setSubject, subject); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getKeywords = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocumentInformation_getKeywords(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, &_m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getKeywords, "getKeywords", "()Ljava/lang/String;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getKeywords); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_setKeywords = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocumentInformation_setKeywords(jobject self_, jobject keywords) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, &_m_org_apache_pdfbox_pdmodel_PDDocumentInformation_setKeywords, "setKeywords", "(Ljava/lang/String;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_setKeywords, keywords); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getCreator = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocumentInformation_getCreator(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, &_m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getCreator, "getCreator", "()Ljava/lang/String;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getCreator); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_setCreator = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocumentInformation_setCreator(jobject self_, jobject creator) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, &_m_org_apache_pdfbox_pdmodel_PDDocumentInformation_setCreator, "setCreator", "(Ljava/lang/String;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_setCreator, creator); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getProducer = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocumentInformation_getProducer(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, &_m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getProducer, "getProducer", "()Ljava/lang/String;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getProducer); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_setProducer = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocumentInformation_setProducer(jobject self_, jobject producer) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, &_m_org_apache_pdfbox_pdmodel_PDDocumentInformation_setProducer, "setProducer", "(Ljava/lang/String;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_setProducer, producer); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getCreationDate = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocumentInformation_getCreationDate(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, &_m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getCreationDate, "getCreationDate", "()Ljava/util/Calendar;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getCreationDate); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_setCreationDate = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocumentInformation_setCreationDate(jobject self_, jobject date) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, &_m_org_apache_pdfbox_pdmodel_PDDocumentInformation_setCreationDate, "setCreationDate", "(Ljava/util/Calendar;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_setCreationDate, date); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getModificationDate = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocumentInformation_getModificationDate(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, &_m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getModificationDate, "getModificationDate", "()Ljava/util/Calendar;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getModificationDate); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_setModificationDate = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocumentInformation_setModificationDate(jobject self_, jobject date) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, &_m_org_apache_pdfbox_pdmodel_PDDocumentInformation_setModificationDate, "setModificationDate", "(Ljava/util/Calendar;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_setModificationDate, date); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getTrapped = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocumentInformation_getTrapped(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, &_m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getTrapped, "getTrapped", "()Ljava/lang/String;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getTrapped); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getMetadataKeys = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocumentInformation_getMetadataKeys(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, &_m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getMetadataKeys, "getMetadataKeys", "()Ljava/util/Set;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getMetadataKeys); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getCustomMetadataValue = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_pdmodel_PDDocumentInformation_getCustomMetadataValue(jobject self_, jobject fieldName) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, &_m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getCustomMetadataValue, "getCustomMetadataValue", "(Ljava/lang/String;)Ljava/lang/String;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_getCustomMetadataValue, fieldName); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_setCustomMetadataValue = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocumentInformation_setCustomMetadataValue(jobject self_, jobject fieldName, jobject fieldValue) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, &_m_org_apache_pdfbox_pdmodel_PDDocumentInformation_setCustomMetadataValue, "setCustomMetadataValue", "(Ljava/lang/String;Ljava/lang/String;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_setCustomMetadataValue, fieldName, fieldValue); +} + +jmethodID _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_setTrapped = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_pdmodel_PDDocumentInformation_setTrapped(jobject self_, jobject value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_method(_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, &_m_org_apache_pdfbox_pdmodel_PDDocumentInformation_setTrapped, "setTrapped", "(Ljava/lang/String;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_pdmodel_PDDocumentInformation_setTrapped, value); +} + +jfieldID _f_org_apache_pdfbox_pdmodel_PDDocumentInformation_info = NULL; +jobject get_org_apache_pdfbox_pdmodel_PDDocumentInformation_info(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_field(_c_org_apache_pdfbox_pdmodel_PDDocumentInformation, &_f_org_apache_pdfbox_pdmodel_PDDocumentInformation_info, "info","Lorg/apache/pdfbox/cos/COSDictionary;"); + return to_global_ref((*jniEnv)->GetObjectField(jniEnv, self_, _f_org_apache_pdfbox_pdmodel_PDDocumentInformation_info)); +} + + +// org.apache.pdfbox.text.PDFTextStripper +jclass _c_org_apache_pdfbox_text_PDFTextStripper = NULL; + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_ctor = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_text_PDFTextStripper_ctor() { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_ctor, "", "()V"); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_org_apache_pdfbox_text_PDFTextStripper, _m_org_apache_pdfbox_text_PDFTextStripper_ctor); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_getText = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_text_PDFTextStripper_getText(jobject self_, jobject doc) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_getText, "getText", "(Lorg/apache/pdfbox/pdmodel/PDDocument;)Ljava/lang/String;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_getText, doc); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_resetEngine = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_resetEngine(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_resetEngine, "resetEngine", "()V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_resetEngine); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_writeText = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_writeText(jobject self_, jobject doc, jobject outputStream) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_writeText, "writeText", "(Lorg/apache/pdfbox/pdmodel/PDDocument;Ljava/io/Writer;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_writeText, doc, outputStream); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_processPages = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_processPages(jobject self_, jobject pages) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_processPages, "processPages", "(Lorg/apache/pdfbox/pdmodel/PDPageTree;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_processPages, pages); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_startDocument = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_startDocument(jobject self_, jobject document) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_startDocument, "startDocument", "(Lorg/apache/pdfbox/pdmodel/PDDocument;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_startDocument, document); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_endDocument = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_endDocument(jobject self_, jobject document) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_endDocument, "endDocument", "(Lorg/apache/pdfbox/pdmodel/PDDocument;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_endDocument, document); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_processPage = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_processPage(jobject self_, jobject page) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_processPage, "processPage", "(Lorg/apache/pdfbox/pdmodel/PDPage;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_processPage, page); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_fillBeadRectangles = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_fillBeadRectangles(jobject self_, jobject page) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_fillBeadRectangles, "fillBeadRectangles", "(Lorg/apache/pdfbox/pdmodel/PDPage;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_fillBeadRectangles, page); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_startArticle = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_startArticle(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_startArticle, "startArticle", "()V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_startArticle); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_startArticle1 = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_startArticle1(jobject self_, uint8_t isLTR) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_startArticle1, "startArticle", "(Z)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_startArticle1, isLTR); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_endArticle = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_endArticle(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_endArticle, "endArticle", "()V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_endArticle); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_startPage1 = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_startPage1(jobject self_, jobject page) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_startPage1, "startPage", "(Lorg/apache/pdfbox/pdmodel/PDPage;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_startPage1, page); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_endPage1 = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_endPage1(jobject self_, jobject page) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_endPage1, "endPage", "(Lorg/apache/pdfbox/pdmodel/PDPage;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_endPage1, page); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_writePage = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_writePage(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_writePage, "writePage", "()V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_writePage); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_overlap = NULL; +FFI_PLUGIN_EXPORT +uint8_t org_apache_pdfbox_text_PDFTextStripper_overlap(jobject self_, float y1, float height1, float y2, float height2) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_overlap, "overlap", "(FFFF)Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_overlap, y1, height1, y2, height2); + return _result; +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_writeLineSeparator = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_writeLineSeparator(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_writeLineSeparator, "writeLineSeparator", "()V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_writeLineSeparator); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_writeWordSeparator = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_writeWordSeparator(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_writeWordSeparator, "writeWordSeparator", "()V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_writeWordSeparator); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_writeCharacters = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_writeCharacters(jobject self_, jobject text) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_writeCharacters, "writeCharacters", "(Lorg/apache/pdfbox/text/TextPosition;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_writeCharacters, text); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_writeString = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_writeString(jobject self_, jobject text, jobject textPositions) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_writeString, "writeString", "(Ljava/lang/String;Ljava/util/List;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_writeString, text, textPositions); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_writeString1 = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_writeString1(jobject self_, jobject text) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_writeString1, "writeString", "(Ljava/lang/String;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_writeString1, text); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_within = NULL; +FFI_PLUGIN_EXPORT +uint8_t org_apache_pdfbox_text_PDFTextStripper_within(jobject self_, float first, float second, float variance) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_within, "within", "(FFF)Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_within, first, second, variance); + return _result; +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_processTextPosition = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_processTextPosition(jobject self_, jobject text) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_processTextPosition, "processTextPosition", "(Lorg/apache/pdfbox/text/TextPosition;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_processTextPosition, text); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_getStartPage = NULL; +FFI_PLUGIN_EXPORT +int32_t org_apache_pdfbox_text_PDFTextStripper_getStartPage(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_getStartPage, "getStartPage", "()I"); + int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_getStartPage); + return _result; +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_setStartPage = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_setStartPage(jobject self_, int32_t startPageValue) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_setStartPage, "setStartPage", "(I)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_setStartPage, startPageValue); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_getEndPage = NULL; +FFI_PLUGIN_EXPORT +int32_t org_apache_pdfbox_text_PDFTextStripper_getEndPage(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_getEndPage, "getEndPage", "()I"); + int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_getEndPage); + return _result; +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_setEndPage = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_setEndPage(jobject self_, int32_t endPageValue) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_setEndPage, "setEndPage", "(I)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_setEndPage, endPageValue); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_setLineSeparator = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_setLineSeparator(jobject self_, jobject separator) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_setLineSeparator, "setLineSeparator", "(Ljava/lang/String;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_setLineSeparator, separator); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_getLineSeparator = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_text_PDFTextStripper_getLineSeparator(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_getLineSeparator, "getLineSeparator", "()Ljava/lang/String;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_getLineSeparator); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_getWordSeparator = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_text_PDFTextStripper_getWordSeparator(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_getWordSeparator, "getWordSeparator", "()Ljava/lang/String;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_getWordSeparator); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_setWordSeparator = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_setWordSeparator(jobject self_, jobject separator) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_setWordSeparator, "setWordSeparator", "(Ljava/lang/String;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_setWordSeparator, separator); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_getSuppressDuplicateOverlappingText = NULL; +FFI_PLUGIN_EXPORT +uint8_t org_apache_pdfbox_text_PDFTextStripper_getSuppressDuplicateOverlappingText(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_getSuppressDuplicateOverlappingText, "getSuppressDuplicateOverlappingText", "()Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_getSuppressDuplicateOverlappingText); + return _result; +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_getCurrentPageNo = NULL; +FFI_PLUGIN_EXPORT +int32_t org_apache_pdfbox_text_PDFTextStripper_getCurrentPageNo(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_getCurrentPageNo, "getCurrentPageNo", "()I"); + int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_getCurrentPageNo); + return _result; +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_getOutput = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_text_PDFTextStripper_getOutput(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_getOutput, "getOutput", "()Ljava/io/Writer;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_getOutput); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_getCharactersByArticle = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_text_PDFTextStripper_getCharactersByArticle(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_getCharactersByArticle, "getCharactersByArticle", "()Ljava/util/List;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_getCharactersByArticle); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_setSuppressDuplicateOverlappingText = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_setSuppressDuplicateOverlappingText(jobject self_, uint8_t suppressDuplicateOverlappingTextValue) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_setSuppressDuplicateOverlappingText, "setSuppressDuplicateOverlappingText", "(Z)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_setSuppressDuplicateOverlappingText, suppressDuplicateOverlappingTextValue); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_getSeparateByBeads = NULL; +FFI_PLUGIN_EXPORT +uint8_t org_apache_pdfbox_text_PDFTextStripper_getSeparateByBeads(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_getSeparateByBeads, "getSeparateByBeads", "()Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_getSeparateByBeads); + return _result; +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_setShouldSeparateByBeads = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_setShouldSeparateByBeads(jobject self_, uint8_t aShouldSeparateByBeads) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_setShouldSeparateByBeads, "setShouldSeparateByBeads", "(Z)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_setShouldSeparateByBeads, aShouldSeparateByBeads); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_getEndBookmark = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_text_PDFTextStripper_getEndBookmark(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_getEndBookmark, "getEndBookmark", "()Lorg/apache/pdfbox/pdmodel/interactive/documentnavigation/outline/PDOutlineItem;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_getEndBookmark); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_setEndBookmark = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_setEndBookmark(jobject self_, jobject aEndBookmark) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_setEndBookmark, "setEndBookmark", "(Lorg/apache/pdfbox/pdmodel/interactive/documentnavigation/outline/PDOutlineItem;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_setEndBookmark, aEndBookmark); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_getStartBookmark = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_text_PDFTextStripper_getStartBookmark(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_getStartBookmark, "getStartBookmark", "()Lorg/apache/pdfbox/pdmodel/interactive/documentnavigation/outline/PDOutlineItem;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_getStartBookmark); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_setStartBookmark = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_setStartBookmark(jobject self_, jobject aStartBookmark) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_setStartBookmark, "setStartBookmark", "(Lorg/apache/pdfbox/pdmodel/interactive/documentnavigation/outline/PDOutlineItem;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_setStartBookmark, aStartBookmark); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_getAddMoreFormatting = NULL; +FFI_PLUGIN_EXPORT +uint8_t org_apache_pdfbox_text_PDFTextStripper_getAddMoreFormatting(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_getAddMoreFormatting, "getAddMoreFormatting", "()Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_getAddMoreFormatting); + return _result; +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_setAddMoreFormatting = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_setAddMoreFormatting(jobject self_, uint8_t newAddMoreFormatting) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_setAddMoreFormatting, "setAddMoreFormatting", "(Z)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_setAddMoreFormatting, newAddMoreFormatting); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_getSortByPosition = NULL; +FFI_PLUGIN_EXPORT +uint8_t org_apache_pdfbox_text_PDFTextStripper_getSortByPosition(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_getSortByPosition, "getSortByPosition", "()Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_getSortByPosition); + return _result; +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_setSortByPosition = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_setSortByPosition(jobject self_, uint8_t newSortByPosition) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_setSortByPosition, "setSortByPosition", "(Z)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_setSortByPosition, newSortByPosition); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_getSpacingTolerance = NULL; +FFI_PLUGIN_EXPORT +float org_apache_pdfbox_text_PDFTextStripper_getSpacingTolerance(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_getSpacingTolerance, "getSpacingTolerance", "()F"); + float _result = (*jniEnv)->CallFloatMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_getSpacingTolerance); + return _result; +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_setSpacingTolerance = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_setSpacingTolerance(jobject self_, float spacingToleranceValue) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_setSpacingTolerance, "setSpacingTolerance", "(F)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_setSpacingTolerance, spacingToleranceValue); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_getAverageCharTolerance = NULL; +FFI_PLUGIN_EXPORT +float org_apache_pdfbox_text_PDFTextStripper_getAverageCharTolerance(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_getAverageCharTolerance, "getAverageCharTolerance", "()F"); + float _result = (*jniEnv)->CallFloatMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_getAverageCharTolerance); + return _result; +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_setAverageCharTolerance = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_setAverageCharTolerance(jobject self_, float averageCharToleranceValue) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_setAverageCharTolerance, "setAverageCharTolerance", "(F)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_setAverageCharTolerance, averageCharToleranceValue); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_getIndentThreshold = NULL; +FFI_PLUGIN_EXPORT +float org_apache_pdfbox_text_PDFTextStripper_getIndentThreshold(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_getIndentThreshold, "getIndentThreshold", "()F"); + float _result = (*jniEnv)->CallFloatMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_getIndentThreshold); + return _result; +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_setIndentThreshold = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_setIndentThreshold(jobject self_, float indentThresholdValue) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_setIndentThreshold, "setIndentThreshold", "(F)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_setIndentThreshold, indentThresholdValue); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_getDropThreshold = NULL; +FFI_PLUGIN_EXPORT +float org_apache_pdfbox_text_PDFTextStripper_getDropThreshold(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_getDropThreshold, "getDropThreshold", "()F"); + float _result = (*jniEnv)->CallFloatMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_getDropThreshold); + return _result; +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_setDropThreshold = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_setDropThreshold(jobject self_, float dropThresholdValue) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_setDropThreshold, "setDropThreshold", "(F)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_setDropThreshold, dropThresholdValue); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_getParagraphStart = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_text_PDFTextStripper_getParagraphStart(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_getParagraphStart, "getParagraphStart", "()Ljava/lang/String;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_getParagraphStart); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_setParagraphStart = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_setParagraphStart(jobject self_, jobject s) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_setParagraphStart, "setParagraphStart", "(Ljava/lang/String;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_setParagraphStart, s); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_getParagraphEnd = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_text_PDFTextStripper_getParagraphEnd(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_getParagraphEnd, "getParagraphEnd", "()Ljava/lang/String;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_getParagraphEnd); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_setParagraphEnd = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_setParagraphEnd(jobject self_, jobject s) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_setParagraphEnd, "setParagraphEnd", "(Ljava/lang/String;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_setParagraphEnd, s); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_getPageStart = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_text_PDFTextStripper_getPageStart(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_getPageStart, "getPageStart", "()Ljava/lang/String;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_getPageStart); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_setPageStart = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_setPageStart(jobject self_, jobject pageStartValue) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_setPageStart, "setPageStart", "(Ljava/lang/String;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_setPageStart, pageStartValue); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_getPageEnd = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_text_PDFTextStripper_getPageEnd(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_getPageEnd, "getPageEnd", "()Ljava/lang/String;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_getPageEnd); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_setPageEnd = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_setPageEnd(jobject self_, jobject pageEndValue) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_setPageEnd, "setPageEnd", "(Ljava/lang/String;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_setPageEnd, pageEndValue); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_getArticleStart = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_text_PDFTextStripper_getArticleStart(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_getArticleStart, "getArticleStart", "()Ljava/lang/String;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_getArticleStart); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_setArticleStart = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_setArticleStart(jobject self_, jobject articleStartValue) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_setArticleStart, "setArticleStart", "(Ljava/lang/String;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_setArticleStart, articleStartValue); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_getArticleEnd = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_text_PDFTextStripper_getArticleEnd(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_getArticleEnd, "getArticleEnd", "()Ljava/lang/String;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_getArticleEnd); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_setArticleEnd = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_setArticleEnd(jobject self_, jobject articleEndValue) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_setArticleEnd, "setArticleEnd", "(Ljava/lang/String;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_setArticleEnd, articleEndValue); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_handleLineSeparation = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_text_PDFTextStripper_handleLineSeparation(jobject self_, jobject current, jobject lastPosition, jobject lastLineStartPosition, float maxHeightForLine) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_handleLineSeparation, "handleLineSeparation", "(Lorg/apache/pdfbox/text/PDFTextStripper$PositionWrapper;Lorg/apache/pdfbox/text/PDFTextStripper$PositionWrapper;Lorg/apache/pdfbox/text/PDFTextStripper$PositionWrapper;F)Lorg/apache/pdfbox/text/PDFTextStripper$PositionWrapper;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_handleLineSeparation, current, lastPosition, lastLineStartPosition, maxHeightForLine); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_isParagraphSeparation = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_isParagraphSeparation(jobject self_, jobject position, jobject lastPosition, jobject lastLineStartPosition, float maxHeightForLine) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_isParagraphSeparation, "isParagraphSeparation", "(Lorg/apache/pdfbox/text/PDFTextStripper$PositionWrapper;Lorg/apache/pdfbox/text/PDFTextStripper$PositionWrapper;Lorg/apache/pdfbox/text/PDFTextStripper$PositionWrapper;F)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_isParagraphSeparation, position, lastPosition, lastLineStartPosition, maxHeightForLine); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_multiplyFloat = NULL; +FFI_PLUGIN_EXPORT +float org_apache_pdfbox_text_PDFTextStripper_multiplyFloat(jobject self_, float value1, float value2) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_multiplyFloat, "multiplyFloat", "(FF)F"); + float _result = (*jniEnv)->CallFloatMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_multiplyFloat, value1, value2); + return _result; +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_writeParagraphSeparator = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_writeParagraphSeparator(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_writeParagraphSeparator, "writeParagraphSeparator", "()V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_writeParagraphSeparator); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_writeParagraphStart = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_writeParagraphStart(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_writeParagraphStart, "writeParagraphStart", "()V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_writeParagraphStart); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_writeParagraphEnd = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_writeParagraphEnd(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_writeParagraphEnd, "writeParagraphEnd", "()V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_writeParagraphEnd); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_writePageStart = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_writePageStart(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_writePageStart, "writePageStart", "()V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_writePageStart); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_writePageEnd = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_writePageEnd(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_writePageEnd, "writePageEnd", "()V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_writePageEnd); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_matchListItemPattern = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_text_PDFTextStripper_matchListItemPattern(jobject self_, jobject pw) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_matchListItemPattern, "matchListItemPattern", "(Lorg/apache/pdfbox/text/PDFTextStripper$PositionWrapper;)Ljava/util/regex/Pattern;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_matchListItemPattern, pw); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_setListItemPatterns = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_setListItemPatterns(jobject self_, jobject patterns) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_setListItemPatterns, "setListItemPatterns", "(Ljava/util/List;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_setListItemPatterns, patterns); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_getListItemPatterns = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_text_PDFTextStripper_getListItemPatterns(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_getListItemPatterns, "getListItemPatterns", "()Ljava/util/List;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_getListItemPatterns); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_matchPattern = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_text_PDFTextStripper_matchPattern(jobject string, jobject patterns) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_static_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_matchPattern, "matchPattern", "(Ljava/lang/String;Ljava/util/List;)Ljava/util/regex/Pattern;"); + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_org_apache_pdfbox_text_PDFTextStripper, _m_org_apache_pdfbox_text_PDFTextStripper_matchPattern, string, patterns); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_writeLine = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_writeLine(jobject self_, jobject line) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_writeLine, "writeLine", "(Ljava/util/List;)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_writeLine, line); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_normalize = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_text_PDFTextStripper_normalize(jobject self_, jobject line) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_normalize, "normalize", "(Ljava/util/List;)Ljava/util/List;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_normalize, line); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_handleDirection = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_text_PDFTextStripper_handleDirection(jobject self_, jobject word) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_handleDirection, "handleDirection", "(Ljava/lang/String;)Ljava/lang/String;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_handleDirection, word); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_parseBidiFile = NULL; +FFI_PLUGIN_EXPORT +void org_apache_pdfbox_text_PDFTextStripper_parseBidiFile(jobject inputStream) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_static_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_parseBidiFile, "parseBidiFile", "(Ljava/io/InputStream;)V"); + (*jniEnv)->CallStaticVoidMethod(jniEnv, _c_org_apache_pdfbox_text_PDFTextStripper, _m_org_apache_pdfbox_text_PDFTextStripper_parseBidiFile, inputStream); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_createWord = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_text_PDFTextStripper_createWord(jobject self_, jobject word, jobject wordPositions) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_createWord, "createWord", "(Ljava/lang/String;Ljava/util/List;)Lorg/apache/pdfbox/text/PDFTextStripper$WordWithTextPositions;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_createWord, word, wordPositions); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_normalizeWord = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_text_PDFTextStripper_normalizeWord(jobject self_, jobject word) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_normalizeWord, "normalizeWord", "(Ljava/lang/String;)Ljava/lang/String;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_normalizeWord, word); + return to_global_ref(_result); +} + +jmethodID _m_org_apache_pdfbox_text_PDFTextStripper_normalizeAdd = NULL; +FFI_PLUGIN_EXPORT +jobject org_apache_pdfbox_text_PDFTextStripper_normalizeAdd(jobject self_, jobject normalized, jobject lineBuilder, jobject wordPositions, jobject item) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_method(_c_org_apache_pdfbox_text_PDFTextStripper, &_m_org_apache_pdfbox_text_PDFTextStripper_normalizeAdd, "normalizeAdd", "(Ljava/util/List;Ljava/lang/StringBuilder;Ljava/util/List;Lorg/apache/pdfbox/text/PDFTextStripper$LineItem;)Ljava/lang/StringBuilder;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_org_apache_pdfbox_text_PDFTextStripper_normalizeAdd, normalized, lineBuilder, wordPositions, item); + return to_global_ref(_result); +} + +jfieldID _f_org_apache_pdfbox_text_PDFTextStripper_defaultIndentThreshold = NULL; +float get_org_apache_pdfbox_text_PDFTextStripper_defaultIndentThreshold() { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_static_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_defaultIndentThreshold, "defaultIndentThreshold","F"); + return ((*jniEnv)->GetStaticFloatField(jniEnv, _c_org_apache_pdfbox_text_PDFTextStripper, _f_org_apache_pdfbox_text_PDFTextStripper_defaultIndentThreshold)); +} + +void set_org_apache_pdfbox_text_PDFTextStripper_defaultIndentThreshold(float value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_static_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_defaultIndentThreshold, "defaultIndentThreshold","F"); + ((*jniEnv)->SetStaticFloatField(jniEnv, _c_org_apache_pdfbox_text_PDFTextStripper, _f_org_apache_pdfbox_text_PDFTextStripper_defaultIndentThreshold, value)); +} + + +jfieldID _f_org_apache_pdfbox_text_PDFTextStripper_defaultDropThreshold = NULL; +float get_org_apache_pdfbox_text_PDFTextStripper_defaultDropThreshold() { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_static_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_defaultDropThreshold, "defaultDropThreshold","F"); + return ((*jniEnv)->GetStaticFloatField(jniEnv, _c_org_apache_pdfbox_text_PDFTextStripper, _f_org_apache_pdfbox_text_PDFTextStripper_defaultDropThreshold)); +} + +void set_org_apache_pdfbox_text_PDFTextStripper_defaultDropThreshold(float value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_static_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_defaultDropThreshold, "defaultDropThreshold","F"); + ((*jniEnv)->SetStaticFloatField(jniEnv, _c_org_apache_pdfbox_text_PDFTextStripper, _f_org_apache_pdfbox_text_PDFTextStripper_defaultDropThreshold, value)); +} + + +jfieldID _f_org_apache_pdfbox_text_PDFTextStripper_LOG = NULL; +jobject get_org_apache_pdfbox_text_PDFTextStripper_LOG() { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_static_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_LOG, "LOG","Lorg/apache/commons/logging/Log;"); + return to_global_ref((*jniEnv)->GetStaticObjectField(jniEnv, _c_org_apache_pdfbox_text_PDFTextStripper, _f_org_apache_pdfbox_text_PDFTextStripper_LOG)); +} + + +jfieldID _f_org_apache_pdfbox_text_PDFTextStripper_LINE_SEPARATOR = NULL; +jobject get_org_apache_pdfbox_text_PDFTextStripper_LINE_SEPARATOR(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_LINE_SEPARATOR, "LINE_SEPARATOR","Ljava/lang/String;"); + return to_global_ref((*jniEnv)->GetObjectField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_LINE_SEPARATOR)); +} + + +jfieldID _f_org_apache_pdfbox_text_PDFTextStripper_lineSeparator = NULL; +jobject get_org_apache_pdfbox_text_PDFTextStripper_lineSeparator(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_lineSeparator, "lineSeparator","Ljava/lang/String;"); + return to_global_ref((*jniEnv)->GetObjectField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_lineSeparator)); +} + +void set_org_apache_pdfbox_text_PDFTextStripper_lineSeparator(jobject self_, jobject value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_lineSeparator, "lineSeparator","Ljava/lang/String;"); + ((*jniEnv)->SetObjectField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_lineSeparator, value)); +} + + +jfieldID _f_org_apache_pdfbox_text_PDFTextStripper_wordSeparator = NULL; +jobject get_org_apache_pdfbox_text_PDFTextStripper_wordSeparator(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_wordSeparator, "wordSeparator","Ljava/lang/String;"); + return to_global_ref((*jniEnv)->GetObjectField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_wordSeparator)); +} + +void set_org_apache_pdfbox_text_PDFTextStripper_wordSeparator(jobject self_, jobject value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_wordSeparator, "wordSeparator","Ljava/lang/String;"); + ((*jniEnv)->SetObjectField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_wordSeparator, value)); +} + + +jfieldID _f_org_apache_pdfbox_text_PDFTextStripper_paragraphStart = NULL; +jobject get_org_apache_pdfbox_text_PDFTextStripper_paragraphStart(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_paragraphStart, "paragraphStart","Ljava/lang/String;"); + return to_global_ref((*jniEnv)->GetObjectField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_paragraphStart)); +} + +void set_org_apache_pdfbox_text_PDFTextStripper_paragraphStart(jobject self_, jobject value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_paragraphStart, "paragraphStart","Ljava/lang/String;"); + ((*jniEnv)->SetObjectField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_paragraphStart, value)); +} + + +jfieldID _f_org_apache_pdfbox_text_PDFTextStripper_paragraphEnd = NULL; +jobject get_org_apache_pdfbox_text_PDFTextStripper_paragraphEnd(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_paragraphEnd, "paragraphEnd","Ljava/lang/String;"); + return to_global_ref((*jniEnv)->GetObjectField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_paragraphEnd)); +} + +void set_org_apache_pdfbox_text_PDFTextStripper_paragraphEnd(jobject self_, jobject value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_paragraphEnd, "paragraphEnd","Ljava/lang/String;"); + ((*jniEnv)->SetObjectField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_paragraphEnd, value)); +} + + +jfieldID _f_org_apache_pdfbox_text_PDFTextStripper_pageStart = NULL; +jobject get_org_apache_pdfbox_text_PDFTextStripper_pageStart(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_pageStart, "pageStart","Ljava/lang/String;"); + return to_global_ref((*jniEnv)->GetObjectField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_pageStart)); +} + +void set_org_apache_pdfbox_text_PDFTextStripper_pageStart(jobject self_, jobject value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_pageStart, "pageStart","Ljava/lang/String;"); + ((*jniEnv)->SetObjectField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_pageStart, value)); +} + + +jfieldID _f_org_apache_pdfbox_text_PDFTextStripper_pageEnd = NULL; +jobject get_org_apache_pdfbox_text_PDFTextStripper_pageEnd(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_pageEnd, "pageEnd","Ljava/lang/String;"); + return to_global_ref((*jniEnv)->GetObjectField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_pageEnd)); +} + +void set_org_apache_pdfbox_text_PDFTextStripper_pageEnd(jobject self_, jobject value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_pageEnd, "pageEnd","Ljava/lang/String;"); + ((*jniEnv)->SetObjectField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_pageEnd, value)); +} + + +jfieldID _f_org_apache_pdfbox_text_PDFTextStripper_articleStart = NULL; +jobject get_org_apache_pdfbox_text_PDFTextStripper_articleStart(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_articleStart, "articleStart","Ljava/lang/String;"); + return to_global_ref((*jniEnv)->GetObjectField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_articleStart)); +} + +void set_org_apache_pdfbox_text_PDFTextStripper_articleStart(jobject self_, jobject value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_articleStart, "articleStart","Ljava/lang/String;"); + ((*jniEnv)->SetObjectField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_articleStart, value)); +} + + +jfieldID _f_org_apache_pdfbox_text_PDFTextStripper_articleEnd = NULL; +jobject get_org_apache_pdfbox_text_PDFTextStripper_articleEnd(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_articleEnd, "articleEnd","Ljava/lang/String;"); + return to_global_ref((*jniEnv)->GetObjectField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_articleEnd)); +} + +void set_org_apache_pdfbox_text_PDFTextStripper_articleEnd(jobject self_, jobject value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_articleEnd, "articleEnd","Ljava/lang/String;"); + ((*jniEnv)->SetObjectField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_articleEnd, value)); +} + + +jfieldID _f_org_apache_pdfbox_text_PDFTextStripper_currentPageNo = NULL; +int32_t get_org_apache_pdfbox_text_PDFTextStripper_currentPageNo(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_currentPageNo, "currentPageNo","I"); + return ((*jniEnv)->GetIntField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_currentPageNo)); +} + +void set_org_apache_pdfbox_text_PDFTextStripper_currentPageNo(jobject self_, int32_t value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_currentPageNo, "currentPageNo","I"); + ((*jniEnv)->SetIntField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_currentPageNo, value)); +} + + +jfieldID _f_org_apache_pdfbox_text_PDFTextStripper_startPage = NULL; +int32_t get_org_apache_pdfbox_text_PDFTextStripper_startPage(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_startPage, "startPage","I"); + return ((*jniEnv)->GetIntField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_startPage)); +} + +void set_org_apache_pdfbox_text_PDFTextStripper_startPage(jobject self_, int32_t value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_startPage, "startPage","I"); + ((*jniEnv)->SetIntField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_startPage, value)); +} + + +jfieldID _f_org_apache_pdfbox_text_PDFTextStripper_endPage = NULL; +int32_t get_org_apache_pdfbox_text_PDFTextStripper_endPage(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_endPage, "endPage","I"); + return ((*jniEnv)->GetIntField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_endPage)); +} + +void set_org_apache_pdfbox_text_PDFTextStripper_endPage(jobject self_, int32_t value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_endPage, "endPage","I"); + ((*jniEnv)->SetIntField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_endPage, value)); +} + + +jfieldID _f_org_apache_pdfbox_text_PDFTextStripper_startBookmark = NULL; +jobject get_org_apache_pdfbox_text_PDFTextStripper_startBookmark(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_startBookmark, "startBookmark","Lorg/apache/pdfbox/pdmodel/interactive/documentnavigation/outline/PDOutlineItem;"); + return to_global_ref((*jniEnv)->GetObjectField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_startBookmark)); +} + +void set_org_apache_pdfbox_text_PDFTextStripper_startBookmark(jobject self_, jobject value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_startBookmark, "startBookmark","Lorg/apache/pdfbox/pdmodel/interactive/documentnavigation/outline/PDOutlineItem;"); + ((*jniEnv)->SetObjectField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_startBookmark, value)); +} + + +jfieldID _f_org_apache_pdfbox_text_PDFTextStripper_startBookmarkPageNumber = NULL; +int32_t get_org_apache_pdfbox_text_PDFTextStripper_startBookmarkPageNumber(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_startBookmarkPageNumber, "startBookmarkPageNumber","I"); + return ((*jniEnv)->GetIntField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_startBookmarkPageNumber)); +} + +void set_org_apache_pdfbox_text_PDFTextStripper_startBookmarkPageNumber(jobject self_, int32_t value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_startBookmarkPageNumber, "startBookmarkPageNumber","I"); + ((*jniEnv)->SetIntField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_startBookmarkPageNumber, value)); +} + + +jfieldID _f_org_apache_pdfbox_text_PDFTextStripper_endBookmarkPageNumber = NULL; +int32_t get_org_apache_pdfbox_text_PDFTextStripper_endBookmarkPageNumber(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_endBookmarkPageNumber, "endBookmarkPageNumber","I"); + return ((*jniEnv)->GetIntField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_endBookmarkPageNumber)); +} + +void set_org_apache_pdfbox_text_PDFTextStripper_endBookmarkPageNumber(jobject self_, int32_t value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_endBookmarkPageNumber, "endBookmarkPageNumber","I"); + ((*jniEnv)->SetIntField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_endBookmarkPageNumber, value)); +} + + +jfieldID _f_org_apache_pdfbox_text_PDFTextStripper_endBookmark = NULL; +jobject get_org_apache_pdfbox_text_PDFTextStripper_endBookmark(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_endBookmark, "endBookmark","Lorg/apache/pdfbox/pdmodel/interactive/documentnavigation/outline/PDOutlineItem;"); + return to_global_ref((*jniEnv)->GetObjectField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_endBookmark)); +} + +void set_org_apache_pdfbox_text_PDFTextStripper_endBookmark(jobject self_, jobject value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_endBookmark, "endBookmark","Lorg/apache/pdfbox/pdmodel/interactive/documentnavigation/outline/PDOutlineItem;"); + ((*jniEnv)->SetObjectField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_endBookmark, value)); +} + + +jfieldID _f_org_apache_pdfbox_text_PDFTextStripper_suppressDuplicateOverlappingText = NULL; +uint8_t get_org_apache_pdfbox_text_PDFTextStripper_suppressDuplicateOverlappingText(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_suppressDuplicateOverlappingText, "suppressDuplicateOverlappingText","Z"); + return ((*jniEnv)->GetBooleanField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_suppressDuplicateOverlappingText)); +} + +void set_org_apache_pdfbox_text_PDFTextStripper_suppressDuplicateOverlappingText(jobject self_, uint8_t value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_suppressDuplicateOverlappingText, "suppressDuplicateOverlappingText","Z"); + ((*jniEnv)->SetBooleanField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_suppressDuplicateOverlappingText, value)); +} + + +jfieldID _f_org_apache_pdfbox_text_PDFTextStripper_shouldSeparateByBeads = NULL; +uint8_t get_org_apache_pdfbox_text_PDFTextStripper_shouldSeparateByBeads(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_shouldSeparateByBeads, "shouldSeparateByBeads","Z"); + return ((*jniEnv)->GetBooleanField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_shouldSeparateByBeads)); +} + +void set_org_apache_pdfbox_text_PDFTextStripper_shouldSeparateByBeads(jobject self_, uint8_t value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_shouldSeparateByBeads, "shouldSeparateByBeads","Z"); + ((*jniEnv)->SetBooleanField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_shouldSeparateByBeads, value)); +} + + +jfieldID _f_org_apache_pdfbox_text_PDFTextStripper_sortByPosition = NULL; +uint8_t get_org_apache_pdfbox_text_PDFTextStripper_sortByPosition(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_sortByPosition, "sortByPosition","Z"); + return ((*jniEnv)->GetBooleanField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_sortByPosition)); +} + +void set_org_apache_pdfbox_text_PDFTextStripper_sortByPosition(jobject self_, uint8_t value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_sortByPosition, "sortByPosition","Z"); + ((*jniEnv)->SetBooleanField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_sortByPosition, value)); +} + + +jfieldID _f_org_apache_pdfbox_text_PDFTextStripper_addMoreFormatting = NULL; +uint8_t get_org_apache_pdfbox_text_PDFTextStripper_addMoreFormatting(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_addMoreFormatting, "addMoreFormatting","Z"); + return ((*jniEnv)->GetBooleanField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_addMoreFormatting)); +} + +void set_org_apache_pdfbox_text_PDFTextStripper_addMoreFormatting(jobject self_, uint8_t value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_addMoreFormatting, "addMoreFormatting","Z"); + ((*jniEnv)->SetBooleanField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_addMoreFormatting, value)); +} + + +jfieldID _f_org_apache_pdfbox_text_PDFTextStripper_indentThreshold = NULL; +float get_org_apache_pdfbox_text_PDFTextStripper_indentThreshold(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_indentThreshold, "indentThreshold","F"); + return ((*jniEnv)->GetFloatField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_indentThreshold)); +} + +void set_org_apache_pdfbox_text_PDFTextStripper_indentThreshold(jobject self_, float value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_indentThreshold, "indentThreshold","F"); + ((*jniEnv)->SetFloatField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_indentThreshold, value)); +} + + +jfieldID _f_org_apache_pdfbox_text_PDFTextStripper_dropThreshold = NULL; +float get_org_apache_pdfbox_text_PDFTextStripper_dropThreshold(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_dropThreshold, "dropThreshold","F"); + return ((*jniEnv)->GetFloatField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_dropThreshold)); +} + +void set_org_apache_pdfbox_text_PDFTextStripper_dropThreshold(jobject self_, float value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_dropThreshold, "dropThreshold","F"); + ((*jniEnv)->SetFloatField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_dropThreshold, value)); +} + + +jfieldID _f_org_apache_pdfbox_text_PDFTextStripper_spacingTolerance = NULL; +float get_org_apache_pdfbox_text_PDFTextStripper_spacingTolerance(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_spacingTolerance, "spacingTolerance","F"); + return ((*jniEnv)->GetFloatField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_spacingTolerance)); +} + +void set_org_apache_pdfbox_text_PDFTextStripper_spacingTolerance(jobject self_, float value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_spacingTolerance, "spacingTolerance","F"); + ((*jniEnv)->SetFloatField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_spacingTolerance, value)); +} + + +jfieldID _f_org_apache_pdfbox_text_PDFTextStripper_averageCharTolerance = NULL; +float get_org_apache_pdfbox_text_PDFTextStripper_averageCharTolerance(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_averageCharTolerance, "averageCharTolerance","F"); + return ((*jniEnv)->GetFloatField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_averageCharTolerance)); +} + +void set_org_apache_pdfbox_text_PDFTextStripper_averageCharTolerance(jobject self_, float value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_averageCharTolerance, "averageCharTolerance","F"); + ((*jniEnv)->SetFloatField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_averageCharTolerance, value)); +} + + +jfieldID _f_org_apache_pdfbox_text_PDFTextStripper_beadRectangles = NULL; +jobject get_org_apache_pdfbox_text_PDFTextStripper_beadRectangles(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_beadRectangles, "beadRectangles","Ljava/util/List;"); + return to_global_ref((*jniEnv)->GetObjectField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_beadRectangles)); +} + +void set_org_apache_pdfbox_text_PDFTextStripper_beadRectangles(jobject self_, jobject value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_beadRectangles, "beadRectangles","Ljava/util/List;"); + ((*jniEnv)->SetObjectField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_beadRectangles, value)); +} + + +jfieldID _f_org_apache_pdfbox_text_PDFTextStripper_charactersByArticle = NULL; +jobject get_org_apache_pdfbox_text_PDFTextStripper_charactersByArticle(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_charactersByArticle, "charactersByArticle","Ljava/util/ArrayList;"); + return to_global_ref((*jniEnv)->GetObjectField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_charactersByArticle)); +} + +void set_org_apache_pdfbox_text_PDFTextStripper_charactersByArticle(jobject self_, jobject value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_charactersByArticle, "charactersByArticle","Ljava/util/ArrayList;"); + ((*jniEnv)->SetObjectField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_charactersByArticle, value)); +} + + +jfieldID _f_org_apache_pdfbox_text_PDFTextStripper_characterListMapping = NULL; +jobject get_org_apache_pdfbox_text_PDFTextStripper_characterListMapping(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_characterListMapping, "characterListMapping","Ljava/util/Map;"); + return to_global_ref((*jniEnv)->GetObjectField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_characterListMapping)); +} + +void set_org_apache_pdfbox_text_PDFTextStripper_characterListMapping(jobject self_, jobject value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_characterListMapping, "characterListMapping","Ljava/util/Map;"); + ((*jniEnv)->SetObjectField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_characterListMapping, value)); +} + + +jfieldID _f_org_apache_pdfbox_text_PDFTextStripper_document = NULL; +jobject get_org_apache_pdfbox_text_PDFTextStripper_document(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_document, "document","Lorg/apache/pdfbox/pdmodel/PDDocument;"); + return to_global_ref((*jniEnv)->GetObjectField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_document)); +} + +void set_org_apache_pdfbox_text_PDFTextStripper_document(jobject self_, jobject value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_document, "document","Lorg/apache/pdfbox/pdmodel/PDDocument;"); + ((*jniEnv)->SetObjectField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_document, value)); +} + + +jfieldID _f_org_apache_pdfbox_text_PDFTextStripper_output = NULL; +jobject get_org_apache_pdfbox_text_PDFTextStripper_output(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_output, "output","Ljava/io/Writer;"); + return to_global_ref((*jniEnv)->GetObjectField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_output)); +} + +void set_org_apache_pdfbox_text_PDFTextStripper_output(jobject self_, jobject value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_output, "output","Ljava/io/Writer;"); + ((*jniEnv)->SetObjectField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_output, value)); +} + + +jfieldID _f_org_apache_pdfbox_text_PDFTextStripper_inParagraph = NULL; +uint8_t get_org_apache_pdfbox_text_PDFTextStripper_inParagraph(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_inParagraph, "inParagraph","Z"); + return ((*jniEnv)->GetBooleanField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_inParagraph)); +} + +void set_org_apache_pdfbox_text_PDFTextStripper_inParagraph(jobject self_, uint8_t value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_inParagraph, "inParagraph","Z"); + ((*jniEnv)->SetBooleanField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_inParagraph, value)); +} + + +jfieldID _f_org_apache_pdfbox_text_PDFTextStripper_LIST_ITEM_EXPRESSIONS = NULL; +jobject get_org_apache_pdfbox_text_PDFTextStripper_LIST_ITEM_EXPRESSIONS() { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_static_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_LIST_ITEM_EXPRESSIONS, "LIST_ITEM_EXPRESSIONS","L[java/lang/String;"); + return to_global_ref((*jniEnv)->GetStaticObjectField(jniEnv, _c_org_apache_pdfbox_text_PDFTextStripper, _f_org_apache_pdfbox_text_PDFTextStripper_LIST_ITEM_EXPRESSIONS)); +} + + +jfieldID _f_org_apache_pdfbox_text_PDFTextStripper_listOfPatterns = NULL; +jobject get_org_apache_pdfbox_text_PDFTextStripper_listOfPatterns(jobject self_) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_listOfPatterns, "listOfPatterns","Ljava/util/List;"); + return to_global_ref((*jniEnv)->GetObjectField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_listOfPatterns)); +} + +void set_org_apache_pdfbox_text_PDFTextStripper_listOfPatterns(jobject self_, jobject value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_listOfPatterns, "listOfPatterns","Ljava/util/List;"); + ((*jniEnv)->SetObjectField(jniEnv, self_, _f_org_apache_pdfbox_text_PDFTextStripper_listOfPatterns, value)); +} + + +jfieldID _f_org_apache_pdfbox_text_PDFTextStripper_MIRRORING_CHAR_MAP = NULL; +jobject get_org_apache_pdfbox_text_PDFTextStripper_MIRRORING_CHAR_MAP() { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_static_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_MIRRORING_CHAR_MAP, "MIRRORING_CHAR_MAP","Ljava/util/Map;"); + return to_global_ref((*jniEnv)->GetStaticObjectField(jniEnv, _c_org_apache_pdfbox_text_PDFTextStripper, _f_org_apache_pdfbox_text_PDFTextStripper_MIRRORING_CHAR_MAP)); +} + +void set_org_apache_pdfbox_text_PDFTextStripper_MIRRORING_CHAR_MAP(jobject value) { + load_env(); + load_class_gr(&_c_org_apache_pdfbox_text_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_static_field(_c_org_apache_pdfbox_text_PDFTextStripper, &_f_org_apache_pdfbox_text_PDFTextStripper_MIRRORING_CHAR_MAP, "MIRRORING_CHAR_MAP","Ljava/util/Map;"); + ((*jniEnv)->SetStaticObjectField(jniEnv, _c_org_apache_pdfbox_text_PDFTextStripper, _f_org_apache_pdfbox_text_PDFTextStripper_MIRRORING_CHAR_MAP, value)); +} + + diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/tool/generate_bindings.dart b/pkgs/jni_gen/examples/pdfbox_plugin/tool/generate_bindings.dart new file mode 100644 index 000000000..b7ea48ee6 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/tool/generate_bindings.dart @@ -0,0 +1,38 @@ +import 'package:jni_gen/jni_gen.dart'; + +const preamble = ''' +// Generated from Apache PDFBox library which is licensed under the Apache License 2.0. +// The following copyright from the original authors applies. +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +'''; + +void main(List arguments) async { + final config = Config( + mavenDownloads: MavenDownloads( + sourceDeps: ['org.apache.pdfbox:pdfbox:2.0.26'], + jarOnlyDeps: [ + 'org.bouncycastle:bcmail-jdk15on:1.70', + 'org.bouncycastle:bcprov-jdk15on:1.70', + ], + ), + classes: ['org.apache.pdfbox.pdmodel', 'org.apache.pdfbox.text'], + cRoot: Uri.directory('src/'), + dartRoot: Uri.directory('lib/'), + libraryName: 'pdfbox_plugin', + ); + await generateJniBindings(config); +} diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/windows/.gitignore b/pkgs/jni_gen/examples/pdfbox_plugin/windows/.gitignore new file mode 100644 index 000000000..b3eb2be16 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/windows/.gitignore @@ -0,0 +1,17 @@ +flutter/ + +# Visual Studio user-specific files. +*.suo +*.user +*.userosscache +*.sln.docstates + +# Visual Studio build-related files. +x64/ +x86/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/windows/CMakeLists.txt b/pkgs/jni_gen/examples/pdfbox_plugin/windows/CMakeLists.txt new file mode 100644 index 000000000..3d9bd5c70 --- /dev/null +++ b/pkgs/jni_gen/examples/pdfbox_plugin/windows/CMakeLists.txt @@ -0,0 +1,23 @@ +# The Flutter tooling requires that developers have a version of Visual Studio +# installed that includes CMake 3.14 or later. You should not increase this +# version, as doing so will cause the plugin to fail to compile for some +# customers of the plugin. +cmake_minimum_required(VERSION 3.14) + +# Project-level configuration. +set(PROJECT_NAME "pdfbox_plugin") +project(${PROJECT_NAME} LANGUAGES CXX) + +# Invoke the build for native code shared with the other target platforms. +# This can be changed to accomodate different builds. +add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../src" "${CMAKE_CURRENT_BINARY_DIR}/shared") + +# List of absolute paths to libraries that should be bundled with the plugin. +# This list could contain prebuilt libraries, or libraries created by an +# external build triggered from this build file. +set(pdfbox_plugin_bundled_libraries + # Defined in ../src/CMakeLists.txt. + # This can be changed to accomodate different builds. + $ + PARENT_SCOPE +) diff --git a/pkgs/jni_gen/lib/src/bindings/dart_bindings.dart b/pkgs/jni_gen/lib/src/bindings/dart_bindings.dart index 7a27303a9..3ca73539e 100644 --- a/pkgs/jni_gen/lib/src/bindings/dart_bindings.dart +++ b/pkgs/jni_gen/lib/src/bindings/dart_bindings.dart @@ -159,7 +159,7 @@ class DartBindingsGenerator { final name = f.finalName; final s = StringBuffer(); - void _writeDocs({bool writeDeleteInstruction = true}) { + void writeDocs({bool writeDeleteInstruction = true}) { s.write('$_indent/// from: ${_originalFieldDecl(f)}\n'); if (!isPrimitive(f.type) && writeDeleteInstruction) { s.write(_deleteInstruction); @@ -168,7 +168,7 @@ class DartBindingsGenerator { } if (isStaticField(f) && isFinalField(f) && f.defaultValue != null) { - _writeDocs(writeDeleteInstruction: false); + writeDocs(writeDeleteInstruction: false); s.write('${_indent}static const $name = ${_literal(f.defaultValue)};\n'); return s.toString(); } @@ -183,7 +183,7 @@ class DartBindingsGenerator { '<${ffi}NativeFunction<$ffiSig>>("${symPrefix}_$cName")\n' '.asFunction<$dartSig>();\n'); // write original type - _writeDocs(); + writeDocs(); s.write(_indent); if (isStaticField(f)) s.write('static '); if (isSetter) { diff --git a/pkgs/jni_gen/lib/src/bindings/symbol_resolver.dart b/pkgs/jni_gen/lib/src/bindings/symbol_resolver.dart index 43b928f14..0ccdc86ef 100644 --- a/pkgs/jni_gen/lib/src/bindings/symbol_resolver.dart +++ b/pkgs/jni_gen/lib/src/bindings/symbol_resolver.dart @@ -15,19 +15,20 @@ abstract class SymbolResolver { } class PackagePathResolver implements SymbolResolver { - PackagePathResolver(this.packages, this.currentPackage, this.inputClassNames, + PackagePathResolver(this.importMap, this.currentPackage, this.inputClassNames, {this.predefined = const {}}); final String currentPackage; - final Map packages; + final Map importMap; final Map predefined; final Set inputClassNames; final List importStrings = []; + final Set relativeImportedPackages = {}; + final Map _importedNameToPackage = {}; final Map _packageToImportedName = {}; - // return null if type's package cannot be resolved // else return the fully qualified name of type @override @@ -46,8 +47,13 @@ class PackagePathResolver implements SymbolResolver { if (_packageToImportedName.containsKey(package)) { // This package was already resolved - final importedName = _packageToImportedName[package]; - return '$importedName.$simpleTypeName'; + // but we still need to check if it was a relative import, in which case + // the class not in inputClassNames cannot be mapped here. + if (!relativeImportedPackages.contains(package) || + inputClassNames.contains(binaryName)) { + final importedName = _packageToImportedName[package]; + return '$importedName.$simpleTypeName'; + } } final packageImport = getImport(package, binaryName); @@ -102,6 +108,7 @@ class PackagePathResolver implements SymbolResolver { pathToCommon = '../' * (src.length - common); } final pathToPackage = dest.skip(max(common - 1, 0)).join('/'); + relativeImportedPackages.add(packageToResolve); return '$pathToCommon$pathToPackage.dart'; } @@ -110,9 +117,9 @@ class PackagePathResolver implements SymbolResolver { final left = split[0]; right.add(split[1]); // eg: packages[org.apache.pdfbox]/org/apache/pdfbox.dart - if (packages.containsKey(prefix)) { + if (importMap.containsKey(prefix)) { final sub = packageToResolve.replaceAll('.', '/'); - final pkg = _suffix(packages[prefix]!, '/'); + final pkg = _suffix(importMap[prefix]!, '/'); return '$pkg$sub.dart'; } prefix = left; diff --git a/pkgs/jni_gen/lib/src/config/config.dart b/pkgs/jni_gen/lib/src/config/config.dart index a0272f31a..278e1bd6c 100644 --- a/pkgs/jni_gen/lib/src/config/config.dart +++ b/pkgs/jni_gen/lib/src/config/config.dart @@ -41,18 +41,35 @@ class MavenDownloads { /// The SDK directories for platform stub JARs and sources are searched in the /// same order in which [versions] are specified. /// -/// If [sdkRoot] is not provided, an attempt is made to discover it -/// using the environment variable `ANDROID_SDK_ROOT`, which will fail if the -/// environment variable is not set. -/// /// If [includeSources] is true, `jni_gen` searches for Android SDK sources /// as well in the SDK directory and adds them to the source path. +/// +/// If [addGradleDeps] is true, a gradle stub is run in order to collect the +/// actual compile classpath of the `android/` subproject. +/// This will fail if there was no previous build of the project, or if a +/// `clean` task was run either through flutter or gradle wrapper. In such case, +/// it's required to run `flutter build apk` & retry running `jni_gen`. +/// +/// A configuration is invalid if [versions] is unspecified or empty, and +/// [addGradleDeps] is also false. If [sdkRoot] is not specified but versions is +/// specified, an attempt is made to find out SDK installation directory using +/// environment variable `ANDROID_SDK_ROOT` if it's defined, else an error +/// will be thrown. class AndroidSdkConfig { AndroidSdkConfig( - {required this.versions, this.sdkRoot, this.includeSources = false}); - List versions; + {this.versions, + this.sdkRoot, + this.includeSources = false, + this.addGradleDeps = false}) { + if (versions == null && !addGradleDeps) { + throw ArgumentError('Neither any SDK versions nor `addGradleDeps` ' + 'is specified. Unable to find Android libraries.'); + } + } + List? versions; String? sdkRoot; bool includeSources; + bool addGradleDeps; } /// Additional options to pass to the summary generator component. @@ -87,6 +104,7 @@ class Config { required this.libraryName, required this.cRoot, required this.dartRoot, + this.cSubdir, this.exclude, this.sourcePath, this.classPath, @@ -113,11 +131,19 @@ class Config { String libraryName; /// Directory to write JNI C Bindings. + /// + /// Strictly speaking, this is the root to place the `CMakeLists.txt` file + /// for the generated C bindings. It may be desirable to use the [cSubdir] + /// options to write C files to a subdirectory of [cRoot]. For instance, + /// when generated code is required to be in `third_party` directory. Uri cRoot; /// Directory to write Dart bindings. Uri dartRoot; + /// Subdirectory relative to [cRoot] to write generated C code. + String? cSubdir; + /// Methods and fields to be excluded from generated bindings. BindingExclusions? exclude; @@ -159,7 +185,6 @@ class Config { static Config parseArgs(List args) { final prov = YamlReader.parseArgs(args); - final List missingValues = []; T must(T? Function(String) f, T ifNull, String property) { final res = f(property); @@ -214,6 +239,7 @@ class Config { ), cRoot: Uri.directory(must(prov.getString, '', _Props.cRoot)), dartRoot: Uri.directory(must(prov.getString, '', _Props.dartRoot)), + cSubdir: prov.getString(_Props.cSubdir), preamble: prov.getString(_Props.preamble), libraryName: must(prov.getString, '', _Props.libraryName), importMap: prov.getStringMap(_Props.importMap), @@ -229,13 +255,14 @@ class Config { : null, androidSdkConfig: prov.hasValue(_Props.androidSdkConfig) ? AndroidSdkConfig( - versions: must>( - prov.getStringList, [], _Props.androidSdkVersions) - .map(int.parse) + versions: prov + .getStringList(_Props.androidSdkVersions) + ?.map(int.parse) .toList(), sdkRoot: getSdkRoot(), includeSources: prov.getBool(_Props.includeAndroidSources) ?? false, + addGradleDeps: prov.getBool(_Props.addGradleDeps) ?? false, ) : null, ); @@ -272,6 +299,7 @@ class _Props { static const importMap = 'import_map'; static const cRoot = 'c_root'; + static const cSubdir = 'c_subdir'; static const dartRoot = 'dart_root'; static const preamble = 'preamble'; static const libraryName = 'library_name'; @@ -286,4 +314,5 @@ class _Props { static const androidSdkRoot = '$androidSdkConfig.sdk_root'; static const androidSdkVersions = '$androidSdkConfig.versions'; static const includeAndroidSources = '$androidSdkConfig.include_sources'; + static const addGradleDeps = '$androidSdkConfig.add_gradle_deps'; } diff --git a/pkgs/jni_gen/lib/src/config/yaml_reader.dart b/pkgs/jni_gen/lib/src/config/yaml_reader.dart index 3d12dae32..6765d9d61 100644 --- a/pkgs/jni_gen/lib/src/config/yaml_reader.dart +++ b/pkgs/jni_gen/lib/src/config/yaml_reader.dart @@ -89,7 +89,7 @@ class YamlReader { } throw ConfigError('expected boolean value for $property, got $v'); } - return null; + return getYamlValue(property); } String? getString(String property) { diff --git a/pkgs/jni_gen/lib/src/generate_bindings.dart b/pkgs/jni_gen/lib/src/generate_bindings.dart index b939f9c49..09f948fa6 100644 --- a/pkgs/jni_gen/lib/src/generate_bindings.dart +++ b/pkgs/jni_gen/lib/src/generate_bindings.dart @@ -44,15 +44,20 @@ Future generateJniBindings(Config config) async { } final androidConfig = config.androidSdkConfig; - if (androidConfig != null) { + if (androidConfig != null && androidConfig.addGradleDeps) { + final deps = AndroidSdkTools.getGradleClasspaths(); + extraJars.addAll(deps.map(Uri.file)); + } + if (androidConfig != null && androidConfig.versions != null) { + final versions = androidConfig.versions!; final androidJar = await AndroidSdkTools.getAndroidJarPath( - sdkRoot: androidConfig.sdkRoot, versionOrder: androidConfig.versions); + sdkRoot: androidConfig.sdkRoot, versionOrder: versions); if (androidJar != null) { extraJars.add(Uri.directory(androidJar)); } if (androidConfig.includeSources) { final androidSources = await AndroidSdkTools.getAndroidSourcesPath( - sdkRoot: androidConfig.sdkRoot, versionOrder: androidConfig.versions); + sdkRoot: androidConfig.sdkRoot, versionOrder: versions); if (androidSources != null) { extraSources.add(Uri.directory(androidSources)); } diff --git a/pkgs/jni_gen/lib/src/tools/android_sdk_tools.dart b/pkgs/jni_gen/lib/src/tools/android_sdk_tools.dart index e1092b2c0..029555ae5 100644 --- a/pkgs/jni_gen/lib/src/tools/android_sdk_tools.dart +++ b/pkgs/jni_gen/lib/src/tools/android_sdk_tools.dart @@ -42,4 +42,51 @@ class AndroidSdkTools { static Future getAndroidJarPath( {String? sdkRoot, required List versionOrder}) async => await _getFile('platforms', 'android.jar', sdkRoot, versionOrder); + + static const _gradleListDepsFunction = ''' +task listDependencies(type: Copy) { + project.afterEvaluate { + def app = project(':app') + def android = app.android + def cp = [android.getBootClasspath()[0]] + android.applicationVariants.each { variant -> + if (variant.name.equals('release')) { + cp += variant.javaCompile.classpath.getFiles() + } + } + cp.each { println it } + } +} +'''; + + /// Get release compile classpath used by Gradle for android build. + /// + /// This function temporarily overwrites the build.gradle file by a stub with + /// function to list all dependency paths for release variant. + /// This function fails if no gradle build is attempted + static List getGradleClasspaths() { + stderr.writeln('trying to obtain gradle classpaths'); + const android = 'android'; + final buildGradle = join(android, 'build.gradle'); + final buildGradleOld = join(android, 'build.gradle.old'); + final origBuild = File(buildGradle); + final script = origBuild.readAsStringSync(); + origBuild.renameSync(buildGradleOld); + origBuild.createSync(); + origBuild.writeAsStringSync('$script\n$_gradleListDepsFunction\n'); + final procRes = Process.runSync('./gradlew', ['-q', 'listDependencies'], + workingDirectory: android); + origBuild.writeAsStringSync(script); + File(buildGradleOld).deleteSync(); + if (procRes.exitCode != 0) { + throw Exception('\n\ngradle exited with exit code ${procRes.exitCode}\n' + 'This can be related to a known issue with gradle. ' + 'Please run `flutter build apk` and try again\n'); + } + final gradleClassPaths = (procRes.stdout as String).split('\n'); + if (gradleClassPaths.last.isEmpty) { + gradleClassPaths.removeLast(); + } + return gradleClassPaths; + } } diff --git a/pkgs/jni_gen/lib/src/writers/writers.dart b/pkgs/jni_gen/lib/src/writers/writers.dart index 38b202e47..6febf91ff 100644 --- a/pkgs/jni_gen/lib/src/writers/writers.dart +++ b/pkgs/jni_gen/lib/src/writers/writers.dart @@ -63,8 +63,9 @@ class FilesWriter extends BindingsWriter { final initFile = await File.fromUri(initFileUri).create(recursive: true); await initFile.writeAsString(DartPreludes.initFile(config.libraryName), flush: true); - - final cFile = await File.fromUri(cRoot.resolve('$libraryName.c')) + final subdir = config.cSubdir ?? '.'; + final cFileRelativePath = '$subdir/$libraryName.c'; + final cFile = await File.fromUri(cRoot.resolve(cFileRelativePath)) .create(recursive: true); final cFileStream = cFile.openWrite(); if (preamble != null) { @@ -116,10 +117,14 @@ class FilesWriter extends BindingsWriter { stderr.writeln('Copying auxiliary files...'); await _copyFileFromPackage( - 'jni', 'src/dartjni.h', cRoot.resolve('dartjni.h')); + 'jni', 'src/dartjni.h', cRoot.resolve('$subdir/dartjni.h')); await _copyFileFromPackage( 'jni_gen', 'cmake/CMakeLists.txt.tmpl', cRoot.resolve('CMakeLists.txt'), - transform: (s) => s.replaceAll('{{LIBRARY_NAME}}', libraryName)); + transform: (s) { + return s + .replaceAll('{{LIBRARY_NAME}}', libraryName) + .replaceAll('{{SUBDIR}}', subdir); + }); stderr.writeln('Completed.'); } diff --git a/pkgs/jni_gen/test/bindings_test.dart b/pkgs/jni_gen/test/bindings_test.dart index fd8a1967b..51b92eb5d 100644 --- a/pkgs/jni_gen/test/bindings_test.dart +++ b/pkgs/jni_gen/test/bindings_test.dart @@ -35,6 +35,12 @@ Future setupDylibsAndClasses() async { await runCmd('javac', ['dev/dart/simple_package/Example.java', 'dev/dart/pkg2/C2.java'], workingDirectory: simplePackageJavaPath); + await runCmd('dart', [ + 'run', + 'jni_gen:download_maven_jars', + '--config', + join(jacksonCorePath, 'jnigen.yaml') + ]); final jacksonJars = await getJarPaths(join(jacksonCorePath, 'third_party')); diff --git a/pkgs/jni_gen/test/jackson_core_test/third_party/src/CMakeLists.txt b/pkgs/jni_gen/test/jackson_core_test/third_party/src/CMakeLists.txt index 657e00105..475daed4f 100644 --- a/pkgs/jni_gen/test/jackson_core_test/third_party/src/CMakeLists.txt +++ b/pkgs/jni_gen/test/jackson_core_test/third_party/src/CMakeLists.txt @@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.10) project(jackson_core_test VERSION 0.0.1 LANGUAGES C) add_library(jackson_core_test SHARED - "jackson_core_test.c" + "./jackson_core_test.c" ) set_target_properties(jackson_core_test PROPERTIES diff --git a/pkgs/jni_gen/test/simple_package_test/src/CMakeLists.txt b/pkgs/jni_gen/test/simple_package_test/src/CMakeLists.txt index ef0660ba7..a029be98f 100644 --- a/pkgs/jni_gen/test/simple_package_test/src/CMakeLists.txt +++ b/pkgs/jni_gen/test/simple_package_test/src/CMakeLists.txt @@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.10) project(simple_package VERSION 0.0.1 LANGUAGES C) add_library(simple_package SHARED - "simple_package.c" + "./simple_package.c" ) set_target_properties(simple_package PROPERTIES From 41e7871e5c35774c21f0e4ca2908c41611026fc7 Mon Sep 17 00:00:00 2001 From: Mahesh Hegde <46179734+mahesh-hegde@users.noreply.github.com> Date: Mon, 5 Sep 2022 14:43:25 +0530 Subject: [PATCH 012/139] [jnigen] Android plugin example (https://github.com/dart-lang/jnigen/issues/46) --- .github/workflows/test-package.yml | 27 +++ .../in_app_java/android/app/build.gradle | 2 +- .../com/example/in_app_java/AndroidUtils.java | 4 + .../examples/in_app_java/lib/main.dart | 4 + .../in_app_java/test/widget_test.dart | 30 --- .../in_app_java/tool/generate_bindings.dart | 6 +- .../examples/notification_plugin/.gitignore | 30 +++ .../examples/notification_plugin/.metadata | 30 +++ .../examples/notification_plugin/README.md | 13 ++ .../notification_plugin/analysis_options.yaml | 4 + .../notification_plugin/android/.gitignore | 9 + .../notification_plugin/android/build.gradle | 59 ++++++ .../android/settings.gradle | 1 + .../android/src/main/AndroidManifest.xml | 3 + .../notification_plugin/Notifications.java | 36 ++++ .../notification_plugin/example/.gitignore | 44 +++++ .../notification_plugin/example/README.md | 4 + .../example/analysis_options.yaml | 29 +++ .../example/android/.gitignore | 13 ++ .../example/android/app/build.gradle | 71 +++++++ .../android/app/src/debug/AndroidManifest.xml | 8 + .../android/app/src/main/AndroidManifest.xml | 34 ++++ .../MainActivity.kt | 6 + .../res/drawable-v21/launch_background.xml | 12 ++ .../main/res/drawable/launch_background.xml | 12 ++ .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 544 bytes .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 442 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 721 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 1031 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 1443 bytes .../app/src/main/res/values-night/styles.xml | 18 ++ .../app/src/main/res/values/styles.xml | 18 ++ .../app/src/profile/AndroidManifest.xml | 8 + .../example/android/build.gradle | 31 +++ .../example/android/gradle.properties | 3 + .../gradle/wrapper/gradle-wrapper.properties | 5 + .../example/android/settings.gradle | 11 ++ .../notification_plugin/example/lib/main.dart | 89 +++++++++ .../notification_plugin/example/pubspec.yaml | 89 +++++++++ .../examples/notification_plugin/jnigen.yaml | 17 ++ .../lib/com/example/notification_plugin.dart | 46 +++++ .../notification_plugin/lib/init.dart | 5 + .../examples/notification_plugin/pubspec.yaml | 76 ++++++++ .../notification_plugin/src/CMakeLists.txt | 30 +++ .../notification_plugin/src/dartjni.h | 177 ++++++++++++++++++ .../src/notification_plugin.c | 44 +++++ .../dart_example/bin/pdf_info.dart | 4 + .../pdfbox_plugin/example/lib/main.dart | 4 + .../pdfbox_plugin/tool/generate_bindings.dart | 8 +- pkgs/jni_gen/lib/src/config/config.dart | 41 +++- pkgs/jni_gen/lib/src/generate_bindings.dart | 3 +- .../lib/src/tools/android_sdk_tools.dart | 15 +- 52 files changed, 1188 insertions(+), 45 deletions(-) delete mode 100644 pkgs/jni_gen/examples/in_app_java/test/widget_test.dart create mode 100644 pkgs/jni_gen/examples/notification_plugin/.gitignore create mode 100644 pkgs/jni_gen/examples/notification_plugin/.metadata create mode 100644 pkgs/jni_gen/examples/notification_plugin/README.md create mode 100644 pkgs/jni_gen/examples/notification_plugin/analysis_options.yaml create mode 100644 pkgs/jni_gen/examples/notification_plugin/android/.gitignore create mode 100644 pkgs/jni_gen/examples/notification_plugin/android/build.gradle create mode 100644 pkgs/jni_gen/examples/notification_plugin/android/settings.gradle create mode 100644 pkgs/jni_gen/examples/notification_plugin/android/src/main/AndroidManifest.xml create mode 100644 pkgs/jni_gen/examples/notification_plugin/android/src/main/java/com/example/notification_plugin/Notifications.java create mode 100644 pkgs/jni_gen/examples/notification_plugin/example/.gitignore create mode 100644 pkgs/jni_gen/examples/notification_plugin/example/README.md create mode 100644 pkgs/jni_gen/examples/notification_plugin/example/analysis_options.yaml create mode 100644 pkgs/jni_gen/examples/notification_plugin/example/android/.gitignore create mode 100644 pkgs/jni_gen/examples/notification_plugin/example/android/app/build.gradle create mode 100644 pkgs/jni_gen/examples/notification_plugin/example/android/app/src/debug/AndroidManifest.xml create mode 100644 pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/AndroidManifest.xml create mode 100644 pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/kotlin/com/example/notification_plugin_example/MainActivity.kt create mode 100644 pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/drawable-v21/launch_background.xml create mode 100644 pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/drawable/launch_background.xml create mode 100644 pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/values-night/styles.xml create mode 100644 pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/values/styles.xml create mode 100644 pkgs/jni_gen/examples/notification_plugin/example/android/app/src/profile/AndroidManifest.xml create mode 100644 pkgs/jni_gen/examples/notification_plugin/example/android/build.gradle create mode 100644 pkgs/jni_gen/examples/notification_plugin/example/android/gradle.properties create mode 100644 pkgs/jni_gen/examples/notification_plugin/example/android/gradle/wrapper/gradle-wrapper.properties create mode 100644 pkgs/jni_gen/examples/notification_plugin/example/android/settings.gradle create mode 100644 pkgs/jni_gen/examples/notification_plugin/example/lib/main.dart create mode 100644 pkgs/jni_gen/examples/notification_plugin/example/pubspec.yaml create mode 100644 pkgs/jni_gen/examples/notification_plugin/jnigen.yaml create mode 100644 pkgs/jni_gen/examples/notification_plugin/lib/com/example/notification_plugin.dart create mode 100644 pkgs/jni_gen/examples/notification_plugin/lib/init.dart create mode 100644 pkgs/jni_gen/examples/notification_plugin/pubspec.yaml create mode 100644 pkgs/jni_gen/examples/notification_plugin/src/CMakeLists.txt create mode 100644 pkgs/jni_gen/examples/notification_plugin/src/dartjni.h create mode 100644 pkgs/jni_gen/examples/notification_plugin/src/notification_plugin.c diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 0b4123f5f..9bae1257f 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -212,6 +212,33 @@ jobs: - run: flutter pub get - run: flutter build apk + build_notification_plugin_example: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./pkgs/jni_gen/examples/notification_plugin + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v2 + with: + distribution: 'zulu' + java-version: '11' + - uses: subosito/flutter-action@v2 + with: + channel: 'stable' + cache: true + cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' + - run: flutter pub get + - run: flutter analyze + - run: flutter build apk + working-directory: ./pkgs/jni_gen/examples/notification_plugin/example + - name: re-generate bindings + run: flutter pub run jni_gen -Ddart_root=_dart -Dc_root=_c --config jnigen.yaml + - name: compare generated dart bindings + run: diff -qr lib/ _dart + - name: compare generated C bindings + run: diff -qr src/ _c + build_in_app_java_example: runs-on: ubuntu-latest defaults: diff --git a/pkgs/jni_gen/examples/in_app_java/android/app/build.gradle b/pkgs/jni_gen/examples/in_app_java/android/app/build.gradle index 784c65997..bd2878982 100644 --- a/pkgs/jni_gen/examples/in_app_java/android/app/build.gradle +++ b/pkgs/jni_gen/examples/in_app_java/android/app/build.gradle @@ -61,7 +61,7 @@ android { } } -externalNativeBuild { + externalNativeBuild { cmake { path "../../src/android_utils/CMakeLists.txt" } diff --git a/pkgs/jni_gen/examples/in_app_java/android/app/src/main/java/com/example/in_app_java/AndroidUtils.java b/pkgs/jni_gen/examples/in_app_java/android/app/src/main/java/com/example/in_app_java/AndroidUtils.java index 4c297bf3a..a998516b4 100644 --- a/pkgs/jni_gen/examples/in_app_java/android/app/src/main/java/com/example/in_app_java/AndroidUtils.java +++ b/pkgs/jni_gen/examples/in_app_java/android/app/src/main/java/com/example/in_app_java/AndroidUtils.java @@ -1,3 +1,7 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + package com.example.in_app_java; import android.app.Activity; diff --git a/pkgs/jni_gen/examples/in_app_java/lib/main.dart b/pkgs/jni_gen/examples/in_app_java/lib/main.dart index b47cb3117..10081f5b5 100644 --- a/pkgs/jni_gen/examples/in_app_java/lib/main.dart +++ b/pkgs/jni_gen/examples/in_app_java/lib/main.dart @@ -1,3 +1,7 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + import 'package:flutter/material.dart'; import 'package:jni/jni.dart'; diff --git a/pkgs/jni_gen/examples/in_app_java/test/widget_test.dart b/pkgs/jni_gen/examples/in_app_java/test/widget_test.dart deleted file mode 100644 index 0c153ccbd..000000000 --- a/pkgs/jni_gen/examples/in_app_java/test/widget_test.dart +++ /dev/null @@ -1,30 +0,0 @@ -// This is a basic Flutter widget test. -// -// To perform an interaction with a widget in your test, use the WidgetTester -// utility in the flutter_test package. For example, you can send tap and scroll -// gestures. You can also use WidgetTester to find child widgets in the widget -// tree, read text, and verify that the values of widget properties are correct. - -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; - -import 'package:in_app_java/main.dart'; - -void main() { - testWidgets('Counter increments smoke test', (WidgetTester tester) async { - // Build our app and trigger a frame. - await tester.pumpWidget(const MyApp()); - - // Verify that our counter starts at 0. - expect(find.text('0'), findsOneWidget); - expect(find.text('1'), findsNothing); - - // Tap the '+' icon and trigger a frame. - await tester.tap(find.byIcon(Icons.add)); - await tester.pump(); - - // Verify that our counter has incremented. - expect(find.text('0'), findsNothing); - expect(find.text('1'), findsOneWidget); - }); -} diff --git a/pkgs/jni_gen/examples/in_app_java/tool/generate_bindings.dart b/pkgs/jni_gen/examples/in_app_java/tool/generate_bindings.dart index 2628d9901..cb2b53d9e 100644 --- a/pkgs/jni_gen/examples/in_app_java/tool/generate_bindings.dart +++ b/pkgs/jni_gen/examples/in_app_java/tool/generate_bindings.dart @@ -1,3 +1,7 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + import 'package:jni_gen/jni_gen.dart'; void main(List args) async { @@ -8,7 +12,7 @@ void main(List args) async { dartRoot: Uri.directory('lib/android_utils'), libraryName: 'android_utils', androidSdkConfig: AndroidSdkConfig( - versions: [31], + addGradleDeps: true, ), ); await generateJniBindings(config); diff --git a/pkgs/jni_gen/examples/notification_plugin/.gitignore b/pkgs/jni_gen/examples/notification_plugin/.gitignore new file mode 100644 index 000000000..96486fd93 --- /dev/null +++ b/pkgs/jni_gen/examples/notification_plugin/.gitignore @@ -0,0 +1,30 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +.packages +build/ diff --git a/pkgs/jni_gen/examples/notification_plugin/.metadata b/pkgs/jni_gen/examples/notification_plugin/.metadata new file mode 100644 index 000000000..d677252b9 --- /dev/null +++ b/pkgs/jni_gen/examples/notification_plugin/.metadata @@ -0,0 +1,30 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled. + +version: + revision: ffccd96b62ee8cec7740dab303538c5fc26ac543 + channel: stable + +project_type: plugin_ffi + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543 + base_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543 + - platform: android + create_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543 + base_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543 + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/pkgs/jni_gen/examples/notification_plugin/README.md b/pkgs/jni_gen/examples/notification_plugin/README.md new file mode 100644 index 000000000..1fcccdcbd --- /dev/null +++ b/pkgs/jni_gen/examples/notification_plugin/README.md @@ -0,0 +1,13 @@ +# notification_plugin + +Example of android plugin project with jni_gen. + +This plugin project contains [custom code](android/src/main/java/com/example/notification_plugin) which uses the Android libraries. The bindings are generated using [jnigen config](jnigen.yaml) and then used in [flutter example](example/lib/main.dart), with help of `package:jni` APIs. + +The command to regenerate JNI bindings is: +``` +flutter run jni_gen --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 jni_gen. This is the equivalent of Gradle Sync in Android Studio, and enables `jni_gen` 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/jni_gen/examples/notification_plugin/analysis_options.yaml b/pkgs/jni_gen/examples/notification_plugin/analysis_options.yaml new file mode 100644 index 000000000..a5744c1cf --- /dev/null +++ b/pkgs/jni_gen/examples/notification_plugin/analysis_options.yaml @@ -0,0 +1,4 @@ +include: package:flutter_lints/flutter.yaml + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/pkgs/jni_gen/examples/notification_plugin/android/.gitignore b/pkgs/jni_gen/examples/notification_plugin/android/.gitignore new file mode 100644 index 000000000..161bdcdaf --- /dev/null +++ b/pkgs/jni_gen/examples/notification_plugin/android/.gitignore @@ -0,0 +1,9 @@ +*.iml +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures +.cxx diff --git a/pkgs/jni_gen/examples/notification_plugin/android/build.gradle b/pkgs/jni_gen/examples/notification_plugin/android/build.gradle new file mode 100644 index 000000000..7643ec56e --- /dev/null +++ b/pkgs/jni_gen/examples/notification_plugin/android/build.gradle @@ -0,0 +1,59 @@ +// The Android Gradle Plugin builds the native code with the Android NDK. + +group 'com.example.notification_plugin' +version '1.0' + +buildscript { + repositories { + google() + mavenCentral() + } + + dependencies { + // The Android Gradle Plugin knows how to build native code with the NDK. + classpath 'com.android.tools.build:gradle:7.1.2' + } +} + +rootProject.allprojects { + repositories { + google() + mavenCentral() + } +} + +apply plugin: 'com.android.library' + +android { + // Bumping the plugin compileSdkVersion requires all clients of this plugin + // to bump the version in their app. + compileSdkVersion 31 + + // Bumping the plugin ndkVersion requires all clients of this plugin to bump + // the version in their app and to download a newer version of the NDK. + ndkVersion "21.1.6352462" + + // Invoke the shared CMake build with the Android Gradle Plugin. + externalNativeBuild { + cmake { + path "../src/CMakeLists.txt" + + // The default CMake version for the Android Gradle Plugin is 3.10.2. + // https://developer.android.com/studio/projects/install-ndk#vanilla_cmake + // + // The Flutter tooling requires that developers have CMake 3.10 or later + // installed. You should not increase this version, as doing so will cause + // the plugin to fail to compile for some customers of the plugin. + // version "3.10.2" + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + defaultConfig { + minSdkVersion 16 + } +} diff --git a/pkgs/jni_gen/examples/notification_plugin/android/settings.gradle b/pkgs/jni_gen/examples/notification_plugin/android/settings.gradle new file mode 100644 index 000000000..8e0a5b1a3 --- /dev/null +++ b/pkgs/jni_gen/examples/notification_plugin/android/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'notification_plugin' diff --git a/pkgs/jni_gen/examples/notification_plugin/android/src/main/AndroidManifest.xml b/pkgs/jni_gen/examples/notification_plugin/android/src/main/AndroidManifest.xml new file mode 100644 index 000000000..01cb16564 --- /dev/null +++ b/pkgs/jni_gen/examples/notification_plugin/android/src/main/AndroidManifest.xml @@ -0,0 +1,3 @@ + + diff --git a/pkgs/jni_gen/examples/notification_plugin/android/src/main/java/com/example/notification_plugin/Notifications.java b/pkgs/jni_gen/examples/notification_plugin/android/src/main/java/com/example/notification_plugin/Notifications.java new file mode 100644 index 000000000..59f8b7a74 --- /dev/null +++ b/pkgs/jni_gen/examples/notification_plugin/android/src/main/java/com/example/notification_plugin/Notifications.java @@ -0,0 +1,36 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +package com.example.notification_plugin; + +import android.app.NotificationChannel; +import android.app.NotificationManager; +import android.content.Context; +import android.os.Build; +import androidx.annotation.Keep; +import androidx.core.app.NotificationCompat; + +@Keep +public class Notifications { + public static void showNotification( + Context context, int notificationID, String title, String text) { + @SuppressWarnings("deprecation") + NotificationCompat.Builder builder = + new NotificationCompat.Builder(context) + .setSmallIcon(android.R.drawable.ic_dialog_info) + .setContentTitle(title) + .setContentText(text); + NotificationManager notificationManager = + (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O) { + String channelId = "my_channel"; + NotificationChannel channel = + new NotificationChannel( + channelId, "My App's notifications", NotificationManager.IMPORTANCE_HIGH); + notificationManager.createNotificationChannel(channel); + builder.setChannelId(channelId); + } + notificationManager.notify(notificationID, builder.build()); + } +} diff --git a/pkgs/jni_gen/examples/notification_plugin/example/.gitignore b/pkgs/jni_gen/examples/notification_plugin/example/.gitignore new file mode 100644 index 000000000..24476c5d1 --- /dev/null +++ b/pkgs/jni_gen/examples/notification_plugin/example/.gitignore @@ -0,0 +1,44 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ +/build/ + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/pkgs/jni_gen/examples/notification_plugin/example/README.md b/pkgs/jni_gen/examples/notification_plugin/example/README.md new file mode 100644 index 000000000..0ec9e1d6c --- /dev/null +++ b/pkgs/jni_gen/examples/notification_plugin/example/README.md @@ -0,0 +1,4 @@ +# notification_plugin_example + +This app demonstrates how to use the notification_plugin plugin. + diff --git a/pkgs/jni_gen/examples/notification_plugin/example/analysis_options.yaml b/pkgs/jni_gen/examples/notification_plugin/example/analysis_options.yaml new file mode 100644 index 000000000..61b6c4de1 --- /dev/null +++ b/pkgs/jni_gen/examples/notification_plugin/example/analysis_options.yaml @@ -0,0 +1,29 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at + # https://dart-lang.github.io/linter/lints/index.html. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/.gitignore b/pkgs/jni_gen/examples/notification_plugin/example/android/.gitignore new file mode 100644 index 000000000..6f568019d --- /dev/null +++ b/pkgs/jni_gen/examples/notification_plugin/example/android/.gitignore @@ -0,0 +1,13 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +key.properties +**/*.keystore +**/*.jks diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/app/build.gradle b/pkgs/jni_gen/examples/notification_plugin/example/android/app/build.gradle new file mode 100644 index 000000000..ee3c62fa0 --- /dev/null +++ b/pkgs/jni_gen/examples/notification_plugin/example/android/app/build.gradle @@ -0,0 +1,71 @@ +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterRoot = localProperties.getProperty('flutter.sdk') +if (flutterRoot == null) { + throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" + +android { + compileSdkVersion flutter.compileSdkVersion + ndkVersion flutter.ndkVersion + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId "com.example.notification_plugin_example" + // You can update the following values to match your application needs. + // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. + minSdkVersion flutter.minSdkVersion + targetSdkVersion flutter.targetSdkVersion + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.debug + } + } +} + +flutter { + source '../..' +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" +} diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/debug/AndroidManifest.xml b/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 000000000..822a20815 --- /dev/null +++ b/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,8 @@ + + + + diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/AndroidManifest.xml b/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/AndroidManifest.xml new file mode 100644 index 000000000..60e7eab80 --- /dev/null +++ b/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/kotlin/com/example/notification_plugin_example/MainActivity.kt b/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/kotlin/com/example/notification_plugin_example/MainActivity.kt new file mode 100644 index 000000000..af88e15d8 --- /dev/null +++ b/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/kotlin/com/example/notification_plugin_example/MainActivity.kt @@ -0,0 +1,6 @@ +package com.example.notification_plugin_example + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() { +} diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/drawable-v21/launch_background.xml b/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 000000000..f74085f3f --- /dev/null +++ b/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/drawable/launch_background.xml b/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 000000000..304732f88 --- /dev/null +++ b/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..db77bb4b7b0906d62b1847e87f15cdcacf6a4f29 GIT binary patch literal 544 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY3?!3`olAj~WQl7;NpOBzNqJ&XDuZK6ep0G} zXKrG8YEWuoN@d~6R2!h8bpbvhu0Wd6uZuB!w&u2PAxD2eNXD>P5D~Wn-+_Wa#27Xc zC?Zj|6r#X(-D3u$NCt}(Ms06KgJ4FxJVv{GM)!I~&n8Bnc94O7-Hd)cjDZswgC;Qs zO=b+9!WcT8F?0rF7!Uys2bs@gozCP?z~o%U|N3vA*22NaGQG zlg@K`O_XuxvZ&Ks^m&R!`&1=spLvfx7oGDKDwpwW`#iqdw@AL`7MR}m`rwr|mZgU`8P7SBkL78fFf!WnuYWm$5Z0 zNXhDbCv&49sM544K|?c)WrFfiZvCi9h0O)B3Pgg&ebxsLQ05GG~ AQ2+n{ literal 0 HcmV?d00001 diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..17987b79bb8a35cc66c3c1fd44f5a5526c1b78be GIT binary patch literal 442 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA3?vioaBc-sk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5Xx&nMcT!A!W`0S9QKQy;}1Cl^CgaH=;G9cpY;r$Q>i*pfB zP2drbID<_#qf;rPZx^FqH)F_D#*k@@q03KywUtLX8Ua?`H+NMzkczFPK3lFz@i_kW%1NOn0|D2I9n9wzH8m|-tHjsw|9>@K=iMBhxvkv6m8Y-l zytQ?X=U+MF$@3 zt`~i=@j|6y)RWMK--}M|=T`o&^Ni>IoWKHEbBXz7?A@mgWoL>!*SXo`SZH-*HSdS+ yn*9;$7;m`l>wYBC5bq;=U}IMqLzqbYCidGC!)_gkIk_C@Uy!y&wkt5C($~2D>~)O*cj@FGjOCM)M>_ixfudOh)?xMu#Fs z#}Y=@YDTwOM)x{K_j*Q;dPdJ?Mz0n|pLRx{4n|)f>SXlmV)XB04CrSJn#dS5nK2lM zrZ9#~WelCp7&e13Y$jvaEXHskn$2V!!DN-nWS__6T*l;H&Fopn?A6HZ-6WRLFP=R` zqG+CE#d4|IbyAI+rJJ`&x9*T`+a=p|0O(+s{UBcyZdkhj=yS1>AirP+0R;mf2uMgM zC}@~JfByORAh4SyRgi&!(cja>F(l*O+nd+@4m$|6K6KDn_&uvCpV23&>G9HJp{xgg zoq1^2_p9@|WEo z*X_Uko@K)qYYv~>43eQGMdbiGbo>E~Q& zrYBH{QP^@Sti!`2)uG{irBBq@y*$B zi#&(U-*=fp74j)RyIw49+0MRPMRU)+a2r*PJ$L5roHt2$UjExCTZSbq%V!HeS7J$N zdG@vOZB4v_lF7Plrx+hxo7(fCV&}fHq)$ literal 0 HcmV?d00001 diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..d5f1c8d34e7a88e3f88bea192c3a370d44689c3c GIT binary patch literal 1031 zcmeAS@N?(olHy`uVBq!ia0vp^6F``Q8Ax83A=Cw=BuiW)N`mv#O3D+9QW+dm@{>{( zJaZG%Q-e|yQz{EjrrIztFa`(sgt!6~Yi|1%a`XoT0ojZ}lNrNjb9xjc(B0U1_% zz5^97Xt*%oq$rQy4?0GKNfJ44uvxI)gC`h-NZ|&0-7(qS@?b!5r36oQ}zyZrNO3 zMO=Or+<~>+A&uN&E!^Sl+>xE!QC-|oJv`ApDhqC^EWD|@=#J`=d#Xzxs4ah}w&Jnc z$|q_opQ^2TrnVZ0o~wh<3t%W&flvYGe#$xqda2bR_R zvPYgMcHgjZ5nSA^lJr%;<&0do;O^tDDh~=pIxA#coaCY>&N%M2^tq^U%3DB@ynvKo}b?yu-bFc-u0JHzced$sg7S3zqI(2 z#Km{dPr7I=pQ5>FuK#)QwK?Y`E`B?nP+}U)I#c1+FM*1kNvWG|a(TpksZQ3B@sD~b zpQ2)*V*TdwjFOtHvV|;OsiDqHi=6%)o4b!)x$)%9pGTsE z-JL={-Ffv+T87W(Xpooq<`r*VzWQcgBN$$`u}f>-ZQI1BB8ykN*=e4rIsJx9>z}*o zo~|9I;xof literal 0 HcmV?d00001 diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..4d6372eebdb28e45604e46eeda8dd24651419bc0 GIT binary patch literal 1443 zcmb`G{WsKk6vsdJTdFg%tJav9_E4vzrOaqkWF|A724Nly!y+?N9`YV6wZ}5(X(D_N(?!*n3`|_r0Hc?=PQw&*vnU?QTFY zB_MsH|!j$PP;I}?dppoE_gA(4uc!jV&0!l7_;&p2^pxNo>PEcNJv za5_RT$o2Mf!<+r?&EbHH6nMoTsDOa;mN(wv8RNsHpG)`^ymG-S5By8=l9iVXzN_eG%Xg2@Xeq76tTZ*dGh~Lo9vl;Zfs+W#BydUw zCkZ$o1LqWQO$FC9aKlLl*7x9^0q%0}$OMlp@Kk_jHXOjofdePND+j!A{q!8~Jn+s3 z?~~w@4?egS02}8NuulUA=L~QQfm;MzCGd)XhiftT;+zFO&JVyp2mBww?;QByS_1w! zrQlx%{^cMj0|Bo1FjwY@Q8?Hx0cIPF*@-ZRFpPc#bBw{5@tD(5%sClzIfl8WU~V#u zm5Q;_F!wa$BSpqhN>W@2De?TKWR*!ujY;Yylk_X5#~V!L*Gw~;$%4Q8~Mad z@`-kG?yb$a9cHIApZDVZ^U6Xkp<*4rU82O7%}0jjHlK{id@?-wpN*fCHXyXh(bLt* zPc}H-x0e4E&nQ>y%B-(EL=9}RyC%MyX=upHuFhAk&MLbsF0LP-q`XnH78@fT+pKPW zu72MW`|?8ht^tz$iC}ZwLp4tB;Q49K!QCF3@!iB1qOI=?w z7In!}F~ij(18UYUjnbmC!qKhPo%24?8U1x{7o(+?^Zu0Hx81|FuS?bJ0jgBhEMzf< zCgUq7r2OCB(`XkKcN-TL>u5y#dD6D!)5W?`O5)V^>jb)P)GBdy%t$uUMpf$SNV31$ zb||OojAbvMP?T@$h_ZiFLFVHDmbyMhJF|-_)HX3%m=CDI+ID$0^C>kzxprBW)hw(v zr!Gmda);ICoQyhV_oP5+C%?jcG8v+D@9f?Dk*!BxY}dazmrT@64UrP3hlslANK)bq z$67n83eh}OeW&SV@HG95P|bjfqJ7gw$e+`Hxo!4cx`jdK1bJ>YDSpGKLPZ^1cv$ek zIB?0S<#tX?SJCLWdMd{-ME?$hc7A$zBOdIJ)4!KcAwb=VMov)nK;9z>x~rfT1>dS+ zZ6#`2v@`jgbqq)P22H)Tx2CpmM^o1$B+xT6`(v%5xJ(?j#>Q$+rx_R|7TzDZe{J6q zG1*EcU%tE?!kO%^M;3aM6JN*LAKUVb^xz8-Pxo#jR5(-KBeLJvA@-gxNHx0M-ZJLl z;#JwQoh~9V?`UVo#}{6ka@II>++D@%KqGpMdlQ}?9E*wFcf5(#XQnP$Dk5~%iX^>f z%$y;?M0BLp{O3a(-4A?ewryHrrD%cx#Q^%KY1H zNre$ve+vceSLZcNY4U(RBX&)oZn*Py()h)XkE?PL$!bNb{N5FVI2Y%LKEm%yvpyTP z(1P?z~7YxD~Rf<(a@_y` literal 0 HcmV?d00001 diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/values-night/styles.xml b/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 000000000..06952be74 --- /dev/null +++ b/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/values/styles.xml b/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/values/styles.xml new file mode 100644 index 000000000..cb1ef8805 --- /dev/null +++ b/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/profile/AndroidManifest.xml b/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 000000000..822a20815 --- /dev/null +++ b/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,8 @@ + + + + diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/build.gradle b/pkgs/jni_gen/examples/notification_plugin/example/android/build.gradle new file mode 100644 index 000000000..83ae22004 --- /dev/null +++ b/pkgs/jni_gen/examples/notification_plugin/example/android/build.gradle @@ -0,0 +1,31 @@ +buildscript { + ext.kotlin_version = '1.6.10' + repositories { + google() + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:7.1.2' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = '../build' +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(':app') +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/gradle.properties b/pkgs/jni_gen/examples/notification_plugin/example/android/gradle.properties new file mode 100644 index 000000000..94adc3a3f --- /dev/null +++ b/pkgs/jni_gen/examples/notification_plugin/example/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx1536M +android.useAndroidX=true +android.enableJetifier=true diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/gradle/wrapper/gradle-wrapper.properties b/pkgs/jni_gen/examples/notification_plugin/example/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..cb24abda1 --- /dev/null +++ b/pkgs/jni_gen/examples/notification_plugin/example/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/settings.gradle b/pkgs/jni_gen/examples/notification_plugin/example/android/settings.gradle new file mode 100644 index 000000000..44e62bcf0 --- /dev/null +++ b/pkgs/jni_gen/examples/notification_plugin/example/android/settings.gradle @@ -0,0 +1,11 @@ +include ':app' + +def localPropertiesFile = new File(rootProject.projectDir, "local.properties") +def properties = new Properties() + +assert localPropertiesFile.exists() +localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + +def flutterSdkPath = properties.getProperty("flutter.sdk") +assert flutterSdkPath != null, "flutter.sdk not set in local.properties" +apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" diff --git a/pkgs/jni_gen/examples/notification_plugin/example/lib/main.dart b/pkgs/jni_gen/examples/notification_plugin/example/lib/main.dart new file mode 100644 index 000000000..4bc30d458 --- /dev/null +++ b/pkgs/jni_gen/examples/notification_plugin/example/lib/main.dart @@ -0,0 +1,89 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:jni/jni.dart'; + +// The hierarchy created in generated code will mirror the java package +// structure. This is an implementation convenience and we may allow +// more customization in future. +import 'package:notification_plugin/com/example/notification_plugin.dart'; + +JlObject activity = JlObject.fromRef(Jni.getInstance().getCurrentActivity()); + +int i = 0; + +void showNotification(String title, String text) { + i = i + 1; + var jTitle = JlString.fromString(title); + var jText = JlString.fromString(text); + Notifications.showNotification(activity, i, jTitle, jText); + jTitle.delete(); + jText.delete(); +} + +void main() { + runApp(const MyApp()); +} + +class MyApp extends StatelessWidget { + const MyApp({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return MaterialApp( + title: 'Flutter Demo', + theme: ThemeData( + primarySwatch: Colors.teal, + ), + home: MyHomePage(title: 'Flutter Demo Home Page'), + ); + } +} + +class MyHomePage extends StatelessWidget { + MyHomePage({Key? key, required this.title}) : super(key: key); + + final String title; + + final _title = TextEditingController(text: 'Hello from JNI'); + final _text = TextEditingController(text: '😀'); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text(title), + ), + body: Center( + child: Padding( + padding: const EdgeInsets.all(16), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + TextFormField( + controller: _title, + textCapitalization: TextCapitalization.sentences, + decoration: + const InputDecoration(labelText: 'Notification title'), + ), + TextFormField( + controller: _text, + keyboardType: TextInputType.multiline, + minLines: 1, + maxLines: 4, + decoration: + const InputDecoration(labelText: 'Notification text'), + ), + ElevatedButton( + child: const Text('Show Notification'), + onPressed: () => showNotification(_title.text, _text.text), + ), + ], + ), + ), + ), + ); + } +} diff --git a/pkgs/jni_gen/examples/notification_plugin/example/pubspec.yaml b/pkgs/jni_gen/examples/notification_plugin/example/pubspec.yaml new file mode 100644 index 000000000..b1f6a9726 --- /dev/null +++ b/pkgs/jni_gen/examples/notification_plugin/example/pubspec.yaml @@ -0,0 +1,89 @@ +name: notification_plugin_example +description: Demonstrates how to use the notification_plugin plugin. + +# The following line prevents the package from being accidentally published to +# pub.dev using `flutter pub publish`. This is preferred for private packages. +publish_to: 'none' # Remove this line if you wish to publish to pub.dev + +# The following defines the version and build number for your application. +# A version number is three numbers separated by dots, like 1.2.43 +# followed by an optional build number separated by a +. +# Both the version and the builder number may be overridden in flutter +# build by specifying --build-name and --build-number, respectively. +# In Android, build-name is used as versionName while build-number used as versionCode. +# Read more about Android versioning at https://developer.android.com/studio/publish/versioning +# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. +# Read more about iOS versioning at +# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html +# In Windows, build-name is used as the major, minor, and patch parts +# of the product and file versions while build-number is used as the build suffix. +version: 1.0.0+1 + +environment: + sdk: '>=2.18.0 <3.0.0' + +dependencies: + flutter: + sdk: flutter + + notification_plugin: + path: ../ + + jni: + path: ../../../../jni/ + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^1.0.2 + +dev_dependencies: + flutter_test: + sdk: flutter + + # The "flutter_lints" package below contains a set of recommended lints to + # encourage good coding practices. The lint set provided by the package is + # activated in the `analysis_options.yaml` file located at the root of your + # package. See that file for information about deactivating specific lint + # rules and activating additional ones. + flutter_lints: ^2.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + + # To add assets to your application, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/assets-and-images/#from-packages + + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/custom-fonts/#from-packages diff --git a/pkgs/jni_gen/examples/notification_plugin/jnigen.yaml b/pkgs/jni_gen/examples/notification_plugin/jnigen.yaml new file mode 100644 index 000000000..16315f6e8 --- /dev/null +++ b/pkgs/jni_gen/examples/notification_plugin/jnigen.yaml @@ -0,0 +1,17 @@ +android_sdk_config: + add_gradle_deps: true + android_example: 'example/' + +preamble: | + // 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 + // BSD-style license that can be found in the LICENSE file. + +library_name: notification_plugin +source_path: + - 'android/src/main/java' +classes: + - 'com.example.notification_plugin.Notifications' +c_root: src/ +dart_root: lib/ + diff --git a/pkgs/jni_gen/examples/notification_plugin/lib/com/example/notification_plugin.dart b/pkgs/jni_gen/examples/notification_plugin/lib/com/example/notification_plugin.dart new file mode 100644 index 000000000..52c75af14 --- /dev/null +++ b/pkgs/jni_gen/examples/notification_plugin/lib/com/example/notification_plugin.dart @@ -0,0 +1,46 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +// Autogenerated by jni_gen. DO NOT EDIT! + +// ignore_for_file: camel_case_types +// ignore_for_file: non_constant_identifier_names +// ignore_for_file: constant_identifier_names +// ignore_for_file: annotate_overrides +// ignore_for_file: no_leading_underscores_for_local_identifiers +// ignore_for_file: unused_element + +import "dart:ffi" as ffi; + +import "package:jni/jni.dart" as jni; + +import "../../init.dart" show jlookup; + +/// from: com.example.notification_plugin.Notifications +class Notifications extends jni.JlObject { + Notifications.fromRef(ffi.Pointer ref) : super.fromRef(ref); + + static final _ctor = + jlookup Function()>>( + "com_example_notification_plugin_Notifications_ctor") + .asFunction Function()>(); + + /// from: public void () + Notifications() : super.fromRef(_ctor()); + + static final _showNotification = jlookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Int32, + ffi.Pointer, ffi.Pointer)>>( + "com_example_notification_plugin_Notifications_showNotification") + .asFunction< + void Function(ffi.Pointer, int, ffi.Pointer, + ffi.Pointer)>(); + + /// from: static public void showNotification(android.content.Context context, int notificationID, java.lang.String title, java.lang.String text) + static void showNotification(jni.JlObject context, int notificationID, + jni.JlString title, jni.JlString text) => + _showNotification( + context.reference, notificationID, title.reference, text.reference); +} diff --git a/pkgs/jni_gen/examples/notification_plugin/lib/init.dart b/pkgs/jni_gen/examples/notification_plugin/lib/init.dart new file mode 100644 index 000000000..9a4243f31 --- /dev/null +++ b/pkgs/jni_gen/examples/notification_plugin/lib/init.dart @@ -0,0 +1,5 @@ +import "dart:ffi"; +import "package:jni/jni.dart"; + +final Pointer Function(String sym) jlookup = + Jni.getInstance().initGeneratedLibrary("notification_plugin"); diff --git a/pkgs/jni_gen/examples/notification_plugin/pubspec.yaml b/pkgs/jni_gen/examples/notification_plugin/pubspec.yaml new file mode 100644 index 000000000..422f83a34 --- /dev/null +++ b/pkgs/jni_gen/examples/notification_plugin/pubspec.yaml @@ -0,0 +1,76 @@ +name: notification_plugin +description: A new Flutter FFI plugin project. +version: 0.0.1 +publish_to: none +homepage: https://github.com/dart-lang/jni_gen + +environment: + sdk: '>=2.18.0 <3.0.0' + flutter: ">=2.11.0" + +dependencies: + jni: + path: ../../../jni/ + flutter: + sdk: flutter + plugin_platform_interface: ^2.0.2 + +dev_dependencies: + jni_gen: + path: ../../ + flutter_test: + sdk: flutter + flutter_lints: ^2.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + # This section identifies this Flutter project as a plugin project. + # The 'pluginClass' specifies the class (in Java, Kotlin, Swift, Objective-C, etc.) + # which should be registered in the plugin registry. This is required for + # using method channels. + # The Android 'package' specifies package in which the registered class is. + # This is required for using method channels on Android. + # The 'ffiPlugin' specifies that native code should be built and bundled. + # This is required for using `dart:ffi`. + # All these are used by the tooling to maintain consistency when + # adding or updating assets for this project. + # + # Please refer to README.md for a detailed explanation. + plugin: + platforms: + android: + ffiPlugin: true + + # To add assets to your plugin package, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + # + # For details regarding assets in packages, see + # https://flutter.dev/assets-and-images/#from-packages + # + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware + + # To add custom fonts to your plugin package, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts in packages, see + # https://flutter.dev/custom-fonts/#from-packages diff --git a/pkgs/jni_gen/examples/notification_plugin/src/CMakeLists.txt b/pkgs/jni_gen/examples/notification_plugin/src/CMakeLists.txt new file mode 100644 index 000000000..c73384560 --- /dev/null +++ b/pkgs/jni_gen/examples/notification_plugin/src/CMakeLists.txt @@ -0,0 +1,30 @@ +# The Flutter tooling requires that developers have CMake 3.10 or later +# installed. You should not increase this version, as doing so will cause +# the plugin to fail to compile for some customers of the plugin. +cmake_minimum_required(VERSION 3.10) + +project(notification_plugin VERSION 0.0.1 LANGUAGES C) + +add_library(notification_plugin SHARED + "./notification_plugin.c" +) + +set_target_properties(notification_plugin PROPERTIES + OUTPUT_NAME "notification_plugin" +) + +target_compile_definitions(notification_plugin PUBLIC DART_SHARED_LIB) + +if(WIN32) + set_target_properties(${TARGET_NAME} PROPERTIES + LINK_FLAGS "/DELAYLOAD:jvm.dll") +endif() + +if (ANDROID) + target_link_libraries(notification_plugin log) +else() + find_package(Java REQUIRED) + find_package(JNI REQUIRED) + include_directories(${JNI_INCLUDE_DIRS}) + target_link_libraries(notification_plugin ${JNI_LIBRARIES}) +endif() diff --git a/pkgs/jni_gen/examples/notification_plugin/src/dartjni.h b/pkgs/jni_gen/examples/notification_plugin/src/dartjni.h new file mode 100644 index 000000000..cd94b1532 --- /dev/null +++ b/pkgs/jni_gen/examples/notification_plugin/src/dartjni.h @@ -0,0 +1,177 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +#include +#include +#include +#include + +#if _WIN32 +#include +#else +#include +#include +#endif + +#if _WIN32 +#define FFI_PLUGIN_EXPORT __declspec(dllexport) +#else +#define FFI_PLUGIN_EXPORT +#endif + +#if defined _WIN32 +#define thread_local __declspec(thread) +#else +#define thread_local __thread +#endif + +#ifdef __ANDROID__ +#include +#endif + +#define JNI_LOG_TAG "Dart-JNI" + +#ifdef __ANDROID__ +#define __ENVP_CAST (JNIEnv **) +#else +#define __ENVP_CAST (void **) +#endif + +struct jni_context { + JavaVM *jvm; + jobject classLoader; + jmethodID loadClassMethod; + jobject currentActivity; + jobject appContext; +}; + +extern thread_local JNIEnv *jniEnv; + +extern struct jni_context jni; + +enum DartJniLogLevel { + JNI_VERBOSE = 2, + JNI_DEBUG, + JNI_INFO, + JNI_WARN, + JNI_ERROR +}; + +FFI_PLUGIN_EXPORT struct jni_context GetJniContext(); + +FFI_PLUGIN_EXPORT JavaVM *GetJavaVM(void); + +FFI_PLUGIN_EXPORT JNIEnv *GetJniEnv(void); + +FFI_PLUGIN_EXPORT JNIEnv *SpawnJvm(JavaVMInitArgs *args); + +FFI_PLUGIN_EXPORT jclass LoadClass(const char *name); + +FFI_PLUGIN_EXPORT jobject GetClassLoader(void); + +FFI_PLUGIN_EXPORT jobject GetApplicationContext(void); + +FFI_PLUGIN_EXPORT jobject GetCurrentActivity(void); + +FFI_PLUGIN_EXPORT void SetJNILogging(int level); + +FFI_PLUGIN_EXPORT jstring ToJavaString(char *str); + +FFI_PLUGIN_EXPORT const char *GetJavaStringChars(jstring jstr); + +FFI_PLUGIN_EXPORT void ReleaseJavaStringChars(jstring jstr, const char *buf); + +// These 2 are the function pointer variables defined and exported by +// the generated C files. +// +// initGeneratedLibrary function in Jni class will set these to +// corresponding functions to the implementations from `dartjni` base library +// which initializes and manages the JNI. +extern struct jni_context (*context_getter)(void); +extern JNIEnv *(*env_getter)(void); + +// This function will be exported by generated code library and will set the +// above 2 variables. +FFI_PLUGIN_EXPORT void setJniGetters(struct jni_context (*cg)(void), + JNIEnv *(*eg)(void)); + +// `static inline` because `inline` doesn't work, it may still not +// inline the function in which case a linker error may be produced. +// +// There has to be a better way to do this. Either to force inlining on target +// platforms, or just leave it as normal function. +static inline void __load_class_into(jclass *cls, const char *name) { +#ifdef __ANDROID__ + jstring className = (*jniEnv)->NewStringUTF(jniEnv, name); + *cls = (*jniEnv)->CallObjectMethod(jniEnv, jni.classLoader, + jni.loadClassMethod, className); + (*jniEnv)->DeleteLocalRef(jniEnv, className); +#else + *cls = (*jniEnv)->FindClass(jniEnv, name); +#endif +} + +static inline void load_class(jclass *cls, const char *name) { + if (*cls == NULL) { + __load_class_into(cls, name); + } +} + +static inline void load_class_gr(jclass *cls, const char *name) { + if (*cls == NULL) { + jclass tmp; + __load_class_into(&tmp, name); + *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); + (*jniEnv)->DeleteLocalRef(jniEnv, tmp); + } +} + +static inline void attach_thread() { + if (jniEnv == NULL) { + (*jni.jvm)->AttachCurrentThread(jni.jvm, __ENVP_CAST & jniEnv, + NULL); + } +} + +static inline void load_env() { + if (jniEnv == NULL) { + jni = context_getter(); + jniEnv = env_getter(); + } +} + +static inline void load_method(jclass cls, jmethodID *res, const char *name, + const char *sig) { + if (*res == NULL) { + *res = (*jniEnv)->GetMethodID(jniEnv, cls, name, sig); + } +} + +static inline void load_static_method(jclass cls, jmethodID *res, + const char *name, const char *sig) { + if (*res == NULL) { + *res = (*jniEnv)->GetStaticMethodID(jniEnv, cls, name, sig); + } +} + +static inline void load_field(jclass cls, jfieldID *res, const char *name, + const char *sig) { + if (*res == NULL) { + *res = (*jniEnv)->GetFieldID(jniEnv, cls, name, sig); + } +} + +static inline void load_static_field(jclass cls, jfieldID *res, + const char *name, const char *sig) { + if (*res == NULL) { + *res = (*jniEnv)->GetStaticFieldID(jniEnv, cls, name, sig); + } +} + +static inline jobject to_global_ref(jobject ref) { + jobject g = (*jniEnv)->NewGlobalRef(jniEnv, ref); + (*jniEnv)->DeleteLocalRef(jniEnv, ref); + return g; +} + diff --git a/pkgs/jni_gen/examples/notification_plugin/src/notification_plugin.c b/pkgs/jni_gen/examples/notification_plugin/src/notification_plugin.c new file mode 100644 index 000000000..6457cae02 --- /dev/null +++ b/pkgs/jni_gen/examples/notification_plugin/src/notification_plugin.c @@ -0,0 +1,44 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +// Autogenerated by jni_gen. DO NOT EDIT! + +#include +#include "jni.h" +#include "dartjni.h" + +thread_local JNIEnv *jniEnv; +struct jni_context jni; + +struct jni_context (*context_getter)(void); +JNIEnv *(*env_getter)(void); + +void setJniGetters(struct jni_context (*cg)(void), + JNIEnv *(*eg)(void)) { + context_getter = cg; + env_getter = eg; +} + +// com.example.notification_plugin.Notifications +jclass _c_com_example_notification_plugin_Notifications = NULL; + +jmethodID _m_com_example_notification_plugin_Notifications_ctor = NULL; +FFI_PLUGIN_EXPORT +jobject com_example_notification_plugin_Notifications_ctor() { + load_env(); + load_class_gr(&_c_com_example_notification_plugin_Notifications, "com/example/notification_plugin/Notifications"); + load_method(_c_com_example_notification_plugin_Notifications, &_m_com_example_notification_plugin_Notifications_ctor, "", "()V"); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_com_example_notification_plugin_Notifications, _m_com_example_notification_plugin_Notifications_ctor); + return to_global_ref(_result); +} + +jmethodID _m_com_example_notification_plugin_Notifications_showNotification = NULL; +FFI_PLUGIN_EXPORT +void com_example_notification_plugin_Notifications_showNotification(jobject context, int32_t notificationID, jobject title, jobject text) { + load_env(); + load_class_gr(&_c_com_example_notification_plugin_Notifications, "com/example/notification_plugin/Notifications"); + load_static_method(_c_com_example_notification_plugin_Notifications, &_m_com_example_notification_plugin_Notifications_showNotification, "showNotification", "(Landroid/content/Context;ILjava/lang/String;Ljava/lang/String;)V"); + (*jniEnv)->CallStaticVoidMethod(jniEnv, _c_com_example_notification_plugin_Notifications, _m_com_example_notification_plugin_Notifications_showNotification, context, notificationID, title, text); +} + diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/dart_example/bin/pdf_info.dart b/pkgs/jni_gen/examples/pdfbox_plugin/dart_example/bin/pdf_info.dart index f8756ff55..f276ea1e1 100644 --- a/pkgs/jni_gen/examples/pdfbox_plugin/dart_example/bin/pdf_info.dart +++ b/pkgs/jni_gen/examples/pdfbox_plugin/dart_example/bin/pdf_info.dart @@ -1,3 +1,7 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + import 'dart:io'; import 'package:path/path.dart'; diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/lib/main.dart b/pkgs/jni_gen/examples/pdfbox_plugin/example/lib/main.dart index 1557b842b..09527fb03 100644 --- a/pkgs/jni_gen/examples/pdfbox_plugin/example/lib/main.dart +++ b/pkgs/jni_gen/examples/pdfbox_plugin/example/lib/main.dart @@ -1,3 +1,7 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + import 'package:flutter/material.dart'; import 'dart:io'; import 'dart:async'; diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/tool/generate_bindings.dart b/pkgs/jni_gen/examples/pdfbox_plugin/tool/generate_bindings.dart index b7ea48ee6..547a207f6 100644 --- a/pkgs/jni_gen/examples/pdfbox_plugin/tool/generate_bindings.dart +++ b/pkgs/jni_gen/examples/pdfbox_plugin/tool/generate_bindings.dart @@ -1,3 +1,7 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + import 'package:jni_gen/jni_gen.dart'; const preamble = ''' @@ -31,7 +35,9 @@ void main(List arguments) async { ), classes: ['org.apache.pdfbox.pdmodel', 'org.apache.pdfbox.text'], cRoot: Uri.directory('src/'), - dartRoot: Uri.directory('lib/'), + cSubdir: 'third_party', + preamble: preamble, + dartRoot: Uri.directory('lib/third_party'), libraryName: 'pdfbox_plugin', ); await generateJniBindings(config); diff --git a/pkgs/jni_gen/lib/src/config/config.dart b/pkgs/jni_gen/lib/src/config/config.dart index 278e1bd6c..6d18085c0 100644 --- a/pkgs/jni_gen/lib/src/config/config.dart +++ b/pkgs/jni_gen/lib/src/config/config.dart @@ -56,20 +56,49 @@ class MavenDownloads { /// environment variable `ANDROID_SDK_ROOT` if it's defined, else an error /// will be thrown. class AndroidSdkConfig { - AndroidSdkConfig( - {this.versions, - this.sdkRoot, - this.includeSources = false, - this.addGradleDeps = false}) { + AndroidSdkConfig({ + this.versions, + this.sdkRoot, + this.includeSources = false, + this.addGradleDeps = false, + this.androidExample, + }) { if (versions == null && !addGradleDeps) { throw ArgumentError('Neither any SDK versions nor `addGradleDeps` ' 'is specified. Unable to find Android libraries.'); } } + + /// Versions of android SDK to search for, in decreasing order of preference. List? versions; + + /// Root of Android SDK installation, this should be normally given on + /// command line or by setting `ANDROID_SDK_ROOT`, since this varies from + /// system to system. String? sdkRoot; + + /// Include downloaded android SDK sources in source path. bool includeSources; + + /// Attempt to determine exact compile time dependencies by running a gradle + /// stub in android subproject of this project. + /// + /// An Android build must have happened before we are able to obtain classpath + /// of Gradle dependencies. Run `flutter build apk` before running a jni_gen + /// script with this option. + /// + /// For the same reason, if the flutter project is a plugin instead of + /// application, it's not possible to determine the build classpath directly. + /// Please provide [androidExample] pointing to an example application in + /// that case. bool addGradleDeps; + + /// Relative path to example application which will be used to determine + /// compile time classpath using a gradle stub. For most Android plugin + /// packages, 'example' will be the name of example application created inside + /// the package. This example should be built once before using this option, + /// so that gradle would have resolved all the dependencies. + String? androidExample; } /// Additional options to pass to the summary generator component. @@ -263,6 +292,7 @@ class Config { includeSources: prov.getBool(_Props.includeAndroidSources) ?? false, addGradleDeps: prov.getBool(_Props.addGradleDeps) ?? false, + androidExample: prov.getString(_Props.androidExample), ) : null, ); @@ -315,4 +345,5 @@ class _Props { static const androidSdkVersions = '$androidSdkConfig.versions'; static const includeAndroidSources = '$androidSdkConfig.include_sources'; static const addGradleDeps = '$androidSdkConfig.add_gradle_deps'; + static const androidExample = '$androidSdkConfig.android_example'; } diff --git a/pkgs/jni_gen/lib/src/generate_bindings.dart b/pkgs/jni_gen/lib/src/generate_bindings.dart index 09f948fa6..c6f410e77 100644 --- a/pkgs/jni_gen/lib/src/generate_bindings.dart +++ b/pkgs/jni_gen/lib/src/generate_bindings.dart @@ -45,7 +45,8 @@ Future generateJniBindings(Config config) async { final androidConfig = config.androidSdkConfig; if (androidConfig != null && androidConfig.addGradleDeps) { - final deps = AndroidSdkTools.getGradleClasspaths(); + final deps = AndroidSdkTools.getGradleClasspaths( + androidConfig.androidExample ?? '.'); extraJars.addAll(deps.map(Uri.file)); } if (androidConfig != null && androidConfig.versions != null) { diff --git a/pkgs/jni_gen/lib/src/tools/android_sdk_tools.dart b/pkgs/jni_gen/lib/src/tools/android_sdk_tools.dart index 029555ae5..ed78566b9 100644 --- a/pkgs/jni_gen/lib/src/tools/android_sdk_tools.dart +++ b/pkgs/jni_gen/lib/src/tools/android_sdk_tools.dart @@ -63,10 +63,13 @@ task listDependencies(type: Copy) { /// /// This function temporarily overwrites the build.gradle file by a stub with /// function to list all dependency paths for release variant. - /// This function fails if no gradle build is attempted - static List getGradleClasspaths() { - stderr.writeln('trying to obtain gradle classpaths'); - const android = 'android'; + /// This function fails if no gradle build is attempted before. + /// + /// If current project is not directly buildable by gradle, eg: a plugin, + /// a relative path to other project can be specified using [androidProject]. + static List getGradleClasspaths([String androidProject = '.']) { + stderr.writeln('trying to obtain gradle classpaths...'); + final android = join(androidProject, 'android'); final buildGradle = join(android, 'build.gradle'); final buildGradleOld = join(android, 'build.gradle.old'); final origBuild = File(buildGradle); @@ -80,8 +83,8 @@ task listDependencies(type: Copy) { File(buildGradleOld).deleteSync(); if (procRes.exitCode != 0) { throw Exception('\n\ngradle exited with exit code ${procRes.exitCode}\n' - 'This can be related to a known issue with gradle. ' - 'Please run `flutter build apk` and try again\n'); + 'This can be related to a known issue with gradle. Please run ' + '`flutter build apk` in $androidProject and try again\n'); } final gradleClassPaths = (procRes.stdout as String).split('\n'); if (gradleClassPaths.last.isEmpty) { From a1bd070d4b1209e11bba0ed53c0048f8c257dd72 Mon Sep 17 00:00:00 2001 From: Mahesh Hegde <46179734+mahesh-hegde@users.noreply.github.com> Date: Mon, 5 Sep 2022 15:23:43 +0530 Subject: [PATCH 013/139] [jnigen] Rename to jnigen (https://github.com/dart-lang/jnigen/issues/47) --- .github/workflows/test-package.yml | 40 ++-- pkgs/jni/README.md | 12 +- pkgs/jni/bin/setup.dart | 2 +- pkgs/jni/lib/src/extensions.dart | 2 +- pkgs/jni_gen/README.md | 32 --- .../examples/notification_plugin/README.md | 13 -- pkgs/jni_gen/examples/pdfbox_plugin/README.md | 8 - .../simple_package_test/src/simple_package.c | 189 ------------------ pkgs/{jni_gen => jnigen}/.gitignore | 0 pkgs/{jni_gen => jnigen}/LICENSE | 0 pkgs/jnigen/README.md | 6 +- .../{jni_gen => jnigen}/analysis_options.yaml | 0 .../bin/download_maven_jars.dart | 6 +- .../jni_gen.dart => jnigen/bin/jnigen.dart} | 2 +- pkgs/{jni_gen => jnigen}/bin/setup.dart | 4 +- .../cmake/CMakeLists.txt.tmpl | 0 pkgs/{jni_gen => jnigen}/examples/README.md | 6 +- .../examples/in_app_java/.gitignore | 0 .../examples/in_app_java/.metadata | 0 .../examples/in_app_java/README.md | 6 +- .../in_app_java/analysis_options.yaml | 0 .../examples/in_app_java/android/.gitignore | 0 .../in_app_java/android/app/build.gradle | 0 .../android/app/src/debug/AndroidManifest.xml | 0 .../android/app/src/main/AndroidManifest.xml | 0 .../com/example/in_app_java/AndroidUtils.java | 0 .../com/example/in_app_java/MainActivity.kt | 0 .../res/drawable-v21/launch_background.xml | 0 .../main/res/drawable/launch_background.xml | 0 .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin .../app/src/main/res/values-night/styles.xml | 0 .../app/src/main/res/values/styles.xml | 0 .../app/src/profile/AndroidManifest.xml | 0 .../examples/in_app_java/android/build.gradle | 0 .../in_app_java/android/gradle.properties | 0 .../gradle/wrapper/gradle-wrapper.properties | 0 .../in_app_java/android/settings.gradle | 0 .../examples/in_app_java/jnigen.yaml | 0 .../com/example/in_app_java.dart | 2 +- .../in_app_java/lib/android_utils/init.dart | 0 .../examples/in_app_java/lib/main.dart | 0 .../examples/in_app_java/pubspec.yaml | 2 +- .../src/android_utils/CMakeLists.txt | 0 .../src/android_utils/android_utils.c | 2 +- .../in_app_java/src/android_utils/dartjni.h | 0 .../in_app_java/tool/generate_bindings.dart | 2 +- .../examples/notification_plugin/.gitignore | 0 .../examples/notification_plugin/.metadata | 0 .../examples/notification_plugin/README.md | 13 ++ .../notification_plugin/analysis_options.yaml | 0 .../notification_plugin/android/.gitignore | 0 .../notification_plugin/android/build.gradle | 0 .../android/settings.gradle | 0 .../android/src/main/AndroidManifest.xml | 0 .../notification_plugin/Notifications.java | 0 .../notification_plugin/example/.gitignore | 0 .../notification_plugin/example/README.md | 0 .../example/analysis_options.yaml | 0 .../example/android/.gitignore | 0 .../example/android/app/build.gradle | 0 .../android/app/src/debug/AndroidManifest.xml | 0 .../android/app/src/main/AndroidManifest.xml | 0 .../MainActivity.kt | 0 .../res/drawable-v21/launch_background.xml | 0 .../main/res/drawable/launch_background.xml | 0 .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin .../app/src/main/res/values-night/styles.xml | 0 .../app/src/main/res/values/styles.xml | 0 .../app/src/profile/AndroidManifest.xml | 0 .../example/android/build.gradle | 0 .../example/android/gradle.properties | 0 .../gradle/wrapper/gradle-wrapper.properties | 0 .../example/android/settings.gradle | 0 .../notification_plugin/example/lib/main.dart | 0 .../notification_plugin/example/pubspec.yaml | 0 .../examples/notification_plugin/jnigen.yaml | 0 .../lib/com/example/notification_plugin.dart | 2 +- .../notification_plugin/lib/init.dart | 0 .../examples/notification_plugin/pubspec.yaml | 4 +- .../notification_plugin/src/CMakeLists.txt | 0 .../notification_plugin/src/dartjni.h | 0 .../src/notification_plugin.c | 2 +- .../examples/pdfbox_plugin/.gitignore | 2 +- .../examples/pdfbox_plugin/.metadata | 0 pkgs/jnigen/examples/pdfbox_plugin/README.md | 8 + .../pdfbox_plugin/analysis_options.yaml | 0 .../examples/pdfbox_plugin/android/.gitignore | 0 .../pdfbox_plugin/android/build.gradle | 0 .../pdfbox_plugin/android/settings.gradle | 0 .../android/src/main/AndroidManifest.xml | 0 .../pdfbox_plugin/dart_example/.gitignore | 0 .../pdfbox_plugin/dart_example/CHANGELOG.md | 0 .../pdfbox_plugin/dart_example/README.md | 0 .../dart_example/analysis_options.yaml | 0 .../dart_example/bin/pdf_info.dart | 2 +- .../pdfbox_plugin/dart_example/pubspec.yaml | 2 +- .../examples/pdfbox_plugin/example/.gitignore | 0 .../examples/pdfbox_plugin/example/README.md | 4 +- .../example/analysis_options.yaml | 0 .../pdfbox_plugin/example/android/.gitignore | 0 .../example/android/app/build.gradle | 0 .../android/app/src/debug/AndroidManifest.xml | 0 .../android/app/src/main/AndroidManifest.xml | 0 .../pdfbox_plugin_example/MainActivity.kt | 0 .../res/drawable-v21/launch_background.xml | 0 .../main/res/drawable/launch_background.xml | 0 .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin .../app/src/main/res/values-night/styles.xml | 0 .../app/src/main/res/values/styles.xml | 0 .../app/src/profile/AndroidManifest.xml | 0 .../example/android/build.gradle | 0 .../example/android/gradle.properties | 0 .../gradle/wrapper/gradle-wrapper.properties | 0 .../example/android/settings.gradle | 0 .../pdfbox_plugin/example/lib/main.dart | 2 +- .../pdfbox_plugin/example/linux/.gitignore | 0 .../example/linux/CMakeLists.txt | 0 .../example/linux/flutter/CMakeLists.txt | 0 .../flutter/generated_plugin_registrant.cc | 0 .../flutter/generated_plugin_registrant.h | 0 .../linux/flutter/generated_plugins.cmake | 0 .../pdfbox_plugin/example/linux/main.cc | 0 .../example/linux/my_application.cc | 0 .../example/linux/my_application.h | 0 .../pdfbox_plugin/example/pubspec.yaml | 0 .../pdfbox_plugin/example/windows/.gitignore | 0 .../example/windows/CMakeLists.txt | 0 .../example/windows/flutter/CMakeLists.txt | 0 .../flutter/generated_plugin_registrant.cc | 0 .../flutter/generated_plugin_registrant.h | 0 .../windows/flutter/generated_plugins.cmake | 0 .../example/windows/runner/CMakeLists.txt | 0 .../example/windows/runner/Runner.rc | 0 .../example/windows/runner/flutter_window.cpp | 0 .../example/windows/runner/flutter_window.h | 0 .../example/windows/runner/main.cpp | 0 .../example/windows/runner/resource.h | 0 .../windows/runner/resources/app_icon.ico | Bin .../windows/runner/runner.exe.manifest | 0 .../example/windows/runner/utils.cpp | 0 .../example/windows/runner/utils.h | 0 .../example/windows/runner/win32_window.cpp | 0 .../example/windows/runner/win32_window.h | 0 .../examples/pdfbox_plugin/jnigen.yaml | 0 .../examples/pdfbox_plugin/jnigen_full.yaml | 0 .../pdfbox_plugin/lib/third_party/init.dart | 0 .../org/apache/pdfbox/pdmodel.dart | 2 +- .../third_party/org/apache/pdfbox/text.dart | 2 +- .../pdfbox_plugin/linux/CMakeLists.txt | 0 .../examples/pdfbox_plugin/pubspec.yaml | 6 +- .../examples/pdfbox_plugin/src/CMakeLists.txt | 0 .../pdfbox_plugin/src/third_party/dartjni.h | 0 .../src/third_party/pdfbox_plugin.c | 2 +- .../pdfbox_plugin/tool/generate_bindings.dart | 2 +- .../examples/pdfbox_plugin/windows/.gitignore | 0 .../pdfbox_plugin/windows/CMakeLists.txt | 0 pkgs/{jni_gen => jnigen}/java/.gitignore | 0 pkgs/{jni_gen => jnigen}/java/README.md | 6 +- pkgs/{jni_gen => jnigen}/java/pom.xml | 4 +- .../dart_lang/jnigen}/apisummarizer/Main.java | 10 +- .../disasm/AsmAnnotatedElementVisitor.java | 4 +- .../disasm/AsmAnnotationVisitor.java | 4 +- .../apisummarizer/disasm/AsmClassVisitor.java | 8 +- .../apisummarizer/disasm/AsmConstants.java | 2 +- .../apisummarizer/disasm/AsmFieldVisitor.java | 6 +- .../disasm/AsmMethodVisitor.java | 6 +- .../apisummarizer/disasm/AsmSummarizer.java | 4 +- .../apisummarizer/disasm/TypeUtils.java | 8 +- .../doclet/AnnotationVisitor.java | 2 +- .../jnigen}/apisummarizer/doclet/AstEnv.java | 2 +- .../apisummarizer/doclet/ElementBuilders.java | 6 +- .../doclet/SummarizerDoclet.java | 4 +- .../doclet/SummarizerDocletBase.java | 12 +- .../apisummarizer/elements/ClassDecl.java | 2 +- .../apisummarizer/elements/DeclKind.java | 2 +- .../jnigen}/apisummarizer/elements/Field.java | 2 +- .../elements/JavaAnnotation.java | 2 +- .../elements/JavaDocComment.java | 2 +- .../apisummarizer/elements/Method.java | 2 +- .../apisummarizer/elements/Package.java | 2 +- .../jnigen}/apisummarizer/elements/Param.java | 2 +- .../apisummarizer/elements/TypeParam.java | 2 +- .../apisummarizer/elements/TypeUsage.java | 2 +- .../jnigen}/apisummarizer/util/Log.java | 2 +- .../apisummarizer/util/SkipException.java | 2 +- .../apisummarizer/util/StreamUtil.java | 2 +- .../apisummarizer/DocletSummarizerTests.java | 4 +- .../jnigen}/apisummarizer/TestDoclet.java | 6 +- .../test/resources/com/example/Example.java | 0 .../jni_gen.dart => jnigen/lib/jnigen.dart} | 4 +- .../lib/src/bindings/bindings.dart | 0 .../lib/src/bindings/c_bindings.dart | 6 +- .../lib/src/bindings/common.dart | 2 +- .../lib/src/bindings/dart_bindings.dart | 8 +- .../lib/src/bindings/preprocessor.dart | 6 +- .../lib/src/bindings/symbol_resolver.dart | 2 +- .../lib/src/config/config.dart | 10 +- .../lib/src/config/filters.dart | 2 +- .../lib/src/config/yaml_reader.dart | 0 .../lib/src/elements/elements.dart | 0 .../lib/src/elements/elements.g.dart | 0 .../lib/src/generate_bindings.dart | 0 .../lib/src/summary/summary.dart | 6 +- .../lib/src/tools/android_sdk_tools.dart | 0 .../lib/src/tools/build_summarizer.dart | 10 +- .../lib/src/tools/maven_tools.dart | 0 .../lib/src/tools/tools.dart | 0 .../lib/src/util/command_output.dart | 0 .../lib/src/util/find_package.dart | 0 .../lib/src/util/name_utils.dart | 2 +- .../lib/src/util/rename_conflict.dart | 0 .../lib/src/writers/writers.dart | 10 +- pkgs/{jni_gen => jnigen}/lib/tools.dart | 2 +- pkgs/{jni_gen => jnigen}/pubspec.yaml | 4 +- .../test/bindings_test.dart | 6 +- .../{jni_gen => jnigen}/test/config_test.dart | 2 +- .../test/jackson_core_test/.gitignore | 0 .../test/jackson_core_test/generate.dart | 2 +- .../generated_files_test.dart | 0 .../test/jackson_core_test/jnigen.yaml | 0 .../lib/com/fasterxml/jackson/core.dart | 2 +- .../third_party/lib/init.dart | 0 .../third_party/src/CMakeLists.txt | 0 .../third_party/src/dartjni.h | 0 .../third_party/src/jackson_core_test.c | 2 +- .../test/package_resolver_test.dart | 4 +- .../test/simple_package_test/.gitignore | 0 .../test/simple_package_test/generate.dart | 8 +- .../generated_files_test.dart | 0 .../com/github/dart_lang/jnigen}/pkg2/C2.java | 2 +- .../jnigen}/simple_package/Example.java | 2 +- .../com/github/dart_lang/jnigen}/pkg2.dart | 10 +- .../dart_lang/jnigen}/simple_package.dart | 44 ++-- .../test/simple_package_test/lib/init.dart | 0 .../simple_package_test/src/CMakeLists.txt | 0 .../test/simple_package_test/src/dartjni.h | 0 .../simple_package_test/src/simple_package.c | 189 ++++++++++++++++++ .../test/test_util/test_util.dart | 0 .../test/yaml_config_test.dart | 2 +- 251 files changed, 416 insertions(+), 448 deletions(-) delete mode 100644 pkgs/jni_gen/README.md delete mode 100644 pkgs/jni_gen/examples/notification_plugin/README.md delete mode 100644 pkgs/jni_gen/examples/pdfbox_plugin/README.md delete mode 100644 pkgs/jni_gen/test/simple_package_test/src/simple_package.c rename pkgs/{jni_gen => jnigen}/.gitignore (100%) rename pkgs/{jni_gen => jnigen}/LICENSE (100%) rename pkgs/{jni_gen => jnigen}/analysis_options.yaml (100%) rename pkgs/{jni_gen => jnigen}/bin/download_maven_jars.dart (85%) rename pkgs/{jni_gen/bin/jni_gen.dart => jnigen/bin/jnigen.dart} (89%) rename pkgs/{jni_gen => jnigen}/bin/setup.dart (83%) rename pkgs/{jni_gen => jnigen}/cmake/CMakeLists.txt.tmpl (100%) rename pkgs/{jni_gen => jnigen}/examples/README.md (71%) rename pkgs/{jni_gen => jnigen}/examples/in_app_java/.gitignore (100%) rename pkgs/{jni_gen => jnigen}/examples/in_app_java/.metadata (100%) rename pkgs/{jni_gen => jnigen}/examples/in_app_java/README.md (66%) rename pkgs/{jni_gen => jnigen}/examples/in_app_java/analysis_options.yaml (100%) rename pkgs/{jni_gen => jnigen}/examples/in_app_java/android/.gitignore (100%) rename pkgs/{jni_gen => jnigen}/examples/in_app_java/android/app/build.gradle (100%) rename pkgs/{jni_gen => jnigen}/examples/in_app_java/android/app/src/debug/AndroidManifest.xml (100%) rename pkgs/{jni_gen => jnigen}/examples/in_app_java/android/app/src/main/AndroidManifest.xml (100%) rename pkgs/{jni_gen => jnigen}/examples/in_app_java/android/app/src/main/java/com/example/in_app_java/AndroidUtils.java (100%) rename pkgs/{jni_gen => jnigen}/examples/in_app_java/android/app/src/main/kotlin/com/example/in_app_java/MainActivity.kt (100%) rename pkgs/{jni_gen => jnigen}/examples/in_app_java/android/app/src/main/res/drawable-v21/launch_background.xml (100%) rename pkgs/{jni_gen => jnigen}/examples/in_app_java/android/app/src/main/res/drawable/launch_background.xml (100%) rename pkgs/{jni_gen => jnigen}/examples/in_app_java/android/app/src/main/res/mipmap-hdpi/ic_launcher.png (100%) rename pkgs/{jni_gen => jnigen}/examples/in_app_java/android/app/src/main/res/mipmap-mdpi/ic_launcher.png (100%) rename pkgs/{jni_gen => jnigen}/examples/in_app_java/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png (100%) rename pkgs/{jni_gen => jnigen}/examples/in_app_java/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png (100%) rename pkgs/{jni_gen => jnigen}/examples/in_app_java/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png (100%) rename pkgs/{jni_gen => jnigen}/examples/in_app_java/android/app/src/main/res/values-night/styles.xml (100%) rename pkgs/{jni_gen => jnigen}/examples/in_app_java/android/app/src/main/res/values/styles.xml (100%) rename pkgs/{jni_gen => jnigen}/examples/in_app_java/android/app/src/profile/AndroidManifest.xml (100%) rename pkgs/{jni_gen => jnigen}/examples/in_app_java/android/build.gradle (100%) rename pkgs/{jni_gen => jnigen}/examples/in_app_java/android/gradle.properties (100%) rename pkgs/{jni_gen => jnigen}/examples/in_app_java/android/gradle/wrapper/gradle-wrapper.properties (100%) rename pkgs/{jni_gen => jnigen}/examples/in_app_java/android/settings.gradle (100%) rename pkgs/{jni_gen => jnigen}/examples/in_app_java/jnigen.yaml (100%) rename pkgs/{jni_gen => jnigen}/examples/in_app_java/lib/android_utils/com/example/in_app_java.dart (97%) rename pkgs/{jni_gen => jnigen}/examples/in_app_java/lib/android_utils/init.dart (100%) rename pkgs/{jni_gen => jnigen}/examples/in_app_java/lib/main.dart (100%) rename pkgs/{jni_gen => jnigen}/examples/in_app_java/pubspec.yaml (99%) rename pkgs/{jni_gen => jnigen}/examples/in_app_java/src/android_utils/CMakeLists.txt (100%) rename pkgs/{jni_gen => jnigen}/examples/in_app_java/src/android_utils/android_utils.c (97%) rename pkgs/{jni_gen => jnigen}/examples/in_app_java/src/android_utils/dartjni.h (100%) rename pkgs/{jni_gen => jnigen}/examples/in_app_java/tool/generate_bindings.dart (94%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/.gitignore (100%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/.metadata (100%) create mode 100644 pkgs/jnigen/examples/notification_plugin/README.md rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/analysis_options.yaml (100%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/android/.gitignore (100%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/android/build.gradle (100%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/android/settings.gradle (100%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/android/src/main/AndroidManifest.xml (100%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/android/src/main/java/com/example/notification_plugin/Notifications.java (100%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/example/.gitignore (100%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/example/README.md (100%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/example/analysis_options.yaml (100%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/example/android/.gitignore (100%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/example/android/app/build.gradle (100%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/example/android/app/src/debug/AndroidManifest.xml (100%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/example/android/app/src/main/AndroidManifest.xml (100%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/example/android/app/src/main/kotlin/com/example/notification_plugin_example/MainActivity.kt (100%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/example/android/app/src/main/res/drawable-v21/launch_background.xml (100%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/example/android/app/src/main/res/drawable/launch_background.xml (100%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png (100%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png (100%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png (100%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png (100%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png (100%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/example/android/app/src/main/res/values-night/styles.xml (100%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/example/android/app/src/main/res/values/styles.xml (100%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/example/android/app/src/profile/AndroidManifest.xml (100%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/example/android/build.gradle (100%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/example/android/gradle.properties (100%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/example/android/gradle/wrapper/gradle-wrapper.properties (100%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/example/android/settings.gradle (100%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/example/lib/main.dart (100%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/example/pubspec.yaml (100%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/jnigen.yaml (100%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/lib/com/example/notification_plugin.dart (97%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/lib/init.dart (100%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/pubspec.yaml (97%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/src/CMakeLists.txt (100%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/src/dartjni.h (100%) rename pkgs/{jni_gen => jnigen}/examples/notification_plugin/src/notification_plugin.c (98%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/.gitignore (96%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/.metadata (100%) create mode 100644 pkgs/jnigen/examples/pdfbox_plugin/README.md rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/analysis_options.yaml (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/android/.gitignore (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/android/build.gradle (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/android/settings.gradle (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/android/src/main/AndroidManifest.xml (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/dart_example/.gitignore (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/dart_example/CHANGELOG.md (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/dart_example/README.md (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/dart_example/analysis_options.yaml (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/dart_example/bin/pdf_info.dart (96%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/dart_example/pubspec.yaml (80%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/.gitignore (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/README.md (74%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/analysis_options.yaml (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/android/.gitignore (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/android/app/build.gradle (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/android/app/src/debug/AndroidManifest.xml (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/android/app/src/main/AndroidManifest.xml (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/android/app/src/main/kotlin/com/example/pdfbox_plugin_example/MainActivity.kt (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/android/app/src/main/res/drawable-v21/launch_background.xml (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/android/app/src/main/res/drawable/launch_background.xml (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/android/app/src/main/res/values-night/styles.xml (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/android/app/src/main/res/values/styles.xml (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/android/app/src/profile/AndroidManifest.xml (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/android/build.gradle (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/android/gradle.properties (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/android/gradle/wrapper/gradle-wrapper.properties (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/android/settings.gradle (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/lib/main.dart (98%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/linux/.gitignore (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/linux/CMakeLists.txt (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/linux/flutter/CMakeLists.txt (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/linux/flutter/generated_plugin_registrant.cc (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/linux/flutter/generated_plugin_registrant.h (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/linux/flutter/generated_plugins.cmake (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/linux/main.cc (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/linux/my_application.cc (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/linux/my_application.h (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/pubspec.yaml (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/windows/.gitignore (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/windows/CMakeLists.txt (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/windows/flutter/CMakeLists.txt (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/windows/flutter/generated_plugin_registrant.cc (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/windows/flutter/generated_plugin_registrant.h (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/windows/flutter/generated_plugins.cmake (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/windows/runner/CMakeLists.txt (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/windows/runner/Runner.rc (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/windows/runner/flutter_window.cpp (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/windows/runner/flutter_window.h (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/windows/runner/main.cpp (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/windows/runner/resource.h (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/windows/runner/resources/app_icon.ico (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/windows/runner/runner.exe.manifest (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/windows/runner/utils.cpp (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/windows/runner/utils.h (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/windows/runner/win32_window.cpp (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/example/windows/runner/win32_window.h (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/jnigen.yaml (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/jnigen_full.yaml (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/lib/third_party/init.dart (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/lib/third_party/org/apache/pdfbox/pdmodel.dart (99%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/lib/third_party/org/apache/pdfbox/text.dart (99%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/linux/CMakeLists.txt (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/pubspec.yaml (84%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/src/CMakeLists.txt (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/src/third_party/dartjni.h (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/src/third_party/pdfbox_plugin.c (99%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/tool/generate_bindings.dart (97%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/windows/.gitignore (100%) rename pkgs/{jni_gen => jnigen}/examples/pdfbox_plugin/windows/CMakeLists.txt (100%) rename pkgs/{jni_gen => jnigen}/java/.gitignore (100%) rename pkgs/{jni_gen => jnigen}/java/README.md (85%) rename pkgs/{jni_gen => jnigen}/java/pom.xml (94%) rename pkgs/{jni_gen/java/src/main/java/com/github/dart_lang/jni_gen => jnigen/java/src/main/java/com/github/dart_lang/jnigen}/apisummarizer/Main.java (95%) rename pkgs/{jni_gen/java/src/main/java/com/github/dart_lang/jni_gen => jnigen/java/src/main/java/com/github/dart_lang/jnigen}/apisummarizer/disasm/AsmAnnotatedElementVisitor.java (86%) rename pkgs/{jni_gen/java/src/main/java/com/github/dart_lang/jni_gen => jnigen/java/src/main/java/com/github/dart_lang/jnigen}/apisummarizer/disasm/AsmAnnotationVisitor.java (94%) rename pkgs/{jni_gen/java/src/main/java/com/github/dart_lang/jni_gen => jnigen/java/src/main/java/com/github/dart_lang/jnigen}/apisummarizer/disasm/AsmClassVisitor.java (94%) rename pkgs/{jni_gen/java/src/main/java/com/github/dart_lang/jni_gen => jnigen/java/src/main/java/com/github/dart_lang/jnigen}/apisummarizer/disasm/AsmConstants.java (84%) rename pkgs/{jni_gen/java/src/main/java/com/github/dart_lang/jni_gen => jnigen/java/src/main/java/com/github/dart_lang/jnigen}/apisummarizer/disasm/AsmFieldVisitor.java (80%) rename pkgs/{jni_gen/java/src/main/java/com/github/dart_lang/jni_gen => jnigen/java/src/main/java/com/github/dart_lang/jnigen}/apisummarizer/disasm/AsmMethodVisitor.java (90%) rename pkgs/{jni_gen/java/src/main/java/com/github/dart_lang/jni_gen => jnigen/java/src/main/java/com/github/dart_lang/jnigen}/apisummarizer/disasm/AsmSummarizer.java (95%) rename pkgs/{jni_gen/java/src/main/java/com/github/dart_lang/jni_gen => jnigen/java/src/main/java/com/github/dart_lang/jnigen}/apisummarizer/disasm/TypeUtils.java (92%) rename pkgs/{jni_gen/java/src/main/java/com/github/dart_lang/jni_gen => jnigen/java/src/main/java/com/github/dart_lang/jnigen}/apisummarizer/doclet/AnnotationVisitor.java (97%) rename pkgs/{jni_gen/java/src/main/java/com/github/dart_lang/jni_gen => jnigen/java/src/main/java/com/github/dart_lang/jnigen}/apisummarizer/doclet/AstEnv.java (93%) rename pkgs/{jni_gen/java/src/main/java/com/github/dart_lang/jni_gen => jnigen/java/src/main/java/com/github/dart_lang/jnigen}/apisummarizer/doclet/ElementBuilders.java (97%) rename pkgs/{jni_gen/java/src/main/java/com/github/dart_lang/jni_gen => jnigen/java/src/main/java/com/github/dart_lang/jnigen}/apisummarizer/doclet/SummarizerDoclet.java (81%) rename pkgs/{jni_gen/java/src/main/java/com/github/dart_lang/jni_gen => jnigen/java/src/main/java/com/github/dart_lang/jnigen}/apisummarizer/doclet/SummarizerDocletBase.java (92%) rename pkgs/{jni_gen/java/src/main/java/com/github/dart_lang/jni_gen => jnigen/java/src/main/java/com/github/dart_lang/jnigen}/apisummarizer/elements/ClassDecl.java (96%) rename pkgs/{jni_gen/java/src/main/java/com/github/dart_lang/jni_gen => jnigen/java/src/main/java/com/github/dart_lang/jnigen}/apisummarizer/elements/DeclKind.java (82%) rename pkgs/{jni_gen/java/src/main/java/com/github/dart_lang/jni_gen => jnigen/java/src/main/java/com/github/dart_lang/jnigen}/apisummarizer/elements/Field.java (90%) rename pkgs/{jni_gen/java/src/main/java/com/github/dart_lang/jni_gen => jnigen/java/src/main/java/com/github/dart_lang/jnigen}/apisummarizer/elements/JavaAnnotation.java (90%) rename pkgs/{jni_gen/java/src/main/java/com/github/dart_lang/jni_gen => jnigen/java/src/main/java/com/github/dart_lang/jnigen}/apisummarizer/elements/JavaDocComment.java (88%) rename pkgs/{jni_gen/java/src/main/java/com/github/dart_lang/jni_gen => jnigen/java/src/main/java/com/github/dart_lang/jnigen}/apisummarizer/elements/Method.java (91%) rename pkgs/{jni_gen/java/src/main/java/com/github/dart_lang/jni_gen => jnigen/java/src/main/java/com/github/dart_lang/jnigen}/apisummarizer/elements/Package.java (81%) rename pkgs/{jni_gen/java/src/main/java/com/github/dart_lang/jni_gen => jnigen/java/src/main/java/com/github/dart_lang/jnigen}/apisummarizer/elements/Param.java (87%) rename pkgs/{jni_gen/java/src/main/java/com/github/dart_lang/jni_gen => jnigen/java/src/main/java/com/github/dart_lang/jnigen}/apisummarizer/elements/TypeParam.java (84%) rename pkgs/{jni_gen/java/src/main/java/com/github/dart_lang/jni_gen => jnigen/java/src/main/java/com/github/dart_lang/jnigen}/apisummarizer/elements/TypeUsage.java (96%) rename pkgs/{jni_gen/java/src/main/java/com/github/dart_lang/jni_gen => jnigen/java/src/main/java/com/github/dart_lang/jnigen}/apisummarizer/util/Log.java (94%) rename pkgs/{jni_gen/java/src/main/java/com/github/dart_lang/jni_gen => jnigen/java/src/main/java/com/github/dart_lang/jnigen}/apisummarizer/util/SkipException.java (89%) rename pkgs/{jni_gen/java/src/main/java/com/github/dart_lang/jni_gen => jnigen/java/src/main/java/com/github/dart_lang/jnigen}/apisummarizer/util/StreamUtil.java (92%) rename pkgs/{jni_gen/java/src/test/java/com/github/dart_lang/jni_gen => jnigen/java/src/test/java/com/github/dart_lang/jnigen}/apisummarizer/DocletSummarizerTests.java (94%) rename pkgs/{jni_gen/java/src/test/java/com/github/dart_lang/jni_gen => jnigen/java/src/test/java/com/github/dart_lang/jnigen}/apisummarizer/TestDoclet.java (72%) rename pkgs/{jni_gen => jnigen}/java/src/test/resources/com/example/Example.java (100%) rename pkgs/{jni_gen/lib/jni_gen.dart => jnigen/lib/jnigen.dart} (82%) rename pkgs/{jni_gen => jnigen}/lib/src/bindings/bindings.dart (100%) rename pkgs/{jni_gen => jnigen}/lib/src/bindings/c_bindings.dart (98%) rename pkgs/{jni_gen => jnigen}/lib/src/bindings/common.dart (97%) rename pkgs/{jni_gen => jnigen}/lib/src/bindings/dart_bindings.dart (98%) rename pkgs/{jni_gen => jnigen}/lib/src/bindings/preprocessor.dart (95%) rename pkgs/{jni_gen => jnigen}/lib/src/bindings/symbol_resolver.dart (98%) rename pkgs/{jni_gen => jnigen}/lib/src/config/config.dart (98%) rename pkgs/{jni_gen => jnigen}/lib/src/config/filters.dart (98%) rename pkgs/{jni_gen => jnigen}/lib/src/config/yaml_reader.dart (100%) rename pkgs/{jni_gen => jnigen}/lib/src/elements/elements.dart (100%) rename pkgs/{jni_gen => jnigen}/lib/src/elements/elements.g.dart (100%) rename pkgs/{jni_gen => jnigen}/lib/src/generate_bindings.dart (100%) rename pkgs/{jni_gen => jnigen}/lib/src/summary/summary.dart (93%) rename pkgs/{jni_gen => jnigen}/lib/src/tools/android_sdk_tools.dart (100%) rename pkgs/{jni_gen => jnigen}/lib/src/tools/build_summarizer.dart (86%) rename pkgs/{jni_gen => jnigen}/lib/src/tools/maven_tools.dart (100%) rename pkgs/{jni_gen => jnigen}/lib/src/tools/tools.dart (100%) rename pkgs/{jni_gen => jnigen}/lib/src/util/command_output.dart (100%) rename pkgs/{jni_gen => jnigen}/lib/src/util/find_package.dart (100%) rename pkgs/{jni_gen => jnigen}/lib/src/util/name_utils.dart (94%) rename pkgs/{jni_gen => jnigen}/lib/src/util/rename_conflict.dart (100%) rename pkgs/{jni_gen => jnigen}/lib/src/writers/writers.dart (94%) rename pkgs/{jni_gen => jnigen}/lib/tools.dart (91%) rename pkgs/{jni_gen => jnigen}/pubspec.yaml (90%) rename pkgs/{jni_gen => jnigen}/test/bindings_test.dart (94%) rename pkgs/{jni_gen => jnigen}/test/config_test.dart (97%) rename pkgs/{jni_gen => jnigen}/test/jackson_core_test/.gitignore (100%) rename pkgs/{jni_gen => jnigen}/test/jackson_core_test/generate.dart (98%) rename pkgs/{jni_gen => jnigen}/test/jackson_core_test/generated_files_test.dart (100%) rename pkgs/{jni_gen => jnigen}/test/jackson_core_test/jnigen.yaml (100%) rename pkgs/{jni_gen => jnigen}/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core.dart (99%) rename pkgs/{jni_gen => jnigen}/test/jackson_core_test/third_party/lib/init.dart (100%) rename pkgs/{jni_gen => jnigen}/test/jackson_core_test/third_party/src/CMakeLists.txt (100%) rename pkgs/{jni_gen => jnigen}/test/jackson_core_test/third_party/src/dartjni.h (100%) rename pkgs/{jni_gen => jnigen}/test/jackson_core_test/third_party/src/jackson_core_test.c (99%) rename pkgs/{jni_gen => jnigen}/test/package_resolver_test.dart (95%) rename pkgs/{jni_gen => jnigen}/test/simple_package_test/.gitignore (100%) rename pkgs/{jni_gen => jnigen}/test/simple_package_test/generate.dart (88%) rename pkgs/{jni_gen => jnigen}/test/simple_package_test/generated_files_test.dart (100%) rename pkgs/{jni_gen/test/simple_package_test/java/com/github/dart_lang/jni_gen => jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen}/pkg2/C2.java (56%) rename pkgs/{jni_gen/test/simple_package_test/java/com/github/dart_lang/jni_gen => jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen}/simple_package/Example.java (93%) rename pkgs/{jni_gen/test/simple_package_test/lib/com/github/dart_lang/jni_gen => jnigen/test/simple_package_test/lib/com/github/dart_lang/jnigen}/pkg2.dart (80%) rename pkgs/{jni_gen/test/simple_package_test/lib/com/github/dart_lang/jni_gen => jnigen/test/simple_package_test/lib/com/github/dart_lang/jnigen}/simple_package.dart (74%) rename pkgs/{jni_gen => jnigen}/test/simple_package_test/lib/init.dart (100%) rename pkgs/{jni_gen => jnigen}/test/simple_package_test/src/CMakeLists.txt (100%) rename pkgs/{jni_gen => jnigen}/test/simple_package_test/src/dartjni.h (100%) create mode 100644 pkgs/jnigen/test/simple_package_test/src/simple_package.c rename pkgs/{jni_gen => jnigen}/test/test_util/test_util.dart (100%) rename pkgs/{jni_gen => jnigen}/test/yaml_config_test.dart (98%) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 9bae1257f..80dba5c1a 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -25,11 +25,11 @@ jobs: with: args: "--set-exit-if-changed" - analyze_jni_gen: + analyze_jnigen: runs-on: ubuntu-latest defaults: run: - working-directory: ./pkgs/jni_gen + working-directory: ./pkgs/jnigen strategy: fail-fast: false matrix: @@ -49,12 +49,12 @@ jobs: run: dart analyze --fatal-infos if: always() && steps.install.outcome == 'success' - test_jni_gen: - needs: analyze_jni_gen + test_jnigen: + needs: analyze_jnigen runs-on: ${{ matrix.os }} defaults: run: - working-directory: ./pkgs/jni_gen + working-directory: ./pkgs/jnigen strategy: fail-fast: false matrix: @@ -83,19 +83,19 @@ jobs: uses: coverallsapp/github-action@v1.1.2 with: github-token: ${{ secrets.GITHUB_TOKEN }} - flag-name: jni_gen_tests + flag-name: jnigen_tests parallel: true - path-to-lcov: ./pkgs/jni_gen/coverage/lcov.info + path-to-lcov: ./pkgs/jnigen/coverage/lcov.info ## TODO: More minimal test on windows after fixing dev dependency. ## i.e do not rerun analyze and format steps, and do not require flutter. - ## IssueRef: https://github.com/dart-lang/jni_gen/issues/15 + ## IssueRef: https://github.com/dart-lang/jnigen/issues/15 test_summarizer: runs-on: ubuntu-latest defaults: run: - working-directory: ./pkgs/jni_gen/java + working-directory: ./pkgs/jnigen/java steps: - uses: actions/checkout@v2 - uses: actions/setup-java@v2 @@ -216,7 +216,7 @@ jobs: runs-on: ubuntu-latest defaults: run: - working-directory: ./pkgs/jni_gen/examples/notification_plugin + working-directory: ./pkgs/jnigen/examples/notification_plugin steps: - uses: actions/checkout@v3 - uses: actions/setup-java@v2 @@ -231,9 +231,9 @@ jobs: - run: flutter pub get - run: flutter analyze - run: flutter build apk - working-directory: ./pkgs/jni_gen/examples/notification_plugin/example + working-directory: ./pkgs/jnigen/examples/notification_plugin/example - name: re-generate bindings - run: flutter pub run jni_gen -Ddart_root=_dart -Dc_root=_c --config jnigen.yaml + run: flutter pub run jnigen -Ddart_root=_dart -Dc_root=_c --config jnigen.yaml - name: compare generated dart bindings run: diff -qr lib/ _dart - name: compare generated C bindings @@ -243,7 +243,7 @@ jobs: runs-on: ubuntu-latest defaults: run: - working-directory: ./pkgs/jni_gen/examples/in_app_java + working-directory: ./pkgs/jnigen/examples/in_app_java steps: - uses: actions/checkout@v3 - uses: actions/setup-java@v2 @@ -259,14 +259,14 @@ jobs: - run: flutter analyze - run: flutter build apk - name: re-generate bindings - run: flutter pub run jni_gen -Ddart_root=_dart -Dc_root=_c --config jnigen.yaml + run: flutter pub run jnigen -Ddart_root=_dart -Dc_root=_c --config jnigen.yaml - name: compare generated dart bindings run: diff -qr lib/android_utils _dart - name: compare generated C bindings run: diff -qr src/android_utils _c coveralls_finish: - needs: [test_jni_gen, test_jni] + needs: [test_jnigen, test_jni] runs-on: ubuntu-latest steps: - name: Coveralls finished @@ -279,7 +279,7 @@ jobs: runs-on: ubuntu-latest defaults: run: - working-directory: ./pkgs/jni_gen/examples/pdfbox_plugin + working-directory: ./pkgs/jnigen/examples/pdfbox_plugin steps: - uses: actions/checkout@v3 - uses: subosito/flutter-action@v2 @@ -298,13 +298,13 @@ jobs: - run: dart pub get - name: Generate bindings run: | - dart run jni_gen -Dc_root=_c -Ddart_root=_dart --config jnigen.yaml + dart run jnigen -Dc_root=_c -Ddart_root=_dart --config jnigen.yaml - name: Compare generated bindings run: | diff -qr _c src/ diff -qr _dart lib/third_party - name: Generate full bindings - run: dart run jni_gen --config jnigen_full.yaml + run: dart run jnigen --config jnigen_full.yaml - name: Analyze generated bindings run: | flutter pub get # dart-analyze errors on flutter example @@ -315,10 +315,10 @@ jobs: dart run jni:setup && dart run jni:setup -p pdfbox_plugin wget 'https://dart.dev/guides/language/specifications/DartLangSpec-v2.2.pdf' dart run bin/pdf_info.dart DartLangSpec-v2.2.pdf - working-directory: ./pkgs/jni_gen/examples/pdfbox_plugin/dart_example + working-directory: ./pkgs/jnigen/examples/pdfbox_plugin/dart_example - name: Build flutter example for pdfbox_plugin run: | flutter pub get flutter build linux - working-directory: ./pkgs/jni_gen/examples/pdfbox_plugin/example + working-directory: ./pkgs/jnigen/examples/pdfbox_plugin/example diff --git a/pkgs/jni/README.md b/pkgs/jni/README.md index 73f122a9b..12d41fbf3 100644 --- a/pkgs/jni/README.md +++ b/pkgs/jni/README.md @@ -1,6 +1,6 @@ # jni (experimental module) -This is a utility library to access JNI from Dart / Flutter code, intended as a supplement for `jnigen` code generator, as well as provide the common base components (such as managing the JVM instance) to the code generated by `jni_gen`. +This is a utility library to access JNI from Dart / Flutter code, intended as a supplement for `jnigen` code generator, as well as provide the common base components (such as managing the JVM instance) to the code generated by `jnigen`. This library contains: @@ -14,9 +14,9 @@ This library contains: * Some helper classes and functions to simplify one-off uses (`JniObject` and `JniClass` intended for calling functions by specifying the name and arguments. It will reduce some boilerplate when you're debugging. Note: this API is slightly incomplete). -This is intended for one-off / debugging uses of JNI, as well as providing a base library for code generated by jni_gen. +This is intended for one-off / debugging uses of JNI, as well as providing a base library for code generated by jnigen. -__To interface a complete java library, look forward for `jni_gen`.__ +__To interface a complete java library, look forward for `jnigen`.__ ## Platform support The focus of this project is Flutter Android, since Flutter Android apps already have a JVM, and JNI enables interop with existing Java code and Android Platform APIs. This project also (partially) supports Linux desktop by spawning a JVM through JNI. @@ -29,9 +29,9 @@ The test/ directory contains files with comments explaining the basics of this m Using this library assumes some familiarity with JNI - it's threading model and object references, among other things. -## jni_gen +## jnigen -This library is a part of `jni_gen` - a 2022 GSoC project. +This library is a part of `jnigen` - a 2022 GSoC project. -The broader aim of jni_gen is making Java APIs accessible from dart in an idiomatic way. +The broader aim of jnigen is making Java APIs accessible from dart in an idiomatic way. diff --git a/pkgs/jni/bin/setup.dart b/pkgs/jni/bin/setup.dart index c4befc633..1e7344a35 100644 --- a/pkgs/jni/bin/setup.dart +++ b/pkgs/jni/bin/setup.dart @@ -37,7 +37,7 @@ class CommandRunner { int? time; // TODO: time commands // TODO: Run all commands in single shell instance - // IssueRef: https://github.com/dart-lang/jni_gen/issues/14 + // IssueRef: https://github.com/dart-lang/jnigen/issues/14 Future run( String exec, List args, String workingDir) async { if (printCmds) { diff --git a/pkgs/jni/lib/src/extensions.dart b/pkgs/jni/lib/src/extensions.dart index 995eb58b3..281460ea6 100644 --- a/pkgs/jni/lib/src/extensions.dart +++ b/pkgs/jni/lib/src/extensions.dart @@ -67,7 +67,7 @@ extension AdditionalJniEnvMethods on Pointer { // TODO: Doing this every time is expensive. // Should lookup and cache method reference, // and keep it alive by keeping a reference to Exception class. - // IssueRef: https://github.com/dart-lang/jni_gen/issues/13 + // IssueRef: https://github.com/dart-lang/jnigen/issues/13 final ecls = GetObjectClass(exc); final toStr = GetMethodID(ecls, _toString, _toStringSig); final jstr = CallObjectMethod(exc, toStr); diff --git a/pkgs/jni_gen/README.md b/pkgs/jni_gen/README.md deleted file mode 100644 index 1ba01931c..000000000 --- a/pkgs/jni_gen/README.md +++ /dev/null @@ -1,32 +0,0 @@ -# Experimental generator for FFI+JNI bindings. - -This package will generate JNI code to invoke Java from C, and Dart FFI bindings to invoke this C code. -This enables calling Java code from Dart. - -This is a GSoC 2022 project. - -Currently this package is highly experimental and proof-of-concept. See `test/jackson_core_test` for an example of generating bindings for a library. It is possible to specify some dependencies to be downloaded automatically through `maven`. - -## Basics -### Running `jni_gen` -There are 2 ways to use `jni_gen`: - -* Import `package:jni_gen/jni_gen.dart` from a script in `tool/` directory of your project. -* Run as command line tool with a YAML config. - -Both approaches are almost identical. If using YAML, it's possible to selectively override configuration properties with command line, using `-Dproperty.name=value` syntax. - -### Generated bindings -Generated bindings will consist of 2 parts - C bindings which call JNI, and Dart bindings which call C bindings. The generated bindings will depend on `package:jni` for instantiating / obtaining a JVM instance. - -The following properties must be specified in yaml. - -* `c_root`: root folder to write generated C bindings. -* `dart_root`: root folder to write generated Dart bindings (see below). -* `library_name`: specifies name of the generated library in CMakeFiles.txt. - -The generated C file has to be linked to JNI libraries. Therefore a CMake configuration is always generated which builds the generated code as shared library. The `init.dart` in generated dart code loads the library on first time a method is accessed. On dart standalone, it will be loaded from the same directory specified in `Jni.spawn` call. - -## Examples -Few runnable examples are provided in [examples/](examples/) directory. These directories do not include generated code. Generate the bindings by running `dart run jni_gen --config jnigen.yaml` in the example project root. See the respective READMEs for more details. - diff --git a/pkgs/jni_gen/examples/notification_plugin/README.md b/pkgs/jni_gen/examples/notification_plugin/README.md deleted file mode 100644 index 1fcccdcbd..000000000 --- a/pkgs/jni_gen/examples/notification_plugin/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# notification_plugin - -Example of android plugin project with jni_gen. - -This plugin project contains [custom code](android/src/main/java/com/example/notification_plugin) which uses the Android libraries. The bindings are generated using [jnigen config](jnigen.yaml) and then used in [flutter example](example/lib/main.dart), with help of `package:jni` APIs. - -The command to regenerate JNI bindings is: -``` -flutter run jni_gen --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 jni_gen. This is the equivalent of Gradle Sync in Android Studio, and enables `jni_gen` 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/jni_gen/examples/pdfbox_plugin/README.md b/pkgs/jni_gen/examples/pdfbox_plugin/README.md deleted file mode 100644 index 5fa64ea67..000000000 --- a/pkgs/jni_gen/examples/pdfbox_plugin/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# pdfbox_plugin - -Example of a JNI plugin using `jni_gen` to auto-generate bindings for PDFBox java library. - -Bindings can be generated by running `dart run jni_gen --config jnigen.yaml`. Required source code and JARs will be downloaded using maven (requires `mvn` command). - -`jni_gen` is also available as an API which tooling scripts can use. See `tool/generate_bindings.dart` for the script equivalent of the YAML file. - diff --git a/pkgs/jni_gen/test/simple_package_test/src/simple_package.c b/pkgs/jni_gen/test/simple_package_test/src/simple_package.c deleted file mode 100644 index b19daa69d..000000000 --- a/pkgs/jni_gen/test/simple_package_test/src/simple_package.c +++ /dev/null @@ -1,189 +0,0 @@ -// Autogenerated by jni_gen. DO NOT EDIT! - -#include -#include "jni.h" -#include "dartjni.h" - -thread_local JNIEnv *jniEnv; -struct jni_context jni; - -struct jni_context (*context_getter)(void); -JNIEnv *(*env_getter)(void); - -void setJniGetters(struct jni_context (*cg)(void), - JNIEnv *(*eg)(void)) { - context_getter = cg; - env_getter = eg; -} - -// com.github.dart_lang.jni_gen.simple_package.Example -jclass _c_com_github_dart_lang_jni_gen_simple_package_Example = NULL; - -jmethodID _m_com_github_dart_lang_jni_gen_simple_package_Example_ctor = NULL; -FFI_PLUGIN_EXPORT -jobject com_github_dart_lang_jni_gen_simple_package_Example_ctor() { - load_env(); - load_class_gr(&_c_com_github_dart_lang_jni_gen_simple_package_Example, "com/github/dart_lang/jni_gen/simple_package/Example"); - load_method(_c_com_github_dart_lang_jni_gen_simple_package_Example, &_m_com_github_dart_lang_jni_gen_simple_package_Example_ctor, "", "()V"); - jobject _result = (*jniEnv)->NewObject(jniEnv, _c_com_github_dart_lang_jni_gen_simple_package_Example, _m_com_github_dart_lang_jni_gen_simple_package_Example_ctor); - return to_global_ref(_result); -} - -jmethodID _m_com_github_dart_lang_jni_gen_simple_package_Example_getAux = NULL; -FFI_PLUGIN_EXPORT -jobject com_github_dart_lang_jni_gen_simple_package_Example_getAux() { - load_env(); - load_class_gr(&_c_com_github_dart_lang_jni_gen_simple_package_Example, "com/github/dart_lang/jni_gen/simple_package/Example"); - load_static_method(_c_com_github_dart_lang_jni_gen_simple_package_Example, &_m_com_github_dart_lang_jni_gen_simple_package_Example_getAux, "getAux", "()Lcom/github/dart_lang/jni_gen/simple_package/Example$Aux;"); - jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_com_github_dart_lang_jni_gen_simple_package_Example, _m_com_github_dart_lang_jni_gen_simple_package_Example_getAux); - return to_global_ref(_result); -} - -jmethodID _m_com_github_dart_lang_jni_gen_simple_package_Example_addInts = NULL; -FFI_PLUGIN_EXPORT -int32_t com_github_dart_lang_jni_gen_simple_package_Example_addInts(int32_t a, int32_t b) { - load_env(); - load_class_gr(&_c_com_github_dart_lang_jni_gen_simple_package_Example, "com/github/dart_lang/jni_gen/simple_package/Example"); - load_static_method(_c_com_github_dart_lang_jni_gen_simple_package_Example, &_m_com_github_dart_lang_jni_gen_simple_package_Example_addInts, "addInts", "(II)I"); - int32_t _result = (*jniEnv)->CallStaticIntMethod(jniEnv, _c_com_github_dart_lang_jni_gen_simple_package_Example, _m_com_github_dart_lang_jni_gen_simple_package_Example_addInts, a, b); - return _result; -} - -jmethodID _m_com_github_dart_lang_jni_gen_simple_package_Example_getSelf = NULL; -FFI_PLUGIN_EXPORT -jobject com_github_dart_lang_jni_gen_simple_package_Example_getSelf(jobject self_) { - load_env(); - load_class_gr(&_c_com_github_dart_lang_jni_gen_simple_package_Example, "com/github/dart_lang/jni_gen/simple_package/Example"); - load_method(_c_com_github_dart_lang_jni_gen_simple_package_Example, &_m_com_github_dart_lang_jni_gen_simple_package_Example_getSelf, "getSelf", "()Lcom/github/dart_lang/jni_gen/simple_package/Example;"); - jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_github_dart_lang_jni_gen_simple_package_Example_getSelf); - return to_global_ref(_result); -} - -jmethodID _m_com_github_dart_lang_jni_gen_simple_package_Example_getNum = NULL; -FFI_PLUGIN_EXPORT -int32_t com_github_dart_lang_jni_gen_simple_package_Example_getNum(jobject self_) { - load_env(); - load_class_gr(&_c_com_github_dart_lang_jni_gen_simple_package_Example, "com/github/dart_lang/jni_gen/simple_package/Example"); - load_method(_c_com_github_dart_lang_jni_gen_simple_package_Example, &_m_com_github_dart_lang_jni_gen_simple_package_Example_getNum, "getNum", "()I"); - int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_com_github_dart_lang_jni_gen_simple_package_Example_getNum); - return _result; -} - -jmethodID _m_com_github_dart_lang_jni_gen_simple_package_Example_setNum = NULL; -FFI_PLUGIN_EXPORT -void com_github_dart_lang_jni_gen_simple_package_Example_setNum(jobject self_, int32_t num) { - load_env(); - load_class_gr(&_c_com_github_dart_lang_jni_gen_simple_package_Example, "com/github/dart_lang/jni_gen/simple_package/Example"); - load_method(_c_com_github_dart_lang_jni_gen_simple_package_Example, &_m_com_github_dart_lang_jni_gen_simple_package_Example_setNum, "setNum", "(I)V"); - (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_com_github_dart_lang_jni_gen_simple_package_Example_setNum, num); -} - -jfieldID _f_com_github_dart_lang_jni_gen_simple_package_Example_aux = NULL; -jobject get_com_github_dart_lang_jni_gen_simple_package_Example_aux() { - load_env(); - load_class_gr(&_c_com_github_dart_lang_jni_gen_simple_package_Example, "com/github/dart_lang/jni_gen/simple_package/Example"); - load_static_field(_c_com_github_dart_lang_jni_gen_simple_package_Example, &_f_com_github_dart_lang_jni_gen_simple_package_Example_aux, "aux","Lcom/github/dart_lang/jni_gen/simple_package/Example$Aux;"); - return to_global_ref((*jniEnv)->GetStaticObjectField(jniEnv, _c_com_github_dart_lang_jni_gen_simple_package_Example, _f_com_github_dart_lang_jni_gen_simple_package_Example_aux)); -} - -void set_com_github_dart_lang_jni_gen_simple_package_Example_aux(jobject value) { - load_env(); - load_class_gr(&_c_com_github_dart_lang_jni_gen_simple_package_Example, "com/github/dart_lang/jni_gen/simple_package/Example"); - load_static_field(_c_com_github_dart_lang_jni_gen_simple_package_Example, &_f_com_github_dart_lang_jni_gen_simple_package_Example_aux, "aux","Lcom/github/dart_lang/jni_gen/simple_package/Example$Aux;"); - ((*jniEnv)->SetStaticObjectField(jniEnv, _c_com_github_dart_lang_jni_gen_simple_package_Example, _f_com_github_dart_lang_jni_gen_simple_package_Example_aux, value)); -} - - -jfieldID _f_com_github_dart_lang_jni_gen_simple_package_Example_num = NULL; -int32_t get_com_github_dart_lang_jni_gen_simple_package_Example_num() { - load_env(); - load_class_gr(&_c_com_github_dart_lang_jni_gen_simple_package_Example, "com/github/dart_lang/jni_gen/simple_package/Example"); - load_static_field(_c_com_github_dart_lang_jni_gen_simple_package_Example, &_f_com_github_dart_lang_jni_gen_simple_package_Example_num, "num","I"); - return ((*jniEnv)->GetStaticIntField(jniEnv, _c_com_github_dart_lang_jni_gen_simple_package_Example, _f_com_github_dart_lang_jni_gen_simple_package_Example_num)); -} - -void set_com_github_dart_lang_jni_gen_simple_package_Example_num(int32_t value) { - load_env(); - load_class_gr(&_c_com_github_dart_lang_jni_gen_simple_package_Example, "com/github/dart_lang/jni_gen/simple_package/Example"); - load_static_field(_c_com_github_dart_lang_jni_gen_simple_package_Example, &_f_com_github_dart_lang_jni_gen_simple_package_Example_num, "num","I"); - ((*jniEnv)->SetStaticIntField(jniEnv, _c_com_github_dart_lang_jni_gen_simple_package_Example, _f_com_github_dart_lang_jni_gen_simple_package_Example_num, value)); -} - - -// com.github.dart_lang.jni_gen.simple_package.Example$Aux -jclass _c_com_github_dart_lang_jni_gen_simple_package_Example__Aux = NULL; - -jmethodID _m_com_github_dart_lang_jni_gen_simple_package_Example__Aux_ctor = NULL; -FFI_PLUGIN_EXPORT -jobject com_github_dart_lang_jni_gen_simple_package_Example__Aux_ctor(uint8_t value) { - load_env(); - load_class_gr(&_c_com_github_dart_lang_jni_gen_simple_package_Example__Aux, "com/github/dart_lang/jni_gen/simple_package/Example$Aux"); - load_method(_c_com_github_dart_lang_jni_gen_simple_package_Example__Aux, &_m_com_github_dart_lang_jni_gen_simple_package_Example__Aux_ctor, "", "(Z)V"); - jobject _result = (*jniEnv)->NewObject(jniEnv, _c_com_github_dart_lang_jni_gen_simple_package_Example__Aux, _m_com_github_dart_lang_jni_gen_simple_package_Example__Aux_ctor, value); - return to_global_ref(_result); -} - -jmethodID _m_com_github_dart_lang_jni_gen_simple_package_Example__Aux_getValue = NULL; -FFI_PLUGIN_EXPORT -uint8_t com_github_dart_lang_jni_gen_simple_package_Example__Aux_getValue(jobject self_) { - load_env(); - load_class_gr(&_c_com_github_dart_lang_jni_gen_simple_package_Example__Aux, "com/github/dart_lang/jni_gen/simple_package/Example$Aux"); - load_method(_c_com_github_dart_lang_jni_gen_simple_package_Example__Aux, &_m_com_github_dart_lang_jni_gen_simple_package_Example__Aux_getValue, "getValue", "()Z"); - uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_github_dart_lang_jni_gen_simple_package_Example__Aux_getValue); - return _result; -} - -jmethodID _m_com_github_dart_lang_jni_gen_simple_package_Example__Aux_setValue = NULL; -FFI_PLUGIN_EXPORT -void com_github_dart_lang_jni_gen_simple_package_Example__Aux_setValue(jobject self_, uint8_t value) { - load_env(); - load_class_gr(&_c_com_github_dart_lang_jni_gen_simple_package_Example__Aux, "com/github/dart_lang/jni_gen/simple_package/Example$Aux"); - load_method(_c_com_github_dart_lang_jni_gen_simple_package_Example__Aux, &_m_com_github_dart_lang_jni_gen_simple_package_Example__Aux_setValue, "setValue", "(Z)V"); - (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_com_github_dart_lang_jni_gen_simple_package_Example__Aux_setValue, value); -} - -jfieldID _f_com_github_dart_lang_jni_gen_simple_package_Example__Aux_value = NULL; -uint8_t get_com_github_dart_lang_jni_gen_simple_package_Example__Aux_value(jobject self_) { - load_env(); - load_class_gr(&_c_com_github_dart_lang_jni_gen_simple_package_Example__Aux, "com/github/dart_lang/jni_gen/simple_package/Example$Aux"); - load_field(_c_com_github_dart_lang_jni_gen_simple_package_Example__Aux, &_f_com_github_dart_lang_jni_gen_simple_package_Example__Aux_value, "value","Z"); - return ((*jniEnv)->GetBooleanField(jniEnv, self_, _f_com_github_dart_lang_jni_gen_simple_package_Example__Aux_value)); -} - -void set_com_github_dart_lang_jni_gen_simple_package_Example__Aux_value(jobject self_, uint8_t value) { - load_env(); - load_class_gr(&_c_com_github_dart_lang_jni_gen_simple_package_Example__Aux, "com/github/dart_lang/jni_gen/simple_package/Example$Aux"); - load_field(_c_com_github_dart_lang_jni_gen_simple_package_Example__Aux, &_f_com_github_dart_lang_jni_gen_simple_package_Example__Aux_value, "value","Z"); - ((*jniEnv)->SetBooleanField(jniEnv, self_, _f_com_github_dart_lang_jni_gen_simple_package_Example__Aux_value, value)); -} - - -// com.github.dart_lang.jni_gen.pkg2.C2 -jclass _c_com_github_dart_lang_jni_gen_pkg2_C2 = NULL; - -jmethodID _m_com_github_dart_lang_jni_gen_pkg2_C2_ctor = NULL; -FFI_PLUGIN_EXPORT -jobject com_github_dart_lang_jni_gen_pkg2_C2_ctor() { - load_env(); - load_class_gr(&_c_com_github_dart_lang_jni_gen_pkg2_C2, "com/github/dart_lang/jni_gen/pkg2/C2"); - load_method(_c_com_github_dart_lang_jni_gen_pkg2_C2, &_m_com_github_dart_lang_jni_gen_pkg2_C2_ctor, "", "()V"); - jobject _result = (*jniEnv)->NewObject(jniEnv, _c_com_github_dart_lang_jni_gen_pkg2_C2, _m_com_github_dart_lang_jni_gen_pkg2_C2_ctor); - return to_global_ref(_result); -} - -jfieldID _f_com_github_dart_lang_jni_gen_pkg2_C2_CONSTANT = NULL; -int32_t get_com_github_dart_lang_jni_gen_pkg2_C2_CONSTANT() { - load_env(); - load_class_gr(&_c_com_github_dart_lang_jni_gen_pkg2_C2, "com/github/dart_lang/jni_gen/pkg2/C2"); - load_static_field(_c_com_github_dart_lang_jni_gen_pkg2_C2, &_f_com_github_dart_lang_jni_gen_pkg2_C2_CONSTANT, "CONSTANT","I"); - return ((*jniEnv)->GetStaticIntField(jniEnv, _c_com_github_dart_lang_jni_gen_pkg2_C2, _f_com_github_dart_lang_jni_gen_pkg2_C2_CONSTANT)); -} - -void set_com_github_dart_lang_jni_gen_pkg2_C2_CONSTANT(int32_t value) { - load_env(); - load_class_gr(&_c_com_github_dart_lang_jni_gen_pkg2_C2, "com/github/dart_lang/jni_gen/pkg2/C2"); - load_static_field(_c_com_github_dart_lang_jni_gen_pkg2_C2, &_f_com_github_dart_lang_jni_gen_pkg2_C2_CONSTANT, "CONSTANT","I"); - ((*jniEnv)->SetStaticIntField(jniEnv, _c_com_github_dart_lang_jni_gen_pkg2_C2, _f_com_github_dart_lang_jni_gen_pkg2_C2_CONSTANT, value)); -} - - diff --git a/pkgs/jni_gen/.gitignore b/pkgs/jnigen/.gitignore similarity index 100% rename from pkgs/jni_gen/.gitignore rename to pkgs/jnigen/.gitignore diff --git a/pkgs/jni_gen/LICENSE b/pkgs/jnigen/LICENSE similarity index 100% rename from pkgs/jni_gen/LICENSE rename to pkgs/jnigen/LICENSE diff --git a/pkgs/jnigen/README.md b/pkgs/jnigen/README.md index a9be65606..7d282e33a 100644 --- a/pkgs/jnigen/README.md +++ b/pkgs/jnigen/README.md @@ -1,13 +1,13 @@ -[![Build Status](https://github.com/dart-lang/jni_gen/workflows/Dart%20CI/badge.svg)](https://github.com/dart-lang/jni_gen/actions?query=workflow%3A%22Dart+CI%22+branch%3Amain) +[![Build Status](https://github.com/dart-lang/jnigen/workflows/Dart%20CI/badge.svg)](https://github.com/dart-lang/jnigen/actions?query=workflow%3A%22Dart+CI%22+branch%3Amain) -## jni_gen +## jnigen This project intends to provide 2 packages to enable JNI interop from Dart & Flutter. Currently this package is highly experimental. | Package | Description | | ------- | --------- | | [jni](jni/) | Ergonomic C bindings to JNI C API and several helper methods | -| [jni_gen](jni_gen/) | Tool to generate Dart bindings to Java code using FFI | +| [jnigen](jnigen/) | Tool to generate Dart bindings to Java code using FFI | This is a work-in-progress project under Google Summer of Code 2022 program. diff --git a/pkgs/jni_gen/analysis_options.yaml b/pkgs/jnigen/analysis_options.yaml similarity index 100% rename from pkgs/jni_gen/analysis_options.yaml rename to pkgs/jnigen/analysis_options.yaml diff --git a/pkgs/jni_gen/bin/download_maven_jars.dart b/pkgs/jnigen/bin/download_maven_jars.dart similarity index 85% rename from pkgs/jni_gen/bin/download_maven_jars.dart rename to pkgs/jnigen/bin/download_maven_jars.dart index a4ada5bdc..6e5b4b022 100644 --- a/pkgs/jni_gen/bin/download_maven_jars.dart +++ b/pkgs/jnigen/bin/download_maven_jars.dart @@ -4,10 +4,10 @@ import 'dart:io'; -import 'package:jni_gen/jni_gen.dart'; -import 'package:jni_gen/tools.dart'; +import 'package:jnigen/jnigen.dart'; +import 'package:jnigen/tools.dart'; -/// Downloads maven dependencies downloaded by equivalent jni_gen invocation. +/// Downloads maven dependencies downloaded by equivalent jnigen invocation. /// /// Useful for running standalone examples on already generated sources. void main(List args) async { diff --git a/pkgs/jni_gen/bin/jni_gen.dart b/pkgs/jnigen/bin/jnigen.dart similarity index 89% rename from pkgs/jni_gen/bin/jni_gen.dart rename to pkgs/jnigen/bin/jnigen.dart index 855ae6e68..01bae8560 100644 --- a/pkgs/jni_gen/bin/jni_gen.dart +++ b/pkgs/jnigen/bin/jnigen.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. -import 'package:jni_gen/jni_gen.dart'; +import 'package:jnigen/jnigen.dart'; void main(List args) async { final config = Config.parseArgs(args); diff --git a/pkgs/jni_gen/bin/setup.dart b/pkgs/jnigen/bin/setup.dart similarity index 83% rename from pkgs/jni_gen/bin/setup.dart rename to pkgs/jnigen/bin/setup.dart index 18e7a8d02..fefbd6732 100644 --- a/pkgs/jni_gen/bin/setup.dart +++ b/pkgs/jnigen/bin/setup.dart @@ -4,13 +4,13 @@ import 'dart:io'; -import 'package:jni_gen/src/tools/tools.dart'; +import 'package:jnigen/src/tools/tools.dart'; void main(List args) async { bool force = false; if (args.isNotEmpty) { if (args.length != 1 || args[0] != '-f') { - stderr.writeln('usage: dart run jni_gen:setup [-f]'); + stderr.writeln('usage: dart run jnigen:setup [-f]'); stderr.writeln('* -f\trebuild ApiSummarizer jar even if it already ' 'exists.'); } else { diff --git a/pkgs/jni_gen/cmake/CMakeLists.txt.tmpl b/pkgs/jnigen/cmake/CMakeLists.txt.tmpl similarity index 100% rename from pkgs/jni_gen/cmake/CMakeLists.txt.tmpl rename to pkgs/jnigen/cmake/CMakeLists.txt.tmpl diff --git a/pkgs/jni_gen/examples/README.md b/pkgs/jnigen/examples/README.md similarity index 71% rename from pkgs/jni_gen/examples/README.md rename to pkgs/jnigen/examples/README.md index 11e3fc01d..9b19c3a82 100644 --- a/pkgs/jni_gen/examples/README.md +++ b/pkgs/jnigen/examples/README.md @@ -1,10 +1,10 @@ -## jni_gen examples +## jnigen examples -This directory contains examples on how to use jni_gen. +This directory contains examples on how to use jnigen. | Directory | Description | | ------- | --------- | -| [in_app_java](in_app_java/) | Demonstrates how to include custom Java code in Flutter application and call that using jni_gen | +| [in_app_java](in_app_java/) | Demonstrates how to include custom Java code in Flutter application and call that using jnigen | | [pdfbox_plugin](pdfbox_plugin/) | Example of a flutter plugin which provides bindings to Apache PDFBox library. Currently works on Flutter desktop and Dart standalone on linux. | We intend to cover few more use cases in future. diff --git a/pkgs/jni_gen/examples/in_app_java/.gitignore b/pkgs/jnigen/examples/in_app_java/.gitignore similarity index 100% rename from pkgs/jni_gen/examples/in_app_java/.gitignore rename to pkgs/jnigen/examples/in_app_java/.gitignore diff --git a/pkgs/jni_gen/examples/in_app_java/.metadata b/pkgs/jnigen/examples/in_app_java/.metadata similarity index 100% rename from pkgs/jni_gen/examples/in_app_java/.metadata rename to pkgs/jnigen/examples/in_app_java/.metadata diff --git a/pkgs/jni_gen/examples/in_app_java/README.md b/pkgs/jnigen/examples/in_app_java/README.md similarity index 66% rename from pkgs/jni_gen/examples/in_app_java/README.md rename to pkgs/jnigen/examples/in_app_java/README.md index f910deba1..13813a821 100644 --- a/pkgs/jni_gen/examples/in_app_java/README.md +++ b/pkgs/jnigen/examples/in_app_java/README.md @@ -1,14 +1,14 @@ # In-App Java Example -This example shows how to write custom java code in `android/app/src` and call it using `jni_gen` generated bindings. +This example shows how to write custom java code in `android/app/src` and call it using `jnigen` generated bindings. #### How to run this example: * Run `flutter run` to run the app. -* To regenerate bindings after changing Java code, run `flutter pub run jni_gen --config jnigen.yaml`. This requires at least one APK build to have been run before, so that it's possible for `jni_gen` to obtain classpaths of Android Gradle libraries. Therefore, once run `flutter build apk` before generating bindings for the first time, or after a `flutter clean`. +* To regenerate bindings after changing Java code, run `flutter pub run jnigen --config jnigen.yaml`. This requires at least one APK build to have been run before, so that it's possible for `jnigen` to obtain classpaths of Android Gradle libraries. Therefore, once run `flutter build apk` before generating bindings for the first time, or after a `flutter clean`. #### General steps -These are general steps to integrate Java code into a flutter project using `jni_gen`. +These are general steps to integrate Java code into a flutter project using `jnigen`. * Write Java code in suitable package folder, under `android/` subproject of the flutter app. diff --git a/pkgs/jni_gen/examples/in_app_java/analysis_options.yaml b/pkgs/jnigen/examples/in_app_java/analysis_options.yaml similarity index 100% rename from pkgs/jni_gen/examples/in_app_java/analysis_options.yaml rename to pkgs/jnigen/examples/in_app_java/analysis_options.yaml diff --git a/pkgs/jni_gen/examples/in_app_java/android/.gitignore b/pkgs/jnigen/examples/in_app_java/android/.gitignore similarity index 100% rename from pkgs/jni_gen/examples/in_app_java/android/.gitignore rename to pkgs/jnigen/examples/in_app_java/android/.gitignore diff --git a/pkgs/jni_gen/examples/in_app_java/android/app/build.gradle b/pkgs/jnigen/examples/in_app_java/android/app/build.gradle similarity index 100% rename from pkgs/jni_gen/examples/in_app_java/android/app/build.gradle rename to pkgs/jnigen/examples/in_app_java/android/app/build.gradle diff --git a/pkgs/jni_gen/examples/in_app_java/android/app/src/debug/AndroidManifest.xml b/pkgs/jnigen/examples/in_app_java/android/app/src/debug/AndroidManifest.xml similarity index 100% rename from pkgs/jni_gen/examples/in_app_java/android/app/src/debug/AndroidManifest.xml rename to pkgs/jnigen/examples/in_app_java/android/app/src/debug/AndroidManifest.xml diff --git a/pkgs/jni_gen/examples/in_app_java/android/app/src/main/AndroidManifest.xml b/pkgs/jnigen/examples/in_app_java/android/app/src/main/AndroidManifest.xml similarity index 100% rename from pkgs/jni_gen/examples/in_app_java/android/app/src/main/AndroidManifest.xml rename to pkgs/jnigen/examples/in_app_java/android/app/src/main/AndroidManifest.xml diff --git a/pkgs/jni_gen/examples/in_app_java/android/app/src/main/java/com/example/in_app_java/AndroidUtils.java b/pkgs/jnigen/examples/in_app_java/android/app/src/main/java/com/example/in_app_java/AndroidUtils.java similarity index 100% rename from pkgs/jni_gen/examples/in_app_java/android/app/src/main/java/com/example/in_app_java/AndroidUtils.java rename to pkgs/jnigen/examples/in_app_java/android/app/src/main/java/com/example/in_app_java/AndroidUtils.java diff --git a/pkgs/jni_gen/examples/in_app_java/android/app/src/main/kotlin/com/example/in_app_java/MainActivity.kt b/pkgs/jnigen/examples/in_app_java/android/app/src/main/kotlin/com/example/in_app_java/MainActivity.kt similarity index 100% rename from pkgs/jni_gen/examples/in_app_java/android/app/src/main/kotlin/com/example/in_app_java/MainActivity.kt rename to pkgs/jnigen/examples/in_app_java/android/app/src/main/kotlin/com/example/in_app_java/MainActivity.kt diff --git a/pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/drawable-v21/launch_background.xml b/pkgs/jnigen/examples/in_app_java/android/app/src/main/res/drawable-v21/launch_background.xml similarity index 100% rename from pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/drawable-v21/launch_background.xml rename to pkgs/jnigen/examples/in_app_java/android/app/src/main/res/drawable-v21/launch_background.xml diff --git a/pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/drawable/launch_background.xml b/pkgs/jnigen/examples/in_app_java/android/app/src/main/res/drawable/launch_background.xml similarity index 100% rename from pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/drawable/launch_background.xml rename to pkgs/jnigen/examples/in_app_java/android/app/src/main/res/drawable/launch_background.xml diff --git a/pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/pkgs/jnigen/examples/in_app_java/android/app/src/main/res/mipmap-hdpi/ic_launcher.png similarity index 100% rename from pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/mipmap-hdpi/ic_launcher.png rename to pkgs/jnigen/examples/in_app_java/android/app/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/pkgs/jnigen/examples/in_app_java/android/app/src/main/res/mipmap-mdpi/ic_launcher.png similarity index 100% rename from pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/mipmap-mdpi/ic_launcher.png rename to pkgs/jnigen/examples/in_app_java/android/app/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/pkgs/jnigen/examples/in_app_java/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png similarity index 100% rename from pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png rename to pkgs/jnigen/examples/in_app_java/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/pkgs/jnigen/examples/in_app_java/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png similarity index 100% rename from pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png rename to pkgs/jnigen/examples/in_app_java/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png diff --git a/pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/pkgs/jnigen/examples/in_app_java/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png similarity index 100% rename from pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png rename to pkgs/jnigen/examples/in_app_java/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/values-night/styles.xml b/pkgs/jnigen/examples/in_app_java/android/app/src/main/res/values-night/styles.xml similarity index 100% rename from pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/values-night/styles.xml rename to pkgs/jnigen/examples/in_app_java/android/app/src/main/res/values-night/styles.xml diff --git a/pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/values/styles.xml b/pkgs/jnigen/examples/in_app_java/android/app/src/main/res/values/styles.xml similarity index 100% rename from pkgs/jni_gen/examples/in_app_java/android/app/src/main/res/values/styles.xml rename to pkgs/jnigen/examples/in_app_java/android/app/src/main/res/values/styles.xml diff --git a/pkgs/jni_gen/examples/in_app_java/android/app/src/profile/AndroidManifest.xml b/pkgs/jnigen/examples/in_app_java/android/app/src/profile/AndroidManifest.xml similarity index 100% rename from pkgs/jni_gen/examples/in_app_java/android/app/src/profile/AndroidManifest.xml rename to pkgs/jnigen/examples/in_app_java/android/app/src/profile/AndroidManifest.xml diff --git a/pkgs/jni_gen/examples/in_app_java/android/build.gradle b/pkgs/jnigen/examples/in_app_java/android/build.gradle similarity index 100% rename from pkgs/jni_gen/examples/in_app_java/android/build.gradle rename to pkgs/jnigen/examples/in_app_java/android/build.gradle diff --git a/pkgs/jni_gen/examples/in_app_java/android/gradle.properties b/pkgs/jnigen/examples/in_app_java/android/gradle.properties similarity index 100% rename from pkgs/jni_gen/examples/in_app_java/android/gradle.properties rename to pkgs/jnigen/examples/in_app_java/android/gradle.properties diff --git a/pkgs/jni_gen/examples/in_app_java/android/gradle/wrapper/gradle-wrapper.properties b/pkgs/jnigen/examples/in_app_java/android/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from pkgs/jni_gen/examples/in_app_java/android/gradle/wrapper/gradle-wrapper.properties rename to pkgs/jnigen/examples/in_app_java/android/gradle/wrapper/gradle-wrapper.properties diff --git a/pkgs/jni_gen/examples/in_app_java/android/settings.gradle b/pkgs/jnigen/examples/in_app_java/android/settings.gradle similarity index 100% rename from pkgs/jni_gen/examples/in_app_java/android/settings.gradle rename to pkgs/jnigen/examples/in_app_java/android/settings.gradle diff --git a/pkgs/jni_gen/examples/in_app_java/jnigen.yaml b/pkgs/jnigen/examples/in_app_java/jnigen.yaml similarity index 100% rename from pkgs/jni_gen/examples/in_app_java/jnigen.yaml rename to pkgs/jnigen/examples/in_app_java/jnigen.yaml diff --git a/pkgs/jni_gen/examples/in_app_java/lib/android_utils/com/example/in_app_java.dart b/pkgs/jnigen/examples/in_app_java/lib/android_utils/com/example/in_app_java.dart similarity index 97% rename from pkgs/jni_gen/examples/in_app_java/lib/android_utils/com/example/in_app_java.dart rename to pkgs/jnigen/examples/in_app_java/lib/android_utils/com/example/in_app_java.dart index 6f6a01031..3412fc1db 100644 --- a/pkgs/jni_gen/examples/in_app_java/lib/android_utils/com/example/in_app_java.dart +++ b/pkgs/jnigen/examples/in_app_java/lib/android_utils/com/example/in_app_java.dart @@ -1,4 +1,4 @@ -// Autogenerated by jni_gen. DO NOT EDIT! +// Autogenerated by jnigen. DO NOT EDIT! // ignore_for_file: camel_case_types // ignore_for_file: non_constant_identifier_names diff --git a/pkgs/jni_gen/examples/in_app_java/lib/android_utils/init.dart b/pkgs/jnigen/examples/in_app_java/lib/android_utils/init.dart similarity index 100% rename from pkgs/jni_gen/examples/in_app_java/lib/android_utils/init.dart rename to pkgs/jnigen/examples/in_app_java/lib/android_utils/init.dart diff --git a/pkgs/jni_gen/examples/in_app_java/lib/main.dart b/pkgs/jnigen/examples/in_app_java/lib/main.dart similarity index 100% rename from pkgs/jni_gen/examples/in_app_java/lib/main.dart rename to pkgs/jnigen/examples/in_app_java/lib/main.dart diff --git a/pkgs/jni_gen/examples/in_app_java/pubspec.yaml b/pkgs/jnigen/examples/in_app_java/pubspec.yaml similarity index 99% rename from pkgs/jni_gen/examples/in_app_java/pubspec.yaml rename to pkgs/jnigen/examples/in_app_java/pubspec.yaml index aef5291ea..f2dcc7de5 100644 --- a/pkgs/jni_gen/examples/in_app_java/pubspec.yaml +++ b/pkgs/jnigen/examples/in_app_java/pubspec.yaml @@ -23,7 +23,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - jni_gen: + jnigen: path: ../../ flutter_lints: ^2.0.0 diff --git a/pkgs/jni_gen/examples/in_app_java/src/android_utils/CMakeLists.txt b/pkgs/jnigen/examples/in_app_java/src/android_utils/CMakeLists.txt similarity index 100% rename from pkgs/jni_gen/examples/in_app_java/src/android_utils/CMakeLists.txt rename to pkgs/jnigen/examples/in_app_java/src/android_utils/CMakeLists.txt diff --git a/pkgs/jni_gen/examples/in_app_java/src/android_utils/android_utils.c b/pkgs/jnigen/examples/in_app_java/src/android_utils/android_utils.c similarity index 97% rename from pkgs/jni_gen/examples/in_app_java/src/android_utils/android_utils.c rename to pkgs/jnigen/examples/in_app_java/src/android_utils/android_utils.c index d9c365ce4..f41c21683 100644 --- a/pkgs/jni_gen/examples/in_app_java/src/android_utils/android_utils.c +++ b/pkgs/jnigen/examples/in_app_java/src/android_utils/android_utils.c @@ -1,4 +1,4 @@ -// Autogenerated by jni_gen. DO NOT EDIT! +// Autogenerated by jnigen. DO NOT EDIT! #include #include "jni.h" diff --git a/pkgs/jni_gen/examples/in_app_java/src/android_utils/dartjni.h b/pkgs/jnigen/examples/in_app_java/src/android_utils/dartjni.h similarity index 100% rename from pkgs/jni_gen/examples/in_app_java/src/android_utils/dartjni.h rename to pkgs/jnigen/examples/in_app_java/src/android_utils/dartjni.h diff --git a/pkgs/jni_gen/examples/in_app_java/tool/generate_bindings.dart b/pkgs/jnigen/examples/in_app_java/tool/generate_bindings.dart similarity index 94% rename from pkgs/jni_gen/examples/in_app_java/tool/generate_bindings.dart rename to pkgs/jnigen/examples/in_app_java/tool/generate_bindings.dart index cb2b53d9e..ce3b03f9a 100644 --- a/pkgs/jni_gen/examples/in_app_java/tool/generate_bindings.dart +++ b/pkgs/jnigen/examples/in_app_java/tool/generate_bindings.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. -import 'package:jni_gen/jni_gen.dart'; +import 'package:jnigen/jnigen.dart'; void main(List args) async { final config = Config( diff --git a/pkgs/jni_gen/examples/notification_plugin/.gitignore b/pkgs/jnigen/examples/notification_plugin/.gitignore similarity index 100% rename from pkgs/jni_gen/examples/notification_plugin/.gitignore rename to pkgs/jnigen/examples/notification_plugin/.gitignore diff --git a/pkgs/jni_gen/examples/notification_plugin/.metadata b/pkgs/jnigen/examples/notification_plugin/.metadata similarity index 100% rename from pkgs/jni_gen/examples/notification_plugin/.metadata rename to pkgs/jnigen/examples/notification_plugin/.metadata diff --git a/pkgs/jnigen/examples/notification_plugin/README.md b/pkgs/jnigen/examples/notification_plugin/README.md new file mode 100644 index 000000000..035b29af7 --- /dev/null +++ b/pkgs/jnigen/examples/notification_plugin/README.md @@ -0,0 +1,13 @@ +# notification_plugin + +Example of android plugin project with jnigen. + +This plugin project contains [custom code](android/src/main/java/com/example/notification_plugin) which uses the Android libraries. The bindings are generated using [jnigen config](jnigen.yaml) and then used in [flutter example](example/lib/main.dart), with help of `package:jni` APIs. + +The command to regenerate JNI bindings is: +``` +flutter 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/jni_gen/examples/notification_plugin/analysis_options.yaml b/pkgs/jnigen/examples/notification_plugin/analysis_options.yaml similarity index 100% rename from pkgs/jni_gen/examples/notification_plugin/analysis_options.yaml rename to pkgs/jnigen/examples/notification_plugin/analysis_options.yaml diff --git a/pkgs/jni_gen/examples/notification_plugin/android/.gitignore b/pkgs/jnigen/examples/notification_plugin/android/.gitignore similarity index 100% rename from pkgs/jni_gen/examples/notification_plugin/android/.gitignore rename to pkgs/jnigen/examples/notification_plugin/android/.gitignore diff --git a/pkgs/jni_gen/examples/notification_plugin/android/build.gradle b/pkgs/jnigen/examples/notification_plugin/android/build.gradle similarity index 100% rename from pkgs/jni_gen/examples/notification_plugin/android/build.gradle rename to pkgs/jnigen/examples/notification_plugin/android/build.gradle diff --git a/pkgs/jni_gen/examples/notification_plugin/android/settings.gradle b/pkgs/jnigen/examples/notification_plugin/android/settings.gradle similarity index 100% rename from pkgs/jni_gen/examples/notification_plugin/android/settings.gradle rename to pkgs/jnigen/examples/notification_plugin/android/settings.gradle diff --git a/pkgs/jni_gen/examples/notification_plugin/android/src/main/AndroidManifest.xml b/pkgs/jnigen/examples/notification_plugin/android/src/main/AndroidManifest.xml similarity index 100% rename from pkgs/jni_gen/examples/notification_plugin/android/src/main/AndroidManifest.xml rename to pkgs/jnigen/examples/notification_plugin/android/src/main/AndroidManifest.xml diff --git a/pkgs/jni_gen/examples/notification_plugin/android/src/main/java/com/example/notification_plugin/Notifications.java b/pkgs/jnigen/examples/notification_plugin/android/src/main/java/com/example/notification_plugin/Notifications.java similarity index 100% rename from pkgs/jni_gen/examples/notification_plugin/android/src/main/java/com/example/notification_plugin/Notifications.java rename to pkgs/jnigen/examples/notification_plugin/android/src/main/java/com/example/notification_plugin/Notifications.java diff --git a/pkgs/jni_gen/examples/notification_plugin/example/.gitignore b/pkgs/jnigen/examples/notification_plugin/example/.gitignore similarity index 100% rename from pkgs/jni_gen/examples/notification_plugin/example/.gitignore rename to pkgs/jnigen/examples/notification_plugin/example/.gitignore diff --git a/pkgs/jni_gen/examples/notification_plugin/example/README.md b/pkgs/jnigen/examples/notification_plugin/example/README.md similarity index 100% rename from pkgs/jni_gen/examples/notification_plugin/example/README.md rename to pkgs/jnigen/examples/notification_plugin/example/README.md diff --git a/pkgs/jni_gen/examples/notification_plugin/example/analysis_options.yaml b/pkgs/jnigen/examples/notification_plugin/example/analysis_options.yaml similarity index 100% rename from pkgs/jni_gen/examples/notification_plugin/example/analysis_options.yaml rename to pkgs/jnigen/examples/notification_plugin/example/analysis_options.yaml diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/.gitignore b/pkgs/jnigen/examples/notification_plugin/example/android/.gitignore similarity index 100% rename from pkgs/jni_gen/examples/notification_plugin/example/android/.gitignore rename to pkgs/jnigen/examples/notification_plugin/example/android/.gitignore diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/app/build.gradle b/pkgs/jnigen/examples/notification_plugin/example/android/app/build.gradle similarity index 100% rename from pkgs/jni_gen/examples/notification_plugin/example/android/app/build.gradle rename to pkgs/jnigen/examples/notification_plugin/example/android/app/build.gradle diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/debug/AndroidManifest.xml b/pkgs/jnigen/examples/notification_plugin/example/android/app/src/debug/AndroidManifest.xml similarity index 100% rename from pkgs/jni_gen/examples/notification_plugin/example/android/app/src/debug/AndroidManifest.xml rename to pkgs/jnigen/examples/notification_plugin/example/android/app/src/debug/AndroidManifest.xml diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/AndroidManifest.xml b/pkgs/jnigen/examples/notification_plugin/example/android/app/src/main/AndroidManifest.xml similarity index 100% rename from pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/AndroidManifest.xml rename to pkgs/jnigen/examples/notification_plugin/example/android/app/src/main/AndroidManifest.xml diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/kotlin/com/example/notification_plugin_example/MainActivity.kt b/pkgs/jnigen/examples/notification_plugin/example/android/app/src/main/kotlin/com/example/notification_plugin_example/MainActivity.kt similarity index 100% rename from pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/kotlin/com/example/notification_plugin_example/MainActivity.kt rename to pkgs/jnigen/examples/notification_plugin/example/android/app/src/main/kotlin/com/example/notification_plugin_example/MainActivity.kt diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/drawable-v21/launch_background.xml b/pkgs/jnigen/examples/notification_plugin/example/android/app/src/main/res/drawable-v21/launch_background.xml similarity index 100% rename from pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/drawable-v21/launch_background.xml rename to pkgs/jnigen/examples/notification_plugin/example/android/app/src/main/res/drawable-v21/launch_background.xml diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/drawable/launch_background.xml b/pkgs/jnigen/examples/notification_plugin/example/android/app/src/main/res/drawable/launch_background.xml similarity index 100% rename from pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/drawable/launch_background.xml rename to pkgs/jnigen/examples/notification_plugin/example/android/app/src/main/res/drawable/launch_background.xml diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/pkgs/jnigen/examples/notification_plugin/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png similarity index 100% rename from pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png rename to pkgs/jnigen/examples/notification_plugin/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/pkgs/jnigen/examples/notification_plugin/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png similarity index 100% rename from pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png rename to pkgs/jnigen/examples/notification_plugin/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/pkgs/jnigen/examples/notification_plugin/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png similarity index 100% rename from pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png rename to pkgs/jnigen/examples/notification_plugin/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/pkgs/jnigen/examples/notification_plugin/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png similarity index 100% rename from pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png rename to pkgs/jnigen/examples/notification_plugin/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/pkgs/jnigen/examples/notification_plugin/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png similarity index 100% rename from pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png rename to pkgs/jnigen/examples/notification_plugin/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/values-night/styles.xml b/pkgs/jnigen/examples/notification_plugin/example/android/app/src/main/res/values-night/styles.xml similarity index 100% rename from pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/values-night/styles.xml rename to pkgs/jnigen/examples/notification_plugin/example/android/app/src/main/res/values-night/styles.xml diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/values/styles.xml b/pkgs/jnigen/examples/notification_plugin/example/android/app/src/main/res/values/styles.xml similarity index 100% rename from pkgs/jni_gen/examples/notification_plugin/example/android/app/src/main/res/values/styles.xml rename to pkgs/jnigen/examples/notification_plugin/example/android/app/src/main/res/values/styles.xml diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/app/src/profile/AndroidManifest.xml b/pkgs/jnigen/examples/notification_plugin/example/android/app/src/profile/AndroidManifest.xml similarity index 100% rename from pkgs/jni_gen/examples/notification_plugin/example/android/app/src/profile/AndroidManifest.xml rename to pkgs/jnigen/examples/notification_plugin/example/android/app/src/profile/AndroidManifest.xml diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/build.gradle b/pkgs/jnigen/examples/notification_plugin/example/android/build.gradle similarity index 100% rename from pkgs/jni_gen/examples/notification_plugin/example/android/build.gradle rename to pkgs/jnigen/examples/notification_plugin/example/android/build.gradle diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/gradle.properties b/pkgs/jnigen/examples/notification_plugin/example/android/gradle.properties similarity index 100% rename from pkgs/jni_gen/examples/notification_plugin/example/android/gradle.properties rename to pkgs/jnigen/examples/notification_plugin/example/android/gradle.properties diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/gradle/wrapper/gradle-wrapper.properties b/pkgs/jnigen/examples/notification_plugin/example/android/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from pkgs/jni_gen/examples/notification_plugin/example/android/gradle/wrapper/gradle-wrapper.properties rename to pkgs/jnigen/examples/notification_plugin/example/android/gradle/wrapper/gradle-wrapper.properties diff --git a/pkgs/jni_gen/examples/notification_plugin/example/android/settings.gradle b/pkgs/jnigen/examples/notification_plugin/example/android/settings.gradle similarity index 100% rename from pkgs/jni_gen/examples/notification_plugin/example/android/settings.gradle rename to pkgs/jnigen/examples/notification_plugin/example/android/settings.gradle diff --git a/pkgs/jni_gen/examples/notification_plugin/example/lib/main.dart b/pkgs/jnigen/examples/notification_plugin/example/lib/main.dart similarity index 100% rename from pkgs/jni_gen/examples/notification_plugin/example/lib/main.dart rename to pkgs/jnigen/examples/notification_plugin/example/lib/main.dart diff --git a/pkgs/jni_gen/examples/notification_plugin/example/pubspec.yaml b/pkgs/jnigen/examples/notification_plugin/example/pubspec.yaml similarity index 100% rename from pkgs/jni_gen/examples/notification_plugin/example/pubspec.yaml rename to pkgs/jnigen/examples/notification_plugin/example/pubspec.yaml diff --git a/pkgs/jni_gen/examples/notification_plugin/jnigen.yaml b/pkgs/jnigen/examples/notification_plugin/jnigen.yaml similarity index 100% rename from pkgs/jni_gen/examples/notification_plugin/jnigen.yaml rename to pkgs/jnigen/examples/notification_plugin/jnigen.yaml diff --git a/pkgs/jni_gen/examples/notification_plugin/lib/com/example/notification_plugin.dart b/pkgs/jnigen/examples/notification_plugin/lib/com/example/notification_plugin.dart similarity index 97% rename from pkgs/jni_gen/examples/notification_plugin/lib/com/example/notification_plugin.dart rename to pkgs/jnigen/examples/notification_plugin/lib/com/example/notification_plugin.dart index 52c75af14..f7bd86cd9 100644 --- a/pkgs/jni_gen/examples/notification_plugin/lib/com/example/notification_plugin.dart +++ b/pkgs/jnigen/examples/notification_plugin/lib/com/example/notification_plugin.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. -// Autogenerated by jni_gen. DO NOT EDIT! +// Autogenerated by jnigen. DO NOT EDIT! // ignore_for_file: camel_case_types // ignore_for_file: non_constant_identifier_names diff --git a/pkgs/jni_gen/examples/notification_plugin/lib/init.dart b/pkgs/jnigen/examples/notification_plugin/lib/init.dart similarity index 100% rename from pkgs/jni_gen/examples/notification_plugin/lib/init.dart rename to pkgs/jnigen/examples/notification_plugin/lib/init.dart diff --git a/pkgs/jni_gen/examples/notification_plugin/pubspec.yaml b/pkgs/jnigen/examples/notification_plugin/pubspec.yaml similarity index 97% rename from pkgs/jni_gen/examples/notification_plugin/pubspec.yaml rename to pkgs/jnigen/examples/notification_plugin/pubspec.yaml index 422f83a34..a680e741a 100644 --- a/pkgs/jni_gen/examples/notification_plugin/pubspec.yaml +++ b/pkgs/jnigen/examples/notification_plugin/pubspec.yaml @@ -2,7 +2,7 @@ name: notification_plugin description: A new Flutter FFI plugin project. version: 0.0.1 publish_to: none -homepage: https://github.com/dart-lang/jni_gen +homepage: https://github.com/dart-lang/jnigen environment: sdk: '>=2.18.0 <3.0.0' @@ -16,7 +16,7 @@ dependencies: plugin_platform_interface: ^2.0.2 dev_dependencies: - jni_gen: + jnigen: path: ../../ flutter_test: sdk: flutter diff --git a/pkgs/jni_gen/examples/notification_plugin/src/CMakeLists.txt b/pkgs/jnigen/examples/notification_plugin/src/CMakeLists.txt similarity index 100% rename from pkgs/jni_gen/examples/notification_plugin/src/CMakeLists.txt rename to pkgs/jnigen/examples/notification_plugin/src/CMakeLists.txt diff --git a/pkgs/jni_gen/examples/notification_plugin/src/dartjni.h b/pkgs/jnigen/examples/notification_plugin/src/dartjni.h similarity index 100% rename from pkgs/jni_gen/examples/notification_plugin/src/dartjni.h rename to pkgs/jnigen/examples/notification_plugin/src/dartjni.h diff --git a/pkgs/jni_gen/examples/notification_plugin/src/notification_plugin.c b/pkgs/jnigen/examples/notification_plugin/src/notification_plugin.c similarity index 98% rename from pkgs/jni_gen/examples/notification_plugin/src/notification_plugin.c rename to pkgs/jnigen/examples/notification_plugin/src/notification_plugin.c index 6457cae02..0408aa189 100644 --- a/pkgs/jni_gen/examples/notification_plugin/src/notification_plugin.c +++ b/pkgs/jnigen/examples/notification_plugin/src/notification_plugin.c @@ -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. -// Autogenerated by jni_gen. DO NOT EDIT! +// Autogenerated by jnigen. DO NOT EDIT! #include #include "jni.h" diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/.gitignore b/pkgs/jnigen/examples/pdfbox_plugin/.gitignore similarity index 96% rename from pkgs/jni_gen/examples/pdfbox_plugin/.gitignore rename to pkgs/jnigen/examples/pdfbox_plugin/.gitignore index 4080544e7..b3f33fc12 100644 --- a/pkgs/jni_gen/examples/pdfbox_plugin/.gitignore +++ b/pkgs/jnigen/examples/pdfbox_plugin/.gitignore @@ -29,7 +29,7 @@ migrate_working_dir/ .packages build/ -## Downloaded by jni_gen +## Downloaded by jnigen /mvn_java/ /mvn_jar/ ## Sometimes generated by maven. diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/.metadata b/pkgs/jnigen/examples/pdfbox_plugin/.metadata similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/.metadata rename to pkgs/jnigen/examples/pdfbox_plugin/.metadata diff --git a/pkgs/jnigen/examples/pdfbox_plugin/README.md b/pkgs/jnigen/examples/pdfbox_plugin/README.md new file mode 100644 index 000000000..efa8caa40 --- /dev/null +++ b/pkgs/jnigen/examples/pdfbox_plugin/README.md @@ -0,0 +1,8 @@ +# pdfbox_plugin + +Example of a JNI plugin using `jnigen` to auto-generate bindings for PDFBox java library. + +Bindings can be generated by running `dart run jnigen --config jnigen.yaml`. Required source code and JARs will be downloaded using maven (requires `mvn` command). + +`jnigen` is also available as an API which tooling scripts can use. See `tool/generate_bindings.dart` for the script equivalent of the YAML file. + diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/analysis_options.yaml b/pkgs/jnigen/examples/pdfbox_plugin/analysis_options.yaml similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/analysis_options.yaml rename to pkgs/jnigen/examples/pdfbox_plugin/analysis_options.yaml diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/android/.gitignore b/pkgs/jnigen/examples/pdfbox_plugin/android/.gitignore similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/android/.gitignore rename to pkgs/jnigen/examples/pdfbox_plugin/android/.gitignore diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/android/build.gradle b/pkgs/jnigen/examples/pdfbox_plugin/android/build.gradle similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/android/build.gradle rename to pkgs/jnigen/examples/pdfbox_plugin/android/build.gradle diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/android/settings.gradle b/pkgs/jnigen/examples/pdfbox_plugin/android/settings.gradle similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/android/settings.gradle rename to pkgs/jnigen/examples/pdfbox_plugin/android/settings.gradle diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/android/src/main/AndroidManifest.xml b/pkgs/jnigen/examples/pdfbox_plugin/android/src/main/AndroidManifest.xml similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/android/src/main/AndroidManifest.xml rename to pkgs/jnigen/examples/pdfbox_plugin/android/src/main/AndroidManifest.xml diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/dart_example/.gitignore b/pkgs/jnigen/examples/pdfbox_plugin/dart_example/.gitignore similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/dart_example/.gitignore rename to pkgs/jnigen/examples/pdfbox_plugin/dart_example/.gitignore diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/dart_example/CHANGELOG.md b/pkgs/jnigen/examples/pdfbox_plugin/dart_example/CHANGELOG.md similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/dart_example/CHANGELOG.md rename to pkgs/jnigen/examples/pdfbox_plugin/dart_example/CHANGELOG.md diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/dart_example/README.md b/pkgs/jnigen/examples/pdfbox_plugin/dart_example/README.md similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/dart_example/README.md rename to pkgs/jnigen/examples/pdfbox_plugin/dart_example/README.md diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/dart_example/analysis_options.yaml b/pkgs/jnigen/examples/pdfbox_plugin/dart_example/analysis_options.yaml similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/dart_example/analysis_options.yaml rename to pkgs/jnigen/examples/pdfbox_plugin/dart_example/analysis_options.yaml diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/dart_example/bin/pdf_info.dart b/pkgs/jnigen/examples/pdfbox_plugin/dart_example/bin/pdf_info.dart similarity index 96% rename from pkgs/jni_gen/examples/pdfbox_plugin/dart_example/bin/pdf_info.dart rename to pkgs/jnigen/examples/pdfbox_plugin/dart_example/bin/pdf_info.dart index f276ea1e1..92f9c3098 100644 --- a/pkgs/jni_gen/examples/pdfbox_plugin/dart_example/bin/pdf_info.dart +++ b/pkgs/jnigen/examples/pdfbox_plugin/dart_example/bin/pdf_info.dart @@ -44,7 +44,7 @@ void writeInfo(String file) { final jniLibsDir = join('build', 'jni_libs'); const jarError = 'No JAR files were found.\n' - 'Run `dart run jni_gen:download_maven_jars --config jnigen.yaml` ' + 'Run `dart run jnigen:download_maven_jars --config jnigen.yaml` ' 'in plugin directory.\n' 'Alternatively, regenerate JNI bindings in plugin directory, which will ' 'automatically download the JAR files.'; diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/dart_example/pubspec.yaml b/pkgs/jnigen/examples/pdfbox_plugin/dart_example/pubspec.yaml similarity index 80% rename from pkgs/jni_gen/examples/pdfbox_plugin/dart_example/pubspec.yaml rename to pkgs/jnigen/examples/pdfbox_plugin/dart_example/pubspec.yaml index b694b73eb..c1e26605c 100644 --- a/pkgs/jni_gen/examples/pdfbox_plugin/dart_example/pubspec.yaml +++ b/pkgs/jnigen/examples/pdfbox_plugin/dart_example/pubspec.yaml @@ -1,5 +1,5 @@ name: pdf_info -description: Dart standalone example using jni_gen PDFBox bindings +description: Dart standalone example using jnigen PDFBox bindings version: 1.0.0 publish_to: none # homepage: https://www.example.com diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/.gitignore b/pkgs/jnigen/examples/pdfbox_plugin/example/.gitignore similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/.gitignore rename to pkgs/jnigen/examples/pdfbox_plugin/example/.gitignore diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/README.md b/pkgs/jnigen/examples/pdfbox_plugin/example/README.md similarity index 74% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/README.md rename to pkgs/jnigen/examples/pdfbox_plugin/example/README.md index 697559cbc..0f471bec6 100644 --- a/pkgs/jni_gen/examples/pdfbox_plugin/example/README.md +++ b/pkgs/jnigen/examples/pdfbox_plugin/example/README.md @@ -1,6 +1,6 @@ # pdfbox_plugin_example -Demonstrates how to use the PDFBox bindings generated using `jni_gen`. This is a Linux Flutter application. The sample application lists the PDF files in a directory with number of pages and title, also allowing to navigate between directories. +Demonstrates how to use the PDFBox bindings generated using `jnigen`. This is a Linux Flutter application. The sample application lists the PDF files in a directory with number of pages and title, also allowing to navigate between directories. First, it's required to have generated the dart and C bindings in the plugin directory, which also downloads the required JARs using maven. The bindings are not committed because generated code is several thousands of lines. @@ -8,7 +8,7 @@ On a Linux machine, following commands can be used to run the example applicatio ``` cd .. ## From this folder -dart run jni_gen --config jnigen.yaml ## Downloads PDFBox JARs and generates bindings. +dart run jnigen --config jnigen.yaml ## Downloads PDFBox JARs and generates bindings. cd example/ flutter run --release ## Opens the files list from home directory ``` diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/analysis_options.yaml b/pkgs/jnigen/examples/pdfbox_plugin/example/analysis_options.yaml similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/analysis_options.yaml rename to pkgs/jnigen/examples/pdfbox_plugin/example/analysis_options.yaml diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/.gitignore b/pkgs/jnigen/examples/pdfbox_plugin/example/android/.gitignore similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/android/.gitignore rename to pkgs/jnigen/examples/pdfbox_plugin/example/android/.gitignore diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/build.gradle b/pkgs/jnigen/examples/pdfbox_plugin/example/android/app/build.gradle similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/build.gradle rename to pkgs/jnigen/examples/pdfbox_plugin/example/android/app/build.gradle diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/debug/AndroidManifest.xml b/pkgs/jnigen/examples/pdfbox_plugin/example/android/app/src/debug/AndroidManifest.xml similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/debug/AndroidManifest.xml rename to pkgs/jnigen/examples/pdfbox_plugin/example/android/app/src/debug/AndroidManifest.xml diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/AndroidManifest.xml b/pkgs/jnigen/examples/pdfbox_plugin/example/android/app/src/main/AndroidManifest.xml similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/AndroidManifest.xml rename to pkgs/jnigen/examples/pdfbox_plugin/example/android/app/src/main/AndroidManifest.xml diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/kotlin/com/example/pdfbox_plugin_example/MainActivity.kt b/pkgs/jnigen/examples/pdfbox_plugin/example/android/app/src/main/kotlin/com/example/pdfbox_plugin_example/MainActivity.kt similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/kotlin/com/example/pdfbox_plugin_example/MainActivity.kt rename to pkgs/jnigen/examples/pdfbox_plugin/example/android/app/src/main/kotlin/com/example/pdfbox_plugin_example/MainActivity.kt diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/drawable-v21/launch_background.xml b/pkgs/jnigen/examples/pdfbox_plugin/example/android/app/src/main/res/drawable-v21/launch_background.xml similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/drawable-v21/launch_background.xml rename to pkgs/jnigen/examples/pdfbox_plugin/example/android/app/src/main/res/drawable-v21/launch_background.xml diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/drawable/launch_background.xml b/pkgs/jnigen/examples/pdfbox_plugin/example/android/app/src/main/res/drawable/launch_background.xml similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/drawable/launch_background.xml rename to pkgs/jnigen/examples/pdfbox_plugin/example/android/app/src/main/res/drawable/launch_background.xml diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/pkgs/jnigen/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png rename to pkgs/jnigen/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/pkgs/jnigen/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png rename to pkgs/jnigen/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/pkgs/jnigen/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png rename to pkgs/jnigen/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/pkgs/jnigen/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png rename to pkgs/jnigen/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/pkgs/jnigen/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png rename to pkgs/jnigen/examples/pdfbox_plugin/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/values-night/styles.xml b/pkgs/jnigen/examples/pdfbox_plugin/example/android/app/src/main/res/values-night/styles.xml similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/values-night/styles.xml rename to pkgs/jnigen/examples/pdfbox_plugin/example/android/app/src/main/res/values-night/styles.xml diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/values/styles.xml b/pkgs/jnigen/examples/pdfbox_plugin/example/android/app/src/main/res/values/styles.xml similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/main/res/values/styles.xml rename to pkgs/jnigen/examples/pdfbox_plugin/example/android/app/src/main/res/values/styles.xml diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/profile/AndroidManifest.xml b/pkgs/jnigen/examples/pdfbox_plugin/example/android/app/src/profile/AndroidManifest.xml similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/android/app/src/profile/AndroidManifest.xml rename to pkgs/jnigen/examples/pdfbox_plugin/example/android/app/src/profile/AndroidManifest.xml diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/build.gradle b/pkgs/jnigen/examples/pdfbox_plugin/example/android/build.gradle similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/android/build.gradle rename to pkgs/jnigen/examples/pdfbox_plugin/example/android/build.gradle diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/gradle.properties b/pkgs/jnigen/examples/pdfbox_plugin/example/android/gradle.properties similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/android/gradle.properties rename to pkgs/jnigen/examples/pdfbox_plugin/example/android/gradle.properties diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/gradle/wrapper/gradle-wrapper.properties b/pkgs/jnigen/examples/pdfbox_plugin/example/android/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/android/gradle/wrapper/gradle-wrapper.properties rename to pkgs/jnigen/examples/pdfbox_plugin/example/android/gradle/wrapper/gradle-wrapper.properties diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/android/settings.gradle b/pkgs/jnigen/examples/pdfbox_plugin/example/android/settings.gradle similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/android/settings.gradle rename to pkgs/jnigen/examples/pdfbox_plugin/example/android/settings.gradle diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/lib/main.dart b/pkgs/jnigen/examples/pdfbox_plugin/example/lib/main.dart similarity index 98% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/lib/main.dart rename to pkgs/jnigen/examples/pdfbox_plugin/example/lib/main.dart index 09527fb03..82d86574a 100644 --- a/pkgs/jni_gen/examples/pdfbox_plugin/example/lib/main.dart +++ b/pkgs/jnigen/examples/pdfbox_plugin/example/lib/main.dart @@ -20,7 +20,7 @@ Stream files(String dir) => Directory(dir).list().map((e) => e.path); late Jni jni; const jarError = 'No JAR files were found.\n' - 'Run `dart run jni_gen:download_maven_jars --config jnigen.yaml` ' + 'Run `dart run jnigen:download_maven_jars --config jnigen.yaml` ' 'in plugin directory.\n' 'Alternatively, regenerate JNI bindings in plugin directory, which will ' 'automatically download the JAR files.'; diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/linux/.gitignore b/pkgs/jnigen/examples/pdfbox_plugin/example/linux/.gitignore similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/linux/.gitignore rename to pkgs/jnigen/examples/pdfbox_plugin/example/linux/.gitignore diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/linux/CMakeLists.txt b/pkgs/jnigen/examples/pdfbox_plugin/example/linux/CMakeLists.txt similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/linux/CMakeLists.txt rename to pkgs/jnigen/examples/pdfbox_plugin/example/linux/CMakeLists.txt diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/linux/flutter/CMakeLists.txt b/pkgs/jnigen/examples/pdfbox_plugin/example/linux/flutter/CMakeLists.txt similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/linux/flutter/CMakeLists.txt rename to pkgs/jnigen/examples/pdfbox_plugin/example/linux/flutter/CMakeLists.txt diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/linux/flutter/generated_plugin_registrant.cc b/pkgs/jnigen/examples/pdfbox_plugin/example/linux/flutter/generated_plugin_registrant.cc similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/linux/flutter/generated_plugin_registrant.cc rename to pkgs/jnigen/examples/pdfbox_plugin/example/linux/flutter/generated_plugin_registrant.cc diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/linux/flutter/generated_plugin_registrant.h b/pkgs/jnigen/examples/pdfbox_plugin/example/linux/flutter/generated_plugin_registrant.h similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/linux/flutter/generated_plugin_registrant.h rename to pkgs/jnigen/examples/pdfbox_plugin/example/linux/flutter/generated_plugin_registrant.h diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/linux/flutter/generated_plugins.cmake b/pkgs/jnigen/examples/pdfbox_plugin/example/linux/flutter/generated_plugins.cmake similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/linux/flutter/generated_plugins.cmake rename to pkgs/jnigen/examples/pdfbox_plugin/example/linux/flutter/generated_plugins.cmake diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/linux/main.cc b/pkgs/jnigen/examples/pdfbox_plugin/example/linux/main.cc similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/linux/main.cc rename to pkgs/jnigen/examples/pdfbox_plugin/example/linux/main.cc diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/linux/my_application.cc b/pkgs/jnigen/examples/pdfbox_plugin/example/linux/my_application.cc similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/linux/my_application.cc rename to pkgs/jnigen/examples/pdfbox_plugin/example/linux/my_application.cc diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/linux/my_application.h b/pkgs/jnigen/examples/pdfbox_plugin/example/linux/my_application.h similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/linux/my_application.h rename to pkgs/jnigen/examples/pdfbox_plugin/example/linux/my_application.h diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/pubspec.yaml b/pkgs/jnigen/examples/pdfbox_plugin/example/pubspec.yaml similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/pubspec.yaml rename to pkgs/jnigen/examples/pdfbox_plugin/example/pubspec.yaml diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/.gitignore b/pkgs/jnigen/examples/pdfbox_plugin/example/windows/.gitignore similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/windows/.gitignore rename to pkgs/jnigen/examples/pdfbox_plugin/example/windows/.gitignore diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/CMakeLists.txt b/pkgs/jnigen/examples/pdfbox_plugin/example/windows/CMakeLists.txt similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/windows/CMakeLists.txt rename to pkgs/jnigen/examples/pdfbox_plugin/example/windows/CMakeLists.txt diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/flutter/CMakeLists.txt b/pkgs/jnigen/examples/pdfbox_plugin/example/windows/flutter/CMakeLists.txt similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/windows/flutter/CMakeLists.txt rename to pkgs/jnigen/examples/pdfbox_plugin/example/windows/flutter/CMakeLists.txt diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/flutter/generated_plugin_registrant.cc b/pkgs/jnigen/examples/pdfbox_plugin/example/windows/flutter/generated_plugin_registrant.cc similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/windows/flutter/generated_plugin_registrant.cc rename to pkgs/jnigen/examples/pdfbox_plugin/example/windows/flutter/generated_plugin_registrant.cc diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/flutter/generated_plugin_registrant.h b/pkgs/jnigen/examples/pdfbox_plugin/example/windows/flutter/generated_plugin_registrant.h similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/windows/flutter/generated_plugin_registrant.h rename to pkgs/jnigen/examples/pdfbox_plugin/example/windows/flutter/generated_plugin_registrant.h diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/flutter/generated_plugins.cmake b/pkgs/jnigen/examples/pdfbox_plugin/example/windows/flutter/generated_plugins.cmake similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/windows/flutter/generated_plugins.cmake rename to pkgs/jnigen/examples/pdfbox_plugin/example/windows/flutter/generated_plugins.cmake diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/CMakeLists.txt b/pkgs/jnigen/examples/pdfbox_plugin/example/windows/runner/CMakeLists.txt similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/CMakeLists.txt rename to pkgs/jnigen/examples/pdfbox_plugin/example/windows/runner/CMakeLists.txt diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/Runner.rc b/pkgs/jnigen/examples/pdfbox_plugin/example/windows/runner/Runner.rc similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/Runner.rc rename to pkgs/jnigen/examples/pdfbox_plugin/example/windows/runner/Runner.rc diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/flutter_window.cpp b/pkgs/jnigen/examples/pdfbox_plugin/example/windows/runner/flutter_window.cpp similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/flutter_window.cpp rename to pkgs/jnigen/examples/pdfbox_plugin/example/windows/runner/flutter_window.cpp diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/flutter_window.h b/pkgs/jnigen/examples/pdfbox_plugin/example/windows/runner/flutter_window.h similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/flutter_window.h rename to pkgs/jnigen/examples/pdfbox_plugin/example/windows/runner/flutter_window.h diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/main.cpp b/pkgs/jnigen/examples/pdfbox_plugin/example/windows/runner/main.cpp similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/main.cpp rename to pkgs/jnigen/examples/pdfbox_plugin/example/windows/runner/main.cpp diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/resource.h b/pkgs/jnigen/examples/pdfbox_plugin/example/windows/runner/resource.h similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/resource.h rename to pkgs/jnigen/examples/pdfbox_plugin/example/windows/runner/resource.h diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/resources/app_icon.ico b/pkgs/jnigen/examples/pdfbox_plugin/example/windows/runner/resources/app_icon.ico similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/resources/app_icon.ico rename to pkgs/jnigen/examples/pdfbox_plugin/example/windows/runner/resources/app_icon.ico diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/runner.exe.manifest b/pkgs/jnigen/examples/pdfbox_plugin/example/windows/runner/runner.exe.manifest similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/runner.exe.manifest rename to pkgs/jnigen/examples/pdfbox_plugin/example/windows/runner/runner.exe.manifest diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/utils.cpp b/pkgs/jnigen/examples/pdfbox_plugin/example/windows/runner/utils.cpp similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/utils.cpp rename to pkgs/jnigen/examples/pdfbox_plugin/example/windows/runner/utils.cpp diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/utils.h b/pkgs/jnigen/examples/pdfbox_plugin/example/windows/runner/utils.h similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/utils.h rename to pkgs/jnigen/examples/pdfbox_plugin/example/windows/runner/utils.h diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/win32_window.cpp b/pkgs/jnigen/examples/pdfbox_plugin/example/windows/runner/win32_window.cpp similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/win32_window.cpp rename to pkgs/jnigen/examples/pdfbox_plugin/example/windows/runner/win32_window.cpp diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/win32_window.h b/pkgs/jnigen/examples/pdfbox_plugin/example/windows/runner/win32_window.h similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/example/windows/runner/win32_window.h rename to pkgs/jnigen/examples/pdfbox_plugin/example/windows/runner/win32_window.h diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/jnigen.yaml b/pkgs/jnigen/examples/pdfbox_plugin/jnigen.yaml similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/jnigen.yaml rename to pkgs/jnigen/examples/pdfbox_plugin/jnigen.yaml diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/jnigen_full.yaml b/pkgs/jnigen/examples/pdfbox_plugin/jnigen_full.yaml similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/jnigen_full.yaml rename to pkgs/jnigen/examples/pdfbox_plugin/jnigen_full.yaml diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/lib/third_party/init.dart b/pkgs/jnigen/examples/pdfbox_plugin/lib/third_party/init.dart similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/lib/third_party/init.dart rename to pkgs/jnigen/examples/pdfbox_plugin/lib/third_party/init.dart diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/lib/third_party/org/apache/pdfbox/pdmodel.dart b/pkgs/jnigen/examples/pdfbox_plugin/lib/third_party/org/apache/pdfbox/pdmodel.dart similarity index 99% rename from pkgs/jni_gen/examples/pdfbox_plugin/lib/third_party/org/apache/pdfbox/pdmodel.dart rename to pkgs/jnigen/examples/pdfbox_plugin/lib/third_party/org/apache/pdfbox/pdmodel.dart index 2eeee3070..f3be916d9 100644 --- a/pkgs/jni_gen/examples/pdfbox_plugin/lib/third_party/org/apache/pdfbox/pdmodel.dart +++ b/pkgs/jnigen/examples/pdfbox_plugin/lib/third_party/org/apache/pdfbox/pdmodel.dart @@ -16,7 +16,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Autogenerated by jni_gen. DO NOT EDIT! +// Autogenerated by jnigen. DO NOT EDIT! // ignore_for_file: camel_case_types // ignore_for_file: non_constant_identifier_names diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/lib/third_party/org/apache/pdfbox/text.dart b/pkgs/jnigen/examples/pdfbox_plugin/lib/third_party/org/apache/pdfbox/text.dart similarity index 99% rename from pkgs/jni_gen/examples/pdfbox_plugin/lib/third_party/org/apache/pdfbox/text.dart rename to pkgs/jnigen/examples/pdfbox_plugin/lib/third_party/org/apache/pdfbox/text.dart index 0b8fe1eaa..6a7d7cc44 100644 --- a/pkgs/jni_gen/examples/pdfbox_plugin/lib/third_party/org/apache/pdfbox/text.dart +++ b/pkgs/jnigen/examples/pdfbox_plugin/lib/third_party/org/apache/pdfbox/text.dart @@ -16,7 +16,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Autogenerated by jni_gen. DO NOT EDIT! +// Autogenerated by jnigen. DO NOT EDIT! // ignore_for_file: camel_case_types // ignore_for_file: non_constant_identifier_names diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/linux/CMakeLists.txt b/pkgs/jnigen/examples/pdfbox_plugin/linux/CMakeLists.txt similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/linux/CMakeLists.txt rename to pkgs/jnigen/examples/pdfbox_plugin/linux/CMakeLists.txt diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/pubspec.yaml b/pkgs/jnigen/examples/pdfbox_plugin/pubspec.yaml similarity index 84% rename from pkgs/jni_gen/examples/pdfbox_plugin/pubspec.yaml rename to pkgs/jnigen/examples/pdfbox_plugin/pubspec.yaml index 7ec1e1f87..78aee9d67 100644 --- a/pkgs/jni_gen/examples/pdfbox_plugin/pubspec.yaml +++ b/pkgs/jnigen/examples/pdfbox_plugin/pubspec.yaml @@ -1,9 +1,9 @@ name: pdfbox_plugin description: | - Example of using jni_gen to generate bindings for a non-trivial library + Example of using jnigen to generate bindings for a non-trivial library version: 0.0.1 publish_to: none -homepage: https://github.com/dart-lang/jni_gen +homepage: https://github.com/dart-lang/jnigen environment: sdk: ">=2.17.6 <3.0.0" @@ -18,7 +18,7 @@ dependencies: dev_dependencies: ## Path dependency for sake of the example - jni_gen: + jnigen: path: ../../ test: any lints: ^2.0.0 diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/src/CMakeLists.txt b/pkgs/jnigen/examples/pdfbox_plugin/src/CMakeLists.txt similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/src/CMakeLists.txt rename to pkgs/jnigen/examples/pdfbox_plugin/src/CMakeLists.txt diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/src/third_party/dartjni.h b/pkgs/jnigen/examples/pdfbox_plugin/src/third_party/dartjni.h similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/src/third_party/dartjni.h rename to pkgs/jnigen/examples/pdfbox_plugin/src/third_party/dartjni.h diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/src/third_party/pdfbox_plugin.c b/pkgs/jnigen/examples/pdfbox_plugin/src/third_party/pdfbox_plugin.c similarity index 99% rename from pkgs/jni_gen/examples/pdfbox_plugin/src/third_party/pdfbox_plugin.c rename to pkgs/jnigen/examples/pdfbox_plugin/src/third_party/pdfbox_plugin.c index a4f00dac5..0de63dec7 100644 --- a/pkgs/jni_gen/examples/pdfbox_plugin/src/third_party/pdfbox_plugin.c +++ b/pkgs/jnigen/examples/pdfbox_plugin/src/third_party/pdfbox_plugin.c @@ -16,7 +16,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Autogenerated by jni_gen. DO NOT EDIT! +// Autogenerated by jnigen. DO NOT EDIT! #include #include "jni.h" diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/tool/generate_bindings.dart b/pkgs/jnigen/examples/pdfbox_plugin/tool/generate_bindings.dart similarity index 97% rename from pkgs/jni_gen/examples/pdfbox_plugin/tool/generate_bindings.dart rename to pkgs/jnigen/examples/pdfbox_plugin/tool/generate_bindings.dart index 547a207f6..615b40432 100644 --- a/pkgs/jni_gen/examples/pdfbox_plugin/tool/generate_bindings.dart +++ b/pkgs/jnigen/examples/pdfbox_plugin/tool/generate_bindings.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. -import 'package:jni_gen/jni_gen.dart'; +import 'package:jnigen/jnigen.dart'; const preamble = ''' // Generated from Apache PDFBox library which is licensed under the Apache License 2.0. diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/windows/.gitignore b/pkgs/jnigen/examples/pdfbox_plugin/windows/.gitignore similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/windows/.gitignore rename to pkgs/jnigen/examples/pdfbox_plugin/windows/.gitignore diff --git a/pkgs/jni_gen/examples/pdfbox_plugin/windows/CMakeLists.txt b/pkgs/jnigen/examples/pdfbox_plugin/windows/CMakeLists.txt similarity index 100% rename from pkgs/jni_gen/examples/pdfbox_plugin/windows/CMakeLists.txt rename to pkgs/jnigen/examples/pdfbox_plugin/windows/CMakeLists.txt diff --git a/pkgs/jni_gen/java/.gitignore b/pkgs/jnigen/java/.gitignore similarity index 100% rename from pkgs/jni_gen/java/.gitignore rename to pkgs/jnigen/java/.gitignore diff --git a/pkgs/jni_gen/java/README.md b/pkgs/jnigen/java/README.md similarity index 85% rename from pkgs/jni_gen/java/README.md rename to pkgs/jnigen/java/README.md index 25a04b319..f304059f7 100644 --- a/pkgs/jni_gen/java/README.md +++ b/pkgs/jnigen/java/README.md @@ -3,10 +3,10 @@ An early version of ApiSummarizer. It analyzes java source code / jars and outputs a JSON representation of the public API. -It's currently used in `jni_gen` to get the information of the Java API. +It's currently used in `jnigen` to get the information of the Java API. ## Build -When using it via `jni_gen`, the `jni_gen:setup` script will take care of building the jar in appropriate location. +When using it via `jnigen`, the `jnigen:setup` script will take care of building the jar in appropriate location. To build the jar manually, run `mvn assembly:assembly` in project root. The jar will be created in `target/` directory. @@ -31,7 +31,7 @@ Here class or package names are specified as fully qualified names, for example Note that some options are directly forwarded to the underlying tool. -ApiSummarizer's current use is in `jni_gen` for obtaining public API of java packages. Only the features strictly required for that purpose are focused upon. +ApiSummarizer's current use is in `jnigen` for obtaining public API of java packages. Only the features strictly required for that purpose are focused upon. ## Running tests Run `mvn surefire:test` diff --git a/pkgs/jni_gen/java/pom.xml b/pkgs/jnigen/java/pom.xml similarity index 94% rename from pkgs/jni_gen/java/pom.xml rename to pkgs/jnigen/java/pom.xml index a36c78f73..61ca7edea 100644 --- a/pkgs/jni_gen/java/pom.xml +++ b/pkgs/jnigen/java/pom.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - com.github.dart_lang.jni_gen + com.github.dart_lang.jnigen ApiSummarizer Summarize public APIs of java packages in JSON or protobuf. 0.0.1-SNAPSHOT @@ -58,7 +58,7 @@ false - com.github.dart_lang.jni_gen.apisummarizer.Main + com.github.dart_lang.jnigen.apisummarizer.Main diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/Main.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/Main.java similarity index 95% rename from pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/Main.java rename to pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/Main.java index f733c8e05..4a8375933 100644 --- a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/Main.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/Main.java @@ -2,15 +2,15 @@ // 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.jni_gen.apisummarizer; +package com.github.dart_lang.jnigen.apisummarizer; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; -import com.github.dart_lang.jni_gen.apisummarizer.disasm.AsmSummarizer; -import com.github.dart_lang.jni_gen.apisummarizer.doclet.SummarizerDoclet; -import com.github.dart_lang.jni_gen.apisummarizer.elements.ClassDecl; -import com.github.dart_lang.jni_gen.apisummarizer.util.Log; +import com.github.dart_lang.jnigen.apisummarizer.disasm.AsmSummarizer; +import com.github.dart_lang.jnigen.apisummarizer.doclet.SummarizerDoclet; +import com.github.dart_lang.jnigen.apisummarizer.elements.ClassDecl; +import com.github.dart_lang.jnigen.apisummarizer.util.Log; import java.io.File; import java.io.FileFilter; import java.io.IOException; diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmAnnotatedElementVisitor.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmAnnotatedElementVisitor.java similarity index 86% rename from pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmAnnotatedElementVisitor.java rename to pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmAnnotatedElementVisitor.java index 8938ed7ab..ca39167f2 100644 --- a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmAnnotatedElementVisitor.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmAnnotatedElementVisitor.java @@ -2,9 +2,9 @@ // 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.jni_gen.apisummarizer.disasm; +package com.github.dart_lang.jnigen.apisummarizer.disasm; -import com.github.dart_lang.jni_gen.apisummarizer.elements.JavaAnnotation; +import com.github.dart_lang.jnigen.apisummarizer.elements.JavaAnnotation; import org.objectweb.asm.AnnotationVisitor; import org.objectweb.asm.Type; diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmAnnotationVisitor.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmAnnotationVisitor.java similarity index 94% rename from pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmAnnotationVisitor.java rename to pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmAnnotationVisitor.java index 7496fc7ad..9f6d5e2ba 100644 --- a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmAnnotationVisitor.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmAnnotationVisitor.java @@ -2,9 +2,9 @@ // 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.jni_gen.apisummarizer.disasm; +package com.github.dart_lang.jnigen.apisummarizer.disasm; -import com.github.dart_lang.jni_gen.apisummarizer.elements.JavaAnnotation; +import com.github.dart_lang.jnigen.apisummarizer.elements.JavaAnnotation; import java.util.ArrayList; import java.util.List; import org.objectweb.asm.AnnotationVisitor; diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmClassVisitor.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmClassVisitor.java similarity index 94% rename from pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmClassVisitor.java rename to pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmClassVisitor.java index faed8312e..187afc179 100644 --- a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmClassVisitor.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmClassVisitor.java @@ -2,14 +2,14 @@ // 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.jni_gen.apisummarizer.disasm; +package com.github.dart_lang.jnigen.apisummarizer.disasm; import static org.objectweb.asm.Opcodes.ACC_PROTECTED; import static org.objectweb.asm.Opcodes.ACC_PUBLIC; -import com.github.dart_lang.jni_gen.apisummarizer.elements.*; -import com.github.dart_lang.jni_gen.apisummarizer.util.SkipException; -import com.github.dart_lang.jni_gen.apisummarizer.util.StreamUtil; +import com.github.dart_lang.jnigen.apisummarizer.elements.*; +import com.github.dart_lang.jnigen.apisummarizer.util.SkipException; +import com.github.dart_lang.jnigen.apisummarizer.util.StreamUtil; import java.util.*; import org.objectweb.asm.*; diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmConstants.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmConstants.java similarity index 84% rename from pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmConstants.java rename to pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmConstants.java index 668db64d8..e3d816510 100644 --- a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmConstants.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmConstants.java @@ -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. -package com.github.dart_lang.jni_gen.apisummarizer.disasm; +package com.github.dart_lang.jnigen.apisummarizer.disasm; import static org.objectweb.asm.Opcodes.ASM9; diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmFieldVisitor.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmFieldVisitor.java similarity index 80% rename from pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmFieldVisitor.java rename to pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmFieldVisitor.java index 5c91cb678..eb72302ab 100644 --- a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmFieldVisitor.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmFieldVisitor.java @@ -2,10 +2,10 @@ // 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.jni_gen.apisummarizer.disasm; +package com.github.dart_lang.jnigen.apisummarizer.disasm; -import com.github.dart_lang.jni_gen.apisummarizer.elements.Field; -import com.github.dart_lang.jni_gen.apisummarizer.elements.JavaAnnotation; +import com.github.dart_lang.jnigen.apisummarizer.elements.Field; +import com.github.dart_lang.jnigen.apisummarizer.elements.JavaAnnotation; import org.objectweb.asm.AnnotationVisitor; import org.objectweb.asm.FieldVisitor; diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmMethodVisitor.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmMethodVisitor.java similarity index 90% rename from pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmMethodVisitor.java rename to pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmMethodVisitor.java index 02f56cfa8..6d66fd6d6 100644 --- a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmMethodVisitor.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmMethodVisitor.java @@ -2,10 +2,10 @@ // 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.jni_gen.apisummarizer.disasm; +package com.github.dart_lang.jnigen.apisummarizer.disasm; -import com.github.dart_lang.jni_gen.apisummarizer.elements.JavaAnnotation; -import com.github.dart_lang.jni_gen.apisummarizer.elements.Method; +import com.github.dart_lang.jnigen.apisummarizer.elements.JavaAnnotation; +import com.github.dart_lang.jnigen.apisummarizer.elements.Method; import java.util.ArrayList; import java.util.List; import org.objectweb.asm.AnnotationVisitor; diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmSummarizer.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmSummarizer.java similarity index 95% rename from pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmSummarizer.java rename to pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmSummarizer.java index af89a0ba7..feee9220a 100644 --- a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/AsmSummarizer.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmSummarizer.java @@ -2,9 +2,9 @@ // 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.jni_gen.apisummarizer.disasm; +package com.github.dart_lang.jnigen.apisummarizer.disasm; -import com.github.dart_lang.jni_gen.apisummarizer.elements.ClassDecl; +import com.github.dart_lang.jnigen.apisummarizer.elements.ClassDecl; import java.io.IOException; import java.util.Arrays; import java.util.List; diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/TypeUtils.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/TypeUtils.java similarity index 92% rename from pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/TypeUtils.java rename to pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/TypeUtils.java index 17dd46e42..70b075a8d 100644 --- a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/disasm/TypeUtils.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/TypeUtils.java @@ -2,15 +2,15 @@ // 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.jni_gen.apisummarizer.disasm; +package com.github.dart_lang.jnigen.apisummarizer.disasm; import static org.objectweb.asm.Opcodes.*; import static org.objectweb.asm.Type.ARRAY; import static org.objectweb.asm.Type.OBJECT; -import com.github.dart_lang.jni_gen.apisummarizer.elements.DeclKind; -import com.github.dart_lang.jni_gen.apisummarizer.elements.TypeUsage; -import com.github.dart_lang.jni_gen.apisummarizer.util.SkipException; +import com.github.dart_lang.jnigen.apisummarizer.elements.DeclKind; +import com.github.dart_lang.jnigen.apisummarizer.elements.TypeUsage; +import com.github.dart_lang.jnigen.apisummarizer.util.SkipException; import java.util.HashMap; import java.util.HashSet; import java.util.Map; diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/doclet/AnnotationVisitor.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/doclet/AnnotationVisitor.java similarity index 97% rename from pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/doclet/AnnotationVisitor.java rename to pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/doclet/AnnotationVisitor.java index 442a9443e..f5343eec0 100644 --- a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/doclet/AnnotationVisitor.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/doclet/AnnotationVisitor.java @@ -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. -package com.github.dart_lang.jni_gen.apisummarizer.doclet; +package com.github.dart_lang.jnigen.apisummarizer.doclet; import java.util.List; import java.util.stream.Collectors; diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/doclet/AstEnv.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/doclet/AstEnv.java similarity index 93% rename from pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/doclet/AstEnv.java rename to pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/doclet/AstEnv.java index 2358a161e..71e31c4cc 100644 --- a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/doclet/AstEnv.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/doclet/AstEnv.java @@ -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. -package com.github.dart_lang.jni_gen.apisummarizer.doclet; +package com.github.dart_lang.jnigen.apisummarizer.doclet; import com.sun.source.util.DocTrees; import javax.lang.model.util.Elements; diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/doclet/ElementBuilders.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/doclet/ElementBuilders.java similarity index 97% rename from pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/doclet/ElementBuilders.java rename to pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/doclet/ElementBuilders.java index 809174f6a..b1af92d67 100644 --- a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/doclet/ElementBuilders.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/doclet/ElementBuilders.java @@ -2,10 +2,10 @@ // 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.jni_gen.apisummarizer.doclet; +package com.github.dart_lang.jnigen.apisummarizer.doclet; -import com.github.dart_lang.jni_gen.apisummarizer.elements.*; -import com.github.dart_lang.jni_gen.apisummarizer.util.StreamUtil; +import com.github.dart_lang.jnigen.apisummarizer.elements.*; +import com.github.dart_lang.jnigen.apisummarizer.util.StreamUtil; import com.sun.source.doctree.DocCommentTree; import java.util.HashMap; import java.util.List; diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/doclet/SummarizerDoclet.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/doclet/SummarizerDoclet.java similarity index 81% rename from pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/doclet/SummarizerDoclet.java rename to pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/doclet/SummarizerDoclet.java index b0dfd7547..0b6d98b86 100644 --- a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/doclet/SummarizerDoclet.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/doclet/SummarizerDoclet.java @@ -2,9 +2,9 @@ // 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.jni_gen.apisummarizer.doclet; +package com.github.dart_lang.jnigen.apisummarizer.doclet; -import com.github.dart_lang.jni_gen.apisummarizer.Main; +import com.github.dart_lang.jnigen.apisummarizer.Main; import jdk.javadoc.doclet.DocletEnvironment; public class SummarizerDoclet extends SummarizerDocletBase { diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/doclet/SummarizerDocletBase.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/doclet/SummarizerDocletBase.java similarity index 92% rename from pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/doclet/SummarizerDocletBase.java rename to pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/doclet/SummarizerDocletBase.java index 8e6067d31..7d9bade44 100644 --- a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/doclet/SummarizerDocletBase.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/doclet/SummarizerDocletBase.java @@ -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. -package com.github.dart_lang.jni_gen.apisummarizer.doclet; +package com.github.dart_lang.jnigen.apisummarizer.doclet; -import com.github.dart_lang.jni_gen.apisummarizer.elements.ClassDecl; -import com.github.dart_lang.jni_gen.apisummarizer.elements.Method; -import com.github.dart_lang.jni_gen.apisummarizer.elements.Package; -import com.github.dart_lang.jni_gen.apisummarizer.util.Log; -import com.github.dart_lang.jni_gen.apisummarizer.util.SkipException; +import com.github.dart_lang.jnigen.apisummarizer.elements.ClassDecl; +import com.github.dart_lang.jnigen.apisummarizer.elements.Method; +import com.github.dart_lang.jnigen.apisummarizer.elements.Package; +import com.github.dart_lang.jnigen.apisummarizer.util.Log; +import com.github.dart_lang.jnigen.apisummarizer.util.SkipException; import java.util.*; import javax.lang.model.SourceVersion; import javax.lang.model.element.*; diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/ClassDecl.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/ClassDecl.java similarity index 96% rename from pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/ClassDecl.java rename to pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/ClassDecl.java index f838d9c80..8131a553b 100644 --- a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/ClassDecl.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/ClassDecl.java @@ -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. -package com.github.dart_lang.jni_gen.apisummarizer.elements; +package com.github.dart_lang.jnigen.apisummarizer.elements; import java.util.ArrayList; import java.util.List; diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/DeclKind.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/DeclKind.java similarity index 82% rename from pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/DeclKind.java rename to pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/DeclKind.java index 376782d41..e2e533ec2 100644 --- a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/DeclKind.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/DeclKind.java @@ -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. -package com.github.dart_lang.jni_gen.apisummarizer.elements; +package com.github.dart_lang.jnigen.apisummarizer.elements; public enum DeclKind { CLASS, diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/Field.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/Field.java similarity index 90% rename from pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/Field.java rename to pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/Field.java index c39c3012d..ced5ceafe 100644 --- a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/Field.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/Field.java @@ -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. -package com.github.dart_lang.jni_gen.apisummarizer.elements; +package com.github.dart_lang.jnigen.apisummarizer.elements; import java.util.ArrayList; import java.util.HashSet; diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/JavaAnnotation.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/JavaAnnotation.java similarity index 90% rename from pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/JavaAnnotation.java rename to pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/JavaAnnotation.java index d45ab0a32..e8ba62438 100644 --- a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/JavaAnnotation.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/JavaAnnotation.java @@ -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. -package com.github.dart_lang.jni_gen.apisummarizer.elements; +package com.github.dart_lang.jnigen.apisummarizer.elements; import java.util.HashMap; import java.util.Map; diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/JavaDocComment.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/JavaDocComment.java similarity index 88% rename from pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/JavaDocComment.java rename to pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/JavaDocComment.java index 3f8d55e0c..c882c97af 100644 --- a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/JavaDocComment.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/JavaDocComment.java @@ -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. -package com.github.dart_lang.jni_gen.apisummarizer.elements; +package com.github.dart_lang.jnigen.apisummarizer.elements; public class JavaDocComment { // TODO(#28): Build a detailed tree representation of JavaDocComment diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/Method.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/Method.java similarity index 91% rename from pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/Method.java rename to pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/Method.java index d1c3cca71..bb558f472 100644 --- a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/Method.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/Method.java @@ -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. -package com.github.dart_lang.jni_gen.apisummarizer.elements; +package com.github.dart_lang.jnigen.apisummarizer.elements; import java.util.ArrayList; import java.util.HashSet; diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/Package.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/Package.java similarity index 81% rename from pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/Package.java rename to pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/Package.java index 8e2cc908b..ca2bfce9d 100644 --- a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/Package.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/Package.java @@ -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. -package com.github.dart_lang.jni_gen.apisummarizer.elements; +package com.github.dart_lang.jnigen.apisummarizer.elements; public class Package { public String name; diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/Param.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/Param.java similarity index 87% rename from pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/Param.java rename to pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/Param.java index 5e50e7311..433f6bf3a 100644 --- a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/Param.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/Param.java @@ -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. -package com.github.dart_lang.jni_gen.apisummarizer.elements; +package com.github.dart_lang.jnigen.apisummarizer.elements; import java.util.ArrayList; import java.util.List; diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/TypeParam.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/TypeParam.java similarity index 84% rename from pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/TypeParam.java rename to pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/TypeParam.java index 17186e55d..9045578ee 100644 --- a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/TypeParam.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/TypeParam.java @@ -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. -package com.github.dart_lang.jni_gen.apisummarizer.elements; +package com.github.dart_lang.jnigen.apisummarizer.elements; import java.util.List; diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/TypeUsage.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/TypeUsage.java similarity index 96% rename from pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/TypeUsage.java rename to pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/TypeUsage.java index 53419ce08..a41b8eabd 100644 --- a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/elements/TypeUsage.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/TypeUsage.java @@ -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. -package com.github.dart_lang.jni_gen.apisummarizer.elements; +package com.github.dart_lang.jnigen.apisummarizer.elements; import java.util.List; diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/util/Log.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/Log.java similarity index 94% rename from pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/util/Log.java rename to pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/Log.java index 7add36bd3..b2b2d78b6 100644 --- a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/util/Log.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/Log.java @@ -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. -package com.github.dart_lang.jni_gen.apisummarizer.util; +package com.github.dart_lang.jnigen.apisummarizer.util; public class Log { private static long lastPrinted = System.currentTimeMillis(); diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/util/SkipException.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/SkipException.java similarity index 89% rename from pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/util/SkipException.java rename to pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/SkipException.java index 158d819f6..1f253b08a 100644 --- a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/util/SkipException.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/SkipException.java @@ -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. -package com.github.dart_lang.jni_gen.apisummarizer.util; +package com.github.dart_lang.jnigen.apisummarizer.util; // Generic skip exception when the code cannot decide how to handle an element. // The caller in some above layer can catch this and skip to appropriate extent. diff --git a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/util/StreamUtil.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/StreamUtil.java similarity index 92% rename from pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/util/StreamUtil.java rename to pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/StreamUtil.java index 2fd2b79b9..7dfa29b2f 100644 --- a/pkgs/jni_gen/java/src/main/java/com/github/dart_lang/jni_gen/apisummarizer/util/StreamUtil.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/StreamUtil.java @@ -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. -package com.github.dart_lang.jni_gen.apisummarizer.util; +package com.github.dart_lang.jnigen.apisummarizer.util; import java.util.Arrays; import java.util.List; diff --git a/pkgs/jni_gen/java/src/test/java/com/github/dart_lang/jni_gen/apisummarizer/DocletSummarizerTests.java b/pkgs/jnigen/java/src/test/java/com/github/dart_lang/jnigen/apisummarizer/DocletSummarizerTests.java similarity index 94% rename from pkgs/jni_gen/java/src/test/java/com/github/dart_lang/jni_gen/apisummarizer/DocletSummarizerTests.java rename to pkgs/jnigen/java/src/test/java/com/github/dart_lang/jnigen/apisummarizer/DocletSummarizerTests.java index afc7a05f6..ff130b4b7 100644 --- a/pkgs/jni_gen/java/src/test/java/com/github/dart_lang/jni_gen/apisummarizer/DocletSummarizerTests.java +++ b/pkgs/jnigen/java/src/test/java/com/github/dart_lang/jnigen/apisummarizer/DocletSummarizerTests.java @@ -2,12 +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. -package com.github.dart_lang.jni_gen.apisummarizer; +package com.github.dart_lang.jnigen.apisummarizer; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import com.github.dart_lang.jni_gen.apisummarizer.elements.ClassDecl; +import com.github.dart_lang.jnigen.apisummarizer.elements.ClassDecl; import java.util.HashMap; import java.util.List; import java.util.Map; diff --git a/pkgs/jni_gen/java/src/test/java/com/github/dart_lang/jni_gen/apisummarizer/TestDoclet.java b/pkgs/jnigen/java/src/test/java/com/github/dart_lang/jnigen/apisummarizer/TestDoclet.java similarity index 72% rename from pkgs/jni_gen/java/src/test/java/com/github/dart_lang/jni_gen/apisummarizer/TestDoclet.java rename to pkgs/jnigen/java/src/test/java/com/github/dart_lang/jnigen/apisummarizer/TestDoclet.java index 188cd19ce..5a3949bae 100644 --- a/pkgs/jni_gen/java/src/test/java/com/github/dart_lang/jni_gen/apisummarizer/TestDoclet.java +++ b/pkgs/jnigen/java/src/test/java/com/github/dart_lang/jnigen/apisummarizer/TestDoclet.java @@ -2,10 +2,10 @@ // 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.jni_gen.apisummarizer; +package com.github.dart_lang.jnigen.apisummarizer; -import com.github.dart_lang.jni_gen.apisummarizer.doclet.SummarizerDocletBase; -import com.github.dart_lang.jni_gen.apisummarizer.elements.ClassDecl; +import com.github.dart_lang.jnigen.apisummarizer.doclet.SummarizerDocletBase; +import com.github.dart_lang.jnigen.apisummarizer.elements.ClassDecl; import java.util.List; import jdk.javadoc.doclet.DocletEnvironment; diff --git a/pkgs/jni_gen/java/src/test/resources/com/example/Example.java b/pkgs/jnigen/java/src/test/resources/com/example/Example.java similarity index 100% rename from pkgs/jni_gen/java/src/test/resources/com/example/Example.java rename to pkgs/jnigen/java/src/test/resources/com/example/Example.java diff --git a/pkgs/jni_gen/lib/jni_gen.dart b/pkgs/jnigen/lib/jnigen.dart similarity index 82% rename from pkgs/jni_gen/lib/jni_gen.dart rename to pkgs/jnigen/lib/jnigen.dart index 33068f404..8e2ebe043 100644 --- a/pkgs/jni_gen/lib/jni_gen.dart +++ b/pkgs/jnigen/lib/jnigen.dart @@ -2,10 +2,10 @@ // 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 exports a high level programmatic API to jni_gen, the entry +/// This library exports a high level programmatic API to jnigen, the entry /// point of which is runJniGenTask function, which takes run configuration as /// a JniGenTask. -library jni_gen; +library jnigen; export 'src/elements/elements.dart'; export 'src/config/config.dart'; diff --git a/pkgs/jni_gen/lib/src/bindings/bindings.dart b/pkgs/jnigen/lib/src/bindings/bindings.dart similarity index 100% rename from pkgs/jni_gen/lib/src/bindings/bindings.dart rename to pkgs/jnigen/lib/src/bindings/bindings.dart diff --git a/pkgs/jni_gen/lib/src/bindings/c_bindings.dart b/pkgs/jnigen/lib/src/bindings/c_bindings.dart similarity index 98% rename from pkgs/jni_gen/lib/src/bindings/c_bindings.dart rename to pkgs/jnigen/lib/src/bindings/c_bindings.dart index f6b7ddf6d..14a2d2ec0 100644 --- a/pkgs/jni_gen/lib/src/bindings/c_bindings.dart +++ b/pkgs/jnigen/lib/src/bindings/c_bindings.dart @@ -2,8 +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:jni_gen/src/elements/elements.dart'; -import 'package:jni_gen/src/config/config.dart'; +import 'package:jnigen/src/elements/elements.dart'; +import 'package:jnigen/src/config/config.dart'; import 'common.dart'; @@ -338,7 +338,7 @@ class CBindingGenerator { } class CPreludes { - static const autoGeneratedNotice = '// Autogenerated by jni_gen. ' + static const autoGeneratedNotice = '// Autogenerated by jnigen. ' 'DO NOT EDIT!\n\n'; static const includes = '#include \n' '#include "jni.h"\n' diff --git a/pkgs/jni_gen/lib/src/bindings/common.dart b/pkgs/jnigen/lib/src/bindings/common.dart similarity index 97% rename from pkgs/jni_gen/lib/src/bindings/common.dart rename to pkgs/jnigen/lib/src/bindings/common.dart index dd46b6bdc..5c93f5433 100644 --- a/pkgs/jni_gen/lib/src/bindings/common.dart +++ b/pkgs/jnigen/lib/src/bindings/common.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. -import 'package:jni_gen/src/elements/elements.dart'; +import 'package:jnigen/src/elements/elements.dart'; String mangledClassName(ClassDecl decl) => decl.binaryName.replaceAll('.', '_').replaceAll('\$', '__'); diff --git a/pkgs/jni_gen/lib/src/bindings/dart_bindings.dart b/pkgs/jnigen/lib/src/bindings/dart_bindings.dart similarity index 98% rename from pkgs/jni_gen/lib/src/bindings/dart_bindings.dart rename to pkgs/jnigen/lib/src/bindings/dart_bindings.dart index 3ca73539e..0f205c2ce 100644 --- a/pkgs/jni_gen/lib/src/bindings/dart_bindings.dart +++ b/pkgs/jnigen/lib/src/bindings/dart_bindings.dart @@ -4,9 +4,9 @@ import 'dart:io'; -import 'package:jni_gen/src/elements/elements.dart'; -import 'package:jni_gen/src/config/config.dart'; -import 'package:jni_gen/src/util/rename_conflict.dart'; +import 'package:jnigen/src/elements/elements.dart'; +import 'package:jnigen/src/config/config.dart'; +import 'package:jnigen/src/util/rename_conflict.dart'; import 'symbol_resolver.dart'; import 'common.dart'; @@ -363,7 +363,7 @@ class DartPreludes { 'final Pointer Function(String sym) ' 'jlookup = Jni.getInstance().initGeneratedLibrary("$libraryName");\n' '\n'; - static const autoGeneratedNotice = '// Autogenerated by jni_gen. ' + static const autoGeneratedNotice = '// Autogenerated by jnigen. ' 'DO NOT EDIT!\n\n'; static const defaultImports = 'import "dart:ffi" as ffi;\n\n' 'import "package:jni/jni.dart" as jni;\n\n'; diff --git a/pkgs/jni_gen/lib/src/bindings/preprocessor.dart b/pkgs/jnigen/lib/src/bindings/preprocessor.dart similarity index 95% rename from pkgs/jni_gen/lib/src/bindings/preprocessor.dart rename to pkgs/jnigen/lib/src/bindings/preprocessor.dart index 21771236b..dabe58472 100644 --- a/pkgs/jni_gen/lib/src/bindings/preprocessor.dart +++ b/pkgs/jnigen/lib/src/bindings/preprocessor.dart @@ -4,9 +4,9 @@ import 'dart:io'; -import 'package:jni_gen/src/elements/elements.dart'; -import 'package:jni_gen/src/config/config.dart'; -import 'package:jni_gen/src/util/rename_conflict.dart'; +import 'package:jnigen/src/elements/elements.dart'; +import 'package:jnigen/src/config/config.dart'; +import 'package:jnigen/src/util/rename_conflict.dart'; import 'common.dart'; /// Preprocessor which fills information needed by both Dart and C generators. diff --git a/pkgs/jni_gen/lib/src/bindings/symbol_resolver.dart b/pkgs/jnigen/lib/src/bindings/symbol_resolver.dart similarity index 98% rename from pkgs/jni_gen/lib/src/bindings/symbol_resolver.dart rename to pkgs/jnigen/lib/src/bindings/symbol_resolver.dart index 0ccdc86ef..530e570f9 100644 --- a/pkgs/jni_gen/lib/src/bindings/symbol_resolver.dart +++ b/pkgs/jnigen/lib/src/bindings/symbol_resolver.dart @@ -6,7 +6,7 @@ // a locally meaningful name, when creating dart bindings import 'dart:math'; -import 'package:jni_gen/src/util/name_utils.dart'; +import 'package:jnigen/src/util/name_utils.dart'; abstract class SymbolResolver { /// Resolve the binary name to a String which can be used in dart code. diff --git a/pkgs/jni_gen/lib/src/config/config.dart b/pkgs/jnigen/lib/src/config/config.dart similarity index 98% rename from pkgs/jni_gen/lib/src/config/config.dart rename to pkgs/jnigen/lib/src/config/config.dart index 6d18085c0..4094e3cca 100644 --- a/pkgs/jni_gen/lib/src/config/config.dart +++ b/pkgs/jnigen/lib/src/config/config.dart @@ -4,7 +4,7 @@ import 'dart:io'; -import 'package:jni_gen/src/elements/elements.dart'; +import 'package:jnigen/src/elements/elements.dart'; import 'yaml_reader.dart'; import 'filters.dart'; @@ -41,14 +41,14 @@ class MavenDownloads { /// The SDK directories for platform stub JARs and sources are searched in the /// same order in which [versions] are specified. /// -/// If [includeSources] is true, `jni_gen` searches for Android SDK sources +/// If [includeSources] is true, `jnigen` searches for Android SDK sources /// as well in the SDK directory and adds them to the source path. /// /// If [addGradleDeps] is true, a gradle stub is run in order to collect the /// actual compile classpath of the `android/` subproject. /// This will fail if there was no previous build of the project, or if a /// `clean` task was run either through flutter or gradle wrapper. In such case, -/// it's required to run `flutter build apk` & retry running `jni_gen`. +/// it's required to run `flutter build apk` & retry running `jnigen`. /// /// A configuration is invalid if [versions] is unspecified or empty, and /// [addGradleDeps] is also false. If [sdkRoot] is not specified but versions is @@ -84,7 +84,7 @@ class AndroidSdkConfig { /// stub in android subproject of this project. /// /// An Android build must have happened before we are able to obtain classpath - /// of Gradle dependencies. Run `flutter build apk` before running a jni_gen + /// of Gradle dependencies. Run `flutter build apk` before running a jnigen /// script with this option. /// /// For the same reason, if the flutter project is a plugin instead of @@ -126,7 +126,7 @@ class BindingExclusions { ClassFilter? classes; } -/// Configuration for jni_gen binding generation. +/// Configuration for jnigen binding generation. class Config { Config({ required this.classes, diff --git a/pkgs/jni_gen/lib/src/config/filters.dart b/pkgs/jnigen/lib/src/config/filters.dart similarity index 98% rename from pkgs/jni_gen/lib/src/config/filters.dart rename to pkgs/jnigen/lib/src/config/filters.dart index 66f161297..962a135de 100644 --- a/pkgs/jni_gen/lib/src/config/filters.dart +++ b/pkgs/jnigen/lib/src/config/filters.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. -import 'package:jni_gen/src/elements/elements.dart'; +import 'package:jnigen/src/elements/elements.dart'; bool _matchesCompletely(String string, Pattern pattern) { final match = pattern.matchAsPrefix(string); diff --git a/pkgs/jni_gen/lib/src/config/yaml_reader.dart b/pkgs/jnigen/lib/src/config/yaml_reader.dart similarity index 100% rename from pkgs/jni_gen/lib/src/config/yaml_reader.dart rename to pkgs/jnigen/lib/src/config/yaml_reader.dart diff --git a/pkgs/jni_gen/lib/src/elements/elements.dart b/pkgs/jnigen/lib/src/elements/elements.dart similarity index 100% rename from pkgs/jni_gen/lib/src/elements/elements.dart rename to pkgs/jnigen/lib/src/elements/elements.dart diff --git a/pkgs/jni_gen/lib/src/elements/elements.g.dart b/pkgs/jnigen/lib/src/elements/elements.g.dart similarity index 100% rename from pkgs/jni_gen/lib/src/elements/elements.g.dart rename to pkgs/jnigen/lib/src/elements/elements.g.dart diff --git a/pkgs/jni_gen/lib/src/generate_bindings.dart b/pkgs/jnigen/lib/src/generate_bindings.dart similarity index 100% rename from pkgs/jni_gen/lib/src/generate_bindings.dart rename to pkgs/jnigen/lib/src/generate_bindings.dart diff --git a/pkgs/jni_gen/lib/src/summary/summary.dart b/pkgs/jnigen/lib/src/summary/summary.dart similarity index 93% rename from pkgs/jni_gen/lib/src/summary/summary.dart rename to pkgs/jnigen/lib/src/summary/summary.dart index a259f277c..5a7d714a3 100644 --- a/pkgs/jni_gen/lib/src/summary/summary.dart +++ b/pkgs/jnigen/lib/src/summary/summary.dart @@ -3,7 +3,7 @@ // BSD-style license that can be found in the LICENSE file. import 'dart:io'; -import 'package:jni_gen/src/util/command_output.dart'; +import 'package:jnigen/src/util/command_output.dart'; /// A command based summary source which calls the ApiSummarizer command. /// [sourcePaths] and [classPaths] can be provided for the summarizer to find @@ -15,11 +15,11 @@ import 'package:jni_gen/src/util/command_output.dart'; /// the directory names reflect actual package paths. For example, a class name /// com.example.pkg.Cls will be mapped to com/example/pkg/Cls.java. /// -/// The default summarizer needs to be built with `jni_gen:setup` +/// The default summarizer needs to be built with `jnigen:setup` /// script before this API is used. class SummarizerCommand { SummarizerCommand({ - this.command = "java -jar .dart_tool/jni_gen/ApiSummarizer.jar", + this.command = "java -jar .dart_tool/jnigen/ApiSummarizer.jar", List? sourcePath, List? classPath, this.extraArgs = const [], diff --git a/pkgs/jni_gen/lib/src/tools/android_sdk_tools.dart b/pkgs/jnigen/lib/src/tools/android_sdk_tools.dart similarity index 100% rename from pkgs/jni_gen/lib/src/tools/android_sdk_tools.dart rename to pkgs/jnigen/lib/src/tools/android_sdk_tools.dart diff --git a/pkgs/jni_gen/lib/src/tools/build_summarizer.dart b/pkgs/jnigen/lib/src/tools/build_summarizer.dart similarity index 86% rename from pkgs/jni_gen/lib/src/tools/build_summarizer.dart rename to pkgs/jnigen/lib/src/tools/build_summarizer.dart index 46847fb68..b018327cd 100644 --- a/pkgs/jni_gen/lib/src/tools/build_summarizer.dart +++ b/pkgs/jnigen/lib/src/tools/build_summarizer.dart @@ -6,17 +6,17 @@ import 'dart:io'; import 'package:path/path.dart'; -import 'package:jni_gen/src/util/find_package.dart'; +import 'package:jnigen/src/util/find_package.dart'; -final toolPath = join('.', '.dart_tool', 'jni_gen'); +final toolPath = join('.', '.dart_tool', 'jnigen'); final mvnTargetDir = join(toolPath, 'target'); final jarFile = join(toolPath, 'ApiSummarizer.jar'); final targetJarFile = join(mvnTargetDir, 'ApiSummarizer.jar'); Future buildApiSummarizer() async { - final pkg = await findPackageRoot('jni_gen'); + final pkg = await findPackageRoot('jnigen'); if (pkg == null) { - stderr.writeln('package jni_gen not found!'); + stderr.writeln('package jnigen not found!'); exitCode = 2; return; } @@ -42,7 +42,7 @@ Future buildSummarizerIfNotExists({bool force = false}) async { final jarExists = await File(jarFile).exists(); final isJarStale = jarExists && await isPackageModifiedAfter( - 'jni_gen', await File(jarFile).lastModified(), 'java/'); + 'jnigen', await File(jarFile).lastModified(), 'java/'); if (isJarStale) { stderr.writeln('Rebuilding ApiSummarizer component since sources ' 'have changed. This might take some time.'); diff --git a/pkgs/jni_gen/lib/src/tools/maven_tools.dart b/pkgs/jnigen/lib/src/tools/maven_tools.dart similarity index 100% rename from pkgs/jni_gen/lib/src/tools/maven_tools.dart rename to pkgs/jnigen/lib/src/tools/maven_tools.dart diff --git a/pkgs/jni_gen/lib/src/tools/tools.dart b/pkgs/jnigen/lib/src/tools/tools.dart similarity index 100% rename from pkgs/jni_gen/lib/src/tools/tools.dart rename to pkgs/jnigen/lib/src/tools/tools.dart diff --git a/pkgs/jni_gen/lib/src/util/command_output.dart b/pkgs/jnigen/lib/src/util/command_output.dart similarity index 100% rename from pkgs/jni_gen/lib/src/util/command_output.dart rename to pkgs/jnigen/lib/src/util/command_output.dart diff --git a/pkgs/jni_gen/lib/src/util/find_package.dart b/pkgs/jnigen/lib/src/util/find_package.dart similarity index 100% rename from pkgs/jni_gen/lib/src/util/find_package.dart rename to pkgs/jnigen/lib/src/util/find_package.dart diff --git a/pkgs/jni_gen/lib/src/util/name_utils.dart b/pkgs/jnigen/lib/src/util/name_utils.dart similarity index 94% rename from pkgs/jni_gen/lib/src/util/name_utils.dart rename to pkgs/jnigen/lib/src/util/name_utils.dart index f75d2db56..38d980be3 100644 --- a/pkgs/jni_gen/lib/src/util/name_utils.dart +++ b/pkgs/jnigen/lib/src/util/name_utils.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. -import 'package:jni_gen/src/elements/elements.dart'; +import 'package:jnigen/src/elements/elements.dart'; String getPackageName(String binaryName) => cutFromLast(binaryName, '.')[0]; diff --git a/pkgs/jni_gen/lib/src/util/rename_conflict.dart b/pkgs/jnigen/lib/src/util/rename_conflict.dart similarity index 100% rename from pkgs/jni_gen/lib/src/util/rename_conflict.dart rename to pkgs/jnigen/lib/src/util/rename_conflict.dart diff --git a/pkgs/jni_gen/lib/src/writers/writers.dart b/pkgs/jnigen/lib/src/writers/writers.dart similarity index 94% rename from pkgs/jni_gen/lib/src/writers/writers.dart rename to pkgs/jnigen/lib/src/writers/writers.dart index 6febf91ff..c1caeb736 100644 --- a/pkgs/jni_gen/lib/src/writers/writers.dart +++ b/pkgs/jnigen/lib/src/writers/writers.dart @@ -4,11 +4,11 @@ import 'dart:io'; -import 'package:jni_gen/src/bindings/bindings.dart'; +import 'package:jnigen/src/bindings/bindings.dart'; -import 'package:jni_gen/src/elements/elements.dart'; -import 'package:jni_gen/src/config/config.dart'; -import 'package:jni_gen/src/util/find_package.dart'; +import 'package:jnigen/src/elements/elements.dart'; +import 'package:jnigen/src/config/config.dart'; +import 'package:jnigen/src/util/find_package.dart'; abstract class BindingsWriter { Future writeBindings(Iterable classes); @@ -119,7 +119,7 @@ class FilesWriter extends BindingsWriter { await _copyFileFromPackage( 'jni', 'src/dartjni.h', cRoot.resolve('$subdir/dartjni.h')); await _copyFileFromPackage( - 'jni_gen', 'cmake/CMakeLists.txt.tmpl', cRoot.resolve('CMakeLists.txt'), + 'jnigen', 'cmake/CMakeLists.txt.tmpl', cRoot.resolve('CMakeLists.txt'), transform: (s) { return s .replaceAll('{{LIBRARY_NAME}}', libraryName) diff --git a/pkgs/jni_gen/lib/tools.dart b/pkgs/jnigen/lib/tools.dart similarity index 91% rename from pkgs/jni_gen/lib/tools.dart rename to pkgs/jnigen/lib/tools.dart index 91934d3f3..252e4b7e7 100644 --- a/pkgs/jni_gen/lib/tools.dart +++ b/pkgs/jnigen/lib/tools.dart @@ -2,6 +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. -library jni_gen_tools; +library jnigen_tools; export 'src/tools/tools.dart'; diff --git a/pkgs/jni_gen/pubspec.yaml b/pkgs/jnigen/pubspec.yaml similarity index 90% rename from pkgs/jni_gen/pubspec.yaml rename to pkgs/jnigen/pubspec.yaml index f347657bb..fd538fc47 100644 --- a/pkgs/jni_gen/pubspec.yaml +++ b/pkgs/jnigen/pubspec.yaml @@ -2,9 +2,9 @@ # 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. -name: jni_gen +name: jnigen version: 0.0.1 -homepage: https://github.com/dart-lang/jni_gen +homepage: https://github.com/dart-lang/jnigen description: Experimental generator for FFI+JNI bindings. environment: diff --git a/pkgs/jni_gen/test/bindings_test.dart b/pkgs/jnigen/test/bindings_test.dart similarity index 94% rename from pkgs/jni_gen/test/bindings_test.dart rename to pkgs/jnigen/test/bindings_test.dart index 51b92eb5d..f8bab76ed 100644 --- a/pkgs/jni_gen/test/bindings_test.dart +++ b/pkgs/jnigen/test/bindings_test.dart @@ -16,8 +16,8 @@ import 'package:path/path.dart' hide equals; import 'package:test/test.dart'; // ignore_for_file: avoid_relative_lib_imports -import 'simple_package_test/lib/com/github/dart_lang/jni_gen/simple_package.dart'; -import 'simple_package_test/lib/com/github/dart_lang/jni_gen/pkg2.dart'; +import 'simple_package_test/lib/com/github/dart_lang/jnigen/simple_package.dart'; +import 'simple_package_test/lib/com/github/dart_lang/jnigen/pkg2.dart'; import 'jackson_core_test/third_party/lib/com/fasterxml/jackson/core.dart'; import 'test_util/test_util.dart'; @@ -37,7 +37,7 @@ Future setupDylibsAndClasses() async { workingDirectory: simplePackageJavaPath); await runCmd('dart', [ 'run', - 'jni_gen:download_maven_jars', + 'jnigen:download_maven_jars', '--config', join(jacksonCorePath, 'jnigen.yaml') ]); diff --git a/pkgs/jni_gen/test/config_test.dart b/pkgs/jnigen/test/config_test.dart similarity index 97% rename from pkgs/jni_gen/test/config_test.dart rename to pkgs/jnigen/test/config_test.dart index e7b8c2536..0c5a78eb6 100644 --- a/pkgs/jni_gen/test/config_test.dart +++ b/pkgs/jnigen/test/config_test.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. -import 'package:jni_gen/src/config/config.dart'; +import 'package:jnigen/src/config/config.dart'; import 'package:test/test.dart'; import 'package:path/path.dart' hide equals; diff --git a/pkgs/jni_gen/test/jackson_core_test/.gitignore b/pkgs/jnigen/test/jackson_core_test/.gitignore similarity index 100% rename from pkgs/jni_gen/test/jackson_core_test/.gitignore rename to pkgs/jnigen/test/jackson_core_test/.gitignore diff --git a/pkgs/jni_gen/test/jackson_core_test/generate.dart b/pkgs/jnigen/test/jackson_core_test/generate.dart similarity index 98% rename from pkgs/jni_gen/test/jackson_core_test/generate.dart rename to pkgs/jnigen/test/jackson_core_test/generate.dart index 919fadb14..32655d5f3 100644 --- a/pkgs/jni_gen/test/jackson_core_test/generate.dart +++ b/pkgs/jnigen/test/jackson_core_test/generate.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. -import 'package:jni_gen/jni_gen.dart'; +import 'package:jnigen/jnigen.dart'; import 'package:path/path.dart' hide equals; const jacksonPreamble = '// Generated from jackson-core which is licensed under' diff --git a/pkgs/jni_gen/test/jackson_core_test/generated_files_test.dart b/pkgs/jnigen/test/jackson_core_test/generated_files_test.dart similarity index 100% rename from pkgs/jni_gen/test/jackson_core_test/generated_files_test.dart rename to pkgs/jnigen/test/jackson_core_test/generated_files_test.dart diff --git a/pkgs/jni_gen/test/jackson_core_test/jnigen.yaml b/pkgs/jnigen/test/jackson_core_test/jnigen.yaml similarity index 100% rename from pkgs/jni_gen/test/jackson_core_test/jnigen.yaml rename to pkgs/jnigen/test/jackson_core_test/jnigen.yaml diff --git a/pkgs/jni_gen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core.dart b/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core.dart similarity index 99% rename from pkgs/jni_gen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core.dart rename to pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core.dart index 6ecc806d3..1f4a1aafa 100644 --- a/pkgs/jni_gen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core.dart @@ -15,7 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Autogenerated by jni_gen. DO NOT EDIT! +// Autogenerated by jnigen. DO NOT EDIT! // ignore_for_file: camel_case_types // ignore_for_file: non_constant_identifier_names diff --git a/pkgs/jni_gen/test/jackson_core_test/third_party/lib/init.dart b/pkgs/jnigen/test/jackson_core_test/third_party/lib/init.dart similarity index 100% rename from pkgs/jni_gen/test/jackson_core_test/third_party/lib/init.dart rename to pkgs/jnigen/test/jackson_core_test/third_party/lib/init.dart diff --git a/pkgs/jni_gen/test/jackson_core_test/third_party/src/CMakeLists.txt b/pkgs/jnigen/test/jackson_core_test/third_party/src/CMakeLists.txt similarity index 100% rename from pkgs/jni_gen/test/jackson_core_test/third_party/src/CMakeLists.txt rename to pkgs/jnigen/test/jackson_core_test/third_party/src/CMakeLists.txt diff --git a/pkgs/jni_gen/test/jackson_core_test/third_party/src/dartjni.h b/pkgs/jnigen/test/jackson_core_test/third_party/src/dartjni.h similarity index 100% rename from pkgs/jni_gen/test/jackson_core_test/third_party/src/dartjni.h rename to pkgs/jnigen/test/jackson_core_test/third_party/src/dartjni.h diff --git a/pkgs/jni_gen/test/jackson_core_test/third_party/src/jackson_core_test.c b/pkgs/jnigen/test/jackson_core_test/third_party/src/jackson_core_test.c similarity index 99% rename from pkgs/jni_gen/test/jackson_core_test/third_party/src/jackson_core_test.c rename to pkgs/jnigen/test/jackson_core_test/third_party/src/jackson_core_test.c index f91f6c00f..a690b7c91 100644 --- a/pkgs/jni_gen/test/jackson_core_test/third_party/src/jackson_core_test.c +++ b/pkgs/jnigen/test/jackson_core_test/third_party/src/jackson_core_test.c @@ -15,7 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Autogenerated by jni_gen. DO NOT EDIT! +// Autogenerated by jnigen. DO NOT EDIT! #include #include "jni.h" diff --git a/pkgs/jni_gen/test/package_resolver_test.dart b/pkgs/jnigen/test/package_resolver_test.dart similarity index 95% rename from pkgs/jni_gen/test/package_resolver_test.dart rename to pkgs/jnigen/test/package_resolver_test.dart index ac5809031..f8f1be8b8 100644 --- a/pkgs/jni_gen/test/package_resolver_test.dart +++ b/pkgs/jnigen/test/package_resolver_test.dart @@ -2,8 +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:jni_gen/src/bindings/symbol_resolver.dart'; -import 'package:jni_gen/src/util/name_utils.dart'; +import 'package:jnigen/src/bindings/symbol_resolver.dart'; +import 'package:jnigen/src/util/name_utils.dart'; import 'package:test/test.dart'; class ResolverTest { diff --git a/pkgs/jni_gen/test/simple_package_test/.gitignore b/pkgs/jnigen/test/simple_package_test/.gitignore similarity index 100% rename from pkgs/jni_gen/test/simple_package_test/.gitignore rename to pkgs/jnigen/test/simple_package_test/.gitignore diff --git a/pkgs/jni_gen/test/simple_package_test/generate.dart b/pkgs/jnigen/test/simple_package_test/generate.dart similarity index 88% rename from pkgs/jni_gen/test/simple_package_test/generate.dart rename to pkgs/jnigen/test/simple_package_test/generate.dart index 2673a0f99..471a648bb 100644 --- a/pkgs/jni_gen/test/simple_package_test/generate.dart +++ b/pkgs/jnigen/test/simple_package_test/generate.dart @@ -5,7 +5,7 @@ import 'dart:io'; import 'package:path/path.dart'; -import 'package:jni_gen/jni_gen.dart'; +import 'package:jnigen/jnigen.dart'; import '../test_util/test_util.dart'; @@ -13,7 +13,7 @@ const testName = 'simple_package_test'; final testRoot = join('test', testName); final javaPath = join(testRoot, 'java'); -var javaPrefix = join('com', 'github', 'dart_lang', 'jni_gen'); +var javaPrefix = join('com', 'github', 'dart_lang', 'jnigen'); var javaFiles = [ join(javaPrefix, 'simple_package', 'Example.java'), @@ -39,8 +39,8 @@ Future generateSources(String lib, String src) async { sourcePath: [Uri.directory(javaPath)], classPath: [Uri.directory(javaPath)], classes: [ - 'com.github.dart_lang.jni_gen.simple_package', - 'com.github.dart_lang.jni_gen.pkg2', + 'com.github.dart_lang.jnigen.simple_package', + 'com.github.dart_lang.jnigen.pkg2', ], cRoot: cWrapperDir, dartRoot: dartWrappersRoot, diff --git a/pkgs/jni_gen/test/simple_package_test/generated_files_test.dart b/pkgs/jnigen/test/simple_package_test/generated_files_test.dart similarity index 100% rename from pkgs/jni_gen/test/simple_package_test/generated_files_test.dart rename to pkgs/jnigen/test/simple_package_test/generated_files_test.dart diff --git a/pkgs/jni_gen/test/simple_package_test/java/com/github/dart_lang/jni_gen/pkg2/C2.java b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/pkg2/C2.java similarity index 56% rename from pkgs/jni_gen/test/simple_package_test/java/com/github/dart_lang/jni_gen/pkg2/C2.java rename to pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/pkg2/C2.java index 2c999c59d..a3c820445 100644 --- a/pkgs/jni_gen/test/simple_package_test/java/com/github/dart_lang/jni_gen/pkg2/C2.java +++ b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/pkg2/C2.java @@ -1,4 +1,4 @@ -package com.github.dart_lang.jni_gen.pkg2; +package com.github.dart_lang.jnigen.pkg2; public class C2 { public static int CONSTANT = 12; diff --git a/pkgs/jni_gen/test/simple_package_test/java/com/github/dart_lang/jni_gen/simple_package/Example.java b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/simple_package/Example.java similarity index 93% rename from pkgs/jni_gen/test/simple_package_test/java/com/github/dart_lang/jni_gen/simple_package/Example.java rename to pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/simple_package/Example.java index 0133b8f9d..81c2dd71d 100644 --- a/pkgs/jni_gen/test/simple_package_test/java/com/github/dart_lang/jni_gen/simple_package/Example.java +++ b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/simple_package/Example.java @@ -1,4 +1,4 @@ -package com.github.dart_lang.jni_gen.simple_package; +package com.github.dart_lang.jnigen.simple_package; public class Example { public static final int ON = 1; diff --git a/pkgs/jni_gen/test/simple_package_test/lib/com/github/dart_lang/jni_gen/pkg2.dart b/pkgs/jnigen/test/simple_package_test/lib/com/github/dart_lang/jnigen/pkg2.dart similarity index 80% rename from pkgs/jni_gen/test/simple_package_test/lib/com/github/dart_lang/jni_gen/pkg2.dart rename to pkgs/jnigen/test/simple_package_test/lib/com/github/dart_lang/jnigen/pkg2.dart index 4f3bea46f..1d9f5eed8 100644 --- a/pkgs/jni_gen/test/simple_package_test/lib/com/github/dart_lang/jni_gen/pkg2.dart +++ b/pkgs/jnigen/test/simple_package_test/lib/com/github/dart_lang/jnigen/pkg2.dart @@ -1,4 +1,4 @@ -// Autogenerated by jni_gen. DO NOT EDIT! +// Autogenerated by jnigen. DO NOT EDIT! // ignore_for_file: camel_case_types // ignore_for_file: non_constant_identifier_names @@ -13,20 +13,20 @@ import "package:jni/jni.dart" as jni; import "../../../../init.dart" show jlookup; -/// from: com.github.dart_lang.jni_gen.pkg2.C2 +/// from: com.github.dart_lang.jnigen.pkg2.C2 class C2 extends jni.JlObject { C2.fromRef(ffi.Pointer ref) : super.fromRef(ref); static final _get_CONSTANT = jlookup>( - "get_com_github_dart_lang_jni_gen_pkg2_C2_CONSTANT") + "get_com_github_dart_lang_jnigen_pkg2_C2_CONSTANT") .asFunction(); /// from: static public int CONSTANT static int get CONSTANT => _get_CONSTANT(); static final _set_CONSTANT = jlookup>( - "set_com_github_dart_lang_jni_gen_pkg2_C2_CONSTANT") + "set_com_github_dart_lang_jnigen_pkg2_C2_CONSTANT") .asFunction(); /// from: static public int CONSTANT @@ -34,7 +34,7 @@ class C2 extends jni.JlObject { static final _ctor = jlookup Function()>>( - "com_github_dart_lang_jni_gen_pkg2_C2_ctor") + "com_github_dart_lang_jnigen_pkg2_C2_ctor") .asFunction Function()>(); /// from: public void () diff --git a/pkgs/jni_gen/test/simple_package_test/lib/com/github/dart_lang/jni_gen/simple_package.dart b/pkgs/jnigen/test/simple_package_test/lib/com/github/dart_lang/jnigen/simple_package.dart similarity index 74% rename from pkgs/jni_gen/test/simple_package_test/lib/com/github/dart_lang/jni_gen/simple_package.dart rename to pkgs/jnigen/test/simple_package_test/lib/com/github/dart_lang/jnigen/simple_package.dart index 370bad814..41655b85b 100644 --- a/pkgs/jni_gen/test/simple_package_test/lib/com/github/dart_lang/jni_gen/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/lib/com/github/dart_lang/jnigen/simple_package.dart @@ -1,4 +1,4 @@ -// Autogenerated by jni_gen. DO NOT EDIT! +// Autogenerated by jnigen. DO NOT EDIT! // ignore_for_file: camel_case_types // ignore_for_file: non_constant_identifier_names @@ -13,7 +13,7 @@ import "package:jni/jni.dart" as jni; import "../../../../init.dart" show jlookup; -/// from: com.github.dart_lang.jni_gen.simple_package.Example +/// from: com.github.dart_lang.jnigen.simple_package.Example class Example extends jni.JlObject { Example.fromRef(ffi.Pointer ref) : super.fromRef(ref); @@ -25,30 +25,30 @@ class Example extends jni.JlObject { static final _get_aux = jlookup Function()>>( - "get_com_github_dart_lang_jni_gen_simple_package_Example_aux") + "get_com_github_dart_lang_jnigen_simple_package_Example_aux") .asFunction Function()>(); - /// from: static public com.github.dart_lang.jni_gen.simple_package.Example.Aux aux + /// from: static public com.github.dart_lang.jnigen.simple_package.Example.Aux aux /// The returned object must be deleted after use, by calling the `delete` method. static Example_Aux get aux => Example_Aux.fromRef(_get_aux()); static final _set_aux = jlookup)>>( - "set_com_github_dart_lang_jni_gen_simple_package_Example_aux") + "set_com_github_dart_lang_jnigen_simple_package_Example_aux") .asFunction)>(); - /// from: static public com.github.dart_lang.jni_gen.simple_package.Example.Aux aux + /// from: static public com.github.dart_lang.jnigen.simple_package.Example.Aux aux /// The returned object must be deleted after use, by calling the `delete` method. static set aux(Example_Aux value) => _set_aux(value.reference); static final _get_num = jlookup>( - "get_com_github_dart_lang_jni_gen_simple_package_Example_num") + "get_com_github_dart_lang_jnigen_simple_package_Example_num") .asFunction(); /// from: static public int num static int get num => _get_num(); static final _set_num = jlookup>( - "set_com_github_dart_lang_jni_gen_simple_package_Example_num") + "set_com_github_dart_lang_jnigen_simple_package_Example_num") .asFunction(); /// from: static public int num @@ -56,7 +56,7 @@ class Example extends jni.JlObject { static final _ctor = jlookup Function()>>( - "com_github_dart_lang_jni_gen_simple_package_Example_ctor") + "com_github_dart_lang_jnigen_simple_package_Example_ctor") .asFunction Function()>(); /// from: public void () @@ -64,16 +64,16 @@ class Example extends jni.JlObject { static final _getAux = jlookup Function()>>( - "com_github_dart_lang_jni_gen_simple_package_Example_getAux") + "com_github_dart_lang_jnigen_simple_package_Example_getAux") .asFunction Function()>(); - /// from: static public com.github.dart_lang.jni_gen.simple_package.Example.Aux getAux() + /// from: static public com.github.dart_lang.jnigen.simple_package.Example.Aux getAux() /// The returned object must be deleted after use, by calling the `delete` method. static Example_Aux getAux() => Example_Aux.fromRef(_getAux()); static final _addInts = jlookup>( - "com_github_dart_lang_jni_gen_simple_package_Example_addInts") + "com_github_dart_lang_jnigen_simple_package_Example_addInts") .asFunction(); /// from: static public int addInts(int a, int b) @@ -82,16 +82,16 @@ class Example extends jni.JlObject { static final _getSelf = jlookup< ffi.NativeFunction< ffi.Pointer Function(ffi.Pointer)>>( - "com_github_dart_lang_jni_gen_simple_package_Example_getSelf") + "com_github_dart_lang_jnigen_simple_package_Example_getSelf") .asFunction Function(ffi.Pointer)>(); - /// from: public com.github.dart_lang.jni_gen.simple_package.Example getSelf() + /// from: public com.github.dart_lang.jnigen.simple_package.Example getSelf() /// The returned object must be deleted after use, by calling the `delete` method. Example getSelf() => Example.fromRef(_getSelf(reference)); static final _getNum = jlookup)>>( - "com_github_dart_lang_jni_gen_simple_package_Example_getNum") + "com_github_dart_lang_jnigen_simple_package_Example_getNum") .asFunction)>(); /// from: public int getNum() @@ -100,14 +100,14 @@ class Example extends jni.JlObject { static final _setNum = jlookup< ffi.NativeFunction< ffi.Void Function(ffi.Pointer, ffi.Int32)>>( - "com_github_dart_lang_jni_gen_simple_package_Example_setNum") + "com_github_dart_lang_jnigen_simple_package_Example_setNum") .asFunction, int)>(); /// from: public void setNum(int num) void setNum(int num) => _setNum(reference, num); } -/// from: com.github.dart_lang.jni_gen.simple_package.Example$Aux +/// from: com.github.dart_lang.jnigen.simple_package.Example$Aux class Example_Aux extends jni.JlObject { Example_Aux.fromRef(ffi.Pointer ref) : super.fromRef(ref); @@ -115,7 +115,7 @@ class Example_Aux extends jni.JlObject { ffi.NativeFunction< ffi.Uint8 Function( ffi.Pointer, - )>>("get_com_github_dart_lang_jni_gen_simple_package_Example__Aux_value") + )>>("get_com_github_dart_lang_jnigen_simple_package_Example__Aux_value") .asFunction< int Function( ffi.Pointer, @@ -126,7 +126,7 @@ class Example_Aux extends jni.JlObject { static final _set_value = jlookup< ffi.NativeFunction< ffi.Void Function(ffi.Pointer, ffi.Uint8)>>( - "set_com_github_dart_lang_jni_gen_simple_package_Example__Aux_value") + "set_com_github_dart_lang_jnigen_simple_package_Example__Aux_value") .asFunction, int)>(); /// from: public boolean value @@ -134,7 +134,7 @@ class Example_Aux extends jni.JlObject { static final _ctor = jlookup Function(ffi.Uint8)>>( - "com_github_dart_lang_jni_gen_simple_package_Example__Aux_ctor") + "com_github_dart_lang_jnigen_simple_package_Example__Aux_ctor") .asFunction Function(int)>(); /// from: public void (boolean value) @@ -142,7 +142,7 @@ class Example_Aux extends jni.JlObject { static final _getValue = jlookup< ffi.NativeFunction)>>( - "com_github_dart_lang_jni_gen_simple_package_Example__Aux_getValue") + "com_github_dart_lang_jnigen_simple_package_Example__Aux_getValue") .asFunction)>(); /// from: public boolean getValue() @@ -151,7 +151,7 @@ class Example_Aux extends jni.JlObject { static final _setValue = jlookup< ffi.NativeFunction< ffi.Void Function(ffi.Pointer, ffi.Uint8)>>( - "com_github_dart_lang_jni_gen_simple_package_Example__Aux_setValue") + "com_github_dart_lang_jnigen_simple_package_Example__Aux_setValue") .asFunction, int)>(); /// from: public void setValue(boolean value) diff --git a/pkgs/jni_gen/test/simple_package_test/lib/init.dart b/pkgs/jnigen/test/simple_package_test/lib/init.dart similarity index 100% rename from pkgs/jni_gen/test/simple_package_test/lib/init.dart rename to pkgs/jnigen/test/simple_package_test/lib/init.dart diff --git a/pkgs/jni_gen/test/simple_package_test/src/CMakeLists.txt b/pkgs/jnigen/test/simple_package_test/src/CMakeLists.txt similarity index 100% rename from pkgs/jni_gen/test/simple_package_test/src/CMakeLists.txt rename to pkgs/jnigen/test/simple_package_test/src/CMakeLists.txt diff --git a/pkgs/jni_gen/test/simple_package_test/src/dartjni.h b/pkgs/jnigen/test/simple_package_test/src/dartjni.h similarity index 100% rename from pkgs/jni_gen/test/simple_package_test/src/dartjni.h rename to pkgs/jnigen/test/simple_package_test/src/dartjni.h diff --git a/pkgs/jnigen/test/simple_package_test/src/simple_package.c b/pkgs/jnigen/test/simple_package_test/src/simple_package.c new file mode 100644 index 000000000..3ab0c5492 --- /dev/null +++ b/pkgs/jnigen/test/simple_package_test/src/simple_package.c @@ -0,0 +1,189 @@ +// Autogenerated by jnigen. DO NOT EDIT! + +#include +#include "jni.h" +#include "dartjni.h" + +thread_local JNIEnv *jniEnv; +struct jni_context jni; + +struct jni_context (*context_getter)(void); +JNIEnv *(*env_getter)(void); + +void setJniGetters(struct jni_context (*cg)(void), + JNIEnv *(*eg)(void)) { + context_getter = cg; + env_getter = eg; +} + +// com.github.dart_lang.jnigen.simple_package.Example +jclass _c_com_github_dart_lang_jnigen_simple_package_Example = NULL; + +jmethodID _m_com_github_dart_lang_jnigen_simple_package_Example_ctor = NULL; +FFI_PLUGIN_EXPORT +jobject com_github_dart_lang_jnigen_simple_package_Example_ctor() { + load_env(); + load_class_gr(&_c_com_github_dart_lang_jnigen_simple_package_Example, "com/github/dart_lang/jnigen/simple_package/Example"); + load_method(_c_com_github_dart_lang_jnigen_simple_package_Example, &_m_com_github_dart_lang_jnigen_simple_package_Example_ctor, "", "()V"); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_com_github_dart_lang_jnigen_simple_package_Example, _m_com_github_dart_lang_jnigen_simple_package_Example_ctor); + return to_global_ref(_result); +} + +jmethodID _m_com_github_dart_lang_jnigen_simple_package_Example_getAux = NULL; +FFI_PLUGIN_EXPORT +jobject com_github_dart_lang_jnigen_simple_package_Example_getAux() { + load_env(); + load_class_gr(&_c_com_github_dart_lang_jnigen_simple_package_Example, "com/github/dart_lang/jnigen/simple_package/Example"); + load_static_method(_c_com_github_dart_lang_jnigen_simple_package_Example, &_m_com_github_dart_lang_jnigen_simple_package_Example_getAux, "getAux", "()Lcom/github/dart_lang/jnigen/simple_package/Example$Aux;"); + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_com_github_dart_lang_jnigen_simple_package_Example, _m_com_github_dart_lang_jnigen_simple_package_Example_getAux); + return to_global_ref(_result); +} + +jmethodID _m_com_github_dart_lang_jnigen_simple_package_Example_addInts = NULL; +FFI_PLUGIN_EXPORT +int32_t com_github_dart_lang_jnigen_simple_package_Example_addInts(int32_t a, int32_t b) { + load_env(); + load_class_gr(&_c_com_github_dart_lang_jnigen_simple_package_Example, "com/github/dart_lang/jnigen/simple_package/Example"); + load_static_method(_c_com_github_dart_lang_jnigen_simple_package_Example, &_m_com_github_dart_lang_jnigen_simple_package_Example_addInts, "addInts", "(II)I"); + int32_t _result = (*jniEnv)->CallStaticIntMethod(jniEnv, _c_com_github_dart_lang_jnigen_simple_package_Example, _m_com_github_dart_lang_jnigen_simple_package_Example_addInts, a, b); + return _result; +} + +jmethodID _m_com_github_dart_lang_jnigen_simple_package_Example_getSelf = NULL; +FFI_PLUGIN_EXPORT +jobject com_github_dart_lang_jnigen_simple_package_Example_getSelf(jobject self_) { + load_env(); + load_class_gr(&_c_com_github_dart_lang_jnigen_simple_package_Example, "com/github/dart_lang/jnigen/simple_package/Example"); + load_method(_c_com_github_dart_lang_jnigen_simple_package_Example, &_m_com_github_dart_lang_jnigen_simple_package_Example_getSelf, "getSelf", "()Lcom/github/dart_lang/jnigen/simple_package/Example;"); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_com_github_dart_lang_jnigen_simple_package_Example_getSelf); + return to_global_ref(_result); +} + +jmethodID _m_com_github_dart_lang_jnigen_simple_package_Example_getNum = NULL; +FFI_PLUGIN_EXPORT +int32_t com_github_dart_lang_jnigen_simple_package_Example_getNum(jobject self_) { + load_env(); + load_class_gr(&_c_com_github_dart_lang_jnigen_simple_package_Example, "com/github/dart_lang/jnigen/simple_package/Example"); + load_method(_c_com_github_dart_lang_jnigen_simple_package_Example, &_m_com_github_dart_lang_jnigen_simple_package_Example_getNum, "getNum", "()I"); + int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_com_github_dart_lang_jnigen_simple_package_Example_getNum); + return _result; +} + +jmethodID _m_com_github_dart_lang_jnigen_simple_package_Example_setNum = NULL; +FFI_PLUGIN_EXPORT +void com_github_dart_lang_jnigen_simple_package_Example_setNum(jobject self_, int32_t num) { + load_env(); + load_class_gr(&_c_com_github_dart_lang_jnigen_simple_package_Example, "com/github/dart_lang/jnigen/simple_package/Example"); + load_method(_c_com_github_dart_lang_jnigen_simple_package_Example, &_m_com_github_dart_lang_jnigen_simple_package_Example_setNum, "setNum", "(I)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_com_github_dart_lang_jnigen_simple_package_Example_setNum, num); +} + +jfieldID _f_com_github_dart_lang_jnigen_simple_package_Example_aux = NULL; +jobject get_com_github_dart_lang_jnigen_simple_package_Example_aux() { + load_env(); + load_class_gr(&_c_com_github_dart_lang_jnigen_simple_package_Example, "com/github/dart_lang/jnigen/simple_package/Example"); + load_static_field(_c_com_github_dart_lang_jnigen_simple_package_Example, &_f_com_github_dart_lang_jnigen_simple_package_Example_aux, "aux","Lcom/github/dart_lang/jnigen/simple_package/Example$Aux;"); + return to_global_ref((*jniEnv)->GetStaticObjectField(jniEnv, _c_com_github_dart_lang_jnigen_simple_package_Example, _f_com_github_dart_lang_jnigen_simple_package_Example_aux)); +} + +void set_com_github_dart_lang_jnigen_simple_package_Example_aux(jobject value) { + load_env(); + load_class_gr(&_c_com_github_dart_lang_jnigen_simple_package_Example, "com/github/dart_lang/jnigen/simple_package/Example"); + load_static_field(_c_com_github_dart_lang_jnigen_simple_package_Example, &_f_com_github_dart_lang_jnigen_simple_package_Example_aux, "aux","Lcom/github/dart_lang/jnigen/simple_package/Example$Aux;"); + ((*jniEnv)->SetStaticObjectField(jniEnv, _c_com_github_dart_lang_jnigen_simple_package_Example, _f_com_github_dart_lang_jnigen_simple_package_Example_aux, value)); +} + + +jfieldID _f_com_github_dart_lang_jnigen_simple_package_Example_num = NULL; +int32_t get_com_github_dart_lang_jnigen_simple_package_Example_num() { + load_env(); + load_class_gr(&_c_com_github_dart_lang_jnigen_simple_package_Example, "com/github/dart_lang/jnigen/simple_package/Example"); + load_static_field(_c_com_github_dart_lang_jnigen_simple_package_Example, &_f_com_github_dart_lang_jnigen_simple_package_Example_num, "num","I"); + return ((*jniEnv)->GetStaticIntField(jniEnv, _c_com_github_dart_lang_jnigen_simple_package_Example, _f_com_github_dart_lang_jnigen_simple_package_Example_num)); +} + +void set_com_github_dart_lang_jnigen_simple_package_Example_num(int32_t value) { + load_env(); + load_class_gr(&_c_com_github_dart_lang_jnigen_simple_package_Example, "com/github/dart_lang/jnigen/simple_package/Example"); + load_static_field(_c_com_github_dart_lang_jnigen_simple_package_Example, &_f_com_github_dart_lang_jnigen_simple_package_Example_num, "num","I"); + ((*jniEnv)->SetStaticIntField(jniEnv, _c_com_github_dart_lang_jnigen_simple_package_Example, _f_com_github_dart_lang_jnigen_simple_package_Example_num, value)); +} + + +// com.github.dart_lang.jnigen.simple_package.Example$Aux +jclass _c_com_github_dart_lang_jnigen_simple_package_Example__Aux = NULL; + +jmethodID _m_com_github_dart_lang_jnigen_simple_package_Example__Aux_ctor = NULL; +FFI_PLUGIN_EXPORT +jobject com_github_dart_lang_jnigen_simple_package_Example__Aux_ctor(uint8_t value) { + load_env(); + load_class_gr(&_c_com_github_dart_lang_jnigen_simple_package_Example__Aux, "com/github/dart_lang/jnigen/simple_package/Example$Aux"); + load_method(_c_com_github_dart_lang_jnigen_simple_package_Example__Aux, &_m_com_github_dart_lang_jnigen_simple_package_Example__Aux_ctor, "", "(Z)V"); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_com_github_dart_lang_jnigen_simple_package_Example__Aux, _m_com_github_dart_lang_jnigen_simple_package_Example__Aux_ctor, value); + return to_global_ref(_result); +} + +jmethodID _m_com_github_dart_lang_jnigen_simple_package_Example__Aux_getValue = NULL; +FFI_PLUGIN_EXPORT +uint8_t com_github_dart_lang_jnigen_simple_package_Example__Aux_getValue(jobject self_) { + load_env(); + load_class_gr(&_c_com_github_dart_lang_jnigen_simple_package_Example__Aux, "com/github/dart_lang/jnigen/simple_package/Example$Aux"); + load_method(_c_com_github_dart_lang_jnigen_simple_package_Example__Aux, &_m_com_github_dart_lang_jnigen_simple_package_Example__Aux_getValue, "getValue", "()Z"); + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_com_github_dart_lang_jnigen_simple_package_Example__Aux_getValue); + return _result; +} + +jmethodID _m_com_github_dart_lang_jnigen_simple_package_Example__Aux_setValue = NULL; +FFI_PLUGIN_EXPORT +void com_github_dart_lang_jnigen_simple_package_Example__Aux_setValue(jobject self_, uint8_t value) { + load_env(); + load_class_gr(&_c_com_github_dart_lang_jnigen_simple_package_Example__Aux, "com/github/dart_lang/jnigen/simple_package/Example$Aux"); + load_method(_c_com_github_dart_lang_jnigen_simple_package_Example__Aux, &_m_com_github_dart_lang_jnigen_simple_package_Example__Aux_setValue, "setValue", "(Z)V"); + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_com_github_dart_lang_jnigen_simple_package_Example__Aux_setValue, value); +} + +jfieldID _f_com_github_dart_lang_jnigen_simple_package_Example__Aux_value = NULL; +uint8_t get_com_github_dart_lang_jnigen_simple_package_Example__Aux_value(jobject self_) { + load_env(); + load_class_gr(&_c_com_github_dart_lang_jnigen_simple_package_Example__Aux, "com/github/dart_lang/jnigen/simple_package/Example$Aux"); + load_field(_c_com_github_dart_lang_jnigen_simple_package_Example__Aux, &_f_com_github_dart_lang_jnigen_simple_package_Example__Aux_value, "value","Z"); + return ((*jniEnv)->GetBooleanField(jniEnv, self_, _f_com_github_dart_lang_jnigen_simple_package_Example__Aux_value)); +} + +void set_com_github_dart_lang_jnigen_simple_package_Example__Aux_value(jobject self_, uint8_t value) { + load_env(); + load_class_gr(&_c_com_github_dart_lang_jnigen_simple_package_Example__Aux, "com/github/dart_lang/jnigen/simple_package/Example$Aux"); + load_field(_c_com_github_dart_lang_jnigen_simple_package_Example__Aux, &_f_com_github_dart_lang_jnigen_simple_package_Example__Aux_value, "value","Z"); + ((*jniEnv)->SetBooleanField(jniEnv, self_, _f_com_github_dart_lang_jnigen_simple_package_Example__Aux_value, value)); +} + + +// com.github.dart_lang.jnigen.pkg2.C2 +jclass _c_com_github_dart_lang_jnigen_pkg2_C2 = NULL; + +jmethodID _m_com_github_dart_lang_jnigen_pkg2_C2_ctor = NULL; +FFI_PLUGIN_EXPORT +jobject com_github_dart_lang_jnigen_pkg2_C2_ctor() { + load_env(); + load_class_gr(&_c_com_github_dart_lang_jnigen_pkg2_C2, "com/github/dart_lang/jnigen/pkg2/C2"); + load_method(_c_com_github_dart_lang_jnigen_pkg2_C2, &_m_com_github_dart_lang_jnigen_pkg2_C2_ctor, "", "()V"); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_com_github_dart_lang_jnigen_pkg2_C2, _m_com_github_dart_lang_jnigen_pkg2_C2_ctor); + return to_global_ref(_result); +} + +jfieldID _f_com_github_dart_lang_jnigen_pkg2_C2_CONSTANT = NULL; +int32_t get_com_github_dart_lang_jnigen_pkg2_C2_CONSTANT() { + load_env(); + load_class_gr(&_c_com_github_dart_lang_jnigen_pkg2_C2, "com/github/dart_lang/jnigen/pkg2/C2"); + load_static_field(_c_com_github_dart_lang_jnigen_pkg2_C2, &_f_com_github_dart_lang_jnigen_pkg2_C2_CONSTANT, "CONSTANT","I"); + return ((*jniEnv)->GetStaticIntField(jniEnv, _c_com_github_dart_lang_jnigen_pkg2_C2, _f_com_github_dart_lang_jnigen_pkg2_C2_CONSTANT)); +} + +void set_com_github_dart_lang_jnigen_pkg2_C2_CONSTANT(int32_t value) { + load_env(); + load_class_gr(&_c_com_github_dart_lang_jnigen_pkg2_C2, "com/github/dart_lang/jnigen/pkg2/C2"); + load_static_field(_c_com_github_dart_lang_jnigen_pkg2_C2, &_f_com_github_dart_lang_jnigen_pkg2_C2_CONSTANT, "CONSTANT","I"); + ((*jniEnv)->SetStaticIntField(jniEnv, _c_com_github_dart_lang_jnigen_pkg2_C2, _f_com_github_dart_lang_jnigen_pkg2_C2_CONSTANT, value)); +} + + diff --git a/pkgs/jni_gen/test/test_util/test_util.dart b/pkgs/jnigen/test/test_util/test_util.dart similarity index 100% rename from pkgs/jni_gen/test/test_util/test_util.dart rename to pkgs/jnigen/test/test_util/test_util.dart diff --git a/pkgs/jni_gen/test/yaml_config_test.dart b/pkgs/jnigen/test/yaml_config_test.dart similarity index 98% rename from pkgs/jni_gen/test/yaml_config_test.dart rename to pkgs/jnigen/test/yaml_config_test.dart index 2f180a60f..330b233d9 100644 --- a/pkgs/jni_gen/test/yaml_config_test.dart +++ b/pkgs/jnigen/test/yaml_config_test.dart @@ -21,7 +21,7 @@ void main() { test('generate and compare bindings using YAML config', () { final jnigenProc = Process.runSync('dart', [ 'run', - 'jni_gen', + 'jnigen', '--config', config, '-Dc_root=$testSrc', From cd369f0b8b8f8691c9cff8c4e66e4ab84d2dfe7d Mon Sep 17 00:00:00 2001 From: Mahesh Hegde <46179734+mahesh-hegde@users.noreply.github.com> Date: Mon, 5 Sep 2022 22:36:44 +0530 Subject: [PATCH 014/139] [jnigen] logging (https://github.com/dart-lang/jnigen/issues/48) --- .../lib/src/bindings/dart_bindings.dart | 11 ++++--- .../jnigen/lib/src/bindings/preprocessor.dart | 14 +++++---- .../lib/src/bindings/symbol_resolver.dart | 11 +++++-- pkgs/jnigen/lib/src/config/config.dart | 28 ++++++++++++++++- pkgs/jnigen/lib/src/generate_bindings.dart | 11 ++++--- pkgs/jnigen/lib/src/logging/logging.dart | 30 ++++++++++++++++++ pkgs/jnigen/lib/src/summary/summary.dart | 3 +- .../lib/src/tools/android_sdk_tools.dart | 24 +++++++++----- .../lib/src/tools/build_summarizer.dart | 31 +++++++++---------- pkgs/jnigen/lib/src/tools/maven_tools.dart | 15 +++------ pkgs/jnigen/lib/src/writers/writers.dart | 21 +++++++------ pkgs/jnigen/pubspec.yaml | 1 + 12 files changed, 137 insertions(+), 63 deletions(-) create mode 100644 pkgs/jnigen/lib/src/logging/logging.dart diff --git a/pkgs/jnigen/lib/src/bindings/dart_bindings.dart b/pkgs/jnigen/lib/src/bindings/dart_bindings.dart index 0f205c2ce..83671611e 100644 --- a/pkgs/jnigen/lib/src/bindings/dart_bindings.dart +++ b/pkgs/jnigen/lib/src/bindings/dart_bindings.dart @@ -2,10 +2,9 @@ // 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:jnigen/src/elements/elements.dart'; import 'package:jnigen/src/config/config.dart'; +import 'package:jnigen/src/logging/logging.dart'; import 'package:jnigen/src/util/rename_conflict.dart'; import 'symbol_resolver.dart'; @@ -41,7 +40,9 @@ class DartBindingsGenerator { if (!decl.isIncluded) { return ''; } - return _class(decl); + final bindings = _class(decl); + log.finest('generated bindings for class ${decl.binaryName}'); + return bindings; } String _class(ClassDecl decl) { @@ -72,7 +73,7 @@ class DartBindingsGenerator { s.write(_field(decl, field)); s.writeln(); } on SkipException catch (e) { - stderr.writeln('skip field ${decl.binaryName}#${field.name}: ' + log.info('skip field ${decl.binaryName}#${field.name}: ' '${e.message}'); } } @@ -85,7 +86,7 @@ class DartBindingsGenerator { s.write(_method(decl, method)); s.writeln(); } on SkipException catch (e) { - stderr.writeln('skip field ${decl.binaryName}#${method.name}: ' + log.info('skip field ${decl.binaryName}#${method.name}: ' '${e.message}'); } } diff --git a/pkgs/jnigen/lib/src/bindings/preprocessor.dart b/pkgs/jnigen/lib/src/bindings/preprocessor.dart index dabe58472..61c2141db 100644 --- a/pkgs/jnigen/lib/src/bindings/preprocessor.dart +++ b/pkgs/jnigen/lib/src/bindings/preprocessor.dart @@ -2,11 +2,11 @@ // 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:jnigen/src/elements/elements.dart'; import 'package:jnigen/src/config/config.dart'; +import 'package:jnigen/src/logging/logging.dart'; import 'package:jnigen/src/util/rename_conflict.dart'; + import 'common.dart'; /// Preprocessor which fills information needed by both Dart and C generators. @@ -22,7 +22,7 @@ class ApiPreprocessor { if (decl.isPreprocessed) return; if (!_isClassIncluded(decl, config)) { decl.isIncluded = false; - stdout.writeln('exclude class ${decl.binaryName}'); + log.info('exclude class ${decl.binaryName}'); decl.isPreprocessed = true; return; } @@ -37,11 +37,12 @@ class ApiPreprocessor { decl.nameCounts.addAll(superclass.nameCounts); } } - + log.finest('Superclass of ${decl.binaryName} resolved to ' + '${superclass?.binaryName}'); for (var field in decl.fields) { if (!_isFieldIncluded(decl, field, config)) { field.isIncluded = false; - stderr.writeln('exclude ${decl.binaryName}#${field.name}'); + log.info('exclude ${decl.binaryName}#${field.name}'); continue; } field.finalName = renameConflict(decl.nameCounts, field.name); @@ -50,7 +51,7 @@ class ApiPreprocessor { for (var method in decl.methods) { if (!_isMethodIncluded(decl, method, config)) { method.isIncluded = false; - stderr.writeln('exclude method ${decl.binaryName}#${method.name}'); + log.info('exclude method ${decl.binaryName}#${method.name}'); continue; } var realName = method.name; @@ -76,6 +77,7 @@ class ApiPreprocessor { } } decl.isPreprocessed = true; + log.finest('preprocessed ${decl.binaryName}'); } static bool _isFieldIncluded(ClassDecl decl, Field field, Config config) => diff --git a/pkgs/jnigen/lib/src/bindings/symbol_resolver.dart b/pkgs/jnigen/lib/src/bindings/symbol_resolver.dart index 530e570f9..45b9e1a12 100644 --- a/pkgs/jnigen/lib/src/bindings/symbol_resolver.dart +++ b/pkgs/jnigen/lib/src/bindings/symbol_resolver.dart @@ -6,6 +6,9 @@ // a locally meaningful name, when creating dart bindings import 'dart:math'; + +import 'package:jnigen/src/logging/logging.dart'; + import 'package:jnigen/src/util/name_utils.dart'; abstract class SymbolResolver { @@ -29,8 +32,9 @@ class PackagePathResolver implements SymbolResolver { final Map _importedNameToPackage = {}; final Map _packageToImportedName = {}; - // return null if type's package cannot be resolved - // else return the fully qualified name of type + + /// Returns the dart name of the [binaryName] in current translation context, + /// or `null` if the name cannot be resolved. @override String? resolve(String binaryName) { if (predefined.containsKey(binaryName)) { @@ -57,6 +61,7 @@ class PackagePathResolver implements SymbolResolver { } final packageImport = getImport(package, binaryName); + log.finest('$package resolved to $packageImport for $binaryName'); if (packageImport == null) { return null; } @@ -67,6 +72,8 @@ class PackagePathResolver implements SymbolResolver { 'qualified binaryName'); } + // We always name imports with an underscore suffix, so that they can be + // never shadowed by a parameter or local variable. var importedName = '${pkgName}_'; int suffix = 0; while (_importedNameToPackage.containsKey(importedName)) { diff --git a/pkgs/jnigen/lib/src/config/config.dart b/pkgs/jnigen/lib/src/config/config.dart index 4094e3cca..136845fac 100644 --- a/pkgs/jnigen/lib/src/config/config.dart +++ b/pkgs/jnigen/lib/src/config/config.dart @@ -9,6 +9,8 @@ import 'package:jnigen/src/elements/elements.dart'; import 'yaml_reader.dart'; import 'filters.dart'; +import 'package:logging/logging.dart'; + /// Configuration for dependencies to be downloaded using maven. /// /// Dependency names should be listed in groupId:artifactId:version format. @@ -142,6 +144,7 @@ class Config { this.androidSdkConfig, this.mavenDownloads, this.summarizerOptions, + this.logLevel = Level.INFO, this.dumpJsonTo, }); @@ -205,8 +208,15 @@ class Config { /// Additional options for the summarizer component SummarizerOptions? summarizerOptions; + /// Log verbosity. The possible values in decreasing order of verbosity + /// are verbose > debug > info > warning > error. Defaults to [LogLevel.info] + Level logLevel = Level.INFO; + + /// File to which JSON summary is written before binding generation. String? dumpJsonTo; + static final _levels = Map.fromEntries( + Level.LEVELS.map((l) => MapEntry(l.name.toLowerCase(), l))); static Uri? _toDirUri(String? path) => path != null ? Uri.directory(path) : null; static List? _toUris(List? paths) => @@ -231,7 +241,7 @@ class Config { for (var exclusion in exclusions) { final split = exclusion.split('#'); if (split.length != 2) { - throw FormatException('Error parsing exclusion: "$exclusion"; ' + throw FormatException('Error parsing exclusion: "$exclusion": ' 'expected to be in binaryName#member format.'); } filters.add(MemberNameFilter.exclude( @@ -252,6 +262,15 @@ class Config { return root; } + Level logLevelFromString(String? levelName) { + if (levelName == null) return Level.INFO; + final level = _levels[levelName.toLowerCase()]; + if (level == null) { + throw ConfigError('Not a valid logging level: $levelName'); + } + return level; + } + final config = Config( sourcePath: _toUris(prov.getStringList(_Props.sourcePath)), classPath: _toUris(prov.getStringList(_Props.classPath)), @@ -295,6 +314,12 @@ class Config { androidExample: prov.getString(_Props.androidExample), ) : null, + logLevel: logLevelFromString( + prov.getOneOf( + _Props.logLevel, + {'error', 'warning', 'info', 'debug', 'verbose'}, + ), + ), ); if (missingValues.isNotEmpty) { stderr.write('Following config values are required but not provided\n' @@ -333,6 +358,7 @@ class _Props { static const dartRoot = 'dart_root'; static const preamble = 'preamble'; static const libraryName = 'library_name'; + static const logLevel = 'log_level'; static const mavenDownloads = 'maven_downloads'; static const sourceDeps = '$mavenDownloads.source_deps'; diff --git a/pkgs/jnigen/lib/src/generate_bindings.dart b/pkgs/jnigen/lib/src/generate_bindings.dart index c6f410e77..b6a64f5ab 100644 --- a/pkgs/jnigen/lib/src/generate_bindings.dart +++ b/pkgs/jnigen/lib/src/generate_bindings.dart @@ -10,8 +10,11 @@ import 'summary/summary.dart'; import 'config/config.dart'; import 'tools/tools.dart'; import 'writers/writers.dart'; +import 'logging/logging.dart'; Future generateJniBindings(Config config) async { + setLoggingLevel(config.logLevel); + await buildSummarizerIfNotExists(); final summarizer = SummarizerCommand( @@ -72,7 +75,7 @@ Future generateJniBindings(Config config) async { try { input = await summarizer.getInputStream(); } on Exception catch (e) { - stderr.writeln('error obtaining API summary: $e'); + log.fatal('Cannot obtain API summary: $e'); return; } final stream = JsonDecoder().bind(Utf8Decoder().bind(input)); @@ -80,11 +83,11 @@ Future generateJniBindings(Config config) async { try { json = await stream.single; } on Exception catch (e) { - stderr.writeln('error while parsing summary: $e'); + log.fatal('Cannot parse summary: $e'); return; } if (json == null) { - stderr.writeln('error: expected JSON element from summarizer.'); + log.fatal('Expected JSON element from summarizer.'); return; } final list = json as List; @@ -93,6 +96,6 @@ Future generateJniBindings(Config config) async { await outputWriter.writeBindings(list.map((c) => ClassDecl.fromJson(c))); } on Exception catch (e, trace) { stderr.writeln(trace); - stderr.writeln('error writing bindings: $e'); + log.fatal('Error while writing bindings: $e'); } } diff --git a/pkgs/jnigen/lib/src/logging/logging.dart b/pkgs/jnigen/lib/src/logging/logging.dart new file mode 100644 index 000000000..526981e51 --- /dev/null +++ b/pkgs/jnigen/lib/src/logging/logging.dart @@ -0,0 +1,30 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +import 'dart:io'; +import 'package:logging/logging.dart'; + +const _ansiRed = '\x1b[31m'; +const _ansiDefault = '\x1b[39;49m'; + +Logger log = Logger('jnigen'); + +void setLoggingLevel(Level level) { + Logger.root.level = level; + Logger.root.onRecord.listen((r) { + var message = '(${r.loggerName}) ${r.level.name}: ${r.message}'; + if (level == Level.SHOUT || level == Level.SEVERE) { + message = '$_ansiRed$message$_ansiDefault'; + } + stderr.writeln(message); + }); +} + +extension FatalErrors on Logger { + void fatal(Object? message, {int exitCode = 2}) { + message = '${_ansiRed}Fatal: $message$_ansiDefault'; + stderr.writeln(message); + exit(exitCode); + } +} diff --git a/pkgs/jnigen/lib/src/summary/summary.dart b/pkgs/jnigen/lib/src/summary/summary.dart index 5a7d714a3..1282ee245 100644 --- a/pkgs/jnigen/lib/src/summary/summary.dart +++ b/pkgs/jnigen/lib/src/summary/summary.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. import 'dart:io'; +import 'package:jnigen/src/logging/logging.dart'; import 'package:jnigen/src/util/command_output.dart'; /// A command based summary source which calls the ApiSummarizer command. @@ -79,7 +80,7 @@ class SummarizerCommand { args.addAll(extraArgs); args.addAll(classes); - stderr.writeln('[exec] $exec ${args.join(' ')}'); + log.info('execute $exec ${args.join(' ')}'); final proc = await Process.start(exec, args, workingDirectory: workingDirectory?.toFilePath() ?? '.'); prefixedCommandOutputStream('[ApiSummarizer]', proc.stderr) diff --git a/pkgs/jnigen/lib/src/tools/android_sdk_tools.dart b/pkgs/jnigen/lib/src/tools/android_sdk_tools.dart index ed78566b9..b903bd6a3 100644 --- a/pkgs/jnigen/lib/src/tools/android_sdk_tools.dart +++ b/pkgs/jnigen/lib/src/tools/android_sdk_tools.dart @@ -5,6 +5,8 @@ import 'dart:io'; import 'package:path/path.dart'; +import 'package:jnigen/src/logging/logging.dart'; + class AndroidSdkTools { /// get path for android API sources static Future _getVersionDir( @@ -25,7 +27,9 @@ class AndroidSdkTools { static Future getAndroidSourcesPath( {String? sdkRoot, required List versionOrder}) async { - return _getVersionDir('sources', sdkRoot, versionOrder); + final dir = _getVersionDir('sources', sdkRoot, versionOrder); + log.info('Found sources at $dir'); + return dir; } static Future _getFile(String relative, String file, String? sdkRoot, @@ -34,6 +38,7 @@ class AndroidSdkTools { if (platform == null) return null; final filePath = join(platform, file); if (await File(filePath).exists()) { + log.info('Found $filePath'); return filePath; } return null; @@ -68,7 +73,7 @@ task listDependencies(type: Copy) { /// If current project is not directly buildable by gradle, eg: a plugin, /// a relative path to other project can be specified using [androidProject]. static List getGradleClasspaths([String androidProject = '.']) { - stderr.writeln('trying to obtain gradle classpaths...'); + log.info('trying to obtain gradle classpaths...'); final android = join(androidProject, 'android'); final buildGradle = join(android, 'build.gradle'); final buildGradleOld = join(android, 'build.gradle.old'); @@ -76,20 +81,23 @@ task listDependencies(type: Copy) { final script = origBuild.readAsStringSync(); origBuild.renameSync(buildGradleOld); origBuild.createSync(); + log.finer('Writing temporary gradle script with stub function...'); origBuild.writeAsStringSync('$script\n$_gradleListDepsFunction\n'); + log.finer('Running gradle wrapper...'); final procRes = Process.runSync('./gradlew', ['-q', 'listDependencies'], workingDirectory: android); + log.finer('Restoring build scripts'); origBuild.writeAsStringSync(script); File(buildGradleOld).deleteSync(); if (procRes.exitCode != 0) { + final inAndroidProject = + (androidProject == '.') ? '' : ' in $androidProject'; throw Exception('\n\ngradle exited with exit code ${procRes.exitCode}\n' 'This can be related to a known issue with gradle. Please run ' - '`flutter build apk` in $androidProject and try again\n'); - } - final gradleClassPaths = (procRes.stdout as String).split('\n'); - if (gradleClassPaths.last.isEmpty) { - gradleClassPaths.removeLast(); + '`flutter build apk`$inAndroidProject and try again\n'); } - return gradleClassPaths; + final classpaths = (procRes.stdout as String).trim().split('\n'); + log.info('Found release build classpath with ${classpaths.length} entries'); + return classpaths; } } diff --git a/pkgs/jnigen/lib/src/tools/build_summarizer.dart b/pkgs/jnigen/lib/src/tools/build_summarizer.dart index b018327cd..d0925490f 100644 --- a/pkgs/jnigen/lib/src/tools/build_summarizer.dart +++ b/pkgs/jnigen/lib/src/tools/build_summarizer.dart @@ -7,6 +7,7 @@ import 'dart:io'; import 'package:path/path.dart'; import 'package:jnigen/src/util/find_package.dart'; +import 'package:jnigen/src/logging/logging.dart'; final toolPath = join('.', '.dart_tool', 'jnigen'); final mvnTargetDir = join(toolPath, 'target'); @@ -16,23 +17,21 @@ final targetJarFile = join(mvnTargetDir, 'ApiSummarizer.jar'); Future buildApiSummarizer() async { final pkg = await findPackageRoot('jnigen'); if (pkg == null) { - stderr.writeln('package jnigen not found!'); - exitCode = 2; + log.fatal('package jnigen not found!'); return; } final pom = pkg.resolve('java/pom.xml'); await Directory(toolPath).create(recursive: true); - final mvnProc = await Process.start( - 'mvn', - [ - '--batch-mode', - '--update-snapshots', - '-f', - pom.toFilePath(), - 'assembly:assembly' - ], - workingDirectory: toolPath, - mode: ProcessStartMode.inheritStdio); + final mvnArgs = [ + '--batch-mode', + '--update-snapshots', + '-f', + pom.toFilePath(), + 'assembly:assembly' + ]; + log.info('execute mvn $mvnArgs'); + final mvnProc = await Process.start('mvn', mvnArgs, + workingDirectory: toolPath, mode: ProcessStartMode.inheritStdio); await mvnProc.exitCode; File(targetJarFile).renameSync(jarFile); Directory(mvnTargetDir).deleteSync(recursive: true); @@ -44,17 +43,17 @@ Future buildSummarizerIfNotExists({bool force = false}) async { await isPackageModifiedAfter( 'jnigen', await File(jarFile).lastModified(), 'java/'); if (isJarStale) { - stderr.writeln('Rebuilding ApiSummarizer component since sources ' + log.info('Rebuilding ApiSummarizer component since sources ' 'have changed. This might take some time.'); } if (!jarExists) { - stderr.write('Building ApiSummarizer component. ' + log.info('Building ApiSummarizer component. ' 'This might take some time. \n' 'The build will be cached for subsequent runs\n'); } if (!jarExists || isJarStale || force) { await buildApiSummarizer(); } else { - stderr.writeln('ApiSummarizer.jar exists. Skipping build..'); + log.info('ApiSummarizer.jar exists. Skipping build..'); } } diff --git a/pkgs/jnigen/lib/src/tools/maven_tools.dart b/pkgs/jnigen/lib/src/tools/maven_tools.dart index 52835d996..b121e3942 100644 --- a/pkgs/jnigen/lib/src/tools/maven_tools.dart +++ b/pkgs/jnigen/lib/src/tools/maven_tools.dart @@ -4,6 +4,8 @@ import 'dart:io'; +import 'package:jnigen/src/logging/logging.dart'; + /// This class provides some utility methods to download a sources / jars /// using maven along with transitive dependencies. class MavenTools { @@ -11,19 +13,10 @@ class MavenTools { static const _tempClassPath = '__temp_classpath.xml'; static const _tempTarget = '__mvn_target'; - static bool _verbose = false; - static void setVerbose(bool enabled) => _verbose = enabled; - - static void _verboseLog(Object? value) { - if (_verbose) { - stderr.writeln(value); - } - } - /// Helper method since we can't pass inheritStdio option to [Process.run]. static Future _runCmd(String exec, List args, [String? workingDirectory]) async { - _verboseLog('[exec] $exec ${args.join(" ")}'); + log.info('execute $exec ${args.join(" ")}'); final proc = await Process.start(exec, args, workingDirectory: workingDirectory, mode: ProcessStartMode.inheritStdio); @@ -33,7 +26,7 @@ class MavenTools { static Future _runMavenCommand( List deps, List mvnArgs) async { final pom = _getStubPom(deps); - _verboseLog('using POM stub:\n$pom'); + log.finer('using POM stub:\n$pom'); await File(_tempPom).writeAsString(pom); await Directory(_tempTarget).create(); await _runCmd('mvn', ['-f', _tempPom, ...mvnArgs]); diff --git a/pkgs/jnigen/lib/src/writers/writers.dart b/pkgs/jnigen/lib/src/writers/writers.dart index c1caeb736..c4f3843c4 100644 --- a/pkgs/jnigen/lib/src/writers/writers.dart +++ b/pkgs/jnigen/lib/src/writers/writers.dart @@ -8,6 +8,7 @@ import 'package:jnigen/src/bindings/bindings.dart'; import 'package:jnigen/src/elements/elements.dart'; import 'package:jnigen/src/config/config.dart'; +import 'package:jnigen/src/logging/logging.dart'; import 'package:jnigen/src/util/find_package.dart'; abstract class BindingsWriter { @@ -58,7 +59,7 @@ class FilesWriter extends BindingsWriter { } final classNames = classesByName.keys.toSet(); - stderr.writeln('Creating dart init file ...'); + log.info('Creating dart init file ...'); final initFileUri = dartRoot.resolve(_initFileName); final initFile = await File.fromUri(initFileUri).create(recursive: true); await initFile.writeAsString(DartPreludes.initFile(config.libraryName), @@ -76,7 +77,7 @@ class FilesWriter extends BindingsWriter { for (var packageName in packages.keys) { final relativeFileName = '${packageName.replaceAll('.', '/')}.dart'; final dartFileUri = dartRoot.resolve(relativeFileName); - stderr.writeln('Writing bindings for $packageName...'); + log.info('Writing bindings for $packageName...'); final dartFile = await File.fromUri(dartFileUri).create(recursive: true); final resolver = PackagePathResolver( config.importMap ?? const {}, packageName, classNames, @@ -107,15 +108,17 @@ class FilesWriter extends BindingsWriter { await dartFileStream.close(); } await cFileStream.close(); - stderr.writeln('Running dart format...'); + log.info('Running dart format...'); final formatRes = await Process.run('dart', ['format', dartRoot.toFilePath()]); - if (formatRes.exitCode != 0) { - stderr.writeln('ERROR: dart format completed with ' - 'exit code ${formatRes.exitCode}'); + // if negative exit code, likely due to an interrupt. + if (formatRes.exitCode > 0) { + log.fatal('Dart format completed with exit code ${formatRes.exitCode} ' + 'This usually means there\'s a syntax error in bindings.\n' + 'Please look at the generated files and report a bug.'); } - stderr.writeln('Copying auxiliary files...'); + log.info('Copying auxiliary files...'); await _copyFileFromPackage( 'jni', 'src/dartjni.h', cRoot.resolve('$subdir/dartjni.h')); await _copyFileFromPackage( @@ -125,7 +128,7 @@ class FilesWriter extends BindingsWriter { .replaceAll('{{LIBRARY_NAME}}', libraryName) .replaceAll('{{SUBDIR}}', subdir); }); - stderr.writeln('Completed.'); + log.info('Completed.'); } Future _copyFileFromPackage(String package, String relPath, Uri target, @@ -140,7 +143,7 @@ class FilesWriter extends BindingsWriter { } await targetFile.writeAsString(source); } else { - stderr.writeln('package $package not found! ' + log.warning('package $package not found! ' 'skipped copying ${target.toFilePath()}'); } } diff --git a/pkgs/jnigen/pubspec.yaml b/pkgs/jnigen/pubspec.yaml index fd538fc47..fe8defab7 100644 --- a/pkgs/jnigen/pubspec.yaml +++ b/pkgs/jnigen/pubspec.yaml @@ -16,6 +16,7 @@ dependencies: path: ^1.8.0 args: ^2.3.0 yaml: ^3.1.0 + logging: ^1.0.2 dev_dependencies: lints: ^2.0.0 From e53465bd79becfbb4ad1d346cecd316c595afe20 Mon Sep 17 00:00:00 2001 From: Mahesh Hegde <46179734+mahesh-hegde@users.noreply.github.com> Date: Tue, 13 Sep 2022 00:51:43 +0530 Subject: [PATCH 015/139] [jnigen] Jni refactor (https://github.com/dart-lang/jnigen/issues/53) --- .github/workflows/test-package.yml | 36 +- pkgs/jni/CHANGELOG.md | 5 +- pkgs/jni/README.md | 11 +- pkgs/jni/analysis_options.yaml | 2 +- pkgs/jni/android/build.gradle | 2 +- pkgs/jni/android/src/main/AndroidManifest.xml | 2 +- .../github/dart_lang}/jni/JniPlugin.java | 2 +- pkgs/jni/bin/setup.dart | 14 +- pkgs/jni/example/README.md | 13 - pkgs/jni/example/android/app/build.gradle | 2 +- .../android/app/src/debug/AndroidManifest.xml | 2 +- .../android/app/src/main/AndroidManifest.xml | 2 +- .../dart_lang/jni_example/Toaster.java} | 13 +- .../dev/dart/jni_example/MainActivity.kt | 2 +- .../app/src/profile/AndroidManifest.xml | 2 +- .../integration_test/jni_object_test.dart | 201 +- pkgs/jni/example/lib/main.dart | 120 +- pkgs/jni/example/linux/CMakeLists.txt | 2 +- .../macos/Runner/Configs/AppInfo.xcconfig | 4 +- pkgs/jni/example/test/widget_test.dart | 50 - pkgs/jni/example/windows/runner/Runner.rc | 4 +- pkgs/jni/ffigen.yaml | 15 +- pkgs/jni/lib/internal_helpers_for_jnigen.dart | 10 + pkgs/jni/lib/jni.dart | 53 +- pkgs/jni/lib/jni_object.dart | 18 - .../jni/lib/src/direct_methods_generated.dart | 634 ---- .../{extensions.dart => env_extensions.dart} | 57 +- pkgs/jni/lib/src/jl_object.dart | 65 - pkgs/jni/lib/src/jni.dart | 308 +- pkgs/jni/lib/src/jni_class.dart | 157 - .../lib/src/jni_class_methods_generated.dart | 412 --- pkgs/jni/lib/src/jni_exceptions.dart | 44 +- pkgs/jni/lib/src/jni_object.dart | 590 +++- .../lib/src/jni_object_methods_generated.dart | 406 --- pkgs/jni/lib/src/jvalues.dart | 26 +- .../third_party/jni_bindings_generated.dart | 2627 ++++++++++------- pkgs/jni/pubspec.yaml | 22 +- pkgs/jni/src/CMakeLists.txt | 1 + pkgs/jni/src/dartjni.c | 75 +- pkgs/jni/src/dartjni.h | 50 +- pkgs/jni/src/global_jni_env.c | 1188 ++++++++ pkgs/jni/src/global_jni_env.h | 219 ++ pkgs/jni/test/exception_test.dart | 51 +- pkgs/jni/test/jni_object_test.dart | 164 +- pkgs/jni/test/jni_test.dart | 170 +- .../.github/workflows/test-package.yml | 78 + .../third_party/ffigen_patch_jni/.gitignore | 41 + pkgs/jni/third_party/ffigen_patch_jni/AUTHORS | 8 + .../third_party/ffigen_patch_jni/CHANGELOG.md | 291 ++ pkgs/jni/third_party/ffigen_patch_jni/LICENSE | 27 + .../third_party/ffigen_patch_jni/README.md | 8 + .../ffigen_patch_jni/analysis_options.yaml | 24 + .../ffigen_patch_jni/bin/ffigen.dart | 6 + .../ffigen_patch_jni/lib/ffigen.dart | 12 + .../ffigen_patch_jni/lib/src/README.md | 41 + .../lib/src/code_generator.dart | 26 + .../lib/src/code_generator/binding.dart | 74 + .../src/code_generator/binding_string.dart | 28 + .../lib/src/code_generator/compound.dart | 276 ++ .../lib/src/code_generator/constant.dart | 65 + .../lib/src/code_generator/dart_keywords.dart | 72 + .../lib/src/code_generator/enum_class.dart | 105 + .../lib/src/code_generator/func.dart | 165 ++ .../lib/src/code_generator/func_type.dart | 83 + .../lib/src/code_generator/global.dart | 86 + .../lib/src/code_generator/handle.dart | 23 + .../lib/src/code_generator/imports.dart | 77 + .../lib/src/code_generator/library.dart | 141 + .../lib/src/code_generator/native_type.dart | 78 + .../lib/src/code_generator/objc_block.dart | 151 + .../objc_built_in_functions.dart | 305 ++ .../src/code_generator/objc_interface.dart | 477 +++ .../lib/src/code_generator/pointer.dart | 63 + .../lib/src/code_generator/struct.dart | 52 + .../lib/src/code_generator/type.dart | 120 + .../lib/src/code_generator/typealias.dart | 86 + .../lib/src/code_generator/union.dart | 49 + .../lib/src/code_generator/utils.dart | 72 + .../lib/src/code_generator/writer.dart | 298 ++ .../lib/src/config_provider.dart | 8 + .../lib/src/config_provider/config.dart | 483 +++ .../lib/src/config_provider/config_types.dart | 373 +++ .../lib/src/config_provider/path_finder.dart | 63 + .../lib/src/config_provider/spec_utils.dart | 866 ++++++ .../lib/src/executables/ffigen.dart | 223 ++ .../lib/src/header_parser.dart | 10 + .../clang_bindings/clang_bindings.dart | 2569 ++++++++++++++++ .../lib/src/header_parser/data.dart | 52 + .../lib/src/header_parser/includer.dart | 90 + .../lib/src/header_parser/parser.dart | 121 + .../sub_parsers/compounddecl_parser.dart | 320 ++ .../sub_parsers/enumdecl_parser.dart | 119 + .../sub_parsers/functiondecl_parser.dart | 130 + .../sub_parsers/macro_parser.dart | 331 +++ .../sub_parsers/objc_block_parser.dart | 40 + .../sub_parsers/objcinterfacedecl_parser.dart | 330 +++ .../sub_parsers/typedefdecl_parser.dart | 84 + .../sub_parsers/unnamed_enumdecl_parser.dart | 70 + .../header_parser/sub_parsers/var_parser.dart | 47 + .../translation_unit_parser.dart | 89 + .../type_extractor/cxtypekindmap.dart | 40 + .../type_extractor/extractor.dart | 305 ++ .../lib/src/header_parser/utils.dart | 395 +++ .../ffigen_patch_jni/lib/src/strings.dart | 221 ++ .../third_party/ffigen_patch_jni/pubspec.yaml | 26 + .../ffigen_patch_jni/tool/coverage.sh | 15 + .../tool/libclang_config.yaml | 119 + pkgs/jni/third_party/jni.h | 1 - pkgs/jni/tool/gen_aux_methods.dart | 138 - .../templates/invoke_static_methods.dart.tmpl | 29 - .../templates/jni_object_fields.dart.tmpl | 16 - .../templates/jni_object_methods.dart.tmpl | 23 - .../retrieve_static_fields.dart.tmpl | 28 - pkgs/jnigen/CHANGELOG.md | 2 + pkgs/jnigen/analysis_options.yaml | 2 +- pkgs/jnigen/example/README.md | 42 + .../in_app_java/.gitignore | 0 .../in_app_java/.metadata | 0 .../in_app_java/README.md | 0 .../in_app_java/analysis_options.yaml | 0 .../in_app_java/android/.gitignore | 0 .../in_app_java/android/app/build.gradle | 0 .../android/app/src/debug/AndroidManifest.xml | 0 .../android/app/src/main/AndroidManifest.xml | 0 .../com/example/in_app_java/AndroidUtils.java | 0 .../com/example/in_app_java/MainActivity.kt | 0 .../res/drawable-v21/launch_background.xml | 0 .../main/res/drawable/launch_background.xml | 0 .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin .../app/src/main/res/values-night/styles.xml | 0 .../app/src/main/res/values/styles.xml | 0 .../app/src/profile/AndroidManifest.xml | 0 .../in_app_java/android/build.gradle | 0 .../in_app_java/android/gradle.properties | 0 .../gradle/wrapper/gradle-wrapper.properties | 0 .../in_app_java/android/settings.gradle | 0 .../in_app_java/jnigen.yaml | 0 .../in_app_java/lib/android_utils/_init.dart | 5 + .../com/example/in_app_java.dart | 21 +- .../in_app_java/lib/main.dart | 6 +- .../in_app_java/pubspec.yaml | 0 .../src/android_utils/CMakeLists.txt | 0 .../src/android_utils/android_utils.c | 10 +- .../in_app_java/src/android_utils}/dartjni.h | 50 +- .../in_app_java/tool/generate_bindings.dart | 0 .../notification_plugin/.gitignore | 0 .../notification_plugin/.metadata | 0 .../notification_plugin/README.md | 0 .../notification_plugin/analysis_options.yaml | 0 .../notification_plugin/android/.gitignore | 0 .../notification_plugin/android/build.gradle | 0 .../android/settings.gradle | 0 .../android/src/main/AndroidManifest.xml | 0 .../notification_plugin/Notifications.java | 0 .../notification_plugin/example/.gitignore | 0 .../notification_plugin/example/README.md | 0 .../example/analysis_options.yaml | 0 .../example/android/.gitignore | 0 .../example/android/app/build.gradle | 0 .../android/app/src/debug/AndroidManifest.xml | 0 .../android/app/src/main/AndroidManifest.xml | 0 .../MainActivity.kt | 0 .../res/drawable-v21/launch_background.xml | 0 .../main/res/drawable/launch_background.xml | 0 .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin .../app/src/main/res/values-night/styles.xml | 0 .../app/src/main/res/values/styles.xml | 0 .../app/src/profile/AndroidManifest.xml | 0 .../example/android/build.gradle | 0 .../example/android/gradle.properties | 0 .../gradle/wrapper/gradle-wrapper.properties | 0 .../example/android/settings.gradle | 0 .../notification_plugin/example/lib/main.dart | 6 +- .../notification_plugin/example/pubspec.yaml | 2 +- .../notification_plugin/jnigen.yaml | 0 .../notification_plugin/lib/_init.dart | 9 + .../lib/com/example/notification_plugin.dart | 24 +- .../notification_plugin/pubspec.yaml | 2 +- .../notification_plugin/src/CMakeLists.txt | 0 .../notification_plugin/src/dartjni.h | 50 +- .../src/notification_plugin.c | 10 +- .../pdfbox_plugin/.gitignore | 0 .../pdfbox_plugin/.metadata | 0 .../pdfbox_plugin/README.md | 0 .../pdfbox_plugin/analysis_options.yaml | 0 .../pdfbox_plugin/android/.gitignore | 0 .../pdfbox_plugin/android/build.gradle | 0 .../pdfbox_plugin/android/settings.gradle | 0 .../android/src/main/AndroidManifest.xml | 0 .../pdfbox_plugin/dart_example/.gitignore | 0 .../pdfbox_plugin/dart_example/CHANGELOG.md | 0 .../pdfbox_plugin/dart_example/README.md | 0 .../dart_example/analysis_options.yaml | 0 .../dart_example/bin/pdf_info.dart | 27 +- .../pdfbox_plugin/dart_example/pubspec.yaml | 2 +- .../pdfbox_plugin/example/.gitignore | 0 .../pdfbox_plugin/example/README.md | 0 .../example/analysis_options.yaml | 0 .../pdfbox_plugin/example/android/.gitignore | 0 .../example/android/app/build.gradle | 0 .../android/app/src/debug/AndroidManifest.xml | 0 .../android/app/src/main/AndroidManifest.xml | 0 .../pdfbox_plugin_example/MainActivity.kt | 0 .../res/drawable-v21/launch_background.xml | 0 .../main/res/drawable/launch_background.xml | 0 .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin .../app/src/main/res/values-night/styles.xml | 0 .../app/src/main/res/values/styles.xml | 0 .../app/src/profile/AndroidManifest.xml | 0 .../example/android/build.gradle | 0 .../example/android/gradle.properties | 0 .../gradle/wrapper/gradle-wrapper.properties | 0 .../example/android/settings.gradle | 0 .../pdfbox_plugin/example/lib/main.dart | 22 +- .../pdfbox_plugin/example/linux/.gitignore | 0 .../example/linux/CMakeLists.txt | 0 .../example/linux/flutter/CMakeLists.txt | 0 .../flutter/generated_plugin_registrant.cc | 0 .../flutter/generated_plugin_registrant.h | 0 .../linux/flutter/generated_plugins.cmake | 0 .../pdfbox_plugin/example/linux/main.cc | 0 .../example/linux/my_application.cc | 0 .../example/linux/my_application.h | 0 .../pdfbox_plugin/example/pubspec.yaml | 2 +- .../pdfbox_plugin/example/windows/.gitignore | 0 .../example/windows/CMakeLists.txt | 0 .../example/windows/flutter/CMakeLists.txt | 0 .../flutter/generated_plugin_registrant.cc | 0 .../flutter/generated_plugin_registrant.h | 0 .../windows/flutter/generated_plugins.cmake | 0 .../example/windows/runner/CMakeLists.txt | 0 .../example/windows/runner/Runner.rc | 0 .../example/windows/runner/flutter_window.cpp | 0 .../example/windows/runner/flutter_window.h | 0 .../example/windows/runner/main.cpp | 0 .../example/windows/runner/resource.h | 0 .../windows/runner/resources/app_icon.ico | Bin .../windows/runner/runner.exe.manifest | 0 .../example/windows/runner/utils.cpp | 0 .../example/windows/runner/utils.h | 0 .../example/windows/runner/win32_window.cpp | 0 .../example/windows/runner/win32_window.h | 0 .../pdfbox_plugin/jnigen.yaml | 0 .../pdfbox_plugin/jnigen_full.yaml | 0 .../pdfbox_plugin/lib/third_party/_init.dart | 23 + .../org/apache/pdfbox/pdmodel.dart | 1097 ++++--- .../third_party/org/apache/pdfbox/text.dart | 1038 ++++--- .../pdfbox_plugin/linux/CMakeLists.txt | 0 .../pdfbox_plugin/pubspec.yaml | 2 +- .../pdfbox_plugin/src/CMakeLists.txt | 0 .../pdfbox_plugin/src/third_party}/dartjni.h | 50 +- .../src/third_party/pdfbox_plugin.c | 464 ++- .../pdfbox_plugin/tool/generate_bindings.dart | 0 .../pdfbox_plugin/windows/.gitignore | 0 .../pdfbox_plugin/windows/CMakeLists.txt | 0 pkgs/jnigen/examples/README.md | 11 - .../in_app_java/lib/android_utils/init.dart | 5 - .../notification_plugin/lib/init.dart | 5 - .../pdfbox_plugin/lib/third_party/init.dart | 5 - pkgs/jnigen/lib/src/bindings/c_bindings.dart | 19 +- pkgs/jnigen/lib/src/bindings/common.dart | 1 + .../lib/src/bindings/dart_bindings.dart | 32 +- pkgs/jnigen/lib/src/elements/elements.dart | 17 +- pkgs/jnigen/lib/src/writers/writers.dart | 13 +- pkgs/jnigen/pubspec.yaml | 2 +- pkgs/jnigen/test/bindings_test.dart | 33 +- .../third_party/lib/_init.dart | 22 + .../lib/com/fasterxml/jackson/core.dart | 1850 ++++++++---- .../third_party/lib/init.dart | 5 - .../third_party/src/dartjni.h | 50 +- .../third_party/src/jackson_core_test.c | 435 ++- .../test/simple_package_test/generate.dart | 8 + .../generated_files_test.dart | 12 +- .../com/github/dart_lang/jnigen/pkg2/C2.java | 4 + .../jnigen/simple_package/Example.java | 8 + .../test/simple_package_test/lib/_init.dart | 9 + .../lib/com/github/dart_lang/jnigen/pkg2.dart | 19 +- .../dart_lang/jnigen/simple_package.dart | 103 +- .../test/simple_package_test/lib/init.dart | 5 - .../test/simple_package_test/src/dartjni.h | 50 +- .../simple_package_test/src/simple_package.c | 50 +- pkgs/jnigen/test/test_util/test_util.dart | 4 + 294 files changed, 19239 insertions(+), 5641 deletions(-) rename pkgs/jni/android/src/main/java/{dev/dart => com/github/dart_lang}/jni/JniPlugin.java (98%) rename pkgs/jni/example/android/app/src/main/java/{dev/dart/jni_example/AnyToast.java => com/github/dart_lang/jni_example/Toaster.java} (53%) delete mode 100644 pkgs/jni/example/test/widget_test.dart create mode 100644 pkgs/jni/lib/internal_helpers_for_jnigen.dart delete mode 100644 pkgs/jni/lib/jni_object.dart delete mode 100644 pkgs/jni/lib/src/direct_methods_generated.dart rename pkgs/jni/lib/src/{extensions.dart => env_extensions.dart} (83%) delete mode 100644 pkgs/jni/lib/src/jl_object.dart delete mode 100644 pkgs/jni/lib/src/jni_class.dart delete mode 100644 pkgs/jni/lib/src/jni_class_methods_generated.dart delete mode 100644 pkgs/jni/lib/src/jni_object_methods_generated.dart create mode 100644 pkgs/jni/src/global_jni_env.c create mode 100644 pkgs/jni/src/global_jni_env.h create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/.github/workflows/test-package.yml create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/.gitignore create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/AUTHORS create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/CHANGELOG.md create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/LICENSE create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/README.md create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/analysis_options.yaml create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/bin/ffigen.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/ffigen.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/README.md create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/binding.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/binding_string.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/compound.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/constant.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/dart_keywords.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/enum_class.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/func.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/func_type.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/global.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/handle.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/imports.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/library.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/native_type.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/objc_block.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/objc_built_in_functions.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/objc_interface.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/pointer.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/struct.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/type.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/typealias.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/union.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/utils.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/writer.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/config_provider.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/config_provider/config.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/config_provider/config_types.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/config_provider/path_finder.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/config_provider/spec_utils.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/executables/ffigen.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/clang_bindings/clang_bindings.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/data.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/includer.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/parser.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/compounddecl_parser.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/enumdecl_parser.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/functiondecl_parser.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/macro_parser.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/objc_block_parser.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/objcinterfacedecl_parser.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/typedefdecl_parser.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/unnamed_enumdecl_parser.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/var_parser.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/translation_unit_parser.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/type_extractor/cxtypekindmap.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/type_extractor/extractor.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/utils.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/strings.dart create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/pubspec.yaml create mode 100755 pkgs/jni/third_party/ffigen_patch_jni/tool/coverage.sh create mode 100644 pkgs/jni/third_party/ffigen_patch_jni/tool/libclang_config.yaml delete mode 100644 pkgs/jni/tool/gen_aux_methods.dart delete mode 100644 pkgs/jni/tool/templates/invoke_static_methods.dart.tmpl delete mode 100644 pkgs/jni/tool/templates/jni_object_fields.dart.tmpl delete mode 100644 pkgs/jni/tool/templates/jni_object_methods.dart.tmpl delete mode 100644 pkgs/jni/tool/templates/retrieve_static_fields.dart.tmpl create mode 100644 pkgs/jnigen/CHANGELOG.md create mode 100644 pkgs/jnigen/example/README.md rename pkgs/jnigen/{examples => example}/in_app_java/.gitignore (100%) rename pkgs/jnigen/{examples => example}/in_app_java/.metadata (100%) rename pkgs/jnigen/{examples => example}/in_app_java/README.md (100%) rename pkgs/jnigen/{examples => example}/in_app_java/analysis_options.yaml (100%) rename pkgs/jnigen/{examples => example}/in_app_java/android/.gitignore (100%) rename pkgs/jnigen/{examples => example}/in_app_java/android/app/build.gradle (100%) rename pkgs/jnigen/{examples => example}/in_app_java/android/app/src/debug/AndroidManifest.xml (100%) rename pkgs/jnigen/{examples => example}/in_app_java/android/app/src/main/AndroidManifest.xml (100%) rename pkgs/jnigen/{examples => example}/in_app_java/android/app/src/main/java/com/example/in_app_java/AndroidUtils.java (100%) rename pkgs/jnigen/{examples => example}/in_app_java/android/app/src/main/kotlin/com/example/in_app_java/MainActivity.kt (100%) rename pkgs/jnigen/{examples => example}/in_app_java/android/app/src/main/res/drawable-v21/launch_background.xml (100%) rename pkgs/jnigen/{examples => example}/in_app_java/android/app/src/main/res/drawable/launch_background.xml (100%) rename pkgs/jnigen/{examples => example}/in_app_java/android/app/src/main/res/mipmap-hdpi/ic_launcher.png (100%) rename pkgs/jnigen/{examples => example}/in_app_java/android/app/src/main/res/mipmap-mdpi/ic_launcher.png (100%) rename pkgs/jnigen/{examples => example}/in_app_java/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png (100%) rename pkgs/jnigen/{examples => example}/in_app_java/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png (100%) rename pkgs/jnigen/{examples => example}/in_app_java/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png (100%) rename pkgs/jnigen/{examples => example}/in_app_java/android/app/src/main/res/values-night/styles.xml (100%) rename pkgs/jnigen/{examples => example}/in_app_java/android/app/src/main/res/values/styles.xml (100%) rename pkgs/jnigen/{examples => example}/in_app_java/android/app/src/profile/AndroidManifest.xml (100%) rename pkgs/jnigen/{examples => example}/in_app_java/android/build.gradle (100%) rename pkgs/jnigen/{examples => example}/in_app_java/android/gradle.properties (100%) rename pkgs/jnigen/{examples => example}/in_app_java/android/gradle/wrapper/gradle-wrapper.properties (100%) rename pkgs/jnigen/{examples => example}/in_app_java/android/settings.gradle (100%) rename pkgs/jnigen/{examples => example}/in_app_java/jnigen.yaml (100%) create mode 100644 pkgs/jnigen/example/in_app_java/lib/android_utils/_init.dart rename pkgs/jnigen/{examples => example}/in_app_java/lib/android_utils/com/example/in_app_java.dart (68%) rename pkgs/jnigen/{examples => example}/in_app_java/lib/main.dart (89%) rename pkgs/jnigen/{examples => example}/in_app_java/pubspec.yaml (100%) rename pkgs/jnigen/{examples => example}/in_app_java/src/android_utils/CMakeLists.txt (100%) rename pkgs/jnigen/{examples => example}/in_app_java/src/android_utils/android_utils.c (79%) rename pkgs/jnigen/{examples/pdfbox_plugin/src/third_party => example/in_app_java/src/android_utils}/dartjni.h (81%) rename pkgs/jnigen/{examples => example}/in_app_java/tool/generate_bindings.dart (100%) rename pkgs/jnigen/{examples => example}/notification_plugin/.gitignore (100%) rename pkgs/jnigen/{examples => example}/notification_plugin/.metadata (100%) rename pkgs/jnigen/{examples => example}/notification_plugin/README.md (100%) rename pkgs/jnigen/{examples => example}/notification_plugin/analysis_options.yaml (100%) rename pkgs/jnigen/{examples => example}/notification_plugin/android/.gitignore (100%) rename pkgs/jnigen/{examples => example}/notification_plugin/android/build.gradle (100%) rename pkgs/jnigen/{examples => example}/notification_plugin/android/settings.gradle (100%) rename pkgs/jnigen/{examples => example}/notification_plugin/android/src/main/AndroidManifest.xml (100%) rename pkgs/jnigen/{examples => example}/notification_plugin/android/src/main/java/com/example/notification_plugin/Notifications.java (100%) rename pkgs/jnigen/{examples => example}/notification_plugin/example/.gitignore (100%) rename pkgs/jnigen/{examples => example}/notification_plugin/example/README.md (100%) rename pkgs/jnigen/{examples => example}/notification_plugin/example/analysis_options.yaml (100%) rename pkgs/jnigen/{examples => example}/notification_plugin/example/android/.gitignore (100%) rename pkgs/jnigen/{examples => example}/notification_plugin/example/android/app/build.gradle (100%) rename pkgs/jnigen/{examples => example}/notification_plugin/example/android/app/src/debug/AndroidManifest.xml (100%) rename pkgs/jnigen/{examples => example}/notification_plugin/example/android/app/src/main/AndroidManifest.xml (100%) rename pkgs/jnigen/{examples => example}/notification_plugin/example/android/app/src/main/kotlin/com/example/notification_plugin_example/MainActivity.kt (100%) rename pkgs/jnigen/{examples => example}/notification_plugin/example/android/app/src/main/res/drawable-v21/launch_background.xml (100%) rename pkgs/jnigen/{examples => example}/notification_plugin/example/android/app/src/main/res/drawable/launch_background.xml (100%) rename pkgs/jnigen/{examples => example}/notification_plugin/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png (100%) rename pkgs/jnigen/{examples => example}/notification_plugin/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png (100%) rename pkgs/jnigen/{examples => example}/notification_plugin/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png (100%) rename pkgs/jnigen/{examples => example}/notification_plugin/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png (100%) rename pkgs/jnigen/{examples => example}/notification_plugin/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png (100%) rename pkgs/jnigen/{examples => example}/notification_plugin/example/android/app/src/main/res/values-night/styles.xml (100%) rename pkgs/jnigen/{examples => example}/notification_plugin/example/android/app/src/main/res/values/styles.xml (100%) rename pkgs/jnigen/{examples => example}/notification_plugin/example/android/app/src/profile/AndroidManifest.xml (100%) rename pkgs/jnigen/{examples => example}/notification_plugin/example/android/build.gradle (100%) rename pkgs/jnigen/{examples => example}/notification_plugin/example/android/gradle.properties (100%) rename pkgs/jnigen/{examples => example}/notification_plugin/example/android/gradle/wrapper/gradle-wrapper.properties (100%) rename pkgs/jnigen/{examples => example}/notification_plugin/example/android/settings.gradle (100%) rename pkgs/jnigen/{examples => example}/notification_plugin/example/lib/main.dart (93%) rename pkgs/jnigen/{examples => example}/notification_plugin/example/pubspec.yaml (98%) rename pkgs/jnigen/{examples => example}/notification_plugin/jnigen.yaml (100%) create mode 100644 pkgs/jnigen/example/notification_plugin/lib/_init.dart rename pkgs/jnigen/{examples => example}/notification_plugin/lib/com/example/notification_plugin.dart (71%) rename pkgs/jnigen/{examples => example}/notification_plugin/pubspec.yaml (96%) rename pkgs/jnigen/{examples => example}/notification_plugin/src/CMakeLists.txt (100%) rename pkgs/jnigen/{examples => example}/notification_plugin/src/dartjni.h (81%) rename pkgs/jnigen/{examples => example}/notification_plugin/src/notification_plugin.c (81%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/.gitignore (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/.metadata (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/README.md (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/analysis_options.yaml (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/android/.gitignore (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/android/build.gradle (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/android/settings.gradle (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/android/src/main/AndroidManifest.xml (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/dart_example/.gitignore (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/dart_example/CHANGELOG.md (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/dart_example/README.md (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/dart_example/analysis_options.yaml (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/dart_example/bin/pdf_info.dart (74%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/dart_example/pubspec.yaml (99%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/.gitignore (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/README.md (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/analysis_options.yaml (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/android/.gitignore (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/android/app/build.gradle (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/android/app/src/debug/AndroidManifest.xml (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/android/app/src/main/AndroidManifest.xml (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/android/app/src/main/kotlin/com/example/pdfbox_plugin_example/MainActivity.kt (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/android/app/src/main/res/drawable-v21/launch_background.xml (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/android/app/src/main/res/drawable/launch_background.xml (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/android/app/src/main/res/values-night/styles.xml (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/android/app/src/main/res/values/styles.xml (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/android/app/src/profile/AndroidManifest.xml (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/android/build.gradle (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/android/gradle.properties (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/android/gradle/wrapper/gradle-wrapper.properties (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/android/settings.gradle (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/lib/main.dart (92%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/linux/.gitignore (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/linux/CMakeLists.txt (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/linux/flutter/CMakeLists.txt (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/linux/flutter/generated_plugin_registrant.cc (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/linux/flutter/generated_plugin_registrant.h (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/linux/flutter/generated_plugins.cmake (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/linux/main.cc (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/linux/my_application.cc (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/linux/my_application.h (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/pubspec.yaml (98%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/windows/.gitignore (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/windows/CMakeLists.txt (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/windows/flutter/CMakeLists.txt (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/windows/flutter/generated_plugin_registrant.cc (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/windows/flutter/generated_plugin_registrant.h (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/windows/flutter/generated_plugins.cmake (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/windows/runner/CMakeLists.txt (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/windows/runner/Runner.rc (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/windows/runner/flutter_window.cpp (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/windows/runner/flutter_window.h (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/windows/runner/main.cpp (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/windows/runner/resource.h (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/windows/runner/resources/app_icon.ico (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/windows/runner/runner.exe.manifest (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/windows/runner/utils.cpp (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/windows/runner/utils.h (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/windows/runner/win32_window.cpp (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/example/windows/runner/win32_window.h (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/jnigen.yaml (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/jnigen_full.yaml (100%) create mode 100644 pkgs/jnigen/example/pdfbox_plugin/lib/third_party/_init.dart rename pkgs/jnigen/{examples => example}/pdfbox_plugin/lib/third_party/org/apache/pdfbox/pdmodel.dart (77%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/lib/third_party/org/apache/pdfbox/text.dart (76%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/linux/CMakeLists.txt (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/pubspec.yaml (98%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/src/CMakeLists.txt (100%) rename pkgs/jnigen/{examples/in_app_java/src/android_utils => example/pdfbox_plugin/src/third_party}/dartjni.h (81%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/src/third_party/pdfbox_plugin.c (81%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/tool/generate_bindings.dart (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/windows/.gitignore (100%) rename pkgs/jnigen/{examples => example}/pdfbox_plugin/windows/CMakeLists.txt (100%) delete mode 100644 pkgs/jnigen/examples/README.md delete mode 100644 pkgs/jnigen/examples/in_app_java/lib/android_utils/init.dart delete mode 100644 pkgs/jnigen/examples/notification_plugin/lib/init.dart delete mode 100644 pkgs/jnigen/examples/pdfbox_plugin/lib/third_party/init.dart create mode 100644 pkgs/jnigen/test/jackson_core_test/third_party/lib/_init.dart delete mode 100644 pkgs/jnigen/test/jackson_core_test/third_party/lib/init.dart create mode 100644 pkgs/jnigen/test/simple_package_test/lib/_init.dart delete mode 100644 pkgs/jnigen/test/simple_package_test/lib/init.dart diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 80dba5c1a..dacfe9400 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -36,9 +36,11 @@ jobs: sdk: [stable] steps: - uses: actions/checkout@v2 - - uses: dart-lang/setup-dart@v1.0 + - uses: subosito/flutter-action@v2 with: - sdk: ${{ matrix.sdk }} + channel: ${{ matrix.sdk }} + cache: true + cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - id: install name: Install dependencies run: dart pub get @@ -60,12 +62,14 @@ jobs: matrix: # Add macos-latest and/or windows-latest if relevant for this package. os: [ubuntu-latest] - sdk: [2.17.0, dev] + sdk: [stable, beta] steps: - uses: actions/checkout@v2 - - uses: dart-lang/setup-dart@v1.0 + - uses: subosito/flutter-action@v2 with: - sdk: stable + channel: ${{ matrix.sdk }} + cache: true + cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - uses: actions/setup-java@v2 with: distribution: 'zulu' @@ -87,9 +91,8 @@ jobs: parallel: true path-to-lcov: ./pkgs/jnigen/coverage/lcov.info - ## TODO: More minimal test on windows after fixing dev dependency. + ## TODO(#15): More minimal test on windows after fixing dev dependency. ## i.e do not rerun analyze and format steps, and do not require flutter. - ## IssueRef: https://github.com/dart-lang/jnigen/issues/15 test_summarizer: runs-on: ubuntu-latest @@ -125,7 +128,7 @@ jobs: java-version: '11' - run: | sudo apt-get update -y - sudo apt-get install -y ninja-build libgtk-3-dev + sudo apt-get install -y ninja-build libgtk-3-dev libclang-dev - run: dart pub get - run: dart run bin/setup.dart - run: flutter pub get @@ -148,6 +151,11 @@ jobs: flag-name: jni_tests parallel: true path-to-lcov: ./pkgs/jni/coverage/lcov.info + - name: regenerate & compare ffigen bindings + run: | + cp lib/src/third_party/jni_bindings_generated.dart __old_bindings + dart run ffigen --config ffigen.yaml + diff lib/src/third_party/jni_bindings_generated.dart __old_bindings build_jni_example_linux: runs-on: ubuntu-latest @@ -216,7 +224,7 @@ jobs: runs-on: ubuntu-latest defaults: run: - working-directory: ./pkgs/jnigen/examples/notification_plugin + working-directory: ./pkgs/jnigen/example/notification_plugin steps: - uses: actions/checkout@v3 - uses: actions/setup-java@v2 @@ -231,7 +239,7 @@ jobs: - run: flutter pub get - run: flutter analyze - run: flutter build apk - working-directory: ./pkgs/jnigen/examples/notification_plugin/example + working-directory: ./pkgs/jnigen/example/notification_plugin/example - name: re-generate bindings run: flutter pub run jnigen -Ddart_root=_dart -Dc_root=_c --config jnigen.yaml - name: compare generated dart bindings @@ -243,7 +251,7 @@ jobs: runs-on: ubuntu-latest defaults: run: - working-directory: ./pkgs/jnigen/examples/in_app_java + working-directory: ./pkgs/jnigen/example/in_app_java steps: - uses: actions/checkout@v3 - uses: actions/setup-java@v2 @@ -279,7 +287,7 @@ jobs: runs-on: ubuntu-latest defaults: run: - working-directory: ./pkgs/jnigen/examples/pdfbox_plugin + working-directory: ./pkgs/jnigen/example/pdfbox_plugin steps: - uses: actions/checkout@v3 - uses: subosito/flutter-action@v2 @@ -315,10 +323,10 @@ jobs: dart run jni:setup && dart run jni:setup -p pdfbox_plugin wget 'https://dart.dev/guides/language/specifications/DartLangSpec-v2.2.pdf' dart run bin/pdf_info.dart DartLangSpec-v2.2.pdf - working-directory: ./pkgs/jnigen/examples/pdfbox_plugin/dart_example + working-directory: ./pkgs/jnigen/example/pdfbox_plugin/dart_example - name: Build flutter example for pdfbox_plugin run: | flutter pub get flutter build linux - working-directory: ./pkgs/jnigen/examples/pdfbox_plugin/example + working-directory: ./pkgs/jnigen/example/pdfbox_plugin/example diff --git a/pkgs/jni/CHANGELOG.md b/pkgs/jni/CHANGELOG.md index 41cc7d819..e61dbc44c 100644 --- a/pkgs/jni/CHANGELOG.md +++ b/pkgs/jni/CHANGELOG.md @@ -1,3 +1,2 @@ -## 0.0.1 - -* TODO: Describe initial release. +## 0.1.0 +* Initial version: Android and Linux support, JniObject API diff --git a/pkgs/jni/README.md b/pkgs/jni/README.md index 12d41fbf3..4cd79278d 100644 --- a/pkgs/jni/README.md +++ b/pkgs/jni/README.md @@ -4,22 +4,17 @@ This is a utility library to access JNI from Dart / Flutter code, intended as a This library contains: -* functions to access the JNIEnv and JavaVM variables from JNI, and wrapper functions to those provided by JNI. (`Jni.getEnv`, `Jni.getJavaVM`). +* functions to access the JNIEnv and JavaVM variables from JNI, and wrapper functions to those provided by JNI. JNIEnv is exposed via `GlobalJniEnv` type which provides a thin abstraction over JNIEnv, so that it can be used from multiple threads. * Functions to spawn a JVM on desktop platforms (`Jni.spawn`). -* Some utility functions to make it easier to work with JNI in Dart; eg: To convert a java string object to Dart string (mostly as extension methods on `Pointer`). - * Some Android-specific helpers (get application context and current activity references). -* Some helper classes and functions to simplify one-off uses (`JniObject` and `JniClass` intended for calling functions by specifying the name and arguments. It will reduce some boilerplate when you're debugging. Note: this API is slightly incomplete). +* `JniObject` class, which provides base class for classes generated by jnigen. This is intended for one-off / debugging uses of JNI, as well as providing a base library for code generated by jnigen. -__To interface a complete java library, look forward for `jnigen`.__ - -## Platform support -The focus of this project is Flutter Android, since Flutter Android apps already have a JVM, and JNI enables interop with existing Java code and Android Platform APIs. This project also (partially) supports Linux desktop by spawning a JVM through JNI. +__To generate type-safe bindings from Java libraries, use `jnigen`.__ ## Version note This library is at an early stage of development and we do not provide backwards compatibility of the API at this point. diff --git a/pkgs/jni/analysis_options.yaml b/pkgs/jni/analysis_options.yaml index 89f8ee95f..e591be846 100644 --- a/pkgs/jni/analysis_options.yaml +++ b/pkgs/jni/analysis_options.yaml @@ -1,7 +1,7 @@ include: package:flutter_lints/flutter.yaml analyzer: - exclude: [build/**] + exclude: [build/**, third_party/**] language: strict-raw-types: true diff --git a/pkgs/jni/android/build.gradle b/pkgs/jni/android/build.gradle index b91cb7bb9..13b25f638 100644 --- a/pkgs/jni/android/build.gradle +++ b/pkgs/jni/android/build.gradle @@ -1,6 +1,6 @@ // The Android Gradle Plugin builds the native code with the Android NDK. -group 'dev.dart.jni' +group 'com.github.dart_lang.jni' version '1.0' buildscript { diff --git a/pkgs/jni/android/src/main/AndroidManifest.xml b/pkgs/jni/android/src/main/AndroidManifest.xml index 8055f584a..9a6646fae 100644 --- a/pkgs/jni/android/src/main/AndroidManifest.xml +++ b/pkgs/jni/android/src/main/AndroidManifest.xml @@ -1,3 +1,3 @@ + package="com.github.dart_lang.jni"> diff --git a/pkgs/jni/android/src/main/java/dev/dart/jni/JniPlugin.java b/pkgs/jni/android/src/main/java/com/github/dart_lang/jni/JniPlugin.java similarity index 98% rename from pkgs/jni/android/src/main/java/dev/dart/jni/JniPlugin.java rename to pkgs/jni/android/src/main/java/com/github/dart_lang/jni/JniPlugin.java index ffda30a03..2a22dd8ed 100644 --- a/pkgs/jni/android/src/main/java/dev/dart/jni/JniPlugin.java +++ b/pkgs/jni/android/src/main/java/com/github/dart_lang/jni/JniPlugin.java @@ -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. -package dev.dart.jni; +package com.github.dart_lang.jni; import android.app.Activity; import android.content.Context; diff --git a/pkgs/jni/bin/setup.dart b/pkgs/jni/bin/setup.dart index 1e7344a35..38ed35c4b 100644 --- a/pkgs/jni/bin/setup.dart +++ b/pkgs/jni/bin/setup.dart @@ -35,9 +35,6 @@ class CommandRunner { CommandRunner({this.printCmds = false}); bool printCmds = false; int? time; - // TODO: time commands - // TODO: Run all commands in single shell instance - // IssueRef: https://github.com/dart-lang/jnigen/issues/14 Future run( String exec, List args, String workingDir) async { if (printCmds) { @@ -168,8 +165,17 @@ Future build(Options options, String srcPath, String buildPath) async { cmakeArgs.add(srcPath); await runner.run("cmake", cmakeArgs, buildPath); await runner.run("cmake", ["--build", "."], buildPath); + final buildPathUri = Uri.directory(buildPath); if (Platform.isWindows) { - await runner.run("move", ["Debug\\dartjni.dll", "."], buildPath); + final debugDir = buildPathUri.resolve('Debug'); + for (var entry in Directory.fromUri(debugDir).listSync()) { + if (entry.path.endsWith('.dll')) { + final fileName = entry.uri.pathSegments.last; + final target = entry.parent.parent.uri.resolve(fileName); + log('rename ${entry.path} -> ${target.toFilePath()}'); + entry.rename(target.toFilePath()); + } + } } // delete cmakeTemporaryArtifacts deleteCMakeTemps(Uri.directory(buildPath)); diff --git a/pkgs/jni/example/README.md b/pkgs/jni/example/README.md index 80af081ac..583f96056 100644 --- a/pkgs/jni/example/README.md +++ b/pkgs/jni/example/README.md @@ -1,16 +1,3 @@ # jni_example - Demonstrates how to use the jni plugin. -## Getting Started - -This project is a starting point for a Flutter application. - -A few resources to get you started if this is your first Flutter project: - -- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) -- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) - -For help getting started with Flutter development, view the -[online documentation](https://docs.flutter.dev/), which offers tutorials, -samples, guidance on mobile development, and a full API reference. diff --git a/pkgs/jni/example/android/app/build.gradle b/pkgs/jni/example/android/app/build.gradle index ec132990b..3c6742ce1 100644 --- a/pkgs/jni/example/android/app/build.gradle +++ b/pkgs/jni/example/android/app/build.gradle @@ -43,7 +43,7 @@ android { } defaultConfig { - applicationId "dev.dart.jni_example" + applicationId "com.github.dart_lang.jni_example" // You can update the following values to match your application needs. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. minSdkVersion flutter.minSdkVersion diff --git a/pkgs/jni/example/android/app/src/debug/AndroidManifest.xml b/pkgs/jni/example/android/app/src/debug/AndroidManifest.xml index 2b66dc274..1a2af73c5 100644 --- a/pkgs/jni/example/android/app/src/debug/AndroidManifest.xml +++ b/pkgs/jni/example/android/app/src/debug/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.github.dart_lang.jni_example"> + + diff --git a/pkgs/jnigen/example/kotlin_plugin/example/android/app/src/main/AndroidManifest.xml b/pkgs/jnigen/example/kotlin_plugin/example/android/app/src/main/AndroidManifest.xml new file mode 100644 index 000000000..9059f10e2 --- /dev/null +++ b/pkgs/jnigen/example/kotlin_plugin/example/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/pkgs/jnigen/example/kotlin_plugin/example/android/app/src/main/kotlin/com/example/kotlin_plugin/example/MainActivity.kt b/pkgs/jnigen/example/kotlin_plugin/example/android/app/src/main/kotlin/com/example/kotlin_plugin/example/MainActivity.kt new file mode 100644 index 000000000..4826f822e --- /dev/null +++ b/pkgs/jnigen/example/kotlin_plugin/example/android/app/src/main/kotlin/com/example/kotlin_plugin/example/MainActivity.kt @@ -0,0 +1,6 @@ +package com.example.kotlin_plugin.example + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() { +} diff --git a/pkgs/jnigen/example/kotlin_plugin/example/android/app/src/main/res/drawable-v21/launch_background.xml b/pkgs/jnigen/example/kotlin_plugin/example/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 000000000..f74085f3f --- /dev/null +++ b/pkgs/jnigen/example/kotlin_plugin/example/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/pkgs/jnigen/example/kotlin_plugin/example/android/app/src/main/res/drawable/launch_background.xml b/pkgs/jnigen/example/kotlin_plugin/example/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 000000000..304732f88 --- /dev/null +++ b/pkgs/jnigen/example/kotlin_plugin/example/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/pkgs/jnigen/example/kotlin_plugin/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/pkgs/jnigen/example/kotlin_plugin/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..db77bb4b7b0906d62b1847e87f15cdcacf6a4f29 GIT binary patch literal 544 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY3?!3`olAj~WQl7;NpOBzNqJ&XDuZK6ep0G} zXKrG8YEWuoN@d~6R2!h8bpbvhu0Wd6uZuB!w&u2PAxD2eNXD>P5D~Wn-+_Wa#27Xc zC?Zj|6r#X(-D3u$NCt}(Ms06KgJ4FxJVv{GM)!I~&n8Bnc94O7-Hd)cjDZswgC;Qs zO=b+9!WcT8F?0rF7!Uys2bs@gozCP?z~o%U|N3vA*22NaGQG zlg@K`O_XuxvZ&Ks^m&R!`&1=spLvfx7oGDKDwpwW`#iqdw@AL`7MR}m`rwr|mZgU`8P7SBkL78fFf!WnuYWm$5Z0 zNXhDbCv&49sM544K|?c)WrFfiZvCi9h0O)B3Pgg&ebxsLQ05GG~ AQ2+n{ literal 0 HcmV?d00001 diff --git a/pkgs/jnigen/example/kotlin_plugin/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/pkgs/jnigen/example/kotlin_plugin/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..17987b79bb8a35cc66c3c1fd44f5a5526c1b78be GIT binary patch literal 442 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA3?vioaBc-sk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5Xx&nMcT!A!W`0S9QKQy;}1Cl^CgaH=;G9cpY;r$Q>i*pfB zP2drbID<_#qf;rPZx^FqH)F_D#*k@@q03KywUtLX8Ua?`H+NMzkczFPK3lFz@i_kW%1NOn0|D2I9n9wzH8m|-tHjsw|9>@K=iMBhxvkv6m8Y-l zytQ?X=U+MF$@3 zt`~i=@j|6y)RWMK--}M|=T`o&^Ni>IoWKHEbBXz7?A@mgWoL>!*SXo`SZH-*HSdS+ yn*9;$7;m`l>wYBC5bq;=U}IMqLzqbYCidGC!)_gkIk_C@Uy!y&wkt5C($~2D>~)O*cj@FGjOCM)M>_ixfudOh)?xMu#Fs z#}Y=@YDTwOM)x{K_j*Q;dPdJ?Mz0n|pLRx{4n|)f>SXlmV)XB04CrSJn#dS5nK2lM zrZ9#~WelCp7&e13Y$jvaEXHskn$2V!!DN-nWS__6T*l;H&Fopn?A6HZ-6WRLFP=R` zqG+CE#d4|IbyAI+rJJ`&x9*T`+a=p|0O(+s{UBcyZdkhj=yS1>AirP+0R;mf2uMgM zC}@~JfByORAh4SyRgi&!(cja>F(l*O+nd+@4m$|6K6KDn_&uvCpV23&>G9HJp{xgg zoq1^2_p9@|WEo z*X_Uko@K)qYYv~>43eQGMdbiGbo>E~Q& zrYBH{QP^@Sti!`2)uG{irBBq@y*$B zi#&(U-*=fp74j)RyIw49+0MRPMRU)+a2r*PJ$L5roHt2$UjExCTZSbq%V!HeS7J$N zdG@vOZB4v_lF7Plrx+hxo7(fCV&}fHq)$ literal 0 HcmV?d00001 diff --git a/pkgs/jnigen/example/kotlin_plugin/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/pkgs/jnigen/example/kotlin_plugin/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..d5f1c8d34e7a88e3f88bea192c3a370d44689c3c GIT binary patch literal 1031 zcmeAS@N?(olHy`uVBq!ia0vp^6F``Q8Ax83A=Cw=BuiW)N`mv#O3D+9QW+dm@{>{( zJaZG%Q-e|yQz{EjrrIztFa`(sgt!6~Yi|1%a`XoT0ojZ}lNrNjb9xjc(B0U1_% zz5^97Xt*%oq$rQy4?0GKNfJ44uvxI)gC`h-NZ|&0-7(qS@?b!5r36oQ}zyZrNO3 zMO=Or+<~>+A&uN&E!^Sl+>xE!QC-|oJv`ApDhqC^EWD|@=#J`=d#Xzxs4ah}w&Jnc z$|q_opQ^2TrnVZ0o~wh<3t%W&flvYGe#$xqda2bR_R zvPYgMcHgjZ5nSA^lJr%;<&0do;O^tDDh~=pIxA#coaCY>&N%M2^tq^U%3DB@ynvKo}b?yu-bFc-u0JHzced$sg7S3zqI(2 z#Km{dPr7I=pQ5>FuK#)QwK?Y`E`B?nP+}U)I#c1+FM*1kNvWG|a(TpksZQ3B@sD~b zpQ2)*V*TdwjFOtHvV|;OsiDqHi=6%)o4b!)x$)%9pGTsE z-JL={-Ffv+T87W(Xpooq<`r*VzWQcgBN$$`u}f>-ZQI1BB8ykN*=e4rIsJx9>z}*o zo~|9I;xof literal 0 HcmV?d00001 diff --git a/pkgs/jnigen/example/kotlin_plugin/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/pkgs/jnigen/example/kotlin_plugin/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..4d6372eebdb28e45604e46eeda8dd24651419bc0 GIT binary patch literal 1443 zcmb`G{WsKk6vsdJTdFg%tJav9_E4vzrOaqkWF|A724Nly!y+?N9`YV6wZ}5(X(D_N(?!*n3`|_r0Hc?=PQw&*vnU?QTFY zB_MsH|!j$PP;I}?dppoE_gA(4uc!jV&0!l7_;&p2^pxNo>PEcNJv za5_RT$o2Mf!<+r?&EbHH6nMoTsDOa;mN(wv8RNsHpG)`^ymG-S5By8=l9iVXzN_eG%Xg2@Xeq76tTZ*dGh~Lo9vl;Zfs+W#BydUw zCkZ$o1LqWQO$FC9aKlLl*7x9^0q%0}$OMlp@Kk_jHXOjofdePND+j!A{q!8~Jn+s3 z?~~w@4?egS02}8NuulUA=L~QQfm;MzCGd)XhiftT;+zFO&JVyp2mBww?;QByS_1w! zrQlx%{^cMj0|Bo1FjwY@Q8?Hx0cIPF*@-ZRFpPc#bBw{5@tD(5%sClzIfl8WU~V#u zm5Q;_F!wa$BSpqhN>W@2De?TKWR*!ujY;Yylk_X5#~V!L*Gw~;$%4Q8~Mad z@`-kG?yb$a9cHIApZDVZ^U6Xkp<*4rU82O7%}0jjHlK{id@?-wpN*fCHXyXh(bLt* zPc}H-x0e4E&nQ>y%B-(EL=9}RyC%MyX=upHuFhAk&MLbsF0LP-q`XnH78@fT+pKPW zu72MW`|?8ht^tz$iC}ZwLp4tB;Q49K!QCF3@!iB1qOI=?w z7In!}F~ij(18UYUjnbmC!qKhPo%24?8U1x{7o(+?^Zu0Hx81|FuS?bJ0jgBhEMzf< zCgUq7r2OCB(`XkKcN-TL>u5y#dD6D!)5W?`O5)V^>jb)P)GBdy%t$uUMpf$SNV31$ zb||OojAbvMP?T@$h_ZiFLFVHDmbyMhJF|-_)HX3%m=CDI+ID$0^C>kzxprBW)hw(v zr!Gmda);ICoQyhV_oP5+C%?jcG8v+D@9f?Dk*!BxY}dazmrT@64UrP3hlslANK)bq z$67n83eh}OeW&SV@HG95P|bjfqJ7gw$e+`Hxo!4cx`jdK1bJ>YDSpGKLPZ^1cv$ek zIB?0S<#tX?SJCLWdMd{-ME?$hc7A$zBOdIJ)4!KcAwb=VMov)nK;9z>x~rfT1>dS+ zZ6#`2v@`jgbqq)P22H)Tx2CpmM^o1$B+xT6`(v%5xJ(?j#>Q$+rx_R|7TzDZe{J6q zG1*EcU%tE?!kO%^M;3aM6JN*LAKUVb^xz8-Pxo#jR5(-KBeLJvA@-gxNHx0M-ZJLl z;#JwQoh~9V?`UVo#}{6ka@II>++D@%KqGpMdlQ}?9E*wFcf5(#XQnP$Dk5~%iX^>f z%$y;?M0BLp{O3a(-4A?ewryHrrD%cx#Q^%KY1H zNre$ve+vceSLZcNY4U(RBX&)oZn*Py()h)XkE?PL$!bNb{N5FVI2Y%LKEm%yvpyTP z(1P?z~7YxD~Rf<(a@_y` literal 0 HcmV?d00001 diff --git a/pkgs/jnigen/example/kotlin_plugin/example/android/app/src/main/res/values-night/styles.xml b/pkgs/jnigen/example/kotlin_plugin/example/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 000000000..06952be74 --- /dev/null +++ b/pkgs/jnigen/example/kotlin_plugin/example/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/pkgs/jnigen/example/kotlin_plugin/example/android/app/src/main/res/values/styles.xml b/pkgs/jnigen/example/kotlin_plugin/example/android/app/src/main/res/values/styles.xml new file mode 100644 index 000000000..cb1ef8805 --- /dev/null +++ b/pkgs/jnigen/example/kotlin_plugin/example/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/pkgs/jnigen/example/kotlin_plugin/example/android/app/src/profile/AndroidManifest.xml b/pkgs/jnigen/example/kotlin_plugin/example/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 000000000..2c06d9bc1 --- /dev/null +++ b/pkgs/jnigen/example/kotlin_plugin/example/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,8 @@ + + + + diff --git a/pkgs/jnigen/example/kotlin_plugin/example/android/build.gradle b/pkgs/jnigen/example/kotlin_plugin/example/android/build.gradle new file mode 100644 index 000000000..58a8c74b1 --- /dev/null +++ b/pkgs/jnigen/example/kotlin_plugin/example/android/build.gradle @@ -0,0 +1,31 @@ +buildscript { + ext.kotlin_version = '1.7.10' + repositories { + google() + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:7.2.0' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = '../build' +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(':app') +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/pkgs/jnigen/example/kotlin_plugin/example/android/gradle.properties b/pkgs/jnigen/example/kotlin_plugin/example/android/gradle.properties new file mode 100644 index 000000000..94adc3a3f --- /dev/null +++ b/pkgs/jnigen/example/kotlin_plugin/example/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx1536M +android.useAndroidX=true +android.enableJetifier=true diff --git a/pkgs/jnigen/example/kotlin_plugin/example/android/gradle/wrapper/gradle-wrapper.properties b/pkgs/jnigen/example/kotlin_plugin/example/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..3c472b99c --- /dev/null +++ b/pkgs/jnigen/example/kotlin_plugin/example/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip diff --git a/pkgs/jnigen/example/kotlin_plugin/example/android/settings.gradle b/pkgs/jnigen/example/kotlin_plugin/example/android/settings.gradle new file mode 100644 index 000000000..44e62bcf0 --- /dev/null +++ b/pkgs/jnigen/example/kotlin_plugin/example/android/settings.gradle @@ -0,0 +1,11 @@ +include ':app' + +def localPropertiesFile = new File(rootProject.projectDir, "local.properties") +def properties = new Properties() + +assert localPropertiesFile.exists() +localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + +def flutterSdkPath = properties.getProperty("flutter.sdk") +assert flutterSdkPath != null, "flutter.sdk not set in local.properties" +apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" diff --git a/pkgs/jnigen/example/kotlin_plugin/example/lib/main.dart b/pkgs/jnigen/example/kotlin_plugin/example/lib/main.dart new file mode 100644 index 000000000..df87f6e7a --- /dev/null +++ b/pkgs/jnigen/example/kotlin_plugin/example/lib/main.dart @@ -0,0 +1,98 @@ +import 'package:flutter/material.dart'; +import 'package:kotlin_plugin/kotlin_plugin.dart'; +import 'package:jni/jni.dart'; + +void main() { + Jni.initDLApi(); + runApp(const MyApp()); +} + +class MyApp extends StatelessWidget { + const MyApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + title: 'Kotlin Plugin Example', + theme: ThemeData( + primarySwatch: Colors.blue, + ), + home: const MyHomePage(title: 'Kotlin Plugin Example Home Page'), + ); + } +} + +class MyHomePage extends StatefulWidget { + const MyHomePage({super.key, required this.title}); + + final String title; + + @override + State createState() => _MyHomePageState(); +} + +class _MyHomePageState extends State { + Future? answer; + + late Example example; + + @override + void initState() { + super.initState(); + example = Example(); + } + + @override + void dispose() { + example.delete(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text(widget.title), + ), + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text( + 'What is the answer to life, the universe, and everything?', + ), + ElevatedButton( + onPressed: () { + setState(() { + answer = example.thinkBeforeAnswering().then( + (value) => value.toDartString(deleteOriginal: true)); + }); + }, + child: const Text('Think...'), + ), + FutureBuilder( + future: answer, + builder: (context, snapshot) { + switch (snapshot.connectionState) { + case ConnectionState.none: + return const SizedBox(); + case ConnectionState.waiting: + case ConnectionState.active: + return Text( + 'Thinking...', + style: Theme.of(context).textTheme.headlineMedium, + ); + case ConnectionState.done: + return Text( + snapshot.data ?? "I don't know!", + style: Theme.of(context).textTheme.headlineMedium, + ); + } + }, + ), + ], + ), + ), + ); + } +} diff --git a/pkgs/jnigen/example/kotlin_plugin/example/pubspec.yaml b/pkgs/jnigen/example/kotlin_plugin/example/pubspec.yaml new file mode 100644 index 000000000..4292ba976 --- /dev/null +++ b/pkgs/jnigen/example/kotlin_plugin/example/pubspec.yaml @@ -0,0 +1,29 @@ +name: example +description: A new Flutter project. + +publish_to: "none" + +version: 1.0.0+1 + +environment: + sdk: ">=2.19.0-444.3.beta <3.0.0" + +dependencies: + flutter: + sdk: flutter + + kotlin_plugin: + path: ../ + + jni: + path: ../../../../jni + +dev_dependencies: + flutter_test: + sdk: flutter + + flutter_lints: ^2.0.0 + +flutter: + uses-material-design: true + diff --git a/pkgs/jnigen/example/kotlin_plugin/jnigen.yaml b/pkgs/jnigen/example/kotlin_plugin/jnigen.yaml new file mode 100644 index 000000000..60978f56f --- /dev/null +++ b/pkgs/jnigen/example/kotlin_plugin/jnigen.yaml @@ -0,0 +1,21 @@ +android_sdk_config: + add_gradle_deps: true + android_example: 'example/' + +summarizer: + backend: asm + +suspend_fun_to_async: true + +output: + c: + library_name: kotlin_plugin_bindings + path: src/ + dart: + path: lib/kotlin_bindings.dart + structure: single_file + +log_level: all + +classes: + - 'Example' diff --git a/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart b/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart new file mode 100644 index 000000000..e5c8331a6 --- /dev/null +++ b/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart @@ -0,0 +1,87 @@ +// Autogenerated by jnigen. DO NOT EDIT! + +// ignore_for_file: annotate_overrides +// ignore_for_file: camel_case_extensions +// ignore_for_file: camel_case_types +// ignore_for_file: constant_identifier_names +// ignore_for_file: file_names +// ignore_for_file: no_leading_underscores_for_local_identifiers +// ignore_for_file: non_constant_identifier_names +// ignore_for_file: overridden_fields +// ignore_for_file: unnecessary_cast +// ignore_for_file: unused_element +// ignore_for_file: unused_import + +import "dart:isolate" show ReceivePort; +import "dart:ffi" as ffi; +import "package:jni/internal_helpers_for_jnigen.dart"; +import "package:jni/jni.dart" as jni; + +// Auto-generated initialization code. + +final ffi.Pointer Function(String sym) jniLookup = + ProtectedJniExtensions.initGeneratedLibrary("kotlin_plugin_bindings"); + +/// from: Example +class Example extends jni.JObject { + late final jni.JObjType? _$type; + @override + jni.JObjType get $type => _$type ??= type; + + Example.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = $ExampleType(); + + static final _ctor = + jniLookup>("Example__ctor") + .asFunction(); + + /// from: public void () + Example() : super.fromRef(_ctor().object); + + static final _thinkBeforeAnswering = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("Example__thinkBeforeAnswering") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public final java.lang.Object thinkBeforeAnswering(kotlin.coroutines.Continuation continuation) + /// The returned object must be deleted after use, by calling the `delete` method. + Future thinkBeforeAnswering() async { + final $p = ReceivePort(); + final $c = jni.Jni.newPortContinuation($p); + _thinkBeforeAnswering(reference, $c).object; + final $o = jni.JObjectPtr.fromAddress(await $p.first); + final $k = const jni.JStringType().getClass().reference; + if (jni.Jni.env.IsInstanceOf($o, $k) == 0) { + throw "Failed"; + } + return const jni.JStringType().fromRef($o); + } +} + +class $ExampleType extends jni.JObjType { + const $ExampleType(); + + @override + String get signature => r"LExample;"; + + @override + Example fromRef(jni.JObjectPtr ref) => Example.fromRef(ref); +} + +extension $ExampleArray on jni.JArray { + Example operator [](int index) { + return (elementType as $ExampleType) + .fromRef(elementAt(index, jni.JniCallType.objectType).object); + } + + void operator []=(int index, Example value) { + (this as jni.JArray)[index] = value; + } +} diff --git a/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_plugin.dart b/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_plugin.dart new file mode 100644 index 000000000..5919c221b --- /dev/null +++ b/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_plugin.dart @@ -0,0 +1,3 @@ +library kotlin_plugin; + +export 'kotlin_bindings.dart'; diff --git a/pkgs/jnigen/example/kotlin_plugin/pubspec.yaml b/pkgs/jnigen/example/kotlin_plugin/pubspec.yaml new file mode 100644 index 000000000..f6b5916c9 --- /dev/null +++ b/pkgs/jnigen/example/kotlin_plugin/pubspec.yaml @@ -0,0 +1,31 @@ +# 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. + +name: kotlin_plugin +description: Example of using jnigen to generate bindings for Kotlin. +version: 0.0.1 +publish_to: none + +environment: + sdk: '>=2.19.0-444.3.beta <3.0.0' + flutter: ">=1.17.0" + +dependencies: + flutter: + sdk: flutter + jni: + path: ../../../jni + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^2.0.0 + jnigen: + path: ../../ + +flutter: + plugin: + platforms: + android: + ffiPlugin: true diff --git a/pkgs/jnigen/example/kotlin_plugin/src/.clang-format b/pkgs/jnigen/example/kotlin_plugin/src/.clang-format new file mode 100644 index 000000000..a256c2f09 --- /dev/null +++ b/pkgs/jnigen/example/kotlin_plugin/src/.clang-format @@ -0,0 +1,15 @@ +# From dart SDK: https://github.com/dart-lang/sdk/blob/main/.clang-format + +# Defines the Chromium style for automatic reformatting. +# http://clang.llvm.org/docs/ClangFormatStyleOptions.html +BasedOnStyle: Chromium + +# clang-format doesn't seem to do a good job of this for longer comments. +ReflowComments: 'false' + +# We have lots of these. Though we need to put them all in curly braces, +# clang-format can't do that. +AllowShortIfStatementsOnASingleLine: 'true' + +# Put escaped newlines into the rightmost column. +AlignEscapedNewlinesLeft: false diff --git a/pkgs/jnigen/example/kotlin_plugin/src/CMakeLists.txt b/pkgs/jnigen/example/kotlin_plugin/src/CMakeLists.txt new file mode 100644 index 000000000..78d9dca2c --- /dev/null +++ b/pkgs/jnigen/example/kotlin_plugin/src/CMakeLists.txt @@ -0,0 +1,32 @@ +# jni_native_build (Build with jni:setup. Do not delete this line.) + +# The Flutter tooling requires that developers have CMake 3.10 or later +# installed. You should not increase this version, as doing so will cause +# the plugin to fail to compile for some customers of the plugin. +cmake_minimum_required(VERSION 3.10) + +project(kotlin_plugin_bindings VERSION 0.0.1 LANGUAGES C) + +add_library(kotlin_plugin_bindings SHARED + "./kotlin_plugin_bindings.c" +) + +set_target_properties(kotlin_plugin_bindings PROPERTIES + OUTPUT_NAME "kotlin_plugin_bindings" +) + +target_compile_definitions(kotlin_plugin_bindings PUBLIC DART_SHARED_LIB) + +if(WIN32) + set_target_properties(${TARGET_NAME} PROPERTIES + LINK_FLAGS "/DELAYLOAD:jvm.dll") +endif() + +if (ANDROID) + target_link_libraries(kotlin_plugin_bindings log) +else() + find_package(Java REQUIRED) + find_package(JNI REQUIRED) + include_directories(${JNI_INCLUDE_DIRS}) + target_link_libraries(kotlin_plugin_bindings ${JNI_LIBRARIES}) +endif() diff --git a/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h b/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h new file mode 100644 index 000000000..39b70bd8f --- /dev/null +++ b/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h @@ -0,0 +1,272 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +#pragma once + +// Note: include appropriate system jni.h as found by CMake, not third_party/jni.h. +#include +#include +#include +#include + +#if _WIN32 +#include +#else +#include +#include +#endif + +#if _WIN32 +#define FFI_PLUGIN_EXPORT __declspec(dllexport) +#else +#define FFI_PLUGIN_EXPORT +#endif + +#if defined _WIN32 +#define thread_local __declspec(thread) +#else +#define thread_local __thread +#endif + +#ifdef __ANDROID__ +#include +#endif + +#ifdef __ANDROID__ +#define __ENVP_CAST (JNIEnv**) +#else +#define __ENVP_CAST (void**) +#endif + +/// Stores the global state of the JNI. +typedef struct JniContext { + JavaVM* jvm; + jobject classLoader; + jmethodID loadClassMethod; + jobject currentActivity; + jobject appContext; +} JniContext; + +// jniEnv for this thread, used by inline functions in this header, +// therefore declared as extern. +extern thread_local JNIEnv* jniEnv; + +extern JniContext jni; + +/// Types used by JNI API to distinguish between primitive types. +enum JniType { + booleanType = 0, + byteType = 1, + shortType = 2, + charType = 3, + intType = 4, + longType = 5, + floatType = 6, + doubleType = 7, + objectType = 8, + voidType = 9, +}; + +/// 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]. +typedef struct JniResult { + jvalue result; + jthrowable exception; +} JniResult; + +/// Similar to [JniResult] but for class lookups. +typedef struct JniClassLookupResult { + jclass classRef; + jthrowable exception; +} JniClassLookupResult; + +/// Similar to [JniResult] but for method/field ID lookups. +typedef struct JniPointerResult { + void* id; + jthrowable exception; +} JniPointerResult; + +/// JniExceptionDetails holds 2 jstring objects, one is the result of +/// calling `toString` on exception object, other is stack trace; +typedef struct JniExceptionDetails { + jstring message; + jstring stacktrace; +} JniExceptionDetails; + +/// This struct contains functions which wrap method call / field access conveniently along with +/// exception checking. +/// +/// Flutter embedding checks for pending JNI exceptions before an FFI transition, which requires us +/// to check for and clear the exception before returning to dart code, which requires these functions +/// to return result types. +typedef struct JniAccessors { + JniClassLookupResult (*getClass)(char* internalName); + JniPointerResult (*getFieldID)(jclass cls, char* fieldName, char* signature); + JniPointerResult (*getStaticFieldID)(jclass cls, + char* fieldName, + char* signature); + JniPointerResult (*getMethodID)(jclass cls, + char* methodName, + char* signature); + JniPointerResult (*getStaticMethodID)(jclass cls, + char* methodName, + char* signature); + JniResult (*newObject)(jclass cls, jmethodID ctor, jvalue* args); + JniPointerResult (*newPrimitiveArray)(jsize length, int type); + JniPointerResult (*newObjectArray)(jsize length, + jclass elementClass, + jobject initialElement); + JniResult (*getArrayElement)(jarray array, int index, int type); + JniResult (*callMethod)(jobject obj, + jmethodID methodID, + int callType, + jvalue* args); + JniResult (*callStaticMethod)(jclass cls, + jmethodID methodID, + int callType, + jvalue* args); + JniResult (*getField)(jobject obj, jfieldID fieldID, int callType); + JniResult (*getStaticField)(jclass cls, jfieldID fieldID, int callType); + JniExceptionDetails (*getExceptionDetails)(jthrowable exception); +} JniAccessors; + +FFI_PLUGIN_EXPORT JniAccessors* GetAccessors(); + +FFI_PLUGIN_EXPORT JavaVM* GetJavaVM(void); + +FFI_PLUGIN_EXPORT JNIEnv* GetJniEnv(void); + +FFI_PLUGIN_EXPORT JNIEnv* SpawnJvm(JavaVMInitArgs* args); + +FFI_PLUGIN_EXPORT jclass LoadClass(const char* name); + +FFI_PLUGIN_EXPORT jobject GetClassLoader(void); + +FFI_PLUGIN_EXPORT jobject GetApplicationContext(void); + +FFI_PLUGIN_EXPORT jobject GetCurrentActivity(void); + +// Migration note: Below inline functions are required by C bindings, but can be moved to dartjni.c +// once migration to pure dart bindings is complete. + +// `static inline` because `inline` doesn't work, it may still not +// inline the function in which case a linker error may be produced. +// +// There has to be a better way to do this. Either to force inlining on target +// platforms, or just leave it as normal function. + +static inline void __load_class_into(jclass* cls, const char* name) { +#ifdef __ANDROID__ + jstring className = (*jniEnv)->NewStringUTF(jniEnv, name); + *cls = (*jniEnv)->CallObjectMethod(jniEnv, jni.classLoader, + jni.loadClassMethod, className); + (*jniEnv)->DeleteLocalRef(jniEnv, className); +#else + *cls = (*jniEnv)->FindClass(jniEnv, name); +#endif +} + +static inline void load_class(jclass* cls, const char* name) { + if (*cls == NULL) { + __load_class_into(cls, name); + } +} + +static inline void load_class_gr(jclass* cls, const char* name) { + if (*cls == NULL) { + jclass tmp; + __load_class_into(&tmp, name); + *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); + (*jniEnv)->DeleteLocalRef(jniEnv, tmp); + } +} + +static inline void attach_thread() { + if (jniEnv == NULL) { + (*jni.jvm)->AttachCurrentThread(jni.jvm, __ENVP_CAST & jniEnv, NULL); + } +} + +static inline void load_method(jclass cls, + jmethodID* res, + const char* name, + const char* sig) { + if (*res == NULL) { + *res = (*jniEnv)->GetMethodID(jniEnv, cls, name, sig); + } +} + +static inline void load_static_method(jclass cls, + jmethodID* res, + const char* name, + const char* sig) { + if (*res == NULL) { + *res = (*jniEnv)->GetStaticMethodID(jniEnv, cls, name, sig); + } +} + +static inline void load_field(jclass cls, + jfieldID* res, + const char* name, + const char* sig) { + if (*res == NULL) { + *res = (*jniEnv)->GetFieldID(jniEnv, cls, name, sig); + } +} + +static inline void load_static_field(jclass cls, + jfieldID* res, + const char* name, + const char* sig) { + if (*res == NULL) { + *res = (*jniEnv)->GetStaticFieldID(jniEnv, cls, name, sig); + } +} + +static inline jobject to_global_ref(jobject ref) { + jobject g = (*jniEnv)->NewGlobalRef(jniEnv, ref); + (*jniEnv)->DeleteLocalRef(jniEnv, ref); + return g; +} + +// These functions are useful for C+Dart bindings, and not required for pure dart bindings. + +FFI_PLUGIN_EXPORT JniContext GetJniContext(); +/// For use by jni_gen's generated code +/// don't use these. + +// these 2 fn ptr vars will be defined by generated code library +extern JniContext (*context_getter)(void); +extern JNIEnv* (*env_getter)(void); + +// this function will be exported by generated code library +// it will set above 2 variables. +FFI_PLUGIN_EXPORT void setJniGetters(struct JniContext (*cg)(void), + JNIEnv* (*eg)(void)); + +static inline void load_env() { + if (jniEnv == NULL) { + jni = context_getter(); + jniEnv = env_getter(); + } +} + +static inline jthrowable check_exception() { + jthrowable exception = (*jniEnv)->ExceptionOccurred(jniEnv); + if (exception != NULL) (*jniEnv)->ExceptionClear(jniEnv); + if (exception == NULL) return NULL; + return to_global_ref(exception); +} + +FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); + +JNIEXPORT void JNICALL +Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env, + jobject thiz, + jlong port, + jobject result); +FFI_PLUGIN_EXPORT +JniResult PortContinuation__ctor(int64_t j); diff --git a/pkgs/jnigen/example/kotlin_plugin/src/kotlin_plugin_bindings.c b/pkgs/jnigen/example/kotlin_plugin/src/kotlin_plugin_bindings.c new file mode 100644 index 000000000..77075ceb2 --- /dev/null +++ b/pkgs/jnigen/example/kotlin_plugin/src/kotlin_plugin_bindings.c @@ -0,0 +1,52 @@ +// Autogenerated by jnigen. DO NOT EDIT! + +#include +#include "dartjni.h" +#include "jni.h" + +thread_local JNIEnv* jniEnv; +JniContext jni; + +JniContext (*context_getter)(void); +JNIEnv* (*env_getter)(void); + +void setJniGetters(JniContext (*cg)(void), JNIEnv* (*eg)(void)) { + context_getter = cg; + env_getter = eg; +} + +// Example +jclass _c_Example = NULL; + +jmethodID _m_Example__ctor = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__ctor() { + load_env(); + load_class_gr(&_c_Example, "Example"); + if (_c_Example == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example, &_m_Example__ctor, "", "()V"); + if (_m_Example__ctor == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Example, _m_Example__ctor); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID _m_Example__thinkBeforeAnswering = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__thinkBeforeAnswering(jobject self_, jobject continuation) { + load_env(); + load_class_gr(&_c_Example, "Example"); + if (_c_Example == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example, &_m_Example__thinkBeforeAnswering, + "thinkBeforeAnswering", + "(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;"); + if (_m_Example__thinkBeforeAnswering == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_Example__thinkBeforeAnswering, continuation); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} diff --git a/pkgs/jnigen/example/notification_plugin/README.md b/pkgs/jnigen/example/notification_plugin/README.md index 035b29af7..e1b3af5d5 100644 --- a/pkgs/jnigen/example/notification_plugin/README.md +++ b/pkgs/jnigen/example/notification_plugin/README.md @@ -1,12 +1,12 @@ # notification_plugin -Example of android plugin project with jnigen. +Example of Android plugin project with jnigen. This plugin project contains [custom code](android/src/main/java/com/example/notification_plugin) which uses the Android libraries. The bindings are generated using [jnigen config](jnigen.yaml) and then used in [flutter example](example/lib/main.dart), with help of `package:jni` APIs. The command to regenerate JNI bindings is: ``` -flutter run jnigen --config jnigen.yaml # run from notification_plugin project root +flutter pub 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 a8ccd100f..853f2a997 100644 --- a/pkgs/jnigen/example/notification_plugin/lib/notifications.dart +++ b/pkgs/jnigen/example/notification_plugin/lib/notifications.dart @@ -16,6 +16,7 @@ // ignore_for_file: unused_element // ignore_for_file: unused_import +import "dart:isolate" show ReceivePort; import "dart:ffi" as ffi; import "package:jni/internal_helpers_for_jnigen.dart"; import "package:jni/jni.dart" as jni; diff --git a/pkgs/jnigen/example/notification_plugin/src/dartjni.h b/pkgs/jnigen/example/notification_plugin/src/dartjni.h index 12e38b972..39b70bd8f 100644 --- a/pkgs/jnigen/example/notification_plugin/src/dartjni.h +++ b/pkgs/jnigen/example/notification_plugin/src/dartjni.h @@ -260,3 +260,13 @@ static inline jthrowable check_exception() { if (exception == NULL) return NULL; return to_global_ref(exception); } + +FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); + +JNIEXPORT void JNICALL +Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env, + jobject thiz, + jlong port, + jobject result); +FFI_PLUGIN_EXPORT +JniResult PortContinuation__ctor(int64_t j); 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 f32c1190c..3ff6a5366 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 @@ -30,6 +30,7 @@ // ignore_for_file: unused_element // ignore_for_file: unused_import +import "dart:isolate" show ReceivePort; import "dart:ffi" as ffi; import "package:jni/internal_helpers_for_jnigen.dart"; import "package:jni/jni.dart" as jni; 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 46928c010..0ea6ad6b6 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 @@ -30,6 +30,7 @@ // ignore_for_file: unused_element // ignore_for_file: unused_import +import "dart:isolate" show ReceivePort; import "dart:ffi" as ffi; import "package:jni/internal_helpers_for_jnigen.dart"; import "package:jni/jni.dart" as jni; 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 e442778ff..2094a0b41 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 @@ -30,6 +30,7 @@ // ignore_for_file: unused_element // ignore_for_file: unused_import +import "dart:isolate" show ReceivePort; import "dart:ffi" as ffi; import "package:jni/internal_helpers_for_jnigen.dart"; import "package:jni/jni.dart" as jni; diff --git a/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h b/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h index 12e38b972..39b70bd8f 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h +++ b/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h @@ -260,3 +260,13 @@ static inline jthrowable check_exception() { if (exception == NULL) return NULL; return to_global_ref(exception); } + +FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); + +JNIEXPORT void JNICALL +Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env, + jobject thiz, + jlong port, + jobject result); +FFI_PLUGIN_EXPORT +JniResult PortContinuation__ctor(int64_t j); diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmTypeUsageSignatureVisitor.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmTypeUsageSignatureVisitor.java index dc0f5a477..3c52c1045 100644 --- a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmTypeUsageSignatureVisitor.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmTypeUsageSignatureVisitor.java @@ -78,7 +78,7 @@ public void visitClassType(String name) { typeUsage.shorthand = name.substring(0, name.length()).replace('/', '.'); var components = name.split("[/$]"); var simpleName = components[components.length - 1]; - typeUsage.type = new TypeUsage.DeclaredType(name, simpleName, new ArrayList<>()); + typeUsage.type = new TypeUsage.DeclaredType(typeUsage.shorthand, simpleName, new ArrayList<>()); } @Override diff --git a/pkgs/jnigen/lib/src/bindings/c_bindings.dart b/pkgs/jnigen/lib/src/bindings/c_bindings.dart index 8a989d373..488e3d8ed 100644 --- a/pkgs/jnigen/lib/src/bindings/c_bindings.dart +++ b/pkgs/jnigen/lib/src/bindings/c_bindings.dart @@ -35,9 +35,11 @@ class CBindingGenerator { String generateBinding(ClassDecl c) => _class(c); String _class(ClassDecl c) { + if (!c.isIncluded) { + return ''; + } final s = StringBuffer(); final classNameInC = getUniqueClassName(c); - // global variable in C that holds the reference to class final classVar = '${classVarPrefix}_$classNameInC'; s.write('// ${c.binaryName}\n' diff --git a/pkgs/jnigen/lib/src/bindings/common.dart b/pkgs/jnigen/lib/src/bindings/common.dart index 19fba1139..480a038bc 100644 --- a/pkgs/jnigen/lib/src/bindings/common.dart +++ b/pkgs/jnigen/lib/src/bindings/common.dart @@ -97,6 +97,10 @@ abstract class BindingsGenerator { args.add( '${getDartOuterType(param.type, resolver)} ${kwRename(param.name)}'); } + if (m.asyncReturnType != null) { + // Remove the continuation object in async methods. + args.removeLast(); + } return args.join(', '); } @@ -107,6 +111,10 @@ abstract class BindingsGenerator { final paramName = kwRename(param.name); args.add(toNativeArg(paramName, param.type)); } + if (m.asyncReturnType != null) { + // Change the continuation object in async methods. + args.last = '\$c'; + } return args.join(', '); } @@ -336,7 +344,16 @@ abstract class BindingsGenerator { type.params.map((param) => _dartType(param, resolver: resolver)); // Replacing the declared ones. They come at the end. + // The rest will be JObject. if (allTypeParams.length >= type.params.length) { + allTypeParams.replaceRange( + 0, + allTypeParams.length - type.params.length, + List.filled( + allTypeParams.length - type.params.length, + jniObjectType, + ), + ); allTypeParams.replaceRange( allTypeParams.length - type.params.length, allTypeParams.length, @@ -425,7 +442,16 @@ abstract class BindingsGenerator { (param) => _getDartTypeClass(param, resolver, addConst: false)); // Replacing the declared ones. They come at the end. + // The rest will be JObject. if (allTypeParams.length >= type.params.length) { + allTypeParams.replaceRange( + 0, + allTypeParams.length - type.params.length, + List.filled( + allTypeParams.length - type.params.length, + 'const $jniObjectTypeClass()', + ), + ); allTypeParams.replaceRange( allTypeParams.length - type.params.length, allTypeParams.length, @@ -690,6 +716,10 @@ String getDescriptor(TypeUsage usage, {bool escapeDollarSign = false}) { } } +String toFuture(String type) { + return 'Future<$type>'; +} + bool isPrimitive(TypeUsage t) => t.kind == Kind.primitive; bool isVoid(TypeUsage t) => isPrimitive(t) && t.name == 'void'; diff --git a/pkgs/jnigen/lib/src/bindings/dart_bindings.dart b/pkgs/jnigen/lib/src/bindings/dart_bindings.dart index e9d58c045..d1ad57639 100644 --- a/pkgs/jnigen/lib/src/bindings/dart_bindings.dart +++ b/pkgs/jnigen/lib/src/bindings/dart_bindings.dart @@ -21,7 +21,7 @@ class CBasedDartBindingsGenerator extends BindingsGenerator { static final indent = ' ' * 2; - static const voidPointer = BindingsGenerator.voidPointer; + static const voidPointer = BindingsGenerator.jobjectType; static const ffiVoidType = BindingsGenerator.ffiVoidType; @@ -91,8 +91,15 @@ class CBasedDartBindingsGenerator extends BindingsGenerator { final sym = '_$name'; final ffiSig = dartSigForMethod(m, isFfiSig: true); final dartSig = dartSigForMethod(m, isFfiSig: false); - final returnType = getDartOuterType(m.returnType, resolver); - final returnTypeClass = getDartTypeClass(m.returnType, resolver); + var returnType = getDartOuterType( + m.asyncReturnType ?? m.returnType, + resolver, + ); + if (m.asyncReturnType != null) { + returnType = toFuture(returnType); + } + final returnTypeClass = + getDartTypeClass(m.asyncReturnType ?? m.returnType, resolver); final ifStaticMethod = isStaticMethod(m) ? 'static' : ''; // Load corresponding C method. @@ -121,13 +128,34 @@ class CBasedDartBindingsGenerator extends BindingsGenerator { final resultGetter = getJValueAccessor(m.returnType); var wrapperExpr = '$sym(${actualArgs(m)}).$resultGetter'; - wrapperExpr = toDartResult(wrapperExpr, m.returnType, returnTypeClass); final typeParamsWithExtend = dartTypeParams(m.typeParams, includeExtends: true); final params = getFormalArgs(c, m, resolver); s.write( - '$indent$ifStaticMethod $returnType $name$typeParamsWithExtend($params) ' - '=> $wrapperExpr;\n'); + '$indent$ifStaticMethod $returnType $name$typeParamsWithExtend($params) ', + ); + if (m.asyncReturnType == null) { + wrapperExpr = toDartResult(wrapperExpr, m.returnType, returnTypeClass); + s.write('=> $wrapperExpr;\n'); + } else { + s.write( + 'async {\n' + '${indent * 2}final \$p = ReceivePort();\n' + '${indent * 2}final \$c = ${jni}Jni.newPortContinuation(\$p);\n' + '${indent * 2}$wrapperExpr;\n' + '${indent * 2}final \$o = $voidPointer.fromAddress(await \$p.first);\n' + '${indent * 2}final \$k = $returnTypeClass.getClass().reference;\n' + '${indent * 2}if (${jni}Jni.env.IsInstanceOf(\$o, \$k) == 0) {\n' + '${indent * 3}throw "Failed";\n' + '${indent * 2}}\n' + '${indent * 2}return ${toDartResult( + '\$o', + m.returnType, + returnTypeClass, + )};\n' + '}\n', + ); + } return s.toString(); } @@ -203,7 +231,8 @@ class CBasedDartBindingsGenerator extends BindingsGenerator { '\n\n'; static const autoGeneratedNotice = '// Autogenerated by jnigen. ' 'DO NOT EDIT!\n\n'; - static const defaultImports = 'import "dart:ffi" as ffi;\n' + static const defaultImports = 'import "dart:isolate" show ReceivePort;\n' + 'import "dart:ffi" as ffi;\n' 'import "package:jni/internal_helpers_for_jnigen.dart";\n' 'import "package:jni/jni.dart" as jni;\n\n'; static const defaultLintSuppressions = diff --git a/pkgs/jnigen/lib/src/bindings/preprocessor.dart b/pkgs/jnigen/lib/src/bindings/preprocessor.dart index acc6f2b57..0003f223f 100644 --- a/pkgs/jnigen/lib/src/bindings/preprocessor.dart +++ b/pkgs/jnigen/lib/src/bindings/preprocessor.dart @@ -11,6 +11,8 @@ import 'common.dart'; /// Preprocessor which fills information needed by both Dart and C generators. abstract class ApiPreprocessor { + static const kotlinContinutationType = 'kotlin.coroutines.Continuation'; + static void preprocessAll(Map classes, Config config, {bool renameClasses = false}) { final classNameCounts = {}; @@ -34,10 +36,11 @@ abstract class ApiPreprocessor { static void _preprocess( ClassDecl decl, Map classes, Config config) { if (decl.isPreprocessed) return; + if (!_isClassIncluded(decl, config)) { decl.isIncluded = false; - log.fine('exclude class ${decl.binaryName}'); decl.isPreprocessed = true; + log.fine('exclude class ${decl.binaryName}'); // Excluding all the class's methods and fields for (final method in decl.methods) { method.isIncluded = false; @@ -78,6 +81,18 @@ abstract class ApiPreprocessor { log.fine('exclude method ${decl.binaryName}#${method.name}'); continue; } + if (config.suspendFunToAsync && + method.params.isNotEmpty && + method.params.last.type.kind == Kind.declared && + method.params.last.type.shorthand == kotlinContinutationType) { + final continuationType = method.params.last.type.type as DeclaredType; + method.asyncReturnType = continuationType.params.isEmpty + ? TypeUsage.object + : continuationType.params.first; + } else { + method.asyncReturnType = null; + } + var realName = method.name; if (isCtor(method)) { realName = 'ctor'; diff --git a/pkgs/jnigen/lib/src/bindings/pure_dart_bindings.dart b/pkgs/jnigen/lib/src/bindings/pure_dart_bindings.dart index 46f168b4b..67ceeed84 100644 --- a/pkgs/jnigen/lib/src/bindings/pure_dart_bindings.dart +++ b/pkgs/jnigen/lib/src/bindings/pure_dart_bindings.dart @@ -23,10 +23,9 @@ class PureDartBindingsGenerator extends BindingsGenerator { static const ffi = BindingsGenerator.ffi; static const jni = BindingsGenerator.jni; - static const voidPointer = BindingsGenerator.voidPointer; + static const voidPointer = BindingsGenerator.jobjectType; static const ffiVoidType = BindingsGenerator.ffiVoidType; static const jniObjectType = BindingsGenerator.jniObjectType; - static const jobjectType = BindingsGenerator.jobjectType; static final _deleteInstruction = BindingsGenerator.deleteInstruction; @@ -117,8 +116,15 @@ class PureDartBindingsGenerator extends BindingsGenerator { // Different logic for constructor and method; // For constructor, we want return type to be new object. - final returnType = getDartOuterType(m.returnType, resolver); - final returnTypeClass = getDartTypeClass(m.returnType, resolver); + var returnType = getDartOuterType( + m.asyncReturnType ?? m.returnType, + resolver, + ); + if (m.asyncReturnType != null) { + returnType = toFuture(returnType); + } + final returnTypeClass = + getDartTypeClass(m.asyncReturnType ?? m.returnType, resolver); s.write('$indent/// from: ${getOriginalMethodHeader(m)}\n'); if (!isPrimitive(m.returnType) || isCtor(m)) { s.write(_deleteInstruction); @@ -148,9 +154,31 @@ class PureDartBindingsGenerator extends BindingsGenerator { var wrapperExpr = '$accessors.call${ifStatic}MethodWithArgs' '($selfArgument, $mID, $callType, [${actualArgs(m)}])' '.$resultGetter'; - wrapperExpr = toDartResult(wrapperExpr, m.returnType, returnTypeClass); s.write( - '$returnType $name$typeParamsWithExtend(${getFormalArgs(c, m, resolver)}) => $wrapperExpr;\n'); + '$returnType $name$typeParamsWithExtend(${getFormalArgs(c, m, resolver)}) ', + ); + if (m.asyncReturnType == null) { + wrapperExpr = toDartResult(wrapperExpr, m.returnType, returnTypeClass); + s.write('=> $wrapperExpr;\n'); + } else { + s.write( + 'async {\n' + '${indent * 2}final \$p = ReceivePort();\n' + '${indent * 2}final \$c = ${jni}Jni.newPortContinuation(\$p);\n' + '${indent * 2}$wrapperExpr;\n' + '${indent * 2}final \$o = $voidPointer.fromAddress(await \$p.first);\n' + '${indent * 2}final \$k = $returnTypeClass.getClass().reference;\n' + '${indent * 2}if (${jni}Jni.env.IsInstanceOf(\$o, \$k) == 0) {\n' + '${indent * 3}throw "Failed";\n' + '${indent * 2}}\n' + '${indent * 2}return ${toDartResult( + '\$o', + m.returnType, + returnTypeClass, + )};\n' + '}\n', + ); + } return s.toString(); } @@ -227,10 +255,11 @@ class PureDartBindingsGenerator extends BindingsGenerator { '// ignore_for_file: unused_shown_name\n' '\n'; + static const dartImports = 'import "dart:isolate" show ReceivePort;\n\n'; static const jniImport = 'import "package:jni/jni.dart" as jni;\n\n'; static const internalHelpersImport = 'import "package:jni/internal_helpers_for_jnigen.dart";\n\n'; - static const defaultImports = jniImport + internalHelpersImport; + static const defaultImports = dartImports + jniImport + internalHelpersImport; static const initialization = 'final jniEnv = ${jni}Jni.env;\n' 'final jniAccessors = ${jni}Jni.accessors;\n\n'; diff --git a/pkgs/jnigen/lib/src/config/config_types.dart b/pkgs/jnigen/lib/src/config/config_types.dart index c32f82479..9918b06dd 100644 --- a/pkgs/jnigen/lib/src/config/config_types.dart +++ b/pkgs/jnigen/lib/src/config/config_types.dart @@ -235,6 +235,7 @@ class Config { required this.outputConfig, required this.classes, this.exclude, + this.suspendFunToAsync = false, this.sourcePath, this.classPath, this.preamble, @@ -289,6 +290,12 @@ class Config { /// `com.abc.package` -> 'package:abc/abc.dart'` final Map? importMap; + /// Whether or not to change Kotlin's suspend functions to Dart async ones. + /// + /// This will remove the final Continuation argument. + /// Defaults to [false]. + final bool suspendFunToAsync; + /// Configuration to search for Android SDK libraries (Experimental). final AndroidSdkConfig? androidSdkConfig; @@ -383,6 +390,7 @@ class Config { methods: regexFilter(_Props.excludeMethods), fields: regexFilter(_Props.excludeFields), ), + suspendFunToAsync: prov.getBool(_Props.suspendFunToAsync) ?? false, outputConfig: OutputConfig( bindingsType: getBindingsType( prov.getString(_Props.bindingsType), @@ -467,6 +475,8 @@ class _Props { static const excludeMethods = '$exclude.methods'; static const excludeFields = '$exclude.fields'; + static const suspendFunToAsync = 'suspend_fun_to_async'; + static const importMap = 'import_map'; static const outputConfig = 'output'; static const bindingsType = '$outputConfig.bindings_type'; diff --git a/pkgs/jnigen/lib/src/elements/elements.dart b/pkgs/jnigen/lib/src/elements/elements.dart index 85269c2b4..1edefc4e4 100644 --- a/pkgs/jnigen/lib/src/elements/elements.dart +++ b/pkgs/jnigen/lib/src/elements/elements.dart @@ -58,7 +58,7 @@ class ClassDecl { this.modifiers = const {}, required this.simpleName, required this.binaryName, - required this.packageName, + this.packageName = '', this.parentName, this.typeParams = const [], this.methods = const [], @@ -156,6 +156,12 @@ class TypeUsage { required this.typeJson, }); + static TypeUsage object = TypeUsage.fromJson({ + "shorthand": "java.lang.Object", + "kind": "DECLARED", + "type": {"binaryName": "java.lang.Object", "simpleName": "Object"} + }); + String shorthand; Kind kind; @JsonKey(includeFromJson: false) @@ -286,6 +292,13 @@ class Method implements ClassMember { late String finalName; @JsonKey(includeFromJson: false) late bool isOverridden; + + /// This gets populated in the preprocessing stage. + /// + /// It will contain a type only when the suspendFunToAsync flag is on + /// and the method has a `kotlin.coroutines.Continuation` final argument. + @JsonKey(includeFromJson: false) + late TypeUsage? asyncReturnType; @JsonKey(includeFromJson: false) bool isIncluded = true; diff --git a/pkgs/jnigen/lib/src/elements/elements.g.dart b/pkgs/jnigen/lib/src/elements/elements.g.dart index 68f91d6eb..64e60f74a 100644 --- a/pkgs/jnigen/lib/src/elements/elements.g.dart +++ b/pkgs/jnigen/lib/src/elements/elements.g.dart @@ -20,7 +20,7 @@ ClassDecl _$ClassDeclFromJson(Map json) => ClassDecl( const {}, simpleName: json['simpleName'] as String, binaryName: json['binaryName'] as String, - packageName: json['packageName'] as String, + packageName: (json['packageName'] as String?) ?? '', parentName: json['parentName'] as String?, typeParams: (json['typeParams'] as List?) ?.map((e) => TypeParam.fromJson(e as Map)) diff --git a/pkgs/jnigen/lib/src/writers/files_writer.dart b/pkgs/jnigen/lib/src/writers/files_writer.dart index 73619152d..79904f049 100644 --- a/pkgs/jnigen/lib/src/writers/files_writer.dart +++ b/pkgs/jnigen/lib/src/writers/files_writer.dart @@ -236,7 +236,7 @@ class FilesWriter extends BindingsWriter { : PureDartBindingsGenerator(config); if (cBased) { - await writeCBindings(config, classes); + await writeCBindings(config, classesByName.values.toList()); } // Write init file diff --git a/pkgs/jnigen/lib/src/writers/single_file_writer.dart b/pkgs/jnigen/lib/src/writers/single_file_writer.dart index 8d8e5c745..438f867e5 100644 --- a/pkgs/jnigen/lib/src/writers/single_file_writer.dart +++ b/pkgs/jnigen/lib/src/writers/single_file_writer.dart @@ -64,7 +64,7 @@ class SingleFileWriter extends BindingsWriter { ApiPreprocessor.preprocessAll(classesByName, config, renameClasses: true); if (cBased) { - await writeCBindings(config, classes); + await writeCBindings(config, classesByName.values.toList()); } log.info("Generating ${cBased ? "C + Dart" : "Pure Dart"} Bindings"); final generator = cBased diff --git a/pkgs/jnigen/pubspec.yaml b/pkgs/jnigen/pubspec.yaml index 0ac0eb516..b491b181e 100644 --- a/pkgs/jnigen/pubspec.yaml +++ b/pkgs/jnigen/pubspec.yaml @@ -3,7 +3,7 @@ # BSD-style license that can be found in the LICENSE file. name: jnigen -version: 0.2.0 +version: 0.3.0 description: Experimental generator for FFI+JNI bindings. repository: https://github.com/dart-lang/jnigen/tree/main/jnigen @@ -11,7 +11,7 @@ environment: sdk: '>=2.17.0 <3.0.0' dependencies: - json_annotation: ^4.7.0 + json_annotation: ^4.8.0 package_config: ^2.1.0 path: ^1.8.0 args: ^2.3.0 @@ -24,5 +24,5 @@ dev_dependencies: path: ../jni test: ^1.17.5 build_runner: ^2.2.0 - json_serializable: ^6.5.4 + json_serializable: ^6.6.0 diff --git a/pkgs/jnigen/test/.gitignore b/pkgs/jnigen/test/.gitignore new file mode 100644 index 000000000..646810145 --- /dev/null +++ b/pkgs/jnigen/test/.gitignore @@ -0,0 +1,2 @@ +# TODO(#166): Remove this. +!jni.jar \ No newline at end of file diff --git a/pkgs/jnigen/test/bindings_test.dart b/pkgs/jnigen/test/bindings_test.dart index 772d03409..3c1cd9f64 100644 --- a/pkgs/jnigen/test/bindings_test.dart +++ b/pkgs/jnigen/test/bindings_test.dart @@ -16,6 +16,7 @@ import 'package:path/path.dart' hide equals; import 'package:test/test.dart'; // ignore_for_file: avoid_relative_lib_imports +import 'kotlin_test/lib/kotlin.dart'; import 'simple_package_test/lib/simple_package.dart'; import 'jackson_core_test/third_party/lib/com/fasterxml/jackson/core/_package.dart'; @@ -23,7 +24,11 @@ import 'test_util/test_util.dart'; final simplePackageTest = join('test', 'simple_package_test'); final jacksonCoreTest = join('test', 'jackson_core_test'); +final kotlinTest = join('test', 'kotlin_test'); +final jniJar = join(kotlinTest, 'jni.jar'); + final simplePackageTestJava = join(simplePackageTest, 'java'); +final kotlinTestKotlin = join(kotlinTest, 'kotlin'); Future setupDylibsAndClasses() async { await runCommand('dart', [ @@ -60,15 +65,38 @@ Future setupDylibsAndClasses() async { final jacksonJars = await getJarPaths(join(jacksonCoreTest, 'third_party')); + await runCommand('dart', [ + 'run', + 'jni:setup', + '-p', + 'jni', + '-s', + join(kotlinTest, 'src'), + ]); + await runCommand( + 'mvn', + ['package'], + workingDirectory: kotlinTestKotlin, + runInShell: true, + ); + // Jar including Kotlin runtime and dependencies. + final kotlinTestJar = + join(kotlinTestKotlin, 'target', 'kotlin_test-jar-with-dependencies.jar'); + if (!Platform.isAndroid) { - Jni.spawn( - dylibDir: join('build', 'jni_libs'), - classPath: [simplePackageTestJava, ...jacksonJars]); + Jni.spawn(dylibDir: join('build', 'jni_libs'), classPath: [ + jniJar, + simplePackageTestJava, + ...jacksonJars, + kotlinTestJar, + ]); } + + Jni.initDLApi(); } void main() async { - await setupDylibsAndClasses(); + setUpAll(setupDylibsAndClasses); test('static final fields', () { expect(Example.ON, equals(1)); @@ -117,7 +145,6 @@ void main() async { final array = JArray(Example.type, 2); array[0] = ex1; array[1] = ex2; - print(array[0].getInternal()); expect(array[0].getInternal(), 1); expect(array[1].getInternal(), 2); array.delete(); @@ -187,6 +214,7 @@ void main() async { expect( ((map.entryStack()..deletedIn(arena)).pop()..deletedIn(arena)) .key + .castTo(JString.type, deleteOriginal: true) .toDartString(deleteOriginal: true), anyOf('Hello', 'World'), ); @@ -251,7 +279,9 @@ void main() async { final strParent = grandParent.stringParent()..deletedIn(arena); expect( - strParent.parentValue.toDartString(deleteOriginal: true), + strParent.parentValue + .castTo(JString.type, deleteOriginal: true) + .toDartString(deleteOriginal: true), "!", ); expect( @@ -263,7 +293,9 @@ void main() async { Example.type, Example()..deletedIn(arena)) ..deletedIn(arena); expect( - exampleParent.parentValue.toDartString(deleteOriginal: true), + exampleParent.parentValue + .castTo(JString.type, deleteOriginal: true) + .toDartString(deleteOriginal: true), "!", ); expect( @@ -275,4 +307,17 @@ void main() async { }); }); }); + group('Kotlin support', () { + test('Suspend functions', () async { + await using((arena) async { + final suspendFun = SuspendFun()..deletedIn(arena); + final hello = await suspendFun.sayHello(); + expect(hello.toDartString(deleteOriginal: true), "Hello!"); + const name = "Bob"; + final helloBob = + await suspendFun.sayHello1(name.toJString()..deletedIn(arena)); + expect(helloBob.toDartString(deleteOriginal: true), "Hello $name!"); + }); + }); + }); } diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonFactory.dart b/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonFactory.dart index be5fc9f29..2cb23c07e 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonFactory.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonFactory.dart @@ -31,6 +31,8 @@ // ignore_for_file: unused_import // ignore_for_file: unused_shown_name +import "dart:isolate" show ReceivePort; + import "package:jni/jni.dart" as jni; import "package:jni/internal_helpers_for_jnigen.dart"; diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonParser.dart b/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonParser.dart index 2e1305edb..4f453370d 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonParser.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonParser.dart @@ -31,6 +31,8 @@ // ignore_for_file: unused_import // ignore_for_file: unused_shown_name +import "dart:isolate" show ReceivePort; + import "package:jni/jni.dart" as jni; import "package:jni/internal_helpers_for_jnigen.dart"; diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonToken.dart b/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonToken.dart index e3aa9b6bd..8c3bc75c9 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonToken.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonToken.dart @@ -31,6 +31,8 @@ // ignore_for_file: unused_import // ignore_for_file: unused_shown_name +import "dart:isolate" show ReceivePort; + import "package:jni/jni.dart" as jni; import "package:jni/internal_helpers_for_jnigen.dart"; diff --git a/pkgs/jnigen/test/kotlin_test/.gitignore b/pkgs/jnigen/test/kotlin_test/.gitignore new file mode 100644 index 000000000..39de10f73 --- /dev/null +++ b/pkgs/jnigen/test/kotlin_test/.gitignore @@ -0,0 +1,5 @@ +build/ +*.class +test_lib/ +test_src/ +target/ diff --git a/pkgs/jnigen/test/kotlin_test/generate.dart b/pkgs/jnigen/test/kotlin_test/generate.dart new file mode 100644 index 000000000..8f877aebe --- /dev/null +++ b/pkgs/jnigen/test/kotlin_test/generate.dart @@ -0,0 +1,70 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +import 'dart:io'; + +import 'package:logging/logging.dart'; +import 'package:path/path.dart'; +import 'package:jnigen/jnigen.dart'; + +const testName = 'kotlin_test'; +const jarFile = '$testName.jar'; + +final testRoot = join('test', testName); +final kotlinPath = join(testRoot, 'kotlin'); +final jarPath = join(kotlinPath, 'target', jarFile); + +const preamble = ''' +// 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. + +'''; + +void compileKotlinSources(String workingDir) async { + final procRes = Process.runSync( + 'mvn', + ['package'], + workingDirectory: workingDir, + runInShell: true, + ); + if (procRes.exitCode != 0) { + throw "mvn exited with ${procRes.exitCode}\n" + "${procRes.stderr}"; + } +} + +Config getConfig([BindingsType bindingsType = BindingsType.cBased]) { + compileKotlinSources(kotlinPath); + final cWrapperDir = Uri.directory(join(testRoot, "src")); + final dartWrappersRoot = Uri.directory(join(testRoot, "lib")); + final config = Config( + classPath: [Uri.file(jarPath)], + classes: [ + // Generating the entire library. + // + // This makes sure that no private class generated by Kotlin can make its + // way to the generated code. + 'com.github.dart_lang.jnigen', + ], + suspendFunToAsync: true, + logLevel: Level.ALL, + outputConfig: OutputConfig( + bindingsType: bindingsType, + cConfig: CCodeOutputConfig( + path: cWrapperDir, + libraryName: 'kotlin', + ), + dartConfig: DartCodeOutputConfig( + path: dartWrappersRoot.resolve('kotlin.dart'), + structure: OutputStructure.singleFile, + ), + ), + summarizerOptions: SummarizerOptions(backend: 'asm'), + preamble: preamble, + ); + return config; +} + +void main() async => await generateJniBindings(getConfig()); diff --git a/pkgs/jnigen/test/kotlin_test/generated_files_test.dart b/pkgs/jnigen/test/kotlin_test/generated_files_test.dart new file mode 100644 index 000000000..ee136e865 --- /dev/null +++ b/pkgs/jnigen/test/kotlin_test/generated_files_test.dart @@ -0,0 +1,25 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +import 'package:jnigen/jnigen.dart'; +import 'package:test/test.dart'; +import 'package:path/path.dart' hide equals; + +import 'generate.dart'; +import '../test_util/test_util.dart'; + +void main() async { + test("Generate and compare bindings for kotlin_test", () async { + await generateAndCompareBindings( + getConfig(), + join(testRoot, "lib", "kotlin.dart"), + join(testRoot, "src"), + ); + }); // test if generated file == expected file + test("Generate and analyze bindings for kotlin_test - pure dart", () async { + await generateAndAnalyzeBindings( + getConfig(BindingsType.dartOnly), + ); + }); // test if generated file == expected file +} diff --git a/pkgs/jnigen/test/kotlin_test/jni.jar b/pkgs/jnigen/test/kotlin_test/jni.jar new file mode 100644 index 0000000000000000000000000000000000000000..37a1bfc8ee9b578163cffca1479743f667050a80 GIT binary patch literal 2755 zcmWIWW@h1H0D+Cg_F-TKl;8x?zOEsTx}JV+`TRsgZ*3~+9=KSU$gDb`lo)+nNojal9t?R_W{$xqm6fx}s zDiu5DbO#B02L+eR)mkee!!0z~I7qZc_;k=`k)E$QU(NvKy^M>!4s4qGbLr8QnKK0z zio~v;lCwbfSruE=vOO_-Vi;h~V_;y(0R%Exo{6)s^EsINY5OxU^*DWx};_fP?<9o@87o69dB*po{hKYRfMwan8>x$;>NFEXmBz z(@V}tEH3U1ew`=eDDtoE_MvH)ytuDm#S}@*L8O zO!KYOo?Vgo=OOctfMdqotw9EvCyL(PuX#RarhR?=U$zfI`XMX=Ap%{>JsgLtuK!5N zusxiYef;dYRIWCU&f76lB%5x=D7R@Oab2+p6G%TX(=R@|_~OS|QKt)zcE;b_y7Sw? zLf4}kS-0Cd7aULH;5~8lz$z`Fh~N!!$9YvGjpoZNHnWG<4BUNq4TywyDC`rK)OQD_>0UNMHTys$BO@H<4(b zuAIgbt9SHTbGd!pRC0TH~eb3S==-2-0XD^`y_&HdQUKYShU-B0@pj=*|VQp zn@`O#y{-^g7$tUimY?SPy>*w1Ub}5}pSR@Q47c@(J7R7Lr+buG@Ge^rU;W4RRgGMx z$qonWJ$61T@M?Nes{CI0!bay&fI&V zb}Va8uJobe&cA^x|798O-SZ;qRH0|K>G5LU*Sgaed&bHhXlyxJyDN^-;LU~UQ}i3} z1h$(Uk20v!aDmu%bt>qbhKIUzeV0tsfG8*hR*hsrJVhnK5|qytoICQ ztG%>T=J+O+mlqZ7EuWftN^;Ll{`y+P{?YGkHFpYgGn#hWKbKrA`k|sJOnv=%rTPEa zmVRKCHa@pX{-)Z#ng2i3HZ`Z#L^|wq+O+sWP1>g=vG&a~)bi&&zBcoGa@i@Zvxbhh z6kjsh95s%&`_GQZR_KKTKQM*D3y0jqveZ0ya>gu4q%jre7p3c^RwU*Yz&W(48awqQTaTz$-zB?KmswQ8 zTPK_j{Pm+??%d_#Timwt;iKT zsPkb${c;l#<*8Z=YPx1GQ1tpBcddKR(!lK6=z#frj%T%EnGViRSYq(_NK@hSM$y{_ zP1X)6Ceq969^TBUsO2pMT z?pk;{gp`z<%0GAK0OK|ri1mn!n0FaIs zKqg2ByuQS(5maMB07#=CFkd2RM6N$^8v&|85k|P+G6GVc!i>RQqrwbY(pZhx7_9Xx za)@Fp3}J5k|6dju!0@Pq6^$^LVJ{pJn!PYJqZXC84N`#l5163-|8K@`5VYuonTEaa zgc-P`@gNbVL5osEKw;0V2t${$VFVPiU%^fU8H&ie0p6@YJq!#yKp4Qxz!1w0;sF54 Cwu%=3 literal 0 HcmV?d00001 diff --git a/pkgs/jnigen/test/kotlin_test/kotlin/pom.xml b/pkgs/jnigen/test/kotlin_test/kotlin/pom.xml new file mode 100644 index 000000000..b32d4ed1a --- /dev/null +++ b/pkgs/jnigen/test/kotlin_test/kotlin/pom.xml @@ -0,0 +1,119 @@ + + + 4.0.0 + + kotlin + com.github.dart_lang.jnigen + 1.0-SNAPSHOT + jar + consoleApp + + + UTF-8 + official + com.github.dart_lang.jnigen.SuspendFun + 1.8 + + + + + mavenCentral + https://repo1.maven.org/maven2/ + + + + + kotlin_test + src/main/kotlin + src/test/kotlin + + + org.jetbrains.kotlin + kotlin-maven-plugin + 1.7.20 + + + compile + compile + + compile + + + + test-compile + test-compile + + test-compile + + + + + + maven-surefire-plugin + 2.22.2 + + + maven-failsafe-plugin + 2.22.2 + + + org.codehaus.mojo + exec-maven-plugin + 1.6.0 + + MainKt + + + + org.apache.maven.plugins + maven-assembly-plugin + 2.6 + + + make-assembly + package + single + + + + ${main.class} + + + + jar-with-dependencies + + + + + + + + + + + org.jetbrains.kotlin + kotlin-test-junit5 + 1.7.20 + test + + + org.jetbrains.kotlinx + kotlinx-coroutines-core + 1.6.4 + + + org.junit.jupiter + junit-jupiter-engine + 5.8.2 + test + + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + 1.7.20 + + + + \ No newline at end of file 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 new file mode 100644 index 000000000..ffd43769e --- /dev/null +++ b/pkgs/jnigen/test/kotlin_test/kotlin/src/main/kotlin/com/github/dart_lang/jnigen/SuspendFun.kt @@ -0,0 +1,21 @@ +/* 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. + */ + +package com.github.dart_lang.jnigen + +import kotlinx.coroutines.delay +import kotlin.coroutines.Continuation + +public class SuspendFun { + suspend fun sayHello(): String { + delay(100L) + return "Hello!" + } + + suspend fun sayHello(name: String): String { + delay(100L) + return "Hello $name!" + } +} \ No newline at end of file diff --git a/pkgs/jnigen/test/kotlin_test/lib/kotlin.dart b/pkgs/jnigen/test/kotlin_test/lib/kotlin.dart new file mode 100644 index 000000000..aaf5b7e93 --- /dev/null +++ b/pkgs/jnigen/test/kotlin_test/lib/kotlin.dart @@ -0,0 +1,115 @@ +// 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. + +// Autogenerated by jnigen. DO NOT EDIT! + +// ignore_for_file: annotate_overrides +// ignore_for_file: camel_case_extensions +// ignore_for_file: camel_case_types +// ignore_for_file: constant_identifier_names +// ignore_for_file: file_names +// ignore_for_file: no_leading_underscores_for_local_identifiers +// ignore_for_file: non_constant_identifier_names +// ignore_for_file: overridden_fields +// ignore_for_file: unnecessary_cast +// ignore_for_file: unused_element +// ignore_for_file: unused_import + +import "dart:isolate" show ReceivePort; +import "dart:ffi" as ffi; +import "package:jni/internal_helpers_for_jnigen.dart"; +import "package:jni/jni.dart" as jni; + +// Auto-generated initialization code. + +final ffi.Pointer Function(String sym) jniLookup = + ProtectedJniExtensions.initGeneratedLibrary("kotlin"); + +/// from: com.github.dart_lang.jnigen.SuspendFun +class SuspendFun extends jni.JObject { + late final jni.JObjType? _$type; + @override + jni.JObjType get $type => _$type ??= type; + + SuspendFun.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = $SuspendFunType(); + + static final _ctor = jniLookup>( + "SuspendFun__ctor") + .asFunction(); + + /// from: public void () + SuspendFun() : super.fromRef(_ctor().object); + + static final _sayHello = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("SuspendFun__sayHello") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public final java.lang.Object sayHello(kotlin.coroutines.Continuation continuation) + /// The returned object must be deleted after use, by calling the `delete` method. + Future sayHello() async { + final $p = ReceivePort(); + final $c = jni.Jni.newPortContinuation($p); + _sayHello(reference, $c).object; + final $o = jni.JObjectPtr.fromAddress(await $p.first); + final $k = const jni.JStringType().getClass().reference; + if (jni.Jni.env.IsInstanceOf($o, $k) == 0) { + throw "Failed"; + } + return const jni.JStringType().fromRef($o); + } + + static final _sayHello1 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>("SuspendFun__sayHello1") + .asFunction< + jni.JniResult Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + /// from: public final java.lang.Object sayHello(java.lang.String string, kotlin.coroutines.Continuation continuation) + /// The returned object must be deleted after use, by calling the `delete` method. + Future sayHello1(jni.JString string) async { + final $p = ReceivePort(); + final $c = jni.Jni.newPortContinuation($p); + _sayHello1(reference, string.reference, $c).object; + final $o = jni.JObjectPtr.fromAddress(await $p.first); + final $k = const jni.JStringType().getClass().reference; + if (jni.Jni.env.IsInstanceOf($o, $k) == 0) { + throw "Failed"; + } + return const jni.JStringType().fromRef($o); + } +} + +class $SuspendFunType extends jni.JObjType { + const $SuspendFunType(); + + @override + String get signature => r"Lcom/github/dart_lang/jnigen/SuspendFun;"; + + @override + SuspendFun fromRef(jni.JObjectPtr ref) => SuspendFun.fromRef(ref); +} + +extension $SuspendFunArray on jni.JArray { + SuspendFun operator [](int index) { + return (elementType as $SuspendFunType) + .fromRef(elementAt(index, jni.JniCallType.objectType).object); + } + + void operator []=(int index, SuspendFun value) { + (this as jni.JArray)[index] = value; + } +} diff --git a/pkgs/jnigen/test/kotlin_test/src/.clang-format b/pkgs/jnigen/test/kotlin_test/src/.clang-format new file mode 100644 index 000000000..a256c2f09 --- /dev/null +++ b/pkgs/jnigen/test/kotlin_test/src/.clang-format @@ -0,0 +1,15 @@ +# From dart SDK: https://github.com/dart-lang/sdk/blob/main/.clang-format + +# Defines the Chromium style for automatic reformatting. +# http://clang.llvm.org/docs/ClangFormatStyleOptions.html +BasedOnStyle: Chromium + +# clang-format doesn't seem to do a good job of this for longer comments. +ReflowComments: 'false' + +# We have lots of these. Though we need to put them all in curly braces, +# clang-format can't do that. +AllowShortIfStatementsOnASingleLine: 'true' + +# Put escaped newlines into the rightmost column. +AlignEscapedNewlinesLeft: false diff --git a/pkgs/jnigen/test/kotlin_test/src/CMakeLists.txt b/pkgs/jnigen/test/kotlin_test/src/CMakeLists.txt new file mode 100644 index 000000000..3889f546a --- /dev/null +++ b/pkgs/jnigen/test/kotlin_test/src/CMakeLists.txt @@ -0,0 +1,32 @@ +# jni_native_build (Build with jni:setup. Do not delete this line.) + +# The Flutter tooling requires that developers have CMake 3.10 or later +# installed. You should not increase this version, as doing so will cause +# the plugin to fail to compile for some customers of the plugin. +cmake_minimum_required(VERSION 3.10) + +project(kotlin VERSION 0.0.1 LANGUAGES C) + +add_library(kotlin SHARED + "./kotlin.c" +) + +set_target_properties(kotlin PROPERTIES + OUTPUT_NAME "kotlin" +) + +target_compile_definitions(kotlin PUBLIC DART_SHARED_LIB) + +if(WIN32) + set_target_properties(${TARGET_NAME} PROPERTIES + LINK_FLAGS "/DELAYLOAD:jvm.dll") +endif() + +if (ANDROID) + target_link_libraries(kotlin log) +else() + find_package(Java REQUIRED) + find_package(JNI REQUIRED) + include_directories(${JNI_INCLUDE_DIRS}) + target_link_libraries(kotlin ${JNI_LIBRARIES}) +endif() diff --git a/pkgs/jnigen/test/kotlin_test/src/dartjni.h b/pkgs/jnigen/test/kotlin_test/src/dartjni.h new file mode 100644 index 000000000..39b70bd8f --- /dev/null +++ b/pkgs/jnigen/test/kotlin_test/src/dartjni.h @@ -0,0 +1,272 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +#pragma once + +// Note: include appropriate system jni.h as found by CMake, not third_party/jni.h. +#include +#include +#include +#include + +#if _WIN32 +#include +#else +#include +#include +#endif + +#if _WIN32 +#define FFI_PLUGIN_EXPORT __declspec(dllexport) +#else +#define FFI_PLUGIN_EXPORT +#endif + +#if defined _WIN32 +#define thread_local __declspec(thread) +#else +#define thread_local __thread +#endif + +#ifdef __ANDROID__ +#include +#endif + +#ifdef __ANDROID__ +#define __ENVP_CAST (JNIEnv**) +#else +#define __ENVP_CAST (void**) +#endif + +/// Stores the global state of the JNI. +typedef struct JniContext { + JavaVM* jvm; + jobject classLoader; + jmethodID loadClassMethod; + jobject currentActivity; + jobject appContext; +} JniContext; + +// jniEnv for this thread, used by inline functions in this header, +// therefore declared as extern. +extern thread_local JNIEnv* jniEnv; + +extern JniContext jni; + +/// Types used by JNI API to distinguish between primitive types. +enum JniType { + booleanType = 0, + byteType = 1, + shortType = 2, + charType = 3, + intType = 4, + longType = 5, + floatType = 6, + doubleType = 7, + objectType = 8, + voidType = 9, +}; + +/// 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]. +typedef struct JniResult { + jvalue result; + jthrowable exception; +} JniResult; + +/// Similar to [JniResult] but for class lookups. +typedef struct JniClassLookupResult { + jclass classRef; + jthrowable exception; +} JniClassLookupResult; + +/// Similar to [JniResult] but for method/field ID lookups. +typedef struct JniPointerResult { + void* id; + jthrowable exception; +} JniPointerResult; + +/// JniExceptionDetails holds 2 jstring objects, one is the result of +/// calling `toString` on exception object, other is stack trace; +typedef struct JniExceptionDetails { + jstring message; + jstring stacktrace; +} JniExceptionDetails; + +/// This struct contains functions which wrap method call / field access conveniently along with +/// exception checking. +/// +/// Flutter embedding checks for pending JNI exceptions before an FFI transition, which requires us +/// to check for and clear the exception before returning to dart code, which requires these functions +/// to return result types. +typedef struct JniAccessors { + JniClassLookupResult (*getClass)(char* internalName); + JniPointerResult (*getFieldID)(jclass cls, char* fieldName, char* signature); + JniPointerResult (*getStaticFieldID)(jclass cls, + char* fieldName, + char* signature); + JniPointerResult (*getMethodID)(jclass cls, + char* methodName, + char* signature); + JniPointerResult (*getStaticMethodID)(jclass cls, + char* methodName, + char* signature); + JniResult (*newObject)(jclass cls, jmethodID ctor, jvalue* args); + JniPointerResult (*newPrimitiveArray)(jsize length, int type); + JniPointerResult (*newObjectArray)(jsize length, + jclass elementClass, + jobject initialElement); + JniResult (*getArrayElement)(jarray array, int index, int type); + JniResult (*callMethod)(jobject obj, + jmethodID methodID, + int callType, + jvalue* args); + JniResult (*callStaticMethod)(jclass cls, + jmethodID methodID, + int callType, + jvalue* args); + JniResult (*getField)(jobject obj, jfieldID fieldID, int callType); + JniResult (*getStaticField)(jclass cls, jfieldID fieldID, int callType); + JniExceptionDetails (*getExceptionDetails)(jthrowable exception); +} JniAccessors; + +FFI_PLUGIN_EXPORT JniAccessors* GetAccessors(); + +FFI_PLUGIN_EXPORT JavaVM* GetJavaVM(void); + +FFI_PLUGIN_EXPORT JNIEnv* GetJniEnv(void); + +FFI_PLUGIN_EXPORT JNIEnv* SpawnJvm(JavaVMInitArgs* args); + +FFI_PLUGIN_EXPORT jclass LoadClass(const char* name); + +FFI_PLUGIN_EXPORT jobject GetClassLoader(void); + +FFI_PLUGIN_EXPORT jobject GetApplicationContext(void); + +FFI_PLUGIN_EXPORT jobject GetCurrentActivity(void); + +// Migration note: Below inline functions are required by C bindings, but can be moved to dartjni.c +// once migration to pure dart bindings is complete. + +// `static inline` because `inline` doesn't work, it may still not +// inline the function in which case a linker error may be produced. +// +// There has to be a better way to do this. Either to force inlining on target +// platforms, or just leave it as normal function. + +static inline void __load_class_into(jclass* cls, const char* name) { +#ifdef __ANDROID__ + jstring className = (*jniEnv)->NewStringUTF(jniEnv, name); + *cls = (*jniEnv)->CallObjectMethod(jniEnv, jni.classLoader, + jni.loadClassMethod, className); + (*jniEnv)->DeleteLocalRef(jniEnv, className); +#else + *cls = (*jniEnv)->FindClass(jniEnv, name); +#endif +} + +static inline void load_class(jclass* cls, const char* name) { + if (*cls == NULL) { + __load_class_into(cls, name); + } +} + +static inline void load_class_gr(jclass* cls, const char* name) { + if (*cls == NULL) { + jclass tmp; + __load_class_into(&tmp, name); + *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); + (*jniEnv)->DeleteLocalRef(jniEnv, tmp); + } +} + +static inline void attach_thread() { + if (jniEnv == NULL) { + (*jni.jvm)->AttachCurrentThread(jni.jvm, __ENVP_CAST & jniEnv, NULL); + } +} + +static inline void load_method(jclass cls, + jmethodID* res, + const char* name, + const char* sig) { + if (*res == NULL) { + *res = (*jniEnv)->GetMethodID(jniEnv, cls, name, sig); + } +} + +static inline void load_static_method(jclass cls, + jmethodID* res, + const char* name, + const char* sig) { + if (*res == NULL) { + *res = (*jniEnv)->GetStaticMethodID(jniEnv, cls, name, sig); + } +} + +static inline void load_field(jclass cls, + jfieldID* res, + const char* name, + const char* sig) { + if (*res == NULL) { + *res = (*jniEnv)->GetFieldID(jniEnv, cls, name, sig); + } +} + +static inline void load_static_field(jclass cls, + jfieldID* res, + const char* name, + const char* sig) { + if (*res == NULL) { + *res = (*jniEnv)->GetStaticFieldID(jniEnv, cls, name, sig); + } +} + +static inline jobject to_global_ref(jobject ref) { + jobject g = (*jniEnv)->NewGlobalRef(jniEnv, ref); + (*jniEnv)->DeleteLocalRef(jniEnv, ref); + return g; +} + +// These functions are useful for C+Dart bindings, and not required for pure dart bindings. + +FFI_PLUGIN_EXPORT JniContext GetJniContext(); +/// For use by jni_gen's generated code +/// don't use these. + +// these 2 fn ptr vars will be defined by generated code library +extern JniContext (*context_getter)(void); +extern JNIEnv* (*env_getter)(void); + +// this function will be exported by generated code library +// it will set above 2 variables. +FFI_PLUGIN_EXPORT void setJniGetters(struct JniContext (*cg)(void), + JNIEnv* (*eg)(void)); + +static inline void load_env() { + if (jniEnv == NULL) { + jni = context_getter(); + jniEnv = env_getter(); + } +} + +static inline jthrowable check_exception() { + jthrowable exception = (*jniEnv)->ExceptionOccurred(jniEnv); + if (exception != NULL) (*jniEnv)->ExceptionClear(jniEnv); + if (exception == NULL) return NULL; + return to_global_ref(exception); +} + +FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); + +JNIEXPORT void JNICALL +Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env, + jobject thiz, + jlong port, + jobject result); +FFI_PLUGIN_EXPORT +JniResult PortContinuation__ctor(int64_t j); diff --git a/pkgs/jnigen/test/kotlin_test/src/kotlin.c b/pkgs/jnigen/test/kotlin_test/src/kotlin.c new file mode 100644 index 000000000..7b1426c26 --- /dev/null +++ b/pkgs/jnigen/test/kotlin_test/src/kotlin.c @@ -0,0 +1,76 @@ +// 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. + +// Autogenerated by jnigen. DO NOT EDIT! + +#include +#include "dartjni.h" +#include "jni.h" + +thread_local JNIEnv* jniEnv; +JniContext jni; + +JniContext (*context_getter)(void); +JNIEnv* (*env_getter)(void); + +void setJniGetters(JniContext (*cg)(void), JNIEnv* (*eg)(void)) { + context_getter = cg; + env_getter = eg; +} + +// com.github.dart_lang.jnigen.SuspendFun +jclass _c_SuspendFun = NULL; + +jmethodID _m_SuspendFun__ctor = NULL; +FFI_PLUGIN_EXPORT +JniResult SuspendFun__ctor() { + load_env(); + load_class_gr(&_c_SuspendFun, "com/github/dart_lang/jnigen/SuspendFun"); + if (_c_SuspendFun == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_SuspendFun, &_m_SuspendFun__ctor, "", "()V"); + if (_m_SuspendFun__ctor == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->NewObject(jniEnv, _c_SuspendFun, _m_SuspendFun__ctor); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID _m_SuspendFun__sayHello = NULL; +FFI_PLUGIN_EXPORT +JniResult SuspendFun__sayHello(jobject self_, jobject continuation) { + load_env(); + load_class_gr(&_c_SuspendFun, "com/github/dart_lang/jnigen/SuspendFun"); + if (_c_SuspendFun == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_SuspendFun, &_m_SuspendFun__sayHello, "sayHello", + "(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;"); + if (_m_SuspendFun__sayHello == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_SuspendFun__sayHello, continuation); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID _m_SuspendFun__sayHello1 = NULL; +FFI_PLUGIN_EXPORT +JniResult SuspendFun__sayHello1(jobject self_, + jobject string, + jobject continuation) { + load_env(); + load_class_gr(&_c_SuspendFun, "com/github/dart_lang/jnigen/SuspendFun"); + if (_c_SuspendFun == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method( + _c_SuspendFun, &_m_SuspendFun__sayHello1, "sayHello", + "(Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;"); + if (_m_SuspendFun__sayHello1 == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_SuspendFun__sayHello1, string, continuation); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} diff --git a/pkgs/jnigen/test/regenerate_examples_test.dart b/pkgs/jnigen/test/regenerate_examples_test.dart index 0f28fed8f..b49da06e0 100644 --- a/pkgs/jnigen/test/regenerate_examples_test.dart +++ b/pkgs/jnigen/test/regenerate_examples_test.dart @@ -16,6 +16,8 @@ final inAppJava = join('example', 'in_app_java'); final inAppJavaYaml = join(inAppJava, 'jnigen.yaml'); final notificationPlugin = join('example', 'notification_plugin'); final notificationPluginYaml = join(notificationPlugin, 'jnigen.yaml'); +final kotlinPlugin = join('example', 'kotlin_plugin'); +final kotlinPluginYaml = join(kotlinPlugin, 'jnigen.yaml'); /// Generates bindings using jnigen config in [exampleName] and compares /// them to provided reference outputs. @@ -54,4 +56,9 @@ void main() { join('lib', 'notifications.dart'), 'src', ); + testExample( + 'kotlin_plugin', + join('lib', 'kotlin_bindings.dart'), + 'src', + ); } diff --git a/pkgs/jnigen/test/simple_package_test/lib/simple_package.dart b/pkgs/jnigen/test/simple_package_test/lib/simple_package.dart index aa79dbe19..0f6841c48 100644 --- a/pkgs/jnigen/test/simple_package_test/lib/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/lib/simple_package.dart @@ -16,6 +16,7 @@ // ignore_for_file: unused_element // ignore_for_file: unused_import +import "dart:isolate" show ReceivePort; import "dart:ffi" as ffi; import "package:jni/internal_helpers_for_jnigen.dart"; import "package:jni/jni.dart" as jni; @@ -468,8 +469,8 @@ class GrandParent extends jni.JObject { /// from: public com.github.dart_lang.jnigen.generics.GrandParent.Parent stringParent() /// The returned object must be deleted after use, by calling the `delete` method. - GrandParent_Parent stringParent() => - $GrandParent_ParentType($T, jni.JStringType()) + GrandParent_Parent stringParent() => + $GrandParent_ParentType(const jni.JObjectType(), jni.JStringType()) .fromRef(_stringParent(reference).object); static final _varParent = jniLookup< @@ -482,9 +483,9 @@ class GrandParent extends jni.JObject { /// from: public com.github.dart_lang.jnigen.generics.GrandParent.Parent varParent(S nestedValue) /// The returned object must be deleted after use, by calling the `delete` method. - GrandParent_Parent varParent( + GrandParent_Parent varParent( jni.JObjType $S, S nestedValue) => - $GrandParent_ParentType($T, $S) + $GrandParent_ParentType(const jni.JObjectType(), $S) .fromRef(_varParent(reference, nestedValue.reference).object); static final _stringStaticParent = @@ -1126,9 +1127,9 @@ class MyMap extends jni.JObject { /// from: public com.github.dart_lang.jnigen.generics.MyStack.MyEntry> entryStack() /// The returned object must be deleted after use, by calling the `delete` method. - MyStack> entryStack() => - $MyStackType($MyMap_MyEntryType($K, $V)) - .fromRef(_entryStack(reference).object); + MyStack> entryStack() => $MyStackType( + $MyMap_MyEntryType(const jni.JObjectType(), const jni.JObjectType())) + .fromRef(_entryStack(reference).object); } class $MyMapType diff --git a/pkgs/jnigen/test/simple_package_test/src/dartjni.h b/pkgs/jnigen/test/simple_package_test/src/dartjni.h index 12e38b972..39b70bd8f 100644 --- a/pkgs/jnigen/test/simple_package_test/src/dartjni.h +++ b/pkgs/jnigen/test/simple_package_test/src/dartjni.h @@ -260,3 +260,13 @@ static inline jthrowable check_exception() { if (exception == NULL) return NULL; return to_global_ref(exception); } + +FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); + +JNIEXPORT void JNICALL +Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env, + jobject thiz, + jlong port, + jobject result); +FFI_PLUGIN_EXPORT +JniResult PortContinuation__ctor(int64_t j); diff --git a/pkgs/jnigen/test/test_util/test_util.dart b/pkgs/jnigen/test/test_util/test_util.dart index df6b1b9e8..51696847b 100644 --- a/pkgs/jnigen/test/test_util/test_util.dart +++ b/pkgs/jnigen/test/test_util/test_util.dart @@ -18,9 +18,9 @@ Future isEmptyOrNotExistDir(String path) async { /// Runs command, and prints output only if the exit status is non-zero. Future runCommand(String exec, List args, - {String? workingDirectory}) async { - final proc = - await Process.run(exec, args, workingDirectory: workingDirectory); + {String? workingDirectory, bool runInShell = false}) async { + final proc = await Process.run(exec, args, + workingDirectory: workingDirectory, runInShell: runInShell); if (proc.exitCode != 0) { printError('command exited with exit status ${proc.exitCode}:\n' '$exec ${args.join(" ")}\n'); diff --git a/pkgs/jnigen/tool/regenerate_all_bindings.dart b/pkgs/jnigen/tool/regenerate_all_bindings.dart index b99fb019f..19b764287 100644 --- a/pkgs/jnigen/tool/regenerate_all_bindings.dart +++ b/pkgs/jnigen/tool/regenerate_all_bindings.dart @@ -13,12 +13,14 @@ import 'command_runner.dart'; const scripts = [ "test/jackson_core_test/generate.dart", "test/simple_package_test/generate.dart", + "test/kotlin_test/generate.dart", ]; const yamlBasedExamples = [ "example/in_app_java", "example/pdfbox_plugin", "example/notification_plugin", + "example/kotlin_plugin", ]; void main() async { From 2267ff48025ff5bca76ac98df6366c7824890046 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Thu, 16 Feb 2023 10:57:56 +0100 Subject: [PATCH 055/139] [jnigen] 0.3.0 (https://github.com/dart-lang/jnigen/issues/189) --- pkgs/jni/CHANGELOG.md | 4 ++++ pkgs/jnigen/CHANGELOG.md | 3 +++ 2 files changed, 7 insertions(+) diff --git a/pkgs/jni/CHANGELOG.md b/pkgs/jni/CHANGELOG.md index 8021bb147..bb1c61c95 100644 --- a/pkgs/jni/CHANGELOG.md +++ b/pkgs/jni/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.3.0 +* Added `PortContinuation` used for `suspend fun` in Kotlin. +* `dartjni` now depends on `dart_api_dl.h`. + ## 0.2.1 * Added `.clang-format` to pub. diff --git a/pkgs/jnigen/CHANGELOG.md b/pkgs/jnigen/CHANGELOG.md index 107c11af0..d47aa13d3 100644 --- a/pkgs/jnigen/CHANGELOG.md +++ b/pkgs/jnigen/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.3.0 +* Added the option to convert Kotlin `suspend fun` to Dart async methods. Add `suspend_fun_to_async: true` to `jnigen.yaml`. + ## 0.2.0 * Support generating bindings for generics. From ce9e59e75e712008581843e636c07f79bd5b3785 Mon Sep 17 00:00:00 2001 From: Daco Harkes Date: Thu, 16 Feb 2023 18:20:36 +0100 Subject: [PATCH 056/139] [jnigen] Bump SDK constraint to 4.0.0 (https://github.com/dart-lang/jnigen/issues/190) --- pkgs/jni/example/pubspec.yaml | 2 +- pkgs/jni/pubspec.yaml | 2 +- pkgs/jni/third_party/ffigen_patch_jni/pubspec.yaml | 2 +- pkgs/jnigen/example/in_app_java/pubspec.yaml | 2 +- pkgs/jnigen/example/kotlin_plugin/example/pubspec.yaml | 2 +- pkgs/jnigen/example/kotlin_plugin/pubspec.yaml | 2 +- pkgs/jnigen/example/notification_plugin/example/pubspec.yaml | 2 +- pkgs/jnigen/example/notification_plugin/pubspec.yaml | 2 +- pkgs/jnigen/example/pdfbox_plugin/dart_example/pubspec.yaml | 2 +- pkgs/jnigen/example/pdfbox_plugin/example/pubspec.yaml | 2 +- pkgs/jnigen/example/pdfbox_plugin/pubspec.yaml | 2 +- pkgs/jnigen/pubspec.yaml | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pkgs/jni/example/pubspec.yaml b/pkgs/jni/example/pubspec.yaml index 1ff0ae2de..70624e670 100644 --- a/pkgs/jni/example/pubspec.yaml +++ b/pkgs/jni/example/pubspec.yaml @@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: ">=2.17.5 <3.0.0" + sdk: ">=2.17.5 <4.0.0" # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions diff --git a/pkgs/jni/pubspec.yaml b/pkgs/jni/pubspec.yaml index 57df539bc..40aa26ce0 100644 --- a/pkgs/jni/pubspec.yaml +++ b/pkgs/jni/pubspec.yaml @@ -4,7 +4,7 @@ version: 0.3.0 repository: https://github.com/dart-lang/jnigen/tree/main/jni environment: - sdk: ">=2.17.1 <3.0.0" + sdk: ">=2.17.1 <4.0.0" flutter: ">=2.11.0" dependencies: diff --git a/pkgs/jni/third_party/ffigen_patch_jni/pubspec.yaml b/pkgs/jni/third_party/ffigen_patch_jni/pubspec.yaml index ffe24d0d0..237c0fda3 100644 --- a/pkgs/jni/third_party/ffigen_patch_jni/pubspec.yaml +++ b/pkgs/jni/third_party/ffigen_patch_jni/pubspec.yaml @@ -8,7 +8,7 @@ description: Generator for FFI bindings, using LibClang to parse C header files. repository: https://github.com/dart-lang/ffigen environment: - sdk: '>=2.17.0 <3.0.0' + sdk: '>=2.17.0 <4.0.0' dependencies: ffi: ^2.0.0 diff --git a/pkgs/jnigen/example/in_app_java/pubspec.yaml b/pkgs/jnigen/example/in_app_java/pubspec.yaml index f2dcc7de5..7ab467b88 100644 --- a/pkgs/jnigen/example/in_app_java/pubspec.yaml +++ b/pkgs/jnigen/example/in_app_java/pubspec.yaml @@ -8,7 +8,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: ">=2.17.6 <3.0.0" + sdk: ">=2.17.6 <4.0.0" dependencies: flutter: diff --git a/pkgs/jnigen/example/kotlin_plugin/example/pubspec.yaml b/pkgs/jnigen/example/kotlin_plugin/example/pubspec.yaml index 4292ba976..2da89b59f 100644 --- a/pkgs/jnigen/example/kotlin_plugin/example/pubspec.yaml +++ b/pkgs/jnigen/example/kotlin_plugin/example/pubspec.yaml @@ -6,7 +6,7 @@ publish_to: "none" version: 1.0.0+1 environment: - sdk: ">=2.19.0-444.3.beta <3.0.0" + sdk: ">=2.19.0-444.3.beta <4.0.0" dependencies: flutter: diff --git a/pkgs/jnigen/example/kotlin_plugin/pubspec.yaml b/pkgs/jnigen/example/kotlin_plugin/pubspec.yaml index f6b5916c9..e0546891a 100644 --- a/pkgs/jnigen/example/kotlin_plugin/pubspec.yaml +++ b/pkgs/jnigen/example/kotlin_plugin/pubspec.yaml @@ -8,7 +8,7 @@ version: 0.0.1 publish_to: none environment: - sdk: '>=2.19.0-444.3.beta <3.0.0' + sdk: '>=2.19.0-444.3.beta <4.0.0' flutter: ">=1.17.0" dependencies: diff --git a/pkgs/jnigen/example/notification_plugin/example/pubspec.yaml b/pkgs/jnigen/example/notification_plugin/example/pubspec.yaml index 127c7dcf9..cbcaed9d0 100644 --- a/pkgs/jnigen/example/notification_plugin/example/pubspec.yaml +++ b/pkgs/jnigen/example/notification_plugin/example/pubspec.yaml @@ -20,7 +20,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: '>=2.17.6 <3.0.0' + sdk: '>=2.17.6 <4.0.0' dependencies: flutter: diff --git a/pkgs/jnigen/example/notification_plugin/pubspec.yaml b/pkgs/jnigen/example/notification_plugin/pubspec.yaml index f059a55dc..f2a6e1b9b 100644 --- a/pkgs/jnigen/example/notification_plugin/pubspec.yaml +++ b/pkgs/jnigen/example/notification_plugin/pubspec.yaml @@ -5,7 +5,7 @@ publish_to: none homepage: https://github.com/dart-lang/jnigen environment: - sdk: '>=2.17.6 <3.0.0' + sdk: '>=2.17.6 <4.0.0' flutter: ">=2.11.0" dependencies: diff --git a/pkgs/jnigen/example/pdfbox_plugin/dart_example/pubspec.yaml b/pkgs/jnigen/example/pdfbox_plugin/dart_example/pubspec.yaml index 235ccbd4c..ed3755980 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/dart_example/pubspec.yaml +++ b/pkgs/jnigen/example/pdfbox_plugin/dart_example/pubspec.yaml @@ -5,7 +5,7 @@ publish_to: none # homepage: https://www.example.com environment: - sdk: '>=2.17.6 <3.0.0' + sdk: '>=2.17.6 <4.0.0' dependencies: path: ^1.8.0 diff --git a/pkgs/jnigen/example/pdfbox_plugin/example/pubspec.yaml b/pkgs/jnigen/example/pdfbox_plugin/example/pubspec.yaml index 67c80b715..6c962985b 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/example/pubspec.yaml +++ b/pkgs/jnigen/example/pdfbox_plugin/example/pubspec.yaml @@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: ">=2.17.6 <3.0.0" + sdk: ">=2.17.6 <4.0.0" # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions diff --git a/pkgs/jnigen/example/pdfbox_plugin/pubspec.yaml b/pkgs/jnigen/example/pdfbox_plugin/pubspec.yaml index 82c871511..f77b031ed 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/pubspec.yaml +++ b/pkgs/jnigen/example/pdfbox_plugin/pubspec.yaml @@ -6,7 +6,7 @@ publish_to: none homepage: https://github.com/dart-lang/jnigen environment: - sdk: ">=2.17.6 <3.0.0" + sdk: ">=2.17.6 <4.0.0" #flutter: ">=2.11.0" dependencies: diff --git a/pkgs/jnigen/pubspec.yaml b/pkgs/jnigen/pubspec.yaml index b491b181e..b944f6b5b 100644 --- a/pkgs/jnigen/pubspec.yaml +++ b/pkgs/jnigen/pubspec.yaml @@ -8,7 +8,7 @@ description: Experimental generator for FFI+JNI bindings. repository: https://github.com/dart-lang/jnigen/tree/main/jnigen environment: - sdk: '>=2.17.0 <3.0.0' + sdk: '>=2.17.0 <4.0.0' dependencies: json_annotation: ^4.8.0 From b54e1cbe8f61fca661fa11ea6f9f28baeab7f7d6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 2 Mar 2023 10:44:08 +0100 Subject: [PATCH 057/139] [jnigen] Bump actions/setup-java (https://github.com/dart-lang/jnigen/issues/191) Bumps [actions/setup-java](https://github.com/actions/setup-java) from 9b86bbe88a8152e5b9e6c15fd2e0efdd2994ffb6 to ea15b3b99cdc9ac45af1882d085e3f9297a75a8b. - [Release notes](https://github.com/actions/setup-java/releases) - [Commits](https://github.com/actions/setup-java/compare/9b86bbe88a8152e5b9e6c15fd2e0efdd2994ffb6...ea15b3b99cdc9ac45af1882d085e3f9297a75a8b) --- updated-dependencies: - dependency-name: actions/setup-java dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/test-package.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 8f860d7d8..47b9f6276 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -74,7 +74,7 @@ jobs: channel: ${{ matrix.sdk }} cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@9b86bbe88a8152e5b9e6c15fd2e0efdd2994ffb6 + - uses: actions/setup-java@ea15b3b99cdc9ac45af1882d085e3f9297a75a8b with: distribution: 'zulu' java-version: '11' @@ -115,7 +115,7 @@ jobs: working-directory: ./pkgs/jnigen/java steps: - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c - - uses: actions/setup-java@9b86bbe88a8152e5b9e6c15fd2e0efdd2994ffb6 + - uses: actions/setup-java@ea15b3b99cdc9ac45af1882d085e3f9297a75a8b with: distribution: 'zulu' java-version: '11' @@ -134,7 +134,7 @@ jobs: channel: 'stable' cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@9b86bbe88a8152e5b9e6c15fd2e0efdd2994ffb6 + - uses: actions/setup-java@ea15b3b99cdc9ac45af1882d085e3f9297a75a8b with: distribution: 'zulu' java-version: '11' @@ -169,7 +169,7 @@ jobs: channel: 'stable' cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@9b86bbe88a8152e5b9e6c15fd2e0efdd2994ffb6 + - uses: actions/setup-java@ea15b3b99cdc9ac45af1882d085e3f9297a75a8b with: distribution: 'zulu' java-version: '11' @@ -214,7 +214,7 @@ jobs: channel: 'stable' cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@9b86bbe88a8152e5b9e6c15fd2e0efdd2994ffb6 + - uses: actions/setup-java@ea15b3b99cdc9ac45af1882d085e3f9297a75a8b with: distribution: 'zulu' java-version: '11' @@ -243,7 +243,7 @@ jobs: channel: 'stable' cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@9b86bbe88a8152e5b9e6c15fd2e0efdd2994ffb6 + - uses: actions/setup-java@ea15b3b99cdc9ac45af1882d085e3f9297a75a8b with: distribution: 'zulu' java-version: '11' @@ -272,7 +272,7 @@ jobs: channel: 'stable' cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@9b86bbe88a8152e5b9e6c15fd2e0efdd2994ffb6 + - uses: actions/setup-java@ea15b3b99cdc9ac45af1882d085e3f9297a75a8b with: distribution: 'temurin' java-version: '11' @@ -299,7 +299,7 @@ jobs: channel: 'stable' cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@9b86bbe88a8152e5b9e6c15fd2e0efdd2994ffb6 + - uses: actions/setup-java@ea15b3b99cdc9ac45af1882d085e3f9297a75a8b with: distribution: 'temurin' java-version: '11' @@ -320,7 +320,7 @@ jobs: channel: 'stable' cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@9b86bbe88a8152e5b9e6c15fd2e0efdd2994ffb6 + - uses: actions/setup-java@ea15b3b99cdc9ac45af1882d085e3f9297a75a8b with: distribution: 'zulu' java-version: '11' @@ -344,7 +344,7 @@ jobs: channel: 'stable' cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@9b86bbe88a8152e5b9e6c15fd2e0efdd2994ffb6 + - uses: actions/setup-java@ea15b3b99cdc9ac45af1882d085e3f9297a75a8b with: distribution: 'zulu' java-version: '11' @@ -359,7 +359,7 @@ jobs: working-directory: ./pkgs/jni/example steps: - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c - - uses: actions/setup-java@9b86bbe88a8152e5b9e6c15fd2e0efdd2994ffb6 + - uses: actions/setup-java@ea15b3b99cdc9ac45af1882d085e3f9297a75a8b with: distribution: 'zulu' java-version: '11' @@ -383,7 +383,7 @@ jobs: channel: 'stable' cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@9b86bbe88a8152e5b9e6c15fd2e0efdd2994ffb6 + - uses: actions/setup-java@ea15b3b99cdc9ac45af1882d085e3f9297a75a8b with: distribution: 'zulu' java-version: '11' From 64fec925f93a053beaf3ae69cbedfa79bfb2fbef Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 2 Mar 2023 10:44:37 +0100 Subject: [PATCH 058/139] [jnigen] Bump coverallsapp/github-action from 1.1.3 to 1.2.4 (https://github.com/dart-lang/jnigen/issues/192) Bumps [coverallsapp/github-action](https://github.com/coverallsapp/github-action) from 1.1.3 to 1.2.4. - [Release notes](https://github.com/coverallsapp/github-action/releases) - [Commits](https://github.com/coverallsapp/github-action/compare/9ba913c152ae4be1327bfb9085dc806cedb44057...50c33ad324a9902697adbf2f92c22cf5023eacf1) --- updated-dependencies: - dependency-name: coverallsapp/github-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/test-package.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 47b9f6276..96871c087 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -100,7 +100,7 @@ jobs: - name: Collect coverage run: dart pub global run coverage:test_with_coverage - name: Upload coverage - uses: coverallsapp/github-action@9ba913c152ae4be1327bfb9085dc806cedb44057 + uses: coverallsapp/github-action@50c33ad324a9902697adbf2f92c22cf5023eacf1 with: github-token: ${{ secrets.GITHUB_TOKEN }} flag-name: jnigen_tests @@ -187,7 +187,7 @@ jobs: - name: Collect coverage run: dart pub global run coverage:test_with_coverage - name: Upload coverage - uses: coverallsapp/github-action@9ba913c152ae4be1327bfb9085dc806cedb44057 + uses: coverallsapp/github-action@50c33ad324a9902697adbf2f92c22cf5023eacf1 with: github-token: ${{ secrets.GITHUB_TOKEN }} flag-name: jni_tests @@ -423,7 +423,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Coveralls finished - uses: coverallsapp/github-action@9ba913c152ae4be1327bfb9085dc806cedb44057 + uses: coverallsapp/github-action@50c33ad324a9902697adbf2f92c22cf5023eacf1 with: github-token: ${{ secrets.github_token }} parallel-finished: true From 15668264a51828689717b35530ae7e9512297665 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Thu, 16 Mar 2023 15:15:32 +0100 Subject: [PATCH 059/139] [jnigen] Refactor into Visitor pattern (https://github.com/dart-lang/jnigen/issues/200) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introducing a top-level `Classes` class which includes all the classes we're trying to generate as yet another element, makes each step of the code generation pipeline, feel the same. For example exclusion of classes and methods are now both done via actually removing the objects instead of setting an `isIncluded` flag. This `Classes` object will go through a pipeline of: 1. `Excluder` – excludes the unwanted classes, the private ones and the ones specified by the user. 2. `Linker` – links up the objects together to create a graph. 3. `Renamer` – renames the classes, methods, fields, ... not to clash with other reserved names. 4. `DartGenerator` – generates and writes to files. --- pkgs/jnigen/analysis_options.yaml | 2 + .../in_app_java/lib/android_utils.dart | 16 +- .../kotlin_plugin/lib/kotlin_bindings.dart | 8 +- .../lib/notifications.dart | 4 +- .../org/apache/pdfbox/pdmodel/PDDocument.dart | 10 +- .../pdfbox/pdmodel/PDDocumentInformation.dart | 7 +- .../apache/pdfbox/text/PDFTextStripper.dart | 39 +- pkgs/jnigen/lib/src/bindings/bindings.dart | 9 - pkgs/jnigen/lib/src/bindings/c_bindings.dart | 85 +- pkgs/jnigen/lib/src/bindings/c_generator.dart | 94 ++ pkgs/jnigen/lib/src/bindings/common.dart | 801 ------------ .../lib/src/bindings/dart_bindings.dart | 273 ---- .../lib/src/bindings/dart_generator.dart | 1115 +++++++++++++++++ pkgs/jnigen/lib/src/bindings/excluder.dart | 61 + pkgs/jnigen/lib/src/bindings/linker.dart | 175 +++ .../jnigen/lib/src/bindings/preprocessor.dart | 166 --- .../lib/src/bindings/pure_dart_bindings.dart | 286 ----- pkgs/jnigen/lib/src/bindings/renamer.dart | 262 ++++ pkgs/jnigen/lib/src/bindings/resolver.dart | 155 +++ .../lib/src/bindings/symbol_resolver.dart | 17 - pkgs/jnigen/lib/src/bindings/visitor.dart | 40 + pkgs/jnigen/lib/src/config/config_types.dart | 9 +- pkgs/jnigen/lib/src/config/filters.dart | 2 +- pkgs/jnigen/lib/src/elements/elements.dart | 528 +++++--- pkgs/jnigen/lib/src/elements/elements.g.dart | 9 +- pkgs/jnigen/lib/src/generate_bindings.dart | 32 +- pkgs/jnigen/lib/src/summary/summary.dart | 3 +- .../lib/src/tools/android_sdk_tools.dart | 3 +- .../lib/src/tools/build_summarizer.dart | 4 +- pkgs/jnigen/lib/src/tools/maven_tools.dart | 3 +- pkgs/jnigen/lib/src/util/command_output.dart | 8 - pkgs/jnigen/lib/src/util/name_utils.dart | 12 - pkgs/jnigen/lib/src/util/rename_conflict.dart | 87 -- .../lib/src/writers/bindings_writer.dart | 13 +- pkgs/jnigen/lib/src/writers/files_writer.dart | 305 ----- .../lib/src/writers/single_file_writer.dart | 97 -- pkgs/jnigen/lib/src/writers/writers.dart | 3 - .../generated_files_test.dart | 8 +- .../third_party/lib/_init.dart | 2 + .../fasterxml/jackson/core/JsonFactory.dart | 311 ++--- .../fasterxml/jackson/core/JsonParser.dart | 299 ++--- .../com/fasterxml/jackson/core/JsonToken.dart | 38 +- pkgs/jnigen/test/kotlin_test/lib/kotlin.dart | 12 +- pkgs/jnigen/test/package_resolver_test.dart | 27 +- .../jnigen/test/regenerate_examples_test.dart | 2 +- .../lib/simple_package.dart | 181 +-- pkgs/jnigen/test/yaml_config_test.dart | 2 +- 47 files changed, 2874 insertions(+), 2751 deletions(-) delete mode 100644 pkgs/jnigen/lib/src/bindings/bindings.dart create mode 100644 pkgs/jnigen/lib/src/bindings/c_generator.dart delete mode 100644 pkgs/jnigen/lib/src/bindings/common.dart delete mode 100644 pkgs/jnigen/lib/src/bindings/dart_bindings.dart create mode 100644 pkgs/jnigen/lib/src/bindings/dart_generator.dart create mode 100644 pkgs/jnigen/lib/src/bindings/excluder.dart create mode 100644 pkgs/jnigen/lib/src/bindings/linker.dart delete mode 100644 pkgs/jnigen/lib/src/bindings/preprocessor.dart delete mode 100644 pkgs/jnigen/lib/src/bindings/pure_dart_bindings.dart create mode 100644 pkgs/jnigen/lib/src/bindings/renamer.dart create mode 100644 pkgs/jnigen/lib/src/bindings/resolver.dart delete mode 100644 pkgs/jnigen/lib/src/bindings/symbol_resolver.dart create mode 100644 pkgs/jnigen/lib/src/bindings/visitor.dart delete mode 100644 pkgs/jnigen/lib/src/util/command_output.dart delete mode 100644 pkgs/jnigen/lib/src/util/name_utils.dart delete mode 100644 pkgs/jnigen/lib/src/util/rename_conflict.dart delete mode 100644 pkgs/jnigen/lib/src/writers/files_writer.dart delete mode 100644 pkgs/jnigen/lib/src/writers/single_file_writer.dart delete mode 100644 pkgs/jnigen/lib/src/writers/writers.dart diff --git a/pkgs/jnigen/analysis_options.yaml b/pkgs/jnigen/analysis_options.yaml index 00d47a9a2..063baccc7 100644 --- a/pkgs/jnigen/analysis_options.yaml +++ b/pkgs/jnigen/analysis_options.yaml @@ -15,4 +15,6 @@ linter: - prefer_final_locals - prefer_const_declarations - unawaited_futures + - prefer_const_constructors + - prefer_relative_imports diff --git a/pkgs/jnigen/example/in_app_java/lib/android_utils.dart b/pkgs/jnigen/example/in_app_java/lib/android_utils.dart index 082b10514..75abb32a0 100644 --- a/pkgs/jnigen/example/in_app_java/lib/android_utils.dart +++ b/pkgs/jnigen/example/in_app_java/lib/android_utils.dart @@ -10,7 +10,9 @@ // ignore_for_file: overridden_fields // ignore_for_file: unnecessary_cast // ignore_for_file: unused_element +// ignore_for_file: unused_field // ignore_for_file: unused_import +// ignore_for_file: unused_shown_name import "dart:isolate" show ReceivePort; import "dart:ffi" as ffi; @@ -34,7 +36,6 @@ class AndroidUtils extends jni.JObject { /// The type which includes information such as the signature of this class. static const type = $AndroidUtilsType(); - static final _showToast = jniLookup< ffi.NativeFunction< jni.JniResult Function(ffi.Pointer, @@ -82,7 +83,6 @@ class Build extends jni.JObject { /// The type which includes information such as the signature of this class. static const type = $BuildType(); - static final _get_BOARD = jniLookup>( "get_Build__BOARD") @@ -339,7 +339,7 @@ class Build extends jni.JObject { const jni.JStringType().fromRef(_get_TYPE().object); /// from: static public final java.lang.String UNKNOWN - static const UNKNOWN = "unknown"; + static const UNKNOWN = r"""unknown"""; static final _get_USER = jniLookup>("get_Build__USER") @@ -355,6 +355,7 @@ class Build extends jni.JObject { .asFunction(); /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. Build() : super.fromRef(_ctor().object); static final _getSerial = @@ -414,10 +415,7 @@ class HashMap extends jni.JObject { late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type( - $K, - $V, - ); + jni.JObjType get $type => _$type ??= type($K, $V); final jni.JObjType $K; final jni.JObjType $V; @@ -445,6 +443,7 @@ class HashMap .asFunction(); /// from: public void (int i, float f) + /// The returned object must be deleted after use, by calling the `delete` method. HashMap(this.$K, this.$V, int i, double f) : super.fromRef(_ctor(i, f).object); @@ -454,6 +453,7 @@ class HashMap .asFunction(); /// from: public void (int i) + /// The returned object must be deleted after use, by calling the `delete` method. HashMap.ctor1(this.$K, this.$V, int i) : super.fromRef(_ctor1(i).object); static final _ctor2 = @@ -461,6 +461,7 @@ class HashMap .asFunction(); /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. HashMap.ctor2(this.$K, this.$V) : super.fromRef(_ctor2().object); static final _ctor3 = jniLookup< @@ -469,6 +470,7 @@ class HashMap .asFunction)>(); /// from: public void (java.util.Map map) + /// The returned object must be deleted after use, by calling the `delete` method. HashMap.ctor3(this.$K, this.$V, jni.JObject map) : super.fromRef(_ctor3(map.reference).object); diff --git a/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart b/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart index e5c8331a6..f508dacda 100644 --- a/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart +++ b/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart @@ -10,7 +10,9 @@ // ignore_for_file: overridden_fields // ignore_for_file: unnecessary_cast // ignore_for_file: unused_element +// ignore_for_file: unused_field // ignore_for_file: unused_import +// ignore_for_file: unused_shown_name import "dart:isolate" show ReceivePort; import "dart:ffi" as ffi; @@ -34,12 +36,12 @@ class Example extends jni.JObject { /// The type which includes information such as the signature of this class. static const type = $ExampleType(); - static final _ctor = jniLookup>("Example__ctor") .asFunction(); /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. Example() : super.fromRef(_ctor().object); static final _thinkBeforeAnswering = jniLookup< @@ -54,8 +56,8 @@ class Example extends jni.JObject { /// The returned object must be deleted after use, by calling the `delete` method. Future thinkBeforeAnswering() async { final $p = ReceivePort(); - final $c = jni.Jni.newPortContinuation($p); - _thinkBeforeAnswering(reference, $c).object; + final $c = jni.JObject.fromRef(jni.Jni.newPortContinuation($p)); + _thinkBeforeAnswering(reference, $c.reference).object; final $o = jni.JObjectPtr.fromAddress(await $p.first); final $k = const jni.JStringType().getClass().reference; if (jni.Jni.env.IsInstanceOf($o, $k) == 0) { diff --git a/pkgs/jnigen/example/notification_plugin/lib/notifications.dart b/pkgs/jnigen/example/notification_plugin/lib/notifications.dart index 853f2a997..028904a1f 100644 --- a/pkgs/jnigen/example/notification_plugin/lib/notifications.dart +++ b/pkgs/jnigen/example/notification_plugin/lib/notifications.dart @@ -14,7 +14,9 @@ // ignore_for_file: overridden_fields // ignore_for_file: unnecessary_cast // ignore_for_file: unused_element +// ignore_for_file: unused_field // ignore_for_file: unused_import +// ignore_for_file: unused_shown_name import "dart:isolate" show ReceivePort; import "dart:ffi" as ffi; @@ -38,12 +40,12 @@ class Notifications extends jni.JObject { /// The type which includes information such as the signature of this class. static const type = $NotificationsType(); - static final _ctor = jniLookup>( "Notifications__ctor") .asFunction(); /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. Notifications() : super.fromRef(_ctor().object); static final _showNotification = jniLookup< 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 3ff6a5366..15e060e0e 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 @@ -28,7 +28,9 @@ // ignore_for_file: overridden_fields // ignore_for_file: unnecessary_cast // ignore_for_file: unused_element +// ignore_for_file: unused_field // ignore_for_file: unused_import +// ignore_for_file: unused_shown_name import "dart:isolate" show ReceivePort; import "dart:ffi" as ffi; @@ -36,7 +38,7 @@ import "package:jni/internal_helpers_for_jnigen.dart"; import "package:jni/jni.dart" as jni; import "PDDocumentInformation.dart" as pddocumentinformation_; -import "../../../../_init.dart" show jniLookup; +import "../../../../_init.dart"; /// from: org.apache.pdfbox.pdmodel.PDDocument /// @@ -54,12 +56,12 @@ class PDDocument extends jni.JObject { /// The type which includes information such as the signature of this class. static const type = $PDDocumentType(); - static final _ctor = jniLookup>( "PDDocument__ctor") .asFunction(); /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. /// /// Creates an empty PDF document. /// You need to add at least one page for the document to be valid. @@ -72,6 +74,7 @@ class PDDocument extends jni.JObject { .asFunction)>(); /// from: public void (org.apache.pdfbox.io.MemoryUsageSetting memUsageSetting) + /// The returned object must be deleted after use, by calling the `delete` method. /// /// Creates an empty PDF document. /// You need to add at least one page for the document to be valid. @@ -86,6 +89,7 @@ class PDDocument extends jni.JObject { .asFunction)>(); /// from: public void (org.apache.pdfbox.cos.COSDocument doc) + /// The returned object must be deleted after use, by calling the `delete` method. /// /// Constructor that uses an existing document. The COSDocument that is passed in must be valid. ///@param doc The COSDocument that this document wraps. @@ -101,6 +105,7 @@ class PDDocument extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public void (org.apache.pdfbox.cos.COSDocument doc, org.apache.pdfbox.io.RandomAccessRead source) + /// The returned object must be deleted after use, by calling the `delete` method. /// /// Constructor that uses an existing document. The COSDocument that is passed in must be valid. ///@param doc The COSDocument that this document wraps. @@ -119,6 +124,7 @@ class PDDocument extends jni.JObject { ffi.Pointer)>(); /// from: public void (org.apache.pdfbox.cos.COSDocument doc, org.apache.pdfbox.io.RandomAccessRead source, org.apache.pdfbox.pdmodel.encryption.AccessPermission permission) + /// The returned object must be deleted after use, by calling the `delete` method. /// /// Constructor that uses an existing document. The COSDocument that is passed in must be valid. ///@param doc The COSDocument that this document wraps. 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 0ea6ad6b6..30e40767b 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 @@ -28,14 +28,16 @@ // ignore_for_file: overridden_fields // ignore_for_file: unnecessary_cast // ignore_for_file: unused_element +// ignore_for_file: unused_field // ignore_for_file: unused_import +// ignore_for_file: unused_shown_name import "dart:isolate" show ReceivePort; import "dart:ffi" as ffi; import "package:jni/internal_helpers_for_jnigen.dart"; import "package:jni/jni.dart" as jni; -import "../../../../_init.dart" show jniLookup; +import "../../../../_init.dart"; /// from: org.apache.pdfbox.pdmodel.PDDocumentInformation /// @@ -55,12 +57,12 @@ class PDDocumentInformation extends jni.JObject { /// The type which includes information such as the signature of this class. static const type = $PDDocumentInformationType(); - static final _ctor = jniLookup>( "PDDocumentInformation__ctor") .asFunction(); /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. /// /// Default Constructor. PDDocumentInformation() : super.fromRef(_ctor().object); @@ -72,6 +74,7 @@ class PDDocumentInformation extends jni.JObject { .asFunction)>(); /// from: public void (org.apache.pdfbox.cos.COSDictionary dic) + /// The returned object must be deleted after use, by calling the `delete` method. /// /// Constructor that is used for a preexisting dictionary. ///@param dic The underlying dictionary. 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 2094a0b41..aff6055f9 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 @@ -28,7 +28,9 @@ // ignore_for_file: overridden_fields // ignore_for_file: unnecessary_cast // ignore_for_file: unused_element +// ignore_for_file: unused_field // ignore_for_file: unused_import +// ignore_for_file: unused_shown_name import "dart:isolate" show ReceivePort; import "dart:ffi" as ffi; @@ -36,7 +38,7 @@ import "package:jni/internal_helpers_for_jnigen.dart"; import "package:jni/jni.dart" as jni; import "../pdmodel/PDDocument.dart" as pddocument_; -import "../../../../_init.dart" show jniLookup; +import "../../../../_init.dart"; /// from: org.apache.pdfbox.text.PDFTextStripper /// @@ -58,7 +60,6 @@ class PDFTextStripper extends jni.JObject { /// The type which includes information such as the signature of this class. static const type = $PDFTextStripperType(); - static final _get_LINE_SEPARATOR = jniLookup< ffi.NativeFunction< jni.JniResult Function( @@ -86,6 +87,14 @@ class PDFTextStripper extends jni.JObject { jni.JObjectPtr, )>(); + static final _set_charactersByArticle = jniLookup< + ffi.NativeFunction< + jni.JThrowablePtr Function( + jni.JObjectPtr, ffi.Pointer)>>( + "set_PDFTextStripper__charactersByArticle") + .asFunction< + jni.JThrowablePtr Function(jni.JObjectPtr, ffi.Pointer)>(); + /// from: protected java.util.ArrayList> charactersByArticle /// The returned object must be deleted after use, by calling the `delete` method. /// @@ -103,13 +112,6 @@ class PDFTextStripper extends jni.JObject { /// Most PDFs won't have any beads, so charactersByArticle will contain a single entry. jni.JObject get charactersByArticle => const jni.JObjectType() .fromRef(_get_charactersByArticle(reference).object); - static final _set_charactersByArticle = jniLookup< - ffi.NativeFunction< - jni.JThrowablePtr Function( - jni.JObjectPtr, ffi.Pointer)>>( - "set_PDFTextStripper__charactersByArticle") - .asFunction< - jni.JThrowablePtr Function(jni.JObjectPtr, ffi.Pointer)>(); /// from: protected java.util.ArrayList> charactersByArticle /// The returned object must be deleted after use, by calling the `delete` method. @@ -139,10 +141,6 @@ class PDFTextStripper extends jni.JObject { jni.JObjectPtr, )>(); - /// from: protected org.apache.pdfbox.pdmodel.PDDocument document - /// The returned object must be deleted after use, by calling the `delete` method. - pddocument_.PDDocument get document => const pddocument_.$PDDocumentType() - .fromRef(_get_document(reference).object); static final _set_document = jniLookup< ffi.NativeFunction< jni.JThrowablePtr Function(jni.JObjectPtr, @@ -150,6 +148,11 @@ class PDFTextStripper extends jni.JObject { .asFunction< jni.JThrowablePtr Function(jni.JObjectPtr, ffi.Pointer)>(); + /// from: protected org.apache.pdfbox.pdmodel.PDDocument document + /// The returned object must be deleted after use, by calling the `delete` method. + pddocument_.PDDocument get document => const pddocument_.$PDDocumentType() + .fromRef(_get_document(reference).object); + /// from: protected org.apache.pdfbox.pdmodel.PDDocument document /// The returned object must be deleted after use, by calling the `delete` method. set document(pddocument_.PDDocument value) => @@ -165,10 +168,6 @@ class PDFTextStripper extends jni.JObject { jni.JObjectPtr, )>(); - /// from: protected java.io.Writer output - /// The returned object must be deleted after use, by calling the `delete` method. - jni.JObject get output => - const jni.JObjectType().fromRef(_get_output(reference).object); static final _set_output = jniLookup< ffi.NativeFunction< jni.JThrowablePtr Function(jni.JObjectPtr, @@ -176,6 +175,11 @@ class PDFTextStripper extends jni.JObject { .asFunction< jni.JThrowablePtr Function(jni.JObjectPtr, ffi.Pointer)>(); + /// from: protected java.io.Writer output + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JObject get output => + const jni.JObjectType().fromRef(_get_output(reference).object); + /// from: protected java.io.Writer output /// The returned object must be deleted after use, by calling the `delete` method. set output(jni.JObject value) => _set_output(reference, value.reference); @@ -185,6 +189,7 @@ class PDFTextStripper extends jni.JObject { .asFunction(); /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. /// /// Instantiate a new PDFTextStripper object. ///@throws IOException If there is an error loading the properties. diff --git a/pkgs/jnigen/lib/src/bindings/bindings.dart b/pkgs/jnigen/lib/src/bindings/bindings.dart deleted file mode 100644 index 27bd35e1e..000000000 --- a/pkgs/jnigen/lib/src/bindings/bindings.dart +++ /dev/null @@ -1,9 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -export 'preprocessor.dart'; -export 'c_bindings.dart'; -export 'dart_bindings.dart'; -export 'pure_dart_bindings.dart'; -export 'symbol_resolver.dart'; diff --git a/pkgs/jnigen/lib/src/bindings/c_bindings.dart b/pkgs/jnigen/lib/src/bindings/c_bindings.dart index 488e3d8ed..f57e79c21 100644 --- a/pkgs/jnigen/lib/src/bindings/c_bindings.dart +++ b/pkgs/jnigen/lib/src/bindings/c_bindings.dart @@ -2,10 +2,9 @@ // 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/elements/elements.dart'; -import 'package:jnigen/src/config/config.dart'; - -import 'common.dart'; +import '../config/config.dart'; +import '../elements/elements.dart'; +import 'c_generator.dart'; class CBindingGenerator { static const classVarPrefix = '_c'; @@ -35,28 +34,19 @@ class CBindingGenerator { String generateBinding(ClassDecl c) => _class(c); String _class(ClassDecl c) { - if (!c.isIncluded) { - return ''; - } final s = StringBuffer(); - final classNameInC = getUniqueClassName(c); + final classNameInC = c.uniqueName; // global variable in C that holds the reference to class final classVar = '${classVarPrefix}_$classNameInC'; s.write('// ${c.binaryName}\n' 'jclass $classVar = NULL;\n\n'); for (var m in c.methods) { - if (!m.isIncluded) { - continue; - } s.write(_method(c, m)); s.writeln(); } for (var f in c.fields) { - if (!f.isIncluded) { - continue; - } final fieldBinding = _field(c, f); s.write(fieldBinding); // Fields are skipped if they're static final. In that case @@ -66,19 +56,42 @@ class CBindingGenerator { return s.toString(); } + String getCType(String binaryName) { + switch (binaryName) { + case "void": + return "void"; + case "byte": + return "int8_t"; + case "char": + return "char"; + case "double": + return "double"; + case "float": + return "float"; + case "int": + return "int32_t"; + case "long": + return "int64_t"; + case "short": + return "int16_t"; + case "boolean": + return "uint8_t"; + default: + return "jobject"; + } + } + String _method(ClassDecl c, Method m) { - final classNameInC = getUniqueClassName(c); - final isACtor = isCtor(m); - final isStatic = isStaticMethod(m); + final classNameInC = c.uniqueName; + final isACtor = m.isCtor; + final isStatic = m.isStatic; final s = StringBuffer(); - final name = m.finalName; - final functionName = getMemberNameInC(c, name); + final cMethodName = m.accept(const CMethodName()); final classRef = '${classVarPrefix}_$classNameInC'; - final methodID = '${methodVarPrefix}_$functionName'; - final cMethodName = getMemberNameInC(c, name); + final methodID = '${methodVarPrefix}_$cMethodName'; final cMethodParams = _formalArgs(m); - final jniSignature = getJniSignatureForMethod(m); + final jniSignature = m.accept(const MethodSignature()); final ifStaticMethodID = isStatic ? 'static_' : ''; var javaReturnType = m.returnType.name; @@ -102,7 +115,7 @@ jmethodID $methodID = NULL; FFI_PLUGIN_EXPORT $jniResultType $cMethodName($cMethodParams) { $_loadEnvCall - ${_loadClassCall(classRef, getInternalName(c.binaryName))} + ${_loadClassCall(classRef, c.internalName)} load_${ifStaticMethodID}method($classRef, &$methodID, "${m.name}", "$jniSignature"); if ($methodID == NULL) return $ifError; @@ -113,16 +126,16 @@ $jniResultType $cMethodName($cMethodParams) { } String _field(ClassDecl c, Field f) { - final cClassName = getUniqueClassName(c); - final isStatic = isStaticField(f); + final cClassName = c.uniqueName; + final isStatic = f.isStatic; final fieldName = f.finalName; - final fieldNameInC = getMemberNameInC(c, fieldName); + final fieldNameInC = f.accept(const CFieldName()); final fieldVar = "${fieldVarPrefix}_$fieldNameInC"; // If the field is final and default is assigned, then no need to wrap // this field. It should then be a constant in dart code. - if (isStatic && isFinalField(f) && f.defaultValue != null) { + if (isStatic && f.isFinal && f.defaultValue != null) { return ""; } @@ -152,7 +165,7 @@ $jniResultType $cMethodName($cMethodParams) { } else { var getterExpr = '(*jniEnv)->Get$ifStaticCall${callType}Field(jniEnv, ' '$objectArgument, $fieldVar)'; - if (!isPrimitive(f.type)) { + if (f.type.kind != Kind.primitive) { getterExpr = 'to_global_ref($getterExpr)'; } final cResultType = getCType(f.type.name); @@ -166,15 +179,15 @@ $jniResultType $cMethodName($cMethodParams) { FFI_PLUGIN_EXPORT $cReturnType ${cMethodPrefix}_$fieldNameInC($formalArgs) { $_loadEnvCall - ${_loadClassCall(classVar, getInternalName(c.binaryName))} + ${_loadClassCall(classVar, c.internalName)} load_${ifStaticField}field($classVar, &$fieldVar, "$fieldName", - "${getDescriptor(f.type)}"); + "${f.type.accept(const Descriptor())}"); $accessorStatements }\n\n'''); } writeAccessor(isSetter: false); - if (isFinalField(f)) { + if (f.isFinal) { return s.toString(); } writeAccessor(isSetter: true); @@ -190,7 +203,7 @@ $accessorStatements String _formalArgs(Method m) { final args = []; - if (hasSelfParam(m)) { + if (!m.isCtor && !m.isStatic) { // The underscore-suffixed name prevents accidental collision with // parameter named self, if any. args.add('jobject self_'); @@ -216,7 +229,7 @@ $accessorStatements 'double': 'd', 'void': 'j', // in case of void return, just write 0 to largest field. }; - if (isPrimitive(type)) { + if (type.kind == Kind.primitive) { return primitives[type.name]!; } return 'l'; @@ -225,7 +238,7 @@ $accessorStatements // Returns arguments at call site, concatenated by `,`. String _callArgs(Method m, String classVar, String methodVar) { final args = ['jniEnv']; - if (hasSelfParam(m)) { + if (!m.isCtor && !m.isStatic) { args.add('self_'); } else { args.add(classVar); @@ -242,7 +255,7 @@ $accessorStatements final cReturnType = getCType(m.returnType.name); String valuePart; String unionField; - if (cReturnType == 'jobject' || isCtor(m)) { + if (cReturnType == 'jobject' || m.isCtor) { unionField = 'l'; valuePart = 'to_global_ref(_result)'; } else if (cReturnType == 'void') { @@ -261,7 +274,7 @@ $accessorStatements /// Returns capitalized java type name to be used as in call${type}Method /// or get${type}Field etc.. String _typeNameAtCallSite(TypeUsage type) { - if (isPrimitive(type)) { + if (type.kind == Kind.primitive) { return type.name.substring(0, 1).toUpperCase() + type.name.substring(1); } return "Object"; diff --git a/pkgs/jnigen/lib/src/bindings/c_generator.dart b/pkgs/jnigen/lib/src/bindings/c_generator.dart new file mode 100644 index 000000000..97b2604d2 --- /dev/null +++ b/pkgs/jnigen/lib/src/bindings/c_generator.dart @@ -0,0 +1,94 @@ +// 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 '../elements/elements.dart'; +import 'visitor.dart'; + +/// JVM representation of type signatures. +/// +/// https://docs.oracle.com/en/java/javase/18/docs/specs/jni/types.html#type-signatures +class Descriptor extends TypeVisitor { + const Descriptor(); + + @override + String visitArrayType(ArrayType node) { + final inner = node.type.accept(this); + return '[$inner'; + } + + @override + String visitDeclaredType(DeclaredType node) { + final internalName = node.binaryName.replaceAll('.', '/'); + return 'L$internalName;'; + } + + @override + String visitPrimitiveType(PrimitiveType node) { + return node.signature; + } + + @override + String visitTypeVar(TypeVar node) { + // It should be possible to compute the erasure of a type + // in parser itself. + // TODO(#23): Use erasure of the type variable here. + // This is just a (wrong) placeholder + return super.visitTypeVar(node); + } + + @override + String visitWildcard(Wildcard node) { + final extendsBound = node.extendsBound?.accept(this); + return extendsBound ?? 'Ljava/lang/Object;'; + } + + @override + String visitNonPrimitiveType(ReferredType node) { + return "Ljava/lang/Object;"; + } +} + +/// Generates JNI Method signatures. +/// +/// https://docs.oracle.com/en/java/javase/18/docs/specs/jni/types.html#type-signatures +/// Also see: [Descriptor] +class MethodSignature extends Visitor { + const MethodSignature(); + + @override + String visit(Method node) { + final s = StringBuffer(); + s.write('('); + s.write(node.params + .map((param) => param.type) + .accept(const Descriptor()) + .join()); + s.write(')'); + final returnType = node.returnType.accept(const Descriptor()); + s.write(returnType); + return s.toString(); + } +} + +class CFieldName extends Visitor { + const CFieldName(); + + @override + String visit(Field node) { + final className = node.classDecl.uniqueName; + final fieldName = node.finalName; + return '${className}__$fieldName'; + } +} + +class CMethodName extends Visitor { + const CMethodName(); + + @override + String visit(Method node) { + final className = node.classDecl.uniqueName; + final methodName = node.finalName; + return '${className}__$methodName'; + } +} diff --git a/pkgs/jnigen/lib/src/bindings/common.dart b/pkgs/jnigen/lib/src/bindings/common.dart deleted file mode 100644 index 480a038bc..000000000 --- a/pkgs/jnigen/lib/src/bindings/common.dart +++ /dev/null @@ -1,801 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -import 'package:jnigen/src/elements/elements.dart'; -import 'package:jnigen/src/util/rename_conflict.dart'; - -import 'symbol_resolver.dart'; - -/// Base class of both C based and Dart-only binding generators. Implements -/// Many methods used commonly by both of them. -/// -/// These methods are in a superclass since they usually require access -/// to resolver, or for consistency with similar methods which require -/// the resolver. -abstract class BindingsGenerator { - // Name for reference in base class. - static const selfPointer = 'reference'; - static final indent = ' ' * 2; - - // import prefixes - static const ffi = 'ffi.'; - static const jni = 'jni.'; - - static const String voidPointer = '${ffi}Pointer<${ffi}Void>'; - - static const String ffiVoidType = '${ffi}Void'; - - static const String jobjectType = '${jni}JObjectPtr'; - - static const String jthrowableType = '${jni}JThrowablePtr'; - - static const String jniStringType = '${jni}JString'; - static const String jniStringTypeClass = '${jni}JString$typeClassSuffix'; - - static const String jniObjectType = '${jni}JObject'; - static const String jniObjectTypeClass = '${jni}JObject$typeClassSuffix'; - - static const String jniArrayType = '${jni}JArray'; - static const String jniArrayTypeClass = '${jni}JArray$typeClassSuffix'; - - static const String jniCallType = '${jni}JniCallType'; - - static const String jniTypeType = '${jni}JObjType'; - static const String typeClassSuffix = 'Type'; - // TODO(#143): this is a temporary fix for the name collision. - static const String typeClassPrefix = '\$'; - - static const String instanceTypeGetter = '\$type'; - - static const String typeParamPrefix = '\$'; - - static const String jniResultType = '${jni}JniResult'; - - /// Generate bindings string for given class declaration. - String generateBindings(ClassDecl decl, SymbolResolver resolver); - - /// Get common initialization code for bindings. - /// - /// if this method returns an empty String, no init file is created. - String getInitFileContents(); - - /// Get boilerplate to be pasted on a file before any imports. - /// - /// [initFilePath], if provided, shall point to the _init.dart file where - /// initialization code is stored. If this is null, the method should provide - /// standalone boilerplate which doesn't need an init file. - /// - /// This method should return an empty string if no such boilerplate is - /// required. - String getPreImportBoilerplate([String? initFilePath]); - - /// Get boilerplate to be pasted on a file before any imports. - /// - /// See [getPreImportBoilerplate] for an explanation of [initFilePath]. - /// - /// This method should return an empty String if no such boilerplate is - /// required. - String getPostImportBoilerplate([String? initFilePath]); - - /// Returns the formal parameters list of the generated function. - /// - /// This is the signature seen by the user. - String getFormalArgs(ClassDecl c, Method m, SymbolResolver resolver) { - final List args = []; - // Prepending the parameters with type parameters - if (isCtor(m)) { - for (final typeParam in c.allTypeParams) { - args.add('this.$typeParamPrefix${typeParam.name}'); - } - } - for (final typeParam in m.typeParams) { - args.add( - '$jniTypeType<${typeParam.name}> $typeParamPrefix${typeParam.name}'); - } - for (final param in m.params) { - args.add( - '${getDartOuterType(param.type, resolver)} ${kwRename(param.name)}'); - } - if (m.asyncReturnType != null) { - // Remove the continuation object in async methods. - args.removeLast(); - } - return args.join(', '); - } - - /// Actual arguments passed to native call. - String actualArgs(Method m, {bool addSelf = true}) { - final List args = [if (hasSelfParam(m) && addSelf) selfPointer]; - for (var param in m.params) { - final paramName = kwRename(param.name); - args.add(toNativeArg(paramName, param.type)); - } - if (m.asyncReturnType != null) { - // Change the continuation object in async methods. - args.last = '\$c'; - } - return args.join(', '); - } - - String _dartTypeClassName(String className) { - return '$typeClassPrefix$className$typeClassSuffix'; - } - - String dartTypeParams(List typeParams, - {required bool includeExtends}) { - if (typeParams.isEmpty) return ''; - // TODO(#144): resolve the actual type being extended, if any. - final ifExtendsIncluded = includeExtends ? ' extends $jniObjectType' : ''; - final args = - typeParams.map((e) => '${e.name}$ifExtendsIncluded').join(' ,'); - return '<$args>'; - } - - String dartClassDefinition(ClassDecl decl, SymbolResolver resolver) { - final name = decl.finalName; - var superName = jniObjectType; - if (decl.superclass != null) { - superName = _dartType(decl.superclass!, resolver: resolver); - } - final typeParamsWithExtend = - dartTypeParams(decl.allTypeParams, includeExtends: true); - final ifSomeArgs = - decl.allTypeParams.isNotEmpty ? '(${_typeParamArgs(decl)})' : ''; - return 'class $name$typeParamsWithExtend extends $superName {\n' - 'late final $jniTypeType? _$instanceTypeGetter;\n' - '@override\n' - '$jniTypeType get $instanceTypeGetter => ' - '_$instanceTypeGetter ??= type$ifSomeArgs;\n\n' - '${_typeParamDefs(decl)}\n' - '$indent$name.fromRef(\n' - '${_typeParamCtorArgs(decl)}' - '$jobjectType ref,' - '): super.fromRef(${dartSuperArgs(decl, resolver)}ref);\n\n'; - } - - String dartSigForField(Field f, - {bool isSetter = false, required bool isFfiSig}) { - final ref = f.modifiers.contains('static') ? '' : '$jobjectType, '; - final conv = isFfiSig ? getDartFfiType : getDartInnerType; - if (isSetter) { - return '$jthrowableType Function($ref${conv(f.type)})'; - } - return '$jniResultType Function($ref)'; - } - - String dartSuperArgs(ClassDecl decl, SymbolResolver resolver) { - if (decl.superclass == null || - resolver.resolve((decl.superclass!.type as DeclaredType).binaryName) == - null) { - return ''; - } - return (decl.superclass!.type as DeclaredType) - .params - .map((param) => '${getDartTypeClass(param, resolver)},') - .join(); - } - - String dartArrayExtension(ClassDecl decl) { - final name = decl.finalName; - final typeParamsWithExtend = - dartTypeParams(decl.allTypeParams, includeExtends: true); - final typeParams = - dartTypeParams(decl.allTypeParams, includeExtends: false); - final typeClassName = _dartTypeClassName(name); - return '\nextension \$${name}Array$typeParamsWithExtend on $jniArrayType<$name$typeParams> {\n' - '$indent$name$typeParams operator [](int index) {\n' - '${indent * 2}return (elementType as $typeClassName$typeParams)' - '.fromRef(elementAt(index, ${jni}JniCallType.objectType).object);\n' - '$indent}\n\n' - '${indent}void operator []=(int index, $name$typeParams value) {\n' - '${indent * 2}(this as $jniArrayType<$jniObjectType>)[index] = value;\n' - '$indent}\n' - '}\n'; - } - - String _typeParamDefs(ClassDecl decl) { - return decl.allTypeParams - .map((e) => - '${indent}final $jniTypeType<${e.name}> $typeParamPrefix${e.name};\n') - .join(); - } - - String _typeParamCtorArgs(ClassDecl decl) { - return decl.allTypeParams - .map((e) => '${indent * 2}this.$typeParamPrefix${e.name},\n') - .join(); - } - - String _typeParamArgs(ClassDecl decl) { - return decl.allTypeParams.map((e) => '$typeParamPrefix${e.name}, ').join(); - } - - String dartTypeClass(ClassDecl decl) { - final name = decl.finalName; - final signature = getSignature(decl.binaryName); - final typeClassName = _dartTypeClassName(name); - final typeParamsWithExtend = - dartTypeParams(decl.allTypeParams, includeExtends: true); - final typeParams = - dartTypeParams(decl.allTypeParams, includeExtends: false); - - return '\nclass $typeClassName$typeParamsWithExtend extends $jniTypeType<$name$typeParams> {\n' - '${_typeParamDefs(decl)}\n' - '${indent}const $typeClassName(\n' - '${_typeParamCtorArgs(decl)}' - '$indent);\n\n' - '$indent@override\n' - '${indent}String get signature => r"$signature";\n\n' - '$indent@override\n' - '$indent$name$typeParams fromRef($jobjectType ref) => $name.fromRef(${_typeParamArgs(decl)}ref);\n' - '}\n'; - } - - String dartInitType(ClassDecl decl) { - final typeClassName = _dartTypeClassName(decl.finalName); - final args = - decl.allTypeParams.map((e) => '$typeParamPrefix${e.name},').join(); - return '$instanceTypeGetter = $typeClassName($args)'; - } - - String dartStaticTypeGetter(ClassDecl decl) { - final typeClassName = _dartTypeClassName(decl.finalName); - const docs = - '/// The type which includes information such as the signature of this class.'; - if (decl.allTypeParams.isEmpty) { - return '$indent$docs\n' - '${indent}static const type = $typeClassName();\n\n'; - } - final typeParamsWithExtend = - dartTypeParams(decl.allTypeParams, includeExtends: true); - final typeParams = - dartTypeParams(decl.allTypeParams, includeExtends: false); - final methodArgs = decl.allTypeParams - .map((e) => - '${indent * 2}$jniTypeType<${e.name}> $typeParamPrefix${e.name},\n') - .join(); - final ctorArgs = decl.allTypeParams - .map((e) => '${indent * 3}$typeParamPrefix${e.name},\n') - .join(); - return '$indent$docs\n' - '${indent}static $typeClassName$typeParams type$typeParamsWithExtend(\n' - '$methodArgs' - '$indent) {\n' - '${indent * 2}return $typeClassName(\n' - '$ctorArgs' - '${indent * 2});\n' - '$indent}\n\n'; - } - - String dartSigForMethod(Method m, {required bool isFfiSig}) { - final conv = isFfiSig ? getDartFfiType : getDartInnerType; - final argTypes = [if (hasSelfParam(m)) voidPointer]; - for (var param in m.params) { - argTypes.add(conv(param.type)); - } - return '$jniResultType Function (${argTypes.join(", ")})'; - } - - String _dartType( - TypeUsage t, { - SymbolResolver? resolver, - }) { - // if resolver == null, looking for inner fn type, type of fn reference - // else looking for outer fn type, that's what user of the library sees. - const primitives = { - 'byte': 'int', - 'short': 'int', - 'char': 'int', - 'int': 'int', - 'long': 'int', - 'float': 'double', - 'double': 'double', - 'void': 'void', - 'boolean': 'bool', - }; - const jniTypes = { - 'byte': 'JByte', - 'short': 'JShort', - 'char': 'JChar', - 'int': 'JInt', - 'long': 'JLong', - 'float': 'JFloat', - 'double': 'JDouble', - 'boolean': 'JBoolean', - }; - switch (t.kind) { - case Kind.primitive: - if (t.name == 'boolean' && resolver == null) return 'int'; - return primitives[(t.type as PrimitiveType).name]!; - case Kind.typeVariable: - if (resolver != null) { - return t.name; - } - return voidPointer; - case Kind.wildcard: - throw SkipException('Wildcards are not yet supported'); - case Kind.array: - if (resolver != null) { - final innerType = (t.type as ArrayType).type; - final dartType = innerType.kind == Kind.primitive - ? jni + jniTypes[(innerType.type as PrimitiveType).name]! - : _dartType(innerType, resolver: resolver); - return '$jniArrayType<$dartType>'; - } - return voidPointer; - case Kind.declared: - if (resolver != null) { - final type = t.type as DeclaredType; - final resolved = resolver.resolve(type.binaryName); - final resolvedClass = resolver.resolveClass(type.binaryName); - if (resolved == null || - resolvedClass == null || - !resolvedClass.isIncluded) { - return jniObjectType; - } - - // All type parameters of this type - final allTypeParams = - resolvedClass.allTypeParams.map((param) => param.name).toList(); - - // The ones that are declared. - final paramTypeClasses = - type.params.map((param) => _dartType(param, resolver: resolver)); - - // Replacing the declared ones. They come at the end. - // The rest will be JObject. - if (allTypeParams.length >= type.params.length) { - allTypeParams.replaceRange( - 0, - allTypeParams.length - type.params.length, - List.filled( - allTypeParams.length - type.params.length, - jniObjectType, - ), - ); - allTypeParams.replaceRange( - allTypeParams.length - type.params.length, - allTypeParams.length, - paramTypeClasses, - ); - } - - final args = allTypeParams.join(','); - final ifArgs = args.isNotEmpty ? '<$args>' : ''; - return '$resolved$ifArgs'; - } - return voidPointer; - } - } - - String getDartTypeClass( - TypeUsage t, - SymbolResolver resolver, - ) { - return _getDartTypeClass(t, resolver, addConst: true).name; - } - - _TypeClass _getDartTypeClass( - TypeUsage t, - SymbolResolver resolver, { - required bool addConst, - }) { - const primitives = { - 'byte': 'JByteType', - 'short': 'JShortType', - 'char': 'JCharType', - 'int': 'JIntType', - 'long': 'JLongType', - 'float': 'JFloatType', - 'double': 'JDoubleType', - 'boolean': 'JBooleanType', - 'void': 'JVoidType', // This will never be in the generated code. - }; - switch (t.kind) { - case Kind.primitive: - final ifConst = addConst ? 'const ' : ''; - return _TypeClass( - '$ifConst$jni${primitives[(t.type as PrimitiveType).name]}()', - true, - ); - case Kind.typeVariable: - return _TypeClass( - '$typeParamPrefix${(t.type as TypeVar).name}', - false, - ); - case Kind.wildcard: - throw SkipException('Wildcards are not yet supported'); - case Kind.array: - final innerType = (t.type as ArrayType).type; - final innerTypeClass = _getDartTypeClass( - innerType, - resolver, - addConst: false, - ); - final ifConst = addConst && innerTypeClass.canBeConst ? 'const ' : ''; - return _TypeClass( - '$ifConst$jniArrayTypeClass(${innerTypeClass.name})', - innerTypeClass.canBeConst, - ); - case Kind.declared: - final type = (t.type as DeclaredType); - final resolved = resolver.resolve(type.binaryName); - final resolvedClass = resolver.resolveClass(type.binaryName); - - if (resolved == null || - resolvedClass == null || - !resolvedClass.isIncluded) { - return _TypeClass( - '${addConst ? 'const ' : ''}$jniObjectTypeClass()', - true, - ); - } - - // All type params of this type - final allTypeParams = resolvedClass.allTypeParams - .map((param) => '$typeParamPrefix${param.name}') - .toList(); - - // The ones that are declared. - final paramTypeClasses = type.params.map( - (param) => _getDartTypeClass(param, resolver, addConst: false)); - - // Replacing the declared ones. They come at the end. - // The rest will be JObject. - if (allTypeParams.length >= type.params.length) { - allTypeParams.replaceRange( - 0, - allTypeParams.length - type.params.length, - List.filled( - allTypeParams.length - type.params.length, - 'const $jniObjectTypeClass()', - ), - ); - allTypeParams.replaceRange( - allTypeParams.length - type.params.length, - allTypeParams.length, - paramTypeClasses.map((param) => param.name), - ); - } - - final args = allTypeParams.join(','); - - final canBeConst = (allTypeParams.length == paramTypeClasses.length && - paramTypeClasses.every((e) => e.canBeConst)) || - allTypeParams.isEmpty; - final ifConst = addConst && canBeConst ? 'const ' : ''; - - if (resolved == jniObjectType) { - return _TypeClass('$ifConst$jniObjectTypeClass()', true); - } else if (resolved == jniStringType) { - return _TypeClass('$ifConst$jniStringTypeClass()', true); - } else if (resolved.contains('.')) { - // It is in form of jni.SomeClass which should be converted to jni.$SomeClassType - final dotIndex = resolved.indexOf('.'); - final module = resolved.substring(0, dotIndex); - final clazz = resolved.substring(dotIndex + 1); - return _TypeClass( - '$ifConst$module.${_dartTypeClassName(clazz)}($args)', - canBeConst, - ); - } - return _TypeClass( - '$ifConst${_dartTypeClassName(resolved)}($args)', - canBeConst, - ); - } - } - - /// Get corresponding Dart FFI type of Java type. - String getDartFfiType(TypeUsage t) { - const primitives = { - 'byte': 'Int8', - 'short': 'Int16', - 'char': 'Uint16', - 'int': 'Int32', - 'long': 'Int64', - 'float': 'Float', - 'double': 'Double', - 'void': 'Void', - 'boolean': 'Uint8', - }; - switch (t.kind) { - case Kind.primitive: - return ffi + primitives[(t.type as PrimitiveType).name]!; - case Kind.wildcard: - throw SkipException('Wildcards are not yet supported'); - case Kind.typeVariable: - case Kind.array: - case Kind.declared: - return voidPointer; - } - } - - String getDartInnerType(TypeUsage t) => _dartType(t); - String getDartOuterType(TypeUsage t, SymbolResolver resolver) => - _dartType(t, resolver: resolver); - - String getDartLiteral(dynamic value) { - if (value is String) { - // TODO(#31): escape string literal. - return '"$value"'.replaceAll('\\', '\\\\'); - } - if (value is int || value is double || value is bool) { - return value.toString(); - } - throw SkipException('Not a constant of a known type.'); - } - - String getJValueAccessor(TypeUsage type) { - const primitives = { - 'boolean': 'boolean', - 'byte': 'byte', - 'short': 'short', - 'char': 'char', - 'int': 'integer', - 'long': 'long', - 'float': 'float', - 'double': 'doubleFloat', - 'void': 'check()', - }; - if (isPrimitive(type)) { - return primitives[type.name]!; - } - return 'object'; - } - - String getOriginalFieldDecl(Field f) { - final declStmt = '${f.type.shorthand} ${f.name}'; - return [...f.modifiers, declStmt].join(' '); - } - - String getOriginalMethodHeader(Method m) { - final args = []; - for (var p in m.params) { - args.add('${p.type.shorthand} ${p.name}'); - } - final declStmt = '${m.returnType.shorthand} ${m.name}' - '(${args.join(', ')})'; - return [...m.modifiers, declStmt].join(' '); - } - - String toNativeArg(String name, TypeUsage type, - {bool convertBooleanToInt = true}) { - if (isPrimitive(type)) { - return (type.name == 'boolean' && convertBooleanToInt) - ? '$name ? 1 : 0' - : name; - } - return '$name.$selfPointer'; - } - - String toDartResult(String expr, TypeUsage type, String dartTypeClass) { - if (isPrimitive(type)) { - return expr; - } - return '$dartTypeClass.fromRef($expr)'; - } - - static final deleteInstruction = - '$indent/// The returned object must be deleted after use, ' - 'by calling the `delete` method.\n'; - String getCallType(TypeUsage returnType) { - if (isPrimitive(returnType)) { - return "$jniCallType.${returnType.name}Type"; - } - return "$jniCallType.objectType"; - } -} - -String breakDocComment(JavaDocComment? javadoc, {String depth = ' '}) { - final link = RegExp('{@link ([^{}]+)}'); - if (javadoc == null) return ''; - final comment = javadoc.comment - .replaceAllMapped(link, (match) => match.group(1) ?? '') - .replaceAll('#', '\\#') - .replaceAll('

', '') - .replaceAll('

', '\n') - .replaceAll('', '__') - .replaceAll('', '__') - .replaceAll('', '_') - .replaceAll('', '_'); - return '$depth///\n' - '$depth/// ${comment.replaceAll('\n', '\n$depth///')}\n'; -} - -/// class name canonicalized for C bindings, by replacing "." with "_" and -/// "$" with "__". -String getUniqueClassName(ClassDecl decl) { - if (!decl.isPreprocessed) { - throw StateError("class not preprocessed: ${decl.binaryName}"); - } - return decl.uniqueName; -} - -/// Returns the name of the class member as referred to by C bindings -String getMemberNameInC(ClassDecl decl, String name) => - "${getUniqueClassName(decl)}__$name"; - -String getCType(String binaryName) { - switch (binaryName) { - case "void": - return "void"; - case "byte": - return "int8_t"; - case "char": - return "char"; - case "double": - return "double"; - case "float": - return "float"; - case "int": - return "int32_t"; - case "long": - return "int64_t"; - case "short": - return "int16_t"; - case "boolean": - return "uint8_t"; - default: - return "jobject"; - } -} - -String getInternalName(String binaryName) { - switch (binaryName) { - case "void": - return "V"; - case "byte": - return "B"; - case "char": - return "C"; - case "double": - return "D"; - case "float": - return "F"; - case "int": - return "I"; - case "long": - return "J"; - case "short": - return "S"; - case "boolean": - return "Z"; - default: - return binaryName.replaceAll(".", "/"); - } -} - -String getSignature(String binaryName) { - switch (binaryName) { - case "void": - return "V"; - case "byte": - return "B"; - case "char": - return "C"; - case "double": - return "D"; - case "float": - return "F"; - case "int": - return "I"; - case "long": - return "J"; - case "short": - return "S"; - case "boolean": - return "Z"; - default: - return 'L${binaryName.replaceAll(".", "/")};'; - } -} - -String getDescriptor(TypeUsage usage, {bool escapeDollarSign = false}) { - switch (usage.kind) { - case Kind.declared: - return getSignature((usage.type as DeclaredType).binaryName); - case Kind.primitive: - return getSignature((usage.type as PrimitiveType).name); - case Kind.typeVariable: - // It should be possible to compute the erasure of a type - // in parser itself. - // TODO(#23): Use erasure of the type variable here. - // This is just a (wrong) placeholder - return "Ljava/lang/Object;"; - case Kind.array: - final inner = getDescriptor((usage.type as ArrayType).type); - return "[$inner"; - case Kind.wildcard: - final extendsBound = (usage.type as Wildcard).extendsBound; - if (extendsBound != null) { - return getDescriptor(extendsBound); - } - return 'Ljava/lang/Object;'; - } -} - -String toFuture(String type) { - return 'Future<$type>'; -} - -bool isPrimitive(TypeUsage t) => t.kind == Kind.primitive; -bool isVoid(TypeUsage t) => isPrimitive(t) && t.name == 'void'; - -bool isStaticField(Field f) => f.modifiers.contains('static'); -bool isStaticMethod(Method m) => m.modifiers.contains('static'); - -bool isFinalField(Field f) => f.modifiers.contains('final'); -bool isFinalMethod(Method m) => m.modifiers.contains('final'); - -bool isCtor(Method m) => m.name == ''; - -// static methods & constructors do not have self param. -bool hasSelfParam(Method m) => !isStaticMethod(m) && !isCtor(m); - -bool isObjectField(Field f) => !isPrimitive(f.type); -bool isObjectMethod(Method m) => !isPrimitive(m.returnType); - -/// Returns class name as useful in dart. -/// -/// Eg -> a.b.X.Y -> X_Y -String getSimplifiedClassName(String binaryName) => - binaryName.split('.').last.replaceAll('\$', '_'); - -// Marker exception when a method or class cannot be translated -// The inner functions may not know how much context has to be skipped in case -// of an error or unknown element. They throw SkipException. -class SkipException implements Exception { - SkipException(this.message, [this.element]); - String message; - dynamic element; - - @override - String toString() { - return '$message;'; - } -} - -String getTypeNameAtCallSite(TypeUsage t) { - if (isPrimitive(t)) { - return t.name.substring(0, 1).toUpperCase() + t.name.substring(1); - } - return "Object"; -} - -String getResultGetterName(TypeUsage returnType) { - final primitives = { - 'boolean': 'boolean', - 'byte': 'byte', - 'short': 'short', - 'char': 'char', - 'int': 'integer', - 'long': 'long', - 'float': 'float', - 'double': 'doubleFloat', - 'void': 'check()', - }; - return primitives[returnType.name] ?? 'object'; -} - -/// Returns the JNI signature of the method. -String getJniSignatureForMethod(Method m) { - final s = StringBuffer(); - s.write('('); - for (var param in m.params) { - final type = getDescriptor(param.type); - s.write(type); - } - s.write(')'); - final returnType = getDescriptor(m.returnType); - s.write(returnType); - return s.toString(); -} - -class _TypeClass { - final String name; - final bool canBeConst; - - _TypeClass(this.name, this.canBeConst); -} diff --git a/pkgs/jnigen/lib/src/bindings/dart_bindings.dart b/pkgs/jnigen/lib/src/bindings/dart_bindings.dart deleted file mode 100644 index d1ad57639..000000000 --- a/pkgs/jnigen/lib/src/bindings/dart_bindings.dart +++ /dev/null @@ -1,273 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -import 'package:jnigen/src/elements/elements.dart'; -import 'package:jnigen/src/config/config.dart'; -import 'package:jnigen/src/logging/logging.dart'; - -import 'symbol_resolver.dart'; -import 'common.dart'; - -class CBasedDartBindingsGenerator extends BindingsGenerator { - static const selfPointer = BindingsGenerator.selfPointer; - - /// Symbol lookup function for generated code. - static const lookup = 'jniLookup'; - - // import prefixes - static const ffi = BindingsGenerator.ffi; - static const jni = BindingsGenerator.jni; - - static final indent = ' ' * 2; - - static const voidPointer = BindingsGenerator.jobjectType; - - static const ffiVoidType = BindingsGenerator.ffiVoidType; - - static const jniObjectType = BindingsGenerator.jniObjectType; - - CBasedDartBindingsGenerator(this.config); - - final Config config; - - @override - String generateBindings(ClassDecl decl, SymbolResolver resolver) { - if (!decl.isPreprocessed) { - throw StateError('Java class declaration must be preprocessed before' - 'being passed to bindings generator'); - } - if (!decl.isIncluded) { - return ''; - } - final bindings = _class(decl, resolver); - log.finest('generated bindings for class ${decl.binaryName}'); - return bindings; - } - - String _class(ClassDecl decl, SymbolResolver resolver) { - final s = StringBuffer(); - - s.write('/// from: ${decl.binaryName}\n'); - s.write(breakDocComment(decl.javadoc, depth: '')); - - s.write(dartClassDefinition(decl, resolver)); - s.write(dartStaticTypeGetter(decl)); - for (var field in decl.fields) { - if (!field.isIncluded) { - continue; - } - try { - s.write(_field(decl, field, resolver)); - s.writeln(); - } on SkipException catch (e) { - log.fine('skip field ${decl.binaryName}#${field.name}: ' - '${e.message}'); - } - } - - for (var method in decl.methods) { - if (!method.isIncluded) { - continue; - } - try { - s.write(_method(decl, method, resolver)); - s.writeln(); - } on SkipException catch (e) { - log.fine('skip field ${decl.binaryName}#${method.name}: ' - '${e.message}'); - } - } - s.write("}\n"); - s.write(dartTypeClass(decl)); - s.write(dartArrayExtension(decl)); - return s.toString(); - } - - String _method(ClassDecl c, Method m, SymbolResolver resolver) { - final name = m.finalName; - final cName = getMemberNameInC(c, name); - final s = StringBuffer(); - final sym = '_$name'; - final ffiSig = dartSigForMethod(m, isFfiSig: true); - final dartSig = dartSigForMethod(m, isFfiSig: false); - var returnType = getDartOuterType( - m.asyncReturnType ?? m.returnType, - resolver, - ); - if (m.asyncReturnType != null) { - returnType = toFuture(returnType); - } - final returnTypeClass = - getDartTypeClass(m.asyncReturnType ?? m.returnType, resolver); - final ifStaticMethod = isStaticMethod(m) ? 'static' : ''; - - // Load corresponding C method. - s.write('${indent}static final $sym = $lookup' - '<${ffi}NativeFunction<$ffiSig>>("$cName")\n' - '.asFunction<$dartSig>();\n'); - // Different logic for constructor and method; - // For constructor, we want return type to be new object. - s.write('$indent/// from: ${getOriginalMethodHeader(m)}\n'); - if (!isPrimitive(m.returnType)) { - s.write(BindingsGenerator.deleteInstruction); - } - s.write(breakDocComment(m.javadoc)); - s.write(indent); - - if (isCtor(m)) { - final className = c.finalName; - final ctorFnName = name == 'ctor' ? className : '$className.$name'; - final wrapperExpr = '$sym(${actualArgs(m)})'; - s.write( - '$ctorFnName(${getFormalArgs(c, m, resolver)}) : ' - 'super.fromRef(${dartSuperArgs(c, resolver)}$wrapperExpr.object);\n', - ); - return s.toString(); - } - - final resultGetter = getJValueAccessor(m.returnType); - var wrapperExpr = '$sym(${actualArgs(m)}).$resultGetter'; - final typeParamsWithExtend = - dartTypeParams(m.typeParams, includeExtends: true); - final params = getFormalArgs(c, m, resolver); - s.write( - '$indent$ifStaticMethod $returnType $name$typeParamsWithExtend($params) ', - ); - if (m.asyncReturnType == null) { - wrapperExpr = toDartResult(wrapperExpr, m.returnType, returnTypeClass); - s.write('=> $wrapperExpr;\n'); - } else { - s.write( - 'async {\n' - '${indent * 2}final \$p = ReceivePort();\n' - '${indent * 2}final \$c = ${jni}Jni.newPortContinuation(\$p);\n' - '${indent * 2}$wrapperExpr;\n' - '${indent * 2}final \$o = $voidPointer.fromAddress(await \$p.first);\n' - '${indent * 2}final \$k = $returnTypeClass.getClass().reference;\n' - '${indent * 2}if (${jni}Jni.env.IsInstanceOf(\$o, \$k) == 0) {\n' - '${indent * 3}throw "Failed";\n' - '${indent * 2}}\n' - '${indent * 2}return ${toDartResult( - '\$o', - m.returnType, - returnTypeClass, - )};\n' - '}\n', - ); - } - return s.toString(); - } - - String _field(ClassDecl c, Field f, SymbolResolver resolver) { - final name = f.finalName; - final s = StringBuffer(); - - void writeDocs({bool writeDeleteInstruction = true}) { - s.write('$indent/// from: ${getOriginalFieldDecl(f)}\n'); - if (!isPrimitive(f.type) && writeDeleteInstruction) { - s.write(BindingsGenerator.deleteInstruction); - } - s.write(breakDocComment(f.javadoc)); - } - - if (isStaticField(f) && isFinalField(f) && f.defaultValue != null) { - writeDocs(writeDeleteInstruction: false); - s.write('${indent}static const $name = ' - '${getDartLiteral(f.defaultValue)};\n'); - return s.toString(); - } - - final cName = getMemberNameInC(c, name); - - void writeAccessor({bool isSetter = false}) { - final symPrefix = isSetter ? 'set' : 'get'; - final sym = '_${symPrefix}_$name'; - final ffiSig = dartSigForField(f, isSetter: isSetter, isFfiSig: true); - final dartSig = dartSigForField(f, isSetter: isSetter, isFfiSig: false); - s.write('${indent}static final $sym = $lookup' - '<${ffi}NativeFunction<$ffiSig>>("${symPrefix}_$cName")\n' - '.asFunction<$dartSig>();\n'); - writeDocs(); - final ifStatic = isStaticField(f) ? 'static' : ''; - if (isSetter) { - final args = [ - if (!isStaticField(f)) selfPointer, - toNativeArg('value', f.type), - ].join(', '); - final valueOuterType = getDartOuterType(f.type, resolver); - s.write('$indent$ifStatic set $name($valueOuterType value) => ' - '$sym($args);\n'); - } else { - // getter - final self = isStaticField(f) ? '' : selfPointer; - final outerType = getDartOuterType(f.type, resolver); - final outerTypeClass = getDartTypeClass(f.type, resolver); - final resultGetter = getJValueAccessor(f.type); - final callExpr = '$sym($self).$resultGetter'; - final resultExpr = toDartResult(callExpr, f.type, outerTypeClass); - s.write('$indent$ifStatic $outerType get $name => $resultExpr;\n'); - } - } - - writeAccessor(isSetter: false); - if (!isFinalField(f)) writeAccessor(isSetter: true); - s.writeln(); - return s.toString(); - } - - static const _importsForInitCode = 'import "dart:ffi" as ffi;\n' - 'import "package:jni/internal_helpers_for_jnigen.dart";\n'; - - /// Initialization code for C based bindings. - /// - /// Should be called once in a package. In package-structured bindings - /// this is placed in _init.dart in package root. - String _initCode() => '// Auto-generated initialization code.\n' - '\n' - 'final ffi.Pointer Function(String sym)\n' - 'jniLookup = ProtectedJniExtensions.initGeneratedLibrary' - '("${config.outputConfig.cConfig!.libraryName}");' - '\n\n'; - static const autoGeneratedNotice = '// Autogenerated by jnigen. ' - 'DO NOT EDIT!\n\n'; - static const defaultImports = 'import "dart:isolate" show ReceivePort;\n' - 'import "dart:ffi" as ffi;\n' - 'import "package:jni/internal_helpers_for_jnigen.dart";\n' - 'import "package:jni/jni.dart" as jni;\n\n'; - static const defaultLintSuppressions = - '// ignore_for_file: annotate_overrides\n' - '// ignore_for_file: camel_case_extensions\n' - '// ignore_for_file: camel_case_types\n' - '// ignore_for_file: constant_identifier_names\n' - '// ignore_for_file: file_names\n' - '// ignore_for_file: no_leading_underscores_for_local_identifiers\n' - '// ignore_for_file: non_constant_identifier_names\n' - '// ignore_for_file: overridden_fields\n' - '// ignore_for_file: unnecessary_cast\n' - '// ignore_for_file: unused_element\n' - '// ignore_for_file: unused_import\n' - '\n'; - static const preImportBoilerplate = - autoGeneratedNotice + defaultLintSuppressions + defaultImports; - - @override - String getPostImportBoilerplate([String? initFilePath]) { - if (config.outputConfig.dartConfig.structure == - OutputStructure.singleFile) { - return _initCode(); - } else { - return 'import "${initFilePath!}" show jniLookup;\n\n'; - } - } - - @override - String getPreImportBoilerplate([String? initFilePath]) { - return preImportBoilerplate; - } - - @override - String getInitFileContents() { - return '$_importsForInitCode\n${_initCode()}'; - } -} diff --git a/pkgs/jnigen/lib/src/bindings/dart_generator.dart b/pkgs/jnigen/lib/src/bindings/dart_generator.dart new file mode 100644 index 000000000..6ae33960b --- /dev/null +++ b/pkgs/jnigen/lib/src/bindings/dart_generator.dart @@ -0,0 +1,1115 @@ +// 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 'dart:io'; + +import '../config/config.dart'; +import '../elements/elements.dart'; +import '../logging/logging.dart'; +import '../writers/bindings_writer.dart'; +import 'c_generator.dart'; +import 'resolver.dart'; +import 'visitor.dart'; + +// Import prefixes +const _jni = 'jni'; +const _ffi = 'ffi'; + +// package:jni types +const _jType = '$_jni.JObjType'; +const _jPointer = '$_jni.JObjectPtr'; +const _jArray = '$_jni.JArray'; +const _jObject = '$_jni.JObject'; +const _jThrowable = '$_jni.JThrowablePtr'; +const _jResult = '$_jni.JniResult'; +const _jCallType = '$_jni.JniCallType'; + +// package:ffi types +const _voidPointer = '$_ffi.Pointer<$_ffi.Void>'; + +// Prefixes and suffixes +const _typeParamPrefix = '\$'; +// TODO(#143): this is a temporary fix for the name collision. +const _typeClassPrefix = '\$'; +const _typeClassSuffix = 'Type'; + +// Misc. +const _classRef = '_classRef'; +const _env = 'jniEnv'; +const _accessors = 'jniAccessors'; +const _lookup = 'jniLookup'; +const _selfPointer = 'reference'; + +// Docs +const _deleteInstruction = + ' /// The returned object must be deleted after use, ' + 'by calling the `delete` method.'; + +extension on String { + String capitalize() { + return '${this[0].toUpperCase()}${substring(1)}'; + } +} + +/// Encloses [inside] in the middle of [open] and [close] +/// if [inside] is not empty. +String _encloseIfNotEmpty(String open, String inside, String close) { + if (inside == '') return ''; + return '$open$inside$close'; +} + +String _newLine({int depth = 0}) { + return '\n${' ' * depth}'; +} + +/// **Naming Convention** +/// +/// Let's take the following code as an example: +/// +/// ```dart +/// Method definition +/// void f(JType $T, JType $U, T t, U u) { +/// // ... +/// } +/// f($T, $U, t, u); // Calling the Method +/// ``` +/// +/// Here `f` will be replaced according to the place of usage. +/// +/// * `fArgsDef` refers to `T t, U u` – the arguments in the method +/// definition. +/// * `fArgsCall` refer to `t, u` – the arguments passed to call the method. +/// * `fTypeParamsDef` refers to `` – the type parameters +/// of the method at the point of definition. +/// * `fTypeParamsCall` refers to `` – the type parameters when +/// calling, or whenever we don't want to have the `extends` keyword. +/// * `fTypeClassesDef` refers to `JType $T, JType $U`. +/// * `fTypeClassesCall` refers to `$T, $U` when calling the method. +class DartGenerator extends Visitor> { + DartGenerator(this.config); + + final Config config; + + static const cInitImport = 'import "dart:ffi" as ffi;\n' + 'import "package:jni/internal_helpers_for_jnigen.dart";\n'; + + /// Initialization code for C based bindings. + /// + /// Should be called once in a package. In package-structured bindings + /// this is placed in _init.dart in package root. + String get cInitCode => ''' +// Auto-generated initialization code. + +final $_ffi.Pointer Function(String sym) $_lookup = + ProtectedJniExtensions.initGeneratedLibrary("${config.outputConfig.cConfig!.libraryName}"); + + +'''; + + static const dartOnlyInitImport = 'import "package:jni/jni.dart" as jni;\n'; + + static const dartOnlyInitCode = ''' +// Auto-generated initialization code. + +final $_env = $_jni.Jni.env; +final $_accessors = $_jni.Jni.accessors; + + +'''; + + static const autoGeneratedNotice = '// Autogenerated by jnigen. ' + 'DO NOT EDIT!\n\n'; + static const defaultImports = ''' +import "dart:isolate" show ReceivePort; +import "dart:ffi" as ffi; +import "package:jni/internal_helpers_for_jnigen.dart"; +import "package:jni/jni.dart" as jni; + +'''; + static const defaultLintSuppressions = ''' +// ignore_for_file: annotate_overrides +// ignore_for_file: camel_case_extensions +// ignore_for_file: camel_case_types +// ignore_for_file: constant_identifier_names +// ignore_for_file: file_names +// ignore_for_file: no_leading_underscores_for_local_identifiers +// ignore_for_file: non_constant_identifier_names +// ignore_for_file: overridden_fields +// ignore_for_file: unnecessary_cast +// ignore_for_file: unused_element +// ignore_for_file: unused_field +// ignore_for_file: unused_import +// ignore_for_file: unused_shown_name + +'''; + static const preImportBoilerplate = + autoGeneratedNotice + defaultLintSuppressions + defaultImports; + + @override + Future visit(Classes node) async { + final cBased = config.outputConfig.bindingsType == BindingsType.cBased; + final root = config.outputConfig.dartConfig.path; + final preamble = config.preamble ?? ''; + if (config.outputConfig.dartConfig.structure == + OutputStructure.singleFile) { + final file = File.fromUri(root); + await file.create(recursive: true); + log.info("Generating ${cBased ? "C + Dart" : "Pure Dart"} Bindings"); + final s = file.openWrite(); + s.writeln(preamble); + s.writeln(autoGeneratedNotice); + s.writeln(defaultLintSuppressions); + s.writeln(defaultImports); + if (cBased) { + s.writeln(cInitCode); + } else { + s.writeln(dartOnlyInitCode); + } + final classGenerator = _ClassGenerator(config, s); + node.decls.values.accept(classGenerator).toList(); + await s.close(); + await runDartFormat(file.path); + return; + } + final files = >{}; + final packages = >{}; + for (final classDecl in node.decls.values) { + final fileClass = Resolver.getFileClassName(classDecl.binaryName); + + files.putIfAbsent(fileClass, () => []); + files[fileClass]!.add(classDecl); + + packages.putIfAbsent(classDecl.packageName, () => {}); + packages[classDecl.packageName]!.add(fileClass.split('.').last); + } + + log.info("Using dart root = $root"); + const initFileName = '_init.dart'; + final initFileUri = root.resolve(initFileName); + final initFile = File.fromUri(initFileUri); + await initFile.create(recursive: true); + final initStream = initFile.openWrite(); + initStream.writeln(preamble); + initStream.writeln(cBased ? cInitImport : dartOnlyInitImport); + initStream.writeln(cBased ? cInitCode : dartOnlyInitCode); + await initStream.close(); + for (var fileClassName in files.keys) { + final relativeFileName = '${fileClassName.replaceAll('.', '/')}.dart'; + final dartFileUri = root.resolve(relativeFileName); + final dartFile = await File.fromUri(dartFileUri).create(recursive: true); + log.fine('$fileClassName -> ${dartFile.path}'); + + final classesInFile = files[fileClassName]!; + final dartFileStream = dartFile.openWrite(); + dartFileStream.writeln(preamble); + dartFileStream.writeln(autoGeneratedNotice); + dartFileStream.writeln(defaultLintSuppressions); + dartFileStream.writeln(defaultImports); + final s = StringBuffer(); + final initFilePath = ('../' * + relativeFileName.codeUnits + .where((cu) => cu == '/'.codeUnitAt(0)) + .length) + + initFileName; + s.write('import "$initFilePath";'); + final resolver = Resolver( + importMap: config.importMap ?? {}, + currentClass: fileClassName, + inputClassNames: node.decls.keys.toSet(), + ); + classesInFile + .accept(_ClassGenerator(config, s, resolver: resolver)) + .toList(); + dartFileStream.writeAll(resolver.getImportStrings(), '\n'); + dartFileStream.writeln(s.toString()); + await dartFileStream.close(); + } + + // write _package.dart export files + for (var package in packages.keys) { + final dirUri = root.resolve('${package.replaceAll('.', '/')}/'); + final exportFileUri = dirUri.resolve("_package.dart"); + final exportFile = File.fromUri(exportFileUri); + exportFile.createSync(recursive: true); + final exports = + packages[package]!.map((cls) => 'export "$cls.dart";').join('\n'); + exportFile.writeAsStringSync(exports); + } + await runDartFormat(root.toFilePath()); + log.info('Completed.'); + } +} + +/// Generates the Dart class definition, type class, and the array extension +class _ClassGenerator extends Visitor { + _ClassGenerator( + this.config, + this.s, { + this.resolver, + }); + + final Config config; + final StringSink s; + final Resolver? resolver; + + static const staticTypeGetter = 'type'; + static const instanceTypeGetter = '\$$staticTypeGetter'; + + static const arrayExtensionPrefix = '\$'; + static const arrayExtensionSuffix = 'Array'; + + @override + void visit(ClassDecl node) { + final isDartOnly = + config.outputConfig.bindingsType == BindingsType.dartOnly; + + // Docs + s.write('/// from: ${node.binaryName}\n'); + node.javadoc?.accept(_DocGenerator(s, depth: 0)); + + // Class definition + final name = node.finalName; + final superName = node.superclass!.accept(_TypeGenerator(resolver)); + final typeParamsDef = _encloseIfNotEmpty( + '<', + node.allTypeParams + .accept(const _TypeParamGenerator(withExtends: true)) + .join(', '), + '>', + ); + final typeParams = node.allTypeParams + .accept(const _TypeParamGenerator(withExtends: false)); + final typeParamsCall = _encloseIfNotEmpty('<', typeParams.join(', '), '>'); + final staticTypeGetterCallArgs = _encloseIfNotEmpty( + '(', + typeParams.map((typeParams) => '$_typeParamPrefix$typeParams').join(', '), + ')', + ); + final typeClassDefinitions = typeParams + .map((typeParam) => + 'final $_jType<$typeParam> $_typeParamPrefix$typeParam;') + .join(_newLine(depth: 1)); + final ctorTypeClassesDef = typeParams + .map((typeParam) => 'this.$_typeParamPrefix$typeParam,') + .join(_newLine(depth: 2)); + final superClass = (node.classDecl.superclass!.type as DeclaredType); + final superTypeClassesCall = superClass.classDecl == ClassDecl.object + ? '' + : superClass.params + .accept(_TypeClassGenerator(resolver)) + .map((typeClass) => '${typeClass.name},') + .join(_newLine(depth: 2)); + s.write(''' +class $name$typeParamsDef extends $superName { + late final $_jType? _$instanceTypeGetter; + @override + $_jType get $instanceTypeGetter => _$instanceTypeGetter ??= $staticTypeGetter$staticTypeGetterCallArgs; + + $typeClassDefinitions + + $name.fromRef( + $ctorTypeClassesDef + $_jPointer ref, + ): super.fromRef( + $superTypeClassesCall + ref + ); + +'''); + + if (isDartOnly) { + final internalName = node.internalName; + s.write(''' + static final $_classRef = $_accessors.getClassOf(r"$internalName"); + +'''); + } + + // Static TypeClass getter + s.writeln( + ' /// The type which includes information such as the signature of this class.'); + final typeClassName = '$_typeClassPrefix$name$_typeClassSuffix'; + if (typeParams.isEmpty) { + s.writeln('static const $staticTypeGetter = $typeClassName();'); + } else { + final staticTypeGetterTypeClassesDef = typeParams + .map( + (typeParam) => '$_jType<$typeParam> $_typeParamPrefix$typeParam,') + .join(_newLine(depth: 2)); + final typeClassesCall = typeParams + .map((typeParam) => '$_typeParamPrefix$typeParam,') + .join(_newLine(depth: 3)); + s.write(''' + static $typeClassName$typeParamsCall $staticTypeGetter$typeParamsDef( + $staticTypeGetterTypeClassesDef + ) { + return $typeClassName( + $typeClassesCall + ); + } + +'''); + } + + // Fields and Methods + final fieldGenerator = _FieldGenerator(config, resolver, s); + for (final field in node.fields) { + field.accept(fieldGenerator); + } + final methodGenerator = _MethodGenerator(config, resolver, s); + for (final method in node.methods) { + method.accept(methodGenerator); + } + + // End of Class definition + s.writeln('}'); + + // TypeClass definition + final typeClassesCall = typeParams + .map((typeParam) => '$_typeParamPrefix$typeParam,') + .join(_newLine(depth: 2)); + final signature = node.signature; + s.write(''' +class $typeClassName$typeParamsDef extends $_jType<$name$typeParamsCall> { + $typeClassDefinitions + + const $typeClassName( + $ctorTypeClassesDef + ); + + @override + String get signature => r"$signature"; + + @override + $name$typeParamsCall fromRef($_jPointer ref) => $name.fromRef( + $typeClassesCall + ref + ); +} + +'''); + + // Array extension + s.write(''' +extension $arrayExtensionPrefix$name$arrayExtensionSuffix$typeParamsDef on $_jArray<$name$typeParamsCall> { + $name$typeParamsCall operator [](int index) { + return (elementType as $typeClassName$typeParamsCall) + .fromRef(elementAt(index, $_jni.JniCallType.objectType).object); + } + + void operator []=(int index, $name$typeParamsCall value) { + (this as $_jArray<$_jObject>)[index] = value; + } +} +'''); + log.finest('Generated bindings for class ${node.binaryName}'); + } +} + +/// Generates the JavaDoc comments. +class _DocGenerator extends Visitor { + const _DocGenerator(this.s, {required this.depth}); + + final StringSink s; + final int depth; + + @override + void visit(JavaDocComment node) { + final link = RegExp('{@link ([^{}]+)}'); + final indent = ' ' * depth; + final comments = node.comment + .replaceAllMapped(link, (match) => match.group(1) ?? '') + .replaceAll('#', '\\#') + .replaceAll('

', '') + .replaceAll('

', '\n') + .replaceAll('', '__') + .replaceAll('', '__') + .replaceAll('', '_') + .replaceAll('', '_') + .split('\n') + .join('\n$indent///'); + s.write(''' +$indent/// +$indent/// $comments +'''); + } +} + +/// Generates the user-facing Dart type. +class _TypeGenerator extends TypeVisitor { + const _TypeGenerator(this.resolver); + + final Resolver? resolver; + + @override + String visitArrayType(ArrayType node) { + final innerType = node.type; + if (innerType.kind == Kind.primitive) { + return '$_jArray<$_jni.${(innerType.type as PrimitiveType).jniType}>'; + } + return '$_jArray<${innerType.accept(this)}>'; + } + + @override + String visitDeclaredType(DeclaredType node) { + if (node.classDecl.binaryName == 'java.lang.Object' || + node.classDecl.binaryName == 'java.lang.String') { + return '$_jni.${node.classDecl.finalName}'; + } + + // All type parameters of this type + final allTypeParams = node.classDecl.allTypeParams + .accept(const _TypeParamGenerator(withExtends: false)) + .toList(); + // The ones that are declared. + final definedTypeParams = node.params.accept(this).toList(); + + // Replacing the declared ones. They come at the end. + // The rest will be JObject. + if (allTypeParams.length >= node.params.length) { + allTypeParams.replaceRange( + 0, + allTypeParams.length - node.params.length, + List.filled( + allTypeParams.length - node.params.length, + _jObject, + ), + ); + allTypeParams.replaceRange( + allTypeParams.length - node.params.length, + allTypeParams.length, + definedTypeParams, + ); + } + + final typeParams = _encloseIfNotEmpty('<', allTypeParams.join(', '), '>'); + final prefix = resolver?.resolvePrefix(node.classDecl.binaryName) ?? ''; + return '$prefix${node.classDecl.finalName}$typeParams'; + } + + @override + String visitPrimitiveType(PrimitiveType node) { + return node.dartType; + } + + @override + String visitTypeVar(TypeVar node) { + return node.name; + } + + @override + String visitWildcard(Wildcard node) { + // TODO(#141): Support wildcards + return super.visitWildcard(node); + } + + @override + String visitNonPrimitiveType(ReferredType node) { + return _jObject; + } +} + +class _TypeClass { + const _TypeClass(this.name, this.canBeConst); + + final String name; + final bool canBeConst; +} + +/// Generates the type class. +class _TypeClassGenerator extends TypeVisitor<_TypeClass> { + final bool isConst; + final Resolver? resolver; + + _TypeClassGenerator(this.resolver, {this.isConst = true}); + + @override + _TypeClass visitArrayType(ArrayType node) { + final innerTypeClass = + node.type.accept(_TypeClassGenerator(resolver, isConst: false)); + final ifConst = innerTypeClass.canBeConst && isConst ? 'const ' : ''; + return _TypeClass( + '$ifConst$_jArray$_typeClassSuffix(${innerTypeClass.name})', + innerTypeClass.canBeConst, + ); + } + + @override + _TypeClass visitDeclaredType(DeclaredType node) { + if (node.classDecl.binaryName == 'java.lang.Object' || + node.classDecl.binaryName == 'java.lang.String') { + final ifConst = isConst ? 'const ' : ''; + return _TypeClass( + '$ifConst$_jni.${node.classDecl.finalName}$_typeClassSuffix()', true); + } + final allTypeParams = node.classDecl.allTypeParams + .accept(const _TypeParamGenerator(withExtends: false)) + .map((typeParam) => '$_typeParamPrefix$typeParam') + .toList(); + + // The ones that are declared. + final definedTypeClasses = + node.params.accept(_TypeClassGenerator(resolver, isConst: false)); + + // Can be const if all the type parameters are defined and each of them are + // also const. + final canBeConst = definedTypeClasses.every((e) => e.canBeConst); + + // Adding const to `JObjectType`s if the entire expression is not const. + final constJObject = canBeConst ? '' : 'const '; + + // Replacing the declared ones. They come at the end. + // The rest will be `JObjectType`. + if (allTypeParams.length >= node.params.length) { + allTypeParams.replaceRange( + 0, + allTypeParams.length - node.params.length, + List.filled( + allTypeParams.length - node.params.length, + '$constJObject$_jObject$_typeClassSuffix()', + ), + ); + allTypeParams.replaceRange( + allTypeParams.length - node.params.length, + allTypeParams.length, + definedTypeClasses.map((param) => param.name), + ); + } + + final args = allTypeParams.join(', '); + final ifConst = isConst && canBeConst ? 'const ' : ''; + final prefix = resolver?.resolvePrefix(node.classDecl.binaryName) ?? ''; + return _TypeClass( + '$ifConst$prefix$_typeClassPrefix${node.classDecl.finalName}$_typeClassSuffix($args)', + canBeConst, + ); + } + + @override + _TypeClass visitPrimitiveType(PrimitiveType node) { + final ifConst = isConst ? 'const ' : ''; + return _TypeClass('$ifConst$_jni.${node.jniType}$_typeClassSuffix()', true); + } + + @override + _TypeClass visitTypeVar(TypeVar node) { + return _TypeClass('$_typeParamPrefix${node.name}', false); + } + + @override + _TypeClass visitWildcard(Wildcard node) { + // TODO(#141): Support wildcards + return super.visitWildcard(node); + } + + @override + _TypeClass visitNonPrimitiveType(ReferredType node) { + final ifConst = isConst ? 'const ' : ''; + return _TypeClass('$ifConst$_jObject$_typeClassSuffix()', true); + } +} + +class _TypeParamGenerator extends Visitor { + const _TypeParamGenerator({required this.withExtends}); + + final bool withExtends; + + @override + String visit(TypeParam node) { + if (!withExtends) { + return node.name; + } + // TODO(#144): resolve the actual type being extended, if any. + return '${node.name} extends $_jObject'; + } +} + +class _JniResultGetter extends TypeVisitor { + const _JniResultGetter(); + + @override + String visitPrimitiveType(PrimitiveType node) { + if (node.name == 'void') return 'check()'; + if (node.name == 'double') return 'doubleFloat'; + if (node.name == 'int') return 'integer'; + return node.name; + } + + @override + String visitNonPrimitiveType(ReferredType node) { + return 'object'; + } +} + +/// Type signature for C-based bindings. +/// +/// When `isFFi` is `true`, it generates the ffi type signature and when it's +/// false, it generates the dart type signature. +/// +/// For example `ffi.Int32` is an ffi type signature while `int` is a Dart one: +/// ```dart +/// jniLookup>( +/// "sum") +/// .asFunction(); +/// ``` +class _TypeSig extends TypeVisitor { + const _TypeSig({required this.isFfi}); + + final bool isFfi; + + @override + String visitPrimitiveType(PrimitiveType node) { + if (isFfi) return '$_ffi.${node.ffiType}'; + if (node.name == 'boolean') return 'int'; + return node.dartType; + } + + @override + String visitNonPrimitiveType(ReferredType node) { + return _voidPointer; + } +} + +class _TypeName extends TypeVisitor { + const _TypeName(); + + @override + String visitPrimitiveType(PrimitiveType node) { + return node.name; + } + + @override + String visitNonPrimitiveType(ReferredType node) { + return 'object'; + } +} + +class _CallType extends TypeVisitor { + const _CallType(); + + @override + String visitPrimitiveType(PrimitiveType node) { + return '$_jCallType.${node.name}Type'; + } + + @override + String visitNonPrimitiveType(ReferredType node) { + return '$_jCallType.objectType'; + } +} + +class _ToNativeSuffix extends TypeVisitor { + const _ToNativeSuffix(); + + @override + String visitPrimitiveType(PrimitiveType node) { + if (node.name == 'boolean') { + return ' ? 1 : 0'; + } + return ''; + } + + @override + String visitNonPrimitiveType(ReferredType node) { + return '.$_selfPointer'; + } +} + +class _FromNative extends TypeVisitor { + const _FromNative(this.resolver, this.value); + + final Resolver? resolver; + final String value; + + @override + String visitPrimitiveType(PrimitiveType node) { + return value; + } + + @override + String visitNonPrimitiveType(ReferredType node) { + final typeClass = node.accept(_TypeClassGenerator(resolver)).name; + return '$typeClass.fromRef($value)'; + } +} + +class _FieldGenerator extends Visitor { + const _FieldGenerator(this.config, this.resolver, this.s); + + final Config config; + final Resolver? resolver; + final StringSink s; + + void writeCAccessor(Field node) { + final name = node.finalName; + final cName = node.accept(const CFieldName()); + final ifRef = node.isStatic ? '' : '$_jPointer, '; + + s.write(''' + static final _get_$name = + $_lookup<$_ffi.NativeFunction<$_jResult Function($ifRef)>>( + "get_$cName") + .asFunction<$_jResult Function($ifRef)>(); + +'''); + + if (!node.isFinal) { + final ffiSig = node.type.accept(const _TypeSig(isFfi: true)); + final dartSig = node.type.accept(const _TypeSig(isFfi: false)); + s.write(''' + static final _set_$name = + $_lookup<$_ffi.NativeFunction<$_jThrowable Function($ifRef$ffiSig)>>( + "set_$cName") + .asFunction<$_jThrowable Function($ifRef$dartSig)>(); + +'''); + } + } + + String cGetter(Field node) { + final name = node.finalName; + final getter = node.type.accept(const _JniResultGetter()); + final self = node.isStatic ? '' : _selfPointer; + return '_get_$name($self).$getter'; + } + + String cSetter(Field node) { + final name = node.finalName; + final self = node.isStatic ? '' : '$_selfPointer, '; + final toNativeSuffix = node.type.accept(const _ToNativeSuffix()); + return '_set_$name(${self}value$toNativeSuffix)'; + } + + void writeDartOnlyAccessor(Field node) { + final name = node.finalName; + final ifStatic = node.isStatic ? 'Static' : ''; + final descriptor = node.type.accept(const Descriptor()); + s.write(''' + static final _id_$name = + $_accessors.get${ifStatic}FieldIDOf( + $_classRef, + r"${node.name}", + r"$descriptor", + ); +'''); + } + + String dartOnlyGetter(Field node) { + final name = node.finalName; + final self = node.isStatic ? _classRef : _selfPointer; + final ifStatic = node.isStatic ? 'Static' : ''; + final callType = node.type.accept(const _CallType()); + final resultGetter = node.type.accept(const _JniResultGetter()); + return '$_accessors.get${ifStatic}Field($self, _id_$name, $callType)' + '.$resultGetter'; + } + + String dartOnlySetter(Field node) { + final name = node.finalName; + final self = node.isStatic ? _classRef : _selfPointer; + final ifStatic = node.isStatic ? 'Static' : ''; + final fieldType = node.type.accept(const _TypeName()).capitalize(); + final toNativeSuffix = node.type.accept(const _ToNativeSuffix()); + return '$_env.Set$ifStatic${fieldType}Field($self, _id_$name, value$toNativeSuffix)'; + } + + void writeDocs(Field node, {required bool writeDeleteInstructions}) { + final originalDecl = '${node.type.shorthand} ${node.name}'; + s.writeln(' /// from: ${node.modifiers.join(' ')} $originalDecl'); + if (node.type.kind != Kind.primitive && writeDeleteInstructions) { + s.writeln(_deleteInstruction); + } + node.javadoc?.accept(_DocGenerator(s, depth: 1)); + } + + @override + void visit(Field node) { + final isCBased = config.outputConfig.bindingsType == BindingsType.cBased; + + // Check if it should be a `static const` getter. + if (node.isFinal && node.isStatic && node.defaultValue != null) { + final name = node.finalName; + final value = node.defaultValue!; + // TODO(#31): Should we leave String as a normal getter instead? + if (value is String || value is num || value is bool) { + writeDocs(node, writeDeleteInstructions: false); + s.write(' static const $name = '); + if (value is String) { + s.write('r"""$value"""'); + } else { + s.write(value); + } + s.writeln(';\n'); + return; + } + } + + // Accessors + (isCBased ? writeCAccessor : writeDartOnlyAccessor)(node); + + // Getter docs + writeDocs(node, writeDeleteInstructions: true); + + final name = node.finalName; + final ifStatic = node.isStatic ? 'static ' : ''; + final type = node.type.accept(_TypeGenerator(resolver)); + s.write('$ifStatic$type get $name => '); + s.write(node.type.accept( + _FromNative(resolver, (isCBased ? cGetter : dartOnlyGetter)(node)), + )); + s.writeln(';\n'); + if (!node.isFinal) { + // Setter docs + writeDocs(node, writeDeleteInstructions: true); + + s.write('${ifStatic}set $name($type value) => '); + s.write((isCBased ? cSetter : dartOnlySetter)(node)); + s.writeln(';\n'); + } + } +} + +class _MethodTypeSig extends Visitor { + const _MethodTypeSig({required this.isFfi}); + + final bool isFfi; + + @override + String visit(Method node) { + final args = [ + if (!node.isCtor && !node.isStatic) _voidPointer, + ...node.params.map((param) => param.type).accept( + _TypeSig(isFfi: isFfi), + ) + ].join(', '); + return '$_jResult Function($args)'; + } +} + +/// Generates Dart bindings for Java methods. +class _MethodGenerator extends Visitor { + const _MethodGenerator(this.config, this.resolver, this.s); + + final Config config; + final Resolver? resolver; + final StringSink s; + + void writeCAccessor(Method node) { + final name = node.finalName; + final cName = node.accept(const CMethodName()); + final ffiSig = node.accept(const _MethodTypeSig(isFfi: true)); + final dartSig = node.accept(const _MethodTypeSig(isFfi: false)); + s.write(''' + static final _$name = + $_lookup<$_ffi.NativeFunction<$ffiSig>>("$cName") + .asFunction<$dartSig>(); + +'''); + } + + void writeDartOnlyAccessor(Method node) { + final name = node.finalName; + final ifStatic = node.isStatic ? 'Static' : ''; + final signature = node.accept(const MethodSignature()); + s.write(''' + static final _id_$name = $_accessors.get${ifStatic}MethodIDOf( + $_classRef, r"${node.name}", r"$signature"); + +'''); + } + + bool isSuspendFun(Method node) { + return node.asyncReturnType != null; + } + + String cCtor(Method node) { + final name = node.finalName; + final params = node.params.accept(const _ParamCall()).join(', '); + return '_$name($params)'; + } + + String dartOnlyCtor(Method node) { + final name = node.finalName; + final params = node.params.accept(const _ParamCall()).join(', '); + return '$_accessors.newObjectWithArgs($_classRef, _id_$name, [$params])'; + } + + String cMethodCall(Method node) { + final name = node.finalName; + final params = [ + if (!node.isStatic) _selfPointer, + ...node.params.accept(const _ParamCall()), + ].join(', '); + final resultGetter = node.returnType.accept(const _JniResultGetter()); + return '_$name($params).$resultGetter'; + } + + String dartOnlyMethodCall(Method node) { + final name = node.finalName; + final ifStatic = node.isStatic ? 'Static' : ''; + final self = node.isStatic ? _classRef : _selfPointer; + final callType = node.returnType.accept(const _CallType()); + final params = node.params.accept(const _ParamCall()).join(', '); + final resultGetter = node.returnType.accept(const _JniResultGetter()); + return '$_accessors.call${ifStatic}MethodWithArgs($self, _id_$name, $callType, [$params]).$resultGetter'; + } + + @override + void visit(Method node) { + final isCBased = config.outputConfig.bindingsType == BindingsType.cBased; + + // Accessors + (isCBased ? writeCAccessor : writeDartOnlyAccessor)(node); + + // Docs + s.write(' /// from: '); + s.writeAll(node.modifiers.map((m) => '$m ')); + s.write('${node.returnType.shorthand} ${node.name}('); + s.writeAll(node.params.map((p) => '${p.type.shorthand} ${p.name}'), ', '); + s.writeln(')'); + if (node.returnType.kind != Kind.primitive || node.isCtor) { + s.writeln(_deleteInstruction); + } + node.javadoc?.accept(_DocGenerator(s, depth: 1)); + + if (node.isCtor) { + final className = node.classDecl.finalName; + final name = node.finalName; + final ctorName = name == 'ctor' ? className : '$className.$name'; + final paramsDef = [ + ...node.classDecl.allTypeParams.accept(const _ClassTypeParamDef()), + ...node.params.accept(_ParamDef(resolver)), + ].join(', '); + final superClass = (node.classDecl.superclass!.type as DeclaredType); + final superTypeClassesCall = superClass.classDecl == ClassDecl.object + ? '' + : superClass.params + .accept(_TypeClassGenerator(resolver)) + .map((typeClass) => '${typeClass.name},') + .join(_newLine(depth: 2)); + final ctorExpr = (isCBased ? cCtor : dartOnlyCtor)(node); + s.write(''' + $ctorName($paramsDef) : super.fromRef( + $superTypeClassesCall + $ctorExpr.object + ); + +'''); + return; + } + + final name = node.finalName; + final returnType = isSuspendFun(node) + ? 'Future<${node.asyncReturnType!.accept(_TypeGenerator(resolver))}>' + : node.returnType.accept(_TypeGenerator(resolver)); + final returnTypeClass = (node.asyncReturnType ?? node.returnType) + .accept(_TypeClassGenerator(resolver)) + .name; + final ifStatic = node.isStatic ? 'static ' : ''; + final defArgs = [ + ...node.typeParams.accept(const _MethodTypeParamDef()), + ...node.params.accept(_ParamDef(resolver)) + ]; + final typeParamsDef = _encloseIfNotEmpty( + '<', + node.typeParams + .accept(const _TypeParamGenerator(withExtends: true)) + .join(', '), + '>', + ); + if (isSuspendFun(node)) { + defArgs.removeLast(); + } + final params = defArgs.join(', '); + s.write(' $ifStatic$returnType $name$typeParamsDef($params) '); + final callExpr = (isCBased ? cMethodCall : dartOnlyMethodCall)(node); + if (isSuspendFun(node)) { + final returning = + node.asyncReturnType!.accept(_FromNative(resolver, '\$o')); + s.write('''async { + final \$p = ReceivePort(); + final \$c = $_jObject.fromRef($_jni.Jni.newPortContinuation(\$p)); + $callExpr; + final \$o = $_jPointer.fromAddress(await \$p.first); + final \$k = $returnTypeClass.getClass().reference; + if ($_jni.Jni.env.IsInstanceOf(\$o, \$k) == 0) { + throw "Failed"; + } + return $returning; + } + +'''); + } else { + final returning = node.returnType.accept(_FromNative(resolver, callExpr)); + s.writeln('=> $returning;\n'); + } + } +} + +/// Generates the method type param definition. +/// +/// For example `JObjType $T` in: +/// ```dart +/// void bar(JObjType $T, ...) => ... +/// ``` +class _MethodTypeParamDef extends Visitor { + const _MethodTypeParamDef(); + + @override + String visit(TypeParam node) { + return '$_jType<${node.name}> $_typeParamPrefix${node.name}'; + } +} + +/// Generates the class type param definition. Used only in constructors. +/// +/// For example `this.$T` in: +/// ```dart +/// class Foo { +/// final JObjType $T; +/// Foo(this.$T, ...) => ... +/// } +/// ``` +class _ClassTypeParamDef extends Visitor { + const _ClassTypeParamDef(); + + @override + String visit(TypeParam node) { + return 'this.$_typeParamPrefix${node.name}'; + } +} + +/// Method parameter's definition. +/// +/// For example `Foo foo` in: +/// ```dart +/// void bar(Foo foo) => ... +/// ``` +class _ParamDef extends Visitor { + const _ParamDef(this.resolver); + + final Resolver? resolver; + + @override + String visit(Param node) { + final type = node.type.accept(_TypeGenerator(resolver)); + return '$type ${node.finalName}'; + } +} + +/// Method parameter used in calling the native method. +/// +/// For example `foo.reference` in: +/// ```dart +/// void bar(Foo foo) => _bar(foo.reference); +/// ``` +class _ParamCall extends Visitor { + const _ParamCall(); + + @override + String visit(Param node) { + final nativeSuffix = node.type.accept(const _ToNativeSuffix()); + return '${node.finalName}$nativeSuffix'; + } +} diff --git a/pkgs/jnigen/lib/src/bindings/excluder.dart b/pkgs/jnigen/lib/src/bindings/excluder.dart new file mode 100644 index 000000000..88beefd22 --- /dev/null +++ b/pkgs/jnigen/lib/src/bindings/excluder.dart @@ -0,0 +1,61 @@ +// 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 '../config/config.dart'; +import '../elements/elements.dart'; +import '../logging/logging.dart'; +import 'visitor.dart'; + +bool _isPrivate(ClassMember classMember) => + !classMember.isPublic && !classMember.isProtected; + +class Excluder extends Visitor { + const Excluder(this.config); + + final Config config; + + @override + void visit(Classes node) { + node.decls.removeWhere((_, classDecl) { + final excluded = _isPrivate(classDecl) || + !(config.exclude?.classes?.included(classDecl) ?? true); + if (excluded) { + log.fine('Excluded class ${classDecl.binaryName}'); + } + return excluded; + }); + final classExcluder = _ClassExcluder(config); + for (final classDecl in node.decls.values) { + classDecl.accept(classExcluder); + } + } +} + +class _ClassExcluder extends Visitor { + _ClassExcluder(this.config); + + final Config config; + + @override + void visit(ClassDecl node) { + node.methods = node.methods.where((method) { + final included = !_isPrivate(method) && + !method.name.startsWith('_') && + (config.exclude?.methods?.included(node, method) ?? true); + if (!included) { + log.fine('Excluded method ${node.binaryName}#${method.name}'); + } + return included; + }).toList(); + node.fields = node.fields.where((field) { + final included = !_isPrivate(field) && + !field.name.startsWith('_') && + (config.exclude?.fields?.included(node, field) ?? true); + if (!included) { + log.fine('Excluded field ${node.binaryName}#${field.name}'); + } + return included; + }).toList(); + } +} diff --git a/pkgs/jnigen/lib/src/bindings/linker.dart b/pkgs/jnigen/lib/src/bindings/linker.dart new file mode 100644 index 000000000..f4fe617bb --- /dev/null +++ b/pkgs/jnigen/lib/src/bindings/linker.dart @@ -0,0 +1,175 @@ +// 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 'visitor.dart'; +import '../config/config.dart'; +import '../elements/elements.dart'; + +typedef _Resolver = ClassDecl Function(String? binaryName); + +/// Adds references from child elements back to their parent elements. +/// Resolves Kotlin specific `asyncReturnType` for methods. +class Linker extends Visitor { + Linker(this.config); + + final Config config; + + @override + void visit(Classes node) { + final classLinker = _ClassLinker(config, (binaryName) { + return ClassDecl.predefined[binaryName] ?? + node.decls[binaryName] ?? + ClassDecl.object; + }); + for (final classDecl in node.decls.values) { + classDecl.accept(classLinker); + } + } +} + +class _ClassLinker extends Visitor { + _ClassLinker(this.config, this.resolve); + + final Config config; + final _Resolver resolve; + final Set _linked = {...ClassDecl.predefined.values}; + + @override + void visit(ClassDecl node) { + if (_linked.contains(node)) return; + _linked.add(node); + + node.parent = resolve(node.parentName); + node.parent!.accept(this); + // Adding type params of outer classes to the nested classes + final allTypeParams = []; + if (!node.modifiers.contains('static')) { + for (final typeParam in node.parent!.allTypeParams) { + if (!node.allTypeParams.contains(typeParam)) { + // Add only if it's not shadowing another type param. + allTypeParams.add(typeParam); + } + } + } + allTypeParams.addAll(node.typeParams); + node.allTypeParams = allTypeParams; + + final typeLinker = _TypeLinker(resolve); + node.superclass ??= TypeUsage.object; + node.superclass!.type.accept(typeLinker); + final superclass = (node.superclass!.type as DeclaredType).classDecl; + superclass.accept(this); + + final fieldLinker = _FieldLinker(typeLinker); + for (final field in node.fields) { + field.classDecl = node; + field.accept(fieldLinker); + } + final methodLinker = _MethodLinker(config, typeLinker); + for (final method in node.methods) { + method.classDecl = node; + method.accept(methodLinker); + } + node.interfaces.accept(typeLinker).toList(); + node.typeParams.accept(_TypeParamLinker(typeLinker)).toList(); + } +} + +class _MethodLinker extends Visitor { + _MethodLinker(this.config, this.typeVisitor); + + final Config config; + final TypeVisitor typeVisitor; + + @override + void visit(Method node) { + node.returnType.accept(typeVisitor); + final typeParamLinker = _TypeParamLinker(typeVisitor); + final paramLinker = _ParamLinker(typeVisitor); + node.typeParams.accept(typeParamLinker).toList(); + node.params.accept(paramLinker).toList(); + // Kotlin specific + const kotlinContinutationType = 'kotlin.coroutines.Continuation'; + if (config.suspendFunToAsync && + node.params.isNotEmpty && + node.params.last.type.kind == Kind.declared && + node.params.last.type.shorthand == kotlinContinutationType) { + final continuationType = node.params.last.type.type as DeclaredType; + node.asyncReturnType = continuationType.params.isEmpty + ? TypeUsage.object + : continuationType.params.first; + } else { + node.asyncReturnType = null; + } + node.asyncReturnType?.accept(typeVisitor); + } +} + +class _TypeLinker extends TypeVisitor { + const _TypeLinker(this.resolve); + + final _Resolver resolve; + + @override + void visitDeclaredType(DeclaredType node) { + node.params.accept(this).toList(); + node.classDecl = resolve(node.binaryName); + } + + @override + void visitWildcard(Wildcard node) { + node.superBound?.type.accept(this); + node.extendsBound?.type.accept(this); + } + + @override + void visitArrayType(ArrayType node) { + node.type.accept(this); + } + + @override + void visitPrimitiveType(PrimitiveType node) { + // Do nothing + } + + @override + void visitNonPrimitiveType(ReferredType node) { + // Do nothing + } +} + +class _FieldLinker extends Visitor { + _FieldLinker(this.typeVisitor); + + final TypeVisitor typeVisitor; + + @override + void visit(Field node) { + node.type.accept(typeVisitor); + } +} + +class _TypeParamLinker extends Visitor { + _TypeParamLinker(this.typeVisitor); + + final TypeVisitor typeVisitor; + + @override + void visit(TypeParam node) { + for (final bound in node.bounds) { + bound.accept(typeVisitor); + } + } +} + +class _ParamLinker extends Visitor { + _ParamLinker(this.typeVisitor); + + final TypeVisitor typeVisitor; + + @override + void visit(Param node) { + node.type.accept(typeVisitor); + } +} diff --git a/pkgs/jnigen/lib/src/bindings/preprocessor.dart b/pkgs/jnigen/lib/src/bindings/preprocessor.dart deleted file mode 100644 index 0003f223f..000000000 --- a/pkgs/jnigen/lib/src/bindings/preprocessor.dart +++ /dev/null @@ -1,166 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -import 'package:jnigen/src/elements/elements.dart'; -import 'package:jnigen/src/config/config.dart'; -import 'package:jnigen/src/logging/logging.dart'; -import 'package:jnigen/src/util/rename_conflict.dart'; - -import 'common.dart'; - -/// Preprocessor which fills information needed by both Dart and C generators. -abstract class ApiPreprocessor { - static const kotlinContinutationType = 'kotlin.coroutines.Continuation'; - - static void preprocessAll(Map classes, Config config, - {bool renameClasses = false}) { - final classNameCounts = {}; - for (final c in classes.values) { - final className = getSimplifiedClassName(c.binaryName); - c.uniqueName = renameConflict(classNameCounts, className); - if (renameClasses) { - c.finalName = c.uniqueName; - } else { - c.finalName = className; - } - _preprocess(c, classes, config); - } - // Adding type params of outer classes to the nested classes - final visited = {}; - for (final c in classes.values) { - _traverseAddTypeParams(visited, c); - } - } - - static void _preprocess( - ClassDecl decl, Map classes, Config config) { - if (decl.isPreprocessed) return; - - if (!_isClassIncluded(decl, config)) { - decl.isIncluded = false; - decl.isPreprocessed = true; - log.fine('exclude class ${decl.binaryName}'); - // Excluding all the class's methods and fields - for (final method in decl.methods) { - method.isIncluded = false; - } - for (final field in decl.fields) { - field.isIncluded = false; - } - return; - } - if (decl.parentName != null && classes.containsKey(decl.parentName!)) { - decl.parent = classes[decl.parentName]; - } - ClassDecl? superclass; - if (decl.superclass != null && classes.containsKey(decl.superclass?.name)) { - superclass = classes[decl.superclass!.name]!; - _preprocess(superclass, classes, config); - // again, un-consider superclass if it was excluded through config - if (!superclass.isIncluded) { - superclass = null; - } else { - decl.nameCounts.addAll(superclass.nameCounts); - } - } - log.finest('Superclass of ${decl.binaryName} resolved to ' - '${superclass?.binaryName}'); - for (var field in decl.fields) { - if (!_isFieldIncluded(decl, field, config)) { - field.isIncluded = false; - log.fine('exclude ${decl.binaryName}#${field.name}'); - continue; - } - field.finalName = renameConflict(decl.nameCounts, field.name); - } - - for (var method in decl.methods) { - if (!_isMethodIncluded(decl, method, config)) { - method.isIncluded = false; - log.fine('exclude method ${decl.binaryName}#${method.name}'); - continue; - } - if (config.suspendFunToAsync && - method.params.isNotEmpty && - method.params.last.type.kind == Kind.declared && - method.params.last.type.shorthand == kotlinContinutationType) { - final continuationType = method.params.last.type.type as DeclaredType; - method.asyncReturnType = continuationType.params.isEmpty - ? TypeUsage.object - : continuationType.params.first; - } else { - method.asyncReturnType = null; - } - - var realName = method.name; - if (isCtor(method)) { - realName = 'ctor'; - } - final sig = method.javaSig; - // if method already in super class, assign its number, overriding it. - final superNum = superclass?.methodNumsAfterRenaming[sig]; - if (superNum != null) { - // TODO(#29): this logic would better live in a dedicated renamer class. - // don't rename if superNum == 0 - // unless the method name is a keyword. - final superNumText = superNum == 0 ? '' : '$superNum'; - final methodName = superNum == 0 ? kwRename(realName) : realName; - method.finalName = '$methodName$superNumText'; - decl.methodNumsAfterRenaming[sig] = superNum; - } else { - method.finalName = renameConflict(decl.nameCounts, realName); - // TODO(#29): This is too much coupled with renameConflict impl. - // see the above todo. - decl.methodNumsAfterRenaming[sig] = decl.nameCounts[realName]! - 1; - } - } - decl.isPreprocessed = true; - log.fine('preprocessed ${decl.binaryName}'); - } - - /// Gathers all the type params from ancestors of a [ClassDecl] and store - /// them in [allTypeParams]. - /// - /// Class A is a parent of Class B when B is nested inside A. - static void _traverseAddTypeParams(Set visited, ClassDecl decl) { - if (visited.contains(decl)) { - // The type params of its ancestors have already been added. - return; - } - final allTypeParams = []; - if (decl.parent != null) { - // Adding all type params of parent's ancestors to the parent. - if (!visited.contains(decl.parent) && decl.parent != decl) { - _traverseAddTypeParams(visited, decl.parent!); - } - // Adding the type params of ancestors if the class is not static. - if (!decl.modifiers.contains('static')) { - for (final typeParam in decl.parent!.allTypeParams) { - if (!decl.allTypeParams.contains(typeParam)) { - // Add only if it's not shadowing another type param. - allTypeParams.add(typeParam); - } - } - } - } - allTypeParams.addAll(decl.typeParams); - decl.allTypeParams = allTypeParams; - visited.add(decl); - } - - static bool _isPublicOrProtected(Set modifiers) => - modifiers.contains("public") || modifiers.contains("protected"); - - static bool _isFieldIncluded(ClassDecl decl, Field field, Config config) => - _isPublicOrProtected(field.modifiers) && - !field.name.startsWith('_') && - config.exclude?.fields?.included(decl, field) != false; - static bool _isMethodIncluded(ClassDecl decl, Method method, Config config) => - _isPublicOrProtected(method.modifiers) && - !method.name.startsWith('_') && - config.exclude?.methods?.included(decl, method) != false; - static bool _isClassIncluded(ClassDecl decl, Config config) => - _isPublicOrProtected(decl.modifiers) && - config.exclude?.classes?.included(decl) != false; -} diff --git a/pkgs/jnigen/lib/src/bindings/pure_dart_bindings.dart b/pkgs/jnigen/lib/src/bindings/pure_dart_bindings.dart deleted file mode 100644 index 67ceeed84..000000000 --- a/pkgs/jnigen/lib/src/bindings/pure_dart_bindings.dart +++ /dev/null @@ -1,286 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -import 'package:jnigen/src/elements/elements.dart'; -import 'package:jnigen/src/config/config.dart'; -import 'package:jnigen/src/logging/logging.dart'; - -import 'symbol_resolver.dart'; -import 'common.dart'; - -class PureDartBindingsGenerator extends BindingsGenerator { - static final indent = BindingsGenerator.indent; - static const accessors = 'jniAccessors'; - static const env = 'jniEnv'; - - /// Name for reference in base class. - static const selfPointer = BindingsGenerator.selfPointer; - - /// Name of field holding class reference. - static const classRef = '_classRef'; - - static const ffi = BindingsGenerator.ffi; - static const jni = BindingsGenerator.jni; - - static const voidPointer = BindingsGenerator.jobjectType; - static const ffiVoidType = BindingsGenerator.ffiVoidType; - static const jniObjectType = BindingsGenerator.jniObjectType; - - static final _deleteInstruction = BindingsGenerator.deleteInstruction; - - String escapeDollarSign(String s) => s.replaceAll('\$', '\\\$'); - - PureDartBindingsGenerator(this.config); - final Config config; - - @override - String generateBindings(ClassDecl decl, SymbolResolver resolver) { - if (!decl.isPreprocessed) { - throw StateError( - 'Java class declaration ${decl.binaryName} must be preprocessed before' - 'being passed to bindings generator'); - } - if (!decl.isIncluded) { - return ''; - } - final bindings = _class(decl, resolver); - log.fine('generated bindings for class ${decl.binaryName}'); - return bindings; - } - - String _class(ClassDecl decl, SymbolResolver resolver) { - final s = StringBuffer(); - - s.write('/// from: ${decl.binaryName}\n'); - s.write(breakDocComment(decl.javadoc, depth: '')); - - final internalName = escapeDollarSign(getInternalName(decl.binaryName)); - - s.write(dartClassDefinition(decl, resolver)); - s.write( - '${indent}static final $classRef = $accessors.getClassOf("$internalName");\n'); - - s.write(dartStaticTypeGetter(decl)); - for (var field in decl.fields) { - if (!field.isIncluded) continue; - try { - s.write(_field(decl, field, resolver)); - s.writeln(); - } on SkipException catch (e) { - log.fine('skip field ${decl.binaryName}#${field.name}: ' - '${e.message}'); - } - } - - for (var method in decl.methods) { - if (!method.isIncluded) { - continue; - } - try { - s.write(_method(decl, method, resolver)); - s.writeln(); - } on SkipException catch (e) { - log.fine('skip field ${decl.binaryName}#${method.name}: ' - '${e.message}'); - } - } - s.write("}\n"); - s.write(dartTypeClass(decl)); - s.write(dartArrayExtension(decl)); - return s.toString(); - } - - @override - String toNativeArg(String name, TypeUsage type, - {bool convertBooleanToInt = false}) { - return super - .toNativeArg(name, type, convertBooleanToInt: convertBooleanToInt); - } - - @override - String actualArgs(Method m, {bool addSelf = false}) { - return super.actualArgs(m, addSelf: addSelf); - } - - String _method(ClassDecl c, Method m, SymbolResolver resolver) { - final name = m.finalName; - final isStatic = isStaticMethod(m); - final ifStatic = isStatic ? 'Static' : ''; - final s = StringBuffer(); - final mID = '_id_$name'; - final jniSignature = escapeDollarSign(getJniSignatureForMethod(m)); - - s.write('static final $mID = $accessors.get${ifStatic}MethodIDOf(' - '$classRef, "${m.name}", "$jniSignature");\n'); - - // Different logic for constructor and method; - // For constructor, we want return type to be new object. - var returnType = getDartOuterType( - m.asyncReturnType ?? m.returnType, - resolver, - ); - if (m.asyncReturnType != null) { - returnType = toFuture(returnType); - } - final returnTypeClass = - getDartTypeClass(m.asyncReturnType ?? m.returnType, resolver); - s.write('$indent/// from: ${getOriginalMethodHeader(m)}\n'); - if (!isPrimitive(m.returnType) || isCtor(m)) { - s.write(_deleteInstruction); - } - s.write(breakDocComment(m.javadoc)); - if (isCtor(m)) { - final wrapperExpr = - '$accessors.newObjectWithArgs($classRef, $mID, [${actualArgs(m)}]).object'; - final className = c.finalName; - final ctorFnName = name == 'ctor' ? className : '$className.$name'; - s.write( - '$ctorFnName(${getFormalArgs(c, m, resolver)}) : ' - 'super.fromRef(${dartSuperArgs(c, resolver)}$wrapperExpr);\n', - ); - return s.toString(); - } - - s.write(indent); - if (isStatic) { - s.write('static '); - } - final selfArgument = isStatic ? classRef : selfPointer; - final callType = getCallType(m.returnType); - final resultGetter = getResultGetterName(m.returnType); - final typeParamsWithExtend = - dartTypeParams(m.typeParams, includeExtends: true); - var wrapperExpr = '$accessors.call${ifStatic}MethodWithArgs' - '($selfArgument, $mID, $callType, [${actualArgs(m)}])' - '.$resultGetter'; - s.write( - '$returnType $name$typeParamsWithExtend(${getFormalArgs(c, m, resolver)}) ', - ); - if (m.asyncReturnType == null) { - wrapperExpr = toDartResult(wrapperExpr, m.returnType, returnTypeClass); - s.write('=> $wrapperExpr;\n'); - } else { - s.write( - 'async {\n' - '${indent * 2}final \$p = ReceivePort();\n' - '${indent * 2}final \$c = ${jni}Jni.newPortContinuation(\$p);\n' - '${indent * 2}$wrapperExpr;\n' - '${indent * 2}final \$o = $voidPointer.fromAddress(await \$p.first);\n' - '${indent * 2}final \$k = $returnTypeClass.getClass().reference;\n' - '${indent * 2}if (${jni}Jni.env.IsInstanceOf(\$o, \$k) == 0) {\n' - '${indent * 3}throw "Failed";\n' - '${indent * 2}}\n' - '${indent * 2}return ${toDartResult( - '\$o', - m.returnType, - returnTypeClass, - )};\n' - '}\n', - ); - } - return s.toString(); - } - - String _field(ClassDecl c, Field f, SymbolResolver resolver) { - final name = f.finalName; - final isStatic = isStaticField(f); - final ifStatic = isStatic ? 'Static' : ''; - final isFinal = isFinalField(f); - final s = StringBuffer(); - final selfArgument = isStatic ? classRef : selfPointer; - final callType = getCallType(f.type); - final resultGetter = getResultGetterName(f.type); - final outerType = getDartOuterType(f.type, resolver); - - void writeDocs({bool writeDeleteInstruction = true}) { - s.write('$indent/// from: ${getOriginalFieldDecl(f)}\n'); - if (!isPrimitive(f.type) && writeDeleteInstruction) { - s.write(_deleteInstruction); - } - s.write(breakDocComment(f.javadoc)); - } - - if (isStatic && isFinal && f.defaultValue != null) { - writeDocs(writeDeleteInstruction: false); - s.write( - '${indent}static const $name = ${getDartLiteral(f.defaultValue)};\n'); - return s.toString(); - } - final jniSignature = escapeDollarSign(getDescriptor(f.type)); - final fID = '_id_$name'; - s.write('static final $fID = ' - '$accessors.get${ifStatic}FieldIDOf(_classRef, ' - '"${f.name}","$jniSignature");\n'); - void writeAccessor({bool setter = false}) { - writeDocs(); - s.write(indent); - if (isStatic) s.write('static '); - if (setter) { - final fieldType = getTypeNameAtCallSite(f.type); - s.write('set $name($outerType value) => $env.Set$ifStatic' - '${fieldType}Field($selfArgument, $fID, ' - '${toNativeArg("value", f.type, convertBooleanToInt: true)});\n'); - } else { - final outer = getDartOuterType(f.type, resolver); - final typeClass = getDartTypeClass(f.type, resolver); - final callExpr = - '$accessors.get${ifStatic}Field($selfArgument, $fID, $callType)' - '.$resultGetter'; - final resultExpr = toDartResult(callExpr, f.type, typeClass); - s.write('$outer get $name => $resultExpr;\n'); - } - } - - writeAccessor(setter: false); - if (!isFinalField(f)) writeAccessor(setter: true); - return s.toString(); - } - - static const autoGeneratedNotice = '// Autogenerated by jnigen. ' - 'DO NOT EDIT!\n\n'; - static const defaultLintSuppressions = - '// ignore_for_file: annotate_overrides\n' - '// ignore_for_file: camel_case_extensions\n' - '// ignore_for_file: camel_case_types\n' - '// ignore_for_file: constant_identifier_names\n' - '// ignore_for_file: file_names\n' - '// ignore_for_file: no_leading_underscores_for_local_identifiers\n' - '// ignore_for_file: non_constant_identifier_names\n' - '// ignore_for_file: overridden_fields\n' - '// ignore_for_file: unnecessary_cast\n' - '// ignore_for_file: unused_element\n' - '// ignore_for_file: unused_field\n' - '// ignore_for_file: unused_import\n' - '// ignore_for_file: unused_shown_name\n' - '\n'; - - static const dartImports = 'import "dart:isolate" show ReceivePort;\n\n'; - static const jniImport = 'import "package:jni/jni.dart" as jni;\n\n'; - static const internalHelpersImport = - 'import "package:jni/internal_helpers_for_jnigen.dart";\n\n'; - static const defaultImports = dartImports + jniImport + internalHelpersImport; - - static const initialization = 'final jniEnv = ${jni}Jni.env;\n' - 'final jniAccessors = ${jni}Jni.accessors;\n\n'; - static String initImport(String initFilePath) => - 'import "$initFilePath" show jniEnv, jniAccessors;\n\n'; - - @override - String getPostImportBoilerplate([String? initFilePath]) { - return (config.outputConfig.dartConfig.structure == - OutputStructure.singleFile) - ? initialization - : initImport(initFilePath!); - } - - @override - String getPreImportBoilerplate([String? initFilePath]) { - return autoGeneratedNotice + defaultLintSuppressions + defaultImports; - } - - @override - String getInitFileContents() { - return jniImport + initialization; - } -} diff --git a/pkgs/jnigen/lib/src/bindings/renamer.dart b/pkgs/jnigen/lib/src/bindings/renamer.dart new file mode 100644 index 000000000..e9fbda924 --- /dev/null +++ b/pkgs/jnigen/lib/src/bindings/renamer.dart @@ -0,0 +1,262 @@ +// 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 '../config/config.dart'; +import '../elements/elements.dart'; +import '../logging/logging.dart'; +import 'visitor.dart'; + +const Set _keywords = { + 'abstract', + 'as', + 'assert', + 'async', + 'await', + 'break', + 'case', + 'catch', + 'class', + 'const', + 'continue', + 'covariant', + 'default', + 'deferred', + 'do', + 'dynamic', + 'else', + 'enum', + 'export', + 'extends', + 'extension', + 'external', + 'factory', + 'false', + 'final', + 'finally', + 'for', + 'Function', + 'get', + 'hide', + 'if', + 'implements', + 'import', + 'in', + 'interface', + 'is', + 'late', + 'library', + 'mixin', + 'new', + 'null', + 'on', + 'operator', + 'part', + 'required', + 'rethrow', + 'return', + 'set', + 'show', + 'static', + 'super', + 'switch', + 'sync', + 'this', + 'throw', + 'true', + 'try', + 'typedef', + 'var', + 'void', + 'while', + 'with', + 'yield', +}; + +/// Methods & properties already defined by dart JObject base class. +const Map _definedSyms = { + 'equals': 1, + 'toString': 1, + 'hashCode': 1, + 'runtimeType': 1, + 'noSuchMethod': 1, + 'reference': 1, + 'isDeleted': 1, + 'isNull': 1, + 'use': 1, + 'delete': 1, + 'getFieldID': 1, + 'getStaticFieldID': 1, + 'getMethodID': 1, + 'getStaticMethodID': 1, + 'getField': 1, + 'getFieldByName': 1, + 'getStaticField': 1, + 'getStaticFieldByName': 1, + 'callMethod': 1, + 'callMethodByName': 1, + 'callStaticMethod': 1, + 'callStaticMethodByName': 1, +}; + +/// Appends 0 to [name] if [name] is a keyword. +/// +/// Examples: +/// * `int` -> `int0` +/// * `i` -> `i` +String _keywordRename(String name) => + _keywords.contains(name) ? '${name}0' : name; + +String _renameConflict(Map counts, String name) { + if (counts.containsKey(name)) { + final count = counts[name]!; + final renamed = '$name$count'; + counts[name] = count + 1; + return renamed; + } + counts[name] = 1; + return _keywordRename(name); +} + +class Renamer implements Visitor { + Renamer(this.config); + final Config config; + + @override + void visit(Classes node) { + final classRenamer = _ClassRenamer(config); + + for (final classDecl in node.decls.values) { + classDecl.accept(classRenamer); + } + } +} + +class _ClassRenamer implements Visitor { + _ClassRenamer( + this.config, + ); + + final Config config; + final Map classNameCounts = {}; + final Set renamed = {...ClassDecl.predefined.values}; + final Map> nameCounts = { + for (final predefined in ClassDecl.predefined.values) ...{ + predefined: {..._definedSyms}, + } + }; + final Map> methodNumsAfterRenaming = {}; + + /// Returns class name as useful in dart. + /// + /// Eg -> a.b.X.Y -> X_Y + static String _getSimplifiedClassName(String binaryName) => + binaryName.split('.').last.replaceAll('\$', '_'); + + @override + void visit(ClassDecl node) { + if (renamed.contains(node)) return; + renamed.add(node); + + nameCounts[node] = {..._definedSyms}; + methodNumsAfterRenaming[node] = {}; + + final className = _getSimplifiedClassName(node.binaryName); + node.uniqueName = _renameConflict(classNameCounts, className); + + // When generating all the classes in a single file + // the names need to be unique. + final uniquifyName = + config.outputConfig.dartConfig.structure == OutputStructure.singleFile; + node.finalName = uniquifyName ? node.uniqueName : className; + log.fine('Class ${node.binaryName} is named ${node.finalName}'); + + final superClass = (node.superclass!.type as DeclaredType).classDecl; + superClass.accept(this); + nameCounts[node]!.addAll(nameCounts[superClass]!); + final methodRenamer = _MethodRenamer( + config, + nameCounts[node]!, + methodNumsAfterRenaming, + ); + for (final method in node.methods) { + method.accept(methodRenamer); + } + + final fieldRenamer = _FieldRenamer(config, nameCounts[node]!); + for (final field in node.fields) { + field.accept(fieldRenamer); + } + } +} + +class _MethodRenamer implements Visitor { + _MethodRenamer(this.config, this.nameCounts, this.methodNumsAfterRenaming); + + final Config config; + final Map nameCounts; + final Map> methodNumsAfterRenaming; + + @override + void visit(Method node) { + final name = node.name == '' ? 'ctor' : node.name; + final sig = node.javaSig; + // If node is in super class, assign its number, overriding it. + final superClass = + (node.classDecl.superclass!.type as DeclaredType).classDecl; + final superNum = methodNumsAfterRenaming[superClass]?[sig]; + if (superNum != null) { + // Don't rename if superNum == 0 + // Unless the node name is a keyword. + final superNumText = superNum == 0 ? '' : '$superNum'; + final methodName = superNum == 0 ? _keywordRename(name) : name; + node.finalName = '$methodName$superNumText'; + methodNumsAfterRenaming[node.classDecl]?[sig] = superNum; + } else { + node.finalName = _renameConflict(nameCounts, name); + methodNumsAfterRenaming[node.classDecl]?[sig] = nameCounts[name]! - 1; + } + log.fine( + 'Method ${node.classDecl.binaryName}#${node.name} is named ${node.finalName}'); + + final paramRenamer = _ParamRenamer(config); + for (final param in node.params) { + param.accept(paramRenamer); + } + + // Kotlin specific + if (node.asyncReturnType != null) { + // It's a suspend fun so the continuation parameter + // should be named $c instead + node.params.last.finalName = '\$c'; + } + } +} + +class _FieldRenamer implements Visitor { + _FieldRenamer(this.config, this.nameCounts); + + final Config config; + final Map nameCounts; + + @override + void visit(Field node) { + node.finalName = _renameConflict( + nameCounts, + node.name, + ); + log.fine( + 'Field ${node.classDecl.binaryName}#${node.name} is named ${node.finalName}'); + } +} + +class _ParamRenamer implements Visitor { + _ParamRenamer(this.config); + + final Config config; + + @override + void visit(Param node) { + node.finalName = _keywordRename(node.name); + } +} diff --git a/pkgs/jnigen/lib/src/bindings/resolver.dart b/pkgs/jnigen/lib/src/bindings/resolver.dart new file mode 100644 index 000000000..cc7a45eb4 --- /dev/null +++ b/pkgs/jnigen/lib/src/bindings/resolver.dart @@ -0,0 +1,155 @@ +// 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 'dart:math'; + +import '../logging/logging.dart'; + +class Resolver { + Resolver({ + required this.importMap, + required this.currentClass, + this.inputClassNames = const {}, + }); + + static const Map predefined = { + 'java.lang.String': 'jni.', + }; + + /// Class corresponding to currently writing file. + final String currentClass; + + /// Explicit import mappings. + final Map importMap; + + /// Names of all classes in input. + final Set inputClassNames; + + final List importStrings = []; + + final Set _relativeImportedClasses = {}; + final Map _importedNameToClass = {}; + final Map _classToImportedName = {}; + + static String getFileClassName(String binaryName) { + final dollarSign = binaryName.indexOf('\$'); + if (dollarSign != -1) { + return binaryName.substring(0, dollarSign); + } + return binaryName; + } + + /// splits [str] into 2 from last occurence of [sep] + static List cutFromLast(String str, String sep) { + final li = str.lastIndexOf(sep); + if (li == -1) { + return ['', str]; + } + return [str.substring(0, li), str.substring(li + 1)]; + } + + /// Get the prefix for the class + String resolvePrefix(String binaryName) { + if (predefined.containsKey(binaryName)) { + return predefined[binaryName]!; + } + final target = getFileClassName(binaryName); + + if (target == currentClass && inputClassNames.contains(binaryName)) { + return ''; + } + + if (_classToImportedName.containsKey(target)) { + // This package was already resolved + // but we still need to check if it was a relative import, in which case + // the class not in inputClassNames cannot be mapped here. + if (!_relativeImportedClasses.contains(target) || + inputClassNames.contains(binaryName)) { + final importedName = _classToImportedName[target]; + return '$importedName.'; + } + } + + final classImport = getImport(target, binaryName); + log.finest('$target resolved to $classImport for $binaryName'); + if (classImport == null) { + return ''; + } + + final pkgName = cutFromLast(target, '.')[1].toLowerCase(); + if (pkgName.isEmpty) { + throw UnsupportedError('No package could be deduced from ' + 'qualified binaryName'); + } + + // We always name imports with an underscore suffix, so that they can be + // never shadowed by a parameter or local variable. + var importedName = '${pkgName}_'; + int suffix = 0; + while (_importedNameToClass.containsKey(importedName)) { + suffix++; + importedName = '$pkgName${suffix}_'; + } + + _importedNameToClass[importedName] = target; + _classToImportedName[target] = importedName; + importStrings.add('import "$classImport" as $importedName;\n'); + return '$importedName.'; + } + + /// Returns import string for [classToResolve], or `null` if the class is not + /// found. + /// + /// [binaryName] is the class name trying to be resolved. This parameter is + /// requested so that classes included in current bindings can be resolved + /// using relative path. + String? getImport(String classToResolve, String binaryName) { + var prefix = classToResolve; + + // short circuit if the requested class is specified directly in import map. + if (importMap.containsKey(binaryName)) { + return importMap[binaryName]!; + } + + if (prefix.isEmpty) { + throw UnsupportedError('unexpected: empty package name.'); + } + + final dest = classToResolve.split('.'); + final src = currentClass.split('.'); + // Use relative import when the required class is included in current set + // of bindings. + if (inputClassNames.contains(binaryName)) { + int common = 0; + // find the common prefix path directory of current package, and directory + // of target package + // src.length - 1 simply corresponds to directory of the package. + for (int i = 0; i < src.length - 1 && i < dest.length - 1; i++) { + if (src[i] == dest[i]) { + common++; + } else { + break; + } + } + final pathToCommon = '../' * ((src.length - 1) - common); + final pathToClass = dest.sublist(max(common, 0)).join('/'); + _relativeImportedClasses.add(classToResolve); + return '$pathToCommon$pathToClass.dart'; + } + + while (prefix.isNotEmpty) { + final split = cutFromLast(prefix, '.'); + final left = split[0]; + if (importMap.containsKey(prefix)) { + return importMap[prefix]!; + } + prefix = left; + } + return null; + } + + List getImportStrings() { + return importStrings; + } +} diff --git a/pkgs/jnigen/lib/src/bindings/symbol_resolver.dart b/pkgs/jnigen/lib/src/bindings/symbol_resolver.dart deleted file mode 100644 index 4b158b9bb..000000000 --- a/pkgs/jnigen/lib/src/bindings/symbol_resolver.dart +++ /dev/null @@ -1,17 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -import '../elements/elements.dart'; - -/// Resolves types referred to in method signatures etc.. and provides -/// appropriate imports for them. -abstract class SymbolResolver { - /// Resolve the binary name to a String which can be used in dart code. - String? resolve(String binaryName); - - ClassDecl? resolveClass(String binaryName); - - /// Get all imports for types so far resolved through this resolver. - List getImportStrings(); -} diff --git a/pkgs/jnigen/lib/src/bindings/visitor.dart b/pkgs/jnigen/lib/src/bindings/visitor.dart new file mode 100644 index 000000000..8454cacc9 --- /dev/null +++ b/pkgs/jnigen/lib/src/bindings/visitor.dart @@ -0,0 +1,40 @@ +// 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 '../elements/elements.dart'; + +abstract class Visitor, R> { + const Visitor(); + + R visit(T node); +} + +abstract class TypeVisitor { + const TypeVisitor(); + + R visitNonPrimitiveType(ReferredType node); + R visitPrimitiveType(PrimitiveType node); + R visitArrayType(ArrayType node) => visitNonPrimitiveType(node); + R visitDeclaredType(DeclaredType node) => visitNonPrimitiveType(node); + R visitTypeVar(TypeVar node) => visitNonPrimitiveType(node); + R visitWildcard(Wildcard node) => visitNonPrimitiveType(node); +} + +extension MultiVisitor> on Iterable> { + Iterable accept(Visitor v) { + return map((e) => e.accept(v)); + } +} + +extension MultiTypeVisitor on Iterable { + Iterable accept(TypeVisitor v) { + return map((e) => e.accept(v)); + } +} + +extension MultiTypeUsageVisitor on Iterable { + Iterable accept(TypeVisitor v) { + return map((e) => e.type.accept(v)); + } +} diff --git a/pkgs/jnigen/lib/src/config/config_types.dart b/pkgs/jnigen/lib/src/config/config_types.dart index 9918b06dd..48d6ee072 100644 --- a/pkgs/jnigen/lib/src/config/config_types.dart +++ b/pkgs/jnigen/lib/src/config/config_types.dart @@ -4,13 +4,12 @@ import 'dart:io'; -import 'package:jnigen/src/elements/elements.dart'; +import 'package:logging/logging.dart'; -import 'yaml_reader.dart'; -import 'filters.dart'; +import '../elements/elements.dart'; import 'config_exception.dart'; - -import 'package:logging/logging.dart'; +import 'filters.dart'; +import 'yaml_reader.dart'; /// Configuration for dependencies to be downloaded using maven. /// diff --git a/pkgs/jnigen/lib/src/config/filters.dart b/pkgs/jnigen/lib/src/config/filters.dart index 962a135de..1d0e1a5a4 100644 --- a/pkgs/jnigen/lib/src/config/filters.dart +++ b/pkgs/jnigen/lib/src/config/filters.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. -import 'package:jnigen/src/elements/elements.dart'; +import '../elements/elements.dart'; bool _matchesCompletely(String string, Pattern pattern) { final match = pattern.matchAsPrefix(string); diff --git a/pkgs/jnigen/lib/src/elements/elements.dart b/pkgs/jnigen/lib/src/elements/elements.dart index 1edefc4e4..73476650d 100644 --- a/pkgs/jnigen/lib/src/elements/elements.dart +++ b/pkgs/jnigen/lib/src/elements/elements.dart @@ -2,12 +2,20 @@ // 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:json_annotation/json_annotation.dart'; + // Types to describe java API elements -import 'package:json_annotation/json_annotation.dart'; +import '../bindings/visitor.dart'; part 'elements.g.dart'; +abstract class Element> { + const Element(); + + R accept(Visitor v); +} + @JsonEnum() /// A kind describes the type of a declaration. @@ -20,38 +28,32 @@ enum DeclKind { enumKind, } +class Classes implements Element { + const Classes._(this.decls); + + final Map decls; + + factory Classes.fromJson(List json) { + final decls = {}; + for (final declJson in json) { + final classDecl = ClassDecl.fromJson(declJson); + decls[classDecl.binaryName] = classDecl; + } + return Classes._(decls); + } + + @override + R accept(Visitor v) { + return v.visit(this); + } +} + // Note: We give default values in constructor, if the field is nullable in // JSON. this allows us to reduce JSON size by providing Include.NON_NULL // option in java. @JsonSerializable(createToJson: false) -class ClassDecl { - /// Methods & properties already defined by dart JObject base class. - static const Map _definedSyms = { - 'equals': 1, - 'toString': 1, - 'hashCode': 1, - 'runtimeType': 1, - 'noSuchMethod': 1, - 'reference': 1, - 'isDeleted': 1, - 'isNull': 1, - 'use': 1, - 'delete': 1, - 'getFieldID': 1, - 'getStaticFieldID': 1, - 'getMethodID': 1, - 'getStaticMethodID': 1, - 'getField': 1, - 'getFieldByName': 1, - 'getStaticField': 1, - 'getStaticFieldByName': 1, - 'callMethod': 1, - 'callMethodByName': 1, - 'callStaticMethod': 1, - 'callStaticMethodByName': 1, - }; - +class ClassDecl extends ClassMember implements Element { ClassDecl({ this.annotations = const [], this.javadoc, @@ -70,68 +72,96 @@ class ClassDecl { this.values, }); - List annotations; - JavaDocComment? javadoc; - - Set modifiers; - String simpleName, binaryName; - String? parentName; - String packageName; + @override + final Set modifiers; + + final List annotations; + final JavaDocComment? javadoc; + final String simpleName; + final String binaryName; + final String? parentName; + final String packageName; List typeParams; List methods; List fields; + final List interfaces; + final bool hasStaticInit; + final bool hasInstanceInit; + + /// Will default to java.lang.Object if null by [Linker]. TypeUsage? superclass; - List interfaces; - bool hasStaticInit, hasInstanceInit; - // Contains enum constant names if class is an enum, - // as obtained by `.values()` method in Java. - List? values; - - factory ClassDecl.fromJson(Map json) => - _$ClassDeclFromJson(json); + /// Contains enum constant names if class is an enum, + /// as obtained by `.values()` method in Java. + final List? values; String get internalName => binaryName.replaceAll(".", "/"); - // synthesized attributes - - /// Final name of this class - @JsonKey(includeFromJson: false) - late String finalName; - - /// Parent's [ClassDecl] obtained from [parentName] + /// Parent's [ClassDecl] obtained from [parentName]. + /// + /// Will be populated by [Linker]. @JsonKey(includeFromJson: false) - ClassDecl? parent; + late final ClassDecl? parent; - /// Type parameters including the ones from its ancestors + /// Final name of this class. + /// + /// Will be populated by [Renamer]. @JsonKey(includeFromJson: false) - List allTypeParams = const []; + late final String finalName; /// Unique name obtained by renaming conflicting names with a number. /// /// This is used by C bindings instead of fully qualified name to reduce - /// the verbosity of generated bindings - @JsonKey(includeFromJson: false) - late String uniqueName; - - @JsonKey(includeFromJson: false) - bool isPreprocessed = false; - @JsonKey(includeFromJson: false) - bool isIncluded = true; - - /// Contains number with which certain overload of a method is renamed to, - /// so the overriding method in subclass can be renamed to same final name. + /// the verbosity of generated bindings. + /// + /// Will be populated by [Renamer]. @JsonKey(includeFromJson: false) - Map methodNumsAfterRenaming = {}; + late final String uniqueName; - /// Name counts map, it's a field so that it can be later used by subclasses. + /// Type parameters including the ones from its ancestors + /// + /// Will be populated by [Linker]. @JsonKey(includeFromJson: false) - Map nameCounts = {..._definedSyms}; + List allTypeParams = const []; @override String toString() { return 'Java class declaration for $binaryName'; } + + String get signature => 'L$internalName;'; + + static final object = ClassDecl( + binaryName: 'java.lang.Object', + packageName: 'java.lang', + simpleName: 'Object', + )..finalName = 'JObject'; + + static final string = ClassDecl( + superclass: TypeUsage.object, + binaryName: 'java.lang.String', + packageName: 'java.lang', + simpleName: 'String', + )..finalName = 'JString'; + + static final predefined = { + 'java.lang.Object': object, + 'java.lang.String': string, + }; + + factory ClassDecl.fromJson(Map json) => + _$ClassDeclFromJson(json); + + @override + R accept(Visitor v) { + return v.visit(this); + } + + @override + ClassDecl get classDecl => this; + + @override + String get name => finalName; } @JsonEnum() @@ -156,18 +186,25 @@ class TypeUsage { required this.typeJson, }); - static TypeUsage object = TypeUsage.fromJson({ - "shorthand": "java.lang.Object", - "kind": "DECLARED", - "type": {"binaryName": "java.lang.Object", "simpleName": "Object"} - }); + static TypeUsage object = () { + final typeUsage = TypeUsage.fromJson({ + "shorthand": "java.lang.Object", + "kind": "DECLARED", + "type": {"binaryName": "java.lang.Object", "simpleName": "Object"} + }); + (typeUsage.type as DeclaredType).classDecl = ClassDecl.object; + return typeUsage; + }(); + + final String shorthand; + final Kind kind; - String shorthand; - Kind kind; - @JsonKey(includeFromJson: false) - late ReferredType type; @JsonKey(name: "type") - Map typeJson; + final Map typeJson; + + /// Will be populated in [TypeUsage.fromJson]. + @JsonKey(includeFromJson: false) + late final ReferredType type; String get name => type.name; @@ -195,52 +232,168 @@ class TypeUsage { } return t; } + + R accept(TypeVisitor v) { + return type.accept(v); + } } abstract class ReferredType { + const ReferredType(); String get name; + + R accept(TypeVisitor v); } -@JsonSerializable(createToJson: false) -class PrimitiveType implements ReferredType { - PrimitiveType({required this.name}); +class PrimitiveType extends ReferredType { + static const _primitives = { + 'byte': PrimitiveType._( + name: 'byte', + signature: 'B', + dartType: 'int', + jniType: 'JByte', + cType: 'int8_t', + ffiType: 'Int8', + ), + 'short': PrimitiveType._( + name: 'short', + signature: 'S', + dartType: 'int', + jniType: 'JShort', + cType: 'int16_t', + ffiType: 'Int16', + ), + 'char': PrimitiveType._( + name: 'char', + signature: 'C', + dartType: 'int', + jniType: 'JChar', + cType: 'char', + ffiType: 'Uint16', + ), + 'int': PrimitiveType._( + name: 'int', + signature: 'I', + dartType: 'int', + jniType: 'JInt', + cType: 'int32_t', + ffiType: 'Int32', + ), + 'long': PrimitiveType._( + name: 'long', + signature: 'J', + dartType: 'int', + jniType: 'JLong', + cType: 'int64_t', + ffiType: 'Int64', + ), + 'float': PrimitiveType._( + name: 'float', + signature: 'F', + dartType: 'double', + jniType: 'JFloat', + cType: 'float', + ffiType: 'Float', + ), + 'double': PrimitiveType._( + name: 'double', + signature: 'D', + dartType: 'double', + jniType: 'JDouble', + cType: 'double', + ffiType: 'Double', + ), + 'boolean': PrimitiveType._( + name: 'boolean', + signature: 'Z', + dartType: 'bool', + jniType: 'JBoolean', + cType: 'uint8_t', + ffiType: 'Uint8', + ), + 'void': PrimitiveType._( + name: 'void', + signature: 'V', + dartType: 'void', + jniType: 'JVoid', // Never used + cType: 'void', + ffiType: 'Void', + ), + }; + + const PrimitiveType._({ + required this.name, + required this.signature, + required this.dartType, + required this.jniType, + required this.cType, + required this.ffiType, + }); @override - String name; + final String name; + + final String signature; + final String dartType; + final String jniType; + final String cType; + final String ffiType; - factory PrimitiveType.fromJson(Map json) => - _$PrimitiveTypeFromJson(json); + factory PrimitiveType.fromJson(Map json) { + return _primitives[json['name']]!; + } + + @override + R accept(TypeVisitor v) { + return v.visitPrimitiveType(this); + } } @JsonSerializable(createToJson: false) -class DeclaredType implements ReferredType { +class DeclaredType extends ReferredType { DeclaredType({ required this.binaryName, required this.simpleName, this.params = const [], }); - String binaryName, simpleName; - List params; + + final String binaryName; + final String simpleName; + final List params; + + @JsonKey(includeFromJson: false) + late ClassDecl classDecl; @override String get name => binaryName; factory DeclaredType.fromJson(Map json) => _$DeclaredTypeFromJson(json); + + @override + R accept(TypeVisitor v) { + return v.visitDeclaredType(this); + } } @JsonSerializable(createToJson: false) -class TypeVar implements ReferredType { +class TypeVar extends ReferredType { TypeVar({required this.name}); + @override String name; factory TypeVar.fromJson(Map json) => _$TypeVarFromJson(json); + + @override + R accept(TypeVisitor v) { + return v.visitTypeVar(this); + } } @JsonSerializable(createToJson: false) -class Wildcard implements ReferredType { +class Wildcard extends ReferredType { Wildcard({this.extendsBound, this.superBound}); TypeUsage? extendsBound, superBound; @@ -249,10 +402,15 @@ class Wildcard implements ReferredType { factory Wildcard.fromJson(Map json) => _$WildcardFromJson(json); + + @override + R accept(TypeVisitor v) { + return v.visitWildcard(this); + } } @JsonSerializable(createToJson: false) -class ArrayType implements ReferredType { +class ArrayType extends ReferredType { ArrayType({required this.type}); TypeUsage type; @@ -261,35 +419,58 @@ class ArrayType implements ReferredType { factory ArrayType.fromJson(Map json) => _$ArrayTypeFromJson(json); + + @override + R accept(TypeVisitor v) { + return v.visitArrayType(this); + } } abstract class ClassMember { String get name; + ClassDecl get classDecl; + Set get modifiers; + + bool get isStatic => modifiers.contains('static'); + bool get isFinal => modifiers.contains('final'); + bool get isPublic => modifiers.contains('public'); + bool get isProtected => modifiers.contains('protected'); } @JsonSerializable(createToJson: false) -class Method implements ClassMember { - Method( - {this.annotations = const [], - this.javadoc, - this.modifiers = const {}, - required this.name, - this.typeParams = const [], - this.params = const [], - required this.returnType}); - List annotations; - JavaDocComment? javadoc; - Set modifiers; +class Method extends ClassMember implements Element { + Method({ + this.annotations = const [], + this.javadoc, + this.modifiers = const {}, + required this.name, + this.typeParams = const [], + this.params = const [], + required this.returnType, + }); @override - String name; + final String name; + @override + final Set modifiers; - List typeParams; - List params; - TypeUsage returnType; + final List annotations; + final JavaDocComment? javadoc; + final List typeParams; + final List params; + final TypeUsage returnType; + + /// The [ClassDecl] where this method is defined. + /// + /// Will be populated by [Linker]. + @JsonKey(includeFromJson: false) + @override + late ClassDecl classDecl; + /// Will be populated by [Renamer]. @JsonKey(includeFromJson: false) late String finalName; + @JsonKey(includeFromJson: false) late bool isOverridden; @@ -299,8 +480,6 @@ class Method implements ClassMember { /// and the method has a `kotlin.coroutines.Continuation` final argument. @JsonKey(includeFromJson: false) late TypeUsage? asyncReturnType; - @JsonKey(includeFromJson: false) - bool isIncluded = true; @JsonKey(includeFromJson: false) late String javaSig = _javaSig(); @@ -310,89 +489,136 @@ class Method implements ClassMember { return '${returnType.name} $name($paramNames)'; } + bool get isCtor => name == ''; + factory Method.fromJson(Map json) => _$MethodFromJson(json); + + @override + R accept(Visitor v) { + return v.visit(this); + } } @JsonSerializable(createToJson: false) -class Param { - Param( - {this.annotations = const [], - this.javadoc, - required this.name, - required this.type}); - List annotations; - JavaDocComment? javadoc; +class Param implements Element { + Param({ + this.annotations = const [], + this.javadoc, + required this.name, + required this.type, + }); - String name; - TypeUsage type; + final List annotations; + final JavaDocComment? javadoc; + final String name; + final TypeUsage type; + + /// Will be populated by [Renamer]. + @JsonKey(includeFromJson: false) + late String finalName; factory Param.fromJson(Map json) => _$ParamFromJson(json); + + @override + R accept(Visitor v) { + return v.visit(this); + } } @JsonSerializable(createToJson: false) -class Field implements ClassMember { - Field( - {this.annotations = const [], - this.javadoc, - this.modifiers = const {}, - required this.name, - required this.type, - this.defaultValue}); - - List annotations; - JavaDocComment? javadoc; - - Set modifiers; +class Field extends ClassMember implements Element { + Field({ + this.annotations = const [], + this.javadoc, + this.modifiers = const {}, + required this.name, + required this.type, + this.defaultValue, + }); @override - String name; + final String name; + @override + final Set modifiers; - TypeUsage type; - Object? defaultValue; + final List annotations; + final JavaDocComment? javadoc; + final TypeUsage type; + final Object? defaultValue; + /// The [ClassDecl] where this field is defined. + /// + /// Will be populated by [Linker]. @JsonKey(includeFromJson: false) - late String finalName; + @override + late final ClassDecl classDecl; + + /// Will be populated by [Renamer]. @JsonKey(includeFromJson: false) - bool isIncluded = true; + late final String finalName; factory Field.fromJson(Map json) => _$FieldFromJson(json); + + @override + R accept(Visitor v) { + return v.visit(this); + } } @JsonSerializable(createToJson: false) -class TypeParam { +class TypeParam implements Element { TypeParam({required this.name, this.bounds = const []}); - String name; - List bounds; + + final String name; + final List bounds; @JsonKey(includeFromJson: false) - late String erasure; + late final String erasure; factory TypeParam.fromJson(Map json) => _$TypeParamFromJson(json); + + @override + R accept(Visitor v) { + return v.visit(this); + } } @JsonSerializable(createToJson: false) -class JavaDocComment { - JavaDocComment({String? comment}) : comment = comment ?? ''; - String comment; +class JavaDocComment implements Element { + JavaDocComment({this.comment = ''}); + + final String comment; @JsonKey(includeFromJson: false) - late String dartDoc; + late final String dartDoc; factory JavaDocComment.fromJson(Map json) => _$JavaDocCommentFromJson(json); + + @override + R accept(Visitor v) { + return v.visit(this); + } } @JsonSerializable(createToJson: false) -class Annotation { - Annotation( - {required this.simpleName, - required this.binaryName, - this.properties = const {}}); - String simpleName; - String binaryName; - Map properties; +class Annotation implements Element { + Annotation({ + required this.simpleName, + required this.binaryName, + this.properties = const {}, + }); + + final String simpleName; + final String binaryName; + final Map properties; factory Annotation.fromJson(Map json) => _$AnnotationFromJson(json); + + @override + R accept(Visitor v) { + return v.visit(this); + } } diff --git a/pkgs/jnigen/lib/src/elements/elements.g.dart b/pkgs/jnigen/lib/src/elements/elements.g.dart index 64e60f74a..2f099138e 100644 --- a/pkgs/jnigen/lib/src/elements/elements.g.dart +++ b/pkgs/jnigen/lib/src/elements/elements.g.dart @@ -20,7 +20,7 @@ ClassDecl _$ClassDeclFromJson(Map json) => ClassDecl( const {}, simpleName: json['simpleName'] as String, binaryName: json['binaryName'] as String, - packageName: (json['packageName'] as String?) ?? '', + packageName: json['packageName'] as String? ?? '', parentName: json['parentName'] as String?, typeParams: (json['typeParams'] as List?) ?.map((e) => TypeParam.fromJson(e as Map)) @@ -61,11 +61,6 @@ const _$KindEnumMap = { Kind.array: 'ARRAY', }; -PrimitiveType _$PrimitiveTypeFromJson(Map json) => - PrimitiveType( - name: json['name'] as String, - ); - DeclaredType _$DeclaredTypeFromJson(Map json) => DeclaredType( binaryName: json['binaryName'] as String, simpleName: json['simpleName'] as String, @@ -156,7 +151,7 @@ TypeParam _$TypeParamFromJson(Map json) => TypeParam( JavaDocComment _$JavaDocCommentFromJson(Map json) => JavaDocComment( - comment: json['comment'] as String?, + comment: json['comment'] as String? ?? '', ); Annotation _$AnnotationFromJson(Map json) => Annotation( diff --git a/pkgs/jnigen/lib/src/generate_bindings.dart b/pkgs/jnigen/lib/src/generate_bindings.dart index b70cf8ca8..9c1202d15 100644 --- a/pkgs/jnigen/lib/src/generate_bindings.dart +++ b/pkgs/jnigen/lib/src/generate_bindings.dart @@ -5,15 +5,19 @@ import 'dart:io'; import 'dart:convert'; -import 'package:jnigen/src/util/command_output.dart'; - +import 'bindings/dart_generator.dart'; +import 'bindings/excluder.dart'; +import 'bindings/linker.dart'; +import 'bindings/renamer.dart'; import 'elements/elements.dart'; import 'summary/summary.dart'; import 'config/config.dart'; import 'tools/tools.dart'; -import 'writers/writers.dart'; +import 'writers/bindings_writer.dart'; import 'logging/logging.dart'; +void collectOutputStream(Stream> stream, StringBuffer buffer) => + stream.transform(const Utf8Decoder()).forEach(buffer.write); Future generateJniBindings(Config config) async { setLoggingLevel(config.logLevel); @@ -81,7 +85,7 @@ Future generateJniBindings(Config config) async { } final errorLog = StringBuffer(); collectOutputStream(process.stderr, errorLog); - final stream = JsonDecoder().bind(Utf8Decoder().bind(input)); + final stream = const JsonDecoder().bind(const Utf8Decoder().bind(input)); dynamic json; try { json = await stream.single; @@ -95,16 +99,20 @@ Future generateJniBindings(Config config) async { return; } final list = json as List; - final outputStructure = config.outputConfig.dartConfig.structure; - BindingsWriter outputWriter; - if (outputStructure == OutputStructure.packageStructure) { - outputWriter = FilesWriter(config); - } else { - outputWriter = SingleFileWriter(config); + final classes = Classes.fromJson(list); + final cBased = config.outputConfig.bindingsType == BindingsType.cBased; + classes + ..accept(Excluder(config)) + ..accept(Linker(config)) + ..accept(Renamer(config)); + + if (cBased) { + await writeCBindings(config, classes.decls.values.toList()); } + try { - await outputWriter - .writeBindings(list.map((c) => ClassDecl.fromJson(c)).toList()); + await classes.accept(DartGenerator(config)); + log.info('Completed'); } on Exception catch (e, trace) { stderr.writeln(trace); log.fatal('Error while writing bindings: $e'); diff --git a/pkgs/jnigen/lib/src/summary/summary.dart b/pkgs/jnigen/lib/src/summary/summary.dart index 900f7f3b0..4580dbedb 100644 --- a/pkgs/jnigen/lib/src/summary/summary.dart +++ b/pkgs/jnigen/lib/src/summary/summary.dart @@ -4,7 +4,8 @@ import 'dart:async'; import 'dart:io'; -import 'package:jnigen/src/logging/logging.dart'; + +import '../logging/logging.dart'; /// A command based summary source which calls the ApiSummarizer command. /// [sourcePaths] and [classPaths] can be provided for the summarizer to find diff --git a/pkgs/jnigen/lib/src/tools/android_sdk_tools.dart b/pkgs/jnigen/lib/src/tools/android_sdk_tools.dart index 703db1387..48fe3b4ae 100644 --- a/pkgs/jnigen/lib/src/tools/android_sdk_tools.dart +++ b/pkgs/jnigen/lib/src/tools/android_sdk_tools.dart @@ -3,9 +3,10 @@ // BSD-style license that can be found in the LICENSE file. import 'dart:io'; + import 'package:path/path.dart'; -import 'package:jnigen/src/logging/logging.dart'; +import '../logging/logging.dart'; class _AndroidToolsException implements Exception { _AndroidToolsException(this.message); diff --git a/pkgs/jnigen/lib/src/tools/build_summarizer.dart b/pkgs/jnigen/lib/src/tools/build_summarizer.dart index 38e395eca..2647bc8e6 100644 --- a/pkgs/jnigen/lib/src/tools/build_summarizer.dart +++ b/pkgs/jnigen/lib/src/tools/build_summarizer.dart @@ -13,8 +13,8 @@ import 'dart:io'; import 'package:path/path.dart'; -import 'package:jnigen/src/util/find_package.dart'; -import 'package:jnigen/src/logging/logging.dart'; +import '../logging/logging.dart'; +import '../util/find_package.dart'; final toolPath = join('.', '.dart_tool', 'jnigen'); final mvnTargetDir = join(toolPath, 'target'); diff --git a/pkgs/jnigen/lib/src/tools/maven_tools.dart b/pkgs/jnigen/lib/src/tools/maven_tools.dart index 07ce7644a..82ebdc7bd 100644 --- a/pkgs/jnigen/lib/src/tools/maven_tools.dart +++ b/pkgs/jnigen/lib/src/tools/maven_tools.dart @@ -4,9 +4,10 @@ import 'dart:io'; -import 'package:jnigen/src/logging/logging.dart'; import 'package:path/path.dart'; +import '../logging/logging.dart'; + /// This class provides some utility methods to download a sources / jars /// using maven along with transitive dependencies. class MavenTools { diff --git a/pkgs/jnigen/lib/src/util/command_output.dart b/pkgs/jnigen/lib/src/util/command_output.dart deleted file mode 100644 index 1e7a9e058..000000000 --- a/pkgs/jnigen/lib/src/util/command_output.dart +++ /dev/null @@ -1,8 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -import 'dart:convert'; - -void collectOutputStream(Stream> stream, StringBuffer buffer) => - stream.transform(Utf8Decoder()).forEach(buffer.write); diff --git a/pkgs/jnigen/lib/src/util/name_utils.dart b/pkgs/jnigen/lib/src/util/name_utils.dart deleted file mode 100644 index 96d0c833b..000000000 --- a/pkgs/jnigen/lib/src/util/name_utils.dart +++ /dev/null @@ -1,12 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -/// splits [str] into 2 from last occurence of [sep] -List cutFromLast(String str, String sep) { - final li = str.lastIndexOf(sep); - if (li == -1) { - return ['', str]; - } - return [str.substring(0, li), str.substring(li + 1)]; -} diff --git a/pkgs/jnigen/lib/src/util/rename_conflict.dart b/pkgs/jnigen/lib/src/util/rename_conflict.dart deleted file mode 100644 index 7971d504a..000000000 --- a/pkgs/jnigen/lib/src/util/rename_conflict.dart +++ /dev/null @@ -1,87 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -String renameConflict(Map counts, String name) { - if (counts.containsKey(name)) { - final count = counts[name]!; - final renamed = '$name$count'; - counts[name] = count + 1; - return renamed; - } - counts[name] = 1; - return kwRename(name); -} - -/// Appends 0 to [name] if [name] is a keyword. -/// -/// Examples: -/// * `int` -> `int0` -/// * `i` -> `i` -String kwRename(String name) => _keywords.contains(name) ? '${name}0' : name; - -const Set _keywords = { - 'abstract', - 'as', - 'assert', - 'async', - 'await', - 'break', - 'case', - 'catch', - 'class', - 'const', - 'continue', - 'covariant', - 'default', - 'deferred', - 'do', - 'dynamic', - 'else', - 'enum', - 'export', - 'extends', - 'extension', - 'external', - 'factory', - 'false', - 'final', - 'finally', - 'for', - 'Function', - 'get', - 'hide', - 'if', - 'implements', - 'import', - 'in', - 'interface', - 'is', - 'late', - 'library', - 'mixin', - 'new', - 'null', - 'on', - 'operator', - 'part', - 'required', - 'rethrow', - 'return', - 'set', - 'show', - 'static', - 'super', - 'switch', - 'sync', - 'this', - 'throw', - 'true', - 'try', - 'typedef', - 'var', - 'void', - 'while', - 'with', - 'yield', -}; diff --git a/pkgs/jnigen/lib/src/writers/bindings_writer.dart b/pkgs/jnigen/lib/src/writers/bindings_writer.dart index 1cfd58e86..a31b3d778 100644 --- a/pkgs/jnigen/lib/src/writers/bindings_writer.dart +++ b/pkgs/jnigen/lib/src/writers/bindings_writer.dart @@ -4,14 +4,11 @@ import 'dart:io'; -import 'package:jnigen/jnigen.dart'; -import 'package:jnigen/src/logging/logging.dart'; -import 'package:jnigen/src/util/find_package.dart'; -import 'package:jnigen/src/bindings/c_bindings.dart'; - -abstract class BindingsWriter { - Future writeBindings(List classes); -} +import '../bindings/c_bindings.dart'; +import '../config/config.dart'; +import '../elements/elements.dart'; +import '../logging/logging.dart'; +import '../util/find_package.dart'; /// Run dart format command on [path]. Future runDartFormat(String path) async { diff --git a/pkgs/jnigen/lib/src/writers/files_writer.dart b/pkgs/jnigen/lib/src/writers/files_writer.dart deleted file mode 100644 index 79904f049..000000000 --- a/pkgs/jnigen/lib/src/writers/files_writer.dart +++ /dev/null @@ -1,305 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -import 'dart:io'; -import 'dart:math'; - -import 'package:jnigen/src/bindings/bindings.dart'; -import 'package:jnigen/src/logging/logging.dart'; -import 'package:jnigen/src/elements/elements.dart'; -import 'package:jnigen/src/config/config.dart'; -import 'package:jnigen/src/util/name_utils.dart'; -import 'package:jnigen/src/writers/bindings_writer.dart'; - -String getFileClassName(String binaryName) { - final dollarSign = binaryName.indexOf('\$'); - if (dollarSign != -1) { - return binaryName.substring(0, dollarSign); - } - return binaryName; -} - -/// Resolver for file-per-package mapping, in which the java package hierarchy -/// is mirrored. -class FilePathResolver implements SymbolResolver { - FilePathResolver({ - this.classes = const {}, - this.importMap = const {}, - required this.currentClass, - this.inputClassNames = const {}, - }); - - static const Map predefined = { - 'java.lang.String': 'jni.JString', - }; - - static final predefinedClasses = { - 'java.lang.String': ClassDecl( - binaryName: 'java.lang.String', - packageName: 'java.lang', - simpleName: 'String', - ) - ..isIncluded = true - ..isPreprocessed = true, - }; - - /// A map of all classes by their names - final Map classes; - - /// Class corresponding to currently writing file. - final String currentClass; - - /// Explicit import mappings. - final Map importMap; - - /// Names of all classes in input. - final Set inputClassNames; - - final List importStrings = []; - - final Set _relativeImportedClasses = {}; - - final Map _importedNameToClass = {}; - final Map _classToImportedName = {}; - - /// Returns the dart name of the [binaryName] in current translation context, - /// or `null` if the name cannot be resolved. - @override - String? resolve(String binaryName) { - if (predefined.containsKey(binaryName)) { - return predefined[binaryName]; - } - final target = getFileClassName(binaryName); - final parts = cutFromLast(binaryName, '.'); - final typename = parts[1]; - final simpleTypeName = typename.replaceAll('\$', '_'); - - if (target == currentClass && inputClassNames.contains(binaryName)) { - return simpleTypeName; - } - - if (_classToImportedName.containsKey(target)) { - // This package was already resolved - // but we still need to check if it was a relative import, in which case - // the class not in inputClassNames cannot be mapped here. - if (!_relativeImportedClasses.contains(target) || - inputClassNames.contains(binaryName)) { - final importedName = _classToImportedName[target]; - return '$importedName.$simpleTypeName'; - } - } - - final classImport = getImport(target, binaryName); - log.finest('$target resolved to $classImport for $binaryName'); - if (classImport == null) { - return null; - } - - final pkgName = cutFromLast(target, '.')[1].toLowerCase(); - if (pkgName.isEmpty) { - throw UnsupportedError('No package could be deduced from ' - 'qualified binaryName'); - } - - // We always name imports with an underscore suffix, so that they can be - // never shadowed by a parameter or local variable. - var importedName = '${pkgName}_'; - int suffix = 0; - while (_importedNameToClass.containsKey(importedName)) { - suffix++; - importedName = '$pkgName${suffix}_'; - } - - _importedNameToClass[importedName] = target; - _classToImportedName[target] = importedName; - importStrings.add('import "$classImport" as $importedName;\n'); - return '$importedName.$simpleTypeName'; - } - - /// Returns import string for [classToResolve], or `null` if the class is not - /// found. - /// - /// [binaryName] is the class name trying to be resolved. This parameter is - /// requested so that classes included in current bindings can be resolved - /// using relative path. - String? getImport(String classToResolve, String binaryName) { - var prefix = classToResolve; - - // short circuit if the requested class is specified directly in import map. - if (importMap.containsKey(binaryName)) { - return importMap[binaryName]!; - } - - if (prefix.isEmpty) { - throw UnsupportedError('unexpected: empty package name.'); - } - - final dest = classToResolve.split('.'); - final src = currentClass.split('.'); - // Use relative import when the required class is included in current set - // of bindings. - if (inputClassNames.contains(binaryName)) { - int common = 0; - // find the common prefix path directory of current package, and directory - // of target package - // src.length - 1 simply corresponds to directory of the package. - for (int i = 0; i < src.length - 1 && i < dest.length - 1; i++) { - if (src[i] == dest[i]) { - common++; - } else { - break; - } - } - final pathToCommon = '../' * ((src.length - 1) - common); - final pathToClass = dest.sublist(max(common, 0)).join('/'); - _relativeImportedClasses.add(classToResolve); - return '$pathToCommon$pathToClass.dart'; - } - - while (prefix.isNotEmpty) { - final split = cutFromLast(prefix, '.'); - final left = split[0]; - if (importMap.containsKey(prefix)) { - return importMap[prefix]!; - } - prefix = left; - } - return null; - } - - @override - List getImportStrings() { - return importStrings; - } - - @override - ClassDecl? resolveClass(String binaryName) { - if (predefinedClasses.containsKey(binaryName)) { - return predefinedClasses[binaryName]; - } - return classes[binaryName]; - } -} - -/// Writer which executes custom callback on passed class elements. -/// -/// This class is provided for debugging purposes. -class CallbackWriter implements BindingsWriter { - CallbackWriter(this.callback); - Future Function(Iterable) callback; - @override - Future writeBindings(Iterable classes) async { - await callback(classes); - } -} - -/// Writer which takes writes C and Dart bindings to specified directories. -/// -/// The structure of dart files is determined by package structure of java. -/// One dart file corresponds to one java package, and it's path is decided by -/// fully qualified name of the package. -/// -/// Example: -/// `android.os` -> `$dartWrappersRoot`/`android/os.dart` -class FilesWriter extends BindingsWriter { - static const _initFileName = '_init.dart'; - - FilesWriter(this.config); - Config config; - - @override - Future writeBindings(List classes) async { - final cBased = config.outputConfig.bindingsType == BindingsType.cBased; - final preamble = config.preamble; - final Map> files = {}; - final Map classesByName = {}; - final Map> packages = {}; - for (var c in classes) { - classesByName.putIfAbsent(c.binaryName, () => c); - final fileClass = getFileClassName(c.binaryName); - - files.putIfAbsent(fileClass, () => []); - files[fileClass]!.add(c); - - packages.putIfAbsent(c.packageName, () => {}); - packages[c.packageName]!.add(fileClass.split('.').last); - } - - final classNames = classesByName.keys.toSet(); - ApiPreprocessor.preprocessAll(classesByName, config); - - final dartRoot = config.outputConfig.dartConfig.path; - log.info("Using dart root = $dartRoot"); - final generator = cBased - ? CBasedDartBindingsGenerator(config) - : PureDartBindingsGenerator(config); - - if (cBased) { - await writeCBindings(config, classesByName.values.toList()); - } - - // Write init file - final initFileUri = dartRoot.resolve("_init.dart"); - var initCode = generator.getInitFileContents(); - if (initCode.isNotEmpty) { - if (preamble != null) { - initCode = '$preamble\n$initCode'; - } - final initFile = File.fromUri(initFileUri); - await initFile.create(recursive: true); - await initFile.writeAsString(initCode); - } - - for (var fileClassName in files.keys) { - final relativeFileName = '${fileClassName.replaceAll('.', '/')}.dart'; - final dartFileUri = dartRoot.resolve(relativeFileName); - final dartFile = await File.fromUri(dartFileUri).create(recursive: true); - log.fine('$fileClassName -> ${dartFile.path}'); - final resolver = FilePathResolver( - classes: classesByName, - importMap: config.importMap ?? const {}, - currentClass: fileClassName, - inputClassNames: classNames, - ); - - final classesInFile = files[fileClassName]!; - final dartBindings = classesInFile - .map((decl) => generator.generateBindings(decl, resolver)) - .toList(); - final dartFileStream = dartFile.openWrite(); - if (preamble != null) { - dartFileStream.writeln(preamble); - } - - final initFilePath = ('../' * - relativeFileName.codeUnits - .where((cu) => '/'.codeUnitAt(0) == cu) - .length) + - _initFileName; - - dartFileStream - ..write(generator.getPreImportBoilerplate(initFilePath)) - ..write(resolver.getImportStrings().join('\n')) - ..write(generator.getPostImportBoilerplate(initFilePath)); - - // write dart bindings only after all imports are figured out - dartBindings.forEach(dartFileStream.write); - await dartFileStream.close(); - } - - // write _package.dart export files - for (var package in packages.keys) { - final dirUri = dartRoot.resolve('${package.replaceAll('.', '/')}/'); - final exportFileUri = dirUri.resolve("_package.dart"); - final exportFile = File.fromUri(exportFileUri); - exportFile.createSync(recursive: true); - final exports = - packages[package]!.map((cls) => 'export "$cls.dart";').join('\n'); - exportFile.writeAsStringSync(exports); - } - - await runDartFormat(dartRoot.toFilePath()); - log.info('Completed.'); - } -} diff --git a/pkgs/jnigen/lib/src/writers/single_file_writer.dart b/pkgs/jnigen/lib/src/writers/single_file_writer.dart deleted file mode 100644 index 438f867e5..000000000 --- a/pkgs/jnigen/lib/src/writers/single_file_writer.dart +++ /dev/null @@ -1,97 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -import 'dart:io'; - -import 'package:jnigen/jnigen.dart'; -import 'package:jnigen/src/bindings/bindings.dart'; -import 'package:jnigen/src/logging/logging.dart'; -import 'package:jnigen/src/writers/bindings_writer.dart'; - -/// Resolver for single-file mapping of input classes. -class SingleFileResolver implements SymbolResolver { - static const predefined = { - 'java.lang.String': 'jni.JString', - }; - static final predefinedClasses = { - 'java.lang.String': ClassDecl( - binaryName: 'java.lang.String', - packageName: 'java.lang', - simpleName: 'String', - ) - ..isIncluded = true - ..isPreprocessed = true, - }; - Map inputClasses; - SingleFileResolver(this.inputClasses); - @override - List getImportStrings() { - return []; - } - - @override - String? resolve(String binaryName) { - if (predefined.containsKey(binaryName)) return predefined[binaryName]; - return inputClasses[binaryName]?.finalName; - } - - @override - ClassDecl? resolveClass(String binaryName) { - if (predefinedClasses.containsKey(binaryName)) { - return predefinedClasses[binaryName]; - } - return inputClasses[binaryName]; - } -} - -class SingleFileWriter extends BindingsWriter { - SingleFileWriter(this.config); - Config config; - @override - Future writeBindings(List classes) async { - final cBased = config.outputConfig.bindingsType == BindingsType.cBased; - final preamble = config.preamble; - final Map> packages = {}; - final Map classesByName = {}; - - for (var c in classes) { - classesByName.putIfAbsent(c.binaryName, () => c); - packages.putIfAbsent(c.packageName, () => []); - packages[c.packageName]!.add(c); - } - - ApiPreprocessor.preprocessAll(classesByName, config, renameClasses: true); - - if (cBased) { - await writeCBindings(config, classesByName.values.toList()); - } - log.info("Generating ${cBased ? "C + Dart" : "Pure Dart"} Bindings"); - final generator = cBased - ? CBasedDartBindingsGenerator(config) - : PureDartBindingsGenerator(config); - final file = File.fromUri(config.outputConfig.dartConfig.path); - await file.create(recursive: true); - final fileStream = file.openWrite(); - final resolver = SingleFileResolver(classesByName); - - // Have to generate bindings beforehand so that imports are all figured - // out. - final bindings = classesByName.values - .map((decl) => generator.generateBindings(decl, resolver)) - .join("\n"); - - log.info("Writing Dart bindings to file: ${file.path}"); - fileStream - ..writeln(preamble ?? '') - ..writeln(generator.getPreImportBoilerplate()) - ..writeln(resolver.getImportStrings().join('\n')) - ..writeln(generator.getPostImportBoilerplate()) - ..writeln(bindings); - - await fileStream.close(); - await runDartFormat(file.path); - log.info('Completed'); - return; - } -} diff --git a/pkgs/jnigen/lib/src/writers/writers.dart b/pkgs/jnigen/lib/src/writers/writers.dart deleted file mode 100644 index 0d2ca4463..000000000 --- a/pkgs/jnigen/lib/src/writers/writers.dart +++ /dev/null @@ -1,3 +0,0 @@ -export 'bindings_writer.dart'; -export 'single_file_writer.dart'; -export 'files_writer.dart'; diff --git a/pkgs/jnigen/test/jackson_core_test/generated_files_test.dart b/pkgs/jnigen/test/jackson_core_test/generated_files_test.dart index d464b6cf6..75dde7d42 100644 --- a/pkgs/jnigen/test/jackson_core_test/generated_files_test.dart +++ b/pkgs/jnigen/test/jackson_core_test/generated_files_test.dart @@ -15,21 +15,21 @@ void main() async { final lib = join(thirdPartyDir, 'lib'); final src = join(thirdPartyDir, 'src'); await generateAndCompareBindings(getConfig(), lib, src); - }, timeout: Timeout.factor(2)); + }, timeout: const Timeout.factor(2)); test( 'generate and analyze bindings for complete library, ' 'not just required classes', () async { final config = getConfig(generateFullVersion: true); await generateAndAnalyzeBindings(config); - }, timeout: Timeout(Duration(minutes: 2))); + }, timeout: const Timeout(Duration(minutes: 2))); test('generate and analyze bindings using ASM', () async { final config = getConfig(generateFullVersion: true, useAsm: true); await generateAndAnalyzeBindings(config); - }, timeout: Timeout(Duration(minutes: 2))); + }, timeout: const Timeout(Duration(minutes: 2))); test('Generate and analyze pure dart bindings', () async { final config = getConfig(generateFullVersion: true); config.outputConfig.bindingsType = BindingsType.dartOnly; await generateAndAnalyzeBindings(config); - }, timeout: Timeout.factor(2)); + }, timeout: const Timeout.factor(2)); } diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/lib/_init.dart b/pkgs/jnigen/test/jackson_core_test/third_party/lib/_init.dart index 7f85005d1..eec3a8c14 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/lib/_init.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/lib/_init.dart @@ -17,5 +17,7 @@ import "package:jni/jni.dart" as jni; +// Auto-generated initialization code. + final jniEnv = jni.Jni.env; final jniAccessors = jni.Jni.accessors; diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonFactory.dart b/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonFactory.dart index 2cb23c07e..9c8decbdf 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonFactory.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonFactory.dart @@ -32,13 +32,12 @@ // ignore_for_file: unused_shown_name import "dart:isolate" show ReceivePort; - -import "package:jni/jni.dart" as jni; - +import "dart:ffi" as ffi; import "package:jni/internal_helpers_for_jnigen.dart"; +import "package:jni/jni.dart" as jni; import "JsonParser.dart" as jsonparser_; -import "../../../../_init.dart" show jniEnv, jniAccessors; +import "../../../../_init.dart"; /// from: com.fasterxml.jackson.core.JsonFactory /// @@ -69,7 +68,7 @@ class JsonFactory extends jni.JObject { ) : super.fromRef(ref); static final _classRef = - jniAccessors.getClassOf("com/fasterxml/jackson/core/JsonFactory"); + jniAccessors.getClassOf(r"com/fasterxml/jackson/core/JsonFactory"); /// The type which includes information such as the signature of this class. static const type = $JsonFactoryType(); @@ -78,10 +77,14 @@ class JsonFactory extends jni.JObject { /// /// Name used to identify JSON format /// (and returned by \#getFormatName() - static const FORMAT_NAME_JSON = "JSON"; + static const FORMAT_NAME_JSON = r"""JSON"""; - static final _id_DEFAULT_FACTORY_FEATURE_FLAGS = jniAccessors - .getStaticFieldIDOf(_classRef, "DEFAULT_FACTORY_FEATURE_FLAGS", "I"); + static final _id_DEFAULT_FACTORY_FEATURE_FLAGS = + jniAccessors.getStaticFieldIDOf( + _classRef, + r"DEFAULT_FACTORY_FEATURE_FLAGS", + r"I", + ); /// from: static protected final int DEFAULT_FACTORY_FEATURE_FLAGS /// @@ -91,8 +94,12 @@ class JsonFactory extends jni.JObject { _classRef, _id_DEFAULT_FACTORY_FEATURE_FLAGS, jni.JniCallType.intType) .integer; - static final _id_DEFAULT_PARSER_FEATURE_FLAGS = jniAccessors - .getStaticFieldIDOf(_classRef, "DEFAULT_PARSER_FEATURE_FLAGS", "I"); + static final _id_DEFAULT_PARSER_FEATURE_FLAGS = + jniAccessors.getStaticFieldIDOf( + _classRef, + r"DEFAULT_PARSER_FEATURE_FLAGS", + r"I", + ); /// from: static protected final int DEFAULT_PARSER_FEATURE_FLAGS /// @@ -103,8 +110,12 @@ class JsonFactory extends jni.JObject { _classRef, _id_DEFAULT_PARSER_FEATURE_FLAGS, jni.JniCallType.intType) .integer; - static final _id_DEFAULT_GENERATOR_FEATURE_FLAGS = jniAccessors - .getStaticFieldIDOf(_classRef, "DEFAULT_GENERATOR_FEATURE_FLAGS", "I"); + static final _id_DEFAULT_GENERATOR_FEATURE_FLAGS = + jniAccessors.getStaticFieldIDOf( + _classRef, + r"DEFAULT_GENERATOR_FEATURE_FLAGS", + r"I", + ); /// from: static protected final int DEFAULT_GENERATOR_FEATURE_FLAGS /// @@ -116,8 +127,11 @@ class JsonFactory extends jni.JObject { .integer; static final _id_DEFAULT_ROOT_VALUE_SEPARATOR = - jniAccessors.getStaticFieldIDOf(_classRef, "DEFAULT_ROOT_VALUE_SEPARATOR", - "Lcom/fasterxml/jackson/core/SerializableString;"); + jniAccessors.getStaticFieldIDOf( + _classRef, + r"DEFAULT_ROOT_VALUE_SEPARATOR", + r"Lcom/fasterxml/jackson/core/SerializableString;", + ); /// from: static public final com.fasterxml.jackson.core.SerializableString DEFAULT_ROOT_VALUE_SEPARATOR /// The returned object must be deleted after use, by calling the `delete` method. @@ -128,7 +142,7 @@ class JsonFactory extends jni.JObject { .object); static final _id_ctor = - jniAccessors.getMethodIDOf(_classRef, "", "()V"); + jniAccessors.getMethodIDOf(_classRef, r"", r"()V"); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. @@ -146,7 +160,7 @@ class JsonFactory extends jni.JObject { jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); static final _id_ctor1 = jniAccessors.getMethodIDOf( - _classRef, "", "(Lcom/fasterxml/jackson/core/ObjectCodec;)V"); + _classRef, r"", r"(Lcom/fasterxml/jackson/core/ObjectCodec;)V"); /// from: public void (com.fasterxml.jackson.core.ObjectCodec oc) /// The returned object must be deleted after use, by calling the `delete` method. @@ -154,8 +168,8 @@ class JsonFactory extends jni.JObject { : super.fromRef(jniAccessors .newObjectWithArgs(_classRef, _id_ctor1, [oc.reference]).object); - static final _id_ctor2 = jniAccessors.getMethodIDOf(_classRef, "", - "(Lcom/fasterxml/jackson/core/JsonFactory;Lcom/fasterxml/jackson/core/ObjectCodec;)V"); + static final _id_ctor2 = jniAccessors.getMethodIDOf(_classRef, r"", + r"(Lcom/fasterxml/jackson/core/JsonFactory;Lcom/fasterxml/jackson/core/ObjectCodec;)V"); /// from: protected void (com.fasterxml.jackson.core.JsonFactory src, com.fasterxml.jackson.core.ObjectCodec codec) /// The returned object must be deleted after use, by calling the `delete` method. @@ -168,8 +182,8 @@ class JsonFactory extends jni.JObject { : super.fromRef(jniAccessors.newObjectWithArgs( _classRef, _id_ctor2, [src.reference, codec.reference]).object); - static final _id_ctor3 = jniAccessors.getMethodIDOf(_classRef, "", - "(Lcom/fasterxml/jackson/core/JsonFactoryBuilder;)V"); + static final _id_ctor3 = jniAccessors.getMethodIDOf(_classRef, r"", + r"(Lcom/fasterxml/jackson/core/JsonFactoryBuilder;)V"); /// from: public void (com.fasterxml.jackson.core.JsonFactoryBuilder b) /// The returned object must be deleted after use, by calling the `delete` method. @@ -182,7 +196,7 @@ class JsonFactory extends jni.JObject { .newObjectWithArgs(_classRef, _id_ctor3, [b.reference]).object); static final _id_ctor4 = jniAccessors.getMethodIDOf( - _classRef, "", "(Lcom/fasterxml/jackson/core/TSFBuilder;Z)V"); + _classRef, r"", r"(Lcom/fasterxml/jackson/core/TSFBuilder;Z)V"); /// from: protected void (com.fasterxml.jackson.core.TSFBuilder b, boolean bogus) /// The returned object must be deleted after use, by calling the `delete` method. @@ -194,10 +208,10 @@ class JsonFactory extends jni.JObject { ///@param bogus Argument only needed to separate constructor signature; ignored JsonFactory.ctor4(jni.JObject b, bool bogus) : super.fromRef(jniAccessors.newObjectWithArgs( - _classRef, _id_ctor4, [b.reference, bogus]).object); + _classRef, _id_ctor4, [b.reference, bogus ? 1 : 0]).object); static final _id_rebuild = jniAccessors.getMethodIDOf( - _classRef, "rebuild", "()Lcom/fasterxml/jackson/core/TSFBuilder;"); + _classRef, r"rebuild", r"()Lcom/fasterxml/jackson/core/TSFBuilder;"); /// from: public com.fasterxml.jackson.core.TSFBuilder rebuild() /// The returned object must be deleted after use, by calling the `delete` method. @@ -211,7 +225,7 @@ class JsonFactory extends jni.JObject { reference, _id_rebuild, jni.JniCallType.objectType, []).object); static final _id_builder = jniAccessors.getStaticMethodIDOf( - _classRef, "builder", "()Lcom/fasterxml/jackson/core/TSFBuilder;"); + _classRef, r"builder", r"()Lcom/fasterxml/jackson/core/TSFBuilder;"); /// from: static public com.fasterxml.jackson.core.TSFBuilder builder() /// The returned object must be deleted after use, by calling the `delete` method. @@ -229,7 +243,7 @@ class JsonFactory extends jni.JObject { _classRef, _id_builder, jni.JniCallType.objectType, []).object); static final _id_copy = jniAccessors.getMethodIDOf( - _classRef, "copy", "()Lcom/fasterxml/jackson/core/JsonFactory;"); + _classRef, r"copy", r"()Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public com.fasterxml.jackson.core.JsonFactory copy() /// The returned object must be deleted after use, by calling the `delete` method. @@ -251,7 +265,7 @@ class JsonFactory extends jni.JObject { reference, _id_copy, jni.JniCallType.objectType, []).object); static final _id_readResolve = jniAccessors.getMethodIDOf( - _classRef, "readResolve", "()Ljava/lang/Object;"); + _classRef, r"readResolve", r"()Ljava/lang/Object;"); /// from: protected java.lang.Object readResolve() /// The returned object must be deleted after use, by calling the `delete` method. @@ -266,8 +280,8 @@ class JsonFactory extends jni.JObject { const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( reference, _id_readResolve, jni.JniCallType.objectType, []).object); - static final _id_requiresPropertyOrdering = - jniAccessors.getMethodIDOf(_classRef, "requiresPropertyOrdering", "()Z"); + static final _id_requiresPropertyOrdering = jniAccessors.getMethodIDOf( + _classRef, r"requiresPropertyOrdering", r"()Z"); /// from: public boolean requiresPropertyOrdering() /// @@ -289,7 +303,7 @@ class JsonFactory extends jni.JObject { _id_requiresPropertyOrdering, jni.JniCallType.booleanType, []).boolean; static final _id_canHandleBinaryNatively = - jniAccessors.getMethodIDOf(_classRef, "canHandleBinaryNatively", "()Z"); + jniAccessors.getMethodIDOf(_classRef, r"canHandleBinaryNatively", r"()Z"); /// from: public boolean canHandleBinaryNatively() /// @@ -308,7 +322,7 @@ class JsonFactory extends jni.JObject { _id_canHandleBinaryNatively, jni.JniCallType.booleanType, []).boolean; static final _id_canUseCharArrays = - jniAccessors.getMethodIDOf(_classRef, "canUseCharArrays", "()Z"); + jniAccessors.getMethodIDOf(_classRef, r"canUseCharArrays", r"()Z"); /// from: public boolean canUseCharArrays() /// @@ -327,7 +341,7 @@ class JsonFactory extends jni.JObject { reference, _id_canUseCharArrays, jni.JniCallType.booleanType, []).boolean; static final _id_canParseAsync = - jniAccessors.getMethodIDOf(_classRef, "canParseAsync", "()Z"); + jniAccessors.getMethodIDOf(_classRef, r"canParseAsync", r"()Z"); /// from: public boolean canParseAsync() /// @@ -342,7 +356,7 @@ class JsonFactory extends jni.JObject { reference, _id_canParseAsync, jni.JniCallType.booleanType, []).boolean; static final _id_getFormatReadFeatureType = jniAccessors.getMethodIDOf( - _classRef, "getFormatReadFeatureType", "()Ljava/lang/Class;"); + _classRef, r"getFormatReadFeatureType", r"()Ljava/lang/Class;"); /// from: public java.lang.Class getFormatReadFeatureType() /// The returned object must be deleted after use, by calling the `delete` method. @@ -351,7 +365,7 @@ class JsonFactory extends jni.JObject { _id_getFormatReadFeatureType, jni.JniCallType.objectType, []).object); static final _id_getFormatWriteFeatureType = jniAccessors.getMethodIDOf( - _classRef, "getFormatWriteFeatureType", "()Ljava/lang/Class;"); + _classRef, r"getFormatWriteFeatureType", r"()Ljava/lang/Class;"); /// from: public java.lang.Class getFormatWriteFeatureType() /// The returned object must be deleted after use, by calling the `delete` method. @@ -362,7 +376,7 @@ class JsonFactory extends jni.JObject { jni.JniCallType.objectType, []).object); static final _id_canUseSchema = jniAccessors.getMethodIDOf(_classRef, - "canUseSchema", "(Lcom/fasterxml/jackson/core/FormatSchema;)Z"); + r"canUseSchema", r"(Lcom/fasterxml/jackson/core/FormatSchema;)Z"); /// from: public boolean canUseSchema(com.fasterxml.jackson.core.FormatSchema schema) /// @@ -382,7 +396,7 @@ class JsonFactory extends jni.JObject { [schema.reference]).boolean; static final _id_getFormatName = jniAccessors.getMethodIDOf( - _classRef, "getFormatName", "()Ljava/lang/String;"); + _classRef, r"getFormatName", r"()Ljava/lang/String;"); /// from: public java.lang.String getFormatName() /// The returned object must be deleted after use, by calling the `delete` method. @@ -399,8 +413,8 @@ class JsonFactory extends jni.JObject { static final _id_hasFormat = jniAccessors.getMethodIDOf( _classRef, - "hasFormat", - "(Lcom/fasterxml/jackson/core/format/InputAccessor;)Lcom/fasterxml/jackson/core/format/MatchStrength;"); + r"hasFormat", + r"(Lcom/fasterxml/jackson/core/format/InputAccessor;)Lcom/fasterxml/jackson/core/format/MatchStrength;"); /// from: public com.fasterxml.jackson.core.format.MatchStrength hasFormat(com.fasterxml.jackson.core.format.InputAccessor acc) /// The returned object must be deleted after use, by calling the `delete` method. @@ -409,7 +423,7 @@ class JsonFactory extends jni.JObject { _id_hasFormat, jni.JniCallType.objectType, [acc.reference]).object); static final _id_requiresCustomCodec = - jniAccessors.getMethodIDOf(_classRef, "requiresCustomCodec", "()Z"); + jniAccessors.getMethodIDOf(_classRef, r"requiresCustomCodec", r"()Z"); /// from: public boolean requiresCustomCodec() /// @@ -427,8 +441,8 @@ class JsonFactory extends jni.JObject { static final _id_hasJSONFormat = jniAccessors.getMethodIDOf( _classRef, - "hasJSONFormat", - "(Lcom/fasterxml/jackson/core/format/InputAccessor;)Lcom/fasterxml/jackson/core/format/MatchStrength;"); + r"hasJSONFormat", + r"(Lcom/fasterxml/jackson/core/format/InputAccessor;)Lcom/fasterxml/jackson/core/format/MatchStrength;"); /// from: protected com.fasterxml.jackson.core.format.MatchStrength hasJSONFormat(com.fasterxml.jackson.core.format.InputAccessor acc) /// The returned object must be deleted after use, by calling the `delete` method. @@ -440,7 +454,7 @@ class JsonFactory extends jni.JObject { [acc.reference]).object); static final _id_version = jniAccessors.getMethodIDOf( - _classRef, "version", "()Lcom/fasterxml/jackson/core/Version;"); + _classRef, r"version", r"()Lcom/fasterxml/jackson/core/Version;"); /// from: public com.fasterxml.jackson.core.Version version() /// The returned object must be deleted after use, by calling the `delete` method. @@ -450,8 +464,8 @@ class JsonFactory extends jni.JObject { static final _id_configure = jniAccessors.getMethodIDOf( _classRef, - "configure", - "(Lcom/fasterxml/jackson/core/JsonFactory\$Feature;Z)Lcom/fasterxml/jackson/core/JsonFactory;"); + r"configure", + r"(Lcom/fasterxml/jackson/core/JsonFactory$Feature;Z)Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public final com.fasterxml.jackson.core.JsonFactory configure(com.fasterxml.jackson.core.JsonFactory.Feature f, boolean state) /// The returned object must be deleted after use, by calling the `delete` method. @@ -467,10 +481,10 @@ class JsonFactory extends jni.JObject { reference, _id_configure, jni.JniCallType.objectType, - [f.reference, state]).object); + [f.reference, state ? 1 : 0]).object); - static final _id_enable = jniAccessors.getMethodIDOf(_classRef, "enable", - "(Lcom/fasterxml/jackson/core/JsonFactory\$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); + static final _id_enable = jniAccessors.getMethodIDOf(_classRef, r"enable", + r"(Lcom/fasterxml/jackson/core/JsonFactory$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public com.fasterxml.jackson.core.JsonFactory enable(com.fasterxml.jackson.core.JsonFactory.Feature f) /// The returned object must be deleted after use, by calling the `delete` method. @@ -487,8 +501,8 @@ class JsonFactory extends jni.JObject { jni.JniCallType.objectType, [f.reference]).object); - static final _id_disable = jniAccessors.getMethodIDOf(_classRef, "disable", - "(Lcom/fasterxml/jackson/core/JsonFactory\$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); + static final _id_disable = jniAccessors.getMethodIDOf(_classRef, r"disable", + r"(Lcom/fasterxml/jackson/core/JsonFactory$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public com.fasterxml.jackson.core.JsonFactory disable(com.fasterxml.jackson.core.JsonFactory.Feature f) /// The returned object must be deleted after use, by calling the `delete` method. @@ -506,7 +520,7 @@ class JsonFactory extends jni.JObject { [f.reference]).object); static final _id_isEnabled = jniAccessors.getMethodIDOf(_classRef, - "isEnabled", "(Lcom/fasterxml/jackson/core/JsonFactory\$Feature;)Z"); + r"isEnabled", r"(Lcom/fasterxml/jackson/core/JsonFactory$Feature;)Z"); /// from: public final boolean isEnabled(com.fasterxml.jackson.core.JsonFactory.Feature f) /// @@ -520,28 +534,28 @@ class JsonFactory extends jni.JObject { [f.reference]).boolean; static final _id_getParserFeatures = - jniAccessors.getMethodIDOf(_classRef, "getParserFeatures", "()I"); + jniAccessors.getMethodIDOf(_classRef, r"getParserFeatures", r"()I"); /// from: public final int getParserFeatures() int getParserFeatures() => jniAccessors.callMethodWithArgs( reference, _id_getParserFeatures, jni.JniCallType.intType, []).integer; static final _id_getGeneratorFeatures = - jniAccessors.getMethodIDOf(_classRef, "getGeneratorFeatures", "()I"); + jniAccessors.getMethodIDOf(_classRef, r"getGeneratorFeatures", r"()I"); /// from: public final int getGeneratorFeatures() int getGeneratorFeatures() => jniAccessors.callMethodWithArgs( reference, _id_getGeneratorFeatures, jni.JniCallType.intType, []).integer; static final _id_getFormatParserFeatures = - jniAccessors.getMethodIDOf(_classRef, "getFormatParserFeatures", "()I"); + jniAccessors.getMethodIDOf(_classRef, r"getFormatParserFeatures", r"()I"); /// from: public int getFormatParserFeatures() int getFormatParserFeatures() => jniAccessors.callMethodWithArgs(reference, _id_getFormatParserFeatures, jni.JniCallType.intType, []).integer; static final _id_getFormatGeneratorFeatures = jniAccessors.getMethodIDOf( - _classRef, "getFormatGeneratorFeatures", "()I"); + _classRef, r"getFormatGeneratorFeatures", r"()I"); /// from: public int getFormatGeneratorFeatures() int getFormatGeneratorFeatures() => jniAccessors.callMethodWithArgs(reference, @@ -549,8 +563,8 @@ class JsonFactory extends jni.JObject { static final _id_configure1 = jniAccessors.getMethodIDOf( _classRef, - "configure", - "(Lcom/fasterxml/jackson/core/JsonParser\$Feature;Z)Lcom/fasterxml/jackson/core/JsonFactory;"); + r"configure", + r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;Z)Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public final com.fasterxml.jackson.core.JsonFactory configure(com.fasterxml.jackson.core.JsonParser.Feature f, boolean state) /// The returned object must be deleted after use, by calling the `delete` method. @@ -565,10 +579,10 @@ class JsonFactory extends jni.JObject { reference, _id_configure1, jni.JniCallType.objectType, - [f.reference, state]).object); + [f.reference, state ? 1 : 0]).object); - static final _id_enable1 = jniAccessors.getMethodIDOf(_classRef, "enable", - "(Lcom/fasterxml/jackson/core/JsonParser\$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); + static final _id_enable1 = jniAccessors.getMethodIDOf(_classRef, r"enable", + r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public com.fasterxml.jackson.core.JsonFactory enable(com.fasterxml.jackson.core.JsonParser.Feature f) /// The returned object must be deleted after use, by calling the `delete` method. @@ -584,8 +598,8 @@ class JsonFactory extends jni.JObject { jni.JniCallType.objectType, [f.reference]).object); - static final _id_disable1 = jniAccessors.getMethodIDOf(_classRef, "disable", - "(Lcom/fasterxml/jackson/core/JsonParser\$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); + static final _id_disable1 = jniAccessors.getMethodIDOf(_classRef, r"disable", + r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public com.fasterxml.jackson.core.JsonFactory disable(com.fasterxml.jackson.core.JsonParser.Feature f) /// The returned object must be deleted after use, by calling the `delete` method. @@ -602,7 +616,7 @@ class JsonFactory extends jni.JObject { [f.reference]).object); static final _id_isEnabled1 = jniAccessors.getMethodIDOf(_classRef, - "isEnabled", "(Lcom/fasterxml/jackson/core/JsonParser\$Feature;)Z"); + r"isEnabled", r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Z"); /// from: public final boolean isEnabled(com.fasterxml.jackson.core.JsonParser.Feature f) /// @@ -614,7 +628,7 @@ class JsonFactory extends jni.JObject { jni.JniCallType.booleanType, [f.reference]).boolean; static final _id_isEnabled2 = jniAccessors.getMethodIDOf(_classRef, - "isEnabled", "(Lcom/fasterxml/jackson/core/StreamReadFeature;)Z"); + r"isEnabled", r"(Lcom/fasterxml/jackson/core/StreamReadFeature;)Z"); /// from: public final boolean isEnabled(com.fasterxml.jackson.core.StreamReadFeature f) /// @@ -625,8 +639,10 @@ class JsonFactory extends jni.JObject { bool isEnabled2(jni.JObject f) => jniAccessors.callMethodWithArgs(reference, _id_isEnabled2, jni.JniCallType.booleanType, [f.reference]).boolean; - static final _id_getInputDecorator = jniAccessors.getMethodIDOf(_classRef, - "getInputDecorator", "()Lcom/fasterxml/jackson/core/io/InputDecorator;"); + static final _id_getInputDecorator = jniAccessors.getMethodIDOf( + _classRef, + r"getInputDecorator", + r"()Lcom/fasterxml/jackson/core/io/InputDecorator;"); /// from: public com.fasterxml.jackson.core.io.InputDecorator getInputDecorator() /// The returned object must be deleted after use, by calling the `delete` method. @@ -640,8 +656,8 @@ class JsonFactory extends jni.JObject { static final _id_setInputDecorator = jniAccessors.getMethodIDOf( _classRef, - "setInputDecorator", - "(Lcom/fasterxml/jackson/core/io/InputDecorator;)Lcom/fasterxml/jackson/core/JsonFactory;"); + r"setInputDecorator", + r"(Lcom/fasterxml/jackson/core/io/InputDecorator;)Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public com.fasterxml.jackson.core.JsonFactory setInputDecorator(com.fasterxml.jackson.core.io.InputDecorator d) /// The returned object must be deleted after use, by calling the `delete` method. @@ -659,8 +675,8 @@ class JsonFactory extends jni.JObject { static final _id_configure2 = jniAccessors.getMethodIDOf( _classRef, - "configure", - "(Lcom/fasterxml/jackson/core/JsonGenerator\$Feature;Z)Lcom/fasterxml/jackson/core/JsonFactory;"); + r"configure", + r"(Lcom/fasterxml/jackson/core/JsonGenerator$Feature;Z)Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public final com.fasterxml.jackson.core.JsonFactory configure(com.fasterxml.jackson.core.JsonGenerator.Feature f, boolean state) /// The returned object must be deleted after use, by calling the `delete` method. @@ -675,10 +691,10 @@ class JsonFactory extends jni.JObject { reference, _id_configure2, jni.JniCallType.objectType, - [f.reference, state]).object); + [f.reference, state ? 1 : 0]).object); - static final _id_enable2 = jniAccessors.getMethodIDOf(_classRef, "enable", - "(Lcom/fasterxml/jackson/core/JsonGenerator\$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); + static final _id_enable2 = jniAccessors.getMethodIDOf(_classRef, r"enable", + r"(Lcom/fasterxml/jackson/core/JsonGenerator$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public com.fasterxml.jackson.core.JsonFactory enable(com.fasterxml.jackson.core.JsonGenerator.Feature f) /// The returned object must be deleted after use, by calling the `delete` method. @@ -694,8 +710,8 @@ class JsonFactory extends jni.JObject { jni.JniCallType.objectType, [f.reference]).object); - static final _id_disable2 = jniAccessors.getMethodIDOf(_classRef, "disable", - "(Lcom/fasterxml/jackson/core/JsonGenerator\$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); + static final _id_disable2 = jniAccessors.getMethodIDOf(_classRef, r"disable", + r"(Lcom/fasterxml/jackson/core/JsonGenerator$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public com.fasterxml.jackson.core.JsonFactory disable(com.fasterxml.jackson.core.JsonGenerator.Feature f) /// The returned object must be deleted after use, by calling the `delete` method. @@ -712,7 +728,7 @@ class JsonFactory extends jni.JObject { [f.reference]).object); static final _id_isEnabled3 = jniAccessors.getMethodIDOf(_classRef, - "isEnabled", "(Lcom/fasterxml/jackson/core/JsonGenerator\$Feature;)Z"); + r"isEnabled", r"(Lcom/fasterxml/jackson/core/JsonGenerator$Feature;)Z"); /// from: public final boolean isEnabled(com.fasterxml.jackson.core.JsonGenerator.Feature f) /// @@ -723,7 +739,7 @@ class JsonFactory extends jni.JObject { _id_isEnabled3, jni.JniCallType.booleanType, [f.reference]).boolean; static final _id_isEnabled4 = jniAccessors.getMethodIDOf(_classRef, - "isEnabled", "(Lcom/fasterxml/jackson/core/StreamWriteFeature;)Z"); + r"isEnabled", r"(Lcom/fasterxml/jackson/core/StreamWriteFeature;)Z"); /// from: public final boolean isEnabled(com.fasterxml.jackson.core.StreamWriteFeature f) /// @@ -736,8 +752,8 @@ class JsonFactory extends jni.JObject { static final _id_getCharacterEscapes = jniAccessors.getMethodIDOf( _classRef, - "getCharacterEscapes", - "()Lcom/fasterxml/jackson/core/io/CharacterEscapes;"); + r"getCharacterEscapes", + r"()Lcom/fasterxml/jackson/core/io/CharacterEscapes;"); /// from: public com.fasterxml.jackson.core.io.CharacterEscapes getCharacterEscapes() /// The returned object must be deleted after use, by calling the `delete` method. @@ -751,8 +767,8 @@ class JsonFactory extends jni.JObject { static final _id_setCharacterEscapes = jniAccessors.getMethodIDOf( _classRef, - "setCharacterEscapes", - "(Lcom/fasterxml/jackson/core/io/CharacterEscapes;)Lcom/fasterxml/jackson/core/JsonFactory;"); + r"setCharacterEscapes", + r"(Lcom/fasterxml/jackson/core/io/CharacterEscapes;)Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public com.fasterxml.jackson.core.JsonFactory setCharacterEscapes(com.fasterxml.jackson.core.io.CharacterEscapes esc) /// The returned object must be deleted after use, by calling the `delete` method. @@ -770,8 +786,8 @@ class JsonFactory extends jni.JObject { static final _id_getOutputDecorator = jniAccessors.getMethodIDOf( _classRef, - "getOutputDecorator", - "()Lcom/fasterxml/jackson/core/io/OutputDecorator;"); + r"getOutputDecorator", + r"()Lcom/fasterxml/jackson/core/io/OutputDecorator;"); /// from: public com.fasterxml.jackson.core.io.OutputDecorator getOutputDecorator() /// The returned object must be deleted after use, by calling the `delete` method. @@ -786,8 +802,8 @@ class JsonFactory extends jni.JObject { static final _id_setOutputDecorator = jniAccessors.getMethodIDOf( _classRef, - "setOutputDecorator", - "(Lcom/fasterxml/jackson/core/io/OutputDecorator;)Lcom/fasterxml/jackson/core/JsonFactory;"); + r"setOutputDecorator", + r"(Lcom/fasterxml/jackson/core/io/OutputDecorator;)Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public com.fasterxml.jackson.core.JsonFactory setOutputDecorator(com.fasterxml.jackson.core.io.OutputDecorator d) /// The returned object must be deleted after use, by calling the `delete` method. @@ -805,8 +821,8 @@ class JsonFactory extends jni.JObject { static final _id_setRootValueSeparator = jniAccessors.getMethodIDOf( _classRef, - "setRootValueSeparator", - "(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonFactory;"); + r"setRootValueSeparator", + r"(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public com.fasterxml.jackson.core.JsonFactory setRootValueSeparator(java.lang.String sep) /// The returned object must be deleted after use, by calling the `delete` method. @@ -824,7 +840,7 @@ class JsonFactory extends jni.JObject { [sep.reference]).object); static final _id_getRootValueSeparator = jniAccessors.getMethodIDOf( - _classRef, "getRootValueSeparator", "()Ljava/lang/String;"); + _classRef, r"getRootValueSeparator", r"()Ljava/lang/String;"); /// from: public java.lang.String getRootValueSeparator() /// The returned object must be deleted after use, by calling the `delete` method. @@ -834,8 +850,8 @@ class JsonFactory extends jni.JObject { const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs(reference, _id_getRootValueSeparator, jni.JniCallType.objectType, []).object); - static final _id_setCodec = jniAccessors.getMethodIDOf(_classRef, "setCodec", - "(Lcom/fasterxml/jackson/core/ObjectCodec;)Lcom/fasterxml/jackson/core/JsonFactory;"); + static final _id_setCodec = jniAccessors.getMethodIDOf(_classRef, r"setCodec", + r"(Lcom/fasterxml/jackson/core/ObjectCodec;)Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public com.fasterxml.jackson.core.JsonFactory setCodec(com.fasterxml.jackson.core.ObjectCodec oc) /// The returned object must be deleted after use, by calling the `delete` method. @@ -855,7 +871,7 @@ class JsonFactory extends jni.JObject { [oc.reference]).object); static final _id_getCodec = jniAccessors.getMethodIDOf( - _classRef, "getCodec", "()Lcom/fasterxml/jackson/core/ObjectCodec;"); + _classRef, r"getCodec", r"()Lcom/fasterxml/jackson/core/ObjectCodec;"); /// from: public com.fasterxml.jackson.core.ObjectCodec getCodec() /// The returned object must be deleted after use, by calling the `delete` method. @@ -865,8 +881,8 @@ class JsonFactory extends jni.JObject { static final _id_createParser = jniAccessors.getMethodIDOf( _classRef, - "createParser", - "(Ljava/io/File;)Lcom/fasterxml/jackson/core/JsonParser;"); + r"createParser", + r"(Ljava/io/File;)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.io.File f) /// The returned object must be deleted after use, by calling the `delete` method. @@ -894,8 +910,8 @@ class JsonFactory extends jni.JObject { static final _id_createParser1 = jniAccessors.getMethodIDOf( _classRef, - "createParser", - "(Ljava/net/URL;)Lcom/fasterxml/jackson/core/JsonParser;"); + r"createParser", + r"(Ljava/net/URL;)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.net.URL url) /// The returned object must be deleted after use, by calling the `delete` method. @@ -921,8 +937,8 @@ class JsonFactory extends jni.JObject { static final _id_createParser2 = jniAccessors.getMethodIDOf( _classRef, - "createParser", - "(Ljava/io/InputStream;)Lcom/fasterxml/jackson/core/JsonParser;"); + r"createParser", + r"(Ljava/io/InputStream;)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.io.InputStream in) /// The returned object must be deleted after use, by calling the `delete` method. @@ -951,8 +967,8 @@ class JsonFactory extends jni.JObject { static final _id_createParser3 = jniAccessors.getMethodIDOf( _classRef, - "createParser", - "(Ljava/io/Reader;)Lcom/fasterxml/jackson/core/JsonParser;"); + r"createParser", + r"(Ljava/io/Reader;)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.io.Reader r) /// The returned object must be deleted after use, by calling the `delete` method. @@ -972,8 +988,8 @@ class JsonFactory extends jni.JObject { .callMethodWithArgs(reference, _id_createParser3, jni.JniCallType.objectType, [r.reference]).object); - static final _id_createParser4 = jniAccessors.getMethodIDOf( - _classRef, "createParser", "([B)Lcom/fasterxml/jackson/core/JsonParser;"); + static final _id_createParser4 = jniAccessors.getMethodIDOf(_classRef, + r"createParser", r"([B)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createParser(byte[] data) /// The returned object must be deleted after use, by calling the `delete` method. @@ -987,7 +1003,7 @@ class JsonFactory extends jni.JObject { jni.JniCallType.objectType, [data.reference]).object); static final _id_createParser5 = jniAccessors.getMethodIDOf(_classRef, - "createParser", "([BII)Lcom/fasterxml/jackson/core/JsonParser;"); + r"createParser", r"([BII)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createParser(byte[] data, int offset, int len) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1009,8 +1025,8 @@ class JsonFactory extends jni.JObject { static final _id_createParser6 = jniAccessors.getMethodIDOf( _classRef, - "createParser", - "(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonParser;"); + r"createParser", + r"(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.lang.String content) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1023,8 +1039,8 @@ class JsonFactory extends jni.JObject { .callMethodWithArgs(reference, _id_createParser6, jni.JniCallType.objectType, [content.reference]).object); - static final _id_createParser7 = jniAccessors.getMethodIDOf( - _classRef, "createParser", "([C)Lcom/fasterxml/jackson/core/JsonParser;"); + static final _id_createParser7 = jniAccessors.getMethodIDOf(_classRef, + r"createParser", r"([C)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createParser(char[] content) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1038,7 +1054,7 @@ class JsonFactory extends jni.JObject { jni.JniCallType.objectType, [content.reference]).object); static final _id_createParser8 = jniAccessors.getMethodIDOf(_classRef, - "createParser", "([CII)Lcom/fasterxml/jackson/core/JsonParser;"); + r"createParser", r"([CII)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createParser(char[] content, int offset, int len) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1056,8 +1072,8 @@ class JsonFactory extends jni.JObject { static final _id_createParser9 = jniAccessors.getMethodIDOf( _classRef, - "createParser", - "(Ljava/io/DataInput;)Lcom/fasterxml/jackson/core/JsonParser;"); + r"createParser", + r"(Ljava/io/DataInput;)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.io.DataInput in) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1074,8 +1090,8 @@ class JsonFactory extends jni.JObject { jni.JniCallType.objectType, [in0.reference]).object); static final _id_createNonBlockingByteArrayParser = - jniAccessors.getMethodIDOf(_classRef, "createNonBlockingByteArrayParser", - "()Lcom/fasterxml/jackson/core/JsonParser;"); + jniAccessors.getMethodIDOf(_classRef, r"createNonBlockingByteArrayParser", + r"()Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createNonBlockingByteArrayParser() /// The returned object must be deleted after use, by calling the `delete` method. @@ -1100,8 +1116,8 @@ class JsonFactory extends jni.JObject { static final _id_createGenerator = jniAccessors.getMethodIDOf( _classRef, - "createGenerator", - "(Ljava/io/OutputStream;Lcom/fasterxml/jackson/core/JsonEncoding;)Lcom/fasterxml/jackson/core/JsonGenerator;"); + r"createGenerator", + r"(Ljava/io/OutputStream;Lcom/fasterxml/jackson/core/JsonEncoding;)Lcom/fasterxml/jackson/core/JsonGenerator;"); /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.OutputStream out, com.fasterxml.jackson.core.JsonEncoding enc) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1133,8 +1149,8 @@ class JsonFactory extends jni.JObject { static final _id_createGenerator1 = jniAccessors.getMethodIDOf( _classRef, - "createGenerator", - "(Ljava/io/OutputStream;)Lcom/fasterxml/jackson/core/JsonGenerator;"); + r"createGenerator", + r"(Ljava/io/OutputStream;)Lcom/fasterxml/jackson/core/JsonGenerator;"); /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.OutputStream out) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1153,8 +1169,8 @@ class JsonFactory extends jni.JObject { static final _id_createGenerator2 = jniAccessors.getMethodIDOf( _classRef, - "createGenerator", - "(Ljava/io/Writer;)Lcom/fasterxml/jackson/core/JsonGenerator;"); + r"createGenerator", + r"(Ljava/io/Writer;)Lcom/fasterxml/jackson/core/JsonGenerator;"); /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.Writer w) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1179,8 +1195,8 @@ class JsonFactory extends jni.JObject { static final _id_createGenerator3 = jniAccessors.getMethodIDOf( _classRef, - "createGenerator", - "(Ljava/io/File;Lcom/fasterxml/jackson/core/JsonEncoding;)Lcom/fasterxml/jackson/core/JsonGenerator;"); + r"createGenerator", + r"(Ljava/io/File;Lcom/fasterxml/jackson/core/JsonEncoding;)Lcom/fasterxml/jackson/core/JsonGenerator;"); /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.File f, com.fasterxml.jackson.core.JsonEncoding enc) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1206,8 +1222,8 @@ class JsonFactory extends jni.JObject { static final _id_createGenerator4 = jniAccessors.getMethodIDOf( _classRef, - "createGenerator", - "(Ljava/io/DataOutput;Lcom/fasterxml/jackson/core/JsonEncoding;)Lcom/fasterxml/jackson/core/JsonGenerator;"); + r"createGenerator", + r"(Ljava/io/DataOutput;Lcom/fasterxml/jackson/core/JsonEncoding;)Lcom/fasterxml/jackson/core/JsonGenerator;"); /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.DataOutput out, com.fasterxml.jackson.core.JsonEncoding enc) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1224,8 +1240,8 @@ class JsonFactory extends jni.JObject { static final _id_createGenerator5 = jniAccessors.getMethodIDOf( _classRef, - "createGenerator", - "(Ljava/io/DataOutput;)Lcom/fasterxml/jackson/core/JsonGenerator;"); + r"createGenerator", + r"(Ljava/io/DataOutput;)Lcom/fasterxml/jackson/core/JsonGenerator;"); /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.DataOutput out) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1244,8 +1260,8 @@ class JsonFactory extends jni.JObject { static final _id_createJsonParser = jniAccessors.getMethodIDOf( _classRef, - "createJsonParser", - "(Ljava/io/File;)Lcom/fasterxml/jackson/core/JsonParser;"); + r"createJsonParser", + r"(Ljava/io/File;)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(java.io.File f) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1275,8 +1291,8 @@ class JsonFactory extends jni.JObject { static final _id_createJsonParser1 = jniAccessors.getMethodIDOf( _classRef, - "createJsonParser", - "(Ljava/net/URL;)Lcom/fasterxml/jackson/core/JsonParser;"); + r"createJsonParser", + r"(Ljava/net/URL;)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(java.net.URL url) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1305,8 +1321,8 @@ class JsonFactory extends jni.JObject { static final _id_createJsonParser2 = jniAccessors.getMethodIDOf( _classRef, - "createJsonParser", - "(Ljava/io/InputStream;)Lcom/fasterxml/jackson/core/JsonParser;"); + r"createJsonParser", + r"(Ljava/io/InputStream;)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(java.io.InputStream in) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1338,8 +1354,8 @@ class JsonFactory extends jni.JObject { static final _id_createJsonParser3 = jniAccessors.getMethodIDOf( _classRef, - "createJsonParser", - "(Ljava/io/Reader;)Lcom/fasterxml/jackson/core/JsonParser;"); + r"createJsonParser", + r"(Ljava/io/Reader;)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(java.io.Reader r) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1363,7 +1379,7 @@ class JsonFactory extends jni.JObject { jni.JniCallType.objectType, [r.reference]).object); static final _id_createJsonParser4 = jniAccessors.getMethodIDOf(_classRef, - "createJsonParser", "([B)Lcom/fasterxml/jackson/core/JsonParser;"); + r"createJsonParser", r"([B)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(byte[] data) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1380,7 +1396,7 @@ class JsonFactory extends jni.JObject { jni.JniCallType.objectType, [data.reference]).object); static final _id_createJsonParser5 = jniAccessors.getMethodIDOf(_classRef, - "createJsonParser", "([BII)Lcom/fasterxml/jackson/core/JsonParser;"); + r"createJsonParser", r"([BII)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(byte[] data, int offset, int len) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1405,8 +1421,8 @@ class JsonFactory extends jni.JObject { static final _id_createJsonParser6 = jniAccessors.getMethodIDOf( _classRef, - "createJsonParser", - "(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonParser;"); + r"createJsonParser", + r"(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(java.lang.String content) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1425,8 +1441,8 @@ class JsonFactory extends jni.JObject { static final _id_createJsonGenerator = jniAccessors.getMethodIDOf( _classRef, - "createJsonGenerator", - "(Ljava/io/OutputStream;Lcom/fasterxml/jackson/core/JsonEncoding;)Lcom/fasterxml/jackson/core/JsonGenerator;"); + r"createJsonGenerator", + r"(Ljava/io/OutputStream;Lcom/fasterxml/jackson/core/JsonEncoding;)Lcom/fasterxml/jackson/core/JsonGenerator;"); /// from: public com.fasterxml.jackson.core.JsonGenerator createJsonGenerator(java.io.OutputStream out, com.fasterxml.jackson.core.JsonEncoding enc) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1460,8 +1476,8 @@ class JsonFactory extends jni.JObject { static final _id_createJsonGenerator1 = jniAccessors.getMethodIDOf( _classRef, - "createJsonGenerator", - "(Ljava/io/Writer;)Lcom/fasterxml/jackson/core/JsonGenerator;"); + r"createJsonGenerator", + r"(Ljava/io/Writer;)Lcom/fasterxml/jackson/core/JsonGenerator;"); /// from: public com.fasterxml.jackson.core.JsonGenerator createJsonGenerator(java.io.Writer out) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1488,8 +1504,8 @@ class JsonFactory extends jni.JObject { static final _id_createJsonGenerator2 = jniAccessors.getMethodIDOf( _classRef, - "createJsonGenerator", - "(Ljava/io/OutputStream;)Lcom/fasterxml/jackson/core/JsonGenerator;"); + r"createJsonGenerator", + r"(Ljava/io/OutputStream;)Lcom/fasterxml/jackson/core/JsonGenerator;"); /// from: public com.fasterxml.jackson.core.JsonGenerator createJsonGenerator(java.io.OutputStream out) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1545,13 +1561,12 @@ class JsonFactory_Feature extends jni.JObject { ) : super.fromRef(ref); static final _classRef = jniAccessors - .getClassOf("com/fasterxml/jackson/core/JsonFactory\$Feature"); + .getClassOf(r"com/fasterxml/jackson/core/JsonFactory$Feature"); /// The type which includes information such as the signature of this class. static const type = $JsonFactory_FeatureType(); - static final _id_values = jniAccessors.getStaticMethodIDOf(_classRef, - "values", "()[Lcom/fasterxml/jackson/core/JsonFactory\$Feature;"); + r"values", r"()[Lcom/fasterxml/jackson/core/JsonFactory$Feature;"); /// from: static public com.fasterxml.jackson.core.JsonFactory.Feature[] values() /// The returned object must be deleted after use, by calling the `delete` method. @@ -1562,8 +1577,8 @@ class JsonFactory_Feature extends jni.JObject { static final _id_valueOf = jniAccessors.getStaticMethodIDOf( _classRef, - "valueOf", - "(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonFactory\$Feature;"); + r"valueOf", + r"(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonFactory$Feature;"); /// from: static public com.fasterxml.jackson.core.JsonFactory.Feature valueOf(java.lang.String name) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1573,7 +1588,7 @@ class JsonFactory_Feature extends jni.JObject { jni.JniCallType.objectType, [name.reference]).object); static final _id_collectDefaults = - jniAccessors.getStaticMethodIDOf(_classRef, "collectDefaults", "()I"); + jniAccessors.getStaticMethodIDOf(_classRef, r"collectDefaults", r"()I"); /// from: static public int collectDefaults() /// @@ -1584,21 +1599,21 @@ class JsonFactory_Feature extends jni.JObject { _classRef, _id_collectDefaults, jni.JniCallType.intType, []).integer; static final _id_enabledByDefault = - jniAccessors.getMethodIDOf(_classRef, "enabledByDefault", "()Z"); + jniAccessors.getMethodIDOf(_classRef, r"enabledByDefault", r"()Z"); /// from: public boolean enabledByDefault() bool enabledByDefault() => jniAccessors.callMethodWithArgs( reference, _id_enabledByDefault, jni.JniCallType.booleanType, []).boolean; static final _id_enabledIn = - jniAccessors.getMethodIDOf(_classRef, "enabledIn", "(I)Z"); + jniAccessors.getMethodIDOf(_classRef, r"enabledIn", r"(I)Z"); /// from: public boolean enabledIn(int flags) bool enabledIn(int flags) => jniAccessors.callMethodWithArgs( reference, _id_enabledIn, jni.JniCallType.booleanType, [flags]).boolean; static final _id_getMask = - jniAccessors.getMethodIDOf(_classRef, "getMask", "()I"); + jniAccessors.getMethodIDOf(_classRef, r"getMask", r"()I"); /// from: public int getMask() int getMask() => jniAccessors.callMethodWithArgs( diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonParser.dart b/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonParser.dart index 4f453370d..c37156055 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonParser.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonParser.dart @@ -32,13 +32,12 @@ // ignore_for_file: unused_shown_name import "dart:isolate" show ReceivePort; - -import "package:jni/jni.dart" as jni; - +import "dart:ffi" as ffi; import "package:jni/internal_helpers_for_jnigen.dart"; +import "package:jni/jni.dart" as jni; import "JsonToken.dart" as jsontoken_; -import "../../../../_init.dart" show jniEnv, jniAccessors; +import "../../../../_init.dart"; /// from: com.fasterxml.jackson.core.JsonParser /// @@ -56,15 +55,15 @@ class JsonParser extends jni.JObject { ) : super.fromRef(ref); static final _classRef = - jniAccessors.getClassOf("com/fasterxml/jackson/core/JsonParser"); + jniAccessors.getClassOf(r"com/fasterxml/jackson/core/JsonParser"); /// The type which includes information such as the signature of this class. static const type = $JsonParserType(); - static final _id_DEFAULT_READ_CAPABILITIES = jniAccessors.getStaticFieldIDOf( - _classRef, - "DEFAULT_READ_CAPABILITIES", - "Lcom/fasterxml/jackson/core/util/JacksonFeatureSet;"); + _classRef, + r"DEFAULT_READ_CAPABILITIES", + r"Lcom/fasterxml/jackson/core/util/JacksonFeatureSet;", + ); /// from: static protected final com.fasterxml.jackson.core.util.JacksonFeatureSet DEFAULT_READ_CAPABILITIES /// The returned object must be deleted after use, by calling the `delete` method. @@ -80,7 +79,7 @@ class JsonParser extends jni.JObject { .object); static final _id_ctor = - jniAccessors.getMethodIDOf(_classRef, "", "()V"); + jniAccessors.getMethodIDOf(_classRef, r"", r"()V"); /// from: protected void () /// The returned object must be deleted after use, by calling the `delete` method. @@ -89,7 +88,7 @@ class JsonParser extends jni.JObject { jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); static final _id_ctor1 = - jniAccessors.getMethodIDOf(_classRef, "", "(I)V"); + jniAccessors.getMethodIDOf(_classRef, r"", r"(I)V"); /// from: protected void (int features) /// The returned object must be deleted after use, by calling the `delete` method. @@ -98,7 +97,7 @@ class JsonParser extends jni.JObject { .newObjectWithArgs(_classRef, _id_ctor1, [features]).object); static final _id_getCodec = jniAccessors.getMethodIDOf( - _classRef, "getCodec", "()Lcom/fasterxml/jackson/core/ObjectCodec;"); + _classRef, r"getCodec", r"()Lcom/fasterxml/jackson/core/ObjectCodec;"); /// from: public abstract com.fasterxml.jackson.core.ObjectCodec getCodec() /// The returned object must be deleted after use, by calling the `delete` method. @@ -112,7 +111,7 @@ class JsonParser extends jni.JObject { reference, _id_getCodec, jni.JniCallType.objectType, []).object); static final _id_setCodec = jniAccessors.getMethodIDOf( - _classRef, "setCodec", "(Lcom/fasterxml/jackson/core/ObjectCodec;)V"); + _classRef, r"setCodec", r"(Lcom/fasterxml/jackson/core/ObjectCodec;)V"); /// from: public abstract void setCodec(com.fasterxml.jackson.core.ObjectCodec oc) /// @@ -124,7 +123,7 @@ class JsonParser extends jni.JObject { _id_setCodec, jni.JniCallType.voidType, [oc.reference]).check(); static final _id_getInputSource = jniAccessors.getMethodIDOf( - _classRef, "getInputSource", "()Ljava/lang/Object;"); + _classRef, r"getInputSource", r"()Ljava/lang/Object;"); /// from: public java.lang.Object getInputSource() /// The returned object must be deleted after use, by calling the `delete` method. @@ -149,8 +148,8 @@ class JsonParser extends jni.JObject { static final _id_setRequestPayloadOnError = jniAccessors.getMethodIDOf( _classRef, - "setRequestPayloadOnError", - "(Lcom/fasterxml/jackson/core/util/RequestPayload;)V"); + r"setRequestPayloadOnError", + r"(Lcom/fasterxml/jackson/core/util/RequestPayload;)V"); /// from: public void setRequestPayloadOnError(com.fasterxml.jackson.core.util.RequestPayload payload) /// @@ -162,7 +161,7 @@ class JsonParser extends jni.JObject { jni.JniCallType.voidType, [payload.reference]).check(); static final _id_setRequestPayloadOnError1 = jniAccessors.getMethodIDOf( - _classRef, "setRequestPayloadOnError", "([BLjava/lang/String;)V"); + _classRef, r"setRequestPayloadOnError", r"([BLjava/lang/String;)V"); /// from: public void setRequestPayloadOnError(byte[] payload, java.lang.String charset) /// @@ -179,7 +178,7 @@ class JsonParser extends jni.JObject { [payload.reference, charset.reference]).check(); static final _id_setRequestPayloadOnError2 = jniAccessors.getMethodIDOf( - _classRef, "setRequestPayloadOnError", "(Ljava/lang/String;)V"); + _classRef, r"setRequestPayloadOnError", r"(Ljava/lang/String;)V"); /// from: public void setRequestPayloadOnError(java.lang.String payload) /// @@ -191,7 +190,7 @@ class JsonParser extends jni.JObject { jni.JniCallType.voidType, [payload.reference]).check(); static final _id_setSchema = jniAccessors.getMethodIDOf( - _classRef, "setSchema", "(Lcom/fasterxml/jackson/core/FormatSchema;)V"); + _classRef, r"setSchema", r"(Lcom/fasterxml/jackson/core/FormatSchema;)V"); /// from: public void setSchema(com.fasterxml.jackson.core.FormatSchema schema) /// @@ -212,7 +211,7 @@ class JsonParser extends jni.JObject { [schema.reference]).check(); static final _id_getSchema = jniAccessors.getMethodIDOf( - _classRef, "getSchema", "()Lcom/fasterxml/jackson/core/FormatSchema;"); + _classRef, r"getSchema", r"()Lcom/fasterxml/jackson/core/FormatSchema;"); /// from: public com.fasterxml.jackson.core.FormatSchema getSchema() /// The returned object must be deleted after use, by calling the `delete` method. @@ -226,7 +225,7 @@ class JsonParser extends jni.JObject { reference, _id_getSchema, jni.JniCallType.objectType, []).object); static final _id_canUseSchema = jniAccessors.getMethodIDOf(_classRef, - "canUseSchema", "(Lcom/fasterxml/jackson/core/FormatSchema;)Z"); + r"canUseSchema", r"(Lcom/fasterxml/jackson/core/FormatSchema;)Z"); /// from: public boolean canUseSchema(com.fasterxml.jackson.core.FormatSchema schema) /// @@ -241,7 +240,7 @@ class JsonParser extends jni.JObject { [schema.reference]).boolean; static final _id_requiresCustomCodec = - jniAccessors.getMethodIDOf(_classRef, "requiresCustomCodec", "()Z"); + jniAccessors.getMethodIDOf(_classRef, r"requiresCustomCodec", r"()Z"); /// from: public boolean requiresCustomCodec() /// @@ -257,7 +256,7 @@ class JsonParser extends jni.JObject { _id_requiresCustomCodec, jni.JniCallType.booleanType, []).boolean; static final _id_canParseAsync = - jniAccessors.getMethodIDOf(_classRef, "canParseAsync", "()Z"); + jniAccessors.getMethodIDOf(_classRef, r"canParseAsync", r"()Z"); /// from: public boolean canParseAsync() /// @@ -277,8 +276,8 @@ class JsonParser extends jni.JObject { static final _id_getNonBlockingInputFeeder = jniAccessors.getMethodIDOf( _classRef, - "getNonBlockingInputFeeder", - "()Lcom/fasterxml/jackson/core/async/NonBlockingInputFeeder;"); + r"getNonBlockingInputFeeder", + r"()Lcom/fasterxml/jackson/core/async/NonBlockingInputFeeder;"); /// from: public com.fasterxml.jackson.core.async.NonBlockingInputFeeder getNonBlockingInputFeeder() /// The returned object must be deleted after use, by calling the `delete` method. @@ -296,8 +295,8 @@ class JsonParser extends jni.JObject { static final _id_getReadCapabilities = jniAccessors.getMethodIDOf( _classRef, - "getReadCapabilities", - "()Lcom/fasterxml/jackson/core/util/JacksonFeatureSet;"); + r"getReadCapabilities", + r"()Lcom/fasterxml/jackson/core/util/JacksonFeatureSet;"); /// from: public com.fasterxml.jackson.core.util.JacksonFeatureSet getReadCapabilities() /// The returned object must be deleted after use, by calling the `delete` method. @@ -311,7 +310,7 @@ class JsonParser extends jni.JObject { _id_getReadCapabilities, jni.JniCallType.objectType, []).object); static final _id_version = jniAccessors.getMethodIDOf( - _classRef, "version", "()Lcom/fasterxml/jackson/core/Version;"); + _classRef, r"version", r"()Lcom/fasterxml/jackson/core/Version;"); /// from: public abstract com.fasterxml.jackson.core.Version version() /// The returned object must be deleted after use, by calling the `delete` method. @@ -325,7 +324,7 @@ class JsonParser extends jni.JObject { reference, _id_version, jni.JniCallType.objectType, []).object); static final _id_close = - jniAccessors.getMethodIDOf(_classRef, "close", "()V"); + jniAccessors.getMethodIDOf(_classRef, r"close", r"()V"); /// from: public abstract void close() /// @@ -347,7 +346,7 @@ class JsonParser extends jni.JObject { reference, _id_close, jni.JniCallType.voidType, []).check(); static final _id_isClosed = - jniAccessors.getMethodIDOf(_classRef, "isClosed", "()Z"); + jniAccessors.getMethodIDOf(_classRef, r"isClosed", r"()Z"); /// from: public abstract boolean isClosed() /// @@ -361,8 +360,10 @@ class JsonParser extends jni.JObject { bool isClosed() => jniAccessors.callMethodWithArgs( reference, _id_isClosed, jni.JniCallType.booleanType, []).boolean; - static final _id_getParsingContext = jniAccessors.getMethodIDOf(_classRef, - "getParsingContext", "()Lcom/fasterxml/jackson/core/JsonStreamContext;"); + static final _id_getParsingContext = jniAccessors.getMethodIDOf( + _classRef, + r"getParsingContext", + r"()Lcom/fasterxml/jackson/core/JsonStreamContext;"); /// from: public abstract com.fasterxml.jackson.core.JsonStreamContext getParsingContext() /// The returned object must be deleted after use, by calling the `delete` method. @@ -381,7 +382,7 @@ class JsonParser extends jni.JObject { _id_getParsingContext, jni.JniCallType.objectType, []).object); static final _id_currentLocation = jniAccessors.getMethodIDOf(_classRef, - "currentLocation", "()Lcom/fasterxml/jackson/core/JsonLocation;"); + r"currentLocation", r"()Lcom/fasterxml/jackson/core/JsonLocation;"); /// from: public com.fasterxml.jackson.core.JsonLocation currentLocation() /// The returned object must be deleted after use, by calling the `delete` method. @@ -403,7 +404,7 @@ class JsonParser extends jni.JObject { _id_currentLocation, jni.JniCallType.objectType, []).object); static final _id_currentTokenLocation = jniAccessors.getMethodIDOf(_classRef, - "currentTokenLocation", "()Lcom/fasterxml/jackson/core/JsonLocation;"); + r"currentTokenLocation", r"()Lcom/fasterxml/jackson/core/JsonLocation;"); /// from: public com.fasterxml.jackson.core.JsonLocation currentTokenLocation() /// The returned object must be deleted after use, by calling the `delete` method. @@ -425,7 +426,7 @@ class JsonParser extends jni.JObject { _id_currentTokenLocation, jni.JniCallType.objectType, []).object); static final _id_getCurrentLocation = jniAccessors.getMethodIDOf(_classRef, - "getCurrentLocation", "()Lcom/fasterxml/jackson/core/JsonLocation;"); + r"getCurrentLocation", r"()Lcom/fasterxml/jackson/core/JsonLocation;"); /// from: public abstract com.fasterxml.jackson.core.JsonLocation getCurrentLocation() /// The returned object must be deleted after use, by calling the `delete` method. @@ -438,7 +439,7 @@ class JsonParser extends jni.JObject { _id_getCurrentLocation, jni.JniCallType.objectType, []).object); static final _id_getTokenLocation = jniAccessors.getMethodIDOf(_classRef, - "getTokenLocation", "()Lcom/fasterxml/jackson/core/JsonLocation;"); + r"getTokenLocation", r"()Lcom/fasterxml/jackson/core/JsonLocation;"); /// from: public abstract com.fasterxml.jackson.core.JsonLocation getTokenLocation() /// The returned object must be deleted after use, by calling the `delete` method. @@ -451,7 +452,7 @@ class JsonParser extends jni.JObject { _id_getTokenLocation, jni.JniCallType.objectType, []).object); static final _id_currentValue = jniAccessors.getMethodIDOf( - _classRef, "currentValue", "()Ljava/lang/Object;"); + _classRef, r"currentValue", r"()Ljava/lang/Object;"); /// from: public java.lang.Object currentValue() /// The returned object must be deleted after use, by calling the `delete` method. @@ -472,7 +473,7 @@ class JsonParser extends jni.JObject { reference, _id_currentValue, jni.JniCallType.objectType, []).object); static final _id_assignCurrentValue = jniAccessors.getMethodIDOf( - _classRef, "assignCurrentValue", "(Ljava/lang/Object;)V"); + _classRef, r"assignCurrentValue", r"(Ljava/lang/Object;)V"); /// from: public void assignCurrentValue(java.lang.Object v) /// @@ -489,7 +490,7 @@ class JsonParser extends jni.JObject { [v.reference]).check(); static final _id_getCurrentValue = jniAccessors.getMethodIDOf( - _classRef, "getCurrentValue", "()Ljava/lang/Object;"); + _classRef, r"getCurrentValue", r"()Ljava/lang/Object;"); /// from: public java.lang.Object getCurrentValue() /// The returned object must be deleted after use, by calling the `delete` method. @@ -502,7 +503,7 @@ class JsonParser extends jni.JObject { _id_getCurrentValue, jni.JniCallType.objectType, []).object); static final _id_setCurrentValue = jniAccessors.getMethodIDOf( - _classRef, "setCurrentValue", "(Ljava/lang/Object;)V"); + _classRef, r"setCurrentValue", r"(Ljava/lang/Object;)V"); /// from: public void setCurrentValue(java.lang.Object v) /// @@ -516,7 +517,7 @@ class JsonParser extends jni.JObject { [v.reference]).check(); static final _id_releaseBuffered = jniAccessors.getMethodIDOf( - _classRef, "releaseBuffered", "(Ljava/io/OutputStream;)I"); + _classRef, r"releaseBuffered", r"(Ljava/io/OutputStream;)I"); /// from: public int releaseBuffered(java.io.OutputStream out) /// @@ -538,7 +539,7 @@ class JsonParser extends jni.JObject { [out.reference]).integer; static final _id_releaseBuffered1 = jniAccessors.getMethodIDOf( - _classRef, "releaseBuffered", "(Ljava/io/Writer;)I"); + _classRef, r"releaseBuffered", r"(Ljava/io/Writer;)I"); /// from: public int releaseBuffered(java.io.Writer w) /// @@ -560,8 +561,8 @@ class JsonParser extends jni.JObject { jni.JniCallType.intType, [w.reference]).integer; - static final _id_enable = jniAccessors.getMethodIDOf(_classRef, "enable", - "(Lcom/fasterxml/jackson/core/JsonParser\$Feature;)Lcom/fasterxml/jackson/core/JsonParser;"); + static final _id_enable = jniAccessors.getMethodIDOf(_classRef, r"enable", + r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser enable(com.fasterxml.jackson.core.JsonParser.Feature f) /// The returned object must be deleted after use, by calling the `delete` method. @@ -574,8 +575,8 @@ class JsonParser extends jni.JObject { const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs(reference, _id_enable, jni.JniCallType.objectType, [f.reference]).object); - static final _id_disable = jniAccessors.getMethodIDOf(_classRef, "disable", - "(Lcom/fasterxml/jackson/core/JsonParser\$Feature;)Lcom/fasterxml/jackson/core/JsonParser;"); + static final _id_disable = jniAccessors.getMethodIDOf(_classRef, r"disable", + r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser disable(com.fasterxml.jackson.core.JsonParser.Feature f) /// The returned object must be deleted after use, by calling the `delete` method. @@ -590,8 +591,8 @@ class JsonParser extends jni.JObject { static final _id_configure = jniAccessors.getMethodIDOf( _classRef, - "configure", - "(Lcom/fasterxml/jackson/core/JsonParser\$Feature;Z)Lcom/fasterxml/jackson/core/JsonParser;"); + r"configure", + r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;Z)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser configure(com.fasterxml.jackson.core.JsonParser.Feature f, boolean state) /// The returned object must be deleted after use, by calling the `delete` method. @@ -606,10 +607,10 @@ class JsonParser extends jni.JObject { reference, _id_configure, jni.JniCallType.objectType, - [f.reference, state]).object); + [f.reference, state ? 1 : 0]).object); static final _id_isEnabled = jniAccessors.getMethodIDOf(_classRef, - "isEnabled", "(Lcom/fasterxml/jackson/core/JsonParser\$Feature;)Z"); + r"isEnabled", r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Z"); /// from: public boolean isEnabled(com.fasterxml.jackson.core.JsonParser.Feature f) /// @@ -623,7 +624,7 @@ class JsonParser extends jni.JObject { [f.reference]).boolean; static final _id_isEnabled1 = jniAccessors.getMethodIDOf(_classRef, - "isEnabled", "(Lcom/fasterxml/jackson/core/StreamReadFeature;)Z"); + r"isEnabled", r"(Lcom/fasterxml/jackson/core/StreamReadFeature;)Z"); /// from: public boolean isEnabled(com.fasterxml.jackson.core.StreamReadFeature f) /// @@ -635,7 +636,7 @@ class JsonParser extends jni.JObject { _id_isEnabled1, jni.JniCallType.booleanType, [f.reference]).boolean; static final _id_getFeatureMask = - jniAccessors.getMethodIDOf(_classRef, "getFeatureMask", "()I"); + jniAccessors.getMethodIDOf(_classRef, r"getFeatureMask", r"()I"); /// from: public int getFeatureMask() /// @@ -646,7 +647,7 @@ class JsonParser extends jni.JObject { reference, _id_getFeatureMask, jni.JniCallType.intType, []).integer; static final _id_setFeatureMask = jniAccessors.getMethodIDOf(_classRef, - "setFeatureMask", "(I)Lcom/fasterxml/jackson/core/JsonParser;"); + r"setFeatureMask", r"(I)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser setFeatureMask(int mask) /// The returned object must be deleted after use, by calling the `delete` method. @@ -661,7 +662,7 @@ class JsonParser extends jni.JObject { _id_setFeatureMask, jni.JniCallType.objectType, [mask]).object); static final _id_overrideStdFeatures = jniAccessors.getMethodIDOf(_classRef, - "overrideStdFeatures", "(II)Lcom/fasterxml/jackson/core/JsonParser;"); + r"overrideStdFeatures", r"(II)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser overrideStdFeatures(int values, int mask) /// The returned object must be deleted after use, by calling the `delete` method. @@ -686,7 +687,7 @@ class JsonParser extends jni.JObject { [values, mask]).object); static final _id_getFormatFeatures = - jniAccessors.getMethodIDOf(_classRef, "getFormatFeatures", "()I"); + jniAccessors.getMethodIDOf(_classRef, r"getFormatFeatures", r"()I"); /// from: public int getFormatFeatures() /// @@ -699,8 +700,8 @@ class JsonParser extends jni.JObject { static final _id_overrideFormatFeatures = jniAccessors.getMethodIDOf( _classRef, - "overrideFormatFeatures", - "(II)Lcom/fasterxml/jackson/core/JsonParser;"); + r"overrideFormatFeatures", + r"(II)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser overrideFormatFeatures(int values, int mask) /// The returned object must be deleted after use, by calling the `delete` method. @@ -723,7 +724,7 @@ class JsonParser extends jni.JObject { [values, mask]).object); static final _id_nextToken = jniAccessors.getMethodIDOf( - _classRef, "nextToken", "()Lcom/fasterxml/jackson/core/JsonToken;"); + _classRef, r"nextToken", r"()Lcom/fasterxml/jackson/core/JsonToken;"); /// from: public abstract com.fasterxml.jackson.core.JsonToken nextToken() /// The returned object must be deleted after use, by calling the `delete` method. @@ -741,7 +742,7 @@ class JsonParser extends jni.JObject { reference, _id_nextToken, jni.JniCallType.objectType, []).object); static final _id_nextValue = jniAccessors.getMethodIDOf( - _classRef, "nextValue", "()Lcom/fasterxml/jackson/core/JsonToken;"); + _classRef, r"nextValue", r"()Lcom/fasterxml/jackson/core/JsonToken;"); /// from: public abstract com.fasterxml.jackson.core.JsonToken nextValue() /// The returned object must be deleted after use, by calling the `delete` method. @@ -767,7 +768,7 @@ class JsonParser extends jni.JObject { reference, _id_nextValue, jni.JniCallType.objectType, []).object); static final _id_nextFieldName = jniAccessors.getMethodIDOf(_classRef, - "nextFieldName", "(Lcom/fasterxml/jackson/core/SerializableString;)Z"); + r"nextFieldName", r"(Lcom/fasterxml/jackson/core/SerializableString;)Z"); /// from: public boolean nextFieldName(com.fasterxml.jackson.core.SerializableString str) /// @@ -793,7 +794,7 @@ class JsonParser extends jni.JObject { [str.reference]).boolean; static final _id_nextFieldName1 = jniAccessors.getMethodIDOf( - _classRef, "nextFieldName", "()Ljava/lang/String;"); + _classRef, r"nextFieldName", r"()Ljava/lang/String;"); /// from: public java.lang.String nextFieldName() /// The returned object must be deleted after use, by calling the `delete` method. @@ -811,7 +812,7 @@ class JsonParser extends jni.JObject { _id_nextFieldName1, jni.JniCallType.objectType, []).object); static final _id_nextTextValue = jniAccessors.getMethodIDOf( - _classRef, "nextTextValue", "()Ljava/lang/String;"); + _classRef, r"nextTextValue", r"()Ljava/lang/String;"); /// from: public java.lang.String nextTextValue() /// The returned object must be deleted after use, by calling the `delete` method. @@ -834,7 +835,7 @@ class JsonParser extends jni.JObject { reference, _id_nextTextValue, jni.JniCallType.objectType, []).object); static final _id_nextIntValue = - jniAccessors.getMethodIDOf(_classRef, "nextIntValue", "(I)I"); + jniAccessors.getMethodIDOf(_classRef, r"nextIntValue", r"(I)I"); /// from: public int nextIntValue(int defaultValue) /// @@ -862,7 +863,7 @@ class JsonParser extends jni.JObject { [defaultValue]).integer; static final _id_nextLongValue = - jniAccessors.getMethodIDOf(_classRef, "nextLongValue", "(J)J"); + jniAccessors.getMethodIDOf(_classRef, r"nextLongValue", r"(J)J"); /// from: public long nextLongValue(long defaultValue) /// @@ -890,7 +891,7 @@ class JsonParser extends jni.JObject { [defaultValue]).long; static final _id_nextBooleanValue = jniAccessors.getMethodIDOf( - _classRef, "nextBooleanValue", "()Ljava/lang/Boolean;"); + _classRef, r"nextBooleanValue", r"()Ljava/lang/Boolean;"); /// from: public java.lang.Boolean nextBooleanValue() /// The returned object must be deleted after use, by calling the `delete` method. @@ -916,7 +917,7 @@ class JsonParser extends jni.JObject { _id_nextBooleanValue, jni.JniCallType.objectType, []).object); static final _id_skipChildren = jniAccessors.getMethodIDOf( - _classRef, "skipChildren", "()Lcom/fasterxml/jackson/core/JsonParser;"); + _classRef, r"skipChildren", r"()Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public abstract com.fasterxml.jackson.core.JsonParser skipChildren() /// The returned object must be deleted after use, by calling the `delete` method. @@ -941,7 +942,7 @@ class JsonParser extends jni.JObject { reference, _id_skipChildren, jni.JniCallType.objectType, []).object); static final _id_finishToken = - jniAccessors.getMethodIDOf(_classRef, "finishToken", "()V"); + jniAccessors.getMethodIDOf(_classRef, r"finishToken", r"()V"); /// from: public void finishToken() /// @@ -962,7 +963,7 @@ class JsonParser extends jni.JObject { reference, _id_finishToken, jni.JniCallType.voidType, []).check(); static final _id_currentToken = jniAccessors.getMethodIDOf( - _classRef, "currentToken", "()Lcom/fasterxml/jackson/core/JsonToken;"); + _classRef, r"currentToken", r"()Lcom/fasterxml/jackson/core/JsonToken;"); /// from: public com.fasterxml.jackson.core.JsonToken currentToken() /// The returned object must be deleted after use, by calling the `delete` method. @@ -981,7 +982,7 @@ class JsonParser extends jni.JObject { reference, _id_currentToken, jni.JniCallType.objectType, []).object); static final _id_currentTokenId = - jniAccessors.getMethodIDOf(_classRef, "currentTokenId", "()I"); + jniAccessors.getMethodIDOf(_classRef, r"currentTokenId", r"()I"); /// from: public int currentTokenId() /// @@ -997,8 +998,8 @@ class JsonParser extends jni.JObject { int currentTokenId() => jniAccessors.callMethodWithArgs( reference, _id_currentTokenId, jni.JniCallType.intType, []).integer; - static final _id_getCurrentToken = jniAccessors.getMethodIDOf( - _classRef, "getCurrentToken", "()Lcom/fasterxml/jackson/core/JsonToken;"); + static final _id_getCurrentToken = jniAccessors.getMethodIDOf(_classRef, + r"getCurrentToken", r"()Lcom/fasterxml/jackson/core/JsonToken;"); /// from: public abstract com.fasterxml.jackson.core.JsonToken getCurrentToken() /// The returned object must be deleted after use, by calling the `delete` method. @@ -1014,7 +1015,7 @@ class JsonParser extends jni.JObject { jni.JniCallType.objectType, []).object); static final _id_getCurrentTokenId = - jniAccessors.getMethodIDOf(_classRef, "getCurrentTokenId", "()I"); + jniAccessors.getMethodIDOf(_classRef, r"getCurrentTokenId", r"()I"); /// from: public abstract int getCurrentTokenId() /// @@ -1025,7 +1026,7 @@ class JsonParser extends jni.JObject { reference, _id_getCurrentTokenId, jni.JniCallType.intType, []).integer; static final _id_hasCurrentToken = - jniAccessors.getMethodIDOf(_classRef, "hasCurrentToken", "()Z"); + jniAccessors.getMethodIDOf(_classRef, r"hasCurrentToken", r"()Z"); /// from: public abstract boolean hasCurrentToken() /// @@ -1041,7 +1042,7 @@ class JsonParser extends jni.JObject { reference, _id_hasCurrentToken, jni.JniCallType.booleanType, []).boolean; static final _id_hasTokenId = - jniAccessors.getMethodIDOf(_classRef, "hasTokenId", "(I)Z"); + jniAccessors.getMethodIDOf(_classRef, r"hasTokenId", r"(I)Z"); /// from: public abstract boolean hasTokenId(int id) /// @@ -1061,7 +1062,7 @@ class JsonParser extends jni.JObject { reference, _id_hasTokenId, jni.JniCallType.booleanType, [id]).boolean; static final _id_hasToken = jniAccessors.getMethodIDOf( - _classRef, "hasToken", "(Lcom/fasterxml/jackson/core/JsonToken;)Z"); + _classRef, r"hasToken", r"(Lcom/fasterxml/jackson/core/JsonToken;)Z"); /// from: public abstract boolean hasToken(com.fasterxml.jackson.core.JsonToken t) /// @@ -1083,8 +1084,8 @@ class JsonParser extends jni.JObject { jni.JniCallType.booleanType, [t.reference]).boolean; - static final _id_isExpectedStartArrayToken = - jniAccessors.getMethodIDOf(_classRef, "isExpectedStartArrayToken", "()Z"); + static final _id_isExpectedStartArrayToken = jniAccessors.getMethodIDOf( + _classRef, r"isExpectedStartArrayToken", r"()Z"); /// from: public boolean isExpectedStartArrayToken() /// @@ -1108,7 +1109,7 @@ class JsonParser extends jni.JObject { _id_isExpectedStartArrayToken, jni.JniCallType.booleanType, []).boolean; static final _id_isExpectedStartObjectToken = jniAccessors.getMethodIDOf( - _classRef, "isExpectedStartObjectToken", "()Z"); + _classRef, r"isExpectedStartObjectToken", r"()Z"); /// from: public boolean isExpectedStartObjectToken() /// @@ -1123,8 +1124,8 @@ class JsonParser extends jni.JObject { _id_isExpectedStartObjectToken, jni.JniCallType.booleanType, []).boolean; - static final _id_isExpectedNumberIntToken = - jniAccessors.getMethodIDOf(_classRef, "isExpectedNumberIntToken", "()Z"); + static final _id_isExpectedNumberIntToken = jniAccessors.getMethodIDOf( + _classRef, r"isExpectedNumberIntToken", r"()Z"); /// from: public boolean isExpectedNumberIntToken() /// @@ -1141,7 +1142,7 @@ class JsonParser extends jni.JObject { _id_isExpectedNumberIntToken, jni.JniCallType.booleanType, []).boolean; static final _id_isNaN = - jniAccessors.getMethodIDOf(_classRef, "isNaN", "()Z"); + jniAccessors.getMethodIDOf(_classRef, r"isNaN", r"()Z"); /// from: public boolean isNaN() /// @@ -1161,7 +1162,7 @@ class JsonParser extends jni.JObject { reference, _id_isNaN, jni.JniCallType.booleanType, []).boolean; static final _id_clearCurrentToken = - jniAccessors.getMethodIDOf(_classRef, "clearCurrentToken", "()V"); + jniAccessors.getMethodIDOf(_classRef, r"clearCurrentToken", r"()V"); /// from: public abstract void clearCurrentToken() /// @@ -1179,7 +1180,7 @@ class JsonParser extends jni.JObject { reference, _id_clearCurrentToken, jni.JniCallType.voidType, []).check(); static final _id_getLastClearedToken = jniAccessors.getMethodIDOf(_classRef, - "getLastClearedToken", "()Lcom/fasterxml/jackson/core/JsonToken;"); + r"getLastClearedToken", r"()Lcom/fasterxml/jackson/core/JsonToken;"); /// from: public abstract com.fasterxml.jackson.core.JsonToken getLastClearedToken() /// The returned object must be deleted after use, by calling the `delete` method. @@ -1197,7 +1198,7 @@ class JsonParser extends jni.JObject { jni.JniCallType.objectType, []).object); static final _id_overrideCurrentName = jniAccessors.getMethodIDOf( - _classRef, "overrideCurrentName", "(Ljava/lang/String;)V"); + _classRef, r"overrideCurrentName", r"(Ljava/lang/String;)V"); /// from: public abstract void overrideCurrentName(java.lang.String name) /// @@ -1216,7 +1217,7 @@ class JsonParser extends jni.JObject { [name.reference]).check(); static final _id_getCurrentName = jniAccessors.getMethodIDOf( - _classRef, "getCurrentName", "()Ljava/lang/String;"); + _classRef, r"getCurrentName", r"()Ljava/lang/String;"); /// from: public abstract java.lang.String getCurrentName() /// The returned object must be deleted after use, by calling the `delete` method. @@ -1230,7 +1231,7 @@ class JsonParser extends jni.JObject { _id_getCurrentName, jni.JniCallType.objectType, []).object); static final _id_currentName = jniAccessors.getMethodIDOf( - _classRef, "currentName", "()Ljava/lang/String;"); + _classRef, r"currentName", r"()Ljava/lang/String;"); /// from: public java.lang.String currentName() /// The returned object must be deleted after use, by calling the `delete` method. @@ -1248,8 +1249,8 @@ class JsonParser extends jni.JObject { const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( reference, _id_currentName, jni.JniCallType.objectType, []).object); - static final _id_getText = - jniAccessors.getMethodIDOf(_classRef, "getText", "()Ljava/lang/String;"); + static final _id_getText = jniAccessors.getMethodIDOf( + _classRef, r"getText", r"()Ljava/lang/String;"); /// from: public abstract java.lang.String getText() /// The returned object must be deleted after use, by calling the `delete` method. @@ -1267,7 +1268,7 @@ class JsonParser extends jni.JObject { reference, _id_getText, jni.JniCallType.objectType, []).object); static final _id_getText1 = - jniAccessors.getMethodIDOf(_classRef, "getText", "(Ljava/io/Writer;)I"); + jniAccessors.getMethodIDOf(_classRef, r"getText", r"(Ljava/io/Writer;)I"); /// from: public int getText(java.io.Writer writer) /// @@ -1290,7 +1291,7 @@ class JsonParser extends jni.JObject { _id_getText1, jni.JniCallType.intType, [writer.reference]).integer; static final _id_getTextCharacters = - jniAccessors.getMethodIDOf(_classRef, "getTextCharacters", "()[C"); + jniAccessors.getMethodIDOf(_classRef, r"getTextCharacters", r"()[C"); /// from: public abstract char[] getTextCharacters() /// The returned object must be deleted after use, by calling the `delete` method. @@ -1328,7 +1329,7 @@ class JsonParser extends jni.JObject { jni.JniCallType.objectType, []).object); static final _id_getTextLength = - jniAccessors.getMethodIDOf(_classRef, "getTextLength", "()I"); + jniAccessors.getMethodIDOf(_classRef, r"getTextLength", r"()I"); /// from: public abstract int getTextLength() /// @@ -1343,7 +1344,7 @@ class JsonParser extends jni.JObject { reference, _id_getTextLength, jni.JniCallType.intType, []).integer; static final _id_getTextOffset = - jniAccessors.getMethodIDOf(_classRef, "getTextOffset", "()I"); + jniAccessors.getMethodIDOf(_classRef, r"getTextOffset", r"()I"); /// from: public abstract int getTextOffset() /// @@ -1358,7 +1359,7 @@ class JsonParser extends jni.JObject { reference, _id_getTextOffset, jni.JniCallType.intType, []).integer; static final _id_hasTextCharacters = - jniAccessors.getMethodIDOf(_classRef, "hasTextCharacters", "()Z"); + jniAccessors.getMethodIDOf(_classRef, r"hasTextCharacters", r"()Z"); /// from: public abstract boolean hasTextCharacters() /// @@ -1380,7 +1381,7 @@ class JsonParser extends jni.JObject { _id_hasTextCharacters, jni.JniCallType.booleanType, []).boolean; static final _id_getNumberValue = jniAccessors.getMethodIDOf( - _classRef, "getNumberValue", "()Ljava/lang/Number;"); + _classRef, r"getNumberValue", r"()Ljava/lang/Number;"); /// from: public abstract java.lang.Number getNumberValue() /// The returned object must be deleted after use, by calling the `delete` method. @@ -1400,7 +1401,7 @@ class JsonParser extends jni.JObject { _id_getNumberValue, jni.JniCallType.objectType, []).object); static final _id_getNumberValueExact = jniAccessors.getMethodIDOf( - _classRef, "getNumberValueExact", "()Ljava/lang/Number;"); + _classRef, r"getNumberValueExact", r"()Ljava/lang/Number;"); /// from: public java.lang.Number getNumberValueExact() /// The returned object must be deleted after use, by calling the `delete` method. @@ -1423,8 +1424,10 @@ class JsonParser extends jni.JObject { const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs(reference, _id_getNumberValueExact, jni.JniCallType.objectType, []).object); - static final _id_getNumberType = jniAccessors.getMethodIDOf(_classRef, - "getNumberType", "()Lcom/fasterxml/jackson/core/JsonParser\$NumberType;"); + static final _id_getNumberType = jniAccessors.getMethodIDOf( + _classRef, + r"getNumberType", + r"()Lcom/fasterxml/jackson/core/JsonParser$NumberType;"); /// from: public abstract com.fasterxml.jackson.core.JsonParser.NumberType getNumberType() /// The returned object must be deleted after use, by calling the `delete` method. @@ -1441,7 +1444,7 @@ class JsonParser extends jni.JObject { reference, _id_getNumberType, jni.JniCallType.objectType, []).object); static final _id_getByteValue = - jniAccessors.getMethodIDOf(_classRef, "getByteValue", "()B"); + jniAccessors.getMethodIDOf(_classRef, r"getByteValue", r"()B"); /// from: public byte getByteValue() /// @@ -1470,7 +1473,7 @@ class JsonParser extends jni.JObject { reference, _id_getByteValue, jni.JniCallType.byteType, []).byte; static final _id_getShortValue = - jniAccessors.getMethodIDOf(_classRef, "getShortValue", "()S"); + jniAccessors.getMethodIDOf(_classRef, r"getShortValue", r"()S"); /// from: public short getShortValue() /// @@ -1493,7 +1496,7 @@ class JsonParser extends jni.JObject { reference, _id_getShortValue, jni.JniCallType.shortType, []).short; static final _id_getIntValue = - jniAccessors.getMethodIDOf(_classRef, "getIntValue", "()I"); + jniAccessors.getMethodIDOf(_classRef, r"getIntValue", r"()I"); /// from: public abstract int getIntValue() /// @@ -1516,7 +1519,7 @@ class JsonParser extends jni.JObject { reference, _id_getIntValue, jni.JniCallType.intType, []).integer; static final _id_getLongValue = - jniAccessors.getMethodIDOf(_classRef, "getLongValue", "()J"); + jniAccessors.getMethodIDOf(_classRef, r"getLongValue", r"()J"); /// from: public abstract long getLongValue() /// @@ -1539,7 +1542,7 @@ class JsonParser extends jni.JObject { reference, _id_getLongValue, jni.JniCallType.longType, []).long; static final _id_getBigIntegerValue = jniAccessors.getMethodIDOf( - _classRef, "getBigIntegerValue", "()Ljava/math/BigInteger;"); + _classRef, r"getBigIntegerValue", r"()Ljava/math/BigInteger;"); /// from: public abstract java.math.BigInteger getBigIntegerValue() /// The returned object must be deleted after use, by calling the `delete` method. @@ -1560,7 +1563,7 @@ class JsonParser extends jni.JObject { _id_getBigIntegerValue, jni.JniCallType.objectType, []).object); static final _id_getFloatValue = - jniAccessors.getMethodIDOf(_classRef, "getFloatValue", "()F"); + jniAccessors.getMethodIDOf(_classRef, r"getFloatValue", r"()F"); /// from: public abstract float getFloatValue() /// @@ -1583,7 +1586,7 @@ class JsonParser extends jni.JObject { reference, _id_getFloatValue, jni.JniCallType.floatType, []).float; static final _id_getDoubleValue = - jniAccessors.getMethodIDOf(_classRef, "getDoubleValue", "()D"); + jniAccessors.getMethodIDOf(_classRef, r"getDoubleValue", r"()D"); /// from: public abstract double getDoubleValue() /// @@ -1606,7 +1609,7 @@ class JsonParser extends jni.JObject { _id_getDoubleValue, jni.JniCallType.doubleType, []).doubleFloat; static final _id_getDecimalValue = jniAccessors.getMethodIDOf( - _classRef, "getDecimalValue", "()Ljava/math/BigDecimal;"); + _classRef, r"getDecimalValue", r"()Ljava/math/BigDecimal;"); /// from: public abstract java.math.BigDecimal getDecimalValue() /// The returned object must be deleted after use, by calling the `delete` method. @@ -1624,7 +1627,7 @@ class JsonParser extends jni.JObject { _id_getDecimalValue, jni.JniCallType.objectType, []).object); static final _id_getBooleanValue = - jniAccessors.getMethodIDOf(_classRef, "getBooleanValue", "()Z"); + jniAccessors.getMethodIDOf(_classRef, r"getBooleanValue", r"()Z"); /// from: public boolean getBooleanValue() /// @@ -1643,7 +1646,7 @@ class JsonParser extends jni.JObject { reference, _id_getBooleanValue, jni.JniCallType.booleanType, []).boolean; static final _id_getEmbeddedObject = jniAccessors.getMethodIDOf( - _classRef, "getEmbeddedObject", "()Ljava/lang/Object;"); + _classRef, r"getEmbeddedObject", r"()Ljava/lang/Object;"); /// from: public java.lang.Object getEmbeddedObject() /// The returned object must be deleted after use, by calling the `delete` method. @@ -1667,7 +1670,7 @@ class JsonParser extends jni.JObject { _id_getEmbeddedObject, jni.JniCallType.objectType, []).object); static final _id_getBinaryValue = jniAccessors.getMethodIDOf(_classRef, - "getBinaryValue", "(Lcom/fasterxml/jackson/core/Base64Variant;)[B"); + r"getBinaryValue", r"(Lcom/fasterxml/jackson/core/Base64Variant;)[B"); /// from: public abstract byte[] getBinaryValue(com.fasterxml.jackson.core.Base64Variant bv) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1698,7 +1701,7 @@ class JsonParser extends jni.JObject { jni.JniCallType.objectType, [bv.reference]).object); static final _id_getBinaryValue1 = - jniAccessors.getMethodIDOf(_classRef, "getBinaryValue", "()[B"); + jniAccessors.getMethodIDOf(_classRef, r"getBinaryValue", r"()[B"); /// from: public byte[] getBinaryValue() /// The returned object must be deleted after use, by calling the `delete` method. @@ -1715,7 +1718,7 @@ class JsonParser extends jni.JObject { jni.JniCallType.objectType, []).object); static final _id_readBinaryValue = jniAccessors.getMethodIDOf( - _classRef, "readBinaryValue", "(Ljava/io/OutputStream;)I"); + _classRef, r"readBinaryValue", r"(Ljava/io/OutputStream;)I"); /// from: public int readBinaryValue(java.io.OutputStream out) /// @@ -1738,8 +1741,8 @@ class JsonParser extends jni.JObject { static final _id_readBinaryValue1 = jniAccessors.getMethodIDOf( _classRef, - "readBinaryValue", - "(Lcom/fasterxml/jackson/core/Base64Variant;Ljava/io/OutputStream;)I"); + r"readBinaryValue", + r"(Lcom/fasterxml/jackson/core/Base64Variant;Ljava/io/OutputStream;)I"); /// from: public int readBinaryValue(com.fasterxml.jackson.core.Base64Variant bv, java.io.OutputStream out) /// @@ -1756,7 +1759,7 @@ class JsonParser extends jni.JObject { jni.JniCallType.intType, [bv.reference, out.reference]).integer; static final _id_getValueAsInt = - jniAccessors.getMethodIDOf(_classRef, "getValueAsInt", "()I"); + jniAccessors.getMethodIDOf(_classRef, r"getValueAsInt", r"()I"); /// from: public int getValueAsInt() /// @@ -1777,7 +1780,7 @@ class JsonParser extends jni.JObject { reference, _id_getValueAsInt, jni.JniCallType.intType, []).integer; static final _id_getValueAsInt1 = - jniAccessors.getMethodIDOf(_classRef, "getValueAsInt", "(I)I"); + jniAccessors.getMethodIDOf(_classRef, r"getValueAsInt", r"(I)I"); /// from: public int getValueAsInt(int def) /// @@ -1798,7 +1801,7 @@ class JsonParser extends jni.JObject { reference, _id_getValueAsInt1, jni.JniCallType.intType, [def]).integer; static final _id_getValueAsLong = - jniAccessors.getMethodIDOf(_classRef, "getValueAsLong", "()J"); + jniAccessors.getMethodIDOf(_classRef, r"getValueAsLong", r"()J"); /// from: public long getValueAsLong() /// @@ -1819,7 +1822,7 @@ class JsonParser extends jni.JObject { reference, _id_getValueAsLong, jni.JniCallType.longType, []).long; static final _id_getValueAsLong1 = - jniAccessors.getMethodIDOf(_classRef, "getValueAsLong", "(J)J"); + jniAccessors.getMethodIDOf(_classRef, r"getValueAsLong", r"(J)J"); /// from: public long getValueAsLong(long def) /// @@ -1840,7 +1843,7 @@ class JsonParser extends jni.JObject { reference, _id_getValueAsLong1, jni.JniCallType.longType, [def]).long; static final _id_getValueAsDouble = - jniAccessors.getMethodIDOf(_classRef, "getValueAsDouble", "()D"); + jniAccessors.getMethodIDOf(_classRef, r"getValueAsDouble", r"()D"); /// from: public double getValueAsDouble() /// @@ -1861,7 +1864,7 @@ class JsonParser extends jni.JObject { _id_getValueAsDouble, jni.JniCallType.doubleType, []).doubleFloat; static final _id_getValueAsDouble1 = - jniAccessors.getMethodIDOf(_classRef, "getValueAsDouble", "(D)D"); + jniAccessors.getMethodIDOf(_classRef, r"getValueAsDouble", r"(D)D"); /// from: public double getValueAsDouble(double def) /// @@ -1885,7 +1888,7 @@ class JsonParser extends jni.JObject { [def]).doubleFloat; static final _id_getValueAsBoolean = - jniAccessors.getMethodIDOf(_classRef, "getValueAsBoolean", "()Z"); + jniAccessors.getMethodIDOf(_classRef, r"getValueAsBoolean", r"()Z"); /// from: public boolean getValueAsBoolean() /// @@ -1906,7 +1909,7 @@ class JsonParser extends jni.JObject { _id_getValueAsBoolean, jni.JniCallType.booleanType, []).boolean; static final _id_getValueAsBoolean1 = - jniAccessors.getMethodIDOf(_classRef, "getValueAsBoolean", "(Z)Z"); + jniAccessors.getMethodIDOf(_classRef, r"getValueAsBoolean", r"(Z)Z"); /// from: public boolean getValueAsBoolean(boolean def) /// @@ -1927,10 +1930,10 @@ class JsonParser extends jni.JObject { reference, _id_getValueAsBoolean1, jni.JniCallType.booleanType, - [def]).boolean; + [def ? 1 : 0]).boolean; static final _id_getValueAsString = jniAccessors.getMethodIDOf( - _classRef, "getValueAsString", "()Ljava/lang/String;"); + _classRef, r"getValueAsString", r"()Ljava/lang/String;"); /// from: public java.lang.String getValueAsString() /// The returned object must be deleted after use, by calling the `delete` method. @@ -1950,8 +1953,8 @@ class JsonParser extends jni.JObject { const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs(reference, _id_getValueAsString, jni.JniCallType.objectType, []).object); - static final _id_getValueAsString1 = jniAccessors.getMethodIDOf( - _classRef, "getValueAsString", "(Ljava/lang/String;)Ljava/lang/String;"); + static final _id_getValueAsString1 = jniAccessors.getMethodIDOf(_classRef, + r"getValueAsString", r"(Ljava/lang/String;)Ljava/lang/String;"); /// from: public abstract java.lang.String getValueAsString(java.lang.String def) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1976,7 +1979,7 @@ class JsonParser extends jni.JObject { [def.reference]).object); static final _id_canReadObjectId = - jniAccessors.getMethodIDOf(_classRef, "canReadObjectId", "()Z"); + jniAccessors.getMethodIDOf(_classRef, r"canReadObjectId", r"()Z"); /// from: public boolean canReadObjectId() /// @@ -1995,7 +1998,7 @@ class JsonParser extends jni.JObject { reference, _id_canReadObjectId, jni.JniCallType.booleanType, []).boolean; static final _id_canReadTypeId = - jniAccessors.getMethodIDOf(_classRef, "canReadTypeId", "()Z"); + jniAccessors.getMethodIDOf(_classRef, r"canReadTypeId", r"()Z"); /// from: public boolean canReadTypeId() /// @@ -2014,7 +2017,7 @@ class JsonParser extends jni.JObject { reference, _id_canReadTypeId, jni.JniCallType.booleanType, []).boolean; static final _id_getObjectId = jniAccessors.getMethodIDOf( - _classRef, "getObjectId", "()Ljava/lang/Object;"); + _classRef, r"getObjectId", r"()Ljava/lang/Object;"); /// from: public java.lang.Object getObjectId() /// The returned object must be deleted after use, by calling the `delete` method. @@ -2037,7 +2040,7 @@ class JsonParser extends jni.JObject { reference, _id_getObjectId, jni.JniCallType.objectType, []).object); static final _id_getTypeId = jniAccessors.getMethodIDOf( - _classRef, "getTypeId", "()Ljava/lang/Object;"); + _classRef, r"getTypeId", r"()Ljava/lang/Object;"); /// from: public java.lang.Object getTypeId() /// The returned object must be deleted after use, by calling the `delete` method. @@ -2060,7 +2063,7 @@ class JsonParser extends jni.JObject { reference, _id_getTypeId, jni.JniCallType.objectType, []).object); static final _id_readValueAs = jniAccessors.getMethodIDOf( - _classRef, "readValueAs", "(Ljava/lang/Class;)Ljava/lang/Object;"); + _classRef, r"readValueAs", r"(Ljava/lang/Class;)Ljava/lang/Object;"); /// from: public T readValueAs(java.lang.Class valueType) /// The returned object must be deleted after use, by calling the `delete` method. @@ -2097,8 +2100,8 @@ class JsonParser extends jni.JObject { static final _id_readValueAs1 = jniAccessors.getMethodIDOf( _classRef, - "readValueAs", - "(Lcom/fasterxml/jackson/core/type/TypeReference;)Ljava/lang/Object;"); + r"readValueAs", + r"(Lcom/fasterxml/jackson/core/type/TypeReference;)Ljava/lang/Object;"); /// from: public T readValueAs(com.fasterxml.jackson.core.type.TypeReference valueTypeRef) /// The returned object must be deleted after use, by calling the `delete` method. @@ -2131,7 +2134,7 @@ class JsonParser extends jni.JObject { jni.JniCallType.objectType, [valueTypeRef.reference]).object); static final _id_readValuesAs = jniAccessors.getMethodIDOf( - _classRef, "readValuesAs", "(Ljava/lang/Class;)Ljava/util/Iterator;"); + _classRef, r"readValuesAs", r"(Ljava/lang/Class;)Ljava/util/Iterator;"); /// from: public java.util.Iterator readValuesAs(java.lang.Class valueType) /// The returned object must be deleted after use, by calling the `delete` method. @@ -2154,8 +2157,8 @@ class JsonParser extends jni.JObject { static final _id_readValuesAs1 = jniAccessors.getMethodIDOf( _classRef, - "readValuesAs", - "(Lcom/fasterxml/jackson/core/type/TypeReference;)Ljava/util/Iterator;"); + r"readValuesAs", + r"(Lcom/fasterxml/jackson/core/type/TypeReference;)Ljava/util/Iterator;"); /// from: public java.util.Iterator readValuesAs(com.fasterxml.jackson.core.type.TypeReference valueTypeRef) /// The returned object must be deleted after use, by calling the `delete` method. @@ -2177,7 +2180,7 @@ class JsonParser extends jni.JObject { [valueTypeRef.reference]).object); static final _id_readValueAsTree = jniAccessors.getMethodIDOf( - _classRef, "readValueAsTree", "()Ljava/lang/Object;"); + _classRef, r"readValueAsTree", r"()Ljava/lang/Object;"); /// from: public T readValueAsTree() /// The returned object must be deleted after use, by calling the `delete` method. @@ -2230,13 +2233,12 @@ class JsonParser_Feature extends jni.JObject { ) : super.fromRef(ref); static final _classRef = - jniAccessors.getClassOf("com/fasterxml/jackson/core/JsonParser\$Feature"); + jniAccessors.getClassOf(r"com/fasterxml/jackson/core/JsonParser$Feature"); /// The type which includes information such as the signature of this class. static const type = $JsonParser_FeatureType(); - static final _id_values = jniAccessors.getStaticMethodIDOf(_classRef, - "values", "()[Lcom/fasterxml/jackson/core/JsonParser\$Feature;"); + r"values", r"()[Lcom/fasterxml/jackson/core/JsonParser$Feature;"); /// from: static public com.fasterxml.jackson.core.JsonParser.Feature[] values() /// The returned object must be deleted after use, by calling the `delete` method. @@ -2247,8 +2249,8 @@ class JsonParser_Feature extends jni.JObject { static final _id_valueOf = jniAccessors.getStaticMethodIDOf( _classRef, - "valueOf", - "(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonParser\$Feature;"); + r"valueOf", + r"(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonParser$Feature;"); /// from: static public com.fasterxml.jackson.core.JsonParser.Feature valueOf(java.lang.String name) /// The returned object must be deleted after use, by calling the `delete` method. @@ -2258,7 +2260,7 @@ class JsonParser_Feature extends jni.JObject { jni.JniCallType.objectType, [name.reference]).object); static final _id_collectDefaults = - jniAccessors.getStaticMethodIDOf(_classRef, "collectDefaults", "()I"); + jniAccessors.getStaticMethodIDOf(_classRef, r"collectDefaults", r"()I"); /// from: static public int collectDefaults() /// @@ -2269,21 +2271,21 @@ class JsonParser_Feature extends jni.JObject { _classRef, _id_collectDefaults, jni.JniCallType.intType, []).integer; static final _id_enabledByDefault = - jniAccessors.getMethodIDOf(_classRef, "enabledByDefault", "()Z"); + jniAccessors.getMethodIDOf(_classRef, r"enabledByDefault", r"()Z"); /// from: public boolean enabledByDefault() bool enabledByDefault() => jniAccessors.callMethodWithArgs( reference, _id_enabledByDefault, jni.JniCallType.booleanType, []).boolean; static final _id_enabledIn = - jniAccessors.getMethodIDOf(_classRef, "enabledIn", "(I)Z"); + jniAccessors.getMethodIDOf(_classRef, r"enabledIn", r"(I)Z"); /// from: public boolean enabledIn(int flags) bool enabledIn(int flags) => jniAccessors.callMethodWithArgs( reference, _id_enabledIn, jni.JniCallType.booleanType, [flags]).boolean; static final _id_getMask = - jniAccessors.getMethodIDOf(_classRef, "getMask", "()I"); + jniAccessors.getMethodIDOf(_classRef, r"getMask", r"()I"); /// from: public int getMask() int getMask() => jniAccessors.callMethodWithArgs( @@ -2326,13 +2328,12 @@ class JsonParser_NumberType extends jni.JObject { ) : super.fromRef(ref); static final _classRef = jniAccessors - .getClassOf("com/fasterxml/jackson/core/JsonParser\$NumberType"); + .getClassOf(r"com/fasterxml/jackson/core/JsonParser$NumberType"); /// The type which includes information such as the signature of this class. static const type = $JsonParser_NumberTypeType(); - static final _id_values = jniAccessors.getStaticMethodIDOf(_classRef, - "values", "()[Lcom/fasterxml/jackson/core/JsonParser\$NumberType;"); + r"values", r"()[Lcom/fasterxml/jackson/core/JsonParser$NumberType;"); /// from: static public com.fasterxml.jackson.core.JsonParser.NumberType[] values() /// The returned object must be deleted after use, by calling the `delete` method. @@ -2343,8 +2344,8 @@ class JsonParser_NumberType extends jni.JObject { static final _id_valueOf = jniAccessors.getStaticMethodIDOf( _classRef, - "valueOf", - "(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonParser\$NumberType;"); + r"valueOf", + r"(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonParser$NumberType;"); /// from: static public com.fasterxml.jackson.core.JsonParser.NumberType valueOf(java.lang.String name) /// The returned object must be deleted after use, by calling the `delete` method. diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonToken.dart b/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonToken.dart index 8c3bc75c9..84d23d7bb 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonToken.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonToken.dart @@ -32,12 +32,11 @@ // ignore_for_file: unused_shown_name import "dart:isolate" show ReceivePort; - -import "package:jni/jni.dart" as jni; - +import "dart:ffi" as ffi; import "package:jni/internal_helpers_for_jnigen.dart"; +import "package:jni/jni.dart" as jni; -import "../../../../_init.dart" show jniEnv, jniAccessors; +import "../../../../_init.dart"; /// from: com.fasterxml.jackson.core.JsonToken /// @@ -53,13 +52,12 @@ class JsonToken extends jni.JObject { ) : super.fromRef(ref); static final _classRef = - jniAccessors.getClassOf("com/fasterxml/jackson/core/JsonToken"); + jniAccessors.getClassOf(r"com/fasterxml/jackson/core/JsonToken"); /// The type which includes information such as the signature of this class. static const type = $JsonTokenType(); - static final _id_values = jniAccessors.getStaticMethodIDOf( - _classRef, "values", "()[Lcom/fasterxml/jackson/core/JsonToken;"); + _classRef, r"values", r"()[Lcom/fasterxml/jackson/core/JsonToken;"); /// from: static public com.fasterxml.jackson.core.JsonToken[] values() /// The returned object must be deleted after use, by calling the `delete` method. @@ -68,8 +66,10 @@ class JsonToken extends jni.JObject { .callStaticMethodWithArgs( _classRef, _id_values, jni.JniCallType.objectType, []).object); - static final _id_valueOf = jniAccessors.getStaticMethodIDOf(_classRef, - "valueOf", "(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonToken;"); + static final _id_valueOf = jniAccessors.getStaticMethodIDOf( + _classRef, + r"valueOf", + r"(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonToken;"); /// from: static public com.fasterxml.jackson.core.JsonToken valueOf(java.lang.String name) /// The returned object must be deleted after use, by calling the `delete` method. @@ -80,14 +80,14 @@ class JsonToken extends jni.JObject { jni.JniCallType.objectType, [name.reference]).object); - static final _id_id = jniAccessors.getMethodIDOf(_classRef, "id", "()I"); + static final _id_id = jniAccessors.getMethodIDOf(_classRef, r"id", r"()I"); /// from: public final int id() int id() => jniAccessors.callMethodWithArgs( reference, _id_id, jni.JniCallType.intType, []).integer; - static final _id_asString = - jniAccessors.getMethodIDOf(_classRef, "asString", "()Ljava/lang/String;"); + static final _id_asString = jniAccessors.getMethodIDOf( + _classRef, r"asString", r"()Ljava/lang/String;"); /// from: public final java.lang.String asString() /// The returned object must be deleted after use, by calling the `delete` method. @@ -96,7 +96,7 @@ class JsonToken extends jni.JObject { reference, _id_asString, jni.JniCallType.objectType, []).object); static final _id_asCharArray = - jniAccessors.getMethodIDOf(_classRef, "asCharArray", "()[C"); + jniAccessors.getMethodIDOf(_classRef, r"asCharArray", r"()[C"); /// from: public final char[] asCharArray() /// The returned object must be deleted after use, by calling the `delete` method. @@ -105,7 +105,7 @@ class JsonToken extends jni.JObject { reference, _id_asCharArray, jni.JniCallType.objectType, []).object); static final _id_asByteArray = - jniAccessors.getMethodIDOf(_classRef, "asByteArray", "()[B"); + jniAccessors.getMethodIDOf(_classRef, r"asByteArray", r"()[B"); /// from: public final byte[] asByteArray() /// The returned object must be deleted after use, by calling the `delete` method. @@ -114,7 +114,7 @@ class JsonToken extends jni.JObject { reference, _id_asByteArray, jni.JniCallType.objectType, []).object); static final _id_isNumeric = - jniAccessors.getMethodIDOf(_classRef, "isNumeric", "()Z"); + jniAccessors.getMethodIDOf(_classRef, r"isNumeric", r"()Z"); /// from: public final boolean isNumeric() /// @@ -124,7 +124,7 @@ class JsonToken extends jni.JObject { reference, _id_isNumeric, jni.JniCallType.booleanType, []).boolean; static final _id_isStructStart = - jniAccessors.getMethodIDOf(_classRef, "isStructStart", "()Z"); + jniAccessors.getMethodIDOf(_classRef, r"isStructStart", r"()Z"); /// from: public final boolean isStructStart() /// @@ -139,7 +139,7 @@ class JsonToken extends jni.JObject { reference, _id_isStructStart, jni.JniCallType.booleanType, []).boolean; static final _id_isStructEnd = - jniAccessors.getMethodIDOf(_classRef, "isStructEnd", "()Z"); + jniAccessors.getMethodIDOf(_classRef, r"isStructEnd", r"()Z"); /// from: public final boolean isStructEnd() /// @@ -154,7 +154,7 @@ class JsonToken extends jni.JObject { reference, _id_isStructEnd, jni.JniCallType.booleanType, []).boolean; static final _id_isScalarValue = - jniAccessors.getMethodIDOf(_classRef, "isScalarValue", "()Z"); + jniAccessors.getMethodIDOf(_classRef, r"isScalarValue", r"()Z"); /// from: public final boolean isScalarValue() /// @@ -168,7 +168,7 @@ class JsonToken extends jni.JObject { reference, _id_isScalarValue, jni.JniCallType.booleanType, []).boolean; static final _id_isBoolean = - jniAccessors.getMethodIDOf(_classRef, "isBoolean", "()Z"); + jniAccessors.getMethodIDOf(_classRef, r"isBoolean", r"()Z"); /// from: public final boolean isBoolean() /// diff --git a/pkgs/jnigen/test/kotlin_test/lib/kotlin.dart b/pkgs/jnigen/test/kotlin_test/lib/kotlin.dart index aaf5b7e93..7546deddd 100644 --- a/pkgs/jnigen/test/kotlin_test/lib/kotlin.dart +++ b/pkgs/jnigen/test/kotlin_test/lib/kotlin.dart @@ -14,7 +14,9 @@ // ignore_for_file: overridden_fields // ignore_for_file: unnecessary_cast // ignore_for_file: unused_element +// ignore_for_file: unused_field // ignore_for_file: unused_import +// ignore_for_file: unused_shown_name import "dart:isolate" show ReceivePort; import "dart:ffi" as ffi; @@ -38,12 +40,12 @@ class SuspendFun extends jni.JObject { /// The type which includes information such as the signature of this class. static const type = $SuspendFunType(); - static final _ctor = jniLookup>( "SuspendFun__ctor") .asFunction(); /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. SuspendFun() : super.fromRef(_ctor().object); static final _sayHello = jniLookup< @@ -58,8 +60,8 @@ class SuspendFun extends jni.JObject { /// The returned object must be deleted after use, by calling the `delete` method. Future sayHello() async { final $p = ReceivePort(); - final $c = jni.Jni.newPortContinuation($p); - _sayHello(reference, $c).object; + final $c = jni.JObject.fromRef(jni.Jni.newPortContinuation($p)); + _sayHello(reference, $c.reference).object; final $o = jni.JObjectPtr.fromAddress(await $p.first); final $k = const jni.JStringType().getClass().reference; if (jni.Jni.env.IsInstanceOf($o, $k) == 0) { @@ -82,8 +84,8 @@ class SuspendFun extends jni.JObject { /// The returned object must be deleted after use, by calling the `delete` method. Future sayHello1(jni.JString string) async { final $p = ReceivePort(); - final $c = jni.Jni.newPortContinuation($p); - _sayHello1(reference, string.reference, $c).object; + final $c = jni.JObject.fromRef(jni.Jni.newPortContinuation($p)); + _sayHello1(reference, string.reference, $c.reference).object; final $o = jni.JObjectPtr.fromAddress(await $p.first); final $k = const jni.JStringType().getClass().reference; if (jni.Jni.env.IsInstanceOf($o, $k) == 0) { diff --git a/pkgs/jnigen/test/package_resolver_test.dart b/pkgs/jnigen/test/package_resolver_test.dart index 7645e129f..39b899887 100644 --- a/pkgs/jnigen/test/package_resolver_test.dart +++ b/pkgs/jnigen/test/package_resolver_test.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. -import 'package:jnigen/src/writers/files_writer.dart'; +import 'package:jnigen/src/bindings/resolver.dart'; import 'package:test/test.dart'; class ResolverTest { @@ -13,7 +13,7 @@ class ResolverTest { } void main() { - final resolver = FilePathResolver( + final resolver = Resolver( importMap: { 'org.apache.pdfbox': 'package:pdfbox/pdfbox.dart', 'android.os.Process': 'package:android/os.dart', @@ -32,29 +32,28 @@ void main() { final tests = [ // Absolute imports resolved using import map - ResolverTest( - 'android.os.Process', 'package:android/os.dart', 'process_.Process'), + ResolverTest('android.os.Process', 'package:android/os.dart', 'process_.'), ResolverTest('org.apache.pdfbox.pdmodel.PDDocument', - 'package:pdfbox/pdfbox.dart', 'pddocument_.PDDocument'), + 'package:pdfbox/pdfbox.dart', 'pddocument_.'), // Relative imports // inner package - ResolverTest('a.b.c.D', 'c/D.dart', 'd_.D'), + ResolverTest('a.b.c.D', 'c/D.dart', 'd_.'), // inner package, deeper - ResolverTest('a.b.c.d.E', 'c/d/E.dart', 'e_.E'), + ResolverTest('a.b.c.d.E', 'c/d/E.dart', 'e_.'), // parent package - ResolverTest('a.X', '../X.dart', 'x_.X'), + ResolverTest('a.X', '../X.dart', 'x_.'), // unrelated package in same translation unit - ResolverTest('e.f.G', '../../e/f/G.dart', 'g_.G'), - ResolverTest('e.F', '../../e/F.dart', 'f_.F'), + ResolverTest('e.f.G', '../../e/f/G.dart', 'g_.'), + ResolverTest('e.F', '../../e/F.dart', 'f_.'), // neighbour package - ResolverTest('a.g.Y', '../g/Y.dart', 'y_.Y'), + ResolverTest('a.g.Y', '../g/Y.dart', 'y_.'), // inner package of a neighbour package - ResolverTest('a.m.n.P', '../m/n/P.dart', 'p_.P'), + ResolverTest('a.m.n.P', '../m/n/P.dart', 'p_.'), ]; for (var testCase in tests) { final binaryName = testCase.binaryName; - final packageName = getFileClassName(binaryName); + final packageName = Resolver.getFileClassName(binaryName); test( 'getImport $binaryName', () => expect(resolver.getImport(packageName, binaryName), @@ -62,6 +61,6 @@ void main() { test( 'resolve $binaryName', () => expect( - resolver.resolve(binaryName), equals(testCase.expectedName))); + resolver.resolvePrefix(binaryName), equals(testCase.expectedName))); } } diff --git a/pkgs/jnigen/test/regenerate_examples_test.dart b/pkgs/jnigen/test/regenerate_examples_test.dart index b49da06e0..0e2ac62ab 100644 --- a/pkgs/jnigen/test/regenerate_examples_test.dart +++ b/pkgs/jnigen/test/regenerate_examples_test.dart @@ -25,7 +25,7 @@ final kotlinPluginYaml = join(kotlinPlugin, 'jnigen.yaml'); /// [dartOutput] and [cOutput] are relative paths from example project dir. void testExample(String exampleName, String dartOutput, String? cOutput) { test('Generate and compare bindings for $exampleName', - timeout: Timeout.factor(2), () async { + timeout: const Timeout.factor(2), () async { final examplePath = join('example', exampleName); final configPath = join(examplePath, 'jnigen.yaml'); diff --git a/pkgs/jnigen/test/simple_package_test/lib/simple_package.dart b/pkgs/jnigen/test/simple_package_test/lib/simple_package.dart index 0f6841c48..c38553f62 100644 --- a/pkgs/jnigen/test/simple_package_test/lib/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/lib/simple_package.dart @@ -14,7 +14,9 @@ // ignore_for_file: overridden_fields // ignore_for_file: unnecessary_cast // ignore_for_file: unused_element +// ignore_for_file: unused_field // ignore_for_file: unused_import +// ignore_for_file: unused_shown_name import "dart:isolate" show ReceivePort; import "dart:ffi" as ffi; @@ -50,16 +52,17 @@ class Example extends jni.JObject { "get_Example__aux") .asFunction(); - /// from: static public com.github.dart_lang.jnigen.simple_package.Example.Aux aux - /// The returned object must be deleted after use, by calling the `delete` method. - static Example_Aux get aux => - const $Example_AuxType().fromRef(_get_aux().object); static final _set_aux = jniLookup< ffi.NativeFunction< jni.JThrowablePtr Function( ffi.Pointer)>>("set_Example__aux") .asFunction)>(); + /// from: static public com.github.dart_lang.jnigen.simple_package.Example.Aux aux + /// The returned object must be deleted after use, by calling the `delete` method. + static Example_Aux get aux => + const $Example_AuxType().fromRef(_get_aux().object); + /// from: static public com.github.dart_lang.jnigen.simple_package.Example.Aux aux /// The returned object must be deleted after use, by calling the `delete` method. static set aux(Example_Aux value) => _set_aux(value.reference); @@ -69,13 +72,14 @@ class Example extends jni.JObject { "get_Example__num") .asFunction(); - /// from: static public int num - static int get num => _get_num().integer; static final _set_num = jniLookup>( "set_Example__num") .asFunction(); + /// from: static public int num + static int get num => _get_num().integer; + /// from: static public int num static set num(int value) => _set_num(value); @@ -84,6 +88,7 @@ class Example extends jni.JObject { .asFunction(); /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. Example() : super.fromRef(_ctor().object); static final _ctor1 = @@ -92,6 +97,7 @@ class Example extends jni.JObject { .asFunction(); /// from: public void (int internal) + /// The returned object must be deleted after use, by calling the `delete` method. Example.ctor1(int internal) : super.fromRef(_ctor1(internal).object); static final _whichExample = jniLookup< @@ -225,7 +231,6 @@ class Example_Aux extends jni.JObject { /// The type which includes information such as the signature of this class. static const type = $Example_AuxType(); - static final _get_value = jniLookup< ffi.NativeFunction< jni.JniResult Function( @@ -236,14 +241,15 @@ class Example_Aux extends jni.JObject { jni.JObjectPtr, )>(); - /// from: public boolean value - bool get value => _get_value(reference).boolean; static final _set_value = jniLookup< ffi.NativeFunction< jni.JThrowablePtr Function( jni.JObjectPtr, ffi.Uint8)>>("set_Example_Aux__value") .asFunction(); + /// from: public boolean value + bool get value => _get_value(reference).boolean; + /// from: public boolean value set value(bool value) => _set_value(reference, value ? 1 : 0); @@ -253,6 +259,7 @@ class Example_Aux extends jni.JObject { .asFunction(); /// from: public void (boolean value) + /// The returned object must be deleted after use, by calling the `delete` method. Example_Aux(bool value) : super.fromRef(_ctor(value ? 1 : 0).object); static final _getValue = jniLookup< @@ -308,19 +315,19 @@ class C2 extends jni.JObject { /// The type which includes information such as the signature of this class. static const type = $C2Type(); - static final _get_CONSTANT = jniLookup>( "get_C2__CONSTANT") .asFunction(); - /// from: static public int CONSTANT - static int get CONSTANT => _get_CONSTANT().integer; static final _set_CONSTANT = jniLookup>( "set_C2__CONSTANT") .asFunction(); + /// from: static public int CONSTANT + static int get CONSTANT => _get_CONSTANT().integer; + /// from: static public int CONSTANT static set CONSTANT(int value) => _set_CONSTANT(value); @@ -329,6 +336,7 @@ class C2 extends jni.JObject { .asFunction(); /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. C2() : super.fromRef(_ctor().object); } @@ -365,12 +373,12 @@ class Example1 extends jni.JObject { /// The type which includes information such as the signature of this class. static const type = $Example1Type(); - static final _ctor = jniLookup>("Example1__ctor") .asFunction(); /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. Example1() : super.fromRef(_ctor().object); static final _whichExample = jniLookup< @@ -408,9 +416,7 @@ extension $Example1Array on jni.JArray { class GrandParent extends jni.JObject { late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type( - $T, - ); + jni.JObjType get $type => _$type ??= type($T); final jni.JObjType $T; @@ -438,9 +444,6 @@ class GrandParent extends jni.JObject { jni.JObjectPtr, )>(); - /// from: public T value - /// The returned object must be deleted after use, by calling the `delete` method. - T get value => $T.fromRef(_get_value(reference).object); static final _set_value = jniLookup< ffi.NativeFunction< jni.JThrowablePtr Function(jni.JObjectPtr, @@ -448,6 +451,10 @@ class GrandParent extends jni.JObject { .asFunction< jni.JThrowablePtr Function(jni.JObjectPtr, ffi.Pointer)>(); + /// from: public T value + /// The returned object must be deleted after use, by calling the `delete` method. + T get value => $T.fromRef(_get_value(reference).object); + /// from: public T value /// The returned object must be deleted after use, by calling the `delete` method. set value(T value) => _set_value(reference, value.reference); @@ -459,6 +466,7 @@ class GrandParent extends jni.JObject { .asFunction)>(); /// from: public void (T value) + /// The returned object must be deleted after use, by calling the `delete` method. GrandParent(this.$T, T value) : super.fromRef(_ctor(value.reference).object); static final _stringParent = jniLookup< @@ -470,7 +478,7 @@ class GrandParent extends jni.JObject { /// from: public com.github.dart_lang.jnigen.generics.GrandParent.Parent stringParent() /// The returned object must be deleted after use, by calling the `delete` method. GrandParent_Parent stringParent() => - $GrandParent_ParentType(const jni.JObjectType(), jni.JStringType()) + const $GrandParent_ParentType(jni.JObjectType(), jni.JStringType()) .fromRef(_stringParent(reference).object); static final _varParent = jniLookup< @@ -557,10 +565,7 @@ class GrandParent_Parent extends jni.JObject { late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type( - $T, - $S, - ); + jni.JObjType get $type => _$type ??= type($T, $S); final jni.JObjType $T; final jni.JObjType $S; @@ -593,9 +598,6 @@ class GrandParent_Parent jni.JObjectPtr, )>(); - /// from: public T parentValue - /// The returned object must be deleted after use, by calling the `delete` method. - T get parentValue => $T.fromRef(_get_parentValue(reference).object); static final _set_parentValue = jniLookup< ffi.NativeFunction< jni.JThrowablePtr Function( @@ -604,6 +606,10 @@ class GrandParent_Parent .asFunction< jni.JThrowablePtr Function(jni.JObjectPtr, ffi.Pointer)>(); + /// from: public T parentValue + /// The returned object must be deleted after use, by calling the `delete` method. + T get parentValue => $T.fromRef(_get_parentValue(reference).object); + /// from: public T parentValue /// The returned object must be deleted after use, by calling the `delete` method. set parentValue(T value) => _set_parentValue(reference, value.reference); @@ -618,9 +624,6 @@ class GrandParent_Parent jni.JObjectPtr, )>(); - /// from: public S value - /// The returned object must be deleted after use, by calling the `delete` method. - S get value => $S.fromRef(_get_value(reference).object); static final _set_value = jniLookup< ffi.NativeFunction< jni.JThrowablePtr Function(jni.JObjectPtr, @@ -628,6 +631,10 @@ class GrandParent_Parent .asFunction< jni.JThrowablePtr Function(jni.JObjectPtr, ffi.Pointer)>(); + /// from: public S value + /// The returned object must be deleted after use, by calling the `delete` method. + S get value => $S.fromRef(_get_value(reference).object); + /// from: public S value /// The returned object must be deleted after use, by calling the `delete` method. set value(S value) => _set_value(reference, value.reference); @@ -641,6 +648,7 @@ class GrandParent_Parent ffi.Pointer, ffi.Pointer)>(); /// from: public void (T parentValue, S value) + /// The returned object must be deleted after use, by calling the `delete` method. GrandParent_Parent(this.$T, this.$S, T parentValue, S value) : super.fromRef(_ctor(parentValue.reference, value.reference).object); } @@ -681,11 +689,7 @@ class GrandParent_Parent_Child extends jni.JObject { late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type( - $T, - $S, - $U, - ); + jni.JObjType get $type => _$type ??= type($T, $S, $U); final jni.JObjType $T; final jni.JObjType $S; @@ -722,9 +726,6 @@ class GrandParent_Parent_Child(); - /// from: public T grandParentValue - /// The returned object must be deleted after use, by calling the `delete` method. - T get grandParentValue => $T.fromRef(_get_grandParentValue(reference).object); static final _set_grandParentValue = jniLookup< ffi.NativeFunction< jni.JThrowablePtr Function( @@ -733,6 +734,10 @@ class GrandParent_Parent_Child)>(); + /// from: public T grandParentValue + /// The returned object must be deleted after use, by calling the `delete` method. + T get grandParentValue => $T.fromRef(_get_grandParentValue(reference).object); + /// from: public T grandParentValue /// The returned object must be deleted after use, by calling the `delete` method. set grandParentValue(T value) => @@ -748,9 +753,6 @@ class GrandParent_Parent_Child(); - /// from: public S parentValue - /// The returned object must be deleted after use, by calling the `delete` method. - S get parentValue => $S.fromRef(_get_parentValue(reference).object); static final _set_parentValue = jniLookup< ffi.NativeFunction< jni.JThrowablePtr Function( @@ -759,6 +761,10 @@ class GrandParent_Parent_Child)>(); + /// from: public S parentValue + /// The returned object must be deleted after use, by calling the `delete` method. + S get parentValue => $S.fromRef(_get_parentValue(reference).object); + /// from: public S parentValue /// The returned object must be deleted after use, by calling the `delete` method. set parentValue(S value) => _set_parentValue(reference, value.reference); @@ -773,9 +779,6 @@ class GrandParent_Parent_Child(); - /// from: public U value - /// The returned object must be deleted after use, by calling the `delete` method. - U get value => $U.fromRef(_get_value(reference).object); static final _set_value = jniLookup< ffi.NativeFunction< jni.JThrowablePtr Function( @@ -784,6 +787,10 @@ class GrandParent_Parent_Child)>(); + /// from: public U value + /// The returned object must be deleted after use, by calling the `delete` method. + U get value => $U.fromRef(_get_value(reference).object); + /// from: public U value /// The returned object must be deleted after use, by calling the `delete` method. set value(U value) => _set_value(reference, value.reference); @@ -799,6 +806,7 @@ class GrandParent_Parent_Child)>(); /// from: public void (T grandParentValue, S parentValue, U value) + /// The returned object must be deleted after use, by calling the `delete` method. GrandParent_Parent_Child( this.$T, this.$S, this.$U, T grandParentValue, S parentValue, U value) : super.fromRef(_ctor(grandParentValue.reference, parentValue.reference, @@ -846,9 +854,7 @@ extension $GrandParent_Parent_ChildArray< class GrandParent_StaticParent extends jni.JObject { late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type( - $S, - ); + jni.JObjType get $type => _$type ??= type($S); final jni.JObjType $S; @@ -876,9 +882,6 @@ class GrandParent_StaticParent extends jni.JObject { jni.JObjectPtr, )>(); - /// from: public S value - /// The returned object must be deleted after use, by calling the `delete` method. - S get value => $S.fromRef(_get_value(reference).object); static final _set_value = jniLookup< ffi.NativeFunction< jni.JThrowablePtr Function( @@ -887,6 +890,10 @@ class GrandParent_StaticParent extends jni.JObject { .asFunction< jni.JThrowablePtr Function(jni.JObjectPtr, ffi.Pointer)>(); + /// from: public S value + /// The returned object must be deleted after use, by calling the `delete` method. + S get value => $S.fromRef(_get_value(reference).object); + /// from: public S value /// The returned object must be deleted after use, by calling the `delete` method. set value(S value) => _set_value(reference, value.reference); @@ -898,6 +905,7 @@ class GrandParent_StaticParent extends jni.JObject { .asFunction)>(); /// from: public void (S value) + /// The returned object must be deleted after use, by calling the `delete` method. GrandParent_StaticParent(this.$S, S value) : super.fromRef(_ctor(value.reference).object); } @@ -936,10 +944,7 @@ class GrandParent_StaticParent_Child extends jni.JObject { late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type( - $S, - $U, - ); + jni.JObjType get $type => _$type ??= type($S, $U); final jni.JObjType $S; final jni.JObjType $U; @@ -972,9 +977,6 @@ class GrandParent_StaticParent_Child(); - /// from: public S parentValue - /// The returned object must be deleted after use, by calling the `delete` method. - S get parentValue => $S.fromRef(_get_parentValue(reference).object); static final _set_parentValue = jniLookup< ffi.NativeFunction< jni.JThrowablePtr Function( @@ -983,6 +985,10 @@ class GrandParent_StaticParent_Child)>(); + /// from: public S parentValue + /// The returned object must be deleted after use, by calling the `delete` method. + S get parentValue => $S.fromRef(_get_parentValue(reference).object); + /// from: public S parentValue /// The returned object must be deleted after use, by calling the `delete` method. set parentValue(S value) => _set_parentValue(reference, value.reference); @@ -997,9 +1003,6 @@ class GrandParent_StaticParent_Child(); - /// from: public U value - /// The returned object must be deleted after use, by calling the `delete` method. - U get value => $U.fromRef(_get_value(reference).object); static final _set_value = jniLookup< ffi.NativeFunction< jni.JThrowablePtr Function( @@ -1008,6 +1011,10 @@ class GrandParent_StaticParent_Child)>(); + /// from: public U value + /// The returned object must be deleted after use, by calling the `delete` method. + U get value => $U.fromRef(_get_value(reference).object); + /// from: public U value /// The returned object must be deleted after use, by calling the `delete` method. set value(U value) => _set_value(reference, value.reference); @@ -1022,6 +1029,7 @@ class GrandParent_StaticParent_Child, ffi.Pointer)>(); /// from: public void (S parentValue, U value) + /// The returned object must be deleted after use, by calling the `delete` method. GrandParent_StaticParent_Child(this.$S, this.$U, S parentValue, U value) : super.fromRef(_ctor(parentValue.reference, value.reference).object); } @@ -1062,10 +1070,7 @@ extension $GrandParent_StaticParent_ChildArray extends jni.JObject { late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type( - $K, - $V, - ); + jni.JObjType get $type => _$type ??= type($K, $V); final jni.JObjType $K; final jni.JObjType $V; @@ -1092,6 +1097,7 @@ class MyMap extends jni.JObject { .asFunction(); /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. MyMap(this.$K, this.$V) : super.fromRef(_ctor().object); static final _get0 = jniLookup< @@ -1127,9 +1133,10 @@ class MyMap extends jni.JObject { /// from: public com.github.dart_lang.jnigen.generics.MyStack.MyEntry> entryStack() /// The returned object must be deleted after use, by calling the `delete` method. - MyStack> entryStack() => $MyStackType( - $MyMap_MyEntryType(const jni.JObjectType(), const jni.JObjectType())) - .fromRef(_entryStack(reference).object); + MyStack> entryStack() => + const $MyStackType( + $MyMap_MyEntryType(jni.JObjectType(), jni.JObjectType())) + .fromRef(_entryStack(reference).object); } class $MyMapType @@ -1166,10 +1173,7 @@ class MyMap_MyEntry extends jni.JObject { late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type( - $K, - $V, - ); + jni.JObjType get $type => _$type ??= type($K, $V); final jni.JObjType $K; final jni.JObjType $V; @@ -1202,9 +1206,6 @@ class MyMap_MyEntry jni.JObjectPtr, )>(); - /// from: public K key - /// The returned object must be deleted after use, by calling the `delete` method. - K get key => $K.fromRef(_get_key(reference).object); static final _set_key = jniLookup< ffi.NativeFunction< jni.JThrowablePtr Function(jni.JObjectPtr, @@ -1212,6 +1213,10 @@ class MyMap_MyEntry .asFunction< jni.JThrowablePtr Function(jni.JObjectPtr, ffi.Pointer)>(); + /// from: public K key + /// The returned object must be deleted after use, by calling the `delete` method. + K get key => $K.fromRef(_get_key(reference).object); + /// from: public K key /// The returned object must be deleted after use, by calling the `delete` method. set key(K value) => _set_key(reference, value.reference); @@ -1226,9 +1231,6 @@ class MyMap_MyEntry jni.JObjectPtr, )>(); - /// from: public V value - /// The returned object must be deleted after use, by calling the `delete` method. - V get value => $V.fromRef(_get_value(reference).object); static final _set_value = jniLookup< ffi.NativeFunction< jni.JThrowablePtr Function(jni.JObjectPtr, @@ -1236,6 +1238,10 @@ class MyMap_MyEntry .asFunction< jni.JThrowablePtr Function(jni.JObjectPtr, ffi.Pointer)>(); + /// from: public V value + /// The returned object must be deleted after use, by calling the `delete` method. + V get value => $V.fromRef(_get_value(reference).object); + /// from: public V value /// The returned object must be deleted after use, by calling the `delete` method. set value(V value) => _set_value(reference, value.reference); @@ -1249,6 +1255,7 @@ class MyMap_MyEntry ffi.Pointer, ffi.Pointer)>(); /// from: public void (K key, V value) + /// The returned object must be deleted after use, by calling the `delete` method. MyMap_MyEntry(this.$K, this.$V, K key, V value) : super.fromRef(_ctor(key.reference, value.reference).object); } @@ -1288,9 +1295,7 @@ extension $MyMap_MyEntryArray class MyStack extends jni.JObject { late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type( - $T, - ); + jni.JObjType get $type => _$type ??= type($T); final jni.JObjType $T; @@ -1313,6 +1318,7 @@ class MyStack extends jni.JObject { .asFunction(); /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. MyStack(this.$T) : super.fromRef(_ctor().object); static final _push = jniLookup< @@ -1365,9 +1371,7 @@ extension $MyStackArray on jni.JArray> { class StringKeyedMap extends MyMap { late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type( - $V, - ); + jni.JObjType get $type => _$type ??= type($V); final jni.JObjType $V; @@ -1390,6 +1394,7 @@ class StringKeyedMap extends MyMap { .asFunction(); /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. StringKeyedMap(this.$V) : super.fromRef(const jni.JStringType(), $V, _ctor().object); } @@ -1435,12 +1440,12 @@ class StringStack extends MyStack { /// The type which includes information such as the signature of this class. static const type = $StringStackType(); - static final _ctor = jniLookup>( "StringStack__ctor") .asFunction(); /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. StringStack() : super.fromRef(const jni.JStringType(), _ctor().object); } @@ -1469,9 +1474,7 @@ extension $StringStackArray on jni.JArray { class StringValuedMap extends MyMap { late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type( - $K, - ); + jni.JObjType get $type => _$type ??= type($K); final jni.JObjType $K; @@ -1494,6 +1497,7 @@ class StringValuedMap extends MyMap { .asFunction(); /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. StringValuedMap(this.$K) : super.fromRef($K, const jni.JStringType(), _ctor().object); } @@ -1539,7 +1543,6 @@ class JsonSerializable_Case extends jni.JObject { /// The type which includes information such as the signature of this class. static const type = $JsonSerializable_CaseType(); - static final _values = jniLookup>( "JsonSerializable_Case__values") @@ -1599,12 +1602,12 @@ class MyDataClass extends jni.JObject { /// The type which includes information such as the signature of this class. static const type = $MyDataClassType(); - static final _ctor = jniLookup>( "MyDataClass__ctor") .asFunction(); /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. MyDataClass() : super.fromRef(_ctor().object); } diff --git a/pkgs/jnigen/test/yaml_config_test.dart b/pkgs/jnigen/test/yaml_config_test.dart index 198457dc4..e995b6ac2 100644 --- a/pkgs/jnigen/test/yaml_config_test.dart +++ b/pkgs/jnigen/test/yaml_config_test.dart @@ -26,5 +26,5 @@ void main() { ]; final config = Config.parseArgs(args); await generateAndCompareBindings(config, lib, src); - }, timeout: Timeout.factor(4)); + }, timeout: const Timeout.factor(4)); } From 4562edc83b9f71c7acd26ec460938b5b05896c2d Mon Sep 17 00:00:00 2001 From: Daco Harkes Date: Thu, 23 Mar 2023 22:14:20 +0100 Subject: [PATCH 060/139] [jnigen] Add Coverage badge (https://github.com/dart-lang/jnigen/issues/205) --- pkgs/jnigen/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/jnigen/README.md b/pkgs/jnigen/README.md index d599e7caa..94a085563 100644 --- a/pkgs/jnigen/README.md +++ b/pkgs/jnigen/README.md @@ -1,4 +1,5 @@ [![Build Status](https://github.com/dart-lang/jnigen/workflows/Dart%20CI/badge.svg)](https://github.com/dart-lang/jnigen/actions?query=workflow%3A%22Dart+CI%22+branch%3Amain) +[![Coverage Status](https://coveralls.io/repos/github/dart-lang/jnigen/badge.svg?branch=main)](https://coveralls.io/github/dart-lang/jnigen?branch=main) ## Introduction Experimental bindings generator for Java bindings through dart:ffi and JNI. From a16ad441f462820f4816f6d3adfc5ce97165b732 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Wed, 29 Mar 2023 21:06:22 +0200 Subject: [PATCH 061/139] [jnigen] Generate JValue wrapper classes in pure Dart bindings (https://github.com/dart-lang/jnigen/issues/212) * closes https://github.com/dart-lang/jnigen/issues/221 --- .../integration_test/on_device_jni_test.dart | 18 +++---- pkgs/jni/lib/src/jni.dart | 6 +-- pkgs/jni/lib/src/jvalues.dart | 12 ++--- pkgs/jni/test/exception_test.dart | 6 +-- pkgs/jni/test/jni_test.dart | 18 +++---- pkgs/jni/test/jobject_test.dart | 14 +++--- .../lib/src/bindings/dart_generator.dart | 47 ++++++++++++++++--- .../fasterxml/jackson/core/JsonFactory.dart | 32 ++++++++----- .../fasterxml/jackson/core/JsonParser.dart | 31 +++++++----- 9 files changed, 117 insertions(+), 67 deletions(-) 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 2bc0d9a6b..3b547ad93 100644 --- a/pkgs/jni/example/integration_test/on_device_jni_test.dart +++ b/pkgs/jni/example/integration_test/on_device_jni_test.dart @@ -39,7 +39,7 @@ void main() { testWidgets("call a static method using JniClass APIs", (t) async { final integerClass = JniClass.fromRef(Jni.findClass("java/lang/Integer")); final result = integerClass.callStaticMethodByName( - "toHexString", "(I)Ljava/lang/String;", [31]); + "toHexString", "(I)Ljava/lang/String;", [JValueInt(31)]); final resultString = result.toDartString(); @@ -58,10 +58,9 @@ void main() { final nextIntMethod = random.getMethodID("nextInt", "(I)I"); for (int i = 0; i < 100; i++) { - int r = random.callMethod(nextIntMethod, [256 * 256]); + int r = random.callMethod(nextIntMethod, [JValueInt(256 * 256)]); int bits = 0; - final jbc = - longClass.callStaticMethod(bitCountMethod, [JValueLong(r)]); + final jbc = longClass.callStaticMethod(bitCountMethod, [r]); while (r != 0) { bits += r % 2; r = (r / 2).floor(); @@ -74,8 +73,8 @@ void main() { // Actually it's not even required to get a reference to class testWidgets("invoke_", (t) async { - final m = Jni.invokeStaticMethod("java/lang/Long", "min", "(JJ)J", - [JValueLong(1234), JValueLong(1324)], JniCallType.longType); + final m = Jni.invokeStaticMethod( + "java/lang/Long", "min", "(JJ)J", [1234, 1324], JniCallType.longType); expect(m, equals(1234)); }); @@ -98,7 +97,7 @@ void main() { final longClass = Jni.findJniClass("java/lang/Long"); const n = 1223334444; final strFromJava = longClass.callStaticMethodByName( - "toOctalString", "(J)Ljava/lang/String;", [JValueLong(n)]); + "toOctalString", "(J)Ljava/lang/String;", [n]); expect(strFromJava, equals(n.toRadixString(8))); longClass.delete(); }); @@ -110,8 +109,9 @@ void main() { }); testWidgets("use() method", (t) async { - final randomInt = Jni.newInstance("java/util/Random", "()V", []) - .use((random) => random.callMethodByName("nextInt", "(I)I", [15])); + final randomInt = Jni.newInstance("java/util/Random", "()V", []).use( + (random) => + random.callMethodByName("nextInt", "(I)I", [JValueInt(15)])); expect(randomInt, lessThan(15)); }); diff --git a/pkgs/jni/lib/src/jni.dart b/pkgs/jni/lib/src/jni.dart index b165f8ea2..4d5a2abd7 100644 --- a/pkgs/jni/lib/src/jni.dart +++ b/pkgs/jni/lib/src/jni.dart @@ -214,9 +214,9 @@ abstract class Jni { /// Converts passed arguments to JValue array. /// - /// int, bool, double and JObject types are converted out of the box. - /// Wrap values in types such as [JValueLong] to convert to other primitive - /// types such as `long`, `short` and `char`. + /// long, bool, double and JObject types are converted out of the box. + /// Wrap values in types such as [JValueInt] to convert to other primitive + /// types such as `int`, `short` and `char`. static Pointer jvalues(List args, {Allocator allocator = calloc}) { return toJValues(args, allocator: allocator); diff --git a/pkgs/jni/lib/src/jvalues.dart b/pkgs/jni/lib/src/jvalues.dart index 8718bb175..ce0cac6f3 100644 --- a/pkgs/jni/lib/src/jvalues.dart +++ b/pkgs/jni/lib/src/jvalues.dart @@ -17,7 +17,7 @@ void _fillJValue(Pointer pos, dynamic arg) { switch (arg.runtimeType) { case int: - pos.ref.i = arg; + pos.ref.j = arg; break; case bool: pos.ref.z = arg ? 1 : 0; @@ -32,8 +32,8 @@ void _fillJValue(Pointer pos, dynamic arg) { case JValueFloat: pos.ref.f = (arg as JValueFloat).value; break; - case JValueLong: - pos.ref.j = (arg as JValueLong).value; + case JValueInt: + pos.ref.i = (arg as JValueInt).value; break; case JValueShort: pos.ref.s = (arg as JValueShort).value; @@ -66,10 +66,10 @@ Pointer toJValues(List args, {Allocator allocator = calloc}) { } /// Use this class as wrapper to convert an integer -/// to Java `long` in jvalues method. -class JValueLong { +/// to Java `int` in jvalues method. +class JValueInt { int value; - JValueLong(this.value); + JValueInt(this.value); } /// Use this class as wrapper to convert an integer diff --git a/pkgs/jni/test/exception_test.dart b/pkgs/jni/test/exception_test.dart index c954678ae..c277b01b3 100644 --- a/pkgs/jni/test/exception_test.dart +++ b/pkgs/jni/test/exception_test.dart @@ -41,7 +41,7 @@ void main() { test("Use after free throws exception", () { final r = Jni.newInstance("java/util/Random", "()V", []); r.delete(); - expect(() => r.callMethodByName("nextInt", "(I)I", [256]), + expect(() => r.callMethodByName("nextInt", "(I)I", [JValueInt(256)]), throwsA(isA())); }); @@ -57,13 +57,13 @@ void main() { final r = Jni.newInstance("java/util/Random", "()V", []); expect( () => r.callMethodByName( - "nextInt", "(I)I", [256], JniCallType.doubleType), + "nextInt", "(I)I", [JValueInt(256)], JniCallType.doubleType), throwsA(isA())); }); test("An exception in JNI throws JniException in Dart", () { final r = Jni.newInstance("java/util/Random", "()V", []); - expect(() => r.callMethodByName("nextInt", "(I)I", [-1]), + expect(() => r.callMethodByName("nextInt", "(I)I", [JValueInt(-1)]), throwsA(isA())); }); } diff --git a/pkgs/jni/test/jni_test.dart b/pkgs/jni/test/jni_test.dart index a40ba813c..19bae21b3 100644 --- a/pkgs/jni/test/jni_test.dart +++ b/pkgs/jni/test/jni_test.dart @@ -49,26 +49,26 @@ void main() { }); test( - 'Manually lookup & call Long.toHexString', + 'Manually lookup & call Integer.toHexString', () => using((arena) { // Method names on JniEnv* from C JNI API are capitalized // like in original, while other extension methods // follow Dart naming conventions. - final longClass = - env.FindClass("java/lang/Long".toNativeChars(arena)); + final integerClass = + env.FindClass("java/lang/Integer".toNativeChars(arena)); // Refer JNI spec on how to construct method signatures // Passing wrong signature leads to a segfault final hexMethod = env.GetStaticMethodID( - longClass, + integerClass, "toHexString".toNativeChars(arena), - "(J)Ljava/lang/String;".toNativeChars(arena)); + "(I)Ljava/lang/String;".toNativeChars(arena)); - for (var i in [1, 80, 13, 76, 1134453224145]) { + for (var i in [1, 80, 13, 76, 11344]) { // if your argument is int, bool, or JObject (`Pointer`) // it can be directly placed in the list. To convert into different primitive // types, use JValue wrappers. - final jres = env.CallStaticObjectMethodA(longClass, hexMethod, - Jni.jvalues([JValueLong(i)], allocator: arena)); + final jres = env.CallStaticObjectMethodA(integerClass, hexMethod, + Jni.jvalues([JValueInt(i)], allocator: arena)); // use asDartString extension method on Pointer // to convert a String jobject result to string @@ -82,7 +82,7 @@ void main() { // java class exists. env.DeleteGlobalRef(jres); } - env.DeleteGlobalRef(longClass); + env.DeleteGlobalRef(integerClass); })); test("asJString extension method", () { diff --git a/pkgs/jni/test/jobject_test.dart b/pkgs/jni/test/jobject_test.dart index 5bafe7526..b055f7d6c 100644 --- a/pkgs/jni/test/jobject_test.dart +++ b/pkgs/jni/test/jobject_test.dart @@ -54,7 +54,7 @@ void main() { test("call a static method using JniClass APIs", () { final integerClass = Jni.findJniClass("java/lang/Integer"); final result = integerClass.callStaticMethodByName( - "toHexString", "(I)Ljava/lang/String;", [31]); + "toHexString", "(I)Ljava/lang/String;", [JValueInt(31)]); // if the object is supposed to be a Java string // you can call toDartString on it. @@ -95,10 +95,9 @@ void main() { final nextIntMethod = random.getMethodID("nextInt", "(I)I"); for (int i = 0; i < 100; i++) { - int r = random.callMethod(nextIntMethod, [256 * 256]); + int r = random.callMethod(nextIntMethod, [JValueInt(256 * 256)]); int bits = 0; - final jbc = - longClass.callStaticMethod(bitCountMethod, [JValueLong(r)]); + final jbc = longClass.callStaticMethod(bitCountMethod, [r]); while (r != 0) { bits += r % 2; r = (r / 2).floor(); @@ -133,7 +132,7 @@ void main() { final longClass = Jni.findJniClass("java/lang/Long"); const n = 1223334444; final strFromJava = longClass.callStaticMethodByName( - "toOctalString", "(J)Ljava/lang/String;", [JValueLong(n)]); + "toOctalString", "(J)Ljava/lang/String;", [n]); expect(strFromJava, equals(n.toRadixString(8))); longClass.delete(); }); @@ -163,8 +162,9 @@ void main() { // You can use() method on JObject for using once and deleting. test("use() method", () { - final randomInt = Jni.newInstance("java/util/Random", "()V", []) - .use((random) => random.callMethodByName("nextInt", "(I)I", [15])); + final randomInt = Jni.newInstance("java/util/Random", "()V", []).use( + (random) => + random.callMethodByName("nextInt", "(I)I", [JValueInt(15)])); expect(randomInt, lessThan(15)); }); diff --git a/pkgs/jnigen/lib/src/bindings/dart_generator.dart b/pkgs/jnigen/lib/src/bindings/dart_generator.dart index 6ae33960b..db532750d 100644 --- a/pkgs/jnigen/lib/src/bindings/dart_generator.dart +++ b/pkgs/jnigen/lib/src/bindings/dart_generator.dart @@ -925,13 +925,15 @@ class _MethodGenerator extends Visitor { String cCtor(Method node) { final name = node.finalName; - final params = node.params.accept(const _ParamCall()).join(', '); + final params = + node.params.accept(const _ParamCall(isCBased: true)).join(', '); return '_$name($params)'; } String dartOnlyCtor(Method node) { final name = node.finalName; - final params = node.params.accept(const _ParamCall()).join(', '); + final params = + node.params.accept(const _ParamCall(isCBased: false)).join(', '); return '$_accessors.newObjectWithArgs($_classRef, _id_$name, [$params])'; } @@ -939,7 +941,7 @@ class _MethodGenerator extends Visitor { final name = node.finalName; final params = [ if (!node.isStatic) _selfPointer, - ...node.params.accept(const _ParamCall()), + ...node.params.accept(const _ParamCall(isCBased: true)), ].join(', '); final resultGetter = node.returnType.accept(const _JniResultGetter()); return '_$name($params).$resultGetter'; @@ -950,7 +952,8 @@ class _MethodGenerator extends Visitor { final ifStatic = node.isStatic ? 'Static' : ''; final self = node.isStatic ? _classRef : _selfPointer; final callType = node.returnType.accept(const _CallType()); - final params = node.params.accept(const _ParamCall()).join(', '); + final params = + node.params.accept(const _ParamCall(isCBased: false)).join(', '); final resultGetter = node.returnType.accept(const _JniResultGetter()); return '$_accessors.call${ifStatic}MethodWithArgs($self, _id_$name, $callType, [$params]).$resultGetter'; } @@ -1105,11 +1108,43 @@ class _ParamDef extends Visitor { /// void bar(Foo foo) => _bar(foo.reference); /// ``` class _ParamCall extends Visitor { - const _ParamCall(); + final bool isCBased; + + const _ParamCall({required this.isCBased}); @override String visit(Param node) { final nativeSuffix = node.type.accept(const _ToNativeSuffix()); - return '${node.finalName}$nativeSuffix'; + final paramCall = '${node.finalName}$nativeSuffix'; + if (!isCBased) { + // We need to wrap [paramCall] in the appropriate wrapper class. + return node.type.accept(_JValueWrapper(paramCall)); + } + return paramCall; + } +} + +/// Wraps the parameter in the appropriate JValue wrapper class. +/// +/// For instance, `int` in Dart can be mapped to `long` or `int` or ... in Java. +/// The wrapper class is how we identify the type in pure dart bindings. +class _JValueWrapper extends TypeVisitor { + final String param; + + _JValueWrapper(this.param); + + @override + String visitNonPrimitiveType(ReferredType node) { + return param; + } + + @override + String visitPrimitiveType(PrimitiveType node) { + if (node.name == 'long' || + node.name == 'double' || + node.name == 'boolean') { + return param; + } + return '$_jni.JValue${node.name.capitalize()}($param)'; } } diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonFactory.dart b/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonFactory.dart index 9c8decbdf..899ab0077 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonFactory.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonFactory.dart @@ -1018,10 +1018,11 @@ class JsonFactory extends jni.JObject { jni.JArray data, int offset, int len) => const jsonparser_.$JsonParserType().fromRef(jniAccessors .callMethodWithArgs( - reference, - _id_createParser5, - jni.JniCallType.objectType, - [data.reference, offset, len]).object); + reference, _id_createParser5, jni.JniCallType.objectType, [ + data.reference, + jni.JValueInt(offset), + jni.JValueInt(len) + ]).object); static final _id_createParser6 = jniAccessors.getMethodIDOf( _classRef, @@ -1065,10 +1066,11 @@ class JsonFactory extends jni.JObject { jni.JArray content, int offset, int len) => const jsonparser_.$JsonParserType().fromRef(jniAccessors .callMethodWithArgs( - reference, - _id_createParser8, - jni.JniCallType.objectType, - [content.reference, offset, len]).object); + reference, _id_createParser8, jni.JniCallType.objectType, [ + content.reference, + jni.JValueInt(offset), + jni.JValueInt(len) + ]).object); static final _id_createParser9 = jniAccessors.getMethodIDOf( _classRef, @@ -1414,10 +1416,11 @@ class JsonFactory extends jni.JObject { jni.JArray data, int offset, int len) => const jsonparser_.$JsonParserType().fromRef(jniAccessors .callMethodWithArgs( - reference, - _id_createJsonParser5, - jni.JniCallType.objectType, - [data.reference, offset, len]).object); + reference, _id_createJsonParser5, jni.JniCallType.objectType, [ + data.reference, + jni.JValueInt(offset), + jni.JValueInt(len) + ]).object); static final _id_createJsonParser6 = jniAccessors.getMethodIDOf( _classRef, @@ -1610,7 +1613,10 @@ class JsonFactory_Feature extends jni.JObject { /// from: public boolean enabledIn(int flags) bool enabledIn(int flags) => jniAccessors.callMethodWithArgs( - reference, _id_enabledIn, jni.JniCallType.booleanType, [flags]).boolean; + reference, + _id_enabledIn, + jni.JniCallType.booleanType, + [jni.JValueInt(flags)]).boolean; static final _id_getMask = jniAccessors.getMethodIDOf(_classRef, r"getMask", r"()I"); diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonParser.dart b/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonParser.dart index c37156055..ee9ceff99 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonParser.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonParser.dart @@ -93,8 +93,8 @@ class JsonParser extends jni.JObject { /// from: protected void (int features) /// The returned object must be deleted after use, by calling the `delete` method. JsonParser.ctor1(int features) - : super.fromRef(jniAccessors - .newObjectWithArgs(_classRef, _id_ctor1, [features]).object); + : super.fromRef(jniAccessors.newObjectWithArgs( + _classRef, _id_ctor1, [jni.JValueInt(features)]).object); static final _id_getCodec = jniAccessors.getMethodIDOf( _classRef, r"getCodec", r"()Lcom/fasterxml/jackson/core/ObjectCodec;"); @@ -658,8 +658,11 @@ class JsonParser extends jni.JObject { ///@since 2.3 ///@deprecated Since 2.7, use \#overrideStdFeatures(int, int) instead JsonParser setFeatureMask(int mask) => - const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs(reference, - _id_setFeatureMask, jni.JniCallType.objectType, [mask]).object); + const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_setFeatureMask, + jni.JniCallType.objectType, + [jni.JValueInt(mask)]).object); static final _id_overrideStdFeatures = jniAccessors.getMethodIDOf(_classRef, r"overrideStdFeatures", r"(II)Lcom/fasterxml/jackson/core/JsonParser;"); @@ -684,7 +687,7 @@ class JsonParser extends jni.JObject { reference, _id_overrideStdFeatures, jni.JniCallType.objectType, - [values, mask]).object); + [jni.JValueInt(values), jni.JValueInt(mask)]).object); static final _id_getFormatFeatures = jniAccessors.getMethodIDOf(_classRef, r"getFormatFeatures", r"()I"); @@ -721,7 +724,7 @@ class JsonParser extends jni.JObject { reference, _id_overrideFormatFeatures, jni.JniCallType.objectType, - [values, mask]).object); + [jni.JValueInt(values), jni.JValueInt(mask)]).object); static final _id_nextToken = jniAccessors.getMethodIDOf( _classRef, r"nextToken", r"()Lcom/fasterxml/jackson/core/JsonToken;"); @@ -860,7 +863,7 @@ class JsonParser extends jni.JObject { reference, _id_nextIntValue, jni.JniCallType.intType, - [defaultValue]).integer; + [jni.JValueInt(defaultValue)]).integer; static final _id_nextLongValue = jniAccessors.getMethodIDOf(_classRef, r"nextLongValue", r"(J)J"); @@ -1058,8 +1061,8 @@ class JsonParser extends jni.JObject { ///@param id Token id to match (from (@link JsonTokenId}) ///@return {@code True} if the parser current points to specified token ///@since 2.5 - bool hasTokenId(int id) => jniAccessors.callMethodWithArgs( - reference, _id_hasTokenId, jni.JniCallType.booleanType, [id]).boolean; + bool hasTokenId(int id) => jniAccessors.callMethodWithArgs(reference, + _id_hasTokenId, jni.JniCallType.booleanType, [jni.JValueInt(id)]).boolean; static final _id_hasToken = jniAccessors.getMethodIDOf( _classRef, r"hasToken", r"(Lcom/fasterxml/jackson/core/JsonToken;)Z"); @@ -1798,7 +1801,10 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems int getValueAsInt1(int def) => jniAccessors.callMethodWithArgs( - reference, _id_getValueAsInt1, jni.JniCallType.intType, [def]).integer; + reference, + _id_getValueAsInt1, + jni.JniCallType.intType, + [jni.JValueInt(def)]).integer; static final _id_getValueAsLong = jniAccessors.getMethodIDOf(_classRef, r"getValueAsLong", r"()J"); @@ -2282,7 +2288,10 @@ class JsonParser_Feature extends jni.JObject { /// from: public boolean enabledIn(int flags) bool enabledIn(int flags) => jniAccessors.callMethodWithArgs( - reference, _id_enabledIn, jni.JniCallType.booleanType, [flags]).boolean; + reference, + _id_enabledIn, + jni.JniCallType.booleanType, + [jni.JValueInt(flags)]).boolean; static final _id_getMask = jniAccessors.getMethodIDOf(_classRef, r"getMask", r"()I"); From 5883326dfa17dc15d4b8a23cbbc773102c818cb7 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Thu, 30 Mar 2023 10:11:27 +0200 Subject: [PATCH 062/139] [jnigen] Remove array extensions from the generated code (https://github.com/dart-lang/jnigen/issues/217) --- pkgs/jni/lib/src/jarray.dart | 20 +- .../in_app_java/lib/android_utils.dart | 34 --- .../kotlin_plugin/lib/kotlin_bindings.dart | 11 - .../lib/notifications.dart | 11 - .../org/apache/pdfbox/pdmodel/PDDocument.dart | 11 - .../pdfbox/pdmodel/PDDocumentInformation.dart | 11 - .../apache/pdfbox/text/PDFTextStripper.dart | 11 - .../lib/src/bindings/dart_generator.dart | 17 -- .../fasterxml/jackson/core/JsonFactory.dart | 22 -- .../fasterxml/jackson/core/JsonParser.dart | 33 --- .../com/fasterxml/jackson/core/JsonToken.dart | 11 - pkgs/jnigen/test/kotlin_test/lib/kotlin.dart | 11 - .../lib/simple_package.dart | 198 ------------------ 13 files changed, 5 insertions(+), 396 deletions(-) diff --git a/pkgs/jni/lib/src/jarray.dart b/pkgs/jni/lib/src/jarray.dart index d1e8ac40a..92f05b4f1 100644 --- a/pkgs/jni/lib/src/jarray.dart +++ b/pkgs/jni/lib/src/jarray.dart @@ -312,17 +312,17 @@ extension DoubleArray on JArray { } extension ObjectArray on JArray { - JObject operator [](int index) { - return JObject.fromRef(elementAt(index, JniCallType.objectType).object); + T operator [](int index) { + return (elementType as JObjType) + .fromRef(elementAt(index, JniCallType.objectType).object); } - void operator []=(int index, JObject value) { + void operator []=(int index, T value) { RangeError.checkValidIndex(index, this); _env.SetObjectArrayElement(reference, index, value.reference); } - void setRange(int start, int end, Iterable iterable, - [int skipCount = 0]) { + void setRange(int start, int end, Iterable iterable, [int skipCount = 0]) { RangeError.checkValidRange(start, end, length); final size = end - start; final it = iterable.skip(skipCount).take(size); @@ -344,13 +344,3 @@ extension ArrayArray on JArray> { (this as JArray)[index] = value; } } - -extension StringArray on JArray { - JString operator [](int index) { - return JString.fromRef(elementAt(index, JniCallType.objectType).object); - } - - void operator []=(int index, JString value) { - (this as JArray)[index] = value; - } -} diff --git a/pkgs/jnigen/example/in_app_java/lib/android_utils.dart b/pkgs/jnigen/example/in_app_java/lib/android_utils.dart index 75abb32a0..4030ba74c 100644 --- a/pkgs/jnigen/example/in_app_java/lib/android_utils.dart +++ b/pkgs/jnigen/example/in_app_java/lib/android_utils.dart @@ -60,17 +60,6 @@ class $AndroidUtilsType extends jni.JObjType { AndroidUtils fromRef(jni.JObjectPtr ref) => AndroidUtils.fromRef(ref); } -extension $AndroidUtilsArray on jni.JArray { - AndroidUtils operator [](int index) { - return (elementType as $AndroidUtilsType) - .fromRef(elementAt(index, jni.JniCallType.objectType).object); - } - - void operator []=(int index, AndroidUtils value) { - (this as jni.JArray)[index] = value; - } -} - /// from: android.os.Build class Build extends jni.JObject { late final jni.JObjType? _$type; @@ -399,17 +388,6 @@ class $BuildType extends jni.JObjType { Build fromRef(jni.JObjectPtr ref) => Build.fromRef(ref); } -extension $BuildArray on jni.JArray { - Build operator [](int index) { - return (elementType as $BuildType) - .fromRef(elementAt(index, jni.JniCallType.objectType).object); - } - - void operator []=(int index, Build value) { - (this as jni.JArray)[index] = value; - } -} - /// from: java.util.HashMap class HashMap extends jni.JObject { @@ -795,15 +773,3 @@ class $HashMapType @override HashMap fromRef(jni.JObjectPtr ref) => HashMap.fromRef($K, $V, ref); } - -extension $HashMapArray - on jni.JArray> { - HashMap operator [](int index) { - return (elementType as $HashMapType) - .fromRef(elementAt(index, jni.JniCallType.objectType).object); - } - - void operator []=(int index, HashMap value) { - (this as jni.JArray)[index] = value; - } -} diff --git a/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart b/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart index f508dacda..b6a9bcaf9 100644 --- a/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart +++ b/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart @@ -76,14 +76,3 @@ class $ExampleType extends jni.JObjType { @override Example fromRef(jni.JObjectPtr ref) => Example.fromRef(ref); } - -extension $ExampleArray on jni.JArray { - Example operator [](int index) { - return (elementType as $ExampleType) - .fromRef(elementAt(index, jni.JniCallType.objectType).object); - } - - void operator []=(int index, Example value) { - (this as jni.JArray)[index] = value; - } -} diff --git a/pkgs/jnigen/example/notification_plugin/lib/notifications.dart b/pkgs/jnigen/example/notification_plugin/lib/notifications.dart index 028904a1f..7d93c7cf8 100644 --- a/pkgs/jnigen/example/notification_plugin/lib/notifications.dart +++ b/pkgs/jnigen/example/notification_plugin/lib/notifications.dart @@ -76,14 +76,3 @@ class $NotificationsType extends jni.JObjType { @override Notifications fromRef(jni.JObjectPtr ref) => Notifications.fromRef(ref); } - -extension $NotificationsArray on jni.JArray { - Notifications operator [](int index) { - return (elementType as $NotificationsType) - .fromRef(elementAt(index, jni.JniCallType.objectType).object); - } - - void operator []=(int index, Notifications value) { - (this as jni.JArray)[index] = value; - } -} 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 15e060e0e..ebafa96f3 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 @@ -1332,14 +1332,3 @@ class $PDDocumentType extends jni.JObjType { @override PDDocument fromRef(jni.JObjectPtr ref) => PDDocument.fromRef(ref); } - -extension $PDDocumentArray on jni.JArray { - PDDocument operator [](int index) { - return (elementType as $PDDocumentType) - .fromRef(elementAt(index, jni.JniCallType.objectType).object); - } - - void operator []=(int index, PDDocument value) { - (this as jni.JArray)[index] = value; - } -} 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 30e40767b..bcb265542 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 @@ -450,14 +450,3 @@ class $PDDocumentInformationType extends jni.JObjType { PDDocumentInformation fromRef(jni.JObjectPtr ref) => PDDocumentInformation.fromRef(ref); } - -extension $PDDocumentInformationArray on jni.JArray { - PDDocumentInformation operator [](int index) { - return (elementType as $PDDocumentInformationType) - .fromRef(elementAt(index, jni.JniCallType.objectType).object); - } - - void operator []=(int index, PDDocumentInformation value) { - (this as jni.JArray)[index] = value; - } -} 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 aff6055f9..ccf668b97 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 @@ -1234,14 +1234,3 @@ class $PDFTextStripperType extends jni.JObjType { @override PDFTextStripper fromRef(jni.JObjectPtr ref) => PDFTextStripper.fromRef(ref); } - -extension $PDFTextStripperArray on jni.JArray { - PDFTextStripper operator [](int index) { - return (elementType as $PDFTextStripperType) - .fromRef(elementAt(index, jni.JniCallType.objectType).object); - } - - void operator []=(int index, PDFTextStripper value) { - (this as jni.JArray)[index] = value; - } -} diff --git a/pkgs/jnigen/lib/src/bindings/dart_generator.dart b/pkgs/jnigen/lib/src/bindings/dart_generator.dart index db532750d..56fff02a6 100644 --- a/pkgs/jnigen/lib/src/bindings/dart_generator.dart +++ b/pkgs/jnigen/lib/src/bindings/dart_generator.dart @@ -256,9 +256,6 @@ class _ClassGenerator extends Visitor { static const staticTypeGetter = 'type'; static const instanceTypeGetter = '\$$staticTypeGetter'; - static const arrayExtensionPrefix = '\$'; - static const arrayExtensionSuffix = 'Array'; - @override void visit(ClassDecl node) { final isDartOnly = @@ -388,20 +385,6 @@ class $typeClassName$typeParamsDef extends $_jType<$name$typeParamsCall> { ); } -'''); - - // Array extension - s.write(''' -extension $arrayExtensionPrefix$name$arrayExtensionSuffix$typeParamsDef on $_jArray<$name$typeParamsCall> { - $name$typeParamsCall operator [](int index) { - return (elementType as $typeClassName$typeParamsCall) - .fromRef(elementAt(index, $_jni.JniCallType.objectType).object); - } - - void operator []=(int index, $name$typeParamsCall value) { - (this as $_jArray<$_jObject>)[index] = value; - } -} '''); log.finest('Generated bindings for class ${node.binaryName}'); } diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonFactory.dart b/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonFactory.dart index 899ab0077..7ce9e774a 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonFactory.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonFactory.dart @@ -1539,17 +1539,6 @@ class $JsonFactoryType extends jni.JObjType { JsonFactory fromRef(jni.JObjectPtr ref) => JsonFactory.fromRef(ref); } -extension $JsonFactoryArray on jni.JArray { - JsonFactory operator [](int index) { - return (elementType as $JsonFactoryType) - .fromRef(elementAt(index, jni.JniCallType.objectType).object); - } - - void operator []=(int index, JsonFactory value) { - (this as jni.JArray)[index] = value; - } -} - /// from: com.fasterxml.jackson.core.JsonFactory$Feature /// /// Enumeration that defines all on/off features that can only be @@ -1636,14 +1625,3 @@ class $JsonFactory_FeatureType extends jni.JObjType { JsonFactory_Feature fromRef(jni.JObjectPtr ref) => JsonFactory_Feature.fromRef(ref); } - -extension $JsonFactory_FeatureArray on jni.JArray { - JsonFactory_Feature operator [](int index) { - return (elementType as $JsonFactory_FeatureType) - .fromRef(elementAt(index, jni.JniCallType.objectType).object); - } - - void operator []=(int index, JsonFactory_Feature value) { - (this as jni.JArray)[index] = value; - } -} diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonParser.dart b/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonParser.dart index ee9ceff99..1f71c76d1 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonParser.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonParser.dart @@ -2215,17 +2215,6 @@ class $JsonParserType extends jni.JObjType { JsonParser fromRef(jni.JObjectPtr ref) => JsonParser.fromRef(ref); } -extension $JsonParserArray on jni.JArray { - JsonParser operator [](int index) { - return (elementType as $JsonParserType) - .fromRef(elementAt(index, jni.JniCallType.objectType).object); - } - - void operator []=(int index, JsonParser value) { - (this as jni.JArray)[index] = value; - } -} - /// from: com.fasterxml.jackson.core.JsonParser$Feature /// /// Enumeration that defines all on/off features for parsers. @@ -2312,17 +2301,6 @@ class $JsonParser_FeatureType extends jni.JObjType { JsonParser_Feature.fromRef(ref); } -extension $JsonParser_FeatureArray on jni.JArray { - JsonParser_Feature operator [](int index) { - return (elementType as $JsonParser_FeatureType) - .fromRef(elementAt(index, jni.JniCallType.objectType).object); - } - - void operator []=(int index, JsonParser_Feature value) { - (this as jni.JArray)[index] = value; - } -} - /// from: com.fasterxml.jackson.core.JsonParser$NumberType /// /// Enumeration of possible "native" (optimal) types that can be @@ -2374,14 +2352,3 @@ class $JsonParser_NumberTypeType extends jni.JObjType { JsonParser_NumberType fromRef(jni.JObjectPtr ref) => JsonParser_NumberType.fromRef(ref); } - -extension $JsonParser_NumberTypeArray on jni.JArray { - JsonParser_NumberType operator [](int index) { - return (elementType as $JsonParser_NumberTypeType) - .fromRef(elementAt(index, jni.JniCallType.objectType).object); - } - - void operator []=(int index, JsonParser_NumberType value) { - (this as jni.JArray)[index] = value; - } -} diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonToken.dart b/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonToken.dart index 84d23d7bb..6f3e8b493 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonToken.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonToken.dart @@ -187,14 +187,3 @@ class $JsonTokenType extends jni.JObjType { @override JsonToken fromRef(jni.JObjectPtr ref) => JsonToken.fromRef(ref); } - -extension $JsonTokenArray on jni.JArray { - JsonToken operator [](int index) { - return (elementType as $JsonTokenType) - .fromRef(elementAt(index, jni.JniCallType.objectType).object); - } - - void operator []=(int index, JsonToken value) { - (this as jni.JArray)[index] = value; - } -} diff --git a/pkgs/jnigen/test/kotlin_test/lib/kotlin.dart b/pkgs/jnigen/test/kotlin_test/lib/kotlin.dart index 7546deddd..5d11a1734 100644 --- a/pkgs/jnigen/test/kotlin_test/lib/kotlin.dart +++ b/pkgs/jnigen/test/kotlin_test/lib/kotlin.dart @@ -104,14 +104,3 @@ class $SuspendFunType extends jni.JObjType { @override SuspendFun fromRef(jni.JObjectPtr ref) => SuspendFun.fromRef(ref); } - -extension $SuspendFunArray on jni.JArray { - SuspendFun operator [](int index) { - return (elementType as $SuspendFunType) - .fromRef(elementAt(index, jni.JniCallType.objectType).object); - } - - void operator []=(int index, SuspendFun value) { - (this as jni.JArray)[index] = value; - } -} diff --git a/pkgs/jnigen/test/simple_package_test/lib/simple_package.dart b/pkgs/jnigen/test/simple_package_test/lib/simple_package.dart index c38553f62..aca99d9ca 100644 --- a/pkgs/jnigen/test/simple_package_test/lib/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/lib/simple_package.dart @@ -208,17 +208,6 @@ class $ExampleType extends jni.JObjType { Example fromRef(jni.JObjectPtr ref) => Example.fromRef(ref); } -extension $ExampleArray on jni.JArray { - Example operator [](int index) { - return (elementType as $ExampleType) - .fromRef(elementAt(index, jni.JniCallType.objectType).object); - } - - void operator []=(int index, Example value) { - (this as jni.JArray)[index] = value; - } -} - /// from: com.github.dart_lang.jnigen.simple_package.Example$Aux class Example_Aux extends jni.JObject { late final jni.JObjType? _$type; @@ -292,17 +281,6 @@ class $Example_AuxType extends jni.JObjType { Example_Aux fromRef(jni.JObjectPtr ref) => Example_Aux.fromRef(ref); } -extension $Example_AuxArray on jni.JArray { - Example_Aux operator [](int index) { - return (elementType as $Example_AuxType) - .fromRef(elementAt(index, jni.JniCallType.objectType).object); - } - - void operator []=(int index, Example_Aux value) { - (this as jni.JArray)[index] = value; - } -} - /// from: com.github.dart_lang.jnigen.pkg2.C2 class C2 extends jni.JObject { late final jni.JObjType? _$type; @@ -350,17 +328,6 @@ class $C2Type extends jni.JObjType { C2 fromRef(jni.JObjectPtr ref) => C2.fromRef(ref); } -extension $C2Array on jni.JArray { - C2 operator [](int index) { - return (elementType as $C2Type) - .fromRef(elementAt(index, jni.JniCallType.objectType).object); - } - - void operator []=(int index, C2 value) { - (this as jni.JArray)[index] = value; - } -} - /// from: com.github.dart_lang.jnigen.pkg2.Example class Example1 extends jni.JObject { late final jni.JObjType? _$type; @@ -401,17 +368,6 @@ class $Example1Type extends jni.JObjType { Example1 fromRef(jni.JObjectPtr ref) => Example1.fromRef(ref); } -extension $Example1Array on jni.JArray { - Example1 operator [](int index) { - return (elementType as $Example1Type) - .fromRef(elementAt(index, jni.JniCallType.objectType).object); - } - - void operator []=(int index, Example1 value) { - (this as jni.JArray)[index] = value; - } -} - /// from: com.github.dart_lang.jnigen.generics.GrandParent class GrandParent extends jni.JObject { late final jni.JObjType? _$type; @@ -548,18 +504,6 @@ class $GrandParentType GrandParent fromRef(jni.JObjectPtr ref) => GrandParent.fromRef($T, ref); } -extension $GrandParentArray - on jni.JArray> { - GrandParent operator [](int index) { - return (elementType as $GrandParentType) - .fromRef(elementAt(index, jni.JniCallType.objectType).object); - } - - void operator []=(int index, GrandParent value) { - (this as jni.JArray)[index] = value; - } -} - /// from: com.github.dart_lang.jnigen.generics.GrandParent$Parent class GrandParent_Parent extends jni.JObject { @@ -672,18 +616,6 @@ class $GrandParent_ParentType GrandParent_Parent.fromRef($T, $S, ref); } -extension $GrandParent_ParentArray - on jni.JArray> { - GrandParent_Parent operator [](int index) { - return (elementType as $GrandParent_ParentType) - .fromRef(elementAt(index, jni.JniCallType.objectType).object); - } - - void operator []=(int index, GrandParent_Parent value) { - (this as jni.JArray)[index] = value; - } -} - /// from: com.github.dart_lang.jnigen.generics.GrandParent$Parent$Child class GrandParent_Parent_Child extends jni.JObject { @@ -836,20 +768,6 @@ class $GrandParent_Parent_ChildType on jni.JArray> { - GrandParent_Parent_Child operator [](int index) { - return (elementType as $GrandParent_Parent_ChildType) - .fromRef(elementAt(index, jni.JniCallType.objectType).object); - } - - void operator []=(int index, GrandParent_Parent_Child value) { - (this as jni.JArray)[index] = value; - } -} - /// from: com.github.dart_lang.jnigen.generics.GrandParent$StaticParent class GrandParent_StaticParent extends jni.JObject { late final jni.JObjType? _$type; @@ -927,18 +845,6 @@ class $GrandParent_StaticParentType GrandParent_StaticParent.fromRef($S, ref); } -extension $GrandParent_StaticParentArray - on jni.JArray> { - GrandParent_StaticParent operator [](int index) { - return (elementType as $GrandParent_StaticParentType) - .fromRef(elementAt(index, jni.JniCallType.objectType).object); - } - - void operator []=(int index, GrandParent_StaticParent value) { - (this as jni.JArray)[index] = value; - } -} - /// from: com.github.dart_lang.jnigen.generics.GrandParent$StaticParent$Child class GrandParent_StaticParent_Child extends jni.JObject { @@ -1054,18 +960,6 @@ class $GrandParent_StaticParent_ChildType on jni.JArray> { - GrandParent_StaticParent_Child operator [](int index) { - return (elementType as $GrandParent_StaticParent_ChildType) - .fromRef(elementAt(index, jni.JniCallType.objectType).object); - } - - void operator []=(int index, GrandParent_StaticParent_Child value) { - (this as jni.JArray)[index] = value; - } -} - /// from: com.github.dart_lang.jnigen.generics.MyMap class MyMap extends jni.JObject { late final jni.JObjType? _$type; @@ -1156,18 +1050,6 @@ class $MyMapType MyMap fromRef(jni.JObjectPtr ref) => MyMap.fromRef($K, $V, ref); } -extension $MyMapArray - on jni.JArray> { - MyMap operator [](int index) { - return (elementType as $MyMapType) - .fromRef(elementAt(index, jni.JniCallType.objectType).object); - } - - void operator []=(int index, MyMap value) { - (this as jni.JArray)[index] = value; - } -} - /// from: com.github.dart_lang.jnigen.generics.MyMap$MyEntry class MyMap_MyEntry extends jni.JObject { @@ -1279,18 +1161,6 @@ class $MyMap_MyEntryType MyMap_MyEntry.fromRef($K, $V, ref); } -extension $MyMap_MyEntryArray - on jni.JArray> { - MyMap_MyEntry operator [](int index) { - return (elementType as $MyMap_MyEntryType) - .fromRef(elementAt(index, jni.JniCallType.objectType).object); - } - - void operator []=(int index, MyMap_MyEntry value) { - (this as jni.JArray)[index] = value; - } -} - /// from: com.github.dart_lang.jnigen.generics.MyStack class MyStack extends jni.JObject { late final jni.JObjType? _$type; @@ -1356,17 +1226,6 @@ class $MyStackType extends jni.JObjType> { MyStack fromRef(jni.JObjectPtr ref) => MyStack.fromRef($T, ref); } -extension $MyStackArray on jni.JArray> { - MyStack operator [](int index) { - return (elementType as $MyStackType) - .fromRef(elementAt(index, jni.JniCallType.objectType).object); - } - - void operator []=(int index, MyStack value) { - (this as jni.JArray)[index] = value; - } -} - /// from: com.github.dart_lang.jnigen.generics.StringKeyedMap class StringKeyedMap extends MyMap { late final jni.JObjType? _$type; @@ -1416,18 +1275,6 @@ class $StringKeyedMapType StringKeyedMap.fromRef($V, ref); } -extension $StringKeyedMapArray - on jni.JArray> { - StringKeyedMap operator [](int index) { - return (elementType as $StringKeyedMapType) - .fromRef(elementAt(index, jni.JniCallType.objectType).object); - } - - void operator []=(int index, StringKeyedMap value) { - (this as jni.JArray)[index] = value; - } -} - /// from: com.github.dart_lang.jnigen.generics.StringStack class StringStack extends MyStack { late final jni.JObjType? _$type; @@ -1459,17 +1306,6 @@ class $StringStackType extends jni.JObjType { StringStack fromRef(jni.JObjectPtr ref) => StringStack.fromRef(ref); } -extension $StringStackArray on jni.JArray { - StringStack operator [](int index) { - return (elementType as $StringStackType) - .fromRef(elementAt(index, jni.JniCallType.objectType).object); - } - - void operator []=(int index, StringStack value) { - (this as jni.JArray)[index] = value; - } -} - /// from: com.github.dart_lang.jnigen.generics.StringValuedMap class StringValuedMap extends MyMap { late final jni.JObjType? _$type; @@ -1519,18 +1355,6 @@ class $StringValuedMapType StringValuedMap.fromRef($K, ref); } -extension $StringValuedMapArray - on jni.JArray> { - StringValuedMap operator [](int index) { - return (elementType as $StringValuedMapType) - .fromRef(elementAt(index, jni.JniCallType.objectType).object); - } - - void operator []=(int index, StringValuedMap value) { - (this as jni.JArray)[index] = value; - } -} - /// from: com.github.dart_lang.jnigen.annotations.JsonSerializable$Case class JsonSerializable_Case extends jni.JObject { late final jni.JObjType? _$type; @@ -1579,17 +1403,6 @@ class $JsonSerializable_CaseType extends jni.JObjType { JsonSerializable_Case.fromRef(ref); } -extension $JsonSerializable_CaseArray on jni.JArray { - JsonSerializable_Case operator [](int index) { - return (elementType as $JsonSerializable_CaseType) - .fromRef(elementAt(index, jni.JniCallType.objectType).object); - } - - void operator []=(int index, JsonSerializable_Case value) { - (this as jni.JArray)[index] = value; - } -} - /// from: com.github.dart_lang.jnigen.annotations.MyDataClass class MyDataClass extends jni.JObject { late final jni.JObjType? _$type; @@ -1621,14 +1434,3 @@ class $MyDataClassType extends jni.JObjType { @override MyDataClass fromRef(jni.JObjectPtr ref) => MyDataClass.fromRef(ref); } - -extension $MyDataClassArray on jni.JArray { - MyDataClass operator [](int index) { - return (elementType as $MyDataClassType) - .fromRef(elementAt(index, jni.JniCallType.objectType).object); - } - - void operator []=(int index, MyDataClass value) { - (this as jni.JArray)[index] = value; - } -} From f16de6d46a7d60832acf45ff65ff499b94840eb4 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Fri, 31 Mar 2023 21:34:19 +0200 Subject: [PATCH 063/139] [jnigen] 1.5x the timeout for the kotlin test (https://github.com/dart-lang/jnigen/issues/221) --- .../test/kotlin_test/generated_files_test.dart | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/pkgs/jnigen/test/kotlin_test/generated_files_test.dart b/pkgs/jnigen/test/kotlin_test/generated_files_test.dart index ee136e865..1bd25bd01 100644 --- a/pkgs/jnigen/test/kotlin_test/generated_files_test.dart +++ b/pkgs/jnigen/test/kotlin_test/generated_files_test.dart @@ -10,13 +10,17 @@ import 'generate.dart'; import '../test_util/test_util.dart'; void main() async { - test("Generate and compare bindings for kotlin_test", () async { - await generateAndCompareBindings( - getConfig(), - join(testRoot, "lib", "kotlin.dart"), - join(testRoot, "src"), - ); - }); // test if generated file == expected file + test( + "Generate and compare bindings for kotlin_test", + () async { + await generateAndCompareBindings( + getConfig(), + join(testRoot, "lib", "kotlin.dart"), + join(testRoot, "src"), + ); + }, + timeout: const Timeout.factor(1.5), + ); // test if generated file == expected file test("Generate and analyze bindings for kotlin_test - pure dart", () async { await generateAndAnalyzeBindings( getConfig(BindingsType.dartOnly), From ea63bdf9c3fcd9edde06c578628a8cf0e3775511 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Apr 2023 08:26:47 +0200 Subject: [PATCH 064/139] [jnigen] Bump actions/checkout from 3.3.0 to 3.5.0 (https://github.com/dart-lang/jnigen/issues/225) Bumps [actions/checkout](https://github.com/actions/checkout) from 3.3.0 to 3.5.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/ac593985615ec2ede58e132d2e21d2b1cbd6127c...8f4b7f84864484a7bf31766abe9204da3cbe65b3) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/test-package.yml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 96871c087..fb5709050 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -25,7 +25,7 @@ jobs: check_java_format: runs-on: ubuntu-latest steps: - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v2 minimum required + - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v2 minimum required - uses: axel-op/googlejavaformat-action@fe78db8a90171b6a836449f8d0e982d5d71e5c5a with: args: "--set-exit-if-changed" @@ -40,7 +40,7 @@ jobs: matrix: sdk: [stable] steps: - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c + - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d with: channel: ${{ matrix.sdk }} @@ -68,7 +68,7 @@ jobs: os: [ubuntu-latest] sdk: [stable, beta] steps: - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c + - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d with: channel: ${{ matrix.sdk }} @@ -114,7 +114,7 @@ jobs: run: working-directory: ./pkgs/jnigen/java steps: - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c + - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - uses: actions/setup-java@ea15b3b99cdc9ac45af1882d085e3f9297a75a8b with: distribution: 'zulu' @@ -128,7 +128,7 @@ jobs: run: working-directory: ./pkgs/jni steps: - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c + - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d with: channel: 'stable' @@ -163,7 +163,7 @@ jobs: run: working-directory: ./pkgs/jni steps: - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c + - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d with: channel: 'stable' @@ -208,7 +208,7 @@ jobs: run: working-directory: ./pkgs/jni steps: - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c + - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d with: channel: 'stable' @@ -232,7 +232,7 @@ jobs: run: working-directory: ./pkgs/jnigen steps: - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c + - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - name: Setup clang uses: egor-tensin/setup-clang@ef434b41eb33a70396fb336b1bae39c76d740c3d with: @@ -266,7 +266,7 @@ jobs: run: working-directory: ./pkgs/jni steps: - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c + - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d with: channel: 'stable' @@ -289,7 +289,7 @@ jobs: run: working-directory: ./pkgs/jnigen steps: - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c + - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - name: Setup clang format uses: ConorMacBride/install-package@3e7ad059e07782ee54fa35f827df52aae0626f30 with: @@ -314,7 +314,7 @@ jobs: run: working-directory: ./pkgs/jni/example steps: - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c + - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d with: channel: 'stable' @@ -338,7 +338,7 @@ jobs: run: working-directory: ./pkgs/jni/example steps: - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c + - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d with: channel: 'stable' @@ -358,7 +358,7 @@ jobs: run: working-directory: ./pkgs/jni/example steps: - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c + - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - uses: actions/setup-java@ea15b3b99cdc9ac45af1882d085e3f9297a75a8b with: distribution: 'zulu' @@ -377,7 +377,7 @@ jobs: run: working-directory: ./pkgs/jnigen/example/pdfbox_plugin steps: - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c + - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d with: channel: 'stable' From 9250933154b730fc68285c1b94b4da7f06a15ec4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Apr 2023 08:53:40 +0200 Subject: [PATCH 065/139] [jnigen] Bump actions/setup-java (https://github.com/dart-lang/jnigen/issues/226) Bumps [actions/setup-java](https://github.com/actions/setup-java) from ea15b3b99cdc9ac45af1882d085e3f9297a75a8b to 5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2. - [Release notes](https://github.com/actions/setup-java/releases) - [Commits](https://github.com/actions/setup-java/compare/ea15b3b99cdc9ac45af1882d085e3f9297a75a8b...5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2) --- updated-dependencies: - dependency-name: actions/setup-java dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/test-package.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index fb5709050..72e5333bd 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -74,7 +74,7 @@ jobs: channel: ${{ matrix.sdk }} cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@ea15b3b99cdc9ac45af1882d085e3f9297a75a8b + - uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 with: distribution: 'zulu' java-version: '11' @@ -115,7 +115,7 @@ jobs: working-directory: ./pkgs/jnigen/java steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - - uses: actions/setup-java@ea15b3b99cdc9ac45af1882d085e3f9297a75a8b + - uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 with: distribution: 'zulu' java-version: '11' @@ -134,7 +134,7 @@ jobs: channel: 'stable' cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@ea15b3b99cdc9ac45af1882d085e3f9297a75a8b + - uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 with: distribution: 'zulu' java-version: '11' @@ -169,7 +169,7 @@ jobs: channel: 'stable' cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@ea15b3b99cdc9ac45af1882d085e3f9297a75a8b + - uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 with: distribution: 'zulu' java-version: '11' @@ -214,7 +214,7 @@ jobs: channel: 'stable' cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@ea15b3b99cdc9ac45af1882d085e3f9297a75a8b + - uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 with: distribution: 'zulu' java-version: '11' @@ -243,7 +243,7 @@ jobs: channel: 'stable' cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@ea15b3b99cdc9ac45af1882d085e3f9297a75a8b + - uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 with: distribution: 'zulu' java-version: '11' @@ -272,7 +272,7 @@ jobs: channel: 'stable' cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@ea15b3b99cdc9ac45af1882d085e3f9297a75a8b + - uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 with: distribution: 'temurin' java-version: '11' @@ -299,7 +299,7 @@ jobs: channel: 'stable' cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@ea15b3b99cdc9ac45af1882d085e3f9297a75a8b + - uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 with: distribution: 'temurin' java-version: '11' @@ -320,7 +320,7 @@ jobs: channel: 'stable' cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@ea15b3b99cdc9ac45af1882d085e3f9297a75a8b + - uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 with: distribution: 'zulu' java-version: '11' @@ -344,7 +344,7 @@ jobs: channel: 'stable' cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@ea15b3b99cdc9ac45af1882d085e3f9297a75a8b + - uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 with: distribution: 'zulu' java-version: '11' @@ -359,7 +359,7 @@ jobs: working-directory: ./pkgs/jni/example steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - - uses: actions/setup-java@ea15b3b99cdc9ac45af1882d085e3f9297a75a8b + - uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 with: distribution: 'zulu' java-version: '11' @@ -383,7 +383,7 @@ jobs: channel: 'stable' cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@ea15b3b99cdc9ac45af1882d085e3f9297a75a8b + - uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 with: distribution: 'zulu' java-version: '11' From eea221dbb39bab53c47cb742ff7541e81a9c258b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Apr 2023 09:35:59 +0200 Subject: [PATCH 066/139] [jnigen] Bump subosito/flutter-action from 2.8.0 to 2.10.0 (https://github.com/dart-lang/jnigen/issues/223) Bumps [subosito/flutter-action](https://github.com/subosito/flutter-action) from 2.8.0 to 2.10.0. - [Release notes](https://github.com/subosito/flutter-action/releases) - [Commits](https://github.com/subosito/flutter-action/compare/dbf1fa04f4d2e52c33185153d06cdb5443aa189d...48cafc24713cca54bbe03cdc3a423187d413aafa) --- updated-dependencies: - dependency-name: subosito/flutter-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/test-package.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 72e5333bd..40a65298e 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -41,7 +41,7 @@ jobs: sdk: [stable] steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - - uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d + - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: ${{ matrix.sdk }} cache: true @@ -69,7 +69,7 @@ jobs: sdk: [stable, beta] steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - - uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d + - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: ${{ matrix.sdk }} cache: true @@ -129,7 +129,7 @@ jobs: working-directory: ./pkgs/jni steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - - uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d + - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' cache: true @@ -164,7 +164,7 @@ jobs: working-directory: ./pkgs/jni steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - - uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d + - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' cache: true @@ -209,7 +209,7 @@ jobs: working-directory: ./pkgs/jni steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - - uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d + - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' cache: true @@ -238,7 +238,7 @@ jobs: with: version: latest platform: x64 - - uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d + - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' cache: true @@ -267,7 +267,7 @@ jobs: working-directory: ./pkgs/jni steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - - uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d + - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' cache: true @@ -294,7 +294,7 @@ jobs: uses: ConorMacBride/install-package@3e7ad059e07782ee54fa35f827df52aae0626f30 with: brew: clang-format - - uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d + - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' cache: true @@ -315,7 +315,7 @@ jobs: working-directory: ./pkgs/jni/example steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - - uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d + - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' cache: true @@ -339,7 +339,7 @@ jobs: working-directory: ./pkgs/jni/example steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - - uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d + - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' cache: true @@ -363,7 +363,7 @@ jobs: with: distribution: 'zulu' java-version: '11' - - uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d + - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' cache: true @@ -378,7 +378,7 @@ jobs: working-directory: ./pkgs/jnigen/example/pdfbox_plugin steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - - uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d + - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' cache: true From 732f363c871f5efc9d5de2e3d26cfc2d97f8180d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Apr 2023 01:30:36 -0700 Subject: [PATCH 067/139] [jnigen] Bump coverallsapp/github-action from 1.2.4 to 2.0.0 (https://github.com/dart-lang/jnigen/issues/224) Bumps [coverallsapp/github-action](https://github.com/coverallsapp/github-action) from 1.2.4 to 2.0.0. - [Release notes](https://github.com/coverallsapp/github-action/releases) - [Commits](https://github.com/coverallsapp/github-action/compare/50c33ad324a9902697adbf2f92c22cf5023eacf1...67662d24394fd74bffcf7b462d1b432814159afd) --- updated-dependencies: - dependency-name: coverallsapp/github-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/test-package.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 40a65298e..92f5fd3cb 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -100,7 +100,7 @@ jobs: - name: Collect coverage run: dart pub global run coverage:test_with_coverage - name: Upload coverage - uses: coverallsapp/github-action@50c33ad324a9902697adbf2f92c22cf5023eacf1 + uses: coverallsapp/github-action@67662d24394fd74bffcf7b462d1b432814159afd with: github-token: ${{ secrets.GITHUB_TOKEN }} flag-name: jnigen_tests @@ -187,7 +187,7 @@ jobs: - name: Collect coverage run: dart pub global run coverage:test_with_coverage - name: Upload coverage - uses: coverallsapp/github-action@50c33ad324a9902697adbf2f92c22cf5023eacf1 + uses: coverallsapp/github-action@67662d24394fd74bffcf7b462d1b432814159afd with: github-token: ${{ secrets.GITHUB_TOKEN }} flag-name: jni_tests @@ -423,7 +423,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Coveralls finished - uses: coverallsapp/github-action@50c33ad324a9902697adbf2f92c22cf5023eacf1 + uses: coverallsapp/github-action@67662d24394fd74bffcf7b462d1b432814159afd with: github-token: ${{ secrets.github_token }} parallel-finished: true From 0dd2f0d0cabc016ec53a8c3501d6e3ee02f90df3 Mon Sep 17 00:00:00 2001 From: Daco Harkes Date: Tue, 4 Apr 2023 01:50:43 -0700 Subject: [PATCH 068/139] [jnigen] Use `package:cli_config` (https://github.com/dart-lang/jnigen/issues/197) --- pkgs/jnigen/bin/jnigen.dart | 3 + pkgs/jnigen/lib/src/config/yaml_reader.dart | 132 +++++++------------- pkgs/jnigen/pubspec.yaml | 2 +- pkgs/jnigen/test/config_test.dart | 30 ++--- 4 files changed, 63 insertions(+), 104 deletions(-) diff --git a/pkgs/jnigen/bin/jnigen.dart b/pkgs/jnigen/bin/jnigen.dart index a5065de57..518ba11be 100644 --- a/pkgs/jnigen/bin/jnigen.dart +++ b/pkgs/jnigen/bin/jnigen.dart @@ -12,6 +12,9 @@ void main(List args) async { } on ConfigException catch (e) { log.fatal(e); return; + } on FormatException catch (e) { + log.fatal(e); + return; } await generateJniBindings(config); } diff --git a/pkgs/jnigen/lib/src/config/yaml_reader.dart b/pkgs/jnigen/lib/src/config/yaml_reader.dart index 4347ecb24..ecae2cb32 100644 --- a/pkgs/jnigen/lib/src/config/yaml_reader.dart +++ b/pkgs/jnigen/lib/src/config/yaml_reader.dart @@ -6,15 +6,17 @@ import 'dart:io'; import 'package:args/args.dart'; import 'package:yaml/yaml.dart'; +import 'package:cli_config/cli_config.dart' as cli_config; import 'config_exception.dart'; /// YAML Reader which enables to override specific values from command line. class YamlReader { - YamlReader.of(this.cli, this.yaml, this.yamlFile); - Map cli; - Map yaml; - File? yamlFile; + final cli_config.Config _config; + + final Uri? _configRoot; + + YamlReader.of(this._config, this._configRoot); /// Parses the provided command line arguments and returns a [YamlReader]. /// @@ -42,19 +44,15 @@ class YamlReader { stderr.writeln(parser.usage); exit(1); } - final configFile = results['config'] as String?; - Map yamlMap = {}; - if (configFile != null) { + final configFilePath = results['config'] as String?; + String? configFileContents; + Uri? configFileUri; + if (configFilePath != null) { try { - final yamlInput = loadYaml(File(configFile).readAsStringSync(), - sourceUrl: Uri.file(configFile)); - if (yamlInput is Map) { - yamlMap = yamlInput; - } else { - throw ConfigException('YAML config must be set of key value pairs'); - } + configFileContents = File(configFilePath).readAsStringSync(); + configFileUri = File(configFilePath).uri; } on Exception catch (e) { - stderr.writeln('cannot read $configFile: $e'); + stderr.writeln('Cannot read $configFilePath: $e.'); } } final regex = RegExp('([a-z-_.]+)=(.+)'); @@ -69,97 +67,53 @@ class YamlReader { throw ConfigException('override does not match expected pattern'); } } + final config = cli_config.Config.fromConfigFileContents( + commandLineDefines: results['override'], + workingDirectory: Directory.current.uri, + environment: Platform.environment, + fileContents: configFileContents, + fileSourceUri: configFileUri, + ); return YamlReader.of( - properties, yamlMap, configFile != null ? File(configFile) : null); + config, + configFileUri?.resolve('.'), + ); } - bool? getBool(String property) { - if (cli.containsKey(property)) { - final v = cli[property]!; - if (v == 'true') { - return true; - } - if (v == 'false') { - return false; - } - throw ConfigException('expected boolean value for $property, got $v'); - } - return getYamlValue(property); - } + bool? getBool(String property) => _config.optionalBool(property); - String? getString(String property) { - final configValue = cli[property] ?? getYamlValue(property); - return configValue; - } + String? getString(String property) => _config.optionalString(property); /// Same as [getString] but path is resolved relative to YAML config if it's /// from YAML config. - String? getPath(String property) { - final cliOverride = cli[property]; - if (cliOverride != null) return cliOverride; - final path = getYamlValue(property); - if (path == null) return null; - // In (very unlikely) case YAML config didn't come from a file, - // do not try to resolve anything. - if (yamlFile == null) return path; - final yamlDir = yamlFile!.parent; - return yamlDir.uri.resolve(path).toFilePath(); - } + String? getPath(String property) => + _config.optionalPath(property)?.toFilePath(); - List? getStringList(String property) { - final configValue = cli[property]?.split(';') ?? - getYamlValue(property)?.cast(); - return configValue; - } + List? getStringList(String property) => _config.optionalStringList( + property, + splitCliPattern: ';', + combineAllConfigs: false, + ); List? getPathList(String property) { - final cliOverride = cli[property]?.split(';'); - if (cliOverride != null) return cliOverride; - final paths = getYamlValue(property)?.cast(); - if (paths == null) return null; - // In (very unlikely) case YAML config didn't come from a file. - if (yamlFile == null) return paths; - final yamlDir = yamlFile!.parent; - return paths.map((path) => yamlDir.uri.resolve(path).toFilePath()).toList(); + final configResult = _config.optionalPathList( + property, + combineAllConfigs: false, + splitCliPattern: ';', + ); + return configResult?.map((e) => e.path).toList(); } - String? getOneOf(String property, Set values) { - final value = cli[property] ?? getYamlValue(property); - if (value == null || values.contains(value)) { - return value; - } - throw ConfigException('expected one of $values for $property'); - } + String? getOneOf(String property, Set values) => + _config.optionalString(property, validValues: values); Map? getStringMap(String property) { - final value = getYamlValue(property); + final value = _config.valueOf(property); return value?.cast(); } - bool hasValue(String property) => getYamlValue(property) != null; - - T? getYamlValue(String property) { - final path = property.split('.'); - dynamic cursor = yaml; - String current = ''; - for (var i in path) { - if (cursor is YamlMap || cursor is Map) { - cursor = cursor[i]; - } else { - throw ConfigException('expected $current to be a YAML map'); - } - current = [if (current != '') current, i].join('.'); - if (cursor == null) { - return null; - } - } - if (cursor is! T) { - throw ConfigException( - 'expected $T for $property, got ${cursor.runtimeType}'); - } - return cursor; - } + bool hasValue(String property) => _config.valueOf(property) != null; /// Returns URI of the directory containing YAML config. - Uri? getConfigRoot() => yamlFile?.parent.uri; + Uri? getConfigRoot() => _configRoot; } diff --git a/pkgs/jnigen/pubspec.yaml b/pkgs/jnigen/pubspec.yaml index b944f6b5b..2a3c73151 100644 --- a/pkgs/jnigen/pubspec.yaml +++ b/pkgs/jnigen/pubspec.yaml @@ -17,6 +17,7 @@ dependencies: args: ^2.3.0 yaml: ^3.1.0 logging: ^1.0.2 + cli_config: ^0.1.0 dev_dependencies: lints: ^2.0.0 @@ -25,4 +26,3 @@ dev_dependencies: test: ^1.17.5 build_runner: ^2.2.0 json_serializable: ^6.6.0 - diff --git a/pkgs/jnigen/test/config_test.dart b/pkgs/jnigen/test/config_test.dart index 883bae8a2..fd935c370 100644 --- a/pkgs/jnigen/test/config_test.dart +++ b/pkgs/jnigen/test/config_test.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 'dart:io'; + import 'package:jnigen/src/config/config.dart'; import 'package:test/test.dart'; import 'package:path/path.dart' hide equals; @@ -10,12 +12,12 @@ import 'package:path/path.dart' as path show equals; import 'jackson_core_test/generate.dart'; const packageTests = 'test'; -final jacksonCoreTests = join(packageTests, 'jackson_core_test'); -final thirdParty = join(jacksonCoreTests, 'third_party'); -final lib = join(thirdParty, 'lib'); -final src = join(thirdParty, 'src'); -final testLib = join(thirdParty, 'test_', 'lib'); -final testSrc = join(thirdParty, 'test_', 'src'); +final jacksonCoreTests = absolute(packageTests, 'jackson_core_test'); +final thirdParty = absolute(jacksonCoreTests, 'third_party'); +final lib = absolute(thirdParty, 'lib'); +final src = absolute(thirdParty, 'src'); +final testLib = absolute(thirdParty, 'test_', 'lib'); +final testSrc = absolute(thirdParty, 'test_', 'src'); /// Compares 2 [Config] objects using [expect] to give useful errors when /// two fields are not equal. @@ -74,7 +76,7 @@ final jnigenYaml = join(jacksonCoreTests, 'jnigen.yaml'); Config parseYamlConfig({List overrides = const []}) => Config.parseArgs(['--config', jnigenYaml, ...overrides]); -void testForErrorChecking( +void testForErrorChecking( {required String name, required List overrides, dynamic Function(Config)? function}) { @@ -86,7 +88,7 @@ void testForErrorChecking( function(config); } }, - throwsA(isA()), + throwsA(isA()), ); }); } @@ -95,8 +97,8 @@ void main() { final config = Config.parseArgs([ '--config', jnigenYaml, - '-Doutput.c.path=$testSrc/', - '-Doutput.dart.path=$testLib/', + '-Doutput.c.path=$testSrc${Platform.pathSeparator}', + '-Doutput.dart.path=$testLib${Platform.pathSeparator}', ]); test('compare configuration values', () { @@ -104,19 +106,19 @@ void main() { }); group('Test for config error checking', () { - testForErrorChecking( + testForErrorChecking( name: 'Invalid bindings type', overrides: ['-Doutput.bindings_type=c_base'], ); - testForErrorChecking( + testForErrorChecking( name: 'Invalid output structure', overrides: ['-Doutput.dart.structure=singl_file'], ); - testForErrorChecking( + testForErrorChecking( name: 'Dart path not ending with /', overrides: ['-Doutput.dart.path=lib'], ); - testForErrorChecking( + testForErrorChecking( name: 'Invalid log level', overrides: ['-Dlog_level=inf'], ); From c9c73a09e15e1df4c88014611ef8071dc913f2c1 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Tue, 4 Apr 2023 11:25:03 +0200 Subject: [PATCH 069/139] [jnigen] 1.5x the timeout for the other kotlin test (https://github.com/dart-lang/jnigen/issues/229) --- .../test/kotlin_test/generated_files_test.dart | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pkgs/jnigen/test/kotlin_test/generated_files_test.dart b/pkgs/jnigen/test/kotlin_test/generated_files_test.dart index 1bd25bd01..9ae50e36f 100644 --- a/pkgs/jnigen/test/kotlin_test/generated_files_test.dart +++ b/pkgs/jnigen/test/kotlin_test/generated_files_test.dart @@ -21,9 +21,13 @@ void main() async { }, timeout: const Timeout.factor(1.5), ); // test if generated file == expected file - test("Generate and analyze bindings for kotlin_test - pure dart", () async { - await generateAndAnalyzeBindings( - getConfig(BindingsType.dartOnly), - ); - }); // test if generated file == expected file + test( + "Generate and analyze bindings for kotlin_test - pure dart", + () async { + await generateAndAnalyzeBindings( + getConfig(BindingsType.dartOnly), + ); + }, + timeout: const Timeout.factor(1.5), + ); // test if generated file == expected file } From e998636a8f3ba14ed61153cf01a9431a952bedd1 Mon Sep 17 00:00:00 2001 From: Mahesh Hegde <46179734+mahesh-hegde@users.noreply.github.com> Date: Tue, 4 Apr 2023 20:38:53 +0530 Subject: [PATCH 070/139] [jnigen] JAR handling improvements (https://github.com/dart-lang/jnigen/issues/220) * Move summarizer invocation into summary.dart for better testability. * Support reading source JARs (https://github.com/dart-lang/jnigen/issues/208) * Fix an issue where the summarizer failed when providing only classes and no source (https://github.com/dart-lang/jnigen/issues/147) --- pkgs/jnigen/bin/jnigen.dart | 2 - .../dart_lang/jnigen/apisummarizer/Main.java | 296 ++++-------------- .../apisummarizer/SummarizerOptions.java | 94 ++++++ .../apisummarizer/disasm/AsmSummarizer.java | 24 +- .../util/FileInputStreamProvider.java | 38 +++ .../util/InputStreamProvider.java | 17 + .../util/JarEntryFileObject.java | 41 +++ .../util/JarEntryInputStreamProvider.java | 29 ++ .../jnigen/apisummarizer/util/SearchUtil.java | 155 +++++++++ pkgs/jnigen/lib/src/generate_bindings.dart | 78 +---- pkgs/jnigen/lib/src/logging/logging.dart | 4 +- pkgs/jnigen/lib/src/summary/summary.dart | 84 +++++ .../lib/src/tools/build_summarizer.dart | 1 - pkgs/jnigen/test/summary_generation_test.dart | 168 ++++++++++ pkgs/jnigen/test/test_util/test_util.dart | 6 + 15 files changed, 700 insertions(+), 337 deletions(-) create mode 100644 pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/SummarizerOptions.java create mode 100644 pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/FileInputStreamProvider.java create mode 100644 pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/InputStreamProvider.java create mode 100644 pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/JarEntryFileObject.java create mode 100644 pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/JarEntryInputStreamProvider.java create mode 100644 pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/SearchUtil.java create mode 100644 pkgs/jnigen/test/summary_generation_test.dart diff --git a/pkgs/jnigen/bin/jnigen.dart b/pkgs/jnigen/bin/jnigen.dart index 518ba11be..be04b584f 100644 --- a/pkgs/jnigen/bin/jnigen.dart +++ b/pkgs/jnigen/bin/jnigen.dart @@ -11,10 +11,8 @@ void main(List args) async { config = Config.parseArgs(args); } on ConfigException catch (e) { log.fatal(e); - return; } on FormatException catch (e) { log.fatal(e); - return; } await generateJniBindings(config); } diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/Main.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/Main.java index d636f6529..07f4430c2 100644 --- a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/Main.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/Main.java @@ -4,134 +4,44 @@ package com.github.dart_lang.jnigen.apisummarizer; -import static com.github.dart_lang.jnigen.apisummarizer.util.ExceptionUtil.wrapCheckedException; - import com.github.dart_lang.jnigen.apisummarizer.disasm.AsmSummarizer; import com.github.dart_lang.jnigen.apisummarizer.doclet.SummarizerDoclet; import com.github.dart_lang.jnigen.apisummarizer.elements.ClassDecl; +import com.github.dart_lang.jnigen.apisummarizer.util.InputStreamProvider; import com.github.dart_lang.jnigen.apisummarizer.util.JsonUtil; import com.github.dart_lang.jnigen.apisummarizer.util.Log; -import com.github.dart_lang.jnigen.apisummarizer.util.StreamUtil; -import java.io.*; -import java.util.*; -import java.util.jar.JarFile; -import java.util.stream.Collectors; -import java.util.zip.ZipEntry; +import com.github.dart_lang.jnigen.apisummarizer.util.SearchUtil; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import javax.tools.DocumentationTool; +import javax.tools.JavaFileObject; import javax.tools.ToolProvider; import jdk.javadoc.doclet.Doclet; -import org.apache.commons.cli.*; public class Main { public enum Backend { - // Produce API descriptions from source files using Doclet API. + /** Produce API descriptions from source files using Doclet API. */ DOCLET, - // Produce API descriptions from class files under classpath. + /** Produce API descriptions from class files under classpath. */ ASM, - // Prefer source but fall back to JARs in classpath if sources not found. + /** Prefer source but fall back to JARs in classpath if sources not found. */ AUTO, } - public static class SummarizerOptions { - String sourcePath; - String classPath; - boolean useModules; - Backend backend; - String modulesList; - boolean addDependencies; - String toolArgs; - boolean verbose; - String outputFile; - String[] args; - - SummarizerOptions() {} - - public static SummarizerOptions fromCommandLine(CommandLine cmd) { - var opts = new SummarizerOptions(); - opts.sourcePath = cmd.getOptionValue("sources", "."); - var backendString = cmd.getOptionValue("backend", "auto"); - opts.backend = Backend.valueOf(backendString.toUpperCase()); - opts.classPath = cmd.getOptionValue("classes", null); - opts.useModules = cmd.hasOption("use-modules"); - opts.modulesList = cmd.getOptionValue("module-names", null); - opts.addDependencies = cmd.hasOption("recursive"); - opts.toolArgs = cmd.getOptionValue("doctool-args", null); - opts.verbose = cmd.hasOption("verbose"); - opts.outputFile = cmd.getOptionValue("output-file", null); - opts.args = cmd.getArgs(); - return opts; - } - } - - private static final CommandLineParser parser = new DefaultParser(); static SummarizerOptions options; - public static SummarizerOptions parseArgs(String[] args) { - var options = new Options(); - Option sources = new Option("s", "sources", true, "paths to search for source files"); - Option classes = new Option("c", "classes", true, "paths to search for compiled classes"); - Option backend = - new Option( - "b", - "backend", - true, - "backend to use for summary generation ('doclet', 'asm' or 'auto' (default))."); - Option useModules = new Option("M", "use-modules", false, "use Java modules"); - Option recursive = new Option("r", "recursive", false, "Include dependencies of classes"); - Option moduleNames = - new Option("m", "module-names", true, "comma separated list of module names"); - Option doctoolArgs = - new Option("D", "doctool-args", true, "Arguments to pass to the documentation tool"); - Option verbose = new Option("v", "verbose", false, "Enable verbose output"); - Option outputFile = - new Option("o", "output-file", true, "Write JSON to file instead of stdout"); - for (Option opt : - new Option[] { - sources, - classes, - backend, - useModules, - recursive, - moduleNames, - doctoolArgs, - verbose, - outputFile, - }) { - options.addOption(opt); - } - - HelpFormatter help = new HelpFormatter(); - - CommandLine cmd; - - try { - cmd = parser.parse(options, args); - if (cmd.getArgs().length < 1) { - throw new ParseException("Need to specify paths to source files"); - } - } catch (ParseException e) { - System.out.println(e.getMessage()); - help.printHelp( - "java -jar [-s ] " - + "[-c ] \n" - + "Class or package names should be fully qualified.\n\n", - options); - System.exit(1); - throw new RuntimeException("Unreachable code"); - } - return SummarizerOptions.fromCommandLine(cmd); - } - public static List runDocletWithClass( - Class docletClass, List javaFilePaths, SummarizerOptions options) { + DocumentationTool javaDoc, + Class docletClass, + List fileObjects, + SummarizerOptions options) { Log.setVerbose(options.verbose); - - var files = javaFilePaths.stream().map(File::getPath).toArray(String[]::new); - - DocumentationTool javadoc = ToolProvider.getSystemDocumentationTool(); - var fileManager = javadoc.getStandardFileManager(null, null, null); - var fileObjects = fileManager.getJavaFileObjects(files); - + var fileManager = javaDoc.getStandardFileManager(null, null, null); var cli = new ArrayList(); cli.add((options.useModules ? "--module-" : "--") + "source-path=" + options.sourcePath); if (options.classPath != null) { @@ -146,161 +56,56 @@ public static List runDocletWithClass( cli.addAll(List.of(options.toolArgs.split(" "))); } - javadoc.getTask(null, fileManager, System.err::println, docletClass, cli, fileObjects).call(); + javaDoc.getTask(null, fileManager, System.err::println, docletClass, cli, fileObjects).call(); return SummarizerDoclet.getClasses(); } - public static List runDoclet(List javaFilePaths, SummarizerOptions options) { - return runDocletWithClass(SummarizerDoclet.class, javaFilePaths, options); - } - - /** - * Lists all files under given directory, which satisfy the condition of filter. The order of - * listing shall be deterministic. - */ - public static List recursiveListFiles(File file, FileFilter filter) { - if (!file.exists()) { - throw new RuntimeException("File not found: " + file.getPath()); - } - - if (!file.isDirectory()) { - return List.of(file); - } - - // List files using a breadth-first traversal. - var files = new ArrayList(); - var queue = new ArrayDeque(); - queue.add(file); - while (!queue.isEmpty()) { - var dir = queue.poll(); - var list = dir.listFiles(entry -> entry.isDirectory() || filter.accept(entry)); - if (list == null) throw new IllegalArgumentException("File.listFiles returned null!"); - Arrays.sort(list); - for (var path : list) { - if (path.isDirectory()) { - queue.add(path); - } else { - files.add(path); - } - } - } - return files; - } - - /** - * Finds and returns source file (s) corresponding to qualified name. It's assumed that package - * hierarchy in Java is same as the filesystem hierarchy, i.e. each package corresponds to a - * directory and each class corresponds to a file in its respective package. If the respective - * file or directory does not exist, the returned optional is empty. - */ - public static Optional> findSourceFiles(String qualifiedName, String[] sourcePaths) { - return findFiles(qualifiedName, sourcePaths, ".java"); - } - - public static Optional> findFiles( - String qualifiedName, String[] searchPaths, String suffix) { - var s = qualifiedName.replace(".", "/"); - for (var folder : searchPaths) { - var f = new File(folder, s + suffix); - if (f.exists() && f.isFile()) { - return Optional.of(List.of(f)); - } - var d = new File(folder, s); - if (d.exists() && d.isDirectory()) { - return Optional.of(recursiveListFiles(d, file -> file.getName().endsWith(".java"))); - } - } - return Optional.empty(); - } - - public static Optional> findClassInputStreamsInJar( - JarFile jar, String relativePath) { - var suffix = ".class"; - var classEntry = jar.getEntry(relativePath + suffix); - if (classEntry != null) { - return Optional.of(List.of(wrapCheckedException(jar::getInputStream, classEntry))); - } - var dirPath = relativePath.endsWith("/") ? relativePath : relativePath + "/"; - var dirEntry = jar.getEntry(dirPath); - if (dirEntry != null && dirEntry.isDirectory()) { - var result = - jar.stream() - .map(je -> (ZipEntry) je) - .filter( - entry -> { - var name = entry.getName(); - return name.endsWith(suffix) && name.startsWith(dirPath); - }) - .map(entry -> wrapCheckedException(jar::getInputStream, entry)) - .collect(Collectors.toList()); - return Optional.of(result); - } - return Optional.empty(); - } - - /** - * Finds and returns class file(s) corresponding to qualified name from JAR files in classpath. - */ - public static Optional> findClassInputStreams( - String binaryName, String[] classPaths) { - String relativePath = binaryName.replace(".", "/"); - for (var path : classPaths) { - var file = new File(path); - // A path in classpath can be a directory or JAR. These cases require different logic. - if (file.isDirectory()) { - var directorySearchResult = findFiles(binaryName, classPaths, ".class"); - if (directorySearchResult.isPresent()) { - var list = directorySearchResult.get(); - return Optional.of( - StreamUtil.map( - list, fileElement -> wrapCheckedException(FileInputStream::new, fileElement))); - } - continue; - } - try { - JarFile jar = new JarFile(file); - var inJar = findClassInputStreamsInJar(jar, relativePath); - if (inJar.isPresent()) { - return inJar; - } else { - jar.close(); - } - } catch (IOException e) { - throw new RuntimeException(e); - } - } - return Optional.empty(); + public static List runDoclet( + DocumentationTool javaDoc, List javaFileObjects, SummarizerOptions options) { + return runDocletWithClass(javaDoc, SummarizerDoclet.class, javaFileObjects, options); } public static void main(String[] args) throws FileNotFoundException { - options = parseArgs(args); + options = SummarizerOptions.parseArgs(args); OutputStream output; + if (options.outputFile == null || options.outputFile.equals("-")) { output = System.out; } else { output = new FileOutputStream(options.outputFile); } - var sourcePaths = - options.sourcePath != null ? options.sourcePath.split(File.pathSeparator) : new String[] {}; - var classPaths = - options.classPath != null ? options.classPath.split(File.pathSeparator) : new String[] {}; - var classStreams = new ArrayList(); - var sourceFiles = new ArrayList(); + + List sourcePaths = + options.sourcePath != null + ? Arrays.asList(options.sourcePath.split(File.pathSeparator)) + : List.of(); + List classPaths = + options.classPath != null + ? Arrays.asList(options.classPath.split(File.pathSeparator)) + : List.of(); + + var classStreamProviders = new ArrayList(); + var sourceFiles = new ArrayList(); var notFound = new ArrayList(); + + var javaDoc = ToolProvider.getSystemDocumentationTool(); + for (var qualifiedName : options.args) { var found = false; if (options.backend != Backend.ASM) { - var sources = findSourceFiles(qualifiedName, sourcePaths); + var sources = + SearchUtil.findJavaSources( + qualifiedName, sourcePaths, javaDoc.getStandardFileManager(null, null, null)); if (sources.isPresent()) { sourceFiles.addAll(sources.get()); found = true; } } if (options.backend != Backend.DOCLET && !found) { - var classes = findClassInputStreams(qualifiedName, classPaths); + var classes = SearchUtil.findJavaClasses(qualifiedName, classPaths); if (classes.isPresent()) { - classStreams.addAll(classes.get()); + classStreamProviders.addAll(classes.get()); found = true; } } @@ -316,14 +121,19 @@ public static void main(String[] args) throws FileNotFoundException { switch (options.backend) { case DOCLET: - JsonUtil.writeJSON(runDoclet(sourceFiles, options), output); + JsonUtil.writeJSON(runDoclet(javaDoc, sourceFiles, options), output); break; case ASM: - JsonUtil.writeJSON(AsmSummarizer.run(classStreams), output); + JsonUtil.writeJSON(AsmSummarizer.run(classStreamProviders), output); break; case AUTO: - var decls = runDoclet(sourceFiles, options); - decls.addAll(AsmSummarizer.run(classStreams)); + List decls = new ArrayList<>(); + if (!sourceFiles.isEmpty()) { + decls.addAll(runDoclet(javaDoc, sourceFiles, options)); + } + if (!classStreamProviders.isEmpty()) { + decls.addAll(AsmSummarizer.run(classStreamProviders)); + } JsonUtil.writeJSON(decls, output); break; } diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/SummarizerOptions.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/SummarizerOptions.java new file mode 100644 index 000000000..ca63a4531 --- /dev/null +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/SummarizerOptions.java @@ -0,0 +1,94 @@ +package com.github.dart_lang.jnigen.apisummarizer; + +import org.apache.commons.cli.*; + +public class SummarizerOptions { + private static final CommandLineParser parser = new DefaultParser(); + String sourcePath; + String classPath; + boolean useModules; + Main.Backend backend; + String modulesList; + boolean addDependencies; + String toolArgs; + boolean verbose; + String outputFile; + String[] args; + + SummarizerOptions() {} + + public static SummarizerOptions fromCommandLine(CommandLine cmd) { + var opts = new SummarizerOptions(); + opts.sourcePath = cmd.getOptionValue("sources", "."); + var backendString = cmd.getOptionValue("backend", "auto"); + opts.backend = Main.Backend.valueOf(backendString.toUpperCase()); + opts.classPath = cmd.getOptionValue("classes", null); + opts.useModules = cmd.hasOption("use-modules"); + opts.modulesList = cmd.getOptionValue("module-names", null); + opts.addDependencies = cmd.hasOption("recursive"); + opts.toolArgs = cmd.getOptionValue("doctool-args", null); + opts.verbose = cmd.hasOption("verbose"); + opts.outputFile = cmd.getOptionValue("output-file", null); + opts.args = cmd.getArgs(); + if (opts.args.length == 0) { + throw new IllegalArgumentException("Need one or more class or package names as arguments"); + } + return opts; + } + + public static SummarizerOptions parseArgs(String[] args) { + var options = new Options(); + Option sources = new Option("s", "sources", true, "paths to search for source files"); + Option classes = new Option("c", "classes", true, "paths to search for compiled classes"); + Option backend = + new Option( + "b", + "backend", + true, + "backend to use for summary generation ('doclet', 'asm' or 'auto' (default))."); + Option useModules = new Option("M", "use-modules", false, "use Java modules"); + Option recursive = new Option("r", "recursive", false, "include dependencies of classes"); + Option moduleNames = + new Option("m", "module-names", true, "comma separated list of module names"); + Option doctoolArgs = + new Option("D", "doctool-args", true, "arguments to pass to the documentation tool"); + Option verbose = new Option("v", "verbose", false, "enable verbose output"); + Option outputFile = + new Option("o", "output-file", true, "write JSON to file instead of stdout"); + for (Option opt : + new Option[] { + sources, + classes, + backend, + useModules, + recursive, + moduleNames, + doctoolArgs, + verbose, + outputFile, + }) { + options.addOption(opt); + } + + HelpFormatter help = new HelpFormatter(); + + CommandLine cmd; + + try { + cmd = parser.parse(options, args); + if (cmd.getArgs().length < 1) { + throw new ParseException("Need to specify paths to source files"); + } + } catch (ParseException e) { + System.out.println(e.getMessage()); + help.printHelp( + "java -jar [-s ] " + + "[-c ] \n" + + "Class or package names should be fully qualified.\n\n", + options); + System.exit(1); + throw new RuntimeException("Unreachable code"); + } + return fromCommandLine(cmd); + } +} diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmSummarizer.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmSummarizer.java index 9cf03d98a..391b83160 100644 --- a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmSummarizer.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmSummarizer.java @@ -7,23 +7,23 @@ import static com.github.dart_lang.jnigen.apisummarizer.util.ExceptionUtil.wrapCheckedException; import com.github.dart_lang.jnigen.apisummarizer.elements.ClassDecl; -import java.io.InputStream; +import com.github.dart_lang.jnigen.apisummarizer.util.InputStreamProvider; import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; import org.objectweb.asm.ClassReader; public class AsmSummarizer { - public static List run(ArrayList inputs) { - return inputs.stream() - .map(input -> wrapCheckedException(ClassReader::new, input)) - .flatMap( - reader -> { - var visitor = new AsmClassVisitor(); - reader.accept(visitor, 0); - return visitor.getVisited().stream(); - }) - .collect(Collectors.toList()); + public static List run(List inputProviders) { + List parsed = new ArrayList<>(); + for (var provider : inputProviders) { + var inputStream = provider.getInputStream(); + var classReader = wrapCheckedException(ClassReader::new, inputStream); + var visitor = new AsmClassVisitor(); + classReader.accept(visitor, 0); + parsed.addAll(visitor.getVisited()); + provider.close(); + } + return parsed; } } diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/FileInputStreamProvider.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/FileInputStreamProvider.java new file mode 100644 index 000000000..da5cadf9e --- /dev/null +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/FileInputStreamProvider.java @@ -0,0 +1,38 @@ +package com.github.dart_lang.jnigen.apisummarizer.util; + +import java.io.*; + +/** Implementation of InputStreamProvider backed by a File. */ +public class FileInputStreamProvider implements InputStreamProvider { + File file; + InputStream stream; + + public FileInputStreamProvider(File file) { + this.file = file; + } + + @Override + public InputStream getInputStream() { + if (stream == null) { + try { + stream = new FileInputStream(file); + } catch (FileNotFoundException e) { + throw new RuntimeException(e); + } + } + return stream; + } + + @Override + public void close() { + if (stream == null) { + return; + } + try { + stream.close(); + stream = null; + } catch (IOException e) { + throw new RuntimeException(e); + } + } +} diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/InputStreamProvider.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/InputStreamProvider.java new file mode 100644 index 000000000..85ba15b2e --- /dev/null +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/InputStreamProvider.java @@ -0,0 +1,17 @@ +package com.github.dart_lang.jnigen.apisummarizer.util; + +import java.io.InputStream; + +/** + * Implementers of this interface provide an InputStream on-demand for writing, and provide a way to + * close the same.
+ * The implementation doesn't need to be thread-safe, since this is only used in AsmSummarizer, + * which reads the classes serially. + */ +public interface InputStreamProvider { + /** Return the input stream, initializing it if needed. */ + InputStream getInputStream(); + + /** close the underlying InputStream. */ + void close(); +} diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/JarEntryFileObject.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/JarEntryFileObject.java new file mode 100644 index 000000000..49f187fe8 --- /dev/null +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/JarEntryFileObject.java @@ -0,0 +1,41 @@ +package com.github.dart_lang.jnigen.apisummarizer.util; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.net.URI; +import java.nio.charset.StandardCharsets; +import java.util.jar.JarFile; +import java.util.zip.ZipEntry; +import javax.tools.SimpleJavaFileObject; + +/** Implements JavaFileObject for use by Doclet summarizer. */ +class JarEntryFileObject extends SimpleJavaFileObject { + JarFile jarFile; + String relativePath; + + protected JarEntryFileObject(JarFile jarFile, ZipEntry entry) { + super(URI.create(new File(jarFile.getName()).toURI() + "/" + entry.getName()), Kind.SOURCE); + this.jarFile = jarFile; + this.relativePath = entry.getName(); + } + + private int getEntrySize(ZipEntry entry) { + long limit = 1024L * 1024L * 16L; // Arbitrary limit, how long can be a source file? + long size = entry.getSize(); + return (int) Long.min(size, limit); + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + var entry = jarFile.getEntry(relativePath); + var out = new ByteArrayOutputStream(getEntrySize(entry)); + + try (var stream = jarFile.getInputStream(entry)) { + stream.transferTo(out); + } catch (IOException e) { + throw new RuntimeException(e); + } + return out.toString(StandardCharsets.UTF_8); + } +} diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/JarEntryInputStreamProvider.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/JarEntryInputStreamProvider.java new file mode 100644 index 000000000..cba3f76bd --- /dev/null +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/JarEntryInputStreamProvider.java @@ -0,0 +1,29 @@ +package com.github.dart_lang.jnigen.apisummarizer.util; + +import java.io.IOException; +import java.io.InputStream; +import java.util.jar.JarFile; +import java.util.zip.ZipEntry; + +public class JarEntryInputStreamProvider implements InputStreamProvider { + + private final JarFile jarFile; + private final ZipEntry zipEntry; + + public JarEntryInputStreamProvider(JarFile jarFile, ZipEntry zipEntry) { + this.jarFile = jarFile; + this.zipEntry = zipEntry; + } + + @Override + public InputStream getInputStream() { + try { + return jarFile.getInputStream(zipEntry); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + @Override + public void close() {} +} diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/SearchUtil.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/SearchUtil.java new file mode 100644 index 000000000..9f1611d0e --- /dev/null +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/SearchUtil.java @@ -0,0 +1,155 @@ +package com.github.dart_lang.jnigen.apisummarizer.util; + +import java.io.File; +import java.io.FileFilter; +import java.util.*; +import java.util.function.BiFunction; +import java.util.function.Function; +import java.util.jar.JarFile; +import java.util.stream.Collectors; +import java.util.zip.ZipEntry; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; + +public class SearchUtil { + public static Optional> findFilesInPath( + String qualifiedName, String searchPath, String suffix) { + var s = qualifiedName.replace(".", File.separator); + var f = new File(searchPath, s + suffix); + if (f.exists() && f.isFile()) { + return Optional.of(List.of(f)); + } + + var d = new File(searchPath, s); + if (d.exists() && d.isDirectory()) { + return Optional.of(recursiveListFiles(d, file -> file.getName().endsWith(".java"))); + } + + return Optional.empty(); + } + + public static Optional> findFilesInJar( + String qualifiedName, JarFile jar, String suffix) { + String relativePath = qualifiedName.replace(".", "/"); + var classEntry = jar.getEntry(relativePath + suffix); + if (classEntry != null) { + return Optional.of(List.of(classEntry)); + } + var dirPath = relativePath.endsWith("/") ? relativePath : relativePath + "/"; + var dirEntry = jar.getEntry(dirPath); + if (dirEntry != null && dirEntry.isDirectory()) { + var result = + jar.stream() + .map(je -> (ZipEntry) je) + .filter( + entry -> { + var name = entry.getName(); + return name.endsWith(suffix) && name.startsWith(dirPath); + }) + .collect(Collectors.toList()); + return Optional.of(result); + } + return Optional.empty(); + } + + public static Optional> find( + String qualifiedName, + List searchPaths, + String suffix, + Function, List> fileMapper, + BiFunction, List> entryMapper) { + for (var searchPath : searchPaths) { + File searchFile = new File(searchPath); + if (searchFile.isDirectory()) { + var result = findFilesInPath(qualifiedName, searchPath, suffix); + if (result.isPresent()) { + var mappedResult = fileMapper.apply(result.get()); + return Optional.of(mappedResult); + } + } + if (searchFile.isFile() && searchPath.endsWith(".jar")) { + var jarFile = ExceptionUtil.wrapCheckedException(JarFile::new, searchPath); + var result = findFilesInJar(qualifiedName, jarFile, suffix); + if (result.isPresent()) { + var mappedResult = entryMapper.apply(jarFile, result.get()); + return Optional.of(mappedResult); + } + } + } + return Optional.empty(); + } + + private static List getJavaFileObjectsFromFiles( + List files, StandardJavaFileManager fm) { + var result = new ArrayList(); + fm.getJavaFileObjectsFromFiles(files).forEach(result::add); + return result; + } + + private static List getJavaFileObjectsFromJar( + JarFile jarFile, List entries) { + return StreamUtil.map(entries, (entry) -> new JarEntryFileObject(jarFile, entry)); + } + + private static List getInputStreamProvidersFromFiles(List files) { + return StreamUtil.map(files, FileInputStreamProvider::new); + } + + private static List getInputStreamProvidersFromJar( + JarFile jarFile, List entries) { + return StreamUtil.map(entries, entry -> new JarEntryInputStreamProvider(jarFile, entry)); + } + + public static Optional> findJavaSources( + String qualifiedName, List searchPaths, StandardJavaFileManager fm) { + return find( + qualifiedName, + searchPaths, + ".java", + files -> getJavaFileObjectsFromFiles(files, fm), + SearchUtil::getJavaFileObjectsFromJar); + } + + public static Optional> findJavaClasses( + String qualifiedName, List searchPaths) { + return find( + qualifiedName, + searchPaths, + ".class", + SearchUtil::getInputStreamProvidersFromFiles, + SearchUtil::getInputStreamProvidersFromJar); + } + + /** + * Lists all files under given directory, which satisfy the condition of filter.
+ * The order of listing will be deterministic. + */ + public static List recursiveListFiles(File file, FileFilter filter) { + if (!file.exists()) { + throw new RuntimeException("File not found: " + file.getPath()); + } + + if (!file.isDirectory()) { + return List.of(file); + } + + // List files using a breadth-first traversal. + var files = new ArrayList(); + var queue = new ArrayDeque(); + queue.add(file); + while (!queue.isEmpty()) { + var dir = queue.poll(); + var list = dir.listFiles(entry -> entry.isDirectory() || filter.accept(entry)); + if (list == null) throw new IllegalArgumentException("File.listFiles returned null!"); + Arrays.sort(list); + for (var path : list) { + if (path.isDirectory()) { + queue.add(path); + } else { + files.add(path); + } + } + } + return files; + } +} diff --git a/pkgs/jnigen/lib/src/generate_bindings.dart b/pkgs/jnigen/lib/src/generate_bindings.dart index 9c1202d15..bc4deb0c1 100644 --- a/pkgs/jnigen/lib/src/generate_bindings.dart +++ b/pkgs/jnigen/lib/src/generate_bindings.dart @@ -9,7 +9,6 @@ import 'bindings/dart_generator.dart'; import 'bindings/excluder.dart'; import 'bindings/linker.dart'; import 'bindings/renamer.dart'; -import 'elements/elements.dart'; import 'summary/summary.dart'; import 'config/config.dart'; import 'tools/tools.dart'; @@ -23,83 +22,8 @@ Future generateJniBindings(Config config) async { await buildSummarizerIfNotExists(); - final summarizer = SummarizerCommand( - sourcePath: config.sourcePath, - classPath: config.classPath, - classes: config.classes, - workingDirectory: config.summarizerOptions?.workingDirectory, - extraArgs: config.summarizerOptions?.extraArgs ?? const [], - backend: config.summarizerOptions?.backend, - ); + final classes = await getSummary(config); - // Additional sources added using maven downloads and gradle trickery. - final extraSources = []; - final extraJars = []; - final mavenDl = config.mavenDownloads; - if (mavenDl != null) { - final sourcePath = mavenDl.sourceDir; - await Directory(sourcePath).create(recursive: true); - await MavenTools.downloadMavenSources( - MavenTools.deps(mavenDl.sourceDeps), sourcePath); - extraSources.add(Uri.directory(sourcePath)); - final jarPath = mavenDl.jarDir; - await Directory(jarPath).create(recursive: true); - await MavenTools.downloadMavenJars( - MavenTools.deps(mavenDl.sourceDeps + mavenDl.jarOnlyDeps), jarPath); - extraJars.addAll(await Directory(jarPath) - .list() - .where((entry) => entry.path.endsWith('.jar')) - .map((entry) => entry.uri) - .toList()); - } - final androidConfig = config.androidSdkConfig; - if (androidConfig != null && androidConfig.addGradleDeps) { - final deps = AndroidSdkTools.getGradleClasspaths( - configRoot: config.configRoot, - androidProject: androidConfig.androidExample ?? '.', - ); - extraJars.addAll(deps.map(Uri.file)); - } - if (androidConfig != null && androidConfig.versions != null) { - final versions = androidConfig.versions!; - final androidSdkRoot = - androidConfig.sdkRoot ?? AndroidSdkTools.getAndroidSdkRoot(); - final androidJar = await AndroidSdkTools.getAndroidJarPath( - sdkRoot: androidSdkRoot, versionOrder: versions); - if (androidJar != null) { - extraJars.add(Uri.directory(androidJar)); - } - } - - summarizer.addSourcePaths(extraSources); - summarizer.addClassPaths(extraJars); - - Process process; - Stream> input; - try { - process = await summarizer.runProcess(); - input = process.stdout; - } on Exception catch (e) { - log.fatal('Cannot obtain API summary: $e'); - return; - } - final errorLog = StringBuffer(); - collectOutputStream(process.stderr, errorLog); - final stream = const JsonDecoder().bind(const Utf8Decoder().bind(input)); - dynamic json; - try { - json = await stream.single; - } on Exception catch (e) { - printError(errorLog); - log.fatal('Cannot parse summary: $e'); - return; - } - if (json == null) { - log.fatal('Expected JSON element from summarizer.'); - return; - } - final list = json as List; - final classes = Classes.fromJson(list); final cBased = config.outputConfig.bindingsType == BindingsType.cBased; classes ..accept(Excluder(config)) diff --git a/pkgs/jnigen/lib/src/logging/logging.dart b/pkgs/jnigen/lib/src/logging/logging.dart index 561b06b29..67c605eee 100644 --- a/pkgs/jnigen/lib/src/logging/logging.dart +++ b/pkgs/jnigen/lib/src/logging/logging.dart @@ -49,9 +49,9 @@ void printError(Object? message) { } extension FatalErrors on Logger { - void fatal(Object? message, {int exitCode = 1}) { + Never fatal(Object? message, {int exitCode = 1}) { message = _colorize('Fatal: $message', _ansiRed); stderr.writeln(message); - exit(exitCode); + return exit(exitCode); } } diff --git a/pkgs/jnigen/lib/src/summary/summary.dart b/pkgs/jnigen/lib/src/summary/summary.dart index 4580dbedb..29e50b737 100644 --- a/pkgs/jnigen/lib/src/summary/summary.dart +++ b/pkgs/jnigen/lib/src/summary/summary.dart @@ -3,8 +3,13 @@ // BSD-style license that can be found in the LICENSE file. import 'dart:async'; +import 'dart:convert'; import 'dart:io'; +import '../../tools.dart'; +import '../config/config.dart'; +import '../elements/elements.dart'; +import '../generate_bindings.dart'; import '../logging/logging.dart'; /// A command based summary source which calls the ApiSummarizer command. @@ -86,3 +91,82 @@ class SummarizerCommand { return proc; } } + +Future getSummary(Config config) async { + setLoggingLevel(config.logLevel); + final summarizer = SummarizerCommand( + sourcePath: config.sourcePath, + classPath: config.classPath, + classes: config.classes, + workingDirectory: config.summarizerOptions?.workingDirectory, + extraArgs: config.summarizerOptions?.extraArgs ?? const [], + backend: config.summarizerOptions?.backend, + ); + + // Additional sources added using maven downloads and gradle trickery. + final extraSources = []; + final extraJars = []; + final mavenDl = config.mavenDownloads; + if (mavenDl != null) { + final sourcePath = mavenDl.sourceDir; + await Directory(sourcePath).create(recursive: true); + await MavenTools.downloadMavenSources( + MavenTools.deps(mavenDl.sourceDeps), sourcePath); + extraSources.add(Uri.directory(sourcePath)); + final jarPath = mavenDl.jarDir; + await Directory(jarPath).create(recursive: true); + await MavenTools.downloadMavenJars( + MavenTools.deps(mavenDl.sourceDeps + mavenDl.jarOnlyDeps), jarPath); + extraJars.addAll(await Directory(jarPath) + .list() + .where((entry) => entry.path.endsWith('.jar')) + .map((entry) => entry.uri) + .toList()); + } + final androidConfig = config.androidSdkConfig; + if (androidConfig != null && androidConfig.addGradleDeps) { + final deps = AndroidSdkTools.getGradleClasspaths( + configRoot: config.configRoot, + androidProject: androidConfig.androidExample ?? '.', + ); + extraJars.addAll(deps.map(Uri.file)); + } + if (androidConfig != null && androidConfig.versions != null) { + final versions = androidConfig.versions!; + final androidSdkRoot = + androidConfig.sdkRoot ?? AndroidSdkTools.getAndroidSdkRoot(); + final androidJar = await AndroidSdkTools.getAndroidJarPath( + sdkRoot: androidSdkRoot, versionOrder: versions); + if (androidJar != null) { + extraJars.add(Uri.directory(androidJar)); + } + } + + summarizer.addSourcePaths(extraSources); + summarizer.addClassPaths(extraJars); + + Process process; + Stream> input; + try { + process = await summarizer.runProcess(); + input = process.stdout; + } on Exception catch (e) { + log.fatal('Cannot obtain API summary: $e'); + } + final errorLog = StringBuffer(); + collectOutputStream(process.stderr, errorLog); + final stream = const JsonDecoder().bind(const Utf8Decoder().bind(input)); + dynamic json; + try { + json = await stream.single; + } on Exception catch (e) { + printError(errorLog); + log.fatal('Cannot parse summary: $e'); + } + if (json == null) { + log.fatal('Expected JSON element from summarizer.'); + } + final list = json as List; + final classes = Classes.fromJson(list); + return classes; +} diff --git a/pkgs/jnigen/lib/src/tools/build_summarizer.dart b/pkgs/jnigen/lib/src/tools/build_summarizer.dart index 2647bc8e6..30ce426f9 100644 --- a/pkgs/jnigen/lib/src/tools/build_summarizer.dart +++ b/pkgs/jnigen/lib/src/tools/build_summarizer.dart @@ -25,7 +25,6 @@ Future buildApiSummarizer() async { final pkg = await findPackageRoot('jnigen'); if (pkg == null) { log.fatal('package jnigen not found!'); - return; } final pom = pkg.resolve('java/pom.xml'); await Directory(toolPath).create(recursive: true); diff --git a/pkgs/jnigen/test/summary_generation_test.dart b/pkgs/jnigen/test/summary_generation_test.dart new file mode 100644 index 000000000..6bf7457b8 --- /dev/null +++ b/pkgs/jnigen/test/summary_generation_test.dart @@ -0,0 +1,168 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +// These tests validate summary generation in various scenarios. +// Currently, no validation of the summary content itself is done. + +import 'dart:io'; + +import 'package:jnigen/src/config/config.dart'; +import 'package:jnigen/src/elements/elements.dart'; +import 'package:jnigen/src/logging/logging.dart'; +import 'package:jnigen/src/summary/summary.dart'; +import 'package:logging/logging.dart'; + +import 'package:path/path.dart' hide equals; +import 'package:test/test.dart'; + +import 'test_util/test_util.dart'; + +void expectNonEmptySummary(Classes? classes) { + expect(classes, isNotNull); + final decls = classes!.decls; + expect(decls.entries.length, greaterThanOrEqualTo(javaFiles.length)); + final declNames = decls.keys.toSet(); + final expectedClasses = + javaClasses.where((name) => !name.contains("annotations.")).toList(); + expect(declNames, containsAll(expectedClasses)); +} + +void deleteTempDir(Directory directory) { + try { + if (Platform.isWindows) { + // This appears to avoid "file used by another process" errors. + sleep(const Duration(seconds: 1)); + } + directory.deleteSync(recursive: true); + } on FileSystemException catch (e) { + log.warning("Cannot delete directory: $e"); + } +} + +List findFiles(Directory dir, String suffix) { + return dir + .listSync(recursive: true) + .map((entry) => relative(entry.path, from: dir.path)) + .where((path) => path.endsWith(suffix)) + .toList(); +} + +Future createJar(List paths, String target) async { + final relativeTarget = relative(target, from: simplePackagePath); + final status = await runCommand( + 'jar', + ['cf', relativeTarget, ...paths], + workingDirectory: simplePackagePath, + ); + if (status != 0) { + throw ArgumentError('Cannot create JAR from provided arguments'); + } +} + +Future compileJavaFiles(List paths, Directory target) async { + final status = await runCommand( + 'javac', + ['-d', target.absolute.path, ...paths], + workingDirectory: simplePackagePath, + ); + if (status != 0) { + throw ArgumentError('Cannot compile Java sources'); + } +} + +String getClassNameFromPath(String path) { + if (!path.endsWith('.java')) { + throw ArgumentError('Filename must end with java'); + } + return path + .replaceAll('/', '.') + .replaceAll('\\', '.') + .substring(0, path.length - 5); +} + +final simplePackagePath = join('test', 'simple_package_test', 'java'); +final simplePackageDir = Directory(simplePackagePath); +final javaFiles = findFiles(simplePackageDir, '.java'); +final javaClasses = javaFiles.map(getClassNameFromPath).toList(); + +Config getConfig({List? sourcePath, List? classPath}) { + return Config( + outputConfig: OutputConfig( + bindingsType: BindingsType.dartOnly, + dartConfig: DartCodeOutputConfig( + path: Uri.file('unused.dart'), + structure: OutputStructure.singleFile, + ), + ), + classes: javaClasses, + sourcePath: sourcePath?.map((e) => Uri.file(e)).toList(), + classPath: classPath?.map((e) => Uri.file(e)).toList(), + logLevel: Level.WARNING, + ); +} + +void main() { + late Directory tempDir; + setUpAll(() { + tempDir = getTempDir("jnigen_summary_tests_"); + }); + + test('Test summary generation from compiled JAR', () async { + final targetDir = tempDir.createTempSync("compiled_jar_test_"); + await compileJavaFiles(javaFiles, targetDir); + final classFiles = findFiles(targetDir, '.class'); + final jarFilePath = join(targetDir.absolute.path, 'classes.jar'); + await createJar(classFiles, jarFilePath); + final config = getConfig(classPath: [jarFilePath]); + final summaryClasses = await getSummary(config); + expectNonEmptySummary(summaryClasses); + }); + + test('Test summary generation from source JAR', () async { + final targetDir = tempDir.createTempSync("source_jar_test_"); + final jarFilePath = join(targetDir.path, 'sources.jar'); + await createJar(javaFiles, jarFilePath); + final config = getConfig(sourcePath: [jarFilePath]); + final summaryClasses = await getSummary(config); + expectNonEmptySummary(summaryClasses); + }); + + test('Test summary generation from source folder', () async { + final config = getConfig(sourcePath: [simplePackagePath]); + final summaryClasses = await getSummary(config); + expectNonEmptySummary(summaryClasses); + }); + + test('Test summary generation from compiled classes in directory', () async { + final targetDir = tempDir.createTempSync("compiled_classes_test_"); + await compileJavaFiles(javaFiles, targetDir); + final config = getConfig(classPath: [targetDir.path]); + final summaryClasses = await getSummary(config); + expectNonEmptySummary(summaryClasses); + }); + + // Test summary generation from combination of a source and class path + test('Test summary generation from combination', () async { + final targetDir = tempDir.createTempSync("combination_test_"); + + // remove a class from source files and create a source JAR + final sourceFiles = javaFiles.toList(); + sourceFiles.removeLast(); + final sourceJarPath = join(targetDir.path, 'sources.jar'); + await createJar(sourceFiles, sourceJarPath); + + await compileJavaFiles(javaFiles, targetDir); + final classFiles = findFiles(targetDir, '.class'); + final classesJarPath = join(targetDir.path, 'classes.jar'); + await createJar(classFiles, classesJarPath); + final config = getConfig( + classPath: [classesJarPath], + sourcePath: [sourceJarPath], + ); + final summaryClasses = await getSummary(config); + expectNonEmptySummary(summaryClasses); + }); + + tearDownAll(() => deleteTempDir(tempDir)); +} diff --git a/pkgs/jnigen/test/test_util/test_util.dart b/pkgs/jnigen/test/test_util/test_util.dart index 51696847b..e48fd0a57 100644 --- a/pkgs/jnigen/test/test_util/test_util.dart +++ b/pkgs/jnigen/test/test_util/test_util.dart @@ -11,6 +11,12 @@ import 'package:logging/logging.dart' show Level; import 'package:jnigen/src/logging/logging.dart' show printError; +final _currentDirectory = Directory("."); + +Directory getTempDir(String prefix) { + return _currentDirectory.createTempSync(prefix); +} + Future isEmptyOrNotExistDir(String path) async { final dir = Directory(path); return (!await dir.exists()) || (await dir.list().length == 0); From 4d24823df023c91f8f0b5da7585c984383418617 Mon Sep 17 00:00:00 2001 From: Mahesh Hegde <46179734+mahesh-hegde@users.noreply.github.com> Date: Thu, 6 Apr 2023 15:48:00 +0530 Subject: [PATCH 071/139] [jnigen] Add ability to use source dependencies from Gradle (https://github.com/dart-lang/jnigen/issues/231) * Add google maven repository to maven * add_gradle_sources option * Add proguard rules and EmojiConfig usage in example --- .../in_app_java/android/app/build.gradle | 5 + .../android/app/proguard-rules.pro | 17 + pkgs/jnigen/example/in_app_java/jnigen.yaml | 3 + .../in_app_java/lib/android_utils.dart | 1919 +++++++++++++++++ pkgs/jnigen/example/in_app_java/lib/main.dart | 11 +- .../src/android_utils/android_utils.c | 1345 ++++++++++++ pkgs/jnigen/lib/src/config/config_types.dart | 17 +- pkgs/jnigen/lib/src/summary/summary.dart | 7 + .../lib/src/tools/android_sdk_tools.dart | 141 +- pkgs/jnigen/lib/src/tools/maven_tools.dart | 7 + .../lib/src/writers/bindings_writer.dart | 2 +- 11 files changed, 3445 insertions(+), 29 deletions(-) create mode 100644 pkgs/jnigen/example/in_app_java/android/app/proguard-rules.pro diff --git a/pkgs/jnigen/example/in_app_java/android/app/build.gradle b/pkgs/jnigen/example/in_app_java/android/app/build.gradle index bd2878982..8f38e430e 100644 --- a/pkgs/jnigen/example/in_app_java/android/app/build.gradle +++ b/pkgs/jnigen/example/in_app_java/android/app/build.gradle @@ -74,4 +74,9 @@ flutter { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + + /// Add AndroidX emoji2 library as dependency. + /// We will be using EmojiCompat's GlyphChecker in our flutter example. + def emoji2_version = "1.3.0" + implementation "androidx.emoji2:emoji2:$emoji2_version" } diff --git a/pkgs/jnigen/example/in_app_java/android/app/proguard-rules.pro b/pkgs/jnigen/example/in_app_java/android/app/proguard-rules.pro new file mode 100644 index 000000000..8eecc4ccf --- /dev/null +++ b/pkgs/jnigen/example/in_app_java/android/app/proguard-rules.pro @@ -0,0 +1,17 @@ +# This is the rules file which prevents `proguard` from aggressively +# removing the classes which appear to be unused, in release mode. +# +# Since JNI is based on runtime lookup for classes, proguard will not have +# a way to know EmojiCompat class in our example is actually used. Therefore +# we have to explicitly list it in this file to prevent the application from +# crashing with ClassNotFoundException. +# +# This doesn't apply to builtin classes, eg: those in `android.` namespace Since +# they are already present on the device. +# For the Java code which is written by yourself, you can add `androidx.annotation.Keep` +# instead. (As done in `AndroidUtils.java`). +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +-keep class androidx.emoji2.text.EmojiCompat { public *; } diff --git a/pkgs/jnigen/example/in_app_java/jnigen.yaml b/pkgs/jnigen/example/in_app_java/jnigen.yaml index f77215b14..f053698ac 100644 --- a/pkgs/jnigen/example/in_app_java/jnigen.yaml +++ b/pkgs/jnigen/example/in_app_java/jnigen.yaml @@ -1,5 +1,6 @@ android_sdk_config: add_gradle_deps: true + add_gradle_sources: true output: c: @@ -13,5 +14,7 @@ source_path: - 'android/app/src/main/java' classes: - 'com.example.in_app_java.AndroidUtils' # from source_path + - 'androidx.emoji2.text.EmojiCompat' # From gradle's source path + - 'androidx.emoji2.text.DefaultEmojiCompatConfig' # From gradle's source path - 'android.os.Build' # from gradle's compile classpath - 'java.util.HashMap' # from gradle's compile classpath diff --git a/pkgs/jnigen/example/in_app_java/lib/android_utils.dart b/pkgs/jnigen/example/in_app_java/lib/android_utils.dart index 4030ba74c..3faba5b55 100644 --- a/pkgs/jnigen/example/in_app_java/lib/android_utils.dart +++ b/pkgs/jnigen/example/in_app_java/lib/android_utils.dart @@ -60,6 +60,1925 @@ class $AndroidUtilsType extends jni.JObjType { AndroidUtils fromRef(jni.JObjectPtr ref) => AndroidUtils.fromRef(ref); } +/// from: androidx.emoji2.text.EmojiCompat +/// +/// Main class to keep Android devices up to date with the newest emojis by adding EmojiSpans +/// to a given CharSequence. +///

+/// By default, EmojiCompat is initialized by EmojiCompatInitializer, which performs +/// deferred font loading to avoid potential app startup delays. The default behavior is to load +/// the font shortly after the first Activity resumes. EmojiCompatInitializer will configure +/// EmojiCompat to use the system emoji font provider via DefaultEmojiCompatConfig and +/// always creates a new background thread for font loading. +///

+/// EmojiCompat will only allow one instance to be initialized and any calls to +/// \#init(Config) after the first one will have no effect. As a result, configuration options +/// may not be provided when using EmojiCompatInitializer. To provide a custom configuration, +/// disable EmojiCompatInitializer in the manifest with: +/// +///

+///     <provider
+///         android:name="androidx.startup.InitializationProvider"
+///         android:authorities="${applicationId}.androidx-startup"
+///         android:exported="false"
+///         tools:node="merge">
+///         <meta-data android:name="androidx.emoji2.text.EmojiCompatInitializer"
+///                   tools:node="remove" />
+///     </provider>
+/// 
+/// +/// When not using EmojiCompatInitializer, EmojiCompat must to be initialized manually using +/// \#init(EmojiCompat.Config). It is recommended to make the initialization as early as +/// possible in your app, such as from Application\#onCreate(). +///

+/// \#init(Config) is fast and may be called from the main thread on the path to +/// displaying the first activity. However, loading the emoji font takes significant resources on a +/// background thread, so it is suggested to use \#LOAD_STRATEGY_MANUAL in all manual +/// configurations to defer font loading until after the first screen displays. Font loading may +/// be started by calling \#load()}. See the implementation EmojiCompatInitializer +/// for ideas when building a manual configuration. +///

+/// After initialization the \#get() function can be used to get the configured instance and +/// the \#process(CharSequence) function can be used to update a CharSequence with emoji +/// EmojiSpans. +///

+///

CharSequence processedSequence = EmojiCompat.get().process("some string")
+///

+/// During loading information about emojis is not available. Before the +/// EmojiCompat instance has finished loading, calls to functions such as EmojiCompat\#process(CharSequence) will throw an exception. It is safe to call process when +/// \#getLoadState() returns \#LOAD_STATE_SUCCEEDED. To register a callback when +/// loading completes use InitCallback. +///

+class EmojiCompat extends jni.JObject { + late final jni.JObjType? _$type; + @override + jni.JObjType get $type => _$type ??= type; + + EmojiCompat.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = $EmojiCompatType(); + + /// from: static public final java.lang.String EDITOR_INFO_METAVERSION_KEY + /// + /// Key in EditorInfo\#extras that represents the emoji metadata version used by the + /// widget. The existence of the value means that the widget is using EmojiCompat. + ///

+ /// If exists, the value for the key is an {@code int} and can be used to query EmojiCompat to + /// see whether the widget has the ability to display a certain emoji using + /// \#hasEmojiGlyph(CharSequence, int). + static const EDITOR_INFO_METAVERSION_KEY = + r"""android.support.text.emoji.emojiCompat_metadataVersion"""; + + /// from: static public final java.lang.String EDITOR_INFO_REPLACE_ALL_KEY + /// + /// Key in EditorInfo\#extras that represents EmojiCompat.Config\#setReplaceAll(boolean) configuration parameter. The key is added only if + /// EmojiCompat is used by the widget. If exists, the value is a boolean. + static const EDITOR_INFO_REPLACE_ALL_KEY = + r"""android.support.text.emoji.emojiCompat_replaceAll"""; + + /// from: static public final int LOAD_STATE_DEFAULT + /// + /// EmojiCompat instance is constructed, however the initialization did not start yet. + ///@see \#getLoadState() + static const LOAD_STATE_DEFAULT = 3; + + /// from: static public final int LOAD_STATE_LOADING + /// + /// EmojiCompat is initializing. + ///@see \#getLoadState() + static const LOAD_STATE_LOADING = 0; + + /// from: static public final int LOAD_STATE_SUCCEEDED + /// + /// EmojiCompat successfully initialized. + ///@see \#getLoadState() + static const LOAD_STATE_SUCCEEDED = 1; + + /// from: static public final int LOAD_STATE_FAILED + /// + /// An unrecoverable error occurred during initialization of EmojiCompat. Calls to functions + /// such as \#process(CharSequence) will fail. + ///@see \#getLoadState() + static const LOAD_STATE_FAILED = 2; + + /// from: static public final int REPLACE_STRATEGY_DEFAULT + /// + /// Replace strategy that uses the value given in EmojiCompat.Config. + ///@see \#process(CharSequence, int, int, int, int) + static const REPLACE_STRATEGY_DEFAULT = 0; + + /// from: static public final int REPLACE_STRATEGY_ALL + /// + /// Replace strategy to add EmojiSpans for all emoji that were found. + ///@see \#process(CharSequence, int, int, int, int) + static const REPLACE_STRATEGY_ALL = 1; + + /// from: static public final int REPLACE_STRATEGY_NON_EXISTENT + /// + /// Replace strategy to add EmojiSpans only for emoji that do not exist in the system. + static const REPLACE_STRATEGY_NON_EXISTENT = 2; + + /// from: static public final int LOAD_STRATEGY_DEFAULT + /// + /// EmojiCompat will start loading metadata when \#init(Config) is called. + ///@see Config\#setMetadataLoadStrategy(int) + static const LOAD_STRATEGY_DEFAULT = 0; + + /// from: static public final int LOAD_STRATEGY_MANUAL + /// + /// EmojiCompat will wait for \#load() to be called by developer in order to + /// start loading metadata. + ///@see Config\#setMetadataLoadStrategy(int) + static const LOAD_STRATEGY_MANUAL = 1; + + /// from: static public final int EMOJI_UNSUPPORTED + /// + /// Result of \#getEmojiMatch(CharSequence, int) that means no part of this codepoint + /// sequence will ever generate an EmojiSpan at the requested metadata level. + /// + /// This return value implies: + /// - EmojiCompat will always defer to system emoji font + /// - System emoji font may or may not support this emoji + /// - This application MAY render this emoji + /// + /// This can be used by keyboards to learn that EmojiCompat does not support this codepoint + /// sequence at this metadata version. The system emoji font is not checked by this method, + /// and this result will be returned even if the system emoji font supports the emoji. This may + /// happen if the application is using an older version of the emoji compat font than the + /// system emoji font. + /// + /// Keyboards may optionally determine that the system emoji font will support the emoji, for + /// example by building a internal lookup table or calling + /// androidx.core.graphics.PaintCompat\#hasGlyph(Paint, String) to query the system + /// emoji font. Keyboards may use a lookup table to optimize this check, however they should be + /// aware that OEMs may add or remove emoji from the system emoji font. + /// + /// Keyboards may finally decide: + /// - If the system emoji font DOES NOT support the emoji, then the emoji IS NOT supported by + /// this application. + /// - If the system emoji font DOES support the emoji, then the emoji IS supported by this + /// application. + /// - If system emoji font is support is UNKNOWN, then assume the emoji IS NOT supported by + /// this application. + static const EMOJI_UNSUPPORTED = 0; + + /// from: static public final int EMOJI_SUPPORTED + /// + /// Result of \#getEmojiMatch(CharSequence, int) that means this codepoint can be drawn + /// by an EmojiSpan at this metadata level. + /// + /// No further checks are required by keyboards for this result. The emoji is always supported + /// by this application. + /// + /// This return value implies: + /// - EmojiCompat can draw this emoji + /// - System emoji font may or may not support this emoji + /// - This application WILL render this emoji + /// + /// This result implies that EmojiCompat can successfully display this emoji. The system emoji + /// font is not checked by this method, and this result may be returned even if the platform + /// also supports the emoji sequence. + /// + /// If the application passes EmojiCompat\#REPLACE_STRATEGY_ALL of true, then an + /// EmojiSpan will always be generated for this emoji. + /// + /// If the application passes EmojiCompat\#REPLACE_STRATEGY_ALL of false, then an + /// EmojiSpan will only be generated if + /// androidx.core.graphics.PaintCompat\#hasGlyph(Paint, String) + /// returns false for this emoji. + static const EMOJI_SUPPORTED = 1; + + /// from: static public final int EMOJI_FALLBACK + /// + /// Result of \#getEmojiMatch(CharSequence, int) that means the full codepoint sequence + /// is not known to emojicompat, but at least one subsequence is an emoji that is known at + /// this metadata level. + /// + /// Keyboards may decide that this emoji is not supported by the application when this result is + /// returned, with no further processing. + /// + /// This return value implies: + /// - EmojiCompat will decompose this ZWJ sequence into multiple glyphs when replaceAll=true + /// - EmojiCompat MAY defer to platform when replaceAll=false + /// - System emoji font may or may not support this emoji + /// - This application MAY render this emoji + /// + /// This return value is only ever returned for ZWJ sequences. To understand this result + /// consider when it may be returned for the multi-skin-tone handshake introduced in emoji 14. + /// + ///

+  ///     U+1FAF1 // unknown @ requested metadata level
+  ///     U+1F3FB // metadata level 1
+  ///     U+200D  // not displayed (ZWJ)
+  ///     U+1FAF2 // unknown @ requested metadata level
+  ///     U+1F3FD // metadata level 1
+  /// 
+ /// + /// In this codepoint sequence, U+1F3FB and U+1F3FD are known from metadata level 1. When an + /// application is using a metadata level that doesn't understand this ZWJ and provides + /// EmojiCompat\#REPLACE_STRATEGY_ALL true, the color emoji are matched and replaced + /// with EmojiSpan. The system emoji font, even if it supports this ZWJ sequence, is + /// never queried and the added EmojiSpans force fallback rendering for the ZWJ sequence. + /// + /// The glyph will only display correctly for this application if ALL of the following + /// requirements are met: + /// - EmojiCompat\#REPLACE_STRATEGY_ALL is false + /// - androidx.core.graphics.PaintCompat\#hasGlyph(Paint, String) returns true for each + /// emoji subsequence known at this metadata level + /// - androidx.core.graphics.PaintCompat\#hasGlyph(Paint, String) returns true for the + /// full sequence + /// + /// Given this return value for the multi-skin-tone handshake above, if + /// EmojiCompat\#REPLACE_STRATEGY_ALL is false then the emoji will display if the + /// entire emoji sequence is matched by + /// androidx.core.graphics.PaintCompat\#hasGlyph(Paint, String) because U+1F3FB and + /// U+1F3FD are both in the system emoji font. + /// + /// Keyboards that wish to determine if the glyph will display correctly by the application in + /// response to this return value should consider building an internal lookup for new ZWJ + /// sequences instead of repeatedly calling + /// androidx.core.graphics.PaintCompat\#hasGlyph(Paint, String) for each emoji + /// subsequence. + static const EMOJI_FALLBACK = 2; + + static final _init = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("EmojiCompat__init") + .asFunction)>(); + + /// from: static public androidx.emoji2.text.EmojiCompat init(android.content.Context context) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Initialize the singleton instance with the default system-provided configuration. + /// + /// This is the recommended configuration for most applications. For more details see + /// DefaultEmojiCompatConfig. + /// + /// + /// This call will use DefaultEmojiCompatConfig to lookup the default emoji font + /// provider installed on the system and use that, if present. If there is no default font + /// provider onthe system, this call will have no effect. + /// + /// + /// Note: EmojiCompat may only be initialized once, and will return the same instance + /// afterwords. + /// + ///@return Default EmojiCompat for this device, or null if there is no provider on the system. + static EmojiCompat init(jni.JObject context) => + const $EmojiCompatType().fromRef(_init(context.reference).object); + + static final _init1 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("EmojiCompat__init1") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: static public androidx.emoji2.text.EmojiCompat init(android.content.Context context, androidx.emoji2.text.DefaultEmojiCompatConfig.DefaultEmojiCompatConfigFactory defaultFactory) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// @hide + static EmojiCompat init1( + jni.JObject context, + DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory + defaultFactory) => + const $EmojiCompatType() + .fromRef(_init1(context.reference, defaultFactory.reference).object); + + static final _init2 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("EmojiCompat__init2") + .asFunction)>(); + + /// from: static public androidx.emoji2.text.EmojiCompat init(androidx.emoji2.text.EmojiCompat.Config config) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Initialize the singleton instance with a configuration. When used on devices running API 18 + /// or below, the singleton instance is immediately moved into \#LOAD_STATE_SUCCEEDED + /// state without loading any metadata. When called for the first time, the library will create + /// the singleton instance and any call after that will not create a new instance and return + /// immediately. + ///@see EmojiCompat.Config + static EmojiCompat init2(EmojiCompat_Config config) => + const $EmojiCompatType().fromRef(_init2(config.reference).object); + + static final _isConfigured = + jniLookup>( + "EmojiCompat__isConfigured") + .asFunction(); + + /// from: static public boolean isConfigured() + /// + /// Return true if EmojiCompat has been configured by a successful call to + /// EmojiCompat\#init. + /// + /// You can use this to check if EmojiCompat\#get() will return a valid EmojiCompat + /// instance. + /// + /// This function does not check the \#getLoadState() and will return true even if the + /// font is still loading, or has failed to load. + ///@return true if EmojiCompat has been successfully initialized. + static bool isConfigured() => _isConfigured().boolean; + + static final _reset = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("EmojiCompat__reset") + .asFunction)>(); + + /// from: static public androidx.emoji2.text.EmojiCompat reset(androidx.emoji2.text.EmojiCompat.Config config) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Used by the tests to reset EmojiCompat with a new configuration. Every time it is called a + /// new instance is created with the new configuration. + ///@hide + static EmojiCompat reset(EmojiCompat_Config config) => + const $EmojiCompatType().fromRef(_reset(config.reference).object); + + static final _reset1 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("EmojiCompat__reset1") + .asFunction)>(); + + /// from: static public androidx.emoji2.text.EmojiCompat reset(androidx.emoji2.text.EmojiCompat emojiCompat) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Used by the tests to reset EmojiCompat with a new singleton instance. + ///@hide + static EmojiCompat reset1(EmojiCompat emojiCompat) => + const $EmojiCompatType().fromRef(_reset1(emojiCompat.reference).object); + + static final _skipDefaultConfigurationLookup = + jniLookup>( + "EmojiCompat__skipDefaultConfigurationLookup") + .asFunction(); + + /// from: static public void skipDefaultConfigurationLookup(boolean shouldSkip) + /// + /// Reset default configuration lookup flag, for tests. + ///@hide + static void skipDefaultConfigurationLookup(bool shouldSkip) => + _skipDefaultConfigurationLookup(shouldSkip ? 1 : 0).check(); + + static final _get0 = jniLookup>( + "EmojiCompat__get0") + .asFunction(); + + /// from: static public androidx.emoji2.text.EmojiCompat get() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Return singleton EmojiCompat instance. Should be called after + /// \#init(EmojiCompat.Config) is called to initialize the singleton instance. + ///@return EmojiCompat instance + ///@throws IllegalStateException if called before \#init(EmojiCompat.Config) + static EmojiCompat get0() => const $EmojiCompatType().fromRef(_get0().object); + + static final _load = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("EmojiCompat__load") + .asFunction)>(); + + /// from: public void load() + /// + /// When Config\#setMetadataLoadStrategy(int) is set to \#LOAD_STRATEGY_MANUAL, + /// this function starts loading the metadata. Calling the function when + /// Config\#setMetadataLoadStrategy(int) is {@code not} set to + /// \#LOAD_STRATEGY_MANUAL will throw an exception. The load will {@code not} start if: + ///
    + ///
  • the metadata is already loaded successfully and \#getLoadState() is + /// \#LOAD_STATE_SUCCEEDED. + ///
  • + ///
  • a previous load attempt is not finished yet and \#getLoadState() is + /// \#LOAD_STATE_LOADING.
  • + ///
+ ///@throws IllegalStateException when Config\#setMetadataLoadStrategy(int) is not set + /// to \#LOAD_STRATEGY_MANUAL + void load() => _load(reference).check(); + + static final _registerInitCallback = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("EmojiCompat__registerInitCallback") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public void registerInitCallback(androidx.emoji2.text.EmojiCompat.InitCallback initCallback) + /// + /// Registers an initialization callback. If the initialization is already completed by the time + /// the listener is added, the callback functions are called immediately. Callbacks are called on + /// the main looper. + ///

+ /// When used on devices running API 18 or below, InitCallback\#onInitialized() is called + /// without loading any metadata. In such cases InitCallback\#onFailed(Throwable) is never + /// called. + ///@param initCallback the initialization callback to register, cannot be {@code null} + ///@see \#unregisterInitCallback(InitCallback) + void registerInitCallback(EmojiCompat_InitCallback initCallback) => + _registerInitCallback(reference, initCallback.reference).check(); + + static final _unregisterInitCallback = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>>( + "EmojiCompat__unregisterInitCallback") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public void unregisterInitCallback(androidx.emoji2.text.EmojiCompat.InitCallback initCallback) + /// + /// Unregisters a callback that was added before. + ///@param initCallback the callback to be removed, cannot be {@code null} + void unregisterInitCallback(EmojiCompat_InitCallback initCallback) => + _unregisterInitCallback(reference, initCallback.reference).check(); + + static final _getLoadState = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("EmojiCompat__getLoadState") + .asFunction)>(); + + /// from: public int getLoadState() + /// + /// Returns loading state of the EmojiCompat instance. When used on devices running API 18 or + /// below always returns \#LOAD_STATE_SUCCEEDED. + ///@return one of \#LOAD_STATE_DEFAULT, \#LOAD_STATE_LOADING, + /// \#LOAD_STATE_SUCCEEDED, \#LOAD_STATE_FAILED + int getLoadState() => _getLoadState(reference).integer; + + static final _isEmojiSpanIndicatorEnabled = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>( + "EmojiCompat__isEmojiSpanIndicatorEnabled") + .asFunction)>(); + + /// from: public boolean isEmojiSpanIndicatorEnabled() + /// + /// @return whether a background should be drawn for the emoji for debugging + ///@hide + bool isEmojiSpanIndicatorEnabled() => + _isEmojiSpanIndicatorEnabled(reference).boolean; + + static final _getEmojiSpanIndicatorColor = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>( + "EmojiCompat__getEmojiSpanIndicatorColor") + .asFunction)>(); + + /// from: public int getEmojiSpanIndicatorColor() + /// + /// @return color of background drawn if EmojiCompat\#isEmojiSpanIndicatorEnabled is true + ///@hide + int getEmojiSpanIndicatorColor() => + _getEmojiSpanIndicatorColor(reference).integer; + + static final _getEmojiStart = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int32)>>("EmojiCompat__getEmojiStart") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer, int)>(); + + /// from: public int getEmojiStart(java.lang.CharSequence charSequence, int offset) + /// + /// Together with \#getEmojiEnd(CharSequence, int), if the character at {@code offset} is + /// part of an emoji, returns the index range of that emoji, start index inclusively/end index + /// exclusively so that {@code charSequence.subSequence(start, end)} will return that emoji. + /// E.g., getEmojiStart/End("AB\ud83d\ude00", 1) will return (-1,-1) since 'B' is not part an emoji; + /// getEmojiStart/End("AB\ud83d\ude00", 3) will return [2,4), note that "\ud83d\ude00" contains 2 Chars. + /// Returns -1 otherwise. + ///@param charSequence the whole sequence + ///@param offset index of the emoji to look up + ///@return the start index inclusively/end index exclusively + int getEmojiStart(jni.JObject charSequence, int offset) => + _getEmojiStart(reference, charSequence.reference, offset).integer; + + static final _getEmojiEnd = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int32)>>("EmojiCompat__getEmojiEnd") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer, int)>(); + + /// from: public int getEmojiEnd(java.lang.CharSequence charSequence, int offset) + /// + /// see \#getEmojiStart(CharSequence, int). + int getEmojiEnd(jni.JObject charSequence, int offset) => + _getEmojiEnd(reference, charSequence.reference, offset).integer; + + static final _handleOnKeyDown = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, ffi.Int32, + ffi.Pointer)>>("EmojiCompat__handleOnKeyDown") + .asFunction< + jni.JniResult Function( + ffi.Pointer, int, ffi.Pointer)>(); + + /// from: static public boolean handleOnKeyDown(android.text.Editable editable, int keyCode, android.view.KeyEvent event) + /// + /// Handles onKeyDown commands from a KeyListener and if {@code keyCode} is one of + /// KeyEvent\#KEYCODE_DEL or KeyEvent\#KEYCODE_FORWARD_DEL it tries to delete an + /// EmojiSpan from an Editable. Returns {@code true} if an EmojiSpan is + /// deleted with the characters it covers. + ///

+ /// If there is a selection where selection start is not equal to selection end, does not + /// delete. + ///

+ /// When used on devices running API 18 or below, always returns {@code false}. + ///@param editable Editable instance passed to KeyListener\#onKeyDown(android.view.View, + /// Editable, int, KeyEvent) + ///@param keyCode keyCode passed to KeyListener\#onKeyDown(android.view.View, Editable, + /// int, KeyEvent) + ///@param event KeyEvent passed to KeyListener\#onKeyDown(android.view.View, Editable, + /// int, KeyEvent) + ///@return {@code true} if an EmojiSpan is deleted + static bool handleOnKeyDown( + jni.JObject editable, int keyCode, jni.JObject event) => + _handleOnKeyDown(editable.reference, keyCode, event.reference).boolean; + + static final _handleDeleteSurroundingText = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int32, + ffi.Int32, + ffi.Uint8)>>("EmojiCompat__handleDeleteSurroundingText") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer, int, int, int)>(); + + /// from: static public boolean handleDeleteSurroundingText(android.view.inputmethod.InputConnection inputConnection, android.text.Editable editable, int beforeLength, int afterLength, boolean inCodePoints) + /// + /// Handles deleteSurroundingText commands from InputConnection and tries to delete an + /// EmojiSpan from an Editable. Returns {@code true} if an EmojiSpan is + /// deleted. + ///

+ /// If there is a selection where selection start is not equal to selection end, does not + /// delete. + ///

+ /// When used on devices running API 18 or below, always returns {@code false}. + ///@param inputConnection InputConnection instance + ///@param editable TextView.Editable instance + ///@param beforeLength the number of characters before the cursor to be deleted + ///@param afterLength the number of characters after the cursor to be deleted + ///@param inCodePoints {@code true} if length parameters are in codepoints + ///@return {@code true} if an EmojiSpan is deleted + static bool handleDeleteSurroundingText( + jni.JObject inputConnection, + jni.JObject editable, + int beforeLength, + int afterLength, + bool inCodePoints) => + _handleDeleteSurroundingText( + inputConnection.reference, + editable.reference, + beforeLength, + afterLength, + inCodePoints ? 1 : 0) + .boolean; + + static final _hasEmojiGlyph = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("EmojiCompat__hasEmojiGlyph") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public boolean hasEmojiGlyph(java.lang.CharSequence sequence) + /// + /// Returns {@code true} if EmojiCompat is capable of rendering an emoji. When used on devices + /// running API 18 or below, always returns {@code false}. + ///@deprecated use getEmojiMatch which returns more accurate lookup information. + ///@param sequence CharSequence representing the emoji + ///@return {@code true} if EmojiCompat can render given emoji, cannot be {@code null} + ///@throws IllegalStateException if not initialized yet + bool hasEmojiGlyph(jni.JObject sequence) => + _hasEmojiGlyph(reference, sequence.reference).boolean; + + static final _hasEmojiGlyph1 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int32)>>("EmojiCompat__hasEmojiGlyph1") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer, int)>(); + + /// from: public boolean hasEmojiGlyph(java.lang.CharSequence sequence, int metadataVersion) + /// + /// Returns {@code true} if EmojiCompat is capable of rendering an emoji at the given metadata + /// version. When used on devices running API 18 or below, always returns {@code false}. + ///@deprecated use getEmojiMatch which returns more accurate lookup information. + ///@param sequence CharSequence representing the emoji + ///@param metadataVersion the metadata version to check against, should be greater than or + /// equal to {@code 0}, + ///@return {@code true} if EmojiCompat can render given emoji, cannot be {@code null} + ///@throws IllegalStateException if not initialized yet + bool hasEmojiGlyph1(jni.JObject sequence, int metadataVersion) => + _hasEmojiGlyph1(reference, sequence.reference, metadataVersion).boolean; + + static final _getEmojiMatch = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int32)>>("EmojiCompat__getEmojiMatch") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer, int)>(); + + /// from: public int getEmojiMatch(java.lang.CharSequence sequence, int metadataVersion) + /// + /// Attempts to lookup the entire sequence at the specified metadata version and returns what + /// the runtime match behavior would be. + /// + /// To be used by keyboards to show or hide emoji in response to specific metadata support. + ///@see \#EMOJI_SUPPORTED + ///@see \#EMOJI_UNSUPPORTED + ///@see \#EMOJI_FALLBACK + ///@param sequence CharSequence representing an emoji + ///@param metadataVersion the metada version to check against, should be greater than or + /// equal to {@code 0}, + ///@return A match result, or decomposes if replaceAll would cause partial subsequence matches. + int getEmojiMatch(jni.JObject sequence, int metadataVersion) => + _getEmojiMatch(reference, sequence.reference, metadataVersion).integer; + + static final _process = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("EmojiCompat__process") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public java.lang.CharSequence process(java.lang.CharSequence charSequence) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Checks a given CharSequence for emojis, and adds EmojiSpans if any emojis are found. When + /// used on devices running API 18 or below, returns the given {@code charSequence} without + /// processing it. + ///@param charSequence CharSequence to add the EmojiSpans + ///@throws IllegalStateException if not initialized yet + ///@see \#process(CharSequence, int, int) + jni.JObject process(jni.JObject charSequence) => const jni.JObjectType() + .fromRef(_process(reference, charSequence.reference).object); + + static final _process1 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int32, + ffi.Int32)>>("EmojiCompat__process1") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer, int, int)>(); + + /// from: public java.lang.CharSequence process(java.lang.CharSequence charSequence, int start, int end) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Checks a given CharSequence for emojis, and adds EmojiSpans if any emojis are found. + /// + ///

    + ///
  • If no emojis are found, {@code charSequence} given as the input is returned without + /// any changes. i.e. charSequence is a String, and no emojis are found, the same String is + /// returned.
  • + ///
  • If the given input is not a Spannable (such as String), and at least one emoji is found + /// a new android.text.Spannable instance is returned.
  • + ///
  • If the given input is a Spannable, the same instance is returned.
  • + ///
+ /// When used on devices running API 18 or below, returns the given {@code charSequence} without + /// processing it. + ///@param charSequence CharSequence to add the EmojiSpans, cannot be {@code null} + ///@param start start index in the charSequence to look for emojis, should be greater than or + /// equal to {@code 0}, also less than or equal to {@code charSequence.length()} + ///@param end end index in the charSequence to look for emojis, should be greater than or equal + /// to {@code start} parameter, also less than or equal to + /// {@code charSequence.length()} + ///@throws IllegalStateException if not initialized yet + ///@throws IllegalArgumentException in the following cases: + /// {@code start < 0}, {@code end < 0}, {@code end < start}, + /// {@code start > charSequence.length()}, + /// {@code end > charSequence.length()} + jni.JObject process1(jni.JObject charSequence, int start, int end) => + const jni.JObjectType().fromRef( + _process1(reference, charSequence.reference, start, end).object); + + static final _process2 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int32, + ffi.Int32, + ffi.Int32)>>("EmojiCompat__process2") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer, int, int, int)>(); + + /// from: public java.lang.CharSequence process(java.lang.CharSequence charSequence, int start, int end, int maxEmojiCount) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Checks a given CharSequence for emojis, and adds EmojiSpans if any emojis are found. + /// + ///
    + ///
  • If no emojis are found, {@code charSequence} given as the input is returned without + /// any changes. i.e. charSequence is a String, and no emojis are found, the same String is + /// returned.
  • + ///
  • If the given input is not a Spannable (such as String), and at least one emoji is found + /// a new android.text.Spannable instance is returned.
  • + ///
  • If the given input is a Spannable, the same instance is returned.
  • + ///
+ /// When used on devices running API 18 or below, returns the given {@code charSequence} without + /// processing it. + ///@param charSequence CharSequence to add the EmojiSpans, cannot be {@code null} + ///@param start start index in the charSequence to look for emojis, should be greater than or + /// equal to {@code 0}, also less than or equal to {@code charSequence.length()} + ///@param end end index in the charSequence to look for emojis, should be greater than or + /// equal to {@code start} parameter, also less than or equal to + /// {@code charSequence.length()} + ///@param maxEmojiCount maximum number of emojis in the {@code charSequence}, should be greater + /// than or equal to {@code 0} + ///@throws IllegalStateException if not initialized yet + ///@throws IllegalArgumentException in the following cases: + /// {@code start < 0}, {@code end < 0}, {@code end < start}, + /// {@code start > charSequence.length()}, + /// {@code end > charSequence.length()} + /// {@code maxEmojiCount < 0} + jni.JObject process2( + jni.JObject charSequence, int start, int end, int maxEmojiCount) => + const jni.JObjectType().fromRef(_process2( + reference, charSequence.reference, start, end, maxEmojiCount) + .object); + + static final _process3 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int32, + ffi.Int32, + ffi.Int32, + ffi.Int32)>>("EmojiCompat__process3") + .asFunction< + jni.JniResult Function(ffi.Pointer, ffi.Pointer, + int, int, int, int)>(); + + /// from: public java.lang.CharSequence process(java.lang.CharSequence charSequence, int start, int end, int maxEmojiCount, int replaceStrategy) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Checks a given CharSequence for emojis, and adds EmojiSpans if any emojis are found. + /// + ///
    + ///
  • If no emojis are found, {@code charSequence} given as the input is returned without + /// any changes. i.e. charSequence is a String, and no emojis are found, the same String is + /// returned.
  • + ///
  • If the given input is not a Spannable (such as String), and at least one emoji is found + /// a new android.text.Spannable instance is returned.
  • + ///
  • If the given input is a Spannable, the same instance is returned.
  • + ///
+ /// When used on devices running API 18 or below, returns the given {@code charSequence} without + /// processing it. + ///@param charSequence CharSequence to add the EmojiSpans, cannot be {@code null} + ///@param start start index in the charSequence to look for emojis, should be greater than or + /// equal to {@code 0}, also less than or equal to {@code charSequence.length()} + ///@param end end index in the charSequence to look for emojis, should be greater than or + /// equal to {@code start} parameter, also less than or equal to + /// {@code charSequence.length()} + ///@param maxEmojiCount maximum number of emojis in the {@code charSequence}, should be greater + /// than or equal to {@code 0} + ///@param replaceStrategy whether to replace all emoji with EmojiSpans, should be one of + /// \#REPLACE_STRATEGY_DEFAULT, + /// \#REPLACE_STRATEGY_NON_EXISTENT, + /// \#REPLACE_STRATEGY_ALL + ///@throws IllegalStateException if not initialized yet + ///@throws IllegalArgumentException in the following cases: + /// {@code start < 0}, {@code end < 0}, {@code end < start}, + /// {@code start > charSequence.length()}, + /// {@code end > charSequence.length()} + /// {@code maxEmojiCount < 0} + jni.JObject process3(jni.JObject charSequence, int start, int end, + int maxEmojiCount, int replaceStrategy) => + const jni.JObjectType().fromRef(_process3( + reference, + charSequence.reference, + start, + end, + maxEmojiCount, + replaceStrategy) + .object); + + static final _getAssetSignature = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("EmojiCompat__getAssetSignature") + .asFunction)>(); + + /// from: public java.lang.String getAssetSignature() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Returns signature for the currently loaded emoji assets. The signature is a SHA that is + /// constructed using emoji assets. Can be used to detect if currently loaded asset is different + /// then previous executions. When used on devices running API 18 or below, returns empty string. + ///@throws IllegalStateException if not initialized yet + jni.JString getAssetSignature() => + const jni.JStringType().fromRef(_getAssetSignature(reference).object); + + static final _updateEditorInfo = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("EmojiCompat__updateEditorInfo") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public void updateEditorInfo(android.view.inputmethod.EditorInfo outAttrs) + /// + /// Updates the EditorInfo attributes in order to communicate information to Keyboards. When + /// used on devices running API 18 or below, does not update EditorInfo attributes. + /// + /// This is called from EditText integrations that use EmojiEditTextHelper. Custom + /// widgets that allow IME not subclassing EditText should call this method when creating an + /// input connection. + /// + /// When EmojiCompat is not in \#LOAD_STATE_SUCCEEDED, this method has no effect. + /// + /// Calling this method on API levels below API 19 will have no effect, as EmojiCompat may + /// never be configured. However, it is always safe to call, even on older API levels. + ///@param outAttrs EditorInfo instance passed to + /// android.widget.TextView\#onCreateInputConnection(EditorInfo) + ///@see \#EDITOR_INFO_METAVERSION_KEY + ///@see \#EDITOR_INFO_REPLACE_ALL_KEY + void updateEditorInfo(jni.JObject outAttrs) => + _updateEditorInfo(reference, outAttrs.reference).check(); +} + +class $EmojiCompatType extends jni.JObjType { + const $EmojiCompatType(); + + @override + String get signature => r"Landroidx/emoji2/text/EmojiCompat;"; + + @override + EmojiCompat fromRef(jni.JObjectPtr ref) => EmojiCompat.fromRef(ref); +} + +/// from: androidx.emoji2.text.EmojiCompat$Config +/// +/// Configuration class for EmojiCompat. Changes to the values will be ignored after +/// \#init(Config) is called. +///@see \#init(EmojiCompat.Config) +class EmojiCompat_Config extends jni.JObject { + late final jni.JObjType? _$type; + @override + jni.JObjType get $type => _$type ??= type; + + EmojiCompat_Config.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = $EmojiCompat_ConfigType(); + static final _ctor = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("EmojiCompat_Config__ctor") + .asFunction)>(); + + /// from: protected void (androidx.emoji2.text.EmojiCompat.MetadataRepoLoader metadataLoader) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Default constructor. + ///@param metadataLoader MetadataRepoLoader instance, cannot be {@code null} + EmojiCompat_Config(EmojiCompat_MetadataRepoLoader metadataLoader) + : super.fromRef(_ctor(metadataLoader.reference).object); + + static final _registerInitCallback = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>>( + "EmojiCompat_Config__registerInitCallback") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public androidx.emoji2.text.EmojiCompat.Config registerInitCallback(androidx.emoji2.text.EmojiCompat.InitCallback initCallback) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Registers an initialization callback. + ///@param initCallback the initialization callback to register, cannot be {@code null} + ///@return EmojiCompat.Config instance + EmojiCompat_Config registerInitCallback( + EmojiCompat_InitCallback initCallback) => + const $EmojiCompat_ConfigType().fromRef( + _registerInitCallback(reference, initCallback.reference).object); + + static final _unregisterInitCallback = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>>( + "EmojiCompat_Config__unregisterInitCallback") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public androidx.emoji2.text.EmojiCompat.Config unregisterInitCallback(androidx.emoji2.text.EmojiCompat.InitCallback initCallback) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Unregisters a callback that was added before. + ///@param initCallback the initialization callback to be removed, cannot be {@code null} + ///@return EmojiCompat.Config instance + EmojiCompat_Config unregisterInitCallback( + EmojiCompat_InitCallback initCallback) => + const $EmojiCompat_ConfigType().fromRef( + _unregisterInitCallback(reference, initCallback.reference).object); + + static final _setReplaceAll = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Uint8)>>("EmojiCompat_Config__setReplaceAll") + .asFunction, int)>(); + + /// from: public androidx.emoji2.text.EmojiCompat.Config setReplaceAll(boolean replaceAll) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Determines whether EmojiCompat should replace all the emojis it finds with the + /// EmojiSpans. By default EmojiCompat tries its best to understand if the system already + /// can render an emoji and do not replace those emojis. + ///@param replaceAll replace all emojis found with EmojiSpans + ///@return EmojiCompat.Config instance + EmojiCompat_Config setReplaceAll(bool replaceAll) => + const $EmojiCompat_ConfigType() + .fromRef(_setReplaceAll(reference, replaceAll ? 1 : 0).object); + + static final _setUseEmojiAsDefaultStyle = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Uint8)>>("EmojiCompat_Config__setUseEmojiAsDefaultStyle") + .asFunction, int)>(); + + /// from: public androidx.emoji2.text.EmojiCompat.Config setUseEmojiAsDefaultStyle(boolean useEmojiAsDefaultStyle) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Determines whether EmojiCompat should use the emoji presentation style for emojis + /// that have text style as default. By default, the text style would be used, unless these + /// are followed by the U+FE0F variation selector. + /// Details about emoji presentation and text presentation styles can be found here: + /// http://unicode.org/reports/tr51/\#Presentation_Style + /// If useEmojiAsDefaultStyle is true, the emoji presentation style will be used for all + /// emojis, including potentially unexpected ones (such as digits or other keycap emojis). If + /// this is not the expected behaviour, method + /// \#setUseEmojiAsDefaultStyle(boolean, List) can be used to specify the + /// exception emojis that should be still presented as text style. + ///@param useEmojiAsDefaultStyle whether to use the emoji style presentation for all emojis + /// that would be presented as text style by default + EmojiCompat_Config setUseEmojiAsDefaultStyle(bool useEmojiAsDefaultStyle) => + const $EmojiCompat_ConfigType().fromRef( + _setUseEmojiAsDefaultStyle(reference, useEmojiAsDefaultStyle ? 1 : 0) + .object); + + static final _setUseEmojiAsDefaultStyle1 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, ffi.Uint8, + ffi.Pointer)>>( + "EmojiCompat_Config__setUseEmojiAsDefaultStyle1") + .asFunction< + jni.JniResult Function( + ffi.Pointer, int, ffi.Pointer)>(); + + /// from: public androidx.emoji2.text.EmojiCompat.Config setUseEmojiAsDefaultStyle(boolean useEmojiAsDefaultStyle, java.util.List emojiAsDefaultStyleExceptions) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// @see \#setUseEmojiAsDefaultStyle(boolean) + ///@param emojiAsDefaultStyleExceptions Contains the exception emojis which will be still + /// presented as text style even if the + /// useEmojiAsDefaultStyle flag is set to {@code true}. + /// This list will be ignored if useEmojiAsDefaultStyle + /// is {@code false}. Note that emojis with default + /// emoji style presentation will remain emoji style + /// regardless the value of useEmojiAsDefaultStyle or + /// whether they are included in the exceptions list or + /// not. When no exception is wanted, the method + /// \#setUseEmojiAsDefaultStyle(boolean) should + /// be used instead. + EmojiCompat_Config setUseEmojiAsDefaultStyle1(bool useEmojiAsDefaultStyle, + jni.JObject emojiAsDefaultStyleExceptions) => + const $EmojiCompat_ConfigType().fromRef(_setUseEmojiAsDefaultStyle1( + reference, + useEmojiAsDefaultStyle ? 1 : 0, + emojiAsDefaultStyleExceptions.reference) + .object); + + static final _setEmojiSpanIndicatorEnabled = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, ffi.Uint8)>>( + "EmojiCompat_Config__setEmojiSpanIndicatorEnabled") + .asFunction, int)>(); + + /// from: public androidx.emoji2.text.EmojiCompat.Config setEmojiSpanIndicatorEnabled(boolean emojiSpanIndicatorEnabled) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Determines whether a background will be drawn for the emojis that are found and + /// replaced by EmojiCompat. Should be used only for debugging purposes. The indicator color + /// can be set using \#setEmojiSpanIndicatorColor(int). + ///@param emojiSpanIndicatorEnabled when {@code true} a background is drawn for each emoji + /// that is replaced + EmojiCompat_Config setEmojiSpanIndicatorEnabled( + bool emojiSpanIndicatorEnabled) => + const $EmojiCompat_ConfigType().fromRef(_setEmojiSpanIndicatorEnabled( + reference, emojiSpanIndicatorEnabled ? 1 : 0) + .object); + + static final _setEmojiSpanIndicatorColor = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Int32)>>("EmojiCompat_Config__setEmojiSpanIndicatorColor") + .asFunction, int)>(); + + /// from: public androidx.emoji2.text.EmojiCompat.Config setEmojiSpanIndicatorColor(int color) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Sets the color used as emoji span indicator. The default value is + /// Color\#GREEN Color.GREEN. + ///@see \#setEmojiSpanIndicatorEnabled(boolean) + EmojiCompat_Config setEmojiSpanIndicatorColor(int color) => + const $EmojiCompat_ConfigType() + .fromRef(_setEmojiSpanIndicatorColor(reference, color).object); + + static final _setMetadataLoadStrategy = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Int32)>>("EmojiCompat_Config__setMetadataLoadStrategy") + .asFunction, int)>(); + + /// from: public androidx.emoji2.text.EmojiCompat.Config setMetadataLoadStrategy(int strategy) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Determines the strategy to start loading the metadata. By default EmojiCompat + /// will start loading the metadata during EmojiCompat\#init(Config). When set to + /// EmojiCompat\#LOAD_STRATEGY_MANUAL, you should call EmojiCompat\#load() to + /// initiate metadata loading. + ///

+ /// Default implementations of EmojiCompat.MetadataRepoLoader start a thread + /// during their EmojiCompat.MetadataRepoLoader\#load functions. Just instantiating + /// and starting a thread might take time especially in older devices. Since + /// EmojiCompat\#init(Config) has to be called before any EmojiCompat widgets are + /// inflated, this results in time spent either on your Application.onCreate or Activity + /// .onCreate. If you'd like to gain more control on when to start loading the metadata + /// and be able to call EmojiCompat\#init(Config) with absolute minimum time cost you + /// can use EmojiCompat\#LOAD_STRATEGY_MANUAL. + ///

+ /// When set to EmojiCompat\#LOAD_STRATEGY_MANUAL, EmojiCompat will wait + /// for \#load() to be called by the developer in order to start loading metadata, + /// therefore you should call EmojiCompat\#load() to initiate metadata loading. + /// \#load() can be called from any thread. + ///

+  /// EmojiCompat.Config config = new FontRequestEmojiCompatConfig(context, fontRequest)
+  ///         .setMetadataLoadStrategy(EmojiCompat.LOAD_STRATEGY_MANUAL);
+  ///
+  /// // EmojiCompat will not start loading metadata and MetadataRepoLoader\#load(...)
+  /// // will not be called
+  /// EmojiCompat.init(config);
+  ///
+  /// // At any time (i.e. idle time or executorService is ready)
+  /// // call EmojiCompat\#load() to start loading metadata.
+  /// executorService.execute(() -> EmojiCompat.get().load());
+  /// 
+ ///@param strategy one of EmojiCompat\#LOAD_STRATEGY_DEFAULT, + /// EmojiCompat\#LOAD_STRATEGY_MANUAL + EmojiCompat_Config setMetadataLoadStrategy(int strategy) => + const $EmojiCompat_ConfigType() + .fromRef(_setMetadataLoadStrategy(reference, strategy).object); + + static final _setSpanFactory = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("EmojiCompat_Config__setSpanFactory") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public androidx.emoji2.text.EmojiCompat.Config setSpanFactory(androidx.emoji2.text.EmojiCompat.SpanFactory factory) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Set the span factory used to actually draw emoji replacements. + ///@param factory custum span factory that can draw the emoji replacements + ///@return this + EmojiCompat_Config setSpanFactory(EmojiCompat_SpanFactory factory0) => + const $EmojiCompat_ConfigType() + .fromRef(_setSpanFactory(reference, factory0.reference).object); + + static final _setGlyphChecker = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>>( + "EmojiCompat_Config__setGlyphChecker") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public androidx.emoji2.text.EmojiCompat.Config setGlyphChecker(androidx.emoji2.text.EmojiCompat.GlyphChecker glyphChecker) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// The interface that is used by EmojiCompat in order to check if a given emoji can be + /// rendered by the system. + ///@param glyphChecker GlyphChecker instance to be used. + EmojiCompat_Config setGlyphChecker(EmojiCompat_GlyphChecker glyphChecker) => + const $EmojiCompat_ConfigType() + .fromRef(_setGlyphChecker(reference, glyphChecker.reference).object); + + static final _getMetadataRepoLoader = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>( + "EmojiCompat_Config__getMetadataRepoLoader") + .asFunction)>(); + + /// from: protected final androidx.emoji2.text.EmojiCompat.MetadataRepoLoader getMetadataRepoLoader() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Returns the MetadataRepoLoader. + EmojiCompat_MetadataRepoLoader getMetadataRepoLoader() => + const $EmojiCompat_MetadataRepoLoaderType() + .fromRef(_getMetadataRepoLoader(reference).object); +} + +class $EmojiCompat_ConfigType extends jni.JObjType { + const $EmojiCompat_ConfigType(); + + @override + String get signature => r"Landroidx/emoji2/text/EmojiCompat$Config;"; + + @override + EmojiCompat_Config fromRef(jni.JObjectPtr ref) => + EmojiCompat_Config.fromRef(ref); +} + +/// from: androidx.emoji2.text.EmojiCompat$MetadataRepoLoaderCallback +/// +/// Callback to inform EmojiCompat about the state of the metadata load. Passed to +/// MetadataRepoLoader during MetadataRepoLoader\#load(MetadataRepoLoaderCallback) call. +class EmojiCompat_MetadataRepoLoaderCallback extends jni.JObject { + late final jni.JObjType? _$type; + @override + jni.JObjType get $type => _$type ??= type; + + EmojiCompat_MetadataRepoLoaderCallback.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = $EmojiCompat_MetadataRepoLoaderCallbackType(); + static final _ctor = jniLookup>( + "EmojiCompat_MetadataRepoLoaderCallback__ctor") + .asFunction(); + + /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. + EmojiCompat_MetadataRepoLoaderCallback() : super.fromRef(_ctor().object); + + static final _onLoaded = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>>( + "EmojiCompat_MetadataRepoLoaderCallback__onLoaded") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public abstract void onLoaded(androidx.emoji2.text.MetadataRepo metadataRepo) + /// + /// Called by MetadataRepoLoader when metadata is loaded successfully. + ///@param metadataRepo MetadataRepo instance, cannot be {@code null} + void onLoaded(jni.JObject metadataRepo) => + _onLoaded(reference, metadataRepo.reference).check(); + + static final _onFailed = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>>( + "EmojiCompat_MetadataRepoLoaderCallback__onFailed") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public abstract void onFailed(java.lang.Throwable throwable) + /// + /// Called by MetadataRepoLoader if an error occurs while loading the metadata. + ///@param throwable the exception that caused the failure, {@code nullable} + void onFailed(jni.JObject throwable) => + _onFailed(reference, throwable.reference).check(); +} + +class $EmojiCompat_MetadataRepoLoaderCallbackType + extends jni.JObjType { + const $EmojiCompat_MetadataRepoLoaderCallbackType(); + + @override + String get signature => + r"Landroidx/emoji2/text/EmojiCompat$MetadataRepoLoaderCallback;"; + + @override + EmojiCompat_MetadataRepoLoaderCallback fromRef(jni.JObjectPtr ref) => + EmojiCompat_MetadataRepoLoaderCallback.fromRef(ref); +} + +/// from: androidx.emoji2.text.EmojiCompat$GlyphChecker +/// +/// Interface to check if a given emoji exists on the system. +class EmojiCompat_GlyphChecker extends jni.JObject { + late final jni.JObjType? _$type; + @override + jni.JObjType get $type => _$type ??= type; + + EmojiCompat_GlyphChecker.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = $EmojiCompat_GlyphCheckerType(); + static final _hasGlyph = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int32, + ffi.Int32, + ffi.Int32)>>("EmojiCompat_GlyphChecker__hasGlyph") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer, int, int, int)>(); + + /// from: public abstract boolean hasGlyph(java.lang.CharSequence charSequence, int start, int end, int sdkAdded) + /// + /// Return {@code true} if the emoji that is in {@code charSequence} between + /// {@code start}(inclusive) and {@code end}(exclusive) can be rendered on the system + /// using the default Typeface. + /// + /// This function is called after an emoji is identified in the given {@code charSequence} + /// and EmojiCompat wants to know if that emoji can be rendered on the system. The result + /// of this call will be cached and the same emoji sequence won't be asked for the same + /// EmojiCompat instance. + /// + /// When the function returns {@code true}, it will mean that the system can render the + /// emoji. In that case if Config\#setReplaceAll is set to {@code false}, then no + /// EmojiSpan will be added in the final emoji processing result. + /// + /// When the function returns {@code false}, it will mean that the system cannot render + /// the given emoji, therefore an EmojiSpan will be added to the final emoji + /// processing result. + /// + /// The default implementation of this class uses + /// androidx.core.graphics.PaintCompat\#hasGlyph(Paint, String) function to check + /// if the emoji can be rendered on the system. This is required even if EmojiCompat + /// knows about the SDK Version that the emoji was added on AOSP. Just the {@code sdkAdded} + /// information is not enough to reliably decide if emoji can be rendered since this + /// information may not be consistent across all the OEMs and all the Android versions. + /// + /// With this interface you can apply your own heuristics to check if the emoji can be + /// rendered on the system. For example, if you'd like to rely on the {@code sdkAdded} + /// information, and some predefined OEMs, it is possible to write the following code + /// snippet. + /// + /// {@sample frameworks/support/samples/SupportEmojiDemos/src/main/java/com/example/android/support/text/emoji/sample/GlyphCheckerSample.java glyphchecker} + ///@param charSequence the CharSequence that is being processed + ///@param start the inclusive starting offset for the emoji in the {@code charSequence} + ///@param end the exclusive end offset for the emoji in the {@code charSequence} + ///@param sdkAdded the API version that the emoji was added in AOSP + ///@return true if the given sequence can be rendered as a single glyph, otherwise false. + bool hasGlyph(jni.JObject charSequence, int start, int end, int sdkAdded) => + _hasGlyph(reference, charSequence.reference, start, end, sdkAdded) + .boolean; +} + +class $EmojiCompat_GlyphCheckerType + extends jni.JObjType { + const $EmojiCompat_GlyphCheckerType(); + + @override + String get signature => r"Landroidx/emoji2/text/EmojiCompat$GlyphChecker;"; + + @override + EmojiCompat_GlyphChecker fromRef(jni.JObjectPtr ref) => + EmojiCompat_GlyphChecker.fromRef(ref); +} + +/// from: androidx.emoji2.text.EmojiCompat$MetadataRepoLoader +/// +/// Interface to load emoji metadata. +class EmojiCompat_MetadataRepoLoader extends jni.JObject { + late final jni.JObjType? _$type; + @override + jni.JObjType get $type => _$type ??= type; + + EmojiCompat_MetadataRepoLoader.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = $EmojiCompat_MetadataRepoLoaderType(); + static final _load = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>>( + "EmojiCompat_MetadataRepoLoader__load") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public abstract void load(androidx.emoji2.text.EmojiCompat.MetadataRepoLoaderCallback loaderCallback) + /// + /// Start loading the metadata. When the loading operation is finished MetadataRepoLoaderCallback\#onLoaded(MetadataRepo) or + /// MetadataRepoLoaderCallback\#onFailed(Throwable) should be called. When used on + /// devices running API 18 or below, this function is never called. + ///@param loaderCallback callback to signal the loading state + void load(EmojiCompat_MetadataRepoLoaderCallback loaderCallback) => + _load(reference, loaderCallback.reference).check(); +} + +class $EmojiCompat_MetadataRepoLoaderType + extends jni.JObjType { + const $EmojiCompat_MetadataRepoLoaderType(); + + @override + String get signature => + r"Landroidx/emoji2/text/EmojiCompat$MetadataRepoLoader;"; + + @override + EmojiCompat_MetadataRepoLoader fromRef(jni.JObjectPtr ref) => + EmojiCompat_MetadataRepoLoader.fromRef(ref); +} + +/// from: androidx.emoji2.text.EmojiCompat$InitCallback +/// +/// Listener class for the initialization of the EmojiCompat. +class EmojiCompat_InitCallback extends jni.JObject { + late final jni.JObjType? _$type; + @override + jni.JObjType get $type => _$type ??= type; + + EmojiCompat_InitCallback.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = $EmojiCompat_InitCallbackType(); + static final _ctor = jniLookup>( + "EmojiCompat_InitCallback__ctor") + .asFunction(); + + /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. + EmojiCompat_InitCallback() : super.fromRef(_ctor().object); + + static final _onInitialized = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>( + "EmojiCompat_InitCallback__onInitialized") + .asFunction)>(); + + /// from: public void onInitialized() + /// + /// Called when EmojiCompat is initialized and the emoji data is loaded. When used on devices + /// running API 18 or below, this function is always called. + void onInitialized() => _onInitialized(reference).check(); + + static final _onFailed = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("EmojiCompat_InitCallback__onFailed") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public void onFailed(java.lang.Throwable throwable) + /// + /// Called when an unrecoverable error occurs during EmojiCompat initialization. When used on + /// devices running API 18 or below, this function is never called. + void onFailed(jni.JObject throwable) => + _onFailed(reference, throwable.reference).check(); +} + +class $EmojiCompat_InitCallbackType + extends jni.JObjType { + const $EmojiCompat_InitCallbackType(); + + @override + String get signature => r"Landroidx/emoji2/text/EmojiCompat$InitCallback;"; + + @override + EmojiCompat_InitCallback fromRef(jni.JObjectPtr ref) => + EmojiCompat_InitCallback.fromRef(ref); +} + +/// from: androidx.emoji2.text.EmojiCompat$DefaultSpanFactory +/// +/// @hide +class EmojiCompat_DefaultSpanFactory extends jni.JObject { + late final jni.JObjType? _$type; + @override + jni.JObjType get $type => _$type ??= type; + + EmojiCompat_DefaultSpanFactory.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = $EmojiCompat_DefaultSpanFactoryType(); + static final _ctor = jniLookup>( + "EmojiCompat_DefaultSpanFactory__ctor") + .asFunction(); + + /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. + EmojiCompat_DefaultSpanFactory() : super.fromRef(_ctor().object); + + static final _createSpan = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>>( + "EmojiCompat_DefaultSpanFactory__createSpan") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public androidx.emoji2.text.EmojiSpan createSpan(androidx.emoji2.text.TypefaceEmojiRasterizer rasterizer) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Returns a TypefaceEmojiSpan. + ///@param rasterizer TypefaceEmojiRasterizer instance, which can draw the emoji onto a + /// Canvas. + ///@return TypefaceEmojiSpan + jni.JObject createSpan(jni.JObject rasterizer) => const jni.JObjectType() + .fromRef(_createSpan(reference, rasterizer.reference).object); +} + +class $EmojiCompat_DefaultSpanFactoryType + extends jni.JObjType { + const $EmojiCompat_DefaultSpanFactoryType(); + + @override + String get signature => + r"Landroidx/emoji2/text/EmojiCompat$DefaultSpanFactory;"; + + @override + EmojiCompat_DefaultSpanFactory fromRef(jni.JObjectPtr ref) => + EmojiCompat_DefaultSpanFactory.fromRef(ref); +} + +/// from: androidx.emoji2.text.EmojiCompat$SpanFactory +/// +/// Factory class that creates the EmojiSpans. +/// +/// By default it creates TypefaceEmojiSpan. +/// +/// Apps should use this only if they want to control the drawing of EmojiSpans for non-standard +/// emoji display (for example, resizing or repositioning emoji). +class EmojiCompat_SpanFactory extends jni.JObject { + late final jni.JObjType? _$type; + @override + jni.JObjType get $type => _$type ??= type; + + EmojiCompat_SpanFactory.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = $EmojiCompat_SpanFactoryType(); + static final _createSpan = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>>( + "EmojiCompat_SpanFactory__createSpan") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public abstract androidx.emoji2.text.EmojiSpan createSpan(androidx.emoji2.text.TypefaceEmojiRasterizer rasterizer) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Create EmojiSpan instance. + ///@param rasterizer TypefaceEmojiRasterizer instance, which can draw the emoji onto a + /// Canvas. + ///@return EmojiSpan instance that can use TypefaceEmojiRasterizer to draw emoji. + jni.JObject createSpan(jni.JObject rasterizer) => const jni.JObjectType() + .fromRef(_createSpan(reference, rasterizer.reference).object); +} + +class $EmojiCompat_SpanFactoryType + extends jni.JObjType { + const $EmojiCompat_SpanFactoryType(); + + @override + String get signature => r"Landroidx/emoji2/text/EmojiCompat$SpanFactory;"; + + @override + EmojiCompat_SpanFactory fromRef(jni.JObjectPtr ref) => + EmojiCompat_SpanFactory.fromRef(ref); +} + +/// from: androidx.emoji2.text.DefaultEmojiCompatConfig +/// +/// The default config will use downloadable fonts to fetch the emoji compat font file. +/// +/// It will automatically fetch the emoji compat font from a {@code ContentProvider} that is +/// installed on the devices system image, if present. +/// +/// +/// You should use this if you want the default emoji font from a system installed +/// downloadable fonts provider. This is the recommended behavior for all applications unless +/// they install a custom emoji font. +/// +/// +/// You may need to specialize the configuration beyond this default config in some +/// situations: +/// +///
    +///
  • If you are trying to install a custom emoji font through downloadable fonts use +/// FontRequestEmojiCompatConfig instead of this method.
  • +///
  • If you're trying to bundle an emoji font with your APK use {@code +/// BundledEmojiCompatConfig} in the {@code emoji2-bundled} artifact.
  • +///
  • If you are building an APK that will be installed on devices that won't have a +/// downloadable fonts provider, use {@code BundledEmojiCompatConfig}.
  • +///
+/// +/// The downloadable font provider used by {@code DefaultEmojiCompatConfig} always satisfies +/// the following contract: +/// +///
    +///
  1. It MUST provide an intent filter for {@code androidx.content.action.LOAD_EMOJI_FONT}. +///
  2. +///
  3. It MUST respond to the query {@code emojicompat-emoji-font} with a valid emoji compat +/// font file including metadata.
  4. +///
  5. It MUST provide fonts via the same contract as downloadable fonts.
  6. +///
  7. It MUST be installed in the system image.
  8. +///
+class DefaultEmojiCompatConfig extends jni.JObject { + late final jni.JObjType? _$type; + @override + jni.JObjType get $type => _$type ??= type; + + DefaultEmojiCompatConfig.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = $DefaultEmojiCompatConfigType(); + static final _create = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("DefaultEmojiCompatConfig__create") + .asFunction)>(); + + /// from: static public androidx.emoji2.text.FontRequestEmojiCompatConfig create(android.content.Context context) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Get the default emoji compat config for this device. + /// + /// You may further configure the returned config before passing it to EmojiCompat\#init. + /// + /// Each call to this method will return a new EmojiCompat.Config, so changes to the returned + /// object will not modify future return values. + ///@param context context for lookup + ///@return A valid config for downloading the emoji compat font, or null if no font provider + /// could be found. + static jni.JObject create(jni.JObject context) => + const jni.JObjectType().fromRef(_create(context.reference).object); +} + +class $DefaultEmojiCompatConfigType + extends jni.JObjType { + const $DefaultEmojiCompatConfigType(); + + @override + String get signature => r"Landroidx/emoji2/text/DefaultEmojiCompatConfig;"; + + @override + DefaultEmojiCompatConfig fromRef(jni.JObjectPtr ref) => + DefaultEmojiCompatConfig.fromRef(ref); +} + +/// from: androidx.emoji2.text.DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28 +/// +/// Helper to lookup signatures in package manager > API 28 +///@hide +class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28 + extends DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19 { + late final jni.JObjType? _$type; + @override + jni.JObjType get $type => _$type ??= type; + + DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = + $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28Type(); + static final _ctor = jniLookup>( + "DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__ctor") + .asFunction(); + + /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. + DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28() + : super.fromRef(_ctor().object); + + static final _getSigningSignatures1 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>( + "DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__getSigningSignatures1") + .asFunction< + jni.JniResult Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + /// from: public android.content.pm.Signature[] getSigningSignatures(android.content.pm.PackageManager packageManager, java.lang.String providerPackage) + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JArray getSigningSignatures1( + jni.JObject packageManager, jni.JString providerPackage) => + const jni.JArrayType(jni.JObjectType()).fromRef(_getSigningSignatures1( + reference, packageManager.reference, providerPackage.reference) + .object); +} + +class $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28Type + extends jni.JObjType< + DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28> { + const $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28Type(); + + @override + String get signature => + r"Landroidx/emoji2/text/DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28;"; + + @override + DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28 fromRef( + jni.JObjectPtr ref) => + DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28.fromRef( + ref); +} + +/// from: androidx.emoji2.text.DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19 +/// +/// Actually do lookups > API 19 +///@hide +class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19 + extends DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper { + late final jni.JObjType? _$type; + @override + jni.JObjType get $type => _$type ??= type; + + DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = + $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19Type(); + static final _ctor = jniLookup>( + "DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__ctor") + .asFunction(); + + /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. + DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19() + : super.fromRef(_ctor().object); + + static final _queryIntentContentProviders = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int32)>>( + "DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__queryIntentContentProviders") + .asFunction< + jni.JniResult Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, int)>(); + + /// from: public java.util.List queryIntentContentProviders(android.content.pm.PackageManager packageManager, android.content.Intent intent, int flags) + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JObject queryIntentContentProviders( + jni.JObject packageManager, jni.JObject intent, int flags) => + const jni.JObjectType().fromRef(_queryIntentContentProviders( + reference, packageManager.reference, intent.reference, flags) + .object); + + static final _getProviderInfo = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>>( + "DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__getProviderInfo") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public android.content.pm.ProviderInfo getProviderInfo(android.content.pm.ResolveInfo resolveInfo) + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JObject getProviderInfo(jni.JObject resolveInfo) => + const jni.JObjectType() + .fromRef(_getProviderInfo(reference, resolveInfo.reference).object); +} + +class $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19Type + extends jni.JObjType< + DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19> { + const $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19Type(); + + @override + String get signature => + r"Landroidx/emoji2/text/DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19;"; + + @override + DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19 fromRef( + jni.JObjectPtr ref) => + DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19.fromRef( + ref); +} + +/// from: androidx.emoji2.text.DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper +/// +/// Helper to lookup signatures in package manager. +///@hide +class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper + extends jni.JObject { + late final jni.JObjType? _$type; + @override + jni.JObjType get $type => _$type ??= type; + + DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = + $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelperType(); + static final _ctor = jniLookup>( + "DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__ctor") + .asFunction(); + + /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. + DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper() + : super.fromRef(_ctor().object); + + static final _getSigningSignatures = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>( + "DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__getSigningSignatures") + .asFunction< + jni.JniResult Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + /// from: public android.content.pm.Signature[] getSigningSignatures(android.content.pm.PackageManager packageManager, java.lang.String providerPackage) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Get the signing signatures for a package in package manager. + jni.JArray getSigningSignatures( + jni.JObject packageManager, jni.JString providerPackage) => + const jni.JArrayType(jni.JObjectType()).fromRef(_getSigningSignatures( + reference, packageManager.reference, providerPackage.reference) + .object); + + static final _queryIntentContentProviders = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int32)>>( + "DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__queryIntentContentProviders") + .asFunction< + jni.JniResult Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, int)>(); + + /// from: public java.util.List queryIntentContentProviders(android.content.pm.PackageManager packageManager, android.content.Intent intent, int flags) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Get the content provider by intent. + jni.JObject queryIntentContentProviders( + jni.JObject packageManager, jni.JObject intent, int flags) => + const jni.JObjectType().fromRef(_queryIntentContentProviders( + reference, packageManager.reference, intent.reference, flags) + .object); + + static final _getProviderInfo = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>>( + "DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__getProviderInfo") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public android.content.pm.ProviderInfo getProviderInfo(android.content.pm.ResolveInfo resolveInfo) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Get a ProviderInfo, if present, from a ResolveInfo + ///@param resolveInfo the subject + ///@return resolveInfo.providerInfo above API 19 + jni.JObject getProviderInfo(jni.JObject resolveInfo) => + const jni.JObjectType() + .fromRef(_getProviderInfo(reference, resolveInfo.reference).object); +} + +class $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelperType extends jni + .JObjType { + const $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelperType(); + + @override + String get signature => + r"Landroidx/emoji2/text/DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper;"; + + @override + DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper fromRef( + jni.JObjectPtr ref) => + DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper.fromRef(ref); +} + +/// from: androidx.emoji2.text.DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory +/// +/// Actual factory for generating default emoji configs, does service locator lookup internally. +///@see DefaultEmojiCompatConfig\#create +///@hide +class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory + extends jni.JObject { + late final jni.JObjType? _$type; + @override + jni.JObjType get $type => _$type ??= type; + + DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = + $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactoryType(); + static final _ctor = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>( + "DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__ctor") + .asFunction)>(); + + /// from: public void (androidx.emoji2.text.DefaultEmojiCompatConfig.DefaultEmojiCompatConfigHelper helper) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// @hide + DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory( + DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper helper) + : super.fromRef(_ctor(helper.reference).object); + + static final _create = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>>( + "DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__create") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public androidx.emoji2.text.EmojiCompat.Config create(android.content.Context context) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// @see DefaultEmojiCompatConfig\#create + ///@hide + EmojiCompat_Config create(jni.JObject context) => + const $EmojiCompat_ConfigType() + .fromRef(_create(reference, context.reference).object); +} + +class $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactoryType extends jni + .JObjType { + const $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactoryType(); + + @override + String get signature => + r"Landroidx/emoji2/text/DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory;"; + + @override + DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory fromRef( + jni.JObjectPtr ref) => + DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory.fromRef(ref); +} + /// from: android.os.Build class Build extends jni.JObject { late final jni.JObjType? _$type; diff --git a/pkgs/jnigen/example/in_app_java/lib/main.dart b/pkgs/jnigen/example/in_app_java/lib/main.dart index 61c9d2b17..f4354283a 100644 --- a/pkgs/jnigen/example/in_app_java/lib/main.dart +++ b/pkgs/jnigen/example/in_app_java/lib/main.dart @@ -10,15 +10,20 @@ import 'package:jni/jni.dart'; import 'android_utils.dart'; JObject activity = JObject.fromRef(Jni.getCurrentActivity()); +JObject context = JObject.fromRef(Jni.getCachedApplicationContext()); final hashmap = HashMap.ctor2(JString.type, JString.type); +final emojiCompat = EmojiCompat.get0(); + extension IntX on int { JString toJString() { return toString().toJString(); } } +const sunglassEmoji = "😎"; + /// Display device model number and the number of times this was called /// as Toast. void showToast() { @@ -26,12 +31,16 @@ void showToast() { hashmap.getOrDefault("toastCount".toJString(), 0.toJString()); final newToastCount = (int.parse(toastCount.toDartString()) + 1).toJString(); hashmap.put("toastCount".toJString(), newToastCount); + final emoji = emojiCompat.hasEmojiGlyph(sunglassEmoji.toJString()) + ? sunglassEmoji + : ':cool:'; final message = - '${newToastCount.toDartString()} - ${Build.MODEL.toDartString()}'; + '${newToastCount.toDartString()} - ${Build.MODEL.toDartString()} $emoji'; AndroidUtils.showToast(activity, message.toJString(), 0); } void main() { + EmojiCompat.init(context); runApp(const MyApp()); } diff --git a/pkgs/jnigen/example/in_app_java/src/android_utils/android_utils.c b/pkgs/jnigen/example/in_app_java/src/android_utils/android_utils.c index 1a1cb55cb..65bbd7b5b 100644 --- a/pkgs/jnigen/example/in_app_java/src/android_utils/android_utils.c +++ b/pkgs/jnigen/example/in_app_java/src/android_utils/android_utils.c @@ -37,6 +37,1351 @@ JniResult AndroidUtils__showToast(jobject mainActivity, return (JniResult){.result = {.j = 0}, .exception = check_exception()}; } +// androidx.emoji2.text.EmojiCompat +jclass _c_EmojiCompat = NULL; + +jmethodID _m_EmojiCompat__init = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat__init(jobject context) { + load_env(); + load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + if (_c_EmojiCompat == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_static_method( + _c_EmojiCompat, &_m_EmojiCompat__init, "init", + "(Landroid/content/Context;)Landroidx/emoji2/text/EmojiCompat;"); + if (_m_EmojiCompat__init == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallStaticObjectMethod( + jniEnv, _c_EmojiCompat, _m_EmojiCompat__init, context); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat__init1 = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat__init1(jobject context, jobject defaultFactory) { + load_env(); + load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + if (_c_EmojiCompat == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_EmojiCompat, &_m_EmojiCompat__init1, "init", + "(Landroid/content/Context;Landroidx/emoji2/text/" + "DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory;" + ")Landroidx/emoji2/text/EmojiCompat;"); + if (_m_EmojiCompat__init1 == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallStaticObjectMethod( + jniEnv, _c_EmojiCompat, _m_EmojiCompat__init1, context, defaultFactory); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat__init2 = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat__init2(jobject config) { + load_env(); + load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + if (_c_EmojiCompat == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_EmojiCompat, &_m_EmojiCompat__init2, "init", + "(Landroidx/emoji2/text/EmojiCompat$Config;)Landroidx/" + "emoji2/text/EmojiCompat;"); + if (_m_EmojiCompat__init2 == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallStaticObjectMethod( + jniEnv, _c_EmojiCompat, _m_EmojiCompat__init2, config); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat__isConfigured = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat__isConfigured() { + load_env(); + load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + if (_c_EmojiCompat == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_EmojiCompat, &_m_EmojiCompat__isConfigured, + "isConfigured", "()Z"); + if (_m_EmojiCompat__isConfigured == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + uint8_t _result = (*jniEnv)->CallStaticBooleanMethod( + jniEnv, _c_EmojiCompat, _m_EmojiCompat__isConfigured); + return (JniResult){.result = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat__reset = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat__reset(jobject config) { + load_env(); + load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + if (_c_EmojiCompat == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_EmojiCompat, &_m_EmojiCompat__reset, "reset", + "(Landroidx/emoji2/text/EmojiCompat$Config;)Landroidx/" + "emoji2/text/EmojiCompat;"); + if (_m_EmojiCompat__reset == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallStaticObjectMethod( + jniEnv, _c_EmojiCompat, _m_EmojiCompat__reset, config); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat__reset1 = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat__reset1(jobject emojiCompat) { + load_env(); + load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + if (_c_EmojiCompat == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_static_method( + _c_EmojiCompat, &_m_EmojiCompat__reset1, "reset", + "(Landroidx/emoji2/text/EmojiCompat;)Landroidx/emoji2/text/EmojiCompat;"); + if (_m_EmojiCompat__reset1 == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallStaticObjectMethod( + jniEnv, _c_EmojiCompat, _m_EmojiCompat__reset1, emojiCompat); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat__skipDefaultConfigurationLookup = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat__skipDefaultConfigurationLookup(uint8_t shouldSkip) { + load_env(); + load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + if (_c_EmojiCompat == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_EmojiCompat, + &_m_EmojiCompat__skipDefaultConfigurationLookup, + "skipDefaultConfigurationLookup", "(Z)V"); + if (_m_EmojiCompat__skipDefaultConfigurationLookup == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallStaticVoidMethod( + jniEnv, _c_EmojiCompat, _m_EmojiCompat__skipDefaultConfigurationLookup, + shouldSkip); + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat__get0 = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat__get0() { + load_env(); + load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + if (_c_EmojiCompat == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_EmojiCompat, &_m_EmojiCompat__get0, "get", + "()Landroidx/emoji2/text/EmojiCompat;"); + if (_m_EmojiCompat__get0 == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_EmojiCompat, + _m_EmojiCompat__get0); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat__load = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat__load(jobject self_) { + load_env(); + load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + if (_c_EmojiCompat == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat, &_m_EmojiCompat__load, "load", "()V"); + if (_m_EmojiCompat__load == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_EmojiCompat__load); + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat__registerInitCallback = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat__registerInitCallback(jobject self_, + jobject initCallback) { + load_env(); + load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + if (_c_EmojiCompat == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat, &_m_EmojiCompat__registerInitCallback, + "registerInitCallback", + "(Landroidx/emoji2/text/EmojiCompat$InitCallback;)V"); + if (_m_EmojiCompat__registerInitCallback == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_EmojiCompat__registerInitCallback, + initCallback); + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat__unregisterInitCallback = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat__unregisterInitCallback(jobject self_, + jobject initCallback) { + load_env(); + load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + if (_c_EmojiCompat == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat, &_m_EmojiCompat__unregisterInitCallback, + "unregisterInitCallback", + "(Landroidx/emoji2/text/EmojiCompat$InitCallback;)V"); + if (_m_EmojiCompat__unregisterInitCallback == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod( + jniEnv, self_, _m_EmojiCompat__unregisterInitCallback, initCallback); + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat__getLoadState = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat__getLoadState(jobject self_) { + load_env(); + load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + if (_c_EmojiCompat == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat, &_m_EmojiCompat__getLoadState, "getLoadState", + "()I"); + if (_m_EmojiCompat__getLoadState == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + int32_t _result = + (*jniEnv)->CallIntMethod(jniEnv, self_, _m_EmojiCompat__getLoadState); + return (JniResult){.result = {.i = _result}, .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat__isEmojiSpanIndicatorEnabled = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat__isEmojiSpanIndicatorEnabled(jobject self_) { + load_env(); + load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + if (_c_EmojiCompat == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat, &_m_EmojiCompat__isEmojiSpanIndicatorEnabled, + "isEmojiSpanIndicatorEnabled", "()Z"); + if (_m_EmojiCompat__isEmojiSpanIndicatorEnabled == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + uint8_t _result = (*jniEnv)->CallBooleanMethod( + jniEnv, self_, _m_EmojiCompat__isEmojiSpanIndicatorEnabled); + return (JniResult){.result = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat__getEmojiSpanIndicatorColor = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat__getEmojiSpanIndicatorColor(jobject self_) { + load_env(); + load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + if (_c_EmojiCompat == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat, &_m_EmojiCompat__getEmojiSpanIndicatorColor, + "getEmojiSpanIndicatorColor", "()I"); + if (_m_EmojiCompat__getEmojiSpanIndicatorColor == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + int32_t _result = (*jniEnv)->CallIntMethod( + jniEnv, self_, _m_EmojiCompat__getEmojiSpanIndicatorColor); + return (JniResult){.result = {.i = _result}, .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat__getEmojiStart = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat__getEmojiStart(jobject self_, + jobject charSequence, + int32_t offset) { + load_env(); + load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + if (_c_EmojiCompat == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat, &_m_EmojiCompat__getEmojiStart, "getEmojiStart", + "(Ljava/lang/CharSequence;I)I"); + if (_m_EmojiCompat__getEmojiStart == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + int32_t _result = (*jniEnv)->CallIntMethod( + jniEnv, self_, _m_EmojiCompat__getEmojiStart, charSequence, offset); + return (JniResult){.result = {.i = _result}, .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat__getEmojiEnd = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat__getEmojiEnd(jobject self_, + jobject charSequence, + int32_t offset) { + load_env(); + load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + if (_c_EmojiCompat == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat, &_m_EmojiCompat__getEmojiEnd, "getEmojiEnd", + "(Ljava/lang/CharSequence;I)I"); + if (_m_EmojiCompat__getEmojiEnd == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + int32_t _result = (*jniEnv)->CallIntMethod( + jniEnv, self_, _m_EmojiCompat__getEmojiEnd, charSequence, offset); + return (JniResult){.result = {.i = _result}, .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat__handleOnKeyDown = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat__handleOnKeyDown(jobject editable, + int32_t keyCode, + jobject event) { + load_env(); + load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + if (_c_EmojiCompat == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_EmojiCompat, &_m_EmojiCompat__handleOnKeyDown, + "handleOnKeyDown", + "(Landroid/text/Editable;ILandroid/view/KeyEvent;)Z"); + if (_m_EmojiCompat__handleOnKeyDown == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + uint8_t _result = (*jniEnv)->CallStaticBooleanMethod( + jniEnv, _c_EmojiCompat, _m_EmojiCompat__handleOnKeyDown, editable, + keyCode, event); + return (JniResult){.result = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat__handleDeleteSurroundingText = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat__handleDeleteSurroundingText(jobject inputConnection, + jobject editable, + int32_t beforeLength, + int32_t afterLength, + uint8_t inCodePoints) { + load_env(); + load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + if (_c_EmojiCompat == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_EmojiCompat, + &_m_EmojiCompat__handleDeleteSurroundingText, + "handleDeleteSurroundingText", + "(Landroid/view/inputmethod/InputConnection;Landroid/text/" + "Editable;IIZ)Z"); + if (_m_EmojiCompat__handleDeleteSurroundingText == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + uint8_t _result = (*jniEnv)->CallStaticBooleanMethod( + jniEnv, _c_EmojiCompat, _m_EmojiCompat__handleDeleteSurroundingText, + inputConnection, editable, beforeLength, afterLength, inCodePoints); + return (JniResult){.result = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat__hasEmojiGlyph = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat__hasEmojiGlyph(jobject self_, jobject sequence) { + load_env(); + load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + if (_c_EmojiCompat == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat, &_m_EmojiCompat__hasEmojiGlyph, "hasEmojiGlyph", + "(Ljava/lang/CharSequence;)Z"); + if (_m_EmojiCompat__hasEmojiGlyph == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + uint8_t _result = (*jniEnv)->CallBooleanMethod( + jniEnv, self_, _m_EmojiCompat__hasEmojiGlyph, sequence); + return (JniResult){.result = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat__hasEmojiGlyph1 = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat__hasEmojiGlyph1(jobject self_, + jobject sequence, + int32_t metadataVersion) { + load_env(); + load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + if (_c_EmojiCompat == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat, &_m_EmojiCompat__hasEmojiGlyph1, "hasEmojiGlyph", + "(Ljava/lang/CharSequence;I)Z"); + if (_m_EmojiCompat__hasEmojiGlyph1 == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + uint8_t _result = (*jniEnv)->CallBooleanMethod( + jniEnv, self_, _m_EmojiCompat__hasEmojiGlyph1, sequence, metadataVersion); + return (JniResult){.result = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat__getEmojiMatch = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat__getEmojiMatch(jobject self_, + jobject sequence, + int32_t metadataVersion) { + load_env(); + load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + if (_c_EmojiCompat == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat, &_m_EmojiCompat__getEmojiMatch, "getEmojiMatch", + "(Ljava/lang/CharSequence;I)I"); + if (_m_EmojiCompat__getEmojiMatch == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + int32_t _result = (*jniEnv)->CallIntMethod( + jniEnv, self_, _m_EmojiCompat__getEmojiMatch, sequence, metadataVersion); + return (JniResult){.result = {.i = _result}, .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat__process = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat__process(jobject self_, jobject charSequence) { + load_env(); + load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + if (_c_EmojiCompat == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat, &_m_EmojiCompat__process, "process", + "(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;"); + if (_m_EmojiCompat__process == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_EmojiCompat__process, charSequence); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat__process1 = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat__process1(jobject self_, + jobject charSequence, + int32_t start, + int32_t end) { + load_env(); + load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + if (_c_EmojiCompat == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat, &_m_EmojiCompat__process1, "process", + "(Ljava/lang/CharSequence;II)Ljava/lang/CharSequence;"); + if (_m_EmojiCompat__process1 == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_EmojiCompat__process1, charSequence, start, end); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat__process2 = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat__process2(jobject self_, + jobject charSequence, + int32_t start, + int32_t end, + int32_t maxEmojiCount) { + load_env(); + load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + if (_c_EmojiCompat == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat, &_m_EmojiCompat__process2, "process", + "(Ljava/lang/CharSequence;III)Ljava/lang/CharSequence;"); + if (_m_EmojiCompat__process2 == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_EmojiCompat__process2, + charSequence, start, end, maxEmojiCount); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat__process3 = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat__process3(jobject self_, + jobject charSequence, + int32_t start, + int32_t end, + int32_t maxEmojiCount, + int32_t replaceStrategy) { + load_env(); + load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + if (_c_EmojiCompat == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat, &_m_EmojiCompat__process3, "process", + "(Ljava/lang/CharSequence;IIII)Ljava/lang/CharSequence;"); + if (_m_EmojiCompat__process3 == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_EmojiCompat__process3, charSequence, start, end, + maxEmojiCount, replaceStrategy); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat__getAssetSignature = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat__getAssetSignature(jobject self_) { + load_env(); + load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + if (_c_EmojiCompat == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat, &_m_EmojiCompat__getAssetSignature, + "getAssetSignature", "()Ljava/lang/String;"); + if (_m_EmojiCompat__getAssetSignature == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_EmojiCompat__getAssetSignature); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat__updateEditorInfo = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat__updateEditorInfo(jobject self_, jobject outAttrs) { + load_env(); + load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + if (_c_EmojiCompat == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat, &_m_EmojiCompat__updateEditorInfo, + "updateEditorInfo", "(Landroid/view/inputmethod/EditorInfo;)V"); + if (_m_EmojiCompat__updateEditorInfo == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_EmojiCompat__updateEditorInfo, + outAttrs); + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; +} + +// androidx.emoji2.text.EmojiCompat$Config +jclass _c_EmojiCompat_Config = NULL; + +jmethodID _m_EmojiCompat_Config__ctor = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat_Config__ctor(jobject metadataLoader) { + load_env(); + load_class_gr(&_c_EmojiCompat_Config, + "androidx/emoji2/text/EmojiCompat$Config"); + if (_c_EmojiCompat_Config == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat_Config, &_m_EmojiCompat_Config__ctor, "", + "(Landroidx/emoji2/text/EmojiCompat$MetadataRepoLoader;)V"); + if (_m_EmojiCompat_Config__ctor == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->NewObject(jniEnv, _c_EmojiCompat_Config, + _m_EmojiCompat_Config__ctor, metadataLoader); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat_Config__registerInitCallback = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat_Config__registerInitCallback(jobject self_, + jobject initCallback) { + load_env(); + load_class_gr(&_c_EmojiCompat_Config, + "androidx/emoji2/text/EmojiCompat$Config"); + if (_c_EmojiCompat_Config == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat_Config, + &_m_EmojiCompat_Config__registerInitCallback, + "registerInitCallback", + "(Landroidx/emoji2/text/EmojiCompat$InitCallback;)Landroidx/" + "emoji2/text/EmojiCompat$Config;"); + if (_m_EmojiCompat_Config__registerInitCallback == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_EmojiCompat_Config__registerInitCallback, initCallback); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat_Config__unregisterInitCallback = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat_Config__unregisterInitCallback(jobject self_, + jobject initCallback) { + load_env(); + load_class_gr(&_c_EmojiCompat_Config, + "androidx/emoji2/text/EmojiCompat$Config"); + if (_c_EmojiCompat_Config == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat_Config, + &_m_EmojiCompat_Config__unregisterInitCallback, + "unregisterInitCallback", + "(Landroidx/emoji2/text/EmojiCompat$InitCallback;)Landroidx/" + "emoji2/text/EmojiCompat$Config;"); + if (_m_EmojiCompat_Config__unregisterInitCallback == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_EmojiCompat_Config__unregisterInitCallback, + initCallback); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat_Config__setReplaceAll = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat_Config__setReplaceAll(jobject self_, uint8_t replaceAll) { + load_env(); + load_class_gr(&_c_EmojiCompat_Config, + "androidx/emoji2/text/EmojiCompat$Config"); + if (_c_EmojiCompat_Config == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat_Config, &_m_EmojiCompat_Config__setReplaceAll, + "setReplaceAll", "(Z)Landroidx/emoji2/text/EmojiCompat$Config;"); + if (_m_EmojiCompat_Config__setReplaceAll == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_EmojiCompat_Config__setReplaceAll, replaceAll); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat_Config__setUseEmojiAsDefaultStyle = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat_Config__setUseEmojiAsDefaultStyle( + jobject self_, + uint8_t useEmojiAsDefaultStyle) { + load_env(); + load_class_gr(&_c_EmojiCompat_Config, + "androidx/emoji2/text/EmojiCompat$Config"); + if (_c_EmojiCompat_Config == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat_Config, + &_m_EmojiCompat_Config__setUseEmojiAsDefaultStyle, + "setUseEmojiAsDefaultStyle", + "(Z)Landroidx/emoji2/text/EmojiCompat$Config;"); + if (_m_EmojiCompat_Config__setUseEmojiAsDefaultStyle == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_EmojiCompat_Config__setUseEmojiAsDefaultStyle, + useEmojiAsDefaultStyle); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat_Config__setUseEmojiAsDefaultStyle1 = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat_Config__setUseEmojiAsDefaultStyle1( + jobject self_, + uint8_t useEmojiAsDefaultStyle, + jobject emojiAsDefaultStyleExceptions) { + load_env(); + load_class_gr(&_c_EmojiCompat_Config, + "androidx/emoji2/text/EmojiCompat$Config"); + if (_c_EmojiCompat_Config == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat_Config, + &_m_EmojiCompat_Config__setUseEmojiAsDefaultStyle1, + "setUseEmojiAsDefaultStyle", + "(ZLjava/util/List;)Landroidx/emoji2/text/EmojiCompat$Config;"); + if (_m_EmojiCompat_Config__setUseEmojiAsDefaultStyle1 == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_EmojiCompat_Config__setUseEmojiAsDefaultStyle1, + useEmojiAsDefaultStyle, emojiAsDefaultStyleExceptions); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat_Config__setEmojiSpanIndicatorEnabled = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat_Config__setEmojiSpanIndicatorEnabled( + jobject self_, + uint8_t emojiSpanIndicatorEnabled) { + load_env(); + load_class_gr(&_c_EmojiCompat_Config, + "androidx/emoji2/text/EmojiCompat$Config"); + if (_c_EmojiCompat_Config == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat_Config, + &_m_EmojiCompat_Config__setEmojiSpanIndicatorEnabled, + "setEmojiSpanIndicatorEnabled", + "(Z)Landroidx/emoji2/text/EmojiCompat$Config;"); + if (_m_EmojiCompat_Config__setEmojiSpanIndicatorEnabled == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_EmojiCompat_Config__setEmojiSpanIndicatorEnabled, + emojiSpanIndicatorEnabled); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat_Config__setEmojiSpanIndicatorColor = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat_Config__setEmojiSpanIndicatorColor(jobject self_, + int32_t color) { + load_env(); + load_class_gr(&_c_EmojiCompat_Config, + "androidx/emoji2/text/EmojiCompat$Config"); + if (_c_EmojiCompat_Config == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat_Config, + &_m_EmojiCompat_Config__setEmojiSpanIndicatorColor, + "setEmojiSpanIndicatorColor", + "(I)Landroidx/emoji2/text/EmojiCompat$Config;"); + if (_m_EmojiCompat_Config__setEmojiSpanIndicatorColor == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_EmojiCompat_Config__setEmojiSpanIndicatorColor, color); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat_Config__setMetadataLoadStrategy = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat_Config__setMetadataLoadStrategy(jobject self_, + int32_t strategy) { + load_env(); + load_class_gr(&_c_EmojiCompat_Config, + "androidx/emoji2/text/EmojiCompat$Config"); + if (_c_EmojiCompat_Config == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat_Config, + &_m_EmojiCompat_Config__setMetadataLoadStrategy, + "setMetadataLoadStrategy", + "(I)Landroidx/emoji2/text/EmojiCompat$Config;"); + if (_m_EmojiCompat_Config__setMetadataLoadStrategy == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_EmojiCompat_Config__setMetadataLoadStrategy, strategy); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat_Config__setSpanFactory = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat_Config__setSpanFactory(jobject self_, jobject factory) { + load_env(); + load_class_gr(&_c_EmojiCompat_Config, + "androidx/emoji2/text/EmojiCompat$Config"); + if (_c_EmojiCompat_Config == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat_Config, &_m_EmojiCompat_Config__setSpanFactory, + "setSpanFactory", + "(Landroidx/emoji2/text/EmojiCompat$SpanFactory;)Landroidx/" + "emoji2/text/EmojiCompat$Config;"); + if (_m_EmojiCompat_Config__setSpanFactory == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_EmojiCompat_Config__setSpanFactory, factory); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat_Config__setGlyphChecker = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat_Config__setGlyphChecker(jobject self_, + jobject glyphChecker) { + load_env(); + load_class_gr(&_c_EmojiCompat_Config, + "androidx/emoji2/text/EmojiCompat$Config"); + if (_c_EmojiCompat_Config == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat_Config, &_m_EmojiCompat_Config__setGlyphChecker, + "setGlyphChecker", + "(Landroidx/emoji2/text/EmojiCompat$GlyphChecker;)Landroidx/" + "emoji2/text/EmojiCompat$Config;"); + if (_m_EmojiCompat_Config__setGlyphChecker == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_EmojiCompat_Config__setGlyphChecker, glyphChecker); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat_Config__getMetadataRepoLoader = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat_Config__getMetadataRepoLoader(jobject self_) { + load_env(); + load_class_gr(&_c_EmojiCompat_Config, + "androidx/emoji2/text/EmojiCompat$Config"); + if (_c_EmojiCompat_Config == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat_Config, + &_m_EmojiCompat_Config__getMetadataRepoLoader, + "getMetadataRepoLoader", + "()Landroidx/emoji2/text/EmojiCompat$MetadataRepoLoader;"); + if (_m_EmojiCompat_Config__getMetadataRepoLoader == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_EmojiCompat_Config__getMetadataRepoLoader); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +// androidx.emoji2.text.EmojiCompat$MetadataRepoLoaderCallback +jclass _c_EmojiCompat_MetadataRepoLoaderCallback = NULL; + +jmethodID _m_EmojiCompat_MetadataRepoLoaderCallback__ctor = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat_MetadataRepoLoaderCallback__ctor() { + load_env(); + load_class_gr(&_c_EmojiCompat_MetadataRepoLoaderCallback, + "androidx/emoji2/text/EmojiCompat$MetadataRepoLoaderCallback"); + if (_c_EmojiCompat_MetadataRepoLoaderCallback == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat_MetadataRepoLoaderCallback, + &_m_EmojiCompat_MetadataRepoLoaderCallback__ctor, "", + "()V"); + if (_m_EmojiCompat_MetadataRepoLoaderCallback__ctor == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->NewObject(jniEnv, _c_EmojiCompat_MetadataRepoLoaderCallback, + _m_EmojiCompat_MetadataRepoLoaderCallback__ctor); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat_MetadataRepoLoaderCallback__onLoaded = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat_MetadataRepoLoaderCallback__onLoaded( + jobject self_, + jobject metadataRepo) { + load_env(); + load_class_gr(&_c_EmojiCompat_MetadataRepoLoaderCallback, + "androidx/emoji2/text/EmojiCompat$MetadataRepoLoaderCallback"); + if (_c_EmojiCompat_MetadataRepoLoaderCallback == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat_MetadataRepoLoaderCallback, + &_m_EmojiCompat_MetadataRepoLoaderCallback__onLoaded, "onLoaded", + "(Landroidx/emoji2/text/MetadataRepo;)V"); + if (_m_EmojiCompat_MetadataRepoLoaderCallback__onLoaded == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod(jniEnv, self_, + _m_EmojiCompat_MetadataRepoLoaderCallback__onLoaded, + metadataRepo); + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat_MetadataRepoLoaderCallback__onFailed = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat_MetadataRepoLoaderCallback__onFailed(jobject self_, + jobject throwable) { + load_env(); + load_class_gr(&_c_EmojiCompat_MetadataRepoLoaderCallback, + "androidx/emoji2/text/EmojiCompat$MetadataRepoLoaderCallback"); + if (_c_EmojiCompat_MetadataRepoLoaderCallback == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat_MetadataRepoLoaderCallback, + &_m_EmojiCompat_MetadataRepoLoaderCallback__onFailed, "onFailed", + "(Ljava/lang/Throwable;)V"); + if (_m_EmojiCompat_MetadataRepoLoaderCallback__onFailed == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod(jniEnv, self_, + _m_EmojiCompat_MetadataRepoLoaderCallback__onFailed, + throwable); + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; +} + +// androidx.emoji2.text.EmojiCompat$GlyphChecker +jclass _c_EmojiCompat_GlyphChecker = NULL; + +jmethodID _m_EmojiCompat_GlyphChecker__hasGlyph = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat_GlyphChecker__hasGlyph(jobject self_, + jobject charSequence, + int32_t start, + int32_t end, + int32_t sdkAdded) { + load_env(); + load_class_gr(&_c_EmojiCompat_GlyphChecker, + "androidx/emoji2/text/EmojiCompat$GlyphChecker"); + if (_c_EmojiCompat_GlyphChecker == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat_GlyphChecker, + &_m_EmojiCompat_GlyphChecker__hasGlyph, "hasGlyph", + "(Ljava/lang/CharSequence;III)Z"); + if (_m_EmojiCompat_GlyphChecker__hasGlyph == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + uint8_t _result = (*jniEnv)->CallBooleanMethod( + jniEnv, self_, _m_EmojiCompat_GlyphChecker__hasGlyph, charSequence, start, + end, sdkAdded); + return (JniResult){.result = {.z = _result}, .exception = check_exception()}; +} + +// androidx.emoji2.text.EmojiCompat$MetadataRepoLoader +jclass _c_EmojiCompat_MetadataRepoLoader = NULL; + +jmethodID _m_EmojiCompat_MetadataRepoLoader__load = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat_MetadataRepoLoader__load(jobject self_, + jobject loaderCallback) { + load_env(); + load_class_gr(&_c_EmojiCompat_MetadataRepoLoader, + "androidx/emoji2/text/EmojiCompat$MetadataRepoLoader"); + if (_c_EmojiCompat_MetadataRepoLoader == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method( + _c_EmojiCompat_MetadataRepoLoader, + &_m_EmojiCompat_MetadataRepoLoader__load, "load", + "(Landroidx/emoji2/text/EmojiCompat$MetadataRepoLoaderCallback;)V"); + if (_m_EmojiCompat_MetadataRepoLoader__load == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod( + jniEnv, self_, _m_EmojiCompat_MetadataRepoLoader__load, loaderCallback); + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; +} + +// androidx.emoji2.text.EmojiCompat$InitCallback +jclass _c_EmojiCompat_InitCallback = NULL; + +jmethodID _m_EmojiCompat_InitCallback__ctor = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat_InitCallback__ctor() { + load_env(); + load_class_gr(&_c_EmojiCompat_InitCallback, + "androidx/emoji2/text/EmojiCompat$InitCallback"); + if (_c_EmojiCompat_InitCallback == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat_InitCallback, &_m_EmojiCompat_InitCallback__ctor, + "", "()V"); + if (_m_EmojiCompat_InitCallback__ctor == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_EmojiCompat_InitCallback, + _m_EmojiCompat_InitCallback__ctor); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat_InitCallback__onInitialized = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat_InitCallback__onInitialized(jobject self_) { + load_env(); + load_class_gr(&_c_EmojiCompat_InitCallback, + "androidx/emoji2/text/EmojiCompat$InitCallback"); + if (_c_EmojiCompat_InitCallback == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat_InitCallback, + &_m_EmojiCompat_InitCallback__onInitialized, "onInitialized", + "()V"); + if (_m_EmojiCompat_InitCallback__onInitialized == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod(jniEnv, self_, + _m_EmojiCompat_InitCallback__onInitialized); + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat_InitCallback__onFailed = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat_InitCallback__onFailed(jobject self_, jobject throwable) { + load_env(); + load_class_gr(&_c_EmojiCompat_InitCallback, + "androidx/emoji2/text/EmojiCompat$InitCallback"); + if (_c_EmojiCompat_InitCallback == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat_InitCallback, + &_m_EmojiCompat_InitCallback__onFailed, "onFailed", + "(Ljava/lang/Throwable;)V"); + if (_m_EmojiCompat_InitCallback__onFailed == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod(jniEnv, self_, + _m_EmojiCompat_InitCallback__onFailed, throwable); + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; +} + +// androidx.emoji2.text.EmojiCompat$DefaultSpanFactory +jclass _c_EmojiCompat_DefaultSpanFactory = NULL; + +jmethodID _m_EmojiCompat_DefaultSpanFactory__ctor = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat_DefaultSpanFactory__ctor() { + load_env(); + load_class_gr(&_c_EmojiCompat_DefaultSpanFactory, + "androidx/emoji2/text/EmojiCompat$DefaultSpanFactory"); + if (_c_EmojiCompat_DefaultSpanFactory == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat_DefaultSpanFactory, + &_m_EmojiCompat_DefaultSpanFactory__ctor, "", "()V"); + if (_m_EmojiCompat_DefaultSpanFactory__ctor == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->NewObject(jniEnv, _c_EmojiCompat_DefaultSpanFactory, + _m_EmojiCompat_DefaultSpanFactory__ctor); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID _m_EmojiCompat_DefaultSpanFactory__createSpan = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat_DefaultSpanFactory__createSpan(jobject self_, + jobject rasterizer) { + load_env(); + load_class_gr(&_c_EmojiCompat_DefaultSpanFactory, + "androidx/emoji2/text/EmojiCompat$DefaultSpanFactory"); + if (_c_EmojiCompat_DefaultSpanFactory == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat_DefaultSpanFactory, + &_m_EmojiCompat_DefaultSpanFactory__createSpan, "createSpan", + "(Landroidx/emoji2/text/TypefaceEmojiRasterizer;)Landroidx/" + "emoji2/text/EmojiSpan;"); + if (_m_EmojiCompat_DefaultSpanFactory__createSpan == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_EmojiCompat_DefaultSpanFactory__createSpan, rasterizer); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +// androidx.emoji2.text.EmojiCompat$SpanFactory +jclass _c_EmojiCompat_SpanFactory = NULL; + +jmethodID _m_EmojiCompat_SpanFactory__createSpan = NULL; +FFI_PLUGIN_EXPORT +JniResult EmojiCompat_SpanFactory__createSpan(jobject self_, + jobject rasterizer) { + load_env(); + load_class_gr(&_c_EmojiCompat_SpanFactory, + "androidx/emoji2/text/EmojiCompat$SpanFactory"); + if (_c_EmojiCompat_SpanFactory == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_EmojiCompat_SpanFactory, + &_m_EmojiCompat_SpanFactory__createSpan, "createSpan", + "(Landroidx/emoji2/text/TypefaceEmojiRasterizer;)Landroidx/" + "emoji2/text/EmojiSpan;"); + if (_m_EmojiCompat_SpanFactory__createSpan == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_EmojiCompat_SpanFactory__createSpan, rasterizer); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +// androidx.emoji2.text.DefaultEmojiCompatConfig +jclass _c_DefaultEmojiCompatConfig = NULL; + +jmethodID _m_DefaultEmojiCompatConfig__create = NULL; +FFI_PLUGIN_EXPORT +JniResult DefaultEmojiCompatConfig__create(jobject context) { + load_env(); + load_class_gr(&_c_DefaultEmojiCompatConfig, + "androidx/emoji2/text/DefaultEmojiCompatConfig"); + if (_c_DefaultEmojiCompatConfig == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_DefaultEmojiCompatConfig, + &_m_DefaultEmojiCompatConfig__create, "create", + "(Landroid/content/Context;)Landroidx/emoji2/text/" + "FontRequestEmojiCompatConfig;"); + if (_m_DefaultEmojiCompatConfig__create == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallStaticObjectMethod( + jniEnv, _c_DefaultEmojiCompatConfig, _m_DefaultEmojiCompatConfig__create, + context); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +// androidx.emoji2.text.DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28 +jclass _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28 = NULL; + +jmethodID + _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__ctor = + NULL; +FFI_PLUGIN_EXPORT +JniResult +DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__ctor() { + load_env(); + load_class_gr( + &_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28, + "androidx/emoji2/text/" + "DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28"); + if (_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28 == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method( + _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28, + &_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__ctor, + "", "()V"); + if (_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__ctor == + NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->NewObject( + jniEnv, _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28, + _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__ctor); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID + _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__getSigningSignatures1 = + NULL; +FFI_PLUGIN_EXPORT +JniResult +DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__getSigningSignatures1( + jobject self_, + jobject packageManager, + jobject providerPackage) { + load_env(); + load_class_gr( + &_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28, + "androidx/emoji2/text/" + "DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28"); + if (_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28 == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method( + _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28, + &_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__getSigningSignatures1, + "getSigningSignatures", + "(Landroid/content/pm/PackageManager;Ljava/lang/String;)[Landroid/" + "content/pm/Signature;"); + if (_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__getSigningSignatures1 == + NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, + _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__getSigningSignatures1, + packageManager, providerPackage); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +// androidx.emoji2.text.DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19 +jclass _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19 = NULL; + +jmethodID + _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__ctor = + NULL; +FFI_PLUGIN_EXPORT +JniResult +DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__ctor() { + load_env(); + load_class_gr( + &_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19, + "androidx/emoji2/text/" + "DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19"); + if (_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19 == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method( + _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19, + &_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__ctor, + "", "()V"); + if (_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__ctor == + NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->NewObject( + jniEnv, _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19, + _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__ctor); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID + _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__queryIntentContentProviders = + NULL; +FFI_PLUGIN_EXPORT +JniResult +DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__queryIntentContentProviders( + jobject self_, + jobject packageManager, + jobject intent, + int32_t flags) { + load_env(); + load_class_gr( + &_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19, + "androidx/emoji2/text/" + "DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19"); + if (_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19 == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method( + _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19, + &_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__queryIntentContentProviders, + "queryIntentContentProviders", + "(Landroid/content/pm/PackageManager;Landroid/content/Intent;I)Ljava/" + "util/List;"); + if (_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__queryIntentContentProviders == + NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, + _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__queryIntentContentProviders, + packageManager, intent, flags); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID + _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__getProviderInfo = + NULL; +FFI_PLUGIN_EXPORT +JniResult +DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__getProviderInfo( + jobject self_, + jobject resolveInfo) { + load_env(); + load_class_gr( + &_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19, + "androidx/emoji2/text/" + "DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19"); + if (_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19 == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method( + _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19, + &_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__getProviderInfo, + "getProviderInfo", + "(Landroid/content/pm/ResolveInfo;)Landroid/content/pm/ProviderInfo;"); + if (_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__getProviderInfo == + NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, + _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__getProviderInfo, + resolveInfo); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +// androidx.emoji2.text.DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper +jclass _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper = NULL; + +jmethodID _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__ctor = + NULL; +FFI_PLUGIN_EXPORT +JniResult DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__ctor() { + load_env(); + load_class_gr(&_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper, + "androidx/emoji2/text/" + "DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper"); + if (_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper, + &_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__ctor, + "", "()V"); + if (_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__ctor == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->NewObject( + jniEnv, _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper, + _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__ctor); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID + _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__getSigningSignatures = + NULL; +FFI_PLUGIN_EXPORT +JniResult +DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__getSigningSignatures( + jobject self_, + jobject packageManager, + jobject providerPackage) { + load_env(); + load_class_gr(&_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper, + "androidx/emoji2/text/" + "DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper"); + if (_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method( + _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper, + &_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__getSigningSignatures, + "getSigningSignatures", + "(Landroid/content/pm/PackageManager;Ljava/lang/String;)[Landroid/" + "content/pm/Signature;"); + if (_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__getSigningSignatures == + NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, + _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__getSigningSignatures, + packageManager, providerPackage); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID + _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__queryIntentContentProviders = + NULL; +FFI_PLUGIN_EXPORT +JniResult +DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__queryIntentContentProviders( + jobject self_, + jobject packageManager, + jobject intent, + int32_t flags) { + load_env(); + load_class_gr(&_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper, + "androidx/emoji2/text/" + "DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper"); + if (_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method( + _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper, + &_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__queryIntentContentProviders, + "queryIntentContentProviders", + "(Landroid/content/pm/PackageManager;Landroid/content/Intent;I)Ljava/" + "util/List;"); + if (_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__queryIntentContentProviders == + NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, + _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__queryIntentContentProviders, + packageManager, intent, flags); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID + _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__getProviderInfo = + NULL; +FFI_PLUGIN_EXPORT +JniResult +DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__getProviderInfo( + jobject self_, + jobject resolveInfo) { + load_env(); + load_class_gr(&_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper, + "androidx/emoji2/text/" + "DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper"); + if (_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method( + _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper, + &_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__getProviderInfo, + "getProviderInfo", + "(Landroid/content/pm/ResolveInfo;)Landroid/content/pm/ProviderInfo;"); + if (_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__getProviderInfo == + NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, + _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__getProviderInfo, + resolveInfo); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +// androidx.emoji2.text.DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory +jclass _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory = NULL; + +jmethodID _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__ctor = + NULL; +FFI_PLUGIN_EXPORT +JniResult DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__ctor( + jobject helper) { + load_env(); + load_class_gr(&_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory, + "androidx/emoji2/text/" + "DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory"); + if (_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method( + _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory, + &_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__ctor, + "", + "(Landroidx/emoji2/text/" + "DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper;)V"); + if (_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__ctor == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->NewObject( + jniEnv, _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory, + _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__ctor, + helper); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__create = + NULL; +FFI_PLUGIN_EXPORT +JniResult DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__create( + jobject self_, + jobject context) { + load_env(); + load_class_gr(&_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory, + "androidx/emoji2/text/" + "DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory"); + if (_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method( + _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory, + &_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__create, + "create", + "(Landroid/content/Context;)Landroidx/emoji2/text/EmojiCompat$Config;"); + if (_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__create == + NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, + _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__create, + context); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + // android.os.Build jclass _c_Build = NULL; diff --git a/pkgs/jnigen/lib/src/config/config_types.dart b/pkgs/jnigen/lib/src/config/config_types.dart index 48d6ee072..39c198fd2 100644 --- a/pkgs/jnigen/lib/src/config/config_types.dart +++ b/pkgs/jnigen/lib/src/config/config_types.dart @@ -49,8 +49,8 @@ class MavenDownloads { /// `clean` task was run either through flutter or gradle wrapper. In such case, /// it's required to run `flutter build apk` & retry running `jnigen`. /// -/// A configuration is invalid if [versions] is unspecified or empty, and -/// [addGradleDeps] is also false. If [sdkRoot] is not specified but versions is +/// A configuration is invalid if [versions] is unspecified or empty, and gradle +/// options are also false. If [sdkRoot] is not specified but versions is /// specified, an attempt is made to find out SDK installation directory using /// environment variable `ANDROID_SDK_ROOT` if it's defined, else an error /// will be thrown. @@ -59,13 +59,14 @@ class AndroidSdkConfig { this.versions, this.sdkRoot, this.addGradleDeps = false, + this.addGradleSources = false, this.androidExample, }) { if (versions != null && sdkRoot == null) { throw ConfigException("No SDK Root specified for finding Android SDK " "from version priority list $versions"); } - if (versions == null && !addGradleDeps) { + if (versions == null && !addGradleDeps && !addGradleSources) { throw ConfigException('Neither any SDK versions nor `addGradleDeps` ' 'is specified. Unable to find Android libraries.'); } @@ -92,6 +93,14 @@ class AndroidSdkConfig { /// that case. bool addGradleDeps; + /// Similar to [addGradleDeps], runs a stub to obtain source dependencies of + /// the Android project. + /// + /// This may cause additional source JAR artifacts to be downloaded. Like the + /// [addGradleDeps] option, plugins cannot be built so an example should be + /// specified. + bool addGradleSources; + /// Relative path to example application which will be used to determine /// compile time classpath using a gradle stub. For most Android plugin /// packages, 'example' will be the name of example application created inside @@ -430,6 +439,7 @@ class Config { .toList(), sdkRoot: getSdkRoot(), addGradleDeps: prov.getBool(_Props.addGradleDeps) ?? false, + addGradleSources: prov.getBool(_Props.addGradleSources) ?? false, // Leaving this as getString instead of getPath, because // it's resolved later in android_sdk_tools. androidExample: prov.getString(_Props.androidExample), @@ -499,5 +509,6 @@ class _Props { static const androidSdkRoot = '$androidSdkConfig.sdk_root'; static const androidSdkVersions = '$androidSdkConfig.versions'; static const addGradleDeps = '$androidSdkConfig.add_gradle_deps'; + static const addGradleSources = '$androidSdkConfig.add_gradle_sources'; static const androidExample = '$androidSdkConfig.android_example'; } diff --git a/pkgs/jnigen/lib/src/summary/summary.dart b/pkgs/jnigen/lib/src/summary/summary.dart index 29e50b737..a2f600e34 100644 --- a/pkgs/jnigen/lib/src/summary/summary.dart +++ b/pkgs/jnigen/lib/src/summary/summary.dart @@ -131,6 +131,13 @@ Future getSummary(Config config) async { ); extraJars.addAll(deps.map(Uri.file)); } + if (androidConfig != null && androidConfig.addGradleSources) { + final deps = AndroidSdkTools.getGradleSources( + configRoot: config.configRoot, + androidProject: androidConfig.androidExample ?? '.', + ); + extraSources.addAll(deps.map(Uri.file)); + } if (androidConfig != null && androidConfig.versions != null) { final versions = androidConfig.versions!; final androidSdkRoot = diff --git a/pkgs/jnigen/lib/src/tools/android_sdk_tools.dart b/pkgs/jnigen/lib/src/tools/android_sdk_tools.dart index 48fe3b4ae..a3f53a325 100644 --- a/pkgs/jnigen/lib/src/tools/android_sdk_tools.dart +++ b/pkgs/jnigen/lib/src/tools/android_sdk_tools.dart @@ -58,23 +58,75 @@ class AndroidSdkTools { return null; } + static const _gradleCannotFindJars = 'Gradle stub cannot find JAR libraries. ' + 'This might be because no APK build has happened yet.'; + + static const _leftOverStubWarning = 'If you are seeing this error in ' + '`flutter build` output, it is likely that `jnigen` left some stubs in ' + 'the build.gradle file. Please restore that file from your version ' + 'control system or manually remove the stub functions named ' + '$_gradleGetClasspathTaskName and / or $_gradleGetSourcesTaskName.'; + static Future getAndroidJarPath( {required String sdkRoot, required List versionOrder}) async => await _getFile(sdkRoot, 'platforms', versionOrder, 'android.jar'); - static const _gradleListDepsFunction = ''' -task listDependencies(type: Copy) { + static const _gradleGetClasspathTaskName = 'getReleaseCompileClasspath'; + + static const _gradleGetClasspathStub = ''' +// Gradle stub for listing dependencies in jnigen. If found in +// android/build.gradle, please delete the following function. +task $_gradleGetClasspathTaskName(type: Copy) { project.afterEvaluate { - def app = project(':app') - def android = app.android - def cp = [android.getBootClasspath()[0]] - android.applicationVariants.each { variant -> - if (variant.name.equals('release')) { - cp += variant.javaCompile.classpath.getFiles() - } - } - cp.each { println it } + try { + def app = project(':app') + def android = app.android + def cp = [android.getBootClasspath()[0]] + android.applicationVariants.each { variant -> + if (variant.name.equals('release')) { + cp += variant.javaCompile.classpath.getFiles() + } + } + cp.each { println it } + } catch (Exception e) { + System.err.println("$_gradleCannotFindJars") + System.err.println("$_leftOverStubWarning") + } + } +} +'''; + + static const _gradleGetSourcesTaskName = 'getSources'; + // adapted from https://stackoverflow.com/questions/39975780/how-can-i-use-gradle-to-download-dependencies-and-their-source-files-and-place-t/39981143#39981143 + // Although it appears we can use this same code for getting JAR artifacts, + // there is no JAR equivalent for `org.gradle.language.base.Artifact`. + // So it appears different methods should be used for JAR artifacts. + static const _gradleGetSourcesStub = ''' +// Gradle stub for fetching source dependencies in jnigen. If found in +// android/build.gradle, please delete the following function. +task $_gradleGetSourcesTaskName(type: Copy) { + project.afterEvaluate { + def componentIds = project(':app').configurations.releaseCompileClasspath.incoming + .resolutionResult.allDependencies.collect { it.selected.id } + + ArtifactResolutionResult result = dependencies.createArtifactResolutionQuery() + .forComponents(componentIds) + .withArtifacts(JvmLibrary, SourcesArtifact) + .execute() + + def sourceArtifacts = [] + + result.resolvedComponents.each { ComponentArtifactsResult component -> + Set sources = component.getArtifacts(SourcesArtifact) + sources.each { ArtifactResult ar -> + if (ar instanceof ResolvedArtifactResult) { + sourceArtifacts << ar.file + } + } + } + sourceArtifacts.forEach { println it } } + System.err.println("$_leftOverStubWarning") } '''; @@ -87,10 +139,42 @@ task listDependencies(type: Copy) { /// If current project is not directly buildable by gradle, eg: a plugin, /// a relative path to other project can be specified using [androidProject]. static List getGradleClasspaths( + {Uri? configRoot, String androidProject = '.'}) => + _runGradleStub( + stubName: _gradleGetClasspathTaskName, + stubCode: _gradleGetClasspathStub, + androidProject: androidProject, + configRoot: configRoot, + ); + + /// Get source paths for all gradle dependencies. + /// + /// This function temporarily overwrites the build.gradle file by a stub with + /// function to list all dependency paths for release variant. + /// This function fails if no gradle build is attempted before. + static List getGradleSources( {Uri? configRoot, String androidProject = '.'}) { - log.info('trying to obtain gradle classpaths...'); + return _runGradleStub( + stubName: _gradleGetSourcesTaskName, + stubCode: _gradleGetSourcesStub, + androidProject: androidProject, + configRoot: configRoot, + ); + } + + static String _appendStub(String script, String stub) { + return script.contains(stub) ? script : script + stub; + } + + static List _runGradleStub({ + required String stubName, + required String stubCode, + Uri? configRoot, + String androidProject = '.', + }) { + log.info('trying to obtain gradle dependencies [$stubName]...'); if (configRoot != null) { - androidProject = join(configRoot.toFilePath(), androidProject); + androidProject = configRoot.resolve(androidProject).toFilePath(); } final android = join(androidProject, 'android'); final buildGradle = join(android, 'build.gradle'); @@ -99,31 +183,40 @@ task listDependencies(type: Copy) { final script = origBuild.readAsStringSync(); origBuild.renameSync(buildGradleOld); origBuild.createSync(); - log.finer('Writing temporary gradle script with stub function...'); - origBuild.writeAsStringSync('$script\n$_gradleListDepsFunction\n'); + log.finer('Writing temporary gradle script with stub "$stubName"...'); + origBuild.writeAsStringSync(_appendStub(script, stubCode)); log.finer('Running gradle wrapper...'); final gradleCommand = Platform.isWindows ? '.\\gradlew.bat' : './gradlew'; ProcessResult procRes; try { - procRes = Process.runSync(gradleCommand, ['-q', 'listDependencies'], + procRes = Process.runSync(gradleCommand, ['-q', stubName], workingDirectory: android, runInShell: true); } finally { - log.finer('Restoring build scripts'); - origBuild.writeAsStringSync(script); + log.info('Restoring build scripts'); + origBuild.writeAsStringSync( + script + .replaceAll(_gradleGetClasspathStub, "") + .replaceAll(_gradleGetSourcesStub, ""), + ); File(buildGradleOld).deleteSync(); } if (procRes.exitCode != 0) { final inAndroidProject = (androidProject == '.') ? '' : ' in $androidProject'; - throw GradleException('\n\ngradle exited with exit code ' - '${procRes.exitCode}\n. This can be related to a known issue with ' - 'gradle. Please run `flutter build apk`$inAndroidProject and try ' + throw GradleException('\n\ngradle exited with status ' + '${procRes.exitCode}\n. This can be because the Android build is not ' + 'yet cached. Please run `flutter build apk`$inAndroidProject and try ' 'again\n'); } - final classpaths = (procRes.stdout as String) + final output = procRes.stdout as String; + if (output.isEmpty) { + printError(procRes.stderr); + throw Exception("Gradle stub exited without output."); + } + final paths = (procRes.stdout as String) .trim() .split(Platform.isWindows ? '\r\n' : '\n'); - log.info('Found release build classpath with ${classpaths.length} entries'); - return classpaths; + log.fine('Found ${paths.length} entries'); + return paths; } } diff --git a/pkgs/jnigen/lib/src/tools/maven_tools.dart b/pkgs/jnigen/lib/src/tools/maven_tools.dart index 82ebdc7bd..74cb3a179 100644 --- a/pkgs/jnigen/lib/src/tools/maven_tools.dart +++ b/pkgs/jnigen/lib/src/tools/maven_tools.dart @@ -101,6 +101,13 @@ class MavenTools { xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + + google-maven-repo + Google Maven Repository + https://maven.google.com + + 4.0.0 com.mycompany.app jnigen_maven_stub diff --git a/pkgs/jnigen/lib/src/writers/bindings_writer.dart b/pkgs/jnigen/lib/src/writers/bindings_writer.dart index a31b3d778..190a90ccc 100644 --- a/pkgs/jnigen/lib/src/writers/bindings_writer.dart +++ b/pkgs/jnigen/lib/src/writers/bindings_writer.dart @@ -80,7 +80,7 @@ Future writeCBindings(Config config, List classes) async { final clangFormat = Process.runSync('clang-format', ['-i', cFile.path]); if (clangFormat.exitCode != 0) { printError(clangFormat.stderr); - log.warning('clang-format exited with $exitCode'); + log.warning('clang-format exited with ${clangFormat.exitCode}'); } } on ProcessException catch (e) { log.warning('cannot run clang-format: $e'); From b7db0faf42c7f5290d75583bf12bf42a32b30d8f Mon Sep 17 00:00:00 2001 From: Mahesh Hegde <46179734+mahesh-hegde@users.noreply.github.com> Date: Mon, 10 Apr 2023 21:55:07 +0530 Subject: [PATCH 072/139] [jnigen] Rethrow exception in gradle stub (https://github.com/dart-lang/jnigen/issues/237) --- pkgs/jnigen/lib/src/tools/android_sdk_tools.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/jnigen/lib/src/tools/android_sdk_tools.dart b/pkgs/jnigen/lib/src/tools/android_sdk_tools.dart index a3f53a325..466863c3e 100644 --- a/pkgs/jnigen/lib/src/tools/android_sdk_tools.dart +++ b/pkgs/jnigen/lib/src/tools/android_sdk_tools.dart @@ -91,6 +91,7 @@ task $_gradleGetClasspathTaskName(type: Copy) { } catch (Exception e) { System.err.println("$_gradleCannotFindJars") System.err.println("$_leftOverStubWarning") + throw e } } } From af0ee4fdfd0956a50a387bd6b1a15e561c9d45a2 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Wed, 12 Apr 2023 16:11:19 +0200 Subject: [PATCH 073/139] [jnigen] Type inference for generics (https://github.com/dart-lang/jnigen/issues/236) Type parameters are now named parameters instead. This allows us to toggle whether or not they're "required". A type parameter is not required if we can find it somewhere in the list of arguments. For example in ` f(ArrayList arr)`, `T` can be inferred because it's also the element type in the `ArrayList`. There might be multiple places where a certain type parameter `T` is found within the arguments. In that case we choose the lowest common super type of all the cases. --- pkgs/jni/lib/src/jarray.dart | 16 + pkgs/jni/lib/src/jobject.dart | 30 +- pkgs/jni/lib/src/jstring.dart | 14 + pkgs/jni/lib/src/types.dart | 24 + pkgs/jni/test/type_test.dart | 244 ++++ pkgs/jnigen/CHANGELOG.md | 7 + .../in_app_java/lib/android_utils.dart | 1096 ++++++++++++---- pkgs/jnigen/example/in_app_java/lib/main.dart | 2 +- .../kotlin_plugin/lib/kotlin_bindings.dart | 21 +- .../lib/notifications.dart | 37 +- .../org/apache/pdfbox/pdmodel/PDDocument.dart | 551 +++++--- .../pdfbox/pdmodel/PDDocumentInformation.dart | 178 ++- .../apache/pdfbox/text/PDFTextStripper.dart | 433 ++++-- .../lib/src/bindings/dart_generator.dart | 404 ++++-- pkgs/jnigen/lib/src/bindings/excluder.dart | 8 +- pkgs/jnigen/lib/src/bindings/linker.dart | 2 + pkgs/jnigen/lib/src/bindings/renamer.dart | 11 +- pkgs/jnigen/lib/src/bindings/resolver.dart | 12 +- pkgs/jnigen/lib/src/bindings/visitor.dart | 3 + pkgs/jnigen/lib/src/elements/elements.dart | 34 +- pkgs/jnigen/pubspec.yaml | 5 +- pkgs/jnigen/test/bindings_test.dart | 137 +- pkgs/jnigen/test/dart_generator_test.dart | 17 + .../fasterxml/jackson/core/JsonFactory.dart | 946 +++++++++----- .../fasterxml/jackson/core/JsonParser.dart | 1064 +++++++++------ .../com/fasterxml/jackson/core/JsonToken.dart | 100 +- pkgs/jnigen/test/kotlin_test/lib/kotlin.dart | 25 +- .../dart_lang/jnigen/generics/MyStack.java | 36 + .../dart_lang/jnigen/generics/StringMap.java | 7 + .../lib/simple_package.dart | 1157 ++++++++++++----- .../simple_package_test/src/simple_package.c | 125 ++ 31 files changed, 4911 insertions(+), 1835 deletions(-) create mode 100644 pkgs/jni/test/type_test.dart create mode 100644 pkgs/jnigen/test/dart_generator_test.dart create mode 100644 pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/generics/StringMap.java diff --git a/pkgs/jni/lib/src/jarray.dart b/pkgs/jni/lib/src/jarray.dart index 92f05b4f1..8b0aead19 100644 --- a/pkgs/jni/lib/src/jarray.dart +++ b/pkgs/jni/lib/src/jarray.dart @@ -16,6 +16,22 @@ class JArrayType extends JObjType> { @override JArray fromRef(Pointer ref) => JArray.fromRef(elementType, ref); + + @override + JObjType get superType => const JObjectType(); + + @override + final int superCount = 1; + + @override + int get hashCode => Object.hash(JArrayType, elementType); + + @override + bool operator ==(Object other) { + return other.runtimeType == JArrayType && + other is JArrayType && + elementType == other.elementType; + } } class JArray extends JObject { diff --git a/pkgs/jni/lib/src/jobject.dart b/pkgs/jni/lib/src/jobject.dart index 7477c55bf..dff8fda23 100644 --- a/pkgs/jni/lib/src/jobject.dart +++ b/pkgs/jni/lib/src/jobject.dart @@ -12,15 +12,33 @@ class JObjectType extends JObjType { @override JObject fromRef(Pointer ref) => JObject.fromRef(ref); + + @override + JObjType get superType => const JObjectType(); + + // 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 => (JObjectType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == JObjectType && other is JObjectType; + } } Pointer _getID( - JniPointerResult Function( - Pointer ptr, Pointer name, Pointer sig) - f, - Pointer ptr, - String name, - String sig) { + JniPointerResult Function( + Pointer ptr, Pointer name, Pointer sig) + f, + Pointer ptr, + String name, + String sig, +) { final result = using( (arena) => f(ptr, name.toNativeChars(arena), sig.toNativeChars(arena))); if (result.exception != nullptr) { diff --git a/pkgs/jni/lib/src/jstring.dart b/pkgs/jni/lib/src/jstring.dart index 5746e2338..9d02df9e2 100644 --- a/pkgs/jni/lib/src/jstring.dart +++ b/pkgs/jni/lib/src/jstring.dart @@ -12,6 +12,20 @@ class JStringType extends JObjType { @override JString fromRef(Pointer ref) => JString.fromRef(ref); + + @override + JObjType get superType => const JObjectType(); + + @override + final int superCount = 1; + + @override + int get hashCode => (JStringType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == JStringType && other is JStringType; + } } class JString extends JObject { diff --git a/pkgs/jni/lib/src/types.dart b/pkgs/jni/lib/src/types.dart index 07102e894..9c0cb4968 100644 --- a/pkgs/jni/lib/src/types.dart +++ b/pkgs/jni/lib/src/types.dart @@ -34,6 +34,11 @@ abstract class JType { } abstract class JObjType extends JType { + /// Number of super types. Distance to the root type. + int get superCount; + + JObjType get superType; + const JObjType(); @override @@ -49,3 +54,22 @@ abstract class JObjType extends JType { return Jni.findJniClass(signature); } } + +/// Lowest common ancestor of two types in the inheritance tree. +JObjType _lowestCommonAncestor(JObjType a, JObjType b) { + 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; +} + +JObjType lowestCommonSuperType(List types) { + return types.reduce(_lowestCommonAncestor); +} diff --git a/pkgs/jni/test/type_test.dart b/pkgs/jni/test/type_test.dart new file mode 100644 index 000000000..0f7f5bfcc --- /dev/null +++ b/pkgs/jni/test/type_test.dart @@ -0,0 +1,244 @@ +// 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 'dart:ffi'; +import 'dart:io'; + +import 'package:jni/jni.dart'; +import 'package:test/test.dart'; + +// Mocking this type tree: +// JObject +// | \ +// A B +// / \ \ +// C D E +// / +// F + +class A extends JObject { + A.fromRef(super.reference) : super.fromRef(); + @override + JObjType get $type => $AType(); +} + +class $AType extends JObjType { + @override + A fromRef(Pointer ref) { + return A.fromRef(ref); + } + + @override + String get signature => 'A'; + + @override + int get superCount => superType.superCount + 1; + + @override + JObjType get superType => JObject.type; + + @override + int get hashCode => ($AType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $AType && other is $AType; + } +} + +class B extends JObject { + B.fromRef(super.reference) : super.fromRef(); + @override + JObjType get $type => $BType(); +} + +class $BType extends JObjType { + @override + B fromRef(Pointer ref) { + return B.fromRef(ref); + } + + @override + String get signature => 'B'; + + @override + int get superCount => superType.superCount + 1; + + @override + JObjType get superType => JObject.type; + + @override + int get hashCode => ($BType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $BType && other is $BType; + } +} + +class C extends A { + C.fromRef(super.reference) : super.fromRef(); + + @override + JObjType get $type => $CType(); +} + +class $CType extends JObjType { + @override + C fromRef(Pointer ref) { + return C.fromRef(ref); + } + + @override + String get signature => 'C'; + + @override + int get superCount => superType.superCount + 1; + + @override + JObjType get superType => $AType(); + + @override + int get hashCode => ($CType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $CType && other is $CType; + } +} + +class D extends A { + D.fromRef(super.reference) : super.fromRef(); + + @override + JObjType get $type => $DType(); +} + +class $DType extends JObjType { + @override + D fromRef(Pointer ref) { + return D.fromRef(ref); + } + + @override + String get signature => 'D'; + + @override + int get superCount => superType.superCount + 1; + + @override + JObjType get superType => $AType(); + + @override + int get hashCode => ($DType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $DType && other is $DType; + } +} + +class E extends B { + E.fromRef(super.reference) : super.fromRef(); + + @override + JObjType get $type => $EType(); +} + +class $EType extends JObjType { + @override + E fromRef(Pointer ref) { + return E.fromRef(ref); + } + + @override + String get signature => 'E'; + + @override + int get superCount => superType.superCount + 1; + + @override + JObjType get superType => $BType(); + + @override + int get hashCode => ($EType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $EType && other is $EType; + } +} + +class F extends C { + F.fromRef(super.reference) : super.fromRef(); + + @override + JObjType get $type => $FType(); +} + +class $FType extends JObjType { + @override + F fromRef(Pointer ref) { + return F.fromRef(ref); + } + + @override + String get signature => 'F'; + + @override + int get superCount => superType.superCount + 1; + + @override + JObjType get superType => $CType(); + + @override + int get hashCode => ($FType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $FType && other is $FType; + } +} + +void main() { + if (!Platform.isAndroid) { + try { + Jni.spawn(dylibDir: "build/jni_libs", jvmOptions: ["-Xmx128m"]); + } on JvmExistsException catch (_) { + // TODO(#51): Support destroying and reinstantiating JVM. + } + } + + test('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(JLong.type)]), + JObject.type); + }); + + test('Mocked type tree', () { + // As a reminder, this is how the type tree looks like: + // JObject + // | \ + // A B + // / \ \ + // C D E + // / + // F + expect(lowestCommonSuperType([$AType(), $BType()]), const JObjectType()); + expect(lowestCommonSuperType([$CType(), $BType()]), const JObjectType()); + expect(lowestCommonSuperType([$FType(), $BType()]), const JObjectType()); + expect(lowestCommonSuperType([$EType(), $CType(), $FType()]), + const JObjectType()); + + expect(lowestCommonSuperType([$CType(), $DType()]), $AType()); + expect(lowestCommonSuperType([$FType(), $DType()]), $AType()); + expect(lowestCommonSuperType([$FType(), $CType(), $DType()]), $AType()); + + expect(lowestCommonSuperType([$EType(), $BType()]), $BType()); + expect(lowestCommonSuperType([$BType(), $BType()]), $BType()); + }); +} diff --git a/pkgs/jnigen/CHANGELOG.md b/pkgs/jnigen/CHANGELOG.md index d47aa13d3..1516220f2 100644 --- a/pkgs/jnigen/CHANGELOG.md +++ b/pkgs/jnigen/CHANGELOG.md @@ -1,3 +1,10 @@ +## 0.4.0-dev +* **Breaking Change** ([#145](https://github.com/dart-lang/jnigen/issues/145)): Type arguments are now named instead of positional. +* Type parameters can now be inferred when possible. +* Fixed a bug where passing a `long` argument truncated it to `int` in pure dart bindings. +* Removed array extensions from the generated code. +* Added the ability to use source dependencies from Gradle. + ## 0.3.0 * Added the option to convert Kotlin `suspend fun` to Dart async methods. Add `suspend_fun_to_async: true` to `jnigen.yaml`. diff --git a/pkgs/jnigen/example/in_app_java/lib/android_utils.dart b/pkgs/jnigen/example/in_app_java/lib/android_utils.dart index 3faba5b55..5925b9251 100644 --- a/pkgs/jnigen/example/in_app_java/lib/android_utils.dart +++ b/pkgs/jnigen/example/in_app_java/lib/android_utils.dart @@ -26,9 +26,8 @@ final ffi.Pointer Function(String sym) jniLookup = /// from: com.example.in_app_java.AndroidUtils class AndroidUtils extends jni.JObject { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type; + late final jni.JObjType $type = type; AndroidUtils.fromRef( jni.JObjectPtr ref, @@ -46,8 +45,12 @@ class AndroidUtils extends jni.JObject { /// from: static public void showToast(android.app.Activity mainActivity, java.lang.CharSequence text, int duration) static void showToast( - jni.JObject mainActivity, jni.JObject text, int duration) => - _showToast(mainActivity.reference, text.reference, duration).check(); + jni.JObject mainActivity, + jni.JObject text, + int duration, + ) { + return _showToast(mainActivity.reference, text.reference, duration).check(); + } } class $AndroidUtilsType extends jni.JObjType { @@ -58,6 +61,20 @@ class $AndroidUtilsType extends jni.JObjType { @override AndroidUtils fromRef(jni.JObjectPtr ref) => AndroidUtils.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($AndroidUtilsType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $AndroidUtilsType && other is $AndroidUtilsType; + } } /// from: androidx.emoji2.text.EmojiCompat @@ -110,9 +127,8 @@ class $AndroidUtilsType extends jni.JObjType { /// loading completes use InitCallback. ///

class EmojiCompat extends jni.JObject { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type; + late final jni.JObjType $type = type; EmojiCompat.fromRef( jni.JObjectPtr ref, @@ -328,8 +344,11 @@ class EmojiCompat extends jni.JObject { /// afterwords. /// ///@return Default EmojiCompat for this device, or null if there is no provider on the system. - static EmojiCompat init(jni.JObject context) => - const $EmojiCompatType().fromRef(_init(context.reference).object); + static EmojiCompat init( + jni.JObject context, + ) { + return const $EmojiCompatType().fromRef(_init(context.reference).object); + } static final _init1 = jniLookup< ffi.NativeFunction< @@ -344,11 +363,12 @@ class EmojiCompat extends jni.JObject { /// /// @hide static EmojiCompat init1( - jni.JObject context, - DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory - defaultFactory) => - const $EmojiCompatType() - .fromRef(_init1(context.reference, defaultFactory.reference).object); + jni.JObject context, + DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory defaultFactory, + ) { + return const $EmojiCompatType() + .fromRef(_init1(context.reference, defaultFactory.reference).object); + } static final _init2 = jniLookup< ffi.NativeFunction< @@ -365,8 +385,11 @@ class EmojiCompat extends jni.JObject { /// the singleton instance and any call after that will not create a new instance and return /// immediately. ///@see EmojiCompat.Config - static EmojiCompat init2(EmojiCompat_Config config) => - const $EmojiCompatType().fromRef(_init2(config.reference).object); + static EmojiCompat init2( + EmojiCompat_Config config, + ) { + return const $EmojiCompatType().fromRef(_init2(config.reference).object); + } static final _isConfigured = jniLookup>( @@ -384,7 +407,9 @@ class EmojiCompat extends jni.JObject { /// This function does not check the \#getLoadState() and will return true even if the /// font is still loading, or has failed to load. ///@return true if EmojiCompat has been successfully initialized. - static bool isConfigured() => _isConfigured().boolean; + static bool isConfigured() { + return _isConfigured().boolean; + } static final _reset = jniLookup< ffi.NativeFunction< @@ -398,8 +423,11 @@ class EmojiCompat extends jni.JObject { /// Used by the tests to reset EmojiCompat with a new configuration. Every time it is called a /// new instance is created with the new configuration. ///@hide - static EmojiCompat reset(EmojiCompat_Config config) => - const $EmojiCompatType().fromRef(_reset(config.reference).object); + static EmojiCompat reset( + EmojiCompat_Config config, + ) { + return const $EmojiCompatType().fromRef(_reset(config.reference).object); + } static final _reset1 = jniLookup< ffi.NativeFunction< @@ -412,8 +440,12 @@ class EmojiCompat extends jni.JObject { /// /// Used by the tests to reset EmojiCompat with a new singleton instance. ///@hide - static EmojiCompat reset1(EmojiCompat emojiCompat) => - const $EmojiCompatType().fromRef(_reset1(emojiCompat.reference).object); + static EmojiCompat reset1( + EmojiCompat emojiCompat, + ) { + return const $EmojiCompatType() + .fromRef(_reset1(emojiCompat.reference).object); + } static final _skipDefaultConfigurationLookup = jniLookup>( @@ -424,8 +456,11 @@ class EmojiCompat extends jni.JObject { /// /// Reset default configuration lookup flag, for tests. ///@hide - static void skipDefaultConfigurationLookup(bool shouldSkip) => - _skipDefaultConfigurationLookup(shouldSkip ? 1 : 0).check(); + static void skipDefaultConfigurationLookup( + bool shouldSkip, + ) { + return _skipDefaultConfigurationLookup(shouldSkip ? 1 : 0).check(); + } static final _get0 = jniLookup>( "EmojiCompat__get0") @@ -438,7 +473,9 @@ class EmojiCompat extends jni.JObject { /// \#init(EmojiCompat.Config) is called to initialize the singleton instance. ///@return EmojiCompat instance ///@throws IllegalStateException if called before \#init(EmojiCompat.Config) - static EmojiCompat get0() => const $EmojiCompatType().fromRef(_get0().object); + static EmojiCompat get0() { + return const $EmojiCompatType().fromRef(_get0().object); + } static final _load = jniLookup< ffi.NativeFunction< @@ -461,7 +498,9 @@ class EmojiCompat extends jni.JObject { /// ///@throws IllegalStateException when Config\#setMetadataLoadStrategy(int) is not set /// to \#LOAD_STRATEGY_MANUAL - void load() => _load(reference).check(); + void load() { + return _load(reference).check(); + } static final _registerInitCallback = jniLookup< ffi.NativeFunction< @@ -482,8 +521,11 @@ class EmojiCompat extends jni.JObject { /// called. ///@param initCallback the initialization callback to register, cannot be {@code null} ///@see \#unregisterInitCallback(InitCallback) - void registerInitCallback(EmojiCompat_InitCallback initCallback) => - _registerInitCallback(reference, initCallback.reference).check(); + void registerInitCallback( + EmojiCompat_InitCallback initCallback, + ) { + return _registerInitCallback(reference, initCallback.reference).check(); + } static final _unregisterInitCallback = jniLookup< ffi.NativeFunction< @@ -498,8 +540,11 @@ class EmojiCompat extends jni.JObject { /// /// Unregisters a callback that was added before. ///@param initCallback the callback to be removed, cannot be {@code null} - void unregisterInitCallback(EmojiCompat_InitCallback initCallback) => - _unregisterInitCallback(reference, initCallback.reference).check(); + void unregisterInitCallback( + EmojiCompat_InitCallback initCallback, + ) { + return _unregisterInitCallback(reference, initCallback.reference).check(); + } static final _getLoadState = jniLookup< ffi.NativeFunction< @@ -513,7 +558,9 @@ class EmojiCompat extends jni.JObject { /// below always returns \#LOAD_STATE_SUCCEEDED. ///@return one of \#LOAD_STATE_DEFAULT, \#LOAD_STATE_LOADING, /// \#LOAD_STATE_SUCCEEDED, \#LOAD_STATE_FAILED - int getLoadState() => _getLoadState(reference).integer; + int getLoadState() { + return _getLoadState(reference).integer; + } static final _isEmojiSpanIndicatorEnabled = jniLookup< ffi.NativeFunction< @@ -525,8 +572,9 @@ class EmojiCompat extends jni.JObject { /// /// @return whether a background should be drawn for the emoji for debugging ///@hide - bool isEmojiSpanIndicatorEnabled() => - _isEmojiSpanIndicatorEnabled(reference).boolean; + bool isEmojiSpanIndicatorEnabled() { + return _isEmojiSpanIndicatorEnabled(reference).boolean; + } static final _getEmojiSpanIndicatorColor = jniLookup< ffi.NativeFunction< @@ -538,8 +586,9 @@ class EmojiCompat extends jni.JObject { /// /// @return color of background drawn if EmojiCompat\#isEmojiSpanIndicatorEnabled is true ///@hide - int getEmojiSpanIndicatorColor() => - _getEmojiSpanIndicatorColor(reference).integer; + int getEmojiSpanIndicatorColor() { + return _getEmojiSpanIndicatorColor(reference).integer; + } static final _getEmojiStart = jniLookup< ffi.NativeFunction< @@ -562,8 +611,12 @@ class EmojiCompat extends jni.JObject { ///@param charSequence the whole sequence ///@param offset index of the emoji to look up ///@return the start index inclusively/end index exclusively - int getEmojiStart(jni.JObject charSequence, int offset) => - _getEmojiStart(reference, charSequence.reference, offset).integer; + int getEmojiStart( + jni.JObject charSequence, + int offset, + ) { + return _getEmojiStart(reference, charSequence.reference, offset).integer; + } static final _getEmojiEnd = jniLookup< ffi.NativeFunction< @@ -578,8 +631,12 @@ class EmojiCompat extends jni.JObject { /// from: public int getEmojiEnd(java.lang.CharSequence charSequence, int offset) /// /// see \#getEmojiStart(CharSequence, int). - int getEmojiEnd(jni.JObject charSequence, int offset) => - _getEmojiEnd(reference, charSequence.reference, offset).integer; + int getEmojiEnd( + jni.JObject charSequence, + int offset, + ) { + return _getEmojiEnd(reference, charSequence.reference, offset).integer; + } static final _handleOnKeyDown = jniLookup< ffi.NativeFunction< @@ -608,8 +665,13 @@ class EmojiCompat extends jni.JObject { /// int, KeyEvent) ///@return {@code true} if an EmojiSpan is deleted static bool handleOnKeyDown( - jni.JObject editable, int keyCode, jni.JObject event) => - _handleOnKeyDown(editable.reference, keyCode, event.reference).boolean; + jni.JObject editable, + int keyCode, + jni.JObject event, + ) { + return _handleOnKeyDown(editable.reference, keyCode, event.reference) + .boolean; + } static final _handleDeleteSurroundingText = jniLookup< ffi.NativeFunction< @@ -640,18 +702,16 @@ class EmojiCompat extends jni.JObject { ///@param inCodePoints {@code true} if length parameters are in codepoints ///@return {@code true} if an EmojiSpan is deleted static bool handleDeleteSurroundingText( - jni.JObject inputConnection, - jni.JObject editable, - int beforeLength, - int afterLength, - bool inCodePoints) => - _handleDeleteSurroundingText( - inputConnection.reference, - editable.reference, - beforeLength, - afterLength, - inCodePoints ? 1 : 0) - .boolean; + jni.JObject inputConnection, + jni.JObject editable, + int beforeLength, + int afterLength, + bool inCodePoints, + ) { + return _handleDeleteSurroundingText(inputConnection.reference, + editable.reference, beforeLength, afterLength, inCodePoints ? 1 : 0) + .boolean; + } static final _hasEmojiGlyph = jniLookup< ffi.NativeFunction< @@ -669,8 +729,11 @@ class EmojiCompat extends jni.JObject { ///@param sequence CharSequence representing the emoji ///@return {@code true} if EmojiCompat can render given emoji, cannot be {@code null} ///@throws IllegalStateException if not initialized yet - bool hasEmojiGlyph(jni.JObject sequence) => - _hasEmojiGlyph(reference, sequence.reference).boolean; + bool hasEmojiGlyph( + jni.JObject sequence, + ) { + return _hasEmojiGlyph(reference, sequence.reference).boolean; + } static final _hasEmojiGlyph1 = jniLookup< ffi.NativeFunction< @@ -692,8 +755,13 @@ class EmojiCompat extends jni.JObject { /// equal to {@code 0}, ///@return {@code true} if EmojiCompat can render given emoji, cannot be {@code null} ///@throws IllegalStateException if not initialized yet - bool hasEmojiGlyph1(jni.JObject sequence, int metadataVersion) => - _hasEmojiGlyph1(reference, sequence.reference, metadataVersion).boolean; + bool hasEmojiGlyph1( + jni.JObject sequence, + int metadataVersion, + ) { + return _hasEmojiGlyph1(reference, sequence.reference, metadataVersion) + .boolean; + } static final _getEmojiMatch = jniLookup< ffi.NativeFunction< @@ -718,8 +786,13 @@ class EmojiCompat extends jni.JObject { ///@param metadataVersion the metada version to check against, should be greater than or /// equal to {@code 0}, ///@return A match result, or decomposes if replaceAll would cause partial subsequence matches. - int getEmojiMatch(jni.JObject sequence, int metadataVersion) => - _getEmojiMatch(reference, sequence.reference, metadataVersion).integer; + int getEmojiMatch( + jni.JObject sequence, + int metadataVersion, + ) { + return _getEmojiMatch(reference, sequence.reference, metadataVersion) + .integer; + } static final _process = jniLookup< ffi.NativeFunction< @@ -738,8 +811,12 @@ class EmojiCompat extends jni.JObject { ///@param charSequence CharSequence to add the EmojiSpans ///@throws IllegalStateException if not initialized yet ///@see \#process(CharSequence, int, int) - jni.JObject process(jni.JObject charSequence) => const jni.JObjectType() - .fromRef(_process(reference, charSequence.reference).object); + jni.JObject process( + jni.JObject charSequence, + ) { + return const jni.JObjectType() + .fromRef(_process(reference, charSequence.reference).object); + } static final _process1 = jniLookup< ffi.NativeFunction< @@ -778,9 +855,14 @@ class EmojiCompat extends jni.JObject { /// {@code start < 0}, {@code end < 0}, {@code end < start}, /// {@code start > charSequence.length()}, /// {@code end > charSequence.length()} - jni.JObject process1(jni.JObject charSequence, int start, int end) => - const jni.JObjectType().fromRef( - _process1(reference, charSequence.reference, start, end).object); + jni.JObject process1( + jni.JObject charSequence, + int start, + int end, + ) { + return const jni.JObjectType().fromRef( + _process1(reference, charSequence.reference, start, end).object); + } static final _process2 = jniLookup< ffi.NativeFunction< @@ -824,10 +906,15 @@ class EmojiCompat extends jni.JObject { /// {@code end > charSequence.length()} /// {@code maxEmojiCount < 0} jni.JObject process2( - jni.JObject charSequence, int start, int end, int maxEmojiCount) => - const jni.JObjectType().fromRef(_process2( - reference, charSequence.reference, start, end, maxEmojiCount) - .object); + jni.JObject charSequence, + int start, + int end, + int maxEmojiCount, + ) { + return const jni.JObjectType().fromRef( + _process2(reference, charSequence.reference, start, end, maxEmojiCount) + .object); + } static final _process3 = jniLookup< ffi.NativeFunction< @@ -875,16 +962,17 @@ class EmojiCompat extends jni.JObject { /// {@code start > charSequence.length()}, /// {@code end > charSequence.length()} /// {@code maxEmojiCount < 0} - jni.JObject process3(jni.JObject charSequence, int start, int end, - int maxEmojiCount, int replaceStrategy) => - const jni.JObjectType().fromRef(_process3( - reference, - charSequence.reference, - start, - end, - maxEmojiCount, - replaceStrategy) - .object); + jni.JObject process3( + jni.JObject charSequence, + int start, + int end, + int maxEmojiCount, + int replaceStrategy, + ) { + return const jni.JObjectType().fromRef(_process3(reference, + charSequence.reference, start, end, maxEmojiCount, replaceStrategy) + .object); + } static final _getAssetSignature = jniLookup< ffi.NativeFunction< @@ -899,8 +987,10 @@ class EmojiCompat extends jni.JObject { /// constructed using emoji assets. Can be used to detect if currently loaded asset is different /// then previous executions. When used on devices running API 18 or below, returns empty string. ///@throws IllegalStateException if not initialized yet - jni.JString getAssetSignature() => - const jni.JStringType().fromRef(_getAssetSignature(reference).object); + jni.JString getAssetSignature() { + return const jni.JStringType() + .fromRef(_getAssetSignature(reference).object); + } static final _updateEditorInfo = jniLookup< ffi.NativeFunction< @@ -927,8 +1017,11 @@ class EmojiCompat extends jni.JObject { /// android.widget.TextView\#onCreateInputConnection(EditorInfo) ///@see \#EDITOR_INFO_METAVERSION_KEY ///@see \#EDITOR_INFO_REPLACE_ALL_KEY - void updateEditorInfo(jni.JObject outAttrs) => - _updateEditorInfo(reference, outAttrs.reference).check(); + void updateEditorInfo( + jni.JObject outAttrs, + ) { + return _updateEditorInfo(reference, outAttrs.reference).check(); + } } class $EmojiCompatType extends jni.JObjType { @@ -939,6 +1032,20 @@ class $EmojiCompatType extends jni.JObjType { @override EmojiCompat fromRef(jni.JObjectPtr ref) => EmojiCompat.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($EmojiCompatType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $EmojiCompatType && other is $EmojiCompatType; + } } /// from: androidx.emoji2.text.EmojiCompat$Config @@ -947,9 +1054,8 @@ class $EmojiCompatType extends jni.JObjType { /// \#init(Config) is called. ///@see \#init(EmojiCompat.Config) class EmojiCompat_Config extends jni.JObject { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type; + late final jni.JObjType $type = type; EmojiCompat_Config.fromRef( jni.JObjectPtr ref, @@ -968,8 +1074,11 @@ class EmojiCompat_Config extends jni.JObject { /// /// Default constructor. ///@param metadataLoader MetadataRepoLoader instance, cannot be {@code null} - EmojiCompat_Config(EmojiCompat_MetadataRepoLoader metadataLoader) - : super.fromRef(_ctor(metadataLoader.reference).object); + factory EmojiCompat_Config( + EmojiCompat_MetadataRepoLoader metadataLoader, + ) { + return EmojiCompat_Config.fromRef(_ctor(metadataLoader.reference).object); + } static final _registerInitCallback = jniLookup< ffi.NativeFunction< @@ -987,9 +1096,11 @@ class EmojiCompat_Config extends jni.JObject { ///@param initCallback the initialization callback to register, cannot be {@code null} ///@return EmojiCompat.Config instance EmojiCompat_Config registerInitCallback( - EmojiCompat_InitCallback initCallback) => - const $EmojiCompat_ConfigType().fromRef( - _registerInitCallback(reference, initCallback.reference).object); + EmojiCompat_InitCallback initCallback, + ) { + return const $EmojiCompat_ConfigType().fromRef( + _registerInitCallback(reference, initCallback.reference).object); + } static final _unregisterInitCallback = jniLookup< ffi.NativeFunction< @@ -1007,9 +1118,11 @@ class EmojiCompat_Config extends jni.JObject { ///@param initCallback the initialization callback to be removed, cannot be {@code null} ///@return EmojiCompat.Config instance EmojiCompat_Config unregisterInitCallback( - EmojiCompat_InitCallback initCallback) => - const $EmojiCompat_ConfigType().fromRef( - _unregisterInitCallback(reference, initCallback.reference).object); + EmojiCompat_InitCallback initCallback, + ) { + return const $EmojiCompat_ConfigType().fromRef( + _unregisterInitCallback(reference, initCallback.reference).object); + } static final _setReplaceAll = jniLookup< ffi.NativeFunction< @@ -1025,9 +1138,12 @@ class EmojiCompat_Config extends jni.JObject { /// can render an emoji and do not replace those emojis. ///@param replaceAll replace all emojis found with EmojiSpans ///@return EmojiCompat.Config instance - EmojiCompat_Config setReplaceAll(bool replaceAll) => - const $EmojiCompat_ConfigType() - .fromRef(_setReplaceAll(reference, replaceAll ? 1 : 0).object); + EmojiCompat_Config setReplaceAll( + bool replaceAll, + ) { + return const $EmojiCompat_ConfigType() + .fromRef(_setReplaceAll(reference, replaceAll ? 1 : 0).object); + } static final _setUseEmojiAsDefaultStyle = jniLookup< ffi.NativeFunction< @@ -1050,10 +1166,13 @@ class EmojiCompat_Config extends jni.JObject { /// exception emojis that should be still presented as text style. ///@param useEmojiAsDefaultStyle whether to use the emoji style presentation for all emojis /// that would be presented as text style by default - EmojiCompat_Config setUseEmojiAsDefaultStyle(bool useEmojiAsDefaultStyle) => - const $EmojiCompat_ConfigType().fromRef( - _setUseEmojiAsDefaultStyle(reference, useEmojiAsDefaultStyle ? 1 : 0) - .object); + EmojiCompat_Config setUseEmojiAsDefaultStyle( + bool useEmojiAsDefaultStyle, + ) { + return const $EmojiCompat_ConfigType().fromRef( + _setUseEmojiAsDefaultStyle(reference, useEmojiAsDefaultStyle ? 1 : 0) + .object); + } static final _setUseEmojiAsDefaultStyle1 = jniLookup< ffi.NativeFunction< @@ -1079,13 +1198,16 @@ class EmojiCompat_Config extends jni.JObject { /// not. When no exception is wanted, the method /// \#setUseEmojiAsDefaultStyle(boolean) should /// be used instead. - EmojiCompat_Config setUseEmojiAsDefaultStyle1(bool useEmojiAsDefaultStyle, - jni.JObject emojiAsDefaultStyleExceptions) => - const $EmojiCompat_ConfigType().fromRef(_setUseEmojiAsDefaultStyle1( - reference, - useEmojiAsDefaultStyle ? 1 : 0, - emojiAsDefaultStyleExceptions.reference) - .object); + EmojiCompat_Config setUseEmojiAsDefaultStyle1( + bool useEmojiAsDefaultStyle, + jni.JObject emojiAsDefaultStyleExceptions, + ) { + return const $EmojiCompat_ConfigType().fromRef(_setUseEmojiAsDefaultStyle1( + reference, + useEmojiAsDefaultStyle ? 1 : 0, + emojiAsDefaultStyleExceptions.reference) + .object); + } static final _setEmojiSpanIndicatorEnabled = jniLookup< ffi.NativeFunction< @@ -1102,10 +1224,13 @@ class EmojiCompat_Config extends jni.JObject { ///@param emojiSpanIndicatorEnabled when {@code true} a background is drawn for each emoji /// that is replaced EmojiCompat_Config setEmojiSpanIndicatorEnabled( - bool emojiSpanIndicatorEnabled) => - const $EmojiCompat_ConfigType().fromRef(_setEmojiSpanIndicatorEnabled( - reference, emojiSpanIndicatorEnabled ? 1 : 0) - .object); + bool emojiSpanIndicatorEnabled, + ) { + return const $EmojiCompat_ConfigType().fromRef( + _setEmojiSpanIndicatorEnabled( + reference, emojiSpanIndicatorEnabled ? 1 : 0) + .object); + } static final _setEmojiSpanIndicatorColor = jniLookup< ffi.NativeFunction< @@ -1119,9 +1244,12 @@ class EmojiCompat_Config extends jni.JObject { /// Sets the color used as emoji span indicator. The default value is /// Color\#GREEN Color.GREEN. ///@see \#setEmojiSpanIndicatorEnabled(boolean) - EmojiCompat_Config setEmojiSpanIndicatorColor(int color) => - const $EmojiCompat_ConfigType() - .fromRef(_setEmojiSpanIndicatorColor(reference, color).object); + EmojiCompat_Config setEmojiSpanIndicatorColor( + int color, + ) { + return const $EmojiCompat_ConfigType() + .fromRef(_setEmojiSpanIndicatorColor(reference, color).object); + } static final _setMetadataLoadStrategy = jniLookup< ffi.NativeFunction< @@ -1164,9 +1292,12 @@ class EmojiCompat_Config extends jni.JObject { /// ///@param strategy one of EmojiCompat\#LOAD_STRATEGY_DEFAULT, /// EmojiCompat\#LOAD_STRATEGY_MANUAL - EmojiCompat_Config setMetadataLoadStrategy(int strategy) => - const $EmojiCompat_ConfigType() - .fromRef(_setMetadataLoadStrategy(reference, strategy).object); + EmojiCompat_Config setMetadataLoadStrategy( + int strategy, + ) { + return const $EmojiCompat_ConfigType() + .fromRef(_setMetadataLoadStrategy(reference, strategy).object); + } static final _setSpanFactory = jniLookup< ffi.NativeFunction< @@ -1182,9 +1313,12 @@ class EmojiCompat_Config extends jni.JObject { /// Set the span factory used to actually draw emoji replacements. ///@param factory custum span factory that can draw the emoji replacements ///@return this - EmojiCompat_Config setSpanFactory(EmojiCompat_SpanFactory factory0) => - const $EmojiCompat_ConfigType() - .fromRef(_setSpanFactory(reference, factory0.reference).object); + EmojiCompat_Config setSpanFactory( + EmojiCompat_SpanFactory factory0, + ) { + return const $EmojiCompat_ConfigType() + .fromRef(_setSpanFactory(reference, factory0.reference).object); + } static final _setGlyphChecker = jniLookup< ffi.NativeFunction< @@ -1201,9 +1335,12 @@ class EmojiCompat_Config extends jni.JObject { /// The interface that is used by EmojiCompat in order to check if a given emoji can be /// rendered by the system. ///@param glyphChecker GlyphChecker instance to be used. - EmojiCompat_Config setGlyphChecker(EmojiCompat_GlyphChecker glyphChecker) => - const $EmojiCompat_ConfigType() - .fromRef(_setGlyphChecker(reference, glyphChecker.reference).object); + EmojiCompat_Config setGlyphChecker( + EmojiCompat_GlyphChecker glyphChecker, + ) { + return const $EmojiCompat_ConfigType() + .fromRef(_setGlyphChecker(reference, glyphChecker.reference).object); + } static final _getMetadataRepoLoader = jniLookup< ffi.NativeFunction< @@ -1215,9 +1352,10 @@ class EmojiCompat_Config extends jni.JObject { /// The returned object must be deleted after use, by calling the `delete` method. /// /// Returns the MetadataRepoLoader. - EmojiCompat_MetadataRepoLoader getMetadataRepoLoader() => - const $EmojiCompat_MetadataRepoLoaderType() - .fromRef(_getMetadataRepoLoader(reference).object); + EmojiCompat_MetadataRepoLoader getMetadataRepoLoader() { + return const $EmojiCompat_MetadataRepoLoaderType() + .fromRef(_getMetadataRepoLoader(reference).object); + } } class $EmojiCompat_ConfigType extends jni.JObjType { @@ -1229,6 +1367,21 @@ class $EmojiCompat_ConfigType extends jni.JObjType { @override EmojiCompat_Config fromRef(jni.JObjectPtr ref) => EmojiCompat_Config.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($EmojiCompat_ConfigType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $EmojiCompat_ConfigType && + other is $EmojiCompat_ConfigType; + } } /// from: androidx.emoji2.text.EmojiCompat$MetadataRepoLoaderCallback @@ -1236,9 +1389,8 @@ class $EmojiCompat_ConfigType extends jni.JObjType { /// Callback to inform EmojiCompat about the state of the metadata load. Passed to /// MetadataRepoLoader during MetadataRepoLoader\#load(MetadataRepoLoaderCallback) call. class EmojiCompat_MetadataRepoLoaderCallback extends jni.JObject { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type; + late final jni.JObjType $type = type; EmojiCompat_MetadataRepoLoaderCallback.fromRef( jni.JObjectPtr ref, @@ -1252,7 +1404,9 @@ class EmojiCompat_MetadataRepoLoaderCallback extends jni.JObject { /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. - EmojiCompat_MetadataRepoLoaderCallback() : super.fromRef(_ctor().object); + factory EmojiCompat_MetadataRepoLoaderCallback() { + return EmojiCompat_MetadataRepoLoaderCallback.fromRef(_ctor().object); + } static final _onLoaded = jniLookup< ffi.NativeFunction< @@ -1267,8 +1421,11 @@ class EmojiCompat_MetadataRepoLoaderCallback extends jni.JObject { /// /// Called by MetadataRepoLoader when metadata is loaded successfully. ///@param metadataRepo MetadataRepo instance, cannot be {@code null} - void onLoaded(jni.JObject metadataRepo) => - _onLoaded(reference, metadataRepo.reference).check(); + void onLoaded( + jni.JObject metadataRepo, + ) { + return _onLoaded(reference, metadataRepo.reference).check(); + } static final _onFailed = jniLookup< ffi.NativeFunction< @@ -1283,8 +1440,11 @@ class EmojiCompat_MetadataRepoLoaderCallback extends jni.JObject { /// /// Called by MetadataRepoLoader if an error occurs while loading the metadata. ///@param throwable the exception that caused the failure, {@code nullable} - void onFailed(jni.JObject throwable) => - _onFailed(reference, throwable.reference).check(); + void onFailed( + jni.JObject throwable, + ) { + return _onFailed(reference, throwable.reference).check(); + } } class $EmojiCompat_MetadataRepoLoaderCallbackType @@ -1298,15 +1458,29 @@ class $EmojiCompat_MetadataRepoLoaderCallbackType @override EmojiCompat_MetadataRepoLoaderCallback fromRef(jni.JObjectPtr ref) => EmojiCompat_MetadataRepoLoaderCallback.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($EmojiCompat_MetadataRepoLoaderCallbackType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $EmojiCompat_MetadataRepoLoaderCallbackType && + other is $EmojiCompat_MetadataRepoLoaderCallbackType; + } } /// from: androidx.emoji2.text.EmojiCompat$GlyphChecker /// /// Interface to check if a given emoji exists on the system. class EmojiCompat_GlyphChecker extends jni.JObject { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type; + late final jni.JObjType $type = type; EmojiCompat_GlyphChecker.fromRef( jni.JObjectPtr ref, @@ -1363,9 +1537,15 @@ class EmojiCompat_GlyphChecker extends jni.JObject { ///@param end the exclusive end offset for the emoji in the {@code charSequence} ///@param sdkAdded the API version that the emoji was added in AOSP ///@return true if the given sequence can be rendered as a single glyph, otherwise false. - bool hasGlyph(jni.JObject charSequence, int start, int end, int sdkAdded) => - _hasGlyph(reference, charSequence.reference, start, end, sdkAdded) - .boolean; + bool hasGlyph( + jni.JObject charSequence, + int start, + int end, + int sdkAdded, + ) { + return _hasGlyph(reference, charSequence.reference, start, end, sdkAdded) + .boolean; + } } class $EmojiCompat_GlyphCheckerType @@ -1378,15 +1558,29 @@ class $EmojiCompat_GlyphCheckerType @override EmojiCompat_GlyphChecker fromRef(jni.JObjectPtr ref) => EmojiCompat_GlyphChecker.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($EmojiCompat_GlyphCheckerType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $EmojiCompat_GlyphCheckerType && + other is $EmojiCompat_GlyphCheckerType; + } } /// from: androidx.emoji2.text.EmojiCompat$MetadataRepoLoader /// /// Interface to load emoji metadata. class EmojiCompat_MetadataRepoLoader extends jni.JObject { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type; + late final jni.JObjType $type = type; EmojiCompat_MetadataRepoLoader.fromRef( jni.JObjectPtr ref, @@ -1409,8 +1603,11 @@ class EmojiCompat_MetadataRepoLoader extends jni.JObject { /// MetadataRepoLoaderCallback\#onFailed(Throwable) should be called. When used on /// devices running API 18 or below, this function is never called. ///@param loaderCallback callback to signal the loading state - void load(EmojiCompat_MetadataRepoLoaderCallback loaderCallback) => - _load(reference, loaderCallback.reference).check(); + void load( + EmojiCompat_MetadataRepoLoaderCallback loaderCallback, + ) { + return _load(reference, loaderCallback.reference).check(); + } } class $EmojiCompat_MetadataRepoLoaderType @@ -1424,15 +1621,29 @@ class $EmojiCompat_MetadataRepoLoaderType @override EmojiCompat_MetadataRepoLoader fromRef(jni.JObjectPtr ref) => EmojiCompat_MetadataRepoLoader.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($EmojiCompat_MetadataRepoLoaderType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $EmojiCompat_MetadataRepoLoaderType && + other is $EmojiCompat_MetadataRepoLoaderType; + } } /// from: androidx.emoji2.text.EmojiCompat$InitCallback /// /// Listener class for the initialization of the EmojiCompat. class EmojiCompat_InitCallback extends jni.JObject { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type; + late final jni.JObjType $type = type; EmojiCompat_InitCallback.fromRef( jni.JObjectPtr ref, @@ -1446,7 +1657,9 @@ class EmojiCompat_InitCallback extends jni.JObject { /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. - EmojiCompat_InitCallback() : super.fromRef(_ctor().object); + factory EmojiCompat_InitCallback() { + return EmojiCompat_InitCallback.fromRef(_ctor().object); + } static final _onInitialized = jniLookup< ffi.NativeFunction< @@ -1458,7 +1671,9 @@ class EmojiCompat_InitCallback extends jni.JObject { /// /// Called when EmojiCompat is initialized and the emoji data is loaded. When used on devices /// running API 18 or below, this function is always called. - void onInitialized() => _onInitialized(reference).check(); + void onInitialized() { + return _onInitialized(reference).check(); + } static final _onFailed = jniLookup< ffi.NativeFunction< @@ -1472,8 +1687,11 @@ class EmojiCompat_InitCallback extends jni.JObject { /// /// Called when an unrecoverable error occurs during EmojiCompat initialization. When used on /// devices running API 18 or below, this function is never called. - void onFailed(jni.JObject throwable) => - _onFailed(reference, throwable.reference).check(); + void onFailed( + jni.JObject throwable, + ) { + return _onFailed(reference, throwable.reference).check(); + } } class $EmojiCompat_InitCallbackType @@ -1486,15 +1704,29 @@ class $EmojiCompat_InitCallbackType @override EmojiCompat_InitCallback fromRef(jni.JObjectPtr ref) => EmojiCompat_InitCallback.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($EmojiCompat_InitCallbackType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $EmojiCompat_InitCallbackType && + other is $EmojiCompat_InitCallbackType; + } } /// from: androidx.emoji2.text.EmojiCompat$DefaultSpanFactory /// /// @hide class EmojiCompat_DefaultSpanFactory extends jni.JObject { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type; + late final jni.JObjType $type = type; EmojiCompat_DefaultSpanFactory.fromRef( jni.JObjectPtr ref, @@ -1508,7 +1740,9 @@ class EmojiCompat_DefaultSpanFactory extends jni.JObject { /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. - EmojiCompat_DefaultSpanFactory() : super.fromRef(_ctor().object); + factory EmojiCompat_DefaultSpanFactory() { + return EmojiCompat_DefaultSpanFactory.fromRef(_ctor().object); + } static final _createSpan = jniLookup< ffi.NativeFunction< @@ -1526,8 +1760,12 @@ class EmojiCompat_DefaultSpanFactory extends jni.JObject { ///@param rasterizer TypefaceEmojiRasterizer instance, which can draw the emoji onto a /// Canvas. ///@return TypefaceEmojiSpan - jni.JObject createSpan(jni.JObject rasterizer) => const jni.JObjectType() - .fromRef(_createSpan(reference, rasterizer.reference).object); + jni.JObject createSpan( + jni.JObject rasterizer, + ) { + return const jni.JObjectType() + .fromRef(_createSpan(reference, rasterizer.reference).object); + } } class $EmojiCompat_DefaultSpanFactoryType @@ -1541,6 +1779,21 @@ class $EmojiCompat_DefaultSpanFactoryType @override EmojiCompat_DefaultSpanFactory fromRef(jni.JObjectPtr ref) => EmojiCompat_DefaultSpanFactory.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($EmojiCompat_DefaultSpanFactoryType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $EmojiCompat_DefaultSpanFactoryType && + other is $EmojiCompat_DefaultSpanFactoryType; + } } /// from: androidx.emoji2.text.EmojiCompat$SpanFactory @@ -1552,9 +1805,8 @@ class $EmojiCompat_DefaultSpanFactoryType /// Apps should use this only if they want to control the drawing of EmojiSpans for non-standard /// emoji display (for example, resizing or repositioning emoji). class EmojiCompat_SpanFactory extends jni.JObject { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type; + late final jni.JObjType $type = type; EmojiCompat_SpanFactory.fromRef( jni.JObjectPtr ref, @@ -1578,8 +1830,12 @@ class EmojiCompat_SpanFactory extends jni.JObject { ///@param rasterizer TypefaceEmojiRasterizer instance, which can draw the emoji onto a /// Canvas. ///@return EmojiSpan instance that can use TypefaceEmojiRasterizer to draw emoji. - jni.JObject createSpan(jni.JObject rasterizer) => const jni.JObjectType() - .fromRef(_createSpan(reference, rasterizer.reference).object); + jni.JObject createSpan( + jni.JObject rasterizer, + ) { + return const jni.JObjectType() + .fromRef(_createSpan(reference, rasterizer.reference).object); + } } class $EmojiCompat_SpanFactoryType @@ -1592,6 +1848,21 @@ class $EmojiCompat_SpanFactoryType @override EmojiCompat_SpanFactory fromRef(jni.JObjectPtr ref) => EmojiCompat_SpanFactory.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($EmojiCompat_SpanFactoryType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $EmojiCompat_SpanFactoryType && + other is $EmojiCompat_SpanFactoryType; + } } /// from: androidx.emoji2.text.DefaultEmojiCompatConfig @@ -1631,9 +1902,8 @@ class $EmojiCompat_SpanFactoryType ///

  • It MUST be installed in the system image.
  • /// class DefaultEmojiCompatConfig extends jni.JObject { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type; + late final jni.JObjType $type = type; DefaultEmojiCompatConfig.fromRef( jni.JObjectPtr ref, @@ -1659,8 +1929,11 @@ class DefaultEmojiCompatConfig extends jni.JObject { ///@param context context for lookup ///@return A valid config for downloading the emoji compat font, or null if no font provider /// could be found. - static jni.JObject create(jni.JObject context) => - const jni.JObjectType().fromRef(_create(context.reference).object); + static jni.JObject create( + jni.JObject context, + ) { + return const jni.JObjectType().fromRef(_create(context.reference).object); + } } class $DefaultEmojiCompatConfigType @@ -1673,6 +1946,21 @@ class $DefaultEmojiCompatConfigType @override DefaultEmojiCompatConfig fromRef(jni.JObjectPtr ref) => DefaultEmojiCompatConfig.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($DefaultEmojiCompatConfigType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $DefaultEmojiCompatConfigType && + other is $DefaultEmojiCompatConfigType; + } } /// from: androidx.emoji2.text.DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28 @@ -1681,9 +1969,8 @@ class $DefaultEmojiCompatConfigType ///@hide class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28 extends DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19 { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type; + late final jni.JObjType $type = type; DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28.fromRef( jni.JObjectPtr ref, @@ -1698,8 +1985,10 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28 /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. - DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28() - : super.fromRef(_ctor().object); + factory DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28() { + return DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28 + .fromRef(_ctor().object); + } static final _getSigningSignatures1 = jniLookup< ffi.NativeFunction< @@ -1713,10 +2002,14 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28 /// from: public android.content.pm.Signature[] getSigningSignatures(android.content.pm.PackageManager packageManager, java.lang.String providerPackage) /// The returned object must be deleted after use, by calling the `delete` method. jni.JArray getSigningSignatures1( - jni.JObject packageManager, jni.JString providerPackage) => - const jni.JArrayType(jni.JObjectType()).fromRef(_getSigningSignatures1( - reference, packageManager.reference, providerPackage.reference) - .object); + jni.JObject packageManager, + jni.JString providerPackage, + ) { + return const jni.JArrayType(jni.JObjectType()).fromRef( + _getSigningSignatures1( + reference, packageManager.reference, providerPackage.reference) + .object); + } } class $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28Type @@ -1733,6 +2026,26 @@ class $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28Type jni.JObjectPtr ref) => DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28.fromRef( ref); + + @override + jni.JObjType get superType => + const $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19Type(); + + @override + final superCount = 3; + + @override + int get hashCode => + ($DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28Type) + .hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == + $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28Type && + other + is $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28Type; + } } /// from: androidx.emoji2.text.DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19 @@ -1741,9 +2054,8 @@ class $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28Type ///@hide class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19 extends DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type; + late final jni.JObjType $type = type; DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19.fromRef( jni.JObjectPtr ref, @@ -1758,8 +2070,10 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19 /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. - DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19() - : super.fromRef(_ctor().object); + factory DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19() { + return DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19 + .fromRef(_ctor().object); + } static final _queryIntentContentProviders = jniLookup< ffi.NativeFunction< @@ -1776,10 +2090,14 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19 /// from: public java.util.List queryIntentContentProviders(android.content.pm.PackageManager packageManager, android.content.Intent intent, int flags) /// The returned object must be deleted after use, by calling the `delete` method. jni.JObject queryIntentContentProviders( - jni.JObject packageManager, jni.JObject intent, int flags) => - const jni.JObjectType().fromRef(_queryIntentContentProviders( - reference, packageManager.reference, intent.reference, flags) - .object); + jni.JObject packageManager, + jni.JObject intent, + int flags, + ) { + return const jni.JObjectType().fromRef(_queryIntentContentProviders( + reference, packageManager.reference, intent.reference, flags) + .object); + } static final _getProviderInfo = jniLookup< ffi.NativeFunction< @@ -1792,9 +2110,12 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19 /// from: public android.content.pm.ProviderInfo getProviderInfo(android.content.pm.ResolveInfo resolveInfo) /// The returned object must be deleted after use, by calling the `delete` method. - jni.JObject getProviderInfo(jni.JObject resolveInfo) => - const jni.JObjectType() - .fromRef(_getProviderInfo(reference, resolveInfo.reference).object); + jni.JObject getProviderInfo( + jni.JObject resolveInfo, + ) { + return const jni.JObjectType() + .fromRef(_getProviderInfo(reference, resolveInfo.reference).object); + } } class $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19Type @@ -1811,6 +2132,26 @@ class $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19Type jni.JObjectPtr ref) => DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19.fromRef( ref); + + @override + jni.JObjType get superType => + const $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelperType(); + + @override + final superCount = 2; + + @override + int get hashCode => + ($DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19Type) + .hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == + $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19Type && + other + is $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19Type; + } } /// from: androidx.emoji2.text.DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper @@ -1819,9 +2160,8 @@ class $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19Type ///@hide class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper extends jni.JObject { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type; + late final jni.JObjType $type = type; DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper.fromRef( jni.JObjectPtr ref, @@ -1836,8 +2176,10 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. - DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper() - : super.fromRef(_ctor().object); + factory DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper() { + return DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper.fromRef( + _ctor().object); + } static final _getSigningSignatures = jniLookup< ffi.NativeFunction< @@ -1853,10 +2195,14 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper /// /// Get the signing signatures for a package in package manager. jni.JArray getSigningSignatures( - jni.JObject packageManager, jni.JString providerPackage) => - const jni.JArrayType(jni.JObjectType()).fromRef(_getSigningSignatures( - reference, packageManager.reference, providerPackage.reference) - .object); + jni.JObject packageManager, + jni.JString providerPackage, + ) { + return const jni.JArrayType(jni.JObjectType()).fromRef( + _getSigningSignatures( + reference, packageManager.reference, providerPackage.reference) + .object); + } static final _queryIntentContentProviders = jniLookup< ffi.NativeFunction< @@ -1875,10 +2221,14 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper /// /// Get the content provider by intent. jni.JObject queryIntentContentProviders( - jni.JObject packageManager, jni.JObject intent, int flags) => - const jni.JObjectType().fromRef(_queryIntentContentProviders( - reference, packageManager.reference, intent.reference, flags) - .object); + jni.JObject packageManager, + jni.JObject intent, + int flags, + ) { + return const jni.JObjectType().fromRef(_queryIntentContentProviders( + reference, packageManager.reference, intent.reference, flags) + .object); + } static final _getProviderInfo = jniLookup< ffi.NativeFunction< @@ -1895,9 +2245,12 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper /// Get a ProviderInfo, if present, from a ResolveInfo ///@param resolveInfo the subject ///@return resolveInfo.providerInfo above API 19 - jni.JObject getProviderInfo(jni.JObject resolveInfo) => - const jni.JObjectType() - .fromRef(_getProviderInfo(reference, resolveInfo.reference).object); + jni.JObject getProviderInfo( + jni.JObject resolveInfo, + ) { + return const jni.JObjectType() + .fromRef(_getProviderInfo(reference, resolveInfo.reference).object); + } } class $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelperType extends jni @@ -1912,6 +2265,23 @@ class $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelperType extends jni DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper fromRef( jni.JObjectPtr ref) => DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => + ($DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelperType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == + $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelperType && + other is $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelperType; + } } /// from: androidx.emoji2.text.DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory @@ -1921,9 +2291,8 @@ class $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelperType extends jni ///@hide class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory extends jni.JObject { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type; + late final jni.JObjType $type = type; DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory.fromRef( jni.JObjectPtr ref, @@ -1942,9 +2311,12 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory /// The returned object must be deleted after use, by calling the `delete` method. /// /// @hide - DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory( - DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper helper) - : super.fromRef(_ctor(helper.reference).object); + factory DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory( + DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper helper, + ) { + return DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory.fromRef( + _ctor(helper.reference).object); + } static final _create = jniLookup< ffi.NativeFunction< @@ -1960,9 +2332,12 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory /// /// @see DefaultEmojiCompatConfig\#create ///@hide - EmojiCompat_Config create(jni.JObject context) => - const $EmojiCompat_ConfigType() - .fromRef(_create(reference, context.reference).object); + EmojiCompat_Config create( + jni.JObject context, + ) { + return const $EmojiCompat_ConfigType() + .fromRef(_create(reference, context.reference).object); + } } class $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactoryType extends jni @@ -1977,13 +2352,29 @@ class $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactoryType extends jni DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory fromRef( jni.JObjectPtr ref) => DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => + ($DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactoryType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == + $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactoryType && + other is $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactoryType; + } } /// from: android.os.Build class Build extends jni.JObject { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type; + late final jni.JObjType $type = type; Build.fromRef( jni.JObjectPtr ref, @@ -2264,7 +2655,9 @@ class Build extends jni.JObject { /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. - Build() : super.fromRef(_ctor().object); + factory Build() { + return Build.fromRef(_ctor().object); + } static final _getSerial = jniLookup>( @@ -2273,8 +2666,9 @@ class Build extends jni.JObject { /// from: static public java.lang.String getSerial() /// The returned object must be deleted after use, by calling the `delete` method. - static jni.JString getSerial() => - const jni.JStringType().fromRef(_getSerial().object); + static jni.JString getSerial() { + return const jni.JStringType().fromRef(_getSerial().object); + } static final _getFingerprintedPartitions = jniLookup>( @@ -2283,8 +2677,10 @@ class Build extends jni.JObject { /// from: static public java.util.List getFingerprintedPartitions() /// The returned object must be deleted after use, by calling the `delete` method. - static jni.JObject getFingerprintedPartitions() => - const jni.JObjectType().fromRef(_getFingerprintedPartitions().object); + static jni.JObject getFingerprintedPartitions() { + return const jni.JObjectType() + .fromRef(_getFingerprintedPartitions().object); + } static final _getRadioVersion = jniLookup>( @@ -2293,8 +2689,9 @@ class Build extends jni.JObject { /// from: static public java.lang.String getRadioVersion() /// The returned object must be deleted after use, by calling the `delete` method. - static jni.JString getRadioVersion() => - const jni.JStringType().fromRef(_getRadioVersion().object); + static jni.JString getRadioVersion() { + return const jni.JStringType().fromRef(_getRadioVersion().object); + } } class $BuildType extends jni.JObjType { @@ -2305,32 +2702,46 @@ class $BuildType extends jni.JObjType { @override Build fromRef(jni.JObjectPtr ref) => Build.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($BuildType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $BuildType && other is $BuildType; + } } /// from: java.util.HashMap -class HashMap +class HashMap<$K extends jni.JObject, $V extends jni.JObject> extends jni.JObject { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type($K, $V); + late final jni.JObjType $type = type(K, V); - final jni.JObjType $K; - final jni.JObjType $V; + final jni.JObjType<$K> K; + final jni.JObjType<$V> V; HashMap.fromRef( - this.$K, - this.$V, + this.K, + this.V, jni.JObjectPtr ref, ) : super.fromRef(ref); /// The type which includes information such as the signature of this class. - static $HashMapType type( - jni.JObjType $K, - jni.JObjType $V, + static $HashMapType<$K, $V> + type<$K extends jni.JObject, $V extends jni.JObject>( + jni.JObjType<$K> K, + jni.JObjType<$V> V, ) { return $HashMapType( - $K, - $V, + K, + V, ); } @@ -2341,8 +2752,14 @@ class HashMap /// from: public void (int i, float f) /// The returned object must be deleted after use, by calling the `delete` method. - HashMap(this.$K, this.$V, int i, double f) - : super.fromRef(_ctor(i, f).object); + factory HashMap( + int i, + double f, { + required jni.JObjType<$K> K, + required jni.JObjType<$V> V, + }) { + return HashMap.fromRef(K, V, _ctor(i, f).object); + } static final _ctor1 = jniLookup>( @@ -2351,7 +2768,13 @@ class HashMap /// from: public void (int i) /// The returned object must be deleted after use, by calling the `delete` method. - HashMap.ctor1(this.$K, this.$V, int i) : super.fromRef(_ctor1(i).object); + factory HashMap.ctor1( + int i, { + required jni.JObjType<$K> K, + required jni.JObjType<$V> V, + }) { + return HashMap.fromRef(K, V, _ctor1(i).object); + } static final _ctor2 = jniLookup>("HashMap__ctor2") @@ -2359,7 +2782,12 @@ class HashMap /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. - HashMap.ctor2(this.$K, this.$V) : super.fromRef(_ctor2().object); + factory HashMap.ctor2({ + required jni.JObjType<$K> K, + required jni.JObjType<$V> V, + }) { + return HashMap.fromRef(K, V, _ctor2().object); + } static final _ctor3 = jniLookup< ffi.NativeFunction< @@ -2368,8 +2796,13 @@ class HashMap /// from: public void (java.util.Map map) /// The returned object must be deleted after use, by calling the `delete` method. - HashMap.ctor3(this.$K, this.$V, jni.JObject map) - : super.fromRef(_ctor3(map.reference).object); + factory HashMap.ctor3( + jni.JObject map, { + required jni.JObjType<$K> K, + required jni.JObjType<$V> V, + }) { + return HashMap.fromRef(K, V, _ctor3(map.reference).object); + } static final _size = jniLookup< ffi.NativeFunction< @@ -2377,7 +2810,9 @@ class HashMap .asFunction)>(); /// from: public int size() - int size() => _size(reference).integer; + int size() { + return _size(reference).integer; + } static final _isEmpty = jniLookup< ffi.NativeFunction< @@ -2386,7 +2821,9 @@ class HashMap .asFunction)>(); /// from: public boolean isEmpty() - bool isEmpty() => _isEmpty(reference).boolean; + bool isEmpty() { + return _isEmpty(reference).boolean; + } static final _get0 = jniLookup< ffi.NativeFunction< @@ -2398,8 +2835,11 @@ class HashMap /// from: public V get(java.lang.Object object) /// The returned object must be deleted after use, by calling the `delete` method. - V get0(jni.JObject object) => - $V.fromRef(_get0(reference, object.reference).object); + $V get0( + jni.JObject object, + ) { + return V.fromRef(_get0(reference, object.reference).object); + } static final _containsKey = jniLookup< ffi.NativeFunction< @@ -2410,8 +2850,11 @@ class HashMap ffi.Pointer, ffi.Pointer)>(); /// from: public boolean containsKey(java.lang.Object object) - bool containsKey(jni.JObject object) => - _containsKey(reference, object.reference).boolean; + bool containsKey( + jni.JObject object, + ) { + return _containsKey(reference, object.reference).boolean; + } static final _put = jniLookup< ffi.NativeFunction< @@ -2425,8 +2868,13 @@ class HashMap /// from: public V put(K object, V object1) /// The returned object must be deleted after use, by calling the `delete` method. - V put(K object, V object1) => - $V.fromRef(_put(reference, object.reference, object1.reference).object); + $V put( + $K object, + $V object1, + ) { + return V + .fromRef(_put(reference, object.reference, object1.reference).object); + } static final _putAll = jniLookup< ffi.NativeFunction< @@ -2437,7 +2885,11 @@ class HashMap ffi.Pointer, ffi.Pointer)>(); /// from: public void putAll(java.util.Map map) - void putAll(jni.JObject map) => _putAll(reference, map.reference).check(); + void putAll( + jni.JObject map, + ) { + return _putAll(reference, map.reference).check(); + } static final _remove = jniLookup< ffi.NativeFunction< @@ -2449,8 +2901,11 @@ class HashMap /// from: public V remove(java.lang.Object object) /// The returned object must be deleted after use, by calling the `delete` method. - V remove(jni.JObject object) => - $V.fromRef(_remove(reference, object.reference).object); + $V remove( + jni.JObject object, + ) { + return V.fromRef(_remove(reference, object.reference).object); + } static final _clear = jniLookup< ffi.NativeFunction< @@ -2458,7 +2913,9 @@ class HashMap .asFunction)>(); /// from: public void clear() - void clear() => _clear(reference).check(); + void clear() { + return _clear(reference).check(); + } static final _containsValue = jniLookup< ffi.NativeFunction< @@ -2469,8 +2926,11 @@ class HashMap ffi.Pointer, ffi.Pointer)>(); /// from: public boolean containsValue(java.lang.Object object) - bool containsValue(jni.JObject object) => - _containsValue(reference, object.reference).boolean; + bool containsValue( + jni.JObject object, + ) { + return _containsValue(reference, object.reference).boolean; + } static final _keySet = jniLookup< ffi.NativeFunction< @@ -2479,8 +2939,9 @@ class HashMap /// from: public java.util.Set keySet() /// The returned object must be deleted after use, by calling the `delete` method. - jni.JObject keySet() => - const jni.JObjectType().fromRef(_keySet(reference).object); + jni.JObject keySet() { + return const jni.JObjectType().fromRef(_keySet(reference).object); + } static final _values = jniLookup< ffi.NativeFunction< @@ -2489,8 +2950,9 @@ class HashMap /// from: public java.util.Collection values() /// The returned object must be deleted after use, by calling the `delete` method. - jni.JObject values() => - const jni.JObjectType().fromRef(_values(reference).object); + jni.JObject values() { + return const jni.JObjectType().fromRef(_values(reference).object); + } static final _entrySet = jniLookup< ffi.NativeFunction< @@ -2500,8 +2962,9 @@ class HashMap /// from: public java.util.Set entrySet() /// The returned object must be deleted after use, by calling the `delete` method. - jni.JObject entrySet() => - const jni.JObjectType().fromRef(_entrySet(reference).object); + jni.JObject entrySet() { + return const jni.JObjectType().fromRef(_entrySet(reference).object); + } static final _getOrDefault = jniLookup< ffi.NativeFunction< @@ -2515,8 +2978,13 @@ class HashMap /// from: public V getOrDefault(java.lang.Object object, V object1) /// The returned object must be deleted after use, by calling the `delete` method. - V getOrDefault(jni.JObject object, V object1) => $V.fromRef( - _getOrDefault(reference, object.reference, object1.reference).object); + $V getOrDefault( + jni.JObject object, + $V object1, + ) { + return V.fromRef( + _getOrDefault(reference, object.reference, object1.reference).object); + } static final _putIfAbsent = jniLookup< ffi.NativeFunction< @@ -2530,8 +2998,13 @@ class HashMap /// from: public V putIfAbsent(K object, V object1) /// The returned object must be deleted after use, by calling the `delete` method. - V putIfAbsent(K object, V object1) => $V.fromRef( - _putIfAbsent(reference, object.reference, object1.reference).object); + $V putIfAbsent( + $K object, + $V object1, + ) { + return V.fromRef( + _putIfAbsent(reference, object.reference, object1.reference).object); + } static final _remove1 = jniLookup< ffi.NativeFunction< @@ -2544,8 +3017,12 @@ class HashMap ffi.Pointer)>(); /// from: public boolean remove(java.lang.Object object, java.lang.Object object1) - bool remove1(jni.JObject object, jni.JObject object1) => - _remove1(reference, object.reference, object1.reference).boolean; + bool remove1( + jni.JObject object, + jni.JObject object1, + ) { + return _remove1(reference, object.reference, object1.reference).boolean; + } static final _replace = jniLookup< ffi.NativeFunction< @@ -2559,9 +3036,15 @@ class HashMap ffi.Pointer, ffi.Pointer)>(); /// from: public boolean replace(K object, V object1, V object2) - bool replace(K object, V object1, V object2) => _replace( - reference, object.reference, object1.reference, object2.reference) - .boolean; + bool replace( + $K object, + $V object1, + $V object2, + ) { + return _replace( + reference, object.reference, object1.reference, object2.reference) + .boolean; + } static final _replace1 = jniLookup< ffi.NativeFunction< @@ -2575,8 +3058,13 @@ class HashMap /// from: public V replace(K object, V object1) /// The returned object must be deleted after use, by calling the `delete` method. - V replace1(K object, V object1) => $V.fromRef( - _replace1(reference, object.reference, object1.reference).object); + $V replace1( + $K object, + $V object1, + ) { + return V.fromRef( + _replace1(reference, object.reference, object1.reference).object); + } static final _computeIfAbsent = jniLookup< ffi.NativeFunction< @@ -2590,8 +3078,14 @@ class HashMap /// from: public V computeIfAbsent(K object, java.util.function.Function function) /// The returned object must be deleted after use, by calling the `delete` method. - V computeIfAbsent(K object, jni.JObject function) => $V.fromRef( - _computeIfAbsent(reference, object.reference, function.reference).object); + $V computeIfAbsent( + $K object, + jni.JObject function, + ) { + return V.fromRef( + _computeIfAbsent(reference, object.reference, function.reference) + .object); + } static final _computeIfPresent = jniLookup< ffi.NativeFunction< @@ -2605,9 +3099,14 @@ class HashMap /// from: public V computeIfPresent(K object, java.util.function.BiFunction biFunction) /// The returned object must be deleted after use, by calling the `delete` method. - V computeIfPresent(K object, jni.JObject biFunction) => $V.fromRef( - _computeIfPresent(reference, object.reference, biFunction.reference) - .object); + $V computeIfPresent( + $K object, + jni.JObject biFunction, + ) { + return V.fromRef( + _computeIfPresent(reference, object.reference, biFunction.reference) + .object); + } static final _compute = jniLookup< ffi.NativeFunction< @@ -2621,8 +3120,13 @@ class HashMap /// from: public V compute(K object, java.util.function.BiFunction biFunction) /// The returned object must be deleted after use, by calling the `delete` method. - V compute(K object, jni.JObject biFunction) => $V.fromRef( - _compute(reference, object.reference, biFunction.reference).object); + $V compute( + $K object, + jni.JObject biFunction, + ) { + return V.fromRef( + _compute(reference, object.reference, biFunction.reference).object); + } static final _merge = jniLookup< ffi.NativeFunction< @@ -2637,9 +3141,15 @@ class HashMap /// from: public V merge(K object, V object1, java.util.function.BiFunction biFunction) /// The returned object must be deleted after use, by calling the `delete` method. - V merge(K object, V object1, jni.JObject biFunction) => $V.fromRef(_merge( - reference, object.reference, object1.reference, biFunction.reference) - .object); + $V merge( + $K object, + $V object1, + jni.JObject biFunction, + ) { + return V.fromRef(_merge(reference, object.reference, object1.reference, + biFunction.reference) + .object); + } static final _forEach = jniLookup< ffi.NativeFunction< @@ -2650,8 +3160,11 @@ class HashMap ffi.Pointer, ffi.Pointer)>(); /// from: public void forEach(java.util.function.BiConsumer biConsumer) - void forEach(jni.JObject biConsumer) => - _forEach(reference, biConsumer.reference).check(); + void forEach( + jni.JObject biConsumer, + ) { + return _forEach(reference, biConsumer.reference).check(); + } static final _replaceAll = jniLookup< ffi.NativeFunction< @@ -2662,8 +3175,11 @@ class HashMap ffi.Pointer, ffi.Pointer)>(); /// from: public void replaceAll(java.util.function.BiFunction biFunction) - void replaceAll(jni.JObject biFunction) => - _replaceAll(reference, biFunction.reference).check(); + void replaceAll( + jni.JObject biFunction, + ) { + return _replaceAll(reference, biFunction.reference).check(); + } static final _clone = jniLookup< ffi.NativeFunction< @@ -2672,23 +3188,41 @@ class HashMap /// from: public java.lang.Object clone() /// The returned object must be deleted after use, by calling the `delete` method. - jni.JObject clone() => - const jni.JObjectType().fromRef(_clone(reference).object); + jni.JObject clone() { + return const jni.JObjectType().fromRef(_clone(reference).object); + } } -class $HashMapType - extends jni.JObjType> { - final jni.JObjType $K; - final jni.JObjType $V; +class $HashMapType<$K extends jni.JObject, $V extends jni.JObject> + extends jni.JObjType> { + final jni.JObjType<$K> K; + final jni.JObjType<$V> V; const $HashMapType( - this.$K, - this.$V, + this.K, + this.V, ); @override String get signature => r"Ljava/util/HashMap;"; @override - HashMap fromRef(jni.JObjectPtr ref) => HashMap.fromRef($K, $V, ref); + HashMap<$K, $V> fromRef(jni.JObjectPtr ref) => HashMap.fromRef(K, V, ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => Object.hash($HashMapType, K, V); + + @override + bool operator ==(Object other) { + return other.runtimeType == $HashMapType && + other is $HashMapType && + K == other.K && + V == other.V; + } } diff --git a/pkgs/jnigen/example/in_app_java/lib/main.dart b/pkgs/jnigen/example/in_app_java/lib/main.dart index f4354283a..7765b9c1a 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.dart'; JObject activity = JObject.fromRef(Jni.getCurrentActivity()); JObject context = JObject.fromRef(Jni.getCachedApplicationContext()); -final hashmap = HashMap.ctor2(JString.type, JString.type); +final hashmap = HashMap.ctor2(K: JString.type, V: JString.type); final emojiCompat = EmojiCompat.get0(); diff --git a/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart b/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart index b6a9bcaf9..3485f937e 100644 --- a/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart +++ b/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart @@ -26,9 +26,8 @@ final ffi.Pointer Function(String sym) jniLookup = /// from: Example class Example extends jni.JObject { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type; + late final jni.JObjType $type = type; Example.fromRef( jni.JObjectPtr ref, @@ -42,7 +41,9 @@ class Example extends jni.JObject { /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. - Example() : super.fromRef(_ctor().object); + factory Example() { + return Example.fromRef(_ctor().object); + } static final _thinkBeforeAnswering = jniLookup< ffi.NativeFunction< @@ -75,4 +76,18 @@ class $ExampleType extends jni.JObjType { @override Example fromRef(jni.JObjectPtr ref) => Example.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($ExampleType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $ExampleType && other is $ExampleType; + } } diff --git a/pkgs/jnigen/example/notification_plugin/lib/notifications.dart b/pkgs/jnigen/example/notification_plugin/lib/notifications.dart index 7d93c7cf8..5a4d5591a 100644 --- a/pkgs/jnigen/example/notification_plugin/lib/notifications.dart +++ b/pkgs/jnigen/example/notification_plugin/lib/notifications.dart @@ -30,9 +30,8 @@ final ffi.Pointer Function(String sym) jniLookup = /// from: com.example.notification_plugin.Notifications class Notifications extends jni.JObject { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type; + late final jni.JObjType $type = type; Notifications.fromRef( jni.JObjectPtr ref, @@ -46,7 +45,9 @@ class Notifications extends jni.JObject { /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. - Notifications() : super.fromRef(_ctor().object); + factory Notifications() { + return Notifications.fromRef(_ctor().object); + } static final _showNotification = jniLookup< ffi.NativeFunction< @@ -60,11 +61,16 @@ class Notifications extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: static public void showNotification(android.content.Context context, int notificationID, java.lang.String title, java.lang.String text) - static void showNotification(jni.JObject context, int notificationID, - jni.JString title, jni.JString text) => - _showNotification(context.reference, notificationID, title.reference, - text.reference) - .check(); + static void showNotification( + jni.JObject context, + int notificationID, + jni.JString title, + jni.JString text, + ) { + return _showNotification( + context.reference, notificationID, title.reference, text.reference) + .check(); + } } class $NotificationsType extends jni.JObjType { @@ -75,4 +81,19 @@ class $NotificationsType extends jni.JObjType { @override Notifications fromRef(jni.JObjectPtr ref) => Notifications.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($NotificationsType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $NotificationsType && + other is $NotificationsType; + } } 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 ebafa96f3..ec0d86036 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 @@ -46,9 +46,8 @@ import "../../../../_init.dart"; /// The \#close() method must be called once the document is no longer needed. ///@author Ben Litchfield class PDDocument extends jni.JObject { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type; + late final jni.JObjType $type = type; PDDocument.fromRef( jni.JObjectPtr ref, @@ -65,7 +64,9 @@ class PDDocument extends jni.JObject { /// /// Creates an empty PDF document. /// You need to add at least one page for the document to be valid. - PDDocument() : super.fromRef(_ctor().object); + factory PDDocument() { + return PDDocument.fromRef(_ctor().object); + } static final _ctor1 = jniLookup< ffi.NativeFunction< @@ -79,8 +80,11 @@ class PDDocument extends jni.JObject { /// Creates an empty PDF document. /// You need to add at least one page for the document to be valid. ///@param memUsageSetting defines how memory is used for buffering PDF streams - PDDocument.ctor1(jni.JObject memUsageSetting) - : super.fromRef(_ctor1(memUsageSetting.reference).object); + factory PDDocument.ctor1( + jni.JObject memUsageSetting, + ) { + return PDDocument.fromRef(_ctor1(memUsageSetting.reference).object); + } static final _ctor2 = jniLookup< ffi.NativeFunction< @@ -93,8 +97,11 @@ class PDDocument extends jni.JObject { /// /// Constructor that uses an existing document. The COSDocument that is passed in must be valid. ///@param doc The COSDocument that this document wraps. - PDDocument.ctor2(jni.JObject doc) - : super.fromRef(_ctor2(doc.reference).object); + factory PDDocument.ctor2( + jni.JObject doc, + ) { + return PDDocument.fromRef(_ctor2(doc.reference).object); + } static final _ctor3 = jniLookup< ffi.NativeFunction< @@ -110,8 +117,12 @@ class PDDocument extends jni.JObject { /// Constructor that uses an existing document. The COSDocument that is passed in must be valid. ///@param doc The COSDocument that this document wraps. ///@param source the parser which is used to read the pdf - PDDocument.ctor3(jni.JObject doc, jni.JObject source) - : super.fromRef(_ctor3(doc.reference, source.reference).object); + factory PDDocument.ctor3( + jni.JObject doc, + jni.JObject source, + ) { + return PDDocument.fromRef(_ctor3(doc.reference, source.reference).object); + } static final _ctor4 = jniLookup< ffi.NativeFunction< @@ -130,10 +141,14 @@ class PDDocument extends jni.JObject { ///@param doc The COSDocument that this document wraps. ///@param source the parser which is used to read the pdf ///@param permission he access permissions of the pdf - PDDocument.ctor4(jni.JObject doc, jni.JObject source, jni.JObject permission) - : super.fromRef( - _ctor4(doc.reference, source.reference, permission.reference) - .object); + factory PDDocument.ctor4( + jni.JObject doc, + jni.JObject source, + jni.JObject permission, + ) { + return PDDocument.fromRef( + _ctor4(doc.reference, source.reference, permission.reference).object); + } static final _addPage = jniLookup< ffi.NativeFunction< @@ -148,7 +163,11 @@ class PDDocument extends jni.JObject { /// 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) => _addPage(reference, page.reference).check(); + void addPage( + jni.JObject page, + ) { + return _addPage(reference, page.reference).check(); + } static final _addSignature = jniLookup< ffi.NativeFunction< @@ -170,8 +189,11 @@ class PDDocument extends jni.JObject { ///@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) => - _addSignature(reference, sigObject.reference).check(); + void addSignature( + jni.JObject sigObject, + ) { + return _addSignature(reference, sigObject.reference).check(); + } static final _addSignature1 = jniLookup< ffi.NativeFunction< @@ -196,8 +218,13 @@ class PDDocument extends jni.JObject { ///@throws IOException if there is an error creating required fields ///@throws IllegalStateException if one attempts to add several signature /// fields. - void addSignature1(jni.JObject sigObject, jni.JObject options) => - _addSignature1(reference, sigObject.reference, options.reference).check(); + void addSignature1( + jni.JObject sigObject, + jni.JObject options, + ) { + return _addSignature1(reference, sigObject.reference, options.reference) + .check(); + } static final _addSignature2 = jniLookup< ffi.NativeFunction< @@ -221,10 +248,14 @@ class PDDocument extends jni.JObject { ///@throws IOException if there is an error creating required fields ///@throws IllegalStateException if one attempts to add several signature /// fields. - void addSignature2(jni.JObject sigObject, jni.JObject signatureInterface) => - _addSignature2( - reference, sigObject.reference, signatureInterface.reference) - .check(); + void addSignature2( + jni.JObject sigObject, + jni.JObject signatureInterface, + ) { + return _addSignature2( + reference, sigObject.reference, signatureInterface.reference) + .check(); + } static final _addSignature3 = jniLookup< ffi.NativeFunction< @@ -252,11 +283,15 @@ class PDDocument extends jni.JObject { ///@throws IOException if there is an error creating required fields ///@throws IllegalStateException if one attempts to add several signature /// fields. - void addSignature3(jni.JObject sigObject, jni.JObject signatureInterface, - jni.JObject options) => - _addSignature3(reference, sigObject.reference, - signatureInterface.reference, options.reference) - .check(); + void addSignature3( + jni.JObject sigObject, + jni.JObject signatureInterface, + jni.JObject options, + ) { + return _addSignature3(reference, sigObject.reference, + signatureInterface.reference, options.reference) + .check(); + } static final _addSignatureField = jniLookup< ffi.NativeFunction< @@ -279,11 +314,15 @@ class PDDocument extends jni.JObject { ///@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.JObject sigFields, jni.JObject signatureInterface, - jni.JObject options) => - _addSignatureField(reference, sigFields.reference, - signatureInterface.reference, options.reference) - .check(); + void addSignatureField( + jni.JObject sigFields, + jni.JObject signatureInterface, + jni.JObject options, + ) { + return _addSignatureField(reference, sigFields.reference, + signatureInterface.reference, options.reference) + .check(); + } static final _removePage = jniLookup< ffi.NativeFunction< @@ -297,8 +336,11 @@ class PDDocument extends jni.JObject { /// /// Remove the page from the document. ///@param page The page to remove from the document. - void removePage(jni.JObject page) => - _removePage(reference, page.reference).check(); + void removePage( + jni.JObject page, + ) { + return _removePage(reference, page.reference).check(); + } static final _removePage1 = jniLookup< ffi.NativeFunction< @@ -310,8 +352,11 @@ class PDDocument extends jni.JObject { /// /// Remove the page from the document. ///@param pageNumber 0 based index to page number. - void removePage1(int pageNumber) => - _removePage1(reference, pageNumber).check(); + void removePage1( + int pageNumber, + ) { + return _removePage1(reference, pageNumber).check(); + } static final _importPage = jniLookup< ffi.NativeFunction< @@ -345,8 +390,12 @@ class PDDocument extends jni.JObject { ///@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) => const jni.JObjectType() - .fromRef(_importPage(reference, page.reference).object); + jni.JObject importPage( + jni.JObject page, + ) { + return const jni.JObjectType() + .fromRef(_importPage(reference, page.reference).object); + } static final _getDocument = jniLookup< ffi.NativeFunction< @@ -359,8 +408,9 @@ class PDDocument extends jni.JObject { /// /// This will get the low level document. ///@return The document that this layer sits on top of. - jni.JObject getDocument() => - const jni.JObjectType().fromRef(_getDocument(reference).object); + jni.JObject getDocument() { + return const jni.JObjectType().fromRef(_getDocument(reference).object); + } static final _getDocumentInformation = jniLookup< ffi.NativeFunction< @@ -378,9 +428,10 @@ class PDDocument extends jni.JObject { /// document level metadata, a metadata stream should be used instead, see /// PDDocumentCatalog\#getMetadata(). ///@return The documents /Info dictionary, never null. - pddocumentinformation_.PDDocumentInformation getDocumentInformation() => - const pddocumentinformation_.$PDDocumentInformationType() - .fromRef(_getDocumentInformation(reference).object); + pddocumentinformation_.PDDocumentInformation getDocumentInformation() { + return const pddocumentinformation_.$PDDocumentInformationType() + .fromRef(_getDocumentInformation(reference).object); + } static final _setDocumentInformation = jniLookup< ffi.NativeFunction< @@ -399,8 +450,10 @@ class PDDocument extends jni.JObject { /// PDDocumentCatalog\#setMetadata(org.apache.pdfbox.pdmodel.common.PDMetadata) PDDocumentCatalog\#setMetadata(PDMetadata). ///@param info The updated document information. void setDocumentInformation( - pddocumentinformation_.PDDocumentInformation info) => - _setDocumentInformation(reference, info.reference).check(); + pddocumentinformation_.PDDocumentInformation info, + ) { + return _setDocumentInformation(reference, info.reference).check(); + } static final _getDocumentCatalog = jniLookup< ffi.NativeFunction< @@ -413,8 +466,10 @@ class PDDocument extends jni.JObject { /// /// This will get the document CATALOG. This is guaranteed to not return null. ///@return The documents /Root dictionary - jni.JObject getDocumentCatalog() => - const jni.JObjectType().fromRef(_getDocumentCatalog(reference).object); + jni.JObject getDocumentCatalog() { + return const jni.JObjectType() + .fromRef(_getDocumentCatalog(reference).object); + } static final _isEncrypted = jniLookup< ffi.NativeFunction< @@ -426,7 +481,9 @@ class PDDocument extends jni.JObject { /// /// This will tell if this document is encrypted or not. ///@return true If this document is encrypted. - bool isEncrypted() => _isEncrypted(reference).boolean; + bool isEncrypted() { + return _isEncrypted(reference).boolean; + } static final _getEncryption = jniLookup< ffi.NativeFunction< @@ -442,8 +499,9 @@ class PDDocument extends jni.JObject { /// but the only supported subclass at this time is a /// PDStandardEncryption object. ///@return The encryption dictionary(most likely a PDStandardEncryption object) - jni.JObject getEncryption() => - const jni.JObjectType().fromRef(_getEncryption(reference).object); + jni.JObject getEncryption() { + return const jni.JObjectType().fromRef(_getEncryption(reference).object); + } static final _setEncryptionDictionary = jniLookup< ffi.NativeFunction< @@ -459,8 +517,11 @@ class PDDocument extends jni.JObject { /// 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) => - _setEncryptionDictionary(reference, encryption.reference).check(); + void setEncryptionDictionary( + jni.JObject encryption, + ) { + return _setEncryptionDictionary(reference, encryption.reference).check(); + } static final _getLastSignatureDictionary = jniLookup< ffi.NativeFunction< @@ -475,8 +536,10 @@ class PDDocument extends jni.JObject { /// 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() => const jni.JObjectType() - .fromRef(_getLastSignatureDictionary(reference).object); + jni.JObject getLastSignatureDictionary() { + return const jni.JObjectType() + .fromRef(_getLastSignatureDictionary(reference).object); + } static final _getSignatureFields = jniLookup< ffi.NativeFunction< @@ -490,8 +553,10 @@ class PDDocument extends jni.JObject { /// Retrieve all signature fields from the document. ///@return a List of PDSignatureFields ///@throws IOException if no document catalog can be found. - jni.JObject getSignatureFields() => - const jni.JObjectType().fromRef(_getSignatureFields(reference).object); + jni.JObject getSignatureFields() { + return const jni.JObjectType() + .fromRef(_getSignatureFields(reference).object); + } static final _getSignatureDictionaries = jniLookup< ffi.NativeFunction< @@ -505,8 +570,10 @@ class PDDocument extends jni.JObject { /// Retrieve all signature dictionaries from the document. ///@return a List of PDSignatureFields ///@throws IOException if no document catalog can be found. - jni.JObject getSignatureDictionaries() => const jni.JObjectType() - .fromRef(_getSignatureDictionaries(reference).object); + jni.JObject getSignatureDictionaries() { + return const jni.JObjectType() + .fromRef(_getSignatureDictionaries(reference).object); + } static final _registerTrueTypeFontForClosing = jniLookup< ffi.NativeFunction< @@ -523,8 +590,11 @@ class PDDocument extends jni.JObject { /// 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) => - _registerTrueTypeFontForClosing(reference, ttf.reference).check(); + void registerTrueTypeFontForClosing( + jni.JObject ttf, + ) { + return _registerTrueTypeFontForClosing(reference, ttf.reference).check(); + } static final _load = jniLookup< ffi.NativeFunction< @@ -540,8 +610,11 @@ class PDDocument extends jni.JObject { ///@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) => - const $PDDocumentType().fromRef(_load(file.reference).object); + static PDDocument load( + jni.JObject file, + ) { + return const $PDDocumentType().fromRef(_load(file.reference).object); + } static final _load1 = jniLookup< ffi.NativeFunction< @@ -560,9 +633,13 @@ class PDDocument extends jni.JObject { ///@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 load1(jni.JObject file, jni.JObject memUsageSetting) => - const $PDDocumentType() - .fromRef(_load1(file.reference, memUsageSetting.reference).object); + static PDDocument load1( + jni.JObject file, + jni.JObject memUsageSetting, + ) { + return const $PDDocumentType() + .fromRef(_load1(file.reference, memUsageSetting.reference).object); + } static final _load2 = jniLookup< ffi.NativeFunction< @@ -581,9 +658,13 @@ class PDDocument extends jni.JObject { ///@return loaded document ///@throws InvalidPasswordException If the password is incorrect. ///@throws IOException in case of a file reading or parsing error - static PDDocument load2(jni.JObject file, jni.JString password) => - const $PDDocumentType() - .fromRef(_load2(file.reference, password.reference).object); + static PDDocument load2( + jni.JObject file, + jni.JString password, + ) { + return const $PDDocumentType() + .fromRef(_load2(file.reference, password.reference).object); + } static final _load3 = jniLookup< ffi.NativeFunction< @@ -605,11 +686,15 @@ class PDDocument extends jni.JObject { ///@return loaded document ///@throws InvalidPasswordException If the password is incorrect. ///@throws IOException in case of a file reading or parsing error - static PDDocument load3(jni.JObject file, jni.JString password, - jni.JObject memUsageSetting) => - const $PDDocumentType().fromRef( - _load3(file.reference, password.reference, memUsageSetting.reference) - .object); + static PDDocument load3( + jni.JObject file, + jni.JString password, + jni.JObject memUsageSetting, + ) { + return const $PDDocumentType().fromRef( + _load3(file.reference, password.reference, memUsageSetting.reference) + .object); + } static final _load4 = jniLookup< ffi.NativeFunction< @@ -632,11 +717,16 @@ class PDDocument extends jni.JObject { ///@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 load4(jni.JObject file, jni.JString password, - jni.JObject keyStore, jni.JString alias) => - const $PDDocumentType().fromRef(_load4(file.reference, password.reference, - keyStore.reference, alias.reference) - .object); + static PDDocument load4( + jni.JObject file, + jni.JString password, + jni.JObject keyStore, + jni.JString alias, + ) { + return const $PDDocumentType().fromRef(_load4(file.reference, + password.reference, keyStore.reference, alias.reference) + .object); + } static final _load5 = jniLookup< ffi.NativeFunction< @@ -666,14 +756,20 @@ class PDDocument extends jni.JObject { ///@return loaded document ///@throws IOException in case of a file reading or parsing error static PDDocument load5( - jni.JObject file, - jni.JString password, - jni.JObject keyStore, - jni.JString alias, - jni.JObject memUsageSetting) => - const $PDDocumentType().fromRef(_load5(file.reference, password.reference, - keyStore.reference, alias.reference, memUsageSetting.reference) - .object); + jni.JObject file, + jni.JString password, + jni.JObject keyStore, + jni.JString alias, + jni.JObject memUsageSetting, + ) { + return const $PDDocumentType().fromRef(_load5( + file.reference, + password.reference, + keyStore.reference, + alias.reference, + memUsageSetting.reference) + .object); + } static final _load6 = jniLookup< ffi.NativeFunction< @@ -690,8 +786,11 @@ class PDDocument extends jni.JObject { ///@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 load6(jni.JObject input) => - const $PDDocumentType().fromRef(_load6(input.reference).object); + static PDDocument load6( + jni.JObject input, + ) { + return const $PDDocumentType().fromRef(_load6(input.reference).object); + } static final _load7 = jniLookup< ffi.NativeFunction< @@ -711,9 +810,13 @@ class PDDocument extends jni.JObject { ///@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 load7(jni.JObject input, jni.JObject memUsageSetting) => - const $PDDocumentType() - .fromRef(_load7(input.reference, memUsageSetting.reference).object); + static PDDocument load7( + jni.JObject input, + jni.JObject memUsageSetting, + ) { + return const $PDDocumentType() + .fromRef(_load7(input.reference, memUsageSetting.reference).object); + } static final _load8 = jniLookup< ffi.NativeFunction< @@ -733,9 +836,13 @@ class PDDocument extends jni.JObject { ///@return loaded document ///@throws InvalidPasswordException If the password is incorrect. ///@throws IOException In case of a reading or parsing error. - static PDDocument load8(jni.JObject input, jni.JString password) => - const $PDDocumentType() - .fromRef(_load8(input.reference, password.reference).object); + static PDDocument load8( + jni.JObject input, + jni.JString password, + ) { + return const $PDDocumentType() + .fromRef(_load8(input.reference, password.reference).object); + } static final _load9 = jniLookup< ffi.NativeFunction< @@ -759,11 +866,16 @@ class PDDocument extends jni.JObject { ///@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 load9(jni.JObject input, jni.JString password, - jni.JObject keyStore, jni.JString alias) => - const $PDDocumentType().fromRef(_load9(input.reference, - password.reference, keyStore.reference, alias.reference) - .object); + static PDDocument load9( + jni.JObject input, + jni.JString password, + jni.JObject keyStore, + jni.JString alias, + ) { + return const $PDDocumentType().fromRef(_load9(input.reference, + password.reference, keyStore.reference, alias.reference) + .object); + } static final _load10 = jniLookup< ffi.NativeFunction< @@ -786,11 +898,15 @@ class PDDocument extends jni.JObject { ///@return loaded document ///@throws InvalidPasswordException If the password is incorrect. ///@throws IOException In case of a reading or parsing error. - static PDDocument load10(jni.JObject input, jni.JString password, - jni.JObject memUsageSetting) => - const $PDDocumentType().fromRef(_load10( - input.reference, password.reference, memUsageSetting.reference) - .object); + static PDDocument load10( + jni.JObject input, + jni.JString password, + jni.JObject memUsageSetting, + ) { + return const $PDDocumentType().fromRef( + _load10(input.reference, password.reference, memUsageSetting.reference) + .object); + } static final _load11 = jniLookup< ffi.NativeFunction< @@ -822,18 +938,20 @@ class PDDocument extends jni.JObject { ///@throws InvalidPasswordException If the password is incorrect. ///@throws IOException In case of a reading or parsing error. static PDDocument load11( - jni.JObject input, - jni.JString password, - jni.JObject keyStore, - jni.JString alias, - jni.JObject memUsageSetting) => - const $PDDocumentType().fromRef(_load11( - input.reference, - password.reference, - keyStore.reference, - alias.reference, - memUsageSetting.reference) - .object); + jni.JObject input, + jni.JString password, + jni.JObject keyStore, + jni.JString alias, + jni.JObject memUsageSetting, + ) { + return const $PDDocumentType().fromRef(_load11( + input.reference, + password.reference, + keyStore.reference, + alias.reference, + memUsageSetting.reference) + .object); + } static final _load12 = jniLookup< ffi.NativeFunction< @@ -849,8 +967,11 @@ class PDDocument extends jni.JObject { ///@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 load12(jni.JArray input) => - const $PDDocumentType().fromRef(_load12(input.reference).object); + static PDDocument load12( + jni.JArray input, + ) { + return const $PDDocumentType().fromRef(_load12(input.reference).object); + } static final _load13 = jniLookup< ffi.NativeFunction< @@ -869,9 +990,13 @@ class PDDocument extends jni.JObject { ///@return loaded document ///@throws InvalidPasswordException If the password is incorrect. ///@throws IOException In case of a reading or parsing error. - static PDDocument load13(jni.JArray input, jni.JString password) => - const $PDDocumentType() - .fromRef(_load13(input.reference, password.reference).object); + static PDDocument load13( + jni.JArray input, + jni.JString password, + ) { + return const $PDDocumentType() + .fromRef(_load13(input.reference, password.reference).object); + } static final _load14 = jniLookup< ffi.NativeFunction< @@ -895,11 +1020,16 @@ class PDDocument extends jni.JObject { ///@return loaded document ///@throws InvalidPasswordException If the password is incorrect. ///@throws IOException In case of a reading or parsing error. - static PDDocument load14(jni.JArray input, jni.JString password, - jni.JObject keyStore, jni.JString alias) => - const $PDDocumentType().fromRef(_load14(input.reference, - password.reference, keyStore.reference, alias.reference) - .object); + static PDDocument load14( + jni.JArray input, + jni.JString password, + jni.JObject keyStore, + jni.JString alias, + ) { + return const $PDDocumentType().fromRef(_load14(input.reference, + password.reference, keyStore.reference, alias.reference) + .object); + } static final _load15 = jniLookup< ffi.NativeFunction< @@ -930,18 +1060,20 @@ class PDDocument extends jni.JObject { ///@throws InvalidPasswordException If the password is incorrect. ///@throws IOException In case of a reading or parsing error. static PDDocument load15( - jni.JArray input, - jni.JString password, - jni.JObject keyStore, - jni.JString alias, - jni.JObject memUsageSetting) => - const $PDDocumentType().fromRef(_load15( - input.reference, - password.reference, - keyStore.reference, - alias.reference, - memUsageSetting.reference) - .object); + jni.JArray input, + jni.JString password, + jni.JObject keyStore, + jni.JString alias, + jni.JObject memUsageSetting, + ) { + return const $PDDocumentType().fromRef(_load15( + input.reference, + password.reference, + keyStore.reference, + alias.reference, + memUsageSetting.reference) + .object); + } static final _save = jniLookup< ffi.NativeFunction< @@ -960,8 +1092,11 @@ class PDDocument extends jni.JObject { /// do not use the document after saving because the contents are now encrypted. ///@param fileName The file to save as. ///@throws IOException if the output could not be written - void save(jni.JString fileName) => - _save(reference, fileName.reference).check(); + void save( + jni.JString fileName, + ) { + return _save(reference, fileName.reference).check(); + } static final _save1 = jniLookup< ffi.NativeFunction< @@ -980,7 +1115,11 @@ class PDDocument extends jni.JObject { /// do not use the document after saving because the contents are now encrypted. ///@param file The file to save as. ///@throws IOException if the output could not be written - void save1(jni.JObject file) => _save1(reference, file.reference).check(); + void save1( + jni.JObject file, + ) { + return _save1(reference, file.reference).check(); + } static final _save2 = jniLookup< ffi.NativeFunction< @@ -1000,7 +1139,11 @@ class PDDocument extends jni.JObject { ///@param output The stream to write to. It will be closed when done. It is recommended to wrap /// it in a java.io.BufferedOutputStream, unless it is already buffered. ///@throws IOException if the output could not be written - void save2(jni.JObject output) => _save2(reference, output.reference).check(); + void save2( + jni.JObject output, + ) { + return _save2(reference, output.reference).check(); + } static final _saveIncremental = jniLookup< ffi.NativeFunction< @@ -1025,8 +1168,11 @@ class PDDocument extends jni.JObject { /// harmed! ///@throws IOException if the output could not be written ///@throws IllegalStateException if the document was not loaded from a file or a stream. - void saveIncremental(jni.JObject output) => - _saveIncremental(reference, output.reference).check(); + void saveIncremental( + jni.JObject output, + ) { + return _saveIncremental(reference, output.reference).check(); + } static final _saveIncremental1 = jniLookup< ffi.NativeFunction< @@ -1058,9 +1204,14 @@ class PDDocument extends jni.JObject { ///@param objectsToWrite objects that __must__ be part of the incremental saving. ///@throws IOException if the output could not be written ///@throws IllegalStateException if the document was not loaded from a file or a stream. - void saveIncremental1(jni.JObject output, jni.JObject objectsToWrite) => - _saveIncremental1(reference, output.reference, objectsToWrite.reference) - .check(); + void saveIncremental1( + jni.JObject output, + jni.JObject objectsToWrite, + ) { + return _saveIncremental1( + reference, output.reference, objectsToWrite.reference) + .check(); + } static final _saveIncrementalForExternalSigning = jniLookup< ffi.NativeFunction< @@ -1111,10 +1262,12 @@ class PDDocument extends jni.JObject { ///@throws IOException if the output could not be written ///@throws IllegalStateException if the document was not loaded from a file or a stream or /// signature options were not set. - jni.JObject saveIncrementalForExternalSigning(jni.JObject output) => - const jni.JObjectType().fromRef( - _saveIncrementalForExternalSigning(reference, output.reference) - .object); + jni.JObject saveIncrementalForExternalSigning( + jni.JObject output, + ) { + return const jni.JObjectType().fromRef( + _saveIncrementalForExternalSigning(reference, output.reference).object); + } static final _getPage = jniLookup< ffi.NativeFunction< @@ -1132,8 +1285,12 @@ class PDDocument extends jni.JObject { /// PDDocument\#getPages() instead. ///@param pageIndex the 0-based page index ///@return the page at the given index. - jni.JObject getPage(int pageIndex) => - const jni.JObjectType().fromRef(_getPage(reference, pageIndex).object); + jni.JObject getPage( + int pageIndex, + ) { + return const jni.JObjectType() + .fromRef(_getPage(reference, pageIndex).object); + } static final _getPages = jniLookup< ffi.NativeFunction< @@ -1146,8 +1303,9 @@ class PDDocument extends jni.JObject { /// /// Returns the page tree. ///@return the page tree - jni.JObject getPages() => - const jni.JObjectType().fromRef(_getPages(reference).object); + jni.JObject getPages() { + return const jni.JObjectType().fromRef(_getPages(reference).object); + } static final _getNumberOfPages = jniLookup< ffi.NativeFunction< @@ -1159,7 +1317,9 @@ 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() => _getNumberOfPages(reference).integer; + int getNumberOfPages() { + return _getNumberOfPages(reference).integer; + } static final _close = jniLookup< ffi.NativeFunction< @@ -1171,7 +1331,9 @@ 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).check(); + void close() { + return _close(reference).check(); + } static final _protect = jniLookup< ffi.NativeFunction< @@ -1193,8 +1355,11 @@ class PDDocument extends jni.JObject { ///@see org.apache.pdfbox.pdmodel.encryption.PublicKeyProtectionPolicy ///@param policy The protection policy. ///@throws IOException if there isn't any suitable security handler. - void protect(jni.JObject policy) => - _protect(reference, policy.reference).check(); + void protect( + jni.JObject policy, + ) { + return _protect(reference, policy.reference).check(); + } static final _getCurrentAccessPermission = jniLookup< ffi.NativeFunction< @@ -1210,8 +1375,10 @@ class PDDocument extends jni.JObject { /// only mode so that permissions cannot be changed. Methods providing access to content should rely on this object /// to verify if the current user is allowed to proceed. ///@return the access permissions for the current user on the document. - jni.JObject getCurrentAccessPermission() => const jni.JObjectType() - .fromRef(_getCurrentAccessPermission(reference).object); + jni.JObject getCurrentAccessPermission() { + return const jni.JObjectType() + .fromRef(_getCurrentAccessPermission(reference).object); + } static final _isAllSecurityToBeRemoved = jniLookup< ffi.NativeFunction< @@ -1223,8 +1390,9 @@ 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 - bool isAllSecurityToBeRemoved() => - _isAllSecurityToBeRemoved(reference).boolean; + bool isAllSecurityToBeRemoved() { + return _isAllSecurityToBeRemoved(reference).boolean; + } static final _setAllSecurityToBeRemoved = jniLookup< ffi.NativeFunction< @@ -1236,8 +1404,12 @@ class PDDocument extends jni.JObject { /// /// Activates/Deactivates the removal of all security when writing the pdf. ///@param removeAllSecurity remove all security if set to true - void setAllSecurityToBeRemoved(bool removeAllSecurity) => - _setAllSecurityToBeRemoved(reference, removeAllSecurity ? 1 : 0).check(); + void setAllSecurityToBeRemoved( + bool removeAllSecurity, + ) { + return _setAllSecurityToBeRemoved(reference, removeAllSecurity ? 1 : 0) + .check(); + } static final _getDocumentId = jniLookup< ffi.NativeFunction< @@ -1250,8 +1422,9 @@ class PDDocument extends jni.JObject { /// /// Provides the document ID. ///@return the document ID - jni.JObject getDocumentId() => - const jni.JObjectType().fromRef(_getDocumentId(reference).object); + jni.JObject getDocumentId() { + return const jni.JObjectType().fromRef(_getDocumentId(reference).object); + } static final _setDocumentId = jniLookup< ffi.NativeFunction< @@ -1265,8 +1438,11 @@ class PDDocument extends jni.JObject { /// /// Sets the document ID to the given value. ///@param docId the new document ID - void setDocumentId(jni.JObject docId) => - _setDocumentId(reference, docId.reference).check(); + void setDocumentId( + jni.JObject docId, + ) { + return _setDocumentId(reference, docId.reference).check(); + } static final _getVersion = jniLookup< ffi.NativeFunction< @@ -1278,7 +1454,9 @@ class PDDocument extends jni.JObject { /// /// Returns the PDF specification version this document conforms to. ///@return the PDF version (e.g. 1.4f) - double getVersion() => _getVersion(reference).float; + double getVersion() { + return _getVersion(reference).float; + } static final _setVersion = jniLookup< ffi.NativeFunction< @@ -1290,8 +1468,11 @@ class PDDocument extends jni.JObject { /// /// Sets the PDF specification version for this document. ///@param newVersion the new PDF version (e.g. 1.4f) - void setVersion(double newVersion) => - _setVersion(reference, newVersion).check(); + void setVersion( + double newVersion, + ) { + return _setVersion(reference, newVersion).check(); + } static final _getResourceCache = jniLookup< ffi.NativeFunction< @@ -1304,8 +1485,9 @@ 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() => - const jni.JObjectType().fromRef(_getResourceCache(reference).object); + jni.JObject getResourceCache() { + return const jni.JObjectType().fromRef(_getResourceCache(reference).object); + } static final _setResourceCache = jniLookup< ffi.NativeFunction< @@ -1319,8 +1501,11 @@ class PDDocument extends jni.JObject { /// /// Sets the resource cache associated with this document. ///@param resourceCache A resource cache, or null. - void setResourceCache(jni.JObject resourceCache) => - _setResourceCache(reference, resourceCache.reference).check(); + void setResourceCache( + jni.JObject resourceCache, + ) { + return _setResourceCache(reference, resourceCache.reference).check(); + } } class $PDDocumentType extends jni.JObjType { @@ -1331,4 +1516,18 @@ class $PDDocumentType extends jni.JObjType { @override PDDocument fromRef(jni.JObjectPtr ref) => PDDocument.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($PDDocumentType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $PDDocumentType && other is $PDDocumentType; + } } 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 bcb265542..90134bc21 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 @@ -47,9 +47,8 @@ import "../../../../_init.dart"; ///@author Ben Litchfield ///@author Gerardo Ortiz class PDDocumentInformation extends jni.JObject { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type; + late final jni.JObjType $type = type; PDDocumentInformation.fromRef( jni.JObjectPtr ref, @@ -65,7 +64,9 @@ class PDDocumentInformation extends jni.JObject { /// The returned object must be deleted after use, by calling the `delete` method. /// /// Default Constructor. - PDDocumentInformation() : super.fromRef(_ctor().object); + factory PDDocumentInformation() { + return PDDocumentInformation.fromRef(_ctor().object); + } static final _ctor1 = jniLookup< ffi.NativeFunction< @@ -78,8 +79,11 @@ class PDDocumentInformation extends jni.JObject { /// /// Constructor that is used for a preexisting dictionary. ///@param dic The underlying dictionary. - PDDocumentInformation.ctor1(jni.JObject dic) - : super.fromRef(_ctor1(dic.reference).object); + factory PDDocumentInformation.ctor1( + jni.JObject dic, + ) { + return PDDocumentInformation.fromRef(_ctor1(dic.reference).object); + } static final _getCOSObject = jniLookup< ffi.NativeFunction< @@ -92,8 +96,9 @@ class PDDocumentInformation extends jni.JObject { /// /// This will get the underlying dictionary that this object wraps. ///@return The underlying info dictionary. - jni.JObject getCOSObject() => - const jni.JObjectType().fromRef(_getCOSObject(reference).object); + jni.JObject getCOSObject() { + return const jni.JObjectType().fromRef(_getCOSObject(reference).object); + } static final _getPropertyStringValue = jniLookup< ffi.NativeFunction< @@ -115,9 +120,12 @@ class PDDocumentInformation extends jni.JObject { /// ///@param propertyKey the dictionaries key ///@return the properties value - jni.JObject getPropertyStringValue(jni.JString propertyKey) => - const jni.JObjectType().fromRef( - _getPropertyStringValue(reference, propertyKey.reference).object); + jni.JObject getPropertyStringValue( + jni.JString propertyKey, + ) { + return const jni.JObjectType().fromRef( + _getPropertyStringValue(reference, propertyKey.reference).object); + } static final _getTitle = jniLookup< ffi.NativeFunction< @@ -130,8 +138,9 @@ 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() => - const jni.JStringType().fromRef(_getTitle(reference).object); + jni.JString getTitle() { + return const jni.JStringType().fromRef(_getTitle(reference).object); + } static final _setTitle = jniLookup< ffi.NativeFunction< @@ -145,8 +154,11 @@ class PDDocumentInformation extends jni.JObject { /// /// This will set the title of the document. ///@param title The new title for the document. - void setTitle(jni.JString title) => - _setTitle(reference, title.reference).check(); + void setTitle( + jni.JString title, + ) { + return _setTitle(reference, title.reference).check(); + } static final _getAuthor = jniLookup< ffi.NativeFunction< @@ -159,8 +171,9 @@ 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() => - const jni.JStringType().fromRef(_getAuthor(reference).object); + jni.JString getAuthor() { + return const jni.JStringType().fromRef(_getAuthor(reference).object); + } static final _setAuthor = jniLookup< ffi.NativeFunction< @@ -174,8 +187,11 @@ class PDDocumentInformation extends jni.JObject { /// /// This will set the author of the document. ///@param author The new author for the document. - void setAuthor(jni.JString author) => - _setAuthor(reference, author.reference).check(); + void setAuthor( + jni.JString author, + ) { + return _setAuthor(reference, author.reference).check(); + } static final _getSubject = jniLookup< ffi.NativeFunction< @@ -188,8 +204,9 @@ 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() => - const jni.JStringType().fromRef(_getSubject(reference).object); + jni.JString getSubject() { + return const jni.JStringType().fromRef(_getSubject(reference).object); + } static final _setSubject = jniLookup< ffi.NativeFunction< @@ -203,8 +220,11 @@ class PDDocumentInformation extends jni.JObject { /// /// This will set the subject of the document. ///@param subject The new subject for the document. - void setSubject(jni.JString subject) => - _setSubject(reference, subject.reference).check(); + void setSubject( + jni.JString subject, + ) { + return _setSubject(reference, subject.reference).check(); + } static final _getKeywords = jniLookup< ffi.NativeFunction< @@ -217,8 +237,9 @@ 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() => - const jni.JStringType().fromRef(_getKeywords(reference).object); + jni.JString getKeywords() { + return const jni.JStringType().fromRef(_getKeywords(reference).object); + } static final _setKeywords = jniLookup< ffi.NativeFunction< @@ -232,8 +253,11 @@ class PDDocumentInformation extends jni.JObject { /// /// This will set the keywords of the document. ///@param keywords The new keywords for the document. - void setKeywords(jni.JString keywords) => - _setKeywords(reference, keywords.reference).check(); + void setKeywords( + jni.JString keywords, + ) { + return _setKeywords(reference, keywords.reference).check(); + } static final _getCreator = jniLookup< ffi.NativeFunction< @@ -246,8 +270,9 @@ 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() => - const jni.JStringType().fromRef(_getCreator(reference).object); + jni.JString getCreator() { + return const jni.JStringType().fromRef(_getCreator(reference).object); + } static final _setCreator = jniLookup< ffi.NativeFunction< @@ -261,8 +286,11 @@ class PDDocumentInformation extends jni.JObject { /// /// This will set the creator of the document. ///@param creator The new creator for the document. - void setCreator(jni.JString creator) => - _setCreator(reference, creator.reference).check(); + void setCreator( + jni.JString creator, + ) { + return _setCreator(reference, creator.reference).check(); + } static final _getProducer = jniLookup< ffi.NativeFunction< @@ -275,8 +303,9 @@ 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() => - const jni.JStringType().fromRef(_getProducer(reference).object); + jni.JString getProducer() { + return const jni.JStringType().fromRef(_getProducer(reference).object); + } static final _setProducer = jniLookup< ffi.NativeFunction< @@ -290,8 +319,11 @@ class PDDocumentInformation extends jni.JObject { /// /// This will set the producer of the document. ///@param producer The new producer for the document. - void setProducer(jni.JString producer) => - _setProducer(reference, producer.reference).check(); + void setProducer( + jni.JString producer, + ) { + return _setProducer(reference, producer.reference).check(); + } static final _getCreationDate = jniLookup< ffi.NativeFunction< @@ -304,8 +336,9 @@ 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() => - const jni.JObjectType().fromRef(_getCreationDate(reference).object); + jni.JObject getCreationDate() { + return const jni.JObjectType().fromRef(_getCreationDate(reference).object); + } static final _setCreationDate = jniLookup< ffi.NativeFunction< @@ -320,8 +353,11 @@ class PDDocumentInformation extends jni.JObject { /// /// This will set the creation date of the document. ///@param date The new creation date for the document. - void setCreationDate(jni.JObject date) => - _setCreationDate(reference, date.reference).check(); + void setCreationDate( + jni.JObject date, + ) { + return _setCreationDate(reference, date.reference).check(); + } static final _getModificationDate = jniLookup< ffi.NativeFunction< @@ -334,8 +370,10 @@ class PDDocumentInformation extends jni.JObject { /// /// This will get the modification date of the document. This will return null if no modification date exists. ///@return The modification date of the document. - jni.JObject getModificationDate() => - const jni.JObjectType().fromRef(_getModificationDate(reference).object); + jni.JObject getModificationDate() { + return const jni.JObjectType() + .fromRef(_getModificationDate(reference).object); + } static final _setModificationDate = jniLookup< ffi.NativeFunction< @@ -350,8 +388,11 @@ class PDDocumentInformation extends jni.JObject { /// /// This will set the modification date of the document. ///@param date The new modification date for the document. - void setModificationDate(jni.JObject date) => - _setModificationDate(reference, date.reference).check(); + void setModificationDate( + jni.JObject date, + ) { + return _setModificationDate(reference, date.reference).check(); + } static final _getTrapped = jniLookup< ffi.NativeFunction< @@ -365,8 +406,9 @@ class PDDocumentInformation extends jni.JObject { /// This will get the trapped value for the document. /// This will return null if one is not found. ///@return The trapped value for the document. - jni.JString getTrapped() => - const jni.JStringType().fromRef(_getTrapped(reference).object); + jni.JString getTrapped() { + return const jni.JStringType().fromRef(_getTrapped(reference).object); + } static final _getMetadataKeys = jniLookup< ffi.NativeFunction< @@ -380,8 +422,9 @@ class PDDocumentInformation extends jni.JObject { /// This will get the keys of all metadata information fields for the document. ///@return all metadata key strings. ///@since Apache PDFBox 1.3.0 - jni.JObject getMetadataKeys() => - const jni.JObjectType().fromRef(_getMetadataKeys(reference).object); + jni.JObject getMetadataKeys() { + return const jni.JObjectType().fromRef(_getMetadataKeys(reference).object); + } static final _getCustomMetadataValue = jniLookup< ffi.NativeFunction< @@ -399,9 +442,12 @@ class PDDocumentInformation extends jni.JObject { /// This will return null if one is not found. ///@param fieldName Name of custom metadata field from pdf document. ///@return String Value of metadata field - jni.JString getCustomMetadataValue(jni.JString fieldName) => - const jni.JStringType().fromRef( - _getCustomMetadataValue(reference, fieldName.reference).object); + jni.JString getCustomMetadataValue( + jni.JString fieldName, + ) { + return const jni.JStringType().fromRef( + _getCustomMetadataValue(reference, fieldName.reference).object); + } static final _setCustomMetadataValue = jniLookup< ffi.NativeFunction< @@ -417,10 +463,14 @@ class PDDocumentInformation extends jni.JObject { /// Set the custom metadata value. ///@param fieldName The name of the custom metadata field. ///@param fieldValue The value to the custom metadata field. - void setCustomMetadataValue(jni.JString fieldName, jni.JString fieldValue) => - _setCustomMetadataValue( - reference, fieldName.reference, fieldValue.reference) - .check(); + void setCustomMetadataValue( + jni.JString fieldName, + jni.JString fieldValue, + ) { + return _setCustomMetadataValue( + reference, fieldName.reference, fieldValue.reference) + .check(); + } static final _setTrapped = jniLookup< ffi.NativeFunction< @@ -436,8 +486,11 @@ class PDDocumentInformation extends jni.JObject { /// 'True', 'False', or 'Unknown'. ///@param value The new trapped value for the document. ///@throws IllegalArgumentException if the parameter is invalid. - void setTrapped(jni.JString value) => - _setTrapped(reference, value.reference).check(); + void setTrapped( + jni.JString value, + ) { + return _setTrapped(reference, value.reference).check(); + } } class $PDDocumentInformationType extends jni.JObjType { @@ -449,4 +502,19 @@ class $PDDocumentInformationType extends jni.JObjType { @override PDDocumentInformation fromRef(jni.JObjectPtr ref) => PDDocumentInformation.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($PDDocumentInformationType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $PDDocumentInformationType && + other is $PDDocumentInformationType; + } } 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 ccf668b97..ee0339135 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 @@ -50,9 +50,8 @@ import "../../../../_init.dart"; /// 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 { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type; + late final jni.JObjType $type = type; PDFTextStripper.fromRef( jni.JObjectPtr ref, @@ -193,7 +192,9 @@ class PDFTextStripper extends jni.JObject { /// /// Instantiate a new PDFTextStripper object. ///@throws IOException If there is an error loading the properties. - PDFTextStripper() : super.fromRef(_ctor().object); + factory PDFTextStripper() { + return PDFTextStripper.fromRef(_ctor().object); + } static final _getText = jniLookup< ffi.NativeFunction< @@ -216,8 +217,12 @@ class PDFTextStripper extends jni.JObject { ///@param doc The document to get the text from. ///@return The text of the PDF document. ///@throws IOException if the doc state is invalid or it is encrypted. - jni.JString getText(pddocument_.PDDocument doc) => const jni.JStringType() - .fromRef(_getText(reference, doc.reference).object); + jni.JString getText( + pddocument_.PDDocument doc, + ) { + return const jni.JStringType() + .fromRef(_getText(reference, doc.reference).object); + } static final _writeText = jniLookup< ffi.NativeFunction< @@ -235,8 +240,12 @@ class PDFTextStripper extends jni.JObject { ///@param doc The document to get the data from. ///@param outputStream The location to put the text. ///@throws IOException If the doc is in an invalid state. - void writeText(pddocument_.PDDocument doc, jni.JObject outputStream) => - _writeText(reference, doc.reference, outputStream.reference).check(); + void writeText( + pddocument_.PDDocument doc, + jni.JObject outputStream, + ) { + return _writeText(reference, doc.reference, outputStream.reference).check(); + } static final _processPages = jniLookup< ffi.NativeFunction< @@ -251,8 +260,11 @@ class PDFTextStripper extends jni.JObject { /// This will process all of the pages and the text that is in them. ///@param pages The pages object in the document. ///@throws IOException If there is an error parsing the text. - void processPages(jni.JObject pages) => - _processPages(reference, pages.reference).check(); + void processPages( + jni.JObject pages, + ) { + return _processPages(reference, pages.reference).check(); + } static final _startDocument = jniLookup< ffi.NativeFunction< @@ -267,8 +279,11 @@ class PDFTextStripper extends jni.JObject { /// This method is available for subclasses of this class. It will be called before processing of the document start. ///@param document The PDF document that is being processed. ///@throws IOException If an IO error occurs. - void startDocument(pddocument_.PDDocument document) => - _startDocument(reference, document.reference).check(); + void startDocument( + pddocument_.PDDocument document, + ) { + return _startDocument(reference, document.reference).check(); + } static final _endDocument = jniLookup< ffi.NativeFunction< @@ -284,8 +299,11 @@ class PDFTextStripper extends jni.JObject { /// finishes. ///@param document The PDF document that is being processed. ///@throws IOException If an IO error occurs. - void endDocument(pddocument_.PDDocument document) => - _endDocument(reference, document.reference).check(); + void endDocument( + pddocument_.PDDocument document, + ) { + return _endDocument(reference, document.reference).check(); + } static final _processPage = jniLookup< ffi.NativeFunction< @@ -300,8 +318,11 @@ class PDFTextStripper extends jni.JObject { /// This will process the contents of a page. ///@param page The page to process. ///@throws IOException If there is an error processing the page. - void processPage(jni.JObject page) => - _processPage(reference, page.reference).check(); + void processPage( + jni.JObject page, + ) { + return _processPage(reference, page.reference).check(); + } static final _startArticle = jniLookup< ffi.NativeFunction< @@ -315,7 +336,9 @@ class PDFTextStripper extends jni.JObject { /// assumes that the primary direction of text is left to right. Default implementation is to do nothing. Subclasses /// may provide additional information. ///@throws IOException If there is any error writing to the stream. - void startArticle() => _startArticle(reference).check(); + void startArticle() { + return _startArticle(reference).check(); + } static final _startArticle1 = jniLookup< ffi.NativeFunction< @@ -329,8 +352,11 @@ class PDFTextStripper extends jni.JObject { /// Default implementation is to do nothing. Subclasses may provide additional information. ///@param isLTR true if primary direction of text is left to right. ///@throws IOException If there is any error writing to the stream. - void startArticle1(bool isLTR) => - _startArticle1(reference, isLTR ? 1 : 0).check(); + void startArticle1( + bool isLTR, + ) { + return _startArticle1(reference, isLTR ? 1 : 0).check(); + } static final _endArticle = jniLookup< ffi.NativeFunction< @@ -342,7 +368,9 @@ class PDFTextStripper extends jni.JObject { /// /// End an article. Default implementation is to do nothing. Subclasses may provide additional information. ///@throws IOException If there is any error writing to the stream. - void endArticle() => _endArticle(reference).check(); + void endArticle() { + return _endArticle(reference).check(); + } static final _startPage = jniLookup< ffi.NativeFunction< @@ -357,8 +385,11 @@ class PDFTextStripper extends jni.JObject { /// Start a new page. Default implementation is to do nothing. Subclasses may provide additional information. ///@param page The page we are about to process. ///@throws IOException If there is any error writing to the stream. - void startPage(jni.JObject page) => - _startPage(reference, page.reference).check(); + void startPage( + jni.JObject page, + ) { + return _startPage(reference, page.reference).check(); + } static final _endPage = jniLookup< ffi.NativeFunction< @@ -373,7 +404,11 @@ class PDFTextStripper extends jni.JObject { /// End a page. Default implementation is to do nothing. Subclasses may provide additional information. ///@param page The page we are about to process. ///@throws IOException If there is any error writing to the stream. - void endPage(jni.JObject page) => _endPage(reference, page.reference).check(); + void endPage( + jni.JObject page, + ) { + return _endPage(reference, page.reference).check(); + } static final _writePage = jniLookup< ffi.NativeFunction< @@ -387,7 +422,9 @@ class PDFTextStripper extends jni.JObject { /// text, where newlines and word spacings should be placed. The text will be sorted only if that feature was /// enabled. ///@throws IOException If there is an error writing the text. - void writePage() => _writePage(reference).check(); + void writePage() { + return _writePage(reference).check(); + } static final _writeLineSeparator = jniLookup< ffi.NativeFunction< @@ -399,7 +436,9 @@ class PDFTextStripper extends jni.JObject { /// /// Write the line separator value to the output stream. ///@throws IOException If there is a problem writing out the line separator to the document. - void writeLineSeparator() => _writeLineSeparator(reference).check(); + void writeLineSeparator() { + return _writeLineSeparator(reference).check(); + } static final _writeWordSeparator = jniLookup< ffi.NativeFunction< @@ -411,7 +450,9 @@ class PDFTextStripper extends jni.JObject { /// /// Write the word separator value to the output stream. ///@throws IOException If there is a problem writing out the word separator to the document. - void writeWordSeparator() => _writeWordSeparator(reference).check(); + void writeWordSeparator() { + return _writeWordSeparator(reference).check(); + } static final _writeCharacters = jniLookup< ffi.NativeFunction< @@ -426,8 +467,11 @@ class PDFTextStripper extends jni.JObject { /// Write the string in TextPosition to the output stream. ///@param text The text to write to the stream. ///@throws IOException If there is an error when writing the text. - void writeCharacters(jni.JObject text) => - _writeCharacters(reference, text.reference).check(); + void writeCharacters( + jni.JObject text, + ) { + return _writeCharacters(reference, text.reference).check(); + } static final _writeString = jniLookup< ffi.NativeFunction< @@ -446,8 +490,13 @@ class PDFTextStripper extends jni.JObject { ///@param text The text to write to the stream. ///@param textPositions The TextPositions belonging to the text. ///@throws IOException If there is an error when writing the text. - void writeString(jni.JString text, jni.JObject textPositions) => - _writeString(reference, text.reference, textPositions.reference).check(); + void writeString( + jni.JString text, + jni.JObject textPositions, + ) { + return _writeString(reference, text.reference, textPositions.reference) + .check(); + } static final _writeString1 = jniLookup< ffi.NativeFunction< @@ -462,8 +511,11 @@ class PDFTextStripper extends jni.JObject { /// Write a Java string to the output stream. ///@param text The text to write to the stream. ///@throws IOException If there is an error when writing the text. - void writeString1(jni.JString text) => - _writeString1(reference, text.reference).check(); + void writeString1( + jni.JString text, + ) { + return _writeString1(reference, text.reference).check(); + } static final _processTextPosition = jniLookup< ffi.NativeFunction< @@ -479,8 +531,11 @@ class PDFTextStripper extends jni.JObject { /// This will process a TextPosition object and add the text to the list of characters on a page. It takes care of /// overlapping text. ///@param text The text to process. - void processTextPosition(jni.JObject text) => - _processTextPosition(reference, text.reference).check(); + void processTextPosition( + jni.JObject text, + ) { + return _processTextPosition(reference, text.reference).check(); + } static final _getStartPage = jniLookup< ffi.NativeFunction< @@ -494,7 +549,9 @@ class PDFTextStripper extends jni.JObject { /// document, if the start page is 1 then all pages will be extracted. If the start page is 4 then pages 4 and 5 will /// be extracted. The default value is 1. ///@return Value of property startPage. - int getStartPage() => _getStartPage(reference).integer; + int getStartPage() { + return _getStartPage(reference).integer; + } static final _setStartPage = jniLookup< ffi.NativeFunction< @@ -506,8 +563,11 @@ class PDFTextStripper extends jni.JObject { /// /// This will set the first page to be extracted by this class. ///@param startPageValue New value of 1-based startPage property. - void setStartPage(int startPageValue) => - _setStartPage(reference, startPageValue).check(); + void setStartPage( + int startPageValue, + ) { + return _setStartPage(reference, startPageValue).check(); + } static final _getEndPage = jniLookup< ffi.NativeFunction< @@ -521,7 +581,9 @@ class PDFTextStripper extends jni.JObject { /// value of 5 would extract the entire document, an end page of 2 would extract pages 1 and 2. This defaults to /// Integer.MAX_VALUE such that all pages of the pdf will be extracted. ///@return Value of property endPage. - int getEndPage() => _getEndPage(reference).integer; + int getEndPage() { + return _getEndPage(reference).integer; + } static final _setEndPage = jniLookup< ffi.NativeFunction< @@ -533,8 +595,11 @@ class PDFTextStripper extends jni.JObject { /// /// This will set the last page to be extracted by this class. ///@param endPageValue New value of 1-based endPage property. - void setEndPage(int endPageValue) => - _setEndPage(reference, endPageValue).check(); + void setEndPage( + int endPageValue, + ) { + return _setEndPage(reference, endPageValue).check(); + } static final _setLineSeparator = jniLookup< ffi.NativeFunction< @@ -549,8 +614,11 @@ class PDFTextStripper extends jni.JObject { /// Set the desired line separator for output text. The line.separator system property is used if the line separator /// preference is not set explicitly using this method. ///@param separator The desired line separator string. - void setLineSeparator(jni.JString separator) => - _setLineSeparator(reference, separator.reference).check(); + void setLineSeparator( + jni.JString separator, + ) { + return _setLineSeparator(reference, separator.reference).check(); + } static final _getLineSeparator = jniLookup< ffi.NativeFunction< @@ -563,8 +631,9 @@ class PDFTextStripper extends jni.JObject { /// /// This will get the line separator. ///@return The desired line separator string. - jni.JString getLineSeparator() => - const jni.JStringType().fromRef(_getLineSeparator(reference).object); + jni.JString getLineSeparator() { + return const jni.JStringType().fromRef(_getLineSeparator(reference).object); + } static final _getWordSeparator = jniLookup< ffi.NativeFunction< @@ -577,8 +646,9 @@ class PDFTextStripper extends jni.JObject { /// /// This will get the word separator. ///@return The desired word separator string. - jni.JString getWordSeparator() => - const jni.JStringType().fromRef(_getWordSeparator(reference).object); + jni.JString getWordSeparator() { + return const jni.JStringType().fromRef(_getWordSeparator(reference).object); + } static final _setWordSeparator = jniLookup< ffi.NativeFunction< @@ -595,8 +665,11 @@ class PDFTextStripper extends jni.JObject { /// accurate count of characters that are found in a PDF document then you might want to set the word separator to /// the empty string. ///@param separator The desired page separator string. - void setWordSeparator(jni.JString separator) => - _setWordSeparator(reference, separator.reference).check(); + void setWordSeparator( + jni.JString separator, + ) { + return _setWordSeparator(reference, separator.reference).check(); + } static final _getSuppressDuplicateOverlappingText = jniLookup< ffi.NativeFunction< @@ -607,8 +680,9 @@ class PDFTextStripper extends jni.JObject { /// from: public boolean getSuppressDuplicateOverlappingText() /// /// @return Returns the suppressDuplicateOverlappingText. - bool getSuppressDuplicateOverlappingText() => - _getSuppressDuplicateOverlappingText(reference).boolean; + bool getSuppressDuplicateOverlappingText() { + return _getSuppressDuplicateOverlappingText(reference).boolean; + } static final _getCurrentPageNo = jniLookup< ffi.NativeFunction< @@ -620,7 +694,9 @@ class PDFTextStripper extends jni.JObject { /// /// Get the current page number that is being processed. ///@return A 1 based number representing the current page. - int getCurrentPageNo() => _getCurrentPageNo(reference).integer; + int getCurrentPageNo() { + return _getCurrentPageNo(reference).integer; + } static final _getOutput = jniLookup< ffi.NativeFunction< @@ -633,8 +709,9 @@ class PDFTextStripper extends jni.JObject { /// /// The output stream that is being written to. ///@return The stream that output is being written to. - jni.JObject getOutput() => - const jni.JObjectType().fromRef(_getOutput(reference).object); + jni.JObject getOutput() { + return const jni.JObjectType().fromRef(_getOutput(reference).object); + } static final _getCharactersByArticle = jniLookup< ffi.NativeFunction< @@ -648,8 +725,10 @@ class PDFTextStripper extends jni.JObject { /// Character strings are grouped by articles. It is quite common that there will only be a single article. This /// returns a List that contains List objects, the inner lists will contain TextPosition objects. ///@return A double List of TextPositions for all text strings on the page. - jni.JObject getCharactersByArticle() => const jni.JObjectType() - .fromRef(_getCharactersByArticle(reference).object); + jni.JObject getCharactersByArticle() { + return const jni.JObjectType() + .fromRef(_getCharactersByArticle(reference).object); + } static final _setSuppressDuplicateOverlappingText = jniLookup< ffi.NativeFunction< @@ -664,10 +743,12 @@ class PDFTextStripper extends jni.JObject { /// means that certain sections will be duplicated, but better performance will be noticed. ///@param suppressDuplicateOverlappingTextValue The suppressDuplicateOverlappingText to set. void setSuppressDuplicateOverlappingText( - bool suppressDuplicateOverlappingTextValue) => - _setSuppressDuplicateOverlappingText( - reference, suppressDuplicateOverlappingTextValue ? 1 : 0) - .check(); + bool suppressDuplicateOverlappingTextValue, + ) { + return _setSuppressDuplicateOverlappingText( + reference, suppressDuplicateOverlappingTextValue ? 1 : 0) + .check(); + } static final _getSeparateByBeads = jniLookup< ffi.NativeFunction< @@ -679,7 +760,9 @@ class PDFTextStripper extends jni.JObject { /// /// This will tell if the text stripper should separate by beads. ///@return If the text will be grouped by beads. - bool getSeparateByBeads() => _getSeparateByBeads(reference).boolean; + bool getSeparateByBeads() { + return _getSeparateByBeads(reference).boolean; + } static final _setShouldSeparateByBeads = jniLookup< ffi.NativeFunction< @@ -691,9 +774,12 @@ class PDFTextStripper extends jni.JObject { /// /// Set if the text stripper should group the text output by a list of beads. The default value is true! ///@param aShouldSeparateByBeads The new grouping of beads. - void setShouldSeparateByBeads(bool aShouldSeparateByBeads) => - _setShouldSeparateByBeads(reference, aShouldSeparateByBeads ? 1 : 0) - .check(); + void setShouldSeparateByBeads( + bool aShouldSeparateByBeads, + ) { + return _setShouldSeparateByBeads(reference, aShouldSeparateByBeads ? 1 : 0) + .check(); + } static final _getEndBookmark = jniLookup< ffi.NativeFunction< @@ -706,8 +792,9 @@ class PDFTextStripper extends jni.JObject { /// /// Get the bookmark where text extraction should end, inclusive. Default is null. ///@return The ending bookmark. - jni.JObject getEndBookmark() => - const jni.JObjectType().fromRef(_getEndBookmark(reference).object); + jni.JObject getEndBookmark() { + return const jni.JObjectType().fromRef(_getEndBookmark(reference).object); + } static final _setEndBookmark = jniLookup< ffi.NativeFunction< @@ -721,8 +808,11 @@ class PDFTextStripper extends jni.JObject { /// /// Set the bookmark where the text extraction should stop. ///@param aEndBookmark The ending bookmark. - void setEndBookmark(jni.JObject aEndBookmark) => - _setEndBookmark(reference, aEndBookmark.reference).check(); + void setEndBookmark( + jni.JObject aEndBookmark, + ) { + return _setEndBookmark(reference, aEndBookmark.reference).check(); + } static final _getStartBookmark = jniLookup< ffi.NativeFunction< @@ -735,8 +825,9 @@ class PDFTextStripper extends jni.JObject { /// /// Get the bookmark where text extraction should start, inclusive. Default is null. ///@return The starting bookmark. - jni.JObject getStartBookmark() => - const jni.JObjectType().fromRef(_getStartBookmark(reference).object); + jni.JObject getStartBookmark() { + return const jni.JObjectType().fromRef(_getStartBookmark(reference).object); + } static final _setStartBookmark = jniLookup< ffi.NativeFunction< @@ -750,8 +841,11 @@ class PDFTextStripper extends jni.JObject { /// /// Set the bookmark where text extraction should start, inclusive. ///@param aStartBookmark The starting bookmark. - void setStartBookmark(jni.JObject aStartBookmark) => - _setStartBookmark(reference, aStartBookmark.reference).check(); + void setStartBookmark( + jni.JObject aStartBookmark, + ) { + return _setStartBookmark(reference, aStartBookmark.reference).check(); + } static final _getAddMoreFormatting = jniLookup< ffi.NativeFunction< @@ -763,7 +857,9 @@ class PDFTextStripper extends jni.JObject { /// /// This will tell if the text stripper should add some more text formatting. ///@return true if some more text formatting will be added - bool getAddMoreFormatting() => _getAddMoreFormatting(reference).boolean; + bool getAddMoreFormatting() { + return _getAddMoreFormatting(reference).boolean; + } static final _setAddMoreFormatting = jniLookup< ffi.NativeFunction< @@ -775,8 +871,12 @@ class PDFTextStripper extends jni.JObject { /// /// There will some additional text formatting be added if addMoreFormatting is set to true. Default is false. ///@param newAddMoreFormatting Tell PDFBox to add some more text formatting - void setAddMoreFormatting(bool newAddMoreFormatting) => - _setAddMoreFormatting(reference, newAddMoreFormatting ? 1 : 0).check(); + void setAddMoreFormatting( + bool newAddMoreFormatting, + ) { + return _setAddMoreFormatting(reference, newAddMoreFormatting ? 1 : 0) + .check(); + } static final _getSortByPosition = jniLookup< ffi.NativeFunction< @@ -788,7 +888,9 @@ 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. - bool getSortByPosition() => _getSortByPosition(reference).boolean; + bool getSortByPosition() { + return _getSortByPosition(reference).boolean; + } static final _setSortByPosition = jniLookup< ffi.NativeFunction< @@ -806,8 +908,11 @@ class PDFTextStripper extends jni.JObject { /// A PDF writer could choose to write each character in a different order. By default PDFBox does __not__ sort /// the text tokens before processing them due to performance reasons. ///@param newSortByPosition Tell PDFBox to sort the text positions. - void setSortByPosition(bool newSortByPosition) => - _setSortByPosition(reference, newSortByPosition ? 1 : 0).check(); + void setSortByPosition( + bool newSortByPosition, + ) { + return _setSortByPosition(reference, newSortByPosition ? 1 : 0).check(); + } static final _getSpacingTolerance = jniLookup< ffi.NativeFunction< @@ -820,7 +925,9 @@ class PDFTextStripper extends jni.JObject { /// Get the current space width-based tolerance value that is being used to estimate where spaces in text should be /// added. Note that the default value for this has been determined from trial and error. ///@return The current tolerance / scaling factor - double getSpacingTolerance() => _getSpacingTolerance(reference).float; + double getSpacingTolerance() { + return _getSpacingTolerance(reference).float; + } static final _setSpacingTolerance = jniLookup< ffi.NativeFunction< @@ -834,8 +941,11 @@ class PDFTextStripper extends jni.JObject { /// that the default value for this has been determined from trial and error. Setting this value larger will reduce /// the number of spaces added. ///@param spacingToleranceValue tolerance / scaling factor to use - void setSpacingTolerance(double spacingToleranceValue) => - _setSpacingTolerance(reference, spacingToleranceValue).check(); + void setSpacingTolerance( + double spacingToleranceValue, + ) { + return _setSpacingTolerance(reference, spacingToleranceValue).check(); + } static final _getAverageCharTolerance = jniLookup< ffi.NativeFunction< @@ -848,7 +958,9 @@ class PDFTextStripper extends jni.JObject { /// Get the current character width-based tolerance value that is being used to estimate where spaces in text should /// be added. Note that the default value for this has been determined from trial and error. ///@return The current tolerance / scaling factor - double getAverageCharTolerance() => _getAverageCharTolerance(reference).float; + double getAverageCharTolerance() { + return _getAverageCharTolerance(reference).float; + } static final _setAverageCharTolerance = jniLookup< ffi.NativeFunction< @@ -862,8 +974,12 @@ class PDFTextStripper extends jni.JObject { /// that the default value for this has been determined from trial and error. Setting this value larger will reduce /// the number of spaces added. ///@param averageCharToleranceValue average tolerance / scaling factor to use - void setAverageCharTolerance(double averageCharToleranceValue) => - _setAverageCharTolerance(reference, averageCharToleranceValue).check(); + void setAverageCharTolerance( + double averageCharToleranceValue, + ) { + return _setAverageCharTolerance(reference, averageCharToleranceValue) + .check(); + } static final _getIndentThreshold = jniLookup< ffi.NativeFunction< @@ -876,7 +992,9 @@ class PDFTextStripper extends jni.JObject { /// returns the multiple of whitespace character widths for the current text which the current line start can be /// indented from the previous line start beyond which the current line start is considered to be a paragraph start. ///@return the number of whitespace character widths to use when detecting paragraph indents. - double getIndentThreshold() => _getIndentThreshold(reference).float; + double getIndentThreshold() { + return _getIndentThreshold(reference).float; + } static final _setIndentThreshold = jniLookup< ffi.NativeFunction< @@ -890,8 +1008,11 @@ class PDFTextStripper extends jni.JObject { /// indented from the previous line start beyond which the current line start is considered to be a paragraph start. /// The default value is 2.0. ///@param indentThresholdValue the number of whitespace character widths to use when detecting paragraph indents. - void setIndentThreshold(double indentThresholdValue) => - _setIndentThreshold(reference, indentThresholdValue).check(); + void setIndentThreshold( + double indentThresholdValue, + ) { + return _setIndentThreshold(reference, indentThresholdValue).check(); + } static final _getDropThreshold = jniLookup< ffi.NativeFunction< @@ -904,7 +1025,9 @@ class PDFTextStripper extends jni.JObject { /// the minimum whitespace, as a multiple of the max height of the current characters beyond which the current line /// 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() => _getDropThreshold(reference).float; + double getDropThreshold() { + return _getDropThreshold(reference).float; + } static final _setDropThreshold = jniLookup< ffi.NativeFunction< @@ -918,8 +1041,11 @@ class PDFTextStripper extends jni.JObject { /// line start is considered to be a paragraph start. The default value is 2.5. ///@param dropThresholdValue the character height multiple for max allowed whitespace between lines in the same /// paragraph. - void setDropThreshold(double dropThresholdValue) => - _setDropThreshold(reference, dropThresholdValue).check(); + void setDropThreshold( + double dropThresholdValue, + ) { + return _setDropThreshold(reference, dropThresholdValue).check(); + } static final _getParagraphStart = jniLookup< ffi.NativeFunction< @@ -932,8 +1058,10 @@ 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() => - const jni.JStringType().fromRef(_getParagraphStart(reference).object); + jni.JString getParagraphStart() { + return const jni.JStringType() + .fromRef(_getParagraphStart(reference).object); + } static final _setParagraphStart = jniLookup< ffi.NativeFunction< @@ -947,8 +1075,11 @@ class PDFTextStripper extends jni.JObject { /// /// Sets the string which will be used at the beginning of a paragraph. ///@param s the paragraph start string - void setParagraphStart(jni.JString s) => - _setParagraphStart(reference, s.reference).check(); + void setParagraphStart( + jni.JString s, + ) { + return _setParagraphStart(reference, s.reference).check(); + } static final _getParagraphEnd = jniLookup< ffi.NativeFunction< @@ -961,8 +1092,9 @@ 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() => - const jni.JStringType().fromRef(_getParagraphEnd(reference).object); + jni.JString getParagraphEnd() { + return const jni.JStringType().fromRef(_getParagraphEnd(reference).object); + } static final _setParagraphEnd = jniLookup< ffi.NativeFunction< @@ -976,8 +1108,11 @@ class PDFTextStripper extends jni.JObject { /// /// Sets the string which will be used at the end of a paragraph. ///@param s the paragraph end string - void setParagraphEnd(jni.JString s) => - _setParagraphEnd(reference, s.reference).check(); + void setParagraphEnd( + jni.JString s, + ) { + return _setParagraphEnd(reference, s.reference).check(); + } static final _getPageStart = jniLookup< ffi.NativeFunction< @@ -990,8 +1125,9 @@ 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() => - const jni.JStringType().fromRef(_getPageStart(reference).object); + jni.JString getPageStart() { + return const jni.JStringType().fromRef(_getPageStart(reference).object); + } static final _setPageStart = jniLookup< ffi.NativeFunction< @@ -1005,8 +1141,11 @@ class PDFTextStripper extends jni.JObject { /// /// Sets the string which will be used at the beginning of a page. ///@param pageStartValue the page start string - void setPageStart(jni.JString pageStartValue) => - _setPageStart(reference, pageStartValue.reference).check(); + void setPageStart( + jni.JString pageStartValue, + ) { + return _setPageStart(reference, pageStartValue.reference).check(); + } static final _getPageEnd = jniLookup< ffi.NativeFunction< @@ -1019,8 +1158,9 @@ 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() => - const jni.JStringType().fromRef(_getPageEnd(reference).object); + jni.JString getPageEnd() { + return const jni.JStringType().fromRef(_getPageEnd(reference).object); + } static final _setPageEnd = jniLookup< ffi.NativeFunction< @@ -1034,8 +1174,11 @@ class PDFTextStripper extends jni.JObject { /// /// Sets the string which will be used at the end of a page. ///@param pageEndValue the page end string - void setPageEnd(jni.JString pageEndValue) => - _setPageEnd(reference, pageEndValue.reference).check(); + void setPageEnd( + jni.JString pageEndValue, + ) { + return _setPageEnd(reference, pageEndValue.reference).check(); + } static final _getArticleStart = jniLookup< ffi.NativeFunction< @@ -1048,8 +1191,9 @@ 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() => - const jni.JStringType().fromRef(_getArticleStart(reference).object); + jni.JString getArticleStart() { + return const jni.JStringType().fromRef(_getArticleStart(reference).object); + } static final _setArticleStart = jniLookup< ffi.NativeFunction< @@ -1063,8 +1207,11 @@ class PDFTextStripper extends jni.JObject { /// /// Sets the string which will be used at the beginning of an article. ///@param articleStartValue the article start string - void setArticleStart(jni.JString articleStartValue) => - _setArticleStart(reference, articleStartValue.reference).check(); + void setArticleStart( + jni.JString articleStartValue, + ) { + return _setArticleStart(reference, articleStartValue.reference).check(); + } static final _getArticleEnd = jniLookup< ffi.NativeFunction< @@ -1077,8 +1224,9 @@ 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() => - const jni.JStringType().fromRef(_getArticleEnd(reference).object); + jni.JString getArticleEnd() { + return const jni.JStringType().fromRef(_getArticleEnd(reference).object); + } static final _setArticleEnd = jniLookup< ffi.NativeFunction< @@ -1092,8 +1240,11 @@ class PDFTextStripper extends jni.JObject { /// /// Sets the string which will be used at the end of an article. ///@param articleEndValue the article end string - void setArticleEnd(jni.JString articleEndValue) => - _setArticleEnd(reference, articleEndValue.reference).check(); + void setArticleEnd( + jni.JString articleEndValue, + ) { + return _setArticleEnd(reference, articleEndValue.reference).check(); + } static final _writeParagraphSeparator = jniLookup< ffi.NativeFunction< @@ -1105,7 +1256,9 @@ class PDFTextStripper extends jni.JObject { /// /// writes the paragraph separator string to the output. ///@throws IOException if something went wrong - void writeParagraphSeparator() => _writeParagraphSeparator(reference).check(); + void writeParagraphSeparator() { + return _writeParagraphSeparator(reference).check(); + } static final _writeParagraphStart = jniLookup< ffi.NativeFunction< @@ -1117,7 +1270,9 @@ class PDFTextStripper extends jni.JObject { /// /// Write something (if defined) at the start of a paragraph. ///@throws IOException if something went wrong - void writeParagraphStart() => _writeParagraphStart(reference).check(); + void writeParagraphStart() { + return _writeParagraphStart(reference).check(); + } static final _writeParagraphEnd = jniLookup< ffi.NativeFunction< @@ -1129,7 +1284,9 @@ class PDFTextStripper extends jni.JObject { /// /// Write something (if defined) at the end of a paragraph. ///@throws IOException if something went wrong - void writeParagraphEnd() => _writeParagraphEnd(reference).check(); + void writeParagraphEnd() { + return _writeParagraphEnd(reference).check(); + } static final _writePageStart = jniLookup< ffi.NativeFunction< @@ -1141,7 +1298,9 @@ class PDFTextStripper extends jni.JObject { /// /// Write something (if defined) at the start of a page. ///@throws IOException if something went wrong - void writePageStart() => _writePageStart(reference).check(); + void writePageStart() { + return _writePageStart(reference).check(); + } static final _writePageEnd = jniLookup< ffi.NativeFunction< @@ -1153,7 +1312,9 @@ class PDFTextStripper extends jni.JObject { /// /// Write something (if defined) at the end of a page. ///@throws IOException if something went wrong - void writePageEnd() => _writePageEnd(reference).check(); + void writePageEnd() { + return _writePageEnd(reference).check(); + } static final _setListItemPatterns = jniLookup< ffi.NativeFunction< @@ -1168,8 +1329,11 @@ class PDFTextStripper extends jni.JObject { /// /// use to supply a different set of regular expression patterns for matching list item starts. ///@param patterns list of patterns - void setListItemPatterns(jni.JObject patterns) => - _setListItemPatterns(reference, patterns.reference).check(); + void setListItemPatterns( + jni.JObject patterns, + ) { + return _setListItemPatterns(reference, patterns.reference).check(); + } static final _getListItemPatterns = jniLookup< ffi.NativeFunction< @@ -1196,8 +1360,10 @@ class PDFTextStripper extends jni.JObject { /// /// This method returns a list of such regular expression Patterns. ///@return a list of Pattern objects. - jni.JObject getListItemPatterns() => - const jni.JObjectType().fromRef(_getListItemPatterns(reference).object); + jni.JObject getListItemPatterns() { + return const jni.JObjectType() + .fromRef(_getListItemPatterns(reference).object); + } static final _matchPattern = jniLookup< ffi.NativeFunction< @@ -1220,9 +1386,13 @@ class PDFTextStripper extends jni.JObject { ///@param string the string to be searched ///@param patterns list of patterns ///@return matching pattern - static jni.JObject matchPattern(jni.JString string, jni.JObject patterns) => - const jni.JObjectType() - .fromRef(_matchPattern(string.reference, patterns.reference).object); + static jni.JObject matchPattern( + jni.JString string, + jni.JObject patterns, + ) { + return const jni.JObjectType() + .fromRef(_matchPattern(string.reference, patterns.reference).object); + } } class $PDFTextStripperType extends jni.JObjType { @@ -1233,4 +1403,19 @@ class $PDFTextStripperType extends jni.JObjType { @override PDFTextStripper fromRef(jni.JObjectPtr ref) => PDFTextStripper.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($PDFTextStripperType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $PDFTextStripperType && + other is $PDFTextStripperType; + } } diff --git a/pkgs/jnigen/lib/src/bindings/dart_generator.dart b/pkgs/jnigen/lib/src/bindings/dart_generator.dart index 56fff02a6..58561f9eb 100644 --- a/pkgs/jnigen/lib/src/bindings/dart_generator.dart +++ b/pkgs/jnigen/lib/src/bindings/dart_generator.dart @@ -4,6 +4,8 @@ import 'dart:io'; +import 'package:meta/meta.dart'; + import '../config/config.dart'; import '../elements/elements.dart'; import '../logging/logging.dart'; @@ -50,6 +52,16 @@ extension on String { String capitalize() { return '${this[0].toUpperCase()}${substring(1)}'; } + + /// Reverses an ASCII string. + String get reversed => split('').reversed.join(); +} + +extension on Iterable { + /// Similar to [join] but adds the [separator] to the end as well. + String delimited([String separator = '']) { + return map((e) => '$e$separator').join(); + } } /// Encloses [inside] in the middle of [open] and [close] @@ -63,6 +75,33 @@ 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: @@ -87,10 +126,10 @@ String _newLine({int depth = 0}) { /// * `fTypeClassesDef` refers to `JType $T, JType $U`. /// * `fTypeClassesCall` refers to `$T, $U` when calling the method. class DartGenerator extends Visitor> { - DartGenerator(this.config); - final Config config; + DartGenerator(this.config); + static const cInitImport = 'import "dart:ffi" as ffi;\n' 'import "package:jni/internal_helpers_for_jnigen.dart";\n'; @@ -243,16 +282,16 @@ import "package:jni/jni.dart" as jni; /// Generates the Dart class definition, type class, and the array extension class _ClassGenerator extends Visitor { + final Config config; + final StringSink s; + final Resolver? resolver; + _ClassGenerator( this.config, this.s, { this.resolver, }); - final Config config; - final StringSink s; - final Resolver? resolver; - static const staticTypeGetter = 'type'; static const instanceTypeGetter = '\$$staticTypeGetter'; @@ -277,18 +316,22 @@ class _ClassGenerator extends Visitor { ); final typeParams = node.allTypeParams .accept(const _TypeParamGenerator(withExtends: false)); - final typeParamsCall = _encloseIfNotEmpty('<', typeParams.join(', '), '>'); + final typeParamsCall = _encloseIfNotEmpty( + '<', + typeParams.map((typeParam) => '$_typeParamPrefix$typeParam').join(', '), + '>', + ); final staticTypeGetterCallArgs = _encloseIfNotEmpty( '(', - typeParams.map((typeParams) => '$_typeParamPrefix$typeParams').join(', '), + typeParams.join(', '), ')', ); final typeClassDefinitions = typeParams .map((typeParam) => - 'final $_jType<$typeParam> $_typeParamPrefix$typeParam;') + 'final $_jType<$_typeParamPrefix$typeParam> $typeParam;') .join(_newLine(depth: 1)); final ctorTypeClassesDef = typeParams - .map((typeParam) => 'this.$_typeParamPrefix$typeParam,') + .map((typeParam) => 'this.$typeParam,') .join(_newLine(depth: 2)); final superClass = (node.classDecl.superclass!.type as DeclaredType); final superTypeClassesCall = superClass.classDecl == ClassDecl.object @@ -299,9 +342,8 @@ class _ClassGenerator extends Visitor { .join(_newLine(depth: 2)); s.write(''' class $name$typeParamsDef extends $superName { - late final $_jType? _$instanceTypeGetter; @override - $_jType get $instanceTypeGetter => _$instanceTypeGetter ??= $staticTypeGetter$staticTypeGetterCallArgs; + late final $_jType $instanceTypeGetter = $staticTypeGetter$staticTypeGetterCallArgs; $typeClassDefinitions @@ -332,11 +374,10 @@ class $name$typeParamsDef extends $superName { } else { final staticTypeGetterTypeClassesDef = typeParams .map( - (typeParam) => '$_jType<$typeParam> $_typeParamPrefix$typeParam,') + (typeParam) => '$_jType<$_typeParamPrefix$typeParam> $typeParam,') .join(_newLine(depth: 2)); - final typeClassesCall = typeParams - .map((typeParam) => '$_typeParamPrefix$typeParam,') - .join(_newLine(depth: 3)); + final typeClassesCall = + typeParams.map((typeParam) => '$typeParam,').join(_newLine(depth: 3)); s.write(''' static $typeClassName$typeParamsCall $staticTypeGetter$typeParamsDef( $staticTypeGetterTypeClassesDef @@ -363,10 +404,17 @@ class $name$typeParamsDef extends $superName { s.writeln('}'); // TypeClass definition - final typeClassesCall = typeParams - .map((typeParam) => '$_typeParamPrefix$typeParam,') - .join(_newLine(depth: 2)); + final typeClassesCall = + typeParams.map((typeParam) => '$typeParam,').join(_newLine(depth: 2)); final signature = node.signature; + final superTypeClass = superClass.accept(_TypeClassGenerator(resolver)); + final hashCodeTypeClasses = typeParams.join(', '); + final equalityTypeClasses = typeParams + .map((typeParam) => ' && $typeParam == other.$typeParam') + .join(); + final hashCode = typeParams.isEmpty + ? '($typeClassName).hashCode' + : 'Object.hash($typeClassName, $hashCodeTypeClasses)'; s.write(''' class $typeClassName$typeParamsDef extends $_jType<$name$typeParamsCall> { $typeClassDefinitions @@ -383,6 +431,20 @@ class $typeClassName$typeParamsDef extends $_jType<$name$typeParamsCall> { $typeClassesCall ref ); + + @override + $_jType get superType => ${superTypeClass.name}; + + @override + final superCount = ${node.superCount}; + + @override + int get hashCode => $hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $typeClassName && other is $typeClassName$equalityTypeClasses; + } } '''); @@ -392,11 +454,11 @@ class $typeClassName$typeParamsDef extends $_jType<$name$typeParamsCall> { /// Generates the JavaDoc comments. class _DocGenerator extends Visitor { - const _DocGenerator(this.s, {required this.depth}); - final StringSink s; final int depth; + const _DocGenerator(this.s, {required this.depth}); + @override void visit(JavaDocComment node) { final link = RegExp('{@link ([^{}]+)}'); @@ -421,10 +483,10 @@ $indent/// $comments /// Generates the user-facing Dart type. class _TypeGenerator extends TypeVisitor { - const _TypeGenerator(this.resolver); - final Resolver? resolver; + const _TypeGenerator(this.resolver); + @override String visitArrayType(ArrayType node) { final innerType = node.type; @@ -478,7 +540,7 @@ class _TypeGenerator extends TypeVisitor { @override String visitTypeVar(TypeVar node) { - return node.name; + return '$_typeParamPrefix${node.name}'; } @override @@ -494,10 +556,10 @@ class _TypeGenerator extends TypeVisitor { } class _TypeClass { - const _TypeClass(this.name, this.canBeConst); - final String name; final bool canBeConst; + + const _TypeClass(this.name, this.canBeConst); } /// Generates the type class. @@ -528,7 +590,6 @@ class _TypeClassGenerator extends TypeVisitor<_TypeClass> { } final allTypeParams = node.classDecl.allTypeParams .accept(const _TypeParamGenerator(withExtends: false)) - .map((typeParam) => '$_typeParamPrefix$typeParam') .toList(); // The ones that are declared. @@ -539,9 +600,6 @@ class _TypeClassGenerator extends TypeVisitor<_TypeClass> { // also const. final canBeConst = definedTypeClasses.every((e) => e.canBeConst); - // Adding const to `JObjectType`s if the entire expression is not const. - final constJObject = canBeConst ? '' : 'const '; - // Replacing the declared ones. They come at the end. // The rest will be `JObjectType`. if (allTypeParams.length >= node.params.length) { @@ -550,13 +608,16 @@ class _TypeClassGenerator extends TypeVisitor<_TypeClass> { allTypeParams.length - node.params.length, List.filled( allTypeParams.length - node.params.length, - '$constJObject$_jObject$_typeClassSuffix()', + // Adding const to subexpressions if the entire expression is not const. + '${canBeConst ? '' : 'const '}$_jObject$_typeClassSuffix()', ), ); allTypeParams.replaceRange( allTypeParams.length - node.params.length, allTypeParams.length, - definedTypeClasses.map((param) => param.name), + // Adding const to subexpressions if the entire expression is not const. + definedTypeClasses.map((param) => + '${param.canBeConst && !canBeConst ? 'const ' : ''}${param.name}'), ); } @@ -577,7 +638,7 @@ class _TypeClassGenerator extends TypeVisitor<_TypeClass> { @override _TypeClass visitTypeVar(TypeVar node) { - return _TypeClass('$_typeParamPrefix${node.name}', false); + return _TypeClass(node.name, false); } @override @@ -594,17 +655,17 @@ class _TypeClassGenerator extends TypeVisitor<_TypeClass> { } class _TypeParamGenerator extends Visitor { - const _TypeParamGenerator({required this.withExtends}); - final bool withExtends; + const _TypeParamGenerator({required this.withExtends}); + @override String visit(TypeParam node) { if (!withExtends) { return node.name; } // TODO(#144): resolve the actual type being extended, if any. - return '${node.name} extends $_jObject'; + return '$_typeParamPrefix${node.name} extends $_jObject'; } } @@ -637,10 +698,10 @@ class _JniResultGetter extends TypeVisitor { /// .asFunction(); /// ``` class _TypeSig extends TypeVisitor { - const _TypeSig({required this.isFfi}); - final bool isFfi; + const _TypeSig({required this.isFfi}); + @override String visitPrimitiveType(PrimitiveType node) { if (isFfi) return '$_ffi.${node.ffiType}'; @@ -700,11 +761,11 @@ class _ToNativeSuffix extends TypeVisitor { } class _FromNative extends TypeVisitor { - const _FromNative(this.resolver, this.value); - final Resolver? resolver; final String value; + const _FromNative(this.resolver, this.value); + @override String visitPrimitiveType(PrimitiveType node) { return value; @@ -718,12 +779,12 @@ class _FromNative extends TypeVisitor { } class _FieldGenerator extends Visitor { - const _FieldGenerator(this.config, this.resolver, this.s); - final Config config; final Resolver? resolver; final StringSink s; + const _FieldGenerator(this.config, this.resolver, this.s); + void writeCAccessor(Field node) { final name = node.finalName; final cName = node.accept(const CFieldName()); @@ -854,10 +915,10 @@ class _FieldGenerator extends Visitor { } class _MethodTypeSig extends Visitor { - const _MethodTypeSig({required this.isFfi}); - final bool isFfi; + const _MethodTypeSig({required this.isFfi}); + @override String visit(Method node) { final args = [ @@ -872,12 +933,12 @@ class _MethodTypeSig extends Visitor { /// Generates Dart bindings for Java methods. class _MethodGenerator extends Visitor { - const _MethodGenerator(this.config, this.resolver, this.s); - final Config config; final Resolver? resolver; final StringSink s; + const _MethodGenerator(this.config, this.resolver, this.s); + void writeCAccessor(Method node) { final name = node.finalName; final cName = node.accept(const CMethodName()); @@ -938,7 +999,8 @@ class _MethodGenerator extends Visitor { final params = node.params.accept(const _ParamCall(isCBased: false)).join(', '); final resultGetter = node.returnType.accept(const _JniResultGetter()); - return '$_accessors.call${ifStatic}MethodWithArgs($self, _id_$name, $callType, [$params]).$resultGetter'; + return '$_accessors.call${ifStatic}MethodWithArgs' + '($self, _id_$name, $callType, [$params]).$resultGetter'; } @override @@ -959,27 +1021,58 @@ class _MethodGenerator extends Visitor { } 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, + _encloseIfNotEmpty( + '[', + value.delimited(', '), + ']', + ), + )); + + bool isRequired(TypeParam typeParam) { + return (typeLocators[typeParam.name] ?? '').isEmpty; + } + + final typeInference = + (node.isCtor ? 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)); + if (node.isCtor) { final className = node.classDecl.finalName; final name = node.finalName; final ctorName = name == 'ctor' ? className : '$className.$name'; - final paramsDef = [ - ...node.classDecl.allTypeParams.accept(const _ClassTypeParamDef()), - ...node.params.accept(_ParamDef(resolver)), - ].join(', '); - final superClass = (node.classDecl.superclass!.type as DeclaredType); - final superTypeClassesCall = superClass.classDecl == ClassDecl.object - ? '' - : superClass.params - .accept(_TypeClassGenerator(resolver)) - .map((typeClass) => '${typeClass.name},') - .join(_newLine(depth: 2)); + final paramsDef = node.params.accept(_ParamDef(resolver)).delimited(', '); + final typeClassDef = _encloseIfNotEmpty( + '{', + node.classDecl.allTypeParams + .map((typeParam) => typeParam + .accept(_CtorTypeClassDef(isRequired: isRequired(typeParam)))) + .delimited(', '), + '}', + ); + final typeClassCall = node.classDecl.allTypeParams + .map((typeParam) => + typeParam.accept(const _TypeParamGenerator(withExtends: false))) + .delimited(', '); + final ctorExpr = (isCBased ? cCtor : dartOnlyCtor)(node); s.write(''' - $ctorName($paramsDef) : super.fromRef( - $superTypeClassesCall - $ctorExpr.object - ); + factory $ctorName($paramsDef$typeClassDef) { + $typeInference + return ${node.classDecl.finalName}.fromRef( + $typeClassCall + $ctorExpr.object + ); + } '''); return; @@ -993,10 +1086,16 @@ class _MethodGenerator extends Visitor { .accept(_TypeClassGenerator(resolver)) .name; final ifStatic = node.isStatic ? 'static ' : ''; - final defArgs = [ - ...node.typeParams.accept(const _MethodTypeParamDef()), - ...node.params.accept(_ParamDef(resolver)) - ]; + final defArgs = node.params.accept(_ParamDef(resolver)).toList(); + final typeClassDef = _encloseIfNotEmpty( + '{', + node.typeParams + .map((typeParam) => typeParam.accept(_MethodTypeClassDef( + isRequired: isRequired(typeParam), + ))) + .delimited(', '), + '}', + ); final typeParamsDef = _encloseIfNotEmpty( '<', node.typeParams @@ -1007,13 +1106,14 @@ class _MethodGenerator extends Visitor { if (isSuspendFun(node)) { defArgs.removeLast(); } - final params = defArgs.join(', '); - s.write(' $ifStatic$returnType $name$typeParamsDef($params) '); + final params = defArgs.delimited(', '); + s.write(' $ifStatic$returnType $name$typeParamsDef($params$typeClassDef)'); final callExpr = (isCBased ? cMethodCall : dartOnlyMethodCall)(node); if (isSuspendFun(node)) { final returning = node.asyncReturnType!.accept(_FromNative(resolver, '\$o')); s.write('''async { + $typeInference final \$p = ReceivePort(); final \$c = $_jObject.fromRef($_jni.Jni.newPortContinuation(\$p)); $callExpr; @@ -1028,41 +1128,51 @@ class _MethodGenerator extends Visitor { '''); } else { final returning = node.returnType.accept(_FromNative(resolver, callExpr)); - s.writeln('=> $returning;\n'); + s.writeln('''{ + $typeInference + return $returning; + } +'''); } } } /// Generates the method type param definition. /// -/// For example `JObjType $T` in: +/// For example `required JObjType $T` in: /// ```dart -/// void bar(JObjType $T, ...) => ... +/// void bar(..., {required JObjType $T}) => ... /// ``` -class _MethodTypeParamDef extends Visitor { - const _MethodTypeParamDef(); +class _MethodTypeClassDef extends Visitor { + final bool isRequired; + + const _MethodTypeClassDef({required this.isRequired}); @override String visit(TypeParam node) { - return '$_jType<${node.name}> $_typeParamPrefix${node.name}'; + return '${isRequired ? 'required ' : ''}$_jType' + '<$_typeParamPrefix${node.name}>${isRequired ? '' : '?'} ${node.name}'; } } /// Generates the class type param definition. Used only in constructors. /// -/// For example `this.$T` in: +/// For example `required this.$T` in: /// ```dart /// class Foo { /// final JObjType $T; -/// Foo(this.$T, ...) => ... +/// Foo(..., {required this.$T}) => ... /// } /// ``` -class _ClassTypeParamDef extends Visitor { - const _ClassTypeParamDef(); +class _CtorTypeClassDef extends Visitor { + final bool isRequired; + + const _CtorTypeClassDef({required this.isRequired}); @override String visit(TypeParam node) { - return 'this.$_typeParamPrefix${node.name}'; + return '${isRequired ? 'required ' : ''} $_jType' + '<$_typeParamPrefix${node.name}>${isRequired ? '' : '?'} ${node.name}'; } } @@ -1073,10 +1183,10 @@ class _ClassTypeParamDef extends Visitor { /// void bar(Foo foo) => ... /// ``` class _ParamDef extends Visitor { - const _ParamDef(this.resolver); - final Resolver? resolver; + const _ParamDef(this.resolver); + @override String visit(Param node) { final type = node.type.accept(_TypeGenerator(resolver)); @@ -1131,3 +1241,135 @@ class _JValueWrapper extends TypeVisitor { return '$_jni.JValue${node.name.capitalize()}($param)'; } } + +/// A pair of [StringBuffer]s that can create an expression from the outer layer +/// inwards. +/// +/// For example: +/// ```dart +/// final buffer = OutsideInBuffer(); // asterisk (*) is used to show the middle +/// buffer.appendLeft('f('); // f(* +/// buffer.prependRight('x)'); // f(*x) +/// buffer.appendLeft('g('); // f(g(*x) +/// buffer.prependRight('y) + '); // f(g(*y) + x) +/// buffer.toString(); // f(g(y) + x) +/// ``` +@visibleForTesting +class OutsideInBuffer { + final StringBuffer _leftBuffer; + final StringBuffer _rightBuffer; + + OutsideInBuffer() + : _leftBuffer = StringBuffer(), + _rightBuffer = StringBuffer(); + + void prependRight(Object? object) { + final s = object.toString(); + for (var i = 0; i < s.length; ++i) { + _rightBuffer.write(s[s.length - i - 1]); + } + } + + void appendLeft(Object? object) { + _leftBuffer.write(object); + } + + @override + String toString() { + return _leftBuffer.toString() + _rightBuffer.toString().reversed; + } +} + +/// The ways to locate each type parameter. +/// +/// For example in `JArray> a`, `T` can be retreived using +/// ```dart +/// ((((a.$type as jni.JArrayType).elementType) as $JMapType).K) as jni.JObjType<$T> +/// ``` +/// and +/// ```dart +/// ((((a.$type as jni.JArrayType).elementType) as $JMapType).V) as jni.JObjType<$T> +/// ``` +class _ParamTypeLocator extends Visitor>> { + final Resolver? resolver; + + _ParamTypeLocator({required this.resolver}); + + @override + Map> visit(Param node) { + 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(#141): Support wildcards + return super.visitWildcard(node); + } + + @override + Map> visitTypeVar(TypeVar node) { + return { + node.name: [ + OutsideInBuffer(), + ], + }; + } + + @override + Map> visitDeclaredType(DeclaredType node) { + if (node.classDecl == ClassDecl.object) { + return {}; + } + final offset = node.classDecl.allTypeParams.length - node.params.length; + final result = >{}; + final prefix = resolver?.resolvePrefix(node.binaryName) ?? ''; + final typeClass = + '$prefix$_typeClassPrefix${node.classDecl.finalName}$_typeClassSuffix'; + 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).$typeParam'); + result[expr.key] = (result[expr.key] ?? [])..add(buffer); + } + } + } + return result; + } + + @override + Map> visitArrayType(ArrayType node) { + final exprs = node.type.accept(this); + for (final e in exprs.values.expand((i) => i)) { + e.appendLeft('(('); + e.prependRight(' as $_jArray$_typeClassSuffix).elementType as $_jType)'); + } + return exprs; + } + + @override + Map> visitPrimitiveType(PrimitiveType node) { + return {}; + } +} diff --git a/pkgs/jnigen/lib/src/bindings/excluder.dart b/pkgs/jnigen/lib/src/bindings/excluder.dart index 88beefd22..1568bd3ec 100644 --- a/pkgs/jnigen/lib/src/bindings/excluder.dart +++ b/pkgs/jnigen/lib/src/bindings/excluder.dart @@ -11,10 +11,10 @@ bool _isPrivate(ClassMember classMember) => !classMember.isPublic && !classMember.isProtected; class Excluder extends Visitor { - const Excluder(this.config); - final Config config; + const Excluder(this.config); + @override void visit(Classes node) { node.decls.removeWhere((_, classDecl) { @@ -33,10 +33,10 @@ class Excluder extends Visitor { } class _ClassExcluder extends Visitor { - _ClassExcluder(this.config); - final Config config; + _ClassExcluder(this.config); + @override void visit(ClassDecl node) { node.methods = node.methods.where((method) { diff --git a/pkgs/jnigen/lib/src/bindings/linker.dart b/pkgs/jnigen/lib/src/bindings/linker.dart index f4fe617bb..e50d43782 100644 --- a/pkgs/jnigen/lib/src/bindings/linker.dart +++ b/pkgs/jnigen/lib/src/bindings/linker.dart @@ -61,6 +61,8 @@ class _ClassLinker extends Visitor { final superclass = (node.superclass!.type as DeclaredType).classDecl; superclass.accept(this); + 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/bindings/renamer.dart b/pkgs/jnigen/lib/src/bindings/renamer.dart index e9fbda924..4f1c44090 100644 --- a/pkgs/jnigen/lib/src/bindings/renamer.dart +++ b/pkgs/jnigen/lib/src/bindings/renamer.dart @@ -119,9 +119,10 @@ String _renameConflict(Map counts, String name) { } class Renamer implements Visitor { - Renamer(this.config); final Config config; + Renamer(this.config); + @override void visit(Classes node) { final classRenamer = _ClassRenamer(config); @@ -133,10 +134,6 @@ class Renamer implements Visitor { } class _ClassRenamer implements Visitor { - _ClassRenamer( - this.config, - ); - final Config config; final Map classNameCounts = {}; final Set renamed = {...ClassDecl.predefined.values}; @@ -147,6 +144,10 @@ class _ClassRenamer implements Visitor { }; final Map> methodNumsAfterRenaming = {}; + _ClassRenamer( + this.config, + ); + /// Returns class name as useful in dart. /// /// Eg -> a.b.X.Y -> X_Y diff --git a/pkgs/jnigen/lib/src/bindings/resolver.dart b/pkgs/jnigen/lib/src/bindings/resolver.dart index cc7a45eb4..b0c82303c 100644 --- a/pkgs/jnigen/lib/src/bindings/resolver.dart +++ b/pkgs/jnigen/lib/src/bindings/resolver.dart @@ -7,12 +7,6 @@ import 'dart:math'; import '../logging/logging.dart'; class Resolver { - Resolver({ - required this.importMap, - required this.currentClass, - this.inputClassNames = const {}, - }); - static const Map predefined = { 'java.lang.String': 'jni.', }; @@ -32,6 +26,12 @@ class Resolver { final Map _importedNameToClass = {}; final Map _classToImportedName = {}; + Resolver({ + required this.importMap, + required this.currentClass, + this.inputClassNames = const {}, + }); + static String getFileClassName(String binaryName) { final dollarSign = binaryName.indexOf('\$'); if (dollarSign != -1) { diff --git a/pkgs/jnigen/lib/src/bindings/visitor.dart b/pkgs/jnigen/lib/src/bindings/visitor.dart index 8454cacc9..c2bf9e65a 100644 --- a/pkgs/jnigen/lib/src/bindings/visitor.dart +++ b/pkgs/jnigen/lib/src/bindings/visitor.dart @@ -22,18 +22,21 @@ abstract class TypeVisitor { } extension MultiVisitor> on Iterable> { + /// Accepts all lazily. Remember to call `.toList()` or similar methods! Iterable accept(Visitor v) { return map((e) => e.accept(v)); } } extension MultiTypeVisitor on Iterable { + /// Accepts all lazily. Remember to call `.toList()` or similar methods! Iterable accept(TypeVisitor v) { return map((e) => e.accept(v)); } } extension MultiTypeUsageVisitor on Iterable { + /// Accepts all lazily. Remember to call `.toList()` or similar methods! Iterable accept(TypeVisitor v) { return map((e) => e.type.accept(v)); } diff --git a/pkgs/jnigen/lib/src/elements/elements.dart b/pkgs/jnigen/lib/src/elements/elements.dart index 73476650d..4c3ce2afb 100644 --- a/pkgs/jnigen/lib/src/elements/elements.dart +++ b/pkgs/jnigen/lib/src/elements/elements.dart @@ -97,15 +97,21 @@ class ClassDecl extends ClassMember implements Element { String get internalName => binaryName.replaceAll(".", "/"); + /// The number of super classes this type has. + /// + /// Populated by [Linker]. + @JsonKey(includeFromJson: false) + late final int superCount; + /// Parent's [ClassDecl] obtained from [parentName]. /// - /// Will be populated by [Linker]. + /// Populated by [Linker]. @JsonKey(includeFromJson: false) late final ClassDecl? parent; /// Final name of this class. /// - /// Will be populated by [Renamer]. + /// Populated by [Renamer]. @JsonKey(includeFromJson: false) late final String finalName; @@ -114,13 +120,13 @@ class ClassDecl extends ClassMember implements Element { /// This is used by C bindings instead of fully qualified name to reduce /// the verbosity of generated bindings. /// - /// Will be populated by [Renamer]. + /// Populated by [Renamer]. @JsonKey(includeFromJson: false) late final String uniqueName; /// Type parameters including the ones from its ancestors /// - /// Will be populated by [Linker]. + /// Populated by [Linker]. @JsonKey(includeFromJson: false) List allTypeParams = const []; @@ -135,14 +141,18 @@ class ClassDecl extends ClassMember implements Element { binaryName: 'java.lang.Object', packageName: 'java.lang', simpleName: 'Object', - )..finalName = 'JObject'; + ) + ..finalName = 'JObject' + ..superCount = 0; static final string = ClassDecl( superclass: TypeUsage.object, binaryName: 'java.lang.String', packageName: 'java.lang', simpleName: 'String', - )..finalName = 'JString'; + ) + ..finalName = 'JString' + ..superCount = 1; static final predefined = { 'java.lang.Object': object, @@ -202,7 +212,7 @@ class TypeUsage { @JsonKey(name: "type") final Map typeJson; - /// Will be populated in [TypeUsage.fromJson]. + /// Populated by in [TypeUsage.fromJson]. @JsonKey(includeFromJson: false) late final ReferredType type; @@ -462,12 +472,12 @@ class Method extends ClassMember implements Element { /// The [ClassDecl] where this method is defined. /// - /// Will be populated by [Linker]. + /// Populated by [Linker]. @JsonKey(includeFromJson: false) @override late ClassDecl classDecl; - /// Will be populated by [Renamer]. + /// Populated by [Renamer]. @JsonKey(includeFromJson: false) late String finalName; @@ -513,7 +523,7 @@ class Param implements Element { final String name; final TypeUsage type; - /// Will be populated by [Renamer]. + /// Populated by [Renamer]. @JsonKey(includeFromJson: false) late String finalName; @@ -548,12 +558,12 @@ class Field extends ClassMember implements Element { /// The [ClassDecl] where this field is defined. /// - /// Will be populated by [Linker]. + /// Populated by [Linker]. @JsonKey(includeFromJson: false) @override late final ClassDecl classDecl; - /// Will be populated by [Renamer]. + /// Populated by [Renamer]. @JsonKey(includeFromJson: false) late final String finalName; diff --git a/pkgs/jnigen/pubspec.yaml b/pkgs/jnigen/pubspec.yaml index 2a3c73151..48092a88a 100644 --- a/pkgs/jnigen/pubspec.yaml +++ b/pkgs/jnigen/pubspec.yaml @@ -3,7 +3,7 @@ # BSD-style license that can be found in the LICENSE file. name: jnigen -version: 0.3.0 +version: 0.4.0-dev description: Experimental generator for FFI+JNI bindings. repository: https://github.com/dart-lang/jnigen/tree/main/jnigen @@ -17,12 +17,13 @@ dependencies: args: ^2.3.0 yaml: ^3.1.0 logging: ^1.0.2 + meta: ^1.8.0 cli_config: ^0.1.0 dev_dependencies: lints: ^2.0.0 jni: path: ../jni - test: ^1.17.5 + test: ^1.24.1 build_runner: ^2.2.0 json_serializable: ^6.6.0 diff --git a/pkgs/jnigen/test/bindings_test.dart b/pkgs/jnigen/test/bindings_test.dart index 3c1cd9f64..107c24d2c 100644 --- a/pkgs/jnigen/test/bindings_test.dart +++ b/pkgs/jnigen/test/bindings_test.dart @@ -50,6 +50,7 @@ Future setupDylibsAndClasses() async { join(group, 'generics', 'StringStack.java'), join(group, 'generics', 'StringValuedMap.java'), join(group, 'generics', 'StringKeyedMap.java'), + join(group, 'generics', 'StringMap.java'), join(group, 'annotations', 'JsonSerializable.java'), join(group, 'annotations', 'MyDataClass.java'), join(group, 'pkg2', 'C2.java'), @@ -185,9 +186,18 @@ void main() async { expect(() => Example.throwException(), throwsException); }); group('generics', () { + test('GrandParent constructor', () { + using((arena) { + final grandParent = GrandParent('Hello'.toJString()..deletedIn(arena)) + ..deletedIn(arena); + expect(grandParent, isA>()); + expect(grandParent.$type, isA<$GrandParentType>()); + expect(grandParent.value.toDartString(deleteOriginal: true), 'Hello'); + }); + }); test('MyStack', () { using((arena) { - final stack = MyStack(JString.type)..deletedIn(arena); + final stack = MyStack(T: JString.type)..deletedIn(arena); stack.push('Hello'.toJString()..deletedIn(arena)); stack.push('World'.toJString()..deletedIn(arena)); expect(stack.pop().toDartString(deleteOriginal: true), 'World'); @@ -196,7 +206,7 @@ void main() async { }); test('MyMap', () { using((arena) { - final map = MyMap(JString.type, Example.type)..deletedIn(arena); + final map = MyMap(K: JString.type, V: Example.type)..deletedIn(arena); final helloExample = Example.ctor1(1)..deletedIn(arena); final worldExample = Example.ctor1(2)..deletedIn(arena); map.put('Hello'.toJString()..deletedIn(arena), helloExample); @@ -230,7 +240,7 @@ void main() async { }); test('StringKeyedMap', () { using((arena) { - final map = StringKeyedMap(Example.type)..deletedIn(arena); + final map = StringKeyedMap(V: Example.type)..deletedIn(arena); final example = Example()..deletedIn(arena); map.put('Hello'.toJString()..deletedIn(arena), example); expect( @@ -242,7 +252,7 @@ void main() async { }); test('StringValuedMap', () { using((arena) { - final map = StringValuedMap(Example.type)..deletedIn(arena); + final map = StringValuedMap(K: Example.type)..deletedIn(arena); final example = Example()..deletedIn(arena); map.put(example, 'Hello'.toJString()..deletedIn(arena)); expect( @@ -251,11 +261,31 @@ void main() async { ); }); }); + test('StringMap', () { + using((arena) { + final map = StringMap()..deletedIn(arena); + map.put('hello'.toJString()..deletedIn(arena), + 'world'.toJString()..deletedIn(arena)); + expect( + map + .get0('hello'.toJString()..deletedIn(arena)) + .toDartString(deleteOriginal: true), + 'world', + ); + }); + }); + }); + test('superclass count', () { + expect(JObject.type.superCount, 0); + expect(MyMap.type(JObject.type, JObject.type).superCount, 1); + expect(StringKeyedMap.type(JObject.type).superCount, 2); + expect(StringValuedMap.type(JObject.type).superCount, 2); + expect(StringMap.type.superCount, 3); }); test('nested generics', () { using((arena) { final grandParent = - GrandParent(JString.type, "!".toJString()..deletedIn(arena)) + GrandParent(T: JString.type, "!".toJString()..deletedIn(arena)) ..deletedIn(arena); expect( grandParent.value.toDartString(deleteOriginal: true), @@ -270,7 +300,7 @@ void main() async { ); final exampleStaticParent = GrandParent.varStaticParent( - Example.type, Example()..deletedIn(arena)) + S: Example.type, Example()..deletedIn(arena)) ..deletedIn(arena); expect( (exampleStaticParent.value..deletedIn(arena)).getInternal(), @@ -290,7 +320,7 @@ void main() async { ); final exampleParent = grandParent.varParent( - Example.type, Example()..deletedIn(arena)) + S: Example.type, Example()..deletedIn(arena)) ..deletedIn(arena); expect( exampleParent.parentValue @@ -307,6 +337,99 @@ void main() async { }); }); }); + group('Generic type inference', () { + test('MyStack.of1', () { + using((arena) { + final emptyStack = MyStack(T: JString.type)..deletedIn(arena); + expect(emptyStack.size(), 0); + final stack = MyStack.of1( + "Hello".toJString()..deletedIn(arena), + )..deletedIn(arena); + expect(stack, isA>()); + expect(stack.$type, isA<$MyStackType>()); + expect( + stack.pop().toDartString(deleteOriginal: true), + "Hello", + ); + }); + }); + test('MyStack.of 2 strings', () { + using((arena) { + final stack = MyStack.of2( + "Hello".toJString()..deletedIn(arena), + "World".toJString()..deletedIn(arena), + )..deletedIn(arena); + expect(stack, isA>()); + expect(stack.$type, isA<$MyStackType>()); + expect( + stack.pop().toDartString(deleteOriginal: true), + "World", + ); + expect( + stack.pop().toDartString(deleteOriginal: true), + "Hello", + ); + }); + }); + test('MyStack.of a string and an array', () { + using((arena) { + final array = JArray.filled(1, "World".toJString()..deletedIn(arena)) + ..deletedIn(arena); + final stack = MyStack.of2( + "Hello".toJString()..deletedIn(arena), + array, + )..deletedIn(arena); + expect(stack, isA>()); + expect(stack.$type, isA<$MyStackType>()); + expect( + stack + .pop() + .castTo(JArray.type(JString.type), deleteOriginal: true)[0] + .toDartString(deleteOriginal: true), + "World", + ); + expect( + stack + .pop() + .castTo(JString.type, deleteOriginal: true) + .toDartString(deleteOriginal: true), + "Hello", + ); + }); + }); + test('MyStack.from array of string', () { + using((arena) { + final array = JArray.filled(1, "Hello".toJString()..deletedIn(arena)) + ..deletedIn(arena); + final stack = MyStack.fromArray(array)..deletedIn(arena); + expect(stack, isA>()); + expect(stack.$type, isA<$MyStackType>()); + expect( + stack.pop().toDartString(deleteOriginal: true), + "Hello", + ); + }); + }); + test('MyStack.fromArrayOfArrayOfGrandParents', () { + using((arena) { + final firstDimention = JArray.filled( + 1, + GrandParent("Hello".toJString()..deletedIn(arena))..deletedIn(arena), + )..deletedIn(arena); + final twoDimentionalArray = JArray.filled(1, firstDimention) + ..deletedIn(arena); + final stack = + MyStack.fromArrayOfArrayOfGrandParents(twoDimentionalArray) + ..deletedIn(arena); + expect(stack, isA>()); + expect(stack.$type, isA<$MyStackType>()); + expect( + stack.pop().toDartString(deleteOriginal: true), + "Hello", + ); + }); + }); + }); group('Kotlin support', () { test('Suspend functions', () async { await using((arena) async { diff --git a/pkgs/jnigen/test/dart_generator_test.dart b/pkgs/jnigen/test/dart_generator_test.dart new file mode 100644 index 000000000..4ad2eb8cc --- /dev/null +++ b/pkgs/jnigen/test/dart_generator_test.dart @@ -0,0 +1,17 @@ +// 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:jnigen/src/bindings/dart_generator.dart'; +import 'package:test/test.dart'; + +void main() { + test('OutsideInBuffer', () { + final buffer = OutsideInBuffer(); + buffer.appendLeft('f('); + buffer.prependRight('x)'); + buffer.appendLeft('g('); + buffer.prependRight('y) + '); + expect(buffer.toString(), 'f(g(y) + x)'); + }); +} diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonFactory.dart b/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonFactory.dart index 7ce9e774a..2ceb3242b 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonFactory.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonFactory.dart @@ -59,9 +59,8 @@ import "../../../../_init.dart"; /// instances. ///@author Tatu Saloranta class JsonFactory extends jni.JObject { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type; + late final jni.JObjType $type = type; JsonFactory.fromRef( jni.JObjectPtr ref, @@ -155,18 +154,22 @@ class JsonFactory extends jni.JObject { /// processing objects (such as symbol tables parsers use) /// and this reuse only works within context of a single /// factory instance. - JsonFactory() - : super.fromRef( - jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); + factory JsonFactory() { + return JsonFactory.fromRef( + jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); + } static final _id_ctor1 = jniAccessors.getMethodIDOf( _classRef, r"", r"(Lcom/fasterxml/jackson/core/ObjectCodec;)V"); /// from: public void (com.fasterxml.jackson.core.ObjectCodec oc) /// The returned object must be deleted after use, by calling the `delete` method. - JsonFactory.ctor1(jni.JObject oc) - : super.fromRef(jniAccessors - .newObjectWithArgs(_classRef, _id_ctor1, [oc.reference]).object); + factory JsonFactory.ctor1( + jni.JObject oc, + ) { + return JsonFactory.fromRef(jniAccessors + .newObjectWithArgs(_classRef, _id_ctor1, [oc.reference]).object); + } static final _id_ctor2 = jniAccessors.getMethodIDOf(_classRef, r"", r"(Lcom/fasterxml/jackson/core/JsonFactory;Lcom/fasterxml/jackson/core/ObjectCodec;)V"); @@ -178,9 +181,13 @@ class JsonFactory extends jni.JObject { ///@param src Original factory to copy settings from ///@param codec Databinding-level codec to use, if any ///@since 2.2.1 - JsonFactory.ctor2(JsonFactory src, jni.JObject codec) - : super.fromRef(jniAccessors.newObjectWithArgs( - _classRef, _id_ctor2, [src.reference, codec.reference]).object); + factory JsonFactory.ctor2( + JsonFactory src, + jni.JObject codec, + ) { + return JsonFactory.fromRef(jniAccessors.newObjectWithArgs( + _classRef, _id_ctor2, [src.reference, codec.reference]).object); + } static final _id_ctor3 = jniAccessors.getMethodIDOf(_classRef, r"", r"(Lcom/fasterxml/jackson/core/JsonFactoryBuilder;)V"); @@ -191,9 +198,12 @@ class JsonFactory extends jni.JObject { /// Constructor used by JsonFactoryBuilder for instantiation. ///@param b Builder that contains settings to use ///@since 2.10 - JsonFactory.ctor3(jni.JObject b) - : super.fromRef(jniAccessors - .newObjectWithArgs(_classRef, _id_ctor3, [b.reference]).object); + factory JsonFactory.ctor3( + jni.JObject b, + ) { + return JsonFactory.fromRef(jniAccessors + .newObjectWithArgs(_classRef, _id_ctor3, [b.reference]).object); + } static final _id_ctor4 = jniAccessors.getMethodIDOf( _classRef, r"", r"(Lcom/fasterxml/jackson/core/TSFBuilder;Z)V"); @@ -206,9 +216,13 @@ class JsonFactory extends jni.JObject { /// implementation for json. ///@param b Builder that contains settings to use ///@param bogus Argument only needed to separate constructor signature; ignored - JsonFactory.ctor4(jni.JObject b, bool bogus) - : super.fromRef(jniAccessors.newObjectWithArgs( - _classRef, _id_ctor4, [b.reference, bogus ? 1 : 0]).object); + factory JsonFactory.ctor4( + jni.JObject b, + bool bogus, + ) { + return JsonFactory.fromRef(jniAccessors.newObjectWithArgs( + _classRef, _id_ctor4, [b.reference, bogus ? 1 : 0]).object); + } static final _id_rebuild = jniAccessors.getMethodIDOf( _classRef, r"rebuild", r"()Lcom/fasterxml/jackson/core/TSFBuilder;"); @@ -220,9 +234,10 @@ class JsonFactory extends jni.JObject { /// with settings of this factory. ///@return Builder instance to use ///@since 2.10 - jni.JObject rebuild() => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_rebuild, jni.JniCallType.objectType, []).object); + jni.JObject rebuild() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_rebuild, jni.JniCallType.objectType, []).object); + } static final _id_builder = jniAccessors.getStaticMethodIDOf( _classRef, r"builder", r"()Lcom/fasterxml/jackson/core/TSFBuilder;"); @@ -238,9 +253,11 @@ class JsonFactory extends jni.JObject { /// NOTE: signature unfortunately does not expose true implementation type; this /// will be fixed in 3.0. ///@return Builder instance to use - static jni.JObject builder() => - const jni.JObjectType().fromRef(jniAccessors.callStaticMethodWithArgs( - _classRef, _id_builder, jni.JniCallType.objectType, []).object); + static jni.JObject builder() { + return const jni.JObjectType().fromRef(jniAccessors + .callStaticMethodWithArgs( + _classRef, _id_builder, jni.JniCallType.objectType, []).object); + } static final _id_copy = jniAccessors.getMethodIDOf( _classRef, r"copy", r"()Lcom/fasterxml/jackson/core/JsonFactory;"); @@ -260,9 +277,10 @@ class JsonFactory extends jni.JObject { /// set codec after making the copy. ///@return Copy of this factory instance ///@since 2.1 - JsonFactory copy() => - const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_copy, jni.JniCallType.objectType, []).object); + JsonFactory copy() { + return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_copy, jni.JniCallType.objectType, []).object); + } static final _id_readResolve = jniAccessors.getMethodIDOf( _classRef, r"readResolve", r"()Ljava/lang/Object;"); @@ -276,9 +294,10 @@ class JsonFactory extends jni.JObject { /// /// Note: must be overridden by sub-classes as well. ///@return Newly constructed instance - jni.JObject readResolve() => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_readResolve, jni.JniCallType.objectType, []).object); + jni.JObject readResolve() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_readResolve, jni.JniCallType.objectType, []).object); + } static final _id_requiresPropertyOrdering = jniAccessors.getMethodIDOf( _classRef, r"requiresPropertyOrdering", r"()Z"); @@ -299,8 +318,10 @@ class JsonFactory extends jni.JObject { ///@return Whether format supported by this factory /// requires Object properties to be ordered. ///@since 2.3 - bool requiresPropertyOrdering() => jniAccessors.callMethodWithArgs(reference, - _id_requiresPropertyOrdering, jni.JniCallType.booleanType, []).boolean; + bool requiresPropertyOrdering() { + return jniAccessors.callMethodWithArgs(reference, + _id_requiresPropertyOrdering, jni.JniCallType.booleanType, []).boolean; + } static final _id_canHandleBinaryNatively = jniAccessors.getMethodIDOf(_classRef, r"canHandleBinaryNatively", r"()Z"); @@ -318,8 +339,10 @@ class JsonFactory extends jni.JObject { ///@return Whether format supported by this factory /// supports native binary content ///@since 2.3 - bool canHandleBinaryNatively() => jniAccessors.callMethodWithArgs(reference, - _id_canHandleBinaryNatively, jni.JniCallType.booleanType, []).boolean; + bool canHandleBinaryNatively() { + return jniAccessors.callMethodWithArgs(reference, + _id_canHandleBinaryNatively, jni.JniCallType.booleanType, []).boolean; + } static final _id_canUseCharArrays = jniAccessors.getMethodIDOf(_classRef, r"canUseCharArrays", r"()Z"); @@ -337,8 +360,10 @@ class JsonFactory extends jni.JObject { ///@return Whether access to decoded textual content can be efficiently /// accessed using parser method {@code getTextCharacters()}. ///@since 2.4 - bool canUseCharArrays() => jniAccessors.callMethodWithArgs( - reference, _id_canUseCharArrays, jni.JniCallType.booleanType, []).boolean; + bool canUseCharArrays() { + return jniAccessors.callMethodWithArgs(reference, _id_canUseCharArrays, + jni.JniCallType.booleanType, []).boolean; + } static final _id_canParseAsync = jniAccessors.getMethodIDOf(_classRef, r"canParseAsync", r"()Z"); @@ -352,28 +377,34 @@ class JsonFactory extends jni.JObject { ///@return Whether this factory supports non-blocking ("async") parsing or /// not (and consequently whether {@code createNonBlockingXxx()} method(s) work) ///@since 2.9 - bool canParseAsync() => jniAccessors.callMethodWithArgs( - reference, _id_canParseAsync, jni.JniCallType.booleanType, []).boolean; + bool canParseAsync() { + return jniAccessors.callMethodWithArgs( + reference, _id_canParseAsync, jni.JniCallType.booleanType, []).boolean; + } static final _id_getFormatReadFeatureType = jniAccessors.getMethodIDOf( _classRef, r"getFormatReadFeatureType", r"()Ljava/lang/Class;"); /// from: public java.lang.Class getFormatReadFeatureType() /// The returned object must be deleted after use, by calling the `delete` method. - jni.JObject getFormatReadFeatureType() => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs(reference, - _id_getFormatReadFeatureType, jni.JniCallType.objectType, []).object); + jni.JObject getFormatReadFeatureType() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_getFormatReadFeatureType, + jni.JniCallType.objectType, []).object); + } static final _id_getFormatWriteFeatureType = jniAccessors.getMethodIDOf( _classRef, r"getFormatWriteFeatureType", r"()Ljava/lang/Class;"); /// from: public java.lang.Class getFormatWriteFeatureType() /// The returned object must be deleted after use, by calling the `delete` method. - jni.JObject getFormatWriteFeatureType() => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_getFormatWriteFeatureType, - jni.JniCallType.objectType, []).object); + jni.JObject getFormatWriteFeatureType() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_getFormatWriteFeatureType, + jni.JniCallType.objectType, []).object); + } static final _id_canUseSchema = jniAccessors.getMethodIDOf(_classRef, r"canUseSchema", r"(Lcom/fasterxml/jackson/core/FormatSchema;)Z"); @@ -389,11 +420,12 @@ class JsonFactory extends jni.JObject { ///@param schema Schema instance to check ///@return Whether parsers and generators constructed by this factory /// can use specified format schema instance - bool canUseSchema(jni.JObject schema) => jniAccessors.callMethodWithArgs( - reference, - _id_canUseSchema, - jni.JniCallType.booleanType, - [schema.reference]).boolean; + bool canUseSchema( + jni.JObject schema, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_canUseSchema, + jni.JniCallType.booleanType, [schema.reference]).boolean; + } static final _id_getFormatName = jniAccessors.getMethodIDOf( _classRef, r"getFormatName", r"()Ljava/lang/String;"); @@ -407,9 +439,10 @@ class JsonFactory extends jni.JObject { /// Note: sub-classes should override this method; default /// implementation will return null for all sub-classes ///@return Name of the format handled by parsers, generators this factory creates - jni.JString getFormatName() => - const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_getFormatName, jni.JniCallType.objectType, []).object); + jni.JString getFormatName() { + return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_getFormatName, jni.JniCallType.objectType, []).object); + } static final _id_hasFormat = jniAccessors.getMethodIDOf( _classRef, @@ -418,9 +451,15 @@ class JsonFactory extends jni.JObject { /// from: public com.fasterxml.jackson.core.format.MatchStrength hasFormat(com.fasterxml.jackson.core.format.InputAccessor acc) /// The returned object must be deleted after use, by calling the `delete` method. - jni.JObject hasFormat(jni.JObject acc) => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs(reference, - _id_hasFormat, jni.JniCallType.objectType, [acc.reference]).object); + jni.JObject hasFormat( + jni.JObject acc, + ) { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_hasFormat, + jni.JniCallType.objectType, + [acc.reference]).object); + } static final _id_requiresCustomCodec = jniAccessors.getMethodIDOf(_classRef, r"requiresCustomCodec", r"()Z"); @@ -436,8 +475,10 @@ class JsonFactory extends jni.JObject { /// generators created by this factory; false if a general /// ObjectCodec is enough ///@since 2.1 - bool requiresCustomCodec() => jniAccessors.callMethodWithArgs(reference, - _id_requiresCustomCodec, jni.JniCallType.booleanType, []).boolean; + bool requiresCustomCodec() { + return jniAccessors.callMethodWithArgs(reference, _id_requiresCustomCodec, + jni.JniCallType.booleanType, []).boolean; + } static final _id_hasJSONFormat = jniAccessors.getMethodIDOf( _classRef, @@ -446,21 +487,25 @@ class JsonFactory extends jni.JObject { /// from: protected com.fasterxml.jackson.core.format.MatchStrength hasJSONFormat(com.fasterxml.jackson.core.format.InputAccessor acc) /// The returned object must be deleted after use, by calling the `delete` method. - jni.JObject hasJSONFormat(jni.JObject acc) => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_hasJSONFormat, - jni.JniCallType.objectType, - [acc.reference]).object); + jni.JObject hasJSONFormat( + jni.JObject acc, + ) { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_hasJSONFormat, + jni.JniCallType.objectType, + [acc.reference]).object); + } static final _id_version = jniAccessors.getMethodIDOf( _classRef, r"version", r"()Lcom/fasterxml/jackson/core/Version;"); /// from: public com.fasterxml.jackson.core.Version version() /// The returned object must be deleted after use, by calling the `delete` method. - jni.JObject version() => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_version, jni.JniCallType.objectType, []).object); + jni.JObject version() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_version, jni.JniCallType.objectType, []).object); + } static final _id_configure = jniAccessors.getMethodIDOf( _classRef, @@ -476,12 +521,16 @@ class JsonFactory extends jni.JObject { ///@param state Whether to enable or disable the feature ///@return This factory instance (to allow call chaining) ///@deprecated since 2.10 use JsonFactoryBuilder\#configure(JsonFactory.Feature, boolean) instead - JsonFactory configure(JsonFactory_Feature f, bool state) => - const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_configure, - jni.JniCallType.objectType, - [f.reference, state ? 1 : 0]).object); + JsonFactory configure( + JsonFactory_Feature f, + bool state, + ) { + return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_configure, + jni.JniCallType.objectType, + [f.reference, state ? 1 : 0]).object); + } static final _id_enable = jniAccessors.getMethodIDOf(_classRef, r"enable", r"(Lcom/fasterxml/jackson/core/JsonFactory$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); @@ -494,12 +543,15 @@ class JsonFactory extends jni.JObject { ///@param f Feature to enable ///@return This factory instance (to allow call chaining) ///@deprecated since 2.10 use JsonFactoryBuilder\#configure(JsonFactory.Feature, boolean) instead - JsonFactory enable(JsonFactory_Feature f) => - const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_enable, - jni.JniCallType.objectType, - [f.reference]).object); + JsonFactory enable( + JsonFactory_Feature f, + ) { + return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_enable, + jni.JniCallType.objectType, + [f.reference]).object); + } static final _id_disable = jniAccessors.getMethodIDOf(_classRef, r"disable", r"(Lcom/fasterxml/jackson/core/JsonFactory$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); @@ -512,12 +564,15 @@ class JsonFactory extends jni.JObject { ///@param f Feature to disable ///@return This factory instance (to allow call chaining) ///@deprecated since 2.10 use JsonFactoryBuilder\#configure(JsonFactory.Feature, boolean) instead - JsonFactory disable(JsonFactory_Feature f) => - const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_disable, - jni.JniCallType.objectType, - [f.reference]).object); + JsonFactory disable( + JsonFactory_Feature f, + ) { + return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_disable, + jni.JniCallType.objectType, + [f.reference]).object); + } static final _id_isEnabled = jniAccessors.getMethodIDOf(_classRef, r"isEnabled", r"(Lcom/fasterxml/jackson/core/JsonFactory$Feature;)Z"); @@ -527,39 +582,48 @@ class JsonFactory extends jni.JObject { /// Checked whether specified parser feature is enabled. ///@param f Feature to check ///@return True if the specified feature is enabled - bool isEnabled(JsonFactory_Feature f) => jniAccessors.callMethodWithArgs( - reference, - _id_isEnabled, - jni.JniCallType.booleanType, - [f.reference]).boolean; + bool isEnabled( + JsonFactory_Feature f, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_isEnabled, + jni.JniCallType.booleanType, [f.reference]).boolean; + } static final _id_getParserFeatures = jniAccessors.getMethodIDOf(_classRef, r"getParserFeatures", r"()I"); /// from: public final int getParserFeatures() - int getParserFeatures() => jniAccessors.callMethodWithArgs( - reference, _id_getParserFeatures, jni.JniCallType.intType, []).integer; + int getParserFeatures() { + return jniAccessors.callMethodWithArgs( + reference, _id_getParserFeatures, jni.JniCallType.intType, []).integer; + } static final _id_getGeneratorFeatures = jniAccessors.getMethodIDOf(_classRef, r"getGeneratorFeatures", r"()I"); /// from: public final int getGeneratorFeatures() - int getGeneratorFeatures() => jniAccessors.callMethodWithArgs( - reference, _id_getGeneratorFeatures, jni.JniCallType.intType, []).integer; + int getGeneratorFeatures() { + return jniAccessors.callMethodWithArgs(reference, _id_getGeneratorFeatures, + jni.JniCallType.intType, []).integer; + } static final _id_getFormatParserFeatures = jniAccessors.getMethodIDOf(_classRef, r"getFormatParserFeatures", r"()I"); /// from: public int getFormatParserFeatures() - int getFormatParserFeatures() => jniAccessors.callMethodWithArgs(reference, - _id_getFormatParserFeatures, jni.JniCallType.intType, []).integer; + int getFormatParserFeatures() { + return jniAccessors.callMethodWithArgs(reference, + _id_getFormatParserFeatures, jni.JniCallType.intType, []).integer; + } static final _id_getFormatGeneratorFeatures = jniAccessors.getMethodIDOf( _classRef, r"getFormatGeneratorFeatures", r"()I"); /// from: public int getFormatGeneratorFeatures() - int getFormatGeneratorFeatures() => jniAccessors.callMethodWithArgs(reference, - _id_getFormatGeneratorFeatures, jni.JniCallType.intType, []).integer; + int getFormatGeneratorFeatures() { + return jniAccessors.callMethodWithArgs(reference, + _id_getFormatGeneratorFeatures, jni.JniCallType.intType, []).integer; + } static final _id_configure1 = jniAccessors.getMethodIDOf( _classRef, @@ -574,12 +638,16 @@ class JsonFactory extends jni.JObject { ///@param f Feature to enable/disable ///@param state Whether to enable or disable the feature ///@return This factory instance (to allow call chaining) - JsonFactory configure1(jsonparser_.JsonParser_Feature f, bool state) => - const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_configure1, - jni.JniCallType.objectType, - [f.reference, state ? 1 : 0]).object); + JsonFactory configure1( + jsonparser_.JsonParser_Feature f, + bool state, + ) { + return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_configure1, + jni.JniCallType.objectType, + [f.reference, state ? 1 : 0]).object); + } static final _id_enable1 = jniAccessors.getMethodIDOf(_classRef, r"enable", r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); @@ -591,12 +659,15 @@ class JsonFactory extends jni.JObject { /// (check JsonParser.Feature for list of features) ///@param f Feature to enable ///@return This factory instance (to allow call chaining) - JsonFactory enable1(jsonparser_.JsonParser_Feature f) => - const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_enable1, - jni.JniCallType.objectType, - [f.reference]).object); + JsonFactory enable1( + jsonparser_.JsonParser_Feature f, + ) { + return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_enable1, + jni.JniCallType.objectType, + [f.reference]).object); + } static final _id_disable1 = jniAccessors.getMethodIDOf(_classRef, r"disable", r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); @@ -608,12 +679,15 @@ class JsonFactory extends jni.JObject { /// (check JsonParser.Feature for list of features) ///@param f Feature to disable ///@return This factory instance (to allow call chaining) - JsonFactory disable1(jsonparser_.JsonParser_Feature f) => - const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_disable1, - jni.JniCallType.objectType, - [f.reference]).object); + JsonFactory disable1( + jsonparser_.JsonParser_Feature f, + ) { + return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_disable1, + jni.JniCallType.objectType, + [f.reference]).object); + } static final _id_isEnabled1 = jniAccessors.getMethodIDOf(_classRef, r"isEnabled", r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Z"); @@ -623,9 +697,12 @@ class JsonFactory extends jni.JObject { /// Method for checking if the specified parser feature is enabled. ///@param f Feature to check ///@return True if specified feature is enabled - bool isEnabled1(jsonparser_.JsonParser_Feature f) => - jniAccessors.callMethodWithArgs(reference, _id_isEnabled1, - jni.JniCallType.booleanType, [f.reference]).boolean; + bool isEnabled1( + jsonparser_.JsonParser_Feature f, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_isEnabled1, + jni.JniCallType.booleanType, [f.reference]).boolean; + } static final _id_isEnabled2 = jniAccessors.getMethodIDOf(_classRef, r"isEnabled", r"(Lcom/fasterxml/jackson/core/StreamReadFeature;)Z"); @@ -636,8 +713,12 @@ class JsonFactory extends jni.JObject { ///@param f Feature to check ///@return True if specified feature is enabled ///@since 2.10 - bool isEnabled2(jni.JObject f) => jniAccessors.callMethodWithArgs(reference, - _id_isEnabled2, jni.JniCallType.booleanType, [f.reference]).boolean; + bool isEnabled2( + jni.JObject f, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_isEnabled2, + jni.JniCallType.booleanType, [f.reference]).boolean; + } static final _id_getInputDecorator = jniAccessors.getMethodIDOf( _classRef, @@ -650,9 +731,12 @@ class JsonFactory extends jni.JObject { /// Method for getting currently configured input decorator (if any; /// there is no default decorator). ///@return InputDecorator configured, if any - jni.JObject getInputDecorator() => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs(reference, - _id_getInputDecorator, jni.JniCallType.objectType, []).object); + jni.JObject getInputDecorator() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_getInputDecorator, + jni.JniCallType.objectType, []).object); + } static final _id_setInputDecorator = jniAccessors.getMethodIDOf( _classRef, @@ -666,12 +750,15 @@ class JsonFactory extends jni.JObject { ///@param d Decorator to configure for this factory, if any ({@code null} if none) ///@return This factory instance (to allow call chaining) ///@deprecated Since 2.10 use JsonFactoryBuilder\#inputDecorator(InputDecorator) instead - JsonFactory setInputDecorator(jni.JObject d) => - const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_setInputDecorator, - jni.JniCallType.objectType, - [d.reference]).object); + JsonFactory setInputDecorator( + jni.JObject d, + ) { + return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_setInputDecorator, + jni.JniCallType.objectType, + [d.reference]).object); + } static final _id_configure2 = jniAccessors.getMethodIDOf( _classRef, @@ -686,12 +773,16 @@ class JsonFactory extends jni.JObject { ///@param f Feature to enable/disable ///@param state Whether to enable or disable the feature ///@return This factory instance (to allow call chaining) - JsonFactory configure2(jni.JObject f, bool state) => - const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_configure2, - jni.JniCallType.objectType, - [f.reference, state ? 1 : 0]).object); + JsonFactory configure2( + jni.JObject f, + bool state, + ) { + return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_configure2, + jni.JniCallType.objectType, + [f.reference, state ? 1 : 0]).object); + } static final _id_enable2 = jniAccessors.getMethodIDOf(_classRef, r"enable", r"(Lcom/fasterxml/jackson/core/JsonGenerator$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); @@ -703,12 +794,15 @@ class JsonFactory extends jni.JObject { /// (check JsonGenerator.Feature for list of features) ///@param f Feature to enable ///@return This factory instance (to allow call chaining) - JsonFactory enable2(jni.JObject f) => - const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_enable2, - jni.JniCallType.objectType, - [f.reference]).object); + JsonFactory enable2( + jni.JObject f, + ) { + return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_enable2, + jni.JniCallType.objectType, + [f.reference]).object); + } static final _id_disable2 = jniAccessors.getMethodIDOf(_classRef, r"disable", r"(Lcom/fasterxml/jackson/core/JsonGenerator$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); @@ -720,12 +814,15 @@ class JsonFactory extends jni.JObject { /// (check JsonGenerator.Feature for list of features) ///@param f Feature to disable ///@return This factory instance (to allow call chaining) - JsonFactory disable2(jni.JObject f) => - const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_disable2, - jni.JniCallType.objectType, - [f.reference]).object); + JsonFactory disable2( + jni.JObject f, + ) { + return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_disable2, + jni.JniCallType.objectType, + [f.reference]).object); + } static final _id_isEnabled3 = jniAccessors.getMethodIDOf(_classRef, r"isEnabled", r"(Lcom/fasterxml/jackson/core/JsonGenerator$Feature;)Z"); @@ -735,8 +832,12 @@ class JsonFactory extends jni.JObject { /// Check whether specified generator feature is enabled. ///@param f Feature to check ///@return Whether specified feature is enabled - bool isEnabled3(jni.JObject f) => jniAccessors.callMethodWithArgs(reference, - _id_isEnabled3, jni.JniCallType.booleanType, [f.reference]).boolean; + bool isEnabled3( + jni.JObject f, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_isEnabled3, + jni.JniCallType.booleanType, [f.reference]).boolean; + } static final _id_isEnabled4 = jniAccessors.getMethodIDOf(_classRef, r"isEnabled", r"(Lcom/fasterxml/jackson/core/StreamWriteFeature;)Z"); @@ -747,8 +848,12 @@ class JsonFactory extends jni.JObject { ///@param f Feature to check ///@return Whether specified feature is enabled ///@since 2.10 - bool isEnabled4(jni.JObject f) => jniAccessors.callMethodWithArgs(reference, - _id_isEnabled4, jni.JniCallType.booleanType, [f.reference]).boolean; + bool isEnabled4( + jni.JObject f, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_isEnabled4, + jni.JniCallType.booleanType, [f.reference]).boolean; + } static final _id_getCharacterEscapes = jniAccessors.getMethodIDOf( _classRef, @@ -761,9 +866,12 @@ class JsonFactory extends jni.JObject { /// Method for accessing custom escapes factory uses for JsonGenerators /// it creates. ///@return Configured {@code CharacterEscapes}, if any; {@code null} if none - jni.JObject getCharacterEscapes() => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs(reference, - _id_getCharacterEscapes, jni.JniCallType.objectType, []).object); + jni.JObject getCharacterEscapes() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_getCharacterEscapes, + jni.JniCallType.objectType, []).object); + } static final _id_setCharacterEscapes = jniAccessors.getMethodIDOf( _classRef, @@ -777,12 +885,15 @@ class JsonFactory extends jni.JObject { /// it creates. ///@param esc CharaterEscapes to set (or {@code null} for "none") ///@return This factory instance (to allow call chaining) - JsonFactory setCharacterEscapes(jni.JObject esc) => - const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_setCharacterEscapes, - jni.JniCallType.objectType, - [esc.reference]).object); + JsonFactory setCharacterEscapes( + jni.JObject esc, + ) { + return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_setCharacterEscapes, + jni.JniCallType.objectType, + [esc.reference]).object); + } static final _id_getOutputDecorator = jniAccessors.getMethodIDOf( _classRef, @@ -796,9 +907,12 @@ class JsonFactory extends jni.JObject { /// there is no default decorator). ///@return OutputDecorator configured for generators factory creates, if any; /// {@code null} if none. - jni.JObject getOutputDecorator() => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs(reference, - _id_getOutputDecorator, jni.JniCallType.objectType, []).object); + jni.JObject getOutputDecorator() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_getOutputDecorator, + jni.JniCallType.objectType, []).object); + } static final _id_setOutputDecorator = jniAccessors.getMethodIDOf( _classRef, @@ -812,12 +926,15 @@ class JsonFactory extends jni.JObject { ///@return This factory instance (to allow call chaining) ///@param d Output decorator to use, if any ///@deprecated Since 2.10 use JsonFactoryBuilder\#outputDecorator(OutputDecorator) instead - JsonFactory setOutputDecorator(jni.JObject d) => - const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_setOutputDecorator, - jni.JniCallType.objectType, - [d.reference]).object); + JsonFactory setOutputDecorator( + jni.JObject d, + ) { + return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_setOutputDecorator, + jni.JniCallType.objectType, + [d.reference]).object); + } static final _id_setRootValueSeparator = jniAccessors.getMethodIDOf( _classRef, @@ -832,12 +949,15 @@ class JsonFactory extends jni.JObject { ///@param sep Separator to use, if any; null means that no separator is /// automatically added ///@return This factory instance (to allow call chaining) - JsonFactory setRootValueSeparator(jni.JString sep) => - const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_setRootValueSeparator, - jni.JniCallType.objectType, - [sep.reference]).object); + JsonFactory setRootValueSeparator( + jni.JString sep, + ) { + return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_setRootValueSeparator, + jni.JniCallType.objectType, + [sep.reference]).object); + } static final _id_getRootValueSeparator = jniAccessors.getMethodIDOf( _classRef, r"getRootValueSeparator", r"()Ljava/lang/String;"); @@ -846,9 +966,12 @@ class JsonFactory extends jni.JObject { /// The returned object must be deleted after use, by calling the `delete` method. /// /// @return Root value separator configured, if any - jni.JString getRootValueSeparator() => - const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs(reference, - _id_getRootValueSeparator, jni.JniCallType.objectType, []).object); + jni.JString getRootValueSeparator() { + return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_getRootValueSeparator, + jni.JniCallType.objectType, []).object); + } static final _id_setCodec = jniAccessors.getMethodIDOf(_classRef, r"setCodec", r"(Lcom/fasterxml/jackson/core/ObjectCodec;)Lcom/fasterxml/jackson/core/JsonFactory;"); @@ -863,21 +986,25 @@ class JsonFactory extends jni.JObject { /// of JsonParser and JsonGenerator instances. ///@param oc Codec to use ///@return This factory instance (to allow call chaining) - JsonFactory setCodec(jni.JObject oc) => - const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_setCodec, - jni.JniCallType.objectType, - [oc.reference]).object); + JsonFactory setCodec( + jni.JObject oc, + ) { + return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_setCodec, + jni.JniCallType.objectType, + [oc.reference]).object); + } static final _id_getCodec = jniAccessors.getMethodIDOf( _classRef, r"getCodec", r"()Lcom/fasterxml/jackson/core/ObjectCodec;"); /// from: public com.fasterxml.jackson.core.ObjectCodec getCodec() /// The returned object must be deleted after use, by calling the `delete` method. - jni.JObject getCodec() => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_getCodec, jni.JniCallType.objectType, []).object); + jni.JObject getCodec() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_getCodec, jni.JniCallType.objectType, []).object); + } static final _id_createParser = jniAccessors.getMethodIDOf( _classRef, @@ -903,10 +1030,13 @@ class JsonFactory extends jni.JObject { /// the parser, since caller has no access to it. ///@param f File that contains JSON content to parse ///@since 2.1 - jsonparser_.JsonParser createParser(jni.JObject f) => - const jsonparser_.$JsonParserType().fromRef(jniAccessors - .callMethodWithArgs(reference, _id_createParser, - jni.JniCallType.objectType, [f.reference]).object); + jsonparser_.JsonParser createParser( + jni.JObject f, + ) { + return const jsonparser_.$JsonParserType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_createParser, + jni.JniCallType.objectType, [f.reference]).object); + } static final _id_createParser1 = jniAccessors.getMethodIDOf( _classRef, @@ -930,10 +1060,13 @@ class JsonFactory extends jni.JObject { /// the parser, since caller has no access to it. ///@param url URL pointing to resource that contains JSON content to parse ///@since 2.1 - jsonparser_.JsonParser createParser1(jni.JObject url) => - const jsonparser_.$JsonParserType().fromRef(jniAccessors - .callMethodWithArgs(reference, _id_createParser1, - jni.JniCallType.objectType, [url.reference]).object); + jsonparser_.JsonParser createParser1( + jni.JObject url, + ) { + return const jsonparser_.$JsonParserType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_createParser1, + jni.JniCallType.objectType, [url.reference]).object); + } static final _id_createParser2 = jniAccessors.getMethodIDOf( _classRef, @@ -960,10 +1093,13 @@ class JsonFactory extends jni.JObject { /// For other charsets use \#createParser(java.io.Reader). ///@param in InputStream to use for reading JSON content to parse ///@since 2.1 - jsonparser_.JsonParser createParser2(jni.JObject in0) => - const jsonparser_.$JsonParserType().fromRef(jniAccessors - .callMethodWithArgs(reference, _id_createParser2, - jni.JniCallType.objectType, [in0.reference]).object); + jsonparser_.JsonParser createParser2( + jni.JObject in0, + ) { + return const jsonparser_.$JsonParserType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_createParser2, + jni.JniCallType.objectType, [in0.reference]).object); + } static final _id_createParser3 = jniAccessors.getMethodIDOf( _classRef, @@ -983,10 +1119,13 @@ class JsonFactory extends jni.JObject { /// is enabled. ///@param r Reader to use for reading JSON content to parse ///@since 2.1 - jsonparser_.JsonParser createParser3(jni.JObject r) => - const jsonparser_.$JsonParserType().fromRef(jniAccessors - .callMethodWithArgs(reference, _id_createParser3, - jni.JniCallType.objectType, [r.reference]).object); + jsonparser_.JsonParser createParser3( + jni.JObject r, + ) { + return const jsonparser_.$JsonParserType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_createParser3, + jni.JniCallType.objectType, [r.reference]).object); + } static final _id_createParser4 = jniAccessors.getMethodIDOf(_classRef, r"createParser", r"([B)Lcom/fasterxml/jackson/core/JsonParser;"); @@ -997,10 +1136,13 @@ class JsonFactory extends jni.JObject { /// Method for constructing parser for parsing /// the contents of given byte array. ///@since 2.1 - jsonparser_.JsonParser createParser4(jni.JArray data) => - const jsonparser_.$JsonParserType().fromRef(jniAccessors - .callMethodWithArgs(reference, _id_createParser4, - jni.JniCallType.objectType, [data.reference]).object); + jsonparser_.JsonParser createParser4( + jni.JArray data, + ) { + return const jsonparser_.$JsonParserType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_createParser4, + jni.JniCallType.objectType, [data.reference]).object); + } static final _id_createParser5 = jniAccessors.getMethodIDOf(_classRef, r"createParser", r"([BII)Lcom/fasterxml/jackson/core/JsonParser;"); @@ -1015,14 +1157,18 @@ class JsonFactory extends jni.JObject { ///@param len Length of contents to parse within buffer ///@since 2.1 jsonparser_.JsonParser createParser5( - jni.JArray data, int offset, int len) => - const jsonparser_.$JsonParserType().fromRef(jniAccessors - .callMethodWithArgs( - reference, _id_createParser5, jni.JniCallType.objectType, [ - data.reference, - jni.JValueInt(offset), - jni.JValueInt(len) - ]).object); + jni.JArray data, + int offset, + int len, + ) { + return const jsonparser_.$JsonParserType().fromRef(jniAccessors + .callMethodWithArgs( + reference, _id_createParser5, jni.JniCallType.objectType, [ + data.reference, + jni.JValueInt(offset), + jni.JValueInt(len) + ]).object); + } static final _id_createParser6 = jniAccessors.getMethodIDOf( _classRef, @@ -1035,10 +1181,13 @@ class JsonFactory extends jni.JObject { /// Method for constructing parser for parsing /// contents of given String. ///@since 2.1 - jsonparser_.JsonParser createParser6(jni.JString content) => - const jsonparser_.$JsonParserType().fromRef(jniAccessors - .callMethodWithArgs(reference, _id_createParser6, - jni.JniCallType.objectType, [content.reference]).object); + jsonparser_.JsonParser createParser6( + jni.JString content, + ) { + return const jsonparser_.$JsonParserType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_createParser6, + jni.JniCallType.objectType, [content.reference]).object); + } static final _id_createParser7 = jniAccessors.getMethodIDOf(_classRef, r"createParser", r"([C)Lcom/fasterxml/jackson/core/JsonParser;"); @@ -1049,10 +1198,13 @@ class JsonFactory extends jni.JObject { /// Method for constructing parser for parsing /// contents of given char array. ///@since 2.4 - jsonparser_.JsonParser createParser7(jni.JArray content) => - const jsonparser_.$JsonParserType().fromRef(jniAccessors - .callMethodWithArgs(reference, _id_createParser7, - jni.JniCallType.objectType, [content.reference]).object); + jsonparser_.JsonParser createParser7( + jni.JArray content, + ) { + return const jsonparser_.$JsonParserType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_createParser7, + jni.JniCallType.objectType, [content.reference]).object); + } static final _id_createParser8 = jniAccessors.getMethodIDOf(_classRef, r"createParser", r"([CII)Lcom/fasterxml/jackson/core/JsonParser;"); @@ -1063,14 +1215,18 @@ class JsonFactory extends jni.JObject { /// Method for constructing parser for parsing contents of given char array. ///@since 2.4 jsonparser_.JsonParser createParser8( - jni.JArray content, int offset, int len) => - const jsonparser_.$JsonParserType().fromRef(jniAccessors - .callMethodWithArgs( - reference, _id_createParser8, jni.JniCallType.objectType, [ - content.reference, - jni.JValueInt(offset), - jni.JValueInt(len) - ]).object); + jni.JArray content, + int offset, + int len, + ) { + return const jsonparser_.$JsonParserType().fromRef(jniAccessors + .callMethodWithArgs( + reference, _id_createParser8, jni.JniCallType.objectType, [ + content.reference, + jni.JValueInt(offset), + jni.JValueInt(len) + ]).object); + } static final _id_createParser9 = jniAccessors.getMethodIDOf( _classRef, @@ -1086,10 +1242,13 @@ class JsonFactory extends jni.JObject { /// If this factory does not support DataInput as source, /// will throw UnsupportedOperationException ///@since 2.8 - jsonparser_.JsonParser createParser9(jni.JObject in0) => - const jsonparser_.$JsonParserType().fromRef(jniAccessors - .callMethodWithArgs(reference, _id_createParser9, - jni.JniCallType.objectType, [in0.reference]).object); + jsonparser_.JsonParser createParser9( + jni.JObject in0, + ) { + return const jsonparser_.$JsonParserType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_createParser9, + jni.JniCallType.objectType, [in0.reference]).object); + } static final _id_createNonBlockingByteArrayParser = jniAccessors.getMethodIDOf(_classRef, r"createNonBlockingByteArrayParser", @@ -1111,10 +1270,11 @@ class JsonFactory extends jni.JObject { /// (and US-ASCII since it is proper subset); other encodings are not supported /// at this point. ///@since 2.9 - jsonparser_.JsonParser createNonBlockingByteArrayParser() => - const jsonparser_.$JsonParserType().fromRef(jniAccessors - .callMethodWithArgs(reference, _id_createNonBlockingByteArrayParser, - jni.JniCallType.objectType, []).object); + jsonparser_.JsonParser createNonBlockingByteArrayParser() { + return const jsonparser_.$JsonParserType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_createNonBlockingByteArrayParser, + jni.JniCallType.objectType, []).object); + } static final _id_createGenerator = jniAccessors.getMethodIDOf( _classRef, @@ -1142,12 +1302,16 @@ class JsonFactory extends jni.JObject { ///@param out OutputStream to use for writing JSON content ///@param enc Character encoding to use ///@since 2.1 - jni.JObject createGenerator(jni.JObject out, jni.JObject enc) => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_createGenerator, - jni.JniCallType.objectType, - [out.reference, enc.reference]).object); + jni.JObject createGenerator( + jni.JObject out, + jni.JObject enc, + ) { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_createGenerator, + jni.JniCallType.objectType, + [out.reference, enc.reference]).object); + } static final _id_createGenerator1 = jniAccessors.getMethodIDOf( _classRef, @@ -1162,12 +1326,15 @@ class JsonFactory extends jni.JObject { /// /// Note: there are formats that use fixed encoding (like most binary data formats). ///@since 2.1 - jni.JObject createGenerator1(jni.JObject out) => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_createGenerator1, - jni.JniCallType.objectType, - [out.reference]).object); + jni.JObject createGenerator1( + jni.JObject out, + ) { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_createGenerator1, + jni.JniCallType.objectType, + [out.reference]).object); + } static final _id_createGenerator2 = jniAccessors.getMethodIDOf( _classRef, @@ -1188,12 +1355,15 @@ class JsonFactory extends jni.JObject { /// Using application needs to close it explicitly. ///@since 2.1 ///@param w Writer to use for writing JSON content - jni.JObject createGenerator2(jni.JObject w) => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_createGenerator2, - jni.JniCallType.objectType, - [w.reference]).object); + jni.JObject createGenerator2( + jni.JObject w, + ) { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_createGenerator2, + jni.JniCallType.objectType, + [w.reference]).object); + } static final _id_createGenerator3 = jniAccessors.getMethodIDOf( _classRef, @@ -1215,12 +1385,16 @@ class JsonFactory extends jni.JObject { ///@param f File to write contents to ///@param enc Character encoding to use ///@since 2.1 - jni.JObject createGenerator3(jni.JObject f, jni.JObject enc) => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_createGenerator3, - jni.JniCallType.objectType, - [f.reference, enc.reference]).object); + jni.JObject createGenerator3( + jni.JObject f, + jni.JObject enc, + ) { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_createGenerator3, + jni.JniCallType.objectType, + [f.reference, enc.reference]).object); + } static final _id_createGenerator4 = jniAccessors.getMethodIDOf( _classRef, @@ -1233,12 +1407,16 @@ class JsonFactory extends jni.JObject { /// Method for constructing generator for writing content using specified /// DataOutput instance. ///@since 2.8 - jni.JObject createGenerator4(jni.JObject out, jni.JObject enc) => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_createGenerator4, - jni.JniCallType.objectType, - [out.reference, enc.reference]).object); + jni.JObject createGenerator4( + jni.JObject out, + jni.JObject enc, + ) { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_createGenerator4, + jni.JniCallType.objectType, + [out.reference, enc.reference]).object); + } static final _id_createGenerator5 = jniAccessors.getMethodIDOf( _classRef, @@ -1253,12 +1431,15 @@ class JsonFactory extends jni.JObject { /// /// Note: there are formats that use fixed encoding (like most binary data formats). ///@since 2.8 - jni.JObject createGenerator5(jni.JObject out) => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_createGenerator5, - jni.JniCallType.objectType, - [out.reference]).object); + jni.JObject createGenerator5( + jni.JObject out, + ) { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_createGenerator5, + jni.JniCallType.objectType, + [out.reference]).object); + } static final _id_createJsonParser = jniAccessors.getMethodIDOf( _classRef, @@ -1286,10 +1467,13 @@ class JsonFactory extends jni.JObject { ///@throws IOException if parser initialization fails due to I/O (read) problem ///@throws JsonParseException if parser initialization fails due to content decoding problem ///@deprecated Since 2.2, use \#createParser(File) instead. - jsonparser_.JsonParser createJsonParser(jni.JObject f) => - const jsonparser_.$JsonParserType().fromRef(jniAccessors - .callMethodWithArgs(reference, _id_createJsonParser, - jni.JniCallType.objectType, [f.reference]).object); + jsonparser_.JsonParser createJsonParser( + jni.JObject f, + ) { + return const jsonparser_.$JsonParserType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_createJsonParser, + jni.JniCallType.objectType, [f.reference]).object); + } static final _id_createJsonParser1 = jniAccessors.getMethodIDOf( _classRef, @@ -1316,10 +1500,13 @@ class JsonFactory extends jni.JObject { ///@throws IOException if parser initialization fails due to I/O (read) problem ///@throws JsonParseException if parser initialization fails due to content decoding problem ///@deprecated Since 2.2, use \#createParser(URL) instead. - jsonparser_.JsonParser createJsonParser1(jni.JObject url) => - const jsonparser_.$JsonParserType().fromRef(jniAccessors - .callMethodWithArgs(reference, _id_createJsonParser1, - jni.JniCallType.objectType, [url.reference]).object); + jsonparser_.JsonParser createJsonParser1( + jni.JObject url, + ) { + return const jsonparser_.$JsonParserType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_createJsonParser1, + jni.JniCallType.objectType, [url.reference]).object); + } static final _id_createJsonParser2 = jniAccessors.getMethodIDOf( _classRef, @@ -1349,10 +1536,13 @@ class JsonFactory extends jni.JObject { ///@throws IOException if parser initialization fails due to I/O (read) problem ///@throws JsonParseException if parser initialization fails due to content decoding problem ///@deprecated Since 2.2, use \#createParser(InputStream) instead. - jsonparser_.JsonParser createJsonParser2(jni.JObject in0) => - const jsonparser_.$JsonParserType().fromRef(jniAccessors - .callMethodWithArgs(reference, _id_createJsonParser2, - jni.JniCallType.objectType, [in0.reference]).object); + jsonparser_.JsonParser createJsonParser2( + jni.JObject in0, + ) { + return const jsonparser_.$JsonParserType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_createJsonParser2, + jni.JniCallType.objectType, [in0.reference]).object); + } static final _id_createJsonParser3 = jniAccessors.getMethodIDOf( _classRef, @@ -1375,10 +1565,13 @@ class JsonFactory extends jni.JObject { ///@throws IOException if parser initialization fails due to I/O (read) problem ///@throws JsonParseException if parser initialization fails due to content decoding problem ///@deprecated Since 2.2, use \#createParser(Reader) instead. - jsonparser_.JsonParser createJsonParser3(jni.JObject r) => - const jsonparser_.$JsonParserType().fromRef(jniAccessors - .callMethodWithArgs(reference, _id_createJsonParser3, - jni.JniCallType.objectType, [r.reference]).object); + jsonparser_.JsonParser createJsonParser3( + jni.JObject r, + ) { + return const jsonparser_.$JsonParserType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_createJsonParser3, + jni.JniCallType.objectType, [r.reference]).object); + } static final _id_createJsonParser4 = jniAccessors.getMethodIDOf(_classRef, r"createJsonParser", r"([B)Lcom/fasterxml/jackson/core/JsonParser;"); @@ -1392,10 +1585,13 @@ class JsonFactory extends jni.JObject { ///@throws IOException if parser initialization fails due to I/O (read) problem ///@throws JsonParseException if parser initialization fails due to content decoding problem ///@deprecated Since 2.2, use \#createParser(byte[]) instead. - jsonparser_.JsonParser createJsonParser4(jni.JArray data) => - const jsonparser_.$JsonParserType().fromRef(jniAccessors - .callMethodWithArgs(reference, _id_createJsonParser4, - jni.JniCallType.objectType, [data.reference]).object); + jsonparser_.JsonParser createJsonParser4( + jni.JArray data, + ) { + return const jsonparser_.$JsonParserType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_createJsonParser4, + jni.JniCallType.objectType, [data.reference]).object); + } static final _id_createJsonParser5 = jniAccessors.getMethodIDOf(_classRef, r"createJsonParser", r"([BII)Lcom/fasterxml/jackson/core/JsonParser;"); @@ -1413,14 +1609,18 @@ class JsonFactory extends jni.JObject { ///@throws JsonParseException if parser initialization fails due to content decoding problem ///@deprecated Since 2.2, use \#createParser(byte[],int,int) instead. jsonparser_.JsonParser createJsonParser5( - jni.JArray data, int offset, int len) => - const jsonparser_.$JsonParserType().fromRef(jniAccessors - .callMethodWithArgs( - reference, _id_createJsonParser5, jni.JniCallType.objectType, [ - data.reference, - jni.JValueInt(offset), - jni.JValueInt(len) - ]).object); + jni.JArray data, + int offset, + int len, + ) { + return const jsonparser_.$JsonParserType().fromRef(jniAccessors + .callMethodWithArgs( + reference, _id_createJsonParser5, jni.JniCallType.objectType, [ + data.reference, + jni.JValueInt(offset), + jni.JValueInt(len) + ]).object); + } static final _id_createJsonParser6 = jniAccessors.getMethodIDOf( _classRef, @@ -1437,10 +1637,13 @@ class JsonFactory extends jni.JObject { ///@throws IOException if parser initialization fails due to I/O (read) problem ///@throws JsonParseException if parser initialization fails due to content decoding problem ///@deprecated Since 2.2, use \#createParser(String) instead. - jsonparser_.JsonParser createJsonParser6(jni.JString content) => - const jsonparser_.$JsonParserType().fromRef(jniAccessors - .callMethodWithArgs(reference, _id_createJsonParser6, - jni.JniCallType.objectType, [content.reference]).object); + jsonparser_.JsonParser createJsonParser6( + jni.JString content, + ) { + return const jsonparser_.$JsonParserType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_createJsonParser6, + jni.JniCallType.objectType, [content.reference]).object); + } static final _id_createJsonGenerator = jniAccessors.getMethodIDOf( _classRef, @@ -1470,12 +1673,16 @@ class JsonFactory extends jni.JObject { ///@return Generator constructed ///@throws IOException if parser initialization fails due to I/O (write) problem ///@deprecated Since 2.2, use \#createGenerator(OutputStream, JsonEncoding) instead. - jni.JObject createJsonGenerator(jni.JObject out, jni.JObject enc) => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_createJsonGenerator, - jni.JniCallType.objectType, - [out.reference, enc.reference]).object); + jni.JObject createJsonGenerator( + jni.JObject out, + jni.JObject enc, + ) { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_createJsonGenerator, + jni.JniCallType.objectType, + [out.reference, enc.reference]).object); + } static final _id_createJsonGenerator1 = jniAccessors.getMethodIDOf( _classRef, @@ -1498,12 +1705,15 @@ class JsonFactory extends jni.JObject { ///@return Generator constructed ///@throws IOException if parser initialization fails due to I/O (write) problem ///@deprecated Since 2.2, use \#createGenerator(Writer) instead. - jni.JObject createJsonGenerator1(jni.JObject out) => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_createJsonGenerator1, - jni.JniCallType.objectType, - [out.reference]).object); + jni.JObject createJsonGenerator1( + jni.JObject out, + ) { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_createJsonGenerator1, + jni.JniCallType.objectType, + [out.reference]).object); + } static final _id_createJsonGenerator2 = jniAccessors.getMethodIDOf( _classRef, @@ -1521,12 +1731,15 @@ class JsonFactory extends jni.JObject { ///@return Generator constructed ///@throws IOException if parser initialization fails due to I/O (write) problem ///@deprecated Since 2.2, use \#createGenerator(OutputStream) instead. - jni.JObject createJsonGenerator2(jni.JObject out) => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_createJsonGenerator2, - jni.JniCallType.objectType, - [out.reference]).object); + jni.JObject createJsonGenerator2( + jni.JObject out, + ) { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_createJsonGenerator2, + jni.JniCallType.objectType, + [out.reference]).object); + } } class $JsonFactoryType extends jni.JObjType { @@ -1537,6 +1750,20 @@ class $JsonFactoryType extends jni.JObjType { @override JsonFactory fromRef(jni.JObjectPtr ref) => JsonFactory.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($JsonFactoryType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $JsonFactoryType && other is $JsonFactoryType; + } } /// from: com.fasterxml.jackson.core.JsonFactory$Feature @@ -1544,9 +1771,8 @@ class $JsonFactoryType extends jni.JObjType { /// Enumeration that defines all on/off features that can only be /// changed for JsonFactory. class JsonFactory_Feature extends jni.JObject { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type; + late final jni.JObjType $type = type; JsonFactory_Feature.fromRef( jni.JObjectPtr ref, @@ -1562,10 +1788,11 @@ class JsonFactory_Feature extends jni.JObject { /// from: static public com.fasterxml.jackson.core.JsonFactory.Feature[] values() /// The returned object must be deleted after use, by calling the `delete` method. - static jni.JArray values() => - const jni.JArrayType($JsonFactory_FeatureType()).fromRef(jniAccessors - .callStaticMethodWithArgs( - _classRef, _id_values, jni.JniCallType.objectType, []).object); + static jni.JArray values() { + return const jni.JArrayType($JsonFactory_FeatureType()).fromRef(jniAccessors + .callStaticMethodWithArgs( + _classRef, _id_values, jni.JniCallType.objectType, []).object); + } static final _id_valueOf = jniAccessors.getStaticMethodIDOf( _classRef, @@ -1574,10 +1801,13 @@ class JsonFactory_Feature extends jni.JObject { /// from: static public com.fasterxml.jackson.core.JsonFactory.Feature valueOf(java.lang.String name) /// The returned object must be deleted after use, by calling the `delete` method. - static JsonFactory_Feature valueOf(jni.JString name) => - const $JsonFactory_FeatureType().fromRef(jniAccessors - .callStaticMethodWithArgs(_classRef, _id_valueOf, - jni.JniCallType.objectType, [name.reference]).object); + static JsonFactory_Feature valueOf( + jni.JString name, + ) { + return const $JsonFactory_FeatureType().fromRef(jniAccessors + .callStaticMethodWithArgs(_classRef, _id_valueOf, + jni.JniCallType.objectType, [name.reference]).object); + } static final _id_collectDefaults = jniAccessors.getStaticMethodIDOf(_classRef, r"collectDefaults", r"()I"); @@ -1587,32 +1817,39 @@ class JsonFactory_Feature extends jni.JObject { /// Method that calculates bit set (flags) of all features that /// are enabled by default. ///@return Bit field of features enabled by default - static int collectDefaults() => jniAccessors.callStaticMethodWithArgs( - _classRef, _id_collectDefaults, jni.JniCallType.intType, []).integer; + static int collectDefaults() { + return jniAccessors.callStaticMethodWithArgs( + _classRef, _id_collectDefaults, jni.JniCallType.intType, []).integer; + } static final _id_enabledByDefault = jniAccessors.getMethodIDOf(_classRef, r"enabledByDefault", r"()Z"); /// from: public boolean enabledByDefault() - bool enabledByDefault() => jniAccessors.callMethodWithArgs( - reference, _id_enabledByDefault, jni.JniCallType.booleanType, []).boolean; + bool enabledByDefault() { + return jniAccessors.callMethodWithArgs(reference, _id_enabledByDefault, + jni.JniCallType.booleanType, []).boolean; + } static final _id_enabledIn = jniAccessors.getMethodIDOf(_classRef, r"enabledIn", r"(I)Z"); /// from: public boolean enabledIn(int flags) - bool enabledIn(int flags) => jniAccessors.callMethodWithArgs( - reference, - _id_enabledIn, - jni.JniCallType.booleanType, - [jni.JValueInt(flags)]).boolean; + bool enabledIn( + int flags, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_enabledIn, + jni.JniCallType.booleanType, [jni.JValueInt(flags)]).boolean; + } static final _id_getMask = jniAccessors.getMethodIDOf(_classRef, r"getMask", r"()I"); /// from: public int getMask() - int getMask() => jniAccessors.callMethodWithArgs( - reference, _id_getMask, jni.JniCallType.intType, []).integer; + int getMask() { + return jniAccessors.callMethodWithArgs( + reference, _id_getMask, jni.JniCallType.intType, []).integer; + } } class $JsonFactory_FeatureType extends jni.JObjType { @@ -1624,4 +1861,19 @@ class $JsonFactory_FeatureType extends jni.JObjType { @override JsonFactory_Feature fromRef(jni.JObjectPtr ref) => JsonFactory_Feature.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($JsonFactory_FeatureType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $JsonFactory_FeatureType && + other is $JsonFactory_FeatureType; + } } diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonParser.dart b/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonParser.dart index 1f71c76d1..e8caa42e3 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonParser.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonParser.dart @@ -46,9 +46,8 @@ import "../../../../_init.dart"; /// a JsonFactory instance. ///@author Tatu Saloranta class JsonParser extends jni.JObject { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type; + late final jni.JObjType $type = type; JsonParser.fromRef( jni.JObjectPtr ref, @@ -83,18 +82,22 @@ class JsonParser extends jni.JObject { /// from: protected void () /// The returned object must be deleted after use, by calling the `delete` method. - JsonParser() - : super.fromRef( - jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); + factory JsonParser() { + return JsonParser.fromRef( + jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); + } static final _id_ctor1 = jniAccessors.getMethodIDOf(_classRef, r"", r"(I)V"); /// from: protected void (int features) /// The returned object must be deleted after use, by calling the `delete` method. - JsonParser.ctor1(int features) - : super.fromRef(jniAccessors.newObjectWithArgs( - _classRef, _id_ctor1, [jni.JValueInt(features)]).object); + factory JsonParser.ctor1( + int features, + ) { + return JsonParser.fromRef(jniAccessors.newObjectWithArgs( + _classRef, _id_ctor1, [jni.JValueInt(features)]).object); + } static final _id_getCodec = jniAccessors.getMethodIDOf( _classRef, r"getCodec", r"()Lcom/fasterxml/jackson/core/ObjectCodec;"); @@ -106,9 +109,10 @@ class JsonParser extends jni.JObject { /// parser, if any. Codec is used by \#readValueAs(Class) /// method (and its variants). ///@return Codec assigned to this parser, if any; {@code null} if none - jni.JObject getCodec() => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_getCodec, jni.JniCallType.objectType, []).object); + jni.JObject getCodec() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_getCodec, jni.JniCallType.objectType, []).object); + } static final _id_setCodec = jniAccessors.getMethodIDOf( _classRef, r"setCodec", r"(Lcom/fasterxml/jackson/core/ObjectCodec;)V"); @@ -119,8 +123,12 @@ class JsonParser extends jni.JObject { /// parser, if any. Codec is used by \#readValueAs(Class) /// method (and its variants). ///@param oc Codec to assign, if any; {@code null} if none - void setCodec(jni.JObject oc) => jniAccessors.callMethodWithArgs(reference, - _id_setCodec, jni.JniCallType.voidType, [oc.reference]).check(); + void setCodec( + jni.JObject oc, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_setCodec, + jni.JniCallType.voidType, [oc.reference]).check(); + } static final _id_getInputSource = jniAccessors.getMethodIDOf( _classRef, r"getInputSource", r"()Ljava/lang/Object;"); @@ -142,9 +150,10 @@ class JsonParser extends jni.JObject { /// In general use of this accessor should be considered as /// "last effort", i.e. only used if no other mechanism is applicable. ///@return Input source this parser was configured with - jni.JObject getInputSource() => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs(reference, - _id_getInputSource, jni.JniCallType.objectType, []).object); + jni.JObject getInputSource() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_getInputSource, jni.JniCallType.objectType, []).object); + } static final _id_setRequestPayloadOnError = jniAccessors.getMethodIDOf( _classRef, @@ -156,9 +165,15 @@ class JsonParser extends jni.JObject { /// Sets the payload to be passed if JsonParseException is thrown. ///@param payload Payload to pass ///@since 2.8 - void setRequestPayloadOnError(jni.JObject payload) => - jniAccessors.callMethodWithArgs(reference, _id_setRequestPayloadOnError, - jni.JniCallType.voidType, [payload.reference]).check(); + void setRequestPayloadOnError( + jni.JObject payload, + ) { + return jniAccessors.callMethodWithArgs( + reference, + _id_setRequestPayloadOnError, + jni.JniCallType.voidType, + [payload.reference]).check(); + } static final _id_setRequestPayloadOnError1 = jniAccessors.getMethodIDOf( _classRef, r"setRequestPayloadOnError", r"([BLjava/lang/String;)V"); @@ -170,12 +185,15 @@ class JsonParser extends jni.JObject { ///@param charset Character encoding for (lazily) decoding payload ///@since 2.8 void setRequestPayloadOnError1( - jni.JArray payload, jni.JString charset) => - jniAccessors.callMethodWithArgs( - reference, - _id_setRequestPayloadOnError1, - jni.JniCallType.voidType, - [payload.reference, charset.reference]).check(); + jni.JArray payload, + jni.JString charset, + ) { + return jniAccessors.callMethodWithArgs( + reference, + _id_setRequestPayloadOnError1, + jni.JniCallType.voidType, + [payload.reference, charset.reference]).check(); + } static final _id_setRequestPayloadOnError2 = jniAccessors.getMethodIDOf( _classRef, r"setRequestPayloadOnError", r"(Ljava/lang/String;)V"); @@ -185,9 +203,15 @@ class JsonParser extends jni.JObject { /// Sets the String request payload ///@param payload Payload to pass ///@since 2.8 - void setRequestPayloadOnError2(jni.JString payload) => - jniAccessors.callMethodWithArgs(reference, _id_setRequestPayloadOnError2, - jni.JniCallType.voidType, [payload.reference]).check(); + void setRequestPayloadOnError2( + jni.JString payload, + ) { + return jniAccessors.callMethodWithArgs( + reference, + _id_setRequestPayloadOnError2, + jni.JniCallType.voidType, + [payload.reference]).check(); + } static final _id_setSchema = jniAccessors.getMethodIDOf( _classRef, r"setSchema", r"(Lcom/fasterxml/jackson/core/FormatSchema;)V"); @@ -204,11 +228,12 @@ class JsonParser extends jni.JObject { /// is thrown. ///@param schema Schema to use ///@throws UnsupportedOperationException if parser does not support schema - void setSchema(jni.JObject schema) => jniAccessors.callMethodWithArgs( - reference, - _id_setSchema, - jni.JniCallType.voidType, - [schema.reference]).check(); + void setSchema( + jni.JObject schema, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_setSchema, + jni.JniCallType.voidType, [schema.reference]).check(); + } static final _id_getSchema = jniAccessors.getMethodIDOf( _classRef, r"getSchema", r"()Lcom/fasterxml/jackson/core/FormatSchema;"); @@ -220,9 +245,10 @@ class JsonParser extends jni.JObject { /// Default implementation returns null. ///@return Schema in use by this parser, if any; {@code null} if none ///@since 2.1 - jni.JObject getSchema() => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_getSchema, jni.JniCallType.objectType, []).object); + jni.JObject getSchema() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_getSchema, jni.JniCallType.objectType, []).object); + } static final _id_canUseSchema = jniAccessors.getMethodIDOf(_classRef, r"canUseSchema", r"(Lcom/fasterxml/jackson/core/FormatSchema;)Z"); @@ -233,11 +259,12 @@ class JsonParser extends jni.JObject { /// this parser (using \#setSchema). ///@param schema Schema to check ///@return True if this parser can use given schema; false if not - bool canUseSchema(jni.JObject schema) => jniAccessors.callMethodWithArgs( - reference, - _id_canUseSchema, - jni.JniCallType.booleanType, - [schema.reference]).boolean; + bool canUseSchema( + jni.JObject schema, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_canUseSchema, + jni.JniCallType.booleanType, [schema.reference]).boolean; + } static final _id_requiresCustomCodec = jniAccessors.getMethodIDOf(_classRef, r"requiresCustomCodec", r"()Z"); @@ -252,8 +279,10 @@ class JsonParser extends jni.JObject { ///@return True if format-specific codec is needed with this parser; false if a general /// ObjectCodec is enough ///@since 2.1 - bool requiresCustomCodec() => jniAccessors.callMethodWithArgs(reference, - _id_requiresCustomCodec, jni.JniCallType.booleanType, []).boolean; + bool requiresCustomCodec() { + return jniAccessors.callMethodWithArgs(reference, _id_requiresCustomCodec, + jni.JniCallType.booleanType, []).boolean; + } static final _id_canParseAsync = jniAccessors.getMethodIDOf(_classRef, r"canParseAsync", r"()Z"); @@ -271,8 +300,10 @@ class JsonParser extends jni.JObject { /// input is read by blocking ///@return True if this is a non-blocking ("asynchronous") parser ///@since 2.9 - bool canParseAsync() => jniAccessors.callMethodWithArgs( - reference, _id_canParseAsync, jni.JniCallType.booleanType, []).boolean; + bool canParseAsync() { + return jniAccessors.callMethodWithArgs( + reference, _id_canParseAsync, jni.JniCallType.booleanType, []).boolean; + } static final _id_getNonBlockingInputFeeder = jniAccessors.getMethodIDOf( _classRef, @@ -287,11 +318,12 @@ class JsonParser extends jni.JObject { /// parsers that use blocking I/O. ///@return Input feeder to use with non-blocking (async) parsing ///@since 2.9 - jni.JObject getNonBlockingInputFeeder() => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_getNonBlockingInputFeeder, - jni.JniCallType.objectType, []).object); + jni.JObject getNonBlockingInputFeeder() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_getNonBlockingInputFeeder, + jni.JniCallType.objectType, []).object); + } static final _id_getReadCapabilities = jniAccessors.getMethodIDOf( _classRef, @@ -305,9 +337,12 @@ class JsonParser extends jni.JObject { /// underlying data format being read (directly or indirectly). ///@return Set of read capabilities for content to read via this parser ///@since 2.12 - jni.JObject getReadCapabilities() => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs(reference, - _id_getReadCapabilities, jni.JniCallType.objectType, []).object); + jni.JObject getReadCapabilities() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_getReadCapabilities, + jni.JniCallType.objectType, []).object); + } static final _id_version = jniAccessors.getMethodIDOf( _classRef, r"version", r"()Lcom/fasterxml/jackson/core/Version;"); @@ -319,9 +354,10 @@ class JsonParser extends jni.JObject { /// Left for sub-classes to implement. ///@return Version of this generator (derived from version declared for /// {@code jackson-core} jar that contains the class - jni.JObject version() => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_version, jni.JniCallType.objectType, []).object); + jni.JObject version() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_version, jni.JniCallType.objectType, []).object); + } static final _id_close = jniAccessors.getMethodIDOf(_classRef, r"close", r"()V"); @@ -342,8 +378,10 @@ class JsonParser extends jni.JObject { /// java.io.File or java.net.URL and creates /// stream or reader it does own them. ///@throws IOException if there is either an underlying I/O problem - void close() => jniAccessors.callMethodWithArgs( - reference, _id_close, jni.JniCallType.voidType, []).check(); + void close() { + return jniAccessors.callMethodWithArgs( + reference, _id_close, jni.JniCallType.voidType, []).check(); + } static final _id_isClosed = jniAccessors.getMethodIDOf(_classRef, r"isClosed", r"()Z"); @@ -357,8 +395,10 @@ class JsonParser extends jni.JObject { /// call to \#close or because parser has encountered /// end of input. ///@return {@code True} if this parser instance has been closed - bool isClosed() => jniAccessors.callMethodWithArgs( - reference, _id_isClosed, jni.JniCallType.booleanType, []).boolean; + bool isClosed() { + return jniAccessors.callMethodWithArgs( + reference, _id_isClosed, jni.JniCallType.booleanType, []).boolean; + } static final _id_getParsingContext = jniAccessors.getMethodIDOf( _classRef, @@ -377,9 +417,12 @@ class JsonParser extends jni.JObject { /// Contexts can also be used for simple xpath-like matching of /// input, if so desired. ///@return Stream input context (JsonStreamContext) associated with this parser - jni.JObject getParsingContext() => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs(reference, - _id_getParsingContext, jni.JniCallType.objectType, []).object); + jni.JObject getParsingContext() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_getParsingContext, + jni.JniCallType.objectType, []).object); + } static final _id_currentLocation = jniAccessors.getMethodIDOf(_classRef, r"currentLocation", r"()Lcom/fasterxml/jackson/core/JsonLocation;"); @@ -399,9 +442,10 @@ class JsonParser extends jni.JObject { /// to other library) ///@return Location of the last processed input unit (byte or character) ///@since 2.13 - jni.JObject currentLocation() => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs(reference, - _id_currentLocation, jni.JniCallType.objectType, []).object); + jni.JObject currentLocation() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_currentLocation, jni.JniCallType.objectType, []).object); + } static final _id_currentTokenLocation = jniAccessors.getMethodIDOf(_classRef, r"currentTokenLocation", r"()Lcom/fasterxml/jackson/core/JsonLocation;"); @@ -421,9 +465,12 @@ class JsonParser extends jni.JObject { /// to other library) ///@return Starting location of the token parser currently points to ///@since 2.13 (will eventually replace \#getTokenLocation) - jni.JObject currentTokenLocation() => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs(reference, - _id_currentTokenLocation, jni.JniCallType.objectType, []).object); + jni.JObject currentTokenLocation() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_currentTokenLocation, + jni.JniCallType.objectType, []).object); + } static final _id_getCurrentLocation = jniAccessors.getMethodIDOf(_classRef, r"getCurrentLocation", r"()Lcom/fasterxml/jackson/core/JsonLocation;"); @@ -434,9 +481,12 @@ class JsonParser extends jni.JObject { /// Alias for \#currentLocation(), to be deprecated in later /// Jackson 2.x versions (and removed from Jackson 3.0). ///@return Location of the last processed input unit (byte or character) - jni.JObject getCurrentLocation() => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs(reference, - _id_getCurrentLocation, jni.JniCallType.objectType, []).object); + jni.JObject getCurrentLocation() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_getCurrentLocation, + jni.JniCallType.objectType, []).object); + } static final _id_getTokenLocation = jniAccessors.getMethodIDOf(_classRef, r"getTokenLocation", r"()Lcom/fasterxml/jackson/core/JsonLocation;"); @@ -447,9 +497,12 @@ class JsonParser extends jni.JObject { /// Alias for \#currentTokenLocation(), to be deprecated in later /// Jackson 2.x versions (and removed from Jackson 3.0). ///@return Starting location of the token parser currently points to - jni.JObject getTokenLocation() => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs(reference, - _id_getTokenLocation, jni.JniCallType.objectType, []).object); + jni.JObject getTokenLocation() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_getTokenLocation, + jni.JniCallType.objectType, []).object); + } static final _id_currentValue = jniAccessors.getMethodIDOf( _classRef, r"currentValue", r"()Ljava/lang/Object;"); @@ -468,9 +521,10 @@ class JsonParser extends jni.JObject { /// and gets passed through data-binding. ///@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() => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_currentValue, jni.JniCallType.objectType, []).object); + jni.JObject currentValue() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_currentValue, jni.JniCallType.objectType, []).object); + } static final _id_assignCurrentValue = jniAccessors.getMethodIDOf( _classRef, r"assignCurrentValue", r"(Ljava/lang/Object;)V"); @@ -483,11 +537,12 @@ class JsonParser extends jni.JObject { ///
    ///@param v Current value to assign for the current input context of this parser ///@since 2.13 (added as replacement for older \#setCurrentValue - void assignCurrentValue(jni.JObject v) => jniAccessors.callMethodWithArgs( - reference, - _id_assignCurrentValue, - jni.JniCallType.voidType, - [v.reference]).check(); + void assignCurrentValue( + jni.JObject v, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_assignCurrentValue, + jni.JniCallType.voidType, [v.reference]).check(); + } static final _id_getCurrentValue = jniAccessors.getMethodIDOf( _classRef, r"getCurrentValue", r"()Ljava/lang/Object;"); @@ -498,9 +553,10 @@ class JsonParser extends jni.JObject { /// Alias for \#currentValue(), to be deprecated in later /// Jackson 2.x versions (and removed from Jackson 3.0). ///@return Location of the last processed input unit (byte or character) - jni.JObject getCurrentValue() => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs(reference, - _id_getCurrentValue, jni.JniCallType.objectType, []).object); + jni.JObject getCurrentValue() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_getCurrentValue, jni.JniCallType.objectType, []).object); + } static final _id_setCurrentValue = jniAccessors.getMethodIDOf( _classRef, r"setCurrentValue", r"(Ljava/lang/Object;)V"); @@ -510,11 +566,12 @@ class JsonParser extends jni.JObject { /// Alias for \#assignCurrentValue, to be deprecated in later /// Jackson 2.x versions (and removed from Jackson 3.0). ///@param v Current value to assign for the current input context of this parser - void setCurrentValue(jni.JObject v) => jniAccessors.callMethodWithArgs( - reference, - _id_setCurrentValue, - jni.JniCallType.voidType, - [v.reference]).check(); + void setCurrentValue( + jni.JObject v, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_setCurrentValue, + jni.JniCallType.voidType, [v.reference]).check(); + } static final _id_releaseBuffered = jniAccessors.getMethodIDOf( _classRef, r"releaseBuffered", r"(Ljava/io/OutputStream;)I"); @@ -532,11 +589,12 @@ class JsonParser extends jni.JObject { /// (that is, input can not be sent to OutputStream; /// otherwise number of bytes released (0 if there was nothing to release) ///@throws IOException if write to stream threw exception - int releaseBuffered(jni.JObject out) => jniAccessors.callMethodWithArgs( - reference, - _id_releaseBuffered, - jni.JniCallType.intType, - [out.reference]).integer; + int releaseBuffered( + jni.JObject out, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_releaseBuffered, + jni.JniCallType.intType, [out.reference]).integer; + } static final _id_releaseBuffered1 = jniAccessors.getMethodIDOf( _classRef, r"releaseBuffered", r"(Ljava/io/Writer;)I"); @@ -555,11 +613,12 @@ class JsonParser extends jni.JObject { /// (that is, input can not be sent to Writer; /// otherwise number of chars released (0 if there was nothing to release) ///@throws IOException if write using Writer threw exception - int releaseBuffered1(jni.JObject w) => jniAccessors.callMethodWithArgs( - reference, - _id_releaseBuffered1, - jni.JniCallType.intType, - [w.reference]).integer; + int releaseBuffered1( + jni.JObject w, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_releaseBuffered1, + jni.JniCallType.intType, [w.reference]).integer; + } static final _id_enable = jniAccessors.getMethodIDOf(_classRef, r"enable", r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/core/JsonParser;"); @@ -571,9 +630,15 @@ class JsonParser extends jni.JObject { /// (check Feature for list of features) ///@param f Feature to enable ///@return This parser, to allow call chaining - JsonParser enable(JsonParser_Feature f) => - const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs(reference, - _id_enable, jni.JniCallType.objectType, [f.reference]).object); + JsonParser enable( + JsonParser_Feature f, + ) { + return const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_enable, + jni.JniCallType.objectType, + [f.reference]).object); + } static final _id_disable = jniAccessors.getMethodIDOf(_classRef, r"disable", r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/core/JsonParser;"); @@ -585,9 +650,15 @@ class JsonParser extends jni.JObject { /// (check Feature for list of features) ///@param f Feature to disable ///@return This parser, to allow call chaining - JsonParser disable(JsonParser_Feature f) => - const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs(reference, - _id_disable, jni.JniCallType.objectType, [f.reference]).object); + JsonParser disable( + JsonParser_Feature f, + ) { + return const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_disable, + jni.JniCallType.objectType, + [f.reference]).object); + } static final _id_configure = jniAccessors.getMethodIDOf( _classRef, @@ -602,12 +673,16 @@ class JsonParser extends jni.JObject { ///@param f Feature to enable or disable ///@param state Whether to enable feature ({@code true}) or disable ({@code false}) ///@return This parser, to allow call chaining - JsonParser configure(JsonParser_Feature f, bool state) => - const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_configure, - jni.JniCallType.objectType, - [f.reference, state ? 1 : 0]).object); + JsonParser configure( + JsonParser_Feature f, + bool state, + ) { + return const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_configure, + jni.JniCallType.objectType, + [f.reference, state ? 1 : 0]).object); + } static final _id_isEnabled = jniAccessors.getMethodIDOf(_classRef, r"isEnabled", r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Z"); @@ -617,11 +692,12 @@ class JsonParser extends jni.JObject { /// Method for checking whether specified Feature is enabled. ///@param f Feature to check ///@return {@code True} if feature is enabled; {@code false} otherwise - bool isEnabled(JsonParser_Feature f) => jniAccessors.callMethodWithArgs( - reference, - _id_isEnabled, - jni.JniCallType.booleanType, - [f.reference]).boolean; + bool isEnabled( + JsonParser_Feature f, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_isEnabled, + jni.JniCallType.booleanType, [f.reference]).boolean; + } static final _id_isEnabled1 = jniAccessors.getMethodIDOf(_classRef, r"isEnabled", r"(Lcom/fasterxml/jackson/core/StreamReadFeature;)Z"); @@ -632,8 +708,12 @@ class JsonParser extends jni.JObject { ///@param f Feature to check ///@return {@code True} if feature is enabled; {@code false} otherwise ///@since 2.10 - bool isEnabled1(jni.JObject f) => jniAccessors.callMethodWithArgs(reference, - _id_isEnabled1, jni.JniCallType.booleanType, [f.reference]).boolean; + bool isEnabled1( + jni.JObject f, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_isEnabled1, + jni.JniCallType.booleanType, [f.reference]).boolean; + } static final _id_getFeatureMask = jniAccessors.getMethodIDOf(_classRef, r"getFeatureMask", r"()I"); @@ -643,8 +723,10 @@ class JsonParser extends jni.JObject { /// Bulk access method for getting state of all standard Features. ///@return Bit mask that defines current states of all standard Features. ///@since 2.3 - int getFeatureMask() => jniAccessors.callMethodWithArgs( - reference, _id_getFeatureMask, jni.JniCallType.intType, []).integer; + int getFeatureMask() { + return jniAccessors.callMethodWithArgs( + reference, _id_getFeatureMask, jni.JniCallType.intType, []).integer; + } static final _id_setFeatureMask = jniAccessors.getMethodIDOf(_classRef, r"setFeatureMask", r"(I)Lcom/fasterxml/jackson/core/JsonParser;"); @@ -657,12 +739,15 @@ class JsonParser extends jni.JObject { ///@return This parser, to allow call chaining ///@since 2.3 ///@deprecated Since 2.7, use \#overrideStdFeatures(int, int) instead - JsonParser setFeatureMask(int mask) => - const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_setFeatureMask, - jni.JniCallType.objectType, - [jni.JValueInt(mask)]).object); + JsonParser setFeatureMask( + int mask, + ) { + return const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_setFeatureMask, + jni.JniCallType.objectType, + [jni.JValueInt(mask)]).object); + } static final _id_overrideStdFeatures = jniAccessors.getMethodIDOf(_classRef, r"overrideStdFeatures", r"(II)Lcom/fasterxml/jackson/core/JsonParser;"); @@ -682,12 +767,16 @@ class JsonParser extends jni.JObject { ///@param mask Bit mask of features to change ///@return This parser, to allow call chaining ///@since 2.6 - JsonParser overrideStdFeatures(int values, int mask) => - const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_overrideStdFeatures, - jni.JniCallType.objectType, - [jni.JValueInt(values), jni.JValueInt(mask)]).object); + JsonParser overrideStdFeatures( + int values, + int mask, + ) { + return const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_overrideStdFeatures, + jni.JniCallType.objectType, + [jni.JValueInt(values), jni.JValueInt(mask)]).object); + } static final _id_getFormatFeatures = jniAccessors.getMethodIDOf(_classRef, r"getFormatFeatures", r"()I"); @@ -698,8 +787,10 @@ class JsonParser extends jni.JObject { /// on/off configuration settings. ///@return Bit mask that defines current states of all standard FormatFeatures. ///@since 2.6 - int getFormatFeatures() => jniAccessors.callMethodWithArgs( - reference, _id_getFormatFeatures, jni.JniCallType.intType, []).integer; + int getFormatFeatures() { + return jniAccessors.callMethodWithArgs( + reference, _id_getFormatFeatures, jni.JniCallType.intType, []).integer; + } static final _id_overrideFormatFeatures = jniAccessors.getMethodIDOf( _classRef, @@ -719,12 +810,16 @@ class JsonParser extends jni.JObject { ///@param mask Bit mask of features to change ///@return This parser, to allow call chaining ///@since 2.6 - JsonParser overrideFormatFeatures(int values, int mask) => - const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_overrideFormatFeatures, - jni.JniCallType.objectType, - [jni.JValueInt(values), jni.JValueInt(mask)]).object); + JsonParser overrideFormatFeatures( + int values, + int mask, + ) { + return const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_overrideFormatFeatures, + jni.JniCallType.objectType, + [jni.JValueInt(values), jni.JValueInt(mask)]).object); + } static final _id_nextToken = jniAccessors.getMethodIDOf( _classRef, r"nextToken", r"()Lcom/fasterxml/jackson/core/JsonToken;"); @@ -740,9 +835,11 @@ class JsonParser extends jni.JObject { /// to indicate end-of-input ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - jsontoken_.JsonToken nextToken() => - const jsontoken_.$JsonTokenType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_nextToken, jni.JniCallType.objectType, []).object); + jsontoken_.JsonToken nextToken() { + return const jsontoken_.$JsonTokenType().fromRef(jniAccessors + .callMethodWithArgs( + reference, _id_nextToken, jni.JniCallType.objectType, []).object); + } static final _id_nextValue = jniAccessors.getMethodIDOf( _classRef, r"nextValue", r"()Lcom/fasterxml/jackson/core/JsonToken;"); @@ -766,9 +863,11 @@ class JsonParser extends jni.JObject { /// available yet) ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - jsontoken_.JsonToken nextValue() => - const jsontoken_.$JsonTokenType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_nextValue, jni.JniCallType.objectType, []).object); + jsontoken_.JsonToken nextValue() { + return const jsontoken_.$JsonTokenType().fromRef(jniAccessors + .callMethodWithArgs( + reference, _id_nextValue, jni.JniCallType.objectType, []).object); + } static final _id_nextFieldName = jniAccessors.getMethodIDOf(_classRef, r"nextFieldName", r"(Lcom/fasterxml/jackson/core/SerializableString;)Z"); @@ -790,11 +889,12 @@ class JsonParser extends jni.JObject { /// specified name; {@code false} otherwise (different token or non-matching name) ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - bool nextFieldName(jni.JObject str) => jniAccessors.callMethodWithArgs( - reference, - _id_nextFieldName, - jni.JniCallType.booleanType, - [str.reference]).boolean; + bool nextFieldName( + jni.JObject str, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_nextFieldName, + jni.JniCallType.booleanType, [str.reference]).boolean; + } static final _id_nextFieldName1 = jniAccessors.getMethodIDOf( _classRef, r"nextFieldName", r"()Ljava/lang/String;"); @@ -810,9 +910,10 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems ///@since 2.5 - jni.JString nextFieldName1() => - const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs(reference, - _id_nextFieldName1, jni.JniCallType.objectType, []).object); + jni.JString nextFieldName1() { + return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_nextFieldName1, jni.JniCallType.objectType, []).object); + } static final _id_nextTextValue = jniAccessors.getMethodIDOf( _classRef, r"nextTextValue", r"()Ljava/lang/String;"); @@ -833,9 +934,10 @@ class JsonParser extends jni.JObject { /// to; or {@code null} if next token is of some other type ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - jni.JString nextTextValue() => - const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_nextTextValue, jni.JniCallType.objectType, []).object); + jni.JString nextTextValue() { + return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_nextTextValue, jni.JniCallType.objectType, []).object); + } static final _id_nextIntValue = jniAccessors.getMethodIDOf(_classRef, r"nextIntValue", r"(I)I"); @@ -859,11 +961,12 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems ///@throws InputCoercionException if integer number does not fit in Java {@code int} - int nextIntValue(int defaultValue) => jniAccessors.callMethodWithArgs( - reference, - _id_nextIntValue, - jni.JniCallType.intType, - [jni.JValueInt(defaultValue)]).integer; + int nextIntValue( + int defaultValue, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_nextIntValue, + jni.JniCallType.intType, [jni.JValueInt(defaultValue)]).integer; + } static final _id_nextLongValue = jniAccessors.getMethodIDOf(_classRef, r"nextLongValue", r"(J)J"); @@ -887,11 +990,12 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems ///@throws InputCoercionException if integer number does not fit in Java {@code long} - int nextLongValue(int defaultValue) => jniAccessors.callMethodWithArgs( - reference, - _id_nextLongValue, - jni.JniCallType.longType, - [defaultValue]).long; + int nextLongValue( + int defaultValue, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_nextLongValue, + jni.JniCallType.longType, [defaultValue]).long; + } static final _id_nextBooleanValue = jniAccessors.getMethodIDOf( _classRef, r"nextBooleanValue", r"()Ljava/lang/Boolean;"); @@ -915,9 +1019,12 @@ class JsonParser extends jni.JObject { /// token parser advanced to; or {@code null} if next token is of some other type ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - jni.JObject nextBooleanValue() => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs(reference, - _id_nextBooleanValue, jni.JniCallType.objectType, []).object); + jni.JObject nextBooleanValue() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_nextBooleanValue, + jni.JniCallType.objectType, []).object); + } static final _id_skipChildren = jniAccessors.getMethodIDOf( _classRef, r"skipChildren", r"()Lcom/fasterxml/jackson/core/JsonParser;"); @@ -940,9 +1047,10 @@ class JsonParser extends jni.JObject { ///@return This parser, to allow call chaining ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - JsonParser skipChildren() => - const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_skipChildren, jni.JniCallType.objectType, []).object); + JsonParser skipChildren() { + return const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_skipChildren, jni.JniCallType.objectType, []).object); + } static final _id_finishToken = jniAccessors.getMethodIDOf(_classRef, r"finishToken", r"()V"); @@ -962,8 +1070,10 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems ///@since 2.8 - void finishToken() => jniAccessors.callMethodWithArgs( - reference, _id_finishToken, jni.JniCallType.voidType, []).check(); + void finishToken() { + return jniAccessors.callMethodWithArgs( + reference, _id_finishToken, jni.JniCallType.voidType, []).check(); + } static final _id_currentToken = jniAccessors.getMethodIDOf( _classRef, r"currentToken", r"()Lcom/fasterxml/jackson/core/JsonToken;"); @@ -980,9 +1090,11 @@ class JsonParser extends jni.JObject { /// after end-of-input has been encountered, as well as /// if the current token has been explicitly cleared. ///@since 2.8 - jsontoken_.JsonToken currentToken() => - const jsontoken_.$JsonTokenType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_currentToken, jni.JniCallType.objectType, []).object); + jsontoken_.JsonToken currentToken() { + return const jsontoken_.$JsonTokenType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_currentToken, + jni.JniCallType.objectType, []).object); + } static final _id_currentTokenId = jniAccessors.getMethodIDOf(_classRef, r"currentTokenId", r"()I"); @@ -998,8 +1110,10 @@ class JsonParser extends jni.JObject { /// to profile performance before deciding to use this method. ///@since 2.8 ///@return {@code int} matching one of constants from JsonTokenId. - int currentTokenId() => jniAccessors.callMethodWithArgs( - reference, _id_currentTokenId, jni.JniCallType.intType, []).integer; + int currentTokenId() { + return jniAccessors.callMethodWithArgs( + reference, _id_currentTokenId, jni.JniCallType.intType, []).integer; + } static final _id_getCurrentToken = jniAccessors.getMethodIDOf(_classRef, r"getCurrentToken", r"()Lcom/fasterxml/jackson/core/JsonToken;"); @@ -1011,11 +1125,11 @@ class JsonParser extends jni.JObject { /// Jackson 2.13 (will be removed from 3.0). ///@return Type of the token this parser currently points to, /// if any: null before any tokens have been read, and - jsontoken_.JsonToken getCurrentToken() => - const jsontoken_.$JsonTokenType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_getCurrentToken, - jni.JniCallType.objectType, []).object); + jsontoken_.JsonToken getCurrentToken() { + return const jsontoken_.$JsonTokenType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_getCurrentToken, + jni.JniCallType.objectType, []).object); + } static final _id_getCurrentTokenId = jniAccessors.getMethodIDOf(_classRef, r"getCurrentTokenId", r"()I"); @@ -1025,8 +1139,10 @@ class JsonParser extends jni.JObject { /// Deprecated alias for \#currentTokenId(). ///@return {@code int} matching one of constants from JsonTokenId. ///@deprecated Since 2.12 use \#currentTokenId instead - int getCurrentTokenId() => jniAccessors.callMethodWithArgs( - reference, _id_getCurrentTokenId, jni.JniCallType.intType, []).integer; + int getCurrentTokenId() { + return jniAccessors.callMethodWithArgs( + reference, _id_getCurrentTokenId, jni.JniCallType.intType, []).integer; + } static final _id_hasCurrentToken = jniAccessors.getMethodIDOf(_classRef, r"hasCurrentToken", r"()Z"); @@ -1041,8 +1157,10 @@ class JsonParser extends jni.JObject { /// was just constructed, encountered end-of-input /// and returned null from \#nextToken, or the token /// has been consumed) - bool hasCurrentToken() => jniAccessors.callMethodWithArgs( - reference, _id_hasCurrentToken, jni.JniCallType.booleanType, []).boolean; + bool hasCurrentToken() { + return jniAccessors.callMethodWithArgs(reference, _id_hasCurrentToken, + jni.JniCallType.booleanType, []).boolean; + } static final _id_hasTokenId = jniAccessors.getMethodIDOf(_classRef, r"hasTokenId", r"(I)Z"); @@ -1061,8 +1179,12 @@ class JsonParser extends jni.JObject { ///@param id Token id to match (from (@link JsonTokenId}) ///@return {@code True} if the parser current points to specified token ///@since 2.5 - bool hasTokenId(int id) => jniAccessors.callMethodWithArgs(reference, - _id_hasTokenId, jni.JniCallType.booleanType, [jni.JValueInt(id)]).boolean; + bool hasTokenId( + int id, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_hasTokenId, + jni.JniCallType.booleanType, [jni.JValueInt(id)]).boolean; + } static final _id_hasToken = jniAccessors.getMethodIDOf( _classRef, r"hasToken", r"(Lcom/fasterxml/jackson/core/JsonToken;)Z"); @@ -1081,11 +1203,12 @@ class JsonParser extends jni.JObject { ///@param t Token to match ///@return {@code True} if the parser current points to specified token ///@since 2.6 - bool hasToken(jsontoken_.JsonToken t) => jniAccessors.callMethodWithArgs( - reference, - _id_hasToken, - jni.JniCallType.booleanType, - [t.reference]).boolean; + bool hasToken( + jsontoken_.JsonToken t, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_hasToken, + jni.JniCallType.booleanType, [t.reference]).boolean; + } static final _id_isExpectedStartArrayToken = jniAccessors.getMethodIDOf( _classRef, r"isExpectedStartArrayToken", r"()Z"); @@ -1108,8 +1231,10 @@ class JsonParser extends jni.JObject { ///@return True if the current token can be considered as a /// start-array marker (such JsonToken\#START_ARRAY); /// {@code false} if not - bool isExpectedStartArrayToken() => jniAccessors.callMethodWithArgs(reference, - _id_isExpectedStartArrayToken, jni.JniCallType.booleanType, []).boolean; + bool isExpectedStartArrayToken() { + return jniAccessors.callMethodWithArgs(reference, + _id_isExpectedStartArrayToken, jni.JniCallType.booleanType, []).boolean; + } static final _id_isExpectedStartObjectToken = jniAccessors.getMethodIDOf( _classRef, r"isExpectedStartObjectToken", r"()Z"); @@ -1122,10 +1247,12 @@ class JsonParser extends jni.JObject { /// start-array marker (such JsonToken\#START_OBJECT); /// {@code false} if not ///@since 2.5 - bool isExpectedStartObjectToken() => jniAccessors.callMethodWithArgs( - reference, - _id_isExpectedStartObjectToken, - jni.JniCallType.booleanType, []).boolean; + bool isExpectedStartObjectToken() { + return jniAccessors.callMethodWithArgs( + reference, + _id_isExpectedStartObjectToken, + jni.JniCallType.booleanType, []).boolean; + } static final _id_isExpectedNumberIntToken = jniAccessors.getMethodIDOf( _classRef, r"isExpectedNumberIntToken", r"()Z"); @@ -1141,8 +1268,10 @@ class JsonParser extends jni.JObject { /// start-array marker (such JsonToken\#VALUE_NUMBER_INT); /// {@code false} if not ///@since 2.12 - bool isExpectedNumberIntToken() => jniAccessors.callMethodWithArgs(reference, - _id_isExpectedNumberIntToken, jni.JniCallType.booleanType, []).boolean; + bool isExpectedNumberIntToken() { + return jniAccessors.callMethodWithArgs(reference, + _id_isExpectedNumberIntToken, jni.JniCallType.booleanType, []).boolean; + } static final _id_isNaN = jniAccessors.getMethodIDOf(_classRef, r"isNaN", r"()Z"); @@ -1161,8 +1290,10 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems ///@since 2.9 - bool isNaN() => jniAccessors.callMethodWithArgs( - reference, _id_isNaN, jni.JniCallType.booleanType, []).boolean; + bool isNaN() { + return jniAccessors.callMethodWithArgs( + reference, _id_isNaN, jni.JniCallType.booleanType, []).boolean; + } static final _id_clearCurrentToken = jniAccessors.getMethodIDOf(_classRef, r"clearCurrentToken", r"()V"); @@ -1179,8 +1310,10 @@ class JsonParser extends jni.JObject { /// Method was added to be used by the optional data binder, since /// it has to be able to consume last token used for binding (so that /// it will not be used again). - void clearCurrentToken() => jniAccessors.callMethodWithArgs( - reference, _id_clearCurrentToken, jni.JniCallType.voidType, []).check(); + void clearCurrentToken() { + return jniAccessors.callMethodWithArgs( + reference, _id_clearCurrentToken, jni.JniCallType.voidType, []).check(); + } static final _id_getLastClearedToken = jniAccessors.getMethodIDOf(_classRef, r"getLastClearedToken", r"()Lcom/fasterxml/jackson/core/JsonToken;"); @@ -1194,11 +1327,11 @@ class JsonParser extends jni.JObject { /// Will return null if no tokens have been cleared, /// or if parser has been closed. ///@return Last cleared token, if any; {@code null} otherwise - jsontoken_.JsonToken getLastClearedToken() => - const jsontoken_.$JsonTokenType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_getLastClearedToken, - jni.JniCallType.objectType, []).object); + jsontoken_.JsonToken getLastClearedToken() { + return const jsontoken_.$JsonTokenType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_getLastClearedToken, + jni.JniCallType.objectType, []).object); + } static final _id_overrideCurrentName = jniAccessors.getMethodIDOf( _classRef, r"overrideCurrentName", r"(Ljava/lang/String;)V"); @@ -1213,11 +1346,12 @@ class JsonParser extends jni.JObject { /// Note that use of this method should only be done as sort of last /// resort, as it is a work-around for regular operation. ///@param name Name to use as the current name; may be null. - void overrideCurrentName(jni.JString name) => jniAccessors.callMethodWithArgs( - reference, - _id_overrideCurrentName, - jni.JniCallType.voidType, - [name.reference]).check(); + void overrideCurrentName( + jni.JString name, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_overrideCurrentName, + jni.JniCallType.voidType, [name.reference]).check(); + } static final _id_getCurrentName = jniAccessors.getMethodIDOf( _classRef, r"getCurrentName", r"()Ljava/lang/String;"); @@ -1229,9 +1363,10 @@ class JsonParser extends jni.JObject { ///@return Name of the current field in the parsing context ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - jni.JString getCurrentName() => - const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs(reference, - _id_getCurrentName, jni.JniCallType.objectType, []).object); + jni.JString getCurrentName() { + return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_getCurrentName, jni.JniCallType.objectType, []).object); + } static final _id_currentName = jniAccessors.getMethodIDOf( _classRef, r"currentName", r"()Ljava/lang/String;"); @@ -1248,9 +1383,10 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems ///@since 2.10 - jni.JString currentName() => - const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_currentName, jni.JniCallType.objectType, []).object); + jni.JString currentName() { + return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_currentName, jni.JniCallType.objectType, []).object); + } static final _id_getText = jniAccessors.getMethodIDOf( _classRef, r"getText", r"()Ljava/lang/String;"); @@ -1266,9 +1402,10 @@ class JsonParser extends jni.JObject { /// by \#nextToken() or other iteration methods) ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - jni.JString getText() => - const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_getText, jni.JniCallType.objectType, []).object); + jni.JString getText() { + return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_getText, jni.JniCallType.objectType, []).object); + } static final _id_getText1 = jniAccessors.getMethodIDOf(_classRef, r"getText", r"(Ljava/io/Writer;)I"); @@ -1290,8 +1427,12 @@ class JsonParser extends jni.JObject { /// {@code writer}, or /// JsonParseException for decoding problems ///@since 2.8 - int getText1(jni.JObject writer) => jniAccessors.callMethodWithArgs(reference, - _id_getText1, jni.JniCallType.intType, [writer.reference]).integer; + int getText1( + jni.JObject writer, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_getText1, + jni.JniCallType.intType, [writer.reference]).integer; + } static final _id_getTextCharacters = jniAccessors.getMethodIDOf(_classRef, r"getTextCharacters", r"()[C"); @@ -1326,10 +1467,11 @@ class JsonParser extends jni.JObject { /// at offset 0, and not necessarily until the end of buffer) ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - jni.JArray getTextCharacters() => - const jni.JArrayType(jni.JCharType()).fromRef(jniAccessors - .callMethodWithArgs(reference, _id_getTextCharacters, - jni.JniCallType.objectType, []).object); + jni.JArray getTextCharacters() { + return const jni.JArrayType(jni.JCharType()).fromRef(jniAccessors + .callMethodWithArgs(reference, _id_getTextCharacters, + jni.JniCallType.objectType, []).object); + } static final _id_getTextLength = jniAccessors.getMethodIDOf(_classRef, r"getTextLength", r"()I"); @@ -1343,8 +1485,10 @@ class JsonParser extends jni.JObject { /// textual content of the current token. ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - int getTextLength() => jniAccessors.callMethodWithArgs( - reference, _id_getTextLength, jni.JniCallType.intType, []).integer; + int getTextLength() { + return jniAccessors.callMethodWithArgs( + reference, _id_getTextLength, jni.JniCallType.intType, []).integer; + } static final _id_getTextOffset = jniAccessors.getMethodIDOf(_classRef, r"getTextOffset", r"()I"); @@ -1358,8 +1502,10 @@ class JsonParser extends jni.JObject { /// textual content of the current token. ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - int getTextOffset() => jniAccessors.callMethodWithArgs( - reference, _id_getTextOffset, jni.JniCallType.intType, []).integer; + int getTextOffset() { + return jniAccessors.callMethodWithArgs( + reference, _id_getTextOffset, jni.JniCallType.intType, []).integer; + } static final _id_hasTextCharacters = jniAccessors.getMethodIDOf(_classRef, r"hasTextCharacters", r"()Z"); @@ -1380,8 +1526,10 @@ class JsonParser extends jni.JObject { ///@return True if parser currently has character array that can /// be efficiently returned via \#getTextCharacters; false /// means that it may or may not exist - bool hasTextCharacters() => jniAccessors.callMethodWithArgs(reference, - _id_hasTextCharacters, jni.JniCallType.booleanType, []).boolean; + bool hasTextCharacters() { + return jniAccessors.callMethodWithArgs(reference, _id_hasTextCharacters, + jni.JniCallType.booleanType, []).boolean; + } static final _id_getNumberValue = jniAccessors.getMethodIDOf( _classRef, r"getNumberValue", r"()Ljava/lang/Number;"); @@ -1399,9 +1547,10 @@ class JsonParser extends jni.JObject { /// the current token is not numeric, or if decoding of the value fails /// (invalid format for numbers); plain IOException if underlying /// content read fails (possible if values are extracted lazily) - jni.JObject getNumberValue() => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs(reference, - _id_getNumberValue, jni.JniCallType.objectType, []).object); + jni.JObject getNumberValue() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_getNumberValue, jni.JniCallType.objectType, []).object); + } static final _id_getNumberValueExact = jniAccessors.getMethodIDOf( _classRef, r"getNumberValueExact", r"()Ljava/lang/Number;"); @@ -1423,9 +1572,12 @@ class JsonParser extends jni.JObject { /// (invalid format for numbers); plain IOException if underlying /// content read fails (possible if values are extracted lazily) ///@since 2.12 - jni.JObject getNumberValueExact() => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs(reference, - _id_getNumberValueExact, jni.JniCallType.objectType, []).object); + jni.JObject getNumberValueExact() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_getNumberValueExact, + jni.JniCallType.objectType, []).object); + } static final _id_getNumberType = jniAccessors.getMethodIDOf( _classRef, @@ -1442,9 +1594,11 @@ class JsonParser extends jni.JObject { ///@return Type of current number, if parser points to numeric token; {@code null} otherwise ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - JsonParser_NumberType getNumberType() => const $JsonParser_NumberTypeType() - .fromRef(jniAccessors.callMethodWithArgs( - reference, _id_getNumberType, jni.JniCallType.objectType, []).object); + JsonParser_NumberType getNumberType() { + return const $JsonParser_NumberTypeType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_getNumberType, + jni.JniCallType.objectType, []).object); + } static final _id_getByteValue = jniAccessors.getMethodIDOf(_classRef, r"getByteValue", r"()B"); @@ -1472,8 +1626,10 @@ class JsonParser extends jni.JObject { /// range of {@code [-128, 255]}); otherwise exception thrown ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - int getByteValue() => jniAccessors.callMethodWithArgs( - reference, _id_getByteValue, jni.JniCallType.byteType, []).byte; + int getByteValue() { + return jniAccessors.callMethodWithArgs( + reference, _id_getByteValue, jni.JniCallType.byteType, []).byte; + } static final _id_getShortValue = jniAccessors.getMethodIDOf(_classRef, r"getShortValue", r"()S"); @@ -1495,8 +1651,10 @@ class JsonParser extends jni.JObject { /// Java 16-bit signed {@code short} range); otherwise exception thrown ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - int getShortValue() => jniAccessors.callMethodWithArgs( - reference, _id_getShortValue, jni.JniCallType.shortType, []).short; + int getShortValue() { + return jniAccessors.callMethodWithArgs( + reference, _id_getShortValue, jni.JniCallType.shortType, []).short; + } static final _id_getIntValue = jniAccessors.getMethodIDOf(_classRef, r"getIntValue", r"()I"); @@ -1518,8 +1676,10 @@ class JsonParser extends jni.JObject { /// Java 32-bit signed {@code int} range); otherwise exception thrown ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - int getIntValue() => jniAccessors.callMethodWithArgs( - reference, _id_getIntValue, jni.JniCallType.intType, []).integer; + int getIntValue() { + return jniAccessors.callMethodWithArgs( + reference, _id_getIntValue, jni.JniCallType.intType, []).integer; + } static final _id_getLongValue = jniAccessors.getMethodIDOf(_classRef, r"getLongValue", r"()J"); @@ -1541,8 +1701,10 @@ class JsonParser extends jni.JObject { /// Java 32-bit signed {@code long} range); otherwise exception thrown ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - int getLongValue() => jniAccessors.callMethodWithArgs( - reference, _id_getLongValue, jni.JniCallType.longType, []).long; + int getLongValue() { + return jniAccessors.callMethodWithArgs( + reference, _id_getLongValue, jni.JniCallType.longType, []).long; + } static final _id_getBigIntegerValue = jniAccessors.getMethodIDOf( _classRef, r"getBigIntegerValue", r"()Ljava/math/BigInteger;"); @@ -1561,9 +1723,12 @@ class JsonParser extends jni.JObject { /// otherwise exception thrown ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - jni.JObject getBigIntegerValue() => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs(reference, - _id_getBigIntegerValue, jni.JniCallType.objectType, []).object); + jni.JObject getBigIntegerValue() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_getBigIntegerValue, + jni.JniCallType.objectType, []).object); + } static final _id_getFloatValue = jniAccessors.getMethodIDOf(_classRef, r"getFloatValue", r"()F"); @@ -1585,8 +1750,10 @@ class JsonParser extends jni.JObject { /// Java {@code float} range); otherwise exception thrown ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - double getFloatValue() => jniAccessors.callMethodWithArgs( - reference, _id_getFloatValue, jni.JniCallType.floatType, []).float; + double getFloatValue() { + return jniAccessors.callMethodWithArgs( + reference, _id_getFloatValue, jni.JniCallType.floatType, []).float; + } static final _id_getDoubleValue = jniAccessors.getMethodIDOf(_classRef, r"getDoubleValue", r"()D"); @@ -1608,8 +1775,10 @@ class JsonParser extends jni.JObject { /// Java {@code double} range); otherwise exception thrown ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - double getDoubleValue() => jniAccessors.callMethodWithArgs(reference, - _id_getDoubleValue, jni.JniCallType.doubleType, []).doubleFloat; + double getDoubleValue() { + return jniAccessors.callMethodWithArgs(reference, _id_getDoubleValue, + jni.JniCallType.doubleType, []).doubleFloat; + } static final _id_getDecimalValue = jniAccessors.getMethodIDOf( _classRef, r"getDecimalValue", r"()Ljava/math/BigDecimal;"); @@ -1625,9 +1794,10 @@ class JsonParser extends jni.JObject { /// otherwise exception thrown ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - jni.JObject getDecimalValue() => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs(reference, - _id_getDecimalValue, jni.JniCallType.objectType, []).object); + jni.JObject getDecimalValue() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_getDecimalValue, jni.JniCallType.objectType, []).object); + } static final _id_getBooleanValue = jniAccessors.getMethodIDOf(_classRef, r"getBooleanValue", r"()Z"); @@ -1645,8 +1815,10 @@ class JsonParser extends jni.JObject { /// otherwise throws JsonParseException ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - bool getBooleanValue() => jniAccessors.callMethodWithArgs( - reference, _id_getBooleanValue, jni.JniCallType.booleanType, []).boolean; + bool getBooleanValue() { + return jniAccessors.callMethodWithArgs(reference, _id_getBooleanValue, + jni.JniCallType.booleanType, []).boolean; + } static final _id_getEmbeddedObject = jniAccessors.getMethodIDOf( _classRef, r"getEmbeddedObject", r"()Ljava/lang/Object;"); @@ -1668,9 +1840,12 @@ class JsonParser extends jni.JObject { /// for the current token, if any; {@code null otherwise} ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - jni.JObject getEmbeddedObject() => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs(reference, - _id_getEmbeddedObject, jni.JniCallType.objectType, []).object); + jni.JObject getEmbeddedObject() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_getEmbeddedObject, + jni.JniCallType.objectType, []).object); + } static final _id_getBinaryValue = jniAccessors.getMethodIDOf(_classRef, r"getBinaryValue", r"(Lcom/fasterxml/jackson/core/Base64Variant;)[B"); @@ -1698,10 +1873,13 @@ class JsonParser extends jni.JObject { ///@return Decoded binary data ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - jni.JArray getBinaryValue(jni.JObject bv) => - const jni.JArrayType(jni.JByteType()).fromRef(jniAccessors - .callMethodWithArgs(reference, _id_getBinaryValue, - jni.JniCallType.objectType, [bv.reference]).object); + jni.JArray getBinaryValue( + jni.JObject bv, + ) { + return const jni.JArrayType(jni.JByteType()).fromRef(jniAccessors + .callMethodWithArgs(reference, _id_getBinaryValue, + jni.JniCallType.objectType, [bv.reference]).object); + } static final _id_getBinaryValue1 = jniAccessors.getMethodIDOf(_classRef, r"getBinaryValue", r"()[B"); @@ -1715,10 +1893,11 @@ class JsonParser extends jni.JObject { ///@return Decoded binary data ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - jni.JArray getBinaryValue1() => - const jni.JArrayType(jni.JByteType()).fromRef(jniAccessors - .callMethodWithArgs(reference, _id_getBinaryValue1, - jni.JniCallType.objectType, []).object); + jni.JArray getBinaryValue1() { + return const jni.JArrayType(jni.JByteType()).fromRef(jniAccessors + .callMethodWithArgs(reference, _id_getBinaryValue1, + jni.JniCallType.objectType, []).object); + } static final _id_readBinaryValue = jniAccessors.getMethodIDOf( _classRef, r"readBinaryValue", r"(Ljava/io/OutputStream;)I"); @@ -1736,11 +1915,12 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems ///@since 2.1 - int readBinaryValue(jni.JObject out) => jniAccessors.callMethodWithArgs( - reference, - _id_readBinaryValue, - jni.JniCallType.intType, - [out.reference]).integer; + int readBinaryValue( + jni.JObject out, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_readBinaryValue, + jni.JniCallType.intType, [out.reference]).integer; + } static final _id_readBinaryValue1 = jniAccessors.getMethodIDOf( _classRef, @@ -1757,9 +1937,13 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems ///@since 2.1 - int readBinaryValue1(jni.JObject bv, jni.JObject out) => - jniAccessors.callMethodWithArgs(reference, _id_readBinaryValue1, - jni.JniCallType.intType, [bv.reference, out.reference]).integer; + int readBinaryValue1( + jni.JObject bv, + jni.JObject out, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_readBinaryValue1, + jni.JniCallType.intType, [bv.reference, out.reference]).integer; + } static final _id_getValueAsInt = jniAccessors.getMethodIDOf(_classRef, r"getValueAsInt", r"()I"); @@ -1779,8 +1963,10 @@ class JsonParser extends jni.JObject { /// otherwise ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - int getValueAsInt() => jniAccessors.callMethodWithArgs( - reference, _id_getValueAsInt, jni.JniCallType.intType, []).integer; + int getValueAsInt() { + return jniAccessors.callMethodWithArgs( + reference, _id_getValueAsInt, jni.JniCallType.intType, []).integer; + } static final _id_getValueAsInt1 = jniAccessors.getMethodIDOf(_classRef, r"getValueAsInt", r"(I)I"); @@ -1800,11 +1986,12 @@ class JsonParser extends jni.JObject { ///@return {@code int} value current token is converted to, if possible; {@code def} otherwise ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - int getValueAsInt1(int def) => jniAccessors.callMethodWithArgs( - reference, - _id_getValueAsInt1, - jni.JniCallType.intType, - [jni.JValueInt(def)]).integer; + int getValueAsInt1( + int def, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_getValueAsInt1, + jni.JniCallType.intType, [jni.JValueInt(def)]).integer; + } static final _id_getValueAsLong = jniAccessors.getMethodIDOf(_classRef, r"getValueAsLong", r"()J"); @@ -1824,8 +2011,10 @@ class JsonParser extends jni.JObject { /// otherwise ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - int getValueAsLong() => jniAccessors.callMethodWithArgs( - reference, _id_getValueAsLong, jni.JniCallType.longType, []).long; + int getValueAsLong() { + return jniAccessors.callMethodWithArgs( + reference, _id_getValueAsLong, jni.JniCallType.longType, []).long; + } static final _id_getValueAsLong1 = jniAccessors.getMethodIDOf(_classRef, r"getValueAsLong", r"(J)J"); @@ -1845,8 +2034,12 @@ class JsonParser extends jni.JObject { ///@return {@code long} value current token is converted to, if possible; {@code def} otherwise ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - int getValueAsLong1(int def) => jniAccessors.callMethodWithArgs( - reference, _id_getValueAsLong1, jni.JniCallType.longType, [def]).long; + int getValueAsLong1( + int def, + ) { + return jniAccessors.callMethodWithArgs( + reference, _id_getValueAsLong1, jni.JniCallType.longType, [def]).long; + } static final _id_getValueAsDouble = jniAccessors.getMethodIDOf(_classRef, r"getValueAsDouble", r"()D"); @@ -1866,8 +2059,10 @@ class JsonParser extends jni.JObject { /// otherwise ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - double getValueAsDouble() => jniAccessors.callMethodWithArgs(reference, - _id_getValueAsDouble, jni.JniCallType.doubleType, []).doubleFloat; + double getValueAsDouble() { + return jniAccessors.callMethodWithArgs(reference, _id_getValueAsDouble, + jni.JniCallType.doubleType, []).doubleFloat; + } static final _id_getValueAsDouble1 = jniAccessors.getMethodIDOf(_classRef, r"getValueAsDouble", r"(D)D"); @@ -1887,11 +2082,12 @@ class JsonParser extends jni.JObject { ///@return {@code double} value current token is converted to, if possible; {@code def} otherwise ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - double getValueAsDouble1(double def) => jniAccessors.callMethodWithArgs( - reference, - _id_getValueAsDouble1, - jni.JniCallType.doubleType, - [def]).doubleFloat; + double getValueAsDouble1( + double def, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_getValueAsDouble1, + jni.JniCallType.doubleType, [def]).doubleFloat; + } static final _id_getValueAsBoolean = jniAccessors.getMethodIDOf(_classRef, r"getValueAsBoolean", r"()Z"); @@ -1911,8 +2107,10 @@ class JsonParser extends jni.JObject { /// otherwise ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - bool getValueAsBoolean() => jniAccessors.callMethodWithArgs(reference, - _id_getValueAsBoolean, jni.JniCallType.booleanType, []).boolean; + bool getValueAsBoolean() { + return jniAccessors.callMethodWithArgs(reference, _id_getValueAsBoolean, + jni.JniCallType.booleanType, []).boolean; + } static final _id_getValueAsBoolean1 = jniAccessors.getMethodIDOf(_classRef, r"getValueAsBoolean", r"(Z)Z"); @@ -1932,11 +2130,12 @@ class JsonParser extends jni.JObject { ///@return {@code boolean} value current token is converted to, if possible; {@code def} otherwise ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - bool getValueAsBoolean1(bool def) => jniAccessors.callMethodWithArgs( - reference, - _id_getValueAsBoolean1, - jni.JniCallType.booleanType, - [def ? 1 : 0]).boolean; + bool getValueAsBoolean1( + bool def, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_getValueAsBoolean1, + jni.JniCallType.booleanType, [def ? 1 : 0]).boolean; + } static final _id_getValueAsString = jniAccessors.getMethodIDOf( _classRef, r"getValueAsString", r"()Ljava/lang/String;"); @@ -1955,9 +2154,12 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems ///@since 2.1 - jni.JString getValueAsString() => - const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs(reference, - _id_getValueAsString, jni.JniCallType.objectType, []).object); + jni.JString getValueAsString() { + return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_getValueAsString, + jni.JniCallType.objectType, []).object); + } static final _id_getValueAsString1 = jniAccessors.getMethodIDOf(_classRef, r"getValueAsString", r"(Ljava/lang/String;)Ljava/lang/String;"); @@ -1977,12 +2179,15 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems ///@since 2.1 - jni.JString getValueAsString1(jni.JString def) => - const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_getValueAsString1, - jni.JniCallType.objectType, - [def.reference]).object); + jni.JString getValueAsString1( + jni.JString def, + ) { + return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_getValueAsString1, + jni.JniCallType.objectType, + [def.reference]).object); + } static final _id_canReadObjectId = jniAccessors.getMethodIDOf(_classRef, r"canReadObjectId", r"()Z"); @@ -2000,8 +2205,10 @@ class JsonParser extends jni.JObject { ///@return {@code True} if the format being read supports native Object Ids; /// {@code false} if not ///@since 2.3 - bool canReadObjectId() => jniAccessors.callMethodWithArgs( - reference, _id_canReadObjectId, jni.JniCallType.booleanType, []).boolean; + bool canReadObjectId() { + return jniAccessors.callMethodWithArgs(reference, _id_canReadObjectId, + jni.JniCallType.booleanType, []).boolean; + } static final _id_canReadTypeId = jniAccessors.getMethodIDOf(_classRef, r"canReadTypeId", r"()Z"); @@ -2019,8 +2226,10 @@ class JsonParser extends jni.JObject { ///@return {@code True} if the format being read supports native Type Ids; /// {@code false} if not ///@since 2.3 - bool canReadTypeId() => jniAccessors.callMethodWithArgs( - reference, _id_canReadTypeId, jni.JniCallType.booleanType, []).boolean; + bool canReadTypeId() { + return jniAccessors.callMethodWithArgs( + reference, _id_canReadTypeId, jni.JniCallType.booleanType, []).boolean; + } static final _id_getObjectId = jniAccessors.getMethodIDOf( _classRef, r"getObjectId", r"()Ljava/lang/Object;"); @@ -2041,9 +2250,10 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems ///@since 2.3 - jni.JObject getObjectId() => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_getObjectId, jni.JniCallType.objectType, []).object); + jni.JObject getObjectId() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_getObjectId, jni.JniCallType.objectType, []).object); + } static final _id_getTypeId = jniAccessors.getMethodIDOf( _classRef, r"getTypeId", r"()Ljava/lang/Object;"); @@ -2064,9 +2274,10 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems ///@since 2.3 - jni.JObject getTypeId() => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_getTypeId, jni.JniCallType.objectType, []).object); + jni.JObject getTypeId() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_getTypeId, jni.JniCallType.objectType, []).object); + } static final _id_readValueAs = jniAccessors.getMethodIDOf( _classRef, r"readValueAs", r"(Ljava/lang/Class;)Ljava/lang/Object;"); @@ -2099,10 +2310,13 @@ class JsonParser extends jni.JObject { ///@return Java value read from content ///@throws IOException if there is either an underlying I/O problem or decoding /// issue at format layer - T readValueAs( - jni.JObjType $T, jni.JObject valueType) => - $T.fromRef(jniAccessors.callMethodWithArgs(reference, _id_readValueAs, - jni.JniCallType.objectType, [valueType.reference]).object); + $T readValueAs<$T extends jni.JObject>( + jni.JObject valueType, { + required jni.JObjType<$T> T, + }) { + return T.fromRef(jniAccessors.callMethodWithArgs(reference, _id_readValueAs, + jni.JniCallType.objectType, [valueType.reference]).object); + } static final _id_readValueAs1 = jniAccessors.getMethodIDOf( _classRef, @@ -2134,10 +2348,16 @@ class JsonParser extends jni.JObject { ///@return Java value read from content ///@throws IOException if there is either an underlying I/O problem or decoding /// issue at format layer - T readValueAs1( - jni.JObjType $T, jni.JObject valueTypeRef) => - $T.fromRef(jniAccessors.callMethodWithArgs(reference, _id_readValueAs1, - jni.JniCallType.objectType, [valueTypeRef.reference]).object); + $T readValueAs1<$T extends jni.JObject>( + jni.JObject valueTypeRef, { + required jni.JObjType<$T> T, + }) { + return T.fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_readValueAs1, + jni.JniCallType.objectType, + [valueTypeRef.reference]).object); + } static final _id_readValuesAs = jniAccessors.getMethodIDOf( _classRef, r"readValuesAs", r"(Ljava/lang/Class;)Ljava/util/Iterator;"); @@ -2153,13 +2373,16 @@ class JsonParser extends jni.JObject { ///@return Iterator for reading multiple Java values from content ///@throws IOException if there is either an underlying I/O problem or decoding /// issue at format layer - jni.JObject readValuesAs( - jni.JObjType $T, jni.JObject valueType) => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_readValuesAs, - jni.JniCallType.objectType, - [valueType.reference]).object); + jni.JObject readValuesAs<$T extends jni.JObject>( + jni.JObject valueType, { + required jni.JObjType<$T> T, + }) { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_readValuesAs, + jni.JniCallType.objectType, + [valueType.reference]).object); + } static final _id_readValuesAs1 = jniAccessors.getMethodIDOf( _classRef, @@ -2177,13 +2400,16 @@ class JsonParser extends jni.JObject { ///@return Iterator for reading multiple Java values from content ///@throws IOException if there is either an underlying I/O problem or decoding /// issue at format layer - jni.JObject readValuesAs1( - jni.JObjType $T, jni.JObject valueTypeRef) => - const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_readValuesAs1, - jni.JniCallType.objectType, - [valueTypeRef.reference]).object); + jni.JObject readValuesAs1<$T extends jni.JObject>( + jni.JObject valueTypeRef, { + required jni.JObjType<$T> T, + }) { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_readValuesAs1, + jni.JniCallType.objectType, + [valueTypeRef.reference]).object); + } static final _id_readValueAsTree = jniAccessors.getMethodIDOf( _classRef, r"readValueAsTree", r"()Ljava/lang/Object;"); @@ -2200,9 +2426,12 @@ 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(jni.JObjType $T) => - $T.fromRef(jniAccessors.callMethodWithArgs(reference, _id_readValueAsTree, - jni.JniCallType.objectType, []).object); + $T readValueAsTree<$T extends jni.JObject>({ + required jni.JObjType<$T> T, + }) { + return T.fromRef(jniAccessors.callMethodWithArgs( + reference, _id_readValueAsTree, jni.JniCallType.objectType, []).object); + } } class $JsonParserType extends jni.JObjType { @@ -2213,15 +2442,28 @@ class $JsonParserType extends jni.JObjType { @override JsonParser fromRef(jni.JObjectPtr ref) => JsonParser.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($JsonParserType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $JsonParserType && other is $JsonParserType; + } } /// from: com.fasterxml.jackson.core.JsonParser$Feature /// /// Enumeration that defines all on/off features for parsers. class JsonParser_Feature extends jni.JObject { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type; + late final jni.JObjType $type = type; JsonParser_Feature.fromRef( jni.JObjectPtr ref, @@ -2237,10 +2479,11 @@ class JsonParser_Feature extends jni.JObject { /// from: static public com.fasterxml.jackson.core.JsonParser.Feature[] values() /// The returned object must be deleted after use, by calling the `delete` method. - static jni.JArray values() => - const jni.JArrayType($JsonParser_FeatureType()).fromRef(jniAccessors - .callStaticMethodWithArgs( - _classRef, _id_values, jni.JniCallType.objectType, []).object); + static jni.JArray values() { + return const jni.JArrayType($JsonParser_FeatureType()).fromRef(jniAccessors + .callStaticMethodWithArgs( + _classRef, _id_values, jni.JniCallType.objectType, []).object); + } static final _id_valueOf = jniAccessors.getStaticMethodIDOf( _classRef, @@ -2249,10 +2492,13 @@ class JsonParser_Feature extends jni.JObject { /// from: static public com.fasterxml.jackson.core.JsonParser.Feature valueOf(java.lang.String name) /// The returned object must be deleted after use, by calling the `delete` method. - static JsonParser_Feature valueOf(jni.JString name) => - const $JsonParser_FeatureType().fromRef(jniAccessors - .callStaticMethodWithArgs(_classRef, _id_valueOf, - jni.JniCallType.objectType, [name.reference]).object); + static JsonParser_Feature valueOf( + jni.JString name, + ) { + return const $JsonParser_FeatureType().fromRef(jniAccessors + .callStaticMethodWithArgs(_classRef, _id_valueOf, + jni.JniCallType.objectType, [name.reference]).object); + } static final _id_collectDefaults = jniAccessors.getStaticMethodIDOf(_classRef, r"collectDefaults", r"()I"); @@ -2262,32 +2508,39 @@ class JsonParser_Feature extends jni.JObject { /// Method that calculates bit set (flags) of all features that /// are enabled by default. ///@return Bit mask of all features that are enabled by default - static int collectDefaults() => jniAccessors.callStaticMethodWithArgs( - _classRef, _id_collectDefaults, jni.JniCallType.intType, []).integer; + static int collectDefaults() { + return jniAccessors.callStaticMethodWithArgs( + _classRef, _id_collectDefaults, jni.JniCallType.intType, []).integer; + } static final _id_enabledByDefault = jniAccessors.getMethodIDOf(_classRef, r"enabledByDefault", r"()Z"); /// from: public boolean enabledByDefault() - bool enabledByDefault() => jniAccessors.callMethodWithArgs( - reference, _id_enabledByDefault, jni.JniCallType.booleanType, []).boolean; + bool enabledByDefault() { + return jniAccessors.callMethodWithArgs(reference, _id_enabledByDefault, + jni.JniCallType.booleanType, []).boolean; + } static final _id_enabledIn = jniAccessors.getMethodIDOf(_classRef, r"enabledIn", r"(I)Z"); /// from: public boolean enabledIn(int flags) - bool enabledIn(int flags) => jniAccessors.callMethodWithArgs( - reference, - _id_enabledIn, - jni.JniCallType.booleanType, - [jni.JValueInt(flags)]).boolean; + bool enabledIn( + int flags, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_enabledIn, + jni.JniCallType.booleanType, [jni.JValueInt(flags)]).boolean; + } static final _id_getMask = jniAccessors.getMethodIDOf(_classRef, r"getMask", r"()I"); /// from: public int getMask() - int getMask() => jniAccessors.callMethodWithArgs( - reference, _id_getMask, jni.JniCallType.intType, []).integer; + int getMask() { + return jniAccessors.callMethodWithArgs( + reference, _id_getMask, jni.JniCallType.intType, []).integer; + } } class $JsonParser_FeatureType extends jni.JObjType { @@ -2299,6 +2552,21 @@ class $JsonParser_FeatureType extends jni.JObjType { @override JsonParser_Feature fromRef(jni.JObjectPtr ref) => JsonParser_Feature.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($JsonParser_FeatureType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $JsonParser_FeatureType && + other is $JsonParser_FeatureType; + } } /// from: com.fasterxml.jackson.core.JsonParser$NumberType @@ -2306,9 +2574,8 @@ class $JsonParser_FeatureType extends jni.JObjType { /// Enumeration of possible "native" (optimal) types that can be /// used for numbers. class JsonParser_NumberType extends jni.JObject { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type; + late final jni.JObjType $type = type; JsonParser_NumberType.fromRef( jni.JObjectPtr ref, @@ -2324,10 +2591,11 @@ class JsonParser_NumberType extends jni.JObject { /// from: static public com.fasterxml.jackson.core.JsonParser.NumberType[] values() /// The returned object must be deleted after use, by calling the `delete` method. - static jni.JArray values() => - const jni.JArrayType($JsonParser_NumberTypeType()).fromRef(jniAccessors - .callStaticMethodWithArgs( - _classRef, _id_values, jni.JniCallType.objectType, []).object); + static jni.JArray values() { + return const jni.JArrayType($JsonParser_NumberTypeType()).fromRef( + jniAccessors.callStaticMethodWithArgs( + _classRef, _id_values, jni.JniCallType.objectType, []).object); + } static final _id_valueOf = jniAccessors.getStaticMethodIDOf( _classRef, @@ -2336,10 +2604,13 @@ class JsonParser_NumberType extends jni.JObject { /// from: static public com.fasterxml.jackson.core.JsonParser.NumberType valueOf(java.lang.String name) /// The returned object must be deleted after use, by calling the `delete` method. - static JsonParser_NumberType valueOf(jni.JString name) => - const $JsonParser_NumberTypeType().fromRef(jniAccessors - .callStaticMethodWithArgs(_classRef, _id_valueOf, - jni.JniCallType.objectType, [name.reference]).object); + static JsonParser_NumberType valueOf( + jni.JString name, + ) { + return const $JsonParser_NumberTypeType().fromRef(jniAccessors + .callStaticMethodWithArgs(_classRef, _id_valueOf, + jni.JniCallType.objectType, [name.reference]).object); + } } class $JsonParser_NumberTypeType extends jni.JObjType { @@ -2351,4 +2622,19 @@ class $JsonParser_NumberTypeType extends jni.JObjType { @override JsonParser_NumberType fromRef(jni.JObjectPtr ref) => JsonParser_NumberType.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($JsonParser_NumberTypeType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $JsonParser_NumberTypeType && + other is $JsonParser_NumberTypeType; + } } diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonToken.dart b/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonToken.dart index 6f3e8b493..2a88806e9 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonToken.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonToken.dart @@ -43,9 +43,8 @@ import "../../../../_init.dart"; /// Enumeration for basic token types used for returning results /// of parsing JSON content. class JsonToken extends jni.JObject { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type; + late final jni.JObjType $type = type; JsonToken.fromRef( jni.JObjectPtr ref, @@ -61,10 +60,11 @@ class JsonToken extends jni.JObject { /// from: static public com.fasterxml.jackson.core.JsonToken[] values() /// The returned object must be deleted after use, by calling the `delete` method. - static jni.JArray values() => - const jni.JArrayType($JsonTokenType()).fromRef(jniAccessors - .callStaticMethodWithArgs( - _classRef, _id_values, jni.JniCallType.objectType, []).object); + static jni.JArray values() { + return const jni.JArrayType($JsonTokenType()).fromRef(jniAccessors + .callStaticMethodWithArgs( + _classRef, _id_values, jni.JniCallType.objectType, []).object); + } static final _id_valueOf = jniAccessors.getStaticMethodIDOf( _classRef, @@ -73,45 +73,55 @@ class JsonToken extends jni.JObject { /// from: static public com.fasterxml.jackson.core.JsonToken valueOf(java.lang.String name) /// The returned object must be deleted after use, by calling the `delete` method. - static JsonToken valueOf(jni.JString name) => - const $JsonTokenType().fromRef(jniAccessors.callStaticMethodWithArgs( - _classRef, - _id_valueOf, - jni.JniCallType.objectType, - [name.reference]).object); + static JsonToken valueOf( + jni.JString name, + ) { + return const $JsonTokenType().fromRef(jniAccessors.callStaticMethodWithArgs( + _classRef, + _id_valueOf, + jni.JniCallType.objectType, + [name.reference]).object); + } static final _id_id = jniAccessors.getMethodIDOf(_classRef, r"id", r"()I"); /// from: public final int id() - int id() => jniAccessors.callMethodWithArgs( - reference, _id_id, jni.JniCallType.intType, []).integer; + int id() { + return jniAccessors.callMethodWithArgs( + reference, _id_id, jni.JniCallType.intType, []).integer; + } static final _id_asString = jniAccessors.getMethodIDOf( _classRef, r"asString", r"()Ljava/lang/String;"); /// from: public final java.lang.String asString() /// The returned object must be deleted after use, by calling the `delete` method. - jni.JString asString() => - const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_asString, jni.JniCallType.objectType, []).object); + jni.JString asString() { + return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_asString, jni.JniCallType.objectType, []).object); + } static final _id_asCharArray = jniAccessors.getMethodIDOf(_classRef, r"asCharArray", r"()[C"); /// from: public final char[] asCharArray() /// The returned object must be deleted after use, by calling the `delete` method. - jni.JArray asCharArray() => const jni.JArrayType(jni.JCharType()) - .fromRef(jniAccessors.callMethodWithArgs( - reference, _id_asCharArray, jni.JniCallType.objectType, []).object); + jni.JArray asCharArray() { + return const jni.JArrayType(jni.JCharType()).fromRef(jniAccessors + .callMethodWithArgs( + reference, _id_asCharArray, jni.JniCallType.objectType, []).object); + } static final _id_asByteArray = jniAccessors.getMethodIDOf(_classRef, r"asByteArray", r"()[B"); /// from: public final byte[] asByteArray() /// The returned object must be deleted after use, by calling the `delete` method. - jni.JArray asByteArray() => const jni.JArrayType(jni.JByteType()) - .fromRef(jniAccessors.callMethodWithArgs( - reference, _id_asByteArray, jni.JniCallType.objectType, []).object); + jni.JArray asByteArray() { + return const jni.JArrayType(jni.JByteType()).fromRef(jniAccessors + .callMethodWithArgs( + reference, _id_asByteArray, jni.JniCallType.objectType, []).object); + } static final _id_isNumeric = jniAccessors.getMethodIDOf(_classRef, r"isNumeric", r"()Z"); @@ -120,8 +130,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 - bool isNumeric() => jniAccessors.callMethodWithArgs( - reference, _id_isNumeric, jni.JniCallType.booleanType, []).boolean; + bool isNumeric() { + return jniAccessors.callMethodWithArgs( + reference, _id_isNumeric, jni.JniCallType.booleanType, []).boolean; + } static final _id_isStructStart = jniAccessors.getMethodIDOf(_classRef, r"isStructStart", r"()Z"); @@ -135,8 +147,10 @@ class JsonToken extends jni.JObject { ///@return {@code True} if this token is {@code START_OBJECT} or {@code START_ARRAY}, /// {@code false} otherwise ///@since 2.3 - bool isStructStart() => jniAccessors.callMethodWithArgs( - reference, _id_isStructStart, jni.JniCallType.booleanType, []).boolean; + bool isStructStart() { + return jniAccessors.callMethodWithArgs( + reference, _id_isStructStart, jni.JniCallType.booleanType, []).boolean; + } static final _id_isStructEnd = jniAccessors.getMethodIDOf(_classRef, r"isStructEnd", r"()Z"); @@ -150,8 +164,10 @@ class JsonToken extends jni.JObject { ///@return {@code True} if this token is {@code END_OBJECT} or {@code END_ARRAY}, /// {@code false} otherwise ///@since 2.3 - bool isStructEnd() => jniAccessors.callMethodWithArgs( - reference, _id_isStructEnd, jni.JniCallType.booleanType, []).boolean; + bool isStructEnd() { + return jniAccessors.callMethodWithArgs( + reference, _id_isStructEnd, jni.JniCallType.booleanType, []).boolean; + } static final _id_isScalarValue = jniAccessors.getMethodIDOf(_classRef, r"isScalarValue", r"()Z"); @@ -164,8 +180,10 @@ class JsonToken extends jni.JObject { /// {@code FIELD_NAME}. ///@return {@code True} if this token is a scalar value token (one of /// {@code VALUE_xxx} tokens), {@code false} otherwise - bool isScalarValue() => jniAccessors.callMethodWithArgs( - reference, _id_isScalarValue, jni.JniCallType.booleanType, []).boolean; + bool isScalarValue() { + return jniAccessors.callMethodWithArgs( + reference, _id_isScalarValue, jni.JniCallType.booleanType, []).boolean; + } static final _id_isBoolean = jniAccessors.getMethodIDOf(_classRef, r"isBoolean", r"()Z"); @@ -174,8 +192,10 @@ class JsonToken extends jni.JObject { /// /// @return {@code True} if this token is {@code VALUE_TRUE} or {@code VALUE_FALSE}, /// {@code false} otherwise - bool isBoolean() => jniAccessors.callMethodWithArgs( - reference, _id_isBoolean, jni.JniCallType.booleanType, []).boolean; + bool isBoolean() { + return jniAccessors.callMethodWithArgs( + reference, _id_isBoolean, jni.JniCallType.booleanType, []).boolean; + } } class $JsonTokenType extends jni.JObjType { @@ -186,4 +206,18 @@ class $JsonTokenType extends jni.JObjType { @override JsonToken fromRef(jni.JObjectPtr ref) => JsonToken.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($JsonTokenType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $JsonTokenType && other is $JsonTokenType; + } } diff --git a/pkgs/jnigen/test/kotlin_test/lib/kotlin.dart b/pkgs/jnigen/test/kotlin_test/lib/kotlin.dart index 5d11a1734..094aa46f6 100644 --- a/pkgs/jnigen/test/kotlin_test/lib/kotlin.dart +++ b/pkgs/jnigen/test/kotlin_test/lib/kotlin.dart @@ -30,9 +30,8 @@ final ffi.Pointer Function(String sym) jniLookup = /// from: com.github.dart_lang.jnigen.SuspendFun class SuspendFun extends jni.JObject { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type; + late final jni.JObjType $type = type; SuspendFun.fromRef( jni.JObjectPtr ref, @@ -46,7 +45,9 @@ class SuspendFun extends jni.JObject { /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. - SuspendFun() : super.fromRef(_ctor().object); + factory SuspendFun() { + return SuspendFun.fromRef(_ctor().object); + } static final _sayHello = jniLookup< ffi.NativeFunction< @@ -82,7 +83,9 @@ class SuspendFun extends jni.JObject { /// from: public final java.lang.Object sayHello(java.lang.String string, kotlin.coroutines.Continuation continuation) /// The returned object must be deleted after use, by calling the `delete` method. - Future sayHello1(jni.JString string) async { + Future sayHello1( + jni.JString string, + ) async { final $p = ReceivePort(); final $c = jni.JObject.fromRef(jni.Jni.newPortContinuation($p)); _sayHello1(reference, string.reference, $c.reference).object; @@ -103,4 +106,18 @@ class $SuspendFunType extends jni.JObjType { @override SuspendFun fromRef(jni.JObjectPtr ref) => SuspendFun.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($SuspendFunType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $SuspendFunType && other is $SuspendFunType; + } } diff --git a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/generics/MyStack.java b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/generics/MyStack.java index fc85a3d07..c4e2d06f4 100644 --- a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/generics/MyStack.java +++ b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/generics/MyStack.java @@ -13,6 +13,38 @@ public MyStack() { stack = new Stack<>(); } + public static MyStack fromArray(T[] arr) { + var stack = new MyStack(); + for (int i = 0; i < arr.length; ++i) { + stack.push(arr[i]); + } + return stack; + } + + public static MyStack fromArrayOfArrayOfGrandParents(GrandParent[][] arr) { + // just for testing + var stack = new MyStack(); + stack.push(arr[0][0].value); + return stack; + } + + public static MyStack of() { + return new MyStack(); + } + + public static MyStack of(T obj) { + var stack = new MyStack(); + stack.push(obj); + return stack; + } + + public static MyStack of(T obj, T obj2) { + var stack = new MyStack(); + stack.push(obj); + stack.push(obj2); + return stack; + } + public void push(T item) { stack.push(item); } @@ -20,4 +52,8 @@ public void push(T item) { public T pop() { return stack.pop(); } + + public int size() { + return stack.size(); + } } diff --git a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/generics/StringMap.java b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/generics/StringMap.java new file mode 100644 index 000000000..05f9365e4 --- /dev/null +++ b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/generics/StringMap.java @@ -0,0 +1,7 @@ +// 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. + +package com.github.dart_lang.jnigen.generics; + +public class StringMap extends StringKeyedMap {} diff --git a/pkgs/jnigen/test/simple_package_test/lib/simple_package.dart b/pkgs/jnigen/test/simple_package_test/lib/simple_package.dart index aca99d9ca..c5d1083f0 100644 --- a/pkgs/jnigen/test/simple_package_test/lib/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/lib/simple_package.dart @@ -30,9 +30,8 @@ final ffi.Pointer Function(String sym) jniLookup = /// from: com.github.dart_lang.jnigen.simple_package.Example class Example extends jni.JObject { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type; + late final jni.JObjType $type = type; Example.fromRef( jni.JObjectPtr ref, @@ -89,7 +88,9 @@ class Example extends jni.JObject { /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. - Example() : super.fromRef(_ctor().object); + factory Example() { + return Example.fromRef(_ctor().object); + } static final _ctor1 = jniLookup>( @@ -98,7 +99,11 @@ class Example extends jni.JObject { /// from: public void (int internal) /// The returned object must be deleted after use, by calling the `delete` method. - Example.ctor1(int internal) : super.fromRef(_ctor1(internal).object); + factory Example.ctor1( + int internal, + ) { + return Example.fromRef(_ctor1(internal).object); + } static final _whichExample = jniLookup< ffi.NativeFunction< @@ -107,7 +112,9 @@ class Example extends jni.JObject { .asFunction)>(); /// from: public int whichExample() - int whichExample() => _whichExample(reference).integer; + int whichExample() { + return _whichExample(reference).integer; + } static final _getAux = jniLookup>("Example__getAux") @@ -115,8 +122,9 @@ class Example extends jni.JObject { /// from: static public com.github.dart_lang.jnigen.simple_package.Example.Aux getAux() /// The returned object must be deleted after use, by calling the `delete` method. - static Example_Aux getAux() => - const $Example_AuxType().fromRef(_getAux().object); + static Example_Aux getAux() { + return const $Example_AuxType().fromRef(_getAux().object); + } static final _addInts = jniLookup< ffi.NativeFunction>( @@ -124,7 +132,12 @@ class Example extends jni.JObject { .asFunction(); /// from: static public int addInts(int a, int b) - static int addInts(int a, int b) => _addInts(a, b).integer; + static int addInts( + int a, + int b, + ) { + return _addInts(a, b).integer; + } static final _getArr = jniLookup>("Example__getArr") @@ -132,8 +145,9 @@ class Example extends jni.JObject { /// from: static public int[] getArr() /// The returned object must be deleted after use, by calling the `delete` method. - static jni.JArray getArr() => - const jni.JArrayType(jni.JIntType()).fromRef(_getArr().object); + static jni.JArray getArr() { + return const jni.JArrayType(jni.JIntType()).fromRef(_getArr().object); + } static final _addAll = jniLookup< ffi.NativeFunction< @@ -141,7 +155,11 @@ class Example extends jni.JObject { .asFunction)>(); /// from: static public int addAll(int[] arr) - static int addAll(jni.JArray arr) => _addAll(arr.reference).integer; + static int addAll( + jni.JArray arr, + ) { + return _addAll(arr.reference).integer; + } static final _getSelf = jniLookup< ffi.NativeFunction< @@ -151,7 +169,9 @@ class Example extends jni.JObject { /// from: public com.github.dart_lang.jnigen.simple_package.Example getSelf() /// The returned object must be deleted after use, by calling the `delete` method. - Example getSelf() => const $ExampleType().fromRef(_getSelf(reference).object); + Example getSelf() { + return const $ExampleType().fromRef(_getSelf(reference).object); + } static final _getNum = jniLookup< ffi.NativeFunction< @@ -159,7 +179,9 @@ class Example extends jni.JObject { .asFunction)>(); /// from: public int getNum() - int getNum() => _getNum(reference).integer; + int getNum() { + return _getNum(reference).integer; + } static final _setNum = jniLookup< ffi.NativeFunction< @@ -168,7 +190,11 @@ class Example extends jni.JObject { .asFunction, int)>(); /// from: public void setNum(int num) - void setNum(int num) => _setNum(reference, num).check(); + void setNum( + int num, + ) { + return _setNum(reference, num).check(); + } static final _getInternal = jniLookup< ffi.NativeFunction< @@ -177,7 +203,9 @@ class Example extends jni.JObject { .asFunction)>(); /// from: public int getInternal() - int getInternal() => _getInternal(reference).integer; + int getInternal() { + return _getInternal(reference).integer; + } static final _setInternal = jniLookup< ffi.NativeFunction< @@ -186,7 +214,11 @@ class Example extends jni.JObject { .asFunction, int)>(); /// from: public void setInternal(int internal) - void setInternal(int internal) => _setInternal(reference, internal).check(); + void setInternal( + int internal, + ) { + return _setInternal(reference, internal).check(); + } static final _throwException = jniLookup>( @@ -194,7 +226,9 @@ class Example extends jni.JObject { .asFunction(); /// from: static public void throwException() - static void throwException() => _throwException().check(); + static void throwException() { + return _throwException().check(); + } } class $ExampleType extends jni.JObjType { @@ -206,13 +240,26 @@ class $ExampleType extends jni.JObjType { @override Example fromRef(jni.JObjectPtr ref) => Example.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($ExampleType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $ExampleType && other is $ExampleType; + } } /// from: com.github.dart_lang.jnigen.simple_package.Example$Aux class Example_Aux extends jni.JObject { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type; + late final jni.JObjType $type = type; Example_Aux.fromRef( jni.JObjectPtr ref, @@ -249,7 +296,11 @@ class Example_Aux extends jni.JObject { /// from: public void (boolean value) /// The returned object must be deleted after use, by calling the `delete` method. - Example_Aux(bool value) : super.fromRef(_ctor(value ? 1 : 0).object); + factory Example_Aux( + bool value, + ) { + return Example_Aux.fromRef(_ctor(value ? 1 : 0).object); + } static final _getValue = jniLookup< ffi.NativeFunction< @@ -258,7 +309,9 @@ class Example_Aux extends jni.JObject { .asFunction)>(); /// from: public boolean getValue() - bool getValue() => _getValue(reference).boolean; + bool getValue() { + return _getValue(reference).boolean; + } static final _setValue = jniLookup< ffi.NativeFunction< @@ -267,7 +320,11 @@ class Example_Aux extends jni.JObject { .asFunction, int)>(); /// from: public void setValue(boolean value) - void setValue(bool value) => _setValue(reference, value ? 1 : 0).check(); + void setValue( + bool value, + ) { + return _setValue(reference, value ? 1 : 0).check(); + } } class $Example_AuxType extends jni.JObjType { @@ -279,13 +336,26 @@ class $Example_AuxType extends jni.JObjType { @override Example_Aux fromRef(jni.JObjectPtr ref) => Example_Aux.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($Example_AuxType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $Example_AuxType && other is $Example_AuxType; + } } /// from: com.github.dart_lang.jnigen.pkg2.C2 class C2 extends jni.JObject { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type; + late final jni.JObjType $type = type; C2.fromRef( jni.JObjectPtr ref, @@ -315,7 +385,9 @@ class C2 extends jni.JObject { /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. - C2() : super.fromRef(_ctor().object); + factory C2() { + return C2.fromRef(_ctor().object); + } } class $C2Type extends jni.JObjType { @@ -326,13 +398,26 @@ class $C2Type extends jni.JObjType { @override C2 fromRef(jni.JObjectPtr ref) => C2.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($C2Type).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $C2Type && other is $C2Type; + } } /// from: com.github.dart_lang.jnigen.pkg2.Example class Example1 extends jni.JObject { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type; + late final jni.JObjType $type = type; Example1.fromRef( jni.JObjectPtr ref, @@ -346,7 +431,9 @@ class Example1 extends jni.JObject { /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. - Example1() : super.fromRef(_ctor().object); + factory Example1() { + return Example1.fromRef(_ctor().object); + } static final _whichExample = jniLookup< ffi.NativeFunction< @@ -355,7 +442,9 @@ class Example1 extends jni.JObject { .asFunction)>(); /// from: public int whichExample() - int whichExample() => _whichExample(reference).integer; + int whichExample() { + return _whichExample(reference).integer; + } } class $Example1Type extends jni.JObjType { @@ -366,27 +455,40 @@ class $Example1Type extends jni.JObjType { @override Example1 fromRef(jni.JObjectPtr ref) => Example1.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($Example1Type).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $Example1Type && other is $Example1Type; + } } /// from: com.github.dart_lang.jnigen.generics.GrandParent -class GrandParent extends jni.JObject { - late final jni.JObjType? _$type; +class GrandParent<$T extends jni.JObject> extends jni.JObject { @override - jni.JObjType get $type => _$type ??= type($T); + late final jni.JObjType $type = type(T); - final jni.JObjType $T; + final jni.JObjType<$T> T; GrandParent.fromRef( - this.$T, + this.T, jni.JObjectPtr ref, ) : super.fromRef(ref); /// The type which includes information such as the signature of this class. - static $GrandParentType type( - jni.JObjType $T, + static $GrandParentType<$T> type<$T extends jni.JObject>( + jni.JObjType<$T> T, ) { return $GrandParentType( - $T, + T, ); } @@ -409,11 +511,11 @@ class GrandParent extends jni.JObject { /// from: public T value /// The returned object must be deleted after use, by calling the `delete` method. - T get value => $T.fromRef(_get_value(reference).object); + $T get value => T.fromRef(_get_value(reference).object); /// from: public T value /// The returned object must be deleted after use, by calling the `delete` method. - set value(T value) => _set_value(reference, value.reference); + set value($T value) => _set_value(reference, value.reference); static final _ctor = jniLookup< ffi.NativeFunction< @@ -423,7 +525,15 @@ class GrandParent extends jni.JObject { /// from: public void (T value) /// The returned object must be deleted after use, by calling the `delete` method. - GrandParent(this.$T, T value) : super.fromRef(_ctor(value.reference).object); + factory GrandParent( + $T value, { + jni.JObjType<$T>? T, + }) { + T ??= jni.lowestCommonSuperType([ + value.$type, + ]) as jni.JObjType<$T>; + return GrandParent.fromRef(T, _ctor(value.reference).object); + } static final _stringParent = jniLookup< ffi.NativeFunction< @@ -433,9 +543,10 @@ class GrandParent extends jni.JObject { /// from: public com.github.dart_lang.jnigen.generics.GrandParent.Parent stringParent() /// The returned object must be deleted after use, by calling the `delete` method. - GrandParent_Parent stringParent() => - const $GrandParent_ParentType(jni.JObjectType(), jni.JStringType()) - .fromRef(_stringParent(reference).object); + GrandParent_Parent stringParent() { + return const $GrandParent_ParentType(jni.JObjectType(), jni.JStringType()) + .fromRef(_stringParent(reference).object); + } static final _varParent = jniLookup< ffi.NativeFunction< @@ -447,10 +558,16 @@ class GrandParent extends jni.JObject { /// from: public com.github.dart_lang.jnigen.generics.GrandParent.Parent varParent(S nestedValue) /// The returned object must be deleted after use, by calling the `delete` method. - GrandParent_Parent varParent( - jni.JObjType $S, S nestedValue) => - $GrandParent_ParentType(const jni.JObjectType(), $S) - .fromRef(_varParent(reference, nestedValue.reference).object); + GrandParent_Parent varParent<$S extends jni.JObject>( + $S nestedValue, { + jni.JObjType<$S>? S, + }) { + S ??= jni.lowestCommonSuperType([ + nestedValue.$type, + ]) as jni.JObjType<$S>; + return $GrandParent_ParentType(const jni.JObjectType(), S) + .fromRef(_varParent(reference, nestedValue.reference).object); + } static final _stringStaticParent = jniLookup>( @@ -459,9 +576,10 @@ class GrandParent extends jni.JObject { /// from: static public com.github.dart_lang.jnigen.generics.GrandParent.StaticParent stringStaticParent() /// The returned object must be deleted after use, by calling the `delete` method. - static GrandParent_StaticParent stringStaticParent() => - const $GrandParent_StaticParentType(jni.JStringType()) - .fromRef(_stringStaticParent().object); + static GrandParent_StaticParent stringStaticParent() { + return const $GrandParent_StaticParentType(jni.JStringType()) + .fromRef(_stringStaticParent().object); + } static final _varStaticParent = jniLookup< ffi.NativeFunction< @@ -471,10 +589,16 @@ class GrandParent extends jni.JObject { /// from: static public com.github.dart_lang.jnigen.generics.GrandParent.StaticParent varStaticParent(S value) /// The returned object must be deleted after use, by calling the `delete` method. - static GrandParent_StaticParent varStaticParent( - jni.JObjType $S, S value) => - $GrandParent_StaticParentType($S) - .fromRef(_varStaticParent(value.reference).object); + static GrandParent_StaticParent<$S> varStaticParent<$S extends jni.JObject>( + $S value, { + jni.JObjType<$S>? S, + }) { + S ??= jni.lowestCommonSuperType([ + value.$type, + ]) as jni.JObjType<$S>; + return $GrandParent_StaticParentType(S) + .fromRef(_varStaticParent(value.reference).object); + } static final _staticParentWithSameType = jniLookup< ffi.NativeFunction< @@ -484,51 +608,67 @@ class GrandParent extends jni.JObject { /// from: public com.github.dart_lang.jnigen.generics.GrandParent.StaticParent staticParentWithSameType() /// The returned object must be deleted after use, by calling the `delete` method. - GrandParent_StaticParent staticParentWithSameType() => - $GrandParent_StaticParentType($T) - .fromRef(_staticParentWithSameType(reference).object); + GrandParent_StaticParent<$T> staticParentWithSameType() { + return $GrandParent_StaticParentType(T) + .fromRef(_staticParentWithSameType(reference).object); + } } -class $GrandParentType - extends jni.JObjType> { - final jni.JObjType $T; +class $GrandParentType<$T extends jni.JObject> + extends jni.JObjType> { + final jni.JObjType<$T> T; const $GrandParentType( - this.$T, + this.T, ); @override String get signature => r"Lcom/github/dart_lang/jnigen/generics/GrandParent;"; @override - GrandParent fromRef(jni.JObjectPtr ref) => GrandParent.fromRef($T, ref); + GrandParent<$T> fromRef(jni.JObjectPtr ref) => GrandParent.fromRef(T, ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => Object.hash($GrandParentType, T); + + @override + bool operator ==(Object other) { + return other.runtimeType == $GrandParentType && + other is $GrandParentType && + T == other.T; + } } /// from: com.github.dart_lang.jnigen.generics.GrandParent$Parent -class GrandParent_Parent +class GrandParent_Parent<$T extends jni.JObject, $S extends jni.JObject> extends jni.JObject { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type($T, $S); + late final jni.JObjType $type = type(T, S); - final jni.JObjType $T; - final jni.JObjType $S; + final jni.JObjType<$T> T; + final jni.JObjType<$S> S; GrandParent_Parent.fromRef( - this.$T, - this.$S, + this.T, + this.S, jni.JObjectPtr ref, ) : super.fromRef(ref); /// The type which includes information such as the signature of this class. - static $GrandParent_ParentType - type( - jni.JObjType $T, - jni.JObjType $S, + static $GrandParent_ParentType<$T, $S> + type<$T extends jni.JObject, $S extends jni.JObject>( + jni.JObjType<$T> T, + jni.JObjType<$S> S, ) { return $GrandParent_ParentType( - $T, - $S, + T, + S, ); } @@ -552,11 +692,11 @@ class GrandParent_Parent /// from: public T parentValue /// The returned object must be deleted after use, by calling the `delete` method. - T get parentValue => $T.fromRef(_get_parentValue(reference).object); + $T get parentValue => T.fromRef(_get_parentValue(reference).object); /// from: public T parentValue /// The returned object must be deleted after use, by calling the `delete` method. - set parentValue(T value) => _set_parentValue(reference, value.reference); + set parentValue($T value) => _set_parentValue(reference, value.reference); static final _get_value = jniLookup< ffi.NativeFunction< @@ -577,11 +717,11 @@ class GrandParent_Parent /// from: public S value /// The returned object must be deleted after use, by calling the `delete` method. - S get value => $S.fromRef(_get_value(reference).object); + $S get value => S.fromRef(_get_value(reference).object); /// from: public S value /// The returned object must be deleted after use, by calling the `delete` method. - set value(S value) => _set_value(reference, value.reference); + set value($S value) => _set_value(reference, value.reference); static final _ctor = jniLookup< ffi.NativeFunction< @@ -593,18 +733,31 @@ class GrandParent_Parent /// from: public void (T parentValue, S value) /// The returned object must be deleted after use, by calling the `delete` method. - GrandParent_Parent(this.$T, this.$S, T parentValue, S value) - : super.fromRef(_ctor(parentValue.reference, value.reference).object); + factory GrandParent_Parent( + $T parentValue, + $S value, { + jni.JObjType<$T>? T, + jni.JObjType<$S>? S, + }) { + T ??= jni.lowestCommonSuperType([ + parentValue.$type, + ]) as jni.JObjType<$T>; + S ??= jni.lowestCommonSuperType([ + value.$type, + ]) as jni.JObjType<$S>; + return GrandParent_Parent.fromRef( + T, S, _ctor(parentValue.reference, value.reference).object); + } } -class $GrandParent_ParentType - extends jni.JObjType> { - final jni.JObjType $T; - final jni.JObjType $S; +class $GrandParent_ParentType<$T extends jni.JObject, $S extends jni.JObject> + extends jni.JObjType> { + final jni.JObjType<$T> T; + final jni.JObjType<$S> S; const $GrandParent_ParentType( - this.$T, - this.$S, + this.T, + this.S, ); @override @@ -612,39 +765,55 @@ class $GrandParent_ParentType r"Lcom/github/dart_lang/jnigen/generics/GrandParent$Parent;"; @override - GrandParent_Parent fromRef(jni.JObjectPtr ref) => - GrandParent_Parent.fromRef($T, $S, ref); + GrandParent_Parent<$T, $S> fromRef(jni.JObjectPtr ref) => + GrandParent_Parent.fromRef(T, S, ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => Object.hash($GrandParent_ParentType, T, S); + + @override + bool operator ==(Object other) { + return other.runtimeType == $GrandParent_ParentType && + other is $GrandParent_ParentType && + T == other.T && + S == other.S; + } } /// from: com.github.dart_lang.jnigen.generics.GrandParent$Parent$Child -class GrandParent_Parent_Child extends jni.JObject { - late final jni.JObjType? _$type; +class GrandParent_Parent_Child<$T extends jni.JObject, $S extends jni.JObject, + $U extends jni.JObject> extends jni.JObject { @override - jni.JObjType get $type => _$type ??= type($T, $S, $U); + late final jni.JObjType $type = type(T, S, U); - final jni.JObjType $T; - final jni.JObjType $S; - final jni.JObjType $U; + final jni.JObjType<$T> T; + final jni.JObjType<$S> S; + final jni.JObjType<$U> U; GrandParent_Parent_Child.fromRef( - this.$T, - this.$S, - this.$U, + this.T, + this.S, + this.U, jni.JObjectPtr ref, ) : super.fromRef(ref); /// The type which includes information such as the signature of this class. - static $GrandParent_Parent_ChildType - type( - jni.JObjType $T, - jni.JObjType $S, - jni.JObjType $U, + static $GrandParent_Parent_ChildType<$T, $S, $U> type<$T extends jni.JObject, + $S extends jni.JObject, $U extends jni.JObject>( + jni.JObjType<$T> T, + jni.JObjType<$S> S, + jni.JObjType<$U> U, ) { return $GrandParent_Parent_ChildType( - $T, - $S, - $U, + T, + S, + U, ); } @@ -668,11 +837,11 @@ class GrandParent_Parent_Child $T.fromRef(_get_grandParentValue(reference).object); + $T get grandParentValue => T.fromRef(_get_grandParentValue(reference).object); /// from: public T grandParentValue /// The returned object must be deleted after use, by calling the `delete` method. - set grandParentValue(T value) => + set grandParentValue($T value) => _set_grandParentValue(reference, value.reference); static final _get_parentValue = jniLookup< @@ -695,11 +864,11 @@ class GrandParent_Parent_Child $S.fromRef(_get_parentValue(reference).object); + $S get parentValue => S.fromRef(_get_parentValue(reference).object); /// from: public S parentValue /// The returned object must be deleted after use, by calling the `delete` method. - set parentValue(S value) => _set_parentValue(reference, value.reference); + set parentValue($S value) => _set_parentValue(reference, value.reference); static final _get_value = jniLookup< ffi.NativeFunction< @@ -721,11 +890,11 @@ class GrandParent_Parent_Child $U.fromRef(_get_value(reference).object); + $U get value => U.fromRef(_get_value(reference).object); /// from: public U value /// The returned object must be deleted after use, by calling the `delete` method. - set value(U value) => _set_value(reference, value.reference); + set value($U value) => _set_value(reference, value.reference); static final _ctor = jniLookup< ffi.NativeFunction< @@ -739,24 +908,44 @@ class GrandParent_Parent_Child(T grandParentValue, S parentValue, U value) /// The returned object must be deleted after use, by calling the `delete` method. - GrandParent_Parent_Child( - this.$T, this.$S, this.$U, T grandParentValue, S parentValue, U value) - : super.fromRef(_ctor(grandParentValue.reference, parentValue.reference, + factory GrandParent_Parent_Child( + $T grandParentValue, + $S parentValue, + $U value, { + jni.JObjType<$T>? T, + jni.JObjType<$S>? S, + jni.JObjType<$U>? U, + }) { + T ??= jni.lowestCommonSuperType([ + grandParentValue.$type, + ]) as jni.JObjType<$T>; + S ??= jni.lowestCommonSuperType([ + parentValue.$type, + ]) as jni.JObjType<$S>; + U ??= jni.lowestCommonSuperType([ + value.$type, + ]) as jni.JObjType<$U>; + return GrandParent_Parent_Child.fromRef( + T, + S, + U, + _ctor(grandParentValue.reference, parentValue.reference, value.reference) .object); + } } -class $GrandParent_Parent_ChildType - extends jni.JObjType> { - final jni.JObjType $T; - final jni.JObjType $S; - final jni.JObjType $U; +class $GrandParent_Parent_ChildType<$T extends jni.JObject, + $S extends jni.JObject, $U extends jni.JObject> + extends jni.JObjType> { + final jni.JObjType<$T> T; + final jni.JObjType<$S> S; + final jni.JObjType<$U> U; const $GrandParent_Parent_ChildType( - this.$T, - this.$S, - this.$U, + this.T, + this.S, + this.U, ); @override @@ -764,29 +953,46 @@ class $GrandParent_Parent_ChildType fromRef(jni.JObjectPtr ref) => - GrandParent_Parent_Child.fromRef($T, $S, $U, ref); + GrandParent_Parent_Child<$T, $S, $U> fromRef(jni.JObjectPtr ref) => + GrandParent_Parent_Child.fromRef(T, S, U, ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => Object.hash($GrandParent_Parent_ChildType, T, S, U); + + @override + bool operator ==(Object other) { + return other.runtimeType == $GrandParent_Parent_ChildType && + other is $GrandParent_Parent_ChildType && + T == other.T && + S == other.S && + U == other.U; + } } /// from: com.github.dart_lang.jnigen.generics.GrandParent$StaticParent -class GrandParent_StaticParent extends jni.JObject { - late final jni.JObjType? _$type; +class GrandParent_StaticParent<$S extends jni.JObject> extends jni.JObject { @override - jni.JObjType get $type => _$type ??= type($S); + late final jni.JObjType $type = type(S); - final jni.JObjType $S; + final jni.JObjType<$S> S; GrandParent_StaticParent.fromRef( - this.$S, + this.S, jni.JObjectPtr ref, ) : super.fromRef(ref); /// The type which includes information such as the signature of this class. - static $GrandParent_StaticParentType type( - jni.JObjType $S, + static $GrandParent_StaticParentType<$S> type<$S extends jni.JObject>( + jni.JObjType<$S> S, ) { return $GrandParent_StaticParentType( - $S, + S, ); } @@ -810,11 +1016,11 @@ class GrandParent_StaticParent extends jni.JObject { /// from: public S value /// The returned object must be deleted after use, by calling the `delete` method. - S get value => $S.fromRef(_get_value(reference).object); + $S get value => S.fromRef(_get_value(reference).object); /// from: public S value /// The returned object must be deleted after use, by calling the `delete` method. - set value(S value) => _set_value(reference, value.reference); + set value($S value) => _set_value(reference, value.reference); static final _ctor = jniLookup< ffi.NativeFunction< @@ -824,16 +1030,23 @@ class GrandParent_StaticParent extends jni.JObject { /// from: public void (S value) /// The returned object must be deleted after use, by calling the `delete` method. - GrandParent_StaticParent(this.$S, S value) - : super.fromRef(_ctor(value.reference).object); + factory GrandParent_StaticParent( + $S value, { + jni.JObjType<$S>? S, + }) { + S ??= jni.lowestCommonSuperType([ + value.$type, + ]) as jni.JObjType<$S>; + return GrandParent_StaticParent.fromRef(S, _ctor(value.reference).object); + } } -class $GrandParent_StaticParentType - extends jni.JObjType> { - final jni.JObjType $S; +class $GrandParent_StaticParentType<$S extends jni.JObject> + extends jni.JObjType> { + final jni.JObjType<$S> S; const $GrandParent_StaticParentType( - this.$S, + this.S, ); @override @@ -841,35 +1054,50 @@ class $GrandParent_StaticParentType r"Lcom/github/dart_lang/jnigen/generics/GrandParent$StaticParent;"; @override - GrandParent_StaticParent fromRef(jni.JObjectPtr ref) => - GrandParent_StaticParent.fromRef($S, ref); + GrandParent_StaticParent<$S> fromRef(jni.JObjectPtr ref) => + GrandParent_StaticParent.fromRef(S, ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => Object.hash($GrandParent_StaticParentType, S); + + @override + bool operator ==(Object other) { + return other.runtimeType == $GrandParent_StaticParentType && + other is $GrandParent_StaticParentType && + S == other.S; + } } /// from: com.github.dart_lang.jnigen.generics.GrandParent$StaticParent$Child -class GrandParent_StaticParent_Child extends jni.JObject { - late final jni.JObjType? _$type; +class GrandParent_StaticParent_Child<$S extends jni.JObject, + $U extends jni.JObject> extends jni.JObject { @override - jni.JObjType get $type => _$type ??= type($S, $U); + late final jni.JObjType $type = type(S, U); - final jni.JObjType $S; - final jni.JObjType $U; + final jni.JObjType<$S> S; + final jni.JObjType<$U> U; GrandParent_StaticParent_Child.fromRef( - this.$S, - this.$U, + this.S, + this.U, jni.JObjectPtr ref, ) : super.fromRef(ref); /// The type which includes information such as the signature of this class. - static $GrandParent_StaticParent_ChildType - type( - jni.JObjType $S, - jni.JObjType $U, + static $GrandParent_StaticParent_ChildType<$S, $U> + type<$S extends jni.JObject, $U extends jni.JObject>( + jni.JObjType<$S> S, + jni.JObjType<$U> U, ) { return $GrandParent_StaticParent_ChildType( - $S, - $U, + S, + U, ); } @@ -893,11 +1121,11 @@ class GrandParent_StaticParent_Child $S.fromRef(_get_parentValue(reference).object); + $S get parentValue => S.fromRef(_get_parentValue(reference).object); /// from: public S parentValue /// The returned object must be deleted after use, by calling the `delete` method. - set parentValue(S value) => _set_parentValue(reference, value.reference); + set parentValue($S value) => _set_parentValue(reference, value.reference); static final _get_value = jniLookup< ffi.NativeFunction< @@ -919,11 +1147,11 @@ class GrandParent_StaticParent_Child $U.fromRef(_get_value(reference).object); + $U get value => U.fromRef(_get_value(reference).object); /// from: public U value /// The returned object must be deleted after use, by calling the `delete` method. - set value(U value) => _set_value(reference, value.reference); + set value($U value) => _set_value(reference, value.reference); static final _ctor = jniLookup< ffi.NativeFunction< @@ -936,19 +1164,32 @@ class GrandParent_StaticParent_Child(S parentValue, U value) /// The returned object must be deleted after use, by calling the `delete` method. - GrandParent_StaticParent_Child(this.$S, this.$U, S parentValue, U value) - : super.fromRef(_ctor(parentValue.reference, value.reference).object); + factory GrandParent_StaticParent_Child( + $S parentValue, + $U value, { + jni.JObjType<$S>? S, + jni.JObjType<$U>? U, + }) { + S ??= jni.lowestCommonSuperType([ + parentValue.$type, + ]) as jni.JObjType<$S>; + U ??= jni.lowestCommonSuperType([ + value.$type, + ]) as jni.JObjType<$U>; + return GrandParent_StaticParent_Child.fromRef( + S, U, _ctor(parentValue.reference, value.reference).object); + } } -class $GrandParent_StaticParent_ChildType - extends jni.JObjType> { - final jni.JObjType $S; - final jni.JObjType $U; +class $GrandParent_StaticParent_ChildType<$S extends jni.JObject, + $U extends jni.JObject> + extends jni.JObjType> { + final jni.JObjType<$S> S; + final jni.JObjType<$U> U; const $GrandParent_StaticParent_ChildType( - this.$S, - this.$U, + this.S, + this.U, ); @override @@ -956,33 +1197,51 @@ class $GrandParent_StaticParent_ChildType fromRef(jni.JObjectPtr ref) => - GrandParent_StaticParent_Child.fromRef($S, $U, ref); + GrandParent_StaticParent_Child<$S, $U> fromRef(jni.JObjectPtr ref) => + GrandParent_StaticParent_Child.fromRef(S, U, ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => Object.hash($GrandParent_StaticParent_ChildType, S, U); + + @override + bool operator ==(Object other) { + return other.runtimeType == $GrandParent_StaticParent_ChildType && + other is $GrandParent_StaticParent_ChildType && + S == other.S && + U == other.U; + } } /// from: com.github.dart_lang.jnigen.generics.MyMap -class MyMap extends jni.JObject { - late final jni.JObjType? _$type; +class MyMap<$K extends jni.JObject, $V extends jni.JObject> + extends jni.JObject { @override - jni.JObjType get $type => _$type ??= type($K, $V); + late final jni.JObjType $type = type(K, V); - final jni.JObjType $K; - final jni.JObjType $V; + final jni.JObjType<$K> K; + final jni.JObjType<$V> V; MyMap.fromRef( - this.$K, - this.$V, + this.K, + this.V, jni.JObjectPtr ref, ) : super.fromRef(ref); /// The type which includes information such as the signature of this class. - static $MyMapType type( - jni.JObjType $K, - jni.JObjType $V, + static $MyMapType<$K, $V> + type<$K extends jni.JObject, $V extends jni.JObject>( + jni.JObjType<$K> K, + jni.JObjType<$V> V, ) { return $MyMapType( - $K, - $V, + K, + V, ); } @@ -992,7 +1251,12 @@ class MyMap extends jni.JObject { /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. - MyMap(this.$K, this.$V) : super.fromRef(_ctor().object); + factory MyMap({ + required jni.JObjType<$K> K, + required jni.JObjType<$V> V, + }) { + return MyMap.fromRef(K, V, _ctor().object); + } static final _get0 = jniLookup< ffi.NativeFunction< @@ -1004,7 +1268,11 @@ class MyMap extends jni.JObject { /// from: public V get(K key) /// The returned object must be deleted after use, by calling the `delete` method. - V get0(K key) => $V.fromRef(_get0(reference, key.reference).object); + $V get0( + $K key, + ) { + return V.fromRef(_get0(reference, key.reference).object); + } static final _put = jniLookup< ffi.NativeFunction< @@ -1016,8 +1284,12 @@ class MyMap extends jni.JObject { /// from: public V put(K key, V value) /// The returned object must be deleted after use, by calling the `delete` method. - V put(K key, V value) => - $V.fromRef(_put(reference, key.reference, value.reference).object); + $V put( + $K key, + $V value, + ) { + return V.fromRef(_put(reference, key.reference, value.reference).object); + } static final _entryStack = jniLookup< ffi.NativeFunction< @@ -1027,54 +1299,71 @@ class MyMap extends jni.JObject { /// from: public com.github.dart_lang.jnigen.generics.MyStack.MyEntry> entryStack() /// The returned object must be deleted after use, by calling the `delete` method. - MyStack> entryStack() => - const $MyStackType( - $MyMap_MyEntryType(jni.JObjectType(), jni.JObjectType())) - .fromRef(_entryStack(reference).object); + MyStack> entryStack() { + return const $MyStackType( + $MyMap_MyEntryType(jni.JObjectType(), jni.JObjectType())) + .fromRef(_entryStack(reference).object); + } } -class $MyMapType - extends jni.JObjType> { - final jni.JObjType $K; - final jni.JObjType $V; +class $MyMapType<$K extends jni.JObject, $V extends jni.JObject> + extends jni.JObjType> { + final jni.JObjType<$K> K; + final jni.JObjType<$V> V; const $MyMapType( - this.$K, - this.$V, + this.K, + this.V, ); @override String get signature => r"Lcom/github/dart_lang/jnigen/generics/MyMap;"; @override - MyMap fromRef(jni.JObjectPtr ref) => MyMap.fromRef($K, $V, ref); + MyMap<$K, $V> fromRef(jni.JObjectPtr ref) => MyMap.fromRef(K, V, ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => Object.hash($MyMapType, K, V); + + @override + bool operator ==(Object other) { + return other.runtimeType == $MyMapType && + other is $MyMapType && + K == other.K && + V == other.V; + } } /// from: com.github.dart_lang.jnigen.generics.MyMap$MyEntry -class MyMap_MyEntry +class MyMap_MyEntry<$K extends jni.JObject, $V extends jni.JObject> extends jni.JObject { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type($K, $V); + late final jni.JObjType $type = type(K, V); - final jni.JObjType $K; - final jni.JObjType $V; + final jni.JObjType<$K> K; + final jni.JObjType<$V> V; MyMap_MyEntry.fromRef( - this.$K, - this.$V, + this.K, + this.V, jni.JObjectPtr ref, ) : super.fromRef(ref); /// The type which includes information such as the signature of this class. - static $MyMap_MyEntryType - type( - jni.JObjType $K, - jni.JObjType $V, + static $MyMap_MyEntryType<$K, $V> + type<$K extends jni.JObject, $V extends jni.JObject>( + jni.JObjType<$K> K, + jni.JObjType<$V> V, ) { return $MyMap_MyEntryType( - $K, - $V, + K, + V, ); } @@ -1097,11 +1386,11 @@ class MyMap_MyEntry /// from: public K key /// The returned object must be deleted after use, by calling the `delete` method. - K get key => $K.fromRef(_get_key(reference).object); + $K get key => K.fromRef(_get_key(reference).object); /// from: public K key /// The returned object must be deleted after use, by calling the `delete` method. - set key(K value) => _set_key(reference, value.reference); + set key($K value) => _set_key(reference, value.reference); static final _get_value = jniLookup< ffi.NativeFunction< @@ -1122,11 +1411,11 @@ class MyMap_MyEntry /// from: public V value /// The returned object must be deleted after use, by calling the `delete` method. - V get value => $V.fromRef(_get_value(reference).object); + $V get value => V.fromRef(_get_value(reference).object); /// from: public V value /// The returned object must be deleted after use, by calling the `delete` method. - set value(V value) => _set_value(reference, value.reference); + set value($V value) => _set_value(reference, value.reference); static final _ctor = jniLookup< ffi.NativeFunction< @@ -1138,18 +1427,31 @@ class MyMap_MyEntry /// from: public void (K key, V value) /// The returned object must be deleted after use, by calling the `delete` method. - MyMap_MyEntry(this.$K, this.$V, K key, V value) - : super.fromRef(_ctor(key.reference, value.reference).object); + factory MyMap_MyEntry( + $K key, + $V value, { + jni.JObjType<$K>? K, + jni.JObjType<$V>? V, + }) { + K ??= jni.lowestCommonSuperType([ + key.$type, + ]) as jni.JObjType<$K>; + V ??= jni.lowestCommonSuperType([ + value.$type, + ]) as jni.JObjType<$V>; + return MyMap_MyEntry.fromRef( + K, V, _ctor(key.reference, value.reference).object); + } } -class $MyMap_MyEntryType - extends jni.JObjType> { - final jni.JObjType $K; - final jni.JObjType $V; +class $MyMap_MyEntryType<$K extends jni.JObject, $V extends jni.JObject> + extends jni.JObjType> { + final jni.JObjType<$K> K; + final jni.JObjType<$V> V; const $MyMap_MyEntryType( - this.$K, - this.$V, + this.K, + this.V, ); @override @@ -1157,29 +1459,45 @@ class $MyMap_MyEntryType r"Lcom/github/dart_lang/jnigen/generics/MyMap$MyEntry;"; @override - MyMap_MyEntry fromRef(jni.JObjectPtr ref) => - MyMap_MyEntry.fromRef($K, $V, ref); + MyMap_MyEntry<$K, $V> fromRef(jni.JObjectPtr ref) => + MyMap_MyEntry.fromRef(K, V, ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => Object.hash($MyMap_MyEntryType, K, V); + + @override + bool operator ==(Object other) { + return other.runtimeType == $MyMap_MyEntryType && + other is $MyMap_MyEntryType && + K == other.K && + V == other.V; + } } /// from: com.github.dart_lang.jnigen.generics.MyStack -class MyStack extends jni.JObject { - late final jni.JObjType? _$type; +class MyStack<$T extends jni.JObject> extends jni.JObject { @override - jni.JObjType get $type => _$type ??= type($T); + late final jni.JObjType $type = type(T); - final jni.JObjType $T; + final jni.JObjType<$T> T; MyStack.fromRef( - this.$T, + this.T, jni.JObjectPtr ref, ) : super.fromRef(ref); /// The type which includes information such as the signature of this class. - static $MyStackType type( - jni.JObjType $T, + static $MyStackType<$T> type<$T extends jni.JObject>( + jni.JObjType<$T> T, ) { return $MyStackType( - $T, + T, ); } @@ -1189,7 +1507,102 @@ class MyStack extends jni.JObject { /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. - MyStack(this.$T) : super.fromRef(_ctor().object); + factory MyStack({ + required jni.JObjType<$T> T, + }) { + return MyStack.fromRef(T, _ctor().object); + } + + static final _fromArray = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("MyStack__fromArray") + .asFunction)>(); + + /// from: static public com.github.dart_lang.jnigen.generics.MyStack fromArray(T[] arr) + /// The returned object must be deleted after use, by calling the `delete` method. + static MyStack<$T> fromArray<$T extends jni.JObject>( + jni.JArray<$T> arr, { + jni.JObjType<$T>? T, + }) { + T ??= jni.lowestCommonSuperType([ + ((arr.$type as jni.JArrayType).elementType as jni.JObjType), + ]) as jni.JObjType<$T>; + return $MyStackType(T).fromRef(_fromArray(arr.reference).object); + } + + static final _fromArrayOfArrayOfGrandParents = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>( + "MyStack__fromArrayOfArrayOfGrandParents") + .asFunction)>(); + + /// from: static public com.github.dart_lang.jnigen.generics.MyStack fromArrayOfArrayOfGrandParents(com.github.dart_lang.jnigen.generics.GrandParent[][] arr) + /// The returned object must be deleted after use, by calling the `delete` method. + static MyStack<$S> fromArrayOfArrayOfGrandParents<$S extends jni.JObject>( + jni.JArray>> arr, { + jni.JObjType<$S>? S, + }) { + S ??= jni.lowestCommonSuperType([ + (((((arr.$type as jni.JArrayType).elementType as jni.JObjType) + as jni.JArrayType) + .elementType as jni.JObjType) as $GrandParentType) + .T, + ]) as jni.JObjType<$S>; + return $MyStackType(S) + .fromRef(_fromArrayOfArrayOfGrandParents(arr.reference).object); + } + + static final _of = + jniLookup>("MyStack__of") + .asFunction(); + + /// from: static public com.github.dart_lang.jnigen.generics.MyStack of() + /// The returned object must be deleted after use, by calling the `delete` method. + static MyStack<$T> of<$T extends jni.JObject>({ + required jni.JObjType<$T> T, + }) { + return $MyStackType(T).fromRef(_of().object); + } + + static final _of1 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>("MyStack__of1") + .asFunction)>(); + + /// from: static public com.github.dart_lang.jnigen.generics.MyStack of(T obj) + /// The returned object must be deleted after use, by calling the `delete` method. + static MyStack<$T> of1<$T extends jni.JObject>( + $T obj, { + jni.JObjType<$T>? T, + }) { + T ??= jni.lowestCommonSuperType([ + obj.$type, + ]) as jni.JObjType<$T>; + return $MyStackType(T).fromRef(_of1(obj.reference).object); + } + + static final _of2 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("MyStack__of2") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: static public com.github.dart_lang.jnigen.generics.MyStack of(T obj, T obj2) + /// The returned object must be deleted after use, by calling the `delete` method. + static MyStack<$T> of2<$T extends jni.JObject>( + $T obj, + $T obj2, { + jni.JObjType<$T>? T, + }) { + T ??= jni.lowestCommonSuperType([ + obj2.$type, + obj.$type, + ]) as jni.JObjType<$T>; + return $MyStackType(T).fromRef(_of2(obj.reference, obj2.reference).object); + } static final _push = jniLookup< ffi.NativeFunction< @@ -1200,7 +1613,11 @@ class MyStack extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public void push(T item) - void push(T item) => _push(reference, item.reference).check(); + void push( + $T item, + ) { + return _push(reference, item.reference).check(); + } static final _pop = jniLookup< ffi.NativeFunction< @@ -1209,42 +1626,69 @@ class MyStack extends jni.JObject { /// from: public T pop() /// The returned object must be deleted after use, by calling the `delete` method. - T pop() => $T.fromRef(_pop(reference).object); + $T pop() { + return T.fromRef(_pop(reference).object); + } + + static final _size = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>("MyStack__size") + .asFunction)>(); + + /// from: public int size() + int size() { + return _size(reference).integer; + } } -class $MyStackType extends jni.JObjType> { - final jni.JObjType $T; +class $MyStackType<$T extends jni.JObject> extends jni.JObjType> { + final jni.JObjType<$T> T; const $MyStackType( - this.$T, + this.T, ); @override String get signature => r"Lcom/github/dart_lang/jnigen/generics/MyStack;"; @override - MyStack fromRef(jni.JObjectPtr ref) => MyStack.fromRef($T, ref); + MyStack<$T> fromRef(jni.JObjectPtr ref) => MyStack.fromRef(T, ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => Object.hash($MyStackType, T); + + @override + bool operator ==(Object other) { + return other.runtimeType == $MyStackType && + other is $MyStackType && + T == other.T; + } } /// from: com.github.dart_lang.jnigen.generics.StringKeyedMap -class StringKeyedMap extends MyMap { - late final jni.JObjType? _$type; +class StringKeyedMap<$V extends jni.JObject> extends MyMap { @override - jni.JObjType get $type => _$type ??= type($V); + late final jni.JObjType $type = type(V); - final jni.JObjType $V; + final jni.JObjType<$V> V; StringKeyedMap.fromRef( - this.$V, + this.V, jni.JObjectPtr ref, - ) : super.fromRef(const jni.JStringType(), $V, ref); + ) : super.fromRef(const jni.JStringType(), V, ref); /// The type which includes information such as the signature of this class. - static $StringKeyedMapType type( - jni.JObjType $V, + static $StringKeyedMapType<$V> type<$V extends jni.JObject>( + jni.JObjType<$V> V, ) { return $StringKeyedMapType( - $V, + V, ); } @@ -1254,16 +1698,19 @@ class StringKeyedMap extends MyMap { /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. - StringKeyedMap(this.$V) - : super.fromRef(const jni.JStringType(), $V, _ctor().object); + factory StringKeyedMap({ + required jni.JObjType<$V> V, + }) { + return StringKeyedMap.fromRef(V, _ctor().object); + } } -class $StringKeyedMapType - extends jni.JObjType> { - final jni.JObjType $V; +class $StringKeyedMapType<$V extends jni.JObject> + extends jni.JObjType> { + final jni.JObjType<$V> V; const $StringKeyedMapType( - this.$V, + this.V, ); @override @@ -1271,15 +1718,76 @@ class $StringKeyedMapType r"Lcom/github/dart_lang/jnigen/generics/StringKeyedMap;"; @override - StringKeyedMap fromRef(jni.JObjectPtr ref) => - StringKeyedMap.fromRef($V, ref); + StringKeyedMap<$V> fromRef(jni.JObjectPtr ref) => + StringKeyedMap.fromRef(V, ref); + + @override + jni.JObjType get superType => $MyMapType(const jni.JStringType(), V); + + @override + final superCount = 2; + + @override + int get hashCode => Object.hash($StringKeyedMapType, V); + + @override + bool operator ==(Object other) { + return other.runtimeType == $StringKeyedMapType && + other is $StringKeyedMapType && + V == other.V; + } +} + +/// from: com.github.dart_lang.jnigen.generics.StringMap +class StringMap extends StringKeyedMap { + @override + late final jni.JObjType $type = type; + + StringMap.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(const jni.JStringType(), ref); + + /// The type which includes information such as the signature of this class. + static const type = $StringMapType(); + static final _ctor = + jniLookup>("StringMap__ctor") + .asFunction(); + + /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. + factory StringMap() { + return StringMap.fromRef(_ctor().object); + } +} + +class $StringMapType extends jni.JObjType { + const $StringMapType(); + + @override + String get signature => r"Lcom/github/dart_lang/jnigen/generics/StringMap;"; + + @override + StringMap fromRef(jni.JObjectPtr ref) => StringMap.fromRef(ref); + + @override + jni.JObjType get superType => const $StringKeyedMapType(jni.JStringType()); + + @override + final superCount = 3; + + @override + int get hashCode => ($StringMapType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $StringMapType && other is $StringMapType; + } } /// from: com.github.dart_lang.jnigen.generics.StringStack class StringStack extends MyStack { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type; + late final jni.JObjType $type = type; StringStack.fromRef( jni.JObjectPtr ref, @@ -1293,7 +1801,9 @@ class StringStack extends MyStack { /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. - StringStack() : super.fromRef(const jni.JStringType(), _ctor().object); + factory StringStack() { + return StringStack.fromRef(_ctor().object); + } } class $StringStackType extends jni.JObjType { @@ -1304,27 +1814,40 @@ class $StringStackType extends jni.JObjType { @override StringStack fromRef(jni.JObjectPtr ref) => StringStack.fromRef(ref); + + @override + jni.JObjType get superType => const $MyStackType(jni.JStringType()); + + @override + final superCount = 2; + + @override + int get hashCode => ($StringStackType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $StringStackType && other is $StringStackType; + } } /// from: com.github.dart_lang.jnigen.generics.StringValuedMap -class StringValuedMap extends MyMap { - late final jni.JObjType? _$type; +class StringValuedMap<$K extends jni.JObject> extends MyMap<$K, jni.JString> { @override - jni.JObjType get $type => _$type ??= type($K); + late final jni.JObjType $type = type(K); - final jni.JObjType $K; + final jni.JObjType<$K> K; StringValuedMap.fromRef( - this.$K, + this.K, jni.JObjectPtr ref, - ) : super.fromRef($K, const jni.JStringType(), ref); + ) : super.fromRef(K, const jni.JStringType(), ref); /// The type which includes information such as the signature of this class. - static $StringValuedMapType type( - jni.JObjType $K, + static $StringValuedMapType<$K> type<$K extends jni.JObject>( + jni.JObjType<$K> K, ) { return $StringValuedMapType( - $K, + K, ); } @@ -1334,16 +1857,19 @@ class StringValuedMap extends MyMap { /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. - StringValuedMap(this.$K) - : super.fromRef($K, const jni.JStringType(), _ctor().object); + factory StringValuedMap({ + required jni.JObjType<$K> K, + }) { + return StringValuedMap.fromRef(K, _ctor().object); + } } -class $StringValuedMapType - extends jni.JObjType> { - final jni.JObjType $K; +class $StringValuedMapType<$K extends jni.JObject> + extends jni.JObjType> { + final jni.JObjType<$K> K; const $StringValuedMapType( - this.$K, + this.K, ); @override @@ -1351,15 +1877,30 @@ class $StringValuedMapType r"Lcom/github/dart_lang/jnigen/generics/StringValuedMap;"; @override - StringValuedMap fromRef(jni.JObjectPtr ref) => - StringValuedMap.fromRef($K, ref); + StringValuedMap<$K> fromRef(jni.JObjectPtr ref) => + StringValuedMap.fromRef(K, ref); + + @override + jni.JObjType get superType => $MyMapType(K, const jni.JStringType()); + + @override + final superCount = 2; + + @override + int get hashCode => Object.hash($StringValuedMapType, K); + + @override + bool operator ==(Object other) { + return other.runtimeType == $StringValuedMapType && + other is $StringValuedMapType && + K == other.K; + } } /// from: com.github.dart_lang.jnigen.annotations.JsonSerializable$Case class JsonSerializable_Case extends jni.JObject { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type; + late final jni.JObjType $type = type; JsonSerializable_Case.fromRef( jni.JObjectPtr ref, @@ -1374,9 +1915,10 @@ class JsonSerializable_Case extends jni.JObject { /// from: static public com.github.dart_lang.jnigen.annotations.JsonSerializable.Case[] values() /// The returned object must be deleted after use, by calling the `delete` method. - static jni.JArray values() => - const jni.JArrayType($JsonSerializable_CaseType()) - .fromRef(_values().object); + static jni.JArray values() { + return const jni.JArrayType($JsonSerializable_CaseType()) + .fromRef(_values().object); + } static final _valueOf = jniLookup< ffi.NativeFunction< @@ -1386,9 +1928,12 @@ class JsonSerializable_Case extends jni.JObject { /// from: static public com.github.dart_lang.jnigen.annotations.JsonSerializable.Case valueOf(java.lang.String name) /// The returned object must be deleted after use, by calling the `delete` method. - static JsonSerializable_Case valueOf(jni.JString name) => - const $JsonSerializable_CaseType() - .fromRef(_valueOf(name.reference).object); + static JsonSerializable_Case valueOf( + jni.JString name, + ) { + return const $JsonSerializable_CaseType() + .fromRef(_valueOf(name.reference).object); + } } class $JsonSerializable_CaseType extends jni.JObjType { @@ -1401,13 +1946,27 @@ class $JsonSerializable_CaseType extends jni.JObjType { @override JsonSerializable_Case fromRef(jni.JObjectPtr ref) => JsonSerializable_Case.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($JsonSerializable_CaseType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $JsonSerializable_CaseType && + other is $JsonSerializable_CaseType; + } } /// from: com.github.dart_lang.jnigen.annotations.MyDataClass class MyDataClass extends jni.JObject { - late final jni.JObjType? _$type; @override - jni.JObjType get $type => _$type ??= type; + late final jni.JObjType $type = type; MyDataClass.fromRef( jni.JObjectPtr ref, @@ -1421,7 +1980,9 @@ class MyDataClass extends jni.JObject { /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. - MyDataClass() : super.fromRef(_ctor().object); + factory MyDataClass() { + return MyDataClass.fromRef(_ctor().object); + } } class $MyDataClassType extends jni.JObjType { @@ -1433,4 +1994,18 @@ class $MyDataClassType extends jni.JObjType { @override MyDataClass fromRef(jni.JObjectPtr ref) => MyDataClass.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($MyDataClassType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $MyDataClassType && other is $MyDataClassType; + } } diff --git a/pkgs/jnigen/test/simple_package_test/src/simple_package.c b/pkgs/jnigen/test/simple_package_test/src/simple_package.c index e5937df54..0e85ae93a 100644 --- a/pkgs/jnigen/test/simple_package_test/src/simple_package.c +++ b/pkgs/jnigen/test/simple_package_test/src/simple_package.c @@ -1102,6 +1102,97 @@ JniResult MyStack__ctor() { .exception = check_exception()}; } +jmethodID _m_MyStack__fromArray = NULL; +FFI_PLUGIN_EXPORT +JniResult MyStack__fromArray(jobject arr) { + load_env(); + load_class_gr(&_c_MyStack, "com/github/dart_lang/jnigen/generics/MyStack"); + if (_c_MyStack == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_static_method( + _c_MyStack, &_m_MyStack__fromArray, "fromArray", + "([Ljava/lang/Object;)Lcom/github/dart_lang/jnigen/generics/MyStack;"); + if (_m_MyStack__fromArray == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallStaticObjectMethod( + jniEnv, _c_MyStack, _m_MyStack__fromArray, arr); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID _m_MyStack__fromArrayOfArrayOfGrandParents = NULL; +FFI_PLUGIN_EXPORT +JniResult MyStack__fromArrayOfArrayOfGrandParents(jobject arr) { + load_env(); + load_class_gr(&_c_MyStack, "com/github/dart_lang/jnigen/generics/MyStack"); + if (_c_MyStack == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_static_method( + _c_MyStack, &_m_MyStack__fromArrayOfArrayOfGrandParents, + "fromArrayOfArrayOfGrandParents", + "([[Lcom/github/dart_lang/jnigen/generics/GrandParent;)Lcom/github/" + "dart_lang/jnigen/generics/MyStack;"); + if (_m_MyStack__fromArrayOfArrayOfGrandParents == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallStaticObjectMethod( + jniEnv, _c_MyStack, _m_MyStack__fromArrayOfArrayOfGrandParents, arr); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID _m_MyStack__of = NULL; +FFI_PLUGIN_EXPORT +JniResult MyStack__of() { + load_env(); + load_class_gr(&_c_MyStack, "com/github/dart_lang/jnigen/generics/MyStack"); + if (_c_MyStack == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_MyStack, &_m_MyStack__of, "of", + "()Lcom/github/dart_lang/jnigen/generics/MyStack;"); + if (_m_MyStack__of == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_MyStack, _m_MyStack__of); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID _m_MyStack__of1 = NULL; +FFI_PLUGIN_EXPORT +JniResult MyStack__of1(jobject obj) { + load_env(); + load_class_gr(&_c_MyStack, "com/github/dart_lang/jnigen/generics/MyStack"); + if (_c_MyStack == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_static_method( + _c_MyStack, &_m_MyStack__of1, "of", + "(Ljava/lang/Object;)Lcom/github/dart_lang/jnigen/generics/MyStack;"); + if (_m_MyStack__of1 == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_MyStack, + _m_MyStack__of1, obj); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + +jmethodID _m_MyStack__of2 = NULL; +FFI_PLUGIN_EXPORT +JniResult MyStack__of2(jobject obj, jobject obj2) { + load_env(); + load_class_gr(&_c_MyStack, "com/github/dart_lang/jnigen/generics/MyStack"); + if (_c_MyStack == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_MyStack, &_m_MyStack__of2, "of", + "(Ljava/lang/Object;Ljava/lang/Object;)Lcom/github/" + "dart_lang/jnigen/generics/MyStack;"); + if (_m_MyStack__of2 == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallStaticObjectMethod( + jniEnv, _c_MyStack, _m_MyStack__of2, obj, obj2); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + jmethodID _m_MyStack__push = NULL; FFI_PLUGIN_EXPORT JniResult MyStack__push(jobject self_, jobject item) { @@ -1131,6 +1222,20 @@ JniResult MyStack__pop(jobject self_) { .exception = check_exception()}; } +jmethodID _m_MyStack__size = NULL; +FFI_PLUGIN_EXPORT +JniResult MyStack__size(jobject self_) { + load_env(); + load_class_gr(&_c_MyStack, "com/github/dart_lang/jnigen/generics/MyStack"); + if (_c_MyStack == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_MyStack, &_m_MyStack__size, "size", "()I"); + if (_m_MyStack__size == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_MyStack__size); + return (JniResult){.result = {.i = _result}, .exception = check_exception()}; +} + // com.github.dart_lang.jnigen.generics.StringKeyedMap jclass _c_StringKeyedMap = NULL; @@ -1151,6 +1256,26 @@ JniResult StringKeyedMap__ctor() { .exception = check_exception()}; } +// com.github.dart_lang.jnigen.generics.StringMap +jclass _c_StringMap = NULL; + +jmethodID _m_StringMap__ctor = NULL; +FFI_PLUGIN_EXPORT +JniResult StringMap__ctor() { + load_env(); + load_class_gr(&_c_StringMap, + "com/github/dart_lang/jnigen/generics/StringMap"); + if (_c_StringMap == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + load_method(_c_StringMap, &_m_StringMap__ctor, "", "()V"); + if (_m_StringMap__ctor == NULL) + return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->NewObject(jniEnv, _c_StringMap, _m_StringMap__ctor); + return (JniResult){.result = {.l = to_global_ref(_result)}, + .exception = check_exception()}; +} + // com.github.dart_lang.jnigen.generics.StringStack jclass _c_StringStack = NULL; From d21b6729ccd2b40b42c468bf8d1dd21da0250247 Mon Sep 17 00:00:00 2001 From: Mahesh Hegde <46179734+mahesh-hegde@users.noreply.github.com> Date: Wed, 12 Apr 2023 19:50:14 +0530 Subject: [PATCH 074/139] [jnigen] (An attempt to) Improve CI workflows (https://github.com/dart-lang/jnigen/issues/222) * Move google-java-format to analyze actions * Remove separate job for running java tests * Reformat YAML to use single quotes * Does removing yaml_config test affect coverage? --- .github/workflows/test-package.yml | 40 +++++++++----------------- pkgs/jnigen/test/yaml_config_test.dart | 30 ------------------- 2 files changed, 14 insertions(+), 56 deletions(-) delete mode 100644 pkgs/jnigen/test/yaml_config_test.dart diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 92f5fd3cb..a4f17bc37 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -12,24 +12,16 @@ name: Dart CI on: # Run on PRs and pushes to the default branch. push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] schedule: - - cron: "0 0 * * 0" + - cron: '0 0 * * 0' env: PUB_ENVIRONMENT: bot.github jobs: - check_java_format: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v2 minimum required - - uses: axel-op/googlejavaformat-action@fe78db8a90171b6a836449f8d0e982d5d71e5c5a - with: - args: "--set-exit-if-changed" - analyze_jnigen: runs-on: ubuntu-latest defaults: @@ -46,6 +38,10 @@ jobs: channel: ${{ matrix.sdk }} cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' + - uses: axel-op/googlejavaformat-action@fe78db8a90171b6a836449f8d0e982d5d71e5c5a + name: 'Check Java formatting with google-java-format' + with: + args: '--set-exit-if-changed' - id: install name: Install dependencies run: dart pub get @@ -93,6 +89,9 @@ jobs: - name: build notification_plugin example APK run: flutter build apk --target-platform=android-arm64 working-directory: ./pkgs/jnigen/example/notification_plugin/example + - name: Run summarizer tests + run: mvn surefire:test + working-directory: ./pkgs/jnigen/java - name: Run VM tests run: dart test --platform vm - name: Install coverage @@ -108,20 +107,6 @@ jobs: path-to-lcov: ./pkgs/jnigen/coverage/lcov.info if: ${{ matrix.sdk == 'stable' }} - test_summarizer: - runs-on: ubuntu-latest - defaults: - run: - working-directory: ./pkgs/jnigen/java - steps: - - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - - uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 - with: - distribution: 'zulu' - java-version: '11' - - name: run tests using maven surefire - run: mvn surefire:test - analyze_jni: runs-on: ubuntu-latest defaults: @@ -138,6 +123,10 @@ jobs: with: distribution: 'zulu' java-version: '11' + - uses: axel-op/googlejavaformat-action@fe78db8a90171b6a836449f8d0e982d5d71e5c5a + name: 'Check Java formatting with google-java-format' + with: + args: '--set-exit-if-changed' - name: install clang tools & CMake run: | sudo apt-get update -y @@ -155,7 +144,6 @@ jobs: dart run tool/generate_ide_files.dart ls src/compile_commands.json - test_jni: runs-on: ubuntu-latest needs: [analyze_jni] diff --git a/pkgs/jnigen/test/yaml_config_test.dart b/pkgs/jnigen/test/yaml_config_test.dart deleted file mode 100644 index e995b6ac2..000000000 --- a/pkgs/jnigen/test/yaml_config_test.dart +++ /dev/null @@ -1,30 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -// End-to-end test confirming yaml config works as expected. - -import 'package:jnigen/jnigen.dart'; -import 'package:path/path.dart' hide equals; -import 'package:test/test.dart'; - -import 'test_util/test_util.dart'; - -void main() { - final thirdParty = join('test', 'jackson_core_test', 'third_party'); - final testLib = join(thirdParty, 'test_lib_yaml'); - final testSrc = join(thirdParty, 'test_src_yaml'); - final lib = join(thirdParty, 'lib'); - final src = join(thirdParty, 'src'); - final configFile = join('test', 'jackson_core_test', 'jnigen.yaml'); - test('generate and compare bindings using YAML config', () async { - final args = [ - '--config', - configFile, - '-Doutput.c.path=$testSrc/', - '-Doutput.dart.path=$testLib/', - ]; - final config = Config.parseArgs(args); - await generateAndCompareBindings(config, lib, src); - }, timeout: const Timeout.factor(4)); -} From e279dd5ae43e7effd54d449a6e07dff0032dedfc Mon Sep 17 00:00:00 2001 From: Mahesh Hegde <46179734+mahesh-hegde@users.noreply.github.com> Date: Wed, 12 Apr 2023 19:51:04 +0530 Subject: [PATCH 075/139] [jnigen] Make README more approachable. (https://github.com/dart-lang/jnigen/issues/235) --- pkgs/jnigen/README.md | 86 +++++++++++++++++++++++++------------------ 1 file changed, 51 insertions(+), 35 deletions(-) diff --git a/pkgs/jnigen/README.md b/pkgs/jnigen/README.md index 94a085563..66daa53ce 100644 --- a/pkgs/jnigen/README.md +++ b/pkgs/jnigen/README.md @@ -4,10 +4,26 @@ ## Introduction Experimental bindings generator for Java bindings through dart:ffi and JNI. -It generates C and Dart bindings which enable calling Java libraries from Dart. C bindings call the Java code through JNI, Dart bindings in turn call these C bindings through FFI. +`jnigen` scans compiled JAR files or Java source code to generate a description of the API, then uses it to generate Dart annd C bindings. The Dart bindings call the C bindings, which in-turn call the Java functions through JNI. Shared functionality and base classes are provided through the support library, `package:jni`. + +The configuration for binding generation is usually provided through YAML. + +Three configuration details are needed to generate the bindings. Everything else is optional: + +* _Inputs_: input can be Java source files (`source_path`), or compiled classes / JARs (`class_path`). Some maven / gradle based tooling is also provided to simplify obtaining dependencies. + +* _Outputs_: Output can be generated in package-structured (one file per class) or single file bindings. Target path to write C and Dart bindings needs to be specified. + +* _Classes_: Specify which classes or packages you need bindings for. Specifying a package includes all classes inside it recursively. + +Check out the [examples](jnigen/example/) to see some sample configurations. + +C code is always generated into a directory with it's own build configuration. It's built as a separate dynamic library. + +Lastly, [dart_only bindings](#pure-dart-bindings) mode is also available as a proof-of-concept. It does not need intermediate C bindings, only a dependency on the support library `package:jni`. ## Example -It's possible to generate bindings for libraries, or any Java source files. +It's possible to generate bindings for JAR libraries, or Java source files. Here's a simple example Java file, in a Flutter Android app. @@ -29,7 +45,10 @@ public abstract class AndroidUtils { } ``` -This produces the following Dart bindings: +This produces the following boilerplate: + +#### Dart Bindings: + ```dart /// Some boilerplate is omitted for clarity. final ffi.Pointer Function(String sym) jniLookup = @@ -54,6 +73,8 @@ class AndroidUtils extends jni.JObject { } ``` +#### C Bindings: + ```c // Some boilerplate is omitted for clarity. @@ -100,9 +121,7 @@ classes: - 'com.example.in_app_java.AndroidUtils' ``` -The complete example can be found in [jnigen/example/in_app_java](jnigen/example/in_app_java). The complete example adds one more class to the configuration to demonstrate using JAR files instead of sources. - -More examples can be found in [jnigen/example/](jnigen/example/). +The complete example can be found in [jnigen/example/in_app_java](jnigen/example/in_app_java), which adds few more classes to demonstrate using classes from gradle JAR and source dependencies. ## Supported platforms | Platform | Dart Standalone | Flutter | @@ -114,35 +133,12 @@ More examples can be found in [jnigen/example/](jnigen/example/). On Android, the flutter application runs embedded in Android JVM. On other platforms, a JVM needs to be explicitly spawned using `Jni.spawn`. `package:jni` provides the infrastructure for initializing and managing the JNI on both Android and Non-Android platforms. -## `package:jnigen` and `package:jni` -This repository contains two packages: `package:jni` (support library) and `package:jnigen` (code generator). - -`package:jnigen` generates C bindings which call Java methods through JNI, and Dart bindings which call these C wrappers through FFI. - -The generated code relies on common infrastructure provided by `package:jni` support library. - -For building a description of Java API, `jnigen` needs complete source code or JAR files of the corresponding library. `jnigen` can use either complete sources or compiled classes from JAR files to build this API description. These are to be provided in the configuration as `class_path` and `source_path` respectively. - -It's possible to generate Java code mirroring source layout with each class having a separate dart file, or all classes into a same dart file. - -C code is always generated into a directory with it's own build configuration. It's built as a separate dynamic library. - -As a proof-of-concept, [pure dart bindings](#pure-dart-bindings) which do not require C code (apart from `package:jni` dependency) are supported. - -## Usage -There are 2 ways to use `jnigen`: - -* Run as command line tool with a YAML config. -* Import `package:jnigen/jnigen.dart` from a script in `tool/` directory of your project. - -Both approaches are almost identical. When using YAML, it's possible to selectively override configuration properties with command line, using `-Dproperty_name=value` syntax. We usually use YAML in our [examples](jnigen/example/). See the [YAML Reference](#yaml-configuration-reference) at the end of this document for a tabular description of configuration properties. - ## Java features support Currently basic features of the Java language are supported in the bindings. Each Java class is mapped to a Dart class. Bindings are generated for methods, constructors and fields. Exceptions thrown in Java are rethrown in Dart with stack trace from Java. -More advanced features are not supported yet. Support for these features is tracked in the [issue tracker](https://github.com/dart-lang/jnigen/issues). +More advanced features such as callbacks are not supported yet. Support for these features is tracked in the [issue tracker](https://github.com/dart-lang/jnigen/issues). -### Note on Dart (standalone) target +## Note on Dart (standalone) target `package:jni` is an FFI plugin containing native code, and any bindings generated from jnigen contains native code too. On Flutter targets, native libraries are built automatically and bundled. On standalone platforms, no such infrastructure exists yet. As a stopgap solution, running `dart run jni:setup` in a target directory builds all JNI native dependencies of the package into `build/jni_libs`. @@ -168,15 +164,32 @@ For example, on Powershell: $env:Path += ";${env:JAVA_HOME}\bin\server". ``` -(If JAVA_HOME not set, find the `java.exe` executable and set the environment variable in Control Panel). If java is installed through a package manager, there may be a more automatic way to do this. (Eg: `scoop reset`). +If JAVA_HOME not set, find the `java.exe` executable and set the environment variable in Control Panel. If java is installed through a package manager, there may be a more automatic way to do this. (Eg: `scoop reset`). ### C/C++ tooling CMake and a standard C toolchain are required to build `package:jni` and C bindings generated by `jnigen`. It's recommended to have `clang-format` installed for formatting the generated C bindings. On Windows, it's part of LLVM installation. On most Linux distributions it is available as a separate package. On MacOS, it can be installed using Homebrew. -## Contributing -See the wiki for architecture-related documents. +## FAQs + +#### I am getting ClassNotFoundError at runtime. +`jnigen` does not handle getting the classes into application. It has to be done by target-specific mechanism. Such as adding a gradle dependency on Android, or manually providing classpath to `Jni.spawn` on desktop / standalone targets. + +On Android, `proguard` prunes classes which it deems inaccessible. Since JNI class lookup happens in runtime, this leads to ClassNotFound errors in release mode even if the dependency is included in gradle. [in_app_java example](jnigen/example/in_app_java/) discusses two mechanisms to prevent this: using `Keep` annotation (`androidx.annotation.Keep`) for the code written in the application itself, and [proguard-rules file](jnigen/example/in_app_java/android/app/proguard-rules.pro) for external libraries. + +Lastly, some libraries such as `java.awt` do not exist in android. Attempting to use libraries which depend on them can also lead to ClassNotFound errors. + +#### `jnigen` is not finding classes. +Ensure you are providing correct source and class paths, and they follow standard directory structure. If your class name is `com.abc.MyClass`, `MyClass` must be in `com/abc/MyClass.java` relative to one of the source paths, or `com/abc/MyClass.class` relative to one of the class paths specified in YAML. + +If the classes are in JAR file, make sure to provide path to JAR file itself, and not the containing directory. + +#### `jnigen` is unable to parse sources. +If the errors are similar to `symbol not found`, ensure all dependencies of the source are available. If such dependency is compiled, it can be included in `class_path`. + +#### Should I use `jnigen` over Method channels? +This is currently an experimental package. Many features are missing, and it's rough around the edges. You're welcome to try it and give feedback. ## YAML Configuration Reference Keys ending with a colon (`:`) denote subsections. @@ -209,7 +222,7 @@ A `*` denotes required configuration. | `output:` >> `dart:` >> `path` * | Directory path or File path | Path to write Dart bindings. Should end in `.dart` for `single_file` configurations, and end in `/` for `package_structure` (default) configuration. | | `maven_downloads:` | (Subsection) | This subsection will contain configuration for automatically downloading Java dependencies (source and JAR) through maven. | | `maven_downloads:` >> `source_deps` | List of maven package coordinates | Source packages to download and unpack using maven. The names should be valid maven artifact coordinates. (Eg: `org.apache.pdfbox:pdfbox:2.0.26`). The downloads do not include transitive dependencies. | -| `maven_downloads"` >> `source_dir` | Path | Directory in which maven sources are extracted. Defaults to `mvn_java`. It's not required to list this explicitly in source_path. | +| `maven_downloads:` >> `source_dir` | Path | Directory in which maven sources are extracted. Defaults to `mvn_java`. It's not required to list this explicitly in source_path. | | `maven_downloads:` >> `jar_only_deps` | List of maven package coordinates | JAR dependencies to download which are not mandatory transitive dependencies of `source_deps`. Often, it's required to find and include optional dependencies so that entire source is valid for further processing. | | `maven_downloads:` >> `jar_dir` | Path | Directory to store downloaded JARs. Defaults to `mvn_jar`. | | `log_level` | Logging level | Configure logging level. Defaults to `info`. | @@ -256,3 +269,6 @@ However there are 2 caveats to this caveat. The JAR files (`$SDK_ROOT/platforms/android-$VERSION/android.jar`) can be used instead. But compiled JARs do not include JavaDoc and method parameter names. This JAR is automatically included by Gradle when `android_sdk_config` >> `add_gradle_deps` is specified. +## Contributing +See the wiki for architecture-related documents. + From 215832ae5565249a223fdca46738f7bdb817fcb7 Mon Sep 17 00:00:00 2001 From: Mahesh Hegde <46179734+mahesh-hegde@users.noreply.github.com> Date: Tue, 18 Apr 2023 21:11:06 +0530 Subject: [PATCH 076/139] [jnigen] Remove FFI patch and use mutex around method/field lookups (https://github.com/dart-lang/jnigen/issues/246) * Add pubspec.lock from JNI example to git. This file should be checked in. * Remove ffi patch and instead depend on the internals of a pinned package:ffi version (closes https://github.com/dart-lang/jnigen/issues/149) * Add new tests on GlobalJniEnv * Rename findJniClass -> findJClass * Locking around method/field lookups. (closes https://github.com/dart-lang/jnigen/issues/85) * Rename asJString and asDartString to toJStringPtr and toDartString for uniform naming * Rename JniClass -> JClass * Compare bindings normally and fallback to ignoring spaces --- .github/workflows/test-package.yml | 6 +- pkgs/jni/.gitignore | 2 + .../integration_test/on_device_jni_test.dart | 132 +- pkgs/jni/example/lib/main.dart | 8 +- pkgs/jni/example/pubspec.lock | 523 +++ pkgs/jni/example/pubspec.yaml | 4 +- pkgs/jni/ffigen.yaml | 25 +- pkgs/jni/ffigen_exts.yaml | 16 + pkgs/jni/lib/jni.dart | 2 +- pkgs/jni/lib/src/accessors.dart | 42 +- pkgs/jni/lib/src/jexceptions.dart | 19 +- pkgs/jni/lib/src/jni.dart | 36 +- pkgs/jni/lib/src/jobject.dart | 33 +- pkgs/jni/lib/src/jreference.dart | 3 +- pkgs/jni/lib/src/jvalues.dart | 11 +- .../src/third_party/generated_bindings.dart | 2 + .../third_party/global_env_extensions.dart | 1391 ++++++ .../third_party/jni_bindings_generated.dart | 4101 +++++++---------- .../third_party/jnienv_javavm_extensions.dart | 1409 ++++++ pkgs/jni/lib/src/types.dart | 8 +- pkgs/jni/pubspec.yaml | 14 +- pkgs/jni/src/dartjni.c | 151 +- pkgs/jni/src/dartjni.h | 169 +- pkgs/jni/src/jni_constants.h | 31 + pkgs/jni/src/third_party/global_jni_env.c | 2222 ++++++--- pkgs/jni/src/third_party/global_jni_env.h | 775 ++-- pkgs/jni/test/exception_test.dart | 15 +- .../{jni_test.dart => global_env_test.dart} | 95 +- pkgs/jni/test/jarray_test.dart | 28 +- pkgs/jni/test/jobject_test.dart | 102 +- pkgs/jni/test/test_util/test_util.dart | 9 + pkgs/jni/test/type_test.dart | 9 +- .../.github/workflows/test-package.yml | 78 - .../third_party/ffigen_patch_jni/.gitignore | 41 - pkgs/jni/third_party/ffigen_patch_jni/AUTHORS | 8 - .../third_party/ffigen_patch_jni/CHANGELOG.md | 291 -- pkgs/jni/third_party/ffigen_patch_jni/LICENSE | 27 - .../third_party/ffigen_patch_jni/README.md | 8 - .../ffigen_patch_jni/analysis_options.yaml | 24 - .../ffigen_patch_jni/bin/ffigen.dart | 6 - .../ffigen_patch_jni/lib/ffigen.dart | 12 - .../ffigen_patch_jni/lib/src/README.md | 41 - .../lib/src/code_generator.dart | 26 - .../lib/src/code_generator/binding.dart | 74 - .../src/code_generator/binding_string.dart | 28 - .../lib/src/code_generator/compound.dart | 279 -- .../lib/src/code_generator/constant.dart | 65 - .../lib/src/code_generator/dart_keywords.dart | 72 - .../lib/src/code_generator/enum_class.dart | 105 - .../lib/src/code_generator/func.dart | 165 - .../lib/src/code_generator/func_type.dart | 83 - .../lib/src/code_generator/global.dart | 86 - .../lib/src/code_generator/handle.dart | 23 - .../lib/src/code_generator/imports.dart | 77 - .../lib/src/code_generator/library.dart | 141 - .../lib/src/code_generator/native_type.dart | 78 - .../lib/src/code_generator/objc_block.dart | 151 - .../objc_built_in_functions.dart | 305 -- .../src/code_generator/objc_interface.dart | 477 -- .../lib/src/code_generator/pointer.dart | 63 - .../lib/src/code_generator/struct.dart | 52 - .../lib/src/code_generator/type.dart | 120 - .../lib/src/code_generator/typealias.dart | 86 - .../lib/src/code_generator/union.dart | 49 - .../lib/src/code_generator/utils.dart | 72 - .../lib/src/code_generator/writer.dart | 300 -- .../lib/src/config_provider.dart | 8 - .../lib/src/config_provider/config.dart | 483 -- .../lib/src/config_provider/config_types.dart | 373 -- .../lib/src/config_provider/path_finder.dart | 63 - .../lib/src/config_provider/spec_utils.dart | 866 ---- .../lib/src/executables/ffigen.dart | 223 - .../lib/src/header_parser.dart | 10 - .../clang_bindings/clang_bindings.dart | 2569 ----------- .../lib/src/header_parser/data.dart | 52 - .../lib/src/header_parser/includer.dart | 90 - .../lib/src/header_parser/parser.dart | 121 - .../sub_parsers/compounddecl_parser.dart | 318 -- .../sub_parsers/enumdecl_parser.dart | 118 - .../sub_parsers/functiondecl_parser.dart | 130 - .../sub_parsers/macro_parser.dart | 331 -- .../sub_parsers/objc_block_parser.dart | 40 - .../sub_parsers/objcinterfacedecl_parser.dart | 329 -- .../sub_parsers/typedefdecl_parser.dart | 84 - .../sub_parsers/unnamed_enumdecl_parser.dart | 70 - .../header_parser/sub_parsers/var_parser.dart | 47 - .../translation_unit_parser.dart | 89 - .../type_extractor/cxtypekindmap.dart | 40 - .../type_extractor/extractor.dart | 304 -- .../lib/src/header_parser/utils.dart | 395 -- .../ffigen_patch_jni/lib/src/strings.dart | 223 - .../third_party/ffigen_patch_jni/pubspec.yaml | 26 - .../ffigen_patch_jni/tool/coverage.sh | 15 - .../tool/libclang_config.yaml | 119 - pkgs/jni/third_party/jni.h | 1845 +++++--- pkgs/jni/tool/generate_ffi_bindings.dart | 68 + .../tool/wrapper_generators/ffigen_util.dart | 50 + .../generate_c_extensions.dart | 296 ++ .../generate_dart_extensions.dart | 215 + pkgs/jni/tool/wrapper_generators/logging.dart | 7 + .../src/android_utils/android_utils.c | 1010 ++-- .../in_app_java/src/android_utils/dartjni.h | 169 +- .../kotlin_plugin/lib/kotlin_bindings.dart | 2 +- .../example/kotlin_plugin/src/dartjni.h | 169 +- .../src/kotlin_plugin_bindings.c | 22 +- .../example/notification_plugin/src/dartjni.h | 169 +- .../src/notification_plugin.c | 26 +- .../pdfbox_plugin/src/third_party/dartjni.h | 169 +- .../src/third_party/pdfbox_plugin.c | 1423 +++--- pkgs/jnigen/lib/src/bindings/c_bindings.dart | 14 +- .../lib/src/bindings/dart_generator.dart | 2 +- .../lib/src/tools/build_summarizer.dart | 4 +- pkgs/jnigen/test/kotlin_test/lib/kotlin.dart | 4 +- pkgs/jnigen/test/kotlin_test/src/dartjni.h | 169 +- pkgs/jnigen/test/kotlin_test/src/kotlin.c | 33 +- .../test/simple_package_test/src/dartjni.h | 169 +- .../simple_package_test/src/simple_package.c | 701 +-- pkgs/jnigen/test/test_util/test_util.dart | 22 +- 118 files changed, 12002 insertions(+), 17198 deletions(-) create mode 100644 pkgs/jni/example/pubspec.lock create mode 100644 pkgs/jni/ffigen_exts.yaml create mode 100644 pkgs/jni/lib/src/third_party/generated_bindings.dart create mode 100644 pkgs/jni/lib/src/third_party/global_env_extensions.dart create mode 100644 pkgs/jni/lib/src/third_party/jnienv_javavm_extensions.dart create mode 100644 pkgs/jni/src/jni_constants.h rename pkgs/jni/test/{jni_test.dart => global_env_test.dart} (59%) create mode 100644 pkgs/jni/test/test_util/test_util.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/.github/workflows/test-package.yml delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/.gitignore delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/AUTHORS delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/CHANGELOG.md delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/LICENSE delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/README.md delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/analysis_options.yaml delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/bin/ffigen.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/ffigen.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/README.md delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/binding.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/binding_string.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/compound.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/constant.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/dart_keywords.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/enum_class.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/func.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/func_type.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/global.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/handle.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/imports.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/library.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/native_type.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/objc_block.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/objc_built_in_functions.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/objc_interface.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/pointer.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/struct.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/type.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/typealias.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/union.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/utils.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/writer.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/config_provider.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/config_provider/config.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/config_provider/config_types.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/config_provider/path_finder.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/config_provider/spec_utils.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/executables/ffigen.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/clang_bindings/clang_bindings.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/data.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/includer.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/parser.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/compounddecl_parser.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/enumdecl_parser.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/functiondecl_parser.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/macro_parser.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/objc_block_parser.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/objcinterfacedecl_parser.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/typedefdecl_parser.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/unnamed_enumdecl_parser.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/var_parser.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/translation_unit_parser.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/type_extractor/cxtypekindmap.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/type_extractor/extractor.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/utils.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/lib/src/strings.dart delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/pubspec.yaml delete mode 100755 pkgs/jni/third_party/ffigen_patch_jni/tool/coverage.sh delete mode 100644 pkgs/jni/third_party/ffigen_patch_jni/tool/libclang_config.yaml create mode 100644 pkgs/jni/tool/generate_ffi_bindings.dart create mode 100644 pkgs/jni/tool/wrapper_generators/ffigen_util.dart create mode 100644 pkgs/jni/tool/wrapper_generators/generate_c_extensions.dart create mode 100644 pkgs/jni/tool/wrapper_generators/generate_dart_extensions.dart create mode 100644 pkgs/jni/tool/wrapper_generators/logging.dart diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index a4f17bc37..f1afa9de0 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -182,10 +182,10 @@ jobs: parallel: true path-to-lcov: ./pkgs/jni/coverage/lcov.info - name: regenerate & compare ffigen bindings + ## Use git to verify no source files have changed run: | - cp lib/src/third_party/jni_bindings_generated.dart __old_bindings - dart run ffigen --config ffigen.yaml - diff lib/src/third_party/jni_bindings_generated.dart __old_bindings + dart run tool/generate_ffi_bindings.dart + git diff --exit-code -- lib/src/third_party src/third_party ## Run tests for package:jni on windows, just to confirm it works. ## Do not, for example, collect coverage or check formatting. diff --git a/pkgs/jni/.gitignore b/pkgs/jni/.gitignore index 96486fd93..ae8c6c2ef 100644 --- a/pkgs/jni/.gitignore +++ b/pkgs/jni/.gitignore @@ -28,3 +28,5 @@ migrate_working_dir/ .dart_tool/ .packages build/ + +.vscode/ \ No newline at end of file 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 3b547ad93..769ae6b7f 100644 --- a/pkgs/jni/example/integration_test/on_device_jni_test.dart +++ b/pkgs/jni/example/integration_test/on_device_jni_test.dart @@ -2,123 +2,27 @@ // 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 contains mostly the same tests from package:jni's -// test/jni_object_test.dart. This file can be run on android device using -// flutter test integration_test/ and therefore useful for checking the -// working of JNI on an Android device (or emulator). - -import 'dart:io'; - import 'package:flutter_test/flutter_test.dart'; -import 'package:jni/jni.dart'; +import '../../test/global_env_test.dart' as global_env_test; +import '../../test/exception_test.dart' as exception_test; +import '../../test/jobject_test.dart' as jobject_test; +import '../../test/jarray_test.dart' as jarray_test; +import '../../test/type_test.dart' as type_test; + +void integrationTestRunner(String description, void Function() testCallback) { + testWidgets(description, (widgetTester) async => testCallback()); +} void main() { - if (!Platform.isAndroid) { - try { - Jni.spawn(dylibDir: "build/jni_libs"); - } on JvmExistsException { - // TODO(#51): Support destroying and restarting JVM. - } + final testSuites = [ + global_env_test.run, + exception_test.run, + jobject_test.run, + jarray_test.run, + type_test.run, + ]; + for (var testSuite in testSuites) { + testSuite(testRunner: integrationTestRunner); } - - testWidgets("Long.intValue() using JObject", (t) async { - final longClass = Jni.findJniClass("java/lang/Long"); - - final longCtor = longClass.getCtorID("(J)V"); - - final long = longClass.newInstance(longCtor, [176]); - - final intValue = long.callMethodByName("intValue", "()I", []); - expect(intValue, equals(176)); - - long.delete(); - longClass.delete(); - }); - - testWidgets("call a static method using JniClass APIs", (t) async { - final integerClass = JniClass.fromRef(Jni.findClass("java/lang/Integer")); - final result = integerClass.callStaticMethodByName( - "toHexString", "(I)Ljava/lang/String;", [JValueInt(31)]); - - final resultString = result.toDartString(); - - result.delete(); - expect(resultString, equals("1f")); - - integerClass.delete(); - }); - - testWidgets("Example for using getMethodID", (t) async { - final longClass = Jni.findJniClass("java/lang/Long"); - final bitCountMethod = longClass.getStaticMethodID("bitCount", "(J)I"); - - final random = Jni.newInstance("java/util/Random", "()V", []); - - final nextIntMethod = random.getMethodID("nextInt", "(I)I"); - - for (int i = 0; i < 100; i++) { - int r = random.callMethod(nextIntMethod, [JValueInt(256 * 256)]); - int bits = 0; - final jbc = longClass.callStaticMethod(bitCountMethod, [r]); - while (r != 0) { - bits += r % 2; - r = (r / 2).floor(); - } - expect(jbc, equals(bits)); - } - random.delete(); - longClass.delete(); - }); - - // Actually it's not even required to get a reference to class - testWidgets("invoke_", (t) async { - final m = Jni.invokeStaticMethod( - "java/lang/Long", "min", "(JJ)J", [1234, 1324], JniCallType.longType); - expect(m, equals(1234)); - }); - - testWidgets("retrieve_", (t) async { - final maxLong = Jni.retrieveStaticField( - "java/lang/Short", "MAX_VALUE", "S", JniCallType.shortType); - expect(maxLong, equals(32767)); - }); - - testWidgets("Call method with null argument, expect exception", - (tester) async { - final integerClass = Jni.findJniClass("java/lang/Integer"); - expect( - () => integerClass.callStaticMethodByName( - "parseInt", "(Ljava/lang/String;)I", [nullptr]), - throwsException); - }); - - testWidgets("callStaticStringMethod", (t) async { - final longClass = Jni.findJniClass("java/lang/Long"); - const n = 1223334444; - final strFromJava = longClass.callStaticMethodByName( - "toOctalString", "(J)Ljava/lang/String;", [n]); - expect(strFromJava, equals(n.toRadixString(8))); - longClass.delete(); - }); - - testWidgets("Passing strings in arguments", (t) async { - final twelve = Jni.invokeStaticMethod("java/lang/Byte", "parseByte", - "(Ljava/lang/String;)B", ["12"], JniCallType.byteType); - expect(twelve, equals(12)); - }); - - testWidgets("use() method", (t) async { - final randomInt = Jni.newInstance("java/util/Random", "()V", []).use( - (random) => - random.callMethodByName("nextInt", "(I)I", [JValueInt(15)])); - expect(randomInt, lessThan(15)); - }); - - testWidgets("enums", (t) async { - final ordinal = Jni.retrieveStaticField( - "java/net/Proxy\$Type", "HTTP", "Ljava/net/Proxy\$Type;") - .use((f) => f.callMethodByName("ordinal", "()I", [])); - expect(ordinal, equals(1)); - }); } diff --git a/pkgs/jni/example/lib/main.dart b/pkgs/jni/example/lib/main.dart index b23b2793e..50c3c75b3 100644 --- a/pkgs/jni/example/lib/main.dart +++ b/pkgs/jni/example/lib/main.dart @@ -15,7 +15,7 @@ import 'package:jni/jni.dart'; // GlobalJniEnv is a thin abstraction over JNIEnv in JNI C API. // // For a more ergonomic API for common use cases of calling methods and -// accessing fields, see next examples using JObject and JniClass. +// accessing fields, see next examples using JObject and JClass. String toJavaStringUsingEnv(int n) => using((arena) { final env = Jni.env; final cls = env.FindClass("java/lang/String".toNativeChars(arena)); @@ -24,7 +24,7 @@ String toJavaStringUsingEnv(int n) => using((arena) { final i = arena(); i.ref.i = n; final res = env.CallStaticObjectMethodA(cls, mId, i); - final str = env.asDartString(res); + final str = env.toDartString(res); env.deleteAllRefs([res, cls]); return str; }); @@ -42,14 +42,14 @@ int randomUsingEnv(int n) => using((arena) { return res; }); double randomDouble() { - final math = Jni.findJniClass("java/lang/Math"); + final math = Jni.findJClass("java/lang/Math"); final random = math.callStaticMethodByName("random", "()D", []); math.delete(); return random; } int uptime() { - return Jni.findJniClass("android/os/SystemClock").use( + return Jni.findJClass("android/os/SystemClock").use( (systemClock) => systemClock.callStaticMethodByName( "uptimeMillis", "()J", [], JniCallType.longType), ); diff --git a/pkgs/jni/example/pubspec.lock b/pkgs/jni/example/pubspec.lock new file mode 100644 index 000000000..5925148f1 --- /dev/null +++ b/pkgs/jni/example/pubspec.lock @@ -0,0 +1,523 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + sha256: a36ec4843dc30ea6bf652bf25e3448db6c5e8bcf4aa55f063a5d1dad216d8214 + url: "https://pub.dev" + source: hosted + version: "58.0.0" + analyzer: + dependency: transitive + description: + name: analyzer + sha256: cc4242565347e98424ce9945c819c192ec0838cb9d1f6aa4a97cc96becbc5b27 + url: "https://pub.dev" + source: hosted + version: "5.10.0" + archive: + dependency: transitive + description: + name: archive + sha256: "80e5141fafcb3361653ce308776cfd7d45e6e9fbb429e14eec571382c0c5fecb" + url: "https://pub.dev" + source: hosted + version: "3.3.2" + args: + dependency: transitive + description: + name: args + sha256: "4cab82a83ffef80b262ddedf47a0a8e56ee6fbf7fe21e6e768b02792034dd440" + url: "https://pub.dev" + source: hosted + version: "2.4.0" + async: + dependency: transitive + description: + name: async + sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 + url: "https://pub.dev" + source: hosted + version: "2.10.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + characters: + dependency: transitive + description: + name: characters + sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c + url: "https://pub.dev" + source: hosted + version: "1.2.1" + clock: + dependency: transitive + description: + name: clock + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" + source: hosted + version: "1.1.1" + collection: + dependency: transitive + description: + name: collection + sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 + url: "https://pub.dev" + source: hosted + version: "1.17.0" + convert: + dependency: transitive + description: + name: convert + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + url: "https://pub.dev" + source: hosted + version: "3.1.1" + coverage: + dependency: transitive + description: + name: coverage + sha256: "2fb815080e44a09b85e0f2ca8a820b15053982b2e714b59267719e8a9ff17097" + url: "https://pub.dev" + source: hosted + version: "1.6.3" + crypto: + dependency: transitive + description: + name: crypto + sha256: aa274aa7774f8964e4f4f38cc994db7b6158dd36e9187aaceaddc994b35c6c67 + url: "https://pub.dev" + source: hosted + version: "3.0.2" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + sha256: e35129dc44c9118cee2a5603506d823bab99c68393879edb440e0090d07586be + url: "https://pub.dev" + source: hosted + version: "1.0.5" + fake_async: + dependency: transitive + description: + name: fake_async + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" + source: hosted + version: "1.3.1" + ffi: + dependency: "direct main" + description: + name: ffi + sha256: a38574032c5f1dd06c4aee541789906c12ccaab8ba01446e800d9c5b79c4a978 + url: "https://pub.dev" + source: hosted + version: "2.0.1" + file: + dependency: transitive + description: + name: file + sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" + url: "https://pub.dev" + source: hosted + version: "6.1.4" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_driver: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + sha256: aeb0b80a8b3709709c9cc496cdc027c5b3216796bc0af0ce1007eaf24464fd4c + url: "https://pub.dev" + source: hosted + version: "2.0.1" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + frontend_server_client: + dependency: transitive + description: + name: frontend_server_client + sha256: "408e3ca148b31c20282ad6f37ebfa6f4bdc8fede5b74bc2f08d9d92b55db3612" + url: "https://pub.dev" + source: hosted + version: "3.2.0" + fuchsia_remote_debug_protocol: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + glob: + dependency: transitive + description: + name: glob + sha256: "4515b5b6ddb505ebdd242a5f2cc5d22d3d6a80013789debfbda7777f47ea308c" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b" + url: "https://pub.dev" + source: hosted + version: "3.2.1" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" + url: "https://pub.dev" + source: hosted + version: "4.0.2" + integration_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + io: + dependency: transitive + description: + name: io + sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e" + url: "https://pub.dev" + source: hosted + version: "1.0.4" + jni: + dependency: "direct main" + description: + path: ".." + relative: true + source: path + version: "0.3.0" + js: + dependency: transitive + description: + name: js + sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" + url: "https://pub.dev" + source: hosted + version: "0.6.5" + lints: + dependency: transitive + description: + name: lints + sha256: "5e4a9cd06d447758280a8ac2405101e0e2094d2a1dbdd3756aec3fe7775ba593" + url: "https://pub.dev" + source: hosted + version: "2.0.1" + logging: + dependency: transitive + description: + name: logging + sha256: "04094f2eb032cbb06c6f6e8d3607edcfcb0455e2bb6cbc010cb01171dcb64e6d" + url: "https://pub.dev" + source: hosted + version: "1.1.1" + matcher: + dependency: transitive + description: + name: matcher + sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" + url: "https://pub.dev" + source: hosted + version: "0.12.13" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + url: "https://pub.dev" + source: hosted + version: "0.2.0" + meta: + dependency: transitive + description: + name: meta + sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" + url: "https://pub.dev" + source: hosted + version: "1.8.0" + mime: + dependency: transitive + description: + name: mime + sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e + url: "https://pub.dev" + source: hosted + version: "1.0.4" + node_preamble: + dependency: transitive + description: + name: node_preamble + sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db" + url: "https://pub.dev" + source: hosted + version: "2.0.2" + package_config: + dependency: transitive + description: + name: package_config + sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" + url: "https://pub.dev" + source: hosted + version: "2.1.0" + path: + dependency: transitive + description: + name: path + sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b + url: "https://pub.dev" + source: hosted + version: "1.8.2" + platform: + dependency: transitive + description: + name: platform + sha256: "4a451831508d7d6ca779f7ac6e212b4023dd5a7d08a27a63da33756410e32b76" + url: "https://pub.dev" + source: hosted + version: "3.1.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "6a2128648c854906c53fa8e33986fc0247a1116122f9534dd20e3ab9e16a32bc" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + pool: + dependency: transitive + description: + name: pool + sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" + url: "https://pub.dev" + source: hosted + version: "1.5.1" + process: + dependency: transitive + description: + name: process + sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09" + url: "https://pub.dev" + source: hosted + version: "4.2.4" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "307de764d305289ff24ad257ad5c5793ce56d04947599ad68b3baa124105fc17" + url: "https://pub.dev" + source: hosted + version: "2.1.3" + shelf: + dependency: transitive + description: + name: shelf + sha256: c24a96135a2ccd62c64b69315a14adc5c3419df63b4d7c05832a346fdb73682c + url: "https://pub.dev" + source: hosted + version: "1.4.0" + shelf_packages_handler: + dependency: transitive + description: + name: shelf_packages_handler + sha256: aef74dc9195746a384843102142ab65b6a4735bb3beea791e63527b88cc83306 + url: "https://pub.dev" + source: hosted + version: "3.0.1" + shelf_static: + dependency: transitive + description: + name: shelf_static + sha256: e792b76b96a36d4a41b819da593aff4bdd413576b3ba6150df5d8d9996d2e74c + url: "https://pub.dev" + source: hosted + version: "1.1.1" + shelf_web_socket: + dependency: transitive + description: + name: shelf_web_socket + sha256: a988c0e8d8ffbdb8a28aa7ec8e449c260f3deb808781fe1284d22c5bba7156e8 + url: "https://pub.dev" + source: hosted + version: "1.0.3" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_map_stack_trace: + dependency: transitive + description: + name: source_map_stack_trace + sha256: "84cf769ad83aa6bb61e0aa5a18e53aea683395f196a6f39c4c881fb90ed4f7ae" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + source_maps: + dependency: transitive + description: + name: source_maps + sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703" + url: "https://pub.dev" + source: hosted + version: "0.10.12" + source_span: + dependency: transitive + description: + name: source_span + sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + url: "https://pub.dev" + source: hosted + version: "1.9.1" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + url: "https://pub.dev" + source: hosted + version: "1.11.0" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + sync_http: + dependency: transitive + description: + name: sync_http + sha256: "7f0cd72eca000d2e026bcd6f990b81d0ca06022ef4e32fb257b30d3d1014a961" + url: "https://pub.dev" + source: hosted + version: "0.3.1" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" + source: hosted + version: "1.2.1" + test: + dependency: "direct dev" + description: + name: test + sha256: a5fcd2d25eeadbb6589e80198a47d6a464ba3e2049da473943b8af9797900c2d + url: "https://pub.dev" + source: hosted + version: "1.22.0" + test_api: + dependency: transitive + description: + name: test_api + sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 + url: "https://pub.dev" + source: hosted + version: "0.4.16" + test_core: + dependency: transitive + description: + name: test_core + sha256: "0ef9755ec6d746951ba0aabe62f874b707690b5ede0fecc818b138fcc9b14888" + url: "https://pub.dev" + source: hosted + version: "0.4.20" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: "26f87ade979c47a150c9eaab93ccd2bebe70a27dc0b4b29517f2904f04eb11a5" + url: "https://pub.dev" + source: hosted + version: "1.3.1" + vector_math: + dependency: transitive + description: + name: vector_math + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: e7fb6c2282f7631712b69c19d1bff82f3767eea33a2321c14fa59ad67ea391c7 + url: "https://pub.dev" + source: hosted + version: "9.4.0" + watcher: + dependency: transitive + description: + name: watcher + sha256: "6a7f46926b01ce81bfc339da6a7f20afbe7733eff9846f6d6a5466aa4c6667c0" + url: "https://pub.dev" + source: hosted + version: "1.0.2" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b + url: "https://pub.dev" + source: hosted + version: "2.4.0" + webdriver: + dependency: transitive + description: + name: webdriver + sha256: ef67178f0cc7e32c1494645b11639dd1335f1d18814aa8435113a92e9ef9d841 + url: "https://pub.dev" + source: hosted + version: "3.0.1" + webkit_inspection_protocol: + dependency: transitive + description: + name: webkit_inspection_protocol + sha256: "67d3a8b6c79e1987d19d848b0892e582dbb0c66c57cc1fef58a177dd2aa2823d" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + yaml: + dependency: transitive + description: + name: yaml + sha256: "23812a9b125b48d4007117254bca50abb6c712352927eece9e155207b1db2370" + url: "https://pub.dev" + source: hosted + version: "3.1.1" +sdks: + dart: ">=2.19.0 <3.0.0" + flutter: ">=2.11.0" diff --git a/pkgs/jni/example/pubspec.yaml b/pkgs/jni/example/pubspec.yaml index 70624e670..30408f94d 100644 --- a/pkgs/jni/example/pubspec.yaml +++ b/pkgs/jni/example/pubspec.yaml @@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: ">=2.17.5 <4.0.0" + sdk: '>=2.17.5 <4.0.0' # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions @@ -45,6 +45,7 @@ dependencies: cupertino_icons: ^1.0.2 dev_dependencies: + test: any flutter_test: sdk: flutter integration_test: @@ -62,7 +63,6 @@ dev_dependencies: # The following section is specific to Flutter packages. flutter: - # The following line ensures that the Material Icons font is # included with your application, so that you can use the icons in # the material Icons class. diff --git a/pkgs/jni/ffigen.yaml b/pkgs/jni/ffigen.yaml index dc1cea2dc..1704f430f 100644 --- a/pkgs/jni/ffigen.yaml +++ b/pkgs/jni/ffigen.yaml @@ -13,27 +13,46 @@ headers: entry-points: - 'src/dartjni.h' # Exports majority of JNI functions - 'src/third_party/global_jni_env.h' # Exports GlobalJniEnv type + - 'src/jni_constants.h' include-directives: - 'src/dartjni.h' - 'src/third_party/global_jni_env.h' - 'third_party/jni.h' # jni.h from Android NDK + - 'src/jni_constants.h' compiler-opts: - '-Ithird_party/' enums: rename: 'JniType': 'JniCallType' + 'jobjectRefType': 'JObjectRefType' functions: exclude: # Exclude init functions supposed to be defined in loaded DLL, not JNI - 'JNI_.*' - - 'GetJniContext' + - 'GetJniContextPtr' - 'setJniGetters' - 'jni_log' + # Inline functions + - 'acquire_lock' + - 'release_lock' + - 'init_lock' + - 'destroy_lock' + - 'load_class' + - 'load_class_global_ref' + - 'attach_thread' + - 'load_method' + - 'load_static_method' + - 'load_field' + - 'load_static_field' + - 'to_global_ref' + - 'check_exception' + - 'load_env' # This is a native function in Java. No need to call it from Dart. - 'Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith' structs: exclude: - 'JniContext' + - 'JniLocks' - 'JNIEnv' - '_JNIEnv' - 'JNIInvokeInterface' @@ -41,7 +60,8 @@ structs: rename: ## opaque struct definitions, base types of jfieldID and jmethodID '_jfieldID': 'jfieldID_' - '_jmethodID': 'jmethodID_' + '_jmethodID': + 'jmethodID_' #'JNI(.*)': 'Jni$1' unions: rename: @@ -126,4 +146,3 @@ preamble: | comments: style: any length: full - diff --git a/pkgs/jni/ffigen_exts.yaml b/pkgs/jni/ffigen_exts.yaml new file mode 100644 index 000000000..d292ad63a --- /dev/null +++ b/pkgs/jni/ffigen_exts.yaml @@ -0,0 +1,16 @@ +# Run with `dart run ffigen --config ffigen.yaml`. +name: JniExtensions +description: | + This config is for use by the script that generates extension methods in C. + This config only scans jni.h and does not do renaming etc.. +output: 'unused.dart' +headers: + entry-points: + - 'third_party/jni.h' # Exports majority of JNI functions + #- 'src/third_party/global_jni_env.h' # Exports GlobalJniEnv type + include-directives: + #- 'src/dartjni.h' + #- 'src/third_party/global_jni_env.h' + - 'third_party/jni.h' # jni.h from Android NDK +compiler-opts: + - '-Ithird_party/' diff --git a/pkgs/jni/lib/jni.dart b/pkgs/jni/lib/jni.dart index 72ef75825..a4a45ec5a 100644 --- a/pkgs/jni/lib/jni.dart +++ b/pkgs/jni/lib/jni.dart @@ -60,7 +60,7 @@ /// This library provides classes and functions for JNI interop from Dart. library jni; -export 'src/third_party/jni_bindings_generated.dart' +export 'src/third_party/generated_bindings.dart' hide JniBindings, JniEnv, JniEnv1, JniExceptionDetails; export 'src/jni.dart' hide ProtectedJniExtensions; export 'src/jvalues.dart' hide JValueArgs, toJValues; diff --git a/pkgs/jni/lib/src/accessors.dart b/pkgs/jni/lib/src/accessors.dart index 6d018658c..66045aec7 100644 --- a/pkgs/jni/lib/src/accessors.dart +++ b/pkgs/jni/lib/src/accessors.dart @@ -7,7 +7,7 @@ import 'package:ffi/ffi.dart' show using; import 'package:jni/src/jvalues.dart'; -import 'third_party/jni_bindings_generated.dart'; +import 'third_party/generated_bindings.dart'; import 'jni.dart'; import 'types.dart'; @@ -22,71 +22,81 @@ extension JniResultMethods on JniResult { int get byte { check(); - return result.b; + return value.b; } int get short { check(); - return result.s; + return value.s; } int get char { check(); - return result.c; + return value.c; } int get integer { check(); - return result.i; + return value.i; } int get long { check(); - return result.j; + return value.j; } double get float { check(); - return result.f; + return value.f; } double get doubleFloat { check(); - return result.d; + return value.d; } JObjectPtr get object { check(); - return result.l; + return value.l; } bool get boolean { check(); - return result.z != 0; + return value.z != 0; } } extension JniIdLookupResultMethods on JniPointerResult { JMethodIDPtr get methodID { _check(exception); - return id.cast(); + return value.cast(); } JFieldIDPtr get fieldID { _check(exception); - return id.cast(); + return value.cast(); } Pointer get checkedRef { _check(exception); - return id; + return value; + } + + Pointer getPointer() { + return value.cast(); } } extension JniClassLookupResultMethods on JniClassLookupResult { JClassPtr get checkedClassRef { _check(exception); - return classRef; + return value; + } +} + +extension JThrowableCheckMethod on JThrowablePtr { + void check() { + _check(this); } } @@ -98,8 +108,8 @@ extension JniAccessorWrappers on Pointer { void throwException(JThrowablePtr exception) { final details = getExceptionDetails(exception); final env = Jni.env; - final message = env.asDartString(details.message); - final stacktrace = env.asDartString(details.stacktrace); + final message = env.toDartString(details.message); + final stacktrace = env.toDartString(details.stacktrace); env.DeleteGlobalRef(exception); env.DeleteGlobalRef(details.message); env.DeleteGlobalRef(details.stacktrace); diff --git a/pkgs/jni/lib/src/jexceptions.dart b/pkgs/jni/lib/src/jexceptions.dart index a9a3cfcab..3200880aa 100644 --- a/pkgs/jni/lib/src/jexceptions.dart +++ b/pkgs/jni/lib/src/jexceptions.dart @@ -43,7 +43,24 @@ class DoubleFreeException implements JException { class JvmExistsException implements JException { @override - String toString() => 'A JVM already exists'; + String toString() => 'A JVM is already spawned'; +} + +/// Represents spawn errors that might be returned by JNI_CreateJavaVM +class SpawnException implements JException { + static const _errors = { + JniErrorCode.JNI_ERR: 'Generic JNI error', + JniErrorCode.JNI_EDETACHED: 'Thread detached from VM', + JniErrorCode.JNI_EVERSION: 'JNI version error', + JniErrorCode.JNI_ENOMEM: 'Out of memory', + JniErrorCode.JNI_EEXIST: 'VM Already created', + JniErrorCode.JNI_EINVAL: 'Invalid arguments', + }; + int status; + SpawnException.of(this.status); + + @override + String toString() => _errors[status] ?? 'Unknown status code: $status'; } class NoJvmInstanceException implements JException { diff --git a/pkgs/jni/lib/src/jni.dart b/pkgs/jni/lib/src/jni.dart index 4d5a2abd7..8ad7fd4c3 100644 --- a/pkgs/jni/lib/src/jni.dart +++ b/pkgs/jni/lib/src/jni.dart @@ -9,7 +9,7 @@ import 'dart:isolate'; import 'package:ffi/ffi.dart'; import 'package:path/path.dart'; -import 'third_party/jni_bindings_generated.dart'; +import 'third_party/generated_bindings.dart'; import 'jvalues.dart'; import 'types.dart'; import 'accessors.dart'; @@ -46,7 +46,7 @@ abstract class Jni { static final DynamicLibrary _dylib = _loadDartJniLibrary(dir: _dylibDir); static final JniBindings _bindings = JniBindings(_dylib); static final _getJniEnvFn = _dylib.lookup('GetJniEnv'); - static final _getJniContextFn = _dylib.lookup('GetJniContext'); + static final _getJniContextFn = _dylib.lookup('GetJniContextPtr'); /// Store dylibDir if any was used. static String? _dylibDir; @@ -84,7 +84,7 @@ abstract class Jni { List jvmOptions = const [], List classPath = const [], bool ignoreUnrecognized = false, - int jniVersion = JNI_VERSION_1_6, + int jniVersion = JniVersions.JNI_VERSION_1_6, }) => using((arena) { _dylibDir = dylibDir; @@ -100,7 +100,17 @@ abstract class Jni { ignoreUnrecognized: ignoreUnrecognized, allocator: arena, ); - _bindings.SpawnJvm(jvmArgs); + final status = _bindings.SpawnJvm(jvmArgs); + if (status == JniErrorCode.JNI_OK) { + return; + } else if (status == DART_JNI_SINGLETON_EXISTS) { + throw JvmExistsException(); + } else if (status == JniErrorCode.JNI_EEXIST) { + sleep(const Duration(seconds: 1)); + throw JvmExistsException(); + } else { + throw SpawnException.of(status); + } }); static Pointer _createVMArgs({ @@ -108,7 +118,7 @@ abstract class Jni { List classPath = const [], String? dylibPath, bool ignoreUnrecognized = false, - int version = JNI_VERSION_1_6, + int version = JniVersions.JNI_VERSION_1_6, required Allocator allocator, }) { final args = allocator(); @@ -195,9 +205,9 @@ abstract class Jni { }); /// Returns class for [qualifiedName] found by platform-specific mechanism, - /// wrapped in a [JniClass]. - static JniClass findJniClass(String qualifiedName) => - JniClass.fromRef(findClass(qualifiedName)); + /// wrapped in a [JClass]. + static JClass findJClass(String qualifiedName) => + JClass.fromRef(findClass(qualifiedName)); /// Constructs an instance of class with given arguments. /// @@ -205,7 +215,7 @@ abstract class Jni { /// required themselves. static JObject newInstance( String qualifiedName, String ctorSignature, List args) { - final cls = findJniClass(qualifiedName); + final cls = findJClass(qualifiedName); final ctor = cls.getCtorID(ctorSignature); final obj = cls.newInstance(ctor, args); cls.delete(); @@ -228,7 +238,7 @@ abstract class Jni { static T retrieveStaticField( String className, String fieldName, String signature, [int? callType]) { - final cls = findJniClass(className); + final cls = findJClass(className); final result = cls.getStaticFieldByName(fieldName, signature, callType); cls.delete(); return result; @@ -242,7 +252,7 @@ abstract class Jni { static T invokeStaticMethod( String className, String methodName, String signature, List args, [int? callType]) { - final cls = findJniClass(className); + final cls = findJClass(className); final result = cls.callStaticMethodByName(methodName, signature, args, callType); cls.delete(); @@ -283,7 +293,7 @@ extension AdditionalEnvMethods on Pointer { /// to dart string. /// if [deleteOriginal] is specified, jstring passed will be deleted using /// DeleteLocalRef. - String asDartString(JStringPtr jstringPtr, {bool deleteOriginal = false}) { + String toDartString(JStringPtr jstringPtr, {bool deleteOriginal = false}) { if (jstringPtr == nullptr) { throw NullJStringException(); } @@ -300,7 +310,7 @@ extension AdditionalEnvMethods on Pointer { } /// Return a new [JStringPtr] from contents of [s]. - JStringPtr asJString(String s) => using((arena) { + JStringPtr toJStringPtr(String s) => using((arena) { final utf = s.toNativeUtf8().cast(); final result = NewStringUTF(utf); malloc.free(utf); diff --git a/pkgs/jni/lib/src/jobject.dart b/pkgs/jni/lib/src/jobject.dart index dff8fda23..3eb4074a1 100644 --- a/pkgs/jni/lib/src/jobject.dart +++ b/pkgs/jni/lib/src/jobject.dart @@ -44,7 +44,7 @@ Pointer _getID( if (result.exception != nullptr) { _accessors.throwException(result.exception); } - return result.id.cast(); + return result.value.cast(); } int _getCallType(int? callType, int defaultType, Set allowed) { @@ -109,10 +109,15 @@ T _callOrGet(int? callType, JniResult Function(int) function) { callType, JniCallType.objectType, {JniCallType.objectType}); final ref = function(finalCallType).object; final ctor = T == String - ? (ref) => _env.asDartString(ref, deleteOriginal: true) + ? (ref) => _env.toDartString(ref, deleteOriginal: true) : (T == JObject ? JObject.fromRef : JString.fromRef); result = ctor(ref) as T; break; + case Pointer: // JObjectPtr + finalCallType = _getCallType( + callType, JniCallType.objectType, {JniCallType.objectType}); + result = function(finalCallType).object as T; + break; case _VoidType: finalCallType = _getCallType(callType, JniCallType.voidType, {JniCallType.voidType}); @@ -131,7 +136,6 @@ T _callMethod(int? callType, List args, JniResult Function(int, Pointer) f) => using((arena) { final jArgs = JValueArgs(args, arena); - arena.onReleaseAll(jArgs.dispose); return _callOrGet(callType, (ct) => f(ct, jArgs.values)); }); @@ -153,30 +157,30 @@ class JObject extends JReference { /// Construct a new [JObject] with [reference] as its underlying reference. JObject.fromRef(JObjectPtr reference) : super.fromRef(reference); - JniClass? _jniClass; + JClass? _jClass; - JniClass get _class { - return _jniClass ??= getClass(); + JClass get _class { + return _jClass ??= getClass(); } /// Deletes the JNI reference and marks this object as deleted. Any further /// uses will throw [UseAfterFreeException]. @override void delete() { - _jniClass?.delete(); + _jClass?.delete(); super.delete(); } - /// Returns [JniClass] corresponding to concrete class of this object. + /// Returns [JClass] corresponding to concrete class of this object. /// /// This may be a subclass of compile-time class. - JniClass getClass() { + JClass getClass() { _ensureNotDeleted(); final classRef = _env.GetObjectClass(reference); if (classRef == nullptr) { _accessors.throwException(_env.ExceptionOccurred()); } - return JniClass.fromRef(classRef); + return JClass.fromRef(classRef); } /// Get [JFieldIDPtr] of instance field identified by [fieldName] & [signature]. @@ -295,7 +299,7 @@ class JObject extends JReference { /// Casts this object to another type. T castTo(JObjType type, {bool deleteOriginal = false}) { if (deleteOriginal) { - _jniClass?.delete(); + _jClass?.delete(); _setAsDeleted(); return type.fromRef(reference); } @@ -305,9 +309,9 @@ class JObject extends JReference { } /// A high level wrapper over a JNI class reference. -class JniClass extends JReference { - /// Construct a new [JniClass] with [reference] as its underlying reference. - JniClass.fromRef(JObjectPtr reference) : super.fromRef(reference); +class JClass extends JReference { + /// Construct a new [JClass] with [reference] as its underlying reference. + JClass.fromRef(JObjectPtr reference) : super.fromRef(reference); /// Get [JFieldIDPtr] of static field [fieldName] with [signature]. JFieldIDPtr getStaticFieldID(String fieldName, String signature) { @@ -384,7 +388,6 @@ class JniClass extends JReference { JObject newInstance(JMethodIDPtr ctor, List args) => using((arena) { _ensureNotDeleted(); final jArgs = JValueArgs(args, arena); - arena.onReleaseAll(jArgs.dispose); final res = _accessors.newObject(reference, ctor, jArgs.values).object; return JObject.fromRef(res); }); diff --git a/pkgs/jni/lib/src/jreference.dart b/pkgs/jni/lib/src/jreference.dart index 1bd6c5ce3..e71febfc1 100644 --- a/pkgs/jni/lib/src/jreference.dart +++ b/pkgs/jni/lib/src/jreference.dart @@ -7,7 +7,8 @@ part of 'types.dart'; /// A class which holds one or more JNI references, and has a `delete` operation /// which disposes the reference(s). abstract class JReference implements Finalizable { - static final _finalizer = NativeFinalizer(_env.ref.DeleteGlobalRef); + //TODO(PR): Is it safe to cast void *f (void *) to void f (void *)? + static final _finalizer = NativeFinalizer(_env.ref.DeleteGlobalRef.cast()); JReference.fromRef(this.reference) { _finalizer.attach(this, reference, detach: this); diff --git a/pkgs/jni/lib/src/jvalues.dart b/pkgs/jni/lib/src/jvalues.dart index ce0cac6f3..b34e306f6 100644 --- a/pkgs/jni/lib/src/jvalues.dart +++ b/pkgs/jni/lib/src/jvalues.dart @@ -5,7 +5,7 @@ import 'dart:ffi'; import 'package:ffi/ffi.dart'; -import 'third_party/jni_bindings_generated.dart'; +import 'third_party/generated_bindings.dart'; import 'jni.dart'; import 'types.dart'; @@ -120,23 +120,24 @@ class JValueArgs { final List createdRefs = []; final _env = Jni.env; - JValueArgs(List args, [Allocator allocator = malloc]) { - values = allocator(args.length); + JValueArgs(List args, Arena arena) { + values = arena(args.length); for (int i = 0; i < args.length; i++) { final arg = args[i]; final ptr = values.elementAt(i); if (arg is String) { - final jstr = _env.asJString(arg); + final jstr = _env.toJStringPtr(arg); ptr.ref.l = jstr; createdRefs.add(jstr); } else { _fillJValue(ptr, arg); } + arena.onReleaseAll(_dispose); } } /// Deletes temporary references such as [JStringPtr]s. - void dispose() { + void _dispose() { for (var ref in createdRefs) { _env.DeleteGlobalRef(ref); } diff --git a/pkgs/jni/lib/src/third_party/generated_bindings.dart b/pkgs/jni/lib/src/third_party/generated_bindings.dart new file mode 100644 index 000000000..6047975b9 --- /dev/null +++ b/pkgs/jni/lib/src/third_party/generated_bindings.dart @@ -0,0 +1,2 @@ +export 'jni_bindings_generated.dart'; +export 'global_env_extensions.dart'; diff --git a/pkgs/jni/lib/src/third_party/global_env_extensions.dart b/pkgs/jni/lib/src/third_party/global_env_extensions.dart new file mode 100644 index 000000000..e561eef4b --- /dev/null +++ b/pkgs/jni/lib/src/third_party/global_env_extensions.dart @@ -0,0 +1,1391 @@ +// Auto generated file. Do not edit. + +// This is generated from JNI header in Android NDK. License for the same is +// provided below. + +/* + * Copyright (C) 2006 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * JNI specification, as defined by Sun: + * http://java.sun.com/javase/6/docs/technotes/guides/jni/spec/jniTOC.html + * + * Everything here is expected to be VM-neutral. + */ + +// ignore_for_file: non_constant_identifier_names +// coverage:ignore-file + +import "dart:ffi" as ffi; + +import "jni_bindings_generated.dart"; + +import "../accessors.dart"; + +extension EnvExtension on ffi.Pointer { + int GetVersion() => + ref.GetVersion.asFunction()().integer; + + JClassPtr DefineClass(ffi.Pointer name, JObjectPtr loader, + ffi.Pointer buf, int bufLen) => + ref.DefineClass.asFunction< + JniClassLookupResult Function( + ffi.Pointer name, + JObjectPtr loader, + ffi.Pointer buf, + int bufLen)>()(name, loader, buf, bufLen) + .value; + + JClassPtr FindClass(ffi.Pointer name) => ref.FindClass.asFunction< + JniClassLookupResult Function(ffi.Pointer name)>()(name) + .value; + + JMethodIDPtr FromReflectedMethod(JObjectPtr method) => ref.FromReflectedMethod + .asFunction()(method) + .methodID; + + JFieldIDPtr FromReflectedField(JObjectPtr field) => ref.FromReflectedField + .asFunction()(field) + .fieldID; + + JObjectPtr ToReflectedMethod( + JClassPtr cls, JMethodIDPtr methodId, int isStatic) => + ref.ToReflectedMethod.asFunction< + JniResult Function(JClassPtr cls, JMethodIDPtr methodId, + int isStatic)>()(cls, methodId, isStatic) + .object; + + JClassPtr GetSuperclass(JClassPtr clazz) => ref.GetSuperclass.asFunction< + JniClassLookupResult Function(JClassPtr clazz)>()(clazz) + .value; + + bool IsAssignableFrom(JClassPtr clazz1, JClassPtr clazz2) => + ref.IsAssignableFrom.asFunction< + JniResult Function( + JClassPtr clazz1, JClassPtr clazz2)>()(clazz1, clazz2) + .boolean; + + JObjectPtr ToReflectedField( + JClassPtr cls, JFieldIDPtr fieldID, int isStatic) => + ref.ToReflectedField.asFunction< + JniResult Function(JClassPtr cls, JFieldIDPtr fieldID, + int isStatic)>()(cls, fieldID, isStatic) + .object; + + int Throw(JThrowablePtr obj) => + ref.Throw.asFunction()(obj) + .integer; + + int ThrowNew(JClassPtr clazz, ffi.Pointer message) => + ref.ThrowNew.asFunction< + JniResult Function(JClassPtr clazz, + ffi.Pointer message)>()(clazz, message) + .integer; + + JThrowablePtr ExceptionOccurred() => + ref.ExceptionOccurred.asFunction()().object; + + void ExceptionDescribe() => + ref.ExceptionDescribe.asFunction()().check(); + + void ExceptionClear() => + ref.ExceptionClear.asFunction()().check(); + + void FatalError(ffi.Pointer msg) => ref.FatalError.asFunction< + JThrowablePtr Function(ffi.Pointer msg)>()(msg) + .check(); + + int PushLocalFrame(int capacity) => + ref.PushLocalFrame.asFunction()( + capacity) + .integer; + + JObjectPtr PopLocalFrame(JObjectPtr result) => + ref.PopLocalFrame.asFunction()( + result) + .object; + + JObjectPtr NewGlobalRef(JObjectPtr obj) => + ref.NewGlobalRef.asFunction()(obj) + .object; + + void DeleteGlobalRef(JObjectPtr globalRef) => ref.DeleteGlobalRef.asFunction< + JThrowablePtr Function(JObjectPtr globalRef)>()(globalRef) + .check(); + + void DeleteLocalRef(JObjectPtr localRef) => ref.DeleteLocalRef.asFunction< + JThrowablePtr Function(JObjectPtr localRef)>()(localRef) + .check(); + + bool IsSameObject(JObjectPtr ref1, JObjectPtr ref2) => + ref.IsSameObject.asFunction< + JniResult Function( + JObjectPtr ref1, JObjectPtr ref2)>()(ref1, ref2) + .boolean; + + JObjectPtr NewLocalRef(JObjectPtr obj) => + ref.NewLocalRef.asFunction()(obj) + .object; + + int EnsureLocalCapacity(int capacity) => + ref.EnsureLocalCapacity.asFunction()( + capacity) + .integer; + + JObjectPtr AllocObject(JClassPtr clazz) => + ref.AllocObject.asFunction()(clazz) + .object; + + JObjectPtr NewObject(JClassPtr clazz, JMethodIDPtr methodID) => + ref.NewObject.asFunction< + JniResult Function( + JClassPtr clazz, JMethodIDPtr methodID)>()(clazz, methodID) + .object; + + JObjectPtr NewObjectA( + JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => + ref.NewObjectA.asFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>()(clazz, methodID, args) + .object; + + JClassPtr GetObjectClass(JObjectPtr obj) => ref.GetObjectClass.asFunction< + JniClassLookupResult Function(JObjectPtr obj)>()(obj) + .value; + + bool IsInstanceOf(JObjectPtr obj, JClassPtr clazz) => + ref.IsInstanceOf.asFunction< + JniResult Function(JObjectPtr obj, JClassPtr clazz)>()(obj, clazz) + .boolean; + + JMethodIDPtr GetMethodID(JClassPtr clazz, ffi.Pointer name, + ffi.Pointer sig) => + ref.GetMethodID.asFunction< + JniPointerResult Function( + JClassPtr clazz, + ffi.Pointer name, + ffi.Pointer sig)>()(clazz, name, sig) + .methodID; + + JObjectPtr CallObjectMethod(JObjectPtr obj, JMethodIDPtr methodID) => + ref.CallObjectMethod.asFunction< + JniResult Function( + JObjectPtr obj, JMethodIDPtr methodID)>()(obj, methodID) + .object; + + JObjectPtr CallObjectMethodA( + JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) => + ref.CallObjectMethodA.asFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Pointer args)>()(obj, methodID, args) + .object; + + bool CallBooleanMethod(JObjectPtr obj, JMethodIDPtr methodID) => + ref.CallBooleanMethod.asFunction< + JniResult Function( + JObjectPtr obj, JMethodIDPtr methodID)>()(obj, methodID) + .boolean; + + bool CallBooleanMethodA( + JObjectPtr obj, JMethodIDPtr methodId, ffi.Pointer args) => + ref.CallBooleanMethodA.asFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodId, + ffi.Pointer args)>()(obj, methodId, args) + .boolean; + + int CallByteMethod(JObjectPtr obj, JMethodIDPtr methodID) => + ref.CallByteMethod.asFunction< + JniResult Function( + JObjectPtr obj, JMethodIDPtr methodID)>()(obj, methodID) + .byte; + + int CallByteMethodA( + JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) => + ref.CallByteMethodA.asFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Pointer args)>()(obj, methodID, args) + .byte; + + int CallCharMethod(JObjectPtr obj, JMethodIDPtr methodID) => + ref.CallCharMethod.asFunction< + JniResult Function( + JObjectPtr obj, JMethodIDPtr methodID)>()(obj, methodID) + .char; + + int CallCharMethodA( + JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) => + ref.CallCharMethodA.asFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Pointer args)>()(obj, methodID, args) + .char; + + int CallShortMethod(JObjectPtr obj, JMethodIDPtr methodID) => + ref.CallShortMethod.asFunction< + JniResult Function( + JObjectPtr obj, JMethodIDPtr methodID)>()(obj, methodID) + .short; + + int CallShortMethodA( + JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) => + ref.CallShortMethodA.asFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Pointer args)>()(obj, methodID, args) + .short; + + int CallIntMethod(JObjectPtr obj, JMethodIDPtr methodID) => + ref.CallIntMethod.asFunction< + JniResult Function( + JObjectPtr obj, JMethodIDPtr methodID)>()(obj, methodID) + .integer; + + int CallIntMethodA( + JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) => + ref.CallIntMethodA.asFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Pointer args)>()(obj, methodID, args) + .integer; + + int CallLongMethod(JObjectPtr obj, JMethodIDPtr methodID) => + ref.CallLongMethod.asFunction< + JniResult Function( + JObjectPtr obj, JMethodIDPtr methodID)>()(obj, methodID) + .long; + + int CallLongMethodA( + JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) => + ref.CallLongMethodA.asFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Pointer args)>()(obj, methodID, args) + .long; + + double CallFloatMethod(JObjectPtr obj, JMethodIDPtr methodID) => + ref.CallFloatMethod.asFunction< + JniResult Function( + JObjectPtr obj, JMethodIDPtr methodID)>()(obj, methodID) + .float; + + double CallFloatMethodA( + JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) => + ref.CallFloatMethodA.asFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Pointer args)>()(obj, methodID, args) + .float; + + double CallDoubleMethod(JObjectPtr obj, JMethodIDPtr methodID) => + ref.CallDoubleMethod.asFunction< + JniResult Function( + JObjectPtr obj, JMethodIDPtr methodID)>()(obj, methodID) + .doubleFloat; + + double CallDoubleMethodA( + JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) => + ref.CallDoubleMethodA.asFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Pointer args)>()(obj, methodID, args) + .doubleFloat; + + void CallVoidMethod(JObjectPtr obj, JMethodIDPtr methodID) => + ref.CallVoidMethod.asFunction< + JThrowablePtr Function( + JObjectPtr obj, JMethodIDPtr methodID)>()(obj, methodID) + .check(); + + void CallVoidMethodA( + JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) => + ref.CallVoidMethodA.asFunction< + JThrowablePtr Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Pointer args)>()(obj, methodID, args) + .check(); + + JObjectPtr CallNonvirtualObjectMethod( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => + ref.CallNonvirtualObjectMethod.asFunction< + JniResult Function(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID)>()(obj, clazz, methodID) + .object; + + JObjectPtr CallNonvirtualObjectMethodA(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args) => + ref.CallNonvirtualObjectMethodA.asFunction< + JniResult Function( + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>()(obj, clazz, methodID, args) + .object; + + bool CallNonvirtualBooleanMethod( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => + ref.CallNonvirtualBooleanMethod.asFunction< + JniResult Function(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID)>()(obj, clazz, methodID) + .boolean; + + bool CallNonvirtualBooleanMethodA(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args) => + ref.CallNonvirtualBooleanMethodA.asFunction< + JniResult Function( + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>()(obj, clazz, methodID, args) + .boolean; + + int CallNonvirtualByteMethod( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => + ref.CallNonvirtualByteMethod.asFunction< + JniResult Function(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID)>()(obj, clazz, methodID) + .byte; + + int CallNonvirtualByteMethodA(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args) => + ref.CallNonvirtualByteMethodA.asFunction< + JniResult Function( + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>()(obj, clazz, methodID, args) + .byte; + + int CallNonvirtualCharMethod( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => + ref.CallNonvirtualCharMethod.asFunction< + JniResult Function(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID)>()(obj, clazz, methodID) + .char; + + int CallNonvirtualCharMethodA(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args) => + ref.CallNonvirtualCharMethodA.asFunction< + JniResult Function( + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>()(obj, clazz, methodID, args) + .char; + + int CallNonvirtualShortMethod( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => + ref.CallNonvirtualShortMethod.asFunction< + JniResult Function(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID)>()(obj, clazz, methodID) + .short; + + int CallNonvirtualShortMethodA(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args) => + ref.CallNonvirtualShortMethodA.asFunction< + JniResult Function( + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>()(obj, clazz, methodID, args) + .short; + + int CallNonvirtualIntMethod( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => + ref.CallNonvirtualIntMethod.asFunction< + JniResult Function(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID)>()(obj, clazz, methodID) + .integer; + + int CallNonvirtualIntMethodA(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args) => + ref.CallNonvirtualIntMethodA.asFunction< + JniResult Function( + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>()(obj, clazz, methodID, args) + .integer; + + int CallNonvirtualLongMethod( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => + ref.CallNonvirtualLongMethod.asFunction< + JniResult Function(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID)>()(obj, clazz, methodID) + .long; + + int CallNonvirtualLongMethodA(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args) => + ref.CallNonvirtualLongMethodA.asFunction< + JniResult Function( + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>()(obj, clazz, methodID, args) + .long; + + double CallNonvirtualFloatMethod( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => + ref.CallNonvirtualFloatMethod.asFunction< + JniResult Function(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID)>()(obj, clazz, methodID) + .float; + + double CallNonvirtualFloatMethodA(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args) => + ref.CallNonvirtualFloatMethodA.asFunction< + JniResult Function( + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>()(obj, clazz, methodID, args) + .float; + + double CallNonvirtualDoubleMethod( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => + ref.CallNonvirtualDoubleMethod.asFunction< + JniResult Function(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID)>()(obj, clazz, methodID) + .doubleFloat; + + double CallNonvirtualDoubleMethodA(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args) => + ref.CallNonvirtualDoubleMethodA.asFunction< + JniResult Function( + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>()(obj, clazz, methodID, args) + .doubleFloat; + + void CallNonvirtualVoidMethod( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => + ref.CallNonvirtualVoidMethod.asFunction< + JThrowablePtr Function(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID)>()(obj, clazz, methodID) + .check(); + + void CallNonvirtualVoidMethodA(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args) => + ref.CallNonvirtualVoidMethodA.asFunction< + JThrowablePtr Function( + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>()(obj, clazz, methodID, args) + .check(); + + JFieldIDPtr GetFieldID(JClassPtr clazz, ffi.Pointer name, + ffi.Pointer sig) => + ref.GetFieldID.asFunction< + JniPointerResult Function( + JClassPtr clazz, + ffi.Pointer name, + ffi.Pointer sig)>()(clazz, name, sig) + .fieldID; + + JObjectPtr GetObjectField(JObjectPtr obj, JFieldIDPtr fieldID) => + ref.GetObjectField.asFunction< + JniResult Function( + JObjectPtr obj, JFieldIDPtr fieldID)>()(obj, fieldID) + .object; + + bool GetBooleanField(JObjectPtr obj, JFieldIDPtr fieldID) => + ref.GetBooleanField.asFunction< + JniResult Function( + JObjectPtr obj, JFieldIDPtr fieldID)>()(obj, fieldID) + .boolean; + + int GetByteField(JObjectPtr obj, JFieldIDPtr fieldID) => + ref.GetByteField.asFunction< + JniResult Function( + JObjectPtr obj, JFieldIDPtr fieldID)>()(obj, fieldID) + .byte; + + int GetCharField(JObjectPtr obj, JFieldIDPtr fieldID) => + ref.GetCharField.asFunction< + JniResult Function( + JObjectPtr obj, JFieldIDPtr fieldID)>()(obj, fieldID) + .char; + + int GetShortField(JObjectPtr obj, JFieldIDPtr fieldID) => + ref.GetShortField.asFunction< + JniResult Function( + JObjectPtr obj, JFieldIDPtr fieldID)>()(obj, fieldID) + .short; + + int GetIntField(JObjectPtr obj, JFieldIDPtr fieldID) => + ref.GetIntField.asFunction< + JniResult Function( + JObjectPtr obj, JFieldIDPtr fieldID)>()(obj, fieldID) + .integer; + + int GetLongField(JObjectPtr obj, JFieldIDPtr fieldID) => + ref.GetLongField.asFunction< + JniResult Function( + JObjectPtr obj, JFieldIDPtr fieldID)>()(obj, fieldID) + .long; + + double GetFloatField(JObjectPtr obj, JFieldIDPtr fieldID) => + ref.GetFloatField.asFunction< + JniResult Function( + JObjectPtr obj, JFieldIDPtr fieldID)>()(obj, fieldID) + .float; + + double GetDoubleField(JObjectPtr obj, JFieldIDPtr fieldID) => + ref.GetDoubleField.asFunction< + JniResult Function( + JObjectPtr obj, JFieldIDPtr fieldID)>()(obj, fieldID) + .doubleFloat; + + void SetObjectField(JObjectPtr obj, JFieldIDPtr fieldID, JObjectPtr val) => + ref.SetObjectField.asFunction< + JThrowablePtr Function(JObjectPtr obj, JFieldIDPtr fieldID, + JObjectPtr val)>()(obj, fieldID, val) + .check(); + + void SetBooleanField(JObjectPtr obj, JFieldIDPtr fieldID, int val) => + ref.SetBooleanField.asFunction< + JThrowablePtr Function(JObjectPtr obj, JFieldIDPtr fieldID, + int val)>()(obj, fieldID, val) + .check(); + + void SetByteField(JObjectPtr obj, JFieldIDPtr fieldID, int val) => + ref.SetByteField.asFunction< + JThrowablePtr Function(JObjectPtr obj, JFieldIDPtr fieldID, + int val)>()(obj, fieldID, val) + .check(); + + void SetCharField(JObjectPtr obj, JFieldIDPtr fieldID, int val) => + ref.SetCharField.asFunction< + JThrowablePtr Function(JObjectPtr obj, JFieldIDPtr fieldID, + int val)>()(obj, fieldID, val) + .check(); + + void SetShortField(JObjectPtr obj, JFieldIDPtr fieldID, int val) => + ref.SetShortField.asFunction< + JThrowablePtr Function(JObjectPtr obj, JFieldIDPtr fieldID, + int val)>()(obj, fieldID, val) + .check(); + + void SetIntField(JObjectPtr obj, JFieldIDPtr fieldID, int val) => + ref.SetIntField.asFunction< + JThrowablePtr Function(JObjectPtr obj, JFieldIDPtr fieldID, + int val)>()(obj, fieldID, val) + .check(); + + void SetLongField(JObjectPtr obj, JFieldIDPtr fieldID, int val) => + ref.SetLongField.asFunction< + JThrowablePtr Function(JObjectPtr obj, JFieldIDPtr fieldID, + int val)>()(obj, fieldID, val) + .check(); + + void SetFloatField(JObjectPtr obj, JFieldIDPtr fieldID, double val) => + ref.SetFloatField.asFunction< + JThrowablePtr Function(JObjectPtr obj, JFieldIDPtr fieldID, + double val)>()(obj, fieldID, val) + .check(); + + void SetDoubleField(JObjectPtr obj, JFieldIDPtr fieldID, double val) => + ref.SetDoubleField.asFunction< + JThrowablePtr Function(JObjectPtr obj, JFieldIDPtr fieldID, + double val)>()(obj, fieldID, val) + .check(); + + JMethodIDPtr GetStaticMethodID(JClassPtr clazz, ffi.Pointer name, + ffi.Pointer sig) => + ref.GetStaticMethodID.asFunction< + JniPointerResult Function( + JClassPtr clazz, + ffi.Pointer name, + ffi.Pointer sig)>()(clazz, name, sig) + .methodID; + + JObjectPtr CallStaticObjectMethod(JClassPtr clazz, JMethodIDPtr methodID) => + ref.CallStaticObjectMethod.asFunction< + JniResult Function( + JClassPtr clazz, JMethodIDPtr methodID)>()(clazz, methodID) + .object; + + JObjectPtr CallStaticObjectMethodA( + JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => + ref.CallStaticObjectMethodA.asFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>()(clazz, methodID, args) + .object; + + bool CallStaticBooleanMethod(JClassPtr clazz, JMethodIDPtr methodID) => + ref.CallStaticBooleanMethod.asFunction< + JniResult Function( + JClassPtr clazz, JMethodIDPtr methodID)>()(clazz, methodID) + .boolean; + + bool CallStaticBooleanMethodA( + JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => + ref.CallStaticBooleanMethodA.asFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>()(clazz, methodID, args) + .boolean; + + int CallStaticByteMethod(JClassPtr clazz, JMethodIDPtr methodID) => + ref.CallStaticByteMethod.asFunction< + JniResult Function( + JClassPtr clazz, JMethodIDPtr methodID)>()(clazz, methodID) + .byte; + + int CallStaticByteMethodA( + JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => + ref.CallStaticByteMethodA.asFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>()(clazz, methodID, args) + .byte; + + int CallStaticCharMethod(JClassPtr clazz, JMethodIDPtr methodID) => + ref.CallStaticCharMethod.asFunction< + JniResult Function( + JClassPtr clazz, JMethodIDPtr methodID)>()(clazz, methodID) + .char; + + int CallStaticCharMethodA( + JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => + ref.CallStaticCharMethodA.asFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>()(clazz, methodID, args) + .char; + + int CallStaticShortMethod(JClassPtr clazz, JMethodIDPtr methodID) => + ref.CallStaticShortMethod.asFunction< + JniResult Function( + JClassPtr clazz, JMethodIDPtr methodID)>()(clazz, methodID) + .short; + + int CallStaticShortMethodA( + JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => + ref.CallStaticShortMethodA.asFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>()(clazz, methodID, args) + .short; + + int CallStaticIntMethod(JClassPtr clazz, JMethodIDPtr methodID) => + ref.CallStaticIntMethod.asFunction< + JniResult Function( + JClassPtr clazz, JMethodIDPtr methodID)>()(clazz, methodID) + .integer; + + int CallStaticIntMethodA( + JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => + ref.CallStaticIntMethodA.asFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>()(clazz, methodID, args) + .integer; + + int CallStaticLongMethod(JClassPtr clazz, JMethodIDPtr methodID) => + ref.CallStaticLongMethod.asFunction< + JniResult Function( + JClassPtr clazz, JMethodIDPtr methodID)>()(clazz, methodID) + .long; + + int CallStaticLongMethodA( + JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => + ref.CallStaticLongMethodA.asFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>()(clazz, methodID, args) + .long; + + double CallStaticFloatMethod(JClassPtr clazz, JMethodIDPtr methodID) => + ref.CallStaticFloatMethod.asFunction< + JniResult Function( + JClassPtr clazz, JMethodIDPtr methodID)>()(clazz, methodID) + .float; + + double CallStaticFloatMethodA( + JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => + ref.CallStaticFloatMethodA.asFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>()(clazz, methodID, args) + .float; + + double CallStaticDoubleMethod(JClassPtr clazz, JMethodIDPtr methodID) => + ref.CallStaticDoubleMethod.asFunction< + JniResult Function( + JClassPtr clazz, JMethodIDPtr methodID)>()(clazz, methodID) + .doubleFloat; + + double CallStaticDoubleMethodA( + JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => + ref.CallStaticDoubleMethodA.asFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>()(clazz, methodID, args) + .doubleFloat; + + void CallStaticVoidMethod(JClassPtr clazz, JMethodIDPtr methodID) => + ref.CallStaticVoidMethod.asFunction< + JThrowablePtr Function( + JClassPtr clazz, JMethodIDPtr methodID)>()(clazz, methodID) + .check(); + + void CallStaticVoidMethodA( + JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => + ref.CallStaticVoidMethodA.asFunction< + JThrowablePtr Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>()(clazz, methodID, args) + .check(); + + JFieldIDPtr GetStaticFieldID(JClassPtr clazz, ffi.Pointer name, + ffi.Pointer sig) => + ref.GetStaticFieldID.asFunction< + JniPointerResult Function( + JClassPtr clazz, + ffi.Pointer name, + ffi.Pointer sig)>()(clazz, name, sig) + .fieldID; + + JObjectPtr GetStaticObjectField(JClassPtr clazz, JFieldIDPtr fieldID) => + ref.GetStaticObjectField.asFunction< + JniResult Function( + JClassPtr clazz, JFieldIDPtr fieldID)>()(clazz, fieldID) + .object; + + bool GetStaticBooleanField(JClassPtr clazz, JFieldIDPtr fieldID) => + ref.GetStaticBooleanField.asFunction< + JniResult Function( + JClassPtr clazz, JFieldIDPtr fieldID)>()(clazz, fieldID) + .boolean; + + int GetStaticByteField(JClassPtr clazz, JFieldIDPtr fieldID) => + ref.GetStaticByteField.asFunction< + JniResult Function( + JClassPtr clazz, JFieldIDPtr fieldID)>()(clazz, fieldID) + .byte; + + int GetStaticCharField(JClassPtr clazz, JFieldIDPtr fieldID) => + ref.GetStaticCharField.asFunction< + JniResult Function( + JClassPtr clazz, JFieldIDPtr fieldID)>()(clazz, fieldID) + .char; + + int GetStaticShortField(JClassPtr clazz, JFieldIDPtr fieldID) => + ref.GetStaticShortField.asFunction< + JniResult Function( + JClassPtr clazz, JFieldIDPtr fieldID)>()(clazz, fieldID) + .short; + + int GetStaticIntField(JClassPtr clazz, JFieldIDPtr fieldID) => + ref.GetStaticIntField.asFunction< + JniResult Function( + JClassPtr clazz, JFieldIDPtr fieldID)>()(clazz, fieldID) + .integer; + + int GetStaticLongField(JClassPtr clazz, JFieldIDPtr fieldID) => + ref.GetStaticLongField.asFunction< + JniResult Function( + JClassPtr clazz, JFieldIDPtr fieldID)>()(clazz, fieldID) + .long; + + double GetStaticFloatField(JClassPtr clazz, JFieldIDPtr fieldID) => + ref.GetStaticFloatField.asFunction< + JniResult Function( + JClassPtr clazz, JFieldIDPtr fieldID)>()(clazz, fieldID) + .float; + + double GetStaticDoubleField(JClassPtr clazz, JFieldIDPtr fieldID) => + ref.GetStaticDoubleField.asFunction< + JniResult Function( + JClassPtr clazz, JFieldIDPtr fieldID)>()(clazz, fieldID) + .doubleFloat; + + void SetStaticObjectField( + JClassPtr clazz, JFieldIDPtr fieldID, JObjectPtr val) => + ref.SetStaticObjectField.asFunction< + JThrowablePtr Function(JClassPtr clazz, JFieldIDPtr fieldID, + JObjectPtr val)>()(clazz, fieldID, val) + .check(); + + void SetStaticBooleanField(JClassPtr clazz, JFieldIDPtr fieldID, int val) => + ref.SetStaticBooleanField.asFunction< + JThrowablePtr Function(JClassPtr clazz, JFieldIDPtr fieldID, + int val)>()(clazz, fieldID, val) + .check(); + + void SetStaticByteField(JClassPtr clazz, JFieldIDPtr fieldID, int val) => + ref.SetStaticByteField.asFunction< + JThrowablePtr Function(JClassPtr clazz, JFieldIDPtr fieldID, + int val)>()(clazz, fieldID, val) + .check(); + + void SetStaticCharField(JClassPtr clazz, JFieldIDPtr fieldID, int val) => + ref.SetStaticCharField.asFunction< + JThrowablePtr Function(JClassPtr clazz, JFieldIDPtr fieldID, + int val)>()(clazz, fieldID, val) + .check(); + + void SetStaticShortField(JClassPtr clazz, JFieldIDPtr fieldID, int val) => + ref.SetStaticShortField.asFunction< + JThrowablePtr Function(JClassPtr clazz, JFieldIDPtr fieldID, + int val)>()(clazz, fieldID, val) + .check(); + + void SetStaticIntField(JClassPtr clazz, JFieldIDPtr fieldID, int val) => + ref.SetStaticIntField.asFunction< + JThrowablePtr Function(JClassPtr clazz, JFieldIDPtr fieldID, + int val)>()(clazz, fieldID, val) + .check(); + + void SetStaticLongField(JClassPtr clazz, JFieldIDPtr fieldID, int val) => + ref.SetStaticLongField.asFunction< + JThrowablePtr Function(JClassPtr clazz, JFieldIDPtr fieldID, + int val)>()(clazz, fieldID, val) + .check(); + + void SetStaticFloatField(JClassPtr clazz, JFieldIDPtr fieldID, double val) => + ref.SetStaticFloatField.asFunction< + JThrowablePtr Function(JClassPtr clazz, JFieldIDPtr fieldID, + double val)>()(clazz, fieldID, val) + .check(); + + void SetStaticDoubleField(JClassPtr clazz, JFieldIDPtr fieldID, double val) => + ref.SetStaticDoubleField.asFunction< + JThrowablePtr Function(JClassPtr clazz, JFieldIDPtr fieldID, + double val)>()(clazz, fieldID, val) + .check(); + + JStringPtr NewString(ffi.Pointer unicodeChars, int len) => + ref.NewString.asFunction< + JniResult Function(ffi.Pointer unicodeChars, + int len)>()(unicodeChars, len) + .object; + + int GetStringLength(JStringPtr string) => + ref.GetStringLength.asFunction()( + string) + .integer; + + ffi.Pointer GetStringChars( + JStringPtr string, ffi.Pointer isCopy) => + ref.GetStringChars.asFunction< + JniPointerResult Function(JStringPtr string, + ffi.Pointer isCopy)>()(string, isCopy) + .getPointer(); + + void ReleaseStringChars(JStringPtr string, ffi.Pointer isCopy) => + ref.ReleaseStringChars.asFunction< + JThrowablePtr Function(JStringPtr string, + ffi.Pointer isCopy)>()(string, isCopy) + .check(); + + JStringPtr NewStringUTF(ffi.Pointer bytes) => ref.NewStringUTF + .asFunction bytes)>()(bytes) + .object; + + int GetStringUTFLength(JStringPtr string) => ref.GetStringUTFLength + .asFunction()(string) + .integer; + + ffi.Pointer GetStringUTFChars( + JStringPtr string, ffi.Pointer isCopy) => + ref.GetStringUTFChars.asFunction< + JniPointerResult Function(JStringPtr string, + ffi.Pointer isCopy)>()(string, isCopy) + .getPointer(); + + void ReleaseStringUTFChars(JStringPtr string, ffi.Pointer utf) => + ref.ReleaseStringUTFChars.asFunction< + JThrowablePtr Function( + JStringPtr string, ffi.Pointer utf)>()(string, utf) + .check(); + + int GetArrayLength(JArrayPtr array) => + ref.GetArrayLength.asFunction()( + array) + .integer; + + JObjectArrayPtr NewObjectArray( + int length, JClassPtr elementClass, JObjectPtr initialElement) => + ref.NewObjectArray.asFunction< + JniResult Function(int length, JClassPtr elementClass, + JObjectPtr initialElement)>()( + length, elementClass, initialElement) + .object; + + JObjectPtr GetObjectArrayElement(JObjectArrayPtr array, int index) => + ref.GetObjectArrayElement.asFunction< + JniResult Function( + JObjectArrayPtr array, int index)>()(array, index) + .object; + + void SetObjectArrayElement( + JObjectArrayPtr array, int index, JObjectPtr val) => + ref.SetObjectArrayElement.asFunction< + JThrowablePtr Function(JObjectArrayPtr array, int index, + JObjectPtr val)>()(array, index, val) + .check(); + + JBooleanArrayPtr NewBooleanArray(int length) => + ref.NewBooleanArray.asFunction()(length) + .object; + + JByteArrayPtr NewByteArray(int length) => + ref.NewByteArray.asFunction()(length) + .object; + + JCharArrayPtr NewCharArray(int length) => + ref.NewCharArray.asFunction()(length) + .object; + + JShortArrayPtr NewShortArray(int length) => + ref.NewShortArray.asFunction()(length) + .object; + + JIntArrayPtr NewIntArray(int length) => + ref.NewIntArray.asFunction()(length) + .object; + + JLongArrayPtr NewLongArray(int length) => + ref.NewLongArray.asFunction()(length) + .object; + + JFloatArrayPtr NewFloatArray(int length) => + ref.NewFloatArray.asFunction()(length) + .object; + + JDoubleArrayPtr NewDoubleArray(int length) => + ref.NewDoubleArray.asFunction()(length) + .object; + + ffi.Pointer GetBooleanArrayElements( + JBooleanArrayPtr array, ffi.Pointer isCopy) => + ref.GetBooleanArrayElements.asFunction< + JniPointerResult Function(JBooleanArrayPtr array, + ffi.Pointer isCopy)>()(array, isCopy) + .getPointer(); + + ffi.Pointer GetByteArrayElements( + JByteArrayPtr array, ffi.Pointer isCopy) => + ref.GetByteArrayElements.asFunction< + JniPointerResult Function(JByteArrayPtr array, + ffi.Pointer isCopy)>()(array, isCopy) + .getPointer(); + + ffi.Pointer GetCharArrayElements( + JCharArrayPtr array, ffi.Pointer isCopy) => + ref.GetCharArrayElements.asFunction< + JniPointerResult Function(JCharArrayPtr array, + ffi.Pointer isCopy)>()(array, isCopy) + .getPointer(); + + ffi.Pointer GetShortArrayElements( + JShortArrayPtr array, ffi.Pointer isCopy) => + ref.GetShortArrayElements.asFunction< + JniPointerResult Function(JShortArrayPtr array, + ffi.Pointer isCopy)>()(array, isCopy) + .getPointer(); + + ffi.Pointer GetIntArrayElements( + JIntArrayPtr array, ffi.Pointer isCopy) => + ref.GetIntArrayElements.asFunction< + JniPointerResult Function(JIntArrayPtr array, + ffi.Pointer isCopy)>()(array, isCopy) + .getPointer(); + + ffi.Pointer GetLongArrayElements( + JLongArrayPtr array, ffi.Pointer isCopy) => + ref.GetLongArrayElements.asFunction< + JniPointerResult Function(JLongArrayPtr array, + ffi.Pointer isCopy)>()(array, isCopy) + .getPointer(); + + ffi.Pointer GetFloatArrayElements( + JFloatArrayPtr array, ffi.Pointer isCopy) => + ref.GetFloatArrayElements.asFunction< + JniPointerResult Function(JFloatArrayPtr array, + ffi.Pointer isCopy)>()(array, isCopy) + .getPointer(); + + ffi.Pointer GetDoubleArrayElements( + JDoubleArrayPtr array, ffi.Pointer isCopy) => + ref.GetDoubleArrayElements.asFunction< + JniPointerResult Function(JDoubleArrayPtr array, + ffi.Pointer isCopy)>()(array, isCopy) + .getPointer(); + + void ReleaseBooleanArrayElements(JBooleanArrayPtr array, + ffi.Pointer elems, int mode) => + ref.ReleaseBooleanArrayElements.asFunction< + JThrowablePtr Function( + JBooleanArrayPtr array, + ffi.Pointer elems, + int mode)>()(array, elems, mode) + .check(); + + void ReleaseByteArrayElements( + JByteArrayPtr array, ffi.Pointer elems, int mode) => + ref.ReleaseByteArrayElements.asFunction< + JThrowablePtr Function( + JByteArrayPtr array, + ffi.Pointer elems, + int mode)>()(array, elems, mode) + .check(); + + void ReleaseCharArrayElements( + JCharArrayPtr array, ffi.Pointer elems, int mode) => + ref.ReleaseCharArrayElements.asFunction< + JThrowablePtr Function( + JCharArrayPtr array, + ffi.Pointer elems, + int mode)>()(array, elems, mode) + .check(); + + void ReleaseShortArrayElements( + JShortArrayPtr array, ffi.Pointer elems, int mode) => + ref.ReleaseShortArrayElements.asFunction< + JThrowablePtr Function( + JShortArrayPtr array, + ffi.Pointer elems, + int mode)>()(array, elems, mode) + .check(); + + void ReleaseIntArrayElements( + JIntArrayPtr array, ffi.Pointer elems, int mode) => + ref.ReleaseIntArrayElements.asFunction< + JThrowablePtr Function( + JIntArrayPtr array, + ffi.Pointer elems, + int mode)>()(array, elems, mode) + .check(); + + void ReleaseLongArrayElements( + JLongArrayPtr array, ffi.Pointer elems, int mode) => + ref.ReleaseLongArrayElements.asFunction< + JThrowablePtr Function( + JLongArrayPtr array, + ffi.Pointer elems, + int mode)>()(array, elems, mode) + .check(); + + void ReleaseFloatArrayElements( + JFloatArrayPtr array, ffi.Pointer elems, int mode) => + ref.ReleaseFloatArrayElements.asFunction< + JThrowablePtr Function( + JFloatArrayPtr array, + ffi.Pointer elems, + int mode)>()(array, elems, mode) + .check(); + + void ReleaseDoubleArrayElements( + JDoubleArrayPtr array, ffi.Pointer elems, int mode) => + ref.ReleaseDoubleArrayElements.asFunction< + JThrowablePtr Function( + JDoubleArrayPtr array, + ffi.Pointer elems, + int mode)>()(array, elems, mode) + .check(); + + void GetBooleanArrayRegion(JBooleanArrayPtr array, int start, int len, + ffi.Pointer buf) => + ref.GetBooleanArrayRegion.asFunction< + JThrowablePtr Function(JBooleanArrayPtr array, int start, int len, + ffi.Pointer buf)>()(array, start, len, buf) + .check(); + + void GetByteArrayRegion(JByteArrayPtr array, int start, int len, + ffi.Pointer buf) => + ref.GetByteArrayRegion.asFunction< + JThrowablePtr Function(JByteArrayPtr array, int start, int len, + ffi.Pointer buf)>()(array, start, len, buf) + .check(); + + void GetCharArrayRegion(JCharArrayPtr array, int start, int len, + ffi.Pointer buf) => + ref.GetCharArrayRegion.asFunction< + JThrowablePtr Function(JCharArrayPtr array, int start, int len, + ffi.Pointer buf)>()(array, start, len, buf) + .check(); + + void GetShortArrayRegion(JShortArrayPtr array, int start, int len, + ffi.Pointer buf) => + ref.GetShortArrayRegion.asFunction< + JThrowablePtr Function(JShortArrayPtr array, int start, int len, + ffi.Pointer buf)>()(array, start, len, buf) + .check(); + + void GetIntArrayRegion(JIntArrayPtr array, int start, int len, + ffi.Pointer buf) => + ref.GetIntArrayRegion.asFunction< + JThrowablePtr Function(JIntArrayPtr array, int start, int len, + ffi.Pointer buf)>()(array, start, len, buf) + .check(); + + void GetLongArrayRegion(JLongArrayPtr array, int start, int len, + ffi.Pointer buf) => + ref.GetLongArrayRegion.asFunction< + JThrowablePtr Function(JLongArrayPtr array, int start, int len, + ffi.Pointer buf)>()(array, start, len, buf) + .check(); + + void GetFloatArrayRegion(JFloatArrayPtr array, int start, int len, + ffi.Pointer buf) => + ref.GetFloatArrayRegion.asFunction< + JThrowablePtr Function(JFloatArrayPtr array, int start, int len, + ffi.Pointer buf)>()(array, start, len, buf) + .check(); + + void GetDoubleArrayRegion(JDoubleArrayPtr array, int start, int len, + ffi.Pointer buf) => + ref.GetDoubleArrayRegion.asFunction< + JThrowablePtr Function(JDoubleArrayPtr array, int start, int len, + ffi.Pointer buf)>()(array, start, len, buf) + .check(); + + void SetBooleanArrayRegion(JBooleanArrayPtr array, int start, int len, + ffi.Pointer buf) => + ref.SetBooleanArrayRegion.asFunction< + JThrowablePtr Function(JBooleanArrayPtr array, int start, int len, + ffi.Pointer buf)>()(array, start, len, buf) + .check(); + + void SetByteArrayRegion(JByteArrayPtr array, int start, int len, + ffi.Pointer buf) => + ref.SetByteArrayRegion.asFunction< + JThrowablePtr Function(JByteArrayPtr array, int start, int len, + ffi.Pointer buf)>()(array, start, len, buf) + .check(); + + void SetCharArrayRegion(JCharArrayPtr array, int start, int len, + ffi.Pointer buf) => + ref.SetCharArrayRegion.asFunction< + JThrowablePtr Function(JCharArrayPtr array, int start, int len, + ffi.Pointer buf)>()(array, start, len, buf) + .check(); + + void SetShortArrayRegion(JShortArrayPtr array, int start, int len, + ffi.Pointer buf) => + ref.SetShortArrayRegion.asFunction< + JThrowablePtr Function(JShortArrayPtr array, int start, int len, + ffi.Pointer buf)>()(array, start, len, buf) + .check(); + + void SetIntArrayRegion(JIntArrayPtr array, int start, int len, + ffi.Pointer buf) => + ref.SetIntArrayRegion.asFunction< + JThrowablePtr Function(JIntArrayPtr array, int start, int len, + ffi.Pointer buf)>()(array, start, len, buf) + .check(); + + void SetLongArrayRegion(JLongArrayPtr array, int start, int len, + ffi.Pointer buf) => + ref.SetLongArrayRegion.asFunction< + JThrowablePtr Function(JLongArrayPtr array, int start, int len, + ffi.Pointer buf)>()(array, start, len, buf) + .check(); + + void SetFloatArrayRegion(JFloatArrayPtr array, int start, int len, + ffi.Pointer buf) => + ref.SetFloatArrayRegion.asFunction< + JThrowablePtr Function(JFloatArrayPtr array, int start, int len, + ffi.Pointer buf)>()(array, start, len, buf) + .check(); + + void SetDoubleArrayRegion(JDoubleArrayPtr array, int start, int len, + ffi.Pointer buf) => + ref.SetDoubleArrayRegion.asFunction< + JThrowablePtr Function(JDoubleArrayPtr array, int start, int len, + ffi.Pointer buf)>()(array, start, len, buf) + .check(); + + int RegisterNatives(JClassPtr clazz, ffi.Pointer methods, + int nMethods) => + ref.RegisterNatives.asFunction< + JniResult Function( + JClassPtr clazz, + ffi.Pointer methods, + int nMethods)>()(clazz, methods, nMethods) + .integer; + + int UnregisterNatives(JClassPtr clazz) => + ref.UnregisterNatives.asFunction()( + clazz) + .integer; + + int MonitorEnter(JObjectPtr obj) => + ref.MonitorEnter.asFunction()(obj) + .integer; + + int MonitorExit(JObjectPtr obj) => + ref.MonitorExit.asFunction()(obj) + .integer; + + int GetJavaVM(ffi.Pointer> vm) => + ref.GetJavaVM.asFunction< + JniResult Function(ffi.Pointer> vm)>()(vm) + .integer; + + void GetStringRegion( + JStringPtr str, int start, int len, ffi.Pointer buf) => + ref.GetStringRegion.asFunction< + JThrowablePtr Function(JStringPtr str, int start, int len, + ffi.Pointer buf)>()(str, start, len, buf) + .check(); + + void GetStringUTFRegion( + JStringPtr str, int start, int len, ffi.Pointer buf) => + ref.GetStringUTFRegion.asFunction< + JThrowablePtr Function(JStringPtr str, int start, int len, + ffi.Pointer buf)>()(str, start, len, buf) + .check(); + + ffi.Pointer GetPrimitiveArrayCritical( + JArrayPtr array, ffi.Pointer isCopy) => + ref.GetPrimitiveArrayCritical.asFunction< + JniPointerResult Function(JArrayPtr array, + ffi.Pointer isCopy)>()(array, isCopy) + .getPointer(); + + void ReleasePrimitiveArrayCritical( + JArrayPtr array, ffi.Pointer carray, int mode) => + ref.ReleasePrimitiveArrayCritical.asFunction< + JThrowablePtr Function( + JArrayPtr array, + ffi.Pointer carray, + int mode)>()(array, carray, mode) + .check(); + + ffi.Pointer GetStringCritical( + JStringPtr str, ffi.Pointer isCopy) => + ref.GetStringCritical.asFunction< + JniPointerResult Function(JStringPtr str, + ffi.Pointer isCopy)>()(str, isCopy) + .getPointer(); + + void ReleaseStringCritical(JStringPtr str, ffi.Pointer carray) => + ref.ReleaseStringCritical.asFunction< + JThrowablePtr Function(JStringPtr str, + ffi.Pointer carray)>()(str, carray) + .check(); + + JWeakPtr NewWeakGlobalRef(JObjectPtr obj) => + ref.NewWeakGlobalRef.asFunction()(obj) + .object; + + void DeleteWeakGlobalRef(JWeakPtr obj) => ref.DeleteWeakGlobalRef.asFunction< + JThrowablePtr Function(JWeakPtr obj)>()(obj) + .check(); + + bool ExceptionCheck() => + ref.ExceptionCheck.asFunction()().boolean; + + JObjectPtr NewDirectByteBuffer(ffi.Pointer address, int capacity) => + ref.NewDirectByteBuffer.asFunction< + JniResult Function(ffi.Pointer address, + int capacity)>()(address, capacity) + .object; + + ffi.Pointer GetDirectBufferAddress(JObjectPtr buf) => + ref.GetDirectBufferAddress.asFunction< + JniPointerResult Function(JObjectPtr buf)>()(buf) + .getPointer(); + + int GetDirectBufferCapacity(JObjectPtr buf) => ref.GetDirectBufferCapacity + .asFunction()(buf) + .long; + + int GetObjectRefType(JObjectPtr obj) => + ref.GetObjectRefType.asFunction()(obj) + .integer; +} + +extension JniAccessorsExtension on ffi.Pointer { + JniClassLookupResult getClass(ffi.Pointer internalName) => + ref.getClass.asFunction< + JniClassLookupResult Function( + ffi.Pointer internalName)>()(internalName); + + JniPointerResult getFieldID(JClassPtr cls, ffi.Pointer fieldName, + ffi.Pointer signature) => + ref.getFieldID.asFunction< + JniPointerResult Function( + JClassPtr cls, + ffi.Pointer fieldName, + ffi.Pointer signature)>()(cls, fieldName, signature); + + JniPointerResult getStaticFieldID(JClassPtr cls, + ffi.Pointer fieldName, ffi.Pointer signature) => + ref.getStaticFieldID.asFunction< + JniPointerResult Function( + JClassPtr cls, + ffi.Pointer fieldName, + ffi.Pointer signature)>()(cls, fieldName, signature); + + JniPointerResult getMethodID(JClassPtr cls, ffi.Pointer methodName, + ffi.Pointer signature) => + ref.getMethodID.asFunction< + JniPointerResult Function( + JClassPtr cls, + ffi.Pointer methodName, + ffi.Pointer signature)>()(cls, methodName, signature); + + JniPointerResult getStaticMethodID(JClassPtr cls, + ffi.Pointer methodName, ffi.Pointer signature) => + ref.getStaticMethodID.asFunction< + JniPointerResult Function( + JClassPtr cls, + ffi.Pointer methodName, + ffi.Pointer signature)>()(cls, methodName, signature); + + JniResult newObject( + JClassPtr cls, JMethodIDPtr ctor, ffi.Pointer args) => + ref.newObject.asFunction< + JniResult Function(JClassPtr cls, JMethodIDPtr ctor, + ffi.Pointer args)>()(cls, ctor, args); + + JniPointerResult newPrimitiveArray(int length, int type) => + ref.newPrimitiveArray + .asFunction()( + length, type); + + JniPointerResult newObjectArray( + int length, JClassPtr elementClass, JObjectPtr initialElement) => + ref.newObjectArray.asFunction< + JniPointerResult Function(int length, JClassPtr elementClass, + JObjectPtr initialElement)>()( + length, elementClass, initialElement); + + JniResult getArrayElement(JArrayPtr array, int index, int type) => + ref.getArrayElement.asFunction< + JniResult Function( + JArrayPtr array, int index, int type)>()(array, index, type); + + JniResult callMethod(JObjectPtr obj, JMethodIDPtr methodID, int callType, + ffi.Pointer args) => + ref.callMethod.asFunction< + JniResult Function( + JObjectPtr obj, + JMethodIDPtr methodID, + int callType, + ffi.Pointer args)>()(obj, methodID, callType, args); + + JniResult callStaticMethod(JClassPtr cls, JMethodIDPtr methodID, int callType, + ffi.Pointer args) => + ref.callStaticMethod.asFunction< + JniResult Function(JClassPtr cls, JMethodIDPtr methodID, int callType, + ffi.Pointer args)>()(cls, methodID, callType, args); + + JniResult getField(JObjectPtr obj, JFieldIDPtr fieldID, int callType) => + ref.getField.asFunction< + JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID, + int callType)>()(obj, fieldID, callType); + + JniResult getStaticField(JClassPtr cls, JFieldIDPtr fieldID, int callType) => + ref.getStaticField.asFunction< + JniResult Function(JClassPtr cls, JFieldIDPtr fieldID, + int callType)>()(cls, fieldID, callType); + + JniExceptionDetails getExceptionDetails(JThrowablePtr exception) => ref + .getExceptionDetails + .asFunction()( + exception); +} 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 3ca9198fd..eb5ba0bfd 100644 --- a/pkgs/jni/lib/src/third_party/jni_bindings_generated.dart +++ b/pkgs/jni/lib/src/third_party/jni_bindings_generated.dart @@ -37,6 +37,7 @@ // AUTO GENERATED FILE, DO NOT EDIT. // // Generated by `package:ffigen`. +// ignore_for_file: type=lint import 'dart:ffi' as ffi; /// Bindings for libdartjni.so which is part of jni plugin. @@ -90,7 +91,12 @@ class JniBindings { late final _GetJniEnv = _GetJniEnvPtr.asFunction Function()>(); - ffi.Pointer SpawnJvm( + /// 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. + int SpawnJvm( ffi.Pointer args, ) { return _SpawnJvm( @@ -99,26 +105,33 @@ class JniBindings { } late final _SpawnJvmPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('SpawnJvm'); - late final _SpawnJvm = _SpawnJvmPtr.asFunction< - ffi.Pointer Function(ffi.Pointer)>(); - - JClassPtr LoadClass( + ffi.NativeFunction)>>( + 'SpawnJvm'); + late final _SpawnJvm = + _SpawnJvmPtr.asFunction)>(); + + /// Load class through platform-specific mechanism. + /// + /// Currently uses application classloader on android, + /// and JNIEnv->FindClass on other platforms. + JClassPtr FindClass( ffi.Pointer name, ) { - return _LoadClass( + return _FindClass( name, ); } - late final _LoadClassPtr = + late final _FindClassPtr = _lookup)>>( - 'LoadClass'); - late final _LoadClass = - _LoadClassPtr.asFunction)>(); - + 'FindClass'); + late final _FindClass = + _FindClassPtr.asFunction)>(); + + /// Returns Application classLoader (on Android), + /// which can be used to load application and platform classes. + /// + /// On other platforms, NULL is returned. JObjectPtr GetClassLoader() { return _GetClassLoader(); } @@ -128,6 +141,9 @@ class JniBindings { late final _GetClassLoader = _GetClassLoaderPtr.asFunction(); + /// Returns application context on Android. + /// + /// On other platforms, NULL is returned. JObjectPtr GetApplicationContext() { return _GetApplicationContext(); } @@ -138,6 +154,7 @@ class JniBindings { late final _GetApplicationContext = _GetApplicationContextPtr.asFunction(); + /// Returns current activity of the app on Android. JObjectPtr GetCurrentActivity() { return _GetCurrentActivity(); } @@ -186,9 +203,29 @@ class JniBindings { _GetGlobalEnvPtr.asFunction Function()>(); } -class jfieldID_ extends ffi.Opaque {} +/// Types used by JNI API to distinguish between primitive types. +abstract class JniCallType { + static const int booleanType = 0; + static const int byteType = 1; + static const int shortType = 2; + static const int charType = 3; + static const int intType = 4; + static const int longType = 5; + static const int floatType = 6; + static const int doubleType = 7; + static const int objectType = 8; + static const int voidType = 9; +} -class jmethodID_ extends ffi.Opaque {} +/// 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]. +class JniResult extends ffi.Struct { + external JValue value; + + external JThrowablePtr exception; +} class JValue extends ffi.Union { @JBooleanMarker() @@ -230,27 +267,135 @@ typedef JDoubleMarker = ffi.Double; /// Reference types, in C. typedef JObjectPtr = ffi.Pointer; +typedef JThrowablePtr = JObjectPtr; -abstract class jobjectRefType { - static const int JNIInvalidRefType = 0; - static const int JNILocalRefType = 1; - static const int JNIGlobalRefType = 2; - static const int JNIWeakGlobalRefType = 3; +/// Similar to [JniResult] but for class lookups. +class JniClassLookupResult extends ffi.Struct { + external JClassPtr value; + + external JThrowablePtr exception; } -class JNINativeMethod extends ffi.Struct { - external ffi.Pointer name; +typedef JClassPtr = JObjectPtr; - external ffi.Pointer signature; +/// Similar to [JniResult] but for method/field ID lookups. +class JniPointerResult extends ffi.Struct { + external ffi.Pointer value; - external ffi.Pointer fnPtr; + external JThrowablePtr exception; +} + +/// JniExceptionDetails holds 2 jstring objects, one is the result of +/// calling `toString` on exception object, other is stack trace; +class JniExceptionDetails extends ffi.Struct { + external JStringPtr message; + + external JStringPtr stacktrace; } -/// C++ version. -class _JavaVM extends ffi.Struct { - external ffi.Pointer functions; +typedef JStringPtr = JObjectPtr; + +/// This struct contains functions which wrap method call / field access conveniently along with +/// exception checking. +/// +/// Flutter embedding checks for pending JNI exceptions before an FFI transition, which requires us +/// to check for and clear the exception before returning to dart code, which requires these functions +/// to return result types. +class JniAccessors extends ffi.Struct { + external ffi.Pointer< + ffi.NativeFunction< + JniClassLookupResult Function( + ffi.Pointer internalName)>> getClass; + + external ffi.Pointer< + ffi.NativeFunction< + JniPointerResult Function( + JClassPtr cls, + ffi.Pointer fieldName, + ffi.Pointer signature)>> getFieldID; + + external ffi.Pointer< + ffi.NativeFunction< + JniPointerResult Function( + JClassPtr cls, + ffi.Pointer fieldName, + ffi.Pointer signature)>> getStaticFieldID; + + external ffi.Pointer< + ffi.NativeFunction< + JniPointerResult Function( + JClassPtr cls, + ffi.Pointer methodName, + ffi.Pointer signature)>> getMethodID; + + external ffi.Pointer< + ffi.NativeFunction< + JniPointerResult Function( + JClassPtr cls, + ffi.Pointer methodName, + ffi.Pointer signature)>> getStaticMethodID; + + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function( + JClassPtr cls, JMethodIDPtr ctor, ffi.Pointer args)>> + newObject; + + external ffi.Pointer< + ffi.NativeFunction< + JniPointerResult Function(JSizeMarker length, ffi.Int type)>> + newPrimitiveArray; + + external ffi.Pointer< + ffi.NativeFunction< + JniPointerResult Function(JSizeMarker length, JClassPtr elementClass, + JObjectPtr initialElement)>> newObjectArray; + + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JArrayPtr array, ffi.Int index, ffi.Int type)>> + getArrayElement; + + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Int callType, ffi.Pointer args)>> callMethod; + + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr cls, JMethodIDPtr methodID, + ffi.Int callType, ffi.Pointer args)>> callStaticMethod; + + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function( + JObjectPtr obj, JFieldIDPtr fieldID, ffi.Int callType)>> getField; + + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function( + JClassPtr cls, JFieldIDPtr fieldID, ffi.Int callType)>> + getStaticField; + + external ffi.Pointer< + ffi.NativeFunction< + JniExceptionDetails Function(JThrowablePtr exception)>> + getExceptionDetails; } +typedef JMethodIDPtr = ffi.Pointer; + +class jmethodID_ extends ffi.Opaque {} + +/// "cardinal indices and sizes" +typedef JSizeMarker = JIntMarker; +typedef JArrayPtr = JObjectPtr; +typedef JFieldIDPtr = ffi.Pointer; + +class jfieldID_ extends ffi.Opaque {} + +typedef JavaVM = ffi.Pointer; + /// JNI invocation interface. class JNIInvokeInterface extends ffi.Struct { external ffi.Pointer reserved0; @@ -259,67 +404,37 @@ class JNIInvokeInterface extends ffi.Struct { external ffi.Pointer reserved2; - external ffi - .Pointer)>> + external ffi.Pointer< + ffi.NativeFunction vm)>> DestroyJavaVM; external ffi.Pointer< ffi.NativeFunction< JIntMarker Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Pointer)>> AttachCurrentThread; + ffi.Pointer vm, + ffi.Pointer> p_env, + ffi.Pointer thr_args)>> AttachCurrentThread; - external ffi - .Pointer)>> + external ffi.Pointer< + ffi.NativeFunction vm)>> DetachCurrentThread; external ffi.Pointer< ffi.NativeFunction< - JIntMarker Function(ffi.Pointer, - ffi.Pointer>, JIntMarker)>> GetEnv; + JIntMarker Function( + ffi.Pointer vm, + ffi.Pointer> p_env, + JIntMarker version)>> GetEnv; external ffi.Pointer< ffi.NativeFunction< JIntMarker Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Pointer)>> AttachCurrentThreadAsDaemon; -} - -extension JNIInvokeInterfaceExtension on ffi.Pointer { - int DestroyJavaVM() { - return value.ref.DestroyJavaVM - .asFunction)>()(this); - } - - int AttachCurrentThread( - ffi.Pointer> p_env, ffi.Pointer thr_args) { - return value.ref.AttachCurrentThread.asFunction< - int Function(ffi.Pointer, ffi.Pointer>, - ffi.Pointer)>()(this, p_env, thr_args); - } - - int DetachCurrentThread() { - return value.ref.DetachCurrentThread - .asFunction)>()(this); - } - - int GetEnv(ffi.Pointer> p_env, int version) { - return value.ref.GetEnv.asFunction< - int Function(ffi.Pointer, ffi.Pointer>, - int)>()(this, p_env, version); - } - - int AttachCurrentThreadAsDaemon( - ffi.Pointer> p_env, ffi.Pointer thr_args) { - return value.ref.AttachCurrentThreadAsDaemon.asFunction< - int Function(ffi.Pointer, ffi.Pointer>, - ffi.Pointer)>()(this, p_env, thr_args); - } + ffi.Pointer vm, + ffi.Pointer> p_env, + ffi.Pointer thr_args)>> AttachCurrentThreadAsDaemon; } -typedef JavaVM = ffi.Pointer; +typedef JavaVM1 = ffi.Pointer; typedef JniEnv = ffi.Pointer; /// Table of interface function pointers. @@ -333,1131 +448,1445 @@ class JNINativeInterface extends ffi.Struct { external ffi.Pointer reserved3; external ffi.Pointer< - ffi.NativeFunction)>> GetVersion; + ffi.NativeFunction env)>> + GetVersion; external ffi.Pointer< ffi.NativeFunction< - JClassPtr Function(ffi.Pointer, ffi.Pointer, - JObjectPtr, ffi.Pointer, JSizeMarker)>> DefineClass; + JClassPtr Function( + ffi.Pointer env, + ffi.Pointer name, + JObjectPtr loader, + ffi.Pointer buf, + JSizeMarker bufLen)>> DefineClass; external ffi.Pointer< - ffi.NativeFunction< - JClassPtr Function(ffi.Pointer, ffi.Pointer)>> - FindClass; + ffi.NativeFunction< + JClassPtr Function( + ffi.Pointer env, ffi.Pointer name)>> FindClass; external ffi.Pointer< ffi.NativeFunction< - JMethodIDPtr Function(ffi.Pointer, JObjectPtr)>> + JMethodIDPtr Function( + ffi.Pointer env, JObjectPtr method)>> FromReflectedMethod; external ffi.Pointer< ffi.NativeFunction< - JFieldIDPtr Function(ffi.Pointer, JObjectPtr)>> + JFieldIDPtr Function(ffi.Pointer env, JObjectPtr field)>> FromReflectedField; /// spec doesn't show jboolean parameter external ffi.Pointer< ffi.NativeFunction< - JObjectPtr Function(ffi.Pointer, JClassPtr, JMethodIDPtr, - JBooleanMarker)>> ToReflectedMethod; + JObjectPtr Function( + ffi.Pointer env, + JClassPtr cls, + JMethodIDPtr methodId, + JBooleanMarker isStatic)>> ToReflectedMethod; external ffi.Pointer< - ffi.NativeFunction< - JClassPtr Function(ffi.Pointer, JClassPtr)>> GetSuperclass; + ffi.NativeFunction< + JClassPtr Function(ffi.Pointer env, JClassPtr clazz)>> + GetSuperclass; external ffi.Pointer< ffi.NativeFunction< - JBooleanMarker Function( - ffi.Pointer, JClassPtr, JClassPtr)>> IsAssignableFrom; + JBooleanMarker Function(ffi.Pointer env, JClassPtr clazz1, + JClassPtr clazz2)>> IsAssignableFrom; /// spec doesn't show jboolean parameter external ffi.Pointer< ffi.NativeFunction< - JObjectPtr Function(ffi.Pointer, JClassPtr, JFieldIDPtr, - JBooleanMarker)>> ToReflectedField; + JObjectPtr Function(ffi.Pointer env, JClassPtr cls, + JFieldIDPtr fieldID, JBooleanMarker isStatic)>> ToReflectedField; external ffi.Pointer< - ffi.NativeFunction< - JIntMarker Function(ffi.Pointer, JThrowablePtr)>> Throw; + ffi.NativeFunction< + JIntMarker Function(ffi.Pointer env, JThrowablePtr obj)>> + Throw; external ffi.Pointer< - ffi.NativeFunction< - JIntMarker Function( - ffi.Pointer, JClassPtr, ffi.Pointer)>> - ThrowNew; + ffi.NativeFunction< + JIntMarker Function(ffi.Pointer env, JClassPtr clazz, + ffi.Pointer message)>> ThrowNew; external ffi.Pointer< - ffi.NativeFunction)>> + ffi.NativeFunction env)>> ExceptionOccurred; - external ffi - .Pointer)>> + external ffi.Pointer< + ffi.NativeFunction env)>> ExceptionDescribe; - external ffi - .Pointer)>> + external ffi.Pointer< + ffi.NativeFunction env)>> ExceptionClear; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer)>> - FatalError; + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer env, ffi.Pointer msg)>> FatalError; external ffi.Pointer< - ffi.NativeFunction< - JIntMarker Function(ffi.Pointer, JIntMarker)>> - PushLocalFrame; + ffi.NativeFunction< + JIntMarker Function( + ffi.Pointer env, JIntMarker capacity)>> PushLocalFrame; external ffi.Pointer< - ffi.NativeFunction< - JObjectPtr Function(ffi.Pointer, JObjectPtr)>> PopLocalFrame; + ffi.NativeFunction< + JObjectPtr Function(ffi.Pointer env, JObjectPtr result)>> + PopLocalFrame; external ffi.Pointer< - ffi.NativeFunction< - JObjectPtr Function(ffi.Pointer, JObjectPtr)>> NewGlobalRef; + ffi.NativeFunction< + JObjectPtr Function(ffi.Pointer env, JObjectPtr obj)>> + NewGlobalRef; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, JObjectPtr)>> DeleteGlobalRef; + ffi.Void Function( + ffi.Pointer env, JObjectPtr globalRef)>> DeleteGlobalRef; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, JObjectPtr)>> DeleteLocalRef; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JObjectPtr localRef)>> + DeleteLocalRef; external ffi.Pointer< - ffi.NativeFunction< - JBooleanMarker Function( - ffi.Pointer, JObjectPtr, JObjectPtr)>> IsSameObject; + ffi.NativeFunction< + JBooleanMarker Function( + ffi.Pointer env, JObjectPtr ref1, JObjectPtr ref2)>> + IsSameObject; external ffi.Pointer< - ffi.NativeFunction< - JObjectPtr Function(ffi.Pointer, JObjectPtr)>> NewLocalRef; + ffi.NativeFunction< + JObjectPtr Function(ffi.Pointer env, JObjectPtr obj)>> + NewLocalRef; external ffi.Pointer< ffi.NativeFunction< - JIntMarker Function(ffi.Pointer, JIntMarker)>> + JIntMarker Function( + ffi.Pointer env, JIntMarker capacity)>> EnsureLocalCapacity; external ffi.Pointer< - ffi.NativeFunction< - JObjectPtr Function(ffi.Pointer, JClassPtr)>> AllocObject; + ffi.NativeFunction< + JObjectPtr Function(ffi.Pointer env, JClassPtr clazz)>> + AllocObject; external ffi.Pointer< ffi.NativeFunction< - JObjectPtr Function( - ffi.Pointer, JClassPtr, JMethodIDPtr)>> NewObject; - - external ffi.Pointer _NewObjectV; + JObjectPtr Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>> NewObject; external ffi.Pointer< ffi.NativeFunction< JObjectPtr Function(ffi.Pointer, JClassPtr, JMethodIDPtr, - ffi.Pointer)>> NewObjectA; + ffi.Pointer)>> NewObjectV; external ffi.Pointer< ffi.NativeFunction< - JClassPtr Function(ffi.Pointer, JObjectPtr)>> GetObjectClass; + JObjectPtr Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args)>> NewObjectA; external ffi.Pointer< - ffi.NativeFunction< - JBooleanMarker Function( - ffi.Pointer, JObjectPtr, JClassPtr)>> IsInstanceOf; + ffi.NativeFunction< + JClassPtr Function(ffi.Pointer env, JObjectPtr obj)>> + GetObjectClass; external ffi.Pointer< - ffi.NativeFunction< - JMethodIDPtr Function(ffi.Pointer, JClassPtr, - ffi.Pointer, ffi.Pointer)>> GetMethodID; + ffi.NativeFunction< + JBooleanMarker Function( + ffi.Pointer env, JObjectPtr obj, JClassPtr clazz)>> + IsInstanceOf; external ffi.Pointer< - ffi.NativeFunction< - JObjectPtr Function( - ffi.Pointer, JObjectPtr, JMethodIDPtr)>> - CallObjectMethod; + ffi.NativeFunction< + JMethodIDPtr Function( + ffi.Pointer env, + JClassPtr clazz, + ffi.Pointer name, + ffi.Pointer sig)>> GetMethodID; - external ffi.Pointer _CallObjectMethodV; + external ffi.Pointer< + ffi.NativeFunction< + JObjectPtr Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>> CallObjectMethod; external ffi.Pointer< ffi.NativeFunction< JObjectPtr Function(ffi.Pointer, JObjectPtr, JMethodIDPtr, - ffi.Pointer)>> CallObjectMethodA; + ffi.Pointer)>> CallObjectMethodV; external ffi.Pointer< - ffi.NativeFunction< - JBooleanMarker Function( - ffi.Pointer, JObjectPtr, JMethodIDPtr)>> - CallBooleanMethod; + ffi.NativeFunction< + JObjectPtr Function( + ffi.Pointer env, + JObjectPtr obj, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallObjectMethodA; - external ffi.Pointer _CallBooleanMethodV; + external ffi.Pointer< + ffi.NativeFunction< + JBooleanMarker Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>> CallBooleanMethod; external ffi.Pointer< ffi.NativeFunction< JBooleanMarker Function(ffi.Pointer, JObjectPtr, - JMethodIDPtr, ffi.Pointer)>> CallBooleanMethodA; + JMethodIDPtr, ffi.Pointer)>> CallBooleanMethodV; external ffi.Pointer< ffi.NativeFunction< - JByteMarker Function( - ffi.Pointer, JObjectPtr, JMethodIDPtr)>> CallByteMethod; + JBooleanMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JMethodIDPtr methodId, + ffi.Pointer args)>> CallBooleanMethodA; - external ffi.Pointer _CallByteMethodV; + external ffi.Pointer< + ffi.NativeFunction< + JByteMarker Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>> CallByteMethod; external ffi.Pointer< ffi.NativeFunction< JByteMarker Function(ffi.Pointer, JObjectPtr, JMethodIDPtr, - ffi.Pointer)>> CallByteMethodA; + ffi.Pointer)>> CallByteMethodV; external ffi.Pointer< ffi.NativeFunction< - JCharMarker Function( - ffi.Pointer, JObjectPtr, JMethodIDPtr)>> CallCharMethod; + JByteMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallByteMethodA; - external ffi.Pointer _CallCharMethodV; + external ffi.Pointer< + ffi.NativeFunction< + JCharMarker Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>> CallCharMethod; external ffi.Pointer< ffi.NativeFunction< JCharMarker Function(ffi.Pointer, JObjectPtr, JMethodIDPtr, - ffi.Pointer)>> CallCharMethodA; + ffi.Pointer)>> CallCharMethodV; external ffi.Pointer< ffi.NativeFunction< - JShortMarker Function( - ffi.Pointer, JObjectPtr, JMethodIDPtr)>> CallShortMethod; + JCharMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallCharMethodA; - external ffi.Pointer _CallShortMethodV; + external ffi.Pointer< + ffi.NativeFunction< + JShortMarker Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>> CallShortMethod; external ffi.Pointer< ffi.NativeFunction< JShortMarker Function(ffi.Pointer, JObjectPtr, JMethodIDPtr, - ffi.Pointer)>> CallShortMethodA; + ffi.Pointer)>> CallShortMethodV; external ffi.Pointer< ffi.NativeFunction< - JIntMarker Function( - ffi.Pointer, JObjectPtr, JMethodIDPtr)>> CallIntMethod; + JShortMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallShortMethodA; - external ffi.Pointer _CallIntMethodV; + external ffi.Pointer< + ffi.NativeFunction< + JIntMarker Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>> CallIntMethod; external ffi.Pointer< ffi.NativeFunction< JIntMarker Function(ffi.Pointer, JObjectPtr, JMethodIDPtr, - ffi.Pointer)>> CallIntMethodA; + ffi.Pointer)>> CallIntMethodV; external ffi.Pointer< ffi.NativeFunction< - JLongMarker Function( - ffi.Pointer, JObjectPtr, JMethodIDPtr)>> CallLongMethod; + JIntMarker Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID, ffi.Pointer args)>> CallIntMethodA; - external ffi.Pointer _CallLongMethodV; + external ffi.Pointer< + ffi.NativeFunction< + JLongMarker Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>> CallLongMethod; external ffi.Pointer< ffi.NativeFunction< JLongMarker Function(ffi.Pointer, JObjectPtr, JMethodIDPtr, - ffi.Pointer)>> CallLongMethodA; + ffi.Pointer)>> CallLongMethodV; external ffi.Pointer< ffi.NativeFunction< - JFloatMarker Function( - ffi.Pointer, JObjectPtr, JMethodIDPtr)>> CallFloatMethod; + JLongMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallLongMethodA; - external ffi.Pointer _CallFloatMethodV; + external ffi.Pointer< + ffi.NativeFunction< + JFloatMarker Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>> CallFloatMethod; external ffi.Pointer< ffi.NativeFunction< JFloatMarker Function(ffi.Pointer, JObjectPtr, JMethodIDPtr, - ffi.Pointer)>> CallFloatMethodA; + ffi.Pointer)>> CallFloatMethodV; external ffi.Pointer< - ffi.NativeFunction< - JDoubleMarker Function( - ffi.Pointer, JObjectPtr, JMethodIDPtr)>> - CallDoubleMethod; + ffi.NativeFunction< + JFloatMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallFloatMethodA; - external ffi.Pointer _CallDoubleMethodV; + external ffi.Pointer< + ffi.NativeFunction< + JDoubleMarker Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>> CallDoubleMethod; external ffi.Pointer< ffi.NativeFunction< JDoubleMarker Function(ffi.Pointer, JObjectPtr, JMethodIDPtr, - ffi.Pointer)>> CallDoubleMethodA; + ffi.Pointer)>> CallDoubleMethodV; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, JObjectPtr, JMethodIDPtr)>> CallVoidMethod; + JDoubleMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallDoubleMethodA; - external ffi.Pointer _CallVoidMethodV; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>> CallVoidMethod; external ffi.Pointer< ffi.NativeFunction< ffi.Void Function(ffi.Pointer, JObjectPtr, JMethodIDPtr, - ffi.Pointer)>> CallVoidMethodA; + ffi.Pointer)>> CallVoidMethodV; external ffi.Pointer< - ffi.NativeFunction< - JObjectPtr Function( - ffi.Pointer, JObjectPtr, JClassPtr, JMethodIDPtr)>> - CallNonvirtualObjectMethod; - - external ffi.Pointer _CallNonvirtualObjectMethodV; + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer env, + JObjectPtr obj, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallVoidMethodA; external ffi.Pointer< ffi.NativeFunction< - JObjectPtr Function(ffi.Pointer, JObjectPtr, JClassPtr, - JMethodIDPtr, ffi.Pointer)>> CallNonvirtualObjectMethodA; + JObjectPtr Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID)>> CallNonvirtualObjectMethod; external ffi.Pointer< - ffi.NativeFunction< - JBooleanMarker Function( - ffi.Pointer, JObjectPtr, JClassPtr, JMethodIDPtr)>> - CallNonvirtualBooleanMethod; + ffi.NativeFunction< + JObjectPtr Function( + ffi.Pointer, + JObjectPtr, + JClassPtr, + JMethodIDPtr, + ffi.Pointer)>> CallNonvirtualObjectMethodV; - external ffi.Pointer _CallNonvirtualBooleanMethodV; + external ffi.Pointer< + ffi.NativeFunction< + JObjectPtr Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallNonvirtualObjectMethodA; external ffi.Pointer< ffi.NativeFunction< - JBooleanMarker Function(ffi.Pointer, JObjectPtr, JClassPtr, - JMethodIDPtr, ffi.Pointer)>> CallNonvirtualBooleanMethodA; + JBooleanMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID)>> CallNonvirtualBooleanMethod; external ffi.Pointer< - ffi.NativeFunction< - JByteMarker Function( - ffi.Pointer, JObjectPtr, JClassPtr, JMethodIDPtr)>> - CallNonvirtualByteMethod; + ffi.NativeFunction< + JBooleanMarker Function( + ffi.Pointer, + JObjectPtr, + JClassPtr, + JMethodIDPtr, + ffi.Pointer)>> CallNonvirtualBooleanMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JBooleanMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallNonvirtualBooleanMethodA; - external ffi.Pointer _CallNonvirtualByteMethodV; + external ffi.Pointer< + ffi.NativeFunction< + JByteMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID)>> CallNonvirtualByteMethod; external ffi.Pointer< ffi.NativeFunction< JByteMarker Function(ffi.Pointer, JObjectPtr, JClassPtr, - JMethodIDPtr, ffi.Pointer)>> CallNonvirtualByteMethodA; + JMethodIDPtr, ffi.Pointer)>> CallNonvirtualByteMethodV; external ffi.Pointer< - ffi.NativeFunction< - JCharMarker Function( - ffi.Pointer, JObjectPtr, JClassPtr, JMethodIDPtr)>> - CallNonvirtualCharMethod; + ffi.NativeFunction< + JByteMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallNonvirtualByteMethodA; - external ffi.Pointer _CallNonvirtualCharMethodV; + external ffi.Pointer< + ffi.NativeFunction< + JCharMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID)>> CallNonvirtualCharMethod; external ffi.Pointer< ffi.NativeFunction< JCharMarker Function(ffi.Pointer, JObjectPtr, JClassPtr, - JMethodIDPtr, ffi.Pointer)>> CallNonvirtualCharMethodA; + JMethodIDPtr, ffi.Pointer)>> CallNonvirtualCharMethodV; external ffi.Pointer< - ffi.NativeFunction< - JShortMarker Function( - ffi.Pointer, JObjectPtr, JClassPtr, JMethodIDPtr)>> - CallNonvirtualShortMethod; + ffi.NativeFunction< + JCharMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallNonvirtualCharMethodA; - external ffi.Pointer _CallNonvirtualShortMethodV; + external ffi.Pointer< + ffi.NativeFunction< + JShortMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID)>> CallNonvirtualShortMethod; external ffi.Pointer< ffi.NativeFunction< JShortMarker Function(ffi.Pointer, JObjectPtr, JClassPtr, - JMethodIDPtr, ffi.Pointer)>> CallNonvirtualShortMethodA; + JMethodIDPtr, ffi.Pointer)>> CallNonvirtualShortMethodV; external ffi.Pointer< - ffi.NativeFunction< - JIntMarker Function( - ffi.Pointer, JObjectPtr, JClassPtr, JMethodIDPtr)>> - CallNonvirtualIntMethod; + ffi.NativeFunction< + JShortMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallNonvirtualShortMethodA; - external ffi.Pointer _CallNonvirtualIntMethodV; + external ffi.Pointer< + ffi.NativeFunction< + JIntMarker Function(ffi.Pointer env, JObjectPtr obj, + JClassPtr clazz, JMethodIDPtr methodID)>> CallNonvirtualIntMethod; external ffi.Pointer< ffi.NativeFunction< JIntMarker Function(ffi.Pointer, JObjectPtr, JClassPtr, - JMethodIDPtr, ffi.Pointer)>> CallNonvirtualIntMethodA; + JMethodIDPtr, ffi.Pointer)>> CallNonvirtualIntMethodV; external ffi.Pointer< - ffi.NativeFunction< - JLongMarker Function( - ffi.Pointer, JObjectPtr, JClassPtr, JMethodIDPtr)>> - CallNonvirtualLongMethod; + ffi.NativeFunction< + JIntMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallNonvirtualIntMethodA; - external ffi.Pointer _CallNonvirtualLongMethodV; + external ffi.Pointer< + ffi.NativeFunction< + JLongMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID)>> CallNonvirtualLongMethod; external ffi.Pointer< ffi.NativeFunction< JLongMarker Function(ffi.Pointer, JObjectPtr, JClassPtr, - JMethodIDPtr, ffi.Pointer)>> CallNonvirtualLongMethodA; + JMethodIDPtr, ffi.Pointer)>> CallNonvirtualLongMethodV; external ffi.Pointer< - ffi.NativeFunction< - JFloatMarker Function( - ffi.Pointer, JObjectPtr, JClassPtr, JMethodIDPtr)>> - CallNonvirtualFloatMethod; + ffi.NativeFunction< + JLongMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallNonvirtualLongMethodA; - external ffi.Pointer _CallNonvirtualFloatMethodV; + external ffi.Pointer< + ffi.NativeFunction< + JFloatMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID)>> CallNonvirtualFloatMethod; external ffi.Pointer< ffi.NativeFunction< JFloatMarker Function(ffi.Pointer, JObjectPtr, JClassPtr, - JMethodIDPtr, ffi.Pointer)>> CallNonvirtualFloatMethodA; + JMethodIDPtr, ffi.Pointer)>> CallNonvirtualFloatMethodV; external ffi.Pointer< - ffi.NativeFunction< - JDoubleMarker Function( - ffi.Pointer, JObjectPtr, JClassPtr, JMethodIDPtr)>> - CallNonvirtualDoubleMethod; + ffi.NativeFunction< + JFloatMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallNonvirtualFloatMethodA; - external ffi.Pointer _CallNonvirtualDoubleMethodV; + external ffi.Pointer< + ffi.NativeFunction< + JDoubleMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID)>> CallNonvirtualDoubleMethod; external ffi.Pointer< ffi.NativeFunction< - JDoubleMarker Function(ffi.Pointer, JObjectPtr, JClassPtr, - JMethodIDPtr, ffi.Pointer)>> CallNonvirtualDoubleMethodA; + JDoubleMarker Function( + ffi.Pointer, + JObjectPtr, + JClassPtr, + JMethodIDPtr, + ffi.Pointer)>> CallNonvirtualDoubleMethodV; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, JObjectPtr, JClassPtr, JMethodIDPtr)>> - CallNonvirtualVoidMethod; + ffi.NativeFunction< + JDoubleMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallNonvirtualDoubleMethodA; - external ffi.Pointer _CallNonvirtualVoidMethodV; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID)>> CallNonvirtualVoidMethod; external ffi.Pointer< ffi.NativeFunction< ffi.Void Function(ffi.Pointer, JObjectPtr, JClassPtr, - JMethodIDPtr, ffi.Pointer)>> CallNonvirtualVoidMethodA; + JMethodIDPtr, ffi.Pointer)>> CallNonvirtualVoidMethodV; external ffi.Pointer< ffi.NativeFunction< - JFieldIDPtr Function(ffi.Pointer, JClassPtr, - ffi.Pointer, ffi.Pointer)>> GetFieldID; + ffi.Void Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallNonvirtualVoidMethodA; external ffi.Pointer< ffi.NativeFunction< - JObjectPtr Function( - ffi.Pointer, JObjectPtr, JFieldIDPtr)>> GetObjectField; + JFieldIDPtr Function( + ffi.Pointer env, + JClassPtr clazz, + ffi.Pointer name, + ffi.Pointer sig)>> GetFieldID; external ffi.Pointer< ffi.NativeFunction< - JBooleanMarker Function( - ffi.Pointer, JObjectPtr, JFieldIDPtr)>> GetBooleanField; + JObjectPtr Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID)>> GetObjectField; external ffi.Pointer< ffi.NativeFunction< - JByteMarker Function( - ffi.Pointer, JObjectPtr, JFieldIDPtr)>> GetByteField; + JBooleanMarker Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID)>> GetBooleanField; external ffi.Pointer< ffi.NativeFunction< - JCharMarker Function( - ffi.Pointer, JObjectPtr, JFieldIDPtr)>> GetCharField; + JByteMarker Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID)>> GetByteField; external ffi.Pointer< ffi.NativeFunction< - JShortMarker Function( - ffi.Pointer, JObjectPtr, JFieldIDPtr)>> GetShortField; + JCharMarker Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID)>> GetCharField; external ffi.Pointer< ffi.NativeFunction< - JIntMarker Function( - ffi.Pointer, JObjectPtr, JFieldIDPtr)>> GetIntField; + JShortMarker Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID)>> GetShortField; external ffi.Pointer< ffi.NativeFunction< - JLongMarker Function( - ffi.Pointer, JObjectPtr, JFieldIDPtr)>> GetLongField; + JIntMarker Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID)>> GetIntField; external ffi.Pointer< ffi.NativeFunction< - JFloatMarker Function( - ffi.Pointer, JObjectPtr, JFieldIDPtr)>> GetFloatField; + JLongMarker Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID)>> GetLongField; external ffi.Pointer< ffi.NativeFunction< - JDoubleMarker Function( - ffi.Pointer, JObjectPtr, JFieldIDPtr)>> GetDoubleField; + JFloatMarker Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID)>> GetFloatField; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, JObjectPtr, JFieldIDPtr, JObjectPtr)>> - SetObjectField; + ffi.NativeFunction< + JDoubleMarker Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID)>> GetDoubleField; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, JObjectPtr, JFieldIDPtr, - JBooleanMarker)>> SetBooleanField; + ffi.Void Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID, JObjectPtr val)>> SetObjectField; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, JObjectPtr, JFieldIDPtr, JByteMarker)>> - SetByteField; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID, JBooleanMarker val)>> SetBooleanField; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, JObjectPtr, JFieldIDPtr, JCharMarker)>> - SetCharField; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID, JByteMarker val)>> SetByteField; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, JObjectPtr, JFieldIDPtr, JShortMarker)>> - SetShortField; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID, JCharMarker val)>> SetCharField; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, JObjectPtr, JFieldIDPtr, JIntMarker)>> - SetIntField; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID, JShortMarker val)>> SetShortField; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, JObjectPtr, JFieldIDPtr, JLongMarker)>> - SetLongField; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID, JIntMarker val)>> SetIntField; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, JObjectPtr, JFieldIDPtr, JFloatMarker)>> - SetFloatField; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID, JLongMarker val)>> SetLongField; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, JObjectPtr, JFieldIDPtr, - JDoubleMarker)>> SetDoubleField; + ffi.Void Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID, JFloatMarker val)>> SetFloatField; external ffi.Pointer< ffi.NativeFunction< - JMethodIDPtr Function(ffi.Pointer, JClassPtr, - ffi.Pointer, ffi.Pointer)>> GetStaticMethodID; + ffi.Void Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID, JDoubleMarker val)>> SetDoubleField; external ffi.Pointer< - ffi.NativeFunction< - JObjectPtr Function( - ffi.Pointer, JClassPtr, JMethodIDPtr)>> - CallStaticObjectMethod; + ffi.NativeFunction< + JMethodIDPtr Function( + ffi.Pointer env, + JClassPtr clazz, + ffi.Pointer name, + ffi.Pointer sig)>> GetStaticMethodID; - external ffi.Pointer _CallStaticObjectMethodV; + external ffi.Pointer< + ffi.NativeFunction< + JObjectPtr Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>> CallStaticObjectMethod; external ffi.Pointer< ffi.NativeFunction< JObjectPtr Function(ffi.Pointer, JClassPtr, JMethodIDPtr, - ffi.Pointer)>> CallStaticObjectMethodA; + ffi.Pointer)>> CallStaticObjectMethodV; external ffi.Pointer< - ffi.NativeFunction< - JBooleanMarker Function( - ffi.Pointer, JClassPtr, JMethodIDPtr)>> - CallStaticBooleanMethod; + ffi.NativeFunction< + JObjectPtr Function( + ffi.Pointer env, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticObjectMethodA; - external ffi.Pointer _CallStaticBooleanMethodV; + external ffi.Pointer< + ffi.NativeFunction< + JBooleanMarker Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>> CallStaticBooleanMethod; external ffi.Pointer< ffi.NativeFunction< JBooleanMarker Function(ffi.Pointer, JClassPtr, JMethodIDPtr, - ffi.Pointer)>> CallStaticBooleanMethodA; + ffi.Pointer)>> CallStaticBooleanMethodV; external ffi.Pointer< - ffi.NativeFunction< - JByteMarker Function( - ffi.Pointer, JClassPtr, JMethodIDPtr)>> - CallStaticByteMethod; + ffi.NativeFunction< + JBooleanMarker Function( + ffi.Pointer env, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticBooleanMethodA; - external ffi.Pointer _CallStaticByteMethodV; + external ffi.Pointer< + ffi.NativeFunction< + JByteMarker Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>> CallStaticByteMethod; external ffi.Pointer< ffi.NativeFunction< JByteMarker Function(ffi.Pointer, JClassPtr, JMethodIDPtr, - ffi.Pointer)>> CallStaticByteMethodA; + ffi.Pointer)>> CallStaticByteMethodV; external ffi.Pointer< - ffi.NativeFunction< - JCharMarker Function( - ffi.Pointer, JClassPtr, JMethodIDPtr)>> - CallStaticCharMethod; + ffi.NativeFunction< + JByteMarker Function( + ffi.Pointer env, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticByteMethodA; - external ffi.Pointer _CallStaticCharMethodV; + external ffi.Pointer< + ffi.NativeFunction< + JCharMarker Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>> CallStaticCharMethod; external ffi.Pointer< ffi.NativeFunction< JCharMarker Function(ffi.Pointer, JClassPtr, JMethodIDPtr, - ffi.Pointer)>> CallStaticCharMethodA; + ffi.Pointer)>> CallStaticCharMethodV; external ffi.Pointer< - ffi.NativeFunction< - JShortMarker Function( - ffi.Pointer, JClassPtr, JMethodIDPtr)>> - CallStaticShortMethod; + ffi.NativeFunction< + JCharMarker Function( + ffi.Pointer env, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticCharMethodA; - external ffi.Pointer _CallStaticShortMethodV; + external ffi.Pointer< + ffi.NativeFunction< + JShortMarker Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>> CallStaticShortMethod; external ffi.Pointer< ffi.NativeFunction< JShortMarker Function(ffi.Pointer, JClassPtr, JMethodIDPtr, - ffi.Pointer)>> CallStaticShortMethodA; + ffi.Pointer)>> CallStaticShortMethodV; external ffi.Pointer< - ffi.NativeFunction< - JIntMarker Function( - ffi.Pointer, JClassPtr, JMethodIDPtr)>> - CallStaticIntMethod; + ffi.NativeFunction< + JShortMarker Function( + ffi.Pointer env, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticShortMethodA; - external ffi.Pointer _CallStaticIntMethodV; + external ffi.Pointer< + ffi.NativeFunction< + JIntMarker Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>> CallStaticIntMethod; external ffi.Pointer< ffi.NativeFunction< JIntMarker Function(ffi.Pointer, JClassPtr, JMethodIDPtr, - ffi.Pointer)>> CallStaticIntMethodA; + ffi.Pointer)>> CallStaticIntMethodV; external ffi.Pointer< - ffi.NativeFunction< - JLongMarker Function( - ffi.Pointer, JClassPtr, JMethodIDPtr)>> - CallStaticLongMethod; + ffi.NativeFunction< + JIntMarker Function( + ffi.Pointer env, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticIntMethodA; - external ffi.Pointer _CallStaticLongMethodV; + external ffi.Pointer< + ffi.NativeFunction< + JLongMarker Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>> CallStaticLongMethod; external ffi.Pointer< ffi.NativeFunction< JLongMarker Function(ffi.Pointer, JClassPtr, JMethodIDPtr, - ffi.Pointer)>> CallStaticLongMethodA; + ffi.Pointer)>> CallStaticLongMethodV; external ffi.Pointer< - ffi.NativeFunction< - JFloatMarker Function( - ffi.Pointer, JClassPtr, JMethodIDPtr)>> - CallStaticFloatMethod; + ffi.NativeFunction< + JLongMarker Function( + ffi.Pointer env, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticLongMethodA; - external ffi.Pointer _CallStaticFloatMethodV; + external ffi.Pointer< + ffi.NativeFunction< + JFloatMarker Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>> CallStaticFloatMethod; external ffi.Pointer< ffi.NativeFunction< JFloatMarker Function(ffi.Pointer, JClassPtr, JMethodIDPtr, - ffi.Pointer)>> CallStaticFloatMethodA; + ffi.Pointer)>> CallStaticFloatMethodV; external ffi.Pointer< - ffi.NativeFunction< - JDoubleMarker Function( - ffi.Pointer, JClassPtr, JMethodIDPtr)>> - CallStaticDoubleMethod; + ffi.NativeFunction< + JFloatMarker Function( + ffi.Pointer env, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticFloatMethodA; - external ffi.Pointer _CallStaticDoubleMethodV; + external ffi.Pointer< + ffi.NativeFunction< + JDoubleMarker Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>> CallStaticDoubleMethod; external ffi.Pointer< ffi.NativeFunction< JDoubleMarker Function(ffi.Pointer, JClassPtr, JMethodIDPtr, - ffi.Pointer)>> CallStaticDoubleMethodA; + ffi.Pointer)>> CallStaticDoubleMethodV; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, JClassPtr, JMethodIDPtr)>> - CallStaticVoidMethod; + ffi.NativeFunction< + JDoubleMarker Function( + ffi.Pointer env, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticDoubleMethodA; - external ffi.Pointer _CallStaticVoidMethodV; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>> CallStaticVoidMethod; external ffi.Pointer< ffi.NativeFunction< ffi.Void Function(ffi.Pointer, JClassPtr, JMethodIDPtr, - ffi.Pointer)>> CallStaticVoidMethodA; + ffi.Pointer)>> CallStaticVoidMethodV; external ffi.Pointer< ffi.NativeFunction< - JFieldIDPtr Function(ffi.Pointer, JClassPtr, - ffi.Pointer, ffi.Pointer)>> GetStaticFieldID; + ffi.Void Function( + ffi.Pointer env, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticVoidMethodA; external ffi.Pointer< - ffi.NativeFunction< - JObjectPtr Function( - ffi.Pointer, JClassPtr, JFieldIDPtr)>> - GetStaticObjectField; + ffi.NativeFunction< + JFieldIDPtr Function( + ffi.Pointer env, + JClassPtr clazz, + ffi.Pointer name, + ffi.Pointer sig)>> GetStaticFieldID; external ffi.Pointer< - ffi.NativeFunction< - JBooleanMarker Function( - ffi.Pointer, JClassPtr, JFieldIDPtr)>> - GetStaticBooleanField; + ffi.NativeFunction< + JObjectPtr Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID)>> GetStaticObjectField; external ffi.Pointer< - ffi.NativeFunction< - JByteMarker Function( - ffi.Pointer, JClassPtr, JFieldIDPtr)>> - GetStaticByteField; + ffi.NativeFunction< + JBooleanMarker Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID)>> GetStaticBooleanField; external ffi.Pointer< - ffi.NativeFunction< - JCharMarker Function( - ffi.Pointer, JClassPtr, JFieldIDPtr)>> - GetStaticCharField; + ffi.NativeFunction< + JByteMarker Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID)>> GetStaticByteField; external ffi.Pointer< - ffi.NativeFunction< - JShortMarker Function( - ffi.Pointer, JClassPtr, JFieldIDPtr)>> - GetStaticShortField; + ffi.NativeFunction< + JCharMarker Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID)>> GetStaticCharField; external ffi.Pointer< ffi.NativeFunction< - JIntMarker Function( - ffi.Pointer, JClassPtr, JFieldIDPtr)>> GetStaticIntField; + JShortMarker Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID)>> GetStaticShortField; external ffi.Pointer< - ffi.NativeFunction< - JLongMarker Function( - ffi.Pointer, JClassPtr, JFieldIDPtr)>> - GetStaticLongField; + ffi.NativeFunction< + JIntMarker Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID)>> GetStaticIntField; external ffi.Pointer< - ffi.NativeFunction< - JFloatMarker Function( - ffi.Pointer, JClassPtr, JFieldIDPtr)>> - GetStaticFloatField; + ffi.NativeFunction< + JLongMarker Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID)>> GetStaticLongField; external ffi.Pointer< - ffi.NativeFunction< - JDoubleMarker Function( - ffi.Pointer, JClassPtr, JFieldIDPtr)>> - GetStaticDoubleField; + ffi.NativeFunction< + JFloatMarker Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID)>> GetStaticFloatField; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, JClassPtr, JFieldIDPtr, JObjectPtr)>> - SetStaticObjectField; + ffi.NativeFunction< + JDoubleMarker Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID)>> GetStaticDoubleField; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, JClassPtr, JFieldIDPtr, - JBooleanMarker)>> SetStaticBooleanField; + ffi.Void Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID, JObjectPtr val)>> SetStaticObjectField; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, JClassPtr, JFieldIDPtr, JByteMarker)>> - SetStaticByteField; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID, JBooleanMarker val)>> SetStaticBooleanField; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, JClassPtr, JFieldIDPtr, JCharMarker)>> - SetStaticCharField; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID, JByteMarker val)>> SetStaticByteField; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, JClassPtr, JFieldIDPtr, JShortMarker)>> - SetStaticShortField; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID, JCharMarker val)>> SetStaticCharField; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, JClassPtr, JFieldIDPtr, JIntMarker)>> - SetStaticIntField; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID, JShortMarker val)>> SetStaticShortField; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, JClassPtr, JFieldIDPtr, JLongMarker)>> - SetStaticLongField; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID, JIntMarker val)>> SetStaticIntField; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, JClassPtr, JFieldIDPtr, JFloatMarker)>> - SetStaticFloatField; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID, JLongMarker val)>> SetStaticLongField; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, JClassPtr, JFieldIDPtr, JDoubleMarker)>> - SetStaticDoubleField; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID, JFloatMarker val)>> SetStaticFloatField; external ffi.Pointer< - ffi.NativeFunction< - JStringPtr Function( - ffi.Pointer, ffi.Pointer, JSizeMarker)>> - NewString; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID, JDoubleMarker val)>> SetStaticDoubleField; external ffi.Pointer< - ffi.NativeFunction< - JSizeMarker Function(ffi.Pointer, JStringPtr)>> - GetStringLength; + ffi.NativeFunction< + JStringPtr Function( + ffi.Pointer env, + ffi.Pointer unicodeChars, + JSizeMarker len)>> NewString; external ffi.Pointer< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, JStringPtr, - ffi.Pointer)>> GetStringChars; + JSizeMarker Function( + ffi.Pointer env, JStringPtr string)>> GetStringLength; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, JStringPtr, ffi.Pointer)>> - ReleaseStringChars; + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer env, + JStringPtr string, + ffi.Pointer isCopy)>> GetStringChars; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JStringPtr string, + ffi.Pointer isCopy)>> ReleaseStringChars; external ffi.Pointer< ffi.NativeFunction< - JStringPtr Function(ffi.Pointer, ffi.Pointer)>> + JStringPtr Function( + ffi.Pointer env, ffi.Pointer bytes)>> NewStringUTF; external ffi.Pointer< - ffi.NativeFunction< - JSizeMarker Function(ffi.Pointer, JStringPtr)>> - GetStringUTFLength; + ffi.NativeFunction< + JSizeMarker Function( + ffi.Pointer env, JStringPtr string)>> GetStringUTFLength; external ffi.Pointer< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, JStringPtr, - ffi.Pointer)>> GetStringUTFChars; + ffi.Pointer Function( + ffi.Pointer env, + JStringPtr string, + ffi.Pointer isCopy)>> GetStringUTFChars; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, JStringPtr, ffi.Pointer)>> - ReleaseStringUTFChars; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JStringPtr string, + ffi.Pointer utf)>> ReleaseStringUTFChars; external ffi.Pointer< ffi.NativeFunction< - JSizeMarker Function(ffi.Pointer, JArrayPtr)>> + JSizeMarker Function(ffi.Pointer env, JArrayPtr array)>> GetArrayLength; external ffi.Pointer< - ffi.NativeFunction< - JObjectArrayPtr Function( - ffi.Pointer, JSizeMarker, JClassPtr, JObjectPtr)>> - NewObjectArray; + ffi.NativeFunction< + JObjectArrayPtr Function( + ffi.Pointer env, + JSizeMarker length, + JClassPtr elementClass, + JObjectPtr initialElement)>> NewObjectArray; external ffi.Pointer< - ffi.NativeFunction< - JObjectPtr Function( - ffi.Pointer, JObjectArrayPtr, JSizeMarker)>> - GetObjectArrayElement; + ffi.NativeFunction< + JObjectPtr Function(ffi.Pointer env, JObjectArrayPtr array, + JSizeMarker index)>> GetObjectArrayElement; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, JObjectArrayPtr, JSizeMarker, - JObjectPtr)>> SetObjectArrayElement; + ffi.Void Function(ffi.Pointer env, JObjectArrayPtr array, + JSizeMarker index, JObjectPtr val)>> SetObjectArrayElement; external ffi.Pointer< - ffi.NativeFunction< - JBooleanArrayPtr Function(ffi.Pointer, JSizeMarker)>> - NewBooleanArray; + ffi.NativeFunction< + JBooleanArrayPtr Function( + ffi.Pointer env, JSizeMarker length)>> NewBooleanArray; external ffi.Pointer< - ffi.NativeFunction< - JByteArrayPtr Function(ffi.Pointer, JSizeMarker)>> - NewByteArray; + ffi.NativeFunction< + JByteArrayPtr Function( + ffi.Pointer env, JSizeMarker length)>> NewByteArray; external ffi.Pointer< - ffi.NativeFunction< - JCharArrayPtr Function(ffi.Pointer, JSizeMarker)>> - NewCharArray; + ffi.NativeFunction< + JCharArrayPtr Function( + ffi.Pointer env, JSizeMarker length)>> NewCharArray; external ffi.Pointer< - ffi.NativeFunction< - JShortArrayPtr Function(ffi.Pointer, JSizeMarker)>> - NewShortArray; + ffi.NativeFunction< + JShortArrayPtr Function( + ffi.Pointer env, JSizeMarker length)>> NewShortArray; external ffi.Pointer< - ffi.NativeFunction< - JIntArrayPtr Function(ffi.Pointer, JSizeMarker)>> - NewIntArray; + ffi.NativeFunction< + JIntArrayPtr Function( + ffi.Pointer env, JSizeMarker length)>> NewIntArray; external ffi.Pointer< - ffi.NativeFunction< - JLongArrayPtr Function(ffi.Pointer, JSizeMarker)>> - NewLongArray; + ffi.NativeFunction< + JLongArrayPtr Function( + ffi.Pointer env, JSizeMarker length)>> NewLongArray; external ffi.Pointer< - ffi.NativeFunction< - JFloatArrayPtr Function(ffi.Pointer, JSizeMarker)>> - NewFloatArray; + ffi.NativeFunction< + JFloatArrayPtr Function( + ffi.Pointer env, JSizeMarker length)>> NewFloatArray; external ffi.Pointer< - ffi.NativeFunction< - JDoubleArrayPtr Function(ffi.Pointer, JSizeMarker)>> - NewDoubleArray; + ffi.NativeFunction< + JDoubleArrayPtr Function( + ffi.Pointer env, JSizeMarker length)>> NewDoubleArray; external ffi.Pointer< ffi.NativeFunction< ffi.Pointer Function( - ffi.Pointer, - JBooleanArrayPtr, - ffi.Pointer)>> GetBooleanArrayElements; + ffi.Pointer env, + JBooleanArrayPtr array, + ffi.Pointer isCopy)>> GetBooleanArrayElements; external ffi.Pointer< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, JByteArrayPtr, - ffi.Pointer)>> GetByteArrayElements; + ffi.Pointer Function( + ffi.Pointer env, + JByteArrayPtr array, + ffi.Pointer isCopy)>> GetByteArrayElements; external ffi.Pointer< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, JCharArrayPtr, - ffi.Pointer)>> GetCharArrayElements; + ffi.Pointer Function( + ffi.Pointer env, + JCharArrayPtr array, + ffi.Pointer isCopy)>> GetCharArrayElements; external ffi.Pointer< ffi.NativeFunction< ffi.Pointer Function( - ffi.Pointer, - JShortArrayPtr, - ffi.Pointer)>> GetShortArrayElements; + ffi.Pointer env, + JShortArrayPtr array, + ffi.Pointer isCopy)>> GetShortArrayElements; external ffi.Pointer< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, JIntArrayPtr, - ffi.Pointer)>> GetIntArrayElements; + ffi.Pointer Function( + ffi.Pointer env, + JIntArrayPtr array, + ffi.Pointer isCopy)>> GetIntArrayElements; external ffi.Pointer< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, JLongArrayPtr, - ffi.Pointer)>> GetLongArrayElements; + ffi.Pointer Function( + ffi.Pointer env, + JLongArrayPtr array, + ffi.Pointer isCopy)>> GetLongArrayElements; external ffi.Pointer< ffi.NativeFunction< ffi.Pointer Function( - ffi.Pointer, - JFloatArrayPtr, - ffi.Pointer)>> GetFloatArrayElements; + ffi.Pointer env, + JFloatArrayPtr array, + ffi.Pointer isCopy)>> GetFloatArrayElements; external ffi.Pointer< ffi.NativeFunction< ffi.Pointer Function( - ffi.Pointer, - JDoubleArrayPtr, - ffi.Pointer)>> GetDoubleArrayElements; + ffi.Pointer env, + JDoubleArrayPtr array, + ffi.Pointer isCopy)>> GetDoubleArrayElements; external ffi.Pointer< ffi.NativeFunction< ffi.Void Function( - ffi.Pointer, - JBooleanArrayPtr, - ffi.Pointer, - JIntMarker)>> ReleaseBooleanArrayElements; + ffi.Pointer env, + JBooleanArrayPtr array, + ffi.Pointer elems, + JIntMarker mode)>> ReleaseBooleanArrayElements; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, JByteArrayPtr, - ffi.Pointer, JIntMarker)>> ReleaseByteArrayElements; + ffi.Void Function( + ffi.Pointer env, + JByteArrayPtr array, + ffi.Pointer elems, + JIntMarker mode)>> ReleaseByteArrayElements; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, JCharArrayPtr, - ffi.Pointer, JIntMarker)>> ReleaseCharArrayElements; + ffi.Void Function( + ffi.Pointer env, + JCharArrayPtr array, + ffi.Pointer elems, + JIntMarker mode)>> ReleaseCharArrayElements; external ffi.Pointer< ffi.NativeFunction< ffi.Void Function( - ffi.Pointer, - JShortArrayPtr, - ffi.Pointer, - JIntMarker)>> ReleaseShortArrayElements; + ffi.Pointer env, + JShortArrayPtr array, + ffi.Pointer elems, + JIntMarker mode)>> ReleaseShortArrayElements; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, JIntArrayPtr, - ffi.Pointer, JIntMarker)>> ReleaseIntArrayElements; + ffi.Void Function( + ffi.Pointer env, + JIntArrayPtr array, + ffi.Pointer elems, + JIntMarker mode)>> ReleaseIntArrayElements; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, JLongArrayPtr, - ffi.Pointer, JIntMarker)>> ReleaseLongArrayElements; + ffi.Void Function( + ffi.Pointer env, + JLongArrayPtr array, + ffi.Pointer elems, + JIntMarker mode)>> ReleaseLongArrayElements; external ffi.Pointer< ffi.NativeFunction< ffi.Void Function( - ffi.Pointer, - JFloatArrayPtr, - ffi.Pointer, - JIntMarker)>> ReleaseFloatArrayElements; + ffi.Pointer env, + JFloatArrayPtr array, + ffi.Pointer elems, + JIntMarker mode)>> ReleaseFloatArrayElements; external ffi.Pointer< ffi.NativeFunction< ffi.Void Function( - ffi.Pointer, - JDoubleArrayPtr, - ffi.Pointer, - JIntMarker)>> ReleaseDoubleArrayElements; + ffi.Pointer env, + JDoubleArrayPtr array, + ffi.Pointer elems, + JIntMarker mode)>> ReleaseDoubleArrayElements; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, JBooleanArrayPtr, JSizeMarker, - JSizeMarker, ffi.Pointer)>> GetBooleanArrayRegion; + ffi.Void Function( + ffi.Pointer env, + JBooleanArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> GetBooleanArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, JByteArrayPtr, JSizeMarker, - JSizeMarker, ffi.Pointer)>> GetByteArrayRegion; + ffi.Void Function( + ffi.Pointer env, + JByteArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> GetByteArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, JCharArrayPtr, JSizeMarker, - JSizeMarker, ffi.Pointer)>> GetCharArrayRegion; + ffi.Void Function( + ffi.Pointer env, + JCharArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> GetCharArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, JShortArrayPtr, JSizeMarker, - JSizeMarker, ffi.Pointer)>> GetShortArrayRegion; + ffi.Void Function( + ffi.Pointer env, + JShortArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> GetShortArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, JIntArrayPtr, JSizeMarker, - JSizeMarker, ffi.Pointer)>> GetIntArrayRegion; + ffi.Void Function( + ffi.Pointer env, + JIntArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> GetIntArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, JLongArrayPtr, JSizeMarker, - JSizeMarker, ffi.Pointer)>> GetLongArrayRegion; + ffi.Void Function( + ffi.Pointer env, + JLongArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> GetLongArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, JFloatArrayPtr, JSizeMarker, - JSizeMarker, ffi.Pointer)>> GetFloatArrayRegion; + ffi.Void Function( + ffi.Pointer env, + JFloatArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> GetFloatArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, JDoubleArrayPtr, JSizeMarker, - JSizeMarker, ffi.Pointer)>> GetDoubleArrayRegion; + 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< - ffi.Void Function(ffi.Pointer, JBooleanArrayPtr, JSizeMarker, - JSizeMarker, ffi.Pointer)>> SetBooleanArrayRegion; + ffi.Void Function( + ffi.Pointer env, + JBooleanArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> SetBooleanArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, JByteArrayPtr, JSizeMarker, - JSizeMarker, ffi.Pointer)>> SetByteArrayRegion; + ffi.Void Function( + ffi.Pointer env, + JByteArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> SetByteArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, JCharArrayPtr, JSizeMarker, - JSizeMarker, ffi.Pointer)>> SetCharArrayRegion; + ffi.Void Function( + ffi.Pointer env, + JCharArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> SetCharArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, JShortArrayPtr, JSizeMarker, - JSizeMarker, ffi.Pointer)>> SetShortArrayRegion; + ffi.Void Function( + ffi.Pointer env, + JShortArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> SetShortArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, JIntArrayPtr, JSizeMarker, - JSizeMarker, ffi.Pointer)>> SetIntArrayRegion; + ffi.Void Function( + ffi.Pointer env, + JIntArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> SetIntArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, JLongArrayPtr, JSizeMarker, - JSizeMarker, ffi.Pointer)>> SetLongArrayRegion; + ffi.Void Function( + ffi.Pointer env, + JLongArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> SetLongArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, JFloatArrayPtr, JSizeMarker, - JSizeMarker, ffi.Pointer)>> SetFloatArrayRegion; + ffi.Void Function( + ffi.Pointer env, + JFloatArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> SetFloatArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, JDoubleArrayPtr, JSizeMarker, - JSizeMarker, ffi.Pointer)>> SetDoubleArrayRegion; + ffi.Void Function( + ffi.Pointer env, + JDoubleArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> SetDoubleArrayRegion; external ffi.Pointer< ffi.NativeFunction< - JIntMarker Function(ffi.Pointer, JClassPtr, - ffi.Pointer, JIntMarker)>> RegisterNatives; + JIntMarker Function( + ffi.Pointer env, + JClassPtr clazz, + ffi.Pointer methods, + JIntMarker nMethods)>> RegisterNatives; external ffi.Pointer< ffi.NativeFunction< - JIntMarker Function(ffi.Pointer, JClassPtr)>> + JIntMarker Function(ffi.Pointer env, JClassPtr clazz)>> UnregisterNatives; external ffi.Pointer< - ffi.NativeFunction< - JIntMarker Function(ffi.Pointer, JObjectPtr)>> MonitorEnter; + ffi.NativeFunction< + JIntMarker Function(ffi.Pointer env, JObjectPtr obj)>> + MonitorEnter; external ffi.Pointer< - ffi.NativeFunction< - JIntMarker Function(ffi.Pointer, JObjectPtr)>> MonitorExit; + ffi.NativeFunction< + JIntMarker Function(ffi.Pointer env, JObjectPtr obj)>> + MonitorExit; external ffi.Pointer< - ffi.NativeFunction< - JIntMarker Function( - ffi.Pointer, ffi.Pointer>)>> - GetJavaVM; + ffi.NativeFunction< + JIntMarker Function(ffi.Pointer env, + ffi.Pointer> vm)>> GetJavaVM; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, JStringPtr, JSizeMarker, - JSizeMarker, ffi.Pointer)>> GetStringRegion; + ffi.Void Function( + ffi.Pointer env, + JStringPtr str, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> GetStringRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, JStringPtr, JSizeMarker, - JSizeMarker, ffi.Pointer)>> GetStringUTFRegion; + ffi.Void Function( + ffi.Pointer env, + JStringPtr str, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> GetStringUTFRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, JArrayPtr, - ffi.Pointer)>> GetPrimitiveArrayCritical; + ffi.Pointer Function( + ffi.Pointer env, + JArrayPtr array, + ffi.Pointer isCopy)>> GetPrimitiveArrayCritical; external ffi.Pointer< ffi.NativeFunction< ffi.Void Function( - ffi.Pointer, - JArrayPtr, - ffi.Pointer, - JIntMarker)>> ReleasePrimitiveArrayCritical; + ffi.Pointer env, + JArrayPtr array, + ffi.Pointer carray, + JIntMarker mode)>> ReleasePrimitiveArrayCritical; external ffi.Pointer< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, JStringPtr, - ffi.Pointer)>> GetStringCritical; + ffi.Pointer Function( + ffi.Pointer env, + JStringPtr str, + ffi.Pointer isCopy)>> GetStringCritical; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, JStringPtr, ffi.Pointer)>> - ReleaseStringCritical; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JStringPtr str, + ffi.Pointer carray)>> ReleaseStringCritical; external ffi.Pointer< ffi.NativeFunction< - JWeakPtr Function(ffi.Pointer, JObjectPtr)>> + JWeakPtr Function(ffi.Pointer env, JObjectPtr obj)>> NewWeakGlobalRef; external ffi.Pointer< - ffi.NativeFunction, JWeakPtr)>> + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JWeakPtr obj)>> DeleteWeakGlobalRef; external ffi.Pointer< - ffi.NativeFunction)>> + ffi.NativeFunction env)>> ExceptionCheck; external ffi.Pointer< - ffi.NativeFunction< - JObjectPtr Function( - ffi.Pointer, ffi.Pointer, JLongMarker)>> - NewDirectByteBuffer; + ffi.NativeFunction< + JObjectPtr Function( + ffi.Pointer env, + ffi.Pointer address, + JLongMarker capacity)>> NewDirectByteBuffer; external ffi.Pointer< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, JObjectPtr)>> + ffi.Pointer Function( + ffi.Pointer env, JObjectPtr buf)>> GetDirectBufferAddress; external ffi.Pointer< ffi.NativeFunction< - JLongMarker Function(ffi.Pointer, JObjectPtr)>> + JLongMarker Function(ffi.Pointer env, JObjectPtr buf)>> GetDirectBufferCapacity; /// added in JNI 1.6 external ffi.Pointer< ffi.NativeFunction< - ffi.Int32 Function(ffi.Pointer, JObjectPtr)>> + ffi.Int32 Function(ffi.Pointer env, JObjectPtr obj)>> GetObjectRefType; } typedef JniEnv1 = ffi.Pointer; -typedef JClassPtr = JObjectPtr; - -/// "cardinal indices and sizes" -typedef JSizeMarker = JIntMarker; -typedef JMethodIDPtr = ffi.Pointer; -typedef JFieldIDPtr = ffi.Pointer; -typedef JThrowablePtr = JObjectPtr; -typedef JStringPtr = JObjectPtr; -typedef JArrayPtr = JObjectPtr; typedef JObjectArrayPtr = JArrayPtr; typedef JBooleanArrayPtr = JArrayPtr; typedef JByteArrayPtr = JArrayPtr; @@ -1467,26 +1896,22 @@ typedef JIntArrayPtr = JArrayPtr; typedef JLongArrayPtr = JArrayPtr; typedef JFloatArrayPtr = JArrayPtr; typedef JDoubleArrayPtr = JArrayPtr; -typedef JWeakPtr = JObjectPtr; - -class JavaVMAttachArgs extends ffi.Struct { - /// must be >= JNI_VERSION_1_2 - @JIntMarker() - external int version; - /// NULL or name of thread as modified UTF-8 str +class JNINativeMethod extends ffi.Struct { external ffi.Pointer name; - /// global ref of a ThreadGroup object, or NULL - external JObjectPtr group; + external ffi.Pointer signature; + + external ffi.Pointer fnPtr; } -/// JNI 1.2+ initialization. (As of 1.6, the pre-1.2 structures are no -/// longer supported.) -class JavaVMOption extends ffi.Struct { - external ffi.Pointer optionString; +typedef JWeakPtr = JObjectPtr; - external ffi.Pointer extraInfo; +abstract class JObjectRefType { + static const int JNIInvalidRefType = 0; + static const int JNILocalRefType = 1; + static const int JNIGlobalRefType = 2; + static const int JNIWeakGlobalRefType = 3; } class JavaVMInitArgs extends ffi.Struct { @@ -1503,2300 +1928,1318 @@ class JavaVMInitArgs extends ffi.Struct { external int ignoreUnrecognized; } -/// Types used by JNI API to distinguish between primitive types. -abstract class JniCallType { - static const int booleanType = 0; - static const int byteType = 1; - static const int shortType = 2; - static const int charType = 3; - static const int intType = 4; - static const int longType = 5; - static const int floatType = 6; - static const int doubleType = 7; - static const int objectType = 8; - static const int voidType = 9; -} - -/// 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]. -class JniResult extends ffi.Struct { - external JValue result; +/// JNI 1.2+ initialization. (As of 1.6, the pre-1.2 structures are no +/// longer supported.) +class JavaVMOption extends ffi.Struct { + external ffi.Pointer optionString; - external JThrowablePtr exception; + external ffi.Pointer extraInfo; } -/// Similar to [JniResult] but for class lookups. -class JniClassLookupResult extends ffi.Struct { - external JClassPtr classRef; - - external JThrowablePtr exception; -} +class GlobalJniEnv extends ffi.Struct { + external ffi.Pointer reserved0; -/// Similar to [JniResult] but for method/field ID lookups. -class JniPointerResult extends ffi.Struct { - external ffi.Pointer id; + external ffi.Pointer reserved1; - external JThrowablePtr exception; -} + external ffi.Pointer reserved2; -/// JniExceptionDetails holds 2 jstring objects, one is the result of -/// calling `toString` on exception object, other is stack trace; -class JniExceptionDetails extends ffi.Struct { - external JStringPtr message; + external ffi.Pointer reserved3; - external JStringPtr stacktrace; -} + external ffi.Pointer> GetVersion; -/// This struct contains functions which wrap method call / field access conveniently along with -/// exception checking. -/// -/// Flutter embedding checks for pending JNI exceptions before an FFI transition, which requires us -/// to check for and clear the exception before returning to dart code, which requires these functions -/// to return result types. -class JniAccessors extends ffi.Struct { external ffi.Pointer< ffi.NativeFunction< - JniClassLookupResult Function(ffi.Pointer)>> getClass; - - external ffi.Pointer< - ffi.NativeFunction< - JniPointerResult Function( - JClassPtr, ffi.Pointer, ffi.Pointer)>> - getFieldID; - - external ffi.Pointer< - ffi.NativeFunction< - JniPointerResult Function( - JClassPtr, ffi.Pointer, ffi.Pointer)>> - getStaticFieldID; - - external ffi.Pointer< - ffi.NativeFunction< - JniPointerResult Function( - JClassPtr, ffi.Pointer, ffi.Pointer)>> - getMethodID; - - external ffi.Pointer< - ffi.NativeFunction< - JniPointerResult Function( - JClassPtr, ffi.Pointer, ffi.Pointer)>> - getStaticMethodID; - - external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JClassPtr, JMethodIDPtr, ffi.Pointer)>> - newObject; - - external ffi.Pointer< - ffi.NativeFunction> - newPrimitiveArray; - - external ffi.Pointer< - ffi.NativeFunction< - JniPointerResult Function(JSizeMarker, JClassPtr, JObjectPtr)>> - newObjectArray; - - external ffi.Pointer< - ffi.NativeFunction> - getArrayElement; - - external ffi.Pointer< - ffi.NativeFunction< - JniResult Function( - JObjectPtr, JMethodIDPtr, ffi.Int, ffi.Pointer)>> - callMethod; - - external ffi.Pointer< - ffi.NativeFunction< - JniResult Function( - JClassPtr, JMethodIDPtr, ffi.Int, ffi.Pointer)>> - callStaticMethod; + JniClassLookupResult Function( + ffi.Pointer name, + JObjectPtr loader, + ffi.Pointer buf, + JSizeMarker bufLen)>> DefineClass; external ffi.Pointer< ffi.NativeFunction< - JniResult Function(JObjectPtr, JFieldIDPtr, ffi.Int)>> getField; + JniClassLookupResult Function(ffi.Pointer name)>> FindClass; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JClassPtr, JFieldIDPtr, ffi.Int)>> getStaticField; + ffi.NativeFunction> + FromReflectedMethod; external ffi.Pointer< - ffi.NativeFunction> - getExceptionDetails; -} - -extension JniAccessorsExtension on ffi.Pointer { - JniClassLookupResult getClass(ffi.Pointer internalName) { - return ref.getClass - .asFunction)>()( - internalName); - } - - JniPointerResult getFieldID(JClassPtr cls, ffi.Pointer fieldName, - ffi.Pointer signature) { - return ref.getFieldID.asFunction< - JniPointerResult Function(JClassPtr, ffi.Pointer, - ffi.Pointer)>()(cls, fieldName, signature); - } - - JniPointerResult getStaticFieldID(JClassPtr cls, - ffi.Pointer fieldName, ffi.Pointer signature) { - return ref.getStaticFieldID.asFunction< - JniPointerResult Function(JClassPtr, ffi.Pointer, - ffi.Pointer)>()(cls, fieldName, signature); - } - - JniPointerResult getMethodID(JClassPtr cls, ffi.Pointer methodName, - ffi.Pointer signature) { - return ref.getMethodID.asFunction< - JniPointerResult Function(JClassPtr, ffi.Pointer, - ffi.Pointer)>()(cls, methodName, signature); - } - - JniPointerResult getStaticMethodID(JClassPtr cls, - ffi.Pointer methodName, ffi.Pointer signature) { - return ref.getStaticMethodID.asFunction< - JniPointerResult Function(JClassPtr, ffi.Pointer, - ffi.Pointer)>()(cls, methodName, signature); - } - - JniResult newObject( - JClassPtr cls, JMethodIDPtr ctor, ffi.Pointer args) { - return ref.newObject.asFunction< - JniResult Function( - JClassPtr, JMethodIDPtr, ffi.Pointer)>()(cls, ctor, args); - } - - JniPointerResult newPrimitiveArray(int length, int type) { - return ref.newPrimitiveArray - .asFunction()(length, type); - } - - JniPointerResult newObjectArray( - int length, JClassPtr elementClass, JObjectPtr initialElement) { - return ref.newObjectArray.asFunction< - JniPointerResult Function(int, JClassPtr, JObjectPtr)>()( - length, elementClass, initialElement); - } - - JniResult getArrayElement(JArrayPtr array, int index, int type) { - return ref.getArrayElement - .asFunction()( - array, index, type); - } - - JniResult callMethod(JObjectPtr obj, JMethodIDPtr methodID, int callType, - ffi.Pointer args) { - return ref.callMethod.asFunction< - JniResult Function(JObjectPtr, JMethodIDPtr, int, - ffi.Pointer)>()(obj, methodID, callType, args); - } - - JniResult callStaticMethod(JClassPtr cls, JMethodIDPtr methodID, int callType, - ffi.Pointer args) { - return ref.callStaticMethod.asFunction< - JniResult Function(JClassPtr, JMethodIDPtr, int, - ffi.Pointer)>()(cls, methodID, callType, args); - } - - JniResult getField(JObjectPtr obj, JFieldIDPtr fieldID, int callType) { - return ref.getField - .asFunction()( - obj, fieldID, callType); - } - - JniResult getStaticField(JClassPtr cls, JFieldIDPtr fieldID, int callType) { - return ref.getStaticField - .asFunction()( - cls, fieldID, callType); - } - - JniExceptionDetails getExceptionDetails(JThrowablePtr exception) { - return ref.getExceptionDetails - .asFunction()(exception); - } -} - -/// Wrapper over JNIEnv in the JNI API, which can be used from multiple Dart -/// Threads. -/// -/// It consists of wrappers to JNIEnv methods which manage the thread-local -/// JNIEnv pointer in C code. Additionally, any returned local reference value -/// is converted to global reference. -/// -/// For the documentation on methods themselves, see the JNI Specification at -/// https://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/functions.html -/// -/// Apart from the specification, the Android NDK's JNI page consists of useful -/// information about using the JNI: -/// https://developer.android.com/training/articles/perf-jni -class GlobalJniEnv extends ffi.Struct { - external ffi.Pointer> GetVersion; + ffi.NativeFunction> + FromReflectedField; external ffi.Pointer< ffi.NativeFunction< - JClassPtr Function(ffi.Pointer, JObjectPtr, - ffi.Pointer, JSizeMarker)>> DefineClass; + JniResult Function(JClassPtr cls, JMethodIDPtr methodId, + JBooleanMarker isStatic)>> ToReflectedMethod; external ffi.Pointer< - ffi.NativeFunction)>> FindClass; - - external ffi.Pointer> - FromReflectedMethod; - - external ffi.Pointer> - FromReflectedField; - - external ffi.Pointer< - ffi.NativeFunction< - JObjectPtr Function(JClassPtr, JMethodIDPtr, JBooleanMarker)>> - ToReflectedMethod; - - external ffi.Pointer> + ffi.NativeFunction> GetSuperclass; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JniResult Function(JClassPtr clazz1, JClassPtr clazz2)>> IsAssignableFrom; external ffi.Pointer< ffi.NativeFunction< - JObjectPtr Function(JClassPtr, JFieldIDPtr, JBooleanMarker)>> + JniResult Function( + JClassPtr cls, JFieldIDPtr fieldID, JBooleanMarker isStatic)>> ToReflectedField; - external ffi.Pointer> - Throw; + external ffi + .Pointer> Throw; external ffi.Pointer< ffi.NativeFunction< - JIntMarker Function(JClassPtr, ffi.Pointer)>> ThrowNew; + JniResult Function( + JClassPtr clazz, ffi.Pointer message)>> ThrowNew; - external ffi.Pointer> + external ffi.Pointer> ExceptionOccurred; - external ffi.Pointer> + external ffi.Pointer> ExceptionDescribe; - external ffi.Pointer> ExceptionClear; + external ffi.Pointer> + ExceptionClear; - external ffi - .Pointer)>> + external ffi.Pointer< + ffi.NativeFunction msg)>> FatalError; - external ffi.Pointer> + external ffi + .Pointer> PushLocalFrame; - external ffi.Pointer> + external ffi + .Pointer> PopLocalFrame; - external ffi.Pointer> + external ffi.Pointer> NewGlobalRef; - external ffi.Pointer> + external ffi.Pointer< + ffi.NativeFunction> DeleteGlobalRef; external ffi.Pointer< - ffi.NativeFunction> - IsSameObject; + ffi.NativeFunction> + DeleteLocalRef; + + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr ref1, JObjectPtr ref2)>> IsSameObject; + + external ffi.Pointer> + NewLocalRef; - external ffi.Pointer> + external ffi + .Pointer> EnsureLocalCapacity; - external ffi.Pointer> + external ffi.Pointer> AllocObject; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> NewObject; external ffi.Pointer< ffi.NativeFunction< - JObjectPtr Function( - JClassPtr, JMethodIDPtr, ffi.Pointer)>> NewObjectA; + JniResult Function( + JClassPtr, JMethodIDPtr, ffi.Pointer)>> NewObjectV; + + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>> NewObjectA; - external ffi.Pointer> + external ffi.Pointer< + ffi.NativeFunction> GetObjectClass; external ffi.Pointer< - ffi.NativeFunction> - IsInstanceOf; + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JClassPtr clazz)>> IsInstanceOf; external ffi.Pointer< - ffi.NativeFunction< - JMethodIDPtr Function( - JClassPtr, ffi.Pointer, ffi.Pointer)>> - GetMethodID; + ffi.NativeFunction< + JniPointerResult Function(JClassPtr clazz, ffi.Pointer name, + ffi.Pointer sig)>> GetMethodID; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID)>> CallObjectMethod; external ffi.Pointer< ffi.NativeFunction< - JObjectPtr Function( - JObjectPtr, JMethodIDPtr, ffi.Pointer)>> - CallObjectMethodA; + JniResult Function( + JObjectPtr, JMethodIDPtr, ffi.Pointer)>> + CallObjectMethodV; external ffi.Pointer< - ffi.NativeFunction> - CallBooleanMethod; + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Pointer args)>> CallObjectMethodA; external ffi.Pointer< ffi.NativeFunction< - JBooleanMarker Function( - JObjectPtr, JMethodIDPtr, ffi.Pointer)>> - CallBooleanMethodA; + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID)>> + CallBooleanMethod; external ffi.Pointer< - ffi.NativeFunction> - CallByteMethod; + ffi.NativeFunction< + JniResult Function( + JObjectPtr, JMethodIDPtr, ffi.Pointer)>> + CallBooleanMethodV; external ffi.Pointer< ffi.NativeFunction< - JByteMarker Function( - JObjectPtr, JMethodIDPtr, ffi.Pointer)>> CallByteMethodA; + JniResult Function(JObjectPtr obj, JMethodIDPtr methodId, + ffi.Pointer args)>> CallBooleanMethodA; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID)>> + CallByteMethod; + + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function( + JObjectPtr, JMethodIDPtr, ffi.Pointer)>> + CallByteMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Pointer args)>> CallByteMethodA; + + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID)>> CallCharMethod; + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function( + JObjectPtr, JMethodIDPtr, ffi.Pointer)>> + CallCharMethodV; + external ffi.Pointer< ffi.NativeFunction< - JCharMarker Function( - JObjectPtr, JMethodIDPtr, ffi.Pointer)>> CallCharMethodA; + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Pointer args)>> CallCharMethodA; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID)>> CallShortMethod; + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function( + JObjectPtr, JMethodIDPtr, ffi.Pointer)>> + CallShortMethodV; + external ffi.Pointer< ffi.NativeFunction< - JShortMarker Function( - JObjectPtr, JMethodIDPtr, ffi.Pointer)>> CallShortMethodA; + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Pointer args)>> CallShortMethodA; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID)>> CallIntMethod; external ffi.Pointer< ffi.NativeFunction< - JIntMarker Function( - JObjectPtr, JMethodIDPtr, ffi.Pointer)>> CallIntMethodA; + JniResult Function( + JObjectPtr, JMethodIDPtr, ffi.Pointer)>> CallIntMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Pointer args)>> CallIntMethodA; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID)>> CallLongMethod; + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function( + JObjectPtr, JMethodIDPtr, ffi.Pointer)>> + CallLongMethodV; + external ffi.Pointer< ffi.NativeFunction< - JLongMarker Function( - JObjectPtr, JMethodIDPtr, ffi.Pointer)>> CallLongMethodA; + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Pointer args)>> CallLongMethodA; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID)>> CallFloatMethod; + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function( + JObjectPtr, JMethodIDPtr, ffi.Pointer)>> + CallFloatMethodV; + external ffi.Pointer< ffi.NativeFunction< - JFloatMarker Function( - JObjectPtr, JMethodIDPtr, ffi.Pointer)>> CallFloatMethodA; + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Pointer args)>> CallFloatMethodA; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID)>> CallDoubleMethod; external ffi.Pointer< ffi.NativeFunction< - JDoubleMarker Function( - JObjectPtr, JMethodIDPtr, ffi.Pointer)>> - CallDoubleMethodA; + JniResult Function( + JObjectPtr, JMethodIDPtr, ffi.Pointer)>> + CallDoubleMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Pointer args)>> CallDoubleMethodA; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JThrowablePtr Function(JObjectPtr obj, JMethodIDPtr methodID)>> CallVoidMethod; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JObjectPtr, JMethodIDPtr, ffi.Pointer)>> - CallVoidMethodA; + JThrowablePtr Function( + JObjectPtr, JMethodIDPtr, ffi.Pointer)>> + CallVoidMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Pointer args)>> CallVoidMethodA; external ffi.Pointer< ffi.NativeFunction< - JObjectPtr Function(JObjectPtr, JClassPtr, JMethodIDPtr)>> + JniResult Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> CallNonvirtualObjectMethod; external ffi.Pointer< ffi.NativeFunction< - JObjectPtr Function( - JObjectPtr, JClassPtr, JMethodIDPtr, ffi.Pointer)>> - CallNonvirtualObjectMethodA; + JniResult Function( + JObjectPtr, JClassPtr, JMethodIDPtr, ffi.Pointer)>> + CallNonvirtualObjectMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function( + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallNonvirtualObjectMethodA; external ffi.Pointer< ffi.NativeFunction< - JBooleanMarker Function(JObjectPtr, JClassPtr, JMethodIDPtr)>> + JniResult Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> CallNonvirtualBooleanMethod; external ffi.Pointer< ffi.NativeFunction< - JBooleanMarker Function( - JObjectPtr, JClassPtr, JMethodIDPtr, ffi.Pointer)>> - CallNonvirtualBooleanMethodA; + JniResult Function( + JObjectPtr, JClassPtr, JMethodIDPtr, ffi.Pointer)>> + CallNonvirtualBooleanMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function( + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallNonvirtualBooleanMethodA; external ffi.Pointer< ffi.NativeFunction< - JByteMarker Function(JObjectPtr, JClassPtr, JMethodIDPtr)>> + JniResult Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> CallNonvirtualByteMethod; external ffi.Pointer< ffi.NativeFunction< - JByteMarker Function( - JObjectPtr, JClassPtr, JMethodIDPtr, ffi.Pointer)>> - CallNonvirtualByteMethodA; + JniResult Function( + JObjectPtr, JClassPtr, JMethodIDPtr, ffi.Pointer)>> + CallNonvirtualByteMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function( + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallNonvirtualByteMethodA; external ffi.Pointer< ffi.NativeFunction< - JCharMarker Function(JObjectPtr, JClassPtr, JMethodIDPtr)>> + JniResult Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> CallNonvirtualCharMethod; external ffi.Pointer< ffi.NativeFunction< - JCharMarker Function( - JObjectPtr, JClassPtr, JMethodIDPtr, ffi.Pointer)>> - CallNonvirtualCharMethodA; + JniResult Function( + JObjectPtr, JClassPtr, JMethodIDPtr, ffi.Pointer)>> + CallNonvirtualCharMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function( + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallNonvirtualCharMethodA; external ffi.Pointer< ffi.NativeFunction< - JShortMarker Function(JObjectPtr, JClassPtr, JMethodIDPtr)>> + JniResult Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> CallNonvirtualShortMethod; external ffi.Pointer< ffi.NativeFunction< - JShortMarker Function( - JObjectPtr, JClassPtr, JMethodIDPtr, ffi.Pointer)>> - CallNonvirtualShortMethodA; + JniResult Function( + JObjectPtr, JClassPtr, JMethodIDPtr, ffi.Pointer)>> + CallNonvirtualShortMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function( + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallNonvirtualShortMethodA; external ffi.Pointer< ffi.NativeFunction< - JIntMarker Function(JObjectPtr, JClassPtr, JMethodIDPtr)>> + JniResult Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> CallNonvirtualIntMethod; external ffi.Pointer< ffi.NativeFunction< - JIntMarker Function( - JObjectPtr, JClassPtr, JMethodIDPtr, ffi.Pointer)>> - CallNonvirtualIntMethodA; + JniResult Function( + JObjectPtr, JClassPtr, JMethodIDPtr, ffi.Pointer)>> + CallNonvirtualIntMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function( + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallNonvirtualIntMethodA; external ffi.Pointer< ffi.NativeFunction< - JLongMarker Function(JObjectPtr, JClassPtr, JMethodIDPtr)>> + JniResult Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> CallNonvirtualLongMethod; external ffi.Pointer< ffi.NativeFunction< - JLongMarker Function( - JObjectPtr, JClassPtr, JMethodIDPtr, ffi.Pointer)>> - CallNonvirtualLongMethodA; + JniResult Function( + JObjectPtr, JClassPtr, JMethodIDPtr, ffi.Pointer)>> + CallNonvirtualLongMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function( + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallNonvirtualLongMethodA; external ffi.Pointer< ffi.NativeFunction< - JFloatMarker Function(JObjectPtr, JClassPtr, JMethodIDPtr)>> + JniResult Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> CallNonvirtualFloatMethod; external ffi.Pointer< ffi.NativeFunction< - JFloatMarker Function( - JObjectPtr, JClassPtr, JMethodIDPtr, ffi.Pointer)>> - CallNonvirtualFloatMethodA; + JniResult Function( + JObjectPtr, JClassPtr, JMethodIDPtr, ffi.Pointer)>> + CallNonvirtualFloatMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function( + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallNonvirtualFloatMethodA; external ffi.Pointer< ffi.NativeFunction< - JDoubleMarker Function(JObjectPtr, JClassPtr, JMethodIDPtr)>> + JniResult Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> CallNonvirtualDoubleMethod; external ffi.Pointer< ffi.NativeFunction< - JDoubleMarker Function( - JObjectPtr, JClassPtr, JMethodIDPtr, ffi.Pointer)>> - CallNonvirtualDoubleMethodA; + JniResult Function( + JObjectPtr, JClassPtr, JMethodIDPtr, ffi.Pointer)>> + CallNonvirtualDoubleMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function( + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallNonvirtualDoubleMethodA; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JObjectPtr, JClassPtr, JMethodIDPtr)>> + JThrowablePtr Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> CallNonvirtualVoidMethod; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function( - JObjectPtr, JClassPtr, JMethodIDPtr, ffi.Pointer)>> - CallNonvirtualVoidMethodA; + JThrowablePtr Function( + JObjectPtr, JClassPtr, JMethodIDPtr, ffi.Pointer)>> + CallNonvirtualVoidMethodV; external ffi.Pointer< - ffi.NativeFunction< - JFieldIDPtr Function( - JClassPtr, ffi.Pointer, ffi.Pointer)>> - GetFieldID; + ffi.NativeFunction< + JThrowablePtr Function( + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallNonvirtualVoidMethodA; + + external ffi.Pointer< + ffi.NativeFunction< + JniPointerResult Function(JClassPtr clazz, ffi.Pointer name, + ffi.Pointer sig)>> GetFieldID; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID)>> GetObjectField; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID)>> GetBooleanField; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID)>> GetByteField; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID)>> GetCharField; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID)>> GetShortField; external ffi.Pointer< - ffi.NativeFunction> - GetIntField; + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID)>> GetIntField; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID)>> GetLongField; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID)>> GetFloatField; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID)>> GetDoubleField; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JObjectPtr, JFieldIDPtr, JObjectPtr)>> + JThrowablePtr Function( + JObjectPtr obj, JFieldIDPtr fieldID, JObjectPtr val)>> SetObjectField; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JObjectPtr, JFieldIDPtr, JBooleanMarker)>> + JThrowablePtr Function( + JObjectPtr obj, JFieldIDPtr fieldID, JBooleanMarker val)>> SetBooleanField; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JObjectPtr, JFieldIDPtr, JByteMarker)>> + JThrowablePtr Function( + JObjectPtr obj, JFieldIDPtr fieldID, JByteMarker val)>> SetByteField; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JObjectPtr, JFieldIDPtr, JCharMarker)>> + JThrowablePtr Function( + JObjectPtr obj, JFieldIDPtr fieldID, JCharMarker val)>> SetCharField; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JObjectPtr, JFieldIDPtr, JShortMarker)>> + JThrowablePtr Function( + JObjectPtr obj, JFieldIDPtr fieldID, JShortMarker val)>> SetShortField; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(JObjectPtr, JFieldIDPtr, JIntMarker)>> SetIntField; + ffi.NativeFunction< + JThrowablePtr Function( + JObjectPtr obj, JFieldIDPtr fieldID, JIntMarker val)>> + SetIntField; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JObjectPtr, JFieldIDPtr, JLongMarker)>> + JThrowablePtr Function( + JObjectPtr obj, JFieldIDPtr fieldID, JLongMarker val)>> SetLongField; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JObjectPtr, JFieldIDPtr, JFloatMarker)>> + JThrowablePtr Function( + JObjectPtr obj, JFieldIDPtr fieldID, JFloatMarker val)>> SetFloatField; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JObjectPtr, JFieldIDPtr, JDoubleMarker)>> + JThrowablePtr Function( + JObjectPtr obj, JFieldIDPtr fieldID, JDoubleMarker val)>> SetDoubleField; external ffi.Pointer< - ffi.NativeFunction< - JMethodIDPtr Function( - JClassPtr, ffi.Pointer, ffi.Pointer)>> - GetStaticMethodID; + ffi.NativeFunction< + JniPointerResult Function(JClassPtr clazz, ffi.Pointer name, + ffi.Pointer sig)>> GetStaticMethodID; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> CallStaticObjectMethod; external ffi.Pointer< ffi.NativeFunction< - JObjectPtr Function( - JClassPtr, JMethodIDPtr, ffi.Pointer)>> - CallStaticObjectMethodA; + JniResult Function( + JClassPtr, JMethodIDPtr, ffi.Pointer)>> + CallStaticObjectMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticObjectMethodA; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> CallStaticBooleanMethod; external ffi.Pointer< ffi.NativeFunction< - JBooleanMarker Function( - JClassPtr, JMethodIDPtr, ffi.Pointer)>> - CallStaticBooleanMethodA; + JniResult Function( + JClassPtr, JMethodIDPtr, ffi.Pointer)>> + CallStaticBooleanMethodV; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticBooleanMethodA; + + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> CallStaticByteMethod; external ffi.Pointer< ffi.NativeFunction< - JByteMarker Function( - JClassPtr, JMethodIDPtr, ffi.Pointer)>> - CallStaticByteMethodA; + JniResult Function( + JClassPtr, JMethodIDPtr, ffi.Pointer)>> + CallStaticByteMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticByteMethodA; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> CallStaticCharMethod; external ffi.Pointer< ffi.NativeFunction< - JCharMarker Function( - JClassPtr, JMethodIDPtr, ffi.Pointer)>> - CallStaticCharMethodA; + JniResult Function( + JClassPtr, JMethodIDPtr, ffi.Pointer)>> + CallStaticCharMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticCharMethodA; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> CallStaticShortMethod; external ffi.Pointer< ffi.NativeFunction< - JShortMarker Function( - JClassPtr, JMethodIDPtr, ffi.Pointer)>> - CallStaticShortMethodA; + JniResult Function( + JClassPtr, JMethodIDPtr, ffi.Pointer)>> + CallStaticShortMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticShortMethodA; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> CallStaticIntMethod; external ffi.Pointer< ffi.NativeFunction< - JIntMarker Function( - JClassPtr, JMethodIDPtr, ffi.Pointer)>> - CallStaticIntMethodA; + JniResult Function( + JClassPtr, JMethodIDPtr, ffi.Pointer)>> + CallStaticIntMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticIntMethodA; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> CallStaticLongMethod; external ffi.Pointer< ffi.NativeFunction< - JLongMarker Function( - JClassPtr, JMethodIDPtr, ffi.Pointer)>> - CallStaticLongMethodA; + JniResult Function( + JClassPtr, JMethodIDPtr, ffi.Pointer)>> + CallStaticLongMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticLongMethodA; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> CallStaticFloatMethod; external ffi.Pointer< ffi.NativeFunction< - JFloatMarker Function( - JClassPtr, JMethodIDPtr, ffi.Pointer)>> - CallStaticFloatMethodA; + JniResult Function( + JClassPtr, JMethodIDPtr, ffi.Pointer)>> + CallStaticFloatMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticFloatMethodA; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> CallStaticDoubleMethod; external ffi.Pointer< ffi.NativeFunction< - JDoubleMarker Function( - JClassPtr, JMethodIDPtr, ffi.Pointer)>> - CallStaticDoubleMethodA; + JniResult Function( + JClassPtr, JMethodIDPtr, ffi.Pointer)>> + CallStaticDoubleMethodV; external ffi.Pointer< - ffi.NativeFunction> - CallStaticVoidMethod; + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticDoubleMethodA; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JClassPtr, JMethodIDPtr, ffi.Pointer)>> - CallStaticVoidMethodA; + JThrowablePtr Function(JClassPtr clazz, JMethodIDPtr methodID)>> + CallStaticVoidMethod; external ffi.Pointer< ffi.NativeFunction< - JFieldIDPtr Function( - JClassPtr, ffi.Pointer, ffi.Pointer)>> - GetStaticFieldID; + JThrowablePtr Function( + JClassPtr, JMethodIDPtr, ffi.Pointer)>> + CallStaticVoidMethodV; + + external ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticVoidMethodA; + + external ffi.Pointer< + ffi.NativeFunction< + JniPointerResult Function(JClassPtr clazz, ffi.Pointer name, + ffi.Pointer sig)>> GetStaticFieldID; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JFieldIDPtr fieldID)>> GetStaticObjectField; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JFieldIDPtr fieldID)>> GetStaticBooleanField; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JFieldIDPtr fieldID)>> GetStaticByteField; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JFieldIDPtr fieldID)>> GetStaticCharField; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JFieldIDPtr fieldID)>> GetStaticShortField; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JFieldIDPtr fieldID)>> GetStaticIntField; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JFieldIDPtr fieldID)>> GetStaticLongField; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JFieldIDPtr fieldID)>> GetStaticFloatField; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JFieldIDPtr fieldID)>> GetStaticDoubleField; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JClassPtr, JFieldIDPtr, JObjectPtr)>> + JThrowablePtr Function( + JClassPtr clazz, JFieldIDPtr fieldID, JObjectPtr val)>> SetStaticObjectField; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JClassPtr, JFieldIDPtr, JBooleanMarker)>> + JThrowablePtr Function( + JClassPtr clazz, JFieldIDPtr fieldID, JBooleanMarker val)>> SetStaticBooleanField; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JClassPtr, JFieldIDPtr, JByteMarker)>> + JThrowablePtr Function( + JClassPtr clazz, JFieldIDPtr fieldID, JByteMarker val)>> SetStaticByteField; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JClassPtr, JFieldIDPtr, JCharMarker)>> + JThrowablePtr Function( + JClassPtr clazz, JFieldIDPtr fieldID, JCharMarker val)>> SetStaticCharField; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JClassPtr, JFieldIDPtr, JShortMarker)>> + JThrowablePtr Function( + JClassPtr clazz, JFieldIDPtr fieldID, JShortMarker val)>> SetStaticShortField; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JClassPtr, JFieldIDPtr, JIntMarker)>> + JThrowablePtr Function( + JClassPtr clazz, JFieldIDPtr fieldID, JIntMarker val)>> SetStaticIntField; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JClassPtr, JFieldIDPtr, JLongMarker)>> + JThrowablePtr Function( + JClassPtr clazz, JFieldIDPtr fieldID, JLongMarker val)>> SetStaticLongField; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JClassPtr, JFieldIDPtr, JFloatMarker)>> + JThrowablePtr Function( + JClassPtr clazz, JFieldIDPtr fieldID, JFloatMarker val)>> SetStaticFloatField; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JClassPtr, JFieldIDPtr, JDoubleMarker)>> + JThrowablePtr Function( + JClassPtr clazz, JFieldIDPtr fieldID, JDoubleMarker val)>> SetStaticDoubleField; external ffi.Pointer< ffi.NativeFunction< - JStringPtr Function(ffi.Pointer, JSizeMarker)>> + JniResult Function( + ffi.Pointer unicodeChars, JSizeMarker len)>> NewString; - external ffi.Pointer> + external ffi + .Pointer> GetStringLength; external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function( - JStringPtr, ffi.Pointer)>> GetStringChars; + ffi.NativeFunction< + JniPointerResult Function( + JStringPtr string, ffi.Pointer isCopy)>> + GetStringChars; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JStringPtr, ffi.Pointer)>> + JThrowablePtr Function( + JStringPtr string, ffi.Pointer isCopy)>> ReleaseStringChars; external ffi.Pointer< - ffi.NativeFunction)>> + ffi.NativeFunction bytes)>> NewStringUTF; - external ffi.Pointer> + external ffi + .Pointer> GetStringUTFLength; external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function( - JStringPtr, ffi.Pointer)>> GetStringUTFChars; + ffi.NativeFunction< + JniPointerResult Function( + JStringPtr string, ffi.Pointer isCopy)>> + GetStringUTFChars; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JStringPtr, ffi.Pointer)>> + JThrowablePtr Function( + JStringPtr string, ffi.Pointer utf)>> ReleaseStringUTFChars; - external ffi.Pointer> + external ffi.Pointer> GetArrayLength; external ffi.Pointer< - ffi.NativeFunction< - JObjectArrayPtr Function(JSizeMarker, JClassPtr, JObjectPtr)>> - NewObjectArray; + ffi.NativeFunction< + JniResult Function(JSizeMarker length, JClassPtr elementClass, + JObjectPtr initialElement)>> NewObjectArray; external ffi.Pointer< - ffi.NativeFunction> + ffi.NativeFunction< + JniResult Function(JObjectArrayPtr array, JSizeMarker index)>> GetObjectArrayElement; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JObjectArrayPtr, JSizeMarker, JObjectPtr)>> + JThrowablePtr Function( + JObjectArrayPtr array, JSizeMarker index, JObjectPtr val)>> SetObjectArrayElement; external ffi - .Pointer> + .Pointer> NewBooleanArray; - external ffi.Pointer> + external ffi + .Pointer> NewByteArray; - external ffi.Pointer> + external ffi + .Pointer> NewCharArray; - external ffi.Pointer> + external ffi + .Pointer> NewShortArray; - external ffi.Pointer> + external ffi + .Pointer> NewIntArray; - external ffi.Pointer> + external ffi + .Pointer> NewLongArray; - external ffi.Pointer> + external ffi + .Pointer> NewFloatArray; external ffi - .Pointer> + .Pointer> NewDoubleArray; external ffi.Pointer< ffi.NativeFunction< - ffi.Pointer Function( - JBooleanArrayPtr, ffi.Pointer)>> + JniPointerResult Function( + JBooleanArrayPtr array, ffi.Pointer isCopy)>> GetBooleanArrayElements; external ffi.Pointer< ffi.NativeFunction< - ffi.Pointer Function( - JByteArrayPtr, ffi.Pointer)>> + JniPointerResult Function( + JByteArrayPtr array, ffi.Pointer isCopy)>> GetByteArrayElements; external ffi.Pointer< ffi.NativeFunction< - ffi.Pointer Function( - JCharArrayPtr, ffi.Pointer)>> + JniPointerResult Function( + JCharArrayPtr array, ffi.Pointer isCopy)>> GetCharArrayElements; external ffi.Pointer< ffi.NativeFunction< - ffi.Pointer Function( - JShortArrayPtr, ffi.Pointer)>> + JniPointerResult Function( + JShortArrayPtr array, ffi.Pointer isCopy)>> GetShortArrayElements; external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function( - JIntArrayPtr, ffi.Pointer)>> GetIntArrayElements; + ffi.NativeFunction< + JniPointerResult Function( + JIntArrayPtr array, ffi.Pointer isCopy)>> + GetIntArrayElements; external ffi.Pointer< ffi.NativeFunction< - ffi.Pointer Function( - JLongArrayPtr, ffi.Pointer)>> + JniPointerResult Function( + JLongArrayPtr array, ffi.Pointer isCopy)>> GetLongArrayElements; external ffi.Pointer< ffi.NativeFunction< - ffi.Pointer Function( - JFloatArrayPtr, ffi.Pointer)>> + JniPointerResult Function( + JFloatArrayPtr array, ffi.Pointer isCopy)>> GetFloatArrayElements; external ffi.Pointer< ffi.NativeFunction< - ffi.Pointer Function( - JDoubleArrayPtr, ffi.Pointer)>> + JniPointerResult Function( + JDoubleArrayPtr array, ffi.Pointer isCopy)>> GetDoubleArrayElements; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - JBooleanArrayPtr, ffi.Pointer, JIntMarker)>> - ReleaseBooleanArrayElements; + ffi.NativeFunction< + JThrowablePtr Function( + JBooleanArrayPtr array, + ffi.Pointer elems, + JIntMarker mode)>> ReleaseBooleanArrayElements; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - JByteArrayPtr, ffi.Pointer, JIntMarker)>> - ReleaseByteArrayElements; + ffi.NativeFunction< + JThrowablePtr Function( + JByteArrayPtr array, + ffi.Pointer elems, + JIntMarker mode)>> ReleaseByteArrayElements; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - JCharArrayPtr, ffi.Pointer, JIntMarker)>> - ReleaseCharArrayElements; + ffi.NativeFunction< + JThrowablePtr Function( + JCharArrayPtr array, + ffi.Pointer elems, + JIntMarker mode)>> ReleaseCharArrayElements; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - JShortArrayPtr, ffi.Pointer, JIntMarker)>> - ReleaseShortArrayElements; + ffi.NativeFunction< + JThrowablePtr Function( + JShortArrayPtr array, + ffi.Pointer elems, + JIntMarker mode)>> ReleaseShortArrayElements; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - JIntArrayPtr, ffi.Pointer, JIntMarker)>> - ReleaseIntArrayElements; + ffi.NativeFunction< + JThrowablePtr Function( + JIntArrayPtr array, + ffi.Pointer elems, + JIntMarker mode)>> ReleaseIntArrayElements; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - JLongArrayPtr, ffi.Pointer, JIntMarker)>> - ReleaseLongArrayElements; + ffi.NativeFunction< + JThrowablePtr Function( + JLongArrayPtr array, + ffi.Pointer elems, + JIntMarker mode)>> ReleaseLongArrayElements; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - JFloatArrayPtr, ffi.Pointer, JIntMarker)>> - ReleaseFloatArrayElements; + ffi.NativeFunction< + JThrowablePtr Function( + JFloatArrayPtr array, + ffi.Pointer elems, + JIntMarker mode)>> ReleaseFloatArrayElements; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - JDoubleArrayPtr, ffi.Pointer, JIntMarker)>> - ReleaseDoubleArrayElements; + ffi.NativeFunction< + JThrowablePtr Function( + JDoubleArrayPtr array, + ffi.Pointer elems, + JIntMarker mode)>> ReleaseDoubleArrayElements; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JBooleanArrayPtr, JSizeMarker, JSizeMarker, - ffi.Pointer)>> GetBooleanArrayRegion; + JThrowablePtr Function( + JBooleanArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> GetBooleanArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JByteArrayPtr, JSizeMarker, JSizeMarker, - ffi.Pointer)>> GetByteArrayRegion; + JThrowablePtr Function( + JByteArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> GetByteArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JCharArrayPtr, JSizeMarker, JSizeMarker, - ffi.Pointer)>> GetCharArrayRegion; + JThrowablePtr Function( + JCharArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> GetCharArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JShortArrayPtr, JSizeMarker, JSizeMarker, - ffi.Pointer)>> GetShortArrayRegion; + JThrowablePtr Function( + JShortArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> GetShortArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JIntArrayPtr, JSizeMarker, JSizeMarker, - ffi.Pointer)>> GetIntArrayRegion; + JThrowablePtr Function(JIntArrayPtr array, JSizeMarker start, + JSizeMarker len, ffi.Pointer buf)>> GetIntArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JLongArrayPtr, JSizeMarker, JSizeMarker, - ffi.Pointer)>> GetLongArrayRegion; + JThrowablePtr Function( + JLongArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> GetLongArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JFloatArrayPtr, JSizeMarker, JSizeMarker, - ffi.Pointer)>> GetFloatArrayRegion; + JThrowablePtr Function( + JFloatArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> GetFloatArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JDoubleArrayPtr, JSizeMarker, JSizeMarker, - ffi.Pointer)>> GetDoubleArrayRegion; + JThrowablePtr Function( + JDoubleArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> GetDoubleArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JBooleanArrayPtr, JSizeMarker, JSizeMarker, - ffi.Pointer)>> SetBooleanArrayRegion; + JThrowablePtr Function( + JBooleanArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> SetBooleanArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JByteArrayPtr, JSizeMarker, JSizeMarker, - ffi.Pointer)>> SetByteArrayRegion; + JThrowablePtr Function( + JByteArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> SetByteArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JCharArrayPtr, JSizeMarker, JSizeMarker, - ffi.Pointer)>> SetCharArrayRegion; + JThrowablePtr Function( + JCharArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> SetCharArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JShortArrayPtr, JSizeMarker, JSizeMarker, - ffi.Pointer)>> SetShortArrayRegion; + JThrowablePtr Function( + JShortArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> SetShortArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JIntArrayPtr, JSizeMarker, JSizeMarker, - ffi.Pointer)>> SetIntArrayRegion; + JThrowablePtr Function(JIntArrayPtr array, JSizeMarker start, + JSizeMarker len, ffi.Pointer buf)>> SetIntArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JLongArrayPtr, JSizeMarker, JSizeMarker, - ffi.Pointer)>> SetLongArrayRegion; + JThrowablePtr Function( + JLongArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> SetLongArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JFloatArrayPtr, JSizeMarker, JSizeMarker, - ffi.Pointer)>> SetFloatArrayRegion; + JThrowablePtr Function( + JFloatArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> SetFloatArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JDoubleArrayPtr, JSizeMarker, JSizeMarker, - ffi.Pointer)>> SetDoubleArrayRegion; + JThrowablePtr Function( + JDoubleArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> SetDoubleArrayRegion; external ffi.Pointer< - ffi.NativeFunction< - JIntMarker Function( - JClassPtr, ffi.Pointer, JIntMarker)>> - RegisterNatives; + ffi.NativeFunction< + JniResult Function( + JClassPtr clazz, + ffi.Pointer methods, + JIntMarker nMethods)>> RegisterNatives; - external ffi.Pointer> + external ffi.Pointer> UnregisterNatives; - external ffi.Pointer> + external ffi.Pointer> MonitorEnter; - external ffi.Pointer> + external ffi.Pointer> MonitorExit; external ffi.Pointer< ffi.NativeFunction< - JIntMarker Function(ffi.Pointer>)>> GetJavaVM; + JniResult Function(ffi.Pointer> vm)>> GetJavaVM; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JStringPtr, JSizeMarker, JSizeMarker, - ffi.Pointer)>> GetStringRegion; + JThrowablePtr Function(JStringPtr str, JSizeMarker start, + JSizeMarker len, ffi.Pointer buf)>> GetStringRegion; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - JStringPtr, JSizeMarker, JSizeMarker, ffi.Pointer)>> - GetStringUTFRegion; + ffi.NativeFunction< + JThrowablePtr Function(JStringPtr str, JSizeMarker start, + JSizeMarker len, ffi.Pointer buf)>> GetStringUTFRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Pointer Function( - JArrayPtr, ffi.Pointer)>> + JniPointerResult Function( + JArrayPtr array, ffi.Pointer isCopy)>> GetPrimitiveArrayCritical; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(JArrayPtr, ffi.Pointer, JIntMarker)>> - ReleasePrimitiveArrayCritical; + ffi.NativeFunction< + JThrowablePtr Function(JArrayPtr array, ffi.Pointer carray, + JIntMarker mode)>> ReleasePrimitiveArrayCritical; external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function( - JStringPtr, ffi.Pointer)>> GetStringCritical; + ffi.NativeFunction< + JniPointerResult Function( + JStringPtr str, ffi.Pointer isCopy)>> + GetStringCritical; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(JStringPtr, ffi.Pointer)>> + JThrowablePtr Function( + JStringPtr str, ffi.Pointer carray)>> ReleaseStringCritical; - external ffi.Pointer> + external ffi.Pointer> NewWeakGlobalRef; - external ffi.Pointer> + external ffi.Pointer> DeleteWeakGlobalRef; - external ffi.Pointer> - ExceptionCheck; + external ffi.Pointer> ExceptionCheck; external ffi.Pointer< ffi.NativeFunction< - JObjectPtr Function(ffi.Pointer, JLongMarker)>> + JniResult Function( + ffi.Pointer address, JLongMarker capacity)>> NewDirectByteBuffer; external ffi.Pointer< - ffi.NativeFunction Function(JObjectPtr)>> + ffi.NativeFunction> GetDirectBufferAddress; - external ffi.Pointer> + external ffi.Pointer> GetDirectBufferCapacity; - external ffi.Pointer> + external ffi.Pointer> GetObjectRefType; } -extension GlobalJniEnvExtension on ffi.Pointer { - int GetVersion() { - return ref.GetVersion.asFunction()(); - } - - JClassPtr DefineClass(ffi.Pointer name, JObjectPtr loader, - ffi.Pointer buf, int bufLen) { - return ref.DefineClass.asFunction< - JClassPtr Function(ffi.Pointer, JObjectPtr, - ffi.Pointer, int)>()(name, loader, buf, bufLen); - } +/// This file re-exports some JNI constants as enum, because they are not +/// currently being included when they are in macro form. +abstract class JniBooleanValues { + static const int JNI_FALSE = 0; + static const int JNI_TRUE = 1; +} - JClassPtr FindClass(ffi.Pointer name) { - return ref.FindClass.asFunction< - JClassPtr Function(ffi.Pointer)>()(name); - } +abstract class JniVersions { + static const int JNI_VERSION_1_1 = 65537; + static const int JNI_VERSION_1_2 = 65538; + static const int JNI_VERSION_1_4 = 65540; + static const int JNI_VERSION_1_6 = 65542; +} - JMethodIDPtr FromReflectedMethod(JObjectPtr method) { - return ref.FromReflectedMethod.asFunction< - JMethodIDPtr Function(JObjectPtr)>()(method); - } +abstract class JniErrorCode { + /// no error + static const int JNI_OK = 0; - JFieldIDPtr FromReflectedField(JObjectPtr field) { - return ref.FromReflectedField.asFunction< - JFieldIDPtr Function(JObjectPtr)>()(field); - } + /// generic error + static const int JNI_ERR = -1; - JObjectPtr ToReflectedMethod( - JClassPtr cls, JMethodIDPtr methodId, int isStatic) { - return ref.ToReflectedMethod.asFunction< - JObjectPtr Function( - JClassPtr, JMethodIDPtr, int)>()(cls, methodId, isStatic); - } + /// thread detached from the VM + static const int JNI_EDETACHED = -2; - JClassPtr GetSuperclass(JClassPtr clazz) { - return ref.GetSuperclass.asFunction()(clazz); - } + /// JNI version error + static const int JNI_EVERSION = -3; - int IsAssignableFrom(JClassPtr clazz1, JClassPtr clazz2) { - return ref.IsAssignableFrom.asFunction< - int Function(JClassPtr, JClassPtr)>()(clazz1, clazz2); - } + /// Out of memory + static const int JNI_ENOMEM = -4; - JObjectPtr ToReflectedField( - JClassPtr cls, JFieldIDPtr fieldID, int isStatic) { - return ref.ToReflectedField.asFunction< - JObjectPtr Function( - JClassPtr, JFieldIDPtr, int)>()(cls, fieldID, isStatic); - } + /// VM already created + static const int JNI_EEXIST = -5; - int Throw(JThrowablePtr obj) { - return ref.Throw.asFunction()(obj); - } + /// Invalid argument + static const int JNI_EINVAL = -6; +} - int ThrowNew(JClassPtr clazz, ffi.Pointer message) { - return ref.ThrowNew.asFunction< - int Function(JClassPtr, ffi.Pointer)>()(clazz, message); - } +abstract class JniBufferWriteBack { + /// copy content, do not free buffer + static const int JNI_COMMIT = 1; - JThrowablePtr ExceptionOccurred() { - return ref.ExceptionOccurred.asFunction()(); - } - - void ExceptionDescribe() { - return ref.ExceptionDescribe.asFunction()(); - } - - void ExceptionClear() { - return ref.ExceptionClear.asFunction()(); - } - - void FatalError(ffi.Pointer msg) { - return ref.FatalError.asFunction)>()( - msg); - } - - int PushLocalFrame(int capacity) { - return ref.PushLocalFrame.asFunction()(capacity); - } - - JObjectPtr PopLocalFrame(JObjectPtr result) { - return ref.PopLocalFrame.asFunction()( - result); - } - - JObjectPtr NewGlobalRef(JObjectPtr obj) { - return ref.NewGlobalRef.asFunction()(obj); - } - - void DeleteGlobalRef(JObjectPtr globalRef) { - return ref.DeleteGlobalRef.asFunction()( - globalRef); - } - - int IsSameObject(JObjectPtr ref1, JObjectPtr ref2) { - return ref.IsSameObject.asFunction()( - ref1, ref2); - } - - int EnsureLocalCapacity(int capacity) { - return ref.EnsureLocalCapacity.asFunction()(capacity); - } - - JObjectPtr AllocObject(JClassPtr clazz) { - return ref.AllocObject.asFunction()(clazz); - } - - JObjectPtr NewObject(JClassPtr arg1, JMethodIDPtr arg2) { - return ref.NewObject.asFunction< - JObjectPtr Function(JClassPtr, JMethodIDPtr)>()(arg1, arg2); - } - - JObjectPtr NewObjectA( - JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) { - return ref.NewObjectA.asFunction< - JObjectPtr Function(JClassPtr, JMethodIDPtr, - ffi.Pointer)>()(clazz, methodID, args); - } - - JClassPtr GetObjectClass(JObjectPtr obj) { - return ref.GetObjectClass.asFunction()(obj); - } - - int IsInstanceOf(JObjectPtr obj, JClassPtr clazz) { - return ref.IsInstanceOf.asFunction()( - obj, clazz); - } - - JMethodIDPtr GetMethodID( - JClassPtr clazz, ffi.Pointer name, ffi.Pointer sig) { - return ref.GetMethodID.asFunction< - JMethodIDPtr Function(JClassPtr, ffi.Pointer, - ffi.Pointer)>()(clazz, name, sig); - } - - JObjectPtr CallObjectMethod(JObjectPtr arg1, JMethodIDPtr arg2) { - return ref.CallObjectMethod.asFunction< - JObjectPtr Function(JObjectPtr, JMethodIDPtr)>()(arg1, arg2); - } - - JObjectPtr CallObjectMethodA( - JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) { - return ref.CallObjectMethodA.asFunction< - JObjectPtr Function(JObjectPtr, JMethodIDPtr, - ffi.Pointer)>()(obj, methodID, args); - } - - int CallBooleanMethod(JObjectPtr arg1, JMethodIDPtr arg2) { - return ref.CallBooleanMethod.asFunction< - int Function(JObjectPtr, JMethodIDPtr)>()(arg1, arg2); - } - - int CallBooleanMethodA( - JObjectPtr obj, JMethodIDPtr methodId, ffi.Pointer args) { - return ref.CallBooleanMethodA.asFunction< - int Function(JObjectPtr, JMethodIDPtr, ffi.Pointer)>()( - obj, methodId, args); - } - - int CallByteMethod(JObjectPtr arg1, JMethodIDPtr arg2) { - return ref.CallByteMethod.asFunction< - int Function(JObjectPtr, JMethodIDPtr)>()(arg1, arg2); - } - - int CallByteMethodA( - JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) { - return ref.CallByteMethodA.asFunction< - int Function(JObjectPtr, JMethodIDPtr, ffi.Pointer)>()( - obj, methodID, args); - } - - int CallCharMethod(JObjectPtr arg1, JMethodIDPtr arg2) { - return ref.CallCharMethod.asFunction< - int Function(JObjectPtr, JMethodIDPtr)>()(arg1, arg2); - } - - int CallCharMethodA( - JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) { - return ref.CallCharMethodA.asFunction< - int Function(JObjectPtr, JMethodIDPtr, ffi.Pointer)>()( - obj, methodID, args); - } - - int CallShortMethod(JObjectPtr arg1, JMethodIDPtr arg2) { - return ref.CallShortMethod.asFunction< - int Function(JObjectPtr, JMethodIDPtr)>()(arg1, arg2); - } - - int CallShortMethodA( - JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) { - return ref.CallShortMethodA.asFunction< - int Function(JObjectPtr, JMethodIDPtr, ffi.Pointer)>()( - obj, methodID, args); - } - - int CallIntMethod(JObjectPtr arg1, JMethodIDPtr arg2) { - return ref.CallIntMethod.asFunction< - int Function(JObjectPtr, JMethodIDPtr)>()(arg1, arg2); - } - - int CallIntMethodA( - JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) { - return ref.CallIntMethodA.asFunction< - int Function(JObjectPtr, JMethodIDPtr, ffi.Pointer)>()( - obj, methodID, args); - } - - int CallLongMethod(JObjectPtr arg1, JMethodIDPtr arg2) { - return ref.CallLongMethod.asFunction< - int Function(JObjectPtr, JMethodIDPtr)>()(arg1, arg2); - } - - int CallLongMethodA( - JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) { - return ref.CallLongMethodA.asFunction< - int Function(JObjectPtr, JMethodIDPtr, ffi.Pointer)>()( - obj, methodID, args); - } - - double CallFloatMethod(JObjectPtr arg1, JMethodIDPtr arg2) { - return ref.CallFloatMethod.asFunction< - double Function(JObjectPtr, JMethodIDPtr)>()(arg1, arg2); - } - - double CallFloatMethodA( - JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) { - return ref.CallFloatMethodA.asFunction< - double Function(JObjectPtr, JMethodIDPtr, ffi.Pointer)>()( - obj, methodID, args); - } - - double CallDoubleMethod(JObjectPtr arg1, JMethodIDPtr arg2) { - return ref.CallDoubleMethod.asFunction< - double Function(JObjectPtr, JMethodIDPtr)>()(arg1, arg2); - } - - double CallDoubleMethodA( - JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) { - return ref.CallDoubleMethodA.asFunction< - double Function(JObjectPtr, JMethodIDPtr, ffi.Pointer)>()( - obj, methodID, args); - } - - void CallVoidMethod(JObjectPtr arg1, JMethodIDPtr arg2) { - return ref.CallVoidMethod.asFunction< - void Function(JObjectPtr, JMethodIDPtr)>()(arg1, arg2); - } - - void CallVoidMethodA( - JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) { - return ref.CallVoidMethodA.asFunction< - void Function(JObjectPtr, JMethodIDPtr, ffi.Pointer)>()( - obj, methodID, args); - } - - JObjectPtr CallNonvirtualObjectMethod( - JObjectPtr arg1, JClassPtr arg2, JMethodIDPtr arg3) { - return ref.CallNonvirtualObjectMethod.asFunction< - JObjectPtr Function( - JObjectPtr, JClassPtr, JMethodIDPtr)>()(arg1, arg2, arg3); - } - - JObjectPtr CallNonvirtualObjectMethodA(JObjectPtr obj, JClassPtr clazz, - JMethodIDPtr methodID, ffi.Pointer args) { - return ref.CallNonvirtualObjectMethodA.asFunction< - JObjectPtr Function(JObjectPtr, JClassPtr, JMethodIDPtr, - ffi.Pointer)>()(obj, clazz, methodID, args); - } - - int CallNonvirtualBooleanMethod( - JObjectPtr arg1, JClassPtr arg2, JMethodIDPtr arg3) { - return ref.CallNonvirtualBooleanMethod.asFunction< - int Function(JObjectPtr, JClassPtr, JMethodIDPtr)>()(arg1, arg2, arg3); - } - - int CallNonvirtualBooleanMethodA(JObjectPtr obj, JClassPtr clazz, - JMethodIDPtr methodID, ffi.Pointer args) { - return ref.CallNonvirtualBooleanMethodA.asFunction< - int Function(JObjectPtr, JClassPtr, JMethodIDPtr, - ffi.Pointer)>()(obj, clazz, methodID, args); - } - - int CallNonvirtualByteMethod( - JObjectPtr arg1, JClassPtr arg2, JMethodIDPtr arg3) { - return ref.CallNonvirtualByteMethod.asFunction< - int Function(JObjectPtr, JClassPtr, JMethodIDPtr)>()(arg1, arg2, arg3); - } - - int CallNonvirtualByteMethodA(JObjectPtr obj, JClassPtr clazz, - JMethodIDPtr methodID, ffi.Pointer args) { - return ref.CallNonvirtualByteMethodA.asFunction< - int Function(JObjectPtr, JClassPtr, JMethodIDPtr, - ffi.Pointer)>()(obj, clazz, methodID, args); - } - - int CallNonvirtualCharMethod( - JObjectPtr arg1, JClassPtr arg2, JMethodIDPtr arg3) { - return ref.CallNonvirtualCharMethod.asFunction< - int Function(JObjectPtr, JClassPtr, JMethodIDPtr)>()(arg1, arg2, arg3); - } - - int CallNonvirtualCharMethodA(JObjectPtr obj, JClassPtr clazz, - JMethodIDPtr methodID, ffi.Pointer args) { - return ref.CallNonvirtualCharMethodA.asFunction< - int Function(JObjectPtr, JClassPtr, JMethodIDPtr, - ffi.Pointer)>()(obj, clazz, methodID, args); - } - - int CallNonvirtualShortMethod( - JObjectPtr arg1, JClassPtr arg2, JMethodIDPtr arg3) { - return ref.CallNonvirtualShortMethod.asFunction< - int Function(JObjectPtr, JClassPtr, JMethodIDPtr)>()(arg1, arg2, arg3); - } - - int CallNonvirtualShortMethodA(JObjectPtr obj, JClassPtr clazz, - JMethodIDPtr methodID, ffi.Pointer args) { - return ref.CallNonvirtualShortMethodA.asFunction< - int Function(JObjectPtr, JClassPtr, JMethodIDPtr, - ffi.Pointer)>()(obj, clazz, methodID, args); - } - - int CallNonvirtualIntMethod( - JObjectPtr arg1, JClassPtr arg2, JMethodIDPtr arg3) { - return ref.CallNonvirtualIntMethod.asFunction< - int Function(JObjectPtr, JClassPtr, JMethodIDPtr)>()(arg1, arg2, arg3); - } - - int CallNonvirtualIntMethodA(JObjectPtr obj, JClassPtr clazz, - JMethodIDPtr methodID, ffi.Pointer args) { - return ref.CallNonvirtualIntMethodA.asFunction< - int Function(JObjectPtr, JClassPtr, JMethodIDPtr, - ffi.Pointer)>()(obj, clazz, methodID, args); - } - - int CallNonvirtualLongMethod( - JObjectPtr arg1, JClassPtr arg2, JMethodIDPtr arg3) { - return ref.CallNonvirtualLongMethod.asFunction< - int Function(JObjectPtr, JClassPtr, JMethodIDPtr)>()(arg1, arg2, arg3); - } - - int CallNonvirtualLongMethodA(JObjectPtr obj, JClassPtr clazz, - JMethodIDPtr methodID, ffi.Pointer args) { - return ref.CallNonvirtualLongMethodA.asFunction< - int Function(JObjectPtr, JClassPtr, JMethodIDPtr, - ffi.Pointer)>()(obj, clazz, methodID, args); - } - - double CallNonvirtualFloatMethod( - JObjectPtr arg1, JClassPtr arg2, JMethodIDPtr arg3) { - return ref.CallNonvirtualFloatMethod.asFunction< - double Function( - JObjectPtr, JClassPtr, JMethodIDPtr)>()(arg1, arg2, arg3); - } - - double CallNonvirtualFloatMethodA(JObjectPtr obj, JClassPtr clazz, - JMethodIDPtr methodID, ffi.Pointer args) { - return ref.CallNonvirtualFloatMethodA.asFunction< - double Function(JObjectPtr, JClassPtr, JMethodIDPtr, - ffi.Pointer)>()(obj, clazz, methodID, args); - } - - double CallNonvirtualDoubleMethod( - JObjectPtr arg1, JClassPtr arg2, JMethodIDPtr arg3) { - return ref.CallNonvirtualDoubleMethod.asFunction< - double Function( - JObjectPtr, JClassPtr, JMethodIDPtr)>()(arg1, arg2, arg3); - } - - double CallNonvirtualDoubleMethodA(JObjectPtr obj, JClassPtr clazz, - JMethodIDPtr methodID, ffi.Pointer args) { - return ref.CallNonvirtualDoubleMethodA.asFunction< - double Function(JObjectPtr, JClassPtr, JMethodIDPtr, - ffi.Pointer)>()(obj, clazz, methodID, args); - } - - void CallNonvirtualVoidMethod( - JObjectPtr arg1, JClassPtr arg2, JMethodIDPtr arg3) { - return ref.CallNonvirtualVoidMethod.asFunction< - void Function(JObjectPtr, JClassPtr, JMethodIDPtr)>()(arg1, arg2, arg3); - } - - void CallNonvirtualVoidMethodA(JObjectPtr obj, JClassPtr clazz, - JMethodIDPtr methodID, ffi.Pointer args) { - return ref.CallNonvirtualVoidMethodA.asFunction< - void Function(JObjectPtr, JClassPtr, JMethodIDPtr, - ffi.Pointer)>()(obj, clazz, methodID, args); - } - - JFieldIDPtr GetFieldID( - JClassPtr clazz, ffi.Pointer name, ffi.Pointer sig) { - return ref.GetFieldID.asFunction< - JFieldIDPtr Function(JClassPtr, ffi.Pointer, - ffi.Pointer)>()(clazz, name, sig); - } - - JObjectPtr GetObjectField(JObjectPtr obj, JFieldIDPtr fieldID) { - return ref.GetObjectField.asFunction< - JObjectPtr Function(JObjectPtr, JFieldIDPtr)>()(obj, fieldID); - } - - int GetBooleanField(JObjectPtr obj, JFieldIDPtr fieldID) { - return ref.GetBooleanField.asFunction< - int Function(JObjectPtr, JFieldIDPtr)>()(obj, fieldID); - } - - int GetByteField(JObjectPtr obj, JFieldIDPtr fieldID) { - return ref.GetByteField.asFunction()( - obj, fieldID); - } - - int GetCharField(JObjectPtr obj, JFieldIDPtr fieldID) { - return ref.GetCharField.asFunction()( - obj, fieldID); - } - - int GetShortField(JObjectPtr obj, JFieldIDPtr fieldID) { - return ref.GetShortField.asFunction< - int Function(JObjectPtr, JFieldIDPtr)>()(obj, fieldID); - } - - int GetIntField(JObjectPtr obj, JFieldIDPtr fieldID) { - return ref.GetIntField.asFunction()( - obj, fieldID); - } - - int GetLongField(JObjectPtr obj, JFieldIDPtr fieldID) { - return ref.GetLongField.asFunction()( - obj, fieldID); - } - - double GetFloatField(JObjectPtr obj, JFieldIDPtr fieldID) { - return ref.GetFloatField.asFunction< - double Function(JObjectPtr, JFieldIDPtr)>()(obj, fieldID); - } - - double GetDoubleField(JObjectPtr obj, JFieldIDPtr fieldID) { - return ref.GetDoubleField.asFunction< - double Function(JObjectPtr, JFieldIDPtr)>()(obj, fieldID); - } - - void SetObjectField(JObjectPtr obj, JFieldIDPtr fieldID, JObjectPtr val) { - return ref.SetObjectField.asFunction< - void Function( - JObjectPtr, JFieldIDPtr, JObjectPtr)>()(obj, fieldID, val); - } - - void SetBooleanField(JObjectPtr obj, JFieldIDPtr fieldID, int val) { - return ref.SetBooleanField.asFunction< - void Function(JObjectPtr, JFieldIDPtr, int)>()(obj, fieldID, val); - } - - void SetByteField(JObjectPtr obj, JFieldIDPtr fieldID, int val) { - return ref.SetByteField.asFunction< - void Function(JObjectPtr, JFieldIDPtr, int)>()(obj, fieldID, val); - } - - void SetCharField(JObjectPtr obj, JFieldIDPtr fieldID, int val) { - return ref.SetCharField.asFunction< - void Function(JObjectPtr, JFieldIDPtr, int)>()(obj, fieldID, val); - } - - void SetShortField(JObjectPtr obj, JFieldIDPtr fieldID, int val) { - return ref.SetShortField.asFunction< - void Function(JObjectPtr, JFieldIDPtr, int)>()(obj, fieldID, val); - } - - void SetIntField(JObjectPtr obj, JFieldIDPtr fieldID, int val) { - return ref.SetIntField.asFunction< - void Function(JObjectPtr, JFieldIDPtr, int)>()(obj, fieldID, val); - } - - void SetLongField(JObjectPtr obj, JFieldIDPtr fieldID, int val) { - return ref.SetLongField.asFunction< - void Function(JObjectPtr, JFieldIDPtr, int)>()(obj, fieldID, val); - } - - void SetFloatField(JObjectPtr obj, JFieldIDPtr fieldID, double val) { - return ref.SetFloatField.asFunction< - void Function(JObjectPtr, JFieldIDPtr, double)>()(obj, fieldID, val); - } - - void SetDoubleField(JObjectPtr obj, JFieldIDPtr fieldID, double val) { - return ref.SetDoubleField.asFunction< - void Function(JObjectPtr, JFieldIDPtr, double)>()(obj, fieldID, val); - } - - JMethodIDPtr GetStaticMethodID( - JClassPtr clazz, ffi.Pointer name, ffi.Pointer sig) { - return ref.GetStaticMethodID.asFunction< - JMethodIDPtr Function(JClassPtr, ffi.Pointer, - ffi.Pointer)>()(clazz, name, sig); - } - - JObjectPtr CallStaticObjectMethod(JClassPtr arg1, JMethodIDPtr arg2) { - return ref.CallStaticObjectMethod.asFunction< - JObjectPtr Function(JClassPtr, JMethodIDPtr)>()(arg1, arg2); - } - - JObjectPtr CallStaticObjectMethodA( - JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) { - return ref.CallStaticObjectMethodA.asFunction< - JObjectPtr Function(JClassPtr, JMethodIDPtr, - ffi.Pointer)>()(clazz, methodID, args); - } - - int CallStaticBooleanMethod(JClassPtr arg1, JMethodIDPtr arg2) { - return ref.CallStaticBooleanMethod.asFunction< - int Function(JClassPtr, JMethodIDPtr)>()(arg1, arg2); - } - - int CallStaticBooleanMethodA( - JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) { - return ref.CallStaticBooleanMethodA.asFunction< - int Function(JClassPtr, JMethodIDPtr, ffi.Pointer)>()( - clazz, methodID, args); - } - - int CallStaticByteMethod(JClassPtr arg1, JMethodIDPtr arg2) { - return ref.CallStaticByteMethod.asFunction< - int Function(JClassPtr, JMethodIDPtr)>()(arg1, arg2); - } - - int CallStaticByteMethodA( - JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) { - return ref.CallStaticByteMethodA.asFunction< - int Function(JClassPtr, JMethodIDPtr, ffi.Pointer)>()( - clazz, methodID, args); - } - - int CallStaticCharMethod(JClassPtr arg1, JMethodIDPtr arg2) { - return ref.CallStaticCharMethod.asFunction< - int Function(JClassPtr, JMethodIDPtr)>()(arg1, arg2); - } - - int CallStaticCharMethodA( - JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) { - return ref.CallStaticCharMethodA.asFunction< - int Function(JClassPtr, JMethodIDPtr, ffi.Pointer)>()( - clazz, methodID, args); - } - - int CallStaticShortMethod(JClassPtr arg1, JMethodIDPtr arg2) { - return ref.CallStaticShortMethod.asFunction< - int Function(JClassPtr, JMethodIDPtr)>()(arg1, arg2); - } - - int CallStaticShortMethodA( - JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) { - return ref.CallStaticShortMethodA.asFunction< - int Function(JClassPtr, JMethodIDPtr, ffi.Pointer)>()( - clazz, methodID, args); - } - - int CallStaticIntMethod(JClassPtr arg1, JMethodIDPtr arg2) { - return ref.CallStaticIntMethod.asFunction< - int Function(JClassPtr, JMethodIDPtr)>()(arg1, arg2); - } - - int CallStaticIntMethodA( - JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) { - return ref.CallStaticIntMethodA.asFunction< - int Function(JClassPtr, JMethodIDPtr, ffi.Pointer)>()( - clazz, methodID, args); - } - - int CallStaticLongMethod(JClassPtr arg1, JMethodIDPtr arg2) { - return ref.CallStaticLongMethod.asFunction< - int Function(JClassPtr, JMethodIDPtr)>()(arg1, arg2); - } - - int CallStaticLongMethodA( - JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) { - return ref.CallStaticLongMethodA.asFunction< - int Function(JClassPtr, JMethodIDPtr, ffi.Pointer)>()( - clazz, methodID, args); - } - - double CallStaticFloatMethod(JClassPtr arg1, JMethodIDPtr arg2) { - return ref.CallStaticFloatMethod.asFunction< - double Function(JClassPtr, JMethodIDPtr)>()(arg1, arg2); - } - - double CallStaticFloatMethodA( - JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) { - return ref.CallStaticFloatMethodA.asFunction< - double Function(JClassPtr, JMethodIDPtr, ffi.Pointer)>()( - clazz, methodID, args); - } - - double CallStaticDoubleMethod(JClassPtr arg1, JMethodIDPtr arg2) { - return ref.CallStaticDoubleMethod.asFunction< - double Function(JClassPtr, JMethodIDPtr)>()(arg1, arg2); - } - - double CallStaticDoubleMethodA( - JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) { - return ref.CallStaticDoubleMethodA.asFunction< - double Function(JClassPtr, JMethodIDPtr, ffi.Pointer)>()( - clazz, methodID, args); - } - - void CallStaticVoidMethod(JClassPtr arg1, JMethodIDPtr arg2) { - return ref.CallStaticVoidMethod.asFunction< - void Function(JClassPtr, JMethodIDPtr)>()(arg1, arg2); - } - - void CallStaticVoidMethodA( - JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) { - return ref.CallStaticVoidMethodA.asFunction< - void Function(JClassPtr, JMethodIDPtr, ffi.Pointer)>()( - clazz, methodID, args); - } - - JFieldIDPtr GetStaticFieldID( - JClassPtr clazz, ffi.Pointer name, ffi.Pointer sig) { - return ref.GetStaticFieldID.asFunction< - JFieldIDPtr Function(JClassPtr, ffi.Pointer, - ffi.Pointer)>()(clazz, name, sig); - } - - JObjectPtr GetStaticObjectField(JClassPtr clazz, JFieldIDPtr fieldID) { - return ref.GetStaticObjectField.asFunction< - JObjectPtr Function(JClassPtr, JFieldIDPtr)>()(clazz, fieldID); - } - - int GetStaticBooleanField(JClassPtr clazz, JFieldIDPtr fieldID) { - return ref.GetStaticBooleanField.asFunction< - int Function(JClassPtr, JFieldIDPtr)>()(clazz, fieldID); - } - - int GetStaticByteField(JClassPtr clazz, JFieldIDPtr fieldID) { - return ref.GetStaticByteField.asFunction< - int Function(JClassPtr, JFieldIDPtr)>()(clazz, fieldID); - } - - int GetStaticCharField(JClassPtr clazz, JFieldIDPtr fieldID) { - return ref.GetStaticCharField.asFunction< - int Function(JClassPtr, JFieldIDPtr)>()(clazz, fieldID); - } - - int GetStaticShortField(JClassPtr clazz, JFieldIDPtr fieldID) { - return ref.GetStaticShortField.asFunction< - int Function(JClassPtr, JFieldIDPtr)>()(clazz, fieldID); - } - - int GetStaticIntField(JClassPtr clazz, JFieldIDPtr fieldID) { - return ref.GetStaticIntField.asFunction< - int Function(JClassPtr, JFieldIDPtr)>()(clazz, fieldID); - } - - int GetStaticLongField(JClassPtr clazz, JFieldIDPtr fieldID) { - return ref.GetStaticLongField.asFunction< - int Function(JClassPtr, JFieldIDPtr)>()(clazz, fieldID); - } - - double GetStaticFloatField(JClassPtr clazz, JFieldIDPtr fieldID) { - return ref.GetStaticFloatField.asFunction< - double Function(JClassPtr, JFieldIDPtr)>()(clazz, fieldID); - } - - double GetStaticDoubleField(JClassPtr clazz, JFieldIDPtr fieldID) { - return ref.GetStaticDoubleField.asFunction< - double Function(JClassPtr, JFieldIDPtr)>()(clazz, fieldID); - } - - void SetStaticObjectField( - JClassPtr clazz, JFieldIDPtr fieldID, JObjectPtr val) { - return ref.SetStaticObjectField.asFunction< - void Function( - JClassPtr, JFieldIDPtr, JObjectPtr)>()(clazz, fieldID, val); - } - - void SetStaticBooleanField(JClassPtr clazz, JFieldIDPtr fieldID, int val) { - return ref.SetStaticBooleanField.asFunction< - void Function(JClassPtr, JFieldIDPtr, int)>()(clazz, fieldID, val); - } - - void SetStaticByteField(JClassPtr clazz, JFieldIDPtr fieldID, int val) { - return ref.SetStaticByteField.asFunction< - void Function(JClassPtr, JFieldIDPtr, int)>()(clazz, fieldID, val); - } - - void SetStaticCharField(JClassPtr clazz, JFieldIDPtr fieldID, int val) { - return ref.SetStaticCharField.asFunction< - void Function(JClassPtr, JFieldIDPtr, int)>()(clazz, fieldID, val); - } - - void SetStaticShortField(JClassPtr clazz, JFieldIDPtr fieldID, int val) { - return ref.SetStaticShortField.asFunction< - void Function(JClassPtr, JFieldIDPtr, int)>()(clazz, fieldID, val); - } - - void SetStaticIntField(JClassPtr clazz, JFieldIDPtr fieldID, int val) { - return ref.SetStaticIntField.asFunction< - void Function(JClassPtr, JFieldIDPtr, int)>()(clazz, fieldID, val); - } - - void SetStaticLongField(JClassPtr clazz, JFieldIDPtr fieldID, int val) { - return ref.SetStaticLongField.asFunction< - void Function(JClassPtr, JFieldIDPtr, int)>()(clazz, fieldID, val); - } - - void SetStaticFloatField(JClassPtr clazz, JFieldIDPtr fieldID, double val) { - return ref.SetStaticFloatField.asFunction< - void Function(JClassPtr, JFieldIDPtr, double)>()(clazz, fieldID, val); - } - - void SetStaticDoubleField(JClassPtr clazz, JFieldIDPtr fieldID, double val) { - return ref.SetStaticDoubleField.asFunction< - void Function(JClassPtr, JFieldIDPtr, double)>()(clazz, fieldID, val); - } - - JStringPtr NewString(ffi.Pointer unicodeChars, int len) { - return ref.NewString.asFunction< - JStringPtr Function( - ffi.Pointer, int)>()(unicodeChars, len); - } - - int GetStringLength(JStringPtr string) { - return ref.GetStringLength.asFunction()(string); - } - - ffi.Pointer GetStringChars( - JStringPtr string, ffi.Pointer isCopy) { - return ref.GetStringChars.asFunction< - ffi.Pointer Function( - JStringPtr, ffi.Pointer)>()(string, isCopy); - } - - void ReleaseStringChars(JStringPtr string, ffi.Pointer isCopy) { - return ref.ReleaseStringChars.asFunction< - void Function(JStringPtr, ffi.Pointer)>()(string, isCopy); - } - - JStringPtr NewStringUTF(ffi.Pointer bytes) { - return ref.NewStringUTF.asFunction< - JStringPtr Function(ffi.Pointer)>()(bytes); - } - - int GetStringUTFLength(JStringPtr string) { - return ref.GetStringUTFLength.asFunction()( - string); - } - - ffi.Pointer GetStringUTFChars( - JStringPtr string, ffi.Pointer isCopy) { - return ref.GetStringUTFChars.asFunction< - ffi.Pointer Function( - JStringPtr, ffi.Pointer)>()(string, isCopy); - } - - void ReleaseStringUTFChars(JStringPtr string, ffi.Pointer utf) { - return ref.ReleaseStringUTFChars.asFunction< - void Function(JStringPtr, ffi.Pointer)>()(string, utf); - } - - int GetArrayLength(JArrayPtr array) { - return ref.GetArrayLength.asFunction()(array); - } - - JObjectArrayPtr NewObjectArray( - int length, JClassPtr elementClass, JObjectPtr initialElement) { - return ref.NewObjectArray.asFunction< - JObjectArrayPtr Function(int, JClassPtr, JObjectPtr)>()( - length, elementClass, initialElement); - } - - JObjectPtr GetObjectArrayElement(JObjectArrayPtr array, int index) { - return ref.GetObjectArrayElement.asFunction< - JObjectPtr Function(JObjectArrayPtr, int)>()(array, index); - } - - void SetObjectArrayElement(JObjectArrayPtr array, int index, JObjectPtr val) { - return ref.SetObjectArrayElement.asFunction< - void Function(JObjectArrayPtr, int, JObjectPtr)>()(array, index, val); - } - - JBooleanArrayPtr NewBooleanArray(int length) { - return ref.NewBooleanArray.asFunction()( - length); - } - - JByteArrayPtr NewByteArray(int length) { - return ref.NewByteArray.asFunction()(length); - } - - JCharArrayPtr NewCharArray(int length) { - return ref.NewCharArray.asFunction()(length); - } - - JShortArrayPtr NewShortArray(int length) { - return ref.NewShortArray.asFunction()(length); - } - - JIntArrayPtr NewIntArray(int length) { - return ref.NewIntArray.asFunction()(length); - } - - JLongArrayPtr NewLongArray(int length) { - return ref.NewLongArray.asFunction()(length); - } - - JFloatArrayPtr NewFloatArray(int length) { - return ref.NewFloatArray.asFunction()(length); - } - - JDoubleArrayPtr NewDoubleArray(int length) { - return ref.NewDoubleArray.asFunction()( - length); - } - - ffi.Pointer GetBooleanArrayElements( - JBooleanArrayPtr array, ffi.Pointer isCopy) { - return ref.GetBooleanArrayElements.asFunction< - ffi.Pointer Function( - JBooleanArrayPtr, ffi.Pointer)>()(array, isCopy); - } - - ffi.Pointer GetByteArrayElements( - JByteArrayPtr array, ffi.Pointer isCopy) { - return ref.GetByteArrayElements.asFunction< - ffi.Pointer Function( - JByteArrayPtr, ffi.Pointer)>()(array, isCopy); - } - - ffi.Pointer GetCharArrayElements( - JCharArrayPtr array, ffi.Pointer isCopy) { - return ref.GetCharArrayElements.asFunction< - ffi.Pointer Function( - JCharArrayPtr, ffi.Pointer)>()(array, isCopy); - } - - ffi.Pointer GetShortArrayElements( - JShortArrayPtr array, ffi.Pointer isCopy) { - return ref.GetShortArrayElements.asFunction< - ffi.Pointer Function( - JShortArrayPtr, ffi.Pointer)>()(array, isCopy); - } - - ffi.Pointer GetIntArrayElements( - JIntArrayPtr array, ffi.Pointer isCopy) { - return ref.GetIntArrayElements.asFunction< - ffi.Pointer Function( - JIntArrayPtr, ffi.Pointer)>()(array, isCopy); - } - - ffi.Pointer GetLongArrayElements( - JLongArrayPtr array, ffi.Pointer isCopy) { - return ref.GetLongArrayElements.asFunction< - ffi.Pointer Function( - JLongArrayPtr, ffi.Pointer)>()(array, isCopy); - } - - ffi.Pointer GetFloatArrayElements( - JFloatArrayPtr array, ffi.Pointer isCopy) { - return ref.GetFloatArrayElements.asFunction< - ffi.Pointer Function( - JFloatArrayPtr, ffi.Pointer)>()(array, isCopy); - } - - ffi.Pointer GetDoubleArrayElements( - JDoubleArrayPtr array, ffi.Pointer isCopy) { - return ref.GetDoubleArrayElements.asFunction< - ffi.Pointer Function( - JDoubleArrayPtr, ffi.Pointer)>()(array, isCopy); - } - - void ReleaseBooleanArrayElements( - JBooleanArrayPtr array, ffi.Pointer elems, int mode) { - return ref.ReleaseBooleanArrayElements.asFunction< - void Function(JBooleanArrayPtr, ffi.Pointer, - int)>()(array, elems, mode); - } - - void ReleaseByteArrayElements( - JByteArrayPtr array, ffi.Pointer elems, int mode) { - return ref.ReleaseByteArrayElements.asFunction< - void Function(JByteArrayPtr, ffi.Pointer, int)>()( - array, elems, mode); - } - - void ReleaseCharArrayElements( - JCharArrayPtr array, ffi.Pointer elems, int mode) { - return ref.ReleaseCharArrayElements.asFunction< - void Function(JCharArrayPtr, ffi.Pointer, int)>()( - array, elems, mode); - } - - void ReleaseShortArrayElements( - JShortArrayPtr array, ffi.Pointer elems, int mode) { - return ref.ReleaseShortArrayElements.asFunction< - void Function(JShortArrayPtr, ffi.Pointer, int)>()( - array, elems, mode); - } - - void ReleaseIntArrayElements( - JIntArrayPtr array, ffi.Pointer elems, int mode) { - return ref.ReleaseIntArrayElements.asFunction< - void Function( - JIntArrayPtr, ffi.Pointer, int)>()(array, elems, mode); - } - - void ReleaseLongArrayElements( - JLongArrayPtr array, ffi.Pointer elems, int mode) { - return ref.ReleaseLongArrayElements.asFunction< - void Function(JLongArrayPtr, ffi.Pointer, int)>()( - array, elems, mode); - } - - void ReleaseFloatArrayElements( - JFloatArrayPtr array, ffi.Pointer elems, int mode) { - return ref.ReleaseFloatArrayElements.asFunction< - void Function(JFloatArrayPtr, ffi.Pointer, int)>()( - array, elems, mode); - } - - void ReleaseDoubleArrayElements( - JDoubleArrayPtr array, ffi.Pointer elems, int mode) { - return ref.ReleaseDoubleArrayElements.asFunction< - void Function(JDoubleArrayPtr, ffi.Pointer, int)>()( - array, elems, mode); - } - - void GetBooleanArrayRegion(JBooleanArrayPtr array, int start, int len, - ffi.Pointer buf) { - return ref.GetBooleanArrayRegion.asFunction< - void Function(JBooleanArrayPtr, int, int, - ffi.Pointer)>()(array, start, len, buf); - } - - void GetByteArrayRegion( - JByteArrayPtr array, int start, int len, ffi.Pointer buf) { - return ref.GetByteArrayRegion.asFunction< - void Function(JByteArrayPtr, int, int, ffi.Pointer)>()( - array, start, len, buf); - } - - void GetCharArrayRegion( - JCharArrayPtr array, int start, int len, ffi.Pointer buf) { - return ref.GetCharArrayRegion.asFunction< - void Function(JCharArrayPtr, int, int, ffi.Pointer)>()( - array, start, len, buf); - } - - void GetShortArrayRegion( - JShortArrayPtr array, int start, int len, ffi.Pointer buf) { - return ref.GetShortArrayRegion.asFunction< - void Function(JShortArrayPtr, int, int, - ffi.Pointer)>()(array, start, len, buf); - } - - void GetIntArrayRegion( - JIntArrayPtr array, int start, int len, ffi.Pointer buf) { - return ref.GetIntArrayRegion.asFunction< - void Function(JIntArrayPtr, int, int, ffi.Pointer)>()( - array, start, len, buf); - } - - void GetLongArrayRegion( - JLongArrayPtr array, int start, int len, ffi.Pointer buf) { - return ref.GetLongArrayRegion.asFunction< - void Function(JLongArrayPtr, int, int, ffi.Pointer)>()( - array, start, len, buf); - } - - void GetFloatArrayRegion( - JFloatArrayPtr array, int start, int len, ffi.Pointer buf) { - return ref.GetFloatArrayRegion.asFunction< - void Function(JFloatArrayPtr, int, int, - ffi.Pointer)>()(array, start, len, buf); - } - - void GetDoubleArrayRegion(JDoubleArrayPtr array, int start, int len, - ffi.Pointer buf) { - return ref.GetDoubleArrayRegion.asFunction< - void Function(JDoubleArrayPtr, int, int, - ffi.Pointer)>()(array, start, len, buf); - } - - void SetBooleanArrayRegion(JBooleanArrayPtr array, int start, int len, - ffi.Pointer buf) { - return ref.SetBooleanArrayRegion.asFunction< - void Function(JBooleanArrayPtr, int, int, - ffi.Pointer)>()(array, start, len, buf); - } - - void SetByteArrayRegion( - JByteArrayPtr array, int start, int len, ffi.Pointer buf) { - return ref.SetByteArrayRegion.asFunction< - void Function(JByteArrayPtr, int, int, ffi.Pointer)>()( - array, start, len, buf); - } - - void SetCharArrayRegion( - JCharArrayPtr array, int start, int len, ffi.Pointer buf) { - return ref.SetCharArrayRegion.asFunction< - void Function(JCharArrayPtr, int, int, ffi.Pointer)>()( - array, start, len, buf); - } - - void SetShortArrayRegion( - JShortArrayPtr array, int start, int len, ffi.Pointer buf) { - return ref.SetShortArrayRegion.asFunction< - void Function(JShortArrayPtr, int, int, - ffi.Pointer)>()(array, start, len, buf); - } - - void SetIntArrayRegion( - JIntArrayPtr array, int start, int len, ffi.Pointer buf) { - return ref.SetIntArrayRegion.asFunction< - void Function(JIntArrayPtr, int, int, ffi.Pointer)>()( - array, start, len, buf); - } - - void SetLongArrayRegion( - JLongArrayPtr array, int start, int len, ffi.Pointer buf) { - return ref.SetLongArrayRegion.asFunction< - void Function(JLongArrayPtr, int, int, ffi.Pointer)>()( - array, start, len, buf); - } - - void SetFloatArrayRegion( - JFloatArrayPtr array, int start, int len, ffi.Pointer buf) { - return ref.SetFloatArrayRegion.asFunction< - void Function(JFloatArrayPtr, int, int, - ffi.Pointer)>()(array, start, len, buf); - } - - void SetDoubleArrayRegion(JDoubleArrayPtr array, int start, int len, - ffi.Pointer buf) { - return ref.SetDoubleArrayRegion.asFunction< - void Function(JDoubleArrayPtr, int, int, - ffi.Pointer)>()(array, start, len, buf); - } - - int RegisterNatives( - JClassPtr clazz, ffi.Pointer methods, int nMethods) { - return ref.RegisterNatives.asFunction< - int Function(JClassPtr, ffi.Pointer, int)>()( - clazz, methods, nMethods); - } - - int UnregisterNatives(JClassPtr clazz) { - return ref.UnregisterNatives.asFunction()(clazz); - } - - int MonitorEnter(JObjectPtr obj) { - return ref.MonitorEnter.asFunction()(obj); - } - - int MonitorExit(JObjectPtr obj) { - return ref.MonitorExit.asFunction()(obj); - } - - int GetJavaVM(ffi.Pointer> vm) { - return ref.GetJavaVM.asFunction< - int Function(ffi.Pointer>)>()(vm); - } - - void GetStringRegion( - JStringPtr str, int start, int len, ffi.Pointer buf) { - return ref.GetStringRegion.asFunction< - void Function(JStringPtr, int, int, ffi.Pointer)>()( - str, start, len, buf); - } - - void GetStringUTFRegion( - JStringPtr str, int start, int len, ffi.Pointer buf) { - return ref.GetStringUTFRegion.asFunction< - void Function(JStringPtr, int, int, ffi.Pointer)>()( - str, start, len, buf); - } - - ffi.Pointer GetPrimitiveArrayCritical( - JArrayPtr array, ffi.Pointer isCopy) { - return ref.GetPrimitiveArrayCritical.asFunction< - ffi.Pointer Function( - JArrayPtr, ffi.Pointer)>()(array, isCopy); - } - - void ReleasePrimitiveArrayCritical( - JArrayPtr array, ffi.Pointer carray, int mode) { - return ref.ReleasePrimitiveArrayCritical.asFunction< - void Function( - JArrayPtr, ffi.Pointer, int)>()(array, carray, mode); - } - - ffi.Pointer GetStringCritical( - JStringPtr str, ffi.Pointer isCopy) { - return ref.GetStringCritical.asFunction< - ffi.Pointer Function( - JStringPtr, ffi.Pointer)>()(str, isCopy); - } - - void ReleaseStringCritical(JStringPtr str, ffi.Pointer carray) { - return ref.ReleaseStringCritical.asFunction< - void Function(JStringPtr, ffi.Pointer)>()(str, carray); - } - - JWeakPtr NewWeakGlobalRef(JObjectPtr obj) { - return ref.NewWeakGlobalRef.asFunction()( - obj); - } - - void DeleteWeakGlobalRef(JWeakPtr obj) { - return ref.DeleteWeakGlobalRef.asFunction()(obj); - } - - int ExceptionCheck() { - return ref.ExceptionCheck.asFunction()(); - } - - JObjectPtr NewDirectByteBuffer(ffi.Pointer address, int capacity) { - return ref.NewDirectByteBuffer.asFunction< - JObjectPtr Function(ffi.Pointer, int)>()(address, capacity); - } - - ffi.Pointer GetDirectBufferAddress(JObjectPtr buf) { - return ref.GetDirectBufferAddress.asFunction< - ffi.Pointer Function(JObjectPtr)>()(buf); - } - - int GetDirectBufferCapacity(JObjectPtr buf) { - return ref.GetDirectBufferCapacity.asFunction()( - buf); - } - - int GetObjectRefType(JObjectPtr obj) { - return ref.GetObjectRefType.asFunction()(obj); - } + /// free buffer w/o copying back + static const int JNI_ABORT = 2; } -const int JNI_FALSE = 0; - -const int JNI_TRUE = 1; - -const int JNI_VERSION_1_1 = 65537; - -const int JNI_VERSION_1_2 = 65538; - -const int JNI_VERSION_1_4 = 65540; - -const int JNI_VERSION_1_6 = 65542; - -const int JNI_OK = 0; - -const int JNI_ERR = -1; - -const int JNI_EDETACHED = -2; - -const int JNI_EVERSION = -3; - -const int JNI_ENOMEM = -4; - -const int JNI_EEXIST = -5; - -const int JNI_EINVAL = -6; - -const int JNI_COMMIT = 1; - -const int JNI_ABORT = 2; +const int DART_JNI_SINGLETON_EXISTS = -99; diff --git a/pkgs/jni/lib/src/third_party/jnienv_javavm_extensions.dart b/pkgs/jni/lib/src/third_party/jnienv_javavm_extensions.dart new file mode 100644 index 000000000..7c145f990 --- /dev/null +++ b/pkgs/jni/lib/src/third_party/jnienv_javavm_extensions.dart @@ -0,0 +1,1409 @@ +// Auto generated file. Do not edit. + +// This is generated from JNI header in Android NDK. License for the same is +// provided below. + +/* + * Copyright (C) 2006 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * JNI specification, as defined by Sun: + * http://java.sun.com/javase/6/docs/technotes/guides/jni/spec/jniTOC.html + * + * Everything here is expected to be VM-neutral. + */ + +// ignore_for_file: non_constant_identifier_names +// coverage:ignore-file + +import "dart:ffi" as ffi; + +import "jni_bindings_generated.dart"; + +extension JniEnvExtension on ffi.Pointer { + int GetVersion() => value.ref.GetVersion + .asFunction env)>()(this); + + JClassPtr DefineClass(ffi.Pointer name, JObjectPtr loader, + ffi.Pointer buf, int bufLen) => + value.ref.DefineClass.asFunction< + JClassPtr Function( + ffi.Pointer env, + ffi.Pointer name, + JObjectPtr loader, + ffi.Pointer buf, + int bufLen)>()(this, name, loader, buf, bufLen); + + JClassPtr FindClass(ffi.Pointer name) => value.ref.FindClass + .asFunction< + JClassPtr Function(ffi.Pointer env, + ffi.Pointer name)>()(this, name); + + JMethodIDPtr FromReflectedMethod(JObjectPtr method) => + value.ref.FromReflectedMethod.asFunction< + JMethodIDPtr Function( + ffi.Pointer env, JObjectPtr method)>()(this, method); + + JFieldIDPtr FromReflectedField(JObjectPtr field) => + value.ref.FromReflectedField.asFunction< + JFieldIDPtr Function( + ffi.Pointer env, JObjectPtr field)>()(this, field); + + JObjectPtr ToReflectedMethod( + JClassPtr cls, JMethodIDPtr methodId, int isStatic) => + value.ref.ToReflectedMethod.asFunction< + JObjectPtr Function( + ffi.Pointer env, + JClassPtr cls, + JMethodIDPtr methodId, + int isStatic)>()(this, cls, methodId, isStatic); + + JClassPtr GetSuperclass(JClassPtr clazz) => + value.ref.GetSuperclass.asFunction< + JClassPtr Function( + ffi.Pointer env, JClassPtr clazz)>()(this, clazz); + + int IsAssignableFrom(JClassPtr clazz1, JClassPtr clazz2) => + value.ref.IsAssignableFrom.asFunction< + int Function(ffi.Pointer env, JClassPtr clazz1, + JClassPtr clazz2)>()(this, clazz1, clazz2); + + JObjectPtr ToReflectedField( + JClassPtr cls, JFieldIDPtr fieldID, int isStatic) => + value.ref.ToReflectedField.asFunction< + JObjectPtr Function( + ffi.Pointer env, + JClassPtr cls, + JFieldIDPtr fieldID, + int isStatic)>()(this, cls, fieldID, isStatic); + + int Throw(JThrowablePtr obj) => value.ref.Throw.asFunction< + int Function(ffi.Pointer env, JThrowablePtr obj)>()(this, obj); + + int ThrowNew(JClassPtr clazz, ffi.Pointer message) => + value.ref.ThrowNew.asFunction< + int Function(ffi.Pointer env, JClassPtr clazz, + ffi.Pointer message)>()(this, clazz, message); + + JThrowablePtr ExceptionOccurred() => value.ref.ExceptionOccurred + .asFunction env)>()(this); + + void ExceptionDescribe() => value.ref.ExceptionDescribe + .asFunction env)>()(this); + + void ExceptionClear() => value.ref.ExceptionClear + .asFunction env)>()(this); + + void FatalError(ffi.Pointer msg) => value.ref.FatalError.asFunction< + void Function( + ffi.Pointer env, ffi.Pointer msg)>()(this, msg); + + int PushLocalFrame(int capacity) => value.ref.PushLocalFrame + .asFunction env, int capacity)>()( + this, capacity); + + JObjectPtr PopLocalFrame(JObjectPtr result) => value.ref.PopLocalFrame + .asFunction< + JObjectPtr Function( + ffi.Pointer env, JObjectPtr result)>()(this, result); + + JObjectPtr NewGlobalRef(JObjectPtr obj) => value.ref.NewGlobalRef.asFunction< + JObjectPtr Function( + ffi.Pointer env, JObjectPtr obj)>()(this, obj); + + void DeleteGlobalRef(JObjectPtr globalRef) => + value.ref.DeleteGlobalRef.asFunction< + void Function(ffi.Pointer env, JObjectPtr globalRef)>()( + this, globalRef); + + void DeleteLocalRef(JObjectPtr localRef) => + value.ref.DeleteLocalRef.asFunction< + void Function( + ffi.Pointer env, JObjectPtr localRef)>()(this, localRef); + + int IsSameObject(JObjectPtr ref1, JObjectPtr ref2) => + value.ref.IsSameObject.asFunction< + int Function(ffi.Pointer env, JObjectPtr ref1, + JObjectPtr ref2)>()(this, ref1, ref2); + + JObjectPtr NewLocalRef(JObjectPtr obj) => value.ref.NewLocalRef.asFunction< + JObjectPtr Function( + ffi.Pointer env, JObjectPtr obj)>()(this, obj); + + int EnsureLocalCapacity(int capacity) => value.ref.EnsureLocalCapacity + .asFunction env, int capacity)>()( + this, capacity); + + JObjectPtr AllocObject(JClassPtr clazz) => value.ref.AllocObject.asFunction< + JObjectPtr Function( + ffi.Pointer env, JClassPtr clazz)>()(this, clazz); + + JObjectPtr NewObject(JClassPtr clazz, JMethodIDPtr methodID) => + value.ref.NewObject.asFunction< + JObjectPtr Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>()(this, clazz, methodID); + + JObjectPtr NewObjectA( + JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => + value.ref.NewObjectA.asFunction< + JObjectPtr Function( + ffi.Pointer env, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>()(this, clazz, methodID, args); + + JClassPtr GetObjectClass(JObjectPtr obj) => + value.ref.GetObjectClass.asFunction< + JClassPtr Function( + ffi.Pointer env, JObjectPtr obj)>()(this, obj); + + int IsInstanceOf(JObjectPtr obj, JClassPtr clazz) => + value.ref.IsInstanceOf.asFunction< + int Function(ffi.Pointer env, JObjectPtr obj, + JClassPtr clazz)>()(this, obj, clazz); + + JMethodIDPtr GetMethodID(JClassPtr clazz, ffi.Pointer name, + ffi.Pointer sig) => + value.ref.GetMethodID.asFunction< + JMethodIDPtr Function( + ffi.Pointer env, + JClassPtr clazz, + ffi.Pointer name, + ffi.Pointer sig)>()(this, clazz, name, sig); + + JObjectPtr CallObjectMethod(JObjectPtr obj, JMethodIDPtr methodID) => + value.ref.CallObjectMethod.asFunction< + JObjectPtr Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>()(this, obj, methodID); + + JObjectPtr CallObjectMethodA( + JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) => + value.ref.CallObjectMethodA.asFunction< + JObjectPtr Function( + ffi.Pointer env, + JObjectPtr obj, + JMethodIDPtr methodID, + ffi.Pointer args)>()(this, obj, methodID, args); + + int CallBooleanMethod(JObjectPtr obj, JMethodIDPtr methodID) => + value.ref.CallBooleanMethod.asFunction< + int Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>()(this, obj, methodID); + + int CallBooleanMethodA( + JObjectPtr obj, JMethodIDPtr methodId, ffi.Pointer args) => + value.ref.CallBooleanMethodA.asFunction< + int Function( + ffi.Pointer env, + JObjectPtr obj, + JMethodIDPtr methodId, + ffi.Pointer args)>()(this, obj, methodId, args); + + int CallByteMethod(JObjectPtr obj, JMethodIDPtr methodID) => + value.ref.CallByteMethod.asFunction< + int Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>()(this, obj, methodID); + + int CallByteMethodA( + JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) => + value.ref.CallByteMethodA.asFunction< + int Function( + ffi.Pointer env, + JObjectPtr obj, + JMethodIDPtr methodID, + ffi.Pointer args)>()(this, obj, methodID, args); + + int CallCharMethod(JObjectPtr obj, JMethodIDPtr methodID) => + value.ref.CallCharMethod.asFunction< + int Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>()(this, obj, methodID); + + int CallCharMethodA( + JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) => + value.ref.CallCharMethodA.asFunction< + int Function( + ffi.Pointer env, + JObjectPtr obj, + JMethodIDPtr methodID, + ffi.Pointer args)>()(this, obj, methodID, args); + + int CallShortMethod(JObjectPtr obj, JMethodIDPtr methodID) => + value.ref.CallShortMethod.asFunction< + int Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>()(this, obj, methodID); + + int CallShortMethodA( + JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) => + value.ref.CallShortMethodA.asFunction< + int Function( + ffi.Pointer env, + JObjectPtr obj, + JMethodIDPtr methodID, + ffi.Pointer args)>()(this, obj, methodID, args); + + int CallIntMethod(JObjectPtr obj, JMethodIDPtr methodID) => + value.ref.CallIntMethod.asFunction< + int Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>()(this, obj, methodID); + + int CallIntMethodA( + JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) => + value.ref.CallIntMethodA.asFunction< + int Function( + ffi.Pointer env, + JObjectPtr obj, + JMethodIDPtr methodID, + ffi.Pointer args)>()(this, obj, methodID, args); + + int CallLongMethod(JObjectPtr obj, JMethodIDPtr methodID) => + value.ref.CallLongMethod.asFunction< + int Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>()(this, obj, methodID); + + int CallLongMethodA( + JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) => + value.ref.CallLongMethodA.asFunction< + int Function( + ffi.Pointer env, + JObjectPtr obj, + JMethodIDPtr methodID, + ffi.Pointer args)>()(this, obj, methodID, args); + + double CallFloatMethod(JObjectPtr obj, JMethodIDPtr methodID) => + value.ref.CallFloatMethod.asFunction< + double Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>()(this, obj, methodID); + + double CallFloatMethodA( + JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) => + value.ref.CallFloatMethodA.asFunction< + double Function( + ffi.Pointer env, + JObjectPtr obj, + JMethodIDPtr methodID, + ffi.Pointer args)>()(this, obj, methodID, args); + + double CallDoubleMethod(JObjectPtr obj, JMethodIDPtr methodID) => + value.ref.CallDoubleMethod.asFunction< + double Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>()(this, obj, methodID); + + double CallDoubleMethodA( + JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) => + value.ref.CallDoubleMethodA.asFunction< + double Function( + ffi.Pointer env, + JObjectPtr obj, + JMethodIDPtr methodID, + ffi.Pointer args)>()(this, obj, methodID, args); + + void CallVoidMethod(JObjectPtr obj, JMethodIDPtr methodID) => + value.ref.CallVoidMethod.asFunction< + void Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>()(this, obj, methodID); + + void CallVoidMethodA( + JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) => + value.ref.CallVoidMethodA.asFunction< + void Function( + ffi.Pointer env, + JObjectPtr obj, + JMethodIDPtr methodID, + ffi.Pointer args)>()(this, obj, methodID, args); + + JObjectPtr CallNonvirtualObjectMethod( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => + value.ref.CallNonvirtualObjectMethod.asFunction< + JObjectPtr Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID)>()(this, obj, clazz, methodID); + + JObjectPtr CallNonvirtualObjectMethodA(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args) => + value.ref.CallNonvirtualObjectMethodA.asFunction< + JObjectPtr Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>()(this, obj, clazz, methodID, args); + + int CallNonvirtualBooleanMethod( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => + value.ref.CallNonvirtualBooleanMethod.asFunction< + int Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID)>()(this, obj, clazz, methodID); + + int CallNonvirtualBooleanMethodA(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args) => + value.ref.CallNonvirtualBooleanMethodA.asFunction< + int Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>()(this, obj, clazz, methodID, args); + + int CallNonvirtualByteMethod( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => + value.ref.CallNonvirtualByteMethod.asFunction< + int Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID)>()(this, obj, clazz, methodID); + + int CallNonvirtualByteMethodA(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args) => + value.ref.CallNonvirtualByteMethodA.asFunction< + int Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>()(this, obj, clazz, methodID, args); + + int CallNonvirtualCharMethod( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => + value.ref.CallNonvirtualCharMethod.asFunction< + int Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID)>()(this, obj, clazz, methodID); + + int CallNonvirtualCharMethodA(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args) => + value.ref.CallNonvirtualCharMethodA.asFunction< + int Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>()(this, obj, clazz, methodID, args); + + int CallNonvirtualShortMethod( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => + value.ref.CallNonvirtualShortMethod.asFunction< + int Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID)>()(this, obj, clazz, methodID); + + int CallNonvirtualShortMethodA(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args) => + value.ref.CallNonvirtualShortMethodA.asFunction< + int Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>()(this, obj, clazz, methodID, args); + + int CallNonvirtualIntMethod( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => + value.ref.CallNonvirtualIntMethod.asFunction< + int Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID)>()(this, obj, clazz, methodID); + + int CallNonvirtualIntMethodA(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args) => + value.ref.CallNonvirtualIntMethodA.asFunction< + int Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>()(this, obj, clazz, methodID, args); + + int CallNonvirtualLongMethod( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => + value.ref.CallNonvirtualLongMethod.asFunction< + int Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID)>()(this, obj, clazz, methodID); + + int CallNonvirtualLongMethodA(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args) => + value.ref.CallNonvirtualLongMethodA.asFunction< + int Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>()(this, obj, clazz, methodID, args); + + double CallNonvirtualFloatMethod( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => + value.ref.CallNonvirtualFloatMethod.asFunction< + double Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID)>()(this, obj, clazz, methodID); + + double CallNonvirtualFloatMethodA(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args) => + value.ref.CallNonvirtualFloatMethodA.asFunction< + double Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>()(this, obj, clazz, methodID, args); + + double CallNonvirtualDoubleMethod( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => + value.ref.CallNonvirtualDoubleMethod.asFunction< + double Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID)>()(this, obj, clazz, methodID); + + double CallNonvirtualDoubleMethodA(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args) => + value.ref.CallNonvirtualDoubleMethodA.asFunction< + double Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>()(this, obj, clazz, methodID, args); + + void CallNonvirtualVoidMethod( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => + value.ref.CallNonvirtualVoidMethod.asFunction< + void Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID)>()(this, obj, clazz, methodID); + + void CallNonvirtualVoidMethodA(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args) => + value.ref.CallNonvirtualVoidMethodA.asFunction< + void Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>()(this, obj, clazz, methodID, args); + + JFieldIDPtr GetFieldID(JClassPtr clazz, ffi.Pointer name, + ffi.Pointer sig) => + value.ref.GetFieldID.asFunction< + JFieldIDPtr Function( + ffi.Pointer env, + JClassPtr clazz, + ffi.Pointer name, + ffi.Pointer sig)>()(this, clazz, name, sig); + + JObjectPtr GetObjectField(JObjectPtr obj, JFieldIDPtr fieldID) => + value.ref.GetObjectField.asFunction< + JObjectPtr Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID)>()(this, obj, fieldID); + + int GetBooleanField(JObjectPtr obj, JFieldIDPtr fieldID) => + value.ref.GetBooleanField.asFunction< + int Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID)>()(this, obj, fieldID); + + int GetByteField(JObjectPtr obj, JFieldIDPtr fieldID) => + value.ref.GetByteField.asFunction< + int Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID)>()(this, obj, fieldID); + + int GetCharField(JObjectPtr obj, JFieldIDPtr fieldID) => + value.ref.GetCharField.asFunction< + int Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID)>()(this, obj, fieldID); + + int GetShortField(JObjectPtr obj, JFieldIDPtr fieldID) => + value.ref.GetShortField.asFunction< + int Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID)>()(this, obj, fieldID); + + int GetIntField(JObjectPtr obj, JFieldIDPtr fieldID) => + value.ref.GetIntField.asFunction< + int Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID)>()(this, obj, fieldID); + + int GetLongField(JObjectPtr obj, JFieldIDPtr fieldID) => + value.ref.GetLongField.asFunction< + int Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID)>()(this, obj, fieldID); + + double GetFloatField(JObjectPtr obj, JFieldIDPtr fieldID) => + value.ref.GetFloatField.asFunction< + double Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID)>()(this, obj, fieldID); + + double GetDoubleField(JObjectPtr obj, JFieldIDPtr fieldID) => + value.ref.GetDoubleField.asFunction< + double Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID)>()(this, obj, fieldID); + + void SetObjectField(JObjectPtr obj, JFieldIDPtr fieldID, JObjectPtr val) => + value.ref.SetObjectField.asFunction< + void Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID, JObjectPtr val)>()(this, obj, fieldID, val); + + void SetBooleanField(JObjectPtr obj, JFieldIDPtr fieldID, int val) => + value.ref.SetBooleanField.asFunction< + void Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID, int val)>()(this, obj, fieldID, val); + + void SetByteField(JObjectPtr obj, JFieldIDPtr fieldID, int val) => + value.ref.SetByteField.asFunction< + void Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID, int val)>()(this, obj, fieldID, val); + + void SetCharField(JObjectPtr obj, JFieldIDPtr fieldID, int val) => + value.ref.SetCharField.asFunction< + void Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID, int val)>()(this, obj, fieldID, val); + + void SetShortField(JObjectPtr obj, JFieldIDPtr fieldID, int val) => + value.ref.SetShortField.asFunction< + void Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID, int val)>()(this, obj, fieldID, val); + + void SetIntField(JObjectPtr obj, JFieldIDPtr fieldID, int val) => + value.ref.SetIntField.asFunction< + void Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID, int val)>()(this, obj, fieldID, val); + + void SetLongField(JObjectPtr obj, JFieldIDPtr fieldID, int val) => + value.ref.SetLongField.asFunction< + void Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID, int val)>()(this, obj, fieldID, val); + + void SetFloatField(JObjectPtr obj, JFieldIDPtr fieldID, double val) => + value.ref.SetFloatField.asFunction< + void Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID, double val)>()(this, obj, fieldID, val); + + void SetDoubleField(JObjectPtr obj, JFieldIDPtr fieldID, double val) => + value.ref.SetDoubleField.asFunction< + void Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID, double val)>()(this, obj, fieldID, val); + + JMethodIDPtr GetStaticMethodID(JClassPtr clazz, ffi.Pointer name, + ffi.Pointer sig) => + value.ref.GetStaticMethodID.asFunction< + JMethodIDPtr Function( + ffi.Pointer env, + JClassPtr clazz, + ffi.Pointer name, + ffi.Pointer sig)>()(this, clazz, name, sig); + + JObjectPtr CallStaticObjectMethod(JClassPtr clazz, JMethodIDPtr methodID) => + value.ref.CallStaticObjectMethod.asFunction< + JObjectPtr Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>()(this, clazz, methodID); + + JObjectPtr CallStaticObjectMethodA( + JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => + value.ref.CallStaticObjectMethodA.asFunction< + JObjectPtr Function( + ffi.Pointer env, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>()(this, clazz, methodID, args); + + int CallStaticBooleanMethod(JClassPtr clazz, JMethodIDPtr methodID) => + value.ref.CallStaticBooleanMethod.asFunction< + int Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>()(this, clazz, methodID); + + int CallStaticBooleanMethodA( + JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => + value.ref.CallStaticBooleanMethodA.asFunction< + int Function( + ffi.Pointer env, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>()(this, clazz, methodID, args); + + int CallStaticByteMethod(JClassPtr clazz, JMethodIDPtr methodID) => + value.ref.CallStaticByteMethod.asFunction< + int Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>()(this, clazz, methodID); + + int CallStaticByteMethodA( + JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => + value.ref.CallStaticByteMethodA.asFunction< + int Function( + ffi.Pointer env, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>()(this, clazz, methodID, args); + + int CallStaticCharMethod(JClassPtr clazz, JMethodIDPtr methodID) => + value.ref.CallStaticCharMethod.asFunction< + int Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>()(this, clazz, methodID); + + int CallStaticCharMethodA( + JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => + value.ref.CallStaticCharMethodA.asFunction< + int Function( + ffi.Pointer env, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>()(this, clazz, methodID, args); + + int CallStaticShortMethod(JClassPtr clazz, JMethodIDPtr methodID) => + value.ref.CallStaticShortMethod.asFunction< + int Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>()(this, clazz, methodID); + + int CallStaticShortMethodA( + JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => + value.ref.CallStaticShortMethodA.asFunction< + int Function( + ffi.Pointer env, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>()(this, clazz, methodID, args); + + int CallStaticIntMethod(JClassPtr clazz, JMethodIDPtr methodID) => + value.ref.CallStaticIntMethod.asFunction< + int Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>()(this, clazz, methodID); + + int CallStaticIntMethodA( + JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => + value.ref.CallStaticIntMethodA.asFunction< + int Function( + ffi.Pointer env, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>()(this, clazz, methodID, args); + + int CallStaticLongMethod(JClassPtr clazz, JMethodIDPtr methodID) => + value.ref.CallStaticLongMethod.asFunction< + int Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>()(this, clazz, methodID); + + int CallStaticLongMethodA( + JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => + value.ref.CallStaticLongMethodA.asFunction< + int Function( + ffi.Pointer env, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>()(this, clazz, methodID, args); + + double CallStaticFloatMethod(JClassPtr clazz, JMethodIDPtr methodID) => + value.ref.CallStaticFloatMethod.asFunction< + double Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>()(this, clazz, methodID); + + double CallStaticFloatMethodA( + JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => + value.ref.CallStaticFloatMethodA.asFunction< + double Function( + ffi.Pointer env, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>()(this, clazz, methodID, args); + + double CallStaticDoubleMethod(JClassPtr clazz, JMethodIDPtr methodID) => + value.ref.CallStaticDoubleMethod.asFunction< + double Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>()(this, clazz, methodID); + + double CallStaticDoubleMethodA( + JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => + value.ref.CallStaticDoubleMethodA.asFunction< + double Function( + ffi.Pointer env, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>()(this, clazz, methodID, args); + + void CallStaticVoidMethod(JClassPtr clazz, JMethodIDPtr methodID) => + value.ref.CallStaticVoidMethod.asFunction< + void Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>()(this, clazz, methodID); + + void CallStaticVoidMethodA( + JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => + value.ref.CallStaticVoidMethodA.asFunction< + void Function( + ffi.Pointer env, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>()(this, clazz, methodID, args); + + JFieldIDPtr GetStaticFieldID(JClassPtr clazz, ffi.Pointer name, + ffi.Pointer sig) => + value.ref.GetStaticFieldID.asFunction< + JFieldIDPtr Function( + ffi.Pointer env, + JClassPtr clazz, + ffi.Pointer name, + ffi.Pointer sig)>()(this, clazz, name, sig); + + JObjectPtr GetStaticObjectField(JClassPtr clazz, JFieldIDPtr fieldID) => + value.ref.GetStaticObjectField.asFunction< + JObjectPtr Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID)>()(this, clazz, fieldID); + + int GetStaticBooleanField(JClassPtr clazz, JFieldIDPtr fieldID) => + value.ref.GetStaticBooleanField.asFunction< + int Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID)>()(this, clazz, fieldID); + + int GetStaticByteField(JClassPtr clazz, JFieldIDPtr fieldID) => + value.ref.GetStaticByteField.asFunction< + int Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID)>()(this, clazz, fieldID); + + int GetStaticCharField(JClassPtr clazz, JFieldIDPtr fieldID) => + value.ref.GetStaticCharField.asFunction< + int Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID)>()(this, clazz, fieldID); + + int GetStaticShortField(JClassPtr clazz, JFieldIDPtr fieldID) => + value.ref.GetStaticShortField.asFunction< + int Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID)>()(this, clazz, fieldID); + + int GetStaticIntField(JClassPtr clazz, JFieldIDPtr fieldID) => + value.ref.GetStaticIntField.asFunction< + int Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID)>()(this, clazz, fieldID); + + int GetStaticLongField(JClassPtr clazz, JFieldIDPtr fieldID) => + value.ref.GetStaticLongField.asFunction< + int Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID)>()(this, clazz, fieldID); + + double GetStaticFloatField(JClassPtr clazz, JFieldIDPtr fieldID) => + value.ref.GetStaticFloatField.asFunction< + double Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID)>()(this, clazz, fieldID); + + double GetStaticDoubleField(JClassPtr clazz, JFieldIDPtr fieldID) => + value.ref.GetStaticDoubleField.asFunction< + double Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID)>()(this, clazz, fieldID); + + void SetStaticObjectField( + JClassPtr clazz, JFieldIDPtr fieldID, JObjectPtr val) => + value.ref.SetStaticObjectField.asFunction< + void Function( + ffi.Pointer env, + JClassPtr clazz, + JFieldIDPtr fieldID, + JObjectPtr val)>()(this, clazz, fieldID, val); + + void SetStaticBooleanField(JClassPtr clazz, JFieldIDPtr fieldID, int val) => + value.ref.SetStaticBooleanField.asFunction< + void Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID, int val)>()(this, clazz, fieldID, val); + + void SetStaticByteField(JClassPtr clazz, JFieldIDPtr fieldID, int val) => + value.ref.SetStaticByteField.asFunction< + void Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID, int val)>()(this, clazz, fieldID, val); + + void SetStaticCharField(JClassPtr clazz, JFieldIDPtr fieldID, int val) => + value.ref.SetStaticCharField.asFunction< + void Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID, int val)>()(this, clazz, fieldID, val); + + void SetStaticShortField(JClassPtr clazz, JFieldIDPtr fieldID, int val) => + value.ref.SetStaticShortField.asFunction< + void Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID, int val)>()(this, clazz, fieldID, val); + + void SetStaticIntField(JClassPtr clazz, JFieldIDPtr fieldID, int val) => + value.ref.SetStaticIntField.asFunction< + void Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID, int val)>()(this, clazz, fieldID, val); + + void SetStaticLongField(JClassPtr clazz, JFieldIDPtr fieldID, int val) => + value.ref.SetStaticLongField.asFunction< + void Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID, int val)>()(this, clazz, fieldID, val); + + void SetStaticFloatField(JClassPtr clazz, JFieldIDPtr fieldID, double val) => + value.ref.SetStaticFloatField.asFunction< + void Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID, double val)>()(this, clazz, fieldID, val); + + void SetStaticDoubleField(JClassPtr clazz, JFieldIDPtr fieldID, double val) => + value.ref.SetStaticDoubleField.asFunction< + void Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID, double val)>()(this, clazz, fieldID, val); + + JStringPtr NewString(ffi.Pointer unicodeChars, int len) => + value.ref.NewString.asFunction< + JStringPtr Function( + ffi.Pointer env, + ffi.Pointer unicodeChars, + int len)>()(this, unicodeChars, len); + + int GetStringLength(JStringPtr string) => + value.ref.GetStringLength.asFunction< + int Function( + ffi.Pointer env, JStringPtr string)>()(this, string); + + ffi.Pointer GetStringChars( + JStringPtr string, ffi.Pointer isCopy) => + value.ref.GetStringChars.asFunction< + ffi.Pointer Function( + ffi.Pointer env, + JStringPtr string, + ffi.Pointer isCopy)>()(this, string, isCopy); + + void ReleaseStringChars(JStringPtr string, ffi.Pointer isCopy) => + value.ref.ReleaseStringChars.asFunction< + void Function(ffi.Pointer env, JStringPtr string, + ffi.Pointer isCopy)>()(this, string, isCopy); + + JStringPtr NewStringUTF(ffi.Pointer bytes) => + value.ref.NewStringUTF.asFunction< + JStringPtr Function(ffi.Pointer env, + ffi.Pointer bytes)>()(this, bytes); + + int GetStringUTFLength(JStringPtr string) => + value.ref.GetStringUTFLength.asFunction< + int Function( + ffi.Pointer env, JStringPtr string)>()(this, string); + + ffi.Pointer GetStringUTFChars( + JStringPtr string, ffi.Pointer isCopy) => + value.ref.GetStringUTFChars.asFunction< + ffi.Pointer Function( + ffi.Pointer env, + JStringPtr string, + ffi.Pointer isCopy)>()(this, string, isCopy); + + void ReleaseStringUTFChars(JStringPtr string, ffi.Pointer utf) => + value.ref.ReleaseStringUTFChars.asFunction< + void Function(ffi.Pointer env, JStringPtr string, + ffi.Pointer utf)>()(this, string, utf); + + int GetArrayLength(JArrayPtr array) => value.ref.GetArrayLength.asFunction< + int Function(ffi.Pointer env, JArrayPtr array)>()(this, array); + + JObjectArrayPtr NewObjectArray( + int length, JClassPtr elementClass, JObjectPtr initialElement) => + value.ref.NewObjectArray.asFunction< + JObjectArrayPtr Function(ffi.Pointer env, int length, + JClassPtr elementClass, JObjectPtr initialElement)>()( + this, length, elementClass, initialElement); + + JObjectPtr GetObjectArrayElement(JObjectArrayPtr array, int index) => + value.ref.GetObjectArrayElement.asFunction< + JObjectPtr Function(ffi.Pointer env, JObjectArrayPtr array, + int index)>()(this, array, index); + + void SetObjectArrayElement( + JObjectArrayPtr array, int index, JObjectPtr val) => + value.ref.SetObjectArrayElement.asFunction< + void Function(ffi.Pointer env, JObjectArrayPtr array, + int index, JObjectPtr val)>()(this, array, index, val); + + JBooleanArrayPtr NewBooleanArray(int length) => + value.ref.NewBooleanArray.asFunction< + JBooleanArrayPtr Function( + ffi.Pointer env, int length)>()(this, length); + + JByteArrayPtr NewByteArray(int length) => value.ref.NewByteArray.asFunction< + JByteArrayPtr Function( + ffi.Pointer env, int length)>()(this, length); + + JCharArrayPtr NewCharArray(int length) => value.ref.NewCharArray.asFunction< + JCharArrayPtr Function( + ffi.Pointer env, int length)>()(this, length); + + JShortArrayPtr NewShortArray(int length) => + value.ref.NewShortArray.asFunction< + JShortArrayPtr Function( + ffi.Pointer env, int length)>()(this, length); + + JIntArrayPtr NewIntArray(int length) => value.ref.NewIntArray.asFunction< + JIntArrayPtr Function( + ffi.Pointer env, int length)>()(this, length); + + JLongArrayPtr NewLongArray(int length) => value.ref.NewLongArray.asFunction< + JLongArrayPtr Function( + ffi.Pointer env, int length)>()(this, length); + + JFloatArrayPtr NewFloatArray(int length) => + value.ref.NewFloatArray.asFunction< + JFloatArrayPtr Function( + ffi.Pointer env, int length)>()(this, length); + + JDoubleArrayPtr NewDoubleArray(int length) => value.ref.NewDoubleArray + .asFunction< + JDoubleArrayPtr Function( + ffi.Pointer env, int length)>()(this, length); + + ffi.Pointer GetBooleanArrayElements( + JBooleanArrayPtr array, ffi.Pointer isCopy) => + value.ref.GetBooleanArrayElements.asFunction< + ffi.Pointer Function( + ffi.Pointer env, + JBooleanArrayPtr array, + ffi.Pointer isCopy)>()(this, array, isCopy); + + ffi.Pointer GetByteArrayElements( + JByteArrayPtr array, ffi.Pointer isCopy) => + value.ref.GetByteArrayElements.asFunction< + ffi.Pointer Function( + ffi.Pointer env, + JByteArrayPtr array, + ffi.Pointer isCopy)>()(this, array, isCopy); + + ffi.Pointer GetCharArrayElements( + JCharArrayPtr array, ffi.Pointer isCopy) => + value.ref.GetCharArrayElements.asFunction< + ffi.Pointer Function( + ffi.Pointer env, + JCharArrayPtr array, + ffi.Pointer isCopy)>()(this, array, isCopy); + + ffi.Pointer GetShortArrayElements( + JShortArrayPtr array, ffi.Pointer isCopy) => + value.ref.GetShortArrayElements.asFunction< + ffi.Pointer Function( + ffi.Pointer env, + JShortArrayPtr array, + ffi.Pointer isCopy)>()(this, array, isCopy); + + ffi.Pointer GetIntArrayElements( + JIntArrayPtr array, ffi.Pointer isCopy) => + value.ref.GetIntArrayElements.asFunction< + ffi.Pointer Function( + ffi.Pointer env, + JIntArrayPtr array, + ffi.Pointer isCopy)>()(this, array, isCopy); + + ffi.Pointer GetLongArrayElements( + JLongArrayPtr array, ffi.Pointer isCopy) => + value.ref.GetLongArrayElements.asFunction< + ffi.Pointer Function( + ffi.Pointer env, + JLongArrayPtr array, + ffi.Pointer isCopy)>()(this, array, isCopy); + + ffi.Pointer GetFloatArrayElements( + JFloatArrayPtr array, ffi.Pointer isCopy) => + value.ref.GetFloatArrayElements.asFunction< + ffi.Pointer Function( + ffi.Pointer env, + JFloatArrayPtr array, + ffi.Pointer isCopy)>()(this, array, isCopy); + + ffi.Pointer GetDoubleArrayElements( + JDoubleArrayPtr array, ffi.Pointer isCopy) => + value.ref.GetDoubleArrayElements.asFunction< + ffi.Pointer Function( + ffi.Pointer env, + JDoubleArrayPtr array, + ffi.Pointer isCopy)>()(this, array, isCopy); + + void ReleaseBooleanArrayElements(JBooleanArrayPtr array, + ffi.Pointer elems, int mode) => + value.ref.ReleaseBooleanArrayElements.asFunction< + void Function( + ffi.Pointer env, + JBooleanArrayPtr array, + ffi.Pointer elems, + int mode)>()(this, array, elems, mode); + + void ReleaseByteArrayElements( + JByteArrayPtr array, ffi.Pointer elems, int mode) => + value.ref.ReleaseByteArrayElements.asFunction< + void Function( + ffi.Pointer env, + JByteArrayPtr array, + ffi.Pointer elems, + int mode)>()(this, array, elems, mode); + + void ReleaseCharArrayElements( + JCharArrayPtr array, ffi.Pointer elems, int mode) => + value.ref.ReleaseCharArrayElements.asFunction< + void Function( + ffi.Pointer env, + JCharArrayPtr array, + ffi.Pointer elems, + int mode)>()(this, array, elems, mode); + + void ReleaseShortArrayElements( + JShortArrayPtr array, ffi.Pointer elems, int mode) => + value.ref.ReleaseShortArrayElements.asFunction< + void Function( + ffi.Pointer env, + JShortArrayPtr array, + ffi.Pointer elems, + int mode)>()(this, array, elems, mode); + + void ReleaseIntArrayElements( + JIntArrayPtr array, ffi.Pointer elems, int mode) => + value.ref.ReleaseIntArrayElements.asFunction< + void Function( + ffi.Pointer env, + JIntArrayPtr array, + ffi.Pointer elems, + int mode)>()(this, array, elems, mode); + + void ReleaseLongArrayElements( + JLongArrayPtr array, ffi.Pointer elems, int mode) => + value.ref.ReleaseLongArrayElements.asFunction< + void Function( + ffi.Pointer env, + JLongArrayPtr array, + ffi.Pointer elems, + int mode)>()(this, array, elems, mode); + + void ReleaseFloatArrayElements( + JFloatArrayPtr array, ffi.Pointer elems, int mode) => + value.ref.ReleaseFloatArrayElements.asFunction< + void Function( + ffi.Pointer env, + JFloatArrayPtr array, + ffi.Pointer elems, + int mode)>()(this, array, elems, mode); + + void ReleaseDoubleArrayElements( + JDoubleArrayPtr array, ffi.Pointer elems, int mode) => + value.ref.ReleaseDoubleArrayElements.asFunction< + void Function( + ffi.Pointer env, + JDoubleArrayPtr array, + ffi.Pointer elems, + int mode)>()(this, array, elems, mode); + + void GetBooleanArrayRegion(JBooleanArrayPtr array, int start, int len, + ffi.Pointer buf) => + value.ref.GetBooleanArrayRegion.asFunction< + void Function( + ffi.Pointer env, + JBooleanArrayPtr array, + int start, + int len, + ffi.Pointer buf)>()(this, array, start, len, buf); + + void GetByteArrayRegion(JByteArrayPtr array, int start, int len, + ffi.Pointer buf) => + value.ref.GetByteArrayRegion.asFunction< + void Function( + ffi.Pointer env, + JByteArrayPtr array, + int start, + int len, + ffi.Pointer buf)>()(this, array, start, len, buf); + + void GetCharArrayRegion(JCharArrayPtr array, int start, int len, + ffi.Pointer buf) => + value.ref.GetCharArrayRegion.asFunction< + void Function( + ffi.Pointer env, + JCharArrayPtr array, + int start, + int len, + ffi.Pointer buf)>()(this, array, start, len, buf); + + void GetShortArrayRegion(JShortArrayPtr array, int start, int len, + ffi.Pointer buf) => + value.ref.GetShortArrayRegion.asFunction< + void Function( + ffi.Pointer env, + JShortArrayPtr array, + int start, + int len, + ffi.Pointer buf)>()(this, array, start, len, buf); + + void GetIntArrayRegion(JIntArrayPtr array, int start, int len, + ffi.Pointer buf) => + value.ref.GetIntArrayRegion.asFunction< + void Function( + ffi.Pointer env, + JIntArrayPtr array, + int start, + int len, + ffi.Pointer buf)>()(this, array, start, len, buf); + + void GetLongArrayRegion(JLongArrayPtr array, int start, int len, + ffi.Pointer buf) => + value.ref.GetLongArrayRegion.asFunction< + void Function( + ffi.Pointer env, + JLongArrayPtr array, + int start, + int len, + ffi.Pointer buf)>()(this, array, start, len, buf); + + void GetFloatArrayRegion(JFloatArrayPtr array, int start, int len, + ffi.Pointer buf) => + value.ref.GetFloatArrayRegion.asFunction< + void Function( + ffi.Pointer env, + JFloatArrayPtr array, + int start, + int len, + ffi.Pointer buf)>()(this, array, start, len, buf); + + void GetDoubleArrayRegion(JDoubleArrayPtr array, int start, int len, + ffi.Pointer buf) => + value.ref.GetDoubleArrayRegion.asFunction< + void Function( + ffi.Pointer env, + JDoubleArrayPtr array, + int start, + int len, + ffi.Pointer buf)>()(this, array, start, len, buf); + + void SetBooleanArrayRegion(JBooleanArrayPtr array, int start, int len, + ffi.Pointer buf) => + value.ref.SetBooleanArrayRegion.asFunction< + void Function( + ffi.Pointer env, + JBooleanArrayPtr array, + int start, + int len, + ffi.Pointer buf)>()(this, array, start, len, buf); + + void SetByteArrayRegion(JByteArrayPtr array, int start, int len, + ffi.Pointer buf) => + value.ref.SetByteArrayRegion.asFunction< + void Function( + ffi.Pointer env, + JByteArrayPtr array, + int start, + int len, + ffi.Pointer buf)>()(this, array, start, len, buf); + + void SetCharArrayRegion(JCharArrayPtr array, int start, int len, + ffi.Pointer buf) => + value.ref.SetCharArrayRegion.asFunction< + void Function( + ffi.Pointer env, + JCharArrayPtr array, + int start, + int len, + ffi.Pointer buf)>()(this, array, start, len, buf); + + void SetShortArrayRegion(JShortArrayPtr array, int start, int len, + ffi.Pointer buf) => + value.ref.SetShortArrayRegion.asFunction< + void Function( + ffi.Pointer env, + JShortArrayPtr array, + int start, + int len, + ffi.Pointer buf)>()(this, array, start, len, buf); + + void SetIntArrayRegion(JIntArrayPtr array, int start, int len, + ffi.Pointer buf) => + value.ref.SetIntArrayRegion.asFunction< + void Function( + ffi.Pointer env, + JIntArrayPtr array, + int start, + int len, + ffi.Pointer buf)>()(this, array, start, len, buf); + + void SetLongArrayRegion(JLongArrayPtr array, int start, int len, + ffi.Pointer buf) => + value.ref.SetLongArrayRegion.asFunction< + void Function( + ffi.Pointer env, + JLongArrayPtr array, + int start, + int len, + ffi.Pointer buf)>()(this, array, start, len, buf); + + void SetFloatArrayRegion(JFloatArrayPtr array, int start, int len, + ffi.Pointer buf) => + value.ref.SetFloatArrayRegion.asFunction< + void Function( + ffi.Pointer env, + JFloatArrayPtr array, + int start, + int len, + ffi.Pointer buf)>()(this, array, start, len, buf); + + void SetDoubleArrayRegion(JDoubleArrayPtr array, int start, int len, + ffi.Pointer buf) => + value.ref.SetDoubleArrayRegion.asFunction< + void Function( + ffi.Pointer env, + JDoubleArrayPtr array, + int start, + int len, + ffi.Pointer buf)>()(this, array, start, len, buf); + + int RegisterNatives(JClassPtr clazz, ffi.Pointer methods, + int nMethods) => + value.ref.RegisterNatives.asFunction< + int Function( + ffi.Pointer env, + JClassPtr clazz, + ffi.Pointer methods, + int nMethods)>()(this, clazz, methods, nMethods); + + int UnregisterNatives(JClassPtr clazz) => + value.ref.UnregisterNatives.asFunction< + int Function( + ffi.Pointer env, JClassPtr clazz)>()(this, clazz); + + int MonitorEnter(JObjectPtr obj) => value.ref.MonitorEnter + .asFunction env, JObjectPtr obj)>()( + this, obj); + + int MonitorExit(JObjectPtr obj) => value.ref.MonitorExit + .asFunction env, JObjectPtr obj)>()( + this, obj); + + int GetJavaVM(ffi.Pointer> vm) => + value.ref.GetJavaVM.asFunction< + int Function(ffi.Pointer env, + ffi.Pointer> vm)>()(this, vm); + + void GetStringRegion( + JStringPtr str, int start, int len, ffi.Pointer buf) => + value.ref.GetStringRegion.asFunction< + void Function( + ffi.Pointer env, + JStringPtr str, + int start, + int len, + ffi.Pointer buf)>()(this, str, start, len, buf); + + void GetStringUTFRegion( + JStringPtr str, int start, int len, ffi.Pointer buf) => + value.ref.GetStringUTFRegion.asFunction< + void Function( + ffi.Pointer env, + JStringPtr str, + int start, + int len, + ffi.Pointer buf)>()(this, str, start, len, buf); + + ffi.Pointer GetPrimitiveArrayCritical( + JArrayPtr array, ffi.Pointer isCopy) => + value.ref.GetPrimitiveArrayCritical.asFunction< + ffi.Pointer Function( + ffi.Pointer env, + JArrayPtr array, + ffi.Pointer isCopy)>()(this, array, isCopy); + + void ReleasePrimitiveArrayCritical( + JArrayPtr array, ffi.Pointer carray, int mode) => + value.ref.ReleasePrimitiveArrayCritical.asFunction< + void Function( + ffi.Pointer env, + JArrayPtr array, + ffi.Pointer carray, + int mode)>()(this, array, carray, mode); + + ffi.Pointer GetStringCritical( + JStringPtr str, ffi.Pointer isCopy) => + value.ref.GetStringCritical.asFunction< + ffi.Pointer Function( + ffi.Pointer env, + JStringPtr str, + ffi.Pointer isCopy)>()(this, str, isCopy); + + void ReleaseStringCritical(JStringPtr str, ffi.Pointer carray) => + value.ref.ReleaseStringCritical.asFunction< + void Function(ffi.Pointer env, JStringPtr str, + ffi.Pointer carray)>()(this, str, carray); + + JWeakPtr NewWeakGlobalRef(JObjectPtr obj) => + value.ref.NewWeakGlobalRef.asFunction< + JWeakPtr Function( + ffi.Pointer env, JObjectPtr obj)>()(this, obj); + + void DeleteWeakGlobalRef(JWeakPtr obj) => value.ref.DeleteWeakGlobalRef + .asFunction env, JWeakPtr obj)>()( + this, obj); + + int ExceptionCheck() => value.ref.ExceptionCheck + .asFunction env)>()(this); + + JObjectPtr NewDirectByteBuffer(ffi.Pointer address, int capacity) => + value.ref.NewDirectByteBuffer.asFunction< + JObjectPtr Function( + ffi.Pointer env, + ffi.Pointer address, + int capacity)>()(this, address, capacity); + + ffi.Pointer GetDirectBufferAddress(JObjectPtr buf) => + value.ref.GetDirectBufferAddress.asFunction< + ffi.Pointer Function( + ffi.Pointer env, JObjectPtr buf)>()(this, buf); + + int GetDirectBufferCapacity(JObjectPtr buf) => value + .ref.GetDirectBufferCapacity + .asFunction env, JObjectPtr buf)>()( + this, buf); + + int GetObjectRefType(JObjectPtr obj) => value.ref.GetObjectRefType + .asFunction env, JObjectPtr obj)>()( + this, obj); +} + +extension JavaVMExtension on ffi.Pointer { + int DestroyJavaVM() => value.ref.DestroyJavaVM + .asFunction vm)>()(this); + + int AttachCurrentThread(ffi.Pointer> p_env, + ffi.Pointer thr_args) => + value.ref.AttachCurrentThread.asFunction< + int Function( + ffi.Pointer vm, + ffi.Pointer> p_env, + ffi.Pointer thr_args)>()(this, p_env, thr_args); + + int DetachCurrentThread() => value.ref.DetachCurrentThread + .asFunction vm)>()(this); + + int GetEnv(ffi.Pointer> p_env, int version) => + value.ref.GetEnv.asFunction< + int Function( + ffi.Pointer vm, + ffi.Pointer> p_env, + int version)>()(this, p_env, version); + + int AttachCurrentThreadAsDaemon(ffi.Pointer> p_env, + ffi.Pointer thr_args) => + value.ref.AttachCurrentThreadAsDaemon.asFunction< + int Function( + ffi.Pointer vm, + ffi.Pointer> p_env, + ffi.Pointer thr_args)>()(this, p_env, thr_args); +} diff --git a/pkgs/jni/lib/src/types.dart b/pkgs/jni/lib/src/types.dart index 9c0cb4968..cc2dbecef 100644 --- a/pkgs/jni/lib/src/types.dart +++ b/pkgs/jni/lib/src/types.dart @@ -10,7 +10,7 @@ import 'package:ffi/ffi.dart'; import 'accessors.dart'; import 'jni.dart'; import 'jvalues.dart'; -import 'third_party/jni_bindings_generated.dart'; +import 'third_party/generated_bindings.dart'; part 'jarray.dart'; part 'jexceptions.dart'; @@ -47,11 +47,11 @@ abstract class JObjType extends JType { /// Creates an object from this type using the reference. T fromRef(Pointer ref); - JniClass getClass() { + JClass getClass() { if (signature.startsWith('L') && signature.endsWith(';')) { - return Jni.findJniClass(signature.substring(1, signature.length - 1)); + return Jni.findJClass(signature.substring(1, signature.length - 1)); } - return Jni.findJniClass(signature); + return Jni.findJClass(signature); } } diff --git a/pkgs/jni/pubspec.yaml b/pkgs/jni/pubspec.yaml index 40aa26ce0..e0a3771dd 100644 --- a/pkgs/jni/pubspec.yaml +++ b/pkgs/jni/pubspec.yaml @@ -4,24 +4,23 @@ version: 0.3.0 repository: https://github.com/dart-lang/jnigen/tree/main/jni environment: - sdk: ">=2.17.1 <4.0.0" - flutter: ">=2.11.0" + sdk: '>=2.17.1 <4.0.0' + flutter: '>=2.11.0' dependencies: collection: ^1.0.0 plugin_platform_interface: ^2.0.2 - ffi: ^2.0.0 + ffi: ^2.0.1 path: ^1.8.0 package_config: ^2.1.0 args: ^2.3.1 dev_dependencies: - ## After running `dart run ffigen --config ffigen.yaml` there - ## should be no changes. - ffigen: - path: third_party/ffigen_patch_jni + ## Pin ffigen version because we are depending on internal APIs. + ffigen: 7.2.10 flutter_lints: ^2.0.0 test: ^1.21.1 + logging: ^1.1.1 # The following section is specific to Flutter packages. flutter: @@ -37,4 +36,3 @@ flutter: ffiPlugin: true package: com.github.dart_lang.jni pluginClass: JniPlugin - diff --git a/pkgs/jni/src/dartjni.c b/pkgs/jni/src/dartjni.c index 6ef1dcf1c..74c4a119f 100644 --- a/pkgs/jni/src/dartjni.c +++ b/pkgs/jni/src/dartjni.c @@ -10,6 +10,12 @@ #include "include/dart_api_dl.h" +void initAllLocks(JniLocks* locks) { + init_lock(&locks->classLoadingLock); + init_lock(&locks->fieldLoadingLock); + init_lock(&locks->methodLoadingLock); +} + /// Stores class and method references for obtaining exception details typedef struct JniExceptionMethods { jclass objectClass, exceptionClass, printStreamClass; @@ -19,18 +25,26 @@ typedef struct JniExceptionMethods { } JniExceptionMethods; // Context and shared global state. Initialized once or if thread-local, initialized once in a thread. -JniContext jni = {NULL, NULL, NULL, NULL, NULL}; +JniContext jni_context = { + .jvm = NULL, + .classLoader = NULL, + .loadClassMethod = NULL, + .appContext = NULL, + .currentActivity = NULL, +}; + +JniContext* jni = &jni_context; thread_local JNIEnv* jniEnv = NULL; JniExceptionMethods exceptionMethods; -void initializeExceptionMethods(JniExceptionMethods* methods) { - methods->objectClass = LoadClass("java/lang/Object"); - methods->exceptionClass = LoadClass("java/lang/Exception"); - methods->printStreamClass = LoadClass("java/io/PrintStream"); +void initExceptionHandling(JniExceptionMethods* methods) { + methods->objectClass = FindClass("java/lang/Object"); + methods->exceptionClass = FindClass("java/lang/Exception"); + methods->printStreamClass = FindClass("java/io/PrintStream"); methods->byteArrayOutputStreamClass = - LoadClass("java/io/ByteArrayOutputStream"); + FindClass("java/io/ByteArrayOutputStream"); load_method(methods->objectClass, &methods->toStringMethod, "toString", "()Ljava/lang/String;"); load_method(methods->exceptionClass, &methods->printStackTraceMethod, @@ -45,47 +59,35 @@ void initializeExceptionMethods(JniExceptionMethods* methods) { /// Returns NULL if no JVM is running. FFI_PLUGIN_EXPORT JavaVM* GetJavaVM() { - return jni.jvm; + return jni_context.jvm; } -/// Load class through platform-specific mechanism. -/// -/// Currently uses application classloader on android, -/// and JNIEnv->FindClass on other platforms. FFI_PLUGIN_EXPORT -jclass LoadClass(const char* name) { +jclass FindClass(const char* name) { jclass cls = NULL; attach_thread(); - load_class(&cls, name); - return to_global_ref(cls); + load_class_global_ref(&cls, name); + return cls; }; // Android specifics -/// Returns Application classLoader (on Android), -/// which can be used to load application and platform classes. -/// ... -/// On other platforms, NULL is returned. FFI_PLUGIN_EXPORT jobject GetClassLoader() { attach_thread(); - return (*jniEnv)->NewGlobalRef(jniEnv, jni.classLoader); + return (*jniEnv)->NewGlobalRef(jniEnv, jni_context.classLoader); } -/// Returns application context on Android. -/// -/// On other platforms, NULL is returned. FFI_PLUGIN_EXPORT jobject GetApplicationContext() { attach_thread(); - return (*jniEnv)->NewGlobalRef(jniEnv, jni.appContext); + return (*jniEnv)->NewGlobalRef(jniEnv, jni_context.appContext); } -/// Returns current activity of the app FFI_PLUGIN_EXPORT jobject GetCurrentActivity() { attach_thread(); - return (*jniEnv)->NewGlobalRef(jniEnv, jni.currentActivity); + return (*jniEnv)->NewGlobalRef(jniEnv, jni_context.currentActivity); } // JNI Initialization @@ -97,14 +99,15 @@ Java_com_github_dart_1lang_jni_JniPlugin_initializeJni(JNIEnv* env, jobject appContext, jobject classLoader) { jniEnv = env; - (*env)->GetJavaVM(env, &jni.jvm); - jni.classLoader = (*env)->NewGlobalRef(env, classLoader); - jni.appContext = (*env)->NewGlobalRef(env, appContext); + (*env)->GetJavaVM(env, &jni_context.jvm); + jni_context.classLoader = (*env)->NewGlobalRef(env, classLoader); + jni_context.appContext = (*env)->NewGlobalRef(env, appContext); jclass classLoaderClass = (*env)->GetObjectClass(env, classLoader); - jni.loadClassMethod = + jni_context.loadClassMethod = (*env)->GetMethodID(env, classLoaderClass, "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;"); - initializeExceptionMethods(&exceptionMethods); + initAllLocks(&jni_context.locks); + initExceptionHandling(&exceptionMethods); } JNIEXPORT void JNICALL @@ -113,21 +116,24 @@ Java_com_github_dart_1lang_jni_JniPlugin_setJniActivity(JNIEnv* env, jobject activity, jobject context) { jniEnv = env; - if (jni.currentActivity != NULL) { - (*env)->DeleteGlobalRef(env, jni.currentActivity); + if (jni_context.currentActivity != NULL) { + (*env)->DeleteGlobalRef(env, jni_context.currentActivity); } - jni.currentActivity = (*env)->NewGlobalRef(env, activity); - if (jni.appContext != NULL) { - (*env)->DeleteGlobalRef(env, jni.appContext); + jni_context.currentActivity = (*env)->NewGlobalRef(env, activity); + if (jni_context.appContext != NULL) { + (*env)->DeleteGlobalRef(env, jni_context.appContext); } - jni.appContext = (*env)->NewGlobalRef(env, context); + jni_context.appContext = (*env)->NewGlobalRef(env, context); } // Sometimes you may get linker error trying to link JNI_CreateJavaVM APIs // on Android NDK. So IFDEF is required. #else FFI_PLUGIN_EXPORT -JNIEnv* SpawnJvm(JavaVMInitArgs* initArgs) { +int SpawnJvm(JavaVMInitArgs* initArgs) { + if (jni_context.jvm != NULL) { + return DART_JNI_SINGLETON_EXISTS; + } JavaVMOption jvmopt[1]; char class_path[] = "-Djava.class.path=."; jvmopt[0].optionString = class_path; @@ -139,12 +145,14 @@ JNIEnv* SpawnJvm(JavaVMInitArgs* initArgs) { vmArgs.ignoreUnrecognized = JNI_TRUE; initArgs = &vmArgs; } - const long flag = JNI_CreateJavaVM(&jni.jvm, __ENVP_CAST & jniEnv, initArgs); - if (flag == JNI_ERR) { - return NULL; + const long flag = + JNI_CreateJavaVM(&jni_context.jvm, __ENVP_CAST & jniEnv, initArgs); + if (flag != JNI_OK) { + return flag; } - initializeExceptionMethods(&exceptionMethods); - return jniEnv; + initAllLocks(&jni_context.locks); + initExceptionHandling(&exceptionMethods); + return JNI_OK; } #endif @@ -153,37 +161,41 @@ JNIEnv* SpawnJvm(JavaVMInitArgs* initArgs) { JniClassLookupResult getClass(char* internalName) { JniClassLookupResult result = {NULL, NULL}; - result.classRef = LoadClass(internalName); + result.value = FindClass(internalName); result.exception = check_exception(); return result; } -static inline JniPointerResult _getId( - void* (*getter)(JNIEnv*, jclass, char*, char*), - jclass cls, - char* name, - char* sig) { +typedef void* (*MemberGetter)(JNIEnv* env, + jclass* clazz, + char* name, + char* sig); + +static inline JniPointerResult _getId(MemberGetter getter, + jclass cls, + char* name, + char* sig) { JniPointerResult result = {NULL, NULL}; attach_thread(); - result.id = getter(jniEnv, cls, name, sig); + result.value = getter(jniEnv, cls, name, sig); result.exception = check_exception(); return result; } JniPointerResult getMethodID(jclass cls, char* name, char* sig) { - return _getId((*jniEnv)->GetMethodID, cls, name, sig); + return _getId((MemberGetter)(*jniEnv)->GetMethodID, cls, name, sig); } JniPointerResult getStaticMethodID(jclass cls, char* name, char* sig) { - return _getId((*jniEnv)->GetStaticMethodID, cls, name, sig); + return _getId((MemberGetter)(*jniEnv)->GetStaticMethodID, cls, name, sig); } JniPointerResult getFieldID(jclass cls, char* name, char* sig) { - return _getId((*jniEnv)->GetFieldID, cls, name, sig); + return _getId((MemberGetter)(*jniEnv)->GetFieldID, cls, name, sig); } JniPointerResult getStaticFieldID(jclass cls, char* name, char* sig) { - return _getId((*jniEnv)->GetStaticFieldID, cls, name, sig); + return _getId((MemberGetter)(*jniEnv)->GetStaticFieldID, cls, name, sig); } JniResult callMethod(jobject obj, @@ -225,7 +237,7 @@ JniResult callMethod(jobject obj, (*jniEnv)->CallVoidMethodA(jniEnv, obj, fieldID, args); break; } - JniResult jniResult = {.result = result, .exception = NULL}; + JniResult jniResult = {.value = result, .exception = NULL}; jniResult.exception = check_exception(); return jniResult; } @@ -272,7 +284,7 @@ JniResult callStaticMethod(jclass cls, (*jniEnv)->CallStaticVoidMethodA(jniEnv, cls, methodID, args); break; } - JniResult jniResult = {.result = result, .exception = NULL}; + JniResult jniResult = {.value = result, .exception = NULL}; jniResult.exception = check_exception(); return jniResult; } @@ -312,7 +324,7 @@ JniResult getField(jobject obj, jfieldID fieldID, int callType) { // This error should have been handled in Dart. break; } - JniResult jniResult = {.result = result, .exception = NULL}; + JniResult jniResult = {.value = result, .exception = NULL}; jniResult.exception = check_exception(); return jniResult; } @@ -356,7 +368,7 @@ JniResult getStaticField(jclass cls, jfieldID fieldID, int callType) { // or throw exception in Dart using Dart's C API. break; } - JniResult jniResult = {.result = result, .exception = NULL}; + JniResult jniResult = {.value = result, .exception = NULL}; jniResult.exception = check_exception(); return jniResult; } @@ -364,7 +376,7 @@ JniResult getStaticField(jclass cls, jfieldID fieldID, int callType) { JniResult newObject(jclass cls, jmethodID ctor, jvalue* args) { attach_thread(); JniResult jniResult; - jniResult.result.l = + jniResult.value.l = to_global_ref((*jniEnv)->NewObjectA(jniEnv, cls, ctor, args)); jniResult.exception = check_exception(); return jniResult; @@ -405,7 +417,8 @@ JniPointerResult newPrimitiveArray(jsize length, int type) { // or throw exception in Dart using Dart's C API. break; } - JniPointerResult result = {.id = to_global_ref(pointer), .exception = NULL}; + JniPointerResult result = {.value = to_global_ref(pointer), + .exception = NULL}; result.exception = check_exception(); return result; } @@ -416,13 +429,13 @@ JniPointerResult newObjectArray(jsize length, attach_thread(); jarray array = to_global_ref( (*jniEnv)->NewObjectArray(jniEnv, length, elementClass, initialElement)); - JniPointerResult result = {.id = array, .exception = NULL}; + JniPointerResult result = {.value = array, .exception = NULL}; result.exception = check_exception(); return result; } JniResult getArrayElement(jarray array, int index, int type) { - JniResult result = {NULL, NULL}; + JniResult result = {{.l = NULL}, NULL}; attach_thread(); jvalue value; switch (type) { @@ -459,7 +472,7 @@ JniResult getArrayElement(jarray array, int index, int type) { // or throw exception in Dart using Dart's C API. break; } - result.result = value; + result.value = value; result.exception = check_exception(); return result; } @@ -505,12 +518,12 @@ FFI_PLUGIN_EXPORT JniAccessors* GetAccessors() { } // These will not be required after migrating to Dart-only bindings. -FFI_PLUGIN_EXPORT JniContext GetJniContext() { +FFI_PLUGIN_EXPORT JniContext* GetJniContextPtr() { return jni; } FFI_PLUGIN_EXPORT JNIEnv* GetJniEnv() { - if (jni.jvm == NULL) { + if (jni_context.jvm == NULL) { return NULL; } attach_thread(); @@ -538,16 +551,16 @@ jclass _c_PortContinuation = NULL; jmethodID _m_PortContinuation__ctor = NULL; FFI_PLUGIN_EXPORT JniResult PortContinuation__ctor(int64_t j) { - load_class_gr(&_c_PortContinuation, - "com/github/dart_lang/jni/PortContinuation"); + load_class_global_ref(&_c_PortContinuation, + "com/github/dart_lang/jni/PortContinuation"); if (_c_PortContinuation == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PortContinuation, &_m_PortContinuation__ctor, "", "(J)V"); if (_m_PortContinuation__ctor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_PortContinuation, _m_PortContinuation__ctor, j); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } diff --git a/pkgs/jni/src/dartjni.h b/pkgs/jni/src/dartjni.h index 39b70bd8f..eb73318d1 100644 --- a/pkgs/jni/src/dartjni.h +++ b/pkgs/jni/src/dartjni.h @@ -39,6 +39,66 @@ #define __ENVP_CAST (void**) #endif +/// Locking functions for windows and pthread. + +#if defined _WIN32 +#include + +typedef CRITICAL_SECTION MutexLock; + +static inline void init_lock(MutexLock* lock) { + InitializeCriticalSection(lock); +} + +static inline void acquire_lock(MutexLock* lock) { + EnterCriticalSection(lock); +} + +static inline void release_lock(MutexLock* lock) { + LeaveCriticalSection(lock); +} + +static inline void _destroyLock(MutexLock* lock) { + DeleteCriticalSection(lock); +} + +#elif defined __DARWIN__ || defined __LINUX__ || defined __ANDROID__ || \ + defined __GNUC__ +#include + +typedef pthread_mutex_t MutexLock; + +static inline void init_lock(MutexLock* lock) { + pthread_mutex_init(lock, NULL); +} + +static inline void acquire_lock(MutexLock* lock) { + pthread_mutex_lock(lock); +} + +static inline void release_lock(MutexLock* lock) { + pthread_mutex_unlock(lock); +} + +static inline void _destroyLock(MutexLock* lock) { + pthread_mutex_destroy(lock); +} + +#else + +#error "No locking support; Possibly unsupported platform" + +#endif + +typedef struct JniLocks { + MutexLock classLoadingLock; + MutexLock methodLoadingLock; + MutexLock fieldLoadingLock; +} JniLocks; + +/// Represents the error when dart-jni layer has already spawned singleton VM. +#define DART_JNI_SINGLETON_EXISTS (-99); + /// Stores the global state of the JNI. typedef struct JniContext { JavaVM* jvm; @@ -46,13 +106,14 @@ typedef struct JniContext { jmethodID loadClassMethod; jobject currentActivity; jobject appContext; + JniLocks locks; } JniContext; // jniEnv for this thread, used by inline functions in this header, // therefore declared as extern. extern thread_local JNIEnv* jniEnv; -extern JniContext jni; +extern JniContext* jni; /// Types used by JNI API to distinguish between primitive types. enum JniType { @@ -73,19 +134,19 @@ enum JniType { /// If [exception] is null, it means the result is valid. /// It's assumed that the caller knows the expected type in [result]. typedef struct JniResult { - jvalue result; + jvalue value; jthrowable exception; } JniResult; /// Similar to [JniResult] but for class lookups. typedef struct JniClassLookupResult { - jclass classRef; + jclass value; jthrowable exception; } JniClassLookupResult; /// Similar to [JniResult] but for method/field ID lookups. typedef struct JniPointerResult { - void* id; + const void* value; jthrowable exception; } JniPointerResult; @@ -139,54 +200,71 @@ FFI_PLUGIN_EXPORT JavaVM* GetJavaVM(void); FFI_PLUGIN_EXPORT JNIEnv* GetJniEnv(void); -FFI_PLUGIN_EXPORT JNIEnv* SpawnJvm(JavaVMInitArgs* args); +/// 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. +FFI_PLUGIN_EXPORT int SpawnJvm(JavaVMInitArgs* args); -FFI_PLUGIN_EXPORT jclass LoadClass(const char* name); +/// Load class through platform-specific mechanism. +/// +/// Currently uses application classloader on android, +/// and JNIEnv->FindClass on other platforms. +FFI_PLUGIN_EXPORT jclass FindClass(const char* name); +/// Returns Application classLoader (on Android), +/// which can be used to load application and platform classes. +/// +/// On other platforms, NULL is returned. FFI_PLUGIN_EXPORT jobject GetClassLoader(void); +/// Returns application context on Android. +/// +/// On other platforms, NULL is returned. FFI_PLUGIN_EXPORT jobject GetApplicationContext(void); +/// Returns current activity of the app on Android. FFI_PLUGIN_EXPORT jobject GetCurrentActivity(void); -// Migration note: Below inline functions are required by C bindings, but can be moved to dartjni.c -// once migration to pure dart bindings is complete. - -// `static inline` because `inline` doesn't work, it may still not -// inline the function in which case a linker error may be produced. -// -// There has to be a better way to do this. Either to force inlining on target -// platforms, or just leave it as normal function. +static inline void attach_thread() { + if (jniEnv == NULL) { + (*jni->jvm)->AttachCurrentThread(jni->jvm, __ENVP_CAST & jniEnv, NULL); + } +} -static inline void __load_class_into(jclass* cls, const char* name) { +/// Load class into [cls] using platform specific mechanism +static inline void load_class_platform(jclass* cls, const char* name) { #ifdef __ANDROID__ jstring className = (*jniEnv)->NewStringUTF(jniEnv, name); - *cls = (*jniEnv)->CallObjectMethod(jniEnv, jni.classLoader, - jni.loadClassMethod, className); + *cls = (*jniEnv)->CallObjectMethod(jniEnv, jni->classLoader, + jni->loadClassMethod, className); (*jniEnv)->DeleteLocalRef(jniEnv, className); #else *cls = (*jniEnv)->FindClass(jniEnv, name); #endif } -static inline void load_class(jclass* cls, const char* name) { +static inline void load_class_local_ref(jclass* cls, const char* name) { if (*cls == NULL) { - __load_class_into(cls, name); + acquire_lock(&jni->locks.classLoadingLock); + if (*cls == NULL) { + load_class_platform(cls, name); + } + release_lock(&jni->locks.classLoadingLock); } } -static inline void load_class_gr(jclass* cls, const char* name) { +static inline void load_class_global_ref(jclass* cls, const char* name) { if (*cls == NULL) { - jclass tmp; - __load_class_into(&tmp, name); - *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); - (*jniEnv)->DeleteLocalRef(jniEnv, tmp); - } -} - -static inline void attach_thread() { - if (jniEnv == NULL) { - (*jni.jvm)->AttachCurrentThread(jni.jvm, __ENVP_CAST & jniEnv, NULL); + jclass tmp = NULL; + acquire_lock(&jni->locks.classLoadingLock); + if (*cls == NULL) { + load_class_platform(&tmp, name); + *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); + (*jniEnv)->DeleteLocalRef(jniEnv, tmp); + } + release_lock(&jni->locks.classLoadingLock); } } @@ -195,7 +273,11 @@ static inline void load_method(jclass cls, const char* name, const char* sig) { if (*res == NULL) { - *res = (*jniEnv)->GetMethodID(jniEnv, cls, name, sig); + acquire_lock(&jni->locks.methodLoadingLock); + if (*res == NULL) { + *res = (*jniEnv)->GetMethodID(jniEnv, cls, name, sig); + } + release_lock(&jni->locks.methodLoadingLock); } } @@ -204,7 +286,11 @@ static inline void load_static_method(jclass cls, const char* name, const char* sig) { if (*res == NULL) { - *res = (*jniEnv)->GetStaticMethodID(jniEnv, cls, name, sig); + acquire_lock(&jni->locks.methodLoadingLock); + if (*res == NULL) { + *res = (*jniEnv)->GetStaticMethodID(jniEnv, cls, name, sig); + } + release_lock(&jni->locks.methodLoadingLock); } } @@ -213,7 +299,11 @@ static inline void load_field(jclass cls, const char* name, const char* sig) { if (*res == NULL) { - *res = (*jniEnv)->GetFieldID(jniEnv, cls, name, sig); + acquire_lock(&jni->locks.fieldLoadingLock); + if (*res == NULL) { + *res = (*jniEnv)->GetFieldID(jniEnv, cls, name, sig); + } + release_lock(&jni->locks.fieldLoadingLock); } } @@ -222,7 +312,11 @@ static inline void load_static_field(jclass cls, const char* name, const char* sig) { if (*res == NULL) { - *res = (*jniEnv)->GetStaticFieldID(jniEnv, cls, name, sig); + acquire_lock(&jni->locks.fieldLoadingLock); + if (*res == NULL) { + *res = (*jniEnv)->GetStaticFieldID(jniEnv, cls, name, sig); + } + release_lock(&jni->locks.fieldLoadingLock); } } @@ -234,17 +328,18 @@ static inline jobject to_global_ref(jobject ref) { // These functions are useful for C+Dart bindings, and not required for pure dart bindings. -FFI_PLUGIN_EXPORT JniContext GetJniContext(); +FFI_PLUGIN_EXPORT JniContext* GetJniContextPtr(); + /// For use by jni_gen's generated code /// don't use these. // these 2 fn ptr vars will be defined by generated code library -extern JniContext (*context_getter)(void); +extern JniContext* (*context_getter)(void); extern JNIEnv* (*env_getter)(void); // this function will be exported by generated code library // it will set above 2 variables. -FFI_PLUGIN_EXPORT void setJniGetters(struct JniContext (*cg)(void), +FFI_PLUGIN_EXPORT void setJniGetters(struct JniContext* (*cg)(void), JNIEnv* (*eg)(void)); static inline void load_env() { diff --git a/pkgs/jni/src/jni_constants.h b/pkgs/jni/src/jni_constants.h new file mode 100644 index 000000000..8423ca10d --- /dev/null +++ b/pkgs/jni/src/jni_constants.h @@ -0,0 +1,31 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +// This file re-exports some JNI constants as enum, because they are not +// currently being included when they are in macro form. + +enum JniBooleanValues { JNI_FALSE = 0, JNI_TRUE = 1 }; + +enum JniVersions { + JNI_VERSION_1_1 = 0x00010001, + JNI_VERSION_1_2 = 0x00010002, + JNI_VERSION_1_4 = 0x00010004, + JNI_VERSION_1_6 = 0x00010006, +}; + +enum JniErrorCode { + // Error codes from JNI + JNI_OK = 0, /* no error */ + JNI_ERR = -1, /* generic error */ + JNI_EDETACHED = -2, /* thread detached from the VM */ + JNI_EVERSION = -3, /* JNI version error */ + JNI_ENOMEM = -4, /* Out of memory */ + JNI_EEXIST = -5, /* VM already created */ + JNI_EINVAL = -6, /* Invalid argument */ +}; + +enum JniBufferWriteBack { + JNI_COMMIT = 1, /* copy content, do not free buffer */ + JNI_ABORT = 2, /* free buffer w/o copying back */ +}; diff --git a/pkgs/jni/src/third_party/global_jni_env.c b/pkgs/jni/src/third_party/global_jni_env.c index 961f16f01..600b585b3 100644 --- a/pkgs/jni/src/third_party/global_jni_env.c +++ b/pkgs/jni/src/third_party/global_jni_env.c @@ -1,1215 +1,2279 @@ -// Generated from an annotated version of jni.h provided in Android NDK. -// (NDK Version 23.1.7779620) -// The license for original file is provided below: +// Auto generated file. Do not edit. + +// This is generated from JNI header in Android NDK. License for the same is +// provided below. + +/* + * Copyright (C) 2006 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* - * Copyright (C) 2006 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + * JNI specification, as defined by Sun: + * http://java.sun.com/javase/6/docs/technotes/guides/jni/spec/jniTOC.html + * + * Everything here is expected to be VM-neutral. + */ #include "global_jni_env.h" -#include "../dartjni.h" -jint globalEnv_GetVersion() { +JniResult globalEnv_GetVersion() { attach_thread(); - return (*jniEnv)->GetVersion(jniEnv); + jint _result = (*jniEnv)->GetVersion(jniEnv); + return (JniResult){.value = {.i = _result}, .exception = NULL}; } -jclass globalEnv_DefineClass(const char* name, - jobject loader, - const jbyte* buf, - jsize bufLen) { +JniClassLookupResult globalEnv_DefineClass(char* name, + jobject loader, + jbyte* buf, + jsize bufLen) { attach_thread(); - return to_global_ref( - (*jniEnv)->DefineClass(jniEnv, name, loader, buf, bufLen)); + jclass _result = (*jniEnv)->DefineClass(jniEnv, name, loader, buf, bufLen); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniClassLookupResult){.value = NULL, .exception = _exception}; + } + _result = to_global_ref(_result); + return (JniClassLookupResult){.value = _result, .exception = NULL}; } -jclass globalEnv_FindClass(const char* name) { +JniClassLookupResult globalEnv_FindClass(char* name) { attach_thread(); - return to_global_ref((*jniEnv)->FindClass(jniEnv, name)); + jclass _result = (*jniEnv)->FindClass(jniEnv, name); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniClassLookupResult){.value = NULL, .exception = _exception}; + } + _result = to_global_ref(_result); + return (JniClassLookupResult){.value = _result, .exception = NULL}; } -jmethodID globalEnv_FromReflectedMethod(jobject method) { +JniPointerResult globalEnv_FromReflectedMethod(jobject method) { attach_thread(); - return (*jniEnv)->FromReflectedMethod(jniEnv, method); + jmethodID _result = (*jniEnv)->FromReflectedMethod(jniEnv, method); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniPointerResult){.value = NULL, .exception = _exception}; + } + return (JniPointerResult){.value = _result, .exception = NULL}; } -jfieldID globalEnv_FromReflectedField(jobject field) { +JniPointerResult globalEnv_FromReflectedField(jobject field) { attach_thread(); - return (*jniEnv)->FromReflectedField(jniEnv, field); + jfieldID _result = (*jniEnv)->FromReflectedField(jniEnv, field); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniPointerResult){.value = NULL, .exception = _exception}; + } + return (JniPointerResult){.value = _result, .exception = NULL}; } -jobject globalEnv_ToReflectedMethod(jclass cls, - jmethodID methodId, - jboolean isStatic) { +JniResult globalEnv_ToReflectedMethod(jclass cls, + jmethodID methodId, + jboolean isStatic) { attach_thread(); - return to_global_ref( - (*jniEnv)->ToReflectedMethod(jniEnv, cls, methodId, isStatic)); + jobject _result = + (*jniEnv)->ToReflectedMethod(jniEnv, cls, methodId, isStatic); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + _result = to_global_ref(_result); + return (JniResult){.value = {.l = _result}, .exception = NULL}; } -jclass globalEnv_GetSuperclass(jclass clazz) { +JniClassLookupResult globalEnv_GetSuperclass(jclass clazz) { attach_thread(); - return to_global_ref((*jniEnv)->GetSuperclass(jniEnv, clazz)); + jclass _result = (*jniEnv)->GetSuperclass(jniEnv, clazz); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniClassLookupResult){.value = NULL, .exception = _exception}; + } + _result = to_global_ref(_result); + return (JniClassLookupResult){.value = _result, .exception = NULL}; } -jboolean globalEnv_IsAssignableFrom(jclass clazz1, jclass clazz2) { +JniResult globalEnv_IsAssignableFrom(jclass clazz1, jclass clazz2) { attach_thread(); - return (*jniEnv)->IsAssignableFrom(jniEnv, clazz1, clazz2); + jboolean _result = (*jniEnv)->IsAssignableFrom(jniEnv, clazz1, clazz2); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.z = _result}, .exception = NULL}; } -jobject globalEnv_ToReflectedField(jclass cls, - jfieldID fieldID, - jboolean isStatic) { +JniResult globalEnv_ToReflectedField(jclass cls, + jfieldID fieldID, + jboolean isStatic) { attach_thread(); - return to_global_ref( - (*jniEnv)->ToReflectedField(jniEnv, cls, fieldID, isStatic)); + jobject _result = (*jniEnv)->ToReflectedField(jniEnv, cls, fieldID, isStatic); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + _result = to_global_ref(_result); + return (JniResult){.value = {.l = _result}, .exception = NULL}; } -jint globalEnv_Throw(jthrowable obj) { +JniResult globalEnv_Throw(jthrowable obj) { attach_thread(); - return (*jniEnv)->Throw(jniEnv, obj); + jint _result = (*jniEnv)->Throw(jniEnv, obj); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.i = _result}, .exception = NULL}; } -jint globalEnv_ThrowNew(jclass clazz, const char* message) { +JniResult globalEnv_ThrowNew(jclass clazz, char* message) { attach_thread(); - return (*jniEnv)->ThrowNew(jniEnv, clazz, message); + jint _result = (*jniEnv)->ThrowNew(jniEnv, clazz, message); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.i = _result}, .exception = NULL}; } -jthrowable globalEnv_ExceptionOccurred() { +JniResult globalEnv_ExceptionOccurred() { attach_thread(); - return to_global_ref((*jniEnv)->ExceptionOccurred(jniEnv)); + jthrowable _result = (*jniEnv)->ExceptionOccurred(jniEnv); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + _result = to_global_ref(_result); + return (JniResult){.value = {.l = _result}, .exception = NULL}; } -void globalEnv_ExceptionDescribe() { +jthrowable globalEnv_ExceptionDescribe() { attach_thread(); (*jniEnv)->ExceptionDescribe(jniEnv); + return NULL; } -void globalEnv_ExceptionClear() { +jthrowable globalEnv_ExceptionClear() { attach_thread(); (*jniEnv)->ExceptionClear(jniEnv); + return NULL; } -void globalEnv_FatalError(const char* msg) { +jthrowable globalEnv_FatalError(char* msg) { attach_thread(); (*jniEnv)->FatalError(jniEnv, msg); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -jint globalEnv_PushLocalFrame(jint capacity) { +JniResult globalEnv_PushLocalFrame(jint capacity) { attach_thread(); - return (*jniEnv)->PushLocalFrame(jniEnv, capacity); + jint _result = (*jniEnv)->PushLocalFrame(jniEnv, capacity); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.i = _result}, .exception = NULL}; } -jobject globalEnv_PopLocalFrame(jobject result) { +JniResult globalEnv_PopLocalFrame(jobject result) { attach_thread(); - return to_global_ref((*jniEnv)->PopLocalFrame(jniEnv, result)); + jobject _result = (*jniEnv)->PopLocalFrame(jniEnv, result); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + _result = to_global_ref(_result); + return (JniResult){.value = {.l = _result}, .exception = NULL}; } -jobject globalEnv_NewGlobalRef(jobject obj) { +JniResult globalEnv_NewGlobalRef(jobject obj) { attach_thread(); - return to_global_ref((*jniEnv)->NewGlobalRef(jniEnv, obj)); + jobject _result = (*jniEnv)->NewGlobalRef(jniEnv, obj); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.l = _result}, .exception = NULL}; } -void globalEnv_DeleteGlobalRef(jobject globalRef) { +jthrowable globalEnv_DeleteGlobalRef(jobject globalRef) { attach_thread(); (*jniEnv)->DeleteGlobalRef(jniEnv, globalRef); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -jboolean globalEnv_IsSameObject(jobject ref1, jobject ref2) { +jthrowable globalEnv_DeleteLocalRef(jobject localRef) { attach_thread(); - return (*jniEnv)->IsSameObject(jniEnv, ref1, ref2); + (*jniEnv)->DeleteLocalRef(jniEnv, localRef); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -jint globalEnv_EnsureLocalCapacity(jint capacity) { +JniResult globalEnv_IsSameObject(jobject ref1, jobject ref2) { attach_thread(); - return (*jniEnv)->EnsureLocalCapacity(jniEnv, capacity); + jboolean _result = (*jniEnv)->IsSameObject(jniEnv, ref1, ref2); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.z = _result}, .exception = NULL}; } -jobject globalEnv_AllocObject(jclass clazz) { +JniResult globalEnv_NewLocalRef(jobject obj) { attach_thread(); - return to_global_ref((*jniEnv)->AllocObject(jniEnv, clazz)); + jobject _result = (*jniEnv)->NewLocalRef(jniEnv, obj); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.l = _result}, .exception = NULL}; } -jobject globalEnv_NewObject(jclass arg1, jmethodID arg2) { +JniResult globalEnv_EnsureLocalCapacity(jint capacity) { attach_thread(); - return to_global_ref((*jniEnv)->NewObject(jniEnv, arg1, arg2)); + jint _result = (*jniEnv)->EnsureLocalCapacity(jniEnv, capacity); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.i = _result}, .exception = NULL}; } -jobject globalEnv_NewObjectA(jclass clazz, - jmethodID methodID, - const jvalue* args) { +JniResult globalEnv_AllocObject(jclass clazz) { attach_thread(); - return to_global_ref((*jniEnv)->NewObjectA(jniEnv, clazz, methodID, args)); + jobject _result = (*jniEnv)->AllocObject(jniEnv, clazz); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + _result = to_global_ref(_result); + return (JniResult){.value = {.l = _result}, .exception = NULL}; } -jclass globalEnv_GetObjectClass(jobject obj) { +JniResult globalEnv_NewObject(jclass clazz, jmethodID methodID) { attach_thread(); - return to_global_ref((*jniEnv)->GetObjectClass(jniEnv, obj)); + jobject _result = (*jniEnv)->NewObject(jniEnv, clazz, methodID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + _result = to_global_ref(_result); + return (JniResult){.value = {.l = _result}, .exception = NULL}; } -jboolean globalEnv_IsInstanceOf(jobject obj, jclass clazz) { +JniResult globalEnv_NewObjectA(jclass clazz, jmethodID methodID, jvalue* args) { attach_thread(); - return (*jniEnv)->IsInstanceOf(jniEnv, obj, clazz); + jobject _result = (*jniEnv)->NewObjectA(jniEnv, clazz, methodID, args); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + _result = to_global_ref(_result); + return (JniResult){.value = {.l = _result}, .exception = NULL}; } -jmethodID globalEnv_GetMethodID(jclass clazz, - const char* name, - const char* sig) { +JniClassLookupResult globalEnv_GetObjectClass(jobject obj) { attach_thread(); - return (*jniEnv)->GetMethodID(jniEnv, clazz, name, sig); + jclass _result = (*jniEnv)->GetObjectClass(jniEnv, obj); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniClassLookupResult){.value = NULL, .exception = _exception}; + } + _result = to_global_ref(_result); + return (JniClassLookupResult){.value = _result, .exception = NULL}; } -jobject globalEnv_CallObjectMethod(jobject arg1, jmethodID arg2) { +JniResult globalEnv_IsInstanceOf(jobject obj, jclass clazz) { attach_thread(); - return to_global_ref((*jniEnv)->CallObjectMethod(jniEnv, arg1, arg2)); + jboolean _result = (*jniEnv)->IsInstanceOf(jniEnv, obj, clazz); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.z = _result}, .exception = NULL}; } -jobject globalEnv_CallObjectMethodA(jobject obj, - jmethodID methodID, - const jvalue* args) { +JniPointerResult globalEnv_GetMethodID(jclass clazz, char* name, char* sig) { attach_thread(); - return to_global_ref( - (*jniEnv)->CallObjectMethodA(jniEnv, obj, methodID, args)); + jmethodID _result = (*jniEnv)->GetMethodID(jniEnv, clazz, name, sig); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniPointerResult){.value = NULL, .exception = _exception}; + } + return (JniPointerResult){.value = _result, .exception = NULL}; } -jboolean globalEnv_CallBooleanMethod(jobject arg1, jmethodID arg2) { +JniResult globalEnv_CallObjectMethod(jobject obj, jmethodID methodID) { attach_thread(); - return (*jniEnv)->CallBooleanMethod(jniEnv, arg1, arg2); + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, obj, methodID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + _result = to_global_ref(_result); + return (JniResult){.value = {.l = _result}, .exception = NULL}; } -jboolean globalEnv_CallBooleanMethodA(jobject obj, - jmethodID methodId, - const jvalue* args) { +JniResult globalEnv_CallObjectMethodA(jobject obj, + jmethodID methodID, + jvalue* args) { attach_thread(); - return (*jniEnv)->CallBooleanMethodA(jniEnv, obj, methodId, args); + jobject _result = (*jniEnv)->CallObjectMethodA(jniEnv, obj, methodID, args); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + _result = to_global_ref(_result); + return (JniResult){.value = {.l = _result}, .exception = NULL}; } -jbyte globalEnv_CallByteMethod(jobject arg1, jmethodID arg2) { +JniResult globalEnv_CallBooleanMethod(jobject obj, jmethodID methodID) { attach_thread(); - return (*jniEnv)->CallByteMethod(jniEnv, arg1, arg2); + jboolean _result = (*jniEnv)->CallBooleanMethod(jniEnv, obj, methodID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.z = _result}, .exception = NULL}; } -jbyte globalEnv_CallByteMethodA(jobject obj, - jmethodID methodID, - const jvalue* args) { +JniResult globalEnv_CallBooleanMethodA(jobject obj, + jmethodID methodId, + jvalue* args) { attach_thread(); - return (*jniEnv)->CallByteMethodA(jniEnv, obj, methodID, args); + jboolean _result = (*jniEnv)->CallBooleanMethodA(jniEnv, obj, methodId, args); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.z = _result}, .exception = NULL}; } -jchar globalEnv_CallCharMethod(jobject arg1, jmethodID arg2) { +JniResult globalEnv_CallByteMethod(jobject obj, jmethodID methodID) { attach_thread(); - return (*jniEnv)->CallCharMethod(jniEnv, arg1, arg2); + jbyte _result = (*jniEnv)->CallByteMethod(jniEnv, obj, methodID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.b = _result}, .exception = NULL}; } -jchar globalEnv_CallCharMethodA(jobject obj, - jmethodID methodID, - const jvalue* args) { +JniResult globalEnv_CallByteMethodA(jobject obj, + jmethodID methodID, + jvalue* args) { attach_thread(); - return (*jniEnv)->CallCharMethodA(jniEnv, obj, methodID, args); + jbyte _result = (*jniEnv)->CallByteMethodA(jniEnv, obj, methodID, args); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.b = _result}, .exception = NULL}; } -jshort globalEnv_CallShortMethod(jobject arg1, jmethodID arg2) { +JniResult globalEnv_CallCharMethod(jobject obj, jmethodID methodID) { attach_thread(); - return (*jniEnv)->CallShortMethod(jniEnv, arg1, arg2); + jchar _result = (*jniEnv)->CallCharMethod(jniEnv, obj, methodID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.c = _result}, .exception = NULL}; } -jshort globalEnv_CallShortMethodA(jobject obj, - jmethodID methodID, - const jvalue* args) { +JniResult globalEnv_CallCharMethodA(jobject obj, + jmethodID methodID, + jvalue* args) { attach_thread(); - return (*jniEnv)->CallShortMethodA(jniEnv, obj, methodID, args); + jchar _result = (*jniEnv)->CallCharMethodA(jniEnv, obj, methodID, args); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.c = _result}, .exception = NULL}; } -jint globalEnv_CallIntMethod(jobject arg1, jmethodID arg2) { +JniResult globalEnv_CallShortMethod(jobject obj, jmethodID methodID) { attach_thread(); - return (*jniEnv)->CallIntMethod(jniEnv, arg1, arg2); + jshort _result = (*jniEnv)->CallShortMethod(jniEnv, obj, methodID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.s = _result}, .exception = NULL}; } -jint globalEnv_CallIntMethodA(jobject obj, - jmethodID methodID, - const jvalue* args) { +JniResult globalEnv_CallShortMethodA(jobject obj, + jmethodID methodID, + jvalue* args) { attach_thread(); - return (*jniEnv)->CallIntMethodA(jniEnv, obj, methodID, args); + jshort _result = (*jniEnv)->CallShortMethodA(jniEnv, obj, methodID, args); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.s = _result}, .exception = NULL}; } -jlong globalEnv_CallLongMethod(jobject arg1, jmethodID arg2) { +JniResult globalEnv_CallIntMethod(jobject obj, jmethodID methodID) { attach_thread(); - return (*jniEnv)->CallLongMethod(jniEnv, arg1, arg2); + jint _result = (*jniEnv)->CallIntMethod(jniEnv, obj, methodID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.i = _result}, .exception = NULL}; } -jlong globalEnv_CallLongMethodA(jobject obj, - jmethodID methodID, - const jvalue* args) { +JniResult globalEnv_CallIntMethodA(jobject obj, + jmethodID methodID, + jvalue* args) { attach_thread(); - return (*jniEnv)->CallLongMethodA(jniEnv, obj, methodID, args); + jint _result = (*jniEnv)->CallIntMethodA(jniEnv, obj, methodID, args); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.i = _result}, .exception = NULL}; } -jfloat globalEnv_CallFloatMethod(jobject arg1, jmethodID arg2) { +JniResult globalEnv_CallLongMethod(jobject obj, jmethodID methodID) { attach_thread(); - return (*jniEnv)->CallFloatMethod(jniEnv, arg1, arg2); + jlong _result = (*jniEnv)->CallLongMethod(jniEnv, obj, methodID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.j = _result}, .exception = NULL}; } -jfloat globalEnv_CallFloatMethodA(jobject obj, - jmethodID methodID, - const jvalue* args) { +JniResult globalEnv_CallLongMethodA(jobject obj, + jmethodID methodID, + jvalue* args) { attach_thread(); - return (*jniEnv)->CallFloatMethodA(jniEnv, obj, methodID, args); + jlong _result = (*jniEnv)->CallLongMethodA(jniEnv, obj, methodID, args); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.j = _result}, .exception = NULL}; } -jdouble globalEnv_CallDoubleMethod(jobject arg1, jmethodID arg2) { +JniResult globalEnv_CallFloatMethod(jobject obj, jmethodID methodID) { attach_thread(); - return (*jniEnv)->CallDoubleMethod(jniEnv, arg1, arg2); + jfloat _result = (*jniEnv)->CallFloatMethod(jniEnv, obj, methodID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.f = _result}, .exception = NULL}; } -jdouble globalEnv_CallDoubleMethodA(jobject obj, - jmethodID methodID, - const jvalue* args) { +JniResult globalEnv_CallFloatMethodA(jobject obj, + jmethodID methodID, + jvalue* args) { attach_thread(); - return (*jniEnv)->CallDoubleMethodA(jniEnv, obj, methodID, args); + jfloat _result = (*jniEnv)->CallFloatMethodA(jniEnv, obj, methodID, args); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.f = _result}, .exception = NULL}; } -void globalEnv_CallVoidMethod(jobject arg1, jmethodID arg2) { +JniResult globalEnv_CallDoubleMethod(jobject obj, jmethodID methodID) { attach_thread(); - (*jniEnv)->CallVoidMethod(jniEnv, arg1, arg2); + jdouble _result = (*jniEnv)->CallDoubleMethod(jniEnv, obj, methodID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.d = _result}, .exception = NULL}; } -void globalEnv_CallVoidMethodA(jobject obj, - jmethodID methodID, - const jvalue* args) { +JniResult globalEnv_CallDoubleMethodA(jobject obj, + jmethodID methodID, + jvalue* args) { attach_thread(); - (*jniEnv)->CallVoidMethodA(jniEnv, obj, methodID, args); + jdouble _result = (*jniEnv)->CallDoubleMethodA(jniEnv, obj, methodID, args); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.d = _result}, .exception = NULL}; } -jobject globalEnv_CallNonvirtualObjectMethod(jobject arg1, - jclass arg2, - jmethodID arg3) { +jthrowable globalEnv_CallVoidMethod(jobject obj, jmethodID methodID) { attach_thread(); - return to_global_ref( - (*jniEnv)->CallNonvirtualObjectMethod(jniEnv, arg1, arg2, arg3)); + (*jniEnv)->CallVoidMethod(jniEnv, obj, methodID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -jobject globalEnv_CallNonvirtualObjectMethodA(jobject obj, - jclass clazz, - jmethodID methodID, - const jvalue* args) { +jthrowable globalEnv_CallVoidMethodA(jobject obj, + jmethodID methodID, + jvalue* args) { attach_thread(); - return to_global_ref((*jniEnv)->CallNonvirtualObjectMethodA( - jniEnv, obj, clazz, methodID, args)); + (*jniEnv)->CallVoidMethodA(jniEnv, obj, methodID, args); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -jboolean globalEnv_CallNonvirtualBooleanMethod(jobject arg1, - jclass arg2, - jmethodID arg3) { +JniResult globalEnv_CallNonvirtualObjectMethod(jobject obj, + jclass clazz, + jmethodID methodID) { attach_thread(); - return (*jniEnv)->CallNonvirtualBooleanMethod(jniEnv, arg1, arg2, arg3); + jobject _result = + (*jniEnv)->CallNonvirtualObjectMethod(jniEnv, obj, clazz, methodID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + _result = to_global_ref(_result); + return (JniResult){.value = {.l = _result}, .exception = NULL}; } -jboolean globalEnv_CallNonvirtualBooleanMethodA(jobject obj, +JniResult globalEnv_CallNonvirtualObjectMethodA(jobject obj, jclass clazz, jmethodID methodID, - const jvalue* args) { + jvalue* args) { + attach_thread(); + jobject _result = (*jniEnv)->CallNonvirtualObjectMethodA(jniEnv, obj, clazz, + methodID, args); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + _result = to_global_ref(_result); + return (JniResult){.value = {.l = _result}, .exception = NULL}; +} + +JniResult globalEnv_CallNonvirtualBooleanMethod(jobject obj, + jclass clazz, + jmethodID methodID) { attach_thread(); - return (*jniEnv)->CallNonvirtualBooleanMethodA(jniEnv, obj, clazz, methodID, - args); + jboolean _result = + (*jniEnv)->CallNonvirtualBooleanMethod(jniEnv, obj, clazz, methodID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.z = _result}, .exception = NULL}; } -jbyte globalEnv_CallNonvirtualByteMethod(jobject arg1, - jclass arg2, - jmethodID arg3) { +JniResult globalEnv_CallNonvirtualBooleanMethodA(jobject obj, + jclass clazz, + jmethodID methodID, + jvalue* args) { attach_thread(); - return (*jniEnv)->CallNonvirtualByteMethod(jniEnv, arg1, arg2, arg3); + jboolean _result = (*jniEnv)->CallNonvirtualBooleanMethodA(jniEnv, obj, clazz, + methodID, args); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.z = _result}, .exception = NULL}; } -jbyte globalEnv_CallNonvirtualByteMethodA(jobject obj, - jclass clazz, - jmethodID methodID, - const jvalue* args) { +JniResult globalEnv_CallNonvirtualByteMethod(jobject obj, + jclass clazz, + jmethodID methodID) { attach_thread(); - return (*jniEnv)->CallNonvirtualByteMethodA(jniEnv, obj, clazz, methodID, - args); + jbyte _result = + (*jniEnv)->CallNonvirtualByteMethod(jniEnv, obj, clazz, methodID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.b = _result}, .exception = NULL}; } -jchar globalEnv_CallNonvirtualCharMethod(jobject arg1, - jclass arg2, - jmethodID arg3) { +JniResult globalEnv_CallNonvirtualByteMethodA(jobject obj, + jclass clazz, + jmethodID methodID, + jvalue* args) { attach_thread(); - return (*jniEnv)->CallNonvirtualCharMethod(jniEnv, arg1, arg2, arg3); + jbyte _result = + (*jniEnv)->CallNonvirtualByteMethodA(jniEnv, obj, clazz, methodID, args); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.b = _result}, .exception = NULL}; } -jchar globalEnv_CallNonvirtualCharMethodA(jobject obj, - jclass clazz, - jmethodID methodID, - const jvalue* args) { +JniResult globalEnv_CallNonvirtualCharMethod(jobject obj, + jclass clazz, + jmethodID methodID) { attach_thread(); - return (*jniEnv)->CallNonvirtualCharMethodA(jniEnv, obj, clazz, methodID, - args); + jchar _result = + (*jniEnv)->CallNonvirtualCharMethod(jniEnv, obj, clazz, methodID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.c = _result}, .exception = NULL}; } -jshort globalEnv_CallNonvirtualShortMethod(jobject arg1, - jclass arg2, - jmethodID arg3) { +JniResult globalEnv_CallNonvirtualCharMethodA(jobject obj, + jclass clazz, + jmethodID methodID, + jvalue* args) { attach_thread(); - return (*jniEnv)->CallNonvirtualShortMethod(jniEnv, arg1, arg2, arg3); + jchar _result = + (*jniEnv)->CallNonvirtualCharMethodA(jniEnv, obj, clazz, methodID, args); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.c = _result}, .exception = NULL}; } -jshort globalEnv_CallNonvirtualShortMethodA(jobject obj, - jclass clazz, - jmethodID methodID, - const jvalue* args) { +JniResult globalEnv_CallNonvirtualShortMethod(jobject obj, + jclass clazz, + jmethodID methodID) { attach_thread(); - return (*jniEnv)->CallNonvirtualShortMethodA(jniEnv, obj, clazz, methodID, - args); + jshort _result = + (*jniEnv)->CallNonvirtualShortMethod(jniEnv, obj, clazz, methodID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.s = _result}, .exception = NULL}; } -jint globalEnv_CallNonvirtualIntMethod(jobject arg1, - jclass arg2, - jmethodID arg3) { +JniResult globalEnv_CallNonvirtualShortMethodA(jobject obj, + jclass clazz, + jmethodID methodID, + jvalue* args) { attach_thread(); - return (*jniEnv)->CallNonvirtualIntMethod(jniEnv, arg1, arg2, arg3); + jshort _result = + (*jniEnv)->CallNonvirtualShortMethodA(jniEnv, obj, clazz, methodID, args); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.s = _result}, .exception = NULL}; } -jint globalEnv_CallNonvirtualIntMethodA(jobject obj, - jclass clazz, - jmethodID methodID, - const jvalue* args) { +JniResult globalEnv_CallNonvirtualIntMethod(jobject obj, + jclass clazz, + jmethodID methodID) { attach_thread(); - return (*jniEnv)->CallNonvirtualIntMethodA(jniEnv, obj, clazz, methodID, - args); + jint _result = + (*jniEnv)->CallNonvirtualIntMethod(jniEnv, obj, clazz, methodID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.i = _result}, .exception = NULL}; } -jlong globalEnv_CallNonvirtualLongMethod(jobject arg1, - jclass arg2, - jmethodID arg3) { +JniResult globalEnv_CallNonvirtualIntMethodA(jobject obj, + jclass clazz, + jmethodID methodID, + jvalue* args) { attach_thread(); - return (*jniEnv)->CallNonvirtualLongMethod(jniEnv, arg1, arg2, arg3); + jint _result = + (*jniEnv)->CallNonvirtualIntMethodA(jniEnv, obj, clazz, methodID, args); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.i = _result}, .exception = NULL}; } -jlong globalEnv_CallNonvirtualLongMethodA(jobject obj, - jclass clazz, - jmethodID methodID, - const jvalue* args) { +JniResult globalEnv_CallNonvirtualLongMethod(jobject obj, + jclass clazz, + jmethodID methodID) { attach_thread(); - return (*jniEnv)->CallNonvirtualLongMethodA(jniEnv, obj, clazz, methodID, - args); + jlong _result = + (*jniEnv)->CallNonvirtualLongMethod(jniEnv, obj, clazz, methodID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.j = _result}, .exception = NULL}; } -jfloat globalEnv_CallNonvirtualFloatMethod(jobject arg1, - jclass arg2, - jmethodID arg3) { +JniResult globalEnv_CallNonvirtualLongMethodA(jobject obj, + jclass clazz, + jmethodID methodID, + jvalue* args) { attach_thread(); - return (*jniEnv)->CallNonvirtualFloatMethod(jniEnv, arg1, arg2, arg3); + jlong _result = + (*jniEnv)->CallNonvirtualLongMethodA(jniEnv, obj, clazz, methodID, args); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.j = _result}, .exception = NULL}; } -jfloat globalEnv_CallNonvirtualFloatMethodA(jobject obj, - jclass clazz, - jmethodID methodID, - const jvalue* args) { +JniResult globalEnv_CallNonvirtualFloatMethod(jobject obj, + jclass clazz, + jmethodID methodID) { attach_thread(); - return (*jniEnv)->CallNonvirtualFloatMethodA(jniEnv, obj, clazz, methodID, - args); + jfloat _result = + (*jniEnv)->CallNonvirtualFloatMethod(jniEnv, obj, clazz, methodID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.f = _result}, .exception = NULL}; } -jdouble globalEnv_CallNonvirtualDoubleMethod(jobject arg1, - jclass arg2, - jmethodID arg3) { +JniResult globalEnv_CallNonvirtualFloatMethodA(jobject obj, + jclass clazz, + jmethodID methodID, + jvalue* args) { attach_thread(); - return (*jniEnv)->CallNonvirtualDoubleMethod(jniEnv, arg1, arg2, arg3); + jfloat _result = + (*jniEnv)->CallNonvirtualFloatMethodA(jniEnv, obj, clazz, methodID, args); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.f = _result}, .exception = NULL}; } -jdouble globalEnv_CallNonvirtualDoubleMethodA(jobject obj, - jclass clazz, - jmethodID methodID, - const jvalue* args) { +JniResult globalEnv_CallNonvirtualDoubleMethod(jobject obj, + jclass clazz, + jmethodID methodID) { + attach_thread(); + jdouble _result = + (*jniEnv)->CallNonvirtualDoubleMethod(jniEnv, obj, clazz, methodID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.d = _result}, .exception = NULL}; +} + +JniResult globalEnv_CallNonvirtualDoubleMethodA(jobject obj, + jclass clazz, + jmethodID methodID, + jvalue* args) { attach_thread(); - return (*jniEnv)->CallNonvirtualDoubleMethodA(jniEnv, obj, clazz, methodID, - args); + jdouble _result = (*jniEnv)->CallNonvirtualDoubleMethodA(jniEnv, obj, clazz, + methodID, args); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.d = _result}, .exception = NULL}; } -void globalEnv_CallNonvirtualVoidMethod(jobject arg1, - jclass arg2, - jmethodID arg3) { +jthrowable globalEnv_CallNonvirtualVoidMethod(jobject obj, + jclass clazz, + jmethodID methodID) { attach_thread(); - (*jniEnv)->CallNonvirtualVoidMethod(jniEnv, arg1, arg2, arg3); + (*jniEnv)->CallNonvirtualVoidMethod(jniEnv, obj, clazz, methodID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_CallNonvirtualVoidMethodA(jobject obj, - jclass clazz, - jmethodID methodID, - const jvalue* args) { +jthrowable globalEnv_CallNonvirtualVoidMethodA(jobject obj, + jclass clazz, + jmethodID methodID, + jvalue* args) { attach_thread(); (*jniEnv)->CallNonvirtualVoidMethodA(jniEnv, obj, clazz, methodID, args); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -jfieldID globalEnv_GetFieldID(jclass clazz, const char* name, const char* sig) { +JniPointerResult globalEnv_GetFieldID(jclass clazz, char* name, char* sig) { attach_thread(); - return (*jniEnv)->GetFieldID(jniEnv, clazz, name, sig); + jfieldID _result = (*jniEnv)->GetFieldID(jniEnv, clazz, name, sig); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniPointerResult){.value = NULL, .exception = _exception}; + } + return (JniPointerResult){.value = _result, .exception = NULL}; } -jobject globalEnv_GetObjectField(jobject obj, jfieldID fieldID) { +JniResult globalEnv_GetObjectField(jobject obj, jfieldID fieldID) { attach_thread(); - return to_global_ref((*jniEnv)->GetObjectField(jniEnv, obj, fieldID)); + jobject _result = (*jniEnv)->GetObjectField(jniEnv, obj, fieldID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + _result = to_global_ref(_result); + return (JniResult){.value = {.l = _result}, .exception = NULL}; } -jboolean globalEnv_GetBooleanField(jobject obj, jfieldID fieldID) { +JniResult globalEnv_GetBooleanField(jobject obj, jfieldID fieldID) { attach_thread(); - return (*jniEnv)->GetBooleanField(jniEnv, obj, fieldID); + jboolean _result = (*jniEnv)->GetBooleanField(jniEnv, obj, fieldID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.z = _result}, .exception = NULL}; } -jbyte globalEnv_GetByteField(jobject obj, jfieldID fieldID) { +JniResult globalEnv_GetByteField(jobject obj, jfieldID fieldID) { attach_thread(); - return (*jniEnv)->GetByteField(jniEnv, obj, fieldID); + jbyte _result = (*jniEnv)->GetByteField(jniEnv, obj, fieldID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.b = _result}, .exception = NULL}; } -jchar globalEnv_GetCharField(jobject obj, jfieldID fieldID) { +JniResult globalEnv_GetCharField(jobject obj, jfieldID fieldID) { attach_thread(); - return (*jniEnv)->GetCharField(jniEnv, obj, fieldID); + jchar _result = (*jniEnv)->GetCharField(jniEnv, obj, fieldID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.c = _result}, .exception = NULL}; } -jshort globalEnv_GetShortField(jobject obj, jfieldID fieldID) { +JniResult globalEnv_GetShortField(jobject obj, jfieldID fieldID) { attach_thread(); - return (*jniEnv)->GetShortField(jniEnv, obj, fieldID); + jshort _result = (*jniEnv)->GetShortField(jniEnv, obj, fieldID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.s = _result}, .exception = NULL}; } -jint globalEnv_GetIntField(jobject obj, jfieldID fieldID) { +JniResult globalEnv_GetIntField(jobject obj, jfieldID fieldID) { attach_thread(); - return (*jniEnv)->GetIntField(jniEnv, obj, fieldID); + jint _result = (*jniEnv)->GetIntField(jniEnv, obj, fieldID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.i = _result}, .exception = NULL}; } -jlong globalEnv_GetLongField(jobject obj, jfieldID fieldID) { +JniResult globalEnv_GetLongField(jobject obj, jfieldID fieldID) { attach_thread(); - return (*jniEnv)->GetLongField(jniEnv, obj, fieldID); + jlong _result = (*jniEnv)->GetLongField(jniEnv, obj, fieldID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.j = _result}, .exception = NULL}; } -jfloat globalEnv_GetFloatField(jobject obj, jfieldID fieldID) { +JniResult globalEnv_GetFloatField(jobject obj, jfieldID fieldID) { attach_thread(); - return (*jniEnv)->GetFloatField(jniEnv, obj, fieldID); + jfloat _result = (*jniEnv)->GetFloatField(jniEnv, obj, fieldID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.f = _result}, .exception = NULL}; } -jdouble globalEnv_GetDoubleField(jobject obj, jfieldID fieldID) { +JniResult globalEnv_GetDoubleField(jobject obj, jfieldID fieldID) { attach_thread(); - return (*jniEnv)->GetDoubleField(jniEnv, obj, fieldID); + jdouble _result = (*jniEnv)->GetDoubleField(jniEnv, obj, fieldID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.d = _result}, .exception = NULL}; } -void globalEnv_SetObjectField(jobject obj, jfieldID fieldID, jobject val) { +jthrowable globalEnv_SetObjectField(jobject obj, + jfieldID fieldID, + jobject val) { attach_thread(); (*jniEnv)->SetObjectField(jniEnv, obj, fieldID, val); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_SetBooleanField(jobject obj, jfieldID fieldID, jboolean val) { +jthrowable globalEnv_SetBooleanField(jobject obj, + jfieldID fieldID, + jboolean val) { attach_thread(); (*jniEnv)->SetBooleanField(jniEnv, obj, fieldID, val); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_SetByteField(jobject obj, jfieldID fieldID, jbyte val) { +jthrowable globalEnv_SetByteField(jobject obj, jfieldID fieldID, jbyte val) { attach_thread(); (*jniEnv)->SetByteField(jniEnv, obj, fieldID, val); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_SetCharField(jobject obj, jfieldID fieldID, jchar val) { +jthrowable globalEnv_SetCharField(jobject obj, jfieldID fieldID, jchar val) { attach_thread(); (*jniEnv)->SetCharField(jniEnv, obj, fieldID, val); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_SetShortField(jobject obj, jfieldID fieldID, jshort val) { +jthrowable globalEnv_SetShortField(jobject obj, jfieldID fieldID, jshort val) { attach_thread(); (*jniEnv)->SetShortField(jniEnv, obj, fieldID, val); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_SetIntField(jobject obj, jfieldID fieldID, jint val) { +jthrowable globalEnv_SetIntField(jobject obj, jfieldID fieldID, jint val) { attach_thread(); (*jniEnv)->SetIntField(jniEnv, obj, fieldID, val); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_SetLongField(jobject obj, jfieldID fieldID, jlong val) { +jthrowable globalEnv_SetLongField(jobject obj, jfieldID fieldID, jlong val) { attach_thread(); (*jniEnv)->SetLongField(jniEnv, obj, fieldID, val); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_SetFloatField(jobject obj, jfieldID fieldID, jfloat val) { +jthrowable globalEnv_SetFloatField(jobject obj, jfieldID fieldID, jfloat val) { attach_thread(); (*jniEnv)->SetFloatField(jniEnv, obj, fieldID, val); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_SetDoubleField(jobject obj, jfieldID fieldID, jdouble val) { +jthrowable globalEnv_SetDoubleField(jobject obj, + jfieldID fieldID, + jdouble val) { attach_thread(); (*jniEnv)->SetDoubleField(jniEnv, obj, fieldID, val); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -jmethodID globalEnv_GetStaticMethodID(jclass clazz, - const char* name, - const char* sig) { +JniPointerResult globalEnv_GetStaticMethodID(jclass clazz, + char* name, + char* sig) { attach_thread(); - return (*jniEnv)->GetStaticMethodID(jniEnv, clazz, name, sig); + jmethodID _result = (*jniEnv)->GetStaticMethodID(jniEnv, clazz, name, sig); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniPointerResult){.value = NULL, .exception = _exception}; + } + return (JniPointerResult){.value = _result, .exception = NULL}; } -jobject globalEnv_CallStaticObjectMethod(jclass arg1, jmethodID arg2) { +JniResult globalEnv_CallStaticObjectMethod(jclass clazz, jmethodID methodID) { attach_thread(); - return to_global_ref((*jniEnv)->CallStaticObjectMethod(jniEnv, arg1, arg2)); + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, clazz, methodID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + _result = to_global_ref(_result); + return (JniResult){.value = {.l = _result}, .exception = NULL}; } -jobject globalEnv_CallStaticObjectMethodA(jclass clazz, - jmethodID methodID, - const jvalue* args) { +JniResult globalEnv_CallStaticObjectMethodA(jclass clazz, + jmethodID methodID, + jvalue* args) { attach_thread(); - return to_global_ref( - (*jniEnv)->CallStaticObjectMethodA(jniEnv, clazz, methodID, args)); + jobject _result = + (*jniEnv)->CallStaticObjectMethodA(jniEnv, clazz, methodID, args); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + _result = to_global_ref(_result); + return (JniResult){.value = {.l = _result}, .exception = NULL}; } -jboolean globalEnv_CallStaticBooleanMethod(jclass arg1, jmethodID arg2) { +JniResult globalEnv_CallStaticBooleanMethod(jclass clazz, jmethodID methodID) { attach_thread(); - return (*jniEnv)->CallStaticBooleanMethod(jniEnv, arg1, arg2); + jboolean _result = + (*jniEnv)->CallStaticBooleanMethod(jniEnv, clazz, methodID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.z = _result}, .exception = NULL}; } -jboolean globalEnv_CallStaticBooleanMethodA(jclass clazz, - jmethodID methodID, - const jvalue* args) { +JniResult globalEnv_CallStaticBooleanMethodA(jclass clazz, + jmethodID methodID, + jvalue* args) { attach_thread(); - return (*jniEnv)->CallStaticBooleanMethodA(jniEnv, clazz, methodID, args); + jboolean _result = + (*jniEnv)->CallStaticBooleanMethodA(jniEnv, clazz, methodID, args); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.z = _result}, .exception = NULL}; } -jbyte globalEnv_CallStaticByteMethod(jclass arg1, jmethodID arg2) { +JniResult globalEnv_CallStaticByteMethod(jclass clazz, jmethodID methodID) { attach_thread(); - return (*jniEnv)->CallStaticByteMethod(jniEnv, arg1, arg2); + jbyte _result = (*jniEnv)->CallStaticByteMethod(jniEnv, clazz, methodID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.b = _result}, .exception = NULL}; } -jbyte globalEnv_CallStaticByteMethodA(jclass clazz, - jmethodID methodID, - const jvalue* args) { +JniResult globalEnv_CallStaticByteMethodA(jclass clazz, + jmethodID methodID, + jvalue* args) { attach_thread(); - return (*jniEnv)->CallStaticByteMethodA(jniEnv, clazz, methodID, args); + jbyte _result = + (*jniEnv)->CallStaticByteMethodA(jniEnv, clazz, methodID, args); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.b = _result}, .exception = NULL}; } -jchar globalEnv_CallStaticCharMethod(jclass arg1, jmethodID arg2) { +JniResult globalEnv_CallStaticCharMethod(jclass clazz, jmethodID methodID) { attach_thread(); - return (*jniEnv)->CallStaticCharMethod(jniEnv, arg1, arg2); + jchar _result = (*jniEnv)->CallStaticCharMethod(jniEnv, clazz, methodID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.c = _result}, .exception = NULL}; } -jchar globalEnv_CallStaticCharMethodA(jclass clazz, - jmethodID methodID, - const jvalue* args) { +JniResult globalEnv_CallStaticCharMethodA(jclass clazz, + jmethodID methodID, + jvalue* args) { attach_thread(); - return (*jniEnv)->CallStaticCharMethodA(jniEnv, clazz, methodID, args); + jchar _result = + (*jniEnv)->CallStaticCharMethodA(jniEnv, clazz, methodID, args); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.c = _result}, .exception = NULL}; } -jshort globalEnv_CallStaticShortMethod(jclass arg1, jmethodID arg2) { +JniResult globalEnv_CallStaticShortMethod(jclass clazz, jmethodID methodID) { attach_thread(); - return (*jniEnv)->CallStaticShortMethod(jniEnv, arg1, arg2); + jshort _result = (*jniEnv)->CallStaticShortMethod(jniEnv, clazz, methodID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.s = _result}, .exception = NULL}; } -jshort globalEnv_CallStaticShortMethodA(jclass clazz, - jmethodID methodID, - const jvalue* args) { +JniResult globalEnv_CallStaticShortMethodA(jclass clazz, + jmethodID methodID, + jvalue* args) { attach_thread(); - return (*jniEnv)->CallStaticShortMethodA(jniEnv, clazz, methodID, args); + jshort _result = + (*jniEnv)->CallStaticShortMethodA(jniEnv, clazz, methodID, args); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.s = _result}, .exception = NULL}; } -jint globalEnv_CallStaticIntMethod(jclass arg1, jmethodID arg2) { +JniResult globalEnv_CallStaticIntMethod(jclass clazz, jmethodID methodID) { attach_thread(); - return (*jniEnv)->CallStaticIntMethod(jniEnv, arg1, arg2); + jint _result = (*jniEnv)->CallStaticIntMethod(jniEnv, clazz, methodID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.i = _result}, .exception = NULL}; } -jint globalEnv_CallStaticIntMethodA(jclass clazz, - jmethodID methodID, - const jvalue* args) { +JniResult globalEnv_CallStaticIntMethodA(jclass clazz, + jmethodID methodID, + jvalue* args) { attach_thread(); - return (*jniEnv)->CallStaticIntMethodA(jniEnv, clazz, methodID, args); + jint _result = (*jniEnv)->CallStaticIntMethodA(jniEnv, clazz, methodID, args); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.i = _result}, .exception = NULL}; } -jlong globalEnv_CallStaticLongMethod(jclass arg1, jmethodID arg2) { +JniResult globalEnv_CallStaticLongMethod(jclass clazz, jmethodID methodID) { attach_thread(); - return (*jniEnv)->CallStaticLongMethod(jniEnv, arg1, arg2); + jlong _result = (*jniEnv)->CallStaticLongMethod(jniEnv, clazz, methodID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.j = _result}, .exception = NULL}; } -jlong globalEnv_CallStaticLongMethodA(jclass clazz, - jmethodID methodID, - const jvalue* args) { +JniResult globalEnv_CallStaticLongMethodA(jclass clazz, + jmethodID methodID, + jvalue* args) { attach_thread(); - return (*jniEnv)->CallStaticLongMethodA(jniEnv, clazz, methodID, args); + jlong _result = + (*jniEnv)->CallStaticLongMethodA(jniEnv, clazz, methodID, args); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.j = _result}, .exception = NULL}; } -jfloat globalEnv_CallStaticFloatMethod(jclass arg1, jmethodID arg2) { +JniResult globalEnv_CallStaticFloatMethod(jclass clazz, jmethodID methodID) { attach_thread(); - return (*jniEnv)->CallStaticFloatMethod(jniEnv, arg1, arg2); + jfloat _result = (*jniEnv)->CallStaticFloatMethod(jniEnv, clazz, methodID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.f = _result}, .exception = NULL}; } -jfloat globalEnv_CallStaticFloatMethodA(jclass clazz, - jmethodID methodID, - const jvalue* args) { +JniResult globalEnv_CallStaticFloatMethodA(jclass clazz, + jmethodID methodID, + jvalue* args) { attach_thread(); - return (*jniEnv)->CallStaticFloatMethodA(jniEnv, clazz, methodID, args); + jfloat _result = + (*jniEnv)->CallStaticFloatMethodA(jniEnv, clazz, methodID, args); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.f = _result}, .exception = NULL}; } -jdouble globalEnv_CallStaticDoubleMethod(jclass arg1, jmethodID arg2) { +JniResult globalEnv_CallStaticDoubleMethod(jclass clazz, jmethodID methodID) { attach_thread(); - return (*jniEnv)->CallStaticDoubleMethod(jniEnv, arg1, arg2); + jdouble _result = (*jniEnv)->CallStaticDoubleMethod(jniEnv, clazz, methodID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.d = _result}, .exception = NULL}; } -jdouble globalEnv_CallStaticDoubleMethodA(jclass clazz, - jmethodID methodID, - const jvalue* args) { +JniResult globalEnv_CallStaticDoubleMethodA(jclass clazz, + jmethodID methodID, + jvalue* args) { attach_thread(); - return (*jniEnv)->CallStaticDoubleMethodA(jniEnv, clazz, methodID, args); + jdouble _result = + (*jniEnv)->CallStaticDoubleMethodA(jniEnv, clazz, methodID, args); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.d = _result}, .exception = NULL}; } -void globalEnv_CallStaticVoidMethod(jclass arg1, jmethodID arg2) { +jthrowable globalEnv_CallStaticVoidMethod(jclass clazz, jmethodID methodID) { attach_thread(); - (*jniEnv)->CallStaticVoidMethod(jniEnv, arg1, arg2); + (*jniEnv)->CallStaticVoidMethod(jniEnv, clazz, methodID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_CallStaticVoidMethodA(jclass clazz, - jmethodID methodID, - const jvalue* args) { +jthrowable globalEnv_CallStaticVoidMethodA(jclass clazz, + jmethodID methodID, + jvalue* args) { attach_thread(); (*jniEnv)->CallStaticVoidMethodA(jniEnv, clazz, methodID, args); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -jfieldID globalEnv_GetStaticFieldID(jclass clazz, - const char* name, - const char* sig) { +JniPointerResult globalEnv_GetStaticFieldID(jclass clazz, + char* name, + char* sig) { attach_thread(); - return (*jniEnv)->GetStaticFieldID(jniEnv, clazz, name, sig); + jfieldID _result = (*jniEnv)->GetStaticFieldID(jniEnv, clazz, name, sig); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniPointerResult){.value = NULL, .exception = _exception}; + } + return (JniPointerResult){.value = _result, .exception = NULL}; } -jobject globalEnv_GetStaticObjectField(jclass clazz, jfieldID fieldID) { +JniResult globalEnv_GetStaticObjectField(jclass clazz, jfieldID fieldID) { attach_thread(); - return to_global_ref((*jniEnv)->GetStaticObjectField(jniEnv, clazz, fieldID)); + jobject _result = (*jniEnv)->GetStaticObjectField(jniEnv, clazz, fieldID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + _result = to_global_ref(_result); + return (JniResult){.value = {.l = _result}, .exception = NULL}; } -jboolean globalEnv_GetStaticBooleanField(jclass clazz, jfieldID fieldID) { +JniResult globalEnv_GetStaticBooleanField(jclass clazz, jfieldID fieldID) { attach_thread(); - return (*jniEnv)->GetStaticBooleanField(jniEnv, clazz, fieldID); + jboolean _result = (*jniEnv)->GetStaticBooleanField(jniEnv, clazz, fieldID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.z = _result}, .exception = NULL}; } -jbyte globalEnv_GetStaticByteField(jclass clazz, jfieldID fieldID) { +JniResult globalEnv_GetStaticByteField(jclass clazz, jfieldID fieldID) { attach_thread(); - return (*jniEnv)->GetStaticByteField(jniEnv, clazz, fieldID); + jbyte _result = (*jniEnv)->GetStaticByteField(jniEnv, clazz, fieldID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.b = _result}, .exception = NULL}; } -jchar globalEnv_GetStaticCharField(jclass clazz, jfieldID fieldID) { +JniResult globalEnv_GetStaticCharField(jclass clazz, jfieldID fieldID) { attach_thread(); - return (*jniEnv)->GetStaticCharField(jniEnv, clazz, fieldID); + jchar _result = (*jniEnv)->GetStaticCharField(jniEnv, clazz, fieldID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.c = _result}, .exception = NULL}; } -jshort globalEnv_GetStaticShortField(jclass clazz, jfieldID fieldID) { +JniResult globalEnv_GetStaticShortField(jclass clazz, jfieldID fieldID) { attach_thread(); - return (*jniEnv)->GetStaticShortField(jniEnv, clazz, fieldID); + jshort _result = (*jniEnv)->GetStaticShortField(jniEnv, clazz, fieldID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.s = _result}, .exception = NULL}; } -jint globalEnv_GetStaticIntField(jclass clazz, jfieldID fieldID) { +JniResult globalEnv_GetStaticIntField(jclass clazz, jfieldID fieldID) { attach_thread(); - return (*jniEnv)->GetStaticIntField(jniEnv, clazz, fieldID); + jint _result = (*jniEnv)->GetStaticIntField(jniEnv, clazz, fieldID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.i = _result}, .exception = NULL}; } -jlong globalEnv_GetStaticLongField(jclass clazz, jfieldID fieldID) { +JniResult globalEnv_GetStaticLongField(jclass clazz, jfieldID fieldID) { attach_thread(); - return (*jniEnv)->GetStaticLongField(jniEnv, clazz, fieldID); + jlong _result = (*jniEnv)->GetStaticLongField(jniEnv, clazz, fieldID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.j = _result}, .exception = NULL}; } -jfloat globalEnv_GetStaticFloatField(jclass clazz, jfieldID fieldID) { +JniResult globalEnv_GetStaticFloatField(jclass clazz, jfieldID fieldID) { attach_thread(); - return (*jniEnv)->GetStaticFloatField(jniEnv, clazz, fieldID); + jfloat _result = (*jniEnv)->GetStaticFloatField(jniEnv, clazz, fieldID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.f = _result}, .exception = NULL}; } -jdouble globalEnv_GetStaticDoubleField(jclass clazz, jfieldID fieldID) { +JniResult globalEnv_GetStaticDoubleField(jclass clazz, jfieldID fieldID) { attach_thread(); - return (*jniEnv)->GetStaticDoubleField(jniEnv, clazz, fieldID); + jdouble _result = (*jniEnv)->GetStaticDoubleField(jniEnv, clazz, fieldID); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.d = _result}, .exception = NULL}; } -void globalEnv_SetStaticObjectField(jclass clazz, - jfieldID fieldID, - jobject val) { +jthrowable globalEnv_SetStaticObjectField(jclass clazz, + jfieldID fieldID, + jobject val) { attach_thread(); (*jniEnv)->SetStaticObjectField(jniEnv, clazz, fieldID, val); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_SetStaticBooleanField(jclass clazz, - jfieldID fieldID, - jboolean val) { +jthrowable globalEnv_SetStaticBooleanField(jclass clazz, + jfieldID fieldID, + jboolean val) { attach_thread(); (*jniEnv)->SetStaticBooleanField(jniEnv, clazz, fieldID, val); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_SetStaticByteField(jclass clazz, jfieldID fieldID, jbyte val) { +jthrowable globalEnv_SetStaticByteField(jclass clazz, + jfieldID fieldID, + jbyte val) { attach_thread(); (*jniEnv)->SetStaticByteField(jniEnv, clazz, fieldID, val); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_SetStaticCharField(jclass clazz, jfieldID fieldID, jchar val) { +jthrowable globalEnv_SetStaticCharField(jclass clazz, + jfieldID fieldID, + jchar val) { attach_thread(); (*jniEnv)->SetStaticCharField(jniEnv, clazz, fieldID, val); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_SetStaticShortField(jclass clazz, jfieldID fieldID, jshort val) { +jthrowable globalEnv_SetStaticShortField(jclass clazz, + jfieldID fieldID, + jshort val) { attach_thread(); (*jniEnv)->SetStaticShortField(jniEnv, clazz, fieldID, val); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_SetStaticIntField(jclass clazz, jfieldID fieldID, jint val) { +jthrowable globalEnv_SetStaticIntField(jclass clazz, + jfieldID fieldID, + jint val) { attach_thread(); (*jniEnv)->SetStaticIntField(jniEnv, clazz, fieldID, val); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_SetStaticLongField(jclass clazz, jfieldID fieldID, jlong val) { +jthrowable globalEnv_SetStaticLongField(jclass clazz, + jfieldID fieldID, + jlong val) { attach_thread(); (*jniEnv)->SetStaticLongField(jniEnv, clazz, fieldID, val); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_SetStaticFloatField(jclass clazz, jfieldID fieldID, jfloat val) { +jthrowable globalEnv_SetStaticFloatField(jclass clazz, + jfieldID fieldID, + jfloat val) { attach_thread(); (*jniEnv)->SetStaticFloatField(jniEnv, clazz, fieldID, val); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_SetStaticDoubleField(jclass clazz, - jfieldID fieldID, - jdouble val) { +jthrowable globalEnv_SetStaticDoubleField(jclass clazz, + jfieldID fieldID, + jdouble val) { attach_thread(); (*jniEnv)->SetStaticDoubleField(jniEnv, clazz, fieldID, val); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -jstring globalEnv_NewString(const jchar* unicodeChars, jsize len) { +JniResult globalEnv_NewString(jchar* unicodeChars, jsize len) { attach_thread(); - return to_global_ref((*jniEnv)->NewString(jniEnv, unicodeChars, len)); + jstring _result = (*jniEnv)->NewString(jniEnv, unicodeChars, len); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + _result = to_global_ref(_result); + return (JniResult){.value = {.l = _result}, .exception = NULL}; } -jsize globalEnv_GetStringLength(jstring string) { +JniResult globalEnv_GetStringLength(jstring string) { attach_thread(); - return (*jniEnv)->GetStringLength(jniEnv, string); + jsize _result = (*jniEnv)->GetStringLength(jniEnv, string); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.i = _result}, .exception = NULL}; } -const jchar* globalEnv_GetStringChars(jstring string, jboolean* isCopy) { +JniPointerResult globalEnv_GetStringChars(jstring string, jboolean* isCopy) { attach_thread(); - return (*jniEnv)->GetStringChars(jniEnv, string, isCopy); + const jchar* _result = (*jniEnv)->GetStringChars(jniEnv, string, isCopy); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniPointerResult){.value = NULL, .exception = _exception}; + } + return (JniPointerResult){.value = _result, .exception = NULL}; } -void globalEnv_ReleaseStringChars(jstring string, const jchar* isCopy) { +jthrowable globalEnv_ReleaseStringChars(jstring string, jchar* isCopy) { attach_thread(); (*jniEnv)->ReleaseStringChars(jniEnv, string, isCopy); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -jstring globalEnv_NewStringUTF(const char* bytes) { +JniResult globalEnv_NewStringUTF(char* bytes) { attach_thread(); - return to_global_ref((*jniEnv)->NewStringUTF(jniEnv, bytes)); + jstring _result = (*jniEnv)->NewStringUTF(jniEnv, bytes); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + _result = to_global_ref(_result); + return (JniResult){.value = {.l = _result}, .exception = NULL}; } -jsize globalEnv_GetStringUTFLength(jstring string) { +JniResult globalEnv_GetStringUTFLength(jstring string) { attach_thread(); - return (*jniEnv)->GetStringUTFLength(jniEnv, string); + jsize _result = (*jniEnv)->GetStringUTFLength(jniEnv, string); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.i = _result}, .exception = NULL}; } -const char* globalEnv_GetStringUTFChars(jstring string, jboolean* isCopy) { +JniPointerResult globalEnv_GetStringUTFChars(jstring string, jboolean* isCopy) { attach_thread(); - return (*jniEnv)->GetStringUTFChars(jniEnv, string, isCopy); + const char* _result = (*jniEnv)->GetStringUTFChars(jniEnv, string, isCopy); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniPointerResult){.value = NULL, .exception = _exception}; + } + return (JniPointerResult){.value = _result, .exception = NULL}; } -void globalEnv_ReleaseStringUTFChars(jstring string, const char* utf) { +jthrowable globalEnv_ReleaseStringUTFChars(jstring string, char* utf) { attach_thread(); (*jniEnv)->ReleaseStringUTFChars(jniEnv, string, utf); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -jsize globalEnv_GetArrayLength(jarray array) { +JniResult globalEnv_GetArrayLength(jarray array) { attach_thread(); - return (*jniEnv)->GetArrayLength(jniEnv, array); + jsize _result = (*jniEnv)->GetArrayLength(jniEnv, array); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.i = _result}, .exception = NULL}; } -jobjectArray globalEnv_NewObjectArray(jsize length, - jclass elementClass, - jobject initialElement) { +JniResult globalEnv_NewObjectArray(jsize length, + jclass elementClass, + jobject initialElement) { attach_thread(); - return to_global_ref( - (*jniEnv)->NewObjectArray(jniEnv, length, elementClass, initialElement)); + jobjectArray _result = + (*jniEnv)->NewObjectArray(jniEnv, length, elementClass, initialElement); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + _result = to_global_ref(_result); + return (JniResult){.value = {.l = _result}, .exception = NULL}; } -jobject globalEnv_GetObjectArrayElement(jobjectArray array, jsize index) { +JniResult globalEnv_GetObjectArrayElement(jobjectArray array, jsize index) { attach_thread(); - return to_global_ref((*jniEnv)->GetObjectArrayElement(jniEnv, array, index)); + jobject _result = (*jniEnv)->GetObjectArrayElement(jniEnv, array, index); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + _result = to_global_ref(_result); + return (JniResult){.value = {.l = _result}, .exception = NULL}; } -void globalEnv_SetObjectArrayElement(jobjectArray array, - jsize index, - jobject val) { +jthrowable globalEnv_SetObjectArrayElement(jobjectArray array, + jsize index, + jobject val) { attach_thread(); (*jniEnv)->SetObjectArrayElement(jniEnv, array, index, val); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -jbooleanArray globalEnv_NewBooleanArray(jsize length) { +JniResult globalEnv_NewBooleanArray(jsize length) { attach_thread(); - return to_global_ref((*jniEnv)->NewBooleanArray(jniEnv, length)); + jbooleanArray _result = (*jniEnv)->NewBooleanArray(jniEnv, length); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + _result = to_global_ref(_result); + return (JniResult){.value = {.l = _result}, .exception = NULL}; } -jbyteArray globalEnv_NewByteArray(jsize length) { +JniResult globalEnv_NewByteArray(jsize length) { attach_thread(); - return to_global_ref((*jniEnv)->NewByteArray(jniEnv, length)); + jbyteArray _result = (*jniEnv)->NewByteArray(jniEnv, length); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + _result = to_global_ref(_result); + return (JniResult){.value = {.l = _result}, .exception = NULL}; } -jcharArray globalEnv_NewCharArray(jsize length) { +JniResult globalEnv_NewCharArray(jsize length) { attach_thread(); - return to_global_ref((*jniEnv)->NewCharArray(jniEnv, length)); + jcharArray _result = (*jniEnv)->NewCharArray(jniEnv, length); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + _result = to_global_ref(_result); + return (JniResult){.value = {.l = _result}, .exception = NULL}; } -jshortArray globalEnv_NewShortArray(jsize length) { +JniResult globalEnv_NewShortArray(jsize length) { attach_thread(); - return to_global_ref((*jniEnv)->NewShortArray(jniEnv, length)); + jshortArray _result = (*jniEnv)->NewShortArray(jniEnv, length); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + _result = to_global_ref(_result); + return (JniResult){.value = {.l = _result}, .exception = NULL}; } -jintArray globalEnv_NewIntArray(jsize length) { +JniResult globalEnv_NewIntArray(jsize length) { attach_thread(); - return to_global_ref((*jniEnv)->NewIntArray(jniEnv, length)); + jintArray _result = (*jniEnv)->NewIntArray(jniEnv, length); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + _result = to_global_ref(_result); + return (JniResult){.value = {.l = _result}, .exception = NULL}; } -jlongArray globalEnv_NewLongArray(jsize length) { +JniResult globalEnv_NewLongArray(jsize length) { attach_thread(); - return to_global_ref((*jniEnv)->NewLongArray(jniEnv, length)); + jlongArray _result = (*jniEnv)->NewLongArray(jniEnv, length); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + _result = to_global_ref(_result); + return (JniResult){.value = {.l = _result}, .exception = NULL}; } -jfloatArray globalEnv_NewFloatArray(jsize length) { +JniResult globalEnv_NewFloatArray(jsize length) { attach_thread(); - return to_global_ref((*jniEnv)->NewFloatArray(jniEnv, length)); + jfloatArray _result = (*jniEnv)->NewFloatArray(jniEnv, length); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + _result = to_global_ref(_result); + return (JniResult){.value = {.l = _result}, .exception = NULL}; } -jdoubleArray globalEnv_NewDoubleArray(jsize length) { +JniResult globalEnv_NewDoubleArray(jsize length) { attach_thread(); - return to_global_ref((*jniEnv)->NewDoubleArray(jniEnv, length)); + jdoubleArray _result = (*jniEnv)->NewDoubleArray(jniEnv, length); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + _result = to_global_ref(_result); + return (JniResult){.value = {.l = _result}, .exception = NULL}; } -jboolean* globalEnv_GetBooleanArrayElements(jbooleanArray array, - jboolean* isCopy) { +JniPointerResult globalEnv_GetBooleanArrayElements(jbooleanArray array, + jboolean* isCopy) { attach_thread(); - return (*jniEnv)->GetBooleanArrayElements(jniEnv, array, isCopy); + jboolean* _result = (*jniEnv)->GetBooleanArrayElements(jniEnv, array, isCopy); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniPointerResult){.value = NULL, .exception = _exception}; + } + return (JniPointerResult){.value = _result, .exception = NULL}; } -jbyte* globalEnv_GetByteArrayElements(jbyteArray array, jboolean* isCopy) { +JniPointerResult globalEnv_GetByteArrayElements(jbyteArray array, + jboolean* isCopy) { attach_thread(); - return (*jniEnv)->GetByteArrayElements(jniEnv, array, isCopy); + jbyte* _result = (*jniEnv)->GetByteArrayElements(jniEnv, array, isCopy); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniPointerResult){.value = NULL, .exception = _exception}; + } + return (JniPointerResult){.value = _result, .exception = NULL}; } -jchar* globalEnv_GetCharArrayElements(jcharArray array, jboolean* isCopy) { +JniPointerResult globalEnv_GetCharArrayElements(jcharArray array, + jboolean* isCopy) { attach_thread(); - return (*jniEnv)->GetCharArrayElements(jniEnv, array, isCopy); + jchar* _result = (*jniEnv)->GetCharArrayElements(jniEnv, array, isCopy); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniPointerResult){.value = NULL, .exception = _exception}; + } + return (JniPointerResult){.value = _result, .exception = NULL}; } -jshort* globalEnv_GetShortArrayElements(jshortArray array, jboolean* isCopy) { +JniPointerResult globalEnv_GetShortArrayElements(jshortArray array, + jboolean* isCopy) { attach_thread(); - return (*jniEnv)->GetShortArrayElements(jniEnv, array, isCopy); + jshort* _result = (*jniEnv)->GetShortArrayElements(jniEnv, array, isCopy); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniPointerResult){.value = NULL, .exception = _exception}; + } + return (JniPointerResult){.value = _result, .exception = NULL}; } -jint* globalEnv_GetIntArrayElements(jintArray array, jboolean* isCopy) { +JniPointerResult globalEnv_GetIntArrayElements(jintArray array, + jboolean* isCopy) { attach_thread(); - return (*jniEnv)->GetIntArrayElements(jniEnv, array, isCopy); + jint* _result = (*jniEnv)->GetIntArrayElements(jniEnv, array, isCopy); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniPointerResult){.value = NULL, .exception = _exception}; + } + return (JniPointerResult){.value = _result, .exception = NULL}; } -jlong* globalEnv_GetLongArrayElements(jlongArray array, jboolean* isCopy) { +JniPointerResult globalEnv_GetLongArrayElements(jlongArray array, + jboolean* isCopy) { attach_thread(); - return (*jniEnv)->GetLongArrayElements(jniEnv, array, isCopy); + jlong* _result = (*jniEnv)->GetLongArrayElements(jniEnv, array, isCopy); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniPointerResult){.value = NULL, .exception = _exception}; + } + return (JniPointerResult){.value = _result, .exception = NULL}; } -jfloat* globalEnv_GetFloatArrayElements(jfloatArray array, jboolean* isCopy) { +JniPointerResult globalEnv_GetFloatArrayElements(jfloatArray array, + jboolean* isCopy) { attach_thread(); - return (*jniEnv)->GetFloatArrayElements(jniEnv, array, isCopy); + jfloat* _result = (*jniEnv)->GetFloatArrayElements(jniEnv, array, isCopy); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniPointerResult){.value = NULL, .exception = _exception}; + } + return (JniPointerResult){.value = _result, .exception = NULL}; } -jdouble* globalEnv_GetDoubleArrayElements(jdoubleArray array, - jboolean* isCopy) { +JniPointerResult globalEnv_GetDoubleArrayElements(jdoubleArray array, + jboolean* isCopy) { attach_thread(); - return (*jniEnv)->GetDoubleArrayElements(jniEnv, array, isCopy); + jdouble* _result = (*jniEnv)->GetDoubleArrayElements(jniEnv, array, isCopy); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniPointerResult){.value = NULL, .exception = _exception}; + } + return (JniPointerResult){.value = _result, .exception = NULL}; } -void globalEnv_ReleaseBooleanArrayElements(jbooleanArray array, - jboolean* elems, - jint mode) { +jthrowable globalEnv_ReleaseBooleanArrayElements(jbooleanArray array, + jboolean* elems, + jint mode) { attach_thread(); (*jniEnv)->ReleaseBooleanArrayElements(jniEnv, array, elems, mode); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_ReleaseByteArrayElements(jbyteArray array, - jbyte* elems, - jint mode) { +jthrowable globalEnv_ReleaseByteArrayElements(jbyteArray array, + jbyte* elems, + jint mode) { attach_thread(); (*jniEnv)->ReleaseByteArrayElements(jniEnv, array, elems, mode); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_ReleaseCharArrayElements(jcharArray array, - jchar* elems, - jint mode) { +jthrowable globalEnv_ReleaseCharArrayElements(jcharArray array, + jchar* elems, + jint mode) { attach_thread(); (*jniEnv)->ReleaseCharArrayElements(jniEnv, array, elems, mode); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_ReleaseShortArrayElements(jshortArray array, - jshort* elems, - jint mode) { +jthrowable globalEnv_ReleaseShortArrayElements(jshortArray array, + jshort* elems, + jint mode) { attach_thread(); (*jniEnv)->ReleaseShortArrayElements(jniEnv, array, elems, mode); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_ReleaseIntArrayElements(jintArray array, - jint* elems, - jint mode) { +jthrowable globalEnv_ReleaseIntArrayElements(jintArray array, + jint* elems, + jint mode) { attach_thread(); (*jniEnv)->ReleaseIntArrayElements(jniEnv, array, elems, mode); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_ReleaseLongArrayElements(jlongArray array, - jlong* elems, - jint mode) { +jthrowable globalEnv_ReleaseLongArrayElements(jlongArray array, + jlong* elems, + jint mode) { attach_thread(); (*jniEnv)->ReleaseLongArrayElements(jniEnv, array, elems, mode); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_ReleaseFloatArrayElements(jfloatArray array, - jfloat* elems, - jint mode) { +jthrowable globalEnv_ReleaseFloatArrayElements(jfloatArray array, + jfloat* elems, + jint mode) { attach_thread(); (*jniEnv)->ReleaseFloatArrayElements(jniEnv, array, elems, mode); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_ReleaseDoubleArrayElements(jdoubleArray array, - jdouble* elems, - jint mode) { +jthrowable globalEnv_ReleaseDoubleArrayElements(jdoubleArray array, + jdouble* elems, + jint mode) { attach_thread(); (*jniEnv)->ReleaseDoubleArrayElements(jniEnv, array, elems, mode); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_GetBooleanArrayRegion(jbooleanArray array, - jsize start, - jsize len, - jboolean* buf) { +jthrowable globalEnv_GetBooleanArrayRegion(jbooleanArray array, + jsize start, + jsize len, + jboolean* buf) { attach_thread(); (*jniEnv)->GetBooleanArrayRegion(jniEnv, array, start, len, buf); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_GetByteArrayRegion(jbyteArray array, - jsize start, - jsize len, - jbyte* buf) { +jthrowable globalEnv_GetByteArrayRegion(jbyteArray array, + jsize start, + jsize len, + jbyte* buf) { attach_thread(); (*jniEnv)->GetByteArrayRegion(jniEnv, array, start, len, buf); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_GetCharArrayRegion(jcharArray array, - jsize start, - jsize len, - jchar* buf) { +jthrowable globalEnv_GetCharArrayRegion(jcharArray array, + jsize start, + jsize len, + jchar* buf) { attach_thread(); (*jniEnv)->GetCharArrayRegion(jniEnv, array, start, len, buf); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_GetShortArrayRegion(jshortArray array, - jsize start, - jsize len, - jshort* buf) { +jthrowable globalEnv_GetShortArrayRegion(jshortArray array, + jsize start, + jsize len, + jshort* buf) { attach_thread(); (*jniEnv)->GetShortArrayRegion(jniEnv, array, start, len, buf); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_GetIntArrayRegion(jintArray array, - jsize start, - jsize len, - jint* buf) { +jthrowable globalEnv_GetIntArrayRegion(jintArray array, + jsize start, + jsize len, + jint* buf) { attach_thread(); (*jniEnv)->GetIntArrayRegion(jniEnv, array, start, len, buf); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_GetLongArrayRegion(jlongArray array, - jsize start, - jsize len, - jlong* buf) { +jthrowable globalEnv_GetLongArrayRegion(jlongArray array, + jsize start, + jsize len, + jlong* buf) { attach_thread(); (*jniEnv)->GetLongArrayRegion(jniEnv, array, start, len, buf); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_GetFloatArrayRegion(jfloatArray array, - jsize start, - jsize len, - jfloat* buf) { +jthrowable globalEnv_GetFloatArrayRegion(jfloatArray array, + jsize start, + jsize len, + jfloat* buf) { attach_thread(); (*jniEnv)->GetFloatArrayRegion(jniEnv, array, start, len, buf); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_GetDoubleArrayRegion(jdoubleArray array, - jsize start, - jsize len, - jdouble* buf) { +jthrowable globalEnv_GetDoubleArrayRegion(jdoubleArray array, + jsize start, + jsize len, + jdouble* buf) { attach_thread(); (*jniEnv)->GetDoubleArrayRegion(jniEnv, array, start, len, buf); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_SetBooleanArrayRegion(jbooleanArray array, - jsize start, - jsize len, - const jboolean* buf) { +jthrowable globalEnv_SetBooleanArrayRegion(jbooleanArray array, + jsize start, + jsize len, + jboolean* buf) { attach_thread(); (*jniEnv)->SetBooleanArrayRegion(jniEnv, array, start, len, buf); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_SetByteArrayRegion(jbyteArray array, - jsize start, - jsize len, - const jbyte* buf) { +jthrowable globalEnv_SetByteArrayRegion(jbyteArray array, + jsize start, + jsize len, + jbyte* buf) { attach_thread(); (*jniEnv)->SetByteArrayRegion(jniEnv, array, start, len, buf); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_SetCharArrayRegion(jcharArray array, - jsize start, - jsize len, - const jchar* buf) { +jthrowable globalEnv_SetCharArrayRegion(jcharArray array, + jsize start, + jsize len, + jchar* buf) { attach_thread(); (*jniEnv)->SetCharArrayRegion(jniEnv, array, start, len, buf); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_SetShortArrayRegion(jshortArray array, - jsize start, - jsize len, - const jshort* buf) { +jthrowable globalEnv_SetShortArrayRegion(jshortArray array, + jsize start, + jsize len, + jshort* buf) { attach_thread(); (*jniEnv)->SetShortArrayRegion(jniEnv, array, start, len, buf); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_SetIntArrayRegion(jintArray array, - jsize start, - jsize len, - const jint* buf) { +jthrowable globalEnv_SetIntArrayRegion(jintArray array, + jsize start, + jsize len, + jint* buf) { attach_thread(); (*jniEnv)->SetIntArrayRegion(jniEnv, array, start, len, buf); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_SetLongArrayRegion(jlongArray array, - jsize start, - jsize len, - const jlong* buf) { +jthrowable globalEnv_SetLongArrayRegion(jlongArray array, + jsize start, + jsize len, + jlong* buf) { attach_thread(); (*jniEnv)->SetLongArrayRegion(jniEnv, array, start, len, buf); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_SetFloatArrayRegion(jfloatArray array, - jsize start, - jsize len, - const jfloat* buf) { +jthrowable globalEnv_SetFloatArrayRegion(jfloatArray array, + jsize start, + jsize len, + jfloat* buf) { attach_thread(); (*jniEnv)->SetFloatArrayRegion(jniEnv, array, start, len, buf); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_SetDoubleArrayRegion(jdoubleArray array, - jsize start, - jsize len, - const jdouble* buf) { +jthrowable globalEnv_SetDoubleArrayRegion(jdoubleArray array, + jsize start, + jsize len, + jdouble* buf) { attach_thread(); (*jniEnv)->SetDoubleArrayRegion(jniEnv, array, start, len, buf); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -jint globalEnv_RegisterNatives(jclass clazz, - const JNINativeMethod* methods, - jint nMethods) { +JniResult globalEnv_RegisterNatives(jclass clazz, + JNINativeMethod* methods, + jint nMethods) { attach_thread(); - return (*jniEnv)->RegisterNatives(jniEnv, clazz, methods, nMethods); + jint _result = (*jniEnv)->RegisterNatives(jniEnv, clazz, methods, nMethods); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.i = _result}, .exception = NULL}; } -jint globalEnv_UnregisterNatives(jclass clazz) { +JniResult globalEnv_UnregisterNatives(jclass clazz) { attach_thread(); - return (*jniEnv)->UnregisterNatives(jniEnv, clazz); + jint _result = (*jniEnv)->UnregisterNatives(jniEnv, clazz); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.i = _result}, .exception = NULL}; } -jint globalEnv_MonitorEnter(jobject obj) { +JniResult globalEnv_MonitorEnter(jobject obj) { attach_thread(); - return (*jniEnv)->MonitorEnter(jniEnv, obj); + jint _result = (*jniEnv)->MonitorEnter(jniEnv, obj); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.i = _result}, .exception = NULL}; } -jint globalEnv_MonitorExit(jobject obj) { +JniResult globalEnv_MonitorExit(jobject obj) { attach_thread(); - return (*jniEnv)->MonitorExit(jniEnv, obj); + jint _result = (*jniEnv)->MonitorExit(jniEnv, obj); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.i = _result}, .exception = NULL}; } -jint globalEnv_GetJavaVM(JavaVM** vm) { +JniResult globalEnv_GetJavaVM(JavaVM** vm) { attach_thread(); - return (*jniEnv)->GetJavaVM(jniEnv, vm); + jint _result = (*jniEnv)->GetJavaVM(jniEnv, vm); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.i = _result}, .exception = NULL}; } -void globalEnv_GetStringRegion(jstring str, - jsize start, - jsize len, - jchar* buf) { +jthrowable globalEnv_GetStringRegion(jstring str, + jsize start, + jsize len, + jchar* buf) { attach_thread(); (*jniEnv)->GetStringRegion(jniEnv, str, start, len, buf); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void globalEnv_GetStringUTFRegion(jstring str, - jsize start, - jsize len, - char* buf) { +jthrowable globalEnv_GetStringUTFRegion(jstring str, + jsize start, + jsize len, + char* buf) { attach_thread(); (*jniEnv)->GetStringUTFRegion(jniEnv, str, start, len, buf); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -void* globalEnv_GetPrimitiveArrayCritical(jarray array, jboolean* isCopy) { +JniPointerResult globalEnv_GetPrimitiveArrayCritical(jarray array, + jboolean* isCopy) { attach_thread(); - return (*jniEnv)->GetPrimitiveArrayCritical(jniEnv, array, isCopy); + void* _result = (*jniEnv)->GetPrimitiveArrayCritical(jniEnv, array, isCopy); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniPointerResult){.value = NULL, .exception = _exception}; + } + return (JniPointerResult){.value = _result, .exception = NULL}; } -void globalEnv_ReleasePrimitiveArrayCritical(jarray array, - void* carray, - jint mode) { +jthrowable globalEnv_ReleasePrimitiveArrayCritical(jarray array, + void* carray, + jint mode) { attach_thread(); (*jniEnv)->ReleasePrimitiveArrayCritical(jniEnv, array, carray, mode); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -const jchar* globalEnv_GetStringCritical(jstring str, jboolean* isCopy) { +JniPointerResult globalEnv_GetStringCritical(jstring str, jboolean* isCopy) { attach_thread(); - return (*jniEnv)->GetStringCritical(jniEnv, str, isCopy); + const jchar* _result = (*jniEnv)->GetStringCritical(jniEnv, str, isCopy); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniPointerResult){.value = NULL, .exception = _exception}; + } + return (JniPointerResult){.value = _result, .exception = NULL}; } -void globalEnv_ReleaseStringCritical(jstring str, const jchar* carray) { +jthrowable globalEnv_ReleaseStringCritical(jstring str, jchar* carray) { attach_thread(); (*jniEnv)->ReleaseStringCritical(jniEnv, str, carray); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -jweak globalEnv_NewWeakGlobalRef(jobject obj) { +JniResult globalEnv_NewWeakGlobalRef(jobject obj) { attach_thread(); - return to_global_ref((*jniEnv)->NewWeakGlobalRef(jniEnv, obj)); + jweak _result = (*jniEnv)->NewWeakGlobalRef(jniEnv, obj); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.l = _result}, .exception = NULL}; } -void globalEnv_DeleteWeakGlobalRef(jweak obj) { +jthrowable globalEnv_DeleteWeakGlobalRef(jweak obj) { attach_thread(); (*jniEnv)->DeleteWeakGlobalRef(jniEnv, obj); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return _exception; + } + return NULL; } -jboolean globalEnv_ExceptionCheck() { +JniResult globalEnv_ExceptionCheck() { attach_thread(); - return (*jniEnv)->ExceptionCheck(jniEnv); + jboolean _result = (*jniEnv)->ExceptionCheck(jniEnv); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.z = _result}, .exception = NULL}; } -jobject globalEnv_NewDirectByteBuffer(void* address, jlong capacity) { +JniResult globalEnv_NewDirectByteBuffer(void* address, jlong capacity) { attach_thread(); - return to_global_ref( - (*jniEnv)->NewDirectByteBuffer(jniEnv, address, capacity)); + jobject _result = (*jniEnv)->NewDirectByteBuffer(jniEnv, address, capacity); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + _result = to_global_ref(_result); + return (JniResult){.value = {.l = _result}, .exception = NULL}; } -void* globalEnv_GetDirectBufferAddress(jobject buf) { +JniPointerResult globalEnv_GetDirectBufferAddress(jobject buf) { attach_thread(); - return (*jniEnv)->GetDirectBufferAddress(jniEnv, buf); + void* _result = (*jniEnv)->GetDirectBufferAddress(jniEnv, buf); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniPointerResult){.value = NULL, .exception = _exception}; + } + return (JniPointerResult){.value = _result, .exception = NULL}; } -jlong globalEnv_GetDirectBufferCapacity(jobject buf) { +JniResult globalEnv_GetDirectBufferCapacity(jobject buf) { attach_thread(); - return (*jniEnv)->GetDirectBufferCapacity(jniEnv, buf); + jlong _result = (*jniEnv)->GetDirectBufferCapacity(jniEnv, buf); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.j = _result}, .exception = NULL}; } -jobjectRefType globalEnv_GetObjectRefType(jobject obj) { +JniResult globalEnv_GetObjectRefType(jobject obj) { attach_thread(); - return (*jniEnv)->GetObjectRefType(jniEnv, obj); + int32_t _result = (*jniEnv)->GetObjectRefType(jniEnv, obj); + jthrowable _exception = check_exception(); + if (_exception != NULL) { + return (JniResult){.value = {.j = 0}, .exception = _exception}; + } + return (JniResult){.value = {.i = _result}, .exception = NULL}; } GlobalJniEnv globalJniEnv = { + .reserved0 = NULL, + .reserved1 = NULL, + .reserved2 = NULL, + .reserved3 = NULL, .GetVersion = globalEnv_GetVersion, .DefineClass = globalEnv_DefineClass, .FindClass = globalEnv_FindClass, @@ -1229,53 +2293,76 @@ GlobalJniEnv globalJniEnv = { .PopLocalFrame = globalEnv_PopLocalFrame, .NewGlobalRef = globalEnv_NewGlobalRef, .DeleteGlobalRef = globalEnv_DeleteGlobalRef, + .DeleteLocalRef = globalEnv_DeleteLocalRef, .IsSameObject = globalEnv_IsSameObject, + .NewLocalRef = globalEnv_NewLocalRef, .EnsureLocalCapacity = globalEnv_EnsureLocalCapacity, .AllocObject = globalEnv_AllocObject, .NewObject = globalEnv_NewObject, + .NewObjectV = NULL, .NewObjectA = globalEnv_NewObjectA, .GetObjectClass = globalEnv_GetObjectClass, .IsInstanceOf = globalEnv_IsInstanceOf, .GetMethodID = globalEnv_GetMethodID, .CallObjectMethod = globalEnv_CallObjectMethod, + .CallObjectMethodV = NULL, .CallObjectMethodA = globalEnv_CallObjectMethodA, .CallBooleanMethod = globalEnv_CallBooleanMethod, + .CallBooleanMethodV = NULL, .CallBooleanMethodA = globalEnv_CallBooleanMethodA, .CallByteMethod = globalEnv_CallByteMethod, + .CallByteMethodV = NULL, .CallByteMethodA = globalEnv_CallByteMethodA, .CallCharMethod = globalEnv_CallCharMethod, + .CallCharMethodV = NULL, .CallCharMethodA = globalEnv_CallCharMethodA, .CallShortMethod = globalEnv_CallShortMethod, + .CallShortMethodV = NULL, .CallShortMethodA = globalEnv_CallShortMethodA, .CallIntMethod = globalEnv_CallIntMethod, + .CallIntMethodV = NULL, .CallIntMethodA = globalEnv_CallIntMethodA, .CallLongMethod = globalEnv_CallLongMethod, + .CallLongMethodV = NULL, .CallLongMethodA = globalEnv_CallLongMethodA, .CallFloatMethod = globalEnv_CallFloatMethod, + .CallFloatMethodV = NULL, .CallFloatMethodA = globalEnv_CallFloatMethodA, .CallDoubleMethod = globalEnv_CallDoubleMethod, + .CallDoubleMethodV = NULL, .CallDoubleMethodA = globalEnv_CallDoubleMethodA, .CallVoidMethod = globalEnv_CallVoidMethod, + .CallVoidMethodV = NULL, .CallVoidMethodA = globalEnv_CallVoidMethodA, .CallNonvirtualObjectMethod = globalEnv_CallNonvirtualObjectMethod, + .CallNonvirtualObjectMethodV = NULL, .CallNonvirtualObjectMethodA = globalEnv_CallNonvirtualObjectMethodA, .CallNonvirtualBooleanMethod = globalEnv_CallNonvirtualBooleanMethod, + .CallNonvirtualBooleanMethodV = NULL, .CallNonvirtualBooleanMethodA = globalEnv_CallNonvirtualBooleanMethodA, .CallNonvirtualByteMethod = globalEnv_CallNonvirtualByteMethod, + .CallNonvirtualByteMethodV = NULL, .CallNonvirtualByteMethodA = globalEnv_CallNonvirtualByteMethodA, .CallNonvirtualCharMethod = globalEnv_CallNonvirtualCharMethod, + .CallNonvirtualCharMethodV = NULL, .CallNonvirtualCharMethodA = globalEnv_CallNonvirtualCharMethodA, .CallNonvirtualShortMethod = globalEnv_CallNonvirtualShortMethod, + .CallNonvirtualShortMethodV = NULL, .CallNonvirtualShortMethodA = globalEnv_CallNonvirtualShortMethodA, .CallNonvirtualIntMethod = globalEnv_CallNonvirtualIntMethod, + .CallNonvirtualIntMethodV = NULL, .CallNonvirtualIntMethodA = globalEnv_CallNonvirtualIntMethodA, .CallNonvirtualLongMethod = globalEnv_CallNonvirtualLongMethod, + .CallNonvirtualLongMethodV = NULL, .CallNonvirtualLongMethodA = globalEnv_CallNonvirtualLongMethodA, .CallNonvirtualFloatMethod = globalEnv_CallNonvirtualFloatMethod, + .CallNonvirtualFloatMethodV = NULL, .CallNonvirtualFloatMethodA = globalEnv_CallNonvirtualFloatMethodA, .CallNonvirtualDoubleMethod = globalEnv_CallNonvirtualDoubleMethod, + .CallNonvirtualDoubleMethodV = NULL, .CallNonvirtualDoubleMethodA = globalEnv_CallNonvirtualDoubleMethodA, .CallNonvirtualVoidMethod = globalEnv_CallNonvirtualVoidMethod, + .CallNonvirtualVoidMethodV = NULL, .CallNonvirtualVoidMethodA = globalEnv_CallNonvirtualVoidMethodA, .GetFieldID = globalEnv_GetFieldID, .GetObjectField = globalEnv_GetObjectField, @@ -1298,24 +2385,34 @@ GlobalJniEnv globalJniEnv = { .SetDoubleField = globalEnv_SetDoubleField, .GetStaticMethodID = globalEnv_GetStaticMethodID, .CallStaticObjectMethod = globalEnv_CallStaticObjectMethod, + .CallStaticObjectMethodV = NULL, .CallStaticObjectMethodA = globalEnv_CallStaticObjectMethodA, .CallStaticBooleanMethod = globalEnv_CallStaticBooleanMethod, + .CallStaticBooleanMethodV = NULL, .CallStaticBooleanMethodA = globalEnv_CallStaticBooleanMethodA, .CallStaticByteMethod = globalEnv_CallStaticByteMethod, + .CallStaticByteMethodV = NULL, .CallStaticByteMethodA = globalEnv_CallStaticByteMethodA, .CallStaticCharMethod = globalEnv_CallStaticCharMethod, + .CallStaticCharMethodV = NULL, .CallStaticCharMethodA = globalEnv_CallStaticCharMethodA, .CallStaticShortMethod = globalEnv_CallStaticShortMethod, + .CallStaticShortMethodV = NULL, .CallStaticShortMethodA = globalEnv_CallStaticShortMethodA, .CallStaticIntMethod = globalEnv_CallStaticIntMethod, + .CallStaticIntMethodV = NULL, .CallStaticIntMethodA = globalEnv_CallStaticIntMethodA, .CallStaticLongMethod = globalEnv_CallStaticLongMethod, + .CallStaticLongMethodV = NULL, .CallStaticLongMethodA = globalEnv_CallStaticLongMethodA, .CallStaticFloatMethod = globalEnv_CallStaticFloatMethod, + .CallStaticFloatMethodV = NULL, .CallStaticFloatMethodA = globalEnv_CallStaticFloatMethodA, .CallStaticDoubleMethod = globalEnv_CallStaticDoubleMethod, + .CallStaticDoubleMethodV = NULL, .CallStaticDoubleMethodA = globalEnv_CallStaticDoubleMethodA, .CallStaticVoidMethod = globalEnv_CallStaticVoidMethod, + .CallStaticVoidMethodV = NULL, .CallStaticVoidMethodA = globalEnv_CallStaticVoidMethodA, .GetStaticFieldID = globalEnv_GetStaticFieldID, .GetStaticObjectField = globalEnv_GetStaticObjectField, @@ -1407,11 +2504,10 @@ GlobalJniEnv globalJniEnv = { .GetDirectBufferCapacity = globalEnv_GetDirectBufferCapacity, .GetObjectRefType = globalEnv_GetObjectRefType, }; - FFI_PLUGIN_EXPORT GlobalJniEnv* GetGlobalEnv() { - if (jni.jvm == NULL) { + if (jni->jvm == NULL) { return NULL; } return &globalJniEnv; -} \ No newline at end of file +} diff --git a/pkgs/jni/src/third_party/global_jni_env.h b/pkgs/jni/src/third_party/global_jni_env.h index e4229c616..8966d2bdd 100644 --- a/pkgs/jni/src/third_party/global_jni_env.h +++ b/pkgs/jni/src/third_party/global_jni_env.h @@ -1,375 +1,434 @@ -// Generated from an annotated version of jni.h provided in Android NDK. -// (NDK Version 23.1.7779620) -// The license for original file is provided below: +// Auto generated file. Do not edit. + +// This is generated from JNI header in Android NDK. License for the same is +// provided below. + +/* + * Copyright (C) 2006 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* - * Copyright (C) 2006 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + * JNI specification, as defined by Sun: + * http://java.sun.com/javase/6/docs/technotes/guides/jni/spec/jniTOC.html + * + * Everything here is expected to be VM-neutral. + */ + +#include +#include "../dartjni.h" -#include -/// Wrapper over JNIEnv in the JNI API, which can be used from multiple Dart -/// Threads. -/// -/// It consists of wrappers to JNIEnv methods which manage the thread-local -/// JNIEnv pointer in C code. Additionally, any returned local reference value -/// is converted to global reference. -/// -/// For the documentation on methods themselves, see the JNI Specification at -/// https://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/functions.html -/// -/// Apart from the specification, the Android NDK's JNI page consists of useful -/// information about using the JNI: -/// https://developer.android.com/training/articles/perf-jni typedef struct GlobalJniEnv { - jint (*GetVersion)(); - jclass (*DefineClass)(const char* name, - jobject loader, - const jbyte* buf, - jsize bufLen); - jclass (*FindClass)(const char* name); - jmethodID (*FromReflectedMethod)(jobject method); - jfieldID (*FromReflectedField)(jobject field); - jobject (*ToReflectedMethod)(jclass cls, - jmethodID methodId, - jboolean isStatic); - jclass (*GetSuperclass)(jclass clazz); - jboolean (*IsAssignableFrom)(jclass clazz1, jclass clazz2); - jobject (*ToReflectedField)(jclass cls, jfieldID fieldID, jboolean isStatic); - jint (*Throw)(jthrowable obj); - jint (*ThrowNew)(jclass clazz, const char* message); - jthrowable (*ExceptionOccurred)(); - void (*ExceptionDescribe)(); - void (*ExceptionClear)(); - void (*FatalError)(const char* msg); - jint (*PushLocalFrame)(jint capacity); - jobject (*PopLocalFrame)(jobject result); - jobject (*NewGlobalRef)(jobject obj); - void (*DeleteGlobalRef)(jobject globalRef); - jboolean (*IsSameObject)(jobject ref1, jobject ref2); - jint (*EnsureLocalCapacity)(jint capacity); - jobject (*AllocObject)(jclass clazz); - jobject (*NewObject)(jclass arg1, jmethodID arg2); - jobject (*NewObjectA)(jclass clazz, jmethodID methodID, const jvalue* args); - jclass (*GetObjectClass)(jobject obj); - jboolean (*IsInstanceOf)(jobject obj, jclass clazz); - jmethodID (*GetMethodID)(jclass clazz, const char* name, const char* sig); - jobject (*CallObjectMethod)(jobject arg1, jmethodID arg2); - jobject (*CallObjectMethodA)(jobject obj, - jmethodID methodID, - const jvalue* args); - jboolean (*CallBooleanMethod)(jobject arg1, jmethodID arg2); - jboolean (*CallBooleanMethodA)(jobject obj, + void* reserved0; + void* reserved1; + void* reserved2; + void* reserved3; + JniResult (*GetVersion)(); + JniClassLookupResult (*DefineClass)(char* name, + jobject loader, + jbyte* buf, + jsize bufLen); + JniClassLookupResult (*FindClass)(char* name); + JniPointerResult (*FromReflectedMethod)(jobject method); + JniPointerResult (*FromReflectedField)(jobject field); + JniResult (*ToReflectedMethod)(jclass cls, jmethodID methodId, - const jvalue* args); - jbyte (*CallByteMethod)(jobject arg1, jmethodID arg2); - jbyte (*CallByteMethodA)(jobject obj, jmethodID methodID, const jvalue* args); - jchar (*CallCharMethod)(jobject arg1, jmethodID arg2); - jchar (*CallCharMethodA)(jobject obj, jmethodID methodID, const jvalue* args); - jshort (*CallShortMethod)(jobject arg1, jmethodID arg2); - jshort (*CallShortMethodA)(jobject obj, - jmethodID methodID, - const jvalue* args); - jint (*CallIntMethod)(jobject arg1, jmethodID arg2); - jint (*CallIntMethodA)(jobject obj, jmethodID methodID, const jvalue* args); - jlong (*CallLongMethod)(jobject arg1, jmethodID arg2); - jlong (*CallLongMethodA)(jobject obj, jmethodID methodID, const jvalue* args); - jfloat (*CallFloatMethod)(jobject arg1, jmethodID arg2); - jfloat (*CallFloatMethodA)(jobject obj, - jmethodID methodID, - const jvalue* args); - jdouble (*CallDoubleMethod)(jobject arg1, jmethodID arg2); - jdouble (*CallDoubleMethodA)(jobject obj, - jmethodID methodID, - const jvalue* args); - void (*CallVoidMethod)(jobject arg1, jmethodID arg2); - void (*CallVoidMethodA)(jobject obj, jmethodID methodID, const jvalue* args); - jobject (*CallNonvirtualObjectMethod)(jobject arg1, - jclass arg2, - jmethodID arg3); - jobject (*CallNonvirtualObjectMethodA)(jobject obj, + jboolean isStatic); + JniClassLookupResult (*GetSuperclass)(jclass clazz); + JniResult (*IsAssignableFrom)(jclass clazz1, jclass clazz2); + JniResult (*ToReflectedField)(jclass cls, + jfieldID fieldID, + jboolean isStatic); + JniResult (*Throw)(jthrowable obj); + JniResult (*ThrowNew)(jclass clazz, char* message); + JniResult (*ExceptionOccurred)(); + jthrowable (*ExceptionDescribe)(); + jthrowable (*ExceptionClear)(); + jthrowable (*FatalError)(char* msg); + JniResult (*PushLocalFrame)(jint capacity); + JniResult (*PopLocalFrame)(jobject result); + JniResult (*NewGlobalRef)(jobject obj); + jthrowable (*DeleteGlobalRef)(jobject globalRef); + jthrowable (*DeleteLocalRef)(jobject localRef); + JniResult (*IsSameObject)(jobject ref1, jobject ref2); + JniResult (*NewLocalRef)(jobject obj); + JniResult (*EnsureLocalCapacity)(jint capacity); + JniResult (*AllocObject)(jclass clazz); + JniResult (*NewObject)(jclass clazz, jmethodID methodID); + JniResult (*NewObjectV)(jclass, jmethodID, void*); + JniResult (*NewObjectA)(jclass clazz, jmethodID methodID, jvalue* args); + JniClassLookupResult (*GetObjectClass)(jobject obj); + JniResult (*IsInstanceOf)(jobject obj, jclass clazz); + JniPointerResult (*GetMethodID)(jclass clazz, char* name, char* sig); + JniResult (*CallObjectMethod)(jobject obj, jmethodID methodID); + JniResult (*CallObjectMethodV)(jobject, jmethodID, void*); + JniResult (*CallObjectMethodA)(jobject obj, jmethodID methodID, jvalue* args); + JniResult (*CallBooleanMethod)(jobject obj, jmethodID methodID); + JniResult (*CallBooleanMethodV)(jobject, jmethodID, void*); + JniResult (*CallBooleanMethodA)(jobject obj, + jmethodID methodId, + jvalue* args); + JniResult (*CallByteMethod)(jobject obj, jmethodID methodID); + JniResult (*CallByteMethodV)(jobject, jmethodID, void*); + JniResult (*CallByteMethodA)(jobject obj, jmethodID methodID, jvalue* args); + JniResult (*CallCharMethod)(jobject obj, jmethodID methodID); + JniResult (*CallCharMethodV)(jobject, jmethodID, void*); + JniResult (*CallCharMethodA)(jobject obj, jmethodID methodID, jvalue* args); + JniResult (*CallShortMethod)(jobject obj, jmethodID methodID); + JniResult (*CallShortMethodV)(jobject, jmethodID, void*); + JniResult (*CallShortMethodA)(jobject obj, jmethodID methodID, jvalue* args); + JniResult (*CallIntMethod)(jobject obj, jmethodID methodID); + JniResult (*CallIntMethodV)(jobject, jmethodID, void*); + JniResult (*CallIntMethodA)(jobject obj, jmethodID methodID, jvalue* args); + JniResult (*CallLongMethod)(jobject obj, jmethodID methodID); + JniResult (*CallLongMethodV)(jobject, jmethodID, void*); + JniResult (*CallLongMethodA)(jobject obj, jmethodID methodID, jvalue* args); + JniResult (*CallFloatMethod)(jobject obj, jmethodID methodID); + JniResult (*CallFloatMethodV)(jobject, jmethodID, void*); + JniResult (*CallFloatMethodA)(jobject obj, jmethodID methodID, jvalue* args); + JniResult (*CallDoubleMethod)(jobject obj, jmethodID methodID); + JniResult (*CallDoubleMethodV)(jobject, jmethodID, void*); + JniResult (*CallDoubleMethodA)(jobject obj, jmethodID methodID, jvalue* args); + jthrowable (*CallVoidMethod)(jobject obj, jmethodID methodID); + jthrowable (*CallVoidMethodV)(jobject, jmethodID, void*); + jthrowable (*CallVoidMethodA)(jobject obj, jmethodID methodID, jvalue* args); + JniResult (*CallNonvirtualObjectMethod)(jobject obj, + jclass clazz, + jmethodID methodID); + JniResult (*CallNonvirtualObjectMethodV)(jobject, jclass, jmethodID, void*); + JniResult (*CallNonvirtualObjectMethodA)(jobject obj, + jclass clazz, + jmethodID methodID, + jvalue* args); + JniResult (*CallNonvirtualBooleanMethod)(jobject obj, + jclass clazz, + jmethodID methodID); + JniResult (*CallNonvirtualBooleanMethodV)(jobject, jclass, jmethodID, void*); + JniResult (*CallNonvirtualBooleanMethodA)(jobject obj, + jclass clazz, + jmethodID methodID, + jvalue* args); + JniResult (*CallNonvirtualByteMethod)(jobject obj, + jclass clazz, + jmethodID methodID); + JniResult (*CallNonvirtualByteMethodV)(jobject, jclass, jmethodID, void*); + JniResult (*CallNonvirtualByteMethodA)(jobject obj, jclass clazz, jmethodID methodID, - const jvalue* args); - jboolean (*CallNonvirtualBooleanMethod)(jobject arg1, - jclass arg2, - jmethodID arg3); - jboolean (*CallNonvirtualBooleanMethodA)(jobject obj, + jvalue* args); + JniResult (*CallNonvirtualCharMethod)(jobject obj, + jclass clazz, + jmethodID methodID); + JniResult (*CallNonvirtualCharMethodV)(jobject, jclass, jmethodID, void*); + JniResult (*CallNonvirtualCharMethodA)(jobject obj, + jclass clazz, + jmethodID methodID, + jvalue* args); + JniResult (*CallNonvirtualShortMethod)(jobject obj, + jclass clazz, + jmethodID methodID); + JniResult (*CallNonvirtualShortMethodV)(jobject, jclass, jmethodID, void*); + JniResult (*CallNonvirtualShortMethodA)(jobject obj, + jclass clazz, + jmethodID methodID, + jvalue* args); + JniResult (*CallNonvirtualIntMethod)(jobject obj, + jclass clazz, + jmethodID methodID); + JniResult (*CallNonvirtualIntMethodV)(jobject, jclass, jmethodID, void*); + JniResult (*CallNonvirtualIntMethodA)(jobject obj, + jclass clazz, + jmethodID methodID, + jvalue* args); + JniResult (*CallNonvirtualLongMethod)(jobject obj, + jclass clazz, + jmethodID methodID); + JniResult (*CallNonvirtualLongMethodV)(jobject, jclass, jmethodID, void*); + JniResult (*CallNonvirtualLongMethodA)(jobject obj, + jclass clazz, + jmethodID methodID, + jvalue* args); + JniResult (*CallNonvirtualFloatMethod)(jobject obj, + jclass clazz, + jmethodID methodID); + JniResult (*CallNonvirtualFloatMethodV)(jobject, jclass, jmethodID, void*); + JniResult (*CallNonvirtualFloatMethodA)(jobject obj, + jclass clazz, + jmethodID methodID, + jvalue* args); + JniResult (*CallNonvirtualDoubleMethod)(jobject obj, + jclass clazz, + jmethodID methodID); + JniResult (*CallNonvirtualDoubleMethodV)(jobject, jclass, jmethodID, void*); + JniResult (*CallNonvirtualDoubleMethodA)(jobject obj, jclass clazz, jmethodID methodID, - const jvalue* args); - jbyte (*CallNonvirtualByteMethod)(jobject arg1, jclass arg2, jmethodID arg3); - jbyte (*CallNonvirtualByteMethodA)(jobject obj, - jclass clazz, - jmethodID methodID, - const jvalue* args); - jchar (*CallNonvirtualCharMethod)(jobject arg1, jclass arg2, jmethodID arg3); - jchar (*CallNonvirtualCharMethodA)(jobject obj, - jclass clazz, - jmethodID methodID, - const jvalue* args); - jshort (*CallNonvirtualShortMethod)(jobject arg1, - jclass arg2, - jmethodID arg3); - jshort (*CallNonvirtualShortMethodA)(jobject obj, - jclass clazz, + jvalue* args); + jthrowable (*CallNonvirtualVoidMethod)(jobject obj, + jclass clazz, + jmethodID methodID); + jthrowable (*CallNonvirtualVoidMethodV)(jobject, jclass, jmethodID, void*); + jthrowable (*CallNonvirtualVoidMethodA)(jobject obj, + jclass clazz, + jmethodID methodID, + jvalue* args); + JniPointerResult (*GetFieldID)(jclass clazz, char* name, char* sig); + JniResult (*GetObjectField)(jobject obj, jfieldID fieldID); + JniResult (*GetBooleanField)(jobject obj, jfieldID fieldID); + JniResult (*GetByteField)(jobject obj, jfieldID fieldID); + JniResult (*GetCharField)(jobject obj, jfieldID fieldID); + JniResult (*GetShortField)(jobject obj, jfieldID fieldID); + JniResult (*GetIntField)(jobject obj, jfieldID fieldID); + JniResult (*GetLongField)(jobject obj, jfieldID fieldID); + JniResult (*GetFloatField)(jobject obj, jfieldID fieldID); + JniResult (*GetDoubleField)(jobject obj, jfieldID fieldID); + jthrowable (*SetObjectField)(jobject obj, jfieldID fieldID, jobject val); + jthrowable (*SetBooleanField)(jobject obj, jfieldID fieldID, jboolean val); + jthrowable (*SetByteField)(jobject obj, jfieldID fieldID, jbyte val); + jthrowable (*SetCharField)(jobject obj, jfieldID fieldID, jchar val); + jthrowable (*SetShortField)(jobject obj, jfieldID fieldID, jshort val); + jthrowable (*SetIntField)(jobject obj, jfieldID fieldID, jint val); + jthrowable (*SetLongField)(jobject obj, jfieldID fieldID, jlong val); + jthrowable (*SetFloatField)(jobject obj, jfieldID fieldID, jfloat val); + jthrowable (*SetDoubleField)(jobject obj, jfieldID fieldID, jdouble val); + JniPointerResult (*GetStaticMethodID)(jclass clazz, char* name, char* sig); + JniResult (*CallStaticObjectMethod)(jclass clazz, jmethodID methodID); + JniResult (*CallStaticObjectMethodV)(jclass, jmethodID, void*); + JniResult (*CallStaticObjectMethodA)(jclass clazz, jmethodID methodID, - const jvalue* args); - jint (*CallNonvirtualIntMethod)(jobject arg1, jclass arg2, jmethodID arg3); - jint (*CallNonvirtualIntMethodA)(jobject obj, - jclass clazz, - jmethodID methodID, - const jvalue* args); - jlong (*CallNonvirtualLongMethod)(jobject arg1, jclass arg2, jmethodID arg3); - jlong (*CallNonvirtualLongMethodA)(jobject obj, - jclass clazz, + jvalue* args); + JniResult (*CallStaticBooleanMethod)(jclass clazz, jmethodID methodID); + JniResult (*CallStaticBooleanMethodV)(jclass, jmethodID, void*); + JniResult (*CallStaticBooleanMethodA)(jclass clazz, + jmethodID methodID, + jvalue* args); + JniResult (*CallStaticByteMethod)(jclass clazz, jmethodID methodID); + JniResult (*CallStaticByteMethodV)(jclass, jmethodID, void*); + JniResult (*CallStaticByteMethodA)(jclass clazz, jmethodID methodID, - const jvalue* args); - jfloat (*CallNonvirtualFloatMethod)(jobject arg1, - jclass arg2, - jmethodID arg3); - jfloat (*CallNonvirtualFloatMethodA)(jobject obj, - jclass clazz, - jmethodID methodID, - const jvalue* args); - jdouble (*CallNonvirtualDoubleMethod)(jobject arg1, - jclass arg2, - jmethodID arg3); - jdouble (*CallNonvirtualDoubleMethodA)(jobject obj, - jclass clazz, - jmethodID methodID, - const jvalue* args); - void (*CallNonvirtualVoidMethod)(jobject arg1, jclass arg2, jmethodID arg3); - void (*CallNonvirtualVoidMethodA)(jobject obj, - jclass clazz, + jvalue* args); + JniResult (*CallStaticCharMethod)(jclass clazz, jmethodID methodID); + JniResult (*CallStaticCharMethodV)(jclass, jmethodID, void*); + JniResult (*CallStaticCharMethodA)(jclass clazz, + jmethodID methodID, + jvalue* args); + JniResult (*CallStaticShortMethod)(jclass clazz, jmethodID methodID); + JniResult (*CallStaticShortMethodV)(jclass, jmethodID, void*); + JniResult (*CallStaticShortMethodA)(jclass clazz, + jmethodID methodID, + jvalue* args); + JniResult (*CallStaticIntMethod)(jclass clazz, jmethodID methodID); + JniResult (*CallStaticIntMethodV)(jclass, jmethodID, void*); + JniResult (*CallStaticIntMethodA)(jclass clazz, jmethodID methodID, - const jvalue* args); - jfieldID (*GetFieldID)(jclass clazz, const char* name, const char* sig); - jobject (*GetObjectField)(jobject obj, jfieldID fieldID); - jboolean (*GetBooleanField)(jobject obj, jfieldID fieldID); - jbyte (*GetByteField)(jobject obj, jfieldID fieldID); - jchar (*GetCharField)(jobject obj, jfieldID fieldID); - jshort (*GetShortField)(jobject obj, jfieldID fieldID); - jint (*GetIntField)(jobject obj, jfieldID fieldID); - jlong (*GetLongField)(jobject obj, jfieldID fieldID); - jfloat (*GetFloatField)(jobject obj, jfieldID fieldID); - jdouble (*GetDoubleField)(jobject obj, jfieldID fieldID); - void (*SetObjectField)(jobject obj, jfieldID fieldID, jobject val); - void (*SetBooleanField)(jobject obj, jfieldID fieldID, jboolean val); - void (*SetByteField)(jobject obj, jfieldID fieldID, jbyte val); - void (*SetCharField)(jobject obj, jfieldID fieldID, jchar val); - void (*SetShortField)(jobject obj, jfieldID fieldID, jshort val); - void (*SetIntField)(jobject obj, jfieldID fieldID, jint val); - void (*SetLongField)(jobject obj, jfieldID fieldID, jlong val); - void (*SetFloatField)(jobject obj, jfieldID fieldID, jfloat val); - void (*SetDoubleField)(jobject obj, jfieldID fieldID, jdouble val); - jmethodID (*GetStaticMethodID)(jclass clazz, - const char* name, - const char* sig); - jobject (*CallStaticObjectMethod)(jclass arg1, jmethodID arg2); - jobject (*CallStaticObjectMethodA)(jclass clazz, + jvalue* args); + JniResult (*CallStaticLongMethod)(jclass clazz, jmethodID methodID); + JniResult (*CallStaticLongMethodV)(jclass, jmethodID, void*); + JniResult (*CallStaticLongMethodA)(jclass clazz, jmethodID methodID, - const jvalue* args); - jboolean (*CallStaticBooleanMethod)(jclass arg1, jmethodID arg2); - jboolean (*CallStaticBooleanMethodA)(jclass clazz, + jvalue* args); + JniResult (*CallStaticFloatMethod)(jclass clazz, jmethodID methodID); + JniResult (*CallStaticFloatMethodV)(jclass, jmethodID, void*); + JniResult (*CallStaticFloatMethodA)(jclass clazz, + jmethodID methodID, + jvalue* args); + JniResult (*CallStaticDoubleMethod)(jclass clazz, jmethodID methodID); + JniResult (*CallStaticDoubleMethodV)(jclass, jmethodID, void*); + JniResult (*CallStaticDoubleMethodA)(jclass clazz, jmethodID methodID, - const jvalue* args); - jbyte (*CallStaticByteMethod)(jclass arg1, jmethodID arg2); - jbyte (*CallStaticByteMethodA)(jclass clazz, - jmethodID methodID, - const jvalue* args); - jchar (*CallStaticCharMethod)(jclass arg1, jmethodID arg2); - jchar (*CallStaticCharMethodA)(jclass clazz, - jmethodID methodID, - const jvalue* args); - jshort (*CallStaticShortMethod)(jclass arg1, jmethodID arg2); - jshort (*CallStaticShortMethodA)(jclass clazz, - jmethodID methodID, - const jvalue* args); - jint (*CallStaticIntMethod)(jclass arg1, jmethodID arg2); - jint (*CallStaticIntMethodA)(jclass clazz, - jmethodID methodID, - const jvalue* args); - jlong (*CallStaticLongMethod)(jclass arg1, jmethodID arg2); - jlong (*CallStaticLongMethodA)(jclass clazz, - jmethodID methodID, - const jvalue* args); - jfloat (*CallStaticFloatMethod)(jclass arg1, jmethodID arg2); - jfloat (*CallStaticFloatMethodA)(jclass clazz, - jmethodID methodID, - const jvalue* args); - jdouble (*CallStaticDoubleMethod)(jclass arg1, jmethodID arg2); - jdouble (*CallStaticDoubleMethodA)(jclass clazz, - jmethodID methodID, - const jvalue* args); - void (*CallStaticVoidMethod)(jclass arg1, jmethodID arg2); - void (*CallStaticVoidMethodA)(jclass clazz, - jmethodID methodID, - const jvalue* args); - jfieldID (*GetStaticFieldID)(jclass clazz, const char* name, const char* sig); - jobject (*GetStaticObjectField)(jclass clazz, jfieldID fieldID); - jboolean (*GetStaticBooleanField)(jclass clazz, jfieldID fieldID); - jbyte (*GetStaticByteField)(jclass clazz, jfieldID fieldID); - jchar (*GetStaticCharField)(jclass clazz, jfieldID fieldID); - jshort (*GetStaticShortField)(jclass clazz, jfieldID fieldID); - jint (*GetStaticIntField)(jclass clazz, jfieldID fieldID); - jlong (*GetStaticLongField)(jclass clazz, jfieldID fieldID); - jfloat (*GetStaticFloatField)(jclass clazz, jfieldID fieldID); - jdouble (*GetStaticDoubleField)(jclass clazz, jfieldID fieldID); - void (*SetStaticObjectField)(jclass clazz, jfieldID fieldID, jobject val); - void (*SetStaticBooleanField)(jclass clazz, jfieldID fieldID, jboolean val); - void (*SetStaticByteField)(jclass clazz, jfieldID fieldID, jbyte val); - void (*SetStaticCharField)(jclass clazz, jfieldID fieldID, jchar val); - void (*SetStaticShortField)(jclass clazz, jfieldID fieldID, jshort val); - void (*SetStaticIntField)(jclass clazz, jfieldID fieldID, jint val); - void (*SetStaticLongField)(jclass clazz, jfieldID fieldID, jlong val); - void (*SetStaticFloatField)(jclass clazz, jfieldID fieldID, jfloat val); - void (*SetStaticDoubleField)(jclass clazz, jfieldID fieldID, jdouble val); - jstring (*NewString)(const jchar* unicodeChars, jsize len); - jsize (*GetStringLength)(jstring string); - const jchar* (*GetStringChars)(jstring string, jboolean* isCopy); - void (*ReleaseStringChars)(jstring string, const jchar* isCopy); - jstring (*NewStringUTF)(const char* bytes); - jsize (*GetStringUTFLength)(jstring string); - const char* (*GetStringUTFChars)(jstring string, jboolean* isCopy); - void (*ReleaseStringUTFChars)(jstring string, const char* utf); - jsize (*GetArrayLength)(jarray array); - jobjectArray (*NewObjectArray)(jsize length, - jclass elementClass, - jobject initialElement); - jobject (*GetObjectArrayElement)(jobjectArray array, jsize index); - void (*SetObjectArrayElement)(jobjectArray array, jsize index, jobject val); - jbooleanArray (*NewBooleanArray)(jsize length); - jbyteArray (*NewByteArray)(jsize length); - jcharArray (*NewCharArray)(jsize length); - jshortArray (*NewShortArray)(jsize length); - jintArray (*NewIntArray)(jsize length); - jlongArray (*NewLongArray)(jsize length); - jfloatArray (*NewFloatArray)(jsize length); - jdoubleArray (*NewDoubleArray)(jsize length); - jboolean* (*GetBooleanArrayElements)(jbooleanArray array, jboolean* isCopy); - jbyte* (*GetByteArrayElements)(jbyteArray array, jboolean* isCopy); - jchar* (*GetCharArrayElements)(jcharArray array, jboolean* isCopy); - jshort* (*GetShortArrayElements)(jshortArray array, jboolean* isCopy); - jint* (*GetIntArrayElements)(jintArray array, jboolean* isCopy); - jlong* (*GetLongArrayElements)(jlongArray array, jboolean* isCopy); - jfloat* (*GetFloatArrayElements)(jfloatArray array, jboolean* isCopy); - jdouble* (*GetDoubleArrayElements)(jdoubleArray array, jboolean* isCopy); - void (*ReleaseBooleanArrayElements)(jbooleanArray array, - jboolean* elems, - jint mode); - void (*ReleaseByteArrayElements)(jbyteArray array, jbyte* elems, jint mode); - void (*ReleaseCharArrayElements)(jcharArray array, jchar* elems, jint mode); - void (*ReleaseShortArrayElements)(jshortArray array, - jshort* elems, - jint mode); - void (*ReleaseIntArrayElements)(jintArray array, jint* elems, jint mode); - void (*ReleaseLongArrayElements)(jlongArray array, jlong* elems, jint mode); - void (*ReleaseFloatArrayElements)(jfloatArray array, - jfloat* elems, - jint mode); - void (*ReleaseDoubleArrayElements)(jdoubleArray array, - jdouble* elems, - jint mode); - void (*GetBooleanArrayRegion)(jbooleanArray array, + jvalue* args); + jthrowable (*CallStaticVoidMethod)(jclass clazz, jmethodID methodID); + jthrowable (*CallStaticVoidMethodV)(jclass, jmethodID, void*); + jthrowable (*CallStaticVoidMethodA)(jclass clazz, + jmethodID methodID, + jvalue* args); + JniPointerResult (*GetStaticFieldID)(jclass clazz, char* name, char* sig); + JniResult (*GetStaticObjectField)(jclass clazz, jfieldID fieldID); + JniResult (*GetStaticBooleanField)(jclass clazz, jfieldID fieldID); + JniResult (*GetStaticByteField)(jclass clazz, jfieldID fieldID); + JniResult (*GetStaticCharField)(jclass clazz, jfieldID fieldID); + JniResult (*GetStaticShortField)(jclass clazz, jfieldID fieldID); + JniResult (*GetStaticIntField)(jclass clazz, jfieldID fieldID); + JniResult (*GetStaticLongField)(jclass clazz, jfieldID fieldID); + JniResult (*GetStaticFloatField)(jclass clazz, jfieldID fieldID); + JniResult (*GetStaticDoubleField)(jclass clazz, jfieldID fieldID); + jthrowable (*SetStaticObjectField)(jclass clazz, + jfieldID fieldID, + jobject val); + jthrowable (*SetStaticBooleanField)(jclass clazz, + jfieldID fieldID, + jboolean val); + jthrowable (*SetStaticByteField)(jclass clazz, jfieldID fieldID, jbyte val); + jthrowable (*SetStaticCharField)(jclass clazz, jfieldID fieldID, jchar val); + jthrowable (*SetStaticShortField)(jclass clazz, jfieldID fieldID, jshort val); + jthrowable (*SetStaticIntField)(jclass clazz, jfieldID fieldID, jint val); + jthrowable (*SetStaticLongField)(jclass clazz, jfieldID fieldID, jlong val); + jthrowable (*SetStaticFloatField)(jclass clazz, jfieldID fieldID, jfloat val); + jthrowable (*SetStaticDoubleField)(jclass clazz, + jfieldID fieldID, + jdouble val); + JniResult (*NewString)(jchar* unicodeChars, jsize len); + JniResult (*GetStringLength)(jstring string); + JniPointerResult (*GetStringChars)(jstring string, jboolean* isCopy); + jthrowable (*ReleaseStringChars)(jstring string, jchar* isCopy); + JniResult (*NewStringUTF)(char* bytes); + JniResult (*GetStringUTFLength)(jstring string); + JniPointerResult (*GetStringUTFChars)(jstring string, jboolean* isCopy); + jthrowable (*ReleaseStringUTFChars)(jstring string, char* utf); + JniResult (*GetArrayLength)(jarray array); + JniResult (*NewObjectArray)(jsize length, + jclass elementClass, + jobject initialElement); + JniResult (*GetObjectArrayElement)(jobjectArray array, jsize index); + jthrowable (*SetObjectArrayElement)(jobjectArray array, + jsize index, + jobject val); + JniResult (*NewBooleanArray)(jsize length); + JniResult (*NewByteArray)(jsize length); + JniResult (*NewCharArray)(jsize length); + JniResult (*NewShortArray)(jsize length); + JniResult (*NewIntArray)(jsize length); + JniResult (*NewLongArray)(jsize length); + JniResult (*NewFloatArray)(jsize length); + JniResult (*NewDoubleArray)(jsize length); + JniPointerResult (*GetBooleanArrayElements)(jbooleanArray array, + jboolean* isCopy); + JniPointerResult (*GetByteArrayElements)(jbyteArray array, jboolean* isCopy); + JniPointerResult (*GetCharArrayElements)(jcharArray array, jboolean* isCopy); + JniPointerResult (*GetShortArrayElements)(jshortArray array, + jboolean* isCopy); + JniPointerResult (*GetIntArrayElements)(jintArray array, jboolean* isCopy); + JniPointerResult (*GetLongArrayElements)(jlongArray array, jboolean* isCopy); + JniPointerResult (*GetFloatArrayElements)(jfloatArray array, + jboolean* isCopy); + JniPointerResult (*GetDoubleArrayElements)(jdoubleArray array, + jboolean* isCopy); + jthrowable (*ReleaseBooleanArrayElements)(jbooleanArray array, + jboolean* elems, + jint mode); + jthrowable (*ReleaseByteArrayElements)(jbyteArray array, + jbyte* elems, + jint mode); + jthrowable (*ReleaseCharArrayElements)(jcharArray array, + jchar* elems, + jint mode); + jthrowable (*ReleaseShortArrayElements)(jshortArray array, + jshort* elems, + jint mode); + jthrowable (*ReleaseIntArrayElements)(jintArray array, + jint* elems, + jint mode); + jthrowable (*ReleaseLongArrayElements)(jlongArray array, + jlong* elems, + jint mode); + jthrowable (*ReleaseFloatArrayElements)(jfloatArray array, + jfloat* elems, + jint mode); + jthrowable (*ReleaseDoubleArrayElements)(jdoubleArray array, + jdouble* elems, + jint mode); + jthrowable (*GetBooleanArrayRegion)(jbooleanArray array, + jsize start, + jsize len, + jboolean* buf); + jthrowable (*GetByteArrayRegion)(jbyteArray array, + jsize start, + jsize len, + jbyte* buf); + jthrowable (*GetCharArrayRegion)(jcharArray array, + jsize start, + jsize len, + jchar* buf); + jthrowable (*GetShortArrayRegion)(jshortArray array, + jsize start, + jsize len, + jshort* buf); + jthrowable (*GetIntArrayRegion)(jintArray array, + jsize start, + jsize len, + jint* buf); + jthrowable (*GetLongArrayRegion)(jlongArray array, + jsize start, + jsize len, + jlong* buf); + jthrowable (*GetFloatArrayRegion)(jfloatArray array, + jsize start, + jsize len, + jfloat* buf); + jthrowable (*GetDoubleArrayRegion)(jdoubleArray array, + jsize start, + jsize len, + jdouble* buf); + jthrowable (*SetBooleanArrayRegion)(jbooleanArray array, + jsize start, + jsize len, + jboolean* buf); + jthrowable (*SetByteArrayRegion)(jbyteArray array, + jsize start, + jsize len, + jbyte* buf); + jthrowable (*SetCharArrayRegion)(jcharArray array, + jsize start, + jsize len, + jchar* buf); + jthrowable (*SetShortArrayRegion)(jshortArray array, + jsize start, + jsize len, + jshort* buf); + jthrowable (*SetIntArrayRegion)(jintArray array, + jsize start, + jsize len, + jint* buf); + jthrowable (*SetLongArrayRegion)(jlongArray array, + jsize start, + jsize len, + jlong* buf); + jthrowable (*SetFloatArrayRegion)(jfloatArray array, + jsize start, + jsize len, + jfloat* buf); + jthrowable (*SetDoubleArrayRegion)(jdoubleArray array, + jsize start, + jsize len, + jdouble* buf); + JniResult (*RegisterNatives)(jclass clazz, + JNINativeMethod* methods, + jint nMethods); + JniResult (*UnregisterNatives)(jclass clazz); + JniResult (*MonitorEnter)(jobject obj); + JniResult (*MonitorExit)(jobject obj); + JniResult (*GetJavaVM)(JavaVM** vm); + jthrowable (*GetStringRegion)(jstring str, jsize start, jsize len, - jboolean* buf); - void (*GetByteArrayRegion)(jbyteArray array, - jsize start, - jsize len, - jbyte* buf); - void (*GetCharArrayRegion)(jcharArray array, - jsize start, - jsize len, - jchar* buf); - void (*GetShortArrayRegion)(jshortArray array, - jsize start, - jsize len, - jshort* buf); - void (*GetIntArrayRegion)(jintArray array, jsize start, jsize len, jint* buf); - void (*GetLongArrayRegion)(jlongArray array, - jsize start, - jsize len, - jlong* buf); - void (*GetFloatArrayRegion)(jfloatArray array, - jsize start, - jsize len, - jfloat* buf); - void (*GetDoubleArrayRegion)(jdoubleArray array, - jsize start, - jsize len, - jdouble* buf); - void (*SetBooleanArrayRegion)(jbooleanArray array, - jsize start, - jsize len, - const jboolean* buf); - void (*SetByteArrayRegion)(jbyteArray array, - jsize start, - jsize len, - const jbyte* buf); - void (*SetCharArrayRegion)(jcharArray array, - jsize start, - jsize len, - const jchar* buf); - void (*SetShortArrayRegion)(jshortArray array, - jsize start, - jsize len, - const jshort* buf); - void (*SetIntArrayRegion)(jintArray array, - jsize start, - jsize len, - const jint* buf); - void (*SetLongArrayRegion)(jlongArray array, - jsize start, - jsize len, - const jlong* buf); - void (*SetFloatArrayRegion)(jfloatArray array, - jsize start, - jsize len, - const jfloat* buf); - void (*SetDoubleArrayRegion)(jdoubleArray array, - jsize start, - jsize len, - const jdouble* buf); - jint (*RegisterNatives)(jclass clazz, - const JNINativeMethod* methods, - jint nMethods); - jint (*UnregisterNatives)(jclass clazz); - jint (*MonitorEnter)(jobject obj); - jint (*MonitorExit)(jobject obj); - jint (*GetJavaVM)(JavaVM** vm); - void (*GetStringRegion)(jstring str, jsize start, jsize len, jchar* buf); - void (*GetStringUTFRegion)(jstring str, jsize start, jsize len, char* buf); - void* (*GetPrimitiveArrayCritical)(jarray array, jboolean* isCopy); - void (*ReleasePrimitiveArrayCritical)(jarray array, void* carray, jint mode); - const jchar* (*GetStringCritical)(jstring str, jboolean* isCopy); - void (*ReleaseStringCritical)(jstring str, const jchar* carray); - jweak (*NewWeakGlobalRef)(jobject obj); - void (*DeleteWeakGlobalRef)(jweak obj); - jboolean (*ExceptionCheck)(); - jobject (*NewDirectByteBuffer)(void* address, jlong capacity); - void* (*GetDirectBufferAddress)(jobject buf); - jlong (*GetDirectBufferCapacity)(jobject buf); - jobjectRefType (*GetObjectRefType)(jobject obj); + jchar* buf); + jthrowable (*GetStringUTFRegion)(jstring str, + jsize start, + jsize len, + char* buf); + JniPointerResult (*GetPrimitiveArrayCritical)(jarray array, jboolean* isCopy); + jthrowable (*ReleasePrimitiveArrayCritical)(jarray array, + void* carray, + jint mode); + JniPointerResult (*GetStringCritical)(jstring str, jboolean* isCopy); + jthrowable (*ReleaseStringCritical)(jstring str, jchar* carray); + JniResult (*NewWeakGlobalRef)(jobject obj); + jthrowable (*DeleteWeakGlobalRef)(jweak obj); + JniResult (*ExceptionCheck)(); + JniResult (*NewDirectByteBuffer)(void* address, jlong capacity); + JniPointerResult (*GetDirectBufferAddress)(jobject buf); + JniResult (*GetDirectBufferCapacity)(jobject buf); + JniResult (*GetObjectRefType)(jobject obj); } GlobalJniEnv; - -// Note(Mahesh): Redoing some work here, because I want these 2 files separate. -// including dartjni.h for FFI_PLUGIN_EXPORT leads to more issues. - -#if _WIN32 -__declspec(dllexport) GlobalJniEnv* GetGlobalEnv(); -#else -GlobalJniEnv* GetGlobalEnv(); -#endif \ No newline at end of file +FFI_PLUGIN_EXPORT GlobalJniEnv* GetGlobalEnv(); diff --git a/pkgs/jni/test/exception_test.dart b/pkgs/jni/test/exception_test.dart index c277b01b3..4fb34efe7 100644 --- a/pkgs/jni/test/exception_test.dart +++ b/pkgs/jni/test/exception_test.dart @@ -7,6 +7,8 @@ import 'dart:io'; import 'package:test/test.dart'; import 'package:jni/jni.dart'; +import 'test_util/test_util.dart'; + void main() { if (!Platform.isAndroid) { bool caught = false; @@ -31,21 +33,24 @@ void main() { "Read exception_test.dart for details."; } } + run(testRunner: test); +} - test("double free throws exception", () { +void run({required TestRunnerCallback testRunner}) { + testRunner("double free throws exception", () { final r = Jni.newInstance("java/util/Random", "()V", []); r.delete(); expect(r.delete, throwsA(isA())); }); - test("Use after free throws exception", () { + testRunner("Use after free throws exception", () { final r = Jni.newInstance("java/util/Random", "()V", []); r.delete(); expect(() => r.callMethodByName("nextInt", "(I)I", [JValueInt(256)]), throwsA(isA())); }); - test("void fieldType throws exception", () { + testRunner("void fieldType throws exception", () { final r = Jni.newInstance("java/util/Random", "()V", []); expect(() => r.getField(nullptr, JniCallType.voidType), throwsArgumentError); @@ -53,7 +58,7 @@ void main() { throwsArgumentError); }); - test("Wrong callType throws exception", () { + testRunner("Wrong callType throws exception", () { final r = Jni.newInstance("java/util/Random", "()V", []); expect( () => r.callMethodByName( @@ -61,7 +66,7 @@ void main() { throwsA(isA())); }); - test("An exception in JNI throws JniException in Dart", () { + testRunner("An exception in JNI throws JniException in Dart", () { final r = Jni.newInstance("java/util/Random", "()V", []); expect(() => r.callMethodByName("nextInt", "(I)I", [JValueInt(-1)]), throwsA(isA())); diff --git a/pkgs/jni/test/jni_test.dart b/pkgs/jni/test/global_env_test.dart similarity index 59% rename from pkgs/jni/test/jni_test.dart rename to pkgs/jni/test/global_env_test.dart index 19bae21b3..8f65d3464 100644 --- a/pkgs/jni/test/jni_test.dart +++ b/pkgs/jni/test/global_env_test.dart @@ -5,8 +5,13 @@ import 'dart:io'; import 'package:jni/jni.dart'; +import 'package:jni/src/jvalues.dart'; import 'package:test/test.dart'; +import 'test_util/test_util.dart'; + +const maxLongInJava = 9223372036854775807; + void main() { // Running on Android through flutter, this plugin // will bind to Android runtime's JVM. @@ -26,7 +31,12 @@ void main() { // TODO(#51): Support destroying and reinstantiating JVM. } } + run(testRunner: test); +} +// We are factoring these tests into a run method which allows us to run same +// tests with different environments. Eg: standalone and integration tests. +void run({required TestRunnerCallback testRunner}) { // Tests in this file demonstrate how to use `GlobalJniEnv`, a thin // abstraction over JNIEnv in JNI C API. This can be used from multiple // threads, and converts all returned object references to global references, @@ -39,16 +49,15 @@ void main() { // // For examples of a higher level API, see `jni_object_tests.dart`. final env = Jni.env; - - test('initDLApi', () { + testRunner('initDLApi', () { Jni.initDLApi(); }); - test('get JNI Version', () { + testRunner('get JNI Version', () { expect(Jni.env.GetVersion(), isNot(equals(0))); }); - test( + testRunner( 'Manually lookup & call Integer.toHexString', () => using((arena) { // Method names on JniEnv* from C JNI API are capitalized @@ -72,7 +81,7 @@ void main() { // use asDartString extension method on Pointer // to convert a String jobject result to string - final res = env.asDartString(jres); + final res = env.toDartString(jres); expect(res, equals(i.toRadixString(16))); // Any object or class result from java is a local reference @@ -85,17 +94,33 @@ void main() { env.DeleteGlobalRef(integerClass); })); - test("asJString extension method", () { + testRunner("asJString extension method", () { const str = "QWERTY QWERTY"; // convenience method that wraps // converting dart string to native string, // instantiating java string, and freeing the native string - final jstr = env.asJString(str); - expect(str, equals(env.asDartString(jstr))); + final jstr = env.toJStringPtr(str); + expect(str, equals(env.toDartString(jstr))); env.DeleteGlobalRef(jstr); }); - test( + testRunner( + 'GlobalJniEnv should catch exceptions', + () => using((arena) { + final integerClass = + env.FindClass("java/lang/Integer".toNativeChars(arena)); + final parseIntMethod = env.GetStaticMethodID( + integerClass, + "parseInt".toNativeChars(arena), + "(Ljava/lang/String;)I".toNativeChars(arena)); + final args = JValueArgs(["hello"], arena); + expect( + () => env.CallStaticIntMethodA( + integerClass, parseIntMethod, args.values), + throwsA(isA())); + })); + + testRunner( "Convert back & forth between Dart & Java strings", () => using((arena) { const str = "ABCD EFGH"; @@ -108,7 +133,7 @@ void main() { env.DeleteGlobalRef(jstr); })); - test( + testRunner( "Print something from Java", () => using((arena) { final system = @@ -124,8 +149,56 @@ void main() { "println".toNativeChars(arena), "(Ljava/lang/String;)V".toNativeChars(arena)); const str = "\nHello World from JNI!"; - final jstr = env.asJString(str); + final jstr = env.toJStringPtr(str); env.CallVoidMethodA(out, println, Jni.jvalues([jstr])); env.deleteAllRefs([system, printStream, jstr]); })); + testRunner( + 'Env create reference methods should retain their default behavior', () { + final systemOut = Jni.retrieveStaticField( + "java/lang/System", "out", "Ljava/io/PrintStream;"); + var refType = env.GetObjectRefType(systemOut); + expect(refType, equals(JObjectRefType.JNIGlobalRefType)); + final localRef = env.NewLocalRef(systemOut); + refType = env.GetObjectRefType(localRef); + expect(refType, equals(JObjectRefType.JNILocalRefType)); + final weakRef = env.NewWeakGlobalRef(systemOut); + refType = env.GetObjectRefType(weakRef); + expect(refType, equals(JObjectRefType.JNIWeakGlobalRefType)); + final globalRef = env.NewGlobalRef(localRef); + refType = env.GetObjectRefType(globalRef); + expect(refType, equals(JObjectRefType.JNIGlobalRefType)); + env.DeleteGlobalRef(globalRef); + env.DeleteWeakGlobalRef(weakRef); + env.DeleteLocalRef(localRef); + env.DeleteGlobalRef(systemOut); + }); + testRunner('long methods return long int without loss of precision', () { + using((arena) { + final longClass = env.FindClass("java/lang/Long".toNativeChars(arena)); + final maxField = env.GetStaticFieldID( + longClass, + 'MAX_VALUE'.toNativeChars(arena), + 'J'.toNativeChars(arena), + ); + final maxValue = env.GetStaticLongField(longClass, maxField); + expect(maxValue, equals(maxLongInJava)); + env.DeleteGlobalRef(longClass); + }); + }); + + testRunner('class <-> object methods', () { + using((arena) { + final systemOut = Jni.retrieveStaticField( + "java/lang/System", "out", "Ljava/io/PrintStream;"); + final systemErr = Jni.retrieveStaticField( + "java/lang/System", "err", "Ljava/io/PrintStream;"); + final outClass = env.GetObjectClass(systemOut); + expect(env.IsInstanceOf(systemOut, outClass), isTrue); + expect(env.IsInstanceOf(systemErr, outClass), isTrue); + final errClass = env.GetObjectClass(systemErr); + expect(env.IsSameObject(outClass, errClass), isTrue); + env.deleteAllRefs([systemOut, systemErr, outClass, errClass]); + }); + }); } diff --git a/pkgs/jni/test/jarray_test.dart b/pkgs/jni/test/jarray_test.dart index 9a75e410b..4eca3d4a3 100644 --- a/pkgs/jni/test/jarray_test.dart +++ b/pkgs/jni/test/jarray_test.dart @@ -7,6 +7,8 @@ import 'dart:io'; import 'package:jni/jni.dart'; import 'package:test/test.dart'; +import 'test_util/test_util.dart'; + void main() { // Don't forget to initialize JNI. if (!Platform.isAndroid) { @@ -16,7 +18,11 @@ void main() { // TODO(#51): Support destroying and reinstantiating JVM. } } - test("Java boolean array", () { + run(testRunner: test); +} + +void run({required TestRunnerCallback testRunner}) { + testRunner("Java boolean array", () { using((arena) { final array = JArray(JBoolean.type, 3)..deletedIn(arena); expect(array.length, 3); @@ -41,7 +47,7 @@ void main() { }, throwsRangeError); }); }); - test("Java char array", () { + testRunner("Java char array", () { using((arena) { final array = JArray(JChar.type, 3)..deletedIn(arena); expect(array.length, 3); @@ -66,7 +72,7 @@ void main() { }, throwsRangeError); }); }); - test("Java byte array", () { + testRunner("Java byte array", () { using((arena) { final array = JArray(JByte.type, 3)..deletedIn(arena); expect(array.length, 3); @@ -91,7 +97,7 @@ void main() { }, throwsRangeError); }); }); - test("Java short array", () { + testRunner("Java short array", () { using((arena) { final array = JArray(JShort.type, 3)..deletedIn(arena); expect(array.length, 3); @@ -116,7 +122,7 @@ void main() { }, throwsRangeError); }); }); - test("Java int array", () { + testRunner("Java int array", () { using((arena) { final array = JArray(JInt.type, 3)..deletedIn(arena); expect(array.length, 3); @@ -142,7 +148,7 @@ void main() { }); }); const epsilon = 1e-6; - test("Java float array", () { + testRunner("Java float array", () { using((arena) { final array = JArray(JFloat.type, 3)..deletedIn(arena); expect(array.length, 3); @@ -167,7 +173,7 @@ void main() { }, throwsRangeError); }); }); - test("Java double array", () { + testRunner("Java double array", () { using((arena) { final array = JArray(JDouble.type, 3)..deletedIn(arena); expect(array.length, 3); @@ -192,7 +198,7 @@ void main() { }, throwsRangeError); }); }); - test("Java string array", () { + testRunner("Java string array", () { using((arena) { final array = JArray(JString.type, 3)..deletedIn(arena); expect(array.length, 3); @@ -227,7 +233,7 @@ void main() { }, throwsRangeError); }); }); - test("Java object array", () { + testRunner("Java object array", () { using((arena) { final array = JArray(JObject.type, 3)..deletedIn(arena); expect(array.length, 3); @@ -236,7 +242,7 @@ void main() { expect(array[2].reference, nullptr); }); }); - test("Java 2d array", () { + testRunner("Java 2d array", () { using((arena) { final array = JArray(JInt.type, 3)..deletedIn(arena); array[0] = 1; @@ -256,7 +262,7 @@ void main() { expect(twoDimArray[2][2], 4); }); }); - test("JArray.filled", () { + testRunner("JArray.filled", () { using((arena) { final string = "abc".toJString()..deletedIn(arena); final array = JArray.filled(3, string)..deletedIn(arena); diff --git a/pkgs/jni/test/jobject_test.dart b/pkgs/jni/test/jobject_test.dart index b055f7d6c..e951002ce 100644 --- a/pkgs/jni/test/jobject_test.dart +++ b/pkgs/jni/test/jobject_test.dart @@ -10,6 +10,10 @@ import 'package:test/test.dart'; import 'package:jni/jni.dart'; +import 'test_util/test_util.dart'; + +const maxLongInJava = 9223372036854775807; + void main() { // Don't forget to initialize JNI. if (!Platform.isAndroid) { @@ -19,17 +23,20 @@ void main() { // TODO(#51): Support destroying and reinstantiating JVM. } } + run(testRunner: test); +} +void run({required TestRunnerCallback testRunner}) { // The API based on JniEnv is intended to closely mimic C API of JNI, // And thus can be too verbose for simple experimenting and one-off uses // JObject API provides an easier way to perform some common operations. // // However, if binding generation using jnigen is possible, that should be // the first choice. - test("Long.intValue() using JObject", () { - // JniClass wraps a local class reference, and + testRunner("Long.intValue() using JObject", () { + // JClass wraps a local class reference, and // provides convenience functions. - final longClass = Jni.findJniClass("java/lang/Long"); + final longClass = Jni.findJClass("java/lang/Long"); // looks for a constructor with given signature. // equivalently you can lookup a method with name @@ -44,15 +51,15 @@ void main() { final intValue = long.callMethodByName("intValue", "()I", []); expect(intValue, equals(176)); - // delete any JObject and JniClass instances using .delete() after use. + // delete any JObject and JClass instances using .delete() after use. // Deletion is not strictly required since JNI objects / classes have // a NativeFinalizer. But deleting them after use is a good practice. long.delete(); longClass.delete(); }); - test("call a static method using JniClass APIs", () { - final integerClass = Jni.findJniClass("java/lang/Integer"); + testRunner("call a static method using JClass APIs", () { + final integerClass = Jni.findJClass("java/lang/Integer"); final result = integerClass.callStaticMethodByName( "toHexString", "(I)Ljava/lang/String;", [JValueInt(31)]); @@ -68,8 +75,8 @@ void main() { integerClass.delete(); }); - test("Call method with null argument, expect exception", () { - final integerClass = Jni.findJniClass("java/lang/Integer"); + testRunner("Call method with null argument, expect exception", () { + final integerClass = Jni.findJClass("java/lang/Integer"); expect( () => integerClass.callStaticMethodByName( "parseInt", "(Ljava/lang/String;)I", [nullptr]), @@ -77,21 +84,25 @@ void main() { integerClass.delete(); }); - test("Try to find a non-exisiting class, expect exception", () { - expect(() => Jni.findJniClass("java/lang/NotExists"), throwsException); - }); + // Skip this test on Android integration test because it fails there, possibly + // due to a CheckJNI precondition check. + if (!Platform.isAndroid) { + testRunner("Try to find a non-exisiting class, expect exception", () { + expect(() => Jni.findJClass("java/lang/NotExists"), throwsException); + }); + } /// callMethodByName will be expensive if making same call many times /// Use getMethodID to get a method ID and use it in subsequent calls - test("Example for using getMethodID", () { - final longClass = Jni.findJniClass("java/lang/Long"); + testRunner("Example for using getMethodID", () { + final longClass = Jni.findJClass("java/lang/Long"); final bitCountMethod = longClass.getStaticMethodID("bitCount", "(J)I"); // Use newInstance if you want only one instance. // It finds the class, gets constructor ID and constructs an instance. final random = Jni.newInstance("java/util/Random", "()V", []); - // You don't need a JniClass reference to get instance method IDs + // You don't need a JClass reference to get instance method IDs final nextIntMethod = random.getMethodID("nextInt", "(I)I"); for (int i = 0; i < 100; i++) { @@ -108,28 +119,28 @@ void main() { }); // One-off invocation of static method in single call. - test("invoke_", () { + testRunner("invoke_", () { final m = Jni.invokeStaticMethod("java/lang/Short", "compare", "(SS)I", [JValueShort(1234), JValueShort(1324)]); expect(m, equals(1234 - 1324)); }); - test("Java char from string", () { + testRunner("Java char from string", () { final m = Jni.invokeStaticMethod("java/lang/Character", "isLowerCase", "(C)Z", [JValueChar.fromString('X')]); expect(m, isFalse); }); // One-off access of static field in single call. - test("Get static field directly", () { + testRunner("Get static field directly", () { final maxLong = Jni.retrieveStaticField( "java/lang/Short", "MAX_VALUE", "S", JniCallType.shortType); expect(maxLong, equals(32767)); }); // Use callStringMethod if all you care about is a string result - test("callStaticStringMethod", () { - final longClass = Jni.findJniClass("java/lang/Long"); + testRunner("callStaticStringMethod", () { + final longClass = Jni.findJClass("java/lang/Long"); const n = 1223334444; final strFromJava = longClass.callStaticMethodByName( "toOctalString", "(J)Ljava/lang/String;", [n]); @@ -137,11 +148,11 @@ void main() { longClass.delete(); }); - // In JObject, JniClass, and retrieve_/invoke_ methods + // In JObject, JClass, and retrieve_/invoke_ methods // you can also pass Dart strings, apart from range of types // allowed by Jni.jvalues // They will be converted automatically. - test( + testRunner( "Passing strings in arguments", () { final out = Jni.retrieveStaticField( @@ -154,26 +165,26 @@ void main() { }, ); - test("Passing strings in arguments 2", () { + testRunner("Passing strings in arguments 2", () { final twelve = Jni.invokeStaticMethod("java/lang/Byte", "parseByte", "(Ljava/lang/String;)B", ["12"], JniCallType.byteType); expect(twelve, equals(12)); }); // You can use() method on JObject for using once and deleting. - test("use() method", () { + testRunner("use() method", () { final randomInt = Jni.newInstance("java/util/Random", "()V", []).use( (random) => random.callMethodByName("nextInt", "(I)I", [JValueInt(15)])); expect(randomInt, lessThan(15)); }); - // The JObject and JniClass have NativeFinalizer. However, it's possible to + // The JObject and JClass have NativeFinalizer. However, it's possible to // explicitly use `Arena`. - test('Using arena', () { + testRunner('Using arena', () { final objects = []; using((arena) { - final r = Jni.findJniClass('java/util/Random')..deletedIn(arena); + final r = Jni.findJClass('java/util/Random')..deletedIn(arena); final ctor = r.getCtorID("()V"); for (int i = 0; i < 10; i++) { objects.add(r.newInstance(ctor, [])..deletedIn(arena)); @@ -184,14 +195,15 @@ void main() { } }); - test("enums", () { + testRunner("enums", () { // Don't forget to escape $ in nested type names final ordinal = Jni.retrieveStaticField( "java/net/Proxy\$Type", "HTTP", "Ljava/net/Proxy\$Type;") .use((f) => f.callMethodByName("ordinal", "()I", [])); expect(ordinal, equals(1)); }); - test("casting", () { + + testRunner("casting", () { using((arena) { final str = "hello".toJString()..deletedIn(arena); final obj = str.castTo(JObject.type)..deletedIn(arena); @@ -204,16 +216,44 @@ void main() { }); }); - test("Isolate", () { + testRunner("Isolate", () { Isolate.spawn(doSomeWorkInIsolate, null); }); + + testRunner("Methods rethrow exceptions in Java as JniException", () { + expect( + () => Jni.invokeStaticMethod( + "java/lang/Integer", "parseInt", "(Ljava/lang/String;)I", ["X"]), + throwsA(isA()), + ); + }); + + testRunner("Passing long integer values to JNI", () { + final maxLongStr = Jni.invokeStaticMethod( + "java/lang/Long", + "toString", + "(J)Ljava/lang/String;", + [maxLongInJava], + ); + expect(maxLongStr, equals('$maxLongInJava')); + }); + + testRunner('Returning long integers from JNI', () { + final maxLong = Jni.retrieveStaticField( + "java/lang/Long", + "MAX_VALUE", + "J", + JniCallType.longType, + ); + expect(maxLong, equals(maxLongInJava)); + }); } void doSomeWorkInIsolate(Void? _) { // On standalone target, make sure to call [setDylibDir] before accessing - // any JNI function. + // any JNI function in a new isolate. // - // otherwise getInstance will throw a "library not found" exception. + // otherwise subsequent JNI calls will throw a "library not found" exception. Jni.setDylibDir(dylibDir: "build/jni_libs"); final random = Jni.newInstance("java/util/Random", "()V", []); // final r = random.callMethodByName("nextInt", "(I)I", [256]); diff --git a/pkgs/jni/test/test_util/test_util.dart b/pkgs/jni/test/test_util/test_util.dart new file mode 100644 index 000000000..40d86ebaf --- /dev/null +++ b/pkgs/jni/test/test_util/test_util.dart @@ -0,0 +1,9 @@ +// 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. + +typedef TestCaseCallback = void Function(); +typedef TestRunnerCallback = void Function( + String description, + TestCaseCallback test, +); diff --git a/pkgs/jni/test/type_test.dart b/pkgs/jni/test/type_test.dart index 0f7f5bfcc..ecdcf109a 100644 --- a/pkgs/jni/test/type_test.dart +++ b/pkgs/jni/test/type_test.dart @@ -8,6 +8,8 @@ import 'dart:io'; import 'package:jni/jni.dart'; import 'package:test/test.dart'; +import 'test_util/test_util.dart'; + // Mocking this type tree: // JObject // | \ @@ -209,8 +211,11 @@ void main() { // TODO(#51): Support destroying and reinstantiating JVM. } } + run(testRunner: test); +} - test('lowestCommonSuperType', () { +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); @@ -219,7 +224,7 @@ void main() { JObject.type); }); - test('Mocked type tree', () { + testRunner('Mocked type tree', () { // As a reminder, this is how the type tree looks like: // JObject // | \ diff --git a/pkgs/jni/third_party/ffigen_patch_jni/.github/workflows/test-package.yml b/pkgs/jni/third_party/ffigen_patch_jni/.github/workflows/test-package.yml deleted file mode 100644 index 1b6b494b7..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/.github/workflows/test-package.yml +++ /dev/null @@ -1,78 +0,0 @@ -name: Dart CI - -on: - # Run on PRs and pushes to the default branch. - push: - branches: [ master, stable] - pull_request: - branches: [ master, stable] - schedule: - - cron: "0 0 * * 0" - -env: - PUB_ENVIRONMENT: bot.github - -jobs: - # Check code formatting and static analysis on a single OS (macos). - analyze: - runs-on: macos-latest - strategy: - fail-fast: false - matrix: - sdk: [stable] - steps: - - uses: actions/checkout@v2 - - uses: dart-lang/setup-dart@v1.0 - 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: Build test dylib and bindings - run: dart test/setup.dart - - name: Analyze code - run: dart analyze --fatal-infos - if: always() && steps.install.outcome == 'success' - - test: - needs: analyze - # This job requires clang-10 which is the default on 20.04 - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - uses: dart-lang/setup-dart@v1.0 - with: - sdk: stable - - name: Install dependencies - run: dart pub get - - name: Install libclang-10-dev - run: sudo apt-get install libclang-10-dev - - name: Build test dylib and bindings - run: dart test/setup.dart - - name: Run VM tests - run: dart test --platform vm - - mac-test: - needs: analyze - runs-on: macos-latest - steps: - - uses: actions/checkout@v2 - - uses: dart-lang/setup-dart@v1.0 - with: - sdk: stable - - name: Install dependencies - run: dart pub get - - name: Build test dylib and bindings - run: dart test/setup.dart - - name: Run VM tests - run: dart test --platform vm - - name: Collect coverage - run: ./tool/coverage.sh - - name: Upload coverage - uses: coverallsapp/github-action@v1.1.2 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - path-to-lcov: lcov.info diff --git a/pkgs/jni/third_party/ffigen_patch_jni/.gitignore b/pkgs/jni/third_party/ffigen_patch_jni/.gitignore deleted file mode 100644 index 71c0ba13d..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/.gitignore +++ /dev/null @@ -1,41 +0,0 @@ -# See https://dart.dev/guides/libraries/private-files - -# Files and directories created by pub. -.dart_tool/ -.packages -pubspec.lock - -# IDE and debugger files. -.clangd -.gdb_history -.history -.vscode -compile_commands.json - -# Directory created by dartdoc. -# If you don't generate documentation locally you can remove this line. -doc/api/ - -# Avoid committing generated Javascript files: -*.dart.js -*.info.json # Produced by the --dump-info flag. -*.js # When generated by dart2js. Don't specify *.js if your - # project includes source files written in JavaScript. -*.js_ -*.js.deps -*.js.map - -# Generated shared libraries. -*.so -*.so.* -*.dylib -*.dll - -# Directory for quick experiments. -experiments/ - -# Files generated by tests for debugging purposes. -test/debug_generated/* -!test/debug_generated/readme.md -lcov.info -coverage.json diff --git a/pkgs/jni/third_party/ffigen_patch_jni/AUTHORS b/pkgs/jni/third_party/ffigen_patch_jni/AUTHORS deleted file mode 100644 index 4f334e852..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/AUTHORS +++ /dev/null @@ -1,8 +0,0 @@ -# Below is a list of people and organizations that have contributed -# to the Dart project. Names should be added to the list like so: -# -# Name/Organization - -Google LLC - -Prerak Mann diff --git a/pkgs/jni/third_party/ffigen_patch_jni/CHANGELOG.md b/pkgs/jni/third_party/ffigen_patch_jni/CHANGELOG.md deleted file mode 100644 index 83edcb08f..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/CHANGELOG.md +++ /dev/null @@ -1,291 +0,0 @@ -# 6.0.1 - -- Replace path separators in `include-directives` before matching file names. - -# 6.0.0 -- Removed config `dart-bool`. Booleans are now always generated with `bool` -and `ffi.Bool` as it's Dart and C Type respectively. - -# 5.0.1 - -- Add a the xcode tools llvm as default path on MacOS. - -# 5.0.0 - -- Stable release targeting Dart 2.17, supporting ABI-specific integer types. -- _EXPERIMENTAL_ support for ObjectiveC on MacOS hosts. The API and output - might change at any point. Feel free to report bugs if encountered. - -# 5.0.0-dev.1 -- Fixed invalid default dart types being generated for `size_t` and `wchar_t`. - -# 5.0.0-dev.0 -- Added support for generating ABI Specific integers. -- Breaking: removed config keys - `size-map` and `typedef-map`. -- Added config keys - `library-imports` and `type-map`. - -# 4.1.3 -- Analyzer fixes. - -# 4.1.2 -- Added fix for empty include list to exclude all - -# 4.1.1 -- Added fix for errors due to name collision between member name -and type name used internally in structs/unions. - -# 4.1.0 -- Add config key `functions -> leaf` for specifying `isLeaf:true` for functions. - -# 4.0.0 -- Release for Dart SDK `>=2.14`. - -# 4.0.0-dev.2 -- Added config key `functions -> expose-typedefs` to expose the typedef -to Native and Dart type. -- Config key `function`->`symbol-address` no longer exposes the typedef -to Native type. Use `expose-typedefs` to get the native type. - -# 4.0.0-dev.1 -- This package now targets package:lints for the generated code. The generated -code uses C symbol names as is. Use either `// ignore_for_file: lintRule1, lintRule2` -in the `preamble`, or rename the symbols to make package:lints happy. -- Name collisions are now resolved by suffixing `` instead of `_`. - -# 4.0.0-dev.0 -- Added support for generating typedefs (_referred_ typedefs only). - - - - - - - - - -
    Example C CodeGenerated Dart typedef
    - -```C++ -typedef struct A{ - ... -} TA, *PA; - -TA func(PA ptr); -``` - - -```dart -class A extends ffi.Struct {...} -typedef TA = A; -typedef PA = ffi.Pointer; -TA func(PA ptr){...} -``` -
    - -- All declarations that are excluded by the user are now only included if being -used somewhere. -- Improved struct/union include/exclude. These declarations can now be targetted -by their actual name, or if they are unnamed then by the name of the first -typedef that refers to them. - -# 3.1.0-dev.1 -- Users can now specify exact path to dynamic library in `llvm-path`. - -# 3.1.0-dev.0 -- Added support for generating unions. - -# 3.0.0 -- Release for dart sdk `>=2.13` (Support for packed structs and inline arrays). - -# 3.0.0-beta.0 -- Added support for inline arrays in `Struct`s. -- Remove config key `array-workaround`. -- Remove deprecated key `llvm-lib` from config, Use `llvm-path` instead. - -# 2.5.0-beta.1 -- Added support for `Packed` structs. Packed annotations are generated -automatically but can be overriden using `structs -> pack` config. -- Updated sdk constraints to `>=2.13.0-211.6.beta`. - -# 2.4.2 -- Fix issues due to declarations having duplicate names. -- Fix name conflict of declaration with ffi library prefix. -- Fix `char` not being recognized on platforms where it's unsigned by default. - -# 2.4.1 -- Added `/usr/lib` to default dynamic library location for linux. - -# 2.4.0 -- Added new config key `llvm-path` that accepts a list of `path/to/llvm`. -- Deprecated config key `llvm-lib`. - -# 2.3.0 -- Added config key `compiler-opts-automatic -> macos -> include-c-standard-library` -(default: true) to automatically find and add C standard library on macOS. -- Allow passing list of string to config key `compiler-opts`. - -# 2.2.5 -- Added new command line flag `--compiler-opts` to the command line tool. - -# 2.2.4 -- Fix `sort: true` not working. -- Fix extra `//` or `///` in comments when using `comments -> style`: `full`. - -# 2.2.3 -- Added new subkey `dependency-only` (options - `full (default) | opaque`) under `structs`. -When set to `opaque`, ffigen will generate empty `Opaque` structs if structs -were excluded in config (i.e added because they were a dependency) and -only passed by reference(pointer). - -# 2.2.2 -- Fixed generation of empty opaque structs due to forward declarations in header files. - -# 2.2.1 -- Fixed generation of duplicate constants suffixed with `_` when using multiple entry points. - -# 2.2.0 -- Added subkey `symbol-address` to expose native symbol pointers for `functions` and `globals`. - -# 2.1.0 -- Added a new named constructor `NativeLibrary.fromLookup()` to support dynamic linking. -- Updated dart SDK constraints to latest stable version `2.12.0`. - -# 2.0.3 -- Ignore typedef to struct pointer when possible. -- Recursively create directories for output file. - -# 2.0.2 -- Fixed illegal use of `const` in name, crash due to unnamed inline structs and -structs having `Opaque` members. - -# 2.0.1 -- Switch to preview release of `package:quiver`. - -# 2.0.0 -- Upgraded all dependencies. `package:ffigen` now runs with sound null safety. - -# 2.0.0-dev.6 -- Functions marked `inline` are now skipped. - -# 2.0.0-dev.5 -- Use `Opaque` for representing empty `Struct`s. - -# 2.0.0-dev.4 -- Add support for parsing and generating globals. - -# 2.0.0-dev.3 -- Removed the usage of `--no-sound-null-safety` flag. - -# 2.0.0-dev.2 -- Removed setup phase for ffigen. Added new optional config key `llvm-lib` -to specify path to `llvm/lib` folder. - -# 2.0.0-dev.1 -- Added support for passing and returning struct by value in functions. - -# 2.0.0-dev.0 -- Added support for Nested structs. - -# 2.0.0-nullsafety.1 -- Removed the need for `--no-sound-null-safety` flag. - -# 2.0.0-nullsafety.0 -- Migrated to (unsound) null safety. - -# 1.2.0 -- Added support for `Dart_Handle` from `dart_api.h`. - -# 1.1.0 -- `typedef-map` can now be used to map a typedef name to a native type directly. - -# 1.0.6 -- Fixed missing typedefs nested in another typedef's return types. - -# 1.0.5 -- Fixed issues with generating macros of type `double.Infinity` and `double.NaN`. - -# 1.0.4 -- Updated code to use `dart format` instead of `dartfmt` for sdk version `>= 2.10.0`. - -# 1.0.3 -- Fixed errors due to extended ASCII and control characters in macro strings. - -# 1.0.2 -- Fix indentation for pub's readme. - -# 1.0.1 -- Fixed generation of `NativeFunction` parameters instead of `Pointer` in type signatures. - -# 1.0.0 -- Bump version to 1.0.0. -- Handle unimplememnted function pointers causing errors. -- Log lexical/semantic issues in headers as SEVERE. - -# 0.3.0 -- Added support for including/excluding/renaming _un-named enums_ using key `unnamed_enums`. - -# 0.2.4+1 -- Minor changes to dylib creation error log. - -# 0.2.4 -- Added support for C booleans as Uint8. -- Added config `dart-bool` (default: true) to use dart bool instead of int in function parameters and return type. - -# 0.2.3+3 -- Wrapper dynamic library version now uses ffigen version from its pubspec.yaml file. - -# 0.2.3+2 -- Handle code formatting using dartfmt by finding dart-sdk. - -# 0.2.3+1 -- Fixed missing typedefs of nested function pointers. - -# 0.2.3 -- Fixed parsing structs with bitfields, all members of structs with bit field members will now be removed. See [#84](https://github.com/dart-lang/ffigen/issues/84) - -# 0.2.2+1 -- Updated `package:meta` version to `^1.1.8` for compatibility with flutter sdk. - -# 0.2.2 -- Fixed multiple generation/skipping of typedef enclosed declarations. -- Typedef names are now given higher preference over inner names, See [#83](https://github.com/dart-lang/ffigen/pull/83). - -# 0.2.1+1 -- Added FAQ to readme. - -# 0.2.1 -- Fixed missing/duplicate typedef generation. - -# 0.2.0 -- Updated header config. Header `entry-points` and `include-directives` are now specified under `headers` key. Glob syntax is allowed. -- Updated declaration `include`/`exclude` config. These are now specified as a list. -- Added Regexp based declaration renaming using `rename` subkey. -- Added Regexp based member renaming for structs, enums and functions using `member-rename` subkey. `prefix` and `prefix-replacement` subkeys have been removed. - -# 0.1.5 -- Added support for parsing macros and anonymous unnamed enums. These are generated as top level constants. - -# 0.1.4 -- Comments config now has a style and length sub keys - `style: doxygen(default) | any`, `length: brief | full(default)`, and can be disabled by passing `comments: false`. - -# 0.1.3 -- Handled function arguments - dart keyword name collision -- Fix travis tests: the dynamic library is created using `pub run ffigen:setup` before running the tests. - -# 0.1.2 -- Fixed wrapper not found error when running `pub run ffigen`. - -# 0.1.1 -- Address pub score: follow dart File conventions, provide documentation, and pass static analysis. - -# 0.1.0 -- Support for Functions, Structs and Enums. -- Glob support for specifying headers. -- HeaderFilter - Include/Exclude declarations from specific header files using name matching. -- Filters - Include/Exclude function, structs and enum declarations using Regexp or Name matching. -- Prefixing - function, structs and enums can have a global prefix. Individual prefix Replacement support using Regexp. -- Comment extraction: full/brief/none -- Support for fixed size arrays in struct. `array-workaround` (if enabled) will generate helpers for accessing fixed size arrays in structs. -- Size for ints can be specified using `size-map` in config. -- Options to disable using supported typedefs (e.g `uint8_t => Uint8`), sort bindings. -- Option to add a raw `preamble` which is included as is in the generated file. diff --git a/pkgs/jni/third_party/ffigen_patch_jni/LICENSE b/pkgs/jni/third_party/ffigen_patch_jni/LICENSE deleted file mode 100644 index 467a98286..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright 2020, the Dart project authors. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - * Neither the name of Google LLC nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/pkgs/jni/third_party/ffigen_patch_jni/README.md b/pkgs/jni/third_party/ffigen_patch_jni/README.md deleted file mode 100644 index 7cd52bfef..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/README.md +++ /dev/null @@ -1,8 +0,0 @@ -#### Developer's Note - -One-off patch of [ffigen](https://github.com/dart-lang/ffigen) for generating bindings of some JNI structs. - -Only changes to ffigen source are made in lib/src/code_generator/compound.dart file. The purpose of these changes is to write the extension methods along with certain types, which make calling function pointer fields easier. - -The modified FFIGEN is used to generate `lib/src/third_party/jni_bindings_generated.dart` using both header files in src/ and third_party/jni.h (the JNI header file from Android NDK). This provides bulk of our interface to JNI through FFI. - diff --git a/pkgs/jni/third_party/ffigen_patch_jni/analysis_options.yaml b/pkgs/jni/third_party/ffigen_patch_jni/analysis_options.yaml deleted file mode 100644 index 29481433b..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/analysis_options.yaml +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (c) 2020, 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. - -include: package:lints/recommended.yaml - -analyzer: - exclude: - - 'test/**_expected*' - # Goldens cannot be generated outside MacOS causing analysis errors. - - test/native_objc_test/** - language: - strict-casts: true - strict-inference: true - -linter: - rules: - # Enabled. - directives_ordering: true - prefer_final_locals: true - duplicate_import: false - prefer_final_in_for_each: true - # Disabled. - constant_identifier_names: false diff --git a/pkgs/jni/third_party/ffigen_patch_jni/bin/ffigen.dart b/pkgs/jni/third_party/ffigen_patch_jni/bin/ffigen.dart deleted file mode 100644 index 6156ed0a2..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/bin/ffigen.dart +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright (c) 2020, 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 'package:ffigen/src/executables/ffigen.dart'; diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/ffigen.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/ffigen.dart deleted file mode 100644 index 3425eecb7..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/ffigen.dart +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) 2020, 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. - -/// A bindings generator for dart. -/// -/// See complete usage at - https://pub.dev/packages/ffigen. -library ffigen; - -export 'src/code_generator.dart' show Library; -export 'src/config_provider.dart' show Config; -export 'src/header_parser.dart' show parse; diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/README.md b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/README.md deleted file mode 100644 index 2b20f84e8..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/README.md +++ /dev/null @@ -1,41 +0,0 @@ -# **_package:ffigen_**: Internal Working -## Table of Contents - -1. [Overview](#overview) -2. [LibClang](#LibClang) - 1. [Bindings](#Bindings) -3. [Scripts](#scripts) - 1. [ffigen.dart](#ffigen.dart) -4. [Components](#components) - 1. [Config Provider](#Config-Provider) - 2. [Header Parser](#Header-Parser) - 3. [Code Generator](#Code-Generator) -# Overview -`package:ffigen` simplifies the process of generating `dart:ffi` bindings from C header files. It is simple to use, with the input being a small YAML config file. It requires LLVM (9+) to work. This document tries to give a complete overview of every component without going into too many details about every single class/file. -# LibClang -`package:ffigen` binds to LibClang using `dart:ffi` for parsing C header files. -## Bindings -The config file for generating bindings is `tool/libclang_config.yaml`. The bindings are generated to `lib/src/header_parser/clang_bindings/clang_bindings.dart`. These are used by [Header Parser](#header-parser) for calling libclang functions. -# Scripts -## ffigen.dart -This is the main entry point for the user- `dart run ffigen`. -- Command-line options: - - `--verbose`: Sets log level. - - `--config`: Specifies a config file. -- The internal modules are called by `ffigen.dart` in the following way: -- `ffigen.dart` will try to find dynamic library in default locations. If that fails, the user must excplicitly specify location in ffigen's config under the key `llvm-path`. - - It first creates a `Config` object from an input Yaml file. This is used by other modules. - - The `parse` method is then invoked to generate a `Library` object. - - Finally, the code is generated from the `Library` object to the specified file. -# Components -## Config Provider -The Config Provider holds all the configurations required by other modules. -- Config Provider handles validation and extraction of configurations from YAML files. -- Config Provider converts configurations to the format required by other modules. This object is passed around to every other module. -## Header Parser -The Header Parser parses C header files and converts them into a `Library` object. -- Header Parser handles including/excluding/renaming of declarations. -- Header Parser also filters out any _unimplemented_ or _unsupported_ declarations before generating a `Library` object. -## Code Generator -The Code Generator generates the actual string bindings. -- Code generator handles all external name collisions, while internal name conflicts are handled by each specific `Binding`. -- Code Generator also handles how workarounds for arrays and bools are generated. diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator.dart deleted file mode 100644 index 82b2ed6b3..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator.dart +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2020, 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 FFI bindings for a given [Library]. -library code_generator; - -export 'code_generator/binding.dart'; -export 'code_generator/compound.dart'; -export 'code_generator/constant.dart'; -export 'code_generator/enum_class.dart'; -export 'code_generator/func.dart'; -export 'code_generator/func_type.dart'; -export 'code_generator/global.dart'; -export 'code_generator/handle.dart'; -export 'code_generator/imports.dart'; -export 'code_generator/library.dart'; -export 'code_generator/native_type.dart'; -export 'code_generator/objc_block.dart'; -export 'code_generator/objc_built_in_functions.dart'; -export 'code_generator/objc_interface.dart'; -export 'code_generator/pointer.dart'; -export 'code_generator/struct.dart'; -export 'code_generator/type.dart'; -export 'code_generator/typealias.dart'; -export 'code_generator/union.dart'; diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/binding.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/binding.dart deleted file mode 100644 index 2e2f189ef..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/binding.dart +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (c) 2020, 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 'binding_string.dart'; -import 'writer.dart'; - -/// Base class for all Bindings. -/// -/// Do not extend directly, use [LookUpBinding] or [NoLookUpBinding]. -abstract class Binding { - /// Holds the Unified Symbol Resolution string obtained from libclang. - final String usr; - - /// The name as it was in C. - final String originalName; - - /// Binding name to generate, may get changed to resolve name conflicts. - String name; - - final String? dartDoc; - final bool isInternal; - - Binding({ - required this.usr, - required this.originalName, - required this.name, - this.dartDoc, - this.isInternal = false, - }); - - /// Get all dependencies, including itself and save them in [dependencies]. - void addDependencies(Set dependencies); - - /// Converts a Binding to its actual string representation. - /// - /// Note: This does not print the typedef dependencies. - /// Must call [getTypedefDependencies] first. - BindingString toBindingString(Writer w); -} - -/// Base class for bindings which look up symbols in dynamic library. -abstract class LookUpBinding extends Binding { - LookUpBinding({ - String? usr, - String? originalName, - required String name, - String? dartDoc, - bool isInternal = false, - }) : super( - usr: usr ?? name, - originalName: originalName ?? name, - name: name, - dartDoc: dartDoc, - isInternal: isInternal, - ); -} - -/// Base class for bindings which don't look up symbols in dynamic library. -abstract class NoLookUpBinding extends Binding { - NoLookUpBinding({ - String? usr, - String? originalName, - required String name, - String? dartDoc, - bool isInternal = false, - }) : super( - usr: usr ?? name, - originalName: originalName ?? name, - name: name, - dartDoc: dartDoc, - isInternal: isInternal, - ); -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/binding_string.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/binding_string.dart deleted file mode 100644 index decfd6fc9..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/binding_string.dart +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2020, 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. - -/// A Binding's String representation. -class BindingString { - // Meta data, (not used for generation). - final BindingStringType type; - final String string; - - const BindingString({required this.type, required this.string}); - - @override - String toString() => string; -} - -/// A [BindingString]'s type. -enum BindingStringType { - func, - struct, - union, - constant, - global, - enumClass, - typeDef, - objcInterface, - objcBlock, -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/compound.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/compound.dart deleted file mode 100644 index 3d477e8ff..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/compound.dart +++ /dev/null @@ -1,279 +0,0 @@ -// Copyright (c) 2021, 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:ffigen/src/code_generator.dart'; - -import 'binding_string.dart'; -import 'utils.dart'; -import 'writer.dart'; - -// Very specific to JNI: Here `X` is vtable class if X contains function pointer -// members invoked with first argument of type `X**`. -const vtableClasses = {"JNIInvokeInterface": "JavaVM"}; - -// Y is extension class if it contains function pointer fields which are -// otherwise equivalent to normal functions, and just packed in a structure -// for convenience. -const extensionClasses = {'GlobalJniEnv', 'JniAccessors'}; - -const methodNameRenames = {"throw": "throwException"}; - -enum CompoundType { struct, union } - -/// A binding for Compound type - Struct/Union. -abstract class Compound extends BindingType { - /// Marker for if a struct definition is complete. - /// - /// A function can be safely pass this struct by value if it's complete. - bool isIncomplete; - - List members; - - bool get isOpaque => members.isEmpty; - - /// Value for `@Packed(X)` annotation. Can be null (no packing), 1, 2, 4, 8, - /// or 16. - /// - /// Only supported for [CompoundType.struct]. - int? pack; - - /// Marker for checking if the dependencies are parsed. - bool parsedDependencies = false; - - CompoundType compoundType; - bool get isStruct => compoundType == CompoundType.struct; - bool get isUnion => compoundType == CompoundType.union; - - Compound({ - String? usr, - String? originalName, - required String name, - required this.compoundType, - this.isIncomplete = false, - this.pack, - String? dartDoc, - List? members, - bool isInternal = false, - }) : members = members ?? [], - super( - usr: usr, - originalName: originalName, - name: name, - dartDoc: dartDoc, - isInternal: isInternal, - ); - - factory Compound.fromType({ - required CompoundType type, - String? usr, - String? originalName, - required String name, - bool isIncomplete = false, - int? pack, - String? dartDoc, - List? members, - }) { - switch (type) { - case CompoundType.struct: - return Struct( - usr: usr, - originalName: originalName, - name: name, - isIncomplete: isIncomplete, - pack: pack, - dartDoc: dartDoc, - members: members, - ); - case CompoundType.union: - return Union( - usr: usr, - originalName: originalName, - name: name, - isIncomplete: isIncomplete, - pack: pack, - dartDoc: dartDoc, - members: members, - ); - } - } - - List _getArrayDimensionLengths(Type type) { - final array = []; - var startType = type; - while (startType is ConstantArray) { - array.add(startType.length); - startType = startType.child; - } - return array; - } - - String _getInlineArrayTypeString(Type type, Writer w) { - if (type is ConstantArray) { - return '${w.ffiLibraryPrefix}.Array<' - '${_getInlineArrayTypeString(type.child, w)}>'; - } - return type.getCType(w); - } - - @override - BindingString toBindingString(Writer w) { - final s = StringBuffer(); - final es = StringBuffer(); - final isVtable = vtableClasses.containsKey(name); - final isExt = extensionClasses.contains(name); - final toExtend = isVtable || isExt; - late String ptrTypeString; // need this later - final enclosingClassName = name; - if (toExtend) { - final ffi = w.ffiLibraryPrefix; - if (isVtable) { - final ptrType = vtableClasses[name]!; - ptrTypeString = "$ffi.Pointer<$ptrType>"; - } else { - ptrTypeString = "$ffi.Pointer<$name>"; - } - es.write( - "extension ${enclosingClassName}Extension on $ptrTypeString {\n"); - } - if (dartDoc != null) { - s.write(makeDartDoc(dartDoc!)); - } - final voidPointer = - "${w.ffiLibraryPrefix}.Pointer<${w.ffiLibraryPrefix}.Void>"; - - /// Adding [enclosingClassName] because dart doesn't allow class member - /// to have the same name as the class. - final localUniqueNamer = UniqueNamer({enclosingClassName}); - - /// Marking type names because dart doesn't allow class member to have the - /// same name as a type name used internally. - for (final m in members) { - localUniqueNamer.markUsed(m.type.getDartType(w)); - } - - /// Write @Packed(X) annotation if struct is packed. - if (isStruct && pack != null) { - s.write('@${w.ffiLibraryPrefix}.Packed($pack)\n'); - } - final dartClassName = isStruct ? 'Struct' : 'Union'; - // Write class declaration. - s.write('class $enclosingClassName extends '); - s.write('${w.ffiLibraryPrefix}.${isOpaque ? 'Opaque' : dartClassName}{\n'); - const depth = ' '; - for (final m in members) { - m.name = localUniqueNamer.makeUnique(m.name); - if (m.type is ConstantArray) { - s.write('$depth@${w.ffiLibraryPrefix}.Array.multi('); - s.write('${_getArrayDimensionLengths(m.type)})\n'); - s.write('${depth}external ${_getInlineArrayTypeString(m.type, w)} '); - s.write('${m.name};\n\n'); - } else { - if (m.dartDoc != null) { - s.write(depth + '/// '); - s.writeAll(m.dartDoc!.split('\n'), '\n' + depth + '/// '); - s.write('\n'); - } - if (!sameDartAndCType(m.type, w)) { - s.write('$depth@${m.type.getCType(w)}()\n'); - } - final isPointer = (m.type is PointerType); - final isFunctionPointer = - isPointer && (m.type as PointerType).child is NativeFunc; - - final hasVarArgListParam = isFunctionPointer && m.name.endsWith('V'); - - if (toExtend && isFunctionPointer) { - final nf = (m.type as PointerType).child as NativeFunc; - final fnType = nf.type as FunctionType; - - if (hasVarArgListParam) { - s.write('${depth}external $voidPointer _${m.name};\n\n'); - continue; - } - - s.write('${depth}external ${m.type.getDartType(w)} ${m.name};\n\n'); - final extensionParams = fnType.parameters.toList(); // copy - final implicitThis = isVtable; - if (implicitThis) { - extensionParams.removeAt(0); - } - if (m.dartDoc != null) { - es.write('$depth/// '); - es.writeAll(m.dartDoc!.split('\n'), '\n$depth/// '); - es.write('\n'); - es.write("$depth///\n" - "$depth/// This is an automatically generated extension method\n"); - } - es.write("$depth${fnType.returnType.getDartType(w)} ${m.name}("); - final visibleParams = []; - final actualParams = [if (implicitThis) "this"]; - final callableFnType = fnType.getDartType(w); - - for (int i = 0; i < extensionParams.length; i++) { - final p = extensionParams[i]; - final paramName = p.name.isEmpty - ? (m.params != null - ? m.params![i + (implicitThis ? 1 : 0)] - : "arg$i") - : p.name; - visibleParams.add("${p.type.getDartType(w)} $paramName"); - actualParams.add(paramName); - } - - es.write("${visibleParams.join(', ')}) {\n"); - final ref = isVtable ? 'value.ref' : 'ref'; - es.write( - "$depth${depth}return $ref.${m.name}.asFunction<$callableFnType>()("); - es.write(actualParams.join(", ")); - es.write(");\n$depth}\n\n"); - } else { - final memberName = hasVarArgListParam ? '_${m.name}' : m.name; - final memberType = - hasVarArgListParam ? voidPointer : m.type.getDartType(w); - s.write('${depth}external $memberType $memberName;\n\n'); - } - } - } - if (toExtend) { - es.write("}\n\n"); - } - s.write('}\n\n'); - - return BindingString( - type: isStruct ? BindingStringType.struct : BindingStringType.union, - string: s.toString() + es.toString()); - } - - @override - void addDependencies(Set dependencies) { - if (dependencies.contains(this)) return; - - dependencies.add(this); - for (final m in members) { - m.type.addDependencies(dependencies); - } - } - - @override - bool get isIncompleteCompound => isIncomplete; - - @override - String getCType(Writer w) => name; -} - -class Member { - final String? dartDoc; - final String originalName; - String name; - final Type type; - final List? params; - - Member({ - String? originalName, - required this.name, - required this.type, - this.dartDoc, - this.params, - }) : originalName = originalName ?? name; -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/constant.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/constant.dart deleted file mode 100644 index 8fd719169..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/constant.dart +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) 2020, 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 'binding.dart'; -import 'binding_string.dart'; -import 'utils.dart'; -import 'writer.dart'; - -/// A simple Constant. -/// -/// Expands to - -/// ```dart -/// const = ; -/// ``` -/// -/// Example - -/// ```dart -/// const int name = 10; -/// ``` -class Constant extends NoLookUpBinding { - /// The rawType is pasted as it is. E.g 'int', 'String', 'double' - final String rawType; - - /// The rawValue is pasted as it is. - /// - /// Put quotes if type is a string. - final String rawValue; - - Constant({ - String? usr, - String? originalName, - required String name, - String? dartDoc, - required this.rawType, - required this.rawValue, - }) : super( - usr: usr, - originalName: originalName, - name: name, - dartDoc: dartDoc, - ); - - @override - BindingString toBindingString(Writer w) { - final s = StringBuffer(); - final constantName = name; - - if (dartDoc != null) { - s.write(makeDartDoc(dartDoc!)); - } - - s.write('\nconst $rawType $constantName = $rawValue;\n\n'); - - return BindingString( - type: BindingStringType.constant, string: s.toString()); - } - - @override - void addDependencies(Set dependencies) { - if (dependencies.contains(this)) return; - - dependencies.add(this); - } -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/dart_keywords.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/dart_keywords.dart deleted file mode 100644 index 93d5877ad..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/dart_keywords.dart +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) 2020, 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. - -/// Dart reserved keywords, used for resolving conflict with a name. -/// -/// Source: https://dart.dev/guides/language/language-tour#keywords. -const keywords = { - 'abstract', - 'as', - 'assert', - 'async', - 'await', - 'break', - 'case', - 'catch', - 'class', - 'const', - 'continue', - 'covariant', - 'default', - 'deferred', - 'do', - 'dynamic', - 'else', - 'enum', - 'export', - 'extends', - 'extension', - 'external', - 'factory', - 'false', - 'final', - 'finally', - 'for', - 'Function', - 'get', - 'hide', - 'if', - 'implements', - 'import', - 'in', - 'interface', - 'is', - 'late', - 'library', - 'mixin', - 'new', - 'null', - 'on', - 'operator', - 'part', - 'required', - 'rethrow', - 'return', - 'set', - 'show', - 'static', - 'super', - 'switch', - 'sync', - 'this', - 'throw', - 'true', - 'try', - 'typedef', - 'var', - 'void', - 'while', - 'with', - 'yield', -}; diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/enum_class.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/enum_class.dart deleted file mode 100644 index 4e8ec3aac..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/enum_class.dart +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright (c) 2020, 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 'binding.dart'; -import 'binding_string.dart'; -import 'native_type.dart'; -import 'type.dart'; -import 'utils.dart'; -import 'writer.dart'; - -/// A binding for enums in C. -/// -/// For a C enum - -/// ```c -/// enum Fruits {apple, banana = 10}; -/// ``` -/// The generated dart code is -/// -/// ```dart -/// class Fruits { -/// static const apple = 0; -/// static const banana = 10; -/// } -/// ``` -class EnumClass extends BindingType { - static final nativeType = NativeType(SupportedNativeType.Int32); - - final List enumConstants; - - EnumClass({ - String? usr, - String? originalName, - required String name, - String? dartDoc, - List? enumConstants, - }) : enumConstants = enumConstants ?? [], - super( - usr: usr, - originalName: originalName, - name: name, - dartDoc: dartDoc, - ); - - @override - BindingString toBindingString(Writer w) { - final s = StringBuffer(); - final enclosingClassName = name; - - if (dartDoc != null) { - s.write(makeDartDoc(dartDoc!)); - } - - /// Adding [enclosingClassName] because dart doesn't allow class member - /// to have the same name as the class. - final localUniqueNamer = UniqueNamer({enclosingClassName}); - - // Print enclosing class. - s.write('abstract class $enclosingClassName {\n'); - const depth = ' '; - for (final ec in enumConstants) { - final enumValueName = localUniqueNamer.makeUnique(ec.name); - if (ec.dartDoc != null) { - s.write(depth + '/// '); - s.writeAll(ec.dartDoc!.split('\n'), '\n' + depth + '/// '); - s.write('\n'); - } - s.write(depth + 'static const int $enumValueName = ${ec.value};\n'); - } - s.write('}\n\n'); - - return BindingString( - type: BindingStringType.enumClass, string: s.toString()); - } - - @override - void addDependencies(Set dependencies) { - if (dependencies.contains(this)) return; - - dependencies.add(this); - } - - @override - String getCType(Writer w) => nativeType.getCType(w); - - @override - String getDartType(Writer w) => nativeType.getDartType(w); - - @override - String? getDefaultValue(Writer w, String nativeLib) => '0'; -} - -/// Represents a single value in an enum. -class EnumConstant { - final String? originalName; - final String? dartDoc; - final String name; - final int value; - const EnumConstant({ - String? originalName, - required this.name, - required this.value, - this.dartDoc, - }) : originalName = originalName ?? name; -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/func.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/func.dart deleted file mode 100644 index c10b0c8dd..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/func.dart +++ /dev/null @@ -1,165 +0,0 @@ -// Copyright (c) 2020, 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:ffigen/src/code_generator.dart'; - -import 'binding_string.dart'; -import 'utils.dart'; -import 'writer.dart'; - -/// A binding for C function. -/// -/// For a C function - -/// ```c -/// int sum(int a, int b); -/// ``` -/// The Generated dart code is - -/// ```dart -/// int sum(int a, int b) { -/// return _sum(a, b); -/// } -/// -/// final _dart_sum _sum = _dylib.lookupFunction<_c_sum, _dart_sum>('sum'); -/// -/// typedef _c_sum = ffi.Int32 Function(ffi.Int32 a, ffi.Int32 b); -/// -/// typedef _dart_sum = int Function(int a, int b); -/// ``` -class Func extends LookUpBinding { - final FunctionType functionType; - final bool exposeSymbolAddress; - final bool exposeFunctionTypedefs; - final bool isLeaf; - late final String funcPointerName; - - /// Contains typealias for function type if [exposeFunctionTypedefs] is true. - Typealias? _exposedCFunctionTypealias; - Typealias? _exposedDartFunctionTypealias; - - /// [originalName] is looked up in dynamic library, if not - /// provided, takes the value of [name]. - Func({ - String? usr, - required String name, - String? originalName, - String? dartDoc, - required Type returnType, - List? parameters, - this.exposeSymbolAddress = false, - this.exposeFunctionTypedefs = false, - this.isLeaf = false, - bool isInternal = false, - }) : functionType = FunctionType( - returnType: returnType, - parameters: parameters ?? const [], - ), - super( - usr: usr, - originalName: originalName, - name: name, - dartDoc: dartDoc, - isInternal: isInternal, - ) { - for (var i = 0; i < functionType.parameters.length; i++) { - if (functionType.parameters[i].name.trim() == '') { - functionType.parameters[i].name = 'arg$i'; - } - } - - // Get function name with first letter in upper case. - final upperCaseName = name[0].toUpperCase() + name.substring(1); - if (exposeFunctionTypedefs) { - _exposedCFunctionTypealias = Typealias( - name: 'Native$upperCaseName', - type: functionType, - ); - _exposedDartFunctionTypealias = Typealias( - name: 'Dart$upperCaseName', - type: functionType, - useDartType: true, - ); - } - } - - @override - BindingString toBindingString(Writer w) { - final s = StringBuffer(); - final enclosingFuncName = name; - final funcVarName = w.wrapperLevelUniqueNamer.makeUnique('_$name'); - funcPointerName = w.wrapperLevelUniqueNamer.makeUnique('_${name}Ptr'); - - if (dartDoc != null) { - s.write(makeDartDoc(dartDoc!)); - } - // Resolve name conflicts in function parameter names. - final paramNamer = UniqueNamer({}); - for (final p in functionType.parameters) { - p.name = paramNamer.makeUnique(p.name); - } - // Write enclosing function. - s.write('${functionType.returnType.getDartType(w)} $enclosingFuncName(\n'); - for (final p in functionType.parameters) { - s.write(' ${p.type.getDartType(w)} ${p.name},\n'); - } - s.write(') {\n'); - s.write('return $funcVarName'); - - s.write('(\n'); - for (final p in functionType.parameters) { - s.write(' ${p.name},\n'); - } - s.write(' );\n'); - s.write('}\n'); - - final cType = exposeFunctionTypedefs - ? _exposedCFunctionTypealias!.name - : functionType.getCType(w, writeArgumentNames: false); - final dartType = exposeFunctionTypedefs - ? _exposedDartFunctionTypealias!.name - : functionType.getDartType(w, writeArgumentNames: false); - - if (exposeSymbolAddress) { - // Add to SymbolAddress in writer. - w.symbolAddressWriter.addSymbol( - type: - '${w.ffiLibraryPrefix}.Pointer<${w.ffiLibraryPrefix}.NativeFunction<$cType>>', - name: name, - ptrName: funcPointerName, - ); - } - // Write function pointer. - s.write( - "late final $funcPointerName = ${w.lookupFuncIdentifier}<${w.ffiLibraryPrefix}.NativeFunction<$cType>>('$originalName');\n"); - final isLeafString = isLeaf ? 'isLeaf:true' : ''; - s.write( - 'late final $funcVarName = $funcPointerName.asFunction<$dartType>($isLeafString);\n\n'); - - return BindingString(type: BindingStringType.func, string: s.toString()); - } - - @override - void addDependencies(Set dependencies) { - if (dependencies.contains(this)) return; - - dependencies.add(this); - functionType.addDependencies(dependencies); - if (exposeFunctionTypedefs) { - _exposedCFunctionTypealias!.addDependencies(dependencies); - _exposedDartFunctionTypealias!.addDependencies(dependencies); - } - } -} - -/// Represents a Parameter, used in [Func] and [Typealias]. -class Parameter { - final String? originalName; - String name; - final Type type; - - Parameter({String? originalName, this.name = '', required Type type}) - : originalName = originalName ?? name, - // A [NativeFunc] is wrapped with a pointer because this is a shorthand - // used in C for Pointer to function. - type = type.typealiasType is NativeFunc ? PointerType(type) : type; -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/func_type.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/func_type.dart deleted file mode 100644 index 0b8abfd1d..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/func_type.dart +++ /dev/null @@ -1,83 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -import 'package:ffigen/src/code_generator.dart'; - -import 'writer.dart'; - -/// Represents a function type. -class FunctionType extends Type { - final Type returnType; - final List parameters; - - FunctionType({ - required this.returnType, - required this.parameters, - }); - - String _getTypeString( - bool writeArgumentNames, String Function(Type) typeToString) { - final sb = StringBuffer(); - - // Write return Type. - sb.write(typeToString(returnType)); - - // Write Function. - sb.write(' Function('); - sb.write(parameters.map((p) { - return '${typeToString(p.type)} ${writeArgumentNames ? p.name : ""}'; - }).join(', ')); - sb.write(')'); - - return sb.toString(); - } - - @override - String getCType(Writer w, {bool writeArgumentNames = true}) => - _getTypeString(writeArgumentNames, (Type t) => t.getCType(w)); - - @override - String getDartType(Writer w, {bool writeArgumentNames = true}) => - _getTypeString(writeArgumentNames, (Type t) => t.getDartType(w)); - - @override - String toString() => _getTypeString(false, (Type t) => t.toString()); - - @override - String cacheKey() => _getTypeString(false, (Type t) => t.cacheKey()); - - @override - void addDependencies(Set dependencies) { - returnType.addDependencies(dependencies); - for (final p in parameters) { - p.type.addDependencies(dependencies); - } - } -} - -/// Represents a NativeFunction. -class NativeFunc extends Type { - final Type type; - - NativeFunc(this.type); - - @override - void addDependencies(Set dependencies) { - type.addDependencies(dependencies); - } - - @override - String getCType(Writer w) => - '${w.ffiLibraryPrefix}.NativeFunction<${type.getCType(w)}>'; - - @override - String getDartType(Writer w) => - '${w.ffiLibraryPrefix}.NativeFunction<${type.getCType(w)}>'; - - @override - String toString() => 'NativeFunction<${type.toString()}>'; - - @override - String cacheKey() => 'NatFn(${type.cacheKey()})'; -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/global.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/global.dart deleted file mode 100644 index 579d8ddaf..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/global.dart +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) 2020, 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 'binding.dart'; -import 'binding_string.dart'; -import 'compound.dart'; -import 'type.dart'; -import 'utils.dart'; -import 'writer.dart'; - -/// A binding to a global variable -/// -/// For a C global variable - -/// ```c -/// int a; -/// ``` -/// The generated dart code is - -/// ```dart -/// final int a = _dylib.lookup('a').value; -/// ``` -class Global extends LookUpBinding { - final Type type; - final bool exposeSymbolAddress; - - Global({ - String? usr, - String? originalName, - required String name, - required this.type, - String? dartDoc, - this.exposeSymbolAddress = false, - }) : super( - usr: usr, - originalName: originalName, - name: name, - dartDoc: dartDoc, - ); - - @override - BindingString toBindingString(Writer w) { - final s = StringBuffer(); - final globalVarName = name; - if (dartDoc != null) { - s.write(makeDartDoc(dartDoc!)); - } - final pointerName = w.wrapperLevelUniqueNamer.makeUnique('_$globalVarName'); - final dartType = type.getDartType(w); - final cType = type.getCType(w); - - s.write( - "late final ${w.ffiLibraryPrefix}.Pointer<$cType> $pointerName = ${w.lookupFuncIdentifier}<$cType>('$originalName');\n\n"); - final baseTypealiasType = type.typealiasType; - if (baseTypealiasType is Compound) { - if (baseTypealiasType.isOpaque) { - s.write( - '${w.ffiLibraryPrefix}.Pointer<$cType> get $globalVarName => $pointerName;\n\n'); - } else { - s.write('$dartType get $globalVarName => $pointerName.ref;\n\n'); - } - } else { - s.write('$dartType get $globalVarName => $pointerName.value;\n\n'); - s.write( - 'set $globalVarName($dartType value) => $pointerName.value = value;\n\n'); - } - - if (exposeSymbolAddress) { - // Add to SymbolAddress in writer. - w.symbolAddressWriter.addSymbol( - type: '${w.ffiLibraryPrefix}.Pointer<$cType>', - name: name, - ptrName: pointerName, - ); - } - - return BindingString(type: BindingStringType.global, string: s.toString()); - } - - @override - void addDependencies(Set dependencies) { - if (dependencies.contains(this)) return; - - dependencies.add(this); - type.addDependencies(dependencies); - } -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/handle.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/handle.dart deleted file mode 100644 index a1b2d47e3..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/handle.dart +++ /dev/null @@ -1,23 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -import 'package:ffigen/src/code_generator.dart'; - -import 'writer.dart'; - -/// Represents a Dart_Handle. -class HandleType extends Type { - const HandleType._(); - static const _handle = HandleType._(); - factory HandleType() => _handle; - - @override - String getCType(Writer w) => '${w.ffiLibraryPrefix}.Handle'; - - @override - String getDartType(Writer w) => 'Object'; - - @override - String toString() => 'Handle'; -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/imports.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/imports.dart deleted file mode 100644 index 41f71617f..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/imports.dart +++ /dev/null @@ -1,77 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -import 'struct.dart'; -import 'type.dart'; -import 'writer.dart'; - -/// A library import which will be written as an import in the generated file. -class LibraryImport { - final String name; - final String importPath; - String prefix; - - LibraryImport(this.name, this.importPath) : prefix = name; - - @override - bool operator ==(other) { - return other is LibraryImport && name == other.name; - } - - @override - int get hashCode => name.hashCode; -} - -/// An imported type which will be used in the generated code. -class ImportedType extends Type { - final LibraryImport libraryImport; - final String cType; - final String dartType; - final String? defaultValue; - - ImportedType(this.libraryImport, this.cType, this.dartType, - [this.defaultValue]); - - @override - String getCType(Writer w) { - w.markImportUsed(libraryImport); - return '${libraryImport.prefix}.$cType'; - } - - @override - String getDartType(Writer w) => cType == dartType ? getCType(w) : dartType; - - @override - String toString() => '${libraryImport.name}.$cType'; - - @override - String? getDefaultValue(Writer w, String nativeLib) => defaultValue; -} - -final ffiImport = LibraryImport('ffi', 'dart:ffi'); -final ffiPkgImport = LibraryImport('pkg_ffi', 'package:ffi/ffi.dart'); - -final voidType = ImportedType(ffiImport, 'Void', 'void'); - -final unsignedCharType = ImportedType(ffiImport, 'UnsignedChar', 'int', '0'); -final signedCharType = ImportedType(ffiImport, 'SignedChar', 'int', '0'); -final charType = ImportedType(ffiImport, 'Char', 'int', '0'); -final unsignedShortType = ImportedType(ffiImport, 'UnsignedShort', 'int', '0'); -final shortType = ImportedType(ffiImport, 'Short', 'int', '0'); -final unsignedIntType = ImportedType(ffiImport, 'UnsignedInt', 'int', '0'); -final intType = ImportedType(ffiImport, 'Int', 'int', '0'); -final unsignedLongType = ImportedType(ffiImport, 'UnsignedLong', 'int', '0'); -final longType = ImportedType(ffiImport, 'Long', 'int', '0'); -final unsignedLongLongType = - ImportedType(ffiImport, 'UnsignedLongLong', 'int', '0'); -final longLongType = ImportedType(ffiImport, 'LongLong', 'int', '0'); - -final floatType = ImportedType(ffiImport, 'Float', 'double', '0'); -final doubleType = ImportedType(ffiImport, 'Double', 'double', '0'); - -final sizeType = ImportedType(ffiImport, 'Size', 'int', '0'); -final wCharType = ImportedType(ffiImport, 'WChar', 'int', '0'); - -final objCObjectType = Struct(name: 'ObjCObject'); -final objCSelType = Struct(name: 'ObjCSel'); diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/library.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/library.dart deleted file mode 100644 index a651871f5..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/library.dart +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright (c) 2020, 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:cli_util/cli_util.dart'; -import 'package:ffigen/src/config_provider/config_types.dart'; -import 'package:logging/logging.dart'; -import 'package:path/path.dart' as p; -import 'binding.dart'; -import 'imports.dart'; -import 'struct.dart'; -import 'utils.dart'; -import 'writer.dart'; - -final _logger = Logger('ffigen.code_generator.library'); - -/// Container for all Bindings. -class Library { - /// List of bindings in this library. - late List bindings; - - late Writer _writer; - Writer get writer => _writer; - - Library({ - required String name, - String? description, - required List bindings, - String? header, - bool sort = false, - StructPackingOverride? packingOverride, - Set? libraryImports, - }) { - /// Get all dependencies (includes itself). - final dependencies = {}; - for (final b in bindings) { - b.addDependencies(dependencies); - } - - /// Save bindings. - this.bindings = dependencies.toList(); - - if (sort) { - _sort(); - } - - /// Handle any declaration-declaration name conflicts. - final declConflictHandler = UniqueNamer({}); - for (final b in this.bindings) { - _warnIfPrivateDeclaration(b); - _resolveIfNameConflicts(declConflictHandler, b); - } - - // Override pack values according to config. We do this after declaration - // conflicts have been handled so that users can target the generated names. - if (packingOverride != null) { - for (final b in this.bindings) { - if (b is Struct && packingOverride.isOverriden(b.name)) { - b.pack = packingOverride.getOverridenPackValue(b.name); - } - } - } - - // Seperate bindings which require lookup. - final lookUpBindings = this.bindings.whereType().toList(); - final noLookUpBindings = - this.bindings.whereType().toList(); - - _writer = Writer( - lookUpBindings: lookUpBindings, - noLookUpBindings: noLookUpBindings, - className: name, - classDocComment: description, - header: header, - additionalImports: libraryImports, - ); - } - - /// Logs a warning if generated declaration will be private. - void _warnIfPrivateDeclaration(Binding b) { - if (b.name.startsWith('_') && !b.isInternal) { - _logger.warning( - "Generated declaration '${b.name}' start's with '_' and therefore will be private."); - } - } - - /// Resolves name conflict(if any) and logs a warning. - void _resolveIfNameConflicts(UniqueNamer namer, Binding b) { - // Print warning if name was conflicting and has been changed. - if (namer.isUsed(b.name)) { - final oldName = b.name; - b.name = namer.makeUnique(b.name); - - _logger.warning( - "Resolved name conflict: Declaration '$oldName' and has been renamed to '${b.name}'."); - } else { - namer.markUsed(b.name); - } - } - - /// Sort all bindings in alphabetical order. - void _sort() { - bindings.sort((b1, b2) => b1.name.compareTo(b2.name)); - } - - /// Generates [file] by generating C bindings. - /// - /// If format is true(default), the formatter will be called to format the generated file. - void generateFile(File file, {bool format = true}) { - if (!file.existsSync()) file.createSync(recursive: true); - file.writeAsStringSync(generate()); - if (format) { - _dartFormat(file.path); - } - } - - /// Formats a file using the Dart formatter. - void _dartFormat(String path) { - final sdkPath = getSdkPath(); - final result = Process.runSync( - p.join(sdkPath, 'bin', 'dart'), ['format', path], - runInShell: Platform.isWindows); - if (result.stderr.toString().isNotEmpty) { - _logger.severe(result.stderr); - throw FormatException('Unable to format generated file: $path.'); - } - } - - /// Generates the bindings. - String generate() { - return writer.generate(); - } - - @override - bool operator ==(other) => other is Library && other.generate() == generate(); - - @override - int get hashCode => bindings.hashCode; -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/native_type.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/native_type.dart deleted file mode 100644 index 4be4b16f3..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/native_type.dart +++ /dev/null @@ -1,78 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -import 'package:ffigen/src/code_generator.dart'; - -import 'writer.dart'; - -enum SupportedNativeType { - Void, - Char, - Int8, - Int16, - Int32, - Int64, - Uint8, - Uint16, - Uint32, - Uint64, - Float, - Double, - IntPtr, -} - -/// Represents a primitive native type, such as float. -class NativeType extends Type { - static const _primitives = { - SupportedNativeType.Void: NativeType._('Void', 'void', null), - SupportedNativeType.Char: NativeType._('Uint8', 'int', '0'), - SupportedNativeType.Int8: NativeType._('Int8', 'int', '0'), - SupportedNativeType.Int16: NativeType._('Int16', 'int', '0'), - SupportedNativeType.Int32: NativeType._('Int32', 'int', '0'), - SupportedNativeType.Int64: NativeType._('Int64', 'int', '0'), - SupportedNativeType.Uint8: NativeType._('Uint8', 'int', '0'), - SupportedNativeType.Uint16: NativeType._('Uint16', 'int', '0'), - SupportedNativeType.Uint32: NativeType._('Uint32', 'int', '0'), - SupportedNativeType.Uint64: NativeType._('Uint64', 'int', '0'), - SupportedNativeType.Float: NativeType._('Float', 'double', '0'), - SupportedNativeType.Double: NativeType._('Double', 'double', '0'), - SupportedNativeType.IntPtr: NativeType._('IntPtr', 'int', '0'), - }; - - final String _cType; - final String _dartType; - final String? _defaultValue; - - const NativeType._(this._cType, this._dartType, this._defaultValue); - - factory NativeType(SupportedNativeType type) => _primitives[type]!; - - @override - String getCType(Writer w) => '${w.ffiLibraryPrefix}.$_cType'; - - @override - String getDartType(Writer w) => _dartType; - - @override - String toString() => _cType; - - @override - String cacheKey() => _cType; - - @override - String? getDefaultValue(Writer w, String nativeLib) => _defaultValue; -} - -class BooleanType extends NativeType { - // Booleans are treated as uint8. - const BooleanType._() : super._('Bool', 'bool', 'false'); - static const _boolean = BooleanType._(); - factory BooleanType() => _boolean; - - @override - String toString() => 'bool'; - - @override - String cacheKey() => 'bool'; -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/objc_block.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/objc_block.dart deleted file mode 100644 index 7ae748647..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/objc_block.dart +++ /dev/null @@ -1,151 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -import 'package:ffigen/src/code_generator.dart'; - -import 'binding_string.dart'; -import 'writer.dart'; - -class ObjCBlock extends BindingType { - final Type returnType; - final List argTypes; - final ObjCBuiltInFunctions builtInFunctions; - - ObjCBlock({ - required String usr, - required String name, - required this.returnType, - required this.argTypes, - required this.builtInFunctions, - }) : super( - usr: usr, - originalName: name, - name: name, - ); - - @override - BindingString toBindingString(Writer w) { - final s = StringBuffer(); - - final params = []; - for (int i = 0; i < argTypes.length; ++i) { - params.add(Parameter(name: 'arg$i', type: argTypes[i])); - } - - final isVoid = returnType == NativeType(SupportedNativeType.Void); - final voidPtr = PointerType(voidType).getCType(w); - final blockPtr = PointerType(builtInFunctions.blockStruct); - final funcType = FunctionType(returnType: returnType, parameters: params); - final natFnType = NativeFunc(funcType); - final natFnPtr = PointerType(natFnType).getCType(w); - final funcPtrTrampoline = - w.topLevelUniqueNamer.makeUnique('_${name}_fnPtrTrampoline'); - final closureTrampoline = - w.topLevelUniqueNamer.makeUnique('_${name}_closureTrampoline'); - final registerClosure = - w.topLevelUniqueNamer.makeUnique('_${name}_registerClosure'); - final closureRegistry = - w.topLevelUniqueNamer.makeUnique('_${name}_closureRegistry'); - final closureRegistryIndex = - w.topLevelUniqueNamer.makeUnique('_${name}_closureRegistryIndex'); - final trampFuncType = FunctionType( - returnType: returnType, - parameters: [Parameter(type: blockPtr, name: 'block'), ...params]); - - // Write the function pointer based trampoline function. - s.write(returnType.getDartType(w)); - s.write(' $funcPtrTrampoline(${blockPtr.getCType(w)} block'); - for (int i = 0; i < params.length; ++i) { - s.write(', ${params[i].type.getDartType(w)} ${params[i].name}'); - } - s.write(') {\n'); - s.write(' ${isVoid ? '' : 'return '}block.ref.target.cast<' - '${natFnType.getDartType(w)}>().asFunction<' - '${funcType.getDartType(w)}>()('); - for (int i = 0; i < params.length; ++i) { - s.write('${i == 0 ? '' : ', '}${params[i].name}'); - } - s.write(');\n'); - s.write('}\n'); - - // Write the closure registry function. - s.write(''' -final $closureRegistry = {}; -int $closureRegistryIndex = 0; -$voidPtr $registerClosure(Function fn) { - final id = ++$closureRegistryIndex; - $closureRegistry[id] = fn; - return $voidPtr.fromAddress(id); -} -'''); - - // Write the closure based trampoline function. - s.write(returnType.getDartType(w)); - s.write(' $closureTrampoline(${blockPtr.getCType(w)} block'); - for (int i = 0; i < params.length; ++i) { - s.write(', ${params[i].type.getDartType(w)} ${params[i].name}'); - } - s.write(') {\n'); - s.write(' ${isVoid ? '' : 'return '}$closureRegistry[' - 'block.ref.target.address]!('); - for (int i = 0; i < params.length; ++i) { - s.write('${i == 0 ? '' : ', '}${params[i].name}'); - } - s.write(');\n'); - s.write('}\n'); - - // Write the wrapper class. - s.write('class $name {\n'); - s.write(' final ${blockPtr.getCType(w)} _impl;\n'); - s.write(' final ${w.className} _lib;\n'); - s.write(' $name._(this._impl, this._lib);\n'); - - // Constructor from a function pointer. - final defaultValue = returnType.getDefaultValue(w, '_lib'); - final exceptionalReturn = defaultValue == null ? '' : ', $defaultValue'; - s.write(''' - $name.fromFunctionPointer(this._lib, $natFnPtr ptr) - : _impl = _lib.${builtInFunctions.newBlock.name}( - ${w.ffiLibraryPrefix}.Pointer.fromFunction< - ${trampFuncType.getCType(w)}>($funcPtrTrampoline - $exceptionalReturn).cast(), ptr.cast()); - $name.fromFunction(this._lib, ${funcType.getDartType(w)} fn) - : _impl = _lib.${builtInFunctions.newBlock.name}( - ${w.ffiLibraryPrefix}.Pointer.fromFunction< - ${trampFuncType.getCType(w)}>($closureTrampoline - $exceptionalReturn).cast(), $registerClosure(fn)); -'''); - - // Get the pointer to the underlying block. - s.write(' ${blockPtr.getCType(w)} get pointer => _impl;\n'); - - s.write('}\n'); - return BindingString( - type: BindingStringType.objcBlock, string: s.toString()); - } - - @override - void addDependencies(Set dependencies) { - if (dependencies.contains(this)) return; - dependencies.add(this); - - returnType.addDependencies(dependencies); - for (final t in argTypes) { - t.addDependencies(dependencies); - } - - builtInFunctions.newBlockDesc.addDependencies(dependencies); - builtInFunctions.blockDescSingleton.addDependencies(dependencies); - builtInFunctions.blockStruct.addDependencies(dependencies); - builtInFunctions.concreteGlobalBlock.addDependencies(dependencies); - builtInFunctions.newBlock.addDependencies(dependencies); - } - - @override - String getCType(Writer w) => - PointerType(builtInFunctions.blockStruct).getCType(w); - - @override - String toString() => '($returnType (^)(${argTypes.join(', ')}))'; -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/objc_built_in_functions.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/objc_built_in_functions.dart deleted file mode 100644 index a92dbcbc9..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/objc_built_in_functions.dart +++ /dev/null @@ -1,305 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -import 'package:ffigen/src/code_generator.dart'; - -import 'binding_string.dart'; -import 'writer.dart'; - -/// Built in functions used by the Objective C bindings. -class ObjCBuiltInFunctions { - late final _registerNameFunc = Func( - name: '_sel_registerName', - originalName: 'sel_registerName', - returnType: PointerType(objCSelType), - parameters: [Parameter(name: 'str', type: PointerType(charType))], - isInternal: true, - ); - late final registerName = ObjCInternalFunction( - '_registerName', _registerNameFunc, (Writer w, String name) { - final s = StringBuffer(); - final selType = _registerNameFunc.functionType.returnType.getCType(w); - s.write('\n$selType $name(String name) {\n'); - s.write(' final cstr = name.toNativeUtf8();\n'); - s.write(' final sel = ${_registerNameFunc.name}(cstr.cast());\n'); - s.write(' ${w.ffiPkgLibraryPrefix}.calloc.free(cstr);\n'); - s.write(' return sel;\n'); - s.write('}\n'); - return s.toString(); - }); - - late final _getClassFunc = Func( - name: '_objc_getClass', - originalName: 'objc_getClass', - returnType: PointerType(objCObjectType), - parameters: [Parameter(name: 'str', type: PointerType(charType))], - isInternal: true, - ); - late final getClass = - ObjCInternalFunction('_getClass', _getClassFunc, (Writer w, String name) { - final s = StringBuffer(); - final objType = _getClassFunc.functionType.returnType.getCType(w); - s.write('\n$objType $name(String name) {\n'); - s.write(' final cstr = name.toNativeUtf8();\n'); - s.write(' final clazz = ${_getClassFunc.name}(cstr.cast());\n'); - s.write(' ${w.ffiPkgLibraryPrefix}.calloc.free(cstr);\n'); - s.write(' return clazz;\n'); - s.write('}\n'); - return s.toString(); - }); - - late final _retainFunc = Func( - name: '_objc_retain', - originalName: 'objc_retain', - returnType: PointerType(objCObjectType), - parameters: [Parameter(name: 'value', type: PointerType(objCObjectType))], - isInternal: true, - ); - late final _releaseFunc = Func( - name: '_objc_release', - originalName: 'objc_release', - returnType: voidType, - parameters: [Parameter(name: 'value', type: PointerType(objCObjectType))], - isInternal: true, - ); - late final _releaseFinalizer = ObjCInternalGlobal( - '_objc_releaseFinalizer', - (Writer w) => '${w.ffiLibraryPrefix}.NativeFinalizer(' - '${_releaseFunc.funcPointerName}.cast())', - _releaseFunc, - ); - - // We need to load a separate instance of objc_msgSend for each signature. - final _msgSendFuncs = {}; - Func getMsgSendFunc(Type returnType, List params) { - var key = returnType.cacheKey(); - for (final p in params) { - key += ' ' + p.type.cacheKey(); - } - return _msgSendFuncs[key] ??= Func( - name: '_objc_msgSend_${_msgSendFuncs.length}', - originalName: 'objc_msgSend', - returnType: returnType, - parameters: [ - Parameter(name: 'obj', type: PointerType(objCObjectType)), - Parameter(name: 'sel', type: PointerType(objCSelType)), - for (final p in params) Parameter(name: p.name, type: p.type), - ], - isInternal: true, - ); - } - - final _selObjects = {}; - ObjCInternalGlobal getSelObject(String methodName) { - return _selObjects[methodName] ??= ObjCInternalGlobal( - '_sel_${methodName.replaceAll(":", "_")}', - (Writer w) => '${registerName.name}("$methodName")', - registerName, - ); - } - - // See https://clang.llvm.org/docs/Block-ABI-Apple.html - late final blockStruct = Struct( - name: '_ObjCBlock', - isInternal: true, - members: [ - Member(name: 'isa', type: PointerType(voidType)), - Member(name: 'flags', type: intType), - Member(name: 'reserved', type: intType), - Member(name: 'invoke', type: PointerType(voidType)), - Member(name: 'descriptor', type: PointerType(blockDescStruct)), - Member(name: 'target', type: PointerType(voidType)), - ], - ); - late final blockDescStruct = Struct( - name: '_ObjCBlockDesc', - isInternal: true, - members: [ - Member(name: 'reserved', type: unsignedLongType), - Member(name: 'size', type: unsignedLongType), - Member(name: 'copy_helper', type: PointerType(voidType)), - Member(name: 'dispose_helper', type: PointerType(voidType)), - Member(name: 'signature', type: PointerType(charType)), - ], - ); - late final newBlockDesc = - ObjCInternalFunction('_newBlockDesc', null, (Writer w, String name) { - final s = StringBuffer(); - final blockType = blockStruct.getCType(w); - final descType = blockDescStruct.getCType(w); - final descPtr = PointerType(blockDescStruct).getCType(w); - s.write('\n$descPtr $name() {\n'); - s.write(' final d = ${w.ffiPkgLibraryPrefix}.calloc.allocate<$descType>(' - '${w.ffiLibraryPrefix}.sizeOf<$descType>());\n'); - s.write(' d.ref.size = ${w.ffiLibraryPrefix}.sizeOf<$blockType>();\n'); - s.write(' return d;\n'); - s.write('}\n'); - return s.toString(); - }); - late final blockDescSingleton = ObjCInternalGlobal( - '_objc_block_desc', - (Writer w) => '${newBlockDesc.name}()', - blockDescStruct, - ); - late final concreteGlobalBlock = ObjCInternalGlobal( - '_objc_concrete_global_block', - (Writer w) => '${w.lookupFuncIdentifier}<${voidType.getCType(w)}>(' - "'_NSConcreteGlobalBlock')", - ); - late final newBlock = - ObjCInternalFunction('_newBlock', null, (Writer w, String name) { - final s = StringBuffer(); - final blockType = blockStruct.getCType(w); - final blockPtr = PointerType(blockStruct).getCType(w); - final voidPtr = PointerType(voidType).getCType(w); - s.write('\n$blockPtr $name($voidPtr invoke, $voidPtr target) {\n'); - s.write(' final b = ${w.ffiPkgLibraryPrefix}.calloc.allocate<$blockType>(' - '${w.ffiLibraryPrefix}.sizeOf<$blockType>());\n'); - s.write(' b.ref.isa = ${concreteGlobalBlock.name};\n'); - s.write(' b.ref.invoke = invoke;\n'); - s.write(' b.ref.target = target;\n'); - s.write(' b.ref.descriptor = ${blockDescSingleton.name};\n'); - s.write(' return b;\n'); - s.write('}\n'); - return s.toString(); - }); - - bool utilsExist = false; - void ensureUtilsExist(Writer w, StringBuffer s) { - if (utilsExist) return; - utilsExist = true; - - final objType = PointerType(objCObjectType).getCType(w); - s.write(''' -class _ObjCWrapper implements ${w.ffiLibraryPrefix}.Finalizable { - final $objType _id; - final ${w.className} _lib; - bool _pendingRelease; - - _ObjCWrapper._(this._id, this._lib, - {bool retain = false, bool release = false}) : _pendingRelease = release { - if (retain) { - _lib.${_retainFunc.name}(_id); - } - if (release) { - _lib.${_releaseFinalizer.name}.attach(this, _id.cast(), detach: this); - } - } - - /// Releases the reference to the underlying ObjC object held by this wrapper. - /// Throws a StateError if this wrapper doesn't currently hold a reference. - void release() { - if (_pendingRelease) { - _pendingRelease = false; - _lib.${_releaseFunc.name}(_id); - _lib.${_releaseFinalizer.name}.detach(this); - } else { - throw StateError( - 'Released an ObjC object that was unowned or already released.'); - } - } - - @override - bool operator ==(Object other) { - return other is _ObjCWrapper && _id == other._id; - } - - @override - int get hashCode => _id.hashCode; -} -'''); - } - - void addDependencies(Set dependencies) { - registerName.addDependencies(dependencies); - getClass.addDependencies(dependencies); - _retainFunc.addDependencies(dependencies); - _releaseFunc.addDependencies(dependencies); - _releaseFinalizer.addDependencies(dependencies); - for (final func in _msgSendFuncs.values) { - func.addDependencies(dependencies); - } - for (final sel in _selObjects.values) { - sel.addDependencies(dependencies); - } - } - - final _interfaceRegistry = {}; - void registerInterface(ObjCInterface interface) { - _interfaceRegistry[interface.originalName] = interface; - } - - void generateNSStringUtils(Writer w, StringBuffer s) { - // Generate a constructor that wraps stringWithCString. - s.write(' factory NSString(${w.className} _lib, String str) {\n'); - s.write(' final cstr = str.toNativeUtf8();\n'); - s.write(' final nsstr = stringWithCString_encoding_(' - '_lib, cstr.cast(), 4 /* UTF8 */);\n'); - s.write(' ${w.ffiPkgLibraryPrefix}.calloc.free(cstr);\n'); - s.write(' return nsstr;\n'); - s.write(' }\n\n'); - - // Generate a toString method that wraps UTF8String. - s.write(' @override\n'); - s.write(' String toString() => (UTF8String).cast<' - '${w.ffiPkgLibraryPrefix}.Utf8>().toDartString();\n\n'); - } - - void generateStringUtils(Writer w, StringBuffer s) { - // Generate an extension on String to convert to NSString - s.write('extension StringToNSString on String {\n'); - s.write(' NSString toNSString(${w.className} lib) => ' - 'NSString(lib, this);\n'); - s.write('}\n\n'); - } -} - -/// Functions only used internally by ObjC bindings, which may or may not wrap a -/// native function, such as getClass. -class ObjCInternalFunction extends LookUpBinding { - final Func? _wrappedFunction; - final String Function(Writer, String) _toBindingString; - - ObjCInternalFunction( - String name, this._wrappedFunction, this._toBindingString) - : super(originalName: name, name: name, isInternal: true); - - @override - BindingString toBindingString(Writer w) { - name = w.wrapperLevelUniqueNamer.makeUnique(name); - return BindingString( - type: BindingStringType.func, string: _toBindingString(w, name)); - } - - @override - void addDependencies(Set dependencies) { - if (dependencies.contains(this)) return; - dependencies.add(this); - _wrappedFunction?.addDependencies(dependencies); - } -} - -/// Globals only used internally by ObjC bindings, such as classes and SELs. -class ObjCInternalGlobal extends LookUpBinding { - final String Function(Writer) makeValue; - Binding? binding; - - ObjCInternalGlobal(String name, this.makeValue, [this.binding]) - : super(originalName: name, name: name, isInternal: true); - - @override - BindingString toBindingString(Writer w) { - final s = StringBuffer(); - name = w.wrapperLevelUniqueNamer.makeUnique(name); - s.write('late final $name = ${makeValue(w)};'); - return BindingString(type: BindingStringType.global, string: s.toString()); - } - - @override - void addDependencies(Set dependencies) { - if (dependencies.contains(this)) return; - dependencies.add(this); - binding?.addDependencies(dependencies); - } -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/objc_interface.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/objc_interface.dart deleted file mode 100644 index 04eb6e5b3..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/objc_interface.dart +++ /dev/null @@ -1,477 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -import 'package:ffigen/src/code_generator.dart'; -import 'package:logging/logging.dart'; - -import 'binding_string.dart'; -import 'utils.dart'; -import 'writer.dart'; - -// Class methods defined on NSObject that we don't want to copy to child objects -// by default. -const _excludedNSObjectClassMethods = { - 'allocWithZone:', - 'class', - 'conformsToProtocol:', - 'copyWithZone:', - 'debugDescription', - 'description', - 'hash', - 'initialize', - 'instanceMethodForSelector:', - 'instanceMethodSignatureForSelector:', - 'instancesRespondToSelector:', - 'isSubclassOfClass:', - 'load', - 'mutableCopyWithZone:', - 'poseAsClass:', - 'resolveClassMethod:', - 'resolveInstanceMethod:', - 'setVersion:', - 'superclass', - 'version', -}; - -final _logger = Logger('ffigen.code_generator.objc_interface'); - -class ObjCInterface extends BindingType { - ObjCInterface? superType; - final methods = {}; - bool filled = false; - - final ObjCBuiltInFunctions builtInFunctions; - final bool isBuiltIn; - late final ObjCInternalGlobal _classObject; - late final ObjCInternalGlobal _isKindOfClass; - late final Func _isKindOfClassMsgSend; - - ObjCInterface({ - String? usr, - required String originalName, - required String name, - String? dartDoc, - required this.builtInFunctions, - required this.isBuiltIn, - }) : super( - usr: usr, - originalName: originalName, - name: name, - dartDoc: dartDoc, - ); - - bool get isNSString => isBuiltIn && originalName == "NSString"; - - @override - BindingString toBindingString(Writer w) { - String paramsToString(List params, - {required bool isStatic}) { - final List stringParams = []; - - if (isStatic) { - stringParams.add('${w.className} _lib'); - } - stringParams.addAll(params.map((p) => - (_getConvertedType(p.type, w, name) + - (p.isNullable ? "? " : " ") + - p.name))); - return '(' + stringParams.join(", ") + ')'; - } - - final s = StringBuffer(); - if (dartDoc != null) { - s.write(makeDartDoc(dartDoc!)); - } - - final uniqueNamer = UniqueNamer({name, '_id', '_lib'}); - final natLib = w.className; - - builtInFunctions.ensureUtilsExist(w, s); - final objType = PointerType(objCObjectType).getCType(w); - - // Class declaration. - s.write(''' -class $name extends ${superType?.name ?? '_ObjCWrapper'} { - $name._($objType id, $natLib lib, - {bool retain = false, bool release = false}) : - super._(id, lib, retain: retain, release: release); - - /// Returns a [$name] that points to the same underlying object as [other]. - static $name castFrom(T other) { - return $name._(other._id, other._lib, retain: true, release: true); - } - - /// Returns a [$name] that wraps the given raw object pointer. - static $name castFromPointer($natLib lib, ffi.Pointer other, - {bool retain = false, bool release = false}) { - return $name._(other, lib, retain: retain, release: release); - } - - /// Returns whether [obj] is an instance of [$name]. - static bool isInstance(_ObjCWrapper obj) { - return obj._lib.${_isKindOfClassMsgSend.name}( - obj._id, obj._lib.${_isKindOfClass.name}, - obj._lib.${_classObject.name}); - } - -'''); - - if (isNSString) { - builtInFunctions.generateNSStringUtils(w, s); - } - - // Methods. - for (final m in methods.values) { - final methodName = m._getDartMethodName(uniqueNamer); - final isStatic = m.isClass; - final returnType = m.returnType!; - - // The method declaration. - if (m.dartDoc != null) { - s.write(makeDartDoc(m.dartDoc!)); - } - - s.write(' '); - if (isStatic) { - s.write('static '); - s.write( - _getConvertedReturnType(returnType, w, name, m.isNullableReturn)); - - switch (m.kind) { - case ObjCMethodKind.method: - // static returnType methodName(NativeLibrary _lib, ...) - s.write(' $methodName'); - break; - case ObjCMethodKind.propertyGetter: - // static returnType getMethodName(NativeLibrary _lib) - s.write(' get'); - s.write(methodName[0].toUpperCase() + methodName.substring(1)); - break; - case ObjCMethodKind.propertySetter: - // static void setMethodName(NativeLibrary _lib, ...) - s.write(' set'); - s.write(methodName[0].toUpperCase() + methodName.substring(1)); - break; - } - s.write(paramsToString(m.params, isStatic: true)); - } else { - if (superType?.methods[m.originalName]?.sameAs(m) ?? false) { - s.write('@override\n '); - } - switch (m.kind) { - case ObjCMethodKind.method: - // returnType methodName(...) - s.write(_getConvertedReturnType( - returnType, w, name, m.isNullableReturn)); - s.write(' $methodName'); - s.write(paramsToString(m.params, isStatic: false)); - break; - case ObjCMethodKind.propertyGetter: - // returnType get methodName - s.write(_getConvertedReturnType( - returnType, w, name, m.isNullableReturn)); - s.write(' get $methodName'); - break; - case ObjCMethodKind.propertySetter: - // set methodName(...) - s.write(' set $methodName'); - s.write(paramsToString(m.params, isStatic: false)); - break; - } - } - - s.write(' {\n'); - - // Implementation. - final convertReturn = m.kind != ObjCMethodKind.propertySetter && - _needsConverting(returnType); - - if (returnType != NativeType(SupportedNativeType.Void)) { - s.write(' ${convertReturn ? 'final _ret = ' : 'return '}'); - } - s.write('_lib.${m.msgSend!.name}('); - s.write(isStatic ? '_lib.${_classObject.name}' : '_id'); - s.write(', _lib.${m.selObject!.name}'); - for (final p in m.params) { - s.write(', ${_doArgConversion(p)}'); - } - s.write(');\n'); - if (convertReturn) { - final result = _doReturnConversion(returnType, '_ret', name, '_lib', - m.isNullableReturn, m.isOwnedReturn); - s.write(' return $result;'); - } - - s.write(' }\n\n'); - } - - s.write('}\n\n'); - - if (isNSString) { - builtInFunctions.generateStringUtils(w, s); - } - - return BindingString( - type: BindingStringType.objcInterface, string: s.toString()); - } - - @override - void addDependencies(Set dependencies) { - if (dependencies.contains(this)) return; - dependencies.add(this); - builtInFunctions.addDependencies(dependencies); - - if (isBuiltIn) { - builtInFunctions.registerInterface(this); - } - - _classObject = ObjCInternalGlobal( - '_class_$originalName', - (Writer w) => '${builtInFunctions.getClass.name}("$originalName")', - builtInFunctions.getClass) - ..addDependencies(dependencies); - _isKindOfClass = builtInFunctions.getSelObject('isKindOfClass:'); - _isKindOfClassMsgSend = builtInFunctions.getMsgSendFunc( - BooleanType(), [ObjCMethodParam(PointerType(objCObjectType), 'clazz')]); - - if (isNSString) { - _addNSStringMethods(); - } - - if (superType != null) { - superType!.addDependencies(dependencies); - _copyClassMethodsFromSuperType(); - } - - for (final m in methods.values) { - m.addDependencies(dependencies, builtInFunctions); - } - } - - void _copyClassMethodsFromSuperType() { - // Copy class methods from the super type, because Dart classes don't - // inherit static methods. - for (final m in superType!.methods.values) { - if (m.isClass && - !_excludedNSObjectClassMethods.contains(m.originalName)) { - addMethod(m); - } - } - } - - void addMethod(ObjCMethod method) { - final oldMethod = methods[method.originalName]; - if (oldMethod != null) { - // Typically we ignore duplicate methods. However, property setters and - // getters are duplicated in the AST. One copy is marked with - // ObjCMethodKind.propertyGetter/Setter. The other copy is missing - // important information, and is a plain old instanceMethod. So if the - // existing method is an instanceMethod, and the new one is a property, - // override it. - if (method.isProperty && !oldMethod.isProperty) { - // Fallthrough. - } else if (!method.isProperty && oldMethod.isProperty) { - // Don't override, but also skip the same method check below. - return; - } else { - // Check duplicate is the same method. - if (!method.sameAs(oldMethod)) { - _logger.severe('Duplicate methods with different signatures: ' - '$originalName.${method.originalName}'); - } - return; - } - } - methods[method.originalName] = method; - } - - void _addNSStringMethods() { - addMethod(ObjCMethod( - originalName: 'stringWithCString:encoding:', - kind: ObjCMethodKind.method, - isClass: true, - returnType: this, - params_: [ - ObjCMethodParam(PointerType(charType), 'cString'), - ObjCMethodParam(unsignedIntType, 'enc'), - ], - )); - addMethod(ObjCMethod( - originalName: 'UTF8String', - kind: ObjCMethodKind.propertyGetter, - isClass: false, - returnType: PointerType(charType), - params_: [], - )); - } - - @override - String getCType(Writer w) => PointerType(objCObjectType).getCType(w); - - bool _isObject(Type type) => - type is PointerType && type.child == objCObjectType; - - bool _isInstanceType(Type type) => - type is Typealias && - type.originalName == 'instancetype' && - _isObject(type.type); - - // Utils for converting between the internal types passed to native code, and - // the external types visible to the user. For example, ObjCInterfaces are - // passed to native as Pointer, but the user sees the Dart wrapper - // class. These methods need to be kept in sync. - bool _needsConverting(Type type) => - type is ObjCInterface || - type is ObjCBlock || - _isObject(type) || - _isInstanceType(type); - - String _getConvertedType(Type type, Writer w, String enclosingClass) { - if (type is BooleanType) return 'bool'; - if (type is ObjCInterface) return type.name; - if (type is ObjCBlock) return type.name; - if (_isObject(type)) return 'NSObject'; - if (_isInstanceType(type)) return enclosingClass; - return type.getDartType(w); - } - - String _getConvertedReturnType( - Type type, Writer w, String enclosingClass, bool isNullableReturn) { - final result = _getConvertedType(type, w, enclosingClass); - if (isNullableReturn) { - return result + "?"; - } - return result; - } - - String _doArgConversion(ObjCMethodParam arg) { - if (arg.type is ObjCInterface || - _isObject(arg.type) || - _isInstanceType(arg.type) || - arg.type is ObjCBlock) { - final field = arg.type is ObjCBlock ? '_impl' : '_id'; - if (arg.isNullable) { - return '${arg.name}?.$field ?? ffi.nullptr'; - } else { - return '${arg.name}.$field'; - } - } - return arg.name; - } - - String _doReturnConversion(Type type, String value, String enclosingClass, - String library, bool isNullable, bool isOwnedReturn) { - final prefix = isNullable ? '$value.address == 0 ? null : ' : ''; - final ownerFlags = 'retain: ${!isOwnedReturn}, release: true'; - if (type is ObjCInterface) { - return '$prefix${type.name}._($value, $library, $ownerFlags)'; - } - if (type is ObjCBlock) { - return '$prefix${type.name}._($value, $library)'; - } - if (_isObject(type)) { - return '${prefix}NSObject._($value, $library, $ownerFlags)'; - } - if (_isInstanceType(type)) { - return '$prefix$enclosingClass._($value, $library, $ownerFlags)'; - } - return prefix + value; - } -} - -enum ObjCMethodKind { - method, - propertyGetter, - propertySetter, -} - -class ObjCProperty { - final String originalName; - String? dartName; - - ObjCProperty(this.originalName); -} - -class ObjCMethod { - final String? dartDoc; - final String originalName; - final ObjCProperty? property; - Type? returnType; - final bool isNullableReturn; - final List params; - final ObjCMethodKind kind; - final bool isClass; - bool returnsRetained = false; - ObjCInternalGlobal? selObject; - Func? msgSend; - - ObjCMethod({ - required this.originalName, - this.property, - this.dartDoc, - required this.kind, - required this.isClass, - this.returnType, - this.isNullableReturn = false, - List? params_, - }) : params = params_ ?? []; - - bool get isProperty => - kind == ObjCMethodKind.propertyGetter || - kind == ObjCMethodKind.propertySetter; - - void addDependencies( - Set dependencies, ObjCBuiltInFunctions builtInFunctions) { - returnType ??= NativeType(SupportedNativeType.Void); - returnType!.addDependencies(dependencies); - for (final p in params) { - p.type.addDependencies(dependencies); - } - selObject ??= builtInFunctions.getSelObject(originalName) - ..addDependencies(dependencies); - msgSend ??= builtInFunctions.getMsgSendFunc(returnType!, params) - ..addDependencies(dependencies); - } - - String _getDartMethodName(UniqueNamer uniqueNamer) { - if (property != null) { - // A getter and a setter are allowed to have the same name, so we can't - // just run the name through uniqueNamer. Instead they need to share - // the dartName, which is run through uniqueNamer. - if (property!.dartName == null) { - property!.dartName = uniqueNamer.makeUnique(property!.originalName); - } - return property!.dartName!; - } - // Objective C methods can look like: - // foo - // foo: - // foo:someArgName: - // So replace all ':' with '_'. - return uniqueNamer.makeUnique(originalName.replaceAll(":", "_")); - } - - bool sameAs(ObjCMethod other) { - if (originalName != other.originalName) return false; - if (isNullableReturn != other.isNullableReturn) return false; - if (kind != other.kind) return false; - if (isClass != other.isClass) return false; - // msgSend is deduped by signature, so this check covers the signature. - return msgSend == other.msgSend; - } - - static final _copyRegExp = RegExp('[cC]opy'); - bool get isOwnedReturn => - returnsRetained || - originalName.startsWith('new') || - originalName.startsWith('alloc') || - originalName.contains(_copyRegExp); -} - -class ObjCMethodParam { - final Type type; - final String name; - final bool isNullable; - ObjCMethodParam(this.type, this.name, {this.isNullable = false}); -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/pointer.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/pointer.dart deleted file mode 100644 index cacb5b2f6..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/pointer.dart +++ /dev/null @@ -1,63 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -import 'package:ffigen/src/code_generator.dart'; - -import 'writer.dart'; - -/// Represents a pointer. -class PointerType extends Type { - final Type child; - PointerType(this.child); - - @override - void addDependencies(Set dependencies) { - child.addDependencies(dependencies); - } - - @override - Type get baseType => child.baseType; - - @override - String getCType(Writer w) => - '${w.ffiLibraryPrefix}.Pointer<${child.getCType(w)}>'; - - @override - String toString() => '$child*'; - - @override - String cacheKey() => '${child.cacheKey()}*'; -} - -/// Represents a constant array, which has a fixed size. -class ConstantArray extends PointerType { - final int length; - ConstantArray(this.length, Type child) : super(child); - - @override - Type get baseArrayType => child.baseArrayType; - - @override - bool get isIncompleteCompound => baseArrayType.isIncompleteCompound; - - @override - String toString() => '$child[$length]'; - - @override - String cacheKey() => '${child.cacheKey()}[$length]'; -} - -/// Represents an incomplete array, which has an unknown size. -class IncompleteArray extends PointerType { - IncompleteArray(Type child) : super(child); - - @override - Type get baseArrayType => child.baseArrayType; - - @override - String toString() => '$child[]'; - - @override - String cacheKey() => '${child.cacheKey()}[]'; -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/struct.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/struct.dart deleted file mode 100644 index c65e04b99..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/struct.dart +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2020, 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:ffigen/src/code_generator/compound.dart'; - -/// A binding for C Struct. -/// -/// For a C structure - -/// ```c -/// struct C { -/// int a; -/// double b; -/// int c; -/// }; -/// ``` -/// The generated dart code is - -/// ```dart -/// class Struct extends ffi.Struct{ -/// @ffi.Int32() -/// int a; -/// -/// @ffi.Double() -/// double b; -/// -/// @ffi.Uint8() -/// int c; -/// -/// } -/// ``` -class Struct extends Compound { - Struct({ - String? usr, - String? originalName, - required String name, - bool isIncomplete = false, - int? pack, - String? dartDoc, - List? members, - bool isInternal = false, - }) : super( - usr: usr, - originalName: originalName, - name: name, - dartDoc: dartDoc, - isIncomplete: isIncomplete, - members: members, - pack: pack, - compoundType: CompoundType.struct, - isInternal: isInternal, - ); -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/type.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/type.dart deleted file mode 100644 index 8468eca3a..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/type.dart +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright (c) 2020, 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:ffigen/src/code_generator.dart'; - -import 'writer.dart'; - -/// Type class for return types, variable types, etc. -/// -/// Implementers should extend either Type, or BindingType if the type is also a -/// binding, and override at least getCType and toString. -abstract class Type { - const Type(); - - /// Get all dependencies of this type and save them in [dependencies]. - void addDependencies(Set dependencies) {} - - /// Get base type for any type. - /// - /// E.g int** has base [Type] of int. - /// double[2][3] has base [Type] of double. - Type get baseType => this; - - /// Get base Array type. - /// - /// Returns itself if it's not an Array Type. - Type get baseArrayType => this; - - /// Get base typealias type. - /// - /// Returns itself if it's not a Typealias. - Type get typealiasType => this; - - /// Returns true if the type is a [Compound] and is incomplete. - bool get isIncompleteCompound => false; - - /// Returns the C type of the Type. This is the FFI compatible type that is - /// passed to native code. - String getCType(Writer w) => throw 'No mapping for type: $this'; - - /// Returns the Dart type of the Type. This is the user visible type that is - /// passed to Dart code. - String getDartType(Writer w) => getCType(w); - - /// Returns the string representation of the Type, for debugging purposes - /// only. This string should not be printed as generated code. - @override - String toString(); - - /// Cache key used in various places to dedupe Types. By default this is just - /// the hash of the Type, but in many cases this does not dedupe sufficiently. - /// So Types that may be duplicated should override this to return a more - /// specific key. Types that are already deduped don't need to override this. - /// toString() is not a valid cache key as there may be name collisions. - String cacheKey() => hashCode.toRadixString(36); - - /// Returns a string of code that creates a default value for this type. For - /// example, for int types this returns the string '0'. A null return means - /// that default values aren't supported for this type, eg void. - String? getDefaultValue(Writer w, String nativeLib) => null; -} - -/// Function to check if the dart and C type string are same. -bool sameDartAndCType(Type t, Writer w) => t.getCType(w) == t.getDartType(w); - -/// Base class for all Type bindings. -/// -/// Since Dart doesn't have multiple inheritance, this type exists so that we -/// don't have to reimplement the default methods in all the classes that want -/// to extend both NoLookUpBinding and Type. -abstract class BindingType extends NoLookUpBinding implements Type { - BindingType({ - String? usr, - String? originalName, - required String name, - String? dartDoc, - bool isInternal = false, - }) : super( - usr: usr, - originalName: originalName, - name: name, - dartDoc: dartDoc, - isInternal: isInternal, - ); - - @override - Type get baseType => this; - - @override - Type get baseArrayType => this; - - @override - Type get typealiasType => this; - - @override - bool get isIncompleteCompound => false; - - @override - String getDartType(Writer w) => getCType(w); - - @override - String toString() => originalName; - - @override - String cacheKey() => hashCode.toRadixString(36); - - @override - String? getDefaultValue(Writer w, String nativeLib) => null; -} - -/// Represents an unimplemented type. Used as a marker, so that declarations -/// having these can exclude them. -class UnimplementedType extends Type { - String reason; - UnimplementedType(this.reason); - - @override - String toString() => '(Unimplemented: $reason)'; -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/typealias.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/typealias.dart deleted file mode 100644 index f42e86360..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/typealias.dart +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) 2020, 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:ffigen/src/code_generator.dart'; - -import 'binding_string.dart'; -import 'utils.dart'; -import 'writer.dart'; - -/// A simple Typealias, Expands to - -/// -/// ```dart -/// typedef $name = $type; -/// ); -/// ``` -class Typealias extends BindingType { - final Type type; - final bool _useDartType; - - Typealias({ - String? usr, - String? originalName, - String? dartDoc, - required String name, - required this.type, - - /// If true, the binding string uses Dart type instead of C type. - /// - /// E.g if C type is ffi.Void func(ffi.Int32), Dart type is void func(int). - bool useDartType = false, - }) : _useDartType = useDartType, - super( - usr: usr, - name: name, - dartDoc: dartDoc, - originalName: originalName, - ); - - @override - void addDependencies(Set dependencies) { - if (dependencies.contains(this)) return; - - dependencies.add(this); - type.addDependencies(dependencies); - } - - @override - BindingString toBindingString(Writer w) { - final sb = StringBuffer(); - if (dartDoc != null) { - sb.write(makeDartDoc(dartDoc!)); - } - sb.write('typedef $name = '); - sb.write('${_useDartType ? type.getDartType(w) : type.getCType(w)};\n'); - return BindingString( - type: BindingStringType.typeDef, string: sb.toString()); - } - - @override - Type get typealiasType => type.typealiasType; - - @override - bool get isIncompleteCompound => type.isIncompleteCompound; - - @override - String getCType(Writer w) => name; - - @override - String getDartType(Writer w) { - // Typealias cannot be used by name in Dart types unless both the C and Dart - // type of the underlying types are same. - if (sameDartAndCType(type, w)) { - return name; - } else { - return type.getDartType(w); - } - } - - @override - String cacheKey() => type.cacheKey(); - - @override - String? getDefaultValue(Writer w, String nativeLib) => - type.getDefaultValue(w, nativeLib); -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/union.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/union.dart deleted file mode 100644 index fc7be967c..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/union.dart +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 2020, 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:ffigen/src/code_generator/compound.dart'; - -/// A binding for a C union - -/// -/// ```c -/// union C { -/// int a; -/// double b; -/// float c; -/// }; -/// ``` -/// The generated dart code is - -/// ```dart -/// class Union extends ffi.Union{ -/// @ffi.Int32() -/// int a; -/// -/// @ffi.Double() -/// double b; -/// -/// @ffi.Float() -/// float c; -/// -/// } -/// ``` -class Union extends Compound { - Union({ - String? usr, - String? originalName, - required String name, - bool isIncomplete = false, - int? pack, - String? dartDoc, - List? members, - }) : super( - usr: usr, - originalName: originalName, - name: name, - dartDoc: dartDoc, - isIncomplete: isIncomplete, - members: members, - pack: pack, - compoundType: CompoundType.union, - ); -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/utils.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/utils.dart deleted file mode 100644 index c000bdf92..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/utils.dart +++ /dev/null @@ -1,72 +0,0 @@ -import 'dart_keywords.dart'; - -class UniqueNamer { - final Set _usedUpNames; - - /// Creates a UniqueNamer with given [usedUpNames] and Dart reserved keywords. - UniqueNamer(Set usedUpNames) - : assert(keywords.intersection(usedUpNames).isEmpty), - _usedUpNames = {...keywords, ...usedUpNames}; - - /// Creates a UniqueNamer with given [usedUpNames] only. - UniqueNamer._raw(this._usedUpNames); - - /// Returns a unique name by appending `` to it if necessary. - /// - /// Adds the resulting name to the used names by default. - String makeUnique(String name, [bool addToUsedUpNames = true]) { - var crName = name; - var i = 1; - while (_usedUpNames.contains(crName)) { - crName = '$name$i'; - i++; - } - if (addToUsedUpNames) { - _usedUpNames.add(crName); - } - return crName; - } - - /// Adds a name to used names. - /// - /// Note: [makeUnique] also adds the name by default. - void markUsed(String name) { - _usedUpNames.add(name); - } - - /// Returns true if a name has been used before. - bool isUsed(String name) { - return _usedUpNames.contains(name); - } - - /// Returns true if a name has not been used before. - bool isUnique(String name) { - return !_usedUpNames.contains(name); - } - - UniqueNamer clone() => UniqueNamer._raw({..._usedUpNames}); -} - -/// Converts [text] to a dart doc comment(`///`). -/// -/// Comment is split on new lines only. -String makeDartDoc(String text) { - final s = StringBuffer(); - s.write('/// '); - s.writeAll(text.split('\n'), '\n/// '); - s.write('\n'); - - return s.toString(); -} - -/// Converts [text] to a dart comment (`//`). -/// -/// Comment is split on new lines only. -String makeDoc(String text) { - final s = StringBuffer(); - s.write('// '); - s.writeAll(text.split('\n'), '\n// '); - s.write('\n'); - - return s.toString(); -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/writer.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/writer.dart deleted file mode 100644 index 0bacf555a..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/code_generator/writer.dart +++ /dev/null @@ -1,300 +0,0 @@ -// Copyright (c) 2020, 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:ffigen/src/code_generator/imports.dart'; -import 'package:ffigen/src/code_generator/utils.dart'; - -import 'binding.dart'; - -/// To store generated String bindings. -class Writer { - final String? header; - - /// Holds bindings, which lookup symbols. - final List lookUpBindings; - - /// Holds bindings which don't lookup symbols. - final List noLookUpBindings; - - /// Manages the `_SymbolAddress` class. - final symbolAddressWriter = SymbolAddressWriter(); - - late String _className; - String get className => _className; - - final String? classDocComment; - - String? _ffiLibraryPrefix; - String get ffiLibraryPrefix { - if (_ffiLibraryPrefix != null) { - return _ffiLibraryPrefix!; - } - - final import = _usedImports.firstWhere( - (element) => element.name == ffiImport.name, - orElse: () => ffiImport); - _usedImports.add(import); - return _ffiLibraryPrefix = import.prefix; - } - - String? _ffiPkgLibraryPrefix; - String get ffiPkgLibraryPrefix { - if (_ffiPkgLibraryPrefix != null) { - return _ffiPkgLibraryPrefix!; - } - - final import = _usedImports.firstWhere( - (element) => element.name == ffiPkgImport.name, - orElse: () => ffiPkgImport); - _usedImports.add(import); - return _ffiPkgLibraryPrefix = import.prefix; - } - - final Set _usedImports = {}; - - late String _lookupFuncIdentifier; - String get lookupFuncIdentifier => _lookupFuncIdentifier; - - late String _symbolAddressClassName; - late String _symbolAddressVariableName; - late String _symbolAddressLibraryVarName; - - /// Initial namers set after running constructor. Namers are reset to this - /// initial state everytime [generate] is called. - late UniqueNamer _initialTopLevelUniqueNamer, _initialWrapperLevelUniqueNamer; - - /// Used by [Binding]s for generating required code. - late UniqueNamer _topLevelUniqueNamer, _wrapperLevelUniqueNamer; - UniqueNamer get topLevelUniqueNamer => _topLevelUniqueNamer; - UniqueNamer get wrapperLevelUniqueNamer => _wrapperLevelUniqueNamer; - - late String _arrayHelperClassPrefix; - - /// Guaranteed to be a unique prefix. - String get arrayHelperClassPrefix => _arrayHelperClassPrefix; - - /// [_usedUpNames] should contain names of all the declarations which are - /// already used. This is used to avoid name collisions. - Writer({ - required this.lookUpBindings, - required this.noLookUpBindings, - required String className, - Set? additionalImports, - this.classDocComment, - this.header, - }) { - final globalLevelNameSet = noLookUpBindings.map((e) => e.name).toSet(); - final wrapperLevelNameSet = lookUpBindings.map((e) => e.name).toSet(); - final allNameSet = {} - ..addAll(globalLevelNameSet) - ..addAll(wrapperLevelNameSet); - - _initialTopLevelUniqueNamer = UniqueNamer(globalLevelNameSet); - _initialWrapperLevelUniqueNamer = UniqueNamer(wrapperLevelNameSet); - final allLevelsUniqueNamer = UniqueNamer(allNameSet); - - /// Wrapper class name must be unique among all names. - _className = _resolveNameConflict( - name: className, - makeUnique: allLevelsUniqueNamer, - markUsed: [_initialWrapperLevelUniqueNamer, _initialTopLevelUniqueNamer], - ); - - /// Library imports prefix should be unique unique among all names. - if (additionalImports != null) { - for (final lib in additionalImports) { - lib.prefix = _resolveNameConflict( - name: lib.prefix, - makeUnique: allLevelsUniqueNamer, - markUsed: [ - _initialWrapperLevelUniqueNamer, - _initialTopLevelUniqueNamer - ], - ); - } - } - - /// [_lookupFuncIdentifier] should be unique in top level. - _lookupFuncIdentifier = _resolveNameConflict( - name: '_lookup', - makeUnique: _initialTopLevelUniqueNamer, - markUsed: [_initialTopLevelUniqueNamer], - ); - - /// Resolve name conflicts of identifiers used for SymbolAddresses. - _symbolAddressClassName = _resolveNameConflict( - name: '_SymbolAddresses', - makeUnique: allLevelsUniqueNamer, - markUsed: [_initialWrapperLevelUniqueNamer, _initialTopLevelUniqueNamer], - ); - _symbolAddressVariableName = _resolveNameConflict( - name: 'addresses', - makeUnique: _initialWrapperLevelUniqueNamer, - markUsed: [_initialWrapperLevelUniqueNamer], - ); - _symbolAddressLibraryVarName = _resolveNameConflict( - name: '_library', - makeUnique: _initialWrapperLevelUniqueNamer, - markUsed: [_initialWrapperLevelUniqueNamer], - ); - - /// Finding a unique prefix for Array Helper Classes and store into - /// [_arrayHelperClassPrefix]. - final base = 'ArrayHelper'; - _arrayHelperClassPrefix = base; - var suffixInt = 0; - for (var i = 0; i < allNameSet.length; i++) { - if (allNameSet.elementAt(i).startsWith(_arrayHelperClassPrefix)) { - // Not a unique prefix, start over with a new suffix. - i = -1; - suffixInt++; - _arrayHelperClassPrefix = '$base$suffixInt'; - } - } - - _resetUniqueNamersNamers(); - } - - /// Resolved name conflict using [makeUnique] and marks the result as used in - /// all [markUsed]. - String _resolveNameConflict({ - required String name, - required UniqueNamer makeUnique, - List markUsed = const [], - }) { - final s = makeUnique.makeUnique(name); - for (final un in markUsed) { - un.markUsed(s); - } - return s; - } - - /// Resets the namers to initial state. Namers are reset before generating. - void _resetUniqueNamersNamers() { - _topLevelUniqueNamer = _initialTopLevelUniqueNamer.clone(); - _wrapperLevelUniqueNamer = _initialWrapperLevelUniqueNamer.clone(); - } - - void markImportUsed(LibraryImport import) { - _usedImports.add(import); - } - - /// Writes all bindings to a String. - String generate() { - final s = StringBuffer(); - - // We write the source first to determine which imports are actually - // referenced. Headers and [s] are then combined into the final result. - final result = StringBuffer(); - - // Reset unique namers to initial state. - _resetUniqueNamersNamers(); - - // Write file header (if any). - if (header != null) { - result.writeln(header); - } - - // Write auto generated declaration. - result.write(makeDoc( - 'AUTO GENERATED FILE, DO NOT EDIT.\n\nGenerated by `package:ffigen`.')); - - /// Write [lookUpBindings]. - if (lookUpBindings.isNotEmpty) { - // Write doc comment for wrapper class. - if (classDocComment != null) { - s.write(makeDartDoc(classDocComment!)); - } - // Write wrapper classs. - s.write('class $_className{\n'); - // Write dylib. - s.write('/// Holds the symbol lookup function.\n'); - s.write( - 'final $ffiLibraryPrefix.Pointer Function(String symbolName) $lookupFuncIdentifier;\n'); - s.write('\n'); - //Write doc comment for wrapper class constructor. - s.write(makeDartDoc('The symbols are looked up in [dynamicLibrary].')); - // Write wrapper class constructor. - s.write( - '$_className($ffiLibraryPrefix.DynamicLibrary dynamicLibrary): $lookupFuncIdentifier = dynamicLibrary.lookup;\n\n'); - //Write doc comment for wrapper class named constructor. - s.write(makeDartDoc('The symbols are looked up with [lookup].')); - // Write wrapper class named constructor. - s.write( - '$_className.fromLookup($ffiLibraryPrefix.Pointer Function(String symbolName) lookup): $lookupFuncIdentifier = lookup;\n\n'); - for (final b in lookUpBindings) { - s.write(b.toBindingString(this).string); - } - if (symbolAddressWriter.shouldGenerate) { - s.write(symbolAddressWriter.writeObject(this)); - } - - s.write('}\n\n'); - } - - if (symbolAddressWriter.shouldGenerate) { - s.write(symbolAddressWriter.writeClass(this)); - } - - /// Write [noLookUpBindings]. - for (final b in noLookUpBindings) { - if (b.name != '__va_list_tag') { - s.write(b.toBindingString(this).string); - } - } - - // Write neccesary imports. - for (final lib in _usedImports) { - result - ..write("import '${lib.importPath}' as ${lib.prefix};") - ..write('\n'); - } - result.write(s); - - return result.toString(); - } -} - -/// Manages the generated `_SymbolAddress` class. -class SymbolAddressWriter { - final List<_SymbolAddressUnit> _addresses = []; - - /// Used to check if we need to generate `_SymbolAddress` class. - bool get shouldGenerate => _addresses.isNotEmpty; - - void addSymbol({ - required String type, - required String name, - required String ptrName, - }) { - _addresses.add(_SymbolAddressUnit(type, name, ptrName)); - } - - String writeObject(Writer w) { - return 'late final ${w._symbolAddressVariableName} = ${w._symbolAddressClassName}(this);'; - } - - String writeClass(Writer w) { - final sb = StringBuffer(); - sb.write('class ${w._symbolAddressClassName} {\n'); - // Write Library object. - sb.write('final ${w._className} ${w._symbolAddressLibraryVarName};\n'); - // Write Constructor. - sb.write( - '${w._symbolAddressClassName}(this.${w._symbolAddressLibraryVarName});\n'); - for (final address in _addresses) { - sb.write( - '${address.type} get ${address.name} => ${w._symbolAddressLibraryVarName}.${address.ptrName};\n'); - } - sb.write('}\n'); - return sb.toString(); - } -} - -/// Holds the data for a single symbol address. -class _SymbolAddressUnit { - final String type, name, ptrName; - - _SymbolAddressUnit(this.type, this.name, this.ptrName); -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/config_provider.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/config_provider.dart deleted file mode 100644 index 990e137dd..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/config_provider.dart +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) 2020, 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. - -/// Creates config object used by other sub_modules. -library config_provider; - -export 'config_provider/config.dart'; diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/config_provider/config.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/config_provider/config.dart deleted file mode 100644 index e9d1f97d9..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/config_provider/config.dart +++ /dev/null @@ -1,483 +0,0 @@ -// Copyright (c) 2020, 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. - -/// Validates the yaml input by the user, prints useful info for the user - -import 'package:ffigen/src/code_generator.dart'; - -import 'package:logging/logging.dart'; -import 'package:yaml/yaml.dart'; - -import '../strings.dart' as strings; -import 'config_types.dart'; -import 'spec_utils.dart'; - -final _logger = Logger('ffigen.config_provider.config'); - -/// Provides configurations to other modules. -/// -/// Handles validation, extraction of confiurations from yaml file. -class Config { - /// Location for llvm/lib folder. - String get libclangDylib => _libclangDylib; - late String _libclangDylib; - - /// Output file name. - String get output => _output; - late String _output; - - /// Language that ffigen is consuming. - Language get language => _language; - late Language _language; - - // Holds headers and filters for header. - Headers get headers => _headers; - late Headers _headers; - - /// CommandLine Arguments to pass to clang_compiler. - List get compilerOpts => _compilerOpts; - late List _compilerOpts; - - /// Declaration config for Functions. - Declaration get functionDecl => _functionDecl; - late Declaration _functionDecl; - - /// Declaration config for Structs. - Declaration get structDecl => _structDecl; - late Declaration _structDecl; - - /// Declaration config for Unions. - Declaration get unionDecl => _unionDecl; - late Declaration _unionDecl; - - /// Declaration config for Enums. - Declaration get enumClassDecl => _enumClassDecl; - late Declaration _enumClassDecl; - - /// Declaration config for Unnamed enum constants. - Declaration get unnamedEnumConstants => _unnamedEnumConstants; - late Declaration _unnamedEnumConstants; - - /// Declaration config for Globals. - Declaration get globals => _globals; - late Declaration _globals; - - /// Declaration config for Macro constants. - Declaration get macroDecl => _macroDecl; - late Declaration _macroDecl; - - /// Declaration config for Typedefs. - Declaration get typedefs => _typedefs; - late Declaration _typedefs; - - /// Declaration config for Objective C interfaces. - Declaration get objcInterfaces => _objcInterfaces; - late Declaration _objcInterfaces; - - /// If generated bindings should be sorted alphabetically. - bool get sort => _sort; - late bool _sort; - - /// If typedef of supported types(int8_t) should be directly used. - bool get useSupportedTypedefs => _useSupportedTypedefs; - late bool _useSupportedTypedefs; - - /// Stores all the library imports specified by user including those for ffi and pkg_ffi. - Map get libraryImports => _libraryImports; - late Map _libraryImports; - - /// Stores typedef name to ImportedType mappings specified by user. - Map get typedefTypeMappings => _typedefTypeMappings; - late Map _typedefTypeMappings; - - /// Stores struct name to ImportedType mappings specified by user. - Map get structTypeMappings => _structTypeMappings; - late Map _structTypeMappings; - - /// Stores union name to ImportedType mappings specified by user. - Map get unionTypeMappings => _unionTypeMappings; - late Map _unionTypeMappings; - - /// Stores native int name to ImportedType mappings specified by user. - Map get nativeTypeMappings => _nativeTypeMappings; - late Map _nativeTypeMappings; - - /// Extracted Doc comment type. - CommentType get commentType => _commentType; - late CommentType _commentType; - - /// Whether structs that are dependencies should be included. - CompoundDependencies get structDependencies => _structDependencies; - late CompoundDependencies _structDependencies; - - /// Whether unions that are dependencies should be included. - CompoundDependencies get unionDependencies => _unionDependencies; - late CompoundDependencies _unionDependencies; - - /// Holds config for how struct packing should be overriden. - StructPackingOverride get structPackingOverride => _structPackingOverride; - late StructPackingOverride _structPackingOverride; - - /// Name of the wrapper class. - String get wrapperName => _wrapperName; - late String _wrapperName; - - /// Doc comment for the wrapper class. - String? get wrapperDocComment => _wrapperDocComment; - String? _wrapperDocComment; - - /// Header of the generated bindings. - String? get preamble => _preamble; - String? _preamble; - - /// If `Dart_Handle` should be mapped with Handle/Object. - bool get useDartHandle => _useDartHandle; - late bool _useDartHandle; - - Includer get exposeFunctionTypedefs => _exposeFunctionTypedefs; - late Includer _exposeFunctionTypedefs; - - Includer get leafFunctions => _leafFunctions; - late Includer _leafFunctions; - - Config._(); - - /// Create config from Yaml map. - factory Config.fromYaml(YamlMap map) { - final configspecs = Config._(); - _logger.finest('Config Map: ' + map.toString()); - - final specs = configspecs._getSpecs(); - - final result = configspecs._checkConfigs(map, specs); - if (!result) { - throw FormatException('Invalid configurations provided.'); - } - - configspecs._extract(map, specs); - return configspecs; - } - - /// Add compiler options for clang. If [highPriority] is true these are added - /// to the front of the list. - void addCompilerOpts(String compilerOpts, {bool highPriority = false}) { - if (highPriority) { - _compilerOpts.insertAll( - 0, compilerOptsToList(compilerOpts)); // Inserts at the front. - } else { - _compilerOpts.addAll(compilerOptsToList(compilerOpts)); - } - } - - /// Validates Yaml according to given specs. - bool _checkConfigs(YamlMap map, Map, Specification> specs) { - var _result = true; - for (final key in specs.keys) { - final spec = specs[key]; - if (checkKeyInYaml(key, map)) { - _result = - _result && spec!.validator(key, getKeyValueFromYaml(key, map)); - } else if (spec!.requirement == Requirement.yes) { - _logger.severe("Key '$key' is required."); - _result = false; - } else if (spec.requirement == Requirement.prefer) { - _logger.warning("Prefer adding Key '$key' to your config."); - } - } - // Warn about unknown keys. - warnUnknownKeys(specs.keys.toList(), map); - - return _result; - } - - /// Extracts variables from Yaml according to given specs. - /// - /// Validation must be done beforehand, using [_checkConfigs]. - void _extract(YamlMap map, Map, Specification> specs) { - for (final key in specs.keys) { - final spec = specs[key]; - if (checkKeyInYaml(key, map)) { - spec!.extractedResult(spec.extractor(getKeyValueFromYaml(key, map))); - } else { - spec!.extractedResult(spec.defaultValue?.call()); - } - } - } - - /// Returns map of various specifications avaialble for our tool. - /// - /// Key: Name, Value: [Specification] - Map, Specification> _getSpecs() { - return , Specification>{ - [strings.llvmPath]: Specification( - requirement: Requirement.no, - validator: llvmPathValidator, - extractor: llvmPathExtractor, - defaultValue: () => findDylibAtDefaultLocations(), - extractedResult: (dynamic result) { - _libclangDylib = result as String; - }, - ), - [strings.output]: Specification( - requirement: Requirement.yes, - validator: outputValidator, - extractor: outputExtractor, - extractedResult: (dynamic result) => _output = result as String, - ), - [strings.language]: Specification( - requirement: Requirement.no, - validator: languageValidator, - extractor: languageExtractor, - defaultValue: () => Language.c, - extractedResult: (dynamic result) => _language = result as Language, - ), - [strings.headers]: Specification( - requirement: Requirement.yes, - validator: headersValidator, - extractor: headersExtractor, - extractedResult: (dynamic result) => _headers = result as Headers, - ), - [strings.compilerOpts]: Specification>( - requirement: Requirement.no, - validator: compilerOptsValidator, - extractor: compilerOptsExtractor, - defaultValue: () => [], - extractedResult: (dynamic result) => - _compilerOpts = result as List, - ), - [strings.compilerOptsAuto]: Specification( - requirement: Requirement.no, - validator: compilerOptsAutoValidator, - extractor: compilerOptsAutoExtractor, - defaultValue: () => CompilerOptsAuto(), - extractedResult: (dynamic result) { - _compilerOpts - .addAll((result as CompilerOptsAuto).extractCompilerOpts()); - }), - [strings.functions]: Specification( - requirement: Requirement.no, - validator: declarationConfigValidator, - extractor: declarationConfigExtractor, - defaultValue: () => Declaration(), - extractedResult: (dynamic result) { - _functionDecl = result as Declaration; - }, - ), - [strings.structs]: Specification( - requirement: Requirement.no, - validator: declarationConfigValidator, - extractor: declarationConfigExtractor, - defaultValue: () => Declaration(), - extractedResult: (dynamic result) { - _structDecl = result as Declaration; - }, - ), - [strings.unions]: Specification( - requirement: Requirement.no, - validator: declarationConfigValidator, - extractor: declarationConfigExtractor, - defaultValue: () => Declaration(), - extractedResult: (dynamic result) { - _unionDecl = result as Declaration; - }, - ), - [strings.enums]: Specification( - requirement: Requirement.no, - validator: declarationConfigValidator, - extractor: declarationConfigExtractor, - defaultValue: () => Declaration(), - extractedResult: (dynamic result) { - _enumClassDecl = result as Declaration; - }, - ), - [strings.unnamedEnums]: Specification( - requirement: Requirement.no, - validator: declarationConfigValidator, - extractor: declarationConfigExtractor, - defaultValue: () => Declaration(), - extractedResult: (dynamic result) => - _unnamedEnumConstants = result as Declaration, - ), - [strings.globals]: Specification( - requirement: Requirement.no, - validator: declarationConfigValidator, - extractor: declarationConfigExtractor, - defaultValue: () => Declaration(), - extractedResult: (dynamic result) { - _globals = result as Declaration; - }, - ), - [strings.macros]: Specification( - requirement: Requirement.no, - validator: declarationConfigValidator, - extractor: declarationConfigExtractor, - defaultValue: () => Declaration(), - extractedResult: (dynamic result) { - _macroDecl = result as Declaration; - }, - ), - [strings.typedefs]: Specification( - requirement: Requirement.no, - validator: declarationConfigValidator, - extractor: declarationConfigExtractor, - defaultValue: () => Declaration(), - extractedResult: (dynamic result) { - _typedefs = result as Declaration; - }, - ), - [strings.objcInterfaces]: Specification( - requirement: Requirement.no, - validator: declarationConfigValidator, - extractor: declarationConfigExtractor, - defaultValue: () => Declaration(), - extractedResult: (dynamic result) { - _objcInterfaces = result as Declaration; - }, - ), - [strings.libraryImports]: Specification>( - validator: libraryImportsValidator, - extractor: libraryImportsExtractor, - defaultValue: () => {}, - extractedResult: (dynamic result) { - _libraryImports = result as Map; - }, - ), - [strings.typeMap, strings.typeMapTypedefs]: - Specification>>( - validator: typeMapValidator, - extractor: typeMapExtractor, - defaultValue: () => >{}, - extractedResult: (dynamic result) { - _typedefTypeMappings = makeImportTypeMapping( - result as Map>, _libraryImports); - }, - ), - [strings.typeMap, strings.typeMapStructs]: - Specification>>( - validator: typeMapValidator, - extractor: typeMapExtractor, - defaultValue: () => >{}, - extractedResult: (dynamic result) { - _structTypeMappings = makeImportTypeMapping( - result as Map>, _libraryImports); - }, - ), - [strings.typeMap, strings.typeMapUnions]: - Specification>>( - validator: typeMapValidator, - extractor: typeMapExtractor, - defaultValue: () => >{}, - extractedResult: (dynamic result) { - _unionTypeMappings = makeImportTypeMapping( - result as Map>, _libraryImports); - }, - ), - [strings.typeMap, strings.typeMapNativeTypes]: - Specification>>( - validator: typeMapValidator, - extractor: typeMapExtractor, - defaultValue: () => >{}, - extractedResult: (dynamic result) { - _nativeTypeMappings = makeImportTypeMapping( - result as Map>, _libraryImports); - }, - ), - [strings.sort]: Specification( - requirement: Requirement.no, - validator: booleanValidator, - extractor: booleanExtractor, - defaultValue: () => false, - extractedResult: (dynamic result) => _sort = result as bool, - ), - [strings.useSupportedTypedefs]: Specification( - requirement: Requirement.no, - validator: booleanValidator, - extractor: booleanExtractor, - defaultValue: () => true, - extractedResult: (dynamic result) => - _useSupportedTypedefs = result as bool, - ), - [strings.comments]: Specification( - requirement: Requirement.no, - validator: commentValidator, - extractor: commentExtractor, - defaultValue: () => CommentType.def(), - extractedResult: (dynamic result) => - _commentType = result as CommentType, - ), - [strings.structs, strings.dependencyOnly]: - Specification( - requirement: Requirement.no, - validator: dependencyOnlyValidator, - extractor: dependencyOnlyExtractor, - defaultValue: () => CompoundDependencies.full, - extractedResult: (dynamic result) => - _structDependencies = result as CompoundDependencies, - ), - [strings.unions, strings.dependencyOnly]: - Specification( - requirement: Requirement.no, - validator: dependencyOnlyValidator, - extractor: dependencyOnlyExtractor, - defaultValue: () => CompoundDependencies.full, - extractedResult: (dynamic result) => - _unionDependencies = result as CompoundDependencies, - ), - [strings.structs, strings.structPack]: - Specification( - requirement: Requirement.no, - validator: structPackingOverrideValidator, - extractor: structPackingOverrideExtractor, - defaultValue: () => StructPackingOverride(), - extractedResult: (dynamic result) => - _structPackingOverride = result as StructPackingOverride, - ), - [strings.name]: Specification( - requirement: Requirement.prefer, - validator: dartClassNameValidator, - extractor: stringExtractor, - defaultValue: () => 'NativeLibrary', - extractedResult: (dynamic result) => _wrapperName = result as String, - ), - [strings.description]: Specification( - requirement: Requirement.prefer, - validator: nonEmptyStringValidator, - extractor: stringExtractor, - defaultValue: () => null, - extractedResult: (dynamic result) => - _wrapperDocComment = result as String?, - ), - [strings.preamble]: Specification( - requirement: Requirement.no, - validator: nonEmptyStringValidator, - extractor: stringExtractor, - extractedResult: (dynamic result) => _preamble = result as String?, - ), - [strings.useDartHandle]: Specification( - requirement: Requirement.no, - validator: booleanValidator, - extractor: booleanExtractor, - defaultValue: () => true, - extractedResult: (dynamic result) => _useDartHandle = result as bool, - ), - [strings.functions, strings.exposeFunctionTypedefs]: - Specification( - requirement: Requirement.no, - validator: exposeFunctionTypeValidator, - extractor: exposeFunctionTypeExtractor, - defaultValue: () => Includer.excludeByDefault(), - extractedResult: (dynamic result) => - _exposeFunctionTypedefs = result as Includer, - ), - [strings.functions, strings.leafFunctions]: Specification( - requirement: Requirement.no, - validator: leafFunctionValidator, - extractor: leafFunctionExtractor, - defaultValue: () => Includer.excludeByDefault(), - extractedResult: (dynamic result) => - _leafFunctions = result as Includer, - ), - }; - } -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/config_provider/config_types.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/config_provider/config_types.dart deleted file mode 100644 index 6ba4f4e5b..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/config_provider/config_types.dart +++ /dev/null @@ -1,373 +0,0 @@ -// Copyright (c) 2020, 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. - -/// Contains all the neccesary classes required by config. -import 'dart:io'; - -import 'package:quiver/pattern.dart' as quiver; - -import 'path_finder.dart'; - -enum Language { c, objc } - -class CommentType { - CommentStyle style; - CommentLength length; - CommentType(this.style, this.length); - - /// Sets default style as [CommentStyle.doxygen], default length as - /// [CommentLength.full]. - CommentType.def() - : style = CommentStyle.doxygen, - length = CommentLength.full; - - /// Disables any comments. - CommentType.none() - : style = CommentStyle.doxygen, - length = CommentLength.none; -} - -enum CommentStyle { doxygen, any } - -enum CommentLength { none, brief, full } - -enum CompoundDependencies { full, opaque } - -/// Holds config for how Structs Packing will be overriden. -class StructPackingOverride { - final Map _matcherMap; - - StructPackingOverride({Map? matcherMap}) - : _matcherMap = matcherMap ?? {}; - - /// Returns true if the user has overriden the pack value. - bool isOverriden(String name) { - for (final key in _matcherMap.keys) { - if (quiver.matchesFull(key, name)) { - return true; - } - } - return false; - } - - /// Returns pack value for [name]. Ensure that value [isOverriden] before - /// using the returned value. - int? getOverridenPackValue(String name) { - for (final opv in _matcherMap.entries) { - if (quiver.matchesFull(opv.key, name)) { - return opv.value; - } - } - return null; - } -} - -/// Represents a single specification in configurations. -/// -/// [E] is the return type of the extractedResult. -class Specification { - final bool Function(List name, dynamic value) validator; - final E Function(dynamic map) extractor; - final E Function()? defaultValue; - - final Requirement requirement; - final void Function(dynamic result) extractedResult; - - Specification({ - required this.extractedResult, - required this.validator, - required this.extractor, - this.defaultValue, - this.requirement = Requirement.no, - }); -} - -enum Requirement { yes, prefer, no } - -// Holds headers and filters for header. -class Headers { - /// Path to headers. - /// - /// This contains all the headers, after extraction from Globs. - final List entryPoints; - - /// Include filter for headers. - final HeaderIncludeFilter includeFilter; - - Headers({List? entryPoints, HeaderIncludeFilter? includeFilter}) - : entryPoints = entryPoints ?? [], - includeFilter = includeFilter ?? GlobHeaderFilter(); -} - -abstract class HeaderIncludeFilter { - bool shouldInclude(String headerSourceFile); -} - -class GlobHeaderFilter extends HeaderIncludeFilter { - List? includeGlobs = []; - - GlobHeaderFilter({ - this.includeGlobs, - }); - - @override - bool shouldInclude(String headerSourceFile) { - // Return true if header was included. - for (final globPattern in includeGlobs!) { - if (quiver.matchesFull(globPattern, headerSourceFile)) { - return true; - } - } - - // If any includedInclusionHeaders is provided, return false. - if (includeGlobs!.isNotEmpty) { - return false; - } else { - return true; - } - } -} - -/// A generic declaration config, used for Functions, Structs, Enums, Macros, -/// unnamed Enums and Globals. -class Declaration { - final Includer _includer; - final Renamer _renamer; - final MemberRenamer _memberRenamer; - final Includer _symbolAddressIncluder; - - Declaration({ - Includer? includer, - Renamer? renamer, - MemberRenamer? memberRenamer, - Includer? symbolAddressIncluder, - }) : _includer = includer ?? Includer(), - _renamer = renamer ?? Renamer(), - _memberRenamer = memberRenamer ?? MemberRenamer(), - _symbolAddressIncluder = - symbolAddressIncluder ?? Includer.excludeByDefault(); - - /// Applies renaming and returns the result. - String renameUsingConfig(String name) => _renamer.rename(name); - - /// Applies member renaming and returns the result. - String renameMemberUsingConfig(String declaration, String member) => - _memberRenamer.rename(declaration, member); - - /// Checks if a name is allowed by a filter. - bool shouldInclude(String name) => _includer.shouldInclude(name); - - /// Checks if the symbol address should be included for this name. - bool shouldIncludeSymbolAddress(String name) => - _symbolAddressIncluder.shouldInclude(name); -} - -/// Matches `$`, value can be accessed in group 1 of match. -final replaceGroupRegexp = RegExp(r'\$([0-9])'); - -/// Match/rename using [regExp]. -class RegExpRenamer { - final RegExp regExp; - final String replacementPattern; - - RegExpRenamer(this.regExp, this.replacementPattern); - - /// Returns true if [str] has a full match with [regExp]. - bool matches(String str) => quiver.matchesFull(regExp, str); - - /// Renames [str] according to [replacementPattern]. - /// - /// Returns [str] if [regExp] doesn't have a full match. - String rename(String str) { - if (matches(str)) { - // Get match. - final regExpMatch = regExp.firstMatch(str)!; - - /// Get group values. - /// E.g for `str`: `clang_dispose` and `regExp`: `clang_(.*)` - /// groups will be `0`: `clang_disponse`, `1`: `dispose`. - final groups = regExpMatch.groups( - List.generate(regExpMatch.groupCount, (index) => index) + - [regExpMatch.groupCount]); - - /// Replace all `$` symbols with respective groups (if any). - final result = - replacementPattern.replaceAllMapped(replaceGroupRegexp, (match) { - final groupInt = int.parse(match.group(1)!); - return groups[groupInt]!; - }); - return result; - } else { - return str; - } - } - - @override - String toString() { - return 'Regexp: $regExp, ReplacementPattern: $replacementPattern'; - } -} - -/// Handles `include/exclude` logic for a declaration. -class Includer { - final List _includeMatchers; - final Set _includeFull; - final List _excludeMatchers; - final Set _excludeFull; - - Includer({ - List? includeMatchers, - Set? includeFull, - List? excludeMatchers, - Set? excludeFull, - }) : _includeMatchers = includeMatchers ?? [], - _includeFull = includeFull ?? {}, - _excludeMatchers = excludeMatchers ?? [], - _excludeFull = excludeFull ?? {}; - - Includer.excludeByDefault() - : _includeMatchers = [], - _includeFull = {}, - _excludeMatchers = [RegExp('.*', dotAll: true)], - _excludeFull = {}; - - /// Returns true if [name] is allowed. - /// - /// Exclude overrides include. - bool shouldInclude(String name) { - if (_excludeFull.contains(name)) { - return false; - } - - for (final em in _excludeMatchers) { - if (quiver.matchesFull(em, name)) { - return false; - } - } - - if (_includeFull.contains(name)) { - return true; - } - - for (final im in _includeMatchers) { - if (quiver.matchesFull(im, name)) { - return true; - } - } - - // If user has provided 'include' field in the filter, then default - // matching is false. - if (_includeMatchers.isNotEmpty || _includeFull.isNotEmpty) { - return false; - } else { - return true; - } - } -} - -/// Handles `full/regexp` renaming logic. -class Renamer { - final Map _renameFull; - final List _renameMatchers; - - Renamer({ - List? renamePatterns, - Map? renameFull, - }) : _renameMatchers = renamePatterns ?? [], - _renameFull = renameFull ?? {}; - - Renamer.noRename() - : _renameMatchers = [], - _renameFull = {}; - - String rename(String name) { - // Apply full rename (if any). - if (_renameFull.containsKey(name)) { - return _renameFull[name]!; - } - - // Apply rename regexp (if matches). - for (final renamer in _renameMatchers) { - if (renamer.matches(name)) { - return renamer.rename(name); - } - } - - // No renaming is provided for this declaration, return unchanged. - return name; - } -} - -/// Match declaration name using [declarationRegExp]. -class RegExpMemberRenamer { - final RegExp declarationRegExp; - final Renamer memberRenamer; - - RegExpMemberRenamer(this.declarationRegExp, this.memberRenamer); - - /// Returns true if [declaration] has a full match with [regExp]. - bool matchesDeclarationName(String declaration) => - quiver.matchesFull(declarationRegExp, declaration); - - @override - String toString() { - return 'DeclarationRegExp: $declarationRegExp, MemberRenamer: $memberRenamer'; - } -} - -/// Handles `full/regexp` member renaming. -class MemberRenamer { - final Map _memberRenameFull; - final List _memberRenameMatchers; - - final Map _cache = {}; - - MemberRenamer({ - Map? memberRenameFull, - List? memberRenamePattern, - }) : _memberRenameFull = memberRenameFull ?? {}, - _memberRenameMatchers = memberRenamePattern ?? []; - - String rename(String declaration, String member) { - if (_cache.containsKey(declaration)) { - return _cache[declaration]!.rename(member); - } - - // Apply full rename (if any). - if (_memberRenameFull.containsKey(declaration)) { - // Add to cache. - _cache[declaration] = _memberRenameFull[declaration]!; - return _cache[declaration]!.rename(member); - } - - // Apply rename regexp (if matches). - for (final renamer in _memberRenameMatchers) { - if (renamer.matchesDeclarationName(declaration)) { - // Add to cache. - _cache[declaration] = renamer.memberRenamer; - return _cache[declaration]!.rename(member); - } - } - - // No renaming is provided for this declaration, return unchanged. - return member; - } -} - -/// Handles config for automatically added compiler options. -class CompilerOptsAuto { - final bool macIncludeStdLib; - - CompilerOptsAuto({bool? macIncludeStdLib}) - : macIncludeStdLib = macIncludeStdLib ?? true; - - /// Extracts compiler options based on OS and config. - List extractCompilerOpts() { - if (Platform.isMacOS && macIncludeStdLib) { - return getCStandardLibraryHeadersForMac(); - } - - return []; - } -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/config_provider/path_finder.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/config_provider/path_finder.dart deleted file mode 100644 index 3f6a59760..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/config_provider/path_finder.dart +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (c) 2021, 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. - -/// Utils for finding header paths on system. - -import 'dart:io'; - -import 'package:logging/logging.dart'; -import 'package:path/path.dart' as p; - -final _logger = Logger('ffigen.config_provider.path_finder'); - -/// This will return include path from either LLVM, XCode or CommandLineTools. -List getCStandardLibraryHeadersForMac() { - final includePaths = []; - - /// Add system headers. - const systemHeaders = - '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include'; - if (Directory(systemHeaders).existsSync()) { - _logger.fine('Added $systemHeaders to compiler-opts.'); - includePaths.add('-I' + systemHeaders); - } - - /// 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]; - for (final searchPath in searchPaths) { - if (!Directory(searchPath).existsSync()) continue; - - final result = Process.runSync('ls', [searchPath]); - final stdout = result.stdout as String; - if (stdout != '') { - final versions = stdout.split('\n').where((s) => s != ''); - for (final version in versions) { - final path = p.join(searchPath, version, 'include'); - if (Directory(path).existsSync()) { - _logger.fine('Added stdlib path: $path to compiler-opts.'); - includePaths.add('-I' + path); - return includePaths; - } - } - } - } - - /// If CommandLineTools are installed use those headers. - const cmdLineToolHeaders = - '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Kernel.framework/Headers/'; - if (Directory(cmdLineToolHeaders).existsSync()) { - _logger.fine('Added stdlib path: $cmdLineToolHeaders to compiler-opts.'); - includePaths.add('-I' + cmdLineToolHeaders); - return includePaths; - } - - // Warnings for missing headers are printed by libclang while parsing. - _logger.fine('Couldn\'t find stdlib headers in default locations.'); - _logger.fine('Paths searched: ${[cmdLineToolHeaders, ...searchPaths]}'); - - return []; -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/config_provider/spec_utils.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/config_provider/spec_utils.dart deleted file mode 100644 index aaa4c08ec..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/config_provider/spec_utils.dart +++ /dev/null @@ -1,866 +0,0 @@ -// Copyright (c) 2020, 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:ffigen/src/code_generator.dart'; -import 'package:file/local.dart'; -import 'package:glob/glob.dart'; -import 'package:logging/logging.dart'; -import 'package:path/path.dart' as p; -import 'package:quiver/pattern.dart' as quiver; -import 'package:yaml/yaml.dart'; - -import '../strings.dart' as strings; -import 'config_types.dart'; - -final _logger = Logger('ffigen.config_provider.spec_utils'); - -/// Replaces the path separators according to current platform. -String _replaceSeparators(String path) { - if (Platform.isWindows) { - return path.replaceAll(p.posix.separator, p.windows.separator); - } else { - return path.replaceAll(p.windows.separator, p.posix.separator); - } -} - -/// Checks if type of value is [T], logs an error if it's not. -/// -/// [key] is printed as `'item1 -> item2 => item3'` in log message. -bool checkType(List keys, dynamic value) { - if (value is! T) { - _logger.severe( - "Expected value of key '${keys.join(' -> ')}' to be of type '$T'."); - return false; - } - return true; -} - -/// Checks if there are nested [key] in [map]. -bool checkKeyInYaml(List key, YamlMap map) { - dynamic last = map; - for (final k in key) { - if (last is YamlMap) { - if (!last.containsKey(k)) return false; - last = last[k]; - } else { - return false; - } - } - return last != null; -} - -/// Extracts value of nested [key] from [map]. -dynamic getKeyValueFromYaml(List key, YamlMap map) { - if (checkKeyInYaml(key, map)) { - dynamic last = map; - for (final k in key) { - last = last[k]; - } - return last; - } - - return null; -} - -/// Recursively checks the keys in [configKeyMap] from [allowedKeyList]. -void warnUnknownKeys(List> allowedKeyList, YamlMap configKeyMap) { - final allowedKeyMap = {}; - for (final specKeys in allowedKeyList) { - var _item = allowedKeyMap; - for (final specSubKey in specKeys) { - _item.putIfAbsent(specSubKey, () => {}); - _item = _item[specSubKey] as Map; - } - // Add empty key to mark that any sub-keys of this key are allowed. - _item[''] = {}; - } - _warnUnknownKeysInMap(allowedKeyMap, configKeyMap, []); -} - -/// Recursive function to check a key set in a configKeyMap. -void _warnUnknownKeysInMap(Map allowedKeyMap, - dynamic configKeyMap, List prev) { - if (allowedKeyMap.containsKey('') || configKeyMap is! YamlMap) { - return; - } - for (final key in configKeyMap.keys) { - if (allowedKeyMap.containsKey(key)) { - prev.add(key); - _warnUnknownKeysInMap( - allowedKeyMap[key] as Map, configKeyMap[key], prev); - prev.removeLast(); - } else { - prev.add(key); - _logger.warning('Unknown key - ${prev.join(' -> ')}.'); - prev.removeLast(); - } - } -} - -bool booleanExtractor(dynamic value) => value as bool; - -bool booleanValidator(List name, dynamic value) => - checkType(name, value); - -Map libraryImportsExtractor(dynamic yamlConfig) { - final resultMap = {}; - final typeMap = yamlConfig as YamlMap?; - if (typeMap != null) { - for (final typeName in typeMap.keys) { - resultMap[typeName as String] = - LibraryImport(typeName, typeMap[typeName] as String); - } - } - return resultMap; -} - -bool libraryImportsValidator(List name, dynamic yamlConfig) { - if (!checkType(name, yamlConfig)) { - return false; - } - for (final key in (yamlConfig as YamlMap).keys) { - if (!checkType([...name, key as String], yamlConfig[key])) { - return false; - } - if (strings.predefinedLibraryImports.containsKey(key)) { - _logger.severe( - 'library-import -> $key should not collide with any predefined imports - ${strings.predefinedLibraryImports.keys}.'); - return false; - } - } - return true; -} - -Map> typeMapExtractor(dynamic yamlConfig) { - // Key - type_name, Value - [lib, cType, dartType]. - final resultMap = >{}; - final typeMap = yamlConfig as YamlMap?; - if (typeMap != null) { - for (final typeName in typeMap.keys) { - final typeConfigItem = typeMap[typeName] as YamlMap; - resultMap[typeName as String] = [ - typeConfigItem[strings.lib] as String, - typeConfigItem[strings.cType] as String, - typeConfigItem[strings.dartType] as String, - ]; - } - } - return resultMap; -} - -bool typeMapValidator(List name, dynamic yamlConfig) { - if (!checkType(name, yamlConfig)) { - return false; - } - var result = true; - for (final key in (yamlConfig as YamlMap).keys) { - if (!checkType([...name, key as String], yamlConfig[key])) { - return false; - } - final lib = (yamlConfig[key] as YamlMap).containsKey(strings.lib); - if (!lib) { - _logger.severe("Key '${strings.lib}' in $name -> $key is required."); - result = false; - } - final cType = (yamlConfig[key] as YamlMap).containsKey(strings.cType); - if (!cType) { - _logger.severe("Key '${strings.cType}' in $name -> $key is required."); - result = false; - } - final dartType = (yamlConfig[key] as YamlMap).containsKey(strings.dartType); - if (!dartType) { - _logger.severe("Key '${strings.dartType}' in $name -> $key is required."); - result = false; - } - } - return result; -} - -Map makeImportTypeMapping( - Map> rawTypeMappings, - Map libraryImportsMap) { - final typeMappings = {}; - for (final key in rawTypeMappings.keys) { - final lib = rawTypeMappings[key]![0]; - final cType = rawTypeMappings[key]![1]; - final dartType = rawTypeMappings[key]![2]; - if (strings.predefinedLibraryImports.containsKey(lib)) { - typeMappings[key] = - ImportedType(strings.predefinedLibraryImports[lib]!, cType, dartType); - } else if (libraryImportsMap.containsKey(lib)) { - typeMappings[key] = - ImportedType(libraryImportsMap[lib]!, cType, dartType); - } else { - throw Exception("Please declare $lib under library-imports."); - } - } - return typeMappings; -} - -final _quoteMatcher = RegExp(r'''^["'](.*)["']$''', dotAll: true); -final _cmdlineArgMatcher = RegExp(r'''['"](\\"|[^"])*?['"]|[^ ]+'''); -List compilerOptsToList(String compilerOpts) { - final list = []; - _cmdlineArgMatcher.allMatches(compilerOpts).forEach((element) { - var match = element.group(0); - if (match != null) { - if (quiver.matchesFull(_quoteMatcher, match)) { - match = _quoteMatcher.allMatches(match).first.group(1)!; - } - list.add(match); - } - }); - - return list; -} - -List compilerOptsExtractor(dynamic value) { - if (value is String) { - return compilerOptsToList(value); - } - - final list = []; - for (final el in (value as YamlList)) { - if (el is String) { - list.addAll(compilerOptsToList(el)); - } - } - return list; -} - -bool compilerOptsValidator(List name, dynamic value) { - if (value is String || value is YamlList) { - return true; - } else { - _logger.severe('Expected $name to be a String or List of String.'); - return false; - } -} - -CompilerOptsAuto compilerOptsAutoExtractor(dynamic value) { - return CompilerOptsAuto( - macIncludeStdLib: getKeyValueFromYaml( - [strings.macos, strings.includeCStdLib], - value as YamlMap, - ) as bool?, - ); -} - -bool compilerOptsAutoValidator(List name, dynamic value) { - var _result = true; - - if (!checkType(name, value)) { - return false; - } - - for (final oskey in (value as YamlMap).keys) { - if (oskey == strings.macos) { - if (!checkType([...name, oskey as String], value[oskey])) { - return false; - } - - for (final inckey in (value[oskey] as YamlMap).keys) { - if (inckey == strings.includeCStdLib) { - if (!checkType( - [...name, oskey, inckey as String], value[oskey][inckey])) { - _result = false; - } - } else { - _logger.severe("Unknown key '$inckey' in '$name -> $oskey."); - _result = false; - } - } - } else { - _logger.severe("Unknown key '$oskey' in '$name'."); - _result = false; - } - } - return _result; -} - -Headers headersExtractor(dynamic yamlConfig) { - final entryPoints = []; - final includeGlobs = []; - for (final key in (yamlConfig as YamlMap).keys) { - if (key == strings.entryPoints) { - for (final h in (yamlConfig[key] as YamlList)) { - final headerGlob = h as String; - // Add file directly to header if it's not a Glob but a File. - if (File(headerGlob).existsSync()) { - final osSpecificPath = _replaceSeparators(headerGlob); - entryPoints.add(osSpecificPath); - _logger.fine('Adding header/file: $headerGlob'); - } else { - final glob = Glob(headerGlob); - for (final file in glob.listFileSystemSync(const LocalFileSystem(), - followLinks: true)) { - final fixedPath = _replaceSeparators(file.path); - entryPoints.add(fixedPath); - _logger.fine('Adding header/file: $fixedPath'); - } - } - } - } - if (key == strings.includeDirectives) { - for (final h in (yamlConfig[key] as YamlList)) { - final headerGlob = h as String; - final fixedGlob = _replaceSeparators(headerGlob); - includeGlobs.add(quiver.Glob(fixedGlob)); - } - } - } - return Headers( - entryPoints: entryPoints, - includeFilter: GlobHeaderFilter( - includeGlobs: includeGlobs, - ), - ); -} - -bool headersValidator(List name, dynamic value) { - if (!checkType(name, value)) { - return false; - } - if (!(value as YamlMap).containsKey(strings.entryPoints)) { - _logger.severe("Required '$name -> ${strings.entryPoints}'."); - return false; - } else { - for (final key in value.keys) { - if (key == strings.entryPoints || key == strings.includeDirectives) { - if (!checkType([...name, key as String], value[key])) { - return false; - } - } else { - _logger.severe("Unknown key '$key' in '$name'."); - return false; - } - } - return true; - } -} - -String libclangDylibExtractor(dynamic value) => getDylibPath(value as String); - -bool libclangDylibValidator(List name, dynamic value) { - if (!checkType(name, value)) { - return false; - } else { - final dylibPath = getDylibPath(value as String); - if (!File(dylibPath).existsSync()) { - _logger.severe( - 'Dynamic library: $dylibPath does not exist or is corrupt, input folder: $value.'); - return false; - } else { - return true; - } - } -} - -String getDylibPath(String dylibParentFoler) { - dylibParentFoler = _replaceSeparators(dylibParentFoler); - String dylibPath; - if (Platform.isMacOS) { - dylibPath = p.join(dylibParentFoler, strings.libclang_dylib_macos); - } else if (Platform.isWindows) { - dylibPath = p.join(dylibParentFoler, strings.libclang_dylib_windows); - } else { - dylibPath = p.join(dylibParentFoler, strings.libclang_dylib_linux); - } - return dylibPath; -} - -/// Returns location of dynamic library by searching default locations. Logs -/// error and throws an Exception if not found. -String findDylibAtDefaultLocations() { - String? k; - if (Platform.isLinux) { - for (final l in strings.linuxDylibLocations) { - k = findLibclangDylib(l); - if (k != null) return k; - } - } else if (Platform.isWindows) { - for (final l in strings.windowsDylibLocations) { - k = findLibclangDylib(l); - if (k != null) return k; - } - } else if (Platform.isMacOS) { - for (final l in strings.macOsDylibLocations) { - k = findLibclangDylib(l); - if (k != null) return k; - } - } else { - throw Exception('Unsupported Platform.'); - } - - _logger.severe("Couldn't find dynamic library in default locations."); - _logger.severe( - "Please supply one or more path/to/llvm in ffigen's config under the key '${strings.llvmPath}'."); - throw Exception("Couldn't find dynamic library in default locations."); -} - -String? findLibclangDylib(String parentFolder) { - final location = p.join(parentFolder, strings.dylibFileName); - if (File(location).existsSync()) { - return location; - } else { - return null; - } -} - -String llvmPathExtractor(dynamic value) { - // Extract libclang's dylib from user specified paths. - for (final path in (value as YamlList)) { - if (path is! String) continue; - final dylibPath = - findLibclangDylib(p.join(path, strings.dynamicLibParentName)); - if (dylibPath != null) { - _logger.fine('Found dynamic library at: $dylibPath'); - return dylibPath; - } - // Check if user has specified complete path to dylib. - final completeDylibPath = path; - if (p.extension(completeDylibPath).isNotEmpty && - File(completeDylibPath).existsSync()) { - _logger.info( - 'Using complete dylib path: $completeDylibPath from llvm-path.'); - return completeDylibPath; - } - } - _logger.fine( - "Couldn't find dynamic library under paths specified by ${strings.llvmPath}."); - // Extract path from default locations. - try { - final res = findDylibAtDefaultLocations(); - return res; - } catch (e) { - _logger.severe( - "Couldn't find ${p.join(strings.dynamicLibParentName, strings.dylibFileName)} in specified locations."); - exit(1); - } -} - -bool llvmPathValidator(List name, dynamic value) { - if (!checkType(name, value)) { - return false; - } - return true; -} - -String outputExtractor(dynamic value) => _replaceSeparators(value as String); - -bool outputValidator(List name, dynamic value) => - checkType(name, value); - -Language languageExtractor(dynamic value) { - if (value == strings.langC) { - return Language.c; - } else if (value == strings.langObjC) { - return Language.objc; - } - return Language.c; -} - -bool languageValidator(List name, dynamic value) { - if (value is String) { - if (value == strings.langC) { - return true; - } - if (value == strings.langObjC) { - _logger.severe('Objective C support is EXPERIMENTAL. The API may change ' - 'in a breaking way without notice.'); - return true; - } - _logger.severe("'$name' must be one of the following - " - "{${strings.langC}, ${strings.langObjC}}"); - return false; - } - _logger.severe("Expected value of key '$name' to be a String."); - return false; -} - -/// Returns true if [str] is not a full name. -/// -/// E.g `abc` is a full name, `abc.*` is not. -bool isFullDeclarationName(String str) => - quiver.matchesFull(RegExp('[a-zA-Z_0-9]*'), str); - -Includer _extractIncluderFromYaml(dynamic yamlMap) { - final includeMatchers = [], - includeFull = {}, - excludeMatchers = [], - excludeFull = {}; - - final include = (yamlMap[strings.include] as YamlList?)?.cast(); - if (include != null) { - if (include.isEmpty) { - return Includer.excludeByDefault(); - } - for (final str in include) { - if (isFullDeclarationName(str)) { - includeFull.add(str); - } else { - includeMatchers.add(RegExp(str, dotAll: true)); - } - } - } - - final exclude = (yamlMap[strings.exclude] as YamlList?)?.cast(); - if (exclude != null) { - for (final str in exclude) { - if (isFullDeclarationName(str)) { - excludeFull.add(str); - } else { - excludeMatchers.add(RegExp(str, dotAll: true)); - } - } - } - - return Includer( - includeMatchers: includeMatchers, - includeFull: includeFull, - excludeMatchers: excludeMatchers, - excludeFull: excludeFull, - ); -} - -Declaration declarationConfigExtractor(dynamic yamlMap) { - final renamePatterns = []; - final renameFull = {}; - final memberRenamePatterns = []; - final memberRenamerFull = {}; - - final includer = _extractIncluderFromYaml(yamlMap); - - Includer? symbolIncluder; - if (yamlMap[strings.symbolAddress] != null) { - symbolIncluder = _extractIncluderFromYaml(yamlMap[strings.symbolAddress]); - } - - final rename = (yamlMap[strings.rename] as YamlMap?)?.cast(); - - if (rename != null) { - for (final str in rename.keys) { - if (isFullDeclarationName(str)) { - renameFull[str] = rename[str]!; - } else { - renamePatterns - .add(RegExpRenamer(RegExp(str, dotAll: true), rename[str]!)); - } - } - } - - final memberRename = - (yamlMap[strings.memberRename] as YamlMap?)?.cast(); - - if (memberRename != null) { - for (final decl in memberRename.keys) { - final renamePatterns = []; - final renameFull = {}; - - final memberRenameMap = memberRename[decl]!.cast(); - for (final member in memberRenameMap.keys) { - if (isFullDeclarationName(member)) { - renameFull[member] = memberRenameMap[member]!; - } else { - renamePatterns.add(RegExpRenamer( - RegExp(member, dotAll: true), memberRenameMap[member]!)); - } - } - if (isFullDeclarationName(decl)) { - memberRenamerFull[decl] = Renamer( - renameFull: renameFull, - renamePatterns: renamePatterns, - ); - } else { - memberRenamePatterns.add( - RegExpMemberRenamer( - RegExp(decl, dotAll: true), - Renamer( - renameFull: renameFull, - renamePatterns: renamePatterns, - ), - ), - ); - } - } - } - - return Declaration( - includer: includer, - renamer: Renamer( - renameFull: renameFull, - renamePatterns: renamePatterns, - ), - memberRenamer: MemberRenamer( - memberRenameFull: memberRenamerFull, - memberRenamePattern: memberRenamePatterns, - ), - symbolAddressIncluder: symbolIncluder, - ); -} - -bool declarationConfigValidator(List name, dynamic value) { - var _result = true; - if (value is YamlMap) { - for (final key in value.keys) { - if (key == strings.include || key == strings.exclude) { - if (!checkType([...name, key as String], value[key])) { - _result = false; - } - } else if (key == strings.rename) { - if (!checkType([...name, key as String], value[key])) { - _result = false; - } else { - for (final subkey in (value[key] as YamlMap).keys) { - if (!checkType( - [...name, key, subkey as String], value[key][subkey])) { - _result = false; - } - } - } - } else if (key == strings.memberRename) { - if (!checkType([...name, key as String], value[key])) { - _result = false; - } else { - for (final declNameKey in (value[key] as YamlMap).keys) { - if (!checkType([...name, key, declNameKey as String], - value[key][declNameKey])) { - _result = false; - } else { - for (final memberNameKey - in ((value[key] as YamlMap)[declNameKey] as YamlMap).keys) { - if (!checkType([ - ...name, - key, - declNameKey, - memberNameKey as String, - ], value[key][declNameKey][memberNameKey])) { - _result = false; - } - } - } - } - } - } else if (key == strings.symbolAddress) { - if (!checkType([...name, key as String], value[key])) { - _result = false; - } else { - for (final subkey in (value[key] as YamlMap).keys) { - if (subkey == strings.include || subkey == strings.exclude) { - if (!checkType( - [...name, key, subkey as String], value[key][subkey])) { - _result = false; - } - } else { - _logger.severe("Unknown key '$subkey' in '$name -> $key'."); - _result = false; - } - } - } - } - } - } else { - _logger.severe("Expected value '$name' to be a Map."); - _result = false; - } - return _result; -} - -Includer exposeFunctionTypeExtractor(dynamic value) => - _extractIncluderFromYaml(value); - -bool exposeFunctionTypeValidator(List name, dynamic value) { - var _result = true; - - if (!checkType(name, value)) { - _result = false; - } else { - final mp = value as YamlMap; - for (final key in mp.keys) { - if (key == strings.include || key == strings.exclude) { - if (!checkType([...name, key as String], value[key])) { - _result = false; - } - } else { - _logger.severe("Unknown subkey '$key' in '$name'."); - _result = false; - } - } - } - - return _result; -} - -Includer leafFunctionExtractor(dynamic value) => - _extractIncluderFromYaml(value); - -bool leafFunctionValidator(List name, dynamic value) { - var _result = true; - - if (!checkType(name, value)) { - _result = false; - } else { - final mp = value as YamlMap; - for (final key in mp.keys) { - if (key == strings.include || key == strings.exclude) { - if (!checkType([...name, key as String], value[key])) { - _result = false; - } - } else { - _logger.severe("Unknown subkey '$key' in '$name'."); - _result = false; - } - } - } - - return _result; -} - -SupportedNativeType nativeSupportedType(int value, {bool signed = true}) { - switch (value) { - case 1: - return signed ? SupportedNativeType.Int8 : SupportedNativeType.Uint8; - case 2: - return signed ? SupportedNativeType.Int16 : SupportedNativeType.Uint16; - case 4: - return signed ? SupportedNativeType.Int32 : SupportedNativeType.Uint32; - case 8: - return signed ? SupportedNativeType.Int64 : SupportedNativeType.Uint64; - default: - throw Exception( - 'Unsupported value given to sizemap, Allowed values for sizes are: 1, 2, 4, 8'); - } -} - -String stringExtractor(dynamic value) => value as String; - -bool nonEmptyStringValidator(List name, dynamic value) { - if (value is String && value.isNotEmpty) { - return true; - } else { - _logger.severe("Expected value of key '$name' to be a non-empty String."); - return false; - } -} - -bool dartClassNameValidator(List name, dynamic value) { - if (value is String && - quiver.matchesFull(RegExp('[a-zA-Z]+[_a-zA-Z0-9]*'), value)) { - return true; - } else { - _logger.severe( - "Expected value of key '$name' to be a valid public class name."); - return false; - } -} - -CommentType commentExtractor(dynamic value) { - if (value is bool) { - if (value) { - return CommentType.def(); - } else { - return CommentType.none(); - } - } - final ct = CommentType.def(); - if (value is YamlMap) { - for (final key in value.keys) { - if (key == strings.style) { - if (value[key] == strings.any) { - ct.style = CommentStyle.any; - } else if (value[key] == strings.doxygen) { - ct.style = CommentStyle.doxygen; - } - } else if (key == strings.length) { - if (value[key] == strings.full) { - ct.length = CommentLength.full; - } else if (value[key] == strings.brief) { - ct.length = CommentLength.brief; - } - } - } - } - return ct; -} - -bool commentValidator(List name, dynamic value) { - if (value is bool) { - return true; - } else if (value is YamlMap) { - var result = true; - for (final key in value.keys) { - if (key == strings.style) { - if (value[key] is! String || - !(value[key] == strings.doxygen || value[key] == strings.any)) { - _logger.severe( - "'$name'>'${strings.style}' must be one of the following - {${strings.doxygen}, ${strings.any}}"); - result = false; - } - } else if (key == strings.length) { - if (value[key] is! String || - !(value[key] == strings.brief || value[key] == strings.full)) { - _logger.severe( - "'$name'>'${strings.length}' must be one of the following - {${strings.brief}, ${strings.full}}"); - result = false; - } - } else { - _logger.severe("Unknown key '$key' in '$name'."); - result = false; - } - } - return result; - } else { - _logger.severe("Expected value of key '$name' to be a bool or a Map."); - return false; - } -} - -CompoundDependencies dependencyOnlyExtractor(dynamic value) { - var result = CompoundDependencies.full; - if (value == strings.opaqueCompoundDependencies) { - result = CompoundDependencies.opaque; - } - return result; -} - -bool dependencyOnlyValidator(List name, dynamic value) { - var result = true; - if (value is! String || - !(value == strings.fullCompoundDependencies || - value == strings.opaqueCompoundDependencies)) { - _logger.severe( - "'$name' must be one of the following - {${strings.fullCompoundDependencies}, ${strings.opaqueCompoundDependencies}}"); - result = false; - } - return result; -} - -StructPackingOverride structPackingOverrideExtractor(dynamic value) { - final matcherMap = {}; - for (final key in (value as YamlMap).keys) { - matcherMap[RegExp(key as String, dotAll: true)] = - strings.packingValuesMap[value[key]]; - } - return StructPackingOverride(matcherMap: matcherMap); -} - -bool structPackingOverrideValidator(List name, dynamic value) { - var _result = true; - - if (!checkType([...name], value)) { - _result = false; - } else { - for (final key in (value as YamlMap).keys) { - if (!(strings.packingValuesMap.keys.contains(value[key]))) { - _logger.severe( - "'$name -> $key' must be one of the following - ${strings.packingValuesMap.keys.toList()}"); - _result = false; - } - } - } - - return _result; -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/executables/ffigen.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/executables/ffigen.dart deleted file mode 100644 index 12dd868d1..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/executables/ffigen.dart +++ /dev/null @@ -1,223 +0,0 @@ -// Copyright (c) 2021, 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. - -// Executable script to generate bindings for some C library. -import 'dart:io'; - -import 'package:args/args.dart'; -import 'package:cli_util/cli_logging.dart' show Ansi; -import 'package:ffigen/ffigen.dart'; -import 'package:logging/logging.dart'; -import 'package:yaml/yaml.dart' as yaml; - -final _logger = Logger('ffigen.ffigen'); -final _ansi = Ansi(Ansi.terminalSupportsAnsi); - -const compilerOpts = 'compiler-opts'; -const conf = 'config'; -const help = 'help'; -const verbose = 'verbose'; -const pubspecName = 'pubspec.yaml'; -const configKey = 'ffigen'; -const logAll = 'all'; -const logFine = 'fine'; -const logInfo = 'info'; -const logWarning = 'warning'; -const logSevere = 'severe'; - -String successPen(String str) { - return '${_ansi.green}$str${_ansi.none}'; -} - -String errorPen(String str) { - return '${_ansi.red}$str${_ansi.none}'; -} - -void main(List args) { - // Parses the cmd args. This will print usage and exit if --help was passed. - final argResult = getArgResults(args); - - // Setup logging level and printing. - setupLogger(argResult); - - // Create a config object. - Config config; - try { - config = getConfig(argResult); - } on FormatException { - _logger.severe('Please fix configuration errors and re-run the tool.'); - exit(1); - } - - // Parse the bindings according to config object provided. - final library = parse(config); - - // Generate file for the parsed bindings. - final gen = File(config.output); - library.generateFile(gen); - _logger - .info(successPen('Finished, Bindings generated in ${gen.absolute.path}')); -} - -Config getConfig(ArgResults result) { - _logger.info('Running in ${Directory.current}'); - Config config; - - // Parse config from yaml. - if (result.wasParsed(conf)) { - config = getConfigFromCustomYaml(result[conf] as String); - } else { - config = getConfigFromPubspec(); - } - - // Add compiler options from command line. - if (result.wasParsed(compilerOpts)) { - _logger.fine('Passed compiler opts - "${result[compilerOpts]}"'); - config.addCompilerOpts((result[compilerOpts] as String), - highPriority: true); - } - - return config; -} - -/// Extracts configuration from pubspec file. -Config getConfigFromPubspec() { - final pubspecFile = File(pubspecName); - - if (!pubspecFile.existsSync()) { - _logger.severe( - 'Error: $pubspecName not found, please run this tool from the root of your package.'); - exit(1); - } - - // Casting this because pubspec is expected to be a YamlMap. - - // Throws a [YamlException] if it's unable to parse the Yaml. - final bindingsConfigMap = - yaml.loadYaml(pubspecFile.readAsStringSync())[configKey] as yaml.YamlMap?; - - if (bindingsConfigMap == null) { - _logger.severe("Couldn't find an entry for '$configKey' in $pubspecName."); - exit(1); - } - return Config.fromYaml(bindingsConfigMap); -} - -/// Extracts configuration from a custom yaml file. -Config getConfigFromCustomYaml(String yamlPath) { - final yamlFile = File(yamlPath); - - if (!yamlFile.existsSync()) { - _logger.severe('Error: $yamlPath not found.'); - exit(1); - } - - // Throws a [YamlException] if it's unable to parse the Yaml. - final bindingsConfigMap = - yaml.loadYaml(yamlFile.readAsStringSync()) as yaml.YamlMap; - - return Config.fromYaml(bindingsConfigMap); -} - -/// Parses the cmd line arguments. -ArgResults getArgResults(List args) { - final parser = ArgParser(allowTrailingOptions: true); - - parser.addSeparator( - 'FFIGEN: Generate dart bindings from C header files\nUsage:'); - parser.addOption( - conf, - help: 'Path to Yaml file containing configurations if not in pubspec.yaml', - ); - parser.addOption( - verbose, - abbr: 'v', - defaultsTo: logInfo, - allowed: [ - logAll, - logFine, - logInfo, - logWarning, - logSevere, - ], - ); - parser.addFlag( - help, - abbr: 'h', - help: 'Prints this usage', - negatable: false, - ); - parser.addOption( - compilerOpts, - help: 'Compiler options for clang. (E.g --$compilerOpts "-I/headers -W")', - ); - - ArgResults results; - try { - results = parser.parse(args); - - if (results.wasParsed(help)) { - print(parser.usage); - exit(0); - } - } catch (e) { - print(e); - print(parser.usage); - exit(1); - } - - return results; -} - -/// Sets up the logging level and printing. -void setupLogger(ArgResults result) { - if (result.wasParsed(verbose)) { - switch (result[verbose] as String?) { - case logAll: - // Logs everything, the entire AST touched by our parser. - Logger.root.level = Level.ALL; - break; - case logFine: - // Logs AST parts relevant to user (i.e those included in filters). - Logger.root.level = Level.FINE; - break; - case logInfo: - // Logs relevant info for general user (default). - Logger.root.level = Level.INFO; - break; - case logWarning: - // Logs warnings for relevant stuff. - Logger.root.level = Level.WARNING; - break; - case logSevere: - // Logs severe warnings and errors. - Logger.root.level = Level.SEVERE; - break; - } - // Setup logger for printing (if verbosity was set by user). - Logger.root.onRecord.listen((record) { - final level = '[${record.level.name}]'.padRight(9); - printLog('$level: ${record.message}', record.level); - }); - } else { - // Setup logger for printing (if verbosity was not set by user). - Logger.root.onRecord.listen((record) { - if (record.level.value > Level.INFO.value) { - final level = '[${record.level.name}]'.padRight(9); - printLog('$level: ${record.message}', record.level); - } else { - printLog(record.message, record.level); - } - }); - } -} - -void printLog(String log, Level level) { - // Prints text in red for Severe logs only. - if (level < Level.SEVERE) { - print(log); - } else { - print(errorPen(log)); - } -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser.dart deleted file mode 100644 index e4dc2c944..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser.dart +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) 2020, 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 a [Library] (code_generator) -/// -/// Parses the header files AST using clang_bindings. -library header_parser; - -export 'header_parser/parser.dart' show parse; diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/clang_bindings/clang_bindings.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/clang_bindings/clang_bindings.dart deleted file mode 100644 index 58108aaee..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/clang_bindings/clang_bindings.dart +++ /dev/null @@ -1,2569 +0,0 @@ -// Part of the LLVM Project, under the Apache License v2.0 with LLVM -// Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -// ignore_for_file: camel_case_types, non_constant_identifier_names - -// AUTO GENERATED FILE, DO NOT EDIT. -// -// Generated by `package:ffigen`. -import 'dart:ffi' as ffi; - -/// Holds bindings to LibClang. -class Clang { - /// Holds the symbol lookup function. - final ffi.Pointer Function(String symbolName) - _lookup; - - /// The symbols are looked up in [dynamicLibrary]. - Clang(ffi.DynamicLibrary dynamicLibrary) : _lookup = dynamicLibrary.lookup; - - /// The symbols are looked up with [lookup]. - Clang.fromLookup( - 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 Function(CXString)>>( - 'clang_getCString'); - late final _clang_getCString = _clang_getCStringPtr - .asFunction Function(CXString)>(); - - /// 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(); - - /// 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 - /// - /// 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, - ); - } - - late final _clang_createIndexPtr = - _lookup>( - 'clang_createIndex'); - late final _clang_createIndex = - _clang_createIndexPtr.asFunction(); - - /// 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_disposeIndexPtr = - _lookup>( - 'clang_disposeIndex'); - late final _clang_disposeIndex = - _clang_disposeIndexPtr.asFunction(); - - /// Retrieve the complete file and path name of the given file. - CXString clang_getFileName( - CXFile SFile, - ) { - return _clang_getFileName( - SFile, - ); - } - - late final _clang_getFileNamePtr = - _lookup>( - 'clang_getFileName'); - late final _clang_getFileName = - _clang_getFileNamePtr.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(); - - /// 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, - ); - } - - late final _clang_equalRangesPtr = _lookup< - ffi.NativeFunction< - ffi.UnsignedInt Function( - CXSourceRange, CXSourceRange)>>('clang_equalRanges'); - late final _clang_equalRanges = _clang_equalRangesPtr - .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. - /// - /// \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_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)>(); - - /// Determine the number of diagnostics produced for the given - /// translation unit. - int clang_getNumDiagnostics( - CXTranslationUnit Unit, - ) { - return _clang_getNumDiagnostics( - Unit, - ); - } - - late final _clang_getNumDiagnosticsPtr = - _lookup>( - 'clang_getNumDiagnostics'); - late final _clang_getNumDiagnostics = - _clang_getNumDiagnosticsPtr.asFunction(); - - /// 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_getDiagnosticPtr = _lookup< - ffi.NativeFunction< - CXDiagnostic Function( - CXTranslationUnit, ffi.UnsignedInt)>>('clang_getDiagnostic'); - late final _clang_getDiagnostic = _clang_getDiagnosticPtr - .asFunction(); - - /// Destroy a diagnostic. - void clang_disposeDiagnostic( - CXDiagnostic Diagnostic, - ) { - return _clang_disposeDiagnostic( - Diagnostic, - ); - } - - late final _clang_disposeDiagnosticPtr = - _lookup>( - 'clang_disposeDiagnostic'); - late final _clang_disposeDiagnostic = - _clang_disposeDiagnosticPtr.asFunction(); - - /// Format the given diagnostic in a manner that is suitable for display. - /// - /// 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_formatDiagnosticPtr = _lookup< - ffi.NativeFunction>( - 'clang_formatDiagnostic'); - late final _clang_formatDiagnostic = _clang_formatDiagnosticPtr - .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, - ); - } - - 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)>(); - - /// Destroy the specified CXTranslationUnit object. - void clang_disposeTranslationUnit( - CXTranslationUnit arg0, - ) { - return _clang_disposeTranslationUnit( - arg0, - ); - } - - late final _clang_disposeTranslationUnitPtr = - _lookup>( - 'clang_disposeTranslationUnit'); - late final _clang_disposeTranslationUnit = _clang_disposeTranslationUnitPtr - .asFunction(); - - /// 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_getTranslationUnitCursorPtr = - _lookup>( - 'clang_getTranslationUnitCursor'); - late final _clang_getTranslationUnitCursor = - _clang_getTranslationUnitCursorPtr - .asFunction(); - - /// Returns non-zero if \p cursor is null. - int clang_Cursor_isNull( - CXCursor cursor, - ) { - return _clang_Cursor_isNull( - cursor, - ); - } - - late final _clang_Cursor_isNullPtr = - _lookup>( - 'clang_Cursor_isNull'); - late final _clang_Cursor_isNull = - _clang_Cursor_isNullPtr.asFunction(); - - /// Retrieve the kind of the given cursor. - int clang_getCursorKind( - CXCursor arg0, - ) { - return _clang_getCursorKind( - arg0, - ); - } - - late final _clang_getCursorKindPtr = - _lookup>( - 'clang_getCursorKind'); - late final _clang_getCursorKind = - _clang_getCursorKindPtr.asFunction(); - - /// Determine whether the given cursor has any attributes. - int clang_Cursor_hasAttrs( - CXCursor C, - ) { - return _clang_Cursor_hasAttrs( - C, - ); - } - - late final _clang_Cursor_hasAttrsPtr = - _lookup>( - 'clang_Cursor_hasAttrs'); - late final _clang_Cursor_hasAttrs = - _clang_Cursor_hasAttrsPtr.asFunction(); - - /// Retrieve the physical location of the source constructor referenced - /// by the given cursor. - /// - /// 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_getCursorLocationPtr = - _lookup>( - 'clang_getCursorLocation'); - late final _clang_getCursorLocation = _clang_getCursorLocationPtr - .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_getCursorType = - _clang_getCursorTypePtr.asFunction(); - - /// 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_getTypeSpellingPtr = - _lookup>( - 'clang_getTypeSpelling'); - late final _clang_getTypeSpelling = - _clang_getTypeSpellingPtr.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, - ); - } - - late final _clang_getTypedefDeclUnderlyingTypePtr = - _lookup>( - 'clang_getTypedefDeclUnderlyingType'); - late final _clang_getTypedefDeclUnderlyingType = - _clang_getTypedefDeclUnderlyingTypePtr - .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, - ); - } - - late final _clang_getEnumConstantDeclValuePtr = - _lookup>( - 'clang_getEnumConstantDeclValue'); - late final _clang_getEnumConstantDeclValue = - _clang_getEnumConstantDeclValuePtr.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, - ); - } - - late final _clang_getFieldDeclBitWidthPtr = - _lookup>( - 'clang_getFieldDeclBitWidth'); - late final _clang_getFieldDeclBitWidth = - _clang_getFieldDeclBitWidthPtr.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, - ); - } - - late final _clang_Cursor_getNumArgumentsPtr = - _lookup>( - 'clang_Cursor_getNumArguments'); - late final _clang_Cursor_getNumArguments = - _clang_Cursor_getNumArgumentsPtr.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, - ); - } - - late final _clang_Cursor_getArgumentPtr = - _lookup>( - 'clang_Cursor_getArgument'); - late final _clang_Cursor_getArgument = _clang_Cursor_getArgumentPtr - .asFunction(); - - /// Return the canonical type for a CXType. - /// - /// 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_getCanonicalTypePtr = - _lookup>( - 'clang_getCanonicalType'); - late final _clang_getCanonicalType = - _clang_getCanonicalTypePtr.asFunction(); - - /// 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_Cursor_isMacroFunctionLikePtr = - _lookup>( - 'clang_Cursor_isMacroFunctionLike'); - late final _clang_Cursor_isMacroFunctionLike = - _clang_Cursor_isMacroFunctionLikePtr.asFunction(); - - /// 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_Cursor_isMacroBuiltinPtr = - _lookup>( - 'clang_Cursor_isMacroBuiltin'); - late final _clang_Cursor_isMacroBuiltin = - _clang_Cursor_isMacroBuiltinPtr.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, - ); - } - - late final _clang_Cursor_isFunctionInlinedPtr = - _lookup>( - 'clang_Cursor_isFunctionInlined'); - late final _clang_Cursor_isFunctionInlined = - _clang_Cursor_isFunctionInlinedPtr.asFunction(); - - /// Returns the typedef name of the given type. - CXString clang_getTypedefName( - CXType CT, - ) { - return _clang_getTypedefName( - CT, - ); - } - - late final _clang_getTypedefNamePtr = - _lookup>( - 'clang_getTypedefName'); - late final _clang_getTypedefName = - _clang_getTypedefNamePtr.asFunction(); - - /// For pointer types, returns the type of the pointee. - CXType clang_getPointeeType( - CXType T, - ) { - return _clang_getPointeeType( - T, - ); - } - - late final _clang_getPointeeTypePtr = - _lookup>( - 'clang_getPointeeType'); - late final _clang_getPointeeType = - _clang_getPointeeTypePtr.asFunction(); - - /// Return the cursor for the declaration of the given type. - CXCursor clang_getTypeDeclaration( - CXType T, - ) { - return _clang_getTypeDeclaration( - T, - ); - } - - late final _clang_getTypeDeclarationPtr = - _lookup>( - 'clang_getTypeDeclaration'); - late final _clang_getTypeDeclaration = - _clang_getTypeDeclarationPtr.asFunction(); - - /// Retrieve the spelling of a given CXTypeKind. - CXString clang_getTypeKindSpelling( - int K, - ) { - return _clang_getTypeKindSpelling( - K, - ); - } - - late final _clang_getTypeKindSpellingPtr = - _lookup>( - 'clang_getTypeKindSpelling'); - late final _clang_getTypeKindSpelling = - _clang_getTypeKindSpellingPtr.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, - ); - } - - late final _clang_getResultTypePtr = - _lookup>( - 'clang_getResultType'); - late final _clang_getResultType = - _clang_getResultTypePtr.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, - ); - } - - late final _clang_getNumArgTypesPtr = - _lookup>( - 'clang_getNumArgTypes'); - late final _clang_getNumArgTypes = - _clang_getNumArgTypesPtr.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, - ); - } - - late final _clang_getArgTypePtr = - _lookup>( - 'clang_getArgType'); - late final _clang_getArgType = - _clang_getArgTypePtr.asFunction(); - - /// Retrieves the base type of the ObjCObjectType. - /// - /// 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_Type_getObjCObjectBaseTypePtr = - _lookup>( - 'clang_Type_getObjCObjectBaseType'); - late final _clang_Type_getObjCObjectBaseType = - _clang_Type_getObjCObjectBaseTypePtr - .asFunction(); - - /// Return the number of elements of an array or vector 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, - ); - } - - late final _clang_getNumElementsPtr = - _lookup>( - 'clang_getNumElements'); - late final _clang_getNumElements = - _clang_getNumElementsPtr.asFunction(); - - /// Return the element type of an array type. - /// - /// If a non-array type is passed in, an invalid type is returned. - CXType clang_getArrayElementType( - CXType T, - ) { - return _clang_getArrayElementType( - T, - ); - } - - late final _clang_getArrayElementTypePtr = - _lookup>( - 'clang_getArrayElementType'); - late final _clang_getArrayElementType = - _clang_getArrayElementTypePtr.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, - ); - } - - late final _clang_Type_getNamedTypePtr = - _lookup>( - 'clang_Type_getNamedType'); - late final _clang_Type_getNamedType = - _clang_Type_getNamedTypePtr.asFunction(); - - /// Retrieve the nullability kind of a pointer type. - int clang_Type_getNullability( - CXType T, - ) { - return _clang_Type_getNullability( - T, - ); - } - - late final _clang_Type_getNullabilityPtr = - _lookup>( - 'clang_Type_getNullability'); - late final _clang_Type_getNullability = - _clang_Type_getNullabilityPtr.asFunction(); - - /// 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_Type_getAlignOfPtr = - _lookup>( - 'clang_Type_getAlignOf'); - late final _clang_Type_getAlignOf = - _clang_Type_getAlignOfPtr.asFunction(); - - /// 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_Cursor_isAnonymousPtr = - _lookup>( - 'clang_Cursor_isAnonymous'); - late final _clang_Cursor_isAnonymous = - _clang_Cursor_isAnonymousPtr.asFunction(); - - /// Determine whether the given cursor represents an anonymous record - /// declaration. - int clang_Cursor_isAnonymousRecordDecl( - CXCursor C, - ) { - return _clang_Cursor_isAnonymousRecordDecl( - C, - ); - } - - late final _clang_Cursor_isAnonymousRecordDeclPtr = - _lookup>( - 'clang_Cursor_isAnonymousRecordDecl'); - late final _clang_Cursor_isAnonymousRecordDecl = - _clang_Cursor_isAnonymousRecordDeclPtr - .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< - ffi.NativeFunction< - ffi.UnsignedInt Function( - CXCursor, CXCursorVisitor, CXClientData)>>('clang_visitChildren'); - late final _clang_visitChildren = _clang_visitChildrenPtr - .asFunction(); - - /// Retrieve a Unified Symbol Resolution (USR) for the entity referenced - /// by the given 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, - ); - } - - late final _clang_getCursorUSRPtr = - _lookup>( - 'clang_getCursorUSR'); - late final _clang_getCursorUSR = - _clang_getCursorUSRPtr.asFunction(); - - /// Retrieve a name for the entity referenced by this cursor. - CXString clang_getCursorSpelling( - CXCursor arg0, - ) { - return _clang_getCursorSpelling( - arg0, - ); - } - - late final _clang_getCursorSpellingPtr = - _lookup>( - 'clang_getCursorSpelling'); - late final _clang_getCursorSpelling = - _clang_getCursorSpellingPtr.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). - /// - /// 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(); - - /// Given a cursor that represents a property declaration, return the - /// associated property attributes. The bits are formed from - /// \c CXObjCPropertyAttrKind. - /// - /// \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_Cursor_getObjCPropertyAttributesPtr = _lookup< - ffi.NativeFunction< - ffi.UnsignedInt Function(CXCursor, - ffi.UnsignedInt)>>('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, - ); - } - - late final _clang_Cursor_getObjCPropertyGetterNamePtr = - _lookup>( - 'clang_Cursor_getObjCPropertyGetterName'); - late final _clang_Cursor_getObjCPropertyGetterName = - _clang_Cursor_getObjCPropertyGetterNamePtr - .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 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_Cursor_getCommentRangePtr = - _lookup>( - 'clang_Cursor_getCommentRange'); - late final _clang_Cursor_getCommentRange = _clang_Cursor_getCommentRangePtr - .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, - ); - } - - late final _clang_Cursor_getRawCommentTextPtr = - _lookup>( - 'clang_Cursor_getRawCommentText'); - late final _clang_Cursor_getRawCommentText = - _clang_Cursor_getRawCommentTextPtr - .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, - ); - } - - late final _clang_Cursor_getBriefCommentTextPtr = - _lookup>( - 'clang_Cursor_getBriefCommentText'); - late final _clang_Cursor_getBriefCommentText = - _clang_Cursor_getBriefCommentTextPtr - .asFunction(); - - /// \defgroup CINDEX_DEBUG Debugging facilities - /// - /// These routines are used for testing and debugging, only, and should not - /// be relied upon. - /// - /// @{ - CXString clang_getCursorKindSpelling( - int Kind, - ) { - return _clang_getCursorKindSpelling( - Kind, - ); - } - - late final _clang_getCursorKindSpellingPtr = - _lookup>( - 'clang_getCursorKindSpelling'); - late final _clang_getCursorKindSpelling = - _clang_getCursorKindSpellingPtr.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, - ); - } - - late final _clang_Cursor_EvaluatePtr = - _lookup>( - 'clang_Cursor_Evaluate'); - late final _clang_Cursor_Evaluate = - _clang_Cursor_EvaluatePtr.asFunction(); - - /// Returns the kind of the evaluated result. - int clang_EvalResult_getKind( - CXEvalResult E, - ) { - return _clang_EvalResult_getKind( - E, - ); - } - - late final _clang_EvalResult_getKindPtr = - _lookup>( - 'clang_EvalResult_getKind'); - late final _clang_EvalResult_getKind = - _clang_EvalResult_getKindPtr.asFunction(); - - /// 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_EvalResult_getAsIntPtr = - _lookup>( - 'clang_EvalResult_getAsInt'); - late final _clang_EvalResult_getAsInt = - _clang_EvalResult_getAsIntPtr.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, - ); - } - - late final _clang_EvalResult_getAsLongLongPtr = - _lookup>( - 'clang_EvalResult_getAsLongLong'); - late final _clang_EvalResult_getAsLongLong = - _clang_EvalResult_getAsLongLongPtr - .asFunction(); - - /// 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_EvalResult_getAsDoublePtr = - _lookup>( - 'clang_EvalResult_getAsDouble'); - late final _clang_EvalResult_getAsDouble = _clang_EvalResult_getAsDoublePtr - .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, - ); - } - - late final _clang_EvalResult_getAsStrPtr = - _lookup Function(CXEvalResult)>>( - 'clang_EvalResult_getAsStr'); - late final _clang_EvalResult_getAsStr = _clang_EvalResult_getAsStrPtr - .asFunction Function(CXEvalResult)>(); - - /// Disposes the created Eval memory. - void clang_EvalResult_dispose( - CXEvalResult E, - ) { - return _clang_EvalResult_dispose( - E, - ); - } - - late final _clang_EvalResult_disposePtr = - _lookup>( - 'clang_EvalResult_dispose'); - late final _clang_EvalResult_dispose = - _clang_EvalResult_disposePtr.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. -class CXString extends ffi.Struct { - external ffi.Pointer data; - - @ffi.UnsignedInt() - external int private_flags; -} - -class CXTranslationUnitImpl extends ffi.Opaque {} - -/// 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. -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; - - /// A buffer containing the unsaved contents of this file. - external ffi.Pointer Contents; - - /// The length of the unsaved contents of this buffer. - @ffi.UnsignedLong() - external int Length; -} - -/// 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 particular source file that is part of a translation unit. -typedef CXFile = ffi.Pointer; - -/// 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. -class CXSourceLocation extends ffi.Struct { - @ffi.Array.multi([2]) - external ffi.Array> ptr_data; - - @ffi.UnsignedInt() - external int int_data; -} - -/// 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. -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; -} - -/// A single translation unit, which resides in an index. -typedef CXTranslationUnit = ffi.Pointer; - -/// A single diagnostic, containing the diagnostic's severity, -/// location, text, source ranges, and fix-it hints. -typedef CXDiagnostic = ffi.Pointer; - -/// Options to control the display of diagnostics. -/// -/// The values in this enum are meant to be combined to customize the -/// behavior of \c clang_formatDiagnostic(). -abstract class CXDiagnosticDisplayOptions { - /// Display the source-location information where the - /// diagnostic was located. - /// - /// When set, diagnostics will be prefixed by the file, line, and - /// (optionally) column to which the diagnostic refers. For example, - /// - /// \code - /// test.c:28: warning: extra tokens at end of #endif directive - /// \endcode - /// - /// This option corresponds to the clang flag \c -fshow-source-location. - static const int CXDiagnostic_DisplaySourceLocation = 1; - - /// If displaying the source-location information of the - /// diagnostic, also include the column number. - /// - /// This option corresponds to the clang flag \c -fshow-column. - static const int CXDiagnostic_DisplayColumn = 2; - - /// If displaying the source-location information of the - /// diagnostic, also include information about source ranges in a - /// machine-parsable format. - /// - /// This option corresponds to the clang flag - /// \c -fdiagnostics-print-source-range-info. - static const int CXDiagnostic_DisplaySourceRanges = 4; - - /// Display the option name associated with this diagnostic, if any. - /// - /// The option name displayed (e.g., -Wconversion) will be placed in brackets - /// after the diagnostic text. This option corresponds to the clang flag - /// \c -fdiagnostics-show-option. - static const int CXDiagnostic_DisplayOption = 8; - - /// Display the category number associated with this diagnostic, if any. - /// - /// The category number is displayed within brackets after the diagnostic text. - /// This option corresponds to the clang flag - /// \c -fdiagnostics-show-category=id. - static const int CXDiagnostic_DisplayCategoryId = 16; - - /// Display the category name associated with this diagnostic, if any. - /// - /// The category name is displayed within brackets after the diagnostic text. - /// This option corresponds to the clang flag - /// \c -fdiagnostics-show-category=name. - static const int CXDiagnostic_DisplayCategoryName = 32; -} - -/// Flags that control the creation of translation units. -/// -/// The enumerators in this enumeration type are meant to be bitwise -/// ORed together to specify which options should be used when -/// constructing the translation unit. -abstract class CXTranslationUnit_Flags { - /// Used to indicate that no special translation-unit options are - /// needed. - static const int CXTranslationUnit_None = 0; - - /// Used to indicate that the parser should construct a "detailed" - /// preprocessing record, including all macro definitions and instantiations. - /// - /// Constructing a detailed preprocessing record requires more memory - /// and time to parse, since the information contained in the record - /// is usually not retained. However, it can be useful for - /// applications that require more detailed information about the - /// behavior of the preprocessor. - static const int CXTranslationUnit_DetailedPreprocessingRecord = 1; - - /// Used to indicate that the translation unit is incomplete. - /// - /// When a translation unit is considered "incomplete", semantic - /// analysis that is typically performed at the end of the - /// translation unit will be suppressed. For example, this suppresses - /// the completion of tentative declarations in C and of - /// instantiation of implicitly-instantiation function templates in - /// C++. This option is typically used when parsing a header with the - /// intent of producing a precompiled header. - static const int CXTranslationUnit_Incomplete = 2; - - /// Used to indicate that the translation unit should be built with an - /// implicit precompiled header for the preamble. - /// - /// An implicit precompiled header is used as an optimization when a - /// particular translation unit is likely to be reparsed many times - /// when the sources aren't changing that often. In this case, an - /// implicit precompiled header will be built containing all of the - /// initial includes at the top of the main file (what we refer to as - /// the "preamble" of the file). In subsequent parses, if the - /// preamble or the files in it have not changed, \c - /// clang_reparseTranslationUnit() will re-use the implicit - /// precompiled header to improve parsing performance. - static const int CXTranslationUnit_PrecompiledPreamble = 4; - - /// Used to indicate that the translation unit should cache some - /// code-completion results with each reparse of the source file. - /// - /// Caching of code-completion results is a performance optimization that - /// introduces some overhead to reparsing but improves the performance of - /// code-completion operations. - static const int CXTranslationUnit_CacheCompletionResults = 8; - - /// Used to indicate that the translation unit will be serialized with - /// \c clang_saveTranslationUnit. - /// - /// This option is typically used when parsing a header with the intent of - /// producing a precompiled header. - static const int CXTranslationUnit_ForSerialization = 16; - - /// DEPRECATED: Enabled chained precompiled preambles in C++. - /// - /// Note: this is a *temporary* option that is available only while - /// we are testing C++ precompiled preamble support. It is deprecated. - static const int CXTranslationUnit_CXXChainedPCH = 32; - - /// Used to indicate that function/method bodies should be skipped while - /// parsing. - /// - /// This option can be used to search for declarations/definitions while - /// ignoring the usages. - static const int CXTranslationUnit_SkipFunctionBodies = 64; - - /// Used to indicate that brief documentation comments should be - /// included into the set of code completions returned from this translation - /// unit. - static const int CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 128; - - /// 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). - static const int CXTranslationUnit_CreatePreambleOnFirstParse = 256; - - /// Do not stop processing when fatal errors are encountered. - /// - /// When fatal errors are encountered while parsing a translation unit, - /// semantic analysis is typically stopped early when compiling code. A common - /// source for fatal errors are unresolvable include files. For the - /// purposes of an IDE, this is undesirable behavior and as much information - /// as possible should be reported. Use this flag to enable this behavior. - static const int CXTranslationUnit_KeepGoing = 512; - - /// Sets the preprocessor in a mode for parsing a single file only. - static const int CXTranslationUnit_SingleFileParse = 1024; - - /// Used in combination with CXTranslationUnit_SkipFunctionBodies to - /// constrain the skipping of function bodies to the preamble. - /// - /// The function bodies of the main file are not skipped. - static const int CXTranslationUnit_LimitSkipFunctionBodiesToPreamble = 2048; - - /// Used to indicate that attributed types should be included in CXType. - static const int CXTranslationUnit_IncludeAttributedTypes = 4096; - - /// Used to indicate that implicit attributes should be visited. - static const int CXTranslationUnit_VisitImplicitAttributes = 8192; - - /// Used to indicate that non-errors from included files should be ignored. - /// - /// If set, clang_getDiagnosticSetFromTU() will not report e.g. warnings from - /// included files anymore. This speeds up clang_getDiagnosticSetFromTU() for - /// the case where these warnings are not of interest, as for an IDE for - /// example, which typically shows only the diagnostics in the main file. - static const int CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles = 16384; - - /// Tells the preprocessor not to skip excluded conditional blocks. - static const int CXTranslationUnit_RetainExcludedConditionalBlocks = 32768; -} - -/// Describes the kind of entity that a cursor refers to. -abstract class CXCursorKind { - /// A declaration whose specific kind is not exposed via this - /// interface. - /// - /// Unexposed declarations have the same operations as any other kind - /// of declaration; one can extract their location information, - /// spelling, find their definitions, etc. However, the specific kind - /// of the declaration is not reported. - static const int CXCursor_UnexposedDecl = 1; - - /// A C or C++ struct. - static const int CXCursor_StructDecl = 2; - - /// A C or C++ union. - static const int CXCursor_UnionDecl = 3; - - /// A C++ class. - static const int CXCursor_ClassDecl = 4; - - /// An enumeration. - static const int CXCursor_EnumDecl = 5; - - /// A field (in C) or non-static data member (in C++) in a - /// struct, union, or C++ class. - static const int CXCursor_FieldDecl = 6; - - /// An enumerator constant. - static const int CXCursor_EnumConstantDecl = 7; - - /// A function. - static const int CXCursor_FunctionDecl = 8; - - /// A variable. - static const int CXCursor_VarDecl = 9; - - /// A function or method parameter. - static const int CXCursor_ParmDecl = 10; - - /// An Objective-C \@interface. - static const int CXCursor_ObjCInterfaceDecl = 11; - - /// An Objective-C \@interface for a category. - static const int CXCursor_ObjCCategoryDecl = 12; - - /// An Objective-C \@protocol declaration. - static const int CXCursor_ObjCProtocolDecl = 13; - - /// An Objective-C \@property declaration. - static const int CXCursor_ObjCPropertyDecl = 14; - - /// An Objective-C instance variable. - static const int CXCursor_ObjCIvarDecl = 15; - - /// An Objective-C instance method. - static const int CXCursor_ObjCInstanceMethodDecl = 16; - - /// An Objective-C class method. - static const int CXCursor_ObjCClassMethodDecl = 17; - - /// An Objective-C \@implementation. - static const int CXCursor_ObjCImplementationDecl = 18; - - /// An Objective-C \@implementation for a category. - static const int CXCursor_ObjCCategoryImplDecl = 19; - - /// A typedef. - static const int CXCursor_TypedefDecl = 20; - - /// A C++ class method. - static const int CXCursor_CXXMethod = 21; - - /// A C++ namespace. - static const int CXCursor_Namespace = 22; - - /// A linkage specification, e.g. 'extern "C"'. - static const int CXCursor_LinkageSpec = 23; - - /// A C++ constructor. - static const int CXCursor_Constructor = 24; - - /// A C++ destructor. - static const int CXCursor_Destructor = 25; - - /// A C++ conversion function. - static const int CXCursor_ConversionFunction = 26; - - /// A C++ template type parameter. - static const int CXCursor_TemplateTypeParameter = 27; - - /// A C++ non-type template parameter. - static const int CXCursor_NonTypeTemplateParameter = 28; - - /// A C++ template template parameter. - static const int CXCursor_TemplateTemplateParameter = 29; - - /// A C++ function template. - static const int CXCursor_FunctionTemplate = 30; - - /// A C++ class template. - static const int CXCursor_ClassTemplate = 31; - - /// A C++ class template partial specialization. - static const int CXCursor_ClassTemplatePartialSpecialization = 32; - - /// A C++ namespace alias declaration. - static const int CXCursor_NamespaceAlias = 33; - - /// A C++ using directive. - static const int CXCursor_UsingDirective = 34; - - /// A C++ using declaration. - static const int CXCursor_UsingDeclaration = 35; - - /// A C++ alias declaration - static const int CXCursor_TypeAliasDecl = 36; - - /// An Objective-C \@synthesize definition. - static const int CXCursor_ObjCSynthesizeDecl = 37; - - /// An Objective-C \@dynamic definition. - static const int CXCursor_ObjCDynamicDecl = 38; - - /// An access specifier. - static const int CXCursor_CXXAccessSpecifier = 39; - static const int CXCursor_FirstDecl = 1; - static const int CXCursor_LastDecl = 39; - static const int CXCursor_FirstRef = 40; - static const int CXCursor_ObjCSuperClassRef = 40; - static const int CXCursor_ObjCProtocolRef = 41; - static const int CXCursor_ObjCClassRef = 42; - - /// A reference to a type declaration. - /// - /// A type reference occurs anywhere where a type is named but not - /// declared. For example, given: - /// - /// \code - /// typedef unsigned size_type; - /// size_type size; - /// \endcode - /// - /// The typedef is a declaration of size_type (CXCursor_TypedefDecl), - /// while the type of the variable "size" is referenced. The cursor - /// referenced by the type of size is the typedef for size_type. - static const int CXCursor_TypeRef = 43; - static const int CXCursor_CXXBaseSpecifier = 44; - - /// A reference to a class template, function template, template - /// template parameter, or class template partial specialization. - static const int CXCursor_TemplateRef = 45; - - /// A reference to a namespace or namespace alias. - static const int CXCursor_NamespaceRef = 46; - - /// A reference to a member of a struct, union, or class that occurs in - /// some non-expression context, e.g., a designated initializer. - static const int CXCursor_MemberRef = 47; - - /// A reference to a labeled statement. - /// - /// This cursor kind is used to describe the jump to "start_over" in the - /// goto statement in the following example: - /// - /// \code - /// start_over: - /// ++counter; - /// - /// goto start_over; - /// \endcode - /// - /// A label reference cursor refers to a label statement. - static const int CXCursor_LabelRef = 48; - - /// A reference to a set of overloaded functions or function templates - /// that has not yet been resolved to a specific function or function template. - /// - /// An overloaded declaration reference cursor occurs in C++ templates where - /// a dependent name refers to a function. For example: - /// - /// \code - /// template void swap(T&, T&); - /// - /// struct X { ... }; - /// void swap(X&, X&); - /// - /// template - /// void reverse(T* first, T* last) { - /// while (first < last - 1) { - /// swap(*first, *--last); - /// ++first; - /// } - /// } - /// - /// struct Y { }; - /// void swap(Y&, Y&); - /// \endcode - /// - /// Here, the identifier "swap" is associated with an overloaded declaration - /// reference. In the template definition, "swap" refers to either of the two - /// "swap" functions declared above, so both results will be available. At - /// instantiation time, "swap" may also refer to other functions found via - /// argument-dependent lookup (e.g., the "swap" function at the end of the - /// example). - /// - /// The functions \c clang_getNumOverloadedDecls() and - /// \c clang_getOverloadedDecl() can be used to retrieve the definitions - /// referenced by this cursor. - static const int CXCursor_OverloadedDeclRef = 49; - - /// A reference to a variable that occurs in some non-expression - /// context, e.g., a C++ lambda capture list. - static const int CXCursor_VariableRef = 50; - static const int CXCursor_LastRef = 50; - static const int CXCursor_FirstInvalid = 70; - static const int CXCursor_InvalidFile = 70; - static const int CXCursor_NoDeclFound = 71; - static const int CXCursor_NotImplemented = 72; - static const int CXCursor_InvalidCode = 73; - static const int CXCursor_LastInvalid = 73; - static const int CXCursor_FirstExpr = 100; - - /// 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 int CXCursor_UnexposedExpr = 100; - - /// An expression that refers to some value declaration, such - /// as a function, variable, or enumerator. - static const int CXCursor_DeclRefExpr = 101; - - /// An expression that refers to a member of a struct, union, - /// class, Objective-C class, etc. - static const int CXCursor_MemberRefExpr = 102; - - /// An expression that calls a function. - static const int CXCursor_CallExpr = 103; - - /// An expression that sends a message to an Objective-C - /// object or class. - static const int CXCursor_ObjCMessageExpr = 104; - - /// An expression that represents a block literal. - static const int CXCursor_BlockExpr = 105; - - /// An integer literal. - static const int CXCursor_IntegerLiteral = 106; - - /// A floating point number literal. - static const int CXCursor_FloatingLiteral = 107; - - /// An imaginary number literal. - static const int CXCursor_ImaginaryLiteral = 108; - - /// A string literal. - static const int CXCursor_StringLiteral = 109; - - /// A character literal. - static const int CXCursor_CharacterLiteral = 110; - - /// A parenthesized expression, e.g. "(1)". - /// - /// This AST node is only formed if full location information is requested. - static const int CXCursor_ParenExpr = 111; - - /// This represents the unary-expression's (except sizeof and - /// alignof). - static const int CXCursor_UnaryOperator = 112; - - /// [C99 6.5.2.1] Array Subscripting. - static const int CXCursor_ArraySubscriptExpr = 113; - - /// A builtin binary operation expression such as "x + y" or - /// "x <= y". - static const int CXCursor_BinaryOperator = 114; - - /// Compound assignment such as "+=". - static const int CXCursor_CompoundAssignOperator = 115; - - /// The ?: ternary operator. - static const int CXCursor_ConditionalOperator = 116; - - /// An explicit cast in C (C99 6.5.4) or a C-style cast in C++ - /// (C++ [expr.cast]), which uses the syntax (Type)expr. - /// - /// For example: (int)f. - static const int CXCursor_CStyleCastExpr = 117; - - /// [C99 6.5.2.5] - static const int CXCursor_CompoundLiteralExpr = 118; - - /// Describes an C or C++ initializer list. - static const int CXCursor_InitListExpr = 119; - - /// The GNU address of label extension, representing &&label. - static const int CXCursor_AddrLabelExpr = 120; - - /// This is the GNU Statement Expression extension: ({int X=4; X;}) - static const int CXCursor_StmtExpr = 121; - - /// Represents a C11 generic selection. - static const int CXCursor_GenericSelectionExpr = 122; - - /// Implements the GNU __null extension, which is a name for a null - /// pointer constant that has integral type (e.g., int or long) and is the same - /// size and alignment as a pointer. - /// - /// The __null extension is typically only used by system headers, which define - /// NULL as __null in C++ rather than using 0 (which is an integer that may not - /// match the size of a pointer). - static const int CXCursor_GNUNullExpr = 123; - - /// C++'s static_cast<> expression. - static const int CXCursor_CXXStaticCastExpr = 124; - - /// C++'s dynamic_cast<> expression. - static const int CXCursor_CXXDynamicCastExpr = 125; - - /// C++'s reinterpret_cast<> expression. - static const int CXCursor_CXXReinterpretCastExpr = 126; - - /// C++'s const_cast<> expression. - static const int CXCursor_CXXConstCastExpr = 127; - - /// Represents an explicit C++ type conversion that uses "functional" - /// notion (C++ [expr.type.conv]). - /// - /// Example: - /// \code - /// x = int(0.5); - /// \endcode - static const int CXCursor_CXXFunctionalCastExpr = 128; - - /// A C++ typeid expression (C++ [expr.typeid]). - static const int CXCursor_CXXTypeidExpr = 129; - - /// [C++ 2.13.5] C++ Boolean Literal. - static const int CXCursor_CXXBoolLiteralExpr = 130; - - /// [C++0x 2.14.7] C++ Pointer Literal. - static const int CXCursor_CXXNullPtrLiteralExpr = 131; - - /// Represents the "this" expression in C++ - static const int CXCursor_CXXThisExpr = 132; - - /// [C++ 15] C++ Throw Expression. - /// - /// This handles 'throw' and 'throw' assignment-expression. When - /// assignment-expression isn't present, Op will be null. - static const int CXCursor_CXXThrowExpr = 133; - - /// A new expression for memory allocation and constructor calls, e.g: - /// "new CXXNewExpr(foo)". - static const int CXCursor_CXXNewExpr = 134; - - /// A delete expression for memory deallocation and destructor calls, - /// e.g. "delete[] pArray". - static const int CXCursor_CXXDeleteExpr = 135; - - /// A unary expression. (noexcept, sizeof, or other traits) - static const int CXCursor_UnaryExpr = 136; - - /// An Objective-C string literal i.e. @"foo". - static const int CXCursor_ObjCStringLiteral = 137; - - /// An Objective-C \@encode expression. - static const int CXCursor_ObjCEncodeExpr = 138; - - /// An Objective-C \@selector expression. - static const int CXCursor_ObjCSelectorExpr = 139; - - /// An Objective-C \@protocol expression. - static const int CXCursor_ObjCProtocolExpr = 140; - - /// An Objective-C "bridged" cast expression, which casts between - /// Objective-C pointers and C pointers, transferring ownership in the process. - /// - /// \code - /// NSString *str = (__bridge_transfer NSString *)CFCreateString(); - /// \endcode - static const int CXCursor_ObjCBridgedCastExpr = 141; - - /// Represents a C++0x pack expansion that produces a sequence of - /// expressions. - /// - /// A pack expansion expression contains a pattern (which itself is an - /// expression) followed by an ellipsis. For example: - /// - /// \code - /// template - /// void forward(F f, Types &&...args) { - /// f(static_cast(args)...); - /// } - /// \endcode - static const int CXCursor_PackExpansionExpr = 142; - - /// Represents an expression that computes the length of a parameter - /// pack. - /// - /// \code - /// template - /// struct count { - /// static const unsigned value = sizeof...(Types); - /// }; - /// \endcode - static const int CXCursor_SizeOfPackExpr = 143; - static const int CXCursor_LambdaExpr = 144; - - /// Objective-c Boolean Literal. - static const int CXCursor_ObjCBoolLiteralExpr = 145; - - /// Represents the "self" expression in an Objective-C method. - static const int CXCursor_ObjCSelfExpr = 146; - - /// OpenMP 4.0 [2.4, Array Section]. - static const int CXCursor_OMPArraySectionExpr = 147; - - /// Represents an @available(...) check. - static const int CXCursor_ObjCAvailabilityCheckExpr = 148; - - /// Fixed point literal - static const int CXCursor_FixedPointLiteral = 149; - static const int CXCursor_LastExpr = 149; - static const int CXCursor_FirstStmt = 200; - - /// 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 int CXCursor_UnexposedStmt = 200; - - /// A labelled statement in a function. - /// - /// This cursor kind is used to describe the "start_over:" label statement in - /// the following example: - /// - /// \code - /// start_over: - /// ++counter; - /// \endcode - static const int CXCursor_LabelStmt = 201; - - /// A group of statements like { stmt stmt }. - /// - /// This cursor kind is used to describe compound statements, e.g. function - /// bodies. - static const int CXCursor_CompoundStmt = 202; - - /// A case statement. - static const int CXCursor_CaseStmt = 203; - - /// A default statement. - static const int CXCursor_DefaultStmt = 204; - - /// An if statement - static const int CXCursor_IfStmt = 205; - - /// A switch statement. - static const int CXCursor_SwitchStmt = 206; - - /// A while statement. - static const int CXCursor_WhileStmt = 207; - - /// A do statement. - static const int CXCursor_DoStmt = 208; - - /// A for statement. - static const int CXCursor_ForStmt = 209; - - /// A goto statement. - static const int CXCursor_GotoStmt = 210; - - /// An indirect goto statement. - static const int CXCursor_IndirectGotoStmt = 211; - - /// A continue statement. - static const int CXCursor_ContinueStmt = 212; - - /// A break statement. - static const int CXCursor_BreakStmt = 213; - - /// A return statement. - static const int CXCursor_ReturnStmt = 214; - - /// A GCC inline assembly statement extension. - static const int CXCursor_GCCAsmStmt = 215; - static const int CXCursor_AsmStmt = 215; - - /// Objective-C's overall \@try-\@catch-\@finally statement. - static const int CXCursor_ObjCAtTryStmt = 216; - - /// Objective-C's \@catch statement. - static const int CXCursor_ObjCAtCatchStmt = 217; - - /// Objective-C's \@finally statement. - static const int CXCursor_ObjCAtFinallyStmt = 218; - - /// Objective-C's \@throw statement. - static const int CXCursor_ObjCAtThrowStmt = 219; - - /// Objective-C's \@synchronized statement. - static const int CXCursor_ObjCAtSynchronizedStmt = 220; - - /// Objective-C's autorelease pool statement. - static const int CXCursor_ObjCAutoreleasePoolStmt = 221; - - /// Objective-C's collection statement. - static const int CXCursor_ObjCForCollectionStmt = 222; - - /// C++'s catch statement. - static const int CXCursor_CXXCatchStmt = 223; - - /// C++'s try statement. - static const int CXCursor_CXXTryStmt = 224; - - /// C++'s for (* : *) statement. - static const int CXCursor_CXXForRangeStmt = 225; - - /// Windows Structured Exception Handling's try statement. - static const int CXCursor_SEHTryStmt = 226; - - /// Windows Structured Exception Handling's except statement. - static const int CXCursor_SEHExceptStmt = 227; - - /// Windows Structured Exception Handling's finally statement. - static const int CXCursor_SEHFinallyStmt = 228; - - /// A MS inline assembly statement extension. - static const int CXCursor_MSAsmStmt = 229; - - /// The null statement ";": C99 6.8.3p3. - /// - /// This cursor kind is used to describe the null statement. - static const int CXCursor_NullStmt = 230; - - /// Adaptor class for mixing declarations with statements and - /// expressions. - static const int CXCursor_DeclStmt = 231; - - /// OpenMP parallel directive. - static const int CXCursor_OMPParallelDirective = 232; - - /// OpenMP SIMD directive. - static const int CXCursor_OMPSimdDirective = 233; - - /// OpenMP for directive. - static const int CXCursor_OMPForDirective = 234; - - /// OpenMP sections directive. - static const int CXCursor_OMPSectionsDirective = 235; - - /// OpenMP section directive. - static const int CXCursor_OMPSectionDirective = 236; - - /// OpenMP single directive. - static const int CXCursor_OMPSingleDirective = 237; - - /// OpenMP parallel for directive. - static const int CXCursor_OMPParallelForDirective = 238; - - /// OpenMP parallel sections directive. - static const int CXCursor_OMPParallelSectionsDirective = 239; - - /// OpenMP task directive. - static const int CXCursor_OMPTaskDirective = 240; - - /// OpenMP master directive. - static const int CXCursor_OMPMasterDirective = 241; - - /// OpenMP critical directive. - static const int CXCursor_OMPCriticalDirective = 242; - - /// OpenMP taskyield directive. - static const int CXCursor_OMPTaskyieldDirective = 243; - - /// OpenMP barrier directive. - static const int CXCursor_OMPBarrierDirective = 244; - - /// OpenMP taskwait directive. - static const int CXCursor_OMPTaskwaitDirective = 245; - - /// OpenMP flush directive. - static const int CXCursor_OMPFlushDirective = 246; - - /// Windows Structured Exception Handling's leave statement. - static const int CXCursor_SEHLeaveStmt = 247; - - /// OpenMP ordered directive. - static const int CXCursor_OMPOrderedDirective = 248; - - /// OpenMP atomic directive. - static const int CXCursor_OMPAtomicDirective = 249; - - /// OpenMP for SIMD directive. - static const int CXCursor_OMPForSimdDirective = 250; - - /// OpenMP parallel for SIMD directive. - static const int CXCursor_OMPParallelForSimdDirective = 251; - - /// OpenMP target directive. - static const int CXCursor_OMPTargetDirective = 252; - - /// OpenMP teams directive. - static const int CXCursor_OMPTeamsDirective = 253; - - /// OpenMP taskgroup directive. - static const int CXCursor_OMPTaskgroupDirective = 254; - - /// OpenMP cancellation point directive. - static const int CXCursor_OMPCancellationPointDirective = 255; - - /// OpenMP cancel directive. - static const int CXCursor_OMPCancelDirective = 256; - - /// OpenMP target data directive. - static const int CXCursor_OMPTargetDataDirective = 257; - - /// OpenMP taskloop directive. - static const int CXCursor_OMPTaskLoopDirective = 258; - - /// OpenMP taskloop simd directive. - static const int CXCursor_OMPTaskLoopSimdDirective = 259; - - /// OpenMP distribute directive. - static const int CXCursor_OMPDistributeDirective = 260; - - /// OpenMP target enter data directive. - static const int CXCursor_OMPTargetEnterDataDirective = 261; - - /// OpenMP target exit data directive. - static const int CXCursor_OMPTargetExitDataDirective = 262; - - /// OpenMP target parallel directive. - static const int CXCursor_OMPTargetParallelDirective = 263; - - /// OpenMP target parallel for directive. - static const int CXCursor_OMPTargetParallelForDirective = 264; - - /// OpenMP target update directive. - static const int CXCursor_OMPTargetUpdateDirective = 265; - - /// OpenMP distribute parallel for directive. - static const int CXCursor_OMPDistributeParallelForDirective = 266; - - /// OpenMP distribute parallel for simd directive. - static const int CXCursor_OMPDistributeParallelForSimdDirective = 267; - - /// OpenMP distribute simd directive. - static const int CXCursor_OMPDistributeSimdDirective = 268; - - /// OpenMP target parallel for simd directive. - static const int CXCursor_OMPTargetParallelForSimdDirective = 269; - - /// OpenMP target simd directive. - static const int CXCursor_OMPTargetSimdDirective = 270; - - /// OpenMP teams distribute directive. - static const int CXCursor_OMPTeamsDistributeDirective = 271; - - /// OpenMP teams distribute simd directive. - static const int CXCursor_OMPTeamsDistributeSimdDirective = 272; - - /// OpenMP teams distribute parallel for simd directive. - static const int CXCursor_OMPTeamsDistributeParallelForSimdDirective = 273; - - /// OpenMP teams distribute parallel for directive. - static const int CXCursor_OMPTeamsDistributeParallelForDirective = 274; - - /// OpenMP target teams directive. - static const int CXCursor_OMPTargetTeamsDirective = 275; - - /// OpenMP target teams distribute directive. - static const int CXCursor_OMPTargetTeamsDistributeDirective = 276; - - /// OpenMP target teams distribute parallel for directive. - static const int CXCursor_OMPTargetTeamsDistributeParallelForDirective = 277; - - /// OpenMP target teams distribute parallel for simd directive. - static const int CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective = - 278; - - /// OpenMP target teams distribute simd directive. - static const int CXCursor_OMPTargetTeamsDistributeSimdDirective = 279; - - /// C++2a std::bit_cast expression. - static const int CXCursor_BuiltinBitCastExpr = 280; - - /// OpenMP master taskloop directive. - static const int CXCursor_OMPMasterTaskLoopDirective = 281; - - /// OpenMP parallel master taskloop directive. - static const int CXCursor_OMPParallelMasterTaskLoopDirective = 282; - - /// OpenMP master taskloop simd directive. - static const int CXCursor_OMPMasterTaskLoopSimdDirective = 283; - - /// OpenMP parallel master taskloop simd directive. - static const int CXCursor_OMPParallelMasterTaskLoopSimdDirective = 284; - - /// OpenMP parallel master directive. - static const int CXCursor_OMPParallelMasterDirective = 285; - static const int CXCursor_LastStmt = 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. - static const int CXCursor_TranslationUnit = 300; - static const int CXCursor_FirstAttr = 400; - - /// An attribute whose specific kind is not exposed via this - /// interface. - static const int CXCursor_UnexposedAttr = 400; - static const int CXCursor_IBActionAttr = 401; - static const int CXCursor_IBOutletAttr = 402; - static const int CXCursor_IBOutletCollectionAttr = 403; - static const int CXCursor_CXXFinalAttr = 404; - static const int CXCursor_CXXOverrideAttr = 405; - static const int CXCursor_AnnotateAttr = 406; - static const int CXCursor_AsmLabelAttr = 407; - static const int CXCursor_PackedAttr = 408; - static const int CXCursor_PureAttr = 409; - static const int CXCursor_ConstAttr = 410; - static const int CXCursor_NoDuplicateAttr = 411; - static const int CXCursor_CUDAConstantAttr = 412; - static const int CXCursor_CUDADeviceAttr = 413; - static const int CXCursor_CUDAGlobalAttr = 414; - static const int CXCursor_CUDAHostAttr = 415; - static const int CXCursor_CUDASharedAttr = 416; - static const int CXCursor_VisibilityAttr = 417; - static const int CXCursor_DLLExport = 418; - static const int CXCursor_DLLImport = 419; - static const int CXCursor_NSReturnsRetained = 420; - static const int CXCursor_NSReturnsNotRetained = 421; - static const int CXCursor_NSReturnsAutoreleased = 422; - static const int CXCursor_NSConsumesSelf = 423; - static const int CXCursor_NSConsumed = 424; - static const int CXCursor_ObjCException = 425; - static const int CXCursor_ObjCNSObject = 426; - static const int CXCursor_ObjCIndependentClass = 427; - static const int CXCursor_ObjCPreciseLifetime = 428; - static const int CXCursor_ObjCReturnsInnerPointer = 429; - static const int CXCursor_ObjCRequiresSuper = 430; - static const int CXCursor_ObjCRootClass = 431; - static const int CXCursor_ObjCSubclassingRestricted = 432; - static const int CXCursor_ObjCExplicitProtocolImpl = 433; - static const int CXCursor_ObjCDesignatedInitializer = 434; - static const int CXCursor_ObjCRuntimeVisible = 435; - static const int CXCursor_ObjCBoxable = 436; - static const int CXCursor_FlagEnum = 437; - static const int CXCursor_ConvergentAttr = 438; - static const int CXCursor_WarnUnusedAttr = 439; - static const int CXCursor_WarnUnusedResultAttr = 440; - static const int CXCursor_AlignedAttr = 441; - static const int CXCursor_LastAttr = 441; - static const int CXCursor_PreprocessingDirective = 500; - static const int CXCursor_MacroDefinition = 501; - static const int CXCursor_MacroExpansion = 502; - static const int CXCursor_MacroInstantiation = 502; - static const int CXCursor_InclusionDirective = 503; - static const int CXCursor_FirstPreprocessing = 500; - static const int CXCursor_LastPreprocessing = 503; - - /// A module import declaration. - static const int CXCursor_ModuleImportDecl = 600; - static const int CXCursor_TypeAliasTemplateDecl = 601; - - /// A static_assert or _Static_assert node - static const int CXCursor_StaticAssert = 602; - - /// a friend declaration. - static const int CXCursor_FriendDecl = 603; - static const int CXCursor_FirstExtraDecl = 600; - static const int CXCursor_LastExtraDecl = 603; - - /// A code completion overload candidate. - static const int CXCursor_OverloadCandidate = 700; -} - -/// 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. -class CXCursor extends ffi.Struct { - @ffi.Int32() - external int kind; - - @ffi.Int() - external int xdata; - - @ffi.Array.multi([3]) - external ffi.Array> data; -} - -/// Describes the kind of type -abstract class CXTypeKind { - /// Represents an invalid type (e.g., where no type is available). - static const int CXType_Invalid = 0; - - /// A type whose specific kind is not exposed via this - /// interface. - static const int CXType_Unexposed = 1; - static const int CXType_Void = 2; - static const int CXType_Bool = 3; - static const int CXType_Char_U = 4; - static const int CXType_UChar = 5; - static const int CXType_Char16 = 6; - static const int CXType_Char32 = 7; - static const int CXType_UShort = 8; - static const int CXType_UInt = 9; - static const int CXType_ULong = 10; - static const int CXType_ULongLong = 11; - static const int CXType_UInt128 = 12; - static const int CXType_Char_S = 13; - static const int CXType_SChar = 14; - static const int CXType_WChar = 15; - static const int CXType_Short = 16; - static const int CXType_Int = 17; - static const int CXType_Long = 18; - static const int CXType_LongLong = 19; - static const int CXType_Int128 = 20; - static const int CXType_Float = 21; - static const int CXType_Double = 22; - static const int CXType_LongDouble = 23; - static const int CXType_NullPtr = 24; - static const int CXType_Overload = 25; - static const int CXType_Dependent = 26; - static const int CXType_ObjCId = 27; - static const int CXType_ObjCClass = 28; - static const int CXType_ObjCSel = 29; - static const int CXType_Float128 = 30; - static const int CXType_Half = 31; - static const int CXType_Float16 = 32; - static const int CXType_ShortAccum = 33; - static const int CXType_Accum = 34; - static const int CXType_LongAccum = 35; - static const int CXType_UShortAccum = 36; - static const int CXType_UAccum = 37; - static const int CXType_ULongAccum = 38; - static const int CXType_FirstBuiltin = 2; - static const int CXType_LastBuiltin = 38; - static const int CXType_Complex = 100; - static const int CXType_Pointer = 101; - static const int CXType_BlockPointer = 102; - static const int CXType_LValueReference = 103; - static const int CXType_RValueReference = 104; - static const int CXType_Record = 105; - static const int CXType_Enum = 106; - static const int CXType_Typedef = 107; - static const int CXType_ObjCInterface = 108; - static const int CXType_ObjCObjectPointer = 109; - static const int CXType_FunctionNoProto = 110; - static const int CXType_FunctionProto = 111; - static const int CXType_ConstantArray = 112; - static const int CXType_Vector = 113; - static const int CXType_IncompleteArray = 114; - static const int CXType_VariableArray = 115; - static const int CXType_DependentSizedArray = 116; - static const int CXType_MemberPointer = 117; - static const int 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. - static const int CXType_Elaborated = 119; - static const int CXType_Pipe = 120; - static const int CXType_OCLImage1dRO = 121; - static const int CXType_OCLImage1dArrayRO = 122; - static const int CXType_OCLImage1dBufferRO = 123; - static const int CXType_OCLImage2dRO = 124; - static const int CXType_OCLImage2dArrayRO = 125; - static const int CXType_OCLImage2dDepthRO = 126; - static const int CXType_OCLImage2dArrayDepthRO = 127; - static const int CXType_OCLImage2dMSAARO = 128; - static const int CXType_OCLImage2dArrayMSAARO = 129; - static const int CXType_OCLImage2dMSAADepthRO = 130; - static const int CXType_OCLImage2dArrayMSAADepthRO = 131; - static const int CXType_OCLImage3dRO = 132; - static const int CXType_OCLImage1dWO = 133; - static const int CXType_OCLImage1dArrayWO = 134; - static const int CXType_OCLImage1dBufferWO = 135; - static const int CXType_OCLImage2dWO = 136; - static const int CXType_OCLImage2dArrayWO = 137; - static const int CXType_OCLImage2dDepthWO = 138; - static const int CXType_OCLImage2dArrayDepthWO = 139; - static const int CXType_OCLImage2dMSAAWO = 140; - static const int CXType_OCLImage2dArrayMSAAWO = 141; - static const int CXType_OCLImage2dMSAADepthWO = 142; - static const int CXType_OCLImage2dArrayMSAADepthWO = 143; - static const int CXType_OCLImage3dWO = 144; - static const int CXType_OCLImage1dRW = 145; - static const int CXType_OCLImage1dArrayRW = 146; - static const int CXType_OCLImage1dBufferRW = 147; - static const int CXType_OCLImage2dRW = 148; - static const int CXType_OCLImage2dArrayRW = 149; - static const int CXType_OCLImage2dDepthRW = 150; - static const int CXType_OCLImage2dArrayDepthRW = 151; - static const int CXType_OCLImage2dMSAARW = 152; - static const int CXType_OCLImage2dArrayMSAARW = 153; - static const int CXType_OCLImage2dMSAADepthRW = 154; - static const int CXType_OCLImage2dArrayMSAADepthRW = 155; - static const int CXType_OCLImage3dRW = 156; - static const int CXType_OCLSampler = 157; - static const int CXType_OCLEvent = 158; - static const int CXType_OCLQueue = 159; - static const int CXType_OCLReserveID = 160; - static const int CXType_ObjCObject = 161; - static const int CXType_ObjCTypeParam = 162; - static const int CXType_Attributed = 163; - static const int CXType_OCLIntelSubgroupAVCMcePayload = 164; - static const int CXType_OCLIntelSubgroupAVCImePayload = 165; - static const int CXType_OCLIntelSubgroupAVCRefPayload = 166; - static const int CXType_OCLIntelSubgroupAVCSicPayload = 167; - static const int CXType_OCLIntelSubgroupAVCMceResult = 168; - static const int CXType_OCLIntelSubgroupAVCImeResult = 169; - static const int CXType_OCLIntelSubgroupAVCRefResult = 170; - static const int CXType_OCLIntelSubgroupAVCSicResult = 171; - static const int CXType_OCLIntelSubgroupAVCImeResultSingleRefStreamout = 172; - static const int CXType_OCLIntelSubgroupAVCImeResultDualRefStreamout = 173; - static const int CXType_OCLIntelSubgroupAVCImeSingleRefStreamin = 174; - static const int CXType_OCLIntelSubgroupAVCImeDualRefStreamin = 175; - static const int CXType_ExtVector = 176; -} - -/// The type of an element in the abstract syntax tree. -class CXType extends ffi.Struct { - @ffi.Int32() - external int kind; - - @ffi.Array.multi([2]) - external ffi.Array> data; -} - -abstract class CXTypeNullabilityKind { - /// Values of this type can never be null. - static const int CXTypeNullability_NonNull = 0; - - /// Values of this type can be null. - static const int CXTypeNullability_Nullable = 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. - static const int CXTypeNullability_Unspecified = 2; - - /// Nullability is not applicable to this type. - static const int CXTypeNullability_Invalid = 3; -} - -/// 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. -abstract class CXChildVisitResult { - /// Terminates the cursor traversal. - static const int CXChildVisit_Break = 0; - - /// Continues the cursor traversal with the next sibling of - /// the cursor just visited, without visiting its children. - static const int CXChildVisit_Continue = 1; - - /// Recursively traverse the children of this cursor, using - /// the same visitor and client data. - static const int CXChildVisit_Recurse = 2; -} - -/// 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< - ffi.NativeFunction>; - -/// Opaque pointer representing client data that will be passed through -/// to various callbacks and visitors. -typedef CXClientData = ffi.Pointer; - -/// Property attributes for a \c CXCursor_ObjCPropertyDecl. -abstract class CXObjCPropertyAttrKind { - static const int CXObjCPropertyAttr_noattr = 0; - static const int CXObjCPropertyAttr_readonly = 1; - static const int CXObjCPropertyAttr_getter = 2; - static const int CXObjCPropertyAttr_assign = 4; - static const int CXObjCPropertyAttr_readwrite = 8; - static const int CXObjCPropertyAttr_retain = 16; - static const int CXObjCPropertyAttr_copy = 32; - static const int CXObjCPropertyAttr_nonatomic = 64; - static const int CXObjCPropertyAttr_setter = 128; - static const int CXObjCPropertyAttr_atomic = 256; - static const int CXObjCPropertyAttr_weak = 512; - static const int CXObjCPropertyAttr_strong = 1024; - static const int CXObjCPropertyAttr_unsafe_unretained = 2048; - static const int CXObjCPropertyAttr_class = 4096; -} - -abstract class CXEvalResultKind { - static const int CXEval_Int = 1; - static const int CXEval_Float = 2; - static const int CXEval_ObjCStrLiteral = 3; - static const int CXEval_StrLiteral = 4; - static const int CXEval_CFStr = 5; - static const int CXEval_Other = 6; - static const int CXEval_UnExposed = 0; -} - -/// Evaluation result of a cursor -typedef CXEvalResult = 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/jni/third_party/ffigen_patch_jni/lib/src/header_parser/data.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/data.dart deleted file mode 100644 index 1381fd3c3..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/data.dart +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2020, 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:ffi'; - -import 'package:ffigen/src/code_generator.dart' - show Constant, ObjCBuiltInFunctions; -import 'package:ffigen/src/config_provider.dart' show Config; -import 'clang_bindings/clang_bindings.dart' show Clang; - -import 'utils.dart'; - -/// Holds all Global shared variables. - -/// Holds configurations. -Config get config => _config; -late Config _config; - -/// Holds clang functions. -Clang get clang => _clang; -late Clang _clang; - -// Tracks seen status for bindings -BindingsIndex get bindingsIndex => _bindingsIndex; -BindingsIndex _bindingsIndex = BindingsIndex(); - -/// Used for naming typedefs. -IncrementalNamer get incrementalNamer => _incrementalNamer; -IncrementalNamer _incrementalNamer = IncrementalNamer(); - -/// Saved macros, Key: prefixedName, Value originalName. -Map get savedMacros => _savedMacros; -Map _savedMacros = {}; - -/// Saved unnamed EnumConstants. -List get unnamedEnumConstants => _unnamedEnumConstants; -List _unnamedEnumConstants = []; - -/// Built in functions used by the Objective C bindings. -ObjCBuiltInFunctions get objCBuiltInFunctions => _objCBuiltInFunctions; -late ObjCBuiltInFunctions _objCBuiltInFunctions; - -void initializeGlobals({required Config config}) { - _config = config; - _clang = Clang(DynamicLibrary.open(config.libclangDylib)); - _incrementalNamer = IncrementalNamer(); - _savedMacros = {}; - _unnamedEnumConstants = []; - _bindingsIndex = BindingsIndex(); - _objCBuiltInFunctions = ObjCBuiltInFunctions(); -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/includer.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/includer.dart deleted file mode 100644 index a9041a612..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/includer.dart +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (c) 2020, 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. - -/// Utility functions to check whether a binding should be parsed or not -/// based on filters. - -import '../config_provider/config_types.dart'; -import '../strings.dart' as strings; -import 'data.dart'; - -bool _shouldIncludeDecl(String usr, String name, - bool Function(String) isSeenDecl, bool Function(String) configIncludes) { - if (isSeenDecl(usr) || name == '') { - return false; - } else if (configIncludes(name)) { - return true; - } else { - return false; - } -} - -bool shouldIncludeStruct(String usr, String name) { - return _shouldIncludeDecl( - usr, name, bindingsIndex.isSeenType, config.structDecl.shouldInclude); -} - -bool shouldIncludeUnion(String usr, String name) { - return _shouldIncludeDecl( - usr, name, bindingsIndex.isSeenType, config.unionDecl.shouldInclude); -} - -bool shouldIncludeFunc(String usr, String name) { - return _shouldIncludeDecl( - usr, name, bindingsIndex.isSeenType, config.functionDecl.shouldInclude); -} - -bool shouldIncludeEnumClass(String usr, String name) { - return _shouldIncludeDecl( - usr, name, bindingsIndex.isSeenType, config.enumClassDecl.shouldInclude); -} - -bool shouldIncludeUnnamedEnumConstant(String usr, String name) { - return _shouldIncludeDecl(usr, name, bindingsIndex.isSeenUnnamedEnumConstant, - config.unnamedEnumConstants.shouldInclude); -} - -bool shouldIncludeGlobalVar(String usr, String name) { - return _shouldIncludeDecl( - usr, name, bindingsIndex.isSeenGlobalVar, config.globals.shouldInclude); -} - -bool shouldIncludeMacro(String usr, String name) { - return _shouldIncludeDecl( - usr, name, bindingsIndex.isSeenMacro, config.macroDecl.shouldInclude); -} - -bool shouldIncludeTypealias(String usr, String name) { - return _shouldIncludeDecl( - usr, name, bindingsIndex.isSeenType, config.typedefs.shouldInclude); -} - -bool shouldIncludeObjCInterface(String usr, String name) { - return _shouldIncludeDecl( - usr, name, bindingsIndex.isSeenType, config.objcInterfaces.shouldInclude); -} - -/// True if a cursor should be included based on headers config, used on root -/// declarations. -bool shouldIncludeRootCursor(String sourceFile) { - // Handle empty string in case of system headers or macros. - if (sourceFile.isEmpty) { - return false; - } - - // Objective C has some extra system headers that have a non-empty sourceFile. - if (config.language == Language.objc && - strings.objCInternalDirectories - .any((path) => sourceFile.startsWith(path))) { - return false; - } - - // Add header to seen if it's not. - if (!bindingsIndex.isSeenHeader(sourceFile)) { - bindingsIndex.addHeaderToSeen( - sourceFile, config.headers.includeFilter.shouldInclude(sourceFile)); - } - - return bindingsIndex.getSeenHeaderStatus(sourceFile)!; -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/parser.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/parser.dart deleted file mode 100644 index 2adbb0bfb..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/parser.dart +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright (c) 2020, 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:ffi'; - -import 'package:ffi/ffi.dart'; -import 'package:ffigen/src/code_generator.dart'; -import 'package:ffigen/src/config_provider.dart'; -import 'package:ffigen/src/config_provider/config_types.dart'; -import 'package:ffigen/src/header_parser/sub_parsers/macro_parser.dart'; -import 'package:ffigen/src/header_parser/translation_unit_parser.dart'; -import 'package:ffigen/src/strings.dart' as strings; -import 'package:logging/logging.dart'; - -import 'clang_bindings/clang_bindings.dart' as clang_types; -import 'data.dart'; -import 'utils.dart'; - -/// Main entrypoint for header_parser. -Library parse(Config c) { - initParser(c); - - final bindings = parseToBindings(); - - final library = Library( - bindings: bindings, - name: config.wrapperName, - description: config.wrapperDocComment, - header: config.preamble, - sort: config.sort, - packingOverride: config.structPackingOverride, - libraryImports: c.libraryImports.values.toSet(), - ); - - return library; -} - -// =================================================================================== -// BELOW FUNCTIONS ARE MEANT FOR INTERNAL USE AND TESTING -// =================================================================================== - -final _logger = Logger('ffigen.header_parser.parser'); - -/// Initializes parser, clears any previous values. -void initParser(Config c) { - // Initialize global variables. - initializeGlobals( - config: c, - ); -} - -/// Parses source files and adds generated bindings to [bindings]. -List parseToBindings() { - final index = clang.clang_createIndex(0, 0); - - Pointer> clangCmdArgs = nullptr; - final compilerOpts = List.from(config.compilerOpts); - - /// Add compiler opt for comment parsing for clang based on config. - if (config.commentType.length != CommentLength.none && - config.commentType.style == CommentStyle.any) { - compilerOpts.add(strings.fparseAllComments); - } - - /// If the config targets Objective C, add a compiler opt for it. - if (config.language == Language.objc) { - compilerOpts.addAll(strings.clangLangObjC); - } - - _logger.fine('CompilerOpts used: $compilerOpts'); - clangCmdArgs = createDynamicStringArray(compilerOpts); - final cmdLen = compilerOpts.length; - - // Contains all bindings. A set ensures we never have duplicates. - final bindings = {}; - - // Log all headers for user. - _logger.info('Input Headers: ${config.headers.entryPoints}'); - - for (final headerLocation in config.headers.entryPoints) { - _logger.fine('Creating TranslationUnit for header: $headerLocation'); - - final tu = clang.clang_parseTranslationUnit( - index, - headerLocation.toNativeUtf8().cast(), - clangCmdArgs.cast(), - cmdLen, - nullptr, - 0, - clang_types.CXTranslationUnit_Flags.CXTranslationUnit_SkipFunctionBodies | - clang_types.CXTranslationUnit_Flags - .CXTranslationUnit_DetailedPreprocessingRecord, - ); - - if (tu == nullptr) { - _logger.severe( - "Skipped header/file: $headerLocation, couldn't parse source."); - // Skip parsing this header. - continue; - } - - logTuDiagnostics(tu, _logger, headerLocation); - final rootCursor = clang.clang_getTranslationUnitCursor(tu); - - bindings.addAll(parseTranslationUnit(rootCursor)); - - // Cleanup. - clang.clang_disposeTranslationUnit(tu); - } - - // Add all saved unnamed enums. - bindings.addAll(unnamedEnumConstants); - - // Parse all saved macros. - bindings.addAll(parseSavedMacros()!); - - clangCmdArgs.dispose(cmdLen); - clang.clang_disposeIndex(index); - return bindings.toList(); -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/compounddecl_parser.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/compounddecl_parser.dart deleted file mode 100644 index a21d6e2a4..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/compounddecl_parser.dart +++ /dev/null @@ -1,318 +0,0 @@ -// Copyright (c) 2021, 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:ffi'; - -import 'package:ffigen/src/code_generator.dart'; -import 'package:ffigen/src/config_provider/config_types.dart'; -import 'package:logging/logging.dart'; - -import '../../strings.dart' as strings; -import '../clang_bindings/clang_bindings.dart' as clang_types; -import '../data.dart'; -import '../includer.dart'; -import '../utils.dart'; - -final _logger = Logger('ffigen.header_parser.compounddecl_parser'); - -/// Holds temporary information regarding [compound] while parsing. -class _ParsedCompound { - Compound compound; - bool unimplementedMemberType = false; - bool flexibleArrayMember = false; - bool bitFieldMember = false; - bool dartHandleMember = false; - bool incompleteCompoundMember = false; - - _ParsedCompound(this.compound); - - bool get isIncomplete => - unimplementedMemberType || - flexibleArrayMember || - bitFieldMember || - (dartHandleMember && config.useDartHandle) || - incompleteCompoundMember; - - // A struct without any attribute is definitely not packed. #pragma pack(...) - // also adds an attribute, but it's unexposed and cannot be travesed. - bool hasAttr = false; - // A struct which as a __packed__ attribute is definitely packed. - bool hasPackedAttr = false; - // Stores the maximum alignment from all the children. - int maxChildAlignment = 0; - // Alignment of this struct. - int alignment = 0; - - bool get _isPacked { - if (!hasAttr || isIncomplete) return false; - if (hasPackedAttr) return true; - - return maxChildAlignment > alignment; - } - - /// Returns pack value of a struct depending on config, returns null for no - /// packing. - int? get packValue { - if (compound.isStruct && _isPacked) { - if (strings.packingValuesMap.containsKey(alignment)) { - return alignment; - } else { - _logger.warning( - 'Unsupported pack value "$alignment" for Struct "${compound.name}".'); - return null; - } - } else { - return null; - } - } -} - -final _stack = Stack<_ParsedCompound>(); - -/// Parses a compound declaration. -Compound? parseCompoundDeclaration( - clang_types.CXCursor cursor, - CompoundType compoundType, { - /// Option to ignore declaration filter (Useful in case of extracting - /// declarations when they are passed/returned by an included function.) - bool ignoreFilter = false, - - /// To track if the declaration was used by reference(i.e T*). (Used to only - /// generate these as opaque if `dependency-only` was set to opaque). - bool pointerReference = false, -}) { - // Set includer functions according to compoundType. - final bool Function(String, String) shouldIncludeDecl; - final Declaration configDecl; - final String className = _compoundTypeDebugName(compoundType); - switch (compoundType) { - case CompoundType.struct: - shouldIncludeDecl = shouldIncludeStruct; - configDecl = config.structDecl; - break; - case CompoundType.union: - shouldIncludeDecl = shouldIncludeUnion; - configDecl = config.unionDecl; - break; - } - - // Parse the cursor definition instead, if this is a forward declaration. - if (isForwardDeclaration(cursor)) { - cursor = clang.clang_getCursorDefinition(cursor); - } - final declUsr = cursor.usr(); - final String declName; - - // Only set name using USR if the type is not Anonymous (A struct is anonymous - // if it has no name, is not inside any typedef and declared inline inside - // another declaration). - if (clang.clang_Cursor_isAnonymous(cursor) == 0) { - // This gives the significant name, i.e name of the struct if defined or - // name of the first typedef declaration that refers to it. - declName = declUsr.split('@').last; - } else { - // Empty names are treated as inline declarations. - declName = ''; - } - - if (declName.isEmpty) { - if (ignoreFilter) { - // This declaration is defined inside some other declaration and hence - // must be generated. - return Compound.fromType( - type: compoundType, - name: incrementalNamer.name('Unnamed$className'), - usr: declUsr, - dartDoc: getCursorDocComment(cursor), - ); - } else { - _logger.finest('unnamed $className declaration'); - } - } else if (ignoreFilter || shouldIncludeDecl(declUsr, declName)) { - _logger.fine( - '++++ Adding $className: Name: $declName, ${cursor.completeStringRepr()}'); - return Compound.fromType( - type: compoundType, - usr: declUsr, - originalName: declName, - name: configDecl.renameUsingConfig(declName), - dartDoc: getCursorDocComment(cursor), - ); - } - return null; -} - -void fillCompoundMembersIfNeeded( - Compound compound, - clang_types.CXCursor cursor, { - /// Option to ignore declaration filter (Useful in case of extracting - /// declarations when they are passed/returned by an included function.) - bool ignoreFilter = false, - - /// To track if the declaration was used by reference(i.e T*). (Used to only - /// generate these as opaque if `dependency-only` was set to opaque). - bool pointerReference = false, -}) { - final compoundType = compound.compoundType; - - // Skip dependencies if already seen OR user has specified `dependency-only` - // as opaque AND this is a pointer reference AND the declaration was not - // included according to config (ignoreFilter). - final skipDependencies = compound.parsedDependencies || - (pointerReference && - ignoreFilter && - ((compoundType == CompoundType.struct && - config.structDependencies == CompoundDependencies.opaque) || - (compoundType == CompoundType.union && - config.unionDependencies == CompoundDependencies.opaque))); - if (skipDependencies) return; - - final parsed = _ParsedCompound(compound); - final String className = _compoundTypeDebugName(compoundType); - parsed.hasAttr = clang.clang_Cursor_hasAttrs(cursor) != 0; - parsed.alignment = cursor.type().alignment(); - compound.parsedDependencies = true; // Break cycles. - - _stack.push(parsed); - final resultCode = clang.clang_visitChildren( - cursor, - Pointer.fromFunction(_compoundMembersVisitor, exceptional_visitor_return), - nullptr, - ); - _stack.pop(); - - _logger.finest( - 'Opaque: ${parsed.isIncomplete}, HasAttr: ${parsed.hasAttr}, AlignValue: ${parsed.alignment}, MaxChildAlignValue: ${parsed.maxChildAlignment}, PackValue: ${parsed.packValue}.'); - compound.pack = parsed.packValue; - - visitChildrenResultChecker(resultCode); - - if (parsed.unimplementedMemberType) { - _logger.fine( - '---- Removed $className members, reason: member with unimplementedtype ${cursor.completeStringRepr()}'); - _logger.warning( - 'Removed All $className Members from ${compound.name}(${compound.originalName}), struct member has an unsupported type.'); - } else if (parsed.flexibleArrayMember) { - _logger.fine( - '---- Removed $className members, reason: incomplete array member ${cursor.completeStringRepr()}'); - _logger.warning( - 'Removed All $className Members from ${compound.name}(${compound.originalName}), Flexible array members not supported.'); - } else if (parsed.bitFieldMember) { - _logger.fine( - '---- Removed $className members, reason: bitfield members ${cursor.completeStringRepr()}'); - _logger.warning( - 'Removed All $className Members from ${compound.name}(${compound.originalName}), Bit Field members not supported.'); - } else if (parsed.dartHandleMember && config.useDartHandle) { - _logger.fine( - '---- Removed $className members, reason: Dart_Handle member. ${cursor.completeStringRepr()}'); - _logger.warning( - 'Removed All $className Members from ${compound.name}(${compound.originalName}), Dart_Handle member not supported.'); - } else if (parsed.incompleteCompoundMember) { - _logger.fine( - '---- Removed $className members, reason: Incomplete Nested Struct member. ${cursor.completeStringRepr()}'); - _logger.warning( - 'Removed All $className Members from ${compound.name}(${compound.originalName}), Incomplete Nested Struct member not supported.'); - } - - // Clear all members if declaration is incomplete. - if (parsed.isIncomplete) { - compound.members.clear(); - } - - // C allows empty structs/union, but it's undefined behaviour at runtine. - // So we need to mark a declaration incomplete if it has no members. - compound.isIncomplete = parsed.isIncomplete || compound.members.isEmpty; -} - -// I've written worse hacks than this -final List _paramNames = []; - -int _fnPtrFieldVisitor(clang_types.CXCursor cursor, clang_types.CXCursor parent, - Pointer clientData) { - if (cursor.kind == clang_types.CXCursorKind.CXCursor_ParmDecl) { - final spelling = cursor.spelling(); - if (spelling.isNotEmpty) { - _paramNames.add(spelling); - } - } - return clang_types.CXChildVisitResult.CXChildVisit_Continue; -} - -/// Visitor for the struct/union cursor [CXCursorKind.CXCursor_StructDecl]/ -/// [CXCursorKind.CXCursor_UnionDecl]. -/// -/// Child visitor invoked on struct/union cursor. -int _compoundMembersVisitor(clang_types.CXCursor cursor, - clang_types.CXCursor parent, Pointer clientData) { - final parsed = _stack.top; - try { - if (cursor.kind == clang_types.CXCursorKind.CXCursor_FieldDecl) { - _logger.finer('===== member: ${cursor.completeStringRepr()}'); - // Set maxChildAlignValue. - final align = cursor.type().alignment(); - if (align > parsed.maxChildAlignment) { - parsed.maxChildAlignment = align; - } - final mt = cursor.type().toCodeGenType(); - List? params; - if (mt is PointerType && mt.child is NativeFunc) { - clang.clang_visitChildren( - cursor, - Pointer.fromFunction( - _fnPtrFieldVisitor, exceptional_visitor_return), - nullptr); - final natFn = mt.child as NativeFunc; - final fnType = natFn.type as FunctionType; - if (_paramNames.length == fnType.parameters.length) { - params = _paramNames.toList(); - } - _paramNames.clear(); - } - if (mt is IncompleteArray) { - // TODO(68): Structs with flexible Array Members are not supported. - parsed.flexibleArrayMember = true; - } - if (clang.clang_getFieldDeclBitWidth(cursor) != -1) { - // TODO(84): Struct with bitfields are not suppoorted. - parsed.bitFieldMember = true; - } - if (mt is HandleType) { - parsed.dartHandleMember = true; - } - if (mt.isIncompleteCompound) { - parsed.incompleteCompoundMember = true; - } - if (mt.baseType is UnimplementedType) { - parsed.unimplementedMemberType = true; - } - - parsed.compound.members.add( - Member( - dartDoc: getCursorDocComment( - cursor, - nesting.length + commentPrefix.length, - ), - originalName: cursor.spelling(), - name: config.structDecl.renameMemberUsingConfig( - parsed.compound.originalName, - cursor.spelling(), - ), - type: mt, - params: params, - ), - ); - } else if (cursor.kind == clang_types.CXCursorKind.CXCursor_PackedAttr) { - parsed.hasPackedAttr = true; - } - } catch (e, s) { - _logger.severe(e); - _logger.severe(s); - rethrow; - } - return clang_types.CXChildVisitResult.CXChildVisit_Continue; -} - -String _compoundTypeDebugName(CompoundType compoundType) { - return compoundType == CompoundType.struct ? "Struct" : "Union"; -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/enumdecl_parser.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/enumdecl_parser.dart deleted file mode 100644 index 68012ed29..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/enumdecl_parser.dart +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright (c) 2020, 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:ffi'; - -import 'package:ffigen/src/code_generator.dart'; -import 'package:ffigen/src/header_parser/data.dart'; -import 'package:ffigen/src/header_parser/sub_parsers/unnamed_enumdecl_parser.dart'; -import 'package:logging/logging.dart'; - -import '../clang_bindings/clang_bindings.dart' as clang_types; -import '../data.dart'; -import '../includer.dart'; -import '../utils.dart'; - -final _logger = Logger('ffigen.header_parser.enumdecl_parser'); - -/// Holds temporary information regarding [EnumClass] while parsing. -class _ParsedEnum { - EnumClass? enumClass; - _ParsedEnum(); -} - -final _stack = Stack<_ParsedEnum>(); - -/// Parses an enum declaration. -EnumClass? parseEnumDeclaration( - clang_types.CXCursor cursor, { - /// Option to ignore declaration filter (Useful in case of extracting - /// declarations when they are passed/returned by an included function.) - bool ignoreFilter = false, -}) { - _stack.push(_ParsedEnum()); - - // Parse the cursor definition instead, if this is a forward declaration. - if (isForwardDeclaration(cursor)) { - cursor = clang.clang_getCursorDefinition(cursor); - } - - final enumUsr = cursor.usr(); - final String enumName; - // Only set name using USR if the type is not Anonymous (i.e not inside - // any typedef and declared inplace inside another type). - if (clang.clang_Cursor_isAnonymous(cursor) == 0) { - // This gives the significant name, i.e name of the enum if defined or - // name of the first typedef declaration that refers to it. - enumName = enumUsr.split('@').last; - } else { - enumName = ''; - } - - if (enumName.isEmpty) { - _logger.fine('Saving anonymous enum.'); - saveUnNamedEnum(cursor); - } else if (ignoreFilter || shouldIncludeEnumClass(enumUsr, enumName)) { - _logger.fine('++++ Adding Enum: ${cursor.completeStringRepr()}'); - _stack.top.enumClass = EnumClass( - usr: enumUsr, - dartDoc: getCursorDocComment(cursor), - originalName: enumName, - name: config.enumClassDecl.renameUsingConfig(enumName), - ); - _addEnumConstant(cursor); - } - - return _stack.pop().enumClass; -} - -void _addEnumConstant(clang_types.CXCursor cursor) { - final resultCode = clang.clang_visitChildren( - cursor, - Pointer.fromFunction(_enumCursorVisitor, exceptional_visitor_return), - nullptr, - ); - - visitChildrenResultChecker(resultCode); -} - -/// Visitor for a enum cursor [clang.CXCursorKind.CXCursor_EnumDecl]. -/// -/// Invoked on every enum directly under rootCursor. -/// Used for for extracting enum values. -int _enumCursorVisitor(clang_types.CXCursor cursor, clang_types.CXCursor parent, - Pointer clientData) { - try { - _logger.finest(' enumCursorVisitor: ${cursor.completeStringRepr()}'); - switch (clang.clang_getCursorKind(cursor)) { - case clang_types.CXCursorKind.CXCursor_EnumConstantDecl: - _addEnumConstantToEnumClass(cursor); - break; - default: - _logger.fine('invalid enum constant'); - } - } catch (e, s) { - _logger.severe(e); - _logger.severe(s); - rethrow; - } - return clang_types.CXChildVisitResult.CXChildVisit_Continue; -} - -/// Adds the parameter to func in [functiondecl_parser.dart]. -void _addEnumConstantToEnumClass(clang_types.CXCursor cursor) { - _stack.top.enumClass!.enumConstants.add( - EnumConstant( - dartDoc: getCursorDocComment( - cursor, - nesting.length + commentPrefix.length, - ), - originalName: cursor.spelling(), - name: config.enumClassDecl.renameMemberUsingConfig( - _stack.top.enumClass!.originalName, - cursor.spelling(), - ), - value: clang.clang_getEnumConstantDeclValue(cursor)), - ); -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/functiondecl_parser.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/functiondecl_parser.dart deleted file mode 100644 index b4c40fc22..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/functiondecl_parser.dart +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright (c) 2020, 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:ffigen/src/code_generator.dart'; -import 'package:ffigen/src/header_parser/data.dart'; -import 'package:logging/logging.dart'; - -import '../clang_bindings/clang_bindings.dart' as clang_types; -import '../includer.dart'; -import '../utils.dart'; - -final _logger = Logger('ffigen.header_parser.functiondecl_parser'); - -/// Holds temporary information regarding [Func] while parsing. -class _ParserFunc { - Func? func; - bool incompleteStructParameter = false; - bool unimplementedParameterType = false; - _ParserFunc(); -} - -final _stack = Stack<_ParserFunc>(); - -/// Parses a function declaration. -Func? parseFunctionDeclaration(clang_types.CXCursor cursor) { - _stack.push(_ParserFunc()); - - final funcUsr = cursor.usr(); - final funcName = cursor.spelling(); - if (shouldIncludeFunc(funcUsr, funcName)) { - _logger.fine('++++ Adding Function: ${cursor.completeStringRepr()}'); - - final rt = _getFunctionReturnType(cursor); - final parameters = _getParameters(cursor, funcName); - - if (clang.clang_Cursor_isFunctionInlined(cursor) != 0) { - _logger.fine('---- Removed Function, reason: inline function: ' - '${cursor.completeStringRepr()}'); - _logger.warning( - "Skipped Function '$funcName', inline functions are not supported."); - // Returning null so that [addToBindings] function excludes this. - return _stack.pop().func; - } - - if (rt.isIncompleteCompound || _stack.top.incompleteStructParameter) { - _logger.fine( - '---- Removed Function, reason: Incomplete struct pass/return by ' - 'value: ${cursor.completeStringRepr()}'); - _logger.warning( - "Skipped Function '$funcName', Incomplete struct pass/return by " - 'value not supported.'); - // Returning null so that [addToBindings] function excludes this. - return _stack.pop().func; - } - - if (rt.baseType is UnimplementedType || - _stack.top.unimplementedParameterType) { - _logger.fine('---- Removed Function, reason: unsupported return type or ' - 'parameter type: ${cursor.completeStringRepr()}'); - _logger.warning( - "Skipped Function '$funcName', function has unsupported return type " - 'or parameter type.'); - // Returning null so that [addToBindings] function excludes this. - return _stack.pop().func; - } - - _stack.top.func = Func( - dartDoc: getCursorDocComment( - cursor, - nesting.length + commentPrefix.length, - ), - usr: funcUsr, - name: config.functionDecl.renameUsingConfig(funcName), - originalName: funcName, - returnType: rt, - parameters: parameters, - exposeSymbolAddress: - config.functionDecl.shouldIncludeSymbolAddress(funcName), - exposeFunctionTypedefs: - config.exposeFunctionTypedefs.shouldInclude(funcName), - isLeaf: config.leafFunctions.shouldInclude(funcName), - ); - bindingsIndex.addFuncToSeen(funcUsr, _stack.top.func!); - } else if (bindingsIndex.isSeenFunc(funcUsr)) { - _stack.top.func = bindingsIndex.getSeenFunc(funcUsr); - } - - return _stack.pop().func; -} - -Type _getFunctionReturnType(clang_types.CXCursor cursor) { - return cursor.returnType().toCodeGenType(); -} - -List _getParameters(clang_types.CXCursor cursor, String funcName) { - final parameters = []; - - final totalArgs = clang.clang_Cursor_getNumArguments(cursor); - for (var i = 0; i < totalArgs; i++) { - final paramCursor = clang.clang_Cursor_getArgument(cursor, i); - - _logger.finer('===== parameter: ${paramCursor.completeStringRepr()}'); - - final pt = _getParameterType(paramCursor); - if (pt.isIncompleteCompound) { - _stack.top.incompleteStructParameter = true; - } else if (pt.baseType is UnimplementedType) { - _logger.finer('Unimplemented type: ${pt.baseType}'); - _stack.top.unimplementedParameterType = true; - } - - final pn = paramCursor.spelling(); - - /// If [pn] is null or empty, its set to `arg$i` by code_generator. - parameters.add( - Parameter( - originalName: pn, - name: config.functionDecl.renameMemberUsingConfig(funcName, pn), - type: pt, - ), - ); - } - - return parameters; -} - -Type _getParameterType(clang_types.CXCursor cursor) { - return cursor.type().toCodeGenType(); -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/macro_parser.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/macro_parser.dart deleted file mode 100644 index cdfe078d1..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/macro_parser.dart +++ /dev/null @@ -1,331 +0,0 @@ -// Copyright (c) 2020, 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:ffi'; -import 'dart:io'; -import 'dart:typed_data'; - -import 'package:ffi/ffi.dart'; -import 'package:ffigen/src/code_generator.dart'; -import 'package:ffigen/src/header_parser/data.dart'; -import 'package:ffigen/src/header_parser/includer.dart'; -import 'package:ffigen/src/strings.dart' as strings; -import 'package:logging/logging.dart'; -import 'package:path/path.dart' as p; - -import '../clang_bindings/clang_bindings.dart' as clang_types; -import '../data.dart'; -import '../utils.dart'; - -final _logger = Logger('ffigen.header_parser.macro_parser'); - -/// Adds a macro definition to be parsed later. -void saveMacroDefinition(clang_types.CXCursor cursor) { - final macroUsr = cursor.usr(); - final originalMacroName = cursor.spelling(); - if (clang.clang_Cursor_isMacroBuiltin(cursor) == 0 && - clang.clang_Cursor_isMacroFunctionLike(cursor) == 0 && - shouldIncludeMacro(macroUsr, originalMacroName)) { - // Parse macro only if it's not builtin or function-like. - _logger.fine( - "++++ Saved Macro '$originalMacroName' for later : ${cursor.completeStringRepr()}"); - final prefixedName = config.macroDecl.renameUsingConfig(originalMacroName); - bindingsIndex.addMacroToSeen(macroUsr, prefixedName); - _saveMacro(prefixedName, macroUsr, originalMacroName); - } -} - -/// Saves a macro to be parsed later. -/// -/// Macros are parsed later in [parseSavedMacros()]. -void _saveMacro(String name, String usr, String originalName) { - savedMacros[name] = Macro(usr, originalName); -} - -List? _bindings; - -/// Macros cannot be parsed directly, so we create a new `.hpp` file in which -/// they are assigned to a variable after which their value can be determined -/// by evaluating the value of the variable. -List? parseSavedMacros() { - _bindings = []; - - if (savedMacros.keys.isEmpty) { - return _bindings; - } - - // Create a file for parsing macros; - final file = createFileForMacros(); - - final index = clang.clang_createIndex(0, 0); - Pointer> clangCmdArgs = nullptr; - var cmdLen = 0; - clangCmdArgs = createDynamicStringArray(config.compilerOpts); - cmdLen = config.compilerOpts.length; - final tu = clang.clang_parseTranslationUnit( - index, - file.path.toNativeUtf8().cast(), - clangCmdArgs.cast(), - cmdLen, - nullptr, - 0, - clang_types.CXTranslationUnit_Flags.CXTranslationUnit_KeepGoing, - ); - - if (tu == nullptr) { - _logger.severe('Unable to parse Macros.'); - } else { - final rootCursor = clang.clang_getTranslationUnitCursor(tu); - - final resultCode = clang.clang_visitChildren( - rootCursor, - Pointer.fromFunction(_macroVariablevisitor, exceptional_visitor_return), - nullptr, - ); - - visitChildrenResultChecker(resultCode); - } - - clang.clang_disposeTranslationUnit(tu); - clang.clang_disposeIndex(index); - // Delete the temp file created for macros. - file.deleteSync(); - - return _bindings; -} - -/// Child visitor invoked on translationUnitCursor for parsing macroVariables. -int _macroVariablevisitor(clang_types.CXCursor cursor, - clang_types.CXCursor parent, Pointer clientData) { - Constant? constant; - try { - if (isFromGeneratedFile(cursor) && - _macroVarNames.contains(cursor.spelling()) && - cursor.kind == clang_types.CXCursorKind.CXCursor_VarDecl) { - final e = clang.clang_Cursor_Evaluate(cursor); - final k = clang.clang_EvalResult_getKind(e); - _logger.fine('macroVariablevisitor: ${cursor.completeStringRepr()}'); - - /// Get macro name, the variable name starts with '_'. - final macroName = MacroVariableString.decode(cursor.spelling()); - switch (k) { - case clang_types.CXEvalResultKind.CXEval_Int: - constant = Constant( - usr: savedMacros[macroName]!.usr, - originalName: savedMacros[macroName]!.originalName, - name: macroName, - rawType: 'int', - rawValue: clang.clang_EvalResult_getAsLongLong(e).toString(), - ); - break; - case clang_types.CXEvalResultKind.CXEval_Float: - constant = Constant( - usr: savedMacros[macroName]!.usr, - originalName: savedMacros[macroName]!.originalName, - name: macroName, - rawType: 'double', - rawValue: - _writeDoubleAsString(clang.clang_EvalResult_getAsDouble(e)), - ); - break; - case clang_types.CXEvalResultKind.CXEval_StrLiteral: - final rawValue = _getWrittenRepresentation( - macroName, - clang.clang_EvalResult_getAsStr(e), - ); - constant = Constant( - usr: savedMacros[macroName]!.usr, - originalName: savedMacros[macroName]!.originalName, - name: macroName, - rawType: 'String', - rawValue: "'$rawValue'", - ); - break; - } - clang.clang_EvalResult_dispose(e); - - if (constant != null) { - _bindings!.add(constant); - } - } - } catch (e, s) { - _logger.severe(e); - _logger.severe(s); - rethrow; - } - return clang_types.CXChildVisitResult.CXChildVisit_Continue; -} - -/// Returns true if cursor is from generated file. -bool isFromGeneratedFile(clang_types.CXCursor cursor) { - final s = cursor.sourceFileName(); - return p.basename(s) == _generatedFileBaseName; -} - -/// Base name of generated file. -String? _generatedFileBaseName; - -/// Generated macro variable names. -/// -/// Used to determine if macro should be included in bindings or not. -late Set _macroVarNames; - -/// Creates a temporary file for parsing macros in current directory. -File createFileForMacros() { - final fileNameBase = 'temp_for_macros'; - final fileExt = 'hpp'; - - // Find a filename which doesn't already exist. - var file = File('$fileNameBase.$fileExt'); - var i = 0; - while (file.existsSync()) { - i++; - file = File('${fileNameBase.split('.')[0]}_$i.$fileExt'); - } - - // Create file. - file.createSync(); - // Save generted name. - _generatedFileBaseName = p.basename(file.path); - - // Write file contents. - final sb = StringBuffer(); - for (final h in config.headers.entryPoints) { - sb.writeln('#include "$h"'); - } - - _macroVarNames = {}; - for (final prefixedMacroName in savedMacros.keys) { - // Write macro. - final macroVarName = MacroVariableString.encode(prefixedMacroName); - sb.writeln( - 'auto $macroVarName = ${savedMacros[prefixedMacroName]!.originalName};'); - // Add to _macroVarNames. - _macroVarNames.add(macroVarName); - } - final macroFileContent = sb.toString(); - // Log this generated file for debugging purpose. - // We use the finest log because this file may be very big. - _logger.finest('=====FILE FOR MACROS===='); - _logger.finest(macroFileContent); - _logger.finest('========================'); - - file.writeAsStringSync(macroFileContent); - return file; -} - -/// Deals with encoding/decoding name of the variable generated for a Macro. -class MacroVariableString { - static String encode(String s) { - return '_${s.length}_${s}_generated_macro_variable'; - } - - static String decode(String s) { - // Remove underscore. - s = s.substring(1); - final intReg = RegExp('[0-9]+'); - final lengthEnd = intReg.matchAsPrefix(s)!.end; - final len = int.parse(s.substring(0, lengthEnd)); - - // Name starts after an unerscore. - final nameStart = lengthEnd + 1; - return s.substring(nameStart, nameStart + len); - } -} - -/// Gets a written representation string of a C string. -/// -/// E.g- For a string "Hello\nWorld", The new line character is converted to \n. -/// Note: The string is considered to be Utf8, but is treated as Extended ASCII, -/// if the conversion fails. -String _getWrittenRepresentation(String macroName, Pointer strPtr) { - final sb = StringBuffer(); - try { - // Consider string to be Utf8 encoded by default. - sb.clear(); - // This throws a Format Exception if string isn't Utf8 so that we handle it - // in the catch block. - final result = strPtr.cast().toDartString(); - for (final s in result.runes) { - sb.write(_getWritableChar(s)); - } - } catch (e) { - // Handle string if it isn't Utf8. String is considered to be - // Extended ASCII in this case. - _logger.warning( - "Couldn't decode Macro string '$macroName' as Utf8, using ASCII instead."); - sb.clear(); - final length = strPtr.cast().length; - final charList = Uint8List.view( - strPtr.cast().asTypedList(length).buffer, 0, length); - - for (final char in charList) { - sb.write(_getWritableChar(char, utf8: false)); - } - } - - return sb.toString(); -} - -/// Creates a writable char from [char] code. -/// -/// E.g- `\` is converted to `\\`. -String _getWritableChar(int char, {bool utf8 = true}) { - /// Handle control characters. - if (char >= 0 && char < 32 || char == 127) { - /// Handle these - `\b \t \n \v \f \r` as special cases. - switch (char) { - case 8: // \b - return r'\b'; - case 9: // \t - return r'\t'; - case 10: // \n - return r'\n'; - case 11: // \v - return r'\v'; - case 12: // \f - return r'\f'; - case 13: // \r - return r'\r'; - default: - final h = char.toRadixString(16).toUpperCase().padLeft(2, '0'); - return '\\x$h'; - } - } - - /// Handle characters - `$ ' \` these need to be escaped when writing to file. - switch (char) { - case 36: // $ - return r'\$'; - case 39: // ' - return r"\'"; - case 92: // \ - return r'\\'; - } - - /// In case encoding is not Utf8, we know all characters will fall in [0..255] - /// Print range [128..255] as `\xHH`. - if (!utf8) { - final h = char.toRadixString(16).toUpperCase().padLeft(2, '0'); - return '\\x$h'; - } - - /// In all other cases, simply convert to string. - return String.fromCharCode(char); -} - -/// Converts a double to a string, handling cases like Infinity and NaN. -String _writeDoubleAsString(double d) { - if (d.isFinite) { - return d.toString(); - } else { - // The only Non-Finite numbers are Infinity, NegativeInfinity and NaN. - if (d.isInfinite) { - return d.isNegative - ? strings.doubleNegativeInfinity - : strings.doubleInfinity; - } - return strings.doubleNaN; - } -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/objc_block_parser.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/objc_block_parser.dart deleted file mode 100644 index 83f82234a..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/objc_block_parser.dart +++ /dev/null @@ -1,40 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -import 'package:ffigen/src/code_generator.dart'; -import 'package:ffigen/src/header_parser/data.dart'; -import 'package:logging/logging.dart'; - -import '../clang_bindings/clang_bindings.dart' as clang_types; -import '../utils.dart'; - -final _logger = Logger('ffigen.header_parser.objc_block_parser'); - -ObjCBlock parseObjCBlock(clang_types.CXType cxtype) { - final blk = clang.clang_getPointeeType(cxtype); - final returnType = clang.clang_getResultType(blk).toCodeGenType(); - final argTypes = []; - final int numArgs = clang.clang_getNumArgTypes(blk); - for (int i = 0; i < numArgs; ++i) { - argTypes.add(clang.clang_getArgType(blk, i).toCodeGenType()); - } - - // Create a fake USR code for the block. This code is used to dedupe blocks - // with the same signature. - var usr = 'objcBlock: ' + returnType.cacheKey(); - for (final type in argTypes) { - usr += ' ' + type.cacheKey(); - } - - _logger.fine('++++ Adding ObjC block: ' - '${cxtype.completeStringRepr()}, syntheticUsr: $usr'); - - return ObjCBlock( - usr: usr.toString(), - name: 'ObjCBlock', - returnType: returnType, - argTypes: argTypes, - builtInFunctions: objCBuiltInFunctions, - ); -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/objcinterfacedecl_parser.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/objcinterfacedecl_parser.dart deleted file mode 100644 index 94fff9255..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/objcinterfacedecl_parser.dart +++ /dev/null @@ -1,329 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -import 'dart:ffi'; - -import 'package:ffigen/src/code_generator.dart'; -import 'package:ffigen/src/header_parser/data.dart'; -import 'package:logging/logging.dart'; - -import '../clang_bindings/clang_bindings.dart' as clang_types; -import '../includer.dart'; -import '../utils.dart'; - -final _logger = Logger('ffigen.header_parser.objcinterfacedecl_parser'); - -class _ParsedObjCInterface { - ObjCInterface interface; - _ParsedObjCInterface(this.interface); -} - -class _ParsedObjCMethod { - ObjCMethod method; - bool hasError = false; - _ParsedObjCMethod(this.method); -} - -final _interfaceStack = Stack<_ParsedObjCInterface>(); -final _methodStack = Stack<_ParsedObjCMethod>(); - -Type? parseObjCInterfaceDeclaration( - clang_types.CXCursor cursor, { - /// Option to ignore declaration filter (Useful in case of extracting - /// declarations when they are passed/returned by an included function.) - bool ignoreFilter = false, -}) { - final itfUsr = cursor.usr(); - final itfName = cursor.spelling(); - if (!ignoreFilter && !shouldIncludeObjCInterface(itfUsr, itfName)) { - return null; - } - - final t = cursor.type(); - final name = t.spelling(); - - _logger.fine('++++ Adding ObjC interface: ' - 'Name: $name, ${cursor.completeStringRepr()}'); - - return ObjCInterface( - usr: itfUsr, - originalName: name, - name: config.objcInterfaces.renameUsingConfig(name), - dartDoc: getCursorDocComment(cursor), - builtInFunctions: objCBuiltInFunctions, - isBuiltIn: cursor.isInSystemHeader(), - ); -} - -void fillObjCInterfaceMethodsIfNeeded( - ObjCInterface itf, clang_types.CXCursor cursor) { - if (_isClassDeclaration(cursor)) { - // @class declarations are ObjC's way of forward declaring classes. In that - // case there's nothing to fill yet. - return; - } - - if (itf.filled) return; - itf.filled = true; // Break cycles. - - _logger.fine('++++ Filling ObjC interface: ' - 'Name: ${itf.originalName}, ${cursor.completeStringRepr()}'); - - _interfaceStack.push(_ParsedObjCInterface(itf)); - clang.clang_visitChildren( - cursor, - Pointer.fromFunction(_parseInterfaceVisitor, exceptional_visitor_return), - nullptr); - _interfaceStack.pop(); - - _logger.fine('++++ Finished ObjC interface: ' - 'Name: ${itf.originalName}, ${cursor.completeStringRepr()}'); -} - -bool _isClassDeclarationResult = false; -bool _isClassDeclaration(clang_types.CXCursor cursor) { - // It's a class declaration if it has no children other than ObjCClassRef. - _isClassDeclarationResult = true; - clang.clang_visitChildren( - cursor, - Pointer.fromFunction( - _isClassDeclarationVisitor, exceptional_visitor_return), - nullptr); - return _isClassDeclarationResult; -} - -int _isClassDeclarationVisitor(clang_types.CXCursor cursor, - clang_types.CXCursor parent, Pointer clientData) { - if (cursor.kind == clang_types.CXCursorKind.CXCursor_ObjCClassRef) { - return clang_types.CXChildVisitResult.CXChildVisit_Continue; - } - _isClassDeclarationResult = false; - return clang_types.CXChildVisitResult.CXChildVisit_Break; -} - -int _parseInterfaceVisitor(clang_types.CXCursor cursor, - clang_types.CXCursor parent, Pointer clientData) { - switch (cursor.kind) { - case clang_types.CXCursorKind.CXCursor_ObjCSuperClassRef: - _parseSuperType(cursor); - break; - case clang_types.CXCursorKind.CXCursor_ObjCPropertyDecl: - _parseProperty(cursor); - break; - case clang_types.CXCursorKind.CXCursor_ObjCInstanceMethodDecl: - case clang_types.CXCursorKind.CXCursor_ObjCClassMethodDecl: - _parseMethod(cursor); - break; - } - return clang_types.CXChildVisitResult.CXChildVisit_Continue; -} - -void _parseSuperType(clang_types.CXCursor cursor) { - final superType = cursor.type().toCodeGenType(); - _logger.fine(' > Super type: ' - '$superType ${cursor.completeStringRepr()}'); - final itf = _interfaceStack.top.interface; - if (superType is ObjCInterface) { - itf.superType = superType; - } else { - _logger.severe( - 'Super type of $itf is $superType, which is not a valid interface.'); - } -} - -void _parseProperty(clang_types.CXCursor cursor) { - final itf = _interfaceStack.top.interface; - final fieldName = cursor.spelling(); - final fieldType = cursor.type().toCodeGenType(); - final dartDoc = getCursorDocComment(cursor); - - final propertyAttributes = - clang.clang_Cursor_getObjCPropertyAttributes(cursor, 0); - final isClass = propertyAttributes & - clang_types.CXObjCPropertyAttrKind.CXObjCPropertyAttr_class > - 0; - final isReadOnly = propertyAttributes & - clang_types.CXObjCPropertyAttrKind.CXObjCPropertyAttr_readonly > - 0; - // TODO(#334): Use the nullable attribute to decide this. - final isNullable = - cursor.type().kind == clang_types.CXTypeKind.CXType_ObjCObjectPointer; - - final property = ObjCProperty(fieldName); - - _logger.fine(' > Property: ' - '$fieldType $fieldName ${cursor.completeStringRepr()}'); - - final getterName = - clang.clang_Cursor_getObjCPropertyGetterName(cursor).toStringAndDispose(); - final getter = ObjCMethod( - originalName: getterName, - property: property, - dartDoc: dartDoc, - kind: ObjCMethodKind.propertyGetter, - isClass: isClass, - returnType: fieldType, - isNullableReturn: isNullable, - ); - itf.addMethod(getter); - - if (!isReadOnly) { - final setterName = clang - .clang_Cursor_getObjCPropertySetterName(cursor) - .toStringAndDispose(); - final setter = ObjCMethod( - originalName: setterName, - property: property, - dartDoc: dartDoc, - kind: ObjCMethodKind.propertySetter, - isClass: isClass); - setter.returnType = NativeType(SupportedNativeType.Void); - setter.params - .add(ObjCMethodParam(fieldType, 'value', isNullable: isNullable)); - itf.addMethod(setter); - } -} - -void _parseMethod(clang_types.CXCursor cursor) { - final methodName = cursor.spelling(); - final isClassMethod = - cursor.kind == clang_types.CXCursorKind.CXCursor_ObjCClassMethodDecl; - final method = ObjCMethod( - originalName: methodName, - dartDoc: getCursorDocComment(cursor), - kind: ObjCMethodKind.method, - isClass: isClassMethod, - ); - final parsed = _ParsedObjCMethod(method); - _logger.fine(' > ${isClassMethod ? 'Class' : 'Instance'} method: ' - '${method.originalName} ${cursor.completeStringRepr()}'); - _methodStack.push(parsed); - clang.clang_visitChildren( - cursor, - Pointer.fromFunction(_parseMethodVisitor, exceptional_visitor_return), - nullptr); - _methodStack.pop(); - if (parsed.hasError) { - // Discard it. - return; - } - _interfaceStack.top.interface.addMethod(method); -} - -int _parseMethodVisitor(clang_types.CXCursor cursor, - clang_types.CXCursor parent, Pointer clientData) { - switch (cursor.kind) { - case clang_types.CXCursorKind.CXCursor_TypeRef: - case clang_types.CXCursorKind.CXCursor_ObjCClassRef: - _parseMethodReturnType(cursor); - break; - case clang_types.CXCursorKind.CXCursor_ParmDecl: - _parseMethodParam(cursor); - break; - case clang_types.CXCursorKind.CXCursor_NSReturnsRetained: - _markMethodReturnsRetained(cursor); - break; - default: - } - return clang_types.CXChildVisitResult.CXChildVisit_Continue; -} - -void _parseMethodReturnType(clang_types.CXCursor cursor) { - final parsed = _methodStack.top; - if (parsed.method.returnType != null) { - parsed.hasError = true; - _logger.fine( - ' >> Extra return type: ${cursor.completeStringRepr()}'); - _logger.warning('Method "${parsed.method.originalName}" in instance ' - '"${_interfaceStack.top.interface.originalName}" has multiple return ' - 'types.'); - } else { - parsed.method.returnType = cursor.type().toCodeGenType(); - _logger.fine(' >> Return type: ' - '${parsed.method.returnType} ${cursor.completeStringRepr()}'); - } -} - -void _parseMethodParam(clang_types.CXCursor cursor) { - /* - TODO(#334): Change this to use: - - clang.clang_Type_getNullability(cursor.type()) == - clang_types.CXTypeNullabilityKind.CXTypeNullability_Nullable; - - NOTE: This will only work with the - - clang_types - .CXTranslationUnit_Flags.CXTranslationUnit_IncludeAttributedTypes - - option set. - */ - final isNullable = - cursor.type().kind == clang_types.CXTypeKind.CXType_ObjCObjectPointer; - final name = cursor.spelling(); - final type = cursor.type().toCodeGenType(); - _logger.fine( - ' >> Parameter: $type $name ${cursor.completeStringRepr()}'); - _methodStack.top.method.params - .add(ObjCMethodParam(type, name, isNullable: isNullable)); -} - -void _markMethodReturnsRetained(clang_types.CXCursor cursor) { - _methodStack.top.method.returnsRetained = true; -} - -BindingType? parseObjCCategoryDeclaration(clang_types.CXCursor cursor) { - // Categories add methods to an existing interface, so first we run a visitor - // to find the interface, then we fully parse that interface, then we run the - // _parseInterfaceVisitor over the category to add its methods etc. Reusing - // the interface visitor relies on the fact that the structure of the category - // AST looks exactly the same as the interface AST, and that the category's - // interface is a different kind of node to the interface's super type (so is - // ignored by _parseInterfaceVisitor). - final name = cursor.spelling(); - _logger.fine('++++ Adding ObjC category: ' - 'Name: $name, ${cursor.completeStringRepr()}'); - - _findCategoryInterfaceVisitorResult = null; - clang.clang_visitChildren( - cursor, - Pointer.fromFunction( - _findCategoryInterfaceVisitor, exceptional_visitor_return), - nullptr); - final itfCursor = _findCategoryInterfaceVisitorResult; - if (itfCursor == null) { - _logger.severe('Category $name has no interface.'); - return null; - } - - // TODO(#347): Currently any interface with a category bypasses the filters. - final itf = itfCursor.type().toCodeGenType(); - if (itf is! ObjCInterface) { - _logger.severe( - 'Interface of category $name is $itf, which is not a valid interface.'); - return null; - } - - _interfaceStack.push(_ParsedObjCInterface(itf)); - clang.clang_visitChildren( - cursor, - Pointer.fromFunction(_parseInterfaceVisitor, exceptional_visitor_return), - nullptr); - _interfaceStack.pop(); - - _logger.fine('++++ Finished ObjC category: ' - 'Name: $name, ${cursor.completeStringRepr()}'); - - return itf; -} - -clang_types.CXCursor? _findCategoryInterfaceVisitorResult; -int _findCategoryInterfaceVisitor(clang_types.CXCursor cursor, - clang_types.CXCursor parent, Pointer clientData) { - if (cursor.kind == clang_types.CXCursorKind.CXCursor_ObjCClassRef) { - _findCategoryInterfaceVisitorResult = cursor; - return clang_types.CXChildVisitResult.CXChildVisit_Break; - } - return clang_types.CXChildVisitResult.CXChildVisit_Continue; -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/typedefdecl_parser.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/typedefdecl_parser.dart deleted file mode 100644 index 988a45e39..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/typedefdecl_parser.dart +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (c) 2020, 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:ffigen/src/code_generator.dart'; -import 'package:ffigen/src/header_parser/includer.dart'; -import 'package:ffigen/src/header_parser/type_extractor/extractor.dart'; -import 'package:logging/logging.dart'; - -import '../clang_bindings/clang_bindings.dart' as clang_types; -import '../data.dart'; -import '../utils.dart'; - -final _logger = Logger('ffigen.header_parser.typedefdecl_parser'); - -/// Parses a typedef declaration. -/// -/// Notes: -/// - Pointer to Typedefs structs are skipped if the struct is seen. -/// - If there are multiple typedefs for a declaration (struct/enum), the last -/// seen name is used. -/// - Typerefs are completely ignored. -/// -/// Libclang marks them as following - -/// ```C -/// typedef struct A{ -/// int a -/// } B, *pB; // Typedef(s). -/// -/// typedef A D; // Typeref. -/// ``` -/// -/// Returns `null` if the typedef could not be generated or has been excluded -/// by the config. -Typealias? parseTypedefDeclaration( - clang_types.CXCursor cursor, { - bool pointerReference = false, -}) { - final typedefName = cursor.spelling(); - final typedefUsr = cursor.usr(); - if (shouldIncludeTypealias(typedefUsr, typedefName)) { - final ct = clang.clang_getTypedefDeclUnderlyingType(cursor); - final s = getCodeGenType(ct, pointerReference: pointerReference); - - if (bindingsIndex.isSeenUnsupportedTypealias(typedefUsr)) { - // Do not process unsupported typealiases again. - } else if (s is UnimplementedType) { - _logger.fine("Skipped Typedef '$typedefName': " - 'Unimplemented type referred.'); - bindingsIndex.addUnsupportedTypealiasToSeen(typedefUsr); - } else if (s is Compound && s.originalName == typedefName) { - // Ignore typedef if it refers to a compound with the same original name. - bindingsIndex.addUnsupportedTypealiasToSeen(typedefUsr); - _logger.fine("Skipped Typedef '$typedefName': " - 'Name matches with referred struct/union.'); - } else if (s is EnumClass) { - // Ignore typedefs to Enum. - bindingsIndex.addUnsupportedTypealiasToSeen(typedefUsr); - _logger.fine("Skipped Typedef '$typedefName': typedef to enum."); - } else if (s is HandleType) { - // Ignore typedefs to Handle. - _logger.fine("Skipped Typedef '$typedefName': typedef to Dart Handle."); - bindingsIndex.addUnsupportedTypealiasToSeen(typedefUsr); - } else if (s is ConstantArray || s is IncompleteArray) { - // Ignore typedefs to Constant Array. - _logger.fine("Skipped Typedef '$typedefName': typedef to array."); - bindingsIndex.addUnsupportedTypealiasToSeen(typedefUsr); - } else if (s is BooleanType) { - // Ignore typedefs to Boolean. - _logger.fine("Skipped Typedef '$typedefName': typedef to bool."); - bindingsIndex.addUnsupportedTypealiasToSeen(typedefUsr); - } else { - // Create typealias. - return Typealias( - usr: typedefUsr, - originalName: typedefName, - name: config.typedefs.renameUsingConfig(typedefName), - type: s, - dartDoc: getCursorDocComment(cursor), - ); - } - } - return null; -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/unnamed_enumdecl_parser.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/unnamed_enumdecl_parser.dart deleted file mode 100644 index 940369ae2..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/unnamed_enumdecl_parser.dart +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) 2020, 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:ffi'; - -import 'package:ffigen/src/code_generator.dart'; -import 'package:ffigen/src/header_parser/data.dart'; -import 'package:ffigen/src/header_parser/includer.dart'; -import 'package:logging/logging.dart'; - -import '../clang_bindings/clang_bindings.dart' as clang_types; -import '../data.dart'; -import '../utils.dart'; - -final _logger = Logger('ffigen.header_parser.unnamed_enumdecl_parser'); - -/// Saves unnamed enums. -void saveUnNamedEnum(clang_types.CXCursor cursor) { - final resultCode = clang.clang_visitChildren( - cursor, - Pointer.fromFunction(_unnamedenumCursorVisitor, exceptional_visitor_return), - nullptr, - ); - - visitChildrenResultChecker(resultCode); -} - -/// Visitor for a enum cursor [clang.CXCursorKind.CXCursor_EnumDecl]. -/// -/// Invoked on every enum directly under rootCursor. -/// Used for for extracting enum values. -int _unnamedenumCursorVisitor(clang_types.CXCursor cursor, - clang_types.CXCursor parent, Pointer clientData) { - try { - _logger - .finest(' unnamedenumCursorVisitor: ${cursor.completeStringRepr()}'); - switch (clang.clang_getCursorKind(cursor)) { - case clang_types.CXCursorKind.CXCursor_EnumConstantDecl: - if (shouldIncludeUnnamedEnumConstant(cursor.usr(), cursor.spelling())) { - _addUnNamedEnumConstant(cursor); - } - break; - default: - _logger.severe('Invalid enum constant.'); - } - } catch (e, s) { - _logger.severe(e); - _logger.severe(s); - rethrow; - } - return clang_types.CXChildVisitResult.CXChildVisit_Continue; -} - -/// Adds the parameter to func in [functiondecl_parser.dart]. -void _addUnNamedEnumConstant(clang_types.CXCursor cursor) { - _logger.fine( - '++++ Adding Constant from unnamed enum: ${cursor.completeStringRepr()}'); - final constant = Constant( - usr: cursor.usr(), - originalName: cursor.spelling(), - name: config.unnamedEnumConstants.renameUsingConfig( - cursor.spelling(), - ), - rawType: 'int', - rawValue: clang.clang_getEnumConstantDeclValue(cursor).toString(), - ); - bindingsIndex.addUnnamedEnumConstantToSeen(cursor.usr(), constant); - unnamedEnumConstants.add(constant); -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/var_parser.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/var_parser.dart deleted file mode 100644 index 8376199fb..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/sub_parsers/var_parser.dart +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) 2021, 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:ffigen/src/code_generator.dart'; -import 'package:ffigen/src/header_parser/data.dart'; -import 'package:ffigen/src/header_parser/includer.dart'; -import 'package:logging/logging.dart'; - -import '../clang_bindings/clang_bindings.dart' as clang_types; -import '../data.dart'; -import '../utils.dart'; - -final _logger = Logger('ffigen.header_parser.var_parser'); - -/// Parses a global variable -Global? parseVarDeclaration(clang_types.CXCursor cursor) { - final name = cursor.spelling(); - final usr = cursor.usr(); - if (bindingsIndex.isSeenGlobalVar(usr)) { - return bindingsIndex.getSeenGlobalVar(usr); - } - if (!shouldIncludeGlobalVar(usr, name)) { - return null; - } - - _logger.fine('++++ Adding Global: ${cursor.completeStringRepr()}'); - - final type = cursor.type().toCodeGenType(); - if (type.baseType is UnimplementedType) { - _logger.fine('---- Removed Global, reason: unsupported type: ' - '${cursor.completeStringRepr()}'); - _logger.warning("Skipped global variable '$name', type not supported."); - return null; - } - - final global = Global( - originalName: name, - name: config.globals.renameUsingConfig(name), - usr: usr, - type: type, - dartDoc: getCursorDocComment(cursor), - exposeSymbolAddress: config.functionDecl.shouldIncludeSymbolAddress(name), - ); - bindingsIndex.addGlobalVarToSeen(usr, global); - return global; -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/translation_unit_parser.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/translation_unit_parser.dart deleted file mode 100644 index 7831ae8aa..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/translation_unit_parser.dart +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (c) 2020, 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:ffi'; - -import 'package:ffigen/src/code_generator.dart'; -import 'package:ffigen/src/header_parser/sub_parsers/macro_parser.dart'; -import 'package:ffigen/src/header_parser/sub_parsers/objcinterfacedecl_parser.dart'; -import 'package:ffigen/src/header_parser/sub_parsers/var_parser.dart'; -import 'package:logging/logging.dart'; - -import 'clang_bindings/clang_bindings.dart' as clang_types; -import 'data.dart'; -import 'includer.dart'; -import 'sub_parsers/functiondecl_parser.dart'; -import 'type_extractor/extractor.dart'; -import 'utils.dart'; - -final _logger = Logger('ffigen.header_parser.translation_unit_parser'); - -late Set _bindings; - -/// Parses the translation unit and returns the generated bindings. -Set parseTranslationUnit(clang_types.CXCursor translationUnitCursor) { - _bindings = {}; - final resultCode = clang.clang_visitChildren( - translationUnitCursor, - Pointer.fromFunction(_rootCursorVisitor, exceptional_visitor_return), - nullptr, - ); - - visitChildrenResultChecker(resultCode); - - return _bindings; -} - -/// Child visitor invoked on translationUnitCursor [CXCursorKind.CXCursor_TranslationUnit]. -int _rootCursorVisitor(clang_types.CXCursor cursor, clang_types.CXCursor parent, - Pointer clientData) { - try { - if (shouldIncludeRootCursor(cursor.sourceFileName())) { - _logger.finest('rootCursorVisitor: ${cursor.completeStringRepr()}'); - switch (clang.clang_getCursorKind(cursor)) { - case clang_types.CXCursorKind.CXCursor_FunctionDecl: - addToBindings(parseFunctionDeclaration(cursor)); - break; - case clang_types.CXCursorKind.CXCursor_StructDecl: - case clang_types.CXCursorKind.CXCursor_UnionDecl: - case clang_types.CXCursorKind.CXCursor_EnumDecl: - case clang_types.CXCursorKind.CXCursor_ObjCInterfaceDecl: - addToBindings(_getCodeGenTypeFromCursor(cursor)); - break; - case clang_types.CXCursorKind.CXCursor_ObjCCategoryDecl: - addToBindings(parseObjCCategoryDeclaration(cursor)); - break; - case clang_types.CXCursorKind.CXCursor_MacroDefinition: - saveMacroDefinition(cursor); - break; - case clang_types.CXCursorKind.CXCursor_VarDecl: - addToBindings(parseVarDeclaration(cursor)); - break; - default: - _logger.finer('rootCursorVisitor: CursorKind not implemented'); - } - } else { - _logger.finest( - 'rootCursorVisitor:(not included) ${cursor.completeStringRepr()}'); - } - } catch (e, s) { - _logger.severe(e); - _logger.severe(s); - rethrow; - } - return clang_types.CXChildVisitResult.CXChildVisit_Continue; -} - -/// Adds to binding if unseen and not null. -void addToBindings(Binding? b) { - if (b != null) { - // This is a set, and hence will not have duplicates. - _bindings.add(b); - } -} - -BindingType? _getCodeGenTypeFromCursor(clang_types.CXCursor cursor) { - final t = getCodeGenType(cursor.type(), ignoreFilter: false); - return t is BindingType ? t : null; -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/type_extractor/cxtypekindmap.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/type_extractor/cxtypekindmap.dart deleted file mode 100644 index 41af99a9d..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/type_extractor/cxtypekindmap.dart +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2020, 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:ffigen/src/code_generator.dart' show SupportedNativeType; -import 'package:ffigen/src/code_generator/imports.dart'; - -var cxTypeKindToImportedTypes = { - 'void': voidType, - 'unsigned char': unsignedCharType, - 'signed char': signedCharType, - 'char': charType, - 'unsigned short': unsignedShortType, - 'short': shortType, - 'unsigned int': unsignedIntType, - 'int': intType, - 'unsigned long': unsignedLongType, - 'long': longType, - 'unsigned long long': unsignedLongLongType, - 'long long': longLongType, - 'float': floatType, - 'double': doubleType, -}; - -var suportedTypedefToSuportedNativeType = { - 'uint8_t': SupportedNativeType.Uint8, - 'uint16_t': SupportedNativeType.Uint16, - 'uint32_t': SupportedNativeType.Uint32, - 'uint64_t': SupportedNativeType.Uint64, - 'int8_t': SupportedNativeType.Int8, - 'int16_t': SupportedNativeType.Int16, - 'int32_t': SupportedNativeType.Int32, - 'int64_t': SupportedNativeType.Int64, - 'intptr_t': SupportedNativeType.IntPtr, -}; - -var supportedTypedefToImportedType = { - 'size_t': sizeType, - 'wchar_t': wCharType, -}; diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/type_extractor/extractor.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/type_extractor/extractor.dart deleted file mode 100644 index 7a497a3cc..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/type_extractor/extractor.dart +++ /dev/null @@ -1,304 +0,0 @@ -// Copyright (c) 2020, 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. - -/// Extracts code_gen Type from type. -import 'package:ffigen/src/code_generator.dart'; -import 'package:ffigen/src/header_parser/sub_parsers/typedefdecl_parser.dart'; -import 'package:ffigen/src/strings.dart' as strings; -import 'package:logging/logging.dart'; - -import '../../config_provider/config_types.dart'; -import '../clang_bindings/clang_bindings.dart' as clang_types; -import '../data.dart'; -import '../sub_parsers/compounddecl_parser.dart'; -import '../sub_parsers/enumdecl_parser.dart'; -import '../sub_parsers/objc_block_parser.dart'; -import '../sub_parsers/objcinterfacedecl_parser.dart'; -import '../type_extractor/cxtypekindmap.dart'; -import '../utils.dart'; - -final _logger = Logger('ffigen.header_parser.extractor'); -const _padding = ' '; - -/// Converts cxtype to a typestring code_generator can accept. -Type getCodeGenType( - clang_types.CXType cxtype, { - /// Option to ignore declaration filter (Useful in case of extracting - /// declarations when they are passed/returned by an included function.) - bool ignoreFilter = true, - - /// Passed on if a value was marked as a pointer before this one. - bool pointerReference = false, -}) { - _logger.fine('${_padding}getCodeGenType ${cxtype.completeStringRepr()}'); - - // Special case: Elaborated types just refer to another type. - if (cxtype.kind == clang_types.CXTypeKind.CXType_Elaborated) { - return getCodeGenType(clang.clang_Type_getNamedType(cxtype), - ignoreFilter: ignoreFilter, pointerReference: pointerReference); - } - - // These basic Objective C types skip the cache, and are conditional on the - // language flag. - if (config.language == Language.objc) { - switch (cxtype.kind) { - case clang_types.CXTypeKind.CXType_ObjCObjectPointer: - case clang_types.CXTypeKind.CXType_ObjCId: - case clang_types.CXTypeKind.CXType_ObjCTypeParam: - case clang_types.CXTypeKind.CXType_ObjCClass: - return PointerType(objCObjectType); - case clang_types.CXTypeKind.CXType_ObjCSel: - return PointerType(objCSelType); - case clang_types.CXTypeKind.CXType_BlockPointer: - return _getOrCreateBlockType(cxtype); - } - } - - // If the type has a declaration cursor, then use the BindingsIndex to break - // any potential cycles, and dedupe the Type. - final cursor = clang.clang_getTypeDeclaration(cxtype); - if (cursor.kind != clang_types.CXCursorKind.CXCursor_NoDeclFound) { - final usr = cursor.usr(); - var type = bindingsIndex.getSeenType(usr); - if (type == null) { - final result = - _createTypeFromCursor(cxtype, cursor, ignoreFilter, pointerReference); - type = result.type; - if (type == null) { - return UnimplementedType('${cxtype.kindSpelling()} not implemented'); - } - if (result.addToCache) { - bindingsIndex.addTypeToSeen(usr, type); - } - } - _fillFromCursorIfNeeded(type, cursor, ignoreFilter, pointerReference); - return type; - } - - // If the type doesn't have a declaration cursor, then it's a basic type such - // as int, or a simple derived type like a pointer, so doesn't need to be - // cached. - switch (cxtype.kind) { - case clang_types.CXTypeKind.CXType_Pointer: - final pt = clang.clang_getPointeeType(cxtype); - final s = getCodeGenType(pt, pointerReference: true); - - // Replace Pointer<_Dart_Handle> with Handle. - if (config.useDartHandle && - s is Compound && - s.compoundType == CompoundType.struct && - s.usr == strings.dartHandleUsr) { - return HandleType(); - } - return PointerType(s); - case clang_types.CXTypeKind.CXType_FunctionProto: - // Primarily used for function pointers. - return _extractFromFunctionProto(cxtype); - case clang_types.CXTypeKind.CXType_FunctionNoProto: - // Primarily used for function types with zero arguments. - return _extractFromFunctionProto(cxtype); - case clang_types.CXTypeKind - .CXType_ConstantArray: // Primarily used for constant array in struct members. - return ConstantArray( - clang.clang_getNumElements(cxtype), - clang.clang_getArrayElementType(cxtype).toCodeGenType(), - ); - case clang_types.CXTypeKind - .CXType_IncompleteArray: // Primarily used for incomplete array in function parameters. - return IncompleteArray( - clang.clang_getArrayElementType(cxtype).toCodeGenType(), - ); - case clang_types.CXTypeKind.CXType_Bool: - return BooleanType(); - default: - var typeSpellKey = - clang.clang_getTypeSpelling(cxtype).toStringAndDispose(); - if (typeSpellKey.startsWith('const ')) { - typeSpellKey = typeSpellKey.replaceFirst('const ', ''); - } - if (config.nativeTypeMappings.containsKey(typeSpellKey)) { - _logger.fine(' Type $typeSpellKey mapped from type-map.'); - return config.nativeTypeMappings[typeSpellKey]!; - } else if (cxTypeKindToImportedTypes.containsKey(typeSpellKey)) { - return cxTypeKindToImportedTypes[typeSpellKey]!; - } else { - _logger.fine('typedeclarationCursorVisitor: getCodeGenType: Type Not ' - 'Implemented, ${cxtype.completeStringRepr()}'); - return UnimplementedType('${cxtype.kindSpelling()} not implemented'); - } - } -} - -Type _getOrCreateBlockType(clang_types.CXType cxtype) { - final block = parseObjCBlock(cxtype); - final key = block.usr; - final oldBlock = bindingsIndex.getSeenObjCBlock(key); - if (oldBlock != null) { - return oldBlock; - } - bindingsIndex.addObjCBlockToSeen(key, block); - return block; -} - -class _CreateTypeFromCursorResult { - final Type? type; - - // Flag that controls whether the type is added to the cache. It should not - // be added to the cache if it's just a fallback implementation, such as the - // int that is returned when an enum is excluded by the config. Later we might - // need to build the full enum type (eg if it's part of an included struct), - // and if we put the fallback int in the cache then the full enum will never - // be created. - final bool addToCache; - - _CreateTypeFromCursorResult(this.type, {this.addToCache = true}); -} - -_CreateTypeFromCursorResult _createTypeFromCursor(clang_types.CXType cxtype, - clang_types.CXCursor cursor, bool ignoreFilter, bool pointerReference) { - switch (cxtype.kind) { - case clang_types.CXTypeKind.CXType_Typedef: - final spelling = clang.clang_getTypedefName(cxtype).toStringAndDispose(); - if (config.language == Language.objc && spelling == strings.objcBOOL) { - // Objective C's BOOL type can be either bool or signed char, depending - // on the platform. We want to present a consistent API to the user, and - // those two types are ABI compatible, so just return bool regardless. - return _CreateTypeFromCursorResult(BooleanType()); - } - if (config.typedefTypeMappings.containsKey(spelling)) { - _logger.fine(' Type $spelling mapped from type-map'); - return _CreateTypeFromCursorResult( - config.typedefTypeMappings[spelling]!); - } - // Get name from supported typedef name if config allows. - if (config.useSupportedTypedefs) { - if (suportedTypedefToSuportedNativeType.containsKey(spelling)) { - _logger.fine(' Type Mapped from supported typedef'); - return _CreateTypeFromCursorResult( - NativeType(suportedTypedefToSuportedNativeType[spelling]!)); - } else if (supportedTypedefToImportedType.containsKey(spelling)) { - _logger.fine(' Type Mapped from supported typedef'); - return _CreateTypeFromCursorResult( - supportedTypedefToImportedType[spelling]!); - } - } - - final typealias = - parseTypedefDeclaration(cursor, pointerReference: pointerReference); - - if (typealias != null) { - return _CreateTypeFromCursorResult(typealias); - } else { - // Use underlying type if typealias couldn't be created or if the user - // excluded this typedef. - final ct = clang.clang_getTypedefDeclUnderlyingType(cursor); - return _CreateTypeFromCursorResult( - getCodeGenType(ct, pointerReference: pointerReference), - addToCache: false); - } - case clang_types.CXTypeKind.CXType_Record: - return _CreateTypeFromCursorResult( - _extractfromRecord(cxtype, cursor, ignoreFilter, pointerReference)); - case clang_types.CXTypeKind.CXType_Enum: - final enumClass = parseEnumDeclaration( - cursor, - ignoreFilter: ignoreFilter, - ); - if (enumClass == null) { - // Handle anonymous enum declarations within another declaration. - return _CreateTypeFromCursorResult(EnumClass.nativeType, - addToCache: false); - } else { - return _CreateTypeFromCursorResult(enumClass); - } - case clang_types.CXTypeKind.CXType_ObjCInterface: - return _CreateTypeFromCursorResult( - parseObjCInterfaceDeclaration(cursor, ignoreFilter: ignoreFilter)); - default: - throw UnimplementedError('Unknown type: ${cxtype.completeStringRepr()}'); - } -} - -void _fillFromCursorIfNeeded(Type? type, clang_types.CXCursor cursor, - bool ignoreFilter, bool pointerReference) { - if (type == null) return; - if (type is Compound) { - fillCompoundMembersIfNeeded(type, cursor, - ignoreFilter: ignoreFilter, pointerReference: pointerReference); - } else if (type is ObjCInterface) { - fillObjCInterfaceMethodsIfNeeded(type, cursor); - } -} - -Type? _extractfromRecord(clang_types.CXType cxtype, clang_types.CXCursor cursor, - bool ignoreFilter, bool pointerReference) { - _logger.fine('${_padding}_extractfromRecord: ${cursor.completeStringRepr()}'); - - final cursorKind = clang.clang_getCursorKind(cursor); - if (cursorKind == clang_types.CXCursorKind.CXCursor_StructDecl || - cursorKind == clang_types.CXCursorKind.CXCursor_UnionDecl) { - final declSpelling = cursor.spelling(); - - // Set includer functions according to compoundType. - final CompoundType compoundType; - final Map compoundTypeMappings; - - switch (cursorKind) { - case clang_types.CXCursorKind.CXCursor_StructDecl: - compoundType = CompoundType.struct; - compoundTypeMappings = config.structTypeMappings; - break; - case clang_types.CXCursorKind.CXCursor_UnionDecl: - compoundType = CompoundType.union; - compoundTypeMappings = config.unionTypeMappings; - break; - default: - throw Exception('Unhandled compound type cursorkind.'); - } - - // Also add a struct binding, if its unseen. - // TODO(23): Check if we should auto add compound declarations. - if (compoundTypeMappings.containsKey(declSpelling)) { - _logger.fine(' Type Mapped from type-map'); - return compoundTypeMappings[declSpelling]!; - } else { - final struct = parseCompoundDeclaration( - cursor, - compoundType, - ignoreFilter: ignoreFilter, - pointerReference: pointerReference, - ); - return struct; - } - } - _logger.fine('typedeclarationCursorVisitor: _extractfromRecord: ' - 'Not Implemented, ${cursor.completeStringRepr()}'); - return UnimplementedType('${cxtype.kindSpelling()} not implemented'); -} - -// Used for function pointer arguments. -Type _extractFromFunctionProto(clang_types.CXType cxtype) { - final _parameters = []; - final totalArgs = clang.clang_getNumArgTypes(cxtype); - for (var i = 0; i < totalArgs; i++) { - final t = clang.clang_getArgType(cxtype, i); - final pt = t.toCodeGenType(); - - if (pt.isIncompleteCompound) { - return UnimplementedType( - 'Incomplete Struct by value in function parameter.'); - } else if (pt.baseType is UnimplementedType) { - return UnimplementedType('Function parameter has an unsupported type.'); - } - - _parameters.add( - Parameter(name: '', type: pt), - ); - } - - return NativeFunc(FunctionType( - parameters: _parameters, - returnType: clang.clang_getResultType(cxtype).toCodeGenType(), - )); -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/utils.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/utils.dart deleted file mode 100644 index 7352642cf..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/header_parser/utils.dart +++ /dev/null @@ -1,395 +0,0 @@ -// Copyright (c) 2020, 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:ffi'; - -import 'package:ffi/ffi.dart'; -import 'package:ffigen/src/code_generator.dart'; -import 'package:ffigen/src/config_provider/config_types.dart'; -import 'package:logging/logging.dart'; - -import 'clang_bindings/clang_bindings.dart' as clang_types; -import 'data.dart'; -import 'type_extractor/extractor.dart'; - -const exceptional_visitor_return = - clang_types.CXChildVisitResult.CXChildVisit_Break; - -/// Check [resultCode] of [clang.clang_visitChildren_wrap]. -/// -/// Throws exception if resultCode is not [exceptional_visitor_return]. -void visitChildrenResultChecker(int resultCode) { - if (resultCode != exceptional_visitor_return) { - throw Exception( - 'Exception thrown in a dart function called via C, use --verbose to see more details'); - } -} - -/// Logs the warnings/errors returned by clang for a translation unit. -void logTuDiagnostics( - Pointer tu, - Logger logger, - String header, -) { - final total = clang.clang_getNumDiagnostics(tu); - if (total == 0) { - return; - } - - logger.severe('Header $header: Total errors/warnings: $total.'); - for (var i = 0; i < total; i++) { - final diag = clang.clang_getDiagnostic(tu, i); - final cxstring = clang.clang_formatDiagnostic( - diag, - clang_types - .CXDiagnosticDisplayOptions.CXDiagnostic_DisplaySourceLocation | - clang_types.CXDiagnosticDisplayOptions.CXDiagnostic_DisplayColumn | - clang_types - .CXDiagnosticDisplayOptions.CXDiagnostic_DisplayCategoryName, - ); - logger.severe(' ' + cxstring.toStringAndDispose()); - clang.clang_disposeDiagnostic(diag); - } -} - -extension CXSourceRangeExt on Pointer { - void dispose() { - calloc.free(this); - } -} - -extension CXCursorExt on clang_types.CXCursor { - String usr() { - return clang.clang_getCursorUSR(this).toStringAndDispose(); - } - - /// Returns the kind int from [clang_types.CXCursorKind]. - int kind() { - return clang.clang_getCursorKind(this); - } - - /// Name of the cursor (E.g function name, Struct name, Parameter name). - String spelling() { - return clang.clang_getCursorSpelling(this).toStringAndDispose(); - } - - /// Spelling for a [clang_types.CXCursorKind], useful for debug purposes. - String kindSpelling() { - return clang - .clang_getCursorKindSpelling(clang.clang_getCursorKind(this)) - .toStringAndDispose(); - } - - /// for debug: returns [spelling] [kind] [kindSpelling] [type] [typeSpelling]. - String completeStringRepr() { - final cxtype = type(); - final s = - '(Cursor) spelling: ${spelling()}, kind: ${kind()}, kindSpelling: ${kindSpelling()}, type: ${cxtype.kind}, typeSpelling: ${cxtype.spelling()}, usr: ${usr()}'; - return s; - } - - /// Type associated with the pointer if any. Type will have kind - /// [clang.CXTypeKind.CXType_Invalid] otherwise. - clang_types.CXType type() { - return clang.clang_getCursorType(this); - } - - /// Only valid for [clang.CXCursorKind.CXCursor_FunctionDecl]. Type will have - /// kind [clang.CXTypeKind.CXType_Invalid] otherwise. - clang_types.CXType returnType() { - return clang.clang_getResultType(type()); - } - - /// Returns the file name of the file that the cursor is inside. - String sourceFileName() { - final cxsource = clang.clang_getCursorLocation(this); - final cxfilePtr = calloc>(); - - // Puts the values in these pointers. - clang.clang_getFileLocation(cxsource, cxfilePtr, nullptr, nullptr, nullptr); - final s = clang.clang_getFileName(cxfilePtr.value).toStringAndDispose(); - - calloc.free(cxfilePtr); - return s; - } - - /// Returns whether the file that the cursor is inside is a system header. - bool isInSystemHeader() { - final location = clang.clang_getCursorLocation(this); - return clang.clang_Location_isInSystemHeader(location) != 0; - } - - /// Recursively print the AST, for debugging. - void printAst([int maxDepth = 3]) { - _printAstVisitorMaxDepth = maxDepth; - _printAstVisitor(this, this, Pointer.fromAddress(0)); - } -} - -int _printAstVisitorMaxDepth = 0; -int _printAstVisitor(clang_types.CXCursor cursor, clang_types.CXCursor parent, - Pointer clientData) { - final depth = clientData.address; - if (depth > _printAstVisitorMaxDepth) { - return clang_types.CXChildVisitResult.CXChildVisit_Break; - } - print((' ' * depth) + cursor.completeStringRepr()); - clang.clang_visitChildren( - cursor, - Pointer.fromFunction(_printAstVisitor, exceptional_visitor_return), - Pointer.fromAddress(depth + 1)); - return clang_types.CXChildVisitResult.CXChildVisit_Continue; -} - -const commentPrefix = '/// '; -const nesting = ' '; - -/// Stores the [clang_types.CXSourceRange] of the last comment. -clang_types.CXSourceRange? lastCommentRange; - -/// Returns a cursor's associated comment. -/// -/// The given string is wrapped at line width = 80 - [indent]. The [indent] is -/// [commentPrefix.dimensions] by default because a comment starts with -/// [commentPrefix]. -String? getCursorDocComment(clang_types.CXCursor cursor, - [int indent = commentPrefix.length]) { - String? formattedDocComment; - final currentCommentRange = clang.clang_Cursor_getCommentRange(cursor); - - // See if this comment and the last comment both point to the same source - // range. - if (lastCommentRange != null && - clang.clang_equalRanges(lastCommentRange!, currentCommentRange) != 0) { - formattedDocComment = null; - } else { - switch (config.commentType.length) { - case CommentLength.full: - formattedDocComment = removeRawCommentMarkups( - clang.clang_Cursor_getRawCommentText(cursor).toStringAndDispose()); - break; - case CommentLength.brief: - formattedDocComment = _wrapNoNewLineString( - clang.clang_Cursor_getBriefCommentText(cursor).toStringAndDispose(), - 80 - indent); - break; - default: - formattedDocComment = null; - } - } - lastCommentRange = currentCommentRange; - return formattedDocComment; -} - -/// Wraps [string] according to given [lineWidth]. -/// -/// Wrapping will work properly only when String has no new lines -/// characters(\n). -String? _wrapNoNewLineString(String? string, int lineWidth) { - if (string == null || string.isEmpty) { - return null; - } - final sb = StringBuffer(); - - final words = string.split(' '); - - sb.write(words[0]); - var trackLineWidth = words[0].length; - for (var i = 1; i < words.length; i++) { - final word = words[i]; - if (trackLineWidth + word.length < lineWidth) { - sb.write(' '); - sb.write(word); - trackLineWidth += word.length + 1; - } else { - sb.write('\n'); - sb.write(word); - trackLineWidth = word.length; - } - } - return sb.toString(); -} - -/// Removes /*, */ and any *'s in the beginning of a line. -String? removeRawCommentMarkups(String? string) { - if (string == null || string.isEmpty) { - return null; - } - final sb = StringBuffer(); - - // Remove comment identifiers (`/** * */`, `///`, `//`) from lines. - if (string.contains(RegExp(r'^\s*\/\*+'))) { - string = string.replaceFirst(RegExp(r'^\s*\/\*+\s*'), ''); - string = string.replaceFirst(RegExp(r'\s*\*+\/$'), ''); - string.split('\n').forEach((element) { - element = element.replaceFirst(RegExp(r'^\s*\**\s*'), ''); - sb.writeln(element); - }); - } else if (string.contains(RegExp(r'^\s*\/\/\/?\s*'))) { - string.split('\n').forEach((element) { - element = element.replaceFirst(RegExp(r'^\s*\/\/\/?\s*'), ''); - sb.writeln(element); - }); - } - - return sb.toString().trim(); -} - -bool isForwardDeclaration(clang_types.CXCursor cursor) { - return clang.clang_Cursor_isNull(clang.clang_getCursorDefinition(cursor)) == - 0; -} - -extension CXTypeExt on clang_types.CXType { - /// Get code_gen [Type] representation of [clang_types.CXType]. - Type toCodeGenType() { - return getCodeGenType(this); - } - - /// Spelling for a [clang_types.CXTypeKind], useful for debug purposes. - String spelling() { - return clang.clang_getTypeSpelling(this).toStringAndDispose(); - } - - /// Returns the typeKind int from [clang_types.CXTypeKind]. - int kind() { - return this.kind; - } - - String kindSpelling() { - return clang.clang_getTypeKindSpelling(kind()).toStringAndDispose(); - } - - int alignment() { - return clang.clang_Type_getAlignOf(this); - } - - /// For debugging: returns [spelling] [kind] [kindSpelling]. - String completeStringRepr() { - final s = - '(Type) spelling: ${spelling()}, kind: ${kind()}, kindSpelling: ${kindSpelling()}'; - return s; - } -} - -extension CXStringExt on clang_types.CXString { - /// Convert CXString to a Dart string - /// - /// Make sure to dispose CXstring using dispose method, or use the - /// [toStringAndDispose] method. - String string() { - final cstring = clang.clang_getCString(this); - if (cstring != nullptr) { - return cstring.cast().toDartString(); - } else { - return ''; - } - } - - /// Converts CXString to dart string and disposes CXString. - String toStringAndDispose() { - // Note: clang_getCString_wrap returns a const char *, calling free will result in error. - final s = string(); - clang.clang_disposeString(this); - return s; - } - - void dispose() { - clang.clang_disposeString(this); - } -} - -/// Converts a [List] to [Pointer>]. -Pointer> createDynamicStringArray(List list) { - final nativeCmdArgs = calloc>(list.length); - - for (var i = 0; i < list.length; i++) { - nativeCmdArgs[i] = list[i].toNativeUtf8(); - } - - return nativeCmdArgs; -} - -extension DynamicCStringArray on Pointer> { - // Properly disposes a Pointer, ensure that sure length is correct. - void dispose(int length) { - for (var i = 0; i < length; i++) { - calloc.free(this[i]); - } - calloc.free(this); - } -} - -class Stack { - final _stack = []; - - T get top => _stack.last; - T pop() => _stack.removeLast(); - void push(T item) => _stack.add(item); -} - -class IncrementalNamer { - final _incrementedStringCounters = {}; - - /// Appends `` to base. is incremented on every call. - String name(String base) { - var i = _incrementedStringCounters[base] ?? 0; - i++; - _incrementedStringCounters[base] = i; - return '$base$i'; - } -} - -class Macro { - final String usr; - final String? originalName; - - Macro(this.usr, this.originalName); -} - -/// Tracks if a binding is 'seen' or not. -class BindingsIndex { - // Tracks if bindings are already seen, Map key is USR obtained from libclang. - final Map _declaredTypes = {}; - final Map _functions = {}; - final Map _unnamedEnumConstants = {}; - final Map _macros = {}; - final Map _globals = {}; - final Map _objcBlocks = {}; - - /// Contains usr for typedefs which cannot be generated. - final Set _unsupportedTypealiases = {}; - - /// Index for headers. - final Map _headerCache = {}; - - bool isSeenType(String usr) => _declaredTypes.containsKey(usr); - void addTypeToSeen(String usr, Type type) => _declaredTypes[usr] = type; - Type? getSeenType(String usr) => _declaredTypes[usr]; - bool isSeenFunc(String usr) => _functions.containsKey(usr); - void addFuncToSeen(String usr, Func func) => _functions[usr] = func; - Func? getSeenFunc(String usr) => _functions[usr]; - bool isSeenUnnamedEnumConstant(String usr) => - _unnamedEnumConstants.containsKey(usr); - void addUnnamedEnumConstantToSeen(String usr, Constant enumConstant) => - _unnamedEnumConstants[usr] = enumConstant; - Constant? getSeenUnnamedEnumConstant(String usr) => - _unnamedEnumConstants[usr]; - bool isSeenGlobalVar(String usr) => _globals.containsKey(usr); - void addGlobalVarToSeen(String usr, Global global) => _globals[usr] = global; - Global? getSeenGlobalVar(String usr) => _globals[usr]; - bool isSeenMacro(String usr) => _macros.containsKey(usr); - void addMacroToSeen(String usr, String macro) => _macros[usr] = macro; - String? getSeenMacro(String usr) => _macros[usr]; - bool isSeenUnsupportedTypealias(String usr) => - _unsupportedTypealiases.contains(usr); - void addUnsupportedTypealiasToSeen(String usr) => - _unsupportedTypealiases.add(usr); - bool isSeenHeader(String source) => _headerCache.containsKey(source); - void addHeaderToSeen(String source, bool includeStatus) => - _headerCache[source] = includeStatus; - bool? getSeenHeaderStatus(String source) => _headerCache[source]; - void addObjCBlockToSeen(String key, ObjCBlock t) => _objcBlocks[key] = t; - ObjCBlock? getSeenObjCBlock(String key) => _objcBlocks[key]; -} diff --git a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/strings.dart b/pkgs/jni/third_party/ffigen_patch_jni/lib/src/strings.dart deleted file mode 100644 index aa2c2d800..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/lib/src/strings.dart +++ /dev/null @@ -1,223 +0,0 @@ -// Copyright (c) 2020, 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:ffigen/src/code_generator.dart'; -import 'package:ffigen/src/header_parser/clang_bindings/clang_bindings.dart' - as clang; - -/// Name of the dynamic library file according to current platform. -String get dylibFileName { - String name; - if (Platform.isLinux) { - name = libclang_dylib_linux; - } else if (Platform.isMacOS) { - name = libclang_dylib_macos; - } else if (Platform.isWindows) { - name = libclang_dylib_windows; - } else { - throw Exception('Unsupported Platform.'); - } - return name; -} - -const llvmPath = 'llvm-path'; - -/// Name of the parent folder of dynamic library `lib` or `bin` (on windows). -String get dynamicLibParentName => Platform.isWindows ? 'bin' : 'lib'; - -const output = 'output'; - -const language = 'language'; - -// String mappings for the Language enum. -const langC = 'c'; -const langObjC = 'objc'; - -// Clang command line args for Objective C. -const clangLangObjC = ['-x', 'objective-c']; -const clangObjCBoolDefine = '__OBJC_BOOL_IS_BOOL'; -const clangInclude = '-include'; -const objcBOOL = 'BOOL'; - -// Internal objective C directories that are automatically pulled in by clang, -// and should be excluded from output (unless explicitly used). -const objCInternalDirectories = [ - '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include', - '/Applications/Xcode.app/Contents/Developer', - '/usr/local/opt/llvm/lib', -]; - -const headers = 'headers'; - -// Sub-fields of headers -const entryPoints = 'entry-points'; -const includeDirectives = 'include-directives'; - -const compilerOpts = 'compiler-opts'; - -const compilerOptsAuto = 'compiler-opts-automatic'; -// Sub-fields of compilerOptsAuto. -const macos = 'macos'; -// Sub-fields of macos. -const includeCStdLib = 'include-c-standard-library'; - -// Declarations. -const functions = 'functions'; -const structs = 'structs'; -const unions = 'unions'; -const enums = 'enums'; -const unnamedEnums = 'unnamed-enums'; -const globals = 'globals'; -const macros = 'macros'; -const typedefs = 'typedefs'; -const objcInterfaces = 'objc-interfaces'; - -// Sub-fields of Declarations. -const include = 'include'; -const exclude = 'exclude'; -const rename = 'rename'; -const memberRename = 'member-rename'; -const symbolAddress = 'symbol-address'; - -// Nested under `functions` -const exposeFunctionTypedefs = 'expose-typedefs'; -const leafFunctions = 'leaf'; - -const dependencyOnly = 'dependency-only'; -// Values for `compoundDependencies`. -const fullCompoundDependencies = 'full'; -const opaqueCompoundDependencies = 'opaque'; - -const structPack = 'pack'; -const Map packingValuesMap = { - 'none': null, - 1: 1, - 2: 2, - 4: 4, - 8: 8, - 16: 16, -}; - -// Sizemap values. -const SChar = 'char'; -const UChar = 'unsigned char'; -const Short = 'short'; -const UShort = 'unsigned short'; -const Int = 'int'; -const UInt = 'unsigned int'; -const Long = 'long'; -const ULong = 'unsigned long'; -const LongLong = 'long long'; -const ULongLong = 'unsigned long long'; -const Enum = 'enum'; - -// Used for validation and extraction of sizemap. -const sizemap_native_mapping = { - SChar: clang.CXTypeKind.CXType_SChar, - UChar: clang.CXTypeKind.CXType_UChar, - Short: clang.CXTypeKind.CXType_Short, - UShort: clang.CXTypeKind.CXType_UShort, - Int: clang.CXTypeKind.CXType_Int, - UInt: clang.CXTypeKind.CXType_UInt, - Long: clang.CXTypeKind.CXType_Long, - ULong: clang.CXTypeKind.CXType_ULong, - LongLong: clang.CXTypeKind.CXType_LongLong, - ULongLong: clang.CXTypeKind.CXType_ULongLong, - Enum: clang.CXTypeKind.CXType_Enum -}; - -// Library imports. -const libraryImports = 'library-imports'; - -final predefinedLibraryImports = { - ffiImport.name: ffiImport, - ffiPkgImport.name: ffiPkgImport -}; - -const typeMap = 'type-map'; - -// Sub-fields for type-map. -const typeMapTypedefs = 'typedefs'; -const typeMapStructs = 'structs'; -const typeMapUnions = 'unions'; -const typeMapNativeTypes = 'native-types'; - -// Sub-sub-keys for fields under typeMap. -const lib = 'lib'; -const cType = 'c-type'; -const dartType = 'dart-type'; - -const supportedNativeType_mappings = { - 'Void': SupportedNativeType.Void, - 'Uint8': SupportedNativeType.Uint8, - 'Uint16': SupportedNativeType.Uint16, - 'Uint32': SupportedNativeType.Uint32, - 'Uint64': SupportedNativeType.Uint64, - 'Int8': SupportedNativeType.Int8, - 'Int16': SupportedNativeType.Int16, - 'Int32': SupportedNativeType.Int32, - 'Int64': SupportedNativeType.Int64, - 'IntPtr': SupportedNativeType.IntPtr, - 'Float': SupportedNativeType.Float, - 'Double': SupportedNativeType.Double, -}; - -// Boolean flags. -const sort = 'sort'; -const useSupportedTypedefs = 'use-supported-typedefs'; -const useDartHandle = 'use-dart-handle'; - -const comments = 'comments'; -// Sub-fields of comments. -const style = 'style'; -const length = 'length'; - -// Sub-fields of style. -const doxygen = 'doxygen'; -const any = 'any'; -// Sub-fields of length. -const brief = 'brief'; -const full = 'full'; -// Cmd line comment option. -const fparseAllComments = '-fparse-all-comments'; - -// Library input. -const name = 'name'; -const description = 'description'; -const preamble = 'preamble'; - -// Dynamic library names. -const libclang_dylib_linux = 'libclang.so'; -const libclang_dylib_macos = 'libclang.dylib'; -const libclang_dylib_windows = 'libclang.dll'; - -// Dynamic library default locations. -const linuxDylibLocations = { - '/usr/lib/llvm-9/lib/', - '/usr/lib/llvm-10/lib/', - '/usr/lib/llvm-11/lib/', - '/usr/lib/llvm-12/lib/', - '/usr/lib/llvm-13/lib/', - '/usr/lib/llvm-14/lib/', - '/usr/lib/llvm-15/lib/', - '/usr/lib/', - '/usr/lib64/', -}; -const windowsDylibLocations = { - r'C:\Program Files\LLVM\bin\', -}; -const macOsDylibLocations = { - '/usr/local/opt/llvm/lib/', - '/opt/homebrew/opt/llvm/lib/', - '/Library/Developer/CommandLineTools/usr/', -}; - -// Writen doubles. -const doubleInfinity = 'double.infinity'; -const doubleNegativeInfinity = 'double.negativeInfinity'; -const doubleNaN = 'double.nan'; - -/// USR for struct `_Dart_Handle`. -const dartHandleUsr = 'c:@S@_Dart_Handle'; diff --git a/pkgs/jni/third_party/ffigen_patch_jni/pubspec.yaml b/pkgs/jni/third_party/ffigen_patch_jni/pubspec.yaml deleted file mode 100644 index 237c0fda3..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/pubspec.yaml +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (c) 2020, 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. - -name: ffigen -version: 6.0.1 -description: Generator for FFI bindings, using LibClang to parse C header files. -repository: https://github.com/dart-lang/ffigen - -environment: - sdk: '>=2.17.0 <4.0.0' - -dependencies: - ffi: ^2.0.0 - yaml: ^3.0.0 - path: ^1.8.0 - quiver: ^3.0.0 - args: ^2.0.0 - logging: ^1.0.0 - cli_util: ^0.3.0 - glob: ^2.0.0 - file: ^6.0.0 - -dev_dependencies: - lints: ^1.0.1 - test: ^1.16.2 diff --git a/pkgs/jni/third_party/ffigen_patch_jni/tool/coverage.sh b/pkgs/jni/third_party/ffigen_patch_jni/tool/coverage.sh deleted file mode 100755 index 02c8e2f47..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/tool/coverage.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -# Copyright (c) 2020, 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. - -# Fast fail the script on failures. -set -e - -# Gather coverage. -dart pub global activate coverage -# Generate coverage report. -dart run --pause-isolates-on-exit --disable-service-auth-codes --enable-vm-service=3000 test & -dart pub global run coverage:collect_coverage --wait-paused --uri=http://127.0.0.1:3000/ -o coverage.json --resume-isolates --scope-output=ffigen -dart pub global run coverage:format_coverage --packages=.dart_tool/package_config.json --lcov -i coverage.json -o lcov.info diff --git a/pkgs/jni/third_party/ffigen_patch_jni/tool/libclang_config.yaml b/pkgs/jni/third_party/ffigen_patch_jni/tool/libclang_config.yaml deleted file mode 100644 index ad0bfd048..000000000 --- a/pkgs/jni/third_party/ffigen_patch_jni/tool/libclang_config.yaml +++ /dev/null @@ -1,119 +0,0 @@ -# Copyright (c) 2020, 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. - -# Config file for generating the libclang bindings used by this package. - -# ===================== GENERATING BINDINGS ===================== -# cd to project's root, and run - -# dart run ffigen --config tool/libclang_config.yaml -# =============================================================== - -name: Clang -description: Holds bindings to LibClang. -output: 'lib/src/header_parser/clang_bindings/clang_bindings.dart' -compiler-opts: - - '-Ithird_party/libclang/include' - - '-Wno-nullability-completeness' -headers: - entry-points: - - 'third_party/libclang/include/clang-c/Index.h' - include-directives: - - '**wrapper.c' - - '**Index.h' - - '**CXString.h' - -preamble: | - // Part of the LLVM Project, under the Apache License v2.0 with LLVM - // Exceptions. - // See https://llvm.org/LICENSE.txt for license information. - // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - - // ignore_for_file: camel_case_types, non_constant_identifier_names - -enums: - include: - - CXChildVisitResult - - CXCursorKind - - CXTypeKind - - CXDiagnosticDisplayOptions - - CXTranslationUnit_Flags - - CXEvalResultKind - - CXObjCPropertyAttrKind - - CXTypeNullabilityKind - -structs: - include: - - CXCursor - - CXType - - CXSourceLocation - - CXString - - CXTranslationUnitImpl - - CXUnsavedFile - - CXSourceRange - -functions: - include: - - clang_createIndex - - clang_disposeIndex - - clang_getNumDiagnostics - - clang_getDiagnostic - - clang_disposeDiagnostic - - clang_parseTranslationUnit - - clang_disposeTranslationUnit - - clang_EvalResult_getKind - - clang_EvalResult_getAsInt - - clang_EvalResult_getAsLongLong - - clang_EvalResult_getAsDouble - - clang_EvalResult_getAsStr - - clang_EvalResult_dispose - - clang_getCString - - clang_disposeString - - clang_getCursorKind - - clang_getCursorKindSpelling - - clang_getCursorType - - clang_getTypeSpelling - - clang_getTypeKindSpelling - - clang_getResultType - - clang_getTypedefName - - clang_getPointeeType - - clang_getCanonicalType - - clang_Type_getNamedType - - clang_Type_getAlignOf - - clang_getTypeDeclaration - - clang_getTypedefDeclUnderlyingType - - clang_getCursorSpelling - - clang_getTranslationUnitCursor - - clang_formatDiagnostic - - clang_visitChildren - - clang_Cursor_getNumArguments - - clang_Cursor_getArgument - - clang_getNumArgTypes - - clang_getArgType - - clang_getEnumConstantDeclValue - - clang_equalRanges - - clang_Cursor_getCommentRange - - clang_Cursor_getRawCommentText - - clang_Cursor_getBriefCommentText - - clang_getCursorLocation - - clang_getFileLocation - - clang_getFileName - - clang_getNumElements - - clang_getArrayElementType - - clang_Cursor_isMacroFunctionLike - - clang_Cursor_isMacroBuiltin - - clang_Cursor_Evaluate - - clang_Cursor_isAnonymous - - clang_Cursor_isAnonymousRecordDecl - - clang_getCursorUSR - - clang_getFieldDeclBitWidth - - clang_Cursor_isFunctionInlined - - clang_getCursorDefinition - - clang_Cursor_isNull - - clang_Cursor_hasAttrs - - clang_Type_getObjCObjectBaseType - - clang_Cursor_getObjCPropertyAttributes - - clang_Cursor_getObjCPropertyGetterName - - clang_Cursor_getObjCPropertySetterName - - clang_Type_getNullability - - clang_Location_isInSystemHeader diff --git a/pkgs/jni/third_party/jni.h b/pkgs/jni/third_party/jni.h index 961dd093c..b71105eaf 100644 --- a/pkgs/jni/third_party/jni.h +++ b/pkgs/jni/third_party/jni.h @@ -29,458 +29,489 @@ #include /* Primitive types that match up with Java equivalents. */ -typedef uint8_t jboolean; /* unsigned 8 bits */ -typedef int8_t jbyte; /* signed 8 bits */ -typedef uint16_t jchar; /* unsigned 16 bits */ -typedef int16_t jshort; /* signed 16 bits */ -typedef int32_t jint; /* signed 32 bits */ -typedef int64_t jlong; /* signed 64 bits */ -typedef float jfloat; /* 32-bit IEEE 754 */ -typedef double jdouble; /* 64-bit IEEE 754 */ +typedef uint8_t jboolean; /* unsigned 8 bits */ +typedef int8_t jbyte; /* signed 8 bits */ +typedef uint16_t jchar; /* unsigned 16 bits */ +typedef int16_t jshort; /* signed 16 bits */ +typedef int32_t jint; /* signed 32 bits */ +typedef int64_t jlong; /* signed 64 bits */ +typedef float jfloat; /* 32-bit IEEE 754 */ +typedef double jdouble; /* 64-bit IEEE 754 */ /* "cardinal indices and sizes" */ -typedef jint jsize; +typedef jint jsize; #ifdef __cplusplus /* * Reference types, in C++ */ -class _jobject {}; -class _jclass : public _jobject {}; -class _jstring : public _jobject {}; -class _jarray : public _jobject {}; -class _jobjectArray : public _jarray {}; -class _jbooleanArray : public _jarray {}; -class _jbyteArray : public _jarray {}; -class _jcharArray : public _jarray {}; -class _jshortArray : public _jarray {}; -class _jintArray : public _jarray {}; -class _jlongArray : public _jarray {}; -class _jfloatArray : public _jarray {}; -class _jdoubleArray : public _jarray {}; -class _jthrowable : public _jobject {}; - -typedef _jobject* jobject; -typedef _jclass* jclass; -typedef _jstring* jstring; -typedef _jarray* jarray; -typedef _jobjectArray* jobjectArray; -typedef _jbooleanArray* jbooleanArray; -typedef _jbyteArray* jbyteArray; -typedef _jcharArray* jcharArray; -typedef _jshortArray* jshortArray; -typedef _jintArray* jintArray; -typedef _jlongArray* jlongArray; -typedef _jfloatArray* jfloatArray; -typedef _jdoubleArray* jdoubleArray; -typedef _jthrowable* jthrowable; -typedef _jobject* jweak; +class _jobject +{ +}; +class _jclass : public _jobject +{ +}; +class _jstring : public _jobject +{ +}; +class _jarray : public _jobject +{ +}; +class _jobjectArray : public _jarray +{ +}; +class _jbooleanArray : public _jarray +{ +}; +class _jbyteArray : public _jarray +{ +}; +class _jcharArray : public _jarray +{ +}; +class _jshortArray : public _jarray +{ +}; +class _jintArray : public _jarray +{ +}; +class _jlongArray : public _jarray +{ +}; +class _jfloatArray : public _jarray +{ +}; +class _jdoubleArray : public _jarray +{ +}; +class _jthrowable : public _jobject +{ +}; +typedef _jobject *jobject; +typedef _jclass *jclass; +typedef _jstring *jstring; +typedef _jarray *jarray; +typedef _jobjectArray *jobjectArray; +typedef _jbooleanArray *jbooleanArray; +typedef _jbyteArray *jbyteArray; +typedef _jcharArray *jcharArray; +typedef _jshortArray *jshortArray; +typedef _jintArray *jintArray; +typedef _jlongArray *jlongArray; +typedef _jfloatArray *jfloatArray; +typedef _jdoubleArray *jdoubleArray; +typedef _jthrowable *jthrowable; +typedef _jobject *jweak; #else /* not __cplusplus */ /* * Reference types, in C. */ -typedef void* jobject; -typedef jobject jclass; -typedef jobject jstring; -typedef jobject jarray; -typedef jarray jobjectArray; -typedef jarray jbooleanArray; -typedef jarray jbyteArray; -typedef jarray jcharArray; -typedef jarray jshortArray; -typedef jarray jintArray; -typedef jarray jlongArray; -typedef jarray jfloatArray; -typedef jarray jdoubleArray; -typedef jobject jthrowable; -typedef jobject jweak; +typedef void *jobject; +typedef jobject jclass; +typedef jobject jstring; +typedef jobject jarray; +typedef jarray jobjectArray; +typedef jarray jbooleanArray; +typedef jarray jbyteArray; +typedef jarray jcharArray; +typedef jarray jshortArray; +typedef jarray jintArray; +typedef jarray jlongArray; +typedef jarray jfloatArray; +typedef jarray jdoubleArray; +typedef jobject jthrowable; +typedef jobject jweak; #endif /* not __cplusplus */ -struct _jfieldID; /* opaque structure */ -typedef struct _jfieldID* jfieldID; /* field IDs */ +struct _jfieldID; /* opaque structure */ +typedef struct _jfieldID *jfieldID; /* field IDs */ -struct _jmethodID; /* opaque structure */ -typedef struct _jmethodID* jmethodID; /* method IDs */ +struct _jmethodID; /* opaque structure */ +typedef struct _jmethodID *jmethodID; /* method IDs */ struct JNIInvokeInterface; -typedef union jvalue { - jboolean z; - jbyte b; - jchar c; - jshort s; - jint i; - jlong j; - jfloat f; - jdouble d; - jobject l; +typedef union jvalue +{ + jboolean z; + jbyte b; + jchar c; + jshort s; + jint i; + jlong j; + jfloat f; + jdouble d; + jobject l; } jvalue; -typedef enum jobjectRefType { +typedef enum jobjectRefType +{ JNIInvalidRefType = 0, JNILocalRefType = 1, JNIGlobalRefType = 2, JNIWeakGlobalRefType = 3 } jobjectRefType; -typedef struct { - const char* name; - const char* signature; - void* fnPtr; +typedef struct +{ + const char *name; + const char *signature; + void *fnPtr; } JNINativeMethod; struct _JNIEnv; struct _JavaVM; -typedef const struct JNINativeInterface* C_JNIEnv; +typedef const struct JNINativeInterface *C_JNIEnv; #if defined(__cplusplus) typedef _JNIEnv JNIEnv; typedef _JavaVM JavaVM; #else -typedef const struct JNINativeInterface* JNIEnv; -typedef const struct JNIInvokeInterface* JavaVM; +typedef const struct JNINativeInterface *JNIEnv; +typedef const struct JNIInvokeInterface *JavaVM; #endif /* * Table of interface function pointers. */ -struct JNINativeInterface { - void* reserved0; - void* reserved1; - void* reserved2; - void* reserved3; +struct JNINativeInterface +{ + void *reserved0; + void *reserved1; + void *reserved2; + void *reserved3; - jint (*GetVersion)(JNIEnv *env); - jclass (*DefineClass)(JNIEnv *env, const char* name, jobject loader, const jbyte* buf, - jsize bufLen); - jclass (*FindClass)(JNIEnv* env, const char* name); + jint (*GetVersion)(JNIEnv *env); + jclass (*DefineClass)(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, + jsize bufLen); + jclass (*FindClass)(JNIEnv *env, const char *name); - jmethodID (*FromReflectedMethod)(JNIEnv* env, jobject method); - jfieldID (*FromReflectedField)(JNIEnv* env, jobject field); + jmethodID (*FromReflectedMethod)(JNIEnv *env, jobject method); + jfieldID (*FromReflectedField)(JNIEnv *env, jobject field); /* spec doesn't show jboolean parameter */ - jobject (*ToReflectedMethod)(JNIEnv* env, jclass cls, jmethodID methodId, jboolean isStatic); + jobject (*ToReflectedMethod)(JNIEnv *env, jclass cls, jmethodID methodId, jboolean isStatic); - jclass (*GetSuperclass)(JNIEnv* env, jclass clazz); - jboolean (*IsAssignableFrom)(JNIEnv* env, jclass clazz1, jclass clazz2); + jclass (*GetSuperclass)(JNIEnv *env, jclass clazz); + jboolean (*IsAssignableFrom)(JNIEnv *env, jclass clazz1, jclass clazz2); /* spec doesn't show jboolean parameter */ - jobject (*ToReflectedField)(JNIEnv* env, jclass cls, jfieldID fieldID, jboolean isStatic); - - jint (*Throw)(JNIEnv* env, jthrowable obj); - jint (*ThrowNew)(JNIEnv *env, jclass clazz, const char *message); - jthrowable (*ExceptionOccurred)(JNIEnv* env); - void (*ExceptionDescribe)(JNIEnv* env); - void (*ExceptionClear)(JNIEnv* env); - void (*FatalError)(JNIEnv* env, const char* msg); - - jint (*PushLocalFrame)(JNIEnv* env, jint capacity); - jobject (*PopLocalFrame)(JNIEnv* env, jobject result); - - jobject (*NewGlobalRef)(JNIEnv* env, jobject obj); - void (*DeleteGlobalRef)(JNIEnv* env, jobject globalRef); - void (*DeleteLocalRef)(JNIEnv* env, jobject localRef); - jboolean (*IsSameObject)(JNIEnv* env, jobject ref1, jobject ref2); - - jobject (*NewLocalRef)(JNIEnv* env, jobject ref); - jint (*EnsureLocalCapacity)(JNIEnv* env, jint capacity); - - jobject (*AllocObject)(JNIEnv* env, jclass clazz); - jobject (*NewObject)(JNIEnv*, jclass, jmethodID, ...); - jobject (*NewObjectV)(JNIEnv*, jclass, jmethodID, va_list); - jobject (*NewObjectA)(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args); - - jclass (*GetObjectClass)(JNIEnv* env, jobject obj); - jboolean (*IsInstanceOf)(JNIEnv* env, jobject obj, jclass clazz); - jmethodID (*GetMethodID)(JNIEnv* env, jclass clazz, const char* name, const char* sig); - - jobject (*CallObjectMethod)(JNIEnv*, jobject, jmethodID, ...); - jobject (*CallObjectMethodV)(JNIEnv*, jobject, jmethodID, va_list); - jobject (*CallObjectMethodA)(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args); - jboolean (*CallBooleanMethod)(JNIEnv*, jobject, jmethodID, ...); - jboolean (*CallBooleanMethodV)(JNIEnv*, jobject, jmethodID, va_list); - jboolean (*CallBooleanMethodA)(JNIEnv* env, jobject obj, jmethodID methodId, const jvalue* args); - jbyte (*CallByteMethod)(JNIEnv*, jobject, jmethodID, ...); - jbyte (*CallByteMethodV)(JNIEnv*, jobject, jmethodID, va_list); - jbyte (*CallByteMethodA)(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args); - jchar (*CallCharMethod)(JNIEnv*, jobject, jmethodID, ...); - jchar (*CallCharMethodV)(JNIEnv*, jobject, jmethodID, va_list); - jchar (*CallCharMethodA)(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args); - jshort (*CallShortMethod)(JNIEnv*, jobject, jmethodID, ...); - jshort (*CallShortMethodV)(JNIEnv*, jobject, jmethodID, va_list); - jshort (*CallShortMethodA)(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args); - jint (*CallIntMethod)(JNIEnv*, jobject, jmethodID, ...); - jint (*CallIntMethodV)(JNIEnv*, jobject, jmethodID, va_list); - jint (*CallIntMethodA)(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args); - jlong (*CallLongMethod)(JNIEnv*, jobject, jmethodID, ...); - jlong (*CallLongMethodV)(JNIEnv*, jobject, jmethodID, va_list); - jlong (*CallLongMethodA)(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args); - jfloat (*CallFloatMethod)(JNIEnv*, jobject, jmethodID, ...); - jfloat (*CallFloatMethodV)(JNIEnv*, jobject, jmethodID, va_list); - jfloat (*CallFloatMethodA)(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args); - jdouble (*CallDoubleMethod)(JNIEnv*, jobject, jmethodID, ...); - jdouble (*CallDoubleMethodV)(JNIEnv*, jobject, jmethodID, va_list); - jdouble (*CallDoubleMethodA)(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args); - void (*CallVoidMethod)(JNIEnv*, jobject, jmethodID, ...); - void (*CallVoidMethodV)(JNIEnv*, jobject, jmethodID, va_list); - void (*CallVoidMethodA)(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args); - - jobject (*CallNonvirtualObjectMethod)(JNIEnv*, jobject, jclass, - jmethodID, ...); - jobject (*CallNonvirtualObjectMethodV)(JNIEnv*, jobject, jclass, - jmethodID, va_list); - jobject (*CallNonvirtualObjectMethodA)(JNIEnv* env, jobject obj, jclass clazz, - jmethodID methodID, const jvalue* args); - jboolean (*CallNonvirtualBooleanMethod)(JNIEnv*, jobject, jclass, - jmethodID, ...); - jboolean (*CallNonvirtualBooleanMethodV)(JNIEnv*, jobject, jclass, - jmethodID, va_list); - jboolean (*CallNonvirtualBooleanMethodA)(JNIEnv* env, jobject obj, jclass clazz, - jmethodID methodID, const jvalue* args); - jbyte (*CallNonvirtualByteMethod)(JNIEnv*, jobject, jclass, - jmethodID, ...); - jbyte (*CallNonvirtualByteMethodV)(JNIEnv*, jobject, jclass, - jmethodID, va_list); - jbyte (*CallNonvirtualByteMethodA)(JNIEnv* env, jobject obj, jclass clazz, - jmethodID methodID, const jvalue* args); - jchar (*CallNonvirtualCharMethod)(JNIEnv*, jobject, jclass, - jmethodID, ...); - jchar (*CallNonvirtualCharMethodV)(JNIEnv*, jobject, jclass, - jmethodID, va_list); - jchar (*CallNonvirtualCharMethodA)(JNIEnv* env, jobject obj, jclass clazz, - jmethodID methodID, const jvalue* args); - jshort (*CallNonvirtualShortMethod)(JNIEnv*, jobject, jclass, - jmethodID, ...); - jshort (*CallNonvirtualShortMethodV)(JNIEnv*, jobject, jclass, - jmethodID, va_list); - jshort (*CallNonvirtualShortMethodA)(JNIEnv* env, jobject obj, jclass clazz, - jmethodID methodID, const jvalue* args); - jint (*CallNonvirtualIntMethod)(JNIEnv*, jobject, jclass, - jmethodID, ...); - jint (*CallNonvirtualIntMethodV)(JNIEnv*, jobject, jclass, - jmethodID, va_list); - jint (*CallNonvirtualIntMethodA)(JNIEnv* env, jobject obj, jclass clazz, - jmethodID methodID, const jvalue* args); - jlong (*CallNonvirtualLongMethod)(JNIEnv*, jobject, jclass, - jmethodID, ...); - jlong (*CallNonvirtualLongMethodV)(JNIEnv*, jobject, jclass, - jmethodID, va_list); - jlong (*CallNonvirtualLongMethodA)(JNIEnv* env, jobject obj, jclass clazz, - jmethodID methodID, const jvalue* args); - jfloat (*CallNonvirtualFloatMethod)(JNIEnv*, jobject, jclass, - jmethodID, ...); - jfloat (*CallNonvirtualFloatMethodV)(JNIEnv*, jobject, jclass, - jmethodID, va_list); - jfloat (*CallNonvirtualFloatMethodA)(JNIEnv* env, jobject obj, jclass clazz, - jmethodID methodID, const jvalue* args); - jdouble (*CallNonvirtualDoubleMethod)(JNIEnv*, jobject, jclass, - jmethodID, ...); - jdouble (*CallNonvirtualDoubleMethodV)(JNIEnv*, jobject, jclass, - jmethodID, va_list); - jdouble (*CallNonvirtualDoubleMethodA)(JNIEnv* env, jobject obj, jclass clazz, - jmethodID methodID, const jvalue* args); - void (*CallNonvirtualVoidMethod)(JNIEnv*, jobject, jclass, - jmethodID, ...); - void (*CallNonvirtualVoidMethodV)(JNIEnv*, jobject, jclass, - jmethodID, va_list); - void (*CallNonvirtualVoidMethodA)(JNIEnv* env, jobject obj, jclass clazz, - jmethodID methodID, const jvalue* args); - - jfieldID (*GetFieldID)(JNIEnv* env, jclass clazz, const char* name, const char* sig); - - jobject (*GetObjectField)(JNIEnv* env, jobject obj, jfieldID fieldID); - jboolean (*GetBooleanField)(JNIEnv* env, jobject obj, jfieldID fieldID); - jbyte (*GetByteField)(JNIEnv* env, jobject obj, jfieldID fieldID); - jchar (*GetCharField)(JNIEnv* env, jobject obj, jfieldID fieldID); - jshort (*GetShortField)(JNIEnv* env, jobject obj, jfieldID fieldID); - jint (*GetIntField)(JNIEnv* env, jobject obj, jfieldID fieldID); - jlong (*GetLongField)(JNIEnv* env, jobject obj, jfieldID fieldID); - jfloat (*GetFloatField)(JNIEnv* env, jobject obj, jfieldID fieldID); - jdouble (*GetDoubleField)(JNIEnv* env, jobject obj, jfieldID fieldID); - - void (*SetObjectField)(JNIEnv* env, jobject obj, jfieldID fieldID, jobject val); - void (*SetBooleanField)(JNIEnv* env, jobject obj, jfieldID fieldID, jboolean val); - void (*SetByteField)(JNIEnv* env, jobject obj, jfieldID fieldID, jbyte val); - void (*SetCharField)(JNIEnv* env, jobject obj, jfieldID fieldID, jchar val); - void (*SetShortField)(JNIEnv* env, jobject obj, jfieldID fieldID, jshort val); - void (*SetIntField)(JNIEnv* env, jobject obj, jfieldID fieldID, jint val); - void (*SetLongField)(JNIEnv* env, jobject obj, jfieldID fieldID, jlong val); - void (*SetFloatField)(JNIEnv* env, jobject obj, jfieldID fieldID, jfloat val); - void (*SetDoubleField)(JNIEnv* env, jobject obj, jfieldID fieldID, jdouble val); - - jmethodID (*GetStaticMethodID)(JNIEnv* env, jclass clazz, const char* name, const char* sig); - - jobject (*CallStaticObjectMethod)(JNIEnv*, jclass, jmethodID, ...); - jobject (*CallStaticObjectMethodV)(JNIEnv*, jclass, jmethodID, va_list); - jobject (*CallStaticObjectMethodA)(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args); - jboolean (*CallStaticBooleanMethod)(JNIEnv*, jclass, jmethodID, ...); - jboolean (*CallStaticBooleanMethodV)(JNIEnv*, jclass, jmethodID, - va_list); - jboolean (*CallStaticBooleanMethodA)(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args); - jbyte (*CallStaticByteMethod)(JNIEnv*, jclass, jmethodID, ...); - jbyte (*CallStaticByteMethodV)(JNIEnv*, jclass, jmethodID, va_list); - jbyte (*CallStaticByteMethodA)(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args); - jchar (*CallStaticCharMethod)(JNIEnv*, jclass, jmethodID, ...); - jchar (*CallStaticCharMethodV)(JNIEnv*, jclass, jmethodID, va_list); - jchar (*CallStaticCharMethodA)(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args); - jshort (*CallStaticShortMethod)(JNIEnv*, jclass, jmethodID, ...); - jshort (*CallStaticShortMethodV)(JNIEnv*, jclass, jmethodID, va_list); - jshort (*CallStaticShortMethodA)(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args); - jint (*CallStaticIntMethod)(JNIEnv*, jclass, jmethodID, ...); - jint (*CallStaticIntMethodV)(JNIEnv*, jclass, jmethodID, va_list); - jint (*CallStaticIntMethodA)(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args); - jlong (*CallStaticLongMethod)(JNIEnv*, jclass, jmethodID, ...); - jlong (*CallStaticLongMethodV)(JNIEnv*, jclass, jmethodID, va_list); - jlong (*CallStaticLongMethodA)(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args); - jfloat (*CallStaticFloatMethod)(JNIEnv*, jclass, jmethodID, ...); - jfloat (*CallStaticFloatMethodV)(JNIEnv*, jclass, jmethodID, va_list); - jfloat (*CallStaticFloatMethodA)(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args); - jdouble (*CallStaticDoubleMethod)(JNIEnv*, jclass, jmethodID, ...); - jdouble (*CallStaticDoubleMethodV)(JNIEnv*, jclass, jmethodID, va_list); - jdouble (*CallStaticDoubleMethodA)(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args); - void (*CallStaticVoidMethod)(JNIEnv*, jclass, jmethodID, ...); - void (*CallStaticVoidMethodV)(JNIEnv*, jclass, jmethodID, va_list); - void (*CallStaticVoidMethodA)(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args); - - jfieldID (*GetStaticFieldID)(JNIEnv* env, jclass clazz, const char* name, - const char* sig); - - jobject (*GetStaticObjectField)(JNIEnv* env, jclass clazz, jfieldID fieldID); - jboolean (*GetStaticBooleanField)(JNIEnv* env, jclass clazz, jfieldID fieldID); - jbyte (*GetStaticByteField)(JNIEnv* env, jclass clazz, jfieldID fieldID); - jchar (*GetStaticCharField)(JNIEnv* env, jclass clazz, jfieldID fieldID); - jshort (*GetStaticShortField)(JNIEnv* env, jclass clazz, jfieldID fieldID); - jint (*GetStaticIntField)(JNIEnv* env, jclass clazz, jfieldID fieldID); - jlong (*GetStaticLongField)(JNIEnv* env, jclass clazz, jfieldID fieldID); - jfloat (*GetStaticFloatField)(JNIEnv* env, jclass clazz, jfieldID fieldID); - jdouble (*GetStaticDoubleField)(JNIEnv* env, jclass clazz, jfieldID fieldID); - - void (*SetStaticObjectField)(JNIEnv* env, jclass clazz, jfieldID fieldID, jobject val); - void (*SetStaticBooleanField)(JNIEnv* env, jclass clazz, jfieldID fieldID, jboolean val); - void (*SetStaticByteField)(JNIEnv* env, jclass clazz, jfieldID fieldID, jbyte val); - void (*SetStaticCharField)(JNIEnv* env, jclass clazz, jfieldID fieldID, jchar val); - void (*SetStaticShortField)(JNIEnv* env, jclass clazz, jfieldID fieldID, jshort val); - void (*SetStaticIntField)(JNIEnv* env, jclass clazz, jfieldID fieldID, jint val); - void (*SetStaticLongField)(JNIEnv* env, jclass clazz, jfieldID fieldID, jlong val); - void (*SetStaticFloatField)(JNIEnv* env, jclass clazz, jfieldID fieldID, jfloat val); - void (*SetStaticDoubleField)(JNIEnv* env, jclass clazz, jfieldID fieldID, jdouble val); - - jstring (*NewString)(JNIEnv* env, const jchar* unicodeChars, jsize len); - jsize (*GetStringLength)(JNIEnv* env, jstring string); - const jchar* (*GetStringChars)(JNIEnv* env, jstring string, jboolean* isCopy); - void (*ReleaseStringChars)(JNIEnv* env, jstring string, const jchar* isCopy); - jstring (*NewStringUTF)(JNIEnv* env, const char* bytes); - jsize (*GetStringUTFLength)(JNIEnv* env, jstring string); - const char* (*GetStringUTFChars)(JNIEnv* env, jstring string, jboolean* isCopy); - void (*ReleaseStringUTFChars)(JNIEnv* env, jstring string, const char* utf); - jsize (*GetArrayLength)(JNIEnv* env, jarray array); - jobjectArray (*NewObjectArray)(JNIEnv* env, jsize length, jclass elementClass, jobject initialElement); - jobject (*GetObjectArrayElement)(JNIEnv* env, jobjectArray array, jsize index); - void (*SetObjectArrayElement)(JNIEnv* env, jobjectArray array, jsize index, jobject val); - - jbooleanArray (*NewBooleanArray)(JNIEnv* env, jsize length); - jbyteArray (*NewByteArray)(JNIEnv* env, jsize length); - jcharArray (*NewCharArray)(JNIEnv* env, jsize length); - jshortArray (*NewShortArray)(JNIEnv* env, jsize length); - jintArray (*NewIntArray)(JNIEnv* env, jsize length); - jlongArray (*NewLongArray)(JNIEnv* env, jsize length); - jfloatArray (*NewFloatArray)(JNIEnv* env, jsize length); - jdoubleArray (*NewDoubleArray)(JNIEnv* env, jsize length); - - jboolean* (*GetBooleanArrayElements)(JNIEnv* env, jbooleanArray array, jboolean* isCopy); - jbyte* (*GetByteArrayElements)(JNIEnv* env, jbyteArray array, jboolean* isCopy); - jchar* (*GetCharArrayElements)(JNIEnv* env, jcharArray array, jboolean* isCopy); - jshort* (*GetShortArrayElements)(JNIEnv* env, jshortArray array, jboolean* isCopy); - jint* (*GetIntArrayElements)(JNIEnv* env, jintArray array, jboolean* isCopy); - jlong* (*GetLongArrayElements)(JNIEnv* env, jlongArray array, jboolean* isCopy); - jfloat* (*GetFloatArrayElements)(JNIEnv* env, jfloatArray array, jboolean* isCopy); - jdouble* (*GetDoubleArrayElements)(JNIEnv* env, jdoubleArray array, jboolean* isCopy); - - void (*ReleaseBooleanArrayElements)(JNIEnv* env, jbooleanArray array, - jboolean* elems, jint mode); - void (*ReleaseByteArrayElements)(JNIEnv* env, jbyteArray array, - jbyte* elems, jint mode); - void (*ReleaseCharArrayElements)(JNIEnv* env, jcharArray array, - jchar* elems, jint mode); - void (*ReleaseShortArrayElements)(JNIEnv* env, jshortArray array, - jshort* elems, jint mode); - void (*ReleaseIntArrayElements)(JNIEnv* env, jintArray array, - jint* elems, jint mode); - void (*ReleaseLongArrayElements)(JNIEnv* env, jlongArray array, - jlong* elems, jint mode); - void (*ReleaseFloatArrayElements)(JNIEnv* env, jfloatArray array, - jfloat* elems, jint mode); - void (*ReleaseDoubleArrayElements)(JNIEnv* env, jdoubleArray array, - jdouble* elems, jint mode); - - void (*GetBooleanArrayRegion)(JNIEnv* env, jbooleanArray array, - jsize start, jsize len, jboolean* buf); - void (*GetByteArrayRegion)(JNIEnv* env, jbyteArray array, - jsize start, jsize len, jbyte* buf); - void (*GetCharArrayRegion)(JNIEnv* env, jcharArray array, - jsize start, jsize len, jchar* buf); - void (*GetShortArrayRegion)(JNIEnv* env, jshortArray array, - jsize start, jsize len, jshort* buf); - void (*GetIntArrayRegion)(JNIEnv* env, jintArray array, - jsize start, jsize len, jint* buf); - void (*GetLongArrayRegion)(JNIEnv* env, jlongArray array, - jsize start, jsize len, jlong* buf); - void (*GetFloatArrayRegion)(JNIEnv* env, jfloatArray array, - jsize start, jsize len, jfloat* buf); - void (*GetDoubleArrayRegion)(JNIEnv* env, jdoubleArray array, - jsize start, jsize len, jdouble* buf); + jobject (*ToReflectedField)(JNIEnv *env, jclass cls, jfieldID fieldID, jboolean isStatic); + + jint (*Throw)(JNIEnv *env, jthrowable obj); + jint (*ThrowNew)(JNIEnv *env, jclass clazz, const char *message); + jthrowable (*ExceptionOccurred)(JNIEnv *env); + void (*ExceptionDescribe)(JNIEnv *env); + void (*ExceptionClear)(JNIEnv *env); + void (*FatalError)(JNIEnv *env, const char *msg); + + jint (*PushLocalFrame)(JNIEnv *env, jint capacity); + jobject (*PopLocalFrame)(JNIEnv *env, jobject result); + + jobject (*NewGlobalRef)(JNIEnv *env, jobject obj); + void (*DeleteGlobalRef)(JNIEnv *env, jobject globalRef); + void (*DeleteLocalRef)(JNIEnv *env, jobject localRef); + jboolean (*IsSameObject)(JNIEnv *env, jobject ref1, jobject ref2); + + jobject (*NewLocalRef)(JNIEnv *env, jobject obj); + jint (*EnsureLocalCapacity)(JNIEnv *env, jint capacity); + + jobject (*AllocObject)(JNIEnv *env, jclass clazz); + jobject (*NewObject)(JNIEnv *env, jclass clazz, jmethodID methodID, ...); + jobject (*NewObjectV)(JNIEnv *, jclass, jmethodID, void *); + jobject (*NewObjectA)(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); + + jclass (*GetObjectClass)(JNIEnv *env, jobject obj); + jboolean (*IsInstanceOf)(JNIEnv *env, jobject obj, jclass clazz); + jmethodID (*GetMethodID)(JNIEnv *env, jclass clazz, const char *name, const char *sig); + + jobject (*CallObjectMethod)(JNIEnv *env, jobject obj, jmethodID methodID, ...); + jobject (*CallObjectMethodV)(JNIEnv *, jobject, jmethodID, void *); + jobject (*CallObjectMethodA)(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args); + jboolean (*CallBooleanMethod)(JNIEnv *env, jobject obj, jmethodID methodID, ...); + jboolean (*CallBooleanMethodV)(JNIEnv *, jobject, jmethodID, void *); + jboolean (*CallBooleanMethodA)(JNIEnv *env, jobject obj, jmethodID methodId, const jvalue *args); + jbyte (*CallByteMethod)(JNIEnv *env, jobject obj, jmethodID methodID, ...); + jbyte (*CallByteMethodV)(JNIEnv *, jobject, jmethodID, void *); + jbyte (*CallByteMethodA)(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args); + jchar (*CallCharMethod)(JNIEnv *env, jobject obj, jmethodID methodID, ...); + jchar (*CallCharMethodV)(JNIEnv *, jobject, jmethodID, void *); + jchar (*CallCharMethodA)(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args); + jshort (*CallShortMethod)(JNIEnv *env, jobject obj, jmethodID methodID, ...); + jshort (*CallShortMethodV)(JNIEnv *, jobject, jmethodID, void *); + jshort (*CallShortMethodA)(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args); + jint (*CallIntMethod)(JNIEnv *env, jobject obj, jmethodID methodID, ...); + jint (*CallIntMethodV)(JNIEnv *, jobject, jmethodID, void *); + jint (*CallIntMethodA)(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args); + jlong (*CallLongMethod)(JNIEnv *env, jobject obj, jmethodID methodID, ...); + jlong (*CallLongMethodV)(JNIEnv *, jobject, jmethodID, void *); + jlong (*CallLongMethodA)(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args); + jfloat (*CallFloatMethod)(JNIEnv *env, jobject obj, jmethodID methodID, ...); + jfloat (*CallFloatMethodV)(JNIEnv *, jobject, jmethodID, void *); + jfloat (*CallFloatMethodA)(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args); + jdouble (*CallDoubleMethod)(JNIEnv *env, jobject obj, jmethodID methodID, ...); + jdouble (*CallDoubleMethodV)(JNIEnv *, jobject, jmethodID, void *); + jdouble (*CallDoubleMethodA)(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args); + void (*CallVoidMethod)(JNIEnv *env, jobject obj, jmethodID methodID, ...); + void (*CallVoidMethodV)(JNIEnv *, jobject, jmethodID, void *); + void (*CallVoidMethodA)(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args); + + jobject (*CallNonvirtualObjectMethod)(JNIEnv *env, jobject obj, jclass clazz, + jmethodID methodID, ...); + jobject (*CallNonvirtualObjectMethodV)(JNIEnv *, jobject, jclass, + jmethodID, void *); + jobject (*CallNonvirtualObjectMethodA)(JNIEnv *env, jobject obj, jclass clazz, + jmethodID methodID, const jvalue *args); + jboolean (*CallNonvirtualBooleanMethod)(JNIEnv *env, jobject obj, jclass clazz, + jmethodID methodID, ...); + jboolean (*CallNonvirtualBooleanMethodV)(JNIEnv *, jobject, jclass, + jmethodID, void *); + jboolean (*CallNonvirtualBooleanMethodA)(JNIEnv *env, jobject obj, jclass clazz, + jmethodID methodID, const jvalue *args); + jbyte (*CallNonvirtualByteMethod)(JNIEnv *env, jobject obj, jclass clazz, + jmethodID methodID, ...); + jbyte (*CallNonvirtualByteMethodV)(JNIEnv *, jobject, jclass, + jmethodID, void *); + jbyte (*CallNonvirtualByteMethodA)(JNIEnv *env, jobject obj, jclass clazz, + jmethodID methodID, const jvalue *args); + jchar (*CallNonvirtualCharMethod)(JNIEnv *env, jobject obj, jclass clazz, + jmethodID methodID, ...); + jchar (*CallNonvirtualCharMethodV)(JNIEnv *, jobject, jclass, + jmethodID, void *); + jchar (*CallNonvirtualCharMethodA)(JNIEnv *env, jobject obj, jclass clazz, + jmethodID methodID, const jvalue *args); + jshort (*CallNonvirtualShortMethod)(JNIEnv *env, jobject obj, jclass clazz, + jmethodID methodID, ...); + jshort (*CallNonvirtualShortMethodV)(JNIEnv *, jobject, jclass, + jmethodID, void *); + jshort (*CallNonvirtualShortMethodA)(JNIEnv *env, jobject obj, jclass clazz, + jmethodID methodID, const jvalue *args); + jint (*CallNonvirtualIntMethod)(JNIEnv *env, jobject obj, jclass clazz, + jmethodID methodID, ...); + jint (*CallNonvirtualIntMethodV)(JNIEnv *, jobject, jclass, + jmethodID, void *); + jint (*CallNonvirtualIntMethodA)(JNIEnv *env, jobject obj, jclass clazz, + jmethodID methodID, const jvalue *args); + jlong (*CallNonvirtualLongMethod)(JNIEnv *env, jobject obj, jclass clazz, + jmethodID methodID, ...); + jlong (*CallNonvirtualLongMethodV)(JNIEnv *, jobject, jclass, + jmethodID, void *); + jlong (*CallNonvirtualLongMethodA)(JNIEnv *env, jobject obj, jclass clazz, + jmethodID methodID, const jvalue *args); + jfloat (*CallNonvirtualFloatMethod)(JNIEnv *env, jobject obj, jclass clazz, + jmethodID methodID, ...); + jfloat (*CallNonvirtualFloatMethodV)(JNIEnv *, jobject, jclass, + jmethodID, void *); + jfloat (*CallNonvirtualFloatMethodA)(JNIEnv *env, jobject obj, jclass clazz, + jmethodID methodID, const jvalue *args); + jdouble (*CallNonvirtualDoubleMethod)(JNIEnv *env, jobject obj, jclass clazz, + jmethodID methodID, ...); + jdouble (*CallNonvirtualDoubleMethodV)(JNIEnv *, jobject, jclass, + jmethodID, void *); + jdouble (*CallNonvirtualDoubleMethodA)(JNIEnv *env, jobject obj, jclass clazz, + jmethodID methodID, const jvalue *args); + void (*CallNonvirtualVoidMethod)(JNIEnv *env, jobject obj, jclass clazz, + jmethodID methodID, ...); + void (*CallNonvirtualVoidMethodV)(JNIEnv *, jobject, jclass, + jmethodID, void *); + void (*CallNonvirtualVoidMethodA)(JNIEnv *env, jobject obj, jclass clazz, + jmethodID methodID, const jvalue *args); + + jfieldID (*GetFieldID)(JNIEnv *env, jclass clazz, const char *name, const char *sig); + + jobject (*GetObjectField)(JNIEnv *env, jobject obj, jfieldID fieldID); + jboolean (*GetBooleanField)(JNIEnv *env, jobject obj, jfieldID fieldID); + jbyte (*GetByteField)(JNIEnv *env, jobject obj, jfieldID fieldID); + jchar (*GetCharField)(JNIEnv *env, jobject obj, jfieldID fieldID); + jshort (*GetShortField)(JNIEnv *env, jobject obj, jfieldID fieldID); + jint (*GetIntField)(JNIEnv *env, jobject obj, jfieldID fieldID); + jlong (*GetLongField)(JNIEnv *env, jobject obj, jfieldID fieldID); + jfloat (*GetFloatField)(JNIEnv *env, jobject obj, jfieldID fieldID); + jdouble (*GetDoubleField)(JNIEnv *env, jobject obj, jfieldID fieldID); + + void (*SetObjectField)(JNIEnv *env, jobject obj, jfieldID fieldID, jobject val); + void (*SetBooleanField)(JNIEnv *env, jobject obj, jfieldID fieldID, jboolean val); + void (*SetByteField)(JNIEnv *env, jobject obj, jfieldID fieldID, jbyte val); + void (*SetCharField)(JNIEnv *env, jobject obj, jfieldID fieldID, jchar val); + void (*SetShortField)(JNIEnv *env, jobject obj, jfieldID fieldID, jshort val); + void (*SetIntField)(JNIEnv *env, jobject obj, jfieldID fieldID, jint val); + void (*SetLongField)(JNIEnv *env, jobject obj, jfieldID fieldID, jlong val); + void (*SetFloatField)(JNIEnv *env, jobject obj, jfieldID fieldID, jfloat val); + void (*SetDoubleField)(JNIEnv *env, jobject obj, jfieldID fieldID, jdouble val); + + jmethodID (*GetStaticMethodID)(JNIEnv *env, jclass clazz, const char *name, const char *sig); + + jobject (*CallStaticObjectMethod)(JNIEnv *env, jclass clazz, jmethodID methodID, ...); + jobject (*CallStaticObjectMethodV)(JNIEnv *, jclass, jmethodID, void *); + jobject (*CallStaticObjectMethodA)(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); + jboolean (*CallStaticBooleanMethod)(JNIEnv *env, jclass clazz, jmethodID methodID, ...); + jboolean (*CallStaticBooleanMethodV)(JNIEnv *, jclass, jmethodID, + void *); + jboolean (*CallStaticBooleanMethodA)(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); + jbyte (*CallStaticByteMethod)(JNIEnv *env, jclass clazz, jmethodID methodID, ...); + jbyte (*CallStaticByteMethodV)(JNIEnv *, jclass, jmethodID, void *); + jbyte (*CallStaticByteMethodA)(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); + jchar (*CallStaticCharMethod)(JNIEnv *env, jclass clazz, jmethodID methodID, ...); + jchar (*CallStaticCharMethodV)(JNIEnv *, jclass, jmethodID, void *); + jchar (*CallStaticCharMethodA)(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); + jshort (*CallStaticShortMethod)(JNIEnv *env, jclass clazz, jmethodID methodID, ...); + jshort (*CallStaticShortMethodV)(JNIEnv *, jclass, jmethodID, void *); + jshort (*CallStaticShortMethodA)(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); + jint (*CallStaticIntMethod)(JNIEnv *env, jclass clazz, jmethodID methodID, ...); + jint (*CallStaticIntMethodV)(JNIEnv *, jclass, jmethodID, void *); + jint (*CallStaticIntMethodA)(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); + jlong (*CallStaticLongMethod)(JNIEnv *env, jclass clazz, jmethodID methodID, ...); + jlong (*CallStaticLongMethodV)(JNIEnv *, jclass, jmethodID, void *); + jlong (*CallStaticLongMethodA)(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); + jfloat (*CallStaticFloatMethod)(JNIEnv *env, jclass clazz, jmethodID methodID, ...); + jfloat (*CallStaticFloatMethodV)(JNIEnv *, jclass, jmethodID, void *); + jfloat (*CallStaticFloatMethodA)(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); + jdouble (*CallStaticDoubleMethod)(JNIEnv *env, jclass clazz, jmethodID methodID, ...); + jdouble (*CallStaticDoubleMethodV)(JNIEnv *, jclass, jmethodID, void *); + jdouble (*CallStaticDoubleMethodA)(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); + void (*CallStaticVoidMethod)(JNIEnv *env, jclass clazz, jmethodID methodID, ...); + void (*CallStaticVoidMethodV)(JNIEnv *, jclass, jmethodID, void *); + void (*CallStaticVoidMethodA)(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); + + jfieldID (*GetStaticFieldID)(JNIEnv *env, jclass clazz, const char *name, + const char *sig); + + jobject (*GetStaticObjectField)(JNIEnv *env, jclass clazz, jfieldID fieldID); + jboolean (*GetStaticBooleanField)(JNIEnv *env, jclass clazz, jfieldID fieldID); + jbyte (*GetStaticByteField)(JNIEnv *env, jclass clazz, jfieldID fieldID); + jchar (*GetStaticCharField)(JNIEnv *env, jclass clazz, jfieldID fieldID); + jshort (*GetStaticShortField)(JNIEnv *env, jclass clazz, jfieldID fieldID); + jint (*GetStaticIntField)(JNIEnv *env, jclass clazz, jfieldID fieldID); + jlong (*GetStaticLongField)(JNIEnv *env, jclass clazz, jfieldID fieldID); + jfloat (*GetStaticFloatField)(JNIEnv *env, jclass clazz, jfieldID fieldID); + jdouble (*GetStaticDoubleField)(JNIEnv *env, jclass clazz, jfieldID fieldID); + + void (*SetStaticObjectField)(JNIEnv *env, jclass clazz, jfieldID fieldID, jobject val); + void (*SetStaticBooleanField)(JNIEnv *env, jclass clazz, jfieldID fieldID, jboolean val); + void (*SetStaticByteField)(JNIEnv *env, jclass clazz, jfieldID fieldID, jbyte val); + void (*SetStaticCharField)(JNIEnv *env, jclass clazz, jfieldID fieldID, jchar val); + void (*SetStaticShortField)(JNIEnv *env, jclass clazz, jfieldID fieldID, jshort val); + void (*SetStaticIntField)(JNIEnv *env, jclass clazz, jfieldID fieldID, jint val); + void (*SetStaticLongField)(JNIEnv *env, jclass clazz, jfieldID fieldID, jlong val); + void (*SetStaticFloatField)(JNIEnv *env, jclass clazz, jfieldID fieldID, jfloat val); + void (*SetStaticDoubleField)(JNIEnv *env, jclass clazz, jfieldID fieldID, jdouble val); + + jstring (*NewString)(JNIEnv *env, const jchar *unicodeChars, jsize len); + jsize (*GetStringLength)(JNIEnv *env, jstring string); + const jchar *(*GetStringChars)(JNIEnv *env, jstring string, jboolean *isCopy); + void (*ReleaseStringChars)(JNIEnv *env, jstring string, const jchar *isCopy); + jstring (*NewStringUTF)(JNIEnv *env, const char *bytes); + jsize (*GetStringUTFLength)(JNIEnv *env, jstring string); + const char *(*GetStringUTFChars)(JNIEnv *env, jstring string, jboolean *isCopy); + void (*ReleaseStringUTFChars)(JNIEnv *env, jstring string, const char *utf); + jsize (*GetArrayLength)(JNIEnv *env, jarray array); + jobjectArray (*NewObjectArray)(JNIEnv *env, jsize length, jclass elementClass, jobject initialElement); + jobject (*GetObjectArrayElement)(JNIEnv *env, jobjectArray array, jsize index); + void (*SetObjectArrayElement)(JNIEnv *env, jobjectArray array, jsize index, jobject val); + + jbooleanArray (*NewBooleanArray)(JNIEnv *env, jsize length); + jbyteArray (*NewByteArray)(JNIEnv *env, jsize length); + jcharArray (*NewCharArray)(JNIEnv *env, jsize length); + jshortArray (*NewShortArray)(JNIEnv *env, jsize length); + jintArray (*NewIntArray)(JNIEnv *env, jsize length); + jlongArray (*NewLongArray)(JNIEnv *env, jsize length); + jfloatArray (*NewFloatArray)(JNIEnv *env, jsize length); + jdoubleArray (*NewDoubleArray)(JNIEnv *env, jsize length); + + jboolean *(*GetBooleanArrayElements)(JNIEnv *env, jbooleanArray array, jboolean *isCopy); + jbyte *(*GetByteArrayElements)(JNIEnv *env, jbyteArray array, jboolean *isCopy); + jchar *(*GetCharArrayElements)(JNIEnv *env, jcharArray array, jboolean *isCopy); + jshort *(*GetShortArrayElements)(JNIEnv *env, jshortArray array, jboolean *isCopy); + jint *(*GetIntArrayElements)(JNIEnv *env, jintArray array, jboolean *isCopy); + jlong *(*GetLongArrayElements)(JNIEnv *env, jlongArray array, jboolean *isCopy); + jfloat *(*GetFloatArrayElements)(JNIEnv *env, jfloatArray array, jboolean *isCopy); + jdouble *(*GetDoubleArrayElements)(JNIEnv *env, jdoubleArray array, jboolean *isCopy); + + void (*ReleaseBooleanArrayElements)(JNIEnv *env, jbooleanArray array, + jboolean *elems, jint mode); + void (*ReleaseByteArrayElements)(JNIEnv *env, jbyteArray array, + jbyte *elems, jint mode); + void (*ReleaseCharArrayElements)(JNIEnv *env, jcharArray array, + jchar *elems, jint mode); + void (*ReleaseShortArrayElements)(JNIEnv *env, jshortArray array, + jshort *elems, jint mode); + void (*ReleaseIntArrayElements)(JNIEnv *env, jintArray array, + jint *elems, jint mode); + void (*ReleaseLongArrayElements)(JNIEnv *env, jlongArray array, + jlong *elems, jint mode); + void (*ReleaseFloatArrayElements)(JNIEnv *env, jfloatArray array, + jfloat *elems, jint mode); + void (*ReleaseDoubleArrayElements)(JNIEnv *env, jdoubleArray array, + jdouble *elems, jint mode); + + void (*GetBooleanArrayRegion)(JNIEnv *env, jbooleanArray array, + jsize start, jsize len, jboolean *buf); + void (*GetByteArrayRegion)(JNIEnv *env, jbyteArray array, + jsize start, jsize len, jbyte *buf); + void (*GetCharArrayRegion)(JNIEnv *env, jcharArray array, + jsize start, jsize len, jchar *buf); + void (*GetShortArrayRegion)(JNIEnv *env, jshortArray array, + jsize start, jsize len, jshort *buf); + void (*GetIntArrayRegion)(JNIEnv *env, jintArray array, + jsize start, jsize len, jint *buf); + void (*GetLongArrayRegion)(JNIEnv *env, jlongArray array, + jsize start, jsize len, jlong *buf); + void (*GetFloatArrayRegion)(JNIEnv *env, jfloatArray array, + jsize start, jsize len, jfloat *buf); + void (*GetDoubleArrayRegion)(JNIEnv *env, jdoubleArray array, + jsize start, jsize len, jdouble *buf); /* spec shows these without const; some jni.h do, some don't */ - void (*SetBooleanArrayRegion)(JNIEnv* env, jbooleanArray array, - jsize start, jsize len, const jboolean* buf); - void (*SetByteArrayRegion)(JNIEnv* env, jbyteArray array, - jsize start, jsize len, const jbyte* buf); - void (*SetCharArrayRegion)(JNIEnv* env, jcharArray array, - jsize start, jsize len, const jchar* buf); - void (*SetShortArrayRegion)(JNIEnv* env, jshortArray array, - jsize start, jsize len, const jshort* buf); - void (*SetIntArrayRegion)(JNIEnv* env, jintArray array, - jsize start, jsize len, const jint* buf); - void (*SetLongArrayRegion)(JNIEnv* env, jlongArray array, - jsize start, jsize len, const jlong* buf); - void (*SetFloatArrayRegion)(JNIEnv* env, jfloatArray array, - jsize start, jsize len, const jfloat* buf); - void (*SetDoubleArrayRegion)(JNIEnv* env, jdoubleArray array, - jsize start, jsize len, const jdouble* buf); - - jint (*RegisterNatives)(JNIEnv* env, jclass clazz, const JNINativeMethod* methods, - jint nMethods); - jint (*UnregisterNatives)(JNIEnv* env, jclass clazz); - jint (*MonitorEnter)(JNIEnv* env, jobject obj); - jint (*MonitorExit)(JNIEnv* env, jobject obj); - jint (*GetJavaVM)(JNIEnv* env, JavaVM** vm); - - void (*GetStringRegion)(JNIEnv* env, jstring str, jsize start, jsize len, jchar* buf); - void (*GetStringUTFRegion)(JNIEnv* env, jstring str, jsize start, jsize len, char* buf); - - void* (*GetPrimitiveArrayCritical)(JNIEnv* env, jarray array, jboolean* isCopy); - void (*ReleasePrimitiveArrayCritical)(JNIEnv* env, jarray array, void* carray, jint mode); - - const jchar* (*GetStringCritical)(JNIEnv* env, jstring str, jboolean* isCopy); - void (*ReleaseStringCritical)(JNIEnv* env, jstring str, const jchar* carray); - - jweak (*NewWeakGlobalRef)(JNIEnv* env, jobject obj); - void (*DeleteWeakGlobalRef)(JNIEnv* env, jweak obj); - - jboolean (*ExceptionCheck)(JNIEnv* env); - - jobject (*NewDirectByteBuffer)(JNIEnv* env, void* address, jlong capacity); - void* (*GetDirectBufferAddress)(JNIEnv* env, jobject buf); - jlong (*GetDirectBufferCapacity)(JNIEnv* env, jobject buf); + void (*SetBooleanArrayRegion)(JNIEnv *env, jbooleanArray array, + jsize start, jsize len, const jboolean *buf); + void (*SetByteArrayRegion)(JNIEnv *env, jbyteArray array, + jsize start, jsize len, const jbyte *buf); + void (*SetCharArrayRegion)(JNIEnv *env, jcharArray array, + jsize start, jsize len, const jchar *buf); + void (*SetShortArrayRegion)(JNIEnv *env, jshortArray array, + jsize start, jsize len, const jshort *buf); + void (*SetIntArrayRegion)(JNIEnv *env, jintArray array, + jsize start, jsize len, const jint *buf); + void (*SetLongArrayRegion)(JNIEnv *env, jlongArray array, + jsize start, jsize len, const jlong *buf); + void (*SetFloatArrayRegion)(JNIEnv *env, jfloatArray array, + jsize start, jsize len, const jfloat *buf); + void (*SetDoubleArrayRegion)(JNIEnv *env, jdoubleArray array, + jsize start, jsize len, const jdouble *buf); + + jint (*RegisterNatives)(JNIEnv *env, jclass clazz, const JNINativeMethod *methods, + jint nMethods); + jint (*UnregisterNatives)(JNIEnv *env, jclass clazz); + jint (*MonitorEnter)(JNIEnv *env, jobject obj); + jint (*MonitorExit)(JNIEnv *env, jobject obj); + jint (*GetJavaVM)(JNIEnv *env, JavaVM **vm); + + void (*GetStringRegion)(JNIEnv *env, jstring str, jsize start, jsize len, jchar *buf); + void (*GetStringUTFRegion)(JNIEnv *env, jstring str, jsize start, jsize len, char *buf); + + void *(*GetPrimitiveArrayCritical)(JNIEnv *env, jarray array, jboolean *isCopy); + void (*ReleasePrimitiveArrayCritical)(JNIEnv *env, jarray array, void *carray, jint mode); + + const jchar *(*GetStringCritical)(JNIEnv *env, jstring str, jboolean *isCopy); + void (*ReleaseStringCritical)(JNIEnv *env, jstring str, const jchar *carray); + + jweak (*NewWeakGlobalRef)(JNIEnv *env, jobject obj); + void (*DeleteWeakGlobalRef)(JNIEnv *env, jweak obj); + + jboolean (*ExceptionCheck)(JNIEnv *env); + + jobject (*NewDirectByteBuffer)(JNIEnv *env, void *address, jlong capacity); + void *(*GetDirectBufferAddress)(JNIEnv *env, jobject buf); + jlong (*GetDirectBufferCapacity)(JNIEnv *env, jobject buf); /* added in JNI 1.6 */ - jobjectRefType (*GetObjectRefType)(JNIEnv* env, jobject obj); + jobjectRefType (*GetObjectRefType)(JNIEnv *env, jobject obj); }; /* @@ -489,84 +520,133 @@ struct JNINativeInterface { * This is usually overlaid on a C struct whose first element is a * JNINativeInterface*. We rely somewhat on compiler behavior. */ -struct _JNIEnv { +struct _JNIEnv +{ /* do not rename this; it does not seem to be entirely opaque */ - const struct JNINativeInterface* functions; + const struct JNINativeInterface *functions; #if defined(__cplusplus) jint GetVersion() - { return functions->GetVersion(this); } + { + return functions->GetVersion(this); + } - jclass DefineClass(const char *name, jobject loader, const jbyte* buf, - jsize bufLen) - { return functions->DefineClass(this, name, loader, buf, bufLen); } + jclass DefineClass(const char *name, jobject loader, const jbyte *buf, + jsize bufLen) + { + return functions->DefineClass(this, name, loader, buf, bufLen); + } - jclass FindClass(const char* name) - { return functions->FindClass(this, name); } + jclass FindClass(const char *name) + { + return functions->FindClass(this, name); + } jmethodID FromReflectedMethod(jobject method) - { return functions->FromReflectedMethod(this, method); } + { + return functions->FromReflectedMethod(this, method); + } jfieldID FromReflectedField(jobject field) - { return functions->FromReflectedField(this, field); } + { + return functions->FromReflectedField(this, field); + } jobject ToReflectedMethod(jclass cls, jmethodID methodID, jboolean isStatic) - { return functions->ToReflectedMethod(this, cls, methodID, isStatic); } + { + return functions->ToReflectedMethod(this, cls, methodID, isStatic); + } jclass GetSuperclass(jclass clazz) - { return functions->GetSuperclass(this, clazz); } + { + return functions->GetSuperclass(this, clazz); + } jboolean IsAssignableFrom(jclass clazz1, jclass clazz2) - { return functions->IsAssignableFrom(this, clazz1, clazz2); } + { + return functions->IsAssignableFrom(this, clazz1, clazz2); + } jobject ToReflectedField(jclass cls, jfieldID fieldID, jboolean isStatic) - { return functions->ToReflectedField(this, cls, fieldID, isStatic); } + { + return functions->ToReflectedField(this, cls, fieldID, isStatic); + } jint Throw(jthrowable obj) - { return functions->Throw(this, obj); } + { + return functions->Throw(this, obj); + } - jint ThrowNew(jclass clazz, const char* message) - { return functions->ThrowNew(this, clazz, message); } + jint ThrowNew(jclass clazz, const char *message) + { + return functions->ThrowNew(this, clazz, message); + } jthrowable ExceptionOccurred() - { return functions->ExceptionOccurred(this); } + { + return functions->ExceptionOccurred(this); + } void ExceptionDescribe() - { functions->ExceptionDescribe(this); } + { + functions->ExceptionDescribe(this); + } void ExceptionClear() - { functions->ExceptionClear(this); } + { + functions->ExceptionClear(this); + } - void FatalError(const char* msg) - { functions->FatalError(this, msg); } + void FatalError(const char *msg) + { + functions->FatalError(this, msg); + } jint PushLocalFrame(jint capacity) - { return functions->PushLocalFrame(this, capacity); } + { + return functions->PushLocalFrame(this, capacity); + } jobject PopLocalFrame(jobject result) - { return functions->PopLocalFrame(this, result); } + { + return functions->PopLocalFrame(this, result); + } jobject NewGlobalRef(jobject obj) - { return functions->NewGlobalRef(this, obj); } + { + return functions->NewGlobalRef(this, obj); + } void DeleteGlobalRef(jobject globalRef) - { functions->DeleteGlobalRef(this, globalRef); } + { + functions->DeleteGlobalRef(this, globalRef); + } void DeleteLocalRef(jobject localRef) - { functions->DeleteLocalRef(this, localRef); } + { + functions->DeleteLocalRef(this, localRef); + } jboolean IsSameObject(jobject ref1, jobject ref2) - { return functions->IsSameObject(this, ref1, ref2); } + { + return functions->IsSameObject(this, ref1, ref2); + } - jobject NewLocalRef(jobject ref) - { return functions->NewLocalRef(this, ref); } + jobject NewLocalRef(jobject obj) + { + return functions->NewLocalRef(this, ref); + } jint EnsureLocalCapacity(jint capacity) - { return functions->EnsureLocalCapacity(this, capacity); } + { + return functions->EnsureLocalCapacity(this, capacity); + } jobject AllocObject(jclass clazz) - { return functions->AllocObject(this, clazz); } + { + return functions->AllocObject(this, clazz); + } jobject NewObject(jclass clazz, jmethodID methodID, ...) { @@ -578,43 +658,57 @@ struct _JNIEnv { } jobject NewObjectV(jclass clazz, jmethodID methodID, va_list args) - { return functions->NewObjectV(this, clazz, methodID, args); } + { + return functions->NewObjectV(this, clazz, methodID, args); + } - jobject NewObjectA(jclass clazz, jmethodID methodID, const jvalue* args) - { return functions->NewObjectA(this, clazz, methodID, args); } + jobject NewObjectA(jclass clazz, jmethodID methodID, const jvalue *args) + { + return functions->NewObjectA(this, clazz, methodID, args); + } jclass GetObjectClass(jobject obj) - { return functions->GetObjectClass(this, obj); } + { + return functions->GetObjectClass(this, obj); + } jboolean IsInstanceOf(jobject obj, jclass clazz) - { return functions->IsInstanceOf(this, obj, clazz); } + { + return functions->IsInstanceOf(this, obj, clazz); + } - jmethodID GetMethodID(jclass clazz, const char* name, const char* sig) - { return functions->GetMethodID(this, clazz, name, sig); } + jmethodID GetMethodID(jclass clazz, const char *name, const char *sig) + { + return functions->GetMethodID(this, clazz, name, sig); + } -#define CALL_TYPE_METHOD(_jtype, _jname) \ - _jtype Call##_jname##Method(jobject obj, jmethodID methodID, ...) \ - { \ - _jtype result; \ - va_list args; \ - va_start(args, methodID); \ - result = functions->Call##_jname##MethodV(this, obj, methodID, \ - args); \ - va_end(args); \ - return result; \ +#define CALL_TYPE_METHOD(_jtype, _jname) \ + _jtype Call##_jname##Method(jobject obj, jmethodID methodID, ...) \ + { \ + _jtype result; \ + va_list args; \ + va_start(args, methodID); \ + result = functions->Call##_jname##MethodV(this, obj, methodID, \ + args); \ + va_end(args); \ + return result; \ } #define CALL_TYPE_METHODV(_jtype, _jname) \ _jtype Call##_jname##MethodV(jobject obj, jmethodID methodID, \ - va_list args) \ - { return functions->Call##_jname##MethodV(this, obj, methodID, args); } + va_list args) \ + { \ + return functions->Call##_jname##MethodV(this, obj, methodID, args); \ + } #define CALL_TYPE_METHODA(_jtype, _jname) \ _jtype Call##_jname##MethodA(jobject obj, jmethodID methodID, \ - const jvalue* args) \ - { return functions->Call##_jname##MethodA(this, obj, methodID, args); } + const jvalue *args) \ + { \ + return functions->Call##_jname##MethodA(this, obj, methodID, args); \ + } -#define CALL_TYPE(_jtype, _jname) \ - CALL_TYPE_METHOD(_jtype, _jname) \ - CALL_TYPE_METHODV(_jtype, _jname) \ +#define CALL_TYPE(_jtype, _jname) \ + CALL_TYPE_METHOD(_jtype, _jname) \ + CALL_TYPE_METHODV(_jtype, _jname) \ CALL_TYPE_METHODA(_jtype, _jname) CALL_TYPE(jobject, Object) @@ -635,36 +729,44 @@ struct _JNIEnv { va_end(args); } void CallVoidMethodV(jobject obj, jmethodID methodID, va_list args) - { functions->CallVoidMethodV(this, obj, methodID, args); } - void CallVoidMethodA(jobject obj, jmethodID methodID, const jvalue* args) - { functions->CallVoidMethodA(this, obj, methodID, args); } + { + functions->CallVoidMethodV(this, obj, methodID, args); + } + void CallVoidMethodA(jobject obj, jmethodID methodID, const jvalue *args) + { + functions->CallVoidMethodA(this, obj, methodID, args); + } -#define CALL_NONVIRT_TYPE_METHOD(_jtype, _jname) \ - _jtype CallNonvirtual##_jname##Method(jobject obj, jclass clazz, \ - jmethodID methodID, ...) \ - { \ - _jtype result; \ - va_list args; \ - va_start(args, methodID); \ - result = functions->CallNonvirtual##_jname##MethodV(this, obj, \ - clazz, methodID, args); \ - va_end(args); \ - return result; \ - } -#define CALL_NONVIRT_TYPE_METHODV(_jtype, _jname) \ - _jtype CallNonvirtual##_jname##MethodV(jobject obj, jclass clazz, \ - jmethodID methodID, va_list args) \ - { return functions->CallNonvirtual##_jname##MethodV(this, obj, clazz, \ - methodID, args); } -#define CALL_NONVIRT_TYPE_METHODA(_jtype, _jname) \ - _jtype CallNonvirtual##_jname##MethodA(jobject obj, jclass clazz, \ - jmethodID methodID, const jvalue* args) \ - { return functions->CallNonvirtual##_jname##MethodA(this, obj, clazz, \ - methodID, args); } - -#define CALL_NONVIRT_TYPE(_jtype, _jname) \ - CALL_NONVIRT_TYPE_METHOD(_jtype, _jname) \ - CALL_NONVIRT_TYPE_METHODV(_jtype, _jname) \ +#define CALL_NONVIRT_TYPE_METHOD(_jtype, _jname) \ + _jtype CallNonvirtual##_jname##Method(jobject obj, jclass clazz, \ + jmethodID methodID, ...) \ + { \ + _jtype result; \ + va_list args; \ + va_start(args, methodID); \ + result = functions->CallNonvirtual##_jname##MethodV(this, obj, \ + clazz, methodID, args); \ + va_end(args); \ + return result; \ + } +#define CALL_NONVIRT_TYPE_METHODV(_jtype, _jname) \ + _jtype CallNonvirtual##_jname##MethodV(jobject obj, jclass clazz, \ + jmethodID methodID, va_list args) \ + { \ + return functions->CallNonvirtual##_jname##MethodV(this, obj, clazz, \ + methodID, args); \ + } +#define CALL_NONVIRT_TYPE_METHODA(_jtype, _jname) \ + _jtype CallNonvirtual##_jname##MethodA(jobject obj, jclass clazz, \ + jmethodID methodID, const jvalue *args) \ + { \ + return functions->CallNonvirtual##_jname##MethodA(this, obj, clazz, \ + methodID, args); \ + } + +#define CALL_NONVIRT_TYPE(_jtype, _jname) \ + CALL_NONVIRT_TYPE_METHOD(_jtype, _jname) \ + CALL_NONVIRT_TYPE_METHODV(_jtype, _jname) \ CALL_NONVIRT_TYPE_METHODA(_jtype, _jname) CALL_NONVIRT_TYPE(jobject, Object) @@ -678,7 +780,7 @@ struct _JNIEnv { CALL_NONVIRT_TYPE(jdouble, Double) void CallNonvirtualVoidMethod(jobject obj, jclass clazz, - jmethodID methodID, ...) + jmethodID methodID, ...) { va_list args; va_start(args, methodID); @@ -686,82 +788,130 @@ struct _JNIEnv { va_end(args); } void CallNonvirtualVoidMethodV(jobject obj, jclass clazz, - jmethodID methodID, va_list args) - { functions->CallNonvirtualVoidMethodV(this, obj, clazz, methodID, args); } + jmethodID methodID, va_list args) + { + functions->CallNonvirtualVoidMethodV(this, obj, clazz, methodID, args); + } void CallNonvirtualVoidMethodA(jobject obj, jclass clazz, - jmethodID methodID, const jvalue* args) - { functions->CallNonvirtualVoidMethodA(this, obj, clazz, methodID, args); } + jmethodID methodID, const jvalue *args) + { + functions->CallNonvirtualVoidMethodA(this, obj, clazz, methodID, args); + } - jfieldID GetFieldID(jclass clazz, const char* name, const char* sig) - { return functions->GetFieldID(this, clazz, name, sig); } + jfieldID GetFieldID(jclass clazz, const char *name, const char *sig) + { + return functions->GetFieldID(this, clazz, name, sig); + } jobject GetObjectField(jobject obj, jfieldID fieldID) - { return functions->GetObjectField(this, obj, fieldID); } + { + return functions->GetObjectField(this, obj, fieldID); + } jboolean GetBooleanField(jobject obj, jfieldID fieldID) - { return functions->GetBooleanField(this, obj, fieldID); } + { + return functions->GetBooleanField(this, obj, fieldID); + } jbyte GetByteField(jobject obj, jfieldID fieldID) - { return functions->GetByteField(this, obj, fieldID); } + { + return functions->GetByteField(this, obj, fieldID); + } jchar GetCharField(jobject obj, jfieldID fieldID) - { return functions->GetCharField(this, obj, fieldID); } + { + return functions->GetCharField(this, obj, fieldID); + } jshort GetShortField(jobject obj, jfieldID fieldID) - { return functions->GetShortField(this, obj, fieldID); } + { + return functions->GetShortField(this, obj, fieldID); + } jint GetIntField(jobject obj, jfieldID fieldID) - { return functions->GetIntField(this, obj, fieldID); } + { + return functions->GetIntField(this, obj, fieldID); + } jlong GetLongField(jobject obj, jfieldID fieldID) - { return functions->GetLongField(this, obj, fieldID); } + { + return functions->GetLongField(this, obj, fieldID); + } jfloat GetFloatField(jobject obj, jfieldID fieldID) - { return functions->GetFloatField(this, obj, fieldID); } + { + return functions->GetFloatField(this, obj, fieldID); + } jdouble GetDoubleField(jobject obj, jfieldID fieldID) - { return functions->GetDoubleField(this, obj, fieldID); } + { + return functions->GetDoubleField(this, obj, fieldID); + } void SetObjectField(jobject obj, jfieldID fieldID, jobject val) - { functions->SetObjectField(this, obj, fieldID, val); } + { + functions->SetObjectField(this, obj, fieldID, val); + } void SetBooleanField(jobject obj, jfieldID fieldID, jboolean val) - { functions->SetBooleanField(this, obj, fieldID, val); } + { + functions->SetBooleanField(this, obj, fieldID, val); + } void SetByteField(jobject obj, jfieldID fieldID, jbyte val) - { functions->SetByteField(this, obj, fieldID, val); } + { + functions->SetByteField(this, obj, fieldID, val); + } void SetCharField(jobject obj, jfieldID fieldID, jchar val) - { functions->SetCharField(this, obj, fieldID, val); } + { + functions->SetCharField(this, obj, fieldID, val); + } void SetShortField(jobject obj, jfieldID fieldID, jshort val) - { functions->SetShortField(this, obj, fieldID, val); } + { + functions->SetShortField(this, obj, fieldID, val); + } void SetIntField(jobject obj, jfieldID fieldID, jint val) - { functions->SetIntField(this, obj, fieldID, val); } + { + functions->SetIntField(this, obj, fieldID, val); + } void SetLongField(jobject obj, jfieldID fieldID, jlong val) - { functions->SetLongField(this, obj, fieldID, val); } + { + functions->SetLongField(this, obj, fieldID, val); + } void SetFloatField(jobject obj, jfieldID fieldID, jfloat val) - { functions->SetFloatField(this, obj, fieldID, val); } + { + functions->SetFloatField(this, obj, fieldID, val); + } void SetDoubleField(jobject obj, jfieldID fieldID, jdouble val) - { functions->SetDoubleField(this, obj, fieldID, val); } + { + functions->SetDoubleField(this, obj, fieldID, val); + } - jmethodID GetStaticMethodID(jclass clazz, const char* name, const char* sig) - { return functions->GetStaticMethodID(this, clazz, name, sig); } + jmethodID GetStaticMethodID(jclass clazz, const char *name, const char *sig) + { + return functions->GetStaticMethodID(this, clazz, name, sig); + } -#define CALL_STATIC_TYPE_METHOD(_jtype, _jname) \ - _jtype CallStatic##_jname##Method(jclass clazz, jmethodID methodID, \ - ...) \ - { \ - _jtype result; \ - va_list args; \ - va_start(args, methodID); \ - result = functions->CallStatic##_jname##MethodV(this, clazz, \ - methodID, args); \ - va_end(args); \ - return result; \ - } -#define CALL_STATIC_TYPE_METHODV(_jtype, _jname) \ - _jtype CallStatic##_jname##MethodV(jclass clazz, jmethodID methodID, \ - va_list args) \ - { return functions->CallStatic##_jname##MethodV(this, clazz, methodID, \ - args); } -#define CALL_STATIC_TYPE_METHODA(_jtype, _jname) \ - _jtype CallStatic##_jname##MethodA(jclass clazz, jmethodID methodID, \ - const jvalue* args) \ - { return functions->CallStatic##_jname##MethodA(this, clazz, methodID, \ - args); } - -#define CALL_STATIC_TYPE(_jtype, _jname) \ - CALL_STATIC_TYPE_METHOD(_jtype, _jname) \ - CALL_STATIC_TYPE_METHODV(_jtype, _jname) \ +#define CALL_STATIC_TYPE_METHOD(_jtype, _jname) \ + _jtype CallStatic##_jname##Method(jclass clazz, jmethodID methodID, \ + ...) \ + { \ + _jtype result; \ + va_list args; \ + va_start(args, methodID); \ + result = functions->CallStatic##_jname##MethodV(this, clazz, \ + methodID, args); \ + va_end(args); \ + return result; \ + } +#define CALL_STATIC_TYPE_METHODV(_jtype, _jname) \ + _jtype CallStatic##_jname##MethodV(jclass clazz, jmethodID methodID, \ + va_list args) \ + { \ + return functions->CallStatic##_jname##MethodV(this, clazz, methodID, \ + args); \ + } +#define CALL_STATIC_TYPE_METHODA(_jtype, _jname) \ + _jtype CallStatic##_jname##MethodA(jclass clazz, jmethodID methodID, \ + const jvalue *args) \ + { \ + return functions->CallStatic##_jname##MethodA(this, clazz, methodID, \ + args); \ + } + +#define CALL_STATIC_TYPE(_jtype, _jname) \ + CALL_STATIC_TYPE_METHOD(_jtype, _jname) \ + CALL_STATIC_TYPE_METHODV(_jtype, _jname) \ CALL_STATIC_TYPE_METHODA(_jtype, _jname) CALL_STATIC_TYPE(jobject, Object) @@ -782,296 +932,490 @@ struct _JNIEnv { va_end(args); } void CallStaticVoidMethodV(jclass clazz, jmethodID methodID, va_list args) - { functions->CallStaticVoidMethodV(this, clazz, methodID, args); } - void CallStaticVoidMethodA(jclass clazz, jmethodID methodID, const jvalue* args) - { functions->CallStaticVoidMethodA(this, clazz, methodID, args); } + { + functions->CallStaticVoidMethodV(this, clazz, methodID, args); + } + void CallStaticVoidMethodA(jclass clazz, jmethodID methodID, const jvalue *args) + { + functions->CallStaticVoidMethodA(this, clazz, methodID, args); + } - jfieldID GetStaticFieldID(jclass clazz, const char* name, const char* sig) - { return functions->GetStaticFieldID(this, clazz, name, sig); } + jfieldID GetStaticFieldID(jclass clazz, const char *name, const char *sig) + { + return functions->GetStaticFieldID(this, clazz, name, sig); + } jobject GetStaticObjectField(jclass clazz, jfieldID fieldID) - { return functions->GetStaticObjectField(this, clazz, fieldID); } + { + return functions->GetStaticObjectField(this, clazz, fieldID); + } jboolean GetStaticBooleanField(jclass clazz, jfieldID fieldID) - { return functions->GetStaticBooleanField(this, clazz, fieldID); } + { + return functions->GetStaticBooleanField(this, clazz, fieldID); + } jbyte GetStaticByteField(jclass clazz, jfieldID fieldID) - { return functions->GetStaticByteField(this, clazz, fieldID); } + { + return functions->GetStaticByteField(this, clazz, fieldID); + } jchar GetStaticCharField(jclass clazz, jfieldID fieldID) - { return functions->GetStaticCharField(this, clazz, fieldID); } + { + return functions->GetStaticCharField(this, clazz, fieldID); + } jshort GetStaticShortField(jclass clazz, jfieldID fieldID) - { return functions->GetStaticShortField(this, clazz, fieldID); } + { + return functions->GetStaticShortField(this, clazz, fieldID); + } jint GetStaticIntField(jclass clazz, jfieldID fieldID) - { return functions->GetStaticIntField(this, clazz, fieldID); } + { + return functions->GetStaticIntField(this, clazz, fieldID); + } jlong GetStaticLongField(jclass clazz, jfieldID fieldID) - { return functions->GetStaticLongField(this, clazz, fieldID); } + { + return functions->GetStaticLongField(this, clazz, fieldID); + } jfloat GetStaticFloatField(jclass clazz, jfieldID fieldID) - { return functions->GetStaticFloatField(this, clazz, fieldID); } + { + return functions->GetStaticFloatField(this, clazz, fieldID); + } jdouble GetStaticDoubleField(jclass clazz, jfieldID fieldID) - { return functions->GetStaticDoubleField(this, clazz, fieldID); } + { + return functions->GetStaticDoubleField(this, clazz, fieldID); + } void SetStaticObjectField(jclass clazz, jfieldID fieldID, jobject val) - { functions->SetStaticObjectField(this, clazz, fieldID, val); } + { + functions->SetStaticObjectField(this, clazz, fieldID, val); + } void SetStaticBooleanField(jclass clazz, jfieldID fieldID, jboolean val) - { functions->SetStaticBooleanField(this, clazz, fieldID, val); } + { + functions->SetStaticBooleanField(this, clazz, fieldID, val); + } void SetStaticByteField(jclass clazz, jfieldID fieldID, jbyte val) - { functions->SetStaticByteField(this, clazz, fieldID, val); } + { + functions->SetStaticByteField(this, clazz, fieldID, val); + } void SetStaticCharField(jclass clazz, jfieldID fieldID, jchar val) - { functions->SetStaticCharField(this, clazz, fieldID, val); } + { + functions->SetStaticCharField(this, clazz, fieldID, val); + } void SetStaticShortField(jclass clazz, jfieldID fieldID, jshort val) - { functions->SetStaticShortField(this, clazz, fieldID, val); } + { + functions->SetStaticShortField(this, clazz, fieldID, val); + } void SetStaticIntField(jclass clazz, jfieldID fieldID, jint val) - { functions->SetStaticIntField(this, clazz, fieldID, val); } + { + functions->SetStaticIntField(this, clazz, fieldID, val); + } void SetStaticLongField(jclass clazz, jfieldID fieldID, jlong val) - { functions->SetStaticLongField(this, clazz, fieldID, val); } + { + functions->SetStaticLongField(this, clazz, fieldID, val); + } void SetStaticFloatField(jclass clazz, jfieldID fieldID, jfloat val) - { functions->SetStaticFloatField(this, clazz, fieldID, val); } + { + functions->SetStaticFloatField(this, clazz, fieldID, val); + } void SetStaticDoubleField(jclass clazz, jfieldID fieldID, jdouble val) - { functions->SetStaticDoubleField(this, clazz, fieldID, val); } + { + functions->SetStaticDoubleField(this, clazz, fieldID, val); + } - jstring NewString(const jchar* unicodeChars, jsize len) - { return functions->NewString(this, unicodeChars, len); } + jstring NewString(const jchar *unicodeChars, jsize len) + { + return functions->NewString(this, unicodeChars, len); + } jsize GetStringLength(jstring string) - { return functions->GetStringLength(this, string); } + { + return functions->GetStringLength(this, string); + } - const jchar* GetStringChars(jstring string, jboolean* isCopy) - { return functions->GetStringChars(this, string, isCopy); } + const jchar *GetStringChars(jstring string, jboolean *isCopy) + { + return functions->GetStringChars(this, string, isCopy); + } - void ReleaseStringChars(jstring string, const jchar* chars) - { functions->ReleaseStringChars(this, string, chars); } + void ReleaseStringChars(jstring string, const jchar *chars) + { + functions->ReleaseStringChars(this, string, chars); + } - jstring NewStringUTF(const char* bytes) - { return functions->NewStringUTF(this, bytes); } + jstring NewStringUTF(const char *bytes) + { + return functions->NewStringUTF(this, bytes); + } jsize GetStringUTFLength(jstring string) - { return functions->GetStringUTFLength(this, string); } + { + return functions->GetStringUTFLength(this, string); + } - const char* GetStringUTFChars(jstring string, jboolean* isCopy) - { return functions->GetStringUTFChars(this, string, isCopy); } + const char *GetStringUTFChars(jstring string, jboolean *isCopy) + { + return functions->GetStringUTFChars(this, string, isCopy); + } - void ReleaseStringUTFChars(jstring string, const char* utf) - { functions->ReleaseStringUTFChars(this, string, utf); } + void ReleaseStringUTFChars(jstring string, const char *utf) + { + functions->ReleaseStringUTFChars(this, string, utf); + } jsize GetArrayLength(jarray array) - { return functions->GetArrayLength(this, array); } + { + return functions->GetArrayLength(this, array); + } jobjectArray NewObjectArray(jsize length, jclass elementClass, - jobject initialElement) - { return functions->NewObjectArray(this, length, elementClass, - initialElement); } + jobject initialElement) + { + return functions->NewObjectArray(this, length, elementClass, + initialElement); + } jobject GetObjectArrayElement(jobjectArray array, jsize index) - { return functions->GetObjectArrayElement(this, array, index); } + { + return functions->GetObjectArrayElement(this, array, index); + } void SetObjectArrayElement(jobjectArray array, jsize index, jobject val) - { functions->SetObjectArrayElement(this, array, index, val); } + { + functions->SetObjectArrayElement(this, array, index, val); + } jbooleanArray NewBooleanArray(jsize length) - { return functions->NewBooleanArray(this, length); } + { + return functions->NewBooleanArray(this, length); + } jbyteArray NewByteArray(jsize length) - { return functions->NewByteArray(this, length); } + { + return functions->NewByteArray(this, length); + } jcharArray NewCharArray(jsize length) - { return functions->NewCharArray(this, length); } + { + return functions->NewCharArray(this, length); + } jshortArray NewShortArray(jsize length) - { return functions->NewShortArray(this, length); } + { + return functions->NewShortArray(this, length); + } jintArray NewIntArray(jsize length) - { return functions->NewIntArray(this, length); } + { + return functions->NewIntArray(this, length); + } jlongArray NewLongArray(jsize length) - { return functions->NewLongArray(this, length); } + { + return functions->NewLongArray(this, length); + } jfloatArray NewFloatArray(jsize length) - { return functions->NewFloatArray(this, length); } + { + return functions->NewFloatArray(this, length); + } jdoubleArray NewDoubleArray(jsize length) - { return functions->NewDoubleArray(this, length); } - - jboolean* GetBooleanArrayElements(jbooleanArray array, jboolean* isCopy) - { return functions->GetBooleanArrayElements(this, array, isCopy); } - jbyte* GetByteArrayElements(jbyteArray array, jboolean* isCopy) - { return functions->GetByteArrayElements(this, array, isCopy); } - jchar* GetCharArrayElements(jcharArray array, jboolean* isCopy) - { return functions->GetCharArrayElements(this, array, isCopy); } - jshort* GetShortArrayElements(jshortArray array, jboolean* isCopy) - { return functions->GetShortArrayElements(this, array, isCopy); } - jint* GetIntArrayElements(jintArray array, jboolean* isCopy) - { return functions->GetIntArrayElements(this, array, isCopy); } - jlong* GetLongArrayElements(jlongArray array, jboolean* isCopy) - { return functions->GetLongArrayElements(this, array, isCopy); } - jfloat* GetFloatArrayElements(jfloatArray array, jboolean* isCopy) - { return functions->GetFloatArrayElements(this, array, isCopy); } - jdouble* GetDoubleArrayElements(jdoubleArray array, jboolean* isCopy) - { return functions->GetDoubleArrayElements(this, array, isCopy); } - - void ReleaseBooleanArrayElements(jbooleanArray array, jboolean* elems, - jint mode) - { functions->ReleaseBooleanArrayElements(this, array, elems, mode); } - void ReleaseByteArrayElements(jbyteArray array, jbyte* elems, - jint mode) - { functions->ReleaseByteArrayElements(this, array, elems, mode); } - void ReleaseCharArrayElements(jcharArray array, jchar* elems, - jint mode) - { functions->ReleaseCharArrayElements(this, array, elems, mode); } - void ReleaseShortArrayElements(jshortArray array, jshort* elems, - jint mode) - { functions->ReleaseShortArrayElements(this, array, elems, mode); } - void ReleaseIntArrayElements(jintArray array, jint* elems, - jint mode) - { functions->ReleaseIntArrayElements(this, array, elems, mode); } - void ReleaseLongArrayElements(jlongArray array, jlong* elems, - jint mode) - { functions->ReleaseLongArrayElements(this, array, elems, mode); } - void ReleaseFloatArrayElements(jfloatArray array, jfloat* elems, - jint mode) - { functions->ReleaseFloatArrayElements(this, array, elems, mode); } - void ReleaseDoubleArrayElements(jdoubleArray array, jdouble* elems, - jint mode) - { functions->ReleaseDoubleArrayElements(this, array, elems, mode); } + { + return functions->NewDoubleArray(this, length); + } + + jboolean *GetBooleanArrayElements(jbooleanArray array, jboolean *isCopy) + { + return functions->GetBooleanArrayElements(this, array, isCopy); + } + jbyte *GetByteArrayElements(jbyteArray array, jboolean *isCopy) + { + return functions->GetByteArrayElements(this, array, isCopy); + } + jchar *GetCharArrayElements(jcharArray array, jboolean *isCopy) + { + return functions->GetCharArrayElements(this, array, isCopy); + } + jshort *GetShortArrayElements(jshortArray array, jboolean *isCopy) + { + return functions->GetShortArrayElements(this, array, isCopy); + } + jint *GetIntArrayElements(jintArray array, jboolean *isCopy) + { + return functions->GetIntArrayElements(this, array, isCopy); + } + jlong *GetLongArrayElements(jlongArray array, jboolean *isCopy) + { + return functions->GetLongArrayElements(this, array, isCopy); + } + jfloat *GetFloatArrayElements(jfloatArray array, jboolean *isCopy) + { + return functions->GetFloatArrayElements(this, array, isCopy); + } + jdouble *GetDoubleArrayElements(jdoubleArray array, jboolean *isCopy) + { + return functions->GetDoubleArrayElements(this, array, isCopy); + } + + void ReleaseBooleanArrayElements(jbooleanArray array, jboolean *elems, + jint mode) + { + functions->ReleaseBooleanArrayElements(this, array, elems, mode); + } + void ReleaseByteArrayElements(jbyteArray array, jbyte *elems, + jint mode) + { + functions->ReleaseByteArrayElements(this, array, elems, mode); + } + void ReleaseCharArrayElements(jcharArray array, jchar *elems, + jint mode) + { + functions->ReleaseCharArrayElements(this, array, elems, mode); + } + void ReleaseShortArrayElements(jshortArray array, jshort *elems, + jint mode) + { + functions->ReleaseShortArrayElements(this, array, elems, mode); + } + void ReleaseIntArrayElements(jintArray array, jint *elems, + jint mode) + { + functions->ReleaseIntArrayElements(this, array, elems, mode); + } + void ReleaseLongArrayElements(jlongArray array, jlong *elems, + jint mode) + { + functions->ReleaseLongArrayElements(this, array, elems, mode); + } + void ReleaseFloatArrayElements(jfloatArray array, jfloat *elems, + jint mode) + { + functions->ReleaseFloatArrayElements(this, array, elems, mode); + } + void ReleaseDoubleArrayElements(jdoubleArray array, jdouble *elems, + jint mode) + { + functions->ReleaseDoubleArrayElements(this, array, elems, mode); + } void GetBooleanArrayRegion(jbooleanArray array, jsize start, jsize len, - jboolean* buf) - { functions->GetBooleanArrayRegion(this, array, start, len, buf); } + jboolean *buf) + { + functions->GetBooleanArrayRegion(this, array, start, len, buf); + } void GetByteArrayRegion(jbyteArray array, jsize start, jsize len, - jbyte* buf) - { functions->GetByteArrayRegion(this, array, start, len, buf); } + jbyte *buf) + { + functions->GetByteArrayRegion(this, array, start, len, buf); + } void GetCharArrayRegion(jcharArray array, jsize start, jsize len, - jchar* buf) - { functions->GetCharArrayRegion(this, array, start, len, buf); } + jchar *buf) + { + functions->GetCharArrayRegion(this, array, start, len, buf); + } void GetShortArrayRegion(jshortArray array, jsize start, jsize len, - jshort* buf) - { functions->GetShortArrayRegion(this, array, start, len, buf); } + jshort *buf) + { + functions->GetShortArrayRegion(this, array, start, len, buf); + } void GetIntArrayRegion(jintArray array, jsize start, jsize len, - jint* buf) - { functions->GetIntArrayRegion(this, array, start, len, buf); } + jint *buf) + { + functions->GetIntArrayRegion(this, array, start, len, buf); + } void GetLongArrayRegion(jlongArray array, jsize start, jsize len, - jlong* buf) - { functions->GetLongArrayRegion(this, array, start, len, buf); } + jlong *buf) + { + functions->GetLongArrayRegion(this, array, start, len, buf); + } void GetFloatArrayRegion(jfloatArray array, jsize start, jsize len, - jfloat* buf) - { functions->GetFloatArrayRegion(this, array, start, len, buf); } + jfloat *buf) + { + functions->GetFloatArrayRegion(this, array, start, len, buf); + } void GetDoubleArrayRegion(jdoubleArray array, jsize start, jsize len, - jdouble* buf) - { functions->GetDoubleArrayRegion(this, array, start, len, buf); } + jdouble *buf) + { + functions->GetDoubleArrayRegion(this, array, start, len, buf); + } void SetBooleanArrayRegion(jbooleanArray array, jsize start, jsize len, - const jboolean* buf) - { functions->SetBooleanArrayRegion(this, array, start, len, buf); } + const jboolean *buf) + { + functions->SetBooleanArrayRegion(this, array, start, len, buf); + } void SetByteArrayRegion(jbyteArray array, jsize start, jsize len, - const jbyte* buf) - { functions->SetByteArrayRegion(this, array, start, len, buf); } + const jbyte *buf) + { + functions->SetByteArrayRegion(this, array, start, len, buf); + } void SetCharArrayRegion(jcharArray array, jsize start, jsize len, - const jchar* buf) - { functions->SetCharArrayRegion(this, array, start, len, buf); } + const jchar *buf) + { + functions->SetCharArrayRegion(this, array, start, len, buf); + } void SetShortArrayRegion(jshortArray array, jsize start, jsize len, - const jshort* buf) - { functions->SetShortArrayRegion(this, array, start, len, buf); } + const jshort *buf) + { + functions->SetShortArrayRegion(this, array, start, len, buf); + } void SetIntArrayRegion(jintArray array, jsize start, jsize len, - const jint* buf) - { functions->SetIntArrayRegion(this, array, start, len, buf); } + const jint *buf) + { + functions->SetIntArrayRegion(this, array, start, len, buf); + } void SetLongArrayRegion(jlongArray array, jsize start, jsize len, - const jlong* buf) - { functions->SetLongArrayRegion(this, array, start, len, buf); } + const jlong *buf) + { + functions->SetLongArrayRegion(this, array, start, len, buf); + } void SetFloatArrayRegion(jfloatArray array, jsize start, jsize len, - const jfloat* buf) - { functions->SetFloatArrayRegion(this, array, start, len, buf); } + const jfloat *buf) + { + functions->SetFloatArrayRegion(this, array, start, len, buf); + } void SetDoubleArrayRegion(jdoubleArray array, jsize start, jsize len, - const jdouble* buf) - { functions->SetDoubleArrayRegion(this, array, start, len, buf); } + const jdouble *buf) + { + functions->SetDoubleArrayRegion(this, array, start, len, buf); + } - jint RegisterNatives(jclass clazz, const JNINativeMethod* methods, - jint nMethods) - { return functions->RegisterNatives(this, clazz, methods, nMethods); } + jint RegisterNatives(jclass clazz, const JNINativeMethod *methods, + jint nMethods) + { + return functions->RegisterNatives(this, clazz, methods, nMethods); + } jint UnregisterNatives(jclass clazz) - { return functions->UnregisterNatives(this, clazz); } + { + return functions->UnregisterNatives(this, clazz); + } jint MonitorEnter(jobject obj) - { return functions->MonitorEnter(this, obj); } + { + return functions->MonitorEnter(this, obj); + } jint MonitorExit(jobject obj) - { return functions->MonitorExit(this, obj); } + { + return functions->MonitorExit(this, obj); + } - jint GetJavaVM(JavaVM** vm) - { return functions->GetJavaVM(this, vm); } + jint GetJavaVM(JavaVM **vm) + { + return functions->GetJavaVM(this, vm); + } - void GetStringRegion(jstring str, jsize start, jsize len, jchar* buf) - { functions->GetStringRegion(this, str, start, len, buf); } + void GetStringRegion(jstring str, jsize start, jsize len, jchar *buf) + { + functions->GetStringRegion(this, str, start, len, buf); + } - void GetStringUTFRegion(jstring str, jsize start, jsize len, char* buf) - { return functions->GetStringUTFRegion(this, str, start, len, buf); } + void GetStringUTFRegion(jstring str, jsize start, jsize len, char *buf) + { + return functions->GetStringUTFRegion(this, str, start, len, buf); + } - void* GetPrimitiveArrayCritical(jarray array, jboolean* isCopy) - { return functions->GetPrimitiveArrayCritical(this, array, isCopy); } + void *GetPrimitiveArrayCritical(jarray array, jboolean *isCopy) + { + return functions->GetPrimitiveArrayCritical(this, array, isCopy); + } - void ReleasePrimitiveArrayCritical(jarray array, void* carray, jint mode) - { functions->ReleasePrimitiveArrayCritical(this, array, carray, mode); } + void ReleasePrimitiveArrayCritical(jarray array, void *carray, jint mode) + { + functions->ReleasePrimitiveArrayCritical(this, array, carray, mode); + } - const jchar* GetStringCritical(jstring string, jboolean* isCopy) - { return functions->GetStringCritical(this, string, isCopy); } + const jchar *GetStringCritical(jstring string, jboolean *isCopy) + { + return functions->GetStringCritical(this, string, isCopy); + } - void ReleaseStringCritical(jstring string, const jchar* carray) - { functions->ReleaseStringCritical(this, string, carray); } + void ReleaseStringCritical(jstring string, const jchar *carray) + { + functions->ReleaseStringCritical(this, string, carray); + } jweak NewWeakGlobalRef(jobject obj) - { return functions->NewWeakGlobalRef(this, obj); } + { + return functions->NewWeakGlobalRef(this, obj); + } void DeleteWeakGlobalRef(jweak obj) - { functions->DeleteWeakGlobalRef(this, obj); } + { + functions->DeleteWeakGlobalRef(this, obj); + } jboolean ExceptionCheck() - { return functions->ExceptionCheck(this); } + { + return functions->ExceptionCheck(this); + } - jobject NewDirectByteBuffer(void* address, jlong capacity) - { return functions->NewDirectByteBuffer(this, address, capacity); } + jobject NewDirectByteBuffer(void *address, jlong capacity) + { + return functions->NewDirectByteBuffer(this, address, capacity); + } - void* GetDirectBufferAddress(jobject buf) - { return functions->GetDirectBufferAddress(this, buf); } + void *GetDirectBufferAddress(jobject buf) + { + return functions->GetDirectBufferAddress(this, buf); + } jlong GetDirectBufferCapacity(jobject buf) - { return functions->GetDirectBufferCapacity(this, buf); } + { + return functions->GetDirectBufferCapacity(this, buf); + } /* added in JNI 1.6 */ jobjectRefType GetObjectRefType(jobject obj) - { return functions->GetObjectRefType(this, obj); } + { + return functions->GetObjectRefType(this, obj); + } #endif /*__cplusplus*/ }; - /* * JNI invocation interface. */ -struct JNIInvokeInterface { - void* reserved0; - void* reserved1; - void* reserved2; - - jint (*DestroyJavaVM)(JavaVM* vm); - jint (*AttachCurrentThread)(JavaVM* vm, JNIEnv** p_env, void* thr_args); - jint (*DetachCurrentThread)(JavaVM* vm); - jint (*GetEnv)(JavaVM* vm, void** p_env, jint version); - jint (*AttachCurrentThreadAsDaemon)(JavaVM* vm, JNIEnv** p_env, void* thr_args); +struct JNIInvokeInterface +{ + void *reserved0; + void *reserved1; + void *reserved2; + + jint (*DestroyJavaVM)(JavaVM *vm); + jint (*AttachCurrentThread)(JavaVM *vm, JNIEnv **p_env, void *thr_args); + jint (*DetachCurrentThread)(JavaVM *vm); + jint (*GetEnv)(JavaVM *vm, void **p_env, jint version); + jint (*AttachCurrentThreadAsDaemon)(JavaVM *vm, JNIEnv **p_env, void *thr_args); }; /* * C++ version. */ -struct _JavaVM { - const struct JNIInvokeInterface* functions; +struct _JavaVM +{ + const struct JNIInvokeInterface *functions; #if defined(__cplusplus) jint DestroyJavaVM() - { return functions->DestroyJavaVM(this); } - jint AttachCurrentThread(JNIEnv** p_env, void* thr_args) - { return functions->AttachCurrentThread(this, p_env, thr_args); } + { + return functions->DestroyJavaVM(this); + } + jint AttachCurrentThread(JNIEnv **p_env, void *thr_args) + { + return functions->AttachCurrentThread(this, p_env, thr_args); + } jint DetachCurrentThread() - { return functions->DetachCurrentThread(this); } - jint GetEnv(void** env, jint version) - { return functions->GetEnv(this, env, version); } - jint AttachCurrentThreadAsDaemon(JNIEnv** p_env, void* thr_args) - { return functions->AttachCurrentThreadAsDaemon(this, p_env, thr_args); } + { + return functions->DetachCurrentThread(this); + } + jint GetEnv(void **env, jint version) + { + return functions->GetEnv(this, env, version); + } + jint AttachCurrentThreadAsDaemon(JNIEnv **p_env, void *thr_args) + { + return functions->AttachCurrentThreadAsDaemon(this, p_env, thr_args); + } #endif /*__cplusplus*/ }; -struct JavaVMAttachArgs { - jint version; /* must be >= JNI_VERSION_1_2 */ - const char* name; /* NULL or name of thread as modified UTF-8 str */ - jobject group; /* global ref of a ThreadGroup object, or NULL */ +struct JavaVMAttachArgs +{ + jint version; /* must be >= JNI_VERSION_1_2 */ + const char *name; /* NULL or name of thread as modified UTF-8 str */ + jobject group; /* global ref of a ThreadGroup object, or NULL */ }; typedef struct JavaVMAttachArgs JavaVMAttachArgs; @@ -1079,67 +1423,68 @@ typedef struct JavaVMAttachArgs JavaVMAttachArgs; * JNI 1.2+ initialization. (As of 1.6, the pre-1.2 structures are no * longer supported.) */ -typedef struct JavaVMOption { - const char* optionString; - void* extraInfo; +typedef struct JavaVMOption +{ + const char *optionString; + void *extraInfo; } JavaVMOption; -typedef struct JavaVMInitArgs { - jint version; /* use JNI_VERSION_1_2 or later */ +typedef struct JavaVMInitArgs +{ + jint version; /* use JNI_VERSION_1_2 or later */ - jint nOptions; - JavaVMOption* options; - jboolean ignoreUnrecognized; + jint nOptions; + JavaVMOption *options; + jboolean ignoreUnrecognized; } JavaVMInitArgs; #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif -/* - * VM initialization functions. - * - * Note these are the only symbols exported for JNI by the VM. - */ + /* + * VM initialization functions. + * + * Note these are the only symbols exported for JNI by the VM. + */ -jint JNI_GetDefaultJavaVMInitArgs(void*); -jint JNI_CreateJavaVM(JavaVM**, JNIEnv**, void*); -jint JNI_GetCreatedJavaVMs(JavaVM**, jsize, jsize*); + jint JNI_GetDefaultJavaVMInitArgs(void *); + jint JNI_CreateJavaVM(JavaVM **, JNIEnv **, void *); + jint JNI_GetCreatedJavaVMs(JavaVM **, jsize, jsize *); #define JNIIMPORT -#define JNIEXPORT __attribute__ ((visibility ("default"))) +#define JNIEXPORT __attribute__((visibility("default"))) #define JNICALL -/* - * Prototypes for functions exported by loadable shared libs. These are - * called by JNI, not provided by JNI. - */ -JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved); -JNIEXPORT void JNI_OnUnload(JavaVM* vm, void* reserved); + /* + * Prototypes for functions exported by loadable shared libs. These are + * called by JNI, not provided by JNI. + */ + JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved); + JNIEXPORT void JNI_OnUnload(JavaVM *vm, void *reserved); #ifdef __cplusplus } #endif - /* * Manifest constants. */ -#define JNI_FALSE 0 -#define JNI_TRUE 1 +#define JNI_FALSE 0 +#define JNI_TRUE 1 #define JNI_VERSION_1_1 0x00010001 #define JNI_VERSION_1_2 0x00010002 #define JNI_VERSION_1_4 0x00010004 #define JNI_VERSION_1_6 0x00010006 -#define JNI_OK (0) /* no error */ -#define JNI_ERR (-1) /* generic error */ -#define JNI_EDETACHED (-2) /* thread detached from the VM */ -#define JNI_EVERSION (-3) /* JNI version error */ -#define JNI_ENOMEM (-4) /* Out of memory */ -#define JNI_EEXIST (-5) /* VM already created */ -#define JNI_EINVAL (-6) /* Invalid argument */ - -#define JNI_COMMIT 1 /* copy content, do not free buffer */ -#define JNI_ABORT 2 /* free buffer w/o copying back */ +#define JNI_OK (0) /* no error */ +#define JNI_ERR (-1) /* generic error */ +#define JNI_EDETACHED (-2) /* thread detached from the VM */ +#define JNI_EVERSION (-3) /* JNI version error */ +#define JNI_ENOMEM (-4) /* Out of memory */ +#define JNI_EEXIST (-5) /* VM already created */ +#define JNI_EINVAL (-6) /* Invalid argument */ +#define JNI_COMMIT 1 /* copy content, do not free buffer */ +#define JNI_ABORT 2 /* free buffer w/o copying back */ diff --git a/pkgs/jni/tool/generate_ffi_bindings.dart b/pkgs/jni/tool/generate_ffi_bindings.dart new file mode 100644 index 000000000..35b9db2b3 --- /dev/null +++ b/pkgs/jni/tool/generate_ffi_bindings.dart @@ -0,0 +1,68 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +// This script generates all FFIGEN-based bindings we require to use JNI, which +// includes some C wrappers over `JNIEnv` type and some Dart extension methods. + +import 'dart:io'; + +import 'package:logging/logging.dart'; +import 'package:args/args.dart'; + +import 'wrapper_generators/logging.dart'; +import 'wrapper_generators/generate_c_extensions.dart'; +import 'wrapper_generators/generate_dart_extensions.dart'; + +import 'package:ffigen/ffigen.dart' as ffigen; + +void main(List args) { + final levels = Map.fromEntries( + Level.LEVELS.map((l) => MapEntry(l.name.toLowerCase(), l)), + ); + final argParser = ArgParser() + ..addOption( + 'verbose', + defaultsTo: 'severe', + help: 'set ffigen log verbosity', + allowed: levels.keys, + ) + ..addFlag( + 'help', + negatable: false, + abbr: 'h', + defaultsTo: false, + help: 'display this help message', + ); + + final argResults = argParser.parse(args); + + if (argResults['help']) { + stderr.writeln('Generates FFI bindings required for package:jni'); + stderr.writeln(argParser.usage); + exitCode = 1; + return; + } + + hierarchicalLoggingEnabled = true; + Logger.root.level = levels[argResults['verbose']]!; + logger.level = Level.INFO; + Logger.root.onRecord.listen((record) { + stderr.writeln('${record.level.name}: ${record.message}'); + }); + + logger.info("Generating C wrappers"); + final minimalConfig = ffigen.Config.fromFile(File('ffigen_exts.yaml')); + final minimalLibrary = ffigen.parse(minimalConfig); + generateCWrappers(minimalLibrary); + + logger.info("Generating FFI bindings for package:jni"); + + final config = ffigen.Config.fromFile(File('ffigen.yaml')); + final library = ffigen.parse(config); + final outputFile = File(config.output); + library.generateFile(outputFile); + + logger.info("Generating Dart extensions"); + generateDartExtensions(library); +} diff --git a/pkgs/jni/tool/wrapper_generators/ffigen_util.dart b/pkgs/jni/tool/wrapper_generators/ffigen_util.dart new file mode 100644 index 000000000..2b234f6a9 --- /dev/null +++ b/pkgs/jni/tool/wrapper_generators/ffigen_util.dart @@ -0,0 +1,50 @@ +// 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:ffigen/src/code_generator/writer.dart'; +import 'package:ffigen/src/code_generator.dart'; + +final dummyWriter = Writer( + lookUpBindings: [], + ffiNativeBindings: [], + noLookUpBindings: [], + className: 'unused', +); + +/// Find compound having [name] in [library]. +Compound findCompound(library, String name) { + return library.bindings.firstWhere((element) => element.name == name) + as Compound; +} + +const preamble = ''' +// Auto generated file. Do not edit. + +// This is generated from JNI header in Android NDK. License for the same is +// provided below. + +/* + * Copyright (C) 2006 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * JNI specification, as defined by Sun: + * http://java.sun.com/javase/6/docs/technotes/guides/jni/spec/jniTOC.html + * + * Everything here is expected to be VM-neutral. + */ + +'''; diff --git a/pkgs/jni/tool/wrapper_generators/generate_c_extensions.dart b/pkgs/jni/tool/wrapper_generators/generate_c_extensions.dart new file mode 100644 index 000000000..ef907bf16 --- /dev/null +++ b/pkgs/jni/tool/wrapper_generators/generate_c_extensions.dart @@ -0,0 +1,296 @@ +// 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 'dart:io'; + +import 'package:ffigen/src/code_generator.dart'; + +import 'ffigen_util.dart'; +import 'logging.dart'; + +class Paths { + static final currentDir = Directory.current.uri; + static final src = currentDir.resolve("src/"); + static final thirdParty = src.resolve("third_party/"); + static final globalJniEnvH = thirdParty.resolve("global_jni_env.h"); + static final globalJniEnvC = thirdParty.resolve("global_jni_env.c"); + static final bindingsDir = currentDir.resolve("lib/src/third_party/"); + static final envExtensions = bindingsDir.resolve("env_extensions.dart"); +} + +/// Name of variable used in wrappers to hold the result. +const resultVar = '_result'; + +/// Name of variable used in wrappers to hold the exception. +const errorVar = '_exception'; + +/// Name of JNIEnv struct definition in JNI headers. +const envType = 'JNINativeInterface'; + +/// Name of wrapper to JNIEnv +const wrapperName = 'GlobalJniEnv'; + +const wrapperIncludes = ''' +#include "global_jni_env.h" + +'''; + +const wrapperDeclIncludes = ''' +#include +#include "../dartjni.h" + +'''; + +const wrapperGetter = ''' +FFI_PLUGIN_EXPORT +$wrapperName* GetGlobalEnv() { + if (jni->jvm == NULL) { + return NULL; + } + return &globalJniEnv; +} +'''; + +const wrapperGetterDecl = ''' +FFI_PLUGIN_EXPORT $wrapperName* GetGlobalEnv(); +'''; + +/// Get C name of a type from its ffigen representation. +String getCType(Type type) { + if (type is PointerType) { + return '${getCType(type.child)}*'; + } + final cType = type.getCType(dummyWriter); + const specialCaseMappings = { + 'JNIEnv1': 'JNIEnv', + 'ffi.Char': 'char', + 'ffi.Void': 'void', + 'ffi.Int': 'int', + 'ffi.Int32': 'int32_t', + }; + return specialCaseMappings[cType] ?? cType; +} + +/// Get type of wrapping function for a JNIEnv function. +FunctionType getGlobalJniEnvFunctionType(FunctionType ft) { + return FunctionType( + returnType: ft.returnType, + parameters: ft.parameters.sublist(1), + ); +} + +// Returns declaration of function field in GlobalJniEnv struct +String getFunctionFieldDecl( + Member field, +) { + final fieldType = field.type; + if (fieldType is PointerType && fieldType.child is NativeFunc) { + final nativeFunc = fieldType.child as NativeFunc; + final functionType = getGlobalJniEnvFunctionType(nativeFunc.type); + final resultWrapper = getResultWrapper(getCType(functionType.returnType)); + final name = field.name; + final params = functionType.parameters + .map((param) => '${getCType(param.type)} ${param.name}') + .join(', '); + return ('${resultWrapper.returnType} (*$name)($params);'); + } else { + return 'void* ${field.name};'; + } +} + +String getWrapperFuncName(Member field) { + return 'globalEnv_${field.name}'; +} + +class ResultWrapper { + String returnType, onResult, onError; + ResultWrapper.withResultAndError( + this.returnType, this.onResult, this.onError); + ResultWrapper.unionType( + String returnType, + String defaultValue, + ) : this.withResultAndError( + returnType, + '($returnType){.value = $resultVar, .exception = NULL}', + '($returnType){.value = $defaultValue, .exception = $errorVar}', + ); + ResultWrapper.forJValueField(String fieldChar) + : this.withResultAndError( + 'JniResult', + '(JniResult){.value = {.$fieldChar = $resultVar}, .exception = NULL}', + '(JniResult){.value = {.j = 0}, .exception = $errorVar}', + ); +} + +ResultWrapper getResultWrapper(String returnType) { + if (returnType.endsWith("*")) { + return ResultWrapper.unionType('JniPointerResult', 'NULL'); + } + + final jobjectWrapper = ResultWrapper.forJValueField('l'); + if (returnType.endsWith('Array')) { + return jobjectWrapper; + } + + const jfields = { + 'jboolean': 'z', + 'jbyte': 'b', + 'jshort': 's', + 'jchar': 'c', + 'jint': 'i', + 'jsize': 'i', // jsize is an alias to jint + 'jfloat': 'f', + 'jlong': 'j', + 'jdouble': 'd', + 'jobject': 'l', + 'jweak': 'l', + 'jarray': 'l', + 'jstring': 'l', + 'jthrowable': 'l', + }; + + switch (returnType) { + case 'void': + return ResultWrapper.withResultAndError( + 'jthrowable', + 'NULL', + errorVar, + ); + case 'jmethodID': + case 'jfieldID': + return ResultWrapper.unionType('JniPointerResult', 'NULL'); + case 'jclass': + return ResultWrapper.unionType('JniClassLookupResult', 'NULL'); + case 'int32_t': + return ResultWrapper.forJValueField('i'); + default: + if (jfields.containsKey(returnType)) { + return ResultWrapper.forJValueField(jfields[returnType]!); + } + throw 'Unknown type $returnType for return type'; + } +} + +bool isJRefType(String type) { + // No need to include jweak here, its only returned by ref-related functions. + const refTypes = { + 'jclass', + 'jobject', + 'jstring', + 'jthrowable', + 'jarray', + 'jweak' + }; + return (type.startsWith('j') && type.endsWith('Array')) || + refTypes.contains(type); +} + +const refFunctions = { + 'NewGlobalRef', + 'DeleteGlobalRef', + 'NewLocalRef', + 'DeleteLocalRef', + 'NewWeakGlobalRef', + 'DeleteWeakGlobalRef', +}; + +/// These return const ptrs so the assignment statement needs to be +/// adjusted in the wrapper. +const constBufferReturningFunctions = { + 'GetStringChars', + 'GetStringUTFChars', + 'GetStringCritical', +}; + +/// Methods which do not throw exceptions, and thus not need to be checked +const _noCheckException = { + 'GetVersion', + 'ExceptionClear', + 'ExceptionDescribe', +}; + +String? getWrapperFunc(Member field) { + final fieldType = field.type; + if (fieldType is PointerType && fieldType.child is NativeFunc) { + final functionType = (fieldType.child as NativeFunc).type; + if (functionType.parameters.first.name.isEmpty) { + return null; + } + + final outerFunctionType = getGlobalJniEnvFunctionType(functionType); + final wrapperName = getWrapperFuncName(field); + final returnType = getCType(outerFunctionType.returnType); + final params = outerFunctionType.parameters + .map((param) => '${getCType(param.type)} ${param.name}') + .join(', '); + var returnCapture = returnType == 'void' ? '' : '$returnType $resultVar ='; + if (constBufferReturningFunctions.contains(field.name)) { + returnCapture = 'const $returnCapture'; + } + final callParams = [ + 'jniEnv', + ...(outerFunctionType.parameters.map((param) => param.name).toList()) + ].join(', '); + final resultWrapper = getResultWrapper(returnType); + + var convertRef = ''; + if (isJRefType(returnType) && !refFunctions.contains(field.name)) { + convertRef = ' $resultVar = to_global_ref($resultVar);\n'; + } + final exceptionCheck = _noCheckException.contains(field.name) + ? '' + : ' jthrowable $errorVar = check_exception();\n' + ' if ($errorVar != NULL) {\n' + ' return ${resultWrapper.onError};\n' + ' }\n'; + return '${resultWrapper.returnType} $wrapperName($params) {\n' + ' attach_thread();\n' + ' $returnCapture (*jniEnv)->${field.name}($callParams);\n' + '$exceptionCheck' + '$convertRef' + ' return ${resultWrapper.onResult};\n' + '}\n'; + } + return null; +} + +void writeGlobalJniEnvWrapper(Library library) { + final jniEnvType = findCompound(library, envType); + + final fieldDecls = jniEnvType.members.map(getFunctionFieldDecl).join('\n'); + final structDecl = + 'typedef struct $wrapperName {\n$fieldDecls\n} $wrapperName;\n'; + File.fromUri(Paths.globalJniEnvH).writeAsStringSync( + '$preamble$wrapperDeclIncludes$structDecl$wrapperGetterDecl'); + + final functionWrappers = StringBuffer(); + final structInst = StringBuffer('$wrapperName globalJniEnv = {\n'); + for (final member in jniEnvType.members) { + final wrapper = getWrapperFunc(member); + if (wrapper == null) { + structInst.write('.${member.name} = NULL,\n'); + } else { + structInst.write('.${member.name} = ${getWrapperFuncName(member)},\n'); + functionWrappers.write('$wrapper\n'); + } + } + structInst.write('};'); + File.fromUri(Paths.globalJniEnvC).writeAsStringSync( + '$preamble$wrapperIncludes$functionWrappers$structInst$wrapperGetter'); +} + +void executeClangFormat(List files) { + final paths = files.map((u) => u.toFilePath()).toList(); + logger.info('execute clang-format -i ${paths.join(" ")}'); + final format = Process.runSync('clang-format', ['-i', ...paths]); + if (format.exitCode != 0) { + stderr.writeln('clang-format exited with ${format.exitCode}'); + stderr.writeln(format.stderr); + } +} + +void generateCWrappers(Library minimalLibrary) { + writeGlobalJniEnvWrapper(minimalLibrary); + executeClangFormat([Paths.globalJniEnvC, Paths.globalJniEnvH]); +} diff --git a/pkgs/jni/tool/wrapper_generators/generate_dart_extensions.dart b/pkgs/jni/tool/wrapper_generators/generate_dart_extensions.dart new file mode 100644 index 000000000..1ec422d93 --- /dev/null +++ b/pkgs/jni/tool/wrapper_generators/generate_dart_extensions.dart @@ -0,0 +1,215 @@ +// 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 'dart:io'; + +import 'package:collection/collection.dart'; +import 'package:ffigen/src/code_generator.dart'; + +import 'ffigen_util.dart'; +import 'logging.dart'; + +class Paths { + static final currentDir = Directory.current.uri; + static final bindingsDir = currentDir.resolve("lib/src/third_party/"); + // Contains extensions for our C wrapper types. + static final globalEnvExts = + bindingsDir.resolve("global_env_extensions.dart"); + // Contains extensions for JNI's struct types. + static final localEnvExts = + bindingsDir.resolve("jnienv_javavm_extensions.dart"); +} + +void executeDartFormat(List files) { + final paths = files.map((u) => u.toFilePath()).toList(); + logger.info('execute dart format ${paths.join(" ")}'); + final format = Process.runSync('dart', ['format', ...paths]); + if (format.exitCode != 0) { + logger.severe('dart format exited with ${format.exitCode}'); + stderr.writeln(format.stderr); + } +} + +const globalEnvType = 'GlobalJniEnv'; +const localEnvType = 'JNINativeInterface'; +const jvmType = 'JNIInvokeInterface'; + +String getCheckedGetter(Type returnType) { + if (returnType is PointerType) { + final child = returnType.child.getCType(dummyWriter); + return 'getPointer<$child>()'; + } + final cType = returnType.getCType(dummyWriter); + if (cType.endsWith("ArrayPtr")) { + return 'object'; + } + const mappings = { + 'JBooleanMarker': 'boolean', + 'JByteMarker': 'byte', + 'JShortMarker': 'short', + 'JCharMarker': 'char', + 'JIntMarker': 'integer', + 'JSizeMarker': 'integer', // jsize is aliased to jint + 'JLongMarker': 'long', + 'JFloatMarker': 'float', + 'JDoubleMarker': 'doubleFloat', + 'JObjectPtr': 'object', + 'JThrowablePtr': 'object', + 'JStringPtr': 'object', + 'JClassPtr': 'value', + 'JFieldIDPtr': 'fieldID', + 'JMethodIDPtr': 'methodID', + 'ffi.Int32': 'integer', + 'ffi.Void': 'check()', + 'JWeakPtr': 'object', + }; + if (mappings.containsKey(cType)) { + return mappings[cType]!; + } + throw 'Unknown return type: $cType'; +} + +String? getGlobalEnvExtensionFunction(Member field, Type? checkedReturnType) { + final fieldType = field.type; + if (fieldType is PointerType && fieldType.child is NativeFunc) { + final nativeFunc = fieldType.child as NativeFunc; + final functionType = nativeFunc.type; + final returnType = functionType.returnType; + var params = functionType.parameters; + if (params.first.name.isEmpty) { + return null; + } + + // Remove env parameter + params = params.sublist(1); + + final signature = params + .map((p) => '${p.type.getDartType(dummyWriter)} ${p.name}') + .join(', '); + + final dartType = + FunctionType(returnType: checkedReturnType!, parameters: params) + .getDartType(dummyWriter); + final callArgs = params.map((p) => p.name).join(', '); + final checkedGetter = getCheckedGetter(returnType); + var returns = returnType.getDartType(dummyWriter); + if (checkedGetter == 'boolean') { + returns = 'bool'; + } + return '$returns ${field.name}($signature) => ' + 'ref.${field.name}.asFunction<$dartType>()($callArgs)' + '.$checkedGetter;\n'; + } + return null; +} + +void writeDartExtensions(Library library) { + const header = ''' +// ignore_for_file: non_constant_identifier_names +// coverage:ignore-file + +import "dart:ffi" as ffi;\n +import "jni_bindings_generated.dart"; + +'''; + const importAccessors = ''' +import "../accessors.dart"; + +'''; + + final globalEnvExtension = getGlobalEnvExtension(library); + final accessorExtension = + getFunctionPointerExtension(library, 'JniAccessors'); + final envExtension = getFunctionPointerExtension( + library, + 'JniEnv', + indirect: true, + implicitThis: true, + ); + final jvmExtension = getFunctionPointerExtension( + library, + 'JavaVM', + indirect: true, + implicitThis: true, + ); + File.fromUri(Paths.globalEnvExts).writeAsStringSync(preamble + + header + + importAccessors + + globalEnvExtension + + accessorExtension); + File.fromUri(Paths.localEnvExts) + .writeAsStringSync(preamble + header + envExtension + jvmExtension); +} + +String getGlobalEnvExtension( + Library library, +) { + final env = findCompound(library, localEnvType); + final globalEnv = findCompound(library, globalEnvType); + final checkedReturnTypes = {}; + for (var field in globalEnv.members) { + final fieldType = field.type; + if (fieldType is PointerType && fieldType.child is NativeFunc) { + checkedReturnTypes[field.name] = + (fieldType.child as NativeFunc).type.returnType; + } + } + final extensionFunctions = env.members + .map((m) => getGlobalEnvExtensionFunction(m, checkedReturnTypes[m.name])) + .whereNotNull() + .join('\n'); + return 'extension EnvExtension on ffi.Pointer<$globalEnvType> ' + '{$extensionFunctions}'; +} + +String? getFunctionPointerExtensionFunction(Member field, + {bool indirect = false, bool implicitThis = false}) { + final fieldType = field.type; + if (fieldType is PointerType && fieldType.child is NativeFunc) { + final nativeFunc = fieldType.child as NativeFunc; + final functionType = nativeFunc.type; + final returnType = functionType.returnType; + final params = functionType.parameters; + if (params.first.name.isEmpty) { + return null; + } + + final visibleParams = implicitThis ? params.sublist(1) : params; + + final signature = visibleParams + .map((p) => '${p.type.getDartType(dummyWriter)} ${p.name}') + .join(', '); + + final dartType = FunctionType(returnType: returnType, parameters: params) + .getDartType(dummyWriter); + final callArgs = [ + if (implicitThis) 'this', + ...visibleParams.map((p) => p.name) + ].join(', '); + final returns = returnType.getDartType(dummyWriter); + final dereference = indirect ? 'value.ref' : 'ref'; + return '$returns ${field.name}($signature) => ' + '$dereference.${field.name}.asFunction<$dartType>()($callArgs);\n'; + } + return null; +} + +String getFunctionPointerExtension(Library library, String type, + {bool indirect = false, bool implicitThis = false}) { + final typeBinding = + library.bindings.firstWhere((b) => b.name == type) as Type; + final compound = typeBinding.typealiasType.baseType as Compound; + final extensionFunctions = compound.members + .map((f) => getFunctionPointerExtensionFunction(f, + indirect: indirect, implicitThis: implicitThis)) + .whereNotNull() + .join('\n'); + return 'extension ${type}Extension on ffi.Pointer<$type> ' + '{$extensionFunctions}'; +} + +void generateDartExtensions(Library library) { + writeDartExtensions(library); + executeDartFormat([Paths.globalEnvExts, Paths.localEnvExts]); +} diff --git a/pkgs/jni/tool/wrapper_generators/logging.dart b/pkgs/jni/tool/wrapper_generators/logging.dart new file mode 100644 index 000000000..386f5c69d --- /dev/null +++ b/pkgs/jni/tool/wrapper_generators/logging.dart @@ -0,0 +1,7 @@ +// 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:logging/logging.dart'; + +final logger = Logger('ffi_wrappers_generator'); diff --git a/pkgs/jnigen/example/in_app_java/src/android_utils/android_utils.c b/pkgs/jnigen/example/in_app_java/src/android_utils/android_utils.c index 65bbd7b5b..0fef6525d 100644 --- a/pkgs/jnigen/example/in_app_java/src/android_utils/android_utils.c +++ b/pkgs/jnigen/example/in_app_java/src/android_utils/android_utils.c @@ -5,12 +5,12 @@ #include "jni.h" thread_local JNIEnv* jniEnv; -JniContext jni; +JniContext* jni; -JniContext (*context_getter)(void); +JniContext* (*context_getter)(void); JNIEnv* (*env_getter)(void); -void setJniGetters(JniContext (*cg)(void), JNIEnv* (*eg)(void)) { +void setJniGetters(JniContext* (*cg)(void), JNIEnv* (*eg)(void)) { context_getter = cg; env_getter = eg; } @@ -24,17 +24,18 @@ JniResult AndroidUtils__showToast(jobject mainActivity, jobject text, int32_t duration) { load_env(); - load_class_gr(&_c_AndroidUtils, "com/example/in_app_java/AndroidUtils"); + load_class_global_ref(&_c_AndroidUtils, + "com/example/in_app_java/AndroidUtils"); if (_c_AndroidUtils == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method(_c_AndroidUtils, &_m_AndroidUtils__showToast, "showToast", "(Landroid/app/Activity;Ljava/lang/CharSequence;I)V"); if (_m_AndroidUtils__showToast == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallStaticVoidMethod(jniEnv, _c_AndroidUtils, _m_AndroidUtils__showToast, mainActivity, text, duration); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } // androidx.emoji2.text.EmojiCompat @@ -44,17 +45,17 @@ jmethodID _m_EmojiCompat__init = NULL; FFI_PLUGIN_EXPORT JniResult EmojiCompat__init(jobject context) { load_env(); - load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + load_class_global_ref(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); if (_c_EmojiCompat == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method( _c_EmojiCompat, &_m_EmojiCompat__init, "init", "(Landroid/content/Context;)Landroidx/emoji2/text/EmojiCompat;"); if (_m_EmojiCompat__init == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_EmojiCompat, _m_EmojiCompat__init, context); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -62,18 +63,18 @@ jmethodID _m_EmojiCompat__init1 = NULL; FFI_PLUGIN_EXPORT JniResult EmojiCompat__init1(jobject context, jobject defaultFactory) { load_env(); - load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + load_class_global_ref(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); if (_c_EmojiCompat == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method(_c_EmojiCompat, &_m_EmojiCompat__init1, "init", "(Landroid/content/Context;Landroidx/emoji2/text/" "DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory;" ")Landroidx/emoji2/text/EmojiCompat;"); if (_m_EmojiCompat__init1 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_EmojiCompat, _m_EmojiCompat__init1, context, defaultFactory); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -81,17 +82,17 @@ jmethodID _m_EmojiCompat__init2 = NULL; FFI_PLUGIN_EXPORT JniResult EmojiCompat__init2(jobject config) { load_env(); - load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + load_class_global_ref(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); if (_c_EmojiCompat == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method(_c_EmojiCompat, &_m_EmojiCompat__init2, "init", "(Landroidx/emoji2/text/EmojiCompat$Config;)Landroidx/" "emoji2/text/EmojiCompat;"); if (_m_EmojiCompat__init2 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_EmojiCompat, _m_EmojiCompat__init2, config); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -99,33 +100,33 @@ jmethodID _m_EmojiCompat__isConfigured = NULL; FFI_PLUGIN_EXPORT JniResult EmojiCompat__isConfigured() { load_env(); - load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + load_class_global_ref(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); if (_c_EmojiCompat == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method(_c_EmojiCompat, &_m_EmojiCompat__isConfigured, "isConfigured", "()Z"); if (_m_EmojiCompat__isConfigured == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; uint8_t _result = (*jniEnv)->CallStaticBooleanMethod( jniEnv, _c_EmojiCompat, _m_EmojiCompat__isConfigured); - return (JniResult){.result = {.z = _result}, .exception = check_exception()}; + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; } jmethodID _m_EmojiCompat__reset = NULL; FFI_PLUGIN_EXPORT JniResult EmojiCompat__reset(jobject config) { load_env(); - load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + load_class_global_ref(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); if (_c_EmojiCompat == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method(_c_EmojiCompat, &_m_EmojiCompat__reset, "reset", "(Landroidx/emoji2/text/EmojiCompat$Config;)Landroidx/" "emoji2/text/EmojiCompat;"); if (_m_EmojiCompat__reset == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_EmojiCompat, _m_EmojiCompat__reset, config); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -133,17 +134,17 @@ jmethodID _m_EmojiCompat__reset1 = NULL; FFI_PLUGIN_EXPORT JniResult EmojiCompat__reset1(jobject emojiCompat) { load_env(); - load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + load_class_global_ref(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); if (_c_EmojiCompat == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method( _c_EmojiCompat, &_m_EmojiCompat__reset1, "reset", "(Landroidx/emoji2/text/EmojiCompat;)Landroidx/emoji2/text/EmojiCompat;"); if (_m_EmojiCompat__reset1 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_EmojiCompat, _m_EmojiCompat__reset1, emojiCompat); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -151,34 +152,34 @@ jmethodID _m_EmojiCompat__skipDefaultConfigurationLookup = NULL; FFI_PLUGIN_EXPORT JniResult EmojiCompat__skipDefaultConfigurationLookup(uint8_t shouldSkip) { load_env(); - load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + load_class_global_ref(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); if (_c_EmojiCompat == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method(_c_EmojiCompat, &_m_EmojiCompat__skipDefaultConfigurationLookup, "skipDefaultConfigurationLookup", "(Z)V"); if (_m_EmojiCompat__skipDefaultConfigurationLookup == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallStaticVoidMethod( jniEnv, _c_EmojiCompat, _m_EmojiCompat__skipDefaultConfigurationLookup, shouldSkip); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_EmojiCompat__get0 = NULL; FFI_PLUGIN_EXPORT JniResult EmojiCompat__get0() { load_env(); - load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + load_class_global_ref(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); if (_c_EmojiCompat == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method(_c_EmojiCompat, &_m_EmojiCompat__get0, "get", "()Landroidx/emoji2/text/EmojiCompat;"); if (_m_EmojiCompat__get0 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_EmojiCompat, _m_EmojiCompat__get0); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -186,14 +187,14 @@ jmethodID _m_EmojiCompat__load = NULL; FFI_PLUGIN_EXPORT JniResult EmojiCompat__load(jobject self_) { load_env(); - load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + load_class_global_ref(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); if (_c_EmojiCompat == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat, &_m_EmojiCompat__load, "load", "()V"); if (_m_EmojiCompat__load == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_EmojiCompat__load); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_EmojiCompat__registerInitCallback = NULL; @@ -201,17 +202,17 @@ FFI_PLUGIN_EXPORT JniResult EmojiCompat__registerInitCallback(jobject self_, jobject initCallback) { load_env(); - load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + load_class_global_ref(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); if (_c_EmojiCompat == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat, &_m_EmojiCompat__registerInitCallback, "registerInitCallback", "(Landroidx/emoji2/text/EmojiCompat$InitCallback;)V"); if (_m_EmojiCompat__registerInitCallback == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_EmojiCompat__registerInitCallback, initCallback); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_EmojiCompat__unregisterInitCallback = NULL; @@ -219,65 +220,65 @@ FFI_PLUGIN_EXPORT JniResult EmojiCompat__unregisterInitCallback(jobject self_, jobject initCallback) { load_env(); - load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + load_class_global_ref(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); if (_c_EmojiCompat == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat, &_m_EmojiCompat__unregisterInitCallback, "unregisterInitCallback", "(Landroidx/emoji2/text/EmojiCompat$InitCallback;)V"); if (_m_EmojiCompat__unregisterInitCallback == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod( jniEnv, self_, _m_EmojiCompat__unregisterInitCallback, initCallback); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_EmojiCompat__getLoadState = NULL; FFI_PLUGIN_EXPORT JniResult EmojiCompat__getLoadState(jobject self_) { load_env(); - load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + load_class_global_ref(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); if (_c_EmojiCompat == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat, &_m_EmojiCompat__getLoadState, "getLoadState", "()I"); if (_m_EmojiCompat__getLoadState == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_EmojiCompat__getLoadState); - return (JniResult){.result = {.i = _result}, .exception = check_exception()}; + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; } jmethodID _m_EmojiCompat__isEmojiSpanIndicatorEnabled = NULL; FFI_PLUGIN_EXPORT JniResult EmojiCompat__isEmojiSpanIndicatorEnabled(jobject self_) { load_env(); - load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + load_class_global_ref(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); if (_c_EmojiCompat == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat, &_m_EmojiCompat__isEmojiSpanIndicatorEnabled, "isEmojiSpanIndicatorEnabled", "()Z"); if (_m_EmojiCompat__isEmojiSpanIndicatorEnabled == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; uint8_t _result = (*jniEnv)->CallBooleanMethod( jniEnv, self_, _m_EmojiCompat__isEmojiSpanIndicatorEnabled); - return (JniResult){.result = {.z = _result}, .exception = check_exception()}; + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; } jmethodID _m_EmojiCompat__getEmojiSpanIndicatorColor = NULL; FFI_PLUGIN_EXPORT JniResult EmojiCompat__getEmojiSpanIndicatorColor(jobject self_) { load_env(); - load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + load_class_global_ref(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); if (_c_EmojiCompat == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat, &_m_EmojiCompat__getEmojiSpanIndicatorColor, "getEmojiSpanIndicatorColor", "()I"); if (_m_EmojiCompat__getEmojiSpanIndicatorColor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; int32_t _result = (*jniEnv)->CallIntMethod( jniEnv, self_, _m_EmojiCompat__getEmojiSpanIndicatorColor); - return (JniResult){.result = {.i = _result}, .exception = check_exception()}; + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; } jmethodID _m_EmojiCompat__getEmojiStart = NULL; @@ -286,16 +287,16 @@ JniResult EmojiCompat__getEmojiStart(jobject self_, jobject charSequence, int32_t offset) { load_env(); - load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + load_class_global_ref(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); if (_c_EmojiCompat == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat, &_m_EmojiCompat__getEmojiStart, "getEmojiStart", "(Ljava/lang/CharSequence;I)I"); if (_m_EmojiCompat__getEmojiStart == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; int32_t _result = (*jniEnv)->CallIntMethod( jniEnv, self_, _m_EmojiCompat__getEmojiStart, charSequence, offset); - return (JniResult){.result = {.i = _result}, .exception = check_exception()}; + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; } jmethodID _m_EmojiCompat__getEmojiEnd = NULL; @@ -304,16 +305,16 @@ JniResult EmojiCompat__getEmojiEnd(jobject self_, jobject charSequence, int32_t offset) { load_env(); - load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + load_class_global_ref(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); if (_c_EmojiCompat == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat, &_m_EmojiCompat__getEmojiEnd, "getEmojiEnd", "(Ljava/lang/CharSequence;I)I"); if (_m_EmojiCompat__getEmojiEnd == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; int32_t _result = (*jniEnv)->CallIntMethod( jniEnv, self_, _m_EmojiCompat__getEmojiEnd, charSequence, offset); - return (JniResult){.result = {.i = _result}, .exception = check_exception()}; + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; } jmethodID _m_EmojiCompat__handleOnKeyDown = NULL; @@ -322,18 +323,18 @@ JniResult EmojiCompat__handleOnKeyDown(jobject editable, int32_t keyCode, jobject event) { load_env(); - load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + load_class_global_ref(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); if (_c_EmojiCompat == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method(_c_EmojiCompat, &_m_EmojiCompat__handleOnKeyDown, "handleOnKeyDown", "(Landroid/text/Editable;ILandroid/view/KeyEvent;)Z"); if (_m_EmojiCompat__handleOnKeyDown == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; uint8_t _result = (*jniEnv)->CallStaticBooleanMethod( jniEnv, _c_EmojiCompat, _m_EmojiCompat__handleOnKeyDown, editable, keyCode, event); - return (JniResult){.result = {.z = _result}, .exception = check_exception()}; + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; } jmethodID _m_EmojiCompat__handleDeleteSurroundingText = NULL; @@ -344,36 +345,36 @@ JniResult EmojiCompat__handleDeleteSurroundingText(jobject inputConnection, int32_t afterLength, uint8_t inCodePoints) { load_env(); - load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + load_class_global_ref(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); if (_c_EmojiCompat == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method(_c_EmojiCompat, &_m_EmojiCompat__handleDeleteSurroundingText, "handleDeleteSurroundingText", "(Landroid/view/inputmethod/InputConnection;Landroid/text/" "Editable;IIZ)Z"); if (_m_EmojiCompat__handleDeleteSurroundingText == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; uint8_t _result = (*jniEnv)->CallStaticBooleanMethod( jniEnv, _c_EmojiCompat, _m_EmojiCompat__handleDeleteSurroundingText, inputConnection, editable, beforeLength, afterLength, inCodePoints); - return (JniResult){.result = {.z = _result}, .exception = check_exception()}; + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; } jmethodID _m_EmojiCompat__hasEmojiGlyph = NULL; FFI_PLUGIN_EXPORT JniResult EmojiCompat__hasEmojiGlyph(jobject self_, jobject sequence) { load_env(); - load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + load_class_global_ref(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); if (_c_EmojiCompat == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat, &_m_EmojiCompat__hasEmojiGlyph, "hasEmojiGlyph", "(Ljava/lang/CharSequence;)Z"); if (_m_EmojiCompat__hasEmojiGlyph == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; uint8_t _result = (*jniEnv)->CallBooleanMethod( jniEnv, self_, _m_EmojiCompat__hasEmojiGlyph, sequence); - return (JniResult){.result = {.z = _result}, .exception = check_exception()}; + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; } jmethodID _m_EmojiCompat__hasEmojiGlyph1 = NULL; @@ -382,16 +383,16 @@ JniResult EmojiCompat__hasEmojiGlyph1(jobject self_, jobject sequence, int32_t metadataVersion) { load_env(); - load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + load_class_global_ref(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); if (_c_EmojiCompat == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat, &_m_EmojiCompat__hasEmojiGlyph1, "hasEmojiGlyph", "(Ljava/lang/CharSequence;I)Z"); if (_m_EmojiCompat__hasEmojiGlyph1 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; uint8_t _result = (*jniEnv)->CallBooleanMethod( jniEnv, self_, _m_EmojiCompat__hasEmojiGlyph1, sequence, metadataVersion); - return (JniResult){.result = {.z = _result}, .exception = check_exception()}; + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; } jmethodID _m_EmojiCompat__getEmojiMatch = NULL; @@ -400,32 +401,32 @@ JniResult EmojiCompat__getEmojiMatch(jobject self_, jobject sequence, int32_t metadataVersion) { load_env(); - load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + load_class_global_ref(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); if (_c_EmojiCompat == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat, &_m_EmojiCompat__getEmojiMatch, "getEmojiMatch", "(Ljava/lang/CharSequence;I)I"); if (_m_EmojiCompat__getEmojiMatch == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; int32_t _result = (*jniEnv)->CallIntMethod( jniEnv, self_, _m_EmojiCompat__getEmojiMatch, sequence, metadataVersion); - return (JniResult){.result = {.i = _result}, .exception = check_exception()}; + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; } jmethodID _m_EmojiCompat__process = NULL; FFI_PLUGIN_EXPORT JniResult EmojiCompat__process(jobject self_, jobject charSequence) { load_env(); - load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + load_class_global_ref(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); if (_c_EmojiCompat == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat, &_m_EmojiCompat__process, "process", "(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;"); if (_m_EmojiCompat__process == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_EmojiCompat__process, charSequence); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -436,16 +437,16 @@ JniResult EmojiCompat__process1(jobject self_, int32_t start, int32_t end) { load_env(); - load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + load_class_global_ref(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); if (_c_EmojiCompat == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat, &_m_EmojiCompat__process1, "process", "(Ljava/lang/CharSequence;II)Ljava/lang/CharSequence;"); if (_m_EmojiCompat__process1 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_EmojiCompat__process1, charSequence, start, end); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -457,17 +458,17 @@ JniResult EmojiCompat__process2(jobject self_, int32_t end, int32_t maxEmojiCount) { load_env(); - load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + load_class_global_ref(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); if (_c_EmojiCompat == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat, &_m_EmojiCompat__process2, "process", "(Ljava/lang/CharSequence;III)Ljava/lang/CharSequence;"); if (_m_EmojiCompat__process2 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_EmojiCompat__process2, charSequence, start, end, maxEmojiCount); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -480,17 +481,17 @@ JniResult EmojiCompat__process3(jobject self_, int32_t maxEmojiCount, int32_t replaceStrategy) { load_env(); - load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + load_class_global_ref(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); if (_c_EmojiCompat == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat, &_m_EmojiCompat__process3, "process", "(Ljava/lang/CharSequence;IIII)Ljava/lang/CharSequence;"); if (_m_EmojiCompat__process3 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_EmojiCompat__process3, charSequence, start, end, maxEmojiCount, replaceStrategy); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -498,16 +499,16 @@ jmethodID _m_EmojiCompat__getAssetSignature = NULL; FFI_PLUGIN_EXPORT JniResult EmojiCompat__getAssetSignature(jobject self_) { load_env(); - load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + load_class_global_ref(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); if (_c_EmojiCompat == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat, &_m_EmojiCompat__getAssetSignature, "getAssetSignature", "()Ljava/lang/String;"); if (_m_EmojiCompat__getAssetSignature == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_EmojiCompat__getAssetSignature); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -515,16 +516,16 @@ jmethodID _m_EmojiCompat__updateEditorInfo = NULL; FFI_PLUGIN_EXPORT JniResult EmojiCompat__updateEditorInfo(jobject self_, jobject outAttrs) { load_env(); - load_class_gr(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); + load_class_global_ref(&_c_EmojiCompat, "androidx/emoji2/text/EmojiCompat"); if (_c_EmojiCompat == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat, &_m_EmojiCompat__updateEditorInfo, "updateEditorInfo", "(Landroid/view/inputmethod/EditorInfo;)V"); if (_m_EmojiCompat__updateEditorInfo == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_EmojiCompat__updateEditorInfo, outAttrs); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } // androidx.emoji2.text.EmojiCompat$Config @@ -534,18 +535,18 @@ jmethodID _m_EmojiCompat_Config__ctor = NULL; FFI_PLUGIN_EXPORT JniResult EmojiCompat_Config__ctor(jobject metadataLoader) { load_env(); - load_class_gr(&_c_EmojiCompat_Config, - "androidx/emoji2/text/EmojiCompat$Config"); + load_class_global_ref(&_c_EmojiCompat_Config, + "androidx/emoji2/text/EmojiCompat$Config"); if (_c_EmojiCompat_Config == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat_Config, &_m_EmojiCompat_Config__ctor, "", "(Landroidx/emoji2/text/EmojiCompat$MetadataRepoLoader;)V"); if (_m_EmojiCompat_Config__ctor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_EmojiCompat_Config, _m_EmojiCompat_Config__ctor, metadataLoader); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -554,20 +555,20 @@ FFI_PLUGIN_EXPORT JniResult EmojiCompat_Config__registerInitCallback(jobject self_, jobject initCallback) { load_env(); - load_class_gr(&_c_EmojiCompat_Config, - "androidx/emoji2/text/EmojiCompat$Config"); + load_class_global_ref(&_c_EmojiCompat_Config, + "androidx/emoji2/text/EmojiCompat$Config"); if (_c_EmojiCompat_Config == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat_Config, &_m_EmojiCompat_Config__registerInitCallback, "registerInitCallback", "(Landroidx/emoji2/text/EmojiCompat$InitCallback;)Landroidx/" "emoji2/text/EmojiCompat$Config;"); if (_m_EmojiCompat_Config__registerInitCallback == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_EmojiCompat_Config__registerInitCallback, initCallback); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -576,21 +577,21 @@ FFI_PLUGIN_EXPORT JniResult EmojiCompat_Config__unregisterInitCallback(jobject self_, jobject initCallback) { load_env(); - load_class_gr(&_c_EmojiCompat_Config, - "androidx/emoji2/text/EmojiCompat$Config"); + load_class_global_ref(&_c_EmojiCompat_Config, + "androidx/emoji2/text/EmojiCompat$Config"); if (_c_EmojiCompat_Config == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat_Config, &_m_EmojiCompat_Config__unregisterInitCallback, "unregisterInitCallback", "(Landroidx/emoji2/text/EmojiCompat$InitCallback;)Landroidx/" "emoji2/text/EmojiCompat$Config;"); if (_m_EmojiCompat_Config__unregisterInitCallback == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_EmojiCompat_Config__unregisterInitCallback, initCallback); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -598,17 +599,17 @@ jmethodID _m_EmojiCompat_Config__setReplaceAll = NULL; FFI_PLUGIN_EXPORT JniResult EmojiCompat_Config__setReplaceAll(jobject self_, uint8_t replaceAll) { load_env(); - load_class_gr(&_c_EmojiCompat_Config, - "androidx/emoji2/text/EmojiCompat$Config"); + load_class_global_ref(&_c_EmojiCompat_Config, + "androidx/emoji2/text/EmojiCompat$Config"); if (_c_EmojiCompat_Config == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat_Config, &_m_EmojiCompat_Config__setReplaceAll, "setReplaceAll", "(Z)Landroidx/emoji2/text/EmojiCompat$Config;"); if (_m_EmojiCompat_Config__setReplaceAll == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_EmojiCompat_Config__setReplaceAll, replaceAll); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -618,20 +619,20 @@ JniResult EmojiCompat_Config__setUseEmojiAsDefaultStyle( jobject self_, uint8_t useEmojiAsDefaultStyle) { load_env(); - load_class_gr(&_c_EmojiCompat_Config, - "androidx/emoji2/text/EmojiCompat$Config"); + load_class_global_ref(&_c_EmojiCompat_Config, + "androidx/emoji2/text/EmojiCompat$Config"); if (_c_EmojiCompat_Config == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat_Config, &_m_EmojiCompat_Config__setUseEmojiAsDefaultStyle, "setUseEmojiAsDefaultStyle", "(Z)Landroidx/emoji2/text/EmojiCompat$Config;"); if (_m_EmojiCompat_Config__setUseEmojiAsDefaultStyle == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_EmojiCompat_Config__setUseEmojiAsDefaultStyle, useEmojiAsDefaultStyle); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -642,20 +643,20 @@ JniResult EmojiCompat_Config__setUseEmojiAsDefaultStyle1( uint8_t useEmojiAsDefaultStyle, jobject emojiAsDefaultStyleExceptions) { load_env(); - load_class_gr(&_c_EmojiCompat_Config, - "androidx/emoji2/text/EmojiCompat$Config"); + load_class_global_ref(&_c_EmojiCompat_Config, + "androidx/emoji2/text/EmojiCompat$Config"); if (_c_EmojiCompat_Config == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat_Config, &_m_EmojiCompat_Config__setUseEmojiAsDefaultStyle1, "setUseEmojiAsDefaultStyle", "(ZLjava/util/List;)Landroidx/emoji2/text/EmojiCompat$Config;"); if (_m_EmojiCompat_Config__setUseEmojiAsDefaultStyle1 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_EmojiCompat_Config__setUseEmojiAsDefaultStyle1, useEmojiAsDefaultStyle, emojiAsDefaultStyleExceptions); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -665,20 +666,20 @@ JniResult EmojiCompat_Config__setEmojiSpanIndicatorEnabled( jobject self_, uint8_t emojiSpanIndicatorEnabled) { load_env(); - load_class_gr(&_c_EmojiCompat_Config, - "androidx/emoji2/text/EmojiCompat$Config"); + load_class_global_ref(&_c_EmojiCompat_Config, + "androidx/emoji2/text/EmojiCompat$Config"); if (_c_EmojiCompat_Config == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat_Config, &_m_EmojiCompat_Config__setEmojiSpanIndicatorEnabled, "setEmojiSpanIndicatorEnabled", "(Z)Landroidx/emoji2/text/EmojiCompat$Config;"); if (_m_EmojiCompat_Config__setEmojiSpanIndicatorEnabled == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_EmojiCompat_Config__setEmojiSpanIndicatorEnabled, emojiSpanIndicatorEnabled); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -687,19 +688,19 @@ FFI_PLUGIN_EXPORT JniResult EmojiCompat_Config__setEmojiSpanIndicatorColor(jobject self_, int32_t color) { load_env(); - load_class_gr(&_c_EmojiCompat_Config, - "androidx/emoji2/text/EmojiCompat$Config"); + load_class_global_ref(&_c_EmojiCompat_Config, + "androidx/emoji2/text/EmojiCompat$Config"); if (_c_EmojiCompat_Config == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat_Config, &_m_EmojiCompat_Config__setEmojiSpanIndicatorColor, "setEmojiSpanIndicatorColor", "(I)Landroidx/emoji2/text/EmojiCompat$Config;"); if (_m_EmojiCompat_Config__setEmojiSpanIndicatorColor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_EmojiCompat_Config__setEmojiSpanIndicatorColor, color); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -708,19 +709,19 @@ FFI_PLUGIN_EXPORT JniResult EmojiCompat_Config__setMetadataLoadStrategy(jobject self_, int32_t strategy) { load_env(); - load_class_gr(&_c_EmojiCompat_Config, - "androidx/emoji2/text/EmojiCompat$Config"); + load_class_global_ref(&_c_EmojiCompat_Config, + "androidx/emoji2/text/EmojiCompat$Config"); if (_c_EmojiCompat_Config == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat_Config, &_m_EmojiCompat_Config__setMetadataLoadStrategy, "setMetadataLoadStrategy", "(I)Landroidx/emoji2/text/EmojiCompat$Config;"); if (_m_EmojiCompat_Config__setMetadataLoadStrategy == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_EmojiCompat_Config__setMetadataLoadStrategy, strategy); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -728,19 +729,19 @@ jmethodID _m_EmojiCompat_Config__setSpanFactory = NULL; FFI_PLUGIN_EXPORT JniResult EmojiCompat_Config__setSpanFactory(jobject self_, jobject factory) { load_env(); - load_class_gr(&_c_EmojiCompat_Config, - "androidx/emoji2/text/EmojiCompat$Config"); + load_class_global_ref(&_c_EmojiCompat_Config, + "androidx/emoji2/text/EmojiCompat$Config"); if (_c_EmojiCompat_Config == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat_Config, &_m_EmojiCompat_Config__setSpanFactory, "setSpanFactory", "(Landroidx/emoji2/text/EmojiCompat$SpanFactory;)Landroidx/" "emoji2/text/EmojiCompat$Config;"); if (_m_EmojiCompat_Config__setSpanFactory == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_EmojiCompat_Config__setSpanFactory, factory); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -749,19 +750,19 @@ FFI_PLUGIN_EXPORT JniResult EmojiCompat_Config__setGlyphChecker(jobject self_, jobject glyphChecker) { load_env(); - load_class_gr(&_c_EmojiCompat_Config, - "androidx/emoji2/text/EmojiCompat$Config"); + load_class_global_ref(&_c_EmojiCompat_Config, + "androidx/emoji2/text/EmojiCompat$Config"); if (_c_EmojiCompat_Config == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat_Config, &_m_EmojiCompat_Config__setGlyphChecker, "setGlyphChecker", "(Landroidx/emoji2/text/EmojiCompat$GlyphChecker;)Landroidx/" "emoji2/text/EmojiCompat$Config;"); if (_m_EmojiCompat_Config__setGlyphChecker == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_EmojiCompat_Config__setGlyphChecker, glyphChecker); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -769,19 +770,19 @@ jmethodID _m_EmojiCompat_Config__getMetadataRepoLoader = NULL; FFI_PLUGIN_EXPORT JniResult EmojiCompat_Config__getMetadataRepoLoader(jobject self_) { load_env(); - load_class_gr(&_c_EmojiCompat_Config, - "androidx/emoji2/text/EmojiCompat$Config"); + load_class_global_ref(&_c_EmojiCompat_Config, + "androidx/emoji2/text/EmojiCompat$Config"); if (_c_EmojiCompat_Config == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat_Config, &_m_EmojiCompat_Config__getMetadataRepoLoader, "getMetadataRepoLoader", "()Landroidx/emoji2/text/EmojiCompat$MetadataRepoLoader;"); if (_m_EmojiCompat_Config__getMetadataRepoLoader == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_EmojiCompat_Config__getMetadataRepoLoader); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -792,19 +793,20 @@ jmethodID _m_EmojiCompat_MetadataRepoLoaderCallback__ctor = NULL; FFI_PLUGIN_EXPORT JniResult EmojiCompat_MetadataRepoLoaderCallback__ctor() { load_env(); - load_class_gr(&_c_EmojiCompat_MetadataRepoLoaderCallback, - "androidx/emoji2/text/EmojiCompat$MetadataRepoLoaderCallback"); + load_class_global_ref( + &_c_EmojiCompat_MetadataRepoLoaderCallback, + "androidx/emoji2/text/EmojiCompat$MetadataRepoLoaderCallback"); if (_c_EmojiCompat_MetadataRepoLoaderCallback == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat_MetadataRepoLoaderCallback, &_m_EmojiCompat_MetadataRepoLoaderCallback__ctor, "", "()V"); if (_m_EmojiCompat_MetadataRepoLoaderCallback__ctor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_EmojiCompat_MetadataRepoLoaderCallback, _m_EmojiCompat_MetadataRepoLoaderCallback__ctor); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -814,19 +816,20 @@ JniResult EmojiCompat_MetadataRepoLoaderCallback__onLoaded( jobject self_, jobject metadataRepo) { load_env(); - load_class_gr(&_c_EmojiCompat_MetadataRepoLoaderCallback, - "androidx/emoji2/text/EmojiCompat$MetadataRepoLoaderCallback"); + load_class_global_ref( + &_c_EmojiCompat_MetadataRepoLoaderCallback, + "androidx/emoji2/text/EmojiCompat$MetadataRepoLoaderCallback"); if (_c_EmojiCompat_MetadataRepoLoaderCallback == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat_MetadataRepoLoaderCallback, &_m_EmojiCompat_MetadataRepoLoaderCallback__onLoaded, "onLoaded", "(Landroidx/emoji2/text/MetadataRepo;)V"); if (_m_EmojiCompat_MetadataRepoLoaderCallback__onLoaded == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_EmojiCompat_MetadataRepoLoaderCallback__onLoaded, metadataRepo); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_EmojiCompat_MetadataRepoLoaderCallback__onFailed = NULL; @@ -834,19 +837,20 @@ FFI_PLUGIN_EXPORT JniResult EmojiCompat_MetadataRepoLoaderCallback__onFailed(jobject self_, jobject throwable) { load_env(); - load_class_gr(&_c_EmojiCompat_MetadataRepoLoaderCallback, - "androidx/emoji2/text/EmojiCompat$MetadataRepoLoaderCallback"); + load_class_global_ref( + &_c_EmojiCompat_MetadataRepoLoaderCallback, + "androidx/emoji2/text/EmojiCompat$MetadataRepoLoaderCallback"); if (_c_EmojiCompat_MetadataRepoLoaderCallback == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat_MetadataRepoLoaderCallback, &_m_EmojiCompat_MetadataRepoLoaderCallback__onFailed, "onFailed", "(Ljava/lang/Throwable;)V"); if (_m_EmojiCompat_MetadataRepoLoaderCallback__onFailed == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_EmojiCompat_MetadataRepoLoaderCallback__onFailed, throwable); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } // androidx.emoji2.text.EmojiCompat$GlyphChecker @@ -860,19 +864,19 @@ JniResult EmojiCompat_GlyphChecker__hasGlyph(jobject self_, int32_t end, int32_t sdkAdded) { load_env(); - load_class_gr(&_c_EmojiCompat_GlyphChecker, - "androidx/emoji2/text/EmojiCompat$GlyphChecker"); + load_class_global_ref(&_c_EmojiCompat_GlyphChecker, + "androidx/emoji2/text/EmojiCompat$GlyphChecker"); if (_c_EmojiCompat_GlyphChecker == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat_GlyphChecker, &_m_EmojiCompat_GlyphChecker__hasGlyph, "hasGlyph", "(Ljava/lang/CharSequence;III)Z"); if (_m_EmojiCompat_GlyphChecker__hasGlyph == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; uint8_t _result = (*jniEnv)->CallBooleanMethod( jniEnv, self_, _m_EmojiCompat_GlyphChecker__hasGlyph, charSequence, start, end, sdkAdded); - return (JniResult){.result = {.z = _result}, .exception = check_exception()}; + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; } // androidx.emoji2.text.EmojiCompat$MetadataRepoLoader @@ -883,19 +887,19 @@ FFI_PLUGIN_EXPORT JniResult EmojiCompat_MetadataRepoLoader__load(jobject self_, jobject loaderCallback) { load_env(); - load_class_gr(&_c_EmojiCompat_MetadataRepoLoader, - "androidx/emoji2/text/EmojiCompat$MetadataRepoLoader"); + load_class_global_ref(&_c_EmojiCompat_MetadataRepoLoader, + "androidx/emoji2/text/EmojiCompat$MetadataRepoLoader"); if (_c_EmojiCompat_MetadataRepoLoader == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method( _c_EmojiCompat_MetadataRepoLoader, &_m_EmojiCompat_MetadataRepoLoader__load, "load", "(Landroidx/emoji2/text/EmojiCompat$MetadataRepoLoaderCallback;)V"); if (_m_EmojiCompat_MetadataRepoLoader__load == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod( jniEnv, self_, _m_EmojiCompat_MetadataRepoLoader__load, loaderCallback); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } // androidx.emoji2.text.EmojiCompat$InitCallback @@ -905,17 +909,17 @@ jmethodID _m_EmojiCompat_InitCallback__ctor = NULL; FFI_PLUGIN_EXPORT JniResult EmojiCompat_InitCallback__ctor() { load_env(); - load_class_gr(&_c_EmojiCompat_InitCallback, - "androidx/emoji2/text/EmojiCompat$InitCallback"); + load_class_global_ref(&_c_EmojiCompat_InitCallback, + "androidx/emoji2/text/EmojiCompat$InitCallback"); if (_c_EmojiCompat_InitCallback == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat_InitCallback, &_m_EmojiCompat_InitCallback__ctor, "", "()V"); if (_m_EmojiCompat_InitCallback__ctor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_EmojiCompat_InitCallback, _m_EmojiCompat_InitCallback__ctor); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -923,36 +927,36 @@ jmethodID _m_EmojiCompat_InitCallback__onInitialized = NULL; FFI_PLUGIN_EXPORT JniResult EmojiCompat_InitCallback__onInitialized(jobject self_) { load_env(); - load_class_gr(&_c_EmojiCompat_InitCallback, - "androidx/emoji2/text/EmojiCompat$InitCallback"); + load_class_global_ref(&_c_EmojiCompat_InitCallback, + "androidx/emoji2/text/EmojiCompat$InitCallback"); if (_c_EmojiCompat_InitCallback == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat_InitCallback, &_m_EmojiCompat_InitCallback__onInitialized, "onInitialized", "()V"); if (_m_EmojiCompat_InitCallback__onInitialized == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_EmojiCompat_InitCallback__onInitialized); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_EmojiCompat_InitCallback__onFailed = NULL; FFI_PLUGIN_EXPORT JniResult EmojiCompat_InitCallback__onFailed(jobject self_, jobject throwable) { load_env(); - load_class_gr(&_c_EmojiCompat_InitCallback, - "androidx/emoji2/text/EmojiCompat$InitCallback"); + load_class_global_ref(&_c_EmojiCompat_InitCallback, + "androidx/emoji2/text/EmojiCompat$InitCallback"); if (_c_EmojiCompat_InitCallback == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat_InitCallback, &_m_EmojiCompat_InitCallback__onFailed, "onFailed", "(Ljava/lang/Throwable;)V"); if (_m_EmojiCompat_InitCallback__onFailed == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_EmojiCompat_InitCallback__onFailed, throwable); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } // androidx.emoji2.text.EmojiCompat$DefaultSpanFactory @@ -962,18 +966,18 @@ jmethodID _m_EmojiCompat_DefaultSpanFactory__ctor = NULL; FFI_PLUGIN_EXPORT JniResult EmojiCompat_DefaultSpanFactory__ctor() { load_env(); - load_class_gr(&_c_EmojiCompat_DefaultSpanFactory, - "androidx/emoji2/text/EmojiCompat$DefaultSpanFactory"); + load_class_global_ref(&_c_EmojiCompat_DefaultSpanFactory, + "androidx/emoji2/text/EmojiCompat$DefaultSpanFactory"); if (_c_EmojiCompat_DefaultSpanFactory == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat_DefaultSpanFactory, &_m_EmojiCompat_DefaultSpanFactory__ctor, "", "()V"); if (_m_EmojiCompat_DefaultSpanFactory__ctor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_EmojiCompat_DefaultSpanFactory, _m_EmojiCompat_DefaultSpanFactory__ctor); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -982,19 +986,19 @@ FFI_PLUGIN_EXPORT JniResult EmojiCompat_DefaultSpanFactory__createSpan(jobject self_, jobject rasterizer) { load_env(); - load_class_gr(&_c_EmojiCompat_DefaultSpanFactory, - "androidx/emoji2/text/EmojiCompat$DefaultSpanFactory"); + load_class_global_ref(&_c_EmojiCompat_DefaultSpanFactory, + "androidx/emoji2/text/EmojiCompat$DefaultSpanFactory"); if (_c_EmojiCompat_DefaultSpanFactory == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat_DefaultSpanFactory, &_m_EmojiCompat_DefaultSpanFactory__createSpan, "createSpan", "(Landroidx/emoji2/text/TypefaceEmojiRasterizer;)Landroidx/" "emoji2/text/EmojiSpan;"); if (_m_EmojiCompat_DefaultSpanFactory__createSpan == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_EmojiCompat_DefaultSpanFactory__createSpan, rasterizer); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1006,19 +1010,19 @@ FFI_PLUGIN_EXPORT JniResult EmojiCompat_SpanFactory__createSpan(jobject self_, jobject rasterizer) { load_env(); - load_class_gr(&_c_EmojiCompat_SpanFactory, - "androidx/emoji2/text/EmojiCompat$SpanFactory"); + load_class_global_ref(&_c_EmojiCompat_SpanFactory, + "androidx/emoji2/text/EmojiCompat$SpanFactory"); if (_c_EmojiCompat_SpanFactory == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat_SpanFactory, &_m_EmojiCompat_SpanFactory__createSpan, "createSpan", "(Landroidx/emoji2/text/TypefaceEmojiRasterizer;)Landroidx/" "emoji2/text/EmojiSpan;"); if (_m_EmojiCompat_SpanFactory__createSpan == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_EmojiCompat_SpanFactory__createSpan, rasterizer); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1029,20 +1033,20 @@ jmethodID _m_DefaultEmojiCompatConfig__create = NULL; FFI_PLUGIN_EXPORT JniResult DefaultEmojiCompatConfig__create(jobject context) { load_env(); - load_class_gr(&_c_DefaultEmojiCompatConfig, - "androidx/emoji2/text/DefaultEmojiCompatConfig"); + load_class_global_ref(&_c_DefaultEmojiCompatConfig, + "androidx/emoji2/text/DefaultEmojiCompatConfig"); if (_c_DefaultEmojiCompatConfig == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method(_c_DefaultEmojiCompatConfig, &_m_DefaultEmojiCompatConfig__create, "create", "(Landroid/content/Context;)Landroidx/emoji2/text/" "FontRequestEmojiCompatConfig;"); if (_m_DefaultEmojiCompatConfig__create == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_DefaultEmojiCompatConfig, _m_DefaultEmojiCompatConfig__create, context); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1056,23 +1060,23 @@ FFI_PLUGIN_EXPORT JniResult DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__ctor() { load_env(); - load_class_gr( + load_class_global_ref( &_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28, "androidx/emoji2/text/" "DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28"); if (_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method( _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28, &_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__ctor, "", "()V"); if (_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__ctor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject( jniEnv, _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28, _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__ctor); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1086,12 +1090,12 @@ DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__getSigningSignatu jobject packageManager, jobject providerPackage) { load_env(); - load_class_gr( + load_class_global_ref( &_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28, "androidx/emoji2/text/" "DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28"); if (_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method( _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28, &_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__getSigningSignatures1, @@ -1100,12 +1104,12 @@ DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__getSigningSignatu "content/pm/Signature;"); if (_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__getSigningSignatures1 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__getSigningSignatures1, packageManager, providerPackage); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1119,23 +1123,23 @@ FFI_PLUGIN_EXPORT JniResult DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__ctor() { load_env(); - load_class_gr( + load_class_global_ref( &_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19, "androidx/emoji2/text/" "DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19"); if (_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method( _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19, &_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__ctor, "", "()V"); if (_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__ctor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject( jniEnv, _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19, _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__ctor); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1150,12 +1154,12 @@ DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__queryIntentConten jobject intent, int32_t flags) { load_env(); - load_class_gr( + load_class_global_ref( &_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19, "androidx/emoji2/text/" "DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19"); if (_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method( _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19, &_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__queryIntentContentProviders, @@ -1164,12 +1168,12 @@ DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__queryIntentConten "util/List;"); if (_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__queryIntentContentProviders == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__queryIntentContentProviders, packageManager, intent, flags); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1182,12 +1186,12 @@ DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__getProviderInfo( jobject self_, jobject resolveInfo) { load_env(); - load_class_gr( + load_class_global_ref( &_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19, "androidx/emoji2/text/" "DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19"); if (_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method( _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19, &_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__getProviderInfo, @@ -1195,12 +1199,12 @@ DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__getProviderInfo( "(Landroid/content/pm/ResolveInfo;)Landroid/content/pm/ProviderInfo;"); if (_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__getProviderInfo == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__getProviderInfo, resolveInfo); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1212,20 +1216,21 @@ jmethodID _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__ctor = FFI_PLUGIN_EXPORT JniResult DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__ctor() { load_env(); - load_class_gr(&_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper, - "androidx/emoji2/text/" - "DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper"); + load_class_global_ref( + &_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper, + "androidx/emoji2/text/" + "DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper"); if (_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper, &_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__ctor, "", "()V"); if (_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__ctor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject( jniEnv, _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper, _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__ctor); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1239,11 +1244,12 @@ DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__getSigningSignatures( jobject packageManager, jobject providerPackage) { load_env(); - load_class_gr(&_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper, - "androidx/emoji2/text/" - "DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper"); + load_class_global_ref( + &_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper, + "androidx/emoji2/text/" + "DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper"); if (_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method( _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper, &_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__getSigningSignatures, @@ -1252,12 +1258,12 @@ DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__getSigningSignatures( "content/pm/Signature;"); if (_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__getSigningSignatures == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__getSigningSignatures, packageManager, providerPackage); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1272,11 +1278,12 @@ DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__queryIntentContentProvi jobject intent, int32_t flags) { load_env(); - load_class_gr(&_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper, - "androidx/emoji2/text/" - "DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper"); + load_class_global_ref( + &_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper, + "androidx/emoji2/text/" + "DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper"); if (_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method( _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper, &_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__queryIntentContentProviders, @@ -1285,12 +1292,12 @@ DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__queryIntentContentProvi "util/List;"); if (_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__queryIntentContentProviders == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__queryIntentContentProviders, packageManager, intent, flags); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1303,11 +1310,12 @@ DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__getProviderInfo( jobject self_, jobject resolveInfo) { load_env(); - load_class_gr(&_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper, - "androidx/emoji2/text/" - "DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper"); + load_class_global_ref( + &_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper, + "androidx/emoji2/text/" + "DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper"); if (_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method( _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper, &_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__getProviderInfo, @@ -1315,12 +1323,12 @@ DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__getProviderInfo( "(Landroid/content/pm/ResolveInfo;)Landroid/content/pm/ProviderInfo;"); if (_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__getProviderInfo == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__getProviderInfo, resolveInfo); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1333,11 +1341,12 @@ FFI_PLUGIN_EXPORT JniResult DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__ctor( jobject helper) { load_env(); - load_class_gr(&_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory, - "androidx/emoji2/text/" - "DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory"); + load_class_global_ref( + &_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory, + "androidx/emoji2/text/" + "DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory"); if (_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method( _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory, &_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__ctor, @@ -1345,12 +1354,12 @@ JniResult DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__ctor( "(Landroidx/emoji2/text/" "DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper;)V"); if (_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__ctor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject( jniEnv, _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory, _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__ctor, helper); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1361,11 +1370,12 @@ JniResult DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__create( jobject self_, jobject context) { load_env(); - load_class_gr(&_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory, - "androidx/emoji2/text/" - "DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory"); + load_class_global_ref( + &_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory, + "androidx/emoji2/text/" + "DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory"); if (_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method( _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory, &_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__create, @@ -1373,12 +1383,12 @@ JniResult DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__create( "(Landroid/content/Context;)Landroidx/emoji2/text/EmojiCompat$Config;"); if (_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__create == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__create, context); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1389,14 +1399,14 @@ jmethodID _m_Build__ctor = NULL; FFI_PLUGIN_EXPORT JniResult Build__ctor() { load_env(); - load_class_gr(&_c_Build, "android/os/Build"); + load_class_global_ref(&_c_Build, "android/os/Build"); if (_c_Build == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_Build, &_m_Build__ctor, "", "()V"); if (_m_Build__ctor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Build, _m_Build__ctor); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1404,16 +1414,16 @@ jmethodID _m_Build__getSerial = NULL; FFI_PLUGIN_EXPORT JniResult Build__getSerial() { load_env(); - load_class_gr(&_c_Build, "android/os/Build"); + load_class_global_ref(&_c_Build, "android/os/Build"); if (_c_Build == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method(_c_Build, &_m_Build__getSerial, "getSerial", "()Ljava/lang/String;"); if (_m_Build__getSerial == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_Build, _m_Build__getSerial); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1421,16 +1431,16 @@ jmethodID _m_Build__getFingerprintedPartitions = NULL; FFI_PLUGIN_EXPORT JniResult Build__getFingerprintedPartitions() { load_env(); - load_class_gr(&_c_Build, "android/os/Build"); + load_class_global_ref(&_c_Build, "android/os/Build"); if (_c_Build == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method(_c_Build, &_m_Build__getFingerprintedPartitions, "getFingerprintedPartitions", "()Ljava/util/List;"); if (_m_Build__getFingerprintedPartitions == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_Build, _m_Build__getFingerprintedPartitions); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1438,16 +1448,16 @@ jmethodID _m_Build__getRadioVersion = NULL; FFI_PLUGIN_EXPORT JniResult Build__getRadioVersion() { load_env(); - load_class_gr(&_c_Build, "android/os/Build"); + load_class_global_ref(&_c_Build, "android/os/Build"); if (_c_Build == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method(_c_Build, &_m_Build__getRadioVersion, "getRadioVersion", "()Ljava/lang/String;"); if (_m_Build__getRadioVersion == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_Build, _m_Build__getRadioVersion); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1455,367 +1465,367 @@ jfieldID _f_Build__BOARD = NULL; FFI_PLUGIN_EXPORT JniResult get_Build__BOARD() { load_env(); - load_class_gr(&_c_Build, "android/os/Build"); + load_class_global_ref(&_c_Build, "android/os/Build"); if (_c_Build == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__BOARD, "BOARD", "Ljava/lang/String;"); jobject _result = to_global_ref( (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__BOARD)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } jfieldID _f_Build__BOOTLOADER = NULL; FFI_PLUGIN_EXPORT JniResult get_Build__BOOTLOADER() { load_env(); - load_class_gr(&_c_Build, "android/os/Build"); + load_class_global_ref(&_c_Build, "android/os/Build"); if (_c_Build == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__BOOTLOADER, "BOOTLOADER", "Ljava/lang/String;"); jobject _result = to_global_ref( (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__BOOTLOADER)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } jfieldID _f_Build__BRAND = NULL; FFI_PLUGIN_EXPORT JniResult get_Build__BRAND() { load_env(); - load_class_gr(&_c_Build, "android/os/Build"); + load_class_global_ref(&_c_Build, "android/os/Build"); if (_c_Build == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__BRAND, "BRAND", "Ljava/lang/String;"); jobject _result = to_global_ref( (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__BRAND)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } jfieldID _f_Build__CPU_ABI = NULL; FFI_PLUGIN_EXPORT JniResult get_Build__CPU_ABI() { load_env(); - load_class_gr(&_c_Build, "android/os/Build"); + load_class_global_ref(&_c_Build, "android/os/Build"); if (_c_Build == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__CPU_ABI, "CPU_ABI", "Ljava/lang/String;"); jobject _result = to_global_ref( (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__CPU_ABI)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } jfieldID _f_Build__CPU_ABI2 = NULL; FFI_PLUGIN_EXPORT JniResult get_Build__CPU_ABI2() { load_env(); - load_class_gr(&_c_Build, "android/os/Build"); + load_class_global_ref(&_c_Build, "android/os/Build"); if (_c_Build == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__CPU_ABI2, "CPU_ABI2", "Ljava/lang/String;"); jobject _result = to_global_ref( (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__CPU_ABI2)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } jfieldID _f_Build__DEVICE = NULL; FFI_PLUGIN_EXPORT JniResult get_Build__DEVICE() { load_env(); - load_class_gr(&_c_Build, "android/os/Build"); + load_class_global_ref(&_c_Build, "android/os/Build"); if (_c_Build == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__DEVICE, "DEVICE", "Ljava/lang/String;"); jobject _result = to_global_ref( (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__DEVICE)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } jfieldID _f_Build__DISPLAY = NULL; FFI_PLUGIN_EXPORT JniResult get_Build__DISPLAY() { load_env(); - load_class_gr(&_c_Build, "android/os/Build"); + load_class_global_ref(&_c_Build, "android/os/Build"); if (_c_Build == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__DISPLAY, "DISPLAY", "Ljava/lang/String;"); jobject _result = to_global_ref( (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__DISPLAY)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } jfieldID _f_Build__FINGERPRINT = NULL; FFI_PLUGIN_EXPORT JniResult get_Build__FINGERPRINT() { load_env(); - load_class_gr(&_c_Build, "android/os/Build"); + load_class_global_ref(&_c_Build, "android/os/Build"); if (_c_Build == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__FINGERPRINT, "FINGERPRINT", "Ljava/lang/String;"); jobject _result = to_global_ref( (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__FINGERPRINT)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } jfieldID _f_Build__HARDWARE = NULL; FFI_PLUGIN_EXPORT JniResult get_Build__HARDWARE() { load_env(); - load_class_gr(&_c_Build, "android/os/Build"); + load_class_global_ref(&_c_Build, "android/os/Build"); if (_c_Build == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__HARDWARE, "HARDWARE", "Ljava/lang/String;"); jobject _result = to_global_ref( (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__HARDWARE)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } jfieldID _f_Build__HOST = NULL; FFI_PLUGIN_EXPORT JniResult get_Build__HOST() { load_env(); - load_class_gr(&_c_Build, "android/os/Build"); + load_class_global_ref(&_c_Build, "android/os/Build"); if (_c_Build == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__HOST, "HOST", "Ljava/lang/String;"); jobject _result = to_global_ref( (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__HOST)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } jfieldID _f_Build__ID = NULL; FFI_PLUGIN_EXPORT JniResult get_Build__ID() { load_env(); - load_class_gr(&_c_Build, "android/os/Build"); + load_class_global_ref(&_c_Build, "android/os/Build"); if (_c_Build == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__ID, "ID", "Ljava/lang/String;"); jobject _result = to_global_ref( (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__ID)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } jfieldID _f_Build__MANUFACTURER = NULL; FFI_PLUGIN_EXPORT JniResult get_Build__MANUFACTURER() { load_env(); - load_class_gr(&_c_Build, "android/os/Build"); + load_class_global_ref(&_c_Build, "android/os/Build"); if (_c_Build == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__MANUFACTURER, "MANUFACTURER", "Ljava/lang/String;"); jobject _result = to_global_ref((*jniEnv)->GetStaticObjectField( jniEnv, _c_Build, _f_Build__MANUFACTURER)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } jfieldID _f_Build__MODEL = NULL; FFI_PLUGIN_EXPORT JniResult get_Build__MODEL() { load_env(); - load_class_gr(&_c_Build, "android/os/Build"); + load_class_global_ref(&_c_Build, "android/os/Build"); if (_c_Build == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__MODEL, "MODEL", "Ljava/lang/String;"); jobject _result = to_global_ref( (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__MODEL)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } jfieldID _f_Build__ODM_SKU = NULL; FFI_PLUGIN_EXPORT JniResult get_Build__ODM_SKU() { load_env(); - load_class_gr(&_c_Build, "android/os/Build"); + load_class_global_ref(&_c_Build, "android/os/Build"); if (_c_Build == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__ODM_SKU, "ODM_SKU", "Ljava/lang/String;"); jobject _result = to_global_ref( (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__ODM_SKU)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } jfieldID _f_Build__PRODUCT = NULL; FFI_PLUGIN_EXPORT JniResult get_Build__PRODUCT() { load_env(); - load_class_gr(&_c_Build, "android/os/Build"); + load_class_global_ref(&_c_Build, "android/os/Build"); if (_c_Build == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__PRODUCT, "PRODUCT", "Ljava/lang/String;"); jobject _result = to_global_ref( (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__PRODUCT)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } jfieldID _f_Build__RADIO = NULL; FFI_PLUGIN_EXPORT JniResult get_Build__RADIO() { load_env(); - load_class_gr(&_c_Build, "android/os/Build"); + load_class_global_ref(&_c_Build, "android/os/Build"); if (_c_Build == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__RADIO, "RADIO", "Ljava/lang/String;"); jobject _result = to_global_ref( (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__RADIO)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } jfieldID _f_Build__SERIAL = NULL; FFI_PLUGIN_EXPORT JniResult get_Build__SERIAL() { load_env(); - load_class_gr(&_c_Build, "android/os/Build"); + load_class_global_ref(&_c_Build, "android/os/Build"); if (_c_Build == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__SERIAL, "SERIAL", "Ljava/lang/String;"); jobject _result = to_global_ref( (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__SERIAL)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } jfieldID _f_Build__SKU = NULL; FFI_PLUGIN_EXPORT JniResult get_Build__SKU() { load_env(); - load_class_gr(&_c_Build, "android/os/Build"); + load_class_global_ref(&_c_Build, "android/os/Build"); if (_c_Build == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__SKU, "SKU", "Ljava/lang/String;"); jobject _result = to_global_ref( (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__SKU)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } jfieldID _f_Build__SOC_MANUFACTURER = NULL; FFI_PLUGIN_EXPORT JniResult get_Build__SOC_MANUFACTURER() { load_env(); - load_class_gr(&_c_Build, "android/os/Build"); + load_class_global_ref(&_c_Build, "android/os/Build"); if (_c_Build == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__SOC_MANUFACTURER, "SOC_MANUFACTURER", "Ljava/lang/String;"); jobject _result = to_global_ref((*jniEnv)->GetStaticObjectField( jniEnv, _c_Build, _f_Build__SOC_MANUFACTURER)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } jfieldID _f_Build__SOC_MODEL = NULL; FFI_PLUGIN_EXPORT JniResult get_Build__SOC_MODEL() { load_env(); - load_class_gr(&_c_Build, "android/os/Build"); + load_class_global_ref(&_c_Build, "android/os/Build"); if (_c_Build == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__SOC_MODEL, "SOC_MODEL", "Ljava/lang/String;"); jobject _result = to_global_ref( (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__SOC_MODEL)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } jfieldID _f_Build__SUPPORTED_32_BIT_ABIS = NULL; FFI_PLUGIN_EXPORT JniResult get_Build__SUPPORTED_32_BIT_ABIS() { load_env(); - load_class_gr(&_c_Build, "android/os/Build"); + load_class_global_ref(&_c_Build, "android/os/Build"); if (_c_Build == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__SUPPORTED_32_BIT_ABIS, "SUPPORTED_32_BIT_ABIS", "[Ljava/lang/String;"); jobject _result = to_global_ref((*jniEnv)->GetStaticObjectField( jniEnv, _c_Build, _f_Build__SUPPORTED_32_BIT_ABIS)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } jfieldID _f_Build__SUPPORTED_64_BIT_ABIS = NULL; FFI_PLUGIN_EXPORT JniResult get_Build__SUPPORTED_64_BIT_ABIS() { load_env(); - load_class_gr(&_c_Build, "android/os/Build"); + load_class_global_ref(&_c_Build, "android/os/Build"); if (_c_Build == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__SUPPORTED_64_BIT_ABIS, "SUPPORTED_64_BIT_ABIS", "[Ljava/lang/String;"); jobject _result = to_global_ref((*jniEnv)->GetStaticObjectField( jniEnv, _c_Build, _f_Build__SUPPORTED_64_BIT_ABIS)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } jfieldID _f_Build__SUPPORTED_ABIS = NULL; FFI_PLUGIN_EXPORT JniResult get_Build__SUPPORTED_ABIS() { load_env(); - load_class_gr(&_c_Build, "android/os/Build"); + load_class_global_ref(&_c_Build, "android/os/Build"); if (_c_Build == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__SUPPORTED_ABIS, "SUPPORTED_ABIS", "[Ljava/lang/String;"); jobject _result = to_global_ref((*jniEnv)->GetStaticObjectField( jniEnv, _c_Build, _f_Build__SUPPORTED_ABIS)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } jfieldID _f_Build__TAGS = NULL; FFI_PLUGIN_EXPORT JniResult get_Build__TAGS() { load_env(); - load_class_gr(&_c_Build, "android/os/Build"); + load_class_global_ref(&_c_Build, "android/os/Build"); if (_c_Build == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__TAGS, "TAGS", "Ljava/lang/String;"); jobject _result = to_global_ref( (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__TAGS)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } jfieldID _f_Build__TIME = NULL; FFI_PLUGIN_EXPORT JniResult get_Build__TIME() { load_env(); - load_class_gr(&_c_Build, "android/os/Build"); + load_class_global_ref(&_c_Build, "android/os/Build"); if (_c_Build == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__TIME, "TIME", "J"); int64_t _result = (*jniEnv)->GetStaticLongField(jniEnv, _c_Build, _f_Build__TIME); - return (JniResult){.result = {.j = _result}, .exception = check_exception()}; + return (JniResult){.value = {.j = _result}, .exception = check_exception()}; } jfieldID _f_Build__TYPE = NULL; FFI_PLUGIN_EXPORT JniResult get_Build__TYPE() { load_env(); - load_class_gr(&_c_Build, "android/os/Build"); + load_class_global_ref(&_c_Build, "android/os/Build"); if (_c_Build == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__TYPE, "TYPE", "Ljava/lang/String;"); jobject _result = to_global_ref( (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__TYPE)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } jfieldID _f_Build__USER = NULL; FFI_PLUGIN_EXPORT JniResult get_Build__USER() { load_env(); - load_class_gr(&_c_Build, "android/os/Build"); + load_class_global_ref(&_c_Build, "android/os/Build"); if (_c_Build == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__USER, "USER", "Ljava/lang/String;"); jobject _result = to_global_ref( (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__USER)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } // java.util.HashMap @@ -1825,15 +1835,15 @@ jmethodID _m_HashMap__ctor = NULL; FFI_PLUGIN_EXPORT JniResult HashMap__ctor(int32_t i, float f) { load_env(); - load_class_gr(&_c_HashMap, "java/util/HashMap"); + load_class_global_ref(&_c_HashMap, "java/util/HashMap"); if (_c_HashMap == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_HashMap, &_m_HashMap__ctor, "", "(IF)V"); if (_m_HashMap__ctor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_HashMap, _m_HashMap__ctor, i, f); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1841,15 +1851,15 @@ jmethodID _m_HashMap__ctor1 = NULL; FFI_PLUGIN_EXPORT JniResult HashMap__ctor1(int32_t i) { load_env(); - load_class_gr(&_c_HashMap, "java/util/HashMap"); + load_class_global_ref(&_c_HashMap, "java/util/HashMap"); if (_c_HashMap == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_HashMap, &_m_HashMap__ctor1, "", "(I)V"); if (_m_HashMap__ctor1 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_HashMap, _m_HashMap__ctor1, i); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1857,14 +1867,14 @@ jmethodID _m_HashMap__ctor2 = NULL; FFI_PLUGIN_EXPORT JniResult HashMap__ctor2() { load_env(); - load_class_gr(&_c_HashMap, "java/util/HashMap"); + load_class_global_ref(&_c_HashMap, "java/util/HashMap"); if (_c_HashMap == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_HashMap, &_m_HashMap__ctor2, "", "()V"); if (_m_HashMap__ctor2 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_HashMap, _m_HashMap__ctor2); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1872,15 +1882,15 @@ jmethodID _m_HashMap__ctor3 = NULL; FFI_PLUGIN_EXPORT JniResult HashMap__ctor3(jobject map) { load_env(); - load_class_gr(&_c_HashMap, "java/util/HashMap"); + load_class_global_ref(&_c_HashMap, "java/util/HashMap"); if (_c_HashMap == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_HashMap, &_m_HashMap__ctor3, "", "(Ljava/util/Map;)V"); if (_m_HashMap__ctor3 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_HashMap, _m_HashMap__ctor3, map); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1888,45 +1898,45 @@ jmethodID _m_HashMap__size = NULL; FFI_PLUGIN_EXPORT JniResult HashMap__size(jobject self_) { load_env(); - load_class_gr(&_c_HashMap, "java/util/HashMap"); + load_class_global_ref(&_c_HashMap, "java/util/HashMap"); if (_c_HashMap == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_HashMap, &_m_HashMap__size, "size", "()I"); if (_m_HashMap__size == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_HashMap__size); - return (JniResult){.result = {.i = _result}, .exception = check_exception()}; + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; } jmethodID _m_HashMap__isEmpty = NULL; FFI_PLUGIN_EXPORT JniResult HashMap__isEmpty(jobject self_) { load_env(); - load_class_gr(&_c_HashMap, "java/util/HashMap"); + load_class_global_ref(&_c_HashMap, "java/util/HashMap"); if (_c_HashMap == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_HashMap, &_m_HashMap__isEmpty, "isEmpty", "()Z"); if (_m_HashMap__isEmpty == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_HashMap__isEmpty); - return (JniResult){.result = {.z = _result}, .exception = check_exception()}; + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; } jmethodID _m_HashMap__get0 = NULL; FFI_PLUGIN_EXPORT JniResult HashMap__get0(jobject self_, jobject object) { load_env(); - load_class_gr(&_c_HashMap, "java/util/HashMap"); + load_class_global_ref(&_c_HashMap, "java/util/HashMap"); if (_c_HashMap == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_HashMap, &_m_HashMap__get0, "get", "(Ljava/lang/Object;)Ljava/lang/Object;"); if (_m_HashMap__get0 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_HashMap__get0, object); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1934,32 +1944,32 @@ jmethodID _m_HashMap__containsKey = NULL; FFI_PLUGIN_EXPORT JniResult HashMap__containsKey(jobject self_, jobject object) { load_env(); - load_class_gr(&_c_HashMap, "java/util/HashMap"); + load_class_global_ref(&_c_HashMap, "java/util/HashMap"); if (_c_HashMap == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_HashMap, &_m_HashMap__containsKey, "containsKey", "(Ljava/lang/Object;)Z"); if (_m_HashMap__containsKey == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; uint8_t _result = (*jniEnv)->CallBooleanMethod( jniEnv, self_, _m_HashMap__containsKey, object); - return (JniResult){.result = {.z = _result}, .exception = check_exception()}; + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; } jmethodID _m_HashMap__put = NULL; FFI_PLUGIN_EXPORT JniResult HashMap__put(jobject self_, jobject object, jobject object1) { load_env(); - load_class_gr(&_c_HashMap, "java/util/HashMap"); + load_class_global_ref(&_c_HashMap, "java/util/HashMap"); if (_c_HashMap == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_HashMap, &_m_HashMap__put, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); if (_m_HashMap__put == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_HashMap__put, object, object1); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1967,30 +1977,30 @@ jmethodID _m_HashMap__putAll = NULL; FFI_PLUGIN_EXPORT JniResult HashMap__putAll(jobject self_, jobject map) { load_env(); - load_class_gr(&_c_HashMap, "java/util/HashMap"); + load_class_global_ref(&_c_HashMap, "java/util/HashMap"); if (_c_HashMap == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_HashMap, &_m_HashMap__putAll, "putAll", "(Ljava/util/Map;)V"); if (_m_HashMap__putAll == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_HashMap__putAll, map); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_HashMap__remove = NULL; FFI_PLUGIN_EXPORT JniResult HashMap__remove(jobject self_, jobject object) { load_env(); - load_class_gr(&_c_HashMap, "java/util/HashMap"); + load_class_global_ref(&_c_HashMap, "java/util/HashMap"); if (_c_HashMap == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_HashMap, &_m_HashMap__remove, "remove", "(Ljava/lang/Object;)Ljava/lang/Object;"); if (_m_HashMap__remove == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_HashMap__remove, object); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1998,45 +2008,45 @@ jmethodID _m_HashMap__clear = NULL; FFI_PLUGIN_EXPORT JniResult HashMap__clear(jobject self_) { load_env(); - load_class_gr(&_c_HashMap, "java/util/HashMap"); + load_class_global_ref(&_c_HashMap, "java/util/HashMap"); if (_c_HashMap == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_HashMap, &_m_HashMap__clear, "clear", "()V"); if (_m_HashMap__clear == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_HashMap__clear); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_HashMap__containsValue = NULL; FFI_PLUGIN_EXPORT JniResult HashMap__containsValue(jobject self_, jobject object) { load_env(); - load_class_gr(&_c_HashMap, "java/util/HashMap"); + load_class_global_ref(&_c_HashMap, "java/util/HashMap"); if (_c_HashMap == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_HashMap, &_m_HashMap__containsValue, "containsValue", "(Ljava/lang/Object;)Z"); if (_m_HashMap__containsValue == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; uint8_t _result = (*jniEnv)->CallBooleanMethod( jniEnv, self_, _m_HashMap__containsValue, object); - return (JniResult){.result = {.z = _result}, .exception = check_exception()}; + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; } jmethodID _m_HashMap__keySet = NULL; FFI_PLUGIN_EXPORT JniResult HashMap__keySet(jobject self_) { load_env(); - load_class_gr(&_c_HashMap, "java/util/HashMap"); + load_class_global_ref(&_c_HashMap, "java/util/HashMap"); if (_c_HashMap == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_HashMap, &_m_HashMap__keySet, "keySet", "()Ljava/util/Set;"); if (_m_HashMap__keySet == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_HashMap__keySet); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -2044,16 +2054,16 @@ jmethodID _m_HashMap__values = NULL; FFI_PLUGIN_EXPORT JniResult HashMap__values(jobject self_) { load_env(); - load_class_gr(&_c_HashMap, "java/util/HashMap"); + load_class_global_ref(&_c_HashMap, "java/util/HashMap"); if (_c_HashMap == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_HashMap, &_m_HashMap__values, "values", "()Ljava/util/Collection;"); if (_m_HashMap__values == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_HashMap__values); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -2061,16 +2071,16 @@ jmethodID _m_HashMap__entrySet = NULL; FFI_PLUGIN_EXPORT JniResult HashMap__entrySet(jobject self_) { load_env(); - load_class_gr(&_c_HashMap, "java/util/HashMap"); + load_class_global_ref(&_c_HashMap, "java/util/HashMap"); if (_c_HashMap == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_HashMap, &_m_HashMap__entrySet, "entrySet", "()Ljava/util/Set;"); if (_m_HashMap__entrySet == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_HashMap__entrySet); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -2080,16 +2090,16 @@ JniResult HashMap__getOrDefault(jobject self_, jobject object, jobject object1) { load_env(); - load_class_gr(&_c_HashMap, "java/util/HashMap"); + load_class_global_ref(&_c_HashMap, "java/util/HashMap"); if (_c_HashMap == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_HashMap, &_m_HashMap__getOrDefault, "getOrDefault", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); if (_m_HashMap__getOrDefault == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_HashMap__getOrDefault, object, object1); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -2097,16 +2107,16 @@ jmethodID _m_HashMap__putIfAbsent = NULL; FFI_PLUGIN_EXPORT JniResult HashMap__putIfAbsent(jobject self_, jobject object, jobject object1) { load_env(); - load_class_gr(&_c_HashMap, "java/util/HashMap"); + load_class_global_ref(&_c_HashMap, "java/util/HashMap"); if (_c_HashMap == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_HashMap, &_m_HashMap__putIfAbsent, "putIfAbsent", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); if (_m_HashMap__putIfAbsent == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_HashMap__putIfAbsent, object, object1); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -2114,16 +2124,16 @@ jmethodID _m_HashMap__remove1 = NULL; FFI_PLUGIN_EXPORT JniResult HashMap__remove1(jobject self_, jobject object, jobject object1) { load_env(); - load_class_gr(&_c_HashMap, "java/util/HashMap"); + load_class_global_ref(&_c_HashMap, "java/util/HashMap"); if (_c_HashMap == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_HashMap, &_m_HashMap__remove1, "remove", "(Ljava/lang/Object;Ljava/lang/Object;)Z"); if (_m_HashMap__remove1 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; uint8_t _result = (*jniEnv)->CallBooleanMethod( jniEnv, self_, _m_HashMap__remove1, object, object1); - return (JniResult){.result = {.z = _result}, .exception = check_exception()}; + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; } jmethodID _m_HashMap__replace = NULL; @@ -2133,32 +2143,32 @@ JniResult HashMap__replace(jobject self_, jobject object1, jobject object2) { load_env(); - load_class_gr(&_c_HashMap, "java/util/HashMap"); + load_class_global_ref(&_c_HashMap, "java/util/HashMap"); if (_c_HashMap == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_HashMap, &_m_HashMap__replace, "replace", "(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Z"); if (_m_HashMap__replace == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; uint8_t _result = (*jniEnv)->CallBooleanMethod( jniEnv, self_, _m_HashMap__replace, object, object1, object2); - return (JniResult){.result = {.z = _result}, .exception = check_exception()}; + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; } jmethodID _m_HashMap__replace1 = NULL; FFI_PLUGIN_EXPORT JniResult HashMap__replace1(jobject self_, jobject object, jobject object1) { load_env(); - load_class_gr(&_c_HashMap, "java/util/HashMap"); + load_class_global_ref(&_c_HashMap, "java/util/HashMap"); if (_c_HashMap == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_HashMap, &_m_HashMap__replace1, "replace", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); if (_m_HashMap__replace1 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_HashMap__replace1, object, object1); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -2168,17 +2178,17 @@ JniResult HashMap__computeIfAbsent(jobject self_, jobject object, jobject function) { load_env(); - load_class_gr(&_c_HashMap, "java/util/HashMap"); + load_class_global_ref(&_c_HashMap, "java/util/HashMap"); if (_c_HashMap == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method( _c_HashMap, &_m_HashMap__computeIfAbsent, "computeIfAbsent", "(Ljava/lang/Object;Ljava/util/function/Function;)Ljava/lang/Object;"); if (_m_HashMap__computeIfAbsent == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_HashMap__computeIfAbsent, object, function); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -2188,17 +2198,17 @@ JniResult HashMap__computeIfPresent(jobject self_, jobject object, jobject biFunction) { load_env(); - load_class_gr(&_c_HashMap, "java/util/HashMap"); + load_class_global_ref(&_c_HashMap, "java/util/HashMap"); if (_c_HashMap == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method( _c_HashMap, &_m_HashMap__computeIfPresent, "computeIfPresent", "(Ljava/lang/Object;Ljava/util/function/BiFunction;)Ljava/lang/Object;"); if (_m_HashMap__computeIfPresent == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_HashMap__computeIfPresent, object, biFunction); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -2206,17 +2216,17 @@ jmethodID _m_HashMap__compute = NULL; FFI_PLUGIN_EXPORT JniResult HashMap__compute(jobject self_, jobject object, jobject biFunction) { load_env(); - load_class_gr(&_c_HashMap, "java/util/HashMap"); + load_class_global_ref(&_c_HashMap, "java/util/HashMap"); if (_c_HashMap == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method( _c_HashMap, &_m_HashMap__compute, "compute", "(Ljava/lang/Object;Ljava/util/function/BiFunction;)Ljava/lang/Object;"); if (_m_HashMap__compute == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_HashMap__compute, object, biFunction); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -2227,17 +2237,17 @@ JniResult HashMap__merge(jobject self_, jobject object1, jobject biFunction) { load_env(); - load_class_gr(&_c_HashMap, "java/util/HashMap"); + load_class_global_ref(&_c_HashMap, "java/util/HashMap"); if (_c_HashMap == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_HashMap, &_m_HashMap__merge, "merge", "(Ljava/lang/Object;Ljava/lang/Object;Ljava/util/function/" "BiFunction;)Ljava/lang/Object;"); if (_m_HashMap__merge == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_HashMap__merge, object, object1, biFunction); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -2245,44 +2255,44 @@ jmethodID _m_HashMap__forEach = NULL; FFI_PLUGIN_EXPORT JniResult HashMap__forEach(jobject self_, jobject biConsumer) { load_env(); - load_class_gr(&_c_HashMap, "java/util/HashMap"); + load_class_global_ref(&_c_HashMap, "java/util/HashMap"); if (_c_HashMap == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_HashMap, &_m_HashMap__forEach, "forEach", "(Ljava/util/function/BiConsumer;)V"); if (_m_HashMap__forEach == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_HashMap__forEach, biConsumer); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_HashMap__replaceAll = NULL; FFI_PLUGIN_EXPORT JniResult HashMap__replaceAll(jobject self_, jobject biFunction) { load_env(); - load_class_gr(&_c_HashMap, "java/util/HashMap"); + load_class_global_ref(&_c_HashMap, "java/util/HashMap"); if (_c_HashMap == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_HashMap, &_m_HashMap__replaceAll, "replaceAll", "(Ljava/util/function/BiFunction;)V"); if (_m_HashMap__replaceAll == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_HashMap__replaceAll, biFunction); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_HashMap__clone = NULL; FFI_PLUGIN_EXPORT JniResult HashMap__clone(jobject self_) { load_env(); - load_class_gr(&_c_HashMap, "java/util/HashMap"); + load_class_global_ref(&_c_HashMap, "java/util/HashMap"); if (_c_HashMap == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_HashMap, &_m_HashMap__clone, "clone", "()Ljava/lang/Object;"); if (_m_HashMap__clone == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_HashMap__clone); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } diff --git a/pkgs/jnigen/example/in_app_java/src/android_utils/dartjni.h b/pkgs/jnigen/example/in_app_java/src/android_utils/dartjni.h index 39b70bd8f..eb73318d1 100644 --- a/pkgs/jnigen/example/in_app_java/src/android_utils/dartjni.h +++ b/pkgs/jnigen/example/in_app_java/src/android_utils/dartjni.h @@ -39,6 +39,66 @@ #define __ENVP_CAST (void**) #endif +/// Locking functions for windows and pthread. + +#if defined _WIN32 +#include + +typedef CRITICAL_SECTION MutexLock; + +static inline void init_lock(MutexLock* lock) { + InitializeCriticalSection(lock); +} + +static inline void acquire_lock(MutexLock* lock) { + EnterCriticalSection(lock); +} + +static inline void release_lock(MutexLock* lock) { + LeaveCriticalSection(lock); +} + +static inline void _destroyLock(MutexLock* lock) { + DeleteCriticalSection(lock); +} + +#elif defined __DARWIN__ || defined __LINUX__ || defined __ANDROID__ || \ + defined __GNUC__ +#include + +typedef pthread_mutex_t MutexLock; + +static inline void init_lock(MutexLock* lock) { + pthread_mutex_init(lock, NULL); +} + +static inline void acquire_lock(MutexLock* lock) { + pthread_mutex_lock(lock); +} + +static inline void release_lock(MutexLock* lock) { + pthread_mutex_unlock(lock); +} + +static inline void _destroyLock(MutexLock* lock) { + pthread_mutex_destroy(lock); +} + +#else + +#error "No locking support; Possibly unsupported platform" + +#endif + +typedef struct JniLocks { + MutexLock classLoadingLock; + MutexLock methodLoadingLock; + MutexLock fieldLoadingLock; +} JniLocks; + +/// Represents the error when dart-jni layer has already spawned singleton VM. +#define DART_JNI_SINGLETON_EXISTS (-99); + /// Stores the global state of the JNI. typedef struct JniContext { JavaVM* jvm; @@ -46,13 +106,14 @@ typedef struct JniContext { jmethodID loadClassMethod; jobject currentActivity; jobject appContext; + JniLocks locks; } JniContext; // jniEnv for this thread, used by inline functions in this header, // therefore declared as extern. extern thread_local JNIEnv* jniEnv; -extern JniContext jni; +extern JniContext* jni; /// Types used by JNI API to distinguish between primitive types. enum JniType { @@ -73,19 +134,19 @@ enum JniType { /// If [exception] is null, it means the result is valid. /// It's assumed that the caller knows the expected type in [result]. typedef struct JniResult { - jvalue result; + jvalue value; jthrowable exception; } JniResult; /// Similar to [JniResult] but for class lookups. typedef struct JniClassLookupResult { - jclass classRef; + jclass value; jthrowable exception; } JniClassLookupResult; /// Similar to [JniResult] but for method/field ID lookups. typedef struct JniPointerResult { - void* id; + const void* value; jthrowable exception; } JniPointerResult; @@ -139,54 +200,71 @@ FFI_PLUGIN_EXPORT JavaVM* GetJavaVM(void); FFI_PLUGIN_EXPORT JNIEnv* GetJniEnv(void); -FFI_PLUGIN_EXPORT JNIEnv* SpawnJvm(JavaVMInitArgs* args); +/// 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. +FFI_PLUGIN_EXPORT int SpawnJvm(JavaVMInitArgs* args); -FFI_PLUGIN_EXPORT jclass LoadClass(const char* name); +/// Load class through platform-specific mechanism. +/// +/// Currently uses application classloader on android, +/// and JNIEnv->FindClass on other platforms. +FFI_PLUGIN_EXPORT jclass FindClass(const char* name); +/// Returns Application classLoader (on Android), +/// which can be used to load application and platform classes. +/// +/// On other platforms, NULL is returned. FFI_PLUGIN_EXPORT jobject GetClassLoader(void); +/// Returns application context on Android. +/// +/// On other platforms, NULL is returned. FFI_PLUGIN_EXPORT jobject GetApplicationContext(void); +/// Returns current activity of the app on Android. FFI_PLUGIN_EXPORT jobject GetCurrentActivity(void); -// Migration note: Below inline functions are required by C bindings, but can be moved to dartjni.c -// once migration to pure dart bindings is complete. - -// `static inline` because `inline` doesn't work, it may still not -// inline the function in which case a linker error may be produced. -// -// There has to be a better way to do this. Either to force inlining on target -// platforms, or just leave it as normal function. +static inline void attach_thread() { + if (jniEnv == NULL) { + (*jni->jvm)->AttachCurrentThread(jni->jvm, __ENVP_CAST & jniEnv, NULL); + } +} -static inline void __load_class_into(jclass* cls, const char* name) { +/// Load class into [cls] using platform specific mechanism +static inline void load_class_platform(jclass* cls, const char* name) { #ifdef __ANDROID__ jstring className = (*jniEnv)->NewStringUTF(jniEnv, name); - *cls = (*jniEnv)->CallObjectMethod(jniEnv, jni.classLoader, - jni.loadClassMethod, className); + *cls = (*jniEnv)->CallObjectMethod(jniEnv, jni->classLoader, + jni->loadClassMethod, className); (*jniEnv)->DeleteLocalRef(jniEnv, className); #else *cls = (*jniEnv)->FindClass(jniEnv, name); #endif } -static inline void load_class(jclass* cls, const char* name) { +static inline void load_class_local_ref(jclass* cls, const char* name) { if (*cls == NULL) { - __load_class_into(cls, name); + acquire_lock(&jni->locks.classLoadingLock); + if (*cls == NULL) { + load_class_platform(cls, name); + } + release_lock(&jni->locks.classLoadingLock); } } -static inline void load_class_gr(jclass* cls, const char* name) { +static inline void load_class_global_ref(jclass* cls, const char* name) { if (*cls == NULL) { - jclass tmp; - __load_class_into(&tmp, name); - *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); - (*jniEnv)->DeleteLocalRef(jniEnv, tmp); - } -} - -static inline void attach_thread() { - if (jniEnv == NULL) { - (*jni.jvm)->AttachCurrentThread(jni.jvm, __ENVP_CAST & jniEnv, NULL); + jclass tmp = NULL; + acquire_lock(&jni->locks.classLoadingLock); + if (*cls == NULL) { + load_class_platform(&tmp, name); + *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); + (*jniEnv)->DeleteLocalRef(jniEnv, tmp); + } + release_lock(&jni->locks.classLoadingLock); } } @@ -195,7 +273,11 @@ static inline void load_method(jclass cls, const char* name, const char* sig) { if (*res == NULL) { - *res = (*jniEnv)->GetMethodID(jniEnv, cls, name, sig); + acquire_lock(&jni->locks.methodLoadingLock); + if (*res == NULL) { + *res = (*jniEnv)->GetMethodID(jniEnv, cls, name, sig); + } + release_lock(&jni->locks.methodLoadingLock); } } @@ -204,7 +286,11 @@ static inline void load_static_method(jclass cls, const char* name, const char* sig) { if (*res == NULL) { - *res = (*jniEnv)->GetStaticMethodID(jniEnv, cls, name, sig); + acquire_lock(&jni->locks.methodLoadingLock); + if (*res == NULL) { + *res = (*jniEnv)->GetStaticMethodID(jniEnv, cls, name, sig); + } + release_lock(&jni->locks.methodLoadingLock); } } @@ -213,7 +299,11 @@ static inline void load_field(jclass cls, const char* name, const char* sig) { if (*res == NULL) { - *res = (*jniEnv)->GetFieldID(jniEnv, cls, name, sig); + acquire_lock(&jni->locks.fieldLoadingLock); + if (*res == NULL) { + *res = (*jniEnv)->GetFieldID(jniEnv, cls, name, sig); + } + release_lock(&jni->locks.fieldLoadingLock); } } @@ -222,7 +312,11 @@ static inline void load_static_field(jclass cls, const char* name, const char* sig) { if (*res == NULL) { - *res = (*jniEnv)->GetStaticFieldID(jniEnv, cls, name, sig); + acquire_lock(&jni->locks.fieldLoadingLock); + if (*res == NULL) { + *res = (*jniEnv)->GetStaticFieldID(jniEnv, cls, name, sig); + } + release_lock(&jni->locks.fieldLoadingLock); } } @@ -234,17 +328,18 @@ static inline jobject to_global_ref(jobject ref) { // These functions are useful for C+Dart bindings, and not required for pure dart bindings. -FFI_PLUGIN_EXPORT JniContext GetJniContext(); +FFI_PLUGIN_EXPORT JniContext* GetJniContextPtr(); + /// For use by jni_gen's generated code /// don't use these. // these 2 fn ptr vars will be defined by generated code library -extern JniContext (*context_getter)(void); +extern JniContext* (*context_getter)(void); extern JNIEnv* (*env_getter)(void); // this function will be exported by generated code library // it will set above 2 variables. -FFI_PLUGIN_EXPORT void setJniGetters(struct JniContext (*cg)(void), +FFI_PLUGIN_EXPORT void setJniGetters(struct JniContext* (*cg)(void), JNIEnv* (*eg)(void)); static inline void load_env() { diff --git a/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart b/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart index 3485f937e..25cd60487 100644 --- a/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart +++ b/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart @@ -61,7 +61,7 @@ class Example extends jni.JObject { _thinkBeforeAnswering(reference, $c.reference).object; final $o = jni.JObjectPtr.fromAddress(await $p.first); final $k = const jni.JStringType().getClass().reference; - if (jni.Jni.env.IsInstanceOf($o, $k) == 0) { + if (!jni.Jni.env.IsInstanceOf($o, $k)) { throw "Failed"; } return const jni.JStringType().fromRef($o); diff --git a/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h b/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h index 39b70bd8f..eb73318d1 100644 --- a/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h +++ b/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h @@ -39,6 +39,66 @@ #define __ENVP_CAST (void**) #endif +/// Locking functions for windows and pthread. + +#if defined _WIN32 +#include + +typedef CRITICAL_SECTION MutexLock; + +static inline void init_lock(MutexLock* lock) { + InitializeCriticalSection(lock); +} + +static inline void acquire_lock(MutexLock* lock) { + EnterCriticalSection(lock); +} + +static inline void release_lock(MutexLock* lock) { + LeaveCriticalSection(lock); +} + +static inline void _destroyLock(MutexLock* lock) { + DeleteCriticalSection(lock); +} + +#elif defined __DARWIN__ || defined __LINUX__ || defined __ANDROID__ || \ + defined __GNUC__ +#include + +typedef pthread_mutex_t MutexLock; + +static inline void init_lock(MutexLock* lock) { + pthread_mutex_init(lock, NULL); +} + +static inline void acquire_lock(MutexLock* lock) { + pthread_mutex_lock(lock); +} + +static inline void release_lock(MutexLock* lock) { + pthread_mutex_unlock(lock); +} + +static inline void _destroyLock(MutexLock* lock) { + pthread_mutex_destroy(lock); +} + +#else + +#error "No locking support; Possibly unsupported platform" + +#endif + +typedef struct JniLocks { + MutexLock classLoadingLock; + MutexLock methodLoadingLock; + MutexLock fieldLoadingLock; +} JniLocks; + +/// Represents the error when dart-jni layer has already spawned singleton VM. +#define DART_JNI_SINGLETON_EXISTS (-99); + /// Stores the global state of the JNI. typedef struct JniContext { JavaVM* jvm; @@ -46,13 +106,14 @@ typedef struct JniContext { jmethodID loadClassMethod; jobject currentActivity; jobject appContext; + JniLocks locks; } JniContext; // jniEnv for this thread, used by inline functions in this header, // therefore declared as extern. extern thread_local JNIEnv* jniEnv; -extern JniContext jni; +extern JniContext* jni; /// Types used by JNI API to distinguish between primitive types. enum JniType { @@ -73,19 +134,19 @@ enum JniType { /// If [exception] is null, it means the result is valid. /// It's assumed that the caller knows the expected type in [result]. typedef struct JniResult { - jvalue result; + jvalue value; jthrowable exception; } JniResult; /// Similar to [JniResult] but for class lookups. typedef struct JniClassLookupResult { - jclass classRef; + jclass value; jthrowable exception; } JniClassLookupResult; /// Similar to [JniResult] but for method/field ID lookups. typedef struct JniPointerResult { - void* id; + const void* value; jthrowable exception; } JniPointerResult; @@ -139,54 +200,71 @@ FFI_PLUGIN_EXPORT JavaVM* GetJavaVM(void); FFI_PLUGIN_EXPORT JNIEnv* GetJniEnv(void); -FFI_PLUGIN_EXPORT JNIEnv* SpawnJvm(JavaVMInitArgs* args); +/// 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. +FFI_PLUGIN_EXPORT int SpawnJvm(JavaVMInitArgs* args); -FFI_PLUGIN_EXPORT jclass LoadClass(const char* name); +/// Load class through platform-specific mechanism. +/// +/// Currently uses application classloader on android, +/// and JNIEnv->FindClass on other platforms. +FFI_PLUGIN_EXPORT jclass FindClass(const char* name); +/// Returns Application classLoader (on Android), +/// which can be used to load application and platform classes. +/// +/// On other platforms, NULL is returned. FFI_PLUGIN_EXPORT jobject GetClassLoader(void); +/// Returns application context on Android. +/// +/// On other platforms, NULL is returned. FFI_PLUGIN_EXPORT jobject GetApplicationContext(void); +/// Returns current activity of the app on Android. FFI_PLUGIN_EXPORT jobject GetCurrentActivity(void); -// Migration note: Below inline functions are required by C bindings, but can be moved to dartjni.c -// once migration to pure dart bindings is complete. - -// `static inline` because `inline` doesn't work, it may still not -// inline the function in which case a linker error may be produced. -// -// There has to be a better way to do this. Either to force inlining on target -// platforms, or just leave it as normal function. +static inline void attach_thread() { + if (jniEnv == NULL) { + (*jni->jvm)->AttachCurrentThread(jni->jvm, __ENVP_CAST & jniEnv, NULL); + } +} -static inline void __load_class_into(jclass* cls, const char* name) { +/// Load class into [cls] using platform specific mechanism +static inline void load_class_platform(jclass* cls, const char* name) { #ifdef __ANDROID__ jstring className = (*jniEnv)->NewStringUTF(jniEnv, name); - *cls = (*jniEnv)->CallObjectMethod(jniEnv, jni.classLoader, - jni.loadClassMethod, className); + *cls = (*jniEnv)->CallObjectMethod(jniEnv, jni->classLoader, + jni->loadClassMethod, className); (*jniEnv)->DeleteLocalRef(jniEnv, className); #else *cls = (*jniEnv)->FindClass(jniEnv, name); #endif } -static inline void load_class(jclass* cls, const char* name) { +static inline void load_class_local_ref(jclass* cls, const char* name) { if (*cls == NULL) { - __load_class_into(cls, name); + acquire_lock(&jni->locks.classLoadingLock); + if (*cls == NULL) { + load_class_platform(cls, name); + } + release_lock(&jni->locks.classLoadingLock); } } -static inline void load_class_gr(jclass* cls, const char* name) { +static inline void load_class_global_ref(jclass* cls, const char* name) { if (*cls == NULL) { - jclass tmp; - __load_class_into(&tmp, name); - *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); - (*jniEnv)->DeleteLocalRef(jniEnv, tmp); - } -} - -static inline void attach_thread() { - if (jniEnv == NULL) { - (*jni.jvm)->AttachCurrentThread(jni.jvm, __ENVP_CAST & jniEnv, NULL); + jclass tmp = NULL; + acquire_lock(&jni->locks.classLoadingLock); + if (*cls == NULL) { + load_class_platform(&tmp, name); + *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); + (*jniEnv)->DeleteLocalRef(jniEnv, tmp); + } + release_lock(&jni->locks.classLoadingLock); } } @@ -195,7 +273,11 @@ static inline void load_method(jclass cls, const char* name, const char* sig) { if (*res == NULL) { - *res = (*jniEnv)->GetMethodID(jniEnv, cls, name, sig); + acquire_lock(&jni->locks.methodLoadingLock); + if (*res == NULL) { + *res = (*jniEnv)->GetMethodID(jniEnv, cls, name, sig); + } + release_lock(&jni->locks.methodLoadingLock); } } @@ -204,7 +286,11 @@ static inline void load_static_method(jclass cls, const char* name, const char* sig) { if (*res == NULL) { - *res = (*jniEnv)->GetStaticMethodID(jniEnv, cls, name, sig); + acquire_lock(&jni->locks.methodLoadingLock); + if (*res == NULL) { + *res = (*jniEnv)->GetStaticMethodID(jniEnv, cls, name, sig); + } + release_lock(&jni->locks.methodLoadingLock); } } @@ -213,7 +299,11 @@ static inline void load_field(jclass cls, const char* name, const char* sig) { if (*res == NULL) { - *res = (*jniEnv)->GetFieldID(jniEnv, cls, name, sig); + acquire_lock(&jni->locks.fieldLoadingLock); + if (*res == NULL) { + *res = (*jniEnv)->GetFieldID(jniEnv, cls, name, sig); + } + release_lock(&jni->locks.fieldLoadingLock); } } @@ -222,7 +312,11 @@ static inline void load_static_field(jclass cls, const char* name, const char* sig) { if (*res == NULL) { - *res = (*jniEnv)->GetStaticFieldID(jniEnv, cls, name, sig); + acquire_lock(&jni->locks.fieldLoadingLock); + if (*res == NULL) { + *res = (*jniEnv)->GetStaticFieldID(jniEnv, cls, name, sig); + } + release_lock(&jni->locks.fieldLoadingLock); } } @@ -234,17 +328,18 @@ static inline jobject to_global_ref(jobject ref) { // These functions are useful for C+Dart bindings, and not required for pure dart bindings. -FFI_PLUGIN_EXPORT JniContext GetJniContext(); +FFI_PLUGIN_EXPORT JniContext* GetJniContextPtr(); + /// For use by jni_gen's generated code /// don't use these. // these 2 fn ptr vars will be defined by generated code library -extern JniContext (*context_getter)(void); +extern JniContext* (*context_getter)(void); extern JNIEnv* (*env_getter)(void); // this function will be exported by generated code library // it will set above 2 variables. -FFI_PLUGIN_EXPORT void setJniGetters(struct JniContext (*cg)(void), +FFI_PLUGIN_EXPORT void setJniGetters(struct JniContext* (*cg)(void), JNIEnv* (*eg)(void)); static inline void load_env() { diff --git a/pkgs/jnigen/example/kotlin_plugin/src/kotlin_plugin_bindings.c b/pkgs/jnigen/example/kotlin_plugin/src/kotlin_plugin_bindings.c index 77075ceb2..d93599cee 100644 --- a/pkgs/jnigen/example/kotlin_plugin/src/kotlin_plugin_bindings.c +++ b/pkgs/jnigen/example/kotlin_plugin/src/kotlin_plugin_bindings.c @@ -5,12 +5,12 @@ #include "jni.h" thread_local JNIEnv* jniEnv; -JniContext jni; +JniContext* jni; -JniContext (*context_getter)(void); +JniContext* (*context_getter)(void); JNIEnv* (*env_getter)(void); -void setJniGetters(JniContext (*cg)(void), JNIEnv* (*eg)(void)) { +void setJniGetters(JniContext* (*cg)(void), JNIEnv* (*eg)(void)) { context_getter = cg; env_getter = eg; } @@ -22,14 +22,14 @@ jmethodID _m_Example__ctor = NULL; FFI_PLUGIN_EXPORT JniResult Example__ctor() { load_env(); - load_class_gr(&_c_Example, "Example"); + load_class_global_ref(&_c_Example, "Example"); if (_c_Example == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_Example, &_m_Example__ctor, "", "()V"); if (_m_Example__ctor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Example, _m_Example__ctor); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -37,16 +37,16 @@ jmethodID _m_Example__thinkBeforeAnswering = NULL; FFI_PLUGIN_EXPORT JniResult Example__thinkBeforeAnswering(jobject self_, jobject continuation) { load_env(); - load_class_gr(&_c_Example, "Example"); + load_class_global_ref(&_c_Example, "Example"); if (_c_Example == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_Example, &_m_Example__thinkBeforeAnswering, "thinkBeforeAnswering", "(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;"); if (_m_Example__thinkBeforeAnswering == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_Example__thinkBeforeAnswering, continuation); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } diff --git a/pkgs/jnigen/example/notification_plugin/src/dartjni.h b/pkgs/jnigen/example/notification_plugin/src/dartjni.h index 39b70bd8f..eb73318d1 100644 --- a/pkgs/jnigen/example/notification_plugin/src/dartjni.h +++ b/pkgs/jnigen/example/notification_plugin/src/dartjni.h @@ -39,6 +39,66 @@ #define __ENVP_CAST (void**) #endif +/// Locking functions for windows and pthread. + +#if defined _WIN32 +#include + +typedef CRITICAL_SECTION MutexLock; + +static inline void init_lock(MutexLock* lock) { + InitializeCriticalSection(lock); +} + +static inline void acquire_lock(MutexLock* lock) { + EnterCriticalSection(lock); +} + +static inline void release_lock(MutexLock* lock) { + LeaveCriticalSection(lock); +} + +static inline void _destroyLock(MutexLock* lock) { + DeleteCriticalSection(lock); +} + +#elif defined __DARWIN__ || defined __LINUX__ || defined __ANDROID__ || \ + defined __GNUC__ +#include + +typedef pthread_mutex_t MutexLock; + +static inline void init_lock(MutexLock* lock) { + pthread_mutex_init(lock, NULL); +} + +static inline void acquire_lock(MutexLock* lock) { + pthread_mutex_lock(lock); +} + +static inline void release_lock(MutexLock* lock) { + pthread_mutex_unlock(lock); +} + +static inline void _destroyLock(MutexLock* lock) { + pthread_mutex_destroy(lock); +} + +#else + +#error "No locking support; Possibly unsupported platform" + +#endif + +typedef struct JniLocks { + MutexLock classLoadingLock; + MutexLock methodLoadingLock; + MutexLock fieldLoadingLock; +} JniLocks; + +/// Represents the error when dart-jni layer has already spawned singleton VM. +#define DART_JNI_SINGLETON_EXISTS (-99); + /// Stores the global state of the JNI. typedef struct JniContext { JavaVM* jvm; @@ -46,13 +106,14 @@ typedef struct JniContext { jmethodID loadClassMethod; jobject currentActivity; jobject appContext; + JniLocks locks; } JniContext; // jniEnv for this thread, used by inline functions in this header, // therefore declared as extern. extern thread_local JNIEnv* jniEnv; -extern JniContext jni; +extern JniContext* jni; /// Types used by JNI API to distinguish between primitive types. enum JniType { @@ -73,19 +134,19 @@ enum JniType { /// If [exception] is null, it means the result is valid. /// It's assumed that the caller knows the expected type in [result]. typedef struct JniResult { - jvalue result; + jvalue value; jthrowable exception; } JniResult; /// Similar to [JniResult] but for class lookups. typedef struct JniClassLookupResult { - jclass classRef; + jclass value; jthrowable exception; } JniClassLookupResult; /// Similar to [JniResult] but for method/field ID lookups. typedef struct JniPointerResult { - void* id; + const void* value; jthrowable exception; } JniPointerResult; @@ -139,54 +200,71 @@ FFI_PLUGIN_EXPORT JavaVM* GetJavaVM(void); FFI_PLUGIN_EXPORT JNIEnv* GetJniEnv(void); -FFI_PLUGIN_EXPORT JNIEnv* SpawnJvm(JavaVMInitArgs* args); +/// 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. +FFI_PLUGIN_EXPORT int SpawnJvm(JavaVMInitArgs* args); -FFI_PLUGIN_EXPORT jclass LoadClass(const char* name); +/// Load class through platform-specific mechanism. +/// +/// Currently uses application classloader on android, +/// and JNIEnv->FindClass on other platforms. +FFI_PLUGIN_EXPORT jclass FindClass(const char* name); +/// Returns Application classLoader (on Android), +/// which can be used to load application and platform classes. +/// +/// On other platforms, NULL is returned. FFI_PLUGIN_EXPORT jobject GetClassLoader(void); +/// Returns application context on Android. +/// +/// On other platforms, NULL is returned. FFI_PLUGIN_EXPORT jobject GetApplicationContext(void); +/// Returns current activity of the app on Android. FFI_PLUGIN_EXPORT jobject GetCurrentActivity(void); -// Migration note: Below inline functions are required by C bindings, but can be moved to dartjni.c -// once migration to pure dart bindings is complete. - -// `static inline` because `inline` doesn't work, it may still not -// inline the function in which case a linker error may be produced. -// -// There has to be a better way to do this. Either to force inlining on target -// platforms, or just leave it as normal function. +static inline void attach_thread() { + if (jniEnv == NULL) { + (*jni->jvm)->AttachCurrentThread(jni->jvm, __ENVP_CAST & jniEnv, NULL); + } +} -static inline void __load_class_into(jclass* cls, const char* name) { +/// Load class into [cls] using platform specific mechanism +static inline void load_class_platform(jclass* cls, const char* name) { #ifdef __ANDROID__ jstring className = (*jniEnv)->NewStringUTF(jniEnv, name); - *cls = (*jniEnv)->CallObjectMethod(jniEnv, jni.classLoader, - jni.loadClassMethod, className); + *cls = (*jniEnv)->CallObjectMethod(jniEnv, jni->classLoader, + jni->loadClassMethod, className); (*jniEnv)->DeleteLocalRef(jniEnv, className); #else *cls = (*jniEnv)->FindClass(jniEnv, name); #endif } -static inline void load_class(jclass* cls, const char* name) { +static inline void load_class_local_ref(jclass* cls, const char* name) { if (*cls == NULL) { - __load_class_into(cls, name); + acquire_lock(&jni->locks.classLoadingLock); + if (*cls == NULL) { + load_class_platform(cls, name); + } + release_lock(&jni->locks.classLoadingLock); } } -static inline void load_class_gr(jclass* cls, const char* name) { +static inline void load_class_global_ref(jclass* cls, const char* name) { if (*cls == NULL) { - jclass tmp; - __load_class_into(&tmp, name); - *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); - (*jniEnv)->DeleteLocalRef(jniEnv, tmp); - } -} - -static inline void attach_thread() { - if (jniEnv == NULL) { - (*jni.jvm)->AttachCurrentThread(jni.jvm, __ENVP_CAST & jniEnv, NULL); + jclass tmp = NULL; + acquire_lock(&jni->locks.classLoadingLock); + if (*cls == NULL) { + load_class_platform(&tmp, name); + *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); + (*jniEnv)->DeleteLocalRef(jniEnv, tmp); + } + release_lock(&jni->locks.classLoadingLock); } } @@ -195,7 +273,11 @@ static inline void load_method(jclass cls, const char* name, const char* sig) { if (*res == NULL) { - *res = (*jniEnv)->GetMethodID(jniEnv, cls, name, sig); + acquire_lock(&jni->locks.methodLoadingLock); + if (*res == NULL) { + *res = (*jniEnv)->GetMethodID(jniEnv, cls, name, sig); + } + release_lock(&jni->locks.methodLoadingLock); } } @@ -204,7 +286,11 @@ static inline void load_static_method(jclass cls, const char* name, const char* sig) { if (*res == NULL) { - *res = (*jniEnv)->GetStaticMethodID(jniEnv, cls, name, sig); + acquire_lock(&jni->locks.methodLoadingLock); + if (*res == NULL) { + *res = (*jniEnv)->GetStaticMethodID(jniEnv, cls, name, sig); + } + release_lock(&jni->locks.methodLoadingLock); } } @@ -213,7 +299,11 @@ static inline void load_field(jclass cls, const char* name, const char* sig) { if (*res == NULL) { - *res = (*jniEnv)->GetFieldID(jniEnv, cls, name, sig); + acquire_lock(&jni->locks.fieldLoadingLock); + if (*res == NULL) { + *res = (*jniEnv)->GetFieldID(jniEnv, cls, name, sig); + } + release_lock(&jni->locks.fieldLoadingLock); } } @@ -222,7 +312,11 @@ static inline void load_static_field(jclass cls, const char* name, const char* sig) { if (*res == NULL) { - *res = (*jniEnv)->GetStaticFieldID(jniEnv, cls, name, sig); + acquire_lock(&jni->locks.fieldLoadingLock); + if (*res == NULL) { + *res = (*jniEnv)->GetStaticFieldID(jniEnv, cls, name, sig); + } + release_lock(&jni->locks.fieldLoadingLock); } } @@ -234,17 +328,18 @@ static inline jobject to_global_ref(jobject ref) { // These functions are useful for C+Dart bindings, and not required for pure dart bindings. -FFI_PLUGIN_EXPORT JniContext GetJniContext(); +FFI_PLUGIN_EXPORT JniContext* GetJniContextPtr(); + /// For use by jni_gen's generated code /// don't use these. // these 2 fn ptr vars will be defined by generated code library -extern JniContext (*context_getter)(void); +extern JniContext* (*context_getter)(void); extern JNIEnv* (*env_getter)(void); // this function will be exported by generated code library // it will set above 2 variables. -FFI_PLUGIN_EXPORT void setJniGetters(struct JniContext (*cg)(void), +FFI_PLUGIN_EXPORT void setJniGetters(struct JniContext* (*cg)(void), JNIEnv* (*eg)(void)); static inline void load_env() { diff --git a/pkgs/jnigen/example/notification_plugin/src/notification_plugin.c b/pkgs/jnigen/example/notification_plugin/src/notification_plugin.c index f4b384e2a..8eb077c12 100644 --- a/pkgs/jnigen/example/notification_plugin/src/notification_plugin.c +++ b/pkgs/jnigen/example/notification_plugin/src/notification_plugin.c @@ -9,12 +9,12 @@ #include "jni.h" thread_local JNIEnv* jniEnv; -JniContext jni; +JniContext* jni; -JniContext (*context_getter)(void); +JniContext* (*context_getter)(void); JNIEnv* (*env_getter)(void); -void setJniGetters(JniContext (*cg)(void), JNIEnv* (*eg)(void)) { +void setJniGetters(JniContext* (*cg)(void), JNIEnv* (*eg)(void)) { context_getter = cg; env_getter = eg; } @@ -26,16 +26,16 @@ jmethodID _m_Notifications__ctor = NULL; FFI_PLUGIN_EXPORT JniResult Notifications__ctor() { load_env(); - load_class_gr(&_c_Notifications, - "com/example/notification_plugin/Notifications"); + load_class_global_ref(&_c_Notifications, + "com/example/notification_plugin/Notifications"); if (_c_Notifications == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_Notifications, &_m_Notifications__ctor, "", "()V"); if (_m_Notifications__ctor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Notifications, _m_Notifications__ctor); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -46,17 +46,17 @@ JniResult Notifications__showNotification(jobject context, jobject title, jobject text) { load_env(); - load_class_gr(&_c_Notifications, - "com/example/notification_plugin/Notifications"); + load_class_global_ref(&_c_Notifications, + "com/example/notification_plugin/Notifications"); if (_c_Notifications == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method( _c_Notifications, &_m_Notifications__showNotification, "showNotification", "(Landroid/content/Context;ILjava/lang/String;Ljava/lang/String;)V"); if (_m_Notifications__showNotification == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallStaticVoidMethod(jniEnv, _c_Notifications, _m_Notifications__showNotification, context, notificationID, title, text); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } diff --git a/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h b/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h index 39b70bd8f..eb73318d1 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h +++ b/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h @@ -39,6 +39,66 @@ #define __ENVP_CAST (void**) #endif +/// Locking functions for windows and pthread. + +#if defined _WIN32 +#include + +typedef CRITICAL_SECTION MutexLock; + +static inline void init_lock(MutexLock* lock) { + InitializeCriticalSection(lock); +} + +static inline void acquire_lock(MutexLock* lock) { + EnterCriticalSection(lock); +} + +static inline void release_lock(MutexLock* lock) { + LeaveCriticalSection(lock); +} + +static inline void _destroyLock(MutexLock* lock) { + DeleteCriticalSection(lock); +} + +#elif defined __DARWIN__ || defined __LINUX__ || defined __ANDROID__ || \ + defined __GNUC__ +#include + +typedef pthread_mutex_t MutexLock; + +static inline void init_lock(MutexLock* lock) { + pthread_mutex_init(lock, NULL); +} + +static inline void acquire_lock(MutexLock* lock) { + pthread_mutex_lock(lock); +} + +static inline void release_lock(MutexLock* lock) { + pthread_mutex_unlock(lock); +} + +static inline void _destroyLock(MutexLock* lock) { + pthread_mutex_destroy(lock); +} + +#else + +#error "No locking support; Possibly unsupported platform" + +#endif + +typedef struct JniLocks { + MutexLock classLoadingLock; + MutexLock methodLoadingLock; + MutexLock fieldLoadingLock; +} JniLocks; + +/// Represents the error when dart-jni layer has already spawned singleton VM. +#define DART_JNI_SINGLETON_EXISTS (-99); + /// Stores the global state of the JNI. typedef struct JniContext { JavaVM* jvm; @@ -46,13 +106,14 @@ typedef struct JniContext { jmethodID loadClassMethod; jobject currentActivity; jobject appContext; + JniLocks locks; } JniContext; // jniEnv for this thread, used by inline functions in this header, // therefore declared as extern. extern thread_local JNIEnv* jniEnv; -extern JniContext jni; +extern JniContext* jni; /// Types used by JNI API to distinguish between primitive types. enum JniType { @@ -73,19 +134,19 @@ enum JniType { /// If [exception] is null, it means the result is valid. /// It's assumed that the caller knows the expected type in [result]. typedef struct JniResult { - jvalue result; + jvalue value; jthrowable exception; } JniResult; /// Similar to [JniResult] but for class lookups. typedef struct JniClassLookupResult { - jclass classRef; + jclass value; jthrowable exception; } JniClassLookupResult; /// Similar to [JniResult] but for method/field ID lookups. typedef struct JniPointerResult { - void* id; + const void* value; jthrowable exception; } JniPointerResult; @@ -139,54 +200,71 @@ FFI_PLUGIN_EXPORT JavaVM* GetJavaVM(void); FFI_PLUGIN_EXPORT JNIEnv* GetJniEnv(void); -FFI_PLUGIN_EXPORT JNIEnv* SpawnJvm(JavaVMInitArgs* args); +/// 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. +FFI_PLUGIN_EXPORT int SpawnJvm(JavaVMInitArgs* args); -FFI_PLUGIN_EXPORT jclass LoadClass(const char* name); +/// Load class through platform-specific mechanism. +/// +/// Currently uses application classloader on android, +/// and JNIEnv->FindClass on other platforms. +FFI_PLUGIN_EXPORT jclass FindClass(const char* name); +/// Returns Application classLoader (on Android), +/// which can be used to load application and platform classes. +/// +/// On other platforms, NULL is returned. FFI_PLUGIN_EXPORT jobject GetClassLoader(void); +/// Returns application context on Android. +/// +/// On other platforms, NULL is returned. FFI_PLUGIN_EXPORT jobject GetApplicationContext(void); +/// Returns current activity of the app on Android. FFI_PLUGIN_EXPORT jobject GetCurrentActivity(void); -// Migration note: Below inline functions are required by C bindings, but can be moved to dartjni.c -// once migration to pure dart bindings is complete. - -// `static inline` because `inline` doesn't work, it may still not -// inline the function in which case a linker error may be produced. -// -// There has to be a better way to do this. Either to force inlining on target -// platforms, or just leave it as normal function. +static inline void attach_thread() { + if (jniEnv == NULL) { + (*jni->jvm)->AttachCurrentThread(jni->jvm, __ENVP_CAST & jniEnv, NULL); + } +} -static inline void __load_class_into(jclass* cls, const char* name) { +/// Load class into [cls] using platform specific mechanism +static inline void load_class_platform(jclass* cls, const char* name) { #ifdef __ANDROID__ jstring className = (*jniEnv)->NewStringUTF(jniEnv, name); - *cls = (*jniEnv)->CallObjectMethod(jniEnv, jni.classLoader, - jni.loadClassMethod, className); + *cls = (*jniEnv)->CallObjectMethod(jniEnv, jni->classLoader, + jni->loadClassMethod, className); (*jniEnv)->DeleteLocalRef(jniEnv, className); #else *cls = (*jniEnv)->FindClass(jniEnv, name); #endif } -static inline void load_class(jclass* cls, const char* name) { +static inline void load_class_local_ref(jclass* cls, const char* name) { if (*cls == NULL) { - __load_class_into(cls, name); + acquire_lock(&jni->locks.classLoadingLock); + if (*cls == NULL) { + load_class_platform(cls, name); + } + release_lock(&jni->locks.classLoadingLock); } } -static inline void load_class_gr(jclass* cls, const char* name) { +static inline void load_class_global_ref(jclass* cls, const char* name) { if (*cls == NULL) { - jclass tmp; - __load_class_into(&tmp, name); - *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); - (*jniEnv)->DeleteLocalRef(jniEnv, tmp); - } -} - -static inline void attach_thread() { - if (jniEnv == NULL) { - (*jni.jvm)->AttachCurrentThread(jni.jvm, __ENVP_CAST & jniEnv, NULL); + jclass tmp = NULL; + acquire_lock(&jni->locks.classLoadingLock); + if (*cls == NULL) { + load_class_platform(&tmp, name); + *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); + (*jniEnv)->DeleteLocalRef(jniEnv, tmp); + } + release_lock(&jni->locks.classLoadingLock); } } @@ -195,7 +273,11 @@ static inline void load_method(jclass cls, const char* name, const char* sig) { if (*res == NULL) { - *res = (*jniEnv)->GetMethodID(jniEnv, cls, name, sig); + acquire_lock(&jni->locks.methodLoadingLock); + if (*res == NULL) { + *res = (*jniEnv)->GetMethodID(jniEnv, cls, name, sig); + } + release_lock(&jni->locks.methodLoadingLock); } } @@ -204,7 +286,11 @@ static inline void load_static_method(jclass cls, const char* name, const char* sig) { if (*res == NULL) { - *res = (*jniEnv)->GetStaticMethodID(jniEnv, cls, name, sig); + acquire_lock(&jni->locks.methodLoadingLock); + if (*res == NULL) { + *res = (*jniEnv)->GetStaticMethodID(jniEnv, cls, name, sig); + } + release_lock(&jni->locks.methodLoadingLock); } } @@ -213,7 +299,11 @@ static inline void load_field(jclass cls, const char* name, const char* sig) { if (*res == NULL) { - *res = (*jniEnv)->GetFieldID(jniEnv, cls, name, sig); + acquire_lock(&jni->locks.fieldLoadingLock); + if (*res == NULL) { + *res = (*jniEnv)->GetFieldID(jniEnv, cls, name, sig); + } + release_lock(&jni->locks.fieldLoadingLock); } } @@ -222,7 +312,11 @@ static inline void load_static_field(jclass cls, const char* name, const char* sig) { if (*res == NULL) { - *res = (*jniEnv)->GetStaticFieldID(jniEnv, cls, name, sig); + acquire_lock(&jni->locks.fieldLoadingLock); + if (*res == NULL) { + *res = (*jniEnv)->GetStaticFieldID(jniEnv, cls, name, sig); + } + release_lock(&jni->locks.fieldLoadingLock); } } @@ -234,17 +328,18 @@ static inline jobject to_global_ref(jobject ref) { // These functions are useful for C+Dart bindings, and not required for pure dart bindings. -FFI_PLUGIN_EXPORT JniContext GetJniContext(); +FFI_PLUGIN_EXPORT JniContext* GetJniContextPtr(); + /// For use by jni_gen's generated code /// don't use these. // these 2 fn ptr vars will be defined by generated code library -extern JniContext (*context_getter)(void); +extern JniContext* (*context_getter)(void); extern JNIEnv* (*env_getter)(void); // this function will be exported by generated code library // it will set above 2 variables. -FFI_PLUGIN_EXPORT void setJniGetters(struct JniContext (*cg)(void), +FFI_PLUGIN_EXPORT void setJniGetters(struct JniContext* (*cg)(void), JNIEnv* (*eg)(void)); static inline void load_env() { diff --git a/pkgs/jnigen/example/pdfbox_plugin/src/third_party/pdfbox_plugin.c b/pkgs/jnigen/example/pdfbox_plugin/src/third_party/pdfbox_plugin.c index 71dcd3249..0ce1442b3 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/src/third_party/pdfbox_plugin.c +++ b/pkgs/jnigen/example/pdfbox_plugin/src/third_party/pdfbox_plugin.c @@ -23,12 +23,12 @@ #include "jni.h" thread_local JNIEnv* jniEnv; -JniContext jni; +JniContext* jni; -JniContext (*context_getter)(void); +JniContext* (*context_getter)(void); JNIEnv* (*env_getter)(void); -void setJniGetters(JniContext (*cg)(void), JNIEnv* (*eg)(void)) { +void setJniGetters(JniContext* (*cg)(void), JNIEnv* (*eg)(void)) { context_getter = cg; env_getter = eg; } @@ -40,15 +40,15 @@ jmethodID _m_PDDocument__ctor = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__ctor() { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__ctor, "", "()V"); if (_m_PDDocument__ctor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_PDDocument, _m_PDDocument__ctor); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -56,16 +56,16 @@ jmethodID _m_PDDocument__ctor1 = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__ctor1(jobject memUsageSetting) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__ctor1, "", "(Lorg/apache/pdfbox/io/MemoryUsageSetting;)V"); if (_m_PDDocument__ctor1 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_PDDocument, _m_PDDocument__ctor1, memUsageSetting); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -73,16 +73,16 @@ jmethodID _m_PDDocument__ctor2 = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__ctor2(jobject doc) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__ctor2, "", "(Lorg/apache/pdfbox/cos/COSDocument;)V"); if (_m_PDDocument__ctor2 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_PDDocument, _m_PDDocument__ctor2, doc); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -90,17 +90,17 @@ jmethodID _m_PDDocument__ctor3 = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__ctor3(jobject doc, jobject source) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__ctor3, "", "(Lorg/apache/pdfbox/cos/COSDocument;Lorg/apache/pdfbox/io/" "RandomAccessRead;)V"); if (_m_PDDocument__ctor3 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_PDDocument, _m_PDDocument__ctor3, doc, source); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -108,18 +108,18 @@ jmethodID _m_PDDocument__ctor4 = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__ctor4(jobject doc, jobject source, jobject permission) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__ctor4, "", "(Lorg/apache/pdfbox/cos/COSDocument;Lorg/apache/pdfbox/io/" "RandomAccessRead;Lorg/apache/pdfbox/pdmodel/encryption/" "AccessPermission;)V"); if (_m_PDDocument__ctor4 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject( jniEnv, _c_PDDocument, _m_PDDocument__ctor4, doc, source, permission); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -127,32 +127,32 @@ jmethodID _m_PDDocument__addPage = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__addPage(jobject self_, jobject page) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__addPage, "addPage", "(Lorg/apache/pdfbox/pdmodel/PDPage;)V"); if (_m_PDDocument__addPage == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDDocument__addPage, page); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDDocument__addSignature = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__addSignature(jobject self_, jobject sigObject) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__addSignature, "addSignature", "(Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/" "PDSignature;)V"); if (_m_PDDocument__addSignature == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDDocument__addSignature, sigObject); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDDocument__addSignature1 = NULL; @@ -161,18 +161,18 @@ JniResult PDDocument__addSignature1(jobject self_, jobject sigObject, jobject options) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__addSignature1, "addSignature", "(Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/" "PDSignature;Lorg/apache/pdfbox/pdmodel/interactive/" "digitalsignature/SignatureOptions;)V"); if (_m_PDDocument__addSignature1 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDDocument__addSignature1, sigObject, options); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDDocument__addSignature2 = NULL; @@ -181,18 +181,18 @@ JniResult PDDocument__addSignature2(jobject self_, jobject sigObject, jobject signatureInterface) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__addSignature2, "addSignature", "(Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/" "PDSignature;Lorg/apache/pdfbox/pdmodel/interactive/" "digitalsignature/SignatureInterface;)V"); if (_m_PDDocument__addSignature2 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDDocument__addSignature2, sigObject, signatureInterface); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDDocument__addSignature3 = NULL; @@ -202,19 +202,19 @@ JniResult PDDocument__addSignature3(jobject self_, jobject signatureInterface, jobject options) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__addSignature3, "addSignature", "(Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/" "PDSignature;Lorg/apache/pdfbox/pdmodel/interactive/" "digitalsignature/SignatureInterface;Lorg/apache/pdfbox/pdmodel/" "interactive/digitalsignature/SignatureOptions;)V"); if (_m_PDDocument__addSignature3 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDDocument__addSignature3, sigObject, signatureInterface, options); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDDocument__addSignatureField = NULL; @@ -224,66 +224,66 @@ JniResult PDDocument__addSignatureField(jobject self_, jobject signatureInterface, jobject options) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__addSignatureField, "addSignatureField", "(Ljava/util/List;Lorg/apache/pdfbox/pdmodel/interactive/" "digitalsignature/SignatureInterface;Lorg/apache/pdfbox/pdmodel/" "interactive/digitalsignature/SignatureOptions;)V"); if (_m_PDDocument__addSignatureField == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDDocument__addSignatureField, sigFields, signatureInterface, options); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDDocument__removePage = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__removePage(jobject self_, jobject page) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__removePage, "removePage", "(Lorg/apache/pdfbox/pdmodel/PDPage;)V"); if (_m_PDDocument__removePage == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDDocument__removePage, page); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDDocument__removePage1 = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__removePage1(jobject self_, int32_t pageNumber) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__removePage1, "removePage", "(I)V"); if (_m_PDDocument__removePage1 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDDocument__removePage1, pageNumber); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDDocument__importPage = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__importPage(jobject self_, jobject page) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method( _c_PDDocument, &_m_PDDocument__importPage, "importPage", "(Lorg/apache/pdfbox/pdmodel/PDPage;)Lorg/apache/pdfbox/pdmodel/PDPage;"); if (_m_PDDocument__importPage == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocument__importPage, page); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -291,16 +291,16 @@ jmethodID _m_PDDocument__getDocument = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__getDocument(jobject self_) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__getDocument, "getDocument", "()Lorg/apache/pdfbox/cos/COSDocument;"); if (_m_PDDocument__getDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_PDDocument__getDocument); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -308,17 +308,17 @@ jmethodID _m_PDDocument__getDocumentInformation = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__getDocumentInformation(jobject self_) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__getDocumentInformation, "getDocumentInformation", "()Lorg/apache/pdfbox/pdmodel/PDDocumentInformation;"); if (_m_PDDocument__getDocumentInformation == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocument__getDocumentInformation); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -326,34 +326,34 @@ jmethodID _m_PDDocument__setDocumentInformation = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__setDocumentInformation(jobject self_, jobject info) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__setDocumentInformation, "setDocumentInformation", "(Lorg/apache/pdfbox/pdmodel/PDDocumentInformation;)V"); if (_m_PDDocument__setDocumentInformation == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDDocument__setDocumentInformation, info); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDDocument__getDocumentCatalog = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__getDocumentCatalog(jobject self_) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__getDocumentCatalog, "getDocumentCatalog", "()Lorg/apache/pdfbox/pdmodel/PDDocumentCatalog;"); if (_m_PDDocument__getDocumentCatalog == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocument__getDocumentCatalog); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -361,31 +361,31 @@ jmethodID _m_PDDocument__isEncrypted = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__isEncrypted(jobject self_) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__isEncrypted, "isEncrypted", "()Z"); if (_m_PDDocument__isEncrypted == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_PDDocument__isEncrypted); - return (JniResult){.result = {.z = _result}, .exception = check_exception()}; + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; } jmethodID _m_PDDocument__getEncryption = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__getEncryption(jobject self_) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__getEncryption, "getEncryption", "()Lorg/apache/pdfbox/pdmodel/encryption/PDEncryption;"); if (_m_PDDocument__getEncryption == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_PDDocument__getEncryption); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -394,35 +394,35 @@ FFI_PLUGIN_EXPORT JniResult PDDocument__setEncryptionDictionary(jobject self_, jobject encryption) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__setEncryptionDictionary, "setEncryptionDictionary", "(Lorg/apache/pdfbox/pdmodel/encryption/PDEncryption;)V"); if (_m_PDDocument__setEncryptionDictionary == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDDocument__setEncryptionDictionary, encryption); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDDocument__getLastSignatureDictionary = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__getLastSignatureDictionary(jobject self_) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method( _c_PDDocument, &_m_PDDocument__getLastSignatureDictionary, "getLastSignatureDictionary", "()Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSignature;"); if (_m_PDDocument__getLastSignatureDictionary == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocument__getLastSignatureDictionary); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -430,16 +430,16 @@ jmethodID _m_PDDocument__getSignatureFields = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__getSignatureFields(jobject self_) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__getSignatureFields, "getSignatureFields", "()Ljava/util/List;"); if (_m_PDDocument__getSignatureFields == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocument__getSignatureFields); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -447,16 +447,16 @@ jmethodID _m_PDDocument__getSignatureDictionaries = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__getSignatureDictionaries(jobject self_) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__getSignatureDictionaries, "getSignatureDictionaries", "()Ljava/util/List;"); if (_m_PDDocument__getSignatureDictionaries == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocument__getSignatureDictionaries); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -465,33 +465,33 @@ FFI_PLUGIN_EXPORT JniResult PDDocument__registerTrueTypeFontForClosing(jobject self_, jobject ttf) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__registerTrueTypeFontForClosing, "registerTrueTypeFontForClosing", "(Lorg/apache/fontbox/ttf/TrueTypeFont;)V"); if (_m_PDDocument__registerTrueTypeFontForClosing == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDDocument__registerTrueTypeFontForClosing, ttf); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDDocument__load = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__load(jobject file) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method(_c_PDDocument, &_m_PDDocument__load, "load", "(Ljava/io/File;)Lorg/apache/pdfbox/pdmodel/PDDocument;"); if (_m_PDDocument__load == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_PDDocument, _m_PDDocument__load, file); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -499,18 +499,18 @@ jmethodID _m_PDDocument__load1 = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__load1(jobject file, jobject memUsageSetting) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method( _c_PDDocument, &_m_PDDocument__load1, "load", "(Ljava/io/File;Lorg/apache/pdfbox/io/MemoryUsageSetting;)Lorg/apache/" "pdfbox/pdmodel/PDDocument;"); if (_m_PDDocument__load1 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_PDDocument, _m_PDDocument__load1, file, memUsageSetting); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -518,17 +518,17 @@ jmethodID _m_PDDocument__load2 = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__load2(jobject file, jobject password) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method(_c_PDDocument, &_m_PDDocument__load2, "load", "(Ljava/io/File;Ljava/lang/String;)Lorg/apache/pdfbox/" "pdmodel/PDDocument;"); if (_m_PDDocument__load2 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_PDDocument, _m_PDDocument__load2, file, password); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -538,19 +538,19 @@ JniResult PDDocument__load3(jobject file, jobject password, jobject memUsageSetting) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method( _c_PDDocument, &_m_PDDocument__load3, "load", "(Ljava/io/File;Ljava/lang/String;Lorg/apache/pdfbox/io/" "MemoryUsageSetting;)Lorg/apache/pdfbox/pdmodel/PDDocument;"); if (_m_PDDocument__load3 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_PDDocument, _m_PDDocument__load3, file, password, memUsageSetting); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -561,19 +561,19 @@ JniResult PDDocument__load4(jobject file, jobject keyStore, jobject alias) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method( _c_PDDocument, &_m_PDDocument__load4, "load", "(Ljava/io/File;Ljava/lang/String;Ljava/io/InputStream;Ljava/lang/" "String;)Lorg/apache/pdfbox/pdmodel/PDDocument;"); if (_m_PDDocument__load4 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_PDDocument, _m_PDDocument__load4, file, password, keyStore, alias); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -585,20 +585,20 @@ JniResult PDDocument__load5(jobject file, jobject alias, jobject memUsageSetting) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method( _c_PDDocument, &_m_PDDocument__load5, "load", "(Ljava/io/File;Ljava/lang/String;Ljava/io/InputStream;Ljava/lang/" "String;Lorg/apache/pdfbox/io/MemoryUsageSetting;)Lorg/apache/pdfbox/" "pdmodel/PDDocument;"); if (_m_PDDocument__load5 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_PDDocument, _m_PDDocument__load5, file, password, keyStore, alias, memUsageSetting); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -606,17 +606,17 @@ jmethodID _m_PDDocument__load6 = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__load6(jobject input) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method( _c_PDDocument, &_m_PDDocument__load6, "load", "(Ljava/io/InputStream;)Lorg/apache/pdfbox/pdmodel/PDDocument;"); if (_m_PDDocument__load6 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_PDDocument, _m_PDDocument__load6, input); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -624,18 +624,18 @@ jmethodID _m_PDDocument__load7 = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__load7(jobject input, jobject memUsageSetting) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method( _c_PDDocument, &_m_PDDocument__load7, "load", "(Ljava/io/InputStream;Lorg/apache/pdfbox/io/MemoryUsageSetting;)Lorg/" "apache/pdfbox/pdmodel/PDDocument;"); if (_m_PDDocument__load7 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_PDDocument, _m_PDDocument__load7, input, memUsageSetting); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -643,17 +643,17 @@ jmethodID _m_PDDocument__load8 = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__load8(jobject input, jobject password) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method(_c_PDDocument, &_m_PDDocument__load8, "load", "(Ljava/io/InputStream;Ljava/lang/String;)Lorg/apache/" "pdfbox/pdmodel/PDDocument;"); if (_m_PDDocument__load8 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_PDDocument, _m_PDDocument__load8, input, password); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -664,19 +664,19 @@ JniResult PDDocument__load9(jobject input, jobject keyStore, jobject alias) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method( _c_PDDocument, &_m_PDDocument__load9, "load", "(Ljava/io/InputStream;Ljava/lang/String;Ljava/io/InputStream;Ljava/lang/" "String;)Lorg/apache/pdfbox/pdmodel/PDDocument;"); if (_m_PDDocument__load9 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_PDDocument, _m_PDDocument__load9, input, password, keyStore, alias); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -686,19 +686,19 @@ JniResult PDDocument__load10(jobject input, jobject password, jobject memUsageSetting) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method( _c_PDDocument, &_m_PDDocument__load10, "load", "(Ljava/io/InputStream;Ljava/lang/String;Lorg/apache/pdfbox/io/" "MemoryUsageSetting;)Lorg/apache/pdfbox/pdmodel/PDDocument;"); if (_m_PDDocument__load10 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_PDDocument, _m_PDDocument__load10, input, password, memUsageSetting); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -710,20 +710,20 @@ JniResult PDDocument__load11(jobject input, jobject alias, jobject memUsageSetting) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method( _c_PDDocument, &_m_PDDocument__load11, "load", "(Ljava/io/InputStream;Ljava/lang/String;Ljava/io/InputStream;Ljava/lang/" "String;Lorg/apache/pdfbox/io/MemoryUsageSetting;)Lorg/apache/pdfbox/" "pdmodel/PDDocument;"); if (_m_PDDocument__load11 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_PDDocument, _m_PDDocument__load11, input, password, keyStore, alias, memUsageSetting); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -731,16 +731,16 @@ jmethodID _m_PDDocument__load12 = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__load12(jobject input) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method(_c_PDDocument, &_m_PDDocument__load12, "load", "([B)Lorg/apache/pdfbox/pdmodel/PDDocument;"); if (_m_PDDocument__load12 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_PDDocument, _m_PDDocument__load12, input); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -748,17 +748,17 @@ jmethodID _m_PDDocument__load13 = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__load13(jobject input, jobject password) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method( _c_PDDocument, &_m_PDDocument__load13, "load", "([BLjava/lang/String;)Lorg/apache/pdfbox/pdmodel/PDDocument;"); if (_m_PDDocument__load13 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_PDDocument, _m_PDDocument__load13, input, password); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -769,18 +769,18 @@ JniResult PDDocument__load14(jobject input, jobject keyStore, jobject alias) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method(_c_PDDocument, &_m_PDDocument__load14, "load", "([BLjava/lang/String;Ljava/io/InputStream;Ljava/lang/" "String;)Lorg/apache/pdfbox/pdmodel/PDDocument;"); if (_m_PDDocument__load14 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_PDDocument, _m_PDDocument__load14, input, password, keyStore, alias); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -792,19 +792,19 @@ JniResult PDDocument__load15(jobject input, jobject alias, jobject memUsageSetting) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method( _c_PDDocument, &_m_PDDocument__load15, "load", "([BLjava/lang/String;Ljava/io/InputStream;Ljava/lang/String;Lorg/apache/" "pdfbox/io/MemoryUsageSetting;)Lorg/apache/pdfbox/pdmodel/PDDocument;"); if (_m_PDDocument__load15 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_PDDocument, _m_PDDocument__load15, input, password, keyStore, alias, memUsageSetting); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -812,61 +812,61 @@ jmethodID _m_PDDocument__save = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__save(jobject self_, jobject fileName) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__save, "save", "(Ljava/lang/String;)V"); if (_m_PDDocument__save == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDDocument__save, fileName); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDDocument__save1 = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__save1(jobject self_, jobject file) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__save1, "save", "(Ljava/io/File;)V"); if (_m_PDDocument__save1 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDDocument__save1, file); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDDocument__save2 = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__save2(jobject self_, jobject output) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__save2, "save", "(Ljava/io/OutputStream;)V"); if (_m_PDDocument__save2 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDDocument__save2, output); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDDocument__saveIncremental = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__saveIncremental(jobject self_, jobject output) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__saveIncremental, "saveIncremental", "(Ljava/io/OutputStream;)V"); if (_m_PDDocument__saveIncremental == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDDocument__saveIncremental, output); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDDocument__saveIncremental1 = NULL; @@ -875,16 +875,16 @@ JniResult PDDocument__saveIncremental1(jobject self_, jobject output, jobject objectsToWrite) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__saveIncremental1, "saveIncremental", "(Ljava/io/OutputStream;Ljava/util/Set;)V"); if (_m_PDDocument__saveIncremental1 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDDocument__saveIncremental1, output, objectsToWrite); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDDocument__saveIncrementalForExternalSigning = NULL; @@ -892,18 +892,18 @@ FFI_PLUGIN_EXPORT JniResult PDDocument__saveIncrementalForExternalSigning(jobject self_, jobject output) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__saveIncrementalForExternalSigning, "saveIncrementalForExternalSigning", "(Ljava/io/OutputStream;)Lorg/apache/pdfbox/pdmodel/interactive/" "digitalsignature/ExternalSigningSupport;"); if (_m_PDDocument__saveIncrementalForExternalSigning == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocument__saveIncrementalForExternalSigning, output); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -911,16 +911,16 @@ jmethodID _m_PDDocument__getPage = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__getPage(jobject self_, int32_t pageIndex) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__getPage, "getPage", "(I)Lorg/apache/pdfbox/pdmodel/PDPage;"); if (_m_PDDocument__getPage == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocument__getPage, pageIndex); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -928,16 +928,16 @@ jmethodID _m_PDDocument__getPages = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__getPages(jobject self_) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__getPages, "getPages", "()Lorg/apache/pdfbox/pdmodel/PDPageTree;"); if (_m_PDDocument__getPages == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_PDDocument__getPages); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -945,62 +945,62 @@ jmethodID _m_PDDocument__getNumberOfPages = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__getNumberOfPages(jobject self_) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__getNumberOfPages, "getNumberOfPages", "()I"); if (_m_PDDocument__getNumberOfPages == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_PDDocument__getNumberOfPages); - return (JniResult){.result = {.i = _result}, .exception = check_exception()}; + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; } jmethodID _m_PDDocument__close = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__close(jobject self_) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__close, "close", "()V"); if (_m_PDDocument__close == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDDocument__close); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDDocument__protect = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__protect(jobject self_, jobject policy) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__protect, "protect", "(Lorg/apache/pdfbox/pdmodel/encryption/ProtectionPolicy;)V"); if (_m_PDDocument__protect == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDDocument__protect, policy); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDDocument__getCurrentAccessPermission = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__getCurrentAccessPermission(jobject self_) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__getCurrentAccessPermission, "getCurrentAccessPermission", "()Lorg/apache/pdfbox/pdmodel/encryption/AccessPermission;"); if (_m_PDDocument__getCurrentAccessPermission == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocument__getCurrentAccessPermission); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1008,16 +1008,16 @@ jmethodID _m_PDDocument__isAllSecurityToBeRemoved = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__isAllSecurityToBeRemoved(jobject self_) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__isAllSecurityToBeRemoved, "isAllSecurityToBeRemoved", "()Z"); if (_m_PDDocument__isAllSecurityToBeRemoved == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; uint8_t _result = (*jniEnv)->CallBooleanMethod( jniEnv, self_, _m_PDDocument__isAllSecurityToBeRemoved); - return (JniResult){.result = {.z = _result}, .exception = check_exception()}; + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; } jmethodID _m_PDDocument__setAllSecurityToBeRemoved = NULL; @@ -1025,33 +1025,33 @@ FFI_PLUGIN_EXPORT JniResult PDDocument__setAllSecurityToBeRemoved(jobject self_, uint8_t removeAllSecurity) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__setAllSecurityToBeRemoved, "setAllSecurityToBeRemoved", "(Z)V"); if (_m_PDDocument__setAllSecurityToBeRemoved == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDDocument__setAllSecurityToBeRemoved, removeAllSecurity); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDDocument__getDocumentId = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__getDocumentId(jobject self_) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__getDocumentId, "getDocumentId", "()Ljava/lang/Long;"); if (_m_PDDocument__getDocumentId == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_PDDocument__getDocumentId); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1059,62 +1059,62 @@ jmethodID _m_PDDocument__setDocumentId = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__setDocumentId(jobject self_, jobject docId) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__setDocumentId, "setDocumentId", "(Ljava/lang/Long;)V"); if (_m_PDDocument__setDocumentId == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDDocument__setDocumentId, docId); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDDocument__getVersion = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__getVersion(jobject self_) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__getVersion, "getVersion", "()F"); if (_m_PDDocument__getVersion == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; float _result = (*jniEnv)->CallFloatMethod(jniEnv, self_, _m_PDDocument__getVersion); - return (JniResult){.result = {.f = _result}, .exception = check_exception()}; + return (JniResult){.value = {.f = _result}, .exception = check_exception()}; } jmethodID _m_PDDocument__setVersion = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__setVersion(jobject self_, float newVersion) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__setVersion, "setVersion", "(F)V"); if (_m_PDDocument__setVersion == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDDocument__setVersion, newVersion); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDDocument__getResourceCache = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__getResourceCache(jobject self_) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__getResourceCache, "getResourceCache", "()Lorg/apache/pdfbox/pdmodel/ResourceCache;"); if (_m_PDDocument__getResourceCache == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocument__getResourceCache); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1122,17 +1122,17 @@ jmethodID _m_PDDocument__setResourceCache = NULL; FFI_PLUGIN_EXPORT JniResult PDDocument__setResourceCache(jobject self_, jobject resourceCache) { load_env(); - load_class_gr(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); + load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocument, &_m_PDDocument__setResourceCache, "setResourceCache", "(Lorg/apache/pdfbox/pdmodel/ResourceCache;)V"); if (_m_PDDocument__setResourceCache == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDDocument__setResourceCache, resourceCache); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } // org.apache.pdfbox.pdmodel.PDDocumentInformation @@ -1142,17 +1142,17 @@ jmethodID _m_PDDocumentInformation__ctor = NULL; FFI_PLUGIN_EXPORT JniResult PDDocumentInformation__ctor() { load_env(); - load_class_gr(&_c_PDDocumentInformation, - "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_class_global_ref(&_c_PDDocumentInformation, + "org/apache/pdfbox/pdmodel/PDDocumentInformation"); if (_c_PDDocumentInformation == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocumentInformation, &_m_PDDocumentInformation__ctor, "", "()V"); if (_m_PDDocumentInformation__ctor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_PDDocumentInformation, _m_PDDocumentInformation__ctor); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1160,17 +1160,17 @@ jmethodID _m_PDDocumentInformation__ctor1 = NULL; FFI_PLUGIN_EXPORT JniResult PDDocumentInformation__ctor1(jobject dic) { load_env(); - load_class_gr(&_c_PDDocumentInformation, - "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_class_global_ref(&_c_PDDocumentInformation, + "org/apache/pdfbox/pdmodel/PDDocumentInformation"); if (_c_PDDocumentInformation == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocumentInformation, &_m_PDDocumentInformation__ctor1, "", "(Lorg/apache/pdfbox/cos/COSDictionary;)V"); if (_m_PDDocumentInformation__ctor1 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_PDDocumentInformation, _m_PDDocumentInformation__ctor1, dic); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1178,17 +1178,17 @@ jmethodID _m_PDDocumentInformation__getCOSObject = NULL; FFI_PLUGIN_EXPORT JniResult PDDocumentInformation__getCOSObject(jobject self_) { load_env(); - load_class_gr(&_c_PDDocumentInformation, - "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_class_global_ref(&_c_PDDocumentInformation, + "org/apache/pdfbox/pdmodel/PDDocumentInformation"); if (_c_PDDocumentInformation == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocumentInformation, &_m_PDDocumentInformation__getCOSObject, "getCOSObject", "()Lorg/apache/pdfbox/cos/COSDictionary;"); if (_m_PDDocumentInformation__getCOSObject == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocumentInformation__getCOSObject); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1197,20 +1197,20 @@ FFI_PLUGIN_EXPORT JniResult PDDocumentInformation__getPropertyStringValue(jobject self_, jobject propertyKey) { load_env(); - load_class_gr(&_c_PDDocumentInformation, - "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_class_global_ref(&_c_PDDocumentInformation, + "org/apache/pdfbox/pdmodel/PDDocumentInformation"); if (_c_PDDocumentInformation == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocumentInformation, &_m_PDDocumentInformation__getPropertyStringValue, "getPropertyStringValue", "(Ljava/lang/String;)Ljava/lang/Object;"); if (_m_PDDocumentInformation__getPropertyStringValue == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocumentInformation__getPropertyStringValue, propertyKey); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1218,17 +1218,17 @@ jmethodID _m_PDDocumentInformation__getTitle = NULL; FFI_PLUGIN_EXPORT JniResult PDDocumentInformation__getTitle(jobject self_) { load_env(); - load_class_gr(&_c_PDDocumentInformation, - "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_class_global_ref(&_c_PDDocumentInformation, + "org/apache/pdfbox/pdmodel/PDDocumentInformation"); if (_c_PDDocumentInformation == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocumentInformation, &_m_PDDocumentInformation__getTitle, "getTitle", "()Ljava/lang/String;"); if (_m_PDDocumentInformation__getTitle == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocumentInformation__getTitle); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1236,34 +1236,34 @@ jmethodID _m_PDDocumentInformation__setTitle = NULL; FFI_PLUGIN_EXPORT JniResult PDDocumentInformation__setTitle(jobject self_, jobject title) { load_env(); - load_class_gr(&_c_PDDocumentInformation, - "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_class_global_ref(&_c_PDDocumentInformation, + "org/apache/pdfbox/pdmodel/PDDocumentInformation"); if (_c_PDDocumentInformation == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocumentInformation, &_m_PDDocumentInformation__setTitle, "setTitle", "(Ljava/lang/String;)V"); if (_m_PDDocumentInformation__setTitle == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDDocumentInformation__setTitle, title); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDDocumentInformation__getAuthor = NULL; FFI_PLUGIN_EXPORT JniResult PDDocumentInformation__getAuthor(jobject self_) { load_env(); - load_class_gr(&_c_PDDocumentInformation, - "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_class_global_ref(&_c_PDDocumentInformation, + "org/apache/pdfbox/pdmodel/PDDocumentInformation"); if (_c_PDDocumentInformation == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocumentInformation, &_m_PDDocumentInformation__getAuthor, "getAuthor", "()Ljava/lang/String;"); if (_m_PDDocumentInformation__getAuthor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocumentInformation__getAuthor); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1271,34 +1271,34 @@ jmethodID _m_PDDocumentInformation__setAuthor = NULL; FFI_PLUGIN_EXPORT JniResult PDDocumentInformation__setAuthor(jobject self_, jobject author) { load_env(); - load_class_gr(&_c_PDDocumentInformation, - "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_class_global_ref(&_c_PDDocumentInformation, + "org/apache/pdfbox/pdmodel/PDDocumentInformation"); if (_c_PDDocumentInformation == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocumentInformation, &_m_PDDocumentInformation__setAuthor, "setAuthor", "(Ljava/lang/String;)V"); if (_m_PDDocumentInformation__setAuthor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDDocumentInformation__setAuthor, author); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDDocumentInformation__getSubject = NULL; FFI_PLUGIN_EXPORT JniResult PDDocumentInformation__getSubject(jobject self_) { load_env(); - load_class_gr(&_c_PDDocumentInformation, - "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_class_global_ref(&_c_PDDocumentInformation, + "org/apache/pdfbox/pdmodel/PDDocumentInformation"); if (_c_PDDocumentInformation == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocumentInformation, &_m_PDDocumentInformation__getSubject, "getSubject", "()Ljava/lang/String;"); if (_m_PDDocumentInformation__getSubject == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocumentInformation__getSubject); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1306,34 +1306,34 @@ jmethodID _m_PDDocumentInformation__setSubject = NULL; FFI_PLUGIN_EXPORT JniResult PDDocumentInformation__setSubject(jobject self_, jobject subject) { load_env(); - load_class_gr(&_c_PDDocumentInformation, - "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_class_global_ref(&_c_PDDocumentInformation, + "org/apache/pdfbox/pdmodel/PDDocumentInformation"); if (_c_PDDocumentInformation == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocumentInformation, &_m_PDDocumentInformation__setSubject, "setSubject", "(Ljava/lang/String;)V"); if (_m_PDDocumentInformation__setSubject == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDDocumentInformation__setSubject, subject); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDDocumentInformation__getKeywords = NULL; FFI_PLUGIN_EXPORT JniResult PDDocumentInformation__getKeywords(jobject self_) { load_env(); - load_class_gr(&_c_PDDocumentInformation, - "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_class_global_ref(&_c_PDDocumentInformation, + "org/apache/pdfbox/pdmodel/PDDocumentInformation"); if (_c_PDDocumentInformation == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocumentInformation, &_m_PDDocumentInformation__getKeywords, "getKeywords", "()Ljava/lang/String;"); if (_m_PDDocumentInformation__getKeywords == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocumentInformation__getKeywords); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1341,34 +1341,34 @@ jmethodID _m_PDDocumentInformation__setKeywords = NULL; FFI_PLUGIN_EXPORT JniResult PDDocumentInformation__setKeywords(jobject self_, jobject keywords) { load_env(); - load_class_gr(&_c_PDDocumentInformation, - "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_class_global_ref(&_c_PDDocumentInformation, + "org/apache/pdfbox/pdmodel/PDDocumentInformation"); if (_c_PDDocumentInformation == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocumentInformation, &_m_PDDocumentInformation__setKeywords, "setKeywords", "(Ljava/lang/String;)V"); if (_m_PDDocumentInformation__setKeywords == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDDocumentInformation__setKeywords, keywords); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDDocumentInformation__getCreator = NULL; FFI_PLUGIN_EXPORT JniResult PDDocumentInformation__getCreator(jobject self_) { load_env(); - load_class_gr(&_c_PDDocumentInformation, - "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_class_global_ref(&_c_PDDocumentInformation, + "org/apache/pdfbox/pdmodel/PDDocumentInformation"); if (_c_PDDocumentInformation == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocumentInformation, &_m_PDDocumentInformation__getCreator, "getCreator", "()Ljava/lang/String;"); if (_m_PDDocumentInformation__getCreator == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocumentInformation__getCreator); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1376,34 +1376,34 @@ jmethodID _m_PDDocumentInformation__setCreator = NULL; FFI_PLUGIN_EXPORT JniResult PDDocumentInformation__setCreator(jobject self_, jobject creator) { load_env(); - load_class_gr(&_c_PDDocumentInformation, - "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_class_global_ref(&_c_PDDocumentInformation, + "org/apache/pdfbox/pdmodel/PDDocumentInformation"); if (_c_PDDocumentInformation == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocumentInformation, &_m_PDDocumentInformation__setCreator, "setCreator", "(Ljava/lang/String;)V"); if (_m_PDDocumentInformation__setCreator == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDDocumentInformation__setCreator, creator); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDDocumentInformation__getProducer = NULL; FFI_PLUGIN_EXPORT JniResult PDDocumentInformation__getProducer(jobject self_) { load_env(); - load_class_gr(&_c_PDDocumentInformation, - "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_class_global_ref(&_c_PDDocumentInformation, + "org/apache/pdfbox/pdmodel/PDDocumentInformation"); if (_c_PDDocumentInformation == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocumentInformation, &_m_PDDocumentInformation__getProducer, "getProducer", "()Ljava/lang/String;"); if (_m_PDDocumentInformation__getProducer == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocumentInformation__getProducer); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1411,35 +1411,35 @@ jmethodID _m_PDDocumentInformation__setProducer = NULL; FFI_PLUGIN_EXPORT JniResult PDDocumentInformation__setProducer(jobject self_, jobject producer) { load_env(); - load_class_gr(&_c_PDDocumentInformation, - "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_class_global_ref(&_c_PDDocumentInformation, + "org/apache/pdfbox/pdmodel/PDDocumentInformation"); if (_c_PDDocumentInformation == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocumentInformation, &_m_PDDocumentInformation__setProducer, "setProducer", "(Ljava/lang/String;)V"); if (_m_PDDocumentInformation__setProducer == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDDocumentInformation__setProducer, producer); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDDocumentInformation__getCreationDate = NULL; FFI_PLUGIN_EXPORT JniResult PDDocumentInformation__getCreationDate(jobject self_) { load_env(); - load_class_gr(&_c_PDDocumentInformation, - "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_class_global_ref(&_c_PDDocumentInformation, + "org/apache/pdfbox/pdmodel/PDDocumentInformation"); if (_c_PDDocumentInformation == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocumentInformation, &_m_PDDocumentInformation__getCreationDate, "getCreationDate", "()Ljava/util/Calendar;"); if (_m_PDDocumentInformation__getCreationDate == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocumentInformation__getCreationDate); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1447,36 +1447,36 @@ jmethodID _m_PDDocumentInformation__setCreationDate = NULL; FFI_PLUGIN_EXPORT JniResult PDDocumentInformation__setCreationDate(jobject self_, jobject date) { load_env(); - load_class_gr(&_c_PDDocumentInformation, - "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_class_global_ref(&_c_PDDocumentInformation, + "org/apache/pdfbox/pdmodel/PDDocumentInformation"); if (_c_PDDocumentInformation == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocumentInformation, &_m_PDDocumentInformation__setCreationDate, "setCreationDate", "(Ljava/util/Calendar;)V"); if (_m_PDDocumentInformation__setCreationDate == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDDocumentInformation__setCreationDate, date); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDDocumentInformation__getModificationDate = NULL; FFI_PLUGIN_EXPORT JniResult PDDocumentInformation__getModificationDate(jobject self_) { load_env(); - load_class_gr(&_c_PDDocumentInformation, - "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_class_global_ref(&_c_PDDocumentInformation, + "org/apache/pdfbox/pdmodel/PDDocumentInformation"); if (_c_PDDocumentInformation == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocumentInformation, &_m_PDDocumentInformation__getModificationDate, "getModificationDate", "()Ljava/util/Calendar;"); if (_m_PDDocumentInformation__getModificationDate == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocumentInformation__getModificationDate); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1485,35 +1485,35 @@ FFI_PLUGIN_EXPORT JniResult PDDocumentInformation__setModificationDate(jobject self_, jobject date) { load_env(); - load_class_gr(&_c_PDDocumentInformation, - "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_class_global_ref(&_c_PDDocumentInformation, + "org/apache/pdfbox/pdmodel/PDDocumentInformation"); if (_c_PDDocumentInformation == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocumentInformation, &_m_PDDocumentInformation__setModificationDate, "setModificationDate", "(Ljava/util/Calendar;)V"); if (_m_PDDocumentInformation__setModificationDate == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod( jniEnv, self_, _m_PDDocumentInformation__setModificationDate, date); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDDocumentInformation__getTrapped = NULL; FFI_PLUGIN_EXPORT JniResult PDDocumentInformation__getTrapped(jobject self_) { load_env(); - load_class_gr(&_c_PDDocumentInformation, - "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_class_global_ref(&_c_PDDocumentInformation, + "org/apache/pdfbox/pdmodel/PDDocumentInformation"); if (_c_PDDocumentInformation == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocumentInformation, &_m_PDDocumentInformation__getTrapped, "getTrapped", "()Ljava/lang/String;"); if (_m_PDDocumentInformation__getTrapped == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocumentInformation__getTrapped); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1521,18 +1521,18 @@ jmethodID _m_PDDocumentInformation__getMetadataKeys = NULL; FFI_PLUGIN_EXPORT JniResult PDDocumentInformation__getMetadataKeys(jobject self_) { load_env(); - load_class_gr(&_c_PDDocumentInformation, - "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_class_global_ref(&_c_PDDocumentInformation, + "org/apache/pdfbox/pdmodel/PDDocumentInformation"); if (_c_PDDocumentInformation == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocumentInformation, &_m_PDDocumentInformation__getMetadataKeys, "getMetadataKeys", "()Ljava/util/Set;"); if (_m_PDDocumentInformation__getMetadataKeys == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocumentInformation__getMetadataKeys); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1541,20 +1541,20 @@ FFI_PLUGIN_EXPORT JniResult PDDocumentInformation__getCustomMetadataValue(jobject self_, jobject fieldName) { load_env(); - load_class_gr(&_c_PDDocumentInformation, - "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_class_global_ref(&_c_PDDocumentInformation, + "org/apache/pdfbox/pdmodel/PDDocumentInformation"); if (_c_PDDocumentInformation == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocumentInformation, &_m_PDDocumentInformation__getCustomMetadataValue, "getCustomMetadataValue", "(Ljava/lang/String;)Ljava/lang/String;"); if (_m_PDDocumentInformation__getCustomMetadataValue == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocumentInformation__getCustomMetadataValue, fieldName); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1564,37 +1564,37 @@ JniResult PDDocumentInformation__setCustomMetadataValue(jobject self_, jobject fieldName, jobject fieldValue) { load_env(); - load_class_gr(&_c_PDDocumentInformation, - "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_class_global_ref(&_c_PDDocumentInformation, + "org/apache/pdfbox/pdmodel/PDDocumentInformation"); if (_c_PDDocumentInformation == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocumentInformation, &_m_PDDocumentInformation__setCustomMetadataValue, "setCustomMetadataValue", "(Ljava/lang/String;Ljava/lang/String;)V"); if (_m_PDDocumentInformation__setCustomMetadataValue == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDDocumentInformation__setCustomMetadataValue, fieldName, fieldValue); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDDocumentInformation__setTrapped = NULL; FFI_PLUGIN_EXPORT JniResult PDDocumentInformation__setTrapped(jobject self_, jobject value) { load_env(); - load_class_gr(&_c_PDDocumentInformation, - "org/apache/pdfbox/pdmodel/PDDocumentInformation"); + load_class_global_ref(&_c_PDDocumentInformation, + "org/apache/pdfbox/pdmodel/PDDocumentInformation"); if (_c_PDDocumentInformation == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDDocumentInformation, &_m_PDDocumentInformation__setTrapped, "setTrapped", "(Ljava/lang/String;)V"); if (_m_PDDocumentInformation__setTrapped == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDDocumentInformation__setTrapped, value); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } // org.apache.pdfbox.text.PDFTextStripper @@ -1604,15 +1604,16 @@ jmethodID _m_PDFTextStripper__ctor = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__ctor() { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__ctor, "", "()V"); if (_m_PDFTextStripper__ctor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_PDFTextStripper, _m_PDFTextStripper__ctor); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1620,16 +1621,17 @@ jmethodID _m_PDFTextStripper__getText = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__getText(jobject self_, jobject doc) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__getText, "getText", "(Lorg/apache/pdfbox/pdmodel/PDDocument;)Ljava/lang/String;"); if (_m_PDFTextStripper__getText == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDFTextStripper__getText, doc); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1639,219 +1641,233 @@ JniResult PDFTextStripper__writeText(jobject self_, jobject doc, jobject outputStream) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__writeText, "writeText", "(Lorg/apache/pdfbox/pdmodel/PDDocument;Ljava/io/Writer;)V"); if (_m_PDFTextStripper__writeText == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__writeText, doc, outputStream); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__processPages = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__processPages(jobject self_, jobject pages) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__processPages, "processPages", "(Lorg/apache/pdfbox/pdmodel/PDPageTree;)V"); if (_m_PDFTextStripper__processPages == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__processPages, pages); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__startDocument = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__startDocument(jobject self_, jobject document) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__startDocument, "startDocument", "(Lorg/apache/pdfbox/pdmodel/PDDocument;)V"); if (_m_PDFTextStripper__startDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__startDocument, document); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__endDocument = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__endDocument(jobject self_, jobject document) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__endDocument, "endDocument", "(Lorg/apache/pdfbox/pdmodel/PDDocument;)V"); if (_m_PDFTextStripper__endDocument == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__endDocument, document); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__processPage = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__processPage(jobject self_, jobject page) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__processPage, "processPage", "(Lorg/apache/pdfbox/pdmodel/PDPage;)V"); if (_m_PDFTextStripper__processPage == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__processPage, page); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__startArticle = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__startArticle(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__startArticle, "startArticle", "()V"); if (_m_PDFTextStripper__startArticle == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__startArticle); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__startArticle1 = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__startArticle1(jobject self_, uint8_t isLTR) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__startArticle1, "startArticle", "(Z)V"); if (_m_PDFTextStripper__startArticle1 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__startArticle1, isLTR); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__endArticle = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__endArticle(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__endArticle, "endArticle", "()V"); if (_m_PDFTextStripper__endArticle == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__endArticle); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__startPage = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__startPage(jobject self_, jobject page) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__startPage, "startPage", "(Lorg/apache/pdfbox/pdmodel/PDPage;)V"); if (_m_PDFTextStripper__startPage == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__startPage, page); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__endPage = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__endPage(jobject self_, jobject page) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__endPage, "endPage", "(Lorg/apache/pdfbox/pdmodel/PDPage;)V"); if (_m_PDFTextStripper__endPage == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__endPage, page); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__writePage = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__writePage(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__writePage, "writePage", "()V"); if (_m_PDFTextStripper__writePage == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__writePage); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__writeLineSeparator = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__writeLineSeparator(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__writeLineSeparator, "writeLineSeparator", "()V"); if (_m_PDFTextStripper__writeLineSeparator == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__writeLineSeparator); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__writeWordSeparator = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__writeWordSeparator(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__writeWordSeparator, "writeWordSeparator", "()V"); if (_m_PDFTextStripper__writeWordSeparator == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__writeWordSeparator); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__writeCharacters = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__writeCharacters(jobject self_, jobject text) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__writeCharacters, "writeCharacters", "(Lorg/apache/pdfbox/text/TextPosition;)V"); if (_m_PDFTextStripper__writeCharacters == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__writeCharacters, text); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__writeString = NULL; @@ -1860,145 +1876,154 @@ JniResult PDFTextStripper__writeString(jobject self_, jobject text, jobject textPositions) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__writeString, "writeString", "(Ljava/lang/String;Ljava/util/List;)V"); if (_m_PDFTextStripper__writeString == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__writeString, text, textPositions); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__writeString1 = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__writeString1(jobject self_, jobject text) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__writeString1, "writeString", "(Ljava/lang/String;)V"); if (_m_PDFTextStripper__writeString1 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__writeString1, text); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__processTextPosition = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__processTextPosition(jobject self_, jobject text) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__processTextPosition, "processTextPosition", "(Lorg/apache/pdfbox/text/TextPosition;)V"); if (_m_PDFTextStripper__processTextPosition == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__processTextPosition, text); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__getStartPage = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__getStartPage(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__getStartPage, "getStartPage", "()I"); if (_m_PDFTextStripper__getStartPage == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_PDFTextStripper__getStartPage); - return (JniResult){.result = {.i = _result}, .exception = check_exception()}; + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__setStartPage = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__setStartPage(jobject self_, int32_t startPageValue) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__setStartPage, "setStartPage", "(I)V"); if (_m_PDFTextStripper__setStartPage == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__setStartPage, startPageValue); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__getEndPage = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__getEndPage(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__getEndPage, "getEndPage", "()I"); if (_m_PDFTextStripper__getEndPage == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_PDFTextStripper__getEndPage); - return (JniResult){.result = {.i = _result}, .exception = check_exception()}; + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__setEndPage = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__setEndPage(jobject self_, int32_t endPageValue) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__setEndPage, "setEndPage", "(I)V"); if (_m_PDFTextStripper__setEndPage == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__setEndPage, endPageValue); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__setLineSeparator = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__setLineSeparator(jobject self_, jobject separator) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__setLineSeparator, "setLineSeparator", "(Ljava/lang/String;)V"); if (_m_PDFTextStripper__setLineSeparator == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__setLineSeparator, separator); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__getLineSeparator = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__getLineSeparator(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__getLineSeparator, "getLineSeparator", "()Ljava/lang/String;"); if (_m_PDFTextStripper__getLineSeparator == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDFTextStripper__getLineSeparator); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -2006,16 +2031,17 @@ jmethodID _m_PDFTextStripper__getWordSeparator = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__getWordSeparator(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__getWordSeparator, "getWordSeparator", "()Ljava/lang/String;"); if (_m_PDFTextStripper__getWordSeparator == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDFTextStripper__getWordSeparator); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -2023,65 +2049,69 @@ jmethodID _m_PDFTextStripper__setWordSeparator = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__setWordSeparator(jobject self_, jobject separator) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__setWordSeparator, "setWordSeparator", "(Ljava/lang/String;)V"); if (_m_PDFTextStripper__setWordSeparator == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__setWordSeparator, separator); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__getSuppressDuplicateOverlappingText = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__getSuppressDuplicateOverlappingText(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__getSuppressDuplicateOverlappingText, "getSuppressDuplicateOverlappingText", "()Z"); if (_m_PDFTextStripper__getSuppressDuplicateOverlappingText == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; uint8_t _result = (*jniEnv)->CallBooleanMethod( jniEnv, self_, _m_PDFTextStripper__getSuppressDuplicateOverlappingText); - return (JniResult){.result = {.z = _result}, .exception = check_exception()}; + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__getCurrentPageNo = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__getCurrentPageNo(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__getCurrentPageNo, "getCurrentPageNo", "()I"); if (_m_PDFTextStripper__getCurrentPageNo == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; int32_t _result = (*jniEnv)->CallIntMethod( jniEnv, self_, _m_PDFTextStripper__getCurrentPageNo); - return (JniResult){.result = {.i = _result}, .exception = check_exception()}; + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__getOutput = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__getOutput(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__getOutput, "getOutput", "()Ljava/io/Writer;"); if (_m_PDFTextStripper__getOutput == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_PDFTextStripper__getOutput); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -2089,16 +2119,17 @@ jmethodID _m_PDFTextStripper__getCharactersByArticle = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__getCharactersByArticle(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__getCharactersByArticle, "getCharactersByArticle", "()Ljava/util/List;"); if (_m_PDFTextStripper__getCharactersByArticle == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDFTextStripper__getCharactersByArticle); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -2108,34 +2139,36 @@ JniResult PDFTextStripper__setSuppressDuplicateOverlappingText( jobject self_, uint8_t suppressDuplicateOverlappingTextValue) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__setSuppressDuplicateOverlappingText, "setSuppressDuplicateOverlappingText", "(Z)V"); if (_m_PDFTextStripper__setSuppressDuplicateOverlappingText == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod( jniEnv, self_, _m_PDFTextStripper__setSuppressDuplicateOverlappingText, suppressDuplicateOverlappingTextValue); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__getSeparateByBeads = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__getSeparateByBeads(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__getSeparateByBeads, "getSeparateByBeads", "()Z"); if (_m_PDFTextStripper__getSeparateByBeads == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; uint8_t _result = (*jniEnv)->CallBooleanMethod( jniEnv, self_, _m_PDFTextStripper__getSeparateByBeads); - return (JniResult){.result = {.z = _result}, .exception = check_exception()}; + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__setShouldSeparateByBeads = NULL; @@ -2144,35 +2177,37 @@ JniResult PDFTextStripper__setShouldSeparateByBeads( jobject self_, uint8_t aShouldSeparateByBeads) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__setShouldSeparateByBeads, "setShouldSeparateByBeads", "(Z)V"); if (_m_PDFTextStripper__setShouldSeparateByBeads == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__setShouldSeparateByBeads, aShouldSeparateByBeads); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__getEndBookmark = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__getEndBookmark(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__getEndBookmark, "getEndBookmark", "()Lorg/apache/pdfbox/pdmodel/interactive/documentnavigation/" "outline/PDOutlineItem;"); if (_m_PDFTextStripper__getEndBookmark == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDFTextStripper__getEndBookmark); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -2180,36 +2215,38 @@ jmethodID _m_PDFTextStripper__setEndBookmark = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__setEndBookmark(jobject self_, jobject aEndBookmark) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__setEndBookmark, "setEndBookmark", "(Lorg/apache/pdfbox/pdmodel/interactive/documentnavigation/" "outline/PDOutlineItem;)V"); if (_m_PDFTextStripper__setEndBookmark == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__setEndBookmark, aEndBookmark); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__getStartBookmark = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__getStartBookmark(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__getStartBookmark, "getStartBookmark", "()Lorg/apache/pdfbox/pdmodel/interactive/documentnavigation/" "outline/PDOutlineItem;"); if (_m_PDFTextStripper__getStartBookmark == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDFTextStripper__getStartBookmark); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -2218,34 +2255,36 @@ FFI_PLUGIN_EXPORT JniResult PDFTextStripper__setStartBookmark(jobject self_, jobject aStartBookmark) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__setStartBookmark, "setStartBookmark", "(Lorg/apache/pdfbox/pdmodel/interactive/documentnavigation/" "outline/PDOutlineItem;)V"); if (_m_PDFTextStripper__setStartBookmark == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__setStartBookmark, aStartBookmark); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__getAddMoreFormatting = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__getAddMoreFormatting(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__getAddMoreFormatting, "getAddMoreFormatting", "()Z"); if (_m_PDFTextStripper__getAddMoreFormatting == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; uint8_t _result = (*jniEnv)->CallBooleanMethod( jniEnv, self_, _m_PDFTextStripper__getAddMoreFormatting); - return (JniResult){.result = {.z = _result}, .exception = check_exception()}; + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__setAddMoreFormatting = NULL; @@ -2253,33 +2292,35 @@ FFI_PLUGIN_EXPORT JniResult PDFTextStripper__setAddMoreFormatting(jobject self_, uint8_t newAddMoreFormatting) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__setAddMoreFormatting, "setAddMoreFormatting", "(Z)V"); if (_m_PDFTextStripper__setAddMoreFormatting == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__setAddMoreFormatting, newAddMoreFormatting); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__getSortByPosition = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__getSortByPosition(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__getSortByPosition, "getSortByPosition", "()Z"); if (_m_PDFTextStripper__getSortByPosition == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; uint8_t _result = (*jniEnv)->CallBooleanMethod( jniEnv, self_, _m_PDFTextStripper__getSortByPosition); - return (JniResult){.result = {.z = _result}, .exception = check_exception()}; + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__setSortByPosition = NULL; @@ -2287,32 +2328,34 @@ FFI_PLUGIN_EXPORT JniResult PDFTextStripper__setSortByPosition(jobject self_, uint8_t newSortByPosition) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__setSortByPosition, "setSortByPosition", "(Z)V"); if (_m_PDFTextStripper__setSortByPosition == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod( jniEnv, self_, _m_PDFTextStripper__setSortByPosition, newSortByPosition); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__getSpacingTolerance = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__getSpacingTolerance(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__getSpacingTolerance, "getSpacingTolerance", "()F"); if (_m_PDFTextStripper__getSpacingTolerance == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; float _result = (*jniEnv)->CallFloatMethod( jniEnv, self_, _m_PDFTextStripper__getSpacingTolerance); - return (JniResult){.result = {.f = _result}, .exception = check_exception()}; + return (JniResult){.value = {.f = _result}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__setSpacingTolerance = NULL; @@ -2320,33 +2363,35 @@ FFI_PLUGIN_EXPORT JniResult PDFTextStripper__setSpacingTolerance(jobject self_, float spacingToleranceValue) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__setSpacingTolerance, "setSpacingTolerance", "(F)V"); if (_m_PDFTextStripper__setSpacingTolerance == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__setSpacingTolerance, spacingToleranceValue); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__getAverageCharTolerance = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__getAverageCharTolerance(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__getAverageCharTolerance, "getAverageCharTolerance", "()F"); if (_m_PDFTextStripper__getAverageCharTolerance == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; float _result = (*jniEnv)->CallFloatMethod( jniEnv, self_, _m_PDFTextStripper__getAverageCharTolerance); - return (JniResult){.result = {.f = _result}, .exception = check_exception()}; + return (JniResult){.value = {.f = _result}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__setAverageCharTolerance = NULL; @@ -2355,33 +2400,35 @@ JniResult PDFTextStripper__setAverageCharTolerance( jobject self_, float averageCharToleranceValue) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__setAverageCharTolerance, "setAverageCharTolerance", "(F)V"); if (_m_PDFTextStripper__setAverageCharTolerance == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__setAverageCharTolerance, averageCharToleranceValue); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__getIndentThreshold = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__getIndentThreshold(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__getIndentThreshold, "getIndentThreshold", "()F"); if (_m_PDFTextStripper__getIndentThreshold == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; float _result = (*jniEnv)->CallFloatMethod( jniEnv, self_, _m_PDFTextStripper__getIndentThreshold); - return (JniResult){.result = {.f = _result}, .exception = check_exception()}; + return (JniResult){.value = {.f = _result}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__setIndentThreshold = NULL; @@ -2389,33 +2436,35 @@ FFI_PLUGIN_EXPORT JniResult PDFTextStripper__setIndentThreshold(jobject self_, float indentThresholdValue) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__setIndentThreshold, "setIndentThreshold", "(F)V"); if (_m_PDFTextStripper__setIndentThreshold == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__setIndentThreshold, indentThresholdValue); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__getDropThreshold = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__getDropThreshold(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__getDropThreshold, "getDropThreshold", "()F"); if (_m_PDFTextStripper__getDropThreshold == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; float _result = (*jniEnv)->CallFloatMethod( jniEnv, self_, _m_PDFTextStripper__getDropThreshold); - return (JniResult){.result = {.f = _result}, .exception = check_exception()}; + return (JniResult){.value = {.f = _result}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__setDropThreshold = NULL; @@ -2423,32 +2472,34 @@ FFI_PLUGIN_EXPORT JniResult PDFTextStripper__setDropThreshold(jobject self_, float dropThresholdValue) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__setDropThreshold, "setDropThreshold", "(F)V"); if (_m_PDFTextStripper__setDropThreshold == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__setDropThreshold, dropThresholdValue); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__getParagraphStart = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__getParagraphStart(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__getParagraphStart, "getParagraphStart", "()Ljava/lang/String;"); if (_m_PDFTextStripper__getParagraphStart == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDFTextStripper__getParagraphStart); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -2456,32 +2507,34 @@ jmethodID _m_PDFTextStripper__setParagraphStart = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__setParagraphStart(jobject self_, jobject s) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__setParagraphStart, "setParagraphStart", "(Ljava/lang/String;)V"); if (_m_PDFTextStripper__setParagraphStart == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__setParagraphStart, s); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__getParagraphEnd = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__getParagraphEnd(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__getParagraphEnd, "getParagraphEnd", "()Ljava/lang/String;"); if (_m_PDFTextStripper__getParagraphEnd == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDFTextStripper__getParagraphEnd); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -2489,32 +2542,34 @@ jmethodID _m_PDFTextStripper__setParagraphEnd = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__setParagraphEnd(jobject self_, jobject s) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__setParagraphEnd, "setParagraphEnd", "(Ljava/lang/String;)V"); if (_m_PDFTextStripper__setParagraphEnd == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__setParagraphEnd, s); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__getPageStart = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__getPageStart(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__getPageStart, "getPageStart", "()Ljava/lang/String;"); if (_m_PDFTextStripper__getPageStart == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDFTextStripper__getPageStart); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -2522,32 +2577,34 @@ jmethodID _m_PDFTextStripper__setPageStart = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__setPageStart(jobject self_, jobject pageStartValue) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__setPageStart, "setPageStart", "(Ljava/lang/String;)V"); if (_m_PDFTextStripper__setPageStart == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__setPageStart, pageStartValue); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__getPageEnd = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__getPageEnd(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__getPageEnd, "getPageEnd", "()Ljava/lang/String;"); if (_m_PDFTextStripper__getPageEnd == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_PDFTextStripper__getPageEnd); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -2555,32 +2612,34 @@ jmethodID _m_PDFTextStripper__setPageEnd = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__setPageEnd(jobject self_, jobject pageEndValue) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__setPageEnd, "setPageEnd", "(Ljava/lang/String;)V"); if (_m_PDFTextStripper__setPageEnd == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__setPageEnd, pageEndValue); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__getArticleStart = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__getArticleStart(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__getArticleStart, "getArticleStart", "()Ljava/lang/String;"); if (_m_PDFTextStripper__getArticleStart == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDFTextStripper__getArticleStart); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -2589,32 +2648,34 @@ FFI_PLUGIN_EXPORT JniResult PDFTextStripper__setArticleStart(jobject self_, jobject articleStartValue) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__setArticleStart, "setArticleStart", "(Ljava/lang/String;)V"); if (_m_PDFTextStripper__setArticleStart == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__setArticleStart, articleStartValue); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__getArticleEnd = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__getArticleEnd(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__getArticleEnd, "getArticleEnd", "()Ljava/lang/String;"); if (_m_PDFTextStripper__getArticleEnd == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDFTextStripper__getArticleEnd); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -2623,94 +2684,100 @@ FFI_PLUGIN_EXPORT JniResult PDFTextStripper__setArticleEnd(jobject self_, jobject articleEndValue) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__setArticleEnd, "setArticleEnd", "(Ljava/lang/String;)V"); if (_m_PDFTextStripper__setArticleEnd == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__setArticleEnd, articleEndValue); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__writeParagraphSeparator = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__writeParagraphSeparator(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__writeParagraphSeparator, "writeParagraphSeparator", "()V"); if (_m_PDFTextStripper__writeParagraphSeparator == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__writeParagraphSeparator); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__writeParagraphStart = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__writeParagraphStart(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__writeParagraphStart, "writeParagraphStart", "()V"); if (_m_PDFTextStripper__writeParagraphStart == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__writeParagraphStart); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__writeParagraphEnd = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__writeParagraphEnd(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__writeParagraphEnd, "writeParagraphEnd", "()V"); if (_m_PDFTextStripper__writeParagraphEnd == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__writeParagraphEnd); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__writePageStart = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__writePageStart(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__writePageStart, "writePageStart", "()V"); if (_m_PDFTextStripper__writePageStart == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__writePageStart); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__writePageEnd = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__writePageEnd(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__writePageEnd, "writePageEnd", "()V"); if (_m_PDFTextStripper__writePageEnd == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__writePageEnd); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__setListItemPatterns = NULL; @@ -2718,32 +2785,34 @@ FFI_PLUGIN_EXPORT JniResult PDFTextStripper__setListItemPatterns(jobject self_, jobject patterns) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__setListItemPatterns, "setListItemPatterns", "(Ljava/util/List;)V"); if (_m_PDFTextStripper__setListItemPatterns == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_PDFTextStripper__setListItemPatterns, patterns); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_PDFTextStripper__getListItemPatterns = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__getListItemPatterns(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_PDFTextStripper, &_m_PDFTextStripper__getListItemPatterns, "getListItemPatterns", "()Ljava/util/List;"); if (_m_PDFTextStripper__getListItemPatterns == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDFTextStripper__getListItemPatterns); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -2751,18 +2820,19 @@ jmethodID _m_PDFTextStripper__matchPattern = NULL; FFI_PLUGIN_EXPORT JniResult PDFTextStripper__matchPattern(jobject string, jobject patterns) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method( _c_PDFTextStripper, &_m_PDFTextStripper__matchPattern, "matchPattern", "(Ljava/lang/String;Ljava/util/List;)Ljava/util/regex/Pattern;"); if (_m_PDFTextStripper__matchPattern == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_PDFTextStripper, _m_PDFTextStripper__matchPattern, string, patterns); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -2770,92 +2840,99 @@ jfieldID _f_PDFTextStripper__LINE_SEPARATOR = NULL; FFI_PLUGIN_EXPORT JniResult get_PDFTextStripper__LINE_SEPARATOR(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_PDFTextStripper, &_f_PDFTextStripper__LINE_SEPARATOR, "LINE_SEPARATOR", "Ljava/lang/String;"); jobject _result = to_global_ref((*jniEnv)->GetObjectField( jniEnv, self_, _f_PDFTextStripper__LINE_SEPARATOR)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } jfieldID _f_PDFTextStripper__charactersByArticle = NULL; FFI_PLUGIN_EXPORT JniResult get_PDFTextStripper__charactersByArticle(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_PDFTextStripper, &_f_PDFTextStripper__charactersByArticle, "charactersByArticle", "Ljava/util/ArrayList;"); jobject _result = to_global_ref((*jniEnv)->GetObjectField( jniEnv, self_, _f_PDFTextStripper__charactersByArticle)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } FFI_PLUGIN_EXPORT JniResult set_PDFTextStripper__charactersByArticle(jobject self_, jobject value) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_PDFTextStripper, &_f_PDFTextStripper__charactersByArticle, "charactersByArticle", "Ljava/util/ArrayList;"); (*jniEnv)->SetObjectField(jniEnv, self_, _f_PDFTextStripper__charactersByArticle, value); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jfieldID _f_PDFTextStripper__document = NULL; FFI_PLUGIN_EXPORT JniResult get_PDFTextStripper__document(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_PDFTextStripper, &_f_PDFTextStripper__document, "document", "Lorg/apache/pdfbox/pdmodel/PDDocument;"); jobject _result = to_global_ref( (*jniEnv)->GetObjectField(jniEnv, self_, _f_PDFTextStripper__document)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } FFI_PLUGIN_EXPORT JniResult set_PDFTextStripper__document(jobject self_, jobject value) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_PDFTextStripper, &_f_PDFTextStripper__document, "document", "Lorg/apache/pdfbox/pdmodel/PDDocument;"); (*jniEnv)->SetObjectField(jniEnv, self_, _f_PDFTextStripper__document, value); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jfieldID _f_PDFTextStripper__output = NULL; FFI_PLUGIN_EXPORT JniResult get_PDFTextStripper__output(jobject self_) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_PDFTextStripper, &_f_PDFTextStripper__output, "output", "Ljava/io/Writer;"); jobject _result = to_global_ref( (*jniEnv)->GetObjectField(jniEnv, self_, _f_PDFTextStripper__output)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } FFI_PLUGIN_EXPORT JniResult set_PDFTextStripper__output(jobject self_, jobject value) { load_env(); - load_class_gr(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); + load_class_global_ref(&_c_PDFTextStripper, + "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_PDFTextStripper, &_f_PDFTextStripper__output, "output", "Ljava/io/Writer;"); (*jniEnv)->SetObjectField(jniEnv, self_, _f_PDFTextStripper__output, value); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } diff --git a/pkgs/jnigen/lib/src/bindings/c_bindings.dart b/pkgs/jnigen/lib/src/bindings/c_bindings.dart index f57e79c21..2e87e3d36 100644 --- a/pkgs/jnigen/lib/src/bindings/c_bindings.dart +++ b/pkgs/jnigen/lib/src/bindings/c_bindings.dart @@ -13,7 +13,7 @@ class CBindingGenerator { static final indent = ' ' * 4; static const jniResultType = 'JniResult'; static const ifError = - '(JniResult){.result = {.j = 0}, .exception = check_exception()}'; + '(JniResult){.value = {.j = 0}, .exception = check_exception()}'; // These should be avoided in parameter names. static const _cTypeKeywords = { @@ -171,7 +171,7 @@ $jniResultType $cMethodName($cMethodParams) { final cResultType = getCType(f.type.name); final unionField = getJValueField(f.type); accessorStatements = '$indent$cResultType _result = $getterExpr;\n' - '${indent}return (JniResult){.result = ' + '${indent}return (JniResult){.value = ' '{.$unionField = _result}, .exception = check_exception()};'; } @@ -197,7 +197,7 @@ $accessorStatements final String _loadEnvCall = '${indent}load_env();'; String _loadClassCall(String classVar, String internalName) { - return '${indent}load_class_gr(&$classVar, "$internalName");\n' + return '${indent}load_class_global_ref(&$classVar, "$internalName");\n' '${indent}if ($classVar == NULL) return $ifError;'; } @@ -267,7 +267,7 @@ $accessorStatements valuePart = '_result'; } const exceptionPart = 'check_exception()'; - return '${indent}return (JniResult){.result = {.$unionField = $valuePart}, ' + return '${indent}return (JniResult){.value = {.$unionField = $valuePart}, ' '.exception = $exceptionPart};'; } @@ -289,11 +289,11 @@ class CPreludes { '#include "dartjni.h"\n' '\n'; static const defines = 'thread_local JNIEnv *jniEnv;\n' - 'JniContext jni;\n\n' - 'JniContext (*context_getter)(void);\n' + 'JniContext *jni;\n\n' + 'JniContext *(*context_getter)(void);\n' 'JNIEnv *(*env_getter)(void);\n' '\n'; - static const initializers = 'void setJniGetters(JniContext (*cg)(void),\n' + static const initializers = 'void setJniGetters(JniContext *(*cg)(void),\n' ' JNIEnv *(*eg)(void)) {\n' ' context_getter = cg;\n' ' env_getter = eg;\n' diff --git a/pkgs/jnigen/lib/src/bindings/dart_generator.dart b/pkgs/jnigen/lib/src/bindings/dart_generator.dart index 58561f9eb..b23854802 100644 --- a/pkgs/jnigen/lib/src/bindings/dart_generator.dart +++ b/pkgs/jnigen/lib/src/bindings/dart_generator.dart @@ -1119,7 +1119,7 @@ class _MethodGenerator extends Visitor { $callExpr; final \$o = $_jPointer.fromAddress(await \$p.first); final \$k = $returnTypeClass.getClass().reference; - if ($_jni.Jni.env.IsInstanceOf(\$o, \$k) == 0) { + if (!$_jni.Jni.env.IsInstanceOf(\$o, \$k)) { throw "Failed"; } return $returning; diff --git a/pkgs/jnigen/lib/src/tools/build_summarizer.dart b/pkgs/jnigen/lib/src/tools/build_summarizer.dart index 30ce426f9..5d5a7efbf 100644 --- a/pkgs/jnigen/lib/src/tools/build_summarizer.dart +++ b/pkgs/jnigen/lib/src/tools/build_summarizer.dart @@ -67,8 +67,8 @@ Future buildSummarizerIfNotExists({bool force = false}) async { } if (!jarExists) { log.info('Building ApiSummarizer component. ' - 'This might take some time. \n' - 'The build will be cached for subsequent runs\n'); + 'This might take some time. ' + 'The build will be cached for subsequent runs.'); } if (!jarExists || isJarStale || force) { await buildApiSummarizer(); diff --git a/pkgs/jnigen/test/kotlin_test/lib/kotlin.dart b/pkgs/jnigen/test/kotlin_test/lib/kotlin.dart index 094aa46f6..59119b474 100644 --- a/pkgs/jnigen/test/kotlin_test/lib/kotlin.dart +++ b/pkgs/jnigen/test/kotlin_test/lib/kotlin.dart @@ -65,7 +65,7 @@ class SuspendFun extends jni.JObject { _sayHello(reference, $c.reference).object; final $o = jni.JObjectPtr.fromAddress(await $p.first); final $k = const jni.JStringType().getClass().reference; - if (jni.Jni.env.IsInstanceOf($o, $k) == 0) { + if (!jni.Jni.env.IsInstanceOf($o, $k)) { throw "Failed"; } return const jni.JStringType().fromRef($o); @@ -91,7 +91,7 @@ class SuspendFun extends jni.JObject { _sayHello1(reference, string.reference, $c.reference).object; final $o = jni.JObjectPtr.fromAddress(await $p.first); final $k = const jni.JStringType().getClass().reference; - if (jni.Jni.env.IsInstanceOf($o, $k) == 0) { + if (!jni.Jni.env.IsInstanceOf($o, $k)) { throw "Failed"; } return const jni.JStringType().fromRef($o); diff --git a/pkgs/jnigen/test/kotlin_test/src/dartjni.h b/pkgs/jnigen/test/kotlin_test/src/dartjni.h index 39b70bd8f..eb73318d1 100644 --- a/pkgs/jnigen/test/kotlin_test/src/dartjni.h +++ b/pkgs/jnigen/test/kotlin_test/src/dartjni.h @@ -39,6 +39,66 @@ #define __ENVP_CAST (void**) #endif +/// Locking functions for windows and pthread. + +#if defined _WIN32 +#include + +typedef CRITICAL_SECTION MutexLock; + +static inline void init_lock(MutexLock* lock) { + InitializeCriticalSection(lock); +} + +static inline void acquire_lock(MutexLock* lock) { + EnterCriticalSection(lock); +} + +static inline void release_lock(MutexLock* lock) { + LeaveCriticalSection(lock); +} + +static inline void _destroyLock(MutexLock* lock) { + DeleteCriticalSection(lock); +} + +#elif defined __DARWIN__ || defined __LINUX__ || defined __ANDROID__ || \ + defined __GNUC__ +#include + +typedef pthread_mutex_t MutexLock; + +static inline void init_lock(MutexLock* lock) { + pthread_mutex_init(lock, NULL); +} + +static inline void acquire_lock(MutexLock* lock) { + pthread_mutex_lock(lock); +} + +static inline void release_lock(MutexLock* lock) { + pthread_mutex_unlock(lock); +} + +static inline void _destroyLock(MutexLock* lock) { + pthread_mutex_destroy(lock); +} + +#else + +#error "No locking support; Possibly unsupported platform" + +#endif + +typedef struct JniLocks { + MutexLock classLoadingLock; + MutexLock methodLoadingLock; + MutexLock fieldLoadingLock; +} JniLocks; + +/// Represents the error when dart-jni layer has already spawned singleton VM. +#define DART_JNI_SINGLETON_EXISTS (-99); + /// Stores the global state of the JNI. typedef struct JniContext { JavaVM* jvm; @@ -46,13 +106,14 @@ typedef struct JniContext { jmethodID loadClassMethod; jobject currentActivity; jobject appContext; + JniLocks locks; } JniContext; // jniEnv for this thread, used by inline functions in this header, // therefore declared as extern. extern thread_local JNIEnv* jniEnv; -extern JniContext jni; +extern JniContext* jni; /// Types used by JNI API to distinguish between primitive types. enum JniType { @@ -73,19 +134,19 @@ enum JniType { /// If [exception] is null, it means the result is valid. /// It's assumed that the caller knows the expected type in [result]. typedef struct JniResult { - jvalue result; + jvalue value; jthrowable exception; } JniResult; /// Similar to [JniResult] but for class lookups. typedef struct JniClassLookupResult { - jclass classRef; + jclass value; jthrowable exception; } JniClassLookupResult; /// Similar to [JniResult] but for method/field ID lookups. typedef struct JniPointerResult { - void* id; + const void* value; jthrowable exception; } JniPointerResult; @@ -139,54 +200,71 @@ FFI_PLUGIN_EXPORT JavaVM* GetJavaVM(void); FFI_PLUGIN_EXPORT JNIEnv* GetJniEnv(void); -FFI_PLUGIN_EXPORT JNIEnv* SpawnJvm(JavaVMInitArgs* args); +/// 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. +FFI_PLUGIN_EXPORT int SpawnJvm(JavaVMInitArgs* args); -FFI_PLUGIN_EXPORT jclass LoadClass(const char* name); +/// Load class through platform-specific mechanism. +/// +/// Currently uses application classloader on android, +/// and JNIEnv->FindClass on other platforms. +FFI_PLUGIN_EXPORT jclass FindClass(const char* name); +/// Returns Application classLoader (on Android), +/// which can be used to load application and platform classes. +/// +/// On other platforms, NULL is returned. FFI_PLUGIN_EXPORT jobject GetClassLoader(void); +/// Returns application context on Android. +/// +/// On other platforms, NULL is returned. FFI_PLUGIN_EXPORT jobject GetApplicationContext(void); +/// Returns current activity of the app on Android. FFI_PLUGIN_EXPORT jobject GetCurrentActivity(void); -// Migration note: Below inline functions are required by C bindings, but can be moved to dartjni.c -// once migration to pure dart bindings is complete. - -// `static inline` because `inline` doesn't work, it may still not -// inline the function in which case a linker error may be produced. -// -// There has to be a better way to do this. Either to force inlining on target -// platforms, or just leave it as normal function. +static inline void attach_thread() { + if (jniEnv == NULL) { + (*jni->jvm)->AttachCurrentThread(jni->jvm, __ENVP_CAST & jniEnv, NULL); + } +} -static inline void __load_class_into(jclass* cls, const char* name) { +/// Load class into [cls] using platform specific mechanism +static inline void load_class_platform(jclass* cls, const char* name) { #ifdef __ANDROID__ jstring className = (*jniEnv)->NewStringUTF(jniEnv, name); - *cls = (*jniEnv)->CallObjectMethod(jniEnv, jni.classLoader, - jni.loadClassMethod, className); + *cls = (*jniEnv)->CallObjectMethod(jniEnv, jni->classLoader, + jni->loadClassMethod, className); (*jniEnv)->DeleteLocalRef(jniEnv, className); #else *cls = (*jniEnv)->FindClass(jniEnv, name); #endif } -static inline void load_class(jclass* cls, const char* name) { +static inline void load_class_local_ref(jclass* cls, const char* name) { if (*cls == NULL) { - __load_class_into(cls, name); + acquire_lock(&jni->locks.classLoadingLock); + if (*cls == NULL) { + load_class_platform(cls, name); + } + release_lock(&jni->locks.classLoadingLock); } } -static inline void load_class_gr(jclass* cls, const char* name) { +static inline void load_class_global_ref(jclass* cls, const char* name) { if (*cls == NULL) { - jclass tmp; - __load_class_into(&tmp, name); - *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); - (*jniEnv)->DeleteLocalRef(jniEnv, tmp); - } -} - -static inline void attach_thread() { - if (jniEnv == NULL) { - (*jni.jvm)->AttachCurrentThread(jni.jvm, __ENVP_CAST & jniEnv, NULL); + jclass tmp = NULL; + acquire_lock(&jni->locks.classLoadingLock); + if (*cls == NULL) { + load_class_platform(&tmp, name); + *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); + (*jniEnv)->DeleteLocalRef(jniEnv, tmp); + } + release_lock(&jni->locks.classLoadingLock); } } @@ -195,7 +273,11 @@ static inline void load_method(jclass cls, const char* name, const char* sig) { if (*res == NULL) { - *res = (*jniEnv)->GetMethodID(jniEnv, cls, name, sig); + acquire_lock(&jni->locks.methodLoadingLock); + if (*res == NULL) { + *res = (*jniEnv)->GetMethodID(jniEnv, cls, name, sig); + } + release_lock(&jni->locks.methodLoadingLock); } } @@ -204,7 +286,11 @@ static inline void load_static_method(jclass cls, const char* name, const char* sig) { if (*res == NULL) { - *res = (*jniEnv)->GetStaticMethodID(jniEnv, cls, name, sig); + acquire_lock(&jni->locks.methodLoadingLock); + if (*res == NULL) { + *res = (*jniEnv)->GetStaticMethodID(jniEnv, cls, name, sig); + } + release_lock(&jni->locks.methodLoadingLock); } } @@ -213,7 +299,11 @@ static inline void load_field(jclass cls, const char* name, const char* sig) { if (*res == NULL) { - *res = (*jniEnv)->GetFieldID(jniEnv, cls, name, sig); + acquire_lock(&jni->locks.fieldLoadingLock); + if (*res == NULL) { + *res = (*jniEnv)->GetFieldID(jniEnv, cls, name, sig); + } + release_lock(&jni->locks.fieldLoadingLock); } } @@ -222,7 +312,11 @@ static inline void load_static_field(jclass cls, const char* name, const char* sig) { if (*res == NULL) { - *res = (*jniEnv)->GetStaticFieldID(jniEnv, cls, name, sig); + acquire_lock(&jni->locks.fieldLoadingLock); + if (*res == NULL) { + *res = (*jniEnv)->GetStaticFieldID(jniEnv, cls, name, sig); + } + release_lock(&jni->locks.fieldLoadingLock); } } @@ -234,17 +328,18 @@ static inline jobject to_global_ref(jobject ref) { // These functions are useful for C+Dart bindings, and not required for pure dart bindings. -FFI_PLUGIN_EXPORT JniContext GetJniContext(); +FFI_PLUGIN_EXPORT JniContext* GetJniContextPtr(); + /// For use by jni_gen's generated code /// don't use these. // these 2 fn ptr vars will be defined by generated code library -extern JniContext (*context_getter)(void); +extern JniContext* (*context_getter)(void); extern JNIEnv* (*env_getter)(void); // this function will be exported by generated code library // it will set above 2 variables. -FFI_PLUGIN_EXPORT void setJniGetters(struct JniContext (*cg)(void), +FFI_PLUGIN_EXPORT void setJniGetters(struct JniContext* (*cg)(void), JNIEnv* (*eg)(void)); static inline void load_env() { diff --git a/pkgs/jnigen/test/kotlin_test/src/kotlin.c b/pkgs/jnigen/test/kotlin_test/src/kotlin.c index 7b1426c26..b70978ef8 100644 --- a/pkgs/jnigen/test/kotlin_test/src/kotlin.c +++ b/pkgs/jnigen/test/kotlin_test/src/kotlin.c @@ -9,12 +9,12 @@ #include "jni.h" thread_local JNIEnv* jniEnv; -JniContext jni; +JniContext* jni; -JniContext (*context_getter)(void); +JniContext* (*context_getter)(void); JNIEnv* (*env_getter)(void); -void setJniGetters(JniContext (*cg)(void), JNIEnv* (*eg)(void)) { +void setJniGetters(JniContext* (*cg)(void), JNIEnv* (*eg)(void)) { context_getter = cg; env_getter = eg; } @@ -26,15 +26,16 @@ jmethodID _m_SuspendFun__ctor = NULL; FFI_PLUGIN_EXPORT JniResult SuspendFun__ctor() { load_env(); - load_class_gr(&_c_SuspendFun, "com/github/dart_lang/jnigen/SuspendFun"); + load_class_global_ref(&_c_SuspendFun, + "com/github/dart_lang/jnigen/SuspendFun"); if (_c_SuspendFun == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_SuspendFun, &_m_SuspendFun__ctor, "", "()V"); if (_m_SuspendFun__ctor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_SuspendFun, _m_SuspendFun__ctor); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -42,16 +43,17 @@ jmethodID _m_SuspendFun__sayHello = NULL; FFI_PLUGIN_EXPORT JniResult SuspendFun__sayHello(jobject self_, jobject continuation) { load_env(); - load_class_gr(&_c_SuspendFun, "com/github/dart_lang/jnigen/SuspendFun"); + load_class_global_ref(&_c_SuspendFun, + "com/github/dart_lang/jnigen/SuspendFun"); if (_c_SuspendFun == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_SuspendFun, &_m_SuspendFun__sayHello, "sayHello", "(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;"); if (_m_SuspendFun__sayHello == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_SuspendFun__sayHello, continuation); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -61,16 +63,17 @@ JniResult SuspendFun__sayHello1(jobject self_, jobject string, jobject continuation) { load_env(); - load_class_gr(&_c_SuspendFun, "com/github/dart_lang/jnigen/SuspendFun"); + load_class_global_ref(&_c_SuspendFun, + "com/github/dart_lang/jnigen/SuspendFun"); if (_c_SuspendFun == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method( _c_SuspendFun, &_m_SuspendFun__sayHello1, "sayHello", "(Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;"); if (_m_SuspendFun__sayHello1 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_SuspendFun__sayHello1, string, continuation); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } diff --git a/pkgs/jnigen/test/simple_package_test/src/dartjni.h b/pkgs/jnigen/test/simple_package_test/src/dartjni.h index 39b70bd8f..eb73318d1 100644 --- a/pkgs/jnigen/test/simple_package_test/src/dartjni.h +++ b/pkgs/jnigen/test/simple_package_test/src/dartjni.h @@ -39,6 +39,66 @@ #define __ENVP_CAST (void**) #endif +/// Locking functions for windows and pthread. + +#if defined _WIN32 +#include + +typedef CRITICAL_SECTION MutexLock; + +static inline void init_lock(MutexLock* lock) { + InitializeCriticalSection(lock); +} + +static inline void acquire_lock(MutexLock* lock) { + EnterCriticalSection(lock); +} + +static inline void release_lock(MutexLock* lock) { + LeaveCriticalSection(lock); +} + +static inline void _destroyLock(MutexLock* lock) { + DeleteCriticalSection(lock); +} + +#elif defined __DARWIN__ || defined __LINUX__ || defined __ANDROID__ || \ + defined __GNUC__ +#include + +typedef pthread_mutex_t MutexLock; + +static inline void init_lock(MutexLock* lock) { + pthread_mutex_init(lock, NULL); +} + +static inline void acquire_lock(MutexLock* lock) { + pthread_mutex_lock(lock); +} + +static inline void release_lock(MutexLock* lock) { + pthread_mutex_unlock(lock); +} + +static inline void _destroyLock(MutexLock* lock) { + pthread_mutex_destroy(lock); +} + +#else + +#error "No locking support; Possibly unsupported platform" + +#endif + +typedef struct JniLocks { + MutexLock classLoadingLock; + MutexLock methodLoadingLock; + MutexLock fieldLoadingLock; +} JniLocks; + +/// Represents the error when dart-jni layer has already spawned singleton VM. +#define DART_JNI_SINGLETON_EXISTS (-99); + /// Stores the global state of the JNI. typedef struct JniContext { JavaVM* jvm; @@ -46,13 +106,14 @@ typedef struct JniContext { jmethodID loadClassMethod; jobject currentActivity; jobject appContext; + JniLocks locks; } JniContext; // jniEnv for this thread, used by inline functions in this header, // therefore declared as extern. extern thread_local JNIEnv* jniEnv; -extern JniContext jni; +extern JniContext* jni; /// Types used by JNI API to distinguish between primitive types. enum JniType { @@ -73,19 +134,19 @@ enum JniType { /// If [exception] is null, it means the result is valid. /// It's assumed that the caller knows the expected type in [result]. typedef struct JniResult { - jvalue result; + jvalue value; jthrowable exception; } JniResult; /// Similar to [JniResult] but for class lookups. typedef struct JniClassLookupResult { - jclass classRef; + jclass value; jthrowable exception; } JniClassLookupResult; /// Similar to [JniResult] but for method/field ID lookups. typedef struct JniPointerResult { - void* id; + const void* value; jthrowable exception; } JniPointerResult; @@ -139,54 +200,71 @@ FFI_PLUGIN_EXPORT JavaVM* GetJavaVM(void); FFI_PLUGIN_EXPORT JNIEnv* GetJniEnv(void); -FFI_PLUGIN_EXPORT JNIEnv* SpawnJvm(JavaVMInitArgs* args); +/// 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. +FFI_PLUGIN_EXPORT int SpawnJvm(JavaVMInitArgs* args); -FFI_PLUGIN_EXPORT jclass LoadClass(const char* name); +/// Load class through platform-specific mechanism. +/// +/// Currently uses application classloader on android, +/// and JNIEnv->FindClass on other platforms. +FFI_PLUGIN_EXPORT jclass FindClass(const char* name); +/// Returns Application classLoader (on Android), +/// which can be used to load application and platform classes. +/// +/// On other platforms, NULL is returned. FFI_PLUGIN_EXPORT jobject GetClassLoader(void); +/// Returns application context on Android. +/// +/// On other platforms, NULL is returned. FFI_PLUGIN_EXPORT jobject GetApplicationContext(void); +/// Returns current activity of the app on Android. FFI_PLUGIN_EXPORT jobject GetCurrentActivity(void); -// Migration note: Below inline functions are required by C bindings, but can be moved to dartjni.c -// once migration to pure dart bindings is complete. - -// `static inline` because `inline` doesn't work, it may still not -// inline the function in which case a linker error may be produced. -// -// There has to be a better way to do this. Either to force inlining on target -// platforms, or just leave it as normal function. +static inline void attach_thread() { + if (jniEnv == NULL) { + (*jni->jvm)->AttachCurrentThread(jni->jvm, __ENVP_CAST & jniEnv, NULL); + } +} -static inline void __load_class_into(jclass* cls, const char* name) { +/// Load class into [cls] using platform specific mechanism +static inline void load_class_platform(jclass* cls, const char* name) { #ifdef __ANDROID__ jstring className = (*jniEnv)->NewStringUTF(jniEnv, name); - *cls = (*jniEnv)->CallObjectMethod(jniEnv, jni.classLoader, - jni.loadClassMethod, className); + *cls = (*jniEnv)->CallObjectMethod(jniEnv, jni->classLoader, + jni->loadClassMethod, className); (*jniEnv)->DeleteLocalRef(jniEnv, className); #else *cls = (*jniEnv)->FindClass(jniEnv, name); #endif } -static inline void load_class(jclass* cls, const char* name) { +static inline void load_class_local_ref(jclass* cls, const char* name) { if (*cls == NULL) { - __load_class_into(cls, name); + acquire_lock(&jni->locks.classLoadingLock); + if (*cls == NULL) { + load_class_platform(cls, name); + } + release_lock(&jni->locks.classLoadingLock); } } -static inline void load_class_gr(jclass* cls, const char* name) { +static inline void load_class_global_ref(jclass* cls, const char* name) { if (*cls == NULL) { - jclass tmp; - __load_class_into(&tmp, name); - *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); - (*jniEnv)->DeleteLocalRef(jniEnv, tmp); - } -} - -static inline void attach_thread() { - if (jniEnv == NULL) { - (*jni.jvm)->AttachCurrentThread(jni.jvm, __ENVP_CAST & jniEnv, NULL); + jclass tmp = NULL; + acquire_lock(&jni->locks.classLoadingLock); + if (*cls == NULL) { + load_class_platform(&tmp, name); + *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); + (*jniEnv)->DeleteLocalRef(jniEnv, tmp); + } + release_lock(&jni->locks.classLoadingLock); } } @@ -195,7 +273,11 @@ static inline void load_method(jclass cls, const char* name, const char* sig) { if (*res == NULL) { - *res = (*jniEnv)->GetMethodID(jniEnv, cls, name, sig); + acquire_lock(&jni->locks.methodLoadingLock); + if (*res == NULL) { + *res = (*jniEnv)->GetMethodID(jniEnv, cls, name, sig); + } + release_lock(&jni->locks.methodLoadingLock); } } @@ -204,7 +286,11 @@ static inline void load_static_method(jclass cls, const char* name, const char* sig) { if (*res == NULL) { - *res = (*jniEnv)->GetStaticMethodID(jniEnv, cls, name, sig); + acquire_lock(&jni->locks.methodLoadingLock); + if (*res == NULL) { + *res = (*jniEnv)->GetStaticMethodID(jniEnv, cls, name, sig); + } + release_lock(&jni->locks.methodLoadingLock); } } @@ -213,7 +299,11 @@ static inline void load_field(jclass cls, const char* name, const char* sig) { if (*res == NULL) { - *res = (*jniEnv)->GetFieldID(jniEnv, cls, name, sig); + acquire_lock(&jni->locks.fieldLoadingLock); + if (*res == NULL) { + *res = (*jniEnv)->GetFieldID(jniEnv, cls, name, sig); + } + release_lock(&jni->locks.fieldLoadingLock); } } @@ -222,7 +312,11 @@ static inline void load_static_field(jclass cls, const char* name, const char* sig) { if (*res == NULL) { - *res = (*jniEnv)->GetStaticFieldID(jniEnv, cls, name, sig); + acquire_lock(&jni->locks.fieldLoadingLock); + if (*res == NULL) { + *res = (*jniEnv)->GetStaticFieldID(jniEnv, cls, name, sig); + } + release_lock(&jni->locks.fieldLoadingLock); } } @@ -234,17 +328,18 @@ static inline jobject to_global_ref(jobject ref) { // These functions are useful for C+Dart bindings, and not required for pure dart bindings. -FFI_PLUGIN_EXPORT JniContext GetJniContext(); +FFI_PLUGIN_EXPORT JniContext* GetJniContextPtr(); + /// For use by jni_gen's generated code /// don't use these. // these 2 fn ptr vars will be defined by generated code library -extern JniContext (*context_getter)(void); +extern JniContext* (*context_getter)(void); extern JNIEnv* (*env_getter)(void); // this function will be exported by generated code library // it will set above 2 variables. -FFI_PLUGIN_EXPORT void setJniGetters(struct JniContext (*cg)(void), +FFI_PLUGIN_EXPORT void setJniGetters(struct JniContext* (*cg)(void), JNIEnv* (*eg)(void)); static inline void load_env() { diff --git a/pkgs/jnigen/test/simple_package_test/src/simple_package.c b/pkgs/jnigen/test/simple_package_test/src/simple_package.c index 0e85ae93a..be680029e 100644 --- a/pkgs/jnigen/test/simple_package_test/src/simple_package.c +++ b/pkgs/jnigen/test/simple_package_test/src/simple_package.c @@ -9,12 +9,12 @@ #include "jni.h" thread_local JNIEnv* jniEnv; -JniContext jni; +JniContext* jni; -JniContext (*context_getter)(void); +JniContext* (*context_getter)(void); JNIEnv* (*env_getter)(void); -void setJniGetters(JniContext (*cg)(void), JNIEnv* (*eg)(void)) { +void setJniGetters(JniContext* (*cg)(void), JNIEnv* (*eg)(void)) { context_getter = cg; env_getter = eg; } @@ -26,15 +26,15 @@ jmethodID _m_Example__ctor = NULL; FFI_PLUGIN_EXPORT JniResult Example__ctor() { load_env(); - load_class_gr(&_c_Example, - "com/github/dart_lang/jnigen/simple_package/Example"); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); if (_c_Example == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_Example, &_m_Example__ctor, "", "()V"); if (_m_Example__ctor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Example, _m_Example__ctor); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -42,16 +42,16 @@ jmethodID _m_Example__ctor1 = NULL; FFI_PLUGIN_EXPORT JniResult Example__ctor1(int32_t internal) { load_env(); - load_class_gr(&_c_Example, - "com/github/dart_lang/jnigen/simple_package/Example"); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); if (_c_Example == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_Example, &_m_Example__ctor1, "", "(I)V"); if (_m_Example__ctor1 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Example, _m_Example__ctor1, internal); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -59,34 +59,34 @@ jmethodID _m_Example__whichExample = NULL; FFI_PLUGIN_EXPORT JniResult Example__whichExample(jobject self_) { load_env(); - load_class_gr(&_c_Example, - "com/github/dart_lang/jnigen/simple_package/Example"); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); if (_c_Example == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_Example, &_m_Example__whichExample, "whichExample", "()I"); if (_m_Example__whichExample == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_Example__whichExample); - return (JniResult){.result = {.i = _result}, .exception = check_exception()}; + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; } jmethodID _m_Example__getAux = NULL; FFI_PLUGIN_EXPORT JniResult Example__getAux() { load_env(); - load_class_gr(&_c_Example, - "com/github/dart_lang/jnigen/simple_package/Example"); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); if (_c_Example == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method( _c_Example, &_m_Example__getAux, "getAux", "()Lcom/github/dart_lang/jnigen/simple_package/Example$Aux;"); if (_m_Example__getAux == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_Example, _m_Example__getAux); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -94,32 +94,32 @@ jmethodID _m_Example__addInts = NULL; FFI_PLUGIN_EXPORT JniResult Example__addInts(int32_t a, int32_t b) { load_env(); - load_class_gr(&_c_Example, - "com/github/dart_lang/jnigen/simple_package/Example"); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); if (_c_Example == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method(_c_Example, &_m_Example__addInts, "addInts", "(II)I"); if (_m_Example__addInts == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; int32_t _result = (*jniEnv)->CallStaticIntMethod(jniEnv, _c_Example, _m_Example__addInts, a, b); - return (JniResult){.result = {.i = _result}, .exception = check_exception()}; + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; } jmethodID _m_Example__getArr = NULL; FFI_PLUGIN_EXPORT JniResult Example__getArr() { load_env(); - load_class_gr(&_c_Example, - "com/github/dart_lang/jnigen/simple_package/Example"); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); if (_c_Example == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method(_c_Example, &_m_Example__getArr, "getArr", "()[I"); if (_m_Example__getArr == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_Example, _m_Example__getArr); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -127,33 +127,33 @@ jmethodID _m_Example__addAll = NULL; FFI_PLUGIN_EXPORT JniResult Example__addAll(jobject arr) { load_env(); - load_class_gr(&_c_Example, - "com/github/dart_lang/jnigen/simple_package/Example"); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); if (_c_Example == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method(_c_Example, &_m_Example__addAll, "addAll", "([I)I"); if (_m_Example__addAll == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; int32_t _result = (*jniEnv)->CallStaticIntMethod(jniEnv, _c_Example, _m_Example__addAll, arr); - return (JniResult){.result = {.i = _result}, .exception = check_exception()}; + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; } jmethodID _m_Example__getSelf = NULL; FFI_PLUGIN_EXPORT JniResult Example__getSelf(jobject self_) { load_env(); - load_class_gr(&_c_Example, - "com/github/dart_lang/jnigen/simple_package/Example"); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); if (_c_Example == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_Example, &_m_Example__getSelf, "getSelf", "()Lcom/github/dart_lang/jnigen/simple_package/Example;"); if (_m_Example__getSelf == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_Example__getSelf); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -161,132 +161,132 @@ jmethodID _m_Example__getNum = NULL; FFI_PLUGIN_EXPORT JniResult Example__getNum(jobject self_) { load_env(); - load_class_gr(&_c_Example, - "com/github/dart_lang/jnigen/simple_package/Example"); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); if (_c_Example == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_Example, &_m_Example__getNum, "getNum", "()I"); if (_m_Example__getNum == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_Example__getNum); - return (JniResult){.result = {.i = _result}, .exception = check_exception()}; + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; } jmethodID _m_Example__setNum = NULL; FFI_PLUGIN_EXPORT JniResult Example__setNum(jobject self_, int32_t num) { load_env(); - load_class_gr(&_c_Example, - "com/github/dart_lang/jnigen/simple_package/Example"); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); if (_c_Example == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_Example, &_m_Example__setNum, "setNum", "(I)V"); if (_m_Example__setNum == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_Example__setNum, num); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_Example__getInternal = NULL; FFI_PLUGIN_EXPORT JniResult Example__getInternal(jobject self_) { load_env(); - load_class_gr(&_c_Example, - "com/github/dart_lang/jnigen/simple_package/Example"); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); if (_c_Example == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_Example, &_m_Example__getInternal, "getInternal", "()I"); if (_m_Example__getInternal == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_Example__getInternal); - return (JniResult){.result = {.i = _result}, .exception = check_exception()}; + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; } jmethodID _m_Example__setInternal = NULL; FFI_PLUGIN_EXPORT JniResult Example__setInternal(jobject self_, int32_t internal) { load_env(); - load_class_gr(&_c_Example, - "com/github/dart_lang/jnigen/simple_package/Example"); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); if (_c_Example == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_Example, &_m_Example__setInternal, "setInternal", "(I)V"); if (_m_Example__setInternal == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_Example__setInternal, internal); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_Example__throwException = NULL; FFI_PLUGIN_EXPORT JniResult Example__throwException() { load_env(); - load_class_gr(&_c_Example, - "com/github/dart_lang/jnigen/simple_package/Example"); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); if (_c_Example == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method(_c_Example, &_m_Example__throwException, "throwException", "()V"); if (_m_Example__throwException == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallStaticVoidMethod(jniEnv, _c_Example, _m_Example__throwException); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jfieldID _f_Example__aux = NULL; FFI_PLUGIN_EXPORT JniResult get_Example__aux() { load_env(); - load_class_gr(&_c_Example, - "com/github/dart_lang/jnigen/simple_package/Example"); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); if (_c_Example == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Example, &_f_Example__aux, "aux", "Lcom/github/dart_lang/jnigen/simple_package/Example$Aux;"); jobject _result = to_global_ref( (*jniEnv)->GetStaticObjectField(jniEnv, _c_Example, _f_Example__aux)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } FFI_PLUGIN_EXPORT JniResult set_Example__aux(jobject value) { load_env(); - load_class_gr(&_c_Example, - "com/github/dart_lang/jnigen/simple_package/Example"); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); if (_c_Example == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Example, &_f_Example__aux, "aux", "Lcom/github/dart_lang/jnigen/simple_package/Example$Aux;"); (*jniEnv)->SetStaticObjectField(jniEnv, _c_Example, _f_Example__aux, value); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jfieldID _f_Example__num = NULL; FFI_PLUGIN_EXPORT JniResult get_Example__num() { load_env(); - load_class_gr(&_c_Example, - "com/github/dart_lang/jnigen/simple_package/Example"); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); if (_c_Example == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Example, &_f_Example__num, "num", "I"); int32_t _result = (*jniEnv)->GetStaticIntField(jniEnv, _c_Example, _f_Example__num); - return (JniResult){.result = {.i = _result}, .exception = check_exception()}; + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; } FFI_PLUGIN_EXPORT JniResult set_Example__num(int32_t value) { load_env(); - load_class_gr(&_c_Example, - "com/github/dart_lang/jnigen/simple_package/Example"); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); if (_c_Example == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Example, &_f_Example__num, "num", "I"); (*jniEnv)->SetStaticIntField(jniEnv, _c_Example, _f_Example__num, value); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } // com.github.dart_lang.jnigen.simple_package.Example$Aux @@ -296,16 +296,17 @@ jmethodID _m_Example_Aux__ctor = NULL; FFI_PLUGIN_EXPORT JniResult Example_Aux__ctor(uint8_t value) { load_env(); - load_class_gr(&_c_Example_Aux, - "com/github/dart_lang/jnigen/simple_package/Example$Aux"); + load_class_global_ref( + &_c_Example_Aux, + "com/github/dart_lang/jnigen/simple_package/Example$Aux"); if (_c_Example_Aux == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_Example_Aux, &_m_Example_Aux__ctor, "", "(Z)V"); if (_m_Example_Aux__ctor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Example_Aux, _m_Example_Aux__ctor, value); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -313,57 +314,61 @@ jmethodID _m_Example_Aux__getValue = NULL; FFI_PLUGIN_EXPORT JniResult Example_Aux__getValue(jobject self_) { load_env(); - load_class_gr(&_c_Example_Aux, - "com/github/dart_lang/jnigen/simple_package/Example$Aux"); + load_class_global_ref( + &_c_Example_Aux, + "com/github/dart_lang/jnigen/simple_package/Example$Aux"); if (_c_Example_Aux == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_Example_Aux, &_m_Example_Aux__getValue, "getValue", "()Z"); if (_m_Example_Aux__getValue == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_Example_Aux__getValue); - return (JniResult){.result = {.z = _result}, .exception = check_exception()}; + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; } jmethodID _m_Example_Aux__setValue = NULL; FFI_PLUGIN_EXPORT JniResult Example_Aux__setValue(jobject self_, uint8_t value) { load_env(); - load_class_gr(&_c_Example_Aux, - "com/github/dart_lang/jnigen/simple_package/Example$Aux"); + load_class_global_ref( + &_c_Example_Aux, + "com/github/dart_lang/jnigen/simple_package/Example$Aux"); if (_c_Example_Aux == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_Example_Aux, &_m_Example_Aux__setValue, "setValue", "(Z)V"); if (_m_Example_Aux__setValue == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_Example_Aux__setValue, value); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jfieldID _f_Example_Aux__value = NULL; FFI_PLUGIN_EXPORT JniResult get_Example_Aux__value(jobject self_) { load_env(); - load_class_gr(&_c_Example_Aux, - "com/github/dart_lang/jnigen/simple_package/Example$Aux"); + load_class_global_ref( + &_c_Example_Aux, + "com/github/dart_lang/jnigen/simple_package/Example$Aux"); if (_c_Example_Aux == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_Example_Aux, &_f_Example_Aux__value, "value", "Z"); uint8_t _result = (*jniEnv)->GetBooleanField(jniEnv, self_, _f_Example_Aux__value); - return (JniResult){.result = {.z = _result}, .exception = check_exception()}; + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; } FFI_PLUGIN_EXPORT JniResult set_Example_Aux__value(jobject self_, uint8_t value) { load_env(); - load_class_gr(&_c_Example_Aux, - "com/github/dart_lang/jnigen/simple_package/Example$Aux"); + load_class_global_ref( + &_c_Example_Aux, + "com/github/dart_lang/jnigen/simple_package/Example$Aux"); if (_c_Example_Aux == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_Example_Aux, &_f_Example_Aux__value, "value", "Z"); (*jniEnv)->SetBooleanField(jniEnv, self_, _f_Example_Aux__value, value); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } // com.github.dart_lang.jnigen.pkg2.C2 @@ -373,14 +378,14 @@ jmethodID _m_C2__ctor = NULL; FFI_PLUGIN_EXPORT JniResult C2__ctor() { load_env(); - load_class_gr(&_c_C2, "com/github/dart_lang/jnigen/pkg2/C2"); + load_class_global_ref(&_c_C2, "com/github/dart_lang/jnigen/pkg2/C2"); if (_c_C2 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_C2, &_m_C2__ctor, "", "()V"); if (_m_C2__ctor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_C2, _m_C2__ctor); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -388,24 +393,24 @@ jfieldID _f_C2__CONSTANT = NULL; FFI_PLUGIN_EXPORT JniResult get_C2__CONSTANT() { load_env(); - load_class_gr(&_c_C2, "com/github/dart_lang/jnigen/pkg2/C2"); + load_class_global_ref(&_c_C2, "com/github/dart_lang/jnigen/pkg2/C2"); if (_c_C2 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_C2, &_f_C2__CONSTANT, "CONSTANT", "I"); int32_t _result = (*jniEnv)->GetStaticIntField(jniEnv, _c_C2, _f_C2__CONSTANT); - return (JniResult){.result = {.i = _result}, .exception = check_exception()}; + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; } FFI_PLUGIN_EXPORT JniResult set_C2__CONSTANT(int32_t value) { load_env(); - load_class_gr(&_c_C2, "com/github/dart_lang/jnigen/pkg2/C2"); + load_class_global_ref(&_c_C2, "com/github/dart_lang/jnigen/pkg2/C2"); if (_c_C2 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_C2, &_f_C2__CONSTANT, "CONSTANT", "I"); (*jniEnv)->SetStaticIntField(jniEnv, _c_C2, _f_C2__CONSTANT, value); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } // com.github.dart_lang.jnigen.pkg2.Example @@ -415,15 +420,16 @@ jmethodID _m_Example1__ctor = NULL; FFI_PLUGIN_EXPORT JniResult Example1__ctor() { load_env(); - load_class_gr(&_c_Example1, "com/github/dart_lang/jnigen/pkg2/Example"); + load_class_global_ref(&_c_Example1, + "com/github/dart_lang/jnigen/pkg2/Example"); if (_c_Example1 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_Example1, &_m_Example1__ctor, "", "()V"); if (_m_Example1__ctor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Example1, _m_Example1__ctor); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -431,15 +437,16 @@ jmethodID _m_Example1__whichExample = NULL; FFI_PLUGIN_EXPORT JniResult Example1__whichExample(jobject self_) { load_env(); - load_class_gr(&_c_Example1, "com/github/dart_lang/jnigen/pkg2/Example"); + load_class_global_ref(&_c_Example1, + "com/github/dart_lang/jnigen/pkg2/Example"); if (_c_Example1 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_Example1, &_m_Example1__whichExample, "whichExample", "()I"); if (_m_Example1__whichExample == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_Example1__whichExample); - return (JniResult){.result = {.i = _result}, .exception = check_exception()}; + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; } // com.github.dart_lang.jnigen.generics.GrandParent @@ -449,17 +456,17 @@ jmethodID _m_GrandParent__ctor = NULL; FFI_PLUGIN_EXPORT JniResult GrandParent__ctor(jobject value) { load_env(); - load_class_gr(&_c_GrandParent, - "com/github/dart_lang/jnigen/generics/GrandParent"); + load_class_global_ref(&_c_GrandParent, + "com/github/dart_lang/jnigen/generics/GrandParent"); if (_c_GrandParent == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_GrandParent, &_m_GrandParent__ctor, "", "(Ljava/lang/Object;)V"); if (_m_GrandParent__ctor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_GrandParent, _m_GrandParent__ctor, value); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -467,17 +474,17 @@ jmethodID _m_GrandParent__stringParent = NULL; FFI_PLUGIN_EXPORT JniResult GrandParent__stringParent(jobject self_) { load_env(); - load_class_gr(&_c_GrandParent, - "com/github/dart_lang/jnigen/generics/GrandParent"); + load_class_global_ref(&_c_GrandParent, + "com/github/dart_lang/jnigen/generics/GrandParent"); if (_c_GrandParent == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_GrandParent, &_m_GrandParent__stringParent, "stringParent", "()Lcom/github/dart_lang/jnigen/generics/GrandParent$Parent;"); if (_m_GrandParent__stringParent == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_GrandParent__stringParent); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -485,18 +492,18 @@ jmethodID _m_GrandParent__varParent = NULL; FFI_PLUGIN_EXPORT JniResult GrandParent__varParent(jobject self_, jobject nestedValue) { load_env(); - load_class_gr(&_c_GrandParent, - "com/github/dart_lang/jnigen/generics/GrandParent"); + load_class_global_ref(&_c_GrandParent, + "com/github/dart_lang/jnigen/generics/GrandParent"); if (_c_GrandParent == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_GrandParent, &_m_GrandParent__varParent, "varParent", "(Ljava/lang/Object;)Lcom/github/dart_lang/jnigen/generics/" "GrandParent$Parent;"); if (_m_GrandParent__varParent == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_GrandParent__varParent, nestedValue); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -504,18 +511,18 @@ jmethodID _m_GrandParent__stringStaticParent = NULL; FFI_PLUGIN_EXPORT JniResult GrandParent__stringStaticParent() { load_env(); - load_class_gr(&_c_GrandParent, - "com/github/dart_lang/jnigen/generics/GrandParent"); + load_class_global_ref(&_c_GrandParent, + "com/github/dart_lang/jnigen/generics/GrandParent"); if (_c_GrandParent == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method( _c_GrandParent, &_m_GrandParent__stringStaticParent, "stringStaticParent", "()Lcom/github/dart_lang/jnigen/generics/GrandParent$StaticParent;"); if (_m_GrandParent__stringStaticParent == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_GrandParent, _m_GrandParent__stringStaticParent); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -523,19 +530,19 @@ jmethodID _m_GrandParent__varStaticParent = NULL; FFI_PLUGIN_EXPORT JniResult GrandParent__varStaticParent(jobject value) { load_env(); - load_class_gr(&_c_GrandParent, - "com/github/dart_lang/jnigen/generics/GrandParent"); + load_class_global_ref(&_c_GrandParent, + "com/github/dart_lang/jnigen/generics/GrandParent"); if (_c_GrandParent == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method(_c_GrandParent, &_m_GrandParent__varStaticParent, "varStaticParent", "(Ljava/lang/Object;)Lcom/github/dart_lang/jnigen/" "generics/GrandParent$StaticParent;"); if (_m_GrandParent__varStaticParent == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_GrandParent, _m_GrandParent__varStaticParent, value); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -543,19 +550,19 @@ jmethodID _m_GrandParent__staticParentWithSameType = NULL; FFI_PLUGIN_EXPORT JniResult GrandParent__staticParentWithSameType(jobject self_) { load_env(); - load_class_gr(&_c_GrandParent, - "com/github/dart_lang/jnigen/generics/GrandParent"); + load_class_global_ref(&_c_GrandParent, + "com/github/dart_lang/jnigen/generics/GrandParent"); if (_c_GrandParent == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method( _c_GrandParent, &_m_GrandParent__staticParentWithSameType, "staticParentWithSameType", "()Lcom/github/dart_lang/jnigen/generics/GrandParent$StaticParent;"); if (_m_GrandParent__staticParentWithSameType == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_GrandParent__staticParentWithSameType); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -563,28 +570,28 @@ jfieldID _f_GrandParent__value = NULL; FFI_PLUGIN_EXPORT JniResult get_GrandParent__value(jobject self_) { load_env(); - load_class_gr(&_c_GrandParent, - "com/github/dart_lang/jnigen/generics/GrandParent"); + load_class_global_ref(&_c_GrandParent, + "com/github/dart_lang/jnigen/generics/GrandParent"); if (_c_GrandParent == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_GrandParent, &_f_GrandParent__value, "value", "Ljava/lang/Object;"); jobject _result = to_global_ref( (*jniEnv)->GetObjectField(jniEnv, self_, _f_GrandParent__value)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } FFI_PLUGIN_EXPORT JniResult set_GrandParent__value(jobject self_, jobject value) { load_env(); - load_class_gr(&_c_GrandParent, - "com/github/dart_lang/jnigen/generics/GrandParent"); + load_class_global_ref(&_c_GrandParent, + "com/github/dart_lang/jnigen/generics/GrandParent"); if (_c_GrandParent == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_GrandParent, &_f_GrandParent__value, "value", "Ljava/lang/Object;"); (*jniEnv)->SetObjectField(jniEnv, self_, _f_GrandParent__value, value); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } // com.github.dart_lang.jnigen.generics.GrandParent$Parent @@ -594,18 +601,19 @@ jmethodID _m_GrandParent_Parent__ctor = NULL; FFI_PLUGIN_EXPORT JniResult GrandParent_Parent__ctor(jobject parentValue, jobject value) { load_env(); - load_class_gr(&_c_GrandParent_Parent, - "com/github/dart_lang/jnigen/generics/GrandParent$Parent"); + load_class_global_ref( + &_c_GrandParent_Parent, + "com/github/dart_lang/jnigen/generics/GrandParent$Parent"); if (_c_GrandParent_Parent == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_GrandParent_Parent, &_m_GrandParent_Parent__ctor, "", "(Ljava/lang/Object;Ljava/lang/Object;)V"); if (_m_GrandParent_Parent__ctor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_GrandParent_Parent, _m_GrandParent_Parent__ctor, parentValue, value); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -613,57 +621,61 @@ jfieldID _f_GrandParent_Parent__parentValue = NULL; FFI_PLUGIN_EXPORT JniResult get_GrandParent_Parent__parentValue(jobject self_) { load_env(); - load_class_gr(&_c_GrandParent_Parent, - "com/github/dart_lang/jnigen/generics/GrandParent$Parent"); + load_class_global_ref( + &_c_GrandParent_Parent, + "com/github/dart_lang/jnigen/generics/GrandParent$Parent"); if (_c_GrandParent_Parent == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_GrandParent_Parent, &_f_GrandParent_Parent__parentValue, "parentValue", "Ljava/lang/Object;"); jobject _result = to_global_ref((*jniEnv)->GetObjectField( jniEnv, self_, _f_GrandParent_Parent__parentValue)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } FFI_PLUGIN_EXPORT JniResult set_GrandParent_Parent__parentValue(jobject self_, jobject value) { load_env(); - load_class_gr(&_c_GrandParent_Parent, - "com/github/dart_lang/jnigen/generics/GrandParent$Parent"); + load_class_global_ref( + &_c_GrandParent_Parent, + "com/github/dart_lang/jnigen/generics/GrandParent$Parent"); if (_c_GrandParent_Parent == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_GrandParent_Parent, &_f_GrandParent_Parent__parentValue, "parentValue", "Ljava/lang/Object;"); (*jniEnv)->SetObjectField(jniEnv, self_, _f_GrandParent_Parent__parentValue, value); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jfieldID _f_GrandParent_Parent__value = NULL; FFI_PLUGIN_EXPORT JniResult get_GrandParent_Parent__value(jobject self_) { load_env(); - load_class_gr(&_c_GrandParent_Parent, - "com/github/dart_lang/jnigen/generics/GrandParent$Parent"); + load_class_global_ref( + &_c_GrandParent_Parent, + "com/github/dart_lang/jnigen/generics/GrandParent$Parent"); if (_c_GrandParent_Parent == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_GrandParent_Parent, &_f_GrandParent_Parent__value, "value", "Ljava/lang/Object;"); jobject _result = to_global_ref( (*jniEnv)->GetObjectField(jniEnv, self_, _f_GrandParent_Parent__value)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } FFI_PLUGIN_EXPORT JniResult set_GrandParent_Parent__value(jobject self_, jobject value) { load_env(); - load_class_gr(&_c_GrandParent_Parent, - "com/github/dart_lang/jnigen/generics/GrandParent$Parent"); + load_class_global_ref( + &_c_GrandParent_Parent, + "com/github/dart_lang/jnigen/generics/GrandParent$Parent"); if (_c_GrandParent_Parent == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_GrandParent_Parent, &_f_GrandParent_Parent__value, "value", "Ljava/lang/Object;"); (*jniEnv)->SetObjectField(jniEnv, self_, _f_GrandParent_Parent__value, value); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } // com.github.dart_lang.jnigen.generics.GrandParent$Parent$Child @@ -675,20 +687,20 @@ JniResult GrandParent_Parent_Child__ctor(jobject grandParentValue, jobject parentValue, jobject value) { load_env(); - load_class_gr( + load_class_global_ref( &_c_GrandParent_Parent_Child, "com/github/dart_lang/jnigen/generics/GrandParent$Parent$Child"); if (_c_GrandParent_Parent_Child == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_GrandParent_Parent_Child, &_m_GrandParent_Parent_Child__ctor, "", "(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V"); if (_m_GrandParent_Parent_Child__ctor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_GrandParent_Parent_Child, _m_GrandParent_Parent_Child__ctor, grandParentValue, parentValue, value); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -696,99 +708,99 @@ jfieldID _f_GrandParent_Parent_Child__grandParentValue = NULL; FFI_PLUGIN_EXPORT JniResult get_GrandParent_Parent_Child__grandParentValue(jobject self_) { load_env(); - load_class_gr( + load_class_global_ref( &_c_GrandParent_Parent_Child, "com/github/dart_lang/jnigen/generics/GrandParent$Parent$Child"); if (_c_GrandParent_Parent_Child == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_GrandParent_Parent_Child, &_f_GrandParent_Parent_Child__grandParentValue, "grandParentValue", "Ljava/lang/Object;"); jobject _result = to_global_ref((*jniEnv)->GetObjectField( jniEnv, self_, _f_GrandParent_Parent_Child__grandParentValue)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } FFI_PLUGIN_EXPORT JniResult set_GrandParent_Parent_Child__grandParentValue(jobject self_, jobject value) { load_env(); - load_class_gr( + load_class_global_ref( &_c_GrandParent_Parent_Child, "com/github/dart_lang/jnigen/generics/GrandParent$Parent$Child"); if (_c_GrandParent_Parent_Child == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_GrandParent_Parent_Child, &_f_GrandParent_Parent_Child__grandParentValue, "grandParentValue", "Ljava/lang/Object;"); (*jniEnv)->SetObjectField( jniEnv, self_, _f_GrandParent_Parent_Child__grandParentValue, value); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jfieldID _f_GrandParent_Parent_Child__parentValue = NULL; FFI_PLUGIN_EXPORT JniResult get_GrandParent_Parent_Child__parentValue(jobject self_) { load_env(); - load_class_gr( + load_class_global_ref( &_c_GrandParent_Parent_Child, "com/github/dart_lang/jnigen/generics/GrandParent$Parent$Child"); if (_c_GrandParent_Parent_Child == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_GrandParent_Parent_Child, &_f_GrandParent_Parent_Child__parentValue, "parentValue", "Ljava/lang/Object;"); jobject _result = to_global_ref((*jniEnv)->GetObjectField( jniEnv, self_, _f_GrandParent_Parent_Child__parentValue)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } FFI_PLUGIN_EXPORT JniResult set_GrandParent_Parent_Child__parentValue(jobject self_, jobject value) { load_env(); - load_class_gr( + load_class_global_ref( &_c_GrandParent_Parent_Child, "com/github/dart_lang/jnigen/generics/GrandParent$Parent$Child"); if (_c_GrandParent_Parent_Child == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_GrandParent_Parent_Child, &_f_GrandParent_Parent_Child__parentValue, "parentValue", "Ljava/lang/Object;"); (*jniEnv)->SetObjectField(jniEnv, self_, _f_GrandParent_Parent_Child__parentValue, value); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jfieldID _f_GrandParent_Parent_Child__value = NULL; FFI_PLUGIN_EXPORT JniResult get_GrandParent_Parent_Child__value(jobject self_) { load_env(); - load_class_gr( + load_class_global_ref( &_c_GrandParent_Parent_Child, "com/github/dart_lang/jnigen/generics/GrandParent$Parent$Child"); if (_c_GrandParent_Parent_Child == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_GrandParent_Parent_Child, &_f_GrandParent_Parent_Child__value, "value", "Ljava/lang/Object;"); jobject _result = to_global_ref((*jniEnv)->GetObjectField( jniEnv, self_, _f_GrandParent_Parent_Child__value)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } FFI_PLUGIN_EXPORT JniResult set_GrandParent_Parent_Child__value(jobject self_, jobject value) { load_env(); - load_class_gr( + load_class_global_ref( &_c_GrandParent_Parent_Child, "com/github/dart_lang/jnigen/generics/GrandParent$Parent$Child"); if (_c_GrandParent_Parent_Child == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_GrandParent_Parent_Child, &_f_GrandParent_Parent_Child__value, "value", "Ljava/lang/Object;"); (*jniEnv)->SetObjectField(jniEnv, self_, _f_GrandParent_Parent_Child__value, value); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } // com.github.dart_lang.jnigen.generics.GrandParent$StaticParent @@ -798,19 +810,19 @@ jmethodID _m_GrandParent_StaticParent__ctor = NULL; FFI_PLUGIN_EXPORT JniResult GrandParent_StaticParent__ctor(jobject value) { load_env(); - load_class_gr( + load_class_global_ref( &_c_GrandParent_StaticParent, "com/github/dart_lang/jnigen/generics/GrandParent$StaticParent"); if (_c_GrandParent_StaticParent == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_GrandParent_StaticParent, &_m_GrandParent_StaticParent__ctor, "", "(Ljava/lang/Object;)V"); if (_m_GrandParent_StaticParent__ctor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_GrandParent_StaticParent, _m_GrandParent_StaticParent__ctor, value); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -818,31 +830,31 @@ jfieldID _f_GrandParent_StaticParent__value = NULL; FFI_PLUGIN_EXPORT JniResult get_GrandParent_StaticParent__value(jobject self_) { load_env(); - load_class_gr( + load_class_global_ref( &_c_GrandParent_StaticParent, "com/github/dart_lang/jnigen/generics/GrandParent$StaticParent"); if (_c_GrandParent_StaticParent == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_GrandParent_StaticParent, &_f_GrandParent_StaticParent__value, "value", "Ljava/lang/Object;"); jobject _result = to_global_ref((*jniEnv)->GetObjectField( jniEnv, self_, _f_GrandParent_StaticParent__value)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } FFI_PLUGIN_EXPORT JniResult set_GrandParent_StaticParent__value(jobject self_, jobject value) { load_env(); - load_class_gr( + load_class_global_ref( &_c_GrandParent_StaticParent, "com/github/dart_lang/jnigen/generics/GrandParent$StaticParent"); if (_c_GrandParent_StaticParent == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_GrandParent_StaticParent, &_f_GrandParent_StaticParent__value, "value", "Ljava/lang/Object;"); (*jniEnv)->SetObjectField(jniEnv, self_, _f_GrandParent_StaticParent__value, value); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } // com.github.dart_lang.jnigen.generics.GrandParent$StaticParent$Child @@ -853,20 +865,20 @@ FFI_PLUGIN_EXPORT JniResult GrandParent_StaticParent_Child__ctor(jobject parentValue, jobject value) { load_env(); - load_class_gr( + load_class_global_ref( &_c_GrandParent_StaticParent_Child, "com/github/dart_lang/jnigen/generics/GrandParent$StaticParent$Child"); if (_c_GrandParent_StaticParent_Child == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_GrandParent_StaticParent_Child, &_m_GrandParent_StaticParent_Child__ctor, "", "(Ljava/lang/Object;Ljava/lang/Object;)V"); if (_m_GrandParent_StaticParent_Child__ctor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject( jniEnv, _c_GrandParent_StaticParent_Child, _m_GrandParent_StaticParent_Child__ctor, parentValue, value); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -874,68 +886,68 @@ jfieldID _f_GrandParent_StaticParent_Child__parentValue = NULL; FFI_PLUGIN_EXPORT JniResult get_GrandParent_StaticParent_Child__parentValue(jobject self_) { load_env(); - load_class_gr( + load_class_global_ref( &_c_GrandParent_StaticParent_Child, "com/github/dart_lang/jnigen/generics/GrandParent$StaticParent$Child"); if (_c_GrandParent_StaticParent_Child == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_GrandParent_StaticParent_Child, &_f_GrandParent_StaticParent_Child__parentValue, "parentValue", "Ljava/lang/Object;"); jobject _result = to_global_ref((*jniEnv)->GetObjectField( jniEnv, self_, _f_GrandParent_StaticParent_Child__parentValue)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } FFI_PLUGIN_EXPORT JniResult set_GrandParent_StaticParent_Child__parentValue(jobject self_, jobject value) { load_env(); - load_class_gr( + load_class_global_ref( &_c_GrandParent_StaticParent_Child, "com/github/dart_lang/jnigen/generics/GrandParent$StaticParent$Child"); if (_c_GrandParent_StaticParent_Child == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_GrandParent_StaticParent_Child, &_f_GrandParent_StaticParent_Child__parentValue, "parentValue", "Ljava/lang/Object;"); (*jniEnv)->SetObjectField( jniEnv, self_, _f_GrandParent_StaticParent_Child__parentValue, value); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jfieldID _f_GrandParent_StaticParent_Child__value = NULL; FFI_PLUGIN_EXPORT JniResult get_GrandParent_StaticParent_Child__value(jobject self_) { load_env(); - load_class_gr( + load_class_global_ref( &_c_GrandParent_StaticParent_Child, "com/github/dart_lang/jnigen/generics/GrandParent$StaticParent$Child"); if (_c_GrandParent_StaticParent_Child == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_GrandParent_StaticParent_Child, &_f_GrandParent_StaticParent_Child__value, "value", "Ljava/lang/Object;"); jobject _result = to_global_ref((*jniEnv)->GetObjectField( jniEnv, self_, _f_GrandParent_StaticParent_Child__value)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } FFI_PLUGIN_EXPORT JniResult set_GrandParent_StaticParent_Child__value(jobject self_, jobject value) { load_env(); - load_class_gr( + load_class_global_ref( &_c_GrandParent_StaticParent_Child, "com/github/dart_lang/jnigen/generics/GrandParent$StaticParent$Child"); if (_c_GrandParent_StaticParent_Child == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_GrandParent_StaticParent_Child, &_f_GrandParent_StaticParent_Child__value, "value", "Ljava/lang/Object;"); (*jniEnv)->SetObjectField(jniEnv, self_, _f_GrandParent_StaticParent_Child__value, value); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } // com.github.dart_lang.jnigen.generics.MyMap @@ -945,14 +957,15 @@ jmethodID _m_MyMap__ctor = NULL; FFI_PLUGIN_EXPORT JniResult MyMap__ctor() { load_env(); - load_class_gr(&_c_MyMap, "com/github/dart_lang/jnigen/generics/MyMap"); + load_class_global_ref(&_c_MyMap, + "com/github/dart_lang/jnigen/generics/MyMap"); if (_c_MyMap == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_MyMap, &_m_MyMap__ctor, "", "()V"); if (_m_MyMap__ctor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_MyMap, _m_MyMap__ctor); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -960,16 +973,17 @@ jmethodID _m_MyMap__get0 = NULL; FFI_PLUGIN_EXPORT JniResult MyMap__get0(jobject self_, jobject key) { load_env(); - load_class_gr(&_c_MyMap, "com/github/dart_lang/jnigen/generics/MyMap"); + load_class_global_ref(&_c_MyMap, + "com/github/dart_lang/jnigen/generics/MyMap"); if (_c_MyMap == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_MyMap, &_m_MyMap__get0, "get", "(Ljava/lang/Object;)Ljava/lang/Object;"); if (_m_MyMap__get0 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_MyMap__get0, key); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -977,16 +991,17 @@ jmethodID _m_MyMap__put = NULL; FFI_PLUGIN_EXPORT JniResult MyMap__put(jobject self_, jobject key, jobject value) { load_env(); - load_class_gr(&_c_MyMap, "com/github/dart_lang/jnigen/generics/MyMap"); + load_class_global_ref(&_c_MyMap, + "com/github/dart_lang/jnigen/generics/MyMap"); if (_c_MyMap == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_MyMap, &_m_MyMap__put, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); if (_m_MyMap__put == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_MyMap__put, key, value); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -994,16 +1009,17 @@ jmethodID _m_MyMap__entryStack = NULL; FFI_PLUGIN_EXPORT JniResult MyMap__entryStack(jobject self_) { load_env(); - load_class_gr(&_c_MyMap, "com/github/dart_lang/jnigen/generics/MyMap"); + load_class_global_ref(&_c_MyMap, + "com/github/dart_lang/jnigen/generics/MyMap"); if (_c_MyMap == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_MyMap, &_m_MyMap__entryStack, "entryStack", "()Lcom/github/dart_lang/jnigen/generics/MyStack;"); if (_m_MyMap__entryStack == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_MyMap__entryStack); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1014,17 +1030,17 @@ jmethodID _m_MyMap_MyEntry__ctor = NULL; FFI_PLUGIN_EXPORT JniResult MyMap_MyEntry__ctor(jobject key, jobject value) { load_env(); - load_class_gr(&_c_MyMap_MyEntry, - "com/github/dart_lang/jnigen/generics/MyMap$MyEntry"); + load_class_global_ref(&_c_MyMap_MyEntry, + "com/github/dart_lang/jnigen/generics/MyMap$MyEntry"); if (_c_MyMap_MyEntry == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_MyMap_MyEntry, &_m_MyMap_MyEntry__ctor, "", "(Ljava/lang/Object;Ljava/lang/Object;)V"); if (_m_MyMap_MyEntry__ctor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_MyMap_MyEntry, _m_MyMap_MyEntry__ctor, key, value); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1032,56 +1048,56 @@ jfieldID _f_MyMap_MyEntry__key = NULL; FFI_PLUGIN_EXPORT JniResult get_MyMap_MyEntry__key(jobject self_) { load_env(); - load_class_gr(&_c_MyMap_MyEntry, - "com/github/dart_lang/jnigen/generics/MyMap$MyEntry"); + load_class_global_ref(&_c_MyMap_MyEntry, + "com/github/dart_lang/jnigen/generics/MyMap$MyEntry"); if (_c_MyMap_MyEntry == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_MyMap_MyEntry, &_f_MyMap_MyEntry__key, "key", "Ljava/lang/Object;"); jobject _result = to_global_ref( (*jniEnv)->GetObjectField(jniEnv, self_, _f_MyMap_MyEntry__key)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } FFI_PLUGIN_EXPORT JniResult set_MyMap_MyEntry__key(jobject self_, jobject value) { load_env(); - load_class_gr(&_c_MyMap_MyEntry, - "com/github/dart_lang/jnigen/generics/MyMap$MyEntry"); + load_class_global_ref(&_c_MyMap_MyEntry, + "com/github/dart_lang/jnigen/generics/MyMap$MyEntry"); if (_c_MyMap_MyEntry == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_MyMap_MyEntry, &_f_MyMap_MyEntry__key, "key", "Ljava/lang/Object;"); (*jniEnv)->SetObjectField(jniEnv, self_, _f_MyMap_MyEntry__key, value); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jfieldID _f_MyMap_MyEntry__value = NULL; FFI_PLUGIN_EXPORT JniResult get_MyMap_MyEntry__value(jobject self_) { load_env(); - load_class_gr(&_c_MyMap_MyEntry, - "com/github/dart_lang/jnigen/generics/MyMap$MyEntry"); + load_class_global_ref(&_c_MyMap_MyEntry, + "com/github/dart_lang/jnigen/generics/MyMap$MyEntry"); if (_c_MyMap_MyEntry == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_MyMap_MyEntry, &_f_MyMap_MyEntry__value, "value", "Ljava/lang/Object;"); jobject _result = to_global_ref( (*jniEnv)->GetObjectField(jniEnv, self_, _f_MyMap_MyEntry__value)); - return (JniResult){.result = {.l = _result}, .exception = check_exception()}; + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } FFI_PLUGIN_EXPORT JniResult set_MyMap_MyEntry__value(jobject self_, jobject value) { load_env(); - load_class_gr(&_c_MyMap_MyEntry, - "com/github/dart_lang/jnigen/generics/MyMap$MyEntry"); + load_class_global_ref(&_c_MyMap_MyEntry, + "com/github/dart_lang/jnigen/generics/MyMap$MyEntry"); if (_c_MyMap_MyEntry == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_MyMap_MyEntry, &_f_MyMap_MyEntry__value, "value", "Ljava/lang/Object;"); (*jniEnv)->SetObjectField(jniEnv, self_, _f_MyMap_MyEntry__value, value); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } // com.github.dart_lang.jnigen.generics.MyStack @@ -1091,14 +1107,15 @@ jmethodID _m_MyStack__ctor = NULL; FFI_PLUGIN_EXPORT JniResult MyStack__ctor() { load_env(); - load_class_gr(&_c_MyStack, "com/github/dart_lang/jnigen/generics/MyStack"); + load_class_global_ref(&_c_MyStack, + "com/github/dart_lang/jnigen/generics/MyStack"); if (_c_MyStack == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_MyStack, &_m_MyStack__ctor, "", "()V"); if (_m_MyStack__ctor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_MyStack, _m_MyStack__ctor); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1106,17 +1123,18 @@ jmethodID _m_MyStack__fromArray = NULL; FFI_PLUGIN_EXPORT JniResult MyStack__fromArray(jobject arr) { load_env(); - load_class_gr(&_c_MyStack, "com/github/dart_lang/jnigen/generics/MyStack"); + load_class_global_ref(&_c_MyStack, + "com/github/dart_lang/jnigen/generics/MyStack"); if (_c_MyStack == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method( _c_MyStack, &_m_MyStack__fromArray, "fromArray", "([Ljava/lang/Object;)Lcom/github/dart_lang/jnigen/generics/MyStack;"); if (_m_MyStack__fromArray == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_MyStack, _m_MyStack__fromArray, arr); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1124,19 +1142,20 @@ jmethodID _m_MyStack__fromArrayOfArrayOfGrandParents = NULL; FFI_PLUGIN_EXPORT JniResult MyStack__fromArrayOfArrayOfGrandParents(jobject arr) { load_env(); - load_class_gr(&_c_MyStack, "com/github/dart_lang/jnigen/generics/MyStack"); + load_class_global_ref(&_c_MyStack, + "com/github/dart_lang/jnigen/generics/MyStack"); if (_c_MyStack == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method( _c_MyStack, &_m_MyStack__fromArrayOfArrayOfGrandParents, "fromArrayOfArrayOfGrandParents", "([[Lcom/github/dart_lang/jnigen/generics/GrandParent;)Lcom/github/" "dart_lang/jnigen/generics/MyStack;"); if (_m_MyStack__fromArrayOfArrayOfGrandParents == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_MyStack, _m_MyStack__fromArrayOfArrayOfGrandParents, arr); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1144,16 +1163,17 @@ jmethodID _m_MyStack__of = NULL; FFI_PLUGIN_EXPORT JniResult MyStack__of() { load_env(); - load_class_gr(&_c_MyStack, "com/github/dart_lang/jnigen/generics/MyStack"); + load_class_global_ref(&_c_MyStack, + "com/github/dart_lang/jnigen/generics/MyStack"); if (_c_MyStack == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method(_c_MyStack, &_m_MyStack__of, "of", "()Lcom/github/dart_lang/jnigen/generics/MyStack;"); if (_m_MyStack__of == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_MyStack, _m_MyStack__of); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1161,17 +1181,18 @@ jmethodID _m_MyStack__of1 = NULL; FFI_PLUGIN_EXPORT JniResult MyStack__of1(jobject obj) { load_env(); - load_class_gr(&_c_MyStack, "com/github/dart_lang/jnigen/generics/MyStack"); + load_class_global_ref(&_c_MyStack, + "com/github/dart_lang/jnigen/generics/MyStack"); if (_c_MyStack == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method( _c_MyStack, &_m_MyStack__of1, "of", "(Ljava/lang/Object;)Lcom/github/dart_lang/jnigen/generics/MyStack;"); if (_m_MyStack__of1 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_MyStack, _m_MyStack__of1, obj); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1179,17 +1200,18 @@ jmethodID _m_MyStack__of2 = NULL; FFI_PLUGIN_EXPORT JniResult MyStack__of2(jobject obj, jobject obj2) { load_env(); - load_class_gr(&_c_MyStack, "com/github/dart_lang/jnigen/generics/MyStack"); + load_class_global_ref(&_c_MyStack, + "com/github/dart_lang/jnigen/generics/MyStack"); if (_c_MyStack == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method(_c_MyStack, &_m_MyStack__of2, "of", "(Ljava/lang/Object;Ljava/lang/Object;)Lcom/github/" "dart_lang/jnigen/generics/MyStack;"); if (_m_MyStack__of2 == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_MyStack, _m_MyStack__of2, obj, obj2); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1197,28 +1219,30 @@ jmethodID _m_MyStack__push = NULL; FFI_PLUGIN_EXPORT JniResult MyStack__push(jobject self_, jobject item) { load_env(); - load_class_gr(&_c_MyStack, "com/github/dart_lang/jnigen/generics/MyStack"); + load_class_global_ref(&_c_MyStack, + "com/github/dart_lang/jnigen/generics/MyStack"); if (_c_MyStack == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_MyStack, &_m_MyStack__push, "push", "(Ljava/lang/Object;)V"); if (_m_MyStack__push == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_MyStack__push, item); - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } jmethodID _m_MyStack__pop = NULL; FFI_PLUGIN_EXPORT JniResult MyStack__pop(jobject self_) { load_env(); - load_class_gr(&_c_MyStack, "com/github/dart_lang/jnigen/generics/MyStack"); + load_class_global_ref(&_c_MyStack, + "com/github/dart_lang/jnigen/generics/MyStack"); if (_c_MyStack == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_MyStack, &_m_MyStack__pop, "pop", "()Ljava/lang/Object;"); if (_m_MyStack__pop == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_MyStack__pop); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1226,14 +1250,15 @@ jmethodID _m_MyStack__size = NULL; FFI_PLUGIN_EXPORT JniResult MyStack__size(jobject self_) { load_env(); - load_class_gr(&_c_MyStack, "com/github/dart_lang/jnigen/generics/MyStack"); + load_class_global_ref(&_c_MyStack, + "com/github/dart_lang/jnigen/generics/MyStack"); if (_c_MyStack == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_MyStack, &_m_MyStack__size, "size", "()I"); if (_m_MyStack__size == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_MyStack__size); - return (JniResult){.result = {.i = _result}, .exception = check_exception()}; + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; } // com.github.dart_lang.jnigen.generics.StringKeyedMap @@ -1243,16 +1268,16 @@ jmethodID _m_StringKeyedMap__ctor = NULL; FFI_PLUGIN_EXPORT JniResult StringKeyedMap__ctor() { load_env(); - load_class_gr(&_c_StringKeyedMap, - "com/github/dart_lang/jnigen/generics/StringKeyedMap"); + load_class_global_ref(&_c_StringKeyedMap, + "com/github/dart_lang/jnigen/generics/StringKeyedMap"); if (_c_StringKeyedMap == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_StringKeyedMap, &_m_StringKeyedMap__ctor, "", "()V"); if (_m_StringKeyedMap__ctor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_StringKeyedMap, _m_StringKeyedMap__ctor); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1263,16 +1288,16 @@ jmethodID _m_StringMap__ctor = NULL; FFI_PLUGIN_EXPORT JniResult StringMap__ctor() { load_env(); - load_class_gr(&_c_StringMap, - "com/github/dart_lang/jnigen/generics/StringMap"); + load_class_global_ref(&_c_StringMap, + "com/github/dart_lang/jnigen/generics/StringMap"); if (_c_StringMap == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_StringMap, &_m_StringMap__ctor, "", "()V"); if (_m_StringMap__ctor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_StringMap, _m_StringMap__ctor); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1283,16 +1308,16 @@ jmethodID _m_StringStack__ctor = NULL; FFI_PLUGIN_EXPORT JniResult StringStack__ctor() { load_env(); - load_class_gr(&_c_StringStack, - "com/github/dart_lang/jnigen/generics/StringStack"); + load_class_global_ref(&_c_StringStack, + "com/github/dart_lang/jnigen/generics/StringStack"); if (_c_StringStack == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_StringStack, &_m_StringStack__ctor, "", "()V"); if (_m_StringStack__ctor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_StringStack, _m_StringStack__ctor); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1303,16 +1328,16 @@ jmethodID _m_StringValuedMap__ctor = NULL; FFI_PLUGIN_EXPORT JniResult StringValuedMap__ctor() { load_env(); - load_class_gr(&_c_StringValuedMap, - "com/github/dart_lang/jnigen/generics/StringValuedMap"); + load_class_global_ref(&_c_StringValuedMap, + "com/github/dart_lang/jnigen/generics/StringValuedMap"); if (_c_StringValuedMap == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_StringValuedMap, &_m_StringValuedMap__ctor, "", "()V"); if (_m_StringValuedMap__ctor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_StringValuedMap, _m_StringValuedMap__ctor); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1323,19 +1348,19 @@ jmethodID _m_JsonSerializable_Case__values = NULL; FFI_PLUGIN_EXPORT JniResult JsonSerializable_Case__values() { load_env(); - load_class_gr( + load_class_global_ref( &_c_JsonSerializable_Case, "com/github/dart_lang/jnigen/annotations/JsonSerializable$Case"); if (_c_JsonSerializable_Case == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method( _c_JsonSerializable_Case, &_m_JsonSerializable_Case__values, "values", "()[Lcom/github/dart_lang/jnigen/annotations/JsonSerializable$Case;"); if (_m_JsonSerializable_Case__values == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_JsonSerializable_Case, _m_JsonSerializable_Case__values); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1343,21 +1368,21 @@ jmethodID _m_JsonSerializable_Case__valueOf = NULL; FFI_PLUGIN_EXPORT JniResult JsonSerializable_Case__valueOf(jobject name) { load_env(); - load_class_gr( + load_class_global_ref( &_c_JsonSerializable_Case, "com/github/dart_lang/jnigen/annotations/JsonSerializable$Case"); if (_c_JsonSerializable_Case == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_method(_c_JsonSerializable_Case, &_m_JsonSerializable_Case__valueOf, "valueOf", "(Ljava/lang/String;)Lcom/github/dart_lang/jnigen/" "annotations/JsonSerializable$Case;"); if (_m_JsonSerializable_Case__valueOf == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_JsonSerializable_Case, _m_JsonSerializable_Case__valueOf, name); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } @@ -1368,15 +1393,15 @@ jmethodID _m_MyDataClass__ctor = NULL; FFI_PLUGIN_EXPORT JniResult MyDataClass__ctor() { load_env(); - load_class_gr(&_c_MyDataClass, - "com/github/dart_lang/jnigen/annotations/MyDataClass"); + load_class_global_ref(&_c_MyDataClass, + "com/github/dart_lang/jnigen/annotations/MyDataClass"); if (_c_MyDataClass == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_MyDataClass, &_m_MyDataClass__ctor, "", "()V"); if (_m_MyDataClass__ctor == NULL) - return (JniResult){.result = {.j = 0}, .exception = check_exception()}; + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_MyDataClass, _m_MyDataClass__ctor); - return (JniResult){.result = {.l = to_global_ref(_result)}, + return (JniResult){.value = {.l = to_global_ref(_result)}, .exception = check_exception()}; } diff --git a/pkgs/jnigen/test/test_util/test_util.dart b/pkgs/jnigen/test/test_util/test_util.dart index e48fd0a57..68707016f 100644 --- a/pkgs/jnigen/test/test_util/test_util.dart +++ b/pkgs/jnigen/test/test_util/test_util.dart @@ -9,7 +9,7 @@ import 'package:path/path.dart' hide equals; import 'package:test/test.dart'; import 'package:logging/logging.dart' show Level; -import 'package:jnigen/src/logging/logging.dart' show printError; +import 'package:jnigen/src/logging/logging.dart' show printError, log; final _currentDirectory = Directory("."); @@ -54,16 +54,22 @@ String readFile(File file) => file.readAsStringSync().replaceAll('\r\n', '\n'); /// Compares 2 hierarchies using `git diff --no-index`. void comparePaths(String path1, String path2) { - final proc = Process.runSync("git", [ + final diffCommand = [ "diff", "--no-index", if (stderr.supportsAnsiEscapes) "--color=always", - path1, - path2, - ]); - if (proc.exitCode != 0) { - stderr.writeln('\n${proc.stdout}'); - throw Exception("Files differ: ($path1, $path2)"); + ]; + final diffProc = Process.runSync("git", [...diffCommand, path1, path2]); + if (diffProc.exitCode != 0) { + final originalDiff = diffProc.stdout; + log.warning( + "Paths $path1 and $path2 differ, comparing by ignoring space change"); + final fallbackDiffProc = Process.runSync( + "git", [...diffCommand, '--ignore-space-change', path1, path2]); + if (fallbackDiffProc.exitCode != 0) { + stderr.writeln(originalDiff); + throw Exception("Paths $path1 and $path2 differ"); + } } } From 24f449b06f48fc25956c1decef9446a7b61fe803 Mon Sep 17 00:00:00 2001 From: Mahesh Hegde <46179734+mahesh-hegde@users.noreply.github.com> Date: Tue, 18 Apr 2023 22:48:26 +0530 Subject: [PATCH 077/139] [jnigen] Fix summary generation tests (https://github.com/dart-lang/jnigen/issues/253) --- pkgs/jnigen/test/summary_generation_test.dart | 41 +++++++++++++------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/pkgs/jnigen/test/summary_generation_test.dart b/pkgs/jnigen/test/summary_generation_test.dart index 6bf7457b8..8386db607 100644 --- a/pkgs/jnigen/test/summary_generation_test.dart +++ b/pkgs/jnigen/test/summary_generation_test.dart @@ -48,12 +48,17 @@ List findFiles(Directory dir, String suffix) { .toList(); } -Future createJar(List paths, String target) async { - final relativeTarget = relative(target, from: simplePackagePath); +/// Packs files indicated by [artifacts], each relative to [artifactDir] into +/// a JAR file at [jarPath]. +Future createJar({ + required String artifactDir, + required List artifacts, + required String jarPath, +}) async { final status = await runCommand( 'jar', - ['cf', relativeTarget, ...paths], - workingDirectory: simplePackagePath, + ['cf', relative(jarPath, from: artifactDir), ...artifacts], + workingDirectory: artifactDir, ); if (status != 0) { throw ArgumentError('Cannot create JAR from provided arguments'); @@ -112,18 +117,22 @@ void main() { final targetDir = tempDir.createTempSync("compiled_jar_test_"); await compileJavaFiles(javaFiles, targetDir); final classFiles = findFiles(targetDir, '.class'); - final jarFilePath = join(targetDir.absolute.path, 'classes.jar'); - await createJar(classFiles, jarFilePath); - final config = getConfig(classPath: [jarFilePath]); + final jarPath = join(targetDir.absolute.path, 'classes.jar'); + await createJar( + artifactDir: targetDir.path, artifacts: classFiles, jarPath: jarPath); + final config = getConfig(classPath: [jarPath]); final summaryClasses = await getSummary(config); expectNonEmptySummary(summaryClasses); }); test('Test summary generation from source JAR', () async { final targetDir = tempDir.createTempSync("source_jar_test_"); - final jarFilePath = join(targetDir.path, 'sources.jar'); - await createJar(javaFiles, jarFilePath); - final config = getConfig(sourcePath: [jarFilePath]); + final jarPath = join(targetDir.path, 'sources.jar'); + await createJar( + artifactDir: simplePackageDir.path, + artifacts: javaFiles, + jarPath: jarPath); + final config = getConfig(sourcePath: [jarPath]); final summaryClasses = await getSummary(config); expectNonEmptySummary(summaryClasses); }); @@ -150,12 +159,20 @@ void main() { final sourceFiles = javaFiles.toList(); sourceFiles.removeLast(); final sourceJarPath = join(targetDir.path, 'sources.jar'); - await createJar(sourceFiles, sourceJarPath); + await createJar( + artifactDir: simplePackageDir.path, + artifacts: sourceFiles, + jarPath: sourceJarPath, + ); await compileJavaFiles(javaFiles, targetDir); final classFiles = findFiles(targetDir, '.class'); final classesJarPath = join(targetDir.path, 'classes.jar'); - await createJar(classFiles, classesJarPath); + await createJar( + artifactDir: targetDir.path, + artifacts: classFiles, + jarPath: classesJarPath, + ); final config = getConfig( classPath: [classesJarPath], sourcePath: [sourceJarPath], From 80808dac23bb3174f31c4f1f82281da00ea32a09 Mon Sep 17 00:00:00 2001 From: Mahesh Hegde <46179734+mahesh-hegde@users.noreply.github.com> Date: Thu, 20 Apr 2023 17:08:48 +0530 Subject: [PATCH 078/139] [jnigen] Further FFI improvements (https://github.com/dart-lang/jnigen/issues/254) * Add DllMain lock initialization in windows * release lock on second init check * Use wrapper class instead of extensions. * Rename GlobalJniEnv in C to `GlobalJniEnvStruct`, and `JniAccessors` to `JniAccessorsStruct` * In dart, generate wrapper classes that store a pointer to above. * Then generate methods which are semantically equivalent to the extensions in previous iterations. * But internally, results of `asFunction` are cached to late field instead of being called again. (This is what ffigen does too). * Do not generate extensions for local env & javavm types * Remove -j * Add --test-randomize-ordering-seed random --- .github/workflows/test-package.yml | 10 +- pkgs/jni/lib/src/accessors.dart | 2 +- pkgs/jni/lib/src/jni.dart | 16 +- pkgs/jni/lib/src/jreference.dart | 3 +- .../third_party/global_env_extensions.dart | 1877 +++++++++-------- .../third_party/jni_bindings_generated.dart | 16 +- .../third_party/jnienv_javavm_extensions.dart | 1409 ------------- pkgs/jni/lib/src/types.dart | 4 +- pkgs/jni/src/dartjni.c | 38 +- pkgs/jni/src/dartjni.h | 6 +- pkgs/jni/src/third_party/global_jni_env.c | 4 +- pkgs/jni/src/third_party/global_jni_env.h | 6 +- .../generate_c_extensions.dart | 2 +- .../generate_dart_extensions.dart | 78 +- .../in_app_java/src/android_utils/dartjni.h | 6 +- .../example/kotlin_plugin/src/dartjni.h | 6 +- .../example/notification_plugin/src/dartjni.h | 6 +- .../pdfbox_plugin/src/third_party/dartjni.h | 6 +- pkgs/jnigen/test/kotlin_test/src/dartjni.h | 6 +- .../test/simple_package_test/src/dartjni.h | 6 +- 20 files changed, 1145 insertions(+), 2362 deletions(-) delete mode 100644 pkgs/jni/lib/src/third_party/jnienv_javavm_extensions.dart diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index f1afa9de0..a5bb09e67 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -169,7 +169,7 @@ jobs: - name: Get dependencies run: dart pub get - name: Run tests - run: dart test + run: dart test --test-randomize-ordering-seed random - name: Install coverage run: dart pub global activate coverage - name: Collect coverage @@ -209,9 +209,7 @@ jobs: - run: Add-Content $env:GITHUB_PATH "$env:JAVA_HOME\bin\server" - run: dart pub get - run: dart run jni:setup - ## TODO(#51): -j 1 is required to avoid a rare race condition which is caused by - ## all tests which spawn JVM being run in same process. - - run: dart test -j 1 + - run: dart test --test-randomize-ordering-seed random test_jnigen_windows_minimal: needs: [analyze_jnigen] @@ -266,9 +264,7 @@ jobs: java-version: '11' - run: dart pub get - run: dart run jni:setup - ## TODO(#51): -j 1 is required to avoid a rare race condition which is caused by - ## all tests which spawn JVM being run in same process. - - run: dart test -j 1 + - run: dart test --test-randomize-ordering-seed random test_jnigen_macos_minimal: needs: [analyze_jnigen] diff --git a/pkgs/jni/lib/src/accessors.dart b/pkgs/jni/lib/src/accessors.dart index 66045aec7..e2bee8905 100644 --- a/pkgs/jni/lib/src/accessors.dart +++ b/pkgs/jni/lib/src/accessors.dart @@ -100,7 +100,7 @@ extension JThrowableCheckMethod on JThrowablePtr { } } -extension JniAccessorWrappers on Pointer { +extension JniAccessorWrappers on JniAccessors { /// Rethrows Java exception in Dart as [JniException]. /// /// The original exception object is deleted by this method. The message diff --git a/pkgs/jni/lib/src/jni.dart b/pkgs/jni/lib/src/jni.dart index 8ad7fd4c3..277c2a5fe 100644 --- a/pkgs/jni/lib/src/jni.dart +++ b/pkgs/jni/lib/src/jni.dart @@ -156,9 +156,9 @@ abstract class Jni { return _bindings.GetJavaVM(); } - /// Returns the instance of [GlobalJniEnv], which is an abstraction over JNIEnv + /// Returns the instance of [GlobalJniEnvStruct], which is an abstraction over JNIEnv /// without the same-thread restriction. - static Pointer _fetchGlobalEnv() { + static Pointer _fetchGlobalEnv() { final env = _bindings.GetGlobalEnv(); if (env == nullptr) { throw NoJvmInstanceException(); @@ -166,17 +166,17 @@ abstract class Jni { return env; } - static Pointer? _env; + static GlobalJniEnv? _env; - /// Points to a process-wide shared instance of [GlobalJniEnv]. + /// Points to a process-wide shared instance of [GlobalJniEnvStruct]. /// /// It provides an indirection over [JniEnv] so that it can be used from /// any thread, and always returns global object references. - static Pointer get env { - return _env ??= _fetchGlobalEnv(); + static GlobalJniEnv get env { + return _env ??= GlobalJniEnv(_fetchGlobalEnv()); } - static Pointer get accessors => _bindings.GetAccessors(); + static JniAccessors get accessors => JniAccessors(_bindings.GetAccessors()); /// Returns a new PortContinuation. static JObjectPtr newPortContinuation(ReceivePort port) { @@ -288,7 +288,7 @@ extension ProtectedJniExtensions on Jni { } } -extension AdditionalEnvMethods on Pointer { +extension AdditionalEnvMethods on GlobalJniEnv { /// Convenience method for converting a [JStringPtr] /// to dart string. /// if [deleteOriginal] is specified, jstring passed will be deleted using diff --git a/pkgs/jni/lib/src/jreference.dart b/pkgs/jni/lib/src/jreference.dart index e71febfc1..3a96bb338 100644 --- a/pkgs/jni/lib/src/jreference.dart +++ b/pkgs/jni/lib/src/jreference.dart @@ -8,7 +8,8 @@ part of 'types.dart'; /// which disposes the reference(s). abstract class JReference implements Finalizable { //TODO(PR): Is it safe to cast void *f (void *) to void f (void *)? - static final _finalizer = NativeFinalizer(_env.ref.DeleteGlobalRef.cast()); + static final _finalizer = + NativeFinalizer(_env.ptr.ref.DeleteGlobalRef.cast()); JReference.fromRef(this.reference) { _finalizer.attach(this, reference, detach: this); diff --git a/pkgs/jni/lib/src/third_party/global_env_extensions.dart b/pkgs/jni/lib/src/third_party/global_env_extensions.dart index e561eef4b..2d2a02892 100644 --- a/pkgs/jni/lib/src/third_party/global_env_extensions.dart +++ b/pkgs/jni/lib/src/third_party/global_env_extensions.dart @@ -35,1357 +35,1480 @@ import "jni_bindings_generated.dart"; import "../accessors.dart"; -extension EnvExtension on ffi.Pointer { - int GetVersion() => - ref.GetVersion.asFunction()().integer; +/// Wraps over Pointer and exposes function pointer fields +/// as methods. +class GlobalJniEnv { + final ffi.Pointer ptr; + GlobalJniEnv(this.ptr); + late final _GetVersion = + ptr.ref.GetVersion.asFunction(); + + int GetVersion() => _GetVersion().integer; + + late final _DefineClass = ptr.ref.DefineClass.asFunction< + JniClassLookupResult Function(ffi.Pointer name, + JObjectPtr loader, ffi.Pointer buf, int bufLen)>(); JClassPtr DefineClass(ffi.Pointer name, JObjectPtr loader, ffi.Pointer buf, int bufLen) => - ref.DefineClass.asFunction< - JniClassLookupResult Function( - ffi.Pointer name, - JObjectPtr loader, - ffi.Pointer buf, - int bufLen)>()(name, loader, buf, bufLen) - .value; - - JClassPtr FindClass(ffi.Pointer name) => ref.FindClass.asFunction< - JniClassLookupResult Function(ffi.Pointer name)>()(name) - .value; - - JMethodIDPtr FromReflectedMethod(JObjectPtr method) => ref.FromReflectedMethod - .asFunction()(method) - .methodID; - - JFieldIDPtr FromReflectedField(JObjectPtr field) => ref.FromReflectedField - .asFunction()(field) - .fieldID; + _DefineClass(name, loader, buf, bufLen).value; + + late final _FindClass = ptr.ref.FindClass + .asFunction name)>(); + + JClassPtr FindClass(ffi.Pointer name) => _FindClass(name).value; + + late final _FromReflectedMethod = ptr.ref.FromReflectedMethod + .asFunction(); + + JMethodIDPtr FromReflectedMethod(JObjectPtr method) => + _FromReflectedMethod(method).methodID; + + late final _FromReflectedField = ptr.ref.FromReflectedField + .asFunction(); + + JFieldIDPtr FromReflectedField(JObjectPtr field) => + _FromReflectedField(field).fieldID; + + late final _ToReflectedMethod = ptr.ref.ToReflectedMethod.asFunction< + JniResult Function(JClassPtr cls, JMethodIDPtr methodId, int isStatic)>(); JObjectPtr ToReflectedMethod( JClassPtr cls, JMethodIDPtr methodId, int isStatic) => - ref.ToReflectedMethod.asFunction< - JniResult Function(JClassPtr cls, JMethodIDPtr methodId, - int isStatic)>()(cls, methodId, isStatic) - .object; + _ToReflectedMethod(cls, methodId, isStatic).object; + + late final _GetSuperclass = ptr.ref.GetSuperclass + .asFunction(); - JClassPtr GetSuperclass(JClassPtr clazz) => ref.GetSuperclass.asFunction< - JniClassLookupResult Function(JClassPtr clazz)>()(clazz) - .value; + JClassPtr GetSuperclass(JClassPtr clazz) => _GetSuperclass(clazz).value; + + late final _IsAssignableFrom = ptr.ref.IsAssignableFrom + .asFunction(); bool IsAssignableFrom(JClassPtr clazz1, JClassPtr clazz2) => - ref.IsAssignableFrom.asFunction< - JniResult Function( - JClassPtr clazz1, JClassPtr clazz2)>()(clazz1, clazz2) - .boolean; + _IsAssignableFrom(clazz1, clazz2).boolean; + + late final _ToReflectedField = ptr.ref.ToReflectedField.asFunction< + JniResult Function(JClassPtr cls, JFieldIDPtr fieldID, int isStatic)>(); JObjectPtr ToReflectedField( JClassPtr cls, JFieldIDPtr fieldID, int isStatic) => - ref.ToReflectedField.asFunction< - JniResult Function(JClassPtr cls, JFieldIDPtr fieldID, - int isStatic)>()(cls, fieldID, isStatic) - .object; + _ToReflectedField(cls, fieldID, isStatic).object; - int Throw(JThrowablePtr obj) => - ref.Throw.asFunction()(obj) - .integer; + late final _Throw = + ptr.ref.Throw.asFunction(); + + int Throw(JThrowablePtr obj) => _Throw(obj).integer; + + late final _ThrowNew = ptr.ref.ThrowNew.asFunction< + JniResult Function(JClassPtr clazz, ffi.Pointer message)>(); int ThrowNew(JClassPtr clazz, ffi.Pointer message) => - ref.ThrowNew.asFunction< - JniResult Function(JClassPtr clazz, - ffi.Pointer message)>()(clazz, message) - .integer; + _ThrowNew(clazz, message).integer; + + late final _ExceptionOccurred = + ptr.ref.ExceptionOccurred.asFunction(); - JThrowablePtr ExceptionOccurred() => - ref.ExceptionOccurred.asFunction()().object; + JThrowablePtr ExceptionOccurred() => _ExceptionOccurred().object; - void ExceptionDescribe() => - ref.ExceptionDescribe.asFunction()().check(); + late final _ExceptionDescribe = + ptr.ref.ExceptionDescribe.asFunction(); - void ExceptionClear() => - ref.ExceptionClear.asFunction()().check(); + void ExceptionDescribe() => _ExceptionDescribe().check(); - void FatalError(ffi.Pointer msg) => ref.FatalError.asFunction< - JThrowablePtr Function(ffi.Pointer msg)>()(msg) - .check(); + late final _ExceptionClear = + ptr.ref.ExceptionClear.asFunction(); - int PushLocalFrame(int capacity) => - ref.PushLocalFrame.asFunction()( - capacity) - .integer; + void ExceptionClear() => _ExceptionClear().check(); - JObjectPtr PopLocalFrame(JObjectPtr result) => - ref.PopLocalFrame.asFunction()( - result) - .object; + late final _FatalError = ptr.ref.FatalError + .asFunction msg)>(); - JObjectPtr NewGlobalRef(JObjectPtr obj) => - ref.NewGlobalRef.asFunction()(obj) - .object; + void FatalError(ffi.Pointer msg) => _FatalError(msg).check(); - void DeleteGlobalRef(JObjectPtr globalRef) => ref.DeleteGlobalRef.asFunction< - JThrowablePtr Function(JObjectPtr globalRef)>()(globalRef) - .check(); + late final _PushLocalFrame = + ptr.ref.PushLocalFrame.asFunction(); - void DeleteLocalRef(JObjectPtr localRef) => ref.DeleteLocalRef.asFunction< - JThrowablePtr Function(JObjectPtr localRef)>()(localRef) - .check(); + int PushLocalFrame(int capacity) => _PushLocalFrame(capacity).integer; + + late final _PopLocalFrame = + ptr.ref.PopLocalFrame.asFunction(); + + JObjectPtr PopLocalFrame(JObjectPtr result) => _PopLocalFrame(result).object; + + late final _NewGlobalRef = + ptr.ref.NewGlobalRef.asFunction(); + + JObjectPtr NewGlobalRef(JObjectPtr obj) => _NewGlobalRef(obj).object; + + late final _DeleteGlobalRef = ptr.ref.DeleteGlobalRef + .asFunction(); + + void DeleteGlobalRef(JObjectPtr globalRef) => + _DeleteGlobalRef(globalRef).check(); + + late final _DeleteLocalRef = ptr.ref.DeleteLocalRef + .asFunction(); + + void DeleteLocalRef(JObjectPtr localRef) => _DeleteLocalRef(localRef).check(); + + late final _IsSameObject = ptr.ref.IsSameObject + .asFunction(); bool IsSameObject(JObjectPtr ref1, JObjectPtr ref2) => - ref.IsSameObject.asFunction< - JniResult Function( - JObjectPtr ref1, JObjectPtr ref2)>()(ref1, ref2) - .boolean; + _IsSameObject(ref1, ref2).boolean; + + late final _NewLocalRef = + ptr.ref.NewLocalRef.asFunction(); + + JObjectPtr NewLocalRef(JObjectPtr obj) => _NewLocalRef(obj).object; - JObjectPtr NewLocalRef(JObjectPtr obj) => - ref.NewLocalRef.asFunction()(obj) - .object; + late final _EnsureLocalCapacity = ptr.ref.EnsureLocalCapacity + .asFunction(); int EnsureLocalCapacity(int capacity) => - ref.EnsureLocalCapacity.asFunction()( - capacity) - .integer; + _EnsureLocalCapacity(capacity).integer; - JObjectPtr AllocObject(JClassPtr clazz) => - ref.AllocObject.asFunction()(clazz) - .object; + late final _AllocObject = + ptr.ref.AllocObject.asFunction(); + + JObjectPtr AllocObject(JClassPtr clazz) => _AllocObject(clazz).object; + + late final _NewObject = ptr.ref.NewObject + .asFunction(); JObjectPtr NewObject(JClassPtr clazz, JMethodIDPtr methodID) => - ref.NewObject.asFunction< - JniResult Function( - JClassPtr clazz, JMethodIDPtr methodID)>()(clazz, methodID) - .object; + _NewObject(clazz, methodID).object; + + late final _NewObjectA = ptr.ref.NewObjectA.asFunction< + JniResult Function( + JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args)>(); JObjectPtr NewObjectA( JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => - ref.NewObjectA.asFunction< - JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, - ffi.Pointer args)>()(clazz, methodID, args) - .object; + _NewObjectA(clazz, methodID, args).object; - JClassPtr GetObjectClass(JObjectPtr obj) => ref.GetObjectClass.asFunction< - JniClassLookupResult Function(JObjectPtr obj)>()(obj) - .value; + late final _GetObjectClass = ptr.ref.GetObjectClass + .asFunction(); + + JClassPtr GetObjectClass(JObjectPtr obj) => _GetObjectClass(obj).value; + + late final _IsInstanceOf = ptr.ref.IsInstanceOf + .asFunction(); bool IsInstanceOf(JObjectPtr obj, JClassPtr clazz) => - ref.IsInstanceOf.asFunction< - JniResult Function(JObjectPtr obj, JClassPtr clazz)>()(obj, clazz) - .boolean; + _IsInstanceOf(obj, clazz).boolean; + + late final _GetMethodID = ptr.ref.GetMethodID.asFunction< + JniPointerResult Function(JClassPtr clazz, ffi.Pointer name, + ffi.Pointer sig)>(); JMethodIDPtr GetMethodID(JClassPtr clazz, ffi.Pointer name, ffi.Pointer sig) => - ref.GetMethodID.asFunction< - JniPointerResult Function( - JClassPtr clazz, - ffi.Pointer name, - ffi.Pointer sig)>()(clazz, name, sig) - .methodID; + _GetMethodID(clazz, name, sig).methodID; + + late final _CallObjectMethod = ptr.ref.CallObjectMethod + .asFunction(); JObjectPtr CallObjectMethod(JObjectPtr obj, JMethodIDPtr methodID) => - ref.CallObjectMethod.asFunction< - JniResult Function( - JObjectPtr obj, JMethodIDPtr methodID)>()(obj, methodID) - .object; + _CallObjectMethod(obj, methodID).object; + + late final _CallObjectMethodA = ptr.ref.CallObjectMethodA.asFunction< + JniResult Function( + JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args)>(); JObjectPtr CallObjectMethodA( JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) => - ref.CallObjectMethodA.asFunction< - JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, - ffi.Pointer args)>()(obj, methodID, args) - .object; + _CallObjectMethodA(obj, methodID, args).object; + + late final _CallBooleanMethod = ptr.ref.CallBooleanMethod + .asFunction(); bool CallBooleanMethod(JObjectPtr obj, JMethodIDPtr methodID) => - ref.CallBooleanMethod.asFunction< - JniResult Function( - JObjectPtr obj, JMethodIDPtr methodID)>()(obj, methodID) - .boolean; + _CallBooleanMethod(obj, methodID).boolean; + + late final _CallBooleanMethodA = ptr.ref.CallBooleanMethodA.asFunction< + JniResult Function( + JObjectPtr obj, JMethodIDPtr methodId, ffi.Pointer args)>(); bool CallBooleanMethodA( JObjectPtr obj, JMethodIDPtr methodId, ffi.Pointer args) => - ref.CallBooleanMethodA.asFunction< - JniResult Function(JObjectPtr obj, JMethodIDPtr methodId, - ffi.Pointer args)>()(obj, methodId, args) - .boolean; + _CallBooleanMethodA(obj, methodId, args).boolean; + + late final _CallByteMethod = ptr.ref.CallByteMethod + .asFunction(); int CallByteMethod(JObjectPtr obj, JMethodIDPtr methodID) => - ref.CallByteMethod.asFunction< - JniResult Function( - JObjectPtr obj, JMethodIDPtr methodID)>()(obj, methodID) - .byte; + _CallByteMethod(obj, methodID).byte; + + late final _CallByteMethodA = ptr.ref.CallByteMethodA.asFunction< + JniResult Function( + JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args)>(); int CallByteMethodA( JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) => - ref.CallByteMethodA.asFunction< - JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, - ffi.Pointer args)>()(obj, methodID, args) - .byte; + _CallByteMethodA(obj, methodID, args).byte; + + late final _CallCharMethod = ptr.ref.CallCharMethod + .asFunction(); int CallCharMethod(JObjectPtr obj, JMethodIDPtr methodID) => - ref.CallCharMethod.asFunction< - JniResult Function( - JObjectPtr obj, JMethodIDPtr methodID)>()(obj, methodID) - .char; + _CallCharMethod(obj, methodID).char; + + late final _CallCharMethodA = ptr.ref.CallCharMethodA.asFunction< + JniResult Function( + JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args)>(); int CallCharMethodA( JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) => - ref.CallCharMethodA.asFunction< - JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, - ffi.Pointer args)>()(obj, methodID, args) - .char; + _CallCharMethodA(obj, methodID, args).char; + + late final _CallShortMethod = ptr.ref.CallShortMethod + .asFunction(); int CallShortMethod(JObjectPtr obj, JMethodIDPtr methodID) => - ref.CallShortMethod.asFunction< - JniResult Function( - JObjectPtr obj, JMethodIDPtr methodID)>()(obj, methodID) - .short; + _CallShortMethod(obj, methodID).short; + + late final _CallShortMethodA = ptr.ref.CallShortMethodA.asFunction< + JniResult Function( + JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args)>(); int CallShortMethodA( JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) => - ref.CallShortMethodA.asFunction< - JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, - ffi.Pointer args)>()(obj, methodID, args) - .short; + _CallShortMethodA(obj, methodID, args).short; + + late final _CallIntMethod = ptr.ref.CallIntMethod + .asFunction(); int CallIntMethod(JObjectPtr obj, JMethodIDPtr methodID) => - ref.CallIntMethod.asFunction< - JniResult Function( - JObjectPtr obj, JMethodIDPtr methodID)>()(obj, methodID) - .integer; + _CallIntMethod(obj, methodID).integer; + + late final _CallIntMethodA = ptr.ref.CallIntMethodA.asFunction< + JniResult Function( + JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args)>(); int CallIntMethodA( JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) => - ref.CallIntMethodA.asFunction< - JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, - ffi.Pointer args)>()(obj, methodID, args) - .integer; + _CallIntMethodA(obj, methodID, args).integer; + + late final _CallLongMethod = ptr.ref.CallLongMethod + .asFunction(); int CallLongMethod(JObjectPtr obj, JMethodIDPtr methodID) => - ref.CallLongMethod.asFunction< - JniResult Function( - JObjectPtr obj, JMethodIDPtr methodID)>()(obj, methodID) - .long; + _CallLongMethod(obj, methodID).long; + + late final _CallLongMethodA = ptr.ref.CallLongMethodA.asFunction< + JniResult Function( + JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args)>(); int CallLongMethodA( JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) => - ref.CallLongMethodA.asFunction< - JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, - ffi.Pointer args)>()(obj, methodID, args) - .long; + _CallLongMethodA(obj, methodID, args).long; + + late final _CallFloatMethod = ptr.ref.CallFloatMethod + .asFunction(); double CallFloatMethod(JObjectPtr obj, JMethodIDPtr methodID) => - ref.CallFloatMethod.asFunction< - JniResult Function( - JObjectPtr obj, JMethodIDPtr methodID)>()(obj, methodID) - .float; + _CallFloatMethod(obj, methodID).float; + + late final _CallFloatMethodA = ptr.ref.CallFloatMethodA.asFunction< + JniResult Function( + JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args)>(); double CallFloatMethodA( JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) => - ref.CallFloatMethodA.asFunction< - JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, - ffi.Pointer args)>()(obj, methodID, args) - .float; + _CallFloatMethodA(obj, methodID, args).float; + + late final _CallDoubleMethod = ptr.ref.CallDoubleMethod + .asFunction(); double CallDoubleMethod(JObjectPtr obj, JMethodIDPtr methodID) => - ref.CallDoubleMethod.asFunction< - JniResult Function( - JObjectPtr obj, JMethodIDPtr methodID)>()(obj, methodID) - .doubleFloat; + _CallDoubleMethod(obj, methodID).doubleFloat; + + late final _CallDoubleMethodA = ptr.ref.CallDoubleMethodA.asFunction< + JniResult Function( + JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args)>(); double CallDoubleMethodA( JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) => - ref.CallDoubleMethodA.asFunction< - JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, - ffi.Pointer args)>()(obj, methodID, args) - .doubleFloat; + _CallDoubleMethodA(obj, methodID, args).doubleFloat; + + late final _CallVoidMethod = ptr.ref.CallVoidMethod.asFunction< + JThrowablePtr Function(JObjectPtr obj, JMethodIDPtr methodID)>(); void CallVoidMethod(JObjectPtr obj, JMethodIDPtr methodID) => - ref.CallVoidMethod.asFunction< - JThrowablePtr Function( - JObjectPtr obj, JMethodIDPtr methodID)>()(obj, methodID) - .check(); + _CallVoidMethod(obj, methodID).check(); + + late final _CallVoidMethodA = ptr.ref.CallVoidMethodA.asFunction< + JThrowablePtr Function( + JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args)>(); void CallVoidMethodA( JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) => - ref.CallVoidMethodA.asFunction< - JThrowablePtr Function(JObjectPtr obj, JMethodIDPtr methodID, - ffi.Pointer args)>()(obj, methodID, args) - .check(); + _CallVoidMethodA(obj, methodID, args).check(); + + late final _CallNonvirtualObjectMethod = ptr.ref.CallNonvirtualObjectMethod + .asFunction< + JniResult Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>(); JObjectPtr CallNonvirtualObjectMethod( JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => - ref.CallNonvirtualObjectMethod.asFunction< - JniResult Function(JObjectPtr obj, JClassPtr clazz, - JMethodIDPtr methodID)>()(obj, clazz, methodID) - .object; + _CallNonvirtualObjectMethod(obj, clazz, methodID).object; + + late final _CallNonvirtualObjectMethodA = ptr.ref.CallNonvirtualObjectMethodA + .asFunction< + JniResult Function(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args)>(); JObjectPtr CallNonvirtualObjectMethodA(JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => - ref.CallNonvirtualObjectMethodA.asFunction< - JniResult Function( - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>()(obj, clazz, methodID, args) - .object; + _CallNonvirtualObjectMethodA(obj, clazz, methodID, args).object; + + late final _CallNonvirtualBooleanMethod = ptr.ref.CallNonvirtualBooleanMethod + .asFunction< + JniResult Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>(); bool CallNonvirtualBooleanMethod( JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => - ref.CallNonvirtualBooleanMethod.asFunction< - JniResult Function(JObjectPtr obj, JClassPtr clazz, - JMethodIDPtr methodID)>()(obj, clazz, methodID) - .boolean; + _CallNonvirtualBooleanMethod(obj, clazz, methodID).boolean; + + late final _CallNonvirtualBooleanMethodA = + ptr.ref.CallNonvirtualBooleanMethodA.asFunction< + JniResult Function(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args)>(); bool CallNonvirtualBooleanMethodA(JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => - ref.CallNonvirtualBooleanMethodA.asFunction< - JniResult Function( - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>()(obj, clazz, methodID, args) - .boolean; + _CallNonvirtualBooleanMethodA(obj, clazz, methodID, args).boolean; + + late final _CallNonvirtualByteMethod = ptr.ref.CallNonvirtualByteMethod + .asFunction< + JniResult Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>(); int CallNonvirtualByteMethod( JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => - ref.CallNonvirtualByteMethod.asFunction< - JniResult Function(JObjectPtr obj, JClassPtr clazz, - JMethodIDPtr methodID)>()(obj, clazz, methodID) - .byte; + _CallNonvirtualByteMethod(obj, clazz, methodID).byte; + + late final _CallNonvirtualByteMethodA = ptr.ref.CallNonvirtualByteMethodA + .asFunction< + JniResult Function(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args)>(); int CallNonvirtualByteMethodA(JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => - ref.CallNonvirtualByteMethodA.asFunction< - JniResult Function( - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>()(obj, clazz, methodID, args) - .byte; + _CallNonvirtualByteMethodA(obj, clazz, methodID, args).byte; + + late final _CallNonvirtualCharMethod = ptr.ref.CallNonvirtualCharMethod + .asFunction< + JniResult Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>(); int CallNonvirtualCharMethod( JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => - ref.CallNonvirtualCharMethod.asFunction< - JniResult Function(JObjectPtr obj, JClassPtr clazz, - JMethodIDPtr methodID)>()(obj, clazz, methodID) - .char; + _CallNonvirtualCharMethod(obj, clazz, methodID).char; + + late final _CallNonvirtualCharMethodA = ptr.ref.CallNonvirtualCharMethodA + .asFunction< + JniResult Function(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args)>(); int CallNonvirtualCharMethodA(JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => - ref.CallNonvirtualCharMethodA.asFunction< - JniResult Function( - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>()(obj, clazz, methodID, args) - .char; + _CallNonvirtualCharMethodA(obj, clazz, methodID, args).char; + + late final _CallNonvirtualShortMethod = ptr.ref.CallNonvirtualShortMethod + .asFunction< + JniResult Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>(); int CallNonvirtualShortMethod( JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => - ref.CallNonvirtualShortMethod.asFunction< - JniResult Function(JObjectPtr obj, JClassPtr clazz, - JMethodIDPtr methodID)>()(obj, clazz, methodID) - .short; + _CallNonvirtualShortMethod(obj, clazz, methodID).short; + + late final _CallNonvirtualShortMethodA = ptr.ref.CallNonvirtualShortMethodA + .asFunction< + JniResult Function(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args)>(); int CallNonvirtualShortMethodA(JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => - ref.CallNonvirtualShortMethodA.asFunction< - JniResult Function( - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>()(obj, clazz, methodID, args) - .short; + _CallNonvirtualShortMethodA(obj, clazz, methodID, args).short; + + late final _CallNonvirtualIntMethod = ptr.ref.CallNonvirtualIntMethod + .asFunction< + JniResult Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>(); int CallNonvirtualIntMethod( JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => - ref.CallNonvirtualIntMethod.asFunction< - JniResult Function(JObjectPtr obj, JClassPtr clazz, - JMethodIDPtr methodID)>()(obj, clazz, methodID) - .integer; + _CallNonvirtualIntMethod(obj, clazz, methodID).integer; + + late final _CallNonvirtualIntMethodA = ptr.ref.CallNonvirtualIntMethodA + .asFunction< + JniResult Function(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args)>(); int CallNonvirtualIntMethodA(JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => - ref.CallNonvirtualIntMethodA.asFunction< - JniResult Function( - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>()(obj, clazz, methodID, args) - .integer; + _CallNonvirtualIntMethodA(obj, clazz, methodID, args).integer; + + late final _CallNonvirtualLongMethod = ptr.ref.CallNonvirtualLongMethod + .asFunction< + JniResult Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>(); int CallNonvirtualLongMethod( JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => - ref.CallNonvirtualLongMethod.asFunction< - JniResult Function(JObjectPtr obj, JClassPtr clazz, - JMethodIDPtr methodID)>()(obj, clazz, methodID) - .long; + _CallNonvirtualLongMethod(obj, clazz, methodID).long; + + late final _CallNonvirtualLongMethodA = ptr.ref.CallNonvirtualLongMethodA + .asFunction< + JniResult Function(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args)>(); int CallNonvirtualLongMethodA(JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => - ref.CallNonvirtualLongMethodA.asFunction< - JniResult Function( - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>()(obj, clazz, methodID, args) - .long; + _CallNonvirtualLongMethodA(obj, clazz, methodID, args).long; + + late final _CallNonvirtualFloatMethod = ptr.ref.CallNonvirtualFloatMethod + .asFunction< + JniResult Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>(); double CallNonvirtualFloatMethod( JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => - ref.CallNonvirtualFloatMethod.asFunction< - JniResult Function(JObjectPtr obj, JClassPtr clazz, - JMethodIDPtr methodID)>()(obj, clazz, methodID) - .float; + _CallNonvirtualFloatMethod(obj, clazz, methodID).float; + + late final _CallNonvirtualFloatMethodA = ptr.ref.CallNonvirtualFloatMethodA + .asFunction< + JniResult Function(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args)>(); double CallNonvirtualFloatMethodA(JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => - ref.CallNonvirtualFloatMethodA.asFunction< - JniResult Function( - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>()(obj, clazz, methodID, args) - .float; + _CallNonvirtualFloatMethodA(obj, clazz, methodID, args).float; + + late final _CallNonvirtualDoubleMethod = ptr.ref.CallNonvirtualDoubleMethod + .asFunction< + JniResult Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>(); double CallNonvirtualDoubleMethod( JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => - ref.CallNonvirtualDoubleMethod.asFunction< - JniResult Function(JObjectPtr obj, JClassPtr clazz, - JMethodIDPtr methodID)>()(obj, clazz, methodID) - .doubleFloat; + _CallNonvirtualDoubleMethod(obj, clazz, methodID).doubleFloat; + + late final _CallNonvirtualDoubleMethodA = ptr.ref.CallNonvirtualDoubleMethodA + .asFunction< + JniResult Function(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args)>(); double CallNonvirtualDoubleMethodA(JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => - ref.CallNonvirtualDoubleMethodA.asFunction< - JniResult Function( - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>()(obj, clazz, methodID, args) - .doubleFloat; + _CallNonvirtualDoubleMethodA(obj, clazz, methodID, args).doubleFloat; + + late final _CallNonvirtualVoidMethod = ptr.ref.CallNonvirtualVoidMethod + .asFunction< + JThrowablePtr Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>(); void CallNonvirtualVoidMethod( JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => - ref.CallNonvirtualVoidMethod.asFunction< - JThrowablePtr Function(JObjectPtr obj, JClassPtr clazz, - JMethodIDPtr methodID)>()(obj, clazz, methodID) - .check(); + _CallNonvirtualVoidMethod(obj, clazz, methodID).check(); + + late final _CallNonvirtualVoidMethodA = ptr.ref.CallNonvirtualVoidMethodA + .asFunction< + JThrowablePtr Function(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args)>(); void CallNonvirtualVoidMethodA(JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => - ref.CallNonvirtualVoidMethodA.asFunction< - JThrowablePtr Function( - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>()(obj, clazz, methodID, args) - .check(); + _CallNonvirtualVoidMethodA(obj, clazz, methodID, args).check(); + + late final _GetFieldID = ptr.ref.GetFieldID.asFunction< + JniPointerResult Function(JClassPtr clazz, ffi.Pointer name, + ffi.Pointer sig)>(); JFieldIDPtr GetFieldID(JClassPtr clazz, ffi.Pointer name, ffi.Pointer sig) => - ref.GetFieldID.asFunction< - JniPointerResult Function( - JClassPtr clazz, - ffi.Pointer name, - ffi.Pointer sig)>()(clazz, name, sig) - .fieldID; + _GetFieldID(clazz, name, sig).fieldID; + + late final _GetObjectField = ptr.ref.GetObjectField + .asFunction(); JObjectPtr GetObjectField(JObjectPtr obj, JFieldIDPtr fieldID) => - ref.GetObjectField.asFunction< - JniResult Function( - JObjectPtr obj, JFieldIDPtr fieldID)>()(obj, fieldID) - .object; + _GetObjectField(obj, fieldID).object; + + late final _GetBooleanField = ptr.ref.GetBooleanField + .asFunction(); bool GetBooleanField(JObjectPtr obj, JFieldIDPtr fieldID) => - ref.GetBooleanField.asFunction< - JniResult Function( - JObjectPtr obj, JFieldIDPtr fieldID)>()(obj, fieldID) - .boolean; + _GetBooleanField(obj, fieldID).boolean; + + late final _GetByteField = ptr.ref.GetByteField + .asFunction(); int GetByteField(JObjectPtr obj, JFieldIDPtr fieldID) => - ref.GetByteField.asFunction< - JniResult Function( - JObjectPtr obj, JFieldIDPtr fieldID)>()(obj, fieldID) - .byte; + _GetByteField(obj, fieldID).byte; + + late final _GetCharField = ptr.ref.GetCharField + .asFunction(); int GetCharField(JObjectPtr obj, JFieldIDPtr fieldID) => - ref.GetCharField.asFunction< - JniResult Function( - JObjectPtr obj, JFieldIDPtr fieldID)>()(obj, fieldID) - .char; + _GetCharField(obj, fieldID).char; + + late final _GetShortField = ptr.ref.GetShortField + .asFunction(); int GetShortField(JObjectPtr obj, JFieldIDPtr fieldID) => - ref.GetShortField.asFunction< - JniResult Function( - JObjectPtr obj, JFieldIDPtr fieldID)>()(obj, fieldID) - .short; + _GetShortField(obj, fieldID).short; + + late final _GetIntField = ptr.ref.GetIntField + .asFunction(); int GetIntField(JObjectPtr obj, JFieldIDPtr fieldID) => - ref.GetIntField.asFunction< - JniResult Function( - JObjectPtr obj, JFieldIDPtr fieldID)>()(obj, fieldID) - .integer; + _GetIntField(obj, fieldID).integer; + + late final _GetLongField = ptr.ref.GetLongField + .asFunction(); int GetLongField(JObjectPtr obj, JFieldIDPtr fieldID) => - ref.GetLongField.asFunction< - JniResult Function( - JObjectPtr obj, JFieldIDPtr fieldID)>()(obj, fieldID) - .long; + _GetLongField(obj, fieldID).long; + + late final _GetFloatField = ptr.ref.GetFloatField + .asFunction(); double GetFloatField(JObjectPtr obj, JFieldIDPtr fieldID) => - ref.GetFloatField.asFunction< - JniResult Function( - JObjectPtr obj, JFieldIDPtr fieldID)>()(obj, fieldID) - .float; + _GetFloatField(obj, fieldID).float; + + late final _GetDoubleField = ptr.ref.GetDoubleField + .asFunction(); double GetDoubleField(JObjectPtr obj, JFieldIDPtr fieldID) => - ref.GetDoubleField.asFunction< - JniResult Function( - JObjectPtr obj, JFieldIDPtr fieldID)>()(obj, fieldID) - .doubleFloat; + _GetDoubleField(obj, fieldID).doubleFloat; + + late final _SetObjectField = ptr.ref.SetObjectField.asFunction< + JThrowablePtr Function( + JObjectPtr obj, JFieldIDPtr fieldID, JObjectPtr val)>(); void SetObjectField(JObjectPtr obj, JFieldIDPtr fieldID, JObjectPtr val) => - ref.SetObjectField.asFunction< - JThrowablePtr Function(JObjectPtr obj, JFieldIDPtr fieldID, - JObjectPtr val)>()(obj, fieldID, val) - .check(); + _SetObjectField(obj, fieldID, val).check(); + + late final _SetBooleanField = ptr.ref.SetBooleanField.asFunction< + JThrowablePtr Function(JObjectPtr obj, JFieldIDPtr fieldID, int val)>(); void SetBooleanField(JObjectPtr obj, JFieldIDPtr fieldID, int val) => - ref.SetBooleanField.asFunction< - JThrowablePtr Function(JObjectPtr obj, JFieldIDPtr fieldID, - int val)>()(obj, fieldID, val) - .check(); + _SetBooleanField(obj, fieldID, val).check(); + + late final _SetByteField = ptr.ref.SetByteField.asFunction< + JThrowablePtr Function(JObjectPtr obj, JFieldIDPtr fieldID, int val)>(); void SetByteField(JObjectPtr obj, JFieldIDPtr fieldID, int val) => - ref.SetByteField.asFunction< - JThrowablePtr Function(JObjectPtr obj, JFieldIDPtr fieldID, - int val)>()(obj, fieldID, val) - .check(); + _SetByteField(obj, fieldID, val).check(); + + late final _SetCharField = ptr.ref.SetCharField.asFunction< + JThrowablePtr Function(JObjectPtr obj, JFieldIDPtr fieldID, int val)>(); void SetCharField(JObjectPtr obj, JFieldIDPtr fieldID, int val) => - ref.SetCharField.asFunction< - JThrowablePtr Function(JObjectPtr obj, JFieldIDPtr fieldID, - int val)>()(obj, fieldID, val) - .check(); + _SetCharField(obj, fieldID, val).check(); + + late final _SetShortField = ptr.ref.SetShortField.asFunction< + JThrowablePtr Function(JObjectPtr obj, JFieldIDPtr fieldID, int val)>(); void SetShortField(JObjectPtr obj, JFieldIDPtr fieldID, int val) => - ref.SetShortField.asFunction< - JThrowablePtr Function(JObjectPtr obj, JFieldIDPtr fieldID, - int val)>()(obj, fieldID, val) - .check(); + _SetShortField(obj, fieldID, val).check(); + + late final _SetIntField = ptr.ref.SetIntField.asFunction< + JThrowablePtr Function(JObjectPtr obj, JFieldIDPtr fieldID, int val)>(); void SetIntField(JObjectPtr obj, JFieldIDPtr fieldID, int val) => - ref.SetIntField.asFunction< - JThrowablePtr Function(JObjectPtr obj, JFieldIDPtr fieldID, - int val)>()(obj, fieldID, val) - .check(); + _SetIntField(obj, fieldID, val).check(); + + late final _SetLongField = ptr.ref.SetLongField.asFunction< + JThrowablePtr Function(JObjectPtr obj, JFieldIDPtr fieldID, int val)>(); void SetLongField(JObjectPtr obj, JFieldIDPtr fieldID, int val) => - ref.SetLongField.asFunction< - JThrowablePtr Function(JObjectPtr obj, JFieldIDPtr fieldID, - int val)>()(obj, fieldID, val) - .check(); + _SetLongField(obj, fieldID, val).check(); + + late final _SetFloatField = ptr.ref.SetFloatField.asFunction< + JThrowablePtr Function( + JObjectPtr obj, JFieldIDPtr fieldID, double val)>(); void SetFloatField(JObjectPtr obj, JFieldIDPtr fieldID, double val) => - ref.SetFloatField.asFunction< - JThrowablePtr Function(JObjectPtr obj, JFieldIDPtr fieldID, - double val)>()(obj, fieldID, val) - .check(); + _SetFloatField(obj, fieldID, val).check(); + + late final _SetDoubleField = ptr.ref.SetDoubleField.asFunction< + JThrowablePtr Function( + JObjectPtr obj, JFieldIDPtr fieldID, double val)>(); void SetDoubleField(JObjectPtr obj, JFieldIDPtr fieldID, double val) => - ref.SetDoubleField.asFunction< - JThrowablePtr Function(JObjectPtr obj, JFieldIDPtr fieldID, - double val)>()(obj, fieldID, val) - .check(); + _SetDoubleField(obj, fieldID, val).check(); + + late final _GetStaticMethodID = ptr.ref.GetStaticMethodID.asFunction< + JniPointerResult Function(JClassPtr clazz, ffi.Pointer name, + ffi.Pointer sig)>(); JMethodIDPtr GetStaticMethodID(JClassPtr clazz, ffi.Pointer name, ffi.Pointer sig) => - ref.GetStaticMethodID.asFunction< - JniPointerResult Function( - JClassPtr clazz, - ffi.Pointer name, - ffi.Pointer sig)>()(clazz, name, sig) - .methodID; + _GetStaticMethodID(clazz, name, sig).methodID; + + late final _CallStaticObjectMethod = ptr.ref.CallStaticObjectMethod + .asFunction(); JObjectPtr CallStaticObjectMethod(JClassPtr clazz, JMethodIDPtr methodID) => - ref.CallStaticObjectMethod.asFunction< - JniResult Function( - JClassPtr clazz, JMethodIDPtr methodID)>()(clazz, methodID) - .object; + _CallStaticObjectMethod(clazz, methodID).object; + + late final _CallStaticObjectMethodA = ptr.ref.CallStaticObjectMethodA + .asFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>(); JObjectPtr CallStaticObjectMethodA( JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => - ref.CallStaticObjectMethodA.asFunction< - JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, - ffi.Pointer args)>()(clazz, methodID, args) - .object; + _CallStaticObjectMethodA(clazz, methodID, args).object; + + late final _CallStaticBooleanMethod = ptr.ref.CallStaticBooleanMethod + .asFunction(); bool CallStaticBooleanMethod(JClassPtr clazz, JMethodIDPtr methodID) => - ref.CallStaticBooleanMethod.asFunction< - JniResult Function( - JClassPtr clazz, JMethodIDPtr methodID)>()(clazz, methodID) - .boolean; + _CallStaticBooleanMethod(clazz, methodID).boolean; + + late final _CallStaticBooleanMethodA = ptr.ref.CallStaticBooleanMethodA + .asFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>(); bool CallStaticBooleanMethodA( JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => - ref.CallStaticBooleanMethodA.asFunction< - JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, - ffi.Pointer args)>()(clazz, methodID, args) - .boolean; + _CallStaticBooleanMethodA(clazz, methodID, args).boolean; + + late final _CallStaticByteMethod = ptr.ref.CallStaticByteMethod + .asFunction(); int CallStaticByteMethod(JClassPtr clazz, JMethodIDPtr methodID) => - ref.CallStaticByteMethod.asFunction< - JniResult Function( - JClassPtr clazz, JMethodIDPtr methodID)>()(clazz, methodID) - .byte; + _CallStaticByteMethod(clazz, methodID).byte; + + late final _CallStaticByteMethodA = ptr.ref.CallStaticByteMethodA.asFunction< + JniResult Function( + JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args)>(); int CallStaticByteMethodA( JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => - ref.CallStaticByteMethodA.asFunction< - JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, - ffi.Pointer args)>()(clazz, methodID, args) - .byte; + _CallStaticByteMethodA(clazz, methodID, args).byte; + + late final _CallStaticCharMethod = ptr.ref.CallStaticCharMethod + .asFunction(); int CallStaticCharMethod(JClassPtr clazz, JMethodIDPtr methodID) => - ref.CallStaticCharMethod.asFunction< - JniResult Function( - JClassPtr clazz, JMethodIDPtr methodID)>()(clazz, methodID) - .char; + _CallStaticCharMethod(clazz, methodID).char; + + late final _CallStaticCharMethodA = ptr.ref.CallStaticCharMethodA.asFunction< + JniResult Function( + JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args)>(); int CallStaticCharMethodA( JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => - ref.CallStaticCharMethodA.asFunction< - JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, - ffi.Pointer args)>()(clazz, methodID, args) - .char; + _CallStaticCharMethodA(clazz, methodID, args).char; + + late final _CallStaticShortMethod = ptr.ref.CallStaticShortMethod + .asFunction(); int CallStaticShortMethod(JClassPtr clazz, JMethodIDPtr methodID) => - ref.CallStaticShortMethod.asFunction< - JniResult Function( - JClassPtr clazz, JMethodIDPtr methodID)>()(clazz, methodID) - .short; + _CallStaticShortMethod(clazz, methodID).short; + + late final _CallStaticShortMethodA = ptr.ref.CallStaticShortMethodA + .asFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>(); int CallStaticShortMethodA( JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => - ref.CallStaticShortMethodA.asFunction< - JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, - ffi.Pointer args)>()(clazz, methodID, args) - .short; + _CallStaticShortMethodA(clazz, methodID, args).short; + + late final _CallStaticIntMethod = ptr.ref.CallStaticIntMethod + .asFunction(); int CallStaticIntMethod(JClassPtr clazz, JMethodIDPtr methodID) => - ref.CallStaticIntMethod.asFunction< - JniResult Function( - JClassPtr clazz, JMethodIDPtr methodID)>()(clazz, methodID) - .integer; + _CallStaticIntMethod(clazz, methodID).integer; + + late final _CallStaticIntMethodA = ptr.ref.CallStaticIntMethodA.asFunction< + JniResult Function( + JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args)>(); int CallStaticIntMethodA( JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => - ref.CallStaticIntMethodA.asFunction< - JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, - ffi.Pointer args)>()(clazz, methodID, args) - .integer; + _CallStaticIntMethodA(clazz, methodID, args).integer; + + late final _CallStaticLongMethod = ptr.ref.CallStaticLongMethod + .asFunction(); int CallStaticLongMethod(JClassPtr clazz, JMethodIDPtr methodID) => - ref.CallStaticLongMethod.asFunction< - JniResult Function( - JClassPtr clazz, JMethodIDPtr methodID)>()(clazz, methodID) - .long; + _CallStaticLongMethod(clazz, methodID).long; + + late final _CallStaticLongMethodA = ptr.ref.CallStaticLongMethodA.asFunction< + JniResult Function( + JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args)>(); int CallStaticLongMethodA( JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => - ref.CallStaticLongMethodA.asFunction< - JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, - ffi.Pointer args)>()(clazz, methodID, args) - .long; + _CallStaticLongMethodA(clazz, methodID, args).long; + + late final _CallStaticFloatMethod = ptr.ref.CallStaticFloatMethod + .asFunction(); double CallStaticFloatMethod(JClassPtr clazz, JMethodIDPtr methodID) => - ref.CallStaticFloatMethod.asFunction< - JniResult Function( - JClassPtr clazz, JMethodIDPtr methodID)>()(clazz, methodID) - .float; + _CallStaticFloatMethod(clazz, methodID).float; + + late final _CallStaticFloatMethodA = ptr.ref.CallStaticFloatMethodA + .asFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>(); double CallStaticFloatMethodA( JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => - ref.CallStaticFloatMethodA.asFunction< - JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, - ffi.Pointer args)>()(clazz, methodID, args) - .float; + _CallStaticFloatMethodA(clazz, methodID, args).float; + + late final _CallStaticDoubleMethod = ptr.ref.CallStaticDoubleMethod + .asFunction(); double CallStaticDoubleMethod(JClassPtr clazz, JMethodIDPtr methodID) => - ref.CallStaticDoubleMethod.asFunction< - JniResult Function( - JClassPtr clazz, JMethodIDPtr methodID)>()(clazz, methodID) - .doubleFloat; + _CallStaticDoubleMethod(clazz, methodID).doubleFloat; + + late final _CallStaticDoubleMethodA = ptr.ref.CallStaticDoubleMethodA + .asFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>(); double CallStaticDoubleMethodA( JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => - ref.CallStaticDoubleMethodA.asFunction< - JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, - ffi.Pointer args)>()(clazz, methodID, args) - .doubleFloat; + _CallStaticDoubleMethodA(clazz, methodID, args).doubleFloat; + + late final _CallStaticVoidMethod = ptr.ref.CallStaticVoidMethod.asFunction< + JThrowablePtr Function(JClassPtr clazz, JMethodIDPtr methodID)>(); void CallStaticVoidMethod(JClassPtr clazz, JMethodIDPtr methodID) => - ref.CallStaticVoidMethod.asFunction< - JThrowablePtr Function( - JClassPtr clazz, JMethodIDPtr methodID)>()(clazz, methodID) - .check(); + _CallStaticVoidMethod(clazz, methodID).check(); + + late final _CallStaticVoidMethodA = ptr.ref.CallStaticVoidMethodA.asFunction< + JThrowablePtr Function( + JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args)>(); void CallStaticVoidMethodA( JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => - ref.CallStaticVoidMethodA.asFunction< - JThrowablePtr Function(JClassPtr clazz, JMethodIDPtr methodID, - ffi.Pointer args)>()(clazz, methodID, args) - .check(); + _CallStaticVoidMethodA(clazz, methodID, args).check(); + + late final _GetStaticFieldID = ptr.ref.GetStaticFieldID.asFunction< + JniPointerResult Function(JClassPtr clazz, ffi.Pointer name, + ffi.Pointer sig)>(); JFieldIDPtr GetStaticFieldID(JClassPtr clazz, ffi.Pointer name, ffi.Pointer sig) => - ref.GetStaticFieldID.asFunction< - JniPointerResult Function( - JClassPtr clazz, - ffi.Pointer name, - ffi.Pointer sig)>()(clazz, name, sig) - .fieldID; + _GetStaticFieldID(clazz, name, sig).fieldID; + + late final _GetStaticObjectField = ptr.ref.GetStaticObjectField + .asFunction(); JObjectPtr GetStaticObjectField(JClassPtr clazz, JFieldIDPtr fieldID) => - ref.GetStaticObjectField.asFunction< - JniResult Function( - JClassPtr clazz, JFieldIDPtr fieldID)>()(clazz, fieldID) - .object; + _GetStaticObjectField(clazz, fieldID).object; + + late final _GetStaticBooleanField = ptr.ref.GetStaticBooleanField + .asFunction(); bool GetStaticBooleanField(JClassPtr clazz, JFieldIDPtr fieldID) => - ref.GetStaticBooleanField.asFunction< - JniResult Function( - JClassPtr clazz, JFieldIDPtr fieldID)>()(clazz, fieldID) - .boolean; + _GetStaticBooleanField(clazz, fieldID).boolean; + + late final _GetStaticByteField = ptr.ref.GetStaticByteField + .asFunction(); int GetStaticByteField(JClassPtr clazz, JFieldIDPtr fieldID) => - ref.GetStaticByteField.asFunction< - JniResult Function( - JClassPtr clazz, JFieldIDPtr fieldID)>()(clazz, fieldID) - .byte; + _GetStaticByteField(clazz, fieldID).byte; + + late final _GetStaticCharField = ptr.ref.GetStaticCharField + .asFunction(); int GetStaticCharField(JClassPtr clazz, JFieldIDPtr fieldID) => - ref.GetStaticCharField.asFunction< - JniResult Function( - JClassPtr clazz, JFieldIDPtr fieldID)>()(clazz, fieldID) - .char; + _GetStaticCharField(clazz, fieldID).char; + + late final _GetStaticShortField = ptr.ref.GetStaticShortField + .asFunction(); int GetStaticShortField(JClassPtr clazz, JFieldIDPtr fieldID) => - ref.GetStaticShortField.asFunction< - JniResult Function( - JClassPtr clazz, JFieldIDPtr fieldID)>()(clazz, fieldID) - .short; + _GetStaticShortField(clazz, fieldID).short; + + late final _GetStaticIntField = ptr.ref.GetStaticIntField + .asFunction(); int GetStaticIntField(JClassPtr clazz, JFieldIDPtr fieldID) => - ref.GetStaticIntField.asFunction< - JniResult Function( - JClassPtr clazz, JFieldIDPtr fieldID)>()(clazz, fieldID) - .integer; + _GetStaticIntField(clazz, fieldID).integer; + + late final _GetStaticLongField = ptr.ref.GetStaticLongField + .asFunction(); int GetStaticLongField(JClassPtr clazz, JFieldIDPtr fieldID) => - ref.GetStaticLongField.asFunction< - JniResult Function( - JClassPtr clazz, JFieldIDPtr fieldID)>()(clazz, fieldID) - .long; + _GetStaticLongField(clazz, fieldID).long; + + late final _GetStaticFloatField = ptr.ref.GetStaticFloatField + .asFunction(); double GetStaticFloatField(JClassPtr clazz, JFieldIDPtr fieldID) => - ref.GetStaticFloatField.asFunction< - JniResult Function( - JClassPtr clazz, JFieldIDPtr fieldID)>()(clazz, fieldID) - .float; + _GetStaticFloatField(clazz, fieldID).float; + + late final _GetStaticDoubleField = ptr.ref.GetStaticDoubleField + .asFunction(); double GetStaticDoubleField(JClassPtr clazz, JFieldIDPtr fieldID) => - ref.GetStaticDoubleField.asFunction< - JniResult Function( - JClassPtr clazz, JFieldIDPtr fieldID)>()(clazz, fieldID) - .doubleFloat; + _GetStaticDoubleField(clazz, fieldID).doubleFloat; + + late final _SetStaticObjectField = ptr.ref.SetStaticObjectField.asFunction< + JThrowablePtr Function( + JClassPtr clazz, JFieldIDPtr fieldID, JObjectPtr val)>(); void SetStaticObjectField( JClassPtr clazz, JFieldIDPtr fieldID, JObjectPtr val) => - ref.SetStaticObjectField.asFunction< - JThrowablePtr Function(JClassPtr clazz, JFieldIDPtr fieldID, - JObjectPtr val)>()(clazz, fieldID, val) - .check(); + _SetStaticObjectField(clazz, fieldID, val).check(); + + late final _SetStaticBooleanField = ptr.ref.SetStaticBooleanField.asFunction< + JThrowablePtr Function(JClassPtr clazz, JFieldIDPtr fieldID, int val)>(); void SetStaticBooleanField(JClassPtr clazz, JFieldIDPtr fieldID, int val) => - ref.SetStaticBooleanField.asFunction< - JThrowablePtr Function(JClassPtr clazz, JFieldIDPtr fieldID, - int val)>()(clazz, fieldID, val) - .check(); + _SetStaticBooleanField(clazz, fieldID, val).check(); + + late final _SetStaticByteField = ptr.ref.SetStaticByteField.asFunction< + JThrowablePtr Function(JClassPtr clazz, JFieldIDPtr fieldID, int val)>(); void SetStaticByteField(JClassPtr clazz, JFieldIDPtr fieldID, int val) => - ref.SetStaticByteField.asFunction< - JThrowablePtr Function(JClassPtr clazz, JFieldIDPtr fieldID, - int val)>()(clazz, fieldID, val) - .check(); + _SetStaticByteField(clazz, fieldID, val).check(); + + late final _SetStaticCharField = ptr.ref.SetStaticCharField.asFunction< + JThrowablePtr Function(JClassPtr clazz, JFieldIDPtr fieldID, int val)>(); void SetStaticCharField(JClassPtr clazz, JFieldIDPtr fieldID, int val) => - ref.SetStaticCharField.asFunction< - JThrowablePtr Function(JClassPtr clazz, JFieldIDPtr fieldID, - int val)>()(clazz, fieldID, val) - .check(); + _SetStaticCharField(clazz, fieldID, val).check(); + + late final _SetStaticShortField = ptr.ref.SetStaticShortField.asFunction< + JThrowablePtr Function(JClassPtr clazz, JFieldIDPtr fieldID, int val)>(); void SetStaticShortField(JClassPtr clazz, JFieldIDPtr fieldID, int val) => - ref.SetStaticShortField.asFunction< - JThrowablePtr Function(JClassPtr clazz, JFieldIDPtr fieldID, - int val)>()(clazz, fieldID, val) - .check(); + _SetStaticShortField(clazz, fieldID, val).check(); + + late final _SetStaticIntField = ptr.ref.SetStaticIntField.asFunction< + JThrowablePtr Function(JClassPtr clazz, JFieldIDPtr fieldID, int val)>(); void SetStaticIntField(JClassPtr clazz, JFieldIDPtr fieldID, int val) => - ref.SetStaticIntField.asFunction< - JThrowablePtr Function(JClassPtr clazz, JFieldIDPtr fieldID, - int val)>()(clazz, fieldID, val) - .check(); + _SetStaticIntField(clazz, fieldID, val).check(); + + late final _SetStaticLongField = ptr.ref.SetStaticLongField.asFunction< + JThrowablePtr Function(JClassPtr clazz, JFieldIDPtr fieldID, int val)>(); void SetStaticLongField(JClassPtr clazz, JFieldIDPtr fieldID, int val) => - ref.SetStaticLongField.asFunction< - JThrowablePtr Function(JClassPtr clazz, JFieldIDPtr fieldID, - int val)>()(clazz, fieldID, val) - .check(); + _SetStaticLongField(clazz, fieldID, val).check(); + + late final _SetStaticFloatField = ptr.ref.SetStaticFloatField.asFunction< + JThrowablePtr Function( + JClassPtr clazz, JFieldIDPtr fieldID, double val)>(); void SetStaticFloatField(JClassPtr clazz, JFieldIDPtr fieldID, double val) => - ref.SetStaticFloatField.asFunction< - JThrowablePtr Function(JClassPtr clazz, JFieldIDPtr fieldID, - double val)>()(clazz, fieldID, val) - .check(); + _SetStaticFloatField(clazz, fieldID, val).check(); + + late final _SetStaticDoubleField = ptr.ref.SetStaticDoubleField.asFunction< + JThrowablePtr Function( + JClassPtr clazz, JFieldIDPtr fieldID, double val)>(); void SetStaticDoubleField(JClassPtr clazz, JFieldIDPtr fieldID, double val) => - ref.SetStaticDoubleField.asFunction< - JThrowablePtr Function(JClassPtr clazz, JFieldIDPtr fieldID, - double val)>()(clazz, fieldID, val) - .check(); + _SetStaticDoubleField(clazz, fieldID, val).check(); + + late final _NewString = ptr.ref.NewString.asFunction< + JniResult Function(ffi.Pointer unicodeChars, int len)>(); JStringPtr NewString(ffi.Pointer unicodeChars, int len) => - ref.NewString.asFunction< - JniResult Function(ffi.Pointer unicodeChars, - int len)>()(unicodeChars, len) - .object; + _NewString(unicodeChars, len).object; - int GetStringLength(JStringPtr string) => - ref.GetStringLength.asFunction()( - string) - .integer; + late final _GetStringLength = ptr.ref.GetStringLength + .asFunction(); + + int GetStringLength(JStringPtr string) => _GetStringLength(string).integer; + + late final _GetStringChars = ptr.ref.GetStringChars.asFunction< + JniPointerResult Function( + JStringPtr string, ffi.Pointer isCopy)>(); ffi.Pointer GetStringChars( JStringPtr string, ffi.Pointer isCopy) => - ref.GetStringChars.asFunction< - JniPointerResult Function(JStringPtr string, - ffi.Pointer isCopy)>()(string, isCopy) - .getPointer(); + _GetStringChars(string, isCopy).getPointer(); + + late final _ReleaseStringChars = ptr.ref.ReleaseStringChars.asFunction< + JThrowablePtr Function( + JStringPtr string, ffi.Pointer isCopy)>(); void ReleaseStringChars(JStringPtr string, ffi.Pointer isCopy) => - ref.ReleaseStringChars.asFunction< - JThrowablePtr Function(JStringPtr string, - ffi.Pointer isCopy)>()(string, isCopy) - .check(); + _ReleaseStringChars(string, isCopy).check(); + + late final _NewStringUTF = ptr.ref.NewStringUTF + .asFunction bytes)>(); - JStringPtr NewStringUTF(ffi.Pointer bytes) => ref.NewStringUTF - .asFunction bytes)>()(bytes) - .object; + JStringPtr NewStringUTF(ffi.Pointer bytes) => + _NewStringUTF(bytes).object; - int GetStringUTFLength(JStringPtr string) => ref.GetStringUTFLength - .asFunction()(string) - .integer; + late final _GetStringUTFLength = ptr.ref.GetStringUTFLength + .asFunction(); + + int GetStringUTFLength(JStringPtr string) => + _GetStringUTFLength(string).integer; + + late final _GetStringUTFChars = ptr.ref.GetStringUTFChars.asFunction< + JniPointerResult Function( + JStringPtr string, ffi.Pointer isCopy)>(); ffi.Pointer GetStringUTFChars( JStringPtr string, ffi.Pointer isCopy) => - ref.GetStringUTFChars.asFunction< - JniPointerResult Function(JStringPtr string, - ffi.Pointer isCopy)>()(string, isCopy) - .getPointer(); + _GetStringUTFChars(string, isCopy).getPointer(); + + late final _ReleaseStringUTFChars = ptr.ref.ReleaseStringUTFChars.asFunction< + JThrowablePtr Function(JStringPtr string, ffi.Pointer utf)>(); void ReleaseStringUTFChars(JStringPtr string, ffi.Pointer utf) => - ref.ReleaseStringUTFChars.asFunction< - JThrowablePtr Function( - JStringPtr string, ffi.Pointer utf)>()(string, utf) - .check(); + _ReleaseStringUTFChars(string, utf).check(); - int GetArrayLength(JArrayPtr array) => - ref.GetArrayLength.asFunction()( - array) - .integer; + late final _GetArrayLength = + ptr.ref.GetArrayLength.asFunction(); + + int GetArrayLength(JArrayPtr array) => _GetArrayLength(array).integer; + + late final _NewObjectArray = ptr.ref.NewObjectArray.asFunction< + JniResult Function( + int length, JClassPtr elementClass, JObjectPtr initialElement)>(); JObjectArrayPtr NewObjectArray( int length, JClassPtr elementClass, JObjectPtr initialElement) => - ref.NewObjectArray.asFunction< - JniResult Function(int length, JClassPtr elementClass, - JObjectPtr initialElement)>()( - length, elementClass, initialElement) - .object; + _NewObjectArray(length, elementClass, initialElement).object; + + late final _GetObjectArrayElement = ptr.ref.GetObjectArrayElement + .asFunction(); JObjectPtr GetObjectArrayElement(JObjectArrayPtr array, int index) => - ref.GetObjectArrayElement.asFunction< - JniResult Function( - JObjectArrayPtr array, int index)>()(array, index) - .object; + _GetObjectArrayElement(array, index).object; + + late final _SetObjectArrayElement = ptr.ref.SetObjectArrayElement.asFunction< + JThrowablePtr Function( + JObjectArrayPtr array, int index, JObjectPtr val)>(); void SetObjectArrayElement( JObjectArrayPtr array, int index, JObjectPtr val) => - ref.SetObjectArrayElement.asFunction< - JThrowablePtr Function(JObjectArrayPtr array, int index, - JObjectPtr val)>()(array, index, val) - .check(); + _SetObjectArrayElement(array, index, val).check(); + + late final _NewBooleanArray = + ptr.ref.NewBooleanArray.asFunction(); JBooleanArrayPtr NewBooleanArray(int length) => - ref.NewBooleanArray.asFunction()(length) - .object; + _NewBooleanArray(length).object; + + late final _NewByteArray = + ptr.ref.NewByteArray.asFunction(); + + JByteArrayPtr NewByteArray(int length) => _NewByteArray(length).object; - JByteArrayPtr NewByteArray(int length) => - ref.NewByteArray.asFunction()(length) - .object; + late final _NewCharArray = + ptr.ref.NewCharArray.asFunction(); - JCharArrayPtr NewCharArray(int length) => - ref.NewCharArray.asFunction()(length) - .object; + JCharArrayPtr NewCharArray(int length) => _NewCharArray(length).object; - JShortArrayPtr NewShortArray(int length) => - ref.NewShortArray.asFunction()(length) - .object; + late final _NewShortArray = + ptr.ref.NewShortArray.asFunction(); - JIntArrayPtr NewIntArray(int length) => - ref.NewIntArray.asFunction()(length) - .object; + JShortArrayPtr NewShortArray(int length) => _NewShortArray(length).object; - JLongArrayPtr NewLongArray(int length) => - ref.NewLongArray.asFunction()(length) - .object; + late final _NewIntArray = + ptr.ref.NewIntArray.asFunction(); - JFloatArrayPtr NewFloatArray(int length) => - ref.NewFloatArray.asFunction()(length) - .object; + JIntArrayPtr NewIntArray(int length) => _NewIntArray(length).object; - JDoubleArrayPtr NewDoubleArray(int length) => - ref.NewDoubleArray.asFunction()(length) - .object; + late final _NewLongArray = + ptr.ref.NewLongArray.asFunction(); + + JLongArrayPtr NewLongArray(int length) => _NewLongArray(length).object; + + late final _NewFloatArray = + ptr.ref.NewFloatArray.asFunction(); + + JFloatArrayPtr NewFloatArray(int length) => _NewFloatArray(length).object; + + late final _NewDoubleArray = + ptr.ref.NewDoubleArray.asFunction(); + + JDoubleArrayPtr NewDoubleArray(int length) => _NewDoubleArray(length).object; + + late final _GetBooleanArrayElements = ptr.ref.GetBooleanArrayElements + .asFunction< + JniPointerResult Function( + JBooleanArrayPtr array, ffi.Pointer isCopy)>(); ffi.Pointer GetBooleanArrayElements( JBooleanArrayPtr array, ffi.Pointer isCopy) => - ref.GetBooleanArrayElements.asFunction< - JniPointerResult Function(JBooleanArrayPtr array, - ffi.Pointer isCopy)>()(array, isCopy) - .getPointer(); + _GetBooleanArrayElements(array, isCopy).getPointer(); + + late final _GetByteArrayElements = ptr.ref.GetByteArrayElements.asFunction< + JniPointerResult Function( + JByteArrayPtr array, ffi.Pointer isCopy)>(); ffi.Pointer GetByteArrayElements( JByteArrayPtr array, ffi.Pointer isCopy) => - ref.GetByteArrayElements.asFunction< - JniPointerResult Function(JByteArrayPtr array, - ffi.Pointer isCopy)>()(array, isCopy) - .getPointer(); + _GetByteArrayElements(array, isCopy).getPointer(); + + late final _GetCharArrayElements = ptr.ref.GetCharArrayElements.asFunction< + JniPointerResult Function( + JCharArrayPtr array, ffi.Pointer isCopy)>(); ffi.Pointer GetCharArrayElements( JCharArrayPtr array, ffi.Pointer isCopy) => - ref.GetCharArrayElements.asFunction< - JniPointerResult Function(JCharArrayPtr array, - ffi.Pointer isCopy)>()(array, isCopy) - .getPointer(); + _GetCharArrayElements(array, isCopy).getPointer(); + + late final _GetShortArrayElements = ptr.ref.GetShortArrayElements.asFunction< + JniPointerResult Function( + JShortArrayPtr array, ffi.Pointer isCopy)>(); ffi.Pointer GetShortArrayElements( JShortArrayPtr array, ffi.Pointer isCopy) => - ref.GetShortArrayElements.asFunction< - JniPointerResult Function(JShortArrayPtr array, - ffi.Pointer isCopy)>()(array, isCopy) - .getPointer(); + _GetShortArrayElements(array, isCopy).getPointer(); + + late final _GetIntArrayElements = ptr.ref.GetIntArrayElements.asFunction< + JniPointerResult Function( + JIntArrayPtr array, ffi.Pointer isCopy)>(); ffi.Pointer GetIntArrayElements( JIntArrayPtr array, ffi.Pointer isCopy) => - ref.GetIntArrayElements.asFunction< - JniPointerResult Function(JIntArrayPtr array, - ffi.Pointer isCopy)>()(array, isCopy) - .getPointer(); + _GetIntArrayElements(array, isCopy).getPointer(); + + late final _GetLongArrayElements = ptr.ref.GetLongArrayElements.asFunction< + JniPointerResult Function( + JLongArrayPtr array, ffi.Pointer isCopy)>(); ffi.Pointer GetLongArrayElements( JLongArrayPtr array, ffi.Pointer isCopy) => - ref.GetLongArrayElements.asFunction< - JniPointerResult Function(JLongArrayPtr array, - ffi.Pointer isCopy)>()(array, isCopy) - .getPointer(); + _GetLongArrayElements(array, isCopy).getPointer(); + + late final _GetFloatArrayElements = ptr.ref.GetFloatArrayElements.asFunction< + JniPointerResult Function( + JFloatArrayPtr array, ffi.Pointer isCopy)>(); ffi.Pointer GetFloatArrayElements( JFloatArrayPtr array, ffi.Pointer isCopy) => - ref.GetFloatArrayElements.asFunction< - JniPointerResult Function(JFloatArrayPtr array, - ffi.Pointer isCopy)>()(array, isCopy) - .getPointer(); + _GetFloatArrayElements(array, isCopy).getPointer(); + + late final _GetDoubleArrayElements = ptr.ref.GetDoubleArrayElements + .asFunction< + JniPointerResult Function( + JDoubleArrayPtr array, ffi.Pointer isCopy)>(); ffi.Pointer GetDoubleArrayElements( JDoubleArrayPtr array, ffi.Pointer isCopy) => - ref.GetDoubleArrayElements.asFunction< - JniPointerResult Function(JDoubleArrayPtr array, - ffi.Pointer isCopy)>()(array, isCopy) - .getPointer(); + _GetDoubleArrayElements(array, isCopy).getPointer(); + + late final _ReleaseBooleanArrayElements = ptr.ref.ReleaseBooleanArrayElements + .asFunction< + JThrowablePtr Function(JBooleanArrayPtr array, + ffi.Pointer elems, int mode)>(); void ReleaseBooleanArrayElements(JBooleanArrayPtr array, ffi.Pointer elems, int mode) => - ref.ReleaseBooleanArrayElements.asFunction< - JThrowablePtr Function( - JBooleanArrayPtr array, - ffi.Pointer elems, - int mode)>()(array, elems, mode) - .check(); + _ReleaseBooleanArrayElements(array, elems, mode).check(); + + late final _ReleaseByteArrayElements = ptr.ref.ReleaseByteArrayElements + .asFunction< + JThrowablePtr Function( + JByteArrayPtr array, ffi.Pointer elems, int mode)>(); void ReleaseByteArrayElements( JByteArrayPtr array, ffi.Pointer elems, int mode) => - ref.ReleaseByteArrayElements.asFunction< - JThrowablePtr Function( - JByteArrayPtr array, - ffi.Pointer elems, - int mode)>()(array, elems, mode) - .check(); + _ReleaseByteArrayElements(array, elems, mode).check(); + + late final _ReleaseCharArrayElements = ptr.ref.ReleaseCharArrayElements + .asFunction< + JThrowablePtr Function( + JCharArrayPtr array, ffi.Pointer elems, int mode)>(); void ReleaseCharArrayElements( JCharArrayPtr array, ffi.Pointer elems, int mode) => - ref.ReleaseCharArrayElements.asFunction< - JThrowablePtr Function( - JCharArrayPtr array, - ffi.Pointer elems, - int mode)>()(array, elems, mode) - .check(); + _ReleaseCharArrayElements(array, elems, mode).check(); + + late final _ReleaseShortArrayElements = ptr.ref.ReleaseShortArrayElements + .asFunction< + JThrowablePtr Function(JShortArrayPtr array, + ffi.Pointer elems, int mode)>(); void ReleaseShortArrayElements( JShortArrayPtr array, ffi.Pointer elems, int mode) => - ref.ReleaseShortArrayElements.asFunction< - JThrowablePtr Function( - JShortArrayPtr array, - ffi.Pointer elems, - int mode)>()(array, elems, mode) - .check(); + _ReleaseShortArrayElements(array, elems, mode).check(); + + late final _ReleaseIntArrayElements = ptr.ref.ReleaseIntArrayElements + .asFunction< + JThrowablePtr Function( + JIntArrayPtr array, ffi.Pointer elems, int mode)>(); void ReleaseIntArrayElements( JIntArrayPtr array, ffi.Pointer elems, int mode) => - ref.ReleaseIntArrayElements.asFunction< - JThrowablePtr Function( - JIntArrayPtr array, - ffi.Pointer elems, - int mode)>()(array, elems, mode) - .check(); + _ReleaseIntArrayElements(array, elems, mode).check(); + + late final _ReleaseLongArrayElements = ptr.ref.ReleaseLongArrayElements + .asFunction< + JThrowablePtr Function( + JLongArrayPtr array, ffi.Pointer elems, int mode)>(); void ReleaseLongArrayElements( JLongArrayPtr array, ffi.Pointer elems, int mode) => - ref.ReleaseLongArrayElements.asFunction< - JThrowablePtr Function( - JLongArrayPtr array, - ffi.Pointer elems, - int mode)>()(array, elems, mode) - .check(); + _ReleaseLongArrayElements(array, elems, mode).check(); + + late final _ReleaseFloatArrayElements = ptr.ref.ReleaseFloatArrayElements + .asFunction< + JThrowablePtr Function(JFloatArrayPtr array, + ffi.Pointer elems, int mode)>(); void ReleaseFloatArrayElements( JFloatArrayPtr array, ffi.Pointer elems, int mode) => - ref.ReleaseFloatArrayElements.asFunction< - JThrowablePtr Function( - JFloatArrayPtr array, - ffi.Pointer elems, - int mode)>()(array, elems, mode) - .check(); + _ReleaseFloatArrayElements(array, elems, mode).check(); + + late final _ReleaseDoubleArrayElements = ptr.ref.ReleaseDoubleArrayElements + .asFunction< + JThrowablePtr Function(JDoubleArrayPtr array, + ffi.Pointer elems, int mode)>(); void ReleaseDoubleArrayElements( JDoubleArrayPtr array, ffi.Pointer elems, int mode) => - ref.ReleaseDoubleArrayElements.asFunction< - JThrowablePtr Function( - JDoubleArrayPtr array, - ffi.Pointer elems, - int mode)>()(array, elems, mode) - .check(); + _ReleaseDoubleArrayElements(array, elems, mode).check(); + + late final _GetBooleanArrayRegion = ptr.ref.GetBooleanArrayRegion.asFunction< + JThrowablePtr Function(JBooleanArrayPtr array, int start, int len, + ffi.Pointer buf)>(); void GetBooleanArrayRegion(JBooleanArrayPtr array, int start, int len, ffi.Pointer buf) => - ref.GetBooleanArrayRegion.asFunction< - JThrowablePtr Function(JBooleanArrayPtr array, int start, int len, - ffi.Pointer buf)>()(array, start, len, buf) - .check(); + _GetBooleanArrayRegion(array, start, len, buf).check(); + + late final _GetByteArrayRegion = ptr.ref.GetByteArrayRegion.asFunction< + JThrowablePtr Function(JByteArrayPtr array, int start, int len, + ffi.Pointer buf)>(); void GetByteArrayRegion(JByteArrayPtr array, int start, int len, ffi.Pointer buf) => - ref.GetByteArrayRegion.asFunction< - JThrowablePtr Function(JByteArrayPtr array, int start, int len, - ffi.Pointer buf)>()(array, start, len, buf) - .check(); + _GetByteArrayRegion(array, start, len, buf).check(); + + late final _GetCharArrayRegion = ptr.ref.GetCharArrayRegion.asFunction< + JThrowablePtr Function(JCharArrayPtr array, int start, int len, + ffi.Pointer buf)>(); void GetCharArrayRegion(JCharArrayPtr array, int start, int len, ffi.Pointer buf) => - ref.GetCharArrayRegion.asFunction< - JThrowablePtr Function(JCharArrayPtr array, int start, int len, - ffi.Pointer buf)>()(array, start, len, buf) - .check(); + _GetCharArrayRegion(array, start, len, buf).check(); + + late final _GetShortArrayRegion = ptr.ref.GetShortArrayRegion.asFunction< + JThrowablePtr Function(JShortArrayPtr array, int start, int len, + ffi.Pointer buf)>(); void GetShortArrayRegion(JShortArrayPtr array, int start, int len, ffi.Pointer buf) => - ref.GetShortArrayRegion.asFunction< - JThrowablePtr Function(JShortArrayPtr array, int start, int len, - ffi.Pointer buf)>()(array, start, len, buf) - .check(); + _GetShortArrayRegion(array, start, len, buf).check(); + + late final _GetIntArrayRegion = ptr.ref.GetIntArrayRegion.asFunction< + JThrowablePtr Function(JIntArrayPtr array, int start, int len, + ffi.Pointer buf)>(); void GetIntArrayRegion(JIntArrayPtr array, int start, int len, ffi.Pointer buf) => - ref.GetIntArrayRegion.asFunction< - JThrowablePtr Function(JIntArrayPtr array, int start, int len, - ffi.Pointer buf)>()(array, start, len, buf) - .check(); + _GetIntArrayRegion(array, start, len, buf).check(); + + late final _GetLongArrayRegion = ptr.ref.GetLongArrayRegion.asFunction< + JThrowablePtr Function(JLongArrayPtr array, int start, int len, + ffi.Pointer buf)>(); void GetLongArrayRegion(JLongArrayPtr array, int start, int len, ffi.Pointer buf) => - ref.GetLongArrayRegion.asFunction< - JThrowablePtr Function(JLongArrayPtr array, int start, int len, - ffi.Pointer buf)>()(array, start, len, buf) - .check(); + _GetLongArrayRegion(array, start, len, buf).check(); + + late final _GetFloatArrayRegion = ptr.ref.GetFloatArrayRegion.asFunction< + JThrowablePtr Function(JFloatArrayPtr array, int start, int len, + ffi.Pointer buf)>(); void GetFloatArrayRegion(JFloatArrayPtr array, int start, int len, ffi.Pointer buf) => - ref.GetFloatArrayRegion.asFunction< - JThrowablePtr Function(JFloatArrayPtr array, int start, int len, - ffi.Pointer buf)>()(array, start, len, buf) - .check(); + _GetFloatArrayRegion(array, start, len, buf).check(); + + late final _GetDoubleArrayRegion = ptr.ref.GetDoubleArrayRegion.asFunction< + JThrowablePtr Function(JDoubleArrayPtr array, int start, int len, + ffi.Pointer buf)>(); void GetDoubleArrayRegion(JDoubleArrayPtr array, int start, int len, ffi.Pointer buf) => - ref.GetDoubleArrayRegion.asFunction< - JThrowablePtr Function(JDoubleArrayPtr array, int start, int len, - ffi.Pointer buf)>()(array, start, len, buf) - .check(); + _GetDoubleArrayRegion(array, start, len, buf).check(); + + late final _SetBooleanArrayRegion = ptr.ref.SetBooleanArrayRegion.asFunction< + JThrowablePtr Function(JBooleanArrayPtr array, int start, int len, + ffi.Pointer buf)>(); void SetBooleanArrayRegion(JBooleanArrayPtr array, int start, int len, ffi.Pointer buf) => - ref.SetBooleanArrayRegion.asFunction< - JThrowablePtr Function(JBooleanArrayPtr array, int start, int len, - ffi.Pointer buf)>()(array, start, len, buf) - .check(); + _SetBooleanArrayRegion(array, start, len, buf).check(); + + late final _SetByteArrayRegion = ptr.ref.SetByteArrayRegion.asFunction< + JThrowablePtr Function(JByteArrayPtr array, int start, int len, + ffi.Pointer buf)>(); void SetByteArrayRegion(JByteArrayPtr array, int start, int len, ffi.Pointer buf) => - ref.SetByteArrayRegion.asFunction< - JThrowablePtr Function(JByteArrayPtr array, int start, int len, - ffi.Pointer buf)>()(array, start, len, buf) - .check(); + _SetByteArrayRegion(array, start, len, buf).check(); + + late final _SetCharArrayRegion = ptr.ref.SetCharArrayRegion.asFunction< + JThrowablePtr Function(JCharArrayPtr array, int start, int len, + ffi.Pointer buf)>(); void SetCharArrayRegion(JCharArrayPtr array, int start, int len, ffi.Pointer buf) => - ref.SetCharArrayRegion.asFunction< - JThrowablePtr Function(JCharArrayPtr array, int start, int len, - ffi.Pointer buf)>()(array, start, len, buf) - .check(); + _SetCharArrayRegion(array, start, len, buf).check(); + + late final _SetShortArrayRegion = ptr.ref.SetShortArrayRegion.asFunction< + JThrowablePtr Function(JShortArrayPtr array, int start, int len, + ffi.Pointer buf)>(); void SetShortArrayRegion(JShortArrayPtr array, int start, int len, ffi.Pointer buf) => - ref.SetShortArrayRegion.asFunction< - JThrowablePtr Function(JShortArrayPtr array, int start, int len, - ffi.Pointer buf)>()(array, start, len, buf) - .check(); + _SetShortArrayRegion(array, start, len, buf).check(); + + late final _SetIntArrayRegion = ptr.ref.SetIntArrayRegion.asFunction< + JThrowablePtr Function(JIntArrayPtr array, int start, int len, + ffi.Pointer buf)>(); void SetIntArrayRegion(JIntArrayPtr array, int start, int len, ffi.Pointer buf) => - ref.SetIntArrayRegion.asFunction< - JThrowablePtr Function(JIntArrayPtr array, int start, int len, - ffi.Pointer buf)>()(array, start, len, buf) - .check(); + _SetIntArrayRegion(array, start, len, buf).check(); + + late final _SetLongArrayRegion = ptr.ref.SetLongArrayRegion.asFunction< + JThrowablePtr Function(JLongArrayPtr array, int start, int len, + ffi.Pointer buf)>(); void SetLongArrayRegion(JLongArrayPtr array, int start, int len, ffi.Pointer buf) => - ref.SetLongArrayRegion.asFunction< - JThrowablePtr Function(JLongArrayPtr array, int start, int len, - ffi.Pointer buf)>()(array, start, len, buf) - .check(); + _SetLongArrayRegion(array, start, len, buf).check(); + + late final _SetFloatArrayRegion = ptr.ref.SetFloatArrayRegion.asFunction< + JThrowablePtr Function(JFloatArrayPtr array, int start, int len, + ffi.Pointer buf)>(); void SetFloatArrayRegion(JFloatArrayPtr array, int start, int len, ffi.Pointer buf) => - ref.SetFloatArrayRegion.asFunction< - JThrowablePtr Function(JFloatArrayPtr array, int start, int len, - ffi.Pointer buf)>()(array, start, len, buf) - .check(); + _SetFloatArrayRegion(array, start, len, buf).check(); + + late final _SetDoubleArrayRegion = ptr.ref.SetDoubleArrayRegion.asFunction< + JThrowablePtr Function(JDoubleArrayPtr array, int start, int len, + ffi.Pointer buf)>(); void SetDoubleArrayRegion(JDoubleArrayPtr array, int start, int len, ffi.Pointer buf) => - ref.SetDoubleArrayRegion.asFunction< - JThrowablePtr Function(JDoubleArrayPtr array, int start, int len, - ffi.Pointer buf)>()(array, start, len, buf) - .check(); + _SetDoubleArrayRegion(array, start, len, buf).check(); + + late final _RegisterNatives = ptr.ref.RegisterNatives.asFunction< + JniResult Function(JClassPtr clazz, ffi.Pointer methods, + int nMethods)>(); int RegisterNatives(JClassPtr clazz, ffi.Pointer methods, int nMethods) => - ref.RegisterNatives.asFunction< - JniResult Function( - JClassPtr clazz, - ffi.Pointer methods, - int nMethods)>()(clazz, methods, nMethods) - .integer; - - int UnregisterNatives(JClassPtr clazz) => - ref.UnregisterNatives.asFunction()( - clazz) - .integer; - - int MonitorEnter(JObjectPtr obj) => - ref.MonitorEnter.asFunction()(obj) - .integer; - - int MonitorExit(JObjectPtr obj) => - ref.MonitorExit.asFunction()(obj) - .integer; - - int GetJavaVM(ffi.Pointer> vm) => - ref.GetJavaVM.asFunction< - JniResult Function(ffi.Pointer> vm)>()(vm) - .integer; + _RegisterNatives(clazz, methods, nMethods).integer; + + late final _UnregisterNatives = ptr.ref.UnregisterNatives + .asFunction(); + + int UnregisterNatives(JClassPtr clazz) => _UnregisterNatives(clazz).integer; + + late final _MonitorEnter = + ptr.ref.MonitorEnter.asFunction(); + + int MonitorEnter(JObjectPtr obj) => _MonitorEnter(obj).integer; + + late final _MonitorExit = + ptr.ref.MonitorExit.asFunction(); + + int MonitorExit(JObjectPtr obj) => _MonitorExit(obj).integer; + + late final _GetJavaVM = ptr.ref.GetJavaVM + .asFunction> vm)>(); + + int GetJavaVM(ffi.Pointer> vm) => _GetJavaVM(vm).integer; + + late final _GetStringRegion = ptr.ref.GetStringRegion.asFunction< + JThrowablePtr Function( + JStringPtr str, int start, int len, ffi.Pointer buf)>(); void GetStringRegion( JStringPtr str, int start, int len, ffi.Pointer buf) => - ref.GetStringRegion.asFunction< - JThrowablePtr Function(JStringPtr str, int start, int len, - ffi.Pointer buf)>()(str, start, len, buf) - .check(); + _GetStringRegion(str, start, len, buf).check(); + + late final _GetStringUTFRegion = ptr.ref.GetStringUTFRegion.asFunction< + JThrowablePtr Function( + JStringPtr str, int start, int len, ffi.Pointer buf)>(); void GetStringUTFRegion( JStringPtr str, int start, int len, ffi.Pointer buf) => - ref.GetStringUTFRegion.asFunction< - JThrowablePtr Function(JStringPtr str, int start, int len, - ffi.Pointer buf)>()(str, start, len, buf) - .check(); + _GetStringUTFRegion(str, start, len, buf).check(); + + late final _GetPrimitiveArrayCritical = ptr.ref.GetPrimitiveArrayCritical + .asFunction< + JniPointerResult Function( + JArrayPtr array, ffi.Pointer isCopy)>(); ffi.Pointer GetPrimitiveArrayCritical( JArrayPtr array, ffi.Pointer isCopy) => - ref.GetPrimitiveArrayCritical.asFunction< - JniPointerResult Function(JArrayPtr array, - ffi.Pointer isCopy)>()(array, isCopy) - .getPointer(); + _GetPrimitiveArrayCritical(array, isCopy).getPointer(); + + late final _ReleasePrimitiveArrayCritical = + ptr.ref.ReleasePrimitiveArrayCritical.asFunction< + JThrowablePtr Function( + JArrayPtr array, ffi.Pointer carray, int mode)>(); void ReleasePrimitiveArrayCritical( JArrayPtr array, ffi.Pointer carray, int mode) => - ref.ReleasePrimitiveArrayCritical.asFunction< - JThrowablePtr Function( - JArrayPtr array, - ffi.Pointer carray, - int mode)>()(array, carray, mode) - .check(); + _ReleasePrimitiveArrayCritical(array, carray, mode).check(); + + late final _GetStringCritical = ptr.ref.GetStringCritical.asFunction< + JniPointerResult Function( + JStringPtr str, ffi.Pointer isCopy)>(); ffi.Pointer GetStringCritical( JStringPtr str, ffi.Pointer isCopy) => - ref.GetStringCritical.asFunction< - JniPointerResult Function(JStringPtr str, - ffi.Pointer isCopy)>()(str, isCopy) - .getPointer(); + _GetStringCritical(str, isCopy).getPointer(); + + late final _ReleaseStringCritical = ptr.ref.ReleaseStringCritical.asFunction< + JThrowablePtr Function( + JStringPtr str, ffi.Pointer carray)>(); void ReleaseStringCritical(JStringPtr str, ffi.Pointer carray) => - ref.ReleaseStringCritical.asFunction< - JThrowablePtr Function(JStringPtr str, - ffi.Pointer carray)>()(str, carray) - .check(); + _ReleaseStringCritical(str, carray).check(); + + late final _NewWeakGlobalRef = + ptr.ref.NewWeakGlobalRef.asFunction(); - JWeakPtr NewWeakGlobalRef(JObjectPtr obj) => - ref.NewWeakGlobalRef.asFunction()(obj) - .object; + JWeakPtr NewWeakGlobalRef(JObjectPtr obj) => _NewWeakGlobalRef(obj).object; - void DeleteWeakGlobalRef(JWeakPtr obj) => ref.DeleteWeakGlobalRef.asFunction< - JThrowablePtr Function(JWeakPtr obj)>()(obj) - .check(); + late final _DeleteWeakGlobalRef = ptr.ref.DeleteWeakGlobalRef + .asFunction(); - bool ExceptionCheck() => - ref.ExceptionCheck.asFunction()().boolean; + void DeleteWeakGlobalRef(JWeakPtr obj) => _DeleteWeakGlobalRef(obj).check(); + + late final _ExceptionCheck = + ptr.ref.ExceptionCheck.asFunction(); + + bool ExceptionCheck() => _ExceptionCheck().boolean; + + late final _NewDirectByteBuffer = ptr.ref.NewDirectByteBuffer.asFunction< + JniResult Function(ffi.Pointer address, int capacity)>(); JObjectPtr NewDirectByteBuffer(ffi.Pointer address, int capacity) => - ref.NewDirectByteBuffer.asFunction< - JniResult Function(ffi.Pointer address, - int capacity)>()(address, capacity) - .object; + _NewDirectByteBuffer(address, capacity).object; + + late final _GetDirectBufferAddress = ptr.ref.GetDirectBufferAddress + .asFunction(); ffi.Pointer GetDirectBufferAddress(JObjectPtr buf) => - ref.GetDirectBufferAddress.asFunction< - JniPointerResult Function(JObjectPtr buf)>()(buf) - .getPointer(); + _GetDirectBufferAddress(buf).getPointer(); - int GetDirectBufferCapacity(JObjectPtr buf) => ref.GetDirectBufferCapacity - .asFunction()(buf) - .long; + late final _GetDirectBufferCapacity = ptr.ref.GetDirectBufferCapacity + .asFunction(); - int GetObjectRefType(JObjectPtr obj) => - ref.GetObjectRefType.asFunction()(obj) - .integer; + int GetDirectBufferCapacity(JObjectPtr buf) => + _GetDirectBufferCapacity(buf).long; + + late final _GetObjectRefType = + ptr.ref.GetObjectRefType.asFunction(); + + int GetObjectRefType(JObjectPtr obj) => _GetObjectRefType(obj).integer; } -extension JniAccessorsExtension on ffi.Pointer { +/// Wraps over the function pointers in JniAccessorsStruct and exposes them as methods. +class JniAccessors { + final ffi.Pointer ptr; + JniAccessors(this.ptr); + + late final _getClass = ptr.ref.getClass.asFunction< + JniClassLookupResult Function(ffi.Pointer internalName)>(); JniClassLookupResult getClass(ffi.Pointer internalName) => - ref.getClass.asFunction< - JniClassLookupResult Function( - ffi.Pointer internalName)>()(internalName); + _getClass(internalName); + late final _getFieldID = ptr.ref.getFieldID.asFunction< + JniPointerResult Function(JClassPtr cls, ffi.Pointer fieldName, + ffi.Pointer signature)>(); JniPointerResult getFieldID(JClassPtr cls, ffi.Pointer fieldName, ffi.Pointer signature) => - ref.getFieldID.asFunction< - JniPointerResult Function( - JClassPtr cls, - ffi.Pointer fieldName, - ffi.Pointer signature)>()(cls, fieldName, signature); + _getFieldID(cls, fieldName, signature); + late final _getStaticFieldID = ptr.ref.getStaticFieldID.asFunction< + JniPointerResult Function(JClassPtr cls, ffi.Pointer fieldName, + ffi.Pointer signature)>(); JniPointerResult getStaticFieldID(JClassPtr cls, ffi.Pointer fieldName, ffi.Pointer signature) => - ref.getStaticFieldID.asFunction< - JniPointerResult Function( - JClassPtr cls, - ffi.Pointer fieldName, - ffi.Pointer signature)>()(cls, fieldName, signature); + _getStaticFieldID(cls, fieldName, signature); + late final _getMethodID = ptr.ref.getMethodID.asFunction< + JniPointerResult Function(JClassPtr cls, ffi.Pointer methodName, + ffi.Pointer signature)>(); JniPointerResult getMethodID(JClassPtr cls, ffi.Pointer methodName, ffi.Pointer signature) => - ref.getMethodID.asFunction< - JniPointerResult Function( - JClassPtr cls, - ffi.Pointer methodName, - ffi.Pointer signature)>()(cls, methodName, signature); + _getMethodID(cls, methodName, signature); + late final _getStaticMethodID = ptr.ref.getStaticMethodID.asFunction< + JniPointerResult Function(JClassPtr cls, ffi.Pointer methodName, + ffi.Pointer signature)>(); JniPointerResult getStaticMethodID(JClassPtr cls, ffi.Pointer methodName, ffi.Pointer signature) => - ref.getStaticMethodID.asFunction< - JniPointerResult Function( - JClassPtr cls, - ffi.Pointer methodName, - ffi.Pointer signature)>()(cls, methodName, signature); + _getStaticMethodID(cls, methodName, signature); + late final _newObject = ptr.ref.newObject.asFunction< + JniResult Function( + JClassPtr cls, JMethodIDPtr ctor, ffi.Pointer args)>(); JniResult newObject( JClassPtr cls, JMethodIDPtr ctor, ffi.Pointer args) => - ref.newObject.asFunction< - JniResult Function(JClassPtr cls, JMethodIDPtr ctor, - ffi.Pointer args)>()(cls, ctor, args); + _newObject(cls, ctor, args); + late final _newPrimitiveArray = ptr.ref.newPrimitiveArray + .asFunction(); JniPointerResult newPrimitiveArray(int length, int type) => - ref.newPrimitiveArray - .asFunction()( - length, type); + _newPrimitiveArray(length, type); + late final _newObjectArray = ptr.ref.newObjectArray.asFunction< + JniPointerResult Function( + int length, JClassPtr elementClass, JObjectPtr initialElement)>(); JniPointerResult newObjectArray( int length, JClassPtr elementClass, JObjectPtr initialElement) => - ref.newObjectArray.asFunction< - JniPointerResult Function(int length, JClassPtr elementClass, - JObjectPtr initialElement)>()( - length, elementClass, initialElement); + _newObjectArray(length, elementClass, initialElement); + late final _getArrayElement = ptr.ref.getArrayElement + .asFunction(); JniResult getArrayElement(JArrayPtr array, int index, int type) => - ref.getArrayElement.asFunction< - JniResult Function( - JArrayPtr array, int index, int type)>()(array, index, type); + _getArrayElement(array, index, type); + late final _callMethod = ptr.ref.callMethod.asFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, int callType, + ffi.Pointer args)>(); JniResult callMethod(JObjectPtr obj, JMethodIDPtr methodID, int callType, ffi.Pointer args) => - ref.callMethod.asFunction< - JniResult Function( - JObjectPtr obj, - JMethodIDPtr methodID, - int callType, - ffi.Pointer args)>()(obj, methodID, callType, args); + _callMethod(obj, methodID, callType, args); + late final _callStaticMethod = ptr.ref.callStaticMethod.asFunction< + JniResult Function(JClassPtr cls, JMethodIDPtr methodID, int callType, + ffi.Pointer args)>(); JniResult callStaticMethod(JClassPtr cls, JMethodIDPtr methodID, int callType, ffi.Pointer args) => - ref.callStaticMethod.asFunction< - JniResult Function(JClassPtr cls, JMethodIDPtr methodID, int callType, - ffi.Pointer args)>()(cls, methodID, callType, args); + _callStaticMethod(cls, methodID, callType, args); + late final _getField = ptr.ref.getField.asFunction< + JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID, int callType)>(); JniResult getField(JObjectPtr obj, JFieldIDPtr fieldID, int callType) => - ref.getField.asFunction< - JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID, - int callType)>()(obj, fieldID, callType); + _getField(obj, fieldID, callType); + late final _getStaticField = ptr.ref.getStaticField.asFunction< + JniResult Function(JClassPtr cls, JFieldIDPtr fieldID, int callType)>(); JniResult getStaticField(JClassPtr cls, JFieldIDPtr fieldID, int callType) => - ref.getStaticField.asFunction< - JniResult Function(JClassPtr cls, JFieldIDPtr fieldID, - int callType)>()(cls, fieldID, callType); - - JniExceptionDetails getExceptionDetails(JThrowablePtr exception) => ref - .getExceptionDetails - .asFunction()( - exception); + _getStaticField(cls, fieldID, callType); + + late final _getExceptionDetails = ptr.ref.getExceptionDetails + .asFunction(); + JniExceptionDetails getExceptionDetails(JThrowablePtr exception) => + _getExceptionDetails(exception); } 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 eb5ba0bfd..6d54cda41 100644 --- a/pkgs/jni/lib/src/third_party/jni_bindings_generated.dart +++ b/pkgs/jni/lib/src/third_party/jni_bindings_generated.dart @@ -63,15 +63,15 @@ class JniBindings { lookup) : _lookup = lookup; - ffi.Pointer GetAccessors() { + ffi.Pointer GetAccessors() { return _GetAccessors(); } late final _GetAccessorsPtr = - _lookup Function()>>( + _lookup Function()>>( 'GetAccessors'); late final _GetAccessors = - _GetAccessorsPtr.asFunction Function()>(); + _GetAccessorsPtr.asFunction Function()>(); ffi.Pointer GetJavaVM() { return _GetJavaVM(); @@ -192,15 +192,15 @@ class JniBindings { late final _PortContinuation__ctor = _PortContinuation__ctorPtr.asFunction(); - ffi.Pointer GetGlobalEnv() { + ffi.Pointer GetGlobalEnv() { return _GetGlobalEnv(); } late final _GetGlobalEnvPtr = - _lookup Function()>>( + _lookup Function()>>( 'GetGlobalEnv'); late final _GetGlobalEnv = - _GetGlobalEnvPtr.asFunction Function()>(); + _GetGlobalEnvPtr.asFunction Function()>(); } /// Types used by JNI API to distinguish between primitive types. @@ -301,7 +301,7 @@ typedef JStringPtr = JObjectPtr; /// Flutter embedding checks for pending JNI exceptions before an FFI transition, which requires us /// to check for and clear the exception before returning to dart code, which requires these functions /// to return result types. -class JniAccessors extends ffi.Struct { +class JniAccessorsStruct extends ffi.Struct { external ffi.Pointer< ffi.NativeFunction< JniClassLookupResult Function( @@ -1936,7 +1936,7 @@ class JavaVMOption extends ffi.Struct { external ffi.Pointer extraInfo; } -class GlobalJniEnv extends ffi.Struct { +class GlobalJniEnvStruct extends ffi.Struct { external ffi.Pointer reserved0; external ffi.Pointer reserved1; diff --git a/pkgs/jni/lib/src/third_party/jnienv_javavm_extensions.dart b/pkgs/jni/lib/src/third_party/jnienv_javavm_extensions.dart deleted file mode 100644 index 7c145f990..000000000 --- a/pkgs/jni/lib/src/third_party/jnienv_javavm_extensions.dart +++ /dev/null @@ -1,1409 +0,0 @@ -// Auto generated file. Do not edit. - -// This is generated from JNI header in Android NDK. License for the same is -// provided below. - -/* - * Copyright (C) 2006 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * JNI specification, as defined by Sun: - * http://java.sun.com/javase/6/docs/technotes/guides/jni/spec/jniTOC.html - * - * Everything here is expected to be VM-neutral. - */ - -// ignore_for_file: non_constant_identifier_names -// coverage:ignore-file - -import "dart:ffi" as ffi; - -import "jni_bindings_generated.dart"; - -extension JniEnvExtension on ffi.Pointer { - int GetVersion() => value.ref.GetVersion - .asFunction env)>()(this); - - JClassPtr DefineClass(ffi.Pointer name, JObjectPtr loader, - ffi.Pointer buf, int bufLen) => - value.ref.DefineClass.asFunction< - JClassPtr Function( - ffi.Pointer env, - ffi.Pointer name, - JObjectPtr loader, - ffi.Pointer buf, - int bufLen)>()(this, name, loader, buf, bufLen); - - JClassPtr FindClass(ffi.Pointer name) => value.ref.FindClass - .asFunction< - JClassPtr Function(ffi.Pointer env, - ffi.Pointer name)>()(this, name); - - JMethodIDPtr FromReflectedMethod(JObjectPtr method) => - value.ref.FromReflectedMethod.asFunction< - JMethodIDPtr Function( - ffi.Pointer env, JObjectPtr method)>()(this, method); - - JFieldIDPtr FromReflectedField(JObjectPtr field) => - value.ref.FromReflectedField.asFunction< - JFieldIDPtr Function( - ffi.Pointer env, JObjectPtr field)>()(this, field); - - JObjectPtr ToReflectedMethod( - JClassPtr cls, JMethodIDPtr methodId, int isStatic) => - value.ref.ToReflectedMethod.asFunction< - JObjectPtr Function( - ffi.Pointer env, - JClassPtr cls, - JMethodIDPtr methodId, - int isStatic)>()(this, cls, methodId, isStatic); - - JClassPtr GetSuperclass(JClassPtr clazz) => - value.ref.GetSuperclass.asFunction< - JClassPtr Function( - ffi.Pointer env, JClassPtr clazz)>()(this, clazz); - - int IsAssignableFrom(JClassPtr clazz1, JClassPtr clazz2) => - value.ref.IsAssignableFrom.asFunction< - int Function(ffi.Pointer env, JClassPtr clazz1, - JClassPtr clazz2)>()(this, clazz1, clazz2); - - JObjectPtr ToReflectedField( - JClassPtr cls, JFieldIDPtr fieldID, int isStatic) => - value.ref.ToReflectedField.asFunction< - JObjectPtr Function( - ffi.Pointer env, - JClassPtr cls, - JFieldIDPtr fieldID, - int isStatic)>()(this, cls, fieldID, isStatic); - - int Throw(JThrowablePtr obj) => value.ref.Throw.asFunction< - int Function(ffi.Pointer env, JThrowablePtr obj)>()(this, obj); - - int ThrowNew(JClassPtr clazz, ffi.Pointer message) => - value.ref.ThrowNew.asFunction< - int Function(ffi.Pointer env, JClassPtr clazz, - ffi.Pointer message)>()(this, clazz, message); - - JThrowablePtr ExceptionOccurred() => value.ref.ExceptionOccurred - .asFunction env)>()(this); - - void ExceptionDescribe() => value.ref.ExceptionDescribe - .asFunction env)>()(this); - - void ExceptionClear() => value.ref.ExceptionClear - .asFunction env)>()(this); - - void FatalError(ffi.Pointer msg) => value.ref.FatalError.asFunction< - void Function( - ffi.Pointer env, ffi.Pointer msg)>()(this, msg); - - int PushLocalFrame(int capacity) => value.ref.PushLocalFrame - .asFunction env, int capacity)>()( - this, capacity); - - JObjectPtr PopLocalFrame(JObjectPtr result) => value.ref.PopLocalFrame - .asFunction< - JObjectPtr Function( - ffi.Pointer env, JObjectPtr result)>()(this, result); - - JObjectPtr NewGlobalRef(JObjectPtr obj) => value.ref.NewGlobalRef.asFunction< - JObjectPtr Function( - ffi.Pointer env, JObjectPtr obj)>()(this, obj); - - void DeleteGlobalRef(JObjectPtr globalRef) => - value.ref.DeleteGlobalRef.asFunction< - void Function(ffi.Pointer env, JObjectPtr globalRef)>()( - this, globalRef); - - void DeleteLocalRef(JObjectPtr localRef) => - value.ref.DeleteLocalRef.asFunction< - void Function( - ffi.Pointer env, JObjectPtr localRef)>()(this, localRef); - - int IsSameObject(JObjectPtr ref1, JObjectPtr ref2) => - value.ref.IsSameObject.asFunction< - int Function(ffi.Pointer env, JObjectPtr ref1, - JObjectPtr ref2)>()(this, ref1, ref2); - - JObjectPtr NewLocalRef(JObjectPtr obj) => value.ref.NewLocalRef.asFunction< - JObjectPtr Function( - ffi.Pointer env, JObjectPtr obj)>()(this, obj); - - int EnsureLocalCapacity(int capacity) => value.ref.EnsureLocalCapacity - .asFunction env, int capacity)>()( - this, capacity); - - JObjectPtr AllocObject(JClassPtr clazz) => value.ref.AllocObject.asFunction< - JObjectPtr Function( - ffi.Pointer env, JClassPtr clazz)>()(this, clazz); - - JObjectPtr NewObject(JClassPtr clazz, JMethodIDPtr methodID) => - value.ref.NewObject.asFunction< - JObjectPtr Function(ffi.Pointer env, JClassPtr clazz, - JMethodIDPtr methodID)>()(this, clazz, methodID); - - JObjectPtr NewObjectA( - JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => - value.ref.NewObjectA.asFunction< - JObjectPtr Function( - ffi.Pointer env, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>()(this, clazz, methodID, args); - - JClassPtr GetObjectClass(JObjectPtr obj) => - value.ref.GetObjectClass.asFunction< - JClassPtr Function( - ffi.Pointer env, JObjectPtr obj)>()(this, obj); - - int IsInstanceOf(JObjectPtr obj, JClassPtr clazz) => - value.ref.IsInstanceOf.asFunction< - int Function(ffi.Pointer env, JObjectPtr obj, - JClassPtr clazz)>()(this, obj, clazz); - - JMethodIDPtr GetMethodID(JClassPtr clazz, ffi.Pointer name, - ffi.Pointer sig) => - value.ref.GetMethodID.asFunction< - JMethodIDPtr Function( - ffi.Pointer env, - JClassPtr clazz, - ffi.Pointer name, - ffi.Pointer sig)>()(this, clazz, name, sig); - - JObjectPtr CallObjectMethod(JObjectPtr obj, JMethodIDPtr methodID) => - value.ref.CallObjectMethod.asFunction< - JObjectPtr Function(ffi.Pointer env, JObjectPtr obj, - JMethodIDPtr methodID)>()(this, obj, methodID); - - JObjectPtr CallObjectMethodA( - JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) => - value.ref.CallObjectMethodA.asFunction< - JObjectPtr Function( - ffi.Pointer env, - JObjectPtr obj, - JMethodIDPtr methodID, - ffi.Pointer args)>()(this, obj, methodID, args); - - int CallBooleanMethod(JObjectPtr obj, JMethodIDPtr methodID) => - value.ref.CallBooleanMethod.asFunction< - int Function(ffi.Pointer env, JObjectPtr obj, - JMethodIDPtr methodID)>()(this, obj, methodID); - - int CallBooleanMethodA( - JObjectPtr obj, JMethodIDPtr methodId, ffi.Pointer args) => - value.ref.CallBooleanMethodA.asFunction< - int Function( - ffi.Pointer env, - JObjectPtr obj, - JMethodIDPtr methodId, - ffi.Pointer args)>()(this, obj, methodId, args); - - int CallByteMethod(JObjectPtr obj, JMethodIDPtr methodID) => - value.ref.CallByteMethod.asFunction< - int Function(ffi.Pointer env, JObjectPtr obj, - JMethodIDPtr methodID)>()(this, obj, methodID); - - int CallByteMethodA( - JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) => - value.ref.CallByteMethodA.asFunction< - int Function( - ffi.Pointer env, - JObjectPtr obj, - JMethodIDPtr methodID, - ffi.Pointer args)>()(this, obj, methodID, args); - - int CallCharMethod(JObjectPtr obj, JMethodIDPtr methodID) => - value.ref.CallCharMethod.asFunction< - int Function(ffi.Pointer env, JObjectPtr obj, - JMethodIDPtr methodID)>()(this, obj, methodID); - - int CallCharMethodA( - JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) => - value.ref.CallCharMethodA.asFunction< - int Function( - ffi.Pointer env, - JObjectPtr obj, - JMethodIDPtr methodID, - ffi.Pointer args)>()(this, obj, methodID, args); - - int CallShortMethod(JObjectPtr obj, JMethodIDPtr methodID) => - value.ref.CallShortMethod.asFunction< - int Function(ffi.Pointer env, JObjectPtr obj, - JMethodIDPtr methodID)>()(this, obj, methodID); - - int CallShortMethodA( - JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) => - value.ref.CallShortMethodA.asFunction< - int Function( - ffi.Pointer env, - JObjectPtr obj, - JMethodIDPtr methodID, - ffi.Pointer args)>()(this, obj, methodID, args); - - int CallIntMethod(JObjectPtr obj, JMethodIDPtr methodID) => - value.ref.CallIntMethod.asFunction< - int Function(ffi.Pointer env, JObjectPtr obj, - JMethodIDPtr methodID)>()(this, obj, methodID); - - int CallIntMethodA( - JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) => - value.ref.CallIntMethodA.asFunction< - int Function( - ffi.Pointer env, - JObjectPtr obj, - JMethodIDPtr methodID, - ffi.Pointer args)>()(this, obj, methodID, args); - - int CallLongMethod(JObjectPtr obj, JMethodIDPtr methodID) => - value.ref.CallLongMethod.asFunction< - int Function(ffi.Pointer env, JObjectPtr obj, - JMethodIDPtr methodID)>()(this, obj, methodID); - - int CallLongMethodA( - JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) => - value.ref.CallLongMethodA.asFunction< - int Function( - ffi.Pointer env, - JObjectPtr obj, - JMethodIDPtr methodID, - ffi.Pointer args)>()(this, obj, methodID, args); - - double CallFloatMethod(JObjectPtr obj, JMethodIDPtr methodID) => - value.ref.CallFloatMethod.asFunction< - double Function(ffi.Pointer env, JObjectPtr obj, - JMethodIDPtr methodID)>()(this, obj, methodID); - - double CallFloatMethodA( - JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) => - value.ref.CallFloatMethodA.asFunction< - double Function( - ffi.Pointer env, - JObjectPtr obj, - JMethodIDPtr methodID, - ffi.Pointer args)>()(this, obj, methodID, args); - - double CallDoubleMethod(JObjectPtr obj, JMethodIDPtr methodID) => - value.ref.CallDoubleMethod.asFunction< - double Function(ffi.Pointer env, JObjectPtr obj, - JMethodIDPtr methodID)>()(this, obj, methodID); - - double CallDoubleMethodA( - JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) => - value.ref.CallDoubleMethodA.asFunction< - double Function( - ffi.Pointer env, - JObjectPtr obj, - JMethodIDPtr methodID, - ffi.Pointer args)>()(this, obj, methodID, args); - - void CallVoidMethod(JObjectPtr obj, JMethodIDPtr methodID) => - value.ref.CallVoidMethod.asFunction< - void Function(ffi.Pointer env, JObjectPtr obj, - JMethodIDPtr methodID)>()(this, obj, methodID); - - void CallVoidMethodA( - JObjectPtr obj, JMethodIDPtr methodID, ffi.Pointer args) => - value.ref.CallVoidMethodA.asFunction< - void Function( - ffi.Pointer env, - JObjectPtr obj, - JMethodIDPtr methodID, - ffi.Pointer args)>()(this, obj, methodID, args); - - JObjectPtr CallNonvirtualObjectMethod( - JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => - value.ref.CallNonvirtualObjectMethod.asFunction< - JObjectPtr Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID)>()(this, obj, clazz, methodID); - - JObjectPtr CallNonvirtualObjectMethodA(JObjectPtr obj, JClassPtr clazz, - JMethodIDPtr methodID, ffi.Pointer args) => - value.ref.CallNonvirtualObjectMethodA.asFunction< - JObjectPtr Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>()(this, obj, clazz, methodID, args); - - int CallNonvirtualBooleanMethod( - JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => - value.ref.CallNonvirtualBooleanMethod.asFunction< - int Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID)>()(this, obj, clazz, methodID); - - int CallNonvirtualBooleanMethodA(JObjectPtr obj, JClassPtr clazz, - JMethodIDPtr methodID, ffi.Pointer args) => - value.ref.CallNonvirtualBooleanMethodA.asFunction< - int Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>()(this, obj, clazz, methodID, args); - - int CallNonvirtualByteMethod( - JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => - value.ref.CallNonvirtualByteMethod.asFunction< - int Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID)>()(this, obj, clazz, methodID); - - int CallNonvirtualByteMethodA(JObjectPtr obj, JClassPtr clazz, - JMethodIDPtr methodID, ffi.Pointer args) => - value.ref.CallNonvirtualByteMethodA.asFunction< - int Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>()(this, obj, clazz, methodID, args); - - int CallNonvirtualCharMethod( - JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => - value.ref.CallNonvirtualCharMethod.asFunction< - int Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID)>()(this, obj, clazz, methodID); - - int CallNonvirtualCharMethodA(JObjectPtr obj, JClassPtr clazz, - JMethodIDPtr methodID, ffi.Pointer args) => - value.ref.CallNonvirtualCharMethodA.asFunction< - int Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>()(this, obj, clazz, methodID, args); - - int CallNonvirtualShortMethod( - JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => - value.ref.CallNonvirtualShortMethod.asFunction< - int Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID)>()(this, obj, clazz, methodID); - - int CallNonvirtualShortMethodA(JObjectPtr obj, JClassPtr clazz, - JMethodIDPtr methodID, ffi.Pointer args) => - value.ref.CallNonvirtualShortMethodA.asFunction< - int Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>()(this, obj, clazz, methodID, args); - - int CallNonvirtualIntMethod( - JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => - value.ref.CallNonvirtualIntMethod.asFunction< - int Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID)>()(this, obj, clazz, methodID); - - int CallNonvirtualIntMethodA(JObjectPtr obj, JClassPtr clazz, - JMethodIDPtr methodID, ffi.Pointer args) => - value.ref.CallNonvirtualIntMethodA.asFunction< - int Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>()(this, obj, clazz, methodID, args); - - int CallNonvirtualLongMethod( - JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => - value.ref.CallNonvirtualLongMethod.asFunction< - int Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID)>()(this, obj, clazz, methodID); - - int CallNonvirtualLongMethodA(JObjectPtr obj, JClassPtr clazz, - JMethodIDPtr methodID, ffi.Pointer args) => - value.ref.CallNonvirtualLongMethodA.asFunction< - int Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>()(this, obj, clazz, methodID, args); - - double CallNonvirtualFloatMethod( - JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => - value.ref.CallNonvirtualFloatMethod.asFunction< - double Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID)>()(this, obj, clazz, methodID); - - double CallNonvirtualFloatMethodA(JObjectPtr obj, JClassPtr clazz, - JMethodIDPtr methodID, ffi.Pointer args) => - value.ref.CallNonvirtualFloatMethodA.asFunction< - double Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>()(this, obj, clazz, methodID, args); - - double CallNonvirtualDoubleMethod( - JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => - value.ref.CallNonvirtualDoubleMethod.asFunction< - double Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID)>()(this, obj, clazz, methodID); - - double CallNonvirtualDoubleMethodA(JObjectPtr obj, JClassPtr clazz, - JMethodIDPtr methodID, ffi.Pointer args) => - value.ref.CallNonvirtualDoubleMethodA.asFunction< - double Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>()(this, obj, clazz, methodID, args); - - void CallNonvirtualVoidMethod( - JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID) => - value.ref.CallNonvirtualVoidMethod.asFunction< - void Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID)>()(this, obj, clazz, methodID); - - void CallNonvirtualVoidMethodA(JObjectPtr obj, JClassPtr clazz, - JMethodIDPtr methodID, ffi.Pointer args) => - value.ref.CallNonvirtualVoidMethodA.asFunction< - void Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>()(this, obj, clazz, methodID, args); - - JFieldIDPtr GetFieldID(JClassPtr clazz, ffi.Pointer name, - ffi.Pointer sig) => - value.ref.GetFieldID.asFunction< - JFieldIDPtr Function( - ffi.Pointer env, - JClassPtr clazz, - ffi.Pointer name, - ffi.Pointer sig)>()(this, clazz, name, sig); - - JObjectPtr GetObjectField(JObjectPtr obj, JFieldIDPtr fieldID) => - value.ref.GetObjectField.asFunction< - JObjectPtr Function(ffi.Pointer env, JObjectPtr obj, - JFieldIDPtr fieldID)>()(this, obj, fieldID); - - int GetBooleanField(JObjectPtr obj, JFieldIDPtr fieldID) => - value.ref.GetBooleanField.asFunction< - int Function(ffi.Pointer env, JObjectPtr obj, - JFieldIDPtr fieldID)>()(this, obj, fieldID); - - int GetByteField(JObjectPtr obj, JFieldIDPtr fieldID) => - value.ref.GetByteField.asFunction< - int Function(ffi.Pointer env, JObjectPtr obj, - JFieldIDPtr fieldID)>()(this, obj, fieldID); - - int GetCharField(JObjectPtr obj, JFieldIDPtr fieldID) => - value.ref.GetCharField.asFunction< - int Function(ffi.Pointer env, JObjectPtr obj, - JFieldIDPtr fieldID)>()(this, obj, fieldID); - - int GetShortField(JObjectPtr obj, JFieldIDPtr fieldID) => - value.ref.GetShortField.asFunction< - int Function(ffi.Pointer env, JObjectPtr obj, - JFieldIDPtr fieldID)>()(this, obj, fieldID); - - int GetIntField(JObjectPtr obj, JFieldIDPtr fieldID) => - value.ref.GetIntField.asFunction< - int Function(ffi.Pointer env, JObjectPtr obj, - JFieldIDPtr fieldID)>()(this, obj, fieldID); - - int GetLongField(JObjectPtr obj, JFieldIDPtr fieldID) => - value.ref.GetLongField.asFunction< - int Function(ffi.Pointer env, JObjectPtr obj, - JFieldIDPtr fieldID)>()(this, obj, fieldID); - - double GetFloatField(JObjectPtr obj, JFieldIDPtr fieldID) => - value.ref.GetFloatField.asFunction< - double Function(ffi.Pointer env, JObjectPtr obj, - JFieldIDPtr fieldID)>()(this, obj, fieldID); - - double GetDoubleField(JObjectPtr obj, JFieldIDPtr fieldID) => - value.ref.GetDoubleField.asFunction< - double Function(ffi.Pointer env, JObjectPtr obj, - JFieldIDPtr fieldID)>()(this, obj, fieldID); - - void SetObjectField(JObjectPtr obj, JFieldIDPtr fieldID, JObjectPtr val) => - value.ref.SetObjectField.asFunction< - void Function(ffi.Pointer env, JObjectPtr obj, - JFieldIDPtr fieldID, JObjectPtr val)>()(this, obj, fieldID, val); - - void SetBooleanField(JObjectPtr obj, JFieldIDPtr fieldID, int val) => - value.ref.SetBooleanField.asFunction< - void Function(ffi.Pointer env, JObjectPtr obj, - JFieldIDPtr fieldID, int val)>()(this, obj, fieldID, val); - - void SetByteField(JObjectPtr obj, JFieldIDPtr fieldID, int val) => - value.ref.SetByteField.asFunction< - void Function(ffi.Pointer env, JObjectPtr obj, - JFieldIDPtr fieldID, int val)>()(this, obj, fieldID, val); - - void SetCharField(JObjectPtr obj, JFieldIDPtr fieldID, int val) => - value.ref.SetCharField.asFunction< - void Function(ffi.Pointer env, JObjectPtr obj, - JFieldIDPtr fieldID, int val)>()(this, obj, fieldID, val); - - void SetShortField(JObjectPtr obj, JFieldIDPtr fieldID, int val) => - value.ref.SetShortField.asFunction< - void Function(ffi.Pointer env, JObjectPtr obj, - JFieldIDPtr fieldID, int val)>()(this, obj, fieldID, val); - - void SetIntField(JObjectPtr obj, JFieldIDPtr fieldID, int val) => - value.ref.SetIntField.asFunction< - void Function(ffi.Pointer env, JObjectPtr obj, - JFieldIDPtr fieldID, int val)>()(this, obj, fieldID, val); - - void SetLongField(JObjectPtr obj, JFieldIDPtr fieldID, int val) => - value.ref.SetLongField.asFunction< - void Function(ffi.Pointer env, JObjectPtr obj, - JFieldIDPtr fieldID, int val)>()(this, obj, fieldID, val); - - void SetFloatField(JObjectPtr obj, JFieldIDPtr fieldID, double val) => - value.ref.SetFloatField.asFunction< - void Function(ffi.Pointer env, JObjectPtr obj, - JFieldIDPtr fieldID, double val)>()(this, obj, fieldID, val); - - void SetDoubleField(JObjectPtr obj, JFieldIDPtr fieldID, double val) => - value.ref.SetDoubleField.asFunction< - void Function(ffi.Pointer env, JObjectPtr obj, - JFieldIDPtr fieldID, double val)>()(this, obj, fieldID, val); - - JMethodIDPtr GetStaticMethodID(JClassPtr clazz, ffi.Pointer name, - ffi.Pointer sig) => - value.ref.GetStaticMethodID.asFunction< - JMethodIDPtr Function( - ffi.Pointer env, - JClassPtr clazz, - ffi.Pointer name, - ffi.Pointer sig)>()(this, clazz, name, sig); - - JObjectPtr CallStaticObjectMethod(JClassPtr clazz, JMethodIDPtr methodID) => - value.ref.CallStaticObjectMethod.asFunction< - JObjectPtr Function(ffi.Pointer env, JClassPtr clazz, - JMethodIDPtr methodID)>()(this, clazz, methodID); - - JObjectPtr CallStaticObjectMethodA( - JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => - value.ref.CallStaticObjectMethodA.asFunction< - JObjectPtr Function( - ffi.Pointer env, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>()(this, clazz, methodID, args); - - int CallStaticBooleanMethod(JClassPtr clazz, JMethodIDPtr methodID) => - value.ref.CallStaticBooleanMethod.asFunction< - int Function(ffi.Pointer env, JClassPtr clazz, - JMethodIDPtr methodID)>()(this, clazz, methodID); - - int CallStaticBooleanMethodA( - JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => - value.ref.CallStaticBooleanMethodA.asFunction< - int Function( - ffi.Pointer env, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>()(this, clazz, methodID, args); - - int CallStaticByteMethod(JClassPtr clazz, JMethodIDPtr methodID) => - value.ref.CallStaticByteMethod.asFunction< - int Function(ffi.Pointer env, JClassPtr clazz, - JMethodIDPtr methodID)>()(this, clazz, methodID); - - int CallStaticByteMethodA( - JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => - value.ref.CallStaticByteMethodA.asFunction< - int Function( - ffi.Pointer env, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>()(this, clazz, methodID, args); - - int CallStaticCharMethod(JClassPtr clazz, JMethodIDPtr methodID) => - value.ref.CallStaticCharMethod.asFunction< - int Function(ffi.Pointer env, JClassPtr clazz, - JMethodIDPtr methodID)>()(this, clazz, methodID); - - int CallStaticCharMethodA( - JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => - value.ref.CallStaticCharMethodA.asFunction< - int Function( - ffi.Pointer env, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>()(this, clazz, methodID, args); - - int CallStaticShortMethod(JClassPtr clazz, JMethodIDPtr methodID) => - value.ref.CallStaticShortMethod.asFunction< - int Function(ffi.Pointer env, JClassPtr clazz, - JMethodIDPtr methodID)>()(this, clazz, methodID); - - int CallStaticShortMethodA( - JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => - value.ref.CallStaticShortMethodA.asFunction< - int Function( - ffi.Pointer env, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>()(this, clazz, methodID, args); - - int CallStaticIntMethod(JClassPtr clazz, JMethodIDPtr methodID) => - value.ref.CallStaticIntMethod.asFunction< - int Function(ffi.Pointer env, JClassPtr clazz, - JMethodIDPtr methodID)>()(this, clazz, methodID); - - int CallStaticIntMethodA( - JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => - value.ref.CallStaticIntMethodA.asFunction< - int Function( - ffi.Pointer env, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>()(this, clazz, methodID, args); - - int CallStaticLongMethod(JClassPtr clazz, JMethodIDPtr methodID) => - value.ref.CallStaticLongMethod.asFunction< - int Function(ffi.Pointer env, JClassPtr clazz, - JMethodIDPtr methodID)>()(this, clazz, methodID); - - int CallStaticLongMethodA( - JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => - value.ref.CallStaticLongMethodA.asFunction< - int Function( - ffi.Pointer env, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>()(this, clazz, methodID, args); - - double CallStaticFloatMethod(JClassPtr clazz, JMethodIDPtr methodID) => - value.ref.CallStaticFloatMethod.asFunction< - double Function(ffi.Pointer env, JClassPtr clazz, - JMethodIDPtr methodID)>()(this, clazz, methodID); - - double CallStaticFloatMethodA( - JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => - value.ref.CallStaticFloatMethodA.asFunction< - double Function( - ffi.Pointer env, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>()(this, clazz, methodID, args); - - double CallStaticDoubleMethod(JClassPtr clazz, JMethodIDPtr methodID) => - value.ref.CallStaticDoubleMethod.asFunction< - double Function(ffi.Pointer env, JClassPtr clazz, - JMethodIDPtr methodID)>()(this, clazz, methodID); - - double CallStaticDoubleMethodA( - JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => - value.ref.CallStaticDoubleMethodA.asFunction< - double Function( - ffi.Pointer env, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>()(this, clazz, methodID, args); - - void CallStaticVoidMethod(JClassPtr clazz, JMethodIDPtr methodID) => - value.ref.CallStaticVoidMethod.asFunction< - void Function(ffi.Pointer env, JClassPtr clazz, - JMethodIDPtr methodID)>()(this, clazz, methodID); - - void CallStaticVoidMethodA( - JClassPtr clazz, JMethodIDPtr methodID, ffi.Pointer args) => - value.ref.CallStaticVoidMethodA.asFunction< - void Function( - ffi.Pointer env, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>()(this, clazz, methodID, args); - - JFieldIDPtr GetStaticFieldID(JClassPtr clazz, ffi.Pointer name, - ffi.Pointer sig) => - value.ref.GetStaticFieldID.asFunction< - JFieldIDPtr Function( - ffi.Pointer env, - JClassPtr clazz, - ffi.Pointer name, - ffi.Pointer sig)>()(this, clazz, name, sig); - - JObjectPtr GetStaticObjectField(JClassPtr clazz, JFieldIDPtr fieldID) => - value.ref.GetStaticObjectField.asFunction< - JObjectPtr Function(ffi.Pointer env, JClassPtr clazz, - JFieldIDPtr fieldID)>()(this, clazz, fieldID); - - int GetStaticBooleanField(JClassPtr clazz, JFieldIDPtr fieldID) => - value.ref.GetStaticBooleanField.asFunction< - int Function(ffi.Pointer env, JClassPtr clazz, - JFieldIDPtr fieldID)>()(this, clazz, fieldID); - - int GetStaticByteField(JClassPtr clazz, JFieldIDPtr fieldID) => - value.ref.GetStaticByteField.asFunction< - int Function(ffi.Pointer env, JClassPtr clazz, - JFieldIDPtr fieldID)>()(this, clazz, fieldID); - - int GetStaticCharField(JClassPtr clazz, JFieldIDPtr fieldID) => - value.ref.GetStaticCharField.asFunction< - int Function(ffi.Pointer env, JClassPtr clazz, - JFieldIDPtr fieldID)>()(this, clazz, fieldID); - - int GetStaticShortField(JClassPtr clazz, JFieldIDPtr fieldID) => - value.ref.GetStaticShortField.asFunction< - int Function(ffi.Pointer env, JClassPtr clazz, - JFieldIDPtr fieldID)>()(this, clazz, fieldID); - - int GetStaticIntField(JClassPtr clazz, JFieldIDPtr fieldID) => - value.ref.GetStaticIntField.asFunction< - int Function(ffi.Pointer env, JClassPtr clazz, - JFieldIDPtr fieldID)>()(this, clazz, fieldID); - - int GetStaticLongField(JClassPtr clazz, JFieldIDPtr fieldID) => - value.ref.GetStaticLongField.asFunction< - int Function(ffi.Pointer env, JClassPtr clazz, - JFieldIDPtr fieldID)>()(this, clazz, fieldID); - - double GetStaticFloatField(JClassPtr clazz, JFieldIDPtr fieldID) => - value.ref.GetStaticFloatField.asFunction< - double Function(ffi.Pointer env, JClassPtr clazz, - JFieldIDPtr fieldID)>()(this, clazz, fieldID); - - double GetStaticDoubleField(JClassPtr clazz, JFieldIDPtr fieldID) => - value.ref.GetStaticDoubleField.asFunction< - double Function(ffi.Pointer env, JClassPtr clazz, - JFieldIDPtr fieldID)>()(this, clazz, fieldID); - - void SetStaticObjectField( - JClassPtr clazz, JFieldIDPtr fieldID, JObjectPtr val) => - value.ref.SetStaticObjectField.asFunction< - void Function( - ffi.Pointer env, - JClassPtr clazz, - JFieldIDPtr fieldID, - JObjectPtr val)>()(this, clazz, fieldID, val); - - void SetStaticBooleanField(JClassPtr clazz, JFieldIDPtr fieldID, int val) => - value.ref.SetStaticBooleanField.asFunction< - void Function(ffi.Pointer env, JClassPtr clazz, - JFieldIDPtr fieldID, int val)>()(this, clazz, fieldID, val); - - void SetStaticByteField(JClassPtr clazz, JFieldIDPtr fieldID, int val) => - value.ref.SetStaticByteField.asFunction< - void Function(ffi.Pointer env, JClassPtr clazz, - JFieldIDPtr fieldID, int val)>()(this, clazz, fieldID, val); - - void SetStaticCharField(JClassPtr clazz, JFieldIDPtr fieldID, int val) => - value.ref.SetStaticCharField.asFunction< - void Function(ffi.Pointer env, JClassPtr clazz, - JFieldIDPtr fieldID, int val)>()(this, clazz, fieldID, val); - - void SetStaticShortField(JClassPtr clazz, JFieldIDPtr fieldID, int val) => - value.ref.SetStaticShortField.asFunction< - void Function(ffi.Pointer env, JClassPtr clazz, - JFieldIDPtr fieldID, int val)>()(this, clazz, fieldID, val); - - void SetStaticIntField(JClassPtr clazz, JFieldIDPtr fieldID, int val) => - value.ref.SetStaticIntField.asFunction< - void Function(ffi.Pointer env, JClassPtr clazz, - JFieldIDPtr fieldID, int val)>()(this, clazz, fieldID, val); - - void SetStaticLongField(JClassPtr clazz, JFieldIDPtr fieldID, int val) => - value.ref.SetStaticLongField.asFunction< - void Function(ffi.Pointer env, JClassPtr clazz, - JFieldIDPtr fieldID, int val)>()(this, clazz, fieldID, val); - - void SetStaticFloatField(JClassPtr clazz, JFieldIDPtr fieldID, double val) => - value.ref.SetStaticFloatField.asFunction< - void Function(ffi.Pointer env, JClassPtr clazz, - JFieldIDPtr fieldID, double val)>()(this, clazz, fieldID, val); - - void SetStaticDoubleField(JClassPtr clazz, JFieldIDPtr fieldID, double val) => - value.ref.SetStaticDoubleField.asFunction< - void Function(ffi.Pointer env, JClassPtr clazz, - JFieldIDPtr fieldID, double val)>()(this, clazz, fieldID, val); - - JStringPtr NewString(ffi.Pointer unicodeChars, int len) => - value.ref.NewString.asFunction< - JStringPtr Function( - ffi.Pointer env, - ffi.Pointer unicodeChars, - int len)>()(this, unicodeChars, len); - - int GetStringLength(JStringPtr string) => - value.ref.GetStringLength.asFunction< - int Function( - ffi.Pointer env, JStringPtr string)>()(this, string); - - ffi.Pointer GetStringChars( - JStringPtr string, ffi.Pointer isCopy) => - value.ref.GetStringChars.asFunction< - ffi.Pointer Function( - ffi.Pointer env, - JStringPtr string, - ffi.Pointer isCopy)>()(this, string, isCopy); - - void ReleaseStringChars(JStringPtr string, ffi.Pointer isCopy) => - value.ref.ReleaseStringChars.asFunction< - void Function(ffi.Pointer env, JStringPtr string, - ffi.Pointer isCopy)>()(this, string, isCopy); - - JStringPtr NewStringUTF(ffi.Pointer bytes) => - value.ref.NewStringUTF.asFunction< - JStringPtr Function(ffi.Pointer env, - ffi.Pointer bytes)>()(this, bytes); - - int GetStringUTFLength(JStringPtr string) => - value.ref.GetStringUTFLength.asFunction< - int Function( - ffi.Pointer env, JStringPtr string)>()(this, string); - - ffi.Pointer GetStringUTFChars( - JStringPtr string, ffi.Pointer isCopy) => - value.ref.GetStringUTFChars.asFunction< - ffi.Pointer Function( - ffi.Pointer env, - JStringPtr string, - ffi.Pointer isCopy)>()(this, string, isCopy); - - void ReleaseStringUTFChars(JStringPtr string, ffi.Pointer utf) => - value.ref.ReleaseStringUTFChars.asFunction< - void Function(ffi.Pointer env, JStringPtr string, - ffi.Pointer utf)>()(this, string, utf); - - int GetArrayLength(JArrayPtr array) => value.ref.GetArrayLength.asFunction< - int Function(ffi.Pointer env, JArrayPtr array)>()(this, array); - - JObjectArrayPtr NewObjectArray( - int length, JClassPtr elementClass, JObjectPtr initialElement) => - value.ref.NewObjectArray.asFunction< - JObjectArrayPtr Function(ffi.Pointer env, int length, - JClassPtr elementClass, JObjectPtr initialElement)>()( - this, length, elementClass, initialElement); - - JObjectPtr GetObjectArrayElement(JObjectArrayPtr array, int index) => - value.ref.GetObjectArrayElement.asFunction< - JObjectPtr Function(ffi.Pointer env, JObjectArrayPtr array, - int index)>()(this, array, index); - - void SetObjectArrayElement( - JObjectArrayPtr array, int index, JObjectPtr val) => - value.ref.SetObjectArrayElement.asFunction< - void Function(ffi.Pointer env, JObjectArrayPtr array, - int index, JObjectPtr val)>()(this, array, index, val); - - JBooleanArrayPtr NewBooleanArray(int length) => - value.ref.NewBooleanArray.asFunction< - JBooleanArrayPtr Function( - ffi.Pointer env, int length)>()(this, length); - - JByteArrayPtr NewByteArray(int length) => value.ref.NewByteArray.asFunction< - JByteArrayPtr Function( - ffi.Pointer env, int length)>()(this, length); - - JCharArrayPtr NewCharArray(int length) => value.ref.NewCharArray.asFunction< - JCharArrayPtr Function( - ffi.Pointer env, int length)>()(this, length); - - JShortArrayPtr NewShortArray(int length) => - value.ref.NewShortArray.asFunction< - JShortArrayPtr Function( - ffi.Pointer env, int length)>()(this, length); - - JIntArrayPtr NewIntArray(int length) => value.ref.NewIntArray.asFunction< - JIntArrayPtr Function( - ffi.Pointer env, int length)>()(this, length); - - JLongArrayPtr NewLongArray(int length) => value.ref.NewLongArray.asFunction< - JLongArrayPtr Function( - ffi.Pointer env, int length)>()(this, length); - - JFloatArrayPtr NewFloatArray(int length) => - value.ref.NewFloatArray.asFunction< - JFloatArrayPtr Function( - ffi.Pointer env, int length)>()(this, length); - - JDoubleArrayPtr NewDoubleArray(int length) => value.ref.NewDoubleArray - .asFunction< - JDoubleArrayPtr Function( - ffi.Pointer env, int length)>()(this, length); - - ffi.Pointer GetBooleanArrayElements( - JBooleanArrayPtr array, ffi.Pointer isCopy) => - value.ref.GetBooleanArrayElements.asFunction< - ffi.Pointer Function( - ffi.Pointer env, - JBooleanArrayPtr array, - ffi.Pointer isCopy)>()(this, array, isCopy); - - ffi.Pointer GetByteArrayElements( - JByteArrayPtr array, ffi.Pointer isCopy) => - value.ref.GetByteArrayElements.asFunction< - ffi.Pointer Function( - ffi.Pointer env, - JByteArrayPtr array, - ffi.Pointer isCopy)>()(this, array, isCopy); - - ffi.Pointer GetCharArrayElements( - JCharArrayPtr array, ffi.Pointer isCopy) => - value.ref.GetCharArrayElements.asFunction< - ffi.Pointer Function( - ffi.Pointer env, - JCharArrayPtr array, - ffi.Pointer isCopy)>()(this, array, isCopy); - - ffi.Pointer GetShortArrayElements( - JShortArrayPtr array, ffi.Pointer isCopy) => - value.ref.GetShortArrayElements.asFunction< - ffi.Pointer Function( - ffi.Pointer env, - JShortArrayPtr array, - ffi.Pointer isCopy)>()(this, array, isCopy); - - ffi.Pointer GetIntArrayElements( - JIntArrayPtr array, ffi.Pointer isCopy) => - value.ref.GetIntArrayElements.asFunction< - ffi.Pointer Function( - ffi.Pointer env, - JIntArrayPtr array, - ffi.Pointer isCopy)>()(this, array, isCopy); - - ffi.Pointer GetLongArrayElements( - JLongArrayPtr array, ffi.Pointer isCopy) => - value.ref.GetLongArrayElements.asFunction< - ffi.Pointer Function( - ffi.Pointer env, - JLongArrayPtr array, - ffi.Pointer isCopy)>()(this, array, isCopy); - - ffi.Pointer GetFloatArrayElements( - JFloatArrayPtr array, ffi.Pointer isCopy) => - value.ref.GetFloatArrayElements.asFunction< - ffi.Pointer Function( - ffi.Pointer env, - JFloatArrayPtr array, - ffi.Pointer isCopy)>()(this, array, isCopy); - - ffi.Pointer GetDoubleArrayElements( - JDoubleArrayPtr array, ffi.Pointer isCopy) => - value.ref.GetDoubleArrayElements.asFunction< - ffi.Pointer Function( - ffi.Pointer env, - JDoubleArrayPtr array, - ffi.Pointer isCopy)>()(this, array, isCopy); - - void ReleaseBooleanArrayElements(JBooleanArrayPtr array, - ffi.Pointer elems, int mode) => - value.ref.ReleaseBooleanArrayElements.asFunction< - void Function( - ffi.Pointer env, - JBooleanArrayPtr array, - ffi.Pointer elems, - int mode)>()(this, array, elems, mode); - - void ReleaseByteArrayElements( - JByteArrayPtr array, ffi.Pointer elems, int mode) => - value.ref.ReleaseByteArrayElements.asFunction< - void Function( - ffi.Pointer env, - JByteArrayPtr array, - ffi.Pointer elems, - int mode)>()(this, array, elems, mode); - - void ReleaseCharArrayElements( - JCharArrayPtr array, ffi.Pointer elems, int mode) => - value.ref.ReleaseCharArrayElements.asFunction< - void Function( - ffi.Pointer env, - JCharArrayPtr array, - ffi.Pointer elems, - int mode)>()(this, array, elems, mode); - - void ReleaseShortArrayElements( - JShortArrayPtr array, ffi.Pointer elems, int mode) => - value.ref.ReleaseShortArrayElements.asFunction< - void Function( - ffi.Pointer env, - JShortArrayPtr array, - ffi.Pointer elems, - int mode)>()(this, array, elems, mode); - - void ReleaseIntArrayElements( - JIntArrayPtr array, ffi.Pointer elems, int mode) => - value.ref.ReleaseIntArrayElements.asFunction< - void Function( - ffi.Pointer env, - JIntArrayPtr array, - ffi.Pointer elems, - int mode)>()(this, array, elems, mode); - - void ReleaseLongArrayElements( - JLongArrayPtr array, ffi.Pointer elems, int mode) => - value.ref.ReleaseLongArrayElements.asFunction< - void Function( - ffi.Pointer env, - JLongArrayPtr array, - ffi.Pointer elems, - int mode)>()(this, array, elems, mode); - - void ReleaseFloatArrayElements( - JFloatArrayPtr array, ffi.Pointer elems, int mode) => - value.ref.ReleaseFloatArrayElements.asFunction< - void Function( - ffi.Pointer env, - JFloatArrayPtr array, - ffi.Pointer elems, - int mode)>()(this, array, elems, mode); - - void ReleaseDoubleArrayElements( - JDoubleArrayPtr array, ffi.Pointer elems, int mode) => - value.ref.ReleaseDoubleArrayElements.asFunction< - void Function( - ffi.Pointer env, - JDoubleArrayPtr array, - ffi.Pointer elems, - int mode)>()(this, array, elems, mode); - - void GetBooleanArrayRegion(JBooleanArrayPtr array, int start, int len, - ffi.Pointer buf) => - value.ref.GetBooleanArrayRegion.asFunction< - void Function( - ffi.Pointer env, - JBooleanArrayPtr array, - int start, - int len, - ffi.Pointer buf)>()(this, array, start, len, buf); - - void GetByteArrayRegion(JByteArrayPtr array, int start, int len, - ffi.Pointer buf) => - value.ref.GetByteArrayRegion.asFunction< - void Function( - ffi.Pointer env, - JByteArrayPtr array, - int start, - int len, - ffi.Pointer buf)>()(this, array, start, len, buf); - - void GetCharArrayRegion(JCharArrayPtr array, int start, int len, - ffi.Pointer buf) => - value.ref.GetCharArrayRegion.asFunction< - void Function( - ffi.Pointer env, - JCharArrayPtr array, - int start, - int len, - ffi.Pointer buf)>()(this, array, start, len, buf); - - void GetShortArrayRegion(JShortArrayPtr array, int start, int len, - ffi.Pointer buf) => - value.ref.GetShortArrayRegion.asFunction< - void Function( - ffi.Pointer env, - JShortArrayPtr array, - int start, - int len, - ffi.Pointer buf)>()(this, array, start, len, buf); - - void GetIntArrayRegion(JIntArrayPtr array, int start, int len, - ffi.Pointer buf) => - value.ref.GetIntArrayRegion.asFunction< - void Function( - ffi.Pointer env, - JIntArrayPtr array, - int start, - int len, - ffi.Pointer buf)>()(this, array, start, len, buf); - - void GetLongArrayRegion(JLongArrayPtr array, int start, int len, - ffi.Pointer buf) => - value.ref.GetLongArrayRegion.asFunction< - void Function( - ffi.Pointer env, - JLongArrayPtr array, - int start, - int len, - ffi.Pointer buf)>()(this, array, start, len, buf); - - void GetFloatArrayRegion(JFloatArrayPtr array, int start, int len, - ffi.Pointer buf) => - value.ref.GetFloatArrayRegion.asFunction< - void Function( - ffi.Pointer env, - JFloatArrayPtr array, - int start, - int len, - ffi.Pointer buf)>()(this, array, start, len, buf); - - void GetDoubleArrayRegion(JDoubleArrayPtr array, int start, int len, - ffi.Pointer buf) => - value.ref.GetDoubleArrayRegion.asFunction< - void Function( - ffi.Pointer env, - JDoubleArrayPtr array, - int start, - int len, - ffi.Pointer buf)>()(this, array, start, len, buf); - - void SetBooleanArrayRegion(JBooleanArrayPtr array, int start, int len, - ffi.Pointer buf) => - value.ref.SetBooleanArrayRegion.asFunction< - void Function( - ffi.Pointer env, - JBooleanArrayPtr array, - int start, - int len, - ffi.Pointer buf)>()(this, array, start, len, buf); - - void SetByteArrayRegion(JByteArrayPtr array, int start, int len, - ffi.Pointer buf) => - value.ref.SetByteArrayRegion.asFunction< - void Function( - ffi.Pointer env, - JByteArrayPtr array, - int start, - int len, - ffi.Pointer buf)>()(this, array, start, len, buf); - - void SetCharArrayRegion(JCharArrayPtr array, int start, int len, - ffi.Pointer buf) => - value.ref.SetCharArrayRegion.asFunction< - void Function( - ffi.Pointer env, - JCharArrayPtr array, - int start, - int len, - ffi.Pointer buf)>()(this, array, start, len, buf); - - void SetShortArrayRegion(JShortArrayPtr array, int start, int len, - ffi.Pointer buf) => - value.ref.SetShortArrayRegion.asFunction< - void Function( - ffi.Pointer env, - JShortArrayPtr array, - int start, - int len, - ffi.Pointer buf)>()(this, array, start, len, buf); - - void SetIntArrayRegion(JIntArrayPtr array, int start, int len, - ffi.Pointer buf) => - value.ref.SetIntArrayRegion.asFunction< - void Function( - ffi.Pointer env, - JIntArrayPtr array, - int start, - int len, - ffi.Pointer buf)>()(this, array, start, len, buf); - - void SetLongArrayRegion(JLongArrayPtr array, int start, int len, - ffi.Pointer buf) => - value.ref.SetLongArrayRegion.asFunction< - void Function( - ffi.Pointer env, - JLongArrayPtr array, - int start, - int len, - ffi.Pointer buf)>()(this, array, start, len, buf); - - void SetFloatArrayRegion(JFloatArrayPtr array, int start, int len, - ffi.Pointer buf) => - value.ref.SetFloatArrayRegion.asFunction< - void Function( - ffi.Pointer env, - JFloatArrayPtr array, - int start, - int len, - ffi.Pointer buf)>()(this, array, start, len, buf); - - void SetDoubleArrayRegion(JDoubleArrayPtr array, int start, int len, - ffi.Pointer buf) => - value.ref.SetDoubleArrayRegion.asFunction< - void Function( - ffi.Pointer env, - JDoubleArrayPtr array, - int start, - int len, - ffi.Pointer buf)>()(this, array, start, len, buf); - - int RegisterNatives(JClassPtr clazz, ffi.Pointer methods, - int nMethods) => - value.ref.RegisterNatives.asFunction< - int Function( - ffi.Pointer env, - JClassPtr clazz, - ffi.Pointer methods, - int nMethods)>()(this, clazz, methods, nMethods); - - int UnregisterNatives(JClassPtr clazz) => - value.ref.UnregisterNatives.asFunction< - int Function( - ffi.Pointer env, JClassPtr clazz)>()(this, clazz); - - int MonitorEnter(JObjectPtr obj) => value.ref.MonitorEnter - .asFunction env, JObjectPtr obj)>()( - this, obj); - - int MonitorExit(JObjectPtr obj) => value.ref.MonitorExit - .asFunction env, JObjectPtr obj)>()( - this, obj); - - int GetJavaVM(ffi.Pointer> vm) => - value.ref.GetJavaVM.asFunction< - int Function(ffi.Pointer env, - ffi.Pointer> vm)>()(this, vm); - - void GetStringRegion( - JStringPtr str, int start, int len, ffi.Pointer buf) => - value.ref.GetStringRegion.asFunction< - void Function( - ffi.Pointer env, - JStringPtr str, - int start, - int len, - ffi.Pointer buf)>()(this, str, start, len, buf); - - void GetStringUTFRegion( - JStringPtr str, int start, int len, ffi.Pointer buf) => - value.ref.GetStringUTFRegion.asFunction< - void Function( - ffi.Pointer env, - JStringPtr str, - int start, - int len, - ffi.Pointer buf)>()(this, str, start, len, buf); - - ffi.Pointer GetPrimitiveArrayCritical( - JArrayPtr array, ffi.Pointer isCopy) => - value.ref.GetPrimitiveArrayCritical.asFunction< - ffi.Pointer Function( - ffi.Pointer env, - JArrayPtr array, - ffi.Pointer isCopy)>()(this, array, isCopy); - - void ReleasePrimitiveArrayCritical( - JArrayPtr array, ffi.Pointer carray, int mode) => - value.ref.ReleasePrimitiveArrayCritical.asFunction< - void Function( - ffi.Pointer env, - JArrayPtr array, - ffi.Pointer carray, - int mode)>()(this, array, carray, mode); - - ffi.Pointer GetStringCritical( - JStringPtr str, ffi.Pointer isCopy) => - value.ref.GetStringCritical.asFunction< - ffi.Pointer Function( - ffi.Pointer env, - JStringPtr str, - ffi.Pointer isCopy)>()(this, str, isCopy); - - void ReleaseStringCritical(JStringPtr str, ffi.Pointer carray) => - value.ref.ReleaseStringCritical.asFunction< - void Function(ffi.Pointer env, JStringPtr str, - ffi.Pointer carray)>()(this, str, carray); - - JWeakPtr NewWeakGlobalRef(JObjectPtr obj) => - value.ref.NewWeakGlobalRef.asFunction< - JWeakPtr Function( - ffi.Pointer env, JObjectPtr obj)>()(this, obj); - - void DeleteWeakGlobalRef(JWeakPtr obj) => value.ref.DeleteWeakGlobalRef - .asFunction env, JWeakPtr obj)>()( - this, obj); - - int ExceptionCheck() => value.ref.ExceptionCheck - .asFunction env)>()(this); - - JObjectPtr NewDirectByteBuffer(ffi.Pointer address, int capacity) => - value.ref.NewDirectByteBuffer.asFunction< - JObjectPtr Function( - ffi.Pointer env, - ffi.Pointer address, - int capacity)>()(this, address, capacity); - - ffi.Pointer GetDirectBufferAddress(JObjectPtr buf) => - value.ref.GetDirectBufferAddress.asFunction< - ffi.Pointer Function( - ffi.Pointer env, JObjectPtr buf)>()(this, buf); - - int GetDirectBufferCapacity(JObjectPtr buf) => value - .ref.GetDirectBufferCapacity - .asFunction env, JObjectPtr buf)>()( - this, buf); - - int GetObjectRefType(JObjectPtr obj) => value.ref.GetObjectRefType - .asFunction env, JObjectPtr obj)>()( - this, obj); -} - -extension JavaVMExtension on ffi.Pointer { - int DestroyJavaVM() => value.ref.DestroyJavaVM - .asFunction vm)>()(this); - - int AttachCurrentThread(ffi.Pointer> p_env, - ffi.Pointer thr_args) => - value.ref.AttachCurrentThread.asFunction< - int Function( - ffi.Pointer vm, - ffi.Pointer> p_env, - ffi.Pointer thr_args)>()(this, p_env, thr_args); - - int DetachCurrentThread() => value.ref.DetachCurrentThread - .asFunction vm)>()(this); - - int GetEnv(ffi.Pointer> p_env, int version) => - value.ref.GetEnv.asFunction< - int Function( - ffi.Pointer vm, - ffi.Pointer> p_env, - int version)>()(this, p_env, version); - - int AttachCurrentThreadAsDaemon(ffi.Pointer> p_env, - ffi.Pointer thr_args) => - value.ref.AttachCurrentThreadAsDaemon.asFunction< - int Function( - ffi.Pointer vm, - ffi.Pointer> p_env, - ffi.Pointer thr_args)>()(this, p_env, thr_args); -} diff --git a/pkgs/jni/lib/src/types.dart b/pkgs/jni/lib/src/types.dart index cc2dbecef..90b9378a1 100644 --- a/pkgs/jni/lib/src/types.dart +++ b/pkgs/jni/lib/src/types.dart @@ -19,8 +19,8 @@ part 'jreference.dart'; part 'jobject.dart'; part 'jstring.dart'; -final Pointer _accessors = Jni.accessors; -final Pointer _env = Jni.env; +final JniAccessors _accessors = Jni.accessors; +final GlobalJniEnv _env = Jni.env; // This typedef is needed because void is a keyword and cannot be used in // type switch like a regular type. typedef _VoidType = void; diff --git a/pkgs/jni/src/dartjni.c b/pkgs/jni/src/dartjni.c index 74c4a119f..7346fef1a 100644 --- a/pkgs/jni/src/dartjni.c +++ b/pkgs/jni/src/dartjni.c @@ -129,11 +129,43 @@ Java_com_github_dart_1lang_jni_JniPlugin_setJniActivity(JNIEnv* env, // Sometimes you may get linker error trying to link JNI_CreateJavaVM APIs // on Android NDK. So IFDEF is required. #else +#ifdef _WIN32 +// Pre-initialization of critical section on windows - this is required because +// there's no coordination between multiple isolates calling Spawn. +// +// Taken from https://stackoverflow.com/a/12858955 +CRITICAL_SECTION spawnLock = {0}; +BOOL WINAPI DllMain(HINSTANCE hinstDLL, // handle to DLL module + DWORD fdwReason, // reason for calling function + LPVOID lpReserved) { // reserved + switch (fdwReason) { + case DLL_PROCESS_ATTACH: + // Initialize once for each new process. + // Return FALSE to fail DLL load. + InitializeCriticalSection(&spawnLock); + break; + case DLL_PROCESS_DETACH: + // Perform any necessary cleanup. + DeleteCriticalSection(&spawnLock); + break; + } + return TRUE; // Successful DLL_PROCESS_ATTACH. +} +#else +pthread_mutex_t spawnLock = PTHREAD_MUTEX_INITIALIZER; +#endif FFI_PLUGIN_EXPORT int SpawnJvm(JavaVMInitArgs* initArgs) { if (jni_context.jvm != NULL) { return DART_JNI_SINGLETON_EXISTS; } + + acquire_lock(&spawnLock); + // Init may have happened in the meanwhile. + if (jni_context.jvm != NULL) { + release_lock(&spawnLock); + return DART_JNI_SINGLETON_EXISTS; + } JavaVMOption jvmopt[1]; char class_path[] = "-Djava.class.path=."; jvmopt[0].optionString = class_path; @@ -152,6 +184,8 @@ int SpawnJvm(JavaVMInitArgs* initArgs) { } initAllLocks(&jni_context.locks); initExceptionHandling(&exceptionMethods); + release_lock(&spawnLock); + return JNI_OK; } #endif @@ -496,7 +530,7 @@ JniExceptionDetails getExceptionDetails(jthrowable exception) { return details; } -JniAccessors accessors = { +JniAccessorsStruct accessors = { .getClass = getClass, .getFieldID = getFieldID, .getStaticFieldID = getStaticFieldID, @@ -513,7 +547,7 @@ JniAccessors accessors = { .getExceptionDetails = getExceptionDetails, }; -FFI_PLUGIN_EXPORT JniAccessors* GetAccessors() { +FFI_PLUGIN_EXPORT JniAccessorsStruct* GetAccessors() { return &accessors; } diff --git a/pkgs/jni/src/dartjni.h b/pkgs/jni/src/dartjni.h index eb73318d1..21cef2036 100644 --- a/pkgs/jni/src/dartjni.h +++ b/pkgs/jni/src/dartjni.h @@ -163,7 +163,7 @@ typedef struct JniExceptionDetails { /// Flutter embedding checks for pending JNI exceptions before an FFI transition, which requires us /// to check for and clear the exception before returning to dart code, which requires these functions /// to return result types. -typedef struct JniAccessors { +typedef struct JniAccessorsStruct { JniClassLookupResult (*getClass)(char* internalName); JniPointerResult (*getFieldID)(jclass cls, char* fieldName, char* signature); JniPointerResult (*getStaticFieldID)(jclass cls, @@ -192,9 +192,9 @@ typedef struct JniAccessors { JniResult (*getField)(jobject obj, jfieldID fieldID, int callType); JniResult (*getStaticField)(jclass cls, jfieldID fieldID, int callType); JniExceptionDetails (*getExceptionDetails)(jthrowable exception); -} JniAccessors; +} JniAccessorsStruct; -FFI_PLUGIN_EXPORT JniAccessors* GetAccessors(); +FFI_PLUGIN_EXPORT JniAccessorsStruct* GetAccessors(); FFI_PLUGIN_EXPORT JavaVM* GetJavaVM(void); diff --git a/pkgs/jni/src/third_party/global_jni_env.c b/pkgs/jni/src/third_party/global_jni_env.c index 600b585b3..c5be7b069 100644 --- a/pkgs/jni/src/third_party/global_jni_env.c +++ b/pkgs/jni/src/third_party/global_jni_env.c @@ -2269,7 +2269,7 @@ JniResult globalEnv_GetObjectRefType(jobject obj) { return (JniResult){.value = {.i = _result}, .exception = NULL}; } -GlobalJniEnv globalJniEnv = { +GlobalJniEnvStruct globalJniEnv = { .reserved0 = NULL, .reserved1 = NULL, .reserved2 = NULL, @@ -2505,7 +2505,7 @@ GlobalJniEnv globalJniEnv = { .GetObjectRefType = globalEnv_GetObjectRefType, }; FFI_PLUGIN_EXPORT -GlobalJniEnv* GetGlobalEnv() { +GlobalJniEnvStruct* GetGlobalEnv() { if (jni->jvm == NULL) { return NULL; } diff --git a/pkgs/jni/src/third_party/global_jni_env.h b/pkgs/jni/src/third_party/global_jni_env.h index 8966d2bdd..562b1bf64 100644 --- a/pkgs/jni/src/third_party/global_jni_env.h +++ b/pkgs/jni/src/third_party/global_jni_env.h @@ -29,7 +29,7 @@ #include #include "../dartjni.h" -typedef struct GlobalJniEnv { +typedef struct GlobalJniEnvStruct { void* reserved0; void* reserved1; void* reserved2; @@ -430,5 +430,5 @@ typedef struct GlobalJniEnv { JniPointerResult (*GetDirectBufferAddress)(jobject buf); JniResult (*GetDirectBufferCapacity)(jobject buf); JniResult (*GetObjectRefType)(jobject obj); -} GlobalJniEnv; -FFI_PLUGIN_EXPORT GlobalJniEnv* GetGlobalEnv(); +} GlobalJniEnvStruct; +FFI_PLUGIN_EXPORT GlobalJniEnvStruct* GetGlobalEnv(); diff --git a/pkgs/jni/tool/wrapper_generators/generate_c_extensions.dart b/pkgs/jni/tool/wrapper_generators/generate_c_extensions.dart index ef907bf16..cde47c9a0 100644 --- a/pkgs/jni/tool/wrapper_generators/generate_c_extensions.dart +++ b/pkgs/jni/tool/wrapper_generators/generate_c_extensions.dart @@ -29,7 +29,7 @@ const errorVar = '_exception'; const envType = 'JNINativeInterface'; /// Name of wrapper to JNIEnv -const wrapperName = 'GlobalJniEnv'; +const wrapperName = 'GlobalJniEnvStruct'; const wrapperIncludes = ''' #include "global_jni_env.h" diff --git a/pkgs/jni/tool/wrapper_generators/generate_dart_extensions.dart b/pkgs/jni/tool/wrapper_generators/generate_dart_extensions.dart index 1ec422d93..c78b88368 100644 --- a/pkgs/jni/tool/wrapper_generators/generate_dart_extensions.dart +++ b/pkgs/jni/tool/wrapper_generators/generate_dart_extensions.dart @@ -21,6 +21,8 @@ class Paths { bindingsDir.resolve("jnienv_javavm_extensions.dart"); } +const writeLocalEnvExtensions = false; + void executeDartFormat(List files) { final paths = files.map((u) => u.toFilePath()).toList(); logger.info('execute dart format ${paths.join(" ")}'); @@ -31,7 +33,7 @@ void executeDartFormat(List files) { } } -const globalEnvType = 'GlobalJniEnv'; +const globalEnvType = 'GlobalJniEnvStruct'; const localEnvType = 'JNINativeInterface'; const jvmType = 'JNIInvokeInterface'; @@ -97,9 +99,13 @@ String? getGlobalEnvExtensionFunction(Member field, Type? checkedReturnType) { if (checkedGetter == 'boolean') { returns = 'bool'; } - return '$returns ${field.name}($signature) => ' - 'ref.${field.name}.asFunction<$dartType>()($callArgs)' - '.$checkedGetter;\n'; + return ''' +late final _${field.name} = + ptr.ref.${field.name}.asFunction<$dartType>();\n +$returns ${field.name}($signature) => + _${field.name}($callArgs).$checkedGetter; + +'''; } return null; } @@ -119,26 +125,38 @@ import "../accessors.dart"; '''; final globalEnvExtension = getGlobalEnvExtension(library); - final accessorExtension = - getFunctionPointerExtension(library, 'JniAccessors'); + final accessorExtension = getFunctionPointerExtension( + library, + 'JniAccessorsStruct', + 'JniAccessors', + ); + File.fromUri(Paths.globalEnvExts).writeAsStringSync(preamble + + header + + importAccessors + + globalEnvExtension + + accessorExtension); + final localEnvExtsFile = File.fromUri(Paths.localEnvExts); + if (localEnvExtsFile.existsSync()) { + localEnvExtsFile.deleteSync(); + } + if (!writeLocalEnvExtensions) { + return; + } final envExtension = getFunctionPointerExtension( library, 'JniEnv', + 'LocalJniEnv', indirect: true, implicitThis: true, ); final jvmExtension = getFunctionPointerExtension( library, 'JavaVM', + 'JniJavaVM', indirect: true, implicitThis: true, ); - File.fromUri(Paths.globalEnvExts).writeAsStringSync(preamble + - header + - importAccessors + - globalEnvExtension + - accessorExtension); - File.fromUri(Paths.localEnvExts) + localEnvExtsFile .writeAsStringSync(preamble + header + envExtension + jvmExtension); } @@ -159,8 +177,15 @@ String getGlobalEnvExtension( .map((m) => getGlobalEnvExtensionFunction(m, checkedReturnTypes[m.name])) .whereNotNull() .join('\n'); - return 'extension EnvExtension on ffi.Pointer<$globalEnvType> ' - '{$extensionFunctions}'; + return ''' +/// Wraps over Pointer and exposes function pointer fields +/// as methods. +class GlobalJniEnv { + final ffi.Pointer ptr; + GlobalJniEnv(this.ptr); + $extensionFunctions +} +'''; } String? getFunctionPointerExtensionFunction(Member field, @@ -184,18 +209,23 @@ String? getFunctionPointerExtensionFunction(Member field, final dartType = FunctionType(returnType: returnType, parameters: params) .getDartType(dummyWriter); final callArgs = [ - if (implicitThis) 'this', + if (implicitThis) 'ptr', ...visibleParams.map((p) => p.name) ].join(', '); final returns = returnType.getDartType(dummyWriter); final dereference = indirect ? 'value.ref' : 'ref'; - return '$returns ${field.name}($signature) => ' - '$dereference.${field.name}.asFunction<$dartType>()($callArgs);\n'; + return ''' +late final _${field.name} = + ptr.$dereference.${field.name}.asFunction<$dartType>(); +$returns ${field.name}($signature) => _${field.name}($callArgs); + +'''; } return null; } -String getFunctionPointerExtension(Library library, String type, +String getFunctionPointerExtension( + Library library, String type, String wrapperClassName, {bool indirect = false, bool implicitThis = false}) { final typeBinding = library.bindings.firstWhere((b) => b.name == type) as Type; @@ -205,8 +235,16 @@ String getFunctionPointerExtension(Library library, String type, indirect: indirect, implicitThis: implicitThis)) .whereNotNull() .join('\n'); - return 'extension ${type}Extension on ffi.Pointer<$type> ' - '{$extensionFunctions}'; + return ''' +/// Wraps over the function pointers in $type and exposes them as methods. +class $wrapperClassName { + final ffi.Pointer<$type> ptr; + $wrapperClassName(this.ptr); + + $extensionFunctions +} + +'''; } void generateDartExtensions(Library library) { diff --git a/pkgs/jnigen/example/in_app_java/src/android_utils/dartjni.h b/pkgs/jnigen/example/in_app_java/src/android_utils/dartjni.h index eb73318d1..21cef2036 100644 --- a/pkgs/jnigen/example/in_app_java/src/android_utils/dartjni.h +++ b/pkgs/jnigen/example/in_app_java/src/android_utils/dartjni.h @@ -163,7 +163,7 @@ typedef struct JniExceptionDetails { /// Flutter embedding checks for pending JNI exceptions before an FFI transition, which requires us /// to check for and clear the exception before returning to dart code, which requires these functions /// to return result types. -typedef struct JniAccessors { +typedef struct JniAccessorsStruct { JniClassLookupResult (*getClass)(char* internalName); JniPointerResult (*getFieldID)(jclass cls, char* fieldName, char* signature); JniPointerResult (*getStaticFieldID)(jclass cls, @@ -192,9 +192,9 @@ typedef struct JniAccessors { JniResult (*getField)(jobject obj, jfieldID fieldID, int callType); JniResult (*getStaticField)(jclass cls, jfieldID fieldID, int callType); JniExceptionDetails (*getExceptionDetails)(jthrowable exception); -} JniAccessors; +} JniAccessorsStruct; -FFI_PLUGIN_EXPORT JniAccessors* GetAccessors(); +FFI_PLUGIN_EXPORT JniAccessorsStruct* GetAccessors(); FFI_PLUGIN_EXPORT JavaVM* GetJavaVM(void); diff --git a/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h b/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h index eb73318d1..21cef2036 100644 --- a/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h +++ b/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h @@ -163,7 +163,7 @@ typedef struct JniExceptionDetails { /// Flutter embedding checks for pending JNI exceptions before an FFI transition, which requires us /// to check for and clear the exception before returning to dart code, which requires these functions /// to return result types. -typedef struct JniAccessors { +typedef struct JniAccessorsStruct { JniClassLookupResult (*getClass)(char* internalName); JniPointerResult (*getFieldID)(jclass cls, char* fieldName, char* signature); JniPointerResult (*getStaticFieldID)(jclass cls, @@ -192,9 +192,9 @@ typedef struct JniAccessors { JniResult (*getField)(jobject obj, jfieldID fieldID, int callType); JniResult (*getStaticField)(jclass cls, jfieldID fieldID, int callType); JniExceptionDetails (*getExceptionDetails)(jthrowable exception); -} JniAccessors; +} JniAccessorsStruct; -FFI_PLUGIN_EXPORT JniAccessors* GetAccessors(); +FFI_PLUGIN_EXPORT JniAccessorsStruct* GetAccessors(); FFI_PLUGIN_EXPORT JavaVM* GetJavaVM(void); diff --git a/pkgs/jnigen/example/notification_plugin/src/dartjni.h b/pkgs/jnigen/example/notification_plugin/src/dartjni.h index eb73318d1..21cef2036 100644 --- a/pkgs/jnigen/example/notification_plugin/src/dartjni.h +++ b/pkgs/jnigen/example/notification_plugin/src/dartjni.h @@ -163,7 +163,7 @@ typedef struct JniExceptionDetails { /// Flutter embedding checks for pending JNI exceptions before an FFI transition, which requires us /// to check for and clear the exception before returning to dart code, which requires these functions /// to return result types. -typedef struct JniAccessors { +typedef struct JniAccessorsStruct { JniClassLookupResult (*getClass)(char* internalName); JniPointerResult (*getFieldID)(jclass cls, char* fieldName, char* signature); JniPointerResult (*getStaticFieldID)(jclass cls, @@ -192,9 +192,9 @@ typedef struct JniAccessors { JniResult (*getField)(jobject obj, jfieldID fieldID, int callType); JniResult (*getStaticField)(jclass cls, jfieldID fieldID, int callType); JniExceptionDetails (*getExceptionDetails)(jthrowable exception); -} JniAccessors; +} JniAccessorsStruct; -FFI_PLUGIN_EXPORT JniAccessors* GetAccessors(); +FFI_PLUGIN_EXPORT JniAccessorsStruct* GetAccessors(); FFI_PLUGIN_EXPORT JavaVM* GetJavaVM(void); diff --git a/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h b/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h index eb73318d1..21cef2036 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h +++ b/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h @@ -163,7 +163,7 @@ typedef struct JniExceptionDetails { /// Flutter embedding checks for pending JNI exceptions before an FFI transition, which requires us /// to check for and clear the exception before returning to dart code, which requires these functions /// to return result types. -typedef struct JniAccessors { +typedef struct JniAccessorsStruct { JniClassLookupResult (*getClass)(char* internalName); JniPointerResult (*getFieldID)(jclass cls, char* fieldName, char* signature); JniPointerResult (*getStaticFieldID)(jclass cls, @@ -192,9 +192,9 @@ typedef struct JniAccessors { JniResult (*getField)(jobject obj, jfieldID fieldID, int callType); JniResult (*getStaticField)(jclass cls, jfieldID fieldID, int callType); JniExceptionDetails (*getExceptionDetails)(jthrowable exception); -} JniAccessors; +} JniAccessorsStruct; -FFI_PLUGIN_EXPORT JniAccessors* GetAccessors(); +FFI_PLUGIN_EXPORT JniAccessorsStruct* GetAccessors(); FFI_PLUGIN_EXPORT JavaVM* GetJavaVM(void); diff --git a/pkgs/jnigen/test/kotlin_test/src/dartjni.h b/pkgs/jnigen/test/kotlin_test/src/dartjni.h index eb73318d1..21cef2036 100644 --- a/pkgs/jnigen/test/kotlin_test/src/dartjni.h +++ b/pkgs/jnigen/test/kotlin_test/src/dartjni.h @@ -163,7 +163,7 @@ typedef struct JniExceptionDetails { /// Flutter embedding checks for pending JNI exceptions before an FFI transition, which requires us /// to check for and clear the exception before returning to dart code, which requires these functions /// to return result types. -typedef struct JniAccessors { +typedef struct JniAccessorsStruct { JniClassLookupResult (*getClass)(char* internalName); JniPointerResult (*getFieldID)(jclass cls, char* fieldName, char* signature); JniPointerResult (*getStaticFieldID)(jclass cls, @@ -192,9 +192,9 @@ typedef struct JniAccessors { JniResult (*getField)(jobject obj, jfieldID fieldID, int callType); JniResult (*getStaticField)(jclass cls, jfieldID fieldID, int callType); JniExceptionDetails (*getExceptionDetails)(jthrowable exception); -} JniAccessors; +} JniAccessorsStruct; -FFI_PLUGIN_EXPORT JniAccessors* GetAccessors(); +FFI_PLUGIN_EXPORT JniAccessorsStruct* GetAccessors(); FFI_PLUGIN_EXPORT JavaVM* GetJavaVM(void); diff --git a/pkgs/jnigen/test/simple_package_test/src/dartjni.h b/pkgs/jnigen/test/simple_package_test/src/dartjni.h index eb73318d1..21cef2036 100644 --- a/pkgs/jnigen/test/simple_package_test/src/dartjni.h +++ b/pkgs/jnigen/test/simple_package_test/src/dartjni.h @@ -163,7 +163,7 @@ typedef struct JniExceptionDetails { /// Flutter embedding checks for pending JNI exceptions before an FFI transition, which requires us /// to check for and clear the exception before returning to dart code, which requires these functions /// to return result types. -typedef struct JniAccessors { +typedef struct JniAccessorsStruct { JniClassLookupResult (*getClass)(char* internalName); JniPointerResult (*getFieldID)(jclass cls, char* fieldName, char* signature); JniPointerResult (*getStaticFieldID)(jclass cls, @@ -192,9 +192,9 @@ typedef struct JniAccessors { JniResult (*getField)(jobject obj, jfieldID fieldID, int callType); JniResult (*getStaticField)(jclass cls, jfieldID fieldID, int callType); JniExceptionDetails (*getExceptionDetails)(jthrowable exception); -} JniAccessors; +} JniAccessorsStruct; -FFI_PLUGIN_EXPORT JniAccessors* GetAccessors(); +FFI_PLUGIN_EXPORT JniAccessorsStruct* GetAccessors(); FFI_PLUGIN_EXPORT JavaVM* GetJavaVM(void); From 1753fed9fade166a9e1d998a810fca8bb21b874a Mon Sep 17 00:00:00 2001 From: Mahesh Hegde <46179734+mahesh-hegde@users.noreply.github.com> Date: Fri, 21 Apr 2023 13:57:44 +0530 Subject: [PATCH 079/139] [jnigen] Bunch of small testsuite improvements (https://github.com/dart-lang/jnigen/issues/257) * Throw error in test if summarizer is stale * Fail if jni dylib is stale * Add spawnIfNotExists. (It sounds like SQL, which means no further evolution is possible) * Add tags mechanism to jnigen test * Add `summarizer_test` and `large_test` tags. So that in dev env, can exclude these with -x tag for fast iteration. * Adds dart_test.yaml which is required for this configuration by test package. * Use random seed for jnigen tests in CI --- .github/workflows/test-package.yml | 11 +++- pkgs/jni/bin/setup.dart | 18 +----- pkgs/jni/lib/src/build_util/build_util.dart | 24 ++++++++ pkgs/jni/lib/src/jni.dart | 35 +++++++++--- pkgs/jni/test/exception_test.dart | 1 + pkgs/jni/test/global_env_test.dart | 7 +-- pkgs/jni/test/jarray_test.dart | 7 +-- pkgs/jni/test/jobject_test.dart | 7 +-- pkgs/jni/test/test_util/test_util.dart | 29 ++++++++++ pkgs/jni/test/type_test.dart | 7 +-- pkgs/jnigen/dart_test.yaml | 12 ++++ pkgs/jnigen/test/bindings_test.dart | 1 + pkgs/jnigen/test/config_test.dart | 4 +- pkgs/jnigen/test/dart_generator_test.dart | 6 +- .../generated_files_test.dart | 10 +++- .../kotlin_test/generated_files_test.dart | 6 +- pkgs/jnigen/test/package_resolver_test.dart | 5 +- .../jnigen/test/regenerate_examples_test.dart | 55 ++++++++++++------- .../generated_files_test.dart | 2 + pkgs/jnigen/test/summary_generation_test.dart | 7 ++- pkgs/jnigen/test/test_util/test_util.dart | 33 ++++++++++- 21 files changed, 211 insertions(+), 76 deletions(-) create mode 100644 pkgs/jni/lib/src/build_util/build_util.dart create mode 100644 pkgs/jnigen/dart_test.yaml diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index a5bb09e67..1809e2cc0 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -92,8 +92,10 @@ jobs: - name: Run summarizer tests run: mvn surefire:test working-directory: ./pkgs/jnigen/java + - name: Build summarizer + run: dart run jnigen:setup - name: Run VM tests - run: dart test --platform vm + run: dart test --test-randomize-ordering-seed random - name: Install coverage run: dart pub global activate coverage - name: Collect coverage @@ -243,7 +245,10 @@ jobs: - name: build notification_plugin example APK run: flutter build apk --target-platform=android-arm64 working-directory: ./pkgs/jnigen/example/notification_plugin/example - - run: dart test + - name: Build summarizer + run: dart run jnigen:setup + - name: Run tests + run: dart test --test-randomize-ordering-seed random test_jni_macos_minimal: needs: [analyze_jni] @@ -290,7 +295,7 @@ jobs: - run: git config --global core.autocrlf true - run: dart pub get - run: dart run jnigen:setup - - run: dart test + - run: dart test --test-randomize-ordering-seed random build_jni_example_linux: runs-on: ubuntu-latest diff --git a/pkgs/jni/bin/setup.dart b/pkgs/jni/bin/setup.dart index eb4f9c91f..3f5bb79dd 100644 --- a/pkgs/jni/bin/setup.dart +++ b/pkgs/jni/bin/setup.dart @@ -7,12 +7,13 @@ import 'dart:io'; import 'package:args/args.dart'; import 'package:package_config/package_config.dart'; -const ansiRed = '\x1b[31m'; -const ansiDefault = '\x1b[39;49m'; +import 'package:jni/src/build_util/build_util.dart'; const jniNativeBuildDirective = '# jni_native_build (Build with jni:setup. Do not delete this line.)'; +// When changing this constant here, also change corresponding path in +// test/test_util. const _defaultRelativeBuildPath = "build/jni_libs"; const _buildPath = "build-path"; @@ -126,19 +127,6 @@ Future> findDependencySources() async { return sources; } -/// Returns true if [artifact] does not exist, or any file in [sourceDir] is -/// newer than [artifact]. -bool needsBuild(File artifact, Directory sourceDir) { - if (!artifact.existsSync()) return true; - final fileLastModified = artifact.lastModifiedSync(); - for (final entry in sourceDir.listSync(recursive: true)) { - if (entry.statSync().modified.isAfter(fileLastModified)) { - return true; - } - } - return false; -} - /// Returns the name of file built using sources in [cDir] String getTargetName(Directory cDir) { for (final file in cDir.listSync(recursive: true)) { diff --git a/pkgs/jni/lib/src/build_util/build_util.dart b/pkgs/jni/lib/src/build_util/build_util.dart new file mode 100644 index 000000000..8d267dfa3 --- /dev/null +++ b/pkgs/jni/lib/src/build_util/build_util.dart @@ -0,0 +1,24 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +// Any shared build logic should be here. This way it can be reused across bin/, +// tool/ and test/. + +import 'dart:io'; + +const ansiRed = '\x1b[31m'; +const ansiDefault = '\x1b[39;49m'; + +/// Returns true if [artifact] does not exist, or any file in [sourceDir] is +/// newer than [artifact]. +bool needsBuild(File artifact, Directory sourceDir) { + if (!artifact.existsSync()) return true; + final fileLastModified = artifact.lastModifiedSync(); + for (final entry in sourceDir.listSync(recursive: true)) { + if (entry.statSync().modified.isAfter(fileLastModified)) { + return true; + } + } + return false; +} diff --git a/pkgs/jni/lib/src/jni.dart b/pkgs/jni/lib/src/jni.dart index 277c2a5fe..97ff46e86 100644 --- a/pkgs/jni/lib/src/jni.dart +++ b/pkgs/jni/lib/src/jni.dart @@ -85,13 +85,33 @@ abstract class Jni { List classPath = const [], bool ignoreUnrecognized = false, int jniVersion = JniVersions.JNI_VERSION_1_6, + }) { + final status = spawnIfNotExists( + dylibDir: dylibDir, + jvmOptions: jvmOptions, + classPath: classPath, + ignoreUnrecognized: ignoreUnrecognized, + jniVersion: jniVersion, + ); + if (status == false) { + throw JvmExistsException(); + } + } + + /// Same as [spawn] but if a JVM exists, returns silently instead of + /// throwing [JvmExistsException]. + /// + /// If the options are different than that of existing VM, the existing VM's + /// options will remain in effect. + static bool spawnIfNotExists({ + String? dylibDir, + List jvmOptions = const [], + List classPath = const [], + bool ignoreUnrecognized = false, + int jniVersion = JniVersions.JNI_VERSION_1_6, }) => using((arena) { _dylibDir = dylibDir; - final existVm = _bindings.GetJavaVM(); - if (existVm != nullptr) { - throw JvmExistsException(); - } final jvmArgs = _createVMArgs( options: jvmOptions, classPath: classPath, @@ -102,12 +122,9 @@ abstract class Jni { ); final status = _bindings.SpawnJvm(jvmArgs); if (status == JniErrorCode.JNI_OK) { - return; + return true; } else if (status == DART_JNI_SINGLETON_EXISTS) { - throw JvmExistsException(); - } else if (status == JniErrorCode.JNI_EEXIST) { - sleep(const Duration(seconds: 1)); - throw JvmExistsException(); + return false; } else { throw SpawnException.of(status); } diff --git a/pkgs/jni/test/exception_test.dart b/pkgs/jni/test/exception_test.dart index 4fb34efe7..01acfdfb6 100644 --- a/pkgs/jni/test/exception_test.dart +++ b/pkgs/jni/test/exception_test.dart @@ -11,6 +11,7 @@ import 'test_util/test_util.dart'; void main() { if (!Platform.isAndroid) { + checkDylibIsUpToDate(); bool caught = false; try { // If library does not exist, a helpful exception should be thrown. diff --git a/pkgs/jni/test/global_env_test.dart b/pkgs/jni/test/global_env_test.dart index 8f65d3464..9b6a8b210 100644 --- a/pkgs/jni/test/global_env_test.dart +++ b/pkgs/jni/test/global_env_test.dart @@ -25,11 +25,8 @@ void main() { // You have to manually pass the path to the `dartjni` dynamic library. if (!Platform.isAndroid) { - try { - Jni.spawn(dylibDir: "build/jni_libs", jvmOptions: ["-Xmx128m"]); - } on JvmExistsException catch (_) { - // TODO(#51): Support destroying and reinstantiating JVM. - } + checkDylibIsUpToDate(); + Jni.spawnIfNotExists(dylibDir: "build/jni_libs", jvmOptions: ["-Xmx128m"]); } run(testRunner: test); } diff --git a/pkgs/jni/test/jarray_test.dart b/pkgs/jni/test/jarray_test.dart index 4eca3d4a3..5717d532e 100644 --- a/pkgs/jni/test/jarray_test.dart +++ b/pkgs/jni/test/jarray_test.dart @@ -12,11 +12,8 @@ import 'test_util/test_util.dart'; void main() { // Don't forget to initialize JNI. if (!Platform.isAndroid) { - try { - Jni.spawn(dylibDir: "build/jni_libs", jvmOptions: ["-Xmx128m"]); - } on JvmExistsException catch (_) { - // TODO(#51): Support destroying and reinstantiating JVM. - } + checkDylibIsUpToDate(); + Jni.spawnIfNotExists(dylibDir: "build/jni_libs", jvmOptions: ["-Xmx128m"]); } run(testRunner: test); } diff --git a/pkgs/jni/test/jobject_test.dart b/pkgs/jni/test/jobject_test.dart index e951002ce..8478d5aa1 100644 --- a/pkgs/jni/test/jobject_test.dart +++ b/pkgs/jni/test/jobject_test.dart @@ -17,11 +17,8 @@ const maxLongInJava = 9223372036854775807; void main() { // Don't forget to initialize JNI. if (!Platform.isAndroid) { - try { - Jni.spawn(dylibDir: "build/jni_libs", jvmOptions: ["-Xmx128m"]); - } on JvmExistsException catch (_) { - // TODO(#51): Support destroying and reinstantiating JVM. - } + checkDylibIsUpToDate(); + Jni.spawnIfNotExists(dylibDir: "build/jni_libs", jvmOptions: ["-Xmx128m"]); } run(testRunner: test); } diff --git a/pkgs/jni/test/test_util/test_util.dart b/pkgs/jni/test/test_util/test_util.dart index 40d86ebaf..07e711aa4 100644 --- a/pkgs/jni/test/test_util/test_util.dart +++ b/pkgs/jni/test/test_util/test_util.dart @@ -2,8 +2,37 @@ // 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:jni/src/build_util/build_util.dart'; + typedef TestCaseCallback = void Function(); typedef TestRunnerCallback = void Function( String description, TestCaseCallback test, ); + +final currentDir = Directory.current.uri; +final dllSuffix = + Platform.isWindows ? "dll" : (Platform.isMacOS ? "dylib" : "so"); +final dllPrefix = Platform.isWindows ? '' : 'lib'; +final dllPath = + currentDir.resolve("build/jni_libs/${dllPrefix}dartjni.$dllSuffix"); +final srcPath = currentDir.resolve("src/"); + +/// Fail if dartjni dll is stale. +void checkDylibIsUpToDate() { + final dllFile = File.fromUri(dllPath); + if (needsBuild(File.fromUri(dllPath), Directory.fromUri(srcPath))) { + final cause = dllFile.existsSync() + ? 'not up-to-date with source modifications' + : 'not built'; + var message = '\nFatal: dartjni.$dllSuffix is $cause. Please run ' + '`dart run jni:setup` and try again.'; + if (stderr.supportsAnsiEscapes) { + message = ansiRed + message + ansiDefault; + } + stderr.writeln(message); + exit(1); + } +} diff --git a/pkgs/jni/test/type_test.dart b/pkgs/jni/test/type_test.dart index ecdcf109a..68693a548 100644 --- a/pkgs/jni/test/type_test.dart +++ b/pkgs/jni/test/type_test.dart @@ -205,11 +205,8 @@ class $FType extends JObjType { void main() { if (!Platform.isAndroid) { - try { - Jni.spawn(dylibDir: "build/jni_libs", jvmOptions: ["-Xmx128m"]); - } on JvmExistsException catch (_) { - // TODO(#51): Support destroying and reinstantiating JVM. - } + checkDylibIsUpToDate(); + Jni.spawnIfNotExists(dylibDir: "build/jni_libs", jvmOptions: ["-Xmx128m"]); } run(testRunner: test); } diff --git a/pkgs/jnigen/dart_test.yaml b/pkgs/jnigen/dart_test.yaml new file mode 100644 index 000000000..0fb13bc13 --- /dev/null +++ b/pkgs/jnigen/dart_test.yaml @@ -0,0 +1,12 @@ +## 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. + +## This file defines test groups for jnigen. This will be helpful to exclude +## lengthy tests by using -x flag. + +tags: + large_test: + timeout: 2x + summarizer_test: + timeout: 1x diff --git a/pkgs/jnigen/test/bindings_test.dart b/pkgs/jnigen/test/bindings_test.dart index 107c24d2c..7d98863a0 100644 --- a/pkgs/jnigen/test/bindings_test.dart +++ b/pkgs/jnigen/test/bindings_test.dart @@ -97,6 +97,7 @@ Future setupDylibsAndClasses() async { } void main() async { + await checkLocallyBuiltDependencies(); setUpAll(setupDylibsAndClasses); test('static final fields', () { diff --git a/pkgs/jnigen/test/config_test.dart b/pkgs/jnigen/test/config_test.dart index fd935c370..2faa528df 100644 --- a/pkgs/jnigen/test/config_test.dart +++ b/pkgs/jnigen/test/config_test.dart @@ -10,6 +10,7 @@ import 'package:path/path.dart' hide equals; import 'package:path/path.dart' as path show equals; import 'jackson_core_test/generate.dart'; +import 'test_util/test_util.dart'; const packageTests = 'test'; final jacksonCoreTests = absolute(packageTests, 'jackson_core_test'); @@ -93,7 +94,8 @@ void testForErrorChecking( }); } -void main() { +void main() async { + await checkLocallyBuiltDependencies(); final config = Config.parseArgs([ '--config', jnigenYaml, diff --git a/pkgs/jnigen/test/dart_generator_test.dart b/pkgs/jnigen/test/dart_generator_test.dart index 4ad2eb8cc..e9bbb7608 100644 --- a/pkgs/jnigen/test/dart_generator_test.dart +++ b/pkgs/jnigen/test/dart_generator_test.dart @@ -5,7 +5,11 @@ import 'package:jnigen/src/bindings/dart_generator.dart'; import 'package:test/test.dart'; -void main() { +import 'test_util/test_util.dart'; + +void main() async { + await checkLocallyBuiltDependencies(); + test('OutsideInBuffer', () { final buffer = OutsideInBuffer(); buffer.appendLeft('f('); diff --git a/pkgs/jnigen/test/jackson_core_test/generated_files_test.dart b/pkgs/jnigen/test/jackson_core_test/generated_files_test.dart index 75dde7d42..912961277 100644 --- a/pkgs/jnigen/test/jackson_core_test/generated_files_test.dart +++ b/pkgs/jnigen/test/jackson_core_test/generated_files_test.dart @@ -11,6 +11,8 @@ import '../test_util/test_util.dart'; import 'generate.dart'; void main() async { + await checkLocallyBuiltDependencies(); + test("compare generated bindings for jackson_core", () async { final lib = join(thirdPartyDir, 'lib'); final src = join(thirdPartyDir, 'src'); @@ -22,14 +24,16 @@ void main() async { 'not just required classes', () async { final config = getConfig(generateFullVersion: true); await generateAndAnalyzeBindings(config); - }, timeout: const Timeout(Duration(minutes: 2))); + }, timeout: const Timeout(Duration(minutes: 2)), tags: largeTestTag); + test('generate and analyze bindings using ASM', () async { final config = getConfig(generateFullVersion: true, useAsm: true); await generateAndAnalyzeBindings(config); - }, timeout: const Timeout(Duration(minutes: 2))); + }, timeout: const Timeout(Duration(minutes: 2)), tags: largeTestTag); + test('Generate and analyze pure dart bindings', () async { final config = getConfig(generateFullVersion: true); config.outputConfig.bindingsType = BindingsType.dartOnly; await generateAndAnalyzeBindings(config); - }, timeout: const Timeout.factor(2)); + }, timeout: const Timeout.factor(2), tags: largeTestTag); } diff --git a/pkgs/jnigen/test/kotlin_test/generated_files_test.dart b/pkgs/jnigen/test/kotlin_test/generated_files_test.dart index 9ae50e36f..be9ff90e0 100644 --- a/pkgs/jnigen/test/kotlin_test/generated_files_test.dart +++ b/pkgs/jnigen/test/kotlin_test/generated_files_test.dart @@ -10,6 +10,9 @@ import 'generate.dart'; import '../test_util/test_util.dart'; void main() async { + // This is not run in setupAll, because we want to exit with one line of + // error message, not throw a long exception. + await checkLocallyBuiltDependencies(); test( "Generate and compare bindings for kotlin_test", () async { @@ -29,5 +32,6 @@ void main() async { ); }, timeout: const Timeout.factor(1.5), - ); // test if generated file == expected file + tags: largeTestTag, + ); } diff --git a/pkgs/jnigen/test/package_resolver_test.dart b/pkgs/jnigen/test/package_resolver_test.dart index 39b899887..98c0d2bfd 100644 --- a/pkgs/jnigen/test/package_resolver_test.dart +++ b/pkgs/jnigen/test/package_resolver_test.dart @@ -5,6 +5,8 @@ import 'package:jnigen/src/bindings/resolver.dart'; import 'package:test/test.dart'; +import 'test_util/test_util.dart'; + class ResolverTest { ResolverTest(this.binaryName, this.expectedImport, this.expectedName); String binaryName; @@ -12,7 +14,8 @@ class ResolverTest { String expectedName; } -void main() { +void main() async { + await checkLocallyBuiltDependencies(); final resolver = Resolver( importMap: { 'org.apache.pdfbox': 'package:pdfbox/pdfbox.dart', diff --git a/pkgs/jnigen/test/regenerate_examples_test.dart b/pkgs/jnigen/test/regenerate_examples_test.dart index 0e2ac62ab..50e41b62b 100644 --- a/pkgs/jnigen/test/regenerate_examples_test.dart +++ b/pkgs/jnigen/test/regenerate_examples_test.dart @@ -23,42 +23,59 @@ final kotlinPluginYaml = join(kotlinPlugin, 'jnigen.yaml'); /// them to provided reference outputs. /// /// [dartOutput] and [cOutput] are relative paths from example project dir. -void testExample(String exampleName, String dartOutput, String? cOutput) { - test('Generate and compare bindings for $exampleName', - timeout: const Timeout.factor(2), () async { - final examplePath = join('example', exampleName); - final configPath = join(examplePath, 'jnigen.yaml'); +/// +/// Pass [isLargeTest] as true if the test will take considerable time. +void testExample(String exampleName, String dartOutput, String? cOutput, + {bool isLargeTest = false}) { + test( + 'Generate and compare bindings for $exampleName', + timeout: const Timeout.factor(2), + () async { + final examplePath = join('example', exampleName); + final configPath = join(examplePath, 'jnigen.yaml'); - final dartBindingsPath = join(examplePath, dartOutput); - String? cBindingsPath; - if (cOutput != null) { - cBindingsPath = join(examplePath, cOutput); - } + final dartBindingsPath = join(examplePath, dartOutput); + String? cBindingsPath; + if (cOutput != null) { + cBindingsPath = join(examplePath, cOutput); + } - final config = Config.parseArgs(['--config', configPath]); - try { - await generateAndCompareBindings(config, dartBindingsPath, cBindingsPath); - } on GradleException catch (_) { - stderr.writeln('Skip: $exampleName'); - } - }); + final config = Config.parseArgs(['--config', configPath]); + try { + await generateAndCompareBindings( + config, dartBindingsPath, cBindingsPath); + } on GradleException catch (_) { + stderr.writeln('Skip: $exampleName'); + } + }, + tags: isLargeTest ? largeTestTag : null, + ); } -void main() { +void main() async { + await checkLocallyBuiltDependencies(); testExample( 'in_app_java', join('lib', 'android_utils.dart'), join('src', 'android_utils'), + isLargeTest: true, + ); + testExample( + 'pdfbox_plugin', + join('lib', 'src', 'third_party'), + 'src', + isLargeTest: false, ); - testExample('pdfbox_plugin', join('lib', 'src', 'third_party'), 'src'); testExample( 'notification_plugin', join('lib', 'notifications.dart'), 'src', + isLargeTest: true, ); testExample( 'kotlin_plugin', join('lib', 'kotlin_bindings.dart'), 'src', + isLargeTest: true, ); } diff --git a/pkgs/jnigen/test/simple_package_test/generated_files_test.dart b/pkgs/jnigen/test/simple_package_test/generated_files_test.dart index 98a6d5f78..084afe043 100644 --- a/pkgs/jnigen/test/simple_package_test/generated_files_test.dart +++ b/pkgs/jnigen/test/simple_package_test/generated_files_test.dart @@ -10,6 +10,8 @@ import 'generate.dart'; import '../test_util/test_util.dart'; void main() async { + await checkLocallyBuiltDependencies(); + test("Generate and compare bindings for simple_package", () async { await generateAndCompareBindings( getConfig(), diff --git a/pkgs/jnigen/test/summary_generation_test.dart b/pkgs/jnigen/test/summary_generation_test.dart index 8386db607..e3582c68e 100644 --- a/pkgs/jnigen/test/summary_generation_test.dart +++ b/pkgs/jnigen/test/summary_generation_test.dart @@ -5,6 +5,8 @@ // These tests validate summary generation in various scenarios. // Currently, no validation of the summary content itself is done. +@Tags(['summarizer_test']) + import 'dart:io'; import 'package:jnigen/src/config/config.dart'; @@ -107,9 +109,10 @@ Config getConfig({List? sourcePath, List? classPath}) { ); } -void main() { +void main() async { + await checkLocallyBuiltDependencies(); late Directory tempDir; - setUpAll(() { + setUpAll(() async { tempDir = getTempDir("jnigen_summary_tests_"); }); diff --git a/pkgs/jnigen/test/test_util/test_util.dart b/pkgs/jnigen/test/test_util/test_util.dart index 68707016f..450e28a0f 100644 --- a/pkgs/jnigen/test/test_util/test_util.dart +++ b/pkgs/jnigen/test/test_util/test_util.dart @@ -5,14 +5,20 @@ import 'dart:io'; import 'package:jnigen/jnigen.dart'; +import 'package:jnigen/src/util/find_package.dart'; import 'package:path/path.dart' hide equals; import 'package:test/test.dart'; import 'package:logging/logging.dart' show Level; -import 'package:jnigen/src/logging/logging.dart' show printError, log; +import 'package:jnigen/src/logging/logging.dart'; final _currentDirectory = Directory("."); +// If changing these constants, grep for these values. In some places, test +// package expects string literals. +const largeTestTag = 'large_test'; +const summarizerTestTag = 'summarizer_test'; + Directory getTempDir(String prefix) { return _currentDirectory.createTempSync(prefix); } @@ -127,3 +133,28 @@ Future generateAndAnalyzeBindings(Config config) async { tempDir.deleteSync(recursive: true); } } + +final summarizerJar = join('.', '.dart_tool', 'jnigen', 'ApiSummarizer.jar'); + +Future failIfSummarizerNotBuilt() async { + final jarExists = await File(summarizerJar).exists(); + if (!jarExists) { + stderr.writeln(); + log.fatal('Please build summarizer by running ' + '`dart run jnigen:setup` and try again'); + } + final isJarStale = jarExists && + await isPackageModifiedAfter( + 'jnigen', await File(summarizerJar).lastModified(), 'java/'); + if (isJarStale) { + stderr.writeln(); + log.fatal('Summarizer is not rebuilt after recent changes. ' + 'Please run `dart run jnigen:setup` and try again.'); + } +} + +/// Verifies if locally built dependencies (currently `ApiSummarizer`) +/// are up-to-date. +Future checkLocallyBuiltDependencies() async { + await failIfSummarizerNotBuilt(); +} From f129cdfc9d36eb44bba981e74c60f7a5293c0c0a Mon Sep 17 00:00:00 2001 From: Mahesh Hegde <46179734+mahesh-hegde@users.noreply.github.com> Date: Tue, 25 Apr 2023 14:11:22 +0530 Subject: [PATCH 080/139] [jnigen] Add FAQ entry about references (https://github.com/dart-lang/jnigen/issues/259) --- pkgs/jnigen/README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkgs/jnigen/README.md b/pkgs/jnigen/README.md index 66daa53ce..56fba3780 100644 --- a/pkgs/jnigen/README.md +++ b/pkgs/jnigen/README.md @@ -188,6 +188,14 @@ If the classes are in JAR file, make sure to provide path to JAR file itself, an #### `jnigen` is unable to parse sources. If the errors are similar to `symbol not found`, ensure all dependencies of the source are available. If such dependency is compiled, it can be included in `class_path`. +#### How are classes mapped into bindings? +Each Java class generates a subclass of `JObject` class, which wraps a `jobject` reference in JNI. Nested classes use `_` as separator, `Example.NestedClass` will be mapped to `Example_NestedClass`. + +#### Does `JObject` hold a local or global reference? Does it need to be manually deleted? +Each Java object returned into Dart creates a JNI global reference. Reference deletion is taken care of by `NativeFinalizer` and that's usually sufficient. + +It's a good practice to keep the interface between languages sparse. However, if there's a need to create several references (Eg: in a loop), you can use FFI Arena mechanism (`using` function) and `deletedIn` method, or manually delete the object using `delete` method. + #### Should I use `jnigen` over Method channels? This is currently an experimental package. Many features are missing, and it's rough around the edges. You're welcome to try it and give feedback. From e9f16e67d347235f2c97659080e813815ebba99b Mon Sep 17 00:00:00 2001 From: Alex James Date: Thu, 27 Apr 2023 11:49:09 +0100 Subject: [PATCH 081/139] [jnigen] Support Maven version 4 (https://github.com/dart-lang/jnigen/issues/261) From version 4 Maven throws an error if we use descriptorId as we should be using descriptorRef instead. descriptorRef also works with Maven 3. To enable support for Maven 4 we have changed the Maven command used to build ApiSummarizer.jar from 'mvn assembly:assembly` to `mvn compile`. Jnigen/java's README contains instructions for manually building ApiSummarizer.jar. These instructions need to be updated to use the new maven commands 'mvn compile' and 'mvn test'. --- pkgs/jnigen/java/README.md | 2 +- pkgs/jnigen/java/pom.xml | 30 ++++++++++++++++++- .../lib/src/tools/build_summarizer.dart | 2 +- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/pkgs/jnigen/java/README.md b/pkgs/jnigen/java/README.md index f304059f7..50c8ab487 100644 --- a/pkgs/jnigen/java/README.md +++ b/pkgs/jnigen/java/README.md @@ -8,7 +8,7 @@ It's currently used in `jnigen` to get the information of the Java API. ## Build When using it via `jnigen`, the `jnigen:setup` script will take care of building the jar in appropriate location. -To build the jar manually, run `mvn assembly:assembly` in project root. The jar will be created in `target/` directory. +To build the jar manually, run `mvn compile` in project root. To build the jar and run the tests as well, run `mvn test`. The jar will be created in `target/` directory. ## Command line ``` diff --git a/pkgs/jnigen/java/pom.xml b/pkgs/jnigen/java/pom.xml index 2ca391697..89c5a9edf 100644 --- a/pkgs/jnigen/java/pom.xml +++ b/pkgs/jnigen/java/pom.xml @@ -44,6 +44,22 @@ ${buildDir}/target ApiSummarizer + + + + maven-clean-plugin + 3.2.0 + + + maven-resources-plugin + 3.3.1 + + + maven-jar-plugin + 3.3.0 + + + org.apache.maven.plugins @@ -53,8 +69,11 @@ org.apache.maven.plugins maven-assembly-plugin + 3.5.0 - jar-with-dependencies + + jar-with-dependencies + false @@ -62,6 +81,15 @@ + + + make-assembly + compile + + single + + + org.apache.maven.plugins diff --git a/pkgs/jnigen/lib/src/tools/build_summarizer.dart b/pkgs/jnigen/lib/src/tools/build_summarizer.dart index 5d5a7efbf..1e0ec06a7 100644 --- a/pkgs/jnigen/lib/src/tools/build_summarizer.dart +++ b/pkgs/jnigen/lib/src/tools/build_summarizer.dart @@ -29,11 +29,11 @@ Future buildApiSummarizer() async { final pom = pkg.resolve('java/pom.xml'); await Directory(toolPath).create(recursive: true); final mvnArgs = [ + 'compile', '--batch-mode', '--update-snapshots', '-f', pom.toFilePath(), - 'assembly:assembly' ]; log.info('execute mvn ${mvnArgs.join(" ")}'); try { From 16f2d4ec5d12ec45bd182255036951804d4750c6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 May 2023 08:19:41 +0200 Subject: [PATCH 082/139] [jnigen] Bump actions/checkout from 3.5.0 to 3.5.2 (https://github.com/dart-lang/jnigen/issues/268) Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.0 to 3.5.2. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/8f4b7f84864484a7bf31766abe9204da3cbe65b3...8e5e7e5ab8b370d6c329ec480221332ada57f0ab) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/test-package.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 1809e2cc0..e059842e2 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -32,7 +32,7 @@ jobs: matrix: sdk: [stable] steps: - - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: ${{ matrix.sdk }} @@ -64,7 +64,7 @@ jobs: os: [ubuntu-latest] sdk: [stable, beta] steps: - - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: ${{ matrix.sdk }} @@ -115,7 +115,7 @@ jobs: run: working-directory: ./pkgs/jni steps: - - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' @@ -153,7 +153,7 @@ jobs: run: working-directory: ./pkgs/jni steps: - - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' @@ -198,7 +198,7 @@ jobs: run: working-directory: ./pkgs/jni steps: - - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' @@ -220,7 +220,7 @@ jobs: run: working-directory: ./pkgs/jnigen steps: - - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - name: Setup clang uses: egor-tensin/setup-clang@ef434b41eb33a70396fb336b1bae39c76d740c3d with: @@ -257,7 +257,7 @@ jobs: run: working-directory: ./pkgs/jni steps: - - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' @@ -278,7 +278,7 @@ jobs: run: working-directory: ./pkgs/jnigen steps: - - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - name: Setup clang format uses: ConorMacBride/install-package@3e7ad059e07782ee54fa35f827df52aae0626f30 with: @@ -303,7 +303,7 @@ jobs: run: working-directory: ./pkgs/jni/example steps: - - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' @@ -327,7 +327,7 @@ jobs: run: working-directory: ./pkgs/jni/example steps: - - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' @@ -347,7 +347,7 @@ jobs: run: working-directory: ./pkgs/jni/example steps: - - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 with: distribution: 'zulu' @@ -366,7 +366,7 @@ jobs: run: working-directory: ./pkgs/jnigen/example/pdfbox_plugin steps: - - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' From cf3db19856162f79b508b395e0715468d0f895e9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 May 2023 08:55:58 +0200 Subject: [PATCH 083/139] [jnigen] Bump coverallsapp/github-action from 2.0.0 to 2.1.2 (https://github.com/dart-lang/jnigen/issues/269) Bumps [coverallsapp/github-action](https://github.com/coverallsapp/github-action) from 2.0.0 to 2.1.2. - [Release notes](https://github.com/coverallsapp/github-action/releases) - [Commits](https://github.com/coverallsapp/github-action/compare/67662d24394fd74bffcf7b462d1b432814159afd...f350da2c033043742f89e8c0b7b5145a1616da6d) --- updated-dependencies: - dependency-name: coverallsapp/github-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/test-package.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index e059842e2..035466b54 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -101,7 +101,7 @@ jobs: - name: Collect coverage run: dart pub global run coverage:test_with_coverage - name: Upload coverage - uses: coverallsapp/github-action@67662d24394fd74bffcf7b462d1b432814159afd + uses: coverallsapp/github-action@f350da2c033043742f89e8c0b7b5145a1616da6d with: github-token: ${{ secrets.GITHUB_TOKEN }} flag-name: jnigen_tests @@ -177,7 +177,7 @@ jobs: - name: Collect coverage run: dart pub global run coverage:test_with_coverage - name: Upload coverage - uses: coverallsapp/github-action@67662d24394fd74bffcf7b462d1b432814159afd + uses: coverallsapp/github-action@f350da2c033043742f89e8c0b7b5145a1616da6d with: github-token: ${{ secrets.GITHUB_TOKEN }} flag-name: jni_tests @@ -412,7 +412,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Coveralls finished - uses: coverallsapp/github-action@67662d24394fd74bffcf7b462d1b432814159afd + uses: coverallsapp/github-action@f350da2c033043742f89e8c0b7b5145a1616da6d with: github-token: ${{ secrets.github_token }} parallel-finished: true From fa265a8c5bc1792e5fc00a3a258bd49992d0ac81 Mon Sep 17 00:00:00 2001 From: Mahesh Hegde <46179734+mahesh-hegde@users.noreply.github.com> Date: Tue, 2 May 2023 14:41:49 +0530 Subject: [PATCH 084/139] [jnigen] Stress tests and a few runtime fixes (https://github.com/dart-lang/jnigen/issues/264) * Generate and compare both types of bindings * Add load tests * Add test cases against exception throwing * add to_global_ref_result function to dartjni.h * Fix field getter double call in certain cases --- .github/workflows/test-package.yml | 17 +- pkgs/jni/bin/setup.dart | 16 +- pkgs/jni/dart_test.yaml | 7 + .../integration_test/on_device_jni_test.dart | 2 + pkgs/jni/lib/src/jarray.dart | 8 +- .../third_party/global_env_extensions.dart | 8 +- .../third_party/jni_bindings_generated.dart | 4 +- pkgs/jni/src/dartjni.c | 110 +- pkgs/jni/src/dartjni.h | 23 +- pkgs/jni/test/load_test.dart | 134 + pkgs/jnigen/android_test_runner/.gitignore | 44 + pkgs/jnigen/android_test_runner/.metadata | 30 + pkgs/jnigen/android_test_runner/README.md | 17 + .../android_test_runner/analysis_options.yaml | 29 + .../android_test_runner/android/.gitignore | 13 + .../android/app/.gitignore | 1 + .../android/app/CMakeLists.txt | 10 + .../android/app/build.gradle | 79 + .../android/app/src/debug/AndroidManifest.xml | 8 + .../android/app/src/main/AndroidManifest.xml | 34 + .../android_integration_test/MainActivity.kt | 6 + .../res/drawable-v21/launch_background.xml | 12 + .../main/res/drawable/launch_background.xml | 12 + .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 544 bytes .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 442 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 721 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 1031 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 1443 bytes .../app/src/main/res/values-night/styles.xml | 18 + .../app/src/main/res/values/styles.xml | 18 + .../app/src/profile/AndroidManifest.xml | 8 + .../android_test_runner/android/build.gradle | 31 + .../android/gradle.properties | 3 + .../gradle/wrapper/gradle-wrapper.properties | 5 + .../android/settings.gradle | 11 + .../integration_test/.gitignore | 1 + pkgs/jnigen/android_test_runner/lib/main.dart | 52 + pkgs/jnigen/android_test_runner/pubspec.yaml | 94 + pkgs/jnigen/dart_test.yaml | 2 + .../src/android_utils/android_utils.c | 342 +- .../in_app_java/src/android_utils/dartjni.h | 23 +- .../example/kotlin_plugin/src/dartjni.h | 23 +- .../src/kotlin_plugin_bindings.c | 6 +- .../example/notification_plugin/src/dartjni.h | 23 +- .../src/notification_plugin.c | 3 +- .../apache/pdfbox/text/PDFTextStripper.dart | 19 +- .../pdfbox_plugin/src/third_party/dartjni.h | 23 +- .../src/third_party/pdfbox_plugin.c | 222 +- pkgs/jnigen/lib/src/bindings/c_bindings.dart | 21 +- .../lib/src/bindings/dart_generator.dart | 7 +- pkgs/jnigen/lib/src/config/config_types.dart | 10 + pkgs/jnigen/test/.gitignore | 4 +- pkgs/jnigen/test/README.md | 18 +- pkgs/jnigen/test/bindings_test.dart | 447 -- pkgs/jnigen/test/config_test.dart | 16 +- .../test/jackson_core_test/generate.dart | 26 +- .../generated_files_test.dart | 12 +- .../jnigen/test/jackson_core_test/jnigen.yaml | 8 +- .../runtime_test_registrant.dart | 42 + .../c_based/c_bindings}/.clang-format | 0 .../c_based/c_bindings/CMakeLists.txt | 32 + .../third_party/c_based/c_bindings}/dartjni.h | 23 +- .../c_based/c_bindings/jackson_core.c | 3729 +++++++++++++++++ .../c_based/dart_bindings/_init.dart | 24 + .../fasterxml/jackson/core/JsonFactory.dart | 1994 +++++++++ .../fasterxml/jackson/core/JsonParser.dart | 2842 +++++++++++++ .../com/fasterxml/jackson/core/JsonToken.dart | 235 ++ .../com/fasterxml/jackson/core/_package.dart | 0 .../dart_bindings}/_init.dart | 0 .../fasterxml/jackson/core/JsonFactory.dart | 0 .../fasterxml/jackson/core/JsonParser.dart | 0 .../com/fasterxml/jackson/core/JsonToken.dart | 0 .../com/fasterxml/jackson/core/_package.dart | 3 + .../third_party/dart_only/lib/_init.dart | 23 + .../fasterxml/jackson/core/JsonFactory.dart | 1879 +++++++++ .../fasterxml/jackson/core/JsonParser.dart | 2640 ++++++++++++ .../com/fasterxml/jackson/core/JsonToken.dart | 223 + .../com/fasterxml/jackson/core/_package.dart | 3 + .../c_based/c_bindings}/.clang-format | 0 .../c_bindings}/CMakeLists.txt | 0 .../c_based/c_bindings}/dartjni.h | 23 +- .../{src => c_based/c_bindings}/kotlin.c | 9 +- .../dart_bindings}/kotlin.dart | 0 .../dart_only/dart_bindings/kotlin.dart | 118 + pkgs/jnigen/test/kotlin_test/generate.dart | 12 +- .../kotlin_test/generated_files_test.dart | 17 +- .../kotlin_test/runtime_test_registrant.dart | 26 + .../jnigen/test/regenerate_examples_test.dart | 9 +- .../test/simple_package_test/.gitignore | 3 +- .../c_based/c_bindings/.clang-format | 15 + .../c_bindings}/CMakeLists.txt | 0 .../c_based/c_bindings/dartjni.h | 378 ++ .../c_bindings}/simple_package.c | 1483 +++++-- .../dart_bindings}/simple_package.dart | 1271 +++++- .../dart_bindings/simple_package.dart | 2680 ++++++++++++ .../test/simple_package_test/generate.dart | 12 +- .../generated_files_test.dart | 14 +- .../jnigen/simple_package/Example.java | 165 +- .../jnigen/simple_package/Exceptions.java | 81 + .../jnigen/simple_package/Fields.java | 34 + .../runtime_test_registrant.dart | 559 +++ pkgs/jnigen/test/summary_generation_test.dart | 36 +- .../test/test_util/bindings_test_setup.dart | 77 + .../jnigen/test/test_util/callback_types.dart | 12 + pkgs/jnigen/test/test_util/test_util.dart | 93 +- pkgs/jnigen/tool/generate_runtime_tests.dart | 183 + 106 files changed, 21544 insertions(+), 1578 deletions(-) create mode 100644 pkgs/jni/dart_test.yaml create mode 100644 pkgs/jni/test/load_test.dart create mode 100644 pkgs/jnigen/android_test_runner/.gitignore create mode 100644 pkgs/jnigen/android_test_runner/.metadata create mode 100644 pkgs/jnigen/android_test_runner/README.md create mode 100644 pkgs/jnigen/android_test_runner/analysis_options.yaml create mode 100644 pkgs/jnigen/android_test_runner/android/.gitignore create mode 100644 pkgs/jnigen/android_test_runner/android/app/.gitignore create mode 100644 pkgs/jnigen/android_test_runner/android/app/CMakeLists.txt create mode 100644 pkgs/jnigen/android_test_runner/android/app/build.gradle create mode 100644 pkgs/jnigen/android_test_runner/android/app/src/debug/AndroidManifest.xml create mode 100644 pkgs/jnigen/android_test_runner/android/app/src/main/AndroidManifest.xml create mode 100644 pkgs/jnigen/android_test_runner/android/app/src/main/kotlin/com/github/dart_lang/jnigen/android_integration_test/MainActivity.kt create mode 100644 pkgs/jnigen/android_test_runner/android/app/src/main/res/drawable-v21/launch_background.xml create mode 100644 pkgs/jnigen/android_test_runner/android/app/src/main/res/drawable/launch_background.xml create mode 100644 pkgs/jnigen/android_test_runner/android/app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 pkgs/jnigen/android_test_runner/android/app/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 pkgs/jnigen/android_test_runner/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 pkgs/jnigen/android_test_runner/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 pkgs/jnigen/android_test_runner/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 pkgs/jnigen/android_test_runner/android/app/src/main/res/values-night/styles.xml create mode 100644 pkgs/jnigen/android_test_runner/android/app/src/main/res/values/styles.xml create mode 100644 pkgs/jnigen/android_test_runner/android/app/src/profile/AndroidManifest.xml create mode 100644 pkgs/jnigen/android_test_runner/android/build.gradle create mode 100644 pkgs/jnigen/android_test_runner/android/gradle.properties create mode 100644 pkgs/jnigen/android_test_runner/android/gradle/wrapper/gradle-wrapper.properties create mode 100644 pkgs/jnigen/android_test_runner/android/settings.gradle create mode 100644 pkgs/jnigen/android_test_runner/integration_test/.gitignore create mode 100644 pkgs/jnigen/android_test_runner/lib/main.dart create mode 100644 pkgs/jnigen/android_test_runner/pubspec.yaml delete mode 100644 pkgs/jnigen/test/bindings_test.dart create mode 100644 pkgs/jnigen/test/jackson_core_test/runtime_test_registrant.dart rename pkgs/jnigen/test/{kotlin_test/src => jackson_core_test/third_party/c_based/c_bindings}/.clang-format (100%) create mode 100644 pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/CMakeLists.txt rename pkgs/jnigen/test/{kotlin_test/src => jackson_core_test/third_party/c_based/c_bindings}/dartjni.h (94%) create mode 100644 pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/jackson_core.c create mode 100644 pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/_init.dart create mode 100644 pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart create mode 100644 pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart create mode 100644 pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart rename pkgs/jnigen/test/jackson_core_test/third_party/{lib => c_based/dart_bindings}/com/fasterxml/jackson/core/_package.dart (100%) rename pkgs/jnigen/test/jackson_core_test/third_party/{lib => dart_only/dart_bindings}/_init.dart (100%) rename pkgs/jnigen/test/jackson_core_test/third_party/{lib => dart_only/dart_bindings}/com/fasterxml/jackson/core/JsonFactory.dart (100%) rename pkgs/jnigen/test/jackson_core_test/third_party/{lib => dart_only/dart_bindings}/com/fasterxml/jackson/core/JsonParser.dart (100%) rename pkgs/jnigen/test/jackson_core_test/third_party/{lib => dart_only/dart_bindings}/com/fasterxml/jackson/core/JsonToken.dart (100%) create mode 100644 pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/_package.dart create mode 100644 pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/_init.dart create mode 100644 pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/com/fasterxml/jackson/core/JsonFactory.dart create mode 100644 pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/com/fasterxml/jackson/core/JsonParser.dart create mode 100644 pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/com/fasterxml/jackson/core/JsonToken.dart create mode 100644 pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/com/fasterxml/jackson/core/_package.dart rename pkgs/jnigen/test/{simple_package_test/src => kotlin_test/c_based/c_bindings}/.clang-format (100%) rename pkgs/jnigen/test/kotlin_test/{src => c_based/c_bindings}/CMakeLists.txt (100%) rename pkgs/jnigen/test/{simple_package_test/src => kotlin_test/c_based/c_bindings}/dartjni.h (94%) rename pkgs/jnigen/test/kotlin_test/{src => c_based/c_bindings}/kotlin.c (88%) rename pkgs/jnigen/test/kotlin_test/{lib => c_based/dart_bindings}/kotlin.dart (100%) create mode 100644 pkgs/jnigen/test/kotlin_test/dart_only/dart_bindings/kotlin.dart create mode 100644 pkgs/jnigen/test/kotlin_test/runtime_test_registrant.dart create mode 100644 pkgs/jnigen/test/simple_package_test/c_based/c_bindings/.clang-format rename pkgs/jnigen/test/simple_package_test/{src => c_based/c_bindings}/CMakeLists.txt (100%) create mode 100644 pkgs/jnigen/test/simple_package_test/c_based/c_bindings/dartjni.h rename pkgs/jnigen/test/simple_package_test/{src => c_based/c_bindings}/simple_package.c (51%) rename pkgs/jnigen/test/simple_package_test/{lib => c_based/dart_bindings}/simple_package.dart (62%) create mode 100644 pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart create mode 100644 pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/simple_package/Exceptions.java create mode 100644 pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/simple_package/Fields.java create mode 100644 pkgs/jnigen/test/simple_package_test/runtime_test_registrant.dart create mode 100644 pkgs/jnigen/test/test_util/bindings_test_setup.dart create mode 100644 pkgs/jnigen/test/test_util/callback_types.dart create mode 100644 pkgs/jnigen/tool/generate_runtime_tests.dart diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 035466b54..aa8b68474 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -45,11 +45,14 @@ jobs: - id: install name: Install dependencies run: dart pub get + - name: install dependencies for android test runner + run: flutter pub get + working-directory: ./pkgs/jnigen/android_test_runner - 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 + run: flutter analyze --fatal-infos if: always() && steps.install.outcome == 'success' test_jnigen: @@ -94,6 +97,8 @@ jobs: working-directory: ./pkgs/jnigen/java - name: Build summarizer run: dart run jnigen:setup + - name: Generate runtime tests + run: dart run tool/generate_runtime_tests.dart - name: Run VM tests run: dart test --test-randomize-ordering-seed random - name: Install coverage @@ -247,6 +252,8 @@ jobs: working-directory: ./pkgs/jnigen/example/notification_plugin/example - name: Build summarizer run: dart run jnigen:setup + - name: Generate runtime tests + run: dart run tool/generate_runtime_tests.dart - name: Run tests run: dart test --test-randomize-ordering-seed random @@ -294,8 +301,12 @@ jobs: java-version: '11' - run: git config --global core.autocrlf true - run: dart pub get - - run: dart run jnigen:setup - - run: dart test --test-randomize-ordering-seed random + - name: Build summarizer + run: dart run jnigen:setup + - name: Generate runtime tests + run: dart run tool/generate_runtime_tests.dart + - name: Run tests + run: dart test --test-randomize-ordering-seed random build_jni_example_linux: runs-on: ubuntu-latest diff --git a/pkgs/jni/bin/setup.dart b/pkgs/jni/bin/setup.dart index 3f5bb79dd..12ee6f976 100644 --- a/pkgs/jni/bin/setup.dart +++ b/pkgs/jni/bin/setup.dart @@ -35,7 +35,7 @@ Future runCommand( final cmd = "$exec ${args.join(" ")}"; stderr.writeln("+ [$workingDir] $cmd"); - int exitCode; + int status; if (options.verbose) { final process = await Process.start( exec, args, @@ -44,13 +44,17 @@ Future runCommand( // without `runInShell`, sometimes cmake doesn't run on windows. runInShell: true, ); - exitCode = await process.exitCode; + status = await process.exitCode; + if (status != 0) { + exitCode = status; + } } else { // ProcessStartMode.normal sometimes hangs on windows. No idea why. final process = await Process.run(exec, args, runInShell: true, workingDirectory: workingDir); - exitCode = process.exitCode; - if (exitCode != 0) { + status = process.exitCode; + if (status != 0) { + exitCode = status; var out = process.stdout; var err = process.stderr; if (stdout.supportsAnsiEscapes) { @@ -61,8 +65,8 @@ Future runCommand( stderr.writeln(err); } } - if (exitCode != 0) { - stderr.writeln("Command exited with $exitCode."); + if (status != 0) { + stderr.writeln('Command exited with status code $status'); } } diff --git a/pkgs/jni/dart_test.yaml b/pkgs/jni/dart_test.yaml new file mode 100644 index 000000000..361ada42e --- /dev/null +++ b/pkgs/jni/dart_test.yaml @@ -0,0 +1,7 @@ +## 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. + +tags: + load_test: + timeout: 10x 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 769ae6b7f..27be71916 100644 --- a/pkgs/jni/example/integration_test/on_device_jni_test.dart +++ b/pkgs/jni/example/integration_test/on_device_jni_test.dart @@ -9,6 +9,7 @@ import '../../test/exception_test.dart' as exception_test; import '../../test/jobject_test.dart' as jobject_test; import '../../test/jarray_test.dart' as jarray_test; import '../../test/type_test.dart' as type_test; +import '../../test/load_test.dart' as load_test; void integrationTestRunner(String description, void Function() testCallback) { testWidgets(description, (widgetTester) async => testCallback()); @@ -21,6 +22,7 @@ void main() { jobject_test.run, jarray_test.run, type_test.run, + load_test.run, ]; for (var testSuite in testSuites) { testSuite(testRunner: integrationTestRunner); diff --git a/pkgs/jni/lib/src/jarray.dart b/pkgs/jni/lib/src/jarray.dart index 8b0aead19..c095da73e 100644 --- a/pkgs/jni/lib/src/jarray.dart +++ b/pkgs/jni/lib/src/jarray.dart @@ -56,14 +56,14 @@ class JArray extends JObject { final clazz = (type as JObjType).getClass(); final array = JArray.fromRef( type, - _accessors.newObjectArray(length, clazz.reference, nullptr).checkedRef, + _accessors.newObjectArray(length, clazz.reference, nullptr).object, ); clazz.delete(); return array; } return JArray.fromRef( type, - _accessors.newPrimitiveArray(length, type._type).checkedRef, + _accessors.newPrimitiveArray(length, type._type).object, ); } @@ -76,9 +76,7 @@ class JArray extends JObject { final clazz = fill.getClass(); final array = JArray.fromRef( fill.$type as JObjType, - _accessors - .newObjectArray(length, clazz.reference, fill.reference) - .checkedRef, + _accessors.newObjectArray(length, clazz.reference, fill.reference).object, ); clazz.delete(); return array; diff --git a/pkgs/jni/lib/src/third_party/global_env_extensions.dart b/pkgs/jni/lib/src/third_party/global_env_extensions.dart index 2d2a02892..2fe400109 100644 --- a/pkgs/jni/lib/src/third_party/global_env_extensions.dart +++ b/pkgs/jni/lib/src/third_party/global_env_extensions.dart @@ -1467,14 +1467,14 @@ class JniAccessors { _newObject(cls, ctor, args); late final _newPrimitiveArray = ptr.ref.newPrimitiveArray - .asFunction(); - JniPointerResult newPrimitiveArray(int length, int type) => + .asFunction(); + JniResult newPrimitiveArray(int length, int type) => _newPrimitiveArray(length, type); late final _newObjectArray = ptr.ref.newObjectArray.asFunction< - JniPointerResult Function( + JniResult Function( int length, JClassPtr elementClass, JObjectPtr initialElement)>(); - JniPointerResult newObjectArray( + JniResult newObjectArray( int length, JClassPtr elementClass, JObjectPtr initialElement) => _newObjectArray(length, elementClass, initialElement); 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 6d54cda41..7cb2bdb8f 100644 --- a/pkgs/jni/lib/src/third_party/jni_bindings_generated.dart +++ b/pkgs/jni/lib/src/third_party/jni_bindings_generated.dart @@ -343,12 +343,12 @@ class JniAccessorsStruct extends ffi.Struct { external ffi.Pointer< ffi.NativeFunction< - JniPointerResult Function(JSizeMarker length, ffi.Int type)>> + JniResult Function(JSizeMarker length, ffi.Int type)>> newPrimitiveArray; external ffi.Pointer< ffi.NativeFunction< - JniPointerResult Function(JSizeMarker length, JClassPtr elementClass, + JniResult Function(JSizeMarker length, JClassPtr elementClass, JObjectPtr initialElement)>> newObjectArray; external ffi.Pointer< diff --git a/pkgs/jni/src/dartjni.c b/pkgs/jni/src/dartjni.c index 7346fef1a..19a32ebed 100644 --- a/pkgs/jni/src/dartjni.c +++ b/pkgs/jni/src/dartjni.c @@ -200,10 +200,7 @@ JniClassLookupResult getClass(char* internalName) { return result; } -typedef void* (*MemberGetter)(JNIEnv* env, - jclass* clazz, - char* name, - char* sig); +typedef void* (*MemberGetter)(JNIEnv* env, jclass clazz, char* name, char* sig); static inline JniPointerResult _getId(MemberGetter getter, jclass cls, @@ -264,15 +261,17 @@ JniResult callMethod(jobject obj, result.d = (*jniEnv)->CallDoubleMethodA(jniEnv, obj, fieldID, args); break; case objectType: - result.l = to_global_ref( - (*jniEnv)->CallObjectMethodA(jniEnv, obj, fieldID, args)); + result.l = (*jniEnv)->CallObjectMethodA(jniEnv, obj, fieldID, args); break; case voidType: (*jniEnv)->CallVoidMethodA(jniEnv, obj, fieldID, args); break; } - JniResult jniResult = {.value = result, .exception = NULL}; - jniResult.exception = check_exception(); + jthrowable exception = check_exception(); + if (callType == objectType && exception == NULL) { + result.l = to_global_ref(result.l); + } + JniResult jniResult = {.value = result, .exception = exception}; return jniResult; } @@ -311,15 +310,18 @@ JniResult callStaticMethod(jclass cls, (*jniEnv)->CallStaticDoubleMethodA(jniEnv, cls, methodID, args); break; case objectType: - result.l = to_global_ref( - (*jniEnv)->CallStaticObjectMethodA(jniEnv, cls, methodID, args)); + result.l = + (*jniEnv)->CallStaticObjectMethodA(jniEnv, cls, methodID, args); break; case voidType: (*jniEnv)->CallStaticVoidMethodA(jniEnv, cls, methodID, args); break; } - JniResult jniResult = {.value = result, .exception = NULL}; - jniResult.exception = check_exception(); + jthrowable exception = check_exception(); + if (callType == objectType && exception == NULL) { + result.l = to_global_ref(result.l); + } + JniResult jniResult = {.value = result, .exception = exception}; return jniResult; } @@ -352,14 +354,17 @@ JniResult getField(jobject obj, jfieldID fieldID, int callType) { result.d = (*jniEnv)->GetDoubleField(jniEnv, obj, fieldID); break; case objectType: - result.l = to_global_ref((*jniEnv)->GetObjectField(jniEnv, obj, fieldID)); + result.l = (*jniEnv)->GetObjectField(jniEnv, obj, fieldID); break; case voidType: // This error should have been handled in Dart. break; } - JniResult jniResult = {.value = result, .exception = NULL}; - jniResult.exception = check_exception(); + jthrowable exception = check_exception(); + if (callType == objectType && exception == NULL) { + result.l = to_global_ref(result.l); + } + JniResult jniResult = {.value = result, .exception = exception}; return jniResult; } @@ -393,8 +398,7 @@ JniResult getStaticField(jclass cls, jfieldID fieldID, int callType) { result.d = (*jniEnv)->GetStaticDoubleField(jniEnv, cls, fieldID); break; case objectType: - result.l = - to_global_ref((*jniEnv)->GetStaticObjectField(jniEnv, cls, fieldID)); + result.l = (*jniEnv)->GetStaticObjectField(jniEnv, cls, fieldID); break; case voidType: // This error should have been handled in dart. @@ -402,47 +406,47 @@ JniResult getStaticField(jclass cls, jfieldID fieldID, int callType) { // or throw exception in Dart using Dart's C API. break; } - JniResult jniResult = {.value = result, .exception = NULL}; - jniResult.exception = check_exception(); + jthrowable exception = check_exception(); + if (callType == objectType && exception == NULL) { + result.l = to_global_ref(result.l); + } + JniResult jniResult = {.value = result, .exception = exception}; return jniResult; } JniResult newObject(jclass cls, jmethodID ctor, jvalue* args) { attach_thread(); - JniResult jniResult; - jniResult.value.l = - to_global_ref((*jniEnv)->NewObjectA(jniEnv, cls, ctor, args)); - jniResult.exception = check_exception(); - return jniResult; + jobject result = (*jniEnv)->NewObjectA(jniEnv, cls, ctor, args); + return to_global_ref_result(result); } -JniPointerResult newPrimitiveArray(jsize length, int type) { +JniResult newPrimitiveArray(jsize length, int type) { attach_thread(); - void* pointer; + jarray array; switch (type) { case booleanType: - pointer = (*jniEnv)->NewBooleanArray(jniEnv, length); + array = (*jniEnv)->NewBooleanArray(jniEnv, length); break; case byteType: - pointer = (*jniEnv)->NewByteArray(jniEnv, length); + array = (*jniEnv)->NewByteArray(jniEnv, length); break; case shortType: - pointer = (*jniEnv)->NewShortArray(jniEnv, length); + array = (*jniEnv)->NewShortArray(jniEnv, length); break; case charType: - pointer = (*jniEnv)->NewCharArray(jniEnv, length); + array = (*jniEnv)->NewCharArray(jniEnv, length); break; case intType: - pointer = (*jniEnv)->NewIntArray(jniEnv, length); + array = (*jniEnv)->NewIntArray(jniEnv, length); break; case longType: - pointer = (*jniEnv)->NewLongArray(jniEnv, length); + array = (*jniEnv)->NewLongArray(jniEnv, length); break; case floatType: - pointer = (*jniEnv)->NewFloatArray(jniEnv, length); + array = (*jniEnv)->NewFloatArray(jniEnv, length); break; case doubleType: - pointer = (*jniEnv)->NewDoubleArray(jniEnv, length); + array = (*jniEnv)->NewDoubleArray(jniEnv, length); break; case objectType: case voidType: @@ -451,21 +455,16 @@ JniPointerResult newPrimitiveArray(jsize length, int type) { // or throw exception in Dart using Dart's C API. break; } - JniPointerResult result = {.value = to_global_ref(pointer), - .exception = NULL}; - result.exception = check_exception(); - return result; + return to_global_ref_result(array); } -JniPointerResult newObjectArray(jsize length, - jclass elementClass, - jobject initialElement) { +JniResult newObjectArray(jsize length, + jclass elementClass, + jobject initialElement) { attach_thread(); - jarray array = to_global_ref( - (*jniEnv)->NewObjectArray(jniEnv, length, elementClass, initialElement)); - JniPointerResult result = {.value = array, .exception = NULL}; - result.exception = check_exception(); - return result; + jarray array = + (*jniEnv)->NewObjectArray(jniEnv, length, elementClass, initialElement); + return to_global_ref_result(array); } JniResult getArrayElement(jarray array, int index, int type) { @@ -498,17 +497,19 @@ JniResult getArrayElement(jarray array, int index, int type) { (*jniEnv)->GetDoubleArrayRegion(jniEnv, array, index, 1, &value.d); break; case objectType: - value.l = - to_global_ref((*jniEnv)->GetObjectArrayElement(jniEnv, array, index)); + value.l = (*jniEnv)->GetObjectArrayElement(jniEnv, array, index); case voidType: // This error should have been handled in dart. // is there a way to mark this as unreachable? // or throw exception in Dart using Dart's C API. break; } - result.value = value; - result.exception = check_exception(); - return result; + jthrowable exception = check_exception(); + if (type == objectType && exception == NULL) { + value.l = to_global_ref(value.l); + } + JniResult jniResult = {.value = value, .exception = exception}; + return jniResult; } JniExceptionDetails getExceptionDetails(jthrowable exception) { @@ -595,6 +596,9 @@ JniResult PortContinuation__ctor(int64_t j) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_PortContinuation, _m_PortContinuation__ctor, j); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + jthrowable exception = check_exception(); + if (exception == NULL) { + _result = to_global_ref(_result); + } + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } diff --git a/pkgs/jni/src/dartjni.h b/pkgs/jni/src/dartjni.h index 21cef2036..c0713af53 100644 --- a/pkgs/jni/src/dartjni.h +++ b/pkgs/jni/src/dartjni.h @@ -176,10 +176,10 @@ typedef struct JniAccessorsStruct { char* methodName, char* signature); JniResult (*newObject)(jclass cls, jmethodID ctor, jvalue* args); - JniPointerResult (*newPrimitiveArray)(jsize length, int type); - JniPointerResult (*newObjectArray)(jsize length, - jclass elementClass, - jobject initialElement); + JniResult (*newPrimitiveArray)(jsize length, int type); + JniResult (*newObjectArray)(jsize length, + jclass elementClass, + jobject initialElement); JniResult (*getArrayElement)(jarray array, int index, int type); JniResult (*callMethod)(jobject obj, jmethodID methodID, @@ -261,8 +261,10 @@ static inline void load_class_global_ref(jclass* cls, const char* name) { acquire_lock(&jni->locks.classLoadingLock); if (*cls == NULL) { load_class_platform(&tmp, name); - *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); - (*jniEnv)->DeleteLocalRef(jniEnv, tmp); + if (!(*jniEnv)->ExceptionCheck(jniEnv)) { + *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); + (*jniEnv)->DeleteLocalRef(jniEnv, tmp); + } } release_lock(&jni->locks.classLoadingLock); } @@ -356,6 +358,15 @@ static inline jthrowable check_exception() { return to_global_ref(exception); } +static inline JniResult to_global_ref_result(jobject ref) { + JniResult result; + result.exception = check_exception(); + if (result.exception == NULL) { + result.value.l = to_global_ref(ref); + } + return result; +} + FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); JNIEXPORT void JNICALL diff --git a/pkgs/jni/test/load_test.dart b/pkgs/jni/test/load_test.dart new file mode 100644 index 000000000..162b3e9ec --- /dev/null +++ b/pkgs/jni/test/load_test.dart @@ -0,0 +1,134 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +@Tags(['load_test']) + +import 'dart:io'; +import 'dart:ffi'; +import 'dart:math'; + +import 'package:ffi/ffi.dart'; +import 'package:test/test.dart'; + +import 'package:jni/jni.dart'; + +import 'test_util/test_util.dart'; + +const maxLongInJava = 9223372036854775807; + +/// Taken from +/// https://github.com/dart-lang/ffigen/blob/master/test/native_objc_test/automated_ref_count_test.dart +final executeInternalCommand = DynamicLibrary.process().lookupFunction< + Void Function(Pointer, Pointer), + void Function(Pointer, Pointer)>('Dart_ExecuteInternalCommand'); + +void doGC() { + final gcNow = "gc-now".toNativeUtf8(); + executeInternalCommand(gcNow.cast(), nullptr); + calloc.free(gcNow); +} + +void main() { + if (!Platform.isAndroid) { + checkDylibIsUpToDate(); + Jni.spawnIfNotExists(dylibDir: "build/jni_libs", jvmOptions: ["-Xmx128m"]); + } + run(testRunner: test); +} + +const k4 = 4 * 1024; +const k64 = 64 * 1024; +const k256 = 256 * 1024; + +const secureRandomSeedBound = 4294967296; + +JObject getSystemOut() => Jni.retrieveStaticField( + 'System', + 'out', + 'Ljava/io/PrintStream;', + ); + +final random = Random.secure(); + +JObject newRandom() => Jni.newInstance( + "java/util/Random", + "(J)V", + [random.nextInt(secureRandomSeedBound)], + ); + +void run({required TestRunnerCallback testRunner}) { + testRunner('Test 4K refs can be created in a row', () { + final list = []; + for (int i = 0; i < k4; i++) { + list.add(newRandom()); + } + for (final jobject in list) { + jobject.delete(); + } + }); + + testRunner('Create and delete 256K references in a loop using arena', () { + for (int i = 0; i < k256; i++) { + using((arena) { + final random = newRandom()..deletedIn(arena); + // The actual expect here does not matter. I am just being paranoid + // against assigning to `_` because compiler may optimize it. (It has + // side effect of calling FFI but still.) + expect(random.reference, isNot(nullptr)); + }); + } + }); + + testRunner('Create & delete 256K references in a loop (explicit delete)', () { + for (int i = 0; i < k256; i++) { + final random = newRandom(); + expect(random.reference, isNot(nullptr)); + random.delete(); + } + }); + + testRunner('Create and delete 64K references, in batches of 256', () { + for (int i = 0; i < 64 * 4; i++) { + using((arena) { + for (int i = 0; i < 256; i++) { + final r = newRandom()..deletedIn(arena); + expect(r.reference, isNot(nullptr)); + } + }); + } + }); + + // We don't have a direct way to check if something creates JNI references. + // So we are checking if we can run this for large number of times. + testRunner('Verify a call returning primitive can be run any times', () { + final random = newRandom(); + final nextInt = random.getMethodID("nextInt", "()I"); + for (int i = 0; i < k256; i++) { + final rInt = random.callMethod(nextInt, []); + expect(rInt, isA()); + } + }); + + void testRefValidityAfterGC(int delayInSeconds) { + testRunner('Validate reference after GC & ${delayInSeconds}s sleep', () { + final random = newRandom(); + doGC(); + sleep(Duration(seconds: delayInSeconds)); + expect( + random.callMethodByName("nextInt", "()I", []), + isA(), + ); + expect( + Jni.env.GetObjectRefType(random.reference), + equals(JObjectRefType.JNIGlobalRefType), + ); + }); + } + + // Dart_ExecuteInternalCommand doesn't exist in Android. + if (!Platform.isAndroid) { + testRefValidityAfterGC(1); + testRefValidityAfterGC(10); + } +} diff --git a/pkgs/jnigen/android_test_runner/.gitignore b/pkgs/jnigen/android_test_runner/.gitignore new file mode 100644 index 000000000..24476c5d1 --- /dev/null +++ b/pkgs/jnigen/android_test_runner/.gitignore @@ -0,0 +1,44 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ +/build/ + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/pkgs/jnigen/android_test_runner/.metadata b/pkgs/jnigen/android_test_runner/.metadata new file mode 100644 index 000000000..957ea81cf --- /dev/null +++ b/pkgs/jnigen/android_test_runner/.metadata @@ -0,0 +1,30 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled. + +version: + revision: f72efea43c3013323d1b95cff571f3c1caa37583 + channel: stable + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: f72efea43c3013323d1b95cff571f3c1caa37583 + base_revision: f72efea43c3013323d1b95cff571f3c1caa37583 + - platform: android + create_revision: f72efea43c3013323d1b95cff571f3c1caa37583 + base_revision: f72efea43c3013323d1b95cff571f3c1caa37583 + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/pkgs/jnigen/android_test_runner/README.md b/pkgs/jnigen/android_test_runner/README.md new file mode 100644 index 000000000..cd85e199b --- /dev/null +++ b/pkgs/jnigen/android_test_runner/README.md @@ -0,0 +1,17 @@ +## What's this? + +This is Flutter app project which serves as a skeleton for running binding runtime tests on android, using Flutter's integration testing mechanism. + +## How to run tests? + +Generate runtime test files, by running the following in parent (jnigen) directory. + +```bash +dart run tool/generate_runtime_tests.dart +``` + +This will generate integration_test/runtime_test.dart in this directory, along with other runtime tests for `jnigen`. This can be run with regular integration test mechanism. + +```bash +flutter test integration_test/ +``` \ No newline at end of file diff --git a/pkgs/jnigen/android_test_runner/analysis_options.yaml b/pkgs/jnigen/android_test_runner/analysis_options.yaml new file mode 100644 index 000000000..61b6c4de1 --- /dev/null +++ b/pkgs/jnigen/android_test_runner/analysis_options.yaml @@ -0,0 +1,29 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at + # https://dart-lang.github.io/linter/lints/index.html. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/pkgs/jnigen/android_test_runner/android/.gitignore b/pkgs/jnigen/android_test_runner/android/.gitignore new file mode 100644 index 000000000..6f568019d --- /dev/null +++ b/pkgs/jnigen/android_test_runner/android/.gitignore @@ -0,0 +1,13 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +key.properties +**/*.keystore +**/*.jks diff --git a/pkgs/jnigen/android_test_runner/android/app/.gitignore b/pkgs/jnigen/android_test_runner/android/app/.gitignore new file mode 100644 index 000000000..df2fa1737 --- /dev/null +++ b/pkgs/jnigen/android_test_runner/android/app/.gitignore @@ -0,0 +1 @@ +.cxx \ No newline at end of file diff --git a/pkgs/jnigen/android_test_runner/android/app/CMakeLists.txt b/pkgs/jnigen/android_test_runner/android/app/CMakeLists.txt new file mode 100644 index 000000000..7bc2474de --- /dev/null +++ b/pkgs/jnigen/android_test_runner/android/app/CMakeLists.txt @@ -0,0 +1,10 @@ +## Parent CMake for Android native build target. This will build +## all C bindings from tests. + +cmake_minimum_required(VERSION 3.10) + +project(simple_package VERSION 0.0.1 LANGUAGES C) + +add_subdirectory(../../../test/jackson_core_test/third_party/c_based/c_bindings jackson_core_test_build) +add_subdirectory(../../../test/simple_package_test/c_based/c_bindings simple_package_test_build) +add_subdirectory(../../../test/kotlin_test/c_based/c_bindings kotlin_test_build) diff --git a/pkgs/jnigen/android_test_runner/android/app/build.gradle b/pkgs/jnigen/android_test_runner/android/app/build.gradle new file mode 100644 index 000000000..e0c777fb1 --- /dev/null +++ b/pkgs/jnigen/android_test_runner/android/app/build.gradle @@ -0,0 +1,79 @@ +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterRoot = localProperties.getProperty('flutter.sdk') +if (flutterRoot == null) { + throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" + +android { + compileSdkVersion flutter.compileSdkVersion + ndkVersion flutter.ndkVersion + + compileOptions { + sourceCompatibility JavaVersion.VERSION_11 + targetCompatibility JavaVersion.VERSION_11 + } + + kotlinOptions { + jvmTarget = '1.8' + } + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + main.java.srcDirs += '../../../test/simple_package_test/java' + main.java.srcDirs += '../../../test/kotlin_test/kotlin/src/main' + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId "com.github.dart_lang.jnigen.android_integration_test" + // You can update the following values to match your application needs. + // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. + minSdkVersion flutter.minSdkVersion + targetSdkVersion flutter.targetSdkVersion + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.debug + } + } + externalNativeBuild { + cmake { + path 'CMakeLists.txt' + } + } +} + +flutter { + source '../..' +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation "com.fasterxml.jackson.core:jackson-core:2.13.4" +} diff --git a/pkgs/jnigen/android_test_runner/android/app/src/debug/AndroidManifest.xml b/pkgs/jnigen/android_test_runner/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 000000000..fc7efb6f4 --- /dev/null +++ b/pkgs/jnigen/android_test_runner/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,8 @@ + + + + diff --git a/pkgs/jnigen/android_test_runner/android/app/src/main/AndroidManifest.xml b/pkgs/jnigen/android_test_runner/android/app/src/main/AndroidManifest.xml new file mode 100644 index 000000000..84209fb25 --- /dev/null +++ b/pkgs/jnigen/android_test_runner/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/pkgs/jnigen/android_test_runner/android/app/src/main/kotlin/com/github/dart_lang/jnigen/android_integration_test/MainActivity.kt b/pkgs/jnigen/android_test_runner/android/app/src/main/kotlin/com/github/dart_lang/jnigen/android_integration_test/MainActivity.kt new file mode 100644 index 000000000..5197ccced --- /dev/null +++ b/pkgs/jnigen/android_test_runner/android/app/src/main/kotlin/com/github/dart_lang/jnigen/android_integration_test/MainActivity.kt @@ -0,0 +1,6 @@ +package com.github.dart_lang.jnigen.android_integration_test + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() { +} diff --git a/pkgs/jnigen/android_test_runner/android/app/src/main/res/drawable-v21/launch_background.xml b/pkgs/jnigen/android_test_runner/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 000000000..f74085f3f --- /dev/null +++ b/pkgs/jnigen/android_test_runner/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/pkgs/jnigen/android_test_runner/android/app/src/main/res/drawable/launch_background.xml b/pkgs/jnigen/android_test_runner/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 000000000..304732f88 --- /dev/null +++ b/pkgs/jnigen/android_test_runner/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/pkgs/jnigen/android_test_runner/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/pkgs/jnigen/android_test_runner/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..db77bb4b7b0906d62b1847e87f15cdcacf6a4f29 GIT binary patch literal 544 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY3?!3`olAj~WQl7;NpOBzNqJ&XDuZK6ep0G} zXKrG8YEWuoN@d~6R2!h8bpbvhu0Wd6uZuB!w&u2PAxD2eNXD>P5D~Wn-+_Wa#27Xc zC?Zj|6r#X(-D3u$NCt}(Ms06KgJ4FxJVv{GM)!I~&n8Bnc94O7-Hd)cjDZswgC;Qs zO=b+9!WcT8F?0rF7!Uys2bs@gozCP?z~o%U|N3vA*22NaGQG zlg@K`O_XuxvZ&Ks^m&R!`&1=spLvfx7oGDKDwpwW`#iqdw@AL`7MR}m`rwr|mZgU`8P7SBkL78fFf!WnuYWm$5Z0 zNXhDbCv&49sM544K|?c)WrFfiZvCi9h0O)B3Pgg&ebxsLQ05GG~ AQ2+n{ literal 0 HcmV?d00001 diff --git a/pkgs/jnigen/android_test_runner/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/pkgs/jnigen/android_test_runner/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..17987b79bb8a35cc66c3c1fd44f5a5526c1b78be GIT binary patch literal 442 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA3?vioaBc-sk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5Xx&nMcT!A!W`0S9QKQy;}1Cl^CgaH=;G9cpY;r$Q>i*pfB zP2drbID<_#qf;rPZx^FqH)F_D#*k@@q03KywUtLX8Ua?`H+NMzkczFPK3lFz@i_kW%1NOn0|D2I9n9wzH8m|-tHjsw|9>@K=iMBhxvkv6m8Y-l zytQ?X=U+MF$@3 zt`~i=@j|6y)RWMK--}M|=T`o&^Ni>IoWKHEbBXz7?A@mgWoL>!*SXo`SZH-*HSdS+ yn*9;$7;m`l>wYBC5bq;=U}IMqLzqbYCidGC!)_gkIk_C@Uy!y&wkt5C($~2D>~)O*cj@FGjOCM)M>_ixfudOh)?xMu#Fs z#}Y=@YDTwOM)x{K_j*Q;dPdJ?Mz0n|pLRx{4n|)f>SXlmV)XB04CrSJn#dS5nK2lM zrZ9#~WelCp7&e13Y$jvaEXHskn$2V!!DN-nWS__6T*l;H&Fopn?A6HZ-6WRLFP=R` zqG+CE#d4|IbyAI+rJJ`&x9*T`+a=p|0O(+s{UBcyZdkhj=yS1>AirP+0R;mf2uMgM zC}@~JfByORAh4SyRgi&!(cja>F(l*O+nd+@4m$|6K6KDn_&uvCpV23&>G9HJp{xgg zoq1^2_p9@|WEo z*X_Uko@K)qYYv~>43eQGMdbiGbo>E~Q& zrYBH{QP^@Sti!`2)uG{irBBq@y*$B zi#&(U-*=fp74j)RyIw49+0MRPMRU)+a2r*PJ$L5roHt2$UjExCTZSbq%V!HeS7J$N zdG@vOZB4v_lF7Plrx+hxo7(fCV&}fHq)$ literal 0 HcmV?d00001 diff --git a/pkgs/jnigen/android_test_runner/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/pkgs/jnigen/android_test_runner/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..d5f1c8d34e7a88e3f88bea192c3a370d44689c3c GIT binary patch literal 1031 zcmeAS@N?(olHy`uVBq!ia0vp^6F``Q8Ax83A=Cw=BuiW)N`mv#O3D+9QW+dm@{>{( zJaZG%Q-e|yQz{EjrrIztFa`(sgt!6~Yi|1%a`XoT0ojZ}lNrNjb9xjc(B0U1_% zz5^97Xt*%oq$rQy4?0GKNfJ44uvxI)gC`h-NZ|&0-7(qS@?b!5r36oQ}zyZrNO3 zMO=Or+<~>+A&uN&E!^Sl+>xE!QC-|oJv`ApDhqC^EWD|@=#J`=d#Xzxs4ah}w&Jnc z$|q_opQ^2TrnVZ0o~wh<3t%W&flvYGe#$xqda2bR_R zvPYgMcHgjZ5nSA^lJr%;<&0do;O^tDDh~=pIxA#coaCY>&N%M2^tq^U%3DB@ynvKo}b?yu-bFc-u0JHzced$sg7S3zqI(2 z#Km{dPr7I=pQ5>FuK#)QwK?Y`E`B?nP+}U)I#c1+FM*1kNvWG|a(TpksZQ3B@sD~b zpQ2)*V*TdwjFOtHvV|;OsiDqHi=6%)o4b!)x$)%9pGTsE z-JL={-Ffv+T87W(Xpooq<`r*VzWQcgBN$$`u}f>-ZQI1BB8ykN*=e4rIsJx9>z}*o zo~|9I;xof literal 0 HcmV?d00001 diff --git a/pkgs/jnigen/android_test_runner/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/pkgs/jnigen/android_test_runner/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..4d6372eebdb28e45604e46eeda8dd24651419bc0 GIT binary patch literal 1443 zcmb`G{WsKk6vsdJTdFg%tJav9_E4vzrOaqkWF|A724Nly!y+?N9`YV6wZ}5(X(D_N(?!*n3`|_r0Hc?=PQw&*vnU?QTFY zB_MsH|!j$PP;I}?dppoE_gA(4uc!jV&0!l7_;&p2^pxNo>PEcNJv za5_RT$o2Mf!<+r?&EbHH6nMoTsDOa;mN(wv8RNsHpG)`^ymG-S5By8=l9iVXzN_eG%Xg2@Xeq76tTZ*dGh~Lo9vl;Zfs+W#BydUw zCkZ$o1LqWQO$FC9aKlLl*7x9^0q%0}$OMlp@Kk_jHXOjofdePND+j!A{q!8~Jn+s3 z?~~w@4?egS02}8NuulUA=L~QQfm;MzCGd)XhiftT;+zFO&JVyp2mBww?;QByS_1w! zrQlx%{^cMj0|Bo1FjwY@Q8?Hx0cIPF*@-ZRFpPc#bBw{5@tD(5%sClzIfl8WU~V#u zm5Q;_F!wa$BSpqhN>W@2De?TKWR*!ujY;Yylk_X5#~V!L*Gw~;$%4Q8~Mad z@`-kG?yb$a9cHIApZDVZ^U6Xkp<*4rU82O7%}0jjHlK{id@?-wpN*fCHXyXh(bLt* zPc}H-x0e4E&nQ>y%B-(EL=9}RyC%MyX=upHuFhAk&MLbsF0LP-q`XnH78@fT+pKPW zu72MW`|?8ht^tz$iC}ZwLp4tB;Q49K!QCF3@!iB1qOI=?w z7In!}F~ij(18UYUjnbmC!qKhPo%24?8U1x{7o(+?^Zu0Hx81|FuS?bJ0jgBhEMzf< zCgUq7r2OCB(`XkKcN-TL>u5y#dD6D!)5W?`O5)V^>jb)P)GBdy%t$uUMpf$SNV31$ zb||OojAbvMP?T@$h_ZiFLFVHDmbyMhJF|-_)HX3%m=CDI+ID$0^C>kzxprBW)hw(v zr!Gmda);ICoQyhV_oP5+C%?jcG8v+D@9f?Dk*!BxY}dazmrT@64UrP3hlslANK)bq z$67n83eh}OeW&SV@HG95P|bjfqJ7gw$e+`Hxo!4cx`jdK1bJ>YDSpGKLPZ^1cv$ek zIB?0S<#tX?SJCLWdMd{-ME?$hc7A$zBOdIJ)4!KcAwb=VMov)nK;9z>x~rfT1>dS+ zZ6#`2v@`jgbqq)P22H)Tx2CpmM^o1$B+xT6`(v%5xJ(?j#>Q$+rx_R|7TzDZe{J6q zG1*EcU%tE?!kO%^M;3aM6JN*LAKUVb^xz8-Pxo#jR5(-KBeLJvA@-gxNHx0M-ZJLl z;#JwQoh~9V?`UVo#}{6ka@II>++D@%KqGpMdlQ}?9E*wFcf5(#XQnP$Dk5~%iX^>f z%$y;?M0BLp{O3a(-4A?ewryHrrD%cx#Q^%KY1H zNre$ve+vceSLZcNY4U(RBX&)oZn*Py()h)XkE?PL$!bNb{N5FVI2Y%LKEm%yvpyTP z(1P?z~7YxD~Rf<(a@_y` literal 0 HcmV?d00001 diff --git a/pkgs/jnigen/android_test_runner/android/app/src/main/res/values-night/styles.xml b/pkgs/jnigen/android_test_runner/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 000000000..06952be74 --- /dev/null +++ b/pkgs/jnigen/android_test_runner/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/pkgs/jnigen/android_test_runner/android/app/src/main/res/values/styles.xml b/pkgs/jnigen/android_test_runner/android/app/src/main/res/values/styles.xml new file mode 100644 index 000000000..cb1ef8805 --- /dev/null +++ b/pkgs/jnigen/android_test_runner/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/pkgs/jnigen/android_test_runner/android/app/src/profile/AndroidManifest.xml b/pkgs/jnigen/android_test_runner/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 000000000..fc7efb6f4 --- /dev/null +++ b/pkgs/jnigen/android_test_runner/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,8 @@ + + + + diff --git a/pkgs/jnigen/android_test_runner/android/build.gradle b/pkgs/jnigen/android_test_runner/android/build.gradle new file mode 100644 index 000000000..58a8c74b1 --- /dev/null +++ b/pkgs/jnigen/android_test_runner/android/build.gradle @@ -0,0 +1,31 @@ +buildscript { + ext.kotlin_version = '1.7.10' + repositories { + google() + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:7.2.0' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = '../build' +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(':app') +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/pkgs/jnigen/android_test_runner/android/gradle.properties b/pkgs/jnigen/android_test_runner/android/gradle.properties new file mode 100644 index 000000000..94adc3a3f --- /dev/null +++ b/pkgs/jnigen/android_test_runner/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx1536M +android.useAndroidX=true +android.enableJetifier=true diff --git a/pkgs/jnigen/android_test_runner/android/gradle/wrapper/gradle-wrapper.properties b/pkgs/jnigen/android_test_runner/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..3c472b99c --- /dev/null +++ b/pkgs/jnigen/android_test_runner/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip diff --git a/pkgs/jnigen/android_test_runner/android/settings.gradle b/pkgs/jnigen/android_test_runner/android/settings.gradle new file mode 100644 index 000000000..44e62bcf0 --- /dev/null +++ b/pkgs/jnigen/android_test_runner/android/settings.gradle @@ -0,0 +1,11 @@ +include ':app' + +def localPropertiesFile = new File(rootProject.projectDir, "local.properties") +def properties = new Properties() + +assert localPropertiesFile.exists() +localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + +def flutterSdkPath = properties.getProperty("flutter.sdk") +assert flutterSdkPath != null, "flutter.sdk not set in local.properties" +apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" diff --git a/pkgs/jnigen/android_test_runner/integration_test/.gitignore b/pkgs/jnigen/android_test_runner/integration_test/.gitignore new file mode 100644 index 000000000..af7c365a2 --- /dev/null +++ b/pkgs/jnigen/android_test_runner/integration_test/.gitignore @@ -0,0 +1 @@ +runtime_test.dart \ No newline at end of file diff --git a/pkgs/jnigen/android_test_runner/lib/main.dart b/pkgs/jnigen/android_test_runner/lib/main.dart new file mode 100644 index 000000000..8e8892848 --- /dev/null +++ b/pkgs/jnigen/android_test_runner/lib/main.dart @@ -0,0 +1,52 @@ +import 'package:flutter/material.dart'; + +void main() { + runApp(const MyApp()); +} + +class MyApp extends StatelessWidget { + const MyApp({super.key}); + + // This widget is the root of your application. + @override + Widget build(BuildContext context) { + return MaterialApp( + title: 'Flutter Demo', + theme: ThemeData( + // This is the theme of your application. + // + // Try running your application with "flutter run". You'll see the + // application has a blue toolbar. Then, without quitting the app, try + // changing the primarySwatch below to Colors.green and then invoke + // "hot reload" (press "r" in the console where you ran "flutter run", + // or simply save your changes to "hot reload" in a Flutter IDE). + // Notice that the counter didn't reset back to zero; the application + // is not restarted. + primarySwatch: Colors.blue, + ), + home: const MyHomePage(), + ); + } +} + +class MyHomePage extends StatelessWidget { + const MyHomePage({super.key}); + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text("Integration test runner"), + ), + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Text( + 'This app should be run as flutter integration test', + ), + ], + ), + ), + ); + } +} diff --git a/pkgs/jnigen/android_test_runner/pubspec.yaml b/pkgs/jnigen/android_test_runner/pubspec.yaml new file mode 100644 index 000000000..a457e7727 --- /dev/null +++ b/pkgs/jnigen/android_test_runner/pubspec.yaml @@ -0,0 +1,94 @@ +name: android_integration_test +description: jnigen integration test runner for android +# The following line prevents the package from being accidentally published to +# pub.dev using `flutter pub publish`. This is preferred for private packages. +publish_to: 'none' # Remove this line if you wish to publish to pub.dev + +# The following defines the version and build number for your application. +# A version number is three numbers separated by dots, like 1.2.43 +# followed by an optional build number separated by a +. +# Both the version and the builder number may be overridden in flutter +# build by specifying --build-name and --build-number, respectively. +# In Android, build-name is used as versionName while build-number used as versionCode. +# Read more about Android versioning at https://developer.android.com/studio/publish/versioning +# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. +# Read more about iOS versioning at +# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html +# In Windows, build-name is used as the major, minor, and patch parts +# of the product and file versions while build-number is used as the build suffix. +version: 1.0.0+1 + +environment: + sdk: '>=2.19.6 <3.0.0' + +# Dependencies specify other packages that your package needs in order to work. +# To automatically upgrade your package dependencies to the latest versions +# consider running `flutter pub upgrade --major-versions`. Alternatively, +# dependencies can be manually updated by changing the version numbers below to +# the latest version available on pub.dev. To see which dependencies have newer +# versions available, run `flutter pub outdated`. +dependencies: + jni: + path: ../../jni/ + ffi: any + flutter: + sdk: flutter + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^1.0.2 + +dev_dependencies: + test: any + flutter_test: + sdk: flutter + integration_test: + sdk: flutter + + # The "flutter_lints" package below contains a set of recommended lints to + # encourage good coding practices. The lint set provided by the package is + # activated in the `analysis_options.yaml` file located at the root of your + # package. See that file for information about deactivating specific lint + # rules and activating additional ones. + flutter_lints: ^2.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + + # To add assets to your application, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/assets-and-images/#from-packages + + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/custom-fonts/#from-packages diff --git a/pkgs/jnigen/dart_test.yaml b/pkgs/jnigen/dart_test.yaml index 0fb13bc13..fdd1587e3 100644 --- a/pkgs/jnigen/dart_test.yaml +++ b/pkgs/jnigen/dart_test.yaml @@ -10,3 +10,5 @@ tags: timeout: 2x summarizer_test: timeout: 1x + runtime_test: + timeout: 1x diff --git a/pkgs/jnigen/example/in_app_java/src/android_utils/android_utils.c b/pkgs/jnigen/example/in_app_java/src/android_utils/android_utils.c index 0fef6525d..6cf0cf289 100644 --- a/pkgs/jnigen/example/in_app_java/src/android_utils/android_utils.c +++ b/pkgs/jnigen/example/in_app_java/src/android_utils/android_utils.c @@ -55,8 +55,7 @@ JniResult EmojiCompat__init(jobject context) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_EmojiCompat, _m_EmojiCompat__init, context); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_EmojiCompat__init1 = NULL; @@ -74,8 +73,7 @@ JniResult EmojiCompat__init1(jobject context, jobject defaultFactory) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_EmojiCompat, _m_EmojiCompat__init1, context, defaultFactory); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_EmojiCompat__init2 = NULL; @@ -92,8 +90,7 @@ JniResult EmojiCompat__init2(jobject config) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_EmojiCompat, _m_EmojiCompat__init2, config); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_EmojiCompat__isConfigured = NULL; @@ -126,8 +123,7 @@ JniResult EmojiCompat__reset(jobject config) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_EmojiCompat, _m_EmojiCompat__reset, config); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_EmojiCompat__reset1 = NULL; @@ -144,8 +140,7 @@ JniResult EmojiCompat__reset1(jobject emojiCompat) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_EmojiCompat, _m_EmojiCompat__reset1, emojiCompat); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_EmojiCompat__skipDefaultConfigurationLookup = NULL; @@ -179,8 +174,7 @@ JniResult EmojiCompat__get0() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_EmojiCompat, _m_EmojiCompat__get0); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_EmojiCompat__load = NULL; @@ -426,8 +420,7 @@ JniResult EmojiCompat__process(jobject self_, jobject charSequence) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_EmojiCompat__process, charSequence); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_EmojiCompat__process1 = NULL; @@ -446,8 +439,7 @@ JniResult EmojiCompat__process1(jobject self_, return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_EmojiCompat__process1, charSequence, start, end); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_EmojiCompat__process2 = NULL; @@ -468,8 +460,7 @@ JniResult EmojiCompat__process2(jobject self_, jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_EmojiCompat__process2, charSequence, start, end, maxEmojiCount); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_EmojiCompat__process3 = NULL; @@ -491,8 +482,7 @@ JniResult EmojiCompat__process3(jobject self_, jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_EmojiCompat__process3, charSequence, start, end, maxEmojiCount, replaceStrategy); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_EmojiCompat__getAssetSignature = NULL; @@ -508,8 +498,7 @@ JniResult EmojiCompat__getAssetSignature(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_EmojiCompat__getAssetSignature); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_EmojiCompat__updateEditorInfo = NULL; @@ -546,8 +535,7 @@ JniResult EmojiCompat_Config__ctor(jobject metadataLoader) { jobject _result = (*jniEnv)->NewObject(jniEnv, _c_EmojiCompat_Config, _m_EmojiCompat_Config__ctor, metadataLoader); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_EmojiCompat_Config__registerInitCallback = NULL; @@ -568,8 +556,7 @@ JniResult EmojiCompat_Config__registerInitCallback(jobject self_, return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_EmojiCompat_Config__registerInitCallback, initCallback); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_EmojiCompat_Config__unregisterInitCallback = NULL; @@ -591,8 +578,7 @@ JniResult EmojiCompat_Config__unregisterInitCallback(jobject self_, jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_EmojiCompat_Config__unregisterInitCallback, initCallback); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_EmojiCompat_Config__setReplaceAll = NULL; @@ -609,8 +595,7 @@ JniResult EmojiCompat_Config__setReplaceAll(jobject self_, uint8_t replaceAll) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_EmojiCompat_Config__setReplaceAll, replaceAll); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_EmojiCompat_Config__setUseEmojiAsDefaultStyle = NULL; @@ -632,8 +617,7 @@ JniResult EmojiCompat_Config__setUseEmojiAsDefaultStyle( jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_EmojiCompat_Config__setUseEmojiAsDefaultStyle, useEmojiAsDefaultStyle); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_EmojiCompat_Config__setUseEmojiAsDefaultStyle1 = NULL; @@ -656,8 +640,7 @@ JniResult EmojiCompat_Config__setUseEmojiAsDefaultStyle1( jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_EmojiCompat_Config__setUseEmojiAsDefaultStyle1, useEmojiAsDefaultStyle, emojiAsDefaultStyleExceptions); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_EmojiCompat_Config__setEmojiSpanIndicatorEnabled = NULL; @@ -679,8 +662,7 @@ JniResult EmojiCompat_Config__setEmojiSpanIndicatorEnabled( jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_EmojiCompat_Config__setEmojiSpanIndicatorEnabled, emojiSpanIndicatorEnabled); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_EmojiCompat_Config__setEmojiSpanIndicatorColor = NULL; @@ -700,8 +682,7 @@ JniResult EmojiCompat_Config__setEmojiSpanIndicatorColor(jobject self_, return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_EmojiCompat_Config__setEmojiSpanIndicatorColor, color); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_EmojiCompat_Config__setMetadataLoadStrategy = NULL; @@ -721,8 +702,7 @@ JniResult EmojiCompat_Config__setMetadataLoadStrategy(jobject self_, return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_EmojiCompat_Config__setMetadataLoadStrategy, strategy); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_EmojiCompat_Config__setSpanFactory = NULL; @@ -741,8 +721,7 @@ JniResult EmojiCompat_Config__setSpanFactory(jobject self_, jobject factory) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_EmojiCompat_Config__setSpanFactory, factory); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_EmojiCompat_Config__setGlyphChecker = NULL; @@ -762,8 +741,7 @@ JniResult EmojiCompat_Config__setGlyphChecker(jobject self_, return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_EmojiCompat_Config__setGlyphChecker, glyphChecker); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_EmojiCompat_Config__getMetadataRepoLoader = NULL; @@ -782,8 +760,7 @@ JniResult EmojiCompat_Config__getMetadataRepoLoader(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_EmojiCompat_Config__getMetadataRepoLoader); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } // androidx.emoji2.text.EmojiCompat$MetadataRepoLoaderCallback @@ -806,8 +783,7 @@ JniResult EmojiCompat_MetadataRepoLoaderCallback__ctor() { jobject _result = (*jniEnv)->NewObject(jniEnv, _c_EmojiCompat_MetadataRepoLoaderCallback, _m_EmojiCompat_MetadataRepoLoaderCallback__ctor); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_EmojiCompat_MetadataRepoLoaderCallback__onLoaded = NULL; @@ -919,8 +895,7 @@ JniResult EmojiCompat_InitCallback__ctor() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_EmojiCompat_InitCallback, _m_EmojiCompat_InitCallback__ctor); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_EmojiCompat_InitCallback__onInitialized = NULL; @@ -977,8 +952,7 @@ JniResult EmojiCompat_DefaultSpanFactory__ctor() { jobject _result = (*jniEnv)->NewObject(jniEnv, _c_EmojiCompat_DefaultSpanFactory, _m_EmojiCompat_DefaultSpanFactory__ctor); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_EmojiCompat_DefaultSpanFactory__createSpan = NULL; @@ -998,8 +972,7 @@ JniResult EmojiCompat_DefaultSpanFactory__createSpan(jobject self_, return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_EmojiCompat_DefaultSpanFactory__createSpan, rasterizer); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } // androidx.emoji2.text.EmojiCompat$SpanFactory @@ -1022,8 +995,7 @@ JniResult EmojiCompat_SpanFactory__createSpan(jobject self_, return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_EmojiCompat_SpanFactory__createSpan, rasterizer); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } // androidx.emoji2.text.DefaultEmojiCompatConfig @@ -1046,8 +1018,7 @@ JniResult DefaultEmojiCompatConfig__create(jobject context) { jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_DefaultEmojiCompatConfig, _m_DefaultEmojiCompatConfig__create, context); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } // androidx.emoji2.text.DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28 @@ -1076,8 +1047,7 @@ DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__ctor() { jobject _result = (*jniEnv)->NewObject( jniEnv, _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28, _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__ctor); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID @@ -1109,8 +1079,7 @@ DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__getSigningSignatu jniEnv, self_, _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__getSigningSignatures1, packageManager, providerPackage); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } // androidx.emoji2.text.DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19 @@ -1139,8 +1108,7 @@ DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__ctor() { jobject _result = (*jniEnv)->NewObject( jniEnv, _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19, _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__ctor); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID @@ -1173,8 +1141,7 @@ DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__queryIntentConten jniEnv, self_, _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__queryIntentContentProviders, packageManager, intent, flags); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID @@ -1204,8 +1171,7 @@ DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__getProviderInfo( jniEnv, self_, _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__getProviderInfo, resolveInfo); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } // androidx.emoji2.text.DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper @@ -1230,8 +1196,7 @@ JniResult DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__ctor() { jobject _result = (*jniEnv)->NewObject( jniEnv, _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper, _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__ctor); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID @@ -1263,8 +1228,7 @@ DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__getSigningSignatures( jniEnv, self_, _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__getSigningSignatures, packageManager, providerPackage); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID @@ -1297,8 +1261,7 @@ DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__queryIntentContentProvi jniEnv, self_, _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__queryIntentContentProviders, packageManager, intent, flags); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID @@ -1328,8 +1291,7 @@ DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__getProviderInfo( jniEnv, self_, _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__getProviderInfo, resolveInfo); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } // androidx.emoji2.text.DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory @@ -1359,8 +1321,7 @@ JniResult DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__ctor( jniEnv, _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory, _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__ctor, helper); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__create = @@ -1388,8 +1349,7 @@ JniResult DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__create( jniEnv, self_, _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__create, context); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } // android.os.Build @@ -1406,8 +1366,7 @@ JniResult Build__ctor() { if (_m_Build__ctor == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Build, _m_Build__ctor); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_Build__getSerial = NULL; @@ -1423,8 +1382,7 @@ JniResult Build__getSerial() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_Build, _m_Build__getSerial); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_Build__getFingerprintedPartitions = NULL; @@ -1440,8 +1398,7 @@ JniResult Build__getFingerprintedPartitions() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_Build, _m_Build__getFingerprintedPartitions); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_Build__getRadioVersion = NULL; @@ -1457,8 +1414,7 @@ JniResult Build__getRadioVersion() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_Build, _m_Build__getRadioVersion); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jfieldID _f_Build__BOARD = NULL; @@ -1469,9 +1425,9 @@ JniResult get_Build__BOARD() { if (_c_Build == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__BOARD, "BOARD", "Ljava/lang/String;"); - jobject _result = to_global_ref( - (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__BOARD)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__BOARD); + return to_global_ref_result(_result); } jfieldID _f_Build__BOOTLOADER = NULL; @@ -1483,9 +1439,9 @@ JniResult get_Build__BOOTLOADER() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__BOOTLOADER, "BOOTLOADER", "Ljava/lang/String;"); - jobject _result = to_global_ref( - (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__BOOTLOADER)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__BOOTLOADER); + return to_global_ref_result(_result); } jfieldID _f_Build__BRAND = NULL; @@ -1496,9 +1452,9 @@ JniResult get_Build__BRAND() { if (_c_Build == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__BRAND, "BRAND", "Ljava/lang/String;"); - jobject _result = to_global_ref( - (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__BRAND)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__BRAND); + return to_global_ref_result(_result); } jfieldID _f_Build__CPU_ABI = NULL; @@ -1510,9 +1466,9 @@ JniResult get_Build__CPU_ABI() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__CPU_ABI, "CPU_ABI", "Ljava/lang/String;"); - jobject _result = to_global_ref( - (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__CPU_ABI)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__CPU_ABI); + return to_global_ref_result(_result); } jfieldID _f_Build__CPU_ABI2 = NULL; @@ -1524,9 +1480,9 @@ JniResult get_Build__CPU_ABI2() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__CPU_ABI2, "CPU_ABI2", "Ljava/lang/String;"); - jobject _result = to_global_ref( - (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__CPU_ABI2)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__CPU_ABI2); + return to_global_ref_result(_result); } jfieldID _f_Build__DEVICE = NULL; @@ -1538,9 +1494,9 @@ JniResult get_Build__DEVICE() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__DEVICE, "DEVICE", "Ljava/lang/String;"); - jobject _result = to_global_ref( - (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__DEVICE)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__DEVICE); + return to_global_ref_result(_result); } jfieldID _f_Build__DISPLAY = NULL; @@ -1552,9 +1508,9 @@ JniResult get_Build__DISPLAY() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__DISPLAY, "DISPLAY", "Ljava/lang/String;"); - jobject _result = to_global_ref( - (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__DISPLAY)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__DISPLAY); + return to_global_ref_result(_result); } jfieldID _f_Build__FINGERPRINT = NULL; @@ -1566,9 +1522,9 @@ JniResult get_Build__FINGERPRINT() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__FINGERPRINT, "FINGERPRINT", "Ljava/lang/String;"); - jobject _result = to_global_ref( - (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__FINGERPRINT)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__FINGERPRINT); + return to_global_ref_result(_result); } jfieldID _f_Build__HARDWARE = NULL; @@ -1580,9 +1536,9 @@ JniResult get_Build__HARDWARE() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__HARDWARE, "HARDWARE", "Ljava/lang/String;"); - jobject _result = to_global_ref( - (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__HARDWARE)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__HARDWARE); + return to_global_ref_result(_result); } jfieldID _f_Build__HOST = NULL; @@ -1593,9 +1549,9 @@ JniResult get_Build__HOST() { if (_c_Build == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__HOST, "HOST", "Ljava/lang/String;"); - jobject _result = to_global_ref( - (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__HOST)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__HOST); + return to_global_ref_result(_result); } jfieldID _f_Build__ID = NULL; @@ -1606,9 +1562,9 @@ JniResult get_Build__ID() { if (_c_Build == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__ID, "ID", "Ljava/lang/String;"); - jobject _result = to_global_ref( - (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__ID)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__ID); + return to_global_ref_result(_result); } jfieldID _f_Build__MANUFACTURER = NULL; @@ -1620,9 +1576,9 @@ JniResult get_Build__MANUFACTURER() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__MANUFACTURER, "MANUFACTURER", "Ljava/lang/String;"); - jobject _result = to_global_ref((*jniEnv)->GetStaticObjectField( - jniEnv, _c_Build, _f_Build__MANUFACTURER)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__MANUFACTURER); + return to_global_ref_result(_result); } jfieldID _f_Build__MODEL = NULL; @@ -1633,9 +1589,9 @@ JniResult get_Build__MODEL() { if (_c_Build == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__MODEL, "MODEL", "Ljava/lang/String;"); - jobject _result = to_global_ref( - (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__MODEL)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__MODEL); + return to_global_ref_result(_result); } jfieldID _f_Build__ODM_SKU = NULL; @@ -1647,9 +1603,9 @@ JniResult get_Build__ODM_SKU() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__ODM_SKU, "ODM_SKU", "Ljava/lang/String;"); - jobject _result = to_global_ref( - (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__ODM_SKU)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__ODM_SKU); + return to_global_ref_result(_result); } jfieldID _f_Build__PRODUCT = NULL; @@ -1661,9 +1617,9 @@ JniResult get_Build__PRODUCT() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__PRODUCT, "PRODUCT", "Ljava/lang/String;"); - jobject _result = to_global_ref( - (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__PRODUCT)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__PRODUCT); + return to_global_ref_result(_result); } jfieldID _f_Build__RADIO = NULL; @@ -1674,9 +1630,9 @@ JniResult get_Build__RADIO() { if (_c_Build == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__RADIO, "RADIO", "Ljava/lang/String;"); - jobject _result = to_global_ref( - (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__RADIO)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__RADIO); + return to_global_ref_result(_result); } jfieldID _f_Build__SERIAL = NULL; @@ -1688,9 +1644,9 @@ JniResult get_Build__SERIAL() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__SERIAL, "SERIAL", "Ljava/lang/String;"); - jobject _result = to_global_ref( - (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__SERIAL)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__SERIAL); + return to_global_ref_result(_result); } jfieldID _f_Build__SKU = NULL; @@ -1701,9 +1657,9 @@ JniResult get_Build__SKU() { if (_c_Build == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__SKU, "SKU", "Ljava/lang/String;"); - jobject _result = to_global_ref( - (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__SKU)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__SKU); + return to_global_ref_result(_result); } jfieldID _f_Build__SOC_MANUFACTURER = NULL; @@ -1715,9 +1671,9 @@ JniResult get_Build__SOC_MANUFACTURER() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__SOC_MANUFACTURER, "SOC_MANUFACTURER", "Ljava/lang/String;"); - jobject _result = to_global_ref((*jniEnv)->GetStaticObjectField( - jniEnv, _c_Build, _f_Build__SOC_MANUFACTURER)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, + _f_Build__SOC_MANUFACTURER); + return to_global_ref_result(_result); } jfieldID _f_Build__SOC_MODEL = NULL; @@ -1729,9 +1685,9 @@ JniResult get_Build__SOC_MODEL() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__SOC_MODEL, "SOC_MODEL", "Ljava/lang/String;"); - jobject _result = to_global_ref( - (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__SOC_MODEL)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__SOC_MODEL); + return to_global_ref_result(_result); } jfieldID _f_Build__SUPPORTED_32_BIT_ABIS = NULL; @@ -1743,9 +1699,9 @@ JniResult get_Build__SUPPORTED_32_BIT_ABIS() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__SUPPORTED_32_BIT_ABIS, "SUPPORTED_32_BIT_ABIS", "[Ljava/lang/String;"); - jobject _result = to_global_ref((*jniEnv)->GetStaticObjectField( - jniEnv, _c_Build, _f_Build__SUPPORTED_32_BIT_ABIS)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = (*jniEnv)->GetStaticObjectField( + jniEnv, _c_Build, _f_Build__SUPPORTED_32_BIT_ABIS); + return to_global_ref_result(_result); } jfieldID _f_Build__SUPPORTED_64_BIT_ABIS = NULL; @@ -1757,9 +1713,9 @@ JniResult get_Build__SUPPORTED_64_BIT_ABIS() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__SUPPORTED_64_BIT_ABIS, "SUPPORTED_64_BIT_ABIS", "[Ljava/lang/String;"); - jobject _result = to_global_ref((*jniEnv)->GetStaticObjectField( - jniEnv, _c_Build, _f_Build__SUPPORTED_64_BIT_ABIS)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = (*jniEnv)->GetStaticObjectField( + jniEnv, _c_Build, _f_Build__SUPPORTED_64_BIT_ABIS); + return to_global_ref_result(_result); } jfieldID _f_Build__SUPPORTED_ABIS = NULL; @@ -1771,9 +1727,9 @@ JniResult get_Build__SUPPORTED_ABIS() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__SUPPORTED_ABIS, "SUPPORTED_ABIS", "[Ljava/lang/String;"); - jobject _result = to_global_ref((*jniEnv)->GetStaticObjectField( - jniEnv, _c_Build, _f_Build__SUPPORTED_ABIS)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, + _f_Build__SUPPORTED_ABIS); + return to_global_ref_result(_result); } jfieldID _f_Build__TAGS = NULL; @@ -1784,9 +1740,9 @@ JniResult get_Build__TAGS() { if (_c_Build == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__TAGS, "TAGS", "Ljava/lang/String;"); - jobject _result = to_global_ref( - (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__TAGS)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__TAGS); + return to_global_ref_result(_result); } jfieldID _f_Build__TIME = NULL; @@ -1810,9 +1766,9 @@ JniResult get_Build__TYPE() { if (_c_Build == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__TYPE, "TYPE", "Ljava/lang/String;"); - jobject _result = to_global_ref( - (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__TYPE)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__TYPE); + return to_global_ref_result(_result); } jfieldID _f_Build__USER = NULL; @@ -1823,9 +1779,9 @@ JniResult get_Build__USER() { if (_c_Build == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_static_field(_c_Build, &_f_Build__USER, "USER", "Ljava/lang/String;"); - jobject _result = to_global_ref( - (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__USER)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build, _f_Build__USER); + return to_global_ref_result(_result); } // java.util.HashMap @@ -1843,8 +1799,7 @@ JniResult HashMap__ctor(int32_t i, float f) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_HashMap, _m_HashMap__ctor, i, f); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_HashMap__ctor1 = NULL; @@ -1859,8 +1814,7 @@ JniResult HashMap__ctor1(int32_t i) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_HashMap, _m_HashMap__ctor1, i); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_HashMap__ctor2 = NULL; @@ -1874,8 +1828,7 @@ JniResult HashMap__ctor2() { if (_m_HashMap__ctor2 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_HashMap, _m_HashMap__ctor2); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_HashMap__ctor3 = NULL; @@ -1890,8 +1843,7 @@ JniResult HashMap__ctor3(jobject map) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_HashMap, _m_HashMap__ctor3, map); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_HashMap__size = NULL; @@ -1936,8 +1888,7 @@ JniResult HashMap__get0(jobject self_, jobject object) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_HashMap__get0, object); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_HashMap__containsKey = NULL; @@ -1969,8 +1920,7 @@ JniResult HashMap__put(jobject self_, jobject object, jobject object1) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_HashMap__put, object, object1); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_HashMap__putAll = NULL; @@ -2000,8 +1950,7 @@ JniResult HashMap__remove(jobject self_, jobject object) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_HashMap__remove, object); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_HashMap__clear = NULL; @@ -2046,8 +1995,7 @@ JniResult HashMap__keySet(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_HashMap__keySet); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_HashMap__values = NULL; @@ -2063,8 +2011,7 @@ JniResult HashMap__values(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_HashMap__values); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_HashMap__entrySet = NULL; @@ -2080,8 +2027,7 @@ JniResult HashMap__entrySet(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_HashMap__entrySet); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_HashMap__getOrDefault = NULL; @@ -2099,8 +2045,7 @@ JniResult HashMap__getOrDefault(jobject self_, return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_HashMap__getOrDefault, object, object1); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_HashMap__putIfAbsent = NULL; @@ -2116,8 +2061,7 @@ JniResult HashMap__putIfAbsent(jobject self_, jobject object, jobject object1) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_HashMap__putIfAbsent, object, object1); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_HashMap__remove1 = NULL; @@ -2168,8 +2112,7 @@ JniResult HashMap__replace1(jobject self_, jobject object, jobject object1) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_HashMap__replace1, object, object1); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_HashMap__computeIfAbsent = NULL; @@ -2188,8 +2131,7 @@ JniResult HashMap__computeIfAbsent(jobject self_, return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_HashMap__computeIfAbsent, object, function); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_HashMap__computeIfPresent = NULL; @@ -2208,8 +2150,7 @@ JniResult HashMap__computeIfPresent(jobject self_, return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_HashMap__computeIfPresent, object, biFunction); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_HashMap__compute = NULL; @@ -2226,8 +2167,7 @@ JniResult HashMap__compute(jobject self_, jobject object, jobject biFunction) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_HashMap__compute, object, biFunction); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_HashMap__merge = NULL; @@ -2247,8 +2187,7 @@ JniResult HashMap__merge(jobject self_, return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_HashMap__merge, object, object1, biFunction); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_HashMap__forEach = NULL; @@ -2293,6 +2232,5 @@ JniResult HashMap__clone(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_HashMap__clone); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } diff --git a/pkgs/jnigen/example/in_app_java/src/android_utils/dartjni.h b/pkgs/jnigen/example/in_app_java/src/android_utils/dartjni.h index 21cef2036..c0713af53 100644 --- a/pkgs/jnigen/example/in_app_java/src/android_utils/dartjni.h +++ b/pkgs/jnigen/example/in_app_java/src/android_utils/dartjni.h @@ -176,10 +176,10 @@ typedef struct JniAccessorsStruct { char* methodName, char* signature); JniResult (*newObject)(jclass cls, jmethodID ctor, jvalue* args); - JniPointerResult (*newPrimitiveArray)(jsize length, int type); - JniPointerResult (*newObjectArray)(jsize length, - jclass elementClass, - jobject initialElement); + JniResult (*newPrimitiveArray)(jsize length, int type); + JniResult (*newObjectArray)(jsize length, + jclass elementClass, + jobject initialElement); JniResult (*getArrayElement)(jarray array, int index, int type); JniResult (*callMethod)(jobject obj, jmethodID methodID, @@ -261,8 +261,10 @@ static inline void load_class_global_ref(jclass* cls, const char* name) { acquire_lock(&jni->locks.classLoadingLock); if (*cls == NULL) { load_class_platform(&tmp, name); - *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); - (*jniEnv)->DeleteLocalRef(jniEnv, tmp); + if (!(*jniEnv)->ExceptionCheck(jniEnv)) { + *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); + (*jniEnv)->DeleteLocalRef(jniEnv, tmp); + } } release_lock(&jni->locks.classLoadingLock); } @@ -356,6 +358,15 @@ static inline jthrowable check_exception() { return to_global_ref(exception); } +static inline JniResult to_global_ref_result(jobject ref) { + JniResult result; + result.exception = check_exception(); + if (result.exception == NULL) { + result.value.l = to_global_ref(ref); + } + return result; +} + FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); JNIEXPORT void JNICALL diff --git a/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h b/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h index 21cef2036..c0713af53 100644 --- a/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h +++ b/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h @@ -176,10 +176,10 @@ typedef struct JniAccessorsStruct { char* methodName, char* signature); JniResult (*newObject)(jclass cls, jmethodID ctor, jvalue* args); - JniPointerResult (*newPrimitiveArray)(jsize length, int type); - JniPointerResult (*newObjectArray)(jsize length, - jclass elementClass, - jobject initialElement); + JniResult (*newPrimitiveArray)(jsize length, int type); + JniResult (*newObjectArray)(jsize length, + jclass elementClass, + jobject initialElement); JniResult (*getArrayElement)(jarray array, int index, int type); JniResult (*callMethod)(jobject obj, jmethodID methodID, @@ -261,8 +261,10 @@ static inline void load_class_global_ref(jclass* cls, const char* name) { acquire_lock(&jni->locks.classLoadingLock); if (*cls == NULL) { load_class_platform(&tmp, name); - *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); - (*jniEnv)->DeleteLocalRef(jniEnv, tmp); + if (!(*jniEnv)->ExceptionCheck(jniEnv)) { + *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); + (*jniEnv)->DeleteLocalRef(jniEnv, tmp); + } } release_lock(&jni->locks.classLoadingLock); } @@ -356,6 +358,15 @@ static inline jthrowable check_exception() { return to_global_ref(exception); } +static inline JniResult to_global_ref_result(jobject ref) { + JniResult result; + result.exception = check_exception(); + if (result.exception == NULL) { + result.value.l = to_global_ref(ref); + } + return result; +} + FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); JNIEXPORT void JNICALL diff --git a/pkgs/jnigen/example/kotlin_plugin/src/kotlin_plugin_bindings.c b/pkgs/jnigen/example/kotlin_plugin/src/kotlin_plugin_bindings.c index d93599cee..fd8b22bf8 100644 --- a/pkgs/jnigen/example/kotlin_plugin/src/kotlin_plugin_bindings.c +++ b/pkgs/jnigen/example/kotlin_plugin/src/kotlin_plugin_bindings.c @@ -29,8 +29,7 @@ JniResult Example__ctor() { if (_m_Example__ctor == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Example, _m_Example__ctor); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_Example__thinkBeforeAnswering = NULL; @@ -47,6 +46,5 @@ JniResult Example__thinkBeforeAnswering(jobject self_, jobject continuation) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_Example__thinkBeforeAnswering, continuation); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } diff --git a/pkgs/jnigen/example/notification_plugin/src/dartjni.h b/pkgs/jnigen/example/notification_plugin/src/dartjni.h index 21cef2036..c0713af53 100644 --- a/pkgs/jnigen/example/notification_plugin/src/dartjni.h +++ b/pkgs/jnigen/example/notification_plugin/src/dartjni.h @@ -176,10 +176,10 @@ typedef struct JniAccessorsStruct { char* methodName, char* signature); JniResult (*newObject)(jclass cls, jmethodID ctor, jvalue* args); - JniPointerResult (*newPrimitiveArray)(jsize length, int type); - JniPointerResult (*newObjectArray)(jsize length, - jclass elementClass, - jobject initialElement); + JniResult (*newPrimitiveArray)(jsize length, int type); + JniResult (*newObjectArray)(jsize length, + jclass elementClass, + jobject initialElement); JniResult (*getArrayElement)(jarray array, int index, int type); JniResult (*callMethod)(jobject obj, jmethodID methodID, @@ -261,8 +261,10 @@ static inline void load_class_global_ref(jclass* cls, const char* name) { acquire_lock(&jni->locks.classLoadingLock); if (*cls == NULL) { load_class_platform(&tmp, name); - *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); - (*jniEnv)->DeleteLocalRef(jniEnv, tmp); + if (!(*jniEnv)->ExceptionCheck(jniEnv)) { + *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); + (*jniEnv)->DeleteLocalRef(jniEnv, tmp); + } } release_lock(&jni->locks.classLoadingLock); } @@ -356,6 +358,15 @@ static inline jthrowable check_exception() { return to_global_ref(exception); } +static inline JniResult to_global_ref_result(jobject ref) { + JniResult result; + result.exception = check_exception(); + if (result.exception == NULL) { + result.value.l = to_global_ref(ref); + } + return result; +} + FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); JNIEXPORT void JNICALL diff --git a/pkgs/jnigen/example/notification_plugin/src/notification_plugin.c b/pkgs/jnigen/example/notification_plugin/src/notification_plugin.c index 8eb077c12..387fe0c54 100644 --- a/pkgs/jnigen/example/notification_plugin/src/notification_plugin.c +++ b/pkgs/jnigen/example/notification_plugin/src/notification_plugin.c @@ -35,8 +35,7 @@ JniResult Notifications__ctor() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Notifications, _m_Notifications__ctor); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_Notifications__showNotification = NULL; 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 ee0339135..59c7919d4 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 @@ -88,11 +88,11 @@ class PDFTextStripper extends jni.JObject { static final _set_charactersByArticle = jniLookup< ffi.NativeFunction< - jni.JThrowablePtr Function( + jni.JniResult Function( jni.JObjectPtr, ffi.Pointer)>>( "set_PDFTextStripper__charactersByArticle") .asFunction< - jni.JThrowablePtr Function(jni.JObjectPtr, ffi.Pointer)>(); + jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); /// from: protected java.util.ArrayList> charactersByArticle /// The returned object must be deleted after use, by calling the `delete` method. @@ -128,7 +128,7 @@ class PDFTextStripper extends jni.JObject { /// /// Most PDFs won't have any beads, so charactersByArticle will contain a single entry. set charactersByArticle(jni.JObject value) => - _set_charactersByArticle(reference, value.reference); + _set_charactersByArticle(reference, value.reference).check(); static final _get_document = jniLookup< ffi.NativeFunction< @@ -142,10 +142,10 @@ class PDFTextStripper extends jni.JObject { static final _set_document = jniLookup< ffi.NativeFunction< - jni.JThrowablePtr Function(jni.JObjectPtr, + jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>>("set_PDFTextStripper__document") .asFunction< - jni.JThrowablePtr Function(jni.JObjectPtr, ffi.Pointer)>(); + jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); /// from: protected org.apache.pdfbox.pdmodel.PDDocument document /// The returned object must be deleted after use, by calling the `delete` method. @@ -155,7 +155,7 @@ class PDFTextStripper extends jni.JObject { /// from: protected org.apache.pdfbox.pdmodel.PDDocument document /// The returned object must be deleted after use, by calling the `delete` method. set document(pddocument_.PDDocument value) => - _set_document(reference, value.reference); + _set_document(reference, value.reference).check(); static final _get_output = jniLookup< ffi.NativeFunction< @@ -169,10 +169,10 @@ class PDFTextStripper extends jni.JObject { static final _set_output = jniLookup< ffi.NativeFunction< - jni.JThrowablePtr Function(jni.JObjectPtr, + jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>>("set_PDFTextStripper__output") .asFunction< - jni.JThrowablePtr Function(jni.JObjectPtr, ffi.Pointer)>(); + jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); /// from: protected java.io.Writer output /// The returned object must be deleted after use, by calling the `delete` method. @@ -181,7 +181,8 @@ class PDFTextStripper extends jni.JObject { /// from: protected java.io.Writer output /// The returned object must be deleted after use, by calling the `delete` method. - set output(jni.JObject value) => _set_output(reference, value.reference); + set output(jni.JObject value) => + _set_output(reference, value.reference).check(); static final _ctor = jniLookup>( "PDFTextStripper__ctor") diff --git a/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h b/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h index 21cef2036..c0713af53 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h +++ b/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h @@ -176,10 +176,10 @@ typedef struct JniAccessorsStruct { char* methodName, char* signature); JniResult (*newObject)(jclass cls, jmethodID ctor, jvalue* args); - JniPointerResult (*newPrimitiveArray)(jsize length, int type); - JniPointerResult (*newObjectArray)(jsize length, - jclass elementClass, - jobject initialElement); + JniResult (*newPrimitiveArray)(jsize length, int type); + JniResult (*newObjectArray)(jsize length, + jclass elementClass, + jobject initialElement); JniResult (*getArrayElement)(jarray array, int index, int type); JniResult (*callMethod)(jobject obj, jmethodID methodID, @@ -261,8 +261,10 @@ static inline void load_class_global_ref(jclass* cls, const char* name) { acquire_lock(&jni->locks.classLoadingLock); if (*cls == NULL) { load_class_platform(&tmp, name); - *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); - (*jniEnv)->DeleteLocalRef(jniEnv, tmp); + if (!(*jniEnv)->ExceptionCheck(jniEnv)) { + *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); + (*jniEnv)->DeleteLocalRef(jniEnv, tmp); + } } release_lock(&jni->locks.classLoadingLock); } @@ -356,6 +358,15 @@ static inline jthrowable check_exception() { return to_global_ref(exception); } +static inline JniResult to_global_ref_result(jobject ref) { + JniResult result; + result.exception = check_exception(); + if (result.exception == NULL) { + result.value.l = to_global_ref(ref); + } + return result; +} + FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); JNIEXPORT void JNICALL diff --git a/pkgs/jnigen/example/pdfbox_plugin/src/third_party/pdfbox_plugin.c b/pkgs/jnigen/example/pdfbox_plugin/src/third_party/pdfbox_plugin.c index 0ce1442b3..86a8161e8 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/src/third_party/pdfbox_plugin.c +++ b/pkgs/jnigen/example/pdfbox_plugin/src/third_party/pdfbox_plugin.c @@ -48,8 +48,7 @@ JniResult PDDocument__ctor() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_PDDocument, _m_PDDocument__ctor); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocument__ctor1 = NULL; @@ -65,8 +64,7 @@ JniResult PDDocument__ctor1(jobject memUsageSetting) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_PDDocument, _m_PDDocument__ctor1, memUsageSetting); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocument__ctor2 = NULL; @@ -82,8 +80,7 @@ JniResult PDDocument__ctor2(jobject doc) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_PDDocument, _m_PDDocument__ctor2, doc); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocument__ctor3 = NULL; @@ -100,8 +97,7 @@ JniResult PDDocument__ctor3(jobject doc, jobject source) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_PDDocument, _m_PDDocument__ctor3, doc, source); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocument__ctor4 = NULL; @@ -119,8 +115,7 @@ JniResult PDDocument__ctor4(jobject doc, jobject source, jobject permission) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject( jniEnv, _c_PDDocument, _m_PDDocument__ctor4, doc, source, permission); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocument__addPage = NULL; @@ -283,8 +278,7 @@ JniResult PDDocument__importPage(jobject self_, jobject page) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocument__importPage, page); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocument__getDocument = NULL; @@ -300,8 +294,7 @@ JniResult PDDocument__getDocument(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_PDDocument__getDocument); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocument__getDocumentInformation = NULL; @@ -318,8 +311,7 @@ JniResult PDDocument__getDocumentInformation(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocument__getDocumentInformation); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocument__setDocumentInformation = NULL; @@ -353,8 +345,7 @@ JniResult PDDocument__getDocumentCatalog(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocument__getDocumentCatalog); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocument__isEncrypted = NULL; @@ -385,8 +376,7 @@ JniResult PDDocument__getEncryption(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_PDDocument__getEncryption); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocument__setEncryptionDictionary = NULL; @@ -422,8 +412,7 @@ JniResult PDDocument__getLastSignatureDictionary(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocument__getLastSignatureDictionary); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocument__getSignatureFields = NULL; @@ -439,8 +428,7 @@ JniResult PDDocument__getSignatureFields(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocument__getSignatureFields); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocument__getSignatureDictionaries = NULL; @@ -456,8 +444,7 @@ JniResult PDDocument__getSignatureDictionaries(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocument__getSignatureDictionaries); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocument__registerTrueTypeFontForClosing = NULL; @@ -491,8 +478,7 @@ JniResult PDDocument__load(jobject file) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_PDDocument, _m_PDDocument__load, file); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocument__load1 = NULL; @@ -510,8 +496,7 @@ JniResult PDDocument__load1(jobject file, jobject memUsageSetting) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_PDDocument, _m_PDDocument__load1, file, memUsageSetting); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocument__load2 = NULL; @@ -528,8 +513,7 @@ JniResult PDDocument__load2(jobject file, jobject password) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_PDDocument, _m_PDDocument__load2, file, password); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocument__load3 = NULL; @@ -550,8 +534,7 @@ JniResult PDDocument__load3(jobject file, jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_PDDocument, _m_PDDocument__load3, file, password, memUsageSetting); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocument__load4 = NULL; @@ -573,8 +556,7 @@ JniResult PDDocument__load4(jobject file, jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_PDDocument, _m_PDDocument__load4, file, password, keyStore, alias); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocument__load5 = NULL; @@ -598,8 +580,7 @@ JniResult PDDocument__load5(jobject file, jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_PDDocument, _m_PDDocument__load5, file, password, keyStore, alias, memUsageSetting); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocument__load6 = NULL; @@ -616,8 +597,7 @@ JniResult PDDocument__load6(jobject input) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_PDDocument, _m_PDDocument__load6, input); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocument__load7 = NULL; @@ -635,8 +615,7 @@ JniResult PDDocument__load7(jobject input, jobject memUsageSetting) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_PDDocument, _m_PDDocument__load7, input, memUsageSetting); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocument__load8 = NULL; @@ -653,8 +632,7 @@ JniResult PDDocument__load8(jobject input, jobject password) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_PDDocument, _m_PDDocument__load8, input, password); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocument__load9 = NULL; @@ -676,8 +654,7 @@ JniResult PDDocument__load9(jobject input, jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_PDDocument, _m_PDDocument__load9, input, password, keyStore, alias); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocument__load10 = NULL; @@ -698,8 +675,7 @@ JniResult PDDocument__load10(jobject input, jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_PDDocument, _m_PDDocument__load10, input, password, memUsageSetting); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocument__load11 = NULL; @@ -723,8 +699,7 @@ JniResult PDDocument__load11(jobject input, jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_PDDocument, _m_PDDocument__load11, input, password, keyStore, alias, memUsageSetting); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocument__load12 = NULL; @@ -740,8 +715,7 @@ JniResult PDDocument__load12(jobject input) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_PDDocument, _m_PDDocument__load12, input); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocument__load13 = NULL; @@ -758,8 +732,7 @@ JniResult PDDocument__load13(jobject input, jobject password) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_PDDocument, _m_PDDocument__load13, input, password); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocument__load14 = NULL; @@ -780,8 +753,7 @@ JniResult PDDocument__load14(jobject input, jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_PDDocument, _m_PDDocument__load14, input, password, keyStore, alias); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocument__load15 = NULL; @@ -804,8 +776,7 @@ JniResult PDDocument__load15(jobject input, jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_PDDocument, _m_PDDocument__load15, input, password, keyStore, alias, memUsageSetting); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocument__save = NULL; @@ -903,8 +874,7 @@ JniResult PDDocument__saveIncrementalForExternalSigning(jobject self_, return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocument__saveIncrementalForExternalSigning, output); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocument__getPage = NULL; @@ -920,8 +890,7 @@ JniResult PDDocument__getPage(jobject self_, int32_t pageIndex) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocument__getPage, pageIndex); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocument__getPages = NULL; @@ -937,8 +906,7 @@ JniResult PDDocument__getPages(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_PDDocument__getPages); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocument__getNumberOfPages = NULL; @@ -1000,8 +968,7 @@ JniResult PDDocument__getCurrentAccessPermission(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocument__getCurrentAccessPermission); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocument__isAllSecurityToBeRemoved = NULL; @@ -1051,8 +1018,7 @@ JniResult PDDocument__getDocumentId(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_PDDocument__getDocumentId); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocument__setDocumentId = NULL; @@ -1114,8 +1080,7 @@ JniResult PDDocument__getResourceCache(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocument__getResourceCache); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocument__setResourceCache = NULL; @@ -1152,8 +1117,7 @@ JniResult PDDocumentInformation__ctor() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_PDDocumentInformation, _m_PDDocumentInformation__ctor); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocumentInformation__ctor1 = NULL; @@ -1170,8 +1134,7 @@ JniResult PDDocumentInformation__ctor1(jobject dic) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_PDDocumentInformation, _m_PDDocumentInformation__ctor1, dic); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocumentInformation__getCOSObject = NULL; @@ -1188,8 +1151,7 @@ JniResult PDDocumentInformation__getCOSObject(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocumentInformation__getCOSObject); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocumentInformation__getPropertyStringValue = NULL; @@ -1210,8 +1172,7 @@ JniResult PDDocumentInformation__getPropertyStringValue(jobject self_, jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocumentInformation__getPropertyStringValue, propertyKey); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocumentInformation__getTitle = NULL; @@ -1228,8 +1189,7 @@ JniResult PDDocumentInformation__getTitle(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocumentInformation__getTitle); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocumentInformation__setTitle = NULL; @@ -1263,8 +1223,7 @@ JniResult PDDocumentInformation__getAuthor(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocumentInformation__getAuthor); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocumentInformation__setAuthor = NULL; @@ -1298,8 +1257,7 @@ JniResult PDDocumentInformation__getSubject(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocumentInformation__getSubject); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocumentInformation__setSubject = NULL; @@ -1333,8 +1291,7 @@ JniResult PDDocumentInformation__getKeywords(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocumentInformation__getKeywords); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocumentInformation__setKeywords = NULL; @@ -1368,8 +1325,7 @@ JniResult PDDocumentInformation__getCreator(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocumentInformation__getCreator); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocumentInformation__setCreator = NULL; @@ -1403,8 +1359,7 @@ JniResult PDDocumentInformation__getProducer(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocumentInformation__getProducer); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocumentInformation__setProducer = NULL; @@ -1439,8 +1394,7 @@ JniResult PDDocumentInformation__getCreationDate(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocumentInformation__getCreationDate); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocumentInformation__setCreationDate = NULL; @@ -1476,8 +1430,7 @@ JniResult PDDocumentInformation__getModificationDate(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocumentInformation__getModificationDate); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocumentInformation__setModificationDate = NULL; @@ -1513,8 +1466,7 @@ JniResult PDDocumentInformation__getTrapped(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocumentInformation__getTrapped); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocumentInformation__getMetadataKeys = NULL; @@ -1532,8 +1484,7 @@ JniResult PDDocumentInformation__getMetadataKeys(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocumentInformation__getMetadataKeys); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocumentInformation__getCustomMetadataValue = NULL; @@ -1554,8 +1505,7 @@ JniResult PDDocumentInformation__getCustomMetadataValue(jobject self_, jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDDocumentInformation__getCustomMetadataValue, fieldName); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDDocumentInformation__setCustomMetadataValue = NULL; @@ -1613,8 +1563,7 @@ JniResult PDFTextStripper__ctor() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_PDFTextStripper, _m_PDFTextStripper__ctor); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDFTextStripper__getText = NULL; @@ -1631,8 +1580,7 @@ JniResult PDFTextStripper__getText(jobject self_, jobject doc) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDFTextStripper__getText, doc); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDFTextStripper__writeText = NULL; @@ -2023,8 +1971,7 @@ JniResult PDFTextStripper__getLineSeparator(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDFTextStripper__getLineSeparator); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDFTextStripper__getWordSeparator = NULL; @@ -2041,8 +1988,7 @@ JniResult PDFTextStripper__getWordSeparator(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDFTextStripper__getWordSeparator); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDFTextStripper__setWordSeparator = NULL; @@ -2111,8 +2057,7 @@ JniResult PDFTextStripper__getOutput(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_PDFTextStripper__getOutput); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDFTextStripper__getCharactersByArticle = NULL; @@ -2129,8 +2074,7 @@ JniResult PDFTextStripper__getCharactersByArticle(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDFTextStripper__getCharactersByArticle); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDFTextStripper__setSuppressDuplicateOverlappingText = NULL; @@ -2207,8 +2151,7 @@ JniResult PDFTextStripper__getEndBookmark(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDFTextStripper__getEndBookmark); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDFTextStripper__setEndBookmark = NULL; @@ -2246,8 +2189,7 @@ JniResult PDFTextStripper__getStartBookmark(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDFTextStripper__getStartBookmark); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDFTextStripper__setStartBookmark = NULL; @@ -2499,8 +2441,7 @@ JniResult PDFTextStripper__getParagraphStart(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDFTextStripper__getParagraphStart); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDFTextStripper__setParagraphStart = NULL; @@ -2534,8 +2475,7 @@ JniResult PDFTextStripper__getParagraphEnd(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDFTextStripper__getParagraphEnd); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDFTextStripper__setParagraphEnd = NULL; @@ -2569,8 +2509,7 @@ JniResult PDFTextStripper__getPageStart(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDFTextStripper__getPageStart); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDFTextStripper__setPageStart = NULL; @@ -2604,8 +2543,7 @@ JniResult PDFTextStripper__getPageEnd(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_PDFTextStripper__getPageEnd); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDFTextStripper__setPageEnd = NULL; @@ -2639,8 +2577,7 @@ JniResult PDFTextStripper__getArticleStart(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDFTextStripper__getArticleStart); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDFTextStripper__setArticleStart = NULL; @@ -2675,8 +2612,7 @@ JniResult PDFTextStripper__getArticleEnd(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDFTextStripper__getArticleEnd); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDFTextStripper__setArticleEnd = NULL; @@ -2812,8 +2748,7 @@ JniResult PDFTextStripper__getListItemPatterns(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_PDFTextStripper__getListItemPatterns); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_PDFTextStripper__matchPattern = NULL; @@ -2832,8 +2767,7 @@ JniResult PDFTextStripper__matchPattern(jobject string, jobject patterns) { jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_PDFTextStripper, _m_PDFTextStripper__matchPattern, string, patterns); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jfieldID _f_PDFTextStripper__LINE_SEPARATOR = NULL; @@ -2846,9 +2780,9 @@ JniResult get_PDFTextStripper__LINE_SEPARATOR(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_PDFTextStripper, &_f_PDFTextStripper__LINE_SEPARATOR, "LINE_SEPARATOR", "Ljava/lang/String;"); - jobject _result = to_global_ref((*jniEnv)->GetObjectField( - jniEnv, self_, _f_PDFTextStripper__LINE_SEPARATOR)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = (*jniEnv)->GetObjectField( + jniEnv, self_, _f_PDFTextStripper__LINE_SEPARATOR); + return to_global_ref_result(_result); } jfieldID _f_PDFTextStripper__charactersByArticle = NULL; @@ -2861,9 +2795,9 @@ JniResult get_PDFTextStripper__charactersByArticle(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_PDFTextStripper, &_f_PDFTextStripper__charactersByArticle, "charactersByArticle", "Ljava/util/ArrayList;"); - jobject _result = to_global_ref((*jniEnv)->GetObjectField( - jniEnv, self_, _f_PDFTextStripper__charactersByArticle)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = (*jniEnv)->GetObjectField( + jniEnv, self_, _f_PDFTextStripper__charactersByArticle); + return to_global_ref_result(_result); } FFI_PLUGIN_EXPORT @@ -2891,9 +2825,9 @@ JniResult get_PDFTextStripper__document(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_PDFTextStripper, &_f_PDFTextStripper__document, "document", "Lorg/apache/pdfbox/pdmodel/PDDocument;"); - jobject _result = to_global_ref( - (*jniEnv)->GetObjectField(jniEnv, self_, _f_PDFTextStripper__document)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->GetObjectField(jniEnv, self_, _f_PDFTextStripper__document); + return to_global_ref_result(_result); } FFI_PLUGIN_EXPORT @@ -2919,9 +2853,9 @@ JniResult get_PDFTextStripper__output(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_PDFTextStripper, &_f_PDFTextStripper__output, "output", "Ljava/io/Writer;"); - jobject _result = to_global_ref( - (*jniEnv)->GetObjectField(jniEnv, self_, _f_PDFTextStripper__output)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->GetObjectField(jniEnv, self_, _f_PDFTextStripper__output); + return to_global_ref_result(_result); } FFI_PLUGIN_EXPORT diff --git a/pkgs/jnigen/lib/src/bindings/c_bindings.dart b/pkgs/jnigen/lib/src/bindings/c_bindings.dart index 2e87e3d36..4f1cad52a 100644 --- a/pkgs/jnigen/lib/src/bindings/c_bindings.dart +++ b/pkgs/jnigen/lib/src/bindings/c_bindings.dart @@ -63,7 +63,7 @@ class CBindingGenerator { case "byte": return "int8_t"; case "char": - return "char"; + return "uint16_t"; case "double": return "double"; case "float": @@ -163,16 +163,20 @@ $jniResultType $cMethodName($cMethodParams) { '$objectArgument, $fieldVar, value);\n' '${indent}return $ifError;'; } else { - var getterExpr = '(*jniEnv)->Get$ifStaticCall${callType}Field(jniEnv, ' + final getterExpr = + '(*jniEnv)->Get$ifStaticCall${callType}Field(jniEnv, ' '$objectArgument, $fieldVar)'; - if (f.type.kind != Kind.primitive) { - getterExpr = 'to_global_ref($getterExpr)'; - } final cResultType = getCType(f.type.name); final unionField = getJValueField(f.type); + final String returnExpr; + if (f.type.kind != Kind.primitive) { + returnExpr = 'to_global_ref_result(_result)'; + } else { + returnExpr = '(JniResult){.value = ' + '{.$unionField = _result}, .exception = check_exception()}'; + } accessorStatements = '$indent$cResultType _result = $getterExpr;\n' - '${indent}return (JniResult){.value = ' - '{.$unionField = _result}, .exception = check_exception()};'; + '${indent}return $returnExpr;'; } s.write(''' @@ -256,8 +260,7 @@ $accessorStatements String valuePart; String unionField; if (cReturnType == 'jobject' || m.isCtor) { - unionField = 'l'; - valuePart = 'to_global_ref(_result)'; + return '${indent}return to_global_ref_result(_result);'; } else if (cReturnType == 'void') { // in case of void return, just write 0 in result part of JniResult unionField = 'j'; diff --git a/pkgs/jnigen/lib/src/bindings/dart_generator.dart b/pkgs/jnigen/lib/src/bindings/dart_generator.dart index b23854802..c2215296d 100644 --- a/pkgs/jnigen/lib/src/bindings/dart_generator.dart +++ b/pkgs/jnigen/lib/src/bindings/dart_generator.dart @@ -23,7 +23,6 @@ const _jType = '$_jni.JObjType'; const _jPointer = '$_jni.JObjectPtr'; const _jArray = '$_jni.JArray'; const _jObject = '$_jni.JObject'; -const _jThrowable = '$_jni.JThrowablePtr'; const _jResult = '$_jni.JniResult'; const _jCallType = '$_jni.JniCallType'; @@ -803,9 +802,9 @@ class _FieldGenerator extends Visitor { final dartSig = node.type.accept(const _TypeSig(isFfi: false)); s.write(''' static final _set_$name = - $_lookup<$_ffi.NativeFunction<$_jThrowable Function($ifRef$ffiSig)>>( + $_lookup<$_ffi.NativeFunction<$_jResult Function($ifRef$ffiSig)>>( "set_$cName") - .asFunction<$_jThrowable Function($ifRef$dartSig)>(); + .asFunction<$_jResult Function($ifRef$dartSig)>(); '''); } @@ -822,7 +821,7 @@ class _FieldGenerator extends Visitor { final name = node.finalName; final self = node.isStatic ? '' : '$_selfPointer, '; final toNativeSuffix = node.type.accept(const _ToNativeSuffix()); - return '_set_$name(${self}value$toNativeSuffix)'; + return '_set_$name(${self}value$toNativeSuffix).check()'; } void writeDartOnlyAccessor(Field node) { diff --git a/pkgs/jnigen/lib/src/config/config_types.dart b/pkgs/jnigen/lib/src/config/config_types.dart index 39c198fd2..6030436b1 100644 --- a/pkgs/jnigen/lib/src/config/config_types.dart +++ b/pkgs/jnigen/lib/src/config/config_types.dart @@ -156,6 +156,16 @@ OutputStructure getOutputStructure(String? name, OutputStructure defaultVal) { enum BindingsType { cBased, dartOnly } +extension GetConfigString on BindingsType { + static const _configStrings = { + BindingsType.cBased: 'c_based', + BindingsType.dartOnly: 'dart_only', + }; + String getConfigString() { + return _configStrings[this]!; + } +} + BindingsType getBindingsType(String? name, BindingsType defaultVal) { const values = { 'c_based': BindingsType.cBased, diff --git a/pkgs/jnigen/test/.gitignore b/pkgs/jnigen/test/.gitignore index 646810145..36f1ec5bc 100644 --- a/pkgs/jnigen/test/.gitignore +++ b/pkgs/jnigen/test/.gitignore @@ -1,2 +1,4 @@ # TODO(#166): Remove this. -!jni.jar \ No newline at end of file +!jni.jar +runtime_test_registrant_dartonly_generated.dart +generated_runtime_test.dart \ No newline at end of file diff --git a/pkgs/jnigen/test/README.md b/pkgs/jnigen/test/README.md index 091133740..e3ada8345 100644 --- a/pkgs/jnigen/test/README.md +++ b/pkgs/jnigen/test/README.md @@ -1,11 +1,13 @@ -Some notes about tests in this directory: +## How to run tests? +#### One-time setup: +``` +dart run jnigen:setup +``` -* [jackson_core_test](jackson_core_test/) is an end-to-end test which generates bindings for `jackson_core` library using the whole jnigen pipeline and compares the generated bindings with expected bindings. [simple_package_test](simple_package_test/) is similar but instead of using a Java library from maven, uses a stub java class. -* [bindings_test.dart](bindings_test.dart) runs the generated bindings to make sure they work. There are only a few tests here right now. -* [test_util/](test_util/) directory contains some code common to both `jackson_core_test` and `simple_package_test`. (Especially the functions `generateAndCompareBindings` and `generateAndAnalyzeBindings`). -* [yaml_config_test.dart](yaml_config_test.dart) runs the same `jackson_core` configuration but through YAML and makes sure it generates the same bindings. -* The other files contain unit tests for some error-prone components. +#### Running tests +```sh +dart run tool/generate_runtime_tests.dart ## Regenerates runtime test files +dart test +``` Note: Tests fail if summarizer is not previously built and 2 tests try to build it concurrently. We have to address it using a lock file and exponential backoff (#43). Temporarily, run `dart run jnigen:setup` before running tests for the first time. - -TODO(#62): Add some unit & integration tests in the java portion. diff --git a/pkgs/jnigen/test/bindings_test.dart b/pkgs/jnigen/test/bindings_test.dart deleted file mode 100644 index 7d98863a0..000000000 --- a/pkgs/jnigen/test/bindings_test.dart +++ /dev/null @@ -1,447 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -// Tests on generated code. -// -// Both the simple java example & jackson core classes example have tests in -// same file, because the test runner will reuse the process, which leads to -// reuse of the old JVM with old classpath if we have separate tests with -// different classpaths. - -import 'dart:io'; - -import 'package:jni/jni.dart'; -import 'package:path/path.dart' hide equals; -import 'package:test/test.dart'; - -// ignore_for_file: avoid_relative_lib_imports -import 'kotlin_test/lib/kotlin.dart'; -import 'simple_package_test/lib/simple_package.dart'; -import 'jackson_core_test/third_party/lib/com/fasterxml/jackson/core/_package.dart'; - -import 'test_util/test_util.dart'; - -final simplePackageTest = join('test', 'simple_package_test'); -final jacksonCoreTest = join('test', 'jackson_core_test'); -final kotlinTest = join('test', 'kotlin_test'); -final jniJar = join(kotlinTest, 'jni.jar'); - -final simplePackageTestJava = join(simplePackageTest, 'java'); -final kotlinTestKotlin = join(kotlinTest, 'kotlin'); - -Future setupDylibsAndClasses() async { - await runCommand('dart', [ - 'run', - 'jni:setup', - '-p', - 'jni', - '-s', - join(simplePackageTest, 'src'), - ]); - final group = join('com', 'github', 'dart_lang', 'jnigen'); - await runCommand( - 'javac', - [ - join(group, 'simple_package', 'Example.java'), - join(group, 'generics', 'MyMap.java'), - join(group, 'generics', 'MyStack.java'), - join(group, 'generics', 'GrandParent.java'), - join(group, 'generics', 'StringStack.java'), - join(group, 'generics', 'StringValuedMap.java'), - join(group, 'generics', 'StringKeyedMap.java'), - join(group, 'generics', 'StringMap.java'), - join(group, 'annotations', 'JsonSerializable.java'), - join(group, 'annotations', 'MyDataClass.java'), - join(group, 'pkg2', 'C2.java'), - join(group, 'pkg2', 'Example.java'), - ], - workingDirectory: simplePackageTestJava); - await runCommand('dart', [ - 'run', - 'jnigen:download_maven_jars', - '--config', - join(jacksonCoreTest, 'jnigen.yaml') - ]); - - final jacksonJars = await getJarPaths(join(jacksonCoreTest, 'third_party')); - - await runCommand('dart', [ - 'run', - 'jni:setup', - '-p', - 'jni', - '-s', - join(kotlinTest, 'src'), - ]); - await runCommand( - 'mvn', - ['package'], - workingDirectory: kotlinTestKotlin, - runInShell: true, - ); - // Jar including Kotlin runtime and dependencies. - final kotlinTestJar = - join(kotlinTestKotlin, 'target', 'kotlin_test-jar-with-dependencies.jar'); - - if (!Platform.isAndroid) { - Jni.spawn(dylibDir: join('build', 'jni_libs'), classPath: [ - jniJar, - simplePackageTestJava, - ...jacksonJars, - kotlinTestJar, - ]); - } - - Jni.initDLApi(); -} - -void main() async { - await checkLocallyBuiltDependencies(); - setUpAll(setupDylibsAndClasses); - - test('static final fields', () { - expect(Example.ON, equals(1)); - expect(Example.OFF, equals(0)); - }); - - test('static & instance fields', () { - expect(Example.num, equals(121)); - final aux = Example.aux; - expect(aux.value, equals(true)); - aux.delete(); - expect(C2.CONSTANT, equals(12)); - }); - - test('static methods', () { - expect(Example.addInts(10, 15), equals(25)); - }); - - test('static methods arrays', () { - final array = Example.getArr(); - expect(array[0], 1); - expect(array[1], 2); - expect(array[2], 3); - expect(Example.addAll(array), 6); - array[0] = 4; - expect(Example.addAll(array), 9); - }); - - test('instance methods', () { - final ex = Example(); - expect(ex.getNum(), equals(Example.num)); - final aux = Example.getAux(); - expect(aux.getValue(), equals(true)); - aux.setValue(false); - expect(aux.getValue(), equals(false)); - aux.setValue(true); - aux.delete(); - ex.delete(); - }); - - test('array of the class', () { - final ex1 = Example(); - final ex2 = Example(); - ex1.setInternal(1); - ex2.setInternal(2); - final array = JArray(Example.type, 2); - array[0] = ex1; - array[1] = ex2; - expect(array[0].getInternal(), 1); - expect(array[1].getInternal(), 2); - array.delete(); - ex1.delete(); - ex2.delete(); - }); - - test("Check bindings for same-named classes", () { - expect(Example().whichExample(), 0); - expect(Example1().whichExample(), 1); - }); - - test('simple json parsing test', () { - final json = JString.fromString('[1, true, false, 2, 4]'); - JsonFactory factory; - factory = JsonFactory(); - final parser = factory.createParser6(json); - final values = []; - while (!parser.isClosed()) { - final next = parser.nextToken(); - if (next.isNull) continue; - values.add(next.isNumeric()); - next.delete(); - } - expect(values, equals([false, true, false, false, true, true, false])); - Jni.deleteAll([factory, parser, json]); - }); - test("parsing invalid JSON throws JniException", () { - using((arena) { - final factory = JsonFactory()..deletedIn(arena); - final erroneous = factory - .createParser6("".toJString()..deletedIn(arena)) - ..deletedIn(arena); - expect(() => erroneous.nextToken(), throwsA(isA())); - }); - }); - test('exceptions', () { - expect(() => Example.throwException(), throwsException); - }); - group('generics', () { - test('GrandParent constructor', () { - using((arena) { - final grandParent = GrandParent('Hello'.toJString()..deletedIn(arena)) - ..deletedIn(arena); - expect(grandParent, isA>()); - expect(grandParent.$type, isA<$GrandParentType>()); - expect(grandParent.value.toDartString(deleteOriginal: true), 'Hello'); - }); - }); - test('MyStack', () { - using((arena) { - final stack = MyStack(T: JString.type)..deletedIn(arena); - stack.push('Hello'.toJString()..deletedIn(arena)); - stack.push('World'.toJString()..deletedIn(arena)); - expect(stack.pop().toDartString(deleteOriginal: true), 'World'); - expect(stack.pop().toDartString(deleteOriginal: true), 'Hello'); - }); - }); - test('MyMap', () { - using((arena) { - final map = MyMap(K: JString.type, V: Example.type)..deletedIn(arena); - final helloExample = Example.ctor1(1)..deletedIn(arena); - final worldExample = Example.ctor1(2)..deletedIn(arena); - map.put('Hello'.toJString()..deletedIn(arena), helloExample); - map.put('World'.toJString()..deletedIn(arena), worldExample); - expect( - (map.get0('Hello'.toJString()..deletedIn(arena))..deletedIn(arena)) - .getInternal(), - 1, - ); - expect( - (map.get0('World'.toJString()..deletedIn(arena))..deletedIn(arena)) - .getInternal(), - 2, - ); - expect( - ((map.entryStack()..deletedIn(arena)).pop()..deletedIn(arena)) - .key - .castTo(JString.type, deleteOriginal: true) - .toDartString(deleteOriginal: true), - anyOf('Hello', 'World'), - ); - }); - }); - group('classes extending generics', () { - test('StringStack', () { - using((arena) { - final stringStack = StringStack()..deletedIn(arena); - stringStack.push('Hello'.toJString()..deletedIn(arena)); - expect(stringStack.pop().toDartString(deleteOriginal: true), 'Hello'); - }); - }); - test('StringKeyedMap', () { - using((arena) { - final map = StringKeyedMap(V: Example.type)..deletedIn(arena); - final example = Example()..deletedIn(arena); - map.put('Hello'.toJString()..deletedIn(arena), example); - expect( - (map.get0('Hello'.toJString()..deletedIn(arena))..deletedIn(arena)) - .getInternal(), - 0, - ); - }); - }); - test('StringValuedMap', () { - using((arena) { - final map = StringValuedMap(K: Example.type)..deletedIn(arena); - final example = Example()..deletedIn(arena); - map.put(example, 'Hello'.toJString()..deletedIn(arena)); - expect( - map.get0(example).toDartString(deleteOriginal: true), - 'Hello', - ); - }); - }); - test('StringMap', () { - using((arena) { - final map = StringMap()..deletedIn(arena); - map.put('hello'.toJString()..deletedIn(arena), - 'world'.toJString()..deletedIn(arena)); - expect( - map - .get0('hello'.toJString()..deletedIn(arena)) - .toDartString(deleteOriginal: true), - 'world', - ); - }); - }); - }); - test('superclass count', () { - expect(JObject.type.superCount, 0); - expect(MyMap.type(JObject.type, JObject.type).superCount, 1); - expect(StringKeyedMap.type(JObject.type).superCount, 2); - expect(StringValuedMap.type(JObject.type).superCount, 2); - expect(StringMap.type.superCount, 3); - }); - test('nested generics', () { - using((arena) { - final grandParent = - GrandParent(T: JString.type, "!".toJString()..deletedIn(arena)) - ..deletedIn(arena); - expect( - grandParent.value.toDartString(deleteOriginal: true), - "!", - ); - - final strStaticParent = GrandParent.stringStaticParent() - ..deletedIn(arena); - expect( - strStaticParent.value.toDartString(deleteOriginal: true), - "Hello", - ); - - final exampleStaticParent = GrandParent.varStaticParent( - S: Example.type, Example()..deletedIn(arena)) - ..deletedIn(arena); - expect( - (exampleStaticParent.value..deletedIn(arena)).getInternal(), - 0, - ); - - final strParent = grandParent.stringParent()..deletedIn(arena); - expect( - strParent.parentValue - .castTo(JString.type, deleteOriginal: true) - .toDartString(deleteOriginal: true), - "!", - ); - expect( - strParent.value.toDartString(deleteOriginal: true), - "Hello", - ); - - final exampleParent = grandParent.varParent( - S: Example.type, Example()..deletedIn(arena)) - ..deletedIn(arena); - expect( - exampleParent.parentValue - .castTo(JString.type, deleteOriginal: true) - .toDartString(deleteOriginal: true), - "!", - ); - expect( - (exampleParent.value..deletedIn(arena)).getInternal(), - 0, - ); - // TODO(#139): test constructing Child, currently does not work due - // to a problem with C-bindings. - }); - }); - }); - group('Generic type inference', () { - test('MyStack.of1', () { - using((arena) { - final emptyStack = MyStack(T: JString.type)..deletedIn(arena); - expect(emptyStack.size(), 0); - final stack = MyStack.of1( - "Hello".toJString()..deletedIn(arena), - )..deletedIn(arena); - expect(stack, isA>()); - expect(stack.$type, isA<$MyStackType>()); - expect( - stack.pop().toDartString(deleteOriginal: true), - "Hello", - ); - }); - }); - test('MyStack.of 2 strings', () { - using((arena) { - final stack = MyStack.of2( - "Hello".toJString()..deletedIn(arena), - "World".toJString()..deletedIn(arena), - )..deletedIn(arena); - expect(stack, isA>()); - expect(stack.$type, isA<$MyStackType>()); - expect( - stack.pop().toDartString(deleteOriginal: true), - "World", - ); - expect( - stack.pop().toDartString(deleteOriginal: true), - "Hello", - ); - }); - }); - test('MyStack.of a string and an array', () { - using((arena) { - final array = JArray.filled(1, "World".toJString()..deletedIn(arena)) - ..deletedIn(arena); - final stack = MyStack.of2( - "Hello".toJString()..deletedIn(arena), - array, - )..deletedIn(arena); - expect(stack, isA>()); - expect(stack.$type, isA<$MyStackType>()); - expect( - stack - .pop() - .castTo(JArray.type(JString.type), deleteOriginal: true)[0] - .toDartString(deleteOriginal: true), - "World", - ); - expect( - stack - .pop() - .castTo(JString.type, deleteOriginal: true) - .toDartString(deleteOriginal: true), - "Hello", - ); - }); - }); - test('MyStack.from array of string', () { - using((arena) { - final array = JArray.filled(1, "Hello".toJString()..deletedIn(arena)) - ..deletedIn(arena); - final stack = MyStack.fromArray(array)..deletedIn(arena); - expect(stack, isA>()); - expect(stack.$type, isA<$MyStackType>()); - expect( - stack.pop().toDartString(deleteOriginal: true), - "Hello", - ); - }); - }); - test('MyStack.fromArrayOfArrayOfGrandParents', () { - using((arena) { - final firstDimention = JArray.filled( - 1, - GrandParent("Hello".toJString()..deletedIn(arena))..deletedIn(arena), - )..deletedIn(arena); - final twoDimentionalArray = JArray.filled(1, firstDimention) - ..deletedIn(arena); - final stack = - MyStack.fromArrayOfArrayOfGrandParents(twoDimentionalArray) - ..deletedIn(arena); - expect(stack, isA>()); - expect(stack.$type, isA<$MyStackType>()); - expect( - stack.pop().toDartString(deleteOriginal: true), - "Hello", - ); - }); - }); - }); - group('Kotlin support', () { - test('Suspend functions', () async { - await using((arena) async { - final suspendFun = SuspendFun()..deletedIn(arena); - final hello = await suspendFun.sayHello(); - expect(hello.toDartString(deleteOriginal: true), "Hello!"); - const name = "Bob"; - final helloBob = - await suspendFun.sayHello1(name.toJString()..deletedIn(arena)); - expect(helloBob.toDartString(deleteOriginal: true), "Hello $name!"); - }); - }); - }); -} diff --git a/pkgs/jnigen/test/config_test.dart b/pkgs/jnigen/test/config_test.dart index 2faa528df..97fbb3d97 100644 --- a/pkgs/jnigen/test/config_test.dart +++ b/pkgs/jnigen/test/config_test.dart @@ -15,10 +15,10 @@ import 'test_util/test_util.dart'; const packageTests = 'test'; final jacksonCoreTests = absolute(packageTests, 'jackson_core_test'); final thirdParty = absolute(jacksonCoreTests, 'third_party'); -final lib = absolute(thirdParty, 'lib'); -final src = absolute(thirdParty, 'src'); -final testLib = absolute(thirdParty, 'test_', 'lib'); -final testSrc = absolute(thirdParty, 'test_', 'src'); +final lib = absolute(thirdParty, 'c_based', 'dart_bindings'); +final src = absolute(thirdParty, 'c_based', 'c_bindings'); +final testLib = absolute(thirdParty, 'test_', 'c_based', 'dart_bindings'); +final testSrc = absolute(thirdParty, 'test_', 'c_based', 'c_bindings'); /// Compares 2 [Config] objects using [expect] to give useful errors when /// two fields are not equal. @@ -104,7 +104,13 @@ void main() async { ]); test('compare configuration values', () { - expectConfigsAreEqual(config, getConfig(root: join(thirdParty, 'test_'))); + expectConfigsAreEqual( + config, + getConfig( + root: join(thirdParty, 'test_'), + bindingsType: BindingsType.cBased, + ), + ); }); group('Test for config error checking', () { diff --git a/pkgs/jnigen/test/jackson_core_test/generate.dart b/pkgs/jnigen/test/jackson_core_test/generate.dart index c804e5792..7077bfa7e 100644 --- a/pkgs/jnigen/test/jackson_core_test/generate.dart +++ b/pkgs/jnigen/test/jackson_core_test/generate.dart @@ -28,9 +28,14 @@ const testName = 'jackson_core_test'; final thirdPartyDir = join('test', testName, 'third_party'); const deps = ['com.fasterxml.jackson.core:jackson-core:2.13.4']; -Config getConfig( - {String? root, bool generateFullVersion = false, bool useAsm = false}) { +Config getConfig({ + String? root, + bool generateFullVersion = false, + bool useAsm = false, + BindingsType bindingsType = BindingsType.dartOnly, +}) { final rootDir = root ?? thirdPartyDir; + final bindingTypeDir = bindingsType.getConfigString(); final config = Config( mavenDownloads: MavenDownloads( sourceDeps: deps, @@ -42,9 +47,17 @@ Config getConfig( ), preamble: jacksonPreamble, outputConfig: OutputConfig( - bindingsType: BindingsType.dartOnly, + bindingsType: bindingsType, + // Have to be judicious here, and ensure null when bindings type is + // dart-only, because config-test is also using this. + cConfig: bindingsType == BindingsType.cBased + ? CCodeOutputConfig( + libraryName: 'jackson_core', + path: Uri.directory(join(rootDir, bindingTypeDir, 'c_bindings')), + ) + : null, dartConfig: DartCodeOutputConfig( - path: Uri.directory(join(rootDir, 'lib')), + path: Uri.directory(join(rootDir, bindingTypeDir, 'dart_bindings')), ), ), classes: (generateFullVersion) @@ -71,4 +84,7 @@ Config getConfig( return config; } -void main() async => await generateJniBindings(getConfig()); +void main() async { + await generateJniBindings(getConfig(bindingsType: BindingsType.cBased)); + await generateJniBindings(getConfig(bindingsType: BindingsType.dartOnly)); +} diff --git a/pkgs/jnigen/test/jackson_core_test/generated_files_test.dart b/pkgs/jnigen/test/jackson_core_test/generated_files_test.dart index 912961277..818e5d071 100644 --- a/pkgs/jnigen/test/jackson_core_test/generated_files_test.dart +++ b/pkgs/jnigen/test/jackson_core_test/generated_files_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:path/path.dart' hide equals; import 'package:test/test.dart'; import 'package:jnigen/jnigen.dart'; @@ -13,12 +12,11 @@ import 'generate.dart'; void main() async { await checkLocallyBuiltDependencies(); - test("compare generated bindings for jackson_core", () async { - final lib = join(thirdPartyDir, 'lib'); - final src = join(thirdPartyDir, 'src'); - await generateAndCompareBindings(getConfig(), lib, src); - }, timeout: const Timeout.factor(2)); - + generateAndCompareBothModes( + 'Generate and compare bindings for jackson_core library', + getConfig(bindingsType: BindingsType.cBased), + getConfig(bindingsType: BindingsType.dartOnly), + ); test( 'generate and analyze bindings for complete library, ' 'not just required classes', () async { diff --git a/pkgs/jnigen/test/jackson_core_test/jnigen.yaml b/pkgs/jnigen/test/jackson_core_test/jnigen.yaml index 54c90ba3f..6041671c9 100644 --- a/pkgs/jnigen/test/jackson_core_test/jnigen.yaml +++ b/pkgs/jnigen/test/jackson_core_test/jnigen.yaml @@ -5,9 +5,12 @@ maven_downloads: jar_dir: third_party/jar/ output: - bindings_type: dart_only + bindings_type: c_based + c: + library_name: jackson_core + path: third_party/c_based/c_bindings/ dart: - path: third_party/lib/ + path: third_party/c_based/dart_bindings/ classes: - 'com.fasterxml.jackson.core.JsonFactory' @@ -21,7 +24,6 @@ exclude: - 'com.fasterxml.jackson.core.base.ParserMinimalBase#CHAR_NULL' - 'com.fasterxml.jackson.core.io.UTF32Reader#NC' - preamble: | // Generated from jackson-core which is licensed under the Apache License 2.0. // The following copyright from the original authors applies. diff --git a/pkgs/jnigen/test/jackson_core_test/runtime_test_registrant.dart b/pkgs/jnigen/test/jackson_core_test/runtime_test_registrant.dart new file mode 100644 index 000000000..32687fba4 --- /dev/null +++ b/pkgs/jnigen/test/jackson_core_test/runtime_test_registrant.dart @@ -0,0 +1,42 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +import 'package:test/test.dart'; +import 'package:jni/jni.dart'; + +import '../test_util/callback_types.dart'; + +import 'third_party/c_based/dart_bindings/com/fasterxml/jackson/core/_package.dart'; + +// This file doesn't define main, because only one JVM has to be spawned with +// all classpaths, it's managed at a different file which calls these tests. + +void registerTests(String groupName, TestRunnerCallback test) { + group(groupName, () { + test('simple json parsing test', () { + final json = JString.fromString('[1, true, false, 2, 4]'); + JsonFactory factory; + factory = JsonFactory(); + final parser = factory.createParser6(json); + final values = []; + while (!parser.isClosed()) { + final next = parser.nextToken(); + if (next.isNull) continue; + values.add(next.isNumeric()); + next.delete(); + } + expect(values, equals([false, true, false, false, true, true, false])); + Jni.deleteAll([factory, parser, json]); + }); + test("parsing invalid JSON throws JniException", () { + using((arena) { + final factory = JsonFactory()..deletedIn(arena); + final erroneous = factory + .createParser6("".toJString()..deletedIn(arena)) + ..deletedIn(arena); + expect(() => erroneous.nextToken(), throwsA(isA())); + }); + }); + }); +} diff --git a/pkgs/jnigen/test/kotlin_test/src/.clang-format b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/.clang-format similarity index 100% rename from pkgs/jnigen/test/kotlin_test/src/.clang-format rename to pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/.clang-format diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/CMakeLists.txt b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/CMakeLists.txt new file mode 100644 index 000000000..db216f524 --- /dev/null +++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/CMakeLists.txt @@ -0,0 +1,32 @@ +# jni_native_build (Build with jni:setup. Do not delete this line.) + +# The Flutter tooling requires that developers have CMake 3.10 or later +# installed. You should not increase this version, as doing so will cause +# the plugin to fail to compile for some customers of the plugin. +cmake_minimum_required(VERSION 3.10) + +project(jackson_core VERSION 0.0.1 LANGUAGES C) + +add_library(jackson_core SHARED + "./jackson_core.c" +) + +set_target_properties(jackson_core PROPERTIES + OUTPUT_NAME "jackson_core" +) + +target_compile_definitions(jackson_core PUBLIC DART_SHARED_LIB) + +if(WIN32) + set_target_properties(${TARGET_NAME} PROPERTIES + LINK_FLAGS "/DELAYLOAD:jvm.dll") +endif() + +if (ANDROID) + target_link_libraries(jackson_core log) +else() + find_package(Java REQUIRED) + find_package(JNI REQUIRED) + include_directories(${JNI_INCLUDE_DIRS}) + target_link_libraries(jackson_core ${JNI_LIBRARIES}) +endif() diff --git a/pkgs/jnigen/test/kotlin_test/src/dartjni.h b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/dartjni.h similarity index 94% rename from pkgs/jnigen/test/kotlin_test/src/dartjni.h rename to pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/dartjni.h index 21cef2036..c0713af53 100644 --- a/pkgs/jnigen/test/kotlin_test/src/dartjni.h +++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/dartjni.h @@ -176,10 +176,10 @@ typedef struct JniAccessorsStruct { char* methodName, char* signature); JniResult (*newObject)(jclass cls, jmethodID ctor, jvalue* args); - JniPointerResult (*newPrimitiveArray)(jsize length, int type); - JniPointerResult (*newObjectArray)(jsize length, - jclass elementClass, - jobject initialElement); + JniResult (*newPrimitiveArray)(jsize length, int type); + JniResult (*newObjectArray)(jsize length, + jclass elementClass, + jobject initialElement); JniResult (*getArrayElement)(jarray array, int index, int type); JniResult (*callMethod)(jobject obj, jmethodID methodID, @@ -261,8 +261,10 @@ static inline void load_class_global_ref(jclass* cls, const char* name) { acquire_lock(&jni->locks.classLoadingLock); if (*cls == NULL) { load_class_platform(&tmp, name); - *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); - (*jniEnv)->DeleteLocalRef(jniEnv, tmp); + if (!(*jniEnv)->ExceptionCheck(jniEnv)) { + *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); + (*jniEnv)->DeleteLocalRef(jniEnv, tmp); + } } release_lock(&jni->locks.classLoadingLock); } @@ -356,6 +358,15 @@ static inline jthrowable check_exception() { return to_global_ref(exception); } +static inline JniResult to_global_ref_result(jobject ref) { + JniResult result; + result.exception = check_exception(); + if (result.exception == NULL) { + result.value.l = to_global_ref(ref); + } + return result; +} + FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); JNIEXPORT void JNICALL diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/jackson_core.c b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/jackson_core.c new file mode 100644 index 000000000..74bf137c2 --- /dev/null +++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/jackson_core.c @@ -0,0 +1,3729 @@ +// Generated from jackson-core which is licensed under the Apache License 2.0. +// The following copyright from the original authors applies. +// See https://github.com/FasterXML/jackson-core/blob/2.14/LICENSE +// +// Copyright (c) 2007 - The Jackson Project Authors +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Autogenerated by jnigen. DO NOT EDIT! + +#include +#include "dartjni.h" +#include "jni.h" + +thread_local JNIEnv* jniEnv; +JniContext* jni; + +JniContext* (*context_getter)(void); +JNIEnv* (*env_getter)(void); + +void setJniGetters(JniContext* (*cg)(void), JNIEnv* (*eg)(void)) { + context_getter = cg; + env_getter = eg; +} + +// com.fasterxml.jackson.core.JsonFactory +jclass _c_JsonFactory = NULL; + +jmethodID _m_JsonFactory__ctor = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__ctor() { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__ctor, "", "()V"); + if (_m_JsonFactory__ctor == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->NewObject(jniEnv, _c_JsonFactory, _m_JsonFactory__ctor); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__ctor1 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__ctor1(jobject oc) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__ctor1, "", + "(Lcom/fasterxml/jackson/core/ObjectCodec;)V"); + if (_m_JsonFactory__ctor1 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->NewObject(jniEnv, _c_JsonFactory, _m_JsonFactory__ctor1, oc); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__ctor2 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__ctor2(jobject src, jobject codec) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__ctor2, "", + "(Lcom/fasterxml/jackson/core/JsonFactory;Lcom/fasterxml/jackson/" + "core/ObjectCodec;)V"); + if (_m_JsonFactory__ctor2 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_JsonFactory, + _m_JsonFactory__ctor2, src, codec); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__ctor3 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__ctor3(jobject b) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__ctor3, "", + "(Lcom/fasterxml/jackson/core/JsonFactoryBuilder;)V"); + if (_m_JsonFactory__ctor3 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->NewObject(jniEnv, _c_JsonFactory, _m_JsonFactory__ctor3, b); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__ctor4 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__ctor4(jobject b, uint8_t bogus) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__ctor4, "", + "(Lcom/fasterxml/jackson/core/TSFBuilder;Z)V"); + if (_m_JsonFactory__ctor4 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_JsonFactory, + _m_JsonFactory__ctor4, b, bogus); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__rebuild = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__rebuild(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__rebuild, "rebuild", + "()Lcom/fasterxml/jackson/core/TSFBuilder;"); + if (_m_JsonFactory__rebuild == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_JsonFactory__rebuild); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__builder = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__builder() { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_JsonFactory, &_m_JsonFactory__builder, "builder", + "()Lcom/fasterxml/jackson/core/TSFBuilder;"); + if (_m_JsonFactory__builder == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_JsonFactory, + _m_JsonFactory__builder); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__copy = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__copy(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__copy, "copy", + "()Lcom/fasterxml/jackson/core/JsonFactory;"); + if (_m_JsonFactory__copy == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_JsonFactory__copy); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__readResolve = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__readResolve(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__readResolve, "readResolve", + "()Ljava/lang/Object;"); + if (_m_JsonFactory__readResolve == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_JsonFactory__readResolve); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__requiresPropertyOrdering = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__requiresPropertyOrdering(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__requiresPropertyOrdering, + "requiresPropertyOrdering", "()Z"); + if (_m_JsonFactory__requiresPropertyOrdering == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = (*jniEnv)->CallBooleanMethod( + jniEnv, self_, _m_JsonFactory__requiresPropertyOrdering); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonFactory__canHandleBinaryNatively = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__canHandleBinaryNatively(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__canHandleBinaryNatively, + "canHandleBinaryNatively", "()Z"); + if (_m_JsonFactory__canHandleBinaryNatively == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = (*jniEnv)->CallBooleanMethod( + jniEnv, self_, _m_JsonFactory__canHandleBinaryNatively); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonFactory__canUseCharArrays = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__canUseCharArrays(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__canUseCharArrays, + "canUseCharArrays", "()Z"); + if (_m_JsonFactory__canUseCharArrays == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = (*jniEnv)->CallBooleanMethod( + jniEnv, self_, _m_JsonFactory__canUseCharArrays); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonFactory__canParseAsync = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__canParseAsync(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__canParseAsync, "canParseAsync", + "()Z"); + if (_m_JsonFactory__canParseAsync == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, + _m_JsonFactory__canParseAsync); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonFactory__getFormatReadFeatureType = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__getFormatReadFeatureType(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__getFormatReadFeatureType, + "getFormatReadFeatureType", "()Ljava/lang/Class;"); + if (_m_JsonFactory__getFormatReadFeatureType == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__getFormatReadFeatureType); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__getFormatWriteFeatureType = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__getFormatWriteFeatureType(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__getFormatWriteFeatureType, + "getFormatWriteFeatureType", "()Ljava/lang/Class;"); + if (_m_JsonFactory__getFormatWriteFeatureType == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__getFormatWriteFeatureType); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__canUseSchema = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__canUseSchema(jobject self_, jobject schema) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__canUseSchema, "canUseSchema", + "(Lcom/fasterxml/jackson/core/FormatSchema;)Z"); + if (_m_JsonFactory__canUseSchema == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = (*jniEnv)->CallBooleanMethod( + jniEnv, self_, _m_JsonFactory__canUseSchema, schema); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonFactory__getFormatName = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__getFormatName(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__getFormatName, "getFormatName", + "()Ljava/lang/String;"); + if (_m_JsonFactory__getFormatName == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_JsonFactory__getFormatName); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__hasFormat = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__hasFormat(jobject self_, jobject acc) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__hasFormat, "hasFormat", + "(Lcom/fasterxml/jackson/core/format/InputAccessor;)Lcom/" + "fasterxml/jackson/core/format/MatchStrength;"); + if (_m_JsonFactory__hasFormat == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, + _m_JsonFactory__hasFormat, acc); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__requiresCustomCodec = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__requiresCustomCodec(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__requiresCustomCodec, + "requiresCustomCodec", "()Z"); + if (_m_JsonFactory__requiresCustomCodec == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = (*jniEnv)->CallBooleanMethod( + jniEnv, self_, _m_JsonFactory__requiresCustomCodec); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonFactory__hasJSONFormat = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__hasJSONFormat(jobject self_, jobject acc) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__hasJSONFormat, "hasJSONFormat", + "(Lcom/fasterxml/jackson/core/format/InputAccessor;)Lcom/" + "fasterxml/jackson/core/format/MatchStrength;"); + if (_m_JsonFactory__hasJSONFormat == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__hasJSONFormat, acc); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__version = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__version(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__version, "version", + "()Lcom/fasterxml/jackson/core/Version;"); + if (_m_JsonFactory__version == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_JsonFactory__version); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__configure = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__configure(jobject self_, jobject f, uint8_t state) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__configure, "configure", + "(Lcom/fasterxml/jackson/core/JsonFactory$Feature;Z)Lcom/" + "fasterxml/jackson/core/JsonFactory;"); + if (_m_JsonFactory__configure == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__configure, f, state); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__enable = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__enable(jobject self_, jobject f) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__enable, "enable", + "(Lcom/fasterxml/jackson/core/JsonFactory$Feature;)Lcom/" + "fasterxml/jackson/core/JsonFactory;"); + if (_m_JsonFactory__enable == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_JsonFactory__enable, f); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__disable = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__disable(jobject self_, jobject f) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__disable, "disable", + "(Lcom/fasterxml/jackson/core/JsonFactory$Feature;)Lcom/" + "fasterxml/jackson/core/JsonFactory;"); + if (_m_JsonFactory__disable == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_JsonFactory__disable, f); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__isEnabled = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__isEnabled(jobject self_, jobject f) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__isEnabled, "isEnabled", + "(Lcom/fasterxml/jackson/core/JsonFactory$Feature;)Z"); + if (_m_JsonFactory__isEnabled == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = + (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_JsonFactory__isEnabled, f); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonFactory__getParserFeatures = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__getParserFeatures(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__getParserFeatures, + "getParserFeatures", "()I"); + if (_m_JsonFactory__getParserFeatures == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, + _m_JsonFactory__getParserFeatures); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonFactory__getGeneratorFeatures = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__getGeneratorFeatures(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__getGeneratorFeatures, + "getGeneratorFeatures", "()I"); + if (_m_JsonFactory__getGeneratorFeatures == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int32_t _result = (*jniEnv)->CallIntMethod( + jniEnv, self_, _m_JsonFactory__getGeneratorFeatures); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonFactory__getFormatParserFeatures = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__getFormatParserFeatures(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__getFormatParserFeatures, + "getFormatParserFeatures", "()I"); + if (_m_JsonFactory__getFormatParserFeatures == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int32_t _result = (*jniEnv)->CallIntMethod( + jniEnv, self_, _m_JsonFactory__getFormatParserFeatures); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonFactory__getFormatGeneratorFeatures = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__getFormatGeneratorFeatures(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__getFormatGeneratorFeatures, + "getFormatGeneratorFeatures", "()I"); + if (_m_JsonFactory__getFormatGeneratorFeatures == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int32_t _result = (*jniEnv)->CallIntMethod( + jniEnv, self_, _m_JsonFactory__getFormatGeneratorFeatures); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonFactory__configure1 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__configure1(jobject self_, jobject f, uint8_t state) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__configure1, "configure", + "(Lcom/fasterxml/jackson/core/JsonParser$Feature;Z)Lcom/" + "fasterxml/jackson/core/JsonFactory;"); + if (_m_JsonFactory__configure1 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__configure1, f, state); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__enable1 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__enable1(jobject self_, jobject f) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__enable1, "enable", + "(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/" + "jackson/core/JsonFactory;"); + if (_m_JsonFactory__enable1 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_JsonFactory__enable1, f); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__disable1 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__disable1(jobject self_, jobject f) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__disable1, "disable", + "(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/" + "jackson/core/JsonFactory;"); + if (_m_JsonFactory__disable1 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_JsonFactory__disable1, f); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__isEnabled1 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__isEnabled1(jobject self_, jobject f) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__isEnabled1, "isEnabled", + "(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Z"); + if (_m_JsonFactory__isEnabled1 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, + _m_JsonFactory__isEnabled1, f); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonFactory__isEnabled2 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__isEnabled2(jobject self_, jobject f) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__isEnabled2, "isEnabled", + "(Lcom/fasterxml/jackson/core/StreamReadFeature;)Z"); + if (_m_JsonFactory__isEnabled2 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, + _m_JsonFactory__isEnabled2, f); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonFactory__getInputDecorator = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__getInputDecorator(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__getInputDecorator, + "getInputDecorator", + "()Lcom/fasterxml/jackson/core/io/InputDecorator;"); + if (_m_JsonFactory__getInputDecorator == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__getInputDecorator); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__setInputDecorator = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__setInputDecorator(jobject self_, jobject d) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__setInputDecorator, + "setInputDecorator", + "(Lcom/fasterxml/jackson/core/io/InputDecorator;)Lcom/fasterxml/" + "jackson/core/JsonFactory;"); + if (_m_JsonFactory__setInputDecorator == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__setInputDecorator, d); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__configure2 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__configure2(jobject self_, jobject f, uint8_t state) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__configure2, "configure", + "(Lcom/fasterxml/jackson/core/JsonGenerator$Feature;Z)Lcom/" + "fasterxml/jackson/core/JsonFactory;"); + if (_m_JsonFactory__configure2 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__configure2, f, state); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__enable2 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__enable2(jobject self_, jobject f) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__enable2, "enable", + "(Lcom/fasterxml/jackson/core/JsonGenerator$Feature;)Lcom/" + "fasterxml/jackson/core/JsonFactory;"); + if (_m_JsonFactory__enable2 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_JsonFactory__enable2, f); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__disable2 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__disable2(jobject self_, jobject f) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__disable2, "disable", + "(Lcom/fasterxml/jackson/core/JsonGenerator$Feature;)Lcom/" + "fasterxml/jackson/core/JsonFactory;"); + if (_m_JsonFactory__disable2 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_JsonFactory__disable2, f); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__isEnabled3 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__isEnabled3(jobject self_, jobject f) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__isEnabled3, "isEnabled", + "(Lcom/fasterxml/jackson/core/JsonGenerator$Feature;)Z"); + if (_m_JsonFactory__isEnabled3 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, + _m_JsonFactory__isEnabled3, f); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonFactory__isEnabled4 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__isEnabled4(jobject self_, jobject f) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__isEnabled4, "isEnabled", + "(Lcom/fasterxml/jackson/core/StreamWriteFeature;)Z"); + if (_m_JsonFactory__isEnabled4 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, + _m_JsonFactory__isEnabled4, f); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonFactory__getCharacterEscapes = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__getCharacterEscapes(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__getCharacterEscapes, + "getCharacterEscapes", + "()Lcom/fasterxml/jackson/core/io/CharacterEscapes;"); + if (_m_JsonFactory__getCharacterEscapes == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__getCharacterEscapes); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__setCharacterEscapes = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__setCharacterEscapes(jobject self_, jobject esc) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__setCharacterEscapes, + "setCharacterEscapes", + "(Lcom/fasterxml/jackson/core/io/CharacterEscapes;)Lcom/" + "fasterxml/jackson/core/JsonFactory;"); + if (_m_JsonFactory__setCharacterEscapes == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__setCharacterEscapes, esc); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__getOutputDecorator = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__getOutputDecorator(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__getOutputDecorator, + "getOutputDecorator", + "()Lcom/fasterxml/jackson/core/io/OutputDecorator;"); + if (_m_JsonFactory__getOutputDecorator == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__getOutputDecorator); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__setOutputDecorator = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__setOutputDecorator(jobject self_, jobject d) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__setOutputDecorator, + "setOutputDecorator", + "(Lcom/fasterxml/jackson/core/io/OutputDecorator;)Lcom/fasterxml/" + "jackson/core/JsonFactory;"); + if (_m_JsonFactory__setOutputDecorator == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__setOutputDecorator, d); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__setRootValueSeparator = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__setRootValueSeparator(jobject self_, jobject sep) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__setRootValueSeparator, + "setRootValueSeparator", + "(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonFactory;"); + if (_m_JsonFactory__setRootValueSeparator == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__setRootValueSeparator, sep); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__getRootValueSeparator = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__getRootValueSeparator(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__getRootValueSeparator, + "getRootValueSeparator", "()Ljava/lang/String;"); + if (_m_JsonFactory__getRootValueSeparator == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__getRootValueSeparator); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__setCodec = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__setCodec(jobject self_, jobject oc) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__setCodec, "setCodec", + "(Lcom/fasterxml/jackson/core/ObjectCodec;)Lcom/fasterxml/" + "jackson/core/JsonFactory;"); + if (_m_JsonFactory__setCodec == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_JsonFactory__setCodec, oc); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__getCodec = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__getCodec(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__getCodec, "getCodec", + "()Lcom/fasterxml/jackson/core/ObjectCodec;"); + if (_m_JsonFactory__getCodec == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_JsonFactory__getCodec); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__createParser = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__createParser(jobject self_, jobject f) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__createParser, "createParser", + "(Ljava/io/File;)Lcom/fasterxml/jackson/core/JsonParser;"); + if (_m_JsonFactory__createParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__createParser, f); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__createParser1 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__createParser1(jobject self_, jobject url) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__createParser1, "createParser", + "(Ljava/net/URL;)Lcom/fasterxml/jackson/core/JsonParser;"); + if (_m_JsonFactory__createParser1 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__createParser1, url); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__createParser2 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__createParser2(jobject self_, jobject in) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__createParser2, "createParser", + "(Ljava/io/InputStream;)Lcom/fasterxml/jackson/core/JsonParser;"); + if (_m_JsonFactory__createParser2 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__createParser2, in); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__createParser3 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__createParser3(jobject self_, jobject r) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__createParser3, "createParser", + "(Ljava/io/Reader;)Lcom/fasterxml/jackson/core/JsonParser;"); + if (_m_JsonFactory__createParser3 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__createParser3, r); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__createParser4 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__createParser4(jobject self_, jobject data) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__createParser4, "createParser", + "([B)Lcom/fasterxml/jackson/core/JsonParser;"); + if (_m_JsonFactory__createParser4 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__createParser4, data); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__createParser5 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__createParser5(jobject self_, + jobject data, + int32_t offset, + int32_t len) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__createParser5, "createParser", + "([BII)Lcom/fasterxml/jackson/core/JsonParser;"); + if (_m_JsonFactory__createParser5 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__createParser5, data, offset, len); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__createParser6 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__createParser6(jobject self_, jobject content) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__createParser6, "createParser", + "(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonParser;"); + if (_m_JsonFactory__createParser6 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__createParser6, content); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__createParser7 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__createParser7(jobject self_, jobject content) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__createParser7, "createParser", + "([C)Lcom/fasterxml/jackson/core/JsonParser;"); + if (_m_JsonFactory__createParser7 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__createParser7, content); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__createParser8 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__createParser8(jobject self_, + jobject content, + int32_t offset, + int32_t len) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__createParser8, "createParser", + "([CII)Lcom/fasterxml/jackson/core/JsonParser;"); + if (_m_JsonFactory__createParser8 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__createParser8, content, offset, len); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__createParser9 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__createParser9(jobject self_, jobject in) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__createParser9, "createParser", + "(Ljava/io/DataInput;)Lcom/fasterxml/jackson/core/JsonParser;"); + if (_m_JsonFactory__createParser9 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__createParser9, in); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__createNonBlockingByteArrayParser = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__createNonBlockingByteArrayParser(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__createNonBlockingByteArrayParser, + "createNonBlockingByteArrayParser", + "()Lcom/fasterxml/jackson/core/JsonParser;"); + if (_m_JsonFactory__createNonBlockingByteArrayParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__createNonBlockingByteArrayParser); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__createGenerator = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__createGenerator(jobject self_, + jobject out, + jobject enc) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__createGenerator, + "createGenerator", + "(Ljava/io/OutputStream;Lcom/fasterxml/jackson/core/" + "JsonEncoding;)Lcom/fasterxml/jackson/core/JsonGenerator;"); + if (_m_JsonFactory__createGenerator == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__createGenerator, out, enc); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__createGenerator1 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__createGenerator1(jobject self_, jobject out) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method( + _c_JsonFactory, &_m_JsonFactory__createGenerator1, "createGenerator", + "(Ljava/io/OutputStream;)Lcom/fasterxml/jackson/core/JsonGenerator;"); + if (_m_JsonFactory__createGenerator1 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__createGenerator1, out); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__createGenerator2 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__createGenerator2(jobject self_, jobject w) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__createGenerator2, + "createGenerator", + "(Ljava/io/Writer;)Lcom/fasterxml/jackson/core/JsonGenerator;"); + if (_m_JsonFactory__createGenerator2 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__createGenerator2, w); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__createGenerator3 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__createGenerator3(jobject self_, jobject f, jobject enc) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__createGenerator3, + "createGenerator", + "(Ljava/io/File;Lcom/fasterxml/jackson/core/JsonEncoding;)Lcom/" + "fasterxml/jackson/core/JsonGenerator;"); + if (_m_JsonFactory__createGenerator3 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__createGenerator3, f, enc); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__createGenerator4 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__createGenerator4(jobject self_, + jobject out, + jobject enc) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__createGenerator4, + "createGenerator", + "(Ljava/io/DataOutput;Lcom/fasterxml/jackson/core/" + "JsonEncoding;)Lcom/fasterxml/jackson/core/JsonGenerator;"); + if (_m_JsonFactory__createGenerator4 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__createGenerator4, out, enc); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__createGenerator5 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__createGenerator5(jobject self_, jobject out) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method( + _c_JsonFactory, &_m_JsonFactory__createGenerator5, "createGenerator", + "(Ljava/io/DataOutput;)Lcom/fasterxml/jackson/core/JsonGenerator;"); + if (_m_JsonFactory__createGenerator5 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__createGenerator5, out); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__createJsonParser = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__createJsonParser(jobject self_, jobject f) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__createJsonParser, + "createJsonParser", + "(Ljava/io/File;)Lcom/fasterxml/jackson/core/JsonParser;"); + if (_m_JsonFactory__createJsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__createJsonParser, f); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__createJsonParser1 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__createJsonParser1(jobject self_, jobject url) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__createJsonParser1, + "createJsonParser", + "(Ljava/net/URL;)Lcom/fasterxml/jackson/core/JsonParser;"); + if (_m_JsonFactory__createJsonParser1 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__createJsonParser1, url); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__createJsonParser2 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__createJsonParser2(jobject self_, jobject in) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__createJsonParser2, + "createJsonParser", + "(Ljava/io/InputStream;)Lcom/fasterxml/jackson/core/JsonParser;"); + if (_m_JsonFactory__createJsonParser2 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__createJsonParser2, in); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__createJsonParser3 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__createJsonParser3(jobject self_, jobject r) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__createJsonParser3, + "createJsonParser", + "(Ljava/io/Reader;)Lcom/fasterxml/jackson/core/JsonParser;"); + if (_m_JsonFactory__createJsonParser3 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__createJsonParser3, r); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__createJsonParser4 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__createJsonParser4(jobject self_, jobject data) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__createJsonParser4, + "createJsonParser", + "([B)Lcom/fasterxml/jackson/core/JsonParser;"); + if (_m_JsonFactory__createJsonParser4 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__createJsonParser4, data); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__createJsonParser5 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__createJsonParser5(jobject self_, + jobject data, + int32_t offset, + int32_t len) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__createJsonParser5, + "createJsonParser", + "([BII)Lcom/fasterxml/jackson/core/JsonParser;"); + if (_m_JsonFactory__createJsonParser5 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__createJsonParser5, data, offset, len); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__createJsonParser6 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__createJsonParser6(jobject self_, jobject content) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__createJsonParser6, + "createJsonParser", + "(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonParser;"); + if (_m_JsonFactory__createJsonParser6 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__createJsonParser6, content); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__createJsonGenerator = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__createJsonGenerator(jobject self_, + jobject out, + jobject enc) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__createJsonGenerator, + "createJsonGenerator", + "(Ljava/io/OutputStream;Lcom/fasterxml/jackson/core/" + "JsonEncoding;)Lcom/fasterxml/jackson/core/JsonGenerator;"); + if (_m_JsonFactory__createJsonGenerator == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__createJsonGenerator, out, enc); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__createJsonGenerator1 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__createJsonGenerator1(jobject self_, jobject out) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory, &_m_JsonFactory__createJsonGenerator1, + "createJsonGenerator", + "(Ljava/io/Writer;)Lcom/fasterxml/jackson/core/JsonGenerator;"); + if (_m_JsonFactory__createJsonGenerator1 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__createJsonGenerator1, out); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory__createJsonGenerator2 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory__createJsonGenerator2(jobject self_, jobject out) { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method( + _c_JsonFactory, &_m_JsonFactory__createJsonGenerator2, + "createJsonGenerator", + "(Ljava/io/OutputStream;)Lcom/fasterxml/jackson/core/JsonGenerator;"); + if (_m_JsonFactory__createJsonGenerator2 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonFactory__createJsonGenerator2, out); + return to_global_ref_result(_result); +} + +jfieldID _f_JsonFactory__DEFAULT_FACTORY_FEATURE_FLAGS = NULL; +FFI_PLUGIN_EXPORT +JniResult get_JsonFactory__DEFAULT_FACTORY_FEATURE_FLAGS() { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_field(_c_JsonFactory, + &_f_JsonFactory__DEFAULT_FACTORY_FEATURE_FLAGS, + "DEFAULT_FACTORY_FEATURE_FLAGS", "I"); + int32_t _result = (*jniEnv)->GetStaticIntField( + jniEnv, _c_JsonFactory, _f_JsonFactory__DEFAULT_FACTORY_FEATURE_FLAGS); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +jfieldID _f_JsonFactory__DEFAULT_PARSER_FEATURE_FLAGS = NULL; +FFI_PLUGIN_EXPORT +JniResult get_JsonFactory__DEFAULT_PARSER_FEATURE_FLAGS() { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_field(_c_JsonFactory, + &_f_JsonFactory__DEFAULT_PARSER_FEATURE_FLAGS, + "DEFAULT_PARSER_FEATURE_FLAGS", "I"); + int32_t _result = (*jniEnv)->GetStaticIntField( + jniEnv, _c_JsonFactory, _f_JsonFactory__DEFAULT_PARSER_FEATURE_FLAGS); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +jfieldID _f_JsonFactory__DEFAULT_GENERATOR_FEATURE_FLAGS = NULL; +FFI_PLUGIN_EXPORT +JniResult get_JsonFactory__DEFAULT_GENERATOR_FEATURE_FLAGS() { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_field(_c_JsonFactory, + &_f_JsonFactory__DEFAULT_GENERATOR_FEATURE_FLAGS, + "DEFAULT_GENERATOR_FEATURE_FLAGS", "I"); + int32_t _result = (*jniEnv)->GetStaticIntField( + jniEnv, _c_JsonFactory, _f_JsonFactory__DEFAULT_GENERATOR_FEATURE_FLAGS); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +jfieldID _f_JsonFactory__DEFAULT_ROOT_VALUE_SEPARATOR = NULL; +FFI_PLUGIN_EXPORT +JniResult get_JsonFactory__DEFAULT_ROOT_VALUE_SEPARATOR() { + load_env(); + load_class_global_ref(&_c_JsonFactory, + "com/fasterxml/jackson/core/JsonFactory"); + if (_c_JsonFactory == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_field(_c_JsonFactory, + &_f_JsonFactory__DEFAULT_ROOT_VALUE_SEPARATOR, + "DEFAULT_ROOT_VALUE_SEPARATOR", + "Lcom/fasterxml/jackson/core/SerializableString;"); + jobject _result = (*jniEnv)->GetStaticObjectField( + jniEnv, _c_JsonFactory, _f_JsonFactory__DEFAULT_ROOT_VALUE_SEPARATOR); + return to_global_ref_result(_result); +} + +// com.fasterxml.jackson.core.JsonFactory$Feature +jclass _c_JsonFactory_Feature = NULL; + +jmethodID _m_JsonFactory_Feature__values = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory_Feature__values() { + load_env(); + load_class_global_ref(&_c_JsonFactory_Feature, + "com/fasterxml/jackson/core/JsonFactory$Feature"); + if (_c_JsonFactory_Feature == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_JsonFactory_Feature, &_m_JsonFactory_Feature__values, + "values", + "()[Lcom/fasterxml/jackson/core/JsonFactory$Feature;"); + if (_m_JsonFactory_Feature__values == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallStaticObjectMethod( + jniEnv, _c_JsonFactory_Feature, _m_JsonFactory_Feature__values); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory_Feature__valueOf = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory_Feature__valueOf(jobject name) { + load_env(); + load_class_global_ref(&_c_JsonFactory_Feature, + "com/fasterxml/jackson/core/JsonFactory$Feature"); + if (_c_JsonFactory_Feature == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_method( + _c_JsonFactory_Feature, &_m_JsonFactory_Feature__valueOf, "valueOf", + "(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonFactory$Feature;"); + if (_m_JsonFactory_Feature__valueOf == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallStaticObjectMethod( + jniEnv, _c_JsonFactory_Feature, _m_JsonFactory_Feature__valueOf, name); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonFactory_Feature__collectDefaults = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory_Feature__collectDefaults() { + load_env(); + load_class_global_ref(&_c_JsonFactory_Feature, + "com/fasterxml/jackson/core/JsonFactory$Feature"); + if (_c_JsonFactory_Feature == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_JsonFactory_Feature, + &_m_JsonFactory_Feature__collectDefaults, + "collectDefaults", "()I"); + if (_m_JsonFactory_Feature__collectDefaults == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int32_t _result = (*jniEnv)->CallStaticIntMethod( + jniEnv, _c_JsonFactory_Feature, _m_JsonFactory_Feature__collectDefaults); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonFactory_Feature__enabledByDefault = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory_Feature__enabledByDefault(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonFactory_Feature, + "com/fasterxml/jackson/core/JsonFactory$Feature"); + if (_c_JsonFactory_Feature == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory_Feature, &_m_JsonFactory_Feature__enabledByDefault, + "enabledByDefault", "()Z"); + if (_m_JsonFactory_Feature__enabledByDefault == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = (*jniEnv)->CallBooleanMethod( + jniEnv, self_, _m_JsonFactory_Feature__enabledByDefault); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonFactory_Feature__enabledIn = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory_Feature__enabledIn(jobject self_, int32_t flags) { + load_env(); + load_class_global_ref(&_c_JsonFactory_Feature, + "com/fasterxml/jackson/core/JsonFactory$Feature"); + if (_c_JsonFactory_Feature == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory_Feature, &_m_JsonFactory_Feature__enabledIn, + "enabledIn", "(I)Z"); + if (_m_JsonFactory_Feature__enabledIn == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = (*jniEnv)->CallBooleanMethod( + jniEnv, self_, _m_JsonFactory_Feature__enabledIn, flags); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonFactory_Feature__getMask = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonFactory_Feature__getMask(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonFactory_Feature, + "com/fasterxml/jackson/core/JsonFactory$Feature"); + if (_c_JsonFactory_Feature == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonFactory_Feature, &_m_JsonFactory_Feature__getMask, + "getMask", "()I"); + if (_m_JsonFactory_Feature__getMask == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int32_t _result = + (*jniEnv)->CallIntMethod(jniEnv, self_, _m_JsonFactory_Feature__getMask); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +// com.fasterxml.jackson.core.JsonParser +jclass _c_JsonParser = NULL; + +jmethodID _m_JsonParser__ctor = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__ctor() { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__ctor, "", "()V"); + if (_m_JsonParser__ctor == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->NewObject(jniEnv, _c_JsonParser, _m_JsonParser__ctor); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__ctor1 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__ctor1(int32_t features) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__ctor1, "", "(I)V"); + if (_m_JsonParser__ctor1 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_JsonParser, + _m_JsonParser__ctor1, features); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__getCodec = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getCodec(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getCodec, "getCodec", + "()Lcom/fasterxml/jackson/core/ObjectCodec;"); + if (_m_JsonParser__getCodec == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_JsonParser__getCodec); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__setCodec = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__setCodec(jobject self_, jobject oc) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__setCodec, "setCodec", + "(Lcom/fasterxml/jackson/core/ObjectCodec;)V"); + if (_m_JsonParser__setCodec == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_JsonParser__setCodec, oc); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__getInputSource = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getInputSource(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getInputSource, "getInputSource", + "()Ljava/lang/Object;"); + if (_m_JsonParser__getInputSource == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_JsonParser__getInputSource); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__setRequestPayloadOnError = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__setRequestPayloadOnError(jobject self_, jobject payload) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__setRequestPayloadOnError, + "setRequestPayloadOnError", + "(Lcom/fasterxml/jackson/core/util/RequestPayload;)V"); + if (_m_JsonParser__setRequestPayloadOnError == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod(jniEnv, self_, + _m_JsonParser__setRequestPayloadOnError, payload); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__setRequestPayloadOnError1 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__setRequestPayloadOnError1(jobject self_, + jobject payload, + jobject charset) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__setRequestPayloadOnError1, + "setRequestPayloadOnError", "([BLjava/lang/String;)V"); + if (_m_JsonParser__setRequestPayloadOnError1 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod(jniEnv, self_, + _m_JsonParser__setRequestPayloadOnError1, payload, + charset); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__setRequestPayloadOnError2 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__setRequestPayloadOnError2(jobject self_, + jobject payload) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__setRequestPayloadOnError2, + "setRequestPayloadOnError", "(Ljava/lang/String;)V"); + if (_m_JsonParser__setRequestPayloadOnError2 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod(jniEnv, self_, + _m_JsonParser__setRequestPayloadOnError2, payload); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__setSchema = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__setSchema(jobject self_, jobject schema) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__setSchema, "setSchema", + "(Lcom/fasterxml/jackson/core/FormatSchema;)V"); + if (_m_JsonParser__setSchema == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_JsonParser__setSchema, schema); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__getSchema = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getSchema(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getSchema, "getSchema", + "()Lcom/fasterxml/jackson/core/FormatSchema;"); + if (_m_JsonParser__getSchema == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_JsonParser__getSchema); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__canUseSchema = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__canUseSchema(jobject self_, jobject schema) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__canUseSchema, "canUseSchema", + "(Lcom/fasterxml/jackson/core/FormatSchema;)Z"); + if (_m_JsonParser__canUseSchema == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = (*jniEnv)->CallBooleanMethod( + jniEnv, self_, _m_JsonParser__canUseSchema, schema); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__requiresCustomCodec = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__requiresCustomCodec(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__requiresCustomCodec, + "requiresCustomCodec", "()Z"); + if (_m_JsonParser__requiresCustomCodec == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = (*jniEnv)->CallBooleanMethod( + jniEnv, self_, _m_JsonParser__requiresCustomCodec); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__canParseAsync = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__canParseAsync(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__canParseAsync, "canParseAsync", + "()Z"); + if (_m_JsonParser__canParseAsync == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = + (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_JsonParser__canParseAsync); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__getNonBlockingInputFeeder = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getNonBlockingInputFeeder(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getNonBlockingInputFeeder, + "getNonBlockingInputFeeder", + "()Lcom/fasterxml/jackson/core/async/NonBlockingInputFeeder;"); + if (_m_JsonParser__getNonBlockingInputFeeder == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonParser__getNonBlockingInputFeeder); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__getReadCapabilities = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getReadCapabilities(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getReadCapabilities, + "getReadCapabilities", + "()Lcom/fasterxml/jackson/core/util/JacksonFeatureSet;"); + if (_m_JsonParser__getReadCapabilities == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonParser__getReadCapabilities); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__version = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__version(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__version, "version", + "()Lcom/fasterxml/jackson/core/Version;"); + if (_m_JsonParser__version == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_JsonParser__version); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__close = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__close(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__close, "close", "()V"); + if (_m_JsonParser__close == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_JsonParser__close); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__isClosed = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__isClosed(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__isClosed, "isClosed", "()Z"); + if (_m_JsonParser__isClosed == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = + (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_JsonParser__isClosed); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__getParsingContext = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getParsingContext(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getParsingContext, + "getParsingContext", + "()Lcom/fasterxml/jackson/core/JsonStreamContext;"); + if (_m_JsonParser__getParsingContext == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonParser__getParsingContext); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__currentLocation = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__currentLocation(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__currentLocation, "currentLocation", + "()Lcom/fasterxml/jackson/core/JsonLocation;"); + if (_m_JsonParser__currentLocation == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, + _m_JsonParser__currentLocation); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__currentTokenLocation = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__currentTokenLocation(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__currentTokenLocation, + "currentTokenLocation", + "()Lcom/fasterxml/jackson/core/JsonLocation;"); + if (_m_JsonParser__currentTokenLocation == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonParser__currentTokenLocation); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__getCurrentLocation = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getCurrentLocation(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getCurrentLocation, + "getCurrentLocation", + "()Lcom/fasterxml/jackson/core/JsonLocation;"); + if (_m_JsonParser__getCurrentLocation == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonParser__getCurrentLocation); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__getTokenLocation = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getTokenLocation(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getTokenLocation, + "getTokenLocation", + "()Lcom/fasterxml/jackson/core/JsonLocation;"); + if (_m_JsonParser__getTokenLocation == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonParser__getTokenLocation); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__currentValue = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__currentValue(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__currentValue, "currentValue", + "()Ljava/lang/Object;"); + if (_m_JsonParser__currentValue == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_JsonParser__currentValue); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__assignCurrentValue = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__assignCurrentValue(jobject self_, jobject v) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__assignCurrentValue, + "assignCurrentValue", "(Ljava/lang/Object;)V"); + if (_m_JsonParser__assignCurrentValue == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_JsonParser__assignCurrentValue, + v); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__getCurrentValue = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getCurrentValue(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getCurrentValue, "getCurrentValue", + "()Ljava/lang/Object;"); + if (_m_JsonParser__getCurrentValue == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, + _m_JsonParser__getCurrentValue); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__setCurrentValue = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__setCurrentValue(jobject self_, jobject v) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__setCurrentValue, "setCurrentValue", + "(Ljava/lang/Object;)V"); + if (_m_JsonParser__setCurrentValue == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_JsonParser__setCurrentValue, v); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__releaseBuffered = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__releaseBuffered(jobject self_, jobject out) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__releaseBuffered, "releaseBuffered", + "(Ljava/io/OutputStream;)I"); + if (_m_JsonParser__releaseBuffered == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int32_t _result = (*jniEnv)->CallIntMethod( + jniEnv, self_, _m_JsonParser__releaseBuffered, out); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__releaseBuffered1 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__releaseBuffered1(jobject self_, jobject w) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__releaseBuffered1, + "releaseBuffered", "(Ljava/io/Writer;)I"); + if (_m_JsonParser__releaseBuffered1 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int32_t _result = (*jniEnv)->CallIntMethod( + jniEnv, self_, _m_JsonParser__releaseBuffered1, w); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__enable = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__enable(jobject self_, jobject f) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__enable, "enable", + "(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/" + "jackson/core/JsonParser;"); + if (_m_JsonParser__enable == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_JsonParser__enable, f); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__disable = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__disable(jobject self_, jobject f) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__disable, "disable", + "(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/" + "jackson/core/JsonParser;"); + if (_m_JsonParser__disable == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_JsonParser__disable, f); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__configure = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__configure(jobject self_, jobject f, uint8_t state) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__configure, "configure", + "(Lcom/fasterxml/jackson/core/JsonParser$Feature;Z)Lcom/" + "fasterxml/jackson/core/JsonParser;"); + if (_m_JsonParser__configure == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonParser__configure, f, state); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__isEnabled = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__isEnabled(jobject self_, jobject f) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__isEnabled, "isEnabled", + "(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Z"); + if (_m_JsonParser__isEnabled == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = + (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_JsonParser__isEnabled, f); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__isEnabled1 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__isEnabled1(jobject self_, jobject f) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__isEnabled1, "isEnabled", + "(Lcom/fasterxml/jackson/core/StreamReadFeature;)Z"); + if (_m_JsonParser__isEnabled1 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = + (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_JsonParser__isEnabled1, f); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__getFeatureMask = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getFeatureMask(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getFeatureMask, "getFeatureMask", + "()I"); + if (_m_JsonParser__getFeatureMask == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int32_t _result = + (*jniEnv)->CallIntMethod(jniEnv, self_, _m_JsonParser__getFeatureMask); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__setFeatureMask = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__setFeatureMask(jobject self_, int32_t mask) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__setFeatureMask, "setFeatureMask", + "(I)Lcom/fasterxml/jackson/core/JsonParser;"); + if (_m_JsonParser__setFeatureMask == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonParser__setFeatureMask, mask); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__overrideStdFeatures = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__overrideStdFeatures(jobject self_, + int32_t values, + int32_t mask) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__overrideStdFeatures, + "overrideStdFeatures", + "(II)Lcom/fasterxml/jackson/core/JsonParser;"); + if (_m_JsonParser__overrideStdFeatures == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonParser__overrideStdFeatures, values, mask); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__getFormatFeatures = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getFormatFeatures(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getFormatFeatures, + "getFormatFeatures", "()I"); + if (_m_JsonParser__getFormatFeatures == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int32_t _result = + (*jniEnv)->CallIntMethod(jniEnv, self_, _m_JsonParser__getFormatFeatures); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__overrideFormatFeatures = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__overrideFormatFeatures(jobject self_, + int32_t values, + int32_t mask) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__overrideFormatFeatures, + "overrideFormatFeatures", + "(II)Lcom/fasterxml/jackson/core/JsonParser;"); + if (_m_JsonParser__overrideFormatFeatures == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonParser__overrideFormatFeatures, values, mask); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__nextToken = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__nextToken(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__nextToken, "nextToken", + "()Lcom/fasterxml/jackson/core/JsonToken;"); + if (_m_JsonParser__nextToken == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_JsonParser__nextToken); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__nextValue = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__nextValue(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__nextValue, "nextValue", + "()Lcom/fasterxml/jackson/core/JsonToken;"); + if (_m_JsonParser__nextValue == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_JsonParser__nextValue); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__nextFieldName = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__nextFieldName(jobject self_, jobject str) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__nextFieldName, "nextFieldName", + "(Lcom/fasterxml/jackson/core/SerializableString;)Z"); + if (_m_JsonParser__nextFieldName == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = (*jniEnv)->CallBooleanMethod( + jniEnv, self_, _m_JsonParser__nextFieldName, str); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__nextFieldName1 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__nextFieldName1(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__nextFieldName1, "nextFieldName", + "()Ljava/lang/String;"); + if (_m_JsonParser__nextFieldName1 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_JsonParser__nextFieldName1); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__nextTextValue = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__nextTextValue(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__nextTextValue, "nextTextValue", + "()Ljava/lang/String;"); + if (_m_JsonParser__nextTextValue == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_JsonParser__nextTextValue); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__nextIntValue = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__nextIntValue(jobject self_, int32_t defaultValue) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__nextIntValue, "nextIntValue", + "(I)I"); + if (_m_JsonParser__nextIntValue == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int32_t _result = (*jniEnv)->CallIntMethod( + jniEnv, self_, _m_JsonParser__nextIntValue, defaultValue); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__nextLongValue = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__nextLongValue(jobject self_, int64_t defaultValue) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__nextLongValue, "nextLongValue", + "(J)J"); + if (_m_JsonParser__nextLongValue == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int64_t _result = (*jniEnv)->CallLongMethod( + jniEnv, self_, _m_JsonParser__nextLongValue, defaultValue); + return (JniResult){.value = {.j = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__nextBooleanValue = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__nextBooleanValue(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__nextBooleanValue, + "nextBooleanValue", "()Ljava/lang/Boolean;"); + if (_m_JsonParser__nextBooleanValue == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonParser__nextBooleanValue); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__skipChildren = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__skipChildren(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__skipChildren, "skipChildren", + "()Lcom/fasterxml/jackson/core/JsonParser;"); + if (_m_JsonParser__skipChildren == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_JsonParser__skipChildren); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__finishToken = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__finishToken(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__finishToken, "finishToken", "()V"); + if (_m_JsonParser__finishToken == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_JsonParser__finishToken); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__currentToken = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__currentToken(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__currentToken, "currentToken", + "()Lcom/fasterxml/jackson/core/JsonToken;"); + if (_m_JsonParser__currentToken == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_JsonParser__currentToken); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__currentTokenId = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__currentTokenId(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__currentTokenId, "currentTokenId", + "()I"); + if (_m_JsonParser__currentTokenId == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int32_t _result = + (*jniEnv)->CallIntMethod(jniEnv, self_, _m_JsonParser__currentTokenId); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__getCurrentToken = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getCurrentToken(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getCurrentToken, "getCurrentToken", + "()Lcom/fasterxml/jackson/core/JsonToken;"); + if (_m_JsonParser__getCurrentToken == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, + _m_JsonParser__getCurrentToken); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__getCurrentTokenId = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getCurrentTokenId(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getCurrentTokenId, + "getCurrentTokenId", "()I"); + if (_m_JsonParser__getCurrentTokenId == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int32_t _result = + (*jniEnv)->CallIntMethod(jniEnv, self_, _m_JsonParser__getCurrentTokenId); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__hasCurrentToken = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__hasCurrentToken(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__hasCurrentToken, "hasCurrentToken", + "()Z"); + if (_m_JsonParser__hasCurrentToken == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = (*jniEnv)->CallBooleanMethod( + jniEnv, self_, _m_JsonParser__hasCurrentToken); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__hasTokenId = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__hasTokenId(jobject self_, int32_t id) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__hasTokenId, "hasTokenId", "(I)Z"); + if (_m_JsonParser__hasTokenId == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = (*jniEnv)->CallBooleanMethod(jniEnv, self_, + _m_JsonParser__hasTokenId, id); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__hasToken = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__hasToken(jobject self_, jobject t) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__hasToken, "hasToken", + "(Lcom/fasterxml/jackson/core/JsonToken;)Z"); + if (_m_JsonParser__hasToken == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = + (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_JsonParser__hasToken, t); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__isExpectedStartArrayToken = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__isExpectedStartArrayToken(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__isExpectedStartArrayToken, + "isExpectedStartArrayToken", "()Z"); + if (_m_JsonParser__isExpectedStartArrayToken == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = (*jniEnv)->CallBooleanMethod( + jniEnv, self_, _m_JsonParser__isExpectedStartArrayToken); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__isExpectedStartObjectToken = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__isExpectedStartObjectToken(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__isExpectedStartObjectToken, + "isExpectedStartObjectToken", "()Z"); + if (_m_JsonParser__isExpectedStartObjectToken == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = (*jniEnv)->CallBooleanMethod( + jniEnv, self_, _m_JsonParser__isExpectedStartObjectToken); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__isExpectedNumberIntToken = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__isExpectedNumberIntToken(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__isExpectedNumberIntToken, + "isExpectedNumberIntToken", "()Z"); + if (_m_JsonParser__isExpectedNumberIntToken == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = (*jniEnv)->CallBooleanMethod( + jniEnv, self_, _m_JsonParser__isExpectedNumberIntToken); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__isNaN = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__isNaN(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__isNaN, "isNaN", "()Z"); + if (_m_JsonParser__isNaN == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = + (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_JsonParser__isNaN); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__clearCurrentToken = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__clearCurrentToken(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__clearCurrentToken, + "clearCurrentToken", "()V"); + if (_m_JsonParser__clearCurrentToken == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_JsonParser__clearCurrentToken); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__getLastClearedToken = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getLastClearedToken(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getLastClearedToken, + "getLastClearedToken", + "()Lcom/fasterxml/jackson/core/JsonToken;"); + if (_m_JsonParser__getLastClearedToken == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonParser__getLastClearedToken); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__overrideCurrentName = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__overrideCurrentName(jobject self_, jobject name) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__overrideCurrentName, + "overrideCurrentName", "(Ljava/lang/String;)V"); + if (_m_JsonParser__overrideCurrentName == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_JsonParser__overrideCurrentName, + name); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__getCurrentName = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getCurrentName(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getCurrentName, "getCurrentName", + "()Ljava/lang/String;"); + if (_m_JsonParser__getCurrentName == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_JsonParser__getCurrentName); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__currentName = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__currentName(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__currentName, "currentName", + "()Ljava/lang/String;"); + if (_m_JsonParser__currentName == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_JsonParser__currentName); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__getText = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getText(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getText, "getText", + "()Ljava/lang/String;"); + if (_m_JsonParser__getText == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_JsonParser__getText); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__getText1 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getText1(jobject self_, jobject writer) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getText1, "getText", + "(Ljava/io/Writer;)I"); + if (_m_JsonParser__getText1 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int32_t _result = + (*jniEnv)->CallIntMethod(jniEnv, self_, _m_JsonParser__getText1, writer); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__getTextCharacters = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getTextCharacters(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getTextCharacters, + "getTextCharacters", "()[C"); + if (_m_JsonParser__getTextCharacters == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonParser__getTextCharacters); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__getTextLength = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getTextLength(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getTextLength, "getTextLength", + "()I"); + if (_m_JsonParser__getTextLength == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int32_t _result = + (*jniEnv)->CallIntMethod(jniEnv, self_, _m_JsonParser__getTextLength); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__getTextOffset = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getTextOffset(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getTextOffset, "getTextOffset", + "()I"); + if (_m_JsonParser__getTextOffset == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int32_t _result = + (*jniEnv)->CallIntMethod(jniEnv, self_, _m_JsonParser__getTextOffset); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__hasTextCharacters = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__hasTextCharacters(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__hasTextCharacters, + "hasTextCharacters", "()Z"); + if (_m_JsonParser__hasTextCharacters == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = (*jniEnv)->CallBooleanMethod( + jniEnv, self_, _m_JsonParser__hasTextCharacters); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__getNumberValue = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getNumberValue(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getNumberValue, "getNumberValue", + "()Ljava/lang/Number;"); + if (_m_JsonParser__getNumberValue == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_JsonParser__getNumberValue); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__getNumberValueExact = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getNumberValueExact(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getNumberValueExact, + "getNumberValueExact", "()Ljava/lang/Number;"); + if (_m_JsonParser__getNumberValueExact == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonParser__getNumberValueExact); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__getNumberType = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getNumberType(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getNumberType, "getNumberType", + "()Lcom/fasterxml/jackson/core/JsonParser$NumberType;"); + if (_m_JsonParser__getNumberType == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_JsonParser__getNumberType); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__getByteValue = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getByteValue(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getByteValue, "getByteValue", + "()B"); + if (_m_JsonParser__getByteValue == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int8_t _result = + (*jniEnv)->CallByteMethod(jniEnv, self_, _m_JsonParser__getByteValue); + return (JniResult){.value = {.b = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__getShortValue = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getShortValue(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getShortValue, "getShortValue", + "()S"); + if (_m_JsonParser__getShortValue == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int16_t _result = + (*jniEnv)->CallShortMethod(jniEnv, self_, _m_JsonParser__getShortValue); + return (JniResult){.value = {.s = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__getIntValue = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getIntValue(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getIntValue, "getIntValue", "()I"); + if (_m_JsonParser__getIntValue == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int32_t _result = + (*jniEnv)->CallIntMethod(jniEnv, self_, _m_JsonParser__getIntValue); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__getLongValue = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getLongValue(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getLongValue, "getLongValue", + "()J"); + if (_m_JsonParser__getLongValue == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int64_t _result = + (*jniEnv)->CallLongMethod(jniEnv, self_, _m_JsonParser__getLongValue); + return (JniResult){.value = {.j = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__getBigIntegerValue = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getBigIntegerValue(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getBigIntegerValue, + "getBigIntegerValue", "()Ljava/math/BigInteger;"); + if (_m_JsonParser__getBigIntegerValue == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonParser__getBigIntegerValue); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__getFloatValue = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getFloatValue(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getFloatValue, "getFloatValue", + "()F"); + if (_m_JsonParser__getFloatValue == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + float _result = + (*jniEnv)->CallFloatMethod(jniEnv, self_, _m_JsonParser__getFloatValue); + return (JniResult){.value = {.f = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__getDoubleValue = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getDoubleValue(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getDoubleValue, "getDoubleValue", + "()D"); + if (_m_JsonParser__getDoubleValue == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + double _result = + (*jniEnv)->CallDoubleMethod(jniEnv, self_, _m_JsonParser__getDoubleValue); + return (JniResult){.value = {.d = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__getDecimalValue = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getDecimalValue(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getDecimalValue, "getDecimalValue", + "()Ljava/math/BigDecimal;"); + if (_m_JsonParser__getDecimalValue == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, + _m_JsonParser__getDecimalValue); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__getBooleanValue = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getBooleanValue(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getBooleanValue, "getBooleanValue", + "()Z"); + if (_m_JsonParser__getBooleanValue == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = (*jniEnv)->CallBooleanMethod( + jniEnv, self_, _m_JsonParser__getBooleanValue); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__getEmbeddedObject = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getEmbeddedObject(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getEmbeddedObject, + "getEmbeddedObject", "()Ljava/lang/Object;"); + if (_m_JsonParser__getEmbeddedObject == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonParser__getEmbeddedObject); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__getBinaryValue = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getBinaryValue(jobject self_, jobject bv) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getBinaryValue, "getBinaryValue", + "(Lcom/fasterxml/jackson/core/Base64Variant;)[B"); + if (_m_JsonParser__getBinaryValue == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonParser__getBinaryValue, bv); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__getBinaryValue1 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getBinaryValue1(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getBinaryValue1, "getBinaryValue", + "()[B"); + if (_m_JsonParser__getBinaryValue1 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, + _m_JsonParser__getBinaryValue1); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__readBinaryValue = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__readBinaryValue(jobject self_, jobject out) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__readBinaryValue, "readBinaryValue", + "(Ljava/io/OutputStream;)I"); + if (_m_JsonParser__readBinaryValue == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int32_t _result = (*jniEnv)->CallIntMethod( + jniEnv, self_, _m_JsonParser__readBinaryValue, out); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__readBinaryValue1 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__readBinaryValue1(jobject self_, jobject bv, jobject out) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method( + _c_JsonParser, &_m_JsonParser__readBinaryValue1, "readBinaryValue", + "(Lcom/fasterxml/jackson/core/Base64Variant;Ljava/io/OutputStream;)I"); + if (_m_JsonParser__readBinaryValue1 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int32_t _result = (*jniEnv)->CallIntMethod( + jniEnv, self_, _m_JsonParser__readBinaryValue1, bv, out); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__getValueAsInt = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getValueAsInt(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getValueAsInt, "getValueAsInt", + "()I"); + if (_m_JsonParser__getValueAsInt == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int32_t _result = + (*jniEnv)->CallIntMethod(jniEnv, self_, _m_JsonParser__getValueAsInt); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__getValueAsInt1 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getValueAsInt1(jobject self_, int32_t def) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getValueAsInt1, "getValueAsInt", + "(I)I"); + if (_m_JsonParser__getValueAsInt1 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int32_t _result = (*jniEnv)->CallIntMethod( + jniEnv, self_, _m_JsonParser__getValueAsInt1, def); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__getValueAsLong = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getValueAsLong(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getValueAsLong, "getValueAsLong", + "()J"); + if (_m_JsonParser__getValueAsLong == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int64_t _result = + (*jniEnv)->CallLongMethod(jniEnv, self_, _m_JsonParser__getValueAsLong); + return (JniResult){.value = {.j = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__getValueAsLong1 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getValueAsLong1(jobject self_, int64_t def) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getValueAsLong1, "getValueAsLong", + "(J)J"); + if (_m_JsonParser__getValueAsLong1 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int64_t _result = (*jniEnv)->CallLongMethod( + jniEnv, self_, _m_JsonParser__getValueAsLong1, def); + return (JniResult){.value = {.j = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__getValueAsDouble = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getValueAsDouble(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getValueAsDouble, + "getValueAsDouble", "()D"); + if (_m_JsonParser__getValueAsDouble == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + double _result = (*jniEnv)->CallDoubleMethod(jniEnv, self_, + _m_JsonParser__getValueAsDouble); + return (JniResult){.value = {.d = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__getValueAsDouble1 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getValueAsDouble1(jobject self_, double def) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getValueAsDouble1, + "getValueAsDouble", "(D)D"); + if (_m_JsonParser__getValueAsDouble1 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + double _result = (*jniEnv)->CallDoubleMethod( + jniEnv, self_, _m_JsonParser__getValueAsDouble1, def); + return (JniResult){.value = {.d = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__getValueAsBoolean = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getValueAsBoolean(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getValueAsBoolean, + "getValueAsBoolean", "()Z"); + if (_m_JsonParser__getValueAsBoolean == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = (*jniEnv)->CallBooleanMethod( + jniEnv, self_, _m_JsonParser__getValueAsBoolean); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__getValueAsBoolean1 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getValueAsBoolean1(jobject self_, uint8_t def) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getValueAsBoolean1, + "getValueAsBoolean", "(Z)Z"); + if (_m_JsonParser__getValueAsBoolean1 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = (*jniEnv)->CallBooleanMethod( + jniEnv, self_, _m_JsonParser__getValueAsBoolean1, def); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__getValueAsString = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getValueAsString(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getValueAsString, + "getValueAsString", "()Ljava/lang/String;"); + if (_m_JsonParser__getValueAsString == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonParser__getValueAsString); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__getValueAsString1 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getValueAsString1(jobject self_, jobject def) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getValueAsString1, + "getValueAsString", "(Ljava/lang/String;)Ljava/lang/String;"); + if (_m_JsonParser__getValueAsString1 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonParser__getValueAsString1, def); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__canReadObjectId = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__canReadObjectId(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__canReadObjectId, "canReadObjectId", + "()Z"); + if (_m_JsonParser__canReadObjectId == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = (*jniEnv)->CallBooleanMethod( + jniEnv, self_, _m_JsonParser__canReadObjectId); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__canReadTypeId = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__canReadTypeId(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__canReadTypeId, "canReadTypeId", + "()Z"); + if (_m_JsonParser__canReadTypeId == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = + (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_JsonParser__canReadTypeId); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser__getObjectId = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getObjectId(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getObjectId, "getObjectId", + "()Ljava/lang/Object;"); + if (_m_JsonParser__getObjectId == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_JsonParser__getObjectId); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__getTypeId = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__getTypeId(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__getTypeId, "getTypeId", + "()Ljava/lang/Object;"); + if (_m_JsonParser__getTypeId == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_JsonParser__getTypeId); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__readValueAs = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__readValueAs(jobject self_, jobject valueType) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__readValueAs, "readValueAs", + "(Ljava/lang/Class;)Ljava/lang/Object;"); + if (_m_JsonParser__readValueAs == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonParser__readValueAs, valueType); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__readValueAs1 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__readValueAs1(jobject self_, jobject valueTypeRef) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method( + _c_JsonParser, &_m_JsonParser__readValueAs1, "readValueAs", + "(Lcom/fasterxml/jackson/core/type/TypeReference;)Ljava/lang/Object;"); + if (_m_JsonParser__readValueAs1 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonParser__readValueAs1, valueTypeRef); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__readValuesAs = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__readValuesAs(jobject self_, jobject valueType) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__readValuesAs, "readValuesAs", + "(Ljava/lang/Class;)Ljava/util/Iterator;"); + if (_m_JsonParser__readValuesAs == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonParser__readValuesAs, valueType); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__readValuesAs1 = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__readValuesAs1(jobject self_, jobject valueTypeRef) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method( + _c_JsonParser, &_m_JsonParser__readValuesAs1, "readValuesAs", + "(Lcom/fasterxml/jackson/core/type/TypeReference;)Ljava/util/Iterator;"); + if (_m_JsonParser__readValuesAs1 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_JsonParser__readValuesAs1, valueTypeRef); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser__readValueAsTree = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser__readValueAsTree(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser, &_m_JsonParser__readValueAsTree, "readValueAsTree", + "()Ljava/lang/Object;"); + if (_m_JsonParser__readValueAsTree == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, + _m_JsonParser__readValueAsTree); + return to_global_ref_result(_result); +} + +jfieldID _f_JsonParser__DEFAULT_READ_CAPABILITIES = NULL; +FFI_PLUGIN_EXPORT +JniResult get_JsonParser__DEFAULT_READ_CAPABILITIES() { + load_env(); + load_class_global_ref(&_c_JsonParser, + "com/fasterxml/jackson/core/JsonParser"); + if (_c_JsonParser == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_field(_c_JsonParser, &_f_JsonParser__DEFAULT_READ_CAPABILITIES, + "DEFAULT_READ_CAPABILITIES", + "Lcom/fasterxml/jackson/core/util/JacksonFeatureSet;"); + jobject _result = (*jniEnv)->GetStaticObjectField( + jniEnv, _c_JsonParser, _f_JsonParser__DEFAULT_READ_CAPABILITIES); + return to_global_ref_result(_result); +} + +// com.fasterxml.jackson.core.JsonParser$Feature +jclass _c_JsonParser_Feature = NULL; + +jmethodID _m_JsonParser_Feature__values = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser_Feature__values() { + load_env(); + load_class_global_ref(&_c_JsonParser_Feature, + "com/fasterxml/jackson/core/JsonParser$Feature"); + if (_c_JsonParser_Feature == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_JsonParser_Feature, &_m_JsonParser_Feature__values, + "values", + "()[Lcom/fasterxml/jackson/core/JsonParser$Feature;"); + if (_m_JsonParser_Feature__values == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallStaticObjectMethod( + jniEnv, _c_JsonParser_Feature, _m_JsonParser_Feature__values); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser_Feature__valueOf = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser_Feature__valueOf(jobject name) { + load_env(); + load_class_global_ref(&_c_JsonParser_Feature, + "com/fasterxml/jackson/core/JsonParser$Feature"); + if (_c_JsonParser_Feature == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_method( + _c_JsonParser_Feature, &_m_JsonParser_Feature__valueOf, "valueOf", + "(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonParser$Feature;"); + if (_m_JsonParser_Feature__valueOf == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallStaticObjectMethod( + jniEnv, _c_JsonParser_Feature, _m_JsonParser_Feature__valueOf, name); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser_Feature__collectDefaults = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser_Feature__collectDefaults() { + load_env(); + load_class_global_ref(&_c_JsonParser_Feature, + "com/fasterxml/jackson/core/JsonParser$Feature"); + if (_c_JsonParser_Feature == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_JsonParser_Feature, + &_m_JsonParser_Feature__collectDefaults, "collectDefaults", + "()I"); + if (_m_JsonParser_Feature__collectDefaults == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int32_t _result = (*jniEnv)->CallStaticIntMethod( + jniEnv, _c_JsonParser_Feature, _m_JsonParser_Feature__collectDefaults); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser_Feature__enabledByDefault = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser_Feature__enabledByDefault(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser_Feature, + "com/fasterxml/jackson/core/JsonParser$Feature"); + if (_c_JsonParser_Feature == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser_Feature, &_m_JsonParser_Feature__enabledByDefault, + "enabledByDefault", "()Z"); + if (_m_JsonParser_Feature__enabledByDefault == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = (*jniEnv)->CallBooleanMethod( + jniEnv, self_, _m_JsonParser_Feature__enabledByDefault); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser_Feature__enabledIn = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser_Feature__enabledIn(jobject self_, int32_t flags) { + load_env(); + load_class_global_ref(&_c_JsonParser_Feature, + "com/fasterxml/jackson/core/JsonParser$Feature"); + if (_c_JsonParser_Feature == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser_Feature, &_m_JsonParser_Feature__enabledIn, + "enabledIn", "(I)Z"); + if (_m_JsonParser_Feature__enabledIn == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = (*jniEnv)->CallBooleanMethod( + jniEnv, self_, _m_JsonParser_Feature__enabledIn, flags); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonParser_Feature__getMask = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser_Feature__getMask(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonParser_Feature, + "com/fasterxml/jackson/core/JsonParser$Feature"); + if (_c_JsonParser_Feature == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonParser_Feature, &_m_JsonParser_Feature__getMask, "getMask", + "()I"); + if (_m_JsonParser_Feature__getMask == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int32_t _result = + (*jniEnv)->CallIntMethod(jniEnv, self_, _m_JsonParser_Feature__getMask); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +// com.fasterxml.jackson.core.JsonParser$NumberType +jclass _c_JsonParser_NumberType = NULL; + +jmethodID _m_JsonParser_NumberType__values = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser_NumberType__values() { + load_env(); + load_class_global_ref(&_c_JsonParser_NumberType, + "com/fasterxml/jackson/core/JsonParser$NumberType"); + if (_c_JsonParser_NumberType == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_JsonParser_NumberType, + &_m_JsonParser_NumberType__values, "values", + "()[Lcom/fasterxml/jackson/core/JsonParser$NumberType;"); + if (_m_JsonParser_NumberType__values == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallStaticObjectMethod( + jniEnv, _c_JsonParser_NumberType, _m_JsonParser_NumberType__values); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonParser_NumberType__valueOf = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonParser_NumberType__valueOf(jobject name) { + load_env(); + load_class_global_ref(&_c_JsonParser_NumberType, + "com/fasterxml/jackson/core/JsonParser$NumberType"); + if (_c_JsonParser_NumberType == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_method( + _c_JsonParser_NumberType, &_m_JsonParser_NumberType__valueOf, "valueOf", + "(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonParser$NumberType;"); + if (_m_JsonParser_NumberType__valueOf == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallStaticObjectMethod( + jniEnv, _c_JsonParser_NumberType, _m_JsonParser_NumberType__valueOf, + name); + return to_global_ref_result(_result); +} + +// com.fasterxml.jackson.core.JsonToken +jclass _c_JsonToken = NULL; + +jmethodID _m_JsonToken__values = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonToken__values() { + load_env(); + load_class_global_ref(&_c_JsonToken, "com/fasterxml/jackson/core/JsonToken"); + if (_c_JsonToken == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_JsonToken, &_m_JsonToken__values, "values", + "()[Lcom/fasterxml/jackson/core/JsonToken;"); + if (_m_JsonToken__values == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_JsonToken, + _m_JsonToken__values); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonToken__valueOf = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonToken__valueOf(jobject name) { + load_env(); + load_class_global_ref(&_c_JsonToken, "com/fasterxml/jackson/core/JsonToken"); + if (_c_JsonToken == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_method( + _c_JsonToken, &_m_JsonToken__valueOf, "valueOf", + "(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonToken;"); + if (_m_JsonToken__valueOf == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallStaticObjectMethod( + jniEnv, _c_JsonToken, _m_JsonToken__valueOf, name); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonToken__id = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonToken__id(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonToken, "com/fasterxml/jackson/core/JsonToken"); + if (_c_JsonToken == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonToken, &_m_JsonToken__id, "id", "()I"); + if (_m_JsonToken__id == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_JsonToken__id); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonToken__asString = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonToken__asString(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonToken, "com/fasterxml/jackson/core/JsonToken"); + if (_c_JsonToken == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonToken, &_m_JsonToken__asString, "asString", + "()Ljava/lang/String;"); + if (_m_JsonToken__asString == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_JsonToken__asString); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonToken__asCharArray = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonToken__asCharArray(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonToken, "com/fasterxml/jackson/core/JsonToken"); + if (_c_JsonToken == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonToken, &_m_JsonToken__asCharArray, "asCharArray", "()[C"); + if (_m_JsonToken__asCharArray == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_JsonToken__asCharArray); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonToken__asByteArray = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonToken__asByteArray(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonToken, "com/fasterxml/jackson/core/JsonToken"); + if (_c_JsonToken == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonToken, &_m_JsonToken__asByteArray, "asByteArray", "()[B"); + if (_m_JsonToken__asByteArray == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_JsonToken__asByteArray); + return to_global_ref_result(_result); +} + +jmethodID _m_JsonToken__isNumeric = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonToken__isNumeric(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonToken, "com/fasterxml/jackson/core/JsonToken"); + if (_c_JsonToken == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonToken, &_m_JsonToken__isNumeric, "isNumeric", "()Z"); + if (_m_JsonToken__isNumeric == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = + (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_JsonToken__isNumeric); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonToken__isStructStart = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonToken__isStructStart(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonToken, "com/fasterxml/jackson/core/JsonToken"); + if (_c_JsonToken == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonToken, &_m_JsonToken__isStructStart, "isStructStart", + "()Z"); + if (_m_JsonToken__isStructStart == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = + (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_JsonToken__isStructStart); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonToken__isStructEnd = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonToken__isStructEnd(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonToken, "com/fasterxml/jackson/core/JsonToken"); + if (_c_JsonToken == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonToken, &_m_JsonToken__isStructEnd, "isStructEnd", "()Z"); + if (_m_JsonToken__isStructEnd == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = + (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_JsonToken__isStructEnd); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonToken__isScalarValue = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonToken__isScalarValue(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonToken, "com/fasterxml/jackson/core/JsonToken"); + if (_c_JsonToken == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonToken, &_m_JsonToken__isScalarValue, "isScalarValue", + "()Z"); + if (_m_JsonToken__isScalarValue == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = + (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_JsonToken__isScalarValue); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_JsonToken__isBoolean = NULL; +FFI_PLUGIN_EXPORT +JniResult JsonToken__isBoolean(jobject self_) { + load_env(); + load_class_global_ref(&_c_JsonToken, "com/fasterxml/jackson/core/JsonToken"); + if (_c_JsonToken == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_JsonToken, &_m_JsonToken__isBoolean, "isBoolean", "()Z"); + if (_m_JsonToken__isBoolean == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = + (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_JsonToken__isBoolean); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/_init.dart b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/_init.dart new file mode 100644 index 000000000..8018e7d3c --- /dev/null +++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/_init.dart @@ -0,0 +1,24 @@ +// Generated from jackson-core which is licensed under the Apache License 2.0. +// The following copyright from the original authors applies. +// See https://github.com/FasterXML/jackson-core/blob/2.14/LICENSE +// +// Copyright (c) 2007 - The Jackson Project Authors +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import "dart:ffi" as ffi; +import "package:jni/internal_helpers_for_jnigen.dart"; + +// Auto-generated initialization code. + +final ffi.Pointer Function(String sym) jniLookup = + ProtectedJniExtensions.initGeneratedLibrary("jackson_core"); diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart new file mode 100644 index 000000000..4389ac33f --- /dev/null +++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart @@ -0,0 +1,1994 @@ +// Generated from jackson-core which is licensed under the Apache License 2.0. +// The following copyright from the original authors applies. +// See https://github.com/FasterXML/jackson-core/blob/2.14/LICENSE +// +// Copyright (c) 2007 - The Jackson Project Authors +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Autogenerated by jnigen. DO NOT EDIT! + +// ignore_for_file: annotate_overrides +// ignore_for_file: camel_case_extensions +// ignore_for_file: camel_case_types +// ignore_for_file: constant_identifier_names +// ignore_for_file: file_names +// ignore_for_file: no_leading_underscores_for_local_identifiers +// ignore_for_file: non_constant_identifier_names +// ignore_for_file: overridden_fields +// ignore_for_file: unnecessary_cast +// ignore_for_file: unused_element +// ignore_for_file: unused_field +// ignore_for_file: unused_import +// ignore_for_file: unused_shown_name + +import "dart:isolate" show ReceivePort; +import "dart:ffi" as ffi; +import "package:jni/internal_helpers_for_jnigen.dart"; +import "package:jni/jni.dart" as jni; + +import "JsonParser.dart" as jsonparser_; +import "../../../../_init.dart"; + +/// from: com.fasterxml.jackson.core.JsonFactory +/// +/// The main factory class of Jackson package, used to configure and +/// construct reader (aka parser, JsonParser) +/// and writer (aka generator, JsonGenerator) +/// instances. +/// +/// Factory instances are thread-safe and reusable after configuration +/// (if any). Typically applications and services use only a single +/// globally shared factory instance, unless they need differently +/// configured factories. Factory reuse is important if efficiency matters; +/// most recycling of expensive construct is done on per-factory basis. +/// +/// Creation of a factory instance is a light-weight operation, +/// and since there is no need for pluggable alternative implementations +/// (as there is no "standard" JSON processor API to implement), +/// the default constructor is used for constructing factory +/// instances. +///@author Tatu Saloranta +class JsonFactory extends jni.JObject { + @override + late final jni.JObjType $type = type; + + JsonFactory.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = $JsonFactoryType(); + + /// from: static public final java.lang.String FORMAT_NAME_JSON + /// + /// Name used to identify JSON format + /// (and returned by \#getFormatName() + static const FORMAT_NAME_JSON = r"""JSON"""; + + static final _get_DEFAULT_FACTORY_FEATURE_FLAGS = + jniLookup>( + "get_JsonFactory__DEFAULT_FACTORY_FEATURE_FLAGS") + .asFunction(); + + /// from: static protected final int DEFAULT_FACTORY_FEATURE_FLAGS + /// + /// Bitfield (set of flags) of all factory features that are enabled by default. + static int get DEFAULT_FACTORY_FEATURE_FLAGS => + _get_DEFAULT_FACTORY_FEATURE_FLAGS().integer; + + static final _get_DEFAULT_PARSER_FEATURE_FLAGS = + jniLookup>( + "get_JsonFactory__DEFAULT_PARSER_FEATURE_FLAGS") + .asFunction(); + + /// from: static protected final int DEFAULT_PARSER_FEATURE_FLAGS + /// + /// Bitfield (set of flags) of all parser features that are enabled + /// by default. + static int get DEFAULT_PARSER_FEATURE_FLAGS => + _get_DEFAULT_PARSER_FEATURE_FLAGS().integer; + + static final _get_DEFAULT_GENERATOR_FEATURE_FLAGS = + jniLookup>( + "get_JsonFactory__DEFAULT_GENERATOR_FEATURE_FLAGS") + .asFunction(); + + /// from: static protected final int DEFAULT_GENERATOR_FEATURE_FLAGS + /// + /// Bitfield (set of flags) of all generator features that are enabled + /// by default. + static int get DEFAULT_GENERATOR_FEATURE_FLAGS => + _get_DEFAULT_GENERATOR_FEATURE_FLAGS().integer; + + static final _get_DEFAULT_ROOT_VALUE_SEPARATOR = + jniLookup>( + "get_JsonFactory__DEFAULT_ROOT_VALUE_SEPARATOR") + .asFunction(); + + /// from: static public final com.fasterxml.jackson.core.SerializableString DEFAULT_ROOT_VALUE_SEPARATOR + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JObject get DEFAULT_ROOT_VALUE_SEPARATOR => const jni.JObjectType() + .fromRef(_get_DEFAULT_ROOT_VALUE_SEPARATOR().object); + + static final _ctor = jniLookup>( + "JsonFactory__ctor") + .asFunction(); + + /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Default constructor used to create factory instances. + /// Creation of a factory instance is a light-weight operation, + /// but it is still a good idea to reuse limited number of + /// factory instances (and quite often just a single instance): + /// factories are used as context for storing some reused + /// processing objects (such as symbol tables parsers use) + /// and this reuse only works within context of a single + /// factory instance. + factory JsonFactory() { + return JsonFactory.fromRef(_ctor().object); + } + + static final _ctor1 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonFactory__ctor1") + .asFunction)>(); + + /// from: public void (com.fasterxml.jackson.core.ObjectCodec oc) + /// The returned object must be deleted after use, by calling the `delete` method. + factory JsonFactory.ctor1( + jni.JObject oc, + ) { + return JsonFactory.fromRef(_ctor1(oc.reference).object); + } + + static final _ctor2 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__ctor2") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: protected void (com.fasterxml.jackson.core.JsonFactory src, com.fasterxml.jackson.core.ObjectCodec codec) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Constructor used when copy()ing a factory instance. + ///@param src Original factory to copy settings from + ///@param codec Databinding-level codec to use, if any + ///@since 2.2.1 + factory JsonFactory.ctor2( + JsonFactory src, + jni.JObject codec, + ) { + return JsonFactory.fromRef(_ctor2(src.reference, codec.reference).object); + } + + static final _ctor3 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonFactory__ctor3") + .asFunction)>(); + + /// from: public void (com.fasterxml.jackson.core.JsonFactoryBuilder b) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Constructor used by JsonFactoryBuilder for instantiation. + ///@param b Builder that contains settings to use + ///@since 2.10 + factory JsonFactory.ctor3( + jni.JObject b, + ) { + return JsonFactory.fromRef(_ctor3(b.reference).object); + } + + static final _ctor4 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Uint8)>>("JsonFactory__ctor4") + .asFunction, int)>(); + + /// from: protected void (com.fasterxml.jackson.core.TSFBuilder b, boolean bogus) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Constructor for subtypes; needed to work around the fact that before 3.0, + /// this factory has cumbersome dual role as generic type as well as actual + /// implementation for json. + ///@param b Builder that contains settings to use + ///@param bogus Argument only needed to separate constructor signature; ignored + factory JsonFactory.ctor4( + jni.JObject b, + bool bogus, + ) { + return JsonFactory.fromRef(_ctor4(b.reference, bogus ? 1 : 0).object); + } + + static final _rebuild = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonFactory__rebuild") + .asFunction)>(); + + /// from: public com.fasterxml.jackson.core.TSFBuilder rebuild() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that allows construction of differently configured factory, starting + /// with settings of this factory. + ///@return Builder instance to use + ///@since 2.10 + jni.JObject rebuild() { + return const jni.JObjectType().fromRef(_rebuild(reference).object); + } + + static final _builder = + jniLookup>( + "JsonFactory__builder") + .asFunction(); + + /// from: static public com.fasterxml.jackson.core.TSFBuilder builder() + /// The returned object must be deleted after use, by calling the `delete` 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. + ///@return Builder instance to use + static jni.JObject builder() { + return const jni.JObjectType().fromRef(_builder().object); + } + + static final _copy = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonFactory__copy") + .asFunction)>(); + + /// from: public com.fasterxml.jackson.core.JsonFactory copy() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing a new JsonFactory that has + /// the same settings as this instance, but is otherwise + /// independent (i.e. nothing is actually shared, symbol tables + /// are separate). + /// Note that ObjectCodec reference is not copied but is + /// set to null; caller typically needs to set it after calling + /// this method. Reason for this is that the codec is used for + /// callbacks, and assumption is that there is strict 1-to-1 + /// mapping between codec, factory. Caller has to, then, explicitly + /// set codec after making the copy. + ///@return Copy of this factory instance + ///@since 2.1 + JsonFactory copy() { + return const $JsonFactoryType().fromRef(_copy(reference).object); + } + + static final _readResolve = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonFactory__readResolve") + .asFunction)>(); + + /// from: protected java.lang.Object readResolve() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that we need to override to actually make restoration go + /// through constructors etc: needed to allow JDK serializability of + /// factory instances. + /// + /// Note: must be overridden by sub-classes as well. + ///@return Newly constructed instance + jni.JObject readResolve() { + return const jni.JObjectType().fromRef(_readResolve(reference).object); + } + + static final _requiresPropertyOrdering = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>( + "JsonFactory__requiresPropertyOrdering") + .asFunction)>(); + + /// from: public boolean requiresPropertyOrdering() + /// + /// Introspection method that higher-level functionality may call + /// to see whether underlying data format requires a stable ordering + /// of object properties or not. + /// This is usually used for determining + /// whether to force a stable ordering (like alphabetic ordering by name) + /// if no ordering if explicitly specified. + /// + /// Default implementation returns false as JSON does NOT + /// require stable ordering. Formats that require ordering include positional + /// textual formats like CSV, and schema-based binary formats + /// like Avro. + ///@return Whether format supported by this factory + /// requires Object properties to be ordered. + ///@since 2.3 + bool requiresPropertyOrdering() { + return _requiresPropertyOrdering(reference).boolean; + } + + static final _canHandleBinaryNatively = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>( + "JsonFactory__canHandleBinaryNatively") + .asFunction)>(); + + /// from: public boolean canHandleBinaryNatively() + /// + /// Introspection method that higher-level functionality may call + /// to see whether underlying data format can read and write binary + /// data natively; that is, embeded it as-is without using encodings + /// such as Base64. + /// + /// Default implementation returns false as JSON does not + /// support native access: all binary content must use Base64 encoding. + /// Most binary formats (like Smile and Avro) support native binary content. + ///@return Whether format supported by this factory + /// supports native binary content + ///@since 2.3 + bool canHandleBinaryNatively() { + return _canHandleBinaryNatively(reference).boolean; + } + + static final _canUseCharArrays = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonFactory__canUseCharArrays") + .asFunction)>(); + + /// from: public boolean canUseCharArrays() + /// + /// Introspection method that can be used by base factory to check + /// whether access using char[] is something that actual + /// parser implementations can take advantage of, over having to + /// use java.io.Reader. Sub-types are expected to override + /// definition; default implementation (suitable for JSON) alleges + /// that optimization are possible; and thereby is likely to try + /// to access java.lang.String content by first copying it into + /// recyclable intermediate buffer. + ///@return Whether access to decoded textual content can be efficiently + /// accessed using parser method {@code getTextCharacters()}. + ///@since 2.4 + bool canUseCharArrays() { + return _canUseCharArrays(reference).boolean; + } + + static final _canParseAsync = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonFactory__canParseAsync") + .asFunction)>(); + + /// from: public boolean canParseAsync() + /// + /// Introspection method that can be used to check whether this + /// factory can create non-blocking parsers: parsers that do not + /// use blocking I/O abstractions but instead use a + /// com.fasterxml.jackson.core.async.NonBlockingInputFeeder. + ///@return Whether this factory supports non-blocking ("async") parsing or + /// not (and consequently whether {@code createNonBlockingXxx()} method(s) work) + ///@since 2.9 + bool canParseAsync() { + return _canParseAsync(reference).boolean; + } + + static final _getFormatReadFeatureType = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>( + "JsonFactory__getFormatReadFeatureType") + .asFunction)>(); + + /// from: public java.lang.Class getFormatReadFeatureType() + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JObject getFormatReadFeatureType() { + return const jni.JObjectType() + .fromRef(_getFormatReadFeatureType(reference).object); + } + + static final _getFormatWriteFeatureType = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>( + "JsonFactory__getFormatWriteFeatureType") + .asFunction)>(); + + /// from: public java.lang.Class getFormatWriteFeatureType() + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JObject getFormatWriteFeatureType() { + return const jni.JObjectType() + .fromRef(_getFormatWriteFeatureType(reference).object); + } + + static final _canUseSchema = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__canUseSchema") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public boolean canUseSchema(com.fasterxml.jackson.core.FormatSchema schema) + /// + /// Method that can be used to quickly check whether given schema + /// is something that parsers and/or generators constructed by this + /// factory could use. Note that this means possible use, at the level + /// of data format (i.e. schema is for same data format as parsers and + /// generators this factory constructs); individual schema instances + /// may have further usage restrictions. + ///@param schema Schema instance to check + ///@return Whether parsers and generators constructed by this factory + /// can use specified format schema instance + bool canUseSchema( + jni.JObject schema, + ) { + return _canUseSchema(reference, schema.reference).boolean; + } + + static final _getFormatName = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonFactory__getFormatName") + .asFunction)>(); + + /// from: public java.lang.String getFormatName() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that returns short textual id identifying format + /// this factory supports. + /// + /// Note: sub-classes should override this method; default + /// implementation will return null for all sub-classes + ///@return Name of the format handled by parsers, generators this factory creates + jni.JString getFormatName() { + return const jni.JStringType().fromRef(_getFormatName(reference).object); + } + + static final _hasFormat = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__hasFormat") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.format.MatchStrength hasFormat(com.fasterxml.jackson.core.format.InputAccessor acc) + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JObject hasFormat( + jni.JObject acc, + ) { + return const jni.JObjectType() + .fromRef(_hasFormat(reference, acc.reference).object); + } + + static final _requiresCustomCodec = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonFactory__requiresCustomCodec") + .asFunction)>(); + + /// from: public boolean requiresCustomCodec() + /// + /// Method that can be called to determine if a custom + /// ObjectCodec is needed for binding data parsed + /// using JsonParser constructed by this factory + /// (which typically also implies the same for serialization + /// with JsonGenerator). + ///@return True if custom codec is needed with parsers and + /// generators created by this factory; false if a general + /// ObjectCodec is enough + ///@since 2.1 + bool requiresCustomCodec() { + return _requiresCustomCodec(reference).boolean; + } + + static final _hasJSONFormat = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__hasJSONFormat") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: protected com.fasterxml.jackson.core.format.MatchStrength hasJSONFormat(com.fasterxml.jackson.core.format.InputAccessor acc) + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JObject hasJSONFormat( + jni.JObject acc, + ) { + return const jni.JObjectType() + .fromRef(_hasJSONFormat(reference, acc.reference).object); + } + + static final _version = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonFactory__version") + .asFunction)>(); + + /// from: public com.fasterxml.jackson.core.Version version() + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JObject version() { + return const jni.JObjectType().fromRef(_version(reference).object); + } + + static final _configure = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer, ffi.Uint8)>>("JsonFactory__configure") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer, int)>(); + + /// from: public final com.fasterxml.jackson.core.JsonFactory configure(com.fasterxml.jackson.core.JsonFactory.Feature f, boolean state) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for enabling or disabling specified parser feature + /// (check JsonParser.Feature for list of features) + ///@param f Feature to enable/disable + ///@param state Whether to enable or disable the feature + ///@return This factory instance (to allow call chaining) + ///@deprecated since 2.10 use JsonFactoryBuilder\#configure(JsonFactory.Feature, boolean) instead + JsonFactory configure( + JsonFactory_Feature f, + bool state, + ) { + return const $JsonFactoryType() + .fromRef(_configure(reference, f.reference, state ? 1 : 0).object); + } + + static final _enable = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__enable") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonFactory enable(com.fasterxml.jackson.core.JsonFactory.Feature f) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for enabling specified parser feature + /// (check JsonFactory.Feature for list of features) + ///@param f Feature to enable + ///@return This factory instance (to allow call chaining) + ///@deprecated since 2.10 use JsonFactoryBuilder\#configure(JsonFactory.Feature, boolean) instead + JsonFactory enable( + JsonFactory_Feature f, + ) { + return const $JsonFactoryType() + .fromRef(_enable(reference, f.reference).object); + } + + static final _disable = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__disable") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonFactory disable(com.fasterxml.jackson.core.JsonFactory.Feature f) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for disabling specified parser features + /// (check JsonFactory.Feature for list of features) + ///@param f Feature to disable + ///@return This factory instance (to allow call chaining) + ///@deprecated since 2.10 use JsonFactoryBuilder\#configure(JsonFactory.Feature, boolean) instead + JsonFactory disable( + JsonFactory_Feature f, + ) { + return const $JsonFactoryType() + .fromRef(_disable(reference, f.reference).object); + } + + static final _isEnabled = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__isEnabled") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public final boolean isEnabled(com.fasterxml.jackson.core.JsonFactory.Feature f) + /// + /// Checked whether specified parser feature is enabled. + ///@param f Feature to check + ///@return True if the specified feature is enabled + bool isEnabled( + JsonFactory_Feature f, + ) { + return _isEnabled(reference, f.reference).boolean; + } + + static final _getParserFeatures = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonFactory__getParserFeatures") + .asFunction)>(); + + /// from: public final int getParserFeatures() + int getParserFeatures() { + return _getParserFeatures(reference).integer; + } + + static final _getGeneratorFeatures = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonFactory__getGeneratorFeatures") + .asFunction)>(); + + /// from: public final int getGeneratorFeatures() + int getGeneratorFeatures() { + return _getGeneratorFeatures(reference).integer; + } + + static final _getFormatParserFeatures = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>( + "JsonFactory__getFormatParserFeatures") + .asFunction)>(); + + /// from: public int getFormatParserFeatures() + int getFormatParserFeatures() { + return _getFormatParserFeatures(reference).integer; + } + + static final _getFormatGeneratorFeatures = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>( + "JsonFactory__getFormatGeneratorFeatures") + .asFunction)>(); + + /// from: public int getFormatGeneratorFeatures() + int getFormatGeneratorFeatures() { + return _getFormatGeneratorFeatures(reference).integer; + } + + static final _configure1 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer, ffi.Uint8)>>("JsonFactory__configure1") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer, int)>(); + + /// from: public final com.fasterxml.jackson.core.JsonFactory configure(com.fasterxml.jackson.core.JsonParser.Feature f, boolean state) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for enabling or disabling specified parser feature + /// (check JsonParser.Feature for list of features) + ///@param f Feature to enable/disable + ///@param state Whether to enable or disable the feature + ///@return This factory instance (to allow call chaining) + JsonFactory configure1( + jsonparser_.JsonParser_Feature f, + bool state, + ) { + return const $JsonFactoryType() + .fromRef(_configure1(reference, f.reference, state ? 1 : 0).object); + } + + static final _enable1 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__enable1") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonFactory enable(com.fasterxml.jackson.core.JsonParser.Feature f) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for enabling specified parser feature + /// (check JsonParser.Feature for list of features) + ///@param f Feature to enable + ///@return This factory instance (to allow call chaining) + JsonFactory enable1( + jsonparser_.JsonParser_Feature f, + ) { + return const $JsonFactoryType() + .fromRef(_enable1(reference, f.reference).object); + } + + static final _disable1 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__disable1") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonFactory disable(com.fasterxml.jackson.core.JsonParser.Feature f) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for disabling specified parser features + /// (check JsonParser.Feature for list of features) + ///@param f Feature to disable + ///@return This factory instance (to allow call chaining) + JsonFactory disable1( + jsonparser_.JsonParser_Feature f, + ) { + return const $JsonFactoryType() + .fromRef(_disable1(reference, f.reference).object); + } + + static final _isEnabled1 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__isEnabled1") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public final boolean isEnabled(com.fasterxml.jackson.core.JsonParser.Feature f) + /// + /// Method for checking if the specified parser feature is enabled. + ///@param f Feature to check + ///@return True if specified feature is enabled + bool isEnabled1( + jsonparser_.JsonParser_Feature f, + ) { + return _isEnabled1(reference, f.reference).boolean; + } + + static final _isEnabled2 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__isEnabled2") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public final boolean isEnabled(com.fasterxml.jackson.core.StreamReadFeature f) + /// + /// Method for checking if the specified stream read feature is enabled. + ///@param f Feature to check + ///@return True if specified feature is enabled + ///@since 2.10 + bool isEnabled2( + jni.JObject f, + ) { + return _isEnabled2(reference, f.reference).boolean; + } + + static final _getInputDecorator = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonFactory__getInputDecorator") + .asFunction)>(); + + /// from: public com.fasterxml.jackson.core.io.InputDecorator getInputDecorator() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for getting currently configured input decorator (if any; + /// there is no default decorator). + ///@return InputDecorator configured, if any + jni.JObject getInputDecorator() { + return const jni.JObjectType() + .fromRef(_getInputDecorator(reference).object); + } + + static final _setInputDecorator = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__setInputDecorator") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonFactory setInputDecorator(com.fasterxml.jackson.core.io.InputDecorator d) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for overriding currently configured input decorator + ///@param d Decorator to configure for this factory, if any ({@code null} if none) + ///@return This factory instance (to allow call chaining) + ///@deprecated Since 2.10 use JsonFactoryBuilder\#inputDecorator(InputDecorator) instead + JsonFactory setInputDecorator( + jni.JObject d, + ) { + return const $JsonFactoryType() + .fromRef(_setInputDecorator(reference, d.reference).object); + } + + static final _configure2 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer, ffi.Uint8)>>("JsonFactory__configure2") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer, int)>(); + + /// from: public final com.fasterxml.jackson.core.JsonFactory configure(com.fasterxml.jackson.core.JsonGenerator.Feature f, boolean state) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for enabling or disabling specified generator feature + /// (check JsonGenerator.Feature for list of features) + ///@param f Feature to enable/disable + ///@param state Whether to enable or disable the feature + ///@return This factory instance (to allow call chaining) + JsonFactory configure2( + jni.JObject f, + bool state, + ) { + return const $JsonFactoryType() + .fromRef(_configure2(reference, f.reference, state ? 1 : 0).object); + } + + static final _enable2 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__enable2") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonFactory enable(com.fasterxml.jackson.core.JsonGenerator.Feature f) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for enabling specified generator features + /// (check JsonGenerator.Feature for list of features) + ///@param f Feature to enable + ///@return This factory instance (to allow call chaining) + JsonFactory enable2( + jni.JObject f, + ) { + return const $JsonFactoryType() + .fromRef(_enable2(reference, f.reference).object); + } + + static final _disable2 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__disable2") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonFactory disable(com.fasterxml.jackson.core.JsonGenerator.Feature f) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for disabling specified generator feature + /// (check JsonGenerator.Feature for list of features) + ///@param f Feature to disable + ///@return This factory instance (to allow call chaining) + JsonFactory disable2( + jni.JObject f, + ) { + return const $JsonFactoryType() + .fromRef(_disable2(reference, f.reference).object); + } + + static final _isEnabled3 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__isEnabled3") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public final boolean isEnabled(com.fasterxml.jackson.core.JsonGenerator.Feature f) + /// + /// Check whether specified generator feature is enabled. + ///@param f Feature to check + ///@return Whether specified feature is enabled + bool isEnabled3( + jni.JObject f, + ) { + return _isEnabled3(reference, f.reference).boolean; + } + + static final _isEnabled4 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__isEnabled4") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public final boolean isEnabled(com.fasterxml.jackson.core.StreamWriteFeature f) + /// + /// Check whether specified stream write feature is enabled. + ///@param f Feature to check + ///@return Whether specified feature is enabled + ///@since 2.10 + bool isEnabled4( + jni.JObject f, + ) { + return _isEnabled4(reference, f.reference).boolean; + } + + static final _getCharacterEscapes = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonFactory__getCharacterEscapes") + .asFunction)>(); + + /// from: public com.fasterxml.jackson.core.io.CharacterEscapes getCharacterEscapes() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for accessing custom escapes factory uses for JsonGenerators + /// it creates. + ///@return Configured {@code CharacterEscapes}, if any; {@code null} if none + jni.JObject getCharacterEscapes() { + return const jni.JObjectType() + .fromRef(_getCharacterEscapes(reference).object); + } + + static final _setCharacterEscapes = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__setCharacterEscapes") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonFactory setCharacterEscapes(com.fasterxml.jackson.core.io.CharacterEscapes esc) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for defining custom escapes factory uses for JsonGenerators + /// it creates. + ///@param esc CharaterEscapes to set (or {@code null} for "none") + ///@return This factory instance (to allow call chaining) + JsonFactory setCharacterEscapes( + jni.JObject esc, + ) { + return const $JsonFactoryType() + .fromRef(_setCharacterEscapes(reference, esc.reference).object); + } + + static final _getOutputDecorator = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonFactory__getOutputDecorator") + .asFunction)>(); + + /// from: public com.fasterxml.jackson.core.io.OutputDecorator getOutputDecorator() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for getting currently configured output decorator (if any; + /// there is no default decorator). + ///@return OutputDecorator configured for generators factory creates, if any; + /// {@code null} if none. + jni.JObject getOutputDecorator() { + return const jni.JObjectType() + .fromRef(_getOutputDecorator(reference).object); + } + + static final _setOutputDecorator = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__setOutputDecorator") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonFactory setOutputDecorator(com.fasterxml.jackson.core.io.OutputDecorator d) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for overriding currently configured output decorator + ///@return This factory instance (to allow call chaining) + ///@param d Output decorator to use, if any + ///@deprecated Since 2.10 use JsonFactoryBuilder\#outputDecorator(OutputDecorator) instead + JsonFactory setOutputDecorator( + jni.JObject d, + ) { + return const $JsonFactoryType() + .fromRef(_setOutputDecorator(reference, d.reference).object); + } + + static final _setRootValueSeparator = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__setRootValueSeparator") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonFactory setRootValueSeparator(java.lang.String sep) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that allows overriding String used for separating root-level + /// JSON values (default is single space character) + ///@param sep Separator to use, if any; null means that no separator is + /// automatically added + ///@return This factory instance (to allow call chaining) + JsonFactory setRootValueSeparator( + jni.JString sep, + ) { + return const $JsonFactoryType() + .fromRef(_setRootValueSeparator(reference, sep.reference).object); + } + + static final _getRootValueSeparator = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonFactory__getRootValueSeparator") + .asFunction)>(); + + /// from: public java.lang.String getRootValueSeparator() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// @return Root value separator configured, if any + jni.JString getRootValueSeparator() { + return const jni.JStringType() + .fromRef(_getRootValueSeparator(reference).object); + } + + static final _setCodec = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__setCodec") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonFactory setCodec(com.fasterxml.jackson.core.ObjectCodec oc) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for associating a ObjectCodec (typically + /// a com.fasterxml.jackson.databind.ObjectMapper) + /// with this factory (and more importantly, parsers and generators + /// it constructs). This is needed to use data-binding methods + /// of JsonParser and JsonGenerator instances. + ///@param oc Codec to use + ///@return This factory instance (to allow call chaining) + JsonFactory setCodec( + jni.JObject oc, + ) { + return const $JsonFactoryType() + .fromRef(_setCodec(reference, oc.reference).object); + } + + static final _getCodec = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonFactory__getCodec") + .asFunction)>(); + + /// from: public com.fasterxml.jackson.core.ObjectCodec getCodec() + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JObject getCodec() { + return const jni.JObjectType().fromRef(_getCodec(reference).object); + } + + static final _createParser = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__createParser") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.io.File f) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing JSON parser instance to parse + /// contents of specified file. + /// + /// + /// Encoding is auto-detected from contents according to JSON + /// specification recommended mechanism. Json specification + /// supports only UTF-8, UTF-16 and UTF-32 as valid encodings, + /// so auto-detection implemented only for this charsets. + /// For other charsets use \#createParser(java.io.Reader). + /// + /// + /// Underlying input stream (needed for reading contents) + /// will be __owned__ (and managed, i.e. closed as need be) by + /// the parser, since caller has no access to it. + ///@param f File that contains JSON content to parse + ///@since 2.1 + jsonparser_.JsonParser createParser( + jni.JObject f, + ) { + return const jsonparser_.$JsonParserType() + .fromRef(_createParser(reference, f.reference).object); + } + + static final _createParser1 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__createParser1") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.net.URL url) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing JSON parser instance to parse + /// contents of resource reference by given URL. + /// + /// Encoding is auto-detected from contents according to JSON + /// specification recommended mechanism. Json specification + /// supports only UTF-8, UTF-16 and UTF-32 as valid encodings, + /// so auto-detection implemented only for this charsets. + /// For other charsets use \#createParser(java.io.Reader). + /// + /// Underlying input stream (needed for reading contents) + /// will be __owned__ (and managed, i.e. closed as need be) by + /// the parser, since caller has no access to it. + ///@param url URL pointing to resource that contains JSON content to parse + ///@since 2.1 + jsonparser_.JsonParser createParser1( + jni.JObject url, + ) { + return const jsonparser_.$JsonParserType() + .fromRef(_createParser1(reference, url.reference).object); + } + + static final _createParser2 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__createParser2") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.io.InputStream in) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing JSON parser instance to parse + /// the contents accessed via specified input stream. + /// + /// The input stream will __not be owned__ by + /// the parser, it will still be managed (i.e. closed if + /// end-of-stream is reacher, or parser close method called) + /// if (and only if) com.fasterxml.jackson.core.StreamReadFeature\#AUTO_CLOSE_SOURCE + /// is enabled. + /// + /// + /// Note: no encoding argument is taken since it can always be + /// auto-detected as suggested by JSON RFC. Json specification + /// supports only UTF-8, UTF-16 and UTF-32 as valid encodings, + /// so auto-detection implemented only for this charsets. + /// For other charsets use \#createParser(java.io.Reader). + ///@param in InputStream to use for reading JSON content to parse + ///@since 2.1 + jsonparser_.JsonParser createParser2( + jni.JObject in0, + ) { + return const jsonparser_.$JsonParserType() + .fromRef(_createParser2(reference, in0.reference).object); + } + + static final _createParser3 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__createParser3") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.io.Reader r) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing parser for parsing + /// the contents accessed via specified Reader. + /// + /// The read stream will __not be owned__ by + /// the parser, it will still be managed (i.e. closed if + /// end-of-stream is reacher, or parser close method called) + /// if (and only if) com.fasterxml.jackson.core.StreamReadFeature\#AUTO_CLOSE_SOURCE + /// is enabled. + ///@param r Reader to use for reading JSON content to parse + ///@since 2.1 + jsonparser_.JsonParser createParser3( + jni.JObject r, + ) { + return const jsonparser_.$JsonParserType() + .fromRef(_createParser3(reference, r.reference).object); + } + + static final _createParser4 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__createParser4") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser createParser(byte[] data) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing parser for parsing + /// the contents of given byte array. + ///@since 2.1 + jsonparser_.JsonParser createParser4( + jni.JArray data, + ) { + return const jsonparser_.$JsonParserType() + .fromRef(_createParser4(reference, data.reference).object); + } + + static final _createParser5 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int32, + ffi.Int32)>>("JsonFactory__createParser5") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer, int, int)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser createParser(byte[] data, int offset, int len) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing parser for parsing + /// the contents of given byte array. + ///@param data Buffer that contains data to parse + ///@param offset Offset of the first data byte within buffer + ///@param len Length of contents to parse within buffer + ///@since 2.1 + jsonparser_.JsonParser createParser5( + jni.JArray data, + int offset, + int len, + ) { + return const jsonparser_.$JsonParserType() + .fromRef(_createParser5(reference, data.reference, offset, len).object); + } + + static final _createParser6 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__createParser6") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.lang.String content) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing parser for parsing + /// contents of given String. + ///@since 2.1 + jsonparser_.JsonParser createParser6( + jni.JString content, + ) { + return const jsonparser_.$JsonParserType() + .fromRef(_createParser6(reference, content.reference).object); + } + + static final _createParser7 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__createParser7") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser createParser(char[] content) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing parser for parsing + /// contents of given char array. + ///@since 2.4 + jsonparser_.JsonParser createParser7( + jni.JArray content, + ) { + return const jsonparser_.$JsonParserType() + .fromRef(_createParser7(reference, content.reference).object); + } + + static final _createParser8 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int32, + ffi.Int32)>>("JsonFactory__createParser8") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer, int, int)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser createParser(char[] content, int offset, int len) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing parser for parsing contents of given char array. + ///@since 2.4 + jsonparser_.JsonParser createParser8( + jni.JArray content, + int offset, + int len, + ) { + return const jsonparser_.$JsonParserType().fromRef( + _createParser8(reference, content.reference, offset, len).object); + } + + static final _createParser9 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__createParser9") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.io.DataInput in) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Optional method for constructing parser for reading contents from specified DataInput + /// instance. + /// + /// If this factory does not support DataInput as source, + /// will throw UnsupportedOperationException + ///@since 2.8 + jsonparser_.JsonParser createParser9( + jni.JObject in0, + ) { + return const jsonparser_.$JsonParserType() + .fromRef(_createParser9(reference, in0.reference).object); + } + + static final _createNonBlockingByteArrayParser = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>( + "JsonFactory__createNonBlockingByteArrayParser") + .asFunction)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser createNonBlockingByteArrayParser() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Optional method for constructing parser for non-blocking parsing + /// via com.fasterxml.jackson.core.async.ByteArrayFeeder + /// interface (accessed using JsonParser\#getNonBlockingInputFeeder() + /// from constructed instance). + /// + /// If this factory does not support non-blocking parsing (either at all, + /// or from byte array), + /// will throw UnsupportedOperationException. + /// + /// Note that JSON-backed factory only supports parsing of UTF-8 encoded JSON content + /// (and US-ASCII since it is proper subset); other encodings are not supported + /// at this point. + ///@since 2.9 + jsonparser_.JsonParser createNonBlockingByteArrayParser() { + return const jsonparser_.$JsonParserType() + .fromRef(_createNonBlockingByteArrayParser(reference).object); + } + + static final _createGenerator = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>("JsonFactory__createGenerator") + .asFunction< + jni.JniResult Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.OutputStream out, com.fasterxml.jackson.core.JsonEncoding enc) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing JSON generator for writing JSON content + /// using specified output stream. + /// Encoding to use must be specified, and needs to be one of available + /// types (as per JSON specification). + /// + /// Underlying stream __is NOT owned__ by the generator constructed, + /// so that generator will NOT close the output stream when + /// JsonGenerator\#close is called (unless auto-closing + /// feature, + /// com.fasterxml.jackson.core.JsonGenerator.Feature\#AUTO_CLOSE_TARGET + /// is enabled). + /// Using application needs to close it explicitly if this is the case. + /// + /// Note: there are formats that use fixed encoding (like most binary data formats) + /// and that ignore passed in encoding. + ///@param out OutputStream to use for writing JSON content + ///@param enc Character encoding to use + ///@since 2.1 + jni.JObject createGenerator( + jni.JObject out, + jni.JObject enc, + ) { + return const jni.JObjectType().fromRef( + _createGenerator(reference, out.reference, enc.reference).object); + } + + static final _createGenerator1 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__createGenerator1") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.OutputStream out) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Convenience method for constructing generator that uses default + /// encoding of the format (UTF-8 for JSON and most other data formats). + /// + /// Note: there are formats that use fixed encoding (like most binary data formats). + ///@since 2.1 + jni.JObject createGenerator1( + jni.JObject out, + ) { + return const jni.JObjectType() + .fromRef(_createGenerator1(reference, out.reference).object); + } + + static final _createGenerator2 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__createGenerator2") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.Writer w) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing JSON generator for writing JSON content + /// using specified Writer. + /// + /// Underlying stream __is NOT owned__ by the generator constructed, + /// so that generator will NOT close the Reader when + /// JsonGenerator\#close is called (unless auto-closing + /// feature, + /// com.fasterxml.jackson.core.JsonGenerator.Feature\#AUTO_CLOSE_TARGET is enabled). + /// Using application needs to close it explicitly. + ///@since 2.1 + ///@param w Writer to use for writing JSON content + jni.JObject createGenerator2( + jni.JObject w, + ) { + return const jni.JObjectType() + .fromRef(_createGenerator2(reference, w.reference).object); + } + + static final _createGenerator3 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>("JsonFactory__createGenerator3") + .asFunction< + jni.JniResult Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.File f, com.fasterxml.jackson.core.JsonEncoding enc) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing JSON generator for writing JSON content + /// to specified file, overwriting contents it might have (or creating + /// it if such file does not yet exist). + /// Encoding to use must be specified, and needs to be one of available + /// types (as per JSON specification). + /// + /// Underlying stream __is owned__ by the generator constructed, + /// i.e. generator will handle closing of file when + /// JsonGenerator\#close is called. + ///@param f File to write contents to + ///@param enc Character encoding to use + ///@since 2.1 + jni.JObject createGenerator3( + jni.JObject f, + jni.JObject enc, + ) { + return const jni.JObjectType().fromRef( + _createGenerator3(reference, f.reference, enc.reference).object); + } + + static final _createGenerator4 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>("JsonFactory__createGenerator4") + .asFunction< + jni.JniResult Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.DataOutput out, com.fasterxml.jackson.core.JsonEncoding enc) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing generator for writing content using specified + /// DataOutput instance. + ///@since 2.8 + jni.JObject createGenerator4( + jni.JObject out, + jni.JObject enc, + ) { + return const jni.JObjectType().fromRef( + _createGenerator4(reference, out.reference, enc.reference).object); + } + + static final _createGenerator5 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__createGenerator5") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.DataOutput out) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Convenience method for constructing generator that uses default + /// encoding of the format (UTF-8 for JSON and most other data formats). + /// + /// Note: there are formats that use fixed encoding (like most binary data formats). + ///@since 2.8 + jni.JObject createGenerator5( + jni.JObject out, + ) { + return const jni.JObjectType() + .fromRef(_createGenerator5(reference, out.reference).object); + } + + static final _createJsonParser = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__createJsonParser") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(java.io.File f) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing JSON parser instance to parse + /// contents of specified file. + /// + /// Encoding is auto-detected from contents according to JSON + /// specification recommended mechanism. Json specification + /// supports only UTF-8, UTF-16 and UTF-32 as valid encodings, + /// so auto-detection implemented only for this charsets. + /// For other charsets use \#createParser(java.io.Reader). + /// + /// + /// Underlying input stream (needed for reading contents) + /// will be __owned__ (and managed, i.e. closed as need be) by + /// the parser, since caller has no access to it. + ///@param f File that contains JSON content to parse + ///@return Parser constructed + ///@throws IOException if parser initialization fails due to I/O (read) problem + ///@throws JsonParseException if parser initialization fails due to content decoding problem + ///@deprecated Since 2.2, use \#createParser(File) instead. + jsonparser_.JsonParser createJsonParser( + jni.JObject f, + ) { + return const jsonparser_.$JsonParserType() + .fromRef(_createJsonParser(reference, f.reference).object); + } + + static final _createJsonParser1 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__createJsonParser1") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(java.net.URL url) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing JSON parser instance to parse + /// contents of resource reference by given URL. + /// + /// Encoding is auto-detected from contents according to JSON + /// specification recommended mechanism. Json specification + /// supports only UTF-8, UTF-16 and UTF-32 as valid encodings, + /// so auto-detection implemented only for this charsets. + /// For other charsets use \#createParser(java.io.Reader). + /// + /// Underlying input stream (needed for reading contents) + /// will be __owned__ (and managed, i.e. closed as need be) by + /// the parser, since caller has no access to it. + ///@param url URL pointing to resource that contains JSON content to parse + ///@return Parser constructed + ///@throws IOException if parser initialization fails due to I/O (read) problem + ///@throws JsonParseException if parser initialization fails due to content decoding problem + ///@deprecated Since 2.2, use \#createParser(URL) instead. + jsonparser_.JsonParser createJsonParser1( + jni.JObject url, + ) { + return const jsonparser_.$JsonParserType() + .fromRef(_createJsonParser1(reference, url.reference).object); + } + + static final _createJsonParser2 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__createJsonParser2") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(java.io.InputStream in) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing JSON parser instance to parse + /// the contents accessed via specified input stream. + /// + /// The input stream will __not be owned__ by + /// the parser, it will still be managed (i.e. closed if + /// end-of-stream is reacher, or parser close method called) + /// if (and only if) com.fasterxml.jackson.core.JsonParser.Feature\#AUTO_CLOSE_SOURCE + /// is enabled. + /// + /// + /// Note: no encoding argument is taken since it can always be + /// auto-detected as suggested by JSON RFC. Json specification + /// supports only UTF-8, UTF-16 and UTF-32 as valid encodings, + /// so auto-detection implemented only for this charsets. + /// For other charsets use \#createParser(java.io.Reader). + ///@param in InputStream to use for reading JSON content to parse + ///@return Parser constructed + ///@throws IOException if parser initialization fails due to I/O (read) problem + ///@throws JsonParseException if parser initialization fails due to content decoding problem + ///@deprecated Since 2.2, use \#createParser(InputStream) instead. + jsonparser_.JsonParser createJsonParser2( + jni.JObject in0, + ) { + return const jsonparser_.$JsonParserType() + .fromRef(_createJsonParser2(reference, in0.reference).object); + } + + static final _createJsonParser3 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__createJsonParser3") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(java.io.Reader r) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing parser for parsing + /// the contents accessed via specified Reader. + /// + /// The read stream will __not be owned__ by + /// the parser, it will still be managed (i.e. closed if + /// end-of-stream is reacher, or parser close method called) + /// if (and only if) com.fasterxml.jackson.core.JsonParser.Feature\#AUTO_CLOSE_SOURCE + /// is enabled. + ///@param r Reader to use for reading JSON content to parse + ///@return Parser constructed + ///@throws IOException if parser initialization fails due to I/O (read) problem + ///@throws JsonParseException if parser initialization fails due to content decoding problem + ///@deprecated Since 2.2, use \#createParser(Reader) instead. + jsonparser_.JsonParser createJsonParser3( + jni.JObject r, + ) { + return const jsonparser_.$JsonParserType() + .fromRef(_createJsonParser3(reference, r.reference).object); + } + + static final _createJsonParser4 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__createJsonParser4") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(byte[] data) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing parser for parsing the contents of given byte array. + ///@param data Input content to parse + ///@return Parser constructed + ///@throws IOException if parser initialization fails due to I/O (read) problem + ///@throws JsonParseException if parser initialization fails due to content decoding problem + ///@deprecated Since 2.2, use \#createParser(byte[]) instead. + jsonparser_.JsonParser createJsonParser4( + jni.JArray data, + ) { + return const jsonparser_.$JsonParserType() + .fromRef(_createJsonParser4(reference, data.reference).object); + } + + static final _createJsonParser5 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int32, + ffi.Int32)>>("JsonFactory__createJsonParser5") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer, int, int)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(byte[] data, int offset, int len) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing parser for parsing + /// the contents of given byte array. + ///@param data Buffer that contains data to parse + ///@param offset Offset of the first data byte within buffer + ///@param len Length of contents to parse within buffer + ///@return Parser constructed + ///@throws IOException if parser initialization fails due to I/O (read) problem + ///@throws JsonParseException if parser initialization fails due to content decoding problem + ///@deprecated Since 2.2, use \#createParser(byte[],int,int) instead. + jsonparser_.JsonParser createJsonParser5( + jni.JArray data, + int offset, + int len, + ) { + return const jsonparser_.$JsonParserType().fromRef( + _createJsonParser5(reference, data.reference, offset, len).object); + } + + static final _createJsonParser6 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__createJsonParser6") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(java.lang.String content) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing parser for parsing + /// contents of given String. + ///@param content Input content to parse + ///@return Parser constructed + ///@throws IOException if parser initialization fails due to I/O (read) problem + ///@throws JsonParseException if parser initialization fails due to content decoding problem + ///@deprecated Since 2.2, use \#createParser(String) instead. + jsonparser_.JsonParser createJsonParser6( + jni.JString content, + ) { + return const jsonparser_.$JsonParserType() + .fromRef(_createJsonParser6(reference, content.reference).object); + } + + static final _createJsonGenerator = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>("JsonFactory__createJsonGenerator") + .asFunction< + jni.JniResult Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonGenerator createJsonGenerator(java.io.OutputStream out, com.fasterxml.jackson.core.JsonEncoding enc) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing JSON generator for writing JSON content + /// using specified output stream. + /// Encoding to use must be specified, and needs to be one of available + /// types (as per JSON specification). + /// + /// Underlying stream __is NOT owned__ by the generator constructed, + /// so that generator will NOT close the output stream when + /// JsonGenerator\#close is called (unless auto-closing + /// feature, + /// com.fasterxml.jackson.core.JsonGenerator.Feature\#AUTO_CLOSE_TARGET + /// is enabled). + /// Using application needs to close it explicitly if this is the case. + /// + /// Note: there are formats that use fixed encoding (like most binary data formats) + /// and that ignore passed in encoding. + ///@param out OutputStream to use for writing JSON content + ///@param enc Character encoding to use + ///@return Generator constructed + ///@throws IOException if parser initialization fails due to I/O (write) problem + ///@deprecated Since 2.2, use \#createGenerator(OutputStream, JsonEncoding) instead. + jni.JObject createJsonGenerator( + jni.JObject out, + jni.JObject enc, + ) { + return const jni.JObjectType().fromRef( + _createJsonGenerator(reference, out.reference, enc.reference).object); + } + + static final _createJsonGenerator1 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__createJsonGenerator1") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonGenerator createJsonGenerator(java.io.Writer out) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing JSON generator for writing JSON content + /// using specified Writer. + /// + /// Underlying stream __is NOT owned__ by the generator constructed, + /// so that generator will NOT close the Reader when + /// JsonGenerator\#close is called (unless auto-closing + /// feature, + /// com.fasterxml.jackson.core.JsonGenerator.Feature\#AUTO_CLOSE_TARGET is enabled). + /// Using application needs to close it explicitly. + ///@param out Writer to use for writing JSON content + ///@return Generator constructed + ///@throws IOException if parser initialization fails due to I/O (write) problem + ///@deprecated Since 2.2, use \#createGenerator(Writer) instead. + jni.JObject createJsonGenerator1( + jni.JObject out, + ) { + return const jni.JObjectType() + .fromRef(_createJsonGenerator1(reference, out.reference).object); + } + + static final _createJsonGenerator2 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonFactory__createJsonGenerator2") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonGenerator createJsonGenerator(java.io.OutputStream out) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Convenience method for constructing generator that uses default + /// encoding of the format (UTF-8 for JSON and most other data formats). + /// + /// Note: there are formats that use fixed encoding (like most binary data formats). + ///@param out OutputStream to use for writing JSON content + ///@return Generator constructed + ///@throws IOException if parser initialization fails due to I/O (write) problem + ///@deprecated Since 2.2, use \#createGenerator(OutputStream) instead. + jni.JObject createJsonGenerator2( + jni.JObject out, + ) { + return const jni.JObjectType() + .fromRef(_createJsonGenerator2(reference, out.reference).object); + } +} + +class $JsonFactoryType extends jni.JObjType { + const $JsonFactoryType(); + + @override + String get signature => r"Lcom/fasterxml/jackson/core/JsonFactory;"; + + @override + JsonFactory fromRef(jni.JObjectPtr ref) => JsonFactory.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($JsonFactoryType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $JsonFactoryType && other is $JsonFactoryType; + } +} + +/// from: com.fasterxml.jackson.core.JsonFactory$Feature +/// +/// Enumeration that defines all on/off features that can only be +/// changed for JsonFactory. +class JsonFactory_Feature extends jni.JObject { + @override + late final jni.JObjType $type = type; + + JsonFactory_Feature.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = $JsonFactory_FeatureType(); + static final _values = + jniLookup>( + "JsonFactory_Feature__values") + .asFunction(); + + /// from: static public com.fasterxml.jackson.core.JsonFactory.Feature[] values() + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JArray values() { + return const jni.JArrayType($JsonFactory_FeatureType()) + .fromRef(_values().object); + } + + static final _valueOf = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonFactory_Feature__valueOf") + .asFunction)>(); + + /// from: static public com.fasterxml.jackson.core.JsonFactory.Feature valueOf(java.lang.String name) + /// The returned object must be deleted after use, by calling the `delete` method. + static JsonFactory_Feature valueOf( + jni.JString name, + ) { + return const $JsonFactory_FeatureType() + .fromRef(_valueOf(name.reference).object); + } + + static final _collectDefaults = + jniLookup>( + "JsonFactory_Feature__collectDefaults") + .asFunction(); + + /// from: static public int collectDefaults() + /// + /// Method that calculates bit set (flags) of all features that + /// are enabled by default. + ///@return Bit field of features enabled by default + static int collectDefaults() { + return _collectDefaults().integer; + } + + static final _enabledByDefault = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>( + "JsonFactory_Feature__enabledByDefault") + .asFunction)>(); + + /// from: public boolean enabledByDefault() + bool enabledByDefault() { + return _enabledByDefault(reference).boolean; + } + + static final _enabledIn = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Int32)>>("JsonFactory_Feature__enabledIn") + .asFunction, int)>(); + + /// from: public boolean enabledIn(int flags) + bool enabledIn( + int flags, + ) { + return _enabledIn(reference, flags).boolean; + } + + static final _getMask = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonFactory_Feature__getMask") + .asFunction)>(); + + /// from: public int getMask() + int getMask() { + return _getMask(reference).integer; + } +} + +class $JsonFactory_FeatureType extends jni.JObjType { + const $JsonFactory_FeatureType(); + + @override + String get signature => r"Lcom/fasterxml/jackson/core/JsonFactory$Feature;"; + + @override + JsonFactory_Feature fromRef(jni.JObjectPtr ref) => + JsonFactory_Feature.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($JsonFactory_FeatureType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $JsonFactory_FeatureType && + other is $JsonFactory_FeatureType; + } +} diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart new file mode 100644 index 000000000..54e45f8ef --- /dev/null +++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart @@ -0,0 +1,2842 @@ +// Generated from jackson-core which is licensed under the Apache License 2.0. +// The following copyright from the original authors applies. +// See https://github.com/FasterXML/jackson-core/blob/2.14/LICENSE +// +// Copyright (c) 2007 - The Jackson Project Authors +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Autogenerated by jnigen. DO NOT EDIT! + +// ignore_for_file: annotate_overrides +// ignore_for_file: camel_case_extensions +// ignore_for_file: camel_case_types +// ignore_for_file: constant_identifier_names +// ignore_for_file: file_names +// ignore_for_file: no_leading_underscores_for_local_identifiers +// ignore_for_file: non_constant_identifier_names +// ignore_for_file: overridden_fields +// ignore_for_file: unnecessary_cast +// ignore_for_file: unused_element +// ignore_for_file: unused_field +// ignore_for_file: unused_import +// ignore_for_file: unused_shown_name + +import "dart:isolate" show ReceivePort; +import "dart:ffi" as ffi; +import "package:jni/internal_helpers_for_jnigen.dart"; +import "package:jni/jni.dart" as jni; + +import "JsonToken.dart" as jsontoken_; +import "../../../../_init.dart"; + +/// from: com.fasterxml.jackson.core.JsonParser +/// +/// Base class that defines public API for reading JSON content. +/// Instances are created using factory methods of +/// a JsonFactory instance. +///@author Tatu Saloranta +class JsonParser extends jni.JObject { + @override + late final jni.JObjType $type = type; + + JsonParser.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = $JsonParserType(); + static final _get_DEFAULT_READ_CAPABILITIES = + jniLookup>( + "get_JsonParser__DEFAULT_READ_CAPABILITIES") + .asFunction(); + + /// from: static protected final com.fasterxml.jackson.core.util.JacksonFeatureSet DEFAULT_READ_CAPABILITIES + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Default set of StreamReadCapabilityies that may be used as + /// basis for format-specific readers (or as bogus instance if non-null + /// set needs to be passed). + ///@since 2.12 + static jni.JObject get DEFAULT_READ_CAPABILITIES => + const jni.JObjectType().fromRef(_get_DEFAULT_READ_CAPABILITIES().object); + + static final _ctor = jniLookup>( + "JsonParser__ctor") + .asFunction(); + + /// from: protected void () + /// The returned object must be deleted after use, by calling the `delete` method. + factory JsonParser() { + return JsonParser.fromRef(_ctor().object); + } + + static final _ctor1 = + jniLookup>( + "JsonParser__ctor1") + .asFunction(); + + /// from: protected void (int features) + /// The returned object must be deleted after use, by calling the `delete` method. + factory JsonParser.ctor1( + int features, + ) { + return JsonParser.fromRef(_ctor1(features).object); + } + + static final _getCodec = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getCodec") + .asFunction)>(); + + /// from: public abstract com.fasterxml.jackson.core.ObjectCodec getCodec() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Accessor for ObjectCodec associated with this + /// parser, if any. Codec is used by \#readValueAs(Class) + /// method (and its variants). + ///@return Codec assigned to this parser, if any; {@code null} if none + jni.JObject getCodec() { + return const jni.JObjectType().fromRef(_getCodec(reference).object); + } + + static final _setCodec = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonParser__setCodec") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public abstract void setCodec(com.fasterxml.jackson.core.ObjectCodec oc) + /// + /// Setter that allows defining ObjectCodec associated with this + /// parser, if any. Codec is used by \#readValueAs(Class) + /// method (and its variants). + ///@param oc Codec to assign, if any; {@code null} if none + void setCodec( + jni.JObject oc, + ) { + return _setCodec(reference, oc.reference).check(); + } + + static final _getInputSource = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getInputSource") + .asFunction)>(); + + /// from: public java.lang.Object getInputSource() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that can be used to get access to object that is used + /// to access input being parsed; this is usually either + /// InputStream or Reader, depending on what + /// parser was constructed with. + /// Note that returned value may be null in some cases; including + /// case where parser implementation does not want to exposed raw + /// source to caller. + /// In cases where input has been decorated, object returned here + /// is the decorated version; this allows some level of interaction + /// between users of parser and decorator object. + /// + /// In general use of this accessor should be considered as + /// "last effort", i.e. only used if no other mechanism is applicable. + ///@return Input source this parser was configured with + jni.JObject getInputSource() { + return const jni.JObjectType().fromRef(_getInputSource(reference).object); + } + + static final _setRequestPayloadOnError = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>>( + "JsonParser__setRequestPayloadOnError") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public void setRequestPayloadOnError(com.fasterxml.jackson.core.util.RequestPayload payload) + /// + /// Sets the payload to be passed if JsonParseException is thrown. + ///@param payload Payload to pass + ///@since 2.8 + void setRequestPayloadOnError( + jni.JObject payload, + ) { + return _setRequestPayloadOnError(reference, payload.reference).check(); + } + + static final _setRequestPayloadOnError1 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>( + "JsonParser__setRequestPayloadOnError1") + .asFunction< + jni.JniResult Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + /// from: public void setRequestPayloadOnError(byte[] payload, java.lang.String charset) + /// + /// Sets the byte[] request payload and the charset + ///@param payload Payload to pass + ///@param charset Character encoding for (lazily) decoding payload + ///@since 2.8 + void setRequestPayloadOnError1( + jni.JArray payload, + jni.JString charset, + ) { + return _setRequestPayloadOnError1( + reference, payload.reference, charset.reference) + .check(); + } + + static final _setRequestPayloadOnError2 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>>( + "JsonParser__setRequestPayloadOnError2") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public void setRequestPayloadOnError(java.lang.String payload) + /// + /// Sets the String request payload + ///@param payload Payload to pass + ///@since 2.8 + void setRequestPayloadOnError2( + jni.JString payload, + ) { + return _setRequestPayloadOnError2(reference, payload.reference).check(); + } + + static final _setSchema = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonParser__setSchema") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public void setSchema(com.fasterxml.jackson.core.FormatSchema schema) + /// + /// Method to call to make this parser use specified schema. Method must + /// be called before trying to parse any content, right after parser instance + /// has been created. + /// Note that not all parsers support schemas; and those that do usually only + /// accept specific types of schemas: ones defined for data format parser can read. + /// + /// If parser does not support specified schema, UnsupportedOperationException + /// is thrown. + ///@param schema Schema to use + ///@throws UnsupportedOperationException if parser does not support schema + void setSchema( + jni.JObject schema, + ) { + return _setSchema(reference, schema.reference).check(); + } + + static final _getSchema = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getSchema") + .asFunction)>(); + + /// from: public com.fasterxml.jackson.core.FormatSchema getSchema() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for accessing Schema that this parser uses, if any. + /// Default implementation returns null. + ///@return Schema in use by this parser, if any; {@code null} if none + ///@since 2.1 + jni.JObject getSchema() { + return const jni.JObjectType().fromRef(_getSchema(reference).object); + } + + static final _canUseSchema = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonParser__canUseSchema") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public boolean canUseSchema(com.fasterxml.jackson.core.FormatSchema schema) + /// + /// Method that can be used to verify that given schema can be used with + /// this parser (using \#setSchema). + ///@param schema Schema to check + ///@return True if this parser can use given schema; false if not + bool canUseSchema( + jni.JObject schema, + ) { + return _canUseSchema(reference, schema.reference).boolean; + } + + static final _requiresCustomCodec = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__requiresCustomCodec") + .asFunction)>(); + + /// from: public boolean requiresCustomCodec() + /// + /// Method that can be called to determine if a custom + /// ObjectCodec is needed for binding data parsed + /// using JsonParser constructed by this factory + /// (which typically also implies the same for serialization + /// with JsonGenerator). + ///@return True if format-specific codec is needed with this parser; false if a general + /// ObjectCodec is enough + ///@since 2.1 + bool requiresCustomCodec() { + return _requiresCustomCodec(reference).boolean; + } + + static final _canParseAsync = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__canParseAsync") + .asFunction)>(); + + /// from: public boolean canParseAsync() + /// + /// Method that can be called to determine if this parser instance + /// uses non-blocking ("asynchronous") input access for decoding or not. + /// Access mode is determined by earlier calls via JsonFactory; + /// it may not be changed after construction. + /// + /// If non-blocking decoding is (@code true}, it is possible to call + /// \#getNonBlockingInputFeeder() to obtain object to use + /// for feeding input; otherwise (false returned) + /// input is read by blocking + ///@return True if this is a non-blocking ("asynchronous") parser + ///@since 2.9 + bool canParseAsync() { + return _canParseAsync(reference).boolean; + } + + static final _getNonBlockingInputFeeder = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>( + "JsonParser__getNonBlockingInputFeeder") + .asFunction)>(); + + /// from: public com.fasterxml.jackson.core.async.NonBlockingInputFeeder getNonBlockingInputFeeder() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that will either return a feeder instance (if parser uses + /// non-blocking, aka asynchronous access); or null for + /// parsers that use blocking I/O. + ///@return Input feeder to use with non-blocking (async) parsing + ///@since 2.9 + jni.JObject getNonBlockingInputFeeder() { + return const jni.JObjectType() + .fromRef(_getNonBlockingInputFeeder(reference).object); + } + + static final _getReadCapabilities = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getReadCapabilities") + .asFunction)>(); + + /// from: public com.fasterxml.jackson.core.util.JacksonFeatureSet getReadCapabilities() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Accessor for getting metadata on capabilities of this parser, based on + /// underlying data format being read (directly or indirectly). + ///@return Set of read capabilities for content to read via this parser + ///@since 2.12 + jni.JObject getReadCapabilities() { + return const jni.JObjectType() + .fromRef(_getReadCapabilities(reference).object); + } + + static final _version = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__version") + .asFunction)>(); + + /// from: public abstract com.fasterxml.jackson.core.Version version() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Accessor for getting version of the core package, given a parser instance. + /// Left for sub-classes to implement. + ///@return Version of this generator (derived from version declared for + /// {@code jackson-core} jar that contains the class + jni.JObject version() { + return const jni.JObjectType().fromRef(_version(reference).object); + } + + static final _close = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__close") + .asFunction)>(); + + /// from: public abstract void close() + /// + /// Closes the parser so that no further iteration or data access + /// can be made; will also close the underlying input source + /// if parser either __owns__ the input source, or feature + /// Feature\#AUTO_CLOSE_SOURCE is enabled. + /// Whether parser owns the input source depends on factory + /// method that was used to construct instance (so check + /// com.fasterxml.jackson.core.JsonFactory for details, + /// but the general + /// idea is that if caller passes in closable resource (such + /// as InputStream or Reader) parser does NOT + /// own the source; but if it passes a reference (such as + /// java.io.File or java.net.URL and creates + /// stream or reader it does own them. + ///@throws IOException if there is either an underlying I/O problem + void close() { + return _close(reference).check(); + } + + static final _isClosed = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__isClosed") + .asFunction)>(); + + /// from: public abstract boolean isClosed() + /// + /// Method that can be called to determine whether this parser + /// is closed or not. If it is closed, no new tokens can be + /// retrieved by calling \#nextToken (and the underlying + /// stream may be closed). Closing may be due to an explicit + /// call to \#close or because parser has encountered + /// end of input. + ///@return {@code True} if this parser instance has been closed + bool isClosed() { + return _isClosed(reference).boolean; + } + + static final _getParsingContext = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getParsingContext") + .asFunction)>(); + + /// from: public abstract com.fasterxml.jackson.core.JsonStreamContext getParsingContext() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that can be used to access current parsing context reader + /// is in. There are 3 different types: root, array and object contexts, + /// with slightly different available information. Contexts are + /// hierarchically nested, and can be used for example for figuring + /// out part of the input document that correspond to specific + /// array or object (for highlighting purposes, or error reporting). + /// Contexts can also be used for simple xpath-like matching of + /// input, if so desired. + ///@return Stream input context (JsonStreamContext) associated with this parser + jni.JObject getParsingContext() { + return const jni.JObjectType() + .fromRef(_getParsingContext(reference).object); + } + + static final _currentLocation = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__currentLocation") + .asFunction)>(); + + /// from: public com.fasterxml.jackson.core.JsonLocation currentLocation() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that returns location of the last processed input unit (character + /// or byte) from the input; + /// usually for error reporting purposes. + /// + /// Note that the location is not guaranteed to be accurate (although most + /// implementation will try their best): some implementations may only + /// report specific boundary locations (start or end locations of tokens) + /// and others only return JsonLocation\#NA due to not having access + /// to input location information (when delegating actual decoding work + /// to other library) + ///@return Location of the last processed input unit (byte or character) + ///@since 2.13 + jni.JObject currentLocation() { + return const jni.JObjectType().fromRef(_currentLocation(reference).object); + } + + static final _currentTokenLocation = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__currentTokenLocation") + .asFunction)>(); + + /// from: public com.fasterxml.jackson.core.JsonLocation currentTokenLocation() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that return the __starting__ location of the current + /// (most recently returned) + /// token; that is, the position of the first input unit (character or byte) from input + /// that starts the current token. + /// + /// Note that the location is not guaranteed to be accurate (although most + /// implementation will try their best): some implementations may only + /// return JsonLocation\#NA due to not having access + /// to input location information (when delegating actual decoding work + /// to other library) + ///@return Starting location of the token parser currently points to + ///@since 2.13 (will eventually replace \#getTokenLocation) + jni.JObject currentTokenLocation() { + return const jni.JObjectType() + .fromRef(_currentTokenLocation(reference).object); + } + + static final _getCurrentLocation = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getCurrentLocation") + .asFunction)>(); + + /// from: public abstract com.fasterxml.jackson.core.JsonLocation getCurrentLocation() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Alias for \#currentLocation(), to be deprecated in later + /// Jackson 2.x versions (and removed from Jackson 3.0). + ///@return Location of the last processed input unit (byte or character) + jni.JObject getCurrentLocation() { + return const jni.JObjectType() + .fromRef(_getCurrentLocation(reference).object); + } + + static final _getTokenLocation = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getTokenLocation") + .asFunction)>(); + + /// from: public abstract com.fasterxml.jackson.core.JsonLocation getTokenLocation() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Alias for \#currentTokenLocation(), to be deprecated in later + /// Jackson 2.x versions (and removed from Jackson 3.0). + ///@return Starting location of the token parser currently points to + jni.JObject getTokenLocation() { + return const jni.JObjectType().fromRef(_getTokenLocation(reference).object); + } + + static final _currentValue = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__currentValue") + .asFunction)>(); + + /// from: public java.lang.Object currentValue() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Helper method, usually equivalent to: + /// + /// getParsingContext().getCurrentValue(); + /// + /// + /// Note that "current value" is NOT populated (or used) by Streaming parser; + /// it is only used by higher-level data-binding functionality. + /// The reason it is included here is that it can be stored and accessed hierarchically, + /// and gets passed through data-binding. + ///@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 const jni.JObjectType().fromRef(_currentValue(reference).object); + } + + static final _assignCurrentValue = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonParser__assignCurrentValue") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public void assignCurrentValue(java.lang.Object v) + /// + /// Helper method, usually equivalent to: + /// + /// getParsingContext().setCurrentValue(v); + /// + ///@param v Current value to assign for the current input context of this parser + ///@since 2.13 (added as replacement for older \#setCurrentValue + void assignCurrentValue( + jni.JObject v, + ) { + return _assignCurrentValue(reference, v.reference).check(); + } + + static final _getCurrentValue = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getCurrentValue") + .asFunction)>(); + + /// from: public java.lang.Object getCurrentValue() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Alias for \#currentValue(), to be deprecated in later + /// 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 const jni.JObjectType().fromRef(_getCurrentValue(reference).object); + } + + static final _setCurrentValue = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonParser__setCurrentValue") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public void setCurrentValue(java.lang.Object v) + /// + /// Alias for \#assignCurrentValue, to be deprecated in later + /// Jackson 2.x versions (and removed from Jackson 3.0). + ///@param v Current value to assign for the current input context of this parser + void setCurrentValue( + jni.JObject v, + ) { + return _setCurrentValue(reference, v.reference).check(); + } + + static final _releaseBuffered = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonParser__releaseBuffered") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public int releaseBuffered(java.io.OutputStream out) + /// + /// Method that can be called to push back any content that + /// has been read but not consumed by the parser. This is usually + /// done after reading all content of interest using parser. + /// Content is released by writing it to given stream if possible; + /// if underlying input is byte-based it can released, if not (char-based) + /// it can not. + ///@param out OutputStream to which buffered, undecoded content is written to + ///@return -1 if the underlying content source is not byte based + /// (that is, input can not be sent to OutputStream; + /// otherwise number of bytes released (0 if there was nothing to release) + ///@throws IOException if write to stream threw exception + int releaseBuffered( + jni.JObject out, + ) { + return _releaseBuffered(reference, out.reference).integer; + } + + static final _releaseBuffered1 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonParser__releaseBuffered1") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public int releaseBuffered(java.io.Writer w) + /// + /// Method that can be called to push back any content that + /// has been read but not consumed by the parser. + /// This is usually + /// done after reading all content of interest using parser. + /// Content is released by writing it to given writer if possible; + /// if underlying input is char-based it can released, if not (byte-based) + /// it can not. + ///@param w Writer to which buffered but unprocessed content is written to + ///@return -1 if the underlying content source is not char-based + /// (that is, input can not be sent to Writer; + /// otherwise number of chars released (0 if there was nothing to release) + ///@throws IOException if write using Writer threw exception + int releaseBuffered1( + jni.JObject w, + ) { + return _releaseBuffered1(reference, w.reference).integer; + } + + static final _enable = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonParser__enable") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser enable(com.fasterxml.jackson.core.JsonParser.Feature f) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for enabling specified parser feature + /// (check Feature for list of features) + ///@param f Feature to enable + ///@return This parser, to allow call chaining + JsonParser enable( + JsonParser_Feature f, + ) { + return const $JsonParserType() + .fromRef(_enable(reference, f.reference).object); + } + + static final _disable = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonParser__disable") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser disable(com.fasterxml.jackson.core.JsonParser.Feature f) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for disabling specified feature + /// (check Feature for list of features) + ///@param f Feature to disable + ///@return This parser, to allow call chaining + JsonParser disable( + JsonParser_Feature f, + ) { + return const $JsonParserType() + .fromRef(_disable(reference, f.reference).object); + } + + static final _configure = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer, ffi.Uint8)>>("JsonParser__configure") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer, int)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser configure(com.fasterxml.jackson.core.JsonParser.Feature f, boolean state) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for enabling or disabling specified feature + /// (check Feature for list of features) + ///@param f Feature to enable or disable + ///@param state Whether to enable feature ({@code true}) or disable ({@code false}) + ///@return This parser, to allow call chaining + JsonParser configure( + JsonParser_Feature f, + bool state, + ) { + return const $JsonParserType() + .fromRef(_configure(reference, f.reference, state ? 1 : 0).object); + } + + static final _isEnabled = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonParser__isEnabled") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public boolean isEnabled(com.fasterxml.jackson.core.JsonParser.Feature f) + /// + /// Method for checking whether specified Feature is enabled. + ///@param f Feature to check + ///@return {@code True} if feature is enabled; {@code false} otherwise + bool isEnabled( + JsonParser_Feature f, + ) { + return _isEnabled(reference, f.reference).boolean; + } + + static final _isEnabled1 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonParser__isEnabled1") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public boolean isEnabled(com.fasterxml.jackson.core.StreamReadFeature f) + /// + /// Method for checking whether specified Feature is enabled. + ///@param f Feature to check + ///@return {@code True} if feature is enabled; {@code false} otherwise + ///@since 2.10 + bool isEnabled1( + jni.JObject f, + ) { + return _isEnabled1(reference, f.reference).boolean; + } + + static final _getFeatureMask = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getFeatureMask") + .asFunction)>(); + + /// from: public int getFeatureMask() + /// + /// Bulk access method for getting state of all standard Features. + ///@return Bit mask that defines current states of all standard Features. + ///@since 2.3 + int getFeatureMask() { + return _getFeatureMask(reference).integer; + } + + static final _setFeatureMask = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Int32)>>("JsonParser__setFeatureMask") + .asFunction, int)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser setFeatureMask(int mask) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Bulk set method for (re)setting states of all standard Features + ///@param mask Bit mask that defines set of features to enable + ///@return This parser, to allow call chaining + ///@since 2.3 + ///@deprecated Since 2.7, use \#overrideStdFeatures(int, int) instead + JsonParser setFeatureMask( + int mask, + ) { + return const $JsonParserType() + .fromRef(_setFeatureMask(reference, mask).object); + } + + static final _overrideStdFeatures = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, ffi.Int32, + ffi.Int32)>>("JsonParser__overrideStdFeatures") + .asFunction, int, int)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser overrideStdFeatures(int values, int mask) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Bulk set method for (re)setting states of features specified by mask. + /// Functionally equivalent to + /// + /// int oldState = getFeatureMask(); + /// int newState = (oldState & ~mask) | (values & mask); + /// setFeatureMask(newState); + /// + /// but preferred as this lets caller more efficiently specify actual changes made. + ///@param values Bit mask of set/clear state for features to change + ///@param mask Bit mask of features to change + ///@return This parser, to allow call chaining + ///@since 2.6 + JsonParser overrideStdFeatures( + int values, + int mask, + ) { + return const $JsonParserType() + .fromRef(_overrideStdFeatures(reference, values, mask).object); + } + + static final _getFormatFeatures = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getFormatFeatures") + .asFunction)>(); + + /// from: public int getFormatFeatures() + /// + /// Bulk access method for getting state of all FormatFeatures, format-specific + /// on/off configuration settings. + ///@return Bit mask that defines current states of all standard FormatFeatures. + ///@since 2.6 + int getFormatFeatures() { + return _getFormatFeatures(reference).integer; + } + + static final _overrideFormatFeatures = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, ffi.Int32, + ffi.Int32)>>("JsonParser__overrideFormatFeatures") + .asFunction, int, int)>(); + + /// from: public com.fasterxml.jackson.core.JsonParser overrideFormatFeatures(int values, int mask) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Bulk set method for (re)setting states of FormatFeatures, + /// by specifying values (set / clear) along with a mask, to determine + /// which features to change, if any. + /// + /// Default implementation will simply throw an exception to indicate that + /// the parser implementation does not support any FormatFeatures. + ///@param values Bit mask of set/clear state for features to change + ///@param mask Bit mask of features to change + ///@return This parser, to allow call chaining + ///@since 2.6 + JsonParser overrideFormatFeatures( + int values, + int mask, + ) { + return const $JsonParserType() + .fromRef(_overrideFormatFeatures(reference, values, mask).object); + } + + static final _nextToken = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__nextToken") + .asFunction)>(); + + /// from: public abstract com.fasterxml.jackson.core.JsonToken nextToken() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Main iteration method, which will advance stream enough + /// to determine type of the next token, if any. If none + /// remaining (stream has no content other than possible + /// white space before ending), null will be returned. + ///@return Next token from the stream, if any found, or null + /// to indicate end-of-input + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + jsontoken_.JsonToken nextToken() { + return const jsontoken_.$JsonTokenType() + .fromRef(_nextToken(reference).object); + } + + static final _nextValue = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__nextValue") + .asFunction)>(); + + /// from: public abstract com.fasterxml.jackson.core.JsonToken nextValue() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Iteration method that will advance stream enough + /// to determine type of the next token that is a value type + /// (including JSON Array and Object start/end markers). + /// Or put another way, nextToken() will be called once, + /// and if JsonToken\#FIELD_NAME is returned, another + /// time to get the value for the field. + /// Method is most useful for iterating over value entries + /// of JSON objects; field name will still be available + /// by calling \#getCurrentName when parser points to + /// the value. + ///@return Next non-field-name token from the stream, if any found, + /// or null to indicate end-of-input (or, for non-blocking + /// parsers, JsonToken\#NOT_AVAILABLE if no tokens were + /// available yet) + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + jsontoken_.JsonToken nextValue() { + return const jsontoken_.$JsonTokenType() + .fromRef(_nextValue(reference).object); + } + + static final _nextFieldName = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonParser__nextFieldName") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public boolean nextFieldName(com.fasterxml.jackson.core.SerializableString str) + /// + /// Method that fetches next token (as if calling \#nextToken) and + /// verifies whether it is JsonToken\#FIELD_NAME with specified name + /// and returns result of that comparison. + /// It is functionally equivalent to: + ///
    +  ///  return (nextToken() == JsonToken.FIELD_NAME) && str.getValue().equals(getCurrentName());
    +  ///
    + /// but may be faster for parser to verify, and can therefore be used if caller + /// expects to get such a property name from input next. + ///@param str Property name to compare next token to (if next token is + /// JsonToken.FIELD_NAME) + ///@return {@code True} if parser advanced to {@code JsonToken.FIELD_NAME} with + /// specified name; {@code false} otherwise (different token or non-matching name) + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + bool nextFieldName( + jni.JObject str, + ) { + return _nextFieldName(reference, str.reference).boolean; + } + + static final _nextFieldName1 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__nextFieldName1") + .asFunction)>(); + + /// from: public java.lang.String nextFieldName() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that fetches next token (as if calling \#nextToken) and + /// verifies whether it is JsonToken\#FIELD_NAME; if it is, + /// returns same as \#getCurrentName(), otherwise null. + ///@return Name of the the {@code JsonToken.FIELD_NAME} parser advanced to, if any; + /// {@code null} if next token is of some other type + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + ///@since 2.5 + jni.JString nextFieldName1() { + return const jni.JStringType().fromRef(_nextFieldName1(reference).object); + } + + static final _nextTextValue = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__nextTextValue") + .asFunction)>(); + + /// from: public java.lang.String nextTextValue() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that fetches next token (as if calling \#nextToken) and + /// if it is JsonToken\#VALUE_STRING returns contained String value; + /// otherwise returns null. + /// It is functionally equivalent to: + ///
    +  ///  return (nextToken() == JsonToken.VALUE_STRING) ? getText() : null;
    +  ///
    + /// but may be faster for parser to process, and can therefore be used if caller + /// expects to get a String value next from input. + ///@return Text value of the {@code JsonToken.VALUE_STRING} token parser advanced + /// to; or {@code null} if next token is of some other type + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + jni.JString nextTextValue() { + return const jni.JStringType().fromRef(_nextTextValue(reference).object); + } + + static final _nextIntValue = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Int32)>>("JsonParser__nextIntValue") + .asFunction, int)>(); + + /// from: public int nextIntValue(int defaultValue) + /// + /// Method that fetches next token (as if calling \#nextToken) and + /// if it is JsonToken\#VALUE_NUMBER_INT returns 32-bit int value; + /// otherwise returns specified default value + /// It is functionally equivalent to: + ///
    +  ///  return (nextToken() == JsonToken.VALUE_NUMBER_INT) ? getIntValue() : defaultValue;
    +  ///
    + /// but may be faster for parser to process, and can therefore be used if caller + /// expects to get an int value next from input. + /// + /// NOTE: value checks are performed similar to \#getIntValue() + ///@param defaultValue Value to return if next token is NOT of type {@code JsonToken.VALUE_NUMBER_INT} + ///@return Integer ({@code int}) value of the {@code JsonToken.VALUE_NUMBER_INT} token parser advanced + /// to; or {@code defaultValue} if next token is of some other type + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + ///@throws InputCoercionException if integer number does not fit in Java {@code int} + int nextIntValue( + int defaultValue, + ) { + return _nextIntValue(reference, defaultValue).integer; + } + + static final _nextLongValue = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Int64)>>("JsonParser__nextLongValue") + .asFunction, int)>(); + + /// from: public long nextLongValue(long defaultValue) + /// + /// Method that fetches next token (as if calling \#nextToken) and + /// if it is JsonToken\#VALUE_NUMBER_INT returns 64-bit long value; + /// otherwise returns specified default value + /// It is functionally equivalent to: + ///
    +  ///  return (nextToken() == JsonToken.VALUE_NUMBER_INT) ? getLongValue() : defaultValue;
    +  ///
    + /// but may be faster for parser to process, and can therefore be used if caller + /// expects to get a long value next from input. + /// + /// NOTE: value checks are performed similar to \#getLongValue() + ///@param defaultValue Value to return if next token is NOT of type {@code JsonToken.VALUE_NUMBER_INT} + ///@return {@code long} value of the {@code JsonToken.VALUE_NUMBER_INT} token parser advanced + /// to; or {@code defaultValue} if next token is of some other type + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + ///@throws InputCoercionException if integer number does not fit in Java {@code long} + int nextLongValue( + int defaultValue, + ) { + return _nextLongValue(reference, defaultValue).long; + } + + static final _nextBooleanValue = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__nextBooleanValue") + .asFunction)>(); + + /// from: public java.lang.Boolean nextBooleanValue() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that fetches next token (as if calling \#nextToken) and + /// if it is JsonToken\#VALUE_TRUE or JsonToken\#VALUE_FALSE + /// returns matching Boolean value; otherwise return null. + /// It is functionally equivalent to: + ///
    +  ///  JsonToken t = nextToken();
    +  ///  if (t == JsonToken.VALUE_TRUE) return Boolean.TRUE;
    +  ///  if (t == JsonToken.VALUE_FALSE) return Boolean.FALSE;
    +  ///  return null;
    +  ///
    + /// but may be faster for parser to process, and can therefore be used if caller + /// expects to get a Boolean value next from input. + ///@return {@code Boolean} value of the {@code JsonToken.VALUE_TRUE} or {@code JsonToken.VALUE_FALSE} + /// token parser advanced to; or {@code null} if next token is of some other type + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + jni.JObject nextBooleanValue() { + return const jni.JObjectType().fromRef(_nextBooleanValue(reference).object); + } + + static final _skipChildren = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__skipChildren") + .asFunction)>(); + + /// from: public abstract com.fasterxml.jackson.core.JsonParser skipChildren() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that will skip all child tokens of an array or + /// object token that the parser currently points to, + /// iff stream points to + /// JsonToken\#START_OBJECT or JsonToken\#START_ARRAY. + /// If not, it will do nothing. + /// After skipping, stream will point to __matching__ + /// JsonToken\#END_OBJECT or JsonToken\#END_ARRAY + /// (possibly skipping nested pairs of START/END OBJECT/ARRAY tokens + /// as well as value tokens). + /// The idea is that after calling this method, application + /// will call \#nextToken to point to the next + /// available token, if any. + ///@return This parser, to allow call chaining + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + JsonParser skipChildren() { + return const $JsonParserType().fromRef(_skipChildren(reference).object); + } + + static final _finishToken = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__finishToken") + .asFunction)>(); + + /// from: public void finishToken() + /// + /// Method that may be used to force full handling of the current token + /// so that even if lazy processing is enabled, the whole contents are + /// read for possible retrieval. This is usually used to ensure that + /// the token end location is available, as well as token contents + /// (similar to what calling, say \#getTextCharacters(), would + /// achieve). + /// + /// Note that for many dataformat implementations this method + /// will not do anything; this is the default implementation unless + /// overridden by sub-classes. + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + ///@since 2.8 + void finishToken() { + return _finishToken(reference).check(); + } + + static final _currentToken = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__currentToken") + .asFunction)>(); + + /// from: public com.fasterxml.jackson.core.JsonToken currentToken() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Accessor to find which token parser currently points to, if any; + /// null will be returned if none. + /// If return value is non-null, data associated with the token + /// is available via other accessor methods. + ///@return Type of the token this parser currently points to, + /// if any: null before any tokens have been read, and + /// after end-of-input has been encountered, as well as + /// if the current token has been explicitly cleared. + ///@since 2.8 + jsontoken_.JsonToken currentToken() { + return const jsontoken_.$JsonTokenType() + .fromRef(_currentToken(reference).object); + } + + static final _currentTokenId = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__currentTokenId") + .asFunction)>(); + + /// from: public int currentTokenId() + /// + /// Method similar to \#getCurrentToken() but that returns an + /// int instead of JsonToken (enum value). + /// + /// Use of int directly is typically more efficient on switch statements, + /// so this method may be useful when building low-overhead codecs. + /// Note, however, that effect may not be big enough to matter: make sure + /// to profile performance before deciding to use this method. + ///@since 2.8 + ///@return {@code int} matching one of constants from JsonTokenId. + int currentTokenId() { + return _currentTokenId(reference).integer; + } + + static final _getCurrentToken = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getCurrentToken") + .asFunction)>(); + + /// from: public abstract com.fasterxml.jackson.core.JsonToken getCurrentToken() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Alias for \#currentToken(), may be deprecated sometime after + /// Jackson 2.13 (will be removed from 3.0). + ///@return Type of the token this parser currently points to, + /// if any: null before any tokens have been read, and + jsontoken_.JsonToken getCurrentToken() { + return const jsontoken_.$JsonTokenType() + .fromRef(_getCurrentToken(reference).object); + } + + static final _getCurrentTokenId = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getCurrentTokenId") + .asFunction)>(); + + /// from: public abstract int getCurrentTokenId() + /// + /// Deprecated alias for \#currentTokenId(). + ///@return {@code int} matching one of constants from JsonTokenId. + ///@deprecated Since 2.12 use \#currentTokenId instead + int getCurrentTokenId() { + return _getCurrentTokenId(reference).integer; + } + + static final _hasCurrentToken = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__hasCurrentToken") + .asFunction)>(); + + /// from: public abstract boolean hasCurrentToken() + /// + /// Method for checking whether parser currently points to + /// a token (and data for that token is available). + /// Equivalent to check for parser.getCurrentToken() != null. + ///@return True if the parser just returned a valid + /// token via \#nextToken; false otherwise (parser + /// was just constructed, encountered end-of-input + /// and returned null from \#nextToken, or the token + /// has been consumed) + bool hasCurrentToken() { + return _hasCurrentToken(reference).boolean; + } + + static final _hasTokenId = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Int32)>>("JsonParser__hasTokenId") + .asFunction, int)>(); + + /// from: public abstract boolean hasTokenId(int id) + /// + /// Method that is functionally equivalent to: + /// + /// return currentTokenId() == id + /// + /// but may be more efficiently implemented. + /// + /// Note that no traversal or conversion is performed; so in some + /// cases calling method like \#isExpectedStartArrayToken() + /// is necessary instead. + ///@param id Token id to match (from (@link JsonTokenId}) + ///@return {@code True} if the parser current points to specified token + ///@since 2.5 + bool hasTokenId( + int id, + ) { + return _hasTokenId(reference, id).boolean; + } + + static final _hasToken = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonParser__hasToken") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public abstract boolean hasToken(com.fasterxml.jackson.core.JsonToken t) + /// + /// Method that is functionally equivalent to: + /// + /// return currentToken() == t + /// + /// but may be more efficiently implemented. + /// + /// Note that no traversal or conversion is performed; so in some + /// cases calling method like \#isExpectedStartArrayToken() + /// is necessary instead. + ///@param t Token to match + ///@return {@code True} if the parser current points to specified token + ///@since 2.6 + bool hasToken( + jsontoken_.JsonToken t, + ) { + return _hasToken(reference, t.reference).boolean; + } + + static final _isExpectedStartArrayToken = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>( + "JsonParser__isExpectedStartArrayToken") + .asFunction)>(); + + /// from: public boolean isExpectedStartArrayToken() + /// + /// Specialized accessor that can be used to verify that the current + /// token indicates start array (usually meaning that current token + /// is JsonToken\#START_ARRAY) when start array is expected. + /// For some specialized parsers this can return true for other cases + /// as well; this is usually done to emulate arrays in cases underlying + /// format is ambiguous (XML, for example, has no format-level difference + /// between Objects and Arrays; it just has elements). + /// + /// Default implementation is equivalent to: + ///
    +  ///   currentToken() == JsonToken.START_ARRAY
    +  ///
    + /// but may be overridden by custom parser implementations. + ///@return True if the current token can be considered as a + /// start-array marker (such JsonToken\#START_ARRAY); + /// {@code false} if not + bool isExpectedStartArrayToken() { + return _isExpectedStartArrayToken(reference).boolean; + } + + static final _isExpectedStartObjectToken = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>( + "JsonParser__isExpectedStartObjectToken") + .asFunction)>(); + + /// from: public boolean isExpectedStartObjectToken() + /// + /// Similar to \#isExpectedStartArrayToken(), but checks whether stream + /// currently points to JsonToken\#START_OBJECT. + ///@return True if the current token can be considered as a + /// start-array marker (such JsonToken\#START_OBJECT); + /// {@code false} if not + ///@since 2.5 + bool isExpectedStartObjectToken() { + return _isExpectedStartObjectToken(reference).boolean; + } + + static final _isExpectedNumberIntToken = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>( + "JsonParser__isExpectedNumberIntToken") + .asFunction)>(); + + /// from: public boolean isExpectedNumberIntToken() + /// + /// Similar to \#isExpectedStartArrayToken(), but checks whether stream + /// currently points to JsonToken\#VALUE_NUMBER_INT. + /// + /// The initial use case is for XML backend to efficiently (attempt to) coerce + /// textual content into numbers. + ///@return True if the current token can be considered as a + /// start-array marker (such JsonToken\#VALUE_NUMBER_INT); + /// {@code false} if not + ///@since 2.12 + bool isExpectedNumberIntToken() { + return _isExpectedNumberIntToken(reference).boolean; + } + + static final _isNaN = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__isNaN") + .asFunction)>(); + + /// from: public boolean isNaN() + /// + /// Access for checking whether current token is a numeric value token, but + /// one that is of "not-a-number" (NaN) variety (including both "NaN" AND + /// positive/negative infinity!): not supported by all formats, + /// but often supported for JsonToken\#VALUE_NUMBER_FLOAT. + /// NOTE: roughly equivalent to calling !Double.isFinite() + /// on value you would get from calling \#getDoubleValue(). + ///@return {@code True} if the current token is of type JsonToken\#VALUE_NUMBER_FLOAT + /// but represents a "Not a Number"; {@code false} for other tokens and regular + /// floating-point numbers + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + ///@since 2.9 + bool isNaN() { + return _isNaN(reference).boolean; + } + + static final _clearCurrentToken = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__clearCurrentToken") + .asFunction)>(); + + /// from: public abstract void clearCurrentToken() + /// + /// Method called to "consume" the current token by effectively + /// removing it so that \#hasCurrentToken returns false, and + /// \#getCurrentToken null). + /// Cleared token value can still be accessed by calling + /// \#getLastClearedToken (if absolutely needed), but + /// usually isn't. + /// + /// Method was added to be used by the optional data binder, since + /// it has to be able to consume last token used for binding (so that + /// it will not be used again). + void clearCurrentToken() { + return _clearCurrentToken(reference).check(); + } + + static final _getLastClearedToken = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getLastClearedToken") + .asFunction)>(); + + /// from: public abstract com.fasterxml.jackson.core.JsonToken getLastClearedToken() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that can be called to get the last token that was + /// cleared using \#clearCurrentToken. This is not necessarily + /// the latest token read. + /// Will return null if no tokens have been cleared, + /// or if parser has been closed. + ///@return Last cleared token, if any; {@code null} otherwise + jsontoken_.JsonToken getLastClearedToken() { + return const jsontoken_.$JsonTokenType() + .fromRef(_getLastClearedToken(reference).object); + } + + static final _overrideCurrentName = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonParser__overrideCurrentName") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public abstract void overrideCurrentName(java.lang.String name) + /// + /// Method that can be used to change what is considered to be + /// the current (field) name. + /// May be needed to support non-JSON data formats or unusual binding + /// conventions; not needed for typical processing. + /// + /// Note that use of this method should only be done as sort of last + /// resort, as it is a work-around for regular operation. + ///@param name Name to use as the current name; may be null. + void overrideCurrentName( + jni.JString name, + ) { + return _overrideCurrentName(reference, name.reference).check(); + } + + static final _getCurrentName = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getCurrentName") + .asFunction)>(); + + /// from: public abstract java.lang.String getCurrentName() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Alias of \#currentName(). + ///@return Name of the current field in the parsing context + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + jni.JString getCurrentName() { + return const jni.JStringType().fromRef(_getCurrentName(reference).object); + } + + static final _currentName = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__currentName") + .asFunction)>(); + + /// from: public java.lang.String currentName() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that can be called to get the name associated with + /// the current token: for JsonToken\#FIELD_NAMEs it will + /// be the same as what \#getText returns; + /// for field values it will be preceding field name; + /// and for others (array values, root-level values) null. + ///@return Name of the current field in the parsing context + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + ///@since 2.10 + jni.JString currentName() { + return const jni.JStringType().fromRef(_currentName(reference).object); + } + + static final _getText = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getText") + .asFunction)>(); + + /// from: public abstract java.lang.String getText() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for accessing textual representation of the current token; + /// if no current token (before first call to \#nextToken, or + /// after encountering end-of-input), returns null. + /// Method can be called for any token type. + ///@return Textual value associated with the current token (one returned + /// by \#nextToken() or other iteration methods) + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + jni.JString getText() { + return const jni.JStringType().fromRef(_getText(reference).object); + } + + static final _getText1 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonParser__getText1") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public int getText(java.io.Writer writer) + /// + /// Method to read the textual representation of the current token in chunks and + /// pass it to the given Writer. + /// Conceptually same as calling: + ///
    +  ///  writer.write(parser.getText());
    +  ///
    + /// but should typically be more efficient as longer content does need to + /// be combined into a single String to return, and write + /// can occur directly from intermediate buffers Jackson uses. + ///@param writer Writer to write textual content to + ///@return The number of characters written to the Writer + ///@throws IOException for low-level read issues or writes using passed + /// {@code writer}, or + /// JsonParseException for decoding problems + ///@since 2.8 + int getText1( + jni.JObject writer, + ) { + return _getText1(reference, writer.reference).integer; + } + + static final _getTextCharacters = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getTextCharacters") + .asFunction)>(); + + /// from: public abstract char[] getTextCharacters() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method similar to \#getText, but that will return + /// underlying (unmodifiable) character array that contains + /// textual value, instead of constructing a String object + /// to contain this information. + /// Note, however, that: + ///
      + ///
    • Textual contents are not guaranteed to start at + /// index 0 (rather, call \#getTextOffset) to + /// know the actual offset + ///
    • + ///
    • Length of textual contents may be less than the + /// length of returned buffer: call \#getTextLength + /// for actual length of returned content. + ///
    • + ///
    + /// + /// Note that caller __MUST NOT__ modify the returned + /// character array in any way -- doing so may corrupt + /// current parser state and render parser instance useless. + /// + /// The only reason to call this method (over \#getText) + /// is to avoid construction of a String object (which + /// will make a copy of contents). + ///@return Buffer that contains the current textual value (but not necessarily + /// at offset 0, and not necessarily until the end of buffer) + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + jni.JArray getTextCharacters() { + return const jni.JArrayType(jni.JCharType()) + .fromRef(_getTextCharacters(reference).object); + } + + static final _getTextLength = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getTextLength") + .asFunction)>(); + + /// from: public abstract int getTextLength() + /// + /// Accessor used with \#getTextCharacters, to know length + /// of String stored in returned buffer. + ///@return Number of characters within buffer returned + /// by \#getTextCharacters that are part of + /// textual content of the current token. + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + int getTextLength() { + return _getTextLength(reference).integer; + } + + static final _getTextOffset = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getTextOffset") + .asFunction)>(); + + /// from: public abstract int getTextOffset() + /// + /// Accessor used with \#getTextCharacters, to know offset + /// of the first text content character within buffer. + ///@return Offset of the first character within buffer returned + /// by \#getTextCharacters that is part of + /// textual content of the current token. + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + int getTextOffset() { + return _getTextOffset(reference).integer; + } + + static final _hasTextCharacters = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__hasTextCharacters") + .asFunction)>(); + + /// from: public abstract boolean hasTextCharacters() + /// + /// Method that can be used to determine whether calling of + /// \#getTextCharacters would be the most efficient + /// way to access textual content for the event parser currently + /// points to. + /// + /// Default implementation simply returns false since only actual + /// implementation class has knowledge of its internal buffering + /// state. + /// Implementations are strongly encouraged to properly override + /// this method, to allow efficient copying of content by other + /// code. + ///@return True if parser currently has character array that can + /// be efficiently returned via \#getTextCharacters; false + /// means that it may or may not exist + bool hasTextCharacters() { + return _hasTextCharacters(reference).boolean; + } + + static final _getNumberValue = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getNumberValue") + .asFunction)>(); + + /// from: public abstract java.lang.Number getNumberValue() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Generic number value accessor method that will work for + /// all kinds of numeric values. It will return the optimal + /// (simplest/smallest possible) wrapper object that can + /// express the numeric value just parsed. + ///@return Numeric value of the current token in its most optimal + /// representation + ///@throws IOException Problem with access: JsonParseException if + /// the current token is not numeric, or if decoding of the value fails + /// (invalid format for numbers); plain IOException if underlying + /// content read fails (possible if values are extracted lazily) + jni.JObject getNumberValue() { + return const jni.JObjectType().fromRef(_getNumberValue(reference).object); + } + + static final _getNumberValueExact = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getNumberValueExact") + .asFunction)>(); + + /// from: public java.lang.Number getNumberValueExact() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method similar to \#getNumberValue with the difference that + /// for floating-point numbers value returned may be BigDecimal + /// if the underlying format does not store floating-point numbers using + /// native representation: for example, textual formats represent numbers + /// as Strings (which are 10-based), and conversion to java.lang.Double + /// is potentially lossy operation. + /// + /// Default implementation simply returns \#getNumberValue() + ///@return Numeric value of the current token using most accurate representation + ///@throws IOException Problem with access: JsonParseException if + /// the current token is not numeric, or if decoding of the value fails + /// (invalid format for numbers); plain IOException if underlying + /// content read fails (possible if values are extracted lazily) + ///@since 2.12 + jni.JObject getNumberValueExact() { + return const jni.JObjectType() + .fromRef(_getNumberValueExact(reference).object); + } + + static final _getNumberType = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getNumberType") + .asFunction)>(); + + /// from: public abstract com.fasterxml.jackson.core.JsonParser.NumberType getNumberType() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// If current token is of type + /// JsonToken\#VALUE_NUMBER_INT or + /// JsonToken\#VALUE_NUMBER_FLOAT, returns + /// one of NumberType constants; otherwise returns null. + ///@return Type of current number, if parser points to numeric token; {@code null} otherwise + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + JsonParser_NumberType getNumberType() { + return const $JsonParser_NumberTypeType() + .fromRef(_getNumberType(reference).object); + } + + static final _getByteValue = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getByteValue") + .asFunction)>(); + + /// from: public byte getByteValue() + /// + /// Numeric accessor that can be called when the current + /// token is of type JsonToken\#VALUE_NUMBER_INT and + /// it can be expressed as a value of Java byte primitive type. + /// Note that in addition to "natural" input range of {@code [-128, 127]}, + /// this also allows "unsigned 8-bit byte" values {@code [128, 255]}: + /// but for this range value will be translated by truncation, leading + /// to sign change. + /// + /// It can also be called for JsonToken\#VALUE_NUMBER_FLOAT; + /// if so, it is equivalent to calling \#getDoubleValue + /// and then casting; except for possible overflow/underflow + /// exception. + /// + /// Note: if the resulting integer value falls outside range of + /// {@code [-128, 255]}, + /// a InputCoercionException + /// will be thrown to indicate numeric overflow/underflow. + ///@return Current number value as {@code byte} (if numeric token within + /// range of {@code [-128, 255]}); otherwise exception thrown + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + int getByteValue() { + return _getByteValue(reference).byte; + } + + static final _getShortValue = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getShortValue") + .asFunction)>(); + + /// from: public short getShortValue() + /// + /// Numeric accessor that can be called when the current + /// token is of type JsonToken\#VALUE_NUMBER_INT and + /// it can be expressed as a value of Java short primitive type. + /// It can also be called for JsonToken\#VALUE_NUMBER_FLOAT; + /// if so, it is equivalent to calling \#getDoubleValue + /// and then casting; except for possible overflow/underflow + /// exception. + /// + /// Note: if the resulting integer value falls outside range of + /// Java short, a InputCoercionException + /// will be thrown to indicate numeric overflow/underflow. + ///@return Current number value as {@code short} (if numeric token within + /// Java 16-bit signed {@code short} range); otherwise exception thrown + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + int getShortValue() { + return _getShortValue(reference).short; + } + + static final _getIntValue = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getIntValue") + .asFunction)>(); + + /// from: public abstract int getIntValue() + /// + /// Numeric accessor that can be called when the current + /// token is of type JsonToken\#VALUE_NUMBER_INT and + /// it can be expressed as a value of Java int primitive type. + /// It can also be called for JsonToken\#VALUE_NUMBER_FLOAT; + /// if so, it is equivalent to calling \#getDoubleValue + /// and then casting; except for possible overflow/underflow + /// exception. + /// + /// Note: if the resulting integer value falls outside range of + /// Java {@code int}, a InputCoercionException + /// may be thrown to indicate numeric overflow/underflow. + ///@return Current number value as {@code int} (if numeric token within + /// Java 32-bit signed {@code int} range); otherwise exception thrown + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + int getIntValue() { + return _getIntValue(reference).integer; + } + + static final _getLongValue = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getLongValue") + .asFunction)>(); + + /// from: public abstract long getLongValue() + /// + /// Numeric accessor that can be called when the current + /// token is of type JsonToken\#VALUE_NUMBER_INT and + /// it can be expressed as a Java long primitive type. + /// It can also be called for JsonToken\#VALUE_NUMBER_FLOAT; + /// if so, it is equivalent to calling \#getDoubleValue + /// and then casting to int; except for possible overflow/underflow + /// exception. + /// + /// Note: if the token is an integer, but its value falls + /// outside of range of Java long, a InputCoercionException + /// may be thrown to indicate numeric overflow/underflow. + ///@return Current number value as {@code long} (if numeric token within + /// Java 32-bit signed {@code long} range); otherwise exception thrown + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + int getLongValue() { + return _getLongValue(reference).long; + } + + static final _getBigIntegerValue = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getBigIntegerValue") + .asFunction)>(); + + /// from: public abstract java.math.BigInteger getBigIntegerValue() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Numeric accessor that can be called when the current + /// token is of type JsonToken\#VALUE_NUMBER_INT and + /// it can not be used as a Java long primitive type due to its + /// magnitude. + /// It can also be called for JsonToken\#VALUE_NUMBER_FLOAT; + /// if so, it is equivalent to calling \#getDecimalValue + /// and then constructing a BigInteger from that value. + ///@return Current number value as BigInteger (if numeric token); + /// otherwise exception thrown + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + jni.JObject getBigIntegerValue() { + return const jni.JObjectType() + .fromRef(_getBigIntegerValue(reference).object); + } + + static final _getFloatValue = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getFloatValue") + .asFunction)>(); + + /// from: public abstract float getFloatValue() + /// + /// Numeric accessor that can be called when the current + /// token is of type JsonToken\#VALUE_NUMBER_FLOAT and + /// it can be expressed as a Java float primitive type. + /// It can also be called for JsonToken\#VALUE_NUMBER_INT; + /// if so, it is equivalent to calling \#getLongValue + /// and then casting; except for possible overflow/underflow + /// exception. + /// + /// Note: if the value falls + /// outside of range of Java float, a InputCoercionException + /// will be thrown to indicate numeric overflow/underflow. + ///@return Current number value as {@code float} (if numeric token within + /// Java {@code float} range); otherwise exception thrown + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + double getFloatValue() { + return _getFloatValue(reference).float; + } + + static final _getDoubleValue = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getDoubleValue") + .asFunction)>(); + + /// from: public abstract double getDoubleValue() + /// + /// Numeric accessor that can be called when the current + /// token is of type JsonToken\#VALUE_NUMBER_FLOAT and + /// it can be expressed as a Java double primitive type. + /// It can also be called for JsonToken\#VALUE_NUMBER_INT; + /// if so, it is equivalent to calling \#getLongValue + /// and then casting; except for possible overflow/underflow + /// exception. + /// + /// Note: if the value falls + /// outside of range of Java double, a InputCoercionException + /// will be thrown to indicate numeric overflow/underflow. + ///@return Current number value as {@code double} (if numeric token within + /// Java {@code double} range); otherwise exception thrown + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + double getDoubleValue() { + return _getDoubleValue(reference).doubleFloat; + } + + static final _getDecimalValue = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getDecimalValue") + .asFunction)>(); + + /// from: public abstract java.math.BigDecimal getDecimalValue() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Numeric accessor that can be called when the current + /// token is of type JsonToken\#VALUE_NUMBER_FLOAT or + /// JsonToken\#VALUE_NUMBER_INT. No under/overflow exceptions + /// are ever thrown. + ///@return Current number value as BigDecimal (if numeric token); + /// otherwise exception thrown + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + jni.JObject getDecimalValue() { + return const jni.JObjectType().fromRef(_getDecimalValue(reference).object); + } + + static final _getBooleanValue = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getBooleanValue") + .asFunction)>(); + + /// from: public boolean getBooleanValue() + /// + /// Convenience accessor that can be called when the current + /// token is JsonToken\#VALUE_TRUE or + /// JsonToken\#VALUE_FALSE, to return matching {@code boolean} + /// value. + /// If the current token is of some other type, JsonParseException + /// will be thrown + ///@return {@code True} if current token is {@code JsonToken.VALUE_TRUE}, + /// {@code false} if current token is {@code JsonToken.VALUE_FALSE}; + /// otherwise throws JsonParseException + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + bool getBooleanValue() { + return _getBooleanValue(reference).boolean; + } + + static final _getEmbeddedObject = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getEmbeddedObject") + .asFunction)>(); + + /// from: public java.lang.Object getEmbeddedObject() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Accessor that can be called if (and only if) the current token + /// is JsonToken\#VALUE_EMBEDDED_OBJECT. For other token types, + /// null is returned. + /// + /// Note: only some specialized parser implementations support + /// embedding of objects (usually ones that are facades on top + /// of non-streaming sources, such as object trees). One exception + /// is access to binary content (whether via base64 encoding or not) + /// which typically is accessible using this method, as well as + /// \#getBinaryValue(). + ///@return Embedded value (usually of "native" type supported by format) + /// for the current token, if any; {@code null otherwise} + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + jni.JObject getEmbeddedObject() { + return const jni.JObjectType() + .fromRef(_getEmbeddedObject(reference).object); + } + + static final _getBinaryValue = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonParser__getBinaryValue") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public abstract byte[] getBinaryValue(com.fasterxml.jackson.core.Base64Variant bv) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that can be used to read (and consume -- results + /// may not be accessible using other methods after the call) + /// base64-encoded binary data + /// included in the current textual JSON value. + /// It works similar to getting String value via \#getText + /// and decoding result (except for decoding part), + /// but should be significantly more performant. + /// + /// Note that non-decoded textual contents of the current token + /// are not guaranteed to be accessible after this method + /// is called. Current implementation, for example, clears up + /// textual content during decoding. + /// Decoded binary content, however, will be retained until + /// parser is advanced to the next event. + ///@param bv Expected variant of base64 encoded + /// content (see Base64Variants for definitions + /// of "standard" variants). + ///@return Decoded binary data + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + jni.JArray getBinaryValue( + jni.JObject bv, + ) { + return const jni.JArrayType(jni.JByteType()) + .fromRef(_getBinaryValue(reference, bv.reference).object); + } + + static final _getBinaryValue1 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getBinaryValue1") + .asFunction)>(); + + /// from: public byte[] getBinaryValue() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Convenience alternative to \#getBinaryValue(Base64Variant) + /// that defaults to using + /// Base64Variants\#getDefaultVariant as the default encoding. + ///@return Decoded binary data + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + jni.JArray getBinaryValue1() { + return const jni.JArrayType(jni.JByteType()) + .fromRef(_getBinaryValue1(reference).object); + } + + static final _readBinaryValue = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonParser__readBinaryValue") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public int readBinaryValue(java.io.OutputStream out) + /// + /// Method that can be used as an alternative to \#getBigIntegerValue(), + /// especially when value can be large. The main difference (beyond method + /// of returning content using OutputStream instead of as byte array) + /// is that content will NOT remain accessible after method returns: any content + /// processed will be consumed and is not buffered in any way. If caller needs + /// buffering, it has to implement it. + ///@param out Output stream to use for passing decoded binary data + ///@return Number of bytes that were decoded and written via OutputStream + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + ///@since 2.1 + int readBinaryValue( + jni.JObject out, + ) { + return _readBinaryValue(reference, out.reference).integer; + } + + static final _readBinaryValue1 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>("JsonParser__readBinaryValue1") + .asFunction< + jni.JniResult Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + /// from: public int readBinaryValue(com.fasterxml.jackson.core.Base64Variant bv, java.io.OutputStream out) + /// + /// Similar to \#readBinaryValue(OutputStream) but allows explicitly + /// specifying base64 variant to use. + ///@param bv base64 variant to use + ///@param out Output stream to use for passing decoded binary data + ///@return Number of bytes that were decoded and written via OutputStream + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + ///@since 2.1 + int readBinaryValue1( + jni.JObject bv, + jni.JObject out, + ) { + return _readBinaryValue1(reference, bv.reference, out.reference).integer; + } + + static final _getValueAsInt = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getValueAsInt") + .asFunction)>(); + + /// from: public int getValueAsInt() + /// + /// Method that will try to convert value of current token to a + /// Java {@code int} value. + /// Numbers are coerced using default Java rules; booleans convert to 0 (false) + /// and 1 (true), and Strings are parsed using default Java language integer + /// parsing rules. + /// + /// If representation can not be converted to an int (including structured type + /// markers like start/end Object/Array) + /// default value of __0__ will be returned; no exceptions are thrown. + ///@return {@code int} value current token is converted to, if possible; exception thrown + /// otherwise + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + int getValueAsInt() { + return _getValueAsInt(reference).integer; + } + + static final _getValueAsInt1 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Int32)>>("JsonParser__getValueAsInt1") + .asFunction, int)>(); + + /// from: public int getValueAsInt(int def) + /// + /// Method that will try to convert value of current token to a + /// __int__. + /// Numbers are coerced using default Java rules; booleans convert to 0 (false) + /// and 1 (true), and Strings are parsed using default Java language integer + /// parsing rules. + /// + /// If representation can not be converted to an int (including structured type + /// markers like start/end Object/Array) + /// specified __def__ will be returned; no exceptions are thrown. + ///@param def Default value to return if conversion to {@code int} is not possible + ///@return {@code int} value current token is converted to, if possible; {@code def} otherwise + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + int getValueAsInt1( + int def, + ) { + return _getValueAsInt1(reference, def).integer; + } + + static final _getValueAsLong = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getValueAsLong") + .asFunction)>(); + + /// from: public long getValueAsLong() + /// + /// Method that will try to convert value of current token to a + /// __long__. + /// Numbers are coerced using default Java rules; booleans convert to 0 (false) + /// and 1 (true), and Strings are parsed using default Java language integer + /// parsing rules. + /// + /// If representation can not be converted to a long (including structured type + /// markers like start/end Object/Array) + /// default value of __0L__ will be returned; no exceptions are thrown. + ///@return {@code long} value current token is converted to, if possible; exception thrown + /// otherwise + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + int getValueAsLong() { + return _getValueAsLong(reference).long; + } + + static final _getValueAsLong1 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Int64)>>("JsonParser__getValueAsLong1") + .asFunction, int)>(); + + /// from: public long getValueAsLong(long def) + /// + /// Method that will try to convert value of current token to a + /// __long__. + /// Numbers are coerced using default Java rules; booleans convert to 0 (false) + /// and 1 (true), and Strings are parsed using default Java language integer + /// parsing rules. + /// + /// If representation can not be converted to a long (including structured type + /// markers like start/end Object/Array) + /// specified __def__ will be returned; no exceptions are thrown. + ///@param def Default value to return if conversion to {@code long} is not possible + ///@return {@code long} value current token is converted to, if possible; {@code def} otherwise + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + int getValueAsLong1( + int def, + ) { + return _getValueAsLong1(reference, def).long; + } + + static final _getValueAsDouble = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getValueAsDouble") + .asFunction)>(); + + /// from: public double getValueAsDouble() + /// + /// Method that will try to convert value of current token to a Java + /// __double__. + /// Numbers are coerced using default Java rules; booleans convert to 0.0 (false) + /// and 1.0 (true), and Strings are parsed using default Java language floating + /// point parsing rules. + /// + /// If representation can not be converted to a double (including structured types + /// like Objects and Arrays), + /// default value of __0.0__ will be returned; no exceptions are thrown. + ///@return {@code double} value current token is converted to, if possible; exception thrown + /// otherwise + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + double getValueAsDouble() { + return _getValueAsDouble(reference).doubleFloat; + } + + static final _getValueAsDouble1 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Double)>>("JsonParser__getValueAsDouble1") + .asFunction, double)>(); + + /// from: public double getValueAsDouble(double def) + /// + /// Method that will try to convert value of current token to a + /// Java __double__. + /// Numbers are coerced using default Java rules; booleans convert to 0.0 (false) + /// and 1.0 (true), and Strings are parsed using default Java language floating + /// point parsing rules. + /// + /// If representation can not be converted to a double (including structured types + /// like Objects and Arrays), + /// specified __def__ will be returned; no exceptions are thrown. + ///@param def Default value to return if conversion to {@code double} is not possible + ///@return {@code double} value current token is converted to, if possible; {@code def} otherwise + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + double getValueAsDouble1( + double def, + ) { + return _getValueAsDouble1(reference, def).doubleFloat; + } + + static final _getValueAsBoolean = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getValueAsBoolean") + .asFunction)>(); + + /// from: public boolean getValueAsBoolean() + /// + /// Method that will try to convert value of current token to a + /// __boolean__. + /// JSON booleans map naturally; integer numbers other than 0 map to true, and + /// 0 maps to false + /// and Strings 'true' and 'false' map to corresponding values. + /// + /// If representation can not be converted to a boolean value (including structured types + /// like Objects and Arrays), + /// default value of __false__ will be returned; no exceptions are thrown. + ///@return {@code boolean} value current token is converted to, if possible; exception thrown + /// otherwise + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + bool getValueAsBoolean() { + return _getValueAsBoolean(reference).boolean; + } + + static final _getValueAsBoolean1 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Uint8)>>("JsonParser__getValueAsBoolean1") + .asFunction, int)>(); + + /// from: public boolean getValueAsBoolean(boolean def) + /// + /// Method that will try to convert value of current token to a + /// __boolean__. + /// JSON booleans map naturally; integer numbers other than 0 map to true, and + /// 0 maps to false + /// and Strings 'true' and 'false' map to corresponding values. + /// + /// If representation can not be converted to a boolean value (including structured types + /// like Objects and Arrays), + /// specified __def__ will be returned; no exceptions are thrown. + ///@param def Default value to return if conversion to {@code boolean} is not possible + ///@return {@code boolean} value current token is converted to, if possible; {@code def} otherwise + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + bool getValueAsBoolean1( + bool def, + ) { + return _getValueAsBoolean1(reference, def ? 1 : 0).boolean; + } + + static final _getValueAsString = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getValueAsString") + .asFunction)>(); + + /// from: public java.lang.String getValueAsString() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that will try to convert value of current token to a + /// java.lang.String. + /// JSON Strings map naturally; scalar values get converted to + /// their textual representation. + /// If representation can not be converted to a String value (including structured types + /// like Objects and Arrays and {@code null} token), default value of + /// __null__ will be returned; no exceptions are thrown. + ///@return String value current token is converted to, if possible; {@code null} otherwise + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + ///@since 2.1 + jni.JString getValueAsString() { + return const jni.JStringType().fromRef(_getValueAsString(reference).object); + } + + static final _getValueAsString1 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonParser__getValueAsString1") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public abstract java.lang.String getValueAsString(java.lang.String def) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that will try to convert value of current token to a + /// java.lang.String. + /// JSON Strings map naturally; scalar values get converted to + /// their textual representation. + /// If representation can not be converted to a String value (including structured types + /// like Objects and Arrays and {@code null} token), specified default value + /// will be returned; no exceptions are thrown. + ///@param def Default value to return if conversion to {@code String} is not possible + ///@return String value current token is converted to, if possible; {@code def} otherwise + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + ///@since 2.1 + jni.JString getValueAsString1( + jni.JString def, + ) { + return const jni.JStringType() + .fromRef(_getValueAsString1(reference, def.reference).object); + } + + static final _canReadObjectId = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__canReadObjectId") + .asFunction)>(); + + /// from: public boolean canReadObjectId() + /// + /// Introspection method that may be called to see if the underlying + /// data format supports some kind of Object Ids natively (many do not; + /// for example, JSON doesn't). + /// + /// Default implementation returns true; overridden by data formats + /// that do support native Object Ids. Caller is expected to either + /// use a non-native notation (explicit property or such), or fail, + /// in case it can not use native object ids. + ///@return {@code True} if the format being read supports native Object Ids; + /// {@code false} if not + ///@since 2.3 + bool canReadObjectId() { + return _canReadObjectId(reference).boolean; + } + + static final _canReadTypeId = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__canReadTypeId") + .asFunction)>(); + + /// from: public boolean canReadTypeId() + /// + /// Introspection method that may be called to see if the underlying + /// data format supports some kind of Type Ids natively (many do not; + /// for example, JSON doesn't). + /// + /// Default implementation returns true; overridden by data formats + /// that do support native Type Ids. Caller is expected to either + /// use a non-native notation (explicit property or such), or fail, + /// in case it can not use native type ids. + ///@return {@code True} if the format being read supports native Type Ids; + /// {@code false} if not + ///@since 2.3 + bool canReadTypeId() { + return _canReadTypeId(reference).boolean; + } + + static final _getObjectId = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getObjectId") + .asFunction)>(); + + /// from: public java.lang.Object getObjectId() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that can be called to check whether current token + /// (one that was just read) has an associated Object id, and if + /// so, return it. + /// Note that while typically caller should check with \#canReadObjectId + /// first, it is not illegal to call this method even if that method returns + /// true; but if so, it will return null. This may be used to simplify calling + /// code. + /// + /// Default implementation will simply return null. + ///@return Native Object id associated with the current token, if any; {@code null} if none + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + ///@since 2.3 + jni.JObject getObjectId() { + return const jni.JObjectType().fromRef(_getObjectId(reference).object); + } + + static final _getTypeId = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__getTypeId") + .asFunction)>(); + + /// from: public java.lang.Object getTypeId() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that can be called to check whether current token + /// (one that was just read) has an associated type id, and if + /// so, return it. + /// Note that while typically caller should check with \#canReadTypeId + /// first, it is not illegal to call this method even if that method returns + /// true; but if so, it will return null. This may be used to simplify calling + /// code. + /// + /// Default implementation will simply return null. + ///@return Native Type Id associated with the current token, if any; {@code null} if none + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + ///@since 2.3 + jni.JObject getTypeId() { + return const jni.JObjectType().fromRef(_getTypeId(reference).object); + } + + static final _readValueAs = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonParser__readValueAs") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public T readValueAs(java.lang.Class valueType) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method to deserialize JSON content into a non-container + /// type (it can be an array type, however): typically a bean, array + /// or a wrapper type (like java.lang.Boolean). + /// __Note__: method can only be called if the parser has + /// an object codec assigned; this is true for parsers constructed + /// by MappingJsonFactory (from "jackson-databind" jar) + /// but not for JsonFactory (unless its setCodec + /// method has been explicitly called). + /// + /// This method may advance the event stream, for structured types + /// the current token will be the closing end marker (END_ARRAY, + /// END_OBJECT) of the bound structure. For non-structured Json types + /// (and for JsonToken\#VALUE_EMBEDDED_OBJECT) + /// stream is not advanced. + /// + /// Note: this method should NOT be used if the result type is a + /// container (java.util.Collection or java.util.Map. + /// The reason is that due to type erasure, key and value types + /// can not be introspected when using this method. + ///@param Nominal type parameter for value type + ///@param valueType Java type to read content as (passed to ObjectCodec that + /// deserializes content) + ///@return Java value read from content + ///@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.JObjType<$T> T, + }) { + return T.fromRef(_readValueAs(reference, valueType.reference).object); + } + + static final _readValueAs1 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonParser__readValueAs1") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public T readValueAs(com.fasterxml.jackson.core.type.TypeReference valueTypeRef) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method to deserialize JSON content into a Java type, reference + /// to which is passed as argument. Type is passed using so-called + /// "super type token" + /// and specifically needs to be used if the root type is a + /// parameterized (generic) container type. + /// __Note__: method can only be called if the parser has + /// an object codec assigned; this is true for parsers constructed + /// by MappingJsonFactory (defined in 'jackson-databind' bundle) + /// but not for JsonFactory (unless its setCodec + /// method has been explicitly called). + /// + /// This method may advance the event stream, for structured types + /// the current token will be the closing end marker (END_ARRAY, + /// END_OBJECT) of the bound structure. For non-structured Json types + /// (and for JsonToken\#VALUE_EMBEDDED_OBJECT) + /// stream is not advanced. + ///@param Nominal type parameter for value type + ///@param valueTypeRef Java type to read content as (passed to ObjectCodec that + /// deserializes content) + ///@return Java value read from content + ///@throws IOException if there is either an underlying I/O problem or decoding + /// issue at format layer + $T readValueAs1<$T extends jni.JObject>( + jni.JObject valueTypeRef, { + required jni.JObjType<$T> T, + }) { + return T.fromRef(_readValueAs1(reference, valueTypeRef.reference).object); + } + + static final _readValuesAs = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonParser__readValuesAs") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public java.util.Iterator readValuesAs(java.lang.Class valueType) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for reading sequence of Objects from parser stream, + /// all with same specified value type. + ///@param Nominal type parameter for value type + ///@param valueType Java type to read content as (passed to ObjectCodec that + /// deserializes content) + ///@return Iterator for reading multiple Java values from content + ///@throws IOException if there is either an underlying I/O problem or decoding + /// issue at format layer + jni.JObject readValuesAs<$T extends jni.JObject>( + jni.JObject valueType, { + required jni.JObjType<$T> T, + }) { + return const jni.JObjectType() + .fromRef(_readValuesAs(reference, valueType.reference).object); + } + + static final _readValuesAs1 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("JsonParser__readValuesAs1") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public java.util.Iterator readValuesAs(com.fasterxml.jackson.core.type.TypeReference valueTypeRef) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for reading sequence of Objects from parser stream, + /// all with same specified value type. + ///@param Nominal type parameter for value type + ///@param valueTypeRef Java type to read content as (passed to ObjectCodec that + /// deserializes content) + ///@return Iterator for reading multiple Java values from content + ///@throws IOException if there is either an underlying I/O problem or decoding + /// issue at format layer + jni.JObject readValuesAs1<$T extends jni.JObject>( + jni.JObject valueTypeRef, { + required jni.JObjType<$T> T, + }) { + return const jni.JObjectType() + .fromRef(_readValuesAs1(reference, valueTypeRef.reference).object); + } + + static final _readValueAsTree = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser__readValueAsTree") + .asFunction)>(); + + /// from: public T readValueAsTree() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method to deserialize JSON content into equivalent "tree model", + /// represented by root TreeNode of resulting model. + /// For JSON Arrays it will an array node (with child nodes), + /// for objects object node (with child nodes), and for other types + /// matching leaf node type. Empty or whitespace documents are null. + ///@param Nominal type parameter for result node type (to reduce need for casting) + ///@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.JObjType<$T> T, + }) { + return T.fromRef(_readValueAsTree(reference).object); + } +} + +class $JsonParserType extends jni.JObjType { + const $JsonParserType(); + + @override + String get signature => r"Lcom/fasterxml/jackson/core/JsonParser;"; + + @override + JsonParser fromRef(jni.JObjectPtr ref) => JsonParser.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($JsonParserType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $JsonParserType && other is $JsonParserType; + } +} + +/// from: com.fasterxml.jackson.core.JsonParser$Feature +/// +/// Enumeration that defines all on/off features for parsers. +class JsonParser_Feature extends jni.JObject { + @override + late final jni.JObjType $type = type; + + JsonParser_Feature.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = $JsonParser_FeatureType(); + static final _values = + jniLookup>( + "JsonParser_Feature__values") + .asFunction(); + + /// from: static public com.fasterxml.jackson.core.JsonParser.Feature[] values() + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JArray values() { + return const jni.JArrayType($JsonParser_FeatureType()) + .fromRef(_values().object); + } + + static final _valueOf = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser_Feature__valueOf") + .asFunction)>(); + + /// from: static public com.fasterxml.jackson.core.JsonParser.Feature valueOf(java.lang.String name) + /// The returned object must be deleted after use, by calling the `delete` method. + static JsonParser_Feature valueOf( + jni.JString name, + ) { + return const $JsonParser_FeatureType() + .fromRef(_valueOf(name.reference).object); + } + + static final _collectDefaults = + jniLookup>( + "JsonParser_Feature__collectDefaults") + .asFunction(); + + /// from: static public int collectDefaults() + /// + /// Method that calculates bit set (flags) of all features that + /// are enabled by default. + ///@return Bit mask of all features that are enabled by default + static int collectDefaults() { + return _collectDefaults().integer; + } + + static final _enabledByDefault = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>( + "JsonParser_Feature__enabledByDefault") + .asFunction)>(); + + /// from: public boolean enabledByDefault() + bool enabledByDefault() { + return _enabledByDefault(reference).boolean; + } + + static final _enabledIn = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Int32)>>("JsonParser_Feature__enabledIn") + .asFunction, int)>(); + + /// from: public boolean enabledIn(int flags) + bool enabledIn( + int flags, + ) { + return _enabledIn(reference, flags).boolean; + } + + static final _getMask = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser_Feature__getMask") + .asFunction)>(); + + /// from: public int getMask() + int getMask() { + return _getMask(reference).integer; + } +} + +class $JsonParser_FeatureType extends jni.JObjType { + const $JsonParser_FeatureType(); + + @override + String get signature => r"Lcom/fasterxml/jackson/core/JsonParser$Feature;"; + + @override + JsonParser_Feature fromRef(jni.JObjectPtr ref) => + JsonParser_Feature.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($JsonParser_FeatureType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $JsonParser_FeatureType && + other is $JsonParser_FeatureType; + } +} + +/// 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 { + @override + late final jni.JObjType $type = type; + + JsonParser_NumberType.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = $JsonParser_NumberTypeType(); + static final _values = + jniLookup>( + "JsonParser_NumberType__values") + .asFunction(); + + /// from: static public com.fasterxml.jackson.core.JsonParser.NumberType[] values() + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JArray values() { + return const jni.JArrayType($JsonParser_NumberTypeType()) + .fromRef(_values().object); + } + + static final _valueOf = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonParser_NumberType__valueOf") + .asFunction)>(); + + /// from: static public com.fasterxml.jackson.core.JsonParser.NumberType valueOf(java.lang.String name) + /// The returned object must be deleted after use, by calling the `delete` method. + static JsonParser_NumberType valueOf( + jni.JString name, + ) { + return const $JsonParser_NumberTypeType() + .fromRef(_valueOf(name.reference).object); + } +} + +class $JsonParser_NumberTypeType extends jni.JObjType { + const $JsonParser_NumberTypeType(); + + @override + String get signature => r"Lcom/fasterxml/jackson/core/JsonParser$NumberType;"; + + @override + JsonParser_NumberType fromRef(jni.JObjectPtr ref) => + JsonParser_NumberType.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($JsonParser_NumberTypeType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $JsonParser_NumberTypeType && + other is $JsonParser_NumberTypeType; + } +} diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart new file mode 100644 index 000000000..071434444 --- /dev/null +++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart @@ -0,0 +1,235 @@ +// Generated from jackson-core which is licensed under the Apache License 2.0. +// The following copyright from the original authors applies. +// See https://github.com/FasterXML/jackson-core/blob/2.14/LICENSE +// +// Copyright (c) 2007 - The Jackson Project Authors +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Autogenerated by jnigen. DO NOT EDIT! + +// ignore_for_file: annotate_overrides +// ignore_for_file: camel_case_extensions +// ignore_for_file: camel_case_types +// ignore_for_file: constant_identifier_names +// ignore_for_file: file_names +// ignore_for_file: no_leading_underscores_for_local_identifiers +// ignore_for_file: non_constant_identifier_names +// ignore_for_file: overridden_fields +// ignore_for_file: unnecessary_cast +// ignore_for_file: unused_element +// ignore_for_file: unused_field +// ignore_for_file: unused_import +// ignore_for_file: unused_shown_name + +import "dart:isolate" show ReceivePort; +import "dart:ffi" as ffi; +import "package:jni/internal_helpers_for_jnigen.dart"; +import "package:jni/jni.dart" as jni; + +import "../../../../_init.dart"; + +/// from: com.fasterxml.jackson.core.JsonToken +/// +/// Enumeration for basic token types used for returning results +/// of parsing JSON content. +class JsonToken extends jni.JObject { + @override + late final jni.JObjType $type = type; + + JsonToken.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = $JsonTokenType(); + static final _values = + jniLookup>( + "JsonToken__values") + .asFunction(); + + /// from: static public com.fasterxml.jackson.core.JsonToken[] values() + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JArray values() { + return const jni.JArrayType($JsonTokenType()).fromRef(_values().object); + } + + static final _valueOf = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonToken__valueOf") + .asFunction)>(); + + /// from: static public com.fasterxml.jackson.core.JsonToken valueOf(java.lang.String name) + /// The returned object must be deleted after use, by calling the `delete` method. + static JsonToken valueOf( + jni.JString name, + ) { + return const $JsonTokenType().fromRef(_valueOf(name.reference).object); + } + + static final _id = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>("JsonToken__id") + .asFunction)>(); + + /// from: public final int id() + int id() { + return _id(reference).integer; + } + + static final _asString = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonToken__asString") + .asFunction)>(); + + /// from: public final java.lang.String asString() + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JString asString() { + return const jni.JStringType().fromRef(_asString(reference).object); + } + + static final _asCharArray = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonToken__asCharArray") + .asFunction)>(); + + /// from: public final char[] asCharArray() + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JArray asCharArray() { + return const jni.JArrayType(jni.JCharType()) + .fromRef(_asCharArray(reference).object); + } + + static final _asByteArray = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonToken__asByteArray") + .asFunction)>(); + + /// from: public final byte[] asByteArray() + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JArray asByteArray() { + return const jni.JArrayType(jni.JByteType()) + .fromRef(_asByteArray(reference).object); + } + + static final _isNumeric = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonToken__isNumeric") + .asFunction)>(); + + /// from: public final boolean isNumeric() + /// + /// @return {@code True} if this token is {@code VALUE_NUMBER_INT} or {@code VALUE_NUMBER_FLOAT}, + /// {@code false} otherwise + bool isNumeric() { + return _isNumeric(reference).boolean; + } + + static final _isStructStart = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonToken__isStructStart") + .asFunction)>(); + + /// from: public final boolean isStructStart() + /// + /// Accessor that is functionally equivalent to: + /// + /// this == JsonToken.START_OBJECT || this == JsonToken.START_ARRAY + /// + ///@return {@code True} if this token is {@code START_OBJECT} or {@code START_ARRAY}, + /// {@code false} otherwise + ///@since 2.3 + bool isStructStart() { + return _isStructStart(reference).boolean; + } + + static final _isStructEnd = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonToken__isStructEnd") + .asFunction)>(); + + /// from: public final boolean isStructEnd() + /// + /// Accessor that is functionally equivalent to: + /// + /// this == JsonToken.END_OBJECT || this == JsonToken.END_ARRAY + /// + ///@return {@code True} if this token is {@code END_OBJECT} or {@code END_ARRAY}, + /// {@code false} otherwise + ///@since 2.3 + bool isStructEnd() { + return _isStructEnd(reference).boolean; + } + + static final _isScalarValue = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonToken__isScalarValue") + .asFunction)>(); + + /// from: public final boolean isScalarValue() + /// + /// Method that can be used to check whether this token represents + /// a valid non-structured value. This means all {@code VALUE_xxx} tokens; + /// excluding {@code START_xxx} and {@code END_xxx} tokens as well + /// {@code FIELD_NAME}. + ///@return {@code True} if this token is a scalar value token (one of + /// {@code VALUE_xxx} tokens), {@code false} otherwise + bool isScalarValue() { + return _isScalarValue(reference).boolean; + } + + static final _isBoolean = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("JsonToken__isBoolean") + .asFunction)>(); + + /// from: public final boolean isBoolean() + /// + /// @return {@code True} if this token is {@code VALUE_TRUE} or {@code VALUE_FALSE}, + /// {@code false} otherwise + bool isBoolean() { + return _isBoolean(reference).boolean; + } +} + +class $JsonTokenType extends jni.JObjType { + const $JsonTokenType(); + + @override + String get signature => r"Lcom/fasterxml/jackson/core/JsonToken;"; + + @override + JsonToken fromRef(jni.JObjectPtr ref) => JsonToken.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($JsonTokenType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $JsonTokenType && other is $JsonTokenType; + } +} diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/_package.dart b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/_package.dart similarity index 100% rename from pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/_package.dart rename to pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/_package.dart diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/lib/_init.dart b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/_init.dart similarity index 100% rename from pkgs/jnigen/test/jackson_core_test/third_party/lib/_init.dart rename to pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/_init.dart diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonFactory.dart b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart similarity index 100% rename from pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonFactory.dart rename to pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonParser.dart b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart similarity index 100% rename from pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonParser.dart rename to pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonToken.dart b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart similarity index 100% rename from pkgs/jnigen/test/jackson_core_test/third_party/lib/com/fasterxml/jackson/core/JsonToken.dart rename to pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/_package.dart b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/_package.dart new file mode 100644 index 000000000..cae2a52e6 --- /dev/null +++ b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/_package.dart @@ -0,0 +1,3 @@ +export "JsonFactory.dart"; +export "JsonParser.dart"; +export "JsonToken.dart"; diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/_init.dart b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/_init.dart new file mode 100644 index 000000000..eec3a8c14 --- /dev/null +++ b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/_init.dart @@ -0,0 +1,23 @@ +// Generated from jackson-core which is licensed under the Apache License 2.0. +// The following copyright from the original authors applies. +// See https://github.com/FasterXML/jackson-core/blob/2.14/LICENSE +// +// Copyright (c) 2007 - The Jackson Project Authors +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import "package:jni/jni.dart" as jni; + +// Auto-generated initialization code. + +final jniEnv = jni.Jni.env; +final jniAccessors = jni.Jni.accessors; diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/com/fasterxml/jackson/core/JsonFactory.dart b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/com/fasterxml/jackson/core/JsonFactory.dart new file mode 100644 index 000000000..2ceb3242b --- /dev/null +++ b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/com/fasterxml/jackson/core/JsonFactory.dart @@ -0,0 +1,1879 @@ +// Generated from jackson-core which is licensed under the Apache License 2.0. +// The following copyright from the original authors applies. +// See https://github.com/FasterXML/jackson-core/blob/2.14/LICENSE +// +// Copyright (c) 2007 - The Jackson Project Authors +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Autogenerated by jnigen. DO NOT EDIT! + +// ignore_for_file: annotate_overrides +// ignore_for_file: camel_case_extensions +// ignore_for_file: camel_case_types +// ignore_for_file: constant_identifier_names +// ignore_for_file: file_names +// ignore_for_file: no_leading_underscores_for_local_identifiers +// ignore_for_file: non_constant_identifier_names +// ignore_for_file: overridden_fields +// ignore_for_file: unnecessary_cast +// ignore_for_file: unused_element +// ignore_for_file: unused_field +// ignore_for_file: unused_import +// ignore_for_file: unused_shown_name + +import "dart:isolate" show ReceivePort; +import "dart:ffi" as ffi; +import "package:jni/internal_helpers_for_jnigen.dart"; +import "package:jni/jni.dart" as jni; + +import "JsonParser.dart" as jsonparser_; +import "../../../../_init.dart"; + +/// from: com.fasterxml.jackson.core.JsonFactory +/// +/// The main factory class of Jackson package, used to configure and +/// construct reader (aka parser, JsonParser) +/// and writer (aka generator, JsonGenerator) +/// instances. +/// +/// Factory instances are thread-safe and reusable after configuration +/// (if any). Typically applications and services use only a single +/// globally shared factory instance, unless they need differently +/// configured factories. Factory reuse is important if efficiency matters; +/// most recycling of expensive construct is done on per-factory basis. +/// +/// Creation of a factory instance is a light-weight operation, +/// and since there is no need for pluggable alternative implementations +/// (as there is no "standard" JSON processor API to implement), +/// the default constructor is used for constructing factory +/// instances. +///@author Tatu Saloranta +class JsonFactory extends jni.JObject { + @override + late final jni.JObjType $type = type; + + JsonFactory.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + static final _classRef = + jniAccessors.getClassOf(r"com/fasterxml/jackson/core/JsonFactory"); + + /// The type which includes information such as the signature of this class. + static const type = $JsonFactoryType(); + + /// from: static public final java.lang.String FORMAT_NAME_JSON + /// + /// Name used to identify JSON format + /// (and returned by \#getFormatName() + static const FORMAT_NAME_JSON = r"""JSON"""; + + static final _id_DEFAULT_FACTORY_FEATURE_FLAGS = + jniAccessors.getStaticFieldIDOf( + _classRef, + r"DEFAULT_FACTORY_FEATURE_FLAGS", + r"I", + ); + + /// from: static protected final int DEFAULT_FACTORY_FEATURE_FLAGS + /// + /// Bitfield (set of flags) of all factory features that are enabled by default. + static int get DEFAULT_FACTORY_FEATURE_FLAGS => jniAccessors + .getStaticField( + _classRef, _id_DEFAULT_FACTORY_FEATURE_FLAGS, jni.JniCallType.intType) + .integer; + + static final _id_DEFAULT_PARSER_FEATURE_FLAGS = + jniAccessors.getStaticFieldIDOf( + _classRef, + r"DEFAULT_PARSER_FEATURE_FLAGS", + r"I", + ); + + /// from: static protected final int DEFAULT_PARSER_FEATURE_FLAGS + /// + /// Bitfield (set of flags) of all parser features that are enabled + /// by default. + static int get DEFAULT_PARSER_FEATURE_FLAGS => jniAccessors + .getStaticField( + _classRef, _id_DEFAULT_PARSER_FEATURE_FLAGS, jni.JniCallType.intType) + .integer; + + static final _id_DEFAULT_GENERATOR_FEATURE_FLAGS = + jniAccessors.getStaticFieldIDOf( + _classRef, + r"DEFAULT_GENERATOR_FEATURE_FLAGS", + r"I", + ); + + /// from: static protected final int DEFAULT_GENERATOR_FEATURE_FLAGS + /// + /// Bitfield (set of flags) of all generator features that are enabled + /// by default. + static int get DEFAULT_GENERATOR_FEATURE_FLAGS => jniAccessors + .getStaticField(_classRef, _id_DEFAULT_GENERATOR_FEATURE_FLAGS, + jni.JniCallType.intType) + .integer; + + static final _id_DEFAULT_ROOT_VALUE_SEPARATOR = + jniAccessors.getStaticFieldIDOf( + _classRef, + r"DEFAULT_ROOT_VALUE_SEPARATOR", + r"Lcom/fasterxml/jackson/core/SerializableString;", + ); + + /// from: static public final com.fasterxml.jackson.core.SerializableString DEFAULT_ROOT_VALUE_SEPARATOR + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JObject get DEFAULT_ROOT_VALUE_SEPARATOR => + const jni.JObjectType().fromRef(jniAccessors + .getStaticField(_classRef, _id_DEFAULT_ROOT_VALUE_SEPARATOR, + jni.JniCallType.objectType) + .object); + + static final _id_ctor = + jniAccessors.getMethodIDOf(_classRef, r"", r"()V"); + + /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Default constructor used to create factory instances. + /// Creation of a factory instance is a light-weight operation, + /// but it is still a good idea to reuse limited number of + /// factory instances (and quite often just a single instance): + /// factories are used as context for storing some reused + /// processing objects (such as symbol tables parsers use) + /// and this reuse only works within context of a single + /// factory instance. + factory JsonFactory() { + return JsonFactory.fromRef( + jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); + } + + static final _id_ctor1 = jniAccessors.getMethodIDOf( + _classRef, r"", r"(Lcom/fasterxml/jackson/core/ObjectCodec;)V"); + + /// from: public void (com.fasterxml.jackson.core.ObjectCodec oc) + /// The returned object must be deleted after use, by calling the `delete` method. + factory JsonFactory.ctor1( + jni.JObject oc, + ) { + return JsonFactory.fromRef(jniAccessors + .newObjectWithArgs(_classRef, _id_ctor1, [oc.reference]).object); + } + + static final _id_ctor2 = jniAccessors.getMethodIDOf(_classRef, r"", + r"(Lcom/fasterxml/jackson/core/JsonFactory;Lcom/fasterxml/jackson/core/ObjectCodec;)V"); + + /// from: protected void (com.fasterxml.jackson.core.JsonFactory src, com.fasterxml.jackson.core.ObjectCodec codec) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Constructor used when copy()ing a factory instance. + ///@param src Original factory to copy settings from + ///@param codec Databinding-level codec to use, if any + ///@since 2.2.1 + factory JsonFactory.ctor2( + JsonFactory src, + jni.JObject codec, + ) { + return JsonFactory.fromRef(jniAccessors.newObjectWithArgs( + _classRef, _id_ctor2, [src.reference, codec.reference]).object); + } + + static final _id_ctor3 = jniAccessors.getMethodIDOf(_classRef, r"", + r"(Lcom/fasterxml/jackson/core/JsonFactoryBuilder;)V"); + + /// from: public void (com.fasterxml.jackson.core.JsonFactoryBuilder b) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Constructor used by JsonFactoryBuilder for instantiation. + ///@param b Builder that contains settings to use + ///@since 2.10 + factory JsonFactory.ctor3( + jni.JObject b, + ) { + return JsonFactory.fromRef(jniAccessors + .newObjectWithArgs(_classRef, _id_ctor3, [b.reference]).object); + } + + static final _id_ctor4 = jniAccessors.getMethodIDOf( + _classRef, r"", r"(Lcom/fasterxml/jackson/core/TSFBuilder;Z)V"); + + /// from: protected void (com.fasterxml.jackson.core.TSFBuilder b, boolean bogus) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Constructor for subtypes; needed to work around the fact that before 3.0, + /// this factory has cumbersome dual role as generic type as well as actual + /// implementation for json. + ///@param b Builder that contains settings to use + ///@param bogus Argument only needed to separate constructor signature; ignored + factory JsonFactory.ctor4( + jni.JObject b, + bool bogus, + ) { + return JsonFactory.fromRef(jniAccessors.newObjectWithArgs( + _classRef, _id_ctor4, [b.reference, bogus ? 1 : 0]).object); + } + + static final _id_rebuild = jniAccessors.getMethodIDOf( + _classRef, r"rebuild", r"()Lcom/fasterxml/jackson/core/TSFBuilder;"); + + /// from: public com.fasterxml.jackson.core.TSFBuilder rebuild() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that allows construction of differently configured factory, starting + /// with settings of this factory. + ///@return Builder instance to use + ///@since 2.10 + jni.JObject rebuild() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_rebuild, jni.JniCallType.objectType, []).object); + } + + static final _id_builder = jniAccessors.getStaticMethodIDOf( + _classRef, r"builder", r"()Lcom/fasterxml/jackson/core/TSFBuilder;"); + + /// from: static public com.fasterxml.jackson.core.TSFBuilder builder() + /// The returned object must be deleted after use, by calling the `delete` 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. + ///@return Builder instance to use + static jni.JObject builder() { + return const jni.JObjectType().fromRef(jniAccessors + .callStaticMethodWithArgs( + _classRef, _id_builder, jni.JniCallType.objectType, []).object); + } + + static final _id_copy = jniAccessors.getMethodIDOf( + _classRef, r"copy", r"()Lcom/fasterxml/jackson/core/JsonFactory;"); + + /// from: public com.fasterxml.jackson.core.JsonFactory copy() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing a new JsonFactory that has + /// the same settings as this instance, but is otherwise + /// independent (i.e. nothing is actually shared, symbol tables + /// are separate). + /// Note that ObjectCodec reference is not copied but is + /// set to null; caller typically needs to set it after calling + /// this method. Reason for this is that the codec is used for + /// callbacks, and assumption is that there is strict 1-to-1 + /// mapping between codec, factory. Caller has to, then, explicitly + /// set codec after making the copy. + ///@return Copy of this factory instance + ///@since 2.1 + JsonFactory copy() { + return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_copy, jni.JniCallType.objectType, []).object); + } + + static final _id_readResolve = jniAccessors.getMethodIDOf( + _classRef, r"readResolve", r"()Ljava/lang/Object;"); + + /// from: protected java.lang.Object readResolve() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that we need to override to actually make restoration go + /// through constructors etc: needed to allow JDK serializability of + /// factory instances. + /// + /// Note: must be overridden by sub-classes as well. + ///@return Newly constructed instance + jni.JObject readResolve() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_readResolve, jni.JniCallType.objectType, []).object); + } + + static final _id_requiresPropertyOrdering = jniAccessors.getMethodIDOf( + _classRef, r"requiresPropertyOrdering", r"()Z"); + + /// from: public boolean requiresPropertyOrdering() + /// + /// Introspection method that higher-level functionality may call + /// to see whether underlying data format requires a stable ordering + /// of object properties or not. + /// This is usually used for determining + /// whether to force a stable ordering (like alphabetic ordering by name) + /// if no ordering if explicitly specified. + /// + /// Default implementation returns false as JSON does NOT + /// require stable ordering. Formats that require ordering include positional + /// textual formats like CSV, and schema-based binary formats + /// like Avro. + ///@return Whether format supported by this factory + /// requires Object properties to be ordered. + ///@since 2.3 + bool requiresPropertyOrdering() { + return jniAccessors.callMethodWithArgs(reference, + _id_requiresPropertyOrdering, jni.JniCallType.booleanType, []).boolean; + } + + static final _id_canHandleBinaryNatively = + jniAccessors.getMethodIDOf(_classRef, r"canHandleBinaryNatively", r"()Z"); + + /// from: public boolean canHandleBinaryNatively() + /// + /// Introspection method that higher-level functionality may call + /// to see whether underlying data format can read and write binary + /// data natively; that is, embeded it as-is without using encodings + /// such as Base64. + /// + /// Default implementation returns false as JSON does not + /// support native access: all binary content must use Base64 encoding. + /// Most binary formats (like Smile and Avro) support native binary content. + ///@return Whether format supported by this factory + /// supports native binary content + ///@since 2.3 + bool canHandleBinaryNatively() { + return jniAccessors.callMethodWithArgs(reference, + _id_canHandleBinaryNatively, jni.JniCallType.booleanType, []).boolean; + } + + static final _id_canUseCharArrays = + jniAccessors.getMethodIDOf(_classRef, r"canUseCharArrays", r"()Z"); + + /// from: public boolean canUseCharArrays() + /// + /// Introspection method that can be used by base factory to check + /// whether access using char[] is something that actual + /// parser implementations can take advantage of, over having to + /// use java.io.Reader. Sub-types are expected to override + /// definition; default implementation (suitable for JSON) alleges + /// that optimization are possible; and thereby is likely to try + /// to access java.lang.String content by first copying it into + /// recyclable intermediate buffer. + ///@return Whether access to decoded textual content can be efficiently + /// accessed using parser method {@code getTextCharacters()}. + ///@since 2.4 + bool canUseCharArrays() { + return jniAccessors.callMethodWithArgs(reference, _id_canUseCharArrays, + jni.JniCallType.booleanType, []).boolean; + } + + static final _id_canParseAsync = + jniAccessors.getMethodIDOf(_classRef, r"canParseAsync", r"()Z"); + + /// from: public boolean canParseAsync() + /// + /// Introspection method that can be used to check whether this + /// factory can create non-blocking parsers: parsers that do not + /// use blocking I/O abstractions but instead use a + /// com.fasterxml.jackson.core.async.NonBlockingInputFeeder. + ///@return Whether this factory supports non-blocking ("async") parsing or + /// not (and consequently whether {@code createNonBlockingXxx()} method(s) work) + ///@since 2.9 + bool canParseAsync() { + return jniAccessors.callMethodWithArgs( + reference, _id_canParseAsync, jni.JniCallType.booleanType, []).boolean; + } + + static final _id_getFormatReadFeatureType = jniAccessors.getMethodIDOf( + _classRef, r"getFormatReadFeatureType", r"()Ljava/lang/Class;"); + + /// from: public java.lang.Class getFormatReadFeatureType() + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JObject getFormatReadFeatureType() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_getFormatReadFeatureType, + jni.JniCallType.objectType, []).object); + } + + static final _id_getFormatWriteFeatureType = jniAccessors.getMethodIDOf( + _classRef, r"getFormatWriteFeatureType", r"()Ljava/lang/Class;"); + + /// from: public java.lang.Class getFormatWriteFeatureType() + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JObject getFormatWriteFeatureType() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_getFormatWriteFeatureType, + jni.JniCallType.objectType, []).object); + } + + static final _id_canUseSchema = jniAccessors.getMethodIDOf(_classRef, + r"canUseSchema", r"(Lcom/fasterxml/jackson/core/FormatSchema;)Z"); + + /// from: public boolean canUseSchema(com.fasterxml.jackson.core.FormatSchema schema) + /// + /// Method that can be used to quickly check whether given schema + /// is something that parsers and/or generators constructed by this + /// factory could use. Note that this means possible use, at the level + /// of data format (i.e. schema is for same data format as parsers and + /// generators this factory constructs); individual schema instances + /// may have further usage restrictions. + ///@param schema Schema instance to check + ///@return Whether parsers and generators constructed by this factory + /// can use specified format schema instance + bool canUseSchema( + jni.JObject schema, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_canUseSchema, + jni.JniCallType.booleanType, [schema.reference]).boolean; + } + + static final _id_getFormatName = jniAccessors.getMethodIDOf( + _classRef, r"getFormatName", r"()Ljava/lang/String;"); + + /// from: public java.lang.String getFormatName() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that returns short textual id identifying format + /// this factory supports. + /// + /// Note: sub-classes should override this method; default + /// implementation will return null for all sub-classes + ///@return Name of the format handled by parsers, generators this factory creates + jni.JString getFormatName() { + return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_getFormatName, jni.JniCallType.objectType, []).object); + } + + static final _id_hasFormat = jniAccessors.getMethodIDOf( + _classRef, + r"hasFormat", + r"(Lcom/fasterxml/jackson/core/format/InputAccessor;)Lcom/fasterxml/jackson/core/format/MatchStrength;"); + + /// from: public com.fasterxml.jackson.core.format.MatchStrength hasFormat(com.fasterxml.jackson.core.format.InputAccessor acc) + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JObject hasFormat( + jni.JObject acc, + ) { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_hasFormat, + jni.JniCallType.objectType, + [acc.reference]).object); + } + + static final _id_requiresCustomCodec = + jniAccessors.getMethodIDOf(_classRef, r"requiresCustomCodec", r"()Z"); + + /// from: public boolean requiresCustomCodec() + /// + /// Method that can be called to determine if a custom + /// ObjectCodec is needed for binding data parsed + /// using JsonParser constructed by this factory + /// (which typically also implies the same for serialization + /// with JsonGenerator). + ///@return True if custom codec is needed with parsers and + /// generators created by this factory; false if a general + /// ObjectCodec is enough + ///@since 2.1 + bool requiresCustomCodec() { + return jniAccessors.callMethodWithArgs(reference, _id_requiresCustomCodec, + jni.JniCallType.booleanType, []).boolean; + } + + static final _id_hasJSONFormat = jniAccessors.getMethodIDOf( + _classRef, + r"hasJSONFormat", + r"(Lcom/fasterxml/jackson/core/format/InputAccessor;)Lcom/fasterxml/jackson/core/format/MatchStrength;"); + + /// from: protected com.fasterxml.jackson.core.format.MatchStrength hasJSONFormat(com.fasterxml.jackson.core.format.InputAccessor acc) + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JObject hasJSONFormat( + jni.JObject acc, + ) { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_hasJSONFormat, + jni.JniCallType.objectType, + [acc.reference]).object); + } + + static final _id_version = jniAccessors.getMethodIDOf( + _classRef, r"version", r"()Lcom/fasterxml/jackson/core/Version;"); + + /// from: public com.fasterxml.jackson.core.Version version() + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JObject version() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_version, jni.JniCallType.objectType, []).object); + } + + static final _id_configure = jniAccessors.getMethodIDOf( + _classRef, + r"configure", + r"(Lcom/fasterxml/jackson/core/JsonFactory$Feature;Z)Lcom/fasterxml/jackson/core/JsonFactory;"); + + /// from: public final com.fasterxml.jackson.core.JsonFactory configure(com.fasterxml.jackson.core.JsonFactory.Feature f, boolean state) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for enabling or disabling specified parser feature + /// (check JsonParser.Feature for list of features) + ///@param f Feature to enable/disable + ///@param state Whether to enable or disable the feature + ///@return This factory instance (to allow call chaining) + ///@deprecated since 2.10 use JsonFactoryBuilder\#configure(JsonFactory.Feature, boolean) instead + JsonFactory configure( + JsonFactory_Feature f, + bool state, + ) { + return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_configure, + jni.JniCallType.objectType, + [f.reference, state ? 1 : 0]).object); + } + + static final _id_enable = jniAccessors.getMethodIDOf(_classRef, r"enable", + r"(Lcom/fasterxml/jackson/core/JsonFactory$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); + + /// from: public com.fasterxml.jackson.core.JsonFactory enable(com.fasterxml.jackson.core.JsonFactory.Feature f) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for enabling specified parser feature + /// (check JsonFactory.Feature for list of features) + ///@param f Feature to enable + ///@return This factory instance (to allow call chaining) + ///@deprecated since 2.10 use JsonFactoryBuilder\#configure(JsonFactory.Feature, boolean) instead + JsonFactory enable( + JsonFactory_Feature f, + ) { + return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_enable, + jni.JniCallType.objectType, + [f.reference]).object); + } + + static final _id_disable = jniAccessors.getMethodIDOf(_classRef, r"disable", + r"(Lcom/fasterxml/jackson/core/JsonFactory$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); + + /// from: public com.fasterxml.jackson.core.JsonFactory disable(com.fasterxml.jackson.core.JsonFactory.Feature f) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for disabling specified parser features + /// (check JsonFactory.Feature for list of features) + ///@param f Feature to disable + ///@return This factory instance (to allow call chaining) + ///@deprecated since 2.10 use JsonFactoryBuilder\#configure(JsonFactory.Feature, boolean) instead + JsonFactory disable( + JsonFactory_Feature f, + ) { + return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_disable, + jni.JniCallType.objectType, + [f.reference]).object); + } + + static final _id_isEnabled = jniAccessors.getMethodIDOf(_classRef, + r"isEnabled", r"(Lcom/fasterxml/jackson/core/JsonFactory$Feature;)Z"); + + /// from: public final boolean isEnabled(com.fasterxml.jackson.core.JsonFactory.Feature f) + /// + /// Checked whether specified parser feature is enabled. + ///@param f Feature to check + ///@return True if the specified feature is enabled + bool isEnabled( + JsonFactory_Feature f, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_isEnabled, + jni.JniCallType.booleanType, [f.reference]).boolean; + } + + static final _id_getParserFeatures = + jniAccessors.getMethodIDOf(_classRef, r"getParserFeatures", r"()I"); + + /// from: public final int getParserFeatures() + int getParserFeatures() { + return jniAccessors.callMethodWithArgs( + reference, _id_getParserFeatures, jni.JniCallType.intType, []).integer; + } + + static final _id_getGeneratorFeatures = + jniAccessors.getMethodIDOf(_classRef, r"getGeneratorFeatures", r"()I"); + + /// from: public final int getGeneratorFeatures() + int getGeneratorFeatures() { + return jniAccessors.callMethodWithArgs(reference, _id_getGeneratorFeatures, + jni.JniCallType.intType, []).integer; + } + + static final _id_getFormatParserFeatures = + jniAccessors.getMethodIDOf(_classRef, r"getFormatParserFeatures", r"()I"); + + /// from: public int getFormatParserFeatures() + int getFormatParserFeatures() { + return jniAccessors.callMethodWithArgs(reference, + _id_getFormatParserFeatures, jni.JniCallType.intType, []).integer; + } + + static final _id_getFormatGeneratorFeatures = jniAccessors.getMethodIDOf( + _classRef, r"getFormatGeneratorFeatures", r"()I"); + + /// from: public int getFormatGeneratorFeatures() + int getFormatGeneratorFeatures() { + return jniAccessors.callMethodWithArgs(reference, + _id_getFormatGeneratorFeatures, jni.JniCallType.intType, []).integer; + } + + static final _id_configure1 = jniAccessors.getMethodIDOf( + _classRef, + r"configure", + r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;Z)Lcom/fasterxml/jackson/core/JsonFactory;"); + + /// from: public final com.fasterxml.jackson.core.JsonFactory configure(com.fasterxml.jackson.core.JsonParser.Feature f, boolean state) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for enabling or disabling specified parser feature + /// (check JsonParser.Feature for list of features) + ///@param f Feature to enable/disable + ///@param state Whether to enable or disable the feature + ///@return This factory instance (to allow call chaining) + JsonFactory configure1( + jsonparser_.JsonParser_Feature f, + bool state, + ) { + return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_configure1, + jni.JniCallType.objectType, + [f.reference, state ? 1 : 0]).object); + } + + static final _id_enable1 = jniAccessors.getMethodIDOf(_classRef, r"enable", + r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); + + /// from: public com.fasterxml.jackson.core.JsonFactory enable(com.fasterxml.jackson.core.JsonParser.Feature f) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for enabling specified parser feature + /// (check JsonParser.Feature for list of features) + ///@param f Feature to enable + ///@return This factory instance (to allow call chaining) + JsonFactory enable1( + jsonparser_.JsonParser_Feature f, + ) { + return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_enable1, + jni.JniCallType.objectType, + [f.reference]).object); + } + + static final _id_disable1 = jniAccessors.getMethodIDOf(_classRef, r"disable", + r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); + + /// from: public com.fasterxml.jackson.core.JsonFactory disable(com.fasterxml.jackson.core.JsonParser.Feature f) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for disabling specified parser features + /// (check JsonParser.Feature for list of features) + ///@param f Feature to disable + ///@return This factory instance (to allow call chaining) + JsonFactory disable1( + jsonparser_.JsonParser_Feature f, + ) { + return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_disable1, + jni.JniCallType.objectType, + [f.reference]).object); + } + + static final _id_isEnabled1 = jniAccessors.getMethodIDOf(_classRef, + r"isEnabled", r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Z"); + + /// from: public final boolean isEnabled(com.fasterxml.jackson.core.JsonParser.Feature f) + /// + /// Method for checking if the specified parser feature is enabled. + ///@param f Feature to check + ///@return True if specified feature is enabled + bool isEnabled1( + jsonparser_.JsonParser_Feature f, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_isEnabled1, + jni.JniCallType.booleanType, [f.reference]).boolean; + } + + static final _id_isEnabled2 = jniAccessors.getMethodIDOf(_classRef, + r"isEnabled", r"(Lcom/fasterxml/jackson/core/StreamReadFeature;)Z"); + + /// from: public final boolean isEnabled(com.fasterxml.jackson.core.StreamReadFeature f) + /// + /// Method for checking if the specified stream read feature is enabled. + ///@param f Feature to check + ///@return True if specified feature is enabled + ///@since 2.10 + bool isEnabled2( + jni.JObject f, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_isEnabled2, + jni.JniCallType.booleanType, [f.reference]).boolean; + } + + static final _id_getInputDecorator = jniAccessors.getMethodIDOf( + _classRef, + r"getInputDecorator", + r"()Lcom/fasterxml/jackson/core/io/InputDecorator;"); + + /// from: public com.fasterxml.jackson.core.io.InputDecorator getInputDecorator() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for getting currently configured input decorator (if any; + /// there is no default decorator). + ///@return InputDecorator configured, if any + jni.JObject getInputDecorator() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_getInputDecorator, + jni.JniCallType.objectType, []).object); + } + + static final _id_setInputDecorator = jniAccessors.getMethodIDOf( + _classRef, + r"setInputDecorator", + r"(Lcom/fasterxml/jackson/core/io/InputDecorator;)Lcom/fasterxml/jackson/core/JsonFactory;"); + + /// from: public com.fasterxml.jackson.core.JsonFactory setInputDecorator(com.fasterxml.jackson.core.io.InputDecorator d) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for overriding currently configured input decorator + ///@param d Decorator to configure for this factory, if any ({@code null} if none) + ///@return This factory instance (to allow call chaining) + ///@deprecated Since 2.10 use JsonFactoryBuilder\#inputDecorator(InputDecorator) instead + JsonFactory setInputDecorator( + jni.JObject d, + ) { + return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_setInputDecorator, + jni.JniCallType.objectType, + [d.reference]).object); + } + + static final _id_configure2 = jniAccessors.getMethodIDOf( + _classRef, + r"configure", + r"(Lcom/fasterxml/jackson/core/JsonGenerator$Feature;Z)Lcom/fasterxml/jackson/core/JsonFactory;"); + + /// from: public final com.fasterxml.jackson.core.JsonFactory configure(com.fasterxml.jackson.core.JsonGenerator.Feature f, boolean state) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for enabling or disabling specified generator feature + /// (check JsonGenerator.Feature for list of features) + ///@param f Feature to enable/disable + ///@param state Whether to enable or disable the feature + ///@return This factory instance (to allow call chaining) + JsonFactory configure2( + jni.JObject f, + bool state, + ) { + return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_configure2, + jni.JniCallType.objectType, + [f.reference, state ? 1 : 0]).object); + } + + static final _id_enable2 = jniAccessors.getMethodIDOf(_classRef, r"enable", + r"(Lcom/fasterxml/jackson/core/JsonGenerator$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); + + /// from: public com.fasterxml.jackson.core.JsonFactory enable(com.fasterxml.jackson.core.JsonGenerator.Feature f) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for enabling specified generator features + /// (check JsonGenerator.Feature for list of features) + ///@param f Feature to enable + ///@return This factory instance (to allow call chaining) + JsonFactory enable2( + jni.JObject f, + ) { + return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_enable2, + jni.JniCallType.objectType, + [f.reference]).object); + } + + static final _id_disable2 = jniAccessors.getMethodIDOf(_classRef, r"disable", + r"(Lcom/fasterxml/jackson/core/JsonGenerator$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); + + /// from: public com.fasterxml.jackson.core.JsonFactory disable(com.fasterxml.jackson.core.JsonGenerator.Feature f) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for disabling specified generator feature + /// (check JsonGenerator.Feature for list of features) + ///@param f Feature to disable + ///@return This factory instance (to allow call chaining) + JsonFactory disable2( + jni.JObject f, + ) { + return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_disable2, + jni.JniCallType.objectType, + [f.reference]).object); + } + + static final _id_isEnabled3 = jniAccessors.getMethodIDOf(_classRef, + r"isEnabled", r"(Lcom/fasterxml/jackson/core/JsonGenerator$Feature;)Z"); + + /// from: public final boolean isEnabled(com.fasterxml.jackson.core.JsonGenerator.Feature f) + /// + /// Check whether specified generator feature is enabled. + ///@param f Feature to check + ///@return Whether specified feature is enabled + bool isEnabled3( + jni.JObject f, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_isEnabled3, + jni.JniCallType.booleanType, [f.reference]).boolean; + } + + static final _id_isEnabled4 = jniAccessors.getMethodIDOf(_classRef, + r"isEnabled", r"(Lcom/fasterxml/jackson/core/StreamWriteFeature;)Z"); + + /// from: public final boolean isEnabled(com.fasterxml.jackson.core.StreamWriteFeature f) + /// + /// Check whether specified stream write feature is enabled. + ///@param f Feature to check + ///@return Whether specified feature is enabled + ///@since 2.10 + bool isEnabled4( + jni.JObject f, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_isEnabled4, + jni.JniCallType.booleanType, [f.reference]).boolean; + } + + static final _id_getCharacterEscapes = jniAccessors.getMethodIDOf( + _classRef, + r"getCharacterEscapes", + r"()Lcom/fasterxml/jackson/core/io/CharacterEscapes;"); + + /// from: public com.fasterxml.jackson.core.io.CharacterEscapes getCharacterEscapes() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for accessing custom escapes factory uses for JsonGenerators + /// it creates. + ///@return Configured {@code CharacterEscapes}, if any; {@code null} if none + jni.JObject getCharacterEscapes() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_getCharacterEscapes, + jni.JniCallType.objectType, []).object); + } + + static final _id_setCharacterEscapes = jniAccessors.getMethodIDOf( + _classRef, + r"setCharacterEscapes", + r"(Lcom/fasterxml/jackson/core/io/CharacterEscapes;)Lcom/fasterxml/jackson/core/JsonFactory;"); + + /// from: public com.fasterxml.jackson.core.JsonFactory setCharacterEscapes(com.fasterxml.jackson.core.io.CharacterEscapes esc) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for defining custom escapes factory uses for JsonGenerators + /// it creates. + ///@param esc CharaterEscapes to set (or {@code null} for "none") + ///@return This factory instance (to allow call chaining) + JsonFactory setCharacterEscapes( + jni.JObject esc, + ) { + return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_setCharacterEscapes, + jni.JniCallType.objectType, + [esc.reference]).object); + } + + static final _id_getOutputDecorator = jniAccessors.getMethodIDOf( + _classRef, + r"getOutputDecorator", + r"()Lcom/fasterxml/jackson/core/io/OutputDecorator;"); + + /// from: public com.fasterxml.jackson.core.io.OutputDecorator getOutputDecorator() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for getting currently configured output decorator (if any; + /// there is no default decorator). + ///@return OutputDecorator configured for generators factory creates, if any; + /// {@code null} if none. + jni.JObject getOutputDecorator() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_getOutputDecorator, + jni.JniCallType.objectType, []).object); + } + + static final _id_setOutputDecorator = jniAccessors.getMethodIDOf( + _classRef, + r"setOutputDecorator", + r"(Lcom/fasterxml/jackson/core/io/OutputDecorator;)Lcom/fasterxml/jackson/core/JsonFactory;"); + + /// from: public com.fasterxml.jackson.core.JsonFactory setOutputDecorator(com.fasterxml.jackson.core.io.OutputDecorator d) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for overriding currently configured output decorator + ///@return This factory instance (to allow call chaining) + ///@param d Output decorator to use, if any + ///@deprecated Since 2.10 use JsonFactoryBuilder\#outputDecorator(OutputDecorator) instead + JsonFactory setOutputDecorator( + jni.JObject d, + ) { + return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_setOutputDecorator, + jni.JniCallType.objectType, + [d.reference]).object); + } + + static final _id_setRootValueSeparator = jniAccessors.getMethodIDOf( + _classRef, + r"setRootValueSeparator", + r"(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonFactory;"); + + /// from: public com.fasterxml.jackson.core.JsonFactory setRootValueSeparator(java.lang.String sep) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that allows overriding String used for separating root-level + /// JSON values (default is single space character) + ///@param sep Separator to use, if any; null means that no separator is + /// automatically added + ///@return This factory instance (to allow call chaining) + JsonFactory setRootValueSeparator( + jni.JString sep, + ) { + return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_setRootValueSeparator, + jni.JniCallType.objectType, + [sep.reference]).object); + } + + static final _id_getRootValueSeparator = jniAccessors.getMethodIDOf( + _classRef, r"getRootValueSeparator", r"()Ljava/lang/String;"); + + /// from: public java.lang.String getRootValueSeparator() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// @return Root value separator configured, if any + jni.JString getRootValueSeparator() { + return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_getRootValueSeparator, + jni.JniCallType.objectType, []).object); + } + + static final _id_setCodec = jniAccessors.getMethodIDOf(_classRef, r"setCodec", + r"(Lcom/fasterxml/jackson/core/ObjectCodec;)Lcom/fasterxml/jackson/core/JsonFactory;"); + + /// from: public com.fasterxml.jackson.core.JsonFactory setCodec(com.fasterxml.jackson.core.ObjectCodec oc) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for associating a ObjectCodec (typically + /// a com.fasterxml.jackson.databind.ObjectMapper) + /// with this factory (and more importantly, parsers and generators + /// it constructs). This is needed to use data-binding methods + /// of JsonParser and JsonGenerator instances. + ///@param oc Codec to use + ///@return This factory instance (to allow call chaining) + JsonFactory setCodec( + jni.JObject oc, + ) { + return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_setCodec, + jni.JniCallType.objectType, + [oc.reference]).object); + } + + static final _id_getCodec = jniAccessors.getMethodIDOf( + _classRef, r"getCodec", r"()Lcom/fasterxml/jackson/core/ObjectCodec;"); + + /// from: public com.fasterxml.jackson.core.ObjectCodec getCodec() + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JObject getCodec() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_getCodec, jni.JniCallType.objectType, []).object); + } + + static final _id_createParser = jniAccessors.getMethodIDOf( + _classRef, + r"createParser", + r"(Ljava/io/File;)Lcom/fasterxml/jackson/core/JsonParser;"); + + /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.io.File f) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing JSON parser instance to parse + /// contents of specified file. + /// + /// + /// Encoding is auto-detected from contents according to JSON + /// specification recommended mechanism. Json specification + /// supports only UTF-8, UTF-16 and UTF-32 as valid encodings, + /// so auto-detection implemented only for this charsets. + /// For other charsets use \#createParser(java.io.Reader). + /// + /// + /// Underlying input stream (needed for reading contents) + /// will be __owned__ (and managed, i.e. closed as need be) by + /// the parser, since caller has no access to it. + ///@param f File that contains JSON content to parse + ///@since 2.1 + jsonparser_.JsonParser createParser( + jni.JObject f, + ) { + return const jsonparser_.$JsonParserType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_createParser, + jni.JniCallType.objectType, [f.reference]).object); + } + + static final _id_createParser1 = jniAccessors.getMethodIDOf( + _classRef, + r"createParser", + r"(Ljava/net/URL;)Lcom/fasterxml/jackson/core/JsonParser;"); + + /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.net.URL url) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing JSON parser instance to parse + /// contents of resource reference by given URL. + /// + /// Encoding is auto-detected from contents according to JSON + /// specification recommended mechanism. Json specification + /// supports only UTF-8, UTF-16 and UTF-32 as valid encodings, + /// so auto-detection implemented only for this charsets. + /// For other charsets use \#createParser(java.io.Reader). + /// + /// Underlying input stream (needed for reading contents) + /// will be __owned__ (and managed, i.e. closed as need be) by + /// the parser, since caller has no access to it. + ///@param url URL pointing to resource that contains JSON content to parse + ///@since 2.1 + jsonparser_.JsonParser createParser1( + jni.JObject url, + ) { + return const jsonparser_.$JsonParserType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_createParser1, + jni.JniCallType.objectType, [url.reference]).object); + } + + static final _id_createParser2 = jniAccessors.getMethodIDOf( + _classRef, + r"createParser", + r"(Ljava/io/InputStream;)Lcom/fasterxml/jackson/core/JsonParser;"); + + /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.io.InputStream in) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing JSON parser instance to parse + /// the contents accessed via specified input stream. + /// + /// The input stream will __not be owned__ by + /// the parser, it will still be managed (i.e. closed if + /// end-of-stream is reacher, or parser close method called) + /// if (and only if) com.fasterxml.jackson.core.StreamReadFeature\#AUTO_CLOSE_SOURCE + /// is enabled. + /// + /// + /// Note: no encoding argument is taken since it can always be + /// auto-detected as suggested by JSON RFC. Json specification + /// supports only UTF-8, UTF-16 and UTF-32 as valid encodings, + /// so auto-detection implemented only for this charsets. + /// For other charsets use \#createParser(java.io.Reader). + ///@param in InputStream to use for reading JSON content to parse + ///@since 2.1 + jsonparser_.JsonParser createParser2( + jni.JObject in0, + ) { + return const jsonparser_.$JsonParserType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_createParser2, + jni.JniCallType.objectType, [in0.reference]).object); + } + + static final _id_createParser3 = jniAccessors.getMethodIDOf( + _classRef, + r"createParser", + r"(Ljava/io/Reader;)Lcom/fasterxml/jackson/core/JsonParser;"); + + /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.io.Reader r) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing parser for parsing + /// the contents accessed via specified Reader. + /// + /// The read stream will __not be owned__ by + /// the parser, it will still be managed (i.e. closed if + /// end-of-stream is reacher, or parser close method called) + /// if (and only if) com.fasterxml.jackson.core.StreamReadFeature\#AUTO_CLOSE_SOURCE + /// is enabled. + ///@param r Reader to use for reading JSON content to parse + ///@since 2.1 + jsonparser_.JsonParser createParser3( + jni.JObject r, + ) { + return const jsonparser_.$JsonParserType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_createParser3, + jni.JniCallType.objectType, [r.reference]).object); + } + + static final _id_createParser4 = jniAccessors.getMethodIDOf(_classRef, + r"createParser", r"([B)Lcom/fasterxml/jackson/core/JsonParser;"); + + /// from: public com.fasterxml.jackson.core.JsonParser createParser(byte[] data) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing parser for parsing + /// the contents of given byte array. + ///@since 2.1 + jsonparser_.JsonParser createParser4( + jni.JArray data, + ) { + return const jsonparser_.$JsonParserType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_createParser4, + jni.JniCallType.objectType, [data.reference]).object); + } + + static final _id_createParser5 = jniAccessors.getMethodIDOf(_classRef, + r"createParser", r"([BII)Lcom/fasterxml/jackson/core/JsonParser;"); + + /// from: public com.fasterxml.jackson.core.JsonParser createParser(byte[] data, int offset, int len) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing parser for parsing + /// the contents of given byte array. + ///@param data Buffer that contains data to parse + ///@param offset Offset of the first data byte within buffer + ///@param len Length of contents to parse within buffer + ///@since 2.1 + jsonparser_.JsonParser createParser5( + jni.JArray data, + int offset, + int len, + ) { + return const jsonparser_.$JsonParserType().fromRef(jniAccessors + .callMethodWithArgs( + reference, _id_createParser5, jni.JniCallType.objectType, [ + data.reference, + jni.JValueInt(offset), + jni.JValueInt(len) + ]).object); + } + + static final _id_createParser6 = jniAccessors.getMethodIDOf( + _classRef, + r"createParser", + r"(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonParser;"); + + /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.lang.String content) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing parser for parsing + /// contents of given String. + ///@since 2.1 + jsonparser_.JsonParser createParser6( + jni.JString content, + ) { + return const jsonparser_.$JsonParserType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_createParser6, + jni.JniCallType.objectType, [content.reference]).object); + } + + static final _id_createParser7 = jniAccessors.getMethodIDOf(_classRef, + r"createParser", r"([C)Lcom/fasterxml/jackson/core/JsonParser;"); + + /// from: public com.fasterxml.jackson.core.JsonParser createParser(char[] content) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing parser for parsing + /// contents of given char array. + ///@since 2.4 + jsonparser_.JsonParser createParser7( + jni.JArray content, + ) { + return const jsonparser_.$JsonParserType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_createParser7, + jni.JniCallType.objectType, [content.reference]).object); + } + + static final _id_createParser8 = jniAccessors.getMethodIDOf(_classRef, + r"createParser", r"([CII)Lcom/fasterxml/jackson/core/JsonParser;"); + + /// from: public com.fasterxml.jackson.core.JsonParser createParser(char[] content, int offset, int len) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing parser for parsing contents of given char array. + ///@since 2.4 + jsonparser_.JsonParser createParser8( + jni.JArray content, + int offset, + int len, + ) { + return const jsonparser_.$JsonParserType().fromRef(jniAccessors + .callMethodWithArgs( + reference, _id_createParser8, jni.JniCallType.objectType, [ + content.reference, + jni.JValueInt(offset), + jni.JValueInt(len) + ]).object); + } + + static final _id_createParser9 = jniAccessors.getMethodIDOf( + _classRef, + r"createParser", + r"(Ljava/io/DataInput;)Lcom/fasterxml/jackson/core/JsonParser;"); + + /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.io.DataInput in) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Optional method for constructing parser for reading contents from specified DataInput + /// instance. + /// + /// If this factory does not support DataInput as source, + /// will throw UnsupportedOperationException + ///@since 2.8 + jsonparser_.JsonParser createParser9( + jni.JObject in0, + ) { + return const jsonparser_.$JsonParserType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_createParser9, + jni.JniCallType.objectType, [in0.reference]).object); + } + + static final _id_createNonBlockingByteArrayParser = + jniAccessors.getMethodIDOf(_classRef, r"createNonBlockingByteArrayParser", + r"()Lcom/fasterxml/jackson/core/JsonParser;"); + + /// from: public com.fasterxml.jackson.core.JsonParser createNonBlockingByteArrayParser() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Optional method for constructing parser for non-blocking parsing + /// via com.fasterxml.jackson.core.async.ByteArrayFeeder + /// interface (accessed using JsonParser\#getNonBlockingInputFeeder() + /// from constructed instance). + /// + /// If this factory does not support non-blocking parsing (either at all, + /// or from byte array), + /// will throw UnsupportedOperationException. + /// + /// Note that JSON-backed factory only supports parsing of UTF-8 encoded JSON content + /// (and US-ASCII since it is proper subset); other encodings are not supported + /// at this point. + ///@since 2.9 + jsonparser_.JsonParser createNonBlockingByteArrayParser() { + return const jsonparser_.$JsonParserType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_createNonBlockingByteArrayParser, + jni.JniCallType.objectType, []).object); + } + + static final _id_createGenerator = jniAccessors.getMethodIDOf( + _classRef, + r"createGenerator", + r"(Ljava/io/OutputStream;Lcom/fasterxml/jackson/core/JsonEncoding;)Lcom/fasterxml/jackson/core/JsonGenerator;"); + + /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.OutputStream out, com.fasterxml.jackson.core.JsonEncoding enc) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing JSON generator for writing JSON content + /// using specified output stream. + /// Encoding to use must be specified, and needs to be one of available + /// types (as per JSON specification). + /// + /// Underlying stream __is NOT owned__ by the generator constructed, + /// so that generator will NOT close the output stream when + /// JsonGenerator\#close is called (unless auto-closing + /// feature, + /// com.fasterxml.jackson.core.JsonGenerator.Feature\#AUTO_CLOSE_TARGET + /// is enabled). + /// Using application needs to close it explicitly if this is the case. + /// + /// Note: there are formats that use fixed encoding (like most binary data formats) + /// and that ignore passed in encoding. + ///@param out OutputStream to use for writing JSON content + ///@param enc Character encoding to use + ///@since 2.1 + jni.JObject createGenerator( + jni.JObject out, + jni.JObject enc, + ) { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_createGenerator, + jni.JniCallType.objectType, + [out.reference, enc.reference]).object); + } + + static final _id_createGenerator1 = jniAccessors.getMethodIDOf( + _classRef, + r"createGenerator", + r"(Ljava/io/OutputStream;)Lcom/fasterxml/jackson/core/JsonGenerator;"); + + /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.OutputStream out) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Convenience method for constructing generator that uses default + /// encoding of the format (UTF-8 for JSON and most other data formats). + /// + /// Note: there are formats that use fixed encoding (like most binary data formats). + ///@since 2.1 + jni.JObject createGenerator1( + jni.JObject out, + ) { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_createGenerator1, + jni.JniCallType.objectType, + [out.reference]).object); + } + + static final _id_createGenerator2 = jniAccessors.getMethodIDOf( + _classRef, + r"createGenerator", + r"(Ljava/io/Writer;)Lcom/fasterxml/jackson/core/JsonGenerator;"); + + /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.Writer w) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing JSON generator for writing JSON content + /// using specified Writer. + /// + /// Underlying stream __is NOT owned__ by the generator constructed, + /// so that generator will NOT close the Reader when + /// JsonGenerator\#close is called (unless auto-closing + /// feature, + /// com.fasterxml.jackson.core.JsonGenerator.Feature\#AUTO_CLOSE_TARGET is enabled). + /// Using application needs to close it explicitly. + ///@since 2.1 + ///@param w Writer to use for writing JSON content + jni.JObject createGenerator2( + jni.JObject w, + ) { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_createGenerator2, + jni.JniCallType.objectType, + [w.reference]).object); + } + + static final _id_createGenerator3 = jniAccessors.getMethodIDOf( + _classRef, + r"createGenerator", + r"(Ljava/io/File;Lcom/fasterxml/jackson/core/JsonEncoding;)Lcom/fasterxml/jackson/core/JsonGenerator;"); + + /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.File f, com.fasterxml.jackson.core.JsonEncoding enc) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing JSON generator for writing JSON content + /// to specified file, overwriting contents it might have (or creating + /// it if such file does not yet exist). + /// Encoding to use must be specified, and needs to be one of available + /// types (as per JSON specification). + /// + /// Underlying stream __is owned__ by the generator constructed, + /// i.e. generator will handle closing of file when + /// JsonGenerator\#close is called. + ///@param f File to write contents to + ///@param enc Character encoding to use + ///@since 2.1 + jni.JObject createGenerator3( + jni.JObject f, + jni.JObject enc, + ) { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_createGenerator3, + jni.JniCallType.objectType, + [f.reference, enc.reference]).object); + } + + static final _id_createGenerator4 = jniAccessors.getMethodIDOf( + _classRef, + r"createGenerator", + r"(Ljava/io/DataOutput;Lcom/fasterxml/jackson/core/JsonEncoding;)Lcom/fasterxml/jackson/core/JsonGenerator;"); + + /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.DataOutput out, com.fasterxml.jackson.core.JsonEncoding enc) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing generator for writing content using specified + /// DataOutput instance. + ///@since 2.8 + jni.JObject createGenerator4( + jni.JObject out, + jni.JObject enc, + ) { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_createGenerator4, + jni.JniCallType.objectType, + [out.reference, enc.reference]).object); + } + + static final _id_createGenerator5 = jniAccessors.getMethodIDOf( + _classRef, + r"createGenerator", + r"(Ljava/io/DataOutput;)Lcom/fasterxml/jackson/core/JsonGenerator;"); + + /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.DataOutput out) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Convenience method for constructing generator that uses default + /// encoding of the format (UTF-8 for JSON and most other data formats). + /// + /// Note: there are formats that use fixed encoding (like most binary data formats). + ///@since 2.8 + jni.JObject createGenerator5( + jni.JObject out, + ) { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_createGenerator5, + jni.JniCallType.objectType, + [out.reference]).object); + } + + static final _id_createJsonParser = jniAccessors.getMethodIDOf( + _classRef, + r"createJsonParser", + r"(Ljava/io/File;)Lcom/fasterxml/jackson/core/JsonParser;"); + + /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(java.io.File f) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing JSON parser instance to parse + /// contents of specified file. + /// + /// Encoding is auto-detected from contents according to JSON + /// specification recommended mechanism. Json specification + /// supports only UTF-8, UTF-16 and UTF-32 as valid encodings, + /// so auto-detection implemented only for this charsets. + /// For other charsets use \#createParser(java.io.Reader). + /// + /// + /// Underlying input stream (needed for reading contents) + /// will be __owned__ (and managed, i.e. closed as need be) by + /// the parser, since caller has no access to it. + ///@param f File that contains JSON content to parse + ///@return Parser constructed + ///@throws IOException if parser initialization fails due to I/O (read) problem + ///@throws JsonParseException if parser initialization fails due to content decoding problem + ///@deprecated Since 2.2, use \#createParser(File) instead. + jsonparser_.JsonParser createJsonParser( + jni.JObject f, + ) { + return const jsonparser_.$JsonParserType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_createJsonParser, + jni.JniCallType.objectType, [f.reference]).object); + } + + static final _id_createJsonParser1 = jniAccessors.getMethodIDOf( + _classRef, + r"createJsonParser", + r"(Ljava/net/URL;)Lcom/fasterxml/jackson/core/JsonParser;"); + + /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(java.net.URL url) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing JSON parser instance to parse + /// contents of resource reference by given URL. + /// + /// Encoding is auto-detected from contents according to JSON + /// specification recommended mechanism. Json specification + /// supports only UTF-8, UTF-16 and UTF-32 as valid encodings, + /// so auto-detection implemented only for this charsets. + /// For other charsets use \#createParser(java.io.Reader). + /// + /// Underlying input stream (needed for reading contents) + /// will be __owned__ (and managed, i.e. closed as need be) by + /// the parser, since caller has no access to it. + ///@param url URL pointing to resource that contains JSON content to parse + ///@return Parser constructed + ///@throws IOException if parser initialization fails due to I/O (read) problem + ///@throws JsonParseException if parser initialization fails due to content decoding problem + ///@deprecated Since 2.2, use \#createParser(URL) instead. + jsonparser_.JsonParser createJsonParser1( + jni.JObject url, + ) { + return const jsonparser_.$JsonParserType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_createJsonParser1, + jni.JniCallType.objectType, [url.reference]).object); + } + + static final _id_createJsonParser2 = jniAccessors.getMethodIDOf( + _classRef, + r"createJsonParser", + r"(Ljava/io/InputStream;)Lcom/fasterxml/jackson/core/JsonParser;"); + + /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(java.io.InputStream in) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing JSON parser instance to parse + /// the contents accessed via specified input stream. + /// + /// The input stream will __not be owned__ by + /// the parser, it will still be managed (i.e. closed if + /// end-of-stream is reacher, or parser close method called) + /// if (and only if) com.fasterxml.jackson.core.JsonParser.Feature\#AUTO_CLOSE_SOURCE + /// is enabled. + /// + /// + /// Note: no encoding argument is taken since it can always be + /// auto-detected as suggested by JSON RFC. Json specification + /// supports only UTF-8, UTF-16 and UTF-32 as valid encodings, + /// so auto-detection implemented only for this charsets. + /// For other charsets use \#createParser(java.io.Reader). + ///@param in InputStream to use for reading JSON content to parse + ///@return Parser constructed + ///@throws IOException if parser initialization fails due to I/O (read) problem + ///@throws JsonParseException if parser initialization fails due to content decoding problem + ///@deprecated Since 2.2, use \#createParser(InputStream) instead. + jsonparser_.JsonParser createJsonParser2( + jni.JObject in0, + ) { + return const jsonparser_.$JsonParserType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_createJsonParser2, + jni.JniCallType.objectType, [in0.reference]).object); + } + + static final _id_createJsonParser3 = jniAccessors.getMethodIDOf( + _classRef, + r"createJsonParser", + r"(Ljava/io/Reader;)Lcom/fasterxml/jackson/core/JsonParser;"); + + /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(java.io.Reader r) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing parser for parsing + /// the contents accessed via specified Reader. + /// + /// The read stream will __not be owned__ by + /// the parser, it will still be managed (i.e. closed if + /// end-of-stream is reacher, or parser close method called) + /// if (and only if) com.fasterxml.jackson.core.JsonParser.Feature\#AUTO_CLOSE_SOURCE + /// is enabled. + ///@param r Reader to use for reading JSON content to parse + ///@return Parser constructed + ///@throws IOException if parser initialization fails due to I/O (read) problem + ///@throws JsonParseException if parser initialization fails due to content decoding problem + ///@deprecated Since 2.2, use \#createParser(Reader) instead. + jsonparser_.JsonParser createJsonParser3( + jni.JObject r, + ) { + return const jsonparser_.$JsonParserType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_createJsonParser3, + jni.JniCallType.objectType, [r.reference]).object); + } + + static final _id_createJsonParser4 = jniAccessors.getMethodIDOf(_classRef, + r"createJsonParser", r"([B)Lcom/fasterxml/jackson/core/JsonParser;"); + + /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(byte[] data) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing parser for parsing the contents of given byte array. + ///@param data Input content to parse + ///@return Parser constructed + ///@throws IOException if parser initialization fails due to I/O (read) problem + ///@throws JsonParseException if parser initialization fails due to content decoding problem + ///@deprecated Since 2.2, use \#createParser(byte[]) instead. + jsonparser_.JsonParser createJsonParser4( + jni.JArray data, + ) { + return const jsonparser_.$JsonParserType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_createJsonParser4, + jni.JniCallType.objectType, [data.reference]).object); + } + + static final _id_createJsonParser5 = jniAccessors.getMethodIDOf(_classRef, + r"createJsonParser", r"([BII)Lcom/fasterxml/jackson/core/JsonParser;"); + + /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(byte[] data, int offset, int len) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing parser for parsing + /// the contents of given byte array. + ///@param data Buffer that contains data to parse + ///@param offset Offset of the first data byte within buffer + ///@param len Length of contents to parse within buffer + ///@return Parser constructed + ///@throws IOException if parser initialization fails due to I/O (read) problem + ///@throws JsonParseException if parser initialization fails due to content decoding problem + ///@deprecated Since 2.2, use \#createParser(byte[],int,int) instead. + jsonparser_.JsonParser createJsonParser5( + jni.JArray data, + int offset, + int len, + ) { + return const jsonparser_.$JsonParserType().fromRef(jniAccessors + .callMethodWithArgs( + reference, _id_createJsonParser5, jni.JniCallType.objectType, [ + data.reference, + jni.JValueInt(offset), + jni.JValueInt(len) + ]).object); + } + + static final _id_createJsonParser6 = jniAccessors.getMethodIDOf( + _classRef, + r"createJsonParser", + r"(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonParser;"); + + /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(java.lang.String content) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing parser for parsing + /// contents of given String. + ///@param content Input content to parse + ///@return Parser constructed + ///@throws IOException if parser initialization fails due to I/O (read) problem + ///@throws JsonParseException if parser initialization fails due to content decoding problem + ///@deprecated Since 2.2, use \#createParser(String) instead. + jsonparser_.JsonParser createJsonParser6( + jni.JString content, + ) { + return const jsonparser_.$JsonParserType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_createJsonParser6, + jni.JniCallType.objectType, [content.reference]).object); + } + + static final _id_createJsonGenerator = jniAccessors.getMethodIDOf( + _classRef, + r"createJsonGenerator", + r"(Ljava/io/OutputStream;Lcom/fasterxml/jackson/core/JsonEncoding;)Lcom/fasterxml/jackson/core/JsonGenerator;"); + + /// from: public com.fasterxml.jackson.core.JsonGenerator createJsonGenerator(java.io.OutputStream out, com.fasterxml.jackson.core.JsonEncoding enc) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing JSON generator for writing JSON content + /// using specified output stream. + /// Encoding to use must be specified, and needs to be one of available + /// types (as per JSON specification). + /// + /// Underlying stream __is NOT owned__ by the generator constructed, + /// so that generator will NOT close the output stream when + /// JsonGenerator\#close is called (unless auto-closing + /// feature, + /// com.fasterxml.jackson.core.JsonGenerator.Feature\#AUTO_CLOSE_TARGET + /// is enabled). + /// Using application needs to close it explicitly if this is the case. + /// + /// Note: there are formats that use fixed encoding (like most binary data formats) + /// and that ignore passed in encoding. + ///@param out OutputStream to use for writing JSON content + ///@param enc Character encoding to use + ///@return Generator constructed + ///@throws IOException if parser initialization fails due to I/O (write) problem + ///@deprecated Since 2.2, use \#createGenerator(OutputStream, JsonEncoding) instead. + jni.JObject createJsonGenerator( + jni.JObject out, + jni.JObject enc, + ) { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_createJsonGenerator, + jni.JniCallType.objectType, + [out.reference, enc.reference]).object); + } + + static final _id_createJsonGenerator1 = jniAccessors.getMethodIDOf( + _classRef, + r"createJsonGenerator", + r"(Ljava/io/Writer;)Lcom/fasterxml/jackson/core/JsonGenerator;"); + + /// from: public com.fasterxml.jackson.core.JsonGenerator createJsonGenerator(java.io.Writer out) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for constructing JSON generator for writing JSON content + /// using specified Writer. + /// + /// Underlying stream __is NOT owned__ by the generator constructed, + /// so that generator will NOT close the Reader when + /// JsonGenerator\#close is called (unless auto-closing + /// feature, + /// com.fasterxml.jackson.core.JsonGenerator.Feature\#AUTO_CLOSE_TARGET is enabled). + /// Using application needs to close it explicitly. + ///@param out Writer to use for writing JSON content + ///@return Generator constructed + ///@throws IOException if parser initialization fails due to I/O (write) problem + ///@deprecated Since 2.2, use \#createGenerator(Writer) instead. + jni.JObject createJsonGenerator1( + jni.JObject out, + ) { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_createJsonGenerator1, + jni.JniCallType.objectType, + [out.reference]).object); + } + + static final _id_createJsonGenerator2 = jniAccessors.getMethodIDOf( + _classRef, + r"createJsonGenerator", + r"(Ljava/io/OutputStream;)Lcom/fasterxml/jackson/core/JsonGenerator;"); + + /// from: public com.fasterxml.jackson.core.JsonGenerator createJsonGenerator(java.io.OutputStream out) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Convenience method for constructing generator that uses default + /// encoding of the format (UTF-8 for JSON and most other data formats). + /// + /// Note: there are formats that use fixed encoding (like most binary data formats). + ///@param out OutputStream to use for writing JSON content + ///@return Generator constructed + ///@throws IOException if parser initialization fails due to I/O (write) problem + ///@deprecated Since 2.2, use \#createGenerator(OutputStream) instead. + jni.JObject createJsonGenerator2( + jni.JObject out, + ) { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_createJsonGenerator2, + jni.JniCallType.objectType, + [out.reference]).object); + } +} + +class $JsonFactoryType extends jni.JObjType { + const $JsonFactoryType(); + + @override + String get signature => r"Lcom/fasterxml/jackson/core/JsonFactory;"; + + @override + JsonFactory fromRef(jni.JObjectPtr ref) => JsonFactory.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($JsonFactoryType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $JsonFactoryType && other is $JsonFactoryType; + } +} + +/// from: com.fasterxml.jackson.core.JsonFactory$Feature +/// +/// Enumeration that defines all on/off features that can only be +/// changed for JsonFactory. +class JsonFactory_Feature extends jni.JObject { + @override + late final jni.JObjType $type = type; + + JsonFactory_Feature.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + static final _classRef = jniAccessors + .getClassOf(r"com/fasterxml/jackson/core/JsonFactory$Feature"); + + /// The type which includes information such as the signature of this class. + static const type = $JsonFactory_FeatureType(); + static final _id_values = jniAccessors.getStaticMethodIDOf(_classRef, + r"values", r"()[Lcom/fasterxml/jackson/core/JsonFactory$Feature;"); + + /// from: static public com.fasterxml.jackson.core.JsonFactory.Feature[] values() + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JArray values() { + return const jni.JArrayType($JsonFactory_FeatureType()).fromRef(jniAccessors + .callStaticMethodWithArgs( + _classRef, _id_values, jni.JniCallType.objectType, []).object); + } + + static final _id_valueOf = jniAccessors.getStaticMethodIDOf( + _classRef, + r"valueOf", + r"(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonFactory$Feature;"); + + /// from: static public com.fasterxml.jackson.core.JsonFactory.Feature valueOf(java.lang.String name) + /// The returned object must be deleted after use, by calling the `delete` method. + static JsonFactory_Feature valueOf( + jni.JString name, + ) { + return const $JsonFactory_FeatureType().fromRef(jniAccessors + .callStaticMethodWithArgs(_classRef, _id_valueOf, + jni.JniCallType.objectType, [name.reference]).object); + } + + static final _id_collectDefaults = + jniAccessors.getStaticMethodIDOf(_classRef, r"collectDefaults", r"()I"); + + /// from: static public int collectDefaults() + /// + /// Method that calculates bit set (flags) of all features that + /// are enabled by default. + ///@return Bit field of features enabled by default + static int collectDefaults() { + return jniAccessors.callStaticMethodWithArgs( + _classRef, _id_collectDefaults, jni.JniCallType.intType, []).integer; + } + + static final _id_enabledByDefault = + jniAccessors.getMethodIDOf(_classRef, r"enabledByDefault", r"()Z"); + + /// from: public boolean enabledByDefault() + bool enabledByDefault() { + return jniAccessors.callMethodWithArgs(reference, _id_enabledByDefault, + jni.JniCallType.booleanType, []).boolean; + } + + static final _id_enabledIn = + jniAccessors.getMethodIDOf(_classRef, r"enabledIn", r"(I)Z"); + + /// from: public boolean enabledIn(int flags) + bool enabledIn( + int flags, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_enabledIn, + jni.JniCallType.booleanType, [jni.JValueInt(flags)]).boolean; + } + + static final _id_getMask = + jniAccessors.getMethodIDOf(_classRef, r"getMask", r"()I"); + + /// from: public int getMask() + int getMask() { + return jniAccessors.callMethodWithArgs( + reference, _id_getMask, jni.JniCallType.intType, []).integer; + } +} + +class $JsonFactory_FeatureType extends jni.JObjType { + const $JsonFactory_FeatureType(); + + @override + String get signature => r"Lcom/fasterxml/jackson/core/JsonFactory$Feature;"; + + @override + JsonFactory_Feature fromRef(jni.JObjectPtr ref) => + JsonFactory_Feature.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($JsonFactory_FeatureType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $JsonFactory_FeatureType && + other is $JsonFactory_FeatureType; + } +} diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/com/fasterxml/jackson/core/JsonParser.dart b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/com/fasterxml/jackson/core/JsonParser.dart new file mode 100644 index 000000000..e8caa42e3 --- /dev/null +++ b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/com/fasterxml/jackson/core/JsonParser.dart @@ -0,0 +1,2640 @@ +// Generated from jackson-core which is licensed under the Apache License 2.0. +// The following copyright from the original authors applies. +// See https://github.com/FasterXML/jackson-core/blob/2.14/LICENSE +// +// Copyright (c) 2007 - The Jackson Project Authors +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Autogenerated by jnigen. DO NOT EDIT! + +// ignore_for_file: annotate_overrides +// ignore_for_file: camel_case_extensions +// ignore_for_file: camel_case_types +// ignore_for_file: constant_identifier_names +// ignore_for_file: file_names +// ignore_for_file: no_leading_underscores_for_local_identifiers +// ignore_for_file: non_constant_identifier_names +// ignore_for_file: overridden_fields +// ignore_for_file: unnecessary_cast +// ignore_for_file: unused_element +// ignore_for_file: unused_field +// ignore_for_file: unused_import +// ignore_for_file: unused_shown_name + +import "dart:isolate" show ReceivePort; +import "dart:ffi" as ffi; +import "package:jni/internal_helpers_for_jnigen.dart"; +import "package:jni/jni.dart" as jni; + +import "JsonToken.dart" as jsontoken_; +import "../../../../_init.dart"; + +/// from: com.fasterxml.jackson.core.JsonParser +/// +/// Base class that defines public API for reading JSON content. +/// Instances are created using factory methods of +/// a JsonFactory instance. +///@author Tatu Saloranta +class JsonParser extends jni.JObject { + @override + late final jni.JObjType $type = type; + + JsonParser.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + static final _classRef = + jniAccessors.getClassOf(r"com/fasterxml/jackson/core/JsonParser"); + + /// The type which includes information such as the signature of this class. + static const type = $JsonParserType(); + static final _id_DEFAULT_READ_CAPABILITIES = jniAccessors.getStaticFieldIDOf( + _classRef, + r"DEFAULT_READ_CAPABILITIES", + r"Lcom/fasterxml/jackson/core/util/JacksonFeatureSet;", + ); + + /// from: static protected final com.fasterxml.jackson.core.util.JacksonFeatureSet DEFAULT_READ_CAPABILITIES + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Default set of StreamReadCapabilityies that may be used as + /// basis for format-specific readers (or as bogus instance if non-null + /// set needs to be passed). + ///@since 2.12 + static jni.JObject get DEFAULT_READ_CAPABILITIES => + const jni.JObjectType().fromRef(jniAccessors + .getStaticField(_classRef, _id_DEFAULT_READ_CAPABILITIES, + jni.JniCallType.objectType) + .object); + + static final _id_ctor = + jniAccessors.getMethodIDOf(_classRef, r"", r"()V"); + + /// from: protected void () + /// The returned object must be deleted after use, by calling the `delete` method. + factory JsonParser() { + return JsonParser.fromRef( + jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); + } + + static final _id_ctor1 = + jniAccessors.getMethodIDOf(_classRef, r"", r"(I)V"); + + /// from: protected void (int features) + /// The returned object must be deleted after use, by calling the `delete` method. + factory JsonParser.ctor1( + int features, + ) { + return JsonParser.fromRef(jniAccessors.newObjectWithArgs( + _classRef, _id_ctor1, [jni.JValueInt(features)]).object); + } + + static final _id_getCodec = jniAccessors.getMethodIDOf( + _classRef, r"getCodec", r"()Lcom/fasterxml/jackson/core/ObjectCodec;"); + + /// from: public abstract com.fasterxml.jackson.core.ObjectCodec getCodec() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Accessor for ObjectCodec associated with this + /// parser, if any. Codec is used by \#readValueAs(Class) + /// method (and its variants). + ///@return Codec assigned to this parser, if any; {@code null} if none + jni.JObject getCodec() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_getCodec, jni.JniCallType.objectType, []).object); + } + + static final _id_setCodec = jniAccessors.getMethodIDOf( + _classRef, r"setCodec", r"(Lcom/fasterxml/jackson/core/ObjectCodec;)V"); + + /// from: public abstract void setCodec(com.fasterxml.jackson.core.ObjectCodec oc) + /// + /// Setter that allows defining ObjectCodec associated with this + /// parser, if any. Codec is used by \#readValueAs(Class) + /// method (and its variants). + ///@param oc Codec to assign, if any; {@code null} if none + void setCodec( + jni.JObject oc, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_setCodec, + jni.JniCallType.voidType, [oc.reference]).check(); + } + + static final _id_getInputSource = jniAccessors.getMethodIDOf( + _classRef, r"getInputSource", r"()Ljava/lang/Object;"); + + /// from: public java.lang.Object getInputSource() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that can be used to get access to object that is used + /// to access input being parsed; this is usually either + /// InputStream or Reader, depending on what + /// parser was constructed with. + /// Note that returned value may be null in some cases; including + /// case where parser implementation does not want to exposed raw + /// source to caller. + /// In cases where input has been decorated, object returned here + /// is the decorated version; this allows some level of interaction + /// between users of parser and decorator object. + /// + /// In general use of this accessor should be considered as + /// "last effort", i.e. only used if no other mechanism is applicable. + ///@return Input source this parser was configured with + jni.JObject getInputSource() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_getInputSource, jni.JniCallType.objectType, []).object); + } + + static final _id_setRequestPayloadOnError = jniAccessors.getMethodIDOf( + _classRef, + r"setRequestPayloadOnError", + r"(Lcom/fasterxml/jackson/core/util/RequestPayload;)V"); + + /// from: public void setRequestPayloadOnError(com.fasterxml.jackson.core.util.RequestPayload payload) + /// + /// Sets the payload to be passed if JsonParseException is thrown. + ///@param payload Payload to pass + ///@since 2.8 + void setRequestPayloadOnError( + jni.JObject payload, + ) { + return jniAccessors.callMethodWithArgs( + reference, + _id_setRequestPayloadOnError, + jni.JniCallType.voidType, + [payload.reference]).check(); + } + + static final _id_setRequestPayloadOnError1 = jniAccessors.getMethodIDOf( + _classRef, r"setRequestPayloadOnError", r"([BLjava/lang/String;)V"); + + /// from: public void setRequestPayloadOnError(byte[] payload, java.lang.String charset) + /// + /// Sets the byte[] request payload and the charset + ///@param payload Payload to pass + ///@param charset Character encoding for (lazily) decoding payload + ///@since 2.8 + void setRequestPayloadOnError1( + jni.JArray payload, + jni.JString charset, + ) { + return jniAccessors.callMethodWithArgs( + reference, + _id_setRequestPayloadOnError1, + jni.JniCallType.voidType, + [payload.reference, charset.reference]).check(); + } + + static final _id_setRequestPayloadOnError2 = jniAccessors.getMethodIDOf( + _classRef, r"setRequestPayloadOnError", r"(Ljava/lang/String;)V"); + + /// from: public void setRequestPayloadOnError(java.lang.String payload) + /// + /// Sets the String request payload + ///@param payload Payload to pass + ///@since 2.8 + void setRequestPayloadOnError2( + jni.JString payload, + ) { + return jniAccessors.callMethodWithArgs( + reference, + _id_setRequestPayloadOnError2, + jni.JniCallType.voidType, + [payload.reference]).check(); + } + + static final _id_setSchema = jniAccessors.getMethodIDOf( + _classRef, r"setSchema", r"(Lcom/fasterxml/jackson/core/FormatSchema;)V"); + + /// from: public void setSchema(com.fasterxml.jackson.core.FormatSchema schema) + /// + /// Method to call to make this parser use specified schema. Method must + /// be called before trying to parse any content, right after parser instance + /// has been created. + /// Note that not all parsers support schemas; and those that do usually only + /// accept specific types of schemas: ones defined for data format parser can read. + /// + /// If parser does not support specified schema, UnsupportedOperationException + /// is thrown. + ///@param schema Schema to use + ///@throws UnsupportedOperationException if parser does not support schema + void setSchema( + jni.JObject schema, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_setSchema, + jni.JniCallType.voidType, [schema.reference]).check(); + } + + static final _id_getSchema = jniAccessors.getMethodIDOf( + _classRef, r"getSchema", r"()Lcom/fasterxml/jackson/core/FormatSchema;"); + + /// from: public com.fasterxml.jackson.core.FormatSchema getSchema() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for accessing Schema that this parser uses, if any. + /// Default implementation returns null. + ///@return Schema in use by this parser, if any; {@code null} if none + ///@since 2.1 + jni.JObject getSchema() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_getSchema, jni.JniCallType.objectType, []).object); + } + + static final _id_canUseSchema = jniAccessors.getMethodIDOf(_classRef, + r"canUseSchema", r"(Lcom/fasterxml/jackson/core/FormatSchema;)Z"); + + /// from: public boolean canUseSchema(com.fasterxml.jackson.core.FormatSchema schema) + /// + /// Method that can be used to verify that given schema can be used with + /// this parser (using \#setSchema). + ///@param schema Schema to check + ///@return True if this parser can use given schema; false if not + bool canUseSchema( + jni.JObject schema, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_canUseSchema, + jni.JniCallType.booleanType, [schema.reference]).boolean; + } + + static final _id_requiresCustomCodec = + jniAccessors.getMethodIDOf(_classRef, r"requiresCustomCodec", r"()Z"); + + /// from: public boolean requiresCustomCodec() + /// + /// Method that can be called to determine if a custom + /// ObjectCodec is needed for binding data parsed + /// using JsonParser constructed by this factory + /// (which typically also implies the same for serialization + /// with JsonGenerator). + ///@return True if format-specific codec is needed with this parser; false if a general + /// ObjectCodec is enough + ///@since 2.1 + bool requiresCustomCodec() { + return jniAccessors.callMethodWithArgs(reference, _id_requiresCustomCodec, + jni.JniCallType.booleanType, []).boolean; + } + + static final _id_canParseAsync = + jniAccessors.getMethodIDOf(_classRef, r"canParseAsync", r"()Z"); + + /// from: public boolean canParseAsync() + /// + /// Method that can be called to determine if this parser instance + /// uses non-blocking ("asynchronous") input access for decoding or not. + /// Access mode is determined by earlier calls via JsonFactory; + /// it may not be changed after construction. + /// + /// If non-blocking decoding is (@code true}, it is possible to call + /// \#getNonBlockingInputFeeder() to obtain object to use + /// for feeding input; otherwise (false returned) + /// input is read by blocking + ///@return True if this is a non-blocking ("asynchronous") parser + ///@since 2.9 + bool canParseAsync() { + return jniAccessors.callMethodWithArgs( + reference, _id_canParseAsync, jni.JniCallType.booleanType, []).boolean; + } + + static final _id_getNonBlockingInputFeeder = jniAccessors.getMethodIDOf( + _classRef, + r"getNonBlockingInputFeeder", + r"()Lcom/fasterxml/jackson/core/async/NonBlockingInputFeeder;"); + + /// from: public com.fasterxml.jackson.core.async.NonBlockingInputFeeder getNonBlockingInputFeeder() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that will either return a feeder instance (if parser uses + /// non-blocking, aka asynchronous access); or null for + /// parsers that use blocking I/O. + ///@return Input feeder to use with non-blocking (async) parsing + ///@since 2.9 + jni.JObject getNonBlockingInputFeeder() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_getNonBlockingInputFeeder, + jni.JniCallType.objectType, []).object); + } + + static final _id_getReadCapabilities = jniAccessors.getMethodIDOf( + _classRef, + r"getReadCapabilities", + r"()Lcom/fasterxml/jackson/core/util/JacksonFeatureSet;"); + + /// from: public com.fasterxml.jackson.core.util.JacksonFeatureSet getReadCapabilities() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Accessor for getting metadata on capabilities of this parser, based on + /// underlying data format being read (directly or indirectly). + ///@return Set of read capabilities for content to read via this parser + ///@since 2.12 + jni.JObject getReadCapabilities() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_getReadCapabilities, + jni.JniCallType.objectType, []).object); + } + + static final _id_version = jniAccessors.getMethodIDOf( + _classRef, r"version", r"()Lcom/fasterxml/jackson/core/Version;"); + + /// from: public abstract com.fasterxml.jackson.core.Version version() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Accessor for getting version of the core package, given a parser instance. + /// Left for sub-classes to implement. + ///@return Version of this generator (derived from version declared for + /// {@code jackson-core} jar that contains the class + jni.JObject version() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_version, jni.JniCallType.objectType, []).object); + } + + static final _id_close = + jniAccessors.getMethodIDOf(_classRef, r"close", r"()V"); + + /// from: public abstract void close() + /// + /// Closes the parser so that no further iteration or data access + /// can be made; will also close the underlying input source + /// if parser either __owns__ the input source, or feature + /// Feature\#AUTO_CLOSE_SOURCE is enabled. + /// Whether parser owns the input source depends on factory + /// method that was used to construct instance (so check + /// com.fasterxml.jackson.core.JsonFactory for details, + /// but the general + /// idea is that if caller passes in closable resource (such + /// as InputStream or Reader) parser does NOT + /// own the source; but if it passes a reference (such as + /// java.io.File or java.net.URL and creates + /// stream or reader it does own them. + ///@throws IOException if there is either an underlying I/O problem + void close() { + return jniAccessors.callMethodWithArgs( + reference, _id_close, jni.JniCallType.voidType, []).check(); + } + + static final _id_isClosed = + jniAccessors.getMethodIDOf(_classRef, r"isClosed", r"()Z"); + + /// from: public abstract boolean isClosed() + /// + /// Method that can be called to determine whether this parser + /// is closed or not. If it is closed, no new tokens can be + /// retrieved by calling \#nextToken (and the underlying + /// stream may be closed). Closing may be due to an explicit + /// call to \#close or because parser has encountered + /// end of input. + ///@return {@code True} if this parser instance has been closed + bool isClosed() { + return jniAccessors.callMethodWithArgs( + reference, _id_isClosed, jni.JniCallType.booleanType, []).boolean; + } + + static final _id_getParsingContext = jniAccessors.getMethodIDOf( + _classRef, + r"getParsingContext", + r"()Lcom/fasterxml/jackson/core/JsonStreamContext;"); + + /// from: public abstract com.fasterxml.jackson.core.JsonStreamContext getParsingContext() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that can be used to access current parsing context reader + /// is in. There are 3 different types: root, array and object contexts, + /// with slightly different available information. Contexts are + /// hierarchically nested, and can be used for example for figuring + /// out part of the input document that correspond to specific + /// array or object (for highlighting purposes, or error reporting). + /// Contexts can also be used for simple xpath-like matching of + /// input, if so desired. + ///@return Stream input context (JsonStreamContext) associated with this parser + jni.JObject getParsingContext() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_getParsingContext, + jni.JniCallType.objectType, []).object); + } + + static final _id_currentLocation = jniAccessors.getMethodIDOf(_classRef, + r"currentLocation", r"()Lcom/fasterxml/jackson/core/JsonLocation;"); + + /// from: public com.fasterxml.jackson.core.JsonLocation currentLocation() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that returns location of the last processed input unit (character + /// or byte) from the input; + /// usually for error reporting purposes. + /// + /// Note that the location is not guaranteed to be accurate (although most + /// implementation will try their best): some implementations may only + /// report specific boundary locations (start or end locations of tokens) + /// and others only return JsonLocation\#NA due to not having access + /// to input location information (when delegating actual decoding work + /// to other library) + ///@return Location of the last processed input unit (byte or character) + ///@since 2.13 + jni.JObject currentLocation() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_currentLocation, jni.JniCallType.objectType, []).object); + } + + static final _id_currentTokenLocation = jniAccessors.getMethodIDOf(_classRef, + r"currentTokenLocation", r"()Lcom/fasterxml/jackson/core/JsonLocation;"); + + /// from: public com.fasterxml.jackson.core.JsonLocation currentTokenLocation() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that return the __starting__ location of the current + /// (most recently returned) + /// token; that is, the position of the first input unit (character or byte) from input + /// that starts the current token. + /// + /// Note that the location is not guaranteed to be accurate (although most + /// implementation will try their best): some implementations may only + /// return JsonLocation\#NA due to not having access + /// to input location information (when delegating actual decoding work + /// to other library) + ///@return Starting location of the token parser currently points to + ///@since 2.13 (will eventually replace \#getTokenLocation) + jni.JObject currentTokenLocation() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_currentTokenLocation, + jni.JniCallType.objectType, []).object); + } + + static final _id_getCurrentLocation = jniAccessors.getMethodIDOf(_classRef, + r"getCurrentLocation", r"()Lcom/fasterxml/jackson/core/JsonLocation;"); + + /// from: public abstract com.fasterxml.jackson.core.JsonLocation getCurrentLocation() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Alias for \#currentLocation(), to be deprecated in later + /// Jackson 2.x versions (and removed from Jackson 3.0). + ///@return Location of the last processed input unit (byte or character) + jni.JObject getCurrentLocation() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_getCurrentLocation, + jni.JniCallType.objectType, []).object); + } + + static final _id_getTokenLocation = jniAccessors.getMethodIDOf(_classRef, + r"getTokenLocation", r"()Lcom/fasterxml/jackson/core/JsonLocation;"); + + /// from: public abstract com.fasterxml.jackson.core.JsonLocation getTokenLocation() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Alias for \#currentTokenLocation(), to be deprecated in later + /// Jackson 2.x versions (and removed from Jackson 3.0). + ///@return Starting location of the token parser currently points to + jni.JObject getTokenLocation() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_getTokenLocation, + jni.JniCallType.objectType, []).object); + } + + static final _id_currentValue = jniAccessors.getMethodIDOf( + _classRef, r"currentValue", r"()Ljava/lang/Object;"); + + /// from: public java.lang.Object currentValue() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Helper method, usually equivalent to: + /// + /// getParsingContext().getCurrentValue(); + /// + /// + /// Note that "current value" is NOT populated (or used) by Streaming parser; + /// it is only used by higher-level data-binding functionality. + /// The reason it is included here is that it can be stored and accessed hierarchically, + /// and gets passed through data-binding. + ///@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 const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_currentValue, jni.JniCallType.objectType, []).object); + } + + static final _id_assignCurrentValue = jniAccessors.getMethodIDOf( + _classRef, r"assignCurrentValue", r"(Ljava/lang/Object;)V"); + + /// from: public void assignCurrentValue(java.lang.Object v) + /// + /// Helper method, usually equivalent to: + /// + /// getParsingContext().setCurrentValue(v); + /// + ///@param v Current value to assign for the current input context of this parser + ///@since 2.13 (added as replacement for older \#setCurrentValue + void assignCurrentValue( + jni.JObject v, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_assignCurrentValue, + jni.JniCallType.voidType, [v.reference]).check(); + } + + static final _id_getCurrentValue = jniAccessors.getMethodIDOf( + _classRef, r"getCurrentValue", r"()Ljava/lang/Object;"); + + /// from: public java.lang.Object getCurrentValue() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Alias for \#currentValue(), to be deprecated in later + /// 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 const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_getCurrentValue, jni.JniCallType.objectType, []).object); + } + + static final _id_setCurrentValue = jniAccessors.getMethodIDOf( + _classRef, r"setCurrentValue", r"(Ljava/lang/Object;)V"); + + /// from: public void setCurrentValue(java.lang.Object v) + /// + /// Alias for \#assignCurrentValue, to be deprecated in later + /// Jackson 2.x versions (and removed from Jackson 3.0). + ///@param v Current value to assign for the current input context of this parser + void setCurrentValue( + jni.JObject v, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_setCurrentValue, + jni.JniCallType.voidType, [v.reference]).check(); + } + + static final _id_releaseBuffered = jniAccessors.getMethodIDOf( + _classRef, r"releaseBuffered", r"(Ljava/io/OutputStream;)I"); + + /// from: public int releaseBuffered(java.io.OutputStream out) + /// + /// Method that can be called to push back any content that + /// has been read but not consumed by the parser. This is usually + /// done after reading all content of interest using parser. + /// Content is released by writing it to given stream if possible; + /// if underlying input is byte-based it can released, if not (char-based) + /// it can not. + ///@param out OutputStream to which buffered, undecoded content is written to + ///@return -1 if the underlying content source is not byte based + /// (that is, input can not be sent to OutputStream; + /// otherwise number of bytes released (0 if there was nothing to release) + ///@throws IOException if write to stream threw exception + int releaseBuffered( + jni.JObject out, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_releaseBuffered, + jni.JniCallType.intType, [out.reference]).integer; + } + + static final _id_releaseBuffered1 = jniAccessors.getMethodIDOf( + _classRef, r"releaseBuffered", r"(Ljava/io/Writer;)I"); + + /// from: public int releaseBuffered(java.io.Writer w) + /// + /// Method that can be called to push back any content that + /// has been read but not consumed by the parser. + /// This is usually + /// done after reading all content of interest using parser. + /// Content is released by writing it to given writer if possible; + /// if underlying input is char-based it can released, if not (byte-based) + /// it can not. + ///@param w Writer to which buffered but unprocessed content is written to + ///@return -1 if the underlying content source is not char-based + /// (that is, input can not be sent to Writer; + /// otherwise number of chars released (0 if there was nothing to release) + ///@throws IOException if write using Writer threw exception + int releaseBuffered1( + jni.JObject w, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_releaseBuffered1, + jni.JniCallType.intType, [w.reference]).integer; + } + + static final _id_enable = jniAccessors.getMethodIDOf(_classRef, r"enable", + r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/core/JsonParser;"); + + /// from: public com.fasterxml.jackson.core.JsonParser enable(com.fasterxml.jackson.core.JsonParser.Feature f) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for enabling specified parser feature + /// (check Feature for list of features) + ///@param f Feature to enable + ///@return This parser, to allow call chaining + JsonParser enable( + JsonParser_Feature f, + ) { + return const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_enable, + jni.JniCallType.objectType, + [f.reference]).object); + } + + static final _id_disable = jniAccessors.getMethodIDOf(_classRef, r"disable", + r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/core/JsonParser;"); + + /// from: public com.fasterxml.jackson.core.JsonParser disable(com.fasterxml.jackson.core.JsonParser.Feature f) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for disabling specified feature + /// (check Feature for list of features) + ///@param f Feature to disable + ///@return This parser, to allow call chaining + JsonParser disable( + JsonParser_Feature f, + ) { + return const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_disable, + jni.JniCallType.objectType, + [f.reference]).object); + } + + static final _id_configure = jniAccessors.getMethodIDOf( + _classRef, + r"configure", + r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;Z)Lcom/fasterxml/jackson/core/JsonParser;"); + + /// from: public com.fasterxml.jackson.core.JsonParser configure(com.fasterxml.jackson.core.JsonParser.Feature f, boolean state) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for enabling or disabling specified feature + /// (check Feature for list of features) + ///@param f Feature to enable or disable + ///@param state Whether to enable feature ({@code true}) or disable ({@code false}) + ///@return This parser, to allow call chaining + JsonParser configure( + JsonParser_Feature f, + bool state, + ) { + return const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_configure, + jni.JniCallType.objectType, + [f.reference, state ? 1 : 0]).object); + } + + static final _id_isEnabled = jniAccessors.getMethodIDOf(_classRef, + r"isEnabled", r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Z"); + + /// from: public boolean isEnabled(com.fasterxml.jackson.core.JsonParser.Feature f) + /// + /// Method for checking whether specified Feature is enabled. + ///@param f Feature to check + ///@return {@code True} if feature is enabled; {@code false} otherwise + bool isEnabled( + JsonParser_Feature f, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_isEnabled, + jni.JniCallType.booleanType, [f.reference]).boolean; + } + + static final _id_isEnabled1 = jniAccessors.getMethodIDOf(_classRef, + r"isEnabled", r"(Lcom/fasterxml/jackson/core/StreamReadFeature;)Z"); + + /// from: public boolean isEnabled(com.fasterxml.jackson.core.StreamReadFeature f) + /// + /// Method for checking whether specified Feature is enabled. + ///@param f Feature to check + ///@return {@code True} if feature is enabled; {@code false} otherwise + ///@since 2.10 + bool isEnabled1( + jni.JObject f, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_isEnabled1, + jni.JniCallType.booleanType, [f.reference]).boolean; + } + + static final _id_getFeatureMask = + jniAccessors.getMethodIDOf(_classRef, r"getFeatureMask", r"()I"); + + /// from: public int getFeatureMask() + /// + /// Bulk access method for getting state of all standard Features. + ///@return Bit mask that defines current states of all standard Features. + ///@since 2.3 + int getFeatureMask() { + return jniAccessors.callMethodWithArgs( + reference, _id_getFeatureMask, jni.JniCallType.intType, []).integer; + } + + static final _id_setFeatureMask = jniAccessors.getMethodIDOf(_classRef, + r"setFeatureMask", r"(I)Lcom/fasterxml/jackson/core/JsonParser;"); + + /// from: public com.fasterxml.jackson.core.JsonParser setFeatureMask(int mask) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Bulk set method for (re)setting states of all standard Features + ///@param mask Bit mask that defines set of features to enable + ///@return This parser, to allow call chaining + ///@since 2.3 + ///@deprecated Since 2.7, use \#overrideStdFeatures(int, int) instead + JsonParser setFeatureMask( + int mask, + ) { + return const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_setFeatureMask, + jni.JniCallType.objectType, + [jni.JValueInt(mask)]).object); + } + + static final _id_overrideStdFeatures = jniAccessors.getMethodIDOf(_classRef, + r"overrideStdFeatures", r"(II)Lcom/fasterxml/jackson/core/JsonParser;"); + + /// from: public com.fasterxml.jackson.core.JsonParser overrideStdFeatures(int values, int mask) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Bulk set method for (re)setting states of features specified by mask. + /// Functionally equivalent to + /// + /// int oldState = getFeatureMask(); + /// int newState = (oldState & ~mask) | (values & mask); + /// setFeatureMask(newState); + /// + /// but preferred as this lets caller more efficiently specify actual changes made. + ///@param values Bit mask of set/clear state for features to change + ///@param mask Bit mask of features to change + ///@return This parser, to allow call chaining + ///@since 2.6 + JsonParser overrideStdFeatures( + int values, + int mask, + ) { + return const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_overrideStdFeatures, + jni.JniCallType.objectType, + [jni.JValueInt(values), jni.JValueInt(mask)]).object); + } + + static final _id_getFormatFeatures = + jniAccessors.getMethodIDOf(_classRef, r"getFormatFeatures", r"()I"); + + /// from: public int getFormatFeatures() + /// + /// Bulk access method for getting state of all FormatFeatures, format-specific + /// on/off configuration settings. + ///@return Bit mask that defines current states of all standard FormatFeatures. + ///@since 2.6 + int getFormatFeatures() { + return jniAccessors.callMethodWithArgs( + reference, _id_getFormatFeatures, jni.JniCallType.intType, []).integer; + } + + static final _id_overrideFormatFeatures = jniAccessors.getMethodIDOf( + _classRef, + r"overrideFormatFeatures", + r"(II)Lcom/fasterxml/jackson/core/JsonParser;"); + + /// from: public com.fasterxml.jackson.core.JsonParser overrideFormatFeatures(int values, int mask) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Bulk set method for (re)setting states of FormatFeatures, + /// by specifying values (set / clear) along with a mask, to determine + /// which features to change, if any. + /// + /// Default implementation will simply throw an exception to indicate that + /// the parser implementation does not support any FormatFeatures. + ///@param values Bit mask of set/clear state for features to change + ///@param mask Bit mask of features to change + ///@return This parser, to allow call chaining + ///@since 2.6 + JsonParser overrideFormatFeatures( + int values, + int mask, + ) { + return const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_overrideFormatFeatures, + jni.JniCallType.objectType, + [jni.JValueInt(values), jni.JValueInt(mask)]).object); + } + + static final _id_nextToken = jniAccessors.getMethodIDOf( + _classRef, r"nextToken", r"()Lcom/fasterxml/jackson/core/JsonToken;"); + + /// from: public abstract com.fasterxml.jackson.core.JsonToken nextToken() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Main iteration method, which will advance stream enough + /// to determine type of the next token, if any. If none + /// remaining (stream has no content other than possible + /// white space before ending), null will be returned. + ///@return Next token from the stream, if any found, or null + /// to indicate end-of-input + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + jsontoken_.JsonToken nextToken() { + return const jsontoken_.$JsonTokenType().fromRef(jniAccessors + .callMethodWithArgs( + reference, _id_nextToken, jni.JniCallType.objectType, []).object); + } + + static final _id_nextValue = jniAccessors.getMethodIDOf( + _classRef, r"nextValue", r"()Lcom/fasterxml/jackson/core/JsonToken;"); + + /// from: public abstract com.fasterxml.jackson.core.JsonToken nextValue() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Iteration method that will advance stream enough + /// to determine type of the next token that is a value type + /// (including JSON Array and Object start/end markers). + /// Or put another way, nextToken() will be called once, + /// and if JsonToken\#FIELD_NAME is returned, another + /// time to get the value for the field. + /// Method is most useful for iterating over value entries + /// of JSON objects; field name will still be available + /// by calling \#getCurrentName when parser points to + /// the value. + ///@return Next non-field-name token from the stream, if any found, + /// or null to indicate end-of-input (or, for non-blocking + /// parsers, JsonToken\#NOT_AVAILABLE if no tokens were + /// available yet) + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + jsontoken_.JsonToken nextValue() { + return const jsontoken_.$JsonTokenType().fromRef(jniAccessors + .callMethodWithArgs( + reference, _id_nextValue, jni.JniCallType.objectType, []).object); + } + + static final _id_nextFieldName = jniAccessors.getMethodIDOf(_classRef, + r"nextFieldName", r"(Lcom/fasterxml/jackson/core/SerializableString;)Z"); + + /// from: public boolean nextFieldName(com.fasterxml.jackson.core.SerializableString str) + /// + /// Method that fetches next token (as if calling \#nextToken) and + /// verifies whether it is JsonToken\#FIELD_NAME with specified name + /// and returns result of that comparison. + /// It is functionally equivalent to: + ///
    +  ///  return (nextToken() == JsonToken.FIELD_NAME) && str.getValue().equals(getCurrentName());
    +  ///
    + /// but may be faster for parser to verify, and can therefore be used if caller + /// expects to get such a property name from input next. + ///@param str Property name to compare next token to (if next token is + /// JsonToken.FIELD_NAME) + ///@return {@code True} if parser advanced to {@code JsonToken.FIELD_NAME} with + /// specified name; {@code false} otherwise (different token or non-matching name) + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + bool nextFieldName( + jni.JObject str, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_nextFieldName, + jni.JniCallType.booleanType, [str.reference]).boolean; + } + + static final _id_nextFieldName1 = jniAccessors.getMethodIDOf( + _classRef, r"nextFieldName", r"()Ljava/lang/String;"); + + /// from: public java.lang.String nextFieldName() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that fetches next token (as if calling \#nextToken) and + /// verifies whether it is JsonToken\#FIELD_NAME; if it is, + /// returns same as \#getCurrentName(), otherwise null. + ///@return Name of the the {@code JsonToken.FIELD_NAME} parser advanced to, if any; + /// {@code null} if next token is of some other type + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + ///@since 2.5 + jni.JString nextFieldName1() { + return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_nextFieldName1, jni.JniCallType.objectType, []).object); + } + + static final _id_nextTextValue = jniAccessors.getMethodIDOf( + _classRef, r"nextTextValue", r"()Ljava/lang/String;"); + + /// from: public java.lang.String nextTextValue() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that fetches next token (as if calling \#nextToken) and + /// if it is JsonToken\#VALUE_STRING returns contained String value; + /// otherwise returns null. + /// It is functionally equivalent to: + ///
    +  ///  return (nextToken() == JsonToken.VALUE_STRING) ? getText() : null;
    +  ///
    + /// but may be faster for parser to process, and can therefore be used if caller + /// expects to get a String value next from input. + ///@return Text value of the {@code JsonToken.VALUE_STRING} token parser advanced + /// to; or {@code null} if next token is of some other type + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + jni.JString nextTextValue() { + return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_nextTextValue, jni.JniCallType.objectType, []).object); + } + + static final _id_nextIntValue = + jniAccessors.getMethodIDOf(_classRef, r"nextIntValue", r"(I)I"); + + /// from: public int nextIntValue(int defaultValue) + /// + /// Method that fetches next token (as if calling \#nextToken) and + /// if it is JsonToken\#VALUE_NUMBER_INT returns 32-bit int value; + /// otherwise returns specified default value + /// It is functionally equivalent to: + ///
    +  ///  return (nextToken() == JsonToken.VALUE_NUMBER_INT) ? getIntValue() : defaultValue;
    +  ///
    + /// but may be faster for parser to process, and can therefore be used if caller + /// expects to get an int value next from input. + /// + /// NOTE: value checks are performed similar to \#getIntValue() + ///@param defaultValue Value to return if next token is NOT of type {@code JsonToken.VALUE_NUMBER_INT} + ///@return Integer ({@code int}) value of the {@code JsonToken.VALUE_NUMBER_INT} token parser advanced + /// to; or {@code defaultValue} if next token is of some other type + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + ///@throws InputCoercionException if integer number does not fit in Java {@code int} + int nextIntValue( + int defaultValue, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_nextIntValue, + jni.JniCallType.intType, [jni.JValueInt(defaultValue)]).integer; + } + + static final _id_nextLongValue = + jniAccessors.getMethodIDOf(_classRef, r"nextLongValue", r"(J)J"); + + /// from: public long nextLongValue(long defaultValue) + /// + /// Method that fetches next token (as if calling \#nextToken) and + /// if it is JsonToken\#VALUE_NUMBER_INT returns 64-bit long value; + /// otherwise returns specified default value + /// It is functionally equivalent to: + ///
    +  ///  return (nextToken() == JsonToken.VALUE_NUMBER_INT) ? getLongValue() : defaultValue;
    +  ///
    + /// but may be faster for parser to process, and can therefore be used if caller + /// expects to get a long value next from input. + /// + /// NOTE: value checks are performed similar to \#getLongValue() + ///@param defaultValue Value to return if next token is NOT of type {@code JsonToken.VALUE_NUMBER_INT} + ///@return {@code long} value of the {@code JsonToken.VALUE_NUMBER_INT} token parser advanced + /// to; or {@code defaultValue} if next token is of some other type + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + ///@throws InputCoercionException if integer number does not fit in Java {@code long} + int nextLongValue( + int defaultValue, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_nextLongValue, + jni.JniCallType.longType, [defaultValue]).long; + } + + static final _id_nextBooleanValue = jniAccessors.getMethodIDOf( + _classRef, r"nextBooleanValue", r"()Ljava/lang/Boolean;"); + + /// from: public java.lang.Boolean nextBooleanValue() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that fetches next token (as if calling \#nextToken) and + /// if it is JsonToken\#VALUE_TRUE or JsonToken\#VALUE_FALSE + /// returns matching Boolean value; otherwise return null. + /// It is functionally equivalent to: + ///
    +  ///  JsonToken t = nextToken();
    +  ///  if (t == JsonToken.VALUE_TRUE) return Boolean.TRUE;
    +  ///  if (t == JsonToken.VALUE_FALSE) return Boolean.FALSE;
    +  ///  return null;
    +  ///
    + /// but may be faster for parser to process, and can therefore be used if caller + /// expects to get a Boolean value next from input. + ///@return {@code Boolean} value of the {@code JsonToken.VALUE_TRUE} or {@code JsonToken.VALUE_FALSE} + /// token parser advanced to; or {@code null} if next token is of some other type + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + jni.JObject nextBooleanValue() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_nextBooleanValue, + jni.JniCallType.objectType, []).object); + } + + static final _id_skipChildren = jniAccessors.getMethodIDOf( + _classRef, r"skipChildren", r"()Lcom/fasterxml/jackson/core/JsonParser;"); + + /// from: public abstract com.fasterxml.jackson.core.JsonParser skipChildren() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that will skip all child tokens of an array or + /// object token that the parser currently points to, + /// iff stream points to + /// JsonToken\#START_OBJECT or JsonToken\#START_ARRAY. + /// If not, it will do nothing. + /// After skipping, stream will point to __matching__ + /// JsonToken\#END_OBJECT or JsonToken\#END_ARRAY + /// (possibly skipping nested pairs of START/END OBJECT/ARRAY tokens + /// as well as value tokens). + /// The idea is that after calling this method, application + /// will call \#nextToken to point to the next + /// available token, if any. + ///@return This parser, to allow call chaining + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + JsonParser skipChildren() { + return const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_skipChildren, jni.JniCallType.objectType, []).object); + } + + static final _id_finishToken = + jniAccessors.getMethodIDOf(_classRef, r"finishToken", r"()V"); + + /// from: public void finishToken() + /// + /// Method that may be used to force full handling of the current token + /// so that even if lazy processing is enabled, the whole contents are + /// read for possible retrieval. This is usually used to ensure that + /// the token end location is available, as well as token contents + /// (similar to what calling, say \#getTextCharacters(), would + /// achieve). + /// + /// Note that for many dataformat implementations this method + /// will not do anything; this is the default implementation unless + /// overridden by sub-classes. + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + ///@since 2.8 + void finishToken() { + return jniAccessors.callMethodWithArgs( + reference, _id_finishToken, jni.JniCallType.voidType, []).check(); + } + + static final _id_currentToken = jniAccessors.getMethodIDOf( + _classRef, r"currentToken", r"()Lcom/fasterxml/jackson/core/JsonToken;"); + + /// from: public com.fasterxml.jackson.core.JsonToken currentToken() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Accessor to find which token parser currently points to, if any; + /// null will be returned if none. + /// If return value is non-null, data associated with the token + /// is available via other accessor methods. + ///@return Type of the token this parser currently points to, + /// if any: null before any tokens have been read, and + /// after end-of-input has been encountered, as well as + /// if the current token has been explicitly cleared. + ///@since 2.8 + jsontoken_.JsonToken currentToken() { + return const jsontoken_.$JsonTokenType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_currentToken, + jni.JniCallType.objectType, []).object); + } + + static final _id_currentTokenId = + jniAccessors.getMethodIDOf(_classRef, r"currentTokenId", r"()I"); + + /// from: public int currentTokenId() + /// + /// Method similar to \#getCurrentToken() but that returns an + /// int instead of JsonToken (enum value). + /// + /// Use of int directly is typically more efficient on switch statements, + /// so this method may be useful when building low-overhead codecs. + /// Note, however, that effect may not be big enough to matter: make sure + /// to profile performance before deciding to use this method. + ///@since 2.8 + ///@return {@code int} matching one of constants from JsonTokenId. + int currentTokenId() { + return jniAccessors.callMethodWithArgs( + reference, _id_currentTokenId, jni.JniCallType.intType, []).integer; + } + + static final _id_getCurrentToken = jniAccessors.getMethodIDOf(_classRef, + r"getCurrentToken", r"()Lcom/fasterxml/jackson/core/JsonToken;"); + + /// from: public abstract com.fasterxml.jackson.core.JsonToken getCurrentToken() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Alias for \#currentToken(), may be deprecated sometime after + /// Jackson 2.13 (will be removed from 3.0). + ///@return Type of the token this parser currently points to, + /// if any: null before any tokens have been read, and + jsontoken_.JsonToken getCurrentToken() { + return const jsontoken_.$JsonTokenType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_getCurrentToken, + jni.JniCallType.objectType, []).object); + } + + static final _id_getCurrentTokenId = + jniAccessors.getMethodIDOf(_classRef, r"getCurrentTokenId", r"()I"); + + /// from: public abstract int getCurrentTokenId() + /// + /// Deprecated alias for \#currentTokenId(). + ///@return {@code int} matching one of constants from JsonTokenId. + ///@deprecated Since 2.12 use \#currentTokenId instead + int getCurrentTokenId() { + return jniAccessors.callMethodWithArgs( + reference, _id_getCurrentTokenId, jni.JniCallType.intType, []).integer; + } + + static final _id_hasCurrentToken = + jniAccessors.getMethodIDOf(_classRef, r"hasCurrentToken", r"()Z"); + + /// from: public abstract boolean hasCurrentToken() + /// + /// Method for checking whether parser currently points to + /// a token (and data for that token is available). + /// Equivalent to check for parser.getCurrentToken() != null. + ///@return True if the parser just returned a valid + /// token via \#nextToken; false otherwise (parser + /// was just constructed, encountered end-of-input + /// and returned null from \#nextToken, or the token + /// has been consumed) + bool hasCurrentToken() { + return jniAccessors.callMethodWithArgs(reference, _id_hasCurrentToken, + jni.JniCallType.booleanType, []).boolean; + } + + static final _id_hasTokenId = + jniAccessors.getMethodIDOf(_classRef, r"hasTokenId", r"(I)Z"); + + /// from: public abstract boolean hasTokenId(int id) + /// + /// Method that is functionally equivalent to: + /// + /// return currentTokenId() == id + /// + /// but may be more efficiently implemented. + /// + /// Note that no traversal or conversion is performed; so in some + /// cases calling method like \#isExpectedStartArrayToken() + /// is necessary instead. + ///@param id Token id to match (from (@link JsonTokenId}) + ///@return {@code True} if the parser current points to specified token + ///@since 2.5 + bool hasTokenId( + int id, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_hasTokenId, + jni.JniCallType.booleanType, [jni.JValueInt(id)]).boolean; + } + + static final _id_hasToken = jniAccessors.getMethodIDOf( + _classRef, r"hasToken", r"(Lcom/fasterxml/jackson/core/JsonToken;)Z"); + + /// from: public abstract boolean hasToken(com.fasterxml.jackson.core.JsonToken t) + /// + /// Method that is functionally equivalent to: + /// + /// return currentToken() == t + /// + /// but may be more efficiently implemented. + /// + /// Note that no traversal or conversion is performed; so in some + /// cases calling method like \#isExpectedStartArrayToken() + /// is necessary instead. + ///@param t Token to match + ///@return {@code True} if the parser current points to specified token + ///@since 2.6 + bool hasToken( + jsontoken_.JsonToken t, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_hasToken, + jni.JniCallType.booleanType, [t.reference]).boolean; + } + + static final _id_isExpectedStartArrayToken = jniAccessors.getMethodIDOf( + _classRef, r"isExpectedStartArrayToken", r"()Z"); + + /// from: public boolean isExpectedStartArrayToken() + /// + /// Specialized accessor that can be used to verify that the current + /// token indicates start array (usually meaning that current token + /// is JsonToken\#START_ARRAY) when start array is expected. + /// For some specialized parsers this can return true for other cases + /// as well; this is usually done to emulate arrays in cases underlying + /// format is ambiguous (XML, for example, has no format-level difference + /// between Objects and Arrays; it just has elements). + /// + /// Default implementation is equivalent to: + ///
    +  ///   currentToken() == JsonToken.START_ARRAY
    +  ///
    + /// but may be overridden by custom parser implementations. + ///@return True if the current token can be considered as a + /// start-array marker (such JsonToken\#START_ARRAY); + /// {@code false} if not + bool isExpectedStartArrayToken() { + return jniAccessors.callMethodWithArgs(reference, + _id_isExpectedStartArrayToken, jni.JniCallType.booleanType, []).boolean; + } + + static final _id_isExpectedStartObjectToken = jniAccessors.getMethodIDOf( + _classRef, r"isExpectedStartObjectToken", r"()Z"); + + /// from: public boolean isExpectedStartObjectToken() + /// + /// Similar to \#isExpectedStartArrayToken(), but checks whether stream + /// currently points to JsonToken\#START_OBJECT. + ///@return True if the current token can be considered as a + /// start-array marker (such JsonToken\#START_OBJECT); + /// {@code false} if not + ///@since 2.5 + bool isExpectedStartObjectToken() { + return jniAccessors.callMethodWithArgs( + reference, + _id_isExpectedStartObjectToken, + jni.JniCallType.booleanType, []).boolean; + } + + static final _id_isExpectedNumberIntToken = jniAccessors.getMethodIDOf( + _classRef, r"isExpectedNumberIntToken", r"()Z"); + + /// from: public boolean isExpectedNumberIntToken() + /// + /// Similar to \#isExpectedStartArrayToken(), but checks whether stream + /// currently points to JsonToken\#VALUE_NUMBER_INT. + /// + /// The initial use case is for XML backend to efficiently (attempt to) coerce + /// textual content into numbers. + ///@return True if the current token can be considered as a + /// start-array marker (such JsonToken\#VALUE_NUMBER_INT); + /// {@code false} if not + ///@since 2.12 + bool isExpectedNumberIntToken() { + return jniAccessors.callMethodWithArgs(reference, + _id_isExpectedNumberIntToken, jni.JniCallType.booleanType, []).boolean; + } + + static final _id_isNaN = + jniAccessors.getMethodIDOf(_classRef, r"isNaN", r"()Z"); + + /// from: public boolean isNaN() + /// + /// Access for checking whether current token is a numeric value token, but + /// one that is of "not-a-number" (NaN) variety (including both "NaN" AND + /// positive/negative infinity!): not supported by all formats, + /// but often supported for JsonToken\#VALUE_NUMBER_FLOAT. + /// NOTE: roughly equivalent to calling !Double.isFinite() + /// on value you would get from calling \#getDoubleValue(). + ///@return {@code True} if the current token is of type JsonToken\#VALUE_NUMBER_FLOAT + /// but represents a "Not a Number"; {@code false} for other tokens and regular + /// floating-point numbers + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + ///@since 2.9 + bool isNaN() { + return jniAccessors.callMethodWithArgs( + reference, _id_isNaN, jni.JniCallType.booleanType, []).boolean; + } + + static final _id_clearCurrentToken = + jniAccessors.getMethodIDOf(_classRef, r"clearCurrentToken", r"()V"); + + /// from: public abstract void clearCurrentToken() + /// + /// Method called to "consume" the current token by effectively + /// removing it so that \#hasCurrentToken returns false, and + /// \#getCurrentToken null). + /// Cleared token value can still be accessed by calling + /// \#getLastClearedToken (if absolutely needed), but + /// usually isn't. + /// + /// Method was added to be used by the optional data binder, since + /// it has to be able to consume last token used for binding (so that + /// it will not be used again). + void clearCurrentToken() { + return jniAccessors.callMethodWithArgs( + reference, _id_clearCurrentToken, jni.JniCallType.voidType, []).check(); + } + + static final _id_getLastClearedToken = jniAccessors.getMethodIDOf(_classRef, + r"getLastClearedToken", r"()Lcom/fasterxml/jackson/core/JsonToken;"); + + /// from: public abstract com.fasterxml.jackson.core.JsonToken getLastClearedToken() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that can be called to get the last token that was + /// cleared using \#clearCurrentToken. This is not necessarily + /// the latest token read. + /// Will return null if no tokens have been cleared, + /// or if parser has been closed. + ///@return Last cleared token, if any; {@code null} otherwise + jsontoken_.JsonToken getLastClearedToken() { + return const jsontoken_.$JsonTokenType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_getLastClearedToken, + jni.JniCallType.objectType, []).object); + } + + static final _id_overrideCurrentName = jniAccessors.getMethodIDOf( + _classRef, r"overrideCurrentName", r"(Ljava/lang/String;)V"); + + /// from: public abstract void overrideCurrentName(java.lang.String name) + /// + /// Method that can be used to change what is considered to be + /// the current (field) name. + /// May be needed to support non-JSON data formats or unusual binding + /// conventions; not needed for typical processing. + /// + /// Note that use of this method should only be done as sort of last + /// resort, as it is a work-around for regular operation. + ///@param name Name to use as the current name; may be null. + void overrideCurrentName( + jni.JString name, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_overrideCurrentName, + jni.JniCallType.voidType, [name.reference]).check(); + } + + static final _id_getCurrentName = jniAccessors.getMethodIDOf( + _classRef, r"getCurrentName", r"()Ljava/lang/String;"); + + /// from: public abstract java.lang.String getCurrentName() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Alias of \#currentName(). + ///@return Name of the current field in the parsing context + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + jni.JString getCurrentName() { + return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_getCurrentName, jni.JniCallType.objectType, []).object); + } + + static final _id_currentName = jniAccessors.getMethodIDOf( + _classRef, r"currentName", r"()Ljava/lang/String;"); + + /// from: public java.lang.String currentName() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that can be called to get the name associated with + /// the current token: for JsonToken\#FIELD_NAMEs it will + /// be the same as what \#getText returns; + /// for field values it will be preceding field name; + /// and for others (array values, root-level values) null. + ///@return Name of the current field in the parsing context + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + ///@since 2.10 + jni.JString currentName() { + return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_currentName, jni.JniCallType.objectType, []).object); + } + + static final _id_getText = jniAccessors.getMethodIDOf( + _classRef, r"getText", r"()Ljava/lang/String;"); + + /// from: public abstract java.lang.String getText() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for accessing textual representation of the current token; + /// if no current token (before first call to \#nextToken, or + /// after encountering end-of-input), returns null. + /// Method can be called for any token type. + ///@return Textual value associated with the current token (one returned + /// by \#nextToken() or other iteration methods) + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + jni.JString getText() { + return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_getText, jni.JniCallType.objectType, []).object); + } + + static final _id_getText1 = + jniAccessors.getMethodIDOf(_classRef, r"getText", r"(Ljava/io/Writer;)I"); + + /// from: public int getText(java.io.Writer writer) + /// + /// Method to read the textual representation of the current token in chunks and + /// pass it to the given Writer. + /// Conceptually same as calling: + ///
    +  ///  writer.write(parser.getText());
    +  ///
    + /// but should typically be more efficient as longer content does need to + /// be combined into a single String to return, and write + /// can occur directly from intermediate buffers Jackson uses. + ///@param writer Writer to write textual content to + ///@return The number of characters written to the Writer + ///@throws IOException for low-level read issues or writes using passed + /// {@code writer}, or + /// JsonParseException for decoding problems + ///@since 2.8 + int getText1( + jni.JObject writer, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_getText1, + jni.JniCallType.intType, [writer.reference]).integer; + } + + static final _id_getTextCharacters = + jniAccessors.getMethodIDOf(_classRef, r"getTextCharacters", r"()[C"); + + /// from: public abstract char[] getTextCharacters() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method similar to \#getText, but that will return + /// underlying (unmodifiable) character array that contains + /// textual value, instead of constructing a String object + /// to contain this information. + /// Note, however, that: + ///
      + ///
    • Textual contents are not guaranteed to start at + /// index 0 (rather, call \#getTextOffset) to + /// know the actual offset + ///
    • + ///
    • Length of textual contents may be less than the + /// length of returned buffer: call \#getTextLength + /// for actual length of returned content. + ///
    • + ///
    + /// + /// Note that caller __MUST NOT__ modify the returned + /// character array in any way -- doing so may corrupt + /// current parser state and render parser instance useless. + /// + /// The only reason to call this method (over \#getText) + /// is to avoid construction of a String object (which + /// will make a copy of contents). + ///@return Buffer that contains the current textual value (but not necessarily + /// at offset 0, and not necessarily until the end of buffer) + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + jni.JArray getTextCharacters() { + return const jni.JArrayType(jni.JCharType()).fromRef(jniAccessors + .callMethodWithArgs(reference, _id_getTextCharacters, + jni.JniCallType.objectType, []).object); + } + + static final _id_getTextLength = + jniAccessors.getMethodIDOf(_classRef, r"getTextLength", r"()I"); + + /// from: public abstract int getTextLength() + /// + /// Accessor used with \#getTextCharacters, to know length + /// of String stored in returned buffer. + ///@return Number of characters within buffer returned + /// by \#getTextCharacters that are part of + /// textual content of the current token. + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + int getTextLength() { + return jniAccessors.callMethodWithArgs( + reference, _id_getTextLength, jni.JniCallType.intType, []).integer; + } + + static final _id_getTextOffset = + jniAccessors.getMethodIDOf(_classRef, r"getTextOffset", r"()I"); + + /// from: public abstract int getTextOffset() + /// + /// Accessor used with \#getTextCharacters, to know offset + /// of the first text content character within buffer. + ///@return Offset of the first character within buffer returned + /// by \#getTextCharacters that is part of + /// textual content of the current token. + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + int getTextOffset() { + return jniAccessors.callMethodWithArgs( + reference, _id_getTextOffset, jni.JniCallType.intType, []).integer; + } + + static final _id_hasTextCharacters = + jniAccessors.getMethodIDOf(_classRef, r"hasTextCharacters", r"()Z"); + + /// from: public abstract boolean hasTextCharacters() + /// + /// Method that can be used to determine whether calling of + /// \#getTextCharacters would be the most efficient + /// way to access textual content for the event parser currently + /// points to. + /// + /// Default implementation simply returns false since only actual + /// implementation class has knowledge of its internal buffering + /// state. + /// Implementations are strongly encouraged to properly override + /// this method, to allow efficient copying of content by other + /// code. + ///@return True if parser currently has character array that can + /// be efficiently returned via \#getTextCharacters; false + /// means that it may or may not exist + bool hasTextCharacters() { + return jniAccessors.callMethodWithArgs(reference, _id_hasTextCharacters, + jni.JniCallType.booleanType, []).boolean; + } + + static final _id_getNumberValue = jniAccessors.getMethodIDOf( + _classRef, r"getNumberValue", r"()Ljava/lang/Number;"); + + /// from: public abstract java.lang.Number getNumberValue() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Generic number value accessor method that will work for + /// all kinds of numeric values. It will return the optimal + /// (simplest/smallest possible) wrapper object that can + /// express the numeric value just parsed. + ///@return Numeric value of the current token in its most optimal + /// representation + ///@throws IOException Problem with access: JsonParseException if + /// the current token is not numeric, or if decoding of the value fails + /// (invalid format for numbers); plain IOException if underlying + /// content read fails (possible if values are extracted lazily) + jni.JObject getNumberValue() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_getNumberValue, jni.JniCallType.objectType, []).object); + } + + static final _id_getNumberValueExact = jniAccessors.getMethodIDOf( + _classRef, r"getNumberValueExact", r"()Ljava/lang/Number;"); + + /// from: public java.lang.Number getNumberValueExact() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method similar to \#getNumberValue with the difference that + /// for floating-point numbers value returned may be BigDecimal + /// if the underlying format does not store floating-point numbers using + /// native representation: for example, textual formats represent numbers + /// as Strings (which are 10-based), and conversion to java.lang.Double + /// is potentially lossy operation. + /// + /// Default implementation simply returns \#getNumberValue() + ///@return Numeric value of the current token using most accurate representation + ///@throws IOException Problem with access: JsonParseException if + /// the current token is not numeric, or if decoding of the value fails + /// (invalid format for numbers); plain IOException if underlying + /// content read fails (possible if values are extracted lazily) + ///@since 2.12 + jni.JObject getNumberValueExact() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_getNumberValueExact, + jni.JniCallType.objectType, []).object); + } + + static final _id_getNumberType = jniAccessors.getMethodIDOf( + _classRef, + r"getNumberType", + r"()Lcom/fasterxml/jackson/core/JsonParser$NumberType;"); + + /// from: public abstract com.fasterxml.jackson.core.JsonParser.NumberType getNumberType() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// If current token is of type + /// JsonToken\#VALUE_NUMBER_INT or + /// JsonToken\#VALUE_NUMBER_FLOAT, returns + /// one of NumberType constants; otherwise returns null. + ///@return Type of current number, if parser points to numeric token; {@code null} otherwise + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + JsonParser_NumberType getNumberType() { + return const $JsonParser_NumberTypeType().fromRef(jniAccessors + .callMethodWithArgs(reference, _id_getNumberType, + jni.JniCallType.objectType, []).object); + } + + static final _id_getByteValue = + jniAccessors.getMethodIDOf(_classRef, r"getByteValue", r"()B"); + + /// from: public byte getByteValue() + /// + /// Numeric accessor that can be called when the current + /// token is of type JsonToken\#VALUE_NUMBER_INT and + /// it can be expressed as a value of Java byte primitive type. + /// Note that in addition to "natural" input range of {@code [-128, 127]}, + /// this also allows "unsigned 8-bit byte" values {@code [128, 255]}: + /// but for this range value will be translated by truncation, leading + /// to sign change. + /// + /// It can also be called for JsonToken\#VALUE_NUMBER_FLOAT; + /// if so, it is equivalent to calling \#getDoubleValue + /// and then casting; except for possible overflow/underflow + /// exception. + /// + /// Note: if the resulting integer value falls outside range of + /// {@code [-128, 255]}, + /// a InputCoercionException + /// will be thrown to indicate numeric overflow/underflow. + ///@return Current number value as {@code byte} (if numeric token within + /// range of {@code [-128, 255]}); otherwise exception thrown + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + int getByteValue() { + return jniAccessors.callMethodWithArgs( + reference, _id_getByteValue, jni.JniCallType.byteType, []).byte; + } + + static final _id_getShortValue = + jniAccessors.getMethodIDOf(_classRef, r"getShortValue", r"()S"); + + /// from: public short getShortValue() + /// + /// Numeric accessor that can be called when the current + /// token is of type JsonToken\#VALUE_NUMBER_INT and + /// it can be expressed as a value of Java short primitive type. + /// It can also be called for JsonToken\#VALUE_NUMBER_FLOAT; + /// if so, it is equivalent to calling \#getDoubleValue + /// and then casting; except for possible overflow/underflow + /// exception. + /// + /// Note: if the resulting integer value falls outside range of + /// Java short, a InputCoercionException + /// will be thrown to indicate numeric overflow/underflow. + ///@return Current number value as {@code short} (if numeric token within + /// Java 16-bit signed {@code short} range); otherwise exception thrown + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + int getShortValue() { + return jniAccessors.callMethodWithArgs( + reference, _id_getShortValue, jni.JniCallType.shortType, []).short; + } + + static final _id_getIntValue = + jniAccessors.getMethodIDOf(_classRef, r"getIntValue", r"()I"); + + /// from: public abstract int getIntValue() + /// + /// Numeric accessor that can be called when the current + /// token is of type JsonToken\#VALUE_NUMBER_INT and + /// it can be expressed as a value of Java int primitive type. + /// It can also be called for JsonToken\#VALUE_NUMBER_FLOAT; + /// if so, it is equivalent to calling \#getDoubleValue + /// and then casting; except for possible overflow/underflow + /// exception. + /// + /// Note: if the resulting integer value falls outside range of + /// Java {@code int}, a InputCoercionException + /// may be thrown to indicate numeric overflow/underflow. + ///@return Current number value as {@code int} (if numeric token within + /// Java 32-bit signed {@code int} range); otherwise exception thrown + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + int getIntValue() { + return jniAccessors.callMethodWithArgs( + reference, _id_getIntValue, jni.JniCallType.intType, []).integer; + } + + static final _id_getLongValue = + jniAccessors.getMethodIDOf(_classRef, r"getLongValue", r"()J"); + + /// from: public abstract long getLongValue() + /// + /// Numeric accessor that can be called when the current + /// token is of type JsonToken\#VALUE_NUMBER_INT and + /// it can be expressed as a Java long primitive type. + /// It can also be called for JsonToken\#VALUE_NUMBER_FLOAT; + /// if so, it is equivalent to calling \#getDoubleValue + /// and then casting to int; except for possible overflow/underflow + /// exception. + /// + /// Note: if the token is an integer, but its value falls + /// outside of range of Java long, a InputCoercionException + /// may be thrown to indicate numeric overflow/underflow. + ///@return Current number value as {@code long} (if numeric token within + /// Java 32-bit signed {@code long} range); otherwise exception thrown + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + int getLongValue() { + return jniAccessors.callMethodWithArgs( + reference, _id_getLongValue, jni.JniCallType.longType, []).long; + } + + static final _id_getBigIntegerValue = jniAccessors.getMethodIDOf( + _classRef, r"getBigIntegerValue", r"()Ljava/math/BigInteger;"); + + /// from: public abstract java.math.BigInteger getBigIntegerValue() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Numeric accessor that can be called when the current + /// token is of type JsonToken\#VALUE_NUMBER_INT and + /// it can not be used as a Java long primitive type due to its + /// magnitude. + /// It can also be called for JsonToken\#VALUE_NUMBER_FLOAT; + /// if so, it is equivalent to calling \#getDecimalValue + /// and then constructing a BigInteger from that value. + ///@return Current number value as BigInteger (if numeric token); + /// otherwise exception thrown + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + jni.JObject getBigIntegerValue() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_getBigIntegerValue, + jni.JniCallType.objectType, []).object); + } + + static final _id_getFloatValue = + jniAccessors.getMethodIDOf(_classRef, r"getFloatValue", r"()F"); + + /// from: public abstract float getFloatValue() + /// + /// Numeric accessor that can be called when the current + /// token is of type JsonToken\#VALUE_NUMBER_FLOAT and + /// it can be expressed as a Java float primitive type. + /// It can also be called for JsonToken\#VALUE_NUMBER_INT; + /// if so, it is equivalent to calling \#getLongValue + /// and then casting; except for possible overflow/underflow + /// exception. + /// + /// Note: if the value falls + /// outside of range of Java float, a InputCoercionException + /// will be thrown to indicate numeric overflow/underflow. + ///@return Current number value as {@code float} (if numeric token within + /// Java {@code float} range); otherwise exception thrown + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + double getFloatValue() { + return jniAccessors.callMethodWithArgs( + reference, _id_getFloatValue, jni.JniCallType.floatType, []).float; + } + + static final _id_getDoubleValue = + jniAccessors.getMethodIDOf(_classRef, r"getDoubleValue", r"()D"); + + /// from: public abstract double getDoubleValue() + /// + /// Numeric accessor that can be called when the current + /// token is of type JsonToken\#VALUE_NUMBER_FLOAT and + /// it can be expressed as a Java double primitive type. + /// It can also be called for JsonToken\#VALUE_NUMBER_INT; + /// if so, it is equivalent to calling \#getLongValue + /// and then casting; except for possible overflow/underflow + /// exception. + /// + /// Note: if the value falls + /// outside of range of Java double, a InputCoercionException + /// will be thrown to indicate numeric overflow/underflow. + ///@return Current number value as {@code double} (if numeric token within + /// Java {@code double} range); otherwise exception thrown + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + double getDoubleValue() { + return jniAccessors.callMethodWithArgs(reference, _id_getDoubleValue, + jni.JniCallType.doubleType, []).doubleFloat; + } + + static final _id_getDecimalValue = jniAccessors.getMethodIDOf( + _classRef, r"getDecimalValue", r"()Ljava/math/BigDecimal;"); + + /// from: public abstract java.math.BigDecimal getDecimalValue() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Numeric accessor that can be called when the current + /// token is of type JsonToken\#VALUE_NUMBER_FLOAT or + /// JsonToken\#VALUE_NUMBER_INT. No under/overflow exceptions + /// are ever thrown. + ///@return Current number value as BigDecimal (if numeric token); + /// otherwise exception thrown + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + jni.JObject getDecimalValue() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_getDecimalValue, jni.JniCallType.objectType, []).object); + } + + static final _id_getBooleanValue = + jniAccessors.getMethodIDOf(_classRef, r"getBooleanValue", r"()Z"); + + /// from: public boolean getBooleanValue() + /// + /// Convenience accessor that can be called when the current + /// token is JsonToken\#VALUE_TRUE or + /// JsonToken\#VALUE_FALSE, to return matching {@code boolean} + /// value. + /// If the current token is of some other type, JsonParseException + /// will be thrown + ///@return {@code True} if current token is {@code JsonToken.VALUE_TRUE}, + /// {@code false} if current token is {@code JsonToken.VALUE_FALSE}; + /// otherwise throws JsonParseException + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + bool getBooleanValue() { + return jniAccessors.callMethodWithArgs(reference, _id_getBooleanValue, + jni.JniCallType.booleanType, []).boolean; + } + + static final _id_getEmbeddedObject = jniAccessors.getMethodIDOf( + _classRef, r"getEmbeddedObject", r"()Ljava/lang/Object;"); + + /// from: public java.lang.Object getEmbeddedObject() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Accessor that can be called if (and only if) the current token + /// is JsonToken\#VALUE_EMBEDDED_OBJECT. For other token types, + /// null is returned. + /// + /// Note: only some specialized parser implementations support + /// embedding of objects (usually ones that are facades on top + /// of non-streaming sources, such as object trees). One exception + /// is access to binary content (whether via base64 encoding or not) + /// which typically is accessible using this method, as well as + /// \#getBinaryValue(). + ///@return Embedded value (usually of "native" type supported by format) + /// for the current token, if any; {@code null otherwise} + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + jni.JObject getEmbeddedObject() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_getEmbeddedObject, + jni.JniCallType.objectType, []).object); + } + + static final _id_getBinaryValue = jniAccessors.getMethodIDOf(_classRef, + r"getBinaryValue", r"(Lcom/fasterxml/jackson/core/Base64Variant;)[B"); + + /// from: public abstract byte[] getBinaryValue(com.fasterxml.jackson.core.Base64Variant bv) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that can be used to read (and consume -- results + /// may not be accessible using other methods after the call) + /// base64-encoded binary data + /// included in the current textual JSON value. + /// It works similar to getting String value via \#getText + /// and decoding result (except for decoding part), + /// but should be significantly more performant. + /// + /// Note that non-decoded textual contents of the current token + /// are not guaranteed to be accessible after this method + /// is called. Current implementation, for example, clears up + /// textual content during decoding. + /// Decoded binary content, however, will be retained until + /// parser is advanced to the next event. + ///@param bv Expected variant of base64 encoded + /// content (see Base64Variants for definitions + /// of "standard" variants). + ///@return Decoded binary data + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + jni.JArray getBinaryValue( + jni.JObject bv, + ) { + return const jni.JArrayType(jni.JByteType()).fromRef(jniAccessors + .callMethodWithArgs(reference, _id_getBinaryValue, + jni.JniCallType.objectType, [bv.reference]).object); + } + + static final _id_getBinaryValue1 = + jniAccessors.getMethodIDOf(_classRef, r"getBinaryValue", r"()[B"); + + /// from: public byte[] getBinaryValue() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Convenience alternative to \#getBinaryValue(Base64Variant) + /// that defaults to using + /// Base64Variants\#getDefaultVariant as the default encoding. + ///@return Decoded binary data + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + jni.JArray getBinaryValue1() { + return const jni.JArrayType(jni.JByteType()).fromRef(jniAccessors + .callMethodWithArgs(reference, _id_getBinaryValue1, + jni.JniCallType.objectType, []).object); + } + + static final _id_readBinaryValue = jniAccessors.getMethodIDOf( + _classRef, r"readBinaryValue", r"(Ljava/io/OutputStream;)I"); + + /// from: public int readBinaryValue(java.io.OutputStream out) + /// + /// Method that can be used as an alternative to \#getBigIntegerValue(), + /// especially when value can be large. The main difference (beyond method + /// of returning content using OutputStream instead of as byte array) + /// is that content will NOT remain accessible after method returns: any content + /// processed will be consumed and is not buffered in any way. If caller needs + /// buffering, it has to implement it. + ///@param out Output stream to use for passing decoded binary data + ///@return Number of bytes that were decoded and written via OutputStream + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + ///@since 2.1 + int readBinaryValue( + jni.JObject out, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_readBinaryValue, + jni.JniCallType.intType, [out.reference]).integer; + } + + static final _id_readBinaryValue1 = jniAccessors.getMethodIDOf( + _classRef, + r"readBinaryValue", + r"(Lcom/fasterxml/jackson/core/Base64Variant;Ljava/io/OutputStream;)I"); + + /// from: public int readBinaryValue(com.fasterxml.jackson.core.Base64Variant bv, java.io.OutputStream out) + /// + /// Similar to \#readBinaryValue(OutputStream) but allows explicitly + /// specifying base64 variant to use. + ///@param bv base64 variant to use + ///@param out Output stream to use for passing decoded binary data + ///@return Number of bytes that were decoded and written via OutputStream + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + ///@since 2.1 + int readBinaryValue1( + jni.JObject bv, + jni.JObject out, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_readBinaryValue1, + jni.JniCallType.intType, [bv.reference, out.reference]).integer; + } + + static final _id_getValueAsInt = + jniAccessors.getMethodIDOf(_classRef, r"getValueAsInt", r"()I"); + + /// from: public int getValueAsInt() + /// + /// Method that will try to convert value of current token to a + /// Java {@code int} value. + /// Numbers are coerced using default Java rules; booleans convert to 0 (false) + /// and 1 (true), and Strings are parsed using default Java language integer + /// parsing rules. + /// + /// If representation can not be converted to an int (including structured type + /// markers like start/end Object/Array) + /// default value of __0__ will be returned; no exceptions are thrown. + ///@return {@code int} value current token is converted to, if possible; exception thrown + /// otherwise + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + int getValueAsInt() { + return jniAccessors.callMethodWithArgs( + reference, _id_getValueAsInt, jni.JniCallType.intType, []).integer; + } + + static final _id_getValueAsInt1 = + jniAccessors.getMethodIDOf(_classRef, r"getValueAsInt", r"(I)I"); + + /// from: public int getValueAsInt(int def) + /// + /// Method that will try to convert value of current token to a + /// __int__. + /// Numbers are coerced using default Java rules; booleans convert to 0 (false) + /// and 1 (true), and Strings are parsed using default Java language integer + /// parsing rules. + /// + /// If representation can not be converted to an int (including structured type + /// markers like start/end Object/Array) + /// specified __def__ will be returned; no exceptions are thrown. + ///@param def Default value to return if conversion to {@code int} is not possible + ///@return {@code int} value current token is converted to, if possible; {@code def} otherwise + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + int getValueAsInt1( + int def, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_getValueAsInt1, + jni.JniCallType.intType, [jni.JValueInt(def)]).integer; + } + + static final _id_getValueAsLong = + jniAccessors.getMethodIDOf(_classRef, r"getValueAsLong", r"()J"); + + /// from: public long getValueAsLong() + /// + /// Method that will try to convert value of current token to a + /// __long__. + /// Numbers are coerced using default Java rules; booleans convert to 0 (false) + /// and 1 (true), and Strings are parsed using default Java language integer + /// parsing rules. + /// + /// If representation can not be converted to a long (including structured type + /// markers like start/end Object/Array) + /// default value of __0L__ will be returned; no exceptions are thrown. + ///@return {@code long} value current token is converted to, if possible; exception thrown + /// otherwise + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + int getValueAsLong() { + return jniAccessors.callMethodWithArgs( + reference, _id_getValueAsLong, jni.JniCallType.longType, []).long; + } + + static final _id_getValueAsLong1 = + jniAccessors.getMethodIDOf(_classRef, r"getValueAsLong", r"(J)J"); + + /// from: public long getValueAsLong(long def) + /// + /// Method that will try to convert value of current token to a + /// __long__. + /// Numbers are coerced using default Java rules; booleans convert to 0 (false) + /// and 1 (true), and Strings are parsed using default Java language integer + /// parsing rules. + /// + /// If representation can not be converted to a long (including structured type + /// markers like start/end Object/Array) + /// specified __def__ will be returned; no exceptions are thrown. + ///@param def Default value to return if conversion to {@code long} is not possible + ///@return {@code long} value current token is converted to, if possible; {@code def} otherwise + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + int getValueAsLong1( + int def, + ) { + return jniAccessors.callMethodWithArgs( + reference, _id_getValueAsLong1, jni.JniCallType.longType, [def]).long; + } + + static final _id_getValueAsDouble = + jniAccessors.getMethodIDOf(_classRef, r"getValueAsDouble", r"()D"); + + /// from: public double getValueAsDouble() + /// + /// Method that will try to convert value of current token to a Java + /// __double__. + /// Numbers are coerced using default Java rules; booleans convert to 0.0 (false) + /// and 1.0 (true), and Strings are parsed using default Java language floating + /// point parsing rules. + /// + /// If representation can not be converted to a double (including structured types + /// like Objects and Arrays), + /// default value of __0.0__ will be returned; no exceptions are thrown. + ///@return {@code double} value current token is converted to, if possible; exception thrown + /// otherwise + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + double getValueAsDouble() { + return jniAccessors.callMethodWithArgs(reference, _id_getValueAsDouble, + jni.JniCallType.doubleType, []).doubleFloat; + } + + static final _id_getValueAsDouble1 = + jniAccessors.getMethodIDOf(_classRef, r"getValueAsDouble", r"(D)D"); + + /// from: public double getValueAsDouble(double def) + /// + /// Method that will try to convert value of current token to a + /// Java __double__. + /// Numbers are coerced using default Java rules; booleans convert to 0.0 (false) + /// and 1.0 (true), and Strings are parsed using default Java language floating + /// point parsing rules. + /// + /// If representation can not be converted to a double (including structured types + /// like Objects and Arrays), + /// specified __def__ will be returned; no exceptions are thrown. + ///@param def Default value to return if conversion to {@code double} is not possible + ///@return {@code double} value current token is converted to, if possible; {@code def} otherwise + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + double getValueAsDouble1( + double def, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_getValueAsDouble1, + jni.JniCallType.doubleType, [def]).doubleFloat; + } + + static final _id_getValueAsBoolean = + jniAccessors.getMethodIDOf(_classRef, r"getValueAsBoolean", r"()Z"); + + /// from: public boolean getValueAsBoolean() + /// + /// Method that will try to convert value of current token to a + /// __boolean__. + /// JSON booleans map naturally; integer numbers other than 0 map to true, and + /// 0 maps to false + /// and Strings 'true' and 'false' map to corresponding values. + /// + /// If representation can not be converted to a boolean value (including structured types + /// like Objects and Arrays), + /// default value of __false__ will be returned; no exceptions are thrown. + ///@return {@code boolean} value current token is converted to, if possible; exception thrown + /// otherwise + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + bool getValueAsBoolean() { + return jniAccessors.callMethodWithArgs(reference, _id_getValueAsBoolean, + jni.JniCallType.booleanType, []).boolean; + } + + static final _id_getValueAsBoolean1 = + jniAccessors.getMethodIDOf(_classRef, r"getValueAsBoolean", r"(Z)Z"); + + /// from: public boolean getValueAsBoolean(boolean def) + /// + /// Method that will try to convert value of current token to a + /// __boolean__. + /// JSON booleans map naturally; integer numbers other than 0 map to true, and + /// 0 maps to false + /// and Strings 'true' and 'false' map to corresponding values. + /// + /// If representation can not be converted to a boolean value (including structured types + /// like Objects and Arrays), + /// specified __def__ will be returned; no exceptions are thrown. + ///@param def Default value to return if conversion to {@code boolean} is not possible + ///@return {@code boolean} value current token is converted to, if possible; {@code def} otherwise + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + bool getValueAsBoolean1( + bool def, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_getValueAsBoolean1, + jni.JniCallType.booleanType, [def ? 1 : 0]).boolean; + } + + static final _id_getValueAsString = jniAccessors.getMethodIDOf( + _classRef, r"getValueAsString", r"()Ljava/lang/String;"); + + /// from: public java.lang.String getValueAsString() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that will try to convert value of current token to a + /// java.lang.String. + /// JSON Strings map naturally; scalar values get converted to + /// their textual representation. + /// If representation can not be converted to a String value (including structured types + /// like Objects and Arrays and {@code null} token), default value of + /// __null__ will be returned; no exceptions are thrown. + ///@return String value current token is converted to, if possible; {@code null} otherwise + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + ///@since 2.1 + jni.JString getValueAsString() { + return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_getValueAsString, + jni.JniCallType.objectType, []).object); + } + + static final _id_getValueAsString1 = jniAccessors.getMethodIDOf(_classRef, + r"getValueAsString", r"(Ljava/lang/String;)Ljava/lang/String;"); + + /// from: public abstract java.lang.String getValueAsString(java.lang.String def) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that will try to convert value of current token to a + /// java.lang.String. + /// JSON Strings map naturally; scalar values get converted to + /// their textual representation. + /// If representation can not be converted to a String value (including structured types + /// like Objects and Arrays and {@code null} token), specified default value + /// will be returned; no exceptions are thrown. + ///@param def Default value to return if conversion to {@code String} is not possible + ///@return String value current token is converted to, if possible; {@code def} otherwise + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + ///@since 2.1 + jni.JString getValueAsString1( + jni.JString def, + ) { + return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_getValueAsString1, + jni.JniCallType.objectType, + [def.reference]).object); + } + + static final _id_canReadObjectId = + jniAccessors.getMethodIDOf(_classRef, r"canReadObjectId", r"()Z"); + + /// from: public boolean canReadObjectId() + /// + /// Introspection method that may be called to see if the underlying + /// data format supports some kind of Object Ids natively (many do not; + /// for example, JSON doesn't). + /// + /// Default implementation returns true; overridden by data formats + /// that do support native Object Ids. Caller is expected to either + /// use a non-native notation (explicit property or such), or fail, + /// in case it can not use native object ids. + ///@return {@code True} if the format being read supports native Object Ids; + /// {@code false} if not + ///@since 2.3 + bool canReadObjectId() { + return jniAccessors.callMethodWithArgs(reference, _id_canReadObjectId, + jni.JniCallType.booleanType, []).boolean; + } + + static final _id_canReadTypeId = + jniAccessors.getMethodIDOf(_classRef, r"canReadTypeId", r"()Z"); + + /// from: public boolean canReadTypeId() + /// + /// Introspection method that may be called to see if the underlying + /// data format supports some kind of Type Ids natively (many do not; + /// for example, JSON doesn't). + /// + /// Default implementation returns true; overridden by data formats + /// that do support native Type Ids. Caller is expected to either + /// use a non-native notation (explicit property or such), or fail, + /// in case it can not use native type ids. + ///@return {@code True} if the format being read supports native Type Ids; + /// {@code false} if not + ///@since 2.3 + bool canReadTypeId() { + return jniAccessors.callMethodWithArgs( + reference, _id_canReadTypeId, jni.JniCallType.booleanType, []).boolean; + } + + static final _id_getObjectId = jniAccessors.getMethodIDOf( + _classRef, r"getObjectId", r"()Ljava/lang/Object;"); + + /// from: public java.lang.Object getObjectId() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that can be called to check whether current token + /// (one that was just read) has an associated Object id, and if + /// so, return it. + /// Note that while typically caller should check with \#canReadObjectId + /// first, it is not illegal to call this method even if that method returns + /// true; but if so, it will return null. This may be used to simplify calling + /// code. + /// + /// Default implementation will simply return null. + ///@return Native Object id associated with the current token, if any; {@code null} if none + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + ///@since 2.3 + jni.JObject getObjectId() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_getObjectId, jni.JniCallType.objectType, []).object); + } + + static final _id_getTypeId = jniAccessors.getMethodIDOf( + _classRef, r"getTypeId", r"()Ljava/lang/Object;"); + + /// from: public java.lang.Object getTypeId() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method that can be called to check whether current token + /// (one that was just read) has an associated type id, and if + /// so, return it. + /// Note that while typically caller should check with \#canReadTypeId + /// first, it is not illegal to call this method even if that method returns + /// true; but if so, it will return null. This may be used to simplify calling + /// code. + /// + /// Default implementation will simply return null. + ///@return Native Type Id associated with the current token, if any; {@code null} if none + ///@throws IOException for low-level read issues, or + /// JsonParseException for decoding problems + ///@since 2.3 + jni.JObject getTypeId() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_getTypeId, jni.JniCallType.objectType, []).object); + } + + static final _id_readValueAs = jniAccessors.getMethodIDOf( + _classRef, r"readValueAs", r"(Ljava/lang/Class;)Ljava/lang/Object;"); + + /// from: public T readValueAs(java.lang.Class valueType) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method to deserialize JSON content into a non-container + /// type (it can be an array type, however): typically a bean, array + /// or a wrapper type (like java.lang.Boolean). + /// __Note__: method can only be called if the parser has + /// an object codec assigned; this is true for parsers constructed + /// by MappingJsonFactory (from "jackson-databind" jar) + /// but not for JsonFactory (unless its setCodec + /// method has been explicitly called). + /// + /// This method may advance the event stream, for structured types + /// the current token will be the closing end marker (END_ARRAY, + /// END_OBJECT) of the bound structure. For non-structured Json types + /// (and for JsonToken\#VALUE_EMBEDDED_OBJECT) + /// stream is not advanced. + /// + /// Note: this method should NOT be used if the result type is a + /// container (java.util.Collection or java.util.Map. + /// The reason is that due to type erasure, key and value types + /// can not be introspected when using this method. + ///@param Nominal type parameter for value type + ///@param valueType Java type to read content as (passed to ObjectCodec that + /// deserializes content) + ///@return Java value read from content + ///@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.JObjType<$T> T, + }) { + return T.fromRef(jniAccessors.callMethodWithArgs(reference, _id_readValueAs, + jni.JniCallType.objectType, [valueType.reference]).object); + } + + static final _id_readValueAs1 = jniAccessors.getMethodIDOf( + _classRef, + r"readValueAs", + r"(Lcom/fasterxml/jackson/core/type/TypeReference;)Ljava/lang/Object;"); + + /// from: public T readValueAs(com.fasterxml.jackson.core.type.TypeReference valueTypeRef) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method to deserialize JSON content into a Java type, reference + /// to which is passed as argument. Type is passed using so-called + /// "super type token" + /// and specifically needs to be used if the root type is a + /// parameterized (generic) container type. + /// __Note__: method can only be called if the parser has + /// an object codec assigned; this is true for parsers constructed + /// by MappingJsonFactory (defined in 'jackson-databind' bundle) + /// but not for JsonFactory (unless its setCodec + /// method has been explicitly called). + /// + /// This method may advance the event stream, for structured types + /// the current token will be the closing end marker (END_ARRAY, + /// END_OBJECT) of the bound structure. For non-structured Json types + /// (and for JsonToken\#VALUE_EMBEDDED_OBJECT) + /// stream is not advanced. + ///@param Nominal type parameter for value type + ///@param valueTypeRef Java type to read content as (passed to ObjectCodec that + /// deserializes content) + ///@return Java value read from content + ///@throws IOException if there is either an underlying I/O problem or decoding + /// issue at format layer + $T readValueAs1<$T extends jni.JObject>( + jni.JObject valueTypeRef, { + required jni.JObjType<$T> T, + }) { + return T.fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_readValueAs1, + jni.JniCallType.objectType, + [valueTypeRef.reference]).object); + } + + static final _id_readValuesAs = jniAccessors.getMethodIDOf( + _classRef, r"readValuesAs", r"(Ljava/lang/Class;)Ljava/util/Iterator;"); + + /// from: public java.util.Iterator readValuesAs(java.lang.Class valueType) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for reading sequence of Objects from parser stream, + /// all with same specified value type. + ///@param Nominal type parameter for value type + ///@param valueType Java type to read content as (passed to ObjectCodec that + /// deserializes content) + ///@return Iterator for reading multiple Java values from content + ///@throws IOException if there is either an underlying I/O problem or decoding + /// issue at format layer + jni.JObject readValuesAs<$T extends jni.JObject>( + jni.JObject valueType, { + required jni.JObjType<$T> T, + }) { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_readValuesAs, + jni.JniCallType.objectType, + [valueType.reference]).object); + } + + static final _id_readValuesAs1 = jniAccessors.getMethodIDOf( + _classRef, + r"readValuesAs", + r"(Lcom/fasterxml/jackson/core/type/TypeReference;)Ljava/util/Iterator;"); + + /// from: public java.util.Iterator readValuesAs(com.fasterxml.jackson.core.type.TypeReference valueTypeRef) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method for reading sequence of Objects from parser stream, + /// all with same specified value type. + ///@param Nominal type parameter for value type + ///@param valueTypeRef Java type to read content as (passed to ObjectCodec that + /// deserializes content) + ///@return Iterator for reading multiple Java values from content + ///@throws IOException if there is either an underlying I/O problem or decoding + /// issue at format layer + jni.JObject readValuesAs1<$T extends jni.JObject>( + jni.JObject valueTypeRef, { + required jni.JObjType<$T> T, + }) { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_readValuesAs1, + jni.JniCallType.objectType, + [valueTypeRef.reference]).object); + } + + static final _id_readValueAsTree = jniAccessors.getMethodIDOf( + _classRef, r"readValueAsTree", r"()Ljava/lang/Object;"); + + /// from: public T readValueAsTree() + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Method to deserialize JSON content into equivalent "tree model", + /// represented by root TreeNode of resulting model. + /// For JSON Arrays it will an array node (with child nodes), + /// for objects object node (with child nodes), and for other types + /// matching leaf node type. Empty or whitespace documents are null. + ///@param Nominal type parameter for result node type (to reduce need for casting) + ///@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.JObjType<$T> T, + }) { + return T.fromRef(jniAccessors.callMethodWithArgs( + reference, _id_readValueAsTree, jni.JniCallType.objectType, []).object); + } +} + +class $JsonParserType extends jni.JObjType { + const $JsonParserType(); + + @override + String get signature => r"Lcom/fasterxml/jackson/core/JsonParser;"; + + @override + JsonParser fromRef(jni.JObjectPtr ref) => JsonParser.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($JsonParserType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $JsonParserType && other is $JsonParserType; + } +} + +/// from: com.fasterxml.jackson.core.JsonParser$Feature +/// +/// Enumeration that defines all on/off features for parsers. +class JsonParser_Feature extends jni.JObject { + @override + late final jni.JObjType $type = type; + + JsonParser_Feature.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + static final _classRef = + jniAccessors.getClassOf(r"com/fasterxml/jackson/core/JsonParser$Feature"); + + /// The type which includes information such as the signature of this class. + static const type = $JsonParser_FeatureType(); + static final _id_values = jniAccessors.getStaticMethodIDOf(_classRef, + r"values", r"()[Lcom/fasterxml/jackson/core/JsonParser$Feature;"); + + /// from: static public com.fasterxml.jackson.core.JsonParser.Feature[] values() + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JArray values() { + return const jni.JArrayType($JsonParser_FeatureType()).fromRef(jniAccessors + .callStaticMethodWithArgs( + _classRef, _id_values, jni.JniCallType.objectType, []).object); + } + + static final _id_valueOf = jniAccessors.getStaticMethodIDOf( + _classRef, + r"valueOf", + r"(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonParser$Feature;"); + + /// from: static public com.fasterxml.jackson.core.JsonParser.Feature valueOf(java.lang.String name) + /// The returned object must be deleted after use, by calling the `delete` method. + static JsonParser_Feature valueOf( + jni.JString name, + ) { + return const $JsonParser_FeatureType().fromRef(jniAccessors + .callStaticMethodWithArgs(_classRef, _id_valueOf, + jni.JniCallType.objectType, [name.reference]).object); + } + + static final _id_collectDefaults = + jniAccessors.getStaticMethodIDOf(_classRef, r"collectDefaults", r"()I"); + + /// from: static public int collectDefaults() + /// + /// Method that calculates bit set (flags) of all features that + /// are enabled by default. + ///@return Bit mask of all features that are enabled by default + static int collectDefaults() { + return jniAccessors.callStaticMethodWithArgs( + _classRef, _id_collectDefaults, jni.JniCallType.intType, []).integer; + } + + static final _id_enabledByDefault = + jniAccessors.getMethodIDOf(_classRef, r"enabledByDefault", r"()Z"); + + /// from: public boolean enabledByDefault() + bool enabledByDefault() { + return jniAccessors.callMethodWithArgs(reference, _id_enabledByDefault, + jni.JniCallType.booleanType, []).boolean; + } + + static final _id_enabledIn = + jniAccessors.getMethodIDOf(_classRef, r"enabledIn", r"(I)Z"); + + /// from: public boolean enabledIn(int flags) + bool enabledIn( + int flags, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_enabledIn, + jni.JniCallType.booleanType, [jni.JValueInt(flags)]).boolean; + } + + static final _id_getMask = + jniAccessors.getMethodIDOf(_classRef, r"getMask", r"()I"); + + /// from: public int getMask() + int getMask() { + return jniAccessors.callMethodWithArgs( + reference, _id_getMask, jni.JniCallType.intType, []).integer; + } +} + +class $JsonParser_FeatureType extends jni.JObjType { + const $JsonParser_FeatureType(); + + @override + String get signature => r"Lcom/fasterxml/jackson/core/JsonParser$Feature;"; + + @override + JsonParser_Feature fromRef(jni.JObjectPtr ref) => + JsonParser_Feature.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($JsonParser_FeatureType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $JsonParser_FeatureType && + other is $JsonParser_FeatureType; + } +} + +/// 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 { + @override + late final jni.JObjType $type = type; + + JsonParser_NumberType.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + static final _classRef = jniAccessors + .getClassOf(r"com/fasterxml/jackson/core/JsonParser$NumberType"); + + /// The type which includes information such as the signature of this class. + static const type = $JsonParser_NumberTypeType(); + static final _id_values = jniAccessors.getStaticMethodIDOf(_classRef, + r"values", r"()[Lcom/fasterxml/jackson/core/JsonParser$NumberType;"); + + /// from: static public com.fasterxml.jackson.core.JsonParser.NumberType[] values() + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JArray values() { + return const jni.JArrayType($JsonParser_NumberTypeType()).fromRef( + jniAccessors.callStaticMethodWithArgs( + _classRef, _id_values, jni.JniCallType.objectType, []).object); + } + + static final _id_valueOf = jniAccessors.getStaticMethodIDOf( + _classRef, + r"valueOf", + r"(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonParser$NumberType;"); + + /// from: static public com.fasterxml.jackson.core.JsonParser.NumberType valueOf(java.lang.String name) + /// The returned object must be deleted after use, by calling the `delete` method. + static JsonParser_NumberType valueOf( + jni.JString name, + ) { + return const $JsonParser_NumberTypeType().fromRef(jniAccessors + .callStaticMethodWithArgs(_classRef, _id_valueOf, + jni.JniCallType.objectType, [name.reference]).object); + } +} + +class $JsonParser_NumberTypeType extends jni.JObjType { + const $JsonParser_NumberTypeType(); + + @override + String get signature => r"Lcom/fasterxml/jackson/core/JsonParser$NumberType;"; + + @override + JsonParser_NumberType fromRef(jni.JObjectPtr ref) => + JsonParser_NumberType.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($JsonParser_NumberTypeType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $JsonParser_NumberTypeType && + other is $JsonParser_NumberTypeType; + } +} diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/com/fasterxml/jackson/core/JsonToken.dart b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/com/fasterxml/jackson/core/JsonToken.dart new file mode 100644 index 000000000..2a88806e9 --- /dev/null +++ b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/com/fasterxml/jackson/core/JsonToken.dart @@ -0,0 +1,223 @@ +// Generated from jackson-core which is licensed under the Apache License 2.0. +// The following copyright from the original authors applies. +// See https://github.com/FasterXML/jackson-core/blob/2.14/LICENSE +// +// Copyright (c) 2007 - The Jackson Project Authors +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Autogenerated by jnigen. DO NOT EDIT! + +// ignore_for_file: annotate_overrides +// ignore_for_file: camel_case_extensions +// ignore_for_file: camel_case_types +// ignore_for_file: constant_identifier_names +// ignore_for_file: file_names +// ignore_for_file: no_leading_underscores_for_local_identifiers +// ignore_for_file: non_constant_identifier_names +// ignore_for_file: overridden_fields +// ignore_for_file: unnecessary_cast +// ignore_for_file: unused_element +// ignore_for_file: unused_field +// ignore_for_file: unused_import +// ignore_for_file: unused_shown_name + +import "dart:isolate" show ReceivePort; +import "dart:ffi" as ffi; +import "package:jni/internal_helpers_for_jnigen.dart"; +import "package:jni/jni.dart" as jni; + +import "../../../../_init.dart"; + +/// from: com.fasterxml.jackson.core.JsonToken +/// +/// Enumeration for basic token types used for returning results +/// of parsing JSON content. +class JsonToken extends jni.JObject { + @override + late final jni.JObjType $type = type; + + JsonToken.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + static final _classRef = + jniAccessors.getClassOf(r"com/fasterxml/jackson/core/JsonToken"); + + /// The type which includes information such as the signature of this class. + static const type = $JsonTokenType(); + static final _id_values = jniAccessors.getStaticMethodIDOf( + _classRef, r"values", r"()[Lcom/fasterxml/jackson/core/JsonToken;"); + + /// from: static public com.fasterxml.jackson.core.JsonToken[] values() + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JArray values() { + return const jni.JArrayType($JsonTokenType()).fromRef(jniAccessors + .callStaticMethodWithArgs( + _classRef, _id_values, jni.JniCallType.objectType, []).object); + } + + static final _id_valueOf = jniAccessors.getStaticMethodIDOf( + _classRef, + r"valueOf", + r"(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonToken;"); + + /// from: static public com.fasterxml.jackson.core.JsonToken valueOf(java.lang.String name) + /// The returned object must be deleted after use, by calling the `delete` method. + static JsonToken valueOf( + jni.JString name, + ) { + return const $JsonTokenType().fromRef(jniAccessors.callStaticMethodWithArgs( + _classRef, + _id_valueOf, + jni.JniCallType.objectType, + [name.reference]).object); + } + + static final _id_id = jniAccessors.getMethodIDOf(_classRef, r"id", r"()I"); + + /// from: public final int id() + int id() { + return jniAccessors.callMethodWithArgs( + reference, _id_id, jni.JniCallType.intType, []).integer; + } + + static final _id_asString = jniAccessors.getMethodIDOf( + _classRef, r"asString", r"()Ljava/lang/String;"); + + /// from: public final java.lang.String asString() + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JString asString() { + return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_asString, jni.JniCallType.objectType, []).object); + } + + static final _id_asCharArray = + jniAccessors.getMethodIDOf(_classRef, r"asCharArray", r"()[C"); + + /// from: public final char[] asCharArray() + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JArray asCharArray() { + return const jni.JArrayType(jni.JCharType()).fromRef(jniAccessors + .callMethodWithArgs( + reference, _id_asCharArray, jni.JniCallType.objectType, []).object); + } + + static final _id_asByteArray = + jniAccessors.getMethodIDOf(_classRef, r"asByteArray", r"()[B"); + + /// from: public final byte[] asByteArray() + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JArray asByteArray() { + return const jni.JArrayType(jni.JByteType()).fromRef(jniAccessors + .callMethodWithArgs( + reference, _id_asByteArray, jni.JniCallType.objectType, []).object); + } + + static final _id_isNumeric = + jniAccessors.getMethodIDOf(_classRef, r"isNumeric", r"()Z"); + + /// from: public final boolean isNumeric() + /// + /// @return {@code True} if this token is {@code VALUE_NUMBER_INT} or {@code VALUE_NUMBER_FLOAT}, + /// {@code false} otherwise + bool isNumeric() { + return jniAccessors.callMethodWithArgs( + reference, _id_isNumeric, jni.JniCallType.booleanType, []).boolean; + } + + static final _id_isStructStart = + jniAccessors.getMethodIDOf(_classRef, r"isStructStart", r"()Z"); + + /// from: public final boolean isStructStart() + /// + /// Accessor that is functionally equivalent to: + /// + /// this == JsonToken.START_OBJECT || this == JsonToken.START_ARRAY + /// + ///@return {@code True} if this token is {@code START_OBJECT} or {@code START_ARRAY}, + /// {@code false} otherwise + ///@since 2.3 + bool isStructStart() { + return jniAccessors.callMethodWithArgs( + reference, _id_isStructStart, jni.JniCallType.booleanType, []).boolean; + } + + static final _id_isStructEnd = + jniAccessors.getMethodIDOf(_classRef, r"isStructEnd", r"()Z"); + + /// from: public final boolean isStructEnd() + /// + /// Accessor that is functionally equivalent to: + /// + /// this == JsonToken.END_OBJECT || this == JsonToken.END_ARRAY + /// + ///@return {@code True} if this token is {@code END_OBJECT} or {@code END_ARRAY}, + /// {@code false} otherwise + ///@since 2.3 + bool isStructEnd() { + return jniAccessors.callMethodWithArgs( + reference, _id_isStructEnd, jni.JniCallType.booleanType, []).boolean; + } + + static final _id_isScalarValue = + jniAccessors.getMethodIDOf(_classRef, r"isScalarValue", r"()Z"); + + /// from: public final boolean isScalarValue() + /// + /// Method that can be used to check whether this token represents + /// a valid non-structured value. This means all {@code VALUE_xxx} tokens; + /// excluding {@code START_xxx} and {@code END_xxx} tokens as well + /// {@code FIELD_NAME}. + ///@return {@code True} if this token is a scalar value token (one of + /// {@code VALUE_xxx} tokens), {@code false} otherwise + bool isScalarValue() { + return jniAccessors.callMethodWithArgs( + reference, _id_isScalarValue, jni.JniCallType.booleanType, []).boolean; + } + + static final _id_isBoolean = + jniAccessors.getMethodIDOf(_classRef, r"isBoolean", r"()Z"); + + /// from: public final boolean isBoolean() + /// + /// @return {@code True} if this token is {@code VALUE_TRUE} or {@code VALUE_FALSE}, + /// {@code false} otherwise + bool isBoolean() { + return jniAccessors.callMethodWithArgs( + reference, _id_isBoolean, jni.JniCallType.booleanType, []).boolean; + } +} + +class $JsonTokenType extends jni.JObjType { + const $JsonTokenType(); + + @override + String get signature => r"Lcom/fasterxml/jackson/core/JsonToken;"; + + @override + JsonToken fromRef(jni.JObjectPtr ref) => JsonToken.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($JsonTokenType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $JsonTokenType && other is $JsonTokenType; + } +} diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/com/fasterxml/jackson/core/_package.dart b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/com/fasterxml/jackson/core/_package.dart new file mode 100644 index 000000000..cae2a52e6 --- /dev/null +++ b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/com/fasterxml/jackson/core/_package.dart @@ -0,0 +1,3 @@ +export "JsonFactory.dart"; +export "JsonParser.dart"; +export "JsonToken.dart"; diff --git a/pkgs/jnigen/test/simple_package_test/src/.clang-format b/pkgs/jnigen/test/kotlin_test/c_based/c_bindings/.clang-format similarity index 100% rename from pkgs/jnigen/test/simple_package_test/src/.clang-format rename to pkgs/jnigen/test/kotlin_test/c_based/c_bindings/.clang-format diff --git a/pkgs/jnigen/test/kotlin_test/src/CMakeLists.txt b/pkgs/jnigen/test/kotlin_test/c_based/c_bindings/CMakeLists.txt similarity index 100% rename from pkgs/jnigen/test/kotlin_test/src/CMakeLists.txt rename to pkgs/jnigen/test/kotlin_test/c_based/c_bindings/CMakeLists.txt diff --git a/pkgs/jnigen/test/simple_package_test/src/dartjni.h b/pkgs/jnigen/test/kotlin_test/c_based/c_bindings/dartjni.h similarity index 94% rename from pkgs/jnigen/test/simple_package_test/src/dartjni.h rename to pkgs/jnigen/test/kotlin_test/c_based/c_bindings/dartjni.h index 21cef2036..c0713af53 100644 --- a/pkgs/jnigen/test/simple_package_test/src/dartjni.h +++ b/pkgs/jnigen/test/kotlin_test/c_based/c_bindings/dartjni.h @@ -176,10 +176,10 @@ typedef struct JniAccessorsStruct { char* methodName, char* signature); JniResult (*newObject)(jclass cls, jmethodID ctor, jvalue* args); - JniPointerResult (*newPrimitiveArray)(jsize length, int type); - JniPointerResult (*newObjectArray)(jsize length, - jclass elementClass, - jobject initialElement); + JniResult (*newPrimitiveArray)(jsize length, int type); + JniResult (*newObjectArray)(jsize length, + jclass elementClass, + jobject initialElement); JniResult (*getArrayElement)(jarray array, int index, int type); JniResult (*callMethod)(jobject obj, jmethodID methodID, @@ -261,8 +261,10 @@ static inline void load_class_global_ref(jclass* cls, const char* name) { acquire_lock(&jni->locks.classLoadingLock); if (*cls == NULL) { load_class_platform(&tmp, name); - *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); - (*jniEnv)->DeleteLocalRef(jniEnv, tmp); + if (!(*jniEnv)->ExceptionCheck(jniEnv)) { + *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); + (*jniEnv)->DeleteLocalRef(jniEnv, tmp); + } } release_lock(&jni->locks.classLoadingLock); } @@ -356,6 +358,15 @@ static inline jthrowable check_exception() { return to_global_ref(exception); } +static inline JniResult to_global_ref_result(jobject ref) { + JniResult result; + result.exception = check_exception(); + if (result.exception == NULL) { + result.value.l = to_global_ref(ref); + } + return result; +} + FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); JNIEXPORT void JNICALL diff --git a/pkgs/jnigen/test/kotlin_test/src/kotlin.c b/pkgs/jnigen/test/kotlin_test/c_based/c_bindings/kotlin.c similarity index 88% rename from pkgs/jnigen/test/kotlin_test/src/kotlin.c rename to pkgs/jnigen/test/kotlin_test/c_based/c_bindings/kotlin.c index b70978ef8..b131ce971 100644 --- a/pkgs/jnigen/test/kotlin_test/src/kotlin.c +++ b/pkgs/jnigen/test/kotlin_test/c_based/c_bindings/kotlin.c @@ -35,8 +35,7 @@ JniResult SuspendFun__ctor() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_SuspendFun, _m_SuspendFun__ctor); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_SuspendFun__sayHello = NULL; @@ -53,8 +52,7 @@ JniResult SuspendFun__sayHello(jobject self_, jobject continuation) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_SuspendFun__sayHello, continuation); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_SuspendFun__sayHello1 = NULL; @@ -74,6 +72,5 @@ JniResult SuspendFun__sayHello1(jobject self_, return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_SuspendFun__sayHello1, string, continuation); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } diff --git a/pkgs/jnigen/test/kotlin_test/lib/kotlin.dart b/pkgs/jnigen/test/kotlin_test/c_based/dart_bindings/kotlin.dart similarity index 100% rename from pkgs/jnigen/test/kotlin_test/lib/kotlin.dart rename to pkgs/jnigen/test/kotlin_test/c_based/dart_bindings/kotlin.dart diff --git a/pkgs/jnigen/test/kotlin_test/dart_only/dart_bindings/kotlin.dart b/pkgs/jnigen/test/kotlin_test/dart_only/dart_bindings/kotlin.dart new file mode 100644 index 000000000..f0a475473 --- /dev/null +++ b/pkgs/jnigen/test/kotlin_test/dart_only/dart_bindings/kotlin.dart @@ -0,0 +1,118 @@ +// 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. + +// Autogenerated by jnigen. DO NOT EDIT! + +// ignore_for_file: annotate_overrides +// ignore_for_file: camel_case_extensions +// ignore_for_file: camel_case_types +// ignore_for_file: constant_identifier_names +// ignore_for_file: file_names +// ignore_for_file: no_leading_underscores_for_local_identifiers +// ignore_for_file: non_constant_identifier_names +// ignore_for_file: overridden_fields +// ignore_for_file: unnecessary_cast +// ignore_for_file: unused_element +// ignore_for_file: unused_field +// ignore_for_file: unused_import +// ignore_for_file: unused_shown_name + +import "dart:isolate" show ReceivePort; +import "dart:ffi" as ffi; +import "package:jni/internal_helpers_for_jnigen.dart"; +import "package:jni/jni.dart" as jni; + +// Auto-generated initialization code. + +final jniEnv = jni.Jni.env; +final jniAccessors = jni.Jni.accessors; + +/// from: com.github.dart_lang.jnigen.SuspendFun +class SuspendFun extends jni.JObject { + @override + late final jni.JObjType $type = type; + + SuspendFun.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + static final _classRef = + jniAccessors.getClassOf(r"com/github/dart_lang/jnigen/SuspendFun"); + + /// The type which includes information such as the signature of this class. + static const type = $SuspendFunType(); + static final _id_ctor = + jniAccessors.getMethodIDOf(_classRef, r"", r"()V"); + + /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. + factory SuspendFun() { + return SuspendFun.fromRef( + jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); + } + + static final _id_sayHello = jniAccessors.getMethodIDOf(_classRef, r"sayHello", + r"(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;"); + + /// from: public final java.lang.Object sayHello(kotlin.coroutines.Continuation continuation) + /// The returned object must be deleted after use, by calling the `delete` method. + Future sayHello() async { + final $p = ReceivePort(); + final $c = jni.JObject.fromRef(jni.Jni.newPortContinuation($p)); + jniAccessors.callMethodWithArgs(reference, _id_sayHello, + jni.JniCallType.objectType, [$c.reference]).object; + final $o = jni.JObjectPtr.fromAddress(await $p.first); + final $k = const jni.JStringType().getClass().reference; + if (!jni.Jni.env.IsInstanceOf($o, $k)) { + throw "Failed"; + } + return const jni.JStringType().fromRef($o); + } + + static final _id_sayHello1 = jniAccessors.getMethodIDOf( + _classRef, + r"sayHello", + r"(Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;"); + + /// from: public final java.lang.Object sayHello(java.lang.String string, kotlin.coroutines.Continuation continuation) + /// The returned object must be deleted after use, by calling the `delete` method. + Future sayHello1( + jni.JString string, + ) async { + final $p = ReceivePort(); + final $c = jni.JObject.fromRef(jni.Jni.newPortContinuation($p)); + jniAccessors.callMethodWithArgs(reference, _id_sayHello1, + jni.JniCallType.objectType, [string.reference, $c.reference]).object; + final $o = jni.JObjectPtr.fromAddress(await $p.first); + final $k = const jni.JStringType().getClass().reference; + if (!jni.Jni.env.IsInstanceOf($o, $k)) { + throw "Failed"; + } + return const jni.JStringType().fromRef($o); + } +} + +class $SuspendFunType extends jni.JObjType { + const $SuspendFunType(); + + @override + String get signature => r"Lcom/github/dart_lang/jnigen/SuspendFun;"; + + @override + SuspendFun fromRef(jni.JObjectPtr ref) => SuspendFun.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($SuspendFunType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $SuspendFunType && other is $SuspendFunType; + } +} diff --git a/pkgs/jnigen/test/kotlin_test/generate.dart b/pkgs/jnigen/test/kotlin_test/generate.dart index 8f877aebe..1b9b111b3 100644 --- a/pkgs/jnigen/test/kotlin_test/generate.dart +++ b/pkgs/jnigen/test/kotlin_test/generate.dart @@ -37,8 +37,11 @@ void compileKotlinSources(String workingDir) async { Config getConfig([BindingsType bindingsType = BindingsType.cBased]) { compileKotlinSources(kotlinPath); - final cWrapperDir = Uri.directory(join(testRoot, "src")); - final dartWrappersRoot = Uri.directory(join(testRoot, "lib")); + final typeDir = bindingsType.getConfigString(); + final cWrapperDir = Uri.directory(join(testRoot, typeDir, "c_bindings")); + final dartWrappersRoot = Uri.directory( + join(testRoot, typeDir, "dart_bindings"), + ); final config = Config( classPath: [Uri.file(jarPath)], classes: [ @@ -67,4 +70,7 @@ Config getConfig([BindingsType bindingsType = BindingsType.cBased]) { return config; } -void main() async => await generateJniBindings(getConfig()); +void main() async { + await generateJniBindings(getConfig(BindingsType.cBased)); + await generateJniBindings(getConfig(BindingsType.dartOnly)); +} diff --git a/pkgs/jnigen/test/kotlin_test/generated_files_test.dart b/pkgs/jnigen/test/kotlin_test/generated_files_test.dart index be9ff90e0..b96c643ca 100644 --- a/pkgs/jnigen/test/kotlin_test/generated_files_test.dart +++ b/pkgs/jnigen/test/kotlin_test/generated_files_test.dart @@ -4,7 +4,6 @@ import 'package:jnigen/jnigen.dart'; import 'package:test/test.dart'; -import 'package:path/path.dart' hide equals; import 'generate.dart'; import '../test_util/test_util.dart'; @@ -13,17 +12,11 @@ void main() async { // This is not run in setupAll, because we want to exit with one line of // error message, not throw a long exception. await checkLocallyBuiltDependencies(); - test( - "Generate and compare bindings for kotlin_test", - () async { - await generateAndCompareBindings( - getConfig(), - join(testRoot, "lib", "kotlin.dart"), - join(testRoot, "src"), - ); - }, - timeout: const Timeout.factor(1.5), - ); // test if generated file == expected file + generateAndCompareBothModes( + 'Generate and compare bindings for kotlin_test', + getConfig(BindingsType.cBased), + getConfig(BindingsType.dartOnly), + ); test( "Generate and analyze bindings for kotlin_test - pure dart", () async { diff --git a/pkgs/jnigen/test/kotlin_test/runtime_test_registrant.dart b/pkgs/jnigen/test/kotlin_test/runtime_test_registrant.dart new file mode 100644 index 000000000..f99e3d444 --- /dev/null +++ b/pkgs/jnigen/test/kotlin_test/runtime_test_registrant.dart @@ -0,0 +1,26 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +import 'package:test/test.dart'; +import 'package:jni/jni.dart'; + +import '../test_util/callback_types.dart'; + +import 'c_based/dart_bindings/kotlin.dart'; + +void registerTests(String groupName, TestRunnerCallback test) { + group(groupName, () { + test('Suspend functions', () async { + await using((arena) async { + final suspendFun = SuspendFun()..deletedIn(arena); + final hello = await suspendFun.sayHello(); + expect(hello.toDartString(deleteOriginal: true), "Hello!"); + const name = "Bob"; + final helloBob = + await suspendFun.sayHello1(name.toJString()..deletedIn(arena)); + expect(helloBob.toDartString(deleteOriginal: true), "Hello $name!"); + }); + }); + }); +} diff --git a/pkgs/jnigen/test/regenerate_examples_test.dart b/pkgs/jnigen/test/regenerate_examples_test.dart index 50e41b62b..5afeebea8 100644 --- a/pkgs/jnigen/test/regenerate_examples_test.dart +++ b/pkgs/jnigen/test/regenerate_examples_test.dart @@ -34,16 +34,9 @@ void testExample(String exampleName, String dartOutput, String? cOutput, final examplePath = join('example', exampleName); final configPath = join(examplePath, 'jnigen.yaml'); - final dartBindingsPath = join(examplePath, dartOutput); - String? cBindingsPath; - if (cOutput != null) { - cBindingsPath = join(examplePath, cOutput); - } - final config = Config.parseArgs(['--config', configPath]); try { - await generateAndCompareBindings( - config, dartBindingsPath, cBindingsPath); + await generateAndCompareBindings(config); } on GradleException catch (_) { stderr.writeln('Skip: $exampleName'); } diff --git a/pkgs/jnigen/test/simple_package_test/.gitignore b/pkgs/jnigen/test/simple_package_test/.gitignore index cbd7ab37c..1db9cf8ee 100644 --- a/pkgs/jnigen/test/simple_package_test/.gitignore +++ b/pkgs/jnigen/test/simple_package_test/.gitignore @@ -2,4 +2,5 @@ build/ *.class test_lib/ test_src/ - +*_dartonly_generated.dart ## Generated test replicas +generated_runtime_test.dart \ No newline at end of file diff --git a/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/.clang-format b/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/.clang-format new file mode 100644 index 000000000..a256c2f09 --- /dev/null +++ b/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/.clang-format @@ -0,0 +1,15 @@ +# From dart SDK: https://github.com/dart-lang/sdk/blob/main/.clang-format + +# Defines the Chromium style for automatic reformatting. +# http://clang.llvm.org/docs/ClangFormatStyleOptions.html +BasedOnStyle: Chromium + +# clang-format doesn't seem to do a good job of this for longer comments. +ReflowComments: 'false' + +# We have lots of these. Though we need to put them all in curly braces, +# clang-format can't do that. +AllowShortIfStatementsOnASingleLine: 'true' + +# Put escaped newlines into the rightmost column. +AlignEscapedNewlinesLeft: false diff --git a/pkgs/jnigen/test/simple_package_test/src/CMakeLists.txt b/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/CMakeLists.txt similarity index 100% rename from pkgs/jnigen/test/simple_package_test/src/CMakeLists.txt rename to pkgs/jnigen/test/simple_package_test/c_based/c_bindings/CMakeLists.txt diff --git a/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/dartjni.h b/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/dartjni.h new file mode 100644 index 000000000..c0713af53 --- /dev/null +++ b/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/dartjni.h @@ -0,0 +1,378 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +#pragma once + +// Note: include appropriate system jni.h as found by CMake, not third_party/jni.h. +#include +#include +#include +#include + +#if _WIN32 +#include +#else +#include +#include +#endif + +#if _WIN32 +#define FFI_PLUGIN_EXPORT __declspec(dllexport) +#else +#define FFI_PLUGIN_EXPORT +#endif + +#if defined _WIN32 +#define thread_local __declspec(thread) +#else +#define thread_local __thread +#endif + +#ifdef __ANDROID__ +#include +#endif + +#ifdef __ANDROID__ +#define __ENVP_CAST (JNIEnv**) +#else +#define __ENVP_CAST (void**) +#endif + +/// Locking functions for windows and pthread. + +#if defined _WIN32 +#include + +typedef CRITICAL_SECTION MutexLock; + +static inline void init_lock(MutexLock* lock) { + InitializeCriticalSection(lock); +} + +static inline void acquire_lock(MutexLock* lock) { + EnterCriticalSection(lock); +} + +static inline void release_lock(MutexLock* lock) { + LeaveCriticalSection(lock); +} + +static inline void _destroyLock(MutexLock* lock) { + DeleteCriticalSection(lock); +} + +#elif defined __DARWIN__ || defined __LINUX__ || defined __ANDROID__ || \ + defined __GNUC__ +#include + +typedef pthread_mutex_t MutexLock; + +static inline void init_lock(MutexLock* lock) { + pthread_mutex_init(lock, NULL); +} + +static inline void acquire_lock(MutexLock* lock) { + pthread_mutex_lock(lock); +} + +static inline void release_lock(MutexLock* lock) { + pthread_mutex_unlock(lock); +} + +static inline void _destroyLock(MutexLock* lock) { + pthread_mutex_destroy(lock); +} + +#else + +#error "No locking support; Possibly unsupported platform" + +#endif + +typedef struct JniLocks { + MutexLock classLoadingLock; + MutexLock methodLoadingLock; + MutexLock fieldLoadingLock; +} JniLocks; + +/// Represents the error when dart-jni layer has already spawned singleton VM. +#define DART_JNI_SINGLETON_EXISTS (-99); + +/// Stores the global state of the JNI. +typedef struct JniContext { + JavaVM* jvm; + jobject classLoader; + jmethodID loadClassMethod; + jobject currentActivity; + jobject appContext; + JniLocks locks; +} JniContext; + +// jniEnv for this thread, used by inline functions in this header, +// therefore declared as extern. +extern thread_local JNIEnv* jniEnv; + +extern JniContext* jni; + +/// Types used by JNI API to distinguish between primitive types. +enum JniType { + booleanType = 0, + byteType = 1, + shortType = 2, + charType = 3, + intType = 4, + longType = 5, + floatType = 6, + doubleType = 7, + objectType = 8, + voidType = 9, +}; + +/// 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]. +typedef struct JniResult { + jvalue value; + jthrowable exception; +} JniResult; + +/// Similar to [JniResult] but for class lookups. +typedef struct JniClassLookupResult { + jclass value; + jthrowable exception; +} JniClassLookupResult; + +/// Similar to [JniResult] but for method/field ID lookups. +typedef struct JniPointerResult { + const void* value; + jthrowable exception; +} JniPointerResult; + +/// JniExceptionDetails holds 2 jstring objects, one is the result of +/// calling `toString` on exception object, other is stack trace; +typedef struct JniExceptionDetails { + jstring message; + jstring stacktrace; +} JniExceptionDetails; + +/// This struct contains functions which wrap method call / field access conveniently along with +/// exception checking. +/// +/// Flutter embedding checks for pending JNI exceptions before an FFI transition, which requires us +/// to check for and clear the exception before returning to dart code, which requires these functions +/// to return result types. +typedef struct JniAccessorsStruct { + JniClassLookupResult (*getClass)(char* internalName); + JniPointerResult (*getFieldID)(jclass cls, char* fieldName, char* signature); + JniPointerResult (*getStaticFieldID)(jclass cls, + char* fieldName, + char* signature); + JniPointerResult (*getMethodID)(jclass cls, + char* methodName, + char* signature); + JniPointerResult (*getStaticMethodID)(jclass cls, + char* methodName, + char* signature); + JniResult (*newObject)(jclass cls, jmethodID ctor, jvalue* args); + JniResult (*newPrimitiveArray)(jsize length, int type); + JniResult (*newObjectArray)(jsize length, + jclass elementClass, + jobject initialElement); + JniResult (*getArrayElement)(jarray array, int index, int type); + JniResult (*callMethod)(jobject obj, + jmethodID methodID, + int callType, + jvalue* args); + JniResult (*callStaticMethod)(jclass cls, + jmethodID methodID, + int callType, + jvalue* args); + JniResult (*getField)(jobject obj, jfieldID fieldID, int callType); + JniResult (*getStaticField)(jclass cls, jfieldID fieldID, int callType); + JniExceptionDetails (*getExceptionDetails)(jthrowable exception); +} JniAccessorsStruct; + +FFI_PLUGIN_EXPORT JniAccessorsStruct* GetAccessors(); + +FFI_PLUGIN_EXPORT JavaVM* GetJavaVM(void); + +FFI_PLUGIN_EXPORT JNIEnv* GetJniEnv(void); + +/// 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. +FFI_PLUGIN_EXPORT int SpawnJvm(JavaVMInitArgs* args); + +/// Load class through platform-specific mechanism. +/// +/// Currently uses application classloader on android, +/// and JNIEnv->FindClass on other platforms. +FFI_PLUGIN_EXPORT jclass FindClass(const char* name); + +/// Returns Application classLoader (on Android), +/// which can be used to load application and platform classes. +/// +/// On other platforms, NULL is returned. +FFI_PLUGIN_EXPORT jobject GetClassLoader(void); + +/// Returns application context on Android. +/// +/// On other platforms, NULL is returned. +FFI_PLUGIN_EXPORT jobject GetApplicationContext(void); + +/// Returns current activity of the app on Android. +FFI_PLUGIN_EXPORT jobject GetCurrentActivity(void); + +static inline void attach_thread() { + if (jniEnv == NULL) { + (*jni->jvm)->AttachCurrentThread(jni->jvm, __ENVP_CAST & jniEnv, NULL); + } +} + +/// Load class into [cls] using platform specific mechanism +static inline void load_class_platform(jclass* cls, const char* name) { +#ifdef __ANDROID__ + jstring className = (*jniEnv)->NewStringUTF(jniEnv, name); + *cls = (*jniEnv)->CallObjectMethod(jniEnv, jni->classLoader, + jni->loadClassMethod, className); + (*jniEnv)->DeleteLocalRef(jniEnv, className); +#else + *cls = (*jniEnv)->FindClass(jniEnv, name); +#endif +} + +static inline void load_class_local_ref(jclass* cls, const char* name) { + if (*cls == NULL) { + acquire_lock(&jni->locks.classLoadingLock); + if (*cls == NULL) { + load_class_platform(cls, name); + } + release_lock(&jni->locks.classLoadingLock); + } +} + +static inline void load_class_global_ref(jclass* cls, const char* name) { + if (*cls == NULL) { + jclass tmp = NULL; + acquire_lock(&jni->locks.classLoadingLock); + if (*cls == NULL) { + load_class_platform(&tmp, name); + if (!(*jniEnv)->ExceptionCheck(jniEnv)) { + *cls = (*jniEnv)->NewGlobalRef(jniEnv, tmp); + (*jniEnv)->DeleteLocalRef(jniEnv, tmp); + } + } + release_lock(&jni->locks.classLoadingLock); + } +} + +static inline void load_method(jclass cls, + jmethodID* res, + const char* name, + const char* sig) { + if (*res == NULL) { + acquire_lock(&jni->locks.methodLoadingLock); + if (*res == NULL) { + *res = (*jniEnv)->GetMethodID(jniEnv, cls, name, sig); + } + release_lock(&jni->locks.methodLoadingLock); + } +} + +static inline void load_static_method(jclass cls, + jmethodID* res, + const char* name, + const char* sig) { + if (*res == NULL) { + acquire_lock(&jni->locks.methodLoadingLock); + if (*res == NULL) { + *res = (*jniEnv)->GetStaticMethodID(jniEnv, cls, name, sig); + } + release_lock(&jni->locks.methodLoadingLock); + } +} + +static inline void load_field(jclass cls, + jfieldID* res, + const char* name, + const char* sig) { + if (*res == NULL) { + acquire_lock(&jni->locks.fieldLoadingLock); + if (*res == NULL) { + *res = (*jniEnv)->GetFieldID(jniEnv, cls, name, sig); + } + release_lock(&jni->locks.fieldLoadingLock); + } +} + +static inline void load_static_field(jclass cls, + jfieldID* res, + const char* name, + const char* sig) { + if (*res == NULL) { + acquire_lock(&jni->locks.fieldLoadingLock); + if (*res == NULL) { + *res = (*jniEnv)->GetStaticFieldID(jniEnv, cls, name, sig); + } + release_lock(&jni->locks.fieldLoadingLock); + } +} + +static inline jobject to_global_ref(jobject ref) { + jobject g = (*jniEnv)->NewGlobalRef(jniEnv, ref); + (*jniEnv)->DeleteLocalRef(jniEnv, ref); + return g; +} + +// These functions are useful for C+Dart bindings, and not required for pure dart bindings. + +FFI_PLUGIN_EXPORT JniContext* GetJniContextPtr(); + +/// For use by jni_gen's generated code +/// don't use these. + +// these 2 fn ptr vars will be defined by generated code library +extern JniContext* (*context_getter)(void); +extern JNIEnv* (*env_getter)(void); + +// this function will be exported by generated code library +// it will set above 2 variables. +FFI_PLUGIN_EXPORT void setJniGetters(struct JniContext* (*cg)(void), + JNIEnv* (*eg)(void)); + +static inline void load_env() { + if (jniEnv == NULL) { + jni = context_getter(); + jniEnv = env_getter(); + } +} + +static inline jthrowable check_exception() { + jthrowable exception = (*jniEnv)->ExceptionOccurred(jniEnv); + if (exception != NULL) (*jniEnv)->ExceptionClear(jniEnv); + if (exception == NULL) return NULL; + return to_global_ref(exception); +} + +static inline JniResult to_global_ref_result(jobject ref) { + JniResult result; + result.exception = check_exception(); + if (result.exception == NULL) { + result.value.l = to_global_ref(ref); + } + return result; +} + +FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); + +JNIEXPORT void JNICALL +Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env, + jobject thiz, + jlong port, + jobject result); +FFI_PLUGIN_EXPORT +JniResult PortContinuation__ctor(int64_t j); diff --git a/pkgs/jnigen/test/simple_package_test/src/simple_package.c b/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/simple_package.c similarity index 51% rename from pkgs/jnigen/test/simple_package_test/src/simple_package.c rename to pkgs/jnigen/test/simple_package_test/c_based/c_bindings/simple_package.c index be680029e..e388ec772 100644 --- a/pkgs/jnigen/test/simple_package_test/src/simple_package.c +++ b/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/simple_package.c @@ -22,352 +22,1274 @@ void setJniGetters(JniContext* (*cg)(void), JNIEnv* (*eg)(void)) { // com.github.dart_lang.jnigen.simple_package.Example jclass _c_Example = NULL; +jmethodID _m_Example__getAmount = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__getAmount() { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_Example, &_m_Example__getAmount, "getAmount", "()I"); + if (_m_Example__getAmount == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int32_t _result = + (*jniEnv)->CallStaticIntMethod(jniEnv, _c_Example, _m_Example__getAmount); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +jmethodID _m_Example__getPi = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__getPi() { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_Example, &_m_Example__getPi, "getPi", "()D"); + if (_m_Example__getPi == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + double _result = + (*jniEnv)->CallStaticDoubleMethod(jniEnv, _c_Example, _m_Example__getPi); + return (JniResult){.value = {.d = _result}, .exception = check_exception()}; +} + +jmethodID _m_Example__getAsterisk = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__getAsterisk() { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_Example, &_m_Example__getAsterisk, "getAsterisk", + "()C"); + if (_m_Example__getAsterisk == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint16_t _result = (*jniEnv)->CallStaticCharMethod(jniEnv, _c_Example, + _m_Example__getAsterisk); + return (JniResult){.value = {.c = _result}, .exception = check_exception()}; +} + +jmethodID _m_Example__getName = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__getName() { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_Example, &_m_Example__getName, "getName", + "()Ljava/lang/String;"); + if (_m_Example__getName == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_Example, + _m_Example__getName); + return to_global_ref_result(_result); +} + +jmethodID _m_Example__getNestedInstance = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__getNestedInstance() { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_method( + _c_Example, &_m_Example__getNestedInstance, "getNestedInstance", + "()Lcom/github/dart_lang/jnigen/simple_package/Example$Nested;"); + if (_m_Example__getNestedInstance == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallStaticObjectMethod( + jniEnv, _c_Example, _m_Example__getNestedInstance); + return to_global_ref_result(_result); +} + +jmethodID _m_Example__setAmount = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__setAmount(int32_t newAmount) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_Example, &_m_Example__setAmount, "setAmount", "(I)V"); + if (_m_Example__setAmount == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallStaticVoidMethod(jniEnv, _c_Example, _m_Example__setAmount, + newAmount); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +jmethodID _m_Example__setName = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__setName(jobject newName) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_Example, &_m_Example__setName, "setName", + "(Ljava/lang/String;)V"); + if (_m_Example__setName == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallStaticVoidMethod(jniEnv, _c_Example, _m_Example__setName, + newName); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +jmethodID _m_Example__setNestedInstance = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__setNestedInstance(jobject newNested) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_method( + _c_Example, &_m_Example__setNestedInstance, "setNestedInstance", + "(Lcom/github/dart_lang/jnigen/simple_package/Example$Nested;)V"); + if (_m_Example__setNestedInstance == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallStaticVoidMethod(jniEnv, _c_Example, + _m_Example__setNestedInstance, newNested); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +jmethodID _m_Example__max4 = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__max4(int32_t a, int32_t b, int32_t c, int32_t d) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_Example, &_m_Example__max4, "max4", "(IIII)I"); + if (_m_Example__max4 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int32_t _result = (*jniEnv)->CallStaticIntMethod( + jniEnv, _c_Example, _m_Example__max4, a, b, c, d); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +jmethodID _m_Example__max8 = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__max8(int32_t a, + int32_t b, + int32_t c, + int32_t d, + int32_t e, + int32_t f, + int32_t g, + int32_t h) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_Example, &_m_Example__max8, "max8", "(IIIIIIII)I"); + if (_m_Example__max8 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int32_t _result = (*jniEnv)->CallStaticIntMethod( + jniEnv, _c_Example, _m_Example__max8, a, b, c, d, e, f, g, h); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +jmethodID _m_Example__getNumber = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__getNumber(jobject self_) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example, &_m_Example__getNumber, "getNumber", "()I"); + if (_m_Example__getNumber == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int32_t _result = + (*jniEnv)->CallIntMethod(jniEnv, self_, _m_Example__getNumber); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +jmethodID _m_Example__setNumber = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__setNumber(jobject self_, int32_t number) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example, &_m_Example__setNumber, "setNumber", "(I)V"); + if (_m_Example__setNumber == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_Example__setNumber, number); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +jmethodID _m_Example__getIsUp = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__getIsUp(jobject self_) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example, &_m_Example__getIsUp, "getIsUp", "()Z"); + if (_m_Example__getIsUp == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = + (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_Example__getIsUp); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_Example__setUp = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__setUp(jobject self_, uint8_t isUp) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example, &_m_Example__setUp, "setUp", "(Z)V"); + if (_m_Example__setUp == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_Example__setUp, isUp); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +jmethodID _m_Example__getCodename = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__getCodename(jobject self_) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example, &_m_Example__getCodename, "getCodename", + "()Ljava/lang/String;"); + if (_m_Example__getCodename == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_Example__getCodename); + return to_global_ref_result(_result); +} + +jmethodID _m_Example__setCodename = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__setCodename(jobject self_, jobject codename) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example, &_m_Example__setCodename, "setCodename", + "(Ljava/lang/String;)V"); + if (_m_Example__setCodename == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_Example__setCodename, codename); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +jmethodID _m_Example__getRandom = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__getRandom(jobject self_) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example, &_m_Example__getRandom, "getRandom", + "()Ljava/util/Random;"); + if (_m_Example__getRandom == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_Example__getRandom); + return to_global_ref_result(_result); +} + +jmethodID _m_Example__setRandom = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__setRandom(jobject self_, jobject random) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example, &_m_Example__setRandom, "setRandom", + "(Ljava/util/Random;)V"); + if (_m_Example__setRandom == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_Example__setRandom, random); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +jmethodID _m_Example__getRandomLong = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__getRandomLong(jobject self_) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example, &_m_Example__getRandomLong, "getRandomLong", "()J"); + if (_m_Example__getRandomLong == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int64_t _result = + (*jniEnv)->CallLongMethod(jniEnv, self_, _m_Example__getRandomLong); + return (JniResult){.value = {.j = _result}, .exception = check_exception()}; +} + +jmethodID _m_Example__add4Longs = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__add4Longs(jobject self_, + int64_t a, + int64_t b, + int64_t c, + int64_t d) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example, &_m_Example__add4Longs, "add4Longs", "(JJJJ)J"); + if (_m_Example__add4Longs == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int64_t _result = (*jniEnv)->CallLongMethod( + jniEnv, self_, _m_Example__add4Longs, a, b, c, d); + return (JniResult){.value = {.j = _result}, .exception = check_exception()}; +} + +jmethodID _m_Example__add8Longs = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__add8Longs(jobject self_, + int64_t a, + int64_t b, + int64_t c, + int64_t d, + int64_t e, + int64_t f, + int64_t g, + int64_t h) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example, &_m_Example__add8Longs, "add8Longs", "(JJJJJJJJ)J"); + if (_m_Example__add8Longs == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int64_t _result = (*jniEnv)->CallLongMethod( + jniEnv, self_, _m_Example__add8Longs, a, b, c, d, e, f, g, h); + return (JniResult){.value = {.j = _result}, .exception = check_exception()}; +} + +jmethodID _m_Example__getRandomNumericString = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__getRandomNumericString(jobject self_, jobject random) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example, &_m_Example__getRandomNumericString, + "getRandomNumericString", + "(Ljava/util/Random;)Ljava/lang/String;"); + if (_m_Example__getRandomNumericString == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_Example__getRandomNumericString, random); + return to_global_ref_result(_result); +} + jmethodID _m_Example__ctor = NULL; FFI_PLUGIN_EXPORT -JniResult Example__ctor() { +JniResult Example__ctor() { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example, &_m_Example__ctor, "", "()V"); + if (_m_Example__ctor == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Example, _m_Example__ctor); + return to_global_ref_result(_result); +} + +jmethodID _m_Example__ctor1 = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__ctor1(int32_t number) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example, &_m_Example__ctor1, "", "(I)V"); + if (_m_Example__ctor1 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->NewObject(jniEnv, _c_Example, _m_Example__ctor1, number); + return to_global_ref_result(_result); +} + +jmethodID _m_Example__ctor2 = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__ctor2(int32_t number, uint8_t isUp) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example, &_m_Example__ctor2, "", "(IZ)V"); + if (_m_Example__ctor2 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->NewObject(jniEnv, _c_Example, _m_Example__ctor2, number, isUp); + return to_global_ref_result(_result); +} + +jmethodID _m_Example__ctor3 = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__ctor3(int32_t number, uint8_t isUp, jobject codename) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example, &_m_Example__ctor3, "", + "(IZLjava/lang/String;)V"); + if (_m_Example__ctor3 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Example, _m_Example__ctor3, + number, isUp, codename); + return to_global_ref_result(_result); +} + +jmethodID _m_Example__ctor4 = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__ctor4(int32_t a, + int32_t b, + int32_t c, + int32_t d, + int32_t e, + int32_t f, + int32_t g, + int32_t h) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example, &_m_Example__ctor4, "", "(IIIIIIII)V"); + if (_m_Example__ctor4 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Example, _m_Example__ctor4, + a, b, c, d, e, f, g, h); + return to_global_ref_result(_result); +} + +jmethodID _m_Example__whichExample = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__whichExample(jobject self_) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example, &_m_Example__whichExample, "whichExample", "()I"); + if (_m_Example__whichExample == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int32_t _result = + (*jniEnv)->CallIntMethod(jniEnv, self_, _m_Example__whichExample); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +jmethodID _m_Example__addInts = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__addInts(int32_t a, int32_t b) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_Example, &_m_Example__addInts, "addInts", "(II)I"); + if (_m_Example__addInts == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int32_t _result = (*jniEnv)->CallStaticIntMethod(jniEnv, _c_Example, + _m_Example__addInts, a, b); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +jmethodID _m_Example__getArr = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__getArr() { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_Example, &_m_Example__getArr, "getArr", "()[I"); + if (_m_Example__getArr == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_Example, _m_Example__getArr); + return to_global_ref_result(_result); +} + +jmethodID _m_Example__addAll = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__addAll(jobject arr) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_Example, &_m_Example__addAll, "addAll", "([I)I"); + if (_m_Example__addAll == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int32_t _result = (*jniEnv)->CallStaticIntMethod(jniEnv, _c_Example, + _m_Example__addAll, arr); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +jmethodID _m_Example__getSelf = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__getSelf(jobject self_) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example, &_m_Example__getSelf, "getSelf", + "()Lcom/github/dart_lang/jnigen/simple_package/Example;"); + if (_m_Example__getSelf == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_Example__getSelf); + return to_global_ref_result(_result); +} + +jmethodID _m_Example__throwException = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__throwException() { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_Example, &_m_Example__throwException, "throwException", + "()V"); + if (_m_Example__throwException == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallStaticVoidMethod(jniEnv, _c_Example, + _m_Example__throwException); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +// com.github.dart_lang.jnigen.simple_package.Example$Nested +jclass _c_Example_Nested = NULL; + +jmethodID _m_Example_Nested__ctor = NULL; +FFI_PLUGIN_EXPORT +JniResult Example_Nested__ctor(uint8_t value) { + load_env(); + load_class_global_ref( + &_c_Example_Nested, + "com/github/dart_lang/jnigen/simple_package/Example$Nested"); + if (_c_Example_Nested == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example_Nested, &_m_Example_Nested__ctor, "", "(Z)V"); + if (_m_Example_Nested__ctor == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Example_Nested, + _m_Example_Nested__ctor, value); + return to_global_ref_result(_result); +} + +jmethodID _m_Example_Nested__getValue = NULL; +FFI_PLUGIN_EXPORT +JniResult Example_Nested__getValue(jobject self_) { + load_env(); + load_class_global_ref( + &_c_Example_Nested, + "com/github/dart_lang/jnigen/simple_package/Example$Nested"); + if (_c_Example_Nested == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example_Nested, &_m_Example_Nested__getValue, "getValue", + "()Z"); + if (_m_Example_Nested__getValue == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = + (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_Example_Nested__getValue); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_Example_Nested__setValue = NULL; +FFI_PLUGIN_EXPORT +JniResult Example_Nested__setValue(jobject self_, uint8_t value) { + load_env(); + load_class_global_ref( + &_c_Example_Nested, + "com/github/dart_lang/jnigen/simple_package/Example$Nested"); + if (_c_Example_Nested == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example_Nested, &_m_Example_Nested__setValue, "setValue", + "(Z)V"); + if (_m_Example_Nested__setValue == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_Example_Nested__setValue, value); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +// com.github.dart_lang.jnigen.simple_package.Exceptions +jclass _c_Exceptions = NULL; + +jmethodID _m_Exceptions__ctor = NULL; +FFI_PLUGIN_EXPORT +JniResult Exceptions__ctor() { load_env(); - load_class_global_ref(&_c_Example, - "com/github/dart_lang/jnigen/simple_package/Example"); - if (_c_Example == NULL) + load_class_global_ref( + &_c_Exceptions, "com/github/dart_lang/jnigen/simple_package/Exceptions"); + if (_c_Exceptions == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_Example, &_m_Example__ctor, "", "()V"); - if (_m_Example__ctor == NULL) + load_method(_c_Exceptions, &_m_Exceptions__ctor, "", "()V"); + if (_m_Exceptions__ctor == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Example, _m_Example__ctor); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + jobject _result = + (*jniEnv)->NewObject(jniEnv, _c_Exceptions, _m_Exceptions__ctor); + return to_global_ref_result(_result); } -jmethodID _m_Example__ctor1 = NULL; +jmethodID _m_Exceptions__ctor1 = NULL; FFI_PLUGIN_EXPORT -JniResult Example__ctor1(int32_t internal) { +JniResult Exceptions__ctor1(float x) { load_env(); - load_class_global_ref(&_c_Example, - "com/github/dart_lang/jnigen/simple_package/Example"); - if (_c_Example == NULL) + load_class_global_ref( + &_c_Exceptions, "com/github/dart_lang/jnigen/simple_package/Exceptions"); + if (_c_Exceptions == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_Example, &_m_Example__ctor1, "", "(I)V"); - if (_m_Example__ctor1 == NULL) + load_method(_c_Exceptions, &_m_Exceptions__ctor1, "", "(F)V"); + if (_m_Exceptions__ctor1 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = - (*jniEnv)->NewObject(jniEnv, _c_Example, _m_Example__ctor1, internal); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + (*jniEnv)->NewObject(jniEnv, _c_Exceptions, _m_Exceptions__ctor1, x); + return to_global_ref_result(_result); } -jmethodID _m_Example__whichExample = NULL; +jmethodID _m_Exceptions__ctor2 = NULL; FFI_PLUGIN_EXPORT -JniResult Example__whichExample(jobject self_) { +JniResult Exceptions__ctor2(int32_t a, + int32_t b, + int32_t c, + int32_t d, + int32_t e, + int32_t f) { load_env(); - load_class_global_ref(&_c_Example, - "com/github/dart_lang/jnigen/simple_package/Example"); - if (_c_Example == NULL) + load_class_global_ref( + &_c_Exceptions, "com/github/dart_lang/jnigen/simple_package/Exceptions"); + if (_c_Exceptions == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_Example, &_m_Example__whichExample, "whichExample", "()I"); - if (_m_Example__whichExample == NULL) + load_method(_c_Exceptions, &_m_Exceptions__ctor2, "", "(IIIIII)V"); + if (_m_Exceptions__ctor2 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - int32_t _result = - (*jniEnv)->CallIntMethod(jniEnv, self_, _m_Example__whichExample); + jobject _result = (*jniEnv)->NewObject( + jniEnv, _c_Exceptions, _m_Exceptions__ctor2, a, b, c, d, e, f); + return to_global_ref_result(_result); +} + +jmethodID _m_Exceptions__staticObjectMethod = NULL; +FFI_PLUGIN_EXPORT +JniResult Exceptions__staticObjectMethod() { + load_env(); + load_class_global_ref( + &_c_Exceptions, "com/github/dart_lang/jnigen/simple_package/Exceptions"); + if (_c_Exceptions == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_Exceptions, &_m_Exceptions__staticObjectMethod, + "staticObjectMethod", "()Ljava/lang/Object;"); + if (_m_Exceptions__staticObjectMethod == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallStaticObjectMethod( + jniEnv, _c_Exceptions, _m_Exceptions__staticObjectMethod); + return to_global_ref_result(_result); +} + +jmethodID _m_Exceptions__staticIntMethod = NULL; +FFI_PLUGIN_EXPORT +JniResult Exceptions__staticIntMethod() { + load_env(); + load_class_global_ref( + &_c_Exceptions, "com/github/dart_lang/jnigen/simple_package/Exceptions"); + if (_c_Exceptions == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_Exceptions, &_m_Exceptions__staticIntMethod, + "staticIntMethod", "()I"); + if (_m_Exceptions__staticIntMethod == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int32_t _result = (*jniEnv)->CallStaticIntMethod( + jniEnv, _c_Exceptions, _m_Exceptions__staticIntMethod); return (JniResult){.value = {.i = _result}, .exception = check_exception()}; } -jmethodID _m_Example__getAux = NULL; +jmethodID _m_Exceptions__staticObjectArrayMethod = NULL; FFI_PLUGIN_EXPORT -JniResult Example__getAux() { +JniResult Exceptions__staticObjectArrayMethod() { load_env(); - load_class_global_ref(&_c_Example, - "com/github/dart_lang/jnigen/simple_package/Example"); - if (_c_Example == NULL) + load_class_global_ref( + &_c_Exceptions, "com/github/dart_lang/jnigen/simple_package/Exceptions"); + if (_c_Exceptions == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_static_method( - _c_Example, &_m_Example__getAux, "getAux", - "()Lcom/github/dart_lang/jnigen/simple_package/Example$Aux;"); - if (_m_Example__getAux == NULL) + load_static_method(_c_Exceptions, &_m_Exceptions__staticObjectArrayMethod, + "staticObjectArrayMethod", "()[Ljava/lang/Object;"); + if (_m_Exceptions__staticObjectArrayMethod == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallStaticObjectMethod( + jniEnv, _c_Exceptions, _m_Exceptions__staticObjectArrayMethod); + return to_global_ref_result(_result); +} + +jmethodID _m_Exceptions__staticIntArrayMethod = NULL; +FFI_PLUGIN_EXPORT +JniResult Exceptions__staticIntArrayMethod() { + load_env(); + load_class_global_ref( + &_c_Exceptions, "com/github/dart_lang/jnigen/simple_package/Exceptions"); + if (_c_Exceptions == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_Exceptions, &_m_Exceptions__staticIntArrayMethod, + "staticIntArrayMethod", "()[I"); + if (_m_Exceptions__staticIntArrayMethod == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallStaticObjectMethod( + jniEnv, _c_Exceptions, _m_Exceptions__staticIntArrayMethod); + return to_global_ref_result(_result); +} + +jmethodID _m_Exceptions__objectMethod = NULL; +FFI_PLUGIN_EXPORT +JniResult Exceptions__objectMethod(jobject self_) { + load_env(); + load_class_global_ref( + &_c_Exceptions, "com/github/dart_lang/jnigen/simple_package/Exceptions"); + if (_c_Exceptions == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Exceptions, &_m_Exceptions__objectMethod, "objectMethod", + "()Ljava/lang/Object;"); + if (_m_Exceptions__objectMethod == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = - (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_Example, _m_Example__getAux); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_Exceptions__objectMethod); + return to_global_ref_result(_result); } -jmethodID _m_Example__addInts = NULL; +jmethodID _m_Exceptions__intMethod = NULL; FFI_PLUGIN_EXPORT -JniResult Example__addInts(int32_t a, int32_t b) { +JniResult Exceptions__intMethod(jobject self_) { load_env(); - load_class_global_ref(&_c_Example, - "com/github/dart_lang/jnigen/simple_package/Example"); - if (_c_Example == NULL) + load_class_global_ref( + &_c_Exceptions, "com/github/dart_lang/jnigen/simple_package/Exceptions"); + if (_c_Exceptions == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_static_method(_c_Example, &_m_Example__addInts, "addInts", "(II)I"); - if (_m_Example__addInts == NULL) + load_method(_c_Exceptions, &_m_Exceptions__intMethod, "intMethod", "()I"); + if (_m_Exceptions__intMethod == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - int32_t _result = (*jniEnv)->CallStaticIntMethod(jniEnv, _c_Example, - _m_Example__addInts, a, b); + int32_t _result = + (*jniEnv)->CallIntMethod(jniEnv, self_, _m_Exceptions__intMethod); return (JniResult){.value = {.i = _result}, .exception = check_exception()}; } -jmethodID _m_Example__getArr = NULL; +jmethodID _m_Exceptions__objectArrayMethod = NULL; FFI_PLUGIN_EXPORT -JniResult Example__getArr() { +JniResult Exceptions__objectArrayMethod(jobject self_) { load_env(); - load_class_global_ref(&_c_Example, - "com/github/dart_lang/jnigen/simple_package/Example"); - if (_c_Example == NULL) + load_class_global_ref( + &_c_Exceptions, "com/github/dart_lang/jnigen/simple_package/Exceptions"); + if (_c_Exceptions == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_static_method(_c_Example, &_m_Example__getArr, "getArr", "()[I"); - if (_m_Example__getArr == NULL) + load_method(_c_Exceptions, &_m_Exceptions__objectArrayMethod, + "objectArrayMethod", "()[Ljava/lang/Object;"); + if (_m_Exceptions__objectArrayMethod == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_Exceptions__objectArrayMethod); + return to_global_ref_result(_result); +} + +jmethodID _m_Exceptions__intArrayMethod = NULL; +FFI_PLUGIN_EXPORT +JniResult Exceptions__intArrayMethod(jobject self_) { + load_env(); + load_class_global_ref( + &_c_Exceptions, "com/github/dart_lang/jnigen/simple_package/Exceptions"); + if (_c_Exceptions == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Exceptions, &_m_Exceptions__intArrayMethod, "intArrayMethod", + "()[I"); + if (_m_Exceptions__intArrayMethod == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = - (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_Example, _m_Example__getArr); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_Exceptions__intArrayMethod); + return to_global_ref_result(_result); } -jmethodID _m_Example__addAll = NULL; +jmethodID _m_Exceptions__throwNullPointerException = NULL; FFI_PLUGIN_EXPORT -JniResult Example__addAll(jobject arr) { +JniResult Exceptions__throwNullPointerException(jobject self_) { load_env(); - load_class_global_ref(&_c_Example, - "com/github/dart_lang/jnigen/simple_package/Example"); - if (_c_Example == NULL) + load_class_global_ref( + &_c_Exceptions, "com/github/dart_lang/jnigen/simple_package/Exceptions"); + if (_c_Exceptions == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_static_method(_c_Example, &_m_Example__addAll, "addAll", "([I)I"); - if (_m_Example__addAll == NULL) + load_method(_c_Exceptions, &_m_Exceptions__throwNullPointerException, + "throwNullPointerException", "()I"); + if (_m_Exceptions__throwNullPointerException == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - int32_t _result = (*jniEnv)->CallStaticIntMethod(jniEnv, _c_Example, - _m_Example__addAll, arr); + int32_t _result = (*jniEnv)->CallIntMethod( + jniEnv, self_, _m_Exceptions__throwNullPointerException); return (JniResult){.value = {.i = _result}, .exception = check_exception()}; } -jmethodID _m_Example__getSelf = NULL; +jmethodID _m_Exceptions__throwFileNotFoundException = NULL; FFI_PLUGIN_EXPORT -JniResult Example__getSelf(jobject self_) { +JniResult Exceptions__throwFileNotFoundException(jobject self_) { load_env(); - load_class_global_ref(&_c_Example, - "com/github/dart_lang/jnigen/simple_package/Example"); - if (_c_Example == NULL) + load_class_global_ref( + &_c_Exceptions, "com/github/dart_lang/jnigen/simple_package/Exceptions"); + if (_c_Exceptions == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_Example, &_m_Example__getSelf, "getSelf", - "()Lcom/github/dart_lang/jnigen/simple_package/Example;"); - if (_m_Example__getSelf == NULL) + load_method(_c_Exceptions, &_m_Exceptions__throwFileNotFoundException, + "throwFileNotFoundException", "()Ljava/io/InputStream;"); + if (_m_Exceptions__throwFileNotFoundException == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - jobject _result = - (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_Example__getSelf); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_Exceptions__throwFileNotFoundException); + return to_global_ref_result(_result); } -jmethodID _m_Example__getNum = NULL; +jmethodID _m_Exceptions__throwClassCastException = NULL; FFI_PLUGIN_EXPORT -JniResult Example__getNum(jobject self_) { +JniResult Exceptions__throwClassCastException(jobject self_) { load_env(); - load_class_global_ref(&_c_Example, - "com/github/dart_lang/jnigen/simple_package/Example"); - if (_c_Example == NULL) + load_class_global_ref( + &_c_Exceptions, "com/github/dart_lang/jnigen/simple_package/Exceptions"); + if (_c_Exceptions == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Exceptions, &_m_Exceptions__throwClassCastException, + "throwClassCastException", "()Ljava/io/FileInputStream;"); + if (_m_Exceptions__throwClassCastException == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_Exceptions__throwClassCastException); + return to_global_ref_result(_result); +} + +jmethodID _m_Exceptions__throwArrayIndexException = NULL; +FFI_PLUGIN_EXPORT +JniResult Exceptions__throwArrayIndexException(jobject self_) { + load_env(); + load_class_global_ref( + &_c_Exceptions, "com/github/dart_lang/jnigen/simple_package/Exceptions"); + if (_c_Exceptions == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_Example, &_m_Example__getNum, "getNum", "()I"); - if (_m_Example__getNum == NULL) + load_method(_c_Exceptions, &_m_Exceptions__throwArrayIndexException, + "throwArrayIndexException", "()I"); + if (_m_Exceptions__throwArrayIndexException == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - int32_t _result = (*jniEnv)->CallIntMethod(jniEnv, self_, _m_Example__getNum); + int32_t _result = (*jniEnv)->CallIntMethod( + jniEnv, self_, _m_Exceptions__throwArrayIndexException); return (JniResult){.value = {.i = _result}, .exception = check_exception()}; } -jmethodID _m_Example__setNum = NULL; +jmethodID _m_Exceptions__throwArithmeticException = NULL; FFI_PLUGIN_EXPORT -JniResult Example__setNum(jobject self_, int32_t num) { +JniResult Exceptions__throwArithmeticException(jobject self_) { load_env(); - load_class_global_ref(&_c_Example, - "com/github/dart_lang/jnigen/simple_package/Example"); - if (_c_Example == NULL) + load_class_global_ref( + &_c_Exceptions, "com/github/dart_lang/jnigen/simple_package/Exceptions"); + if (_c_Exceptions == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Exceptions, &_m_Exceptions__throwArithmeticException, + "throwArithmeticException", "()I"); + if (_m_Exceptions__throwArithmeticException == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int32_t _result = (*jniEnv)->CallIntMethod( + jniEnv, self_, _m_Exceptions__throwArithmeticException); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +jmethodID _m_Exceptions__throwLoremIpsum = NULL; +FFI_PLUGIN_EXPORT +JniResult Exceptions__throwLoremIpsum() { + load_env(); + load_class_global_ref( + &_c_Exceptions, "com/github/dart_lang/jnigen/simple_package/Exceptions"); + if (_c_Exceptions == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_Example, &_m_Example__setNum, "setNum", "(I)V"); - if (_m_Example__setNum == NULL) + load_static_method(_c_Exceptions, &_m_Exceptions__throwLoremIpsum, + "throwLoremIpsum", "()V"); + if (_m_Exceptions__throwLoremIpsum == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_Example__setNum, num); + (*jniEnv)->CallStaticVoidMethod(jniEnv, _c_Exceptions, + _m_Exceptions__throwLoremIpsum); return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } -jmethodID _m_Example__getInternal = NULL; +// com.github.dart_lang.jnigen.simple_package.Fields +jclass _c_Fields = NULL; + +jmethodID _m_Fields__ctor = NULL; FFI_PLUGIN_EXPORT -JniResult Example__getInternal(jobject self_) { +JniResult Fields__ctor() { load_env(); - load_class_global_ref(&_c_Example, - "com/github/dart_lang/jnigen/simple_package/Example"); - if (_c_Example == NULL) + load_class_global_ref(&_c_Fields, + "com/github/dart_lang/jnigen/simple_package/Fields"); + if (_c_Fields == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Fields, &_m_Fields__ctor, "", "()V"); + if (_m_Fields__ctor == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_Example, &_m_Example__getInternal, "getInternal", "()I"); - if (_m_Example__getInternal == NULL) + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Fields, _m_Fields__ctor); + return to_global_ref_result(_result); +} + +jfieldID _f_Fields__amount = NULL; +FFI_PLUGIN_EXPORT +JniResult get_Fields__amount() { + load_env(); + load_class_global_ref(&_c_Fields, + "com/github/dart_lang/jnigen/simple_package/Fields"); + if (_c_Fields == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_field(_c_Fields, &_f_Fields__amount, "amount", "I"); int32_t _result = - (*jniEnv)->CallIntMethod(jniEnv, self_, _m_Example__getInternal); + (*jniEnv)->GetStaticIntField(jniEnv, _c_Fields, _f_Fields__amount); return (JniResult){.value = {.i = _result}, .exception = check_exception()}; } -jmethodID _m_Example__setInternal = NULL; FFI_PLUGIN_EXPORT -JniResult Example__setInternal(jobject self_, int32_t internal) { +JniResult set_Fields__amount(int32_t value) { load_env(); - load_class_global_ref(&_c_Example, - "com/github/dart_lang/jnigen/simple_package/Example"); - if (_c_Example == NULL) + load_class_global_ref(&_c_Fields, + "com/github/dart_lang/jnigen/simple_package/Fields"); + if (_c_Fields == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_field(_c_Fields, &_f_Fields__amount, "amount", "I"); + (*jniEnv)->SetStaticIntField(jniEnv, _c_Fields, _f_Fields__amount, value); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +jfieldID _f_Fields__pi = NULL; +FFI_PLUGIN_EXPORT +JniResult get_Fields__pi() { + load_env(); + load_class_global_ref(&_c_Fields, + "com/github/dart_lang/jnigen/simple_package/Fields"); + if (_c_Fields == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_Example, &_m_Example__setInternal, "setInternal", "(I)V"); - if (_m_Example__setInternal == NULL) + load_static_field(_c_Fields, &_f_Fields__pi, "pi", "D"); + double _result = + (*jniEnv)->GetStaticDoubleField(jniEnv, _c_Fields, _f_Fields__pi); + return (JniResult){.value = {.d = _result}, .exception = check_exception()}; +} + +FFI_PLUGIN_EXPORT +JniResult set_Fields__pi(double value) { + load_env(); + load_class_global_ref(&_c_Fields, + "com/github/dart_lang/jnigen/simple_package/Fields"); + if (_c_Fields == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_Example__setInternal, internal); + load_static_field(_c_Fields, &_f_Fields__pi, "pi", "D"); + (*jniEnv)->SetStaticDoubleField(jniEnv, _c_Fields, _f_Fields__pi, value); return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } -jmethodID _m_Example__throwException = NULL; +jfieldID _f_Fields__asterisk = NULL; FFI_PLUGIN_EXPORT -JniResult Example__throwException() { +JniResult get_Fields__asterisk() { load_env(); - load_class_global_ref(&_c_Example, - "com/github/dart_lang/jnigen/simple_package/Example"); - if (_c_Example == NULL) + load_class_global_ref(&_c_Fields, + "com/github/dart_lang/jnigen/simple_package/Fields"); + if (_c_Fields == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_static_method(_c_Example, &_m_Example__throwException, "throwException", - "()V"); - if (_m_Example__throwException == NULL) + load_static_field(_c_Fields, &_f_Fields__asterisk, "asterisk", "C"); + uint16_t _result = + (*jniEnv)->GetStaticCharField(jniEnv, _c_Fields, _f_Fields__asterisk); + return (JniResult){.value = {.c = _result}, .exception = check_exception()}; +} + +FFI_PLUGIN_EXPORT +JniResult set_Fields__asterisk(uint16_t value) { + load_env(); + load_class_global_ref(&_c_Fields, + "com/github/dart_lang/jnigen/simple_package/Fields"); + if (_c_Fields == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - (*jniEnv)->CallStaticVoidMethod(jniEnv, _c_Example, - _m_Example__throwException); + load_static_field(_c_Fields, &_f_Fields__asterisk, "asterisk", "C"); + (*jniEnv)->SetStaticCharField(jniEnv, _c_Fields, _f_Fields__asterisk, value); return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } -jfieldID _f_Example__aux = NULL; +jfieldID _f_Fields__name = NULL; FFI_PLUGIN_EXPORT -JniResult get_Example__aux() { +JniResult get_Fields__name() { load_env(); - load_class_global_ref(&_c_Example, - "com/github/dart_lang/jnigen/simple_package/Example"); - if (_c_Example == NULL) + load_class_global_ref(&_c_Fields, + "com/github/dart_lang/jnigen/simple_package/Fields"); + if (_c_Fields == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_static_field(_c_Example, &_f_Example__aux, "aux", - "Lcom/github/dart_lang/jnigen/simple_package/Example$Aux;"); - jobject _result = to_global_ref( - (*jniEnv)->GetStaticObjectField(jniEnv, _c_Example, _f_Example__aux)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + load_static_field(_c_Fields, &_f_Fields__name, "name", "Ljava/lang/String;"); + jobject _result = + (*jniEnv)->GetStaticObjectField(jniEnv, _c_Fields, _f_Fields__name); + return to_global_ref_result(_result); } FFI_PLUGIN_EXPORT -JniResult set_Example__aux(jobject value) { +JniResult set_Fields__name(jobject value) { load_env(); - load_class_global_ref(&_c_Example, - "com/github/dart_lang/jnigen/simple_package/Example"); - if (_c_Example == NULL) + load_class_global_ref(&_c_Fields, + "com/github/dart_lang/jnigen/simple_package/Fields"); + if (_c_Fields == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_static_field(_c_Example, &_f_Example__aux, "aux", - "Lcom/github/dart_lang/jnigen/simple_package/Example$Aux;"); - (*jniEnv)->SetStaticObjectField(jniEnv, _c_Example, _f_Example__aux, value); + load_static_field(_c_Fields, &_f_Fields__name, "name", "Ljava/lang/String;"); + (*jniEnv)->SetStaticObjectField(jniEnv, _c_Fields, _f_Fields__name, value); return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } -jfieldID _f_Example__num = NULL; +jfieldID _f_Fields__i = NULL; FFI_PLUGIN_EXPORT -JniResult get_Example__num() { +JniResult get_Fields__i(jobject self_) { load_env(); - load_class_global_ref(&_c_Example, - "com/github/dart_lang/jnigen/simple_package/Example"); - if (_c_Example == NULL) + load_class_global_ref(&_c_Fields, + "com/github/dart_lang/jnigen/simple_package/Fields"); + if (_c_Fields == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_static_field(_c_Example, &_f_Example__num, "num", "I"); - int32_t _result = - (*jniEnv)->GetStaticIntField(jniEnv, _c_Example, _f_Example__num); - return (JniResult){.value = {.i = _result}, .exception = check_exception()}; + load_field(_c_Fields, &_f_Fields__i, "i", "Ljava/lang/Integer;"); + jobject _result = (*jniEnv)->GetObjectField(jniEnv, self_, _f_Fields__i); + return to_global_ref_result(_result); } FFI_PLUGIN_EXPORT -JniResult set_Example__num(int32_t value) { +JniResult set_Fields__i(jobject self_, jobject value) { load_env(); - load_class_global_ref(&_c_Example, - "com/github/dart_lang/jnigen/simple_package/Example"); - if (_c_Example == NULL) + load_class_global_ref(&_c_Fields, + "com/github/dart_lang/jnigen/simple_package/Fields"); + if (_c_Fields == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_field(_c_Fields, &_f_Fields__i, "i", "Ljava/lang/Integer;"); + (*jniEnv)->SetObjectField(jniEnv, self_, _f_Fields__i, value); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +jfieldID _f_Fields__trillion = NULL; +FFI_PLUGIN_EXPORT +JniResult get_Fields__trillion(jobject self_) { + load_env(); + load_class_global_ref(&_c_Fields, + "com/github/dart_lang/jnigen/simple_package/Fields"); + if (_c_Fields == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_field(_c_Fields, &_f_Fields__trillion, "trillion", "J"); + int64_t _result = (*jniEnv)->GetLongField(jniEnv, self_, _f_Fields__trillion); + return (JniResult){.value = {.j = _result}, .exception = check_exception()}; +} + +FFI_PLUGIN_EXPORT +JniResult set_Fields__trillion(jobject self_, int64_t value) { + load_env(); + load_class_global_ref(&_c_Fields, + "com/github/dart_lang/jnigen/simple_package/Fields"); + if (_c_Fields == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_static_field(_c_Example, &_f_Example__num, "num", "I"); - (*jniEnv)->SetStaticIntField(jniEnv, _c_Example, _f_Example__num, value); + load_field(_c_Fields, &_f_Fields__trillion, "trillion", "J"); + (*jniEnv)->SetLongField(jniEnv, self_, _f_Fields__trillion, value); return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } -// com.github.dart_lang.jnigen.simple_package.Example$Aux -jclass _c_Example_Aux = NULL; +jfieldID _f_Fields__isAchillesDead = NULL; +FFI_PLUGIN_EXPORT +JniResult get_Fields__isAchillesDead(jobject self_) { + load_env(); + load_class_global_ref(&_c_Fields, + "com/github/dart_lang/jnigen/simple_package/Fields"); + if (_c_Fields == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_field(_c_Fields, &_f_Fields__isAchillesDead, "isAchillesDead", "Z"); + uint8_t _result = + (*jniEnv)->GetBooleanField(jniEnv, self_, _f_Fields__isAchillesDead); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} -jmethodID _m_Example_Aux__ctor = NULL; FFI_PLUGIN_EXPORT -JniResult Example_Aux__ctor(uint8_t value) { +JniResult set_Fields__isAchillesDead(jobject self_, uint8_t value) { load_env(); - load_class_global_ref( - &_c_Example_Aux, - "com/github/dart_lang/jnigen/simple_package/Example$Aux"); - if (_c_Example_Aux == NULL) + load_class_global_ref(&_c_Fields, + "com/github/dart_lang/jnigen/simple_package/Fields"); + if (_c_Fields == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_Example_Aux, &_m_Example_Aux__ctor, "", "(Z)V"); - if (_m_Example_Aux__ctor == NULL) + load_field(_c_Fields, &_f_Fields__isAchillesDead, "isAchillesDead", "Z"); + (*jniEnv)->SetBooleanField(jniEnv, self_, _f_Fields__isAchillesDead, value); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +jfieldID _f_Fields__bestFighterInGreece = NULL; +FFI_PLUGIN_EXPORT +JniResult get_Fields__bestFighterInGreece(jobject self_) { + load_env(); + load_class_global_ref(&_c_Fields, + "com/github/dart_lang/jnigen/simple_package/Fields"); + if (_c_Fields == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_field(_c_Fields, &_f_Fields__bestFighterInGreece, "bestFighterInGreece", + "Ljava/lang/String;"); jobject _result = - (*jniEnv)->NewObject(jniEnv, _c_Example_Aux, _m_Example_Aux__ctor, value); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + (*jniEnv)->GetObjectField(jniEnv, self_, _f_Fields__bestFighterInGreece); + return to_global_ref_result(_result); +} + +FFI_PLUGIN_EXPORT +JniResult set_Fields__bestFighterInGreece(jobject self_, jobject value) { + load_env(); + load_class_global_ref(&_c_Fields, + "com/github/dart_lang/jnigen/simple_package/Fields"); + if (_c_Fields == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_field(_c_Fields, &_f_Fields__bestFighterInGreece, "bestFighterInGreece", + "Ljava/lang/String;"); + (*jniEnv)->SetObjectField(jniEnv, self_, _f_Fields__bestFighterInGreece, + value); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +jfieldID _f_Fields__random = NULL; +FFI_PLUGIN_EXPORT +JniResult get_Fields__random(jobject self_) { + load_env(); + load_class_global_ref(&_c_Fields, + "com/github/dart_lang/jnigen/simple_package/Fields"); + if (_c_Fields == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_field(_c_Fields, &_f_Fields__random, "random", "Ljava/util/Random;"); + jobject _result = (*jniEnv)->GetObjectField(jniEnv, self_, _f_Fields__random); + return to_global_ref_result(_result); +} + +FFI_PLUGIN_EXPORT +JniResult set_Fields__random(jobject self_, jobject value) { + load_env(); + load_class_global_ref(&_c_Fields, + "com/github/dart_lang/jnigen/simple_package/Fields"); + if (_c_Fields == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_field(_c_Fields, &_f_Fields__random, "random", "Ljava/util/Random;"); + (*jniEnv)->SetObjectField(jniEnv, self_, _f_Fields__random, value); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +jfieldID _f_Fields__euroSymbol = NULL; +FFI_PLUGIN_EXPORT +JniResult get_Fields__euroSymbol() { + load_env(); + load_class_global_ref(&_c_Fields, + "com/github/dart_lang/jnigen/simple_package/Fields"); + if (_c_Fields == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_field(_c_Fields, &_f_Fields__euroSymbol, "euroSymbol", "C"); + uint16_t _result = + (*jniEnv)->GetStaticCharField(jniEnv, _c_Fields, _f_Fields__euroSymbol); + return (JniResult){.value = {.c = _result}, .exception = check_exception()}; +} + +FFI_PLUGIN_EXPORT +JniResult set_Fields__euroSymbol(uint16_t value) { + load_env(); + load_class_global_ref(&_c_Fields, + "com/github/dart_lang/jnigen/simple_package/Fields"); + if (_c_Fields == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_field(_c_Fields, &_f_Fields__euroSymbol, "euroSymbol", "C"); + (*jniEnv)->SetStaticCharField(jniEnv, _c_Fields, _f_Fields__euroSymbol, + value); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } -jmethodID _m_Example_Aux__getValue = NULL; +// com.github.dart_lang.jnigen.simple_package.Fields$Nested +jclass _c_Fields_Nested = NULL; + +jmethodID _m_Fields_Nested__ctor = NULL; FFI_PLUGIN_EXPORT -JniResult Example_Aux__getValue(jobject self_) { +JniResult Fields_Nested__ctor() { load_env(); load_class_global_ref( - &_c_Example_Aux, - "com/github/dart_lang/jnigen/simple_package/Example$Aux"); - if (_c_Example_Aux == NULL) + &_c_Fields_Nested, + "com/github/dart_lang/jnigen/simple_package/Fields$Nested"); + if (_c_Fields_Nested == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_Example_Aux, &_m_Example_Aux__getValue, "getValue", "()Z"); - if (_m_Example_Aux__getValue == NULL) + load_method(_c_Fields_Nested, &_m_Fields_Nested__ctor, "", "()V"); + if (_m_Fields_Nested__ctor == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - uint8_t _result = - (*jniEnv)->CallBooleanMethod(jniEnv, self_, _m_Example_Aux__getValue); - return (JniResult){.value = {.z = _result}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->NewObject(jniEnv, _c_Fields_Nested, _m_Fields_Nested__ctor); + return to_global_ref_result(_result); } -jmethodID _m_Example_Aux__setValue = NULL; +jfieldID _f_Fields_Nested__hundred = NULL; FFI_PLUGIN_EXPORT -JniResult Example_Aux__setValue(jobject self_, uint8_t value) { +JniResult get_Fields_Nested__hundred(jobject self_) { load_env(); load_class_global_ref( - &_c_Example_Aux, - "com/github/dart_lang/jnigen/simple_package/Example$Aux"); - if (_c_Example_Aux == NULL) + &_c_Fields_Nested, + "com/github/dart_lang/jnigen/simple_package/Fields$Nested"); + if (_c_Fields_Nested == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_Example_Aux, &_m_Example_Aux__setValue, "setValue", "(Z)V"); - if (_m_Example_Aux__setValue == NULL) + load_field(_c_Fields_Nested, &_f_Fields_Nested__hundred, "hundred", "J"); + int64_t _result = + (*jniEnv)->GetLongField(jniEnv, self_, _f_Fields_Nested__hundred); + return (JniResult){.value = {.j = _result}, .exception = check_exception()}; +} + +FFI_PLUGIN_EXPORT +JniResult set_Fields_Nested__hundred(jobject self_, int64_t value) { + load_env(); + load_class_global_ref( + &_c_Fields_Nested, + "com/github/dart_lang/jnigen/simple_package/Fields$Nested"); + if (_c_Fields_Nested == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_Example_Aux__setValue, value); + load_field(_c_Fields_Nested, &_f_Fields_Nested__hundred, "hundred", "J"); + (*jniEnv)->SetLongField(jniEnv, self_, _f_Fields_Nested__hundred, value); return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } -jfieldID _f_Example_Aux__value = NULL; +jfieldID _f_Fields_Nested__BEST_GOD = NULL; FFI_PLUGIN_EXPORT -JniResult get_Example_Aux__value(jobject self_) { +JniResult get_Fields_Nested__BEST_GOD() { load_env(); load_class_global_ref( - &_c_Example_Aux, - "com/github/dart_lang/jnigen/simple_package/Example$Aux"); - if (_c_Example_Aux == NULL) + &_c_Fields_Nested, + "com/github/dart_lang/jnigen/simple_package/Fields$Nested"); + if (_c_Fields_Nested == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_field(_c_Example_Aux, &_f_Example_Aux__value, "value", "Z"); - uint8_t _result = - (*jniEnv)->GetBooleanField(jniEnv, self_, _f_Example_Aux__value); - return (JniResult){.value = {.z = _result}, .exception = check_exception()}; + load_static_field(_c_Fields_Nested, &_f_Fields_Nested__BEST_GOD, "BEST_GOD", + "Ljava/lang/String;"); + jobject _result = (*jniEnv)->GetStaticObjectField(jniEnv, _c_Fields_Nested, + _f_Fields_Nested__BEST_GOD); + return to_global_ref_result(_result); } FFI_PLUGIN_EXPORT -JniResult set_Example_Aux__value(jobject self_, uint8_t value) { +JniResult set_Fields_Nested__BEST_GOD(jobject value) { load_env(); load_class_global_ref( - &_c_Example_Aux, - "com/github/dart_lang/jnigen/simple_package/Example$Aux"); - if (_c_Example_Aux == NULL) - return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_field(_c_Example_Aux, &_f_Example_Aux__value, "value", "Z"); - (*jniEnv)->SetBooleanField(jniEnv, self_, _f_Example_Aux__value, value); + &_c_Fields_Nested, + "com/github/dart_lang/jnigen/simple_package/Fields$Nested"); + if (_c_Fields_Nested == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_field(_c_Fields_Nested, &_f_Fields_Nested__BEST_GOD, "BEST_GOD", + "Ljava/lang/String;"); + (*jniEnv)->SetStaticObjectField(jniEnv, _c_Fields_Nested, + _f_Fields_Nested__BEST_GOD, value); return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } @@ -385,8 +1307,7 @@ JniResult C2__ctor() { if (_m_C2__ctor == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_C2, _m_C2__ctor); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jfieldID _f_C2__CONSTANT = NULL; @@ -429,8 +1350,7 @@ JniResult Example1__ctor() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Example1, _m_Example1__ctor); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_Example1__whichExample = NULL; @@ -466,8 +1386,7 @@ JniResult GrandParent__ctor(jobject value) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_GrandParent, _m_GrandParent__ctor, value); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_GrandParent__stringParent = NULL; @@ -484,8 +1403,7 @@ JniResult GrandParent__stringParent(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_GrandParent__stringParent); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_GrandParent__varParent = NULL; @@ -503,8 +1421,7 @@ JniResult GrandParent__varParent(jobject self_, jobject nestedValue) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_GrandParent__varParent, nestedValue); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_GrandParent__stringStaticParent = NULL; @@ -522,8 +1439,7 @@ JniResult GrandParent__stringStaticParent() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_GrandParent, _m_GrandParent__stringStaticParent); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_GrandParent__varStaticParent = NULL; @@ -542,8 +1458,7 @@ JniResult GrandParent__varStaticParent(jobject value) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_GrandParent, _m_GrandParent__varStaticParent, value); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_GrandParent__staticParentWithSameType = NULL; @@ -562,8 +1477,7 @@ JniResult GrandParent__staticParentWithSameType(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod( jniEnv, self_, _m_GrandParent__staticParentWithSameType); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jfieldID _f_GrandParent__value = NULL; @@ -576,9 +1490,9 @@ JniResult get_GrandParent__value(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_GrandParent, &_f_GrandParent__value, "value", "Ljava/lang/Object;"); - jobject _result = to_global_ref( - (*jniEnv)->GetObjectField(jniEnv, self_, _f_GrandParent__value)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->GetObjectField(jniEnv, self_, _f_GrandParent__value); + return to_global_ref_result(_result); } FFI_PLUGIN_EXPORT @@ -613,8 +1527,7 @@ JniResult GrandParent_Parent__ctor(jobject parentValue, jobject value) { jobject _result = (*jniEnv)->NewObject(jniEnv, _c_GrandParent_Parent, _m_GrandParent_Parent__ctor, parentValue, value); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jfieldID _f_GrandParent_Parent__parentValue = NULL; @@ -628,9 +1541,9 @@ JniResult get_GrandParent_Parent__parentValue(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_GrandParent_Parent, &_f_GrandParent_Parent__parentValue, "parentValue", "Ljava/lang/Object;"); - jobject _result = to_global_ref((*jniEnv)->GetObjectField( - jniEnv, self_, _f_GrandParent_Parent__parentValue)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = (*jniEnv)->GetObjectField( + jniEnv, self_, _f_GrandParent_Parent__parentValue); + return to_global_ref_result(_result); } FFI_PLUGIN_EXPORT @@ -659,9 +1572,9 @@ JniResult get_GrandParent_Parent__value(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_GrandParent_Parent, &_f_GrandParent_Parent__value, "value", "Ljava/lang/Object;"); - jobject _result = to_global_ref( - (*jniEnv)->GetObjectField(jniEnv, self_, _f_GrandParent_Parent__value)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->GetObjectField(jniEnv, self_, _f_GrandParent_Parent__value); + return to_global_ref_result(_result); } FFI_PLUGIN_EXPORT @@ -700,8 +1613,7 @@ JniResult GrandParent_Parent_Child__ctor(jobject grandParentValue, jobject _result = (*jniEnv)->NewObject(jniEnv, _c_GrandParent_Parent_Child, _m_GrandParent_Parent_Child__ctor, grandParentValue, parentValue, value); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jfieldID _f_GrandParent_Parent_Child__grandParentValue = NULL; @@ -716,9 +1628,9 @@ JniResult get_GrandParent_Parent_Child__grandParentValue(jobject self_) { load_field(_c_GrandParent_Parent_Child, &_f_GrandParent_Parent_Child__grandParentValue, "grandParentValue", "Ljava/lang/Object;"); - jobject _result = to_global_ref((*jniEnv)->GetObjectField( - jniEnv, self_, _f_GrandParent_Parent_Child__grandParentValue)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = (*jniEnv)->GetObjectField( + jniEnv, self_, _f_GrandParent_Parent_Child__grandParentValue); + return to_global_ref_result(_result); } FFI_PLUGIN_EXPORT @@ -750,9 +1662,9 @@ JniResult get_GrandParent_Parent_Child__parentValue(jobject self_) { load_field(_c_GrandParent_Parent_Child, &_f_GrandParent_Parent_Child__parentValue, "parentValue", "Ljava/lang/Object;"); - jobject _result = to_global_ref((*jniEnv)->GetObjectField( - jniEnv, self_, _f_GrandParent_Parent_Child__parentValue)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = (*jniEnv)->GetObjectField( + jniEnv, self_, _f_GrandParent_Parent_Child__parentValue); + return to_global_ref_result(_result); } FFI_PLUGIN_EXPORT @@ -783,9 +1695,9 @@ JniResult get_GrandParent_Parent_Child__value(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_GrandParent_Parent_Child, &_f_GrandParent_Parent_Child__value, "value", "Ljava/lang/Object;"); - jobject _result = to_global_ref((*jniEnv)->GetObjectField( - jniEnv, self_, _f_GrandParent_Parent_Child__value)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = (*jniEnv)->GetObjectField( + jniEnv, self_, _f_GrandParent_Parent_Child__value); + return to_global_ref_result(_result); } FFI_PLUGIN_EXPORT @@ -822,8 +1734,7 @@ JniResult GrandParent_StaticParent__ctor(jobject value) { jobject _result = (*jniEnv)->NewObject(jniEnv, _c_GrandParent_StaticParent, _m_GrandParent_StaticParent__ctor, value); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jfieldID _f_GrandParent_StaticParent__value = NULL; @@ -837,9 +1748,9 @@ JniResult get_GrandParent_StaticParent__value(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_GrandParent_StaticParent, &_f_GrandParent_StaticParent__value, "value", "Ljava/lang/Object;"); - jobject _result = to_global_ref((*jniEnv)->GetObjectField( - jniEnv, self_, _f_GrandParent_StaticParent__value)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = (*jniEnv)->GetObjectField( + jniEnv, self_, _f_GrandParent_StaticParent__value); + return to_global_ref_result(_result); } FFI_PLUGIN_EXPORT @@ -878,8 +1789,7 @@ JniResult GrandParent_StaticParent_Child__ctor(jobject parentValue, jobject _result = (*jniEnv)->NewObject( jniEnv, _c_GrandParent_StaticParent_Child, _m_GrandParent_StaticParent_Child__ctor, parentValue, value); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jfieldID _f_GrandParent_StaticParent_Child__parentValue = NULL; @@ -894,9 +1804,9 @@ JniResult get_GrandParent_StaticParent_Child__parentValue(jobject self_) { load_field(_c_GrandParent_StaticParent_Child, &_f_GrandParent_StaticParent_Child__parentValue, "parentValue", "Ljava/lang/Object;"); - jobject _result = to_global_ref((*jniEnv)->GetObjectField( - jniEnv, self_, _f_GrandParent_StaticParent_Child__parentValue)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = (*jniEnv)->GetObjectField( + jniEnv, self_, _f_GrandParent_StaticParent_Child__parentValue); + return to_global_ref_result(_result); } FFI_PLUGIN_EXPORT @@ -928,9 +1838,9 @@ JniResult get_GrandParent_StaticParent_Child__value(jobject self_) { load_field(_c_GrandParent_StaticParent_Child, &_f_GrandParent_StaticParent_Child__value, "value", "Ljava/lang/Object;"); - jobject _result = to_global_ref((*jniEnv)->GetObjectField( - jniEnv, self_, _f_GrandParent_StaticParent_Child__value)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = (*jniEnv)->GetObjectField( + jniEnv, self_, _f_GrandParent_StaticParent_Child__value); + return to_global_ref_result(_result); } FFI_PLUGIN_EXPORT @@ -965,8 +1875,7 @@ JniResult MyMap__ctor() { if (_m_MyMap__ctor == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_MyMap, _m_MyMap__ctor); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_MyMap__get0 = NULL; @@ -983,8 +1892,7 @@ JniResult MyMap__get0(jobject self_, jobject key) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_MyMap__get0, key); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_MyMap__put = NULL; @@ -1001,8 +1909,7 @@ JniResult MyMap__put(jobject self_, jobject key, jobject value) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_MyMap__put, key, value); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_MyMap__entryStack = NULL; @@ -1019,8 +1926,7 @@ JniResult MyMap__entryStack(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_MyMap__entryStack); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } // com.github.dart_lang.jnigen.generics.MyMap$MyEntry @@ -1040,8 +1946,7 @@ JniResult MyMap_MyEntry__ctor(jobject key, jobject value) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_MyMap_MyEntry, _m_MyMap_MyEntry__ctor, key, value); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jfieldID _f_MyMap_MyEntry__key = NULL; @@ -1054,9 +1959,9 @@ JniResult get_MyMap_MyEntry__key(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_MyMap_MyEntry, &_f_MyMap_MyEntry__key, "key", "Ljava/lang/Object;"); - jobject _result = to_global_ref( - (*jniEnv)->GetObjectField(jniEnv, self_, _f_MyMap_MyEntry__key)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->GetObjectField(jniEnv, self_, _f_MyMap_MyEntry__key); + return to_global_ref_result(_result); } FFI_PLUGIN_EXPORT @@ -1082,9 +1987,9 @@ JniResult get_MyMap_MyEntry__value(jobject self_) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_field(_c_MyMap_MyEntry, &_f_MyMap_MyEntry__value, "value", "Ljava/lang/Object;"); - jobject _result = to_global_ref( - (*jniEnv)->GetObjectField(jniEnv, self_, _f_MyMap_MyEntry__value)); - return (JniResult){.value = {.l = _result}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->GetObjectField(jniEnv, self_, _f_MyMap_MyEntry__value); + return to_global_ref_result(_result); } FFI_PLUGIN_EXPORT @@ -1115,8 +2020,7 @@ JniResult MyStack__ctor() { if (_m_MyStack__ctor == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_MyStack, _m_MyStack__ctor); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_MyStack__fromArray = NULL; @@ -1134,8 +2038,7 @@ JniResult MyStack__fromArray(jobject arr) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_MyStack, _m_MyStack__fromArray, arr); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_MyStack__fromArrayOfArrayOfGrandParents = NULL; @@ -1155,8 +2058,7 @@ JniResult MyStack__fromArrayOfArrayOfGrandParents(jobject arr) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_MyStack, _m_MyStack__fromArrayOfArrayOfGrandParents, arr); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_MyStack__of = NULL; @@ -1173,8 +2075,7 @@ JniResult MyStack__of() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_MyStack, _m_MyStack__of); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_MyStack__of1 = NULL; @@ -1192,8 +2093,7 @@ JniResult MyStack__of1(jobject obj) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_MyStack, _m_MyStack__of1, obj); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_MyStack__of2 = NULL; @@ -1211,8 +2111,7 @@ JniResult MyStack__of2(jobject obj, jobject obj2) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_MyStack, _m_MyStack__of2, obj, obj2); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_MyStack__push = NULL; @@ -1242,8 +2141,7 @@ JniResult MyStack__pop(jobject self_) { if (_m_MyStack__pop == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_MyStack__pop); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_MyStack__size = NULL; @@ -1277,8 +2175,7 @@ JniResult StringKeyedMap__ctor() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_StringKeyedMap, _m_StringKeyedMap__ctor); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } // com.github.dart_lang.jnigen.generics.StringMap @@ -1297,8 +2194,7 @@ JniResult StringMap__ctor() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_StringMap, _m_StringMap__ctor); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } // com.github.dart_lang.jnigen.generics.StringStack @@ -1317,8 +2213,7 @@ JniResult StringStack__ctor() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_StringStack, _m_StringStack__ctor); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } // com.github.dart_lang.jnigen.generics.StringValuedMap @@ -1337,8 +2232,7 @@ JniResult StringValuedMap__ctor() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_StringValuedMap, _m_StringValuedMap__ctor); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } // com.github.dart_lang.jnigen.annotations.JsonSerializable$Case @@ -1360,8 +2254,7 @@ JniResult JsonSerializable_Case__values() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_JsonSerializable_Case, _m_JsonSerializable_Case__values); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } jmethodID _m_JsonSerializable_Case__valueOf = NULL; @@ -1382,8 +2275,7 @@ JniResult JsonSerializable_Case__valueOf(jobject name) { jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_JsonSerializable_Case, _m_JsonSerializable_Case__valueOf, name); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } // com.github.dart_lang.jnigen.annotations.MyDataClass @@ -1402,6 +2294,5 @@ JniResult MyDataClass__ctor() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_MyDataClass, _m_MyDataClass__ctor); - return (JniResult){.value = {.l = to_global_ref(_result)}, - .exception = check_exception()}; + return to_global_ref_result(_result); } diff --git a/pkgs/jnigen/test/simple_package_test/lib/simple_package.dart b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart similarity index 62% rename from pkgs/jnigen/test/simple_package_test/lib/simple_package.dart rename to pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart index c5d1083f0..16e99fc67 100644 --- a/pkgs/jnigen/test/simple_package_test/lib/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart @@ -46,200 +46,1051 @@ class Example extends jni.JObject { /// from: static public final int OFF static const OFF = 0; - static final _get_aux = + /// from: static public final double PI + static const PI = 3.14159; + + /// from: static public final char SEMICOLON + static const SEMICOLON = r""";"""; + + /// from: static public final java.lang.String SEMICOLON_STRING + static const SEMICOLON_STRING = r""";"""; + + static final _getAmount = + jniLookup>( + "Example__getAmount") + .asFunction(); + + /// from: static public int getAmount() + static int getAmount() { + return _getAmount().integer; + } + + static final _getPi = + jniLookup>("Example__getPi") + .asFunction(); + + /// from: static public double getPi() + static double getPi() { + return _getPi().doubleFloat; + } + + static final _getAsterisk = + jniLookup>( + "Example__getAsterisk") + .asFunction(); + + /// from: static public char getAsterisk() + static int getAsterisk() { + return _getAsterisk().char; + } + + static final _getName = + jniLookup>( + "Example__getName") + .asFunction(); + + /// from: static public java.lang.String getName() + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JString getName() { + return const jni.JStringType().fromRef(_getName().object); + } + + static final _getNestedInstance = + jniLookup>( + "Example__getNestedInstance") + .asFunction(); + + /// from: static public com.github.dart_lang.jnigen.simple_package.Example.Nested getNestedInstance() + /// The returned object must be deleted after use, by calling the `delete` method. + static Example_Nested getNestedInstance() { + return const $Example_NestedType().fromRef(_getNestedInstance().object); + } + + static final _setAmount = + jniLookup>( + "Example__setAmount") + .asFunction(); + + /// from: static public void setAmount(int newAmount) + static void setAmount( + int newAmount, + ) { + return _setAmount(newAmount).check(); + } + + static final _setName = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("Example__setName") + .asFunction)>(); + + /// from: static public void setName(java.lang.String newName) + static void setName( + jni.JString newName, + ) { + return _setName(newName.reference).check(); + } + + static final _setNestedInstance = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("Example__setNestedInstance") + .asFunction)>(); + + /// from: static public void setNestedInstance(com.github.dart_lang.jnigen.simple_package.Example.Nested newNested) + static void setNestedInstance( + Example_Nested newNested, + ) { + return _setNestedInstance(newNested.reference).check(); + } + + static final _max4 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Int32, ffi.Int32, ffi.Int32, ffi.Int32)>>("Example__max4") + .asFunction(); + + /// from: static public int max4(int a, int b, int c, int d) + static int max4( + int a, + int b, + int c, + int d, + ) { + return _max4(a, b, c, d).integer; + } + + static final _max8 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Int32, ffi.Int32, ffi.Int32, ffi.Int32, + ffi.Int32, ffi.Int32, ffi.Int32, ffi.Int32)>>("Example__max8") + .asFunction< + jni.JniResult Function(int, int, int, int, int, int, int, int)>(); + + /// from: static public int max8(int a, int b, int c, int d, int e, int f, int g, int h) + static int max8( + int a, + int b, + int c, + int d, + int e, + int f, + int g, + int h, + ) { + return _max8(a, b, c, d, e, f, g, h).integer; + } + + static final _getNumber = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("Example__getNumber") + .asFunction)>(); + + /// from: public int getNumber() + int getNumber() { + return _getNumber(reference).integer; + } + + static final _setNumber = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Int32)>>("Example__setNumber") + .asFunction, int)>(); + + /// from: public void setNumber(int number) + void setNumber( + int number, + ) { + return _setNumber(reference, number).check(); + } + + static final _getIsUp = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("Example__getIsUp") + .asFunction)>(); + + /// from: public boolean getIsUp() + bool getIsUp() { + return _getIsUp(reference).boolean; + } + + static final _setUp = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Uint8)>>("Example__setUp") + .asFunction, int)>(); + + /// from: public void setUp(boolean isUp) + void setUp( + bool isUp, + ) { + return _setUp(reference, isUp ? 1 : 0).check(); + } + + static final _getCodename = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("Example__getCodename") + .asFunction)>(); + + /// from: public java.lang.String getCodename() + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JString getCodename() { + return const jni.JStringType().fromRef(_getCodename(reference).object); + } + + static final _setCodename = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("Example__setCodename") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public void setCodename(java.lang.String codename) + void setCodename( + jni.JString codename, + ) { + return _setCodename(reference, codename.reference).check(); + } + + static final _getRandom = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("Example__getRandom") + .asFunction)>(); + + /// from: public java.util.Random getRandom() + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JObject getRandom() { + return const jni.JObjectType().fromRef(_getRandom(reference).object); + } + + static final _setRandom = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("Example__setRandom") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public void setRandom(java.util.Random random) + void setRandom( + jni.JObject random, + ) { + return _setRandom(reference, random.reference).check(); + } + + static final _getRandomLong = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("Example__getRandomLong") + .asFunction)>(); + + /// from: public long getRandomLong() + int getRandomLong() { + return _getRandomLong(reference).long; + } + + static final _add4Longs = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, ffi.Int64, + ffi.Int64, ffi.Int64, ffi.Int64)>>("Example__add4Longs") + .asFunction< + jni.JniResult Function(ffi.Pointer, int, int, int, int)>(); + + /// from: public long add4Longs(long a, long b, long c, long d) + int add4Longs( + int a, + int b, + int c, + int d, + ) { + return _add4Longs(reference, a, b, c, d).long; + } + + static final _add8Longs = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ffi.Int64)>>("Example__add8Longs") + .asFunction< + jni.JniResult Function( + ffi.Pointer, int, int, int, int, int, int, int, int)>(); + + /// from: public long add8Longs(long a, long b, long c, long d, long e, long f, long g, long h) + int add8Longs( + int a, + int b, + int c, + int d, + int e, + int f, + int g, + int h, + ) { + return _add8Longs(reference, a, b, c, d, e, f, g, h).long; + } + + static final _getRandomNumericString = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("Example__getRandomNumericString") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public java.lang.String getRandomNumericString(java.util.Random random) + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JString getRandomNumericString( + jni.JObject random, + ) { + return const jni.JStringType() + .fromRef(_getRandomNumericString(reference, random.reference).object); + } + + static final _ctor = + jniLookup>("Example__ctor") + .asFunction(); + + /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. + factory Example() { + return Example.fromRef(_ctor().object); + } + + static final _ctor1 = + jniLookup>( + "Example__ctor1") + .asFunction(); + + /// from: public void (int number) + /// The returned object must be deleted after use, by calling the `delete` method. + factory Example.ctor1( + int number, + ) { + return Example.fromRef(_ctor1(number).object); + } + + static final _ctor2 = jniLookup< + ffi.NativeFunction>( + "Example__ctor2") + .asFunction(); + + /// from: public void (int number, boolean isUp) + /// The returned object must be deleted after use, by calling the `delete` method. + factory Example.ctor2( + int number, + bool isUp, + ) { + return Example.fromRef(_ctor2(number, isUp ? 1 : 0).object); + } + + static final _ctor3 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Int32, ffi.Uint8, + ffi.Pointer)>>("Example__ctor3") + .asFunction)>(); + + /// from: public void (int number, boolean isUp, java.lang.String codename) + /// The returned object must be deleted after use, by calling the `delete` method. + factory Example.ctor3( + int number, + bool isUp, + jni.JString codename, + ) { + return Example.fromRef( + _ctor3(number, isUp ? 1 : 0, codename.reference).object); + } + + static final _ctor4 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Int32, + ffi.Int32, + ffi.Int32, + ffi.Int32, + ffi.Int32, + ffi.Int32, + ffi.Int32, + ffi.Int32)>>("Example__ctor4") + .asFunction< + jni.JniResult Function(int, int, int, int, int, int, int, int)>(); + + /// from: public void (int a, int b, int c, int d, int e, int f, int g, int h) + /// The returned object must be deleted after use, by calling the `delete` method. + factory Example.ctor4( + int a, + int b, + int c, + int d, + int e, + int f, + int g, + int h, + ) { + return Example.fromRef(_ctor4(a, b, c, d, e, f, g, h).object); + } + + static final _whichExample = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("Example__whichExample") + .asFunction)>(); + + /// from: public int whichExample() + int whichExample() { + return _whichExample(reference).integer; + } + + static final _addInts = jniLookup< + ffi.NativeFunction>( + "Example__addInts") + .asFunction(); + + /// from: static public int addInts(int a, int b) + static int addInts( + int a, + int b, + ) { + return _addInts(a, b).integer; + } + + static final _getArr = + jniLookup>("Example__getArr") + .asFunction(); + + /// from: static public int[] getArr() + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JArray getArr() { + return const jni.JArrayType(jni.JIntType()).fromRef(_getArr().object); + } + + static final _addAll = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>("Example__addAll") + .asFunction)>(); + + /// from: static public int addAll(int[] arr) + static int addAll( + jni.JArray arr, + ) { + return _addAll(arr.reference).integer; + } + + static final _getSelf = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("Example__getSelf") + .asFunction)>(); + + /// from: public com.github.dart_lang.jnigen.simple_package.Example getSelf() + /// The returned object must be deleted after use, by calling the `delete` method. + Example getSelf() { + return const $ExampleType().fromRef(_getSelf(reference).object); + } + + static final _throwException = jniLookup>( - "get_Example__aux") + "Example__throwException") .asFunction(); - static final _set_aux = jniLookup< + /// from: static public void throwException() + static void throwException() { + return _throwException().check(); + } +} + +class $ExampleType extends jni.JObjType { + const $ExampleType(); + + @override + String get signature => + r"Lcom/github/dart_lang/jnigen/simple_package/Example;"; + + @override + Example fromRef(jni.JObjectPtr ref) => Example.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($ExampleType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $ExampleType && other is $ExampleType; + } +} + +/// from: com.github.dart_lang.jnigen.simple_package.Example$Nested +class Example_Nested extends jni.JObject { + @override + late final jni.JObjType $type = type; + + Example_Nested.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = $Example_NestedType(); + static final _ctor = + jniLookup>( + "Example_Nested__ctor") + .asFunction(); + + /// from: public void (boolean value) + /// The returned object must be deleted after use, by calling the `delete` method. + factory Example_Nested( + bool value, + ) { + return Example_Nested.fromRef(_ctor(value ? 1 : 0).object); + } + + static final _getValue = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("Example_Nested__getValue") + .asFunction)>(); + + /// from: public boolean getValue() + bool getValue() { + return _getValue(reference).boolean; + } + + static final _setValue = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Uint8)>>("Example_Nested__setValue") + .asFunction, int)>(); + + /// from: public void setValue(boolean value) + void setValue( + bool value, + ) { + return _setValue(reference, value ? 1 : 0).check(); + } +} + +class $Example_NestedType extends jni.JObjType { + const $Example_NestedType(); + + @override + String get signature => + r"Lcom/github/dart_lang/jnigen/simple_package/Example$Nested;"; + + @override + Example_Nested fromRef(jni.JObjectPtr ref) => Example_Nested.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($Example_NestedType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $Example_NestedType && + other is $Example_NestedType; + } +} + +/// from: com.github.dart_lang.jnigen.simple_package.Exceptions +class Exceptions extends jni.JObject { + @override + late final jni.JObjType $type = type; + + Exceptions.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = $ExceptionsType(); + static final _ctor = jniLookup>( + "Exceptions__ctor") + .asFunction(); + + /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. + factory Exceptions() { + return Exceptions.fromRef(_ctor().object); + } + + static final _ctor1 = + jniLookup>( + "Exceptions__ctor1") + .asFunction(); + + /// from: public void (float x) + /// The returned object must be deleted after use, by calling the `delete` method. + factory Exceptions.ctor1( + double x, + ) { + return Exceptions.fromRef(_ctor1(x).object); + } + + static final _ctor2 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Int32, ffi.Int32, ffi.Int32, ffi.Int32, + ffi.Int32, ffi.Int32)>>("Exceptions__ctor2") + .asFunction(); + + /// from: public void (int a, int b, int c, int d, int e, int f) + /// The returned object must be deleted after use, by calling the `delete` method. + factory Exceptions.ctor2( + int a, + int b, + int c, + int d, + int e, + int f, + ) { + return Exceptions.fromRef(_ctor2(a, b, c, d, e, f).object); + } + + static final _staticObjectMethod = + jniLookup>( + "Exceptions__staticObjectMethod") + .asFunction(); + + /// from: static public java.lang.Object staticObjectMethod() + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JObject staticObjectMethod() { + return const jni.JObjectType().fromRef(_staticObjectMethod().object); + } + + static final _staticIntMethod = + jniLookup>( + "Exceptions__staticIntMethod") + .asFunction(); + + /// from: static public int staticIntMethod() + static int staticIntMethod() { + return _staticIntMethod().integer; + } + + static final _staticObjectArrayMethod = + jniLookup>( + "Exceptions__staticObjectArrayMethod") + .asFunction(); + + /// from: static public java.lang.Object[] staticObjectArrayMethod() + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JArray staticObjectArrayMethod() { + return const jni.JArrayType(jni.JObjectType()) + .fromRef(_staticObjectArrayMethod().object); + } + + static final _staticIntArrayMethod = + jniLookup>( + "Exceptions__staticIntArrayMethod") + .asFunction(); + + /// from: static public int[] staticIntArrayMethod() + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JArray staticIntArrayMethod() { + return const jni.JArrayType(jni.JIntType()) + .fromRef(_staticIntArrayMethod().object); + } + + static final _objectMethod = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("Exceptions__objectMethod") + .asFunction)>(); + + /// from: public java.lang.Object objectMethod() + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JObject objectMethod() { + return const jni.JObjectType().fromRef(_objectMethod(reference).object); + } + + static final _intMethod = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("Exceptions__intMethod") + .asFunction)>(); + + /// from: public int intMethod() + int intMethod() { + return _intMethod(reference).integer; + } + + static final _objectArrayMethod = jniLookup< ffi.NativeFunction< - jni.JThrowablePtr Function( - ffi.Pointer)>>("set_Example__aux") - .asFunction)>(); + jni.JniResult Function( + ffi.Pointer)>>("Exceptions__objectArrayMethod") + .asFunction)>(); - /// from: static public com.github.dart_lang.jnigen.simple_package.Example.Aux aux + /// from: public java.lang.Object[] objectArrayMethod() /// The returned object must be deleted after use, by calling the `delete` method. - static Example_Aux get aux => - const $Example_AuxType().fromRef(_get_aux().object); + jni.JArray objectArrayMethod() { + return const jni.JArrayType(jni.JObjectType()) + .fromRef(_objectArrayMethod(reference).object); + } + + static final _intArrayMethod = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("Exceptions__intArrayMethod") + .asFunction)>(); - /// from: static public com.github.dart_lang.jnigen.simple_package.Example.Aux aux + /// from: public int[] intArrayMethod() /// The returned object must be deleted after use, by calling the `delete` method. - static set aux(Example_Aux value) => _set_aux(value.reference); + jni.JArray intArrayMethod() { + return const jni.JArrayType(jni.JIntType()) + .fromRef(_intArrayMethod(reference).object); + } - static final _get_num = - jniLookup>( - "get_Example__num") - .asFunction(); + static final _throwNullPointerException = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>( + "Exceptions__throwNullPointerException") + .asFunction)>(); - static final _set_num = - jniLookup>( - "set_Example__num") - .asFunction(); + /// from: public int throwNullPointerException() + int throwNullPointerException() { + return _throwNullPointerException(reference).integer; + } - /// from: static public int num - static int get num => _get_num().integer; + static final _throwFileNotFoundException = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>( + "Exceptions__throwFileNotFoundException") + .asFunction)>(); - /// from: static public int num - static set num(int value) => _set_num(value); + /// from: public java.io.InputStream throwFileNotFoundException() + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JObject throwFileNotFoundException() { + return const jni.JObjectType() + .fromRef(_throwFileNotFoundException(reference).object); + } - static final _ctor = - jniLookup>("Example__ctor") - .asFunction(); + static final _throwClassCastException = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>( + "Exceptions__throwClassCastException") + .asFunction)>(); - /// from: public void () + /// from: public java.io.FileInputStream throwClassCastException() /// The returned object must be deleted after use, by calling the `delete` method. - factory Example() { - return Example.fromRef(_ctor().object); + jni.JObject throwClassCastException() { + return const jni.JObjectType() + .fromRef(_throwClassCastException(reference).object); } - static final _ctor1 = - jniLookup>( - "Example__ctor1") - .asFunction(); + static final _throwArrayIndexException = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>( + "Exceptions__throwArrayIndexException") + .asFunction)>(); - /// from: public void (int internal) - /// The returned object must be deleted after use, by calling the `delete` method. - factory Example.ctor1( - int internal, - ) { - return Example.fromRef(_ctor1(internal).object); + /// from: public int throwArrayIndexException() + int throwArrayIndexException() { + return _throwArrayIndexException(reference).integer; } - static final _whichExample = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("Example__whichExample") + static final _throwArithmeticException = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>( + "Exceptions__throwArithmeticException") .asFunction)>(); - /// from: public int whichExample() - int whichExample() { - return _whichExample(reference).integer; + /// from: public int throwArithmeticException() + int throwArithmeticException() { + return _throwArithmeticException(reference).integer; } - static final _getAux = - jniLookup>("Example__getAux") + static final _throwLoremIpsum = + jniLookup>( + "Exceptions__throwLoremIpsum") .asFunction(); - /// from: static public com.github.dart_lang.jnigen.simple_package.Example.Aux getAux() - /// The returned object must be deleted after use, by calling the `delete` method. - static Example_Aux getAux() { - return const $Example_AuxType().fromRef(_getAux().object); + /// from: static public void throwLoremIpsum() + static void throwLoremIpsum() { + return _throwLoremIpsum().check(); } +} - static final _addInts = jniLookup< - ffi.NativeFunction>( - "Example__addInts") - .asFunction(); +class $ExceptionsType extends jni.JObjType { + const $ExceptionsType(); - /// from: static public int addInts(int a, int b) - static int addInts( - int a, - int b, - ) { - return _addInts(a, b).integer; + @override + String get signature => + r"Lcom/github/dart_lang/jnigen/simple_package/Exceptions;"; + + @override + Exceptions fromRef(jni.JObjectPtr ref) => Exceptions.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($ExceptionsType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $ExceptionsType && other is $ExceptionsType; } +} - static final _getArr = - jniLookup>("Example__getArr") +/// from: com.github.dart_lang.jnigen.simple_package.Fields +class Fields extends jni.JObject { + @override + late final jni.JObjType $type = type; + + Fields.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = $FieldsType(); + static final _get_amount = + jniLookup>( + "get_Fields__amount") .asFunction(); - /// from: static public int[] getArr() - /// The returned object must be deleted after use, by calling the `delete` method. - static jni.JArray getArr() { - return const jni.JArrayType(jni.JIntType()).fromRef(_getArr().object); - } + static final _set_amount = + jniLookup>( + "set_Fields__amount") + .asFunction(); - static final _addAll = jniLookup< + /// from: static public int amount + static int get amount => _get_amount().integer; + + /// from: static public int amount + static set amount(int value) => _set_amount(value).check(); + + static final _get_pi = + jniLookup>("get_Fields__pi") + .asFunction(); + + static final _set_pi = + jniLookup>( + "set_Fields__pi") + .asFunction(); + + /// from: static public double pi + static double get pi => _get_pi().doubleFloat; + + /// from: static public double pi + static set pi(double value) => _set_pi(value).check(); + + static final _get_asterisk = + jniLookup>( + "get_Fields__asterisk") + .asFunction(); + + static final _set_asterisk = + jniLookup>( + "set_Fields__asterisk") + .asFunction(); + + /// from: static public char asterisk + static int get asterisk => _get_asterisk().char; + + /// from: static public char asterisk + static set asterisk(int value) => _set_asterisk(value).check(); + + static final _get_name = + jniLookup>( + "get_Fields__name") + .asFunction(); + + static final _set_name = jniLookup< ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>("Example__addAll") + jni.JniResult Function( + ffi.Pointer)>>("set_Fields__name") .asFunction)>(); - /// from: static public int addAll(int[] arr) - static int addAll( - jni.JArray arr, - ) { - return _addAll(arr.reference).integer; - } + /// from: static public java.lang.String name + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JString get name => + const jni.JStringType().fromRef(_get_name().object); - static final _getSelf = jniLookup< + /// from: static public java.lang.String name + /// The returned object must be deleted after use, by calling the `delete` method. + static set name(jni.JString value) => _set_name(value.reference).check(); + + static final _get_i = jniLookup< ffi.NativeFunction< jni.JniResult Function( - ffi.Pointer)>>("Example__getSelf") - .asFunction)>(); + jni.JObjectPtr, + )>>("get_Fields__i") + .asFunction< + jni.JniResult Function( + jni.JObjectPtr, + )>(); - /// from: public com.github.dart_lang.jnigen.simple_package.Example getSelf() + static final _set_i = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + jni.JObjectPtr, ffi.Pointer)>>("set_Fields__i") + .asFunction< + jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); + + /// from: public java.lang.Integer i /// The returned object must be deleted after use, by calling the `delete` method. - Example getSelf() { - return const $ExampleType().fromRef(_getSelf(reference).object); - } + jni.JObject get i => + const jni.JObjectType().fromRef(_get_i(reference).object); + + /// from: public java.lang.Integer i + /// The returned object must be deleted after use, by calling the `delete` method. + set i(jni.JObject value) => _set_i(reference, value.reference).check(); - static final _getNum = jniLookup< + static final _get_trillion = jniLookup< ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>("Example__getNum") - .asFunction)>(); + jni.JniResult Function( + jni.JObjectPtr, + )>>("get_Fields__trillion") + .asFunction< + jni.JniResult Function( + jni.JObjectPtr, + )>(); - /// from: public int getNum() - int getNum() { - return _getNum(reference).integer; - } + static final _set_trillion = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + jni.JObjectPtr, ffi.Int64)>>("set_Fields__trillion") + .asFunction(); + + /// from: public long trillion + int get trillion => _get_trillion(reference).long; + + /// from: public long trillion + set trillion(int value) => _set_trillion(reference, value).check(); - static final _setNum = jniLookup< + static final _get_isAchillesDead = jniLookup< ffi.NativeFunction< jni.JniResult Function( - ffi.Pointer, ffi.Int32)>>("Example__setNum") - .asFunction, int)>(); + jni.JObjectPtr, + )>>("get_Fields__isAchillesDead") + .asFunction< + jni.JniResult Function( + jni.JObjectPtr, + )>(); - /// from: public void setNum(int num) - void setNum( - int num, - ) { - return _setNum(reference, num).check(); - } + static final _set_isAchillesDead = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + jni.JObjectPtr, ffi.Uint8)>>("set_Fields__isAchillesDead") + .asFunction(); + + /// from: public boolean isAchillesDead + bool get isAchillesDead => _get_isAchillesDead(reference).boolean; + + /// from: public boolean isAchillesDead + set isAchillesDead(bool value) => + _set_isAchillesDead(reference, value ? 1 : 0).check(); - static final _getInternal = jniLookup< + static final _get_bestFighterInGreece = jniLookup< ffi.NativeFunction< jni.JniResult Function( - ffi.Pointer)>>("Example__getInternal") - .asFunction)>(); + jni.JObjectPtr, + )>>("get_Fields__bestFighterInGreece") + .asFunction< + jni.JniResult Function( + jni.JObjectPtr, + )>(); - /// from: public int getInternal() - int getInternal() { - return _getInternal(reference).integer; - } + static final _set_bestFighterInGreece = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(jni.JObjectPtr, + ffi.Pointer)>>("set_Fields__bestFighterInGreece") + .asFunction< + jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); + + /// from: public java.lang.String bestFighterInGreece + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JString get bestFighterInGreece => const jni.JStringType() + .fromRef(_get_bestFighterInGreece(reference).object); + + /// from: public java.lang.String bestFighterInGreece + /// The returned object must be deleted after use, by calling the `delete` method. + set bestFighterInGreece(jni.JString value) => + _set_bestFighterInGreece(reference, value.reference).check(); - static final _setInternal = jniLookup< + static final _get_random = jniLookup< ffi.NativeFunction< jni.JniResult Function( - ffi.Pointer, ffi.Int32)>>("Example__setInternal") - .asFunction, int)>(); + jni.JObjectPtr, + )>>("get_Fields__random") + .asFunction< + jni.JniResult Function( + jni.JObjectPtr, + )>(); - /// from: public void setInternal(int internal) - void setInternal( - int internal, - ) { - return _setInternal(reference, internal).check(); - } + static final _set_random = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + jni.JObjectPtr, ffi.Pointer)>>("set_Fields__random") + .asFunction< + jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); - static final _throwException = + /// from: public java.util.Random random + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JObject get random => + const jni.JObjectType().fromRef(_get_random(reference).object); + + /// from: public java.util.Random random + /// The returned object must be deleted after use, by calling the `delete` method. + set random(jni.JObject value) => + _set_random(reference, value.reference).check(); + + static final _get_euroSymbol = jniLookup>( - "Example__throwException") + "get_Fields__euroSymbol") .asFunction(); - /// from: static public void throwException() - static void throwException() { - return _throwException().check(); + static final _set_euroSymbol = + jniLookup>( + "set_Fields__euroSymbol") + .asFunction(); + + /// from: static public char euroSymbol + static int get euroSymbol => _get_euroSymbol().char; + + /// from: static public char euroSymbol + static set euroSymbol(int value) => _set_euroSymbol(value).check(); + + static final _ctor = + jniLookup>("Fields__ctor") + .asFunction(); + + /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. + factory Fields() { + return Fields.fromRef(_ctor().object); } } -class $ExampleType extends jni.JObjType { - const $ExampleType(); +class $FieldsType extends jni.JObjType { + const $FieldsType(); @override String get signature => - r"Lcom/github/dart_lang/jnigen/simple_package/Example;"; + r"Lcom/github/dart_lang/jnigen/simple_package/Fields;"; @override - Example fromRef(jni.JObjectPtr ref) => Example.fromRef(ref); + Fields fromRef(jni.JObjectPtr ref) => Fields.fromRef(ref); @override jni.JObjType get superType => const jni.JObjectType(); @@ -248,94 +1099,88 @@ class $ExampleType extends jni.JObjType { final superCount = 1; @override - int get hashCode => ($ExampleType).hashCode; + int get hashCode => ($FieldsType).hashCode; @override bool operator ==(Object other) { - return other.runtimeType == $ExampleType && other is $ExampleType; + return other.runtimeType == $FieldsType && other is $FieldsType; } } -/// from: com.github.dart_lang.jnigen.simple_package.Example$Aux -class Example_Aux extends jni.JObject { +/// from: com.github.dart_lang.jnigen.simple_package.Fields$Nested +class Fields_Nested extends jni.JObject { @override late final jni.JObjType $type = type; - Example_Aux.fromRef( + Fields_Nested.fromRef( jni.JObjectPtr ref, ) : super.fromRef(ref); /// The type which includes information such as the signature of this class. - static const type = $Example_AuxType(); - static final _get_value = jniLookup< + static const type = $Fields_NestedType(); + static final _get_hundred = jniLookup< ffi.NativeFunction< jni.JniResult Function( jni.JObjectPtr, - )>>("get_Example_Aux__value") + )>>("get_Fields_Nested__hundred") .asFunction< jni.JniResult Function( jni.JObjectPtr, )>(); - static final _set_value = jniLookup< + static final _set_hundred = jniLookup< ffi.NativeFunction< - jni.JThrowablePtr Function( - jni.JObjectPtr, ffi.Uint8)>>("set_Example_Aux__value") - .asFunction(); - - /// from: public boolean value - bool get value => _get_value(reference).boolean; + jni.JniResult Function( + jni.JObjectPtr, ffi.Int64)>>("set_Fields_Nested__hundred") + .asFunction(); - /// from: public boolean value - set value(bool value) => _set_value(reference, value ? 1 : 0); + /// from: public long hundred + int get hundred => _get_hundred(reference).long; - static final _ctor = - jniLookup>( - "Example_Aux__ctor") - .asFunction(); + /// from: public long hundred + set hundred(int value) => _set_hundred(reference, value).check(); - /// from: public void (boolean value) - /// The returned object must be deleted after use, by calling the `delete` method. - factory Example_Aux( - bool value, - ) { - return Example_Aux.fromRef(_ctor(value ? 1 : 0).object); - } + static final _get_BEST_GOD = + jniLookup>( + "get_Fields_Nested__BEST_GOD") + .asFunction(); - static final _getValue = jniLookup< + static final _set_BEST_GOD = jniLookup< ffi.NativeFunction< jni.JniResult Function( - ffi.Pointer)>>("Example_Aux__getValue") + ffi.Pointer)>>("set_Fields_Nested__BEST_GOD") .asFunction)>(); - /// from: public boolean getValue() - bool getValue() { - return _getValue(reference).boolean; - } + /// from: static public java.lang.String BEST_GOD + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JString get BEST_GOD => + const jni.JStringType().fromRef(_get_BEST_GOD().object); - static final _setValue = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer, ffi.Uint8)>>("Example_Aux__setValue") - .asFunction, int)>(); + /// from: static public java.lang.String BEST_GOD + /// The returned object must be deleted after use, by calling the `delete` method. + static set BEST_GOD(jni.JString value) => + _set_BEST_GOD(value.reference).check(); - /// from: public void setValue(boolean value) - void setValue( - bool value, - ) { - return _setValue(reference, value ? 1 : 0).check(); + static final _ctor = jniLookup>( + "Fields_Nested__ctor") + .asFunction(); + + /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. + factory Fields_Nested() { + return Fields_Nested.fromRef(_ctor().object); } } -class $Example_AuxType extends jni.JObjType { - const $Example_AuxType(); +class $Fields_NestedType extends jni.JObjType { + const $Fields_NestedType(); @override String get signature => - r"Lcom/github/dart_lang/jnigen/simple_package/Example$Aux;"; + r"Lcom/github/dart_lang/jnigen/simple_package/Fields$Nested;"; @override - Example_Aux fromRef(jni.JObjectPtr ref) => Example_Aux.fromRef(ref); + Fields_Nested fromRef(jni.JObjectPtr ref) => Fields_Nested.fromRef(ref); @override jni.JObjType get superType => const jni.JObjectType(); @@ -344,11 +1189,12 @@ class $Example_AuxType extends jni.JObjType { final superCount = 1; @override - int get hashCode => ($Example_AuxType).hashCode; + int get hashCode => ($Fields_NestedType).hashCode; @override bool operator ==(Object other) { - return other.runtimeType == $Example_AuxType && other is $Example_AuxType; + return other.runtimeType == $Fields_NestedType && + other is $Fields_NestedType; } } @@ -369,15 +1215,15 @@ class C2 extends jni.JObject { .asFunction(); static final _set_CONSTANT = - jniLookup>( + jniLookup>( "set_C2__CONSTANT") - .asFunction(); + .asFunction(); /// from: static public int CONSTANT static int get CONSTANT => _get_CONSTANT().integer; /// from: static public int CONSTANT - static set CONSTANT(int value) => _set_CONSTANT(value); + static set CONSTANT(int value) => _set_CONSTANT(value).check(); static final _ctor = jniLookup>("C2__ctor") @@ -504,10 +1350,10 @@ class GrandParent<$T extends jni.JObject> extends jni.JObject { static final _set_value = jniLookup< ffi.NativeFunction< - jni.JThrowablePtr Function(jni.JObjectPtr, + jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>>("set_GrandParent__value") .asFunction< - jni.JThrowablePtr Function(jni.JObjectPtr, ffi.Pointer)>(); + jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); /// from: public T value /// The returned object must be deleted after use, by calling the `delete` method. @@ -515,7 +1361,7 @@ class GrandParent<$T extends jni.JObject> extends jni.JObject { /// from: public T value /// The returned object must be deleted after use, by calling the `delete` method. - set value($T value) => _set_value(reference, value.reference); + set value($T value) => _set_value(reference, value.reference).check(); static final _ctor = jniLookup< ffi.NativeFunction< @@ -684,11 +1530,11 @@ class GrandParent_Parent<$T extends jni.JObject, $S extends jni.JObject> static final _set_parentValue = jniLookup< ffi.NativeFunction< - jni.JThrowablePtr Function( + jni.JniResult Function( jni.JObjectPtr, ffi.Pointer)>>( "set_GrandParent_Parent__parentValue") .asFunction< - jni.JThrowablePtr Function(jni.JObjectPtr, ffi.Pointer)>(); + jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); /// from: public T parentValue /// The returned object must be deleted after use, by calling the `delete` method. @@ -696,7 +1542,8 @@ class GrandParent_Parent<$T extends jni.JObject, $S extends jni.JObject> /// from: public T parentValue /// The returned object must be deleted after use, by calling the `delete` method. - set parentValue($T value) => _set_parentValue(reference, value.reference); + set parentValue($T value) => + _set_parentValue(reference, value.reference).check(); static final _get_value = jniLookup< ffi.NativeFunction< @@ -710,10 +1557,10 @@ class GrandParent_Parent<$T extends jni.JObject, $S extends jni.JObject> static final _set_value = jniLookup< ffi.NativeFunction< - jni.JThrowablePtr Function(jni.JObjectPtr, + jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>>("set_GrandParent_Parent__value") .asFunction< - jni.JThrowablePtr Function(jni.JObjectPtr, ffi.Pointer)>(); + jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); /// from: public S value /// The returned object must be deleted after use, by calling the `delete` method. @@ -721,7 +1568,7 @@ class GrandParent_Parent<$T extends jni.JObject, $S extends jni.JObject> /// from: public S value /// The returned object must be deleted after use, by calling the `delete` method. - set value($S value) => _set_value(reference, value.reference); + set value($S value) => _set_value(reference, value.reference).check(); static final _ctor = jniLookup< ffi.NativeFunction< @@ -829,11 +1676,11 @@ class GrandParent_Parent_Child<$T extends jni.JObject, $S extends jni.JObject, static final _set_grandParentValue = jniLookup< ffi.NativeFunction< - jni.JThrowablePtr Function( + jni.JniResult Function( jni.JObjectPtr, ffi.Pointer)>>( "set_GrandParent_Parent_Child__grandParentValue") .asFunction< - jni.JThrowablePtr Function(jni.JObjectPtr, ffi.Pointer)>(); + jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); /// from: public T grandParentValue /// The returned object must be deleted after use, by calling the `delete` method. @@ -842,7 +1689,7 @@ class GrandParent_Parent_Child<$T extends jni.JObject, $S extends jni.JObject, /// from: public T grandParentValue /// The returned object must be deleted after use, by calling the `delete` method. set grandParentValue($T value) => - _set_grandParentValue(reference, value.reference); + _set_grandParentValue(reference, value.reference).check(); static final _get_parentValue = jniLookup< ffi.NativeFunction< @@ -856,11 +1703,11 @@ class GrandParent_Parent_Child<$T extends jni.JObject, $S extends jni.JObject, static final _set_parentValue = jniLookup< ffi.NativeFunction< - jni.JThrowablePtr Function( + jni.JniResult Function( jni.JObjectPtr, ffi.Pointer)>>( "set_GrandParent_Parent_Child__parentValue") .asFunction< - jni.JThrowablePtr Function(jni.JObjectPtr, ffi.Pointer)>(); + jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); /// from: public S parentValue /// The returned object must be deleted after use, by calling the `delete` method. @@ -868,7 +1715,8 @@ class GrandParent_Parent_Child<$T extends jni.JObject, $S extends jni.JObject, /// from: public S parentValue /// The returned object must be deleted after use, by calling the `delete` method. - set parentValue($S value) => _set_parentValue(reference, value.reference); + set parentValue($S value) => + _set_parentValue(reference, value.reference).check(); static final _get_value = jniLookup< ffi.NativeFunction< @@ -882,11 +1730,11 @@ class GrandParent_Parent_Child<$T extends jni.JObject, $S extends jni.JObject, static final _set_value = jniLookup< ffi.NativeFunction< - jni.JThrowablePtr Function( + jni.JniResult Function( jni.JObjectPtr, ffi.Pointer)>>( "set_GrandParent_Parent_Child__value") .asFunction< - jni.JThrowablePtr Function(jni.JObjectPtr, ffi.Pointer)>(); + jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); /// from: public U value /// The returned object must be deleted after use, by calling the `delete` method. @@ -894,7 +1742,7 @@ class GrandParent_Parent_Child<$T extends jni.JObject, $S extends jni.JObject, /// from: public U value /// The returned object must be deleted after use, by calling the `delete` method. - set value($U value) => _set_value(reference, value.reference); + set value($U value) => _set_value(reference, value.reference).check(); static final _ctor = jniLookup< ffi.NativeFunction< @@ -1008,11 +1856,11 @@ class GrandParent_StaticParent<$S extends jni.JObject> extends jni.JObject { static final _set_value = jniLookup< ffi.NativeFunction< - jni.JThrowablePtr Function( + jni.JniResult Function( jni.JObjectPtr, ffi.Pointer)>>( "set_GrandParent_StaticParent__value") .asFunction< - jni.JThrowablePtr Function(jni.JObjectPtr, ffi.Pointer)>(); + jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); /// from: public S value /// The returned object must be deleted after use, by calling the `delete` method. @@ -1020,7 +1868,7 @@ class GrandParent_StaticParent<$S extends jni.JObject> extends jni.JObject { /// from: public S value /// The returned object must be deleted after use, by calling the `delete` method. - set value($S value) => _set_value(reference, value.reference); + set value($S value) => _set_value(reference, value.reference).check(); static final _ctor = jniLookup< ffi.NativeFunction< @@ -1113,11 +1961,11 @@ class GrandParent_StaticParent_Child<$S extends jni.JObject, static final _set_parentValue = jniLookup< ffi.NativeFunction< - jni.JThrowablePtr Function( + jni.JniResult Function( jni.JObjectPtr, ffi.Pointer)>>( "set_GrandParent_StaticParent_Child__parentValue") .asFunction< - jni.JThrowablePtr Function(jni.JObjectPtr, ffi.Pointer)>(); + jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); /// from: public S parentValue /// The returned object must be deleted after use, by calling the `delete` method. @@ -1125,7 +1973,8 @@ class GrandParent_StaticParent_Child<$S extends jni.JObject, /// from: public S parentValue /// The returned object must be deleted after use, by calling the `delete` method. - set parentValue($S value) => _set_parentValue(reference, value.reference); + set parentValue($S value) => + _set_parentValue(reference, value.reference).check(); static final _get_value = jniLookup< ffi.NativeFunction< @@ -1139,11 +1988,11 @@ class GrandParent_StaticParent_Child<$S extends jni.JObject, static final _set_value = jniLookup< ffi.NativeFunction< - jni.JThrowablePtr Function( + jni.JniResult Function( jni.JObjectPtr, ffi.Pointer)>>( "set_GrandParent_StaticParent_Child__value") .asFunction< - jni.JThrowablePtr Function(jni.JObjectPtr, ffi.Pointer)>(); + jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); /// from: public U value /// The returned object must be deleted after use, by calling the `delete` method. @@ -1151,7 +2000,7 @@ class GrandParent_StaticParent_Child<$S extends jni.JObject, /// from: public U value /// The returned object must be deleted after use, by calling the `delete` method. - set value($U value) => _set_value(reference, value.reference); + set value($U value) => _set_value(reference, value.reference).check(); static final _ctor = jniLookup< ffi.NativeFunction< @@ -1379,10 +2228,10 @@ class MyMap_MyEntry<$K extends jni.JObject, $V extends jni.JObject> static final _set_key = jniLookup< ffi.NativeFunction< - jni.JThrowablePtr Function(jni.JObjectPtr, + jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>>("set_MyMap_MyEntry__key") .asFunction< - jni.JThrowablePtr Function(jni.JObjectPtr, ffi.Pointer)>(); + jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); /// from: public K key /// The returned object must be deleted after use, by calling the `delete` method. @@ -1390,7 +2239,7 @@ class MyMap_MyEntry<$K extends jni.JObject, $V extends jni.JObject> /// from: public K key /// The returned object must be deleted after use, by calling the `delete` method. - set key($K value) => _set_key(reference, value.reference); + set key($K value) => _set_key(reference, value.reference).check(); static final _get_value = jniLookup< ffi.NativeFunction< @@ -1404,10 +2253,10 @@ class MyMap_MyEntry<$K extends jni.JObject, $V extends jni.JObject> static final _set_value = jniLookup< ffi.NativeFunction< - jni.JThrowablePtr Function(jni.JObjectPtr, + jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>>("set_MyMap_MyEntry__value") .asFunction< - jni.JThrowablePtr Function(jni.JObjectPtr, ffi.Pointer)>(); + jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); /// from: public V value /// The returned object must be deleted after use, by calling the `delete` method. @@ -1415,7 +2264,7 @@ class MyMap_MyEntry<$K extends jni.JObject, $V extends jni.JObject> /// from: public V value /// The returned object must be deleted after use, by calling the `delete` method. - set value($V value) => _set_value(reference, value.reference); + set value($V value) => _set_value(reference, value.reference).check(); static final _ctor = jniLookup< ffi.NativeFunction< diff --git a/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart new file mode 100644 index 000000000..d1c4bdbad --- /dev/null +++ b/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart @@ -0,0 +1,2680 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +// Autogenerated by jnigen. DO NOT EDIT! + +// ignore_for_file: annotate_overrides +// ignore_for_file: camel_case_extensions +// ignore_for_file: camel_case_types +// ignore_for_file: constant_identifier_names +// ignore_for_file: file_names +// ignore_for_file: no_leading_underscores_for_local_identifiers +// ignore_for_file: non_constant_identifier_names +// ignore_for_file: overridden_fields +// ignore_for_file: unnecessary_cast +// ignore_for_file: unused_element +// ignore_for_file: unused_field +// ignore_for_file: unused_import +// ignore_for_file: unused_shown_name + +import "dart:isolate" show ReceivePort; +import "dart:ffi" as ffi; +import "package:jni/internal_helpers_for_jnigen.dart"; +import "package:jni/jni.dart" as jni; + +// Auto-generated initialization code. + +final jniEnv = jni.Jni.env; +final jniAccessors = jni.Jni.accessors; + +/// from: com.github.dart_lang.jnigen.simple_package.Example +class Example extends jni.JObject { + @override + late final jni.JObjType $type = type; + + Example.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + static final _classRef = jniAccessors + .getClassOf(r"com/github/dart_lang/jnigen/simple_package/Example"); + + /// The type which includes information such as the signature of this class. + static const type = $ExampleType(); + + /// from: static public final int ON + static const ON = 1; + + /// from: static public final int OFF + static const OFF = 0; + + /// from: static public final double PI + static const PI = 3.14159; + + /// from: static public final char SEMICOLON + static const SEMICOLON = r""";"""; + + /// from: static public final java.lang.String SEMICOLON_STRING + static const SEMICOLON_STRING = r""";"""; + + static final _id_getAmount = + jniAccessors.getStaticMethodIDOf(_classRef, r"getAmount", r"()I"); + + /// from: static public int getAmount() + static int getAmount() { + return jniAccessors.callStaticMethodWithArgs( + _classRef, _id_getAmount, jni.JniCallType.intType, []).integer; + } + + static final _id_getPi = + jniAccessors.getStaticMethodIDOf(_classRef, r"getPi", r"()D"); + + /// from: static public double getPi() + static double getPi() { + return jniAccessors.callStaticMethodWithArgs( + _classRef, _id_getPi, jni.JniCallType.doubleType, []).doubleFloat; + } + + static final _id_getAsterisk = + jniAccessors.getStaticMethodIDOf(_classRef, r"getAsterisk", r"()C"); + + /// from: static public char getAsterisk() + static int getAsterisk() { + return jniAccessors.callStaticMethodWithArgs( + _classRef, _id_getAsterisk, jni.JniCallType.charType, []).char; + } + + static final _id_getName = jniAccessors.getStaticMethodIDOf( + _classRef, r"getName", r"()Ljava/lang/String;"); + + /// from: static public java.lang.String getName() + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JString getName() { + return const jni.JStringType().fromRef(jniAccessors + .callStaticMethodWithArgs( + _classRef, _id_getName, jni.JniCallType.objectType, []).object); + } + + static final _id_getNestedInstance = jniAccessors.getStaticMethodIDOf( + _classRef, + r"getNestedInstance", + r"()Lcom/github/dart_lang/jnigen/simple_package/Example$Nested;"); + + /// from: static public com.github.dart_lang.jnigen.simple_package.Example.Nested getNestedInstance() + /// The returned object must be deleted after use, by calling the `delete` method. + static Example_Nested getNestedInstance() { + return const $Example_NestedType().fromRef(jniAccessors + .callStaticMethodWithArgs(_classRef, _id_getNestedInstance, + jni.JniCallType.objectType, []).object); + } + + static final _id_setAmount = + jniAccessors.getStaticMethodIDOf(_classRef, r"setAmount", r"(I)V"); + + /// from: static public void setAmount(int newAmount) + static void setAmount( + int newAmount, + ) { + return jniAccessors.callStaticMethodWithArgs(_classRef, _id_setAmount, + jni.JniCallType.voidType, [jni.JValueInt(newAmount)]).check(); + } + + static final _id_setName = jniAccessors.getStaticMethodIDOf( + _classRef, r"setName", r"(Ljava/lang/String;)V"); + + /// from: static public void setName(java.lang.String newName) + static void setName( + jni.JString newName, + ) { + return jniAccessors.callStaticMethodWithArgs(_classRef, _id_setName, + jni.JniCallType.voidType, [newName.reference]).check(); + } + + static final _id_setNestedInstance = jniAccessors.getStaticMethodIDOf( + _classRef, + r"setNestedInstance", + r"(Lcom/github/dart_lang/jnigen/simple_package/Example$Nested;)V"); + + /// from: static public void setNestedInstance(com.github.dart_lang.jnigen.simple_package.Example.Nested newNested) + static void setNestedInstance( + Example_Nested newNested, + ) { + return jniAccessors.callStaticMethodWithArgs( + _classRef, + _id_setNestedInstance, + jni.JniCallType.voidType, + [newNested.reference]).check(); + } + + static final _id_max4 = + jniAccessors.getStaticMethodIDOf(_classRef, r"max4", r"(IIII)I"); + + /// from: static public int max4(int a, int b, int c, int d) + static int max4( + int a, + int b, + int c, + int d, + ) { + return jniAccessors.callStaticMethodWithArgs( + _classRef, _id_max4, jni.JniCallType.intType, [ + jni.JValueInt(a), + jni.JValueInt(b), + jni.JValueInt(c), + jni.JValueInt(d) + ]).integer; + } + + static final _id_max8 = + jniAccessors.getStaticMethodIDOf(_classRef, r"max8", r"(IIIIIIII)I"); + + /// from: static public int max8(int a, int b, int c, int d, int e, int f, int g, int h) + static int max8( + int a, + int b, + int c, + int d, + int e, + int f, + int g, + int h, + ) { + return jniAccessors.callStaticMethodWithArgs( + _classRef, _id_max8, jni.JniCallType.intType, [ + jni.JValueInt(a), + jni.JValueInt(b), + jni.JValueInt(c), + jni.JValueInt(d), + jni.JValueInt(e), + jni.JValueInt(f), + jni.JValueInt(g), + jni.JValueInt(h) + ]).integer; + } + + static final _id_getNumber = + jniAccessors.getMethodIDOf(_classRef, r"getNumber", r"()I"); + + /// from: public int getNumber() + int getNumber() { + return jniAccessors.callMethodWithArgs( + reference, _id_getNumber, jni.JniCallType.intType, []).integer; + } + + static final _id_setNumber = + jniAccessors.getMethodIDOf(_classRef, r"setNumber", r"(I)V"); + + /// from: public void setNumber(int number) + void setNumber( + int number, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_setNumber, + jni.JniCallType.voidType, [jni.JValueInt(number)]).check(); + } + + static final _id_getIsUp = + jniAccessors.getMethodIDOf(_classRef, r"getIsUp", r"()Z"); + + /// from: public boolean getIsUp() + bool getIsUp() { + return jniAccessors.callMethodWithArgs( + reference, _id_getIsUp, jni.JniCallType.booleanType, []).boolean; + } + + static final _id_setUp = + jniAccessors.getMethodIDOf(_classRef, r"setUp", r"(Z)V"); + + /// from: public void setUp(boolean isUp) + void setUp( + bool isUp, + ) { + return jniAccessors.callMethodWithArgs( + reference, _id_setUp, jni.JniCallType.voidType, [isUp ? 1 : 0]).check(); + } + + static final _id_getCodename = jniAccessors.getMethodIDOf( + _classRef, r"getCodename", r"()Ljava/lang/String;"); + + /// from: public java.lang.String getCodename() + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JString getCodename() { + return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_getCodename, jni.JniCallType.objectType, []).object); + } + + static final _id_setCodename = jniAccessors.getMethodIDOf( + _classRef, r"setCodename", r"(Ljava/lang/String;)V"); + + /// from: public void setCodename(java.lang.String codename) + void setCodename( + jni.JString codename, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_setCodename, + jni.JniCallType.voidType, [codename.reference]).check(); + } + + static final _id_getRandom = jniAccessors.getMethodIDOf( + _classRef, r"getRandom", r"()Ljava/util/Random;"); + + /// from: public java.util.Random getRandom() + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JObject getRandom() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_getRandom, jni.JniCallType.objectType, []).object); + } + + static final _id_setRandom = jniAccessors.getMethodIDOf( + _classRef, r"setRandom", r"(Ljava/util/Random;)V"); + + /// from: public void setRandom(java.util.Random random) + void setRandom( + jni.JObject random, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_setRandom, + jni.JniCallType.voidType, [random.reference]).check(); + } + + static final _id_getRandomLong = + jniAccessors.getMethodIDOf(_classRef, r"getRandomLong", r"()J"); + + /// from: public long getRandomLong() + int getRandomLong() { + return jniAccessors.callMethodWithArgs( + reference, _id_getRandomLong, jni.JniCallType.longType, []).long; + } + + static final _id_add4Longs = + jniAccessors.getMethodIDOf(_classRef, r"add4Longs", r"(JJJJ)J"); + + /// from: public long add4Longs(long a, long b, long c, long d) + int add4Longs( + int a, + int b, + int c, + int d, + ) { + return jniAccessors.callMethodWithArgs( + reference, _id_add4Longs, jni.JniCallType.longType, [a, b, c, d]).long; + } + + static final _id_add8Longs = + jniAccessors.getMethodIDOf(_classRef, r"add8Longs", r"(JJJJJJJJ)J"); + + /// from: public long add8Longs(long a, long b, long c, long d, long e, long f, long g, long h) + int add8Longs( + int a, + int b, + int c, + int d, + int e, + int f, + int g, + int h, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_add8Longs, + jni.JniCallType.longType, [a, b, c, d, e, f, g, h]).long; + } + + static final _id_getRandomNumericString = jniAccessors.getMethodIDOf( + _classRef, + r"getRandomNumericString", + r"(Ljava/util/Random;)Ljava/lang/String;"); + + /// from: public java.lang.String getRandomNumericString(java.util.Random random) + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JString getRandomNumericString( + jni.JObject random, + ) { + return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_getRandomNumericString, + jni.JniCallType.objectType, + [random.reference]).object); + } + + static final _id_ctor = + jniAccessors.getMethodIDOf(_classRef, r"", r"()V"); + + /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. + factory Example() { + return Example.fromRef( + jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); + } + + static final _id_ctor1 = + jniAccessors.getMethodIDOf(_classRef, r"", r"(I)V"); + + /// from: public void (int number) + /// The returned object must be deleted after use, by calling the `delete` method. + factory Example.ctor1( + int number, + ) { + return Example.fromRef(jniAccessors.newObjectWithArgs( + _classRef, _id_ctor1, [jni.JValueInt(number)]).object); + } + + static final _id_ctor2 = + jniAccessors.getMethodIDOf(_classRef, r"", r"(IZ)V"); + + /// from: public void (int number, boolean isUp) + /// The returned object must be deleted after use, by calling the `delete` method. + factory Example.ctor2( + int number, + bool isUp, + ) { + return Example.fromRef(jniAccessors.newObjectWithArgs( + _classRef, _id_ctor2, [jni.JValueInt(number), isUp ? 1 : 0]).object); + } + + static final _id_ctor3 = jniAccessors.getMethodIDOf( + _classRef, r"", r"(IZLjava/lang/String;)V"); + + /// from: public void (int number, boolean isUp, java.lang.String codename) + /// The returned object must be deleted after use, by calling the `delete` method. + factory Example.ctor3( + int number, + bool isUp, + jni.JString codename, + ) { + return Example.fromRef(jniAccessors.newObjectWithArgs(_classRef, _id_ctor3, + [jni.JValueInt(number), isUp ? 1 : 0, codename.reference]).object); + } + + static final _id_ctor4 = + jniAccessors.getMethodIDOf(_classRef, r"", r"(IIIIIIII)V"); + + /// from: public void (int a, int b, int c, int d, int e, int f, int g, int h) + /// The returned object must be deleted after use, by calling the `delete` method. + factory Example.ctor4( + int a, + int b, + int c, + int d, + int e, + int f, + int g, + int h, + ) { + return Example.fromRef( + jniAccessors.newObjectWithArgs(_classRef, _id_ctor4, [ + jni.JValueInt(a), + jni.JValueInt(b), + jni.JValueInt(c), + jni.JValueInt(d), + jni.JValueInt(e), + jni.JValueInt(f), + jni.JValueInt(g), + jni.JValueInt(h) + ]).object); + } + + static final _id_whichExample = + jniAccessors.getMethodIDOf(_classRef, r"whichExample", r"()I"); + + /// from: public int whichExample() + int whichExample() { + return jniAccessors.callMethodWithArgs( + reference, _id_whichExample, jni.JniCallType.intType, []).integer; + } + + static final _id_addInts = + jniAccessors.getStaticMethodIDOf(_classRef, r"addInts", r"(II)I"); + + /// from: static public int addInts(int a, int b) + static int addInts( + int a, + int b, + ) { + return jniAccessors.callStaticMethodWithArgs(_classRef, _id_addInts, + jni.JniCallType.intType, [jni.JValueInt(a), jni.JValueInt(b)]).integer; + } + + static final _id_getArr = + jniAccessors.getStaticMethodIDOf(_classRef, r"getArr", r"()[I"); + + /// from: static public int[] getArr() + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JArray getArr() { + return const jni.JArrayType(jni.JIntType()).fromRef(jniAccessors + .callStaticMethodWithArgs( + _classRef, _id_getArr, jni.JniCallType.objectType, []).object); + } + + static final _id_addAll = + jniAccessors.getStaticMethodIDOf(_classRef, r"addAll", r"([I)I"); + + /// from: static public int addAll(int[] arr) + static int addAll( + jni.JArray arr, + ) { + return jniAccessors.callStaticMethodWithArgs(_classRef, _id_addAll, + jni.JniCallType.intType, [arr.reference]).integer; + } + + static final _id_getSelf = jniAccessors.getMethodIDOf(_classRef, r"getSelf", + r"()Lcom/github/dart_lang/jnigen/simple_package/Example;"); + + /// from: public com.github.dart_lang.jnigen.simple_package.Example getSelf() + /// The returned object must be deleted after use, by calling the `delete` method. + Example getSelf() { + return const $ExampleType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_getSelf, jni.JniCallType.objectType, []).object); + } + + static final _id_throwException = + jniAccessors.getStaticMethodIDOf(_classRef, r"throwException", r"()V"); + + /// from: static public void throwException() + static void throwException() { + return jniAccessors.callStaticMethodWithArgs( + _classRef, _id_throwException, jni.JniCallType.voidType, []).check(); + } +} + +class $ExampleType extends jni.JObjType { + const $ExampleType(); + + @override + String get signature => + r"Lcom/github/dart_lang/jnigen/simple_package/Example;"; + + @override + Example fromRef(jni.JObjectPtr ref) => Example.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($ExampleType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $ExampleType && other is $ExampleType; + } +} + +/// from: com.github.dart_lang.jnigen.simple_package.Example$Nested +class Example_Nested extends jni.JObject { + @override + late final jni.JObjType $type = type; + + Example_Nested.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + static final _classRef = jniAccessors + .getClassOf(r"com/github/dart_lang/jnigen/simple_package/Example$Nested"); + + /// The type which includes information such as the signature of this class. + static const type = $Example_NestedType(); + static final _id_ctor = + jniAccessors.getMethodIDOf(_classRef, r"", r"(Z)V"); + + /// from: public void (boolean value) + /// The returned object must be deleted after use, by calling the `delete` method. + factory Example_Nested( + bool value, + ) { + return Example_Nested.fromRef(jniAccessors + .newObjectWithArgs(_classRef, _id_ctor, [value ? 1 : 0]).object); + } + + static final _id_getValue = + jniAccessors.getMethodIDOf(_classRef, r"getValue", r"()Z"); + + /// from: public boolean getValue() + bool getValue() { + return jniAccessors.callMethodWithArgs( + reference, _id_getValue, jni.JniCallType.booleanType, []).boolean; + } + + static final _id_setValue = + jniAccessors.getMethodIDOf(_classRef, r"setValue", r"(Z)V"); + + /// from: public void setValue(boolean value) + void setValue( + bool value, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_setValue, + jni.JniCallType.voidType, [value ? 1 : 0]).check(); + } +} + +class $Example_NestedType extends jni.JObjType { + const $Example_NestedType(); + + @override + String get signature => + r"Lcom/github/dart_lang/jnigen/simple_package/Example$Nested;"; + + @override + Example_Nested fromRef(jni.JObjectPtr ref) => Example_Nested.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($Example_NestedType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $Example_NestedType && + other is $Example_NestedType; + } +} + +/// from: com.github.dart_lang.jnigen.simple_package.Exceptions +class Exceptions extends jni.JObject { + @override + late final jni.JObjType $type = type; + + Exceptions.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + static final _classRef = jniAccessors + .getClassOf(r"com/github/dart_lang/jnigen/simple_package/Exceptions"); + + /// The type which includes information such as the signature of this class. + static const type = $ExceptionsType(); + static final _id_ctor = + jniAccessors.getMethodIDOf(_classRef, r"", r"()V"); + + /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. + factory Exceptions() { + return Exceptions.fromRef( + jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); + } + + static final _id_ctor1 = + jniAccessors.getMethodIDOf(_classRef, r"", r"(F)V"); + + /// from: public void (float x) + /// The returned object must be deleted after use, by calling the `delete` method. + factory Exceptions.ctor1( + double x, + ) { + return Exceptions.fromRef(jniAccessors + .newObjectWithArgs(_classRef, _id_ctor1, [jni.JValueFloat(x)]).object); + } + + static final _id_ctor2 = + jniAccessors.getMethodIDOf(_classRef, r"", r"(IIIIII)V"); + + /// from: public void (int a, int b, int c, int d, int e, int f) + /// The returned object must be deleted after use, by calling the `delete` method. + factory Exceptions.ctor2( + int a, + int b, + int c, + int d, + int e, + int f, + ) { + return Exceptions.fromRef( + jniAccessors.newObjectWithArgs(_classRef, _id_ctor2, [ + jni.JValueInt(a), + jni.JValueInt(b), + jni.JValueInt(c), + jni.JValueInt(d), + jni.JValueInt(e), + jni.JValueInt(f) + ]).object); + } + + static final _id_staticObjectMethod = jniAccessors.getStaticMethodIDOf( + _classRef, r"staticObjectMethod", r"()Ljava/lang/Object;"); + + /// from: static public java.lang.Object staticObjectMethod() + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JObject staticObjectMethod() { + return const jni.JObjectType().fromRef(jniAccessors + .callStaticMethodWithArgs(_classRef, _id_staticObjectMethod, + jni.JniCallType.objectType, []).object); + } + + static final _id_staticIntMethod = + jniAccessors.getStaticMethodIDOf(_classRef, r"staticIntMethod", r"()I"); + + /// from: static public int staticIntMethod() + static int staticIntMethod() { + return jniAccessors.callStaticMethodWithArgs( + _classRef, _id_staticIntMethod, jni.JniCallType.intType, []).integer; + } + + static final _id_staticObjectArrayMethod = jniAccessors.getStaticMethodIDOf( + _classRef, r"staticObjectArrayMethod", r"()[Ljava/lang/Object;"); + + /// from: static public java.lang.Object[] staticObjectArrayMethod() + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JArray staticObjectArrayMethod() { + return const jni.JArrayType(jni.JObjectType()).fromRef(jniAccessors + .callStaticMethodWithArgs(_classRef, _id_staticObjectArrayMethod, + jni.JniCallType.objectType, []).object); + } + + static final _id_staticIntArrayMethod = jniAccessors.getStaticMethodIDOf( + _classRef, r"staticIntArrayMethod", r"()[I"); + + /// from: static public int[] staticIntArrayMethod() + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JArray staticIntArrayMethod() { + return const jni.JArrayType(jni.JIntType()).fromRef(jniAccessors + .callStaticMethodWithArgs(_classRef, _id_staticIntArrayMethod, + jni.JniCallType.objectType, []).object); + } + + static final _id_objectMethod = jniAccessors.getMethodIDOf( + _classRef, r"objectMethod", r"()Ljava/lang/Object;"); + + /// from: public java.lang.Object objectMethod() + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JObject objectMethod() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, _id_objectMethod, jni.JniCallType.objectType, []).object); + } + + static final _id_intMethod = + jniAccessors.getMethodIDOf(_classRef, r"intMethod", r"()I"); + + /// from: public int intMethod() + int intMethod() { + return jniAccessors.callMethodWithArgs( + reference, _id_intMethod, jni.JniCallType.intType, []).integer; + } + + static final _id_objectArrayMethod = jniAccessors.getMethodIDOf( + _classRef, r"objectArrayMethod", r"()[Ljava/lang/Object;"); + + /// from: public java.lang.Object[] objectArrayMethod() + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JArray objectArrayMethod() { + return const jni.JArrayType(jni.JObjectType()).fromRef(jniAccessors + .callMethodWithArgs(reference, _id_objectArrayMethod, + jni.JniCallType.objectType, []).object); + } + + static final _id_intArrayMethod = + jniAccessors.getMethodIDOf(_classRef, r"intArrayMethod", r"()[I"); + + /// from: public int[] intArrayMethod() + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JArray intArrayMethod() { + return const jni.JArrayType(jni.JIntType()).fromRef(jniAccessors + .callMethodWithArgs(reference, _id_intArrayMethod, + jni.JniCallType.objectType, []).object); + } + + static final _id_throwNullPointerException = jniAccessors.getMethodIDOf( + _classRef, r"throwNullPointerException", r"()I"); + + /// from: public int throwNullPointerException() + int throwNullPointerException() { + return jniAccessors.callMethodWithArgs(reference, + _id_throwNullPointerException, jni.JniCallType.intType, []).integer; + } + + static final _id_throwFileNotFoundException = jniAccessors.getMethodIDOf( + _classRef, r"throwFileNotFoundException", r"()Ljava/io/InputStream;"); + + /// from: public java.io.InputStream throwFileNotFoundException() + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JObject throwFileNotFoundException() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_throwFileNotFoundException, + jni.JniCallType.objectType, []).object); + } + + static final _id_throwClassCastException = jniAccessors.getMethodIDOf( + _classRef, r"throwClassCastException", r"()Ljava/io/FileInputStream;"); + + /// from: public java.io.FileInputStream throwClassCastException() + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JObject throwClassCastException() { + return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + reference, + _id_throwClassCastException, + jni.JniCallType.objectType, []).object); + } + + static final _id_throwArrayIndexException = jniAccessors.getMethodIDOf( + _classRef, r"throwArrayIndexException", r"()I"); + + /// from: public int throwArrayIndexException() + int throwArrayIndexException() { + return jniAccessors.callMethodWithArgs(reference, + _id_throwArrayIndexException, jni.JniCallType.intType, []).integer; + } + + static final _id_throwArithmeticException = jniAccessors.getMethodIDOf( + _classRef, r"throwArithmeticException", r"()I"); + + /// from: public int throwArithmeticException() + int throwArithmeticException() { + return jniAccessors.callMethodWithArgs(reference, + _id_throwArithmeticException, jni.JniCallType.intType, []).integer; + } + + static final _id_throwLoremIpsum = + jniAccessors.getStaticMethodIDOf(_classRef, r"throwLoremIpsum", r"()V"); + + /// from: static public void throwLoremIpsum() + static void throwLoremIpsum() { + return jniAccessors.callStaticMethodWithArgs( + _classRef, _id_throwLoremIpsum, jni.JniCallType.voidType, []).check(); + } +} + +class $ExceptionsType extends jni.JObjType { + const $ExceptionsType(); + + @override + String get signature => + r"Lcom/github/dart_lang/jnigen/simple_package/Exceptions;"; + + @override + Exceptions fromRef(jni.JObjectPtr ref) => Exceptions.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($ExceptionsType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $ExceptionsType && other is $ExceptionsType; + } +} + +/// from: com.github.dart_lang.jnigen.simple_package.Fields +class Fields extends jni.JObject { + @override + late final jni.JObjType $type = type; + + Fields.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + static final _classRef = jniAccessors + .getClassOf(r"com/github/dart_lang/jnigen/simple_package/Fields"); + + /// The type which includes information such as the signature of this class. + static const type = $FieldsType(); + static final _id_amount = jniAccessors.getStaticFieldIDOf( + _classRef, + r"amount", + r"I", + ); + + /// from: static public int amount + static int get amount => jniAccessors + .getStaticField(_classRef, _id_amount, jni.JniCallType.intType) + .integer; + + /// from: static public int amount + static set amount(int value) => + jniEnv.SetStaticIntField(_classRef, _id_amount, value); + + static final _id_pi = jniAccessors.getStaticFieldIDOf( + _classRef, + r"pi", + r"D", + ); + + /// from: static public double pi + static double get pi => jniAccessors + .getStaticField(_classRef, _id_pi, jni.JniCallType.doubleType) + .doubleFloat; + + /// from: static public double pi + static set pi(double value) => + jniEnv.SetStaticDoubleField(_classRef, _id_pi, value); + + static final _id_asterisk = jniAccessors.getStaticFieldIDOf( + _classRef, + r"asterisk", + r"C", + ); + + /// from: static public char asterisk + static int get asterisk => jniAccessors + .getStaticField(_classRef, _id_asterisk, jni.JniCallType.charType) + .char; + + /// from: static public char asterisk + static set asterisk(int value) => + jniEnv.SetStaticCharField(_classRef, _id_asterisk, value); + + static final _id_name = jniAccessors.getStaticFieldIDOf( + _classRef, + r"name", + r"Ljava/lang/String;", + ); + + /// from: static public java.lang.String name + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JString get name => const jni.JStringType().fromRef(jniAccessors + .getStaticField(_classRef, _id_name, jni.JniCallType.objectType) + .object); + + /// from: static public java.lang.String name + /// The returned object must be deleted after use, by calling the `delete` method. + static set name(jni.JString value) => + jniEnv.SetStaticObjectField(_classRef, _id_name, value.reference); + + static final _id_i = jniAccessors.getFieldIDOf( + _classRef, + r"i", + r"Ljava/lang/Integer;", + ); + + /// from: public java.lang.Integer i + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JObject get i => const jni.JObjectType().fromRef(jniAccessors + .getField(reference, _id_i, jni.JniCallType.objectType) + .object); + + /// from: public java.lang.Integer i + /// The returned object must be deleted after use, by calling the `delete` method. + set i(jni.JObject value) => + jniEnv.SetObjectField(reference, _id_i, value.reference); + + static final _id_trillion = jniAccessors.getFieldIDOf( + _classRef, + r"trillion", + r"J", + ); + + /// from: public long trillion + int get trillion => jniAccessors + .getField(reference, _id_trillion, jni.JniCallType.longType) + .long; + + /// from: public long trillion + set trillion(int value) => + jniEnv.SetLongField(reference, _id_trillion, value); + + static final _id_isAchillesDead = jniAccessors.getFieldIDOf( + _classRef, + r"isAchillesDead", + r"Z", + ); + + /// from: public boolean isAchillesDead + bool get isAchillesDead => jniAccessors + .getField(reference, _id_isAchillesDead, jni.JniCallType.booleanType) + .boolean; + + /// from: public boolean isAchillesDead + set isAchillesDead(bool value) => + jniEnv.SetBooleanField(reference, _id_isAchillesDead, value ? 1 : 0); + + static final _id_bestFighterInGreece = jniAccessors.getFieldIDOf( + _classRef, + r"bestFighterInGreece", + r"Ljava/lang/String;", + ); + + /// from: public java.lang.String bestFighterInGreece + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JString get bestFighterInGreece => + const jni.JStringType().fromRef(jniAccessors + .getField( + reference, _id_bestFighterInGreece, jni.JniCallType.objectType) + .object); + + /// from: public java.lang.String bestFighterInGreece + /// The returned object must be deleted after use, by calling the `delete` method. + set bestFighterInGreece(jni.JString value) => jniEnv.SetObjectField( + reference, _id_bestFighterInGreece, value.reference); + + static final _id_random = jniAccessors.getFieldIDOf( + _classRef, + r"random", + r"Ljava/util/Random;", + ); + + /// from: public java.util.Random random + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JObject get random => const jni.JObjectType().fromRef(jniAccessors + .getField(reference, _id_random, jni.JniCallType.objectType) + .object); + + /// from: public java.util.Random random + /// The returned object must be deleted after use, by calling the `delete` method. + set random(jni.JObject value) => + jniEnv.SetObjectField(reference, _id_random, value.reference); + + static final _id_euroSymbol = jniAccessors.getStaticFieldIDOf( + _classRef, + r"euroSymbol", + r"C", + ); + + /// from: static public char euroSymbol + static int get euroSymbol => jniAccessors + .getStaticField(_classRef, _id_euroSymbol, jni.JniCallType.charType) + .char; + + /// from: static public char euroSymbol + static set euroSymbol(int value) => + jniEnv.SetStaticCharField(_classRef, _id_euroSymbol, value); + + static final _id_ctor = + jniAccessors.getMethodIDOf(_classRef, r"", r"()V"); + + /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. + factory Fields() { + return Fields.fromRef( + jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); + } +} + +class $FieldsType extends jni.JObjType { + const $FieldsType(); + + @override + String get signature => + r"Lcom/github/dart_lang/jnigen/simple_package/Fields;"; + + @override + Fields fromRef(jni.JObjectPtr ref) => Fields.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($FieldsType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $FieldsType && other is $FieldsType; + } +} + +/// from: com.github.dart_lang.jnigen.simple_package.Fields$Nested +class Fields_Nested extends jni.JObject { + @override + late final jni.JObjType $type = type; + + Fields_Nested.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + static final _classRef = jniAccessors + .getClassOf(r"com/github/dart_lang/jnigen/simple_package/Fields$Nested"); + + /// The type which includes information such as the signature of this class. + static const type = $Fields_NestedType(); + static final _id_hundred = jniAccessors.getFieldIDOf( + _classRef, + r"hundred", + r"J", + ); + + /// from: public long hundred + int get hundred => jniAccessors + .getField(reference, _id_hundred, jni.JniCallType.longType) + .long; + + /// from: public long hundred + set hundred(int value) => jniEnv.SetLongField(reference, _id_hundred, value); + + static final _id_BEST_GOD = jniAccessors.getStaticFieldIDOf( + _classRef, + r"BEST_GOD", + r"Ljava/lang/String;", + ); + + /// from: static public java.lang.String BEST_GOD + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JString get BEST_GOD => + const jni.JStringType().fromRef(jniAccessors + .getStaticField(_classRef, _id_BEST_GOD, jni.JniCallType.objectType) + .object); + + /// from: static public java.lang.String BEST_GOD + /// The returned object must be deleted after use, by calling the `delete` method. + static set BEST_GOD(jni.JString value) => + jniEnv.SetStaticObjectField(_classRef, _id_BEST_GOD, value.reference); + + static final _id_ctor = + jniAccessors.getMethodIDOf(_classRef, r"", r"()V"); + + /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. + factory Fields_Nested() { + return Fields_Nested.fromRef( + jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); + } +} + +class $Fields_NestedType extends jni.JObjType { + const $Fields_NestedType(); + + @override + String get signature => + r"Lcom/github/dart_lang/jnigen/simple_package/Fields$Nested;"; + + @override + Fields_Nested fromRef(jni.JObjectPtr ref) => Fields_Nested.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($Fields_NestedType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $Fields_NestedType && + other is $Fields_NestedType; + } +} + +/// from: com.github.dart_lang.jnigen.pkg2.C2 +class C2 extends jni.JObject { + @override + late final jni.JObjType $type = type; + + C2.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + static final _classRef = + jniAccessors.getClassOf(r"com/github/dart_lang/jnigen/pkg2/C2"); + + /// The type which includes information such as the signature of this class. + static const type = $C2Type(); + static final _id_CONSTANT = jniAccessors.getStaticFieldIDOf( + _classRef, + r"CONSTANT", + r"I", + ); + + /// from: static public int CONSTANT + static int get CONSTANT => jniAccessors + .getStaticField(_classRef, _id_CONSTANT, jni.JniCallType.intType) + .integer; + + /// from: static public int CONSTANT + static set CONSTANT(int value) => + jniEnv.SetStaticIntField(_classRef, _id_CONSTANT, value); + + static final _id_ctor = + jniAccessors.getMethodIDOf(_classRef, r"", r"()V"); + + /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. + factory C2() { + return C2.fromRef( + jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); + } +} + +class $C2Type extends jni.JObjType { + const $C2Type(); + + @override + String get signature => r"Lcom/github/dart_lang/jnigen/pkg2/C2;"; + + @override + C2 fromRef(jni.JObjectPtr ref) => C2.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($C2Type).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $C2Type && other is $C2Type; + } +} + +/// from: com.github.dart_lang.jnigen.pkg2.Example +class Example1 extends jni.JObject { + @override + late final jni.JObjType $type = type; + + Example1.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + static final _classRef = + jniAccessors.getClassOf(r"com/github/dart_lang/jnigen/pkg2/Example"); + + /// The type which includes information such as the signature of this class. + static const type = $Example1Type(); + static final _id_ctor = + jniAccessors.getMethodIDOf(_classRef, r"", r"()V"); + + /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. + factory Example1() { + return Example1.fromRef( + jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); + } + + static final _id_whichExample = + jniAccessors.getMethodIDOf(_classRef, r"whichExample", r"()I"); + + /// from: public int whichExample() + int whichExample() { + return jniAccessors.callMethodWithArgs( + reference, _id_whichExample, jni.JniCallType.intType, []).integer; + } +} + +class $Example1Type extends jni.JObjType { + const $Example1Type(); + + @override + String get signature => r"Lcom/github/dart_lang/jnigen/pkg2/Example;"; + + @override + Example1 fromRef(jni.JObjectPtr ref) => Example1.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($Example1Type).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $Example1Type && other is $Example1Type; + } +} + +/// from: com.github.dart_lang.jnigen.generics.GrandParent +class GrandParent<$T extends jni.JObject> extends jni.JObject { + @override + late final jni.JObjType $type = type(T); + + final jni.JObjType<$T> T; + + GrandParent.fromRef( + this.T, + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + static final _classRef = jniAccessors + .getClassOf(r"com/github/dart_lang/jnigen/generics/GrandParent"); + + /// The type which includes information such as the signature of this class. + static $GrandParentType<$T> type<$T extends jni.JObject>( + jni.JObjType<$T> T, + ) { + return $GrandParentType( + T, + ); + } + + static final _id_value = jniAccessors.getFieldIDOf( + _classRef, + r"value", + r"Ljava/lang/Object;", + ); + + /// from: public T value + /// The returned object must be deleted after use, by calling the `delete` method. + $T get value => T.fromRef(jniAccessors + .getField(reference, _id_value, jni.JniCallType.objectType) + .object); + + /// from: public T value + /// The returned object must be deleted after use, by calling the `delete` method. + set value($T value) => + jniEnv.SetObjectField(reference, _id_value, value.reference); + + static final _id_ctor = jniAccessors.getMethodIDOf( + _classRef, r"", r"(Ljava/lang/Object;)V"); + + /// from: public void (T value) + /// The returned object must be deleted after use, by calling the `delete` method. + factory GrandParent( + $T value, { + jni.JObjType<$T>? T, + }) { + T ??= jni.lowestCommonSuperType([ + value.$type, + ]) as jni.JObjType<$T>; + return GrandParent.fromRef( + T, + jniAccessors + .newObjectWithArgs(_classRef, _id_ctor, [value.reference]).object); + } + + static final _id_stringParent = jniAccessors.getMethodIDOf( + _classRef, + r"stringParent", + r"()Lcom/github/dart_lang/jnigen/generics/GrandParent$Parent;"); + + /// from: public com.github.dart_lang.jnigen.generics.GrandParent.Parent stringParent() + /// The returned object must be deleted after use, by calling the `delete` method. + GrandParent_Parent stringParent() { + return const $GrandParent_ParentType(jni.JObjectType(), jni.JStringType()) + .fromRef(jniAccessors.callMethodWithArgs(reference, _id_stringParent, + jni.JniCallType.objectType, []).object); + } + + static final _id_varParent = jniAccessors.getMethodIDOf( + _classRef, + r"varParent", + r"(Ljava/lang/Object;)Lcom/github/dart_lang/jnigen/generics/GrandParent$Parent;"); + + /// from: public com.github.dart_lang.jnigen.generics.GrandParent.Parent varParent(S nestedValue) + /// The returned object must be deleted after use, by calling the `delete` method. + GrandParent_Parent varParent<$S extends jni.JObject>( + $S nestedValue, { + jni.JObjType<$S>? S, + }) { + S ??= jni.lowestCommonSuperType([ + nestedValue.$type, + ]) as jni.JObjType<$S>; + return $GrandParent_ParentType(const jni.JObjectType(), S).fromRef( + jniAccessors.callMethodWithArgs(reference, _id_varParent, + jni.JniCallType.objectType, [nestedValue.reference]).object); + } + + static final _id_stringStaticParent = jniAccessors.getStaticMethodIDOf( + _classRef, + r"stringStaticParent", + r"()Lcom/github/dart_lang/jnigen/generics/GrandParent$StaticParent;"); + + /// from: static public com.github.dart_lang.jnigen.generics.GrandParent.StaticParent stringStaticParent() + /// The returned object must be deleted after use, by calling the `delete` method. + static GrandParent_StaticParent stringStaticParent() { + return const $GrandParent_StaticParentType(jni.JStringType()).fromRef( + jniAccessors.callStaticMethodWithArgs(_classRef, _id_stringStaticParent, + jni.JniCallType.objectType, []).object); + } + + static final _id_varStaticParent = jniAccessors.getStaticMethodIDOf( + _classRef, + r"varStaticParent", + r"(Ljava/lang/Object;)Lcom/github/dart_lang/jnigen/generics/GrandParent$StaticParent;"); + + /// from: static public com.github.dart_lang.jnigen.generics.GrandParent.StaticParent varStaticParent(S value) + /// The returned object must be deleted after use, by calling the `delete` method. + static GrandParent_StaticParent<$S> varStaticParent<$S extends jni.JObject>( + $S value, { + jni.JObjType<$S>? S, + }) { + S ??= jni.lowestCommonSuperType([ + value.$type, + ]) as jni.JObjType<$S>; + return $GrandParent_StaticParentType(S).fromRef(jniAccessors + .callStaticMethodWithArgs(_classRef, _id_varStaticParent, + jni.JniCallType.objectType, [value.reference]).object); + } + + static final _id_staticParentWithSameType = jniAccessors.getMethodIDOf( + _classRef, + r"staticParentWithSameType", + r"()Lcom/github/dart_lang/jnigen/generics/GrandParent$StaticParent;"); + + /// from: public com.github.dart_lang.jnigen.generics.GrandParent.StaticParent staticParentWithSameType() + /// The returned object must be deleted after use, by calling the `delete` method. + GrandParent_StaticParent<$T> staticParentWithSameType() { + return $GrandParent_StaticParentType(T).fromRef(jniAccessors + .callMethodWithArgs(reference, _id_staticParentWithSameType, + jni.JniCallType.objectType, []).object); + } +} + +class $GrandParentType<$T extends jni.JObject> + extends jni.JObjType> { + final jni.JObjType<$T> T; + + const $GrandParentType( + this.T, + ); + + @override + String get signature => r"Lcom/github/dart_lang/jnigen/generics/GrandParent;"; + + @override + GrandParent<$T> fromRef(jni.JObjectPtr ref) => GrandParent.fromRef(T, ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => Object.hash($GrandParentType, T); + + @override + bool operator ==(Object other) { + return other.runtimeType == $GrandParentType && + other is $GrandParentType && + T == other.T; + } +} + +/// from: com.github.dart_lang.jnigen.generics.GrandParent$Parent +class GrandParent_Parent<$T extends jni.JObject, $S extends jni.JObject> + extends jni.JObject { + @override + late final jni.JObjType $type = type(T, S); + + final jni.JObjType<$T> T; + final jni.JObjType<$S> S; + + GrandParent_Parent.fromRef( + this.T, + this.S, + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + static final _classRef = jniAccessors + .getClassOf(r"com/github/dart_lang/jnigen/generics/GrandParent$Parent"); + + /// The type which includes information such as the signature of this class. + static $GrandParent_ParentType<$T, $S> + type<$T extends jni.JObject, $S extends jni.JObject>( + jni.JObjType<$T> T, + jni.JObjType<$S> S, + ) { + return $GrandParent_ParentType( + T, + S, + ); + } + + static final _id_parentValue = jniAccessors.getFieldIDOf( + _classRef, + r"parentValue", + r"Ljava/lang/Object;", + ); + + /// from: public T parentValue + /// The returned object must be deleted after use, by calling the `delete` method. + $T get parentValue => T.fromRef(jniAccessors + .getField(reference, _id_parentValue, jni.JniCallType.objectType) + .object); + + /// from: public T parentValue + /// The returned object must be deleted after use, by calling the `delete` method. + set parentValue($T value) => + jniEnv.SetObjectField(reference, _id_parentValue, value.reference); + + static final _id_value = jniAccessors.getFieldIDOf( + _classRef, + r"value", + r"Ljava/lang/Object;", + ); + + /// from: public S value + /// The returned object must be deleted after use, by calling the `delete` method. + $S get value => S.fromRef(jniAccessors + .getField(reference, _id_value, jni.JniCallType.objectType) + .object); + + /// from: public S value + /// The returned object must be deleted after use, by calling the `delete` method. + set value($S value) => + jniEnv.SetObjectField(reference, _id_value, value.reference); + + static final _id_ctor = jniAccessors.getMethodIDOf( + _classRef, r"", r"(Ljava/lang/Object;Ljava/lang/Object;)V"); + + /// from: public void (T parentValue, S value) + /// The returned object must be deleted after use, by calling the `delete` method. + factory GrandParent_Parent( + $T parentValue, + $S value, { + jni.JObjType<$T>? T, + jni.JObjType<$S>? S, + }) { + T ??= jni.lowestCommonSuperType([ + parentValue.$type, + ]) as jni.JObjType<$T>; + S ??= jni.lowestCommonSuperType([ + value.$type, + ]) as jni.JObjType<$S>; + return GrandParent_Parent.fromRef( + T, + S, + jniAccessors.newObjectWithArgs(_classRef, _id_ctor, + [parentValue.reference, value.reference]).object); + } +} + +class $GrandParent_ParentType<$T extends jni.JObject, $S extends jni.JObject> + extends jni.JObjType> { + final jni.JObjType<$T> T; + final jni.JObjType<$S> S; + + const $GrandParent_ParentType( + this.T, + this.S, + ); + + @override + String get signature => + r"Lcom/github/dart_lang/jnigen/generics/GrandParent$Parent;"; + + @override + GrandParent_Parent<$T, $S> fromRef(jni.JObjectPtr ref) => + GrandParent_Parent.fromRef(T, S, ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => Object.hash($GrandParent_ParentType, T, S); + + @override + bool operator ==(Object other) { + return other.runtimeType == $GrandParent_ParentType && + other is $GrandParent_ParentType && + T == other.T && + S == other.S; + } +} + +/// from: com.github.dart_lang.jnigen.generics.GrandParent$Parent$Child +class GrandParent_Parent_Child<$T extends jni.JObject, $S extends jni.JObject, + $U extends jni.JObject> extends jni.JObject { + @override + late final jni.JObjType $type = type(T, S, U); + + final jni.JObjType<$T> T; + final jni.JObjType<$S> S; + final jni.JObjType<$U> U; + + GrandParent_Parent_Child.fromRef( + this.T, + this.S, + this.U, + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + static final _classRef = jniAccessors.getClassOf( + r"com/github/dart_lang/jnigen/generics/GrandParent$Parent$Child"); + + /// The type which includes information such as the signature of this class. + static $GrandParent_Parent_ChildType<$T, $S, $U> type<$T extends jni.JObject, + $S extends jni.JObject, $U extends jni.JObject>( + jni.JObjType<$T> T, + jni.JObjType<$S> S, + jni.JObjType<$U> U, + ) { + return $GrandParent_Parent_ChildType( + T, + S, + U, + ); + } + + static final _id_grandParentValue = jniAccessors.getFieldIDOf( + _classRef, + r"grandParentValue", + r"Ljava/lang/Object;", + ); + + /// from: public T grandParentValue + /// The returned object must be deleted after use, by calling the `delete` method. + $T get grandParentValue => T.fromRef(jniAccessors + .getField(reference, _id_grandParentValue, jni.JniCallType.objectType) + .object); + + /// from: public T grandParentValue + /// The returned object must be deleted after use, by calling the `delete` method. + set grandParentValue($T value) => + jniEnv.SetObjectField(reference, _id_grandParentValue, value.reference); + + static final _id_parentValue = jniAccessors.getFieldIDOf( + _classRef, + r"parentValue", + r"Ljava/lang/Object;", + ); + + /// from: public S parentValue + /// The returned object must be deleted after use, by calling the `delete` method. + $S get parentValue => S.fromRef(jniAccessors + .getField(reference, _id_parentValue, jni.JniCallType.objectType) + .object); + + /// from: public S parentValue + /// The returned object must be deleted after use, by calling the `delete` method. + set parentValue($S value) => + jniEnv.SetObjectField(reference, _id_parentValue, value.reference); + + static final _id_value = jniAccessors.getFieldIDOf( + _classRef, + r"value", + r"Ljava/lang/Object;", + ); + + /// from: public U value + /// The returned object must be deleted after use, by calling the `delete` method. + $U get value => U.fromRef(jniAccessors + .getField(reference, _id_value, jni.JniCallType.objectType) + .object); + + /// from: public U value + /// The returned object must be deleted after use, by calling the `delete` method. + set value($U value) => + jniEnv.SetObjectField(reference, _id_value, value.reference); + + static final _id_ctor = jniAccessors.getMethodIDOf(_classRef, r"", + r"(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V"); + + /// from: public void (T grandParentValue, S parentValue, U value) + /// The returned object must be deleted after use, by calling the `delete` method. + factory GrandParent_Parent_Child( + $T grandParentValue, + $S parentValue, + $U value, { + jni.JObjType<$T>? T, + jni.JObjType<$S>? S, + jni.JObjType<$U>? U, + }) { + T ??= jni.lowestCommonSuperType([ + grandParentValue.$type, + ]) as jni.JObjType<$T>; + S ??= jni.lowestCommonSuperType([ + parentValue.$type, + ]) as jni.JObjType<$S>; + U ??= jni.lowestCommonSuperType([ + value.$type, + ]) as jni.JObjType<$U>; + return GrandParent_Parent_Child.fromRef( + T, + S, + U, + jniAccessors.newObjectWithArgs(_classRef, _id_ctor, [ + grandParentValue.reference, + parentValue.reference, + value.reference + ]).object); + } +} + +class $GrandParent_Parent_ChildType<$T extends jni.JObject, + $S extends jni.JObject, $U extends jni.JObject> + extends jni.JObjType> { + final jni.JObjType<$T> T; + final jni.JObjType<$S> S; + final jni.JObjType<$U> U; + + const $GrandParent_Parent_ChildType( + this.T, + this.S, + this.U, + ); + + @override + String get signature => + r"Lcom/github/dart_lang/jnigen/generics/GrandParent$Parent$Child;"; + + @override + GrandParent_Parent_Child<$T, $S, $U> fromRef(jni.JObjectPtr ref) => + GrandParent_Parent_Child.fromRef(T, S, U, ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => Object.hash($GrandParent_Parent_ChildType, T, S, U); + + @override + bool operator ==(Object other) { + return other.runtimeType == $GrandParent_Parent_ChildType && + other is $GrandParent_Parent_ChildType && + T == other.T && + 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 { + @override + late final jni.JObjType $type = type(S); + + final jni.JObjType<$S> S; + + GrandParent_StaticParent.fromRef( + this.S, + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + static final _classRef = jniAccessors.getClassOf( + r"com/github/dart_lang/jnigen/generics/GrandParent$StaticParent"); + + /// The type which includes information such as the signature of this class. + static $GrandParent_StaticParentType<$S> type<$S extends jni.JObject>( + jni.JObjType<$S> S, + ) { + return $GrandParent_StaticParentType( + S, + ); + } + + static final _id_value = jniAccessors.getFieldIDOf( + _classRef, + r"value", + r"Ljava/lang/Object;", + ); + + /// from: public S value + /// The returned object must be deleted after use, by calling the `delete` method. + $S get value => S.fromRef(jniAccessors + .getField(reference, _id_value, jni.JniCallType.objectType) + .object); + + /// from: public S value + /// The returned object must be deleted after use, by calling the `delete` method. + set value($S value) => + jniEnv.SetObjectField(reference, _id_value, value.reference); + + static final _id_ctor = jniAccessors.getMethodIDOf( + _classRef, r"", r"(Ljava/lang/Object;)V"); + + /// from: public void (S value) + /// The returned object must be deleted after use, by calling the `delete` method. + factory GrandParent_StaticParent( + $S value, { + jni.JObjType<$S>? S, + }) { + S ??= jni.lowestCommonSuperType([ + value.$type, + ]) as jni.JObjType<$S>; + return GrandParent_StaticParent.fromRef( + S, + jniAccessors + .newObjectWithArgs(_classRef, _id_ctor, [value.reference]).object); + } +} + +class $GrandParent_StaticParentType<$S extends jni.JObject> + extends jni.JObjType> { + final jni.JObjType<$S> S; + + const $GrandParent_StaticParentType( + this.S, + ); + + @override + String get signature => + r"Lcom/github/dart_lang/jnigen/generics/GrandParent$StaticParent;"; + + @override + GrandParent_StaticParent<$S> fromRef(jni.JObjectPtr ref) => + GrandParent_StaticParent.fromRef(S, ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => Object.hash($GrandParent_StaticParentType, S); + + @override + bool operator ==(Object other) { + return other.runtimeType == $GrandParent_StaticParentType && + other is $GrandParent_StaticParentType && + S == other.S; + } +} + +/// 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 { + @override + late final jni.JObjType $type = type(S, U); + + final jni.JObjType<$S> S; + final jni.JObjType<$U> U; + + GrandParent_StaticParent_Child.fromRef( + this.S, + this.U, + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + static final _classRef = jniAccessors.getClassOf( + r"com/github/dart_lang/jnigen/generics/GrandParent$StaticParent$Child"); + + /// The type which includes information such as the signature of this class. + static $GrandParent_StaticParent_ChildType<$S, $U> + type<$S extends jni.JObject, $U extends jni.JObject>( + jni.JObjType<$S> S, + jni.JObjType<$U> U, + ) { + return $GrandParent_StaticParent_ChildType( + S, + U, + ); + } + + static final _id_parentValue = jniAccessors.getFieldIDOf( + _classRef, + r"parentValue", + r"Ljava/lang/Object;", + ); + + /// from: public S parentValue + /// The returned object must be deleted after use, by calling the `delete` method. + $S get parentValue => S.fromRef(jniAccessors + .getField(reference, _id_parentValue, jni.JniCallType.objectType) + .object); + + /// from: public S parentValue + /// The returned object must be deleted after use, by calling the `delete` method. + set parentValue($S value) => + jniEnv.SetObjectField(reference, _id_parentValue, value.reference); + + static final _id_value = jniAccessors.getFieldIDOf( + _classRef, + r"value", + r"Ljava/lang/Object;", + ); + + /// from: public U value + /// The returned object must be deleted after use, by calling the `delete` method. + $U get value => U.fromRef(jniAccessors + .getField(reference, _id_value, jni.JniCallType.objectType) + .object); + + /// from: public U value + /// The returned object must be deleted after use, by calling the `delete` method. + set value($U value) => + jniEnv.SetObjectField(reference, _id_value, value.reference); + + static final _id_ctor = jniAccessors.getMethodIDOf( + _classRef, r"", r"(Ljava/lang/Object;Ljava/lang/Object;)V"); + + /// from: public void (S parentValue, U value) + /// The returned object must be deleted after use, by calling the `delete` method. + factory GrandParent_StaticParent_Child( + $S parentValue, + $U value, { + jni.JObjType<$S>? S, + jni.JObjType<$U>? U, + }) { + S ??= jni.lowestCommonSuperType([ + parentValue.$type, + ]) as jni.JObjType<$S>; + U ??= jni.lowestCommonSuperType([ + value.$type, + ]) as jni.JObjType<$U>; + return GrandParent_StaticParent_Child.fromRef( + S, + U, + jniAccessors.newObjectWithArgs(_classRef, _id_ctor, + [parentValue.reference, value.reference]).object); + } +} + +class $GrandParent_StaticParent_ChildType<$S extends jni.JObject, + $U extends jni.JObject> + extends jni.JObjType> { + final jni.JObjType<$S> S; + final jni.JObjType<$U> U; + + const $GrandParent_StaticParent_ChildType( + this.S, + this.U, + ); + + @override + String get signature => + r"Lcom/github/dart_lang/jnigen/generics/GrandParent$StaticParent$Child;"; + + @override + GrandParent_StaticParent_Child<$S, $U> fromRef(jni.JObjectPtr ref) => + GrandParent_StaticParent_Child.fromRef(S, U, ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => Object.hash($GrandParent_StaticParent_ChildType, S, U); + + @override + bool operator ==(Object other) { + return other.runtimeType == $GrandParent_StaticParent_ChildType && + other is $GrandParent_StaticParent_ChildType && + S == other.S && + U == other.U; + } +} + +/// from: com.github.dart_lang.jnigen.generics.MyMap +class MyMap<$K extends jni.JObject, $V extends jni.JObject> + extends jni.JObject { + @override + late final jni.JObjType $type = type(K, V); + + final jni.JObjType<$K> K; + final jni.JObjType<$V> V; + + MyMap.fromRef( + this.K, + this.V, + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + static final _classRef = + jniAccessors.getClassOf(r"com/github/dart_lang/jnigen/generics/MyMap"); + + /// The type which includes information such as the signature of this class. + static $MyMapType<$K, $V> + type<$K extends jni.JObject, $V extends jni.JObject>( + jni.JObjType<$K> K, + jni.JObjType<$V> V, + ) { + return $MyMapType( + K, + V, + ); + } + + static final _id_ctor = + jniAccessors.getMethodIDOf(_classRef, r"", r"()V"); + + /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. + factory MyMap({ + required jni.JObjType<$K> K, + required jni.JObjType<$V> V, + }) { + return MyMap.fromRef( + K, V, jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); + } + + static final _id_get0 = jniAccessors.getMethodIDOf( + _classRef, r"get", r"(Ljava/lang/Object;)Ljava/lang/Object;"); + + /// from: public V get(K key) + /// The returned object must be deleted after use, by calling the `delete` method. + $V get0( + $K key, + ) { + return V.fromRef(jniAccessors.callMethodWithArgs(reference, _id_get0, + jni.JniCallType.objectType, [key.reference]).object); + } + + static final _id_put = jniAccessors.getMethodIDOf(_classRef, r"put", + r"(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); + + /// from: public V put(K key, V value) + /// The returned object must be deleted after use, by calling the `delete` method. + $V put( + $K key, + $V value, + ) { + return V.fromRef(jniAccessors.callMethodWithArgs(reference, _id_put, + jni.JniCallType.objectType, [key.reference, value.reference]).object); + } + + static final _id_entryStack = jniAccessors.getMethodIDOf(_classRef, + r"entryStack", r"()Lcom/github/dart_lang/jnigen/generics/MyStack;"); + + /// from: public com.github.dart_lang.jnigen.generics.MyStack.MyEntry> entryStack() + /// The returned object must be deleted after use, by calling the `delete` method. + MyStack> entryStack() { + return const $MyStackType( + $MyMap_MyEntryType(jni.JObjectType(), jni.JObjectType())) + .fromRef(jniAccessors.callMethodWithArgs( + reference, _id_entryStack, jni.JniCallType.objectType, []).object); + } +} + +class $MyMapType<$K extends jni.JObject, $V extends jni.JObject> + extends jni.JObjType> { + final jni.JObjType<$K> K; + final jni.JObjType<$V> V; + + const $MyMapType( + this.K, + this.V, + ); + + @override + String get signature => r"Lcom/github/dart_lang/jnigen/generics/MyMap;"; + + @override + MyMap<$K, $V> fromRef(jni.JObjectPtr ref) => MyMap.fromRef(K, V, ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => Object.hash($MyMapType, K, V); + + @override + bool operator ==(Object other) { + return other.runtimeType == $MyMapType && + other is $MyMapType && + K == other.K && + V == other.V; + } +} + +/// from: com.github.dart_lang.jnigen.generics.MyMap$MyEntry +class MyMap_MyEntry<$K extends jni.JObject, $V extends jni.JObject> + extends jni.JObject { + @override + late final jni.JObjType $type = type(K, V); + + final jni.JObjType<$K> K; + final jni.JObjType<$V> V; + + MyMap_MyEntry.fromRef( + this.K, + this.V, + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + static final _classRef = jniAccessors + .getClassOf(r"com/github/dart_lang/jnigen/generics/MyMap$MyEntry"); + + /// The type which includes information such as the signature of this class. + static $MyMap_MyEntryType<$K, $V> + type<$K extends jni.JObject, $V extends jni.JObject>( + jni.JObjType<$K> K, + jni.JObjType<$V> V, + ) { + return $MyMap_MyEntryType( + K, + V, + ); + } + + static final _id_key = jniAccessors.getFieldIDOf( + _classRef, + r"key", + r"Ljava/lang/Object;", + ); + + /// from: public K key + /// The returned object must be deleted after use, by calling the `delete` method. + $K get key => K.fromRef(jniAccessors + .getField(reference, _id_key, jni.JniCallType.objectType) + .object); + + /// from: public K key + /// The returned object must be deleted after use, by calling the `delete` method. + set key($K value) => + jniEnv.SetObjectField(reference, _id_key, value.reference); + + static final _id_value = jniAccessors.getFieldIDOf( + _classRef, + r"value", + r"Ljava/lang/Object;", + ); + + /// from: public V value + /// The returned object must be deleted after use, by calling the `delete` method. + $V get value => V.fromRef(jniAccessors + .getField(reference, _id_value, jni.JniCallType.objectType) + .object); + + /// from: public V value + /// The returned object must be deleted after use, by calling the `delete` method. + set value($V value) => + jniEnv.SetObjectField(reference, _id_value, value.reference); + + static final _id_ctor = jniAccessors.getMethodIDOf( + _classRef, r"", r"(Ljava/lang/Object;Ljava/lang/Object;)V"); + + /// from: public void (K key, V value) + /// The returned object must be deleted after use, by calling the `delete` method. + factory MyMap_MyEntry( + $K key, + $V value, { + jni.JObjType<$K>? K, + jni.JObjType<$V>? V, + }) { + K ??= jni.lowestCommonSuperType([ + key.$type, + ]) as jni.JObjType<$K>; + V ??= jni.lowestCommonSuperType([ + value.$type, + ]) as jni.JObjType<$V>; + return MyMap_MyEntry.fromRef( + K, + V, + jniAccessors.newObjectWithArgs( + _classRef, _id_ctor, [key.reference, value.reference]).object); + } +} + +class $MyMap_MyEntryType<$K extends jni.JObject, $V extends jni.JObject> + extends jni.JObjType> { + final jni.JObjType<$K> K; + final jni.JObjType<$V> V; + + const $MyMap_MyEntryType( + this.K, + this.V, + ); + + @override + String get signature => + r"Lcom/github/dart_lang/jnigen/generics/MyMap$MyEntry;"; + + @override + MyMap_MyEntry<$K, $V> fromRef(jni.JObjectPtr ref) => + MyMap_MyEntry.fromRef(K, V, ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => Object.hash($MyMap_MyEntryType, K, V); + + @override + bool operator ==(Object other) { + return other.runtimeType == $MyMap_MyEntryType && + other is $MyMap_MyEntryType && + K == other.K && + V == other.V; + } +} + +/// from: com.github.dart_lang.jnigen.generics.MyStack +class MyStack<$T extends jni.JObject> extends jni.JObject { + @override + late final jni.JObjType $type = type(T); + + final jni.JObjType<$T> T; + + MyStack.fromRef( + this.T, + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + static final _classRef = + jniAccessors.getClassOf(r"com/github/dart_lang/jnigen/generics/MyStack"); + + /// The type which includes information such as the signature of this class. + static $MyStackType<$T> type<$T extends jni.JObject>( + jni.JObjType<$T> T, + ) { + return $MyStackType( + T, + ); + } + + static final _id_ctor = + jniAccessors.getMethodIDOf(_classRef, r"", r"()V"); + + /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. + factory MyStack({ + required jni.JObjType<$T> T, + }) { + return MyStack.fromRef( + T, jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); + } + + static final _id_fromArray = jniAccessors.getStaticMethodIDOf( + _classRef, + r"fromArray", + r"([Ljava/lang/Object;)Lcom/github/dart_lang/jnigen/generics/MyStack;"); + + /// from: static public com.github.dart_lang.jnigen.generics.MyStack fromArray(T[] arr) + /// The returned object must be deleted after use, by calling the `delete` method. + static MyStack<$T> fromArray<$T extends jni.JObject>( + jni.JArray<$T> arr, { + jni.JObjType<$T>? T, + }) { + T ??= jni.lowestCommonSuperType([ + ((arr.$type as jni.JArrayType).elementType as jni.JObjType), + ]) as jni.JObjType<$T>; + return $MyStackType(T).fromRef(jniAccessors.callStaticMethodWithArgs( + _classRef, + _id_fromArray, + jni.JniCallType.objectType, + [arr.reference]).object); + } + + static final _id_fromArrayOfArrayOfGrandParents = + jniAccessors.getStaticMethodIDOf( + _classRef, + r"fromArrayOfArrayOfGrandParents", + r"([[Lcom/github/dart_lang/jnigen/generics/GrandParent;)Lcom/github/dart_lang/jnigen/generics/MyStack;"); + + /// from: static public com.github.dart_lang.jnigen.generics.MyStack fromArrayOfArrayOfGrandParents(com.github.dart_lang.jnigen.generics.GrandParent[][] arr) + /// The returned object must be deleted after use, by calling the `delete` method. + static MyStack<$S> fromArrayOfArrayOfGrandParents<$S extends jni.JObject>( + jni.JArray>> arr, { + jni.JObjType<$S>? S, + }) { + S ??= jni.lowestCommonSuperType([ + (((((arr.$type as jni.JArrayType).elementType as jni.JObjType) + as jni.JArrayType) + .elementType as jni.JObjType) as $GrandParentType) + .T, + ]) as jni.JObjType<$S>; + return $MyStackType(S).fromRef(jniAccessors.callStaticMethodWithArgs( + _classRef, + _id_fromArrayOfArrayOfGrandParents, + jni.JniCallType.objectType, + [arr.reference]).object); + } + + static final _id_of = jniAccessors.getStaticMethodIDOf( + _classRef, r"of", r"()Lcom/github/dart_lang/jnigen/generics/MyStack;"); + + /// from: static public com.github.dart_lang.jnigen.generics.MyStack of() + /// The returned object must be deleted after use, by calling the `delete` method. + static MyStack<$T> of<$T extends jni.JObject>({ + required jni.JObjType<$T> T, + }) { + return $MyStackType(T).fromRef(jniAccessors.callStaticMethodWithArgs( + _classRef, _id_of, jni.JniCallType.objectType, []).object); + } + + static final _id_of1 = jniAccessors.getStaticMethodIDOf(_classRef, r"of", + r"(Ljava/lang/Object;)Lcom/github/dart_lang/jnigen/generics/MyStack;"); + + /// from: static public com.github.dart_lang.jnigen.generics.MyStack of(T obj) + /// The returned object must be deleted after use, by calling the `delete` method. + static MyStack<$T> of1<$T extends jni.JObject>( + $T obj, { + jni.JObjType<$T>? T, + }) { + T ??= jni.lowestCommonSuperType([ + obj.$type, + ]) as jni.JObjType<$T>; + return $MyStackType(T).fromRef(jniAccessors.callStaticMethodWithArgs( + _classRef, + _id_of1, + jni.JniCallType.objectType, + [obj.reference]).object); + } + + static final _id_of2 = jniAccessors.getStaticMethodIDOf(_classRef, r"of", + r"(Ljava/lang/Object;Ljava/lang/Object;)Lcom/github/dart_lang/jnigen/generics/MyStack;"); + + /// from: static public com.github.dart_lang.jnigen.generics.MyStack of(T obj, T obj2) + /// The returned object must be deleted after use, by calling the `delete` method. + static MyStack<$T> of2<$T extends jni.JObject>( + $T obj, + $T obj2, { + jni.JObjType<$T>? T, + }) { + T ??= jni.lowestCommonSuperType([ + obj2.$type, + obj.$type, + ]) as jni.JObjType<$T>; + return $MyStackType(T).fromRef(jniAccessors.callStaticMethodWithArgs( + _classRef, + _id_of2, + jni.JniCallType.objectType, + [obj.reference, obj2.reference]).object); + } + + static final _id_push = + jniAccessors.getMethodIDOf(_classRef, r"push", r"(Ljava/lang/Object;)V"); + + /// from: public void push(T item) + void push( + $T item, + ) { + return jniAccessors.callMethodWithArgs(reference, _id_push, + jni.JniCallType.voidType, [item.reference]).check(); + } + + static final _id_pop = + jniAccessors.getMethodIDOf(_classRef, r"pop", r"()Ljava/lang/Object;"); + + /// from: public T pop() + /// The returned object must be deleted after use, by calling the `delete` method. + $T pop() { + return T.fromRef(jniAccessors.callMethodWithArgs( + reference, _id_pop, jni.JniCallType.objectType, []).object); + } + + static final _id_size = + jniAccessors.getMethodIDOf(_classRef, r"size", r"()I"); + + /// from: public int size() + int size() { + return jniAccessors.callMethodWithArgs( + reference, _id_size, jni.JniCallType.intType, []).integer; + } +} + +class $MyStackType<$T extends jni.JObject> extends jni.JObjType> { + final jni.JObjType<$T> T; + + const $MyStackType( + this.T, + ); + + @override + String get signature => r"Lcom/github/dart_lang/jnigen/generics/MyStack;"; + + @override + MyStack<$T> fromRef(jni.JObjectPtr ref) => MyStack.fromRef(T, ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => Object.hash($MyStackType, T); + + @override + bool operator ==(Object other) { + return other.runtimeType == $MyStackType && + other is $MyStackType && + T == other.T; + } +} + +/// from: com.github.dart_lang.jnigen.generics.StringKeyedMap +class StringKeyedMap<$V extends jni.JObject> extends MyMap { + @override + late final jni.JObjType $type = type(V); + + final jni.JObjType<$V> V; + + StringKeyedMap.fromRef( + this.V, + jni.JObjectPtr ref, + ) : super.fromRef(const jni.JStringType(), V, ref); + + static final _classRef = jniAccessors + .getClassOf(r"com/github/dart_lang/jnigen/generics/StringKeyedMap"); + + /// The type which includes information such as the signature of this class. + static $StringKeyedMapType<$V> type<$V extends jni.JObject>( + jni.JObjType<$V> V, + ) { + return $StringKeyedMapType( + V, + ); + } + + static final _id_ctor = + jniAccessors.getMethodIDOf(_classRef, r"", r"()V"); + + /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. + factory StringKeyedMap({ + required jni.JObjType<$V> V, + }) { + return StringKeyedMap.fromRef( + V, jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); + } +} + +class $StringKeyedMapType<$V extends jni.JObject> + extends jni.JObjType> { + final jni.JObjType<$V> V; + + const $StringKeyedMapType( + this.V, + ); + + @override + String get signature => + r"Lcom/github/dart_lang/jnigen/generics/StringKeyedMap;"; + + @override + StringKeyedMap<$V> fromRef(jni.JObjectPtr ref) => + StringKeyedMap.fromRef(V, ref); + + @override + jni.JObjType get superType => $MyMapType(const jni.JStringType(), V); + + @override + final superCount = 2; + + @override + int get hashCode => Object.hash($StringKeyedMapType, V); + + @override + bool operator ==(Object other) { + return other.runtimeType == $StringKeyedMapType && + other is $StringKeyedMapType && + V == other.V; + } +} + +/// from: com.github.dart_lang.jnigen.generics.StringMap +class StringMap extends StringKeyedMap { + @override + late final jni.JObjType $type = type; + + StringMap.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(const jni.JStringType(), ref); + + static final _classRef = jniAccessors + .getClassOf(r"com/github/dart_lang/jnigen/generics/StringMap"); + + /// The type which includes information such as the signature of this class. + static const type = $StringMapType(); + static final _id_ctor = + jniAccessors.getMethodIDOf(_classRef, r"", r"()V"); + + /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. + factory StringMap() { + return StringMap.fromRef( + jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); + } +} + +class $StringMapType extends jni.JObjType { + const $StringMapType(); + + @override + String get signature => r"Lcom/github/dart_lang/jnigen/generics/StringMap;"; + + @override + StringMap fromRef(jni.JObjectPtr ref) => StringMap.fromRef(ref); + + @override + jni.JObjType get superType => const $StringKeyedMapType(jni.JStringType()); + + @override + final superCount = 3; + + @override + int get hashCode => ($StringMapType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $StringMapType && other is $StringMapType; + } +} + +/// from: com.github.dart_lang.jnigen.generics.StringStack +class StringStack extends MyStack { + @override + late final jni.JObjType $type = type; + + StringStack.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(const jni.JStringType(), ref); + + static final _classRef = jniAccessors + .getClassOf(r"com/github/dart_lang/jnigen/generics/StringStack"); + + /// The type which includes information such as the signature of this class. + static const type = $StringStackType(); + static final _id_ctor = + jniAccessors.getMethodIDOf(_classRef, r"", r"()V"); + + /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. + factory StringStack() { + return StringStack.fromRef( + jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); + } +} + +class $StringStackType extends jni.JObjType { + const $StringStackType(); + + @override + String get signature => r"Lcom/github/dart_lang/jnigen/generics/StringStack;"; + + @override + StringStack fromRef(jni.JObjectPtr ref) => StringStack.fromRef(ref); + + @override + jni.JObjType get superType => const $MyStackType(jni.JStringType()); + + @override + final superCount = 2; + + @override + int get hashCode => ($StringStackType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $StringStackType && other is $StringStackType; + } +} + +/// from: com.github.dart_lang.jnigen.generics.StringValuedMap +class StringValuedMap<$K extends jni.JObject> extends MyMap<$K, jni.JString> { + @override + late final jni.JObjType $type = type(K); + + final jni.JObjType<$K> K; + + StringValuedMap.fromRef( + this.K, + jni.JObjectPtr ref, + ) : super.fromRef(K, const jni.JStringType(), ref); + + static final _classRef = jniAccessors + .getClassOf(r"com/github/dart_lang/jnigen/generics/StringValuedMap"); + + /// The type which includes information such as the signature of this class. + static $StringValuedMapType<$K> type<$K extends jni.JObject>( + jni.JObjType<$K> K, + ) { + return $StringValuedMapType( + K, + ); + } + + static final _id_ctor = + jniAccessors.getMethodIDOf(_classRef, r"", r"()V"); + + /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. + factory StringValuedMap({ + required jni.JObjType<$K> K, + }) { + return StringValuedMap.fromRef( + K, jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); + } +} + +class $StringValuedMapType<$K extends jni.JObject> + extends jni.JObjType> { + final jni.JObjType<$K> K; + + const $StringValuedMapType( + this.K, + ); + + @override + String get signature => + r"Lcom/github/dart_lang/jnigen/generics/StringValuedMap;"; + + @override + StringValuedMap<$K> fromRef(jni.JObjectPtr ref) => + StringValuedMap.fromRef(K, ref); + + @override + jni.JObjType get superType => $MyMapType(K, const jni.JStringType()); + + @override + final superCount = 2; + + @override + int get hashCode => Object.hash($StringValuedMapType, K); + + @override + bool operator ==(Object other) { + return other.runtimeType == $StringValuedMapType && + other is $StringValuedMapType && + K == other.K; + } +} + +/// from: com.github.dart_lang.jnigen.annotations.JsonSerializable$Case +class JsonSerializable_Case extends jni.JObject { + @override + late final jni.JObjType $type = type; + + JsonSerializable_Case.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + static final _classRef = jniAccessors.getClassOf( + r"com/github/dart_lang/jnigen/annotations/JsonSerializable$Case"); + + /// The type which includes information such as the signature of this class. + static const type = $JsonSerializable_CaseType(); + static final _id_values = jniAccessors.getStaticMethodIDOf( + _classRef, + r"values", + r"()[Lcom/github/dart_lang/jnigen/annotations/JsonSerializable$Case;"); + + /// from: static public com.github.dart_lang.jnigen.annotations.JsonSerializable.Case[] values() + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JArray values() { + return const jni.JArrayType($JsonSerializable_CaseType()).fromRef( + jniAccessors.callStaticMethodWithArgs( + _classRef, _id_values, jni.JniCallType.objectType, []).object); + } + + static final _id_valueOf = jniAccessors.getStaticMethodIDOf( + _classRef, + r"valueOf", + r"(Ljava/lang/String;)Lcom/github/dart_lang/jnigen/annotations/JsonSerializable$Case;"); + + /// from: static public com.github.dart_lang.jnigen.annotations.JsonSerializable.Case valueOf(java.lang.String name) + /// The returned object must be deleted after use, by calling the `delete` method. + static JsonSerializable_Case valueOf( + jni.JString name, + ) { + return const $JsonSerializable_CaseType().fromRef(jniAccessors + .callStaticMethodWithArgs(_classRef, _id_valueOf, + jni.JniCallType.objectType, [name.reference]).object); + } +} + +class $JsonSerializable_CaseType extends jni.JObjType { + const $JsonSerializable_CaseType(); + + @override + String get signature => + r"Lcom/github/dart_lang/jnigen/annotations/JsonSerializable$Case;"; + + @override + JsonSerializable_Case fromRef(jni.JObjectPtr ref) => + JsonSerializable_Case.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($JsonSerializable_CaseType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $JsonSerializable_CaseType && + other is $JsonSerializable_CaseType; + } +} + +/// from: com.github.dart_lang.jnigen.annotations.MyDataClass +class MyDataClass extends jni.JObject { + @override + late final jni.JObjType $type = type; + + MyDataClass.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + static final _classRef = jniAccessors + .getClassOf(r"com/github/dart_lang/jnigen/annotations/MyDataClass"); + + /// The type which includes information such as the signature of this class. + static const type = $MyDataClassType(); + static final _id_ctor = + jniAccessors.getMethodIDOf(_classRef, r"", r"()V"); + + /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. + factory MyDataClass() { + return MyDataClass.fromRef( + jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); + } +} + +class $MyDataClassType extends jni.JObjType { + const $MyDataClassType(); + + @override + String get signature => + r"Lcom/github/dart_lang/jnigen/annotations/MyDataClass;"; + + @override + MyDataClass fromRef(jni.JObjectPtr ref) => MyDataClass.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($MyDataClassType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == $MyDataClassType && other is $MyDataClassType; + } +} diff --git a/pkgs/jnigen/test/simple_package_test/generate.dart b/pkgs/jnigen/test/simple_package_test/generate.dart index 962fe17b5..18c38e0d3 100644 --- a/pkgs/jnigen/test/simple_package_test/generate.dart +++ b/pkgs/jnigen/test/simple_package_test/generate.dart @@ -45,8 +45,11 @@ void compileJavaSources(String workingDir, List files) async { Config getConfig([BindingsType bindingsType = BindingsType.cBased]) { compileJavaSources(javaPath, javaFiles); - final cWrapperDir = Uri.directory(join(testRoot, "src")); - final dartWrappersRoot = Uri.directory(join(testRoot, "lib")); + final typeDir = bindingsType.getConfigString(); + final cWrapperDir = Uri.directory(join(testRoot, typeDir, "c_bindings")); + final dartWrappersRoot = Uri.directory( + join(testRoot, typeDir, "dart_bindings"), + ); final config = Config( sourcePath: [Uri.directory(javaPath)], classPath: [Uri.directory(javaPath)], @@ -73,4 +76,7 @@ Config getConfig([BindingsType bindingsType = BindingsType.cBased]) { return config; } -void main() async => await generateJniBindings(getConfig()); +void main() async { + await generateJniBindings(getConfig(BindingsType.cBased)); + await generateJniBindings(getConfig(BindingsType.dartOnly)); +} diff --git a/pkgs/jnigen/test/simple_package_test/generated_files_test.dart b/pkgs/jnigen/test/simple_package_test/generated_files_test.dart index 084afe043..0f595d2ff 100644 --- a/pkgs/jnigen/test/simple_package_test/generated_files_test.dart +++ b/pkgs/jnigen/test/simple_package_test/generated_files_test.dart @@ -4,7 +4,6 @@ import 'package:jnigen/jnigen.dart'; import 'package:test/test.dart'; -import 'package:path/path.dart' hide equals; import 'generate.dart'; import '../test_util/test_util.dart'; @@ -12,13 +11,12 @@ import '../test_util/test_util.dart'; void main() async { await checkLocallyBuiltDependencies(); - test("Generate and compare bindings for simple_package", () async { - await generateAndCompareBindings( - getConfig(), - join(testRoot, "lib", "simple_package.dart"), - join(testRoot, "src"), - ); - }); // test if generated file == expected file + generateAndCompareBothModes( + 'Generate and compare bindings for simple_package java files', + getConfig(BindingsType.cBased), + getConfig(BindingsType.dartOnly), + ); + test("Generate and analyze bindings for simple_package - pure dart", () async { await generateAndAnalyzeBindings( diff --git a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/simple_package/Example.java b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/simple_package/Example.java index abd87c462..edb274894 100644 --- a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/simple_package/Example.java +++ b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/simple_package/Example.java @@ -4,76 +4,175 @@ package com.github.dart_lang.jnigen.simple_package; -import java.util.Arrays; +import java.util.*; public class Example { + // static fields - primitive & string public static final int ON = 1; public static final int OFF = 0; + public static final double PI = 3.14159; + public static final char SEMICOLON = ';'; + public static final String SEMICOLON_STRING = ";"; - public static Aux aux; - public static int num; + private static int amount = 500; + private static double pi = 3.14159; + private static char asterisk = '*'; + private static String name = "Ragnar Lothbrok"; - private int internal = 0; + // Static fields - object + private static Nested nested = new Nested(true); - public Example() {} + // static methods + public static int getAmount() { + return amount; + } - public Example(int internal) { - this.internal = internal; + public static double getPi() { + return pi; } - static { - aux = new Aux(true); - num = 121; + public static char getAsterisk() { + return asterisk; } - public int whichExample() { - return 0; + public static String getName() { + return name; } - public static Aux getAux() { - return aux; + public static Nested getNestedInstance() { + return nested; } - public static int addInts(int a, int b) { - return a + b; + // void functions with 1 parameter + public static void setAmount(int newAmount) { + amount = newAmount; } - public static int[] getArr() { - return new int[] {1, 2, 3}; + public static void setName(String newName) { + name = newName; } - public static int addAll(int[] arr) { - return Arrays.stream(arr).sum(); + public static void setNestedInstance(Nested newNested) { + nested = newNested; } - public Example getSelf() { - return this; + // void functions with many parameters + public static int max4(int a, int b, int c, int d) { + return Integer.max(Integer.max(a, b), Integer.max(c, d)); + } + + public static int max8(int a, int b, int c, int d, int e, int f, int g, int h) { + return Integer.max(max4(a, b, c, d), max4(e, f, g, h)); + } + + // Instance fields - primitive and string + private int number = 0; + private boolean isUp = false; + private String codename = "achilles"; + + // Instance fields - object + private Random random = new Random(); + + // Instance methods + public int getNumber() { + return number; + } + + public void setNumber(int number) { + this.number = number; + } + + public boolean getIsUp() { + return isUp; + } + + public void setUp(boolean isUp) { + this.isUp = isUp; + } + + public String getCodename() { + return codename; + } + + public void setCodename(String codename) { + this.codename = codename; + } + + public Random getRandom() { + return random; + } + + public void setRandom(Random random) { + this.random = random; } - public int getNum() { - return num; + public long getRandomLong() { + return random.nextLong(); } - public void setNum(int num) { - this.num = num; + public long add4Longs(long a, long b, long c, long d) { + return a + b + c + d; } - public int getInternal() { - return internal; + public long add8Longs(long a, long b, long c, long d, long e, long f, long g, long h) { + return a + b + c + d + e + f + g + h; } - public void setInternal(int internal) { - this.internal = internal; + public String getRandomNumericString(Random random) { + return String.format( + "%d%d%d%d", random.nextInt(10), random.nextInt(10), random.nextInt(10), random.nextInt(10)); + } + + public Example() { + this(0); + } + + public Example(int number) { + this(number, true); + } + + public Example(int number, boolean isUp) { + this(number, isUp, "achilles"); + } + + public Example(int number, boolean isUp, String codename) { + this.number = number; + this.isUp = isUp; + this.codename = codename; + } + + public Example(int a, int b, int c, int d, int e, int f, int g, int h) { + this(a + b + c + d + e + f + g + h); + } + + public int whichExample() { + return 0; + } + + public static int addInts(int a, int b) { + return a + b; + } + + public static int[] getArr() { + return new int[] {1, 2, 3}; + } + + public static int addAll(int[] arr) { + return Arrays.stream(arr).sum(); + } + + public Example getSelf() { + return this; } public static void throwException() { throw new RuntimeException("Hello"); } - public static class Aux { - public boolean value; + public static class Nested { + private boolean value; - public Aux(boolean value) { + public Nested(boolean value) { this.value = value; } 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 new file mode 100644 index 000000000..29490894f --- /dev/null +++ b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/simple_package/Exceptions.java @@ -0,0 +1,81 @@ +// 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. + +package com.github.dart_lang.jnigen.simple_package; + +import java.io.*; +import java.util.*; + +public class Exceptions { + public Exceptions() {} + // constructor throwing exception + public Exceptions(float x) { + throw new IllegalArgumentException("Float is not a serious type"); + } + + public Exceptions(int a, int b, int c, int d, int e, int f) { + throw new IllegalArgumentException("Too many arguments, but none in your favor"); + } + + public static Object staticObjectMethod() { + throw new RuntimeException(":-/"); + } + + public static int staticIntMethod() { + throw new RuntimeException("\\-:"); + } + + public static Object[] staticObjectArrayMethod() { + throw new RuntimeException(":-/[]"); + } + + public static int[] staticIntArrayMethod() { + throw new RuntimeException("\\-:[]"); + } + + public Object objectMethod() { + throw new RuntimeException("['--']"); + } + + public int intMethod() { + throw new RuntimeException("[-_-]"); + } + + public Object[] objectArrayMethod() { + throw new RuntimeException(":-/[]"); + } + + public int[] intArrayMethod() { + throw new RuntimeException("\\-:[]"); + } + + public int throwNullPointerException() { + Random random = null; + return random.nextInt(); + } + + public InputStream throwFileNotFoundException() throws IOException { + return new FileInputStream("/dev/nulll/59613/287"); + } + + public FileInputStream throwClassCastException() { + InputStream x = System.in; + return (FileInputStream) x; + } + + public int throwArrayIndexException() { + int[] nums = {1, 2}; + return nums[4]; + } + + public int throwArithmeticException() { + int x = 10; + int y = 100 - 100 + 1 - 1; + return x / y; + } + + public static void throwLoremIpsum() { + throw new RuntimeException("Lorem Ipsum"); + } +} diff --git a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/simple_package/Fields.java b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/simple_package/Fields.java new file mode 100644 index 000000000..face69c17 --- /dev/null +++ b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/simple_package/Fields.java @@ -0,0 +1,34 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jnigen.simple_package; + +import java.util.*; + +public class Fields { + // static fields - non-final primitive & string + public static int amount = 500; + public static double pi = 3.14159; + public static char asterisk = '*'; + public static String name = "Earl Haraldson"; + + // Static fields - object + public Integer i = 100; + + // Instance fields - primitive and string + public long trillion = 1024L * 1024L * 1024L * 1024L; + public boolean isAchillesDead = false; + public String bestFighterInGreece = "Achilles"; + + // Instance fields - object + public Random random = new Random(); + + // Static and instance fields in nested class. + public static class Nested { + public long hundred = 100L; + public static String BEST_GOD = "Pallas Athena"; + } + + public static char euroSymbol = '\u20ac'; +} diff --git a/pkgs/jnigen/test/simple_package_test/runtime_test_registrant.dart b/pkgs/jnigen/test/simple_package_test/runtime_test_registrant.dart new file mode 100644 index 000000000..41747e01b --- /dev/null +++ b/pkgs/jnigen/test/simple_package_test/runtime_test_registrant.dart @@ -0,0 +1,559 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +import 'dart:io'; + +import 'package:test/test.dart'; +import 'package:jni/jni.dart'; + +import '../test_util/callback_types.dart'; + +import 'c_based/dart_bindings/simple_package.dart'; + +const pi = 3.14159; +const fpDelta = 0.001; +const trillion = 1024 * 1024 * 1024 * 1024; + +void registerTests(String groupName, TestRunnerCallback test) { + group(groupName, () { + test('static final fields - int', () { + expect(Example.ON, equals(1)); + expect(Example.OFF, equals(0)); + expect(Example.PI, closeTo(pi, fpDelta)); + expect(Example.SEMICOLON, equals(';')); + expect(Example.SEMICOLON_STRING, equals(';')); + }); + + test('Static methods - primitive', () { + // same test can be run at a replicated (dart-only) test, check for both + // possible values. + expect(Example.getAmount(), isIn([1012, 500])); + Example.setAmount(1012); + expect(Example.getAmount(), equals(1012)); + expect(Example.getAsterisk(), equals('*'.codeUnitAt(0))); + expect(C2.CONSTANT, equals(12)); + }); + + test('Static fields & methods - string', () { + expect( + Example.getName().toDartString(deleteOriginal: true), + isIn(["Ragnar Lothbrok", "Theseus"]), + ); + Example.setName("Theseus".toJString()); + expect( + Example.getName().toDartString(deleteOriginal: true), + equals("Theseus"), + ); + }); + + test('Static fields and methods - Object', () { + final nested = Example.getNestedInstance(); + expect(nested.getValue(), isIn([true, false])); + nested.setValue(false); + expect(nested.getValue(), isFalse); + }); + + test('static methods with several arguments', () { + expect(Example.addInts(10, 15), equals(25)); + expect(Example.max4(-1, 15, 30, 12), equals(30)); + expect(Example.max8(1, 4, 8, 2, 4, 10, 8, 6), equals(10)); + }); + + test('Instance methods (getters & setters)', () { + final e = Example(); + expect(e.getNumber(), equals(0)); + expect(e.getIsUp(), true); + expect(e.getCodename().toDartString(), equals("achilles")); + e.setNumber(1); + e.setUp(false); + e.setCodename("spartan".toJString()); + expect(e.getIsUp(), false); + expect(e.getNumber(), 1); + expect(e.getCodename().toDartString(), equals("spartan")); + e.delete(); + }); + + test('Instance methods with several arguments', () { + final e = Example(); + expect(e.add4Longs(1, 2, 3, 4), equals(10)); + expect(e.add8Longs(1, 1, 2, 2, 3, 3, 12, 24), equals(48)); + expect( + e.add4Longs(trillion, trillion, trillion, trillion), + equals(4 * trillion), + ); + expect( + e.add8Longs(trillion, -trillion, trillion, -trillion, trillion, + -trillion, -trillion, -trillion), + equals(2 * -trillion), + ); + e.delete(); + }); + + test('Misc. instance methods', () { + final e = Example(); + final rand = e.getRandom(); + expect(rand.isNull, isFalse); + final _ = e.getRandomLong(); + final id = + e.getRandomNumericString(rand).toDartString(deleteOriginal: true); + expect(int.parse(id), lessThan(10000)); + e.setNumber(145); + expect( + e.getSelf().getSelf().getSelf().getSelf().getNumber(), + equals(145), + ); + e.delete(); + }); + + test('Constructors', () { + final e0 = Example(); + expect(e0.getNumber(), 0); + expect(e0.getIsUp(), true); + expect(e0.getCodename().toDartString(), equals('achilles')); + final e1 = Example.ctor1(111); + expect(e1.getNumber(), equals(111)); + expect(e1.getIsUp(), true); + expect(e1.getCodename().toDartString(), "achilles"); + final e2 = Example.ctor2(122, false); + expect(e2.getNumber(), equals(122)); + expect(e2.getIsUp(), false); + expect(e2.getCodename().toDartString(), "achilles"); + final e3 = Example.ctor3(133, false, "spartan".toJString()); + expect(e3.getNumber(), equals(133)); + expect(e3.getIsUp(), false); + expect(e3.getCodename().toDartString(), "spartan"); + }); + + test('Static (non-final) fields', () { + // Other replica test may already have modified this, so assert both + // values. + expect(Fields.amount, isIn([500, 101])); + Fields.amount = 101; + expect(Fields.amount, equals(101)); + + expect(Fields.asterisk, equals('*'.codeUnitAt(0))); + + expect( + Fields.name.toDartString(), + isIn(["Earl Haraldson", "Ragnar Lothbrok"]), + ); + + Fields.name = "Ragnar Lothbrok".toJString(); + expect(Fields.name.toDartString(), equals("Ragnar Lothbrok")); + + expect(Fields.pi, closeTo(pi, fpDelta)); + }); + + test('Instance fields', () { + final f = Fields(); + expect(f.trillion, equals(trillion)); + + expect(f.isAchillesDead, isFalse); + expect(f.bestFighterInGreece.toDartString(), equals("Achilles")); + // "For your glory walks hand-in-hand with your doom." - Thetis. + f.isAchillesDead = true; + // I don't know much Greek mythology. But Troy was released in 2004, + // and 300 was released in 2006, so it's Leonidas I. + f.bestFighterInGreece = "Leonidas I".toJString(); + expect(f.isAchillesDead, isTrue); + expect(f.bestFighterInGreece.toDartString(), "Leonidas I"); + }); + + test('Fields from nested class', () { + expect(Fields_Nested().hundred, equals(100)); + // Hector of Troy may disagree. + expect(Fields_Nested.BEST_GOD.toDartString(), equals('Pallas Athena')); + }); + + test('static methods arrays', () { + final array = Example.getArr(); + expect(array[0], 1); + expect(array[1], 2); + expect(array[2], 3); + expect(Example.addAll(array), 6); + array[0] = 4; + expect(Example.addAll(array), 9); + }); + + test('array of the class', () { + final ex1 = Example(); + final ex2 = Example(); + ex1.setNumber(1); + ex2.setNumber(2); + final array = JArray(Example.type, 2); + array[0] = ex1; + array[1] = ex2; + expect(array[0].getNumber(), 1); + expect(array[1].getNumber(), 2); + array.delete(); + ex1.delete(); + ex2.delete(); + }); + + test("Check bindings for same-named classes", () { + expect(Example().whichExample(), 0); + expect(Example1().whichExample(), 1); + }); + + test('Unicode char', () { + expect(Fields.euroSymbol, equals('\u20AC'.codeUnitAt(0))); + }); + + group('exception tests', () { + void throwsException(void Function() f) { + expect(f, throwsA(isA())); + } + + test('Example throw exception', () { + throwsException(Example.throwException); + }); + + test('Exception from method returning Object', () { + throwsException(Exceptions.staticObjectMethod); + throwsException(Exceptions.staticObjectArrayMethod); + final x = Exceptions(); + throwsException(x.objectMethod); + throwsException(x.objectArrayMethod); + }); + + test('Exception from method returning int', () { + throwsException(Exceptions.staticIntMethod); + throwsException(Exceptions.staticIntArrayMethod); + final x = Exceptions(); + throwsException(x.intMethod); + throwsException(x.intArrayMethod); + }); + + test('Exception from constructor', () { + throwsException(() => Exceptions.ctor1(6.8)); + throwsException(() => Exceptions.ctor2(1, 2, 3, 4, 5, 6)); + }); + + test('Exception contains error message & stack trace', () { + try { + Exceptions.throwLoremIpsum(); + } on JniException catch (e) { + expect(e.message, stringContainsInOrder(["Lorem Ipsum"])); + expect( + e.toString(), + stringContainsInOrder(["Lorem Ipsum", "throwLoremIpsum"]), + ); + return; + } + throw AssertionError("No exception was thrown"); + }); + }); + + group('generics', () { + test('GrandParent constructor', () { + using((arena) { + final grandParent = GrandParent('Hello'.toJString()..deletedIn(arena)) + ..deletedIn(arena); + expect(grandParent, isA>()); + expect(grandParent.$type, isA<$GrandParentType>()); + expect(grandParent.value.toDartString(deleteOriginal: true), 'Hello'); + }); + }); + test('MyStack', () { + using((arena) { + final stack = MyStack(T: JString.type)..deletedIn(arena); + stack.push('Hello'.toJString()..deletedIn(arena)); + stack.push('World'.toJString()..deletedIn(arena)); + expect(stack.pop().toDartString(deleteOriginal: true), 'World'); + expect(stack.pop().toDartString(deleteOriginal: true), 'Hello'); + }); + }); + test('MyMap', () { + using((arena) { + final map = MyMap(K: JString.type, V: Example.type)..deletedIn(arena); + final helloExample = Example.ctor1(1)..deletedIn(arena); + final worldExample = Example.ctor1(2)..deletedIn(arena); + map.put('Hello'.toJString()..deletedIn(arena), helloExample); + map.put('World'.toJString()..deletedIn(arena), worldExample); + expect( + (map.get0('Hello'.toJString()..deletedIn(arena))..deletedIn(arena)) + .getNumber(), + 1, + ); + expect( + (map.get0('World'.toJString()..deletedIn(arena))..deletedIn(arena)) + .getNumber(), + 2, + ); + expect( + ((map.entryStack()..deletedIn(arena)).pop()..deletedIn(arena)) + .key + .castTo(JString.type, deleteOriginal: true) + .toDartString(deleteOriginal: true), + anyOf('Hello', 'World'), + ); + }); + }); + group('classes extending generics', () { + test('StringStack', () { + using((arena) { + final stringStack = StringStack()..deletedIn(arena); + stringStack.push('Hello'.toJString()..deletedIn(arena)); + expect( + stringStack.pop().toDartString(deleteOriginal: true), 'Hello'); + }); + }); + test('StringKeyedMap', () { + using((arena) { + final map = StringKeyedMap(V: Example.type)..deletedIn(arena); + final example = Example()..deletedIn(arena); + map.put('Hello'.toJString()..deletedIn(arena), example); + expect( + (map.get0('Hello'.toJString()..deletedIn(arena)) + ..deletedIn(arena)) + .getNumber(), + 0, + ); + }); + }); + test('StringValuedMap', () { + using((arena) { + final map = StringValuedMap(K: Example.type)..deletedIn(arena); + final example = Example()..deletedIn(arena); + map.put(example, 'Hello'.toJString()..deletedIn(arena)); + expect( + map.get0(example).toDartString(deleteOriginal: true), + 'Hello', + ); + }); + }); + test('StringMap', () { + using((arena) { + final map = StringMap()..deletedIn(arena); + map.put('hello'.toJString()..deletedIn(arena), + 'world'.toJString()..deletedIn(arena)); + expect( + map + .get0('hello'.toJString()..deletedIn(arena)) + .toDartString(deleteOriginal: true), + 'world', + ); + }); + }); + }); + test('superclass count', () { + expect(JObject.type.superCount, 0); + expect(MyMap.type(JObject.type, JObject.type).superCount, 1); + expect(StringKeyedMap.type(JObject.type).superCount, 2); + expect(StringValuedMap.type(JObject.type).superCount, 2); + expect(StringMap.type.superCount, 3); + }); + test('nested generics', () { + using((arena) { + final grandParent = + GrandParent(T: JString.type, "!".toJString()..deletedIn(arena)) + ..deletedIn(arena); + expect( + grandParent.value.toDartString(deleteOriginal: true), + "!", + ); + + final strStaticParent = GrandParent.stringStaticParent() + ..deletedIn(arena); + expect( + strStaticParent.value.toDartString(deleteOriginal: true), + "Hello", + ); + + final exampleStaticParent = GrandParent.varStaticParent( + S: Example.type, Example()..deletedIn(arena)) + ..deletedIn(arena); + expect( + (exampleStaticParent.value..deletedIn(arena)).getNumber(), + 0, + ); + + final strParent = grandParent.stringParent()..deletedIn(arena); + expect( + strParent.parentValue + .castTo(JString.type, deleteOriginal: true) + .toDartString(deleteOriginal: true), + "!", + ); + expect( + strParent.value.toDartString(deleteOriginal: true), + "Hello", + ); + + final exampleParent = grandParent.varParent( + S: Example.type, Example()..deletedIn(arena)) + ..deletedIn(arena); + expect( + exampleParent.parentValue + .castTo(JString.type, deleteOriginal: true) + .toDartString(deleteOriginal: true), + "!", + ); + expect( + (exampleParent.value..deletedIn(arena)).getNumber(), + 0, + ); + // TODO(#139): test constructing Child, currently does not work due + // to a problem with C-bindings. + }); + }); + }); + group('Generic type inference', () { + test('MyStack.of1', () { + using((arena) { + final emptyStack = MyStack(T: JString.type)..deletedIn(arena); + expect(emptyStack.size(), 0); + final stack = MyStack.of1( + "Hello".toJString()..deletedIn(arena), + )..deletedIn(arena); + expect(stack, isA>()); + expect(stack.$type, isA<$MyStackType>()); + expect( + stack.pop().toDartString(deleteOriginal: true), + "Hello", + ); + }); + }); + test('MyStack.of 2 strings', () { + using((arena) { + final stack = MyStack.of2( + "Hello".toJString()..deletedIn(arena), + "World".toJString()..deletedIn(arena), + )..deletedIn(arena); + expect(stack, isA>()); + expect(stack.$type, isA<$MyStackType>()); + expect( + stack.pop().toDartString(deleteOriginal: true), + "World", + ); + expect( + stack.pop().toDartString(deleteOriginal: true), + "Hello", + ); + }); + }); + test('MyStack.of a string and an array', () { + using((arena) { + final array = JArray.filled(1, "World".toJString()..deletedIn(arena)) + ..deletedIn(arena); + final stack = MyStack.of2( + "Hello".toJString()..deletedIn(arena), + array, + )..deletedIn(arena); + expect(stack, isA>()); + expect(stack.$type, isA<$MyStackType>()); + expect( + stack + .pop() + .castTo(JArray.type(JString.type), deleteOriginal: true)[0] + .toDartString(deleteOriginal: true), + "World", + ); + expect( + stack + .pop() + .castTo(JString.type, deleteOriginal: true) + .toDartString(deleteOriginal: true), + "Hello", + ); + }); + }); + test('MyStack.from array of string', () { + using((arena) { + final array = JArray.filled(1, "Hello".toJString()..deletedIn(arena)) + ..deletedIn(arena); + final stack = MyStack.fromArray(array)..deletedIn(arena); + expect(stack, isA>()); + expect(stack.$type, isA<$MyStackType>()); + expect( + stack.pop().toDartString(deleteOriginal: true), + "Hello", + ); + }); + }); + test('MyStack.fromArrayOfArrayOfGrandParents', () { + using((arena) { + final firstDimention = JArray.filled( + 1, + GrandParent("Hello".toJString()..deletedIn(arena)) + ..deletedIn(arena), + )..deletedIn(arena); + final twoDimentionalArray = JArray.filled(1, firstDimention) + ..deletedIn(arena); + final stack = + MyStack.fromArrayOfArrayOfGrandParents(twoDimentionalArray) + ..deletedIn(arena); + expect(stack, isA>()); + expect(stack.$type, isA<$MyStackType>()); + expect( + stack.pop().toDartString(deleteOriginal: true), + "Hello", + ); + }); + }); + }); + }); + 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 (int i = 0; i < k4; i++) { + final e = Example.ctor1(i); + expect(e.getNumber(), equals(i)); + } + }); + test('Create many JNI refs with scoped deletion', () { + for (int i = 0; i < k256; i++) { + using((arena) { + final e = Example.ctor1(i)..deletedIn(arena); + expect(e.getNumber(), equals(i)); + }); + } + }); + test('Create many JNI refs with scoped deletion, in batches', () { + for (int i = 0; i < 256; i++) { + using((arena) { + for (int i = 0; i < 1024; i++) { + final e = Example.ctor1(i)..deletedIn(arena); + expect(e.getNumber(), equals(i)); + } + }); + } + }); + test('Create large number of JNI refs with manual delete', () { + for (int i = 0; i < k256; i++) { + final e = Example.ctor1(i); + expect(e.getNumber(), equals(i)); + e.delete(); + } + }); + test('Method returning primitive type does not create references', () { + using((arena) { + final e = Example.ctor1(64)..deletedIn(arena); + for (int i = 0; i < k256; i++) { + expect(e.getNumber(), equals(64)); + } + }); + }); + test('Class references are cached', () { + final asterisk = '*'.codeUnitAt(0); + for (int 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)); + }); + } + + if (!Platform.isAndroid) { + testPassageOfTime(1); + testPassageOfTime(4); + } + }); +} diff --git a/pkgs/jnigen/test/summary_generation_test.dart b/pkgs/jnigen/test/summary_generation_test.dart index e3582c68e..8a4eab157 100644 --- a/pkgs/jnigen/test/summary_generation_test.dart +++ b/pkgs/jnigen/test/summary_generation_test.dart @@ -42,14 +42,6 @@ void deleteTempDir(Directory directory) { } } -List findFiles(Directory dir, String suffix) { - return dir - .listSync(recursive: true) - .map((entry) => relative(entry.path, from: dir.path)) - .where((path) => path.endsWith(suffix)) - .toList(); -} - /// Packs files indicated by [artifacts], each relative to [artifactDir] into /// a JAR file at [jarPath]. Future createJar({ @@ -57,25 +49,11 @@ Future createJar({ required List artifacts, required String jarPath, }) async { - final status = await runCommand( + await runCommand( 'jar', ['cf', relative(jarPath, from: artifactDir), ...artifacts], workingDirectory: artifactDir, ); - if (status != 0) { - throw ArgumentError('Cannot create JAR from provided arguments'); - } -} - -Future compileJavaFiles(List paths, Directory target) async { - final status = await runCommand( - 'javac', - ['-d', target.absolute.path, ...paths], - workingDirectory: simplePackagePath, - ); - if (status != 0) { - throw ArgumentError('Cannot compile Java sources'); - } } String getClassNameFromPath(String path) { @@ -90,7 +68,7 @@ String getClassNameFromPath(String path) { final simplePackagePath = join('test', 'simple_package_test', 'java'); final simplePackageDir = Directory(simplePackagePath); -final javaFiles = findFiles(simplePackageDir, '.java'); +final javaFiles = findFilesWithSuffix(simplePackageDir, '.java'); final javaClasses = javaFiles.map(getClassNameFromPath).toList(); Config getConfig({List? sourcePath, List? classPath}) { @@ -118,8 +96,8 @@ void main() async { test('Test summary generation from compiled JAR', () async { final targetDir = tempDir.createTempSync("compiled_jar_test_"); - await compileJavaFiles(javaFiles, targetDir); - final classFiles = findFiles(targetDir, '.class'); + await compileJavaFiles(simplePackageDir, targetDir); + final classFiles = findFilesWithSuffix(targetDir, '.class'); final jarPath = join(targetDir.absolute.path, 'classes.jar'); await createJar( artifactDir: targetDir.path, artifacts: classFiles, jarPath: jarPath); @@ -148,7 +126,7 @@ void main() async { test('Test summary generation from compiled classes in directory', () async { final targetDir = tempDir.createTempSync("compiled_classes_test_"); - await compileJavaFiles(javaFiles, targetDir); + await compileJavaFiles(simplePackageDir, targetDir); final config = getConfig(classPath: [targetDir.path]); final summaryClasses = await getSummary(config); expectNonEmptySummary(summaryClasses); @@ -168,8 +146,8 @@ void main() async { jarPath: sourceJarPath, ); - await compileJavaFiles(javaFiles, targetDir); - final classFiles = findFiles(targetDir, '.class'); + await compileJavaFiles(simplePackageDir, targetDir); + final classFiles = findFilesWithSuffix(targetDir, '.class'); final classesJarPath = join(targetDir.path, 'classes.jar'); await createJar( artifactDir: targetDir.path, diff --git a/pkgs/jnigen/test/test_util/bindings_test_setup.dart b/pkgs/jnigen/test/test_util/bindings_test_setup.dart new file mode 100644 index 000000000..b4d292cbd --- /dev/null +++ b/pkgs/jnigen/test/test_util/bindings_test_setup.dart @@ -0,0 +1,77 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +// Tests on generated code. +// +// Both the simple java example & jackson core classes example have tests in +// same file, because the test runner will reuse the process, which leads to +// reuse of the old JVM with old classpath if we have separate tests with +// different classpaths. + +import 'dart:io'; + +import 'package:jni/jni.dart'; +import 'package:path/path.dart' hide equals; + +import 'test_util.dart'; + +final simplePackageTest = join('test', 'simple_package_test'); +final jacksonCoreTest = join('test', 'jackson_core_test'); +final kotlinTest = join('test', 'kotlin_test'); +final jniJar = join(kotlinTest, 'jni.jar'); + +final simplePackageTestJava = join(simplePackageTest, 'java'); +final kotlinTestKotlin = join(kotlinTest, 'kotlin'); + +late Directory tempClassDir; + +Future bindingsTestSetup() async { + await runCommand('dart', [ + 'run', + 'jni:setup', + '-p', + 'jni', + '-s', + join(simplePackageTest, 'c_based', 'c_bindings'), + '-s', + join(kotlinTest, 'c_based', 'c_bindings'), + '-s', + join(jacksonCoreTest, 'third_party', 'c_based', 'c_bindings'), + ]); + tempClassDir = + Directory.current.createTempSync("jnigen_runtime_test_classpath_"); + await compileJavaFiles(Directory(simplePackageTestJava), tempClassDir); + await runCommand('dart', [ + 'run', + 'jnigen:download_maven_jars', + '--config', + join(jacksonCoreTest, 'jnigen.yaml') + ]); + + final jacksonJars = await getJarPaths(join(jacksonCoreTest, 'third_party')); + + await runCommand( + 'mvn', + ['package'], + workingDirectory: kotlinTestKotlin, + runInShell: true, + ); + // Jar including Kotlin runtime and dependencies. + final kotlinTestJar = + join(kotlinTestKotlin, 'target', 'kotlin_test-jar-with-dependencies.jar'); + + if (!Platform.isAndroid) { + Jni.spawn(dylibDir: join('build', 'jni_libs'), classPath: [ + jniJar, + tempClassDir.path, + ...jacksonJars, + kotlinTestJar, + ]); + } + Jni.initDLApi(); +} + +void bindingsTestTeardown() { + tempClassDir.deleteSync(recursive: true); +} diff --git a/pkgs/jnigen/test/test_util/callback_types.dart b/pkgs/jnigen/test/test_util/callback_types.dart new file mode 100644 index 000000000..3b3356e7d --- /dev/null +++ b/pkgs/jnigen/test/test_util/callback_types.dart @@ -0,0 +1,12 @@ +// 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 +// BSD-style license that can be found in the LICENSE file. + +// These definitions could be in `test_util` but these are imported by android +// integration tests, and we test_util imports several parts of package:jnigen. + +typedef TestCaseCallback = void Function(); +typedef TestRunnerCallback = void Function( + String description, + TestCaseCallback test, +); diff --git a/pkgs/jnigen/test/test_util/test_util.dart b/pkgs/jnigen/test/test_util/test_util.dart index 450e28a0f..4ac90ac92 100644 --- a/pkgs/jnigen/test/test_util/test_util.dart +++ b/pkgs/jnigen/test/test_util/test_util.dart @@ -29,7 +29,7 @@ Future isEmptyOrNotExistDir(String path) async { } /// Runs command, and prints output only if the exit status is non-zero. -Future runCommand(String exec, List args, +Future runCommandReturningStatus(String exec, List args, {String? workingDirectory, bool runInShell = false}) async { final proc = await Process.run(exec, args, workingDirectory: workingDirectory, runInShell: runInShell); @@ -42,6 +42,25 @@ Future runCommand(String exec, List args, return proc.exitCode; } +Future runCommand( + String exec, + List args, { + String? workingDirectory, + bool runInShell = false, + String? messageOnFailure, +}) async { + final status = await runCommandReturningStatus( + exec, + args, + workingDirectory: workingDirectory, + runInShell: runInShell, + ); + if (status != 0) { + final message = messageOnFailure ?? 'Failed to execute $exec'; + throw Exception('$message: Command exited with return code $status'); + } +} + /// List all JAR files in [testRoot]/jar Future> getJarPaths(String testRoot) async { final jarPath = join(testRoot, 'jar'); @@ -101,8 +120,10 @@ Future _generateTempBindings(Config config, Directory tempDir) async { /// /// If the config generates C code, [cReferenceBindings] must be a non-null /// directory path. -Future generateAndCompareBindings(Config config, - String dartReferenceBindings, String? cReferenceBindings) async { +Future generateAndCompareBindings(Config config) async { + final dartReferenceBindings = + config.outputConfig.dartConfig.path.toFilePath(); + final cReferenceBindings = config.outputConfig.cConfig?.path.toFilePath(); final currentDir = Directory.current; final tempDir = currentDir.createTempSync("jnigen_test_temp"); final tempSrc = tempDir.uri.resolve("src/"); @@ -153,8 +174,74 @@ Future failIfSummarizerNotBuilt() async { } } +const bindingTests = [ + 'jackson_core_test', + 'simple_package_test', + 'kotlin_test', +]; + +const registrantName = 'runtime_test_registrant.dart'; +const replicaName = 'runtime_test_registrant_dartonly_generated.dart'; + +void warnIfRuntimeTestsAreOutdated() { + final runtimeTests = join('test', 'generated_runtime_test.dart'); + if (!File(runtimeTests).existsSync()) { + log.fatal('Runtime test files not found. To run binding ' + 'runtime tests, please generate them by running ' + '`dart run tool/generate_runtime_tests.dart`'); + } + const regenInstr = 'Please run `dart run tool/generate_runtime_tests.dart` ' + 'and try again.'; + for (var testName in bindingTests) { + final registrant = File(join('test', testName, registrantName)); + final replica = File(join('test', testName, replicaName)); + if (!replica.existsSync()) { + log.fatal( + 'One or more generated runtime tests do not exist. $regenInstr', + ); + } + if (replica.lastModifiedSync().isBefore(registrant.lastModifiedSync())) { + log.fatal( + 'One or more generated runtime tests are not up-to-date. $regenInstr', + ); + } + } +} + /// Verifies if locally built dependencies (currently `ApiSummarizer`) /// are up-to-date. Future checkLocallyBuiltDependencies() async { await failIfSummarizerNotBuilt(); + warnIfRuntimeTestsAreOutdated(); +} + +void generateAndCompareBothModes( + String description, + Config cBasedConfig, + Config dartOnlyConfig, +) { + test('$description (cBased)', () async { + await generateAndCompareBindings(cBasedConfig); + }); + test('$description (dartOnly)', () async { + await generateAndCompareBindings(dartOnlyConfig); + }); +} + +List findFilesWithSuffix(Directory dir, String suffix) { + return dir + .listSync(recursive: true) + .map((entry) => relative(entry.path, from: dir.path)) + .where((path) => path.endsWith(suffix)) + .toList(); +} + +Future compileJavaFiles(Directory root, Directory target) async { + final javaFiles = findFilesWithSuffix(root, '.java'); + await runCommand( + 'javac', + ['-d', target.absolute.path, ...javaFiles], + workingDirectory: root.path, + messageOnFailure: 'Cannot compile java sources', + ); } diff --git a/pkgs/jnigen/tool/generate_runtime_tests.dart b/pkgs/jnigen/tool/generate_runtime_tests.dart new file mode 100644 index 000000000..75a1ea2fb --- /dev/null +++ b/pkgs/jnigen/tool/generate_runtime_tests.dart @@ -0,0 +1,183 @@ +// 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 'dart:io'; + +import 'package:path/path.dart'; +import 'package:args/args.dart'; + +import 'package:jnigen/src/logging/logging.dart'; + +final lineBreak = Platform.isWindows ? '\r\n' : '\n'; + +void runCommand(String exec, List args) { + final proc = Process.runSync(exec, args, runInShell: true); + log.info('Execute $exec ${args.join(" ")}'); + if (proc.exitCode != 0) { + exitCode = proc.exitCode; + printError(proc.stdout); + printError(proc.stderr); + throw Exception('Command failed: $exec ${args.join(" ")}'); + } +} + +const testPath = 'test'; +const registrantFileName = 'runtime_test_registrant.dart'; +const dartOnlyRegistrantFileName = + 'runtime_test_registrant_dartonly_generated.dart'; + +// Paths of generated files, should not be checked in. +// If you change this, add the corresponding entry to .gitignore as well. +const replicaSuffix = '_dartonly_generated.dart'; +final runnerFilePath = join(testPath, 'generated_runtime_test.dart'); +final androidRunnerFilePath = + join('android_test_runner', 'integration_test', 'runtime_test.dart'); + +final generatedComment = + '// Generated file. Do not edit or check-in to version control.$lineBreak'; +const copyright = ''' +// 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. +'''; + +const bindingTests = [ + 'jackson_core_test', + 'simple_package_test', + 'kotlin_test', +]; + +const hasThirdPartyDir = {'jackson_core_test'}; + +final _generatedFiles = [ + for (var testName in bindingTests) + join(testPath, testName, dartOnlyRegistrantFileName), + runnerFilePath, + androidRunnerFilePath, +]; + +void generateReplicasAndRunner() { + final imports = {}; + for (var testName in bindingTests) { + final registrant = join(testName, registrantFileName); + final registrantFile = File(join(testPath, registrant)); + final contents = registrantFile + .readAsStringSync() + .replaceAll('c_based/dart_bindings/', 'dart_only/dart_bindings/'); + + final replica = registrant.replaceAll('.dart', replicaSuffix); + final replicaFile = File(join(testPath, replica)); + replicaFile.writeAsStringSync('$generatedComment$lineBreak$contents'); + log.info('Generated $replica'); + imports['${testName}_c_based'] = + Uri.file(registrant).toFilePath(windows: false); + imports['${testName}_dart_only'] = + Uri.file(replica).toFilePath(windows: false); + } + final importStrings = imports.entries + .map((e) => 'import "${e.value}" as ${e.key};') + .join(lineBreak); + final androidImportStrings = imports.entries + .map((e) => 'import "../../test/${e.value}" as ${e.key};') + .join(lineBreak); + final runStrings = imports.keys + .map((name) => '$name.registerTests("$name", test);') + .join('$lineBreak '); + final runnerProgram = ''' +$generatedComment +$copyright +import 'package:test/test.dart'; +import 'test_util/bindings_test_setup.dart' as setup; + +$importStrings + +void main() { + setUpAll(setup.bindingsTestSetup); + $runStrings + tearDownAll(setup.bindingsTestTeardown); +} +'''; + final runnerFile = File(runnerFilePath); + runnerFile.writeAsStringSync(runnerProgram); + log.info('Generated runner $runnerFilePath'); + + final androidRunnerProgram = ''' +$generatedComment +$copyright +import "package:flutter_test/flutter_test.dart"; +import "package:jni/jni.dart"; + +$androidImportStrings + +typedef TestCaseCallback = void Function(); + +void test(String description, TestCaseCallback testCase) { + testWidgets(description, (widgetTester) async => testCase()); +} + +void main() { + Jni.initDLApi(); + $runStrings +} +'''; + File(androidRunnerFilePath).writeAsStringSync(androidRunnerProgram); + log.info('Generated android runner: $androidRunnerFilePath'); + + final cMakePath = + join('android_test_runner', 'android', 'app', 'CMakeLists.txt'); + + final cmakeSubdirs = bindingTests.map((testName) { + final indirect = hasThirdPartyDir.contains(testName) ? '/third_party' : ''; + return 'add_subdirectory' + '(../../../test/$testName$indirect/c_based/c_bindings ' + '${testName}_build)'; + }).join(lineBreak); + final cMakeConfig = ''' +## Parent CMake for Android native build target. This will build +## all C bindings from tests. + +cmake_minimum_required(VERSION 3.10) + +project(simple_package VERSION 0.0.1 LANGUAGES C) + +$cmakeSubdirs +'''; + File(cMakePath).writeAsStringSync(cMakeConfig); + log.info('Wrote Android CMake file: $cMakePath'); +} + +void cleanup() { + for (var path in _generatedFiles) { + File(path).deleteSync(); + log.info('Deleted $path'); + } +} + +void main(List args) async { + final parser = ArgParser() + ..addFlag( + 'help', + abbr: 'h', + help: 'show help', + negatable: false, + ) + ..addFlag( + 'clean', + abbr: 'c', + help: 'clear generated files', + negatable: false, + ); + final argResults = parser.parse(args); + if (argResults['help']) { + stderr.writeln( + 'Generates runtime tests for both Dart-only and C based bindings.'); + stderr.writeln(parser.usage); + return; + } else if (argResults['clean']) { + cleanup(); + } else { + generateReplicasAndRunner(); + runCommand('dart', ['format', ..._generatedFiles]); + } +} From 995c530ae6ad0e39f29622d2f03ae332d95b018d Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Tue, 2 May 2023 15:54:53 +0200 Subject: [PATCH 085/139] [jnigen] 0.4.0 (https://github.com/dart-lang/jnigen/issues/270) --- pkgs/jni/CHANGELOG.md | 3 +++ pkgs/jni/pubspec.yaml | 2 +- pkgs/jnigen/CHANGELOG.md | 4 +++- pkgs/jnigen/pubspec.yaml | 2 +- pkgs/jnigen/test/kotlin_test/runtime_test_registrant.dart | 2 +- .../github/dart_lang/jnigen/simple_package/Exceptions.java | 1 + .../test/simple_package_test/runtime_test_registrant.dart | 2 +- 7 files changed, 11 insertions(+), 5 deletions(-) diff --git a/pkgs/jni/CHANGELOG.md b/pkgs/jni/CHANGELOG.md index bb1c61c95..5847f004f 100644 --- a/pkgs/jni/CHANGELOG.md +++ b/pkgs/jni/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.4.0 +* Type classes now have `superCount` and `superType` getters used for type inference. + ## 0.3.0 * Added `PortContinuation` used for `suspend fun` in Kotlin. * `dartjni` now depends on `dart_api_dl.h`. diff --git a/pkgs/jni/pubspec.yaml b/pkgs/jni/pubspec.yaml index e0a3771dd..7dc42d5d8 100644 --- a/pkgs/jni/pubspec.yaml +++ b/pkgs/jni/pubspec.yaml @@ -1,6 +1,6 @@ name: jni description: Library to access JNI from dart and flutter -version: 0.3.0 +version: 0.4.0 repository: https://github.com/dart-lang/jnigen/tree/main/jni environment: diff --git a/pkgs/jnigen/CHANGELOG.md b/pkgs/jnigen/CHANGELOG.md index 1516220f2..5c8b9caed 100644 --- a/pkgs/jnigen/CHANGELOG.md +++ b/pkgs/jnigen/CHANGELOG.md @@ -1,9 +1,11 @@ -## 0.4.0-dev +## 0.4.0 * **Breaking Change** ([#145](https://github.com/dart-lang/jnigen/issues/145)): Type arguments are now named instead of positional. * Type parameters can now be inferred when possible. * Fixed a bug where passing a `long` argument truncated it to `int` in pure dart bindings. * Removed array extensions from the generated code. * Added the ability to use source dependencies from Gradle. +* Fixed an issue with the field setter. +* Fixed an issue where exceptions were not properly thrown in pure Dart bindings. ## 0.3.0 * Added the option to convert Kotlin `suspend fun` to Dart async methods. Add `suspend_fun_to_async: true` to `jnigen.yaml`. diff --git a/pkgs/jnigen/pubspec.yaml b/pkgs/jnigen/pubspec.yaml index 48092a88a..1da9c68c7 100644 --- a/pkgs/jnigen/pubspec.yaml +++ b/pkgs/jnigen/pubspec.yaml @@ -3,7 +3,7 @@ # BSD-style license that can be found in the LICENSE file. name: jnigen -version: 0.4.0-dev +version: 0.4.0 description: Experimental generator for FFI+JNI bindings. repository: https://github.com/dart-lang/jnigen/tree/main/jnigen diff --git a/pkgs/jnigen/test/kotlin_test/runtime_test_registrant.dart b/pkgs/jnigen/test/kotlin_test/runtime_test_registrant.dart index f99e3d444..642622bdb 100644 --- a/pkgs/jnigen/test/kotlin_test/runtime_test_registrant.dart +++ b/pkgs/jnigen/test/kotlin_test/runtime_test_registrant.dart @@ -1,4 +1,4 @@ -// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file +// 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. 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 29490894f..e0e79b344 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 @@ -9,6 +9,7 @@ public class Exceptions { public Exceptions() {} + // constructor throwing exception public Exceptions(float x) { throw new IllegalArgumentException("Float is not a serious type"); 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 41747e01b..d46dcf713 100644 --- a/pkgs/jnigen/test/simple_package_test/runtime_test_registrant.dart +++ b/pkgs/jnigen/test/simple_package_test/runtime_test_registrant.dart @@ -1,4 +1,4 @@ -// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file +// 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. From 06afdf117f989e7f538066df10e9408361c27618 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Thu, 4 May 2023 16:22:21 +0200 Subject: [PATCH 086/139] [jnigen] Boxed types + Map + Set + List (https://github.com/dart-lang/jnigen/issues/271) * make primitive types lowercased * remove part statements * add jset, jlist, jmap and jiterator * add JNumber and JBoolean, JInteger and other boxed types * increase coverage --- pkgs/jni/CHANGELOG.md | 4 + .../integration_test/on_device_jni_test.dart | 8 + pkgs/jni/lib/internal_helpers_for_jnigen.dart | 2 +- pkgs/jni/lib/jni.dart | 9 +- pkgs/jni/lib/src/accessors.dart | 2 +- pkgs/jni/lib/src/jarray.dart | 80 +- pkgs/jni/lib/src/jexceptions.dart | 4 +- pkgs/jni/lib/src/jni.dart | 14 +- pkgs/jni/lib/src/jobject.dart | 126 +- pkgs/jni/lib/src/jprimitives.dart | 87 +- pkgs/jni/lib/src/jreference.dart | 42 +- pkgs/jni/lib/src/jvalues.dart | 7 +- pkgs/jni/lib/src/lang/jboolean.dart | 66 + pkgs/jni/lib/src/lang/jbyte.dart | 55 + pkgs/jni/lib/src/lang/jdouble.dart | 54 + pkgs/jni/lib/src/lang/jfloat.dart | 56 + pkgs/jni/lib/src/lang/jinteger.dart | 56 + pkgs/jni/lib/src/lang/jlong.dart | 55 + pkgs/jni/lib/src/lang/jnumber.dart | 149 + pkgs/jni/lib/src/lang/jshort.dart | 56 + pkgs/jni/lib/src/{ => lang}/jstring.dart | 24 +- pkgs/jni/lib/src/lang/lang.dart | 13 + pkgs/jni/lib/src/types.dart | 23 +- pkgs/jni/lib/src/util/jiterator.dart | 91 + pkgs/jni/lib/src/util/jlist.dart | 293 ++ pkgs/jni/lib/src/util/jmap.dart | 187 ++ pkgs/jni/lib/src/util/jset.dart | 228 ++ pkgs/jni/lib/src/util/util.dart | 8 + pkgs/jni/pubspec.yaml | 2 +- pkgs/jni/test/boxed_test.dart | 130 + pkgs/jni/test/exception_test.dart | 7 +- pkgs/jni/test/jarray_test.dart | 85 +- pkgs/jni/test/jlist_test.dart | 216 ++ pkgs/jni/test/jmap_test.dart | 166 ++ pkgs/jni/test/jset_test.dart | 202 ++ pkgs/jni/test/type_test.dart | 50 +- pkgs/jnigen/CHANGELOG.md | 3 + pkgs/jnigen/analysis_options.yaml | 1 - pkgs/jnigen/android_test_runner/lib/main.dart | 2 +- .../in_app_java/lib/android_utils.dart | 75 +- .../kotlin_plugin/lib/kotlin_bindings.dart | 4 +- .../lib/notifications.dart | 4 +- .../org/apache/pdfbox/pdmodel/PDDocument.dart | 12 +- .../pdfbox/pdmodel/PDDocumentInformation.dart | 4 +- .../apache/pdfbox/text/PDFTextStripper.dart | 4 +- .../lib/src/bindings/dart_generator.dart | 60 +- pkgs/jnigen/lib/src/elements/elements.dart | 18 +- pkgs/jnigen/pubspec.yaml | 2 +- .../fasterxml/jackson/core/JsonFactory.dart | 20 +- .../fasterxml/jackson/core/JsonParser.dart | 26 +- .../com/fasterxml/jackson/core/JsonToken.dart | 12 +- .../dart_only/dart_bindings/_init.dart | 23 - .../fasterxml/jackson/core/JsonFactory.dart | 688 ++--- .../fasterxml/jackson/core/JsonParser.dart | 794 ++--- .../com/fasterxml/jackson/core/JsonToken.dart | 85 +- .../third_party/dart_only/lib/_init.dart | 23 - .../fasterxml/jackson/core/JsonFactory.dart | 1879 ------------ .../fasterxml/jackson/core/JsonParser.dart | 2640 ----------------- .../com/fasterxml/jackson/core/JsonToken.dart | 223 -- .../com/fasterxml/jackson/core/_package.dart | 3 - .../c_based/dart_bindings/kotlin.dart | 4 +- .../dart_only/dart_bindings/kotlin.dart | 31 +- .../c_based/dart_bindings/simple_package.dart | 120 +- .../dart_bindings/simple_package.dart | 1022 +++---- .../runtime_test_registrant.dart | 18 + 65 files changed, 4024 insertions(+), 6433 deletions(-) create mode 100644 pkgs/jni/lib/src/lang/jboolean.dart create mode 100644 pkgs/jni/lib/src/lang/jbyte.dart create mode 100644 pkgs/jni/lib/src/lang/jdouble.dart create mode 100644 pkgs/jni/lib/src/lang/jfloat.dart create mode 100644 pkgs/jni/lib/src/lang/jinteger.dart create mode 100644 pkgs/jni/lib/src/lang/jlong.dart create mode 100644 pkgs/jni/lib/src/lang/jnumber.dart create mode 100644 pkgs/jni/lib/src/lang/jshort.dart rename pkgs/jni/lib/src/{ => lang}/jstring.dart (79%) create mode 100644 pkgs/jni/lib/src/lang/lang.dart create mode 100644 pkgs/jni/lib/src/util/jiterator.dart create mode 100644 pkgs/jni/lib/src/util/jlist.dart create mode 100644 pkgs/jni/lib/src/util/jmap.dart create mode 100644 pkgs/jni/lib/src/util/jset.dart create mode 100644 pkgs/jni/lib/src/util/util.dart create mode 100644 pkgs/jni/test/boxed_test.dart create mode 100644 pkgs/jni/test/jlist_test.dart create mode 100644 pkgs/jni/test/jmap_test.dart create mode 100644 pkgs/jni/test/jset_test.dart delete mode 100644 pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/_init.dart delete mode 100644 pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/_init.dart delete mode 100644 pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/com/fasterxml/jackson/core/JsonFactory.dart delete mode 100644 pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/com/fasterxml/jackson/core/JsonParser.dart delete mode 100644 pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/com/fasterxml/jackson/core/JsonToken.dart delete mode 100644 pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/com/fasterxml/jackson/core/_package.dart diff --git a/pkgs/jni/CHANGELOG.md b/pkgs/jni/CHANGELOG.md index 5847f004f..c1367635b 100644 --- a/pkgs/jni/CHANGELOG.md +++ b/pkgs/jni/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.5.0-dev.0 +* **Breaking Change** ([#137](https://github.com/dart-lang/jnigen/issues/137)): Java primitive types are now all lowercase like `jint`, `jshort`, ... +* The bindings for `java.util.Set`, `java.util.Map`, `java.util.List` and the numeric types like `java.lang.Integer`, `java.lang.Boolean`, ... are now included in `package:jni`. + ## 0.4.0 * Type classes now have `superCount` and `superType` getters used for type inference. 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 27be71916..f9ae286cd 100644 --- a/pkgs/jni/example/integration_test/on_device_jni_test.dart +++ b/pkgs/jni/example/integration_test/on_device_jni_test.dart @@ -6,8 +6,12 @@ import 'package:flutter_test/flutter_test.dart'; import '../../test/global_env_test.dart' as global_env_test; import '../../test/exception_test.dart' as exception_test; +import '../../test/jlist_test.dart' as jlist_test; +import '../../test/jmap_test.dart' as jmap_test; import '../../test/jobject_test.dart' as jobject_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; @@ -19,8 +23,12 @@ void main() { final testSuites = [ global_env_test.run, exception_test.run, + jlist_test.run, + jmap_test.run, jobject_test.run, + jset_test.run, jarray_test.run, + boxed_test.run, type_test.run, load_test.run, ]; diff --git a/pkgs/jni/lib/internal_helpers_for_jnigen.dart b/pkgs/jni/lib/internal_helpers_for_jnigen.dart index 0ad5ce16b..7e1fc8e78 100644 --- a/pkgs/jni/lib/internal_helpers_for_jnigen.dart +++ b/pkgs/jni/lib/internal_helpers_for_jnigen.dart @@ -7,5 +7,5 @@ library internal_helpers_for_jnigen; export 'src/jni.dart' show ProtectedJniExtensions; -export 'src/types.dart' show JReference; +export 'src/jreference.dart'; export 'src/accessors.dart'; diff --git a/pkgs/jni/lib/jni.dart b/pkgs/jni/lib/jni.dart index a4a45ec5a..d63fc73a9 100644 --- a/pkgs/jni/lib/jni.dart +++ b/pkgs/jni/lib/jni.dart @@ -64,7 +64,14 @@ export 'src/third_party/generated_bindings.dart' hide JniBindings, JniEnv, JniEnv1, JniExceptionDetails; export 'src/jni.dart' hide ProtectedJniExtensions; export 'src/jvalues.dart' hide JValueArgs, toJValues; -export 'src/types.dart' hide JReference; +export 'src/types.dart'; +export 'src/jarray.dart'; +export 'src/jexceptions.dart'; +export 'src/jobject.dart'; +export 'src/jprimitives.dart'; +export 'src/jreference.dart' show JReferenceUseExtension; +export 'src/lang/lang.dart'; +export 'src/util/util.dart'; export 'package:ffi/ffi.dart' show using, Arena; export 'dart:ffi' show nullptr; diff --git a/pkgs/jni/lib/src/accessors.dart b/pkgs/jni/lib/src/accessors.dart index e2bee8905..b5e843c2a 100644 --- a/pkgs/jni/lib/src/accessors.dart +++ b/pkgs/jni/lib/src/accessors.dart @@ -7,9 +7,9 @@ import 'package:ffi/ffi.dart' show using; import 'package:jni/src/jvalues.dart'; +import 'jexceptions.dart'; import 'third_party/generated_bindings.dart'; import 'jni.dart'; -import 'types.dart'; void _check(JThrowablePtr exception) { if (exception != nullptr) { diff --git a/pkgs/jni/lib/src/jarray.dart b/pkgs/jni/lib/src/jarray.dart index c095da73e..fe92e0540 100644 --- a/pkgs/jni/lib/src/jarray.dart +++ b/pkgs/jni/lib/src/jarray.dart @@ -2,9 +2,19 @@ // 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 +// ignore_for_file: unnecessary_cast, overridden_fields -part of 'types.dart'; +import 'dart:ffi'; + +import 'package:collection/collection.dart'; +import 'package:ffi/ffi.dart'; +import 'package:jni/src/accessors.dart'; +import 'package:jni/src/third_party/generated_bindings.dart'; + +import 'jni.dart'; +import 'jobject.dart'; +import 'jprimitives.dart'; +import 'types.dart'; class JArrayType extends JObjType> { final JType elementType; @@ -38,7 +48,7 @@ class JArray extends JObject { final JType elementType; @override - JArrayType get $type => (_$type ??= type(elementType)) as JArrayType; + late final JArrayType $type = type(elementType) as JArrayType; /// The type which includes information such as the signature of this class. static JObjType> type(JType innerType) => @@ -52,18 +62,18 @@ class JArray extends JObject { /// /// The [length] must be a non-negative integer. factory JArray(JType type, int length) { - if (type._type == JniCallType.objectType && type is JObjType) { + if (type.callType == JniCallType.objectType && type is JObjType) { final clazz = (type as JObjType).getClass(); final array = JArray.fromRef( type, - _accessors.newObjectArray(length, clazz.reference, nullptr).object, + Jni.accessors.newObjectArray(length, clazz.reference, nullptr).object, ); clazz.delete(); return array; } return JArray.fromRef( type, - _accessors.newPrimitiveArray(length, type._type).object, + Jni.accessors.newPrimitiveArray(length, type.callType).object, ); } @@ -76,7 +86,9 @@ class JArray extends JObject { final clazz = fill.getClass(); final array = JArray.fromRef( fill.$type as JObjType, - _accessors.newObjectArray(length, clazz.reference, fill.reference).object, + Jni.accessors + .newObjectArray(length, clazz.reference, fill.reference) + .object, ); clazz.delete(); return array; @@ -86,12 +98,12 @@ class JArray extends JObject { JniResult elementAt(int index, int type) { RangeError.checkValidIndex(index, this); - return _accessors.getArrayElement(reference, index, type); + return Jni.accessors.getArrayElement(reference, index, type); } /// The number of elements in this array. int get length { - return _length ??= _env.GetArrayLength(reference); + return _length ??= Jni.env.GetArrayLength(reference); } } @@ -107,7 +119,7 @@ extension NativeArray on JArray { } } -extension BoolArray on JArray { +extension BoolArray on JArray { bool operator [](int index) { return elementAt(index, JniCallType.booleanType).boolean; } @@ -116,7 +128,7 @@ extension BoolArray on JArray { RangeError.checkValidIndex(index, this); _allocate(sizeOf(), (ptr) { ptr.value = value ? 1 : 0; - _env.SetBooleanArrayRegion(reference, index, 1, ptr); + Jni.env.SetBooleanArrayRegion(reference, index, 1, ptr); }); } @@ -129,12 +141,12 @@ extension BoolArray on JArray { it.forEachIndexed((index, element) { ptr[index] = element ? 1 : 0; }); - _env.SetBooleanArrayRegion(reference, start, size, ptr); + Jni.env.SetBooleanArrayRegion(reference, start, size, ptr); }); } } -extension ByteArray on JArray { +extension ByteArray on JArray { int operator [](int index) { return elementAt(index, JniCallType.byteType).byte; } @@ -143,7 +155,7 @@ extension ByteArray on JArray { RangeError.checkValidIndex(index, this); _allocate(sizeOf(), (ptr) { ptr.value = value; - _env.SetByteArrayRegion(reference, index, 1, ptr); + Jni.env.SetByteArrayRegion(reference, index, 1, ptr); }); } @@ -156,12 +168,12 @@ extension ByteArray on JArray { it.forEachIndexed((index, element) { ptr[index] = element; }); - _env.SetByteArrayRegion(reference, start, size, ptr); + Jni.env.SetByteArrayRegion(reference, start, size, ptr); }); } } -extension CharArray on JArray { +extension CharArray on JArray { String operator [](int index) { return String.fromCharCode( elementAt(index, JniCallType.charType).char, @@ -172,7 +184,7 @@ extension CharArray on JArray { RangeError.checkValidIndex(index, this); _allocate(sizeOf(), (ptr) { ptr.value = value.codeUnits.first; - _env.SetCharArrayRegion(reference, index, 1, ptr); + Jni.env.SetCharArrayRegion(reference, index, 1, ptr); }); } @@ -185,12 +197,12 @@ extension CharArray on JArray { it.forEachIndexed((index, element) { ptr[index] = element.codeUnits.first; }); - _env.SetCharArrayRegion(reference, start, size, ptr); + Jni.env.SetCharArrayRegion(reference, start, size, ptr); }); } } -extension ShortArray on JArray { +extension ShortArray on JArray { int operator [](int index) { return elementAt(index, JniCallType.shortType).short; } @@ -199,7 +211,7 @@ extension ShortArray on JArray { RangeError.checkValidIndex(index, this); _allocate(sizeOf(), (ptr) { ptr.value = value; - _env.SetShortArrayRegion(reference, index, 1, ptr); + Jni.env.SetShortArrayRegion(reference, index, 1, ptr); }); } @@ -212,12 +224,12 @@ extension ShortArray on JArray { it.forEachIndexed((index, element) { ptr[index] = element; }); - _env.SetShortArrayRegion(reference, start, size, ptr); + Jni.env.SetShortArrayRegion(reference, start, size, ptr); }); } } -extension IntArray on JArray { +extension IntArray on JArray { int operator [](int index) { return elementAt(index, JniCallType.intType).integer; } @@ -226,7 +238,7 @@ extension IntArray on JArray { RangeError.checkValidIndex(index, this); _allocate(sizeOf(), (ptr) { ptr.value = value; - _env.SetIntArrayRegion(reference, index, 1, ptr); + Jni.env.SetIntArrayRegion(reference, index, 1, ptr); }); } @@ -239,12 +251,12 @@ extension IntArray on JArray { it.forEachIndexed((index, element) { ptr[index] = element; }); - _env.SetIntArrayRegion(reference, start, size, ptr); + Jni.env.SetIntArrayRegion(reference, start, size, ptr); }); } } -extension LongArray on JArray { +extension LongArray on JArray { int operator [](int index) { return elementAt(index, JniCallType.longType).long; } @@ -253,7 +265,7 @@ extension LongArray on JArray { RangeError.checkValidIndex(index, this); _allocate(sizeOf(), (ptr) { ptr.value = value; - _env.SetLongArrayRegion(reference, index, 1, ptr); + Jni.env.SetLongArrayRegion(reference, index, 1, ptr); }); } @@ -266,12 +278,12 @@ extension LongArray on JArray { it.forEachIndexed((index, element) { ptr[index] = element; }); - _env.SetLongArrayRegion(reference, start, size, ptr); + Jni.env.SetLongArrayRegion(reference, start, size, ptr); }); } } -extension FloatArray on JArray { +extension FloatArray on JArray { double operator [](int index) { return elementAt(index, JniCallType.floatType).float; } @@ -280,7 +292,7 @@ extension FloatArray on JArray { RangeError.checkValidIndex(index, this); _allocate(sizeOf(), (ptr) { ptr.value = value; - _env.SetFloatArrayRegion(reference, index, 1, ptr); + Jni.env.SetFloatArrayRegion(reference, index, 1, ptr); }); } @@ -293,12 +305,12 @@ extension FloatArray on JArray { it.forEachIndexed((index, element) { ptr[index] = element; }); - _env.SetFloatArrayRegion(reference, start, size, ptr); + Jni.env.SetFloatArrayRegion(reference, start, size, ptr); }); } } -extension DoubleArray on JArray { +extension DoubleArray on JArray { double operator [](int index) { return elementAt(index, JniCallType.doubleType).doubleFloat; } @@ -307,7 +319,7 @@ extension DoubleArray on JArray { RangeError.checkValidIndex(index, this); _allocate(sizeOf(), (ptr) { ptr.value = value; - _env.SetDoubleArrayRegion(reference, index, 1, ptr); + Jni.env.SetDoubleArrayRegion(reference, index, 1, ptr); }); } @@ -320,7 +332,7 @@ extension DoubleArray on JArray { it.forEachIndexed((index, element) { ptr[index] = element; }); - _env.SetDoubleArrayRegion(reference, start, size, ptr); + Jni.env.SetDoubleArrayRegion(reference, start, size, ptr); }); } } @@ -333,7 +345,7 @@ extension ObjectArray on JArray { void operator []=(int index, T value) { RangeError.checkValidIndex(index, this); - _env.SetObjectArrayElement(reference, index, value.reference); + Jni.env.SetObjectArrayElement(reference, index, value.reference); } void setRange(int start, int end, Iterable iterable, [int skipCount = 0]) { diff --git a/pkgs/jni/lib/src/jexceptions.dart b/pkgs/jni/lib/src/jexceptions.dart index 3200880aa..4c9cda0c2 100644 --- a/pkgs/jni/lib/src/jexceptions.dart +++ b/pkgs/jni/lib/src/jexceptions.dart @@ -2,7 +2,9 @@ // 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. -part of 'types.dart'; +import 'dart:ffi'; + +import 'package:jni/src/third_party/generated_bindings.dart'; abstract class JException implements Exception {} diff --git a/pkgs/jni/lib/src/jni.dart b/pkgs/jni/lib/src/jni.dart index 97ff46e86..0698b84dc 100644 --- a/pkgs/jni/lib/src/jni.dart +++ b/pkgs/jni/lib/src/jni.dart @@ -9,9 +9,11 @@ import 'dart:isolate'; import 'package:ffi/ffi.dart'; import 'package:path/path.dart'; +import 'jexceptions.dart'; +import 'jobject.dart'; +import 'jreference.dart'; import 'third_party/generated_bindings.dart'; import 'jvalues.dart'; -import 'types.dart'; import 'accessors.dart'; String _getLibraryFileName(String base) { @@ -183,17 +185,13 @@ abstract class Jni { return env; } - static GlobalJniEnv? _env; - - /// Points to a process-wide shared instance of [GlobalJniEnvStruct]. + /// Points to a process-wide shared instance of [GlobalJniEnv]. /// /// It provides an indirection over [JniEnv] so that it can be used from /// any thread, and always returns global object references. - static GlobalJniEnv get env { - return _env ??= GlobalJniEnv(_fetchGlobalEnv()); - } + static final env = GlobalJniEnv(_fetchGlobalEnv()); - static JniAccessors get accessors => JniAccessors(_bindings.GetAccessors()); + static final accessors = JniAccessors(_bindings.GetAccessors()); /// Returns a new PortContinuation. static JObjectPtr newPortContinuation(ReceivePort port) { diff --git a/pkgs/jni/lib/src/jobject.dart b/pkgs/jni/lib/src/jobject.dart index 3eb4074a1..5de5bbdf2 100644 --- a/pkgs/jni/lib/src/jobject.dart +++ b/pkgs/jni/lib/src/jobject.dart @@ -2,7 +2,22 @@ // 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. -part of 'types.dart'; +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; +import 'package:jni/src/accessors.dart'; + +import 'jexceptions.dart'; +import 'jni.dart'; +import 'jreference.dart'; +import 'lang/jstring.dart'; +import 'jvalues.dart'; +import 'third_party/generated_bindings.dart'; +import 'types.dart'; + +// This typedef is needed because void is a keyword and cannot be used in +// type switch like a regular type. +typedef _VoidType = void; class JObjectType extends JObjType { const JObjectType(); @@ -42,7 +57,7 @@ Pointer _getID( final result = using( (arena) => f(ptr, name.toNativeChars(arena), sig.toNativeChars(arena))); if (result.exception != nullptr) { - _accessors.throwException(result.exception); + Jni.accessors.throwException(result.exception); } return result.value.cast(); } @@ -109,7 +124,7 @@ T _callOrGet(int? callType, JniResult Function(int) function) { callType, JniCallType.objectType, {JniCallType.objectType}); final ref = function(finalCallType).object; final ctor = T == String - ? (ref) => _env.toDartString(ref, deleteOriginal: true) + ? (ref) => Jni.env.toDartString(ref, deleteOriginal: true) : (T == JObject ? JObject.fromRef : JString.fromRef); result = ctor(ref) as T; break; @@ -148,8 +163,7 @@ T _getField(int? callType, JniResult Function(int) f) { /// /// This is the base class for classes generated by `jnigen`. class JObject extends JReference { - JObjType? _$type; - JObjType get $type => _$type ??= type; + late final JObjType $type = type; /// The type which includes information such as the signature of this class. static const JObjType type = JObjectType(); @@ -175,40 +189,40 @@ class JObject extends JReference { /// /// This may be a subclass of compile-time class. JClass getClass() { - _ensureNotDeleted(); - final classRef = _env.GetObjectClass(reference); + ensureNotDeleted(); + final classRef = Jni.env.GetObjectClass(reference); if (classRef == nullptr) { - _accessors.throwException(_env.ExceptionOccurred()); + Jni.accessors.throwException(Jni.env.ExceptionOccurred()); } return JClass.fromRef(classRef); } /// Get [JFieldIDPtr] of instance field identified by [fieldName] & [signature]. JFieldIDPtr getFieldID(String fieldName, String signature) { - _ensureNotDeleted(); + ensureNotDeleted(); return _getID( - _accessors.getFieldID, _class.reference, fieldName, signature); + Jni.accessors.getFieldID, _class.reference, fieldName, signature); } /// Get [JFieldIDPtr] of static field identified by [fieldName] & [signature]. JFieldIDPtr getStaticFieldID(String fieldName, String signature) { - _ensureNotDeleted(); + ensureNotDeleted(); return _getID( - _accessors.getStaticFieldID, _class.reference, fieldName, signature); + Jni.accessors.getStaticFieldID, _class.reference, fieldName, signature); } /// Get [JMethodIDPtr] of instance method [methodName] with [signature]. JMethodIDPtr getMethodID(String methodName, String signature) { - _ensureNotDeleted(); + ensureNotDeleted(); return _getID( - _accessors.getMethodID, _class.reference, methodName, signature); + Jni.accessors.getMethodID, _class.reference, methodName, signature); } /// Get [JMethodIDPtr] of static method [methodName] with [signature]. JMethodIDPtr getStaticMethodID(String methodName, String signature) { - _ensureNotDeleted(); - return _getID( - _accessors.getStaticMethodID, _class.reference, methodName, signature); + ensureNotDeleted(); + return _getID(Jni.accessors.getStaticMethodID, _class.reference, + methodName, signature); } /// Retrieve the value of the field using [fieldID]. @@ -221,12 +235,12 @@ class JObject extends JReference { /// If [T] is String or [JObject], required conversions are performed and /// final value is returned. T getField(JFieldIDPtr fieldID, [int? callType]) { - _ensureNotDeleted(); + ensureNotDeleted(); if (callType == JniCallType.voidType) { throw ArgumentError("void is not a valid field type."); } return _getField( - callType, (ct) => _accessors.getField(reference, fieldID, ct)); + callType, (ct) => Jni.accessors.getField(reference, fieldID, ct)); } /// Get value of the field identified by [name] and [signature]. @@ -244,9 +258,9 @@ class JObject extends JReference { if (callType == JniCallType.voidType) { throw ArgumentError("void is not a valid field type."); } - _ensureNotDeleted(); + ensureNotDeleted(); return _getField(callType, - (ct) => _accessors.getStaticField(_class.reference, fieldID, ct)); + (ct) => Jni.accessors.getStaticField(_class.reference, fieldID, ct)); } /// Get value of the static field identified by [name] and [signature]. @@ -264,9 +278,9 @@ class JObject extends JReference { /// /// See [getField] for an explanation about [callType] and return type [T]. T callMethod(JMethodIDPtr methodID, List args, [int? callType]) { - _ensureNotDeleted(); + ensureNotDeleted(); return _callMethod(callType, args, - (ct, jvs) => _accessors.callMethod(reference, methodID, ct, jvs)); + (ct, jvs) => Jni.accessors.callMethod(reference, methodID, ct, jvs)); } /// Call instance method identified by [name] and [signature]. @@ -282,9 +296,12 @@ class JObject extends JReference { /// more details about [args] and [callType]. T callStaticMethod(JMethodIDPtr methodID, List args, [int? callType]) { - _ensureNotDeleted(); - return _callMethod(callType, args, - (ct, jvs) => _accessors.callStaticMethod(reference, methodID, ct, jvs)); + ensureNotDeleted(); + return _callMethod( + callType, + args, + (ct, jvs) => + Jni.accessors.callStaticMethod(reference, methodID, ct, jvs)); } /// Call static method identified by [name] and [signature]. @@ -300,12 +317,31 @@ class JObject extends JReference { T castTo(JObjType type, {bool deleteOriginal = false}) { if (deleteOriginal) { _jClass?.delete(); - _setAsDeleted(); + setAsDeleted(); return type.fromRef(reference); } - final newRef = _env.NewGlobalRef(reference); + final newRef = Jni.env.NewGlobalRef(reference); return type.fromRef(newRef); } + + static final _objectClass = Jni.findJClass('java/lang/Object'); + + static final _hashCodeId = + Jni.accessors.getMethodIDOf(_objectClass.reference, r"hashCode", r"()I"); + @override + int get hashCode => Jni.accessors.callMethodWithArgs( + reference, _hashCodeId, JniCallType.intType, []).integer; + + static final _equalsId = Jni.accessors.getMethodIDOf( + _objectClass.reference, r"equals", r"(Ljava/lang/Object;)Z"); + @override + bool operator ==(Object other) { + if (other is! JObject) { + return false; + } + return Jni.accessors.callMethodWithArgs(reference, _equalsId, + JniCallType.booleanType, [other.reference]).boolean; + } } /// A high level wrapper over a JNI class reference. @@ -315,30 +351,30 @@ class JClass extends JReference { /// Get [JFieldIDPtr] of static field [fieldName] with [signature]. JFieldIDPtr getStaticFieldID(String fieldName, String signature) { - _ensureNotDeleted(); + ensureNotDeleted(); return _getID( - _accessors.getStaticFieldID, reference, fieldName, signature); + Jni.accessors.getStaticFieldID, reference, fieldName, signature); } /// Get [JMethodIDPtr] of static method [methodName] with [signature]. JMethodIDPtr getStaticMethodID(String methodName, String signature) { - _ensureNotDeleted(); + ensureNotDeleted(); return _getID( - _accessors.getStaticMethodID, reference, methodName, signature); + Jni.accessors.getStaticMethodID, reference, methodName, signature); } /// Get [JFieldIDPtr] of field [fieldName] with [signature]. JFieldIDPtr getFieldID(String fieldName, String signature) { - _ensureNotDeleted(); + ensureNotDeleted(); return _getID( - _accessors.getFieldID, reference, fieldName, signature); + Jni.accessors.getFieldID, reference, fieldName, signature); } /// Get [JMethodIDPtr] of method [methodName] with [signature]. JMethodIDPtr getMethodID(String methodName, String signature) { - _ensureNotDeleted(); + ensureNotDeleted(); return _getID( - _accessors.getMethodID, reference, methodName, signature); + Jni.accessors.getMethodID, reference, methodName, signature); } /// Get [JMethodIDPtr] of constructor with [signature]. @@ -351,9 +387,9 @@ class JClass extends JReference { if (callType == JniCallType.voidType) { throw ArgumentError("void is not a valid field type."); } - _ensureNotDeleted(); + ensureNotDeleted(); return _getField( - callType, (ct) => _accessors.getStaticField(reference, fieldID, ct)); + callType, (ct) => Jni.accessors.getStaticField(reference, fieldID, ct)); } /// Get the value of static field identified by [name] and [signature]. @@ -370,9 +406,12 @@ class JClass extends JReference { /// about [args] and [callType]. T callStaticMethod(JMethodIDPtr methodID, List args, [int? callType]) { - _ensureNotDeleted(); - return _callMethod(callType, args, - (ct, jvs) => _accessors.callStaticMethod(reference, methodID, ct, jvs)); + ensureNotDeleted(); + return _callMethod( + callType, + args, + (ct, jvs) => + Jni.accessors.callStaticMethod(reference, methodID, ct, jvs)); } /// Call the static method identified by [name] and [signature]. @@ -386,9 +425,10 @@ class JClass extends JReference { /// Create a new instance of this class with [ctor] and [args]. JObject newInstance(JMethodIDPtr ctor, List args) => using((arena) { - _ensureNotDeleted(); + ensureNotDeleted(); final jArgs = JValueArgs(args, arena); - final res = _accessors.newObject(reference, ctor, jArgs.values).object; + final res = + Jni.accessors.newObject(reference, ctor, jArgs.values).object; return JObject.fromRef(res); }); } diff --git a/pkgs/jni/lib/src/jprimitives.dart b/pkgs/jni/lib/src/jprimitives.dart index c83bf6d4a..f7f8a9aaf 100644 --- a/pkgs/jni/lib/src/jprimitives.dart +++ b/pkgs/jni/lib/src/jprimitives.dart @@ -2,117 +2,122 @@ // 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. -part of 'types.dart'; +// The types here are mapped to primitive types in Java, so they're all in +// lowercase. +// ignore_for_file: camel_case_types + +import 'third_party/generated_bindings.dart'; +import 'types.dart'; abstract class JPrimitive {} -abstract class JByte extends JPrimitive { - static const type = JByteType(); +abstract class jbyte extends JPrimitive { + static const type = jbyteType(); } -class JByteType extends JType { - const JByteType(); +class jbyteType extends JType { + const jbyteType(); @override - int get _type => JniCallType.byteType; + int get callType => JniCallType.byteType; @override String get signature => "B"; } -abstract class JBoolean extends JPrimitive { - static const type = JBooleanType(); +abstract class jboolean extends JPrimitive { + static const type = jbooleanType(); } -class JBooleanType extends JType { - const JBooleanType(); +class jbooleanType extends JType { + const jbooleanType(); @override - int get _type => JniCallType.booleanType; + int get callType => JniCallType.booleanType; @override String get signature => "Z"; } -abstract class JChar extends JPrimitive { - static const type = JCharType(); +abstract class jchar extends JPrimitive { + static const type = jcharType(); } -class JCharType extends JType { - const JCharType(); +class jcharType extends JType { + const jcharType(); @override - int get _type => JniCallType.charType; + int get callType => JniCallType.charType; @override String get signature => "C"; } -abstract class JShort extends JPrimitive { - static const type = JShortType(); +abstract class jshort extends JPrimitive { + static const type = jshortType(); } -class JShortType extends JType { - const JShortType(); +class jshortType extends JType { + const jshortType(); @override - int get _type => JniCallType.shortType; + int get callType => JniCallType.shortType; @override String get signature => "S"; } -abstract class JInt extends JPrimitive { - static const type = JIntType(); +abstract class jint extends JPrimitive { + static const type = jintType(); } -class JIntType extends JType { - const JIntType(); +class jintType extends JType { + const jintType(); @override - int get _type => JniCallType.intType; + int get callType => JniCallType.intType; @override String get signature => "I"; } -abstract class JLong extends JPrimitive { - static const type = JLongType(); +abstract class jlong extends JPrimitive { + static const type = jlongType(); } -class JLongType extends JType { - const JLongType(); +class jlongType extends JType { + const jlongType(); @override - int get _type => JniCallType.longType; + int get callType => JniCallType.longType; @override String get signature => "J"; } -abstract class JFloat extends JPrimitive { - static const type = JFloatType(); +abstract class jfloat extends JPrimitive { + static const type = jfloatType(); } -class JFloatType extends JType { - const JFloatType(); +class jfloatType extends JType { + const jfloatType(); @override - int get _type => JniCallType.floatType; + int get callType => JniCallType.floatType; @override String get signature => "F"; } -abstract class JDouble extends JPrimitive { - static const type = JDoubleType(); +abstract class jdouble extends JPrimitive { + static const type = jdoubleType(); } -class JDoubleType extends JType { - const JDoubleType(); +class jdoubleType extends JType { + const jdoubleType(); @override - int get _type => JniCallType.doubleType; + int get callType => JniCallType.doubleType; @override String get signature => "D"; diff --git a/pkgs/jni/lib/src/jreference.dart b/pkgs/jni/lib/src/jreference.dart index 3a96bb338..94303363c 100644 --- a/pkgs/jni/lib/src/jreference.dart +++ b/pkgs/jni/lib/src/jreference.dart @@ -2,14 +2,34 @@ // 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. -part of 'types.dart'; +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; +import 'package:jni/src/third_party/generated_bindings.dart'; + +import 'jexceptions.dart'; +import 'jni.dart'; + +extension ProtectedJReference on JReference { + void ensureNotDeleted() { + if (_deleted) throw UseAfterFreeException(this, reference); + } + + void setAsDeleted() { + if (_deleted) { + throw DoubleFreeException(this, reference); + } + _deleted = true; + JReference._finalizer.detach(this); + } +} /// A class which holds one or more JNI references, and has a `delete` operation /// which disposes the reference(s). abstract class JReference implements Finalizable { //TODO(PR): Is it safe to cast void *f (void *) to void f (void *)? static final _finalizer = - NativeFinalizer(_env.ptr.ref.DeleteGlobalRef.cast()); + NativeFinalizer(Jni.env.ptr.ref.DeleteGlobalRef.cast()); JReference.fromRef(this.reference) { _finalizer.attach(this, reference, detach: this); @@ -17,29 +37,17 @@ abstract class JReference implements Finalizable { bool _deleted = false; - void _ensureNotDeleted() { - if (_deleted) throw UseAfterFreeException(this, reference); - } - /// Check whether the underlying JNI reference is `null`. bool get isNull => reference == nullptr; /// Returns whether this object is deleted. bool get isDeleted => _deleted; - void _setAsDeleted() { - if (_deleted) { - throw DoubleFreeException(this, reference); - } - _deleted = true; - _finalizer.detach(this); - } - /// Deletes the underlying JNI reference. Further uses will throw /// [UseAfterFreeException]. void delete() { - _setAsDeleted(); - _env.DeleteGlobalRef(reference); + setAsDeleted(); + Jni.env.DeleteGlobalRef(reference); } /// The underlying JNI global object reference. @@ -53,7 +61,7 @@ extension JReferenceUseExtension on T { /// Applies [callback] on [this] object and then delete the underlying JNI /// reference, returning the result of [callback]. R use(R Function(T) callback) { - _ensureNotDeleted(); + ensureNotDeleted(); try { final result = callback(this); delete(); diff --git a/pkgs/jni/lib/src/jvalues.dart b/pkgs/jni/lib/src/jvalues.dart index b34e306f6..cc99b1134 100644 --- a/pkgs/jni/lib/src/jvalues.dart +++ b/pkgs/jni/lib/src/jvalues.dart @@ -5,9 +5,9 @@ import 'dart:ffi'; import 'package:ffi/ffi.dart'; +import 'jobject.dart'; import 'third_party/generated_bindings.dart'; import 'jni.dart'; -import 'types.dart'; void _fillJValue(Pointer pos, dynamic arg) { if (arg is JObject) { @@ -118,7 +118,6 @@ class JValueChar { class JValueArgs { late Pointer values; final List createdRefs = []; - final _env = Jni.env; JValueArgs(List args, Arena arena) { values = arena(args.length); @@ -126,7 +125,7 @@ class JValueArgs { final arg = args[i]; final ptr = values.elementAt(i); if (arg is String) { - final jstr = _env.toJStringPtr(arg); + final jstr = Jni.env.toJStringPtr(arg); ptr.ref.l = jstr; createdRefs.add(jstr); } else { @@ -139,7 +138,7 @@ class JValueArgs { /// Deletes temporary references such as [JStringPtr]s. void _dispose() { for (var ref in createdRefs) { - _env.DeleteGlobalRef(ref); + Jni.env.DeleteGlobalRef(ref); } } } diff --git a/pkgs/jni/lib/src/lang/jboolean.dart b/pkgs/jni/lib/src/lang/jboolean.dart new file mode 100644 index 000000000..03d5304e9 --- /dev/null +++ b/pkgs/jni/lib/src/lang/jboolean.dart @@ -0,0 +1,66 @@ +// 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 '../accessors.dart'; +import '../jobject.dart'; +import '../jni.dart'; +import '../third_party/generated_bindings.dart'; +import '../types.dart'; + +class JBooleanType extends JObjType { + const JBooleanType(); + + @override + String get signature => r"Ljava/lang/Boolean;"; + + @override + JBoolean fromRef(JObjectPtr ref) => JBoolean.fromRef(ref); + + @override + JObjType get superType => const JObjectType(); + + @override + final superCount = 2; + + @override + int get hashCode => (JBooleanType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == JBooleanType && other is JBooleanType; + } +} + +class JBoolean extends JObject { + @override + // ignore: overridden_fields + late final JObjType $type = type; + + JBoolean.fromRef( + JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = JBooleanType(); + + static final _class = Jni.findJClass(r"java/lang/Boolean"); + + static final _ctorId = + Jni.accessors.getMethodIDOf(_class.reference, r"", r"(Z)V"); + JBoolean(bool boolean) + : super.fromRef(Jni.accessors.newObjectWithArgs( + _class.reference, _ctorId, [boolean ? 1 : 0]).object); + + static final _booleanValueId = + Jni.accessors.getMethodIDOf(_class.reference, r"booleanValue", r"()Z"); + + bool booleanValue({bool deleteOriginal = false}) { + final ret = Jni.accessors.callMethodWithArgs( + reference, _booleanValueId, JniCallType.booleanType, []).boolean; + if (deleteOriginal) { + delete(); + } + return ret; + } +} diff --git a/pkgs/jni/lib/src/lang/jbyte.dart b/pkgs/jni/lib/src/lang/jbyte.dart new file mode 100644 index 000000000..3cb9e96d6 --- /dev/null +++ b/pkgs/jni/lib/src/lang/jbyte.dart @@ -0,0 +1,55 @@ +// 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 '../accessors.dart'; +import '../jni.dart'; +import '../jvalues.dart'; +import '../third_party/generated_bindings.dart'; +import '../types.dart'; +import 'jnumber.dart'; + +class JByteType extends JObjType { + const JByteType(); + + @override + String get signature => r"Ljava/lang/Byte;"; + + @override + JByte fromRef(JObjectPtr ref) => JByte.fromRef(ref); + + @override + JObjType get superType => const JNumberType(); + + @override + final superCount = 2; + + @override + int get hashCode => (JByteType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == JByteType && other is JByteType; + } +} + +class JByte extends JNumber { + @override + // ignore: overridden_fields + late final JObjType $type = type; + + JByte.fromRef( + JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = JByteType(); + + static final _class = Jni.findJClass(r"java/lang/Byte"); + + static final _ctorId = + Jni.accessors.getMethodIDOf(_class.reference, r"", r"(B)V"); + JByte(int num) + : super.fromRef(Jni.accessors.newObjectWithArgs( + _class.reference, _ctorId, [JValueByte(num)]).object); +} diff --git a/pkgs/jni/lib/src/lang/jdouble.dart b/pkgs/jni/lib/src/lang/jdouble.dart new file mode 100644 index 000000000..c6852a1e9 --- /dev/null +++ b/pkgs/jni/lib/src/lang/jdouble.dart @@ -0,0 +1,54 @@ +// 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 '../accessors.dart'; +import '../jni.dart'; +import '../third_party/generated_bindings.dart'; +import '../types.dart'; +import 'jnumber.dart'; + +class JDoubleType extends JObjType { + const JDoubleType(); + + @override + String get signature => r"Ljava/lang/Double;"; + + @override + JDouble fromRef(JObjectPtr ref) => JDouble.fromRef(ref); + + @override + JObjType get superType => const JNumberType(); + + @override + final superCount = 2; + + @override + int get hashCode => (JDoubleType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == JDoubleType && other is JDoubleType; + } +} + +class JDouble extends JNumber { + @override + // ignore: overridden_fields + late final JObjType $type = type; + + JDouble.fromRef( + JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = JDoubleType(); + + static final _class = Jni.findJClass(r"java/lang/Double"); + + static final _ctorId = + Jni.accessors.getMethodIDOf(_class.reference, r"", r"(D)V"); + JDouble(double num) + : super.fromRef(Jni.accessors + .newObjectWithArgs(_class.reference, _ctorId, [num]).object); +} diff --git a/pkgs/jni/lib/src/lang/jfloat.dart b/pkgs/jni/lib/src/lang/jfloat.dart new file mode 100644 index 000000000..f23c23738 --- /dev/null +++ b/pkgs/jni/lib/src/lang/jfloat.dart @@ -0,0 +1,56 @@ +// 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 '../accessors.dart'; +import '../jni.dart'; +import '../jvalues.dart'; +import '../third_party/generated_bindings.dart'; +import '../types.dart'; +import 'jnumber.dart'; + +class JFloatType extends JObjType { + const JFloatType(); + + @override + String get signature => r"Ljava/lang/Float;"; + + @override + JFloat fromRef(JObjectPtr ref) => JFloat.fromRef(ref); + + @override + JObjType get superType => const JNumberType(); + + @override + final superCount = 2; + + @override + int get hashCode => (JFloatType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == JFloatType && other is JFloatType; + } +} + +class JFloat extends JNumber { + @override + // ignore: overridden_fields + late final JObjType $type = type; + + JFloat.fromRef( + JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = JFloatType(); + + static final _class = Jni.findJClass(r"java/lang/Float"); + + static final _ctorId = + Jni.accessors.getMethodIDOf(_class.reference, r"", r"(F)V"); + + JFloat(double num) + : super.fromRef(Jni.accessors.newObjectWithArgs( + _class.reference, _ctorId, [JValueFloat(num)]).object); +} diff --git a/pkgs/jni/lib/src/lang/jinteger.dart b/pkgs/jni/lib/src/lang/jinteger.dart new file mode 100644 index 000000000..907d7ba9f --- /dev/null +++ b/pkgs/jni/lib/src/lang/jinteger.dart @@ -0,0 +1,56 @@ +// 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 '../accessors.dart'; +import '../jni.dart'; +import '../jvalues.dart'; +import '../third_party/generated_bindings.dart'; +import '../types.dart'; +import 'jnumber.dart'; + +class JIntegerType extends JObjType { + const JIntegerType(); + + @override + String get signature => r"Ljava/lang/Integer;"; + + @override + JInteger fromRef(JObjectPtr ref) => JInteger.fromRef(ref); + + @override + JObjType get superType => const JNumberType(); + + @override + final superCount = 2; + + @override + int get hashCode => (JIntegerType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == JIntegerType && other is JIntegerType; + } +} + +class JInteger extends JNumber { + @override + // ignore: overridden_fields + late final JObjType $type = type; + + JInteger.fromRef( + JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = JIntegerType(); + + static final _class = Jni.findJClass(r"java/lang/Integer"); + + static final _ctorId = + Jni.accessors.getMethodIDOf(_class.reference, r"", r"(I)V"); + + JInteger(int num) + : super.fromRef(Jni.accessors.newObjectWithArgs( + _class.reference, _ctorId, [JValueInt(num)]).object); +} diff --git a/pkgs/jni/lib/src/lang/jlong.dart b/pkgs/jni/lib/src/lang/jlong.dart new file mode 100644 index 000000000..fb2ee8011 --- /dev/null +++ b/pkgs/jni/lib/src/lang/jlong.dart @@ -0,0 +1,55 @@ +// 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 '../accessors.dart'; +import '../jni.dart'; +import '../third_party/generated_bindings.dart'; +import '../types.dart'; +import 'jnumber.dart'; + +class JLongType extends JObjType { + const JLongType(); + + @override + String get signature => r"Ljava/lang/Long;"; + + @override + JLong fromRef(JObjectPtr ref) => JLong.fromRef(ref); + + @override + JObjType get superType => const JNumberType(); + + @override + final superCount = 2; + + @override + int get hashCode => (JLongType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == JLongType && other is JLongType; + } +} + +class JLong extends JNumber { + @override + // ignore: overridden_fields + late final JObjType $type = type; + + JLong.fromRef( + JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = JLongType(); + + static final _class = Jni.findJClass(r"java/lang/Long"); + + static final _ctorId = + Jni.accessors.getMethodIDOf(_class.reference, r"", r"(J)V"); + + JLong(int num) + : super.fromRef(Jni.accessors + .newObjectWithArgs(_class.reference, _ctorId, [num]).object); +} diff --git a/pkgs/jni/lib/src/lang/jnumber.dart b/pkgs/jni/lib/src/lang/jnumber.dart new file mode 100644 index 000000000..8461f1086 --- /dev/null +++ b/pkgs/jni/lib/src/lang/jnumber.dart @@ -0,0 +1,149 @@ +// 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 '../accessors.dart'; +import '../jni.dart'; +import '../jobject.dart'; +import '../third_party/generated_bindings.dart'; +import '../types.dart'; +import 'jinteger.dart'; +import 'jshort.dart'; +import 'jlong.dart'; +import 'jdouble.dart'; +import 'jfloat.dart'; +import 'jbyte.dart'; +import 'jboolean.dart'; + +class JNumberType extends JObjType { + const JNumberType(); + + @override + String get signature => r"Ljava/lang/Number;"; + + @override + JNumber fromRef(JObjectPtr ref) => JNumber.fromRef(ref); + + @override + JObjType get superType => const JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => (JNumberType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == JNumberType && other is JNumberType; + } +} + +class JNumber extends JObject { + @override + // ignore: overridden_fields + late final JObjType $type = type; + + JNumber.fromRef( + JObjectPtr ref, + ) : super.fromRef(ref); + + static final _class = Jni.findJClass(r"java/lang/Number"); + + /// The type which includes information such as the signature of this class. + static const type = JNumberType(); + static final _ctorId = + Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); + + JNumber() + : super.fromRef(Jni.accessors + .newObjectWithArgs(_class.reference, _ctorId, []).object); + + static final _intValueId = + Jni.accessors.getMethodIDOf(_class.reference, r"intValue", r"()I"); + + int intValue({bool deleteOriginal = false}) { + final ret = Jni.accessors.callMethodWithArgs( + reference, _intValueId, JniCallType.intType, []).integer; + if (deleteOriginal) { + delete(); + } + return ret; + } + + static final _longValueId = + Jni.accessors.getMethodIDOf(_class.reference, r"longValue", r"()J"); + + int longValue({bool deleteOriginal = false}) { + final ret = Jni.accessors.callMethodWithArgs( + reference, _longValueId, JniCallType.longType, []).long; + if (deleteOriginal) { + delete(); + } + return ret; + } + + static final _floatValueId = + Jni.accessors.getMethodIDOf(_class.reference, r"floatValue", r"()F"); + + double floatValue({bool deleteOriginal = false}) { + final ret = Jni.accessors.callMethodWithArgs( + reference, _floatValueId, JniCallType.floatType, []).float; + if (deleteOriginal) { + delete(); + } + return ret; + } + + static final _doubleValueId = + Jni.accessors.getMethodIDOf(_class.reference, r"doubleValue", r"()D"); + + double doubleValue({bool deleteOriginal = false}) { + final ret = Jni.accessors.callMethodWithArgs( + reference, _doubleValueId, JniCallType.doubleType, []).doubleFloat; + if (deleteOriginal) { + delete(); + } + return ret; + } + + static final _byteValueId = + Jni.accessors.getMethodIDOf(_class.reference, r"byteValue", r"()B"); + + int byteValue({bool deleteOriginal = false}) { + final ret = Jni.accessors.callMethodWithArgs( + reference, _byteValueId, JniCallType.byteType, []).byte; + if (deleteOriginal) { + delete(); + } + return ret; + } + + static final _shortValueId = + Jni.accessors.getMethodIDOf(_class.reference, r"shortValue", r"()S"); + + int shortValue({bool deleteOriginal = false}) { + final ret = Jni.accessors.callMethodWithArgs( + reference, _shortValueId, JniCallType.shortType, []).short; + if (deleteOriginal) { + delete(); + } + return ret; + } +} + +extension IntToJava on int { + JByte toJByte() => JByte(this); + JShort toJShort() => JShort(this); + JInteger toJInteger() => JInteger(this); + JLong toJLong() => JLong(this); +} + +extension DoubleToJava on double { + JFloat toJFloat() => JFloat(this); + JDouble toJDouble() => JDouble(this); +} + +extension BoolToJava on bool { + JBoolean toJBoolean() => JBoolean(this); +} diff --git a/pkgs/jni/lib/src/lang/jshort.dart b/pkgs/jni/lib/src/lang/jshort.dart new file mode 100644 index 000000000..a07ea4e40 --- /dev/null +++ b/pkgs/jni/lib/src/lang/jshort.dart @@ -0,0 +1,56 @@ +// 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 '../accessors.dart'; +import '../jni.dart'; +import '../jvalues.dart'; +import '../third_party/generated_bindings.dart'; +import '../types.dart'; +import 'jnumber.dart'; + +class JShortType extends JObjType { + const JShortType(); + + @override + String get signature => r"Ljava/lang/Short;"; + + @override + JShort fromRef(JObjectPtr ref) => JShort.fromRef(ref); + + @override + JObjType get superType => const JNumberType(); + + @override + final superCount = 2; + + @override + int get hashCode => (JShortType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == JShortType && other is JShortType; + } +} + +class JShort extends JNumber { + @override + // ignore: overridden_fields + late final JObjType $type = type; + + JShort.fromRef( + JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = JShortType(); + + static final _class = Jni.findJClass(r"java/lang/Short"); + + static final _ctorId = + Jni.accessors.getMethodIDOf(_class.reference, r"", r"(S)V"); + + JShort(int num) + : super.fromRef(Jni.accessors.newObjectWithArgs( + _class.reference, _ctorId, [JValueShort(num)]).object); +} diff --git a/pkgs/jni/lib/src/jstring.dart b/pkgs/jni/lib/src/lang/jstring.dart similarity index 79% rename from pkgs/jni/lib/src/jstring.dart rename to pkgs/jni/lib/src/lang/jstring.dart index 9d02df9e2..1361b53d1 100644 --- a/pkgs/jni/lib/src/jstring.dart +++ b/pkgs/jni/lib/src/lang/jstring.dart @@ -2,7 +2,16 @@ // 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. -part of 'types.dart'; +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; + +import '../jexceptions.dart'; +import '../jni.dart'; +import '../jobject.dart'; +import '../jreference.dart'; +import '../third_party/generated_bindings.dart'; +import '../types.dart'; class JStringType extends JObjType { const JStringType(); @@ -30,7 +39,8 @@ class JStringType extends JObjType { class JString extends JObject { @override - JObjType get $type => _$type ??= type; + // ignore: overridden_fields + late final JObjType $type = type; /// The type which includes information such as the signature of this class. static const JObjType type = JStringType(); @@ -40,7 +50,7 @@ class JString extends JObject { static JStringPtr _toJavaString(String s) => using((arena) { final chars = s.toNativeUtf8(allocator: arena).cast(); - final jstr = _env.NewStringUTF(chars); + final jstr = Jni.env.NewStringUTF(chars); if (jstr == nullptr) { throw 'Fatal: cannot convert string to Java string: $s'; } @@ -48,7 +58,7 @@ class JString extends JObject { }); /// The number of Unicode characters in this Java string. - int get length => _env.GetStringLength(reference); + int get length => Jni.env.GetStringLength(reference); /// Construct a [JString] from the contents of Dart string [s]. JString.fromString(String s) : super.fromRef(_toJavaString(s)); @@ -58,13 +68,13 @@ class JString extends JObject { /// If [deleteOriginal] is true, the underlying reference is deleted /// after conversion and this object will be marked as deleted. String toDartString({bool deleteOriginal = false}) { - _ensureNotDeleted(); + ensureNotDeleted(); if (reference == nullptr) { throw NullJStringException(); } - final chars = _env.GetStringUTFChars(reference, nullptr); + final chars = Jni.env.GetStringUTFChars(reference, nullptr); final result = chars.cast().toDartString(); - _env.ReleaseStringUTFChars(reference, chars); + Jni.env.ReleaseStringUTFChars(reference, chars); if (deleteOriginal) { delete(); } diff --git a/pkgs/jni/lib/src/lang/lang.dart b/pkgs/jni/lib/src/lang/lang.dart new file mode 100644 index 000000000..e4c1af72d --- /dev/null +++ b/pkgs/jni/lib/src/lang/lang.dart @@ -0,0 +1,13 @@ +// 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. + +export 'jboolean.dart'; +export 'jbyte.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/types.dart b/pkgs/jni/lib/src/types.dart index 90b9378a1..64df75cbc 100644 --- a/pkgs/jni/lib/src/types.dart +++ b/pkgs/jni/lib/src/types.dart @@ -4,31 +4,14 @@ import 'dart:ffi'; -import 'package:collection/collection.dart'; -import 'package:ffi/ffi.dart'; - -import 'accessors.dart'; import 'jni.dart'; -import 'jvalues.dart'; +import 'jobject.dart'; import 'third_party/generated_bindings.dart'; -part 'jarray.dart'; -part 'jexceptions.dart'; -part 'jprimitives.dart'; -part 'jreference.dart'; -part 'jobject.dart'; -part 'jstring.dart'; - -final JniAccessors _accessors = Jni.accessors; -final GlobalJniEnv _env = Jni.env; -// This typedef is needed because void is a keyword and cannot be used in -// type switch like a regular type. -typedef _VoidType = void; - abstract class JType { const JType(); - int get _type; + int get callType; String get signature; } @@ -42,7 +25,7 @@ abstract class JObjType extends JType { const JObjType(); @override - int get _type => JniCallType.objectType; + int get callType => JniCallType.objectType; /// Creates an object from this type using the reference. T fromRef(Pointer ref); diff --git a/pkgs/jni/lib/src/util/jiterator.dart b/pkgs/jni/lib/src/util/jiterator.dart new file mode 100644 index 000000000..eab305d00 --- /dev/null +++ b/pkgs/jni/lib/src/util/jiterator.dart @@ -0,0 +1,91 @@ +// 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 '../accessors.dart'; +import '../jni.dart'; +import '../jobject.dart'; +import '../third_party/generated_bindings.dart'; +import '../types.dart'; + +class JIteratorType<$E extends JObject> extends JObjType> { + final JObjType<$E> E; + + const JIteratorType( + this.E, + ); + + @override + String get signature => r"Ljava/util/Iterator;"; + + @override + JIterator<$E> fromRef(JObjectPtr ref) => JIterator.fromRef(E, ref); + + @override + JObjType get superType => const JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => Object.hash(JIteratorType, E); + + @override + bool operator ==(Object other) { + return other.runtimeType == (JIteratorType<$E>) && + other is JIteratorType<$E> && + E == other.E; + } +} + +class JIterator<$E extends JObject> extends JObject implements Iterator<$E> { + @override + // ignore: overridden_fields + late final JObjType $type = type(E); + + final JObjType<$E> E; + + JIterator.fromRef( + this.E, + JObjectPtr ref, + ) : super.fromRef(ref); + + static final _class = Jni.findJClass(r"java/util/Iterator"); + + /// The type which includes information such as the signature of this class. + static JIteratorType<$E> type<$E extends JObject>( + JObjType<$E> E, + ) { + return JIteratorType( + E, + ); + } + + $E? _current; + + @override + $E get current => _current as $E; + + static final _hasNextId = + Jni.accessors.getMethodIDOf(_class.reference, r"hasNext", r"()Z"); + bool _hasNext() { + return Jni.accessors.callMethodWithArgs( + reference, _hasNextId, JniCallType.booleanType, []).boolean; + } + + static final _nextId = Jni.accessors + .getMethodIDOf(_class.reference, r"next", r"()Ljava/lang/Object;"); + $E _next() { + return E.fromRef(Jni.accessors.callMethodWithArgs( + reference, _nextId, JniCallType.objectType, []).object); + } + + @override + bool moveNext() { + if (!_hasNext()) { + return false; + } + _current = _next(); + return true; + } +} diff --git a/pkgs/jni/lib/src/util/jlist.dart b/pkgs/jni/lib/src/util/jlist.dart new file mode 100644 index 000000000..577ef8917 --- /dev/null +++ b/pkgs/jni/lib/src/util/jlist.dart @@ -0,0 +1,293 @@ +// 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 'dart:collection'; +import 'dart:ffi'; + +import 'package:jni/src/util/jset.dart'; + +import '../accessors.dart'; +import '../jni.dart'; +import '../jobject.dart'; +import '../jvalues.dart'; +import '../third_party/generated_bindings.dart'; +import '../types.dart'; +import 'jiterator.dart'; + +class JListType<$E extends JObject> extends JObjType> { + final JObjType<$E> E; + + const JListType( + this.E, + ); + + @override + String get signature => r"Ljava/util/List;"; + + @override + JList<$E> fromRef(JObjectPtr ref) => JList.fromRef(E, ref); + + @override + JObjType get superType => const JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => Object.hash(JListType, E); + + @override + bool operator ==(Object other) { + return other.runtimeType == JListType && other is JListType && E == other.E; + } +} + +class JList<$E extends JObject> extends JObject with ListMixin<$E> { + @override + // ignore: overridden_fields + late final JObjType $type = type(E); + + final JObjType<$E> E; + + JList.fromRef( + this.E, + JObjectPtr ref, + ) : super.fromRef(ref); + + static final _class = Jni.findJClass(r"java/util/List"); + + /// The type which includes information such as the signature of this class. + static JListType<$E> type<$E extends JObject>( + JObjType<$E> E, + ) { + return JListType( + E, + ); + } + + static final _arrayListClassRef = Jni.findJClass(r"java/util/ArrayList"); + static final _ctorId = Jni.accessors + .getMethodIDOf(_arrayListClassRef.reference, r"", r"()V"); + JList.array(this.E) + : super.fromRef(Jni.accessors.newObjectWithArgs( + _arrayListClassRef.reference, _ctorId, []).object); + + static final _sizeId = + Jni.accessors.getMethodIDOf(_class.reference, r"size", r"()I"); + @override + int get length => Jni.accessors + .callMethodWithArgs(reference, _sizeId, JniCallType.intType, []).integer; + + @override + set length(int newLength) { + RangeError.checkNotNegative(newLength); + while (length < newLength) { + add(E.fromRef(nullptr)); + } + while (newLength < length) { + removeAt(length - 1); + } + } + + static final _getId = Jni.accessors + .getMethodIDOf(_class.reference, r"get", r"(I)Ljava/lang/Object;"); + @override + $E operator [](int index) { + RangeError.checkValidIndex(index, this); + return E.fromRef(Jni.accessors.callMethodWithArgs( + reference, _getId, JniCallType.objectType, [JValueInt(index)]).object); + } + + static final _setId = Jni.accessors.getMethodIDOf( + _class.reference, r"set", r"(ILjava/lang/Object;)Ljava/lang/Object;"); + @override + void operator []=(int index, $E value) { + RangeError.checkValidIndex(index, this); + E.fromRef(Jni.accessors.callMethodWithArgs(reference, _setId, + JniCallType.objectType, [JValueInt(index), value.reference]).object); + } + + static final _addId = Jni.accessors + .getMethodIDOf(_class.reference, r"add", r"(Ljava/lang/Object;)Z"); + @override + void add($E element) { + Jni.accessors.callMethodWithArgs( + reference, _addId, JniCallType.voidType, [element.reference]).check(); + } + + static final _collectionClass = Jni.findJClass("java/util/Collection"); + static final _addAllId = Jni.accessors + .getMethodIDOf(_class.reference, r"addAll", r"(Ljava/util/Collection;)Z"); + @override + void addAll(Iterable<$E> iterable) { + if (iterable is JObject && + Jni.env.IsInstanceOf( + (iterable as JObject).reference, _collectionClass.reference)) { + Jni.accessors.callMethodWithArgs(reference, _addAllId, + JniCallType.booleanType, [(iterable as JObject).reference]).boolean; + return; + } + return super.addAll(iterable); + } + + static final _clearId = + Jni.accessors.getMethodIDOf(_class.reference, r"clear", r"()V"); + @override + void clear() { + Jni.accessors.callMethodWithArgs( + reference, _clearId, JniCallType.voidType, []).check(); + } + + static final _containsId = Jni.accessors + .getMethodIDOf(_class.reference, r"contains", r"(Ljava/lang/Object;)Z"); + @override + bool contains(Object? element) { + if (element is! JObject) return false; + return Jni.accessors.callMethodWithArgs(reference, _containsId, + JniCallType.booleanType, [element.reference]).boolean; + } + + static final _getRangeId = Jni.accessors + .getMethodIDOf(_class.reference, r"subList", r"(II)Ljava/util/List;"); + @override + JList<$E> getRange(int start, int end) { + RangeError.checkValidRange(start, end, this.length); + return JListType(E).fromRef( + Jni.accessors.callMethodWithArgs(reference, _getRangeId, + JniCallType.objectType, [JValueInt(start), JValueInt(end)]).object, + ); + } + + static final _indexOfId = Jni.accessors + .getMethodIDOf(_class.reference, 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; + if (start == 0) { + return Jni.accessors.callMethodWithArgs(reference, _indexOfId, + JniCallType.intType, [element.reference]).integer; + } + return Jni.accessors.callMethodWithArgs( + getRange(start, length).reference, + _indexOfId, + JniCallType.intType, + [element.reference], + ).integer; + } + + static final _insertId = Jni.accessors + .getMethodIDOf(_class.reference, r"add", r"(ILjava/lang/Object;)V"); + @override + void insert(int index, $E element) { + Jni.accessors.callMethodWithArgs(reference, _insertId, JniCallType.voidType, + [JValueInt(index), element.reference]).check(); + } + + static final _insertAllId = Jni.accessors.getMethodIDOf( + _class.reference, r"addAll", r"(ILjava/util/Collection;)Z"); + @override + void insertAll(int index, Iterable<$E> iterable) { + if (iterable is JObject && + Jni.env.IsInstanceOf( + (iterable as JObject).reference, _collectionClass.reference)) { + Jni.accessors.callMethodWithArgs( + reference, + _insertAllId, + JniCallType.booleanType, + [JValueInt(index), (iterable as JObject).reference]); + return; + } + super.insertAll(index, iterable); + } + + static final _isEmptyId = + Jni.accessors.getMethodIDOf(_class.reference, r"isEmpty", r"()Z"); + @override + bool get isEmpty => Jni.accessors.callMethodWithArgs( + reference, _isEmptyId, JniCallType.booleanType, []).boolean; + + @override + bool get isNotEmpty => !isEmpty; + + static final _iteratorId = Jni.accessors + .getMethodIDOf(_class.reference, r"iterator", r"()Ljava/util/Iterator;"); + @override + JIterator<$E> get iterator => + JIteratorType(E).fromRef(Jni.accessors.callMethodWithArgs( + reference, _iteratorId, JniCallType.objectType, []).object); + + static final _lastIndexOfId = Jni.accessors.getMethodIDOf( + _class.reference, r"lastIndexOf", r"(Ljava/lang/Object;)I"); + @override + int lastIndexOf(Object? element, [int? start]) { + if (element is! JObject) return -1; + if (start == null || start >= this.length) start = this.length - 1; + if (start == this.length - 1) { + return Jni.accessors.callMethodWithArgs(reference, _lastIndexOfId, + JniCallType.intType, [element.reference]).integer; + } + final range = getRange(start, length); + final res = Jni.accessors.callMethodWithArgs( + range.reference, + _lastIndexOfId, + JniCallType.intType, + [element.reference], + ).integer; + range.delete(); + return res; + } + + static final _removeId = Jni.accessors + .getMethodIDOf(_class.reference, r"remove", r"(Ljava/lang/Object;)Z"); + @override + bool remove(Object? element) { + if (element is! JObject) return false; + return Jni.accessors.callMethodWithArgs(reference, _removeId, + JniCallType.booleanType, [element.reference]).boolean; + } + + static final _removeAtId = Jni.accessors + .getMethodIDOf(_class.reference, r"remove", r"(I)Ljava/lang/Object;"); + @override + $E removeAt(int index) { + return E.fromRef(Jni.accessors.callMethodWithArgs(reference, _removeAtId, + JniCallType.objectType, [JValueInt(index)]).object); + } + + @override + void removeRange(int start, int end) { + final range = getRange(start, end); + range.clear(); + range.delete(); + } + + @override + JSet<$E> toSet() { + return toJSet(E); + } + + static final _hashCodeId = + Jni.accessors.getMethodIDOf(_class.reference, r"hashCode", r"()I"); + @override + int get hashCode => Jni.accessors.callMethodWithArgs( + reference, _hashCodeId, JniCallType.intType, []).integer; + + static final _equalsId = Jni.accessors + .getMethodIDOf(_class.reference, r"equals", r"(Ljava/lang/Object;)Z"); + @override + bool operator ==(Object other) { + if (other is! JObject) return false; + return Jni.accessors.callMethodWithArgs(reference, _equalsId, + JniCallType.booleanType, [other.reference]).boolean; + } +} + +extension ToJavaList on Iterable { + JList toJList(JObjType type) { + final list = JList.array(type); + list.addAll(this); + return list; + } +} diff --git a/pkgs/jni/lib/src/util/jmap.dart b/pkgs/jni/lib/src/util/jmap.dart new file mode 100644 index 000000000..015fea859 --- /dev/null +++ b/pkgs/jni/lib/src/util/jmap.dart @@ -0,0 +1,187 @@ +// 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 'dart:collection'; + +import '../accessors.dart'; +import '../jni.dart'; +import '../jobject.dart'; +import '../third_party/jni_bindings_generated.dart'; +import '../types.dart'; +import 'jset.dart'; + +class JMapType<$K extends JObject, $V extends JObject> + extends JObjType> { + final JObjType<$K> K; + final JObjType<$V> V; + + const JMapType( + this.K, + this.V, + ); + + @override + String get signature => r"Ljava/util/Map;"; + + @override + JMap<$K, $V> fromRef(JObjectPtr ref) => JMap.fromRef(K, V, ref); + + @override + JObjType get superType => const JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => Object.hash(JMapType, K, V); + + @override + bool operator ==(Object other) { + return other.runtimeType == (JMapType<$K, $V>) && + other is JMapType<$K, $V> && + K == other.K && + V == other.V; + } +} + +class JMap<$K extends JObject, $V extends JObject> extends JObject + with MapMixin<$K, $V> { + @override + // ignore: overridden_fields + late final JObjType $type = type(K, V); + + final JObjType<$K> K; + final JObjType<$V> V; + + JMap.fromRef( + this.K, + this.V, + JObjectPtr ref, + ) : super.fromRef(ref); + + static final _class = Jni.findJClass(r"java/util/Map"); + + /// The type which includes information such as the signature of this class. + static JMapType<$K, $V> type<$K extends JObject, $V extends JObject>( + JObjType<$K> K, + JObjType<$V> V, + ) { + return JMapType( + K, + V, + ); + } + + static final _hashMapClass = Jni.findJClass(r"java/util/HashMap"); + static final _ctorId = + Jni.accessors.getMethodIDOf(_hashMapClass.reference, r"", r"()V"); + JMap.hash(this.K, this.V) + : super.fromRef(Jni.accessors + .newObjectWithArgs(_hashMapClass.reference, _ctorId, []).object); + + static final _getId = Jni.accessors.getMethodIDOf( + _class.reference, r"get", r"(Ljava/lang/Object;)Ljava/lang/Object;"); + @override + $V? operator [](Object? key) { + if (key is! JObject) { + return null; + } + final value = V.fromRef(Jni.accessors.callMethodWithArgs( + reference, _getId, JniCallType.objectType, [key.reference]).object); + return value.isNull ? null : value; + } + + static final _putId = Jni.accessors.getMethodIDOf(_class.reference, r"put", + r"(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); + @override + void operator []=($K key, $V value) { + Jni.accessors.callMethodWithArgs(reference, _putId, JniCallType.objectType, + [key.reference, value.reference]).object; + } + + static final _addAllId = Jni.accessors + .getMethodIDOf(_class.reference, r"putAll", r"(Ljava/util/Map;)V"); + @override + void addAll(Map<$K, $V> other) { + if (other is JMap<$K, $V>) { + Jni.accessors.callMethodWithArgs(reference, _addAllId, + JniCallType.voidType, [other.reference]).check(); + } else { + for (final entry in other.entries) { + this[entry.key] = entry.value; + } + } + } + + static final _clearId = + Jni.accessors.getMethodIDOf(_class.reference, r"clear", r"()V"); + @override + void clear() { + Jni.accessors.callMethodWithArgs( + reference, _clearId, JniCallType.voidType, []).check(); + } + + static final _containsKeyId = Jni.accessors.getMethodIDOf( + _class.reference, r"containsKey", r"(Ljava/lang/Object;)Z"); + @override + bool containsKey(Object? key) { + if (key is! JObject) { + return false; + } + return Jni.accessors.callMethodWithArgs(reference, _containsKeyId, + JniCallType.booleanType, [key.reference]).boolean; + } + + static final _containsValueId = Jni.accessors.getMethodIDOf( + _class.reference, r"containsValue", r"(Ljava/lang/Object;)Z"); + @override + bool containsValue(Object? value) { + if (value is! JObject) { + return false; + } + return Jni.accessors.callMethodWithArgs(reference, _containsValueId, + JniCallType.booleanType, [value.reference]).boolean; + } + + static final isEmptyId = + Jni.accessors.getMethodIDOf(_class.reference, r"isEmpty", r"()Z"); + @override + bool get isEmpty => Jni.accessors.callMethodWithArgs( + reference, isEmptyId, JniCallType.booleanType, []).boolean; + + @override + bool get isNotEmpty => !isEmpty; + + static final _keysId = Jni.accessors + .getMethodIDOf(_class.reference, r"keySet", r"()Ljava/util/Set;"); + @override + JSet<$K> get keys => JSetType(K).fromRef(Jni.accessors.callMethodWithArgs( + reference, _keysId, JniCallType.objectType, []).object); + + static final _sizeId = + Jni.accessors.getMethodIDOf(_class.reference, r"size", r"()I"); + @override + int get length => Jni.accessors + .callMethodWithArgs(reference, _sizeId, JniCallType.intType, []).integer; + + static final _removeId = Jni.accessors.getMethodIDOf( + _class.reference, r"remove", r"(Ljava/lang/Object;)Ljava/lang/Object;"); + @override + $V? remove(Object? key) { + if (key is! JObject) { + return null; + } + final value = V.fromRef(Jni.accessors.callMethodWithArgs( + reference, _removeId, JniCallType.objectType, [key.reference]).object); + return value.isNull ? null : value; + } +} + +extension ToJavaMap on Map { + JMap toJMap(JObjType keyType, JObjType valueType) { + final map = JMap.hash(keyType, valueType); + map.addAll(this); + return map; + } +} diff --git a/pkgs/jni/lib/src/util/jset.dart b/pkgs/jni/lib/src/util/jset.dart new file mode 100644 index 000000000..530010782 --- /dev/null +++ b/pkgs/jni/lib/src/util/jset.dart @@ -0,0 +1,228 @@ +// 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 'dart:collection'; + +import 'package:jni/src/third_party/generated_bindings.dart'; + +import '../accessors.dart'; +import '../jni.dart'; +import '../jobject.dart'; +import '../types.dart'; +import 'jiterator.dart'; + +class JSetType<$E extends JObject> extends JObjType> { + final JObjType<$E> E; + + const JSetType( + this.E, + ); + + @override + String get signature => r"Ljava/util/Set;"; + + @override + JSet<$E> fromRef(JObjectPtr ref) => JSet.fromRef(E, ref); + + @override + JObjType get superType => const JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => Object.hash(JSetType, E); + + @override + bool operator ==(Object other) { + return other.runtimeType == (JSetType<$E>) && + other is JSetType<$E> && + E == other.E; + } +} + +class JSet<$E extends JObject> extends JObject with SetMixin<$E> { + @override + // ignore: overridden_fields + late final JObjType $type = type(E); + + final JObjType<$E> E; + + JSet.fromRef( + this.E, + JObjectPtr ref, + ) : super.fromRef(ref); + + static final _class = Jni.findJClass(r"java/util/Set"); + + /// The type which includes information such as the signature of this class. + static JSetType<$E> type<$E extends JObject>( + JObjType<$E> E, + ) { + return JSetType( + E, + ); + } + + static final _hashSetClass = Jni.findJClass(r"java/util/HashSet"); + static final _ctorId = + Jni.accessors.getMethodIDOf(_hashSetClass.reference, r"", r"()V"); + JSet.hash(this.E) + : super.fromRef(Jni.accessors + .newObjectWithArgs(_hashSetClass.reference, _ctorId, []).object); + + static final _addId = Jni.accessors + .getMethodIDOf(_class.reference, r"add", r"(Ljava/lang/Object;)Z"); + @override + bool add($E value) { + return Jni.accessors.callMethodWithArgs( + reference, _addId, JniCallType.booleanType, [value.reference]).boolean; + } + + static final _addAllId = Jni.accessors + .getMethodIDOf(_class.reference, r"addAll", r"(Ljava/util/Collection;)Z"); + @override + void addAll(Iterable<$E> elements) { + if (elements is JObject && + Jni.env.IsInstanceOf( + (elements as JObject).reference, _collectionClass.reference)) { + Jni.accessors.callMethodWithArgs( + reference, + _addAllId, + JniCallType.booleanType, + [(elements as JObject).reference], + ).boolean; + } + return super.addAll(elements); + } + + static final _clearId = + Jni.accessors.getMethodIDOf(_class.reference, r"clear", r"()V"); + @override + void clear() { + return Jni.accessors.callMethodWithArgs( + reference, _clearId, JniCallType.voidType, []).check(); + } + + static final _containsId = Jni.accessors + .getMethodIDOf(_class.reference, r"contains", r"(Ljava/lang/Object;)Z"); + + @override + bool contains(Object? element) { + if (element is! JObject) { + return false; + } + return Jni.accessors.callMethodWithArgs(reference, _containsId, + JniCallType.booleanType, [element.reference]).boolean; + } + + static final _containsAllId = Jni.accessors.getMethodIDOf( + _class.reference, r"containsAll", r"(Ljava/util/Collection;)Z"); + static final _collectionClass = Jni.findJClass("java/util/Collection"); + @override + bool containsAll(Iterable other) { + if (other is JObject && + Jni.env.IsInstanceOf( + (other as JObject).reference, _collectionClass.reference)) { + return Jni.accessors.callMethodWithArgs(reference, _containsAllId, + JniCallType.booleanType, [(other as JObject).reference]).boolean; + } + return super.containsAll(other); + } + + static final _isEmptyId = + Jni.accessors.getMethodIDOf(_class.reference, r"isEmpty", r"()Z"); + @override + bool get isEmpty => Jni.accessors.callMethodWithArgs( + reference, _isEmptyId, JniCallType.booleanType, []).boolean; + + @override + bool get isNotEmpty => !isEmpty; + + static final _iteratorId = Jni.accessors + .getMethodIDOf(_class.reference, r"iterator", r"()Ljava/util/Iterator;"); + @override + JIterator<$E> get iterator => + JIteratorType(E).fromRef(Jni.accessors.callMethodWithArgs( + reference, _iteratorId, JniCallType.objectType, []).object); + + static final _sizeId = + Jni.accessors.getMethodIDOf(_class.reference, r"size", r"()I"); + @override + int get length => Jni.accessors + .callMethodWithArgs(reference, _sizeId, JniCallType.intType, []).integer; + + static final _removeId = Jni.accessors + .getMethodIDOf(_class.reference, r"remove", r"(Ljava/lang/Object;)Z"); + @override + bool remove(Object? value) { + if (value is! $E) { + return false; + } + return Jni.accessors.callMethodWithArgs(reference, _removeId, + JniCallType.booleanType, [value.reference]).boolean; + } + + static final _removeAllId = Jni.accessors.getMethodIDOf( + _class.reference, r"removeAll", r"(Ljava/util/Collection;)Z"); + @override + void removeAll(Iterable elements) { + if (elements is JObject && + Jni.env.IsInstanceOf( + (elements as JObject).reference, _collectionClass.reference)) { + Jni.accessors.callMethodWithArgs(reference, _removeAllId, + JniCallType.booleanType, [(elements as JObject).reference]).boolean; + } + return super.removeAll(elements); + } + + static final _retainAllId = Jni.accessors.getMethodIDOf( + _class.reference, r"retainAll", r"(Ljava/util/Collection;)Z"); + @override + void retainAll(Iterable elements) { + if (elements is JObject && + Jni.env.IsInstanceOf( + (elements as JObject).reference, _collectionClass.reference)) { + Jni.accessors.callMethodWithArgs(reference, _retainAllId, + JniCallType.booleanType, [(elements as JObject).reference]).boolean; + } + return super.retainAll(elements); + } + + static final _hashCodeId = + Jni.accessors.getMethodIDOf(_class.reference, r"hashCode", r"()I"); + @override + int get hashCode => Jni.accessors.callMethodWithArgs( + reference, _hashCodeId, JniCallType.intType, []).integer; + + static final _equalsId = Jni.accessors + .getMethodIDOf(_class.reference, r"equals", r"(Ljava/lang/Object;)Z"); + @override + bool operator ==(Object other) { + if (other is! JObject) { + return false; + } + return Jni.accessors.callMethodWithArgs(reference, _equalsId, + JniCallType.booleanType, [other.reference]).boolean; + } + + @override + $E? lookup(Object? element) { + if (contains(element)) return element as $E; + return null; + } + + @override + JSet<$E> toSet() { + return toJSet(E); + } +} + +extension ToJavaSet on Iterable { + JSet toJSet(JObjType type) { + final set = JSet.hash(type); + set.addAll(this); + return set; + } +} diff --git a/pkgs/jni/lib/src/util/util.dart b/pkgs/jni/lib/src/util/util.dart new file mode 100644 index 000000000..d0a0dc503 --- /dev/null +++ b/pkgs/jni/lib/src/util/util.dart @@ -0,0 +1,8 @@ +// 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. + +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 7dc42d5d8..6a999b6ac 100644 --- a/pkgs/jni/pubspec.yaml +++ b/pkgs/jni/pubspec.yaml @@ -1,6 +1,6 @@ name: jni description: Library to access JNI from dart and flutter -version: 0.4.0 +version: 0.5.0-dev.0 repository: https://github.com/dart-lang/jnigen/tree/main/jni environment: diff --git a/pkgs/jni/test/boxed_test.dart b/pkgs/jni/test/boxed_test.dart new file mode 100644 index 000000000..43489e887 --- /dev/null +++ b/pkgs/jni/test/boxed_test.dart @@ -0,0 +1,130 @@ +// 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 'dart:io'; + +import 'package:jni/jni.dart'; +import 'package:test/test.dart'; + +import 'test_util/test_util.dart'; + +void main() { + // Don't forget to initialize JNI. + if (!Platform.isAndroid) { + checkDylibIsUpToDate(); + Jni.spawnIfNotExists(dylibDir: "build/jni_libs", jvmOptions: ["-Xmx128m"]); + } + run(testRunner: test); +} + +void run({required TestRunnerCallback testRunner}) { + testRunner('JByte', () { + const val = 1 << 5; + using((arena) { + expect(JByte(val).byteValue(deleteOriginal: true), val); + expect((-val).toJByte().byteValue(deleteOriginal: true), -val); + }); + }); + testRunner('JShort', () { + const val = 1 << 10; + using((arena) { + expect(JShort(val).shortValue(deleteOriginal: true), val); + expect((-val).toJShort().shortValue(deleteOriginal: true), -val); + }); + }); + testRunner('JInteger', () { + const val = 1 << 20; + using((arena) { + expect(JInteger(val).intValue(deleteOriginal: true), val); + expect((-val).toJInteger().intValue(deleteOriginal: true), -val); + }); + }); + testRunner('JLong', () { + const val = 1 << 40; + using((arena) { + expect(JLong(val).longValue(deleteOriginal: true), val); + expect((-val).toJLong().longValue(deleteOriginal: true), -val); + }); + }); + testRunner('JFloat', () { + const val = 3.14; + const eps = 1e-6; + using((arena) { + expect(JFloat(val).floatValue(deleteOriginal: true), closeTo(val, eps)); + expect((-val).toJFloat().floatValue(deleteOriginal: true), + closeTo(-val, eps)); + }); + }); + testRunner('JDouble', () { + const val = 3.14; + const eps = 1e-9; + using((arena) { + expect(JDouble(val).doubleValue(deleteOriginal: true), closeTo(val, eps)); + expect((-val).toJDouble().doubleValue(deleteOriginal: true), + closeTo(-val, eps)); + }); + }); + testRunner('JBoolean', () { + using((arena) { + expect(JBoolean(false).booleanValue(deleteOriginal: true), false); + expect(JBoolean(true).booleanValue(deleteOriginal: true), true); + }); + }); + testRunner('JByte.\$type hashCode and ==', () { + using((arena) { + final a = JByte(1)..deletedIn(arena); + final b = JByte(2)..deletedIn(arena); + expect(a.$type, b.$type); + expect(a.$type.hashCode, b.$type.hashCode); + }); + }); + testRunner('JShort.\$type hashCode and ==', () { + using((arena) { + final a = JShort(1)..deletedIn(arena); + final b = JShort(2)..deletedIn(arena); + expect(a.$type, b.$type); + expect(a.$type.hashCode, b.$type.hashCode); + }); + }); + testRunner('JInteger.\$type hashCode and ==', () { + using((arena) { + final a = JInteger(1)..deletedIn(arena); + final b = JInteger(2)..deletedIn(arena); + expect(a.$type, b.$type); + expect(a.$type.hashCode, b.$type.hashCode); + }); + }); + testRunner('JLong.\$type hashCode and ==', () { + using((arena) { + final a = JLong(1)..deletedIn(arena); + final b = JLong(2)..deletedIn(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)..deletedIn(arena); + final b = JFloat(2.0)..deletedIn(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)..deletedIn(arena); + final b = JDouble(2.0)..deletedIn(arena); + expect(a.$type, b.$type); + expect(a.$type.hashCode, b.$type.hashCode); + }); + }); + testRunner('JBoolean.\$type hashCode and ==', () { + using((arena) { + final a = JBoolean(true)..deletedIn(arena); + final b = JBoolean(false)..deletedIn(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 01acfdfb6..d9af2542f 100644 --- a/pkgs/jni/test/exception_test.dart +++ b/pkgs/jni/test/exception_test.dart @@ -20,11 +20,8 @@ void main() { Jni.spawn(dylibDir: "wrong_dir"); } on HelperNotFoundException catch (_) { // stderr.write("\n$_\n"); - try { - Jni.spawn(dylibDir: "build/jni_libs", jvmOptions: ["-Xmx128m"]); - } on JvmExistsException catch (_) { - // TODO(#51): Support destroying and reinstantiating JVM. - } + Jni.spawnIfNotExists( + dylibDir: "build/jni_libs", jvmOptions: ["-Xmx128m"]); caught = true; } on JvmExistsException { stderr.writeln('cannot verify: HelperNotFoundException thrown'); diff --git a/pkgs/jni/test/jarray_test.dart b/pkgs/jni/test/jarray_test.dart index 5717d532e..d0bc8cfe0 100644 --- a/pkgs/jni/test/jarray_test.dart +++ b/pkgs/jni/test/jarray_test.dart @@ -21,7 +21,7 @@ void main() { void run({required TestRunnerCallback testRunner}) { testRunner("Java boolean array", () { using((arena) { - final array = JArray(JBoolean.type, 3)..deletedIn(arena); + final array = JArray(jboolean.type, 3)..deletedIn(arena); expect(array.length, 3); array[0] = true; array[1] = false; @@ -46,7 +46,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner("Java char array", () { using((arena) { - final array = JArray(JChar.type, 3)..deletedIn(arena); + final array = JArray(jchar.type, 3)..deletedIn(arena); expect(array.length, 3); array[0] = 'ح'; array[1] = '2'; @@ -71,7 +71,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner("Java byte array", () { using((arena) { - final array = JArray(JByte.type, 3)..deletedIn(arena); + final array = JArray(jbyte.type, 3)..deletedIn(arena); expect(array.length, 3); array[0] = 1; array[1] = 2; @@ -96,7 +96,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner("Java short array", () { using((arena) { - final array = JArray(JShort.type, 3)..deletedIn(arena); + final array = JArray(jshort.type, 3)..deletedIn(arena); expect(array.length, 3); array[0] = 1; array[1] = 2; @@ -121,7 +121,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner("Java int array", () { using((arena) { - final array = JArray(JInt.type, 3)..deletedIn(arena); + final array = JArray(jint.type, 3)..deletedIn(arena); expect(array.length, 3); array[0] = 1; array[1] = 2; @@ -147,7 +147,7 @@ void run({required TestRunnerCallback testRunner}) { const epsilon = 1e-6; testRunner("Java float array", () { using((arena) { - final array = JArray(JFloat.type, 3)..deletedIn(arena); + final array = JArray(jfloat.type, 3)..deletedIn(arena); expect(array.length, 3); array[0] = 0.5; array[1] = 2; @@ -172,7 +172,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner("Java double array", () { using((arena) { - final array = JArray(JDouble.type, 3)..deletedIn(arena); + final array = JArray(jdouble.type, 3)..deletedIn(arena); expect(array.length, 3); array[0] = 0.5; array[1] = 2; @@ -241,11 +241,11 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner("Java 2d array", () { using((arena) { - final array = JArray(JInt.type, 3)..deletedIn(arena); + final array = JArray(jint.type, 3)..deletedIn(arena); array[0] = 1; array[1] = 2; array[2] = 3; - final twoDimArray = JArray(JArray.type(JInt.type), 3)..deletedIn(arena); + final twoDimArray = JArray(JArray.type(jint.type), 3)..deletedIn(arena); expect(twoDimArray.length, 3); twoDimArray[0] = array; twoDimArray[1] = array; @@ -276,4 +276,71 @@ void run({required TestRunnerCallback testRunner}) { expect(array[2].toDartString(deleteOriginal: true), "abc"); }); }); + testRunner('JArray of JByte', () { + using((arena) { + final arr = JArray(JByte.type, 1)..deletedIn(arena); + expect((arr[0]..deletedIn(arena)).isNull, true); + }); + }); + testRunner('JArray of JShort', () { + using((arena) { + final arr = JArray(JShort.type, 1)..deletedIn(arena); + expect((arr[0]..deletedIn(arena)).isNull, true); + }); + }); + testRunner('JArray of JInteger', () { + using((arena) { + final arr = JArray(JInteger.type, 1)..deletedIn(arena); + expect((arr[0]..deletedIn(arena)).isNull, true); + }); + }); + testRunner('JArray of JLong', () { + using((arena) { + final arr = JArray(JLong.type, 1)..deletedIn(arena); + expect((arr[0]..deletedIn(arena)).isNull, true); + }); + }); + testRunner('JArray of JFloat', () { + using((arena) { + final arr = JArray(JFloat.type, 1)..deletedIn(arena); + expect((arr[0]..deletedIn(arena)).isNull, true); + }); + }); + testRunner('JArray of JDouble', () { + using((arena) { + final arr = JArray(JDouble.type, 1)..deletedIn(arena); + expect((arr[0]..deletedIn(arena)).isNull, true); + }); + }); + testRunner('JArray of JBoolean', () { + using((arena) { + final arr = JArray(JBoolean.type, 1)..deletedIn(arena); + expect((arr[0]..deletedIn(arena)).isNull, true); + }); + }); + testRunner('JArray of JSet', () { + using((arena) { + final arr = JArray(JSet.type(JString.type), 1)..deletedIn(arena); + expect((arr[0]..deletedIn(arena)).isNull, true); + }); + }); + testRunner('JArray of JList', () { + using((arena) { + final arr = JArray(JList.type(JString.type), 1)..deletedIn(arena); + expect((arr[0]..deletedIn(arena)).isNull, true); + }); + }); + testRunner('JArray of JMap', () { + using((arena) { + final arr = JArray(JMap.type(JString.type, JString.type), 1) + ..deletedIn(arena); + expect((arr[0]..deletedIn(arena)).isNull, true); + }); + }); + testRunner('JArray of JIterator', () { + using((arena) { + final arr = JArray(JIterator.type(JString.type), 1)..deletedIn(arena); + expect((arr[0]..deletedIn(arena)).isNull, true); + }); + }); } diff --git a/pkgs/jni/test/jlist_test.dart b/pkgs/jni/test/jlist_test.dart new file mode 100644 index 000000000..c483d53d3 --- /dev/null +++ b/pkgs/jni/test/jlist_test.dart @@ -0,0 +1,216 @@ +// 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 'dart:io'; + +import 'package:jni/jni.dart'; +import 'package:test/test.dart'; + +import 'test_util/test_util.dart'; + +void main() { + // Don't forget to initialize JNI. + if (!Platform.isAndroid) { + checkDylibIsUpToDate(); + Jni.spawnIfNotExists(dylibDir: "build/jni_libs", jvmOptions: ["-Xmx128m"]); + } + run(testRunner: test); +} + +void run({required TestRunnerCallback testRunner}) { + JList testDataList(Arena arena) { + return [ + "1".toJString()..deletedIn(arena), + "2".toJString()..deletedIn(arena), + "3".toJString()..deletedIn(arena), + ].toJList(JString.type) + ..deletedIn(arena); + } + + testRunner('length get', () { + using((arena) { + final list = testDataList(arena); + expect(list.length, 3); + }); + }); + testRunner('length set', () { + using((arena) { + final list = testDataList(arena); + list.length = 2; + expect(list.length, 2); + list.length = 3; + expect(list.length, 3); + expect(list.last.isNull, true); + }); + }); + testRunner('[]', () { + using((arena) { + final list = testDataList(arena); + expect(list[0].toDartString(deleteOriginal: true), "1"); + expect(list[1].toDartString(deleteOriginal: true), "2"); + expect(list[2].toDartString(deleteOriginal: true), "3"); + }); + }); + testRunner('[]=', () { + using((arena) { + final list = testDataList(arena); + expect(list[0].toDartString(deleteOriginal: true), "1"); + list[0] = "2".toJString()..deletedIn(arena); + expect(list[0].toDartString(deleteOriginal: true), "2"); + }); + }); + testRunner('add', () { + using((arena) { + final list = testDataList(arena); + list.add("4".toJString()..deletedIn(arena)); + expect(list.length, 4); + expect(list[3].toDartString(deleteOriginal: true), "4"); + }); + }); + testRunner('addAll', () { + using((arena) { + final list = testDataList(arena); + final toAppend = testDataList(arena); + list.addAll(toAppend); + expect(list.length, 6); + list.addAll(["4".toJString()..deletedIn(arena)]); + expect(list.length, 7); + }); + }); + testRunner('clear, isEmpty, isNotEmpty', () { + using((arena) { + final list = testDataList(arena); + expect(list.isNotEmpty, true); + expect(list.isEmpty, false); + list.clear(); + expect(list.isNotEmpty, false); + expect(list.isEmpty, true); + }); + }); + testRunner('contains', () { + using((arena) { + final list = testDataList(arena); + // ignore: iterable_contains_unrelated_type + expect(list.contains("1"), false); + expect(list.contains("1".toJString()..deletedIn(arena)), true); + expect(list.contains("4".toJString()..deletedIn(arena)), false); + }); + }); + testRunner('getRange', () { + using((arena) { + final list = testDataList(arena); + // ignore: iterable_contains_unrelated_type + final range = list.getRange(1, 2)..deletedIn(arena); + expect(range.length, 1); + expect(range.first.toDartString(deleteOriginal: true), "2"); + }); + }); + testRunner('indexOf', () { + using((arena) { + final list = testDataList(arena); + expect(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); + expect(list.indexOf("1".toJString()..toDartString(), -1), 0); + }); + }); + testRunner('insert', () { + using((arena) { + final list = testDataList(arena); + list.insert(1, "0".toJString()..deletedIn(arena)); + expect(list.length, 4); + expect(list[1].toDartString(deleteOriginal: true), "0"); + }); + }); + testRunner('insertAll', () { + using((arena) { + final list = testDataList(arena); + final toInsert = testDataList(arena); + list.insertAll(1, toInsert); + expect(list[1].toDartString(deleteOriginal: true), "1"); + expect(list.length, 6); + list.insertAll(1, ["4".toJString()..deletedIn(arena)]); + expect(list.length, 7); + expect(list[1].toDartString(deleteOriginal: true), "4"); + }); + }); + testRunner('iterator', () { + using((arena) { + final list = testDataList(arena); + final it = list.iterator; + expect(it.moveNext(), true); + expect(it.current.toDartString(deleteOriginal: true), "1"); + expect(it.moveNext(), true); + expect(it.current.toDartString(deleteOriginal: true), "2"); + expect(it.moveNext(), true); + expect(it.current.toDartString(deleteOriginal: true), "3"); + expect(it.moveNext(), false); + }); + }); + testRunner('remove', () { + using((arena) { + final list = testDataList(arena); + expect(list.remove("3".toJString()..deletedIn(arena)), true); + expect(list.length, 2); + expect(list.remove("4".toJString()..deletedIn(arena)), false); + // ignore: list_remove_unrelated_type + expect(list.remove(1), false); + }); + }); + testRunner('removeAt', () { + using((arena) { + final list = testDataList(arena); + expect(list.removeAt(0).toDartString(deleteOriginal: true), "1"); + expect(list.removeAt(1).toDartString(deleteOriginal: true), "3"); + }); + }); + testRunner('removeRange', () { + using((arena) { + final list = testDataList(arena); + list.removeRange(0, 2); + expect(list.single.toDartString(deleteOriginal: 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()..deletedIn(arena)); + expect(a.hashCode, isNot(b.hashCode)); + expect(a, isNot(b)); + }); + }); + testRunner('toSet', () { + using((arena) { + final list = testDataList(arena); + final set = list.toSet()..deletedIn(arena); + 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)..deletedIn(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)..deletedIn(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 new file mode 100644 index 000000000..23edb22d0 --- /dev/null +++ b/pkgs/jni/test/jmap_test.dart @@ -0,0 +1,166 @@ +// 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 'dart:io'; + +import 'package:jni/jni.dart'; +import 'package:test/test.dart'; + +import 'test_util/test_util.dart'; + +void main() { + // Don't forget to initialize JNI. + if (!Platform.isAndroid) { + Jni.spawnIfNotExists(dylibDir: "build/jni_libs", jvmOptions: ["-Xmx128m"]); + } + run(testRunner: test); +} + +void run({required TestRunnerCallback testRunner}) { + JMap testDataMap(Arena arena) { + return { + "1".toJString()..deletedIn(arena): "One".toJString()..deletedIn(arena), + "2".toJString()..deletedIn(arena): "Two".toJString()..deletedIn(arena), + "3".toJString()..deletedIn(arena): "Three".toJString()..deletedIn(arena), + }.toJMap(JString.type, JString.type) + ..deletedIn(arena); + } + + testRunner('length', () { + using((arena) { + final map = testDataMap(arena); + expect(map.length, 3); + }); + }); + testRunner('[]', () { + using((arena) { + final map = testDataMap(arena); + // ignore: collection_methods_unrelated_type + expect(map[1], null); + expect( + map["1".toJString()..deletedIn(arena)] + ?.toDartString(deleteOriginal: true), + "One", + ); + expect( + map["4".toJString()..deletedIn(arena)], + null, + ); + }); + }); + testRunner('[]=', () { + using((arena) { + final map = testDataMap(arena); + map["0".toJString()..deletedIn(arena)] = "Zero".toJString() + ..deletedIn(arena); + expect( + map["0".toJString()..deletedIn(arena)] + ?.toDartString(deleteOriginal: true), + "Zero", + ); + expect(map.length, 4); + map["1".toJString()..deletedIn(arena)] = "one!".toJString() + ..deletedIn(arena); + expect( + map["1".toJString()..deletedIn(arena)] + ?.toDartString(deleteOriginal: true), + "one!", + ); + expect(map.length, 4); + }); + }); + testRunner('addAll', () { + using((arena) { + final map = testDataMap(arena); + final toAdd = { + "0".toJString()..deletedIn(arena): "Zero".toJString()..deletedIn(arena), + "1".toJString()..deletedIn(arena): "one!".toJString()..deletedIn(arena), + }.toJMap(JString.type, JString.type); + map.addAll(toAdd); + expect(map.length, 4); + expect( + map["0".toJString()..deletedIn(arena)] + ?.toDartString(deleteOriginal: true), + "Zero", + ); + expect( + map["1".toJString()..deletedIn(arena)] + ?.toDartString(deleteOriginal: true), + "one!", + ); + map.addAll({ + "4".toJString()..deletedIn(arena): "Four".toJString()..deletedIn(arena) + }); + expect(map.length, 5); + }); + }); + testRunner('clear, isEmpty, isNotEmpty', () { + using((arena) { + final map = testDataMap(arena); + expect(map.isEmpty, false); + expect(map.isNotEmpty, true); + map.clear(); + expect(map.isEmpty, true); + expect(map.isNotEmpty, false); + }); + }); + testRunner('containsKey', () { + using((arena) { + final map = testDataMap(arena); + // ignore: iterable_contains_unrelated_type + expect(map.containsKey(1), false); + expect(map.containsKey("1".toJString()..deletedIn(arena)), true); + expect(map.containsKey("4".toJString()..deletedIn(arena)), false); + }); + }); + testRunner('containsValue', () { + using((arena) { + final map = testDataMap(arena); + // ignore: iterable_contains_unrelated_type + expect(map.containsValue(1), false); + expect(map.containsValue("One".toJString()..deletedIn(arena)), true); + expect(map.containsValue("Four".toJString()..deletedIn(arena)), false); + }); + }); + testRunner('keys', () { + using((arena) { + final map = testDataMap(arena); + final keys = map.keys; + expect( + keys + .map((element) => element.toDartString(deleteOriginal: true)) + .toSet(), + {"1", "2", "3"}, + ); + }); + }); + testRunner('remove', () { + using((arena) { + final map = testDataMap(arena); + // ignore: collection_methods_unrelated_type + expect(map.remove(1), null); + expect(map.remove("4".toJString()..deletedIn(arena)), null); + expect(map.length, 3); + expect( + map + .remove("3".toJString()..deletedIn(arena)) + ?.toDartString(deleteOriginal: true), + "Three", + ); + 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)..deletedIn(arena); + expect(a.$type, isNot(c.$type)); + expect(a.$type.hashCode, isNot(c.$type.hashCode)); + }); + }); +} diff --git a/pkgs/jni/test/jset_test.dart b/pkgs/jni/test/jset_test.dart new file mode 100644 index 000000000..92aaa0c15 --- /dev/null +++ b/pkgs/jni/test/jset_test.dart @@ -0,0 +1,202 @@ +// 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 'dart:io'; + +import 'package:jni/jni.dart'; +import 'package:test/test.dart'; + +import 'test_util/test_util.dart'; + +void main() { + // Don't forget to initialize JNI. + if (!Platform.isAndroid) { + checkDylibIsUpToDate(); + Jni.spawnIfNotExists(dylibDir: "build/jni_libs", jvmOptions: ["-Xmx128m"]); + } + run(testRunner: test); +} + +void run({required TestRunnerCallback testRunner}) { + JSet testDataSet(Arena arena) { + return { + "1".toJString()..deletedIn(arena), + "2".toJString()..deletedIn(arena), + "3".toJString()..deletedIn(arena), + }.toJSet(JString.type) + ..deletedIn(arena); + } + + testRunner('length', () { + using((arena) { + final set = testDataSet(arena); + expect(set.length, 3); + }); + }); + testRunner('add', () { + using((arena) { + final set = testDataSet(arena); + set.add("1".toJString()..deletedIn(arena)); + expect(set.length, 3); + set.add("4".toJString()..deletedIn(arena)); + expect(set.length, 4); + }); + }); + testRunner('addAll', () { + using((arena) { + final set = testDataSet(arena); + final toAdd = testDataSet(arena); + toAdd.add("4".toJString()..deletedIn(arena)); + set.addAll(toAdd); + expect(set.length, 4); + set.addAll([ + "1".toJString()..deletedIn(arena), + "5".toJString()..deletedIn(arena), + ]); + expect(set.length, 5); + }); + }); + testRunner('clear, isEmpty, isNotEmpty', () { + using((arena) { + final set = testDataSet(arena); + set.clear(); + expect(set.isEmpty, true); + expect(set.isNotEmpty, false); + }); + }); + testRunner('contains', () { + using((arena) { + final set = testDataSet(arena); + // ignore: iterable_contains_unrelated_type + expect(set.contains(1), false); + expect(set.contains("1".toJString()..deletedIn(arena)), true); + expect(set.contains("4".toJString()..deletedIn(arena)), false); + }); + }); + testRunner('containsAll', () { + using((arena) { + final set = testDataSet(arena); + expect(set.containsAll(set), true); + expect( + set.containsAll([ + "1".toJString()..deletedIn(arena), + "2".toJString()..deletedIn(arena), + ]), + true, + ); + final testSet = testDataSet(arena); + testSet.add("4".toJString()..deletedIn(arena)); + expect(set.containsAll(testSet), false); + expect(set.containsAll(["4".toJString()..deletedIn(arena)]), false); + }); + }); + testRunner('iterator', () { + using((arena) { + final set = testDataSet(arena); + final it = set.iterator; + // There are no order guarantees in a hashset. + final dartSet = {}; + expect(it.moveNext(), true); + dartSet.add(it.current.toDartString(deleteOriginal: true)); + expect(it.moveNext(), true); + dartSet.add(it.current.toDartString(deleteOriginal: true)); + expect(it.moveNext(), true); + dartSet.add(it.current.toDartString(deleteOriginal: true)); + expect(it.moveNext(), false); + // So we just check if the elements have appeared in some order. + expect(dartSet, {"1", "2", "3"}); + }); + }); + testRunner('remove', () { + using((arena) { + final set = testDataSet(arena); + // ignore: collection_methods_unrelated_type + expect(set.remove(1), false); + expect(set.remove("4".toJString()..deletedIn(arena)), false); + expect(set.length, 3); + expect(set.remove("3".toJString()..deletedIn(arena)), true); + expect(set.length, 2); + }); + }); + testRunner('removeAll', () { + using((arena) { + final set = testDataSet(arena); + final toRemoveExclusive = {"4".toJString()..deletedIn(arena)} + .toJSet(JString.type) + ..deletedIn(arena); + set.removeAll(toRemoveExclusive); + expect(set.length, 3); + final toRemoveInclusive = { + "1".toJString()..deletedIn(arena), + "4".toJString()..deletedIn(arena), + }.toJSet(JString.type) + ..deletedIn(arena); + set.removeAll(toRemoveInclusive); + expect(set.length, 2); + set.removeAll(["2".toJString()..deletedIn(arena)]); + expect(set.length, 1); + }); + }); + testRunner('retainAll', () { + using((arena) { + final set = testDataSet(arena); + final toRetain = { + "1".toJString()..deletedIn(arena), + "3".toJString()..deletedIn(arena), + "4".toJString()..deletedIn(arena), + }; + set.retainAll(set); + expect(set.length, 3); + set.retainAll(toRetain); + expect(set.length, 2); + final toRetainJSet = toRetain.toJSet(JString.type)..deletedIn(arena); + set.retainAll(toRetainJSet); + 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()..deletedIn(arena)); + expect(a.hashCode, isNot(b.hashCode)); + expect(a, isNot(b)); + }); + }); + testRunner('lookup', () { + using((arena) { + final set = testDataSet(arena); + // ignore: iterable_contains_unrelated_type + expect(set.lookup(1), null); + expect( + set.lookup("1".toJString())?.toDartString(deleteOriginal: true), + "1", + ); + expect(set.lookup("4".toJString()..deletedIn(arena)), null); + }); + }); + testRunner('toSet', () { + using((arena) { + // Test if the set gets copied. + final set = testDataSet(arena); + final setCopy = set.toSet()..deletedIn(arena); + expect(set, setCopy); + set.add("4".toJString()..deletedIn(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)..deletedIn(arena); + expect(a.$type, isNot(c.$type)); + expect(a.$type.hashCode, isNot(c.$type.hashCode)); + }); + }); +} diff --git a/pkgs/jni/test/type_test.dart b/pkgs/jni/test/type_test.dart index 68693a548..ffc11d692 100644 --- a/pkgs/jni/test/type_test.dart +++ b/pkgs/jni/test/type_test.dart @@ -217,10 +217,58 @@ void run({required TestRunnerCallback testRunner}) { 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(JLong.type)]), + expect(lowestCommonSuperType([JString.type, JArray.type(jlong.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('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, + ); + }); + }); + testRunner('Mocked type tree', () { // As a reminder, this is how the type tree looks like: // JObject diff --git a/pkgs/jnigen/CHANGELOG.md b/pkgs/jnigen/CHANGELOG.md index 5c8b9caed..23c1e261a 100644 --- a/pkgs/jnigen/CHANGELOG.md +++ b/pkgs/jnigen/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.5.0-dev.0 +* No JNIGen changes (yet), but keeping version in lockstep with `package:jni`. + ## 0.4.0 * **Breaking Change** ([#145](https://github.com/dart-lang/jnigen/issues/145)): Type arguments are now named instead of positional. * Type parameters can now be inferred when possible. diff --git a/pkgs/jnigen/analysis_options.yaml b/pkgs/jnigen/analysis_options.yaml index 063baccc7..4bebf0eb6 100644 --- a/pkgs/jnigen/analysis_options.yaml +++ b/pkgs/jnigen/analysis_options.yaml @@ -17,4 +17,3 @@ linter: - unawaited_futures - prefer_const_constructors - prefer_relative_imports - diff --git a/pkgs/jnigen/android_test_runner/lib/main.dart b/pkgs/jnigen/android_test_runner/lib/main.dart index 8e8892848..ee6f2d812 100644 --- a/pkgs/jnigen/android_test_runner/lib/main.dart +++ b/pkgs/jnigen/android_test_runner/lib/main.dart @@ -40,7 +40,7 @@ class MyHomePage extends StatelessWidget { body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, - children: const [ + children: const [ Text( 'This app should be run as flutter integration test', ), diff --git a/pkgs/jnigen/example/in_app_java/lib/android_utils.dart b/pkgs/jnigen/example/in_app_java/lib/android_utils.dart index 5925b9251..50e1e76d1 100644 --- a/pkgs/jnigen/example/in_app_java/lib/android_utils.dart +++ b/pkgs/jnigen/example/in_app_java/lib/android_utils.dart @@ -27,7 +27,7 @@ final ffi.Pointer Function(String sym) jniLookup = /// from: com.example.in_app_java.AndroidUtils class AndroidUtils extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; AndroidUtils.fromRef( jni.JObjectPtr ref, @@ -73,7 +73,8 @@ class $AndroidUtilsType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $AndroidUtilsType && other is $AndroidUtilsType; + return other.runtimeType == ($AndroidUtilsType) && + other is $AndroidUtilsType; } } @@ -128,7 +129,7 @@ class $AndroidUtilsType extends jni.JObjType { ///

    class EmojiCompat extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; EmojiCompat.fromRef( jni.JObjectPtr ref, @@ -1044,7 +1045,7 @@ class $EmojiCompatType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $EmojiCompatType && other is $EmojiCompatType; + return other.runtimeType == ($EmojiCompatType) && other is $EmojiCompatType; } } @@ -1055,7 +1056,7 @@ class $EmojiCompatType extends jni.JObjType { ///@see \#init(EmojiCompat.Config) class EmojiCompat_Config extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; EmojiCompat_Config.fromRef( jni.JObjectPtr ref, @@ -1379,7 +1380,7 @@ class $EmojiCompat_ConfigType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $EmojiCompat_ConfigType && + return other.runtimeType == ($EmojiCompat_ConfigType) && other is $EmojiCompat_ConfigType; } } @@ -1390,7 +1391,7 @@ class $EmojiCompat_ConfigType extends jni.JObjType { /// MetadataRepoLoader during MetadataRepoLoader\#load(MetadataRepoLoaderCallback) call. class EmojiCompat_MetadataRepoLoaderCallback extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; EmojiCompat_MetadataRepoLoaderCallback.fromRef( jni.JObjectPtr ref, @@ -1470,7 +1471,7 @@ class $EmojiCompat_MetadataRepoLoaderCallbackType @override bool operator ==(Object other) { - return other.runtimeType == $EmojiCompat_MetadataRepoLoaderCallbackType && + return other.runtimeType == ($EmojiCompat_MetadataRepoLoaderCallbackType) && other is $EmojiCompat_MetadataRepoLoaderCallbackType; } } @@ -1480,7 +1481,7 @@ class $EmojiCompat_MetadataRepoLoaderCallbackType /// Interface to check if a given emoji exists on the system. class EmojiCompat_GlyphChecker extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; EmojiCompat_GlyphChecker.fromRef( jni.JObjectPtr ref, @@ -1570,7 +1571,7 @@ class $EmojiCompat_GlyphCheckerType @override bool operator ==(Object other) { - return other.runtimeType == $EmojiCompat_GlyphCheckerType && + return other.runtimeType == ($EmojiCompat_GlyphCheckerType) && other is $EmojiCompat_GlyphCheckerType; } } @@ -1580,7 +1581,7 @@ class $EmojiCompat_GlyphCheckerType /// Interface to load emoji metadata. class EmojiCompat_MetadataRepoLoader extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; EmojiCompat_MetadataRepoLoader.fromRef( jni.JObjectPtr ref, @@ -1633,7 +1634,7 @@ class $EmojiCompat_MetadataRepoLoaderType @override bool operator ==(Object other) { - return other.runtimeType == $EmojiCompat_MetadataRepoLoaderType && + return other.runtimeType == ($EmojiCompat_MetadataRepoLoaderType) && other is $EmojiCompat_MetadataRepoLoaderType; } } @@ -1643,7 +1644,7 @@ class $EmojiCompat_MetadataRepoLoaderType /// Listener class for the initialization of the EmojiCompat. class EmojiCompat_InitCallback extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; EmojiCompat_InitCallback.fromRef( jni.JObjectPtr ref, @@ -1716,7 +1717,7 @@ class $EmojiCompat_InitCallbackType @override bool operator ==(Object other) { - return other.runtimeType == $EmojiCompat_InitCallbackType && + return other.runtimeType == ($EmojiCompat_InitCallbackType) && other is $EmojiCompat_InitCallbackType; } } @@ -1726,7 +1727,7 @@ class $EmojiCompat_InitCallbackType /// @hide class EmojiCompat_DefaultSpanFactory extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; EmojiCompat_DefaultSpanFactory.fromRef( jni.JObjectPtr ref, @@ -1791,7 +1792,7 @@ class $EmojiCompat_DefaultSpanFactoryType @override bool operator ==(Object other) { - return other.runtimeType == $EmojiCompat_DefaultSpanFactoryType && + return other.runtimeType == ($EmojiCompat_DefaultSpanFactoryType) && other is $EmojiCompat_DefaultSpanFactoryType; } } @@ -1806,7 +1807,7 @@ class $EmojiCompat_DefaultSpanFactoryType /// emoji display (for example, resizing or repositioning emoji). class EmojiCompat_SpanFactory extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; EmojiCompat_SpanFactory.fromRef( jni.JObjectPtr ref, @@ -1860,7 +1861,7 @@ class $EmojiCompat_SpanFactoryType @override bool operator ==(Object other) { - return other.runtimeType == $EmojiCompat_SpanFactoryType && + return other.runtimeType == ($EmojiCompat_SpanFactoryType) && other is $EmojiCompat_SpanFactoryType; } } @@ -1903,7 +1904,7 @@ class $EmojiCompat_SpanFactoryType /// class DefaultEmojiCompatConfig extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; DefaultEmojiCompatConfig.fromRef( jni.JObjectPtr ref, @@ -1958,7 +1959,7 @@ class $DefaultEmojiCompatConfigType @override bool operator ==(Object other) { - return other.runtimeType == $DefaultEmojiCompatConfigType && + return other.runtimeType == ($DefaultEmojiCompatConfigType) && other is $DefaultEmojiCompatConfigType; } } @@ -1970,7 +1971,9 @@ class $DefaultEmojiCompatConfigType class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28 extends DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19 { @override - late final jni.JObjType $type = type; + late final jni.JObjType< + DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28> $type = + type; DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28.fromRef( jni.JObjectPtr ref, @@ -2042,7 +2045,7 @@ class $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28Type @override bool operator ==(Object other) { return other.runtimeType == - $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28Type && + ($DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28Type) && other is $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28Type; } @@ -2055,7 +2058,9 @@ class $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28Type class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19 extends DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper { @override - late final jni.JObjType $type = type; + late final jni.JObjType< + DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19> $type = + type; DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19.fromRef( jni.JObjectPtr ref, @@ -2148,7 +2153,7 @@ class $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19Type @override bool operator ==(Object other) { return other.runtimeType == - $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19Type && + ($DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19Type) && other is $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19Type; } @@ -2161,7 +2166,9 @@ class $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19Type class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni + .JObjType + $type = type; DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper.fromRef( jni.JObjectPtr ref, @@ -2279,7 +2286,7 @@ class $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelperType extends jni @override bool operator ==(Object other) { return other.runtimeType == - $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelperType && + ($DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelperType) && other is $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelperType; } } @@ -2292,7 +2299,9 @@ class $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelperType extends jni class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni + .JObjType + $type = type; DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory.fromRef( jni.JObjectPtr ref, @@ -2366,7 +2375,7 @@ class $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactoryType extends jni @override bool operator ==(Object other) { return other.runtimeType == - $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactoryType && + ($DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactoryType) && other is $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactoryType; } } @@ -2374,7 +2383,7 @@ class $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactoryType extends jni /// from: android.os.Build class Build extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; Build.fromRef( jni.JObjectPtr ref, @@ -2714,7 +2723,7 @@ class $BuildType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $BuildType && other is $BuildType; + return other.runtimeType == ($BuildType) && other is $BuildType; } } @@ -2722,7 +2731,7 @@ class $BuildType extends jni.JObjType { class HashMap<$K extends jni.JObject, $V extends jni.JObject> extends jni.JObject { @override - late final jni.JObjType $type = type(K, V); + late final jni.JObjType> $type = type(K, V); final jni.JObjType<$K> K; final jni.JObjType<$V> V; @@ -3220,8 +3229,8 @@ class $HashMapType<$K extends jni.JObject, $V extends jni.JObject> @override bool operator ==(Object other) { - return other.runtimeType == $HashMapType && - other is $HashMapType && + return other.runtimeType == ($HashMapType<$K, $V>) && + other is $HashMapType<$K, $V> && K == other.K && V == other.V; } diff --git a/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart b/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart index 25cd60487..78a7ded87 100644 --- a/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart +++ b/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart @@ -27,7 +27,7 @@ final ffi.Pointer Function(String sym) jniLookup = /// from: Example class Example extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; Example.fromRef( jni.JObjectPtr ref, @@ -88,6 +88,6 @@ class $ExampleType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $ExampleType && other is $ExampleType; + return other.runtimeType == ($ExampleType) && other is $ExampleType; } } diff --git a/pkgs/jnigen/example/notification_plugin/lib/notifications.dart b/pkgs/jnigen/example/notification_plugin/lib/notifications.dart index 5a4d5591a..c95f3e6e8 100644 --- a/pkgs/jnigen/example/notification_plugin/lib/notifications.dart +++ b/pkgs/jnigen/example/notification_plugin/lib/notifications.dart @@ -31,7 +31,7 @@ final ffi.Pointer Function(String sym) jniLookup = /// from: com.example.notification_plugin.Notifications class Notifications extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; Notifications.fromRef( jni.JObjectPtr ref, @@ -93,7 +93,7 @@ class $NotificationsType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $NotificationsType && + return other.runtimeType == ($NotificationsType) && other is $NotificationsType; } } 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 ec0d86036..25d114650 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 @@ -47,7 +47,7 @@ import "../../../../_init.dart"; ///@author Ben Litchfield class PDDocument extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; PDDocument.fromRef( jni.JObjectPtr ref, @@ -968,7 +968,7 @@ class PDDocument extends jni.JObject { ///@throws InvalidPasswordException If the PDF required a non-empty password. ///@throws IOException In case of a reading or parsing error. static PDDocument load12( - jni.JArray input, + jni.JArray input, ) { return const $PDDocumentType().fromRef(_load12(input.reference).object); } @@ -991,7 +991,7 @@ class PDDocument extends jni.JObject { ///@throws InvalidPasswordException If the password is incorrect. ///@throws IOException In case of a reading or parsing error. static PDDocument load13( - jni.JArray input, + jni.JArray input, jni.JString password, ) { return const $PDDocumentType() @@ -1021,7 +1021,7 @@ class PDDocument extends jni.JObject { ///@throws InvalidPasswordException If the password is incorrect. ///@throws IOException In case of a reading or parsing error. static PDDocument load14( - jni.JArray input, + jni.JArray input, jni.JString password, jni.JObject keyStore, jni.JString alias, @@ -1060,7 +1060,7 @@ class PDDocument extends jni.JObject { ///@throws InvalidPasswordException If the password is incorrect. ///@throws IOException In case of a reading or parsing error. static PDDocument load15( - jni.JArray input, + jni.JArray input, jni.JString password, jni.JObject keyStore, jni.JString alias, @@ -1528,6 +1528,6 @@ class $PDDocumentType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $PDDocumentType && other is $PDDocumentType; + return other.runtimeType == ($PDDocumentType) && other is $PDDocumentType; } } 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 90134bc21..0b2354141 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 @@ -48,7 +48,7 @@ import "../../../../_init.dart"; ///@author Gerardo Ortiz class PDDocumentInformation extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; PDDocumentInformation.fromRef( jni.JObjectPtr ref, @@ -514,7 +514,7 @@ class $PDDocumentInformationType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $PDDocumentInformationType && + return other.runtimeType == ($PDDocumentInformationType) && other is $PDDocumentInformationType; } } 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 59c7919d4..eb3912929 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 @@ -51,7 +51,7 @@ import "../../../../_init.dart"; ///@author Ben Litchfield class PDFTextStripper extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; PDFTextStripper.fromRef( jni.JObjectPtr ref, @@ -1416,7 +1416,7 @@ class $PDFTextStripperType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $PDFTextStripperType && + return other.runtimeType == ($PDFTextStripperType) && other is $PDFTextStripperType; } } diff --git a/pkgs/jnigen/lib/src/bindings/dart_generator.dart b/pkgs/jnigen/lib/src/bindings/dart_generator.dart index c2215296d..326069a76 100644 --- a/pkgs/jnigen/lib/src/bindings/dart_generator.dart +++ b/pkgs/jnigen/lib/src/bindings/dart_generator.dart @@ -36,9 +36,9 @@ const _typeClassPrefix = '\$'; const _typeClassSuffix = 'Type'; // Misc. -const _classRef = '_classRef'; -const _env = 'jniEnv'; -const _accessors = 'jniAccessors'; +const _classRef = '_class.reference'; +const _env = '$_jni.Jni.env'; +const _accessors = '$_jni.Jni.accessors'; const _lookup = 'jniLookup'; const _selfPointer = 'reference'; @@ -143,17 +143,6 @@ final $_ffi.Pointer Function(String sym) $_lookup ProtectedJniExtensions.initGeneratedLibrary("${config.outputConfig.cConfig!.libraryName}"); -'''; - - static const dartOnlyInitImport = 'import "package:jni/jni.dart" as jni;\n'; - - static const dartOnlyInitCode = ''' -// Auto-generated initialization code. - -final $_env = $_jni.Jni.env; -final $_accessors = $_jni.Jni.accessors; - - '''; static const autoGeneratedNotice = '// Autogenerated by jnigen. ' @@ -201,8 +190,6 @@ import "package:jni/jni.dart" as jni; s.writeln(defaultImports); if (cBased) { s.writeln(cInitCode); - } else { - s.writeln(dartOnlyInitCode); } final classGenerator = _ClassGenerator(config, s); node.decls.values.accept(classGenerator).toList(); @@ -224,14 +211,16 @@ import "package:jni/jni.dart" as jni; log.info("Using dart root = $root"); const initFileName = '_init.dart'; - final initFileUri = root.resolve(initFileName); - final initFile = File.fromUri(initFileUri); - await initFile.create(recursive: true); - final initStream = initFile.openWrite(); - initStream.writeln(preamble); - initStream.writeln(cBased ? cInitImport : dartOnlyInitImport); - initStream.writeln(cBased ? cInitCode : dartOnlyInitCode); - await initStream.close(); + if (cBased) { + final initFileUri = root.resolve(initFileName); + final initFile = File.fromUri(initFileUri); + await initFile.create(recursive: true); + final initStream = initFile.openWrite(); + initStream.writeln(preamble); + initStream.writeln(cInitImport); + initStream.writeln(cInitCode); + await initStream.close(); + } for (var fileClassName in files.keys) { final relativeFileName = '${fileClassName.replaceAll('.', '/')}.dart'; final dartFileUri = root.resolve(relativeFileName); @@ -245,12 +234,14 @@ import "package:jni/jni.dart" as jni; dartFileStream.writeln(defaultLintSuppressions); dartFileStream.writeln(defaultImports); final s = StringBuffer(); - final initFilePath = ('../' * - relativeFileName.codeUnits - .where((cu) => cu == '/'.codeUnitAt(0)) - .length) + - initFileName; - s.write('import "$initFilePath";'); + if (cBased) { + final initFilePath = ('../' * + relativeFileName.codeUnits + .where((cu) => cu == '/'.codeUnitAt(0)) + .length) + + initFileName; + s.write('import "$initFilePath";'); + } final resolver = Resolver( importMap: config.importMap ?? {}, currentClass: fileClassName, @@ -342,7 +333,7 @@ class _ClassGenerator extends Visitor { s.write(''' class $name$typeParamsDef extends $superName { @override - late final $_jType $instanceTypeGetter = $staticTypeGetter$staticTypeGetterCallArgs; + late final $_jType<$name$typeParamsCall> $instanceTypeGetter = $staticTypeGetter$staticTypeGetterCallArgs; $typeClassDefinitions @@ -359,7 +350,7 @@ class $name$typeParamsDef extends $superName { if (isDartOnly) { final internalName = node.internalName; s.write(''' - static final $_classRef = $_accessors.getClassOf(r"$internalName"); + static final _class = $_jni.Jni.findJClass(r"$internalName"); '''); } @@ -409,7 +400,7 @@ class $name$typeParamsDef extends $superName { final superTypeClass = superClass.accept(_TypeClassGenerator(resolver)); final hashCodeTypeClasses = typeParams.join(', '); final equalityTypeClasses = typeParams - .map((typeParam) => ' && $typeParam == other.$typeParam') + .map((typeParam) => ' &&\n $typeParam == other.$typeParam') .join(); final hashCode = typeParams.isEmpty ? '($typeClassName).hashCode' @@ -442,7 +433,8 @@ class $typeClassName$typeParamsDef extends $_jType<$name$typeParamsCall> { @override bool operator ==(Object other) { - return other.runtimeType == $typeClassName && other is $typeClassName$equalityTypeClasses; + return other.runtimeType == ($typeClassName$typeParamsCall) && + other is $typeClassName$typeParamsCall$equalityTypeClasses; } } diff --git a/pkgs/jnigen/lib/src/elements/elements.dart b/pkgs/jnigen/lib/src/elements/elements.dart index 4c3ce2afb..2e4a9f516 100644 --- a/pkgs/jnigen/lib/src/elements/elements.dart +++ b/pkgs/jnigen/lib/src/elements/elements.dart @@ -261,7 +261,7 @@ class PrimitiveType extends ReferredType { name: 'byte', signature: 'B', dartType: 'int', - jniType: 'JByte', + jniType: 'jbyte', cType: 'int8_t', ffiType: 'Int8', ), @@ -269,7 +269,7 @@ class PrimitiveType extends ReferredType { name: 'short', signature: 'S', dartType: 'int', - jniType: 'JShort', + jniType: 'jshort', cType: 'int16_t', ffiType: 'Int16', ), @@ -277,7 +277,7 @@ class PrimitiveType extends ReferredType { name: 'char', signature: 'C', dartType: 'int', - jniType: 'JChar', + jniType: 'jchar', cType: 'char', ffiType: 'Uint16', ), @@ -285,7 +285,7 @@ class PrimitiveType extends ReferredType { name: 'int', signature: 'I', dartType: 'int', - jniType: 'JInt', + jniType: 'jint', cType: 'int32_t', ffiType: 'Int32', ), @@ -293,7 +293,7 @@ class PrimitiveType extends ReferredType { name: 'long', signature: 'J', dartType: 'int', - jniType: 'JLong', + jniType: 'jlong', cType: 'int64_t', ffiType: 'Int64', ), @@ -301,7 +301,7 @@ class PrimitiveType extends ReferredType { name: 'float', signature: 'F', dartType: 'double', - jniType: 'JFloat', + jniType: 'jfloat', cType: 'float', ffiType: 'Float', ), @@ -309,7 +309,7 @@ class PrimitiveType extends ReferredType { name: 'double', signature: 'D', dartType: 'double', - jniType: 'JDouble', + jniType: 'jdouble', cType: 'double', ffiType: 'Double', ), @@ -317,7 +317,7 @@ class PrimitiveType extends ReferredType { name: 'boolean', signature: 'Z', dartType: 'bool', - jniType: 'JBoolean', + jniType: 'jboolean', cType: 'uint8_t', ffiType: 'Uint8', ), @@ -325,7 +325,7 @@ class PrimitiveType extends ReferredType { name: 'void', signature: 'V', dartType: 'void', - jniType: 'JVoid', // Never used + jniType: 'jvoid', // Never used cType: 'void', ffiType: 'Void', ), diff --git a/pkgs/jnigen/pubspec.yaml b/pkgs/jnigen/pubspec.yaml index 1da9c68c7..5cde347c6 100644 --- a/pkgs/jnigen/pubspec.yaml +++ b/pkgs/jnigen/pubspec.yaml @@ -3,7 +3,7 @@ # BSD-style license that can be found in the LICENSE file. name: jnigen -version: 0.4.0 +version: 0.5.0-dev.0 description: Experimental generator for FFI+JNI bindings. repository: https://github.com/dart-lang/jnigen/tree/main/jnigen diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart index 4389ac33f..0b91b29f0 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart @@ -60,7 +60,7 @@ import "../../../../_init.dart"; ///@author Tatu Saloranta class JsonFactory extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; JsonFactory.fromRef( jni.JObjectPtr ref, @@ -1208,7 +1208,7 @@ class JsonFactory extends jni.JObject { /// the contents of given byte array. ///@since 2.1 jsonparser_.JsonParser createParser4( - jni.JArray data, + jni.JArray data, ) { return const jsonparser_.$JsonParserType() .fromRef(_createParser4(reference, data.reference).object); @@ -1235,7 +1235,7 @@ class JsonFactory extends jni.JObject { ///@param len Length of contents to parse within buffer ///@since 2.1 jsonparser_.JsonParser createParser5( - jni.JArray data, + jni.JArray data, int offset, int len, ) { @@ -1279,7 +1279,7 @@ class JsonFactory extends jni.JObject { /// contents of given char array. ///@since 2.4 jsonparser_.JsonParser createParser7( - jni.JArray content, + jni.JArray content, ) { return const jsonparser_.$JsonParserType() .fromRef(_createParser7(reference, content.reference).object); @@ -1302,7 +1302,7 @@ class JsonFactory extends jni.JObject { /// Method for constructing parser for parsing contents of given char array. ///@since 2.4 jsonparser_.JsonParser createParser8( - jni.JArray content, + jni.JArray content, int offset, int len, ) { @@ -1690,7 +1690,7 @@ class JsonFactory extends jni.JObject { ///@throws JsonParseException if parser initialization fails due to content decoding problem ///@deprecated Since 2.2, use \#createParser(byte[]) instead. jsonparser_.JsonParser createJsonParser4( - jni.JArray data, + jni.JArray data, ) { return const jsonparser_.$JsonParserType() .fromRef(_createJsonParser4(reference, data.reference).object); @@ -1720,7 +1720,7 @@ class JsonFactory extends jni.JObject { ///@throws JsonParseException if parser initialization fails due to content decoding problem ///@deprecated Since 2.2, use \#createParser(byte[],int,int) instead. jsonparser_.JsonParser createJsonParser5( - jni.JArray data, + jni.JArray data, int offset, int len, ) { @@ -1872,7 +1872,7 @@ class $JsonFactoryType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $JsonFactoryType && other is $JsonFactoryType; + return other.runtimeType == ($JsonFactoryType) && other is $JsonFactoryType; } } @@ -1882,7 +1882,7 @@ class $JsonFactoryType extends jni.JObjType { /// changed for JsonFactory. class JsonFactory_Feature extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; JsonFactory_Feature.fromRef( jni.JObjectPtr ref, @@ -1988,7 +1988,7 @@ class $JsonFactory_FeatureType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $JsonFactory_FeatureType && + return other.runtimeType == ($JsonFactory_FeatureType) && other is $JsonFactory_FeatureType; } } diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart index 54e45f8ef..562f0dd00 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart @@ -47,7 +47,7 @@ import "../../../../_init.dart"; ///@author Tatu Saloranta class JsonParser extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; JsonParser.fromRef( jni.JObjectPtr ref, @@ -193,7 +193,7 @@ class JsonParser extends jni.JObject { ///@param charset Character encoding for (lazily) decoding payload ///@since 2.8 void setRequestPayloadOnError1( - jni.JArray payload, + jni.JArray payload, jni.JString charset, ) { return _setRequestPayloadOnError1( @@ -1593,8 +1593,8 @@ class JsonParser extends jni.JObject { /// at offset 0, and not necessarily until the end of buffer) ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - jni.JArray getTextCharacters() { - return const jni.JArrayType(jni.JCharType()) + jni.JArray getTextCharacters() { + return const jni.JArrayType(jni.jcharType()) .fromRef(_getTextCharacters(reference).object); } @@ -2030,10 +2030,10 @@ class JsonParser extends jni.JObject { ///@return Decoded binary data ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - jni.JArray getBinaryValue( + jni.JArray getBinaryValue( jni.JObject bv, ) { - return const jni.JArrayType(jni.JByteType()) + return const jni.JArrayType(jni.jbyteType()) .fromRef(_getBinaryValue(reference, bv.reference).object); } @@ -2052,8 +2052,8 @@ class JsonParser extends jni.JObject { ///@return Decoded binary data ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - jni.JArray getBinaryValue1() { - return const jni.JArrayType(jni.JByteType()) + jni.JArray getBinaryValue1() { + return const jni.JArrayType(jni.jbyteType()) .fromRef(_getBinaryValue1(reference).object); } @@ -2653,7 +2653,7 @@ class $JsonParserType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $JsonParserType && other is $JsonParserType; + return other.runtimeType == ($JsonParserType) && other is $JsonParserType; } } @@ -2662,7 +2662,7 @@ class $JsonParserType extends jni.JObjType { /// Enumeration that defines all on/off features for parsers. class JsonParser_Feature extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; JsonParser_Feature.fromRef( jni.JObjectPtr ref, @@ -2768,7 +2768,7 @@ class $JsonParser_FeatureType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $JsonParser_FeatureType && + return other.runtimeType == ($JsonParser_FeatureType) && other is $JsonParser_FeatureType; } } @@ -2779,7 +2779,7 @@ class $JsonParser_FeatureType extends jni.JObjType { /// used for numbers. class JsonParser_NumberType extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; JsonParser_NumberType.fromRef( jni.JObjectPtr ref, @@ -2836,7 +2836,7 @@ class $JsonParser_NumberTypeType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $JsonParser_NumberTypeType && + return other.runtimeType == ($JsonParser_NumberTypeType) && other is $JsonParser_NumberTypeType; } } diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart index 071434444..fe8cf885d 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart @@ -44,7 +44,7 @@ import "../../../../_init.dart"; /// of parsing JSON content. class JsonToken extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; JsonToken.fromRef( jni.JObjectPtr ref, @@ -107,8 +107,8 @@ class JsonToken extends jni.JObject { /// from: public final char[] asCharArray() /// The returned object must be deleted after use, by calling the `delete` method. - jni.JArray asCharArray() { - return const jni.JArrayType(jni.JCharType()) + jni.JArray asCharArray() { + return const jni.JArrayType(jni.jcharType()) .fromRef(_asCharArray(reference).object); } @@ -120,8 +120,8 @@ class JsonToken extends jni.JObject { /// from: public final byte[] asByteArray() /// The returned object must be deleted after use, by calling the `delete` method. - jni.JArray asByteArray() { - return const jni.JArrayType(jni.JByteType()) + jni.JArray asByteArray() { + return const jni.JArrayType(jni.jbyteType()) .fromRef(_asByteArray(reference).object); } @@ -230,6 +230,6 @@ class $JsonTokenType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $JsonTokenType && other is $JsonTokenType; + return other.runtimeType == ($JsonTokenType) && other is $JsonTokenType; } } diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/_init.dart b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/_init.dart deleted file mode 100644 index eec3a8c14..000000000 --- a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/_init.dart +++ /dev/null @@ -1,23 +0,0 @@ -// Generated from jackson-core which is licensed under the Apache License 2.0. -// The following copyright from the original authors applies. -// See https://github.com/FasterXML/jackson-core/blob/2.14/LICENSE -// -// Copyright (c) 2007 - The Jackson Project Authors -// Licensed under the Apache License, Version 2.0 (the "License") -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import "package:jni/jni.dart" as jni; - -// Auto-generated initialization code. - -final jniEnv = jni.Jni.env; -final jniAccessors = jni.Jni.accessors; diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart index 2ceb3242b..c58fb97aa 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart @@ -37,7 +37,6 @@ import "package:jni/internal_helpers_for_jnigen.dart"; import "package:jni/jni.dart" as jni; import "JsonParser.dart" as jsonparser_; -import "../../../../_init.dart"; /// from: com.fasterxml.jackson.core.JsonFactory /// @@ -60,14 +59,14 @@ import "../../../../_init.dart"; ///@author Tatu Saloranta class JsonFactory extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; JsonFactory.fromRef( jni.JObjectPtr ref, ) : super.fromRef(ref); - static final _classRef = - jniAccessors.getClassOf(r"com/fasterxml/jackson/core/JsonFactory"); + static final _class = + jni.Jni.findJClass(r"com/fasterxml/jackson/core/JsonFactory"); /// The type which includes information such as the signature of this class. static const type = $JsonFactoryType(); @@ -79,8 +78,8 @@ class JsonFactory extends jni.JObject { static const FORMAT_NAME_JSON = r"""JSON"""; static final _id_DEFAULT_FACTORY_FEATURE_FLAGS = - jniAccessors.getStaticFieldIDOf( - _classRef, + jni.Jni.accessors.getStaticFieldIDOf( + _class.reference, r"DEFAULT_FACTORY_FEATURE_FLAGS", r"I", ); @@ -88,14 +87,14 @@ class JsonFactory extends jni.JObject { /// from: static protected final int DEFAULT_FACTORY_FEATURE_FLAGS /// /// Bitfield (set of flags) of all factory features that are enabled by default. - static int get DEFAULT_FACTORY_FEATURE_FLAGS => jniAccessors - .getStaticField( - _classRef, _id_DEFAULT_FACTORY_FEATURE_FLAGS, jni.JniCallType.intType) + static int get DEFAULT_FACTORY_FEATURE_FLAGS => jni.Jni.accessors + .getStaticField(_class.reference, _id_DEFAULT_FACTORY_FEATURE_FLAGS, + jni.JniCallType.intType) .integer; static final _id_DEFAULT_PARSER_FEATURE_FLAGS = - jniAccessors.getStaticFieldIDOf( - _classRef, + jni.Jni.accessors.getStaticFieldIDOf( + _class.reference, r"DEFAULT_PARSER_FEATURE_FLAGS", r"I", ); @@ -104,14 +103,14 @@ class JsonFactory extends jni.JObject { /// /// Bitfield (set of flags) of all parser features that are enabled /// by default. - static int get DEFAULT_PARSER_FEATURE_FLAGS => jniAccessors - .getStaticField( - _classRef, _id_DEFAULT_PARSER_FEATURE_FLAGS, jni.JniCallType.intType) + static int get DEFAULT_PARSER_FEATURE_FLAGS => jni.Jni.accessors + .getStaticField(_class.reference, _id_DEFAULT_PARSER_FEATURE_FLAGS, + jni.JniCallType.intType) .integer; static final _id_DEFAULT_GENERATOR_FEATURE_FLAGS = - jniAccessors.getStaticFieldIDOf( - _classRef, + jni.Jni.accessors.getStaticFieldIDOf( + _class.reference, r"DEFAULT_GENERATOR_FEATURE_FLAGS", r"I", ); @@ -120,14 +119,14 @@ class JsonFactory extends jni.JObject { /// /// Bitfield (set of flags) of all generator features that are enabled /// by default. - static int get DEFAULT_GENERATOR_FEATURE_FLAGS => jniAccessors - .getStaticField(_classRef, _id_DEFAULT_GENERATOR_FEATURE_FLAGS, + static int get DEFAULT_GENERATOR_FEATURE_FLAGS => jni.Jni.accessors + .getStaticField(_class.reference, _id_DEFAULT_GENERATOR_FEATURE_FLAGS, jni.JniCallType.intType) .integer; static final _id_DEFAULT_ROOT_VALUE_SEPARATOR = - jniAccessors.getStaticFieldIDOf( - _classRef, + jni.Jni.accessors.getStaticFieldIDOf( + _class.reference, r"DEFAULT_ROOT_VALUE_SEPARATOR", r"Lcom/fasterxml/jackson/core/SerializableString;", ); @@ -135,13 +134,13 @@ class JsonFactory extends jni.JObject { /// from: static public final com.fasterxml.jackson.core.SerializableString DEFAULT_ROOT_VALUE_SEPARATOR /// The returned object must be deleted after use, by calling the `delete` method. static jni.JObject get DEFAULT_ROOT_VALUE_SEPARATOR => - const jni.JObjectType().fromRef(jniAccessors - .getStaticField(_classRef, _id_DEFAULT_ROOT_VALUE_SEPARATOR, + const jni.JObjectType().fromRef(jni.Jni.accessors + .getStaticField(_class.reference, _id_DEFAULT_ROOT_VALUE_SEPARATOR, jni.JniCallType.objectType) .object); static final _id_ctor = - jniAccessors.getMethodIDOf(_classRef, r"", r"()V"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. @@ -155,23 +154,25 @@ class JsonFactory extends jni.JObject { /// and this reuse only works within context of a single /// factory instance. factory JsonFactory() { - return JsonFactory.fromRef( - jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); + return JsonFactory.fromRef(jni.Jni.accessors + .newObjectWithArgs(_class.reference, _id_ctor, []).object); } - static final _id_ctor1 = jniAccessors.getMethodIDOf( - _classRef, r"", r"(Lcom/fasterxml/jackson/core/ObjectCodec;)V"); + static final _id_ctor1 = jni.Jni.accessors.getMethodIDOf(_class.reference, + r"", r"(Lcom/fasterxml/jackson/core/ObjectCodec;)V"); /// from: public void (com.fasterxml.jackson.core.ObjectCodec oc) /// The returned object must be deleted after use, by calling the `delete` method. factory JsonFactory.ctor1( jni.JObject oc, ) { - return JsonFactory.fromRef(jniAccessors - .newObjectWithArgs(_classRef, _id_ctor1, [oc.reference]).object); + return JsonFactory.fromRef(jni.Jni.accessors + .newObjectWithArgs(_class.reference, _id_ctor1, [oc.reference]).object); } - static final _id_ctor2 = jniAccessors.getMethodIDOf(_classRef, r"", + static final _id_ctor2 = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"", r"(Lcom/fasterxml/jackson/core/JsonFactory;Lcom/fasterxml/jackson/core/ObjectCodec;)V"); /// from: protected void (com.fasterxml.jackson.core.JsonFactory src, com.fasterxml.jackson.core.ObjectCodec codec) @@ -185,12 +186,12 @@ class JsonFactory extends jni.JObject { JsonFactory src, jni.JObject codec, ) { - return JsonFactory.fromRef(jniAccessors.newObjectWithArgs( - _classRef, _id_ctor2, [src.reference, codec.reference]).object); + return JsonFactory.fromRef(jni.Jni.accessors.newObjectWithArgs( + _class.reference, _id_ctor2, [src.reference, codec.reference]).object); } - static final _id_ctor3 = jniAccessors.getMethodIDOf(_classRef, r"", - r"(Lcom/fasterxml/jackson/core/JsonFactoryBuilder;)V"); + static final _id_ctor3 = jni.Jni.accessors.getMethodIDOf(_class.reference, + r"", r"(Lcom/fasterxml/jackson/core/JsonFactoryBuilder;)V"); /// from: public void (com.fasterxml.jackson.core.JsonFactoryBuilder b) /// The returned object must be deleted after use, by calling the `delete` method. @@ -201,12 +202,12 @@ class JsonFactory extends jni.JObject { factory JsonFactory.ctor3( jni.JObject b, ) { - return JsonFactory.fromRef(jniAccessors - .newObjectWithArgs(_classRef, _id_ctor3, [b.reference]).object); + return JsonFactory.fromRef(jni.Jni.accessors + .newObjectWithArgs(_class.reference, _id_ctor3, [b.reference]).object); } - static final _id_ctor4 = jniAccessors.getMethodIDOf( - _classRef, r"", r"(Lcom/fasterxml/jackson/core/TSFBuilder;Z)V"); + static final _id_ctor4 = jni.Jni.accessors.getMethodIDOf(_class.reference, + r"", r"(Lcom/fasterxml/jackson/core/TSFBuilder;Z)V"); /// from: protected void (com.fasterxml.jackson.core.TSFBuilder b, boolean bogus) /// The returned object must be deleted after use, by calling the `delete` method. @@ -220,12 +221,12 @@ class JsonFactory extends jni.JObject { jni.JObject b, bool bogus, ) { - return JsonFactory.fromRef(jniAccessors.newObjectWithArgs( - _classRef, _id_ctor4, [b.reference, bogus ? 1 : 0]).object); + return JsonFactory.fromRef(jni.Jni.accessors.newObjectWithArgs( + _class.reference, _id_ctor4, [b.reference, bogus ? 1 : 0]).object); } - static final _id_rebuild = jniAccessors.getMethodIDOf( - _classRef, r"rebuild", r"()Lcom/fasterxml/jackson/core/TSFBuilder;"); + static final _id_rebuild = jni.Jni.accessors.getMethodIDOf(_class.reference, + r"rebuild", r"()Lcom/fasterxml/jackson/core/TSFBuilder;"); /// from: public com.fasterxml.jackson.core.TSFBuilder rebuild() /// The returned object must be deleted after use, by calling the `delete` method. @@ -235,12 +236,14 @@ class JsonFactory extends jni.JObject { ///@return Builder instance to use ///@since 2.10 jni.JObject rebuild() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_rebuild, jni.JniCallType.objectType, []).object); } - static final _id_builder = jniAccessors.getStaticMethodIDOf( - _classRef, r"builder", r"()Lcom/fasterxml/jackson/core/TSFBuilder;"); + static final _id_builder = jni.Jni.accessors.getStaticMethodIDOf( + _class.reference, + r"builder", + r"()Lcom/fasterxml/jackson/core/TSFBuilder;"); /// from: static public com.fasterxml.jackson.core.TSFBuilder builder() /// The returned object must be deleted after use, by calling the `delete` method. @@ -254,13 +257,13 @@ class JsonFactory extends jni.JObject { /// will be fixed in 3.0. ///@return Builder instance to use static jni.JObject builder() { - return const jni.JObjectType().fromRef(jniAccessors - .callStaticMethodWithArgs( - _classRef, _id_builder, jni.JniCallType.objectType, []).object); + return const jni.JObjectType().fromRef(jni.Jni.accessors + .callStaticMethodWithArgs(_class.reference, _id_builder, + jni.JniCallType.objectType, []).object); } - static final _id_copy = jniAccessors.getMethodIDOf( - _classRef, r"copy", r"()Lcom/fasterxml/jackson/core/JsonFactory;"); + static final _id_copy = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"copy", r"()Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public com.fasterxml.jackson.core.JsonFactory copy() /// The returned object must be deleted after use, by calling the `delete` method. @@ -278,12 +281,13 @@ class JsonFactory extends jni.JObject { ///@return Copy of this factory instance ///@since 2.1 JsonFactory copy() { - return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_copy, jni.JniCallType.objectType, []).object); + return const $JsonFactoryType().fromRef(jni.Jni.accessors + .callMethodWithArgs( + reference, _id_copy, jni.JniCallType.objectType, []).object); } - static final _id_readResolve = jniAccessors.getMethodIDOf( - _classRef, r"readResolve", r"()Ljava/lang/Object;"); + static final _id_readResolve = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"readResolve", r"()Ljava/lang/Object;"); /// from: protected java.lang.Object readResolve() /// The returned object must be deleted after use, by calling the `delete` method. @@ -295,12 +299,12 @@ class JsonFactory extends jni.JObject { /// Note: must be overridden by sub-classes as well. ///@return Newly constructed instance jni.JObject readResolve() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_readResolve, jni.JniCallType.objectType, []).object); } - static final _id_requiresPropertyOrdering = jniAccessors.getMethodIDOf( - _classRef, r"requiresPropertyOrdering", r"()Z"); + static final _id_requiresPropertyOrdering = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"requiresPropertyOrdering", r"()Z"); /// from: public boolean requiresPropertyOrdering() /// @@ -319,12 +323,12 @@ class JsonFactory extends jni.JObject { /// requires Object properties to be ordered. ///@since 2.3 bool requiresPropertyOrdering() { - return jniAccessors.callMethodWithArgs(reference, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_requiresPropertyOrdering, jni.JniCallType.booleanType, []).boolean; } - static final _id_canHandleBinaryNatively = - jniAccessors.getMethodIDOf(_classRef, r"canHandleBinaryNatively", r"()Z"); + static final _id_canHandleBinaryNatively = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"canHandleBinaryNatively", r"()Z"); /// from: public boolean canHandleBinaryNatively() /// @@ -340,12 +344,12 @@ class JsonFactory extends jni.JObject { /// supports native binary content ///@since 2.3 bool canHandleBinaryNatively() { - return jniAccessors.callMethodWithArgs(reference, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_canHandleBinaryNatively, jni.JniCallType.booleanType, []).boolean; } - static final _id_canUseCharArrays = - jniAccessors.getMethodIDOf(_classRef, r"canUseCharArrays", r"()Z"); + static final _id_canUseCharArrays = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"canUseCharArrays", r"()Z"); /// from: public boolean canUseCharArrays() /// @@ -361,12 +365,12 @@ class JsonFactory extends jni.JObject { /// accessed using parser method {@code getTextCharacters()}. ///@since 2.4 bool canUseCharArrays() { - return jniAccessors.callMethodWithArgs(reference, _id_canUseCharArrays, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_canUseCharArrays, jni.JniCallType.booleanType, []).boolean; } - static final _id_canParseAsync = - jniAccessors.getMethodIDOf(_classRef, r"canParseAsync", r"()Z"); + static final _id_canParseAsync = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"canParseAsync", r"()Z"); /// from: public boolean canParseAsync() /// @@ -378,36 +382,38 @@ class JsonFactory extends jni.JObject { /// not (and consequently whether {@code createNonBlockingXxx()} method(s) work) ///@since 2.9 bool canParseAsync() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_canParseAsync, jni.JniCallType.booleanType, []).boolean; } - static final _id_getFormatReadFeatureType = jniAccessors.getMethodIDOf( - _classRef, r"getFormatReadFeatureType", r"()Ljava/lang/Class;"); + static final _id_getFormatReadFeatureType = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"getFormatReadFeatureType", r"()Ljava/lang/Class;"); /// from: public java.lang.Class getFormatReadFeatureType() /// The returned object must be deleted after use, by calling the `delete` method. jni.JObject getFormatReadFeatureType() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getFormatReadFeatureType, jni.JniCallType.objectType, []).object); } - static final _id_getFormatWriteFeatureType = jniAccessors.getMethodIDOf( - _classRef, r"getFormatWriteFeatureType", r"()Ljava/lang/Class;"); + static final _id_getFormatWriteFeatureType = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"getFormatWriteFeatureType", r"()Ljava/lang/Class;"); /// from: public java.lang.Class getFormatWriteFeatureType() /// The returned object must be deleted after use, by calling the `delete` method. jni.JObject getFormatWriteFeatureType() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getFormatWriteFeatureType, jni.JniCallType.objectType, []).object); } - static final _id_canUseSchema = jniAccessors.getMethodIDOf(_classRef, - r"canUseSchema", r"(Lcom/fasterxml/jackson/core/FormatSchema;)Z"); + static final _id_canUseSchema = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"canUseSchema", + r"(Lcom/fasterxml/jackson/core/FormatSchema;)Z"); /// from: public boolean canUseSchema(com.fasterxml.jackson.core.FormatSchema schema) /// @@ -423,12 +429,12 @@ class JsonFactory extends jni.JObject { bool canUseSchema( jni.JObject schema, ) { - return jniAccessors.callMethodWithArgs(reference, _id_canUseSchema, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_canUseSchema, jni.JniCallType.booleanType, [schema.reference]).boolean; } - static final _id_getFormatName = jniAccessors.getMethodIDOf( - _classRef, r"getFormatName", r"()Ljava/lang/String;"); + static final _id_getFormatName = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"getFormatName", r"()Ljava/lang/String;"); /// from: public java.lang.String getFormatName() /// The returned object must be deleted after use, by calling the `delete` method. @@ -440,12 +446,12 @@ 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 const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JStringType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getFormatName, jni.JniCallType.objectType, []).object); } - static final _id_hasFormat = jniAccessors.getMethodIDOf( - _classRef, + static final _id_hasFormat = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"hasFormat", r"(Lcom/fasterxml/jackson/core/format/InputAccessor;)Lcom/fasterxml/jackson/core/format/MatchStrength;"); @@ -454,15 +460,15 @@ class JsonFactory extends jni.JObject { jni.JObject hasFormat( jni.JObject acc, ) { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_hasFormat, jni.JniCallType.objectType, [acc.reference]).object); } - static final _id_requiresCustomCodec = - jniAccessors.getMethodIDOf(_classRef, r"requiresCustomCodec", r"()Z"); + static final _id_requiresCustomCodec = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"requiresCustomCodec", r"()Z"); /// from: public boolean requiresCustomCodec() /// @@ -476,12 +482,12 @@ class JsonFactory extends jni.JObject { /// ObjectCodec is enough ///@since 2.1 bool requiresCustomCodec() { - return jniAccessors.callMethodWithArgs(reference, _id_requiresCustomCodec, - jni.JniCallType.booleanType, []).boolean; + return jni.Jni.accessors.callMethodWithArgs(reference, + _id_requiresCustomCodec, jni.JniCallType.booleanType, []).boolean; } - static final _id_hasJSONFormat = jniAccessors.getMethodIDOf( - _classRef, + static final _id_hasJSONFormat = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"hasJSONFormat", r"(Lcom/fasterxml/jackson/core/format/InputAccessor;)Lcom/fasterxml/jackson/core/format/MatchStrength;"); @@ -490,25 +496,25 @@ class JsonFactory extends jni.JObject { jni.JObject hasJSONFormat( jni.JObject acc, ) { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_hasJSONFormat, jni.JniCallType.objectType, [acc.reference]).object); } - static final _id_version = jniAccessors.getMethodIDOf( - _classRef, r"version", r"()Lcom/fasterxml/jackson/core/Version;"); + static final _id_version = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"version", r"()Lcom/fasterxml/jackson/core/Version;"); /// from: public com.fasterxml.jackson.core.Version version() /// The returned object must be deleted after use, by calling the `delete` method. jni.JObject version() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_version, jni.JniCallType.objectType, []).object); } - static final _id_configure = jniAccessors.getMethodIDOf( - _classRef, + static final _id_configure = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"configure", r"(Lcom/fasterxml/jackson/core/JsonFactory$Feature;Z)Lcom/fasterxml/jackson/core/JsonFactory;"); @@ -525,14 +531,14 @@ class JsonFactory extends jni.JObject { JsonFactory_Feature f, bool state, ) { - return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_configure, - jni.JniCallType.objectType, - [f.reference, state ? 1 : 0]).object); + return const $JsonFactoryType().fromRef(jni.Jni.accessors + .callMethodWithArgs(reference, _id_configure, + jni.JniCallType.objectType, [f.reference, state ? 1 : 0]).object); } - static final _id_enable = jniAccessors.getMethodIDOf(_classRef, r"enable", + static final _id_enable = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"enable", r"(Lcom/fasterxml/jackson/core/JsonFactory$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public com.fasterxml.jackson.core.JsonFactory enable(com.fasterxml.jackson.core.JsonFactory.Feature f) @@ -546,14 +552,14 @@ class JsonFactory extends jni.JObject { JsonFactory enable( JsonFactory_Feature f, ) { - return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_enable, - jni.JniCallType.objectType, - [f.reference]).object); + return const $JsonFactoryType().fromRef(jni.Jni.accessors + .callMethodWithArgs(reference, _id_enable, jni.JniCallType.objectType, + [f.reference]).object); } - static final _id_disable = jniAccessors.getMethodIDOf(_classRef, r"disable", + static final _id_disable = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"disable", r"(Lcom/fasterxml/jackson/core/JsonFactory$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public com.fasterxml.jackson.core.JsonFactory disable(com.fasterxml.jackson.core.JsonFactory.Feature f) @@ -567,14 +573,12 @@ class JsonFactory extends jni.JObject { JsonFactory disable( JsonFactory_Feature f, ) { - return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_disable, - jni.JniCallType.objectType, - [f.reference]).object); + return const $JsonFactoryType().fromRef(jni.Jni.accessors + .callMethodWithArgs(reference, _id_disable, jni.JniCallType.objectType, + [f.reference]).object); } - static final _id_isEnabled = jniAccessors.getMethodIDOf(_classRef, + static final _id_isEnabled = jni.Jni.accessors.getMethodIDOf(_class.reference, r"isEnabled", r"(Lcom/fasterxml/jackson/core/JsonFactory$Feature;)Z"); /// from: public final boolean isEnabled(com.fasterxml.jackson.core.JsonFactory.Feature f) @@ -585,48 +589,48 @@ class JsonFactory extends jni.JObject { bool isEnabled( JsonFactory_Feature f, ) { - return jniAccessors.callMethodWithArgs(reference, _id_isEnabled, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_isEnabled, jni.JniCallType.booleanType, [f.reference]).boolean; } - static final _id_getParserFeatures = - jniAccessors.getMethodIDOf(_classRef, r"getParserFeatures", r"()I"); + static final _id_getParserFeatures = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"getParserFeatures", r"()I"); /// from: public final int getParserFeatures() int getParserFeatures() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_getParserFeatures, jni.JniCallType.intType, []).integer; } - static final _id_getGeneratorFeatures = - jniAccessors.getMethodIDOf(_classRef, r"getGeneratorFeatures", r"()I"); + static final _id_getGeneratorFeatures = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"getGeneratorFeatures", r"()I"); /// from: public final int getGeneratorFeatures() int getGeneratorFeatures() { - return jniAccessors.callMethodWithArgs(reference, _id_getGeneratorFeatures, - jni.JniCallType.intType, []).integer; + return jni.Jni.accessors.callMethodWithArgs(reference, + _id_getGeneratorFeatures, jni.JniCallType.intType, []).integer; } - static final _id_getFormatParserFeatures = - jniAccessors.getMethodIDOf(_classRef, r"getFormatParserFeatures", r"()I"); + static final _id_getFormatParserFeatures = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"getFormatParserFeatures", r"()I"); /// from: public int getFormatParserFeatures() int getFormatParserFeatures() { - return jniAccessors.callMethodWithArgs(reference, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_getFormatParserFeatures, jni.JniCallType.intType, []).integer; } - static final _id_getFormatGeneratorFeatures = jniAccessors.getMethodIDOf( - _classRef, r"getFormatGeneratorFeatures", r"()I"); + static final _id_getFormatGeneratorFeatures = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"getFormatGeneratorFeatures", r"()I"); /// from: public int getFormatGeneratorFeatures() int getFormatGeneratorFeatures() { - return jniAccessors.callMethodWithArgs(reference, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_getFormatGeneratorFeatures, jni.JniCallType.intType, []).integer; } - static final _id_configure1 = jniAccessors.getMethodIDOf( - _classRef, + static final _id_configure1 = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"configure", r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;Z)Lcom/fasterxml/jackson/core/JsonFactory;"); @@ -642,14 +646,14 @@ class JsonFactory extends jni.JObject { jsonparser_.JsonParser_Feature f, bool state, ) { - return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_configure1, - jni.JniCallType.objectType, - [f.reference, state ? 1 : 0]).object); + return const $JsonFactoryType().fromRef(jni.Jni.accessors + .callMethodWithArgs(reference, _id_configure1, + jni.JniCallType.objectType, [f.reference, state ? 1 : 0]).object); } - static final _id_enable1 = jniAccessors.getMethodIDOf(_classRef, r"enable", + static final _id_enable1 = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"enable", r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public com.fasterxml.jackson.core.JsonFactory enable(com.fasterxml.jackson.core.JsonParser.Feature f) @@ -662,14 +666,14 @@ class JsonFactory extends jni.JObject { JsonFactory enable1( jsonparser_.JsonParser_Feature f, ) { - return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_enable1, - jni.JniCallType.objectType, - [f.reference]).object); + return const $JsonFactoryType().fromRef(jni.Jni.accessors + .callMethodWithArgs(reference, _id_enable1, jni.JniCallType.objectType, + [f.reference]).object); } - static final _id_disable1 = jniAccessors.getMethodIDOf(_classRef, r"disable", + static final _id_disable1 = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"disable", r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public com.fasterxml.jackson.core.JsonFactory disable(com.fasterxml.jackson.core.JsonParser.Feature f) @@ -682,15 +686,15 @@ class JsonFactory extends jni.JObject { JsonFactory disable1( jsonparser_.JsonParser_Feature f, ) { - return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_disable1, - jni.JniCallType.objectType, - [f.reference]).object); + return const $JsonFactoryType().fromRef(jni.Jni.accessors + .callMethodWithArgs(reference, _id_disable1, jni.JniCallType.objectType, + [f.reference]).object); } - static final _id_isEnabled1 = jniAccessors.getMethodIDOf(_classRef, - r"isEnabled", r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Z"); + static final _id_isEnabled1 = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"isEnabled", + r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Z"); /// from: public final boolean isEnabled(com.fasterxml.jackson.core.JsonParser.Feature f) /// @@ -700,12 +704,14 @@ class JsonFactory extends jni.JObject { bool isEnabled1( jsonparser_.JsonParser_Feature f, ) { - return jniAccessors.callMethodWithArgs(reference, _id_isEnabled1, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_isEnabled1, jni.JniCallType.booleanType, [f.reference]).boolean; } - static final _id_isEnabled2 = jniAccessors.getMethodIDOf(_classRef, - r"isEnabled", r"(Lcom/fasterxml/jackson/core/StreamReadFeature;)Z"); + static final _id_isEnabled2 = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"isEnabled", + r"(Lcom/fasterxml/jackson/core/StreamReadFeature;)Z"); /// from: public final boolean isEnabled(com.fasterxml.jackson.core.StreamReadFeature f) /// @@ -716,12 +722,12 @@ class JsonFactory extends jni.JObject { bool isEnabled2( jni.JObject f, ) { - return jniAccessors.callMethodWithArgs(reference, _id_isEnabled2, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_isEnabled2, jni.JniCallType.booleanType, [f.reference]).boolean; } - static final _id_getInputDecorator = jniAccessors.getMethodIDOf( - _classRef, + static final _id_getInputDecorator = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"getInputDecorator", r"()Lcom/fasterxml/jackson/core/io/InputDecorator;"); @@ -732,14 +738,14 @@ class JsonFactory extends jni.JObject { /// there is no default decorator). ///@return InputDecorator configured, if any jni.JObject getInputDecorator() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getInputDecorator, jni.JniCallType.objectType, []).object); } - static final _id_setInputDecorator = jniAccessors.getMethodIDOf( - _classRef, + static final _id_setInputDecorator = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"setInputDecorator", r"(Lcom/fasterxml/jackson/core/io/InputDecorator;)Lcom/fasterxml/jackson/core/JsonFactory;"); @@ -753,15 +759,13 @@ class JsonFactory extends jni.JObject { JsonFactory setInputDecorator( jni.JObject d, ) { - return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_setInputDecorator, - jni.JniCallType.objectType, - [d.reference]).object); + return const $JsonFactoryType().fromRef(jni.Jni.accessors + .callMethodWithArgs(reference, _id_setInputDecorator, + jni.JniCallType.objectType, [d.reference]).object); } - static final _id_configure2 = jniAccessors.getMethodIDOf( - _classRef, + static final _id_configure2 = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"configure", r"(Lcom/fasterxml/jackson/core/JsonGenerator$Feature;Z)Lcom/fasterxml/jackson/core/JsonFactory;"); @@ -777,14 +781,14 @@ class JsonFactory extends jni.JObject { jni.JObject f, bool state, ) { - return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_configure2, - jni.JniCallType.objectType, - [f.reference, state ? 1 : 0]).object); + return const $JsonFactoryType().fromRef(jni.Jni.accessors + .callMethodWithArgs(reference, _id_configure2, + jni.JniCallType.objectType, [f.reference, state ? 1 : 0]).object); } - static final _id_enable2 = jniAccessors.getMethodIDOf(_classRef, r"enable", + static final _id_enable2 = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"enable", r"(Lcom/fasterxml/jackson/core/JsonGenerator$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public com.fasterxml.jackson.core.JsonFactory enable(com.fasterxml.jackson.core.JsonGenerator.Feature f) @@ -797,14 +801,14 @@ class JsonFactory extends jni.JObject { JsonFactory enable2( jni.JObject f, ) { - return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_enable2, - jni.JniCallType.objectType, - [f.reference]).object); + return const $JsonFactoryType().fromRef(jni.Jni.accessors + .callMethodWithArgs(reference, _id_enable2, jni.JniCallType.objectType, + [f.reference]).object); } - static final _id_disable2 = jniAccessors.getMethodIDOf(_classRef, r"disable", + static final _id_disable2 = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"disable", r"(Lcom/fasterxml/jackson/core/JsonGenerator$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public com.fasterxml.jackson.core.JsonFactory disable(com.fasterxml.jackson.core.JsonGenerator.Feature f) @@ -817,15 +821,15 @@ class JsonFactory extends jni.JObject { JsonFactory disable2( jni.JObject f, ) { - return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_disable2, - jni.JniCallType.objectType, - [f.reference]).object); + return const $JsonFactoryType().fromRef(jni.Jni.accessors + .callMethodWithArgs(reference, _id_disable2, jni.JniCallType.objectType, + [f.reference]).object); } - static final _id_isEnabled3 = jniAccessors.getMethodIDOf(_classRef, - r"isEnabled", r"(Lcom/fasterxml/jackson/core/JsonGenerator$Feature;)Z"); + static final _id_isEnabled3 = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"isEnabled", + r"(Lcom/fasterxml/jackson/core/JsonGenerator$Feature;)Z"); /// from: public final boolean isEnabled(com.fasterxml.jackson.core.JsonGenerator.Feature f) /// @@ -835,12 +839,14 @@ class JsonFactory extends jni.JObject { bool isEnabled3( jni.JObject f, ) { - return jniAccessors.callMethodWithArgs(reference, _id_isEnabled3, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_isEnabled3, jni.JniCallType.booleanType, [f.reference]).boolean; } - static final _id_isEnabled4 = jniAccessors.getMethodIDOf(_classRef, - r"isEnabled", r"(Lcom/fasterxml/jackson/core/StreamWriteFeature;)Z"); + static final _id_isEnabled4 = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"isEnabled", + r"(Lcom/fasterxml/jackson/core/StreamWriteFeature;)Z"); /// from: public final boolean isEnabled(com.fasterxml.jackson.core.StreamWriteFeature f) /// @@ -851,12 +857,12 @@ class JsonFactory extends jni.JObject { bool isEnabled4( jni.JObject f, ) { - return jniAccessors.callMethodWithArgs(reference, _id_isEnabled4, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_isEnabled4, jni.JniCallType.booleanType, [f.reference]).boolean; } - static final _id_getCharacterEscapes = jniAccessors.getMethodIDOf( - _classRef, + static final _id_getCharacterEscapes = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"getCharacterEscapes", r"()Lcom/fasterxml/jackson/core/io/CharacterEscapes;"); @@ -867,14 +873,14 @@ class JsonFactory extends jni.JObject { /// it creates. ///@return Configured {@code CharacterEscapes}, if any; {@code null} if none jni.JObject getCharacterEscapes() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getCharacterEscapes, jni.JniCallType.objectType, []).object); } - static final _id_setCharacterEscapes = jniAccessors.getMethodIDOf( - _classRef, + static final _id_setCharacterEscapes = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"setCharacterEscapes", r"(Lcom/fasterxml/jackson/core/io/CharacterEscapes;)Lcom/fasterxml/jackson/core/JsonFactory;"); @@ -888,15 +894,13 @@ class JsonFactory extends jni.JObject { JsonFactory setCharacterEscapes( jni.JObject esc, ) { - return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_setCharacterEscapes, - jni.JniCallType.objectType, - [esc.reference]).object); + return const $JsonFactoryType().fromRef(jni.Jni.accessors + .callMethodWithArgs(reference, _id_setCharacterEscapes, + jni.JniCallType.objectType, [esc.reference]).object); } - static final _id_getOutputDecorator = jniAccessors.getMethodIDOf( - _classRef, + static final _id_getOutputDecorator = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"getOutputDecorator", r"()Lcom/fasterxml/jackson/core/io/OutputDecorator;"); @@ -908,14 +912,14 @@ class JsonFactory extends jni.JObject { ///@return OutputDecorator configured for generators factory creates, if any; /// {@code null} if none. jni.JObject getOutputDecorator() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getOutputDecorator, jni.JniCallType.objectType, []).object); } - static final _id_setOutputDecorator = jniAccessors.getMethodIDOf( - _classRef, + static final _id_setOutputDecorator = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"setOutputDecorator", r"(Lcom/fasterxml/jackson/core/io/OutputDecorator;)Lcom/fasterxml/jackson/core/JsonFactory;"); @@ -929,15 +933,13 @@ class JsonFactory extends jni.JObject { JsonFactory setOutputDecorator( jni.JObject d, ) { - return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_setOutputDecorator, - jni.JniCallType.objectType, - [d.reference]).object); + return const $JsonFactoryType().fromRef(jni.Jni.accessors + .callMethodWithArgs(reference, _id_setOutputDecorator, + jni.JniCallType.objectType, [d.reference]).object); } - static final _id_setRootValueSeparator = jniAccessors.getMethodIDOf( - _classRef, + static final _id_setRootValueSeparator = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"setRootValueSeparator", r"(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonFactory;"); @@ -952,28 +954,28 @@ class JsonFactory extends jni.JObject { JsonFactory setRootValueSeparator( jni.JString sep, ) { - return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_setRootValueSeparator, - jni.JniCallType.objectType, - [sep.reference]).object); + return const $JsonFactoryType().fromRef(jni.Jni.accessors + .callMethodWithArgs(reference, _id_setRootValueSeparator, + jni.JniCallType.objectType, [sep.reference]).object); } - static final _id_getRootValueSeparator = jniAccessors.getMethodIDOf( - _classRef, r"getRootValueSeparator", r"()Ljava/lang/String;"); + static final _id_getRootValueSeparator = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"getRootValueSeparator", r"()Ljava/lang/String;"); /// from: public java.lang.String getRootValueSeparator() /// The returned object must be deleted after use, by calling the `delete` method. /// /// @return Root value separator configured, if any jni.JString getRootValueSeparator() { - return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JStringType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getRootValueSeparator, jni.JniCallType.objectType, []).object); } - static final _id_setCodec = jniAccessors.getMethodIDOf(_classRef, r"setCodec", + static final _id_setCodec = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"setCodec", r"(Lcom/fasterxml/jackson/core/ObjectCodec;)Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public com.fasterxml.jackson.core.JsonFactory setCodec(com.fasterxml.jackson.core.ObjectCodec oc) @@ -989,25 +991,23 @@ class JsonFactory extends jni.JObject { JsonFactory setCodec( jni.JObject oc, ) { - return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_setCodec, - jni.JniCallType.objectType, - [oc.reference]).object); + return const $JsonFactoryType().fromRef(jni.Jni.accessors + .callMethodWithArgs(reference, _id_setCodec, jni.JniCallType.objectType, + [oc.reference]).object); } - static final _id_getCodec = jniAccessors.getMethodIDOf( - _classRef, r"getCodec", r"()Lcom/fasterxml/jackson/core/ObjectCodec;"); + static final _id_getCodec = jni.Jni.accessors.getMethodIDOf(_class.reference, + r"getCodec", r"()Lcom/fasterxml/jackson/core/ObjectCodec;"); /// from: public com.fasterxml.jackson.core.ObjectCodec getCodec() /// The returned object must be deleted after use, by calling the `delete` method. jni.JObject getCodec() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getCodec, jni.JniCallType.objectType, []).object); } - static final _id_createParser = jniAccessors.getMethodIDOf( - _classRef, + static final _id_createParser = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"createParser", r"(Ljava/io/File;)Lcom/fasterxml/jackson/core/JsonParser;"); @@ -1033,13 +1033,13 @@ class JsonFactory extends jni.JObject { jsonparser_.JsonParser createParser( jni.JObject f, ) { - return const jsonparser_.$JsonParserType().fromRef(jniAccessors + return const jsonparser_.$JsonParserType().fromRef(jni.Jni.accessors .callMethodWithArgs(reference, _id_createParser, jni.JniCallType.objectType, [f.reference]).object); } - static final _id_createParser1 = jniAccessors.getMethodIDOf( - _classRef, + static final _id_createParser1 = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"createParser", r"(Ljava/net/URL;)Lcom/fasterxml/jackson/core/JsonParser;"); @@ -1063,13 +1063,13 @@ class JsonFactory extends jni.JObject { jsonparser_.JsonParser createParser1( jni.JObject url, ) { - return const jsonparser_.$JsonParserType().fromRef(jniAccessors + return const jsonparser_.$JsonParserType().fromRef(jni.Jni.accessors .callMethodWithArgs(reference, _id_createParser1, jni.JniCallType.objectType, [url.reference]).object); } - static final _id_createParser2 = jniAccessors.getMethodIDOf( - _classRef, + static final _id_createParser2 = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"createParser", r"(Ljava/io/InputStream;)Lcom/fasterxml/jackson/core/JsonParser;"); @@ -1096,13 +1096,13 @@ class JsonFactory extends jni.JObject { jsonparser_.JsonParser createParser2( jni.JObject in0, ) { - return const jsonparser_.$JsonParserType().fromRef(jniAccessors + return const jsonparser_.$JsonParserType().fromRef(jni.Jni.accessors .callMethodWithArgs(reference, _id_createParser2, jni.JniCallType.objectType, [in0.reference]).object); } - static final _id_createParser3 = jniAccessors.getMethodIDOf( - _classRef, + static final _id_createParser3 = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"createParser", r"(Ljava/io/Reader;)Lcom/fasterxml/jackson/core/JsonParser;"); @@ -1122,13 +1122,15 @@ class JsonFactory extends jni.JObject { jsonparser_.JsonParser createParser3( jni.JObject r, ) { - return const jsonparser_.$JsonParserType().fromRef(jniAccessors + return const jsonparser_.$JsonParserType().fromRef(jni.Jni.accessors .callMethodWithArgs(reference, _id_createParser3, jni.JniCallType.objectType, [r.reference]).object); } - static final _id_createParser4 = jniAccessors.getMethodIDOf(_classRef, - r"createParser", r"([B)Lcom/fasterxml/jackson/core/JsonParser;"); + static final _id_createParser4 = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"createParser", + r"([B)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createParser(byte[] data) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1137,15 +1139,17 @@ class JsonFactory extends jni.JObject { /// the contents of given byte array. ///@since 2.1 jsonparser_.JsonParser createParser4( - jni.JArray data, + jni.JArray data, ) { - return const jsonparser_.$JsonParserType().fromRef(jniAccessors + return const jsonparser_.$JsonParserType().fromRef(jni.Jni.accessors .callMethodWithArgs(reference, _id_createParser4, jni.JniCallType.objectType, [data.reference]).object); } - static final _id_createParser5 = jniAccessors.getMethodIDOf(_classRef, - r"createParser", r"([BII)Lcom/fasterxml/jackson/core/JsonParser;"); + static final _id_createParser5 = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"createParser", + r"([BII)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createParser(byte[] data, int offset, int len) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1157,11 +1161,11 @@ class JsonFactory extends jni.JObject { ///@param len Length of contents to parse within buffer ///@since 2.1 jsonparser_.JsonParser createParser5( - jni.JArray data, + jni.JArray data, int offset, int len, ) { - return const jsonparser_.$JsonParserType().fromRef(jniAccessors + return const jsonparser_.$JsonParserType().fromRef(jni.Jni.accessors .callMethodWithArgs( reference, _id_createParser5, jni.JniCallType.objectType, [ data.reference, @@ -1170,8 +1174,8 @@ class JsonFactory extends jni.JObject { ]).object); } - static final _id_createParser6 = jniAccessors.getMethodIDOf( - _classRef, + static final _id_createParser6 = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"createParser", r"(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonParser;"); @@ -1184,13 +1188,15 @@ class JsonFactory extends jni.JObject { jsonparser_.JsonParser createParser6( jni.JString content, ) { - return const jsonparser_.$JsonParserType().fromRef(jniAccessors + return const jsonparser_.$JsonParserType().fromRef(jni.Jni.accessors .callMethodWithArgs(reference, _id_createParser6, jni.JniCallType.objectType, [content.reference]).object); } - static final _id_createParser7 = jniAccessors.getMethodIDOf(_classRef, - r"createParser", r"([C)Lcom/fasterxml/jackson/core/JsonParser;"); + static final _id_createParser7 = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"createParser", + r"([C)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createParser(char[] content) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1199,15 +1205,17 @@ class JsonFactory extends jni.JObject { /// contents of given char array. ///@since 2.4 jsonparser_.JsonParser createParser7( - jni.JArray content, + jni.JArray content, ) { - return const jsonparser_.$JsonParserType().fromRef(jniAccessors + return const jsonparser_.$JsonParserType().fromRef(jni.Jni.accessors .callMethodWithArgs(reference, _id_createParser7, jni.JniCallType.objectType, [content.reference]).object); } - static final _id_createParser8 = jniAccessors.getMethodIDOf(_classRef, - r"createParser", r"([CII)Lcom/fasterxml/jackson/core/JsonParser;"); + static final _id_createParser8 = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"createParser", + r"([CII)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createParser(char[] content, int offset, int len) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1215,11 +1223,11 @@ class JsonFactory extends jni.JObject { /// Method for constructing parser for parsing contents of given char array. ///@since 2.4 jsonparser_.JsonParser createParser8( - jni.JArray content, + jni.JArray content, int offset, int len, ) { - return const jsonparser_.$JsonParserType().fromRef(jniAccessors + return const jsonparser_.$JsonParserType().fromRef(jni.Jni.accessors .callMethodWithArgs( reference, _id_createParser8, jni.JniCallType.objectType, [ content.reference, @@ -1228,8 +1236,8 @@ class JsonFactory extends jni.JObject { ]).object); } - static final _id_createParser9 = jniAccessors.getMethodIDOf( - _classRef, + static final _id_createParser9 = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"createParser", r"(Ljava/io/DataInput;)Lcom/fasterxml/jackson/core/JsonParser;"); @@ -1245,13 +1253,13 @@ class JsonFactory extends jni.JObject { jsonparser_.JsonParser createParser9( jni.JObject in0, ) { - return const jsonparser_.$JsonParserType().fromRef(jniAccessors + return const jsonparser_.$JsonParserType().fromRef(jni.Jni.accessors .callMethodWithArgs(reference, _id_createParser9, jni.JniCallType.objectType, [in0.reference]).object); } - static final _id_createNonBlockingByteArrayParser = - jniAccessors.getMethodIDOf(_classRef, r"createNonBlockingByteArrayParser", + static final _id_createNonBlockingByteArrayParser = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"createNonBlockingByteArrayParser", r"()Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createNonBlockingByteArrayParser() @@ -1271,13 +1279,13 @@ class JsonFactory extends jni.JObject { /// at this point. ///@since 2.9 jsonparser_.JsonParser createNonBlockingByteArrayParser() { - return const jsonparser_.$JsonParserType().fromRef(jniAccessors + return const jsonparser_.$JsonParserType().fromRef(jni.Jni.accessors .callMethodWithArgs(reference, _id_createNonBlockingByteArrayParser, jni.JniCallType.objectType, []).object); } - static final _id_createGenerator = jniAccessors.getMethodIDOf( - _classRef, + static final _id_createGenerator = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"createGenerator", r"(Ljava/io/OutputStream;Lcom/fasterxml/jackson/core/JsonEncoding;)Lcom/fasterxml/jackson/core/JsonGenerator;"); @@ -1306,15 +1314,15 @@ class JsonFactory extends jni.JObject { jni.JObject out, jni.JObject enc, ) { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_createGenerator, jni.JniCallType.objectType, [out.reference, enc.reference]).object); } - static final _id_createGenerator1 = jniAccessors.getMethodIDOf( - _classRef, + static final _id_createGenerator1 = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"createGenerator", r"(Ljava/io/OutputStream;)Lcom/fasterxml/jackson/core/JsonGenerator;"); @@ -1329,15 +1337,15 @@ class JsonFactory extends jni.JObject { jni.JObject createGenerator1( jni.JObject out, ) { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_createGenerator1, jni.JniCallType.objectType, [out.reference]).object); } - static final _id_createGenerator2 = jniAccessors.getMethodIDOf( - _classRef, + static final _id_createGenerator2 = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"createGenerator", r"(Ljava/io/Writer;)Lcom/fasterxml/jackson/core/JsonGenerator;"); @@ -1358,15 +1366,15 @@ class JsonFactory extends jni.JObject { jni.JObject createGenerator2( jni.JObject w, ) { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_createGenerator2, jni.JniCallType.objectType, [w.reference]).object); } - static final _id_createGenerator3 = jniAccessors.getMethodIDOf( - _classRef, + static final _id_createGenerator3 = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"createGenerator", r"(Ljava/io/File;Lcom/fasterxml/jackson/core/JsonEncoding;)Lcom/fasterxml/jackson/core/JsonGenerator;"); @@ -1389,15 +1397,15 @@ class JsonFactory extends jni.JObject { jni.JObject f, jni.JObject enc, ) { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_createGenerator3, jni.JniCallType.objectType, [f.reference, enc.reference]).object); } - static final _id_createGenerator4 = jniAccessors.getMethodIDOf( - _classRef, + static final _id_createGenerator4 = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"createGenerator", r"(Ljava/io/DataOutput;Lcom/fasterxml/jackson/core/JsonEncoding;)Lcom/fasterxml/jackson/core/JsonGenerator;"); @@ -1411,15 +1419,15 @@ class JsonFactory extends jni.JObject { jni.JObject out, jni.JObject enc, ) { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_createGenerator4, jni.JniCallType.objectType, [out.reference, enc.reference]).object); } - static final _id_createGenerator5 = jniAccessors.getMethodIDOf( - _classRef, + static final _id_createGenerator5 = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"createGenerator", r"(Ljava/io/DataOutput;)Lcom/fasterxml/jackson/core/JsonGenerator;"); @@ -1434,15 +1442,15 @@ class JsonFactory extends jni.JObject { jni.JObject createGenerator5( jni.JObject out, ) { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_createGenerator5, jni.JniCallType.objectType, [out.reference]).object); } - static final _id_createJsonParser = jniAccessors.getMethodIDOf( - _classRef, + static final _id_createJsonParser = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"createJsonParser", r"(Ljava/io/File;)Lcom/fasterxml/jackson/core/JsonParser;"); @@ -1470,13 +1478,13 @@ class JsonFactory extends jni.JObject { jsonparser_.JsonParser createJsonParser( jni.JObject f, ) { - return const jsonparser_.$JsonParserType().fromRef(jniAccessors + return const jsonparser_.$JsonParserType().fromRef(jni.Jni.accessors .callMethodWithArgs(reference, _id_createJsonParser, jni.JniCallType.objectType, [f.reference]).object); } - static final _id_createJsonParser1 = jniAccessors.getMethodIDOf( - _classRef, + static final _id_createJsonParser1 = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"createJsonParser", r"(Ljava/net/URL;)Lcom/fasterxml/jackson/core/JsonParser;"); @@ -1503,13 +1511,13 @@ class JsonFactory extends jni.JObject { jsonparser_.JsonParser createJsonParser1( jni.JObject url, ) { - return const jsonparser_.$JsonParserType().fromRef(jniAccessors + return const jsonparser_.$JsonParserType().fromRef(jni.Jni.accessors .callMethodWithArgs(reference, _id_createJsonParser1, jni.JniCallType.objectType, [url.reference]).object); } - static final _id_createJsonParser2 = jniAccessors.getMethodIDOf( - _classRef, + static final _id_createJsonParser2 = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"createJsonParser", r"(Ljava/io/InputStream;)Lcom/fasterxml/jackson/core/JsonParser;"); @@ -1539,13 +1547,13 @@ class JsonFactory extends jni.JObject { jsonparser_.JsonParser createJsonParser2( jni.JObject in0, ) { - return const jsonparser_.$JsonParserType().fromRef(jniAccessors + return const jsonparser_.$JsonParserType().fromRef(jni.Jni.accessors .callMethodWithArgs(reference, _id_createJsonParser2, jni.JniCallType.objectType, [in0.reference]).object); } - static final _id_createJsonParser3 = jniAccessors.getMethodIDOf( - _classRef, + static final _id_createJsonParser3 = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"createJsonParser", r"(Ljava/io/Reader;)Lcom/fasterxml/jackson/core/JsonParser;"); @@ -1568,13 +1576,15 @@ class JsonFactory extends jni.JObject { jsonparser_.JsonParser createJsonParser3( jni.JObject r, ) { - return const jsonparser_.$JsonParserType().fromRef(jniAccessors + return const jsonparser_.$JsonParserType().fromRef(jni.Jni.accessors .callMethodWithArgs(reference, _id_createJsonParser3, jni.JniCallType.objectType, [r.reference]).object); } - static final _id_createJsonParser4 = jniAccessors.getMethodIDOf(_classRef, - r"createJsonParser", r"([B)Lcom/fasterxml/jackson/core/JsonParser;"); + static final _id_createJsonParser4 = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"createJsonParser", + r"([B)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(byte[] data) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1586,15 +1596,17 @@ class JsonFactory extends jni.JObject { ///@throws JsonParseException if parser initialization fails due to content decoding problem ///@deprecated Since 2.2, use \#createParser(byte[]) instead. jsonparser_.JsonParser createJsonParser4( - jni.JArray data, + jni.JArray data, ) { - return const jsonparser_.$JsonParserType().fromRef(jniAccessors + return const jsonparser_.$JsonParserType().fromRef(jni.Jni.accessors .callMethodWithArgs(reference, _id_createJsonParser4, jni.JniCallType.objectType, [data.reference]).object); } - static final _id_createJsonParser5 = jniAccessors.getMethodIDOf(_classRef, - r"createJsonParser", r"([BII)Lcom/fasterxml/jackson/core/JsonParser;"); + static final _id_createJsonParser5 = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"createJsonParser", + r"([BII)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(byte[] data, int offset, int len) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1609,11 +1621,11 @@ class JsonFactory extends jni.JObject { ///@throws JsonParseException if parser initialization fails due to content decoding problem ///@deprecated Since 2.2, use \#createParser(byte[],int,int) instead. jsonparser_.JsonParser createJsonParser5( - jni.JArray data, + jni.JArray data, int offset, int len, ) { - return const jsonparser_.$JsonParserType().fromRef(jniAccessors + return const jsonparser_.$JsonParserType().fromRef(jni.Jni.accessors .callMethodWithArgs( reference, _id_createJsonParser5, jni.JniCallType.objectType, [ data.reference, @@ -1622,8 +1634,8 @@ class JsonFactory extends jni.JObject { ]).object); } - static final _id_createJsonParser6 = jniAccessors.getMethodIDOf( - _classRef, + static final _id_createJsonParser6 = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"createJsonParser", r"(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonParser;"); @@ -1640,13 +1652,13 @@ class JsonFactory extends jni.JObject { jsonparser_.JsonParser createJsonParser6( jni.JString content, ) { - return const jsonparser_.$JsonParserType().fromRef(jniAccessors + return const jsonparser_.$JsonParserType().fromRef(jni.Jni.accessors .callMethodWithArgs(reference, _id_createJsonParser6, jni.JniCallType.objectType, [content.reference]).object); } - static final _id_createJsonGenerator = jniAccessors.getMethodIDOf( - _classRef, + static final _id_createJsonGenerator = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"createJsonGenerator", r"(Ljava/io/OutputStream;Lcom/fasterxml/jackson/core/JsonEncoding;)Lcom/fasterxml/jackson/core/JsonGenerator;"); @@ -1677,15 +1689,15 @@ class JsonFactory extends jni.JObject { jni.JObject out, jni.JObject enc, ) { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_createJsonGenerator, jni.JniCallType.objectType, [out.reference, enc.reference]).object); } - static final _id_createJsonGenerator1 = jniAccessors.getMethodIDOf( - _classRef, + static final _id_createJsonGenerator1 = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"createJsonGenerator", r"(Ljava/io/Writer;)Lcom/fasterxml/jackson/core/JsonGenerator;"); @@ -1708,15 +1720,15 @@ class JsonFactory extends jni.JObject { jni.JObject createJsonGenerator1( jni.JObject out, ) { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_createJsonGenerator1, jni.JniCallType.objectType, [out.reference]).object); } - static final _id_createJsonGenerator2 = jniAccessors.getMethodIDOf( - _classRef, + static final _id_createJsonGenerator2 = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"createJsonGenerator", r"(Ljava/io/OutputStream;)Lcom/fasterxml/jackson/core/JsonGenerator;"); @@ -1734,7 +1746,7 @@ class JsonFactory extends jni.JObject { jni.JObject createJsonGenerator2( jni.JObject out, ) { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_createJsonGenerator2, jni.JniCallType.objectType, @@ -1762,7 +1774,7 @@ class $JsonFactoryType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $JsonFactoryType && other is $JsonFactoryType; + return other.runtimeType == ($JsonFactoryType) && other is $JsonFactoryType; } } @@ -1772,30 +1784,32 @@ class $JsonFactoryType extends jni.JObjType { /// changed for JsonFactory. class JsonFactory_Feature extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; JsonFactory_Feature.fromRef( jni.JObjectPtr ref, ) : super.fromRef(ref); - static final _classRef = jniAccessors - .getClassOf(r"com/fasterxml/jackson/core/JsonFactory$Feature"); + static final _class = + jni.Jni.findJClass(r"com/fasterxml/jackson/core/JsonFactory$Feature"); /// The type which includes information such as the signature of this class. static const type = $JsonFactory_FeatureType(); - static final _id_values = jniAccessors.getStaticMethodIDOf(_classRef, - r"values", r"()[Lcom/fasterxml/jackson/core/JsonFactory$Feature;"); + static final _id_values = jni.Jni.accessors.getStaticMethodIDOf( + _class.reference, + r"values", + r"()[Lcom/fasterxml/jackson/core/JsonFactory$Feature;"); /// from: static public com.fasterxml.jackson.core.JsonFactory.Feature[] values() /// The returned object must be deleted after use, by calling the `delete` method. static jni.JArray values() { - return const jni.JArrayType($JsonFactory_FeatureType()).fromRef(jniAccessors - .callStaticMethodWithArgs( - _classRef, _id_values, jni.JniCallType.objectType, []).object); + return const jni.JArrayType($JsonFactory_FeatureType()).fromRef( + jni.Jni.accessors.callStaticMethodWithArgs(_class.reference, _id_values, + jni.JniCallType.objectType, []).object); } - static final _id_valueOf = jniAccessors.getStaticMethodIDOf( - _classRef, + static final _id_valueOf = jni.Jni.accessors.getStaticMethodIDOf( + _class.reference, r"valueOf", r"(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonFactory$Feature;"); @@ -1804,13 +1818,13 @@ class JsonFactory_Feature extends jni.JObject { static JsonFactory_Feature valueOf( jni.JString name, ) { - return const $JsonFactory_FeatureType().fromRef(jniAccessors - .callStaticMethodWithArgs(_classRef, _id_valueOf, + return const $JsonFactory_FeatureType().fromRef(jni.Jni.accessors + .callStaticMethodWithArgs(_class.reference, _id_valueOf, jni.JniCallType.objectType, [name.reference]).object); } - static final _id_collectDefaults = - jniAccessors.getStaticMethodIDOf(_classRef, r"collectDefaults", r"()I"); + static final _id_collectDefaults = jni.Jni.accessors + .getStaticMethodIDOf(_class.reference, r"collectDefaults", r"()I"); /// from: static public int collectDefaults() /// @@ -1818,36 +1832,36 @@ class JsonFactory_Feature extends jni.JObject { /// are enabled by default. ///@return Bit field of features enabled by default static int collectDefaults() { - return jniAccessors.callStaticMethodWithArgs( - _classRef, _id_collectDefaults, jni.JniCallType.intType, []).integer; + return jni.Jni.accessors.callStaticMethodWithArgs(_class.reference, + _id_collectDefaults, jni.JniCallType.intType, []).integer; } - static final _id_enabledByDefault = - jniAccessors.getMethodIDOf(_classRef, r"enabledByDefault", r"()Z"); + static final _id_enabledByDefault = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"enabledByDefault", r"()Z"); /// from: public boolean enabledByDefault() bool enabledByDefault() { - return jniAccessors.callMethodWithArgs(reference, _id_enabledByDefault, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_enabledByDefault, jni.JniCallType.booleanType, []).boolean; } static final _id_enabledIn = - jniAccessors.getMethodIDOf(_classRef, r"enabledIn", r"(I)Z"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"enabledIn", r"(I)Z"); /// from: public boolean enabledIn(int flags) bool enabledIn( int flags, ) { - return jniAccessors.callMethodWithArgs(reference, _id_enabledIn, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_enabledIn, jni.JniCallType.booleanType, [jni.JValueInt(flags)]).boolean; } static final _id_getMask = - jniAccessors.getMethodIDOf(_classRef, r"getMask", r"()I"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"getMask", r"()I"); /// from: public int getMask() int getMask() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_getMask, jni.JniCallType.intType, []).integer; } } @@ -1873,7 +1887,7 @@ class $JsonFactory_FeatureType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $JsonFactory_FeatureType && + return other.runtimeType == ($JsonFactory_FeatureType) && other is $JsonFactory_FeatureType; } } diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart index e8caa42e3..89a9affd2 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart @@ -37,7 +37,6 @@ import "package:jni/internal_helpers_for_jnigen.dart"; import "package:jni/jni.dart" as jni; import "JsonToken.dart" as jsontoken_; -import "../../../../_init.dart"; /// from: com.fasterxml.jackson.core.JsonParser /// @@ -47,19 +46,20 @@ import "../../../../_init.dart"; ///@author Tatu Saloranta class JsonParser extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; JsonParser.fromRef( jni.JObjectPtr ref, ) : super.fromRef(ref); - static final _classRef = - jniAccessors.getClassOf(r"com/fasterxml/jackson/core/JsonParser"); + static final _class = + jni.Jni.findJClass(r"com/fasterxml/jackson/core/JsonParser"); /// The type which includes information such as the signature of this class. static const type = $JsonParserType(); - static final _id_DEFAULT_READ_CAPABILITIES = jniAccessors.getStaticFieldIDOf( - _classRef, + static final _id_DEFAULT_READ_CAPABILITIES = + jni.Jni.accessors.getStaticFieldIDOf( + _class.reference, r"DEFAULT_READ_CAPABILITIES", r"Lcom/fasterxml/jackson/core/util/JacksonFeatureSet;", ); @@ -72,35 +72,35 @@ class JsonParser extends jni.JObject { /// set needs to be passed). ///@since 2.12 static jni.JObject get DEFAULT_READ_CAPABILITIES => - const jni.JObjectType().fromRef(jniAccessors - .getStaticField(_classRef, _id_DEFAULT_READ_CAPABILITIES, + const jni.JObjectType().fromRef(jni.Jni.accessors + .getStaticField(_class.reference, _id_DEFAULT_READ_CAPABILITIES, jni.JniCallType.objectType) .object); static final _id_ctor = - jniAccessors.getMethodIDOf(_classRef, r"", r"()V"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: protected void () /// The returned object must be deleted after use, by calling the `delete` method. factory JsonParser() { - return JsonParser.fromRef( - jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); + return JsonParser.fromRef(jni.Jni.accessors + .newObjectWithArgs(_class.reference, _id_ctor, []).object); } static final _id_ctor1 = - jniAccessors.getMethodIDOf(_classRef, r"", r"(I)V"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"(I)V"); /// from: protected void (int features) /// The returned object must be deleted after use, by calling the `delete` method. factory JsonParser.ctor1( int features, ) { - return JsonParser.fromRef(jniAccessors.newObjectWithArgs( - _classRef, _id_ctor1, [jni.JValueInt(features)]).object); + return JsonParser.fromRef(jni.Jni.accessors.newObjectWithArgs( + _class.reference, _id_ctor1, [jni.JValueInt(features)]).object); } - static final _id_getCodec = jniAccessors.getMethodIDOf( - _classRef, r"getCodec", r"()Lcom/fasterxml/jackson/core/ObjectCodec;"); + static final _id_getCodec = jni.Jni.accessors.getMethodIDOf(_class.reference, + r"getCodec", r"()Lcom/fasterxml/jackson/core/ObjectCodec;"); /// from: public abstract com.fasterxml.jackson.core.ObjectCodec getCodec() /// The returned object must be deleted after use, by calling the `delete` method. @@ -110,12 +110,12 @@ 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 const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getCodec, jni.JniCallType.objectType, []).object); } - static final _id_setCodec = jniAccessors.getMethodIDOf( - _classRef, r"setCodec", r"(Lcom/fasterxml/jackson/core/ObjectCodec;)V"); + static final _id_setCodec = jni.Jni.accessors.getMethodIDOf(_class.reference, + r"setCodec", r"(Lcom/fasterxml/jackson/core/ObjectCodec;)V"); /// from: public abstract void setCodec(com.fasterxml.jackson.core.ObjectCodec oc) /// @@ -126,12 +126,12 @@ class JsonParser extends jni.JObject { void setCodec( jni.JObject oc, ) { - return jniAccessors.callMethodWithArgs(reference, _id_setCodec, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_setCodec, jni.JniCallType.voidType, [oc.reference]).check(); } - static final _id_getInputSource = jniAccessors.getMethodIDOf( - _classRef, r"getInputSource", r"()Ljava/lang/Object;"); + static final _id_getInputSource = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"getInputSource", r"()Ljava/lang/Object;"); /// from: public java.lang.Object getInputSource() /// The returned object must be deleted after use, by calling the `delete` method. @@ -151,12 +151,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 const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getInputSource, jni.JniCallType.objectType, []).object); } - static final _id_setRequestPayloadOnError = jniAccessors.getMethodIDOf( - _classRef, + static final _id_setRequestPayloadOnError = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"setRequestPayloadOnError", r"(Lcom/fasterxml/jackson/core/util/RequestPayload;)V"); @@ -168,15 +168,17 @@ class JsonParser extends jni.JObject { void setRequestPayloadOnError( jni.JObject payload, ) { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_setRequestPayloadOnError, jni.JniCallType.voidType, [payload.reference]).check(); } - static final _id_setRequestPayloadOnError1 = jniAccessors.getMethodIDOf( - _classRef, r"setRequestPayloadOnError", r"([BLjava/lang/String;)V"); + static final _id_setRequestPayloadOnError1 = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"setRequestPayloadOnError", + r"([BLjava/lang/String;)V"); /// from: public void setRequestPayloadOnError(byte[] payload, java.lang.String charset) /// @@ -185,18 +187,18 @@ class JsonParser extends jni.JObject { ///@param charset Character encoding for (lazily) decoding payload ///@since 2.8 void setRequestPayloadOnError1( - jni.JArray payload, + jni.JArray payload, jni.JString charset, ) { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_setRequestPayloadOnError1, jni.JniCallType.voidType, [payload.reference, charset.reference]).check(); } - static final _id_setRequestPayloadOnError2 = jniAccessors.getMethodIDOf( - _classRef, r"setRequestPayloadOnError", r"(Ljava/lang/String;)V"); + static final _id_setRequestPayloadOnError2 = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"setRequestPayloadOnError", r"(Ljava/lang/String;)V"); /// from: public void setRequestPayloadOnError(java.lang.String payload) /// @@ -206,15 +208,15 @@ class JsonParser extends jni.JObject { void setRequestPayloadOnError2( jni.JString payload, ) { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_setRequestPayloadOnError2, jni.JniCallType.voidType, [payload.reference]).check(); } - static final _id_setSchema = jniAccessors.getMethodIDOf( - _classRef, r"setSchema", r"(Lcom/fasterxml/jackson/core/FormatSchema;)V"); + static final _id_setSchema = jni.Jni.accessors.getMethodIDOf(_class.reference, + r"setSchema", r"(Lcom/fasterxml/jackson/core/FormatSchema;)V"); /// from: public void setSchema(com.fasterxml.jackson.core.FormatSchema schema) /// @@ -231,12 +233,12 @@ class JsonParser extends jni.JObject { void setSchema( jni.JObject schema, ) { - return jniAccessors.callMethodWithArgs(reference, _id_setSchema, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_setSchema, jni.JniCallType.voidType, [schema.reference]).check(); } - static final _id_getSchema = jniAccessors.getMethodIDOf( - _classRef, r"getSchema", r"()Lcom/fasterxml/jackson/core/FormatSchema;"); + static final _id_getSchema = jni.Jni.accessors.getMethodIDOf(_class.reference, + r"getSchema", r"()Lcom/fasterxml/jackson/core/FormatSchema;"); /// from: public com.fasterxml.jackson.core.FormatSchema getSchema() /// The returned object must be deleted after use, by calling the `delete` method. @@ -246,12 +248,14 @@ 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 const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getSchema, jni.JniCallType.objectType, []).object); } - static final _id_canUseSchema = jniAccessors.getMethodIDOf(_classRef, - r"canUseSchema", r"(Lcom/fasterxml/jackson/core/FormatSchema;)Z"); + static final _id_canUseSchema = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"canUseSchema", + r"(Lcom/fasterxml/jackson/core/FormatSchema;)Z"); /// from: public boolean canUseSchema(com.fasterxml.jackson.core.FormatSchema schema) /// @@ -262,12 +266,12 @@ class JsonParser extends jni.JObject { bool canUseSchema( jni.JObject schema, ) { - return jniAccessors.callMethodWithArgs(reference, _id_canUseSchema, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_canUseSchema, jni.JniCallType.booleanType, [schema.reference]).boolean; } - static final _id_requiresCustomCodec = - jniAccessors.getMethodIDOf(_classRef, r"requiresCustomCodec", r"()Z"); + static final _id_requiresCustomCodec = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"requiresCustomCodec", r"()Z"); /// from: public boolean requiresCustomCodec() /// @@ -280,12 +284,12 @@ class JsonParser extends jni.JObject { /// ObjectCodec is enough ///@since 2.1 bool requiresCustomCodec() { - return jniAccessors.callMethodWithArgs(reference, _id_requiresCustomCodec, - jni.JniCallType.booleanType, []).boolean; + return jni.Jni.accessors.callMethodWithArgs(reference, + _id_requiresCustomCodec, jni.JniCallType.booleanType, []).boolean; } - static final _id_canParseAsync = - jniAccessors.getMethodIDOf(_classRef, r"canParseAsync", r"()Z"); + static final _id_canParseAsync = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"canParseAsync", r"()Z"); /// from: public boolean canParseAsync() /// @@ -301,12 +305,12 @@ class JsonParser extends jni.JObject { ///@return True if this is a non-blocking ("asynchronous") parser ///@since 2.9 bool canParseAsync() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_canParseAsync, jni.JniCallType.booleanType, []).boolean; } - static final _id_getNonBlockingInputFeeder = jniAccessors.getMethodIDOf( - _classRef, + static final _id_getNonBlockingInputFeeder = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"getNonBlockingInputFeeder", r"()Lcom/fasterxml/jackson/core/async/NonBlockingInputFeeder;"); @@ -319,14 +323,14 @@ class JsonParser extends jni.JObject { ///@return Input feeder to use with non-blocking (async) parsing ///@since 2.9 jni.JObject getNonBlockingInputFeeder() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getNonBlockingInputFeeder, jni.JniCallType.objectType, []).object); } - static final _id_getReadCapabilities = jniAccessors.getMethodIDOf( - _classRef, + static final _id_getReadCapabilities = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"getReadCapabilities", r"()Lcom/fasterxml/jackson/core/util/JacksonFeatureSet;"); @@ -338,14 +342,14 @@ class JsonParser extends jni.JObject { ///@return Set of read capabilities for content to read via this parser ///@since 2.12 jni.JObject getReadCapabilities() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getReadCapabilities, jni.JniCallType.objectType, []).object); } - static final _id_version = jniAccessors.getMethodIDOf( - _classRef, r"version", r"()Lcom/fasterxml/jackson/core/Version;"); + static final _id_version = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"version", r"()Lcom/fasterxml/jackson/core/Version;"); /// from: public abstract com.fasterxml.jackson.core.Version version() /// The returned object must be deleted after use, by calling the `delete` method. @@ -355,12 +359,12 @@ 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 const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_version, jni.JniCallType.objectType, []).object); } static final _id_close = - jniAccessors.getMethodIDOf(_classRef, r"close", r"()V"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"close", r"()V"); /// from: public abstract void close() /// @@ -379,12 +383,12 @@ 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() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_close, jni.JniCallType.voidType, []).check(); } static final _id_isClosed = - jniAccessors.getMethodIDOf(_classRef, r"isClosed", r"()Z"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"isClosed", r"()Z"); /// from: public abstract boolean isClosed() /// @@ -396,12 +400,12 @@ class JsonParser extends jni.JObject { /// end of input. ///@return {@code True} if this parser instance has been closed bool isClosed() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_isClosed, jni.JniCallType.booleanType, []).boolean; } - static final _id_getParsingContext = jniAccessors.getMethodIDOf( - _classRef, + static final _id_getParsingContext = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"getParsingContext", r"()Lcom/fasterxml/jackson/core/JsonStreamContext;"); @@ -418,14 +422,16 @@ class JsonParser extends jni.JObject { /// input, if so desired. ///@return Stream input context (JsonStreamContext) associated with this parser jni.JObject getParsingContext() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getParsingContext, jni.JniCallType.objectType, []).object); } - static final _id_currentLocation = jniAccessors.getMethodIDOf(_classRef, - r"currentLocation", r"()Lcom/fasterxml/jackson/core/JsonLocation;"); + static final _id_currentLocation = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"currentLocation", + r"()Lcom/fasterxml/jackson/core/JsonLocation;"); /// from: public com.fasterxml.jackson.core.JsonLocation currentLocation() /// The returned object must be deleted after use, by calling the `delete` method. @@ -443,12 +449,14 @@ class JsonParser extends jni.JObject { ///@return Location of the last processed input unit (byte or character) ///@since 2.13 jni.JObject currentLocation() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_currentLocation, jni.JniCallType.objectType, []).object); } - static final _id_currentTokenLocation = jniAccessors.getMethodIDOf(_classRef, - r"currentTokenLocation", r"()Lcom/fasterxml/jackson/core/JsonLocation;"); + static final _id_currentTokenLocation = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"currentTokenLocation", + r"()Lcom/fasterxml/jackson/core/JsonLocation;"); /// from: public com.fasterxml.jackson.core.JsonLocation currentTokenLocation() /// The returned object must be deleted after use, by calling the `delete` method. @@ -466,14 +474,16 @@ class JsonParser extends jni.JObject { ///@return Starting location of the token parser currently points to ///@since 2.13 (will eventually replace \#getTokenLocation) jni.JObject currentTokenLocation() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_currentTokenLocation, jni.JniCallType.objectType, []).object); } - static final _id_getCurrentLocation = jniAccessors.getMethodIDOf(_classRef, - r"getCurrentLocation", r"()Lcom/fasterxml/jackson/core/JsonLocation;"); + static final _id_getCurrentLocation = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"getCurrentLocation", + r"()Lcom/fasterxml/jackson/core/JsonLocation;"); /// from: public abstract com.fasterxml.jackson.core.JsonLocation getCurrentLocation() /// The returned object must be deleted after use, by calling the `delete` method. @@ -482,14 +492,16 @@ 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 getCurrentLocation() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getCurrentLocation, jni.JniCallType.objectType, []).object); } - static final _id_getTokenLocation = jniAccessors.getMethodIDOf(_classRef, - r"getTokenLocation", r"()Lcom/fasterxml/jackson/core/JsonLocation;"); + static final _id_getTokenLocation = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"getTokenLocation", + r"()Lcom/fasterxml/jackson/core/JsonLocation;"); /// from: public abstract com.fasterxml.jackson.core.JsonLocation getTokenLocation() /// The returned object must be deleted after use, by calling the `delete` method. @@ -498,14 +510,14 @@ 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 const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getTokenLocation, jni.JniCallType.objectType, []).object); } - static final _id_currentValue = jniAccessors.getMethodIDOf( - _classRef, r"currentValue", r"()Ljava/lang/Object;"); + static final _id_currentValue = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"currentValue", r"()Ljava/lang/Object;"); /// from: public java.lang.Object currentValue() /// The returned object must be deleted after use, by calling the `delete` method. @@ -522,12 +534,12 @@ 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 const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_currentValue, jni.JniCallType.objectType, []).object); } - static final _id_assignCurrentValue = jniAccessors.getMethodIDOf( - _classRef, r"assignCurrentValue", r"(Ljava/lang/Object;)V"); + static final _id_assignCurrentValue = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"assignCurrentValue", r"(Ljava/lang/Object;)V"); /// from: public void assignCurrentValue(java.lang.Object v) /// @@ -540,12 +552,15 @@ class JsonParser extends jni.JObject { void assignCurrentValue( jni.JObject v, ) { - return jniAccessors.callMethodWithArgs(reference, _id_assignCurrentValue, - jni.JniCallType.voidType, [v.reference]).check(); + return jni.Jni.accessors.callMethodWithArgs( + reference, + _id_assignCurrentValue, + jni.JniCallType.voidType, + [v.reference]).check(); } - static final _id_getCurrentValue = jniAccessors.getMethodIDOf( - _classRef, r"getCurrentValue", r"()Ljava/lang/Object;"); + static final _id_getCurrentValue = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"getCurrentValue", r"()Ljava/lang/Object;"); /// from: public java.lang.Object getCurrentValue() /// The returned object must be deleted after use, by calling the `delete` method. @@ -554,12 +569,12 @@ 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 const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getCurrentValue, jni.JniCallType.objectType, []).object); } - static final _id_setCurrentValue = jniAccessors.getMethodIDOf( - _classRef, r"setCurrentValue", r"(Ljava/lang/Object;)V"); + static final _id_setCurrentValue = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"setCurrentValue", r"(Ljava/lang/Object;)V"); /// from: public void setCurrentValue(java.lang.Object v) /// @@ -569,12 +584,12 @@ class JsonParser extends jni.JObject { void setCurrentValue( jni.JObject v, ) { - return jniAccessors.callMethodWithArgs(reference, _id_setCurrentValue, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_setCurrentValue, jni.JniCallType.voidType, [v.reference]).check(); } - static final _id_releaseBuffered = jniAccessors.getMethodIDOf( - _classRef, r"releaseBuffered", r"(Ljava/io/OutputStream;)I"); + static final _id_releaseBuffered = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"releaseBuffered", r"(Ljava/io/OutputStream;)I"); /// from: public int releaseBuffered(java.io.OutputStream out) /// @@ -592,12 +607,12 @@ class JsonParser extends jni.JObject { int releaseBuffered( jni.JObject out, ) { - return jniAccessors.callMethodWithArgs(reference, _id_releaseBuffered, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_releaseBuffered, jni.JniCallType.intType, [out.reference]).integer; } - static final _id_releaseBuffered1 = jniAccessors.getMethodIDOf( - _classRef, r"releaseBuffered", r"(Ljava/io/Writer;)I"); + static final _id_releaseBuffered1 = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"releaseBuffered", r"(Ljava/io/Writer;)I"); /// from: public int releaseBuffered(java.io.Writer w) /// @@ -616,11 +631,13 @@ class JsonParser extends jni.JObject { int releaseBuffered1( jni.JObject w, ) { - return jniAccessors.callMethodWithArgs(reference, _id_releaseBuffered1, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_releaseBuffered1, jni.JniCallType.intType, [w.reference]).integer; } - static final _id_enable = jniAccessors.getMethodIDOf(_classRef, r"enable", + static final _id_enable = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"enable", r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser enable(com.fasterxml.jackson.core.JsonParser.Feature f) @@ -633,14 +650,16 @@ class JsonParser extends jni.JObject { JsonParser enable( JsonParser_Feature f, ) { - return const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs( + return const $JsonParserType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_enable, jni.JniCallType.objectType, [f.reference]).object); } - static final _id_disable = jniAccessors.getMethodIDOf(_classRef, r"disable", + static final _id_disable = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"disable", r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser disable(com.fasterxml.jackson.core.JsonParser.Feature f) @@ -653,15 +672,15 @@ class JsonParser extends jni.JObject { JsonParser disable( JsonParser_Feature f, ) { - return const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs( + return const $JsonParserType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_disable, jni.JniCallType.objectType, [f.reference]).object); } - static final _id_configure = jniAccessors.getMethodIDOf( - _classRef, + static final _id_configure = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"configure", r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;Z)Lcom/fasterxml/jackson/core/JsonParser;"); @@ -677,14 +696,14 @@ class JsonParser extends jni.JObject { JsonParser_Feature f, bool state, ) { - return const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs( + return const $JsonParserType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_configure, jni.JniCallType.objectType, [f.reference, state ? 1 : 0]).object); } - static final _id_isEnabled = jniAccessors.getMethodIDOf(_classRef, + static final _id_isEnabled = jni.Jni.accessors.getMethodIDOf(_class.reference, r"isEnabled", r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Z"); /// from: public boolean isEnabled(com.fasterxml.jackson.core.JsonParser.Feature f) @@ -695,12 +714,14 @@ class JsonParser extends jni.JObject { bool isEnabled( JsonParser_Feature f, ) { - return jniAccessors.callMethodWithArgs(reference, _id_isEnabled, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_isEnabled, jni.JniCallType.booleanType, [f.reference]).boolean; } - static final _id_isEnabled1 = jniAccessors.getMethodIDOf(_classRef, - r"isEnabled", r"(Lcom/fasterxml/jackson/core/StreamReadFeature;)Z"); + static final _id_isEnabled1 = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"isEnabled", + r"(Lcom/fasterxml/jackson/core/StreamReadFeature;)Z"); /// from: public boolean isEnabled(com.fasterxml.jackson.core.StreamReadFeature f) /// @@ -711,12 +732,12 @@ class JsonParser extends jni.JObject { bool isEnabled1( jni.JObject f, ) { - return jniAccessors.callMethodWithArgs(reference, _id_isEnabled1, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_isEnabled1, jni.JniCallType.booleanType, [f.reference]).boolean; } - static final _id_getFeatureMask = - jniAccessors.getMethodIDOf(_classRef, r"getFeatureMask", r"()I"); + static final _id_getFeatureMask = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"getFeatureMask", r"()I"); /// from: public int getFeatureMask() /// @@ -724,12 +745,14 @@ class JsonParser extends jni.JObject { ///@return Bit mask that defines current states of all standard Features. ///@since 2.3 int getFeatureMask() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_getFeatureMask, jni.JniCallType.intType, []).integer; } - static final _id_setFeatureMask = jniAccessors.getMethodIDOf(_classRef, - r"setFeatureMask", r"(I)Lcom/fasterxml/jackson/core/JsonParser;"); + static final _id_setFeatureMask = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"setFeatureMask", + r"(I)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser setFeatureMask(int mask) /// The returned object must be deleted after use, by calling the `delete` method. @@ -742,15 +765,17 @@ class JsonParser extends jni.JObject { JsonParser setFeatureMask( int mask, ) { - return const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs( + return const $JsonParserType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_setFeatureMask, jni.JniCallType.objectType, [jni.JValueInt(mask)]).object); } - static final _id_overrideStdFeatures = jniAccessors.getMethodIDOf(_classRef, - r"overrideStdFeatures", r"(II)Lcom/fasterxml/jackson/core/JsonParser;"); + static final _id_overrideStdFeatures = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"overrideStdFeatures", + r"(II)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser overrideStdFeatures(int values, int mask) /// The returned object must be deleted after use, by calling the `delete` method. @@ -771,15 +796,15 @@ class JsonParser extends jni.JObject { int values, int mask, ) { - return const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs( + return const $JsonParserType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_overrideStdFeatures, jni.JniCallType.objectType, [jni.JValueInt(values), jni.JValueInt(mask)]).object); } - static final _id_getFormatFeatures = - jniAccessors.getMethodIDOf(_classRef, r"getFormatFeatures", r"()I"); + static final _id_getFormatFeatures = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"getFormatFeatures", r"()I"); /// from: public int getFormatFeatures() /// @@ -788,12 +813,12 @@ class JsonParser extends jni.JObject { ///@return Bit mask that defines current states of all standard FormatFeatures. ///@since 2.6 int getFormatFeatures() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_getFormatFeatures, jni.JniCallType.intType, []).integer; } - static final _id_overrideFormatFeatures = jniAccessors.getMethodIDOf( - _classRef, + static final _id_overrideFormatFeatures = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"overrideFormatFeatures", r"(II)Lcom/fasterxml/jackson/core/JsonParser;"); @@ -814,15 +839,15 @@ class JsonParser extends jni.JObject { int values, int mask, ) { - return const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs( + return const $JsonParserType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_overrideFormatFeatures, jni.JniCallType.objectType, [jni.JValueInt(values), jni.JValueInt(mask)]).object); } - static final _id_nextToken = jniAccessors.getMethodIDOf( - _classRef, r"nextToken", r"()Lcom/fasterxml/jackson/core/JsonToken;"); + static final _id_nextToken = jni.Jni.accessors.getMethodIDOf(_class.reference, + r"nextToken", r"()Lcom/fasterxml/jackson/core/JsonToken;"); /// from: public abstract com.fasterxml.jackson.core.JsonToken nextToken() /// The returned object must be deleted after use, by calling the `delete` method. @@ -836,13 +861,13 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems jsontoken_.JsonToken nextToken() { - return const jsontoken_.$JsonTokenType().fromRef(jniAccessors + return const jsontoken_.$JsonTokenType().fromRef(jni.Jni.accessors .callMethodWithArgs( reference, _id_nextToken, jni.JniCallType.objectType, []).object); } - static final _id_nextValue = jniAccessors.getMethodIDOf( - _classRef, r"nextValue", r"()Lcom/fasterxml/jackson/core/JsonToken;"); + static final _id_nextValue = jni.Jni.accessors.getMethodIDOf(_class.reference, + r"nextValue", r"()Lcom/fasterxml/jackson/core/JsonToken;"); /// from: public abstract com.fasterxml.jackson.core.JsonToken nextValue() /// The returned object must be deleted after use, by calling the `delete` method. @@ -864,13 +889,15 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems jsontoken_.JsonToken nextValue() { - return const jsontoken_.$JsonTokenType().fromRef(jniAccessors + return const jsontoken_.$JsonTokenType().fromRef(jni.Jni.accessors .callMethodWithArgs( reference, _id_nextValue, jni.JniCallType.objectType, []).object); } - static final _id_nextFieldName = jniAccessors.getMethodIDOf(_classRef, - r"nextFieldName", r"(Lcom/fasterxml/jackson/core/SerializableString;)Z"); + static final _id_nextFieldName = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"nextFieldName", + r"(Lcom/fasterxml/jackson/core/SerializableString;)Z"); /// from: public boolean nextFieldName(com.fasterxml.jackson.core.SerializableString str) /// @@ -892,12 +919,12 @@ class JsonParser extends jni.JObject { bool nextFieldName( jni.JObject str, ) { - return jniAccessors.callMethodWithArgs(reference, _id_nextFieldName, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_nextFieldName, jni.JniCallType.booleanType, [str.reference]).boolean; } - static final _id_nextFieldName1 = jniAccessors.getMethodIDOf( - _classRef, r"nextFieldName", r"()Ljava/lang/String;"); + static final _id_nextFieldName1 = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"nextFieldName", r"()Ljava/lang/String;"); /// from: public java.lang.String nextFieldName() /// The returned object must be deleted after use, by calling the `delete` method. @@ -911,12 +938,12 @@ class JsonParser extends jni.JObject { /// JsonParseException for decoding problems ///@since 2.5 jni.JString nextFieldName1() { - return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JStringType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_nextFieldName1, jni.JniCallType.objectType, []).object); } - static final _id_nextTextValue = jniAccessors.getMethodIDOf( - _classRef, r"nextTextValue", r"()Ljava/lang/String;"); + static final _id_nextTextValue = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"nextTextValue", r"()Ljava/lang/String;"); /// from: public java.lang.String nextTextValue() /// The returned object must be deleted after use, by calling the `delete` method. @@ -935,12 +962,12 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems jni.JString nextTextValue() { - return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JStringType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_nextTextValue, jni.JniCallType.objectType, []).object); } - static final _id_nextIntValue = - jniAccessors.getMethodIDOf(_classRef, r"nextIntValue", r"(I)I"); + static final _id_nextIntValue = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"nextIntValue", r"(I)I"); /// from: public int nextIntValue(int defaultValue) /// @@ -964,12 +991,12 @@ class JsonParser extends jni.JObject { int nextIntValue( int defaultValue, ) { - return jniAccessors.callMethodWithArgs(reference, _id_nextIntValue, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_nextIntValue, jni.JniCallType.intType, [jni.JValueInt(defaultValue)]).integer; } - static final _id_nextLongValue = - jniAccessors.getMethodIDOf(_classRef, r"nextLongValue", r"(J)J"); + static final _id_nextLongValue = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"nextLongValue", r"(J)J"); /// from: public long nextLongValue(long defaultValue) /// @@ -993,12 +1020,12 @@ class JsonParser extends jni.JObject { int nextLongValue( int defaultValue, ) { - return jniAccessors.callMethodWithArgs(reference, _id_nextLongValue, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_nextLongValue, jni.JniCallType.longType, [defaultValue]).long; } - static final _id_nextBooleanValue = jniAccessors.getMethodIDOf( - _classRef, r"nextBooleanValue", r"()Ljava/lang/Boolean;"); + static final _id_nextBooleanValue = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"nextBooleanValue", r"()Ljava/lang/Boolean;"); /// from: public java.lang.Boolean nextBooleanValue() /// The returned object must be deleted after use, by calling the `delete` method. @@ -1020,14 +1047,16 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems jni.JObject nextBooleanValue() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_nextBooleanValue, jni.JniCallType.objectType, []).object); } - static final _id_skipChildren = jniAccessors.getMethodIDOf( - _classRef, r"skipChildren", r"()Lcom/fasterxml/jackson/core/JsonParser;"); + static final _id_skipChildren = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"skipChildren", + r"()Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public abstract com.fasterxml.jackson.core.JsonParser skipChildren() /// The returned object must be deleted after use, by calling the `delete` method. @@ -1048,12 +1077,12 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems JsonParser skipChildren() { - return const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs( + return const $JsonParserType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_skipChildren, jni.JniCallType.objectType, []).object); } static final _id_finishToken = - jniAccessors.getMethodIDOf(_classRef, r"finishToken", r"()V"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"finishToken", r"()V"); /// from: public void finishToken() /// @@ -1071,12 +1100,14 @@ class JsonParser extends jni.JObject { /// JsonParseException for decoding problems ///@since 2.8 void finishToken() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_finishToken, jni.JniCallType.voidType, []).check(); } - static final _id_currentToken = jniAccessors.getMethodIDOf( - _classRef, r"currentToken", r"()Lcom/fasterxml/jackson/core/JsonToken;"); + static final _id_currentToken = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"currentToken", + r"()Lcom/fasterxml/jackson/core/JsonToken;"); /// from: public com.fasterxml.jackson.core.JsonToken currentToken() /// The returned object must be deleted after use, by calling the `delete` method. @@ -1091,13 +1122,13 @@ class JsonParser extends jni.JObject { /// if the current token has been explicitly cleared. ///@since 2.8 jsontoken_.JsonToken currentToken() { - return const jsontoken_.$JsonTokenType().fromRef(jniAccessors + return const jsontoken_.$JsonTokenType().fromRef(jni.Jni.accessors .callMethodWithArgs(reference, _id_currentToken, jni.JniCallType.objectType, []).object); } - static final _id_currentTokenId = - jniAccessors.getMethodIDOf(_classRef, r"currentTokenId", r"()I"); + static final _id_currentTokenId = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"currentTokenId", r"()I"); /// from: public int currentTokenId() /// @@ -1111,12 +1142,14 @@ class JsonParser extends jni.JObject { ///@since 2.8 ///@return {@code int} matching one of constants from JsonTokenId. int currentTokenId() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_currentTokenId, jni.JniCallType.intType, []).integer; } - static final _id_getCurrentToken = jniAccessors.getMethodIDOf(_classRef, - r"getCurrentToken", r"()Lcom/fasterxml/jackson/core/JsonToken;"); + static final _id_getCurrentToken = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"getCurrentToken", + r"()Lcom/fasterxml/jackson/core/JsonToken;"); /// from: public abstract com.fasterxml.jackson.core.JsonToken getCurrentToken() /// The returned object must be deleted after use, by calling the `delete` method. @@ -1126,13 +1159,13 @@ 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 const jsontoken_.$JsonTokenType().fromRef(jniAccessors + return const jsontoken_.$JsonTokenType().fromRef(jni.Jni.accessors .callMethodWithArgs(reference, _id_getCurrentToken, jni.JniCallType.objectType, []).object); } - static final _id_getCurrentTokenId = - jniAccessors.getMethodIDOf(_classRef, r"getCurrentTokenId", r"()I"); + static final _id_getCurrentTokenId = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"getCurrentTokenId", r"()I"); /// from: public abstract int getCurrentTokenId() /// @@ -1140,12 +1173,12 @@ class JsonParser extends jni.JObject { ///@return {@code int} matching one of constants from JsonTokenId. ///@deprecated Since 2.12 use \#currentTokenId instead int getCurrentTokenId() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_getCurrentTokenId, jni.JniCallType.intType, []).integer; } - static final _id_hasCurrentToken = - jniAccessors.getMethodIDOf(_classRef, r"hasCurrentToken", r"()Z"); + static final _id_hasCurrentToken = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"hasCurrentToken", r"()Z"); /// from: public abstract boolean hasCurrentToken() /// @@ -1158,12 +1191,12 @@ class JsonParser extends jni.JObject { /// and returned null from \#nextToken, or the token /// has been consumed) bool hasCurrentToken() { - return jniAccessors.callMethodWithArgs(reference, _id_hasCurrentToken, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_hasCurrentToken, jni.JniCallType.booleanType, []).boolean; } static final _id_hasTokenId = - jniAccessors.getMethodIDOf(_classRef, r"hasTokenId", r"(I)Z"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"hasTokenId", r"(I)Z"); /// from: public abstract boolean hasTokenId(int id) /// @@ -1182,12 +1215,12 @@ class JsonParser extends jni.JObject { bool hasTokenId( int id, ) { - return jniAccessors.callMethodWithArgs(reference, _id_hasTokenId, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_hasTokenId, jni.JniCallType.booleanType, [jni.JValueInt(id)]).boolean; } - static final _id_hasToken = jniAccessors.getMethodIDOf( - _classRef, r"hasToken", r"(Lcom/fasterxml/jackson/core/JsonToken;)Z"); + static final _id_hasToken = jni.Jni.accessors.getMethodIDOf(_class.reference, + r"hasToken", r"(Lcom/fasterxml/jackson/core/JsonToken;)Z"); /// from: public abstract boolean hasToken(com.fasterxml.jackson.core.JsonToken t) /// @@ -1206,12 +1239,12 @@ class JsonParser extends jni.JObject { bool hasToken( jsontoken_.JsonToken t, ) { - return jniAccessors.callMethodWithArgs(reference, _id_hasToken, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_hasToken, jni.JniCallType.booleanType, [t.reference]).boolean; } - static final _id_isExpectedStartArrayToken = jniAccessors.getMethodIDOf( - _classRef, r"isExpectedStartArrayToken", r"()Z"); + static final _id_isExpectedStartArrayToken = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"isExpectedStartArrayToken", r"()Z"); /// from: public boolean isExpectedStartArrayToken() /// @@ -1232,12 +1265,12 @@ class JsonParser extends jni.JObject { /// start-array marker (such JsonToken\#START_ARRAY); /// {@code false} if not bool isExpectedStartArrayToken() { - return jniAccessors.callMethodWithArgs(reference, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_isExpectedStartArrayToken, jni.JniCallType.booleanType, []).boolean; } - static final _id_isExpectedStartObjectToken = jniAccessors.getMethodIDOf( - _classRef, r"isExpectedStartObjectToken", r"()Z"); + static final _id_isExpectedStartObjectToken = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"isExpectedStartObjectToken", r"()Z"); /// from: public boolean isExpectedStartObjectToken() /// @@ -1248,14 +1281,14 @@ class JsonParser extends jni.JObject { /// {@code false} if not ///@since 2.5 bool isExpectedStartObjectToken() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_isExpectedStartObjectToken, jni.JniCallType.booleanType, []).boolean; } - static final _id_isExpectedNumberIntToken = jniAccessors.getMethodIDOf( - _classRef, r"isExpectedNumberIntToken", r"()Z"); + static final _id_isExpectedNumberIntToken = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"isExpectedNumberIntToken", r"()Z"); /// from: public boolean isExpectedNumberIntToken() /// @@ -1269,12 +1302,12 @@ class JsonParser extends jni.JObject { /// {@code false} if not ///@since 2.12 bool isExpectedNumberIntToken() { - return jniAccessors.callMethodWithArgs(reference, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_isExpectedNumberIntToken, jni.JniCallType.booleanType, []).boolean; } static final _id_isNaN = - jniAccessors.getMethodIDOf(_classRef, r"isNaN", r"()Z"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"isNaN", r"()Z"); /// from: public boolean isNaN() /// @@ -1291,12 +1324,12 @@ class JsonParser extends jni.JObject { /// JsonParseException for decoding problems ///@since 2.9 bool isNaN() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_isNaN, jni.JniCallType.booleanType, []).boolean; } - static final _id_clearCurrentToken = - jniAccessors.getMethodIDOf(_classRef, r"clearCurrentToken", r"()V"); + static final _id_clearCurrentToken = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"clearCurrentToken", r"()V"); /// from: public abstract void clearCurrentToken() /// @@ -1311,12 +1344,14 @@ 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() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_clearCurrentToken, jni.JniCallType.voidType, []).check(); } - static final _id_getLastClearedToken = jniAccessors.getMethodIDOf(_classRef, - r"getLastClearedToken", r"()Lcom/fasterxml/jackson/core/JsonToken;"); + static final _id_getLastClearedToken = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"getLastClearedToken", + r"()Lcom/fasterxml/jackson/core/JsonToken;"); /// from: public abstract com.fasterxml.jackson.core.JsonToken getLastClearedToken() /// The returned object must be deleted after use, by calling the `delete` method. @@ -1328,13 +1363,13 @@ class JsonParser extends jni.JObject { /// or if parser has been closed. ///@return Last cleared token, if any; {@code null} otherwise jsontoken_.JsonToken getLastClearedToken() { - return const jsontoken_.$JsonTokenType().fromRef(jniAccessors + return const jsontoken_.$JsonTokenType().fromRef(jni.Jni.accessors .callMethodWithArgs(reference, _id_getLastClearedToken, jni.JniCallType.objectType, []).object); } - static final _id_overrideCurrentName = jniAccessors.getMethodIDOf( - _classRef, r"overrideCurrentName", r"(Ljava/lang/String;)V"); + static final _id_overrideCurrentName = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"overrideCurrentName", r"(Ljava/lang/String;)V"); /// from: public abstract void overrideCurrentName(java.lang.String name) /// @@ -1349,12 +1384,15 @@ class JsonParser extends jni.JObject { void overrideCurrentName( jni.JString name, ) { - return jniAccessors.callMethodWithArgs(reference, _id_overrideCurrentName, - jni.JniCallType.voidType, [name.reference]).check(); + return jni.Jni.accessors.callMethodWithArgs( + reference, + _id_overrideCurrentName, + jni.JniCallType.voidType, + [name.reference]).check(); } - static final _id_getCurrentName = jniAccessors.getMethodIDOf( - _classRef, r"getCurrentName", r"()Ljava/lang/String;"); + static final _id_getCurrentName = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"getCurrentName", r"()Ljava/lang/String;"); /// from: public abstract java.lang.String getCurrentName() /// The returned object must be deleted after use, by calling the `delete` method. @@ -1364,12 +1402,12 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems jni.JString getCurrentName() { - return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JStringType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getCurrentName, jni.JniCallType.objectType, []).object); } - static final _id_currentName = jniAccessors.getMethodIDOf( - _classRef, r"currentName", r"()Ljava/lang/String;"); + static final _id_currentName = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"currentName", r"()Ljava/lang/String;"); /// from: public java.lang.String currentName() /// The returned object must be deleted after use, by calling the `delete` method. @@ -1384,12 +1422,12 @@ class JsonParser extends jni.JObject { /// JsonParseException for decoding problems ///@since 2.10 jni.JString currentName() { - return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JStringType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_currentName, jni.JniCallType.objectType, []).object); } - static final _id_getText = jniAccessors.getMethodIDOf( - _classRef, r"getText", r"()Ljava/lang/String;"); + static final _id_getText = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"getText", r"()Ljava/lang/String;"); /// from: public abstract java.lang.String getText() /// The returned object must be deleted after use, by calling the `delete` method. @@ -1403,12 +1441,12 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems jni.JString getText() { - return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JStringType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getText, jni.JniCallType.objectType, []).object); } - static final _id_getText1 = - jniAccessors.getMethodIDOf(_classRef, r"getText", r"(Ljava/io/Writer;)I"); + static final _id_getText1 = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"getText", r"(Ljava/io/Writer;)I"); /// from: public int getText(java.io.Writer writer) /// @@ -1430,12 +1468,12 @@ class JsonParser extends jni.JObject { int getText1( jni.JObject writer, ) { - return jniAccessors.callMethodWithArgs(reference, _id_getText1, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_getText1, jni.JniCallType.intType, [writer.reference]).integer; } - static final _id_getTextCharacters = - jniAccessors.getMethodIDOf(_classRef, r"getTextCharacters", r"()[C"); + static final _id_getTextCharacters = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"getTextCharacters", r"()[C"); /// from: public abstract char[] getTextCharacters() /// The returned object must be deleted after use, by calling the `delete` method. @@ -1467,14 +1505,14 @@ class JsonParser extends jni.JObject { /// at offset 0, and not necessarily until the end of buffer) ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - jni.JArray getTextCharacters() { - return const jni.JArrayType(jni.JCharType()).fromRef(jniAccessors + jni.JArray getTextCharacters() { + return const jni.JArrayType(jni.jcharType()).fromRef(jni.Jni.accessors .callMethodWithArgs(reference, _id_getTextCharacters, jni.JniCallType.objectType, []).object); } - static final _id_getTextLength = - jniAccessors.getMethodIDOf(_classRef, r"getTextLength", r"()I"); + static final _id_getTextLength = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"getTextLength", r"()I"); /// from: public abstract int getTextLength() /// @@ -1486,12 +1524,12 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems int getTextLength() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_getTextLength, jni.JniCallType.intType, []).integer; } - static final _id_getTextOffset = - jniAccessors.getMethodIDOf(_classRef, r"getTextOffset", r"()I"); + static final _id_getTextOffset = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"getTextOffset", r"()I"); /// from: public abstract int getTextOffset() /// @@ -1503,12 +1541,12 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems int getTextOffset() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_getTextOffset, jni.JniCallType.intType, []).integer; } - static final _id_hasTextCharacters = - jniAccessors.getMethodIDOf(_classRef, r"hasTextCharacters", r"()Z"); + static final _id_hasTextCharacters = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"hasTextCharacters", r"()Z"); /// from: public abstract boolean hasTextCharacters() /// @@ -1527,12 +1565,12 @@ class JsonParser extends jni.JObject { /// be efficiently returned via \#getTextCharacters; false /// means that it may or may not exist bool hasTextCharacters() { - return jniAccessors.callMethodWithArgs(reference, _id_hasTextCharacters, - jni.JniCallType.booleanType, []).boolean; + return jni.Jni.accessors.callMethodWithArgs(reference, + _id_hasTextCharacters, jni.JniCallType.booleanType, []).boolean; } - static final _id_getNumberValue = jniAccessors.getMethodIDOf( - _classRef, r"getNumberValue", r"()Ljava/lang/Number;"); + static final _id_getNumberValue = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"getNumberValue", r"()Ljava/lang/Number;"); /// from: public abstract java.lang.Number getNumberValue() /// The returned object must be deleted after use, by calling the `delete` method. @@ -1548,12 +1586,12 @@ class JsonParser extends jni.JObject { /// (invalid format for numbers); plain IOException if underlying /// content read fails (possible if values are extracted lazily) jni.JObject getNumberValue() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getNumberValue, jni.JniCallType.objectType, []).object); } - static final _id_getNumberValueExact = jniAccessors.getMethodIDOf( - _classRef, r"getNumberValueExact", r"()Ljava/lang/Number;"); + static final _id_getNumberValueExact = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"getNumberValueExact", r"()Ljava/lang/Number;"); /// from: public java.lang.Number getNumberValueExact() /// The returned object must be deleted after use, by calling the `delete` method. @@ -1573,14 +1611,14 @@ class JsonParser extends jni.JObject { /// content read fails (possible if values are extracted lazily) ///@since 2.12 jni.JObject getNumberValueExact() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getNumberValueExact, jni.JniCallType.objectType, []).object); } - static final _id_getNumberType = jniAccessors.getMethodIDOf( - _classRef, + static final _id_getNumberType = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"getNumberType", r"()Lcom/fasterxml/jackson/core/JsonParser$NumberType;"); @@ -1595,13 +1633,13 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems JsonParser_NumberType getNumberType() { - return const $JsonParser_NumberTypeType().fromRef(jniAccessors + return const $JsonParser_NumberTypeType().fromRef(jni.Jni.accessors .callMethodWithArgs(reference, _id_getNumberType, jni.JniCallType.objectType, []).object); } - static final _id_getByteValue = - jniAccessors.getMethodIDOf(_classRef, r"getByteValue", r"()B"); + static final _id_getByteValue = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"getByteValue", r"()B"); /// from: public byte getByteValue() /// @@ -1627,12 +1665,12 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems int getByteValue() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_getByteValue, jni.JniCallType.byteType, []).byte; } - static final _id_getShortValue = - jniAccessors.getMethodIDOf(_classRef, r"getShortValue", r"()S"); + static final _id_getShortValue = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"getShortValue", r"()S"); /// from: public short getShortValue() /// @@ -1652,12 +1690,12 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems int getShortValue() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_getShortValue, jni.JniCallType.shortType, []).short; } static final _id_getIntValue = - jniAccessors.getMethodIDOf(_classRef, r"getIntValue", r"()I"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"getIntValue", r"()I"); /// from: public abstract int getIntValue() /// @@ -1677,12 +1715,12 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems int getIntValue() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_getIntValue, jni.JniCallType.intType, []).integer; } - static final _id_getLongValue = - jniAccessors.getMethodIDOf(_classRef, r"getLongValue", r"()J"); + static final _id_getLongValue = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"getLongValue", r"()J"); /// from: public abstract long getLongValue() /// @@ -1702,12 +1740,12 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems int getLongValue() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_getLongValue, jni.JniCallType.longType, []).long; } - static final _id_getBigIntegerValue = jniAccessors.getMethodIDOf( - _classRef, r"getBigIntegerValue", r"()Ljava/math/BigInteger;"); + static final _id_getBigIntegerValue = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"getBigIntegerValue", r"()Ljava/math/BigInteger;"); /// from: public abstract java.math.BigInteger getBigIntegerValue() /// The returned object must be deleted after use, by calling the `delete` method. @@ -1724,14 +1762,14 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems jni.JObject getBigIntegerValue() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getBigIntegerValue, jni.JniCallType.objectType, []).object); } - static final _id_getFloatValue = - jniAccessors.getMethodIDOf(_classRef, r"getFloatValue", r"()F"); + static final _id_getFloatValue = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"getFloatValue", r"()F"); /// from: public abstract float getFloatValue() /// @@ -1751,12 +1789,12 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems double getFloatValue() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_getFloatValue, jni.JniCallType.floatType, []).float; } - static final _id_getDoubleValue = - jniAccessors.getMethodIDOf(_classRef, r"getDoubleValue", r"()D"); + static final _id_getDoubleValue = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"getDoubleValue", r"()D"); /// from: public abstract double getDoubleValue() /// @@ -1776,12 +1814,12 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems double getDoubleValue() { - return jniAccessors.callMethodWithArgs(reference, _id_getDoubleValue, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_getDoubleValue, jni.JniCallType.doubleType, []).doubleFloat; } - static final _id_getDecimalValue = jniAccessors.getMethodIDOf( - _classRef, r"getDecimalValue", r"()Ljava/math/BigDecimal;"); + static final _id_getDecimalValue = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"getDecimalValue", r"()Ljava/math/BigDecimal;"); /// from: public abstract java.math.BigDecimal getDecimalValue() /// The returned object must be deleted after use, by calling the `delete` method. @@ -1795,12 +1833,12 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems jni.JObject getDecimalValue() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getDecimalValue, jni.JniCallType.objectType, []).object); } - static final _id_getBooleanValue = - jniAccessors.getMethodIDOf(_classRef, r"getBooleanValue", r"()Z"); + static final _id_getBooleanValue = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"getBooleanValue", r"()Z"); /// from: public boolean getBooleanValue() /// @@ -1816,12 +1854,12 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems bool getBooleanValue() { - return jniAccessors.callMethodWithArgs(reference, _id_getBooleanValue, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_getBooleanValue, jni.JniCallType.booleanType, []).boolean; } - static final _id_getEmbeddedObject = jniAccessors.getMethodIDOf( - _classRef, r"getEmbeddedObject", r"()Ljava/lang/Object;"); + static final _id_getEmbeddedObject = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"getEmbeddedObject", r"()Ljava/lang/Object;"); /// from: public java.lang.Object getEmbeddedObject() /// The returned object must be deleted after use, by calling the `delete` method. @@ -1841,14 +1879,16 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems jni.JObject getEmbeddedObject() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getEmbeddedObject, jni.JniCallType.objectType, []).object); } - static final _id_getBinaryValue = jniAccessors.getMethodIDOf(_classRef, - r"getBinaryValue", r"(Lcom/fasterxml/jackson/core/Base64Variant;)[B"); + static final _id_getBinaryValue = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"getBinaryValue", + r"(Lcom/fasterxml/jackson/core/Base64Variant;)[B"); /// from: public abstract byte[] getBinaryValue(com.fasterxml.jackson.core.Base64Variant bv) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1873,16 +1913,16 @@ class JsonParser extends jni.JObject { ///@return Decoded binary data ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - jni.JArray getBinaryValue( + jni.JArray getBinaryValue( jni.JObject bv, ) { - return const jni.JArrayType(jni.JByteType()).fromRef(jniAccessors + return const jni.JArrayType(jni.jbyteType()).fromRef(jni.Jni.accessors .callMethodWithArgs(reference, _id_getBinaryValue, jni.JniCallType.objectType, [bv.reference]).object); } - static final _id_getBinaryValue1 = - jniAccessors.getMethodIDOf(_classRef, r"getBinaryValue", r"()[B"); + static final _id_getBinaryValue1 = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"getBinaryValue", r"()[B"); /// from: public byte[] getBinaryValue() /// The returned object must be deleted after use, by calling the `delete` method. @@ -1893,14 +1933,14 @@ class JsonParser extends jni.JObject { ///@return Decoded binary data ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - jni.JArray getBinaryValue1() { - return const jni.JArrayType(jni.JByteType()).fromRef(jniAccessors + jni.JArray getBinaryValue1() { + return const jni.JArrayType(jni.jbyteType()).fromRef(jni.Jni.accessors .callMethodWithArgs(reference, _id_getBinaryValue1, jni.JniCallType.objectType, []).object); } - static final _id_readBinaryValue = jniAccessors.getMethodIDOf( - _classRef, r"readBinaryValue", r"(Ljava/io/OutputStream;)I"); + static final _id_readBinaryValue = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"readBinaryValue", r"(Ljava/io/OutputStream;)I"); /// from: public int readBinaryValue(java.io.OutputStream out) /// @@ -1918,12 +1958,12 @@ class JsonParser extends jni.JObject { int readBinaryValue( jni.JObject out, ) { - return jniAccessors.callMethodWithArgs(reference, _id_readBinaryValue, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_readBinaryValue, jni.JniCallType.intType, [out.reference]).integer; } - static final _id_readBinaryValue1 = jniAccessors.getMethodIDOf( - _classRef, + static final _id_readBinaryValue1 = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"readBinaryValue", r"(Lcom/fasterxml/jackson/core/Base64Variant;Ljava/io/OutputStream;)I"); @@ -1941,12 +1981,12 @@ class JsonParser extends jni.JObject { jni.JObject bv, jni.JObject out, ) { - return jniAccessors.callMethodWithArgs(reference, _id_readBinaryValue1, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_readBinaryValue1, jni.JniCallType.intType, [bv.reference, out.reference]).integer; } - static final _id_getValueAsInt = - jniAccessors.getMethodIDOf(_classRef, r"getValueAsInt", r"()I"); + static final _id_getValueAsInt = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"getValueAsInt", r"()I"); /// from: public int getValueAsInt() /// @@ -1964,12 +2004,12 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems int getValueAsInt() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_getValueAsInt, jni.JniCallType.intType, []).integer; } - static final _id_getValueAsInt1 = - jniAccessors.getMethodIDOf(_classRef, r"getValueAsInt", r"(I)I"); + static final _id_getValueAsInt1 = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"getValueAsInt", r"(I)I"); /// from: public int getValueAsInt(int def) /// @@ -1989,12 +2029,12 @@ class JsonParser extends jni.JObject { int getValueAsInt1( int def, ) { - return jniAccessors.callMethodWithArgs(reference, _id_getValueAsInt1, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_getValueAsInt1, jni.JniCallType.intType, [jni.JValueInt(def)]).integer; } - static final _id_getValueAsLong = - jniAccessors.getMethodIDOf(_classRef, r"getValueAsLong", r"()J"); + static final _id_getValueAsLong = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"getValueAsLong", r"()J"); /// from: public long getValueAsLong() /// @@ -2012,12 +2052,12 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems int getValueAsLong() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_getValueAsLong, jni.JniCallType.longType, []).long; } - static final _id_getValueAsLong1 = - jniAccessors.getMethodIDOf(_classRef, r"getValueAsLong", r"(J)J"); + static final _id_getValueAsLong1 = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"getValueAsLong", r"(J)J"); /// from: public long getValueAsLong(long def) /// @@ -2037,12 +2077,12 @@ class JsonParser extends jni.JObject { int getValueAsLong1( int def, ) { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_getValueAsLong1, jni.JniCallType.longType, [def]).long; } - static final _id_getValueAsDouble = - jniAccessors.getMethodIDOf(_classRef, r"getValueAsDouble", r"()D"); + static final _id_getValueAsDouble = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"getValueAsDouble", r"()D"); /// from: public double getValueAsDouble() /// @@ -2060,12 +2100,12 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems double getValueAsDouble() { - return jniAccessors.callMethodWithArgs(reference, _id_getValueAsDouble, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_getValueAsDouble, jni.JniCallType.doubleType, []).doubleFloat; } - static final _id_getValueAsDouble1 = - jniAccessors.getMethodIDOf(_classRef, r"getValueAsDouble", r"(D)D"); + static final _id_getValueAsDouble1 = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"getValueAsDouble", r"(D)D"); /// from: public double getValueAsDouble(double def) /// @@ -2085,12 +2125,12 @@ class JsonParser extends jni.JObject { double getValueAsDouble1( double def, ) { - return jniAccessors.callMethodWithArgs(reference, _id_getValueAsDouble1, - jni.JniCallType.doubleType, [def]).doubleFloat; + return jni.Jni.accessors.callMethodWithArgs(reference, + _id_getValueAsDouble1, jni.JniCallType.doubleType, [def]).doubleFloat; } - static final _id_getValueAsBoolean = - jniAccessors.getMethodIDOf(_classRef, r"getValueAsBoolean", r"()Z"); + static final _id_getValueAsBoolean = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"getValueAsBoolean", r"()Z"); /// from: public boolean getValueAsBoolean() /// @@ -2108,12 +2148,12 @@ class JsonParser extends jni.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems bool getValueAsBoolean() { - return jniAccessors.callMethodWithArgs(reference, _id_getValueAsBoolean, - jni.JniCallType.booleanType, []).boolean; + return jni.Jni.accessors.callMethodWithArgs(reference, + _id_getValueAsBoolean, jni.JniCallType.booleanType, []).boolean; } - static final _id_getValueAsBoolean1 = - jniAccessors.getMethodIDOf(_classRef, r"getValueAsBoolean", r"(Z)Z"); + static final _id_getValueAsBoolean1 = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"getValueAsBoolean", r"(Z)Z"); /// from: public boolean getValueAsBoolean(boolean def) /// @@ -2133,12 +2173,15 @@ class JsonParser extends jni.JObject { bool getValueAsBoolean1( bool def, ) { - return jniAccessors.callMethodWithArgs(reference, _id_getValueAsBoolean1, - jni.JniCallType.booleanType, [def ? 1 : 0]).boolean; + return jni.Jni.accessors.callMethodWithArgs( + reference, + _id_getValueAsBoolean1, + jni.JniCallType.booleanType, + [def ? 1 : 0]).boolean; } - static final _id_getValueAsString = jniAccessors.getMethodIDOf( - _classRef, r"getValueAsString", r"()Ljava/lang/String;"); + static final _id_getValueAsString = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"getValueAsString", r"()Ljava/lang/String;"); /// from: public java.lang.String getValueAsString() /// The returned object must be deleted after use, by calling the `delete` method. @@ -2155,14 +2198,16 @@ class JsonParser extends jni.JObject { /// JsonParseException for decoding problems ///@since 2.1 jni.JString getValueAsString() { - return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JStringType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getValueAsString, jni.JniCallType.objectType, []).object); } - static final _id_getValueAsString1 = jniAccessors.getMethodIDOf(_classRef, - r"getValueAsString", r"(Ljava/lang/String;)Ljava/lang/String;"); + static final _id_getValueAsString1 = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"getValueAsString", + r"(Ljava/lang/String;)Ljava/lang/String;"); /// from: public abstract java.lang.String getValueAsString(java.lang.String def) /// The returned object must be deleted after use, by calling the `delete` method. @@ -2182,15 +2227,15 @@ class JsonParser extends jni.JObject { jni.JString getValueAsString1( jni.JString def, ) { - return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JStringType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getValueAsString1, jni.JniCallType.objectType, [def.reference]).object); } - static final _id_canReadObjectId = - jniAccessors.getMethodIDOf(_classRef, r"canReadObjectId", r"()Z"); + static final _id_canReadObjectId = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"canReadObjectId", r"()Z"); /// from: public boolean canReadObjectId() /// @@ -2206,12 +2251,12 @@ class JsonParser extends jni.JObject { /// {@code false} if not ///@since 2.3 bool canReadObjectId() { - return jniAccessors.callMethodWithArgs(reference, _id_canReadObjectId, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_canReadObjectId, jni.JniCallType.booleanType, []).boolean; } - static final _id_canReadTypeId = - jniAccessors.getMethodIDOf(_classRef, r"canReadTypeId", r"()Z"); + static final _id_canReadTypeId = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"canReadTypeId", r"()Z"); /// from: public boolean canReadTypeId() /// @@ -2227,12 +2272,12 @@ class JsonParser extends jni.JObject { /// {@code false} if not ///@since 2.3 bool canReadTypeId() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_canReadTypeId, jni.JniCallType.booleanType, []).boolean; } - static final _id_getObjectId = jniAccessors.getMethodIDOf( - _classRef, r"getObjectId", r"()Ljava/lang/Object;"); + static final _id_getObjectId = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"getObjectId", r"()Ljava/lang/Object;"); /// from: public java.lang.Object getObjectId() /// The returned object must be deleted after use, by calling the `delete` method. @@ -2251,12 +2296,12 @@ class JsonParser extends jni.JObject { /// JsonParseException for decoding problems ///@since 2.3 jni.JObject getObjectId() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getObjectId, jni.JniCallType.objectType, []).object); } - static final _id_getTypeId = jniAccessors.getMethodIDOf( - _classRef, r"getTypeId", r"()Ljava/lang/Object;"); + static final _id_getTypeId = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"getTypeId", r"()Ljava/lang/Object;"); /// from: public java.lang.Object getTypeId() /// The returned object must be deleted after use, by calling the `delete` method. @@ -2275,12 +2320,14 @@ class JsonParser extends jni.JObject { /// JsonParseException for decoding problems ///@since 2.3 jni.JObject getTypeId() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getTypeId, jni.JniCallType.objectType, []).object); } - static final _id_readValueAs = jniAccessors.getMethodIDOf( - _classRef, r"readValueAs", r"(Ljava/lang/Class;)Ljava/lang/Object;"); + static final _id_readValueAs = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"readValueAs", + r"(Ljava/lang/Class;)Ljava/lang/Object;"); /// from: public T readValueAs(java.lang.Class valueType) /// The returned object must be deleted after use, by calling the `delete` method. @@ -2314,12 +2361,15 @@ class JsonParser extends jni.JObject { jni.JObject valueType, { required jni.JObjType<$T> T, }) { - return T.fromRef(jniAccessors.callMethodWithArgs(reference, _id_readValueAs, - jni.JniCallType.objectType, [valueType.reference]).object); + return T.fromRef(jni.Jni.accessors.callMethodWithArgs( + reference, + _id_readValueAs, + jni.JniCallType.objectType, + [valueType.reference]).object); } - static final _id_readValueAs1 = jniAccessors.getMethodIDOf( - _classRef, + static final _id_readValueAs1 = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"readValueAs", r"(Lcom/fasterxml/jackson/core/type/TypeReference;)Ljava/lang/Object;"); @@ -2352,15 +2402,17 @@ class JsonParser extends jni.JObject { jni.JObject valueTypeRef, { required jni.JObjType<$T> T, }) { - return T.fromRef(jniAccessors.callMethodWithArgs( + return T.fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_readValueAs1, jni.JniCallType.objectType, [valueTypeRef.reference]).object); } - static final _id_readValuesAs = jniAccessors.getMethodIDOf( - _classRef, r"readValuesAs", r"(Ljava/lang/Class;)Ljava/util/Iterator;"); + static final _id_readValuesAs = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"readValuesAs", + r"(Ljava/lang/Class;)Ljava/util/Iterator;"); /// from: public java.util.Iterator readValuesAs(java.lang.Class valueType) /// The returned object must be deleted after use, by calling the `delete` method. @@ -2377,15 +2429,15 @@ class JsonParser extends jni.JObject { jni.JObject valueType, { required jni.JObjType<$T> T, }) { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_readValuesAs, jni.JniCallType.objectType, [valueType.reference]).object); } - static final _id_readValuesAs1 = jniAccessors.getMethodIDOf( - _classRef, + static final _id_readValuesAs1 = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"readValuesAs", r"(Lcom/fasterxml/jackson/core/type/TypeReference;)Ljava/util/Iterator;"); @@ -2404,15 +2456,15 @@ class JsonParser extends jni.JObject { jni.JObject valueTypeRef, { required jni.JObjType<$T> T, }) { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_readValuesAs1, jni.JniCallType.objectType, [valueTypeRef.reference]).object); } - static final _id_readValueAsTree = jniAccessors.getMethodIDOf( - _classRef, r"readValueAsTree", r"()Ljava/lang/Object;"); + static final _id_readValueAsTree = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"readValueAsTree", r"()Ljava/lang/Object;"); /// from: public T readValueAsTree() /// The returned object must be deleted after use, by calling the `delete` method. @@ -2429,7 +2481,7 @@ class JsonParser extends jni.JObject { $T readValueAsTree<$T extends jni.JObject>({ required jni.JObjType<$T> T, }) { - return T.fromRef(jniAccessors.callMethodWithArgs( + return T.fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_readValueAsTree, jni.JniCallType.objectType, []).object); } } @@ -2454,7 +2506,7 @@ class $JsonParserType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $JsonParserType && other is $JsonParserType; + return other.runtimeType == ($JsonParserType) && other is $JsonParserType; } } @@ -2463,30 +2515,32 @@ class $JsonParserType extends jni.JObjType { /// Enumeration that defines all on/off features for parsers. class JsonParser_Feature extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; JsonParser_Feature.fromRef( jni.JObjectPtr ref, ) : super.fromRef(ref); - static final _classRef = - jniAccessors.getClassOf(r"com/fasterxml/jackson/core/JsonParser$Feature"); + static final _class = + jni.Jni.findJClass(r"com/fasterxml/jackson/core/JsonParser$Feature"); /// The type which includes information such as the signature of this class. static const type = $JsonParser_FeatureType(); - static final _id_values = jniAccessors.getStaticMethodIDOf(_classRef, - r"values", r"()[Lcom/fasterxml/jackson/core/JsonParser$Feature;"); + static final _id_values = jni.Jni.accessors.getStaticMethodIDOf( + _class.reference, + r"values", + r"()[Lcom/fasterxml/jackson/core/JsonParser$Feature;"); /// from: static public com.fasterxml.jackson.core.JsonParser.Feature[] values() /// The returned object must be deleted after use, by calling the `delete` method. static jni.JArray values() { - return const jni.JArrayType($JsonParser_FeatureType()).fromRef(jniAccessors - .callStaticMethodWithArgs( - _classRef, _id_values, jni.JniCallType.objectType, []).object); + return const jni.JArrayType($JsonParser_FeatureType()).fromRef( + jni.Jni.accessors.callStaticMethodWithArgs(_class.reference, _id_values, + jni.JniCallType.objectType, []).object); } - static final _id_valueOf = jniAccessors.getStaticMethodIDOf( - _classRef, + static final _id_valueOf = jni.Jni.accessors.getStaticMethodIDOf( + _class.reference, r"valueOf", r"(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonParser$Feature;"); @@ -2495,13 +2549,13 @@ class JsonParser_Feature extends jni.JObject { static JsonParser_Feature valueOf( jni.JString name, ) { - return const $JsonParser_FeatureType().fromRef(jniAccessors - .callStaticMethodWithArgs(_classRef, _id_valueOf, + return const $JsonParser_FeatureType().fromRef(jni.Jni.accessors + .callStaticMethodWithArgs(_class.reference, _id_valueOf, jni.JniCallType.objectType, [name.reference]).object); } - static final _id_collectDefaults = - jniAccessors.getStaticMethodIDOf(_classRef, r"collectDefaults", r"()I"); + static final _id_collectDefaults = jni.Jni.accessors + .getStaticMethodIDOf(_class.reference, r"collectDefaults", r"()I"); /// from: static public int collectDefaults() /// @@ -2509,36 +2563,36 @@ class JsonParser_Feature extends jni.JObject { /// are enabled by default. ///@return Bit mask of all features that are enabled by default static int collectDefaults() { - return jniAccessors.callStaticMethodWithArgs( - _classRef, _id_collectDefaults, jni.JniCallType.intType, []).integer; + return jni.Jni.accessors.callStaticMethodWithArgs(_class.reference, + _id_collectDefaults, jni.JniCallType.intType, []).integer; } - static final _id_enabledByDefault = - jniAccessors.getMethodIDOf(_classRef, r"enabledByDefault", r"()Z"); + static final _id_enabledByDefault = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"enabledByDefault", r"()Z"); /// from: public boolean enabledByDefault() bool enabledByDefault() { - return jniAccessors.callMethodWithArgs(reference, _id_enabledByDefault, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_enabledByDefault, jni.JniCallType.booleanType, []).boolean; } static final _id_enabledIn = - jniAccessors.getMethodIDOf(_classRef, r"enabledIn", r"(I)Z"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"enabledIn", r"(I)Z"); /// from: public boolean enabledIn(int flags) bool enabledIn( int flags, ) { - return jniAccessors.callMethodWithArgs(reference, _id_enabledIn, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_enabledIn, jni.JniCallType.booleanType, [jni.JValueInt(flags)]).boolean; } static final _id_getMask = - jniAccessors.getMethodIDOf(_classRef, r"getMask", r"()I"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"getMask", r"()I"); /// from: public int getMask() int getMask() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_getMask, jni.JniCallType.intType, []).integer; } } @@ -2564,7 +2618,7 @@ class $JsonParser_FeatureType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $JsonParser_FeatureType && + return other.runtimeType == ($JsonParser_FeatureType) && other is $JsonParser_FeatureType; } } @@ -2575,30 +2629,32 @@ class $JsonParser_FeatureType extends jni.JObjType { /// used for numbers. class JsonParser_NumberType extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; JsonParser_NumberType.fromRef( jni.JObjectPtr ref, ) : super.fromRef(ref); - static final _classRef = jniAccessors - .getClassOf(r"com/fasterxml/jackson/core/JsonParser$NumberType"); + static final _class = + jni.Jni.findJClass(r"com/fasterxml/jackson/core/JsonParser$NumberType"); /// The type which includes information such as the signature of this class. static const type = $JsonParser_NumberTypeType(); - static final _id_values = jniAccessors.getStaticMethodIDOf(_classRef, - r"values", r"()[Lcom/fasterxml/jackson/core/JsonParser$NumberType;"); + static final _id_values = jni.Jni.accessors.getStaticMethodIDOf( + _class.reference, + r"values", + r"()[Lcom/fasterxml/jackson/core/JsonParser$NumberType;"); /// from: static public com.fasterxml.jackson.core.JsonParser.NumberType[] values() /// The returned object must be deleted after use, by calling the `delete` method. static jni.JArray values() { return const jni.JArrayType($JsonParser_NumberTypeType()).fromRef( - jniAccessors.callStaticMethodWithArgs( - _classRef, _id_values, jni.JniCallType.objectType, []).object); + jni.Jni.accessors.callStaticMethodWithArgs(_class.reference, _id_values, + jni.JniCallType.objectType, []).object); } - static final _id_valueOf = jniAccessors.getStaticMethodIDOf( - _classRef, + static final _id_valueOf = jni.Jni.accessors.getStaticMethodIDOf( + _class.reference, r"valueOf", r"(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonParser$NumberType;"); @@ -2607,8 +2663,8 @@ class JsonParser_NumberType extends jni.JObject { static JsonParser_NumberType valueOf( jni.JString name, ) { - return const $JsonParser_NumberTypeType().fromRef(jniAccessors - .callStaticMethodWithArgs(_classRef, _id_valueOf, + return const $JsonParser_NumberTypeType().fromRef(jni.Jni.accessors + .callStaticMethodWithArgs(_class.reference, _id_valueOf, jni.JniCallType.objectType, [name.reference]).object); } } @@ -2634,7 +2690,7 @@ class $JsonParser_NumberTypeType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $JsonParser_NumberTypeType && + return other.runtimeType == ($JsonParser_NumberTypeType) && other is $JsonParser_NumberTypeType; } } diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart index 2a88806e9..b6bc6e549 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart @@ -36,38 +36,38 @@ import "dart:ffi" as ffi; import "package:jni/internal_helpers_for_jnigen.dart"; import "package:jni/jni.dart" as jni; -import "../../../../_init.dart"; - /// from: com.fasterxml.jackson.core.JsonToken /// /// Enumeration for basic token types used for returning results /// of parsing JSON content. class JsonToken extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; JsonToken.fromRef( jni.JObjectPtr ref, ) : super.fromRef(ref); - static final _classRef = - jniAccessors.getClassOf(r"com/fasterxml/jackson/core/JsonToken"); + static final _class = + jni.Jni.findJClass(r"com/fasterxml/jackson/core/JsonToken"); /// The type which includes information such as the signature of this class. static const type = $JsonTokenType(); - static final _id_values = jniAccessors.getStaticMethodIDOf( - _classRef, r"values", r"()[Lcom/fasterxml/jackson/core/JsonToken;"); + static final _id_values = jni.Jni.accessors.getStaticMethodIDOf( + _class.reference, + r"values", + r"()[Lcom/fasterxml/jackson/core/JsonToken;"); /// from: static public com.fasterxml.jackson.core.JsonToken[] values() /// The returned object must be deleted after use, by calling the `delete` method. static jni.JArray values() { - return const jni.JArrayType($JsonTokenType()).fromRef(jniAccessors - .callStaticMethodWithArgs( - _classRef, _id_values, jni.JniCallType.objectType, []).object); + return const jni.JArrayType($JsonTokenType()).fromRef(jni.Jni.accessors + .callStaticMethodWithArgs(_class.reference, _id_values, + jni.JniCallType.objectType, []).object); } - static final _id_valueOf = jniAccessors.getStaticMethodIDOf( - _classRef, + static final _id_valueOf = jni.Jni.accessors.getStaticMethodIDOf( + _class.reference, r"valueOf", r"(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonToken;"); @@ -76,67 +76,66 @@ class JsonToken extends jni.JObject { static JsonToken valueOf( jni.JString name, ) { - return const $JsonTokenType().fromRef(jniAccessors.callStaticMethodWithArgs( - _classRef, - _id_valueOf, - jni.JniCallType.objectType, - [name.reference]).object); + return const $JsonTokenType().fromRef(jni.Jni.accessors + .callStaticMethodWithArgs(_class.reference, _id_valueOf, + jni.JniCallType.objectType, [name.reference]).object); } - static final _id_id = jniAccessors.getMethodIDOf(_classRef, r"id", r"()I"); + static final _id_id = + jni.Jni.accessors.getMethodIDOf(_class.reference, r"id", r"()I"); /// from: public final int id() int id() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_id, jni.JniCallType.intType, []).integer; } - static final _id_asString = jniAccessors.getMethodIDOf( - _classRef, r"asString", r"()Ljava/lang/String;"); + static final _id_asString = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"asString", r"()Ljava/lang/String;"); /// from: public final java.lang.String asString() /// The returned object must be deleted after use, by calling the `delete` method. jni.JString asString() { - return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JStringType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_asString, jni.JniCallType.objectType, []).object); } - static final _id_asCharArray = - jniAccessors.getMethodIDOf(_classRef, r"asCharArray", r"()[C"); + static final _id_asCharArray = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"asCharArray", r"()[C"); /// from: public final char[] asCharArray() /// The returned object must be deleted after use, by calling the `delete` method. - jni.JArray asCharArray() { - return const jni.JArrayType(jni.JCharType()).fromRef(jniAccessors + jni.JArray asCharArray() { + return const jni.JArrayType(jni.jcharType()).fromRef(jni.Jni.accessors .callMethodWithArgs( reference, _id_asCharArray, jni.JniCallType.objectType, []).object); } - static final _id_asByteArray = - jniAccessors.getMethodIDOf(_classRef, r"asByteArray", r"()[B"); + static final _id_asByteArray = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"asByteArray", r"()[B"); /// from: public final byte[] asByteArray() /// The returned object must be deleted after use, by calling the `delete` method. - jni.JArray asByteArray() { - return const jni.JArrayType(jni.JByteType()).fromRef(jniAccessors + jni.JArray asByteArray() { + return const jni.JArrayType(jni.jbyteType()).fromRef(jni.Jni.accessors .callMethodWithArgs( reference, _id_asByteArray, jni.JniCallType.objectType, []).object); } static final _id_isNumeric = - jniAccessors.getMethodIDOf(_classRef, r"isNumeric", r"()Z"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"isNumeric", r"()Z"); /// from: public final boolean isNumeric() /// /// @return {@code True} if this token is {@code VALUE_NUMBER_INT} or {@code VALUE_NUMBER_FLOAT}, /// {@code false} otherwise bool isNumeric() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_isNumeric, jni.JniCallType.booleanType, []).boolean; } - static final _id_isStructStart = - jniAccessors.getMethodIDOf(_classRef, r"isStructStart", r"()Z"); + static final _id_isStructStart = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"isStructStart", r"()Z"); /// from: public final boolean isStructStart() /// @@ -148,12 +147,12 @@ class JsonToken extends jni.JObject { /// {@code false} otherwise ///@since 2.3 bool isStructStart() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_isStructStart, jni.JniCallType.booleanType, []).boolean; } static final _id_isStructEnd = - jniAccessors.getMethodIDOf(_classRef, r"isStructEnd", r"()Z"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"isStructEnd", r"()Z"); /// from: public final boolean isStructEnd() /// @@ -165,12 +164,12 @@ class JsonToken extends jni.JObject { /// {@code false} otherwise ///@since 2.3 bool isStructEnd() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_isStructEnd, jni.JniCallType.booleanType, []).boolean; } - static final _id_isScalarValue = - jniAccessors.getMethodIDOf(_classRef, r"isScalarValue", r"()Z"); + static final _id_isScalarValue = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"isScalarValue", r"()Z"); /// from: public final boolean isScalarValue() /// @@ -181,19 +180,19 @@ 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 bool isScalarValue() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_isScalarValue, jni.JniCallType.booleanType, []).boolean; } static final _id_isBoolean = - jniAccessors.getMethodIDOf(_classRef, r"isBoolean", r"()Z"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"isBoolean", r"()Z"); /// from: public final boolean isBoolean() /// /// @return {@code True} if this token is {@code VALUE_TRUE} or {@code VALUE_FALSE}, /// {@code false} otherwise bool isBoolean() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_isBoolean, jni.JniCallType.booleanType, []).boolean; } } @@ -218,6 +217,6 @@ class $JsonTokenType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $JsonTokenType && other is $JsonTokenType; + return other.runtimeType == ($JsonTokenType) && other is $JsonTokenType; } } diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/_init.dart b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/_init.dart deleted file mode 100644 index eec3a8c14..000000000 --- a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/_init.dart +++ /dev/null @@ -1,23 +0,0 @@ -// Generated from jackson-core which is licensed under the Apache License 2.0. -// The following copyright from the original authors applies. -// See https://github.com/FasterXML/jackson-core/blob/2.14/LICENSE -// -// Copyright (c) 2007 - The Jackson Project Authors -// Licensed under the Apache License, Version 2.0 (the "License") -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import "package:jni/jni.dart" as jni; - -// Auto-generated initialization code. - -final jniEnv = jni.Jni.env; -final jniAccessors = jni.Jni.accessors; diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/com/fasterxml/jackson/core/JsonFactory.dart b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/com/fasterxml/jackson/core/JsonFactory.dart deleted file mode 100644 index 2ceb3242b..000000000 --- a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/com/fasterxml/jackson/core/JsonFactory.dart +++ /dev/null @@ -1,1879 +0,0 @@ -// Generated from jackson-core which is licensed under the Apache License 2.0. -// The following copyright from the original authors applies. -// See https://github.com/FasterXML/jackson-core/blob/2.14/LICENSE -// -// Copyright (c) 2007 - The Jackson Project Authors -// Licensed under the Apache License, Version 2.0 (the "License") -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Autogenerated by jnigen. DO NOT EDIT! - -// ignore_for_file: annotate_overrides -// ignore_for_file: camel_case_extensions -// ignore_for_file: camel_case_types -// ignore_for_file: constant_identifier_names -// ignore_for_file: file_names -// ignore_for_file: no_leading_underscores_for_local_identifiers -// ignore_for_file: non_constant_identifier_names -// ignore_for_file: overridden_fields -// ignore_for_file: unnecessary_cast -// ignore_for_file: unused_element -// ignore_for_file: unused_field -// ignore_for_file: unused_import -// ignore_for_file: unused_shown_name - -import "dart:isolate" show ReceivePort; -import "dart:ffi" as ffi; -import "package:jni/internal_helpers_for_jnigen.dart"; -import "package:jni/jni.dart" as jni; - -import "JsonParser.dart" as jsonparser_; -import "../../../../_init.dart"; - -/// from: com.fasterxml.jackson.core.JsonFactory -/// -/// The main factory class of Jackson package, used to configure and -/// construct reader (aka parser, JsonParser) -/// and writer (aka generator, JsonGenerator) -/// instances. -/// -/// Factory instances are thread-safe and reusable after configuration -/// (if any). Typically applications and services use only a single -/// globally shared factory instance, unless they need differently -/// configured factories. Factory reuse is important if efficiency matters; -/// most recycling of expensive construct is done on per-factory basis. -/// -/// Creation of a factory instance is a light-weight operation, -/// and since there is no need for pluggable alternative implementations -/// (as there is no "standard" JSON processor API to implement), -/// the default constructor is used for constructing factory -/// instances. -///@author Tatu Saloranta -class JsonFactory extends jni.JObject { - @override - late final jni.JObjType $type = type; - - JsonFactory.fromRef( - jni.JObjectPtr ref, - ) : super.fromRef(ref); - - static final _classRef = - jniAccessors.getClassOf(r"com/fasterxml/jackson/core/JsonFactory"); - - /// The type which includes information such as the signature of this class. - static const type = $JsonFactoryType(); - - /// from: static public final java.lang.String FORMAT_NAME_JSON - /// - /// Name used to identify JSON format - /// (and returned by \#getFormatName() - static const FORMAT_NAME_JSON = r"""JSON"""; - - static final _id_DEFAULT_FACTORY_FEATURE_FLAGS = - jniAccessors.getStaticFieldIDOf( - _classRef, - r"DEFAULT_FACTORY_FEATURE_FLAGS", - r"I", - ); - - /// from: static protected final int DEFAULT_FACTORY_FEATURE_FLAGS - /// - /// Bitfield (set of flags) of all factory features that are enabled by default. - static int get DEFAULT_FACTORY_FEATURE_FLAGS => jniAccessors - .getStaticField( - _classRef, _id_DEFAULT_FACTORY_FEATURE_FLAGS, jni.JniCallType.intType) - .integer; - - static final _id_DEFAULT_PARSER_FEATURE_FLAGS = - jniAccessors.getStaticFieldIDOf( - _classRef, - r"DEFAULT_PARSER_FEATURE_FLAGS", - r"I", - ); - - /// from: static protected final int DEFAULT_PARSER_FEATURE_FLAGS - /// - /// Bitfield (set of flags) of all parser features that are enabled - /// by default. - static int get DEFAULT_PARSER_FEATURE_FLAGS => jniAccessors - .getStaticField( - _classRef, _id_DEFAULT_PARSER_FEATURE_FLAGS, jni.JniCallType.intType) - .integer; - - static final _id_DEFAULT_GENERATOR_FEATURE_FLAGS = - jniAccessors.getStaticFieldIDOf( - _classRef, - r"DEFAULT_GENERATOR_FEATURE_FLAGS", - r"I", - ); - - /// from: static protected final int DEFAULT_GENERATOR_FEATURE_FLAGS - /// - /// Bitfield (set of flags) of all generator features that are enabled - /// by default. - static int get DEFAULT_GENERATOR_FEATURE_FLAGS => jniAccessors - .getStaticField(_classRef, _id_DEFAULT_GENERATOR_FEATURE_FLAGS, - jni.JniCallType.intType) - .integer; - - static final _id_DEFAULT_ROOT_VALUE_SEPARATOR = - jniAccessors.getStaticFieldIDOf( - _classRef, - r"DEFAULT_ROOT_VALUE_SEPARATOR", - r"Lcom/fasterxml/jackson/core/SerializableString;", - ); - - /// from: static public final com.fasterxml.jackson.core.SerializableString DEFAULT_ROOT_VALUE_SEPARATOR - /// The returned object must be deleted after use, by calling the `delete` method. - static jni.JObject get DEFAULT_ROOT_VALUE_SEPARATOR => - const jni.JObjectType().fromRef(jniAccessors - .getStaticField(_classRef, _id_DEFAULT_ROOT_VALUE_SEPARATOR, - jni.JniCallType.objectType) - .object); - - static final _id_ctor = - jniAccessors.getMethodIDOf(_classRef, r"", r"()V"); - - /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Default constructor used to create factory instances. - /// Creation of a factory instance is a light-weight operation, - /// but it is still a good idea to reuse limited number of - /// factory instances (and quite often just a single instance): - /// factories are used as context for storing some reused - /// processing objects (such as symbol tables parsers use) - /// and this reuse only works within context of a single - /// factory instance. - factory JsonFactory() { - return JsonFactory.fromRef( - jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); - } - - static final _id_ctor1 = jniAccessors.getMethodIDOf( - _classRef, r"", r"(Lcom/fasterxml/jackson/core/ObjectCodec;)V"); - - /// from: public void (com.fasterxml.jackson.core.ObjectCodec oc) - /// The returned object must be deleted after use, by calling the `delete` method. - factory JsonFactory.ctor1( - jni.JObject oc, - ) { - return JsonFactory.fromRef(jniAccessors - .newObjectWithArgs(_classRef, _id_ctor1, [oc.reference]).object); - } - - static final _id_ctor2 = jniAccessors.getMethodIDOf(_classRef, r"", - r"(Lcom/fasterxml/jackson/core/JsonFactory;Lcom/fasterxml/jackson/core/ObjectCodec;)V"); - - /// from: protected void (com.fasterxml.jackson.core.JsonFactory src, com.fasterxml.jackson.core.ObjectCodec codec) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Constructor used when copy()ing a factory instance. - ///@param src Original factory to copy settings from - ///@param codec Databinding-level codec to use, if any - ///@since 2.2.1 - factory JsonFactory.ctor2( - JsonFactory src, - jni.JObject codec, - ) { - return JsonFactory.fromRef(jniAccessors.newObjectWithArgs( - _classRef, _id_ctor2, [src.reference, codec.reference]).object); - } - - static final _id_ctor3 = jniAccessors.getMethodIDOf(_classRef, r"", - r"(Lcom/fasterxml/jackson/core/JsonFactoryBuilder;)V"); - - /// from: public void (com.fasterxml.jackson.core.JsonFactoryBuilder b) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Constructor used by JsonFactoryBuilder for instantiation. - ///@param b Builder that contains settings to use - ///@since 2.10 - factory JsonFactory.ctor3( - jni.JObject b, - ) { - return JsonFactory.fromRef(jniAccessors - .newObjectWithArgs(_classRef, _id_ctor3, [b.reference]).object); - } - - static final _id_ctor4 = jniAccessors.getMethodIDOf( - _classRef, r"", r"(Lcom/fasterxml/jackson/core/TSFBuilder;Z)V"); - - /// from: protected void (com.fasterxml.jackson.core.TSFBuilder b, boolean bogus) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Constructor for subtypes; needed to work around the fact that before 3.0, - /// this factory has cumbersome dual role as generic type as well as actual - /// implementation for json. - ///@param b Builder that contains settings to use - ///@param bogus Argument only needed to separate constructor signature; ignored - factory JsonFactory.ctor4( - jni.JObject b, - bool bogus, - ) { - return JsonFactory.fromRef(jniAccessors.newObjectWithArgs( - _classRef, _id_ctor4, [b.reference, bogus ? 1 : 0]).object); - } - - static final _id_rebuild = jniAccessors.getMethodIDOf( - _classRef, r"rebuild", r"()Lcom/fasterxml/jackson/core/TSFBuilder;"); - - /// from: public com.fasterxml.jackson.core.TSFBuilder rebuild() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method that allows construction of differently configured factory, starting - /// with settings of this factory. - ///@return Builder instance to use - ///@since 2.10 - jni.JObject rebuild() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_rebuild, jni.JniCallType.objectType, []).object); - } - - static final _id_builder = jniAccessors.getStaticMethodIDOf( - _classRef, r"builder", r"()Lcom/fasterxml/jackson/core/TSFBuilder;"); - - /// from: static public com.fasterxml.jackson.core.TSFBuilder builder() - /// The returned object must be deleted after use, by calling the `delete` 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. - ///@return Builder instance to use - static jni.JObject builder() { - return const jni.JObjectType().fromRef(jniAccessors - .callStaticMethodWithArgs( - _classRef, _id_builder, jni.JniCallType.objectType, []).object); - } - - static final _id_copy = jniAccessors.getMethodIDOf( - _classRef, r"copy", r"()Lcom/fasterxml/jackson/core/JsonFactory;"); - - /// from: public com.fasterxml.jackson.core.JsonFactory copy() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for constructing a new JsonFactory that has - /// the same settings as this instance, but is otherwise - /// independent (i.e. nothing is actually shared, symbol tables - /// are separate). - /// Note that ObjectCodec reference is not copied but is - /// set to null; caller typically needs to set it after calling - /// this method. Reason for this is that the codec is used for - /// callbacks, and assumption is that there is strict 1-to-1 - /// mapping between codec, factory. Caller has to, then, explicitly - /// set codec after making the copy. - ///@return Copy of this factory instance - ///@since 2.1 - JsonFactory copy() { - return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_copy, jni.JniCallType.objectType, []).object); - } - - static final _id_readResolve = jniAccessors.getMethodIDOf( - _classRef, r"readResolve", r"()Ljava/lang/Object;"); - - /// from: protected java.lang.Object readResolve() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method that we need to override to actually make restoration go - /// through constructors etc: needed to allow JDK serializability of - /// factory instances. - /// - /// Note: must be overridden by sub-classes as well. - ///@return Newly constructed instance - jni.JObject readResolve() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_readResolve, jni.JniCallType.objectType, []).object); - } - - static final _id_requiresPropertyOrdering = jniAccessors.getMethodIDOf( - _classRef, r"requiresPropertyOrdering", r"()Z"); - - /// from: public boolean requiresPropertyOrdering() - /// - /// Introspection method that higher-level functionality may call - /// to see whether underlying data format requires a stable ordering - /// of object properties or not. - /// This is usually used for determining - /// whether to force a stable ordering (like alphabetic ordering by name) - /// if no ordering if explicitly specified. - /// - /// Default implementation returns false as JSON does NOT - /// require stable ordering. Formats that require ordering include positional - /// textual formats like CSV, and schema-based binary formats - /// like Avro. - ///@return Whether format supported by this factory - /// requires Object properties to be ordered. - ///@since 2.3 - bool requiresPropertyOrdering() { - return jniAccessors.callMethodWithArgs(reference, - _id_requiresPropertyOrdering, jni.JniCallType.booleanType, []).boolean; - } - - static final _id_canHandleBinaryNatively = - jniAccessors.getMethodIDOf(_classRef, r"canHandleBinaryNatively", r"()Z"); - - /// from: public boolean canHandleBinaryNatively() - /// - /// Introspection method that higher-level functionality may call - /// to see whether underlying data format can read and write binary - /// data natively; that is, embeded it as-is without using encodings - /// such as Base64. - /// - /// Default implementation returns false as JSON does not - /// support native access: all binary content must use Base64 encoding. - /// Most binary formats (like Smile and Avro) support native binary content. - ///@return Whether format supported by this factory - /// supports native binary content - ///@since 2.3 - bool canHandleBinaryNatively() { - return jniAccessors.callMethodWithArgs(reference, - _id_canHandleBinaryNatively, jni.JniCallType.booleanType, []).boolean; - } - - static final _id_canUseCharArrays = - jniAccessors.getMethodIDOf(_classRef, r"canUseCharArrays", r"()Z"); - - /// from: public boolean canUseCharArrays() - /// - /// Introspection method that can be used by base factory to check - /// whether access using char[] is something that actual - /// parser implementations can take advantage of, over having to - /// use java.io.Reader. Sub-types are expected to override - /// definition; default implementation (suitable for JSON) alleges - /// that optimization are possible; and thereby is likely to try - /// to access java.lang.String content by first copying it into - /// recyclable intermediate buffer. - ///@return Whether access to decoded textual content can be efficiently - /// accessed using parser method {@code getTextCharacters()}. - ///@since 2.4 - bool canUseCharArrays() { - return jniAccessors.callMethodWithArgs(reference, _id_canUseCharArrays, - jni.JniCallType.booleanType, []).boolean; - } - - static final _id_canParseAsync = - jniAccessors.getMethodIDOf(_classRef, r"canParseAsync", r"()Z"); - - /// from: public boolean canParseAsync() - /// - /// Introspection method that can be used to check whether this - /// factory can create non-blocking parsers: parsers that do not - /// use blocking I/O abstractions but instead use a - /// com.fasterxml.jackson.core.async.NonBlockingInputFeeder. - ///@return Whether this factory supports non-blocking ("async") parsing or - /// not (and consequently whether {@code createNonBlockingXxx()} method(s) work) - ///@since 2.9 - bool canParseAsync() { - return jniAccessors.callMethodWithArgs( - reference, _id_canParseAsync, jni.JniCallType.booleanType, []).boolean; - } - - static final _id_getFormatReadFeatureType = jniAccessors.getMethodIDOf( - _classRef, r"getFormatReadFeatureType", r"()Ljava/lang/Class;"); - - /// from: public java.lang.Class getFormatReadFeatureType() - /// The returned object must be deleted after use, by calling the `delete` method. - jni.JObject getFormatReadFeatureType() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_getFormatReadFeatureType, - jni.JniCallType.objectType, []).object); - } - - static final _id_getFormatWriteFeatureType = jniAccessors.getMethodIDOf( - _classRef, r"getFormatWriteFeatureType", r"()Ljava/lang/Class;"); - - /// from: public java.lang.Class getFormatWriteFeatureType() - /// The returned object must be deleted after use, by calling the `delete` method. - jni.JObject getFormatWriteFeatureType() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_getFormatWriteFeatureType, - jni.JniCallType.objectType, []).object); - } - - static final _id_canUseSchema = jniAccessors.getMethodIDOf(_classRef, - r"canUseSchema", r"(Lcom/fasterxml/jackson/core/FormatSchema;)Z"); - - /// from: public boolean canUseSchema(com.fasterxml.jackson.core.FormatSchema schema) - /// - /// Method that can be used to quickly check whether given schema - /// is something that parsers and/or generators constructed by this - /// factory could use. Note that this means possible use, at the level - /// of data format (i.e. schema is for same data format as parsers and - /// generators this factory constructs); individual schema instances - /// may have further usage restrictions. - ///@param schema Schema instance to check - ///@return Whether parsers and generators constructed by this factory - /// can use specified format schema instance - bool canUseSchema( - jni.JObject schema, - ) { - return jniAccessors.callMethodWithArgs(reference, _id_canUseSchema, - jni.JniCallType.booleanType, [schema.reference]).boolean; - } - - static final _id_getFormatName = jniAccessors.getMethodIDOf( - _classRef, r"getFormatName", r"()Ljava/lang/String;"); - - /// from: public java.lang.String getFormatName() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method that returns short textual id identifying format - /// this factory supports. - /// - /// Note: sub-classes should override this method; default - /// implementation will return null for all sub-classes - ///@return Name of the format handled by parsers, generators this factory creates - jni.JString getFormatName() { - return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_getFormatName, jni.JniCallType.objectType, []).object); - } - - static final _id_hasFormat = jniAccessors.getMethodIDOf( - _classRef, - r"hasFormat", - r"(Lcom/fasterxml/jackson/core/format/InputAccessor;)Lcom/fasterxml/jackson/core/format/MatchStrength;"); - - /// from: public com.fasterxml.jackson.core.format.MatchStrength hasFormat(com.fasterxml.jackson.core.format.InputAccessor acc) - /// The returned object must be deleted after use, by calling the `delete` method. - jni.JObject hasFormat( - jni.JObject acc, - ) { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_hasFormat, - jni.JniCallType.objectType, - [acc.reference]).object); - } - - static final _id_requiresCustomCodec = - jniAccessors.getMethodIDOf(_classRef, r"requiresCustomCodec", r"()Z"); - - /// from: public boolean requiresCustomCodec() - /// - /// Method that can be called to determine if a custom - /// ObjectCodec is needed for binding data parsed - /// using JsonParser constructed by this factory - /// (which typically also implies the same for serialization - /// with JsonGenerator). - ///@return True if custom codec is needed with parsers and - /// generators created by this factory; false if a general - /// ObjectCodec is enough - ///@since 2.1 - bool requiresCustomCodec() { - return jniAccessors.callMethodWithArgs(reference, _id_requiresCustomCodec, - jni.JniCallType.booleanType, []).boolean; - } - - static final _id_hasJSONFormat = jniAccessors.getMethodIDOf( - _classRef, - r"hasJSONFormat", - r"(Lcom/fasterxml/jackson/core/format/InputAccessor;)Lcom/fasterxml/jackson/core/format/MatchStrength;"); - - /// from: protected com.fasterxml.jackson.core.format.MatchStrength hasJSONFormat(com.fasterxml.jackson.core.format.InputAccessor acc) - /// The returned object must be deleted after use, by calling the `delete` method. - jni.JObject hasJSONFormat( - jni.JObject acc, - ) { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_hasJSONFormat, - jni.JniCallType.objectType, - [acc.reference]).object); - } - - static final _id_version = jniAccessors.getMethodIDOf( - _classRef, r"version", r"()Lcom/fasterxml/jackson/core/Version;"); - - /// from: public com.fasterxml.jackson.core.Version version() - /// The returned object must be deleted after use, by calling the `delete` method. - jni.JObject version() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_version, jni.JniCallType.objectType, []).object); - } - - static final _id_configure = jniAccessors.getMethodIDOf( - _classRef, - r"configure", - r"(Lcom/fasterxml/jackson/core/JsonFactory$Feature;Z)Lcom/fasterxml/jackson/core/JsonFactory;"); - - /// from: public final com.fasterxml.jackson.core.JsonFactory configure(com.fasterxml.jackson.core.JsonFactory.Feature f, boolean state) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for enabling or disabling specified parser feature - /// (check JsonParser.Feature for list of features) - ///@param f Feature to enable/disable - ///@param state Whether to enable or disable the feature - ///@return This factory instance (to allow call chaining) - ///@deprecated since 2.10 use JsonFactoryBuilder\#configure(JsonFactory.Feature, boolean) instead - JsonFactory configure( - JsonFactory_Feature f, - bool state, - ) { - return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_configure, - jni.JniCallType.objectType, - [f.reference, state ? 1 : 0]).object); - } - - static final _id_enable = jniAccessors.getMethodIDOf(_classRef, r"enable", - r"(Lcom/fasterxml/jackson/core/JsonFactory$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); - - /// from: public com.fasterxml.jackson.core.JsonFactory enable(com.fasterxml.jackson.core.JsonFactory.Feature f) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for enabling specified parser feature - /// (check JsonFactory.Feature for list of features) - ///@param f Feature to enable - ///@return This factory instance (to allow call chaining) - ///@deprecated since 2.10 use JsonFactoryBuilder\#configure(JsonFactory.Feature, boolean) instead - JsonFactory enable( - JsonFactory_Feature f, - ) { - return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_enable, - jni.JniCallType.objectType, - [f.reference]).object); - } - - static final _id_disable = jniAccessors.getMethodIDOf(_classRef, r"disable", - r"(Lcom/fasterxml/jackson/core/JsonFactory$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); - - /// from: public com.fasterxml.jackson.core.JsonFactory disable(com.fasterxml.jackson.core.JsonFactory.Feature f) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for disabling specified parser features - /// (check JsonFactory.Feature for list of features) - ///@param f Feature to disable - ///@return This factory instance (to allow call chaining) - ///@deprecated since 2.10 use JsonFactoryBuilder\#configure(JsonFactory.Feature, boolean) instead - JsonFactory disable( - JsonFactory_Feature f, - ) { - return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_disable, - jni.JniCallType.objectType, - [f.reference]).object); - } - - static final _id_isEnabled = jniAccessors.getMethodIDOf(_classRef, - r"isEnabled", r"(Lcom/fasterxml/jackson/core/JsonFactory$Feature;)Z"); - - /// from: public final boolean isEnabled(com.fasterxml.jackson.core.JsonFactory.Feature f) - /// - /// Checked whether specified parser feature is enabled. - ///@param f Feature to check - ///@return True if the specified feature is enabled - bool isEnabled( - JsonFactory_Feature f, - ) { - return jniAccessors.callMethodWithArgs(reference, _id_isEnabled, - jni.JniCallType.booleanType, [f.reference]).boolean; - } - - static final _id_getParserFeatures = - jniAccessors.getMethodIDOf(_classRef, r"getParserFeatures", r"()I"); - - /// from: public final int getParserFeatures() - int getParserFeatures() { - return jniAccessors.callMethodWithArgs( - reference, _id_getParserFeatures, jni.JniCallType.intType, []).integer; - } - - static final _id_getGeneratorFeatures = - jniAccessors.getMethodIDOf(_classRef, r"getGeneratorFeatures", r"()I"); - - /// from: public final int getGeneratorFeatures() - int getGeneratorFeatures() { - return jniAccessors.callMethodWithArgs(reference, _id_getGeneratorFeatures, - jni.JniCallType.intType, []).integer; - } - - static final _id_getFormatParserFeatures = - jniAccessors.getMethodIDOf(_classRef, r"getFormatParserFeatures", r"()I"); - - /// from: public int getFormatParserFeatures() - int getFormatParserFeatures() { - return jniAccessors.callMethodWithArgs(reference, - _id_getFormatParserFeatures, jni.JniCallType.intType, []).integer; - } - - static final _id_getFormatGeneratorFeatures = jniAccessors.getMethodIDOf( - _classRef, r"getFormatGeneratorFeatures", r"()I"); - - /// from: public int getFormatGeneratorFeatures() - int getFormatGeneratorFeatures() { - return jniAccessors.callMethodWithArgs(reference, - _id_getFormatGeneratorFeatures, jni.JniCallType.intType, []).integer; - } - - static final _id_configure1 = jniAccessors.getMethodIDOf( - _classRef, - r"configure", - r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;Z)Lcom/fasterxml/jackson/core/JsonFactory;"); - - /// from: public final com.fasterxml.jackson.core.JsonFactory configure(com.fasterxml.jackson.core.JsonParser.Feature f, boolean state) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for enabling or disabling specified parser feature - /// (check JsonParser.Feature for list of features) - ///@param f Feature to enable/disable - ///@param state Whether to enable or disable the feature - ///@return This factory instance (to allow call chaining) - JsonFactory configure1( - jsonparser_.JsonParser_Feature f, - bool state, - ) { - return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_configure1, - jni.JniCallType.objectType, - [f.reference, state ? 1 : 0]).object); - } - - static final _id_enable1 = jniAccessors.getMethodIDOf(_classRef, r"enable", - r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); - - /// from: public com.fasterxml.jackson.core.JsonFactory enable(com.fasterxml.jackson.core.JsonParser.Feature f) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for enabling specified parser feature - /// (check JsonParser.Feature for list of features) - ///@param f Feature to enable - ///@return This factory instance (to allow call chaining) - JsonFactory enable1( - jsonparser_.JsonParser_Feature f, - ) { - return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_enable1, - jni.JniCallType.objectType, - [f.reference]).object); - } - - static final _id_disable1 = jniAccessors.getMethodIDOf(_classRef, r"disable", - r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); - - /// from: public com.fasterxml.jackson.core.JsonFactory disable(com.fasterxml.jackson.core.JsonParser.Feature f) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for disabling specified parser features - /// (check JsonParser.Feature for list of features) - ///@param f Feature to disable - ///@return This factory instance (to allow call chaining) - JsonFactory disable1( - jsonparser_.JsonParser_Feature f, - ) { - return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_disable1, - jni.JniCallType.objectType, - [f.reference]).object); - } - - static final _id_isEnabled1 = jniAccessors.getMethodIDOf(_classRef, - r"isEnabled", r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Z"); - - /// from: public final boolean isEnabled(com.fasterxml.jackson.core.JsonParser.Feature f) - /// - /// Method for checking if the specified parser feature is enabled. - ///@param f Feature to check - ///@return True if specified feature is enabled - bool isEnabled1( - jsonparser_.JsonParser_Feature f, - ) { - return jniAccessors.callMethodWithArgs(reference, _id_isEnabled1, - jni.JniCallType.booleanType, [f.reference]).boolean; - } - - static final _id_isEnabled2 = jniAccessors.getMethodIDOf(_classRef, - r"isEnabled", r"(Lcom/fasterxml/jackson/core/StreamReadFeature;)Z"); - - /// from: public final boolean isEnabled(com.fasterxml.jackson.core.StreamReadFeature f) - /// - /// Method for checking if the specified stream read feature is enabled. - ///@param f Feature to check - ///@return True if specified feature is enabled - ///@since 2.10 - bool isEnabled2( - jni.JObject f, - ) { - return jniAccessors.callMethodWithArgs(reference, _id_isEnabled2, - jni.JniCallType.booleanType, [f.reference]).boolean; - } - - static final _id_getInputDecorator = jniAccessors.getMethodIDOf( - _classRef, - r"getInputDecorator", - r"()Lcom/fasterxml/jackson/core/io/InputDecorator;"); - - /// from: public com.fasterxml.jackson.core.io.InputDecorator getInputDecorator() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for getting currently configured input decorator (if any; - /// there is no default decorator). - ///@return InputDecorator configured, if any - jni.JObject getInputDecorator() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_getInputDecorator, - jni.JniCallType.objectType, []).object); - } - - static final _id_setInputDecorator = jniAccessors.getMethodIDOf( - _classRef, - r"setInputDecorator", - r"(Lcom/fasterxml/jackson/core/io/InputDecorator;)Lcom/fasterxml/jackson/core/JsonFactory;"); - - /// from: public com.fasterxml.jackson.core.JsonFactory setInputDecorator(com.fasterxml.jackson.core.io.InputDecorator d) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for overriding currently configured input decorator - ///@param d Decorator to configure for this factory, if any ({@code null} if none) - ///@return This factory instance (to allow call chaining) - ///@deprecated Since 2.10 use JsonFactoryBuilder\#inputDecorator(InputDecorator) instead - JsonFactory setInputDecorator( - jni.JObject d, - ) { - return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_setInputDecorator, - jni.JniCallType.objectType, - [d.reference]).object); - } - - static final _id_configure2 = jniAccessors.getMethodIDOf( - _classRef, - r"configure", - r"(Lcom/fasterxml/jackson/core/JsonGenerator$Feature;Z)Lcom/fasterxml/jackson/core/JsonFactory;"); - - /// from: public final com.fasterxml.jackson.core.JsonFactory configure(com.fasterxml.jackson.core.JsonGenerator.Feature f, boolean state) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for enabling or disabling specified generator feature - /// (check JsonGenerator.Feature for list of features) - ///@param f Feature to enable/disable - ///@param state Whether to enable or disable the feature - ///@return This factory instance (to allow call chaining) - JsonFactory configure2( - jni.JObject f, - bool state, - ) { - return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_configure2, - jni.JniCallType.objectType, - [f.reference, state ? 1 : 0]).object); - } - - static final _id_enable2 = jniAccessors.getMethodIDOf(_classRef, r"enable", - r"(Lcom/fasterxml/jackson/core/JsonGenerator$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); - - /// from: public com.fasterxml.jackson.core.JsonFactory enable(com.fasterxml.jackson.core.JsonGenerator.Feature f) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for enabling specified generator features - /// (check JsonGenerator.Feature for list of features) - ///@param f Feature to enable - ///@return This factory instance (to allow call chaining) - JsonFactory enable2( - jni.JObject f, - ) { - return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_enable2, - jni.JniCallType.objectType, - [f.reference]).object); - } - - static final _id_disable2 = jniAccessors.getMethodIDOf(_classRef, r"disable", - r"(Lcom/fasterxml/jackson/core/JsonGenerator$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); - - /// from: public com.fasterxml.jackson.core.JsonFactory disable(com.fasterxml.jackson.core.JsonGenerator.Feature f) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for disabling specified generator feature - /// (check JsonGenerator.Feature for list of features) - ///@param f Feature to disable - ///@return This factory instance (to allow call chaining) - JsonFactory disable2( - jni.JObject f, - ) { - return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_disable2, - jni.JniCallType.objectType, - [f.reference]).object); - } - - static final _id_isEnabled3 = jniAccessors.getMethodIDOf(_classRef, - r"isEnabled", r"(Lcom/fasterxml/jackson/core/JsonGenerator$Feature;)Z"); - - /// from: public final boolean isEnabled(com.fasterxml.jackson.core.JsonGenerator.Feature f) - /// - /// Check whether specified generator feature is enabled. - ///@param f Feature to check - ///@return Whether specified feature is enabled - bool isEnabled3( - jni.JObject f, - ) { - return jniAccessors.callMethodWithArgs(reference, _id_isEnabled3, - jni.JniCallType.booleanType, [f.reference]).boolean; - } - - static final _id_isEnabled4 = jniAccessors.getMethodIDOf(_classRef, - r"isEnabled", r"(Lcom/fasterxml/jackson/core/StreamWriteFeature;)Z"); - - /// from: public final boolean isEnabled(com.fasterxml.jackson.core.StreamWriteFeature f) - /// - /// Check whether specified stream write feature is enabled. - ///@param f Feature to check - ///@return Whether specified feature is enabled - ///@since 2.10 - bool isEnabled4( - jni.JObject f, - ) { - return jniAccessors.callMethodWithArgs(reference, _id_isEnabled4, - jni.JniCallType.booleanType, [f.reference]).boolean; - } - - static final _id_getCharacterEscapes = jniAccessors.getMethodIDOf( - _classRef, - r"getCharacterEscapes", - r"()Lcom/fasterxml/jackson/core/io/CharacterEscapes;"); - - /// from: public com.fasterxml.jackson.core.io.CharacterEscapes getCharacterEscapes() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for accessing custom escapes factory uses for JsonGenerators - /// it creates. - ///@return Configured {@code CharacterEscapes}, if any; {@code null} if none - jni.JObject getCharacterEscapes() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_getCharacterEscapes, - jni.JniCallType.objectType, []).object); - } - - static final _id_setCharacterEscapes = jniAccessors.getMethodIDOf( - _classRef, - r"setCharacterEscapes", - r"(Lcom/fasterxml/jackson/core/io/CharacterEscapes;)Lcom/fasterxml/jackson/core/JsonFactory;"); - - /// from: public com.fasterxml.jackson.core.JsonFactory setCharacterEscapes(com.fasterxml.jackson.core.io.CharacterEscapes esc) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for defining custom escapes factory uses for JsonGenerators - /// it creates. - ///@param esc CharaterEscapes to set (or {@code null} for "none") - ///@return This factory instance (to allow call chaining) - JsonFactory setCharacterEscapes( - jni.JObject esc, - ) { - return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_setCharacterEscapes, - jni.JniCallType.objectType, - [esc.reference]).object); - } - - static final _id_getOutputDecorator = jniAccessors.getMethodIDOf( - _classRef, - r"getOutputDecorator", - r"()Lcom/fasterxml/jackson/core/io/OutputDecorator;"); - - /// from: public com.fasterxml.jackson.core.io.OutputDecorator getOutputDecorator() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for getting currently configured output decorator (if any; - /// there is no default decorator). - ///@return OutputDecorator configured for generators factory creates, if any; - /// {@code null} if none. - jni.JObject getOutputDecorator() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_getOutputDecorator, - jni.JniCallType.objectType, []).object); - } - - static final _id_setOutputDecorator = jniAccessors.getMethodIDOf( - _classRef, - r"setOutputDecorator", - r"(Lcom/fasterxml/jackson/core/io/OutputDecorator;)Lcom/fasterxml/jackson/core/JsonFactory;"); - - /// from: public com.fasterxml.jackson.core.JsonFactory setOutputDecorator(com.fasterxml.jackson.core.io.OutputDecorator d) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for overriding currently configured output decorator - ///@return This factory instance (to allow call chaining) - ///@param d Output decorator to use, if any - ///@deprecated Since 2.10 use JsonFactoryBuilder\#outputDecorator(OutputDecorator) instead - JsonFactory setOutputDecorator( - jni.JObject d, - ) { - return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_setOutputDecorator, - jni.JniCallType.objectType, - [d.reference]).object); - } - - static final _id_setRootValueSeparator = jniAccessors.getMethodIDOf( - _classRef, - r"setRootValueSeparator", - r"(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonFactory;"); - - /// from: public com.fasterxml.jackson.core.JsonFactory setRootValueSeparator(java.lang.String sep) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method that allows overriding String used for separating root-level - /// JSON values (default is single space character) - ///@param sep Separator to use, if any; null means that no separator is - /// automatically added - ///@return This factory instance (to allow call chaining) - JsonFactory setRootValueSeparator( - jni.JString sep, - ) { - return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_setRootValueSeparator, - jni.JniCallType.objectType, - [sep.reference]).object); - } - - static final _id_getRootValueSeparator = jniAccessors.getMethodIDOf( - _classRef, r"getRootValueSeparator", r"()Ljava/lang/String;"); - - /// from: public java.lang.String getRootValueSeparator() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// @return Root value separator configured, if any - jni.JString getRootValueSeparator() { - return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_getRootValueSeparator, - jni.JniCallType.objectType, []).object); - } - - static final _id_setCodec = jniAccessors.getMethodIDOf(_classRef, r"setCodec", - r"(Lcom/fasterxml/jackson/core/ObjectCodec;)Lcom/fasterxml/jackson/core/JsonFactory;"); - - /// from: public com.fasterxml.jackson.core.JsonFactory setCodec(com.fasterxml.jackson.core.ObjectCodec oc) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for associating a ObjectCodec (typically - /// a com.fasterxml.jackson.databind.ObjectMapper) - /// with this factory (and more importantly, parsers and generators - /// it constructs). This is needed to use data-binding methods - /// of JsonParser and JsonGenerator instances. - ///@param oc Codec to use - ///@return This factory instance (to allow call chaining) - JsonFactory setCodec( - jni.JObject oc, - ) { - return const $JsonFactoryType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_setCodec, - jni.JniCallType.objectType, - [oc.reference]).object); - } - - static final _id_getCodec = jniAccessors.getMethodIDOf( - _classRef, r"getCodec", r"()Lcom/fasterxml/jackson/core/ObjectCodec;"); - - /// from: public com.fasterxml.jackson.core.ObjectCodec getCodec() - /// The returned object must be deleted after use, by calling the `delete` method. - jni.JObject getCodec() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_getCodec, jni.JniCallType.objectType, []).object); - } - - static final _id_createParser = jniAccessors.getMethodIDOf( - _classRef, - r"createParser", - r"(Ljava/io/File;)Lcom/fasterxml/jackson/core/JsonParser;"); - - /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.io.File f) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for constructing JSON parser instance to parse - /// contents of specified file. - /// - /// - /// Encoding is auto-detected from contents according to JSON - /// specification recommended mechanism. Json specification - /// supports only UTF-8, UTF-16 and UTF-32 as valid encodings, - /// so auto-detection implemented only for this charsets. - /// For other charsets use \#createParser(java.io.Reader). - /// - /// - /// Underlying input stream (needed for reading contents) - /// will be __owned__ (and managed, i.e. closed as need be) by - /// the parser, since caller has no access to it. - ///@param f File that contains JSON content to parse - ///@since 2.1 - jsonparser_.JsonParser createParser( - jni.JObject f, - ) { - return const jsonparser_.$JsonParserType().fromRef(jniAccessors - .callMethodWithArgs(reference, _id_createParser, - jni.JniCallType.objectType, [f.reference]).object); - } - - static final _id_createParser1 = jniAccessors.getMethodIDOf( - _classRef, - r"createParser", - r"(Ljava/net/URL;)Lcom/fasterxml/jackson/core/JsonParser;"); - - /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.net.URL url) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for constructing JSON parser instance to parse - /// contents of resource reference by given URL. - /// - /// Encoding is auto-detected from contents according to JSON - /// specification recommended mechanism. Json specification - /// supports only UTF-8, UTF-16 and UTF-32 as valid encodings, - /// so auto-detection implemented only for this charsets. - /// For other charsets use \#createParser(java.io.Reader). - /// - /// Underlying input stream (needed for reading contents) - /// will be __owned__ (and managed, i.e. closed as need be) by - /// the parser, since caller has no access to it. - ///@param url URL pointing to resource that contains JSON content to parse - ///@since 2.1 - jsonparser_.JsonParser createParser1( - jni.JObject url, - ) { - return const jsonparser_.$JsonParserType().fromRef(jniAccessors - .callMethodWithArgs(reference, _id_createParser1, - jni.JniCallType.objectType, [url.reference]).object); - } - - static final _id_createParser2 = jniAccessors.getMethodIDOf( - _classRef, - r"createParser", - r"(Ljava/io/InputStream;)Lcom/fasterxml/jackson/core/JsonParser;"); - - /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.io.InputStream in) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for constructing JSON parser instance to parse - /// the contents accessed via specified input stream. - /// - /// The input stream will __not be owned__ by - /// the parser, it will still be managed (i.e. closed if - /// end-of-stream is reacher, or parser close method called) - /// if (and only if) com.fasterxml.jackson.core.StreamReadFeature\#AUTO_CLOSE_SOURCE - /// is enabled. - /// - /// - /// Note: no encoding argument is taken since it can always be - /// auto-detected as suggested by JSON RFC. Json specification - /// supports only UTF-8, UTF-16 and UTF-32 as valid encodings, - /// so auto-detection implemented only for this charsets. - /// For other charsets use \#createParser(java.io.Reader). - ///@param in InputStream to use for reading JSON content to parse - ///@since 2.1 - jsonparser_.JsonParser createParser2( - jni.JObject in0, - ) { - return const jsonparser_.$JsonParserType().fromRef(jniAccessors - .callMethodWithArgs(reference, _id_createParser2, - jni.JniCallType.objectType, [in0.reference]).object); - } - - static final _id_createParser3 = jniAccessors.getMethodIDOf( - _classRef, - r"createParser", - r"(Ljava/io/Reader;)Lcom/fasterxml/jackson/core/JsonParser;"); - - /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.io.Reader r) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for constructing parser for parsing - /// the contents accessed via specified Reader. - /// - /// The read stream will __not be owned__ by - /// the parser, it will still be managed (i.e. closed if - /// end-of-stream is reacher, or parser close method called) - /// if (and only if) com.fasterxml.jackson.core.StreamReadFeature\#AUTO_CLOSE_SOURCE - /// is enabled. - ///@param r Reader to use for reading JSON content to parse - ///@since 2.1 - jsonparser_.JsonParser createParser3( - jni.JObject r, - ) { - return const jsonparser_.$JsonParserType().fromRef(jniAccessors - .callMethodWithArgs(reference, _id_createParser3, - jni.JniCallType.objectType, [r.reference]).object); - } - - static final _id_createParser4 = jniAccessors.getMethodIDOf(_classRef, - r"createParser", r"([B)Lcom/fasterxml/jackson/core/JsonParser;"); - - /// from: public com.fasterxml.jackson.core.JsonParser createParser(byte[] data) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for constructing parser for parsing - /// the contents of given byte array. - ///@since 2.1 - jsonparser_.JsonParser createParser4( - jni.JArray data, - ) { - return const jsonparser_.$JsonParserType().fromRef(jniAccessors - .callMethodWithArgs(reference, _id_createParser4, - jni.JniCallType.objectType, [data.reference]).object); - } - - static final _id_createParser5 = jniAccessors.getMethodIDOf(_classRef, - r"createParser", r"([BII)Lcom/fasterxml/jackson/core/JsonParser;"); - - /// from: public com.fasterxml.jackson.core.JsonParser createParser(byte[] data, int offset, int len) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for constructing parser for parsing - /// the contents of given byte array. - ///@param data Buffer that contains data to parse - ///@param offset Offset of the first data byte within buffer - ///@param len Length of contents to parse within buffer - ///@since 2.1 - jsonparser_.JsonParser createParser5( - jni.JArray data, - int offset, - int len, - ) { - return const jsonparser_.$JsonParserType().fromRef(jniAccessors - .callMethodWithArgs( - reference, _id_createParser5, jni.JniCallType.objectType, [ - data.reference, - jni.JValueInt(offset), - jni.JValueInt(len) - ]).object); - } - - static final _id_createParser6 = jniAccessors.getMethodIDOf( - _classRef, - r"createParser", - r"(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonParser;"); - - /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.lang.String content) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for constructing parser for parsing - /// contents of given String. - ///@since 2.1 - jsonparser_.JsonParser createParser6( - jni.JString content, - ) { - return const jsonparser_.$JsonParserType().fromRef(jniAccessors - .callMethodWithArgs(reference, _id_createParser6, - jni.JniCallType.objectType, [content.reference]).object); - } - - static final _id_createParser7 = jniAccessors.getMethodIDOf(_classRef, - r"createParser", r"([C)Lcom/fasterxml/jackson/core/JsonParser;"); - - /// from: public com.fasterxml.jackson.core.JsonParser createParser(char[] content) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for constructing parser for parsing - /// contents of given char array. - ///@since 2.4 - jsonparser_.JsonParser createParser7( - jni.JArray content, - ) { - return const jsonparser_.$JsonParserType().fromRef(jniAccessors - .callMethodWithArgs(reference, _id_createParser7, - jni.JniCallType.objectType, [content.reference]).object); - } - - static final _id_createParser8 = jniAccessors.getMethodIDOf(_classRef, - r"createParser", r"([CII)Lcom/fasterxml/jackson/core/JsonParser;"); - - /// from: public com.fasterxml.jackson.core.JsonParser createParser(char[] content, int offset, int len) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for constructing parser for parsing contents of given char array. - ///@since 2.4 - jsonparser_.JsonParser createParser8( - jni.JArray content, - int offset, - int len, - ) { - return const jsonparser_.$JsonParserType().fromRef(jniAccessors - .callMethodWithArgs( - reference, _id_createParser8, jni.JniCallType.objectType, [ - content.reference, - jni.JValueInt(offset), - jni.JValueInt(len) - ]).object); - } - - static final _id_createParser9 = jniAccessors.getMethodIDOf( - _classRef, - r"createParser", - r"(Ljava/io/DataInput;)Lcom/fasterxml/jackson/core/JsonParser;"); - - /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.io.DataInput in) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Optional method for constructing parser for reading contents from specified DataInput - /// instance. - /// - /// If this factory does not support DataInput as source, - /// will throw UnsupportedOperationException - ///@since 2.8 - jsonparser_.JsonParser createParser9( - jni.JObject in0, - ) { - return const jsonparser_.$JsonParserType().fromRef(jniAccessors - .callMethodWithArgs(reference, _id_createParser9, - jni.JniCallType.objectType, [in0.reference]).object); - } - - static final _id_createNonBlockingByteArrayParser = - jniAccessors.getMethodIDOf(_classRef, r"createNonBlockingByteArrayParser", - r"()Lcom/fasterxml/jackson/core/JsonParser;"); - - /// from: public com.fasterxml.jackson.core.JsonParser createNonBlockingByteArrayParser() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Optional method for constructing parser for non-blocking parsing - /// via com.fasterxml.jackson.core.async.ByteArrayFeeder - /// interface (accessed using JsonParser\#getNonBlockingInputFeeder() - /// from constructed instance). - /// - /// If this factory does not support non-blocking parsing (either at all, - /// or from byte array), - /// will throw UnsupportedOperationException. - /// - /// Note that JSON-backed factory only supports parsing of UTF-8 encoded JSON content - /// (and US-ASCII since it is proper subset); other encodings are not supported - /// at this point. - ///@since 2.9 - jsonparser_.JsonParser createNonBlockingByteArrayParser() { - return const jsonparser_.$JsonParserType().fromRef(jniAccessors - .callMethodWithArgs(reference, _id_createNonBlockingByteArrayParser, - jni.JniCallType.objectType, []).object); - } - - static final _id_createGenerator = jniAccessors.getMethodIDOf( - _classRef, - r"createGenerator", - r"(Ljava/io/OutputStream;Lcom/fasterxml/jackson/core/JsonEncoding;)Lcom/fasterxml/jackson/core/JsonGenerator;"); - - /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.OutputStream out, com.fasterxml.jackson.core.JsonEncoding enc) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for constructing JSON generator for writing JSON content - /// using specified output stream. - /// Encoding to use must be specified, and needs to be one of available - /// types (as per JSON specification). - /// - /// Underlying stream __is NOT owned__ by the generator constructed, - /// so that generator will NOT close the output stream when - /// JsonGenerator\#close is called (unless auto-closing - /// feature, - /// com.fasterxml.jackson.core.JsonGenerator.Feature\#AUTO_CLOSE_TARGET - /// is enabled). - /// Using application needs to close it explicitly if this is the case. - /// - /// Note: there are formats that use fixed encoding (like most binary data formats) - /// and that ignore passed in encoding. - ///@param out OutputStream to use for writing JSON content - ///@param enc Character encoding to use - ///@since 2.1 - jni.JObject createGenerator( - jni.JObject out, - jni.JObject enc, - ) { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_createGenerator, - jni.JniCallType.objectType, - [out.reference, enc.reference]).object); - } - - static final _id_createGenerator1 = jniAccessors.getMethodIDOf( - _classRef, - r"createGenerator", - r"(Ljava/io/OutputStream;)Lcom/fasterxml/jackson/core/JsonGenerator;"); - - /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.OutputStream out) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Convenience method for constructing generator that uses default - /// encoding of the format (UTF-8 for JSON and most other data formats). - /// - /// Note: there are formats that use fixed encoding (like most binary data formats). - ///@since 2.1 - jni.JObject createGenerator1( - jni.JObject out, - ) { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_createGenerator1, - jni.JniCallType.objectType, - [out.reference]).object); - } - - static final _id_createGenerator2 = jniAccessors.getMethodIDOf( - _classRef, - r"createGenerator", - r"(Ljava/io/Writer;)Lcom/fasterxml/jackson/core/JsonGenerator;"); - - /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.Writer w) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for constructing JSON generator for writing JSON content - /// using specified Writer. - /// - /// Underlying stream __is NOT owned__ by the generator constructed, - /// so that generator will NOT close the Reader when - /// JsonGenerator\#close is called (unless auto-closing - /// feature, - /// com.fasterxml.jackson.core.JsonGenerator.Feature\#AUTO_CLOSE_TARGET is enabled). - /// Using application needs to close it explicitly. - ///@since 2.1 - ///@param w Writer to use for writing JSON content - jni.JObject createGenerator2( - jni.JObject w, - ) { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_createGenerator2, - jni.JniCallType.objectType, - [w.reference]).object); - } - - static final _id_createGenerator3 = jniAccessors.getMethodIDOf( - _classRef, - r"createGenerator", - r"(Ljava/io/File;Lcom/fasterxml/jackson/core/JsonEncoding;)Lcom/fasterxml/jackson/core/JsonGenerator;"); - - /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.File f, com.fasterxml.jackson.core.JsonEncoding enc) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for constructing JSON generator for writing JSON content - /// to specified file, overwriting contents it might have (or creating - /// it if such file does not yet exist). - /// Encoding to use must be specified, and needs to be one of available - /// types (as per JSON specification). - /// - /// Underlying stream __is owned__ by the generator constructed, - /// i.e. generator will handle closing of file when - /// JsonGenerator\#close is called. - ///@param f File to write contents to - ///@param enc Character encoding to use - ///@since 2.1 - jni.JObject createGenerator3( - jni.JObject f, - jni.JObject enc, - ) { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_createGenerator3, - jni.JniCallType.objectType, - [f.reference, enc.reference]).object); - } - - static final _id_createGenerator4 = jniAccessors.getMethodIDOf( - _classRef, - r"createGenerator", - r"(Ljava/io/DataOutput;Lcom/fasterxml/jackson/core/JsonEncoding;)Lcom/fasterxml/jackson/core/JsonGenerator;"); - - /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.DataOutput out, com.fasterxml.jackson.core.JsonEncoding enc) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for constructing generator for writing content using specified - /// DataOutput instance. - ///@since 2.8 - jni.JObject createGenerator4( - jni.JObject out, - jni.JObject enc, - ) { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_createGenerator4, - jni.JniCallType.objectType, - [out.reference, enc.reference]).object); - } - - static final _id_createGenerator5 = jniAccessors.getMethodIDOf( - _classRef, - r"createGenerator", - r"(Ljava/io/DataOutput;)Lcom/fasterxml/jackson/core/JsonGenerator;"); - - /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.DataOutput out) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Convenience method for constructing generator that uses default - /// encoding of the format (UTF-8 for JSON and most other data formats). - /// - /// Note: there are formats that use fixed encoding (like most binary data formats). - ///@since 2.8 - jni.JObject createGenerator5( - jni.JObject out, - ) { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_createGenerator5, - jni.JniCallType.objectType, - [out.reference]).object); - } - - static final _id_createJsonParser = jniAccessors.getMethodIDOf( - _classRef, - r"createJsonParser", - r"(Ljava/io/File;)Lcom/fasterxml/jackson/core/JsonParser;"); - - /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(java.io.File f) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for constructing JSON parser instance to parse - /// contents of specified file. - /// - /// Encoding is auto-detected from contents according to JSON - /// specification recommended mechanism. Json specification - /// supports only UTF-8, UTF-16 and UTF-32 as valid encodings, - /// so auto-detection implemented only for this charsets. - /// For other charsets use \#createParser(java.io.Reader). - /// - /// - /// Underlying input stream (needed for reading contents) - /// will be __owned__ (and managed, i.e. closed as need be) by - /// the parser, since caller has no access to it. - ///@param f File that contains JSON content to parse - ///@return Parser constructed - ///@throws IOException if parser initialization fails due to I/O (read) problem - ///@throws JsonParseException if parser initialization fails due to content decoding problem - ///@deprecated Since 2.2, use \#createParser(File) instead. - jsonparser_.JsonParser createJsonParser( - jni.JObject f, - ) { - return const jsonparser_.$JsonParserType().fromRef(jniAccessors - .callMethodWithArgs(reference, _id_createJsonParser, - jni.JniCallType.objectType, [f.reference]).object); - } - - static final _id_createJsonParser1 = jniAccessors.getMethodIDOf( - _classRef, - r"createJsonParser", - r"(Ljava/net/URL;)Lcom/fasterxml/jackson/core/JsonParser;"); - - /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(java.net.URL url) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for constructing JSON parser instance to parse - /// contents of resource reference by given URL. - /// - /// Encoding is auto-detected from contents according to JSON - /// specification recommended mechanism. Json specification - /// supports only UTF-8, UTF-16 and UTF-32 as valid encodings, - /// so auto-detection implemented only for this charsets. - /// For other charsets use \#createParser(java.io.Reader). - /// - /// Underlying input stream (needed for reading contents) - /// will be __owned__ (and managed, i.e. closed as need be) by - /// the parser, since caller has no access to it. - ///@param url URL pointing to resource that contains JSON content to parse - ///@return Parser constructed - ///@throws IOException if parser initialization fails due to I/O (read) problem - ///@throws JsonParseException if parser initialization fails due to content decoding problem - ///@deprecated Since 2.2, use \#createParser(URL) instead. - jsonparser_.JsonParser createJsonParser1( - jni.JObject url, - ) { - return const jsonparser_.$JsonParserType().fromRef(jniAccessors - .callMethodWithArgs(reference, _id_createJsonParser1, - jni.JniCallType.objectType, [url.reference]).object); - } - - static final _id_createJsonParser2 = jniAccessors.getMethodIDOf( - _classRef, - r"createJsonParser", - r"(Ljava/io/InputStream;)Lcom/fasterxml/jackson/core/JsonParser;"); - - /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(java.io.InputStream in) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for constructing JSON parser instance to parse - /// the contents accessed via specified input stream. - /// - /// The input stream will __not be owned__ by - /// the parser, it will still be managed (i.e. closed if - /// end-of-stream is reacher, or parser close method called) - /// if (and only if) com.fasterxml.jackson.core.JsonParser.Feature\#AUTO_CLOSE_SOURCE - /// is enabled. - /// - /// - /// Note: no encoding argument is taken since it can always be - /// auto-detected as suggested by JSON RFC. Json specification - /// supports only UTF-8, UTF-16 and UTF-32 as valid encodings, - /// so auto-detection implemented only for this charsets. - /// For other charsets use \#createParser(java.io.Reader). - ///@param in InputStream to use for reading JSON content to parse - ///@return Parser constructed - ///@throws IOException if parser initialization fails due to I/O (read) problem - ///@throws JsonParseException if parser initialization fails due to content decoding problem - ///@deprecated Since 2.2, use \#createParser(InputStream) instead. - jsonparser_.JsonParser createJsonParser2( - jni.JObject in0, - ) { - return const jsonparser_.$JsonParserType().fromRef(jniAccessors - .callMethodWithArgs(reference, _id_createJsonParser2, - jni.JniCallType.objectType, [in0.reference]).object); - } - - static final _id_createJsonParser3 = jniAccessors.getMethodIDOf( - _classRef, - r"createJsonParser", - r"(Ljava/io/Reader;)Lcom/fasterxml/jackson/core/JsonParser;"); - - /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(java.io.Reader r) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for constructing parser for parsing - /// the contents accessed via specified Reader. - /// - /// The read stream will __not be owned__ by - /// the parser, it will still be managed (i.e. closed if - /// end-of-stream is reacher, or parser close method called) - /// if (and only if) com.fasterxml.jackson.core.JsonParser.Feature\#AUTO_CLOSE_SOURCE - /// is enabled. - ///@param r Reader to use for reading JSON content to parse - ///@return Parser constructed - ///@throws IOException if parser initialization fails due to I/O (read) problem - ///@throws JsonParseException if parser initialization fails due to content decoding problem - ///@deprecated Since 2.2, use \#createParser(Reader) instead. - jsonparser_.JsonParser createJsonParser3( - jni.JObject r, - ) { - return const jsonparser_.$JsonParserType().fromRef(jniAccessors - .callMethodWithArgs(reference, _id_createJsonParser3, - jni.JniCallType.objectType, [r.reference]).object); - } - - static final _id_createJsonParser4 = jniAccessors.getMethodIDOf(_classRef, - r"createJsonParser", r"([B)Lcom/fasterxml/jackson/core/JsonParser;"); - - /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(byte[] data) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for constructing parser for parsing the contents of given byte array. - ///@param data Input content to parse - ///@return Parser constructed - ///@throws IOException if parser initialization fails due to I/O (read) problem - ///@throws JsonParseException if parser initialization fails due to content decoding problem - ///@deprecated Since 2.2, use \#createParser(byte[]) instead. - jsonparser_.JsonParser createJsonParser4( - jni.JArray data, - ) { - return const jsonparser_.$JsonParserType().fromRef(jniAccessors - .callMethodWithArgs(reference, _id_createJsonParser4, - jni.JniCallType.objectType, [data.reference]).object); - } - - static final _id_createJsonParser5 = jniAccessors.getMethodIDOf(_classRef, - r"createJsonParser", r"([BII)Lcom/fasterxml/jackson/core/JsonParser;"); - - /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(byte[] data, int offset, int len) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for constructing parser for parsing - /// the contents of given byte array. - ///@param data Buffer that contains data to parse - ///@param offset Offset of the first data byte within buffer - ///@param len Length of contents to parse within buffer - ///@return Parser constructed - ///@throws IOException if parser initialization fails due to I/O (read) problem - ///@throws JsonParseException if parser initialization fails due to content decoding problem - ///@deprecated Since 2.2, use \#createParser(byte[],int,int) instead. - jsonparser_.JsonParser createJsonParser5( - jni.JArray data, - int offset, - int len, - ) { - return const jsonparser_.$JsonParserType().fromRef(jniAccessors - .callMethodWithArgs( - reference, _id_createJsonParser5, jni.JniCallType.objectType, [ - data.reference, - jni.JValueInt(offset), - jni.JValueInt(len) - ]).object); - } - - static final _id_createJsonParser6 = jniAccessors.getMethodIDOf( - _classRef, - r"createJsonParser", - r"(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonParser;"); - - /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(java.lang.String content) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for constructing parser for parsing - /// contents of given String. - ///@param content Input content to parse - ///@return Parser constructed - ///@throws IOException if parser initialization fails due to I/O (read) problem - ///@throws JsonParseException if parser initialization fails due to content decoding problem - ///@deprecated Since 2.2, use \#createParser(String) instead. - jsonparser_.JsonParser createJsonParser6( - jni.JString content, - ) { - return const jsonparser_.$JsonParserType().fromRef(jniAccessors - .callMethodWithArgs(reference, _id_createJsonParser6, - jni.JniCallType.objectType, [content.reference]).object); - } - - static final _id_createJsonGenerator = jniAccessors.getMethodIDOf( - _classRef, - r"createJsonGenerator", - r"(Ljava/io/OutputStream;Lcom/fasterxml/jackson/core/JsonEncoding;)Lcom/fasterxml/jackson/core/JsonGenerator;"); - - /// from: public com.fasterxml.jackson.core.JsonGenerator createJsonGenerator(java.io.OutputStream out, com.fasterxml.jackson.core.JsonEncoding enc) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for constructing JSON generator for writing JSON content - /// using specified output stream. - /// Encoding to use must be specified, and needs to be one of available - /// types (as per JSON specification). - /// - /// Underlying stream __is NOT owned__ by the generator constructed, - /// so that generator will NOT close the output stream when - /// JsonGenerator\#close is called (unless auto-closing - /// feature, - /// com.fasterxml.jackson.core.JsonGenerator.Feature\#AUTO_CLOSE_TARGET - /// is enabled). - /// Using application needs to close it explicitly if this is the case. - /// - /// Note: there are formats that use fixed encoding (like most binary data formats) - /// and that ignore passed in encoding. - ///@param out OutputStream to use for writing JSON content - ///@param enc Character encoding to use - ///@return Generator constructed - ///@throws IOException if parser initialization fails due to I/O (write) problem - ///@deprecated Since 2.2, use \#createGenerator(OutputStream, JsonEncoding) instead. - jni.JObject createJsonGenerator( - jni.JObject out, - jni.JObject enc, - ) { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_createJsonGenerator, - jni.JniCallType.objectType, - [out.reference, enc.reference]).object); - } - - static final _id_createJsonGenerator1 = jniAccessors.getMethodIDOf( - _classRef, - r"createJsonGenerator", - r"(Ljava/io/Writer;)Lcom/fasterxml/jackson/core/JsonGenerator;"); - - /// from: public com.fasterxml.jackson.core.JsonGenerator createJsonGenerator(java.io.Writer out) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for constructing JSON generator for writing JSON content - /// using specified Writer. - /// - /// Underlying stream __is NOT owned__ by the generator constructed, - /// so that generator will NOT close the Reader when - /// JsonGenerator\#close is called (unless auto-closing - /// feature, - /// com.fasterxml.jackson.core.JsonGenerator.Feature\#AUTO_CLOSE_TARGET is enabled). - /// Using application needs to close it explicitly. - ///@param out Writer to use for writing JSON content - ///@return Generator constructed - ///@throws IOException if parser initialization fails due to I/O (write) problem - ///@deprecated Since 2.2, use \#createGenerator(Writer) instead. - jni.JObject createJsonGenerator1( - jni.JObject out, - ) { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_createJsonGenerator1, - jni.JniCallType.objectType, - [out.reference]).object); - } - - static final _id_createJsonGenerator2 = jniAccessors.getMethodIDOf( - _classRef, - r"createJsonGenerator", - r"(Ljava/io/OutputStream;)Lcom/fasterxml/jackson/core/JsonGenerator;"); - - /// from: public com.fasterxml.jackson.core.JsonGenerator createJsonGenerator(java.io.OutputStream out) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Convenience method for constructing generator that uses default - /// encoding of the format (UTF-8 for JSON and most other data formats). - /// - /// Note: there are formats that use fixed encoding (like most binary data formats). - ///@param out OutputStream to use for writing JSON content - ///@return Generator constructed - ///@throws IOException if parser initialization fails due to I/O (write) problem - ///@deprecated Since 2.2, use \#createGenerator(OutputStream) instead. - jni.JObject createJsonGenerator2( - jni.JObject out, - ) { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_createJsonGenerator2, - jni.JniCallType.objectType, - [out.reference]).object); - } -} - -class $JsonFactoryType extends jni.JObjType { - const $JsonFactoryType(); - - @override - String get signature => r"Lcom/fasterxml/jackson/core/JsonFactory;"; - - @override - JsonFactory fromRef(jni.JObjectPtr ref) => JsonFactory.fromRef(ref); - - @override - jni.JObjType get superType => const jni.JObjectType(); - - @override - final superCount = 1; - - @override - int get hashCode => ($JsonFactoryType).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JsonFactoryType && other is $JsonFactoryType; - } -} - -/// from: com.fasterxml.jackson.core.JsonFactory$Feature -/// -/// Enumeration that defines all on/off features that can only be -/// changed for JsonFactory. -class JsonFactory_Feature extends jni.JObject { - @override - late final jni.JObjType $type = type; - - JsonFactory_Feature.fromRef( - jni.JObjectPtr ref, - ) : super.fromRef(ref); - - static final _classRef = jniAccessors - .getClassOf(r"com/fasterxml/jackson/core/JsonFactory$Feature"); - - /// The type which includes information such as the signature of this class. - static const type = $JsonFactory_FeatureType(); - static final _id_values = jniAccessors.getStaticMethodIDOf(_classRef, - r"values", r"()[Lcom/fasterxml/jackson/core/JsonFactory$Feature;"); - - /// from: static public com.fasterxml.jackson.core.JsonFactory.Feature[] values() - /// The returned object must be deleted after use, by calling the `delete` method. - static jni.JArray values() { - return const jni.JArrayType($JsonFactory_FeatureType()).fromRef(jniAccessors - .callStaticMethodWithArgs( - _classRef, _id_values, jni.JniCallType.objectType, []).object); - } - - static final _id_valueOf = jniAccessors.getStaticMethodIDOf( - _classRef, - r"valueOf", - r"(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonFactory$Feature;"); - - /// from: static public com.fasterxml.jackson.core.JsonFactory.Feature valueOf(java.lang.String name) - /// The returned object must be deleted after use, by calling the `delete` method. - static JsonFactory_Feature valueOf( - jni.JString name, - ) { - return const $JsonFactory_FeatureType().fromRef(jniAccessors - .callStaticMethodWithArgs(_classRef, _id_valueOf, - jni.JniCallType.objectType, [name.reference]).object); - } - - static final _id_collectDefaults = - jniAccessors.getStaticMethodIDOf(_classRef, r"collectDefaults", r"()I"); - - /// from: static public int collectDefaults() - /// - /// Method that calculates bit set (flags) of all features that - /// are enabled by default. - ///@return Bit field of features enabled by default - static int collectDefaults() { - return jniAccessors.callStaticMethodWithArgs( - _classRef, _id_collectDefaults, jni.JniCallType.intType, []).integer; - } - - static final _id_enabledByDefault = - jniAccessors.getMethodIDOf(_classRef, r"enabledByDefault", r"()Z"); - - /// from: public boolean enabledByDefault() - bool enabledByDefault() { - return jniAccessors.callMethodWithArgs(reference, _id_enabledByDefault, - jni.JniCallType.booleanType, []).boolean; - } - - static final _id_enabledIn = - jniAccessors.getMethodIDOf(_classRef, r"enabledIn", r"(I)Z"); - - /// from: public boolean enabledIn(int flags) - bool enabledIn( - int flags, - ) { - return jniAccessors.callMethodWithArgs(reference, _id_enabledIn, - jni.JniCallType.booleanType, [jni.JValueInt(flags)]).boolean; - } - - static final _id_getMask = - jniAccessors.getMethodIDOf(_classRef, r"getMask", r"()I"); - - /// from: public int getMask() - int getMask() { - return jniAccessors.callMethodWithArgs( - reference, _id_getMask, jni.JniCallType.intType, []).integer; - } -} - -class $JsonFactory_FeatureType extends jni.JObjType { - const $JsonFactory_FeatureType(); - - @override - String get signature => r"Lcom/fasterxml/jackson/core/JsonFactory$Feature;"; - - @override - JsonFactory_Feature fromRef(jni.JObjectPtr ref) => - JsonFactory_Feature.fromRef(ref); - - @override - jni.JObjType get superType => const jni.JObjectType(); - - @override - final superCount = 1; - - @override - int get hashCode => ($JsonFactory_FeatureType).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JsonFactory_FeatureType && - other is $JsonFactory_FeatureType; - } -} diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/com/fasterxml/jackson/core/JsonParser.dart b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/com/fasterxml/jackson/core/JsonParser.dart deleted file mode 100644 index e8caa42e3..000000000 --- a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/com/fasterxml/jackson/core/JsonParser.dart +++ /dev/null @@ -1,2640 +0,0 @@ -// Generated from jackson-core which is licensed under the Apache License 2.0. -// The following copyright from the original authors applies. -// See https://github.com/FasterXML/jackson-core/blob/2.14/LICENSE -// -// Copyright (c) 2007 - The Jackson Project Authors -// Licensed under the Apache License, Version 2.0 (the "License") -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Autogenerated by jnigen. DO NOT EDIT! - -// ignore_for_file: annotate_overrides -// ignore_for_file: camel_case_extensions -// ignore_for_file: camel_case_types -// ignore_for_file: constant_identifier_names -// ignore_for_file: file_names -// ignore_for_file: no_leading_underscores_for_local_identifiers -// ignore_for_file: non_constant_identifier_names -// ignore_for_file: overridden_fields -// ignore_for_file: unnecessary_cast -// ignore_for_file: unused_element -// ignore_for_file: unused_field -// ignore_for_file: unused_import -// ignore_for_file: unused_shown_name - -import "dart:isolate" show ReceivePort; -import "dart:ffi" as ffi; -import "package:jni/internal_helpers_for_jnigen.dart"; -import "package:jni/jni.dart" as jni; - -import "JsonToken.dart" as jsontoken_; -import "../../../../_init.dart"; - -/// from: com.fasterxml.jackson.core.JsonParser -/// -/// Base class that defines public API for reading JSON content. -/// Instances are created using factory methods of -/// a JsonFactory instance. -///@author Tatu Saloranta -class JsonParser extends jni.JObject { - @override - late final jni.JObjType $type = type; - - JsonParser.fromRef( - jni.JObjectPtr ref, - ) : super.fromRef(ref); - - static final _classRef = - jniAccessors.getClassOf(r"com/fasterxml/jackson/core/JsonParser"); - - /// The type which includes information such as the signature of this class. - static const type = $JsonParserType(); - static final _id_DEFAULT_READ_CAPABILITIES = jniAccessors.getStaticFieldIDOf( - _classRef, - r"DEFAULT_READ_CAPABILITIES", - r"Lcom/fasterxml/jackson/core/util/JacksonFeatureSet;", - ); - - /// from: static protected final com.fasterxml.jackson.core.util.JacksonFeatureSet DEFAULT_READ_CAPABILITIES - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Default set of StreamReadCapabilityies that may be used as - /// basis for format-specific readers (or as bogus instance if non-null - /// set needs to be passed). - ///@since 2.12 - static jni.JObject get DEFAULT_READ_CAPABILITIES => - const jni.JObjectType().fromRef(jniAccessors - .getStaticField(_classRef, _id_DEFAULT_READ_CAPABILITIES, - jni.JniCallType.objectType) - .object); - - static final _id_ctor = - jniAccessors.getMethodIDOf(_classRef, r"", r"()V"); - - /// from: protected void () - /// The returned object must be deleted after use, by calling the `delete` method. - factory JsonParser() { - return JsonParser.fromRef( - jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); - } - - static final _id_ctor1 = - jniAccessors.getMethodIDOf(_classRef, r"", r"(I)V"); - - /// from: protected void (int features) - /// The returned object must be deleted after use, by calling the `delete` method. - factory JsonParser.ctor1( - int features, - ) { - return JsonParser.fromRef(jniAccessors.newObjectWithArgs( - _classRef, _id_ctor1, [jni.JValueInt(features)]).object); - } - - static final _id_getCodec = jniAccessors.getMethodIDOf( - _classRef, r"getCodec", r"()Lcom/fasterxml/jackson/core/ObjectCodec;"); - - /// from: public abstract com.fasterxml.jackson.core.ObjectCodec getCodec() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Accessor for ObjectCodec associated with this - /// parser, if any. Codec is used by \#readValueAs(Class) - /// method (and its variants). - ///@return Codec assigned to this parser, if any; {@code null} if none - jni.JObject getCodec() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_getCodec, jni.JniCallType.objectType, []).object); - } - - static final _id_setCodec = jniAccessors.getMethodIDOf( - _classRef, r"setCodec", r"(Lcom/fasterxml/jackson/core/ObjectCodec;)V"); - - /// from: public abstract void setCodec(com.fasterxml.jackson.core.ObjectCodec oc) - /// - /// Setter that allows defining ObjectCodec associated with this - /// parser, if any. Codec is used by \#readValueAs(Class) - /// method (and its variants). - ///@param oc Codec to assign, if any; {@code null} if none - void setCodec( - jni.JObject oc, - ) { - return jniAccessors.callMethodWithArgs(reference, _id_setCodec, - jni.JniCallType.voidType, [oc.reference]).check(); - } - - static final _id_getInputSource = jniAccessors.getMethodIDOf( - _classRef, r"getInputSource", r"()Ljava/lang/Object;"); - - /// from: public java.lang.Object getInputSource() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method that can be used to get access to object that is used - /// to access input being parsed; this is usually either - /// InputStream or Reader, depending on what - /// parser was constructed with. - /// Note that returned value may be null in some cases; including - /// case where parser implementation does not want to exposed raw - /// source to caller. - /// In cases where input has been decorated, object returned here - /// is the decorated version; this allows some level of interaction - /// between users of parser and decorator object. - /// - /// In general use of this accessor should be considered as - /// "last effort", i.e. only used if no other mechanism is applicable. - ///@return Input source this parser was configured with - jni.JObject getInputSource() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_getInputSource, jni.JniCallType.objectType, []).object); - } - - static final _id_setRequestPayloadOnError = jniAccessors.getMethodIDOf( - _classRef, - r"setRequestPayloadOnError", - r"(Lcom/fasterxml/jackson/core/util/RequestPayload;)V"); - - /// from: public void setRequestPayloadOnError(com.fasterxml.jackson.core.util.RequestPayload payload) - /// - /// Sets the payload to be passed if JsonParseException is thrown. - ///@param payload Payload to pass - ///@since 2.8 - void setRequestPayloadOnError( - jni.JObject payload, - ) { - return jniAccessors.callMethodWithArgs( - reference, - _id_setRequestPayloadOnError, - jni.JniCallType.voidType, - [payload.reference]).check(); - } - - static final _id_setRequestPayloadOnError1 = jniAccessors.getMethodIDOf( - _classRef, r"setRequestPayloadOnError", r"([BLjava/lang/String;)V"); - - /// from: public void setRequestPayloadOnError(byte[] payload, java.lang.String charset) - /// - /// Sets the byte[] request payload and the charset - ///@param payload Payload to pass - ///@param charset Character encoding for (lazily) decoding payload - ///@since 2.8 - void setRequestPayloadOnError1( - jni.JArray payload, - jni.JString charset, - ) { - return jniAccessors.callMethodWithArgs( - reference, - _id_setRequestPayloadOnError1, - jni.JniCallType.voidType, - [payload.reference, charset.reference]).check(); - } - - static final _id_setRequestPayloadOnError2 = jniAccessors.getMethodIDOf( - _classRef, r"setRequestPayloadOnError", r"(Ljava/lang/String;)V"); - - /// from: public void setRequestPayloadOnError(java.lang.String payload) - /// - /// Sets the String request payload - ///@param payload Payload to pass - ///@since 2.8 - void setRequestPayloadOnError2( - jni.JString payload, - ) { - return jniAccessors.callMethodWithArgs( - reference, - _id_setRequestPayloadOnError2, - jni.JniCallType.voidType, - [payload.reference]).check(); - } - - static final _id_setSchema = jniAccessors.getMethodIDOf( - _classRef, r"setSchema", r"(Lcom/fasterxml/jackson/core/FormatSchema;)V"); - - /// from: public void setSchema(com.fasterxml.jackson.core.FormatSchema schema) - /// - /// Method to call to make this parser use specified schema. Method must - /// be called before trying to parse any content, right after parser instance - /// has been created. - /// Note that not all parsers support schemas; and those that do usually only - /// accept specific types of schemas: ones defined for data format parser can read. - /// - /// If parser does not support specified schema, UnsupportedOperationException - /// is thrown. - ///@param schema Schema to use - ///@throws UnsupportedOperationException if parser does not support schema - void setSchema( - jni.JObject schema, - ) { - return jniAccessors.callMethodWithArgs(reference, _id_setSchema, - jni.JniCallType.voidType, [schema.reference]).check(); - } - - static final _id_getSchema = jniAccessors.getMethodIDOf( - _classRef, r"getSchema", r"()Lcom/fasterxml/jackson/core/FormatSchema;"); - - /// from: public com.fasterxml.jackson.core.FormatSchema getSchema() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for accessing Schema that this parser uses, if any. - /// Default implementation returns null. - ///@return Schema in use by this parser, if any; {@code null} if none - ///@since 2.1 - jni.JObject getSchema() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_getSchema, jni.JniCallType.objectType, []).object); - } - - static final _id_canUseSchema = jniAccessors.getMethodIDOf(_classRef, - r"canUseSchema", r"(Lcom/fasterxml/jackson/core/FormatSchema;)Z"); - - /// from: public boolean canUseSchema(com.fasterxml.jackson.core.FormatSchema schema) - /// - /// Method that can be used to verify that given schema can be used with - /// this parser (using \#setSchema). - ///@param schema Schema to check - ///@return True if this parser can use given schema; false if not - bool canUseSchema( - jni.JObject schema, - ) { - return jniAccessors.callMethodWithArgs(reference, _id_canUseSchema, - jni.JniCallType.booleanType, [schema.reference]).boolean; - } - - static final _id_requiresCustomCodec = - jniAccessors.getMethodIDOf(_classRef, r"requiresCustomCodec", r"()Z"); - - /// from: public boolean requiresCustomCodec() - /// - /// Method that can be called to determine if a custom - /// ObjectCodec is needed for binding data parsed - /// using JsonParser constructed by this factory - /// (which typically also implies the same for serialization - /// with JsonGenerator). - ///@return True if format-specific codec is needed with this parser; false if a general - /// ObjectCodec is enough - ///@since 2.1 - bool requiresCustomCodec() { - return jniAccessors.callMethodWithArgs(reference, _id_requiresCustomCodec, - jni.JniCallType.booleanType, []).boolean; - } - - static final _id_canParseAsync = - jniAccessors.getMethodIDOf(_classRef, r"canParseAsync", r"()Z"); - - /// from: public boolean canParseAsync() - /// - /// Method that can be called to determine if this parser instance - /// uses non-blocking ("asynchronous") input access for decoding or not. - /// Access mode is determined by earlier calls via JsonFactory; - /// it may not be changed after construction. - /// - /// If non-blocking decoding is (@code true}, it is possible to call - /// \#getNonBlockingInputFeeder() to obtain object to use - /// for feeding input; otherwise (false returned) - /// input is read by blocking - ///@return True if this is a non-blocking ("asynchronous") parser - ///@since 2.9 - bool canParseAsync() { - return jniAccessors.callMethodWithArgs( - reference, _id_canParseAsync, jni.JniCallType.booleanType, []).boolean; - } - - static final _id_getNonBlockingInputFeeder = jniAccessors.getMethodIDOf( - _classRef, - r"getNonBlockingInputFeeder", - r"()Lcom/fasterxml/jackson/core/async/NonBlockingInputFeeder;"); - - /// from: public com.fasterxml.jackson.core.async.NonBlockingInputFeeder getNonBlockingInputFeeder() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method that will either return a feeder instance (if parser uses - /// non-blocking, aka asynchronous access); or null for - /// parsers that use blocking I/O. - ///@return Input feeder to use with non-blocking (async) parsing - ///@since 2.9 - jni.JObject getNonBlockingInputFeeder() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_getNonBlockingInputFeeder, - jni.JniCallType.objectType, []).object); - } - - static final _id_getReadCapabilities = jniAccessors.getMethodIDOf( - _classRef, - r"getReadCapabilities", - r"()Lcom/fasterxml/jackson/core/util/JacksonFeatureSet;"); - - /// from: public com.fasterxml.jackson.core.util.JacksonFeatureSet getReadCapabilities() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Accessor for getting metadata on capabilities of this parser, based on - /// underlying data format being read (directly or indirectly). - ///@return Set of read capabilities for content to read via this parser - ///@since 2.12 - jni.JObject getReadCapabilities() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_getReadCapabilities, - jni.JniCallType.objectType, []).object); - } - - static final _id_version = jniAccessors.getMethodIDOf( - _classRef, r"version", r"()Lcom/fasterxml/jackson/core/Version;"); - - /// from: public abstract com.fasterxml.jackson.core.Version version() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Accessor for getting version of the core package, given a parser instance. - /// Left for sub-classes to implement. - ///@return Version of this generator (derived from version declared for - /// {@code jackson-core} jar that contains the class - jni.JObject version() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_version, jni.JniCallType.objectType, []).object); - } - - static final _id_close = - jniAccessors.getMethodIDOf(_classRef, r"close", r"()V"); - - /// from: public abstract void close() - /// - /// Closes the parser so that no further iteration or data access - /// can be made; will also close the underlying input source - /// if parser either __owns__ the input source, or feature - /// Feature\#AUTO_CLOSE_SOURCE is enabled. - /// Whether parser owns the input source depends on factory - /// method that was used to construct instance (so check - /// com.fasterxml.jackson.core.JsonFactory for details, - /// but the general - /// idea is that if caller passes in closable resource (such - /// as InputStream or Reader) parser does NOT - /// own the source; but if it passes a reference (such as - /// java.io.File or java.net.URL and creates - /// stream or reader it does own them. - ///@throws IOException if there is either an underlying I/O problem - void close() { - return jniAccessors.callMethodWithArgs( - reference, _id_close, jni.JniCallType.voidType, []).check(); - } - - static final _id_isClosed = - jniAccessors.getMethodIDOf(_classRef, r"isClosed", r"()Z"); - - /// from: public abstract boolean isClosed() - /// - /// Method that can be called to determine whether this parser - /// is closed or not. If it is closed, no new tokens can be - /// retrieved by calling \#nextToken (and the underlying - /// stream may be closed). Closing may be due to an explicit - /// call to \#close or because parser has encountered - /// end of input. - ///@return {@code True} if this parser instance has been closed - bool isClosed() { - return jniAccessors.callMethodWithArgs( - reference, _id_isClosed, jni.JniCallType.booleanType, []).boolean; - } - - static final _id_getParsingContext = jniAccessors.getMethodIDOf( - _classRef, - r"getParsingContext", - r"()Lcom/fasterxml/jackson/core/JsonStreamContext;"); - - /// from: public abstract com.fasterxml.jackson.core.JsonStreamContext getParsingContext() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method that can be used to access current parsing context reader - /// is in. There are 3 different types: root, array and object contexts, - /// with slightly different available information. Contexts are - /// hierarchically nested, and can be used for example for figuring - /// out part of the input document that correspond to specific - /// array or object (for highlighting purposes, or error reporting). - /// Contexts can also be used for simple xpath-like matching of - /// input, if so desired. - ///@return Stream input context (JsonStreamContext) associated with this parser - jni.JObject getParsingContext() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_getParsingContext, - jni.JniCallType.objectType, []).object); - } - - static final _id_currentLocation = jniAccessors.getMethodIDOf(_classRef, - r"currentLocation", r"()Lcom/fasterxml/jackson/core/JsonLocation;"); - - /// from: public com.fasterxml.jackson.core.JsonLocation currentLocation() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method that returns location of the last processed input unit (character - /// or byte) from the input; - /// usually for error reporting purposes. - /// - /// Note that the location is not guaranteed to be accurate (although most - /// implementation will try their best): some implementations may only - /// report specific boundary locations (start or end locations of tokens) - /// and others only return JsonLocation\#NA due to not having access - /// to input location information (when delegating actual decoding work - /// to other library) - ///@return Location of the last processed input unit (byte or character) - ///@since 2.13 - jni.JObject currentLocation() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_currentLocation, jni.JniCallType.objectType, []).object); - } - - static final _id_currentTokenLocation = jniAccessors.getMethodIDOf(_classRef, - r"currentTokenLocation", r"()Lcom/fasterxml/jackson/core/JsonLocation;"); - - /// from: public com.fasterxml.jackson.core.JsonLocation currentTokenLocation() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method that return the __starting__ location of the current - /// (most recently returned) - /// token; that is, the position of the first input unit (character or byte) from input - /// that starts the current token. - /// - /// Note that the location is not guaranteed to be accurate (although most - /// implementation will try their best): some implementations may only - /// return JsonLocation\#NA due to not having access - /// to input location information (when delegating actual decoding work - /// to other library) - ///@return Starting location of the token parser currently points to - ///@since 2.13 (will eventually replace \#getTokenLocation) - jni.JObject currentTokenLocation() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_currentTokenLocation, - jni.JniCallType.objectType, []).object); - } - - static final _id_getCurrentLocation = jniAccessors.getMethodIDOf(_classRef, - r"getCurrentLocation", r"()Lcom/fasterxml/jackson/core/JsonLocation;"); - - /// from: public abstract com.fasterxml.jackson.core.JsonLocation getCurrentLocation() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Alias for \#currentLocation(), to be deprecated in later - /// Jackson 2.x versions (and removed from Jackson 3.0). - ///@return Location of the last processed input unit (byte or character) - jni.JObject getCurrentLocation() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_getCurrentLocation, - jni.JniCallType.objectType, []).object); - } - - static final _id_getTokenLocation = jniAccessors.getMethodIDOf(_classRef, - r"getTokenLocation", r"()Lcom/fasterxml/jackson/core/JsonLocation;"); - - /// from: public abstract com.fasterxml.jackson.core.JsonLocation getTokenLocation() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Alias for \#currentTokenLocation(), to be deprecated in later - /// Jackson 2.x versions (and removed from Jackson 3.0). - ///@return Starting location of the token parser currently points to - jni.JObject getTokenLocation() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_getTokenLocation, - jni.JniCallType.objectType, []).object); - } - - static final _id_currentValue = jniAccessors.getMethodIDOf( - _classRef, r"currentValue", r"()Ljava/lang/Object;"); - - /// from: public java.lang.Object currentValue() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Helper method, usually equivalent to: - /// - /// getParsingContext().getCurrentValue(); - /// - /// - /// Note that "current value" is NOT populated (or used) by Streaming parser; - /// it is only used by higher-level data-binding functionality. - /// The reason it is included here is that it can be stored and accessed hierarchically, - /// and gets passed through data-binding. - ///@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 const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_currentValue, jni.JniCallType.objectType, []).object); - } - - static final _id_assignCurrentValue = jniAccessors.getMethodIDOf( - _classRef, r"assignCurrentValue", r"(Ljava/lang/Object;)V"); - - /// from: public void assignCurrentValue(java.lang.Object v) - /// - /// Helper method, usually equivalent to: - /// - /// getParsingContext().setCurrentValue(v); - /// - ///@param v Current value to assign for the current input context of this parser - ///@since 2.13 (added as replacement for older \#setCurrentValue - void assignCurrentValue( - jni.JObject v, - ) { - return jniAccessors.callMethodWithArgs(reference, _id_assignCurrentValue, - jni.JniCallType.voidType, [v.reference]).check(); - } - - static final _id_getCurrentValue = jniAccessors.getMethodIDOf( - _classRef, r"getCurrentValue", r"()Ljava/lang/Object;"); - - /// from: public java.lang.Object getCurrentValue() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Alias for \#currentValue(), to be deprecated in later - /// 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 const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_getCurrentValue, jni.JniCallType.objectType, []).object); - } - - static final _id_setCurrentValue = jniAccessors.getMethodIDOf( - _classRef, r"setCurrentValue", r"(Ljava/lang/Object;)V"); - - /// from: public void setCurrentValue(java.lang.Object v) - /// - /// Alias for \#assignCurrentValue, to be deprecated in later - /// Jackson 2.x versions (and removed from Jackson 3.0). - ///@param v Current value to assign for the current input context of this parser - void setCurrentValue( - jni.JObject v, - ) { - return jniAccessors.callMethodWithArgs(reference, _id_setCurrentValue, - jni.JniCallType.voidType, [v.reference]).check(); - } - - static final _id_releaseBuffered = jniAccessors.getMethodIDOf( - _classRef, r"releaseBuffered", r"(Ljava/io/OutputStream;)I"); - - /// from: public int releaseBuffered(java.io.OutputStream out) - /// - /// Method that can be called to push back any content that - /// has been read but not consumed by the parser. This is usually - /// done after reading all content of interest using parser. - /// Content is released by writing it to given stream if possible; - /// if underlying input is byte-based it can released, if not (char-based) - /// it can not. - ///@param out OutputStream to which buffered, undecoded content is written to - ///@return -1 if the underlying content source is not byte based - /// (that is, input can not be sent to OutputStream; - /// otherwise number of bytes released (0 if there was nothing to release) - ///@throws IOException if write to stream threw exception - int releaseBuffered( - jni.JObject out, - ) { - return jniAccessors.callMethodWithArgs(reference, _id_releaseBuffered, - jni.JniCallType.intType, [out.reference]).integer; - } - - static final _id_releaseBuffered1 = jniAccessors.getMethodIDOf( - _classRef, r"releaseBuffered", r"(Ljava/io/Writer;)I"); - - /// from: public int releaseBuffered(java.io.Writer w) - /// - /// Method that can be called to push back any content that - /// has been read but not consumed by the parser. - /// This is usually - /// done after reading all content of interest using parser. - /// Content is released by writing it to given writer if possible; - /// if underlying input is char-based it can released, if not (byte-based) - /// it can not. - ///@param w Writer to which buffered but unprocessed content is written to - ///@return -1 if the underlying content source is not char-based - /// (that is, input can not be sent to Writer; - /// otherwise number of chars released (0 if there was nothing to release) - ///@throws IOException if write using Writer threw exception - int releaseBuffered1( - jni.JObject w, - ) { - return jniAccessors.callMethodWithArgs(reference, _id_releaseBuffered1, - jni.JniCallType.intType, [w.reference]).integer; - } - - static final _id_enable = jniAccessors.getMethodIDOf(_classRef, r"enable", - r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/core/JsonParser;"); - - /// from: public com.fasterxml.jackson.core.JsonParser enable(com.fasterxml.jackson.core.JsonParser.Feature f) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for enabling specified parser feature - /// (check Feature for list of features) - ///@param f Feature to enable - ///@return This parser, to allow call chaining - JsonParser enable( - JsonParser_Feature f, - ) { - return const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_enable, - jni.JniCallType.objectType, - [f.reference]).object); - } - - static final _id_disable = jniAccessors.getMethodIDOf(_classRef, r"disable", - r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/core/JsonParser;"); - - /// from: public com.fasterxml.jackson.core.JsonParser disable(com.fasterxml.jackson.core.JsonParser.Feature f) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for disabling specified feature - /// (check Feature for list of features) - ///@param f Feature to disable - ///@return This parser, to allow call chaining - JsonParser disable( - JsonParser_Feature f, - ) { - return const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_disable, - jni.JniCallType.objectType, - [f.reference]).object); - } - - static final _id_configure = jniAccessors.getMethodIDOf( - _classRef, - r"configure", - r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;Z)Lcom/fasterxml/jackson/core/JsonParser;"); - - /// from: public com.fasterxml.jackson.core.JsonParser configure(com.fasterxml.jackson.core.JsonParser.Feature f, boolean state) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for enabling or disabling specified feature - /// (check Feature for list of features) - ///@param f Feature to enable or disable - ///@param state Whether to enable feature ({@code true}) or disable ({@code false}) - ///@return This parser, to allow call chaining - JsonParser configure( - JsonParser_Feature f, - bool state, - ) { - return const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_configure, - jni.JniCallType.objectType, - [f.reference, state ? 1 : 0]).object); - } - - static final _id_isEnabled = jniAccessors.getMethodIDOf(_classRef, - r"isEnabled", r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Z"); - - /// from: public boolean isEnabled(com.fasterxml.jackson.core.JsonParser.Feature f) - /// - /// Method for checking whether specified Feature is enabled. - ///@param f Feature to check - ///@return {@code True} if feature is enabled; {@code false} otherwise - bool isEnabled( - JsonParser_Feature f, - ) { - return jniAccessors.callMethodWithArgs(reference, _id_isEnabled, - jni.JniCallType.booleanType, [f.reference]).boolean; - } - - static final _id_isEnabled1 = jniAccessors.getMethodIDOf(_classRef, - r"isEnabled", r"(Lcom/fasterxml/jackson/core/StreamReadFeature;)Z"); - - /// from: public boolean isEnabled(com.fasterxml.jackson.core.StreamReadFeature f) - /// - /// Method for checking whether specified Feature is enabled. - ///@param f Feature to check - ///@return {@code True} if feature is enabled; {@code false} otherwise - ///@since 2.10 - bool isEnabled1( - jni.JObject f, - ) { - return jniAccessors.callMethodWithArgs(reference, _id_isEnabled1, - jni.JniCallType.booleanType, [f.reference]).boolean; - } - - static final _id_getFeatureMask = - jniAccessors.getMethodIDOf(_classRef, r"getFeatureMask", r"()I"); - - /// from: public int getFeatureMask() - /// - /// Bulk access method for getting state of all standard Features. - ///@return Bit mask that defines current states of all standard Features. - ///@since 2.3 - int getFeatureMask() { - return jniAccessors.callMethodWithArgs( - reference, _id_getFeatureMask, jni.JniCallType.intType, []).integer; - } - - static final _id_setFeatureMask = jniAccessors.getMethodIDOf(_classRef, - r"setFeatureMask", r"(I)Lcom/fasterxml/jackson/core/JsonParser;"); - - /// from: public com.fasterxml.jackson.core.JsonParser setFeatureMask(int mask) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Bulk set method for (re)setting states of all standard Features - ///@param mask Bit mask that defines set of features to enable - ///@return This parser, to allow call chaining - ///@since 2.3 - ///@deprecated Since 2.7, use \#overrideStdFeatures(int, int) instead - JsonParser setFeatureMask( - int mask, - ) { - return const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_setFeatureMask, - jni.JniCallType.objectType, - [jni.JValueInt(mask)]).object); - } - - static final _id_overrideStdFeatures = jniAccessors.getMethodIDOf(_classRef, - r"overrideStdFeatures", r"(II)Lcom/fasterxml/jackson/core/JsonParser;"); - - /// from: public com.fasterxml.jackson.core.JsonParser overrideStdFeatures(int values, int mask) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Bulk set method for (re)setting states of features specified by mask. - /// Functionally equivalent to - /// - /// int oldState = getFeatureMask(); - /// int newState = (oldState & ~mask) | (values & mask); - /// setFeatureMask(newState); - /// - /// but preferred as this lets caller more efficiently specify actual changes made. - ///@param values Bit mask of set/clear state for features to change - ///@param mask Bit mask of features to change - ///@return This parser, to allow call chaining - ///@since 2.6 - JsonParser overrideStdFeatures( - int values, - int mask, - ) { - return const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_overrideStdFeatures, - jni.JniCallType.objectType, - [jni.JValueInt(values), jni.JValueInt(mask)]).object); - } - - static final _id_getFormatFeatures = - jniAccessors.getMethodIDOf(_classRef, r"getFormatFeatures", r"()I"); - - /// from: public int getFormatFeatures() - /// - /// Bulk access method for getting state of all FormatFeatures, format-specific - /// on/off configuration settings. - ///@return Bit mask that defines current states of all standard FormatFeatures. - ///@since 2.6 - int getFormatFeatures() { - return jniAccessors.callMethodWithArgs( - reference, _id_getFormatFeatures, jni.JniCallType.intType, []).integer; - } - - static final _id_overrideFormatFeatures = jniAccessors.getMethodIDOf( - _classRef, - r"overrideFormatFeatures", - r"(II)Lcom/fasterxml/jackson/core/JsonParser;"); - - /// from: public com.fasterxml.jackson.core.JsonParser overrideFormatFeatures(int values, int mask) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Bulk set method for (re)setting states of FormatFeatures, - /// by specifying values (set / clear) along with a mask, to determine - /// which features to change, if any. - /// - /// Default implementation will simply throw an exception to indicate that - /// the parser implementation does not support any FormatFeatures. - ///@param values Bit mask of set/clear state for features to change - ///@param mask Bit mask of features to change - ///@return This parser, to allow call chaining - ///@since 2.6 - JsonParser overrideFormatFeatures( - int values, - int mask, - ) { - return const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_overrideFormatFeatures, - jni.JniCallType.objectType, - [jni.JValueInt(values), jni.JValueInt(mask)]).object); - } - - static final _id_nextToken = jniAccessors.getMethodIDOf( - _classRef, r"nextToken", r"()Lcom/fasterxml/jackson/core/JsonToken;"); - - /// from: public abstract com.fasterxml.jackson.core.JsonToken nextToken() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Main iteration method, which will advance stream enough - /// to determine type of the next token, if any. If none - /// remaining (stream has no content other than possible - /// white space before ending), null will be returned. - ///@return Next token from the stream, if any found, or null - /// to indicate end-of-input - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - jsontoken_.JsonToken nextToken() { - return const jsontoken_.$JsonTokenType().fromRef(jniAccessors - .callMethodWithArgs( - reference, _id_nextToken, jni.JniCallType.objectType, []).object); - } - - static final _id_nextValue = jniAccessors.getMethodIDOf( - _classRef, r"nextValue", r"()Lcom/fasterxml/jackson/core/JsonToken;"); - - /// from: public abstract com.fasterxml.jackson.core.JsonToken nextValue() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Iteration method that will advance stream enough - /// to determine type of the next token that is a value type - /// (including JSON Array and Object start/end markers). - /// Or put another way, nextToken() will be called once, - /// and if JsonToken\#FIELD_NAME is returned, another - /// time to get the value for the field. - /// Method is most useful for iterating over value entries - /// of JSON objects; field name will still be available - /// by calling \#getCurrentName when parser points to - /// the value. - ///@return Next non-field-name token from the stream, if any found, - /// or null to indicate end-of-input (or, for non-blocking - /// parsers, JsonToken\#NOT_AVAILABLE if no tokens were - /// available yet) - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - jsontoken_.JsonToken nextValue() { - return const jsontoken_.$JsonTokenType().fromRef(jniAccessors - .callMethodWithArgs( - reference, _id_nextValue, jni.JniCallType.objectType, []).object); - } - - static final _id_nextFieldName = jniAccessors.getMethodIDOf(_classRef, - r"nextFieldName", r"(Lcom/fasterxml/jackson/core/SerializableString;)Z"); - - /// from: public boolean nextFieldName(com.fasterxml.jackson.core.SerializableString str) - /// - /// Method that fetches next token (as if calling \#nextToken) and - /// verifies whether it is JsonToken\#FIELD_NAME with specified name - /// and returns result of that comparison. - /// It is functionally equivalent to: - ///

    -  ///  return (nextToken() == JsonToken.FIELD_NAME) && str.getValue().equals(getCurrentName());
    -  ///
    - /// but may be faster for parser to verify, and can therefore be used if caller - /// expects to get such a property name from input next. - ///@param str Property name to compare next token to (if next token is - /// JsonToken.FIELD_NAME) - ///@return {@code True} if parser advanced to {@code JsonToken.FIELD_NAME} with - /// specified name; {@code false} otherwise (different token or non-matching name) - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - bool nextFieldName( - jni.JObject str, - ) { - return jniAccessors.callMethodWithArgs(reference, _id_nextFieldName, - jni.JniCallType.booleanType, [str.reference]).boolean; - } - - static final _id_nextFieldName1 = jniAccessors.getMethodIDOf( - _classRef, r"nextFieldName", r"()Ljava/lang/String;"); - - /// from: public java.lang.String nextFieldName() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method that fetches next token (as if calling \#nextToken) and - /// verifies whether it is JsonToken\#FIELD_NAME; if it is, - /// returns same as \#getCurrentName(), otherwise null. - ///@return Name of the the {@code JsonToken.FIELD_NAME} parser advanced to, if any; - /// {@code null} if next token is of some other type - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - ///@since 2.5 - jni.JString nextFieldName1() { - return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_nextFieldName1, jni.JniCallType.objectType, []).object); - } - - static final _id_nextTextValue = jniAccessors.getMethodIDOf( - _classRef, r"nextTextValue", r"()Ljava/lang/String;"); - - /// from: public java.lang.String nextTextValue() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method that fetches next token (as if calling \#nextToken) and - /// if it is JsonToken\#VALUE_STRING returns contained String value; - /// otherwise returns null. - /// It is functionally equivalent to: - ///
    -  ///  return (nextToken() == JsonToken.VALUE_STRING) ? getText() : null;
    -  ///
    - /// but may be faster for parser to process, and can therefore be used if caller - /// expects to get a String value next from input. - ///@return Text value of the {@code JsonToken.VALUE_STRING} token parser advanced - /// to; or {@code null} if next token is of some other type - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - jni.JString nextTextValue() { - return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_nextTextValue, jni.JniCallType.objectType, []).object); - } - - static final _id_nextIntValue = - jniAccessors.getMethodIDOf(_classRef, r"nextIntValue", r"(I)I"); - - /// from: public int nextIntValue(int defaultValue) - /// - /// Method that fetches next token (as if calling \#nextToken) and - /// if it is JsonToken\#VALUE_NUMBER_INT returns 32-bit int value; - /// otherwise returns specified default value - /// It is functionally equivalent to: - ///
    -  ///  return (nextToken() == JsonToken.VALUE_NUMBER_INT) ? getIntValue() : defaultValue;
    -  ///
    - /// but may be faster for parser to process, and can therefore be used if caller - /// expects to get an int value next from input. - /// - /// NOTE: value checks are performed similar to \#getIntValue() - ///@param defaultValue Value to return if next token is NOT of type {@code JsonToken.VALUE_NUMBER_INT} - ///@return Integer ({@code int}) value of the {@code JsonToken.VALUE_NUMBER_INT} token parser advanced - /// to; or {@code defaultValue} if next token is of some other type - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - ///@throws InputCoercionException if integer number does not fit in Java {@code int} - int nextIntValue( - int defaultValue, - ) { - return jniAccessors.callMethodWithArgs(reference, _id_nextIntValue, - jni.JniCallType.intType, [jni.JValueInt(defaultValue)]).integer; - } - - static final _id_nextLongValue = - jniAccessors.getMethodIDOf(_classRef, r"nextLongValue", r"(J)J"); - - /// from: public long nextLongValue(long defaultValue) - /// - /// Method that fetches next token (as if calling \#nextToken) and - /// if it is JsonToken\#VALUE_NUMBER_INT returns 64-bit long value; - /// otherwise returns specified default value - /// It is functionally equivalent to: - ///
    -  ///  return (nextToken() == JsonToken.VALUE_NUMBER_INT) ? getLongValue() : defaultValue;
    -  ///
    - /// but may be faster for parser to process, and can therefore be used if caller - /// expects to get a long value next from input. - /// - /// NOTE: value checks are performed similar to \#getLongValue() - ///@param defaultValue Value to return if next token is NOT of type {@code JsonToken.VALUE_NUMBER_INT} - ///@return {@code long} value of the {@code JsonToken.VALUE_NUMBER_INT} token parser advanced - /// to; or {@code defaultValue} if next token is of some other type - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - ///@throws InputCoercionException if integer number does not fit in Java {@code long} - int nextLongValue( - int defaultValue, - ) { - return jniAccessors.callMethodWithArgs(reference, _id_nextLongValue, - jni.JniCallType.longType, [defaultValue]).long; - } - - static final _id_nextBooleanValue = jniAccessors.getMethodIDOf( - _classRef, r"nextBooleanValue", r"()Ljava/lang/Boolean;"); - - /// from: public java.lang.Boolean nextBooleanValue() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method that fetches next token (as if calling \#nextToken) and - /// if it is JsonToken\#VALUE_TRUE or JsonToken\#VALUE_FALSE - /// returns matching Boolean value; otherwise return null. - /// It is functionally equivalent to: - ///
    -  ///  JsonToken t = nextToken();
    -  ///  if (t == JsonToken.VALUE_TRUE) return Boolean.TRUE;
    -  ///  if (t == JsonToken.VALUE_FALSE) return Boolean.FALSE;
    -  ///  return null;
    -  ///
    - /// but may be faster for parser to process, and can therefore be used if caller - /// expects to get a Boolean value next from input. - ///@return {@code Boolean} value of the {@code JsonToken.VALUE_TRUE} or {@code JsonToken.VALUE_FALSE} - /// token parser advanced to; or {@code null} if next token is of some other type - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - jni.JObject nextBooleanValue() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_nextBooleanValue, - jni.JniCallType.objectType, []).object); - } - - static final _id_skipChildren = jniAccessors.getMethodIDOf( - _classRef, r"skipChildren", r"()Lcom/fasterxml/jackson/core/JsonParser;"); - - /// from: public abstract com.fasterxml.jackson.core.JsonParser skipChildren() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method that will skip all child tokens of an array or - /// object token that the parser currently points to, - /// iff stream points to - /// JsonToken\#START_OBJECT or JsonToken\#START_ARRAY. - /// If not, it will do nothing. - /// After skipping, stream will point to __matching__ - /// JsonToken\#END_OBJECT or JsonToken\#END_ARRAY - /// (possibly skipping nested pairs of START/END OBJECT/ARRAY tokens - /// as well as value tokens). - /// The idea is that after calling this method, application - /// will call \#nextToken to point to the next - /// available token, if any. - ///@return This parser, to allow call chaining - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - JsonParser skipChildren() { - return const $JsonParserType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_skipChildren, jni.JniCallType.objectType, []).object); - } - - static final _id_finishToken = - jniAccessors.getMethodIDOf(_classRef, r"finishToken", r"()V"); - - /// from: public void finishToken() - /// - /// Method that may be used to force full handling of the current token - /// so that even if lazy processing is enabled, the whole contents are - /// read for possible retrieval. This is usually used to ensure that - /// the token end location is available, as well as token contents - /// (similar to what calling, say \#getTextCharacters(), would - /// achieve). - /// - /// Note that for many dataformat implementations this method - /// will not do anything; this is the default implementation unless - /// overridden by sub-classes. - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - ///@since 2.8 - void finishToken() { - return jniAccessors.callMethodWithArgs( - reference, _id_finishToken, jni.JniCallType.voidType, []).check(); - } - - static final _id_currentToken = jniAccessors.getMethodIDOf( - _classRef, r"currentToken", r"()Lcom/fasterxml/jackson/core/JsonToken;"); - - /// from: public com.fasterxml.jackson.core.JsonToken currentToken() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Accessor to find which token parser currently points to, if any; - /// null will be returned if none. - /// If return value is non-null, data associated with the token - /// is available via other accessor methods. - ///@return Type of the token this parser currently points to, - /// if any: null before any tokens have been read, and - /// after end-of-input has been encountered, as well as - /// if the current token has been explicitly cleared. - ///@since 2.8 - jsontoken_.JsonToken currentToken() { - return const jsontoken_.$JsonTokenType().fromRef(jniAccessors - .callMethodWithArgs(reference, _id_currentToken, - jni.JniCallType.objectType, []).object); - } - - static final _id_currentTokenId = - jniAccessors.getMethodIDOf(_classRef, r"currentTokenId", r"()I"); - - /// from: public int currentTokenId() - /// - /// Method similar to \#getCurrentToken() but that returns an - /// int instead of JsonToken (enum value). - /// - /// Use of int directly is typically more efficient on switch statements, - /// so this method may be useful when building low-overhead codecs. - /// Note, however, that effect may not be big enough to matter: make sure - /// to profile performance before deciding to use this method. - ///@since 2.8 - ///@return {@code int} matching one of constants from JsonTokenId. - int currentTokenId() { - return jniAccessors.callMethodWithArgs( - reference, _id_currentTokenId, jni.JniCallType.intType, []).integer; - } - - static final _id_getCurrentToken = jniAccessors.getMethodIDOf(_classRef, - r"getCurrentToken", r"()Lcom/fasterxml/jackson/core/JsonToken;"); - - /// from: public abstract com.fasterxml.jackson.core.JsonToken getCurrentToken() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Alias for \#currentToken(), may be deprecated sometime after - /// Jackson 2.13 (will be removed from 3.0). - ///@return Type of the token this parser currently points to, - /// if any: null before any tokens have been read, and - jsontoken_.JsonToken getCurrentToken() { - return const jsontoken_.$JsonTokenType().fromRef(jniAccessors - .callMethodWithArgs(reference, _id_getCurrentToken, - jni.JniCallType.objectType, []).object); - } - - static final _id_getCurrentTokenId = - jniAccessors.getMethodIDOf(_classRef, r"getCurrentTokenId", r"()I"); - - /// from: public abstract int getCurrentTokenId() - /// - /// Deprecated alias for \#currentTokenId(). - ///@return {@code int} matching one of constants from JsonTokenId. - ///@deprecated Since 2.12 use \#currentTokenId instead - int getCurrentTokenId() { - return jniAccessors.callMethodWithArgs( - reference, _id_getCurrentTokenId, jni.JniCallType.intType, []).integer; - } - - static final _id_hasCurrentToken = - jniAccessors.getMethodIDOf(_classRef, r"hasCurrentToken", r"()Z"); - - /// from: public abstract boolean hasCurrentToken() - /// - /// Method for checking whether parser currently points to - /// a token (and data for that token is available). - /// Equivalent to check for parser.getCurrentToken() != null. - ///@return True if the parser just returned a valid - /// token via \#nextToken; false otherwise (parser - /// was just constructed, encountered end-of-input - /// and returned null from \#nextToken, or the token - /// has been consumed) - bool hasCurrentToken() { - return jniAccessors.callMethodWithArgs(reference, _id_hasCurrentToken, - jni.JniCallType.booleanType, []).boolean; - } - - static final _id_hasTokenId = - jniAccessors.getMethodIDOf(_classRef, r"hasTokenId", r"(I)Z"); - - /// from: public abstract boolean hasTokenId(int id) - /// - /// Method that is functionally equivalent to: - /// - /// return currentTokenId() == id - /// - /// but may be more efficiently implemented. - /// - /// Note that no traversal or conversion is performed; so in some - /// cases calling method like \#isExpectedStartArrayToken() - /// is necessary instead. - ///@param id Token id to match (from (@link JsonTokenId}) - ///@return {@code True} if the parser current points to specified token - ///@since 2.5 - bool hasTokenId( - int id, - ) { - return jniAccessors.callMethodWithArgs(reference, _id_hasTokenId, - jni.JniCallType.booleanType, [jni.JValueInt(id)]).boolean; - } - - static final _id_hasToken = jniAccessors.getMethodIDOf( - _classRef, r"hasToken", r"(Lcom/fasterxml/jackson/core/JsonToken;)Z"); - - /// from: public abstract boolean hasToken(com.fasterxml.jackson.core.JsonToken t) - /// - /// Method that is functionally equivalent to: - /// - /// return currentToken() == t - /// - /// but may be more efficiently implemented. - /// - /// Note that no traversal or conversion is performed; so in some - /// cases calling method like \#isExpectedStartArrayToken() - /// is necessary instead. - ///@param t Token to match - ///@return {@code True} if the parser current points to specified token - ///@since 2.6 - bool hasToken( - jsontoken_.JsonToken t, - ) { - return jniAccessors.callMethodWithArgs(reference, _id_hasToken, - jni.JniCallType.booleanType, [t.reference]).boolean; - } - - static final _id_isExpectedStartArrayToken = jniAccessors.getMethodIDOf( - _classRef, r"isExpectedStartArrayToken", r"()Z"); - - /// from: public boolean isExpectedStartArrayToken() - /// - /// Specialized accessor that can be used to verify that the current - /// token indicates start array (usually meaning that current token - /// is JsonToken\#START_ARRAY) when start array is expected. - /// For some specialized parsers this can return true for other cases - /// as well; this is usually done to emulate arrays in cases underlying - /// format is ambiguous (XML, for example, has no format-level difference - /// between Objects and Arrays; it just has elements). - /// - /// Default implementation is equivalent to: - ///
    -  ///   currentToken() == JsonToken.START_ARRAY
    -  ///
    - /// but may be overridden by custom parser implementations. - ///@return True if the current token can be considered as a - /// start-array marker (such JsonToken\#START_ARRAY); - /// {@code false} if not - bool isExpectedStartArrayToken() { - return jniAccessors.callMethodWithArgs(reference, - _id_isExpectedStartArrayToken, jni.JniCallType.booleanType, []).boolean; - } - - static final _id_isExpectedStartObjectToken = jniAccessors.getMethodIDOf( - _classRef, r"isExpectedStartObjectToken", r"()Z"); - - /// from: public boolean isExpectedStartObjectToken() - /// - /// Similar to \#isExpectedStartArrayToken(), but checks whether stream - /// currently points to JsonToken\#START_OBJECT. - ///@return True if the current token can be considered as a - /// start-array marker (such JsonToken\#START_OBJECT); - /// {@code false} if not - ///@since 2.5 - bool isExpectedStartObjectToken() { - return jniAccessors.callMethodWithArgs( - reference, - _id_isExpectedStartObjectToken, - jni.JniCallType.booleanType, []).boolean; - } - - static final _id_isExpectedNumberIntToken = jniAccessors.getMethodIDOf( - _classRef, r"isExpectedNumberIntToken", r"()Z"); - - /// from: public boolean isExpectedNumberIntToken() - /// - /// Similar to \#isExpectedStartArrayToken(), but checks whether stream - /// currently points to JsonToken\#VALUE_NUMBER_INT. - /// - /// The initial use case is for XML backend to efficiently (attempt to) coerce - /// textual content into numbers. - ///@return True if the current token can be considered as a - /// start-array marker (such JsonToken\#VALUE_NUMBER_INT); - /// {@code false} if not - ///@since 2.12 - bool isExpectedNumberIntToken() { - return jniAccessors.callMethodWithArgs(reference, - _id_isExpectedNumberIntToken, jni.JniCallType.booleanType, []).boolean; - } - - static final _id_isNaN = - jniAccessors.getMethodIDOf(_classRef, r"isNaN", r"()Z"); - - /// from: public boolean isNaN() - /// - /// Access for checking whether current token is a numeric value token, but - /// one that is of "not-a-number" (NaN) variety (including both "NaN" AND - /// positive/negative infinity!): not supported by all formats, - /// but often supported for JsonToken\#VALUE_NUMBER_FLOAT. - /// NOTE: roughly equivalent to calling !Double.isFinite() - /// on value you would get from calling \#getDoubleValue(). - ///@return {@code True} if the current token is of type JsonToken\#VALUE_NUMBER_FLOAT - /// but represents a "Not a Number"; {@code false} for other tokens and regular - /// floating-point numbers - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - ///@since 2.9 - bool isNaN() { - return jniAccessors.callMethodWithArgs( - reference, _id_isNaN, jni.JniCallType.booleanType, []).boolean; - } - - static final _id_clearCurrentToken = - jniAccessors.getMethodIDOf(_classRef, r"clearCurrentToken", r"()V"); - - /// from: public abstract void clearCurrentToken() - /// - /// Method called to "consume" the current token by effectively - /// removing it so that \#hasCurrentToken returns false, and - /// \#getCurrentToken null). - /// Cleared token value can still be accessed by calling - /// \#getLastClearedToken (if absolutely needed), but - /// usually isn't. - /// - /// Method was added to be used by the optional data binder, since - /// it has to be able to consume last token used for binding (so that - /// it will not be used again). - void clearCurrentToken() { - return jniAccessors.callMethodWithArgs( - reference, _id_clearCurrentToken, jni.JniCallType.voidType, []).check(); - } - - static final _id_getLastClearedToken = jniAccessors.getMethodIDOf(_classRef, - r"getLastClearedToken", r"()Lcom/fasterxml/jackson/core/JsonToken;"); - - /// from: public abstract com.fasterxml.jackson.core.JsonToken getLastClearedToken() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method that can be called to get the last token that was - /// cleared using \#clearCurrentToken. This is not necessarily - /// the latest token read. - /// Will return null if no tokens have been cleared, - /// or if parser has been closed. - ///@return Last cleared token, if any; {@code null} otherwise - jsontoken_.JsonToken getLastClearedToken() { - return const jsontoken_.$JsonTokenType().fromRef(jniAccessors - .callMethodWithArgs(reference, _id_getLastClearedToken, - jni.JniCallType.objectType, []).object); - } - - static final _id_overrideCurrentName = jniAccessors.getMethodIDOf( - _classRef, r"overrideCurrentName", r"(Ljava/lang/String;)V"); - - /// from: public abstract void overrideCurrentName(java.lang.String name) - /// - /// Method that can be used to change what is considered to be - /// the current (field) name. - /// May be needed to support non-JSON data formats or unusual binding - /// conventions; not needed for typical processing. - /// - /// Note that use of this method should only be done as sort of last - /// resort, as it is a work-around for regular operation. - ///@param name Name to use as the current name; may be null. - void overrideCurrentName( - jni.JString name, - ) { - return jniAccessors.callMethodWithArgs(reference, _id_overrideCurrentName, - jni.JniCallType.voidType, [name.reference]).check(); - } - - static final _id_getCurrentName = jniAccessors.getMethodIDOf( - _classRef, r"getCurrentName", r"()Ljava/lang/String;"); - - /// from: public abstract java.lang.String getCurrentName() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Alias of \#currentName(). - ///@return Name of the current field in the parsing context - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - jni.JString getCurrentName() { - return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_getCurrentName, jni.JniCallType.objectType, []).object); - } - - static final _id_currentName = jniAccessors.getMethodIDOf( - _classRef, r"currentName", r"()Ljava/lang/String;"); - - /// from: public java.lang.String currentName() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method that can be called to get the name associated with - /// the current token: for JsonToken\#FIELD_NAMEs it will - /// be the same as what \#getText returns; - /// for field values it will be preceding field name; - /// and for others (array values, root-level values) null. - ///@return Name of the current field in the parsing context - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - ///@since 2.10 - jni.JString currentName() { - return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_currentName, jni.JniCallType.objectType, []).object); - } - - static final _id_getText = jniAccessors.getMethodIDOf( - _classRef, r"getText", r"()Ljava/lang/String;"); - - /// from: public abstract java.lang.String getText() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for accessing textual representation of the current token; - /// if no current token (before first call to \#nextToken, or - /// after encountering end-of-input), returns null. - /// Method can be called for any token type. - ///@return Textual value associated with the current token (one returned - /// by \#nextToken() or other iteration methods) - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - jni.JString getText() { - return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_getText, jni.JniCallType.objectType, []).object); - } - - static final _id_getText1 = - jniAccessors.getMethodIDOf(_classRef, r"getText", r"(Ljava/io/Writer;)I"); - - /// from: public int getText(java.io.Writer writer) - /// - /// Method to read the textual representation of the current token in chunks and - /// pass it to the given Writer. - /// Conceptually same as calling: - ///
    -  ///  writer.write(parser.getText());
    -  ///
    - /// but should typically be more efficient as longer content does need to - /// be combined into a single String to return, and write - /// can occur directly from intermediate buffers Jackson uses. - ///@param writer Writer to write textual content to - ///@return The number of characters written to the Writer - ///@throws IOException for low-level read issues or writes using passed - /// {@code writer}, or - /// JsonParseException for decoding problems - ///@since 2.8 - int getText1( - jni.JObject writer, - ) { - return jniAccessors.callMethodWithArgs(reference, _id_getText1, - jni.JniCallType.intType, [writer.reference]).integer; - } - - static final _id_getTextCharacters = - jniAccessors.getMethodIDOf(_classRef, r"getTextCharacters", r"()[C"); - - /// from: public abstract char[] getTextCharacters() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method similar to \#getText, but that will return - /// underlying (unmodifiable) character array that contains - /// textual value, instead of constructing a String object - /// to contain this information. - /// Note, however, that: - ///
      - ///
    • Textual contents are not guaranteed to start at - /// index 0 (rather, call \#getTextOffset) to - /// know the actual offset - ///
    • - ///
    • Length of textual contents may be less than the - /// length of returned buffer: call \#getTextLength - /// for actual length of returned content. - ///
    • - ///
    - /// - /// Note that caller __MUST NOT__ modify the returned - /// character array in any way -- doing so may corrupt - /// current parser state and render parser instance useless. - /// - /// The only reason to call this method (over \#getText) - /// is to avoid construction of a String object (which - /// will make a copy of contents). - ///@return Buffer that contains the current textual value (but not necessarily - /// at offset 0, and not necessarily until the end of buffer) - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - jni.JArray getTextCharacters() { - return const jni.JArrayType(jni.JCharType()).fromRef(jniAccessors - .callMethodWithArgs(reference, _id_getTextCharacters, - jni.JniCallType.objectType, []).object); - } - - static final _id_getTextLength = - jniAccessors.getMethodIDOf(_classRef, r"getTextLength", r"()I"); - - /// from: public abstract int getTextLength() - /// - /// Accessor used with \#getTextCharacters, to know length - /// of String stored in returned buffer. - ///@return Number of characters within buffer returned - /// by \#getTextCharacters that are part of - /// textual content of the current token. - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - int getTextLength() { - return jniAccessors.callMethodWithArgs( - reference, _id_getTextLength, jni.JniCallType.intType, []).integer; - } - - static final _id_getTextOffset = - jniAccessors.getMethodIDOf(_classRef, r"getTextOffset", r"()I"); - - /// from: public abstract int getTextOffset() - /// - /// Accessor used with \#getTextCharacters, to know offset - /// of the first text content character within buffer. - ///@return Offset of the first character within buffer returned - /// by \#getTextCharacters that is part of - /// textual content of the current token. - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - int getTextOffset() { - return jniAccessors.callMethodWithArgs( - reference, _id_getTextOffset, jni.JniCallType.intType, []).integer; - } - - static final _id_hasTextCharacters = - jniAccessors.getMethodIDOf(_classRef, r"hasTextCharacters", r"()Z"); - - /// from: public abstract boolean hasTextCharacters() - /// - /// Method that can be used to determine whether calling of - /// \#getTextCharacters would be the most efficient - /// way to access textual content for the event parser currently - /// points to. - /// - /// Default implementation simply returns false since only actual - /// implementation class has knowledge of its internal buffering - /// state. - /// Implementations are strongly encouraged to properly override - /// this method, to allow efficient copying of content by other - /// code. - ///@return True if parser currently has character array that can - /// be efficiently returned via \#getTextCharacters; false - /// means that it may or may not exist - bool hasTextCharacters() { - return jniAccessors.callMethodWithArgs(reference, _id_hasTextCharacters, - jni.JniCallType.booleanType, []).boolean; - } - - static final _id_getNumberValue = jniAccessors.getMethodIDOf( - _classRef, r"getNumberValue", r"()Ljava/lang/Number;"); - - /// from: public abstract java.lang.Number getNumberValue() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Generic number value accessor method that will work for - /// all kinds of numeric values. It will return the optimal - /// (simplest/smallest possible) wrapper object that can - /// express the numeric value just parsed. - ///@return Numeric value of the current token in its most optimal - /// representation - ///@throws IOException Problem with access: JsonParseException if - /// the current token is not numeric, or if decoding of the value fails - /// (invalid format for numbers); plain IOException if underlying - /// content read fails (possible if values are extracted lazily) - jni.JObject getNumberValue() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_getNumberValue, jni.JniCallType.objectType, []).object); - } - - static final _id_getNumberValueExact = jniAccessors.getMethodIDOf( - _classRef, r"getNumberValueExact", r"()Ljava/lang/Number;"); - - /// from: public java.lang.Number getNumberValueExact() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method similar to \#getNumberValue with the difference that - /// for floating-point numbers value returned may be BigDecimal - /// if the underlying format does not store floating-point numbers using - /// native representation: for example, textual formats represent numbers - /// as Strings (which are 10-based), and conversion to java.lang.Double - /// is potentially lossy operation. - /// - /// Default implementation simply returns \#getNumberValue() - ///@return Numeric value of the current token using most accurate representation - ///@throws IOException Problem with access: JsonParseException if - /// the current token is not numeric, or if decoding of the value fails - /// (invalid format for numbers); plain IOException if underlying - /// content read fails (possible if values are extracted lazily) - ///@since 2.12 - jni.JObject getNumberValueExact() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_getNumberValueExact, - jni.JniCallType.objectType, []).object); - } - - static final _id_getNumberType = jniAccessors.getMethodIDOf( - _classRef, - r"getNumberType", - r"()Lcom/fasterxml/jackson/core/JsonParser$NumberType;"); - - /// from: public abstract com.fasterxml.jackson.core.JsonParser.NumberType getNumberType() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// If current token is of type - /// JsonToken\#VALUE_NUMBER_INT or - /// JsonToken\#VALUE_NUMBER_FLOAT, returns - /// one of NumberType constants; otherwise returns null. - ///@return Type of current number, if parser points to numeric token; {@code null} otherwise - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - JsonParser_NumberType getNumberType() { - return const $JsonParser_NumberTypeType().fromRef(jniAccessors - .callMethodWithArgs(reference, _id_getNumberType, - jni.JniCallType.objectType, []).object); - } - - static final _id_getByteValue = - jniAccessors.getMethodIDOf(_classRef, r"getByteValue", r"()B"); - - /// from: public byte getByteValue() - /// - /// Numeric accessor that can be called when the current - /// token is of type JsonToken\#VALUE_NUMBER_INT and - /// it can be expressed as a value of Java byte primitive type. - /// Note that in addition to "natural" input range of {@code [-128, 127]}, - /// this also allows "unsigned 8-bit byte" values {@code [128, 255]}: - /// but for this range value will be translated by truncation, leading - /// to sign change. - /// - /// It can also be called for JsonToken\#VALUE_NUMBER_FLOAT; - /// if so, it is equivalent to calling \#getDoubleValue - /// and then casting; except for possible overflow/underflow - /// exception. - /// - /// Note: if the resulting integer value falls outside range of - /// {@code [-128, 255]}, - /// a InputCoercionException - /// will be thrown to indicate numeric overflow/underflow. - ///@return Current number value as {@code byte} (if numeric token within - /// range of {@code [-128, 255]}); otherwise exception thrown - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - int getByteValue() { - return jniAccessors.callMethodWithArgs( - reference, _id_getByteValue, jni.JniCallType.byteType, []).byte; - } - - static final _id_getShortValue = - jniAccessors.getMethodIDOf(_classRef, r"getShortValue", r"()S"); - - /// from: public short getShortValue() - /// - /// Numeric accessor that can be called when the current - /// token is of type JsonToken\#VALUE_NUMBER_INT and - /// it can be expressed as a value of Java short primitive type. - /// It can also be called for JsonToken\#VALUE_NUMBER_FLOAT; - /// if so, it is equivalent to calling \#getDoubleValue - /// and then casting; except for possible overflow/underflow - /// exception. - /// - /// Note: if the resulting integer value falls outside range of - /// Java short, a InputCoercionException - /// will be thrown to indicate numeric overflow/underflow. - ///@return Current number value as {@code short} (if numeric token within - /// Java 16-bit signed {@code short} range); otherwise exception thrown - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - int getShortValue() { - return jniAccessors.callMethodWithArgs( - reference, _id_getShortValue, jni.JniCallType.shortType, []).short; - } - - static final _id_getIntValue = - jniAccessors.getMethodIDOf(_classRef, r"getIntValue", r"()I"); - - /// from: public abstract int getIntValue() - /// - /// Numeric accessor that can be called when the current - /// token is of type JsonToken\#VALUE_NUMBER_INT and - /// it can be expressed as a value of Java int primitive type. - /// It can also be called for JsonToken\#VALUE_NUMBER_FLOAT; - /// if so, it is equivalent to calling \#getDoubleValue - /// and then casting; except for possible overflow/underflow - /// exception. - /// - /// Note: if the resulting integer value falls outside range of - /// Java {@code int}, a InputCoercionException - /// may be thrown to indicate numeric overflow/underflow. - ///@return Current number value as {@code int} (if numeric token within - /// Java 32-bit signed {@code int} range); otherwise exception thrown - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - int getIntValue() { - return jniAccessors.callMethodWithArgs( - reference, _id_getIntValue, jni.JniCallType.intType, []).integer; - } - - static final _id_getLongValue = - jniAccessors.getMethodIDOf(_classRef, r"getLongValue", r"()J"); - - /// from: public abstract long getLongValue() - /// - /// Numeric accessor that can be called when the current - /// token is of type JsonToken\#VALUE_NUMBER_INT and - /// it can be expressed as a Java long primitive type. - /// It can also be called for JsonToken\#VALUE_NUMBER_FLOAT; - /// if so, it is equivalent to calling \#getDoubleValue - /// and then casting to int; except for possible overflow/underflow - /// exception. - /// - /// Note: if the token is an integer, but its value falls - /// outside of range of Java long, a InputCoercionException - /// may be thrown to indicate numeric overflow/underflow. - ///@return Current number value as {@code long} (if numeric token within - /// Java 32-bit signed {@code long} range); otherwise exception thrown - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - int getLongValue() { - return jniAccessors.callMethodWithArgs( - reference, _id_getLongValue, jni.JniCallType.longType, []).long; - } - - static final _id_getBigIntegerValue = jniAccessors.getMethodIDOf( - _classRef, r"getBigIntegerValue", r"()Ljava/math/BigInteger;"); - - /// from: public abstract java.math.BigInteger getBigIntegerValue() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Numeric accessor that can be called when the current - /// token is of type JsonToken\#VALUE_NUMBER_INT and - /// it can not be used as a Java long primitive type due to its - /// magnitude. - /// It can also be called for JsonToken\#VALUE_NUMBER_FLOAT; - /// if so, it is equivalent to calling \#getDecimalValue - /// and then constructing a BigInteger from that value. - ///@return Current number value as BigInteger (if numeric token); - /// otherwise exception thrown - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - jni.JObject getBigIntegerValue() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_getBigIntegerValue, - jni.JniCallType.objectType, []).object); - } - - static final _id_getFloatValue = - jniAccessors.getMethodIDOf(_classRef, r"getFloatValue", r"()F"); - - /// from: public abstract float getFloatValue() - /// - /// Numeric accessor that can be called when the current - /// token is of type JsonToken\#VALUE_NUMBER_FLOAT and - /// it can be expressed as a Java float primitive type. - /// It can also be called for JsonToken\#VALUE_NUMBER_INT; - /// if so, it is equivalent to calling \#getLongValue - /// and then casting; except for possible overflow/underflow - /// exception. - /// - /// Note: if the value falls - /// outside of range of Java float, a InputCoercionException - /// will be thrown to indicate numeric overflow/underflow. - ///@return Current number value as {@code float} (if numeric token within - /// Java {@code float} range); otherwise exception thrown - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - double getFloatValue() { - return jniAccessors.callMethodWithArgs( - reference, _id_getFloatValue, jni.JniCallType.floatType, []).float; - } - - static final _id_getDoubleValue = - jniAccessors.getMethodIDOf(_classRef, r"getDoubleValue", r"()D"); - - /// from: public abstract double getDoubleValue() - /// - /// Numeric accessor that can be called when the current - /// token is of type JsonToken\#VALUE_NUMBER_FLOAT and - /// it can be expressed as a Java double primitive type. - /// It can also be called for JsonToken\#VALUE_NUMBER_INT; - /// if so, it is equivalent to calling \#getLongValue - /// and then casting; except for possible overflow/underflow - /// exception. - /// - /// Note: if the value falls - /// outside of range of Java double, a InputCoercionException - /// will be thrown to indicate numeric overflow/underflow. - ///@return Current number value as {@code double} (if numeric token within - /// Java {@code double} range); otherwise exception thrown - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - double getDoubleValue() { - return jniAccessors.callMethodWithArgs(reference, _id_getDoubleValue, - jni.JniCallType.doubleType, []).doubleFloat; - } - - static final _id_getDecimalValue = jniAccessors.getMethodIDOf( - _classRef, r"getDecimalValue", r"()Ljava/math/BigDecimal;"); - - /// from: public abstract java.math.BigDecimal getDecimalValue() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Numeric accessor that can be called when the current - /// token is of type JsonToken\#VALUE_NUMBER_FLOAT or - /// JsonToken\#VALUE_NUMBER_INT. No under/overflow exceptions - /// are ever thrown. - ///@return Current number value as BigDecimal (if numeric token); - /// otherwise exception thrown - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - jni.JObject getDecimalValue() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_getDecimalValue, jni.JniCallType.objectType, []).object); - } - - static final _id_getBooleanValue = - jniAccessors.getMethodIDOf(_classRef, r"getBooleanValue", r"()Z"); - - /// from: public boolean getBooleanValue() - /// - /// Convenience accessor that can be called when the current - /// token is JsonToken\#VALUE_TRUE or - /// JsonToken\#VALUE_FALSE, to return matching {@code boolean} - /// value. - /// If the current token is of some other type, JsonParseException - /// will be thrown - ///@return {@code True} if current token is {@code JsonToken.VALUE_TRUE}, - /// {@code false} if current token is {@code JsonToken.VALUE_FALSE}; - /// otherwise throws JsonParseException - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - bool getBooleanValue() { - return jniAccessors.callMethodWithArgs(reference, _id_getBooleanValue, - jni.JniCallType.booleanType, []).boolean; - } - - static final _id_getEmbeddedObject = jniAccessors.getMethodIDOf( - _classRef, r"getEmbeddedObject", r"()Ljava/lang/Object;"); - - /// from: public java.lang.Object getEmbeddedObject() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Accessor that can be called if (and only if) the current token - /// is JsonToken\#VALUE_EMBEDDED_OBJECT. For other token types, - /// null is returned. - /// - /// Note: only some specialized parser implementations support - /// embedding of objects (usually ones that are facades on top - /// of non-streaming sources, such as object trees). One exception - /// is access to binary content (whether via base64 encoding or not) - /// which typically is accessible using this method, as well as - /// \#getBinaryValue(). - ///@return Embedded value (usually of "native" type supported by format) - /// for the current token, if any; {@code null otherwise} - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - jni.JObject getEmbeddedObject() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_getEmbeddedObject, - jni.JniCallType.objectType, []).object); - } - - static final _id_getBinaryValue = jniAccessors.getMethodIDOf(_classRef, - r"getBinaryValue", r"(Lcom/fasterxml/jackson/core/Base64Variant;)[B"); - - /// from: public abstract byte[] getBinaryValue(com.fasterxml.jackson.core.Base64Variant bv) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method that can be used to read (and consume -- results - /// may not be accessible using other methods after the call) - /// base64-encoded binary data - /// included in the current textual JSON value. - /// It works similar to getting String value via \#getText - /// and decoding result (except for decoding part), - /// but should be significantly more performant. - /// - /// Note that non-decoded textual contents of the current token - /// are not guaranteed to be accessible after this method - /// is called. Current implementation, for example, clears up - /// textual content during decoding. - /// Decoded binary content, however, will be retained until - /// parser is advanced to the next event. - ///@param bv Expected variant of base64 encoded - /// content (see Base64Variants for definitions - /// of "standard" variants). - ///@return Decoded binary data - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - jni.JArray getBinaryValue( - jni.JObject bv, - ) { - return const jni.JArrayType(jni.JByteType()).fromRef(jniAccessors - .callMethodWithArgs(reference, _id_getBinaryValue, - jni.JniCallType.objectType, [bv.reference]).object); - } - - static final _id_getBinaryValue1 = - jniAccessors.getMethodIDOf(_classRef, r"getBinaryValue", r"()[B"); - - /// from: public byte[] getBinaryValue() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Convenience alternative to \#getBinaryValue(Base64Variant) - /// that defaults to using - /// Base64Variants\#getDefaultVariant as the default encoding. - ///@return Decoded binary data - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - jni.JArray getBinaryValue1() { - return const jni.JArrayType(jni.JByteType()).fromRef(jniAccessors - .callMethodWithArgs(reference, _id_getBinaryValue1, - jni.JniCallType.objectType, []).object); - } - - static final _id_readBinaryValue = jniAccessors.getMethodIDOf( - _classRef, r"readBinaryValue", r"(Ljava/io/OutputStream;)I"); - - /// from: public int readBinaryValue(java.io.OutputStream out) - /// - /// Method that can be used as an alternative to \#getBigIntegerValue(), - /// especially when value can be large. The main difference (beyond method - /// of returning content using OutputStream instead of as byte array) - /// is that content will NOT remain accessible after method returns: any content - /// processed will be consumed and is not buffered in any way. If caller needs - /// buffering, it has to implement it. - ///@param out Output stream to use for passing decoded binary data - ///@return Number of bytes that were decoded and written via OutputStream - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - ///@since 2.1 - int readBinaryValue( - jni.JObject out, - ) { - return jniAccessors.callMethodWithArgs(reference, _id_readBinaryValue, - jni.JniCallType.intType, [out.reference]).integer; - } - - static final _id_readBinaryValue1 = jniAccessors.getMethodIDOf( - _classRef, - r"readBinaryValue", - r"(Lcom/fasterxml/jackson/core/Base64Variant;Ljava/io/OutputStream;)I"); - - /// from: public int readBinaryValue(com.fasterxml.jackson.core.Base64Variant bv, java.io.OutputStream out) - /// - /// Similar to \#readBinaryValue(OutputStream) but allows explicitly - /// specifying base64 variant to use. - ///@param bv base64 variant to use - ///@param out Output stream to use for passing decoded binary data - ///@return Number of bytes that were decoded and written via OutputStream - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - ///@since 2.1 - int readBinaryValue1( - jni.JObject bv, - jni.JObject out, - ) { - return jniAccessors.callMethodWithArgs(reference, _id_readBinaryValue1, - jni.JniCallType.intType, [bv.reference, out.reference]).integer; - } - - static final _id_getValueAsInt = - jniAccessors.getMethodIDOf(_classRef, r"getValueAsInt", r"()I"); - - /// from: public int getValueAsInt() - /// - /// Method that will try to convert value of current token to a - /// Java {@code int} value. - /// Numbers are coerced using default Java rules; booleans convert to 0 (false) - /// and 1 (true), and Strings are parsed using default Java language integer - /// parsing rules. - /// - /// If representation can not be converted to an int (including structured type - /// markers like start/end Object/Array) - /// default value of __0__ will be returned; no exceptions are thrown. - ///@return {@code int} value current token is converted to, if possible; exception thrown - /// otherwise - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - int getValueAsInt() { - return jniAccessors.callMethodWithArgs( - reference, _id_getValueAsInt, jni.JniCallType.intType, []).integer; - } - - static final _id_getValueAsInt1 = - jniAccessors.getMethodIDOf(_classRef, r"getValueAsInt", r"(I)I"); - - /// from: public int getValueAsInt(int def) - /// - /// Method that will try to convert value of current token to a - /// __int__. - /// Numbers are coerced using default Java rules; booleans convert to 0 (false) - /// and 1 (true), and Strings are parsed using default Java language integer - /// parsing rules. - /// - /// If representation can not be converted to an int (including structured type - /// markers like start/end Object/Array) - /// specified __def__ will be returned; no exceptions are thrown. - ///@param def Default value to return if conversion to {@code int} is not possible - ///@return {@code int} value current token is converted to, if possible; {@code def} otherwise - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - int getValueAsInt1( - int def, - ) { - return jniAccessors.callMethodWithArgs(reference, _id_getValueAsInt1, - jni.JniCallType.intType, [jni.JValueInt(def)]).integer; - } - - static final _id_getValueAsLong = - jniAccessors.getMethodIDOf(_classRef, r"getValueAsLong", r"()J"); - - /// from: public long getValueAsLong() - /// - /// Method that will try to convert value of current token to a - /// __long__. - /// Numbers are coerced using default Java rules; booleans convert to 0 (false) - /// and 1 (true), and Strings are parsed using default Java language integer - /// parsing rules. - /// - /// If representation can not be converted to a long (including structured type - /// markers like start/end Object/Array) - /// default value of __0L__ will be returned; no exceptions are thrown. - ///@return {@code long} value current token is converted to, if possible; exception thrown - /// otherwise - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - int getValueAsLong() { - return jniAccessors.callMethodWithArgs( - reference, _id_getValueAsLong, jni.JniCallType.longType, []).long; - } - - static final _id_getValueAsLong1 = - jniAccessors.getMethodIDOf(_classRef, r"getValueAsLong", r"(J)J"); - - /// from: public long getValueAsLong(long def) - /// - /// Method that will try to convert value of current token to a - /// __long__. - /// Numbers are coerced using default Java rules; booleans convert to 0 (false) - /// and 1 (true), and Strings are parsed using default Java language integer - /// parsing rules. - /// - /// If representation can not be converted to a long (including structured type - /// markers like start/end Object/Array) - /// specified __def__ will be returned; no exceptions are thrown. - ///@param def Default value to return if conversion to {@code long} is not possible - ///@return {@code long} value current token is converted to, if possible; {@code def} otherwise - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - int getValueAsLong1( - int def, - ) { - return jniAccessors.callMethodWithArgs( - reference, _id_getValueAsLong1, jni.JniCallType.longType, [def]).long; - } - - static final _id_getValueAsDouble = - jniAccessors.getMethodIDOf(_classRef, r"getValueAsDouble", r"()D"); - - /// from: public double getValueAsDouble() - /// - /// Method that will try to convert value of current token to a Java - /// __double__. - /// Numbers are coerced using default Java rules; booleans convert to 0.0 (false) - /// and 1.0 (true), and Strings are parsed using default Java language floating - /// point parsing rules. - /// - /// If representation can not be converted to a double (including structured types - /// like Objects and Arrays), - /// default value of __0.0__ will be returned; no exceptions are thrown. - ///@return {@code double} value current token is converted to, if possible; exception thrown - /// otherwise - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - double getValueAsDouble() { - return jniAccessors.callMethodWithArgs(reference, _id_getValueAsDouble, - jni.JniCallType.doubleType, []).doubleFloat; - } - - static final _id_getValueAsDouble1 = - jniAccessors.getMethodIDOf(_classRef, r"getValueAsDouble", r"(D)D"); - - /// from: public double getValueAsDouble(double def) - /// - /// Method that will try to convert value of current token to a - /// Java __double__. - /// Numbers are coerced using default Java rules; booleans convert to 0.0 (false) - /// and 1.0 (true), and Strings are parsed using default Java language floating - /// point parsing rules. - /// - /// If representation can not be converted to a double (including structured types - /// like Objects and Arrays), - /// specified __def__ will be returned; no exceptions are thrown. - ///@param def Default value to return if conversion to {@code double} is not possible - ///@return {@code double} value current token is converted to, if possible; {@code def} otherwise - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - double getValueAsDouble1( - double def, - ) { - return jniAccessors.callMethodWithArgs(reference, _id_getValueAsDouble1, - jni.JniCallType.doubleType, [def]).doubleFloat; - } - - static final _id_getValueAsBoolean = - jniAccessors.getMethodIDOf(_classRef, r"getValueAsBoolean", r"()Z"); - - /// from: public boolean getValueAsBoolean() - /// - /// Method that will try to convert value of current token to a - /// __boolean__. - /// JSON booleans map naturally; integer numbers other than 0 map to true, and - /// 0 maps to false - /// and Strings 'true' and 'false' map to corresponding values. - /// - /// If representation can not be converted to a boolean value (including structured types - /// like Objects and Arrays), - /// default value of __false__ will be returned; no exceptions are thrown. - ///@return {@code boolean} value current token is converted to, if possible; exception thrown - /// otherwise - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - bool getValueAsBoolean() { - return jniAccessors.callMethodWithArgs(reference, _id_getValueAsBoolean, - jni.JniCallType.booleanType, []).boolean; - } - - static final _id_getValueAsBoolean1 = - jniAccessors.getMethodIDOf(_classRef, r"getValueAsBoolean", r"(Z)Z"); - - /// from: public boolean getValueAsBoolean(boolean def) - /// - /// Method that will try to convert value of current token to a - /// __boolean__. - /// JSON booleans map naturally; integer numbers other than 0 map to true, and - /// 0 maps to false - /// and Strings 'true' and 'false' map to corresponding values. - /// - /// If representation can not be converted to a boolean value (including structured types - /// like Objects and Arrays), - /// specified __def__ will be returned; no exceptions are thrown. - ///@param def Default value to return if conversion to {@code boolean} is not possible - ///@return {@code boolean} value current token is converted to, if possible; {@code def} otherwise - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - bool getValueAsBoolean1( - bool def, - ) { - return jniAccessors.callMethodWithArgs(reference, _id_getValueAsBoolean1, - jni.JniCallType.booleanType, [def ? 1 : 0]).boolean; - } - - static final _id_getValueAsString = jniAccessors.getMethodIDOf( - _classRef, r"getValueAsString", r"()Ljava/lang/String;"); - - /// from: public java.lang.String getValueAsString() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method that will try to convert value of current token to a - /// java.lang.String. - /// JSON Strings map naturally; scalar values get converted to - /// their textual representation. - /// If representation can not be converted to a String value (including structured types - /// like Objects and Arrays and {@code null} token), default value of - /// __null__ will be returned; no exceptions are thrown. - ///@return String value current token is converted to, if possible; {@code null} otherwise - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - ///@since 2.1 - jni.JString getValueAsString() { - return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_getValueAsString, - jni.JniCallType.objectType, []).object); - } - - static final _id_getValueAsString1 = jniAccessors.getMethodIDOf(_classRef, - r"getValueAsString", r"(Ljava/lang/String;)Ljava/lang/String;"); - - /// from: public abstract java.lang.String getValueAsString(java.lang.String def) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method that will try to convert value of current token to a - /// java.lang.String. - /// JSON Strings map naturally; scalar values get converted to - /// their textual representation. - /// If representation can not be converted to a String value (including structured types - /// like Objects and Arrays and {@code null} token), specified default value - /// will be returned; no exceptions are thrown. - ///@param def Default value to return if conversion to {@code String} is not possible - ///@return String value current token is converted to, if possible; {@code def} otherwise - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - ///@since 2.1 - jni.JString getValueAsString1( - jni.JString def, - ) { - return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_getValueAsString1, - jni.JniCallType.objectType, - [def.reference]).object); - } - - static final _id_canReadObjectId = - jniAccessors.getMethodIDOf(_classRef, r"canReadObjectId", r"()Z"); - - /// from: public boolean canReadObjectId() - /// - /// Introspection method that may be called to see if the underlying - /// data format supports some kind of Object Ids natively (many do not; - /// for example, JSON doesn't). - /// - /// Default implementation returns true; overridden by data formats - /// that do support native Object Ids. Caller is expected to either - /// use a non-native notation (explicit property or such), or fail, - /// in case it can not use native object ids. - ///@return {@code True} if the format being read supports native Object Ids; - /// {@code false} if not - ///@since 2.3 - bool canReadObjectId() { - return jniAccessors.callMethodWithArgs(reference, _id_canReadObjectId, - jni.JniCallType.booleanType, []).boolean; - } - - static final _id_canReadTypeId = - jniAccessors.getMethodIDOf(_classRef, r"canReadTypeId", r"()Z"); - - /// from: public boolean canReadTypeId() - /// - /// Introspection method that may be called to see if the underlying - /// data format supports some kind of Type Ids natively (many do not; - /// for example, JSON doesn't). - /// - /// Default implementation returns true; overridden by data formats - /// that do support native Type Ids. Caller is expected to either - /// use a non-native notation (explicit property or such), or fail, - /// in case it can not use native type ids. - ///@return {@code True} if the format being read supports native Type Ids; - /// {@code false} if not - ///@since 2.3 - bool canReadTypeId() { - return jniAccessors.callMethodWithArgs( - reference, _id_canReadTypeId, jni.JniCallType.booleanType, []).boolean; - } - - static final _id_getObjectId = jniAccessors.getMethodIDOf( - _classRef, r"getObjectId", r"()Ljava/lang/Object;"); - - /// from: public java.lang.Object getObjectId() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method that can be called to check whether current token - /// (one that was just read) has an associated Object id, and if - /// so, return it. - /// Note that while typically caller should check with \#canReadObjectId - /// first, it is not illegal to call this method even if that method returns - /// true; but if so, it will return null. This may be used to simplify calling - /// code. - /// - /// Default implementation will simply return null. - ///@return Native Object id associated with the current token, if any; {@code null} if none - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - ///@since 2.3 - jni.JObject getObjectId() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_getObjectId, jni.JniCallType.objectType, []).object); - } - - static final _id_getTypeId = jniAccessors.getMethodIDOf( - _classRef, r"getTypeId", r"()Ljava/lang/Object;"); - - /// from: public java.lang.Object getTypeId() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method that can be called to check whether current token - /// (one that was just read) has an associated type id, and if - /// so, return it. - /// Note that while typically caller should check with \#canReadTypeId - /// first, it is not illegal to call this method even if that method returns - /// true; but if so, it will return null. This may be used to simplify calling - /// code. - /// - /// Default implementation will simply return null. - ///@return Native Type Id associated with the current token, if any; {@code null} if none - ///@throws IOException for low-level read issues, or - /// JsonParseException for decoding problems - ///@since 2.3 - jni.JObject getTypeId() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_getTypeId, jni.JniCallType.objectType, []).object); - } - - static final _id_readValueAs = jniAccessors.getMethodIDOf( - _classRef, r"readValueAs", r"(Ljava/lang/Class;)Ljava/lang/Object;"); - - /// from: public T readValueAs(java.lang.Class valueType) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method to deserialize JSON content into a non-container - /// type (it can be an array type, however): typically a bean, array - /// or a wrapper type (like java.lang.Boolean). - /// __Note__: method can only be called if the parser has - /// an object codec assigned; this is true for parsers constructed - /// by MappingJsonFactory (from "jackson-databind" jar) - /// but not for JsonFactory (unless its setCodec - /// method has been explicitly called). - /// - /// This method may advance the event stream, for structured types - /// the current token will be the closing end marker (END_ARRAY, - /// END_OBJECT) of the bound structure. For non-structured Json types - /// (and for JsonToken\#VALUE_EMBEDDED_OBJECT) - /// stream is not advanced. - /// - /// Note: this method should NOT be used if the result type is a - /// container (java.util.Collection or java.util.Map. - /// The reason is that due to type erasure, key and value types - /// can not be introspected when using this method. - ///@param Nominal type parameter for value type - ///@param valueType Java type to read content as (passed to ObjectCodec that - /// deserializes content) - ///@return Java value read from content - ///@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.JObjType<$T> T, - }) { - return T.fromRef(jniAccessors.callMethodWithArgs(reference, _id_readValueAs, - jni.JniCallType.objectType, [valueType.reference]).object); - } - - static final _id_readValueAs1 = jniAccessors.getMethodIDOf( - _classRef, - r"readValueAs", - r"(Lcom/fasterxml/jackson/core/type/TypeReference;)Ljava/lang/Object;"); - - /// from: public T readValueAs(com.fasterxml.jackson.core.type.TypeReference valueTypeRef) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method to deserialize JSON content into a Java type, reference - /// to which is passed as argument. Type is passed using so-called - /// "super type token" - /// and specifically needs to be used if the root type is a - /// parameterized (generic) container type. - /// __Note__: method can only be called if the parser has - /// an object codec assigned; this is true for parsers constructed - /// by MappingJsonFactory (defined in 'jackson-databind' bundle) - /// but not for JsonFactory (unless its setCodec - /// method has been explicitly called). - /// - /// This method may advance the event stream, for structured types - /// the current token will be the closing end marker (END_ARRAY, - /// END_OBJECT) of the bound structure. For non-structured Json types - /// (and for JsonToken\#VALUE_EMBEDDED_OBJECT) - /// stream is not advanced. - ///@param Nominal type parameter for value type - ///@param valueTypeRef Java type to read content as (passed to ObjectCodec that - /// deserializes content) - ///@return Java value read from content - ///@throws IOException if there is either an underlying I/O problem or decoding - /// issue at format layer - $T readValueAs1<$T extends jni.JObject>( - jni.JObject valueTypeRef, { - required jni.JObjType<$T> T, - }) { - return T.fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_readValueAs1, - jni.JniCallType.objectType, - [valueTypeRef.reference]).object); - } - - static final _id_readValuesAs = jniAccessors.getMethodIDOf( - _classRef, r"readValuesAs", r"(Ljava/lang/Class;)Ljava/util/Iterator;"); - - /// from: public java.util.Iterator readValuesAs(java.lang.Class valueType) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for reading sequence of Objects from parser stream, - /// all with same specified value type. - ///@param Nominal type parameter for value type - ///@param valueType Java type to read content as (passed to ObjectCodec that - /// deserializes content) - ///@return Iterator for reading multiple Java values from content - ///@throws IOException if there is either an underlying I/O problem or decoding - /// issue at format layer - jni.JObject readValuesAs<$T extends jni.JObject>( - jni.JObject valueType, { - required jni.JObjType<$T> T, - }) { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_readValuesAs, - jni.JniCallType.objectType, - [valueType.reference]).object); - } - - static final _id_readValuesAs1 = jniAccessors.getMethodIDOf( - _classRef, - r"readValuesAs", - r"(Lcom/fasterxml/jackson/core/type/TypeReference;)Ljava/util/Iterator;"); - - /// from: public java.util.Iterator readValuesAs(com.fasterxml.jackson.core.type.TypeReference valueTypeRef) - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method for reading sequence of Objects from parser stream, - /// all with same specified value type. - ///@param Nominal type parameter for value type - ///@param valueTypeRef Java type to read content as (passed to ObjectCodec that - /// deserializes content) - ///@return Iterator for reading multiple Java values from content - ///@throws IOException if there is either an underlying I/O problem or decoding - /// issue at format layer - jni.JObject readValuesAs1<$T extends jni.JObject>( - jni.JObject valueTypeRef, { - required jni.JObjType<$T> T, - }) { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( - reference, - _id_readValuesAs1, - jni.JniCallType.objectType, - [valueTypeRef.reference]).object); - } - - static final _id_readValueAsTree = jniAccessors.getMethodIDOf( - _classRef, r"readValueAsTree", r"()Ljava/lang/Object;"); - - /// from: public T readValueAsTree() - /// The returned object must be deleted after use, by calling the `delete` method. - /// - /// Method to deserialize JSON content into equivalent "tree model", - /// represented by root TreeNode of resulting model. - /// For JSON Arrays it will an array node (with child nodes), - /// for objects object node (with child nodes), and for other types - /// matching leaf node type. Empty or whitespace documents are null. - ///@param Nominal type parameter for result node type (to reduce need for casting) - ///@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.JObjType<$T> T, - }) { - return T.fromRef(jniAccessors.callMethodWithArgs( - reference, _id_readValueAsTree, jni.JniCallType.objectType, []).object); - } -} - -class $JsonParserType extends jni.JObjType { - const $JsonParserType(); - - @override - String get signature => r"Lcom/fasterxml/jackson/core/JsonParser;"; - - @override - JsonParser fromRef(jni.JObjectPtr ref) => JsonParser.fromRef(ref); - - @override - jni.JObjType get superType => const jni.JObjectType(); - - @override - final superCount = 1; - - @override - int get hashCode => ($JsonParserType).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JsonParserType && other is $JsonParserType; - } -} - -/// from: com.fasterxml.jackson.core.JsonParser$Feature -/// -/// Enumeration that defines all on/off features for parsers. -class JsonParser_Feature extends jni.JObject { - @override - late final jni.JObjType $type = type; - - JsonParser_Feature.fromRef( - jni.JObjectPtr ref, - ) : super.fromRef(ref); - - static final _classRef = - jniAccessors.getClassOf(r"com/fasterxml/jackson/core/JsonParser$Feature"); - - /// The type which includes information such as the signature of this class. - static const type = $JsonParser_FeatureType(); - static final _id_values = jniAccessors.getStaticMethodIDOf(_classRef, - r"values", r"()[Lcom/fasterxml/jackson/core/JsonParser$Feature;"); - - /// from: static public com.fasterxml.jackson.core.JsonParser.Feature[] values() - /// The returned object must be deleted after use, by calling the `delete` method. - static jni.JArray values() { - return const jni.JArrayType($JsonParser_FeatureType()).fromRef(jniAccessors - .callStaticMethodWithArgs( - _classRef, _id_values, jni.JniCallType.objectType, []).object); - } - - static final _id_valueOf = jniAccessors.getStaticMethodIDOf( - _classRef, - r"valueOf", - r"(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonParser$Feature;"); - - /// from: static public com.fasterxml.jackson.core.JsonParser.Feature valueOf(java.lang.String name) - /// The returned object must be deleted after use, by calling the `delete` method. - static JsonParser_Feature valueOf( - jni.JString name, - ) { - return const $JsonParser_FeatureType().fromRef(jniAccessors - .callStaticMethodWithArgs(_classRef, _id_valueOf, - jni.JniCallType.objectType, [name.reference]).object); - } - - static final _id_collectDefaults = - jniAccessors.getStaticMethodIDOf(_classRef, r"collectDefaults", r"()I"); - - /// from: static public int collectDefaults() - /// - /// Method that calculates bit set (flags) of all features that - /// are enabled by default. - ///@return Bit mask of all features that are enabled by default - static int collectDefaults() { - return jniAccessors.callStaticMethodWithArgs( - _classRef, _id_collectDefaults, jni.JniCallType.intType, []).integer; - } - - static final _id_enabledByDefault = - jniAccessors.getMethodIDOf(_classRef, r"enabledByDefault", r"()Z"); - - /// from: public boolean enabledByDefault() - bool enabledByDefault() { - return jniAccessors.callMethodWithArgs(reference, _id_enabledByDefault, - jni.JniCallType.booleanType, []).boolean; - } - - static final _id_enabledIn = - jniAccessors.getMethodIDOf(_classRef, r"enabledIn", r"(I)Z"); - - /// from: public boolean enabledIn(int flags) - bool enabledIn( - int flags, - ) { - return jniAccessors.callMethodWithArgs(reference, _id_enabledIn, - jni.JniCallType.booleanType, [jni.JValueInt(flags)]).boolean; - } - - static final _id_getMask = - jniAccessors.getMethodIDOf(_classRef, r"getMask", r"()I"); - - /// from: public int getMask() - int getMask() { - return jniAccessors.callMethodWithArgs( - reference, _id_getMask, jni.JniCallType.intType, []).integer; - } -} - -class $JsonParser_FeatureType extends jni.JObjType { - const $JsonParser_FeatureType(); - - @override - String get signature => r"Lcom/fasterxml/jackson/core/JsonParser$Feature;"; - - @override - JsonParser_Feature fromRef(jni.JObjectPtr ref) => - JsonParser_Feature.fromRef(ref); - - @override - jni.JObjType get superType => const jni.JObjectType(); - - @override - final superCount = 1; - - @override - int get hashCode => ($JsonParser_FeatureType).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JsonParser_FeatureType && - other is $JsonParser_FeatureType; - } -} - -/// 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 { - @override - late final jni.JObjType $type = type; - - JsonParser_NumberType.fromRef( - jni.JObjectPtr ref, - ) : super.fromRef(ref); - - static final _classRef = jniAccessors - .getClassOf(r"com/fasterxml/jackson/core/JsonParser$NumberType"); - - /// The type which includes information such as the signature of this class. - static const type = $JsonParser_NumberTypeType(); - static final _id_values = jniAccessors.getStaticMethodIDOf(_classRef, - r"values", r"()[Lcom/fasterxml/jackson/core/JsonParser$NumberType;"); - - /// from: static public com.fasterxml.jackson.core.JsonParser.NumberType[] values() - /// The returned object must be deleted after use, by calling the `delete` method. - static jni.JArray values() { - return const jni.JArrayType($JsonParser_NumberTypeType()).fromRef( - jniAccessors.callStaticMethodWithArgs( - _classRef, _id_values, jni.JniCallType.objectType, []).object); - } - - static final _id_valueOf = jniAccessors.getStaticMethodIDOf( - _classRef, - r"valueOf", - r"(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonParser$NumberType;"); - - /// from: static public com.fasterxml.jackson.core.JsonParser.NumberType valueOf(java.lang.String name) - /// The returned object must be deleted after use, by calling the `delete` method. - static JsonParser_NumberType valueOf( - jni.JString name, - ) { - return const $JsonParser_NumberTypeType().fromRef(jniAccessors - .callStaticMethodWithArgs(_classRef, _id_valueOf, - jni.JniCallType.objectType, [name.reference]).object); - } -} - -class $JsonParser_NumberTypeType extends jni.JObjType { - const $JsonParser_NumberTypeType(); - - @override - String get signature => r"Lcom/fasterxml/jackson/core/JsonParser$NumberType;"; - - @override - JsonParser_NumberType fromRef(jni.JObjectPtr ref) => - JsonParser_NumberType.fromRef(ref); - - @override - jni.JObjType get superType => const jni.JObjectType(); - - @override - final superCount = 1; - - @override - int get hashCode => ($JsonParser_NumberTypeType).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JsonParser_NumberTypeType && - other is $JsonParser_NumberTypeType; - } -} diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/com/fasterxml/jackson/core/JsonToken.dart b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/com/fasterxml/jackson/core/JsonToken.dart deleted file mode 100644 index 2a88806e9..000000000 --- a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/com/fasterxml/jackson/core/JsonToken.dart +++ /dev/null @@ -1,223 +0,0 @@ -// Generated from jackson-core which is licensed under the Apache License 2.0. -// The following copyright from the original authors applies. -// See https://github.com/FasterXML/jackson-core/blob/2.14/LICENSE -// -// Copyright (c) 2007 - The Jackson Project Authors -// Licensed under the Apache License, Version 2.0 (the "License") -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Autogenerated by jnigen. DO NOT EDIT! - -// ignore_for_file: annotate_overrides -// ignore_for_file: camel_case_extensions -// ignore_for_file: camel_case_types -// ignore_for_file: constant_identifier_names -// ignore_for_file: file_names -// ignore_for_file: no_leading_underscores_for_local_identifiers -// ignore_for_file: non_constant_identifier_names -// ignore_for_file: overridden_fields -// ignore_for_file: unnecessary_cast -// ignore_for_file: unused_element -// ignore_for_file: unused_field -// ignore_for_file: unused_import -// ignore_for_file: unused_shown_name - -import "dart:isolate" show ReceivePort; -import "dart:ffi" as ffi; -import "package:jni/internal_helpers_for_jnigen.dart"; -import "package:jni/jni.dart" as jni; - -import "../../../../_init.dart"; - -/// from: com.fasterxml.jackson.core.JsonToken -/// -/// Enumeration for basic token types used for returning results -/// of parsing JSON content. -class JsonToken extends jni.JObject { - @override - late final jni.JObjType $type = type; - - JsonToken.fromRef( - jni.JObjectPtr ref, - ) : super.fromRef(ref); - - static final _classRef = - jniAccessors.getClassOf(r"com/fasterxml/jackson/core/JsonToken"); - - /// The type which includes information such as the signature of this class. - static const type = $JsonTokenType(); - static final _id_values = jniAccessors.getStaticMethodIDOf( - _classRef, r"values", r"()[Lcom/fasterxml/jackson/core/JsonToken;"); - - /// from: static public com.fasterxml.jackson.core.JsonToken[] values() - /// The returned object must be deleted after use, by calling the `delete` method. - static jni.JArray values() { - return const jni.JArrayType($JsonTokenType()).fromRef(jniAccessors - .callStaticMethodWithArgs( - _classRef, _id_values, jni.JniCallType.objectType, []).object); - } - - static final _id_valueOf = jniAccessors.getStaticMethodIDOf( - _classRef, - r"valueOf", - r"(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonToken;"); - - /// from: static public com.fasterxml.jackson.core.JsonToken valueOf(java.lang.String name) - /// The returned object must be deleted after use, by calling the `delete` method. - static JsonToken valueOf( - jni.JString name, - ) { - return const $JsonTokenType().fromRef(jniAccessors.callStaticMethodWithArgs( - _classRef, - _id_valueOf, - jni.JniCallType.objectType, - [name.reference]).object); - } - - static final _id_id = jniAccessors.getMethodIDOf(_classRef, r"id", r"()I"); - - /// from: public final int id() - int id() { - return jniAccessors.callMethodWithArgs( - reference, _id_id, jni.JniCallType.intType, []).integer; - } - - static final _id_asString = jniAccessors.getMethodIDOf( - _classRef, r"asString", r"()Ljava/lang/String;"); - - /// from: public final java.lang.String asString() - /// The returned object must be deleted after use, by calling the `delete` method. - jni.JString asString() { - return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( - reference, _id_asString, jni.JniCallType.objectType, []).object); - } - - static final _id_asCharArray = - jniAccessors.getMethodIDOf(_classRef, r"asCharArray", r"()[C"); - - /// from: public final char[] asCharArray() - /// The returned object must be deleted after use, by calling the `delete` method. - jni.JArray asCharArray() { - return const jni.JArrayType(jni.JCharType()).fromRef(jniAccessors - .callMethodWithArgs( - reference, _id_asCharArray, jni.JniCallType.objectType, []).object); - } - - static final _id_asByteArray = - jniAccessors.getMethodIDOf(_classRef, r"asByteArray", r"()[B"); - - /// from: public final byte[] asByteArray() - /// The returned object must be deleted after use, by calling the `delete` method. - jni.JArray asByteArray() { - return const jni.JArrayType(jni.JByteType()).fromRef(jniAccessors - .callMethodWithArgs( - reference, _id_asByteArray, jni.JniCallType.objectType, []).object); - } - - static final _id_isNumeric = - jniAccessors.getMethodIDOf(_classRef, r"isNumeric", r"()Z"); - - /// from: public final boolean isNumeric() - /// - /// @return {@code True} if this token is {@code VALUE_NUMBER_INT} or {@code VALUE_NUMBER_FLOAT}, - /// {@code false} otherwise - bool isNumeric() { - return jniAccessors.callMethodWithArgs( - reference, _id_isNumeric, jni.JniCallType.booleanType, []).boolean; - } - - static final _id_isStructStart = - jniAccessors.getMethodIDOf(_classRef, r"isStructStart", r"()Z"); - - /// from: public final boolean isStructStart() - /// - /// Accessor that is functionally equivalent to: - /// - /// this == JsonToken.START_OBJECT || this == JsonToken.START_ARRAY - /// - ///@return {@code True} if this token is {@code START_OBJECT} or {@code START_ARRAY}, - /// {@code false} otherwise - ///@since 2.3 - bool isStructStart() { - return jniAccessors.callMethodWithArgs( - reference, _id_isStructStart, jni.JniCallType.booleanType, []).boolean; - } - - static final _id_isStructEnd = - jniAccessors.getMethodIDOf(_classRef, r"isStructEnd", r"()Z"); - - /// from: public final boolean isStructEnd() - /// - /// Accessor that is functionally equivalent to: - /// - /// this == JsonToken.END_OBJECT || this == JsonToken.END_ARRAY - /// - ///@return {@code True} if this token is {@code END_OBJECT} or {@code END_ARRAY}, - /// {@code false} otherwise - ///@since 2.3 - bool isStructEnd() { - return jniAccessors.callMethodWithArgs( - reference, _id_isStructEnd, jni.JniCallType.booleanType, []).boolean; - } - - static final _id_isScalarValue = - jniAccessors.getMethodIDOf(_classRef, r"isScalarValue", r"()Z"); - - /// from: public final boolean isScalarValue() - /// - /// Method that can be used to check whether this token represents - /// a valid non-structured value. This means all {@code VALUE_xxx} tokens; - /// excluding {@code START_xxx} and {@code END_xxx} tokens as well - /// {@code FIELD_NAME}. - ///@return {@code True} if this token is a scalar value token (one of - /// {@code VALUE_xxx} tokens), {@code false} otherwise - bool isScalarValue() { - return jniAccessors.callMethodWithArgs( - reference, _id_isScalarValue, jni.JniCallType.booleanType, []).boolean; - } - - static final _id_isBoolean = - jniAccessors.getMethodIDOf(_classRef, r"isBoolean", r"()Z"); - - /// from: public final boolean isBoolean() - /// - /// @return {@code True} if this token is {@code VALUE_TRUE} or {@code VALUE_FALSE}, - /// {@code false} otherwise - bool isBoolean() { - return jniAccessors.callMethodWithArgs( - reference, _id_isBoolean, jni.JniCallType.booleanType, []).boolean; - } -} - -class $JsonTokenType extends jni.JObjType { - const $JsonTokenType(); - - @override - String get signature => r"Lcom/fasterxml/jackson/core/JsonToken;"; - - @override - JsonToken fromRef(jni.JObjectPtr ref) => JsonToken.fromRef(ref); - - @override - jni.JObjType get superType => const jni.JObjectType(); - - @override - final superCount = 1; - - @override - int get hashCode => ($JsonTokenType).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JsonTokenType && other is $JsonTokenType; - } -} diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/com/fasterxml/jackson/core/_package.dart b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/com/fasterxml/jackson/core/_package.dart deleted file mode 100644 index cae2a52e6..000000000 --- a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/lib/com/fasterxml/jackson/core/_package.dart +++ /dev/null @@ -1,3 +0,0 @@ -export "JsonFactory.dart"; -export "JsonParser.dart"; -export "JsonToken.dart"; diff --git a/pkgs/jnigen/test/kotlin_test/c_based/dart_bindings/kotlin.dart b/pkgs/jnigen/test/kotlin_test/c_based/dart_bindings/kotlin.dart index 59119b474..b8e33c26f 100644 --- a/pkgs/jnigen/test/kotlin_test/c_based/dart_bindings/kotlin.dart +++ b/pkgs/jnigen/test/kotlin_test/c_based/dart_bindings/kotlin.dart @@ -31,7 +31,7 @@ final ffi.Pointer Function(String sym) jniLookup = /// from: com.github.dart_lang.jnigen.SuspendFun class SuspendFun extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; SuspendFun.fromRef( jni.JObjectPtr ref, @@ -118,6 +118,6 @@ class $SuspendFunType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $SuspendFunType && other is $SuspendFunType; + return other.runtimeType == ($SuspendFunType) && other is $SuspendFunType; } } diff --git a/pkgs/jnigen/test/kotlin_test/dart_only/dart_bindings/kotlin.dart b/pkgs/jnigen/test/kotlin_test/dart_only/dart_bindings/kotlin.dart index f0a475473..a0510088b 100644 --- a/pkgs/jnigen/test/kotlin_test/dart_only/dart_bindings/kotlin.dart +++ b/pkgs/jnigen/test/kotlin_test/dart_only/dart_bindings/kotlin.dart @@ -23,44 +23,39 @@ import "dart:ffi" as ffi; import "package:jni/internal_helpers_for_jnigen.dart"; import "package:jni/jni.dart" as jni; -// Auto-generated initialization code. - -final jniEnv = jni.Jni.env; -final jniAccessors = jni.Jni.accessors; - /// from: com.github.dart_lang.jnigen.SuspendFun class SuspendFun extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; SuspendFun.fromRef( jni.JObjectPtr ref, ) : super.fromRef(ref); - static final _classRef = - jniAccessors.getClassOf(r"com/github/dart_lang/jnigen/SuspendFun"); + static final _class = + jni.Jni.findJClass(r"com/github/dart_lang/jnigen/SuspendFun"); /// The type which includes information such as the signature of this class. static const type = $SuspendFunType(); static final _id_ctor = - jniAccessors.getMethodIDOf(_classRef, r"", r"()V"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory SuspendFun() { - return SuspendFun.fromRef( - jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); + return SuspendFun.fromRef(jni.Jni.accessors + .newObjectWithArgs(_class.reference, _id_ctor, []).object); } - static final _id_sayHello = jniAccessors.getMethodIDOf(_classRef, r"sayHello", - r"(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;"); + static final _id_sayHello = jni.Jni.accessors.getMethodIDOf(_class.reference, + r"sayHello", r"(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;"); /// from: public final java.lang.Object sayHello(kotlin.coroutines.Continuation continuation) /// The returned object must be deleted after use, by calling the `delete` method. Future sayHello() async { final $p = ReceivePort(); final $c = jni.JObject.fromRef(jni.Jni.newPortContinuation($p)); - jniAccessors.callMethodWithArgs(reference, _id_sayHello, + jni.Jni.accessors.callMethodWithArgs(reference, _id_sayHello, jni.JniCallType.objectType, [$c.reference]).object; final $o = jni.JObjectPtr.fromAddress(await $p.first); final $k = const jni.JStringType().getClass().reference; @@ -70,8 +65,8 @@ class SuspendFun extends jni.JObject { return const jni.JStringType().fromRef($o); } - static final _id_sayHello1 = jniAccessors.getMethodIDOf( - _classRef, + static final _id_sayHello1 = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"sayHello", r"(Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;"); @@ -82,7 +77,7 @@ class SuspendFun extends jni.JObject { ) async { final $p = ReceivePort(); final $c = jni.JObject.fromRef(jni.Jni.newPortContinuation($p)); - jniAccessors.callMethodWithArgs(reference, _id_sayHello1, + jni.Jni.accessors.callMethodWithArgs(reference, _id_sayHello1, jni.JniCallType.objectType, [string.reference, $c.reference]).object; final $o = jni.JObjectPtr.fromAddress(await $p.first); final $k = const jni.JStringType().getClass().reference; @@ -113,6 +108,6 @@ class $SuspendFunType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $SuspendFunType && other is $SuspendFunType; + return other.runtimeType == ($SuspendFunType) && other is $SuspendFunType; } } diff --git a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart index 16e99fc67..d8b09c731 100644 --- a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart @@ -31,7 +31,7 @@ final ffi.Pointer Function(String sym) jniLookup = /// from: com.github.dart_lang.jnigen.simple_package.Example class Example extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; Example.fromRef( jni.JObjectPtr ref, @@ -471,8 +471,8 @@ class Example extends jni.JObject { /// from: static public int[] getArr() /// The returned object must be deleted after use, by calling the `delete` method. - static jni.JArray getArr() { - return const jni.JArrayType(jni.JIntType()).fromRef(_getArr().object); + static jni.JArray getArr() { + return const jni.JArrayType(jni.jintType()).fromRef(_getArr().object); } static final _addAll = jniLookup< @@ -482,7 +482,7 @@ class Example extends jni.JObject { /// from: static public int addAll(int[] arr) static int addAll( - jni.JArray arr, + jni.JArray arr, ) { return _addAll(arr.reference).integer; } @@ -531,14 +531,14 @@ class $ExampleType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $ExampleType && other is $ExampleType; + return other.runtimeType == ($ExampleType) && other is $ExampleType; } } /// from: com.github.dart_lang.jnigen.simple_package.Example$Nested class Example_Nested extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; Example_Nested.fromRef( jni.JObjectPtr ref, @@ -605,7 +605,7 @@ class $Example_NestedType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $Example_NestedType && + return other.runtimeType == ($Example_NestedType) && other is $Example_NestedType; } } @@ -613,7 +613,7 @@ class $Example_NestedType extends jni.JObjType { /// from: com.github.dart_lang.jnigen.simple_package.Exceptions class Exceptions extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; Exceptions.fromRef( jni.JObjectPtr ref, @@ -703,8 +703,8 @@ class Exceptions extends jni.JObject { /// from: static public int[] staticIntArrayMethod() /// The returned object must be deleted after use, by calling the `delete` method. - static jni.JArray staticIntArrayMethod() { - return const jni.JArrayType(jni.JIntType()) + static jni.JArray staticIntArrayMethod() { + return const jni.JArrayType(jni.jintType()) .fromRef(_staticIntArrayMethod().object); } @@ -752,8 +752,8 @@ class Exceptions extends jni.JObject { /// from: public int[] intArrayMethod() /// The returned object must be deleted after use, by calling the `delete` method. - jni.JArray intArrayMethod() { - return const jni.JArrayType(jni.JIntType()) + jni.JArray intArrayMethod() { + return const jni.JArrayType(jni.jintType()) .fromRef(_intArrayMethod(reference).object); } @@ -848,14 +848,14 @@ class $ExceptionsType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $ExceptionsType && other is $ExceptionsType; + return other.runtimeType == ($ExceptionsType) && other is $ExceptionsType; } } /// from: com.github.dart_lang.jnigen.simple_package.Fields class Fields extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; Fields.fromRef( jni.JObjectPtr ref, @@ -1103,14 +1103,14 @@ class $FieldsType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $FieldsType && other is $FieldsType; + return other.runtimeType == ($FieldsType) && other is $FieldsType; } } /// from: com.github.dart_lang.jnigen.simple_package.Fields$Nested class Fields_Nested extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; Fields_Nested.fromRef( jni.JObjectPtr ref, @@ -1193,7 +1193,7 @@ class $Fields_NestedType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $Fields_NestedType && + return other.runtimeType == ($Fields_NestedType) && other is $Fields_NestedType; } } @@ -1201,7 +1201,7 @@ class $Fields_NestedType extends jni.JObjType { /// from: com.github.dart_lang.jnigen.pkg2.C2 class C2 extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; C2.fromRef( jni.JObjectPtr ref, @@ -1256,14 +1256,14 @@ class $C2Type extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $C2Type && other is $C2Type; + return other.runtimeType == ($C2Type) && other is $C2Type; } } /// from: com.github.dart_lang.jnigen.pkg2.Example class Example1 extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; Example1.fromRef( jni.JObjectPtr ref, @@ -1313,14 +1313,14 @@ class $Example1Type extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $Example1Type && other is $Example1Type; + return other.runtimeType == ($Example1Type) && other is $Example1Type; } } /// from: com.github.dart_lang.jnigen.generics.GrandParent class GrandParent<$T extends jni.JObject> extends jni.JObject { @override - late final jni.JObjType $type = type(T); + late final jni.JObjType> $type = type(T); final jni.JObjType<$T> T; @@ -1485,8 +1485,8 @@ class $GrandParentType<$T extends jni.JObject> @override bool operator ==(Object other) { - return other.runtimeType == $GrandParentType && - other is $GrandParentType && + return other.runtimeType == ($GrandParentType<$T>) && + other is $GrandParentType<$T> && T == other.T; } } @@ -1495,7 +1495,7 @@ class $GrandParentType<$T extends jni.JObject> class GrandParent_Parent<$T extends jni.JObject, $S extends jni.JObject> extends jni.JObject { @override - late final jni.JObjType $type = type(T, S); + late final jni.JObjType> $type = type(T, S); final jni.JObjType<$T> T; final jni.JObjType<$S> S; @@ -1626,8 +1626,8 @@ class $GrandParent_ParentType<$T extends jni.JObject, $S extends jni.JObject> @override bool operator ==(Object other) { - return other.runtimeType == $GrandParent_ParentType && - other is $GrandParent_ParentType && + return other.runtimeType == ($GrandParent_ParentType<$T, $S>) && + other is $GrandParent_ParentType<$T, $S> && T == other.T && S == other.S; } @@ -1637,7 +1637,8 @@ class $GrandParent_ParentType<$T extends jni.JObject, $S extends jni.JObject> class GrandParent_Parent_Child<$T extends jni.JObject, $S extends jni.JObject, $U extends jni.JObject> extends jni.JObject { @override - late final jni.JObjType $type = type(T, S, U); + late final jni.JObjType> $type = + type(T, S, U); final jni.JObjType<$T> T; final jni.JObjType<$S> S; @@ -1815,8 +1816,8 @@ class $GrandParent_Parent_ChildType<$T extends jni.JObject, @override bool operator ==(Object other) { - return other.runtimeType == $GrandParent_Parent_ChildType && - other is $GrandParent_Parent_ChildType && + return other.runtimeType == ($GrandParent_Parent_ChildType<$T, $S, $U>) && + other is $GrandParent_Parent_ChildType<$T, $S, $U> && T == other.T && S == other.S && U == other.U; @@ -1826,7 +1827,7 @@ class $GrandParent_Parent_ChildType<$T extends jni.JObject, /// from: com.github.dart_lang.jnigen.generics.GrandParent$StaticParent class GrandParent_StaticParent<$S extends jni.JObject> extends jni.JObject { @override - late final jni.JObjType $type = type(S); + late final jni.JObjType> $type = type(S); final jni.JObjType<$S> S; @@ -1916,8 +1917,8 @@ class $GrandParent_StaticParentType<$S extends jni.JObject> @override bool operator ==(Object other) { - return other.runtimeType == $GrandParent_StaticParentType && - other is $GrandParent_StaticParentType && + return other.runtimeType == ($GrandParent_StaticParentType<$S>) && + other is $GrandParent_StaticParentType<$S> && S == other.S; } } @@ -1926,7 +1927,8 @@ class $GrandParent_StaticParentType<$S extends jni.JObject> class GrandParent_StaticParent_Child<$S extends jni.JObject, $U extends jni.JObject> extends jni.JObject { @override - late final jni.JObjType $type = type(S, U); + late final jni.JObjType> $type = + type(S, U); final jni.JObjType<$S> S; final jni.JObjType<$U> U; @@ -2060,8 +2062,8 @@ class $GrandParent_StaticParent_ChildType<$S extends jni.JObject, @override bool operator ==(Object other) { - return other.runtimeType == $GrandParent_StaticParent_ChildType && - other is $GrandParent_StaticParent_ChildType && + return other.runtimeType == ($GrandParent_StaticParent_ChildType<$S, $U>) && + other is $GrandParent_StaticParent_ChildType<$S, $U> && S == other.S && U == other.U; } @@ -2071,7 +2073,7 @@ class $GrandParent_StaticParent_ChildType<$S extends jni.JObject, class MyMap<$K extends jni.JObject, $V extends jni.JObject> extends jni.JObject { @override - late final jni.JObjType $type = type(K, V); + late final jni.JObjType> $type = type(K, V); final jni.JObjType<$K> K; final jni.JObjType<$V> V; @@ -2182,8 +2184,8 @@ class $MyMapType<$K extends jni.JObject, $V extends jni.JObject> @override bool operator ==(Object other) { - return other.runtimeType == $MyMapType && - other is $MyMapType && + return other.runtimeType == ($MyMapType<$K, $V>) && + other is $MyMapType<$K, $V> && K == other.K && V == other.V; } @@ -2193,7 +2195,7 @@ class $MyMapType<$K extends jni.JObject, $V extends jni.JObject> class MyMap_MyEntry<$K extends jni.JObject, $V extends jni.JObject> extends jni.JObject { @override - late final jni.JObjType $type = type(K, V); + late final jni.JObjType> $type = type(K, V); final jni.JObjType<$K> K; final jni.JObjType<$V> V; @@ -2322,8 +2324,8 @@ class $MyMap_MyEntryType<$K extends jni.JObject, $V extends jni.JObject> @override bool operator ==(Object other) { - return other.runtimeType == $MyMap_MyEntryType && - other is $MyMap_MyEntryType && + return other.runtimeType == ($MyMap_MyEntryType<$K, $V>) && + other is $MyMap_MyEntryType<$K, $V> && K == other.K && V == other.V; } @@ -2332,7 +2334,7 @@ class $MyMap_MyEntryType<$K extends jni.JObject, $V extends jni.JObject> /// from: com.github.dart_lang.jnigen.generics.MyStack class MyStack<$T extends jni.JObject> extends jni.JObject { @override - late final jni.JObjType $type = type(T); + late final jni.JObjType> $type = type(T); final jni.JObjType<$T> T; @@ -2514,8 +2516,8 @@ class $MyStackType<$T extends jni.JObject> extends jni.JObjType> { @override bool operator ==(Object other) { - return other.runtimeType == $MyStackType && - other is $MyStackType && + return other.runtimeType == ($MyStackType<$T>) && + other is $MyStackType<$T> && T == other.T; } } @@ -2523,7 +2525,7 @@ class $MyStackType<$T extends jni.JObject> extends jni.JObjType> { /// from: com.github.dart_lang.jnigen.generics.StringKeyedMap class StringKeyedMap<$V extends jni.JObject> extends MyMap { @override - late final jni.JObjType $type = type(V); + late final jni.JObjType> $type = type(V); final jni.JObjType<$V> V; @@ -2581,8 +2583,8 @@ class $StringKeyedMapType<$V extends jni.JObject> @override bool operator ==(Object other) { - return other.runtimeType == $StringKeyedMapType && - other is $StringKeyedMapType && + return other.runtimeType == ($StringKeyedMapType<$V>) && + other is $StringKeyedMapType<$V> && V == other.V; } } @@ -2590,7 +2592,7 @@ class $StringKeyedMapType<$V extends jni.JObject> /// from: com.github.dart_lang.jnigen.generics.StringMap class StringMap extends StringKeyedMap { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; StringMap.fromRef( jni.JObjectPtr ref, @@ -2629,14 +2631,14 @@ class $StringMapType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $StringMapType && other is $StringMapType; + return other.runtimeType == ($StringMapType) && other is $StringMapType; } } /// from: com.github.dart_lang.jnigen.generics.StringStack class StringStack extends MyStack { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; StringStack.fromRef( jni.JObjectPtr ref, @@ -2675,14 +2677,14 @@ class $StringStackType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $StringStackType && other is $StringStackType; + return other.runtimeType == ($StringStackType) && other is $StringStackType; } } /// from: com.github.dart_lang.jnigen.generics.StringValuedMap class StringValuedMap<$K extends jni.JObject> extends MyMap<$K, jni.JString> { @override - late final jni.JObjType $type = type(K); + late final jni.JObjType> $type = type(K); final jni.JObjType<$K> K; @@ -2740,8 +2742,8 @@ class $StringValuedMapType<$K extends jni.JObject> @override bool operator ==(Object other) { - return other.runtimeType == $StringValuedMapType && - other is $StringValuedMapType && + return other.runtimeType == ($StringValuedMapType<$K>) && + other is $StringValuedMapType<$K> && K == other.K; } } @@ -2749,7 +2751,7 @@ class $StringValuedMapType<$K extends jni.JObject> /// from: com.github.dart_lang.jnigen.annotations.JsonSerializable$Case class JsonSerializable_Case extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; JsonSerializable_Case.fromRef( jni.JObjectPtr ref, @@ -2807,7 +2809,7 @@ class $JsonSerializable_CaseType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $JsonSerializable_CaseType && + return other.runtimeType == ($JsonSerializable_CaseType) && other is $JsonSerializable_CaseType; } } @@ -2815,7 +2817,7 @@ class $JsonSerializable_CaseType extends jni.JObjType { /// from: com.github.dart_lang.jnigen.annotations.MyDataClass class MyDataClass extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; MyDataClass.fromRef( jni.JObjectPtr ref, @@ -2855,6 +2857,6 @@ class $MyDataClassType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $MyDataClassType && other is $MyDataClassType; + return other.runtimeType == ($MyDataClassType) && other is $MyDataClassType; } } diff --git a/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart index d1c4bdbad..24b9657cb 100644 --- a/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart @@ -23,22 +23,17 @@ import "dart:ffi" as ffi; import "package:jni/internal_helpers_for_jnigen.dart"; import "package:jni/jni.dart" as jni; -// Auto-generated initialization code. - -final jniEnv = jni.Jni.env; -final jniAccessors = jni.Jni.accessors; - /// from: com.github.dart_lang.jnigen.simple_package.Example class Example extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; Example.fromRef( jni.JObjectPtr ref, ) : super.fromRef(ref); - static final _classRef = jniAccessors - .getClassOf(r"com/github/dart_lang/jnigen/simple_package/Example"); + static final _class = + jni.Jni.findJClass(r"com/github/dart_lang/jnigen/simple_package/Example"); /// The type which includes information such as the signature of this class. static const type = $ExampleType(); @@ -58,81 +53,84 @@ class Example extends jni.JObject { /// from: static public final java.lang.String SEMICOLON_STRING static const SEMICOLON_STRING = r""";"""; - static final _id_getAmount = - jniAccessors.getStaticMethodIDOf(_classRef, r"getAmount", r"()I"); + static final _id_getAmount = jni.Jni.accessors + .getStaticMethodIDOf(_class.reference, r"getAmount", r"()I"); /// from: static public int getAmount() static int getAmount() { - return jniAccessors.callStaticMethodWithArgs( - _classRef, _id_getAmount, jni.JniCallType.intType, []).integer; + return jni.Jni.accessors.callStaticMethodWithArgs( + _class.reference, _id_getAmount, jni.JniCallType.intType, []).integer; } static final _id_getPi = - jniAccessors.getStaticMethodIDOf(_classRef, r"getPi", r"()D"); + jni.Jni.accessors.getStaticMethodIDOf(_class.reference, r"getPi", r"()D"); /// from: static public double getPi() static double getPi() { - return jniAccessors.callStaticMethodWithArgs( - _classRef, _id_getPi, jni.JniCallType.doubleType, []).doubleFloat; + return jni.Jni.accessors.callStaticMethodWithArgs(_class.reference, + _id_getPi, jni.JniCallType.doubleType, []).doubleFloat; } - static final _id_getAsterisk = - jniAccessors.getStaticMethodIDOf(_classRef, r"getAsterisk", r"()C"); + static final _id_getAsterisk = jni.Jni.accessors + .getStaticMethodIDOf(_class.reference, r"getAsterisk", r"()C"); /// from: static public char getAsterisk() static int getAsterisk() { - return jniAccessors.callStaticMethodWithArgs( - _classRef, _id_getAsterisk, jni.JniCallType.charType, []).char; + return jni.Jni.accessors.callStaticMethodWithArgs( + _class.reference, _id_getAsterisk, jni.JniCallType.charType, []).char; } - static final _id_getName = jniAccessors.getStaticMethodIDOf( - _classRef, r"getName", r"()Ljava/lang/String;"); + static final _id_getName = jni.Jni.accessors.getStaticMethodIDOf( + _class.reference, r"getName", r"()Ljava/lang/String;"); /// from: static public java.lang.String getName() /// The returned object must be deleted after use, by calling the `delete` method. static jni.JString getName() { - return const jni.JStringType().fromRef(jniAccessors - .callStaticMethodWithArgs( - _classRef, _id_getName, jni.JniCallType.objectType, []).object); + return const jni.JStringType().fromRef(jni.Jni.accessors + .callStaticMethodWithArgs(_class.reference, _id_getName, + jni.JniCallType.objectType, []).object); } - static final _id_getNestedInstance = jniAccessors.getStaticMethodIDOf( - _classRef, + static final _id_getNestedInstance = jni.Jni.accessors.getStaticMethodIDOf( + _class.reference, r"getNestedInstance", r"()Lcom/github/dart_lang/jnigen/simple_package/Example$Nested;"); /// from: static public com.github.dart_lang.jnigen.simple_package.Example.Nested getNestedInstance() /// The returned object must be deleted after use, by calling the `delete` method. static Example_Nested getNestedInstance() { - return const $Example_NestedType().fromRef(jniAccessors - .callStaticMethodWithArgs(_classRef, _id_getNestedInstance, + return const $Example_NestedType().fromRef(jni.Jni.accessors + .callStaticMethodWithArgs(_class.reference, _id_getNestedInstance, jni.JniCallType.objectType, []).object); } - static final _id_setAmount = - jniAccessors.getStaticMethodIDOf(_classRef, r"setAmount", r"(I)V"); + static final _id_setAmount = jni.Jni.accessors + .getStaticMethodIDOf(_class.reference, r"setAmount", r"(I)V"); /// from: static public void setAmount(int newAmount) static void setAmount( int newAmount, ) { - return jniAccessors.callStaticMethodWithArgs(_classRef, _id_setAmount, - jni.JniCallType.voidType, [jni.JValueInt(newAmount)]).check(); + return jni.Jni.accessors.callStaticMethodWithArgs( + _class.reference, + _id_setAmount, + jni.JniCallType.voidType, + [jni.JValueInt(newAmount)]).check(); } - static final _id_setName = jniAccessors.getStaticMethodIDOf( - _classRef, r"setName", r"(Ljava/lang/String;)V"); + static final _id_setName = jni.Jni.accessors.getStaticMethodIDOf( + _class.reference, r"setName", r"(Ljava/lang/String;)V"); /// from: static public void setName(java.lang.String newName) static void setName( jni.JString newName, ) { - return jniAccessors.callStaticMethodWithArgs(_classRef, _id_setName, - jni.JniCallType.voidType, [newName.reference]).check(); + return jni.Jni.accessors.callStaticMethodWithArgs(_class.reference, + _id_setName, jni.JniCallType.voidType, [newName.reference]).check(); } - static final _id_setNestedInstance = jniAccessors.getStaticMethodIDOf( - _classRef, + static final _id_setNestedInstance = jni.Jni.accessors.getStaticMethodIDOf( + _class.reference, r"setNestedInstance", r"(Lcom/github/dart_lang/jnigen/simple_package/Example$Nested;)V"); @@ -140,15 +138,15 @@ class Example extends jni.JObject { static void setNestedInstance( Example_Nested newNested, ) { - return jniAccessors.callStaticMethodWithArgs( - _classRef, + return jni.Jni.accessors.callStaticMethodWithArgs( + _class.reference, _id_setNestedInstance, jni.JniCallType.voidType, [newNested.reference]).check(); } - static final _id_max4 = - jniAccessors.getStaticMethodIDOf(_classRef, r"max4", r"(IIII)I"); + static final _id_max4 = jni.Jni.accessors + .getStaticMethodIDOf(_class.reference, r"max4", r"(IIII)I"); /// from: static public int max4(int a, int b, int c, int d) static int max4( @@ -157,8 +155,8 @@ class Example extends jni.JObject { int c, int d, ) { - return jniAccessors.callStaticMethodWithArgs( - _classRef, _id_max4, jni.JniCallType.intType, [ + return jni.Jni.accessors.callStaticMethodWithArgs( + _class.reference, _id_max4, jni.JniCallType.intType, [ jni.JValueInt(a), jni.JValueInt(b), jni.JValueInt(c), @@ -166,8 +164,8 @@ class Example extends jni.JObject { ]).integer; } - static final _id_max8 = - jniAccessors.getStaticMethodIDOf(_classRef, r"max8", r"(IIIIIIII)I"); + static final _id_max8 = jni.Jni.accessors + .getStaticMethodIDOf(_class.reference, r"max8", r"(IIIIIIII)I"); /// from: static public int max8(int a, int b, int c, int d, int e, int f, int g, int h) static int max8( @@ -180,8 +178,8 @@ class Example extends jni.JObject { int g, int h, ) { - return jniAccessors.callStaticMethodWithArgs( - _classRef, _id_max8, jni.JniCallType.intType, [ + return jni.Jni.accessors.callStaticMethodWithArgs( + _class.reference, _id_max8, jni.JniCallType.intType, [ jni.JValueInt(a), jni.JValueInt(b), jni.JValueInt(c), @@ -194,98 +192,98 @@ class Example extends jni.JObject { } static final _id_getNumber = - jniAccessors.getMethodIDOf(_classRef, r"getNumber", r"()I"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"getNumber", r"()I"); /// from: public int getNumber() int getNumber() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_getNumber, jni.JniCallType.intType, []).integer; } static final _id_setNumber = - jniAccessors.getMethodIDOf(_classRef, r"setNumber", r"(I)V"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"setNumber", r"(I)V"); /// from: public void setNumber(int number) void setNumber( int number, ) { - return jniAccessors.callMethodWithArgs(reference, _id_setNumber, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_setNumber, jni.JniCallType.voidType, [jni.JValueInt(number)]).check(); } static final _id_getIsUp = - jniAccessors.getMethodIDOf(_classRef, r"getIsUp", r"()Z"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"getIsUp", r"()Z"); /// from: public boolean getIsUp() bool getIsUp() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_getIsUp, jni.JniCallType.booleanType, []).boolean; } static final _id_setUp = - jniAccessors.getMethodIDOf(_classRef, r"setUp", r"(Z)V"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"setUp", r"(Z)V"); /// from: public void setUp(boolean isUp) void setUp( bool isUp, ) { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_setUp, jni.JniCallType.voidType, [isUp ? 1 : 0]).check(); } - static final _id_getCodename = jniAccessors.getMethodIDOf( - _classRef, r"getCodename", r"()Ljava/lang/String;"); + static final _id_getCodename = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"getCodename", r"()Ljava/lang/String;"); /// from: public java.lang.String getCodename() /// The returned object must be deleted after use, by calling the `delete` method. jni.JString getCodename() { - return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JStringType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getCodename, jni.JniCallType.objectType, []).object); } - static final _id_setCodename = jniAccessors.getMethodIDOf( - _classRef, r"setCodename", r"(Ljava/lang/String;)V"); + static final _id_setCodename = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"setCodename", r"(Ljava/lang/String;)V"); /// from: public void setCodename(java.lang.String codename) void setCodename( jni.JString codename, ) { - return jniAccessors.callMethodWithArgs(reference, _id_setCodename, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_setCodename, jni.JniCallType.voidType, [codename.reference]).check(); } - static final _id_getRandom = jniAccessors.getMethodIDOf( - _classRef, r"getRandom", r"()Ljava/util/Random;"); + static final _id_getRandom = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"getRandom", r"()Ljava/util/Random;"); /// from: public java.util.Random getRandom() /// The returned object must be deleted after use, by calling the `delete` method. jni.JObject getRandom() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getRandom, jni.JniCallType.objectType, []).object); } - static final _id_setRandom = jniAccessors.getMethodIDOf( - _classRef, r"setRandom", r"(Ljava/util/Random;)V"); + static final _id_setRandom = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"setRandom", r"(Ljava/util/Random;)V"); /// from: public void setRandom(java.util.Random random) void setRandom( jni.JObject random, ) { - return jniAccessors.callMethodWithArgs(reference, _id_setRandom, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_setRandom, jni.JniCallType.voidType, [random.reference]).check(); } - static final _id_getRandomLong = - jniAccessors.getMethodIDOf(_classRef, r"getRandomLong", r"()J"); + static final _id_getRandomLong = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"getRandomLong", r"()J"); /// from: public long getRandomLong() int getRandomLong() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_getRandomLong, jni.JniCallType.longType, []).long; } - static final _id_add4Longs = - jniAccessors.getMethodIDOf(_classRef, r"add4Longs", r"(JJJJ)J"); + static final _id_add4Longs = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"add4Longs", r"(JJJJ)J"); /// from: public long add4Longs(long a, long b, long c, long d) int add4Longs( @@ -294,12 +292,12 @@ class Example extends jni.JObject { int c, int d, ) { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_add4Longs, jni.JniCallType.longType, [a, b, c, d]).long; } - static final _id_add8Longs = - jniAccessors.getMethodIDOf(_classRef, r"add8Longs", r"(JJJJJJJJ)J"); + static final _id_add8Longs = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"add8Longs", r"(JJJJJJJJ)J"); /// from: public long add8Longs(long a, long b, long c, long d, long e, long f, long g, long h) int add8Longs( @@ -312,12 +310,12 @@ class Example extends jni.JObject { int g, int h, ) { - return jniAccessors.callMethodWithArgs(reference, _id_add8Longs, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_add8Longs, jni.JniCallType.longType, [a, b, c, d, e, f, g, h]).long; } - static final _id_getRandomNumericString = jniAccessors.getMethodIDOf( - _classRef, + static final _id_getRandomNumericString = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"getRandomNumericString", r"(Ljava/util/Random;)Ljava/lang/String;"); @@ -326,7 +324,7 @@ class Example extends jni.JObject { jni.JString getRandomNumericString( jni.JObject random, ) { - return const jni.JStringType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JStringType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getRandomNumericString, jni.JniCallType.objectType, @@ -334,29 +332,29 @@ class Example extends jni.JObject { } static final _id_ctor = - jniAccessors.getMethodIDOf(_classRef, r"", r"()V"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory Example() { - return Example.fromRef( - jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); + return Example.fromRef(jni.Jni.accessors + .newObjectWithArgs(_class.reference, _id_ctor, []).object); } static final _id_ctor1 = - jniAccessors.getMethodIDOf(_classRef, r"", r"(I)V"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"(I)V"); /// from: public void (int number) /// The returned object must be deleted after use, by calling the `delete` method. factory Example.ctor1( int number, ) { - return Example.fromRef(jniAccessors.newObjectWithArgs( - _classRef, _id_ctor1, [jni.JValueInt(number)]).object); + return Example.fromRef(jni.Jni.accessors.newObjectWithArgs( + _class.reference, _id_ctor1, [jni.JValueInt(number)]).object); } static final _id_ctor2 = - jniAccessors.getMethodIDOf(_classRef, r"", r"(IZ)V"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"(IZ)V"); /// from: public void (int number, boolean isUp) /// The returned object must be deleted after use, by calling the `delete` method. @@ -364,12 +362,12 @@ class Example extends jni.JObject { int number, bool isUp, ) { - return Example.fromRef(jniAccessors.newObjectWithArgs( - _classRef, _id_ctor2, [jni.JValueInt(number), isUp ? 1 : 0]).object); + return Example.fromRef(jni.Jni.accessors.newObjectWithArgs(_class.reference, + _id_ctor2, [jni.JValueInt(number), isUp ? 1 : 0]).object); } - static final _id_ctor3 = jniAccessors.getMethodIDOf( - _classRef, r"", r"(IZLjava/lang/String;)V"); + static final _id_ctor3 = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"", r"(IZLjava/lang/String;)V"); /// from: public void (int number, boolean isUp, java.lang.String codename) /// The returned object must be deleted after use, by calling the `delete` method. @@ -378,12 +376,14 @@ class Example extends jni.JObject { bool isUp, jni.JString codename, ) { - return Example.fromRef(jniAccessors.newObjectWithArgs(_classRef, _id_ctor3, + return Example.fromRef(jni.Jni.accessors.newObjectWithArgs( + _class.reference, + _id_ctor3, [jni.JValueInt(number), isUp ? 1 : 0, codename.reference]).object); } - static final _id_ctor4 = - jniAccessors.getMethodIDOf(_classRef, r"", r"(IIIIIIII)V"); + static final _id_ctor4 = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"", r"(IIIIIIII)V"); /// from: public void (int a, int b, int c, int d, int e, int f, int g, int h) /// The returned object must be deleted after use, by calling the `delete` method. @@ -398,7 +398,7 @@ class Example extends jni.JObject { int h, ) { return Example.fromRef( - jniAccessors.newObjectWithArgs(_classRef, _id_ctor4, [ + jni.Jni.accessors.newObjectWithArgs(_class.reference, _id_ctor4, [ jni.JValueInt(a), jni.JValueInt(b), jni.JValueInt(c), @@ -410,66 +410,69 @@ class Example extends jni.JObject { ]).object); } - static final _id_whichExample = - jniAccessors.getMethodIDOf(_classRef, r"whichExample", r"()I"); + static final _id_whichExample = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"whichExample", r"()I"); /// from: public int whichExample() int whichExample() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_whichExample, jni.JniCallType.intType, []).integer; } - static final _id_addInts = - jniAccessors.getStaticMethodIDOf(_classRef, r"addInts", r"(II)I"); + static final _id_addInts = jni.Jni.accessors + .getStaticMethodIDOf(_class.reference, r"addInts", r"(II)I"); /// from: static public int addInts(int a, int b) static int addInts( int a, int b, ) { - return jniAccessors.callStaticMethodWithArgs(_classRef, _id_addInts, - jni.JniCallType.intType, [jni.JValueInt(a), jni.JValueInt(b)]).integer; + return jni.Jni.accessors.callStaticMethodWithArgs( + _class.reference, + _id_addInts, + jni.JniCallType.intType, + [jni.JValueInt(a), jni.JValueInt(b)]).integer; } - static final _id_getArr = - jniAccessors.getStaticMethodIDOf(_classRef, r"getArr", r"()[I"); + static final _id_getArr = jni.Jni.accessors + .getStaticMethodIDOf(_class.reference, r"getArr", r"()[I"); /// from: static public int[] getArr() /// The returned object must be deleted after use, by calling the `delete` method. - static jni.JArray getArr() { - return const jni.JArrayType(jni.JIntType()).fromRef(jniAccessors - .callStaticMethodWithArgs( - _classRef, _id_getArr, jni.JniCallType.objectType, []).object); + static jni.JArray getArr() { + return const jni.JArrayType(jni.jintType()).fromRef(jni.Jni.accessors + .callStaticMethodWithArgs(_class.reference, _id_getArr, + jni.JniCallType.objectType, []).object); } - static final _id_addAll = - jniAccessors.getStaticMethodIDOf(_classRef, r"addAll", r"([I)I"); + static final _id_addAll = jni.Jni.accessors + .getStaticMethodIDOf(_class.reference, r"addAll", r"([I)I"); /// from: static public int addAll(int[] arr) static int addAll( - jni.JArray arr, + jni.JArray arr, ) { - return jniAccessors.callStaticMethodWithArgs(_classRef, _id_addAll, - jni.JniCallType.intType, [arr.reference]).integer; + return jni.Jni.accessors.callStaticMethodWithArgs(_class.reference, + _id_addAll, jni.JniCallType.intType, [arr.reference]).integer; } - static final _id_getSelf = jniAccessors.getMethodIDOf(_classRef, r"getSelf", - r"()Lcom/github/dart_lang/jnigen/simple_package/Example;"); + static final _id_getSelf = jni.Jni.accessors.getMethodIDOf(_class.reference, + r"getSelf", r"()Lcom/github/dart_lang/jnigen/simple_package/Example;"); /// from: public com.github.dart_lang.jnigen.simple_package.Example getSelf() /// The returned object must be deleted after use, by calling the `delete` method. Example getSelf() { - return const $ExampleType().fromRef(jniAccessors.callMethodWithArgs( + return const $ExampleType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getSelf, jni.JniCallType.objectType, []).object); } - static final _id_throwException = - jniAccessors.getStaticMethodIDOf(_classRef, r"throwException", r"()V"); + static final _id_throwException = jni.Jni.accessors + .getStaticMethodIDOf(_class.reference, r"throwException", r"()V"); /// from: static public void throwException() static void throwException() { - return jniAccessors.callStaticMethodWithArgs( - _classRef, _id_throwException, jni.JniCallType.voidType, []).check(); + return jni.Jni.accessors.callStaticMethodWithArgs(_class.reference, + _id_throwException, jni.JniCallType.voidType, []).check(); } } @@ -494,53 +497,53 @@ class $ExampleType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $ExampleType && other is $ExampleType; + return other.runtimeType == ($ExampleType) && other is $ExampleType; } } /// from: com.github.dart_lang.jnigen.simple_package.Example$Nested class Example_Nested extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; Example_Nested.fromRef( jni.JObjectPtr ref, ) : super.fromRef(ref); - static final _classRef = jniAccessors - .getClassOf(r"com/github/dart_lang/jnigen/simple_package/Example$Nested"); + static final _class = jni.Jni.findJClass( + r"com/github/dart_lang/jnigen/simple_package/Example$Nested"); /// The type which includes information such as the signature of this class. static const type = $Example_NestedType(); static final _id_ctor = - jniAccessors.getMethodIDOf(_classRef, r"", r"(Z)V"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"(Z)V"); /// from: public void (boolean value) /// The returned object must be deleted after use, by calling the `delete` method. factory Example_Nested( bool value, ) { - return Example_Nested.fromRef(jniAccessors - .newObjectWithArgs(_classRef, _id_ctor, [value ? 1 : 0]).object); + return Example_Nested.fromRef(jni.Jni.accessors + .newObjectWithArgs(_class.reference, _id_ctor, [value ? 1 : 0]).object); } static final _id_getValue = - jniAccessors.getMethodIDOf(_classRef, r"getValue", r"()Z"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"getValue", r"()Z"); /// from: public boolean getValue() bool getValue() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_getValue, jni.JniCallType.booleanType, []).boolean; } static final _id_setValue = - jniAccessors.getMethodIDOf(_classRef, r"setValue", r"(Z)V"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"setValue", r"(Z)V"); /// from: public void setValue(boolean value) void setValue( bool value, ) { - return jniAccessors.callMethodWithArgs(reference, _id_setValue, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_setValue, jni.JniCallType.voidType, [value ? 1 : 0]).check(); } } @@ -566,7 +569,7 @@ class $Example_NestedType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $Example_NestedType && + return other.runtimeType == ($Example_NestedType) && other is $Example_NestedType; } } @@ -574,41 +577,41 @@ class $Example_NestedType extends jni.JObjType { /// from: com.github.dart_lang.jnigen.simple_package.Exceptions class Exceptions extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; Exceptions.fromRef( jni.JObjectPtr ref, ) : super.fromRef(ref); - static final _classRef = jniAccessors - .getClassOf(r"com/github/dart_lang/jnigen/simple_package/Exceptions"); + static final _class = jni.Jni.findJClass( + r"com/github/dart_lang/jnigen/simple_package/Exceptions"); /// The type which includes information such as the signature of this class. static const type = $ExceptionsType(); static final _id_ctor = - jniAccessors.getMethodIDOf(_classRef, r"", r"()V"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory Exceptions() { - return Exceptions.fromRef( - jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); + return Exceptions.fromRef(jni.Jni.accessors + .newObjectWithArgs(_class.reference, _id_ctor, []).object); } static final _id_ctor1 = - jniAccessors.getMethodIDOf(_classRef, r"", r"(F)V"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"(F)V"); /// from: public void (float x) /// The returned object must be deleted after use, by calling the `delete` method. factory Exceptions.ctor1( double x, ) { - return Exceptions.fromRef(jniAccessors - .newObjectWithArgs(_classRef, _id_ctor1, [jni.JValueFloat(x)]).object); + return Exceptions.fromRef(jni.Jni.accessors.newObjectWithArgs( + _class.reference, _id_ctor1, [jni.JValueFloat(x)]).object); } - static final _id_ctor2 = - jniAccessors.getMethodIDOf(_classRef, r"", r"(IIIIII)V"); + static final _id_ctor2 = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"", r"(IIIIII)V"); /// from: public void (int a, int b, int c, int d, int e, int f) /// The returned object must be deleted after use, by calling the `delete` method. @@ -621,7 +624,7 @@ class Exceptions extends jni.JObject { int f, ) { return Exceptions.fromRef( - jniAccessors.newObjectWithArgs(_classRef, _id_ctor2, [ + jni.Jni.accessors.newObjectWithArgs(_class.reference, _id_ctor2, [ jni.JValueInt(a), jni.JValueInt(b), jni.JValueInt(c), @@ -631,147 +634,152 @@ class Exceptions extends jni.JObject { ]).object); } - static final _id_staticObjectMethod = jniAccessors.getStaticMethodIDOf( - _classRef, r"staticObjectMethod", r"()Ljava/lang/Object;"); + static final _id_staticObjectMethod = jni.Jni.accessors.getStaticMethodIDOf( + _class.reference, r"staticObjectMethod", r"()Ljava/lang/Object;"); /// from: static public java.lang.Object staticObjectMethod() /// The returned object must be deleted after use, by calling the `delete` method. static jni.JObject staticObjectMethod() { - return const jni.JObjectType().fromRef(jniAccessors - .callStaticMethodWithArgs(_classRef, _id_staticObjectMethod, + return const jni.JObjectType().fromRef(jni.Jni.accessors + .callStaticMethodWithArgs(_class.reference, _id_staticObjectMethod, jni.JniCallType.objectType, []).object); } - static final _id_staticIntMethod = - jniAccessors.getStaticMethodIDOf(_classRef, r"staticIntMethod", r"()I"); + static final _id_staticIntMethod = jni.Jni.accessors + .getStaticMethodIDOf(_class.reference, r"staticIntMethod", r"()I"); /// from: static public int staticIntMethod() static int staticIntMethod() { - return jniAccessors.callStaticMethodWithArgs( - _classRef, _id_staticIntMethod, jni.JniCallType.intType, []).integer; + return jni.Jni.accessors.callStaticMethodWithArgs(_class.reference, + _id_staticIntMethod, jni.JniCallType.intType, []).integer; } - static final _id_staticObjectArrayMethod = jniAccessors.getStaticMethodIDOf( - _classRef, r"staticObjectArrayMethod", r"()[Ljava/lang/Object;"); + static final _id_staticObjectArrayMethod = jni.Jni.accessors + .getStaticMethodIDOf(_class.reference, r"staticObjectArrayMethod", + r"()[Ljava/lang/Object;"); /// from: static public java.lang.Object[] staticObjectArrayMethod() /// The returned object must be deleted after use, by calling the `delete` method. static jni.JArray staticObjectArrayMethod() { - return const jni.JArrayType(jni.JObjectType()).fromRef(jniAccessors - .callStaticMethodWithArgs(_classRef, _id_staticObjectArrayMethod, + return const jni.JArrayType(jni.JObjectType()).fromRef(jni.Jni.accessors + .callStaticMethodWithArgs(_class.reference, _id_staticObjectArrayMethod, jni.JniCallType.objectType, []).object); } - static final _id_staticIntArrayMethod = jniAccessors.getStaticMethodIDOf( - _classRef, r"staticIntArrayMethod", r"()[I"); + static final _id_staticIntArrayMethod = jni.Jni.accessors + .getStaticMethodIDOf(_class.reference, r"staticIntArrayMethod", r"()[I"); /// from: static public int[] staticIntArrayMethod() /// The returned object must be deleted after use, by calling the `delete` method. - static jni.JArray staticIntArrayMethod() { - return const jni.JArrayType(jni.JIntType()).fromRef(jniAccessors - .callStaticMethodWithArgs(_classRef, _id_staticIntArrayMethod, + static jni.JArray staticIntArrayMethod() { + return const jni.JArrayType(jni.jintType()).fromRef(jni.Jni.accessors + .callStaticMethodWithArgs(_class.reference, _id_staticIntArrayMethod, jni.JniCallType.objectType, []).object); } - static final _id_objectMethod = jniAccessors.getMethodIDOf( - _classRef, r"objectMethod", r"()Ljava/lang/Object;"); + static final _id_objectMethod = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"objectMethod", r"()Ljava/lang/Object;"); /// from: public java.lang.Object objectMethod() /// The returned object must be deleted after use, by calling the `delete` method. jni.JObject objectMethod() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_objectMethod, jni.JniCallType.objectType, []).object); } static final _id_intMethod = - jniAccessors.getMethodIDOf(_classRef, r"intMethod", r"()I"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"intMethod", r"()I"); /// from: public int intMethod() int intMethod() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_intMethod, jni.JniCallType.intType, []).integer; } - static final _id_objectArrayMethod = jniAccessors.getMethodIDOf( - _classRef, r"objectArrayMethod", r"()[Ljava/lang/Object;"); + static final _id_objectArrayMethod = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"objectArrayMethod", r"()[Ljava/lang/Object;"); /// from: public java.lang.Object[] objectArrayMethod() /// The returned object must be deleted after use, by calling the `delete` method. jni.JArray objectArrayMethod() { - return const jni.JArrayType(jni.JObjectType()).fromRef(jniAccessors + return const jni.JArrayType(jni.JObjectType()).fromRef(jni.Jni.accessors .callMethodWithArgs(reference, _id_objectArrayMethod, jni.JniCallType.objectType, []).object); } - static final _id_intArrayMethod = - jniAccessors.getMethodIDOf(_classRef, r"intArrayMethod", r"()[I"); + static final _id_intArrayMethod = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"intArrayMethod", r"()[I"); /// from: public int[] intArrayMethod() /// The returned object must be deleted after use, by calling the `delete` method. - jni.JArray intArrayMethod() { - return const jni.JArrayType(jni.JIntType()).fromRef(jniAccessors + jni.JArray intArrayMethod() { + return const jni.JArrayType(jni.jintType()).fromRef(jni.Jni.accessors .callMethodWithArgs(reference, _id_intArrayMethod, jni.JniCallType.objectType, []).object); } - static final _id_throwNullPointerException = jniAccessors.getMethodIDOf( - _classRef, r"throwNullPointerException", r"()I"); + static final _id_throwNullPointerException = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"throwNullPointerException", r"()I"); /// from: public int throwNullPointerException() int throwNullPointerException() { - return jniAccessors.callMethodWithArgs(reference, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_throwNullPointerException, jni.JniCallType.intType, []).integer; } - static final _id_throwFileNotFoundException = jniAccessors.getMethodIDOf( - _classRef, r"throwFileNotFoundException", r"()Ljava/io/InputStream;"); + static final _id_throwFileNotFoundException = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"throwFileNotFoundException", + r"()Ljava/io/InputStream;"); /// from: public java.io.InputStream throwFileNotFoundException() /// The returned object must be deleted after use, by calling the `delete` method. jni.JObject throwFileNotFoundException() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_throwFileNotFoundException, jni.JniCallType.objectType, []).object); } - static final _id_throwClassCastException = jniAccessors.getMethodIDOf( - _classRef, r"throwClassCastException", r"()Ljava/io/FileInputStream;"); + static final _id_throwClassCastException = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"throwClassCastException", + r"()Ljava/io/FileInputStream;"); /// from: public java.io.FileInputStream throwClassCastException() /// The returned object must be deleted after use, by calling the `delete` method. jni.JObject throwClassCastException() { - return const jni.JObjectType().fromRef(jniAccessors.callMethodWithArgs( + return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_throwClassCastException, jni.JniCallType.objectType, []).object); } - static final _id_throwArrayIndexException = jniAccessors.getMethodIDOf( - _classRef, r"throwArrayIndexException", r"()I"); + static final _id_throwArrayIndexException = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"throwArrayIndexException", r"()I"); /// from: public int throwArrayIndexException() int throwArrayIndexException() { - return jniAccessors.callMethodWithArgs(reference, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_throwArrayIndexException, jni.JniCallType.intType, []).integer; } - static final _id_throwArithmeticException = jniAccessors.getMethodIDOf( - _classRef, r"throwArithmeticException", r"()I"); + static final _id_throwArithmeticException = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"throwArithmeticException", r"()I"); /// from: public int throwArithmeticException() int throwArithmeticException() { - return jniAccessors.callMethodWithArgs(reference, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_throwArithmeticException, jni.JniCallType.intType, []).integer; } - static final _id_throwLoremIpsum = - jniAccessors.getStaticMethodIDOf(_classRef, r"throwLoremIpsum", r"()V"); + static final _id_throwLoremIpsum = jni.Jni.accessors + .getStaticMethodIDOf(_class.reference, r"throwLoremIpsum", r"()V"); /// from: static public void throwLoremIpsum() static void throwLoremIpsum() { - return jniAccessors.callStaticMethodWithArgs( - _classRef, _id_throwLoremIpsum, jni.JniCallType.voidType, []).check(); + return jni.Jni.accessors.callStaticMethodWithArgs(_class.reference, + _id_throwLoremIpsum, jni.JniCallType.voidType, []).check(); } } @@ -796,192 +804,193 @@ class $ExceptionsType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $ExceptionsType && other is $ExceptionsType; + return other.runtimeType == ($ExceptionsType) && other is $ExceptionsType; } } /// from: com.github.dart_lang.jnigen.simple_package.Fields class Fields extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; Fields.fromRef( jni.JObjectPtr ref, ) : super.fromRef(ref); - static final _classRef = jniAccessors - .getClassOf(r"com/github/dart_lang/jnigen/simple_package/Fields"); + static final _class = + jni.Jni.findJClass(r"com/github/dart_lang/jnigen/simple_package/Fields"); /// The type which includes information such as the signature of this class. static const type = $FieldsType(); - static final _id_amount = jniAccessors.getStaticFieldIDOf( - _classRef, + static final _id_amount = jni.Jni.accessors.getStaticFieldIDOf( + _class.reference, r"amount", r"I", ); /// from: static public int amount - static int get amount => jniAccessors - .getStaticField(_classRef, _id_amount, jni.JniCallType.intType) + static int get amount => jni.Jni.accessors + .getStaticField(_class.reference, _id_amount, jni.JniCallType.intType) .integer; /// from: static public int amount static set amount(int value) => - jniEnv.SetStaticIntField(_classRef, _id_amount, value); + jni.Jni.env.SetStaticIntField(_class.reference, _id_amount, value); - static final _id_pi = jniAccessors.getStaticFieldIDOf( - _classRef, + static final _id_pi = jni.Jni.accessors.getStaticFieldIDOf( + _class.reference, r"pi", r"D", ); /// from: static public double pi - static double get pi => jniAccessors - .getStaticField(_classRef, _id_pi, jni.JniCallType.doubleType) + static double get pi => jni.Jni.accessors + .getStaticField(_class.reference, _id_pi, jni.JniCallType.doubleType) .doubleFloat; /// from: static public double pi static set pi(double value) => - jniEnv.SetStaticDoubleField(_classRef, _id_pi, value); + jni.Jni.env.SetStaticDoubleField(_class.reference, _id_pi, value); - static final _id_asterisk = jniAccessors.getStaticFieldIDOf( - _classRef, + static final _id_asterisk = jni.Jni.accessors.getStaticFieldIDOf( + _class.reference, r"asterisk", r"C", ); /// from: static public char asterisk - static int get asterisk => jniAccessors - .getStaticField(_classRef, _id_asterisk, jni.JniCallType.charType) + static int get asterisk => jni.Jni.accessors + .getStaticField(_class.reference, _id_asterisk, jni.JniCallType.charType) .char; /// from: static public char asterisk static set asterisk(int value) => - jniEnv.SetStaticCharField(_classRef, _id_asterisk, value); + jni.Jni.env.SetStaticCharField(_class.reference, _id_asterisk, value); - static final _id_name = jniAccessors.getStaticFieldIDOf( - _classRef, + static final _id_name = jni.Jni.accessors.getStaticFieldIDOf( + _class.reference, r"name", r"Ljava/lang/String;", ); /// from: static public java.lang.String name /// The returned object must be deleted after use, by calling the `delete` method. - static jni.JString get name => const jni.JStringType().fromRef(jniAccessors - .getStaticField(_classRef, _id_name, jni.JniCallType.objectType) + static jni.JString get name => const jni.JStringType().fromRef(jni + .Jni.accessors + .getStaticField(_class.reference, _id_name, jni.JniCallType.objectType) .object); /// from: static public java.lang.String name /// The returned object must be deleted after use, by calling the `delete` method. - static set name(jni.JString value) => - jniEnv.SetStaticObjectField(_classRef, _id_name, value.reference); + static set name(jni.JString value) => jni.Jni.env + .SetStaticObjectField(_class.reference, _id_name, value.reference); - static final _id_i = jniAccessors.getFieldIDOf( - _classRef, + static final _id_i = jni.Jni.accessors.getFieldIDOf( + _class.reference, r"i", r"Ljava/lang/Integer;", ); /// from: public java.lang.Integer i /// The returned object must be deleted after use, by calling the `delete` method. - jni.JObject get i => const jni.JObjectType().fromRef(jniAccessors + jni.JObject get i => const jni.JObjectType().fromRef(jni.Jni.accessors .getField(reference, _id_i, jni.JniCallType.objectType) .object); /// from: public java.lang.Integer i /// The returned object must be deleted after use, by calling the `delete` method. set i(jni.JObject value) => - jniEnv.SetObjectField(reference, _id_i, value.reference); + jni.Jni.env.SetObjectField(reference, _id_i, value.reference); - static final _id_trillion = jniAccessors.getFieldIDOf( - _classRef, + static final _id_trillion = jni.Jni.accessors.getFieldIDOf( + _class.reference, r"trillion", r"J", ); /// from: public long trillion - int get trillion => jniAccessors + int get trillion => jni.Jni.accessors .getField(reference, _id_trillion, jni.JniCallType.longType) .long; /// from: public long trillion set trillion(int value) => - jniEnv.SetLongField(reference, _id_trillion, value); + jni.Jni.env.SetLongField(reference, _id_trillion, value); - static final _id_isAchillesDead = jniAccessors.getFieldIDOf( - _classRef, + static final _id_isAchillesDead = jni.Jni.accessors.getFieldIDOf( + _class.reference, r"isAchillesDead", r"Z", ); /// from: public boolean isAchillesDead - bool get isAchillesDead => jniAccessors + bool get isAchillesDead => jni.Jni.accessors .getField(reference, _id_isAchillesDead, jni.JniCallType.booleanType) .boolean; /// from: public boolean isAchillesDead set isAchillesDead(bool value) => - jniEnv.SetBooleanField(reference, _id_isAchillesDead, value ? 1 : 0); + jni.Jni.env.SetBooleanField(reference, _id_isAchillesDead, value ? 1 : 0); - static final _id_bestFighterInGreece = jniAccessors.getFieldIDOf( - _classRef, + static final _id_bestFighterInGreece = jni.Jni.accessors.getFieldIDOf( + _class.reference, r"bestFighterInGreece", r"Ljava/lang/String;", ); /// from: public java.lang.String bestFighterInGreece /// The returned object must be deleted after use, by calling the `delete` method. - jni.JString get bestFighterInGreece => - const jni.JStringType().fromRef(jniAccessors - .getField( - reference, _id_bestFighterInGreece, jni.JniCallType.objectType) - .object); + jni.JString get bestFighterInGreece => const jni.JStringType().fromRef(jni + .Jni.accessors + .getField(reference, _id_bestFighterInGreece, jni.JniCallType.objectType) + .object); /// from: public java.lang.String bestFighterInGreece /// The returned object must be deleted after use, by calling the `delete` method. - set bestFighterInGreece(jni.JString value) => jniEnv.SetObjectField( - reference, _id_bestFighterInGreece, value.reference); + set bestFighterInGreece(jni.JString value) => jni.Jni.env + .SetObjectField(reference, _id_bestFighterInGreece, value.reference); - static final _id_random = jniAccessors.getFieldIDOf( - _classRef, + static final _id_random = jni.Jni.accessors.getFieldIDOf( + _class.reference, r"random", r"Ljava/util/Random;", ); /// from: public java.util.Random random /// The returned object must be deleted after use, by calling the `delete` method. - jni.JObject get random => const jni.JObjectType().fromRef(jniAccessors + jni.JObject get random => const jni.JObjectType().fromRef(jni.Jni.accessors .getField(reference, _id_random, jni.JniCallType.objectType) .object); /// from: public java.util.Random random /// The returned object must be deleted after use, by calling the `delete` method. set random(jni.JObject value) => - jniEnv.SetObjectField(reference, _id_random, value.reference); + jni.Jni.env.SetObjectField(reference, _id_random, value.reference); - static final _id_euroSymbol = jniAccessors.getStaticFieldIDOf( - _classRef, + static final _id_euroSymbol = jni.Jni.accessors.getStaticFieldIDOf( + _class.reference, r"euroSymbol", r"C", ); /// from: static public char euroSymbol - static int get euroSymbol => jniAccessors - .getStaticField(_classRef, _id_euroSymbol, jni.JniCallType.charType) + static int get euroSymbol => jni.Jni.accessors + .getStaticField( + _class.reference, _id_euroSymbol, jni.JniCallType.charType) .char; /// from: static public char euroSymbol static set euroSymbol(int value) => - jniEnv.SetStaticCharField(_classRef, _id_euroSymbol, value); + jni.Jni.env.SetStaticCharField(_class.reference, _id_euroSymbol, value); static final _id_ctor = - jniAccessors.getMethodIDOf(_classRef, r"", r"()V"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory Fields() { - return Fields.fromRef( - jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); + return Fields.fromRef(jni.Jni.accessors + .newObjectWithArgs(_class.reference, _id_ctor, []).object); } } @@ -1006,40 +1015,41 @@ class $FieldsType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $FieldsType && other is $FieldsType; + return other.runtimeType == ($FieldsType) && other is $FieldsType; } } /// from: com.github.dart_lang.jnigen.simple_package.Fields$Nested class Fields_Nested extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; Fields_Nested.fromRef( jni.JObjectPtr ref, ) : super.fromRef(ref); - static final _classRef = jniAccessors - .getClassOf(r"com/github/dart_lang/jnigen/simple_package/Fields$Nested"); + static final _class = jni.Jni.findJClass( + r"com/github/dart_lang/jnigen/simple_package/Fields$Nested"); /// The type which includes information such as the signature of this class. static const type = $Fields_NestedType(); - static final _id_hundred = jniAccessors.getFieldIDOf( - _classRef, + static final _id_hundred = jni.Jni.accessors.getFieldIDOf( + _class.reference, r"hundred", r"J", ); /// from: public long hundred - int get hundred => jniAccessors + int get hundred => jni.Jni.accessors .getField(reference, _id_hundred, jni.JniCallType.longType) .long; /// from: public long hundred - set hundred(int value) => jniEnv.SetLongField(reference, _id_hundred, value); + set hundred(int value) => + jni.Jni.env.SetLongField(reference, _id_hundred, value); - static final _id_BEST_GOD = jniAccessors.getStaticFieldIDOf( - _classRef, + static final _id_BEST_GOD = jni.Jni.accessors.getStaticFieldIDOf( + _class.reference, r"BEST_GOD", r"Ljava/lang/String;", ); @@ -1047,23 +1057,24 @@ class Fields_Nested extends jni.JObject { /// from: static public java.lang.String BEST_GOD /// The returned object must be deleted after use, by calling the `delete` method. static jni.JString get BEST_GOD => - const jni.JStringType().fromRef(jniAccessors - .getStaticField(_classRef, _id_BEST_GOD, jni.JniCallType.objectType) + const jni.JStringType().fromRef(jni.Jni.accessors + .getStaticField( + _class.reference, _id_BEST_GOD, jni.JniCallType.objectType) .object); /// from: static public java.lang.String BEST_GOD /// The returned object must be deleted after use, by calling the `delete` method. - static set BEST_GOD(jni.JString value) => - jniEnv.SetStaticObjectField(_classRef, _id_BEST_GOD, value.reference); + static set BEST_GOD(jni.JString value) => jni.Jni.env + .SetStaticObjectField(_class.reference, _id_BEST_GOD, value.reference); static final _id_ctor = - jniAccessors.getMethodIDOf(_classRef, r"", r"()V"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory Fields_Nested() { - return Fields_Nested.fromRef( - jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); + return Fields_Nested.fromRef(jni.Jni.accessors + .newObjectWithArgs(_class.reference, _id_ctor, []).object); } } @@ -1088,7 +1099,7 @@ class $Fields_NestedType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $Fields_NestedType && + return other.runtimeType == ($Fields_NestedType) && other is $Fields_NestedType; } } @@ -1096,40 +1107,40 @@ class $Fields_NestedType extends jni.JObjType { /// from: com.github.dart_lang.jnigen.pkg2.C2 class C2 extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; C2.fromRef( jni.JObjectPtr ref, ) : super.fromRef(ref); - static final _classRef = - jniAccessors.getClassOf(r"com/github/dart_lang/jnigen/pkg2/C2"); + static final _class = + jni.Jni.findJClass(r"com/github/dart_lang/jnigen/pkg2/C2"); /// The type which includes information such as the signature of this class. static const type = $C2Type(); - static final _id_CONSTANT = jniAccessors.getStaticFieldIDOf( - _classRef, + static final _id_CONSTANT = jni.Jni.accessors.getStaticFieldIDOf( + _class.reference, r"CONSTANT", r"I", ); /// from: static public int CONSTANT - static int get CONSTANT => jniAccessors - .getStaticField(_classRef, _id_CONSTANT, jni.JniCallType.intType) + static int get CONSTANT => jni.Jni.accessors + .getStaticField(_class.reference, _id_CONSTANT, jni.JniCallType.intType) .integer; /// from: static public int CONSTANT static set CONSTANT(int value) => - jniEnv.SetStaticIntField(_classRef, _id_CONSTANT, value); + jni.Jni.env.SetStaticIntField(_class.reference, _id_CONSTANT, value); static final _id_ctor = - jniAccessors.getMethodIDOf(_classRef, r"", r"()V"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory C2() { - return C2.fromRef( - jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); + return C2.fromRef(jni.Jni.accessors + .newObjectWithArgs(_class.reference, _id_ctor, []).object); } } @@ -1153,40 +1164,40 @@ class $C2Type extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $C2Type && other is $C2Type; + return other.runtimeType == ($C2Type) && other is $C2Type; } } /// from: com.github.dart_lang.jnigen.pkg2.Example class Example1 extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; Example1.fromRef( jni.JObjectPtr ref, ) : super.fromRef(ref); - static final _classRef = - jniAccessors.getClassOf(r"com/github/dart_lang/jnigen/pkg2/Example"); + static final _class = + jni.Jni.findJClass(r"com/github/dart_lang/jnigen/pkg2/Example"); /// The type which includes information such as the signature of this class. static const type = $Example1Type(); static final _id_ctor = - jniAccessors.getMethodIDOf(_classRef, r"", r"()V"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory Example1() { - return Example1.fromRef( - jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); + return Example1.fromRef(jni.Jni.accessors + .newObjectWithArgs(_class.reference, _id_ctor, []).object); } - static final _id_whichExample = - jniAccessors.getMethodIDOf(_classRef, r"whichExample", r"()I"); + static final _id_whichExample = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"whichExample", r"()I"); /// from: public int whichExample() int whichExample() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_whichExample, jni.JniCallType.intType, []).integer; } } @@ -1211,14 +1222,14 @@ class $Example1Type extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $Example1Type && other is $Example1Type; + return other.runtimeType == ($Example1Type) && other is $Example1Type; } } /// from: com.github.dart_lang.jnigen.generics.GrandParent class GrandParent<$T extends jni.JObject> extends jni.JObject { @override - late final jni.JObjType $type = type(T); + late final jni.JObjType> $type = type(T); final jni.JObjType<$T> T; @@ -1227,8 +1238,8 @@ class GrandParent<$T extends jni.JObject> extends jni.JObject { jni.JObjectPtr ref, ) : super.fromRef(ref); - static final _classRef = jniAccessors - .getClassOf(r"com/github/dart_lang/jnigen/generics/GrandParent"); + static final _class = + jni.Jni.findJClass(r"com/github/dart_lang/jnigen/generics/GrandParent"); /// The type which includes information such as the signature of this class. static $GrandParentType<$T> type<$T extends jni.JObject>( @@ -1239,25 +1250,25 @@ class GrandParent<$T extends jni.JObject> extends jni.JObject { ); } - static final _id_value = jniAccessors.getFieldIDOf( - _classRef, + static final _id_value = jni.Jni.accessors.getFieldIDOf( + _class.reference, r"value", r"Ljava/lang/Object;", ); /// from: public T value /// The returned object must be deleted after use, by calling the `delete` method. - $T get value => T.fromRef(jniAccessors + $T get value => T.fromRef(jni.Jni.accessors .getField(reference, _id_value, jni.JniCallType.objectType) .object); /// from: public T value /// The returned object must be deleted after use, by calling the `delete` method. set value($T value) => - jniEnv.SetObjectField(reference, _id_value, value.reference); + jni.Jni.env.SetObjectField(reference, _id_value, value.reference); - static final _id_ctor = jniAccessors.getMethodIDOf( - _classRef, r"", r"(Ljava/lang/Object;)V"); + static final _id_ctor = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"", r"(Ljava/lang/Object;)V"); /// from: public void (T value) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1270,12 +1281,12 @@ class GrandParent<$T extends jni.JObject> extends jni.JObject { ]) as jni.JObjType<$T>; return GrandParent.fromRef( T, - jniAccessors - .newObjectWithArgs(_classRef, _id_ctor, [value.reference]).object); + jni.Jni.accessors.newObjectWithArgs( + _class.reference, _id_ctor, [value.reference]).object); } - static final _id_stringParent = jniAccessors.getMethodIDOf( - _classRef, + static final _id_stringParent = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"stringParent", r"()Lcom/github/dart_lang/jnigen/generics/GrandParent$Parent;"); @@ -1283,12 +1294,12 @@ class GrandParent<$T extends jni.JObject> extends jni.JObject { /// The returned object must be deleted after use, by calling the `delete` method. GrandParent_Parent stringParent() { return const $GrandParent_ParentType(jni.JObjectType(), jni.JStringType()) - .fromRef(jniAccessors.callMethodWithArgs(reference, _id_stringParent, - jni.JniCallType.objectType, []).object); + .fromRef(jni.Jni.accessors.callMethodWithArgs(reference, + _id_stringParent, jni.JniCallType.objectType, []).object); } - static final _id_varParent = jniAccessors.getMethodIDOf( - _classRef, + static final _id_varParent = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"varParent", r"(Ljava/lang/Object;)Lcom/github/dart_lang/jnigen/generics/GrandParent$Parent;"); @@ -1302,12 +1313,12 @@ class GrandParent<$T extends jni.JObject> extends jni.JObject { nestedValue.$type, ]) as jni.JObjType<$S>; return $GrandParent_ParentType(const jni.JObjectType(), S).fromRef( - jniAccessors.callMethodWithArgs(reference, _id_varParent, + jni.Jni.accessors.callMethodWithArgs(reference, _id_varParent, jni.JniCallType.objectType, [nestedValue.reference]).object); } - static final _id_stringStaticParent = jniAccessors.getStaticMethodIDOf( - _classRef, + static final _id_stringStaticParent = jni.Jni.accessors.getStaticMethodIDOf( + _class.reference, r"stringStaticParent", r"()Lcom/github/dart_lang/jnigen/generics/GrandParent$StaticParent;"); @@ -1315,12 +1326,12 @@ class GrandParent<$T extends jni.JObject> extends jni.JObject { /// The returned object must be deleted after use, by calling the `delete` method. static GrandParent_StaticParent stringStaticParent() { return const $GrandParent_StaticParentType(jni.JStringType()).fromRef( - jniAccessors.callStaticMethodWithArgs(_classRef, _id_stringStaticParent, - jni.JniCallType.objectType, []).object); + jni.Jni.accessors.callStaticMethodWithArgs(_class.reference, + _id_stringStaticParent, jni.JniCallType.objectType, []).object); } - static final _id_varStaticParent = jniAccessors.getStaticMethodIDOf( - _classRef, + static final _id_varStaticParent = jni.Jni.accessors.getStaticMethodIDOf( + _class.reference, r"varStaticParent", r"(Ljava/lang/Object;)Lcom/github/dart_lang/jnigen/generics/GrandParent$StaticParent;"); @@ -1333,20 +1344,20 @@ class GrandParent<$T extends jni.JObject> extends jni.JObject { S ??= jni.lowestCommonSuperType([ value.$type, ]) as jni.JObjType<$S>; - return $GrandParent_StaticParentType(S).fromRef(jniAccessors - .callStaticMethodWithArgs(_classRef, _id_varStaticParent, + return $GrandParent_StaticParentType(S).fromRef(jni.Jni.accessors + .callStaticMethodWithArgs(_class.reference, _id_varStaticParent, jni.JniCallType.objectType, [value.reference]).object); } - static final _id_staticParentWithSameType = jniAccessors.getMethodIDOf( - _classRef, + static final _id_staticParentWithSameType = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"staticParentWithSameType", r"()Lcom/github/dart_lang/jnigen/generics/GrandParent$StaticParent;"); /// from: public com.github.dart_lang.jnigen.generics.GrandParent.StaticParent staticParentWithSameType() /// The returned object must be deleted after use, by calling the `delete` method. GrandParent_StaticParent<$T> staticParentWithSameType() { - return $GrandParent_StaticParentType(T).fromRef(jniAccessors + return $GrandParent_StaticParentType(T).fromRef(jni.Jni.accessors .callMethodWithArgs(reference, _id_staticParentWithSameType, jni.JniCallType.objectType, []).object); } @@ -1377,8 +1388,8 @@ class $GrandParentType<$T extends jni.JObject> @override bool operator ==(Object other) { - return other.runtimeType == $GrandParentType && - other is $GrandParentType && + return other.runtimeType == ($GrandParentType<$T>) && + other is $GrandParentType<$T> && T == other.T; } } @@ -1387,7 +1398,7 @@ class $GrandParentType<$T extends jni.JObject> class GrandParent_Parent<$T extends jni.JObject, $S extends jni.JObject> extends jni.JObject { @override - late final jni.JObjType $type = type(T, S); + late final jni.JObjType> $type = type(T, S); final jni.JObjType<$T> T; final jni.JObjType<$S> S; @@ -1398,8 +1409,8 @@ class GrandParent_Parent<$T extends jni.JObject, $S extends jni.JObject> jni.JObjectPtr ref, ) : super.fromRef(ref); - static final _classRef = jniAccessors - .getClassOf(r"com/github/dart_lang/jnigen/generics/GrandParent$Parent"); + static final _class = jni.Jni.findJClass( + r"com/github/dart_lang/jnigen/generics/GrandParent$Parent"); /// The type which includes information such as the signature of this class. static $GrandParent_ParentType<$T, $S> @@ -1413,42 +1424,42 @@ class GrandParent_Parent<$T extends jni.JObject, $S extends jni.JObject> ); } - static final _id_parentValue = jniAccessors.getFieldIDOf( - _classRef, + static final _id_parentValue = jni.Jni.accessors.getFieldIDOf( + _class.reference, r"parentValue", r"Ljava/lang/Object;", ); /// from: public T parentValue /// The returned object must be deleted after use, by calling the `delete` method. - $T get parentValue => T.fromRef(jniAccessors + $T get parentValue => T.fromRef(jni.Jni.accessors .getField(reference, _id_parentValue, jni.JniCallType.objectType) .object); /// from: public T parentValue /// The returned object must be deleted after use, by calling the `delete` method. set parentValue($T value) => - jniEnv.SetObjectField(reference, _id_parentValue, value.reference); + jni.Jni.env.SetObjectField(reference, _id_parentValue, value.reference); - static final _id_value = jniAccessors.getFieldIDOf( - _classRef, + static final _id_value = jni.Jni.accessors.getFieldIDOf( + _class.reference, r"value", r"Ljava/lang/Object;", ); /// from: public S value /// The returned object must be deleted after use, by calling the `delete` method. - $S get value => S.fromRef(jniAccessors + $S get value => S.fromRef(jni.Jni.accessors .getField(reference, _id_value, jni.JniCallType.objectType) .object); /// from: public S value /// The returned object must be deleted after use, by calling the `delete` method. set value($S value) => - jniEnv.SetObjectField(reference, _id_value, value.reference); + jni.Jni.env.SetObjectField(reference, _id_value, value.reference); - static final _id_ctor = jniAccessors.getMethodIDOf( - _classRef, r"", r"(Ljava/lang/Object;Ljava/lang/Object;)V"); + static final _id_ctor = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"", r"(Ljava/lang/Object;Ljava/lang/Object;)V"); /// from: public void (T parentValue, S value) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1467,7 +1478,7 @@ class GrandParent_Parent<$T extends jni.JObject, $S extends jni.JObject> return GrandParent_Parent.fromRef( T, S, - jniAccessors.newObjectWithArgs(_classRef, _id_ctor, + jni.Jni.accessors.newObjectWithArgs(_class.reference, _id_ctor, [parentValue.reference, value.reference]).object); } } @@ -1501,8 +1512,8 @@ class $GrandParent_ParentType<$T extends jni.JObject, $S extends jni.JObject> @override bool operator ==(Object other) { - return other.runtimeType == $GrandParent_ParentType && - other is $GrandParent_ParentType && + return other.runtimeType == ($GrandParent_ParentType<$T, $S>) && + other is $GrandParent_ParentType<$T, $S> && T == other.T && S == other.S; } @@ -1512,7 +1523,8 @@ class $GrandParent_ParentType<$T extends jni.JObject, $S extends jni.JObject> class GrandParent_Parent_Child<$T extends jni.JObject, $S extends jni.JObject, $U extends jni.JObject> extends jni.JObject { @override - late final jni.JObjType $type = type(T, S, U); + late final jni.JObjType> $type = + type(T, S, U); final jni.JObjType<$T> T; final jni.JObjType<$S> S; @@ -1525,7 +1537,7 @@ class GrandParent_Parent_Child<$T extends jni.JObject, $S extends jni.JObject, jni.JObjectPtr ref, ) : super.fromRef(ref); - static final _classRef = jniAccessors.getClassOf( + static final _class = jni.Jni.findJClass( r"com/github/dart_lang/jnigen/generics/GrandParent$Parent$Child"); /// The type which includes information such as the signature of this class. @@ -1542,59 +1554,59 @@ class GrandParent_Parent_Child<$T extends jni.JObject, $S extends jni.JObject, ); } - static final _id_grandParentValue = jniAccessors.getFieldIDOf( - _classRef, + static final _id_grandParentValue = jni.Jni.accessors.getFieldIDOf( + _class.reference, r"grandParentValue", r"Ljava/lang/Object;", ); /// from: public T grandParentValue /// The returned object must be deleted after use, by calling the `delete` method. - $T get grandParentValue => T.fromRef(jniAccessors + $T get grandParentValue => T.fromRef(jni.Jni.accessors .getField(reference, _id_grandParentValue, jni.JniCallType.objectType) .object); /// from: public T grandParentValue /// The returned object must be deleted after use, by calling the `delete` method. - set grandParentValue($T value) => - jniEnv.SetObjectField(reference, _id_grandParentValue, value.reference); + set grandParentValue($T value) => jni.Jni.env + .SetObjectField(reference, _id_grandParentValue, value.reference); - static final _id_parentValue = jniAccessors.getFieldIDOf( - _classRef, + static final _id_parentValue = jni.Jni.accessors.getFieldIDOf( + _class.reference, r"parentValue", r"Ljava/lang/Object;", ); /// from: public S parentValue /// The returned object must be deleted after use, by calling the `delete` method. - $S get parentValue => S.fromRef(jniAccessors + $S get parentValue => S.fromRef(jni.Jni.accessors .getField(reference, _id_parentValue, jni.JniCallType.objectType) .object); /// from: public S parentValue /// The returned object must be deleted after use, by calling the `delete` method. set parentValue($S value) => - jniEnv.SetObjectField(reference, _id_parentValue, value.reference); + jni.Jni.env.SetObjectField(reference, _id_parentValue, value.reference); - static final _id_value = jniAccessors.getFieldIDOf( - _classRef, + static final _id_value = jni.Jni.accessors.getFieldIDOf( + _class.reference, r"value", r"Ljava/lang/Object;", ); /// from: public U value /// The returned object must be deleted after use, by calling the `delete` method. - $U get value => U.fromRef(jniAccessors + $U get value => U.fromRef(jni.Jni.accessors .getField(reference, _id_value, jni.JniCallType.objectType) .object); /// from: public U value /// The returned object must be deleted after use, by calling the `delete` method. set value($U value) => - jniEnv.SetObjectField(reference, _id_value, value.reference); + jni.Jni.env.SetObjectField(reference, _id_value, value.reference); - static final _id_ctor = jniAccessors.getMethodIDOf(_classRef, r"", - r"(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V"); + static final _id_ctor = jni.Jni.accessors.getMethodIDOf(_class.reference, + r"", r"(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V"); /// from: public void (T grandParentValue, S parentValue, U value) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1619,7 +1631,7 @@ class GrandParent_Parent_Child<$T extends jni.JObject, $S extends jni.JObject, T, S, U, - jniAccessors.newObjectWithArgs(_classRef, _id_ctor, [ + jni.Jni.accessors.newObjectWithArgs(_class.reference, _id_ctor, [ grandParentValue.reference, parentValue.reference, value.reference @@ -1659,8 +1671,8 @@ class $GrandParent_Parent_ChildType<$T extends jni.JObject, @override bool operator ==(Object other) { - return other.runtimeType == $GrandParent_Parent_ChildType && - other is $GrandParent_Parent_ChildType && + return other.runtimeType == ($GrandParent_Parent_ChildType<$T, $S, $U>) && + other is $GrandParent_Parent_ChildType<$T, $S, $U> && T == other.T && S == other.S && U == other.U; @@ -1670,7 +1682,7 @@ class $GrandParent_Parent_ChildType<$T extends jni.JObject, /// from: com.github.dart_lang.jnigen.generics.GrandParent$StaticParent class GrandParent_StaticParent<$S extends jni.JObject> extends jni.JObject { @override - late final jni.JObjType $type = type(S); + late final jni.JObjType> $type = type(S); final jni.JObjType<$S> S; @@ -1679,7 +1691,7 @@ class GrandParent_StaticParent<$S extends jni.JObject> extends jni.JObject { jni.JObjectPtr ref, ) : super.fromRef(ref); - static final _classRef = jniAccessors.getClassOf( + static final _class = jni.Jni.findJClass( r"com/github/dart_lang/jnigen/generics/GrandParent$StaticParent"); /// The type which includes information such as the signature of this class. @@ -1691,25 +1703,25 @@ class GrandParent_StaticParent<$S extends jni.JObject> extends jni.JObject { ); } - static final _id_value = jniAccessors.getFieldIDOf( - _classRef, + static final _id_value = jni.Jni.accessors.getFieldIDOf( + _class.reference, r"value", r"Ljava/lang/Object;", ); /// from: public S value /// The returned object must be deleted after use, by calling the `delete` method. - $S get value => S.fromRef(jniAccessors + $S get value => S.fromRef(jni.Jni.accessors .getField(reference, _id_value, jni.JniCallType.objectType) .object); /// from: public S value /// The returned object must be deleted after use, by calling the `delete` method. set value($S value) => - jniEnv.SetObjectField(reference, _id_value, value.reference); + jni.Jni.env.SetObjectField(reference, _id_value, value.reference); - static final _id_ctor = jniAccessors.getMethodIDOf( - _classRef, r"", r"(Ljava/lang/Object;)V"); + static final _id_ctor = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"", r"(Ljava/lang/Object;)V"); /// from: public void (S value) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1722,8 +1734,8 @@ class GrandParent_StaticParent<$S extends jni.JObject> extends jni.JObject { ]) as jni.JObjType<$S>; return GrandParent_StaticParent.fromRef( S, - jniAccessors - .newObjectWithArgs(_classRef, _id_ctor, [value.reference]).object); + jni.Jni.accessors.newObjectWithArgs( + _class.reference, _id_ctor, [value.reference]).object); } } @@ -1754,8 +1766,8 @@ class $GrandParent_StaticParentType<$S extends jni.JObject> @override bool operator ==(Object other) { - return other.runtimeType == $GrandParent_StaticParentType && - other is $GrandParent_StaticParentType && + return other.runtimeType == ($GrandParent_StaticParentType<$S>) && + other is $GrandParent_StaticParentType<$S> && S == other.S; } } @@ -1764,7 +1776,8 @@ class $GrandParent_StaticParentType<$S extends jni.JObject> class GrandParent_StaticParent_Child<$S extends jni.JObject, $U extends jni.JObject> extends jni.JObject { @override - late final jni.JObjType $type = type(S, U); + late final jni.JObjType> $type = + type(S, U); final jni.JObjType<$S> S; final jni.JObjType<$U> U; @@ -1775,7 +1788,7 @@ class GrandParent_StaticParent_Child<$S extends jni.JObject, jni.JObjectPtr ref, ) : super.fromRef(ref); - static final _classRef = jniAccessors.getClassOf( + static final _class = jni.Jni.findJClass( r"com/github/dart_lang/jnigen/generics/GrandParent$StaticParent$Child"); /// The type which includes information such as the signature of this class. @@ -1790,42 +1803,42 @@ class GrandParent_StaticParent_Child<$S extends jni.JObject, ); } - static final _id_parentValue = jniAccessors.getFieldIDOf( - _classRef, + static final _id_parentValue = jni.Jni.accessors.getFieldIDOf( + _class.reference, r"parentValue", r"Ljava/lang/Object;", ); /// from: public S parentValue /// The returned object must be deleted after use, by calling the `delete` method. - $S get parentValue => S.fromRef(jniAccessors + $S get parentValue => S.fromRef(jni.Jni.accessors .getField(reference, _id_parentValue, jni.JniCallType.objectType) .object); /// from: public S parentValue /// The returned object must be deleted after use, by calling the `delete` method. set parentValue($S value) => - jniEnv.SetObjectField(reference, _id_parentValue, value.reference); + jni.Jni.env.SetObjectField(reference, _id_parentValue, value.reference); - static final _id_value = jniAccessors.getFieldIDOf( - _classRef, + static final _id_value = jni.Jni.accessors.getFieldIDOf( + _class.reference, r"value", r"Ljava/lang/Object;", ); /// from: public U value /// The returned object must be deleted after use, by calling the `delete` method. - $U get value => U.fromRef(jniAccessors + $U get value => U.fromRef(jni.Jni.accessors .getField(reference, _id_value, jni.JniCallType.objectType) .object); /// from: public U value /// The returned object must be deleted after use, by calling the `delete` method. set value($U value) => - jniEnv.SetObjectField(reference, _id_value, value.reference); + jni.Jni.env.SetObjectField(reference, _id_value, value.reference); - static final _id_ctor = jniAccessors.getMethodIDOf( - _classRef, r"", r"(Ljava/lang/Object;Ljava/lang/Object;)V"); + static final _id_ctor = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"", r"(Ljava/lang/Object;Ljava/lang/Object;)V"); /// from: public void (S parentValue, U value) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1844,7 +1857,7 @@ class GrandParent_StaticParent_Child<$S extends jni.JObject, return GrandParent_StaticParent_Child.fromRef( S, U, - jniAccessors.newObjectWithArgs(_classRef, _id_ctor, + jni.Jni.accessors.newObjectWithArgs(_class.reference, _id_ctor, [parentValue.reference, value.reference]).object); } } @@ -1879,8 +1892,8 @@ class $GrandParent_StaticParent_ChildType<$S extends jni.JObject, @override bool operator ==(Object other) { - return other.runtimeType == $GrandParent_StaticParent_ChildType && - other is $GrandParent_StaticParent_ChildType && + return other.runtimeType == ($GrandParent_StaticParent_ChildType<$S, $U>) && + other is $GrandParent_StaticParent_ChildType<$S, $U> && S == other.S && U == other.U; } @@ -1890,7 +1903,7 @@ class $GrandParent_StaticParent_ChildType<$S extends jni.JObject, class MyMap<$K extends jni.JObject, $V extends jni.JObject> extends jni.JObject { @override - late final jni.JObjType $type = type(K, V); + late final jni.JObjType> $type = type(K, V); final jni.JObjType<$K> K; final jni.JObjType<$V> V; @@ -1901,8 +1914,8 @@ class MyMap<$K extends jni.JObject, $V extends jni.JObject> jni.JObjectPtr ref, ) : super.fromRef(ref); - static final _classRef = - jniAccessors.getClassOf(r"com/github/dart_lang/jnigen/generics/MyMap"); + static final _class = + jni.Jni.findJClass(r"com/github/dart_lang/jnigen/generics/MyMap"); /// The type which includes information such as the signature of this class. static $MyMapType<$K, $V> @@ -1917,7 +1930,7 @@ class MyMap<$K extends jni.JObject, $V extends jni.JObject> } static final _id_ctor = - jniAccessors.getMethodIDOf(_classRef, r"", r"()V"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. @@ -1926,23 +1939,26 @@ class MyMap<$K extends jni.JObject, $V extends jni.JObject> required jni.JObjType<$V> V, }) { return MyMap.fromRef( - K, V, jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); + K, + V, + jni.Jni.accessors + .newObjectWithArgs(_class.reference, _id_ctor, []).object); } - static final _id_get0 = jniAccessors.getMethodIDOf( - _classRef, r"get", r"(Ljava/lang/Object;)Ljava/lang/Object;"); + static final _id_get0 = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"get", r"(Ljava/lang/Object;)Ljava/lang/Object;"); /// from: public V get(K key) /// The returned object must be deleted after use, by calling the `delete` method. $V get0( $K key, ) { - return V.fromRef(jniAccessors.callMethodWithArgs(reference, _id_get0, + return V.fromRef(jni.Jni.accessors.callMethodWithArgs(reference, _id_get0, jni.JniCallType.objectType, [key.reference]).object); } - static final _id_put = jniAccessors.getMethodIDOf(_classRef, r"put", - r"(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); + static final _id_put = jni.Jni.accessors.getMethodIDOf(_class.reference, + r"put", r"(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); /// from: public V put(K key, V value) /// The returned object must be deleted after use, by calling the `delete` method. @@ -1950,19 +1966,21 @@ class MyMap<$K extends jni.JObject, $V extends jni.JObject> $K key, $V value, ) { - return V.fromRef(jniAccessors.callMethodWithArgs(reference, _id_put, + return V.fromRef(jni.Jni.accessors.callMethodWithArgs(reference, _id_put, jni.JniCallType.objectType, [key.reference, value.reference]).object); } - static final _id_entryStack = jniAccessors.getMethodIDOf(_classRef, - r"entryStack", r"()Lcom/github/dart_lang/jnigen/generics/MyStack;"); + static final _id_entryStack = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"entryStack", + r"()Lcom/github/dart_lang/jnigen/generics/MyStack;"); /// from: public com.github.dart_lang.jnigen.generics.MyStack.MyEntry> entryStack() /// The returned object must be deleted after use, by calling the `delete` method. MyStack> entryStack() { return const $MyStackType( $MyMap_MyEntryType(jni.JObjectType(), jni.JObjectType())) - .fromRef(jniAccessors.callMethodWithArgs( + .fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_entryStack, jni.JniCallType.objectType, []).object); } } @@ -1994,8 +2012,8 @@ class $MyMapType<$K extends jni.JObject, $V extends jni.JObject> @override bool operator ==(Object other) { - return other.runtimeType == $MyMapType && - other is $MyMapType && + return other.runtimeType == ($MyMapType<$K, $V>) && + other is $MyMapType<$K, $V> && K == other.K && V == other.V; } @@ -2005,7 +2023,7 @@ class $MyMapType<$K extends jni.JObject, $V extends jni.JObject> class MyMap_MyEntry<$K extends jni.JObject, $V extends jni.JObject> extends jni.JObject { @override - late final jni.JObjType $type = type(K, V); + late final jni.JObjType> $type = type(K, V); final jni.JObjType<$K> K; final jni.JObjType<$V> V; @@ -2016,8 +2034,8 @@ class MyMap_MyEntry<$K extends jni.JObject, $V extends jni.JObject> jni.JObjectPtr ref, ) : super.fromRef(ref); - static final _classRef = jniAccessors - .getClassOf(r"com/github/dart_lang/jnigen/generics/MyMap$MyEntry"); + static final _class = + jni.Jni.findJClass(r"com/github/dart_lang/jnigen/generics/MyMap$MyEntry"); /// The type which includes information such as the signature of this class. static $MyMap_MyEntryType<$K, $V> @@ -2031,42 +2049,42 @@ class MyMap_MyEntry<$K extends jni.JObject, $V extends jni.JObject> ); } - static final _id_key = jniAccessors.getFieldIDOf( - _classRef, + static final _id_key = jni.Jni.accessors.getFieldIDOf( + _class.reference, r"key", r"Ljava/lang/Object;", ); /// from: public K key /// The returned object must be deleted after use, by calling the `delete` method. - $K get key => K.fromRef(jniAccessors + $K get key => K.fromRef(jni.Jni.accessors .getField(reference, _id_key, jni.JniCallType.objectType) .object); /// from: public K key /// The returned object must be deleted after use, by calling the `delete` method. set key($K value) => - jniEnv.SetObjectField(reference, _id_key, value.reference); + jni.Jni.env.SetObjectField(reference, _id_key, value.reference); - static final _id_value = jniAccessors.getFieldIDOf( - _classRef, + static final _id_value = jni.Jni.accessors.getFieldIDOf( + _class.reference, r"value", r"Ljava/lang/Object;", ); /// from: public V value /// The returned object must be deleted after use, by calling the `delete` method. - $V get value => V.fromRef(jniAccessors + $V get value => V.fromRef(jni.Jni.accessors .getField(reference, _id_value, jni.JniCallType.objectType) .object); /// from: public V value /// The returned object must be deleted after use, by calling the `delete` method. set value($V value) => - jniEnv.SetObjectField(reference, _id_value, value.reference); + jni.Jni.env.SetObjectField(reference, _id_value, value.reference); - static final _id_ctor = jniAccessors.getMethodIDOf( - _classRef, r"", r"(Ljava/lang/Object;Ljava/lang/Object;)V"); + static final _id_ctor = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"", r"(Ljava/lang/Object;Ljava/lang/Object;)V"); /// from: public void (K key, V value) /// The returned object must be deleted after use, by calling the `delete` method. @@ -2085,8 +2103,8 @@ class MyMap_MyEntry<$K extends jni.JObject, $V extends jni.JObject> return MyMap_MyEntry.fromRef( K, V, - jniAccessors.newObjectWithArgs( - _classRef, _id_ctor, [key.reference, value.reference]).object); + jni.Jni.accessors.newObjectWithArgs(_class.reference, _id_ctor, + [key.reference, value.reference]).object); } } @@ -2119,8 +2137,8 @@ class $MyMap_MyEntryType<$K extends jni.JObject, $V extends jni.JObject> @override bool operator ==(Object other) { - return other.runtimeType == $MyMap_MyEntryType && - other is $MyMap_MyEntryType && + return other.runtimeType == ($MyMap_MyEntryType<$K, $V>) && + other is $MyMap_MyEntryType<$K, $V> && K == other.K && V == other.V; } @@ -2129,7 +2147,7 @@ class $MyMap_MyEntryType<$K extends jni.JObject, $V extends jni.JObject> /// from: com.github.dart_lang.jnigen.generics.MyStack class MyStack<$T extends jni.JObject> extends jni.JObject { @override - late final jni.JObjType $type = type(T); + late final jni.JObjType> $type = type(T); final jni.JObjType<$T> T; @@ -2138,8 +2156,8 @@ class MyStack<$T extends jni.JObject> extends jni.JObject { jni.JObjectPtr ref, ) : super.fromRef(ref); - static final _classRef = - jniAccessors.getClassOf(r"com/github/dart_lang/jnigen/generics/MyStack"); + static final _class = + jni.Jni.findJClass(r"com/github/dart_lang/jnigen/generics/MyStack"); /// The type which includes information such as the signature of this class. static $MyStackType<$T> type<$T extends jni.JObject>( @@ -2151,7 +2169,7 @@ class MyStack<$T extends jni.JObject> extends jni.JObject { } static final _id_ctor = - jniAccessors.getMethodIDOf(_classRef, r"", r"()V"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. @@ -2159,11 +2177,13 @@ class MyStack<$T extends jni.JObject> extends jni.JObject { required jni.JObjType<$T> T, }) { return MyStack.fromRef( - T, jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); + T, + jni.Jni.accessors + .newObjectWithArgs(_class.reference, _id_ctor, []).object); } - static final _id_fromArray = jniAccessors.getStaticMethodIDOf( - _classRef, + static final _id_fromArray = jni.Jni.accessors.getStaticMethodIDOf( + _class.reference, r"fromArray", r"([Ljava/lang/Object;)Lcom/github/dart_lang/jnigen/generics/MyStack;"); @@ -2176,17 +2196,15 @@ class MyStack<$T extends jni.JObject> extends jni.JObject { T ??= jni.lowestCommonSuperType([ ((arr.$type as jni.JArrayType).elementType as jni.JObjType), ]) as jni.JObjType<$T>; - return $MyStackType(T).fromRef(jniAccessors.callStaticMethodWithArgs( - _classRef, + return $MyStackType(T).fromRef(jni.Jni.accessors.callStaticMethodWithArgs( + _class.reference, _id_fromArray, jni.JniCallType.objectType, [arr.reference]).object); } - static final _id_fromArrayOfArrayOfGrandParents = - jniAccessors.getStaticMethodIDOf( - _classRef, - r"fromArrayOfArrayOfGrandParents", + static final _id_fromArrayOfArrayOfGrandParents = jni.Jni.accessors + .getStaticMethodIDOf(_class.reference, r"fromArrayOfArrayOfGrandParents", r"([[Lcom/github/dart_lang/jnigen/generics/GrandParent;)Lcom/github/dart_lang/jnigen/generics/MyStack;"); /// from: static public com.github.dart_lang.jnigen.generics.MyStack fromArrayOfArrayOfGrandParents(com.github.dart_lang.jnigen.generics.GrandParent[][] arr) @@ -2201,26 +2219,28 @@ class MyStack<$T extends jni.JObject> extends jni.JObject { .elementType as jni.JObjType) as $GrandParentType) .T, ]) as jni.JObjType<$S>; - return $MyStackType(S).fromRef(jniAccessors.callStaticMethodWithArgs( - _classRef, + return $MyStackType(S).fromRef(jni.Jni.accessors.callStaticMethodWithArgs( + _class.reference, _id_fromArrayOfArrayOfGrandParents, jni.JniCallType.objectType, [arr.reference]).object); } - static final _id_of = jniAccessors.getStaticMethodIDOf( - _classRef, r"of", r"()Lcom/github/dart_lang/jnigen/generics/MyStack;"); + static final _id_of = jni.Jni.accessors.getStaticMethodIDOf(_class.reference, + r"of", r"()Lcom/github/dart_lang/jnigen/generics/MyStack;"); /// from: static public com.github.dart_lang.jnigen.generics.MyStack of() /// The returned object must be deleted after use, by calling the `delete` method. static MyStack<$T> of<$T extends jni.JObject>({ required jni.JObjType<$T> T, }) { - return $MyStackType(T).fromRef(jniAccessors.callStaticMethodWithArgs( - _classRef, _id_of, jni.JniCallType.objectType, []).object); + return $MyStackType(T).fromRef(jni.Jni.accessors.callStaticMethodWithArgs( + _class.reference, _id_of, jni.JniCallType.objectType, []).object); } - static final _id_of1 = jniAccessors.getStaticMethodIDOf(_classRef, r"of", + static final _id_of1 = jni.Jni.accessors.getStaticMethodIDOf( + _class.reference, + r"of", r"(Ljava/lang/Object;)Lcom/github/dart_lang/jnigen/generics/MyStack;"); /// from: static public com.github.dart_lang.jnigen.generics.MyStack of(T obj) @@ -2232,14 +2252,16 @@ class MyStack<$T extends jni.JObject> extends jni.JObject { T ??= jni.lowestCommonSuperType([ obj.$type, ]) as jni.JObjType<$T>; - return $MyStackType(T).fromRef(jniAccessors.callStaticMethodWithArgs( - _classRef, + return $MyStackType(T).fromRef(jni.Jni.accessors.callStaticMethodWithArgs( + _class.reference, _id_of1, jni.JniCallType.objectType, [obj.reference]).object); } - static final _id_of2 = jniAccessors.getStaticMethodIDOf(_classRef, r"of", + static final _id_of2 = jni.Jni.accessors.getStaticMethodIDOf( + _class.reference, + r"of", r"(Ljava/lang/Object;Ljava/lang/Object;)Lcom/github/dart_lang/jnigen/generics/MyStack;"); /// from: static public com.github.dart_lang.jnigen.generics.MyStack of(T obj, T obj2) @@ -2253,40 +2275,40 @@ class MyStack<$T extends jni.JObject> extends jni.JObject { obj2.$type, obj.$type, ]) as jni.JObjType<$T>; - return $MyStackType(T).fromRef(jniAccessors.callStaticMethodWithArgs( - _classRef, + return $MyStackType(T).fromRef(jni.Jni.accessors.callStaticMethodWithArgs( + _class.reference, _id_of2, jni.JniCallType.objectType, [obj.reference, obj2.reference]).object); } - static final _id_push = - jniAccessors.getMethodIDOf(_classRef, r"push", r"(Ljava/lang/Object;)V"); + static final _id_push = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"push", r"(Ljava/lang/Object;)V"); /// from: public void push(T item) void push( $T item, ) { - return jniAccessors.callMethodWithArgs(reference, _id_push, + return jni.Jni.accessors.callMethodWithArgs(reference, _id_push, jni.JniCallType.voidType, [item.reference]).check(); } - static final _id_pop = - jniAccessors.getMethodIDOf(_classRef, r"pop", r"()Ljava/lang/Object;"); + static final _id_pop = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"pop", r"()Ljava/lang/Object;"); /// from: public T pop() /// The returned object must be deleted after use, by calling the `delete` method. $T pop() { - return T.fromRef(jniAccessors.callMethodWithArgs( + return T.fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_pop, jni.JniCallType.objectType, []).object); } static final _id_size = - jniAccessors.getMethodIDOf(_classRef, r"size", r"()I"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"size", r"()I"); /// from: public int size() int size() { - return jniAccessors.callMethodWithArgs( + return jni.Jni.accessors.callMethodWithArgs( reference, _id_size, jni.JniCallType.intType, []).integer; } } @@ -2315,8 +2337,8 @@ class $MyStackType<$T extends jni.JObject> extends jni.JObjType> { @override bool operator ==(Object other) { - return other.runtimeType == $MyStackType && - other is $MyStackType && + return other.runtimeType == ($MyStackType<$T>) && + other is $MyStackType<$T> && T == other.T; } } @@ -2324,7 +2346,7 @@ class $MyStackType<$T extends jni.JObject> extends jni.JObjType> { /// from: com.github.dart_lang.jnigen.generics.StringKeyedMap class StringKeyedMap<$V extends jni.JObject> extends MyMap { @override - late final jni.JObjType $type = type(V); + late final jni.JObjType> $type = type(V); final jni.JObjType<$V> V; @@ -2333,8 +2355,8 @@ class StringKeyedMap<$V extends jni.JObject> extends MyMap { jni.JObjectPtr ref, ) : super.fromRef(const jni.JStringType(), V, ref); - static final _classRef = jniAccessors - .getClassOf(r"com/github/dart_lang/jnigen/generics/StringKeyedMap"); + static final _class = jni.Jni.findJClass( + r"com/github/dart_lang/jnigen/generics/StringKeyedMap"); /// The type which includes information such as the signature of this class. static $StringKeyedMapType<$V> type<$V extends jni.JObject>( @@ -2346,7 +2368,7 @@ class StringKeyedMap<$V extends jni.JObject> extends MyMap { } static final _id_ctor = - jniAccessors.getMethodIDOf(_classRef, r"", r"()V"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. @@ -2354,7 +2376,9 @@ class StringKeyedMap<$V extends jni.JObject> extends MyMap { required jni.JObjType<$V> V, }) { return StringKeyedMap.fromRef( - V, jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); + V, + jni.Jni.accessors + .newObjectWithArgs(_class.reference, _id_ctor, []).object); } } @@ -2385,8 +2409,8 @@ class $StringKeyedMapType<$V extends jni.JObject> @override bool operator ==(Object other) { - return other.runtimeType == $StringKeyedMapType && - other is $StringKeyedMapType && + return other.runtimeType == ($StringKeyedMapType<$V>) && + other is $StringKeyedMapType<$V> && V == other.V; } } @@ -2394,25 +2418,25 @@ class $StringKeyedMapType<$V extends jni.JObject> /// from: com.github.dart_lang.jnigen.generics.StringMap class StringMap extends StringKeyedMap { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; StringMap.fromRef( jni.JObjectPtr ref, ) : super.fromRef(const jni.JStringType(), ref); - static final _classRef = jniAccessors - .getClassOf(r"com/github/dart_lang/jnigen/generics/StringMap"); + static final _class = + jni.Jni.findJClass(r"com/github/dart_lang/jnigen/generics/StringMap"); /// The type which includes information such as the signature of this class. static const type = $StringMapType(); static final _id_ctor = - jniAccessors.getMethodIDOf(_classRef, r"", r"()V"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory StringMap() { - return StringMap.fromRef( - jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); + return StringMap.fromRef(jni.Jni.accessors + .newObjectWithArgs(_class.reference, _id_ctor, []).object); } } @@ -2436,32 +2460,32 @@ class $StringMapType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $StringMapType && other is $StringMapType; + return other.runtimeType == ($StringMapType) && other is $StringMapType; } } /// from: com.github.dart_lang.jnigen.generics.StringStack class StringStack extends MyStack { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; StringStack.fromRef( jni.JObjectPtr ref, ) : super.fromRef(const jni.JStringType(), ref); - static final _classRef = jniAccessors - .getClassOf(r"com/github/dart_lang/jnigen/generics/StringStack"); + static final _class = + jni.Jni.findJClass(r"com/github/dart_lang/jnigen/generics/StringStack"); /// The type which includes information such as the signature of this class. static const type = $StringStackType(); static final _id_ctor = - jniAccessors.getMethodIDOf(_classRef, r"", r"()V"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory StringStack() { - return StringStack.fromRef( - jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); + return StringStack.fromRef(jni.Jni.accessors + .newObjectWithArgs(_class.reference, _id_ctor, []).object); } } @@ -2485,14 +2509,14 @@ class $StringStackType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $StringStackType && other is $StringStackType; + return other.runtimeType == ($StringStackType) && other is $StringStackType; } } /// from: com.github.dart_lang.jnigen.generics.StringValuedMap class StringValuedMap<$K extends jni.JObject> extends MyMap<$K, jni.JString> { @override - late final jni.JObjType $type = type(K); + late final jni.JObjType> $type = type(K); final jni.JObjType<$K> K; @@ -2501,8 +2525,8 @@ class StringValuedMap<$K extends jni.JObject> extends MyMap<$K, jni.JString> { jni.JObjectPtr ref, ) : super.fromRef(K, const jni.JStringType(), ref); - static final _classRef = jniAccessors - .getClassOf(r"com/github/dart_lang/jnigen/generics/StringValuedMap"); + static final _class = jni.Jni.findJClass( + r"com/github/dart_lang/jnigen/generics/StringValuedMap"); /// The type which includes information such as the signature of this class. static $StringValuedMapType<$K> type<$K extends jni.JObject>( @@ -2514,7 +2538,7 @@ class StringValuedMap<$K extends jni.JObject> extends MyMap<$K, jni.JString> { } static final _id_ctor = - jniAccessors.getMethodIDOf(_classRef, r"", r"()V"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. @@ -2522,7 +2546,9 @@ class StringValuedMap<$K extends jni.JObject> extends MyMap<$K, jni.JString> { required jni.JObjType<$K> K, }) { return StringValuedMap.fromRef( - K, jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); + K, + jni.Jni.accessors + .newObjectWithArgs(_class.reference, _id_ctor, []).object); } } @@ -2553,8 +2579,8 @@ class $StringValuedMapType<$K extends jni.JObject> @override bool operator ==(Object other) { - return other.runtimeType == $StringValuedMapType && - other is $StringValuedMapType && + return other.runtimeType == ($StringValuedMapType<$K>) && + other is $StringValuedMapType<$K> && K == other.K; } } @@ -2562,19 +2588,19 @@ class $StringValuedMapType<$K extends jni.JObject> /// from: com.github.dart_lang.jnigen.annotations.JsonSerializable$Case class JsonSerializable_Case extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; JsonSerializable_Case.fromRef( jni.JObjectPtr ref, ) : super.fromRef(ref); - static final _classRef = jniAccessors.getClassOf( + static final _class = jni.Jni.findJClass( r"com/github/dart_lang/jnigen/annotations/JsonSerializable$Case"); /// The type which includes information such as the signature of this class. static const type = $JsonSerializable_CaseType(); - static final _id_values = jniAccessors.getStaticMethodIDOf( - _classRef, + static final _id_values = jni.Jni.accessors.getStaticMethodIDOf( + _class.reference, r"values", r"()[Lcom/github/dart_lang/jnigen/annotations/JsonSerializable$Case;"); @@ -2582,12 +2608,12 @@ class JsonSerializable_Case extends jni.JObject { /// The returned object must be deleted after use, by calling the `delete` method. static jni.JArray values() { return const jni.JArrayType($JsonSerializable_CaseType()).fromRef( - jniAccessors.callStaticMethodWithArgs( - _classRef, _id_values, jni.JniCallType.objectType, []).object); + jni.Jni.accessors.callStaticMethodWithArgs(_class.reference, _id_values, + jni.JniCallType.objectType, []).object); } - static final _id_valueOf = jniAccessors.getStaticMethodIDOf( - _classRef, + static final _id_valueOf = jni.Jni.accessors.getStaticMethodIDOf( + _class.reference, r"valueOf", r"(Ljava/lang/String;)Lcom/github/dart_lang/jnigen/annotations/JsonSerializable$Case;"); @@ -2596,8 +2622,8 @@ class JsonSerializable_Case extends jni.JObject { static JsonSerializable_Case valueOf( jni.JString name, ) { - return const $JsonSerializable_CaseType().fromRef(jniAccessors - .callStaticMethodWithArgs(_classRef, _id_valueOf, + return const $JsonSerializable_CaseType().fromRef(jni.Jni.accessors + .callStaticMethodWithArgs(_class.reference, _id_valueOf, jni.JniCallType.objectType, [name.reference]).object); } } @@ -2624,7 +2650,7 @@ class $JsonSerializable_CaseType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $JsonSerializable_CaseType && + return other.runtimeType == ($JsonSerializable_CaseType) && other is $JsonSerializable_CaseType; } } @@ -2632,25 +2658,25 @@ class $JsonSerializable_CaseType extends jni.JObjType { /// from: com.github.dart_lang.jnigen.annotations.MyDataClass class MyDataClass extends jni.JObject { @override - late final jni.JObjType $type = type; + late final jni.JObjType $type = type; MyDataClass.fromRef( jni.JObjectPtr ref, ) : super.fromRef(ref); - static final _classRef = jniAccessors - .getClassOf(r"com/github/dart_lang/jnigen/annotations/MyDataClass"); + static final _class = jni.Jni.findJClass( + r"com/github/dart_lang/jnigen/annotations/MyDataClass"); /// The type which includes information such as the signature of this class. static const type = $MyDataClassType(); static final _id_ctor = - jniAccessors.getMethodIDOf(_classRef, r"", r"()V"); + jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory MyDataClass() { - return MyDataClass.fromRef( - jniAccessors.newObjectWithArgs(_classRef, _id_ctor, []).object); + return MyDataClass.fromRef(jni.Jni.accessors + .newObjectWithArgs(_class.reference, _id_ctor, []).object); } } @@ -2675,6 +2701,6 @@ class $MyDataClassType extends jni.JObjType { @override bool operator ==(Object other) { - return other.runtimeType == $MyDataClassType && other is $MyDataClassType; + return other.runtimeType == ($MyDataClassType) && other is $MyDataClassType; } } 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 d46dcf713..6472985c9 100644 --- a/pkgs/jnigen/test/simple_package_test/runtime_test_registrant.dart +++ b/pkgs/jnigen/test/simple_package_test/runtime_test_registrant.dart @@ -264,6 +264,24 @@ void registerTests(String groupName, TestRunnerCallback test) { expect(stack.pop().toDartString(deleteOriginal: true), 'Hello'); }); }); + test('Different stacks have different types, same stacks have same types', + () { + using((arena) { + final aStringStack = MyStack(T: JString.type)..deletedIn(arena); + final anotherStringStack = MyStack(T: JString.type)..deletedIn(arena); + final anObjectStack = MyStack(T: JObject.type)..deletedIn(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)..deletedIn(arena); From 6822f909628a75b212d0dda29501e6f537f010c2 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Tue, 9 May 2023 11:12:09 +0200 Subject: [PATCH 087/139] [jnigen] improve coverage (https://github.com/dart-lang/jnigen/issues/274) --- pkgs/jni/lib/src/jarray.dart | 33 +++++++++--------- pkgs/jni/lib/src/jprimitives.dart | 41 +++++------------------ pkgs/jni/lib/src/types.dart | 6 ---- pkgs/jni/test/jarray_test.dart | 25 ++++++++++++++ pkgs/jni/test/type_test.dart | 26 ++++++++++++++ pkgs/jnigen/lib/src/bindings/visitor.dart | 7 ---- 6 files changed, 75 insertions(+), 63 deletions(-) diff --git a/pkgs/jni/lib/src/jarray.dart b/pkgs/jni/lib/src/jarray.dart index fe92e0540..b07cee0b8 100644 --- a/pkgs/jni/lib/src/jarray.dart +++ b/pkgs/jni/lib/src/jarray.dart @@ -38,8 +38,8 @@ class JArrayType extends JObjType> { @override bool operator ==(Object other) { - return other.runtimeType == JArrayType && - other is JArrayType && + return other.runtimeType == (JArrayType) && + other is JArrayType && elementType == other.elementType; } } @@ -62,7 +62,17 @@ class JArray extends JObject { /// /// The [length] must be a non-negative integer. factory JArray(JType type, int length) { - if (type.callType == JniCallType.objectType && type is JObjType) { + const primitiveCallTypes = { + 'B': JniCallType.byteType, + 'Z': JniCallType.booleanType, + 'C': JniCallType.charType, + 'S': JniCallType.shortType, + 'I': JniCallType.intType, + 'J': JniCallType.longType, + 'F': JniCallType.floatType, + 'D': JniCallType.doubleType, + }; + if (!primitiveCallTypes.containsKey(type.signature) && type is JObjType) { final clazz = (type as JObjType).getClass(); final array = JArray.fromRef( type, @@ -73,7 +83,9 @@ class JArray extends JObject { } return JArray.fromRef( type, - Jni.accessors.newPrimitiveArray(length, type.callType).object, + Jni.accessors + .newPrimitiveArray(length, primitiveCallTypes[type.signature]!) + .object, ); } @@ -357,16 +369,3 @@ extension ObjectArray on JArray { }); } } - -extension ArrayArray on JArray> { - JArray operator [](int index) { - return JArray.fromRef( - (elementType as JArrayType).elementType, - elementAt(index, JniCallType.objectType).object, - ); - } - - void operator []=(int index, JArray value) { - (this as JArray)[index] = value; - } -} diff --git a/pkgs/jni/lib/src/jprimitives.dart b/pkgs/jni/lib/src/jprimitives.dart index f7f8a9aaf..672255726 100644 --- a/pkgs/jni/lib/src/jprimitives.dart +++ b/pkgs/jni/lib/src/jprimitives.dart @@ -6,7 +6,6 @@ // lowercase. // ignore_for_file: camel_case_types -import 'third_party/generated_bindings.dart'; import 'types.dart'; abstract class JPrimitive {} @@ -19,10 +18,7 @@ class jbyteType extends JType { const jbyteType(); @override - int get callType => JniCallType.byteType; - - @override - String get signature => "B"; + final signature = 'B'; } abstract class jboolean extends JPrimitive { @@ -33,10 +29,7 @@ class jbooleanType extends JType { const jbooleanType(); @override - int get callType => JniCallType.booleanType; - - @override - String get signature => "Z"; + final signature = 'Z'; } abstract class jchar extends JPrimitive { @@ -47,10 +40,7 @@ class jcharType extends JType { const jcharType(); @override - int get callType => JniCallType.charType; - - @override - String get signature => "C"; + final signature = 'C'; } abstract class jshort extends JPrimitive { @@ -61,10 +51,7 @@ class jshortType extends JType { const jshortType(); @override - int get callType => JniCallType.shortType; - - @override - String get signature => "S"; + final signature = 'S'; } abstract class jint extends JPrimitive { @@ -75,10 +62,7 @@ class jintType extends JType { const jintType(); @override - int get callType => JniCallType.intType; - - @override - String get signature => "I"; + final signature = 'I'; } abstract class jlong extends JPrimitive { @@ -89,10 +73,7 @@ class jlongType extends JType { const jlongType(); @override - int get callType => JniCallType.longType; - - @override - String get signature => "J"; + final signature = 'J'; } abstract class jfloat extends JPrimitive { @@ -103,10 +84,7 @@ class jfloatType extends JType { const jfloatType(); @override - int get callType => JniCallType.floatType; - - @override - String get signature => "F"; + final signature = 'F'; } abstract class jdouble extends JPrimitive { @@ -117,8 +95,5 @@ class jdoubleType extends JType { const jdoubleType(); @override - int get callType => JniCallType.doubleType; - - @override - String get signature => "D"; + final signature = 'D'; } diff --git a/pkgs/jni/lib/src/types.dart b/pkgs/jni/lib/src/types.dart index 64df75cbc..c6f44b65b 100644 --- a/pkgs/jni/lib/src/types.dart +++ b/pkgs/jni/lib/src/types.dart @@ -6,13 +6,10 @@ import 'dart:ffi'; import 'jni.dart'; import 'jobject.dart'; -import 'third_party/generated_bindings.dart'; abstract class JType { const JType(); - int get callType; - String get signature; } @@ -24,9 +21,6 @@ abstract class JObjType extends JType { const JObjType(); - @override - int get callType => JniCallType.objectType; - /// Creates an object from this type using the reference. T fromRef(Pointer ref); diff --git a/pkgs/jni/test/jarray_test.dart b/pkgs/jni/test/jarray_test.dart index d0bc8cfe0..18550e5e8 100644 --- a/pkgs/jni/test/jarray_test.dart +++ b/pkgs/jni/test/jarray_test.dart @@ -144,6 +144,31 @@ void run({required TestRunnerCallback testRunner}) { }, throwsRangeError); }); }); + testRunner("Java long array", () { + using((arena) { + final array = JArray(jlong.type, 3)..deletedIn(arena); + expect(array.length, 3); + array[0] = 1; + array[1] = 2; + array[2] = 3 + 256 * 256 * 256 * 256 * 5; + expect(array[0], 1); + expect(array[1], 2); + expect(array[2], 3 + 256 * 256 * 256 * 256 * 5); + array.setRange(0, 3, [4, 5, 6, 7], 1); + expect(array[0], 5); + expect(array[1], 6); + expect(array[2], 7); + expect(() { + final _ = array[-1]; + }, throwsRangeError); + expect(() { + array[-1] = 4; + }, throwsRangeError); + expect(() { + array[3] = 4; + }, throwsRangeError); + }); + }); const epsilon = 1e-6; testRunner("Java float array", () { using((arena) { diff --git a/pkgs/jni/test/type_test.dart b/pkgs/jni/test/type_test.dart index ffc11d692..f0f3caaab 100644 --- a/pkgs/jni/test/type_test.dart +++ b/pkgs/jni/test/type_test.dart @@ -236,6 +236,32 @@ void run({required TestRunnerCallback testRunner}) { expect(lowestCommonSuperType([JByte.type, JBoolean.type]), JObject.type); }); + testRunner('array types', () { + using((arena) { + expect( + lowestCommonSuperType([ + JArray.type(jint.type), + JArray.type(jint.type), + ]), + JArray.type(jint.type), + ); + expect( + lowestCommonSuperType([ + JArray.type(JObject.type), + JArray.type(JObject.type), + ]), + JArray.type(JObject.type), + ); + expect( + lowestCommonSuperType([ + JArray.type(JObject.type), + JArray.type(jint.type), + ]), + JObject.type, + ); + }); + }); + testRunner('util types', () { using((arena) { expect( diff --git a/pkgs/jnigen/lib/src/bindings/visitor.dart b/pkgs/jnigen/lib/src/bindings/visitor.dart index c2bf9e65a..417180c85 100644 --- a/pkgs/jnigen/lib/src/bindings/visitor.dart +++ b/pkgs/jnigen/lib/src/bindings/visitor.dart @@ -28,13 +28,6 @@ extension MultiVisitor> on Iterable> { } } -extension MultiTypeVisitor on Iterable { - /// Accepts all lazily. Remember to call `.toList()` or similar methods! - Iterable accept(TypeVisitor v) { - return map((e) => e.accept(v)); - } -} - extension MultiTypeUsageVisitor on Iterable { /// Accepts all lazily. Remember to call `.toList()` or similar methods! Iterable accept(TypeVisitor v) { From d6a05944f1ba3d33d6d5246ecc2db58fad7dec71 Mon Sep 17 00:00:00 2001 From: Mahesh Hegde <46179734+mahesh-hegde@users.noreply.github.com> Date: Thu, 11 May 2023 18:11:25 +0530 Subject: [PATCH 088/139] [jnigen] Summarizer fix class listing (https://github.com/dart-lang/jnigen/issues/272) * Add tests for summarizer failure cases. * Fix class listings --- .../dart_lang/jnigen/apisummarizer/Main.java | 66 ++++---- .../{SearchUtil.java => ClassFinder.java} | 129 ++++++++------- .../util/{JsonUtil.java => JsonWriter.java} | 2 +- .../jnigen/apisummarizer/util/StreamUtil.java | 10 +- pkgs/jnigen/lib/src/generate_bindings.dart | 12 +- pkgs/jnigen/lib/src/summary/summary.dart | 30 +++- pkgs/jnigen/test/summary_generation_test.dart | 148 ++++++++++++------ 7 files changed, 251 insertions(+), 146 deletions(-) rename pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/{SearchUtil.java => ClassFinder.java} (51%) rename pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/{JsonUtil.java => JsonWriter.java} (96%) diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/Main.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/Main.java index 07f4430c2..1eda46005 100644 --- a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/Main.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/Main.java @@ -7,16 +7,14 @@ import com.github.dart_lang.jnigen.apisummarizer.disasm.AsmSummarizer; import com.github.dart_lang.jnigen.apisummarizer.doclet.SummarizerDoclet; import com.github.dart_lang.jnigen.apisummarizer.elements.ClassDecl; -import com.github.dart_lang.jnigen.apisummarizer.util.InputStreamProvider; -import com.github.dart_lang.jnigen.apisummarizer.util.JsonUtil; -import com.github.dart_lang.jnigen.apisummarizer.util.Log; -import com.github.dart_lang.jnigen.apisummarizer.util.SearchUtil; +import com.github.dart_lang.jnigen.apisummarizer.util.*; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.Arrays; +import java.util.LinkedHashMap; import java.util.List; import javax.tools.DocumentationTool; import javax.tools.JavaFileObject; @@ -85,31 +83,42 @@ public static void main(String[] args) throws FileNotFoundException { ? Arrays.asList(options.classPath.split(File.pathSeparator)) : List.of(); - var classStreamProviders = new ArrayList(); - var sourceFiles = new ArrayList(); - var notFound = new ArrayList(); - var javaDoc = ToolProvider.getSystemDocumentationTool(); + var sourceClasses = new LinkedHashMap>(); + var binaryClasses = new LinkedHashMap>(); + for (var qualifiedName : options.args) { - var found = false; - if (options.backend != Backend.ASM) { - var sources = - SearchUtil.findJavaSources( - qualifiedName, sourcePaths, javaDoc.getStandardFileManager(null, null, null)); - if (sources.isPresent()) { - sourceFiles.addAll(sources.get()); - found = true; - } + sourceClasses.put(qualifiedName, null); + binaryClasses.put(qualifiedName, null); + } + + if (options.backend != Backend.ASM) { + ClassFinder.findJavaSources( + sourceClasses, sourcePaths, javaDoc.getStandardFileManager(null, null, null)); + } + + // remove found classes from binaryClasses, so that they don't need to be searched again. + // TODO: Tidy up this logic, move to ClassFinder class + for (var qualifiedName : options.args) { + if (sourceClasses.get(qualifiedName) != null) { + binaryClasses.remove(qualifiedName); } - if (options.backend != Backend.DOCLET && !found) { - var classes = SearchUtil.findJavaClasses(qualifiedName, classPaths); - if (classes.isPresent()) { - classStreamProviders.addAll(classes.get()); - found = true; - } + } + + if (options.backend != Backend.DOCLET) { + ClassFinder.findJavaClasses(binaryClasses, classPaths); + } + + // remove duplicates (found as both source & binary), and determine if any class is not found. + var notFound = new ArrayList(); + for (var qualifiedName : options.args) { + var foundSource = sourceClasses.get(qualifiedName) != null; + var foundBinary = binaryClasses.get(qualifiedName) != null; + if (foundSource) { + binaryClasses.remove(qualifiedName); } - if (!found) { + if (!foundBinary && !foundSource) { notFound.add(qualifiedName); } } @@ -119,12 +128,15 @@ public static void main(String[] args) throws FileNotFoundException { System.exit(1); } + var classStreamProviders = StreamUtil.flattenListValues(binaryClasses); + var sourceFiles = StreamUtil.flattenListValues(sourceClasses); + switch (options.backend) { case DOCLET: - JsonUtil.writeJSON(runDoclet(javaDoc, sourceFiles, options), output); + JsonWriter.writeJSON(runDoclet(javaDoc, sourceFiles, options), output); break; case ASM: - JsonUtil.writeJSON(AsmSummarizer.run(classStreamProviders), output); + JsonWriter.writeJSON(AsmSummarizer.run(classStreamProviders), output); break; case AUTO: List decls = new ArrayList<>(); @@ -134,7 +146,7 @@ public static void main(String[] args) throws FileNotFoundException { if (!classStreamProviders.isEmpty()) { decls.addAll(AsmSummarizer.run(classStreamProviders)); } - JsonUtil.writeJSON(decls, output); + JsonWriter.writeJSON(decls, output); break; } } diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/SearchUtil.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/ClassFinder.java similarity index 51% rename from pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/SearchUtil.java rename to pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/ClassFinder.java index 9f1611d0e..293802248 100644 --- a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/SearchUtil.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/ClassFinder.java @@ -5,55 +5,74 @@ import java.util.*; import java.util.function.BiFunction; import java.util.function.Function; +import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.stream.Collectors; import java.util.zip.ZipEntry; import javax.tools.JavaFileObject; import javax.tools.StandardJavaFileManager; -public class SearchUtil { - public static Optional> findFilesInPath( - String qualifiedName, String searchPath, String suffix) { - var s = qualifiedName.replace(".", File.separator); - var f = new File(searchPath, s + suffix); - if (f.exists() && f.isFile()) { - return Optional.of(List.of(f)); - } +public class ClassFinder { + public static void findFilesInPath( + String searchPath, + String suffix, + Map> classes, + Function, List> mapper) { - var d = new File(searchPath, s); - if (d.exists() && d.isDirectory()) { - return Optional.of(recursiveListFiles(d, file -> file.getName().endsWith(".java"))); - } + for (var binaryName : classes.keySet()) { + if (classes.get(binaryName) != null) { + continue; + } + var s = binaryName.replace(".", File.separator); + var f = new File(searchPath, s + suffix); + if (f.exists() && f.isFile()) { + classes.put(binaryName, mapper.apply(List.of(f))); + } - return Optional.empty(); + var d = new File(searchPath, s); + if (d.exists() && d.isDirectory()) { + var files = recursiveListFiles(d, file -> file.getName().endsWith(suffix)); + classes.put(binaryName, mapper.apply(files)); + } + } } - public static Optional> findFilesInJar( - String qualifiedName, JarFile jar, String suffix) { - String relativePath = qualifiedName.replace(".", "/"); - var classEntry = jar.getEntry(relativePath + suffix); - if (classEntry != null) { - return Optional.of(List.of(classEntry)); - } - var dirPath = relativePath.endsWith("/") ? relativePath : relativePath + "/"; - var dirEntry = jar.getEntry(dirPath); - if (dirEntry != null && dirEntry.isDirectory()) { - var result = - jar.stream() - .map(je -> (ZipEntry) je) - .filter( - entry -> { - var name = entry.getName(); - return name.endsWith(suffix) && name.startsWith(dirPath); - }) + public static void findFilesInJar( + Map> classes, + JarFile jar, + String suffix, + BiFunction, List> mapper) { + var entries = + jar.stream().map(JarEntry::getName).collect(Collectors.toCollection(TreeSet::new)); + for (var binaryName : classes.keySet()) { + if (classes.get(binaryName) != null) { + continue; + } + var relativePath = binaryName.replace('.', '/'); + + var filePath = relativePath + suffix; + if (entries.contains(filePath)) { + var found = List.of(jar.getEntry(filePath)); + classes.put(binaryName, mapper.apply(jar, found)); + } + + // Obtain set of all strings prefixed with relativePath + '/' + var dirPath = relativePath + '/'; + var children = + entries.tailSet(dirPath).stream() + .takeWhile(e -> e.startsWith(dirPath)) + .filter(e -> e.endsWith(suffix)) + .map(jar::getEntry) .collect(Collectors.toList()); - return Optional.of(result); + if (!children.isEmpty()) { + var mapped = mapper.apply(jar, children); + classes.put(binaryName, mapped); + } } - return Optional.empty(); } - public static Optional> find( - String qualifiedName, + public static void find( + Map> classes, List searchPaths, String suffix, Function, List> fileMapper, @@ -61,22 +80,12 @@ public static Optional> find( for (var searchPath : searchPaths) { File searchFile = new File(searchPath); if (searchFile.isDirectory()) { - var result = findFilesInPath(qualifiedName, searchPath, suffix); - if (result.isPresent()) { - var mappedResult = fileMapper.apply(result.get()); - return Optional.of(mappedResult); - } - } - if (searchFile.isFile() && searchPath.endsWith(".jar")) { + findFilesInPath(searchPath, suffix, classes, fileMapper); + } else if (searchFile.isFile() && searchPath.endsWith(".jar")) { var jarFile = ExceptionUtil.wrapCheckedException(JarFile::new, searchPath); - var result = findFilesInJar(qualifiedName, jarFile, suffix); - if (result.isPresent()) { - var mappedResult = entryMapper.apply(jarFile, result.get()); - return Optional.of(mappedResult); - } + findFilesInJar(classes, jarFile, suffix, entryMapper); } } - return Optional.empty(); } private static List getJavaFileObjectsFromFiles( @@ -100,24 +109,26 @@ private static List getInputStreamProvidersFromJar( return StreamUtil.map(entries, entry -> new JarEntryInputStreamProvider(jarFile, entry)); } - public static Optional> findJavaSources( - String qualifiedName, List searchPaths, StandardJavaFileManager fm) { - return find( - qualifiedName, + public static void findJavaSources( + Map> classes, + List searchPaths, + StandardJavaFileManager fm) { + find( + classes, searchPaths, ".java", files -> getJavaFileObjectsFromFiles(files, fm), - SearchUtil::getJavaFileObjectsFromJar); + ClassFinder::getJavaFileObjectsFromJar); } - public static Optional> findJavaClasses( - String qualifiedName, List searchPaths) { - return find( - qualifiedName, + public static void findJavaClasses( + Map> classes, List searchPaths) { + find( + classes, searchPaths, ".class", - SearchUtil::getInputStreamProvidersFromFiles, - SearchUtil::getInputStreamProvidersFromJar); + ClassFinder::getInputStreamProvidersFromFiles, + ClassFinder::getInputStreamProvidersFromJar); } /** diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/JsonUtil.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/JsonWriter.java similarity index 96% rename from pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/JsonUtil.java rename to pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/JsonWriter.java index cf7e8a401..873a6be96 100644 --- a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/JsonUtil.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/JsonWriter.java @@ -8,7 +8,7 @@ import java.io.OutputStream; import java.util.List; -public class JsonUtil { +public class JsonWriter { public static void writeJSON(List classes, OutputStream output) { var mapper = new ObjectMapper(); Log.timed("Writing JSON"); diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/StreamUtil.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/StreamUtil.java index 7dfa29b2f..30a8fa0bd 100644 --- a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/StreamUtil.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/StreamUtil.java @@ -4,8 +4,7 @@ package com.github.dart_lang.jnigen.apisummarizer.util; -import java.util.Arrays; -import java.util.List; +import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; @@ -17,4 +16,11 @@ public static List map(List list, Function function) { public static List map(T[] array, Function function) { return Arrays.stream(array).map(function).collect(Collectors.toList()); } + + public static List flattenListValues(Map> map) { + return map.values().stream() + .filter(Objects::nonNull) + .flatMap(Collection::stream) + .collect(Collectors.toList()); + } } diff --git a/pkgs/jnigen/lib/src/generate_bindings.dart b/pkgs/jnigen/lib/src/generate_bindings.dart index bc4deb0c1..d553657dd 100644 --- a/pkgs/jnigen/lib/src/generate_bindings.dart +++ b/pkgs/jnigen/lib/src/generate_bindings.dart @@ -9,6 +9,7 @@ import 'bindings/dart_generator.dart'; import 'bindings/excluder.dart'; import 'bindings/linker.dart'; import 'bindings/renamer.dart'; +import 'elements/elements.dart'; import 'summary/summary.dart'; import 'config/config.dart'; import 'tools/tools.dart'; @@ -22,7 +23,16 @@ Future generateJniBindings(Config config) async { await buildSummarizerIfNotExists(); - final classes = await getSummary(config); + final Classes classes; + + try { + classes = await getSummary(config); + } on SummaryParseException catch (e) { + if (e.stderr != null) { + printError(e.stderr); + } + log.fatal(e.message); + } final cBased = config.outputConfig.bindingsType == BindingsType.cBased; classes diff --git a/pkgs/jnigen/lib/src/summary/summary.dart b/pkgs/jnigen/lib/src/summary/summary.dart index a2f600e34..31473a631 100644 --- a/pkgs/jnigen/lib/src/summary/summary.dart +++ b/pkgs/jnigen/lib/src/summary/summary.dart @@ -12,6 +12,16 @@ import '../elements/elements.dart'; import '../generate_bindings.dart'; import '../logging/logging.dart'; +class SummaryParseException implements Exception { + final String? stderr; + final String message; + SummaryParseException(this.message) : stderr = null; + SummaryParseException.withStderr(this.stderr, this.message); + + @override + String toString() => message; +} + /// 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 @@ -93,6 +103,8 @@ class SummarizerCommand { } Future getSummary(Config config) async { + // This function is a potential entry point in tests, which set log level to + // warning. setLoggingLevel(config.logLevel); final summarizer = SummarizerCommand( sourcePath: config.sourcePath, @@ -154,24 +166,30 @@ Future getSummary(Config config) async { Process process; Stream> input; + final stopwatch = Stopwatch()..start(); try { process = await summarizer.runProcess(); input = process.stdout; } on Exception catch (e) { - log.fatal('Cannot obtain API summary: $e'); + throw SummaryParseException('Cannot generate API summary: $e'); } - final errorLog = StringBuffer(); - collectOutputStream(process.stderr, errorLog); + final stderrBuffer = StringBuffer(); + collectOutputStream(process.stderr, stderrBuffer); final stream = const JsonDecoder().bind(const Utf8Decoder().bind(input)); dynamic json; try { json = await stream.single; + stopwatch.stop(); + log.info('Parsing inputs took ${stopwatch.elapsedMilliseconds} ms'); } on Exception catch (e) { - printError(errorLog); - log.fatal('Cannot parse summary: $e'); + await process.exitCode; + throw SummaryParseException.withStderr( + stderrBuffer.toString(), + 'Cannot generate summary: $e', + ); } if (json == null) { - log.fatal('Expected JSON element from summarizer.'); + throw SummaryParseException('Expected JSON element from summarizer.'); } final list = json as List; final classes = Classes.fromJson(list); diff --git a/pkgs/jnigen/test/summary_generation_test.dart b/pkgs/jnigen/test/summary_generation_test.dart index 8a4eab157..0133bac36 100644 --- a/pkgs/jnigen/test/summary_generation_test.dart +++ b/pkgs/jnigen/test/summary_generation_test.dart @@ -8,6 +8,7 @@ @Tags(['summarizer_test']) import 'dart:io'; +import 'dart:math'; import 'package:jnigen/src/config/config.dart'; import 'package:jnigen/src/elements/elements.dart'; @@ -20,7 +21,7 @@ import 'package:test/test.dart'; import 'test_util/test_util.dart'; -void expectNonEmptySummary(Classes? classes) { +void expectSummaryHasAllClasses(Classes? classes) { expect(classes, isNotNull); final decls = classes!.decls; expect(decls.entries.length, greaterThanOrEqualTo(javaFiles.length)); @@ -70,6 +71,13 @@ final simplePackagePath = join('test', 'simple_package_test', 'java'); final simplePackageDir = Directory(simplePackagePath); final javaFiles = findFilesWithSuffix(simplePackageDir, '.java'); final javaClasses = javaFiles.map(getClassNameFromPath).toList(); +// remove individual class listings from one package, +// and add the package name instead, for testing. +const _removalPackage = 'com.github.dart_lang.jnigen.pkg2'; +final summarizerClassesSpec = [ + ...javaClasses.where((e) => !e.startsWith('$_removalPackage.')), + _removalPackage, +]; Config getConfig({List? sourcePath, List? classPath}) { return Config( @@ -80,86 +88,126 @@ Config getConfig({List? sourcePath, List? classPath}) { structure: OutputStructure.singleFile, ), ), - classes: javaClasses, + classes: summarizerClassesSpec, sourcePath: sourcePath?.map((e) => Uri.file(e)).toList(), classPath: classPath?.map((e) => Uri.file(e)).toList(), logLevel: Level.WARNING, ); } +final random = Random.secure(); + +void testSuccessCase(String description, Config config) { + config.classes = summarizerClassesSpec; + test(description, () async { + final classes = await getSummary(config); + expectSummaryHasAllClasses(classes); + }); +} + +void testFailureCase( + String description, Config config, String nonExistingClass) { + test(description, () async { + final insertPosition = random.nextInt(config.classes.length + 1); + config.classes = summarizerClassesSpec.sublist(0, insertPosition) + + [nonExistingClass] + + summarizerClassesSpec.sublist(insertPosition); + try { + await getSummary(config); + } on SummaryParseException catch (e) { + expect(e.stderr, isNotNull); + expect(e.stderr!, stringContainsInOrder(["Not found", nonExistingClass])); + return; + } + throw AssertionError("No exception was caught"); + }); +} + +void testAllCases({ + List? sourcePath, + List? classPath, +}) { + testSuccessCase( + '- valid config', + getConfig(sourcePath: sourcePath, classPath: classPath), + ); + testFailureCase( + '- should fail with non-existing class', + getConfig(sourcePath: sourcePath, classPath: classPath), + 'com.github.dart_lang.jnigen.DoesNotExist', + ); + testFailureCase( + '- should fail with non-existing package', + getConfig(sourcePath: sourcePath, classPath: classPath), + 'com.github.dart_lang.notexist', + ); +} + void main() async { await checkLocallyBuiltDependencies(); - late Directory tempDir; - setUpAll(() async { - tempDir = getTempDir("jnigen_summary_tests_"); - }); + final tempDir = getTempDir("jnigen_summary_tests_"); - test('Test summary generation from compiled JAR', () async { + group('Test summary generation from compiled JAR', () { final targetDir = tempDir.createTempSync("compiled_jar_test_"); - await compileJavaFiles(simplePackageDir, targetDir); - final classFiles = findFilesWithSuffix(targetDir, '.class'); final jarPath = join(targetDir.absolute.path, 'classes.jar'); - await createJar( - artifactDir: targetDir.path, artifacts: classFiles, jarPath: jarPath); - final config = getConfig(classPath: [jarPath]); - final summaryClasses = await getSummary(config); - expectNonEmptySummary(summaryClasses); + setUpAll(() async { + await compileJavaFiles(simplePackageDir, targetDir); + final classFiles = findFilesWithSuffix(targetDir, '.class'); + await createJar( + artifactDir: targetDir.path, artifacts: classFiles, jarPath: jarPath); + }); + testAllCases(classPath: [jarPath]); }); - test('Test summary generation from source JAR', () async { + group('Test summary generation from source JAR', () { final targetDir = tempDir.createTempSync("source_jar_test_"); final jarPath = join(targetDir.path, 'sources.jar'); - await createJar( - artifactDir: simplePackageDir.path, - artifacts: javaFiles, - jarPath: jarPath); - final config = getConfig(sourcePath: [jarPath]); - final summaryClasses = await getSummary(config); - expectNonEmptySummary(summaryClasses); + setUpAll(() async { + await createJar( + artifactDir: simplePackageDir.path, + artifacts: javaFiles, + jarPath: jarPath); + }); + testAllCases(sourcePath: [jarPath]); }); - test('Test summary generation from source folder', () async { - final config = getConfig(sourcePath: [simplePackagePath]); - final summaryClasses = await getSummary(config); - expectNonEmptySummary(summaryClasses); + group('Test summary generation from source folder', () { + testAllCases(sourcePath: [simplePackagePath]); }); - test('Test summary generation from compiled classes in directory', () async { + group('Test summary generation from compiled classes in directory', () { final targetDir = tempDir.createTempSync("compiled_classes_test_"); - await compileJavaFiles(simplePackageDir, targetDir); - final config = getConfig(classPath: [targetDir.path]); - final summaryClasses = await getSummary(config); - expectNonEmptySummary(summaryClasses); + setUpAll(() => compileJavaFiles(simplePackageDir, targetDir)); + testAllCases(classPath: [targetDir.path]); }); // Test summary generation from combination of a source and class path - test('Test summary generation from combination', () async { + group('Test summary generation from combination', () { final targetDir = tempDir.createTempSync("combination_test_"); - + final classesJarPath = join(targetDir.path, 'classes.jar'); // remove a class from source files and create a source JAR final sourceFiles = javaFiles.toList(); sourceFiles.removeLast(); final sourceJarPath = join(targetDir.path, 'sources.jar'); - await createJar( - artifactDir: simplePackageDir.path, - artifacts: sourceFiles, - jarPath: sourceJarPath, - ); - - await compileJavaFiles(simplePackageDir, targetDir); - final classFiles = findFilesWithSuffix(targetDir, '.class'); - final classesJarPath = join(targetDir.path, 'classes.jar'); - await createJar( - artifactDir: targetDir.path, - artifacts: classFiles, - jarPath: classesJarPath, - ); - final config = getConfig( + setUpAll(() async { + await createJar( + artifactDir: simplePackageDir.path, + artifacts: sourceFiles, + jarPath: sourceJarPath, + ); + + await compileJavaFiles(simplePackageDir, targetDir); + final classFiles = findFilesWithSuffix(targetDir, '.class'); + await createJar( + artifactDir: targetDir.path, + artifacts: classFiles, + jarPath: classesJarPath, + ); + }); + testAllCases( classPath: [classesJarPath], sourcePath: [sourceJarPath], ); - final summaryClasses = await getSummary(config); - expectNonEmptySummary(summaryClasses); }); tearDownAll(() => deleteTempDir(tempDir)); From 58a1e635675425814d86b6f21c2ab508f7b52b9f Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Fri, 12 May 2023 15:13:35 +0200 Subject: [PATCH 089/139] [jnigen] CI fix (https://github.com/dart-lang/jnigen/issues/277) --- .github/workflows/test-package.yml | 2 +- pkgs/jni/example/pubspec.lock | 60 ++++---- pkgs/jnigen/android_test_runner/lib/main.dart | 4 +- .../example/in_app_java/android/build.gradle | 2 +- .../example/android/build.gradle | 2 +- .../example/android/build.gradle | 2 +- .../example/android/build.gradle | 2 +- .../apache/pdfbox/text/PDFTextStripper.dart | 32 ++--- .../c_based/dart_bindings/simple_package.dart | 136 +++++++++--------- 9 files changed, 117 insertions(+), 125 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index aa8b68474..6a763822b 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -140,7 +140,7 @@ jobs: sudo apt-get install -y clang-format build-essential cmake - run: flutter pub get - name: Check formatting - run: flutter format --output=none --set-exit-if-changed . + run: dart format --output=none --set-exit-if-changed . - name: Run lints run: flutter analyze --fatal-infos - name: Check C code formatting using clang-format diff --git a/pkgs/jni/example/pubspec.lock b/pkgs/jni/example/pubspec.lock index 5925148f1..2edbc759c 100644 --- a/pkgs/jni/example/pubspec.lock +++ b/pkgs/jni/example/pubspec.lock @@ -17,14 +17,6 @@ packages: url: "https://pub.dev" source: hosted version: "5.10.0" - archive: - dependency: transitive - description: - name: archive - sha256: "80e5141fafcb3361653ce308776cfd7d45e6e9fbb429e14eec571382c0c5fecb" - url: "https://pub.dev" - source: hosted - version: "3.3.2" args: dependency: transitive description: @@ -37,10 +29,10 @@ packages: dependency: transitive description: name: async - sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" url: "https://pub.dev" source: hosted - version: "2.10.0" + version: "2.11.0" boolean_selector: dependency: transitive description: @@ -53,10 +45,10 @@ packages: dependency: transitive description: name: characters - sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.3.0" clock: dependency: transitive description: @@ -69,10 +61,10 @@ packages: dependency: transitive description: name: collection - sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 + sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" url: "https://pub.dev" source: hosted - version: "1.17.0" + version: "1.17.1" convert: dependency: transitive description: @@ -208,15 +200,15 @@ packages: path: ".." relative: true source: path - version: "0.3.0" + version: "0.5.0-dev.0" js: dependency: transitive description: name: js - sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 url: "https://pub.dev" source: hosted - version: "0.6.5" + version: "0.6.7" lints: dependency: transitive description: @@ -237,10 +229,10 @@ packages: dependency: transitive description: name: matcher - sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" + sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" url: "https://pub.dev" source: hosted - version: "0.12.13" + version: "0.12.15" material_color_utilities: dependency: transitive description: @@ -253,10 +245,10 @@ packages: dependency: transitive description: name: meta - sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" + sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.9.1" mime: dependency: transitive description: @@ -285,10 +277,10 @@ packages: dependency: transitive description: name: path - sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" url: "https://pub.dev" source: hosted - version: "1.8.2" + version: "1.8.3" platform: dependency: transitive description: @@ -434,26 +426,26 @@ packages: dependency: "direct dev" description: name: test - sha256: a5fcd2d25eeadbb6589e80198a47d6a464ba3e2049da473943b8af9797900c2d + sha256: "3dac9aecf2c3991d09b9cdde4f98ded7b30804a88a0d7e4e7e1678e78d6b97f4" url: "https://pub.dev" source: hosted - version: "1.22.0" + version: "1.24.1" test_api: dependency: transitive description: name: test_api - sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 + sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb url: "https://pub.dev" source: hosted - version: "0.4.16" + version: "0.5.1" test_core: dependency: transitive description: name: test_core - sha256: "0ef9755ec6d746951ba0aabe62f874b707690b5ede0fecc818b138fcc9b14888" + sha256: "5138dbffb77b2289ecb12b81c11ba46036590b72a64a7a90d6ffb880f1a29e93" url: "https://pub.dev" source: hosted - version: "0.4.20" + version: "0.5.1" typed_data: dependency: transitive description: @@ -474,10 +466,10 @@ packages: dependency: transitive description: name: vm_service - sha256: e7fb6c2282f7631712b69c19d1bff82f3767eea33a2321c14fa59ad67ea391c7 + sha256: f6deed8ed625c52864792459709183da231ebf66ff0cf09e69b573227c377efe url: "https://pub.dev" source: hosted - version: "9.4.0" + version: "11.3.0" watcher: dependency: transitive description: @@ -498,10 +490,10 @@ packages: dependency: transitive description: name: webdriver - sha256: ef67178f0cc7e32c1494645b11639dd1335f1d18814aa8435113a92e9ef9d841 + sha256: "3c923e918918feeb90c4c9fdf1fe39220fa4c0e8e2c0fffaded174498ef86c49" url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "3.0.2" webkit_inspection_protocol: dependency: transitive description: @@ -519,5 +511,5 @@ packages: source: hosted version: "3.1.1" sdks: - dart: ">=2.19.0 <3.0.0" + dart: ">=3.0.0-0 <4.0.0" flutter: ">=2.11.0" diff --git a/pkgs/jnigen/android_test_runner/lib/main.dart b/pkgs/jnigen/android_test_runner/lib/main.dart index ee6f2d812..da07cdd5b 100644 --- a/pkgs/jnigen/android_test_runner/lib/main.dart +++ b/pkgs/jnigen/android_test_runner/lib/main.dart @@ -37,10 +37,10 @@ class MyHomePage extends StatelessWidget { appBar: AppBar( title: const Text("Integration test runner"), ), - body: Center( + body: const Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, - children: const [ + children: [ Text( 'This app should be run as flutter integration test', ), diff --git a/pkgs/jnigen/example/in_app_java/android/build.gradle b/pkgs/jnigen/example/in_app_java/android/build.gradle index 88265a9b1..2fbab8036 100644 --- a/pkgs/jnigen/example/in_app_java/android/build.gradle +++ b/pkgs/jnigen/example/in_app_java/android/build.gradle @@ -27,6 +27,6 @@ subprojects { project.evaluationDependsOn(':app') } -task clean(type: Delete) { +tasks.register("clean", Delete) { delete rootProject.buildDir } diff --git a/pkgs/jnigen/example/kotlin_plugin/example/android/build.gradle b/pkgs/jnigen/example/kotlin_plugin/example/android/build.gradle index 58a8c74b1..713d7f6e6 100644 --- a/pkgs/jnigen/example/kotlin_plugin/example/android/build.gradle +++ b/pkgs/jnigen/example/kotlin_plugin/example/android/build.gradle @@ -26,6 +26,6 @@ subprojects { project.evaluationDependsOn(':app') } -task clean(type: Delete) { +tasks.register("clean", Delete) { delete rootProject.buildDir } diff --git a/pkgs/jnigen/example/notification_plugin/example/android/build.gradle b/pkgs/jnigen/example/notification_plugin/example/android/build.gradle index 83ae22004..3cdaac958 100644 --- a/pkgs/jnigen/example/notification_plugin/example/android/build.gradle +++ b/pkgs/jnigen/example/notification_plugin/example/android/build.gradle @@ -26,6 +26,6 @@ subprojects { project.evaluationDependsOn(':app') } -task clean(type: Delete) { +tasks.register("clean", Delete) { delete rootProject.buildDir } diff --git a/pkgs/jnigen/example/pdfbox_plugin/example/android/build.gradle b/pkgs/jnigen/example/pdfbox_plugin/example/android/build.gradle index 83ae22004..3cdaac958 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/example/android/build.gradle +++ b/pkgs/jnigen/example/pdfbox_plugin/example/android/build.gradle @@ -26,6 +26,6 @@ subprojects { project.evaluationDependsOn(':app') } -task clean(type: Delete) { +tasks.register("clean", Delete) { delete rootProject.buildDir } 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 eb3912929..1ae50f7f1 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 @@ -62,12 +62,12 @@ class PDFTextStripper extends jni.JObject { static final _get_LINE_SEPARATOR = jniLookup< ffi.NativeFunction< jni.JniResult Function( - jni.JObjectPtr, - )>>("get_PDFTextStripper__LINE_SEPARATOR") + jni.JObjectPtr, + )>>("get_PDFTextStripper__LINE_SEPARATOR") .asFunction< jni.JniResult Function( - jni.JObjectPtr, - )>(); + jni.JObjectPtr, + )>(); /// from: protected final java.lang.String LINE_SEPARATOR /// The returned object must be deleted after use, by calling the `delete` method. @@ -79,12 +79,12 @@ class PDFTextStripper extends jni.JObject { static final _get_charactersByArticle = jniLookup< ffi.NativeFunction< jni.JniResult Function( - jni.JObjectPtr, - )>>("get_PDFTextStripper__charactersByArticle") + jni.JObjectPtr, + )>>("get_PDFTextStripper__charactersByArticle") .asFunction< jni.JniResult Function( - jni.JObjectPtr, - )>(); + jni.JObjectPtr, + )>(); static final _set_charactersByArticle = jniLookup< ffi.NativeFunction< @@ -133,12 +133,12 @@ class PDFTextStripper extends jni.JObject { static final _get_document = jniLookup< ffi.NativeFunction< jni.JniResult Function( - jni.JObjectPtr, - )>>("get_PDFTextStripper__document") + jni.JObjectPtr, + )>>("get_PDFTextStripper__document") .asFunction< jni.JniResult Function( - jni.JObjectPtr, - )>(); + jni.JObjectPtr, + )>(); static final _set_document = jniLookup< ffi.NativeFunction< @@ -160,12 +160,12 @@ class PDFTextStripper extends jni.JObject { static final _get_output = jniLookup< ffi.NativeFunction< jni.JniResult Function( - jni.JObjectPtr, - )>>("get_PDFTextStripper__output") + jni.JObjectPtr, + )>>("get_PDFTextStripper__output") .asFunction< jni.JniResult Function( - jni.JObjectPtr, - )>(); + jni.JObjectPtr, + )>(); static final _set_output = jniLookup< ffi.NativeFunction< diff --git a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart index d8b09c731..70e0d7105 100644 --- a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart @@ -933,12 +933,12 @@ class Fields extends jni.JObject { static final _get_i = jniLookup< ffi.NativeFunction< jni.JniResult Function( - jni.JObjectPtr, - )>>("get_Fields__i") + jni.JObjectPtr, + )>>("get_Fields__i") .asFunction< jni.JniResult Function( - jni.JObjectPtr, - )>(); + jni.JObjectPtr, + )>(); static final _set_i = jniLookup< ffi.NativeFunction< @@ -959,12 +959,12 @@ class Fields extends jni.JObject { static final _get_trillion = jniLookup< ffi.NativeFunction< jni.JniResult Function( - jni.JObjectPtr, - )>>("get_Fields__trillion") + jni.JObjectPtr, + )>>("get_Fields__trillion") .asFunction< jni.JniResult Function( - jni.JObjectPtr, - )>(); + jni.JObjectPtr, + )>(); static final _set_trillion = jniLookup< ffi.NativeFunction< @@ -981,12 +981,12 @@ class Fields extends jni.JObject { static final _get_isAchillesDead = jniLookup< ffi.NativeFunction< jni.JniResult Function( - jni.JObjectPtr, - )>>("get_Fields__isAchillesDead") + jni.JObjectPtr, + )>>("get_Fields__isAchillesDead") .asFunction< jni.JniResult Function( - jni.JObjectPtr, - )>(); + jni.JObjectPtr, + )>(); static final _set_isAchillesDead = jniLookup< ffi.NativeFunction< @@ -1004,12 +1004,12 @@ class Fields extends jni.JObject { static final _get_bestFighterInGreece = jniLookup< ffi.NativeFunction< jni.JniResult Function( - jni.JObjectPtr, - )>>("get_Fields__bestFighterInGreece") + jni.JObjectPtr, + )>>("get_Fields__bestFighterInGreece") .asFunction< jni.JniResult Function( - jni.JObjectPtr, - )>(); + jni.JObjectPtr, + )>(); static final _set_bestFighterInGreece = jniLookup< ffi.NativeFunction< @@ -1031,12 +1031,12 @@ class Fields extends jni.JObject { static final _get_random = jniLookup< ffi.NativeFunction< jni.JniResult Function( - jni.JObjectPtr, - )>>("get_Fields__random") + jni.JObjectPtr, + )>>("get_Fields__random") .asFunction< jni.JniResult Function( - jni.JObjectPtr, - )>(); + jni.JObjectPtr, + )>(); static final _set_random = jniLookup< ffi.NativeFunction< @@ -1121,12 +1121,12 @@ class Fields_Nested extends jni.JObject { static final _get_hundred = jniLookup< ffi.NativeFunction< jni.JniResult Function( - jni.JObjectPtr, - )>>("get_Fields_Nested__hundred") + jni.JObjectPtr, + )>>("get_Fields_Nested__hundred") .asFunction< jni.JniResult Function( - jni.JObjectPtr, - )>(); + jni.JObjectPtr, + )>(); static final _set_hundred = jniLookup< ffi.NativeFunction< @@ -1341,12 +1341,12 @@ class GrandParent<$T extends jni.JObject> extends jni.JObject { static final _get_value = jniLookup< ffi.NativeFunction< jni.JniResult Function( - jni.JObjectPtr, - )>>("get_GrandParent__value") + jni.JObjectPtr, + )>>("get_GrandParent__value") .asFunction< jni.JniResult Function( - jni.JObjectPtr, - )>(); + jni.JObjectPtr, + )>(); static final _set_value = jniLookup< ffi.NativeFunction< @@ -1521,12 +1521,12 @@ class GrandParent_Parent<$T extends jni.JObject, $S extends jni.JObject> static final _get_parentValue = jniLookup< ffi.NativeFunction< jni.JniResult Function( - jni.JObjectPtr, - )>>("get_GrandParent_Parent__parentValue") + jni.JObjectPtr, + )>>("get_GrandParent_Parent__parentValue") .asFunction< jni.JniResult Function( - jni.JObjectPtr, - )>(); + jni.JObjectPtr, + )>(); static final _set_parentValue = jniLookup< ffi.NativeFunction< @@ -1548,12 +1548,12 @@ class GrandParent_Parent<$T extends jni.JObject, $S extends jni.JObject> static final _get_value = jniLookup< ffi.NativeFunction< jni.JniResult Function( - jni.JObjectPtr, - )>>("get_GrandParent_Parent__value") + jni.JObjectPtr, + )>>("get_GrandParent_Parent__value") .asFunction< jni.JniResult Function( - jni.JObjectPtr, - )>(); + jni.JObjectPtr, + )>(); static final _set_value = jniLookup< ffi.NativeFunction< @@ -1668,12 +1668,12 @@ class GrandParent_Parent_Child<$T extends jni.JObject, $S extends jni.JObject, static final _get_grandParentValue = jniLookup< ffi.NativeFunction< jni.JniResult Function( - jni.JObjectPtr, - )>>("get_GrandParent_Parent_Child__grandParentValue") + jni.JObjectPtr, + )>>("get_GrandParent_Parent_Child__grandParentValue") .asFunction< jni.JniResult Function( - jni.JObjectPtr, - )>(); + jni.JObjectPtr, + )>(); static final _set_grandParentValue = jniLookup< ffi.NativeFunction< @@ -1695,12 +1695,12 @@ class GrandParent_Parent_Child<$T extends jni.JObject, $S extends jni.JObject, static final _get_parentValue = jniLookup< ffi.NativeFunction< jni.JniResult Function( - jni.JObjectPtr, - )>>("get_GrandParent_Parent_Child__parentValue") + jni.JObjectPtr, + )>>("get_GrandParent_Parent_Child__parentValue") .asFunction< jni.JniResult Function( - jni.JObjectPtr, - )>(); + jni.JObjectPtr, + )>(); static final _set_parentValue = jniLookup< ffi.NativeFunction< @@ -1722,12 +1722,12 @@ class GrandParent_Parent_Child<$T extends jni.JObject, $S extends jni.JObject, static final _get_value = jniLookup< ffi.NativeFunction< jni.JniResult Function( - jni.JObjectPtr, - )>>("get_GrandParent_Parent_Child__value") + jni.JObjectPtr, + )>>("get_GrandParent_Parent_Child__value") .asFunction< jni.JniResult Function( - jni.JObjectPtr, - )>(); + jni.JObjectPtr, + )>(); static final _set_value = jniLookup< ffi.NativeFunction< @@ -1848,12 +1848,12 @@ class GrandParent_StaticParent<$S extends jni.JObject> extends jni.JObject { static final _get_value = jniLookup< ffi.NativeFunction< jni.JniResult Function( - jni.JObjectPtr, - )>>("get_GrandParent_StaticParent__value") + jni.JObjectPtr, + )>>("get_GrandParent_StaticParent__value") .asFunction< jni.JniResult Function( - jni.JObjectPtr, - )>(); + jni.JObjectPtr, + )>(); static final _set_value = jniLookup< ffi.NativeFunction< @@ -1954,12 +1954,12 @@ class GrandParent_StaticParent_Child<$S extends jni.JObject, static final _get_parentValue = jniLookup< ffi.NativeFunction< jni.JniResult Function( - jni.JObjectPtr, - )>>("get_GrandParent_StaticParent_Child__parentValue") + jni.JObjectPtr, + )>>("get_GrandParent_StaticParent_Child__parentValue") .asFunction< jni.JniResult Function( - jni.JObjectPtr, - )>(); + jni.JObjectPtr, + )>(); static final _set_parentValue = jniLookup< ffi.NativeFunction< @@ -1981,12 +1981,12 @@ class GrandParent_StaticParent_Child<$S extends jni.JObject, static final _get_value = jniLookup< ffi.NativeFunction< jni.JniResult Function( - jni.JObjectPtr, - )>>("get_GrandParent_StaticParent_Child__value") + jni.JObjectPtr, + )>>("get_GrandParent_StaticParent_Child__value") .asFunction< jni.JniResult Function( - jni.JObjectPtr, - )>(); + jni.JObjectPtr, + )>(); static final _set_value = jniLookup< ffi.NativeFunction< @@ -2221,12 +2221,12 @@ class MyMap_MyEntry<$K extends jni.JObject, $V extends jni.JObject> static final _get_key = jniLookup< ffi.NativeFunction< jni.JniResult Function( - jni.JObjectPtr, - )>>("get_MyMap_MyEntry__key") + jni.JObjectPtr, + )>>("get_MyMap_MyEntry__key") .asFunction< jni.JniResult Function( - jni.JObjectPtr, - )>(); + jni.JObjectPtr, + )>(); static final _set_key = jniLookup< ffi.NativeFunction< @@ -2246,12 +2246,12 @@ class MyMap_MyEntry<$K extends jni.JObject, $V extends jni.JObject> static final _get_value = jniLookup< ffi.NativeFunction< jni.JniResult Function( - jni.JObjectPtr, - )>>("get_MyMap_MyEntry__value") + jni.JObjectPtr, + )>>("get_MyMap_MyEntry__value") .asFunction< jni.JniResult Function( - jni.JObjectPtr, - )>(); + jni.JObjectPtr, + )>(); static final _set_value = jniLookup< ffi.NativeFunction< From 7452aae59094c59e78237933429bfad45262d185 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Mon, 15 May 2023 16:28:16 +0200 Subject: [PATCH 090/139] [jnigen] closes https://github.com/dart-lang/jnigen/issues/280 (https://github.com/dart-lang/jnigen/issues/281) --- pkgs/jni/example/android/build.gradle | 2 +- pkgs/jni/lib/src/util/jlist.dart | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/jni/example/android/build.gradle b/pkgs/jni/example/android/build.gradle index 83ae22004..3cdaac958 100644 --- a/pkgs/jni/example/android/build.gradle +++ b/pkgs/jni/example/android/build.gradle @@ -26,6 +26,6 @@ subprojects { project.evaluationDependsOn(':app') } -task clean(type: Delete) { +tasks.register("clean", Delete) { delete rootProject.buildDir } diff --git a/pkgs/jni/lib/src/util/jlist.dart b/pkgs/jni/lib/src/util/jlist.dart index 577ef8917..eac7f20c5 100644 --- a/pkgs/jni/lib/src/util/jlist.dart +++ b/pkgs/jni/lib/src/util/jlist.dart @@ -112,8 +112,8 @@ class JList<$E extends JObject> extends JObject with ListMixin<$E> { .getMethodIDOf(_class.reference, r"add", r"(Ljava/lang/Object;)Z"); @override void add($E element) { - Jni.accessors.callMethodWithArgs( - reference, _addId, JniCallType.voidType, [element.reference]).check(); + Jni.accessors.callMethodWithArgs(reference, _addId, JniCallType.booleanType, + [element.reference]).check(); } static final _collectionClass = Jni.findJClass("java/util/Collection"); From 31eb7b8b53d80da08509249a563e13d518fbe12c Mon Sep 17 00:00:00 2001 From: Mahesh Hegde <46179734+mahesh-hegde@users.noreply.github.com> Date: Tue, 16 May 2023 13:51:34 +0530 Subject: [PATCH 091/139] [jnigen] Fix encoding bug (https://github.com/dart-lang/jnigen/issues/279) * Use UTF-16 in strings --- .../integration_test/on_device_jni_test.dart | 2 + pkgs/jni/example/lib/main.dart | 7 +++ pkgs/jni/lib/src/lang/jstring.dart | 11 +++-- pkgs/jni/src/third_party/global_jni_env.c | 4 -- pkgs/jni/test/jstring_test.dart | 46 +++++++++++++++++++ .../generate_c_extensions.dart | 1 + 6 files changed, 62 insertions(+), 9 deletions(-) create mode 100644 pkgs/jni/test/jstring_test.dart 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 f9ae286cd..cdc729669 100644 --- a/pkgs/jni/example/integration_test/on_device_jni_test.dart +++ b/pkgs/jni/example/integration_test/on_device_jni_test.dart @@ -9,6 +9,7 @@ import '../../test/exception_test.dart' as exception_test; import '../../test/jlist_test.dart' as jlist_test; import '../../test/jmap_test.dart' as jmap_test; import '../../test/jobject_test.dart' as jobject_test; +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; @@ -26,6 +27,7 @@ void main() { jlist_test.run, jmap_test.run, jobject_test.run, + jstring_test.run, jset_test.run, jarray_test.run, boxed_test.run, diff --git a/pkgs/jni/example/lib/main.dart b/pkgs/jni/example/lib/main.dart index 50c3c75b3..b2ca2b715 100644 --- a/pkgs/jni/example/lib/main.dart +++ b/pkgs/jni/example/lib/main.dart @@ -55,6 +55,12 @@ int uptime() { ); } +String backAndForth() { + final jstring = '🪓'.toJString(); + final dartString = jstring.toDartString(deleteOriginal: true); + return dartString; +} + void quit() { JObject.fromRef(Jni.getCurrentActivity()) .use((ac) => ac.callMethodByName("finish", "()V", [])); @@ -94,6 +100,7 @@ void main() { if (Platform.isAndroid) ...[ Example("Minutes of usage since reboot", () => (uptime() / (60 * 1000)).floor()), + Example("Back and forth string conversion", () => backAndForth()), Example( "Device name", () => Jni.retrieveStaticField( diff --git a/pkgs/jni/lib/src/lang/jstring.dart b/pkgs/jni/lib/src/lang/jstring.dart index 1361b53d1..fff169c7a 100644 --- a/pkgs/jni/lib/src/lang/jstring.dart +++ b/pkgs/jni/lib/src/lang/jstring.dart @@ -49,8 +49,8 @@ class JString extends JObject { JString.fromRef(JStringPtr reference) : super.fromRef(reference); static JStringPtr _toJavaString(String s) => using((arena) { - final chars = s.toNativeUtf8(allocator: arena).cast(); - final jstr = Jni.env.NewStringUTF(chars); + final chars = s.toNativeUtf16(allocator: arena).cast(); + final jstr = Jni.env.NewString(chars, s.length); if (jstr == nullptr) { throw 'Fatal: cannot convert string to Java string: $s'; } @@ -72,9 +72,10 @@ class JString extends JObject { if (reference == nullptr) { throw NullJStringException(); } - final chars = Jni.env.GetStringUTFChars(reference, nullptr); - final result = chars.cast().toDartString(); - Jni.env.ReleaseStringUTFChars(reference, chars); + final length = Jni.env.GetStringLength(reference); + final chars = Jni.env.GetStringChars(reference, nullptr); + final result = chars.cast().toDartString(length: length); + Jni.env.ReleaseStringChars(reference, chars); if (deleteOriginal) { delete(); } diff --git a/pkgs/jni/src/third_party/global_jni_env.c b/pkgs/jni/src/third_party/global_jni_env.c index c5be7b069..7ddc16414 100644 --- a/pkgs/jni/src/third_party/global_jni_env.c +++ b/pkgs/jni/src/third_party/global_jni_env.c @@ -2181,10 +2181,6 @@ jthrowable globalEnv_ReleasePrimitiveArrayCritical(jarray array, JniPointerResult globalEnv_GetStringCritical(jstring str, jboolean* isCopy) { attach_thread(); const jchar* _result = (*jniEnv)->GetStringCritical(jniEnv, str, isCopy); - jthrowable _exception = check_exception(); - if (_exception != NULL) { - return (JniPointerResult){.value = NULL, .exception = _exception}; - } return (JniPointerResult){.value = _result, .exception = NULL}; } diff --git a/pkgs/jni/test/jstring_test.dart b/pkgs/jni/test/jstring_test.dart new file mode 100644 index 000000000..1bc6436af --- /dev/null +++ b/pkgs/jni/test/jstring_test.dart @@ -0,0 +1,46 @@ +// 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 'dart:io'; + +import 'package:jni/jni.dart'; +import 'package:test/test.dart'; + +import 'test_util/test_util.dart'; + +void main() { + // Don't forget to initialize JNI. + if (!Platform.isAndroid) { + checkDylibIsUpToDate(); + Jni.spawnIfNotExists(dylibDir: "build/jni_libs", jvmOptions: ["-Xmx128m"]); + } + run(testRunner: test); +} + +void testStringBackAndForth(String str) { + final jstring = str.toJString(); + final dartString = jstring.toDartString(deleteOriginal: true); + expect(dartString, str); +} + +void run({required TestRunnerCallback testRunner}) { + group("String encoding tests", () { + testRunner('Long string back-and-forth', () { + testStringBackAndForth('1' * 8096); + }); + + testRunner('#278 UTF-8 bug', () { + testStringBackAndForth('🐬'); + }); + + testRunner('String containing null character', () { + final str = 'A${String.fromCharCode(0)}B'; + testStringBackAndForth(str); + }); + + testRunner('Zero length string', () { + testStringBackAndForth(''); + }); + }); +} diff --git a/pkgs/jni/tool/wrapper_generators/generate_c_extensions.dart b/pkgs/jni/tool/wrapper_generators/generate_c_extensions.dart index cde47c9a0..f1e15b21e 100644 --- a/pkgs/jni/tool/wrapper_generators/generate_c_extensions.dart +++ b/pkgs/jni/tool/wrapper_generators/generate_c_extensions.dart @@ -206,6 +206,7 @@ const constBufferReturningFunctions = { /// Methods which do not throw exceptions, and thus not need to be checked const _noCheckException = { 'GetVersion', + 'GetStringCritical', 'ExceptionClear', 'ExceptionDescribe', }; From 1ecd702b3ded1c028e631ecb72dadb9f7c85f5fc Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Tue, 16 May 2023 17:18:37 +0200 Subject: [PATCH 092/139] [jnigen] Refactor C bindings generation (https://github.com/dart-lang/jnigen/issues/282) --- pkgs/jnigen/lib/src/bindings/c_bindings.dart | 307 --------------- pkgs/jnigen/lib/src/bindings/c_generator.dart | 353 ++++++++++++++++++ .../lib/src/bindings/dart_generator.dart | 39 +- pkgs/jnigen/lib/src/elements/elements.dart | 2 +- pkgs/jnigen/lib/src/generate_bindings.dart | 6 +- pkgs/jnigen/lib/src/util/string_util.dart | 13 + .../lib/src/writers/bindings_writer.dart | 88 ----- 7 files changed, 393 insertions(+), 415 deletions(-) delete mode 100644 pkgs/jnigen/lib/src/bindings/c_bindings.dart create mode 100644 pkgs/jnigen/lib/src/util/string_util.dart delete mode 100644 pkgs/jnigen/lib/src/writers/bindings_writer.dart diff --git a/pkgs/jnigen/lib/src/bindings/c_bindings.dart b/pkgs/jnigen/lib/src/bindings/c_bindings.dart deleted file mode 100644 index 4f1cad52a..000000000 --- a/pkgs/jnigen/lib/src/bindings/c_bindings.dart +++ /dev/null @@ -1,307 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -import '../config/config.dart'; -import '../elements/elements.dart'; -import 'c_generator.dart'; - -class CBindingGenerator { - static const classVarPrefix = '_c'; - static const methodVarPrefix = '_m'; - static const fieldVarPrefix = '_f'; - static final indent = ' ' * 4; - static const jniResultType = 'JniResult'; - static const ifError = - '(JniResult){.value = {.j = 0}, .exception = check_exception()}'; - - // These should be avoided in parameter names. - static const _cTypeKeywords = { - 'short', - 'char', - 'int', - 'long', - 'float', - 'double', - }; - - String _renameCParam(String paramName) => - _cTypeKeywords.contains(paramName) ? '${paramName}0' : paramName; - - CBindingGenerator(this.config); - Config config; - - String generateBinding(ClassDecl c) => _class(c); - - String _class(ClassDecl c) { - final s = StringBuffer(); - final classNameInC = c.uniqueName; - // global variable in C that holds the reference to class - final classVar = '${classVarPrefix}_$classNameInC'; - s.write('// ${c.binaryName}\n' - 'jclass $classVar = NULL;\n\n'); - - for (var m in c.methods) { - s.write(_method(c, m)); - s.writeln(); - } - - for (var f in c.fields) { - final fieldBinding = _field(c, f); - s.write(fieldBinding); - // Fields are skipped if they're static final. In that case - // do not write too much whitespace. - if (fieldBinding.isNotEmpty) s.writeln(); - } - return s.toString(); - } - - String getCType(String binaryName) { - switch (binaryName) { - case "void": - return "void"; - case "byte": - return "int8_t"; - case "char": - return "uint16_t"; - case "double": - return "double"; - case "float": - return "float"; - case "int": - return "int32_t"; - case "long": - return "int64_t"; - case "short": - return "int16_t"; - case "boolean": - return "uint8_t"; - default: - return "jobject"; - } - } - - String _method(ClassDecl c, Method m) { - final classNameInC = c.uniqueName; - final isACtor = m.isCtor; - final isStatic = m.isStatic; - - final s = StringBuffer(); - final cMethodName = m.accept(const CMethodName()); - final classRef = '${classVarPrefix}_$classNameInC'; - final methodID = '${methodVarPrefix}_$cMethodName'; - final cMethodParams = _formalArgs(m); - final jniSignature = m.accept(const MethodSignature()); - final ifStaticMethodID = isStatic ? 'static_' : ''; - - var javaReturnType = m.returnType.name; - if (isACtor) { - javaReturnType = c.binaryName; - } - final callType = _typeNameAtCallSite(m.returnType); - final callArgs = _callArgs(m, classRef, methodID); - - var ifAssignResult = ''; - if (javaReturnType != 'void') { - ifAssignResult = '${getCType(javaReturnType)} _result = '; - } - - final ifStaticCall = isStatic ? 'Static' : ''; - final envMethod = - isACtor ? 'NewObject' : 'Call$ifStaticCall${callType}Method'; - final returnResultIfAny = _result(m); - s.write(''' -jmethodID $methodID = NULL; -FFI_PLUGIN_EXPORT -$jniResultType $cMethodName($cMethodParams) { - $_loadEnvCall - ${_loadClassCall(classRef, c.internalName)} - load_${ifStaticMethodID}method($classRef, - &$methodID, "${m.name}", "$jniSignature"); - if ($methodID == NULL) return $ifError; - $ifAssignResult(*jniEnv)->$envMethod($callArgs); - $returnResultIfAny -}\n'''); - return s.toString(); - } - - String _field(ClassDecl c, Field f) { - final cClassName = c.uniqueName; - final isStatic = f.isStatic; - - final fieldName = f.finalName; - final fieldNameInC = f.accept(const CFieldName()); - final fieldVar = "${fieldVarPrefix}_$fieldNameInC"; - - // If the field is final and default is assigned, then no need to wrap - // this field. It should then be a constant in dart code. - if (isStatic && f.isFinal && f.defaultValue != null) { - return ""; - } - - final s = StringBuffer(); - - s.write('jfieldID $fieldVar = NULL;\n'); - - final classVar = '${classVarPrefix}_$cClassName'; - void writeAccessor({bool isSetter = false}) { - const cReturnType = jniResultType; - final cMethodPrefix = isSetter ? 'set' : 'get'; - final formalArgs = [ - if (!isStatic) 'jobject self_', - if (isSetter) '${getCType(f.type.name)} value', - ].join(', '); - final ifStaticField = isStatic ? 'static_' : ''; - final ifStaticCall = isStatic ? 'Static' : ''; - final callType = _typeNameAtCallSite(f.type); - final objectArgument = isStatic ? classVar : 'self_'; - - String accessorStatements; - if (isSetter) { - accessorStatements = - '$indent(*jniEnv)->Set$ifStaticCall${callType}Field(jniEnv, ' - '$objectArgument, $fieldVar, value);\n' - '${indent}return $ifError;'; - } else { - final getterExpr = - '(*jniEnv)->Get$ifStaticCall${callType}Field(jniEnv, ' - '$objectArgument, $fieldVar)'; - final cResultType = getCType(f.type.name); - final unionField = getJValueField(f.type); - final String returnExpr; - if (f.type.kind != Kind.primitive) { - returnExpr = 'to_global_ref_result(_result)'; - } else { - returnExpr = '(JniResult){.value = ' - '{.$unionField = _result}, .exception = check_exception()}'; - } - accessorStatements = '$indent$cResultType _result = $getterExpr;\n' - '${indent}return $returnExpr;'; - } - - s.write(''' -FFI_PLUGIN_EXPORT -$cReturnType ${cMethodPrefix}_$fieldNameInC($formalArgs) { - $_loadEnvCall - ${_loadClassCall(classVar, c.internalName)} - load_${ifStaticField}field($classVar, &$fieldVar, "$fieldName", - "${f.type.accept(const Descriptor())}"); -$accessorStatements -}\n\n'''); - } - - writeAccessor(isSetter: false); - if (f.isFinal) { - return s.toString(); - } - writeAccessor(isSetter: true); - return s.toString(); - } - - final String _loadEnvCall = '${indent}load_env();'; - - String _loadClassCall(String classVar, String internalName) { - return '${indent}load_class_global_ref(&$classVar, "$internalName");\n' - '${indent}if ($classVar == NULL) return $ifError;'; - } - - String _formalArgs(Method m) { - final args = []; - if (!m.isCtor && !m.isStatic) { - // The underscore-suffixed name prevents accidental collision with - // parameter named self, if any. - args.add('jobject self_'); - } - - for (var param in m.params) { - final paramName = _renameCParam(param.name); - args.add('${getCType(param.type.name)} $paramName'); - } - - return args.join(", "); - } - - String getJValueField(TypeUsage type) { - const primitives = { - 'boolean': 'z', - 'byte': 'b', - 'short': 's', - 'char': 'c', - 'int': 'i', - 'long': 'j', - 'float': 'f', - 'double': 'd', - 'void': 'j', // in case of void return, just write 0 to largest field. - }; - if (type.kind == Kind.primitive) { - return primitives[type.name]!; - } - return 'l'; - } - - // Returns arguments at call site, concatenated by `,`. - String _callArgs(Method m, String classVar, String methodVar) { - final args = ['jniEnv']; - if (!m.isCtor && !m.isStatic) { - args.add('self_'); - } else { - args.add(classVar); - } - args.add(methodVar); - for (var param in m.params) { - final paramName = _renameCParam(param.name); - args.add(paramName); - } - return args.join(', '); - } - - String _result(Method m) { - final cReturnType = getCType(m.returnType.name); - String valuePart; - String unionField; - if (cReturnType == 'jobject' || m.isCtor) { - return '${indent}return to_global_ref_result(_result);'; - } else if (cReturnType == 'void') { - // in case of void return, just write 0 in result part of JniResult - unionField = 'j'; - valuePart = '0'; - } else { - unionField = getJValueField(m.returnType); - valuePart = '_result'; - } - const exceptionPart = 'check_exception()'; - return '${indent}return (JniResult){.value = {.$unionField = $valuePart}, ' - '.exception = $exceptionPart};'; - } - - /// Returns capitalized java type name to be used as in call${type}Method - /// or get${type}Field etc.. - String _typeNameAtCallSite(TypeUsage type) { - if (type.kind == Kind.primitive) { - return type.name.substring(0, 1).toUpperCase() + type.name.substring(1); - } - return "Object"; - } -} - -class CPreludes { - static const autoGeneratedNotice = '// Autogenerated by jnigen. ' - 'DO NOT EDIT!\n\n'; - static const includes = '#include \n' - '#include "jni.h"\n' - '#include "dartjni.h"\n' - '\n'; - static const defines = 'thread_local JNIEnv *jniEnv;\n' - 'JniContext *jni;\n\n' - 'JniContext *(*context_getter)(void);\n' - 'JNIEnv *(*env_getter)(void);\n' - '\n'; - static const initializers = 'void setJniGetters(JniContext *(*cg)(void),\n' - ' JNIEnv *(*eg)(void)) {\n' - ' context_getter = cg;\n' - ' env_getter = eg;\n' - '}\n' - '\n'; - static const prelude = - autoGeneratedNotice + includes + defines + initializers; -} diff --git a/pkgs/jnigen/lib/src/bindings/c_generator.dart b/pkgs/jnigen/lib/src/bindings/c_generator.dart index 97b2604d2..ee30572a7 100644 --- a/pkgs/jnigen/lib/src/bindings/c_generator.dart +++ b/pkgs/jnigen/lib/src/bindings/c_generator.dart @@ -2,7 +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. +import 'dart:io'; + +import '../config/config.dart'; import '../elements/elements.dart'; +import '../logging/logging.dart'; +import '../util/find_package.dart'; +import '../util/string_util.dart'; import 'visitor.dart'; /// JVM representation of type signatures. @@ -92,3 +98,350 @@ class CMethodName extends Visitor { return '${className}__$methodName'; } } + +class CGenerator extends Visitor> { + static const _prelude = '''// Autogenerated by jnigen. DO NOT EDIT! + +#include +#include "jni.h" +#include "dartjni.h" + +thread_local JNIEnv *jniEnv; +JniContext *jni; + +JniContext *(*context_getter)(void); +JNIEnv *(*env_getter)(void); + +void setJniGetters(JniContext *(*cg)(void), + JNIEnv *(*eg)(void)) { + context_getter = cg; + env_getter = eg; +} + +'''; + + final Config config; + + CGenerator(this.config); + + Future _copyFileFromPackage(String package, String relPath, Uri target, + {String Function(String)? transform}) async { + final packagePath = await findPackageRoot(package); + if (packagePath != null) { + final sourceFile = File.fromUri(packagePath.resolve(relPath)); + final targetFile = await File.fromUri(target).create(recursive: true); + var source = await sourceFile.readAsString(); + if (transform != null) { + source = transform(source); + } + await targetFile.writeAsString(source); + } else { + log.warning('package $package not found! ' + 'skipped copying ${target.toFilePath()}'); + } + } + + @override + Future visit(Classes node) async { + // Write C file and init file. + final cConfig = config.outputConfig.cConfig!; + final cRoot = cConfig.path; + final preamble = config.preamble; + log.info("Using c root = $cRoot"); + final libraryName = cConfig.libraryName; + log.info('Creating dart init file ...'); + // Create C file. + final subdir = cConfig.subdir ?? '.'; + final cFileRelativePath = '$subdir/$libraryName.c'; + final cFile = await File.fromUri(cRoot.resolve(cFileRelativePath)) + .create(recursive: true); + final cFileStream = cFile.openWrite(); + // Write C Bindings. + if (preamble != null) { + cFileStream.writeln(preamble); + } + cFileStream.write(_prelude); + final classGenerator = _CClassGenerator(config, cFileStream); + for (final classDecl in node.decls.values) { + classDecl.accept(classGenerator); + } + await cFileStream.close(); + log.info('Copying auxiliary files...'); + for (final file in ['dartjni.h', '.clang-format']) { + await _copyFileFromPackage( + 'jni', 'src/$file', cRoot.resolve('$subdir/$file')); + } + await _copyFileFromPackage( + 'jnigen', 'cmake/CMakeLists.txt.tmpl', cRoot.resolve('CMakeLists.txt'), + transform: (s) { + return s + .replaceAll('{{LIBRARY_NAME}}', libraryName) + .replaceAll('{{SUBDIR}}', subdir); + }); + log.info('Running clang-format on C bindings'); + try { + final clangFormat = Process.runSync('clang-format', ['-i', cFile.path]); + if (clangFormat.exitCode != 0) { + printError(clangFormat.stderr); + log.warning('clang-format exited with ${clangFormat.exitCode}'); + } + } on ProcessException catch (e) { + log.warning('cannot run clang-format: $e'); + } + } +} + +const _classVarPrefix = '_c_'; +const _jniResultType = 'JniResult'; +const _loadEnvCall = 'load_env();'; +const _ifError = + '(JniResult){.value = {.j = 0}, .exception = check_exception()}'; + +class _CClassGenerator extends Visitor { + final Config config; + final StringSink s; + + _CClassGenerator(this.config, this.s); + + @override + void visit(ClassDecl node) { + final classNameInC = node.uniqueName; + final classVar = '$_classVarPrefix$classNameInC'; + // Global variable in C that holds the reference to class. + s.write('''// ${node.binaryName} +jclass $classVar = NULL; + +'''); + + final methodGenerator = _CMethodGenerator(config, s); + for (final method in node.methods) { + method.accept(methodGenerator); + } + + final fieldGenerator = _CFieldGenerator(config, s); + for (final field in node.fields) { + field.accept(fieldGenerator); + } + } +} + +class _CLoadClassGenerator extends Visitor { + _CLoadClassGenerator(); + + @override + String visit(ClassDecl node) { + final classVar = '$_classVarPrefix${node.uniqueName}'; + return ''' load_class_global_ref(&$classVar, "${node.internalName}"); + if ($classVar == NULL) return $_ifError;'''; + } +} + +class _CMethodGenerator extends Visitor { + static const _methodVarPrefix = '_m_'; + + final Config config; + final StringSink s; + + _CMethodGenerator(this.config, this.s); + + @override + void visit(Method node) { + final classNameInC = node.classDecl.uniqueName; + + final cMethodName = node.accept(const CMethodName()); + final classRef = '$_classVarPrefix$classNameInC'; + final methodId = '$_methodVarPrefix$cMethodName'; + final cMethodParams = [ + if (!node.isCtor && !node.isStatic) 'jobject self_', + ...node.params.accept(const _CParamGenerator(addReturnType: true)), + ].join(','); + final jniSignature = node.accept(const MethodSignature()); + final ifStaticMethodID = node.isStatic ? 'static_' : ''; + + var javaReturnType = node.returnType.type; + if (node.isCtor) { + javaReturnType = DeclaredType( + binaryName: node.classDecl.binaryName, + simpleName: node.classDecl.simpleName, + ); + } + final callType = node.returnType.accept(const _CTypeCallSite()); + final callArgs = [ + 'jniEnv', + if (!node.isCtor && !node.isStatic) 'self_' else classRef, + methodId, + ...node.params.accept(const _CParamGenerator(addReturnType: false)) + ].join(', '); + + var ifAssignResult = ''; + if (javaReturnType.name != 'void') { + ifAssignResult = + '${javaReturnType.accept(const _CReturnType())} _result = '; + } + + final ifStaticCall = node.isStatic ? 'Static' : ''; + final envMethod = + node.isCtor ? 'NewObject' : 'Call$ifStaticCall${callType}Method'; + final returnResultIfAny = javaReturnType.accept(const _CResult()); + s.write(''' +jmethodID $methodId = NULL; +FFI_PLUGIN_EXPORT +$_jniResultType $cMethodName($cMethodParams) { + $_loadEnvCall + ${node.classDecl.accept(_CLoadClassGenerator())} + load_${ifStaticMethodID}method($classRef, + &$methodId, "${node.name}", "$jniSignature"); + if ($methodId == NULL) return $_ifError; + $ifAssignResult(*jniEnv)->$envMethod($callArgs); + $returnResultIfAny +} + +'''); + } +} + +class _CFieldGenerator extends Visitor { + static const _fieldVarPrefix = '_f_'; + + final Config config; + final StringSink s; + + _CFieldGenerator(this.config, this.s); + + @override + void visit(Field node) { + final cClassName = node.classDecl.uniqueName; + + final fieldName = node.finalName; + final fieldNameInC = node.accept(const CFieldName()); + final fieldVar = "$_fieldVarPrefix$fieldNameInC"; + + // If the field is final and default is assigned, then no need to wrap + // this field. It should then be a constant in dart code. + if (node.isStatic && node.isFinal && node.defaultValue != null) { + return; + } + + s.write('jfieldID $fieldVar = NULL;\n'); + + final classVar = '$_classVarPrefix$cClassName'; + void writeAccessor({bool isSetter = false}) { + const cReturnType = _jniResultType; + final cMethodPrefix = isSetter ? 'set' : 'get'; + final formalArgs = [ + if (!node.isStatic) 'jobject self_', + if (isSetter) '${node.type.accept(const _CReturnType())} value', + ].join(', '); + final ifStaticField = node.isStatic ? 'static_' : ''; + final ifStaticCall = node.isStatic ? 'Static' : ''; + final callType = node.type.accept(const _CTypeCallSite()); + final objectArgument = node.isStatic ? classVar : 'self_'; + + String accessorStatements; + if (isSetter) { + accessorStatements = + ' (*jniEnv)->Set$ifStaticCall${callType}Field(jniEnv, ' + '$objectArgument, $fieldVar, value);\n' + ' return $_ifError;'; + } else { + final getterExpr = + '(*jniEnv)->Get$ifStaticCall${callType}Field(jniEnv, ' + '$objectArgument, $fieldVar)'; + final cResultType = node.type.accept(const _CReturnType()); + final result = node.type.accept(const _CResult()); + accessorStatements = ''' $cResultType _result = $getterExpr; + $result'''; + } + s.write(''' +FFI_PLUGIN_EXPORT +$cReturnType ${cMethodPrefix}_$fieldNameInC($formalArgs) { + $_loadEnvCall + ${node.classDecl.accept(_CLoadClassGenerator())} + load_${ifStaticField}field($classVar, &$fieldVar, "$fieldName", + "${node.type.accept(const Descriptor())}"); +$accessorStatements +} + +'''); + } + + writeAccessor(isSetter: false); + if (node.isFinal) { + return; + } + writeAccessor(isSetter: true); + } +} + +class _CParamGenerator extends Visitor { + /// These should be avoided in parameter names. + static const _cTypeKeywords = { + 'short', + 'char', + 'int', + 'long', + 'float', + 'double', + }; + + const _CParamGenerator({required this.addReturnType}); + + final bool addReturnType; + + @override + String visit(Param node) { + final paramName = + _cTypeKeywords.contains(node.name) ? '${node.name}0' : node.name; + final type = node.type.accept(const _CReturnType()); + if (addReturnType) return '$type $paramName'; + return paramName; + } +} + +class _CReturnType extends TypeVisitor { + const _CReturnType(); + + @override + String visitNonPrimitiveType(ReferredType node) { + return 'jobject'; + } + + @override + String visitPrimitiveType(PrimitiveType node) { + return node.cType; + } +} + +class _CTypeCallSite extends TypeVisitor { + const _CTypeCallSite(); + + @override + String visitNonPrimitiveType(ReferredType node) { + return 'Object'; + } + + @override + String visitPrimitiveType(PrimitiveType node) { + return node.name.capitalize(); + } +} + +class _CResult extends TypeVisitor { + const _CResult(); + + @override + String visitNonPrimitiveType(ReferredType node) { + return 'return to_global_ref_result(_result);'; + } + + @override + String visitPrimitiveType(PrimitiveType node) { + if (node.name == 'void') { + return 'return $_ifError;'; + } + // The union field is the same as the type's signature, but in lowercase. + final unionField = node.signature.toLowerCase(); + return 'return (JniResult){.value = {.$unionField = _result}, ' + '.exception = check_exception()};'; + } +} diff --git a/pkgs/jnigen/lib/src/bindings/dart_generator.dart b/pkgs/jnigen/lib/src/bindings/dart_generator.dart index 326069a76..1cd3c2be3 100644 --- a/pkgs/jnigen/lib/src/bindings/dart_generator.dart +++ b/pkgs/jnigen/lib/src/bindings/dart_generator.dart @@ -9,7 +9,7 @@ import 'package:meta/meta.dart'; import '../config/config.dart'; import '../elements/elements.dart'; import '../logging/logging.dart'; -import '../writers/bindings_writer.dart'; +import '../util/string_util.dart'; import 'c_generator.dart'; import 'resolver.dart'; import 'visitor.dart'; @@ -47,15 +47,6 @@ const _deleteInstruction = ' /// The returned object must be deleted after use, ' 'by calling the `delete` method.'; -extension on String { - String capitalize() { - return '${this[0].toUpperCase()}${substring(1)}'; - } - - /// Reverses an ASCII string. - String get reversed => split('').reversed.join(); -} - extension on Iterable { /// Similar to [join] but adds the [separator] to the end as well. String delimited([String separator = '']) { @@ -173,6 +164,19 @@ import "package:jni/jni.dart" as jni; static const preImportBoilerplate = autoGeneratedNotice + defaultLintSuppressions + defaultImports; + /// Run dart format command on [path]. + Future _runDartFormat(String path) async { + log.info('Running dart format...'); + final formatRes = await Process.run('dart', ['format', path]); + // if negative exit code, likely due to an interrupt. + if (formatRes.exitCode > 0) { + log.fatal('Dart format completed with exit code ${formatRes.exitCode} ' + 'This usually means there\'s a syntax error in bindings.\n' + 'Please look at the generated files and report a bug: \n' + 'https://github.com/dart-lang/jnigen/issues/new\n'); + } + } + @override Future visit(Classes node) async { final cBased = config.outputConfig.bindingsType == BindingsType.cBased; @@ -192,9 +196,11 @@ import "package:jni/jni.dart" as jni; s.writeln(cInitCode); } final classGenerator = _ClassGenerator(config, s); - node.decls.values.accept(classGenerator).toList(); + for (final classDecl in node.decls.values) { + classDecl.accept(classGenerator); + } await s.close(); - await runDartFormat(file.path); + await _runDartFormat(file.path); return; } final files = >{}; @@ -247,9 +253,10 @@ import "package:jni/jni.dart" as jni; currentClass: fileClassName, inputClassNames: node.decls.keys.toSet(), ); - classesInFile - .accept(_ClassGenerator(config, s, resolver: resolver)) - .toList(); + final classGenerator = _ClassGenerator(config, s, resolver: resolver); + for (final classDecl in classesInFile) { + classDecl.accept(classGenerator); + } dartFileStream.writeAll(resolver.getImportStrings(), '\n'); dartFileStream.writeln(s.toString()); await dartFileStream.close(); @@ -265,7 +272,7 @@ import "package:jni/jni.dart" as jni; packages[package]!.map((cls) => 'export "$cls.dart";').join('\n'); exportFile.writeAsStringSync(exports); } - await runDartFormat(root.toFilePath()); + await _runDartFormat(root.toFilePath()); log.info('Completed.'); } } diff --git a/pkgs/jnigen/lib/src/elements/elements.dart b/pkgs/jnigen/lib/src/elements/elements.dart index 2e4a9f516..7793c1f03 100644 --- a/pkgs/jnigen/lib/src/elements/elements.dart +++ b/pkgs/jnigen/lib/src/elements/elements.dart @@ -278,7 +278,7 @@ class PrimitiveType extends ReferredType { signature: 'C', dartType: 'int', jniType: 'jchar', - cType: 'char', + cType: 'uint16_t', ffiType: 'Uint16', ), 'int': PrimitiveType._( diff --git a/pkgs/jnigen/lib/src/generate_bindings.dart b/pkgs/jnigen/lib/src/generate_bindings.dart index d553657dd..ab184da4f 100644 --- a/pkgs/jnigen/lib/src/generate_bindings.dart +++ b/pkgs/jnigen/lib/src/generate_bindings.dart @@ -5,6 +5,7 @@ import 'dart:io'; import 'dart:convert'; +import 'bindings/c_generator.dart'; import 'bindings/dart_generator.dart'; import 'bindings/excluder.dart'; import 'bindings/linker.dart'; @@ -13,7 +14,6 @@ import 'elements/elements.dart'; import 'summary/summary.dart'; import 'config/config.dart'; import 'tools/tools.dart'; -import 'writers/bindings_writer.dart'; import 'logging/logging.dart'; void collectOutputStream(Stream> stream, StringBuffer buffer) => @@ -34,14 +34,14 @@ Future generateJniBindings(Config config) async { log.fatal(e.message); } - final cBased = config.outputConfig.bindingsType == BindingsType.cBased; classes ..accept(Excluder(config)) ..accept(Linker(config)) ..accept(Renamer(config)); + final cBased = config.outputConfig.bindingsType == BindingsType.cBased; if (cBased) { - await writeCBindings(config, classes.decls.values.toList()); + await classes.accept(CGenerator(config)); } try { diff --git a/pkgs/jnigen/lib/src/util/string_util.dart b/pkgs/jnigen/lib/src/util/string_util.dart new file mode 100644 index 000000000..5a65bfb47 --- /dev/null +++ b/pkgs/jnigen/lib/src/util/string_util.dart @@ -0,0 +1,13 @@ +// 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. + +extension StringUtil on String { + /// Makes the first letter uppercase. + String capitalize() { + return '${this[0].toUpperCase()}${substring(1)}'; + } + + /// Reverses an ASCII string. + String get reversed => split('').reversed.join(); +} diff --git a/pkgs/jnigen/lib/src/writers/bindings_writer.dart b/pkgs/jnigen/lib/src/writers/bindings_writer.dart deleted file mode 100644 index 190a90ccc..000000000 --- a/pkgs/jnigen/lib/src/writers/bindings_writer.dart +++ /dev/null @@ -1,88 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -import 'dart:io'; - -import '../bindings/c_bindings.dart'; -import '../config/config.dart'; -import '../elements/elements.dart'; -import '../logging/logging.dart'; -import '../util/find_package.dart'; - -/// Run dart format command on [path]. -Future runDartFormat(String path) async { - log.info('Running dart format...'); - final formatRes = await Process.run('dart', ['format', path]); - // if negative exit code, likely due to an interrupt. - if (formatRes.exitCode > 0) { - log.fatal('Dart format completed with exit code ${formatRes.exitCode} ' - 'This usually means there\'s a syntax error in bindings.\n' - 'Please look at the generated files and report a bug.'); - } -} - -Future _copyFileFromPackage(String package, String relPath, Uri target, - {String Function(String)? transform}) async { - final packagePath = await findPackageRoot(package); - if (packagePath != null) { - final sourceFile = File.fromUri(packagePath.resolve(relPath)); - final targetFile = await File.fromUri(target).create(recursive: true); - var source = await sourceFile.readAsString(); - if (transform != null) { - source = transform(source); - } - await targetFile.writeAsString(source); - } else { - log.warning('package $package not found! ' - 'skipped copying ${target.toFilePath()}'); - } -} - -Future writeCBindings(Config config, List classes) async { - // write C file and init file - final cConfig = config.outputConfig.cConfig!; - final cRoot = cConfig.path; - final preamble = config.preamble; - log.info("Using c root = $cRoot"); - final libraryName = cConfig.libraryName; - log.info('Creating dart init file ...'); - // Create C file - final subdir = cConfig.subdir ?? '.'; - final cFileRelativePath = '$subdir/$libraryName.c'; - final cFile = await File.fromUri(cRoot.resolve(cFileRelativePath)) - .create(recursive: true); - final cFileStream = cFile.openWrite(); - // Write C Bindings - if (preamble != null) { - cFileStream.writeln(preamble); - } - cFileStream.write(CPreludes.prelude); - final cgen = CBindingGenerator(config); - final cBindings = classes.map(cgen.generateBinding).toList(); - log.info('writing c bindings to $cFile'); - cBindings.forEach(cFileStream.write); - await cFileStream.close(); - log.info('Copying auxiliary files...'); - await _copyFileFromPackage( - 'jni', 'src/dartjni.h', cRoot.resolve('$subdir/dartjni.h')); - await _copyFileFromPackage( - 'jni', 'src/.clang-format', cRoot.resolve('$subdir/.clang-format')); - await _copyFileFromPackage( - 'jnigen', 'cmake/CMakeLists.txt.tmpl', cRoot.resolve('CMakeLists.txt'), - transform: (s) { - return s - .replaceAll('{{LIBRARY_NAME}}', libraryName) - .replaceAll('{{SUBDIR}}', subdir); - }); - log.info('Running clang-format on C bindings'); - try { - final clangFormat = Process.runSync('clang-format', ['-i', cFile.path]); - if (clangFormat.exitCode != 0) { - printError(clangFormat.stderr); - log.warning('clang-format exited with ${clangFormat.exitCode}'); - } - } on ProcessException catch (e) { - log.warning('cannot run clang-format: $e'); - } -} From 32d057e32dbd5903115167de77bebbf613b1b6c5 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Thu, 18 May 2023 22:54:00 -0700 Subject: [PATCH 093/139] [jnigen] blast_repo fixes (https://github.com/dart-lang/jnigen/issues/283) dependabot --- .github/dependabot.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 952351121..fb01db0e6 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -7,3 +7,5 @@ updates: directory: / schedule: interval: monthly + labels: + - autosubmit From 19ff0d272d99729d0a52a0c7e7bb2328f9c704aa Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Wed, 31 May 2023 15:33:32 +0200 Subject: [PATCH 094/139] [jnigen] Using a yaml symbols file instead of hard coding package:jni exported classes (https://github.com/dart-lang/jnigen/issues/289) * Removes the support for importMap in config. * Adds the support for importing a yaml symbols file. --- pkgs/jni/lib/jni_symbols.yaml | 12 ++ pkgs/jnigen/CHANGELOG.md | 3 +- .../lib/src/bindings/dart_generator.dart | 70 ++++--- pkgs/jnigen/lib/src/bindings/linker.dart | 78 ++++++-- pkgs/jnigen/lib/src/bindings/renamer.dart | 28 ++- pkgs/jnigen/lib/src/bindings/resolver.dart | 44 ++--- pkgs/jnigen/lib/src/config/config_types.dart | 185 ++++++++++++++---- pkgs/jnigen/lib/src/config/yaml_reader.dart | 16 +- pkgs/jnigen/lib/src/elements/elements.dart | 59 +++--- pkgs/jnigen/lib/src/generate_bindings.dart | 7 +- pkgs/jnigen/pubspec.yaml | 1 + pkgs/jnigen/test/config_test.dart | 4 +- pkgs/jnigen/test/package_resolver_test.dart | 42 ++-- 13 files changed, 362 insertions(+), 187 deletions(-) create mode 100644 pkgs/jni/lib/jni_symbols.yaml diff --git a/pkgs/jni/lib/jni_symbols.yaml b/pkgs/jni/lib/jni_symbols.yaml new file mode 100644 index 000000000..199df295c --- /dev/null +++ b/pkgs/jni/lib/jni_symbols.yaml @@ -0,0 +1,12 @@ +version: 1.0.0 +files: + 'jni.dart': + 'java.lang.Object': + name: JObject + type_class: JObjectType + super_count: 0 + 'java.lang.String': + name: JString + type_class: JStringType + super_count: 1 + diff --git a/pkgs/jnigen/CHANGELOG.md b/pkgs/jnigen/CHANGELOG.md index 23c1e261a..58fb5be78 100644 --- a/pkgs/jnigen/CHANGELOG.md +++ b/pkgs/jnigen/CHANGELOG.md @@ -1,5 +1,6 @@ ## 0.5.0-dev.0 -* No JNIGen changes (yet), but keeping version in lockstep with `package:jni`. +* **Breaking Change** ([#72](https://github.com/dart-lang/jnigen/issues/72)): Removed support for `importMap` in favor of the newly added interop mechanism with importing yaml files. +* Strings now use UTF16. ## 0.4.0 * **Breaking Change** ([#145](https://github.com/dart-lang/jnigen/issues/145)): Type arguments are now named instead of positional. diff --git a/pkgs/jnigen/lib/src/bindings/dart_generator.dart b/pkgs/jnigen/lib/src/bindings/dart_generator.dart index 1cd3c2be3..a1559cf3e 100644 --- a/pkgs/jnigen/lib/src/bindings/dart_generator.dart +++ b/pkgs/jnigen/lib/src/bindings/dart_generator.dart @@ -31,9 +31,6 @@ const _voidPointer = '$_ffi.Pointer<$_ffi.Void>'; // Prefixes and suffixes const _typeParamPrefix = '\$'; -// TODO(#143): this is a temporary fix for the name collision. -const _typeClassPrefix = '\$'; -const _typeClassSuffix = 'Type'; // Misc. const _classRef = '_class.reference'; @@ -195,7 +192,12 @@ import "package:jni/jni.dart" as jni; if (cBased) { s.writeln(cInitCode); } - final classGenerator = _ClassGenerator(config, s); + final resolver = Resolver( + importedClasses: config.importedClasses, + currentClass: null, // Single file mode. + inputClassNames: node.decls.keys.toSet(), + ); + final classGenerator = _ClassGenerator(config, s, resolver); for (final classDecl in node.decls.values) { classDecl.accept(classGenerator); } @@ -249,11 +251,11 @@ import "package:jni/jni.dart" as jni; s.write('import "$initFilePath";'); } final resolver = Resolver( - importMap: config.importMap ?? {}, + importedClasses: config.importedClasses, currentClass: fileClassName, inputClassNames: node.decls.keys.toSet(), ); - final classGenerator = _ClassGenerator(config, s, resolver: resolver); + final classGenerator = _ClassGenerator(config, s, resolver); for (final classDecl in classesInFile) { classDecl.accept(classGenerator); } @@ -281,13 +283,13 @@ import "package:jni/jni.dart" as jni; class _ClassGenerator extends Visitor { final Config config; final StringSink s; - final Resolver? resolver; + final Resolver resolver; _ClassGenerator( this.config, - this.s, { + this.s, this.resolver, - }); + ); static const staticTypeGetter = 'type'; static const instanceTypeGetter = '\$$staticTypeGetter'; @@ -331,7 +333,7 @@ class _ClassGenerator extends Visitor { .map((typeParam) => 'this.$typeParam,') .join(_newLine(depth: 2)); final superClass = (node.classDecl.superclass!.type as DeclaredType); - final superTypeClassesCall = superClass.classDecl == ClassDecl.object + final superTypeClassesCall = superClass.classDecl.isObject() ? '' : superClass.params .accept(_TypeClassGenerator(resolver)) @@ -365,7 +367,7 @@ class $name$typeParamsDef extends $superName { // Static TypeClass getter s.writeln( ' /// The type which includes information such as the signature of this class.'); - final typeClassName = '$_typeClassPrefix$name$_typeClassSuffix'; + final typeClassName = node.typeClassName; if (typeParams.isEmpty) { s.writeln('static const $staticTypeGetter = $typeClassName();'); } else { @@ -527,7 +529,7 @@ class _TypeGenerator extends TypeVisitor { } final typeParams = _encloseIfNotEmpty('<', allTypeParams.join(', '), '>'); - final prefix = resolver?.resolvePrefix(node.classDecl.binaryName) ?? ''; + final prefix = resolver?.resolvePrefix(node.classDecl) ?? ''; return '$prefix${node.classDecl.finalName}$typeParams'; } @@ -563,7 +565,7 @@ class _TypeClass { /// Generates the type class. class _TypeClassGenerator extends TypeVisitor<_TypeClass> { final bool isConst; - final Resolver? resolver; + final Resolver resolver; _TypeClassGenerator(this.resolver, {this.isConst = true}); @@ -573,19 +575,13 @@ class _TypeClassGenerator extends TypeVisitor<_TypeClass> { node.type.accept(_TypeClassGenerator(resolver, isConst: false)); final ifConst = innerTypeClass.canBeConst && isConst ? 'const ' : ''; return _TypeClass( - '$ifConst$_jArray$_typeClassSuffix(${innerTypeClass.name})', + '$ifConst${_jArray}Type(${innerTypeClass.name})', innerTypeClass.canBeConst, ); } @override _TypeClass visitDeclaredType(DeclaredType node) { - if (node.classDecl.binaryName == 'java.lang.Object' || - node.classDecl.binaryName == 'java.lang.String') { - final ifConst = isConst ? 'const ' : ''; - return _TypeClass( - '$ifConst$_jni.${node.classDecl.finalName}$_typeClassSuffix()', true); - } final allTypeParams = node.classDecl.allTypeParams .accept(const _TypeParamGenerator(withExtends: false)) .toList(); @@ -596,7 +592,8 @@ class _TypeClassGenerator extends TypeVisitor<_TypeClass> { // Can be const if all the type parameters are defined and each of them are // also const. - final canBeConst = definedTypeClasses.every((e) => e.canBeConst); + final canBeConst = + allTypeParams.isEmpty || definedTypeClasses.every((e) => e.canBeConst); // Replacing the declared ones. They come at the end. // The rest will be `JObjectType`. @@ -607,7 +604,7 @@ class _TypeClassGenerator extends TypeVisitor<_TypeClass> { List.filled( allTypeParams.length - node.params.length, // Adding const to subexpressions if the entire expression is not const. - '${canBeConst ? '' : 'const '}$_jObject$_typeClassSuffix()', + '${canBeConst ? '' : 'const '}${_jObject}Type()', ), ); allTypeParams.replaceRange( @@ -621,9 +618,9 @@ class _TypeClassGenerator extends TypeVisitor<_TypeClass> { final args = allTypeParams.join(', '); final ifConst = isConst && canBeConst ? 'const ' : ''; - final prefix = resolver?.resolvePrefix(node.classDecl.binaryName) ?? ''; + final prefix = resolver.resolvePrefix(node.classDecl); return _TypeClass( - '$ifConst$prefix$_typeClassPrefix${node.classDecl.finalName}$_typeClassSuffix($args)', + '$ifConst$prefix${node.classDecl.typeClassName}($args)', canBeConst, ); } @@ -631,7 +628,7 @@ class _TypeClassGenerator extends TypeVisitor<_TypeClass> { @override _TypeClass visitPrimitiveType(PrimitiveType node) { final ifConst = isConst ? 'const ' : ''; - return _TypeClass('$ifConst$_jni.${node.jniType}$_typeClassSuffix()', true); + return _TypeClass('$ifConst$_jni.${node.jniType}Type()', true); } @override @@ -648,7 +645,7 @@ class _TypeClassGenerator extends TypeVisitor<_TypeClass> { @override _TypeClass visitNonPrimitiveType(ReferredType node) { final ifConst = isConst ? 'const ' : ''; - return _TypeClass('$ifConst$_jObject$_typeClassSuffix()', true); + return _TypeClass('$ifConst${_jObject}Type()', true); } } @@ -759,7 +756,7 @@ class _ToNativeSuffix extends TypeVisitor { } class _FromNative extends TypeVisitor { - final Resolver? resolver; + final Resolver resolver; final String value; const _FromNative(this.resolver, this.value); @@ -778,7 +775,7 @@ class _FromNative extends TypeVisitor { class _FieldGenerator extends Visitor { final Config config; - final Resolver? resolver; + final Resolver resolver; final StringSink s; const _FieldGenerator(this.config, this.resolver, this.s); @@ -932,7 +929,7 @@ class _MethodTypeSig extends Visitor { /// Generates Dart bindings for Java methods. class _MethodGenerator extends Visitor { final Config config; - final Resolver? resolver; + final Resolver resolver; final StringSink s; const _MethodGenerator(this.config, this.resolver, this.s); @@ -1181,7 +1178,7 @@ class _CtorTypeClassDef extends Visitor { /// void bar(Foo foo) => ... /// ``` class _ParamDef extends Visitor { - final Resolver? resolver; + final Resolver resolver; const _ParamDef(this.resolver); @@ -1289,7 +1286,7 @@ class OutsideInBuffer { /// ((((a.$type as jni.JArrayType).elementType) as $JMapType).V) as jni.JObjType<$T> /// ``` class _ParamTypeLocator extends Visitor>> { - final Resolver? resolver; + final Resolver resolver; _ParamTypeLocator({required this.resolver}); @@ -1308,7 +1305,7 @@ class _ParamTypeLocator extends Visitor>> { } class _TypeVarLocator extends TypeVisitor>> { - final Resolver? resolver; + final Resolver resolver; _TypeVarLocator({required this.resolver}); @@ -1334,14 +1331,13 @@ class _TypeVarLocator extends TypeVisitor>> { @override Map> visitDeclaredType(DeclaredType node) { - if (node.classDecl == ClassDecl.object) { + if (node.classDecl.isObject()) { return {}; } final offset = node.classDecl.allTypeParams.length - node.params.length; final result = >{}; - final prefix = resolver?.resolvePrefix(node.binaryName) ?? ''; - final typeClass = - '$prefix$_typeClassPrefix${node.classDecl.finalName}$_typeClassSuffix'; + final prefix = resolver.resolvePrefix(node.classDecl); + final typeClass = '$prefix${node.classDecl.typeClassName}'; for (var i = 0; i < node.params.length; ++i) { final typeParam = node.classDecl.allTypeParams[i + offset].name; final exprs = node.params[i].accept(this); @@ -1361,7 +1357,7 @@ class _TypeVarLocator extends TypeVisitor>> { final exprs = node.type.accept(this); for (final e in exprs.values.expand((i) => i)) { e.appendLeft('(('); - e.prependRight(' as $_jArray$_typeClassSuffix).elementType as $_jType)'); + e.prependRight(' as ${_jArray}Type).elementType as $_jType)'); } return exprs; } diff --git a/pkgs/jnigen/lib/src/bindings/linker.dart b/pkgs/jnigen/lib/src/bindings/linker.dart index e50d43782..74c14e7a0 100644 --- a/pkgs/jnigen/lib/src/bindings/linker.dart +++ b/pkgs/jnigen/lib/src/bindings/linker.dart @@ -2,26 +2,74 @@ // 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 'visitor.dart'; import '../config/config.dart'; import '../elements/elements.dart'; +import '../logging/logging.dart'; +import 'visitor.dart'; typedef _Resolver = ClassDecl Function(String? binaryName); -/// Adds references from child elements back to their parent elements. -/// Resolves Kotlin specific `asyncReturnType` for methods. -class Linker extends Visitor { +/// A [Visitor] that adds the correct [ClassDecl] references from the +/// string binary names. +/// +/// It adds the following references: +/// * Links [ClassDecl] objects from imported dependencies. +/// * Adds references from child elements back to their parent elements. +/// * Resolves Kotlin specific `asyncReturnType` for methods. +class Linker extends Visitor> { Linker(this.config); final Config config; @override - void visit(Classes node) { - final classLinker = _ClassLinker(config, (binaryName) { - return ClassDecl.predefined[binaryName] ?? + Future visit(Classes node) async { + // Specify paths for this package's classes. + final root = config.outputConfig.dartConfig.path; + if (config.outputConfig.dartConfig.structure == + OutputStructure.singleFile) { + // Connect all to the root if the output is in single file mode. + final path = root.toFilePath(); + for (final decl in node.decls.values) { + decl.path = path; + } + } else { + for (final decl in node.decls.values) { + final dollarSign = decl.binaryName.indexOf('\$'); + final className = dollarSign != -1 + ? decl.binaryName.substring(0, dollarSign) + : decl.binaryName; + final path = className.replaceAll('.', '/'); + decl.path = root.resolve(path).toFilePath(); + } + } + + // Find all the imported classes. + await config.importClasses(); + + if (config.importedClasses.keys + .toSet() + .intersection(node.decls.keys.toSet()) + .isNotEmpty) { + log.fatal( + 'Trying to re-import the generated classes.\n' + 'Try hiding the class(es) in import.', + ); + } + + for (final className in config.importedClasses.keys) { + log.finest('Imported $className successfully.'); + } + + ClassDecl resolve(String? binaryName) { + return config.importedClasses[binaryName] ?? node.decls[binaryName] ?? - ClassDecl.object; - }); + resolve(TypeUsage.object.name); + } + + final classLinker = _ClassLinker( + config, + resolve, + ); for (final classDecl in node.decls.values) { classDecl.accept(classLinker); } @@ -29,20 +77,24 @@ class Linker extends Visitor { } class _ClassLinker extends Visitor { - _ClassLinker(this.config, this.resolve); - final Config config; final _Resolver resolve; - final Set _linked = {...ClassDecl.predefined.values}; + final Set _linked; + + _ClassLinker( + this.config, + this.resolve, + ) : _linked = {...config.importedClasses.values}; @override void visit(ClassDecl node) { if (_linked.contains(node)) return; + log.finest('Linking ${node.binaryName}.'); _linked.add(node); node.parent = resolve(node.parentName); node.parent!.accept(this); - // Adding type params of outer classes to the nested classes + // Add type params of outer classes to the nested classes final allTypeParams = []; if (!node.modifiers.contains('static')) { for (final typeParam in node.parent!.allTypeParams) { diff --git a/pkgs/jnigen/lib/src/bindings/renamer.dart b/pkgs/jnigen/lib/src/bindings/renamer.dart index 4f1c44090..d5f9a7339 100644 --- a/pkgs/jnigen/lib/src/bindings/renamer.dart +++ b/pkgs/jnigen/lib/src/bindings/renamer.dart @@ -135,18 +135,13 @@ class Renamer implements Visitor { class _ClassRenamer implements Visitor { final Config config; + final Set renamed; final Map classNameCounts = {}; - final Set renamed = {...ClassDecl.predefined.values}; - final Map> nameCounts = { - for (final predefined in ClassDecl.predefined.values) ...{ - predefined: {..._definedSyms}, - } - }; - final Map> methodNumsAfterRenaming = {}; + final Map> nameCounts = {}; _ClassRenamer( this.config, - ); + ) : renamed = {...config.importedClasses.values}; /// Returns class name as useful in dart. /// @@ -157,10 +152,11 @@ class _ClassRenamer implements Visitor { @override void visit(ClassDecl node) { if (renamed.contains(node)) return; + log.finest('Renaming ${node.binaryName}.'); renamed.add(node); nameCounts[node] = {..._definedSyms}; - methodNumsAfterRenaming[node] = {}; + node.methodNumsAfterRenaming = {}; final className = _getSimplifiedClassName(node.binaryName); node.uniqueName = _renameConflict(classNameCounts, className); @@ -170,15 +166,16 @@ class _ClassRenamer implements Visitor { final uniquifyName = config.outputConfig.dartConfig.structure == OutputStructure.singleFile; node.finalName = uniquifyName ? node.uniqueName : className; + // TODO(#143): $ at the beginning is a temporary fix for the name collision. + node.typeClassName = '\$${node.finalName}Type'; log.fine('Class ${node.binaryName} is named ${node.finalName}'); final superClass = (node.superclass!.type as DeclaredType).classDecl; superClass.accept(this); - nameCounts[node]!.addAll(nameCounts[superClass]!); + nameCounts[node]!.addAll(nameCounts[superClass] ?? {}); final methodRenamer = _MethodRenamer( config, nameCounts[node]!, - methodNumsAfterRenaming, ); for (final method in node.methods) { method.accept(methodRenamer); @@ -192,11 +189,10 @@ class _ClassRenamer implements Visitor { } class _MethodRenamer implements Visitor { - _MethodRenamer(this.config, this.nameCounts, this.methodNumsAfterRenaming); + _MethodRenamer(this.config, this.nameCounts); final Config config; final Map nameCounts; - final Map> methodNumsAfterRenaming; @override void visit(Method node) { @@ -205,17 +201,17 @@ class _MethodRenamer implements Visitor { // If node is in super class, assign its number, overriding it. final superClass = (node.classDecl.superclass!.type as DeclaredType).classDecl; - final superNum = methodNumsAfterRenaming[superClass]?[sig]; + final superNum = superClass.methodNumsAfterRenaming[sig]; if (superNum != null) { // Don't rename if superNum == 0 // Unless the node name is a keyword. final superNumText = superNum == 0 ? '' : '$superNum'; final methodName = superNum == 0 ? _keywordRename(name) : name; node.finalName = '$methodName$superNumText'; - methodNumsAfterRenaming[node.classDecl]?[sig] = superNum; + node.classDecl.methodNumsAfterRenaming[sig] = superNum; } else { node.finalName = _renameConflict(nameCounts, name); - methodNumsAfterRenaming[node.classDecl]?[sig] = nameCounts[name]! - 1; + node.classDecl.methodNumsAfterRenaming[sig] = nameCounts[name]! - 1; } log.fine( 'Method ${node.classDecl.binaryName}#${node.name} is named ${node.finalName}'); diff --git a/pkgs/jnigen/lib/src/bindings/resolver.dart b/pkgs/jnigen/lib/src/bindings/resolver.dart index b0c82303c..68b250b78 100644 --- a/pkgs/jnigen/lib/src/bindings/resolver.dart +++ b/pkgs/jnigen/lib/src/bindings/resolver.dart @@ -4,18 +4,17 @@ import 'dart:math'; +import '../elements/elements.dart'; import '../logging/logging.dart'; class Resolver { - static const Map predefined = { - 'java.lang.String': 'jni.', - }; - /// Class corresponding to currently writing file. - final String currentClass; + /// + /// Is [null] when in single file mode. + final String? currentClass; /// Explicit import mappings. - final Map importMap; + final Map importedClasses; /// Names of all classes in input. final Set inputClassNames; @@ -27,7 +26,7 @@ class Resolver { final Map _classToImportedName = {}; Resolver({ - required this.importMap, + required this.importedClasses, required this.currentClass, this.inputClassNames = const {}, }); @@ -50,13 +49,20 @@ class Resolver { } /// Get the prefix for the class - String resolvePrefix(String binaryName) { - if (predefined.containsKey(binaryName)) { - return predefined[binaryName]!; + String resolvePrefix(ClassDecl classDecl) { + if (classDecl.path == 'package:jni/jni.dart') { + // For package:jni we don't use a leading underscore. + return 'jni.'; } + final binaryName = classDecl.binaryName; final target = getFileClassName(binaryName); - if (target == currentClass && inputClassNames.contains(binaryName)) { + // For classes we generate (inside [inputClassNames]) no import + // (and therefore no prefix) is necessary when: + // * Never necessary in single file mode + // * In multi file mode if the target is the same as the current class + if ((currentClass == null || target == currentClass) && + inputClassNames.contains(binaryName)) { return ''; } @@ -105,11 +111,11 @@ class Resolver { /// requested so that classes included in current bindings can be resolved /// using relative path. String? getImport(String classToResolve, String binaryName) { - var prefix = classToResolve; + final prefix = classToResolve; // short circuit if the requested class is specified directly in import map. - if (importMap.containsKey(binaryName)) { - return importMap[binaryName]!; + if (importedClasses.containsKey(binaryName)) { + return importedClasses[binaryName]!.path; } if (prefix.isEmpty) { @@ -117,7 +123,7 @@ class Resolver { } final dest = classToResolve.split('.'); - final src = currentClass.split('.'); + final src = currentClass!.split('.'); // Use relative import when the required class is included in current set // of bindings. if (inputClassNames.contains(binaryName)) { @@ -138,14 +144,6 @@ class Resolver { return '$pathToCommon$pathToClass.dart'; } - while (prefix.isNotEmpty) { - final split = cutFromLast(prefix, '.'); - final left = split[0]; - if (importMap.containsKey(prefix)) { - return importMap[prefix]!; - } - prefix = left; - } return null; } diff --git a/pkgs/jnigen/lib/src/config/config_types.dart b/pkgs/jnigen/lib/src/config/config_types.dart index 6030436b1..e74718c09 100644 --- a/pkgs/jnigen/lib/src/config/config_types.dart +++ b/pkgs/jnigen/lib/src/config/config_types.dart @@ -5,12 +5,20 @@ import 'dart:io'; import 'package:logging/logging.dart'; +import 'package:path/path.dart' as p; +import 'package:pub_semver/pub_semver.dart'; +import 'package:yaml/yaml.dart'; import '../elements/elements.dart'; +import '../logging/logging.dart'; +import '../util/find_package.dart'; import 'config_exception.dart'; import 'filters.dart'; import 'yaml_reader.dart'; +/// Modify this when symbols file format changes according to pub_semver. +final _currentVersion = Version(1, 0, 0); + /// Configuration for dependencies to be downloaded using maven. /// /// Dependency names should be listed in groupId:artifactId:version format. @@ -209,9 +217,9 @@ class DartCodeOutputConfig { this.structure = OutputStructure.packageStructure, }) { if (structure == OutputStructure.singleFile) { - if (!path.toFilePath().endsWith('.dart')) { + if (p.extension(path.toFilePath()) != '.dart') { throw ConfigException( - 'output path must end with ".dart" in single file mode'); + 'Dart\'s output path must end with ".dart" in single file mode.'); } } else { _ensureIsDirectory('Dart output path', path); @@ -225,19 +233,32 @@ class DartCodeOutputConfig { OutputStructure structure; } +class SymbolsOutputConfig { + /// Path to write generated Dart bindings. + final Uri path; + + SymbolsOutputConfig(this.path) { + if (p.extension(path.toFilePath()) != '.yaml') { + throw ConfigException('Symbol\'s output path must end with ".yaml".'); + } + } +} + class OutputConfig { OutputConfig({ + required this.dartConfig, this.bindingsType = BindingsType.cBased, this.cConfig, - required this.dartConfig, + this.symbolsConfig, }) { if (bindingsType == BindingsType.cBased && cConfig == null) { - throw ConfigException("C output config must be provided!"); + throw ConfigException('C output config must be provided!'); } } BindingsType bindingsType; DartCodeOutputConfig dartConfig; CCodeOutputConfig? cConfig; + SymbolsOutputConfig? symbolsConfig; } class BindingExclusions { @@ -257,12 +278,12 @@ class Config { this.sourcePath, this.classPath, this.preamble, - this.importMap, this.androidSdkConfig, this.mavenDownloads, this.summarizerOptions, this.logLevel = Level.INFO, this.dumpJsonTo, + this.imports, }); /// Output configuration for generated bindings @@ -296,18 +317,6 @@ class Config { /// Common text to be pasted on top of generated C and Dart files. final String? preamble; - /// Additional java package -> dart package mappings (Experimental). - /// - /// a mapping com.abc.package -> 'package:my_package.dart/my_import.dart' - /// in this configuration suggests that any reference to a type from - /// com.abc.package shall resolve to an import of 'package:my_package.dart'. - /// - /// This can be as granular - /// `com.abc.package.Class -> 'package:abc/abc.dart'` - /// or coarse - /// `com.abc.package` -> 'package:abc/abc.dart'` - final Map? importMap; - /// Whether or not to change Kotlin's suspend functions to Dart async ones. /// /// This will remove the final Continuation argument. @@ -321,9 +330,119 @@ class Config { /// along with their transitive dependencies. final MavenDownloads? mavenDownloads; - /// Additional options for the summarizer component + /// Additional options for the summarizer component. final SummarizerOptions? summarizerOptions; + /// List of dependencies. + final List? imports; + + /// Call [importClasses] before using this. + late final Map importedClasses; + + Future importClasses() async { + importedClasses = {}; + for (final import in [ + // Implicitly importing package:jni symbols. + Uri.parse('package:jni/jni_symbols.yaml'), + ...?imports, + ]) { + // Getting the actual uri in case of package uris. + final Uri yamlUri; + final String importPath; + if (import.scheme == 'package') { + final packageName = import.pathSegments.first; + final packageRoot = await findPackageRoot(packageName); + if (packageRoot == null) { + log.fatal('package:$packageName was not found.'); + } + yamlUri = packageRoot + .resolve('lib/') + .resolve(import.pathSegments.sublist(1).join('/')); + importPath = 'package:$packageName'; + } else { + yamlUri = import; + importPath = ([...import.pathSegments]..removeLast()).join('/'); + } + log.finest('Parsing yaml file in url $yamlUri.'); + final YamlMap yaml; + try { + final symbolsFile = File.fromUri(yamlUri); + final content = symbolsFile.readAsStringSync(); + yaml = loadYaml(content, sourceUrl: yamlUri); + } on UnsupportedError catch (_) { + log.fatal('Could not reference "$import".'); + } catch (e, s) { + log.warning(e); + log.warning(s); + log.fatal('Error while parsing yaml file "$import".'); + } + final version = Version.parse(yaml['version'] as String); + if (!VersionConstraint.compatibleWith(_currentVersion).allows(version)) { + log.fatal('"$import" is version "$version" which is not compatible with' + 'the current JNIgen symbols version $_currentVersion'); + } + final files = yaml['files'] as YamlMap; + for (final entry in files.entries) { + final filePath = entry.key as String; + final classes = entry.value as YamlMap; + for (final classEntry in classes.entries) { + final binaryName = classEntry.key as String; + final decl = classEntry.value as YamlMap; + if (importedClasses.containsKey(binaryName)) { + log.fatal( + 'Re-importing "$binaryName" in "$import".\n' + 'Try hiding the class in import.', + ); + } + final classDecl = ClassDecl( + simpleName: binaryName.split('.').last, + packageName: (binaryName.split('.')..removeLast()).join('.'), + binaryName: binaryName, + ) + ..path = '$importPath/$filePath' + ..finalName = decl['name'] + ..typeClassName = decl['type_class'] + ..superCount = decl['super_count']; + for (final typeParamEntry + in ((decl['type_params'] as YamlMap?)?.entries) ?? + >[]) { + final typeParamName = typeParamEntry.key as String; + final bounds = (typeParamEntry.value as YamlMap).entries.map((e) { + final boundName = e.key as String; + // Can only be DECLARED or TYPE_VARIABLE + if (!['DECLARED', 'TYPE_VARIABLE'].contains(e.value)) { + log.fatal( + 'Unsupported bound kind "${e.value}" for bound "$boundName" ' + 'in type parameter "$typeParamName" ' + 'of "$binaryName".', + ); + } + final boundKind = (e.value as String) == 'DECLARED' + ? Kind.declared + : Kind.typeVariable; + final ReferredType type; + if (boundKind == Kind.declared) { + type = + DeclaredType(binaryName: boundName, simpleName: boundName); + } else { + type = TypeVar(name: boundName); + } + return TypeUsage( + shorthand: boundName, kind: boundKind, typeJson: {}) + ..type = type; + }).toList(); + classDecl.allTypeParams.add( + TypeParam(name: typeParamName, bounds: bounds), + ); + } + classDecl.methodNumsAfterRenaming = + (decl['methods'] as YamlMap?)?.cast() ?? {}; + importedClasses[binaryName] = classDecl; + } + } + } + } + /// Directory containing the YAML configuration file, if any. Uri? get configRoot => _configRoot; Uri? _configRoot; @@ -337,8 +456,6 @@ class Config { static final _levels = Map.fromEntries( Level.LEVELS.map((l) => MapEntry(l.name.toLowerCase(), l))); - static List? _toUris(List? paths) => - paths?.map(Uri.file).toList(); static Config parseArgs(List args) { final prov = YamlReader.parseArgs(args); @@ -354,9 +471,6 @@ class Config { return res; } - Uri? directoryUri(String? path) => - path != null ? Uri.directory(path) : null; - MemberFilter? regexFilter(String property) { final exclusions = prov.getStringList(property); if (exclusions == null) return null; @@ -395,14 +509,13 @@ class Config { configRoot?.resolve(reference).toFilePath() ?? reference; final config = Config( - sourcePath: _toUris(prov.getPathList(_Props.sourcePath)), - classPath: _toUris(prov.getPathList(_Props.classPath)), + sourcePath: prov.getPathList(_Props.sourcePath), + classPath: prov.getPathList(_Props.classPath), classes: must(prov.getStringList, [], _Props.classes), summarizerOptions: SummarizerOptions( extraArgs: prov.getStringList(_Props.summarizerArgs) ?? const [], backend: prov.getString(_Props.backend), - workingDirectory: - directoryUri(prov.getPath(_Props.summarizerWorkingDir)), + workingDirectory: prov.getPath(_Props.summarizerWorkingDir), ), exclude: BindingExclusions( methods: regexFilter(_Props.excludeMethods), @@ -417,27 +530,32 @@ class Config { cConfig: prov.hasValue(_Props.cCodeOutputConfig) ? CCodeOutputConfig( libraryName: must(prov.getString, '', _Props.libraryName), - path: Uri.file(must(prov.getPath, '.', _Props.cRoot)), + path: must(prov.getPath, Uri.parse('.'), _Props.cRoot), subdir: prov.getString(_Props.cSubdir), ) : null, dartConfig: DartCodeOutputConfig( - path: Uri.file(must(prov.getPath, '.', _Props.dartRoot)), + path: must(prov.getPath, Uri.parse('.'), _Props.dartRoot), structure: getOutputStructure( prov.getString(_Props.outputStructure), OutputStructure.packageStructure, ), ), + symbolsConfig: prov.hasValue(_Props.symbolsOutputConfig) + ? SymbolsOutputConfig( + must(prov.getPath, Uri.parse('.'), _Props.symbolsOutputConfig), + ) + : null, ), preamble: prov.getString(_Props.preamble), - importMap: prov.getStringMap(_Props.importMap), + imports: prov.getPathList(_Props.import), mavenDownloads: prov.hasValue(_Props.mavenDownloads) ? MavenDownloads( sourceDeps: prov.getStringList(_Props.sourceDeps) ?? const [], - sourceDir: prov.getPath(_Props.mavenSourceDir) ?? + sourceDir: prov.getPath(_Props.mavenSourceDir)?.toFilePath() ?? resolveFromConfigRoot(MavenDownloads.defaultMavenSourceDir), jarOnlyDeps: prov.getStringList(_Props.jarOnlyDeps) ?? const [], - jarDir: prov.getPath(_Props.mavenJarDir) ?? + jarDir: prov.getPath(_Props.mavenJarDir)?.toFilePath() ?? resolveFromConfigRoot(MavenDownloads.defaultMavenJarDir), ) : null, @@ -496,11 +614,12 @@ class _Props { static const suspendFunToAsync = 'suspend_fun_to_async'; - static const importMap = 'import_map'; + static const import = 'import'; static const outputConfig = 'output'; static const bindingsType = '$outputConfig.bindings_type'; static const cCodeOutputConfig = '$outputConfig.c'; static const dartCodeOutputConfig = '$outputConfig.dart'; + static const symbolsOutputConfig = '$outputConfig.symbols'; static const cRoot = '$cCodeOutputConfig.path'; static const cSubdir = '$cCodeOutputConfig.subdir'; static const dartRoot = '$dartCodeOutputConfig.path'; diff --git a/pkgs/jnigen/lib/src/config/yaml_reader.dart b/pkgs/jnigen/lib/src/config/yaml_reader.dart index ecae2cb32..1cb1f46ca 100644 --- a/pkgs/jnigen/lib/src/config/yaml_reader.dart +++ b/pkgs/jnigen/lib/src/config/yaml_reader.dart @@ -86,8 +86,7 @@ class YamlReader { /// Same as [getString] but path is resolved relative to YAML config if it's /// from YAML config. - String? getPath(String property) => - _config.optionalPath(property)?.toFilePath(); + Uri? getPath(String property) => _config.optionalPath(property); List? getStringList(String property) => _config.optionalStringList( property, @@ -95,14 +94,11 @@ class YamlReader { combineAllConfigs: false, ); - List? getPathList(String property) { - final configResult = _config.optionalPathList( - property, - combineAllConfigs: false, - splitCliPattern: ';', - ); - return configResult?.map((e) => e.path).toList(); - } + List? getPathList(String property) => _config.optionalPathList( + property, + combineAllConfigs: false, + splitCliPattern: ';', + ); String? getOneOf(String property, Set values) => _config.optionalString(property, validValues: values); diff --git a/pkgs/jnigen/lib/src/elements/elements.dart b/pkgs/jnigen/lib/src/elements/elements.dart index 7793c1f03..347c818b3 100644 --- a/pkgs/jnigen/lib/src/elements/elements.dart +++ b/pkgs/jnigen/lib/src/elements/elements.dart @@ -29,7 +29,7 @@ enum DeclKind { } class Classes implements Element { - const Classes._(this.decls); + const Classes(this.decls); final Map decls; @@ -39,7 +39,7 @@ class Classes implements Element { final classDecl = ClassDecl.fromJson(declJson); decls[classDecl.binaryName] = classDecl; } - return Classes._(decls); + return Classes(decls); } @override @@ -115,6 +115,12 @@ class ClassDecl extends ClassMember implements Element { @JsonKey(includeFromJson: false) late final String finalName; + /// Name of the type class. + /// + /// Populated by [Renamer]. + @JsonKey(includeFromJson: false) + late final String typeClassName; + /// Unique name obtained by renaming conflicting names with a number. /// /// This is used by C bindings instead of fully qualified name to reduce @@ -130,6 +136,18 @@ class ClassDecl extends ClassMember implements Element { @JsonKey(includeFromJson: false) List allTypeParams = const []; + /// The path which this class is generated in. + /// + /// Populated by [Linker]. + @JsonKey(includeFromJson: false) + late final String path; + + /// The numeric suffix of the methods. + /// + /// Populated by [Renamer]. + @JsonKey(includeFromJson: false) + late final Map methodNumsAfterRenaming; + @override String toString() { return 'Java class declaration for $binaryName'; @@ -137,28 +155,6 @@ class ClassDecl extends ClassMember implements Element { String get signature => 'L$internalName;'; - static final object = ClassDecl( - binaryName: 'java.lang.Object', - packageName: 'java.lang', - simpleName: 'Object', - ) - ..finalName = 'JObject' - ..superCount = 0; - - static final string = ClassDecl( - superclass: TypeUsage.object, - binaryName: 'java.lang.String', - packageName: 'java.lang', - simpleName: 'String', - ) - ..finalName = 'JString' - ..superCount = 1; - - static final predefined = { - 'java.lang.Object': object, - 'java.lang.String': string, - }; - factory ClassDecl.fromJson(Map json) => _$ClassDeclFromJson(json); @@ -172,6 +168,8 @@ class ClassDecl extends ClassMember implements Element { @override String get name => finalName; + + bool isObject() => superCount == 0; } @JsonEnum() @@ -196,15 +194,10 @@ class TypeUsage { required this.typeJson, }); - static TypeUsage object = () { - final typeUsage = TypeUsage.fromJson({ - "shorthand": "java.lang.Object", - "kind": "DECLARED", - "type": {"binaryName": "java.lang.Object", "simpleName": "Object"} - }); - (typeUsage.type as DeclaredType).classDecl = ClassDecl.object; - return typeUsage; - }(); + static TypeUsage object = TypeUsage( + kind: Kind.declared, shorthand: 'JObject', typeJson: {}) + ..type = + (DeclaredType(binaryName: 'java.lang.Object', simpleName: 'Object')); final String shorthand; final Kind kind; diff --git a/pkgs/jnigen/lib/src/generate_bindings.dart b/pkgs/jnigen/lib/src/generate_bindings.dart index ab184da4f..5c9dc9bed 100644 --- a/pkgs/jnigen/lib/src/generate_bindings.dart +++ b/pkgs/jnigen/lib/src/generate_bindings.dart @@ -34,10 +34,9 @@ Future generateJniBindings(Config config) async { log.fatal(e.message); } - classes - ..accept(Excluder(config)) - ..accept(Linker(config)) - ..accept(Renamer(config)); + classes.accept(Excluder(config)); + await classes.accept(Linker(config)); + classes.accept(Renamer(config)); final cBased = config.outputConfig.bindingsType == BindingsType.cBased; if (cBased) { diff --git a/pkgs/jnigen/pubspec.yaml b/pkgs/jnigen/pubspec.yaml index 5cde347c6..a76d658f3 100644 --- a/pkgs/jnigen/pubspec.yaml +++ b/pkgs/jnigen/pubspec.yaml @@ -14,6 +14,7 @@ dependencies: json_annotation: ^4.8.0 package_config: ^2.1.0 path: ^1.8.0 + pub_semver: ^2.1.4 args: ^2.3.0 yaml: ^3.1.0 logging: ^1.0.2 diff --git a/pkgs/jnigen/test/config_test.dart b/pkgs/jnigen/test/config_test.dart index 97fbb3d97..8538ac1c1 100644 --- a/pkgs/jnigen/test/config_test.dart +++ b/pkgs/jnigen/test/config_test.dart @@ -31,10 +31,12 @@ void expectConfigsAreEqual(Config a, Config b) { reason: "cRoot"); expect(a.outputConfig.dartConfig.path, equals(b.outputConfig.dartConfig.path), reason: "dartRoot"); + expect(a.outputConfig.symbolsConfig?.path, + equals(b.outputConfig.symbolsConfig?.path), + reason: "symbolsRoot"); expect(a.sourcePath, equals(b.sourcePath), reason: "sourcePath"); expect(a.classPath, equals(b.classPath), reason: "classPath"); expect(a.preamble, equals(b.preamble), reason: "preamble"); - expect(a.importMap, equals(b.importMap), reason: "importMap"); final am = a.mavenDownloads; final bm = b.mavenDownloads; if (am != null) { diff --git a/pkgs/jnigen/test/package_resolver_test.dart b/pkgs/jnigen/test/package_resolver_test.dart index 98c0d2bfd..2f3a2ea84 100644 --- a/pkgs/jnigen/test/package_resolver_test.dart +++ b/pkgs/jnigen/test/package_resolver_test.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. import 'package:jnigen/src/bindings/resolver.dart'; +import 'package:jnigen/src/elements/elements.dart'; import 'package:test/test.dart'; import 'test_util/test_util.dart'; @@ -17,21 +18,28 @@ class ResolverTest { void main() async { await checkLocallyBuiltDependencies(); final resolver = Resolver( - importMap: { - 'org.apache.pdfbox': 'package:pdfbox/pdfbox.dart', - 'android.os.Process': 'package:android/os.dart', - }, - currentClass: 'a.b.N', - inputClassNames: { - 'a.b.C', - 'a.b.c.D', - 'a.b.c.d.E', - 'a.X', - 'e.f.G', - 'e.F', - 'a.g.Y', - 'a.m.n.P' - }); + importedClasses: { + 'org.apache.pdfbox.pdmodel.PDDocument': ClassDecl( + binaryName: 'org.apache.pdfbox.pdmodel.PDDocument', + simpleName: 'PDDocument', + )..path = 'package:pdfbox/pdfbox.dart', + 'android.os.Process': ClassDecl( + binaryName: 'android.os.Process', + simpleName: 'Process', + )..path = 'package:android/os.dart', + }, + currentClass: 'a.b.N', + inputClassNames: { + 'a.b.C', + 'a.b.c.D', + 'a.b.c.d.E', + 'a.X', + 'e.f.G', + 'e.F', + 'a.g.Y', + 'a.m.n.P' + }, + ); final tests = [ // Absolute imports resolved using import map @@ -64,6 +72,8 @@ void main() async { test( 'resolve $binaryName', () => expect( - resolver.resolvePrefix(binaryName), equals(testCase.expectedName))); + resolver.resolvePrefix( + ClassDecl(binaryName: binaryName, simpleName: '')..path = ''), + equals(testCase.expectedName))); } } From 756cd11a2c407c88bb38e4184368bc8746c674c0 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Wed, 31 May 2023 20:41:03 +0200 Subject: [PATCH 095/139] [jnigen] Generating List/Map/... from classes in `package:jni` (https://github.com/dart-lang/jnigen/issues/291) Now some util classes: List, Map, Set and Iterator and boxed types (java.lang.Number, Byte, Integer, ...) are generated from `package:jni` readily available classes. --- pkgs/jni/CHANGELOG.md | 2 +- pkgs/jni/example/pubspec.lock | 2 +- pkgs/jni/lib/jni_symbols.yaml | 63 ++++++++++++++++++- pkgs/jni/pubspec.yaml | 2 +- pkgs/jnigen/CHANGELOG.md | 3 +- .../in_app_java/lib/android_utils.dart | 47 ++++++++------ .../org/apache/pdfbox/pdmodel/PDDocument.dart | 18 +++--- .../pdfbox/pdmodel/PDDocumentInformation.dart | 5 +- .../apache/pdfbox/text/PDFTextStripper.dart | 14 ++--- pkgs/jnigen/lib/src/config/config_types.dart | 3 +- pkgs/jnigen/pubspec.yaml | 2 +- .../fasterxml/jackson/core/JsonParser.dart | 21 ++++--- .../fasterxml/jackson/core/JsonParser.dart | 25 ++++---- .../c_based/dart_bindings/simple_package.dart | 6 +- .../dart_bindings/simple_package.dart | 4 +- 15 files changed, 145 insertions(+), 72 deletions(-) diff --git a/pkgs/jni/CHANGELOG.md b/pkgs/jni/CHANGELOG.md index c1367635b..08d66d880 100644 --- a/pkgs/jni/CHANGELOG.md +++ b/pkgs/jni/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.5.0-dev.0 +## 0.5.0 * **Breaking Change** ([#137](https://github.com/dart-lang/jnigen/issues/137)): Java primitive types are now all lowercase like `jint`, `jshort`, ... * The bindings for `java.util.Set`, `java.util.Map`, `java.util.List` and the numeric types like `java.lang.Integer`, `java.lang.Boolean`, ... are now included in `package:jni`. diff --git a/pkgs/jni/example/pubspec.lock b/pkgs/jni/example/pubspec.lock index 2edbc759c..3080aea5a 100644 --- a/pkgs/jni/example/pubspec.lock +++ b/pkgs/jni/example/pubspec.lock @@ -200,7 +200,7 @@ packages: path: ".." relative: true source: path - version: "0.5.0-dev.0" + version: "0.5.0" js: dependency: transitive description: diff --git a/pkgs/jni/lib/jni_symbols.yaml b/pkgs/jni/lib/jni_symbols.yaml index 199df295c..8b1f9ec88 100644 --- a/pkgs/jni/lib/jni_symbols.yaml +++ b/pkgs/jni/lib/jni_symbols.yaml @@ -9,4 +9,65 @@ files: name: JString type_class: JStringType super_count: 1 - + 'java.lang.Number': + name: JNumber + type_class: JNumberType + super_count: 1 + 'java.lang.Byte': + name: JByte + type_class: JByteType + super_count: 2 + 'java.lang.Short': + name: JShort + type_class: JShortType + super_count: 2 + 'java.lang.Integer': + name: JInteger + type_class: JIntegerType + super_count: 2 + 'java.lang.Long': + name: JLong + type_class: JLongType + super_count: 2 + 'java.lang.Float': + name: JFloat + type_class: JFloatType + super_count: 2 + 'java.lang.Double': + name: JDouble + type_class: JDoubleType + super_count: 2 + 'java.lang.Boolean': + name: JBoolean + type_class: JBooleanType + super_count: 1 + 'java.util.Set': + name: JSet + type_class: JSetType + super_count: 1 + type_params: + E: + 'java.lang.Object': DECLARED + 'java.util.List': + name: JList + type_class: JListType + super_count: 1 + type_params: + E: + 'java.lang.Object': DECLARED + 'java.util.Iterator': + name: JIterator + type_class: JIteratorType + super_count: 1 + type_params: + E: + 'java.lang.Object': DECLARED + 'java.util.Map': + name: JMap + type_class: JMapType + super_count: 1 + type_params: + K: + 'java.lang.Object': DECLARED + V: + 'java.lang.Object': DECLARED diff --git a/pkgs/jni/pubspec.yaml b/pkgs/jni/pubspec.yaml index 6a999b6ac..4de344fa3 100644 --- a/pkgs/jni/pubspec.yaml +++ b/pkgs/jni/pubspec.yaml @@ -1,6 +1,6 @@ name: jni description: Library to access JNI from dart and flutter -version: 0.5.0-dev.0 +version: 0.5.0 repository: https://github.com/dart-lang/jnigen/tree/main/jni environment: diff --git a/pkgs/jnigen/CHANGELOG.md b/pkgs/jnigen/CHANGELOG.md index 58fb5be78..4b7ca8e12 100644 --- a/pkgs/jnigen/CHANGELOG.md +++ b/pkgs/jnigen/CHANGELOG.md @@ -1,5 +1,6 @@ -## 0.5.0-dev.0 +## 0.5.0 * **Breaking Change** ([#72](https://github.com/dart-lang/jnigen/issues/72)): Removed support for `importMap` in favor of the newly added interop mechanism with importing yaml files. +* **Breaking Change** ([#72](https://github.com/dart-lang/jnigen/issues/72)): `java.util.Set`, `java.util.Map`, `java.util.List`, `java.util.Iterator` and the boxed types like `java.lang.Integer`, `java.lang.Double`, ... will be generated as their corresponding classes in `package:jni`. * Strings now use UTF16. ## 0.4.0 diff --git a/pkgs/jnigen/example/in_app_java/lib/android_utils.dart b/pkgs/jnigen/example/in_app_java/lib/android_utils.dart index 50e1e76d1..77ffac78b 100644 --- a/pkgs/jnigen/example/in_app_java/lib/android_utils.dart +++ b/pkgs/jnigen/example/in_app_java/lib/android_utils.dart @@ -1201,7 +1201,7 @@ class EmojiCompat_Config extends jni.JObject { /// be used instead. EmojiCompat_Config setUseEmojiAsDefaultStyle1( bool useEmojiAsDefaultStyle, - jni.JObject emojiAsDefaultStyleExceptions, + jni.JList emojiAsDefaultStyleExceptions, ) { return const $EmojiCompat_ConfigType().fromRef(_setUseEmojiAsDefaultStyle1( reference, @@ -2094,14 +2094,15 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19 /// from: public java.util.List queryIntentContentProviders(android.content.pm.PackageManager packageManager, android.content.Intent intent, int flags) /// The returned object must be deleted after use, by calling the `delete` method. - jni.JObject queryIntentContentProviders( + jni.JList queryIntentContentProviders( jni.JObject packageManager, jni.JObject intent, int flags, ) { - return const jni.JObjectType().fromRef(_queryIntentContentProviders( - reference, packageManager.reference, intent.reference, flags) - .object); + return const jni.JListType(jni.JObjectType()).fromRef( + _queryIntentContentProviders( + reference, packageManager.reference, intent.reference, flags) + .object); } static final _getProviderInfo = jniLookup< @@ -2227,14 +2228,15 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper /// The returned object must be deleted after use, by calling the `delete` method. /// /// Get the content provider by intent. - jni.JObject queryIntentContentProviders( + jni.JList queryIntentContentProviders( jni.JObject packageManager, jni.JObject intent, int flags, ) { - return const jni.JObjectType().fromRef(_queryIntentContentProviders( - reference, packageManager.reference, intent.reference, flags) - .object); + return const jni.JListType(jni.JObjectType()).fromRef( + _queryIntentContentProviders( + reference, packageManager.reference, intent.reference, flags) + .object); } static final _getProviderInfo = jniLookup< @@ -2686,8 +2688,8 @@ class Build extends jni.JObject { /// from: static public java.util.List getFingerprintedPartitions() /// The returned object must be deleted after use, by calling the `delete` method. - static jni.JObject getFingerprintedPartitions() { - return const jni.JObjectType() + static jni.JList getFingerprintedPartitions() { + return const jni.JListType(jni.JObjectType()) .fromRef(_getFingerprintedPartitions().object); } @@ -2806,10 +2808,16 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> /// from: public void (java.util.Map map) /// The returned object must be deleted after use, by calling the `delete` method. factory HashMap.ctor3( - jni.JObject map, { - required jni.JObjType<$K> K, - required jni.JObjType<$V> V, + jni.JMap<$K, $V> map, { + jni.JObjType<$K>? K, + jni.JObjType<$V>? V, }) { + K ??= jni.lowestCommonSuperType([ + (map.$type as jni.JMapType).K, + ]) as jni.JObjType<$K>; + V ??= jni.lowestCommonSuperType([ + (map.$type as jni.JMapType).V, + ]) as jni.JObjType<$V>; return HashMap.fromRef(K, V, _ctor3(map.reference).object); } @@ -2895,7 +2903,7 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> /// from: public void putAll(java.util.Map map) void putAll( - jni.JObject map, + jni.JMap<$K, $V> map, ) { return _putAll(reference, map.reference).check(); } @@ -2948,8 +2956,8 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> /// from: public java.util.Set keySet() /// The returned object must be deleted after use, by calling the `delete` method. - jni.JObject keySet() { - return const jni.JObjectType().fromRef(_keySet(reference).object); + jni.JSet<$K> keySet() { + return jni.JSetType(K).fromRef(_keySet(reference).object); } static final _values = jniLookup< @@ -2971,8 +2979,9 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> /// from: public java.util.Set entrySet() /// The returned object must be deleted after use, by calling the `delete` method. - jni.JObject entrySet() { - return const jni.JObjectType().fromRef(_entrySet(reference).object); + jni.JSet entrySet() { + return const jni.JSetType(jni.JObjectType()) + .fromRef(_entrySet(reference).object); } static final _getOrDefault = jniLookup< 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 25d114650..614a23f71 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 @@ -315,7 +315,7 @@ class PDDocument extends jni.JObject { ///@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.JObject sigFields, + jni.JList sigFields, jni.JObject signatureInterface, jni.JObject options, ) { @@ -553,8 +553,8 @@ class PDDocument extends jni.JObject { /// Retrieve all signature fields from the document. ///@return a List of PDSignatureFields ///@throws IOException if no document catalog can be found. - jni.JObject getSignatureFields() { - return const jni.JObjectType() + jni.JList getSignatureFields() { + return const jni.JListType(jni.JObjectType()) .fromRef(_getSignatureFields(reference).object); } @@ -570,8 +570,8 @@ class PDDocument extends jni.JObject { /// Retrieve all signature dictionaries from the document. ///@return a List of PDSignatureFields ///@throws IOException if no document catalog can be found. - jni.JObject getSignatureDictionaries() { - return const jni.JObjectType() + jni.JList getSignatureDictionaries() { + return const jni.JListType(jni.JObjectType()) .fromRef(_getSignatureDictionaries(reference).object); } @@ -1206,7 +1206,7 @@ class PDDocument extends jni.JObject { ///@throws IllegalStateException if the document was not loaded from a file or a stream. void saveIncremental1( jni.JObject output, - jni.JObject objectsToWrite, + jni.JSet objectsToWrite, ) { return _saveIncremental1( reference, output.reference, objectsToWrite.reference) @@ -1422,8 +1422,8 @@ class PDDocument extends jni.JObject { /// /// Provides the document ID. ///@return the document ID - jni.JObject getDocumentId() { - return const jni.JObjectType().fromRef(_getDocumentId(reference).object); + jni.JLong getDocumentId() { + return const jni.JLongType().fromRef(_getDocumentId(reference).object); } static final _setDocumentId = jniLookup< @@ -1439,7 +1439,7 @@ class PDDocument extends jni.JObject { /// Sets the document ID to the given value. ///@param docId the new document ID void setDocumentId( - jni.JObject docId, + jni.JLong docId, ) { return _setDocumentId(reference, docId.reference).check(); } 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 0b2354141..657f68ae1 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 @@ -422,8 +422,9 @@ class PDDocumentInformation extends jni.JObject { /// This will get the keys of all metadata information fields for the document. ///@return all metadata key strings. ///@since Apache PDFBox 1.3.0 - jni.JObject getMetadataKeys() { - return const jni.JObjectType().fromRef(_getMetadataKeys(reference).object); + jni.JSet getMetadataKeys() { + return const jni.JSetType(jni.JStringType()) + .fromRef(_getMetadataKeys(reference).object); } static final _getCustomMetadataValue = jniLookup< 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 1ae50f7f1..9d6fe3a33 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 @@ -493,7 +493,7 @@ class PDFTextStripper extends jni.JObject { ///@throws IOException If there is an error when writing the text. void writeString( jni.JString text, - jni.JObject textPositions, + jni.JList textPositions, ) { return _writeString(reference, text.reference, textPositions.reference) .check(); @@ -726,8 +726,8 @@ class PDFTextStripper extends jni.JObject { /// Character strings are grouped by articles. It is quite common that there will only be a single article. This /// returns a List that contains List objects, the inner lists will contain TextPosition objects. ///@return A double List of TextPositions for all text strings on the page. - jni.JObject getCharactersByArticle() { - return const jni.JObjectType() + jni.JList> getCharactersByArticle() { + return const jni.JListType(jni.JListType(jni.JObjectType())) .fromRef(_getCharactersByArticle(reference).object); } @@ -1331,7 +1331,7 @@ class PDFTextStripper extends jni.JObject { /// use to supply a different set of regular expression patterns for matching list item starts. ///@param patterns list of patterns void setListItemPatterns( - jni.JObject patterns, + jni.JList patterns, ) { return _setListItemPatterns(reference, patterns.reference).check(); } @@ -1361,8 +1361,8 @@ class PDFTextStripper extends jni.JObject { /// /// This method returns a list of such regular expression Patterns. ///@return a list of Pattern objects. - jni.JObject getListItemPatterns() { - return const jni.JObjectType() + jni.JList getListItemPatterns() { + return const jni.JListType(jni.JObjectType()) .fromRef(_getListItemPatterns(reference).object); } @@ -1389,7 +1389,7 @@ class PDFTextStripper extends jni.JObject { ///@return matching pattern static jni.JObject matchPattern( jni.JString string, - jni.JObject patterns, + jni.JList patterns, ) { return const jni.JObjectType() .fromRef(_matchPattern(string.reference, patterns.reference).object); diff --git a/pkgs/jnigen/lib/src/config/config_types.dart b/pkgs/jnigen/lib/src/config/config_types.dart index e74718c09..2c659a0e7 100644 --- a/pkgs/jnigen/lib/src/config/config_types.dart +++ b/pkgs/jnigen/lib/src/config/config_types.dart @@ -402,7 +402,8 @@ class Config { ..path = '$importPath/$filePath' ..finalName = decl['name'] ..typeClassName = decl['type_class'] - ..superCount = decl['super_count']; + ..superCount = decl['super_count'] + ..allTypeParams = []; for (final typeParamEntry in ((decl['type_params'] as YamlMap?)?.entries) ?? >[]) { diff --git a/pkgs/jnigen/pubspec.yaml b/pkgs/jnigen/pubspec.yaml index a76d658f3..65b523b7a 100644 --- a/pkgs/jnigen/pubspec.yaml +++ b/pkgs/jnigen/pubspec.yaml @@ -3,7 +3,7 @@ # BSD-style license that can be found in the LICENSE file. name: jnigen -version: 0.5.0-dev.0 +version: 0.5.0 description: Experimental generator for FFI+JNI bindings. repository: https://github.com/dart-lang/jnigen/tree/main/jnigen diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart index 562f0dd00..1c60902d0 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart @@ -1101,8 +1101,9 @@ class JsonParser extends jni.JObject { /// token parser advanced to; or {@code null} if next token is of some other type ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - jni.JObject nextBooleanValue() { - return const jni.JObjectType().fromRef(_nextBooleanValue(reference).object); + jni.JBoolean nextBooleanValue() { + return const jni.JBooleanType() + .fromRef(_nextBooleanValue(reference).object); } static final _skipChildren = jniLookup< @@ -1681,8 +1682,8 @@ class JsonParser extends jni.JObject { /// the current token is not numeric, or if decoding of the value fails /// (invalid format for numbers); plain IOException if underlying /// content read fails (possible if values are extracted lazily) - jni.JObject getNumberValue() { - return const jni.JObjectType().fromRef(_getNumberValue(reference).object); + jni.JNumber getNumberValue() { + return const jni.JNumberType().fromRef(_getNumberValue(reference).object); } static final _getNumberValueExact = jniLookup< @@ -1708,8 +1709,8 @@ class JsonParser extends jni.JObject { /// (invalid format for numbers); plain IOException if underlying /// content read fails (possible if values are extracted lazily) ///@since 2.12 - jni.JObject getNumberValueExact() { - return const jni.JObjectType() + jni.JNumber getNumberValueExact() { + return const jni.JNumberType() .fromRef(_getNumberValueExact(reference).object); } @@ -2573,11 +2574,11 @@ class JsonParser extends jni.JObject { ///@return Iterator for reading multiple Java values from content ///@throws IOException if there is either an underlying I/O problem or decoding /// issue at format layer - jni.JObject readValuesAs<$T extends jni.JObject>( + jni.JIterator<$T> readValuesAs<$T extends jni.JObject>( jni.JObject valueType, { required jni.JObjType<$T> T, }) { - return const jni.JObjectType() + return jni.JIteratorType(T) .fromRef(_readValuesAs(reference, valueType.reference).object); } @@ -2600,11 +2601,11 @@ class JsonParser extends jni.JObject { ///@return Iterator for reading multiple Java values from content ///@throws IOException if there is either an underlying I/O problem or decoding /// issue at format layer - jni.JObject readValuesAs1<$T extends jni.JObject>( + jni.JIterator<$T> readValuesAs1<$T extends jni.JObject>( jni.JObject valueTypeRef, { required jni.JObjType<$T> T, }) { - return const jni.JObjectType() + return jni.JIteratorType(T) .fromRef(_readValuesAs1(reference, valueTypeRef.reference).object); } diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart index 89a9affd2..601b40422 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart @@ -1046,11 +1046,10 @@ class JsonParser extends jni.JObject { /// token parser advanced to; or {@code null} if next token is of some other type ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems - jni.JObject nextBooleanValue() { - return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( - reference, - _id_nextBooleanValue, - jni.JniCallType.objectType, []).object); + jni.JBoolean nextBooleanValue() { + return const jni.JBooleanType().fromRef(jni.Jni.accessors + .callMethodWithArgs(reference, _id_nextBooleanValue, + jni.JniCallType.objectType, []).object); } static final _id_skipChildren = jni.Jni.accessors.getMethodIDOf( @@ -1585,8 +1584,8 @@ class JsonParser extends jni.JObject { /// the current token is not numeric, or if decoding of the value fails /// (invalid format for numbers); plain IOException if underlying /// content read fails (possible if values are extracted lazily) - jni.JObject getNumberValue() { - return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( + jni.JNumber getNumberValue() { + return const jni.JNumberType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getNumberValue, jni.JniCallType.objectType, []).object); } @@ -1610,8 +1609,8 @@ class JsonParser extends jni.JObject { /// (invalid format for numbers); plain IOException if underlying /// content read fails (possible if values are extracted lazily) ///@since 2.12 - jni.JObject getNumberValueExact() { - return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( + jni.JNumber getNumberValueExact() { + return const jni.JNumberType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getNumberValueExact, jni.JniCallType.objectType, []).object); @@ -2425,11 +2424,11 @@ class JsonParser extends jni.JObject { ///@return Iterator for reading multiple Java values from content ///@throws IOException if there is either an underlying I/O problem or decoding /// issue at format layer - jni.JObject readValuesAs<$T extends jni.JObject>( + jni.JIterator<$T> readValuesAs<$T extends jni.JObject>( jni.JObject valueType, { required jni.JObjType<$T> T, }) { - return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( + return jni.JIteratorType(T).fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_readValuesAs, jni.JniCallType.objectType, @@ -2452,11 +2451,11 @@ class JsonParser extends jni.JObject { ///@return Iterator for reading multiple Java values from content ///@throws IOException if there is either an underlying I/O problem or decoding /// issue at format layer - jni.JObject readValuesAs1<$T extends jni.JObject>( + jni.JIterator<$T> readValuesAs1<$T extends jni.JObject>( jni.JObject valueTypeRef, { required jni.JObjType<$T> T, }) { - return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( + return jni.JIteratorType(T).fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_readValuesAs1, jni.JniCallType.objectType, diff --git a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart index 70e0d7105..5cdec3763 100644 --- a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart @@ -949,12 +949,12 @@ class Fields extends jni.JObject { /// from: public java.lang.Integer i /// The returned object must be deleted after use, by calling the `delete` method. - jni.JObject get i => - const jni.JObjectType().fromRef(_get_i(reference).object); + jni.JInteger get i => + const jni.JIntegerType().fromRef(_get_i(reference).object); /// from: public java.lang.Integer i /// The returned object must be deleted after use, by calling the `delete` method. - set i(jni.JObject value) => _set_i(reference, value.reference).check(); + set i(jni.JInteger value) => _set_i(reference, value.reference).check(); static final _get_trillion = jniLookup< ffi.NativeFunction< diff --git a/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart index 24b9657cb..76effbbae 100644 --- a/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart @@ -893,13 +893,13 @@ class Fields extends jni.JObject { /// from: public java.lang.Integer i /// The returned object must be deleted after use, by calling the `delete` method. - jni.JObject get i => const jni.JObjectType().fromRef(jni.Jni.accessors + jni.JInteger get i => const jni.JIntegerType().fromRef(jni.Jni.accessors .getField(reference, _id_i, jni.JniCallType.objectType) .object); /// from: public java.lang.Integer i /// The returned object must be deleted after use, by calling the `delete` method. - set i(jni.JObject value) => + set i(jni.JInteger value) => jni.Jni.env.SetObjectField(reference, _id_i, value.reference); static final _id_trillion = jni.Jni.accessors.getFieldIDOf( From 4827fc357fd9f09a8622d2eb80f7905b0dc1a335 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Fri, 2 Jun 2023 12:01:10 +0200 Subject: [PATCH 096/139] [jnigen] remove simpleName and packageName (https://github.com/dart-lang/jnigen/issues/294) --- .../disasm/AsmAnnotatedElementVisitor.java | 1 - .../disasm/AsmAnnotationVisitor.java | 2 -- .../apisummarizer/disasm/AsmClassVisitor.java | 2 -- .../jnigen/apisummarizer/disasm/TypeUtils.java | 9 --------- .../apisummarizer/doclet/ElementBuilders.java | 3 --- .../jnigen/apisummarizer/elements/ClassDecl.java | 4 ---- .../apisummarizer/elements/JavaAnnotation.java | 1 - pkgs/jnigen/lib/src/bindings/c_generator.dart | 1 - pkgs/jnigen/lib/src/bindings/linker.dart | 2 +- pkgs/jnigen/lib/src/config/config_types.dart | 11 +++++------ pkgs/jnigen/lib/src/elements/elements.dart | 15 ++++----------- pkgs/jnigen/lib/src/elements/elements.g.dart | 4 ---- pkgs/jnigen/test/package_resolver_test.dart | 6 ++---- 13 files changed, 12 insertions(+), 49 deletions(-) diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmAnnotatedElementVisitor.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmAnnotatedElementVisitor.java index ca39167f2..0a723b310 100644 --- a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmAnnotatedElementVisitor.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmAnnotatedElementVisitor.java @@ -17,7 +17,6 @@ default AnnotationVisitor visitAnnotationDefault(String descriptor, boolean visi var annotation = new JavaAnnotation(); var aType = Type.getType(descriptor); annotation.binaryName = aType.getClassName(); - annotation.simpleName = TypeUtils.simpleName(aType); addAnnotation(annotation); return new AsmAnnotationVisitor(annotation); } diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmAnnotationVisitor.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmAnnotationVisitor.java index 9f6d5e2ba..1323a45b7 100644 --- a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmAnnotationVisitor.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmAnnotationVisitor.java @@ -35,7 +35,6 @@ public AnnotationVisitor visitAnnotation(String name, String descriptor) { var type = Type.getType(descriptor); var nested = new JavaAnnotation(); nested.binaryName = type.getClassName(); - nested.simpleName = TypeUtils.simpleName(type); annotation.properties.put(name, nested); return new AsmAnnotationVisitor(nested); } @@ -71,7 +70,6 @@ public AnnotationVisitor visitAnnotation(String unused, String descriptor) { var type = Type.getType(descriptor); var nested = new JavaAnnotation(); nested.binaryName = type.getClassName(); - nested.simpleName = TypeUtils.simpleName(type); list.add(nested); return new AsmAnnotationVisitor(nested); } diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmClassVisitor.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmClassVisitor.java index f542fe86c..061f3b496 100644 --- a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmClassVisitor.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmClassVisitor.java @@ -48,9 +48,7 @@ public void visit( current.binaryName = type.getClassName(); current.modifiers = TypeUtils.access(access); current.parentName = TypeUtils.parentName(type); - current.packageName = TypeUtils.packageName(type); current.declKind = TypeUtils.declKind(access); - current.simpleName = TypeUtils.simpleName(type); current.superclass = TypeUtils.typeUsage(Type.getObjectType(superName), null); current.interfaces = StreamUtil.map(interfaces, i -> TypeUtils.typeUsage(Type.getObjectType(i), null)); diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/TypeUtils.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/TypeUtils.java index 70b075a8d..7cb6f1e9f 100644 --- a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/TypeUtils.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/TypeUtils.java @@ -23,15 +23,6 @@ public static String parentName(Type type) { return type.getClassName().split("\\$")[0]; } - public static String packageName(Type type) { - var className = type.getClassName(); - var last = className.lastIndexOf("."); - if (last != -1) { - return className.substring(0, last); - } - return null; - } - public static String simpleName(Type type) { var internalName = type.getInternalName(); if (type.getInternalName().length() == 1) { diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/doclet/ElementBuilders.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/doclet/ElementBuilders.java index d1288159d..d0f2301c5 100644 --- a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/doclet/ElementBuilders.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/doclet/ElementBuilders.java @@ -22,7 +22,6 @@ public ElementBuilders(AstEnv env) { private void fillInFromTypeElement(TypeElement e, ClassDecl c) { c.modifiers = e.getModifiers().stream().map(Modifier::toString).collect(Collectors.toSet()); - c.simpleName = e.getSimpleName().toString(); c.binaryName = env.elements.getBinaryName(e).toString(); switch (e.getKind()) { case INTERFACE: @@ -45,7 +44,6 @@ private void fillInFromTypeElement(TypeElement e, ClassDecl c) { if (parent instanceof TypeElement) { c.parentName = env.elements.getBinaryName((TypeElement) parent).toString(); } - c.packageName = env.elements.getPackageOf(e).getQualifiedName().toString(); c.javadoc = docComment(env.trees.getDocCommentTree(e)); c.typeParams = StreamUtil.map(e.getTypeParameters(), this::typeParam); var superclass = e.getSuperclass(); @@ -82,7 +80,6 @@ public JavaAnnotation annotation(AnnotationMirror mirror) { var annotation = new JavaAnnotation(); var type = mirror.getAnnotationType(); var typeElement = (TypeElement) (env.types.asElement(type)); - annotation.simpleName = typeElement.getSimpleName().toString(); annotation.binaryName = env.elements.getBinaryName(typeElement).toString(); var values = env.elements.getElementValuesWithDefaults(mirror); if (values.isEmpty()) { diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/ClassDecl.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/ClassDecl.java index 42e069e4f..e439ab9f4 100644 --- a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/ClassDecl.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/ClassDecl.java @@ -21,9 +21,6 @@ public class ClassDecl { /** Modifiers eg: static, public and abstract. */ public Set modifiers; - /** Unqualified name of the class. For example `ClassDecl` */ - public String simpleName; - /** * Unique, fully qualified name of the class, it's like a qualified name used in a program but * uses $ instead of dot (.) before nested classes. @@ -31,7 +28,6 @@ public class ClassDecl { public String binaryName; public String parentName; - public String packageName; public List typeParams = new ArrayList<>(); public List methods = new ArrayList<>(); public List fields = new ArrayList<>(); diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/JavaAnnotation.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/JavaAnnotation.java index 89460bc5d..c463cba55 100644 --- a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/JavaAnnotation.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/JavaAnnotation.java @@ -8,7 +8,6 @@ import java.util.Map; public class JavaAnnotation { - public String simpleName; public String binaryName; public Map properties = new HashMap<>(); diff --git a/pkgs/jnigen/lib/src/bindings/c_generator.dart b/pkgs/jnigen/lib/src/bindings/c_generator.dart index ee30572a7..7ca6ef116 100644 --- a/pkgs/jnigen/lib/src/bindings/c_generator.dart +++ b/pkgs/jnigen/lib/src/bindings/c_generator.dart @@ -262,7 +262,6 @@ class _CMethodGenerator extends Visitor { if (node.isCtor) { javaReturnType = DeclaredType( binaryName: node.classDecl.binaryName, - simpleName: node.classDecl.simpleName, ); } final callType = node.returnType.accept(const _CTypeCallSite()); diff --git a/pkgs/jnigen/lib/src/bindings/linker.dart b/pkgs/jnigen/lib/src/bindings/linker.dart index 74c14e7a0..cdddaf54d 100644 --- a/pkgs/jnigen/lib/src/bindings/linker.dart +++ b/pkgs/jnigen/lib/src/bindings/linker.dart @@ -148,7 +148,7 @@ class _MethodLinker extends Visitor { if (config.suspendFunToAsync && node.params.isNotEmpty && node.params.last.type.kind == Kind.declared && - node.params.last.type.shorthand == kotlinContinutationType) { + node.params.last.type.name == kotlinContinutationType) { final continuationType = node.params.last.type.type as DeclaredType; node.asyncReturnType = continuationType.params.isEmpty ? TypeUsage.object diff --git a/pkgs/jnigen/lib/src/config/config_types.dart b/pkgs/jnigen/lib/src/config/config_types.dart index 2c659a0e7..63a418c2f 100644 --- a/pkgs/jnigen/lib/src/config/config_types.dart +++ b/pkgs/jnigen/lib/src/config/config_types.dart @@ -395,8 +395,6 @@ class Config { ); } final classDecl = ClassDecl( - simpleName: binaryName.split('.').last, - packageName: (binaryName.split('.')..removeLast()).join('.'), binaryName: binaryName, ) ..path = '$importPath/$filePath' @@ -423,14 +421,15 @@ class Config { : Kind.typeVariable; final ReferredType type; if (boundKind == Kind.declared) { - type = - DeclaredType(binaryName: boundName, simpleName: boundName); + type = DeclaredType(binaryName: boundName); } else { type = TypeVar(name: boundName); } return TypeUsage( - shorthand: boundName, kind: boundKind, typeJson: {}) - ..type = type; + shorthand: binaryName, + kind: boundKind, + typeJson: {}, + )..type = type; }).toList(); classDecl.allTypeParams.add( TypeParam(name: typeParamName, bounds: bounds), diff --git a/pkgs/jnigen/lib/src/elements/elements.dart b/pkgs/jnigen/lib/src/elements/elements.dart index 347c818b3..15f2f451a 100644 --- a/pkgs/jnigen/lib/src/elements/elements.dart +++ b/pkgs/jnigen/lib/src/elements/elements.dart @@ -58,9 +58,7 @@ class ClassDecl extends ClassMember implements Element { this.annotations = const [], this.javadoc, this.modifiers = const {}, - required this.simpleName, required this.binaryName, - this.packageName = '', this.parentName, this.typeParams = const [], this.methods = const [], @@ -77,10 +75,8 @@ class ClassDecl extends ClassMember implements Element { final List annotations; final JavaDocComment? javadoc; - final String simpleName; final String binaryName; final String? parentName; - final String packageName; List typeParams; List methods; List fields; @@ -97,6 +93,8 @@ class ClassDecl extends ClassMember implements Element { String get internalName => binaryName.replaceAll(".", "/"); + String get packageName => (binaryName.split('.')..removeLast()).join('.'); + /// The number of super classes this type has. /// /// Populated by [Linker]. @@ -195,9 +193,8 @@ class TypeUsage { }); static TypeUsage object = TypeUsage( - kind: Kind.declared, shorthand: 'JObject', typeJson: {}) - ..type = - (DeclaredType(binaryName: 'java.lang.Object', simpleName: 'Object')); + kind: Kind.declared, shorthand: 'java.lang.Object', typeJson: {}) + ..type = DeclaredType(binaryName: 'java.lang.Object'); final String shorthand; final Kind kind; @@ -356,12 +353,10 @@ class PrimitiveType extends ReferredType { class DeclaredType extends ReferredType { DeclaredType({ required this.binaryName, - required this.simpleName, this.params = const [], }); final String binaryName; - final String simpleName; final List params; @JsonKey(includeFromJson: false) @@ -608,12 +603,10 @@ class JavaDocComment implements Element { @JsonSerializable(createToJson: false) class Annotation implements Element { Annotation({ - required this.simpleName, required this.binaryName, this.properties = const {}, }); - final String simpleName; final String binaryName; final Map properties; diff --git a/pkgs/jnigen/lib/src/elements/elements.g.dart b/pkgs/jnigen/lib/src/elements/elements.g.dart index 2f099138e..20ce98c9a 100644 --- a/pkgs/jnigen/lib/src/elements/elements.g.dart +++ b/pkgs/jnigen/lib/src/elements/elements.g.dart @@ -18,9 +18,7 @@ ClassDecl _$ClassDeclFromJson(Map json) => ClassDecl( ?.map((e) => e as String) .toSet() ?? const {}, - simpleName: json['simpleName'] as String, binaryName: json['binaryName'] as String, - packageName: json['packageName'] as String? ?? '', parentName: json['parentName'] as String?, typeParams: (json['typeParams'] as List?) ?.map((e) => TypeParam.fromJson(e as Map)) @@ -63,7 +61,6 @@ const _$KindEnumMap = { DeclaredType _$DeclaredTypeFromJson(Map json) => DeclaredType( binaryName: json['binaryName'] as String, - simpleName: json['simpleName'] as String, params: (json['params'] as List?) ?.map((e) => TypeUsage.fromJson(e as Map)) .toList() ?? @@ -155,7 +152,6 @@ JavaDocComment _$JavaDocCommentFromJson(Map json) => ); Annotation _$AnnotationFromJson(Map json) => Annotation( - simpleName: json['simpleName'] as String, binaryName: json['binaryName'] as String, properties: (json['properties'] as Map?)?.map( (k, e) => MapEntry(k, e as Object), diff --git a/pkgs/jnigen/test/package_resolver_test.dart b/pkgs/jnigen/test/package_resolver_test.dart index 2f3a2ea84..8053b5aa2 100644 --- a/pkgs/jnigen/test/package_resolver_test.dart +++ b/pkgs/jnigen/test/package_resolver_test.dart @@ -21,11 +21,9 @@ void main() async { importedClasses: { 'org.apache.pdfbox.pdmodel.PDDocument': ClassDecl( binaryName: 'org.apache.pdfbox.pdmodel.PDDocument', - simpleName: 'PDDocument', )..path = 'package:pdfbox/pdfbox.dart', 'android.os.Process': ClassDecl( binaryName: 'android.os.Process', - simpleName: 'Process', )..path = 'package:android/os.dart', }, currentClass: 'a.b.N', @@ -72,8 +70,8 @@ void main() async { test( 'resolve $binaryName', () => expect( - resolver.resolvePrefix( - ClassDecl(binaryName: binaryName, simpleName: '')..path = ''), + resolver + .resolvePrefix(ClassDecl(binaryName: binaryName)..path = ''), equals(testCase.expectedName))); } } From 72e7019d61a9641c118cb14ab667ee4684ef8072 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Fri, 2 Jun 2023 15:58:07 +0200 Subject: [PATCH 097/139] [jnigen] Add proguard-rules for kotlin_plugin (https://github.com/dart-lang/jnigen/issues/296) --- .../example/kotlin_plugin/example/android/app/proguard-rules.pro | 1 + 1 file changed, 1 insertion(+) create mode 100644 pkgs/jnigen/example/kotlin_plugin/example/android/app/proguard-rules.pro diff --git a/pkgs/jnigen/example/kotlin_plugin/example/android/app/proguard-rules.pro b/pkgs/jnigen/example/kotlin_plugin/example/android/app/proguard-rules.pro new file mode 100644 index 000000000..8c1218b7c --- /dev/null +++ b/pkgs/jnigen/example/kotlin_plugin/example/android/app/proguard-rules.pro @@ -0,0 +1 @@ +-keep class kotlin.coroutines.** { *; } From 9ef4d1f8ca42e1796d98f9266db5f65cddd30557 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Tue, 13 Jun 2023 15:20:15 +0200 Subject: [PATCH 098/139] [jnigen] Non static nested class construction (https://github.com/dart-lang/jnigen/issues/297) Construct the non-static nested classes correctly --- .../apisummarizer/disasm/TypeUtils.java | 6 +- pkgs/jnigen/lib/src/bindings/c_generator.dart | 9 +- .../lib/src/bindings/dart_generator.dart | 4 +- pkgs/jnigen/lib/src/bindings/linker.dart | 15 +--- pkgs/jnigen/lib/src/bindings/renamer.dart | 9 +- pkgs/jnigen/lib/src/bindings/unnester.dart | 83 +++++++++++++++++++ pkgs/jnigen/lib/src/config/config_types.dart | 3 +- pkgs/jnigen/lib/src/elements/elements.dart | 6 +- pkgs/jnigen/lib/src/generate_bindings.dart | 2 + .../c_based/c_bindings/simple_package.c | 38 +++++---- .../c_based/dart_bindings/simple_package.dart | 70 ++++++++-------- .../dart_bindings/simple_package.dart | 68 ++++++++------- .../jnigen/generics/GrandParent.java | 18 ++-- .../runtime_test_registrant.dart | 16 ++++ 14 files changed, 232 insertions(+), 115 deletions(-) create mode 100644 pkgs/jnigen/lib/src/bindings/unnester.dart diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/TypeUtils.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/TypeUtils.java index 7cb6f1e9f..521c02d52 100644 --- a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/TypeUtils.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/TypeUtils.java @@ -20,7 +20,11 @@ class TypeUtils { public static String parentName(Type type) { - return type.getClassName().split("\\$")[0]; + var className = type.getClassName(); + if (!className.contains("$")) { + return null; + } + return className.split("\\$")[0]; } public static String simpleName(Type type) { diff --git a/pkgs/jnigen/lib/src/bindings/c_generator.dart b/pkgs/jnigen/lib/src/bindings/c_generator.dart index 7ca6ef116..dedef7666 100644 --- a/pkgs/jnigen/lib/src/bindings/c_generator.dart +++ b/pkgs/jnigen/lib/src/bindings/c_generator.dart @@ -390,9 +390,12 @@ class _CParamGenerator extends Visitor { @override String visit(Param node) { final paramName = - _cTypeKeywords.contains(node.name) ? '${node.name}0' : node.name; - final type = node.type.accept(const _CReturnType()); - if (addReturnType) return '$type $paramName'; + (_cTypeKeywords.contains(node.name) ? '${node.name}0' : node.name) + .replaceAll('\$', '_'); + if (addReturnType) { + final type = node.type.accept(const _CReturnType()); + return '$type $paramName'; + } return paramName; } } diff --git a/pkgs/jnigen/lib/src/bindings/dart_generator.dart b/pkgs/jnigen/lib/src/bindings/dart_generator.dart index a1559cf3e..2854e6be4 100644 --- a/pkgs/jnigen/lib/src/bindings/dart_generator.dart +++ b/pkgs/jnigen/lib/src/bindings/dart_generator.dart @@ -333,7 +333,7 @@ class _ClassGenerator extends Visitor { .map((typeParam) => 'this.$typeParam,') .join(_newLine(depth: 2)); final superClass = (node.classDecl.superclass!.type as DeclaredType); - final superTypeClassesCall = superClass.classDecl.isObject() + final superTypeClassesCall = superClass.classDecl.isObject ? '' : superClass.params .accept(_TypeClassGenerator(resolver)) @@ -1331,7 +1331,7 @@ class _TypeVarLocator extends TypeVisitor>> { @override Map> visitDeclaredType(DeclaredType node) { - if (node.classDecl.isObject()) { + if (node.classDecl.isObject) { return {}; } final offset = node.classDecl.allTypeParams.length - node.params.length; diff --git a/pkgs/jnigen/lib/src/bindings/linker.dart b/pkgs/jnigen/lib/src/bindings/linker.dart index cdddaf54d..d6b44a5f3 100644 --- a/pkgs/jnigen/lib/src/bindings/linker.dart +++ b/pkgs/jnigen/lib/src/bindings/linker.dart @@ -92,20 +92,7 @@ class _ClassLinker extends Visitor { log.finest('Linking ${node.binaryName}.'); _linked.add(node); - node.parent = resolve(node.parentName); - node.parent!.accept(this); - // Add type params of outer classes to the nested classes - final allTypeParams = []; - if (!node.modifiers.contains('static')) { - for (final typeParam in node.parent!.allTypeParams) { - if (!node.allTypeParams.contains(typeParam)) { - // Add only if it's not shadowing another type param. - allTypeParams.add(typeParam); - } - } - } - allTypeParams.addAll(node.typeParams); - node.allTypeParams = allTypeParams; + node.parent = node.parentName == null ? null : resolve(node.parentName); final typeLinker = _TypeLinker(resolve); node.superclass ??= TypeUsage.object; diff --git a/pkgs/jnigen/lib/src/bindings/renamer.dart b/pkgs/jnigen/lib/src/bindings/renamer.dart index d5f9a7339..607216ea1 100644 --- a/pkgs/jnigen/lib/src/bindings/renamer.dart +++ b/pkgs/jnigen/lib/src/bindings/renamer.dart @@ -65,6 +65,7 @@ const Set _keywords = { 'throw', 'true', 'try', + 'type', // Is used for type classes. 'typedef', 'var', 'void', @@ -213,8 +214,8 @@ class _MethodRenamer implements Visitor { node.finalName = _renameConflict(nameCounts, name); node.classDecl.methodNumsAfterRenaming[sig] = nameCounts[name]! - 1; } - log.fine( - 'Method ${node.classDecl.binaryName}#${node.name} is named ${node.finalName}'); + log.fine('Method ${node.classDecl.binaryName}#${node.name}' + ' is named ${node.finalName}'); final paramRenamer = _ParamRenamer(config); for (final param in node.params) { @@ -242,8 +243,8 @@ class _FieldRenamer implements Visitor { nameCounts, node.name, ); - log.fine( - 'Field ${node.classDecl.binaryName}#${node.name} is named ${node.finalName}'); + log.fine('Field ${node.classDecl.binaryName}#${node.name}' + ' is named ${node.finalName}'); } } diff --git a/pkgs/jnigen/lib/src/bindings/unnester.dart b/pkgs/jnigen/lib/src/bindings/unnester.dart new file mode 100644 index 000000000..00522051a --- /dev/null +++ b/pkgs/jnigen/lib/src/bindings/unnester.dart @@ -0,0 +1,83 @@ +// 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 '../elements/elements.dart'; +import 'visitor.dart'; + +/// A [Visitor] that processes nested classes. +/// +/// Nested classes are not supported in Dart. So this "unnests" them into +/// separate classes. +class Unnester extends Visitor { + @override + void visit(node) { + final classProcessor = _ClassUnnester(); + for (final classDecl in node.decls.values) { + classDecl.accept(classProcessor); + } + } +} + +class _ClassUnnester extends Visitor { + final processed = {}; + + @override + void visit(ClassDecl node) { + if (processed.contains(node)) return; + processed.add(node); + // We need to visit the ancestors first. + node.parent?.accept(this); + + // Add type params of outer classes to the nested classes. + final allTypeParams = []; + if (!node.isStatic) { + allTypeParams.addAll(node.parent?.allTypeParams ?? []); + } + allTypeParams.addAll(node.typeParams); + node.allTypeParams = allTypeParams; + + if (node.isNested && !node.isStatic) { + const methodProcessor = _MethodUnnester(); + for (final method in node.methods) { + method.accept(methodProcessor); + } + } + } +} + +class _MethodUnnester extends Visitor { + const _MethodUnnester(); + + @override + void visit(Method node) { + assert(!node.classDecl.isStatic); + assert(node.classDecl.isNested); + if (node.isCtor || node.isStatic) { + // Non-static nested classes take an instance of their outer class as the + // first parameter. This is not accounted for by the summarizer, so we + // manually add it as the first parameter. + final parentTypeParamCount = node.classDecl.allTypeParams.length - + node.classDecl.typeParams.length; + final parentTypeParams = [ + for (final typeParam + in node.classDecl.allTypeParams.take(parentTypeParamCount)) ...[ + TypeUsage( + shorthand: typeParam.name, kind: Kind.typeVariable, typeJson: {}) + ..type = TypeVar(name: typeParam.name), + ] + ]; + final parentType = DeclaredType( + binaryName: node.classDecl.parent!.binaryName, + params: parentTypeParams, + )..classDecl = node.classDecl.parent!; + final parentTypeUsage = TypeUsage( + shorthand: parentType.binaryName, kind: Kind.declared, typeJson: {}) + ..type = parentType; + final param = Param(name: '\$parent', type: parentTypeUsage); + // Make the list modifiable. + if (node.params.isEmpty) node.params = []; + node.params.insert(0, param); + } + } +} diff --git a/pkgs/jnigen/lib/src/config/config_types.dart b/pkgs/jnigen/lib/src/config/config_types.dart index 63a418c2f..58fc9a51a 100644 --- a/pkgs/jnigen/lib/src/config/config_types.dart +++ b/pkgs/jnigen/lib/src/config/config_types.dart @@ -401,7 +401,8 @@ class Config { ..finalName = decl['name'] ..typeClassName = decl['type_class'] ..superCount = decl['super_count'] - ..allTypeParams = []; + ..allTypeParams = [] + ..parent = null; for (final typeParamEntry in ((decl['type_params'] as YamlMap?)?.entries) ?? >[]) { diff --git a/pkgs/jnigen/lib/src/elements/elements.dart b/pkgs/jnigen/lib/src/elements/elements.dart index 15f2f451a..51c19b953 100644 --- a/pkgs/jnigen/lib/src/elements/elements.dart +++ b/pkgs/jnigen/lib/src/elements/elements.dart @@ -167,7 +167,9 @@ class ClassDecl extends ClassMember implements Element { @override String get name => finalName; - bool isObject() => superCount == 0; + bool get isObject => superCount == 0; + + bool get isNested => parentName != null; } @JsonEnum() @@ -455,7 +457,7 @@ class Method extends ClassMember implements Element { final List annotations; final JavaDocComment? javadoc; final List typeParams; - final List params; + List params; final TypeUsage returnType; /// The [ClassDecl] where this method is defined. diff --git a/pkgs/jnigen/lib/src/generate_bindings.dart b/pkgs/jnigen/lib/src/generate_bindings.dart index 5c9dc9bed..87727dce2 100644 --- a/pkgs/jnigen/lib/src/generate_bindings.dart +++ b/pkgs/jnigen/lib/src/generate_bindings.dart @@ -9,6 +9,7 @@ import 'bindings/c_generator.dart'; import 'bindings/dart_generator.dart'; import 'bindings/excluder.dart'; import 'bindings/linker.dart'; +import 'bindings/unnester.dart'; import 'bindings/renamer.dart'; import 'elements/elements.dart'; import 'summary/summary.dart'; @@ -36,6 +37,7 @@ Future generateJniBindings(Config config) async { classes.accept(Excluder(config)); await classes.accept(Linker(config)); + classes.accept(Unnester()); classes.accept(Renamer(config)); final cBased = config.outputConfig.bindingsType == BindingsType.cBased; diff --git a/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/simple_package.c b/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/simple_package.c index e388ec772..4a170e764 100644 --- a/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/simple_package.c +++ b/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/simple_package.c @@ -1513,7 +1513,7 @@ jclass _c_GrandParent_Parent = NULL; jmethodID _m_GrandParent_Parent__ctor = NULL; FFI_PLUGIN_EXPORT -JniResult GrandParent_Parent__ctor(jobject parentValue, jobject value) { +JniResult GrandParent_Parent__ctor(jobject _parent, jobject newValue) { load_env(); load_class_global_ref( &_c_GrandParent_Parent, @@ -1521,12 +1521,13 @@ JniResult GrandParent_Parent__ctor(jobject parentValue, jobject value) { if (_c_GrandParent_Parent == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_GrandParent_Parent, &_m_GrandParent_Parent__ctor, "", - "(Ljava/lang/Object;Ljava/lang/Object;)V"); + "(Lcom/github/dart_lang/jnigen/generics/GrandParent;Ljava/lang/" + "Object;)V"); if (_m_GrandParent_Parent__ctor == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_GrandParent_Parent, - _m_GrandParent_Parent__ctor, parentValue, value); + _m_GrandParent_Parent__ctor, _parent, newValue); return to_global_ref_result(_result); } @@ -1596,9 +1597,7 @@ jclass _c_GrandParent_Parent_Child = NULL; jmethodID _m_GrandParent_Parent_Child__ctor = NULL; FFI_PLUGIN_EXPORT -JniResult GrandParent_Parent_Child__ctor(jobject grandParentValue, - jobject parentValue, - jobject value) { +JniResult GrandParent_Parent_Child__ctor(jobject _parent, jobject newValue) { load_env(); load_class_global_ref( &_c_GrandParent_Parent_Child, @@ -1607,12 +1606,13 @@ JniResult GrandParent_Parent_Child__ctor(jobject grandParentValue, return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_GrandParent_Parent_Child, &_m_GrandParent_Parent_Child__ctor, "", - "(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V"); + "(Lcom/github/dart_lang/jnigen/generics/GrandParent$Parent;Ljava/" + "lang/Object;)V"); if (_m_GrandParent_Parent_Child__ctor == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_GrandParent_Parent_Child, _m_GrandParent_Parent_Child__ctor, - grandParentValue, parentValue, value); + _parent, newValue); return to_global_ref_result(_result); } @@ -1773,7 +1773,8 @@ jclass _c_GrandParent_StaticParent_Child = NULL; jmethodID _m_GrandParent_StaticParent_Child__ctor = NULL; FFI_PLUGIN_EXPORT -JniResult GrandParent_StaticParent_Child__ctor(jobject parentValue, +JniResult GrandParent_StaticParent_Child__ctor(jobject _parent, + jobject parentValue, jobject value) { load_env(); load_class_global_ref( @@ -1781,14 +1782,16 @@ JniResult GrandParent_StaticParent_Child__ctor(jobject parentValue, "com/github/dart_lang/jnigen/generics/GrandParent$StaticParent$Child"); if (_c_GrandParent_StaticParent_Child == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_GrandParent_StaticParent_Child, - &_m_GrandParent_StaticParent_Child__ctor, "", - "(Ljava/lang/Object;Ljava/lang/Object;)V"); + load_method( + _c_GrandParent_StaticParent_Child, + &_m_GrandParent_StaticParent_Child__ctor, "", + "(Lcom/github/dart_lang/jnigen/generics/GrandParent$StaticParent;Ljava/" + "lang/Object;Ljava/lang/Object;)V"); if (_m_GrandParent_StaticParent_Child__ctor == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject( jniEnv, _c_GrandParent_StaticParent_Child, - _m_GrandParent_StaticParent_Child__ctor, parentValue, value); + _m_GrandParent_StaticParent_Child__ctor, _parent, parentValue, value); return to_global_ref_result(_result); } @@ -1934,18 +1937,19 @@ jclass _c_MyMap_MyEntry = NULL; jmethodID _m_MyMap_MyEntry__ctor = NULL; FFI_PLUGIN_EXPORT -JniResult MyMap_MyEntry__ctor(jobject key, jobject value) { +JniResult MyMap_MyEntry__ctor(jobject _parent, jobject key, jobject value) { load_env(); load_class_global_ref(&_c_MyMap_MyEntry, "com/github/dart_lang/jnigen/generics/MyMap$MyEntry"); if (_c_MyMap_MyEntry == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_MyMap_MyEntry, &_m_MyMap_MyEntry__ctor, "", - "(Ljava/lang/Object;Ljava/lang/Object;)V"); + "(Lcom/github/dart_lang/jnigen/generics/MyMap;Ljava/lang/" + "Object;Ljava/lang/Object;)V"); if (_m_MyMap_MyEntry__ctor == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - jobject _result = (*jniEnv)->NewObject(jniEnv, _c_MyMap_MyEntry, - _m_MyMap_MyEntry__ctor, key, value); + jobject _result = (*jniEnv)->NewObject( + jniEnv, _c_MyMap_MyEntry, _m_MyMap_MyEntry__ctor, _parent, key, value); return to_global_ref_result(_result); } diff --git a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart index 5cdec3763..4e16f1e89 100644 --- a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart @@ -1578,22 +1578,22 @@ class GrandParent_Parent<$T extends jni.JObject, $S extends jni.JObject> jni.JniResult Function( ffi.Pointer, ffi.Pointer)>(); - /// from: public void (T parentValue, S value) + /// from: public void (com.github.dart_lang.jnigen.generics.GrandParent $parent, S newValue) /// The returned object must be deleted after use, by calling the `delete` method. factory GrandParent_Parent( - $T parentValue, - $S value, { + GrandParent<$T> $parent, + $S newValue, { jni.JObjType<$T>? T, jni.JObjType<$S>? S, }) { T ??= jni.lowestCommonSuperType([ - parentValue.$type, + ($parent.$type as $GrandParentType).T, ]) as jni.JObjType<$T>; S ??= jni.lowestCommonSuperType([ - value.$type, + newValue.$type, ]) as jni.JObjType<$S>; return GrandParent_Parent.fromRef( - T, S, _ctor(parentValue.reference, value.reference).object); + T, S, _ctor($parent.reference, newValue.reference).object); } } @@ -1747,40 +1747,32 @@ class GrandParent_Parent_Child<$T extends jni.JObject, $S extends jni.JObject, static final _ctor = jniLookup< ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer, - ffi.Pointer, + jni.JniResult Function(ffi.Pointer, ffi.Pointer)>>("GrandParent_Parent_Child__ctor") .asFunction< - jni.JniResult Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)>(); + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); - /// from: public void (T grandParentValue, S parentValue, U value) + /// from: public void (com.github.dart_lang.jnigen.generics.GrandParent$Parent $parent, U newValue) /// The returned object must be deleted after use, by calling the `delete` method. factory GrandParent_Parent_Child( - $T grandParentValue, - $S parentValue, - $U value, { + GrandParent_Parent<$T, $S> $parent, + $U newValue, { jni.JObjType<$T>? T, jni.JObjType<$S>? S, jni.JObjType<$U>? U, }) { T ??= jni.lowestCommonSuperType([ - grandParentValue.$type, + ($parent.$type as $GrandParent_ParentType).T, ]) as jni.JObjType<$T>; S ??= jni.lowestCommonSuperType([ - parentValue.$type, + ($parent.$type as $GrandParent_ParentType).S, ]) as jni.JObjType<$S>; U ??= jni.lowestCommonSuperType([ - value.$type, + newValue.$type, ]) as jni.JObjType<$U>; return GrandParent_Parent_Child.fromRef( - T, - S, - U, - _ctor(grandParentValue.reference, parentValue.reference, - value.reference) - .object); + T, S, U, _ctor($parent.reference, newValue.reference).object); } } @@ -2006,16 +1998,17 @@ class GrandParent_StaticParent_Child<$S extends jni.JObject, static final _ctor = jniLookup< ffi.NativeFunction< - jni.JniResult Function( + jni.JniResult Function(ffi.Pointer, ffi.Pointer, ffi.Pointer)>>( "GrandParent_StaticParent_Child__ctor") .asFunction< - jni.JniResult Function( - ffi.Pointer, ffi.Pointer)>(); + jni.JniResult Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); - /// from: public void (S parentValue, U value) + /// from: public void (com.github.dart_lang.jnigen.generics.GrandParent$StaticParent $parent, S parentValue, U value) /// The returned object must be deleted after use, by calling the `delete` method. factory GrandParent_StaticParent_Child( + GrandParent_StaticParent<$S> $parent, $S parentValue, $U value, { jni.JObjType<$S>? S, @@ -2023,12 +2016,16 @@ class GrandParent_StaticParent_Child<$S extends jni.JObject, }) { S ??= jni.lowestCommonSuperType([ parentValue.$type, + ($parent.$type as $GrandParent_StaticParentType).S, ]) as jni.JObjType<$S>; U ??= jni.lowestCommonSuperType([ value.$type, ]) as jni.JObjType<$U>; return GrandParent_StaticParent_Child.fromRef( - S, U, _ctor(parentValue.reference, value.reference).object); + S, + U, + _ctor($parent.reference, parentValue.reference, value.reference) + .object); } } @@ -2270,15 +2267,18 @@ class MyMap_MyEntry<$K extends jni.JObject, $V extends jni.JObject> static final _ctor = jniLookup< ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer, + jni.JniResult Function( + ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>("MyMap_MyEntry__ctor") .asFunction< - jni.JniResult Function( - ffi.Pointer, ffi.Pointer)>(); + jni.JniResult Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); - /// from: public void (K key, V value) + /// from: public void (com.github.dart_lang.jnigen.generics.MyMap $parent, K key, V value) /// The returned object must be deleted after use, by calling the `delete` method. factory MyMap_MyEntry( + MyMap<$K, $V> $parent, $K key, $V value, { jni.JObjType<$K>? K, @@ -2286,12 +2286,14 @@ class MyMap_MyEntry<$K extends jni.JObject, $V extends jni.JObject> }) { K ??= jni.lowestCommonSuperType([ key.$type, + ($parent.$type as $MyMapType).K, ]) as jni.JObjType<$K>; V ??= jni.lowestCommonSuperType([ value.$type, + ($parent.$type as $MyMapType).V, ]) as jni.JObjType<$V>; return MyMap_MyEntry.fromRef( - K, V, _ctor(key.reference, value.reference).object); + K, V, _ctor($parent.reference, key.reference, value.reference).object); } } diff --git a/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart index 76effbbae..fb92e1dd5 100644 --- a/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart @@ -1459,27 +1459,29 @@ class GrandParent_Parent<$T extends jni.JObject, $S extends jni.JObject> jni.Jni.env.SetObjectField(reference, _id_value, value.reference); static final _id_ctor = jni.Jni.accessors.getMethodIDOf( - _class.reference, r"", r"(Ljava/lang/Object;Ljava/lang/Object;)V"); + _class.reference, + r"", + r"(Lcom/github/dart_lang/jnigen/generics/GrandParent;Ljava/lang/Object;)V"); - /// from: public void (T parentValue, S value) + /// from: public void (com.github.dart_lang.jnigen.generics.GrandParent $parent, S newValue) /// The returned object must be deleted after use, by calling the `delete` method. factory GrandParent_Parent( - $T parentValue, - $S value, { + GrandParent<$T> $parent, + $S newValue, { jni.JObjType<$T>? T, jni.JObjType<$S>? S, }) { T ??= jni.lowestCommonSuperType([ - parentValue.$type, + ($parent.$type as $GrandParentType).T, ]) as jni.JObjType<$T>; S ??= jni.lowestCommonSuperType([ - value.$type, + newValue.$type, ]) as jni.JObjType<$S>; return GrandParent_Parent.fromRef( T, S, jni.Jni.accessors.newObjectWithArgs(_class.reference, _id_ctor, - [parentValue.reference, value.reference]).object); + [$parent.reference, newValue.reference]).object); } } @@ -1605,37 +1607,35 @@ class GrandParent_Parent_Child<$T extends jni.JObject, $S extends jni.JObject, set value($U value) => jni.Jni.env.SetObjectField(reference, _id_value, value.reference); - static final _id_ctor = jni.Jni.accessors.getMethodIDOf(_class.reference, - r"", r"(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V"); + static final _id_ctor = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"", + r"(Lcom/github/dart_lang/jnigen/generics/GrandParent$Parent;Ljava/lang/Object;)V"); - /// from: public void (T grandParentValue, S parentValue, U value) + /// from: public void (com.github.dart_lang.jnigen.generics.GrandParent$Parent $parent, U newValue) /// The returned object must be deleted after use, by calling the `delete` method. factory GrandParent_Parent_Child( - $T grandParentValue, - $S parentValue, - $U value, { + GrandParent_Parent<$T, $S> $parent, + $U newValue, { jni.JObjType<$T>? T, jni.JObjType<$S>? S, jni.JObjType<$U>? U, }) { T ??= jni.lowestCommonSuperType([ - grandParentValue.$type, + ($parent.$type as $GrandParent_ParentType).T, ]) as jni.JObjType<$T>; S ??= jni.lowestCommonSuperType([ - parentValue.$type, + ($parent.$type as $GrandParent_ParentType).S, ]) as jni.JObjType<$S>; U ??= jni.lowestCommonSuperType([ - value.$type, + newValue.$type, ]) as jni.JObjType<$U>; return GrandParent_Parent_Child.fromRef( T, S, U, - jni.Jni.accessors.newObjectWithArgs(_class.reference, _id_ctor, [ - grandParentValue.reference, - parentValue.reference, - value.reference - ]).object); + jni.Jni.accessors.newObjectWithArgs(_class.reference, _id_ctor, + [$parent.reference, newValue.reference]).object); } } @@ -1838,11 +1838,14 @@ class GrandParent_StaticParent_Child<$S extends jni.JObject, jni.Jni.env.SetObjectField(reference, _id_value, value.reference); static final _id_ctor = jni.Jni.accessors.getMethodIDOf( - _class.reference, r"", r"(Ljava/lang/Object;Ljava/lang/Object;)V"); + _class.reference, + r"", + r"(Lcom/github/dart_lang/jnigen/generics/GrandParent$StaticParent;Ljava/lang/Object;Ljava/lang/Object;)V"); - /// from: public void (S parentValue, U value) + /// from: public void (com.github.dart_lang.jnigen.generics.GrandParent$StaticParent $parent, S parentValue, U value) /// The returned object must be deleted after use, by calling the `delete` method. factory GrandParent_StaticParent_Child( + GrandParent_StaticParent<$S> $parent, $S parentValue, $U value, { jni.JObjType<$S>? S, @@ -1850,6 +1853,7 @@ class GrandParent_StaticParent_Child<$S extends jni.JObject, }) { S ??= jni.lowestCommonSuperType([ parentValue.$type, + ($parent.$type as $GrandParent_StaticParentType).S, ]) as jni.JObjType<$S>; U ??= jni.lowestCommonSuperType([ value.$type, @@ -1857,8 +1861,11 @@ class GrandParent_StaticParent_Child<$S extends jni.JObject, return GrandParent_StaticParent_Child.fromRef( S, U, - jni.Jni.accessors.newObjectWithArgs(_class.reference, _id_ctor, - [parentValue.reference, value.reference]).object); + jni.Jni.accessors.newObjectWithArgs(_class.reference, _id_ctor, [ + $parent.reference, + parentValue.reference, + value.reference + ]).object); } } @@ -2084,11 +2091,14 @@ class MyMap_MyEntry<$K extends jni.JObject, $V extends jni.JObject> jni.Jni.env.SetObjectField(reference, _id_value, value.reference); static final _id_ctor = jni.Jni.accessors.getMethodIDOf( - _class.reference, r"", r"(Ljava/lang/Object;Ljava/lang/Object;)V"); + _class.reference, + r"", + r"(Lcom/github/dart_lang/jnigen/generics/MyMap;Ljava/lang/Object;Ljava/lang/Object;)V"); - /// from: public void (K key, V value) + /// from: public void (com.github.dart_lang.jnigen.generics.MyMap $parent, K key, V value) /// The returned object must be deleted after use, by calling the `delete` method. factory MyMap_MyEntry( + MyMap<$K, $V> $parent, $K key, $V value, { jni.JObjType<$K>? K, @@ -2096,15 +2106,17 @@ class MyMap_MyEntry<$K extends jni.JObject, $V extends jni.JObject> }) { K ??= jni.lowestCommonSuperType([ key.$type, + ($parent.$type as $MyMapType).K, ]) as jni.JObjType<$K>; V ??= jni.lowestCommonSuperType([ value.$type, + ($parent.$type as $MyMapType).V, ]) as jni.JObjType<$V>; return MyMap_MyEntry.fromRef( K, V, jni.Jni.accessors.newObjectWithArgs(_class.reference, _id_ctor, - [key.reference, value.reference]).object); + [$parent.reference, key.reference, value.reference]).object); } } diff --git a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/generics/GrandParent.java b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/generics/GrandParent.java index a12675a6d..b7034034b 100644 --- a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/generics/GrandParent.java +++ b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/generics/GrandParent.java @@ -12,11 +12,11 @@ public GrandParent(T value) { } public Parent stringParent() { - return new Parent<>(value, "Hello"); + return new Parent<>("Hello"); } public Parent varParent(S nestedValue) { - return new Parent<>(value, nestedValue); + return new Parent<>(nestedValue); } public static StaticParent stringStaticParent() { @@ -54,9 +54,9 @@ public class Parent { public T parentValue; public S value; - public Parent(T parentValue, S value) { - this.parentValue = parentValue; - this.value = value; + public Parent(S newValue) { + parentValue = GrandParent.this.value; + value = newValue; } public class Child { @@ -64,10 +64,10 @@ public class Child { public S parentValue; public U value; - public Child(T grandParentValue, S parentValue, U value) { - this.grandParentValue = grandParentValue; - this.parentValue = parentValue; - this.value = value; + public Child(U newValue) { + this.grandParentValue = GrandParent.this.value; + this.parentValue = Parent.this.value; + this.value = newValue; } } } 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 6472985c9..f3075ac79 100644 --- a/pkgs/jnigen/test/simple_package_test/runtime_test_registrant.dart +++ b/pkgs/jnigen/test/simple_package_test/runtime_test_registrant.dart @@ -417,6 +417,22 @@ void registerTests(String groupName, TestRunnerCallback test) { }); }); }); + test('Constructing non-static nested classes', () { + using((arena) { + final grandParent = GrandParent(1.toJInteger())..deletedIn(arena); + final parent = GrandParent_Parent(grandParent, 2.toJInteger()) + ..deletedIn(arena); + final child = GrandParent_Parent_Child(parent, 3.toJInteger()) + ..deletedIn(arena); + expect(grandParent.value.intValue(deleteOriginal: true), 1); + expect(parent.parentValue.intValue(deleteOriginal: true), 1); + expect(parent.value.intValue(deleteOriginal: true), 2); + expect(child.grandParentValue.intValue(deleteOriginal: true), 1); + expect(child.parentValue.intValue(deleteOriginal: true), 2); + expect(child.value.intValue(deleteOriginal: true), 3); + }); + }); + group('Generic type inference', () { test('MyStack.of1', () { using((arena) { From cda656435428429629d5fc218d97caaec71fcdd4 Mon Sep 17 00:00:00 2001 From: Marco Domingos <66222324+Marco4763@users.noreply.github.com> Date: Mon, 26 Jun 2023 09:22:17 +0100 Subject: [PATCH 099/139] [jnigen] Added the namespace property in build.gradle if the field is necessary. (https://github.com/dart-lang/jnigen/issues/306) --- pkgs/jni/android/build.gradle | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/jni/android/build.gradle b/pkgs/jni/android/build.gradle index 8900d0c9c..4f5ca1b8e 100644 --- a/pkgs/jni/android/build.gradle +++ b/pkgs/jni/android/build.gradle @@ -27,6 +27,11 @@ rootProject.allprojects { apply plugin: 'com.android.library' android { + // Condition for namespace compatibility in AGP 8 + if (project.android.hasProperty("namespace")) { + namespace 'com.github.dart_lang.jni' + } + // Bumping the plugin compileSdkVersion requires all clients of this plugin // to bump the version in their app. compileSdkVersion 31 From fc6688dab3776826cdcffac7cc59c94297fbcd05 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Mon, 26 Jun 2023 19:08:41 +0200 Subject: [PATCH 100/139] [jnigen] Parse Kotlin's metadata + Remove `suspend_fun_to_async` flag in config (https://github.com/dart-lang/jnigen/issues/308) * Parse Kotlin's metadata in API Summarizer * Remove `suspend_fun_to_async` from config now that `isSuspend` reliably detect `suspend fun`s. --- pkgs/jnigen/CHANGELOG.md | 3 + pkgs/jnigen/README.md | 1 - pkgs/jnigen/java/README.md | 9 +- pkgs/jnigen/java/pom.xml | 5 + .../apisummarizer/disasm/AsmClassVisitor.java | 9 ++ .../KotlinMetadataAnnotationVisitor.java | 105 ++++++++++++++++++ .../apisummarizer/elements/ClassDecl.java | 1 + .../apisummarizer/elements/KotlinClass.java | 62 +++++++++++ .../elements/KotlinConstructor.java | 30 +++++ .../elements/KotlinFunction.java | 55 +++++++++ .../elements/KotlinProperty.java | 68 ++++++++++++ .../apisummarizer/elements/KotlinType.java | 40 +++++++ .../elements/KotlinTypeParameter.java | 29 +++++ .../elements/KotlinTypeProjection.java | 20 ++++ .../elements/KotlinValueParameter.java | 24 ++++ .../jnigen/apisummarizer/elements/Method.java | 1 + .../lib/src/bindings/kotlin_processor.dart | 60 ++++++++++ pkgs/jnigen/lib/src/bindings/linker.dart | 13 --- pkgs/jnigen/lib/src/config/config_types.dart | 10 -- pkgs/jnigen/lib/src/elements/elements.dart | 61 +++++++++- pkgs/jnigen/lib/src/elements/elements.g.dart | 20 ++++ pkgs/jnigen/lib/src/generate_bindings.dart | 2 + pkgs/jnigen/pubspec.yaml | 2 +- pkgs/jnigen/test/kotlin_test/generate.dart | 1 - 24 files changed, 599 insertions(+), 32 deletions(-) create mode 100644 pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/KotlinMetadataAnnotationVisitor.java create mode 100644 pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/KotlinClass.java create mode 100644 pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/KotlinConstructor.java create mode 100644 pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/KotlinFunction.java create mode 100644 pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/KotlinProperty.java create mode 100644 pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/KotlinType.java create mode 100644 pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/KotlinTypeParameter.java create mode 100644 pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/KotlinTypeProjection.java create mode 100644 pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/KotlinValueParameter.java create mode 100644 pkgs/jnigen/lib/src/bindings/kotlin_processor.dart diff --git a/pkgs/jnigen/CHANGELOG.md b/pkgs/jnigen/CHANGELOG.md index 4b7ca8e12..6ed1e844b 100644 --- a/pkgs/jnigen/CHANGELOG.md +++ b/pkgs/jnigen/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.6.0-dev.0 +* **Breaking Change** Removed `suspend_fun_to_async` flag from the config. It's now happening by default since we read the Kotlin's metadata and reliably identify the `suspend fun`s. + ## 0.5.0 * **Breaking Change** ([#72](https://github.com/dart-lang/jnigen/issues/72)): Removed support for `importMap` in favor of the newly added interop mechanism with importing yaml files. * **Breaking Change** ([#72](https://github.com/dart-lang/jnigen/issues/72)): `java.util.Set`, `java.util.Map`, `java.util.List`, `java.util.Iterator` and the boxed types like `java.lang.Integer`, `java.lang.Double`, ... will be generated as their corresponding classes in `package:jni`. diff --git a/pkgs/jnigen/README.md b/pkgs/jnigen/README.md index 56fba3780..8d47afd54 100644 --- a/pkgs/jnigen/README.md +++ b/pkgs/jnigen/README.md @@ -218,7 +218,6 @@ A `*` denotes required configuration. | `source_path` | List of directory paths | Directories to search for source files. Note: source_path for dependencies downloaded using `maven_downloads` configuration is added automatically without the need to specify here. | | `class_path` | List of directory / JAR paths | Classpath for API summary generation. This should include any JAR dependencies of the source files in `source_path`. | | `classes` * | List of qualified class / package names | List of qualified class / package names. `source_path` will be scanned assuming the sources follow standard java-ish hierarchy. That is a.b.c either maps to a directory `a/b/c` or a class file `a/b/c.java`. | -| `suspend_fun_to_async` | True/False | Converting Kotlin's suspend functions to Dart's async functions. Defaults to False. | | `output:` | (Subsection) | This subsection will contain configuration related to output files. | | `output:` >> `bindings_type` | `c_based` (default) or `dart_only` | Binding generation strategy. [Trade-offs](#pure-dart-bindings) are explained at the end of this document. | | `output:` >> `c:` | (Subsection) | This subsection specified C output configuration. Required if `bindings_type` is `c_based`. | diff --git a/pkgs/jnigen/java/README.md b/pkgs/jnigen/java/README.md index 50c8ab487..8b15049a8 100644 --- a/pkgs/jnigen/java/README.md +++ b/pkgs/jnigen/java/README.md @@ -1,4 +1,5 @@ ## ApiSummarizer + An early version of ApiSummarizer. It analyzes java source code / jars and outputs a JSON representation of the public API. @@ -6,11 +7,13 @@ It analyzes java source code / jars and outputs a JSON representation of the pub It's currently used in `jnigen` to get the information of the Java API. ## Build + When using it via `jnigen`, the `jnigen:setup` script will take care of building the jar in appropriate location. To build the jar manually, run `mvn compile` in project root. To build the jar and run the tests as well, run `mvn test`. The jar will be created in `target/` directory. ## Command line + ``` usage: java -jar [-s ] [-c ] @@ -27,13 +30,14 @@ or 'asm'). -v,--verbose Enable verbose output ``` -Here class or package names are specified as fully qualified names, for example `org.apache.pdfbox.pdmodel.PDDocument` will load `org/apache/pdfbox/pdmodel/PDDocument.java`. It assumes the package naming reflects directory structure. If such mapping results in a directory, for example `android.os` is given and a directory `android/os` is found under the source path, it is considered as a package and all Java source files under that directory are loaded recursively. +Here class or package names are specified as fully qualified names, for example `org.apache.pdfbox.pdmodel.PDDocument` will load `org/apache/pdfbox/pdmodel/PDDocument.java`. It assumes the package naming reflects directory structure. If such mapping results in a directory, for example `android.os` is given and a directory `android/os` is found under the source path, it is considered as a package and all Java source files under that directory are loaded recursively. Note that some options are directly forwarded to the underlying tool. ApiSummarizer's current use is in `jnigen` for obtaining public API of java packages. Only the features strictly required for that purpose are focused upon. ## Running tests + Run `mvn surefire:test` There are not many tests at the moment. We plan to add some later. @@ -43,4 +47,5 @@ There are not many tests at the moment. We plan to add some later. The main backend is based on javadoc API and generates summary based on java sources. A more experimental ASM backend also exists, and works somewhat okay-ish. It can summarize the compiled JARs. However, compiled jars without debug information do not include method parameter names. Some basic renaming is applied, i.e If type is `Object`, the parameter name will be output as `object` if an actual name is absent. ## TODO -See issue #23. \ No newline at end of file + +See issue #23. diff --git a/pkgs/jnigen/java/pom.xml b/pkgs/jnigen/java/pom.xml index 89c5a9edf..226bb03fc 100644 --- a/pkgs/jnigen/java/pom.xml +++ b/pkgs/jnigen/java/pom.xml @@ -33,6 +33,11 @@ asm-tree 9.3 + + org.jetbrains.kotlinx + kotlinx-metadata-jvm + 0.6.2 + junit junit diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmClassVisitor.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmClassVisitor.java index 061f3b496..50bf2f0db 100644 --- a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmClassVisitor.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmClassVisitor.java @@ -91,6 +91,7 @@ public MethodVisitor visitMethod( return null; } method.name = name; + method.descriptor = descriptor; var type = Type.getType(descriptor); var params = new ArrayList(); var paramTypes = type.getArgumentTypes(); @@ -117,6 +118,14 @@ public MethodVisitor visitMethod( return new AsmMethodVisitor(method); } + @Override + public AnnotationVisitor visitAnnotation(String descriptor, boolean visible) { + if (descriptor.equals("Lkotlin/Metadata;")) { + return new KotlinMetadataAnnotationVisitor(peekVisiting()); + } + return super.visitAnnotation(descriptor, visible); + } + @Override public void addAnnotation(JavaAnnotation annotation) { peekVisiting().annotations.add(annotation); diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/KotlinMetadataAnnotationVisitor.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/KotlinMetadataAnnotationVisitor.java new file mode 100644 index 000000000..c4aa8a13b --- /dev/null +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/KotlinMetadataAnnotationVisitor.java @@ -0,0 +1,105 @@ +// 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. + +package com.github.dart_lang.jnigen.apisummarizer.disasm; + +import com.github.dart_lang.jnigen.apisummarizer.elements.ClassDecl; +import com.github.dart_lang.jnigen.apisummarizer.elements.KotlinClass; +import java.util.ArrayList; +import java.util.List; +import kotlinx.metadata.jvm.KotlinClassHeader; +import kotlinx.metadata.jvm.KotlinClassMetadata; +import org.objectweb.asm.AnnotationVisitor; + +/** + * The format of Kotlin's metadata can be found here: + * https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-metadata/ + */ +public class KotlinMetadataAnnotationVisitor extends AnnotationVisitor { + private ClassDecl decl; + + private int kind; + private int[] metadataVersion; + private List data1 = new ArrayList<>(); + private List data2 = new ArrayList<>(); + private String extraString; + private String packageName; + private int extraInt; + + public KotlinMetadataAnnotationVisitor(ClassDecl decl) { + super(AsmConstants.API); + this.decl = decl; + } + + @Override + public void visit(String name, Object value) { + switch (name) { + case "k": + kind = (int) value; + return; + case "mv": + metadataVersion = (int[]) value; + return; + case "xs": + extraString = (String) value; + return; + case "pn": + packageName = (String) value; + return; + case "xi": + extraInt = (int) value; + } + } + + @Override + public AnnotationVisitor visitArray(String name) { + List arr; + switch (name) { + case "d1": + arr = data1; + break; + case "d2": + arr = data2; + break; + default: + return super.visitArray(name); + } + return new AnnotationVisitor(AsmConstants.API) { + @Override + public void visit(String name, Object value) { + arr.add((String) value); + super.visit(name, value); + } + }; + } + + @Override + public void visitEnd() { + var header = + new KotlinClassHeader( + kind, + metadataVersion, + data1.toArray(String[]::new), + data2.toArray(String[]::new), + extraString, + packageName, + extraInt); + var metadata = KotlinClassMetadata.read(header); + if (metadata instanceof KotlinClassMetadata.Class) { + decl.kotlinClass = + KotlinClass.fromKmClass(((KotlinClassMetadata.Class) metadata).toKmClass()); + } else if (metadata instanceof KotlinClassMetadata.FileFacade) { + // TODO(#301): Handle file facades. + } else if (metadata instanceof KotlinClassMetadata.SyntheticClass) { + // Ignore synthetic classes such as lambdas. + } else if (metadata instanceof KotlinClassMetadata.MultiFileClassFacade) { + // Ignore multi-file classes + } else if (metadata instanceof KotlinClassMetadata.MultiFileClassPart) { + // Ignore multi-file classes + } else if (metadata instanceof KotlinClassMetadata.Unknown) { + // Unsupported + } + super.visitEnd(); + } +} diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/ClassDecl.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/ClassDecl.java index e439ab9f4..231f0f5b9 100644 --- a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/ClassDecl.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/ClassDecl.java @@ -37,6 +37,7 @@ public class ClassDecl { public boolean hasInstanceInit; public JavaDocComment javadoc; public List annotations; + public KotlinClass kotlinClass; /** In case of enum, names of enum constants */ public List values = new ArrayList<>(); diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/KotlinClass.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/KotlinClass.java new file mode 100644 index 000000000..22906f705 --- /dev/null +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/KotlinClass.java @@ -0,0 +1,62 @@ +// 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. + +package com.github.dart_lang.jnigen.apisummarizer.elements; + +import java.util.List; +import java.util.stream.Collectors; +import kotlinx.metadata.KmClass; +import kotlinx.metadata.jvm.JvmExtensionsKt; + +public class KotlinClass { + public String name; + public String moduleName; + public List functions; + public List properties; + public List constructors; + public List typeParameters; + public List contextReceiverTypes; + public List superTypes; + public List nestedClasses; + public List enumEntries; + public List sealedClasses; + public String companionObject; + public String inlineClassUnderlyingPropertyName; + public KotlinType inlineClassUnderlyingType; + public int flags; + public int jvmFlags; + + public static KotlinClass fromKmClass(KmClass c) { + var klass = new KotlinClass(); + klass.name = c.getName(); + klass.moduleName = JvmExtensionsKt.getModuleName(c); + klass.functions = + c.getFunctions().stream().map(KotlinFunction::fromKmFunction).collect(Collectors.toList()); + klass.properties = + c.getProperties().stream().map(KotlinProperty::fromKmProperty).collect(Collectors.toList()); + klass.constructors = + c.getConstructors().stream() + .map(KotlinConstructor::fromKmConstructor) + .collect(Collectors.toList()); + klass.typeParameters = + c.getTypeParameters().stream() + .map(KotlinTypeParameter::fromKmTypeParameter) + .collect(Collectors.toList()); + klass.contextReceiverTypes = + c.getContextReceiverTypes().stream() + .map(KotlinType::fromKmType) + .collect(Collectors.toList()); + klass.superTypes = + c.getSupertypes().stream().map(KotlinType::fromKmType).collect(Collectors.toList()); + klass.enumEntries = c.getEnumEntries(); + klass.flags = c.getFlags(); + klass.jvmFlags = JvmExtensionsKt.getJvmFlags(c); + klass.nestedClasses = c.getNestedClasses(); + klass.companionObject = c.getCompanionObject(); + klass.inlineClassUnderlyingPropertyName = c.getInlineClassUnderlyingPropertyName(); + klass.inlineClassUnderlyingType = KotlinType.fromKmType(c.getInlineClassUnderlyingType()); + klass.sealedClasses = c.getSealedSubclasses(); + return klass; + } +} diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/KotlinConstructor.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/KotlinConstructor.java new file mode 100644 index 000000000..dae3a2f61 --- /dev/null +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/KotlinConstructor.java @@ -0,0 +1,30 @@ +// 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. + +package com.github.dart_lang.jnigen.apisummarizer.elements; + +import java.util.List; +import java.util.stream.Collectors; +import kotlinx.metadata.KmConstructor; +import kotlinx.metadata.jvm.JvmExtensionsKt; + +public class KotlinConstructor { + public String name; + public String descriptor; + public List valueParameters; + public int flags; + + public static KotlinConstructor fromKmConstructor(KmConstructor c) { + var ctor = new KotlinConstructor(); + ctor.flags = c.getFlags(); + var signature = JvmExtensionsKt.getSignature(c); + ctor.name = signature == null ? null : signature.getName(); + ctor.descriptor = signature == null ? null : signature.getDesc(); + ctor.valueParameters = + c.getValueParameters().stream() + .map(KotlinValueParameter::fromKmValueParameter) + .collect(Collectors.toList()); + return ctor; + } +} diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/KotlinFunction.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/KotlinFunction.java new file mode 100644 index 000000000..87cdc7be8 --- /dev/null +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/KotlinFunction.java @@ -0,0 +1,55 @@ +// 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. + +package com.github.dart_lang.jnigen.apisummarizer.elements; + +import java.util.List; +import java.util.stream.Collectors; +import kotlinx.metadata.Flag; +import kotlinx.metadata.KmFunction; +import kotlinx.metadata.jvm.JvmExtensionsKt; + +public class KotlinFunction { + /** Name in the byte code. */ + public String name; + + public String descriptor; + + /** Name in the Kotlin's metadata. */ + public String kotlinName; + + public List valueParameters; + public KotlinType returnType; + public KotlinType receiverParameterType; + public List contextReceiverTypes; + public List typeParameters; + public int flags; + public boolean isSuspend; + + public static KotlinFunction fromKmFunction(KmFunction f) { + var fun = new KotlinFunction(); + var signature = JvmExtensionsKt.getSignature(f); + fun.descriptor = signature == null ? null : signature.getDesc(); + fun.name = signature == null ? null : signature.getName(); + fun.kotlinName = f.getName(); + fun.flags = f.getFlags(); + // Processing the information needed from the flags. + fun.isSuspend = Flag.Function.IS_SUSPEND.invoke(fun.flags); + fun.valueParameters = + f.getValueParameters().stream() + .map(KotlinValueParameter::fromKmValueParameter) + .collect(Collectors.toList()); + fun.returnType = KotlinType.fromKmType(f.getReturnType()); + fun.receiverParameterType = KotlinType.fromKmType(f.getReceiverParameterType()); + fun.contextReceiverTypes = + f.getContextReceiverTypes().stream() + .map(KotlinType::fromKmType) + .collect(Collectors.toList()); + fun.typeParameters = + f.getTypeParameters().stream() + .map(KotlinTypeParameter::fromKmTypeParameter) + .collect(Collectors.toList()); + return fun; + } +} diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/KotlinProperty.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/KotlinProperty.java new file mode 100644 index 000000000..2858be4ba --- /dev/null +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/KotlinProperty.java @@ -0,0 +1,68 @@ +// 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. + +package com.github.dart_lang.jnigen.apisummarizer.elements; + +import java.util.List; +import java.util.stream.Collectors; +import kotlinx.metadata.KmProperty; +import kotlinx.metadata.jvm.JvmExtensionsKt; + +public class KotlinProperty { + public String fieldName; + public String fieldDescriptor; + + /** Getter's name in the byte code. */ + public String getterName; + + public String getterDescriptor; + + /** Setter's name in the byte code. */ + public String setterName; + + public String setterDescriptor; + + /** Name in the Kotlin's metadata. */ + public String kotlinName; + + public KotlinType returnType; + public KotlinType receiverParameterType; + public List contextReceiverTypes; + public int jvmFlags; + public int flags; + public int setterFlags; + public int getterFlags; + public List typeParameters; + public KotlinValueParameter setterParameter; + + public static KotlinProperty fromKmProperty(KmProperty p) { + var prop = new KotlinProperty(); + var fieldSignature = JvmExtensionsKt.getFieldSignature(p); + prop.fieldDescriptor = fieldSignature == null ? null : fieldSignature.getDesc(); + prop.fieldName = fieldSignature == null ? null : fieldSignature.getName(); + var getterSignature = JvmExtensionsKt.getGetterSignature(p); + prop.getterDescriptor = getterSignature == null ? null : getterSignature.getDesc(); + prop.getterName = getterSignature == null ? null : getterSignature.getName(); + var setterSignature = JvmExtensionsKt.getSetterSignature(p); + prop.setterDescriptor = setterSignature == null ? null : setterSignature.getDesc(); + prop.setterName = setterSignature == null ? null : setterSignature.getName(); + prop.kotlinName = p.getName(); + prop.returnType = KotlinType.fromKmType(p.getReturnType()); + prop.receiverParameterType = KotlinType.fromKmType(p.getReceiverParameterType()); + prop.contextReceiverTypes = + p.getContextReceiverTypes().stream() + .map(KotlinType::fromKmType) + .collect(Collectors.toList()); + prop.jvmFlags = JvmExtensionsKt.getJvmFlags(p); + prop.flags = p.getFlags(); + prop.setterFlags = p.getSetterFlags(); + prop.getterFlags = p.getGetterFlags(); + prop.typeParameters = + p.getTypeParameters().stream() + .map(KotlinTypeParameter::fromKmTypeParameter) + .collect(Collectors.toList()); + prop.setterParameter = KotlinValueParameter.fromKmValueParameter(p.getSetterParameter()); + return prop; + } +} diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/KotlinType.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/KotlinType.java new file mode 100644 index 000000000..8e91122ef --- /dev/null +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/KotlinType.java @@ -0,0 +1,40 @@ +// 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. + +package com.github.dart_lang.jnigen.apisummarizer.elements; + +import java.util.List; +import java.util.stream.Collectors; +import kotlinx.metadata.KmClassifier; +import kotlinx.metadata.KmType; + +public class KotlinType { + public int flags; + public String kind; + public String name; + public int id; + public List arguments; + + public static KotlinType fromKmType(KmType t) { + if (t == null) return null; + var type = new KotlinType(); + type.flags = t.getFlags(); + var classifier = t.getClassifier(); + if (classifier instanceof KmClassifier.Class) { + type.kind = "class"; + type.name = ((KmClassifier.Class) classifier).getName(); + } else if (classifier instanceof KmClassifier.TypeAlias) { + type.kind = "typeAlias"; + type.name = ((KmClassifier.TypeAlias) classifier).getName(); + } else if (classifier instanceof KmClassifier.TypeParameter) { + type.kind = "typeParameter"; + type.id = ((KmClassifier.TypeParameter) classifier).getId(); + } + type.arguments = + t.getArguments().stream() + .map(KotlinTypeProjection::fromKmTypeProjection) + .collect(Collectors.toList()); + return type; + } +} diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/KotlinTypeParameter.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/KotlinTypeParameter.java new file mode 100644 index 000000000..449aef16c --- /dev/null +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/KotlinTypeParameter.java @@ -0,0 +1,29 @@ +// 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. + +package com.github.dart_lang.jnigen.apisummarizer.elements; + +import java.util.List; +import java.util.stream.Collectors; +import kotlinx.metadata.KmTypeParameter; +import kotlinx.metadata.KmVariance; + +public class KotlinTypeParameter { + public String name; + public int id; + public int flags; + public List upperBounds; + public KmVariance variance; + + public static KotlinTypeParameter fromKmTypeParameter(KmTypeParameter t) { + var typeParam = new KotlinTypeParameter(); + typeParam.name = t.getName(); + typeParam.id = t.getId(); + typeParam.flags = t.getFlags(); + typeParam.upperBounds = + t.getUpperBounds().stream().map(KotlinType::fromKmType).collect(Collectors.toList()); + typeParam.variance = t.getVariance(); + return typeParam; + } +} diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/KotlinTypeProjection.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/KotlinTypeProjection.java new file mode 100644 index 000000000..364634c2e --- /dev/null +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/KotlinTypeProjection.java @@ -0,0 +1,20 @@ +// 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. + +package com.github.dart_lang.jnigen.apisummarizer.elements; + +import kotlinx.metadata.KmTypeProjection; +import kotlinx.metadata.KmVariance; + +public class KotlinTypeProjection { + public KotlinType type; + public KmVariance variance; + + public static KotlinTypeProjection fromKmTypeProjection(KmTypeProjection t) { + var proj = new KotlinTypeProjection(); + proj.type = KotlinType.fromKmType(t.getType()); + proj.variance = t.getVariance(); + return proj; + } +} diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/KotlinValueParameter.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/KotlinValueParameter.java new file mode 100644 index 000000000..1fba28d62 --- /dev/null +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/KotlinValueParameter.java @@ -0,0 +1,24 @@ +// 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. + +package com.github.dart_lang.jnigen.apisummarizer.elements; + +import kotlinx.metadata.KmValueParameter; + +public class KotlinValueParameter { + public String name; + public int flags; + public KotlinType type; + public KotlinType varargElementType; + + public static KotlinValueParameter fromKmValueParameter(KmValueParameter p) { + if (p == null) return null; + var param = new KotlinValueParameter(); + param.name = p.getName(); + param.flags = p.getFlags(); + param.type = KotlinType.fromKmType(p.getType()); + param.varargElementType = KotlinType.fromKmType(p.getVarargElementType()); + return param; + } +} diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/Method.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/Method.java index 0711c10c1..33bb0fb89 100644 --- a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/Method.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/Method.java @@ -12,6 +12,7 @@ public class Method { public Set modifiers = new HashSet<>(); public String name; + public String descriptor; public List typeParams = new ArrayList<>(); public List params = new ArrayList<>(); public TypeUsage returnType; diff --git a/pkgs/jnigen/lib/src/bindings/kotlin_processor.dart b/pkgs/jnigen/lib/src/bindings/kotlin_processor.dart new file mode 100644 index 000000000..4a48aa8c5 --- /dev/null +++ b/pkgs/jnigen/lib/src/bindings/kotlin_processor.dart @@ -0,0 +1,60 @@ +// 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 '../elements/elements.dart'; +import 'visitor.dart'; + +/// A [Visitor] that adds the the information from Kotlin's metadata to the Java +/// classes and methods. +class KotlinProcessor extends Visitor { + @override + void visit(Classes node) { + final classProcessor = _KotlinClassProcessor(); + for (final classDecl in node.decls.values) { + classDecl.accept(classProcessor); + } + } +} + +class _KotlinClassProcessor extends Visitor { + @override + void visit(ClassDecl node) { + if (node.kotlinClass == null) { + return; + } + // This [ClassDecl] is actually a Kotlin class. + // Matching methods and functions from the metadata. + final functions = {}; + for (final function in node.kotlinClass!.functions) { + final signature = function.name + function.descriptor; + functions[signature] = function; + } + for (final method in node.methods) { + final signature = method.name + method.descriptor!; + if (functions.containsKey(signature)) { + method.accept(_KotlinMethodProcessor(functions[signature]!)); + } + } + } +} + +class _KotlinMethodProcessor extends Visitor { + final KotlinFunction function; + + _KotlinMethodProcessor(this.function); + + @override + void visit(Method node) { + if (function.isSuspend) { + const kotlinContinutationType = 'kotlin.coroutines.Continuation'; + assert(node.params.isNotEmpty && + node.params.last.type.kind == Kind.declared && + node.params.last.type.name == kotlinContinutationType); + final continuationType = node.params.last.type.type as DeclaredType; + node.asyncReturnType = continuationType.params.isEmpty + ? TypeUsage.object + : continuationType.params.first; + } + } +} diff --git a/pkgs/jnigen/lib/src/bindings/linker.dart b/pkgs/jnigen/lib/src/bindings/linker.dart index d6b44a5f3..8e9091028 100644 --- a/pkgs/jnigen/lib/src/bindings/linker.dart +++ b/pkgs/jnigen/lib/src/bindings/linker.dart @@ -130,19 +130,6 @@ class _MethodLinker extends Visitor { final paramLinker = _ParamLinker(typeVisitor); node.typeParams.accept(typeParamLinker).toList(); node.params.accept(paramLinker).toList(); - // Kotlin specific - const kotlinContinutationType = 'kotlin.coroutines.Continuation'; - if (config.suspendFunToAsync && - node.params.isNotEmpty && - node.params.last.type.kind == Kind.declared && - node.params.last.type.name == kotlinContinutationType) { - final continuationType = node.params.last.type.type as DeclaredType; - node.asyncReturnType = continuationType.params.isEmpty - ? TypeUsage.object - : continuationType.params.first; - } else { - node.asyncReturnType = null; - } node.asyncReturnType?.accept(typeVisitor); } } diff --git a/pkgs/jnigen/lib/src/config/config_types.dart b/pkgs/jnigen/lib/src/config/config_types.dart index 58fc9a51a..f737b8111 100644 --- a/pkgs/jnigen/lib/src/config/config_types.dart +++ b/pkgs/jnigen/lib/src/config/config_types.dart @@ -274,7 +274,6 @@ class Config { required this.outputConfig, required this.classes, this.exclude, - this.suspendFunToAsync = false, this.sourcePath, this.classPath, this.preamble, @@ -317,12 +316,6 @@ class Config { /// Common text to be pasted on top of generated C and Dart files. final String? preamble; - /// Whether or not to change Kotlin's suspend functions to Dart async ones. - /// - /// This will remove the final Continuation argument. - /// Defaults to [false]. - final bool suspendFunToAsync; - /// Configuration to search for Android SDK libraries (Experimental). final AndroidSdkConfig? androidSdkConfig; @@ -522,7 +515,6 @@ class Config { methods: regexFilter(_Props.excludeMethods), fields: regexFilter(_Props.excludeFields), ), - suspendFunToAsync: prov.getBool(_Props.suspendFunToAsync) ?? false, outputConfig: OutputConfig( bindingsType: getBindingsType( prov.getString(_Props.bindingsType), @@ -613,8 +605,6 @@ class _Props { static const excludeMethods = '$exclude.methods'; static const excludeFields = '$exclude.fields'; - static const suspendFunToAsync = 'suspend_fun_to_async'; - static const import = 'import'; static const outputConfig = 'output'; static const bindingsType = '$outputConfig.bindings_type'; diff --git a/pkgs/jnigen/lib/src/elements/elements.dart b/pkgs/jnigen/lib/src/elements/elements.dart index 51c19b953..ceaee017c 100644 --- a/pkgs/jnigen/lib/src/elements/elements.dart +++ b/pkgs/jnigen/lib/src/elements/elements.dart @@ -68,12 +68,14 @@ class ClassDecl extends ClassMember implements Element { this.hasStaticInit = false, this.hasInstanceInit = false, this.values, + this.kotlinClass, }); @override final Set modifiers; final List annotations; + final KotlinClass? kotlinClass; final JavaDocComment? javadoc; final String binaryName; final String? parentName; @@ -444,6 +446,7 @@ class Method extends ClassMember implements Element { this.javadoc, this.modifiers = const {}, required this.name, + this.descriptor, this.typeParams = const [], this.params = const [], required this.returnType, @@ -460,6 +463,11 @@ class Method extends ClassMember implements Element { List params; final TypeUsage returnType; + /// Can be used to match with [KotlinFunction]'s descriptor. + /// + /// Can create a unique signature in combination with [name]. + final String? descriptor; + /// The [ClassDecl] where this method is defined. /// /// Populated by [Linker]. @@ -474,12 +482,11 @@ class Method extends ClassMember implements Element { @JsonKey(includeFromJson: false) late bool isOverridden; - /// This gets populated in the preprocessing stage. + /// The actual return type when the method is a Kotlin's suspend fun. /// - /// It will contain a type only when the suspendFunToAsync flag is on - /// and the method has a `kotlin.coroutines.Continuation` final argument. + /// Populated by [KotlinProcessor]. @JsonKey(includeFromJson: false) - late TypeUsage? asyncReturnType; + TypeUsage? asyncReturnType; @JsonKey(includeFromJson: false) late String javaSig = _javaSig(); @@ -620,3 +627,49 @@ class Annotation implements Element { return v.visit(this); } } + +@JsonSerializable(createToJson: false) +class KotlinClass implements Element { + KotlinClass({ + required this.name, + this.functions = const [], + }); + + final String name; + final List functions; + + factory KotlinClass.fromJson(Map json) => + _$KotlinClassFromJson(json); + + @override + R accept(Visitor v) { + return v.visit(this); + } +} + +@JsonSerializable(createToJson: false) +class KotlinFunction implements Element { + KotlinFunction({ + required this.name, + required this.descriptor, + required this.kotlinName, + required this.isSuspend, + }); + + final String name; + + /// Used to match with [Method]'s descriptor. + /// + /// Creates a unique signature in combination with [name]. + final String descriptor; + final String kotlinName; + final bool isSuspend; + + factory KotlinFunction.fromJson(Map json) => + _$KotlinFunctionFromJson(json); + + @override + R accept(Visitor v) { + return v.visit(this); + } +} diff --git a/pkgs/jnigen/lib/src/elements/elements.g.dart b/pkgs/jnigen/lib/src/elements/elements.g.dart index 20ce98c9a..4531342ec 100644 --- a/pkgs/jnigen/lib/src/elements/elements.g.dart +++ b/pkgs/jnigen/lib/src/elements/elements.g.dart @@ -43,6 +43,9 @@ ClassDecl _$ClassDeclFromJson(Map json) => ClassDecl( hasInstanceInit: json['hasInstanceInit'] as bool? ?? false, values: (json['values'] as List?)?.map((e) => e as String).toList(), + kotlinClass: json['kotlinClass'] == null + ? null + : KotlinClass.fromJson(json['kotlinClass'] as Map), ); TypeUsage _$TypeUsageFromJson(Map json) => TypeUsage( @@ -97,6 +100,7 @@ Method _$MethodFromJson(Map json) => Method( .toSet() ?? const {}, name: json['name'] as String, + descriptor: json['descriptor'] as String?, typeParams: (json['typeParams'] as List?) ?.map((e) => TypeParam.fromJson(e as Map)) .toList() ?? @@ -158,3 +162,19 @@ Annotation _$AnnotationFromJson(Map json) => Annotation( ) ?? const {}, ); + +KotlinClass _$KotlinClassFromJson(Map json) => KotlinClass( + name: json['name'] as String, + functions: (json['functions'] as List?) + ?.map((e) => KotlinFunction.fromJson(e as Map)) + .toList() ?? + const [], + ); + +KotlinFunction _$KotlinFunctionFromJson(Map json) => + KotlinFunction( + name: json['name'] as String, + descriptor: json['descriptor'] as String, + kotlinName: json['kotlinName'] as String, + isSuspend: json['isSuspend'] as bool, + ); diff --git a/pkgs/jnigen/lib/src/generate_bindings.dart b/pkgs/jnigen/lib/src/generate_bindings.dart index 87727dce2..174828eb3 100644 --- a/pkgs/jnigen/lib/src/generate_bindings.dart +++ b/pkgs/jnigen/lib/src/generate_bindings.dart @@ -8,6 +8,7 @@ import 'dart:convert'; import 'bindings/c_generator.dart'; import 'bindings/dart_generator.dart'; import 'bindings/excluder.dart'; +import 'bindings/kotlin_processor.dart'; import 'bindings/linker.dart'; import 'bindings/unnester.dart'; import 'bindings/renamer.dart'; @@ -36,6 +37,7 @@ Future generateJniBindings(Config config) async { } classes.accept(Excluder(config)); + classes.accept(KotlinProcessor()); await classes.accept(Linker(config)); classes.accept(Unnester()); classes.accept(Renamer(config)); diff --git a/pkgs/jnigen/pubspec.yaml b/pkgs/jnigen/pubspec.yaml index 65b523b7a..75be98a73 100644 --- a/pkgs/jnigen/pubspec.yaml +++ b/pkgs/jnigen/pubspec.yaml @@ -3,7 +3,7 @@ # BSD-style license that can be found in the LICENSE file. name: jnigen -version: 0.5.0 +version: 0.6.0-dev.0 description: Experimental generator for FFI+JNI bindings. repository: https://github.com/dart-lang/jnigen/tree/main/jnigen diff --git a/pkgs/jnigen/test/kotlin_test/generate.dart b/pkgs/jnigen/test/kotlin_test/generate.dart index 1b9b111b3..11b89ea53 100644 --- a/pkgs/jnigen/test/kotlin_test/generate.dart +++ b/pkgs/jnigen/test/kotlin_test/generate.dart @@ -51,7 +51,6 @@ Config getConfig([BindingsType bindingsType = BindingsType.cBased]) { // way to the generated code. 'com.github.dart_lang.jnigen', ], - suspendFunToAsync: true, logLevel: Level.ALL, outputConfig: OutputConfig( bindingsType: bindingsType, From fc8bd8ecdf9809ccbc8e39218eb2c20a658e5973 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Jul 2023 10:24:24 +0200 Subject: [PATCH 101/139] [jnigen] Bump coverallsapp/github-action from 2.1.2 to 2.2.0 (https://github.com/dart-lang/jnigen/issues/310) Bumps [coverallsapp/github-action](https://github.com/coverallsapp/github-action) from 2.1.2 to 2.2.0. - [Release notes](https://github.com/coverallsapp/github-action/releases) - [Commits](https://github.com/coverallsapp/github-action/compare/f350da2c033043742f89e8c0b7b5145a1616da6d...c7885c00cb7ec0b8f9f5ff3f53cddb980f7a4412) --- updated-dependencies: - dependency-name: coverallsapp/github-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/test-package.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 6a763822b..1599b8be5 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -106,7 +106,7 @@ jobs: - name: Collect coverage run: dart pub global run coverage:test_with_coverage - name: Upload coverage - uses: coverallsapp/github-action@f350da2c033043742f89e8c0b7b5145a1616da6d + uses: coverallsapp/github-action@c7885c00cb7ec0b8f9f5ff3f53cddb980f7a4412 with: github-token: ${{ secrets.GITHUB_TOKEN }} flag-name: jnigen_tests @@ -182,7 +182,7 @@ jobs: - name: Collect coverage run: dart pub global run coverage:test_with_coverage - name: Upload coverage - uses: coverallsapp/github-action@f350da2c033043742f89e8c0b7b5145a1616da6d + uses: coverallsapp/github-action@c7885c00cb7ec0b8f9f5ff3f53cddb980f7a4412 with: github-token: ${{ secrets.GITHUB_TOKEN }} flag-name: jni_tests @@ -423,7 +423,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Coveralls finished - uses: coverallsapp/github-action@f350da2c033043742f89e8c0b7b5145a1616da6d + uses: coverallsapp/github-action@c7885c00cb7ec0b8f9f5ff3f53cddb980f7a4412 with: github-token: ${{ secrets.github_token }} parallel-finished: true From e6bdddbfe50d353b17d8ee28467d7446dc5e4922 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Jul 2023 10:24:49 +0200 Subject: [PATCH 102/139] [jnigen] Bump actions/checkout from 3.5.2 to 3.5.3 (https://github.com/dart-lang/jnigen/issues/311) Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.2 to 3.5.3. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/8e5e7e5ab8b370d6c329ec480221332ada57f0ab...c85c95e3d7251135ab7dc9ce3241c5835cc595a9) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/test-package.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 1599b8be5..4e00de4c0 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -32,7 +32,7 @@ jobs: matrix: sdk: [stable] steps: - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: ${{ matrix.sdk }} @@ -67,7 +67,7 @@ jobs: os: [ubuntu-latest] sdk: [stable, beta] steps: - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: ${{ matrix.sdk }} @@ -120,7 +120,7 @@ jobs: run: working-directory: ./pkgs/jni steps: - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' @@ -158,7 +158,7 @@ jobs: run: working-directory: ./pkgs/jni steps: - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' @@ -203,7 +203,7 @@ jobs: run: working-directory: ./pkgs/jni steps: - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' @@ -225,7 +225,7 @@ jobs: run: working-directory: ./pkgs/jnigen steps: - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - name: Setup clang uses: egor-tensin/setup-clang@ef434b41eb33a70396fb336b1bae39c76d740c3d with: @@ -264,7 +264,7 @@ jobs: run: working-directory: ./pkgs/jni steps: - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' @@ -285,7 +285,7 @@ jobs: run: working-directory: ./pkgs/jnigen steps: - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - name: Setup clang format uses: ConorMacBride/install-package@3e7ad059e07782ee54fa35f827df52aae0626f30 with: @@ -314,7 +314,7 @@ jobs: run: working-directory: ./pkgs/jni/example steps: - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' @@ -338,7 +338,7 @@ jobs: run: working-directory: ./pkgs/jni/example steps: - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' @@ -358,7 +358,7 @@ jobs: run: working-directory: ./pkgs/jni/example steps: - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 with: distribution: 'zulu' @@ -377,7 +377,7 @@ jobs: run: working-directory: ./pkgs/jnigen/example/pdfbox_plugin steps: - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' From 7960c768c85acf2dbcdae009737353761d748206 Mon Sep 17 00:00:00 2001 From: Mahesh Hegde <46179734+mahesh-hegde@users.noreply.github.com> Date: Thu, 6 Jul 2023 01:48:25 +0530 Subject: [PATCH 103/139] [jnigen] Fix summarizer nested class bug (https://github.com/dart-lang/jnigen/issues/312) * Fix inner classes * Fix nested class finding * Remove -r and -v options * Add checks for nested classes in config * Remove problematic steps from GH action * Add anonymous inner class example * Use sorted() for deterministic order * Refactor ClassFinder logic and add Unit test * Filter anonymous classes in summarizer itself --- .github/workflows/test-package.yml | 7 - pkgs/jni/example/pubspec.lock | 2 +- pkgs/jni/pubspec.yaml | 2 +- pkgs/jnigen/CHANGELOG.md | 4 + pkgs/jnigen/bin/jnigen.dart | 1 + .../in_app_java/lib/android_utils.dart | 417 +++++++++++++++++- .../src/android_utils/android_utils.c | 278 ++++++++++++ pkgs/jnigen/java/.gitignore | 2 + .../dart_lang/jnigen/apisummarizer/Main.java | 10 +- .../apisummarizer/SummarizerOptions.java | 26 +- .../apisummarizer/disasm/AsmClassVisitor.java | 7 - .../doclet/SummarizerDoclet.java | 12 +- .../apisummarizer/util/ClassFinder.java | 187 ++++---- .../apisummarizer/util/ExceptionUtil.java | 17 +- .../jnigen/apisummarizer/util/JsonWriter.java | 4 +- .../jnigen/apisummarizer/util/Log.java | 30 +- .../jnigen/apisummarizer/ClassFinderTest.java | 95 ++++ .../apisummarizer/JSONComparisonTest.java | 12 + .../test/resources/exampleClassSummary.json | 4 - pkgs/jnigen/lib/src/config/config_types.dart | 29 +- pkgs/jnigen/lib/src/logging/logging.dart | 77 +++- pkgs/jnigen/lib/src/summary/summary.dart | 2 + .../lib/src/tools/android_sdk_tools.dart | 3 + pkgs/jnigen/pubspec.yaml | 2 +- pkgs/jnigen/test/config_test.dart | 4 + .../c_based/c_bindings/simple_package.c | 71 +++ .../c_based/dart_bindings/simple_package.dart | 77 ++++ .../dart_bindings/simple_package.dart | 77 ++++ .../jnigen/simple_package/Example.java | 15 + pkgs/jnigen/test/summary_generation_test.dart | 12 + 30 files changed, 1326 insertions(+), 160 deletions(-) create mode 100644 pkgs/jnigen/java/src/test/java/com/github/dart_lang/jnigen/apisummarizer/ClassFinderTest.java diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 4e00de4c0..6bcd5624b 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -392,13 +392,6 @@ jobs: sudo apt-get install -y ninja-build libgtk-3-dev clang-format - run: flutter config --enable-linux-desktop - run: dart pub get - - name: Generate bindings - run: | - dart run jnigen -Doutput.c.path=_c/ -Doutput.dart.path=_dart/ --config jnigen.yaml - - name: Compare generated bindings - run: | - diff -r _c src/ - diff -r _dart lib/src/third_party - name: Generate full bindings run: dart run jnigen --config jnigen.yaml --override classes="org.apache.pdfbox" - name: Analyze generated bindings diff --git a/pkgs/jni/example/pubspec.lock b/pkgs/jni/example/pubspec.lock index 3080aea5a..34dff04b1 100644 --- a/pkgs/jni/example/pubspec.lock +++ b/pkgs/jni/example/pubspec.lock @@ -200,7 +200,7 @@ packages: path: ".." relative: true source: path - version: "0.5.0" + version: "0.6.0-dev.1" js: dependency: transitive description: diff --git a/pkgs/jni/pubspec.yaml b/pkgs/jni/pubspec.yaml index 4de344fa3..0c1068a36 100644 --- a/pkgs/jni/pubspec.yaml +++ b/pkgs/jni/pubspec.yaml @@ -1,6 +1,6 @@ name: jni description: Library to access JNI from dart and flutter -version: 0.5.0 +version: 0.6.0-dev.1 repository: https://github.com/dart-lang/jnigen/tree/main/jni environment: diff --git a/pkgs/jnigen/CHANGELOG.md b/pkgs/jnigen/CHANGELOG.md index 6ed1e844b..48b1b212b 100644 --- a/pkgs/jnigen/CHANGELOG.md +++ b/pkgs/jnigen/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.6.0-dev.1 +* **Breaking Change** Specifying a class always pulls in nested classes by default. If a nested class is specified in config, it will be an error. +* Save all `jnigen` logs to a file in `.dart_tool/jnigen/logs/`. This is useful for debugging. + ## 0.6.0-dev.0 * **Breaking Change** Removed `suspend_fun_to_async` flag from the config. It's now happening by default since we read the Kotlin's metadata and reliably identify the `suspend fun`s. diff --git a/pkgs/jnigen/bin/jnigen.dart b/pkgs/jnigen/bin/jnigen.dart index be04b584f..8dc69e371 100644 --- a/pkgs/jnigen/bin/jnigen.dart +++ b/pkgs/jnigen/bin/jnigen.dart @@ -6,6 +6,7 @@ import 'package:jnigen/jnigen.dart'; import 'package:jnigen/src/logging/logging.dart'; void main(List args) async { + enableLoggingToFile(); Config config; try { config = Config.parseArgs(args); diff --git a/pkgs/jnigen/example/in_app_java/lib/android_utils.dart b/pkgs/jnigen/example/in_app_java/lib/android_utils.dart index 77ffac78b..028fa4292 100644 --- a/pkgs/jnigen/example/in_app_java/lib/android_utils.dart +++ b/pkgs/jnigen/example/in_app_java/lib/android_utils.dart @@ -2382,6 +2382,419 @@ class $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactoryType extends jni } } +/// from: android.os.Build$Partition +class Build_Partition extends jni.JObject { + @override + late final jni.JObjType $type = type; + + Build_Partition.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = $Build_PartitionType(); + + /// from: static public final java.lang.String PARTITION_NAME_SYSTEM + static const PARTITION_NAME_SYSTEM = r"""system"""; + + static final _getName = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("Build_Partition__getName") + .asFunction)>(); + + /// from: public java.lang.String getName() + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JString getName() { + return const jni.JStringType().fromRef(_getName(reference).object); + } + + static final _getFingerprint = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("Build_Partition__getFingerprint") + .asFunction)>(); + + /// from: public java.lang.String getFingerprint() + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JString getFingerprint() { + return const jni.JStringType().fromRef(_getFingerprint(reference).object); + } + + static final _getBuildTimeMillis = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>( + "Build_Partition__getBuildTimeMillis") + .asFunction)>(); + + /// from: public long getBuildTimeMillis() + int getBuildTimeMillis() { + return _getBuildTimeMillis(reference).long; + } + + static final _equals1 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("Build_Partition__equals1") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public boolean equals(java.lang.Object object) + bool equals1( + jni.JObject object, + ) { + return _equals1(reference, object.reference).boolean; + } + + static final _hashCode1 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("Build_Partition__hashCode1") + .asFunction)>(); + + /// from: public int hashCode() + int hashCode1() { + return _hashCode1(reference).integer; + } +} + +class $Build_PartitionType extends jni.JObjType { + const $Build_PartitionType(); + + @override + String get signature => r"Landroid/os/Build$Partition;"; + + @override + Build_Partition fromRef(jni.JObjectPtr ref) => Build_Partition.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($Build_PartitionType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == ($Build_PartitionType) && + other is $Build_PartitionType; + } +} + +/// from: android.os.Build$VERSION +class Build_VERSION extends jni.JObject { + @override + late final jni.JObjType $type = type; + + Build_VERSION.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = $Build_VERSIONType(); + static final _get_BASE_OS = + jniLookup>( + "get_Build_VERSION__BASE_OS") + .asFunction(); + + /// from: static public final java.lang.String BASE_OS + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JString get BASE_OS => + const jni.JStringType().fromRef(_get_BASE_OS().object); + + static final _get_CODENAME = + jniLookup>( + "get_Build_VERSION__CODENAME") + .asFunction(); + + /// from: static public final java.lang.String CODENAME + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JString get CODENAME => + const jni.JStringType().fromRef(_get_CODENAME().object); + + static final _get_INCREMENTAL = + jniLookup>( + "get_Build_VERSION__INCREMENTAL") + .asFunction(); + + /// from: static public final java.lang.String INCREMENTAL + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JString get INCREMENTAL => + const jni.JStringType().fromRef(_get_INCREMENTAL().object); + + static final _get_MEDIA_PERFORMANCE_CLASS = + jniLookup>( + "get_Build_VERSION__MEDIA_PERFORMANCE_CLASS") + .asFunction(); + + /// from: static public final int MEDIA_PERFORMANCE_CLASS + static int get MEDIA_PERFORMANCE_CLASS => + _get_MEDIA_PERFORMANCE_CLASS().integer; + + static final _get_PREVIEW_SDK_INT = + jniLookup>( + "get_Build_VERSION__PREVIEW_SDK_INT") + .asFunction(); + + /// from: static public final int PREVIEW_SDK_INT + static int get PREVIEW_SDK_INT => _get_PREVIEW_SDK_INT().integer; + + static final _get_RELEASE = + jniLookup>( + "get_Build_VERSION__RELEASE") + .asFunction(); + + /// from: static public final java.lang.String RELEASE + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JString get RELEASE => + const jni.JStringType().fromRef(_get_RELEASE().object); + + static final _get_RELEASE_OR_CODENAME = + jniLookup>( + "get_Build_VERSION__RELEASE_OR_CODENAME") + .asFunction(); + + /// from: static public final java.lang.String RELEASE_OR_CODENAME + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JString get RELEASE_OR_CODENAME => + const jni.JStringType().fromRef(_get_RELEASE_OR_CODENAME().object); + + static final _get_RELEASE_OR_PREVIEW_DISPLAY = + jniLookup>( + "get_Build_VERSION__RELEASE_OR_PREVIEW_DISPLAY") + .asFunction(); + + /// from: static public final java.lang.String RELEASE_OR_PREVIEW_DISPLAY + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JString get RELEASE_OR_PREVIEW_DISPLAY => + const jni.JStringType().fromRef(_get_RELEASE_OR_PREVIEW_DISPLAY().object); + + static final _get_SDK = + jniLookup>( + "get_Build_VERSION__SDK") + .asFunction(); + + /// from: static public final java.lang.String SDK + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JString get SDK => + const jni.JStringType().fromRef(_get_SDK().object); + + static final _get_SDK_INT = + jniLookup>( + "get_Build_VERSION__SDK_INT") + .asFunction(); + + /// from: static public final int SDK_INT + static int get SDK_INT => _get_SDK_INT().integer; + + static final _get_SECURITY_PATCH = + jniLookup>( + "get_Build_VERSION__SECURITY_PATCH") + .asFunction(); + + /// from: static public final java.lang.String SECURITY_PATCH + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JString get SECURITY_PATCH => + const jni.JStringType().fromRef(_get_SECURITY_PATCH().object); + + static final _ctor = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("Build_VERSION__ctor") + .asFunction)>(); + + /// from: public void (android.os.Build $parent) + /// The returned object must be deleted after use, by calling the `delete` method. + factory Build_VERSION( + Build $parent, + ) { + return Build_VERSION.fromRef(_ctor($parent.reference).object); + } +} + +class $Build_VERSIONType extends jni.JObjType { + const $Build_VERSIONType(); + + @override + String get signature => r"Landroid/os/Build$VERSION;"; + + @override + Build_VERSION fromRef(jni.JObjectPtr ref) => Build_VERSION.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($Build_VERSIONType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == ($Build_VERSIONType) && + other is $Build_VERSIONType; + } +} + +/// from: android.os.Build$VERSION_CODES +class Build_VERSION_CODES extends jni.JObject { + @override + late final jni.JObjType $type = type; + + Build_VERSION_CODES.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = $Build_VERSION_CODESType(); + + /// from: static public final int BASE + static const BASE = 1; + + /// from: static public final int BASE_1_1 + static const BASE_1_1 = 2; + + /// from: static public final int CUPCAKE + static const CUPCAKE = 3; + + /// from: static public final int CUR_DEVELOPMENT + static const CUR_DEVELOPMENT = 10000; + + /// from: static public final int DONUT + static const DONUT = 4; + + /// from: static public final int ECLAIR + static const ECLAIR = 5; + + /// from: static public final int ECLAIR_0_1 + static const ECLAIR_0_1 = 6; + + /// from: static public final int ECLAIR_MR1 + static const ECLAIR_MR1 = 7; + + /// from: static public final int FROYO + static const FROYO = 8; + + /// from: static public final int GINGERBREAD + static const GINGERBREAD = 9; + + /// from: static public final int GINGERBREAD_MR1 + static const GINGERBREAD_MR1 = 10; + + /// from: static public final int HONEYCOMB + static const HONEYCOMB = 11; + + /// from: static public final int HONEYCOMB_MR1 + static const HONEYCOMB_MR1 = 12; + + /// from: static public final int HONEYCOMB_MR2 + static const HONEYCOMB_MR2 = 13; + + /// from: static public final int ICE_CREAM_SANDWICH + static const ICE_CREAM_SANDWICH = 14; + + /// from: static public final int ICE_CREAM_SANDWICH_MR1 + static const ICE_CREAM_SANDWICH_MR1 = 15; + + /// from: static public final int JELLY_BEAN + static const JELLY_BEAN = 16; + + /// from: static public final int JELLY_BEAN_MR1 + static const JELLY_BEAN_MR1 = 17; + + /// from: static public final int JELLY_BEAN_MR2 + static const JELLY_BEAN_MR2 = 18; + + /// from: static public final int KITKAT + static const KITKAT = 19; + + /// from: static public final int KITKAT_WATCH + static const KITKAT_WATCH = 20; + + /// from: static public final int LOLLIPOP + static const LOLLIPOP = 21; + + /// from: static public final int LOLLIPOP_MR1 + static const LOLLIPOP_MR1 = 22; + + /// from: static public final int M + static const M = 23; + + /// from: static public final int N + static const N = 24; + + /// from: static public final int N_MR1 + static const N_MR1 = 25; + + /// from: static public final int O + static const O = 26; + + /// from: static public final int O_MR1 + static const O_MR1 = 27; + + /// from: static public final int P + static const P = 28; + + /// from: static public final int Q + static const Q = 29; + + /// from: static public final int R + static const R = 30; + + /// from: static public final int S + static const S = 31; + + /// from: static public final int S_V2 + static const S_V2 = 32; + + /// from: static public final int TIRAMISU + static const TIRAMISU = 33; + + static final _ctor = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer)>>("Build_VERSION_CODES__ctor") + .asFunction)>(); + + /// from: public void (android.os.Build $parent) + /// The returned object must be deleted after use, by calling the `delete` method. + factory Build_VERSION_CODES( + Build $parent, + ) { + return Build_VERSION_CODES.fromRef(_ctor($parent.reference).object); + } +} + +class $Build_VERSION_CODESType extends jni.JObjType { + const $Build_VERSION_CODESType(); + + @override + String get signature => r"Landroid/os/Build$VERSION_CODES;"; + + @override + Build_VERSION_CODES fromRef(jni.JObjectPtr ref) => + Build_VERSION_CODES.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($Build_VERSION_CODESType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == ($Build_VERSION_CODESType) && + other is $Build_VERSION_CODESType; + } +} + /// from: android.os.Build class Build extends jni.JObject { @override @@ -2688,8 +3101,8 @@ class Build extends jni.JObject { /// from: static public java.util.List getFingerprintedPartitions() /// The returned object must be deleted after use, by calling the `delete` method. - static jni.JList getFingerprintedPartitions() { - return const jni.JListType(jni.JObjectType()) + static jni.JList getFingerprintedPartitions() { + return const jni.JListType($Build_PartitionType()) .fromRef(_getFingerprintedPartitions().object); } diff --git a/pkgs/jnigen/example/in_app_java/src/android_utils/android_utils.c b/pkgs/jnigen/example/in_app_java/src/android_utils/android_utils.c index 6cf0cf289..c41ff6e96 100644 --- a/pkgs/jnigen/example/in_app_java/src/android_utils/android_utils.c +++ b/pkgs/jnigen/example/in_app_java/src/android_utils/android_utils.c @@ -1352,6 +1352,284 @@ JniResult DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__create( return to_global_ref_result(_result); } +// android.os.Build$Partition +jclass _c_Build_Partition = NULL; + +jmethodID _m_Build_Partition__getName = NULL; +FFI_PLUGIN_EXPORT +JniResult Build_Partition__getName(jobject self_) { + load_env(); + load_class_global_ref(&_c_Build_Partition, "android/os/Build$Partition"); + if (_c_Build_Partition == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Build_Partition, &_m_Build_Partition__getName, "getName", + "()Ljava/lang/String;"); + if (_m_Build_Partition__getName == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_Build_Partition__getName); + return to_global_ref_result(_result); +} + +jmethodID _m_Build_Partition__getFingerprint = NULL; +FFI_PLUGIN_EXPORT +JniResult Build_Partition__getFingerprint(jobject self_) { + load_env(); + load_class_global_ref(&_c_Build_Partition, "android/os/Build$Partition"); + if (_c_Build_Partition == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Build_Partition, &_m_Build_Partition__getFingerprint, + "getFingerprint", "()Ljava/lang/String;"); + if (_m_Build_Partition__getFingerprint == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_Build_Partition__getFingerprint); + return to_global_ref_result(_result); +} + +jmethodID _m_Build_Partition__getBuildTimeMillis = NULL; +FFI_PLUGIN_EXPORT +JniResult Build_Partition__getBuildTimeMillis(jobject self_) { + load_env(); + load_class_global_ref(&_c_Build_Partition, "android/os/Build$Partition"); + if (_c_Build_Partition == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Build_Partition, &_m_Build_Partition__getBuildTimeMillis, + "getBuildTimeMillis", "()J"); + if (_m_Build_Partition__getBuildTimeMillis == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int64_t _result = (*jniEnv)->CallLongMethod( + jniEnv, self_, _m_Build_Partition__getBuildTimeMillis); + return (JniResult){.value = {.j = _result}, .exception = check_exception()}; +} + +jmethodID _m_Build_Partition__equals1 = NULL; +FFI_PLUGIN_EXPORT +JniResult Build_Partition__equals1(jobject self_, jobject object) { + load_env(); + load_class_global_ref(&_c_Build_Partition, "android/os/Build$Partition"); + if (_c_Build_Partition == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Build_Partition, &_m_Build_Partition__equals1, "equals", + "(Ljava/lang/Object;)Z"); + if (_m_Build_Partition__equals1 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + uint8_t _result = (*jniEnv)->CallBooleanMethod( + jniEnv, self_, _m_Build_Partition__equals1, object); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +jmethodID _m_Build_Partition__hashCode1 = NULL; +FFI_PLUGIN_EXPORT +JniResult Build_Partition__hashCode1(jobject self_) { + load_env(); + load_class_global_ref(&_c_Build_Partition, "android/os/Build$Partition"); + if (_c_Build_Partition == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Build_Partition, &_m_Build_Partition__hashCode1, "hashCode", + "()I"); + if (_m_Build_Partition__hashCode1 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int32_t _result = + (*jniEnv)->CallIntMethod(jniEnv, self_, _m_Build_Partition__hashCode1); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +// android.os.Build$VERSION +jclass _c_Build_VERSION = NULL; + +jmethodID _m_Build_VERSION__ctor = NULL; +FFI_PLUGIN_EXPORT +JniResult Build_VERSION__ctor(jobject _parent) { + load_env(); + load_class_global_ref(&_c_Build_VERSION, "android/os/Build$VERSION"); + if (_c_Build_VERSION == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Build_VERSION, &_m_Build_VERSION__ctor, "", + "(Landroid/os/Build;)V"); + if (_m_Build_VERSION__ctor == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Build_VERSION, + _m_Build_VERSION__ctor, _parent); + return to_global_ref_result(_result); +} + +jfieldID _f_Build_VERSION__BASE_OS = NULL; +FFI_PLUGIN_EXPORT +JniResult get_Build_VERSION__BASE_OS() { + load_env(); + load_class_global_ref(&_c_Build_VERSION, "android/os/Build$VERSION"); + if (_c_Build_VERSION == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_field(_c_Build_VERSION, &_f_Build_VERSION__BASE_OS, "BASE_OS", + "Ljava/lang/String;"); + jobject _result = (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build_VERSION, + _f_Build_VERSION__BASE_OS); + return to_global_ref_result(_result); +} + +jfieldID _f_Build_VERSION__CODENAME = NULL; +FFI_PLUGIN_EXPORT +JniResult get_Build_VERSION__CODENAME() { + load_env(); + load_class_global_ref(&_c_Build_VERSION, "android/os/Build$VERSION"); + if (_c_Build_VERSION == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_field(_c_Build_VERSION, &_f_Build_VERSION__CODENAME, "CODENAME", + "Ljava/lang/String;"); + jobject _result = (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build_VERSION, + _f_Build_VERSION__CODENAME); + return to_global_ref_result(_result); +} + +jfieldID _f_Build_VERSION__INCREMENTAL = NULL; +FFI_PLUGIN_EXPORT +JniResult get_Build_VERSION__INCREMENTAL() { + load_env(); + load_class_global_ref(&_c_Build_VERSION, "android/os/Build$VERSION"); + if (_c_Build_VERSION == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_field(_c_Build_VERSION, &_f_Build_VERSION__INCREMENTAL, + "INCREMENTAL", "Ljava/lang/String;"); + jobject _result = (*jniEnv)->GetStaticObjectField( + jniEnv, _c_Build_VERSION, _f_Build_VERSION__INCREMENTAL); + return to_global_ref_result(_result); +} + +jfieldID _f_Build_VERSION__MEDIA_PERFORMANCE_CLASS = NULL; +FFI_PLUGIN_EXPORT +JniResult get_Build_VERSION__MEDIA_PERFORMANCE_CLASS() { + load_env(); + load_class_global_ref(&_c_Build_VERSION, "android/os/Build$VERSION"); + if (_c_Build_VERSION == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_field(_c_Build_VERSION, + &_f_Build_VERSION__MEDIA_PERFORMANCE_CLASS, + "MEDIA_PERFORMANCE_CLASS", "I"); + int32_t _result = (*jniEnv)->GetStaticIntField( + jniEnv, _c_Build_VERSION, _f_Build_VERSION__MEDIA_PERFORMANCE_CLASS); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +jfieldID _f_Build_VERSION__PREVIEW_SDK_INT = NULL; +FFI_PLUGIN_EXPORT +JniResult get_Build_VERSION__PREVIEW_SDK_INT() { + load_env(); + load_class_global_ref(&_c_Build_VERSION, "android/os/Build$VERSION"); + if (_c_Build_VERSION == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_field(_c_Build_VERSION, &_f_Build_VERSION__PREVIEW_SDK_INT, + "PREVIEW_SDK_INT", "I"); + int32_t _result = (*jniEnv)->GetStaticIntField( + jniEnv, _c_Build_VERSION, _f_Build_VERSION__PREVIEW_SDK_INT); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +jfieldID _f_Build_VERSION__RELEASE = NULL; +FFI_PLUGIN_EXPORT +JniResult get_Build_VERSION__RELEASE() { + load_env(); + load_class_global_ref(&_c_Build_VERSION, "android/os/Build$VERSION"); + if (_c_Build_VERSION == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_field(_c_Build_VERSION, &_f_Build_VERSION__RELEASE, "RELEASE", + "Ljava/lang/String;"); + jobject _result = (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build_VERSION, + _f_Build_VERSION__RELEASE); + return to_global_ref_result(_result); +} + +jfieldID _f_Build_VERSION__RELEASE_OR_CODENAME = NULL; +FFI_PLUGIN_EXPORT +JniResult get_Build_VERSION__RELEASE_OR_CODENAME() { + load_env(); + load_class_global_ref(&_c_Build_VERSION, "android/os/Build$VERSION"); + if (_c_Build_VERSION == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_field(_c_Build_VERSION, &_f_Build_VERSION__RELEASE_OR_CODENAME, + "RELEASE_OR_CODENAME", "Ljava/lang/String;"); + jobject _result = (*jniEnv)->GetStaticObjectField( + jniEnv, _c_Build_VERSION, _f_Build_VERSION__RELEASE_OR_CODENAME); + return to_global_ref_result(_result); +} + +jfieldID _f_Build_VERSION__RELEASE_OR_PREVIEW_DISPLAY = NULL; +FFI_PLUGIN_EXPORT +JniResult get_Build_VERSION__RELEASE_OR_PREVIEW_DISPLAY() { + load_env(); + load_class_global_ref(&_c_Build_VERSION, "android/os/Build$VERSION"); + if (_c_Build_VERSION == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_field(_c_Build_VERSION, + &_f_Build_VERSION__RELEASE_OR_PREVIEW_DISPLAY, + "RELEASE_OR_PREVIEW_DISPLAY", "Ljava/lang/String;"); + jobject _result = (*jniEnv)->GetStaticObjectField( + jniEnv, _c_Build_VERSION, _f_Build_VERSION__RELEASE_OR_PREVIEW_DISPLAY); + return to_global_ref_result(_result); +} + +jfieldID _f_Build_VERSION__SDK = NULL; +FFI_PLUGIN_EXPORT +JniResult get_Build_VERSION__SDK() { + load_env(); + load_class_global_ref(&_c_Build_VERSION, "android/os/Build$VERSION"); + if (_c_Build_VERSION == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_field(_c_Build_VERSION, &_f_Build_VERSION__SDK, "SDK", + "Ljava/lang/String;"); + jobject _result = (*jniEnv)->GetStaticObjectField(jniEnv, _c_Build_VERSION, + _f_Build_VERSION__SDK); + return to_global_ref_result(_result); +} + +jfieldID _f_Build_VERSION__SDK_INT = NULL; +FFI_PLUGIN_EXPORT +JniResult get_Build_VERSION__SDK_INT() { + load_env(); + load_class_global_ref(&_c_Build_VERSION, "android/os/Build$VERSION"); + if (_c_Build_VERSION == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_field(_c_Build_VERSION, &_f_Build_VERSION__SDK_INT, "SDK_INT", + "I"); + int32_t _result = (*jniEnv)->GetStaticIntField(jniEnv, _c_Build_VERSION, + _f_Build_VERSION__SDK_INT); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +jfieldID _f_Build_VERSION__SECURITY_PATCH = NULL; +FFI_PLUGIN_EXPORT +JniResult get_Build_VERSION__SECURITY_PATCH() { + load_env(); + load_class_global_ref(&_c_Build_VERSION, "android/os/Build$VERSION"); + if (_c_Build_VERSION == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_field(_c_Build_VERSION, &_f_Build_VERSION__SECURITY_PATCH, + "SECURITY_PATCH", "Ljava/lang/String;"); + jobject _result = (*jniEnv)->GetStaticObjectField( + jniEnv, _c_Build_VERSION, _f_Build_VERSION__SECURITY_PATCH); + return to_global_ref_result(_result); +} + +// android.os.Build$VERSION_CODES +jclass _c_Build_VERSION_CODES = NULL; + +jmethodID _m_Build_VERSION_CODES__ctor = NULL; +FFI_PLUGIN_EXPORT +JniResult Build_VERSION_CODES__ctor(jobject _parent) { + load_env(); + load_class_global_ref(&_c_Build_VERSION_CODES, + "android/os/Build$VERSION_CODES"); + if (_c_Build_VERSION_CODES == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Build_VERSION_CODES, &_m_Build_VERSION_CODES__ctor, "", + "(Landroid/os/Build;)V"); + if (_m_Build_VERSION_CODES__ctor == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Build_VERSION_CODES, + _m_Build_VERSION_CODES__ctor, _parent); + return to_global_ref_result(_result); +} + // android.os.Build jclass _c_Build = NULL; diff --git a/pkgs/jnigen/java/.gitignore b/pkgs/jnigen/java/.gitignore index fe41dfd15..5ccba1795 100644 --- a/pkgs/jnigen/java/.gitignore +++ b/pkgs/jnigen/java/.gitignore @@ -8,3 +8,5 @@ target/* .idea/jarRepositories.xml .idea/misc.xml .idea/runConfigurations.xml + +.classpath ## Used for experimenting with JShell REPL diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/Main.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/Main.java index 1eda46005..0077fd71e 100644 --- a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/Main.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/Main.java @@ -7,7 +7,10 @@ import com.github.dart_lang.jnigen.apisummarizer.disasm.AsmSummarizer; import com.github.dart_lang.jnigen.apisummarizer.doclet.SummarizerDoclet; import com.github.dart_lang.jnigen.apisummarizer.elements.ClassDecl; -import com.github.dart_lang.jnigen.apisummarizer.util.*; +import com.github.dart_lang.jnigen.apisummarizer.util.ClassFinder; +import com.github.dart_lang.jnigen.apisummarizer.util.InputStreamProvider; +import com.github.dart_lang.jnigen.apisummarizer.util.JsonWriter; +import com.github.dart_lang.jnigen.apisummarizer.util.StreamUtil; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; @@ -38,16 +41,12 @@ public static List runDocletWithClass( Class docletClass, List fileObjects, SummarizerOptions options) { - Log.setVerbose(options.verbose); var fileManager = javaDoc.getStandardFileManager(null, null, null); var cli = new ArrayList(); cli.add((options.useModules ? "--module-" : "--") + "source-path=" + options.sourcePath); if (options.classPath != null) { cli.add("--class-path=" + options.classPath); } - if (options.addDependencies) { - cli.add("--expand-requires=all"); - } cli.addAll(List.of("-encoding", "utf8")); if (options.toolArgs != null) { @@ -73,7 +72,6 @@ public static void main(String[] args) throws FileNotFoundException { } else { output = new FileOutputStream(options.outputFile); } - List sourcePaths = options.sourcePath != null ? Arrays.asList(options.sourcePath.split(File.pathSeparator)) diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/SummarizerOptions.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/SummarizerOptions.java index ca63a4531..8a3e5450c 100644 --- a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/SummarizerOptions.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/SummarizerOptions.java @@ -1,5 +1,6 @@ package com.github.dart_lang.jnigen.apisummarizer; +import java.util.Arrays; import org.apache.commons.cli.*; public class SummarizerOptions { @@ -9,7 +10,6 @@ public class SummarizerOptions { boolean useModules; Main.Backend backend; String modulesList; - boolean addDependencies; String toolArgs; boolean verbose; String outputFile; @@ -19,15 +19,13 @@ public class SummarizerOptions { public static SummarizerOptions fromCommandLine(CommandLine cmd) { var opts = new SummarizerOptions(); - opts.sourcePath = cmd.getOptionValue("sources", "."); + opts.sourcePath = cmd.getOptionValue("sources", null); var backendString = cmd.getOptionValue("backend", "auto"); opts.backend = Main.Backend.valueOf(backendString.toUpperCase()); opts.classPath = cmd.getOptionValue("classes", null); opts.useModules = cmd.hasOption("use-modules"); opts.modulesList = cmd.getOptionValue("module-names", null); - opts.addDependencies = cmd.hasOption("recursive"); opts.toolArgs = cmd.getOptionValue("doctool-args", null); - opts.verbose = cmd.hasOption("verbose"); opts.outputFile = cmd.getOptionValue("output-file", null); opts.args = cmd.getArgs(); if (opts.args.length == 0) { @@ -47,28 +45,16 @@ public static SummarizerOptions parseArgs(String[] args) { true, "backend to use for summary generation ('doclet', 'asm' or 'auto' (default))."); Option useModules = new Option("M", "use-modules", false, "use Java modules"); - Option recursive = new Option("r", "recursive", false, "include dependencies of classes"); Option moduleNames = new Option("m", "module-names", true, "comma separated list of module names"); Option doctoolArgs = new Option("D", "doctool-args", true, "arguments to pass to the documentation tool"); - Option verbose = new Option("v", "verbose", false, "enable verbose output"); Option outputFile = new Option("o", "output-file", true, "write JSON to file instead of stdout"); - for (Option opt : - new Option[] { - sources, - classes, - backend, - useModules, - recursive, - moduleNames, - doctoolArgs, - verbose, - outputFile, - }) { - options.addOption(opt); - } + Option[] allOptions = { + sources, classes, backend, useModules, moduleNames, doctoolArgs, outputFile + }; + Arrays.stream(allOptions).forEach(options::addOption); HelpFormatter help = new HelpFormatter(); diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmClassVisitor.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmClassVisitor.java index 50bf2f0db..6a536d321 100644 --- a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmClassVisitor.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmClassVisitor.java @@ -4,9 +4,6 @@ package com.github.dart_lang.jnigen.apisummarizer.disasm; -import static org.objectweb.asm.Opcodes.ACC_PROTECTED; -import static org.objectweb.asm.Opcodes.ACC_PUBLIC; - import com.github.dart_lang.jnigen.apisummarizer.elements.*; import com.github.dart_lang.jnigen.apisummarizer.util.SkipException; import com.github.dart_lang.jnigen.apisummarizer.util.StreamUtil; @@ -59,10 +56,6 @@ public void visit( super.visit(version, access, name, signature, superName, interfaces); } - private static boolean isPrivate(int access) { - return ((access & ACC_PUBLIC) == 0) && ((access & ACC_PROTECTED) == 0); - } - @Override public FieldVisitor visitField( int access, String name, String descriptor, String signature, Object value) { diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/doclet/SummarizerDoclet.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/doclet/SummarizerDoclet.java index b1664e5e7..abbc7cc65 100644 --- a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/doclet/SummarizerDoclet.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/doclet/SummarizerDoclet.java @@ -46,7 +46,7 @@ public static List getClasses() { @Override public boolean run(DocletEnvironment docletEnvironment) { - Log.timed("Initializing doclet"); + Log.info("Initializing doclet"); utils = AstEnv.fromEnvironment(docletEnvironment); SummarizingScanner scanner = new SummarizingScanner(); docletEnvironment.getSpecifiedElements().forEach(e -> scanner.scan(e, new SummaryCollector())); @@ -77,7 +77,7 @@ public Void scan(Element e, SummaryCollector collector) { @Override public Void visitPackage(PackageElement e, SummaryCollector collector) { - Log.verbose("Visiting package: %s", e.getQualifiedName()); + Log.info("Visiting package: %s", e.getQualifiedName()); collector.packages.push(new Package()); System.out.println("package: " + e.getQualifiedName()); var result = super.visitPackage(e, collector); @@ -91,7 +91,7 @@ public Void visitType(TypeElement e, SummaryCollector collector) { if (!collector.types.isEmpty()) { return null; } - Log.verbose("Visiting class: %s, %s", e.getQualifiedName(), collector.types); + Log.info("Visiting class: %s, %s", e.getQualifiedName(), collector.types); switch (e.getKind()) { case CLASS: case INTERFACE: @@ -102,11 +102,11 @@ public Void visitType(TypeElement e, SummaryCollector collector) { super.visitType(e, collector); types.add(collector.types.pop()); } catch (SkipException skip) { - Log.always("Skip type: %s", e.getQualifiedName()); + Log.info("Skip type: %s", e.getQualifiedName()); } break; case ANNOTATION_TYPE: - Log.always("Skip annotation type: %s", e.getQualifiedName()); + Log.info("Skip annotation type: %s", e.getQualifiedName()); break; } return null; @@ -149,7 +149,7 @@ public Void visitExecutable(ExecutableElement element, SummaryCollector collecto collector.method = null; cls.methods.add(method); } catch (SkipException skip) { - Log.always("Skip method: %s", element.getSimpleName()); + Log.info("Skip method: %s", element.getSimpleName()); } break; case STATIC_INIT: diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/ClassFinder.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/ClassFinder.java index 293802248..23c1ca534 100644 --- a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/ClassFinder.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/ClassFinder.java @@ -1,7 +1,11 @@ package com.github.dart_lang.jnigen.apisummarizer.util; +import static com.github.dart_lang.jnigen.apisummarizer.util.ExceptionUtil.wrapCheckedException; + import java.io.File; -import java.io.FileFilter; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.*; import java.util.function.BiFunction; import java.util.function.Function; @@ -13,84 +17,146 @@ import javax.tools.StandardJavaFileManager; public class ClassFinder { + // If class is A$B$C, simpleName can be B$C or A$B$C. Doesn't matter much, because + // A can't be anonymous class. + private static boolean isNonAnonymousNestedClassName(String simpleName) { + String[] nestedParts = simpleName.split("\\$"); + return Arrays.stream(nestedParts).allMatch(part -> part.matches("[a-zA-Z_][a-zA-Z0-9_]*")); + } + + public static boolean isNestedClassOf(String pathString, String fqnWithSlashes, String suffix) { + var fqnWithSlashesDollarSign = fqnWithSlashes + "$"; + if (!pathString.startsWith(fqnWithSlashesDollarSign) || !pathString.endsWith(suffix)) { + return false; + } + String nested = + pathString.substring( + fqnWithSlashesDollarSign.length(), pathString.length() - suffix.length()); + return isNonAnonymousNestedClassName(nested); + } + + private static boolean isNonAnonymousClassFullPath(String path) { + String[] pathParts = path.split("[/\\\\]"); + String simpleNameWithExt = pathParts[pathParts.length - 1]; + int extIndex = simpleNameWithExt.indexOf('.'); + assert extIndex != -1 : "Should've passed full path with extension to this method"; + String simpleName = simpleNameWithExt.substring(0, extIndex); + return isNonAnonymousNestedClassName(simpleName); + } + + // Finds [fqn] and its children with [suffix] in [entries]. + public static Optional> findClassAndChildren( + TreeSet entries, String fqn, String sep, String suffix) { + String fqnWithSlashes = fqn.replace(".", sep); + String fqnWithSlashesSuffix = fqnWithSlashes + suffix; + String fqnWithSlashesSlash = fqnWithSlashes + sep; + String fqnWithSlashesDollarSign = fqnWithSlashes + "$"; + if (entries.contains(fqnWithSlashesSuffix)) { + List classes = new ArrayList<>(); + // Add nested classes first, because they're alphabetically first + entries.tailSet(fqnWithSlashesDollarSign).stream() + .takeWhile(entry -> entry.startsWith(fqnWithSlashesDollarSign)) + // Note: filter comes after takeWhile, because it can filter out additional elements + // eg: Class$1 - but there may be valid nested classes after Class$1. + .filter(entry -> isNestedClassOf(entry, fqnWithSlashes, suffix)) + .forEach(classes::add); + classes.add(fqnWithSlashesSuffix); + return Optional.of(classes); + } + + // consider fqnWithSlashes as a directory + List children = + entries.tailSet(fqnWithSlashesSlash).stream() + // takeWhile instead of filter - the difference is O(log n + k) instead of O(n) + // so always use takeWhile when doing a treeSet subset stream. + .takeWhile(entry -> entry.startsWith(fqnWithSlashesSlash)) + .filter(entry -> entry.endsWith(suffix)) + .filter(ClassFinder::isNonAnonymousClassFullPath) + .collect(Collectors.toList()); + return children.isEmpty() ? Optional.empty() : Optional.of(children); + } + public static void findFilesInPath( - String searchPath, + String searchLocation, String suffix, Map> classes, - Function, List> mapper) { + Function, List> mapper) { + Path searchPath = Path.of(searchLocation); + + TreeSet filePaths; + try (var walk = Files.walk(searchPath)) { + filePaths = + walk.map(searchPath::relativize) + .map(Path::toString) + .collect(Collectors.toCollection(TreeSet::new)); + } catch (IOException e) { + throw new RuntimeException(e); + } - for (var binaryName : classes.keySet()) { - if (classes.get(binaryName) != null) { + for (var className : classes.keySet()) { + if (classes.get(className) != null) { // Already found by other method of searching continue; } - var s = binaryName.replace(".", File.separator); - var f = new File(searchPath, s + suffix); - if (f.exists() && f.isFile()) { - classes.put(binaryName, mapper.apply(List.of(f))); - } - - var d = new File(searchPath, s); - if (d.exists() && d.isDirectory()) { - var files = recursiveListFiles(d, file -> file.getName().endsWith(suffix)); - classes.put(binaryName, mapper.apply(files)); + var resultPaths = findClassAndChildren(filePaths, className, File.separator, suffix); + if (resultPaths.isPresent()) { + // [filePaths] and [resultPaths] are relativized to searchPath. + // perform opposite operation (resolve) to get full paths. + var fullPaths = + resultPaths.get().stream().map(searchPath::resolve).collect(Collectors.toList()); + classes.put(className, mapper.apply(fullPaths)); } } } - public static void findFilesInJar( + public static boolean findFilesInJar( Map> classes, JarFile jar, String suffix, BiFunction, List> mapper) { - var entries = + + // It appears JAR file entries are always separated by "/" + var jarSeparator = "/"; + var entryNames = jar.stream().map(JarEntry::getName).collect(Collectors.toCollection(TreeSet::new)); - for (var binaryName : classes.keySet()) { - if (classes.get(binaryName) != null) { + boolean foundClassesInThisJar = false; + for (var fqn : classes.keySet()) { + if (classes.get(fqn) != null) { // already found continue; } - var relativePath = binaryName.replace('.', '/'); - - var filePath = relativePath + suffix; - if (entries.contains(filePath)) { - var found = List.of(jar.getEntry(filePath)); - classes.put(binaryName, mapper.apply(jar, found)); - } - - // Obtain set of all strings prefixed with relativePath + '/' - var dirPath = relativePath + '/'; - var children = - entries.tailSet(dirPath).stream() - .takeWhile(e -> e.startsWith(dirPath)) - .filter(e -> e.endsWith(suffix)) - .map(jar::getEntry) - .collect(Collectors.toList()); - if (!children.isEmpty()) { - var mapped = mapper.apply(jar, children); - classes.put(binaryName, mapped); + var resultPaths = findClassAndChildren(entryNames, fqn, jarSeparator, suffix); + if (resultPaths.isPresent()) { + var jarEntries = resultPaths.get().stream().map(jar::getEntry).collect(Collectors.toList()); + classes.put(fqn, mapper.apply(jar, jarEntries)); + foundClassesInThisJar = true; } } + return foundClassesInThisJar; } public static void find( Map> classes, List searchPaths, String suffix, - Function, List> fileMapper, + Function, List> fileMapper, BiFunction, List> entryMapper) { for (var searchPath : searchPaths) { File searchFile = new File(searchPath); if (searchFile.isDirectory()) { findFilesInPath(searchPath, suffix, classes, fileMapper); } else if (searchFile.isFile() && searchPath.endsWith(".jar")) { - var jarFile = ExceptionUtil.wrapCheckedException(JarFile::new, searchPath); - findFilesInJar(classes, jarFile, suffix, entryMapper); + var jarFile = wrapCheckedException(JarFile::new, searchPath); + var useful = findFilesInJar(classes, jarFile, suffix, entryMapper); + if (!useful) { + wrapCheckedException(jarFile::close); + } } } } private static List getJavaFileObjectsFromFiles( - List files, StandardJavaFileManager fm) { + List paths, StandardJavaFileManager fm) { var result = new ArrayList(); + var files = StreamUtil.map(paths, Path::toFile); fm.getJavaFileObjectsFromFiles(files).forEach(result::add); return result; } @@ -100,8 +166,8 @@ private static List getJavaFileObjectsFromJar( return StreamUtil.map(entries, (entry) -> new JarEntryFileObject(jarFile, entry)); } - private static List getInputStreamProvidersFromFiles(List files) { - return StreamUtil.map(files, FileInputStreamProvider::new); + private static List getInputStreamProvidersFromFiles(List files) { + return StreamUtil.map(files, (path) -> new FileInputStreamProvider(path.toFile())); } private static List getInputStreamProvidersFromJar( @@ -130,37 +196,4 @@ public static void findJavaClasses( ClassFinder::getInputStreamProvidersFromFiles, ClassFinder::getInputStreamProvidersFromJar); } - - /** - * Lists all files under given directory, which satisfy the condition of filter.
    - * The order of listing will be deterministic. - */ - public static List recursiveListFiles(File file, FileFilter filter) { - if (!file.exists()) { - throw new RuntimeException("File not found: " + file.getPath()); - } - - if (!file.isDirectory()) { - return List.of(file); - } - - // List files using a breadth-first traversal. - var files = new ArrayList(); - var queue = new ArrayDeque(); - queue.add(file); - while (!queue.isEmpty()) { - var dir = queue.poll(); - var list = dir.listFiles(entry -> entry.isDirectory() || filter.accept(entry)); - if (list == null) throw new IllegalArgumentException("File.listFiles returned null!"); - Arrays.sort(list); - for (var path : list) { - if (path.isDirectory()) { - queue.add(path); - } else { - files.add(path); - } - } - } - return files; - } } diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/ExceptionUtil.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/ExceptionUtil.java index 3ed92a523..6b4c8bd15 100644 --- a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/ExceptionUtil.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/ExceptionUtil.java @@ -2,19 +2,32 @@ public class ExceptionUtil { @FunctionalInterface - public interface FunctionThrowingException { + public interface CheckedFunction { R function(T value) throws Exception; } + @FunctionalInterface + public interface CheckedRunnable { + void run() throws Exception; + } + /** * Wraps a function throwing a checked exception and throws all checked exceptions as runtime * exceptions. */ - public static R wrapCheckedException(FunctionThrowingException function, T value) { + public static R wrapCheckedException(CheckedFunction function, T value) { try { return function.function(value); } catch (Exception e) { throw new RuntimeException(e); } } + + public static void wrapCheckedException(CheckedRunnable runnable) { + try { + runnable.run(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } } diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/JsonWriter.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/JsonWriter.java index 873a6be96..112e241f7 100644 --- a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/JsonWriter.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/JsonWriter.java @@ -11,7 +11,7 @@ public class JsonWriter { public static void writeJSON(List classes, OutputStream output) { var mapper = new ObjectMapper(); - Log.timed("Writing JSON"); + Log.info("Writing JSON for %d classes", classes.size()); mapper.enable(SerializationFeature.INDENT_OUTPUT); mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); try { @@ -19,6 +19,6 @@ public static void writeJSON(List classes, OutputStream output) { } catch (IOException e) { e.printStackTrace(); } - Log.timed("Finished"); + Log.info("Finished"); } } diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/Log.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/Log.java index b2b2d78b6..dfb48e18c 100644 --- a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/Log.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/util/Log.java @@ -4,30 +4,22 @@ package com.github.dart_lang.jnigen.apisummarizer.util; -public class Log { - private static long lastPrinted = System.currentTimeMillis(); - - public static void setVerbose(boolean verbose) { - Log.verboseLogs = verbose; - } +import java.util.logging.Level; +import java.util.logging.Logger; - private static boolean verboseLogs = false; +public class Log { + private static final Logger logger = Logger.getLogger("ApiSummarizer"); - public static void verbose(String format, Object... args) { - if (!verboseLogs) { - return; - } - System.err.printf(format + "\n", args); + private static void log(Level level, String format, Object... args) { + String formatted = String.format(format, args); + logger.log(level, formatted); } - public static void timed(String format, Object... args) { - long now = System.currentTimeMillis(); - System.err.printf("[%6d ms] ", now - lastPrinted); - lastPrinted = now; - System.err.printf(format + "\n", args); + public static void info(String format, Object... args) { + log(Level.INFO, format, args); } - public static void always(String format, Object... args) { - System.err.printf(format + "\n", args); + public static void warning(String format, Object... args) { + log(Level.WARNING, format, args); } } diff --git a/pkgs/jnigen/java/src/test/java/com/github/dart_lang/jnigen/apisummarizer/ClassFinderTest.java b/pkgs/jnigen/java/src/test/java/com/github/dart_lang/jnigen/apisummarizer/ClassFinderTest.java new file mode 100644 index 000000000..4209e3a2e --- /dev/null +++ b/pkgs/jnigen/java/src/test/java/com/github/dart_lang/jnigen/apisummarizer/ClassFinderTest.java @@ -0,0 +1,95 @@ +package com.github.dart_lang.jnigen.apisummarizer; + +import static com.github.dart_lang.jnigen.apisummarizer.util.ClassFinder.findClassAndChildren; +import static com.github.dart_lang.jnigen.apisummarizer.util.ClassFinder.isNestedClassOf; +import static org.junit.Assert.*; + +import java.util.*; +import java.util.stream.Collectors; +import org.junit.Test; + +public class ClassFinderTest { + @Test + public void testNestedClassCheck() { + assertTrue( + "Single nested class", + isNestedClassOf("com/abc/Class$Nested.class", "com/abc/Class", ".class")); + assertTrue( + "Nested twice", + isNestedClassOf("com/abc/Class$Nested$Twice.class", "com/abc/Class", ".class")); + assertTrue( + "Single nested class - backslash separator", + isNestedClassOf("com\\abc\\Class$Nested.class", "com\\abc\\Class", ".class")); + assertFalse( + "Anon inner class", isNestedClassOf("com/abc/Class$1.class", "com/abc/Class", ".class")); + assertFalse( + "Anon inner class inside nested class", + isNestedClassOf("com/abc/Class$Nested$1.class", "com/abc/Class", ".class")); + assertFalse( + "Different class name", + isNestedClassOf("com/abc/AClass$Nested.class", "com/abc/Class", ".class")); + } + + private Optional> pathListOf(String sep, String... paths) { + List pathList = + Arrays.stream(paths).map(path -> path.replace("/", sep)).collect(Collectors.toList()); + return Optional.of(pathList); + } + + @Test + public void testFindChildren() { + TreeSet entriesWithSlash = + new TreeSet<>( + List.of( + "random/os/App.class", + "random/os/App$1.class", + "random/os/App$1$3.class", + "random/os/Process.class", + "random/os/Process$Fork.class", + "random/os/Process$Fork$1.class", + "random/os/Process$Fork$A$B$C$2.class", + "random/widget/Dialog.class", + "random/widget/Dialog$Button.class", + "random/widget/Dialog$Button$2.class", + "random/widget/Dialog$Button$Color.class", + "random/widget/Dialogue$Button.class", + "random/time/Clock.class", + "random/time/Clock$1.class", + "random/time/Calendar.class", + "random/time/Calendar$Month$1.class", + "random/time/Calendar$Month.class")); + TreeSet entriesWithBackslash = + entriesWithSlash.stream() + .map(x -> x.replace('/', '\\')) + .collect(Collectors.toCollection(TreeSet::new)); + Map> bySeparater = + Map.of("/", entriesWithSlash, "\\", entriesWithBackslash); + + for (var sep : bySeparater.keySet()) { + var entries = bySeparater.get(sep); + assertEquals( + pathListOf(sep, "random/os/Process$Fork.class", "random/os/Process.class"), + findClassAndChildren(entries, "random.os.Process", sep, ".class")); + assertEquals( + pathListOf( + sep, + "random/time/Calendar$Month.class", + "random/time/Calendar.class", + "random/time/Clock.class"), + findClassAndChildren(entries, "random.time", sep, ".class")); + assertEquals( + pathListOf( + sep, + "random/widget/Dialog$Button$Color.class", + "random/widget/Dialog$Button.class", + "random/widget/Dialog.class"), + findClassAndChildren(entries, "random.widget.Dialog", sep, ".class")); + assertEquals( + pathListOf(sep, "random/os/App.class"), + findClassAndChildren(entries, "random.os.App", sep, ".class")); + assertEquals( + pathListOf(sep, "random/os/App.class"), + findClassAndChildren(entries, "random.os.App", sep, ".class")); + } + } +} diff --git a/pkgs/jnigen/java/src/test/java/com/github/dart_lang/jnigen/apisummarizer/JSONComparisonTest.java b/pkgs/jnigen/java/src/test/java/com/github/dart_lang/jnigen/apisummarizer/JSONComparisonTest.java index 4d15ad2e5..b02ee15e5 100644 --- a/pkgs/jnigen/java/src/test/java/com/github/dart_lang/jnigen/apisummarizer/JSONComparisonTest.java +++ b/pkgs/jnigen/java/src/test/java/com/github/dart_lang/jnigen/apisummarizer/JSONComparisonTest.java @@ -1,5 +1,6 @@ package com.github.dart_lang.jnigen.apisummarizer; +import com.github.dart_lang.jnigen.apisummarizer.util.Log; import java.io.File; import java.io.IOException; import org.junit.Assert; @@ -31,11 +32,22 @@ private int gitDiff(String a, String b) throws IOException, InterruptedException @Test public void testExampleSummary() throws IOException, InterruptedException { var tempFile = File.createTempFile("summarizer_test", ".json"); + Log.info("Temporary file: %s", tempFile.getPath()); Main.main( new String[] { "-s", "src/test/resources", "com.example.Example", "-o", tempFile.getPath(), }); int comparison = gitDiff(exampleClassJsonOutput, tempFile); + if (comparison != 0) { + Log.warning("New output (%s) is different than reference output.", tempFile.getPath()); + } + + // Fail test if git diff exited with 1 Assert.assertEquals(0, comparison); + + var deleted = tempFile.delete(); + if (!deleted) { + Log.warning("Cannot delete temp file %s", tempFile.getPath()); + } } } diff --git a/pkgs/jnigen/java/src/test/resources/exampleClassSummary.json b/pkgs/jnigen/java/src/test/resources/exampleClassSummary.json index 90a08e418..208e7ae13 100644 --- a/pkgs/jnigen/java/src/test/resources/exampleClassSummary.json +++ b/pkgs/jnigen/java/src/test/resources/exampleClassSummary.json @@ -1,9 +1,7 @@ [ { "declKind" : "CLASS", "modifiers" : [ "public" ], - "simpleName" : "Example", "binaryName" : "com.example.Example", - "packageName" : "com.example", "methods" : [ { "modifiers" : [ "public" ], "name" : "", @@ -140,10 +138,8 @@ }, { "declKind" : "CLASS", "modifiers" : [ "static", "public" ], - "simpleName" : "Aux", "binaryName" : "com.example.Example$Aux", "parentName" : "com.example.Example", - "packageName" : "com.example", "methods" : [ { "modifiers" : [ "public" ], "name" : "", diff --git a/pkgs/jnigen/lib/src/config/config_types.dart b/pkgs/jnigen/lib/src/config/config_types.dart index f737b8111..c1d166bff 100644 --- a/pkgs/jnigen/lib/src/config/config_types.dart +++ b/pkgs/jnigen/lib/src/config/config_types.dart @@ -268,6 +268,29 @@ class BindingExclusions { ClassFilter? classes; } +bool _isCapitalized(String s) { + final firstLetter = s.substring(0, 1); + return firstLetter == firstLetter.toUpperCase(); +} + +void _validateClassName(String className) { + final parts = className.split('.'); + assert(parts.isNotEmpty); + const nestedClassesInfo = + "Nested classes cannot be specified separately. Specifying the " + "parent class will pull the nested classes."; + if (parts.length > 1 && _isCapitalized(parts[parts.length - 2])) { + // Try to detect possible nested classes specified using dot notation eg: + // `com.package.Class.NestedClass` and emit a warning. + log.warning("It appears a nested class $className is specified in the " + "config. $nestedClassesInfo"); + } + if (className.contains('\$')) { + throw ConfigException( + "Nested class $className not allowed. $nestedClassesInfo"); + } +} + /// Configuration for jnigen binding generation. class Config { Config({ @@ -283,7 +306,11 @@ class Config { this.logLevel = Level.INFO, this.dumpJsonTo, this.imports, - }); + }) { + for (final className in classes) { + _validateClassName(className); + } + } /// Output configuration for generated bindings OutputConfig outputConfig; diff --git a/pkgs/jnigen/lib/src/logging/logging.dart b/pkgs/jnigen/lib/src/logging/logging.dart index 67c605eee..71db21791 100644 --- a/pkgs/jnigen/lib/src/logging/logging.dart +++ b/pkgs/jnigen/lib/src/logging/logging.dart @@ -18,10 +18,69 @@ String _colorize(String message, String colorCode) { return message; } +/// Format [DateTime] for use in filename +String _formatTime(DateTime now) { + return '${now.year}-${now.month}-${now.day}-' + '${now.hour}.${now.minute}.${now.second}'; +} + +// We need to respect logging level for console but log everything to file. +// Hierarchical logging is convoluted. I'm just keeping track of log level. +var _logLevel = Level.INFO; + +final _logDirUri = Directory.current.uri.resolve(".dart_tool/jnigen/logs/"); + +final _logDir = () { + final dir = Directory.fromUri(_logDirUri); + dir.createSync(recursive: true); + return dir; +}(); + +Uri _getDefaultLogFileUri() => + _logDir.uri.resolve("jnigen-${_formatTime(DateTime.now())}.log"); + +IOSink? _logStream; + +/// Enable saving the logs to a file. +/// +/// This is only meant to be called from an application entry point such as +/// `main`. +void enableLoggingToFile() { + _deleteOldLogFiles(); + if (_logStream != null) { + throw StateError('Log file is already set'); + } + _logStream = File.fromUri(_getDefaultLogFileUri()).openWrite(); +} + +// Maximum number of log files to keep. +const _maxLogFiles = 5; + +/// Delete log files except most recent [_maxLogFiles] files. +void _deleteOldLogFiles() { + final logFiles = _logDir.listSync().map((f) => File(f.path)).toList(); + // sort in descending order of last modified time. + logFiles + .sort((f1, f2) => f2.lastModifiedSync().compareTo(f1.lastModifiedSync())); + final toDelete = logFiles.length < _maxLogFiles + ? const [] + : logFiles.sublist(_maxLogFiles - 1); + for (final oldLogFile in toDelete) { + oldLogFile.deleteSync(); + } +} + Logger log = () { + // initialize the logger. final jnigenLogger = Logger('jnigen'); - Logger.root.level = Level.INFO; + Logger.root.level = Level.ALL; Logger.root.onRecord.listen((r) { + // Write to file regardless of level. + _logStream?.writeln('${r.level} ${r.time}: ${r.message}'); + // write to console only if level is above configured level. + if (r.level < _logLevel) { + return; + } var message = '(${r.loggerName}) ${r.level.name}: ${r.message}'; if ((r.level == Level.SHOUT || r.level == Level.SEVERE)) { message = _colorize(message, _ansiRed); @@ -35,10 +94,8 @@ Logger log = () { /// Set logging level to [level]. void setLoggingLevel(Level level) { - /// This initializes `log` as a side effect, so that level setting we apply - /// is always the last one applied. log.fine('Set log level: $level'); - Logger.root.level = level; + _logLevel = level; } /// Prints [message] without logging information. @@ -55,3 +112,15 @@ extension FatalErrors on Logger { return exit(exitCode); } } + +extension WriteToFile on Logger { + void writeToFile(Object? data) { + _logStream?.writeln(data); + } + + void writeSectionToFile(String? sectionName, Object? data) { + _logStream?.writeln("==== Begin $sectionName ===="); + _logStream?.writeln(data); + _logStream?.writeln("==== End $sectionName ===="); + } +} diff --git a/pkgs/jnigen/lib/src/summary/summary.dart b/pkgs/jnigen/lib/src/summary/summary.dart index 31473a631..09c13f5c8 100644 --- a/pkgs/jnigen/lib/src/summary/summary.dart +++ b/pkgs/jnigen/lib/src/summary/summary.dart @@ -187,6 +187,8 @@ Future getSummary(Config config) async { stderrBuffer.toString(), 'Cannot generate summary: $e', ); + } finally { + log.writeSectionToFile("summarizer logs", stderrBuffer.toString()); } if (json == null) { throw SummaryParseException('Expected JSON element from summarizer.'); diff --git a/pkgs/jnigen/lib/src/tools/android_sdk_tools.dart b/pkgs/jnigen/lib/src/tools/android_sdk_tools.dart index 466863c3e..3de5575f0 100644 --- a/pkgs/jnigen/lib/src/tools/android_sdk_tools.dart +++ b/pkgs/jnigen/lib/src/tools/android_sdk_tools.dart @@ -209,6 +209,9 @@ task $_gradleGetSourcesTaskName(type: Copy) { 'yet cached. Please run `flutter build apk`$inAndroidProject and try ' 'again\n'); } + // Record both stdout and stderr of gradle. + log.writeSectionToFile("Gradle logs ($stubName)", procRes.stderr); + log.writeSectionToFile("Gradle output ($stubName)", procRes.stdout); final output = procRes.stdout as String; if (output.isEmpty) { printError(procRes.stderr); diff --git a/pkgs/jnigen/pubspec.yaml b/pkgs/jnigen/pubspec.yaml index 75be98a73..ee7043086 100644 --- a/pkgs/jnigen/pubspec.yaml +++ b/pkgs/jnigen/pubspec.yaml @@ -3,7 +3,7 @@ # BSD-style license that can be found in the LICENSE file. name: jnigen -version: 0.6.0-dev.0 +version: 0.6.0-dev.1 description: Experimental generator for FFI+JNI bindings. repository: https://github.com/dart-lang/jnigen/tree/main/jnigen diff --git a/pkgs/jnigen/test/config_test.dart b/pkgs/jnigen/test/config_test.dart index 8538ac1c1..4b6617b35 100644 --- a/pkgs/jnigen/test/config_test.dart +++ b/pkgs/jnigen/test/config_test.dart @@ -132,5 +132,9 @@ void main() async { name: 'Invalid log level', overrides: ['-Dlog_level=inf'], ); + testForErrorChecking( + name: 'Nested class specified', + overrides: ['-Dclasses=com.android.Clock\$Clock'], + ); }); } diff --git a/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/simple_package.c b/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/simple_package.c index 4a170e764..6c0f3e245 100644 --- a/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/simple_package.c +++ b/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/simple_package.c @@ -607,6 +607,24 @@ JniResult Example_Nested__ctor(uint8_t value) { return to_global_ref_result(_result); } +jmethodID _m_Example_Nested__usesAnonymousInnerClass = NULL; +FFI_PLUGIN_EXPORT +JniResult Example_Nested__usesAnonymousInnerClass(jobject self_) { + load_env(); + load_class_global_ref( + &_c_Example_Nested, + "com/github/dart_lang/jnigen/simple_package/Example$Nested"); + if (_c_Example_Nested == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example_Nested, &_m_Example_Nested__usesAnonymousInnerClass, + "usesAnonymousInnerClass", "()V"); + if (_m_Example_Nested__usesAnonymousInnerClass == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod(jniEnv, self_, + _m_Example_Nested__usesAnonymousInnerClass); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + jmethodID _m_Example_Nested__getValue = NULL; FFI_PLUGIN_EXPORT JniResult Example_Nested__getValue(jobject self_) { @@ -642,6 +660,59 @@ JniResult Example_Nested__setValue(jobject self_, uint8_t value) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } +// com.github.dart_lang.jnigen.simple_package.Example$Nested$NestedTwice +jclass _c_Example_Nested_NestedTwice = NULL; + +jmethodID _m_Example_Nested_NestedTwice__ctor = NULL; +FFI_PLUGIN_EXPORT +JniResult Example_Nested_NestedTwice__ctor() { + load_env(); + load_class_global_ref( + &_c_Example_Nested_NestedTwice, + "com/github/dart_lang/jnigen/simple_package/Example$Nested$NestedTwice"); + if (_c_Example_Nested_NestedTwice == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example_Nested_NestedTwice, + &_m_Example_Nested_NestedTwice__ctor, "", "()V"); + if (_m_Example_Nested_NestedTwice__ctor == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Example_Nested_NestedTwice, + _m_Example_Nested_NestedTwice__ctor); + return to_global_ref_result(_result); +} + +jfieldID _f_Example_Nested_NestedTwice__ZERO = NULL; +FFI_PLUGIN_EXPORT +JniResult get_Example_Nested_NestedTwice__ZERO() { + load_env(); + load_class_global_ref( + &_c_Example_Nested_NestedTwice, + "com/github/dart_lang/jnigen/simple_package/Example$Nested$NestedTwice"); + if (_c_Example_Nested_NestedTwice == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_field(_c_Example_Nested_NestedTwice, + &_f_Example_Nested_NestedTwice__ZERO, "ZERO", "I"); + int32_t _result = + (*jniEnv)->GetStaticIntField(jniEnv, _c_Example_Nested_NestedTwice, + _f_Example_Nested_NestedTwice__ZERO); + return (JniResult){.value = {.i = _result}, .exception = check_exception()}; +} + +FFI_PLUGIN_EXPORT +JniResult set_Example_Nested_NestedTwice__ZERO(int32_t value) { + load_env(); + load_class_global_ref( + &_c_Example_Nested_NestedTwice, + "com/github/dart_lang/jnigen/simple_package/Example$Nested$NestedTwice"); + if (_c_Example_Nested_NestedTwice == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_field(_c_Example_Nested_NestedTwice, + &_f_Example_Nested_NestedTwice__ZERO, "ZERO", "I"); + (*jniEnv)->SetStaticIntField(jniEnv, _c_Example_Nested_NestedTwice, + _f_Example_Nested_NestedTwice__ZERO, value); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + // com.github.dart_lang.jnigen.simple_package.Exceptions jclass _c_Exceptions = NULL; diff --git a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart index 4e16f1e89..d0ad47c7d 100644 --- a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart @@ -559,6 +559,17 @@ class Example_Nested extends jni.JObject { return Example_Nested.fromRef(_ctor(value ? 1 : 0).object); } + static final _usesAnonymousInnerClass = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>( + "Example_Nested__usesAnonymousInnerClass") + .asFunction)>(); + + /// from: public void usesAnonymousInnerClass() + void usesAnonymousInnerClass() { + return _usesAnonymousInnerClass(reference).check(); + } + static final _getValue = jniLookup< ffi.NativeFunction< jni.JniResult Function( @@ -610,6 +621,72 @@ class $Example_NestedType extends jni.JObjType { } } +/// from: com.github.dart_lang.jnigen.simple_package.Example$Nested$NestedTwice +class Example_Nested_NestedTwice extends jni.JObject { + @override + late final jni.JObjType $type = type; + + Example_Nested_NestedTwice.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = $Example_Nested_NestedTwiceType(); + static final _get_ZERO = + jniLookup>( + "get_Example_Nested_NestedTwice__ZERO") + .asFunction(); + + static final _set_ZERO = + jniLookup>( + "set_Example_Nested_NestedTwice__ZERO") + .asFunction(); + + /// from: static public int ZERO + static int get ZERO => _get_ZERO().integer; + + /// from: static public int ZERO + static set ZERO(int value) => _set_ZERO(value).check(); + + static final _ctor = jniLookup>( + "Example_Nested_NestedTwice__ctor") + .asFunction(); + + /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. + factory Example_Nested_NestedTwice() { + return Example_Nested_NestedTwice.fromRef(_ctor().object); + } +} + +class $Example_Nested_NestedTwiceType + extends jni.JObjType { + const $Example_Nested_NestedTwiceType(); + + @override + String get signature => + r"Lcom/github/dart_lang/jnigen/simple_package/Example$Nested$NestedTwice;"; + + @override + Example_Nested_NestedTwice fromRef(jni.JObjectPtr ref) => + Example_Nested_NestedTwice.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($Example_Nested_NestedTwiceType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == ($Example_Nested_NestedTwiceType) && + other is $Example_Nested_NestedTwiceType; + } +} + /// from: com.github.dart_lang.jnigen.simple_package.Exceptions class Exceptions extends jni.JObject { @override diff --git a/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart index fb92e1dd5..3394d3d92 100644 --- a/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart @@ -527,6 +527,15 @@ class Example_Nested extends jni.JObject { .newObjectWithArgs(_class.reference, _id_ctor, [value ? 1 : 0]).object); } + static final _id_usesAnonymousInnerClass = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"usesAnonymousInnerClass", r"()V"); + + /// from: public void usesAnonymousInnerClass() + void usesAnonymousInnerClass() { + return jni.Jni.accessors.callMethodWithArgs(reference, + _id_usesAnonymousInnerClass, jni.JniCallType.voidType, []).check(); + } + static final _id_getValue = jni.Jni.accessors.getMethodIDOf(_class.reference, r"getValue", r"()Z"); @@ -574,6 +583,74 @@ class $Example_NestedType extends jni.JObjType { } } +/// from: com.github.dart_lang.jnigen.simple_package.Example$Nested$NestedTwice +class Example_Nested_NestedTwice extends jni.JObject { + @override + late final jni.JObjType $type = type; + + Example_Nested_NestedTwice.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + static final _class = jni.Jni.findJClass( + 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 type = $Example_Nested_NestedTwiceType(); + static final _id_ZERO = jni.Jni.accessors.getStaticFieldIDOf( + _class.reference, + r"ZERO", + r"I", + ); + + /// from: static public int ZERO + static int get ZERO => jni.Jni.accessors + .getStaticField(_class.reference, _id_ZERO, jni.JniCallType.intType) + .integer; + + /// from: static public int ZERO + static set ZERO(int value) => + jni.Jni.env.SetStaticIntField(_class.reference, _id_ZERO, value); + + static final _id_ctor = + jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); + + /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. + factory Example_Nested_NestedTwice() { + return Example_Nested_NestedTwice.fromRef(jni.Jni.accessors + .newObjectWithArgs(_class.reference, _id_ctor, []).object); + } +} + +class $Example_Nested_NestedTwiceType + extends jni.JObjType { + const $Example_Nested_NestedTwiceType(); + + @override + String get signature => + r"Lcom/github/dart_lang/jnigen/simple_package/Example$Nested$NestedTwice;"; + + @override + Example_Nested_NestedTwice fromRef(jni.JObjectPtr ref) => + Example_Nested_NestedTwice.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($Example_Nested_NestedTwiceType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == ($Example_Nested_NestedTwiceType) && + other is $Example_Nested_NestedTwiceType; + } +} + /// from: com.github.dart_lang.jnigen.simple_package.Exceptions class Exceptions extends jni.JObject { @override diff --git a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/simple_package/Example.java b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/simple_package/Example.java index edb274894..47fab9d24 100644 --- a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/simple_package/Example.java +++ b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/simple_package/Example.java @@ -176,6 +176,17 @@ public Nested(boolean value) { this.value = value; } + public void usesAnonymousInnerClass() { + new Thread( + new Runnable() { + @Override + public void run() { + System.out.println("2982157093127690243"); + } + }) + .start(); + } + public boolean getValue() { return value; } @@ -183,5 +194,9 @@ public boolean getValue() { public void setValue(boolean value) { this.value = value; } + + public static class NestedTwice { + public static int ZERO = 0; + } } } diff --git a/pkgs/jnigen/test/summary_generation_test.dart b/pkgs/jnigen/test/summary_generation_test.dart index 0133bac36..e1657f1a8 100644 --- a/pkgs/jnigen/test/summary_generation_test.dart +++ b/pkgs/jnigen/test/summary_generation_test.dart @@ -21,6 +21,15 @@ import 'package:test/test.dart'; import 'test_util/test_util.dart'; +const nestedClasses = [ + 'com.github.dart_lang.jnigen.simple_package.Example\$Nested', + 'com.github.dart_lang.jnigen.simple_package.Example\$Nested\$NestedTwice', + 'com.github.dart_lang.jnigen.generics.GrandParent\$StaticParent', + 'com.github.dart_lang.jnigen.generics.GrandParent\$StaticParent\$Child', + 'com.github.dart_lang.jnigen.generics.GrandParent\$Parent', + 'com.github.dart_lang.jnigen.generics.GrandParent\$Parent\$Child', +]; + void expectSummaryHasAllClasses(Classes? classes) { expect(classes, isNotNull); final decls = classes!.decls; @@ -28,6 +37,9 @@ void expectSummaryHasAllClasses(Classes? classes) { final declNames = decls.keys.toSet(); final expectedClasses = javaClasses.where((name) => !name.contains("annotations.")).toList(); + // Nested classes should be included automatically with parent class. + // change this part if you change this behavior intentionally. + expectedClasses.addAll(nestedClasses); expect(declNames, containsAll(expectedClasses)); } From 0673049230bf9af875f556a9259632d57bb0129e Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Tue, 25 Jul 2023 13:08:16 +0200 Subject: [PATCH 104/139] [jnigen] Interface implementation (https://github.com/dart-lang/jnigen/issues/326) * attach finalizable to close the port for interfaces * add missing JCharacter boxed type * add .implement method completed for interfaces * fix descriptor issues * temporarily do not check the ffigen bindings until ffigenhttps://github.com/dart-lang/jnigen/issues/555 is solved * remove duplicated java source in jni + sort ffigen.yaml inline functions * add the interface implementation under an experiment flag + docs --- .github/workflows/test-package.yml | 14 +- pkgs/jni/CHANGELOG.md | 4 + pkgs/jni/android/build.gradle | 20 + pkgs/jni/android/consumer-rules.pro | 1 + .../com/github/dart_lang/jni/JniPlugin.java | 2 - .../dart_lang/jni/PortContinuation.java | 42 -- pkgs/jni/bin/setup.dart | 45 ++- pkgs/jni/example/pubspec.lock | 2 +- pkgs/jni/ffigen.yaml | 28 +- pkgs/jni/java/pom.xml | 1 + .../com/github/dart_lang/jni/PortProxy.java | 82 ++++ pkgs/jni/lib/internal_helpers_for_jnigen.dart | 3 +- pkgs/jni/lib/jni_symbols.yaml | 4 + pkgs/jni/lib/src/jni.dart | 35 +- pkgs/jni/lib/src/lang/jcharacter.dart | 64 +++ pkgs/jni/lib/src/lang/jnumber.dart | 12 +- pkgs/jni/lib/src/lang/lang.dart | 1 + pkgs/jni/lib/src/method_invocation.dart | 38 ++ .../third_party/jni_bindings_generated.dart | 71 ++++ pkgs/jni/pubspec.yaml | 6 +- pkgs/jni/src/dartjni.c | 95 ++++- pkgs/jni/src/dartjni.h | 76 +++- pkgs/jni/test/boxed_test.dart | 15 + pkgs/jnigen/CHANGELOG.md | 11 +- pkgs/jnigen/README.md | 1 + .../in_app_java/lib/android_utils.dart | 33 +- .../src/android_utils/android_utils.c | 15 +- .../in_app_java/src/android_utils/dartjni.h | 76 +++- .../kotlin_plugin/lib/kotlin_bindings.dart | 4 +- .../example/kotlin_plugin/src/dartjni.h | 76 +++- .../lib/notifications.dart | 1 + .../example/notification_plugin/src/dartjni.h | 76 +++- .../org/apache/pdfbox/pdmodel/PDDocument.dart | 1 + .../pdfbox/pdmodel/PDDocumentInformation.dart | 1 + .../apache/pdfbox/text/PDFTextStripper.dart | 1 + .../pdfbox_plugin/src/third_party/dartjni.h | 76 +++- .../apisummarizer/disasm/AsmClassVisitor.java | 24 +- .../disasm/AsmMethodSignatureVisitor.java | 17 +- .../apisummarizer/disasm/AsmSummarizer.java | 7 +- .../disasm/AsmTypeUsageSignatureVisitor.java | 5 +- .../apisummarizer/disasm/TypeUtils.java | 11 +- .../apisummarizer/doclet/ElementBuilders.java | 4 - .../apisummarizer/elements/ClassDecl.java | 1 - pkgs/jnigen/lib/src/bindings/c_generator.dart | 70 +--- .../lib/src/bindings/dart_generator.dart | 292 +++++++++++++- pkgs/jnigen/lib/src/bindings/descriptor.dart | 115 ++++++ pkgs/jnigen/lib/src/bindings/unnester.dart | 11 +- pkgs/jnigen/lib/src/config/config_types.dart | 87 +++-- pkgs/jnigen/lib/src/config/experiments.dart | 38 ++ pkgs/jnigen/lib/src/elements/elements.dart | 50 +-- pkgs/jnigen/lib/src/elements/elements.g.dart | 8 +- pkgs/jnigen/lib/src/generate_bindings.dart | 4 +- pkgs/jnigen/lib/src/summary/summary.dart | 10 +- pkgs/jnigen/pubspec.yaml | 2 +- pkgs/jnigen/test/config_test.dart | 1 + pkgs/jnigen/test/descriptor_test.dart | 43 ++ .../test/jackson_core_test/generate.dart | 27 +- .../jnigen/test/jackson_core_test/jnigen.yaml | 3 + .../third_party/c_based/c_bindings/dartjni.h | 76 +++- .../c_based/c_bindings/jackson_core.c | 2 +- .../fasterxml/jackson/core/JsonFactory.dart | 1 + .../fasterxml/jackson/core/JsonParser.dart | 1 + .../com/fasterxml/jackson/core/JsonToken.dart | 1 + .../fasterxml/jackson/core/JsonFactory.dart | 1 + .../fasterxml/jackson/core/JsonParser.dart | 5 +- .../com/fasterxml/jackson/core/JsonToken.dart | 1 + .../kotlin_test/c_based/c_bindings/dartjni.h | 76 +++- .../c_based/dart_bindings/kotlin.dart | 7 +- .../dart_only/dart_bindings/kotlin.dart | 7 +- pkgs/jnigen/test/kotlin_test/generate.dart | 2 +- pkgs/jnigen/test/kotlin_test/jni.jar | Bin 2755 -> 0 bytes pkgs/jnigen/test/package_resolver_test.dart | 8 +- .../c_based/c_bindings/dartjni.h | 76 +++- .../c_based/c_bindings/simple_package.c | 152 ++++++++ .../c_based/dart_bindings/simple_package.dart | 367 ++++++++++++++++++ .../dart_bindings/simple_package.dart | 356 +++++++++++++++++ .../test/simple_package_test/generate.dart | 5 + .../jnigen/interfaces/MyInterface.java | 15 + .../interfaces/MyInterfaceConsumer.java | 21 + .../runtime_test_registrant.dart | 69 ++++ .../test/test_util/bindings_test_setup.dart | 2 +- 81 files changed, 2774 insertions(+), 340 deletions(-) create mode 100644 pkgs/jni/android/consumer-rules.pro delete mode 100644 pkgs/jni/android/src/main/java/com/github/dart_lang/jni/PortContinuation.java create mode 100644 pkgs/jni/java/src/main/java/com/github/dart_lang/jni/PortProxy.java create mode 100644 pkgs/jni/lib/src/lang/jcharacter.dart create mode 100644 pkgs/jni/lib/src/method_invocation.dart create mode 100644 pkgs/jnigen/lib/src/bindings/descriptor.dart create mode 100644 pkgs/jnigen/lib/src/config/experiments.dart create mode 100644 pkgs/jnigen/test/descriptor_test.dart delete mode 100644 pkgs/jnigen/test/kotlin_test/jni.jar create mode 100644 pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/interfaces/MyInterface.java create mode 100644 pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/interfaces/MyInterfaceConsumer.java diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 6bcd5624b..4e5da23df 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -188,11 +188,15 @@ jobs: flag-name: jni_tests parallel: true path-to-lcov: ./pkgs/jni/coverage/lcov.info - - name: regenerate & compare ffigen bindings - ## Use git to verify no source files have changed - run: | - dart run tool/generate_ffi_bindings.dart - git diff --exit-code -- lib/src/third_party src/third_party + # 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. + # + # - name: regenerate & compare ffigen bindings + # ## Use git to verify no source files have changed + # run: | + # dart run tool/generate_ffi_bindings.dart + # git diff --exit-code -- lib/src/third_party src/third_party ## Run tests for package:jni on windows, just to confirm it works. ## Do not, for example, collect coverage or check formatting. diff --git a/pkgs/jni/CHANGELOG.md b/pkgs/jni/CHANGELOG.md index 08d66d880..35a09db03 100644 --- a/pkgs/jni/CHANGELOG.md +++ b/pkgs/jni/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.6.0-wip-2 +* Added `PortProxy` and related methods used for interface implementation. +* Added the missing binding for `java.lang.Character`. + ## 0.5.0 * **Breaking Change** ([#137](https://github.com/dart-lang/jnigen/issues/137)): Java primitive types are now all lowercase like `jint`, `jshort`, ... * The bindings for `java.util.Set`, `java.util.Map`, `java.util.List` and the numeric types like `java.lang.Integer`, `java.lang.Boolean`, ... are now included in `package:jni`. diff --git a/pkgs/jni/android/build.gradle b/pkgs/jni/android/build.gradle index 4f5ca1b8e..3f650e845 100644 --- a/pkgs/jni/android/build.gradle +++ b/pkgs/jni/android/build.gradle @@ -27,11 +27,31 @@ rootProject.allprojects { apply plugin: 'com.android.library' android { + // Keeping the classes from being removed by proguard. + defaultConfig { + consumerProguardFiles 'consumer-rules.pro' + } + buildTypes { + release { + minifyEnabled false + } + } + // Condition for namespace compatibility in AGP 8 if (project.android.hasProperty("namespace")) { namespace 'com.github.dart_lang.jni' } + // Adding [PortContinuation] and [PortProxy] classes shared between Flutter and + // Dart-standalone versions of package:jni. + sourceSets { + main { + java { + srcDirs '../java/src/main/java' + } + } + } + // Bumping the plugin compileSdkVersion requires all clients of this plugin // to bump the version in their app. compileSdkVersion 31 diff --git a/pkgs/jni/android/consumer-rules.pro b/pkgs/jni/android/consumer-rules.pro new file mode 100644 index 000000000..269e42125 --- /dev/null +++ b/pkgs/jni/android/consumer-rules.pro @@ -0,0 +1 @@ +-keep class com.github.dart_lang.jni.** { *; } diff --git a/pkgs/jni/android/src/main/java/com/github/dart_lang/jni/JniPlugin.java b/pkgs/jni/android/src/main/java/com/github/dart_lang/jni/JniPlugin.java index 2a22dd8ed..d3a1ebe78 100644 --- a/pkgs/jni/android/src/main/java/com/github/dart_lang/jni/JniPlugin.java +++ b/pkgs/jni/android/src/main/java/com/github/dart_lang/jni/JniPlugin.java @@ -6,14 +6,12 @@ import android.app.Activity; import android.content.Context; -import androidx.annotation.Keep; import androidx.annotation.NonNull; import io.flutter.embedding.engine.plugins.FlutterPlugin; import io.flutter.embedding.engine.plugins.activity.ActivityAware; import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding; import io.flutter.plugin.common.PluginRegistry.Registrar; -@Keep public class JniPlugin implements FlutterPlugin, ActivityAware { @Override diff --git a/pkgs/jni/android/src/main/java/com/github/dart_lang/jni/PortContinuation.java b/pkgs/jni/android/src/main/java/com/github/dart_lang/jni/PortContinuation.java deleted file mode 100644 index eb377e4a7..000000000 --- a/pkgs/jni/android/src/main/java/com/github/dart_lang/jni/PortContinuation.java +++ /dev/null @@ -1,42 +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. - -package com.github.dart_lang.jni; - -import androidx.annotation.Keep; -import androidx.annotation.NonNull; -import kotlin.coroutines.Continuation; -import kotlin.coroutines.CoroutineContext; -import kotlinx.coroutines.Dispatchers; - -/// An implementation of kotlin.coroutines.Continuation which sends the address -/// of the object to Dart through a native port. -/// -/// This allows converting Kotlin coroutines to Dart async methods. -/// The implementation of native void _resumeWith is located in `dartjni.c`. -@Keep -public class PortContinuation implements Continuation { - static { - System.loadLibrary("dartjni"); - } - - private long port; - - public PortContinuation(long port) { - this.port = port; - } - - @NonNull - @Override - public CoroutineContext getContext() { - return (CoroutineContext) Dispatchers.getIO(); - } - - @Override - public void resumeWith(Object o) { - _resumeWith(port, o); - } - - private native void _resumeWith(long port, Object result); -} diff --git a/pkgs/jni/bin/setup.dart b/pkgs/jni/bin/setup.dart index 12ee6f976..7727cc148 100644 --- a/pkgs/jni/bin/setup.dart +++ b/pkgs/jni/bin/setup.dart @@ -93,11 +93,11 @@ void verboseLog(String msg) { } } -/// Find path to C sources in pub cache for package specified by [packageName]. +/// Find path to C or Java sources in pub cache for package specified by +/// [packageName]. /// -/// It's assumed C FFI sources are in "src/" relative to package root. /// If package cannot be found, null is returned. -Future findSources(String packageName) async { +Future findSources(String packageName, String subDirectory) async { final packageConfig = await findPackageConfig(Directory.current); if (packageConfig == null) { throw UnsupportedError("Please run from project root."); @@ -106,7 +106,7 @@ Future findSources(String packageName) async { if (package == null) { throw UnsupportedError("Cannot find package: $packageName"); } - return package.root.resolve("src").toFilePath(); + return package.root.resolve(subDirectory).toFilePath(); } /// Return '/src' directories of all dependencies which has a CMakeLists.txt @@ -170,7 +170,8 @@ void main(List arguments) async { final sources = options.sources; for (var packageName in options.packages) { - sources.add(await findSources(packageName)); + // It's assumed C FFI sources are in "src/" relative to package root. + sources.add(await findSources(packageName, 'src')); } if (sources.isEmpty) { final dependencySources = await findDependencySources(); @@ -185,6 +186,28 @@ void main(List arguments) async { exitCode = 1; return; } + + final currentDirUri = Uri.directory("."); + final buildPath = options.buildPath ?? + currentDirUri.resolve(_defaultRelativeBuildPath).toFilePath(); + final buildDir = Directory(buildPath); + await buildDir.create(recursive: true); + + final javaSrc = await findSources('jni', 'java'); + final targetJar = File.fromUri(buildDir.uri.resolve('jni.jar')); + if (!needsBuild(targetJar, Directory.fromUri(Uri.directory(javaSrc)))) { + verboseLog('Last modified of ${targetJar.path}: ' + '${targetJar.lastModifiedSync()}.'); + stderr.writeln('Target newer than source, skipping build.'); + } else { + verboseLog('Running mvn package for jni java sources to $buildPath.'); + await runCommand( + 'mvn', + ['package', '-Dtarget=${buildDir.absolute.path}'], + await findSources('jni', 'java'), + ); + } + for (var srcPath in sources) { final srcDir = Directory(srcPath); if (!srcDir.existsSync()) { @@ -194,20 +217,14 @@ void main(List arguments) async { } verboseLog("srcPath: $srcPath"); - - final currentDirUri = Uri.directory("."); - final buildPath = options.buildPath ?? - currentDirUri.resolve(_defaultRelativeBuildPath).toFilePath(); - final buildDir = Directory(buildPath); - await buildDir.create(recursive: true); verboseLog("buildPath: $buildPath"); final targetFileUri = buildDir.uri.resolve(getTargetName(srcDir)); final targetFile = File.fromUri(targetFileUri); if (!needsBuild(targetFile, srcDir)) { - verboseLog("last modified of ${targetFile.path}: " - "${targetFile.lastModifiedSync()}"); - stderr.writeln("target newer than source, skipping build"); + verboseLog("Last modified of ${targetFile.path}: " + "${targetFile.lastModifiedSync()}."); + stderr.writeln('Target newer than source, skipping build.'); continue; } diff --git a/pkgs/jni/example/pubspec.lock b/pkgs/jni/example/pubspec.lock index 34dff04b1..c730dba99 100644 --- a/pkgs/jni/example/pubspec.lock +++ b/pkgs/jni/example/pubspec.lock @@ -200,7 +200,7 @@ packages: path: ".." relative: true source: path - version: "0.6.0-dev.1" + version: "0.6.0-dev.2" js: dependency: transitive description: diff --git a/pkgs/jni/ffigen.yaml b/pkgs/jni/ffigen.yaml index 1704f430f..62b7429ab 100644 --- a/pkgs/jni/ffigen.yaml +++ b/pkgs/jni/ffigen.yaml @@ -33,22 +33,33 @@ functions: - 'setJniGetters' - 'jni_log' # Inline functions + # keep-sorted start - 'acquire_lock' - - 'release_lock' - - 'init_lock' + - 'attach_thread' + - 'check_exception' + - 'destroy_cond' - 'destroy_lock' + - 'init_cond' + - 'init_lock' - 'load_class' - 'load_class_global_ref' - - 'attach_thread' - - 'load_method' - - 'load_static_method' + - 'load_class_local_ref' + - 'load_class_platform' + - 'load_env' - 'load_field' + - 'load_method' - 'load_static_field' + - 'load_static_method' + - 'release_lock' + - 'signal_cond' + - 'thread_id' - 'to_global_ref' - - 'check_exception' - - 'load_env' - # This is a native function in Java. No need to call it from Dart. + - 'to_global_ref_result' + - 'wait_for' + # keep-sorted end + # Native functions in Java. No need to call them from Dart. - 'Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith' + - 'Java_com_github_dart_1lang_jni_PortProxy__1invoke' structs: exclude: - 'JniContext' @@ -57,6 +68,7 @@ structs: - '_JNIEnv' - 'JNIInvokeInterface' - '__va_list_tag' + - 'CallbackResult' rename: ## opaque struct definitions, base types of jfieldID and jmethodID '_jfieldID': 'jfieldID_' diff --git a/pkgs/jni/java/pom.xml b/pkgs/jni/java/pom.xml index 62f121e3d..2bd6f88d4 100644 --- a/pkgs/jni/java/pom.xml +++ b/pkgs/jni/java/pom.xml @@ -16,6 +16,7 @@ jni + ${target} diff --git a/pkgs/jni/java/src/main/java/com/github/dart_lang/jni/PortProxy.java b/pkgs/jni/java/src/main/java/com/github/dart_lang/jni/PortProxy.java new file mode 100644 index 000000000..a75a914f9 --- /dev/null +++ b/pkgs/jni/java/src/main/java/com/github/dart_lang/jni/PortProxy.java @@ -0,0 +1,82 @@ +// 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. + +package com.github.dart_lang.jni; + +import java.lang.reflect.*; + +public class PortProxy implements InvocationHandler { + static { + System.loadLibrary("dartjni"); + } + + private final long port; + private final long threadId; + private final long functionPtr; + + private PortProxy(long port, long threadId, long functionPtr) { + this.port = port; + this.threadId = threadId; + this.functionPtr = functionPtr; + } + + private static String getDescriptor(Method method) { + StringBuilder descriptor = new StringBuilder(); + descriptor.append(method.getName()).append("("); + Class[] parameterTypes = method.getParameterTypes(); + for (Class paramType : parameterTypes) { + appendType(descriptor, paramType); + } + descriptor.append(")"); + appendType(descriptor, method.getReturnType()); + return descriptor.toString(); + } + + private static void appendType(StringBuilder descriptor, Class type) { + if (type == void.class) { + descriptor.append("V"); + } else if (type == boolean.class) { + descriptor.append("Z"); + } else if (type == byte.class) { + descriptor.append("B"); + } else if (type == char.class) { + descriptor.append("C"); + } else if (type == short.class) { + descriptor.append("S"); + } else if (type == int.class) { + descriptor.append("I"); + } else if (type == long.class) { + descriptor.append("J"); + } else if (type == float.class) { + descriptor.append("F"); + } else if (type == double.class) { + descriptor.append("D"); + } else if (type.isArray()) { + descriptor.append('['); + appendType(descriptor, type.getComponentType()); + } else { + descriptor.append("L").append(type.getName().replace('.', '/')).append(";"); + } + } + + public static Object newInstance(String binaryName, long port, long threadId, long functionPtr) + throws ClassNotFoundException { + Class clazz = Class.forName(binaryName); + return Proxy.newProxyInstance( + clazz.getClassLoader(), new Class[] {clazz}, new PortProxy(port, threadId, functionPtr)); + } + + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + return _invoke(port, threadId, functionPtr, proxy, getDescriptor(method), args); + } + + private native Object _invoke( + long port, + long threadId, + long functionPtr, + Object proxy, + String methodDescriptor, + Object[] args); +} diff --git a/pkgs/jni/lib/internal_helpers_for_jnigen.dart b/pkgs/jni/lib/internal_helpers_for_jnigen.dart index 7e1fc8e78..257b0c25d 100644 --- a/pkgs/jni/lib/internal_helpers_for_jnigen.dart +++ b/pkgs/jni/lib/internal_helpers_for_jnigen.dart @@ -6,6 +6,7 @@ /// not to be used directly. library internal_helpers_for_jnigen; +export 'src/accessors.dart'; export 'src/jni.dart' show ProtectedJniExtensions; export 'src/jreference.dart'; -export 'src/accessors.dart'; +export 'src/method_invocation.dart'; diff --git a/pkgs/jni/lib/jni_symbols.yaml b/pkgs/jni/lib/jni_symbols.yaml index 8b1f9ec88..5159dc9cc 100644 --- a/pkgs/jni/lib/jni_symbols.yaml +++ b/pkgs/jni/lib/jni_symbols.yaml @@ -41,6 +41,10 @@ files: name: JBoolean type_class: JBooleanType super_count: 1 + 'java.lang.Character': + name: JCharacter + type_class: JCharacterType + super_count: 1 'java.util.Set': name: JSet type_class: JSetType diff --git a/pkgs/jni/lib/src/jni.dart b/pkgs/jni/lib/src/jni.dart index 0698b84dc..8145642fb 100644 --- a/pkgs/jni/lib/src/jni.dart +++ b/pkgs/jni/lib/src/jni.dart @@ -193,11 +193,6 @@ abstract class Jni { static final accessors = JniAccessors(_bindings.GetAccessors()); - /// Returns a new PortContinuation. - static JObjectPtr newPortContinuation(ReceivePort port) { - return _bindings.PortContinuation__ctor(port.sendPort.nativePort).object; - } - /// Returns current application context on Android. static JObjectPtr getCachedApplicationContext() { return _bindings.GetApplicationContext(); @@ -301,6 +296,36 @@ extension ProtectedJniExtensions on Jni { final lookup = dl.lookup; return lookup; } + + /// Returns a new PortContinuation. + static JObjectPtr newPortContinuation(ReceivePort port) { + return Jni._bindings + .PortContinuation__ctor(port.sendPort.nativePort) + .object; + } + + /// Returns a new PortProxy for a class with the given [binaryName]. + static JObjectPtr newPortProxy( + String binaryName, + ReceivePort port, + Pointer< + NativeFunction< + Pointer Function(Uint64, Pointer, Pointer)>> + functionPtr) { + return Jni._bindings + .PortProxy__newInstance( + Jni.env.toJStringPtr(binaryName), + port.sendPort.nativePort, + functionPtr.address, + ) + .object; + } + + /// Return the result of a callback.. + static void returnResult( + Pointer result, JObjectPtr object) async { + Jni._bindings.resultFor(result, object); + } } extension AdditionalEnvMethods on GlobalJniEnv { diff --git a/pkgs/jni/lib/src/lang/jcharacter.dart b/pkgs/jni/lib/src/lang/jcharacter.dart new file mode 100644 index 000000000..6ab76cf7a --- /dev/null +++ b/pkgs/jni/lib/src/lang/jcharacter.dart @@ -0,0 +1,64 @@ +import '../accessors.dart'; +import '../jni.dart'; +import '../jobject.dart'; +import '../jvalues.dart'; +import '../third_party/generated_bindings.dart'; +import '../types.dart'; + +class JCharacterType extends JObjType { + const JCharacterType(); + + @override + String get signature => r"Ljava/lang/Character;"; + + @override + JCharacter fromRef(JObjectPtr ref) => JCharacter.fromRef(ref); + + @override + JObjType get superType => const JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => (JCharacterType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == (JCharacterType) && other is JCharacterType; + } +} + +class JCharacter extends JObject { + @override + // ignore: overridden_fields + late final JObjType $type = type; + + JCharacter.fromRef( + JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = JCharacterType(); + + static final _class = Jni.findJClass(r"java/lang/Character"); + + static final _ctorId = + Jni.accessors.getMethodIDOf(_class.reference, r"", r"(C)V"); + + JCharacter(int c) + : super.fromRef(Jni.accessors.newObjectWithArgs( + _class.reference, _ctorId, [JValueChar(c)]).object); + + static final _charValueId = + Jni.accessors.getMethodIDOf(_class.reference, r"charValue", r"()C"); + + int charValue({bool deleteOriginal = false}) { + final ret = Jni.accessors.callMethodWithArgs( + reference, _charValueId, JniCallType.charType, []).char; + if (deleteOriginal) { + delete(); + } + return ret; + } +} diff --git a/pkgs/jni/lib/src/lang/jnumber.dart b/pkgs/jni/lib/src/lang/jnumber.dart index 8461f1086..cab303322 100644 --- a/pkgs/jni/lib/src/lang/jnumber.dart +++ b/pkgs/jni/lib/src/lang/jnumber.dart @@ -7,13 +7,14 @@ import '../jni.dart'; import '../jobject.dart'; import '../third_party/generated_bindings.dart'; import '../types.dart'; -import 'jinteger.dart'; -import 'jshort.dart'; -import 'jlong.dart'; +import 'jboolean.dart'; +import 'jbyte.dart'; +import 'jcharacter.dart'; import 'jdouble.dart'; import 'jfloat.dart'; -import 'jbyte.dart'; -import 'jboolean.dart'; +import 'jinteger.dart'; +import 'jlong.dart'; +import 'jshort.dart'; class JNumberType extends JObjType { const JNumberType(); @@ -137,6 +138,7 @@ extension IntToJava on int { JShort toJShort() => JShort(this); JInteger toJInteger() => JInteger(this); JLong toJLong() => JLong(this); + JCharacter toJCharacter() => JCharacter(this); } extension DoubleToJava on double { diff --git a/pkgs/jni/lib/src/lang/lang.dart b/pkgs/jni/lib/src/lang/lang.dart index e4c1af72d..786488c06 100644 --- a/pkgs/jni/lib/src/lang/lang.dart +++ b/pkgs/jni/lib/src/lang/lang.dart @@ -4,6 +4,7 @@ export 'jboolean.dart'; export 'jbyte.dart'; +export 'jcharacter.dart'; export 'jdouble.dart'; export 'jfloat.dart'; export 'jinteger.dart'; diff --git a/pkgs/jni/lib/src/method_invocation.dart b/pkgs/jni/lib/src/method_invocation.dart new file mode 100644 index 000000000..69cdc4a03 --- /dev/null +++ b/pkgs/jni/lib/src/method_invocation.dart @@ -0,0 +1,38 @@ +// 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 'dart:ffi'; + +import 'third_party/generated_bindings.dart'; + +import 'lang/jstring.dart'; +import 'jarray.dart'; +import 'jobject.dart'; + +class $MethodInvocation { + final Pointer result; + final JString methodDescriptor; + final JArray args; + + $MethodInvocation._(this.result, this.methodDescriptor, this.args); + + factory $MethodInvocation.fromAddresses( + int resultAddress, + int descriptorAddress, + int argsAddress, + ) { + return $MethodInvocation._( + Pointer.fromAddress(resultAddress), + JString.fromRef(Pointer.fromAddress(descriptorAddress)), + JArray.fromRef( + const JObjectType(), + Pointer.fromAddress(argsAddress), + ), + ); + } + + factory $MethodInvocation.fromMessage(List message) { + return $MethodInvocation.fromAddresses(message[0], message[1], message[2]); + } +} 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 7cb2bdb8f..ef83bb57e 100644 --- a/pkgs/jni/lib/src/third_party/jni_bindings_generated.dart +++ b/pkgs/jni/lib/src/third_party/jni_bindings_generated.dart @@ -178,6 +178,23 @@ class JniBindings { late final _InitDartApiDL = _InitDartApiDLPtr.asFunction)>(); + void resultFor( + ffi.Pointer result, + JObjectPtr object, + ) { + return _resultFor( + result, + object, + ); + } + + late final _resultForPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, JObjectPtr)>>('resultFor'); + late final _resultFor = _resultForPtr + .asFunction, JObjectPtr)>(); + JniResult PortContinuation__ctor( int j, ) { @@ -192,6 +209,25 @@ class JniBindings { late final _PortContinuation__ctor = _PortContinuation__ctorPtr.asFunction(); + JniResult PortProxy__newInstance( + JObjectPtr binaryName, + int port, + int functionPtr, + ) { + return _PortProxy__newInstance( + binaryName, + port, + functionPtr, + ); + } + + late final _PortProxy__newInstancePtr = _lookup< + ffi.NativeFunction< + JniResult Function( + JObjectPtr, ffi.Int64, ffi.Int64)>>('PortProxy__newInstance'); + late final _PortProxy__newInstance = _PortProxy__newInstancePtr.asFunction< + JniResult Function(JObjectPtr, int, int)>(); + ffi.Pointer GetGlobalEnv() { return _GetGlobalEnv(); } @@ -1936,6 +1972,41 @@ class JavaVMOption extends ffi.Struct { external ffi.Pointer extraInfo; } +class CallbackResult extends ffi.Struct { + external MutexLock lock; + + external ConditionVariable cond; + + @ffi.Int() + external int ready; + + external JObjectPtr object; +} + +typedef MutexLock = pthread_mutex_t; +typedef pthread_mutex_t = __darwin_pthread_mutex_t; +typedef __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; + +class _opaque_pthread_mutex_t extends ffi.Struct { + @ffi.Long() + external int __sig; + + @ffi.Array.multi([56]) + external ffi.Array __opaque; +} + +typedef ConditionVariable = pthread_cond_t; +typedef pthread_cond_t = __darwin_pthread_cond_t; +typedef __darwin_pthread_cond_t = _opaque_pthread_cond_t; + +class _opaque_pthread_cond_t extends ffi.Struct { + @ffi.Long() + external int __sig; + + @ffi.Array.multi([40]) + external ffi.Array __opaque; +} + class GlobalJniEnvStruct extends ffi.Struct { external ffi.Pointer reserved0; diff --git a/pkgs/jni/pubspec.yaml b/pkgs/jni/pubspec.yaml index 0c1068a36..834424973 100644 --- a/pkgs/jni/pubspec.yaml +++ b/pkgs/jni/pubspec.yaml @@ -1,6 +1,10 @@ +# 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 +# BSD-style license that can be found in the LICENSE file. + name: jni description: Library to access JNI from dart and flutter -version: 0.6.0-dev.1 +version: 0.6.0-wip.2 repository: https://github.com/dart-lang/jnigen/tree/main/jni environment: diff --git a/pkgs/jni/src/dartjni.c b/pkgs/jni/src/dartjni.c index 19a32ebed..6f0fa0867 100644 --- a/pkgs/jni/src/dartjni.c +++ b/pkgs/jni/src/dartjni.c @@ -574,10 +574,11 @@ Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env, jobject thiz, jlong port, jobject result) { - Dart_CObject dartPtr; - dartPtr.type = Dart_CObject_kInt64; - dartPtr.value.as_int64 = (jlong)((*env)->NewGlobalRef(env, result)); - Dart_PostCObject_DL(port, &dartPtr); + attach_thread(); + Dart_CObject c_post; + c_post.type = Dart_CObject_kInt64; + c_post.value.as_int64 = (jlong)((*env)->NewGlobalRef(env, result)); + Dart_PostCObject_DL(port, &c_post); } // com.github.dart_lang.jni.PortContinuation @@ -586,6 +587,7 @@ jclass _c_PortContinuation = NULL; jmethodID _m_PortContinuation__ctor = NULL; FFI_PLUGIN_EXPORT JniResult PortContinuation__ctor(int64_t j) { + attach_thread(); load_class_global_ref(&_c_PortContinuation, "com/github/dart_lang/jni/PortContinuation"); if (_c_PortContinuation == NULL) @@ -602,3 +604,88 @@ JniResult PortContinuation__ctor(int64_t j) { } return (JniResult){.value = {.l = _result}, .exception = check_exception()}; } + +// com.github.dart_lang.jni.PortProxy +jclass _c_PortProxy = NULL; + +jmethodID _m_PortProxy__newInstance = NULL; +FFI_PLUGIN_EXPORT +JniResult PortProxy__newInstance(jobject binaryName, + int64_t port, + int64_t functionPtr) { + attach_thread(); + load_class_global_ref(&_c_PortProxy, "com/github/dart_lang/jni/PortProxy"); + if (_c_PortProxy == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_PortProxy, &_m_PortProxy__newInstance, "newInstance", + "(Ljava/lang/String;JJJ)Ljava/lang/Object;"); + if (_m_PortProxy__newInstance == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallStaticObjectMethod( + jniEnv, _c_PortProxy, _m_PortProxy__newInstance, binaryName, port, + thread_id(), functionPtr); + return to_global_ref_result(_result); +} + +FFI_PLUGIN_EXPORT +void resultFor(CallbackResult* result, jobject object) { + acquire_lock(&result->lock); + result->ready = 1; + result->object = object; + signal_cond(&result->cond); + release_lock(&result->lock); +} + +JNIEXPORT jobject JNICALL +Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, + jobject thiz, + jlong port, + jlong threadId, + jlong functionPtr, + jobject proxy, + jstring methodDescriptor, + jobjectArray args) { + attach_thread(); + if (threadId != thread_id()) { + CallbackResult* result = (CallbackResult*)malloc(sizeof(CallbackResult)); + init_lock(&result->lock); + init_cond(&result->cond); + acquire_lock(&result->lock); + result->ready = 0; + result->object = NULL; + + Dart_CObject c_result; + c_result.type = Dart_CObject_kInt64; + c_result.value.as_int64 = (jlong)result; + + Dart_CObject c_method; + c_method.type = Dart_CObject_kInt64; + c_method.value.as_int64 = + (jlong)((*env)->NewGlobalRef(env, methodDescriptor)); + + Dart_CObject c_args; + c_args.type = Dart_CObject_kInt64; + c_args.value.as_int64 = (jlong)((*env)->NewGlobalRef(env, args)); + + Dart_CObject* c_post_arr[] = {&c_result, &c_method, &c_args}; + Dart_CObject c_post; + c_post.type = Dart_CObject_kArray; + c_post.value.as_array.values = c_post_arr; + c_post.value.as_array.length = sizeof(c_post_arr) / sizeof(c_post_arr[0]); + + Dart_PostCObject_DL(port, &c_post); + while (!result->ready) { + wait_for(&result->cond, &result->lock); + } + release_lock(&result->lock); + destroy_lock(&result->lock); + destroy_cond(&result->cond); + jobject object = result->object; + free(result); + return object; + } else { + return ((jobject(*)(uint64_t, jobject, jobject))functionPtr)( + port, (*env)->NewGlobalRef(env, methodDescriptor), + (*env)->NewGlobalRef(env, args)); + } +} \ No newline at end of file diff --git a/pkgs/jni/src/dartjni.h b/pkgs/jni/src/dartjni.h index c0713af53..cbb1f7f5c 100644 --- a/pkgs/jni/src/dartjni.h +++ b/pkgs/jni/src/dartjni.h @@ -45,6 +45,7 @@ #include typedef CRITICAL_SECTION MutexLock; +typedef CONDITION_VARIABLE ConditionVariable; static inline void init_lock(MutexLock* lock) { InitializeCriticalSection(lock); @@ -58,15 +59,32 @@ static inline void release_lock(MutexLock* lock) { LeaveCriticalSection(lock); } -static inline void _destroyLock(MutexLock* lock) { +static inline void destroy_lock(MutexLock* lock) { DeleteCriticalSection(lock); } -#elif defined __DARWIN__ || defined __LINUX__ || defined __ANDROID__ || \ +static inline void init_cond(ConditionVariable* cond) { + InitializeConditionVariable(cond); +} + +static inline void signal_cond(ConditionVariable* cond) { + WakeConditionVariable(cond); +} + +static inline void wait_for(ConditionVariable* cond, MutexLock* lock) { + SleepConditionVariableCS(cond, lock, INFINITE); +} + +static inline void destroy_cond(ConditionVariable* cond) { + DeleteCriticalSection(cond); +} + +#elif defined __APPLE__ || defined __LINUX__ || defined __ANDROID__ || \ defined __GNUC__ #include typedef pthread_mutex_t MutexLock; +typedef pthread_cond_t ConditionVariable; static inline void init_lock(MutexLock* lock) { pthread_mutex_init(lock, NULL); @@ -80,15 +98,48 @@ static inline void release_lock(MutexLock* lock) { pthread_mutex_unlock(lock); } -static inline void _destroyLock(MutexLock* lock) { +static inline void destroy_lock(MutexLock* lock) { pthread_mutex_destroy(lock); } +static inline void init_cond(ConditionVariable* cond) { + pthread_cond_init(cond, NULL); +} + +static inline void signal_cond(ConditionVariable* cond) { + pthread_cond_signal(cond); +} + +static inline void wait_for(ConditionVariable* cond, MutexLock* lock) { + pthread_cond_wait(cond, lock); +} + +static inline void destroy_cond(ConditionVariable* cond) { + pthread_cond_destroy(cond); +} + #else -#error "No locking support; Possibly unsupported platform" +#error "No locking/condition variable support; Possibly unsupported platform" + +#endif +static inline uint64_t thread_id() { +#ifdef _WIN32 + return GetCurrentThreadId(); +#elif defined __APPLE__ + return pthread_mach_thread_np(pthread_self()); +#else + return pthread_self(); #endif +} + +typedef struct CallbackResult { + MutexLock lock; + ConditionVariable cond; + int ready; + jobject object; +} CallbackResult; typedef struct JniLocks { MutexLock classLoadingLock; @@ -369,6 +420,8 @@ static inline JniResult to_global_ref_result(jobject ref) { FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); +FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object); + JNIEXPORT void JNICALL Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env, jobject thiz, @@ -376,3 +429,18 @@ Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env, jobject result); FFI_PLUGIN_EXPORT JniResult PortContinuation__ctor(int64_t j); + +FFI_PLUGIN_EXPORT +JniResult PortProxy__newInstance(jobject binaryName, + int64_t port, + int64_t functionPtr); + +JNIEXPORT jobject JNICALL +Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, + jobject thiz, + jlong port, + jlong threadId, + jlong functionPtr, + jobject proxy, + jstring methodDescriptor, + jobjectArray args); diff --git a/pkgs/jni/test/boxed_test.dart b/pkgs/jni/test/boxed_test.dart index 43489e887..88d8686d1 100644 --- a/pkgs/jni/test/boxed_test.dart +++ b/pkgs/jni/test/boxed_test.dart @@ -26,6 +26,13 @@ void run({required TestRunnerCallback testRunner}) { expect((-val).toJByte().byteValue(deleteOriginal: true), -val); }); }); + testRunner('JCharacter', () { + const val = 1 << 5; + using((arena) { + expect(JCharacter(val).charValue(deleteOriginal: true), val); + expect(JCharacter(0).charValue(deleteOriginal: true), 0); + }); + }); testRunner('JShort', () { const val = 1 << 10; using((arena) { @@ -79,6 +86,14 @@ void run({required TestRunnerCallback testRunner}) { expect(a.$type.hashCode, b.$type.hashCode); }); }); + testRunner('JCharacter.\$type hashCode and ==', () { + using((arena) { + final a = JCharacter(1)..deletedIn(arena); + final b = JCharacter(2)..deletedIn(arena); + expect(a.$type, b.$type); + expect(a.$type.hashCode, b.$type.hashCode); + }); + }); testRunner('JShort.\$type hashCode and ==', () { using((arena) { final a = JShort(1)..deletedIn(arena); diff --git a/pkgs/jnigen/CHANGELOG.md b/pkgs/jnigen/CHANGELOG.md index 48b1b212b..8d2086e44 100644 --- a/pkgs/jnigen/CHANGELOG.md +++ b/pkgs/jnigen/CHANGELOG.md @@ -1,8 +1,15 @@ -## 0.6.0-dev.1 +## 0.6.0-wip.2 +* Fixed a bug where the nested classes would be generated incorrectly depending on the backend used for generation. +* Fixed a bug where ASM backend would produce the incorrect parent for multi-level nested classes. +* Fixed a bug where the backends would produce different descriptors for the same method. +* Added `enable_experiment` option to config. +* Created an experiment called `interface_implementation` which creates a `.implement` method for interfaces, so you can implement them using Dart. + +## 0.6.0-wip.1 * **Breaking Change** Specifying a class always pulls in nested classes by default. If a nested class is specified in config, it will be an error. * Save all `jnigen` logs to a file in `.dart_tool/jnigen/logs/`. This is useful for debugging. -## 0.6.0-dev.0 +## 0.6.0-wip.0 * **Breaking Change** Removed `suspend_fun_to_async` flag from the config. It's now happening by default since we read the Kotlin's metadata and reliably identify the `suspend fun`s. ## 0.5.0 diff --git a/pkgs/jnigen/README.md b/pkgs/jnigen/README.md index 8d47afd54..d524e0e8a 100644 --- a/pkgs/jnigen/README.md +++ b/pkgs/jnigen/README.md @@ -218,6 +218,7 @@ A `*` denotes required configuration. | `source_path` | List of directory paths | Directories to search for source files. Note: source_path for dependencies downloaded using `maven_downloads` configuration is added automatically without the need to specify here. | | `class_path` | List of directory / JAR paths | Classpath for API summary generation. This should include any JAR dependencies of the source files in `source_path`. | | `classes` * | List of qualified class / package names | List of qualified class / package names. `source_path` will be scanned assuming the sources follow standard java-ish hierarchy. That is a.b.c either maps to a directory `a/b/c` or a class file `a/b/c.java`. | +| `enable_experiment` | List of experiment names:
    • `interface_implementation`
    | List of enabled experiments. These features are still in development and their API might break. | | `output:` | (Subsection) | This subsection will contain configuration related to output files. | | `output:` >> `bindings_type` | `c_based` (default) or `dart_only` | Binding generation strategy. [Trade-offs](#pure-dart-bindings) are explained at the end of this document. | | `output:` >> `c:` | (Subsection) | This subsection specified C output configuration. Required if `bindings_type` is `c_based`. | diff --git a/pkgs/jnigen/example/in_app_java/lib/android_utils.dart b/pkgs/jnigen/example/in_app_java/lib/android_utils.dart index 028fa4292..b14813fc6 100644 --- a/pkgs/jnigen/example/in_app_java/lib/android_utils.dart +++ b/pkgs/jnigen/example/in_app_java/lib/android_utils.dart @@ -12,6 +12,7 @@ // 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 import "dart:isolate" show ReceivePort; @@ -2600,18 +2601,14 @@ class Build_VERSION extends jni.JObject { static jni.JString get SECURITY_PATCH => const jni.JStringType().fromRef(_get_SECURITY_PATCH().object); - static final _ctor = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("Build_VERSION__ctor") - .asFunction)>(); + static final _ctor = jniLookup>( + "Build_VERSION__ctor") + .asFunction(); - /// from: public void (android.os.Build $parent) + /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. - factory Build_VERSION( - Build $parent, - ) { - return Build_VERSION.fromRef(_ctor($parent.reference).object); + factory Build_VERSION() { + return Build_VERSION.fromRef(_ctor().object); } } @@ -2754,18 +2751,14 @@ class Build_VERSION_CODES extends jni.JObject { /// from: static public final int TIRAMISU static const TIRAMISU = 33; - static final _ctor = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("Build_VERSION_CODES__ctor") - .asFunction)>(); + static final _ctor = jniLookup>( + "Build_VERSION_CODES__ctor") + .asFunction(); - /// from: public void (android.os.Build $parent) + /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. - factory Build_VERSION_CODES( - Build $parent, - ) { - return Build_VERSION_CODES.fromRef(_ctor($parent.reference).object); + factory Build_VERSION_CODES() { + return Build_VERSION_CODES.fromRef(_ctor().object); } } diff --git a/pkgs/jnigen/example/in_app_java/src/android_utils/android_utils.c b/pkgs/jnigen/example/in_app_java/src/android_utils/android_utils.c index c41ff6e96..a6e491c9d 100644 --- a/pkgs/jnigen/example/in_app_java/src/android_utils/android_utils.c +++ b/pkgs/jnigen/example/in_app_java/src/android_utils/android_utils.c @@ -1440,17 +1440,16 @@ jclass _c_Build_VERSION = NULL; jmethodID _m_Build_VERSION__ctor = NULL; FFI_PLUGIN_EXPORT -JniResult Build_VERSION__ctor(jobject _parent) { +JniResult Build_VERSION__ctor() { load_env(); load_class_global_ref(&_c_Build_VERSION, "android/os/Build$VERSION"); if (_c_Build_VERSION == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_Build_VERSION, &_m_Build_VERSION__ctor, "", - "(Landroid/os/Build;)V"); + load_method(_c_Build_VERSION, &_m_Build_VERSION__ctor, "", "()V"); if (_m_Build_VERSION__ctor == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Build_VERSION, - _m_Build_VERSION__ctor, _parent); + jobject _result = + (*jniEnv)->NewObject(jniEnv, _c_Build_VERSION, _m_Build_VERSION__ctor); return to_global_ref_result(_result); } @@ -1615,18 +1614,18 @@ jclass _c_Build_VERSION_CODES = NULL; jmethodID _m_Build_VERSION_CODES__ctor = NULL; FFI_PLUGIN_EXPORT -JniResult Build_VERSION_CODES__ctor(jobject _parent) { +JniResult Build_VERSION_CODES__ctor() { load_env(); load_class_global_ref(&_c_Build_VERSION_CODES, "android/os/Build$VERSION_CODES"); if (_c_Build_VERSION_CODES == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_Build_VERSION_CODES, &_m_Build_VERSION_CODES__ctor, "", - "(Landroid/os/Build;)V"); + "()V"); if (_m_Build_VERSION_CODES__ctor == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Build_VERSION_CODES, - _m_Build_VERSION_CODES__ctor, _parent); + _m_Build_VERSION_CODES__ctor); return to_global_ref_result(_result); } diff --git a/pkgs/jnigen/example/in_app_java/src/android_utils/dartjni.h b/pkgs/jnigen/example/in_app_java/src/android_utils/dartjni.h index c0713af53..cbb1f7f5c 100644 --- a/pkgs/jnigen/example/in_app_java/src/android_utils/dartjni.h +++ b/pkgs/jnigen/example/in_app_java/src/android_utils/dartjni.h @@ -45,6 +45,7 @@ #include typedef CRITICAL_SECTION MutexLock; +typedef CONDITION_VARIABLE ConditionVariable; static inline void init_lock(MutexLock* lock) { InitializeCriticalSection(lock); @@ -58,15 +59,32 @@ static inline void release_lock(MutexLock* lock) { LeaveCriticalSection(lock); } -static inline void _destroyLock(MutexLock* lock) { +static inline void destroy_lock(MutexLock* lock) { DeleteCriticalSection(lock); } -#elif defined __DARWIN__ || defined __LINUX__ || defined __ANDROID__ || \ +static inline void init_cond(ConditionVariable* cond) { + InitializeConditionVariable(cond); +} + +static inline void signal_cond(ConditionVariable* cond) { + WakeConditionVariable(cond); +} + +static inline void wait_for(ConditionVariable* cond, MutexLock* lock) { + SleepConditionVariableCS(cond, lock, INFINITE); +} + +static inline void destroy_cond(ConditionVariable* cond) { + DeleteCriticalSection(cond); +} + +#elif defined __APPLE__ || defined __LINUX__ || defined __ANDROID__ || \ defined __GNUC__ #include typedef pthread_mutex_t MutexLock; +typedef pthread_cond_t ConditionVariable; static inline void init_lock(MutexLock* lock) { pthread_mutex_init(lock, NULL); @@ -80,15 +98,48 @@ static inline void release_lock(MutexLock* lock) { pthread_mutex_unlock(lock); } -static inline void _destroyLock(MutexLock* lock) { +static inline void destroy_lock(MutexLock* lock) { pthread_mutex_destroy(lock); } +static inline void init_cond(ConditionVariable* cond) { + pthread_cond_init(cond, NULL); +} + +static inline void signal_cond(ConditionVariable* cond) { + pthread_cond_signal(cond); +} + +static inline void wait_for(ConditionVariable* cond, MutexLock* lock) { + pthread_cond_wait(cond, lock); +} + +static inline void destroy_cond(ConditionVariable* cond) { + pthread_cond_destroy(cond); +} + #else -#error "No locking support; Possibly unsupported platform" +#error "No locking/condition variable support; Possibly unsupported platform" + +#endif +static inline uint64_t thread_id() { +#ifdef _WIN32 + return GetCurrentThreadId(); +#elif defined __APPLE__ + return pthread_mach_thread_np(pthread_self()); +#else + return pthread_self(); #endif +} + +typedef struct CallbackResult { + MutexLock lock; + ConditionVariable cond; + int ready; + jobject object; +} CallbackResult; typedef struct JniLocks { MutexLock classLoadingLock; @@ -369,6 +420,8 @@ static inline JniResult to_global_ref_result(jobject ref) { FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); +FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object); + JNIEXPORT void JNICALL Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env, jobject thiz, @@ -376,3 +429,18 @@ Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env, jobject result); FFI_PLUGIN_EXPORT JniResult PortContinuation__ctor(int64_t j); + +FFI_PLUGIN_EXPORT +JniResult PortProxy__newInstance(jobject binaryName, + int64_t port, + int64_t functionPtr); + +JNIEXPORT jobject JNICALL +Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, + jobject thiz, + jlong port, + jlong threadId, + jlong functionPtr, + jobject proxy, + jstring methodDescriptor, + jobjectArray args); diff --git a/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart b/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart index 78a7ded87..e1002dd9d 100644 --- a/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart +++ b/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart @@ -12,6 +12,7 @@ // 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 import "dart:isolate" show ReceivePort; @@ -57,7 +58,8 @@ class Example extends jni.JObject { /// The returned object must be deleted after use, by calling the `delete` method. Future thinkBeforeAnswering() async { final $p = ReceivePort(); - final $c = jni.JObject.fromRef(jni.Jni.newPortContinuation($p)); + final $c = + jni.JObject.fromRef(ProtectedJniExtensions.newPortContinuation($p)); _thinkBeforeAnswering(reference, $c.reference).object; final $o = jni.JObjectPtr.fromAddress(await $p.first); final $k = const jni.JStringType().getClass().reference; diff --git a/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h b/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h index c0713af53..cbb1f7f5c 100644 --- a/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h +++ b/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h @@ -45,6 +45,7 @@ #include typedef CRITICAL_SECTION MutexLock; +typedef CONDITION_VARIABLE ConditionVariable; static inline void init_lock(MutexLock* lock) { InitializeCriticalSection(lock); @@ -58,15 +59,32 @@ static inline void release_lock(MutexLock* lock) { LeaveCriticalSection(lock); } -static inline void _destroyLock(MutexLock* lock) { +static inline void destroy_lock(MutexLock* lock) { DeleteCriticalSection(lock); } -#elif defined __DARWIN__ || defined __LINUX__ || defined __ANDROID__ || \ +static inline void init_cond(ConditionVariable* cond) { + InitializeConditionVariable(cond); +} + +static inline void signal_cond(ConditionVariable* cond) { + WakeConditionVariable(cond); +} + +static inline void wait_for(ConditionVariable* cond, MutexLock* lock) { + SleepConditionVariableCS(cond, lock, INFINITE); +} + +static inline void destroy_cond(ConditionVariable* cond) { + DeleteCriticalSection(cond); +} + +#elif defined __APPLE__ || defined __LINUX__ || defined __ANDROID__ || \ defined __GNUC__ #include typedef pthread_mutex_t MutexLock; +typedef pthread_cond_t ConditionVariable; static inline void init_lock(MutexLock* lock) { pthread_mutex_init(lock, NULL); @@ -80,15 +98,48 @@ static inline void release_lock(MutexLock* lock) { pthread_mutex_unlock(lock); } -static inline void _destroyLock(MutexLock* lock) { +static inline void destroy_lock(MutexLock* lock) { pthread_mutex_destroy(lock); } +static inline void init_cond(ConditionVariable* cond) { + pthread_cond_init(cond, NULL); +} + +static inline void signal_cond(ConditionVariable* cond) { + pthread_cond_signal(cond); +} + +static inline void wait_for(ConditionVariable* cond, MutexLock* lock) { + pthread_cond_wait(cond, lock); +} + +static inline void destroy_cond(ConditionVariable* cond) { + pthread_cond_destroy(cond); +} + #else -#error "No locking support; Possibly unsupported platform" +#error "No locking/condition variable support; Possibly unsupported platform" + +#endif +static inline uint64_t thread_id() { +#ifdef _WIN32 + return GetCurrentThreadId(); +#elif defined __APPLE__ + return pthread_mach_thread_np(pthread_self()); +#else + return pthread_self(); #endif +} + +typedef struct CallbackResult { + MutexLock lock; + ConditionVariable cond; + int ready; + jobject object; +} CallbackResult; typedef struct JniLocks { MutexLock classLoadingLock; @@ -369,6 +420,8 @@ static inline JniResult to_global_ref_result(jobject ref) { FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); +FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object); + JNIEXPORT void JNICALL Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env, jobject thiz, @@ -376,3 +429,18 @@ Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env, jobject result); FFI_PLUGIN_EXPORT JniResult PortContinuation__ctor(int64_t j); + +FFI_PLUGIN_EXPORT +JniResult PortProxy__newInstance(jobject binaryName, + int64_t port, + int64_t functionPtr); + +JNIEXPORT jobject JNICALL +Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, + jobject thiz, + jlong port, + jlong threadId, + jlong functionPtr, + jobject proxy, + jstring methodDescriptor, + jobjectArray args); diff --git a/pkgs/jnigen/example/notification_plugin/lib/notifications.dart b/pkgs/jnigen/example/notification_plugin/lib/notifications.dart index c95f3e6e8..170c7205d 100644 --- a/pkgs/jnigen/example/notification_plugin/lib/notifications.dart +++ b/pkgs/jnigen/example/notification_plugin/lib/notifications.dart @@ -16,6 +16,7 @@ // 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 import "dart:isolate" show ReceivePort; diff --git a/pkgs/jnigen/example/notification_plugin/src/dartjni.h b/pkgs/jnigen/example/notification_plugin/src/dartjni.h index c0713af53..cbb1f7f5c 100644 --- a/pkgs/jnigen/example/notification_plugin/src/dartjni.h +++ b/pkgs/jnigen/example/notification_plugin/src/dartjni.h @@ -45,6 +45,7 @@ #include typedef CRITICAL_SECTION MutexLock; +typedef CONDITION_VARIABLE ConditionVariable; static inline void init_lock(MutexLock* lock) { InitializeCriticalSection(lock); @@ -58,15 +59,32 @@ static inline void release_lock(MutexLock* lock) { LeaveCriticalSection(lock); } -static inline void _destroyLock(MutexLock* lock) { +static inline void destroy_lock(MutexLock* lock) { DeleteCriticalSection(lock); } -#elif defined __DARWIN__ || defined __LINUX__ || defined __ANDROID__ || \ +static inline void init_cond(ConditionVariable* cond) { + InitializeConditionVariable(cond); +} + +static inline void signal_cond(ConditionVariable* cond) { + WakeConditionVariable(cond); +} + +static inline void wait_for(ConditionVariable* cond, MutexLock* lock) { + SleepConditionVariableCS(cond, lock, INFINITE); +} + +static inline void destroy_cond(ConditionVariable* cond) { + DeleteCriticalSection(cond); +} + +#elif defined __APPLE__ || defined __LINUX__ || defined __ANDROID__ || \ defined __GNUC__ #include typedef pthread_mutex_t MutexLock; +typedef pthread_cond_t ConditionVariable; static inline void init_lock(MutexLock* lock) { pthread_mutex_init(lock, NULL); @@ -80,15 +98,48 @@ static inline void release_lock(MutexLock* lock) { pthread_mutex_unlock(lock); } -static inline void _destroyLock(MutexLock* lock) { +static inline void destroy_lock(MutexLock* lock) { pthread_mutex_destroy(lock); } +static inline void init_cond(ConditionVariable* cond) { + pthread_cond_init(cond, NULL); +} + +static inline void signal_cond(ConditionVariable* cond) { + pthread_cond_signal(cond); +} + +static inline void wait_for(ConditionVariable* cond, MutexLock* lock) { + pthread_cond_wait(cond, lock); +} + +static inline void destroy_cond(ConditionVariable* cond) { + pthread_cond_destroy(cond); +} + #else -#error "No locking support; Possibly unsupported platform" +#error "No locking/condition variable support; Possibly unsupported platform" + +#endif +static inline uint64_t thread_id() { +#ifdef _WIN32 + return GetCurrentThreadId(); +#elif defined __APPLE__ + return pthread_mach_thread_np(pthread_self()); +#else + return pthread_self(); #endif +} + +typedef struct CallbackResult { + MutexLock lock; + ConditionVariable cond; + int ready; + jobject object; +} CallbackResult; typedef struct JniLocks { MutexLock classLoadingLock; @@ -369,6 +420,8 @@ static inline JniResult to_global_ref_result(jobject ref) { FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); +FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object); + JNIEXPORT void JNICALL Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env, jobject thiz, @@ -376,3 +429,18 @@ Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env, jobject result); FFI_PLUGIN_EXPORT JniResult PortContinuation__ctor(int64_t j); + +FFI_PLUGIN_EXPORT +JniResult PortProxy__newInstance(jobject binaryName, + int64_t port, + int64_t functionPtr); + +JNIEXPORT jobject JNICALL +Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, + jobject thiz, + jlong port, + jlong threadId, + jlong functionPtr, + jobject proxy, + jstring methodDescriptor, + jobjectArray args); 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 614a23f71..3e5525212 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 @@ -30,6 +30,7 @@ // 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 import "dart:isolate" show ReceivePort; 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 657f68ae1..87862bacc 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 @@ -30,6 +30,7 @@ // 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 import "dart:isolate" show ReceivePort; 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 9d6fe3a33..306258cca 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 @@ -30,6 +30,7 @@ // 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 import "dart:isolate" show ReceivePort; diff --git a/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h b/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h index c0713af53..cbb1f7f5c 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h +++ b/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h @@ -45,6 +45,7 @@ #include typedef CRITICAL_SECTION MutexLock; +typedef CONDITION_VARIABLE ConditionVariable; static inline void init_lock(MutexLock* lock) { InitializeCriticalSection(lock); @@ -58,15 +59,32 @@ static inline void release_lock(MutexLock* lock) { LeaveCriticalSection(lock); } -static inline void _destroyLock(MutexLock* lock) { +static inline void destroy_lock(MutexLock* lock) { DeleteCriticalSection(lock); } -#elif defined __DARWIN__ || defined __LINUX__ || defined __ANDROID__ || \ +static inline void init_cond(ConditionVariable* cond) { + InitializeConditionVariable(cond); +} + +static inline void signal_cond(ConditionVariable* cond) { + WakeConditionVariable(cond); +} + +static inline void wait_for(ConditionVariable* cond, MutexLock* lock) { + SleepConditionVariableCS(cond, lock, INFINITE); +} + +static inline void destroy_cond(ConditionVariable* cond) { + DeleteCriticalSection(cond); +} + +#elif defined __APPLE__ || defined __LINUX__ || defined __ANDROID__ || \ defined __GNUC__ #include typedef pthread_mutex_t MutexLock; +typedef pthread_cond_t ConditionVariable; static inline void init_lock(MutexLock* lock) { pthread_mutex_init(lock, NULL); @@ -80,15 +98,48 @@ static inline void release_lock(MutexLock* lock) { pthread_mutex_unlock(lock); } -static inline void _destroyLock(MutexLock* lock) { +static inline void destroy_lock(MutexLock* lock) { pthread_mutex_destroy(lock); } +static inline void init_cond(ConditionVariable* cond) { + pthread_cond_init(cond, NULL); +} + +static inline void signal_cond(ConditionVariable* cond) { + pthread_cond_signal(cond); +} + +static inline void wait_for(ConditionVariable* cond, MutexLock* lock) { + pthread_cond_wait(cond, lock); +} + +static inline void destroy_cond(ConditionVariable* cond) { + pthread_cond_destroy(cond); +} + #else -#error "No locking support; Possibly unsupported platform" +#error "No locking/condition variable support; Possibly unsupported platform" + +#endif +static inline uint64_t thread_id() { +#ifdef _WIN32 + return GetCurrentThreadId(); +#elif defined __APPLE__ + return pthread_mach_thread_np(pthread_self()); +#else + return pthread_self(); #endif +} + +typedef struct CallbackResult { + MutexLock lock; + ConditionVariable cond; + int ready; + jobject object; +} CallbackResult; typedef struct JniLocks { MutexLock classLoadingLock; @@ -369,6 +420,8 @@ static inline JniResult to_global_ref_result(jobject ref) { FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); +FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object); + JNIEXPORT void JNICALL Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env, jobject thiz, @@ -376,3 +429,18 @@ Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env, jobject result); FFI_PLUGIN_EXPORT JniResult PortContinuation__ctor(int64_t j); + +FFI_PLUGIN_EXPORT +JniResult PortProxy__newInstance(jobject binaryName, + int64_t port, + int64_t functionPtr); + +JNIEXPORT jobject JNICALL +Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, + jobject thiz, + jlong port, + jlong threadId, + jlong functionPtr, + jobject proxy, + jstring methodDescriptor, + jobjectArray args); diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmClassVisitor.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmClassVisitor.java index 6a536d321..33fecbd5b 100644 --- a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmClassVisitor.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmClassVisitor.java @@ -8,6 +8,7 @@ import com.github.dart_lang.jnigen.apisummarizer.util.SkipException; import com.github.dart_lang.jnigen.apisummarizer.util.StreamUtil; import java.util.*; +import java.util.stream.Collectors; import org.objectweb.asm.*; import org.objectweb.asm.signature.SignatureReader; @@ -27,6 +28,9 @@ public List getVisited() { List visited = new ArrayList<>(); Stack visiting = new Stack<>(); + /// Actual access for the inner classes as originally defined. + Map actualAccess = new HashMap<>(); + public AsmClassVisitor() { super(AsmConstants.API); } @@ -42,9 +46,8 @@ public void visit( var current = new ClassDecl(); visiting.push(current); var type = Type.getObjectType(name); - current.binaryName = type.getClassName(); - current.modifiers = TypeUtils.access(access); - current.parentName = TypeUtils.parentName(type); + current.binaryName = name.replace('/', '.'); + current.modifiers = TypeUtils.access(actualAccess.getOrDefault(current.binaryName, access)); current.declKind = TypeUtils.declKind(access); current.superclass = TypeUtils.typeUsage(Type.getObjectType(superName), null); current.interfaces = @@ -56,6 +59,21 @@ public void visit( super.visit(version, access, name, signature, superName, interfaces); } + @Override + public void visitInnerClass(String name, String outerName, String innerName, int access) { + var binaryName = name.replace('/', '.'); + actualAccess.put(binaryName, access); + var alreadyVisitedInnerClass = + visited.stream() + .filter(decl -> decl.binaryName.equals(binaryName)) + .collect(Collectors.toList()); + // If the order of visit is outer first inner second. + // We still want to correct the modifiers. + if (!alreadyVisitedInnerClass.isEmpty()) { + alreadyVisitedInnerClass.get(0).modifiers = TypeUtils.access(access); + } + } + @Override public FieldVisitor visitField( int access, String name, String descriptor, String signature, Object value) { diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmMethodSignatureVisitor.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmMethodSignatureVisitor.java index 9067f9eb9..5410acfa1 100644 --- a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmMethodSignatureVisitor.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmMethodSignatureVisitor.java @@ -7,11 +7,13 @@ import com.github.dart_lang.jnigen.apisummarizer.elements.Method; import com.github.dart_lang.jnigen.apisummarizer.elements.TypeParam; import com.github.dart_lang.jnigen.apisummarizer.elements.TypeUsage; +import java.util.ArrayList; +import java.util.List; import org.objectweb.asm.signature.SignatureVisitor; public class AsmMethodSignatureVisitor extends SignatureVisitor { private final Method method; - private int paramIndex = -1; + private final List paramTypes = new ArrayList<>(); public AsmMethodSignatureVisitor(Method method) { super(AsmConstants.API); @@ -43,13 +45,22 @@ public SignatureVisitor visitInterfaceBound() { @Override public SignatureVisitor visitReturnType() { + // Visiting params finished. + // + // In case of non-static inner class constructor, there is an extra parent parameter + // at the beginning which is not accounted for by the signature. So we fill the types + // for the last [paramTypes.size()] params. + int startIndex = method.params.size() - paramTypes.size(); + for (int i = 0; i < paramTypes.size(); ++i) { + method.params.get(startIndex + i).type = paramTypes.get(i); + } return new AsmTypeUsageSignatureVisitor(method.returnType); } @Override public SignatureVisitor visitParameterType() { - paramIndex++; - return new AsmTypeUsageSignatureVisitor(method.params.get(paramIndex).type); + paramTypes.add(new TypeUsage()); + return new AsmTypeUsageSignatureVisitor(paramTypes.get(paramTypes.size() - 1)); } @Override diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmSummarizer.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmSummarizer.java index 391b83160..485c44268 100644 --- a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmSummarizer.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmSummarizer.java @@ -8,22 +8,19 @@ import com.github.dart_lang.jnigen.apisummarizer.elements.ClassDecl; import com.github.dart_lang.jnigen.apisummarizer.util.InputStreamProvider; -import java.util.ArrayList; import java.util.List; import org.objectweb.asm.ClassReader; public class AsmSummarizer { public static List run(List inputProviders) { - List parsed = new ArrayList<>(); + var visitor = new AsmClassVisitor(); for (var provider : inputProviders) { var inputStream = provider.getInputStream(); var classReader = wrapCheckedException(ClassReader::new, inputStream); - var visitor = new AsmClassVisitor(); classReader.accept(visitor, 0); - parsed.addAll(visitor.getVisited()); provider.close(); } - return parsed; + return visitor.getVisited(); } } diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmTypeUsageSignatureVisitor.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmTypeUsageSignatureVisitor.java index 3c52c1045..6ddda4546 100644 --- a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmTypeUsageSignatureVisitor.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmTypeUsageSignatureVisitor.java @@ -93,7 +93,8 @@ public SignatureVisitor visitTypeArgument(char wildcard) { @Override public void visitInnerClassType(String name) { - super.visitInnerClassType(name); - // TODO(#139) support nested generic classes + typeUsage.shorthand += "." + name; + ((TypeUsage.DeclaredType) typeUsage.type).binaryName += "$" + name; + ((TypeUsage.DeclaredType) typeUsage.type).simpleName = name; } } diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/TypeUtils.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/TypeUtils.java index 521c02d52..8f1856523 100644 --- a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/TypeUtils.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/TypeUtils.java @@ -19,14 +19,6 @@ class TypeUtils { - public static String parentName(Type type) { - var className = type.getClassName(); - if (!className.contains("$")) { - return null; - } - return className.split("\\$")[0]; - } - public static String simpleName(Type type) { var internalName = type.getInternalName(); if (type.getInternalName().length() == 1) { @@ -46,7 +38,8 @@ public static TypeUsage typeUsage(Type type, @SuppressWarnings("unused") String case OBJECT: usage.kind = TypeUsage.Kind.DECLARED; usage.type = - new TypeUsage.DeclaredType(type.getClassName(), TypeUtils.simpleName(type), null); + new TypeUsage.DeclaredType( + type.getInternalName().replace('/', '.'), TypeUtils.simpleName(type), null); break; case ARRAY: usage.kind = TypeUsage.Kind.ARRAY; diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/doclet/ElementBuilders.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/doclet/ElementBuilders.java index d0f2301c5..7ca8bb62e 100644 --- a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/doclet/ElementBuilders.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/doclet/ElementBuilders.java @@ -40,10 +40,6 @@ private void fillInFromTypeElement(TypeElement e, ClassDecl c) { throw new RuntimeException( "Unexpected element kind " + e.getKind() + " on " + c.binaryName); } - var parent = e.getEnclosingElement(); - if (parent instanceof TypeElement) { - c.parentName = env.elements.getBinaryName((TypeElement) parent).toString(); - } c.javadoc = docComment(env.trees.getDocCommentTree(e)); c.typeParams = StreamUtil.map(e.getTypeParameters(), this::typeParam); var superclass = e.getSuperclass(); diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/ClassDecl.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/ClassDecl.java index 231f0f5b9..746b91378 100644 --- a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/ClassDecl.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/ClassDecl.java @@ -27,7 +27,6 @@ public class ClassDecl { */ public String binaryName; - public String parentName; public List typeParams = new ArrayList<>(); public List methods = new ArrayList<>(); public List fields = new ArrayList<>(); diff --git a/pkgs/jnigen/lib/src/bindings/c_generator.dart b/pkgs/jnigen/lib/src/bindings/c_generator.dart index dedef7666..79b07c8b6 100644 --- a/pkgs/jnigen/lib/src/bindings/c_generator.dart +++ b/pkgs/jnigen/lib/src/bindings/c_generator.dart @@ -11,72 +11,6 @@ import '../util/find_package.dart'; import '../util/string_util.dart'; import 'visitor.dart'; -/// JVM representation of type signatures. -/// -/// https://docs.oracle.com/en/java/javase/18/docs/specs/jni/types.html#type-signatures -class Descriptor extends TypeVisitor { - const Descriptor(); - - @override - String visitArrayType(ArrayType node) { - final inner = node.type.accept(this); - return '[$inner'; - } - - @override - String visitDeclaredType(DeclaredType node) { - final internalName = node.binaryName.replaceAll('.', '/'); - return 'L$internalName;'; - } - - @override - String visitPrimitiveType(PrimitiveType node) { - return node.signature; - } - - @override - String visitTypeVar(TypeVar node) { - // It should be possible to compute the erasure of a type - // in parser itself. - // TODO(#23): Use erasure of the type variable here. - // This is just a (wrong) placeholder - return super.visitTypeVar(node); - } - - @override - String visitWildcard(Wildcard node) { - final extendsBound = node.extendsBound?.accept(this); - return extendsBound ?? 'Ljava/lang/Object;'; - } - - @override - String visitNonPrimitiveType(ReferredType node) { - return "Ljava/lang/Object;"; - } -} - -/// Generates JNI Method signatures. -/// -/// https://docs.oracle.com/en/java/javase/18/docs/specs/jni/types.html#type-signatures -/// Also see: [Descriptor] -class MethodSignature extends Visitor { - const MethodSignature(); - - @override - String visit(Method node) { - final s = StringBuffer(); - s.write('('); - s.write(node.params - .map((param) => param.type) - .accept(const Descriptor()) - .join()); - s.write(')'); - final returnType = node.returnType.accept(const Descriptor()); - s.write(returnType); - return s.toString(); - } -} - class CFieldName extends Visitor { const CFieldName(); @@ -255,7 +189,7 @@ class _CMethodGenerator extends Visitor { if (!node.isCtor && !node.isStatic) 'jobject self_', ...node.params.accept(const _CParamGenerator(addReturnType: true)), ].join(','); - final jniSignature = node.accept(const MethodSignature()); + final jniSignature = node.descriptor; final ifStaticMethodID = node.isStatic ? 'static_' : ''; var javaReturnType = node.returnType.type; @@ -357,7 +291,7 @@ $cReturnType ${cMethodPrefix}_$fieldNameInC($formalArgs) { $_loadEnvCall ${node.classDecl.accept(_CLoadClassGenerator())} load_${ifStaticField}field($classVar, &$fieldVar, "$fieldName", - "${node.type.accept(const Descriptor())}"); + "${node.type.descriptor}"); $accessorStatements } diff --git a/pkgs/jnigen/lib/src/bindings/dart_generator.dart b/pkgs/jnigen/lib/src/bindings/dart_generator.dart index 2854e6be4..3db7c0bc7 100644 --- a/pkgs/jnigen/lib/src/bindings/dart_generator.dart +++ b/pkgs/jnigen/lib/src/bindings/dart_generator.dart @@ -7,6 +7,7 @@ import 'dart:io'; import 'package:meta/meta.dart'; import '../config/config.dart'; +import '../config/experiments.dart'; import '../elements/elements.dart'; import '../logging/logging.dart'; import '../util/string_util.dart'; @@ -33,6 +34,7 @@ const _voidPointer = '$_ffi.Pointer<$_ffi.Void>'; const _typeParamPrefix = '\$'; // Misc. +const _protectedExtension = 'ProtectedJniExtensions'; const _classRef = '_class.reference'; const _env = '$_jni.Jni.env'; const _accessors = '$_jni.Jni.accessors'; @@ -128,7 +130,7 @@ class DartGenerator extends Visitor> { // Auto-generated initialization code. final $_ffi.Pointer Function(String sym) $_lookup = - ProtectedJniExtensions.initGeneratedLibrary("${config.outputConfig.cConfig!.libraryName}"); + $_protectedExtension.initGeneratedLibrary("${config.outputConfig.cConfig!.libraryName}"); '''; @@ -155,6 +157,7 @@ import "package:jni/jni.dart" as jni; // 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 '''; @@ -399,6 +402,119 @@ class $name$typeParamsDef extends $superName { method.accept(methodGenerator); } + // Experimental: Interface implementation + if (node.declKind == DeclKind.interfaceKind && + (config.experiments?.contains(Experiment.interfaceImplementation) ?? + false)) { + s.write(''' + /// Maps a specific port to the implemented methods. + static final Map> _\$methods = {}; + + /// Maps a specific port to the type parameters. + static final Map> _\$types = {}; + + ReceivePort? _\$p; + + static final Finalizer _\$finalizer = Finalizer((\$p) { + _\$methods.remove(\$p.sendPort.nativePort); + _\$types.remove(\$p.sendPort.nativePort); + \$p.close(); + }); + + @override + void delete() { + _\$methods.remove(_\$p?.sendPort.nativePort); + _\$types.remove(_\$p?.sendPort.nativePort); + _\$p?.close(); + _\$finalizer.detach(this); + super.delete(); + } + + static jni.JObjectPtr _\$invoke( + int port, + jni.JObjectPtr descriptor, + jni.JObjectPtr args, + ) { + return _\$invokeMethod( + port, + \$MethodInvocation.fromAddresses( + 0, + descriptor.address, + args.address, + ), + ); + } + + static final ffi.Pointer< + ffi.NativeFunction< + jni.JObjectPtr Function( + ffi.Uint64, jni.JObjectPtr, jni.JObjectPtr)>> + _\$invokePointer = ffi.Pointer.fromFunction(_\$invoke); + + static ffi.Pointer _\$invokeMethod( + int \$p, + \$MethodInvocation \$i, + ) { + final \$d = \$i.methodDescriptor.toDartString(deleteOriginal: true); + final \$a = \$i.args; + '''); + final proxyMethodIf = _InterfaceMethodIf(resolver, s); + for (final method in node.methods) { + method.accept(proxyMethodIf); + } + s.write(''' + return jni.nullptr; + } + + factory $name.implement( +'''); + final typeClassesCall = + typeParams.map((typeParam) => '$typeParam,').join(_newLine(depth: 3)); + s.write(_encloseIfNotEmpty( + '{', + [ + ...typeParams + .map((typeParam) => 'required $_jType<\$$typeParam> $typeParam,'), + ...node.methods.accept(_InterfaceImplementArg(resolver)) + ].join(_newLine(depth: 2)), + '}', + )); + + s.write(''' + ) { + final \$p = ReceivePort(); + final \$x = $name.fromRef( + $typeClassesCall + $_protectedExtension.newPortProxy( + r"${node.binaryName}", + \$p, + _\$invokePointer, + ), + ).._\$p = \$p; + final \$a = \$p.sendPort.nativePort; + _\$types[\$a] = {}; + _\$methods[\$a] = {}; +'''); + final typeFiller = _InterfaceTypesFiller(s); + for (final typeParam in node.allTypeParams) { + typeParam.accept(typeFiller); + } + final methodFiller = _InterfaceMethodsFiller(s); + for (final method in node.methods) { + method.accept(methodFiller); + } + s.write(''' + _\$finalizer.attach(\$x, \$p, detach: \$x); + \$p.listen((\$m) { + final \$i = \$MethodInvocation.fromMessage(\$m); + final \$r = _\$invokeMethod(\$p.sendPort.nativePort, \$i); + ProtectedJniExtensions.returnResult(\$i.result, \$r); + }); + return \$x; + } + '''); + } + // End of Class definition s.writeln('}'); @@ -491,7 +607,7 @@ class _TypeGenerator extends TypeVisitor { String visitArrayType(ArrayType node) { final innerType = node.type; if (innerType.kind == Kind.primitive) { - return '$_jArray<$_jni.${(innerType.type as PrimitiveType).jniType}>'; + return '$_jArray<$_jni.j${(innerType.type as PrimitiveType).name}>'; } return '$_jArray<${innerType.accept(this)}>'; } @@ -565,14 +681,32 @@ class _TypeClass { /// Generates the type class. class _TypeClassGenerator extends TypeVisitor<_TypeClass> { final bool isConst; + + /// Whether or not to return the equivalent boxed type class for primitives. + /// Only for interface implemetation. + final bool boxPrimitives; + + /// Whether or not to find the correct type variable from the static map. + /// Only for interface implemetation. + final bool typeVarFromMap; + final Resolver resolver; - _TypeClassGenerator(this.resolver, {this.isConst = true}); + _TypeClassGenerator( + this.resolver, { + this.isConst = true, + this.boxPrimitives = false, + this.typeVarFromMap = false, + }); @override _TypeClass visitArrayType(ArrayType node) { - final innerTypeClass = - node.type.accept(_TypeClassGenerator(resolver, isConst: false)); + final innerTypeClass = node.type.accept(_TypeClassGenerator( + resolver, + isConst: false, + boxPrimitives: boxPrimitives, + typeVarFromMap: typeVarFromMap, + )); final ifConst = innerTypeClass.canBeConst && isConst ? 'const ' : ''; return _TypeClass( '$ifConst${_jArray}Type(${innerTypeClass.name})', @@ -587,8 +721,12 @@ class _TypeClassGenerator extends TypeVisitor<_TypeClass> { .toList(); // The ones that are declared. - final definedTypeClasses = - node.params.accept(_TypeClassGenerator(resolver, isConst: false)); + final definedTypeClasses = node.params.accept(_TypeClassGenerator( + resolver, + isConst: false, + boxPrimitives: boxPrimitives, + typeVarFromMap: typeVarFromMap, + )); // Can be const if all the type parameters are defined and each of them are // also const. @@ -628,11 +766,15 @@ class _TypeClassGenerator extends TypeVisitor<_TypeClass> { @override _TypeClass visitPrimitiveType(PrimitiveType node) { final ifConst = isConst ? 'const ' : ''; - return _TypeClass('$ifConst$_jni.${node.jniType}Type()', true); + final name = boxPrimitives ? 'J${node.boxedName}' : 'j${node.name}'; + return _TypeClass('$ifConst$_jni.${name}Type()', true); } @override _TypeClass visitTypeVar(TypeVar node) { + if (typeVarFromMap) { + return _TypeClass('_\$types[\$p]!["${node.name}"]!', false); + } return _TypeClass(node.name, false); } @@ -823,7 +965,7 @@ class _FieldGenerator extends Visitor { void writeDartOnlyAccessor(Field node) { final name = node.finalName; final ifStatic = node.isStatic ? 'Static' : ''; - final descriptor = node.type.accept(const Descriptor()); + final descriptor = node.type.descriptor; s.write(''' static final _id_$name = $_accessors.get${ifStatic}FieldIDOf( @@ -950,10 +1092,10 @@ class _MethodGenerator extends Visitor { void writeDartOnlyAccessor(Method node) { final name = node.finalName; final ifStatic = node.isStatic ? 'Static' : ''; - final signature = node.accept(const MethodSignature()); + final descriptor = node.descriptor; s.write(''' static final _id_$name = $_accessors.get${ifStatic}MethodIDOf( - $_classRef, r"${node.name}", r"$signature"); + $_classRef, r"${node.name}", r"$descriptor"); '''); } @@ -1110,7 +1252,7 @@ class _MethodGenerator extends Visitor { s.write('''async { $typeInference final \$p = ReceivePort(); - final \$c = $_jObject.fromRef($_jni.Jni.newPortContinuation(\$p)); + final \$c = $_jObject.fromRef($_protectedExtension.newPortContinuation(\$p)); $callExpr; final \$o = $_jPointer.fromAddress(await \$p.first); final \$k = $returnTypeClass.getClass().reference; @@ -1367,3 +1509,129 @@ class _TypeVarLocator extends TypeVisitor>> { return {}; } } + +/// The argument for .implement method of interfaces. +class _InterfaceImplementArg extends Visitor { + final Resolver resolver; + + _InterfaceImplementArg(this.resolver); + + @override + String visit(Method node) { + final returnType = node.returnType.accept(_TypeGenerator(resolver)); + final name = node.finalName; + final args = node.params.accept(_ParamDef(resolver)).join(', '); + return 'required $returnType Function($args) $name,'; + } +} + +/// The if statement to check which method has been called from the proxy class. +class _InterfaceMethodIf extends Visitor { + final Resolver resolver; + final StringSink s; + + _InterfaceMethodIf(this.resolver, this.s); + + @override + void visit(Method node) { + final signature = node.javaSig; + final saveResult = node.returnType.name == 'void' ? '' : 'final \$r = '; + s.write(''' + if (\$d == r"$signature") { + ${saveResult}_\$methods[\$p]![\$d]!( +'''); + for (var i = 0; i < node.params.length; ++i) { + node.params[i].accept(_InterfaceParamCast(resolver, s, paramIndex: i)); + } + const returnBox = _InterfaceReturnBox(); + s.write(''' + ); + return ${node.returnType.accept(returnBox)}; + } +'''); + } +} + +/// Generates casting to the correct parameter type from the list of JObject +/// arguments received from the call to the proxy class. +class _InterfaceParamCast extends Visitor { + final Resolver resolver; + final StringSink s; + final int paramIndex; + + _InterfaceParamCast( + this.resolver, + this.s, { + required this.paramIndex, + }); + + @override + void visit(Param node) { + final typeClass = node.type + .accept(_TypeClassGenerator( + resolver, + boxPrimitives: true, + typeVarFromMap: true, + )) + .name; + s.write('\$a[$paramIndex].castTo($typeClass, deleteOriginal: true)'); + if (node.type.kind == Kind.primitive) { + // Convert to Dart type. + final name = (node.type.type as PrimitiveType).name; + s.write('.${name}Value(deleteOriginal: true)'); + } + s.writeln(','); + } +} + +/// Boxes the returned primitive value into the correct Boxed type. +/// Only returns the reference for non primitive types. +/// Returns null for void. +/// +/// For example `$r.toJInteger().reference` when the return type is `integer`. +class _InterfaceReturnBox extends TypeVisitor { + const _InterfaceReturnBox(); + + @override + String visitNonPrimitiveType(ReferredType node) { + return '\$r.reference'; + } + + @override + String visitPrimitiveType(PrimitiveType node) { + if (node.name == 'void') { + return '$_jni.nullptr'; + } + return '$_jni.J${node.boxedName}(\$r).reference'; + } +} + +/// Fills the static _$types map with the correct type classes for the given +/// port. +class _InterfaceTypesFiller extends Visitor { + final StringSink s; + + _InterfaceTypesFiller(this.s); + + @override + void visit(TypeParam node) { + s.write(''' + _\$types[\$a]!["${node.name}"] = ${node.name}; +'''); + } +} + +/// Fills the static _$method map with the correct callbacks for the given +/// port. +class _InterfaceMethodsFiller extends Visitor { + final StringSink s; + + _InterfaceMethodsFiller(this.s); + + @override + void visit(Method node) { + s.write(''' + _\$methods[\$a]![r"${node.javaSig}"] = ${node.finalName}; +'''); + } +} diff --git a/pkgs/jnigen/lib/src/bindings/descriptor.dart b/pkgs/jnigen/lib/src/bindings/descriptor.dart new file mode 100644 index 000000000..f7d774ae0 --- /dev/null +++ b/pkgs/jnigen/lib/src/bindings/descriptor.dart @@ -0,0 +1,115 @@ +import '../elements/elements.dart'; +import 'visitor.dart'; + +/// Adds the type and method descriptor to all methods in all of the classes. +/// +/// ASM already fills the descriptor field for methods but doclet does not. +class Descriptor extends Visitor { + const Descriptor(); + + @override + void visit(Classes node) { + for (final classDecl in node.decls.values) { + classDecl.accept(const _ClassDescriptor()); + } + } +} + +class _ClassDescriptor extends Visitor { + const _ClassDescriptor(); + + @override + void visit(ClassDecl node) { + final methodDescriptor = MethodDescriptor(node.allTypeParams); + for (final method in node.methods) { + method.descriptor ??= method.accept(methodDescriptor); + } + final typeDescriptor = TypeDescriptor(node.allTypeParams); + for (final field in node.fields) { + field.type.descriptor = field.type.accept(typeDescriptor); + } + for (final interface in node.interfaces) { + interface.descriptor = interface.accept(typeDescriptor); + } + } +} + +/// Generates JNI Method descriptor. +/// +/// https://docs.oracle.com/en/java/javase/18/docs/specs/jni/types.html#type-signatures +/// Also see: [TypeDescriptor] +class MethodDescriptor extends Visitor { + final List typeParams; + + MethodDescriptor(this.typeParams); + + @override + String visit(Method node) { + final s = StringBuffer(); + final typeParamsIncludingThis = [...typeParams, ...node.typeParams]; + final typeDescriptor = TypeDescriptor(typeParamsIncludingThis); + s.write('('); + for (final param in node.params) { + final desc = param.type.accept(typeDescriptor); + param.type.descriptor = desc; + s.write(desc); + } + s.write(')'); + final returnTypeDesc = + node.returnType.accept(TypeDescriptor(typeParamsIncludingThis)); + node.returnType.descriptor = returnTypeDesc; + s.write(returnTypeDesc); + return s.toString(); + } +} + +/// JVM representation of type signatures. +/// +/// https://docs.oracle.com/en/java/javase/18/docs/specs/jni/types.html#type-signatures +class TypeDescriptor extends TypeVisitor { + final List typeParams; + + TypeDescriptor(this.typeParams); + + @override + String visitArrayType(ArrayType node) { + final inner = node.type.accept(this); + return '[$inner'; + } + + @override + String visitDeclaredType(DeclaredType node) { + final internalName = node.binaryName.replaceAll('.', '/'); + return 'L$internalName;'; + } + + @override + String visitPrimitiveType(PrimitiveType node) { + return node.signature; + } + + @override + String visitTypeVar(TypeVar node) { + final typeParam = typeParams.lastWhere( + (typeParam) => typeParam.name == node.name, + orElse: () { + print('${node.name} was not found!'); + throw 'error'; + }, + ); + return typeParam.bounds.isEmpty + ? super.visitTypeVar(node) + : typeParam.bounds.first.accept(this); + } + + @override + String visitWildcard(Wildcard node) { + final extendsBound = node.extendsBound?.accept(this); + return extendsBound ?? super.visitWildcard(node); + } + + @override + String visitNonPrimitiveType(ReferredType node) { + return 'Ljava/lang/Object;'; + } +} diff --git a/pkgs/jnigen/lib/src/bindings/unnester.dart b/pkgs/jnigen/lib/src/bindings/unnester.dart index 00522051a..d9323df91 100644 --- a/pkgs/jnigen/lib/src/bindings/unnester.dart +++ b/pkgs/jnigen/lib/src/bindings/unnester.dart @@ -10,6 +10,8 @@ import 'visitor.dart'; /// Nested classes are not supported in Dart. So this "unnests" them into /// separate classes. class Unnester extends Visitor { + const Unnester(); + @override void visit(node) { final classProcessor = _ClassUnnester(); @@ -53,9 +55,14 @@ class _MethodUnnester extends Visitor { void visit(Method node) { assert(!node.classDecl.isStatic); assert(node.classDecl.isNested); - if (node.isCtor || node.isStatic) { + // TODO(#319): Unnest the methods in APISummarizer itself. + // For now the nullity of [node.descriptor] identifies if the doclet + // backend was used and the method would potentially need "unnesting". + if ((node.isCtor || node.isStatic) && node.descriptor == null) { // Non-static nested classes take an instance of their outer class as the - // first parameter. This is not accounted for by the summarizer, so we + // first parameter. + // + // This is not accounted for by the **doclet** summarizer, so we // manually add it as the first parameter. final parentTypeParamCount = node.classDecl.allTypeParams.length - node.classDecl.typeParams.length; diff --git a/pkgs/jnigen/lib/src/config/config_types.dart b/pkgs/jnigen/lib/src/config/config_types.dart index c1d166bff..8004cee46 100644 --- a/pkgs/jnigen/lib/src/config/config_types.dart +++ b/pkgs/jnigen/lib/src/config/config_types.dart @@ -13,6 +13,7 @@ import '../elements/elements.dart'; import '../logging/logging.dart'; import '../util/find_package.dart'; import 'config_exception.dart'; +import 'experiments.dart'; import 'filters.dart'; import 'yaml_reader.dart'; @@ -117,13 +118,39 @@ class AndroidSdkConfig { String? androidExample; } +extension on String { + /// Converts the enum name from camelCase to snake_case. + String toSnakeCase() { + return splitMapJoin( + RegExp('[A-Z]'), + onMatch: (p) => '_${p[0]!.toLowerCase()}', + ); + } +} + +extension on Iterable { + Map valuesMap() { + return Map.fromEntries(map((e) => MapEntry(e.name.toSnakeCase(), e))); + } +} + +T _getEnumValueFromString( + Map values, String? name, T defaultVal) { + if (name == null) return defaultVal; + final value = values[name]; + if (value == null) { + throw ConfigException('Got: $name, allowed: ${values.keys}'); + } + return value; +} + /// Additional options to pass to the summary generator component. class SummarizerOptions { SummarizerOptions( {this.extraArgs = const [], this.workingDirectory, this.backend}); List extraArgs; Uri? workingDirectory; - String? backend; + SummarizerBackend? backend; } /// Backend for reading summary of Java libraries @@ -135,14 +162,15 @@ enum SummarizerBackend { doclet, } -T _getEnumValueFromString( - Map values, String? name, T defaultVal) { - if (name == null) return defaultVal; - final value = values[name]; - if (value == null) { - throw ConfigException('Got: $name, allowed: ${values.keys}'); - } - return value; +SummarizerBackend? getSummarizerBackend( + String? name, + SummarizerBackend? defaultVal, +) { + return _getEnumValueFromString( + SummarizerBackend.values.valuesMap(), + name, + defaultVal, + ); } void _ensureIsDirectory(String name, Uri path) { @@ -155,31 +183,27 @@ void _ensureIsDirectory(String name, Uri path) { enum OutputStructure { packageStructure, singleFile } OutputStructure getOutputStructure(String? name, OutputStructure defaultVal) { - const values = { - 'package_structure': OutputStructure.packageStructure, - 'single_file': OutputStructure.singleFile, - }; - return _getEnumValueFromString(values, name, defaultVal); + return _getEnumValueFromString( + OutputStructure.values.valuesMap(), + name, + defaultVal, + ); } enum BindingsType { cBased, dartOnly } extension GetConfigString on BindingsType { - static const _configStrings = { - BindingsType.cBased: 'c_based', - BindingsType.dartOnly: 'dart_only', - }; String getConfigString() { - return _configStrings[this]!; + return name.toSnakeCase(); } } BindingsType getBindingsType(String? name, BindingsType defaultVal) { - const values = { - 'c_based': BindingsType.cBased, - 'dart_only': BindingsType.dartOnly, - }; - return _getEnumValueFromString(values, name, defaultVal); + return _getEnumValueFromString( + BindingsType.values.valuesMap(), + name, + defaultVal, + ); } class CCodeOutputConfig { @@ -296,6 +320,7 @@ class Config { Config({ required this.outputConfig, required this.classes, + this.experiments, this.exclude, this.sourcePath, this.classPath, @@ -324,6 +349,8 @@ class Config { /// name suffix is `.class`. List classes; + Set? experiments; + /// Methods and fields to be excluded from generated bindings. final BindingExclusions? exclude; @@ -351,7 +378,7 @@ class Config { final MavenDownloads? mavenDownloads; /// Additional options for the summarizer component. - final SummarizerOptions? summarizerOptions; + SummarizerOptions? summarizerOptions; /// List of dependencies. final List? imports; @@ -415,6 +442,7 @@ class Config { ); } final classDecl = ClassDecl( + declKind: DeclKind.classKind, binaryName: binaryName, ) ..path = '$importPath/$filePath' @@ -535,7 +563,7 @@ class Config { classes: must(prov.getStringList, [], _Props.classes), summarizerOptions: SummarizerOptions( extraArgs: prov.getStringList(_Props.summarizerArgs) ?? const [], - backend: prov.getString(_Props.backend), + backend: getSummarizerBackend(prov.getString(_Props.backend), null), workingDirectory: prov.getPath(_Props.summarizerWorkingDir), ), exclude: BindingExclusions( @@ -568,6 +596,12 @@ class Config { : null, ), preamble: prov.getString(_Props.preamble), + experiments: prov + .getStringList(_Props.experiments) + ?.map( + (e) => Experiment.fromString(e), + ) + .toSet(), imports: prov.getPathList(_Props.import), mavenDownloads: prov.hasValue(_Props.mavenDownloads) ? MavenDownloads( @@ -632,6 +666,7 @@ class _Props { static const excludeMethods = '$exclude.methods'; static const excludeFields = '$exclude.fields'; + static const experiments = 'enable_experiment'; static const import = 'import'; static const outputConfig = 'output'; static const bindingsType = '$outputConfig.bindings_type'; diff --git a/pkgs/jnigen/lib/src/config/experiments.dart b/pkgs/jnigen/lib/src/config/experiments.dart new file mode 100644 index 000000000..d0eb39dd6 --- /dev/null +++ b/pkgs/jnigen/lib/src/config/experiments.dart @@ -0,0 +1,38 @@ +// 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. + +class Experiment { + static const available = [ + interfaceImplementation, + ]; + + static const interfaceImplementation = Experiment( + name: 'interface_implementation', + description: 'Enables generation of machinery for ' + 'implementing Java interfaces in Dart.', + isExpired: false, + ); + + final String name; + final String description; + final bool isExpired; + + const Experiment({ + required this.name, + required this.description, + required this.isExpired, + }); + + factory Experiment.fromString(String s) { + final search = available.where((element) => element.name == s); + if (search.isEmpty) { + throw 'The experiment $s is not available in this version.'; + } + final result = search.single; + if (result.isExpired) { + throw 'The experiment $s can no longer be used in this version. '; + } + return result; + } +} diff --git a/pkgs/jnigen/lib/src/elements/elements.dart b/pkgs/jnigen/lib/src/elements/elements.dart index ceaee017c..020f05dbf 100644 --- a/pkgs/jnigen/lib/src/elements/elements.dart +++ b/pkgs/jnigen/lib/src/elements/elements.dart @@ -57,9 +57,9 @@ class ClassDecl extends ClassMember implements Element { ClassDecl({ this.annotations = const [], this.javadoc, + required this.declKind, this.modifiers = const {}, required this.binaryName, - this.parentName, this.typeParams = const [], this.methods = const [], this.fields = const [], @@ -77,8 +77,8 @@ class ClassDecl extends ClassMember implements Element { final List annotations; final KotlinClass? kotlinClass; final JavaDocComment? javadoc; + final DeclKind declKind; final String binaryName; - final String? parentName; List typeParams; List methods; List fields; @@ -171,7 +171,13 @@ class ClassDecl extends ClassMember implements Element { bool get isObject => superCount == 0; - bool get isNested => parentName != null; + @JsonKey(includeFromJson: false) + late final String? parentName = binaryName.contains(r'$') + ? binaryName.splitMapJoin(RegExp(r'\$[^$]+$'), onMatch: (_) => '') + : null; + + @JsonKey(includeFromJson: false) + late final isNested = parentName != null; } @JsonEnum() @@ -206,10 +212,14 @@ class TypeUsage { @JsonKey(name: "type") final Map typeJson; - /// Populated by in [TypeUsage.fromJson]. + /// Populated by [TypeUsage.fromJson]. @JsonKey(includeFromJson: false) late final ReferredType type; + /// Populated by [Descriptor]. + @JsonKey(includeFromJson: false) + late String descriptor; + String get name => type.name; // Since json_serializable doesn't directly support union types, @@ -255,7 +265,7 @@ class PrimitiveType extends ReferredType { name: 'byte', signature: 'B', dartType: 'int', - jniType: 'jbyte', + boxedName: 'Byte', cType: 'int8_t', ffiType: 'Int8', ), @@ -263,7 +273,7 @@ class PrimitiveType extends ReferredType { name: 'short', signature: 'S', dartType: 'int', - jniType: 'jshort', + boxedName: 'Short', cType: 'int16_t', ffiType: 'Int16', ), @@ -271,7 +281,7 @@ class PrimitiveType extends ReferredType { name: 'char', signature: 'C', dartType: 'int', - jniType: 'jchar', + boxedName: 'Character', cType: 'uint16_t', ffiType: 'Uint16', ), @@ -279,7 +289,7 @@ class PrimitiveType extends ReferredType { name: 'int', signature: 'I', dartType: 'int', - jniType: 'jint', + boxedName: 'Integer', cType: 'int32_t', ffiType: 'Int32', ), @@ -287,7 +297,7 @@ class PrimitiveType extends ReferredType { name: 'long', signature: 'J', dartType: 'int', - jniType: 'jlong', + boxedName: 'Long', cType: 'int64_t', ffiType: 'Int64', ), @@ -295,7 +305,7 @@ class PrimitiveType extends ReferredType { name: 'float', signature: 'F', dartType: 'double', - jniType: 'jfloat', + boxedName: 'Float', cType: 'float', ffiType: 'Float', ), @@ -303,7 +313,7 @@ class PrimitiveType extends ReferredType { name: 'double', signature: 'D', dartType: 'double', - jniType: 'jdouble', + boxedName: 'Double', cType: 'double', ffiType: 'Double', ), @@ -311,7 +321,7 @@ class PrimitiveType extends ReferredType { name: 'boolean', signature: 'Z', dartType: 'bool', - jniType: 'jboolean', + boxedName: 'Boolean', cType: 'uint8_t', ffiType: 'Uint8', ), @@ -319,7 +329,7 @@ class PrimitiveType extends ReferredType { name: 'void', signature: 'V', dartType: 'void', - jniType: 'jvoid', // Never used + boxedName: 'Void', // Not used. cType: 'void', ffiType: 'Void', ), @@ -329,7 +339,7 @@ class PrimitiveType extends ReferredType { required this.name, required this.signature, required this.dartType, - required this.jniType, + required this.boxedName, required this.cType, required this.ffiType, }); @@ -339,7 +349,7 @@ class PrimitiveType extends ReferredType { final String signature; final String dartType; - final String jniType; + final String boxedName; final String cType; final String ffiType; @@ -466,7 +476,8 @@ class Method extends ClassMember implements Element { /// Can be used to match with [KotlinFunction]'s descriptor. /// /// Can create a unique signature in combination with [name]. - final String? descriptor; + /// Populated either by the ASM backend or [Descriptor]. + String? descriptor; /// The [ClassDecl] where this method is defined. /// @@ -489,12 +500,7 @@ class Method extends ClassMember implements Element { TypeUsage? asyncReturnType; @JsonKey(includeFromJson: false) - late String javaSig = _javaSig(); - - String _javaSig() { - final paramNames = params.map((p) => p.type.name).join(', '); - return '${returnType.name} $name($paramNames)'; - } + late final String javaSig = '$name$descriptor'; bool get isCtor => name == ''; diff --git a/pkgs/jnigen/lib/src/elements/elements.g.dart b/pkgs/jnigen/lib/src/elements/elements.g.dart index 4531342ec..dcd35dd38 100644 --- a/pkgs/jnigen/lib/src/elements/elements.g.dart +++ b/pkgs/jnigen/lib/src/elements/elements.g.dart @@ -14,12 +14,12 @@ ClassDecl _$ClassDeclFromJson(Map json) => ClassDecl( javadoc: json['javadoc'] == null ? null : JavaDocComment.fromJson(json['javadoc'] as Map), + declKind: $enumDecode(_$DeclKindEnumMap, json['declKind']), modifiers: (json['modifiers'] as List?) ?.map((e) => e as String) .toSet() ?? const {}, binaryName: json['binaryName'] as String, - parentName: json['parentName'] as String?, typeParams: (json['typeParams'] as List?) ?.map((e) => TypeParam.fromJson(e as Map)) .toList() ?? @@ -48,6 +48,12 @@ ClassDecl _$ClassDeclFromJson(Map json) => ClassDecl( : KotlinClass.fromJson(json['kotlinClass'] as Map), ); +const _$DeclKindEnumMap = { + DeclKind.classKind: 'CLASS', + DeclKind.interfaceKind: 'INTERFACE', + DeclKind.enumKind: 'ENUM', +}; + TypeUsage _$TypeUsageFromJson(Map json) => TypeUsage( shorthand: json['shorthand'] as String, kind: $enumDecode(_$KindEnumMap, json['kind']), diff --git a/pkgs/jnigen/lib/src/generate_bindings.dart b/pkgs/jnigen/lib/src/generate_bindings.dart index 174828eb3..883ca8575 100644 --- a/pkgs/jnigen/lib/src/generate_bindings.dart +++ b/pkgs/jnigen/lib/src/generate_bindings.dart @@ -7,6 +7,7 @@ import 'dart:convert'; import 'bindings/c_generator.dart'; import 'bindings/dart_generator.dart'; +import 'bindings/descriptor.dart'; import 'bindings/excluder.dart'; import 'bindings/kotlin_processor.dart'; import 'bindings/linker.dart'; @@ -39,7 +40,8 @@ Future generateJniBindings(Config config) async { classes.accept(Excluder(config)); classes.accept(KotlinProcessor()); await classes.accept(Linker(config)); - classes.accept(Unnester()); + classes.accept(const Unnester()); + classes.accept(const Descriptor()); classes.accept(Renamer(config)); final cBased = config.outputConfig.bindingsType == BindingsType.cBased; diff --git a/pkgs/jnigen/lib/src/summary/summary.dart b/pkgs/jnigen/lib/src/summary/summary.dart index 09c13f5c8..170627582 100644 --- a/pkgs/jnigen/lib/src/summary/summary.dart +++ b/pkgs/jnigen/lib/src/summary/summary.dart @@ -44,11 +44,7 @@ class SummarizerCommand { this.workingDirectory, this.backend, }) : sourcePaths = sourcePath ?? [], - classPaths = classPath ?? [] { - if (backend != null && !{'asm', 'doclet'}.contains(backend)) { - throw ArgumentError('Supported backends: asm, doclet'); - } - } + classPaths = classPath ?? []; static const sourcePathsOption = '-s'; static const classPathsOption = '-c'; @@ -60,7 +56,7 @@ class SummarizerCommand { List classes; Uri? workingDirectory; - String? backend; + SummarizerBackend? backend; void addSourcePaths(List paths) { sourcePaths.addAll(paths); @@ -91,7 +87,7 @@ class SummarizerCommand { _addPathParam(args, sourcePathsOption, sourcePaths); _addPathParam(args, classPathsOption, classPaths); if (backend != null) { - args.addAll(['--backend', backend!]); + args.addAll(['--backend', backend!.name]); } args.addAll(extraArgs); args.addAll(classes); diff --git a/pkgs/jnigen/pubspec.yaml b/pkgs/jnigen/pubspec.yaml index ee7043086..07be3c818 100644 --- a/pkgs/jnigen/pubspec.yaml +++ b/pkgs/jnigen/pubspec.yaml @@ -3,7 +3,7 @@ # BSD-style license that can be found in the LICENSE file. name: jnigen -version: 0.6.0-dev.1 +version: 0.6.0-wip.2 description: Experimental generator for FFI+JNI bindings. repository: https://github.com/dart-lang/jnigen/tree/main/jnigen diff --git a/pkgs/jnigen/test/config_test.dart b/pkgs/jnigen/test/config_test.dart index 4b6617b35..ae2f9871e 100644 --- a/pkgs/jnigen/test/config_test.dart +++ b/pkgs/jnigen/test/config_test.dart @@ -35,6 +35,7 @@ void expectConfigsAreEqual(Config a, Config b) { equals(b.outputConfig.symbolsConfig?.path), reason: "symbolsRoot"); expect(a.sourcePath, equals(b.sourcePath), reason: "sourcePath"); + expect(a.experiments, equals(b.experiments), reason: "experiments"); expect(a.classPath, equals(b.classPath), reason: "classPath"); expect(a.preamble, equals(b.preamble), reason: "preamble"); final am = a.mavenDownloads; diff --git a/pkgs/jnigen/test/descriptor_test.dart b/pkgs/jnigen/test/descriptor_test.dart new file mode 100644 index 000000000..41ac58cf5 --- /dev/null +++ b/pkgs/jnigen/test/descriptor_test.dart @@ -0,0 +1,43 @@ +// 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:jnigen/src/bindings/descriptor.dart'; +import 'package:jnigen/src/bindings/linker.dart'; +import 'package:jnigen/src/bindings/unnester.dart'; +import 'package:jnigen/src/config/config_types.dart'; +import 'package:jnigen/src/summary/summary.dart'; +import 'package:test/test.dart'; + +import 'simple_package_test/generate.dart' as simple_package_test; +import 'kotlin_test/generate.dart' as kotlin_test; +import 'jackson_core_test/generate.dart' as jackson_core_test; +import 'test_util/test_util.dart'; + +void main() { + checkLocallyBuiltDependencies(); + test('Method descriptor generation', timeout: const Timeout.factor(3), + () async { + final configGetters = [ + simple_package_test.getConfig, + kotlin_test.getConfig, + jackson_core_test.getConfig + ]; + for (final getConfig in configGetters) { + final config = getConfig(); + config.summarizerOptions = + SummarizerOptions(backend: SummarizerBackend.asm); + final classes = await getSummary(config); + await classes.accept(Linker(config)); + classes.accept(const Unnester()); + for (final decl in classes.decls.values) { + // Checking if the descriptor from ASM matches the one generated by + // [MethodDescriptor]. + final methodDescriptor = MethodDescriptor(decl.allTypeParams); + for (final method in decl.methods) { + expect(method.descriptor, method.accept(methodDescriptor)); + } + } + } + }); +} diff --git a/pkgs/jnigen/test/jackson_core_test/generate.dart b/pkgs/jnigen/test/jackson_core_test/generate.dart index 7077bfa7e..796a760ca 100644 --- a/pkgs/jnigen/test/jackson_core_test/generate.dart +++ b/pkgs/jnigen/test/jackson_core_test/generate.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. import 'package:jnigen/jnigen.dart'; +import 'package:jnigen/src/config/experiments.dart'; import 'package:logging/logging.dart'; import 'package:path/path.dart' hide equals; @@ -43,7 +44,7 @@ Config getConfig({ jarDir: join(thirdPartyDir, 'jar'), ), summarizerOptions: SummarizerOptions( - backend: useAsm ? 'asm' : null, + backend: useAsm ? SummarizerBackend.asm : null, ), preamble: jacksonPreamble, outputConfig: OutputConfig( @@ -69,17 +70,19 @@ Config getConfig({ ], logLevel: Level.INFO, exclude: BindingExclusions( - // TODO(#31): Remove field exclusions. - fields: excludeAll([ - ['com.fasterxml.jackson.core.JsonFactory', 'DEFAULT_QUOTE_CHAR'], - ['com.fasterxml.jackson.core.Base64Variant', 'PADDING_CHAR_NONE'], - ['com.fasterxml.jackson.core.base.ParserMinimalBase', 'CHAR_NULL'], - ['com.fasterxml.jackson.core.io.UTF32Reader', 'NC'], - ]), - // TODO(#159): Remove class exclusions. - classes: ClassNameFilter.exclude( - 'com.fasterxml.jackson.core.JsonFactoryBuilder', - )), + // TODO(#31): Remove field exclusions. + fields: excludeAll([ + ['com.fasterxml.jackson.core.JsonFactory', 'DEFAULT_QUOTE_CHAR'], + ['com.fasterxml.jackson.core.Base64Variant', 'PADDING_CHAR_NONE'], + ['com.fasterxml.jackson.core.base.ParserMinimalBase', 'CHAR_NULL'], + ['com.fasterxml.jackson.core.io.UTF32Reader', 'NC'], + ]), + // TODO(#159): Remove class exclusions. + classes: ClassNameFilter.exclude( + 'com.fasterxml.jackson.core.JsonFactoryBuilder', + ), + ), + experiments: {Experiment.interfaceImplementation}, ); return config; } diff --git a/pkgs/jnigen/test/jackson_core_test/jnigen.yaml b/pkgs/jnigen/test/jackson_core_test/jnigen.yaml index 6041671c9..cf3b4db15 100644 --- a/pkgs/jnigen/test/jackson_core_test/jnigen.yaml +++ b/pkgs/jnigen/test/jackson_core_test/jnigen.yaml @@ -43,3 +43,6 @@ preamble: | // limitations under the License. log_level: warning + +enable_experiment: + - interface_implementation diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/dartjni.h b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/dartjni.h index c0713af53..cbb1f7f5c 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/dartjni.h +++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/dartjni.h @@ -45,6 +45,7 @@ #include typedef CRITICAL_SECTION MutexLock; +typedef CONDITION_VARIABLE ConditionVariable; static inline void init_lock(MutexLock* lock) { InitializeCriticalSection(lock); @@ -58,15 +59,32 @@ static inline void release_lock(MutexLock* lock) { LeaveCriticalSection(lock); } -static inline void _destroyLock(MutexLock* lock) { +static inline void destroy_lock(MutexLock* lock) { DeleteCriticalSection(lock); } -#elif defined __DARWIN__ || defined __LINUX__ || defined __ANDROID__ || \ +static inline void init_cond(ConditionVariable* cond) { + InitializeConditionVariable(cond); +} + +static inline void signal_cond(ConditionVariable* cond) { + WakeConditionVariable(cond); +} + +static inline void wait_for(ConditionVariable* cond, MutexLock* lock) { + SleepConditionVariableCS(cond, lock, INFINITE); +} + +static inline void destroy_cond(ConditionVariable* cond) { + DeleteCriticalSection(cond); +} + +#elif defined __APPLE__ || defined __LINUX__ || defined __ANDROID__ || \ defined __GNUC__ #include typedef pthread_mutex_t MutexLock; +typedef pthread_cond_t ConditionVariable; static inline void init_lock(MutexLock* lock) { pthread_mutex_init(lock, NULL); @@ -80,15 +98,48 @@ static inline void release_lock(MutexLock* lock) { pthread_mutex_unlock(lock); } -static inline void _destroyLock(MutexLock* lock) { +static inline void destroy_lock(MutexLock* lock) { pthread_mutex_destroy(lock); } +static inline void init_cond(ConditionVariable* cond) { + pthread_cond_init(cond, NULL); +} + +static inline void signal_cond(ConditionVariable* cond) { + pthread_cond_signal(cond); +} + +static inline void wait_for(ConditionVariable* cond, MutexLock* lock) { + pthread_cond_wait(cond, lock); +} + +static inline void destroy_cond(ConditionVariable* cond) { + pthread_cond_destroy(cond); +} + #else -#error "No locking support; Possibly unsupported platform" +#error "No locking/condition variable support; Possibly unsupported platform" + +#endif +static inline uint64_t thread_id() { +#ifdef _WIN32 + return GetCurrentThreadId(); +#elif defined __APPLE__ + return pthread_mach_thread_np(pthread_self()); +#else + return pthread_self(); #endif +} + +typedef struct CallbackResult { + MutexLock lock; + ConditionVariable cond; + int ready; + jobject object; +} CallbackResult; typedef struct JniLocks { MutexLock classLoadingLock; @@ -369,6 +420,8 @@ static inline JniResult to_global_ref_result(jobject ref) { FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); +FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object); + JNIEXPORT void JNICALL Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env, jobject thiz, @@ -376,3 +429,18 @@ Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env, jobject result); FFI_PLUGIN_EXPORT JniResult PortContinuation__ctor(int64_t j); + +FFI_PLUGIN_EXPORT +JniResult PortProxy__newInstance(jobject binaryName, + int64_t port, + int64_t functionPtr); + +JNIEXPORT jobject JNICALL +Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, + jobject thiz, + jlong port, + jlong threadId, + jlong functionPtr, + jobject proxy, + jstring methodDescriptor, + jobjectArray args); diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/jackson_core.c b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/jackson_core.c index 74bf137c2..0f6b727df 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/jackson_core.c +++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/jackson_core.c @@ -3383,7 +3383,7 @@ JniResult JsonParser__readValueAsTree(jobject self_) { if (_c_JsonParser == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_JsonParser, &_m_JsonParser__readValueAsTree, "readValueAsTree", - "()Ljava/lang/Object;"); + "()Lcom/fasterxml/jackson/core/TreeNode;"); if (_m_JsonParser__readValueAsTree == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart index 0b91b29f0..33f513996 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart @@ -29,6 +29,7 @@ // 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 import "dart:isolate" show ReceivePort; diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart index 1c60902d0..032db3141 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart @@ -29,6 +29,7 @@ // 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 import "dart:isolate" show ReceivePort; diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart index fe8cf885d..14ce836aa 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart @@ -29,6 +29,7 @@ // 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 import "dart:isolate" show ReceivePort; diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart index c58fb97aa..71a79f1b8 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart @@ -29,6 +29,7 @@ // 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 import "dart:isolate" show ReceivePort; diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart index 601b40422..f978756ba 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart @@ -29,6 +29,7 @@ // 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 import "dart:isolate" show ReceivePort; @@ -2463,7 +2464,9 @@ class JsonParser extends jni.JObject { } static final _id_readValueAsTree = jni.Jni.accessors.getMethodIDOf( - _class.reference, r"readValueAsTree", r"()Ljava/lang/Object;"); + _class.reference, + r"readValueAsTree", + r"()Lcom/fasterxml/jackson/core/TreeNode;"); /// from: public T readValueAsTree() /// The returned object must be deleted after use, by calling the `delete` method. diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart index b6bc6e549..aac454b68 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart @@ -29,6 +29,7 @@ // 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 import "dart:isolate" show ReceivePort; diff --git a/pkgs/jnigen/test/kotlin_test/c_based/c_bindings/dartjni.h b/pkgs/jnigen/test/kotlin_test/c_based/c_bindings/dartjni.h index c0713af53..cbb1f7f5c 100644 --- a/pkgs/jnigen/test/kotlin_test/c_based/c_bindings/dartjni.h +++ b/pkgs/jnigen/test/kotlin_test/c_based/c_bindings/dartjni.h @@ -45,6 +45,7 @@ #include typedef CRITICAL_SECTION MutexLock; +typedef CONDITION_VARIABLE ConditionVariable; static inline void init_lock(MutexLock* lock) { InitializeCriticalSection(lock); @@ -58,15 +59,32 @@ static inline void release_lock(MutexLock* lock) { LeaveCriticalSection(lock); } -static inline void _destroyLock(MutexLock* lock) { +static inline void destroy_lock(MutexLock* lock) { DeleteCriticalSection(lock); } -#elif defined __DARWIN__ || defined __LINUX__ || defined __ANDROID__ || \ +static inline void init_cond(ConditionVariable* cond) { + InitializeConditionVariable(cond); +} + +static inline void signal_cond(ConditionVariable* cond) { + WakeConditionVariable(cond); +} + +static inline void wait_for(ConditionVariable* cond, MutexLock* lock) { + SleepConditionVariableCS(cond, lock, INFINITE); +} + +static inline void destroy_cond(ConditionVariable* cond) { + DeleteCriticalSection(cond); +} + +#elif defined __APPLE__ || defined __LINUX__ || defined __ANDROID__ || \ defined __GNUC__ #include typedef pthread_mutex_t MutexLock; +typedef pthread_cond_t ConditionVariable; static inline void init_lock(MutexLock* lock) { pthread_mutex_init(lock, NULL); @@ -80,15 +98,48 @@ static inline void release_lock(MutexLock* lock) { pthread_mutex_unlock(lock); } -static inline void _destroyLock(MutexLock* lock) { +static inline void destroy_lock(MutexLock* lock) { pthread_mutex_destroy(lock); } +static inline void init_cond(ConditionVariable* cond) { + pthread_cond_init(cond, NULL); +} + +static inline void signal_cond(ConditionVariable* cond) { + pthread_cond_signal(cond); +} + +static inline void wait_for(ConditionVariable* cond, MutexLock* lock) { + pthread_cond_wait(cond, lock); +} + +static inline void destroy_cond(ConditionVariable* cond) { + pthread_cond_destroy(cond); +} + #else -#error "No locking support; Possibly unsupported platform" +#error "No locking/condition variable support; Possibly unsupported platform" + +#endif +static inline uint64_t thread_id() { +#ifdef _WIN32 + return GetCurrentThreadId(); +#elif defined __APPLE__ + return pthread_mach_thread_np(pthread_self()); +#else + return pthread_self(); #endif +} + +typedef struct CallbackResult { + MutexLock lock; + ConditionVariable cond; + int ready; + jobject object; +} CallbackResult; typedef struct JniLocks { MutexLock classLoadingLock; @@ -369,6 +420,8 @@ static inline JniResult to_global_ref_result(jobject ref) { FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); +FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object); + JNIEXPORT void JNICALL Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env, jobject thiz, @@ -376,3 +429,18 @@ Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env, jobject result); FFI_PLUGIN_EXPORT JniResult PortContinuation__ctor(int64_t j); + +FFI_PLUGIN_EXPORT +JniResult PortProxy__newInstance(jobject binaryName, + int64_t port, + int64_t functionPtr); + +JNIEXPORT jobject JNICALL +Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, + jobject thiz, + jlong port, + jlong threadId, + jlong functionPtr, + jobject proxy, + jstring methodDescriptor, + jobjectArray args); diff --git a/pkgs/jnigen/test/kotlin_test/c_based/dart_bindings/kotlin.dart b/pkgs/jnigen/test/kotlin_test/c_based/dart_bindings/kotlin.dart index b8e33c26f..3e65d3b09 100644 --- a/pkgs/jnigen/test/kotlin_test/c_based/dart_bindings/kotlin.dart +++ b/pkgs/jnigen/test/kotlin_test/c_based/dart_bindings/kotlin.dart @@ -16,6 +16,7 @@ // 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 import "dart:isolate" show ReceivePort; @@ -61,7 +62,8 @@ class SuspendFun extends jni.JObject { /// The returned object must be deleted after use, by calling the `delete` method. Future sayHello() async { final $p = ReceivePort(); - final $c = jni.JObject.fromRef(jni.Jni.newPortContinuation($p)); + final $c = + jni.JObject.fromRef(ProtectedJniExtensions.newPortContinuation($p)); _sayHello(reference, $c.reference).object; final $o = jni.JObjectPtr.fromAddress(await $p.first); final $k = const jni.JStringType().getClass().reference; @@ -87,7 +89,8 @@ class SuspendFun extends jni.JObject { jni.JString string, ) async { final $p = ReceivePort(); - final $c = jni.JObject.fromRef(jni.Jni.newPortContinuation($p)); + final $c = + jni.JObject.fromRef(ProtectedJniExtensions.newPortContinuation($p)); _sayHello1(reference, string.reference, $c.reference).object; final $o = jni.JObjectPtr.fromAddress(await $p.first); final $k = const jni.JStringType().getClass().reference; diff --git a/pkgs/jnigen/test/kotlin_test/dart_only/dart_bindings/kotlin.dart b/pkgs/jnigen/test/kotlin_test/dart_only/dart_bindings/kotlin.dart index a0510088b..e4ceec3e6 100644 --- a/pkgs/jnigen/test/kotlin_test/dart_only/dart_bindings/kotlin.dart +++ b/pkgs/jnigen/test/kotlin_test/dart_only/dart_bindings/kotlin.dart @@ -16,6 +16,7 @@ // 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 import "dart:isolate" show ReceivePort; @@ -54,7 +55,8 @@ class SuspendFun extends jni.JObject { /// The returned object must be deleted after use, by calling the `delete` method. Future sayHello() async { final $p = ReceivePort(); - final $c = jni.JObject.fromRef(jni.Jni.newPortContinuation($p)); + final $c = + jni.JObject.fromRef(ProtectedJniExtensions.newPortContinuation($p)); jni.Jni.accessors.callMethodWithArgs(reference, _id_sayHello, jni.JniCallType.objectType, [$c.reference]).object; final $o = jni.JObjectPtr.fromAddress(await $p.first); @@ -76,7 +78,8 @@ class SuspendFun extends jni.JObject { jni.JString string, ) async { final $p = ReceivePort(); - final $c = jni.JObject.fromRef(jni.Jni.newPortContinuation($p)); + final $c = + jni.JObject.fromRef(ProtectedJniExtensions.newPortContinuation($p)); jni.Jni.accessors.callMethodWithArgs(reference, _id_sayHello1, jni.JniCallType.objectType, [string.reference, $c.reference]).object; final $o = jni.JObjectPtr.fromAddress(await $p.first); diff --git a/pkgs/jnigen/test/kotlin_test/generate.dart b/pkgs/jnigen/test/kotlin_test/generate.dart index 11b89ea53..61686679a 100644 --- a/pkgs/jnigen/test/kotlin_test/generate.dart +++ b/pkgs/jnigen/test/kotlin_test/generate.dart @@ -63,7 +63,7 @@ Config getConfig([BindingsType bindingsType = BindingsType.cBased]) { structure: OutputStructure.singleFile, ), ), - summarizerOptions: SummarizerOptions(backend: 'asm'), + summarizerOptions: SummarizerOptions(backend: SummarizerBackend.asm), preamble: preamble, ); return config; diff --git a/pkgs/jnigen/test/kotlin_test/jni.jar b/pkgs/jnigen/test/kotlin_test/jni.jar deleted file mode 100644 index 37a1bfc8ee9b578163cffca1479743f667050a80..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2755 zcmWIWW@h1H0D+Cg_F-TKl;8x?zOEsTx}JV+`TRsgZ*3~+9=KSU$gDb`lo)+nNojal9t?R_W{$xqm6fx}s zDiu5DbO#B02L+eR)mkee!!0z~I7qZc_;k=`k)E$QU(NvKy^M>!4s4qGbLr8QnKK0z zio~v;lCwbfSruE=vOO_-Vi;h~V_;y(0R%Exo{6)s^EsINY5OxU^*DWx};_fP?<9o@87o69dB*po{hKYRfMwan8>x$;>NFEXmBz z(@V}tEH3U1ew`=eDDtoE_MvH)ytuDm#S}@*L8O zO!KYOo?Vgo=OOctfMdqotw9EvCyL(PuX#RarhR?=U$zfI`XMX=Ap%{>JsgLtuK!5N zusxiYef;dYRIWCU&f76lB%5x=D7R@Oab2+p6G%TX(=R@|_~OS|QKt)zcE;b_y7Sw? zLf4}kS-0Cd7aULH;5~8lz$z`Fh~N!!$9YvGjpoZNHnWG<4BUNq4TywyDC`rK)OQD_>0UNMHTys$BO@H<4(b zuAIgbt9SHTbGd!pRC0TH~eb3S==-2-0XD^`y_&HdQUKYShU-B0@pj=*|VQp zn@`O#y{-^g7$tUimY?SPy>*w1Ub}5}pSR@Q47c@(J7R7Lr+buG@Ge^rU;W4RRgGMx z$qonWJ$61T@M?Nes{CI0!bay&fI&V zb}Va8uJobe&cA^x|798O-SZ;qRH0|K>G5LU*Sgaed&bHhXlyxJyDN^-;LU~UQ}i3} z1h$(Uk20v!aDmu%bt>qbhKIUzeV0tsfG8*hR*hsrJVhnK5|qytoICQ ztG%>T=J+O+mlqZ7EuWftN^;Ll{`y+P{?YGkHFpYgGn#hWKbKrA`k|sJOnv=%rTPEa zmVRKCHa@pX{-)Z#ng2i3HZ`Z#L^|wq+O+sWP1>g=vG&a~)bi&&zBcoGa@i@Zvxbhh z6kjsh95s%&`_GQZR_KKTKQM*D3y0jqveZ0ya>gu4q%jre7p3c^RwU*Yz&W(48awqQTaTz$-zB?KmswQ8 zTPK_j{Pm+??%d_#Timwt;iKT zsPkb${c;l#<*8Z=YPx1GQ1tpBcddKR(!lK6=z#frj%T%EnGViRSYq(_NK@hSM$y{_ zP1X)6Ceq969^TBUsO2pMT z?pk;{gp`z<%0GAK0OK|ri1mn!n0FaIs zKqg2ByuQS(5maMB07#=CFkd2RM6N$^8v&|85k|P+G6GVc!i>RQqrwbY(pZhx7_9Xx za)@Fp3}J5k|6dju!0@Pq6^$^LVJ{pJn!PYJqZXC84N`#l5163-|8K@`5VYuonTEaa zgc-P`@gNbVL5osEKw;0V2t${$VFVPiU%^fU8H&ie0p6@YJq!#yKp4Qxz!1w0;sF54 Cwu%=3 diff --git a/pkgs/jnigen/test/package_resolver_test.dart b/pkgs/jnigen/test/package_resolver_test.dart index 8053b5aa2..a29e04362 100644 --- a/pkgs/jnigen/test/package_resolver_test.dart +++ b/pkgs/jnigen/test/package_resolver_test.dart @@ -20,9 +20,11 @@ void main() async { final resolver = Resolver( importedClasses: { 'org.apache.pdfbox.pdmodel.PDDocument': ClassDecl( + declKind: DeclKind.classKind, binaryName: 'org.apache.pdfbox.pdmodel.PDDocument', )..path = 'package:pdfbox/pdfbox.dart', 'android.os.Process': ClassDecl( + declKind: DeclKind.classKind, binaryName: 'android.os.Process', )..path = 'package:android/os.dart', }, @@ -70,8 +72,10 @@ void main() async { test( 'resolve $binaryName', () => expect( - resolver - .resolvePrefix(ClassDecl(binaryName: binaryName)..path = ''), + resolver.resolvePrefix(ClassDecl( + declKind: DeclKind.classKind, + binaryName: binaryName, + )..path = ''), equals(testCase.expectedName))); } } diff --git a/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/dartjni.h b/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/dartjni.h index c0713af53..cbb1f7f5c 100644 --- a/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/dartjni.h +++ b/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/dartjni.h @@ -45,6 +45,7 @@ #include typedef CRITICAL_SECTION MutexLock; +typedef CONDITION_VARIABLE ConditionVariable; static inline void init_lock(MutexLock* lock) { InitializeCriticalSection(lock); @@ -58,15 +59,32 @@ static inline void release_lock(MutexLock* lock) { LeaveCriticalSection(lock); } -static inline void _destroyLock(MutexLock* lock) { +static inline void destroy_lock(MutexLock* lock) { DeleteCriticalSection(lock); } -#elif defined __DARWIN__ || defined __LINUX__ || defined __ANDROID__ || \ +static inline void init_cond(ConditionVariable* cond) { + InitializeConditionVariable(cond); +} + +static inline void signal_cond(ConditionVariable* cond) { + WakeConditionVariable(cond); +} + +static inline void wait_for(ConditionVariable* cond, MutexLock* lock) { + SleepConditionVariableCS(cond, lock, INFINITE); +} + +static inline void destroy_cond(ConditionVariable* cond) { + DeleteCriticalSection(cond); +} + +#elif defined __APPLE__ || defined __LINUX__ || defined __ANDROID__ || \ defined __GNUC__ #include typedef pthread_mutex_t MutexLock; +typedef pthread_cond_t ConditionVariable; static inline void init_lock(MutexLock* lock) { pthread_mutex_init(lock, NULL); @@ -80,15 +98,48 @@ static inline void release_lock(MutexLock* lock) { pthread_mutex_unlock(lock); } -static inline void _destroyLock(MutexLock* lock) { +static inline void destroy_lock(MutexLock* lock) { pthread_mutex_destroy(lock); } +static inline void init_cond(ConditionVariable* cond) { + pthread_cond_init(cond, NULL); +} + +static inline void signal_cond(ConditionVariable* cond) { + pthread_cond_signal(cond); +} + +static inline void wait_for(ConditionVariable* cond, MutexLock* lock) { + pthread_cond_wait(cond, lock); +} + +static inline void destroy_cond(ConditionVariable* cond) { + pthread_cond_destroy(cond); +} + #else -#error "No locking support; Possibly unsupported platform" +#error "No locking/condition variable support; Possibly unsupported platform" + +#endif +static inline uint64_t thread_id() { +#ifdef _WIN32 + return GetCurrentThreadId(); +#elif defined __APPLE__ + return pthread_mach_thread_np(pthread_self()); +#else + return pthread_self(); #endif +} + +typedef struct CallbackResult { + MutexLock lock; + ConditionVariable cond; + int ready; + jobject object; +} CallbackResult; typedef struct JniLocks { MutexLock classLoadingLock; @@ -369,6 +420,8 @@ static inline JniResult to_global_ref_result(jobject ref) { FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); +FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object); + JNIEXPORT void JNICALL Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env, jobject thiz, @@ -376,3 +429,18 @@ Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env, jobject result); FFI_PLUGIN_EXPORT JniResult PortContinuation__ctor(int64_t j); + +FFI_PLUGIN_EXPORT +JniResult PortProxy__newInstance(jobject binaryName, + int64_t port, + int64_t functionPtr); + +JNIEXPORT jobject JNICALL +Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, + jobject thiz, + jlong port, + jlong threadId, + jlong functionPtr, + jobject proxy, + jstring methodDescriptor, + jobjectArray args); diff --git a/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/simple_package.c b/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/simple_package.c index 6c0f3e245..9b6e5e10c 100644 --- a/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/simple_package.c +++ b/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/simple_package.c @@ -2310,6 +2310,158 @@ JniResult StringValuedMap__ctor() { return to_global_ref_result(_result); } +// com.github.dart_lang.jnigen.interfaces.MyInterface +jclass _c_MyInterface = NULL; + +jmethodID _m_MyInterface__voidCallback = NULL; +FFI_PLUGIN_EXPORT +JniResult MyInterface__voidCallback(jobject self_, jobject s) { + load_env(); + load_class_global_ref(&_c_MyInterface, + "com/github/dart_lang/jnigen/interfaces/MyInterface"); + if (_c_MyInterface == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_MyInterface, &_m_MyInterface__voidCallback, "voidCallback", + "(Ljava/lang/String;)V"); + if (_m_MyInterface__voidCallback == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_MyInterface__voidCallback, s); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +jmethodID _m_MyInterface__stringCallback = NULL; +FFI_PLUGIN_EXPORT +JniResult MyInterface__stringCallback(jobject self_, jobject s) { + load_env(); + load_class_global_ref(&_c_MyInterface, + "com/github/dart_lang/jnigen/interfaces/MyInterface"); + if (_c_MyInterface == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_MyInterface, &_m_MyInterface__stringCallback, "stringCallback", + "(Ljava/lang/String;)Ljava/lang/String;"); + if (_m_MyInterface__stringCallback == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_MyInterface__stringCallback, s); + return to_global_ref_result(_result); +} + +jmethodID _m_MyInterface__varCallback = NULL; +FFI_PLUGIN_EXPORT +JniResult MyInterface__varCallback(jobject self_, jobject t) { + load_env(); + load_class_global_ref(&_c_MyInterface, + "com/github/dart_lang/jnigen/interfaces/MyInterface"); + if (_c_MyInterface == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_MyInterface, &_m_MyInterface__varCallback, "varCallback", + "(Ljava/lang/Object;)Ljava/lang/Object;"); + if (_m_MyInterface__varCallback == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod(jniEnv, self_, + _m_MyInterface__varCallback, t); + return to_global_ref_result(_result); +} + +jmethodID _m_MyInterface__manyPrimitives = NULL; +FFI_PLUGIN_EXPORT +JniResult MyInterface__manyPrimitives(jobject self_, + int32_t a, + uint8_t b, + uint16_t c, + double d) { + load_env(); + load_class_global_ref(&_c_MyInterface, + "com/github/dart_lang/jnigen/interfaces/MyInterface"); + if (_c_MyInterface == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_MyInterface, &_m_MyInterface__manyPrimitives, "manyPrimitives", + "(IZCD)J"); + if (_m_MyInterface__manyPrimitives == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + int64_t _result = (*jniEnv)->CallLongMethod( + jniEnv, self_, _m_MyInterface__manyPrimitives, a, b, c, d); + return (JniResult){.value = {.j = _result}, .exception = check_exception()}; +} + +// com.github.dart_lang.jnigen.interfaces.MyInterfaceConsumer +jclass _c_MyInterfaceConsumer = NULL; + +jmethodID _m_MyInterfaceConsumer__ctor = NULL; +FFI_PLUGIN_EXPORT +JniResult MyInterfaceConsumer__ctor() { + load_env(); + load_class_global_ref( + &_c_MyInterfaceConsumer, + "com/github/dart_lang/jnigen/interfaces/MyInterfaceConsumer"); + if (_c_MyInterfaceConsumer == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_MyInterfaceConsumer, &_m_MyInterfaceConsumer__ctor, "", + "()V"); + if (_m_MyInterfaceConsumer__ctor == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_MyInterfaceConsumer, + _m_MyInterfaceConsumer__ctor); + return to_global_ref_result(_result); +} + +jmethodID _m_MyInterfaceConsumer__consumeOnAnotherThread = NULL; +FFI_PLUGIN_EXPORT +JniResult MyInterfaceConsumer__consumeOnAnotherThread(jobject myInterface, + jobject s, + int32_t a, + uint8_t b, + uint16_t c, + double d, + jobject t) { + load_env(); + load_class_global_ref( + &_c_MyInterfaceConsumer, + "com/github/dart_lang/jnigen/interfaces/MyInterfaceConsumer"); + if (_c_MyInterfaceConsumer == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_MyInterfaceConsumer, + &_m_MyInterfaceConsumer__consumeOnAnotherThread, + "consumeOnAnotherThread", + "(Lcom/github/dart_lang/jnigen/interfaces/" + "MyInterface;Ljava/lang/String;IZCDLjava/lang/Object;)V"); + if (_m_MyInterfaceConsumer__consumeOnAnotherThread == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallStaticVoidMethod( + jniEnv, _c_MyInterfaceConsumer, + _m_MyInterfaceConsumer__consumeOnAnotherThread, myInterface, s, a, b, c, + d, t); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +jmethodID _m_MyInterfaceConsumer__consumeOnSameThread = NULL; +FFI_PLUGIN_EXPORT +JniResult MyInterfaceConsumer__consumeOnSameThread(jobject myInterface, + jobject s, + int32_t a, + uint8_t b, + uint16_t c, + double d, + jobject t) { + load_env(); + load_class_global_ref( + &_c_MyInterfaceConsumer, + "com/github/dart_lang/jnigen/interfaces/MyInterfaceConsumer"); + if (_c_MyInterfaceConsumer == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_MyInterfaceConsumer, + &_m_MyInterfaceConsumer__consumeOnSameThread, + "consumeOnSameThread", + "(Lcom/github/dart_lang/jnigen/interfaces/" + "MyInterface;Ljava/lang/String;IZCDLjava/lang/Object;)V"); + if (_m_MyInterfaceConsumer__consumeOnSameThread == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallStaticVoidMethod(jniEnv, _c_MyInterfaceConsumer, + _m_MyInterfaceConsumer__consumeOnSameThread, + myInterface, s, a, b, c, d, t); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + // com.github.dart_lang.jnigen.annotations.JsonSerializable$Case jclass _c_JsonSerializable_Case = NULL; diff --git a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart index d0ad47c7d..7cb011083 100644 --- a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart @@ -16,6 +16,7 @@ // 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 import "dart:isolate" show ReceivePort; @@ -2827,6 +2828,372 @@ class $StringValuedMapType<$K extends jni.JObject> } } +/// from: com.github.dart_lang.jnigen.interfaces.MyInterface +class MyInterface<$T extends jni.JObject> extends jni.JObject { + @override + late final jni.JObjType> $type = type(T); + + final jni.JObjType<$T> T; + + MyInterface.fromRef( + this.T, + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static $MyInterfaceType<$T> type<$T extends jni.JObject>( + jni.JObjType<$T> T, + ) { + return $MyInterfaceType( + T, + ); + } + + static final _voidCallback = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("MyInterface__voidCallback") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public abstract void voidCallback(java.lang.String s) + void voidCallback( + jni.JString s, + ) { + return _voidCallback(reference, s.reference).check(); + } + + static final _stringCallback = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("MyInterface__stringCallback") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public abstract java.lang.String stringCallback(java.lang.String s) + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JString stringCallback( + jni.JString s, + ) { + return const jni.JStringType() + .fromRef(_stringCallback(reference, s.reference).object); + } + + static final _varCallback = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("MyInterface__varCallback") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public abstract T varCallback(T t) + /// The returned object must be deleted after use, by calling the `delete` method. + $T varCallback( + $T t, + ) { + return T.fromRef(_varCallback(reference, t.reference).object); + } + + static final _manyPrimitives = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, + ffi.Int32, + ffi.Uint8, + ffi.Uint16, + ffi.Double)>>("MyInterface__manyPrimitives") + .asFunction< + jni.JniResult Function( + ffi.Pointer, int, int, int, double)>(); + + /// from: public abstract long manyPrimitives(int a, boolean b, char c, double d) + int manyPrimitives( + int a, + bool b, + int c, + double d, + ) { + return _manyPrimitives(reference, a, b ? 1 : 0, c, d).long; + } + + /// Maps a specific port to the implemented methods. + static final Map> _$methods = {}; + + /// Maps a specific port to the type parameters. + static final Map> _$types = {}; + + ReceivePort? _$p; + + static final Finalizer _$finalizer = Finalizer(($p) { + _$methods.remove($p.sendPort.nativePort); + _$types.remove($p.sendPort.nativePort); + $p.close(); + }); + + @override + void delete() { + _$methods.remove(_$p?.sendPort.nativePort); + _$types.remove(_$p?.sendPort.nativePort); + _$p?.close(); + _$finalizer.detach(this); + super.delete(); + } + + static jni.JObjectPtr _$invoke( + int port, + jni.JObjectPtr descriptor, + jni.JObjectPtr args, + ) { + return _$invokeMethod( + port, + $MethodInvocation.fromAddresses( + 0, + descriptor.address, + args.address, + ), + ); + } + + static final ffi.Pointer< + ffi.NativeFunction< + jni.JObjectPtr Function( + ffi.Uint64, jni.JObjectPtr, jni.JObjectPtr)>> + _$invokePointer = ffi.Pointer.fromFunction(_$invoke); + + static ffi.Pointer _$invokeMethod( + int $p, + $MethodInvocation $i, + ) { + final $d = $i.methodDescriptor.toDartString(deleteOriginal: true); + final $a = $i.args; + if ($d == r"voidCallback(Ljava/lang/String;)V") { + _$methods[$p]![$d]!( + $a[0].castTo(const jni.JStringType(), deleteOriginal: true), + ); + return jni.nullptr; + } + if ($d == r"stringCallback(Ljava/lang/String;)Ljava/lang/String;") { + final $r = _$methods[$p]![$d]!( + $a[0].castTo(const jni.JStringType(), deleteOriginal: true), + ); + return $r.reference; + } + if ($d == r"varCallback(Ljava/lang/Object;)Ljava/lang/Object;") { + final $r = _$methods[$p]![$d]!( + $a[0].castTo(_$types[$p]!["T"]!, deleteOriginal: true), + ); + return $r.reference; + } + if ($d == r"manyPrimitives(IZCD)J") { + final $r = _$methods[$p]![$d]!( + $a[0] + .castTo(const jni.JIntegerType(), deleteOriginal: true) + .intValue(deleteOriginal: true), + $a[1] + .castTo(const jni.JBooleanType(), deleteOriginal: true) + .booleanValue(deleteOriginal: true), + $a[2] + .castTo(const jni.JCharacterType(), deleteOriginal: true) + .charValue(deleteOriginal: true), + $a[3] + .castTo(const jni.JDoubleType(), deleteOriginal: true) + .doubleValue(deleteOriginal: true), + ); + return jni.JLong($r).reference; + } + return jni.nullptr; + } + + factory MyInterface.implement({ + required jni.JObjType<$T> T, + required void Function(jni.JString s) voidCallback, + required jni.JString Function(jni.JString s) stringCallback, + required $T Function($T t) varCallback, + required int Function(int a, bool b, int c, double d) manyPrimitives, + }) { + final $p = ReceivePort(); + final $x = MyInterface.fromRef( + T, + ProtectedJniExtensions.newPortProxy( + r"com.github.dart_lang.jnigen.interfaces.MyInterface", + $p, + _$invokePointer, + ), + ).._$p = $p; + final $a = $p.sendPort.nativePort; + _$types[$a] = {}; + _$methods[$a] = {}; + _$types[$a]!["T"] = T; + _$methods[$a]![r"voidCallback(Ljava/lang/String;)V"] = voidCallback; + _$methods[$a]![r"stringCallback(Ljava/lang/String;)Ljava/lang/String;"] = + stringCallback; + _$methods[$a]![r"varCallback(Ljava/lang/Object;)Ljava/lang/Object;"] = + varCallback; + _$methods[$a]![r"manyPrimitives(IZCD)J"] = manyPrimitives; + _$finalizer.attach($x, $p, detach: $x); + $p.listen(($m) { + final $i = $MethodInvocation.fromMessage($m); + final $r = _$invokeMethod($p.sendPort.nativePort, $i); + ProtectedJniExtensions.returnResult($i.result, $r); + }); + return $x; + } +} + +class $MyInterfaceType<$T extends jni.JObject> + extends jni.JObjType> { + final jni.JObjType<$T> T; + + const $MyInterfaceType( + this.T, + ); + + @override + String get signature => + r"Lcom/github/dart_lang/jnigen/interfaces/MyInterface;"; + + @override + MyInterface<$T> fromRef(jni.JObjectPtr ref) => MyInterface.fromRef(T, ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => Object.hash($MyInterfaceType, T); + + @override + bool operator ==(Object other) { + return other.runtimeType == ($MyInterfaceType<$T>) && + other is $MyInterfaceType<$T> && + T == other.T; + } +} + +/// from: com.github.dart_lang.jnigen.interfaces.MyInterfaceConsumer +class MyInterfaceConsumer extends jni.JObject { + @override + late final jni.JObjType $type = type; + + MyInterfaceConsumer.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = $MyInterfaceConsumerType(); + static final _ctor = jniLookup>( + "MyInterfaceConsumer__ctor") + .asFunction(); + + /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. + factory MyInterfaceConsumer() { + return MyInterfaceConsumer.fromRef(_ctor().object); + } + + static final _consumeOnAnotherThread = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int32, + ffi.Uint8, + ffi.Uint16, + ffi.Double, + ffi.Pointer)>>( + "MyInterfaceConsumer__consumeOnAnotherThread") + .asFunction< + jni.JniResult Function(ffi.Pointer, ffi.Pointer, + int, int, int, double, ffi.Pointer)>(); + + /// from: static public void consumeOnAnotherThread(com.github.dart_lang.jnigen.interfaces.MyInterface myInterface, java.lang.String s, int a, boolean b, char c, double d, T t) + static void consumeOnAnotherThread<$T extends jni.JObject>( + MyInterface<$T> myInterface, + jni.JString s, + int a, + bool b, + int c, + double d, + $T t, { + jni.JObjType<$T>? T, + }) { + T ??= jni.lowestCommonSuperType([ + t.$type, + (myInterface.$type as $MyInterfaceType).T, + ]) as jni.JObjType<$T>; + return _consumeOnAnotherThread( + myInterface.reference, s.reference, a, b ? 1 : 0, c, d, t.reference) + .check(); + } + + static final _consumeOnSameThread = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int32, + ffi.Uint8, + ffi.Uint16, + ffi.Double, + ffi.Pointer)>>( + "MyInterfaceConsumer__consumeOnSameThread") + .asFunction< + jni.JniResult Function(ffi.Pointer, ffi.Pointer, + int, int, int, double, ffi.Pointer)>(); + + /// from: static public void consumeOnSameThread(com.github.dart_lang.jnigen.interfaces.MyInterface myInterface, java.lang.String s, int a, boolean b, char c, double d, T t) + static void consumeOnSameThread<$T extends jni.JObject>( + MyInterface<$T> myInterface, + jni.JString s, + int a, + bool b, + int c, + double d, + $T t, { + jni.JObjType<$T>? T, + }) { + T ??= jni.lowestCommonSuperType([ + t.$type, + (myInterface.$type as $MyInterfaceType).T, + ]) as jni.JObjType<$T>; + return _consumeOnSameThread( + myInterface.reference, s.reference, a, b ? 1 : 0, c, d, t.reference) + .check(); + } +} + +class $MyInterfaceConsumerType extends jni.JObjType { + const $MyInterfaceConsumerType(); + + @override + String get signature => + r"Lcom/github/dart_lang/jnigen/interfaces/MyInterfaceConsumer;"; + + @override + MyInterfaceConsumer fromRef(jni.JObjectPtr ref) => + MyInterfaceConsumer.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($MyInterfaceConsumerType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == ($MyInterfaceConsumerType) && + other is $MyInterfaceConsumerType; + } +} + /// from: com.github.dart_lang.jnigen.annotations.JsonSerializable$Case class JsonSerializable_Case extends jni.JObject { @override diff --git a/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart index 3394d3d92..7befe1b98 100644 --- a/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart @@ -16,6 +16,7 @@ // 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 import "dart:isolate" show ReceivePort; @@ -2674,6 +2675,361 @@ class $StringValuedMapType<$K extends jni.JObject> } } +/// from: com.github.dart_lang.jnigen.interfaces.MyInterface +class MyInterface<$T extends jni.JObject> extends jni.JObject { + @override + late final jni.JObjType> $type = type(T); + + final jni.JObjType<$T> T; + + MyInterface.fromRef( + this.T, + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + static final _class = + jni.Jni.findJClass(r"com/github/dart_lang/jnigen/interfaces/MyInterface"); + + /// The type which includes information such as the signature of this class. + static $MyInterfaceType<$T> type<$T extends jni.JObject>( + jni.JObjType<$T> T, + ) { + return $MyInterfaceType( + T, + ); + } + + static final _id_voidCallback = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"voidCallback", r"(Ljava/lang/String;)V"); + + /// from: public abstract void voidCallback(java.lang.String s) + void voidCallback( + jni.JString s, + ) { + return jni.Jni.accessors.callMethodWithArgs(reference, _id_voidCallback, + jni.JniCallType.voidType, [s.reference]).check(); + } + + static final _id_stringCallback = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"stringCallback", + r"(Ljava/lang/String;)Ljava/lang/String;"); + + /// from: public abstract java.lang.String stringCallback(java.lang.String s) + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JString stringCallback( + jni.JString s, + ) { + return const jni.JStringType().fromRef(jni.Jni.accessors.callMethodWithArgs( + reference, + _id_stringCallback, + jni.JniCallType.objectType, + [s.reference]).object); + } + + static final _id_varCallback = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"varCallback", + r"(Ljava/lang/Object;)Ljava/lang/Object;"); + + /// from: public abstract T varCallback(T t) + /// The returned object must be deleted after use, by calling the `delete` method. + $T varCallback( + $T t, + ) { + return T.fromRef(jni.Jni.accessors.callMethodWithArgs(reference, + _id_varCallback, jni.JniCallType.objectType, [t.reference]).object); + } + + static final _id_manyPrimitives = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"manyPrimitives", r"(IZCD)J"); + + /// from: public abstract long manyPrimitives(int a, boolean b, char c, double d) + int manyPrimitives( + int a, + bool b, + int c, + double d, + ) { + return jni.Jni.accessors.callMethodWithArgs( + reference, + _id_manyPrimitives, + jni.JniCallType.longType, + [jni.JValueInt(a), b ? 1 : 0, jni.JValueChar(c), d]).long; + } + + /// Maps a specific port to the implemented methods. + static final Map> _$methods = {}; + + /// Maps a specific port to the type parameters. + static final Map> _$types = {}; + + ReceivePort? _$p; + + static final Finalizer _$finalizer = Finalizer(($p) { + _$methods.remove($p.sendPort.nativePort); + _$types.remove($p.sendPort.nativePort); + $p.close(); + }); + + @override + void delete() { + _$methods.remove(_$p?.sendPort.nativePort); + _$types.remove(_$p?.sendPort.nativePort); + _$p?.close(); + _$finalizer.detach(this); + super.delete(); + } + + static jni.JObjectPtr _$invoke( + int port, + jni.JObjectPtr descriptor, + jni.JObjectPtr args, + ) { + return _$invokeMethod( + port, + $MethodInvocation.fromAddresses( + 0, + descriptor.address, + args.address, + ), + ); + } + + static final ffi.Pointer< + ffi.NativeFunction< + jni.JObjectPtr Function( + ffi.Uint64, jni.JObjectPtr, jni.JObjectPtr)>> + _$invokePointer = ffi.Pointer.fromFunction(_$invoke); + + static ffi.Pointer _$invokeMethod( + int $p, + $MethodInvocation $i, + ) { + final $d = $i.methodDescriptor.toDartString(deleteOriginal: true); + final $a = $i.args; + if ($d == r"voidCallback(Ljava/lang/String;)V") { + _$methods[$p]![$d]!( + $a[0].castTo(const jni.JStringType(), deleteOriginal: true), + ); + return jni.nullptr; + } + if ($d == r"stringCallback(Ljava/lang/String;)Ljava/lang/String;") { + final $r = _$methods[$p]![$d]!( + $a[0].castTo(const jni.JStringType(), deleteOriginal: true), + ); + return $r.reference; + } + if ($d == r"varCallback(Ljava/lang/Object;)Ljava/lang/Object;") { + final $r = _$methods[$p]![$d]!( + $a[0].castTo(_$types[$p]!["T"]!, deleteOriginal: true), + ); + return $r.reference; + } + if ($d == r"manyPrimitives(IZCD)J") { + final $r = _$methods[$p]![$d]!( + $a[0] + .castTo(const jni.JIntegerType(), deleteOriginal: true) + .intValue(deleteOriginal: true), + $a[1] + .castTo(const jni.JBooleanType(), deleteOriginal: true) + .booleanValue(deleteOriginal: true), + $a[2] + .castTo(const jni.JCharacterType(), deleteOriginal: true) + .charValue(deleteOriginal: true), + $a[3] + .castTo(const jni.JDoubleType(), deleteOriginal: true) + .doubleValue(deleteOriginal: true), + ); + return jni.JLong($r).reference; + } + return jni.nullptr; + } + + factory MyInterface.implement({ + required jni.JObjType<$T> T, + required void Function(jni.JString s) voidCallback, + required jni.JString Function(jni.JString s) stringCallback, + required $T Function($T t) varCallback, + required int Function(int a, bool b, int c, double d) manyPrimitives, + }) { + final $p = ReceivePort(); + final $x = MyInterface.fromRef( + T, + ProtectedJniExtensions.newPortProxy( + r"com.github.dart_lang.jnigen.interfaces.MyInterface", + $p, + _$invokePointer, + ), + ).._$p = $p; + final $a = $p.sendPort.nativePort; + _$types[$a] = {}; + _$methods[$a] = {}; + _$types[$a]!["T"] = T; + _$methods[$a]![r"voidCallback(Ljava/lang/String;)V"] = voidCallback; + _$methods[$a]![r"stringCallback(Ljava/lang/String;)Ljava/lang/String;"] = + stringCallback; + _$methods[$a]![r"varCallback(Ljava/lang/Object;)Ljava/lang/Object;"] = + varCallback; + _$methods[$a]![r"manyPrimitives(IZCD)J"] = manyPrimitives; + _$finalizer.attach($x, $p, detach: $x); + $p.listen(($m) { + final $i = $MethodInvocation.fromMessage($m); + final $r = _$invokeMethod($p.sendPort.nativePort, $i); + ProtectedJniExtensions.returnResult($i.result, $r); + }); + return $x; + } +} + +class $MyInterfaceType<$T extends jni.JObject> + extends jni.JObjType> { + final jni.JObjType<$T> T; + + const $MyInterfaceType( + this.T, + ); + + @override + String get signature => + r"Lcom/github/dart_lang/jnigen/interfaces/MyInterface;"; + + @override + MyInterface<$T> fromRef(jni.JObjectPtr ref) => MyInterface.fromRef(T, ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => Object.hash($MyInterfaceType, T); + + @override + bool operator ==(Object other) { + return other.runtimeType == ($MyInterfaceType<$T>) && + other is $MyInterfaceType<$T> && + T == other.T; + } +} + +/// from: com.github.dart_lang.jnigen.interfaces.MyInterfaceConsumer +class MyInterfaceConsumer extends jni.JObject { + @override + late final jni.JObjType $type = type; + + MyInterfaceConsumer.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + static final _class = jni.Jni.findJClass( + r"com/github/dart_lang/jnigen/interfaces/MyInterfaceConsumer"); + + /// The type which includes information such as the signature of this class. + static const type = $MyInterfaceConsumerType(); + static final _id_ctor = + jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); + + /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. + factory MyInterfaceConsumer() { + return MyInterfaceConsumer.fromRef(jni.Jni.accessors + .newObjectWithArgs(_class.reference, _id_ctor, []).object); + } + + static final _id_consumeOnAnotherThread = jni.Jni.accessors.getStaticMethodIDOf( + _class.reference, + r"consumeOnAnotherThread", + r"(Lcom/github/dart_lang/jnigen/interfaces/MyInterface;Ljava/lang/String;IZCDLjava/lang/Object;)V"); + + /// from: static public void consumeOnAnotherThread(com.github.dart_lang.jnigen.interfaces.MyInterface myInterface, java.lang.String s, int a, boolean b, char c, double d, T t) + static void consumeOnAnotherThread<$T extends jni.JObject>( + MyInterface<$T> myInterface, + jni.JString s, + int a, + bool b, + int c, + double d, + $T t, { + jni.JObjType<$T>? T, + }) { + T ??= jni.lowestCommonSuperType([ + t.$type, + (myInterface.$type as $MyInterfaceType).T, + ]) as jni.JObjType<$T>; + return jni.Jni.accessors.callStaticMethodWithArgs(_class.reference, + _id_consumeOnAnotherThread, jni.JniCallType.voidType, [ + myInterface.reference, + s.reference, + jni.JValueInt(a), + b ? 1 : 0, + jni.JValueChar(c), + d, + t.reference + ]).check(); + } + + static final _id_consumeOnSameThread = jni.Jni.accessors.getStaticMethodIDOf( + _class.reference, + r"consumeOnSameThread", + r"(Lcom/github/dart_lang/jnigen/interfaces/MyInterface;Ljava/lang/String;IZCDLjava/lang/Object;)V"); + + /// from: static public void consumeOnSameThread(com.github.dart_lang.jnigen.interfaces.MyInterface myInterface, java.lang.String s, int a, boolean b, char c, double d, T t) + static void consumeOnSameThread<$T extends jni.JObject>( + MyInterface<$T> myInterface, + jni.JString s, + int a, + bool b, + int c, + double d, + $T t, { + jni.JObjType<$T>? T, + }) { + T ??= jni.lowestCommonSuperType([ + t.$type, + (myInterface.$type as $MyInterfaceType).T, + ]) as jni.JObjType<$T>; + return jni.Jni.accessors.callStaticMethodWithArgs( + _class.reference, _id_consumeOnSameThread, jni.JniCallType.voidType, [ + myInterface.reference, + s.reference, + jni.JValueInt(a), + b ? 1 : 0, + jni.JValueChar(c), + d, + t.reference + ]).check(); + } +} + +class $MyInterfaceConsumerType extends jni.JObjType { + const $MyInterfaceConsumerType(); + + @override + String get signature => + r"Lcom/github/dart_lang/jnigen/interfaces/MyInterfaceConsumer;"; + + @override + MyInterfaceConsumer fromRef(jni.JObjectPtr ref) => + MyInterfaceConsumer.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($MyInterfaceConsumerType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == ($MyInterfaceConsumerType) && + other is $MyInterfaceConsumerType; + } +} + /// from: com.github.dart_lang.jnigen.annotations.JsonSerializable$Case class JsonSerializable_Case extends jni.JObject { @override diff --git a/pkgs/jnigen/test/simple_package_test/generate.dart b/pkgs/jnigen/test/simple_package_test/generate.dart index 18c38e0d3..ce38009d3 100644 --- a/pkgs/jnigen/test/simple_package_test/generate.dart +++ b/pkgs/jnigen/test/simple_package_test/generate.dart @@ -4,6 +4,7 @@ import 'dart:io'; +import 'package:jnigen/src/config/experiments.dart'; import 'package:logging/logging.dart'; import 'package:path/path.dart'; import 'package:jnigen/jnigen.dart'; @@ -31,6 +32,8 @@ var javaFiles = [ join(javaPrefix, 'generics', 'StringStack.java'), join(javaPrefix, 'generics', 'StringValuedMap.java'), join(javaPrefix, 'generics', 'StringKeyedMap.java'), + join(javaPrefix, 'interfaces', 'MyInterface.java'), + join(javaPrefix, 'interfaces', 'MyInterfaceConsumer.java'), join(javaPrefix, 'annotations', 'JsonSerializable.java'), join(javaPrefix, 'annotations', 'MyDataClass.java'), ]; @@ -57,6 +60,7 @@ Config getConfig([BindingsType bindingsType = BindingsType.cBased]) { 'com.github.dart_lang.jnigen.simple_package', 'com.github.dart_lang.jnigen.pkg2', 'com.github.dart_lang.jnigen.generics', + 'com.github.dart_lang.jnigen.interfaces', 'com.github.dart_lang.jnigen.annotations', ], logLevel: Level.INFO, @@ -72,6 +76,7 @@ Config getConfig([BindingsType bindingsType = BindingsType.cBased]) { ), ), preamble: preamble, + experiments: {Experiment.interfaceImplementation}, ); return config; } diff --git a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/interfaces/MyInterface.java b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/interfaces/MyInterface.java new file mode 100644 index 000000000..97b243e52 --- /dev/null +++ b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/interfaces/MyInterface.java @@ -0,0 +1,15 @@ +// 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. + +package com.github.dart_lang.jnigen.interfaces; + +public interface MyInterface { + void voidCallback(String s); + + String stringCallback(String s); + + T varCallback(T t); + + long manyPrimitives(int a, boolean b, char c, double d); +} diff --git a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/interfaces/MyInterfaceConsumer.java b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/interfaces/MyInterfaceConsumer.java new file mode 100644 index 000000000..b4eeb2fda --- /dev/null +++ b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/interfaces/MyInterfaceConsumer.java @@ -0,0 +1,21 @@ +// 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. + +package com.github.dart_lang.jnigen.interfaces; + +public class MyInterfaceConsumer { + public static void consumeOnAnotherThread( + MyInterface myInterface, String s, int a, boolean b, char c, double d, T t) { + var thread = new Thread(() -> consumeOnSameThread(myInterface, s, a, b, c, d, t)); + thread.start(); + } + + public static void consumeOnSameThread( + MyInterface myInterface, String s, int a, boolean b, char c, double d, T t) { + String result = myInterface.stringCallback(s); + myInterface.voidCallback(result); + myInterface.manyPrimitives(a, b, c, d); + myInterface.varCallback(t); + } +} 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 f3075ac79..cd6f99970 100644 --- a/pkgs/jnigen/test/simple_package_test/runtime_test_registrant.dart +++ b/pkgs/jnigen/test/simple_package_test/runtime_test_registrant.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:io'; import 'package:test/test.dart'; @@ -528,6 +529,74 @@ void registerTests(String groupName, TestRunnerCallback test) { }); }); }); + + group('interface implementation', () { + for (final method in { + 'another thread': MyInterfaceConsumer.consumeOnAnotherThread, + 'the same thread': MyInterfaceConsumer.consumeOnSameThread, + }.entries) { + test('MyInterface.implement on ${method.key}', () 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( + voidCallback: (s) { + voidCallbackResult.complete(s); + }, + stringCallback: (s) { + return (s.toDartString(deleteOriginal: true) * 2).toJString(); + }, + varCallback: (JInteger t) { + final result = (t.intValue(deleteOriginal: 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. + method.value( + myInterface, + // For stringCallback: + 'hello'.toJString(), + // For manyPrimitives: + -1, + false, + 3, + 3.14, + // For varCallback + 7.toJInteger(), + ); + final voidCallback = await voidCallbackResult.future; + expect(voidCallback.toDartString(deleteOriginal: true), 'hellohello'); + + final varCallback = await varCallbackResult.future; + expect(varCallback.intValue(), 14); + + final manyPrimitives = await manyPrimitivesResult.future; + expect(manyPrimitives, -1 + 3 + 3.14.toInt() + 1); + + myInterface.delete(); + }); + } + }); + group('$groupName (load tests)', () { const k4 = 4 * 1024; // This is a round number, unlike say 4000 const k256 = 256 * 1024; diff --git a/pkgs/jnigen/test/test_util/bindings_test_setup.dart b/pkgs/jnigen/test/test_util/bindings_test_setup.dart index b4d292cbd..c493ad144 100644 --- a/pkgs/jnigen/test/test_util/bindings_test_setup.dart +++ b/pkgs/jnigen/test/test_util/bindings_test_setup.dart @@ -19,7 +19,7 @@ import 'test_util.dart'; final simplePackageTest = join('test', 'simple_package_test'); final jacksonCoreTest = join('test', 'jackson_core_test'); final kotlinTest = join('test', 'kotlin_test'); -final jniJar = join(kotlinTest, 'jni.jar'); +final jniJar = join('build', 'jni_libs', 'jni.jar'); final simplePackageTestJava = join(simplePackageTest, 'java'); final kotlinTestKotlin = join(kotlinTest, 'kotlin'); From 7e690dde926e1b32fdf7b1e006e622507c2e13f3 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Tue, 25 Jul 2023 16:27:31 +0200 Subject: [PATCH 105/139] [jnigen] Fix CI (https://github.com/dart-lang/jnigen/issues/330) --- pkgs/jnigen/test/test_util/test_util.dart | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkgs/jnigen/test/test_util/test_util.dart b/pkgs/jnigen/test/test_util/test_util.dart index 4ac90ac92..3c418abc3 100644 --- a/pkgs/jnigen/test/test_util/test_util.dart +++ b/pkgs/jnigen/test/test_util/test_util.dart @@ -88,9 +88,10 @@ void comparePaths(String path1, String path2) { if (diffProc.exitCode != 0) { final originalDiff = diffProc.stdout; log.warning( - "Paths $path1 and $path2 differ, comparing by ignoring space change"); - final fallbackDiffProc = Process.runSync( - "git", [...diffCommand, '--ignore-space-change', path1, path2]); + "Paths $path1 and $path2 differ, Running dart format on $path1."); + Process.runSync('dart', ['format', path1]); + final fallbackDiffProc = + Process.runSync("git", [...diffCommand, path1, path2]); if (fallbackDiffProc.exitCode != 0) { stderr.writeln(originalDiff); throw Exception("Paths $path1 and $path2 differ"); From ef333492657839614a7f613e0aa938e1c601b1b1 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Mon, 31 Jul 2023 12:55:57 +0200 Subject: [PATCH 106/139] [jnigen] Fix windows specifics and global reference ownership in interface implementation (https://github.com/dart-lang/jnigen/issues/335) Since Dart doesn't know that this global reference is still used, it might garbage collect it via NativeFinalizer thus making it invalid. We're letting Java handle the clean up and use setAsDeleted to detach the native finalizer from the return value in Dart. --- .../com/github/dart_lang/jni/PortProxy.java | 15 +++++-- pkgs/jni/src/dartjni.c | 42 +++++++++++++++---- pkgs/jni/src/dartjni.h | 9 +++- .../in_app_java/src/android_utils/dartjni.h | 9 +++- .../example/kotlin_plugin/src/dartjni.h | 9 +++- .../example/notification_plugin/src/dartjni.h | 9 +++- .../pdfbox_plugin/src/third_party/dartjni.h | 9 +++- .../lib/src/bindings/dart_generator.dart | 21 ++++++++-- .../third_party/c_based/c_bindings/dartjni.h | 9 +++- .../kotlin_test/c_based/c_bindings/dartjni.h | 9 +++- .../c_based/c_bindings/dartjni.h | 9 +++- .../c_based/dart_bindings/simple_package.dart | 10 +++-- .../dart_bindings/simple_package.dart | 10 +++-- 13 files changed, 132 insertions(+), 38 deletions(-) diff --git a/pkgs/jni/java/src/main/java/com/github/dart_lang/jni/PortProxy.java b/pkgs/jni/java/src/main/java/com/github/dart_lang/jni/PortProxy.java index a75a914f9..bae1c3254 100644 --- a/pkgs/jni/java/src/main/java/com/github/dart_lang/jni/PortProxy.java +++ b/pkgs/jni/java/src/main/java/com/github/dart_lang/jni/PortProxy.java @@ -62,21 +62,28 @@ private static void appendType(StringBuilder descriptor, Class type) { public static Object newInstance(String binaryName, long port, long threadId, long functionPtr) throws ClassNotFoundException { - Class clazz = Class.forName(binaryName); + Class clazz = Class.forName(binaryName); return Proxy.newProxyInstance( clazz.getClassLoader(), new Class[] {clazz}, new PortProxy(port, threadId, functionPtr)); } @Override - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - return _invoke(port, threadId, functionPtr, proxy, getDescriptor(method), args); + public Object invoke(Object proxy, Method method, Object[] args) { + Object[] result = _invoke(port, threadId, functionPtr, proxy, getDescriptor(method), args); + _cleanUp((Long) result[0]); + return result[1]; } - private native Object _invoke( + /// Returns an array with two objects: + /// [0]: The address of the result pointer used for the clean-up. + /// [1]: The result of the invocation. + private native Object[] _invoke( long port, long threadId, long functionPtr, Object proxy, String methodDescriptor, Object[] args); + + private native void _cleanUp(long resultPtr); } diff --git a/pkgs/jni/src/dartjni.c b/pkgs/jni/src/dartjni.c index 6f0fa0867..df8feb78d 100644 --- a/pkgs/jni/src/dartjni.c +++ b/pkgs/jni/src/dartjni.c @@ -636,7 +636,12 @@ void resultFor(CallbackResult* result, jobject object) { release_lock(&result->lock); } -JNIEXPORT jobject JNICALL +jclass _c_Object = NULL; +jclass _c_Long = NULL; + +jmethodID _m_Long_init = NULL; + +JNIEXPORT jobjectArray JNICALL Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, jobject thiz, jlong port, @@ -645,9 +650,8 @@ Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, jobject proxy, jstring methodDescriptor, jobjectArray args) { - attach_thread(); + CallbackResult* result = (CallbackResult*)malloc(sizeof(CallbackResult)); if (threadId != thread_id()) { - CallbackResult* result = (CallbackResult*)malloc(sizeof(CallbackResult)); init_lock(&result->lock); init_cond(&result->cond); acquire_lock(&result->lock); @@ -674,18 +678,40 @@ Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, c_post.value.as_array.length = sizeof(c_post_arr) / sizeof(c_post_arr[0]); Dart_PostCObject_DL(port, &c_post); + while (!result->ready) { wait_for(&result->cond, &result->lock); } + release_lock(&result->lock); destroy_lock(&result->lock); destroy_cond(&result->cond); - jobject object = result->object; - free(result); - return object; } else { - return ((jobject(*)(uint64_t, jobject, jobject))functionPtr)( + result->object = ((jobject(*)(uint64_t, jobject, jobject))functionPtr)( port, (*env)->NewGlobalRef(env, methodDescriptor), (*env)->NewGlobalRef(env, args)); } -} \ No newline at end of file + // Returning an array of length 2. + // [0]: The result pointer, used for cleaning up the global reference, and + // freeing the memory since we passed the ownership to Java. + // [1]: The returned object. + attach_thread(); + load_class_global_ref(&_c_Object, "java/lang/Object"); + load_class_global_ref(&_c_Long, "java/lang/Long"); + load_method(_c_Long, &_m_Long_init, "", "(J)V"); + jobject first = (*env)->NewObject(env, _c_Long, _m_Long_init, (jlong)result); + jobject second = result->object; + jobjectArray arr = (*env)->NewObjectArray(env, 2, _c_Object, NULL); + (*env)->SetObjectArrayElement(env, arr, 0, first); + (*env)->SetObjectArrayElement(env, arr, 1, second); + return arr; +} + +JNIEXPORT void JNICALL +Java_com_github_dart_1lang_jni_PortProxy__1cleanUp(JNIEnv* env, + jobject thiz, + jlong resultPtr) { + CallbackResult* result = (CallbackResult*)resultPtr; + (*env)->DeleteGlobalRef(env, result->object); + free(result); +} diff --git a/pkgs/jni/src/dartjni.h b/pkgs/jni/src/dartjni.h index cbb1f7f5c..8a07d0918 100644 --- a/pkgs/jni/src/dartjni.h +++ b/pkgs/jni/src/dartjni.h @@ -76,7 +76,7 @@ static inline void wait_for(ConditionVariable* cond, MutexLock* lock) { } static inline void destroy_cond(ConditionVariable* cond) { - DeleteCriticalSection(cond); + // Not available. } #elif defined __APPLE__ || defined __LINUX__ || defined __ANDROID__ || \ @@ -435,7 +435,7 @@ JniResult PortProxy__newInstance(jobject binaryName, int64_t port, int64_t functionPtr); -JNIEXPORT jobject JNICALL +JNIEXPORT jobjectArray JNICALL Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, jobject thiz, jlong port, @@ -444,3 +444,8 @@ Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, jobject proxy, jstring methodDescriptor, jobjectArray args); + +JNIEXPORT void JNICALL +Java_com_github_dart_1lang_jni_PortProxy__1cleanUp(JNIEnv* env, + jobject thiz, + jlong resultPtr); diff --git a/pkgs/jnigen/example/in_app_java/src/android_utils/dartjni.h b/pkgs/jnigen/example/in_app_java/src/android_utils/dartjni.h index cbb1f7f5c..8a07d0918 100644 --- a/pkgs/jnigen/example/in_app_java/src/android_utils/dartjni.h +++ b/pkgs/jnigen/example/in_app_java/src/android_utils/dartjni.h @@ -76,7 +76,7 @@ static inline void wait_for(ConditionVariable* cond, MutexLock* lock) { } static inline void destroy_cond(ConditionVariable* cond) { - DeleteCriticalSection(cond); + // Not available. } #elif defined __APPLE__ || defined __LINUX__ || defined __ANDROID__ || \ @@ -435,7 +435,7 @@ JniResult PortProxy__newInstance(jobject binaryName, int64_t port, int64_t functionPtr); -JNIEXPORT jobject JNICALL +JNIEXPORT jobjectArray JNICALL Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, jobject thiz, jlong port, @@ -444,3 +444,8 @@ Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, jobject proxy, jstring methodDescriptor, jobjectArray args); + +JNIEXPORT void JNICALL +Java_com_github_dart_1lang_jni_PortProxy__1cleanUp(JNIEnv* env, + jobject thiz, + jlong resultPtr); diff --git a/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h b/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h index cbb1f7f5c..8a07d0918 100644 --- a/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h +++ b/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h @@ -76,7 +76,7 @@ static inline void wait_for(ConditionVariable* cond, MutexLock* lock) { } static inline void destroy_cond(ConditionVariable* cond) { - DeleteCriticalSection(cond); + // Not available. } #elif defined __APPLE__ || defined __LINUX__ || defined __ANDROID__ || \ @@ -435,7 +435,7 @@ JniResult PortProxy__newInstance(jobject binaryName, int64_t port, int64_t functionPtr); -JNIEXPORT jobject JNICALL +JNIEXPORT jobjectArray JNICALL Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, jobject thiz, jlong port, @@ -444,3 +444,8 @@ Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, jobject proxy, jstring methodDescriptor, jobjectArray args); + +JNIEXPORT void JNICALL +Java_com_github_dart_1lang_jni_PortProxy__1cleanUp(JNIEnv* env, + jobject thiz, + jlong resultPtr); diff --git a/pkgs/jnigen/example/notification_plugin/src/dartjni.h b/pkgs/jnigen/example/notification_plugin/src/dartjni.h index cbb1f7f5c..8a07d0918 100644 --- a/pkgs/jnigen/example/notification_plugin/src/dartjni.h +++ b/pkgs/jnigen/example/notification_plugin/src/dartjni.h @@ -76,7 +76,7 @@ static inline void wait_for(ConditionVariable* cond, MutexLock* lock) { } static inline void destroy_cond(ConditionVariable* cond) { - DeleteCriticalSection(cond); + // Not available. } #elif defined __APPLE__ || defined __LINUX__ || defined __ANDROID__ || \ @@ -435,7 +435,7 @@ JniResult PortProxy__newInstance(jobject binaryName, int64_t port, int64_t functionPtr); -JNIEXPORT jobject JNICALL +JNIEXPORT jobjectArray JNICALL Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, jobject thiz, jlong port, @@ -444,3 +444,8 @@ Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, jobject proxy, jstring methodDescriptor, jobjectArray args); + +JNIEXPORT void JNICALL +Java_com_github_dart_1lang_jni_PortProxy__1cleanUp(JNIEnv* env, + jobject thiz, + jlong resultPtr); diff --git a/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h b/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h index cbb1f7f5c..8a07d0918 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h +++ b/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h @@ -76,7 +76,7 @@ static inline void wait_for(ConditionVariable* cond, MutexLock* lock) { } static inline void destroy_cond(ConditionVariable* cond) { - DeleteCriticalSection(cond); + // Not available. } #elif defined __APPLE__ || defined __LINUX__ || defined __ANDROID__ || \ @@ -435,7 +435,7 @@ JniResult PortProxy__newInstance(jobject binaryName, int64_t port, int64_t functionPtr); -JNIEXPORT jobject JNICALL +JNIEXPORT jobjectArray JNICALL Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, jobject thiz, jlong port, @@ -444,3 +444,8 @@ Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, jobject proxy, jstring methodDescriptor, jobjectArray args); + +JNIEXPORT void JNICALL +Java_com_github_dart_1lang_jni_PortProxy__1cleanUp(JNIEnv* env, + jobject thiz, + jlong resultPtr); diff --git a/pkgs/jnigen/lib/src/bindings/dart_generator.dart b/pkgs/jnigen/lib/src/bindings/dart_generator.dart index 3db7c0bc7..c78a3b25f 100644 --- a/pkgs/jnigen/lib/src/bindings/dart_generator.dart +++ b/pkgs/jnigen/lib/src/bindings/dart_generator.dart @@ -1534,8 +1534,9 @@ class _InterfaceMethodIf extends Visitor { @override void visit(Method node) { + final isVoid = node.returnType.name == 'void'; final signature = node.javaSig; - final saveResult = node.returnType.name == 'void' ? '' : 'final \$r = '; + final saveResult = isVoid ? '' : 'final \$r = '; s.write(''' if (\$d == r"$signature") { ${saveResult}_\$methods[\$p]![\$d]!( @@ -1588,13 +1589,25 @@ class _InterfaceParamCast extends Visitor { /// Only returns the reference for non primitive types. /// Returns null for void. /// -/// For example `$r.toJInteger().reference` when the return type is `integer`. +/// Since Dart doesn't know that this global reference is still used, it might +/// garbage collect it via [NativeFinalizer] thus making it invalid. +/// This passes the ownership to Java using [setAsDeleted]. +/// +/// `..setAsDeleted` detaches the object from the [NativeFinalizer] and Java +/// will clean up the global reference afterwards. +/// +/// For example `($r.toJInteger()..setAsDeleted()).reference` when the return +/// type is `integer`. class _InterfaceReturnBox extends TypeVisitor { const _InterfaceReturnBox(); @override String visitNonPrimitiveType(ReferredType node) { - return '\$r.reference'; + // Casting is done to create a new global reference. The user might + // use the original reference elsewhere and so the original object + // should not be [setAsDeleted]. + return '((\$r as $_jObject).castTo(const ${_jObject}Type())' + '..setAsDeleted()).reference'; } @override @@ -1602,7 +1615,7 @@ class _InterfaceReturnBox extends TypeVisitor { if (node.name == 'void') { return '$_jni.nullptr'; } - return '$_jni.J${node.boxedName}(\$r).reference'; + return '($_jni.J${node.boxedName}(\$r)..setAsDeleted()).reference'; } } diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/dartjni.h b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/dartjni.h index cbb1f7f5c..8a07d0918 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/dartjni.h +++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/dartjni.h @@ -76,7 +76,7 @@ static inline void wait_for(ConditionVariable* cond, MutexLock* lock) { } static inline void destroy_cond(ConditionVariable* cond) { - DeleteCriticalSection(cond); + // Not available. } #elif defined __APPLE__ || defined __LINUX__ || defined __ANDROID__ || \ @@ -435,7 +435,7 @@ JniResult PortProxy__newInstance(jobject binaryName, int64_t port, int64_t functionPtr); -JNIEXPORT jobject JNICALL +JNIEXPORT jobjectArray JNICALL Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, jobject thiz, jlong port, @@ -444,3 +444,8 @@ Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, jobject proxy, jstring methodDescriptor, jobjectArray args); + +JNIEXPORT void JNICALL +Java_com_github_dart_1lang_jni_PortProxy__1cleanUp(JNIEnv* env, + jobject thiz, + jlong resultPtr); diff --git a/pkgs/jnigen/test/kotlin_test/c_based/c_bindings/dartjni.h b/pkgs/jnigen/test/kotlin_test/c_based/c_bindings/dartjni.h index cbb1f7f5c..8a07d0918 100644 --- a/pkgs/jnigen/test/kotlin_test/c_based/c_bindings/dartjni.h +++ b/pkgs/jnigen/test/kotlin_test/c_based/c_bindings/dartjni.h @@ -76,7 +76,7 @@ static inline void wait_for(ConditionVariable* cond, MutexLock* lock) { } static inline void destroy_cond(ConditionVariable* cond) { - DeleteCriticalSection(cond); + // Not available. } #elif defined __APPLE__ || defined __LINUX__ || defined __ANDROID__ || \ @@ -435,7 +435,7 @@ JniResult PortProxy__newInstance(jobject binaryName, int64_t port, int64_t functionPtr); -JNIEXPORT jobject JNICALL +JNIEXPORT jobjectArray JNICALL Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, jobject thiz, jlong port, @@ -444,3 +444,8 @@ Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, jobject proxy, jstring methodDescriptor, jobjectArray args); + +JNIEXPORT void JNICALL +Java_com_github_dart_1lang_jni_PortProxy__1cleanUp(JNIEnv* env, + jobject thiz, + jlong resultPtr); diff --git a/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/dartjni.h b/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/dartjni.h index cbb1f7f5c..8a07d0918 100644 --- a/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/dartjni.h +++ b/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/dartjni.h @@ -76,7 +76,7 @@ static inline void wait_for(ConditionVariable* cond, MutexLock* lock) { } static inline void destroy_cond(ConditionVariable* cond) { - DeleteCriticalSection(cond); + // Not available. } #elif defined __APPLE__ || defined __LINUX__ || defined __ANDROID__ || \ @@ -435,7 +435,7 @@ JniResult PortProxy__newInstance(jobject binaryName, int64_t port, int64_t functionPtr); -JNIEXPORT jobject JNICALL +JNIEXPORT jobjectArray JNICALL Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, jobject thiz, jlong port, @@ -444,3 +444,8 @@ Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, jobject proxy, jstring methodDescriptor, jobjectArray args); + +JNIEXPORT void JNICALL +Java_com_github_dart_1lang_jni_PortProxy__1cleanUp(JNIEnv* env, + jobject thiz, + jlong resultPtr); diff --git a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart index 7cb011083..11e873e53 100644 --- a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart @@ -2979,13 +2979,17 @@ class MyInterface<$T extends jni.JObject> extends jni.JObject { final $r = _$methods[$p]![$d]!( $a[0].castTo(const jni.JStringType(), deleteOriginal: true), ); - return $r.reference; + return (($r as jni.JObject).castTo(const jni.JObjectType()) + ..setAsDeleted()) + .reference; } if ($d == r"varCallback(Ljava/lang/Object;)Ljava/lang/Object;") { final $r = _$methods[$p]![$d]!( $a[0].castTo(_$types[$p]!["T"]!, deleteOriginal: true), ); - return $r.reference; + return (($r as jni.JObject).castTo(const jni.JObjectType()) + ..setAsDeleted()) + .reference; } if ($d == r"manyPrimitives(IZCD)J") { final $r = _$methods[$p]![$d]!( @@ -3002,7 +3006,7 @@ class MyInterface<$T extends jni.JObject> extends jni.JObject { .castTo(const jni.JDoubleType(), deleteOriginal: true) .doubleValue(deleteOriginal: true), ); - return jni.JLong($r).reference; + return (jni.JLong($r)..setAsDeleted()).reference; } return jni.nullptr; } diff --git a/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart index 7befe1b98..ef24ce3ee 100644 --- a/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart @@ -2818,13 +2818,17 @@ class MyInterface<$T extends jni.JObject> extends jni.JObject { final $r = _$methods[$p]![$d]!( $a[0].castTo(const jni.JStringType(), deleteOriginal: true), ); - return $r.reference; + return (($r as jni.JObject).castTo(const jni.JObjectType()) + ..setAsDeleted()) + .reference; } if ($d == r"varCallback(Ljava/lang/Object;)Ljava/lang/Object;") { final $r = _$methods[$p]![$d]!( $a[0].castTo(_$types[$p]!["T"]!, deleteOriginal: true), ); - return $r.reference; + return (($r as jni.JObject).castTo(const jni.JObjectType()) + ..setAsDeleted()) + .reference; } if ($d == r"manyPrimitives(IZCD)J") { final $r = _$methods[$p]![$d]!( @@ -2841,7 +2845,7 @@ class MyInterface<$T extends jni.JObject> extends jni.JObject { .castTo(const jni.JDoubleType(), deleteOriginal: true) .doubleValue(deleteOriginal: true), ); - return jni.JLong($r).reference; + return (jni.JLong($r)..setAsDeleted()).reference; } return jni.nullptr; } From bb1c49fd8b86d955937ad8a485c561488fdf7b04 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Mon, 31 Jul 2023 13:03:37 +0200 Subject: [PATCH 107/139] [jnigen] Closes https://github.com/dart-lang/jnigen/issues/325 (https://github.com/dart-lang/jnigen/issues/336) --- pkgs/jnigen/example/README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pkgs/jnigen/example/README.md b/pkgs/jnigen/example/README.md index 5b0bfe6de..dce00fbd5 100644 --- a/pkgs/jnigen/example/README.md +++ b/pkgs/jnigen/example/README.md @@ -4,10 +4,10 @@ This directory contains examples on how to use jnigen. | Directory | Description | | ------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -| [in_app_java](in_app_java/) | Demonstrates how to include custom Java code in Flutter application and call that using jnigen | -| [pdfbox_plugin](pdfbox_plugin/) | Example of a flutter plugin which provides bindings to Apache PDFBox library. Currently works on Flutter desktop and Dart standalone on linux. | -| [notification_plugin](notification_plugin/) | Example of a reusable Flutter plugin with custom Java code which uses Android libraries. | -| [kotlin_plugin](kotlin_plugin/) | Example of using jnigen to generate bindings for Kotlin. | +| [in_app_java](https://github.com/dart-lang/jnigen/tree/main/jnigen/example/in_app_java/) | Demonstrates how to include custom Java code in Flutter application and call that using jnigen | +| [pdfbox_plugin](https://github.com/dart-lang/jnigen/tree/main/jnigen/example/pdfbox_plugin/) | Example of a flutter plugin which provides bindings to Apache PDFBox library. Currently works on Flutter desktop and Dart standalone on linux. | +| [notification_plugin](https://github.com/dart-lang/jnigen/tree/main/jnigen/example/notification_plugin/) | Example of a reusable Flutter plugin with custom Java code which uses Android libraries. | +| [kotlin_plugin](https://github.com/dart-lang/jnigen/tree/main/jnigen/example/kotlin_plugin) | Example of using jnigen to generate bindings for Kotlin. | We intend to cover few more use cases in future. @@ -16,12 +16,12 @@ We intend to cover few more use cases in future. ### Dart package (Standalone only) - Create dart package, add `jni` as dependency and `jnigen` as dev dependency. -- Write the jnigen config similar to [the one in pdfbox_plugin](pdfbox_plugin/jnigen.yaml). +- Write the jnigen config similar to [the one in pdfbox_plugin](https://github.com/dart-lang/jnigen/tree/main/jnigen/example/pdfbox_plugin/jnigen.yaml). - Generate JNI bindings by running `dart run jnigen --config jnigen.yaml`. - In the CLI project which uses this package, add this package, and `jni` as a dependency. - Run `dart run jni:setup` to build native libraries for JNI base library and jnigen generated package. -- Import the package. See [pdf_info.dart](pdfbox_plugin/dart_example/bin/pdf_info.dart) for an example of using JNI from dart standalone. +- Import the package. See [pdf_info.dart](https://github.com/dart-lang/jnigen/tree/main/jnigen/example/pdfbox_plugin/dart_example/bin/pdf_info.dart) for an example of using JNI from dart standalone. ### Flutter FFI plugin @@ -42,7 +42,7 @@ To create an FFI plugin with JNI bindings: - Create an FFI plugin with Android as the only platform. - Build the example/ Android project using command `flutter build apk`. After a release build is done, jnigen can use a gradle stub to collect compile classpaths. - Write your custom Java code in `android/src/main/java` hierarchy of the plugin. -- Generate JNI bindings as described above. See [notification_plugin/jnigen.yaml](notification_plugin/jnigen.yaml) for example configuration. +- Generate JNI bindings as described above. See [notification_plugin/jnigen.yaml](https://github.com/dart-lang/jnigen/tree/main/jnigen/example/notification_plugin/jnigen.yaml) for example configuration. ### Pure dart bindings From db9185a3675c3344704a739a0cb18235a9211931 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Mon, 31 Jul 2023 13:05:06 +0200 Subject: [PATCH 108/139] [jnigen] Override JObject's toString with appropriate Java's toString (https://github.com/dart-lang/jnigen/issues/337) * add toString * remove extra hashCode and == as JObject already has it --- pkgs/jni/lib/src/jobject.dart | 9 +++++++++ pkgs/jni/lib/src/util/jlist.dart | 15 --------------- pkgs/jni/lib/src/util/jset.dart | 17 ----------------- pkgs/jni/test/jstring_test.dart | 5 +++++ 4 files changed, 14 insertions(+), 32 deletions(-) diff --git a/pkgs/jni/lib/src/jobject.dart b/pkgs/jni/lib/src/jobject.dart index 5de5bbdf2..26df6be1b 100644 --- a/pkgs/jni/lib/src/jobject.dart +++ b/pkgs/jni/lib/src/jobject.dart @@ -342,6 +342,15 @@ class JObject extends JReference { return Jni.accessors.callMethodWithArgs(reference, _equalsId, JniCallType.booleanType, [other.reference]).boolean; } + + static final _toStringId = Jni.accessors.getMethodIDOf( + _objectClass.reference, r"toString", r"()Ljava/lang/String;"); + @override + String toString() { + return JString.fromRef(Jni.accessors.callMethodWithArgs( + reference, _toStringId, JniCallType.objectType, []).object) + .toDartString(deleteOriginal: true); + } } /// A high level wrapper over a JNI class reference. diff --git a/pkgs/jni/lib/src/util/jlist.dart b/pkgs/jni/lib/src/util/jlist.dart index eac7f20c5..8087af985 100644 --- a/pkgs/jni/lib/src/util/jlist.dart +++ b/pkgs/jni/lib/src/util/jlist.dart @@ -267,21 +267,6 @@ class JList<$E extends JObject> extends JObject with ListMixin<$E> { JSet<$E> toSet() { return toJSet(E); } - - static final _hashCodeId = - Jni.accessors.getMethodIDOf(_class.reference, r"hashCode", r"()I"); - @override - int get hashCode => Jni.accessors.callMethodWithArgs( - reference, _hashCodeId, JniCallType.intType, []).integer; - - static final _equalsId = Jni.accessors - .getMethodIDOf(_class.reference, r"equals", r"(Ljava/lang/Object;)Z"); - @override - bool operator ==(Object other) { - if (other is! JObject) return false; - return Jni.accessors.callMethodWithArgs(reference, _equalsId, - JniCallType.booleanType, [other.reference]).boolean; - } } extension ToJavaList on Iterable { diff --git a/pkgs/jni/lib/src/util/jset.dart b/pkgs/jni/lib/src/util/jset.dart index 530010782..367c1213c 100644 --- a/pkgs/jni/lib/src/util/jset.dart +++ b/pkgs/jni/lib/src/util/jset.dart @@ -190,23 +190,6 @@ class JSet<$E extends JObject> extends JObject with SetMixin<$E> { return super.retainAll(elements); } - static final _hashCodeId = - Jni.accessors.getMethodIDOf(_class.reference, r"hashCode", r"()I"); - @override - int get hashCode => Jni.accessors.callMethodWithArgs( - reference, _hashCodeId, JniCallType.intType, []).integer; - - static final _equalsId = Jni.accessors - .getMethodIDOf(_class.reference, r"equals", r"(Ljava/lang/Object;)Z"); - @override - bool operator ==(Object other) { - if (other is! JObject) { - return false; - } - return Jni.accessors.callMethodWithArgs(reference, _equalsId, - JniCallType.booleanType, [other.reference]).boolean; - } - @override $E? lookup(Object? element) { if (contains(element)) return element as $E; diff --git a/pkgs/jni/test/jstring_test.dart b/pkgs/jni/test/jstring_test.dart index 1bc6436af..210c91d6f 100644 --- a/pkgs/jni/test/jstring_test.dart +++ b/pkgs/jni/test/jstring_test.dart @@ -43,4 +43,9 @@ void run({required TestRunnerCallback testRunner}) { testStringBackAndForth(''); }); }); + + testRunner('Inherited toString', () { + final s = 'hello'.toJString(); + expect(s.toString(), 'hello'); + }); } From 2527e476ac6862f67a86602c67982fc93706d555 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Aug 2023 21:02:41 +0000 Subject: [PATCH 109/139] [jnigen] Bump coverallsapp/github-action from 2.2.0 to 2.2.1 (https://github.com/dart-lang/jnigen/issues/339) Bumps [coverallsapp/github-action](https://github.com/coverallsapp/github-action) from 2.2.0 to 2.2.1.

    [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=coverallsapp/github-action&package-manager=github_actions&previous-version=2.2.0&new-version=2.2.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
    Dependabot commands and options
    You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    --- .github/workflows/test-package.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 4e5da23df..8dfe768a2 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -106,7 +106,7 @@ jobs: - name: Collect coverage run: dart pub global run coverage:test_with_coverage - name: Upload coverage - uses: coverallsapp/github-action@c7885c00cb7ec0b8f9f5ff3f53cddb980f7a4412 + uses: coverallsapp/github-action@95b1a2355bd0e526ad2fd62da9fd386ad4c98474 with: github-token: ${{ secrets.GITHUB_TOKEN }} flag-name: jnigen_tests @@ -182,7 +182,7 @@ jobs: - name: Collect coverage run: dart pub global run coverage:test_with_coverage - name: Upload coverage - uses: coverallsapp/github-action@c7885c00cb7ec0b8f9f5ff3f53cddb980f7a4412 + uses: coverallsapp/github-action@95b1a2355bd0e526ad2fd62da9fd386ad4c98474 with: github-token: ${{ secrets.GITHUB_TOKEN }} flag-name: jni_tests @@ -420,7 +420,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Coveralls finished - uses: coverallsapp/github-action@c7885c00cb7ec0b8f9f5ff3f53cddb980f7a4412 + uses: coverallsapp/github-action@95b1a2355bd0e526ad2fd62da9fd386ad4c98474 with: github-token: ${{ secrets.github_token }} parallel-finished: true From 9492c19605f834f8960585cb3e88f0891412ff49 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Aug 2023 11:04:36 +0200 Subject: [PATCH 110/139] [jnigen] Bump actions/setup-java from 3.11.0 to 3.12.0 (https://github.com/dart-lang/jnigen/issues/338) Bumps [actions/setup-java](https://github.com/actions/setup-java) from 3.11.0 to 3.12.0. - [Release notes](https://github.com/actions/setup-java/releases) - [Commits](https://github.com/actions/setup-java/compare/5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2...cd89f46ac9d01407894225f350157564c9c7cee2) --- updated-dependencies: - dependency-name: actions/setup-java dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/test-package.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 8dfe768a2..7f6bcb331 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -73,7 +73,7 @@ jobs: channel: ${{ matrix.sdk }} cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 + - uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 with: distribution: 'zulu' java-version: '11' @@ -126,7 +126,7 @@ jobs: channel: 'stable' cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 + - uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 with: distribution: 'zulu' java-version: '11' @@ -164,7 +164,7 @@ jobs: channel: 'stable' cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 + - uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 with: distribution: 'zulu' java-version: '11' @@ -213,7 +213,7 @@ jobs: channel: 'stable' cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 + - uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 with: distribution: 'zulu' java-version: '11' @@ -240,7 +240,7 @@ jobs: channel: 'stable' cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 + - uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 with: distribution: 'zulu' java-version: '11' @@ -274,7 +274,7 @@ jobs: channel: 'stable' cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 + - uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 with: distribution: 'temurin' java-version: '11' @@ -299,7 +299,7 @@ jobs: channel: 'stable' cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 + - uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 with: distribution: 'temurin' java-version: '11' @@ -324,7 +324,7 @@ jobs: channel: 'stable' cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 + - uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 with: distribution: 'zulu' java-version: '11' @@ -348,7 +348,7 @@ jobs: channel: 'stable' cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 + - uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 with: distribution: 'zulu' java-version: '11' @@ -363,7 +363,7 @@ jobs: working-directory: ./pkgs/jni/example steps: - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - - uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 + - uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 with: distribution: 'zulu' java-version: '11' @@ -387,7 +387,7 @@ jobs: channel: 'stable' cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 + - uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 with: distribution: 'zulu' java-version: '11' From 17d48f8e905698cede94abe9f69acfbfb373b5f0 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Wed, 16 Aug 2023 11:47:07 +0200 Subject: [PATCH 111/139] [jnigen] Clean up interface implementation using auxiliary generated classes (https://github.com/dart-lang/jnigen/issues/349) * Use impl classes for implementing interfaces --- .../lib/src/bindings/dart_generator.dart | 254 ++++++++++++------ .../c_based/dart_bindings/simple_package.dart | 100 ++++--- .../dart_bindings/simple_package.dart | 100 ++++--- .../runtime_test_registrant.dart | 45 ++-- 4 files changed, 329 insertions(+), 170 deletions(-) diff --git a/pkgs/jnigen/lib/src/bindings/dart_generator.dart b/pkgs/jnigen/lib/src/bindings/dart_generator.dart index c78a3b25f..ab710f626 100644 --- a/pkgs/jnigen/lib/src/bindings/dart_generator.dart +++ b/pkgs/jnigen/lib/src/bindings/dart_generator.dart @@ -15,11 +15,11 @@ import 'c_generator.dart'; import 'resolver.dart'; import 'visitor.dart'; -// Import prefixes +// Import prefixes. const _jni = 'jni'; const _ffi = 'ffi'; -// package:jni types +// package:jni types. const _jType = '$_jni.JObjType'; const _jPointer = '$_jni.JObjectPtr'; const _jArray = '$_jni.JArray'; @@ -27,10 +27,10 @@ const _jObject = '$_jni.JObject'; const _jResult = '$_jni.JniResult'; const _jCallType = '$_jni.JniCallType'; -// package:ffi types +// package:ffi types. const _voidPointer = '$_ffi.Pointer<$_ffi.Void>'; -// Prefixes and suffixes +// Prefixes and suffixes. const _typeParamPrefix = '\$'; // Misc. @@ -41,7 +41,7 @@ const _accessors = '$_jni.Jni.accessors'; const _lookup = 'jniLookup'; const _selfPointer = 'reference'; -// Docs +// Docs. const _deleteInstruction = ' /// The returned object must be deleted after use, ' 'by calling the `delete` method.'; @@ -282,7 +282,7 @@ import "package:jni/jni.dart" as jni; } } -/// Generates the Dart class definition, type class, and the array extension +/// Generates the Dart class definition, type class, and the array extension. class _ClassGenerator extends Visitor { final Config config; final StringSink s; @@ -302,13 +302,14 @@ class _ClassGenerator extends Visitor { final isDartOnly = config.outputConfig.bindingsType == BindingsType.dartOnly; - // Docs + // Docs. s.write('/// from: ${node.binaryName}\n'); node.javadoc?.accept(_DocGenerator(s, depth: 0)); - // Class definition + // Class definition. final name = node.finalName; final superName = node.superclass!.accept(_TypeGenerator(resolver)); + final implClassName = '\$${name}Impl'; final typeParamsDef = _encloseIfNotEmpty( '<', node.allTypeParams @@ -328,7 +329,7 @@ class _ClassGenerator extends Visitor { typeParams.join(', '), ')', ); - final typeClassDefinitions = typeParams + final typeClassesDef = typeParams .map((typeParam) => 'final $_jType<$_typeParamPrefix$typeParam> $typeParam;') .join(_newLine(depth: 1)); @@ -347,7 +348,7 @@ class $name$typeParamsDef extends $superName { @override late final $_jType<$name$typeParamsCall> $instanceTypeGetter = $staticTypeGetter$staticTypeGetterCallArgs; - $typeClassDefinitions + $typeClassesDef $name.fromRef( $ctorTypeClassesDef @@ -367,7 +368,7 @@ class $name$typeParamsDef extends $superName { '''); } - // Static TypeClass getter + // Static TypeClass getter. s.writeln( ' /// The type which includes information such as the signature of this class.'); final typeClassName = node.typeClassName; @@ -402,29 +403,24 @@ class $name$typeParamsDef extends $superName { method.accept(methodGenerator); } - // Experimental: Interface implementation + // Experimental: Interface implementation. if (node.declKind == DeclKind.interfaceKind && (config.experiments?.contains(Experiment.interfaceImplementation) ?? false)) { s.write(''' - /// Maps a specific port to the implemented methods. - static final Map> _\$methods = {}; - - /// Maps a specific port to the type parameters. - static final Map> _\$types = {}; + /// Maps a specific port to the implemented interface. + static final Map _\$impls = {}; ReceivePort? _\$p; static final Finalizer _\$finalizer = Finalizer((\$p) { - _\$methods.remove(\$p.sendPort.nativePort); - _\$types.remove(\$p.sendPort.nativePort); + _\$impls.remove(\$p.sendPort.nativePort); \$p.close(); }); @override void delete() { - _\$methods.remove(_\$p?.sendPort.nativePort); - _\$types.remove(_\$p?.sendPort.nativePort); + _\$impls.remove(_\$p?.sendPort.nativePort); _\$p?.close(); _\$finalizer.detach(this); super.delete(); @@ -467,21 +463,13 @@ class $name$typeParamsDef extends $superName { } factory $name.implement( + $implClassName$typeParamsCall \$impl, + ) { '''); - final typeClassesCall = - typeParams.map((typeParam) => '$typeParam,').join(_newLine(depth: 3)); - s.write(_encloseIfNotEmpty( - '{', - [ - ...typeParams - .map((typeParam) => 'required $_jType<\$$typeParam> $typeParam,'), - ...node.methods.accept(_InterfaceImplementArg(resolver)) - ].join(_newLine(depth: 2)), - '}', - )); - + final typeClassesCall = typeParams + .map((typeParam) => '\$impl.$typeParam,') + .join(_newLine(depth: 3)); s.write(''' - ) { final \$p = ReceivePort(); final \$x = $name.fromRef( $typeClassesCall @@ -492,17 +480,8 @@ class $name$typeParamsDef extends $superName { ), ).._\$p = \$p; final \$a = \$p.sendPort.nativePort; - _\$types[\$a] = {}; - _\$methods[\$a] = {}; + _\$impls[\$a] = \$impl; '''); - final typeFiller = _InterfaceTypesFiller(s); - for (final typeParam in node.allTypeParams) { - typeParam.accept(typeFiller); - } - final methodFiller = _InterfaceMethodsFiller(s); - for (final method in node.methods) { - method.accept(methodFiller); - } s.write(''' _\$finalizer.attach(\$x, \$p, detach: \$x); \$p.listen((\$m) { @@ -515,10 +494,87 @@ class $name$typeParamsDef extends $superName { '''); } - // End of Class definition + // End of Class definition. s.writeln('}'); - // TypeClass definition + // Experimental: Interface implementation + // Abstract and concrete Impl class definition. + // Used for interface implementation. + if (node.declKind == DeclKind.interfaceKind && + (config.experiments?.contains(Experiment.interfaceImplementation) ?? + false)) { + // Abstract Impl class. + final typeClassGetters = typeParams + .map((typeParam) => + '$_jType<$_typeParamPrefix$typeParam> get $typeParam;') + .join(_newLine(depth: 1)); + final abstractFactoryArgs = _encloseIfNotEmpty( + '{', + [ + ...typeParams + .map((typeParam) => 'required $_jType<\$$typeParam> $typeParam,'), + ...node.methods.accept(_ConcreteImplClosureCtorArg(resolver)), + ].join(_newLine(depth: 2)), + '}', + ); + s.write(''' +abstract class $implClassName$typeParamsDef { + factory $implClassName( + $abstractFactoryArgs + ) = _$implClassName; + + $typeClassGetters + +'''); + final abstractImplMethod = _AbstractImplMethod(resolver, s); + for (final method in node.methods) { + method.accept(abstractImplMethod); + } + s.writeln('}'); + + // Concrete Impl class. + // This is for passing closures instead of implementing the class. + final concreteCtorArgs = _encloseIfNotEmpty( + '{', + [ + ...typeParams.map((typeParam) => 'required this.$typeParam,'), + ...node.methods.accept(_ConcreteImplClosureCtorArg(resolver)), + ].join(_newLine(depth: 2)), + '}', + ); + final setClosures = _encloseIfNotEmpty( + ' : ', + node.methods + .map((method) => '_${method.finalName} = ${method.finalName}') + .join(', '), + '', + ); + final typeClassesDef = typeParams.map((typeParam) => ''' +@override +final $_jType<\$$typeParam> $typeParam; +''').join(_newLine(depth: 1)); + s.write(''' + +class _$implClassName$typeParamsDef implements $implClassName$typeParamsCall { + _$implClassName( + $concreteCtorArgs + )$setClosures; + + $typeClassesDef + +'''); + final concreteClosureDef = _ConcreteImplClosureDef(resolver, s); + for (final method in node.methods) { + method.accept(concreteClosureDef); + } + s.writeln(); + final concreteMethodDef = _ConcreteImplMethod(resolver, s); + for (final method in node.methods) { + method.accept(concreteMethodDef); + } + s.writeln('}'); + } + // TypeClass definition. final typeClassesCall = typeParams.map((typeParam) => '$typeParam,').join(_newLine(depth: 2)); final signature = node.signature; @@ -532,7 +588,7 @@ class $name$typeParamsDef extends $superName { : 'Object.hash($typeClassName, $hashCodeTypeClasses)'; s.write(''' class $typeClassName$typeParamsDef extends $_jType<$name$typeParamsCall> { - $typeClassDefinitions + $typeClassesDef const $typeClassName( $ctorTypeClassesDef @@ -704,7 +760,7 @@ class _TypeClassGenerator extends TypeVisitor<_TypeClass> { final innerTypeClass = node.type.accept(_TypeClassGenerator( resolver, isConst: false, - boxPrimitives: boxPrimitives, + boxPrimitives: false, typeVarFromMap: typeVarFromMap, )); final ifConst = innerTypeClass.canBeConst && isConst ? 'const ' : ''; @@ -724,7 +780,7 @@ class _TypeClassGenerator extends TypeVisitor<_TypeClass> { final definedTypeClasses = node.params.accept(_TypeClassGenerator( resolver, isConst: false, - boxPrimitives: boxPrimitives, + boxPrimitives: false, typeVarFromMap: typeVarFromMap, )); @@ -773,7 +829,7 @@ class _TypeClassGenerator extends TypeVisitor<_TypeClass> { @override _TypeClass visitTypeVar(TypeVar node) { if (typeVarFromMap) { - return _TypeClass('_\$types[\$p]!["${node.name}"]!', false); + return _TypeClass('_\$impls[\$p]!.${node.name}', false); } return _TypeClass(node.name, false); } @@ -1026,10 +1082,10 @@ class _FieldGenerator extends Visitor { } } - // Accessors + // Accessors. (isCBased ? writeCAccessor : writeDartOnlyAccessor)(node); - // Getter docs + // Getter docs. writeDocs(node, writeDeleteInstructions: true); final name = node.finalName; @@ -1041,7 +1097,7 @@ class _FieldGenerator extends Visitor { )); s.writeln(';\n'); if (!node.isFinal) { - // Setter docs + // Setter docs. writeDocs(node, writeDeleteInstructions: true); s.write('${ifStatic}set $name($type value) => '); @@ -1510,11 +1566,44 @@ class _TypeVarLocator extends TypeVisitor>> { } } -/// The argument for .implement method of interfaces. -class _InterfaceImplementArg extends Visitor { +/// Method defintion for Impl abstract class used for interface implementation. +class _AbstractImplMethod extends Visitor { + final Resolver resolver; + final StringSink s; + + _AbstractImplMethod(this.resolver, this.s); + + @override + void visit(Method node) { + final returnType = node.returnType.accept(_TypeGenerator(resolver)); + final name = node.finalName; + final args = node.params.accept(_ParamDef(resolver)).join(', '); + s.writeln(' $returnType $name($args);'); + } +} + +/// Closure defintion for concrete Impl class used for interface implementation. +class _ConcreteImplClosureDef extends Visitor { final Resolver resolver; + final StringSink s; - _InterfaceImplementArg(this.resolver); + _ConcreteImplClosureDef(this.resolver, this.s); + + @override + void visit(Method node) { + final returnType = node.returnType.accept(_TypeGenerator(resolver)); + final name = node.finalName; + final args = node.params.accept(_ParamDef(resolver)).join(', '); + s.writeln(' final $returnType Function($args) _$name;'); + } +} + +/// Closure argument for concrete Impl class constructor. +/// Used for interface implementation. +class _ConcreteImplClosureCtorArg extends Visitor { + final Resolver resolver; + + _ConcreteImplClosureCtorArg(this.resolver); @override String visit(Method node) { @@ -1525,6 +1614,26 @@ class _InterfaceImplementArg extends Visitor { } } +/// Method defintion for concrete Impl class used for interface implementation. +class _ConcreteImplMethod extends Visitor { + final Resolver resolver; + final StringSink s; + + _ConcreteImplMethod(this.resolver, this.s); + + @override + void visit(Method node) { + final returnType = node.returnType.accept(_TypeGenerator(resolver)); + final name = node.finalName; + final argsDef = node.params.accept(_ParamDef(resolver)).join(', '); + final argsCall = node.params.map((param) => param.finalName).join(', '); + s.write(''' + $returnType $name($argsDef) { + return _$name($argsCall); + }'''); + } +} + /// The if statement to check which method has been called from the proxy class. class _InterfaceMethodIf extends Visitor { final Resolver resolver; @@ -1537,9 +1646,10 @@ class _InterfaceMethodIf extends Visitor { final isVoid = node.returnType.name == 'void'; final signature = node.javaSig; final saveResult = isVoid ? '' : 'final \$r = '; + final name = node.finalName; s.write(''' if (\$d == r"$signature") { - ${saveResult}_\$methods[\$p]![\$d]!( + ${saveResult}_\$impls[\$p]!.$name( '''); for (var i = 0; i < node.params.length; ++i) { node.params[i].accept(_InterfaceParamCast(resolver, s, paramIndex: i)); @@ -1618,33 +1728,3 @@ class _InterfaceReturnBox extends TypeVisitor { return '($_jni.J${node.boxedName}(\$r)..setAsDeleted()).reference'; } } - -/// Fills the static _$types map with the correct type classes for the given -/// port. -class _InterfaceTypesFiller extends Visitor { - final StringSink s; - - _InterfaceTypesFiller(this.s); - - @override - void visit(TypeParam node) { - s.write(''' - _\$types[\$a]!["${node.name}"] = ${node.name}; -'''); - } -} - -/// Fills the static _$method map with the correct callbacks for the given -/// port. -class _InterfaceMethodsFiller extends Visitor { - final StringSink s; - - _InterfaceMethodsFiller(this.s); - - @override - void visit(Method node) { - s.write(''' - _\$methods[\$a]![r"${node.javaSig}"] = ${node.finalName}; -'''); - } -} diff --git a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart index 11e873e53..27f396211 100644 --- a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart @@ -2919,24 +2919,19 @@ class MyInterface<$T extends jni.JObject> extends jni.JObject { return _manyPrimitives(reference, a, b ? 1 : 0, c, d).long; } - /// Maps a specific port to the implemented methods. - static final Map> _$methods = {}; - - /// Maps a specific port to the type parameters. - static final Map> _$types = {}; + /// Maps a specific port to the implemented interface. + static final Map _$impls = {}; ReceivePort? _$p; static final Finalizer _$finalizer = Finalizer(($p) { - _$methods.remove($p.sendPort.nativePort); - _$types.remove($p.sendPort.nativePort); + _$impls.remove($p.sendPort.nativePort); $p.close(); }); @override void delete() { - _$methods.remove(_$p?.sendPort.nativePort); - _$types.remove(_$p?.sendPort.nativePort); + _$impls.remove(_$p?.sendPort.nativePort); _$p?.close(); _$finalizer.detach(this); super.delete(); @@ -2970,13 +2965,13 @@ class MyInterface<$T extends jni.JObject> extends jni.JObject { final $d = $i.methodDescriptor.toDartString(deleteOriginal: true); final $a = $i.args; if ($d == r"voidCallback(Ljava/lang/String;)V") { - _$methods[$p]![$d]!( + _$impls[$p]!.voidCallback( $a[0].castTo(const jni.JStringType(), deleteOriginal: true), ); return jni.nullptr; } if ($d == r"stringCallback(Ljava/lang/String;)Ljava/lang/String;") { - final $r = _$methods[$p]![$d]!( + final $r = _$impls[$p]!.stringCallback( $a[0].castTo(const jni.JStringType(), deleteOriginal: true), ); return (($r as jni.JObject).castTo(const jni.JObjectType()) @@ -2984,15 +2979,15 @@ class MyInterface<$T extends jni.JObject> extends jni.JObject { .reference; } if ($d == r"varCallback(Ljava/lang/Object;)Ljava/lang/Object;") { - final $r = _$methods[$p]![$d]!( - $a[0].castTo(_$types[$p]!["T"]!, deleteOriginal: true), + final $r = _$impls[$p]!.varCallback( + $a[0].castTo(_$impls[$p]!.T, deleteOriginal: true), ); return (($r as jni.JObject).castTo(const jni.JObjectType()) ..setAsDeleted()) .reference; } if ($d == r"manyPrimitives(IZCD)J") { - final $r = _$methods[$p]![$d]!( + final $r = _$impls[$p]!.manyPrimitives( $a[0] .castTo(const jni.JIntegerType(), deleteOriginal: true) .intValue(deleteOriginal: true), @@ -3011,16 +3006,12 @@ class MyInterface<$T extends jni.JObject> extends jni.JObject { return jni.nullptr; } - factory MyInterface.implement({ - required jni.JObjType<$T> T, - required void Function(jni.JString s) voidCallback, - required jni.JString Function(jni.JString s) stringCallback, - required $T Function($T t) varCallback, - required int Function(int a, bool b, int c, double d) manyPrimitives, - }) { + factory MyInterface.implement( + $MyInterfaceImpl<$T> $impl, + ) { final $p = ReceivePort(); final $x = MyInterface.fromRef( - T, + $impl.T, ProtectedJniExtensions.newPortProxy( r"com.github.dart_lang.jnigen.interfaces.MyInterface", $p, @@ -3028,15 +3019,7 @@ class MyInterface<$T extends jni.JObject> extends jni.JObject { ), ).._$p = $p; final $a = $p.sendPort.nativePort; - _$types[$a] = {}; - _$methods[$a] = {}; - _$types[$a]!["T"] = T; - _$methods[$a]![r"voidCallback(Ljava/lang/String;)V"] = voidCallback; - _$methods[$a]![r"stringCallback(Ljava/lang/String;)Ljava/lang/String;"] = - stringCallback; - _$methods[$a]![r"varCallback(Ljava/lang/Object;)Ljava/lang/Object;"] = - varCallback; - _$methods[$a]![r"manyPrimitives(IZCD)J"] = manyPrimitives; + _$impls[$a] = $impl; _$finalizer.attach($x, $p, detach: $x); $p.listen(($m) { final $i = $MethodInvocation.fromMessage($m); @@ -3047,6 +3030,61 @@ class MyInterface<$T extends jni.JObject> extends jni.JObject { } } +abstract class $MyInterfaceImpl<$T extends jni.JObject> { + factory $MyInterfaceImpl({ + required jni.JObjType<$T> T, + required void Function(jni.JString s) voidCallback, + required jni.JString Function(jni.JString s) stringCallback, + required $T Function($T t) varCallback, + required int Function(int a, bool b, int c, double d) manyPrimitives, + }) = _$MyInterfaceImpl; + + jni.JObjType<$T> get T; + + void voidCallback(jni.JString s); + jni.JString stringCallback(jni.JString s); + $T varCallback($T t); + int manyPrimitives(int a, bool b, int c, double d); +} + +class _$MyInterfaceImpl<$T extends jni.JObject> + implements $MyInterfaceImpl<$T> { + _$MyInterfaceImpl({ + required this.T, + required void Function(jni.JString s) voidCallback, + required jni.JString Function(jni.JString s) stringCallback, + required $T Function($T t) varCallback, + required int Function(int a, bool b, int c, double d) manyPrimitives, + }) : _voidCallback = voidCallback, + _stringCallback = stringCallback, + _varCallback = varCallback, + _manyPrimitives = manyPrimitives; + + @override + final jni.JObjType<$T> T; + + final void Function(jni.JString s) _voidCallback; + final jni.JString Function(jni.JString s) _stringCallback; + final $T Function($T t) _varCallback; + final int Function(int a, bool b, int c, double d) _manyPrimitives; + + void voidCallback(jni.JString s) { + return _voidCallback(s); + } + + jni.JString stringCallback(jni.JString s) { + return _stringCallback(s); + } + + $T varCallback($T t) { + return _varCallback(t); + } + + int manyPrimitives(int a, bool b, int c, double d) { + return _manyPrimitives(a, b, c, d); + } +} + class $MyInterfaceType<$T extends jni.JObject> extends jni.JObjType> { final jni.JObjType<$T> T; diff --git a/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart index ef24ce3ee..9d016f7fe 100644 --- a/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart @@ -2758,24 +2758,19 @@ class MyInterface<$T extends jni.JObject> extends jni.JObject { [jni.JValueInt(a), b ? 1 : 0, jni.JValueChar(c), d]).long; } - /// Maps a specific port to the implemented methods. - static final Map> _$methods = {}; - - /// Maps a specific port to the type parameters. - static final Map> _$types = {}; + /// Maps a specific port to the implemented interface. + static final Map _$impls = {}; ReceivePort? _$p; static final Finalizer _$finalizer = Finalizer(($p) { - _$methods.remove($p.sendPort.nativePort); - _$types.remove($p.sendPort.nativePort); + _$impls.remove($p.sendPort.nativePort); $p.close(); }); @override void delete() { - _$methods.remove(_$p?.sendPort.nativePort); - _$types.remove(_$p?.sendPort.nativePort); + _$impls.remove(_$p?.sendPort.nativePort); _$p?.close(); _$finalizer.detach(this); super.delete(); @@ -2809,13 +2804,13 @@ class MyInterface<$T extends jni.JObject> extends jni.JObject { final $d = $i.methodDescriptor.toDartString(deleteOriginal: true); final $a = $i.args; if ($d == r"voidCallback(Ljava/lang/String;)V") { - _$methods[$p]![$d]!( + _$impls[$p]!.voidCallback( $a[0].castTo(const jni.JStringType(), deleteOriginal: true), ); return jni.nullptr; } if ($d == r"stringCallback(Ljava/lang/String;)Ljava/lang/String;") { - final $r = _$methods[$p]![$d]!( + final $r = _$impls[$p]!.stringCallback( $a[0].castTo(const jni.JStringType(), deleteOriginal: true), ); return (($r as jni.JObject).castTo(const jni.JObjectType()) @@ -2823,15 +2818,15 @@ class MyInterface<$T extends jni.JObject> extends jni.JObject { .reference; } if ($d == r"varCallback(Ljava/lang/Object;)Ljava/lang/Object;") { - final $r = _$methods[$p]![$d]!( - $a[0].castTo(_$types[$p]!["T"]!, deleteOriginal: true), + final $r = _$impls[$p]!.varCallback( + $a[0].castTo(_$impls[$p]!.T, deleteOriginal: true), ); return (($r as jni.JObject).castTo(const jni.JObjectType()) ..setAsDeleted()) .reference; } if ($d == r"manyPrimitives(IZCD)J") { - final $r = _$methods[$p]![$d]!( + final $r = _$impls[$p]!.manyPrimitives( $a[0] .castTo(const jni.JIntegerType(), deleteOriginal: true) .intValue(deleteOriginal: true), @@ -2850,16 +2845,12 @@ class MyInterface<$T extends jni.JObject> extends jni.JObject { return jni.nullptr; } - factory MyInterface.implement({ - required jni.JObjType<$T> T, - required void Function(jni.JString s) voidCallback, - required jni.JString Function(jni.JString s) stringCallback, - required $T Function($T t) varCallback, - required int Function(int a, bool b, int c, double d) manyPrimitives, - }) { + factory MyInterface.implement( + $MyInterfaceImpl<$T> $impl, + ) { final $p = ReceivePort(); final $x = MyInterface.fromRef( - T, + $impl.T, ProtectedJniExtensions.newPortProxy( r"com.github.dart_lang.jnigen.interfaces.MyInterface", $p, @@ -2867,15 +2858,7 @@ class MyInterface<$T extends jni.JObject> extends jni.JObject { ), ).._$p = $p; final $a = $p.sendPort.nativePort; - _$types[$a] = {}; - _$methods[$a] = {}; - _$types[$a]!["T"] = T; - _$methods[$a]![r"voidCallback(Ljava/lang/String;)V"] = voidCallback; - _$methods[$a]![r"stringCallback(Ljava/lang/String;)Ljava/lang/String;"] = - stringCallback; - _$methods[$a]![r"varCallback(Ljava/lang/Object;)Ljava/lang/Object;"] = - varCallback; - _$methods[$a]![r"manyPrimitives(IZCD)J"] = manyPrimitives; + _$impls[$a] = $impl; _$finalizer.attach($x, $p, detach: $x); $p.listen(($m) { final $i = $MethodInvocation.fromMessage($m); @@ -2886,6 +2869,61 @@ class MyInterface<$T extends jni.JObject> extends jni.JObject { } } +abstract class $MyInterfaceImpl<$T extends jni.JObject> { + factory $MyInterfaceImpl({ + required jni.JObjType<$T> T, + required void Function(jni.JString s) voidCallback, + required jni.JString Function(jni.JString s) stringCallback, + required $T Function($T t) varCallback, + required int Function(int a, bool b, int c, double d) manyPrimitives, + }) = _$MyInterfaceImpl; + + jni.JObjType<$T> get T; + + void voidCallback(jni.JString s); + jni.JString stringCallback(jni.JString s); + $T varCallback($T t); + int manyPrimitives(int a, bool b, int c, double d); +} + +class _$MyInterfaceImpl<$T extends jni.JObject> + implements $MyInterfaceImpl<$T> { + _$MyInterfaceImpl({ + required this.T, + required void Function(jni.JString s) voidCallback, + required jni.JString Function(jni.JString s) stringCallback, + required $T Function($T t) varCallback, + required int Function(int a, bool b, int c, double d) manyPrimitives, + }) : _voidCallback = voidCallback, + _stringCallback = stringCallback, + _varCallback = varCallback, + _manyPrimitives = manyPrimitives; + + @override + final jni.JObjType<$T> T; + + final void Function(jni.JString s) _voidCallback; + final jni.JString Function(jni.JString s) _stringCallback; + final $T Function($T t) _varCallback; + final int Function(int a, bool b, int c, double d) _manyPrimitives; + + void voidCallback(jni.JString s) { + return _voidCallback(s); + } + + jni.JString stringCallback(jni.JString s) { + return _stringCallback(s); + } + + $T varCallback($T t) { + return _varCallback(t); + } + + int manyPrimitives(int a, bool b, int c, double d) { + return _manyPrimitives(a, b, c, d); + } +} + class $MyInterfaceType<$T extends jni.JObject> extends jni.JObjType> { final jni.JObjType<$T> T; 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 cd6f99970..1c4076883 100644 --- a/pkgs/jnigen/test/simple_package_test/runtime_test_registrant.dart +++ b/pkgs/jnigen/test/simple_package_test/runtime_test_registrant.dart @@ -543,28 +543,31 @@ void registerTests(String groupName, TestRunnerCallback test) { // or `self` argument for each one of the callbacks. late final MyInterface myInterface; myInterface = MyInterface.implement( - voidCallback: (s) { - voidCallbackResult.complete(s); - }, - stringCallback: (s) { - return (s.toDartString(deleteOriginal: true) * 2).toJString(); - }, - varCallback: (JInteger t) { - final result = (t.intValue(deleteOriginal: true) * 2).toJInteger(); - varCallbackResult.complete(result); - return result; - }, - manyPrimitives: (a, b, c, d) { - if (b) { - final result = a + c + d.toInt(); - manyPrimitivesResult.complete(result); + $MyInterfaceImpl( + voidCallback: (s) { + voidCallbackResult.complete(s); + }, + stringCallback: (s) { + return (s.toDartString(deleteOriginal: true) * 2).toJString(); + }, + varCallback: (JInteger t) { + final result = + (t.intValue(deleteOriginal: true) * 2).toJInteger(); + varCallbackResult.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, + }, + 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 From 651320e472f4159deb1c1218812d83c7ce98f9ec Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Wed, 16 Aug 2023 15:11:20 +0200 Subject: [PATCH 112/139] [jnigen] Update Dart API headers (https://github.com/dart-lang/jnigen/issues/358) * Update Dart API * Remove unnecessary methods in dartjni.h --- pkgs/jni/example/pubspec.lock | 2 +- pkgs/jni/ffigen.yaml | 3 - pkgs/jni/src/dartjni.h | 20 -- pkgs/jni/src/include/dart_api.h | 181 ++++++++++---- pkgs/jni/src/include/dart_api_dl.h | 10 +- pkgs/jni/src/include/dart_native_api.h | 6 +- pkgs/jni/src/include/dart_tools_api.h | 232 ++++++++++-------- pkgs/jni/src/include/dart_version.h | 2 +- .../in_app_java/src/android_utils/dartjni.h | 20 -- .../example/kotlin_plugin/src/dartjni.h | 20 -- .../example/notification_plugin/src/dartjni.h | 20 -- .../pdfbox_plugin/src/third_party/dartjni.h | 20 -- .../third_party/c_based/c_bindings/dartjni.h | 20 -- .../kotlin_test/c_based/c_bindings/dartjni.h | 20 -- .../c_based/c_bindings/dartjni.h | 20 -- 15 files changed, 283 insertions(+), 313 deletions(-) diff --git a/pkgs/jni/example/pubspec.lock b/pkgs/jni/example/pubspec.lock index c730dba99..1fd2db8b1 100644 --- a/pkgs/jni/example/pubspec.lock +++ b/pkgs/jni/example/pubspec.lock @@ -200,7 +200,7 @@ packages: path: ".." relative: true source: path - version: "0.6.0-dev.2" + version: "0.6.0-wip.2" js: dependency: transitive description: diff --git a/pkgs/jni/ffigen.yaml b/pkgs/jni/ffigen.yaml index 62b7429ab..782668e36 100644 --- a/pkgs/jni/ffigen.yaml +++ b/pkgs/jni/ffigen.yaml @@ -57,9 +57,6 @@ functions: - 'to_global_ref_result' - 'wait_for' # keep-sorted end - # Native functions in Java. No need to call them from Dart. - - 'Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith' - - 'Java_com_github_dart_1lang_jni_PortProxy__1invoke' structs: exclude: - 'JniContext' diff --git a/pkgs/jni/src/dartjni.h b/pkgs/jni/src/dartjni.h index 8a07d0918..cca31f49e 100644 --- a/pkgs/jni/src/dartjni.h +++ b/pkgs/jni/src/dartjni.h @@ -422,11 +422,6 @@ FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object); -JNIEXPORT void JNICALL -Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env, - jobject thiz, - jlong port, - jobject result); FFI_PLUGIN_EXPORT JniResult PortContinuation__ctor(int64_t j); @@ -434,18 +429,3 @@ FFI_PLUGIN_EXPORT JniResult PortProxy__newInstance(jobject binaryName, int64_t port, int64_t functionPtr); - -JNIEXPORT jobjectArray JNICALL -Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, - jobject thiz, - jlong port, - jlong threadId, - jlong functionPtr, - jobject proxy, - jstring methodDescriptor, - jobjectArray args); - -JNIEXPORT void JNICALL -Java_com_github_dart_1lang_jni_PortProxy__1cleanUp(JNIEnv* env, - jobject thiz, - jlong resultPtr); diff --git a/pkgs/jni/src/include/dart_api.h b/pkgs/jni/src/include/dart_api.h index 741447a06..99dde6f9d 100644 --- a/pkgs/jni/src/include/dart_api.h +++ b/pkgs/jni/src/include/dart_api.h @@ -25,6 +25,10 @@ #include #include +#if defined(__Fuchsia__) +#include +#endif + #ifdef __cplusplus #define DART_EXTERN_C extern "C" #else @@ -849,7 +853,7 @@ typedef Dart_Handle (*Dart_GetVMServiceAssetsArchive)(void); * The current version of the Dart_InitializeFlags. Should be incremented every * time Dart_InitializeFlags changes in a binary incompatible way. */ -#define DART_INITIALIZE_PARAMS_CURRENT_VERSION (0x00000007) +#define DART_INITIALIZE_PARAMS_CURRENT_VERSION (0x00000008) /** Forward declaration */ struct Dart_CodeObserver; @@ -992,6 +996,15 @@ typedef struct { * Kernel blob unregistration callback function. See Dart_UnregisterKernelBlobCallback. */ Dart_UnregisterKernelBlobCallback unregister_kernel_blob; + +#if defined(__Fuchsia__) + /** + * The resource needed to use zx_vmo_replace_as_executable. Can be + * ZX_HANDLE_INVALID if the process has ambient-replace-as-executable or if + * executable memory is not needed (e.g., this is an AOT runtime). + */ + zx_handle_t vmex_resource; +#endif } Dart_InitializeParams; /** @@ -1105,7 +1118,7 @@ Dart_CreateIsolateGroup(const char* script_uri, * shutdown (may be NULL). * \param cleanup_callback A callback to be called when the isolate is being * cleaned up (may be NULL). - * \param isolate_data The embedder-specific data associated with this isolate. + * \param child_isolate_data The embedder-specific data associated with this isolate. * \param error Set to NULL if creation is successful, set to an error * message otherwise. The caller is responsible for calling free() on the * error message. @@ -1210,7 +1223,7 @@ DART_EXPORT void* Dart_CurrentIsolateGroupData(void); * It is the responsibility of the caller to free the returned ID. */ typedef int64_t Dart_IsolateGroupId; -DART_EXPORT Dart_IsolateGroupId Dart_CurrentIsolateGroupId(); +DART_EXPORT Dart_IsolateGroupId Dart_CurrentIsolateGroupId(void); /** * Returns the callback data associated with the specified isolate group. This @@ -1228,6 +1241,17 @@ DART_EXPORT void* Dart_IsolateGroupData(Dart_Isolate isolate); */ DART_EXPORT Dart_Handle Dart_DebugName(void); +/** + * Returns the debugging name for the current isolate. + * + * This name is unique to each isolate and should only be used to make + * debugging messages more comprehensible. + * + * The returned string is scope allocated and is only valid until the next call + * to Dart_ExitScope. + */ +DART_EXPORT const char* Dart_DebugNameToCString(void); + /** * Returns the ID for an isolate which is used to query the service protocol. * @@ -1270,6 +1294,79 @@ DART_EXPORT void Dart_KillIsolate(Dart_Isolate isolate); */ DART_EXPORT void Dart_NotifyIdle(int64_t deadline); +typedef void (*Dart_HeapSamplingReportCallback)(void* context, + void* data); + +typedef void* (*Dart_HeapSamplingCreateCallback)( + Dart_Isolate isolate, + Dart_IsolateGroup isolate_group, + const char* cls_name, + intptr_t allocation_size); +typedef void (*Dart_HeapSamplingDeleteCallback)(void* data); + +/** + * Starts the heap sampling profiler for each thread in the VM. + */ +DART_EXPORT void Dart_EnableHeapSampling(void); + +/* + * Stops the heap sampling profiler for each thread in the VM. + */ +DART_EXPORT void Dart_DisableHeapSampling(void); + +/* Registers callbacks are invoked once per sampled allocation upon object + * allocation and garbage collection. + * + * |create_callback| can be used to associate additional data with the sampled + * allocation, such as a stack trace. This data pointer will be passed to + * |delete_callback| to allow for proper disposal when the object associated + * with the allocation sample is collected. + * + * The provided callbacks must not call into the VM and should do as little + * work as possible to avoid performance penalities during object allocation and + * garbage collection. + * + * NOTE: It is a fatal error to set either callback to null once they have been + * initialized. + */ +DART_EXPORT void Dart_RegisterHeapSamplingCallback( + Dart_HeapSamplingCreateCallback create_callback, + Dart_HeapSamplingDeleteCallback delete_callback); + +/* + * Reports the surviving allocation samples for all live isolate groups in the + * VM. + * + * When the callback is invoked: + * - |context| will be the context object provided when invoking + * |Dart_ReportSurvivingAllocations|. This can be safely set to null if not + * required. + * - |heap_size| will be equal to the size of the allocated object associated + * with the sample. + * - |cls_name| will be a C String representing + * the class name of the allocated object. This string is valid for the + * duration of the call to Dart_ReportSurvivingAllocations and can be + * freed by the VM at any point after the method returns. + * - |data| will be set to the data associated with the sample by + * |Dart_HeapSamplingCreateCallback|. + * + * If |force_gc| is true, a full GC will be performed before reporting the + * allocations. + */ +DART_EXPORT void Dart_ReportSurvivingAllocations( + Dart_HeapSamplingReportCallback callback, + void* context, + bool force_gc); + +/* + * Sets the average heap sampling rate based on a number of |bytes| for each + * thread. + * + * In other words, approximately every |bytes| allocated will create a sample. + * Defaults to 512 KiB. + */ +DART_EXPORT void Dart_SetHeapSamplingPeriod(intptr_t bytes); + /** * Notifies the VM that the embedder expects the application's working set has * recently shrunk significantly and is not expected to rise in the near future. @@ -1328,7 +1425,7 @@ DART_EXPORT void Dart_StartProfiling(void); /** * Stops the CPU sampling profiler. * - * Note that some profile samples might still be taken after this fucntion + * Note that some profile samples might still be taken after this function * returns due to the asynchronous nature of the implementation on some * platforms. */ @@ -1663,8 +1760,8 @@ DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_RunLoop(void); * \param error A non-NULL pointer which will hold an error message if the call * fails. The error has to be free()ed by the caller. * - * \return If successful the VM takes owernship of the isolate and takes care - * of its message loop. If not successful the caller retains owernship of the + * \return If successful the VM takes ownership of the isolate and takes care + * of its message loop. If not successful the caller retains ownership of the * isolate. */ DART_EXPORT DART_WARN_UNUSED_RESULT bool Dart_RunLoopAsync( @@ -1924,7 +2021,7 @@ DART_EXPORT Dart_Handle Dart_FunctionName(Dart_Handle function); DART_EXPORT Dart_Handle Dart_FunctionOwner(Dart_Handle function); /** - * Determines whether a function handle referes to a static function + * Determines whether a function handle refers to a static function * of method. * * For the purposes of the embedding API, a top-level function is @@ -3456,7 +3553,7 @@ DART_EXPORT Dart_Handle Dart_SetRootLibrary(Dart_Handle library); * \param number_of_type_arguments Number of type arguments. * For non parametric types the number of type arguments would be 0. * \param type_arguments Pointer to an array of type arguments. - * For non parameteric types a NULL would be passed in for this argument. + * For non parametric types a NULL would be passed in for this argument. * * \return If no error occurs, the type is returned. * Otherwise an error handle is returned. @@ -3475,7 +3572,7 @@ DART_EXPORT Dart_Handle Dart_GetType(Dart_Handle library, * \param number_of_type_arguments Number of type arguments. * For non parametric types the number of type arguments would be 0. * \param type_arguments Pointer to an array of type arguments. - * For non parameteric types a NULL would be passed in for this argument. + * For non parametric types a NULL would be passed in for this argument. * * \return If no error occurs, the type is returned. * Otherwise an error handle is returned. @@ -3494,7 +3591,7 @@ DART_EXPORT Dart_Handle Dart_GetNullableType(Dart_Handle library, * \param number_of_type_arguments Number of type arguments. * For non parametric types the number of type arguments would be 0. * \param type_arguments Pointer to an array of type arguments. - * For non parameteric types a NULL would be passed in for this argument. + * For non parametric types a NULL would be passed in for this argument. * * \return If no error occurs, the type is returned. * Otherwise an error handle is returned. @@ -3598,6 +3695,8 @@ DART_EXPORT Dart_Handle Dart_LibraryHandleError(Dart_Handle library, DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_LoadLibraryFromKernel(const uint8_t* kernel_buffer, intptr_t kernel_buffer_size); +DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle +Dart_LoadLibrary(Dart_Handle kernel_buffer); /** * Indicates that all outstanding load requests have been satisfied. @@ -3730,43 +3829,6 @@ Dart_CompileToKernel(const char* script_uri, const char* package_config, Dart_KernelCompilationVerbosityLevel verbosity); -/** - * Compiles the given `script_uri` to a kernel file. - * - * \param platform_kernel A buffer containing the kernel of the platform (e.g. - * `vm_platform_strong.dill`). The VM does not take ownership of this memory. - * - * \param platform_kernel_size The length of the platform_kernel buffer. - * - * \param snapshot_compile Set to `true` when the compilation is for a snapshot. - * This is used by the frontend to determine if compilation related information - * should be printed to console (e.g., null safety mode). - * - * \param null_safety Provides null-safety mode setting for the compiler. - * - * \param verbosity Specifies the logging behavior of the kernel compilation - * service. - * - * \return Returns the result of the compilation. - * - * On a successful compilation the returned [Dart_KernelCompilationResult] has - * a status of [Dart_KernelCompilationStatus_Ok] and the `kernel`/`kernel_size` - * fields are set. The caller takes ownership of the malloc()ed buffer. - * - * On a failed compilation the `error` might be set describing the reason for - * the failed compilation. The caller takes ownership of the malloc()ed - * error. - */ -DART_EXPORT Dart_KernelCompilationResult -Dart_CompileToKernelWithGivenNullsafety( - const char* script_uri, - const uint8_t* platform_kernel, - const intptr_t platform_kernel_size, - bool snapshot_compile, - const char* package_config, - const bool null_safety, - Dart_KernelCompilationVerbosityLevel verbosity); - typedef struct { const char* uri; const char* source; @@ -4095,4 +4157,29 @@ DART_EXPORT void Dart_DumpNativeStackTrace(void* context); */ DART_EXPORT void Dart_PrepareToAbort(void); +/** + * Callback provided by the embedder that is used by the VM to + * produce footnotes appended to DWARF stack traces. + * + * Whenever VM formats a stack trace as a string it would call this callback + * passing raw program counters for each frame in the stack trace. + * + * Embedder can then return a string which if not-null will be appended to the + * formatted stack trace. + * + * Returned string is expected to be `malloc()` allocated. VM takes ownership + * of the returned string and will `free()` it. + * + * \param addresses raw program counter addresses for each frame + * \param count number of elements in the addresses array + */ +typedef char* (*Dart_DwarfStackTraceFootnoteCallback)(void* addresses[], + intptr_t count); + +/** + * Configure DWARF stack trace footnote callback. + */ +DART_EXPORT void Dart_SetDwarfStackTraceFootnoteCallback( + Dart_DwarfStackTraceFootnoteCallback callback); + #endif /* INCLUDE_DART_API_H_ */ /* NOLINT */ diff --git a/pkgs/jni/src/include/dart_api_dl.h b/pkgs/jni/src/include/dart_api_dl.h index 804b2811c..cce345009 100644 --- a/pkgs/jni/src/include/dart_api_dl.h +++ b/pkgs/jni/src/include/dart_api_dl.h @@ -29,7 +29,7 @@ DART_EXPORT intptr_t Dart_InitializeApiDL(void* data); // DART_API_DL_MAJOR_VERSION and DART_API_DL_MINOR_VERSION. // // Verbatim copy of `dart_native_api.h` and `dart_api.h` symbol names and types -// to trigger compile-time errors if the sybols in those files are updated +// to trigger compile-time errors if the symbols in those files are updated // without updating these. // // Function return and argument types, and typedefs are carbon copied. Structs @@ -90,6 +90,10 @@ typedef void (*Dart_NativeMessageHandler_DL)(Dart_Port_DL dest_port_id, F(Dart_UpdateFinalizableExternalSize, void, \ (Dart_FinalizableHandle object, Dart_Handle strong_ref_to_object, \ intptr_t external_allocation_size)) \ + /* Isolates */ \ + F(Dart_CurrentIsolate, Dart_Isolate, (void)) \ + F(Dart_ExitIsolate, void, (void)) \ + F(Dart_EnterIsolate, void, (Dart_Isolate)) \ /* Dart_Port */ \ F(Dart_Post, bool, (Dart_Port_DL port_id, Dart_Handle object)) \ F(Dart_NewSendPort, Dart_Handle, (Dart_Port_DL port_id)) \ @@ -97,7 +101,9 @@ typedef void (*Dart_NativeMessageHandler_DL)(Dart_Port_DL dest_port_id, (Dart_Handle port, Dart_Port_DL * port_id)) \ /* Scopes */ \ F(Dart_EnterScope, void, (void)) \ - F(Dart_ExitScope, void, (void)) + F(Dart_ExitScope, void, (void)) \ + /* Objects */ \ + F(Dart_IsNull, bool, (Dart_Handle)) #define DART_API_ALL_DL_SYMBOLS(F) \ DART_NATIVE_API_DL_SYMBOLS(F) \ diff --git a/pkgs/jni/src/include/dart_native_api.h b/pkgs/jni/src/include/dart_native_api.h index 318a4b735..79194e03b 100644 --- a/pkgs/jni/src/include/dart_native_api.h +++ b/pkgs/jni/src/include/dart_native_api.h @@ -50,13 +50,15 @@ typedef enum { Dart_CObject_kArray, Dart_CObject_kTypedData, Dart_CObject_kExternalTypedData, - Dart_CObject_kUnmodifiableExternalTypedData, Dart_CObject_kSendPort, Dart_CObject_kCapability, Dart_CObject_kNativePointer, Dart_CObject_kUnsupported, + Dart_CObject_kUnmodifiableExternalTypedData, Dart_CObject_kNumberOfTypes } Dart_CObject_Type; +// This enum is versioned by DART_API_DL_MAJOR_VERSION, only add at the end +// and bump the DART_API_DL_MINOR_VERSION. typedef struct _Dart_CObject { Dart_CObject_Type type; @@ -65,7 +67,7 @@ typedef struct _Dart_CObject { int32_t as_int32; int64_t as_int64; double as_double; - char* as_string; + const char* as_string; struct { Dart_Port id; Dart_Port origin_id; diff --git a/pkgs/jni/src/include/dart_tools_api.h b/pkgs/jni/src/include/dart_tools_api.h index 90687f601..7b706bc97 100644 --- a/pkgs/jni/src/include/dart_tools_api.h +++ b/pkgs/jni/src/include/dart_tools_api.h @@ -143,7 +143,7 @@ typedef struct { * \return Returns a pointer to a Dart_EmbedderInformation structure. * The embedder keeps the ownership of the structure and any field in it. * The embedder must ensure that the structure will remain valid until the - * next invokation of the callback. + * next invocation of the callback. */ typedef void (*Dart_EmbedderInformationCallback)( Dart_EmbedderInformation* info); @@ -254,70 +254,6 @@ DART_EXPORT char* Dart_ServiceSendDataEvent(const char* stream_id, const uint8_t* bytes, intptr_t bytes_length); -/** - * Usage statistics for a space/generation at a particular moment in time. - * - * \param used Amount of memory used, in bytes. - * - * \param capacity Memory capacity, in bytes. - * - * \param external External memory, in bytes. - * - * \param collections How many times the garbage collector has run in this - * space. - * - * \param time Cumulative time spent collecting garbage in this space, in - * seconds. - * - * \param avg_collection_period Average time between garbage collector running - * in this space, in milliseconds. - */ -typedef struct { - intptr_t used; - intptr_t capacity; - intptr_t external; - intptr_t collections; - double time; - double avg_collection_period; -} Dart_GCStats; - -/** - * A Garbage Collection event with memory usage statistics. - * - * \param type The event type. Static lifetime. - * - * \param reason The reason for the GC event. Static lifetime. - * - * \param new_space Data for New Space. - * - * \param old_space Data for Old Space. - */ -typedef struct { - const char* type; - const char* reason; - - Dart_IsolateGroupId isolate_group_id; - - Dart_GCStats new_space; - Dart_GCStats old_space; -} Dart_GCEvent; - -/** - * A callback invoked when the VM emits a GC event. - * - * \param event The GC event data. Pointer only valid for the duration of the - * callback. - */ -typedef void (*Dart_GCEventCallback)(Dart_GCEvent* event); - -/** - * Sets the native GC event callback. - * - * \param callback A function pointer to an event handler callback function. - * A NULL value removes the existing listen callback function if any. - */ -DART_EXPORT void Dart_SetGCEventCallback(Dart_GCEventCallback callback); - /* * ======== * Reload support @@ -364,12 +300,12 @@ DART_EXPORT bool Dart_IsReloading(); * "Embedder" - Execution of Dart embedder code * "GC" - Execution of Dart Garbage Collector * "Isolate" - Dart Isolate lifecycle execution - * "VM" - Excution in Dart VM runtime code + * "VM" - Execution in Dart VM runtime code * "" - None * * When "all" is specified all the categories are enabled. * When a comma separated list of categories is specified, the categories - * that are specified will be enabled and the rest will be disabled. + * that are specified will be enabled and the rest will be disabled. * When "" is specified all the categories are disabled. * The category names are case sensitive. * eg: Dart_EnableTimelineCategory("all"); @@ -420,11 +356,26 @@ typedef enum { /** * Add a timeline event to the embedder stream. * + * DEPRECATED: this function will be removed in Dart SDK v3.2. + * * \param label The name of the event. Its lifetime must extend at least until * Dart_Cleanup. * \param timestamp0 The first timestamp of the event. - * \param timestamp1_or_async_id The second timestamp of the event or - * the async id. + * \param timestamp1_or_id When reporting an event of type + * |Dart_Timeline_Event_Duration|, the second (end) timestamp of the event + * should be passed through |timestamp1_or_id|. When reporting an event of + * type |Dart_Timeline_Event_Async_Begin|, |Dart_Timeline_Event_Async_End|, + * or |Dart_Timeline_Event_Async_Instant|, the async ID associated with the + * event should be passed through |timestamp1_or_id|. When reporting an + * event of type |Dart_Timeline_Event_Flow_Begin|, + * |Dart_Timeline_Event_Flow_Step|, or |Dart_Timeline_Event_Flow_End|, the + * flow ID associated with the event should be passed through + * |timestamp1_or_id|. When reporting an event of type + * |Dart_Timeline_Event_Begin| or |Dart_Timeline_Event_End|, the event ID + * associated with the event should be passed through |timestamp1_or_id|. + * Note that this event ID will only be used by the MacOS recorder. The + * argument to |timestamp1_or_id| will not be used when reporting events of + * other types. * \param argument_count The number of argument names and values. * \param argument_names An array of names of the arguments. The lifetime of the * names must extend at least until Dart_Cleanup. The array may be reclaimed @@ -434,12 +385,64 @@ typedef enum { */ DART_EXPORT void Dart_TimelineEvent(const char* label, int64_t timestamp0, - int64_t timestamp1_or_async_id, + int64_t timestamp1_or_id, Dart_Timeline_Event_Type type, intptr_t argument_count, const char** argument_names, const char** argument_values); +/** + * Add a timeline event to the embedder stream. + * + * Note regarding flow events: events must be associated with flow IDs in two + * different ways to allow flow events to be serialized correctly in both + * Chrome's JSON trace event format and Perfetto's proto trace format. Events + * of type |Dart_Timeline_Event_Flow_Begin|, |Dart_Timeline_Event_Flow_Step|, + * and |Dart_Timeline_Event_Flow_End| must be reported to support serialization + * in Chrome's trace format. The |flow_ids| argument must be supplied when + * reporting events of type |Dart_Timeline_Event_Begin|, + * |Dart_Timeline_Event_Duration|, |Dart_Timeline_Event_Instant|, + * |Dart_Timeline_Event_Async_Begin|, and |Dart_Timeline_Event_Async_Instant| to + * support serialization in Perfetto's proto format. + * + * \param label The name of the event. Its lifetime must extend at least until + * Dart_Cleanup. + * \param timestamp0 The first timestamp of the event. + * \param timestamp1_or_id When reporting an event of type + * |Dart_Timeline_Event_Duration|, the second (end) timestamp of the event + * should be passed through |timestamp1_or_id|. When reporting an event of + * type |Dart_Timeline_Event_Async_Begin|, |Dart_Timeline_Event_Async_End|, + * or |Dart_Timeline_Event_Async_Instant|, the async ID associated with the + * event should be passed through |timestamp1_or_id|. When reporting an + * event of type |Dart_Timeline_Event_Flow_Begin|, + * |Dart_Timeline_Event_Flow_Step|, or |Dart_Timeline_Event_Flow_End|, the + * flow ID associated with the event should be passed through + * |timestamp1_or_id|. When reporting an event of type + * |Dart_Timeline_Event_Begin| or |Dart_Timeline_Event_End|, the event ID + * associated with the event should be passed through |timestamp1_or_id|. + * Note that this event ID will only be used by the MacOS recorder. The + * argument to |timestamp1_or_id| will not be used when reporting events of + * other types. + * \param flow_id_count The number of flow IDs associated with this event. + * \param flow_ids An array of flow IDs associated with this event. The array + * may be reclaimed when this call returns. + * \param argument_count The number of argument names and values. + * \param argument_names An array of names of the arguments. The lifetime of the + * names must extend at least until Dart_Cleanup. The array may be reclaimed + * when this call returns. + * \param argument_values An array of values of the arguments. The values and + * the array may be reclaimed when this call returns. + */ +DART_EXPORT void Dart_RecordTimelineEvent(const char* label, + int64_t timestamp0, + int64_t timestamp1_or_id, + intptr_t flow_id_count, + const int64_t* flow_ids, + Dart_Timeline_Event_Type type, + intptr_t argument_count, + const char** argument_names, + const char** argument_values); + /** * Associates a name with the current thread. This name will be used to name * threads in the timeline. Can only be called after a call to Dart_Initialize. @@ -453,7 +456,7 @@ typedef struct { const char* value; } Dart_TimelineRecorderEvent_Argument; -#define DART_TIMELINE_RECORDER_CURRENT_VERSION (0x00000001) +#define DART_TIMELINE_RECORDER_CURRENT_VERSION (0x00000002) typedef struct { /* Set to DART_TIMELINE_RECORDER_CURRENT_VERSION */ @@ -467,9 +470,12 @@ typedef struct { */ int64_t timestamp0; - /* For a duration event, this is the end time. For an async event, this is the - * async id. */ - int64_t timestamp1_or_async_id; + /** + * For a duration event, this is the end time. For an async event, this is the + * async ID. For a flow event, this is the flow ID. For a begin or end event, + * this is the event ID (which is only referenced by the MacOS recorder). + */ + int64_t timestamp1_or_id; /* The current isolate of the event, as if by Dart_GetMainPortId, or * ILLEGAL_PORT if the event had no current isolate. */ @@ -480,6 +486,12 @@ typedef struct { * isolate group. */ Dart_IsolateGroupId isolate_group; + /* The callback data associated with the isolate if any. */ + void* isolate_data; + + /* The callback data associated with the isolate group if any. */ + void* isolate_group_data; + /* The name / label of the event. */ const char* label; @@ -518,7 +530,7 @@ typedef void (*Dart_TimelineRecorderCallback)( * will be remembered. Providing a NULL callback will clear the registration * (i.e., a NULL callback produced a no-op instead of a crash). * - * Setting a callback is insuffient to receive events through the callback. The + * Setting a callback is insufficient to receive events through the callback. The * VM flag `timeline_recorder` must also be set to `callback`. */ DART_EXPORT void Dart_SetTimelineRecorderCallback( @@ -532,41 +544,19 @@ DART_EXPORT void Dart_SetTimelineRecorderCallback( /** * Return metrics gathered for the VM and individual isolates. - * - * NOTE: Non-heap metrics are not available in PRODUCT builds of Dart. - * Calling the non-heap metric functions on a PRODUCT build might return invalid metrics. */ -DART_EXPORT int64_t Dart_VMIsolateCountMetric(); // Counter -DART_EXPORT int64_t Dart_VMCurrentRSSMetric(); // Byte -DART_EXPORT int64_t Dart_VMPeakRSSMetric(); // Byte DART_EXPORT int64_t Dart_IsolateGroupHeapOldUsedMetric(Dart_IsolateGroup group); // Byte DART_EXPORT int64_t -Dart_IsolateGroupHeapOldUsedMaxMetric(Dart_IsolateGroup group); // Byte -DART_EXPORT int64_t Dart_IsolateGroupHeapOldCapacityMetric(Dart_IsolateGroup group); // Byte DART_EXPORT int64_t -Dart_IsolateGroupHeapOldCapacityMaxMetric(Dart_IsolateGroup group); // Byte -DART_EXPORT int64_t Dart_IsolateGroupHeapOldExternalMetric(Dart_IsolateGroup group); // Byte DART_EXPORT int64_t Dart_IsolateGroupHeapNewUsedMetric(Dart_IsolateGroup group); // Byte DART_EXPORT int64_t -Dart_IsolateGroupHeapNewUsedMaxMetric(Dart_IsolateGroup group); // Byte -DART_EXPORT int64_t Dart_IsolateGroupHeapNewCapacityMetric(Dart_IsolateGroup group); // Byte DART_EXPORT int64_t -Dart_IsolateGroupHeapNewCapacityMaxMetric(Dart_IsolateGroup group); // Byte -DART_EXPORT int64_t Dart_IsolateGroupHeapNewExternalMetric(Dart_IsolateGroup group); // Byte -DART_EXPORT int64_t -Dart_IsolateGroupHeapGlobalUsedMetric(Dart_IsolateGroup group); // Byte -DART_EXPORT int64_t -Dart_IsolateGroupHeapGlobalUsedMaxMetric(Dart_IsolateGroup group); // Byte -DART_EXPORT int64_t -Dart_IsolateRunnableLatencyMetric(Dart_Isolate isolate); // Microsecond -DART_EXPORT int64_t -Dart_IsolateRunnableHeapSizeMetric(Dart_Isolate isolate); // Byte /* * ======== @@ -617,4 +607,52 @@ DART_EXPORT Dart_Handle Dart_SetCurrentUserTag(Dart_Handle user_tag); DART_EXPORT DART_WARN_UNUSED_RESULT char* Dart_GetUserTagLabel( Dart_Handle user_tag); +/* + * ======= + * Heap Snapshot + * ======= + */ + +/** + * Callback provided by the caller of `Dart_WriteHeapSnapshot` which is + * used to write out chunks of the requested heap snapshot. + * + * \param context An opaque context which was passed to `Dart_WriteHeapSnapshot` + * together with this callback. + * + * \param buffer Pointer to the buffer containing a chunk of the snapshot. + * The callback owns the buffer and needs to `free` it. + * + * \param size Number of bytes in the `buffer` to be written. + * + * \param is_last Set to `true` for the last chunk. The callback will not + * be invoked again after it was invoked once with `is_last` set to `true`. + */ +typedef void (*Dart_HeapSnapshotWriteChunkCallback)(void* context, + uint8_t* buffer, + intptr_t size, + bool is_last); + +/** + * Generate heap snapshot of the current isolate group and stream it into the + * given `callback`. VM would produce snapshot in chunks and send these chunks + * one by one back to the embedder by invoking the provided `callback`. + * + * This API enables embedder to stream snapshot into a file or socket without + * allocating a buffer to hold the whole snapshot in memory. + * + * The isolate group will be paused for the duration of this operation. + * + * \param write Callback used to write chunks of the heap snapshot. + * + * \param context Opaque context which would be passed on each invocation of + * `write` callback. + * + * \returns `nullptr` if the operation is successful otherwise error message. + * Caller owns error message string and needs to `free` it. + */ +DART_EXPORT char* Dart_WriteHeapSnapshot( + Dart_HeapSnapshotWriteChunkCallback write, + void* context); + #endif // RUNTIME_INCLUDE_DART_TOOLS_API_H_ diff --git a/pkgs/jni/src/include/dart_version.h b/pkgs/jni/src/include/dart_version.h index b3b492439..e2d3651fb 100644 --- a/pkgs/jni/src/include/dart_version.h +++ b/pkgs/jni/src/include/dart_version.h @@ -11,6 +11,6 @@ // On backwards compatible changes the minor version is increased. // The versioning covers the symbols exposed in dart_api_dl.h #define DART_API_DL_MAJOR_VERSION 2 -#define DART_API_DL_MINOR_VERSION 0 +#define DART_API_DL_MINOR_VERSION 3 #endif /* RUNTIME_INCLUDE_DART_VERSION_H_ */ /* NOLINT */ diff --git a/pkgs/jnigen/example/in_app_java/src/android_utils/dartjni.h b/pkgs/jnigen/example/in_app_java/src/android_utils/dartjni.h index 8a07d0918..cca31f49e 100644 --- a/pkgs/jnigen/example/in_app_java/src/android_utils/dartjni.h +++ b/pkgs/jnigen/example/in_app_java/src/android_utils/dartjni.h @@ -422,11 +422,6 @@ FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object); -JNIEXPORT void JNICALL -Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env, - jobject thiz, - jlong port, - jobject result); FFI_PLUGIN_EXPORT JniResult PortContinuation__ctor(int64_t j); @@ -434,18 +429,3 @@ FFI_PLUGIN_EXPORT JniResult PortProxy__newInstance(jobject binaryName, int64_t port, int64_t functionPtr); - -JNIEXPORT jobjectArray JNICALL -Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, - jobject thiz, - jlong port, - jlong threadId, - jlong functionPtr, - jobject proxy, - jstring methodDescriptor, - jobjectArray args); - -JNIEXPORT void JNICALL -Java_com_github_dart_1lang_jni_PortProxy__1cleanUp(JNIEnv* env, - jobject thiz, - jlong resultPtr); diff --git a/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h b/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h index 8a07d0918..cca31f49e 100644 --- a/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h +++ b/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h @@ -422,11 +422,6 @@ FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object); -JNIEXPORT void JNICALL -Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env, - jobject thiz, - jlong port, - jobject result); FFI_PLUGIN_EXPORT JniResult PortContinuation__ctor(int64_t j); @@ -434,18 +429,3 @@ FFI_PLUGIN_EXPORT JniResult PortProxy__newInstance(jobject binaryName, int64_t port, int64_t functionPtr); - -JNIEXPORT jobjectArray JNICALL -Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, - jobject thiz, - jlong port, - jlong threadId, - jlong functionPtr, - jobject proxy, - jstring methodDescriptor, - jobjectArray args); - -JNIEXPORT void JNICALL -Java_com_github_dart_1lang_jni_PortProxy__1cleanUp(JNIEnv* env, - jobject thiz, - jlong resultPtr); diff --git a/pkgs/jnigen/example/notification_plugin/src/dartjni.h b/pkgs/jnigen/example/notification_plugin/src/dartjni.h index 8a07d0918..cca31f49e 100644 --- a/pkgs/jnigen/example/notification_plugin/src/dartjni.h +++ b/pkgs/jnigen/example/notification_plugin/src/dartjni.h @@ -422,11 +422,6 @@ FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object); -JNIEXPORT void JNICALL -Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env, - jobject thiz, - jlong port, - jobject result); FFI_PLUGIN_EXPORT JniResult PortContinuation__ctor(int64_t j); @@ -434,18 +429,3 @@ FFI_PLUGIN_EXPORT JniResult PortProxy__newInstance(jobject binaryName, int64_t port, int64_t functionPtr); - -JNIEXPORT jobjectArray JNICALL -Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, - jobject thiz, - jlong port, - jlong threadId, - jlong functionPtr, - jobject proxy, - jstring methodDescriptor, - jobjectArray args); - -JNIEXPORT void JNICALL -Java_com_github_dart_1lang_jni_PortProxy__1cleanUp(JNIEnv* env, - jobject thiz, - jlong resultPtr); diff --git a/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h b/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h index 8a07d0918..cca31f49e 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h +++ b/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h @@ -422,11 +422,6 @@ FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object); -JNIEXPORT void JNICALL -Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env, - jobject thiz, - jlong port, - jobject result); FFI_PLUGIN_EXPORT JniResult PortContinuation__ctor(int64_t j); @@ -434,18 +429,3 @@ FFI_PLUGIN_EXPORT JniResult PortProxy__newInstance(jobject binaryName, int64_t port, int64_t functionPtr); - -JNIEXPORT jobjectArray JNICALL -Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, - jobject thiz, - jlong port, - jlong threadId, - jlong functionPtr, - jobject proxy, - jstring methodDescriptor, - jobjectArray args); - -JNIEXPORT void JNICALL -Java_com_github_dart_1lang_jni_PortProxy__1cleanUp(JNIEnv* env, - jobject thiz, - jlong resultPtr); diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/dartjni.h b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/dartjni.h index 8a07d0918..cca31f49e 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/dartjni.h +++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/dartjni.h @@ -422,11 +422,6 @@ FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object); -JNIEXPORT void JNICALL -Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env, - jobject thiz, - jlong port, - jobject result); FFI_PLUGIN_EXPORT JniResult PortContinuation__ctor(int64_t j); @@ -434,18 +429,3 @@ FFI_PLUGIN_EXPORT JniResult PortProxy__newInstance(jobject binaryName, int64_t port, int64_t functionPtr); - -JNIEXPORT jobjectArray JNICALL -Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, - jobject thiz, - jlong port, - jlong threadId, - jlong functionPtr, - jobject proxy, - jstring methodDescriptor, - jobjectArray args); - -JNIEXPORT void JNICALL -Java_com_github_dart_1lang_jni_PortProxy__1cleanUp(JNIEnv* env, - jobject thiz, - jlong resultPtr); diff --git a/pkgs/jnigen/test/kotlin_test/c_based/c_bindings/dartjni.h b/pkgs/jnigen/test/kotlin_test/c_based/c_bindings/dartjni.h index 8a07d0918..cca31f49e 100644 --- a/pkgs/jnigen/test/kotlin_test/c_based/c_bindings/dartjni.h +++ b/pkgs/jnigen/test/kotlin_test/c_based/c_bindings/dartjni.h @@ -422,11 +422,6 @@ FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object); -JNIEXPORT void JNICALL -Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env, - jobject thiz, - jlong port, - jobject result); FFI_PLUGIN_EXPORT JniResult PortContinuation__ctor(int64_t j); @@ -434,18 +429,3 @@ FFI_PLUGIN_EXPORT JniResult PortProxy__newInstance(jobject binaryName, int64_t port, int64_t functionPtr); - -JNIEXPORT jobjectArray JNICALL -Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, - jobject thiz, - jlong port, - jlong threadId, - jlong functionPtr, - jobject proxy, - jstring methodDescriptor, - jobjectArray args); - -JNIEXPORT void JNICALL -Java_com_github_dart_1lang_jni_PortProxy__1cleanUp(JNIEnv* env, - jobject thiz, - jlong resultPtr); diff --git a/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/dartjni.h b/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/dartjni.h index 8a07d0918..cca31f49e 100644 --- a/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/dartjni.h +++ b/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/dartjni.h @@ -422,11 +422,6 @@ FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object); -JNIEXPORT void JNICALL -Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env, - jobject thiz, - jlong port, - jobject result); FFI_PLUGIN_EXPORT JniResult PortContinuation__ctor(int64_t j); @@ -434,18 +429,3 @@ FFI_PLUGIN_EXPORT JniResult PortProxy__newInstance(jobject binaryName, int64_t port, int64_t functionPtr); - -JNIEXPORT jobjectArray JNICALL -Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, - jobject thiz, - jlong port, - jlong threadId, - jlong functionPtr, - jobject proxy, - jstring methodDescriptor, - jobjectArray args); - -JNIEXPORT void JNICALL -Java_com_github_dart_1lang_jni_PortProxy__1cleanUp(JNIEnv* env, - jobject thiz, - jlong resultPtr); From 7c9cca95f96da5682ed696b1757825d96b30bfe8 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Thu, 17 Aug 2023 12:12:15 +0200 Subject: [PATCH 113/139] [jnigen] Use isolate_id instead of thread_id (https://github.com/dart-lang/jnigen/issues/360) --- pkgs/jni/example/pubspec.lock | 114 ++--- pkgs/jni/example/pubspec.yaml | 2 +- .../com/github/dart_lang/jni/PortProxy.java | 14 +- pkgs/jni/lib/src/jni.dart | 4 +- pkgs/jni/lib/src/jobject.dart | 2 +- pkgs/jni/lib/src/jvalues.dart | 4 +- .../third_party/jni_bindings_generated.dart | 110 ++--- pkgs/jni/pubspec.yaml | 6 +- pkgs/jni/src/dartjni.c | 6 +- pkgs/jni/src/dartjni.h | 10 - pkgs/jnigen/android_test_runner/pubspec.yaml | 2 +- .../in_app_java/lib/android_utils.dart | 164 +++---- pkgs/jnigen/example/in_app_java/pubspec.yaml | 2 +- .../in_app_java/src/android_utils/dartjni.h | 10 - .../kotlin_plugin/example/pubspec.yaml | 2 +- .../jnigen/example/kotlin_plugin/pubspec.yaml | 2 +- .../example/kotlin_plugin/src/dartjni.h | 10 - .../notification_plugin/example/pubspec.yaml | 2 +- .../example/notification_plugin/pubspec.yaml | 2 +- .../example/notification_plugin/src/dartjni.h | 10 - .../pdfbox_plugin/dart_example/pubspec.yaml | 2 +- .../pdfbox_plugin/example/pubspec.yaml | 2 +- .../org/apache/pdfbox/pdmodel/PDDocument.dart | 118 ++--- .../pdfbox/pdmodel/PDDocumentInformation.dart | 64 +-- .../apache/pdfbox/text/PDFTextStripper.dart | 180 ++++---- .../jnigen/example/pdfbox_plugin/pubspec.yaml | 2 +- .../pdfbox_plugin/src/third_party/dartjni.h | 10 - pkgs/jnigen/pubspec.yaml | 2 +- .../third_party/c_based/c_bindings/dartjni.h | 10 - .../fasterxml/jackson/core/JsonFactory.dart | 146 +++--- .../fasterxml/jackson/core/JsonParser.dart | 422 +++++++++--------- .../com/fasterxml/jackson/core/JsonToken.dart | 59 +-- .../kotlin_test/c_based/c_bindings/dartjni.h | 10 - .../c_based/c_bindings/dartjni.h | 10 - .../c_based/dart_bindings/simple_package.dart | 196 ++++---- 35 files changed, 827 insertions(+), 884 deletions(-) diff --git a/pkgs/jni/example/pubspec.lock b/pkgs/jni/example/pubspec.lock index 1fd2db8b1..0824b6e6d 100644 --- a/pkgs/jni/example/pubspec.lock +++ b/pkgs/jni/example/pubspec.lock @@ -5,26 +5,26 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - sha256: a36ec4843dc30ea6bf652bf25e3448db6c5e8bcf4aa55f063a5d1dad216d8214 + sha256: ae92f5d747aee634b87f89d9946000c2de774be1d6ac3e58268224348cd0101a url: "https://pub.dev" source: hosted - version: "58.0.0" + version: "61.0.0" analyzer: dependency: transitive description: name: analyzer - sha256: cc4242565347e98424ce9945c819c192ec0838cb9d1f6aa4a97cc96becbc5b27 + sha256: ea3d8652bda62982addfd92fdc2d0214e5f82e43325104990d4f4c4a2a313562 url: "https://pub.dev" source: hosted - version: "5.10.0" + version: "5.13.0" args: dependency: transitive description: name: args - sha256: "4cab82a83ffef80b262ddedf47a0a8e56ee6fbf7fe21e6e768b02792034dd440" + sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 url: "https://pub.dev" source: hosted - version: "2.4.0" + version: "2.4.2" async: dependency: transitive description: @@ -61,10 +61,10 @@ packages: dependency: transitive description: name: collection - sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" + sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 url: "https://pub.dev" source: hosted - version: "1.17.1" + version: "1.17.2" convert: dependency: transitive description: @@ -85,10 +85,10 @@ packages: dependency: transitive description: name: crypto - sha256: aa274aa7774f8964e4f4f38cc994db7b6158dd36e9187aaceaddc994b35c6c67 + sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab url: "https://pub.dev" source: hosted - version: "3.0.2" + version: "3.0.3" cupertino_icons: dependency: "direct main" description: @@ -109,10 +109,10 @@ packages: dependency: "direct main" description: name: ffi - sha256: a38574032c5f1dd06c4aee541789906c12ccaab8ba01446e800d9c5b79c4a978 + sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.1.0" file: dependency: transitive description: @@ -135,10 +135,10 @@ packages: dependency: "direct dev" description: name: flutter_lints - sha256: aeb0b80a8b3709709c9cc496cdc027c5b3216796bc0af0ce1007eaf24464fd4c + sha256: "2118df84ef0c3ca93f96123a616ae8540879991b8b57af2f81b76a7ada49b2a4" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.0.2" flutter_test: dependency: "direct dev" description: flutter @@ -161,10 +161,10 @@ packages: dependency: transitive description: name: glob - sha256: "4515b5b6ddb505ebdd242a5f2cc5d22d3d6a80013789debfbda7777f47ea308c" + sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" http_multi_server: dependency: transitive description: @@ -213,34 +213,34 @@ packages: dependency: transitive description: name: lints - sha256: "5e4a9cd06d447758280a8ac2405101e0e2094d2a1dbdd3756aec3fe7775ba593" + sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.1.1" logging: dependency: transitive description: name: logging - sha256: "04094f2eb032cbb06c6f6e8d3607edcfcb0455e2bb6cbc010cb01171dcb64e6d" + sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.2.0" matcher: dependency: transitive description: name: matcher - sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" + sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" url: "https://pub.dev" source: hosted - version: "0.12.15" + version: "0.12.16" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" url: "https://pub.dev" source: hosted - version: "0.2.0" + version: "0.5.0" meta: dependency: transitive description: @@ -293,10 +293,10 @@ packages: dependency: transitive description: name: plugin_platform_interface - sha256: "6a2128648c854906c53fa8e33986fc0247a1116122f9534dd20e3ab9e16a32bc" + sha256: "43798d895c929056255600343db8f049921cbec94d31ec87f1dc5c16c01935dd" url: "https://pub.dev" source: hosted - version: "2.1.4" + version: "2.1.5" pool: dependency: transitive description: @@ -317,42 +317,42 @@ packages: dependency: transitive description: name: pub_semver - sha256: "307de764d305289ff24ad257ad5c5793ce56d04947599ad68b3baa124105fc17" + sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" url: "https://pub.dev" source: hosted - version: "2.1.3" + version: "2.1.4" shelf: dependency: transitive description: name: shelf - sha256: c24a96135a2ccd62c64b69315a14adc5c3419df63b4d7c05832a346fdb73682c + sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4 url: "https://pub.dev" source: hosted - version: "1.4.0" + version: "1.4.1" shelf_packages_handler: dependency: transitive description: name: shelf_packages_handler - sha256: aef74dc9195746a384843102142ab65b6a4735bb3beea791e63527b88cc83306 + sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e" url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "3.0.2" shelf_static: dependency: transitive description: name: shelf_static - sha256: e792b76b96a36d4a41b819da593aff4bdd413576b3ba6150df5d8d9996d2e74c + sha256: a41d3f53c4adf0f57480578c1d61d90342cd617de7fc8077b1304643c2d85c1e url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.1.2" shelf_web_socket: dependency: transitive description: name: shelf_web_socket - sha256: a988c0e8d8ffbdb8a28aa7ec8e449c260f3deb808781fe1284d22c5bba7156e8 + sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1" url: "https://pub.dev" source: hosted - version: "1.0.3" + version: "1.0.4" sky_engine: dependency: transitive description: flutter @@ -378,10 +378,10 @@ packages: dependency: transitive description: name: source_span - sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.10.0" stack_trace: dependency: transitive description: @@ -426,34 +426,34 @@ packages: dependency: "direct dev" description: name: test - sha256: "3dac9aecf2c3991d09b9cdde4f98ded7b30804a88a0d7e4e7e1678e78d6b97f4" + sha256: "13b41f318e2a5751c3169137103b60c584297353d4b1761b66029bae6411fe46" url: "https://pub.dev" source: hosted - version: "1.24.1" + version: "1.24.3" test_api: dependency: transitive description: name: test_api - sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb + sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" url: "https://pub.dev" source: hosted - version: "0.5.1" + version: "0.6.0" test_core: dependency: transitive description: name: test_core - sha256: "5138dbffb77b2289ecb12b81c11ba46036590b72a64a7a90d6ffb880f1a29e93" + sha256: "99806e9e6d95c7b059b7a0fc08f07fc53fabe54a829497f0d9676299f1e8637e" url: "https://pub.dev" source: hosted - version: "0.5.1" + version: "0.5.3" typed_data: dependency: transitive description: name: typed_data - sha256: "26f87ade979c47a150c9eaab93ccd2bebe70a27dc0b4b29517f2904f04eb11a5" + sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c url: "https://pub.dev" source: hosted - version: "1.3.1" + version: "1.3.2" vector_math: dependency: transitive description: @@ -466,18 +466,26 @@ packages: dependency: transitive description: name: vm_service - sha256: f6deed8ed625c52864792459709183da231ebf66ff0cf09e69b573227c377efe + sha256: c620a6f783fa22436da68e42db7ebbf18b8c44b9a46ab911f666ff09ffd9153f url: "https://pub.dev" source: hosted - version: "11.3.0" + version: "11.7.1" watcher: dependency: transitive description: name: watcher - sha256: "6a7f46926b01ce81bfc339da6a7f20afbe7733eff9846f6d6a5466aa4c6667c0" + sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" url: "https://pub.dev" source: hosted - version: "1.0.2" + version: "1.1.0" + web: + dependency: transitive + description: + name: web + sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 + url: "https://pub.dev" + source: hosted + version: "0.1.4-beta" web_socket_channel: dependency: transitive description: @@ -506,10 +514,10 @@ packages: dependency: transitive description: name: yaml - sha256: "23812a9b125b48d4007117254bca50abb6c712352927eece9e155207b1db2370" + sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" url: "https://pub.dev" source: hosted - version: "3.1.1" + version: "3.1.2" sdks: - dart: ">=3.0.0-0 <4.0.0" + dart: ">=3.1.0 <4.0.0" flutter: ">=2.11.0" diff --git a/pkgs/jni/example/pubspec.yaml b/pkgs/jni/example/pubspec.yaml index 30408f94d..ce0646488 100644 --- a/pkgs/jni/example/pubspec.yaml +++ b/pkgs/jni/example/pubspec.yaml @@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: '>=2.17.5 <4.0.0' + sdk: '>=3.1.0 <4.0.0' # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions diff --git a/pkgs/jni/java/src/main/java/com/github/dart_lang/jni/PortProxy.java b/pkgs/jni/java/src/main/java/com/github/dart_lang/jni/PortProxy.java index bae1c3254..77cff1357 100644 --- a/pkgs/jni/java/src/main/java/com/github/dart_lang/jni/PortProxy.java +++ b/pkgs/jni/java/src/main/java/com/github/dart_lang/jni/PortProxy.java @@ -12,12 +12,12 @@ public class PortProxy implements InvocationHandler { } private final long port; - private final long threadId; + private final long isolateId; private final long functionPtr; - private PortProxy(long port, long threadId, long functionPtr) { + private PortProxy(long port, long isolateId, long functionPtr) { this.port = port; - this.threadId = threadId; + this.isolateId = isolateId; this.functionPtr = functionPtr; } @@ -60,16 +60,16 @@ private static void appendType(StringBuilder descriptor, Class type) { } } - public static Object newInstance(String binaryName, long port, long threadId, long functionPtr) + public static Object newInstance(String binaryName, long port, long isolateId, long functionPtr) throws ClassNotFoundException { Class clazz = Class.forName(binaryName); return Proxy.newProxyInstance( - clazz.getClassLoader(), new Class[] {clazz}, new PortProxy(port, threadId, functionPtr)); + clazz.getClassLoader(), new Class[] {clazz}, new PortProxy(port, isolateId, functionPtr)); } @Override public Object invoke(Object proxy, Method method, Object[] args) { - Object[] result = _invoke(port, threadId, functionPtr, proxy, getDescriptor(method), args); + Object[] result = _invoke(port, isolateId, functionPtr, proxy, getDescriptor(method), args); _cleanUp((Long) result[0]); return result[1]; } @@ -79,7 +79,7 @@ public Object invoke(Object proxy, Method method, Object[] args) { /// [1]: The result of the invocation. private native Object[] _invoke( long port, - long threadId, + long isolateId, long functionPtr, Object proxy, String methodDescriptor, diff --git a/pkgs/jni/lib/src/jni.dart b/pkgs/jni/lib/src/jni.dart index 8145642fb..d6836b028 100644 --- a/pkgs/jni/lib/src/jni.dart +++ b/pkgs/jni/lib/src/jni.dart @@ -64,8 +64,10 @@ abstract class Jni { _dylibDir = dylibDir; } + /// Initializes DartApiDL used for Continuations and interface implementation. static void initDLApi() { - // Initializing DartApiDL used for Continuations. + assert(NativeApi.majorVersion == 2); + assert(NativeApi.minorVersion >= 3); final result = _bindings.InitDartApiDL(NativeApi.initializeApiDLData); assert(result == 0); } diff --git a/pkgs/jni/lib/src/jobject.dart b/pkgs/jni/lib/src/jobject.dart index 26df6be1b..c5e88c137 100644 --- a/pkgs/jni/lib/src/jobject.dart +++ b/pkgs/jni/lib/src/jobject.dart @@ -128,7 +128,7 @@ T _callOrGet(int? callType, JniResult Function(int) function) { : (T == JObject ? JObject.fromRef : JString.fromRef); result = ctor(ref) as T; break; - case Pointer: // JObjectPtr + case const (Pointer): // JObjectPtr finalCallType = _getCallType( callType, JniCallType.objectType, {JniCallType.objectType}); result = function(finalCallType).object as T; diff --git a/pkgs/jni/lib/src/jvalues.dart b/pkgs/jni/lib/src/jvalues.dart index cc99b1134..84439bf42 100644 --- a/pkgs/jni/lib/src/jvalues.dart +++ b/pkgs/jni/lib/src/jvalues.dart @@ -22,8 +22,8 @@ void _fillJValue(Pointer pos, dynamic arg) { case bool: pos.ref.z = arg ? 1 : 0; break; - case Pointer: - case Pointer: // for nullptr + case const (Pointer): + case const (Pointer): // for nullptr pos.ref.l = arg; break; case double: 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 ef83bb57e..bdd6ab747 100644 --- a/pkgs/jni/lib/src/third_party/jni_bindings_generated.dart +++ b/pkgs/jni/lib/src/third_party/jni_bindings_generated.dart @@ -257,13 +257,13 @@ abstract class JniCallType { /// /// If [exception] is null, it means the result is valid. /// It's assumed that the caller knows the expected type in [result]. -class JniResult extends ffi.Struct { +final class JniResult extends ffi.Struct { external JValue value; external JThrowablePtr exception; } -class JValue extends ffi.Union { +final class JValue extends ffi.Union { @JBooleanMarker() external int z; @@ -306,7 +306,7 @@ typedef JObjectPtr = ffi.Pointer; typedef JThrowablePtr = JObjectPtr; /// Similar to [JniResult] but for class lookups. -class JniClassLookupResult extends ffi.Struct { +final class JniClassLookupResult extends ffi.Struct { external JClassPtr value; external JThrowablePtr exception; @@ -315,7 +315,7 @@ class JniClassLookupResult extends ffi.Struct { typedef JClassPtr = JObjectPtr; /// Similar to [JniResult] but for method/field ID lookups. -class JniPointerResult extends ffi.Struct { +final class JniPointerResult extends ffi.Struct { external ffi.Pointer value; external JThrowablePtr exception; @@ -323,7 +323,7 @@ class JniPointerResult extends ffi.Struct { /// JniExceptionDetails holds 2 jstring objects, one is the result of /// calling `toString` on exception object, other is stack trace; -class JniExceptionDetails extends ffi.Struct { +final class JniExceptionDetails extends ffi.Struct { external JStringPtr message; external JStringPtr stacktrace; @@ -337,7 +337,7 @@ typedef JStringPtr = JObjectPtr; /// Flutter embedding checks for pending JNI exceptions before an FFI transition, which requires us /// to check for and clear the exception before returning to dart code, which requires these functions /// to return result types. -class JniAccessorsStruct extends ffi.Struct { +final class JniAccessorsStruct extends ffi.Struct { external ffi.Pointer< ffi.NativeFunction< JniClassLookupResult Function( @@ -378,8 +378,8 @@ class JniAccessorsStruct extends ffi.Struct { newObject; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JSizeMarker length, ffi.Int type)>> + ffi + .NativeFunction> newPrimitiveArray; external ffi.Pointer< @@ -421,27 +421,27 @@ class JniAccessorsStruct extends ffi.Struct { typedef JMethodIDPtr = ffi.Pointer; -class jmethodID_ extends ffi.Opaque {} +final class jmethodID_ extends ffi.Opaque {} /// "cardinal indices and sizes" typedef JSizeMarker = JIntMarker; typedef JArrayPtr = JObjectPtr; typedef JFieldIDPtr = ffi.Pointer; -class jfieldID_ extends ffi.Opaque {} +final class jfieldID_ extends ffi.Opaque {} typedef JavaVM = ffi.Pointer; /// JNI invocation interface. -class JNIInvokeInterface extends ffi.Struct { +final class JNIInvokeInterface extends ffi.Struct { external ffi.Pointer reserved0; external ffi.Pointer reserved1; external ffi.Pointer reserved2; - external ffi.Pointer< - ffi.NativeFunction vm)>> + external ffi + .Pointer vm)>> DestroyJavaVM; external ffi.Pointer< @@ -451,8 +451,8 @@ class JNIInvokeInterface extends ffi.Struct { ffi.Pointer> p_env, ffi.Pointer thr_args)>> AttachCurrentThread; - external ffi.Pointer< - ffi.NativeFunction vm)>> + external ffi + .Pointer vm)>> DetachCurrentThread; external ffi.Pointer< @@ -474,7 +474,7 @@ typedef JavaVM1 = ffi.Pointer; typedef JniEnv = ffi.Pointer; /// Table of interface function pointers. -class JNINativeInterface extends ffi.Struct { +final class JNINativeInterface extends ffi.Struct { external ffi.Pointer reserved0; external ffi.Pointer reserved1; @@ -551,12 +551,12 @@ class JNINativeInterface extends ffi.Struct { ffi.NativeFunction env)>> ExceptionOccurred; - external ffi.Pointer< - ffi.NativeFunction env)>> + external ffi + .Pointer env)>> ExceptionDescribe; - external ffi.Pointer< - ffi.NativeFunction env)>> + external ffi + .Pointer env)>> ExceptionClear; external ffi.Pointer< @@ -1933,7 +1933,7 @@ typedef JLongArrayPtr = JArrayPtr; typedef JFloatArrayPtr = JArrayPtr; typedef JDoubleArrayPtr = JArrayPtr; -class JNINativeMethod extends ffi.Struct { +final class JNINativeMethod extends ffi.Struct { external ffi.Pointer name; external ffi.Pointer signature; @@ -1950,7 +1950,7 @@ abstract class JObjectRefType { static const int JNIWeakGlobalRefType = 3; } -class JavaVMInitArgs extends ffi.Struct { +final class JavaVMInitArgs extends ffi.Struct { /// use JNI_VERSION_1_2 or later @JIntMarker() external int version; @@ -1966,13 +1966,13 @@ class JavaVMInitArgs extends ffi.Struct { /// JNI 1.2+ initialization. (As of 1.6, the pre-1.2 structures are no /// longer supported.) -class JavaVMOption extends ffi.Struct { +final class JavaVMOption extends ffi.Struct { external ffi.Pointer optionString; external ffi.Pointer extraInfo; } -class CallbackResult extends ffi.Struct { +final class CallbackResult extends ffi.Struct { external MutexLock lock; external ConditionVariable cond; @@ -1987,7 +1987,7 @@ typedef MutexLock = pthread_mutex_t; typedef pthread_mutex_t = __darwin_pthread_mutex_t; typedef __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; -class _opaque_pthread_mutex_t extends ffi.Struct { +final class _opaque_pthread_mutex_t extends ffi.Struct { @ffi.Long() external int __sig; @@ -1999,7 +1999,7 @@ typedef ConditionVariable = pthread_cond_t; typedef pthread_cond_t = __darwin_pthread_cond_t; typedef __darwin_pthread_cond_t = _opaque_pthread_cond_t; -class _opaque_pthread_cond_t extends ffi.Struct { +final class _opaque_pthread_cond_t extends ffi.Struct { @ffi.Long() external int __sig; @@ -2007,7 +2007,7 @@ class _opaque_pthread_cond_t extends ffi.Struct { external ffi.Array __opaque; } -class GlobalJniEnvStruct extends ffi.Struct { +final class GlobalJniEnvStruct extends ffi.Struct { external ffi.Pointer reserved0; external ffi.Pointer reserved1; @@ -2030,12 +2030,12 @@ class GlobalJniEnvStruct extends ffi.Struct { ffi.NativeFunction< JniClassLookupResult Function(ffi.Pointer name)>> FindClass; - external ffi.Pointer< - ffi.NativeFunction> + external ffi + .Pointer> FromReflectedMethod; - external ffi.Pointer< - ffi.NativeFunction> + external ffi + .Pointer> FromReflectedField; external ffi.Pointer< @@ -2080,33 +2080,34 @@ class GlobalJniEnvStruct extends ffi.Struct { FatalError; external ffi - .Pointer> + .Pointer> PushLocalFrame; external ffi - .Pointer> + .Pointer> PopLocalFrame; external ffi.Pointer> NewGlobalRef; - external ffi.Pointer< - ffi.NativeFunction> + external ffi + .Pointer> DeleteGlobalRef; - external ffi.Pointer< - ffi.NativeFunction> + external ffi + .Pointer> DeleteLocalRef; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JObjectPtr ref1, JObjectPtr ref2)>> IsSameObject; + ffi + .NativeFunction> + IsSameObject; external ffi.Pointer> NewLocalRef; external ffi - .Pointer> + .Pointer> EnsureLocalCapacity; external ffi.Pointer> @@ -2132,8 +2133,9 @@ class GlobalJniEnvStruct extends ffi.Struct { GetObjectClass; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JObjectPtr obj, JClassPtr clazz)>> IsInstanceOf; + ffi + .NativeFunction> + IsInstanceOf; external ffi.Pointer< ffi.NativeFunction< @@ -2878,7 +2880,7 @@ class GlobalJniEnvStruct extends ffi.Struct { NewString; external ffi - .Pointer> + .Pointer> GetStringLength; external ffi.Pointer< @@ -2898,7 +2900,7 @@ class GlobalJniEnvStruct extends ffi.Struct { NewStringUTF; external ffi - .Pointer> + .Pointer> GetStringUTFLength; external ffi.Pointer< @@ -2933,35 +2935,35 @@ class GlobalJniEnvStruct extends ffi.Struct { SetObjectArrayElement; external ffi - .Pointer> + .Pointer> NewBooleanArray; external ffi - .Pointer> + .Pointer> NewByteArray; external ffi - .Pointer> + .Pointer> NewCharArray; external ffi - .Pointer> + .Pointer> NewShortArray; external ffi - .Pointer> + .Pointer> NewIntArray; external ffi - .Pointer> + .Pointer> NewLongArray; external ffi - .Pointer> + .Pointer> NewFloatArray; external ffi - .Pointer> + .Pointer> NewDoubleArray; external ffi.Pointer< @@ -3257,8 +3259,8 @@ class GlobalJniEnvStruct extends ffi.Struct { ffi.Pointer address, JLongMarker capacity)>> NewDirectByteBuffer; - external ffi.Pointer< - ffi.NativeFunction> + external ffi + .Pointer> GetDirectBufferAddress; external ffi.Pointer> diff --git a/pkgs/jni/pubspec.yaml b/pkgs/jni/pubspec.yaml index 834424973..d4a8da9ab 100644 --- a/pkgs/jni/pubspec.yaml +++ b/pkgs/jni/pubspec.yaml @@ -3,12 +3,12 @@ # BSD-style license that can be found in the LICENSE file. name: jni -description: Library to access JNI from dart and flutter +description: Library to access JNI from Dart and Flutter. version: 0.6.0-wip.2 repository: https://github.com/dart-lang/jnigen/tree/main/jni environment: - sdk: '>=2.17.1 <4.0.0' + sdk: '>=3.1.0 <4.0.0' flutter: '>=2.11.0' dependencies: @@ -21,7 +21,7 @@ dependencies: dev_dependencies: ## Pin ffigen version because we are depending on internal APIs. - ffigen: 7.2.10 + ffigen: 8.0.2 flutter_lints: ^2.0.0 test: ^1.21.1 logging: ^1.1.1 diff --git a/pkgs/jni/src/dartjni.c b/pkgs/jni/src/dartjni.c index df8feb78d..5c34c360e 100644 --- a/pkgs/jni/src/dartjni.c +++ b/pkgs/jni/src/dartjni.c @@ -623,7 +623,7 @@ JniResult PortProxy__newInstance(jobject binaryName, return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->CallStaticObjectMethod( jniEnv, _c_PortProxy, _m_PortProxy__newInstance, binaryName, port, - thread_id(), functionPtr); + (jlong)Dart_CurrentIsolate_DL(), functionPtr); return to_global_ref_result(_result); } @@ -645,13 +645,13 @@ JNIEXPORT jobjectArray JNICALL Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, jobject thiz, jlong port, - jlong threadId, + jlong isolateId, jlong functionPtr, jobject proxy, jstring methodDescriptor, jobjectArray args) { CallbackResult* result = (CallbackResult*)malloc(sizeof(CallbackResult)); - if (threadId != thread_id()) { + if (isolateId != (jlong)Dart_CurrentIsolate_DL()) { init_lock(&result->lock); init_cond(&result->cond); acquire_lock(&result->lock); diff --git a/pkgs/jni/src/dartjni.h b/pkgs/jni/src/dartjni.h index cca31f49e..0a7f66914 100644 --- a/pkgs/jni/src/dartjni.h +++ b/pkgs/jni/src/dartjni.h @@ -124,16 +124,6 @@ static inline void destroy_cond(ConditionVariable* cond) { #endif -static inline uint64_t thread_id() { -#ifdef _WIN32 - return GetCurrentThreadId(); -#elif defined __APPLE__ - return pthread_mach_thread_np(pthread_self()); -#else - return pthread_self(); -#endif -} - typedef struct CallbackResult { MutexLock lock; ConditionVariable cond; diff --git a/pkgs/jnigen/android_test_runner/pubspec.yaml b/pkgs/jnigen/android_test_runner/pubspec.yaml index a457e7727..fccc86e48 100644 --- a/pkgs/jnigen/android_test_runner/pubspec.yaml +++ b/pkgs/jnigen/android_test_runner/pubspec.yaml @@ -19,7 +19,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: '>=2.19.6 <3.0.0' + sdk: '>=3.1.0 <4.0.0' # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions diff --git a/pkgs/jnigen/example/in_app_java/lib/android_utils.dart b/pkgs/jnigen/example/in_app_java/lib/android_utils.dart index b14813fc6..c4a8f0456 100644 --- a/pkgs/jnigen/example/in_app_java/lib/android_utils.dart +++ b/pkgs/jnigen/example/in_app_java/lib/android_utils.dart @@ -323,9 +323,9 @@ class EmojiCompat extends jni.JObject { static const EMOJI_FALLBACK = 2; static final _init = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("EmojiCompat__init") + ffi + .NativeFunction)>>( + "EmojiCompat__init") .asFunction)>(); /// from: static public androidx.emoji2.text.EmojiCompat init(android.content.Context context) @@ -373,9 +373,9 @@ class EmojiCompat extends jni.JObject { } static final _init2 = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("EmojiCompat__init2") + ffi + .NativeFunction)>>( + "EmojiCompat__init2") .asFunction)>(); /// from: static public androidx.emoji2.text.EmojiCompat init(androidx.emoji2.text.EmojiCompat.Config config) @@ -414,9 +414,9 @@ class EmojiCompat extends jni.JObject { } static final _reset = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("EmojiCompat__reset") + ffi + .NativeFunction)>>( + "EmojiCompat__reset") .asFunction)>(); /// from: static public androidx.emoji2.text.EmojiCompat reset(androidx.emoji2.text.EmojiCompat.Config config) @@ -432,9 +432,9 @@ class EmojiCompat extends jni.JObject { } static final _reset1 = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("EmojiCompat__reset1") + ffi + .NativeFunction)>>( + "EmojiCompat__reset1") .asFunction)>(); /// from: static public androidx.emoji2.text.EmojiCompat reset(androidx.emoji2.text.EmojiCompat emojiCompat) @@ -480,9 +480,9 @@ class EmojiCompat extends jni.JObject { } static final _load = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("EmojiCompat__load") + ffi + .NativeFunction)>>( + "EmojiCompat__load") .asFunction)>(); /// from: public void load() @@ -549,9 +549,9 @@ class EmojiCompat extends jni.JObject { } static final _getLoadState = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("EmojiCompat__getLoadState") + ffi + .NativeFunction)>>( + "EmojiCompat__getLoadState") .asFunction)>(); /// from: public int getLoadState() @@ -565,8 +565,8 @@ class EmojiCompat extends jni.JObject { } static final _isEmojiSpanIndicatorEnabled = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "EmojiCompat__isEmojiSpanIndicatorEnabled") .asFunction)>(); @@ -579,8 +579,8 @@ class EmojiCompat extends jni.JObject { } static final _getEmojiSpanIndicatorColor = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "EmojiCompat__getEmojiSpanIndicatorColor") .asFunction)>(); @@ -977,9 +977,9 @@ class EmojiCompat extends jni.JObject { } static final _getAssetSignature = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("EmojiCompat__getAssetSignature") + ffi + .NativeFunction)>>( + "EmojiCompat__getAssetSignature") .asFunction)>(); /// from: public java.lang.String getAssetSignature() @@ -1066,9 +1066,9 @@ class EmojiCompat_Config extends jni.JObject { /// The type which includes information such as the signature of this class. static const type = $EmojiCompat_ConfigType(); static final _ctor = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("EmojiCompat_Config__ctor") + ffi + .NativeFunction)>>( + "EmojiCompat_Config__ctor") .asFunction)>(); /// from: protected void (androidx.emoji2.text.EmojiCompat.MetadataRepoLoader metadataLoader) @@ -1345,8 +1345,8 @@ class EmojiCompat_Config extends jni.JObject { } static final _getMetadataRepoLoader = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "EmojiCompat_Config__getMetadataRepoLoader") .asFunction)>(); @@ -1664,8 +1664,8 @@ class EmojiCompat_InitCallback extends jni.JObject { } static final _onInitialized = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "EmojiCompat_InitCallback__onInitialized") .asFunction)>(); @@ -1914,9 +1914,9 @@ class DefaultEmojiCompatConfig extends jni.JObject { /// The type which includes information such as the signature of this class. static const type = $DefaultEmojiCompatConfigType(); static final _create = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("DefaultEmojiCompatConfig__create") + ffi + .NativeFunction)>>( + "DefaultEmojiCompatConfig__create") .asFunction)>(); /// from: static public androidx.emoji2.text.FontRequestEmojiCompatConfig create(android.content.Context context) @@ -1972,9 +1972,9 @@ class $DefaultEmojiCompatConfigType class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28 extends DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19 { @override - late final jni.JObjType< - DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28> $type = - type; + late final jni + .JObjType + $type = type; DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28.fromRef( jni.JObjectPtr ref, @@ -2017,8 +2017,8 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28 } class $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28Type - extends jni.JObjType< - DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28> { + extends jni + .JObjType { const $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28Type(); @override @@ -2059,9 +2059,9 @@ class $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28Type class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19 extends DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper { @override - late final jni.JObjType< - DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19> $type = - type; + late final jni + .JObjType + $type = type; DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19.fromRef( jni.JObjectPtr ref, @@ -2126,8 +2126,8 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19 } class $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19Type - extends jni.JObjType< - DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19> { + extends jni + .JObjType { const $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19Type(); @override @@ -2169,8 +2169,8 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper extends jni.JObject { @override late final jni - .JObjType - $type = type; + .JObjType $type = + type; DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper.fromRef( jni.JObjectPtr ref, @@ -2303,7 +2303,7 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory extends jni.JObject { @override late final jni - .JObjType + .JObjType $type = type; DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory.fromRef( @@ -2314,8 +2314,8 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory static const type = $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactoryType(); static final _ctor = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__ctor") .asFunction)>(); @@ -2399,9 +2399,9 @@ class Build_Partition extends jni.JObject { static const PARTITION_NAME_SYSTEM = r"""system"""; static final _getName = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("Build_Partition__getName") + ffi + .NativeFunction)>>( + "Build_Partition__getName") .asFunction)>(); /// from: public java.lang.String getName() @@ -2411,9 +2411,9 @@ class Build_Partition extends jni.JObject { } static final _getFingerprint = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("Build_Partition__getFingerprint") + ffi + .NativeFunction)>>( + "Build_Partition__getFingerprint") .asFunction)>(); /// from: public java.lang.String getFingerprint() @@ -2423,8 +2423,8 @@ class Build_Partition extends jni.JObject { } static final _getBuildTimeMillis = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "Build_Partition__getBuildTimeMillis") .asFunction)>(); @@ -2449,9 +2449,9 @@ class Build_Partition extends jni.JObject { } static final _hashCode1 = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("Build_Partition__hashCode1") + ffi + .NativeFunction)>>( + "Build_Partition__hashCode1") .asFunction)>(); /// from: public int hashCode() @@ -3207,8 +3207,9 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> } static final _ctor3 = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>("HashMap__ctor3") + ffi + .NativeFunction)>>( + "HashMap__ctor3") .asFunction)>(); /// from: public void (java.util.Map map) @@ -3228,8 +3229,9 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> } static final _size = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>("HashMap__size") + ffi + .NativeFunction)>>( + "HashMap__size") .asFunction)>(); /// from: public int size() @@ -3238,9 +3240,9 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> } static final _isEmpty = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("HashMap__isEmpty") + ffi + .NativeFunction)>>( + "HashMap__isEmpty") .asFunction)>(); /// from: public boolean isEmpty() @@ -3331,8 +3333,9 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> } static final _clear = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>("HashMap__clear") + ffi + .NativeFunction)>>( + "HashMap__clear") .asFunction)>(); /// from: public void clear() @@ -3356,8 +3359,9 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> } static final _keySet = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>("HashMap__keySet") + ffi + .NativeFunction)>>( + "HashMap__keySet") .asFunction)>(); /// from: public java.util.Set keySet() @@ -3367,8 +3371,9 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> } static final _values = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>("HashMap__values") + ffi + .NativeFunction)>>( + "HashMap__values") .asFunction)>(); /// from: public java.util.Collection values() @@ -3378,9 +3383,9 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> } static final _entrySet = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("HashMap__entrySet") + ffi + .NativeFunction)>>( + "HashMap__entrySet") .asFunction)>(); /// from: public java.util.Set entrySet() @@ -3606,8 +3611,9 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> } static final _clone = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>("HashMap__clone") + ffi + .NativeFunction)>>( + "HashMap__clone") .asFunction)>(); /// from: public java.lang.Object clone() diff --git a/pkgs/jnigen/example/in_app_java/pubspec.yaml b/pkgs/jnigen/example/in_app_java/pubspec.yaml index 7ab467b88..2d97acf42 100644 --- a/pkgs/jnigen/example/in_app_java/pubspec.yaml +++ b/pkgs/jnigen/example/in_app_java/pubspec.yaml @@ -8,7 +8,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: ">=2.17.6 <4.0.0" + sdk: ">=3.1.0 <4.0.0" dependencies: flutter: diff --git a/pkgs/jnigen/example/in_app_java/src/android_utils/dartjni.h b/pkgs/jnigen/example/in_app_java/src/android_utils/dartjni.h index cca31f49e..0a7f66914 100644 --- a/pkgs/jnigen/example/in_app_java/src/android_utils/dartjni.h +++ b/pkgs/jnigen/example/in_app_java/src/android_utils/dartjni.h @@ -124,16 +124,6 @@ static inline void destroy_cond(ConditionVariable* cond) { #endif -static inline uint64_t thread_id() { -#ifdef _WIN32 - return GetCurrentThreadId(); -#elif defined __APPLE__ - return pthread_mach_thread_np(pthread_self()); -#else - return pthread_self(); -#endif -} - typedef struct CallbackResult { MutexLock lock; ConditionVariable cond; diff --git a/pkgs/jnigen/example/kotlin_plugin/example/pubspec.yaml b/pkgs/jnigen/example/kotlin_plugin/example/pubspec.yaml index 2da89b59f..0f6224e7c 100644 --- a/pkgs/jnigen/example/kotlin_plugin/example/pubspec.yaml +++ b/pkgs/jnigen/example/kotlin_plugin/example/pubspec.yaml @@ -6,7 +6,7 @@ publish_to: "none" version: 1.0.0+1 environment: - sdk: ">=2.19.0-444.3.beta <4.0.0" + sdk: ">=3.1.0 <4.0.0" dependencies: flutter: diff --git a/pkgs/jnigen/example/kotlin_plugin/pubspec.yaml b/pkgs/jnigen/example/kotlin_plugin/pubspec.yaml index e0546891a..fd89ad6cc 100644 --- a/pkgs/jnigen/example/kotlin_plugin/pubspec.yaml +++ b/pkgs/jnigen/example/kotlin_plugin/pubspec.yaml @@ -8,7 +8,7 @@ version: 0.0.1 publish_to: none environment: - sdk: '>=2.19.0-444.3.beta <4.0.0' + sdk: '>=3.1.0 <4.0.0' flutter: ">=1.17.0" dependencies: diff --git a/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h b/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h index cca31f49e..0a7f66914 100644 --- a/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h +++ b/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h @@ -124,16 +124,6 @@ static inline void destroy_cond(ConditionVariable* cond) { #endif -static inline uint64_t thread_id() { -#ifdef _WIN32 - return GetCurrentThreadId(); -#elif defined __APPLE__ - return pthread_mach_thread_np(pthread_self()); -#else - return pthread_self(); -#endif -} - typedef struct CallbackResult { MutexLock lock; ConditionVariable cond; diff --git a/pkgs/jnigen/example/notification_plugin/example/pubspec.yaml b/pkgs/jnigen/example/notification_plugin/example/pubspec.yaml index cbcaed9d0..35f3357f1 100644 --- a/pkgs/jnigen/example/notification_plugin/example/pubspec.yaml +++ b/pkgs/jnigen/example/notification_plugin/example/pubspec.yaml @@ -20,7 +20,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: '>=2.17.6 <4.0.0' + sdk: '>=3.1.0 <4.0.0' dependencies: flutter: diff --git a/pkgs/jnigen/example/notification_plugin/pubspec.yaml b/pkgs/jnigen/example/notification_plugin/pubspec.yaml index f2a6e1b9b..1f6cf4925 100644 --- a/pkgs/jnigen/example/notification_plugin/pubspec.yaml +++ b/pkgs/jnigen/example/notification_plugin/pubspec.yaml @@ -5,7 +5,7 @@ publish_to: none homepage: https://github.com/dart-lang/jnigen environment: - sdk: '>=2.17.6 <4.0.0' + sdk: '>=3.1.0 <4.0.0' flutter: ">=2.11.0" dependencies: diff --git a/pkgs/jnigen/example/notification_plugin/src/dartjni.h b/pkgs/jnigen/example/notification_plugin/src/dartjni.h index cca31f49e..0a7f66914 100644 --- a/pkgs/jnigen/example/notification_plugin/src/dartjni.h +++ b/pkgs/jnigen/example/notification_plugin/src/dartjni.h @@ -124,16 +124,6 @@ static inline void destroy_cond(ConditionVariable* cond) { #endif -static inline uint64_t thread_id() { -#ifdef _WIN32 - return GetCurrentThreadId(); -#elif defined __APPLE__ - return pthread_mach_thread_np(pthread_self()); -#else - return pthread_self(); -#endif -} - typedef struct CallbackResult { MutexLock lock; ConditionVariable cond; diff --git a/pkgs/jnigen/example/pdfbox_plugin/dart_example/pubspec.yaml b/pkgs/jnigen/example/pdfbox_plugin/dart_example/pubspec.yaml index ed3755980..4af3cf1fd 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/dart_example/pubspec.yaml +++ b/pkgs/jnigen/example/pdfbox_plugin/dart_example/pubspec.yaml @@ -5,7 +5,7 @@ publish_to: none # homepage: https://www.example.com environment: - sdk: '>=2.17.6 <4.0.0' + sdk: '>=3.1.0 <4.0.0' dependencies: path: ^1.8.0 diff --git a/pkgs/jnigen/example/pdfbox_plugin/example/pubspec.yaml b/pkgs/jnigen/example/pdfbox_plugin/example/pubspec.yaml index 6c962985b..af0ea2d28 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/example/pubspec.yaml +++ b/pkgs/jnigen/example/pdfbox_plugin/example/pubspec.yaml @@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: ">=2.17.6 <4.0.0" + sdk: ">=3.1.0 <4.0.0" # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions 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 3e5525212..ed3c555c6 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 @@ -70,9 +70,9 @@ class PDDocument extends jni.JObject { } static final _ctor1 = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDDocument__ctor1") + ffi + .NativeFunction)>>( + "PDDocument__ctor1") .asFunction)>(); /// from: public void (org.apache.pdfbox.io.MemoryUsageSetting memUsageSetting) @@ -88,9 +88,9 @@ class PDDocument extends jni.JObject { } static final _ctor2 = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDDocument__ctor2") + ffi + .NativeFunction)>>( + "PDDocument__ctor2") .asFunction)>(); /// from: public void (org.apache.pdfbox.cos.COSDocument doc) @@ -399,9 +399,9 @@ class PDDocument extends jni.JObject { } static final _getDocument = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDDocument__getDocument") + ffi + .NativeFunction)>>( + "PDDocument__getDocument") .asFunction)>(); /// from: public org.apache.pdfbox.cos.COSDocument getDocument() @@ -414,9 +414,9 @@ class PDDocument extends jni.JObject { } static final _getDocumentInformation = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDDocument__getDocumentInformation") + ffi + .NativeFunction)>>( + "PDDocument__getDocumentInformation") .asFunction)>(); /// from: public org.apache.pdfbox.pdmodel.PDDocumentInformation getDocumentInformation() @@ -457,9 +457,9 @@ class PDDocument extends jni.JObject { } static final _getDocumentCatalog = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDDocument__getDocumentCatalog") + ffi + .NativeFunction)>>( + "PDDocument__getDocumentCatalog") .asFunction)>(); /// from: public org.apache.pdfbox.pdmodel.PDDocumentCatalog getDocumentCatalog() @@ -473,9 +473,9 @@ class PDDocument extends jni.JObject { } static final _isEncrypted = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDDocument__isEncrypted") + ffi + .NativeFunction)>>( + "PDDocument__isEncrypted") .asFunction)>(); /// from: public boolean isEncrypted() @@ -487,9 +487,9 @@ class PDDocument extends jni.JObject { } static final _getEncryption = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDDocument__getEncryption") + ffi + .NativeFunction)>>( + "PDDocument__getEncryption") .asFunction)>(); /// from: public org.apache.pdfbox.pdmodel.encryption.PDEncryption getEncryption() @@ -525,8 +525,8 @@ class PDDocument extends jni.JObject { } static final _getLastSignatureDictionary = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "PDDocument__getLastSignatureDictionary") .asFunction)>(); @@ -543,9 +543,9 @@ class PDDocument extends jni.JObject { } static final _getSignatureFields = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDDocument__getSignatureFields") + ffi + .NativeFunction)>>( + "PDDocument__getSignatureFields") .asFunction)>(); /// from: public java.util.List getSignatureFields() @@ -560,8 +560,8 @@ class PDDocument extends jni.JObject { } static final _getSignatureDictionaries = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "PDDocument__getSignatureDictionaries") .asFunction)>(); @@ -598,9 +598,9 @@ class PDDocument extends jni.JObject { } static final _load = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDDocument__load") + ffi + .NativeFunction)>>( + "PDDocument__load") .asFunction)>(); /// from: static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.File file) @@ -773,9 +773,9 @@ class PDDocument extends jni.JObject { } static final _load6 = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDDocument__load6") + ffi + .NativeFunction)>>( + "PDDocument__load6") .asFunction)>(); /// from: static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.InputStream input) @@ -955,9 +955,9 @@ class PDDocument extends jni.JObject { } static final _load12 = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDDocument__load12") + ffi + .NativeFunction)>>( + "PDDocument__load12") .asFunction)>(); /// from: static public org.apache.pdfbox.pdmodel.PDDocument load(byte[] input) @@ -1294,9 +1294,9 @@ class PDDocument extends jni.JObject { } static final _getPages = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDDocument__getPages") + ffi + .NativeFunction)>>( + "PDDocument__getPages") .asFunction)>(); /// from: public org.apache.pdfbox.pdmodel.PDPageTree getPages() @@ -1309,9 +1309,9 @@ class PDDocument extends jni.JObject { } static final _getNumberOfPages = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDDocument__getNumberOfPages") + ffi + .NativeFunction)>>( + "PDDocument__getNumberOfPages") .asFunction)>(); /// from: public int getNumberOfPages() @@ -1323,9 +1323,9 @@ class PDDocument extends jni.JObject { } static final _close = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDDocument__close") + ffi + .NativeFunction)>>( + "PDDocument__close") .asFunction)>(); /// from: public void close() @@ -1363,8 +1363,8 @@ class PDDocument extends jni.JObject { } static final _getCurrentAccessPermission = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "PDDocument__getCurrentAccessPermission") .asFunction)>(); @@ -1382,8 +1382,8 @@ class PDDocument extends jni.JObject { } static final _isAllSecurityToBeRemoved = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "PDDocument__isAllSecurityToBeRemoved") .asFunction)>(); @@ -1413,9 +1413,9 @@ class PDDocument extends jni.JObject { } static final _getDocumentId = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDDocument__getDocumentId") + ffi + .NativeFunction)>>( + "PDDocument__getDocumentId") .asFunction)>(); /// from: public java.lang.Long getDocumentId() @@ -1446,9 +1446,9 @@ class PDDocument extends jni.JObject { } static final _getVersion = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDDocument__getVersion") + ffi + .NativeFunction)>>( + "PDDocument__getVersion") .asFunction)>(); /// from: public float getVersion() @@ -1476,9 +1476,9 @@ class PDDocument extends jni.JObject { } static final _getResourceCache = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDDocument__getResourceCache") + ffi + .NativeFunction)>>( + "PDDocument__getResourceCache") .asFunction)>(); /// from: public org.apache.pdfbox.pdmodel.ResourceCache getResourceCache() 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 87862bacc..5d9a8ff6a 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 @@ -70,9 +70,9 @@ class PDDocumentInformation extends jni.JObject { } static final _ctor1 = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDDocumentInformation__ctor1") + ffi + .NativeFunction)>>( + "PDDocumentInformation__ctor1") .asFunction)>(); /// from: public void (org.apache.pdfbox.cos.COSDictionary dic) @@ -87,8 +87,8 @@ class PDDocumentInformation extends jni.JObject { } static final _getCOSObject = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "PDDocumentInformation__getCOSObject") .asFunction)>(); @@ -129,9 +129,9 @@ class PDDocumentInformation extends jni.JObject { } static final _getTitle = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDDocumentInformation__getTitle") + ffi + .NativeFunction)>>( + "PDDocumentInformation__getTitle") .asFunction)>(); /// from: public java.lang.String getTitle() @@ -162,9 +162,9 @@ class PDDocumentInformation extends jni.JObject { } static final _getAuthor = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDDocumentInformation__getAuthor") + ffi + .NativeFunction)>>( + "PDDocumentInformation__getAuthor") .asFunction)>(); /// from: public java.lang.String getAuthor() @@ -195,9 +195,9 @@ class PDDocumentInformation extends jni.JObject { } static final _getSubject = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDDocumentInformation__getSubject") + ffi + .NativeFunction)>>( + "PDDocumentInformation__getSubject") .asFunction)>(); /// from: public java.lang.String getSubject() @@ -228,9 +228,9 @@ class PDDocumentInformation extends jni.JObject { } static final _getKeywords = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDDocumentInformation__getKeywords") + ffi + .NativeFunction)>>( + "PDDocumentInformation__getKeywords") .asFunction)>(); /// from: public java.lang.String getKeywords() @@ -261,9 +261,9 @@ class PDDocumentInformation extends jni.JObject { } static final _getCreator = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDDocumentInformation__getCreator") + ffi + .NativeFunction)>>( + "PDDocumentInformation__getCreator") .asFunction)>(); /// from: public java.lang.String getCreator() @@ -294,9 +294,9 @@ class PDDocumentInformation extends jni.JObject { } static final _getProducer = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDDocumentInformation__getProducer") + ffi + .NativeFunction)>>( + "PDDocumentInformation__getProducer") .asFunction)>(); /// from: public java.lang.String getProducer() @@ -327,8 +327,8 @@ class PDDocumentInformation extends jni.JObject { } static final _getCreationDate = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "PDDocumentInformation__getCreationDate") .asFunction)>(); @@ -361,8 +361,8 @@ class PDDocumentInformation extends jni.JObject { } static final _getModificationDate = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "PDDocumentInformation__getModificationDate") .asFunction)>(); @@ -396,9 +396,9 @@ class PDDocumentInformation extends jni.JObject { } static final _getTrapped = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDDocumentInformation__getTrapped") + ffi + .NativeFunction)>>( + "PDDocumentInformation__getTrapped") .asFunction)>(); /// from: public java.lang.String getTrapped() @@ -412,8 +412,8 @@ class PDDocumentInformation extends jni.JObject { } static final _getMetadataKeys = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "PDDocumentInformation__getMetadataKeys") .asFunction)>(); 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 306258cca..e2bc49074 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 @@ -327,9 +327,9 @@ class PDFTextStripper extends jni.JObject { } static final _startArticle = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDFTextStripper__startArticle") + ffi + .NativeFunction)>>( + "PDFTextStripper__startArticle") .asFunction)>(); /// from: protected void startArticle() @@ -361,9 +361,9 @@ class PDFTextStripper extends jni.JObject { } static final _endArticle = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDFTextStripper__endArticle") + ffi + .NativeFunction)>>( + "PDFTextStripper__endArticle") .asFunction)>(); /// from: protected void endArticle() @@ -413,9 +413,9 @@ class PDFTextStripper extends jni.JObject { } static final _writePage = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDFTextStripper__writePage") + ffi + .NativeFunction)>>( + "PDFTextStripper__writePage") .asFunction)>(); /// from: protected void writePage() @@ -429,8 +429,8 @@ class PDFTextStripper extends jni.JObject { } static final _writeLineSeparator = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "PDFTextStripper__writeLineSeparator") .asFunction)>(); @@ -443,8 +443,8 @@ class PDFTextStripper extends jni.JObject { } static final _writeWordSeparator = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "PDFTextStripper__writeWordSeparator") .asFunction)>(); @@ -540,9 +540,9 @@ class PDFTextStripper extends jni.JObject { } static final _getStartPage = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDFTextStripper__getStartPage") + ffi + .NativeFunction)>>( + "PDFTextStripper__getStartPage") .asFunction)>(); /// from: public int getStartPage() @@ -572,9 +572,9 @@ class PDFTextStripper extends jni.JObject { } static final _getEndPage = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDFTextStripper__getEndPage") + ffi + .NativeFunction)>>( + "PDFTextStripper__getEndPage") .asFunction)>(); /// from: public int getEndPage() @@ -623,9 +623,9 @@ class PDFTextStripper extends jni.JObject { } static final _getLineSeparator = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDFTextStripper__getLineSeparator") + ffi + .NativeFunction)>>( + "PDFTextStripper__getLineSeparator") .asFunction)>(); /// from: public java.lang.String getLineSeparator() @@ -638,9 +638,9 @@ class PDFTextStripper extends jni.JObject { } static final _getWordSeparator = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDFTextStripper__getWordSeparator") + ffi + .NativeFunction)>>( + "PDFTextStripper__getWordSeparator") .asFunction)>(); /// from: public java.lang.String getWordSeparator() @@ -674,8 +674,8 @@ class PDFTextStripper extends jni.JObject { } static final _getSuppressDuplicateOverlappingText = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "PDFTextStripper__getSuppressDuplicateOverlappingText") .asFunction)>(); @@ -687,9 +687,9 @@ class PDFTextStripper extends jni.JObject { } static final _getCurrentPageNo = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDFTextStripper__getCurrentPageNo") + ffi + .NativeFunction)>>( + "PDFTextStripper__getCurrentPageNo") .asFunction)>(); /// from: protected int getCurrentPageNo() @@ -701,9 +701,9 @@ class PDFTextStripper extends jni.JObject { } static final _getOutput = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDFTextStripper__getOutput") + ffi + .NativeFunction)>>( + "PDFTextStripper__getOutput") .asFunction)>(); /// from: protected java.io.Writer getOutput() @@ -716,8 +716,8 @@ class PDFTextStripper extends jni.JObject { } static final _getCharactersByArticle = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "PDFTextStripper__getCharactersByArticle") .asFunction)>(); @@ -753,8 +753,8 @@ class PDFTextStripper extends jni.JObject { } static final _getSeparateByBeads = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "PDFTextStripper__getSeparateByBeads") .asFunction)>(); @@ -784,9 +784,9 @@ class PDFTextStripper extends jni.JObject { } static final _getEndBookmark = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDFTextStripper__getEndBookmark") + ffi + .NativeFunction)>>( + "PDFTextStripper__getEndBookmark") .asFunction)>(); /// from: public org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem getEndBookmark() @@ -817,9 +817,9 @@ class PDFTextStripper extends jni.JObject { } static final _getStartBookmark = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDFTextStripper__getStartBookmark") + ffi + .NativeFunction)>>( + "PDFTextStripper__getStartBookmark") .asFunction)>(); /// from: public org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem getStartBookmark() @@ -850,8 +850,8 @@ class PDFTextStripper extends jni.JObject { } static final _getAddMoreFormatting = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "PDFTextStripper__getAddMoreFormatting") .asFunction)>(); @@ -881,9 +881,9 @@ class PDFTextStripper extends jni.JObject { } static final _getSortByPosition = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDFTextStripper__getSortByPosition") + ffi + .NativeFunction)>>( + "PDFTextStripper__getSortByPosition") .asFunction)>(); /// from: public boolean getSortByPosition() @@ -917,8 +917,8 @@ class PDFTextStripper extends jni.JObject { } static final _getSpacingTolerance = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "PDFTextStripper__getSpacingTolerance") .asFunction)>(); @@ -950,8 +950,8 @@ class PDFTextStripper extends jni.JObject { } static final _getAverageCharTolerance = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "PDFTextStripper__getAverageCharTolerance") .asFunction)>(); @@ -984,8 +984,8 @@ class PDFTextStripper extends jni.JObject { } static final _getIndentThreshold = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "PDFTextStripper__getIndentThreshold") .asFunction)>(); @@ -1017,9 +1017,9 @@ class PDFTextStripper extends jni.JObject { } static final _getDropThreshold = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDFTextStripper__getDropThreshold") + ffi + .NativeFunction)>>( + "PDFTextStripper__getDropThreshold") .asFunction)>(); /// from: public float getDropThreshold() @@ -1050,9 +1050,9 @@ class PDFTextStripper extends jni.JObject { } static final _getParagraphStart = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDFTextStripper__getParagraphStart") + ffi + .NativeFunction)>>( + "PDFTextStripper__getParagraphStart") .asFunction)>(); /// from: public java.lang.String getParagraphStart() @@ -1084,9 +1084,9 @@ class PDFTextStripper extends jni.JObject { } static final _getParagraphEnd = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDFTextStripper__getParagraphEnd") + ffi + .NativeFunction)>>( + "PDFTextStripper__getParagraphEnd") .asFunction)>(); /// from: public java.lang.String getParagraphEnd() @@ -1117,9 +1117,9 @@ class PDFTextStripper extends jni.JObject { } static final _getPageStart = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDFTextStripper__getPageStart") + ffi + .NativeFunction)>>( + "PDFTextStripper__getPageStart") .asFunction)>(); /// from: public java.lang.String getPageStart() @@ -1150,9 +1150,9 @@ class PDFTextStripper extends jni.JObject { } static final _getPageEnd = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDFTextStripper__getPageEnd") + ffi + .NativeFunction)>>( + "PDFTextStripper__getPageEnd") .asFunction)>(); /// from: public java.lang.String getPageEnd() @@ -1183,9 +1183,9 @@ class PDFTextStripper extends jni.JObject { } static final _getArticleStart = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDFTextStripper__getArticleStart") + ffi + .NativeFunction)>>( + "PDFTextStripper__getArticleStart") .asFunction)>(); /// from: public java.lang.String getArticleStart() @@ -1216,9 +1216,9 @@ class PDFTextStripper extends jni.JObject { } static final _getArticleEnd = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDFTextStripper__getArticleEnd") + ffi + .NativeFunction)>>( + "PDFTextStripper__getArticleEnd") .asFunction)>(); /// from: public java.lang.String getArticleEnd() @@ -1249,8 +1249,8 @@ class PDFTextStripper extends jni.JObject { } static final _writeParagraphSeparator = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "PDFTextStripper__writeParagraphSeparator") .asFunction)>(); @@ -1263,8 +1263,8 @@ class PDFTextStripper extends jni.JObject { } static final _writeParagraphStart = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "PDFTextStripper__writeParagraphStart") .asFunction)>(); @@ -1277,9 +1277,9 @@ class PDFTextStripper extends jni.JObject { } static final _writeParagraphEnd = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDFTextStripper__writeParagraphEnd") + ffi + .NativeFunction)>>( + "PDFTextStripper__writeParagraphEnd") .asFunction)>(); /// from: protected void writeParagraphEnd() @@ -1291,9 +1291,9 @@ class PDFTextStripper extends jni.JObject { } static final _writePageStart = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDFTextStripper__writePageStart") + ffi + .NativeFunction)>>( + "PDFTextStripper__writePageStart") .asFunction)>(); /// from: protected void writePageStart() @@ -1305,9 +1305,9 @@ class PDFTextStripper extends jni.JObject { } static final _writePageEnd = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("PDFTextStripper__writePageEnd") + ffi + .NativeFunction)>>( + "PDFTextStripper__writePageEnd") .asFunction)>(); /// from: protected void writePageEnd() @@ -1338,8 +1338,8 @@ class PDFTextStripper extends jni.JObject { } static final _getListItemPatterns = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "PDFTextStripper__getListItemPatterns") .asFunction)>(); diff --git a/pkgs/jnigen/example/pdfbox_plugin/pubspec.yaml b/pkgs/jnigen/example/pdfbox_plugin/pubspec.yaml index f77b031ed..fc9c7399f 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/pubspec.yaml +++ b/pkgs/jnigen/example/pdfbox_plugin/pubspec.yaml @@ -6,7 +6,7 @@ publish_to: none homepage: https://github.com/dart-lang/jnigen environment: - sdk: ">=2.17.6 <4.0.0" + sdk: ">=3.1.0 <4.0.0" #flutter: ">=2.11.0" dependencies: diff --git a/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h b/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h index cca31f49e..0a7f66914 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h +++ b/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h @@ -124,16 +124,6 @@ static inline void destroy_cond(ConditionVariable* cond) { #endif -static inline uint64_t thread_id() { -#ifdef _WIN32 - return GetCurrentThreadId(); -#elif defined __APPLE__ - return pthread_mach_thread_np(pthread_self()); -#else - return pthread_self(); -#endif -} - typedef struct CallbackResult { MutexLock lock; ConditionVariable cond; diff --git a/pkgs/jnigen/pubspec.yaml b/pkgs/jnigen/pubspec.yaml index 07be3c818..0bc676466 100644 --- a/pkgs/jnigen/pubspec.yaml +++ b/pkgs/jnigen/pubspec.yaml @@ -8,7 +8,7 @@ description: Experimental generator for FFI+JNI bindings. repository: https://github.com/dart-lang/jnigen/tree/main/jnigen environment: - sdk: '>=2.17.0 <4.0.0' + sdk: '>=3.1.0 <4.0.0' dependencies: json_annotation: ^4.8.0 diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/dartjni.h b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/dartjni.h index cca31f49e..0a7f66914 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/dartjni.h +++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/dartjni.h @@ -124,16 +124,6 @@ static inline void destroy_cond(ConditionVariable* cond) { #endif -static inline uint64_t thread_id() { -#ifdef _WIN32 - return GetCurrentThreadId(); -#elif defined __APPLE__ - return pthread_mach_thread_np(pthread_self()); -#else - return pthread_self(); -#endif -} - typedef struct CallbackResult { MutexLock lock; ConditionVariable cond; diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart index 33f513996..1e60c8a6b 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart @@ -141,9 +141,9 @@ class JsonFactory extends jni.JObject { } static final _ctor1 = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonFactory__ctor1") + ffi + .NativeFunction)>>( + "JsonFactory__ctor1") .asFunction)>(); /// from: public void (com.fasterxml.jackson.core.ObjectCodec oc) @@ -177,9 +177,9 @@ class JsonFactory extends jni.JObject { } static final _ctor3 = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonFactory__ctor3") + ffi + .NativeFunction)>>( + "JsonFactory__ctor3") .asFunction)>(); /// from: public void (com.fasterxml.jackson.core.JsonFactoryBuilder b) @@ -216,9 +216,9 @@ class JsonFactory extends jni.JObject { } static final _rebuild = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonFactory__rebuild") + ffi + .NativeFunction)>>( + "JsonFactory__rebuild") .asFunction)>(); /// from: public com.fasterxml.jackson.core.TSFBuilder rebuild() @@ -253,9 +253,9 @@ class JsonFactory extends jni.JObject { } static final _copy = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonFactory__copy") + ffi + .NativeFunction)>>( + "JsonFactory__copy") .asFunction)>(); /// from: public com.fasterxml.jackson.core.JsonFactory copy() @@ -278,9 +278,9 @@ class JsonFactory extends jni.JObject { } static final _readResolve = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonFactory__readResolve") + ffi + .NativeFunction)>>( + "JsonFactory__readResolve") .asFunction)>(); /// from: protected java.lang.Object readResolve() @@ -297,8 +297,8 @@ class JsonFactory extends jni.JObject { } static final _requiresPropertyOrdering = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "JsonFactory__requiresPropertyOrdering") .asFunction)>(); @@ -323,8 +323,8 @@ class JsonFactory extends jni.JObject { } static final _canHandleBinaryNatively = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "JsonFactory__canHandleBinaryNatively") .asFunction)>(); @@ -346,9 +346,9 @@ class JsonFactory extends jni.JObject { } static final _canUseCharArrays = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonFactory__canUseCharArrays") + ffi + .NativeFunction)>>( + "JsonFactory__canUseCharArrays") .asFunction)>(); /// from: public boolean canUseCharArrays() @@ -369,9 +369,9 @@ class JsonFactory extends jni.JObject { } static final _canParseAsync = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonFactory__canParseAsync") + ffi + .NativeFunction)>>( + "JsonFactory__canParseAsync") .asFunction)>(); /// from: public boolean canParseAsync() @@ -388,8 +388,8 @@ class JsonFactory extends jni.JObject { } static final _getFormatReadFeatureType = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "JsonFactory__getFormatReadFeatureType") .asFunction)>(); @@ -401,8 +401,8 @@ class JsonFactory extends jni.JObject { } static final _getFormatWriteFeatureType = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "JsonFactory__getFormatWriteFeatureType") .asFunction)>(); @@ -439,9 +439,9 @@ class JsonFactory extends jni.JObject { } static final _getFormatName = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonFactory__getFormatName") + ffi + .NativeFunction)>>( + "JsonFactory__getFormatName") .asFunction)>(); /// from: public java.lang.String getFormatName() @@ -475,9 +475,9 @@ class JsonFactory extends jni.JObject { } static final _requiresCustomCodec = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonFactory__requiresCustomCodec") + ffi + .NativeFunction)>>( + "JsonFactory__requiresCustomCodec") .asFunction)>(); /// from: public boolean requiresCustomCodec() @@ -513,9 +513,9 @@ class JsonFactory extends jni.JObject { } static final _version = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonFactory__version") + ffi + .NativeFunction)>>( + "JsonFactory__version") .asFunction)>(); /// from: public com.fasterxml.jackson.core.Version version() @@ -615,9 +615,9 @@ class JsonFactory extends jni.JObject { } static final _getParserFeatures = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonFactory__getParserFeatures") + ffi + .NativeFunction)>>( + "JsonFactory__getParserFeatures") .asFunction)>(); /// from: public final int getParserFeatures() @@ -626,9 +626,9 @@ class JsonFactory extends jni.JObject { } static final _getGeneratorFeatures = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonFactory__getGeneratorFeatures") + ffi + .NativeFunction)>>( + "JsonFactory__getGeneratorFeatures") .asFunction)>(); /// from: public final int getGeneratorFeatures() @@ -637,8 +637,8 @@ class JsonFactory extends jni.JObject { } static final _getFormatParserFeatures = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "JsonFactory__getFormatParserFeatures") .asFunction)>(); @@ -648,8 +648,8 @@ class JsonFactory extends jni.JObject { } static final _getFormatGeneratorFeatures = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "JsonFactory__getFormatGeneratorFeatures") .asFunction)>(); @@ -766,9 +766,9 @@ class JsonFactory extends jni.JObject { } static final _getInputDecorator = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonFactory__getInputDecorator") + ffi + .NativeFunction)>>( + "JsonFactory__getInputDecorator") .asFunction)>(); /// from: public com.fasterxml.jackson.core.io.InputDecorator getInputDecorator() @@ -912,9 +912,9 @@ class JsonFactory extends jni.JObject { } static final _getCharacterEscapes = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonFactory__getCharacterEscapes") + ffi + .NativeFunction)>>( + "JsonFactory__getCharacterEscapes") .asFunction)>(); /// from: public com.fasterxml.jackson.core.io.CharacterEscapes getCharacterEscapes() @@ -951,9 +951,9 @@ class JsonFactory extends jni.JObject { } static final _getOutputDecorator = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonFactory__getOutputDecorator") + ffi + .NativeFunction)>>( + "JsonFactory__getOutputDecorator") .asFunction)>(); /// from: public com.fasterxml.jackson.core.io.OutputDecorator getOutputDecorator() @@ -1014,9 +1014,9 @@ class JsonFactory extends jni.JObject { } static final _getRootValueSeparator = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonFactory__getRootValueSeparator") + ffi + .NativeFunction)>>( + "JsonFactory__getRootValueSeparator") .asFunction)>(); /// from: public java.lang.String getRootValueSeparator() @@ -1054,9 +1054,9 @@ class JsonFactory extends jni.JObject { } static final _getCodec = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonFactory__getCodec") + ffi + .NativeFunction)>>( + "JsonFactory__getCodec") .asFunction)>(); /// from: public com.fasterxml.jackson.core.ObjectCodec getCodec() @@ -1336,8 +1336,8 @@ class JsonFactory extends jni.JObject { } static final _createNonBlockingByteArrayParser = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "JsonFactory__createNonBlockingByteArrayParser") .asFunction)>(); @@ -1904,9 +1904,9 @@ class JsonFactory_Feature extends jni.JObject { } static final _valueOf = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonFactory_Feature__valueOf") + ffi + .NativeFunction)>>( + "JsonFactory_Feature__valueOf") .asFunction)>(); /// from: static public com.fasterxml.jackson.core.JsonFactory.Feature valueOf(java.lang.String name) @@ -1933,8 +1933,8 @@ class JsonFactory_Feature extends jni.JObject { } static final _enabledByDefault = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "JsonFactory_Feature__enabledByDefault") .asFunction)>(); @@ -1957,9 +1957,9 @@ class JsonFactory_Feature extends jni.JObject { } static final _getMask = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonFactory_Feature__getMask") + ffi + .NativeFunction)>>( + "JsonFactory_Feature__getMask") .asFunction)>(); /// from: public int getMask() diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart index 032db3141..8790d3c75 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart @@ -95,9 +95,9 @@ class JsonParser extends jni.JObject { } static final _getCodec = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getCodec") + ffi + .NativeFunction)>>( + "JsonParser__getCodec") .asFunction)>(); /// from: public abstract com.fasterxml.jackson.core.ObjectCodec getCodec() @@ -132,9 +132,9 @@ class JsonParser extends jni.JObject { } static final _getInputSource = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getInputSource") + ffi + .NativeFunction)>>( + "JsonParser__getInputSource") .asFunction)>(); /// from: public java.lang.Object getInputSource() @@ -249,9 +249,9 @@ class JsonParser extends jni.JObject { } static final _getSchema = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getSchema") + ffi + .NativeFunction)>>( + "JsonParser__getSchema") .asFunction)>(); /// from: public com.fasterxml.jackson.core.FormatSchema getSchema() @@ -286,9 +286,9 @@ class JsonParser extends jni.JObject { } static final _requiresCustomCodec = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__requiresCustomCodec") + ffi + .NativeFunction)>>( + "JsonParser__requiresCustomCodec") .asFunction)>(); /// from: public boolean requiresCustomCodec() @@ -306,9 +306,9 @@ class JsonParser extends jni.JObject { } static final _canParseAsync = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__canParseAsync") + ffi + .NativeFunction)>>( + "JsonParser__canParseAsync") .asFunction)>(); /// from: public boolean canParseAsync() @@ -329,8 +329,8 @@ class JsonParser extends jni.JObject { } static final _getNonBlockingInputFeeder = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "JsonParser__getNonBlockingInputFeeder") .asFunction)>(); @@ -348,9 +348,9 @@ class JsonParser extends jni.JObject { } static final _getReadCapabilities = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getReadCapabilities") + ffi + .NativeFunction)>>( + "JsonParser__getReadCapabilities") .asFunction)>(); /// from: public com.fasterxml.jackson.core.util.JacksonFeatureSet getReadCapabilities() @@ -366,9 +366,9 @@ class JsonParser extends jni.JObject { } static final _version = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__version") + ffi + .NativeFunction)>>( + "JsonParser__version") .asFunction)>(); /// from: public abstract com.fasterxml.jackson.core.Version version() @@ -383,9 +383,9 @@ class JsonParser extends jni.JObject { } static final _close = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__close") + ffi + .NativeFunction)>>( + "JsonParser__close") .asFunction)>(); /// from: public abstract void close() @@ -409,9 +409,9 @@ class JsonParser extends jni.JObject { } static final _isClosed = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__isClosed") + ffi + .NativeFunction)>>( + "JsonParser__isClosed") .asFunction)>(); /// from: public abstract boolean isClosed() @@ -428,9 +428,9 @@ class JsonParser extends jni.JObject { } static final _getParsingContext = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getParsingContext") + ffi + .NativeFunction)>>( + "JsonParser__getParsingContext") .asFunction)>(); /// from: public abstract com.fasterxml.jackson.core.JsonStreamContext getParsingContext() @@ -451,9 +451,9 @@ class JsonParser extends jni.JObject { } static final _currentLocation = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__currentLocation") + ffi + .NativeFunction)>>( + "JsonParser__currentLocation") .asFunction)>(); /// from: public com.fasterxml.jackson.core.JsonLocation currentLocation() @@ -476,9 +476,9 @@ class JsonParser extends jni.JObject { } static final _currentTokenLocation = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__currentTokenLocation") + ffi + .NativeFunction)>>( + "JsonParser__currentTokenLocation") .asFunction)>(); /// from: public com.fasterxml.jackson.core.JsonLocation currentTokenLocation() @@ -502,9 +502,9 @@ class JsonParser extends jni.JObject { } static final _getCurrentLocation = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getCurrentLocation") + ffi + .NativeFunction)>>( + "JsonParser__getCurrentLocation") .asFunction)>(); /// from: public abstract com.fasterxml.jackson.core.JsonLocation getCurrentLocation() @@ -519,9 +519,9 @@ class JsonParser extends jni.JObject { } static final _getTokenLocation = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getTokenLocation") + ffi + .NativeFunction)>>( + "JsonParser__getTokenLocation") .asFunction)>(); /// from: public abstract com.fasterxml.jackson.core.JsonLocation getTokenLocation() @@ -535,9 +535,9 @@ class JsonParser extends jni.JObject { } static final _currentValue = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__currentValue") + ffi + .NativeFunction)>>( + "JsonParser__currentValue") .asFunction)>(); /// from: public java.lang.Object currentValue() @@ -581,9 +581,9 @@ class JsonParser extends jni.JObject { } static final _getCurrentValue = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getCurrentValue") + ffi + .NativeFunction)>>( + "JsonParser__getCurrentValue") .asFunction)>(); /// from: public java.lang.Object getCurrentValue() @@ -778,9 +778,9 @@ class JsonParser extends jni.JObject { } static final _getFeatureMask = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getFeatureMask") + ffi + .NativeFunction)>>( + "JsonParser__getFeatureMask") .asFunction)>(); /// from: public int getFeatureMask() @@ -843,9 +843,9 @@ class JsonParser extends jni.JObject { } static final _getFormatFeatures = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getFormatFeatures") + ffi + .NativeFunction)>>( + "JsonParser__getFormatFeatures") .asFunction)>(); /// from: public int getFormatFeatures() @@ -886,9 +886,9 @@ class JsonParser extends jni.JObject { } static final _nextToken = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__nextToken") + ffi + .NativeFunction)>>( + "JsonParser__nextToken") .asFunction)>(); /// from: public abstract com.fasterxml.jackson.core.JsonToken nextToken() @@ -908,9 +908,9 @@ class JsonParser extends jni.JObject { } static final _nextValue = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__nextValue") + ffi + .NativeFunction)>>( + "JsonParser__nextValue") .asFunction)>(); /// from: public abstract com.fasterxml.jackson.core.JsonToken nextValue() @@ -969,9 +969,9 @@ class JsonParser extends jni.JObject { } static final _nextFieldName1 = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__nextFieldName1") + ffi + .NativeFunction)>>( + "JsonParser__nextFieldName1") .asFunction)>(); /// from: public java.lang.String nextFieldName() @@ -990,9 +990,9 @@ class JsonParser extends jni.JObject { } static final _nextTextValue = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__nextTextValue") + ffi + .NativeFunction)>>( + "JsonParser__nextTextValue") .asFunction)>(); /// from: public java.lang.String nextTextValue() @@ -1078,9 +1078,9 @@ class JsonParser extends jni.JObject { } static final _nextBooleanValue = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__nextBooleanValue") + ffi + .NativeFunction)>>( + "JsonParser__nextBooleanValue") .asFunction)>(); /// from: public java.lang.Boolean nextBooleanValue() @@ -1108,9 +1108,9 @@ class JsonParser extends jni.JObject { } static final _skipChildren = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__skipChildren") + ffi + .NativeFunction)>>( + "JsonParser__skipChildren") .asFunction)>(); /// from: public abstract com.fasterxml.jackson.core.JsonParser skipChildren() @@ -1136,9 +1136,9 @@ class JsonParser extends jni.JObject { } static final _finishToken = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__finishToken") + ffi + .NativeFunction)>>( + "JsonParser__finishToken") .asFunction)>(); /// from: public void finishToken() @@ -1161,9 +1161,9 @@ class JsonParser extends jni.JObject { } static final _currentToken = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__currentToken") + ffi + .NativeFunction)>>( + "JsonParser__currentToken") .asFunction)>(); /// from: public com.fasterxml.jackson.core.JsonToken currentToken() @@ -1184,9 +1184,9 @@ class JsonParser extends jni.JObject { } static final _currentTokenId = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__currentTokenId") + ffi + .NativeFunction)>>( + "JsonParser__currentTokenId") .asFunction)>(); /// from: public int currentTokenId() @@ -1205,9 +1205,9 @@ class JsonParser extends jni.JObject { } static final _getCurrentToken = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getCurrentToken") + ffi + .NativeFunction)>>( + "JsonParser__getCurrentToken") .asFunction)>(); /// from: public abstract com.fasterxml.jackson.core.JsonToken getCurrentToken() @@ -1223,9 +1223,9 @@ class JsonParser extends jni.JObject { } static final _getCurrentTokenId = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getCurrentTokenId") + ffi + .NativeFunction)>>( + "JsonParser__getCurrentTokenId") .asFunction)>(); /// from: public abstract int getCurrentTokenId() @@ -1238,9 +1238,9 @@ class JsonParser extends jni.JObject { } static final _hasCurrentToken = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__hasCurrentToken") + ffi + .NativeFunction)>>( + "JsonParser__hasCurrentToken") .asFunction)>(); /// from: public abstract boolean hasCurrentToken() @@ -1312,8 +1312,8 @@ class JsonParser extends jni.JObject { } static final _isExpectedStartArrayToken = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "JsonParser__isExpectedStartArrayToken") .asFunction)>(); @@ -1340,8 +1340,8 @@ class JsonParser extends jni.JObject { } static final _isExpectedStartObjectToken = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "JsonParser__isExpectedStartObjectToken") .asFunction)>(); @@ -1358,8 +1358,8 @@ class JsonParser extends jni.JObject { } static final _isExpectedNumberIntToken = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "JsonParser__isExpectedNumberIntToken") .asFunction)>(); @@ -1379,9 +1379,9 @@ class JsonParser extends jni.JObject { } static final _isNaN = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__isNaN") + ffi + .NativeFunction)>>( + "JsonParser__isNaN") .asFunction)>(); /// from: public boolean isNaN() @@ -1403,9 +1403,9 @@ class JsonParser extends jni.JObject { } static final _clearCurrentToken = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__clearCurrentToken") + ffi + .NativeFunction)>>( + "JsonParser__clearCurrentToken") .asFunction)>(); /// from: public abstract void clearCurrentToken() @@ -1425,9 +1425,9 @@ class JsonParser extends jni.JObject { } static final _getLastClearedToken = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getLastClearedToken") + ffi + .NativeFunction)>>( + "JsonParser__getLastClearedToken") .asFunction)>(); /// from: public abstract com.fasterxml.jackson.core.JsonToken getLastClearedToken() @@ -1469,9 +1469,9 @@ class JsonParser extends jni.JObject { } static final _getCurrentName = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getCurrentName") + ffi + .NativeFunction)>>( + "JsonParser__getCurrentName") .asFunction)>(); /// from: public abstract java.lang.String getCurrentName() @@ -1486,9 +1486,9 @@ class JsonParser extends jni.JObject { } static final _currentName = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__currentName") + ffi + .NativeFunction)>>( + "JsonParser__currentName") .asFunction)>(); /// from: public java.lang.String currentName() @@ -1508,9 +1508,9 @@ class JsonParser extends jni.JObject { } static final _getText = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getText") + ffi + .NativeFunction)>>( + "JsonParser__getText") .asFunction)>(); /// from: public abstract java.lang.String getText() @@ -1560,9 +1560,9 @@ class JsonParser extends jni.JObject { } static final _getTextCharacters = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getTextCharacters") + ffi + .NativeFunction)>>( + "JsonParser__getTextCharacters") .asFunction)>(); /// from: public abstract char[] getTextCharacters() @@ -1601,9 +1601,9 @@ class JsonParser extends jni.JObject { } static final _getTextLength = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getTextLength") + ffi + .NativeFunction)>>( + "JsonParser__getTextLength") .asFunction)>(); /// from: public abstract int getTextLength() @@ -1620,9 +1620,9 @@ class JsonParser extends jni.JObject { } static final _getTextOffset = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getTextOffset") + ffi + .NativeFunction)>>( + "JsonParser__getTextOffset") .asFunction)>(); /// from: public abstract int getTextOffset() @@ -1639,9 +1639,9 @@ class JsonParser extends jni.JObject { } static final _hasTextCharacters = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__hasTextCharacters") + ffi + .NativeFunction)>>( + "JsonParser__hasTextCharacters") .asFunction)>(); /// from: public abstract boolean hasTextCharacters() @@ -1665,9 +1665,9 @@ class JsonParser extends jni.JObject { } static final _getNumberValue = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getNumberValue") + ffi + .NativeFunction)>>( + "JsonParser__getNumberValue") .asFunction)>(); /// from: public abstract java.lang.Number getNumberValue() @@ -1688,9 +1688,9 @@ class JsonParser extends jni.JObject { } static final _getNumberValueExact = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getNumberValueExact") + ffi + .NativeFunction)>>( + "JsonParser__getNumberValueExact") .asFunction)>(); /// from: public java.lang.Number getNumberValueExact() @@ -1716,9 +1716,9 @@ class JsonParser extends jni.JObject { } static final _getNumberType = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getNumberType") + ffi + .NativeFunction)>>( + "JsonParser__getNumberType") .asFunction)>(); /// from: public abstract com.fasterxml.jackson.core.JsonParser.NumberType getNumberType() @@ -1737,9 +1737,9 @@ class JsonParser extends jni.JObject { } static final _getByteValue = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getByteValue") + ffi + .NativeFunction)>>( + "JsonParser__getByteValue") .asFunction)>(); /// from: public byte getByteValue() @@ -1770,9 +1770,9 @@ class JsonParser extends jni.JObject { } static final _getShortValue = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getShortValue") + ffi + .NativeFunction)>>( + "JsonParser__getShortValue") .asFunction)>(); /// from: public short getShortValue() @@ -1797,9 +1797,9 @@ class JsonParser extends jni.JObject { } static final _getIntValue = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getIntValue") + ffi + .NativeFunction)>>( + "JsonParser__getIntValue") .asFunction)>(); /// from: public abstract int getIntValue() @@ -1824,9 +1824,9 @@ class JsonParser extends jni.JObject { } static final _getLongValue = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getLongValue") + ffi + .NativeFunction)>>( + "JsonParser__getLongValue") .asFunction)>(); /// from: public abstract long getLongValue() @@ -1851,9 +1851,9 @@ class JsonParser extends jni.JObject { } static final _getBigIntegerValue = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getBigIntegerValue") + ffi + .NativeFunction)>>( + "JsonParser__getBigIntegerValue") .asFunction)>(); /// from: public abstract java.math.BigInteger getBigIntegerValue() @@ -1876,9 +1876,9 @@ class JsonParser extends jni.JObject { } static final _getFloatValue = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getFloatValue") + ffi + .NativeFunction)>>( + "JsonParser__getFloatValue") .asFunction)>(); /// from: public abstract float getFloatValue() @@ -1903,9 +1903,9 @@ class JsonParser extends jni.JObject { } static final _getDoubleValue = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getDoubleValue") + ffi + .NativeFunction)>>( + "JsonParser__getDoubleValue") .asFunction)>(); /// from: public abstract double getDoubleValue() @@ -1930,9 +1930,9 @@ class JsonParser extends jni.JObject { } static final _getDecimalValue = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getDecimalValue") + ffi + .NativeFunction)>>( + "JsonParser__getDecimalValue") .asFunction)>(); /// from: public abstract java.math.BigDecimal getDecimalValue() @@ -1951,9 +1951,9 @@ class JsonParser extends jni.JObject { } static final _getBooleanValue = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getBooleanValue") + ffi + .NativeFunction)>>( + "JsonParser__getBooleanValue") .asFunction)>(); /// from: public boolean getBooleanValue() @@ -1974,9 +1974,9 @@ class JsonParser extends jni.JObject { } static final _getEmbeddedObject = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getEmbeddedObject") + ffi + .NativeFunction)>>( + "JsonParser__getEmbeddedObject") .asFunction)>(); /// from: public java.lang.Object getEmbeddedObject() @@ -2040,9 +2040,9 @@ class JsonParser extends jni.JObject { } static final _getBinaryValue1 = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getBinaryValue1") + ffi + .NativeFunction)>>( + "JsonParser__getBinaryValue1") .asFunction)>(); /// from: public byte[] getBinaryValue() @@ -2114,9 +2114,9 @@ class JsonParser extends jni.JObject { } static final _getValueAsInt = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getValueAsInt") + ffi + .NativeFunction)>>( + "JsonParser__getValueAsInt") .asFunction)>(); /// from: public int getValueAsInt() @@ -2166,9 +2166,9 @@ class JsonParser extends jni.JObject { } static final _getValueAsLong = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getValueAsLong") + ffi + .NativeFunction)>>( + "JsonParser__getValueAsLong") .asFunction)>(); /// from: public long getValueAsLong() @@ -2218,9 +2218,9 @@ class JsonParser extends jni.JObject { } static final _getValueAsDouble = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getValueAsDouble") + ffi + .NativeFunction)>>( + "JsonParser__getValueAsDouble") .asFunction)>(); /// from: public double getValueAsDouble() @@ -2270,9 +2270,9 @@ class JsonParser extends jni.JObject { } static final _getValueAsBoolean = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getValueAsBoolean") + ffi + .NativeFunction)>>( + "JsonParser__getValueAsBoolean") .asFunction)>(); /// from: public boolean getValueAsBoolean() @@ -2322,9 +2322,9 @@ class JsonParser extends jni.JObject { } static final _getValueAsString = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getValueAsString") + ffi + .NativeFunction)>>( + "JsonParser__getValueAsString") .asFunction)>(); /// from: public java.lang.String getValueAsString() @@ -2376,9 +2376,9 @@ class JsonParser extends jni.JObject { } static final _canReadObjectId = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__canReadObjectId") + ffi + .NativeFunction)>>( + "JsonParser__canReadObjectId") .asFunction)>(); /// from: public boolean canReadObjectId() @@ -2399,9 +2399,9 @@ class JsonParser extends jni.JObject { } static final _canReadTypeId = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__canReadTypeId") + ffi + .NativeFunction)>>( + "JsonParser__canReadTypeId") .asFunction)>(); /// from: public boolean canReadTypeId() @@ -2422,9 +2422,9 @@ class JsonParser extends jni.JObject { } static final _getObjectId = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getObjectId") + ffi + .NativeFunction)>>( + "JsonParser__getObjectId") .asFunction)>(); /// from: public java.lang.Object getObjectId() @@ -2448,9 +2448,9 @@ class JsonParser extends jni.JObject { } static final _getTypeId = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__getTypeId") + ffi + .NativeFunction)>>( + "JsonParser__getTypeId") .asFunction)>(); /// from: public java.lang.Object getTypeId() @@ -2611,9 +2611,9 @@ class JsonParser extends jni.JObject { } static final _readValueAsTree = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser__readValueAsTree") + ffi + .NativeFunction)>>( + "JsonParser__readValueAsTree") .asFunction)>(); /// from: public T readValueAsTree() @@ -2685,9 +2685,9 @@ class JsonParser_Feature extends jni.JObject { } static final _valueOf = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser_Feature__valueOf") + ffi + .NativeFunction)>>( + "JsonParser_Feature__valueOf") .asFunction)>(); /// from: static public com.fasterxml.jackson.core.JsonParser.Feature valueOf(java.lang.String name) @@ -2714,8 +2714,8 @@ class JsonParser_Feature extends jni.JObject { } static final _enabledByDefault = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "JsonParser_Feature__enabledByDefault") .asFunction)>(); @@ -2738,9 +2738,9 @@ class JsonParser_Feature extends jni.JObject { } static final _getMask = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser_Feature__getMask") + ffi + .NativeFunction)>>( + "JsonParser_Feature__getMask") .asFunction)>(); /// from: public int getMask() @@ -2802,9 +2802,9 @@ class JsonParser_NumberType extends jni.JObject { } static final _valueOf = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonParser_NumberType__valueOf") + ffi + .NativeFunction)>>( + "JsonParser_NumberType__valueOf") .asFunction)>(); /// from: static public com.fasterxml.jackson.core.JsonParser.NumberType valueOf(java.lang.String name) diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart index 14ce836aa..d5c82a594 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart @@ -65,9 +65,9 @@ class JsonToken extends jni.JObject { } static final _valueOf = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonToken__valueOf") + ffi + .NativeFunction)>>( + "JsonToken__valueOf") .asFunction)>(); /// from: static public com.fasterxml.jackson.core.JsonToken valueOf(java.lang.String name) @@ -79,8 +79,9 @@ class JsonToken extends jni.JObject { } static final _id = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>("JsonToken__id") + ffi + .NativeFunction)>>( + "JsonToken__id") .asFunction)>(); /// from: public final int id() @@ -89,9 +90,9 @@ class JsonToken extends jni.JObject { } static final _asString = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonToken__asString") + ffi + .NativeFunction)>>( + "JsonToken__asString") .asFunction)>(); /// from: public final java.lang.String asString() @@ -101,9 +102,9 @@ class JsonToken extends jni.JObject { } static final _asCharArray = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonToken__asCharArray") + ffi + .NativeFunction)>>( + "JsonToken__asCharArray") .asFunction)>(); /// from: public final char[] asCharArray() @@ -114,9 +115,9 @@ class JsonToken extends jni.JObject { } static final _asByteArray = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonToken__asByteArray") + ffi + .NativeFunction)>>( + "JsonToken__asByteArray") .asFunction)>(); /// from: public final byte[] asByteArray() @@ -127,9 +128,9 @@ class JsonToken extends jni.JObject { } static final _isNumeric = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonToken__isNumeric") + ffi + .NativeFunction)>>( + "JsonToken__isNumeric") .asFunction)>(); /// from: public final boolean isNumeric() @@ -141,9 +142,9 @@ class JsonToken extends jni.JObject { } static final _isStructStart = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonToken__isStructStart") + ffi + .NativeFunction)>>( + "JsonToken__isStructStart") .asFunction)>(); /// from: public final boolean isStructStart() @@ -160,9 +161,9 @@ class JsonToken extends jni.JObject { } static final _isStructEnd = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonToken__isStructEnd") + ffi + .NativeFunction)>>( + "JsonToken__isStructEnd") .asFunction)>(); /// from: public final boolean isStructEnd() @@ -179,9 +180,9 @@ class JsonToken extends jni.JObject { } static final _isScalarValue = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonToken__isScalarValue") + ffi + .NativeFunction)>>( + "JsonToken__isScalarValue") .asFunction)>(); /// from: public final boolean isScalarValue() @@ -197,9 +198,9 @@ class JsonToken extends jni.JObject { } static final _isBoolean = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonToken__isBoolean") + ffi + .NativeFunction)>>( + "JsonToken__isBoolean") .asFunction)>(); /// from: public final boolean isBoolean() diff --git a/pkgs/jnigen/test/kotlin_test/c_based/c_bindings/dartjni.h b/pkgs/jnigen/test/kotlin_test/c_based/c_bindings/dartjni.h index cca31f49e..0a7f66914 100644 --- a/pkgs/jnigen/test/kotlin_test/c_based/c_bindings/dartjni.h +++ b/pkgs/jnigen/test/kotlin_test/c_based/c_bindings/dartjni.h @@ -124,16 +124,6 @@ static inline void destroy_cond(ConditionVariable* cond) { #endif -static inline uint64_t thread_id() { -#ifdef _WIN32 - return GetCurrentThreadId(); -#elif defined __APPLE__ - return pthread_mach_thread_np(pthread_self()); -#else - return pthread_self(); -#endif -} - typedef struct CallbackResult { MutexLock lock; ConditionVariable cond; diff --git a/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/dartjni.h b/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/dartjni.h index cca31f49e..0a7f66914 100644 --- a/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/dartjni.h +++ b/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/dartjni.h @@ -124,16 +124,6 @@ static inline void destroy_cond(ConditionVariable* cond) { #endif -static inline uint64_t thread_id() { -#ifdef _WIN32 - return GetCurrentThreadId(); -#elif defined __APPLE__ - return pthread_mach_thread_np(pthread_self()); -#else - return pthread_self(); -#endif -} - typedef struct CallbackResult { MutexLock lock; ConditionVariable cond; diff --git a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart index 27f396211..f32e13eaa 100644 --- a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart @@ -120,9 +120,9 @@ class Example extends jni.JObject { } static final _setName = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("Example__setName") + ffi + .NativeFunction)>>( + "Example__setName") .asFunction)>(); /// from: static public void setName(java.lang.String newName) @@ -133,9 +133,9 @@ class Example extends jni.JObject { } static final _setNestedInstance = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("Example__setNestedInstance") + ffi + .NativeFunction)>>( + "Example__setNestedInstance") .asFunction)>(); /// from: static public void setNestedInstance(com.github.dart_lang.jnigen.simple_package.Example.Nested newNested) @@ -183,9 +183,9 @@ class Example extends jni.JObject { } static final _getNumber = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("Example__getNumber") + ffi + .NativeFunction)>>( + "Example__getNumber") .asFunction)>(); /// from: public int getNumber() @@ -207,9 +207,9 @@ class Example extends jni.JObject { } static final _getIsUp = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("Example__getIsUp") + ffi + .NativeFunction)>>( + "Example__getIsUp") .asFunction)>(); /// from: public boolean getIsUp() @@ -231,9 +231,9 @@ class Example extends jni.JObject { } static final _getCodename = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("Example__getCodename") + ffi + .NativeFunction)>>( + "Example__getCodename") .asFunction)>(); /// from: public java.lang.String getCodename() @@ -258,9 +258,9 @@ class Example extends jni.JObject { } static final _getRandom = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("Example__getRandom") + ffi + .NativeFunction)>>( + "Example__getRandom") .asFunction)>(); /// from: public java.util.Random getRandom() @@ -285,9 +285,9 @@ class Example extends jni.JObject { } static final _getRandomLong = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("Example__getRandomLong") + ffi + .NativeFunction)>>( + "Example__getRandomLong") .asFunction)>(); /// from: public long getRandomLong() @@ -443,9 +443,9 @@ class Example extends jni.JObject { } static final _whichExample = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("Example__whichExample") + ffi + .NativeFunction)>>( + "Example__whichExample") .asFunction)>(); /// from: public int whichExample() @@ -477,8 +477,9 @@ class Example extends jni.JObject { } static final _addAll = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>("Example__addAll") + ffi + .NativeFunction)>>( + "Example__addAll") .asFunction)>(); /// from: static public int addAll(int[] arr) @@ -489,9 +490,9 @@ class Example extends jni.JObject { } static final _getSelf = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("Example__getSelf") + ffi + .NativeFunction)>>( + "Example__getSelf") .asFunction)>(); /// from: public com.github.dart_lang.jnigen.simple_package.Example getSelf() @@ -561,8 +562,8 @@ class Example_Nested extends jni.JObject { } static final _usesAnonymousInnerClass = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "Example_Nested__usesAnonymousInnerClass") .asFunction)>(); @@ -572,9 +573,9 @@ class Example_Nested extends jni.JObject { } static final _getValue = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("Example_Nested__getValue") + ffi + .NativeFunction)>>( + "Example_Nested__getValue") .asFunction)>(); /// from: public boolean getValue() @@ -787,9 +788,9 @@ class Exceptions extends jni.JObject { } static final _objectMethod = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("Exceptions__objectMethod") + ffi + .NativeFunction)>>( + "Exceptions__objectMethod") .asFunction)>(); /// from: public java.lang.Object objectMethod() @@ -799,9 +800,9 @@ class Exceptions extends jni.JObject { } static final _intMethod = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("Exceptions__intMethod") + ffi + .NativeFunction)>>( + "Exceptions__intMethod") .asFunction)>(); /// from: public int intMethod() @@ -810,9 +811,9 @@ class Exceptions extends jni.JObject { } static final _objectArrayMethod = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("Exceptions__objectArrayMethod") + ffi + .NativeFunction)>>( + "Exceptions__objectArrayMethod") .asFunction)>(); /// from: public java.lang.Object[] objectArrayMethod() @@ -823,9 +824,9 @@ class Exceptions extends jni.JObject { } static final _intArrayMethod = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("Exceptions__intArrayMethod") + ffi + .NativeFunction)>>( + "Exceptions__intArrayMethod") .asFunction)>(); /// from: public int[] intArrayMethod() @@ -836,8 +837,8 @@ class Exceptions extends jni.JObject { } static final _throwNullPointerException = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "Exceptions__throwNullPointerException") .asFunction)>(); @@ -847,8 +848,8 @@ class Exceptions extends jni.JObject { } static final _throwFileNotFoundException = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "Exceptions__throwFileNotFoundException") .asFunction)>(); @@ -860,8 +861,8 @@ class Exceptions extends jni.JObject { } static final _throwClassCastException = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "Exceptions__throwClassCastException") .asFunction)>(); @@ -873,8 +874,8 @@ class Exceptions extends jni.JObject { } static final _throwArrayIndexException = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "Exceptions__throwArrayIndexException") .asFunction)>(); @@ -884,8 +885,8 @@ class Exceptions extends jni.JObject { } static final _throwArithmeticException = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "Exceptions__throwArithmeticException") .asFunction)>(); @@ -994,9 +995,9 @@ class Fields extends jni.JObject { .asFunction(); static final _set_name = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("set_Fields__name") + ffi + .NativeFunction)>>( + "set_Fields__name") .asFunction)>(); /// from: static public java.lang.String name @@ -1224,9 +1225,9 @@ class Fields_Nested extends jni.JObject { .asFunction(); static final _set_BEST_GOD = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("set_Fields_Nested__BEST_GOD") + ffi + .NativeFunction)>>( + "set_Fields_Nested__BEST_GOD") .asFunction)>(); /// from: static public java.lang.String BEST_GOD @@ -1360,9 +1361,9 @@ class Example1 extends jni.JObject { } static final _whichExample = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("Example1__whichExample") + ffi + .NativeFunction)>>( + "Example1__whichExample") .asFunction)>(); /// from: public int whichExample() @@ -1442,9 +1443,9 @@ class GrandParent<$T extends jni.JObject> extends jni.JObject { set value($T value) => _set_value(reference, value.reference).check(); static final _ctor = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("GrandParent__ctor") + ffi + .NativeFunction)>>( + "GrandParent__ctor") .asFunction)>(); /// from: public void (T value) @@ -1460,9 +1461,9 @@ class GrandParent<$T extends jni.JObject> extends jni.JObject { } static final _stringParent = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("GrandParent__stringParent") + ffi + .NativeFunction)>>( + "GrandParent__stringParent") .asFunction)>(); /// from: public com.github.dart_lang.jnigen.generics.GrandParent.Parent stringParent() @@ -1506,9 +1507,9 @@ class GrandParent<$T extends jni.JObject> extends jni.JObject { } static final _varStaticParent = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("GrandParent__varStaticParent") + ffi + .NativeFunction)>>( + "GrandParent__varStaticParent") .asFunction)>(); /// from: static public com.github.dart_lang.jnigen.generics.GrandParent.StaticParent varStaticParent(S value) @@ -1525,8 +1526,8 @@ class GrandParent<$T extends jni.JObject> extends jni.JObject { } static final _staticParentWithSameType = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "GrandParent__staticParentWithSameType") .asFunction)>(); @@ -1942,9 +1943,9 @@ class GrandParent_StaticParent<$S extends jni.JObject> extends jni.JObject { set value($S value) => _set_value(reference, value.reference).check(); static final _ctor = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("GrandParent_StaticParent__ctor") + ffi + .NativeFunction)>>( + "GrandParent_StaticParent__ctor") .asFunction)>(); /// from: public void (S value) @@ -2218,9 +2219,9 @@ class MyMap<$K extends jni.JObject, $V extends jni.JObject> } static final _entryStack = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("MyMap__entryStack") + ffi + .NativeFunction)>>( + "MyMap__entryStack") .asFunction)>(); /// from: public com.github.dart_lang.jnigen.generics.MyStack.MyEntry> entryStack() @@ -2445,9 +2446,9 @@ class MyStack<$T extends jni.JObject> extends jni.JObject { } static final _fromArray = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("MyStack__fromArray") + ffi + .NativeFunction)>>( + "MyStack__fromArray") .asFunction)>(); /// from: static public com.github.dart_lang.jnigen.generics.MyStack fromArray(T[] arr) @@ -2463,8 +2464,8 @@ class MyStack<$T extends jni.JObject> extends jni.JObject { } static final _fromArrayOfArrayOfGrandParents = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>( + ffi + .NativeFunction)>>( "MyStack__fromArrayOfArrayOfGrandParents") .asFunction)>(); @@ -2497,8 +2498,9 @@ class MyStack<$T extends jni.JObject> extends jni.JObject { } static final _of1 = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>("MyStack__of1") + ffi + .NativeFunction)>>( + "MyStack__of1") .asFunction)>(); /// from: static public com.github.dart_lang.jnigen.generics.MyStack of(T obj) @@ -2551,8 +2553,9 @@ class MyStack<$T extends jni.JObject> extends jni.JObject { } static final _pop = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>("MyStack__pop") + ffi + .NativeFunction)>>( + "MyStack__pop") .asFunction)>(); /// from: public T pop() @@ -2562,8 +2565,9 @@ class MyStack<$T extends jni.JObject> extends jni.JObject { } static final _size = jniLookup< - ffi.NativeFunction< - jni.JniResult Function(ffi.Pointer)>>("MyStack__size") + ffi + .NativeFunction)>>( + "MyStack__size") .asFunction)>(); /// from: public int size() @@ -3260,9 +3264,9 @@ class JsonSerializable_Case extends jni.JObject { } static final _valueOf = jniLookup< - ffi.NativeFunction< - jni.JniResult Function( - ffi.Pointer)>>("JsonSerializable_Case__valueOf") + ffi + .NativeFunction)>>( + "JsonSerializable_Case__valueOf") .asFunction)>(); /// from: static public com.github.dart_lang.jnigen.annotations.JsonSerializable.Case valueOf(java.lang.String name) From fa5ff14b6242ade15ebfd54afeb517abd1d89f96 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Thu, 17 Aug 2023 17:42:51 +0200 Subject: [PATCH 114/139] [jnigen] Check for free in reference getter (https://github.com/dart-lang/jnigen/issues/361) --- pkgs/jni/example/pubspec.lock | 2 +- pkgs/jni/example/pubspec.yaml | 2 +- pkgs/jni/lib/src/jexceptions.dart | 36 ++++++++------- pkgs/jni/lib/src/jni.dart | 2 +- pkgs/jni/lib/src/jobject.dart | 19 +------- pkgs/jni/lib/src/jreference.dart | 45 +++++++++++++------ pkgs/jni/lib/src/lang/jboolean.dart | 2 + pkgs/jni/lib/src/lang/jcharacter.dart | 2 + pkgs/jni/lib/src/lang/jnumber.dart | 7 +++ pkgs/jni/lib/src/lang/jstring.dart | 8 +--- pkgs/jni/pubspec.yaml | 2 +- pkgs/jnigen/android_test_runner/pubspec.yaml | 2 +- pkgs/jnigen/example/in_app_java/pubspec.yaml | 2 +- .../kotlin_plugin/example/pubspec.yaml | 2 +- .../jnigen/example/kotlin_plugin/pubspec.yaml | 2 +- .../notification_plugin/example/pubspec.yaml | 2 +- .../example/notification_plugin/pubspec.yaml | 2 +- .../pdfbox_plugin/dart_example/pubspec.yaml | 2 +- .../pdfbox_plugin/example/pubspec.yaml | 2 +- .../jnigen/example/pdfbox_plugin/pubspec.yaml | 2 +- .../lib/src/bindings/dart_generator.dart | 9 ++-- pkgs/jnigen/pubspec.yaml | 2 +- .../c_based/dart_bindings/simple_package.dart | 10 ++--- .../dart_bindings/simple_package.dart | 10 ++--- 24 files changed, 90 insertions(+), 86 deletions(-) diff --git a/pkgs/jni/example/pubspec.lock b/pkgs/jni/example/pubspec.lock index 0824b6e6d..eb16370f1 100644 --- a/pkgs/jni/example/pubspec.lock +++ b/pkgs/jni/example/pubspec.lock @@ -519,5 +519,5 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.1.0 <4.0.0" + dart: ">=3.1.0-262.3.beta <4.0.0" flutter: ">=2.11.0" diff --git a/pkgs/jni/example/pubspec.yaml b/pkgs/jni/example/pubspec.yaml index ce0646488..7972e84f3 100644 --- a/pkgs/jni/example/pubspec.yaml +++ b/pkgs/jni/example/pubspec.yaml @@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: '>=3.1.0 <4.0.0' + sdk: '>=3.1.0-262.3.beta <4.0.0' # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions diff --git a/pkgs/jni/lib/src/jexceptions.dart b/pkgs/jni/lib/src/jexceptions.dart index 4c9cda0c2..64b95fcd1 100644 --- a/pkgs/jni/lib/src/jexceptions.dart +++ b/pkgs/jni/lib/src/jexceptions.dart @@ -9,37 +9,38 @@ import 'package:jni/src/third_party/generated_bindings.dart'; abstract class JException implements Exception {} class UseAfterFreeException implements JException { - dynamic object; - Pointer ptr; - UseAfterFreeException(this.object, this.ptr); + final Pointer ptr; + UseAfterFreeException(this.ptr); @override String toString() { - return "use after free on $ptr through $object"; + return 'Use after free on $ptr.'; } } -class NullJStringException implements JException { +class JNullException implements JException { + const JNullException(); + @override - String toString() => 'toDartString called on null JString reference'; + String toString() => 'The reference was null.'; } class InvalidJStringException implements JException { - Pointer reference; + final Pointer reference; InvalidJStringException(this.reference); + @override String toString() => 'Not a valid Java String: ' - '0x${reference.address.toRadixString(16)}'; + '0x${reference.address.toRadixString(16)}.'; } class DoubleFreeException implements JException { - dynamic object; - Pointer ptr; - DoubleFreeException(this.object, this.ptr); + final Pointer ptr; + DoubleFreeException(this.ptr); @override String toString() { - return "double free on $ptr through $object"; + return 'Double free on $ptr.'; } } @@ -113,9 +114,10 @@ class HelperNotFoundException implements JException { final String path; @override - String toString() => "Lookup for helper library $path failed.\n" - "Please ensure that `dartjni` shared library is built.\n" - "Provided jni:setup script can be used to build the shared library." - "If the library is already built, ensure that the JVM libraries can be " - "loaded from Dart."; + String toString() => ''' +Lookup for helper library $path failed. +Please ensure that `dartjni` shared library is built. +Provided jni:setup script can be used to build the shared library. +If the library is already built, ensure that the JVM libraries can be +loaded from Dart.'''; } diff --git a/pkgs/jni/lib/src/jni.dart b/pkgs/jni/lib/src/jni.dart index d6836b028..2957105af 100644 --- a/pkgs/jni/lib/src/jni.dart +++ b/pkgs/jni/lib/src/jni.dart @@ -337,7 +337,7 @@ extension AdditionalEnvMethods on GlobalJniEnv { /// DeleteLocalRef. String toDartString(JStringPtr jstringPtr, {bool deleteOriginal = false}) { if (jstringPtr == nullptr) { - throw NullJStringException(); + throw const JNullException(); } final chars = GetStringUTFChars(jstringPtr, nullptr); if (chars == nullptr) { diff --git a/pkgs/jni/lib/src/jobject.dart b/pkgs/jni/lib/src/jobject.dart index c5e88c137..c0b077b77 100644 --- a/pkgs/jni/lib/src/jobject.dart +++ b/pkgs/jni/lib/src/jobject.dart @@ -189,7 +189,6 @@ class JObject extends JReference { /// /// This may be a subclass of compile-time class. JClass getClass() { - ensureNotDeleted(); final classRef = Jni.env.GetObjectClass(reference); if (classRef == nullptr) { Jni.accessors.throwException(Jni.env.ExceptionOccurred()); @@ -199,28 +198,24 @@ class JObject extends JReference { /// Get [JFieldIDPtr] of instance field identified by [fieldName] & [signature]. JFieldIDPtr getFieldID(String fieldName, String signature) { - ensureNotDeleted(); return _getID( Jni.accessors.getFieldID, _class.reference, fieldName, signature); } /// Get [JFieldIDPtr] of static field identified by [fieldName] & [signature]. JFieldIDPtr getStaticFieldID(String fieldName, String signature) { - ensureNotDeleted(); return _getID( Jni.accessors.getStaticFieldID, _class.reference, fieldName, signature); } /// Get [JMethodIDPtr] of instance method [methodName] with [signature]. JMethodIDPtr getMethodID(String methodName, String signature) { - ensureNotDeleted(); return _getID( Jni.accessors.getMethodID, _class.reference, methodName, signature); } /// Get [JMethodIDPtr] of static method [methodName] with [signature]. JMethodIDPtr getStaticMethodID(String methodName, String signature) { - ensureNotDeleted(); return _getID(Jni.accessors.getStaticMethodID, _class.reference, methodName, signature); } @@ -235,7 +230,6 @@ class JObject extends JReference { /// If [T] is String or [JObject], required conversions are performed and /// final value is returned. T getField(JFieldIDPtr fieldID, [int? callType]) { - ensureNotDeleted(); if (callType == JniCallType.voidType) { throw ArgumentError("void is not a valid field type."); } @@ -258,7 +252,6 @@ class JObject extends JReference { if (callType == JniCallType.voidType) { throw ArgumentError("void is not a valid field type."); } - ensureNotDeleted(); return _getField(callType, (ct) => Jni.accessors.getStaticField(_class.reference, fieldID, ct)); } @@ -278,7 +271,6 @@ class JObject extends JReference { /// /// See [getField] for an explanation about [callType] and return type [T]. T callMethod(JMethodIDPtr methodID, List args, [int? callType]) { - ensureNotDeleted(); return _callMethod(callType, args, (ct, jvs) => Jni.accessors.callMethod(reference, methodID, ct, jvs)); } @@ -296,7 +288,6 @@ class JObject extends JReference { /// more details about [args] and [callType]. T callStaticMethod(JMethodIDPtr methodID, List args, [int? callType]) { - ensureNotDeleted(); return _callMethod( callType, args, @@ -317,8 +308,9 @@ class JObject extends JReference { T castTo(JObjType type, {bool deleteOriginal = false}) { if (deleteOriginal) { _jClass?.delete(); + final ret = type.fromRef(reference); setAsDeleted(); - return type.fromRef(reference); + return ret; } final newRef = Jni.env.NewGlobalRef(reference); return type.fromRef(newRef); @@ -360,28 +352,24 @@ class JClass extends JReference { /// Get [JFieldIDPtr] of static field [fieldName] with [signature]. JFieldIDPtr getStaticFieldID(String fieldName, String signature) { - ensureNotDeleted(); return _getID( Jni.accessors.getStaticFieldID, reference, fieldName, signature); } /// Get [JMethodIDPtr] of static method [methodName] with [signature]. JMethodIDPtr getStaticMethodID(String methodName, String signature) { - ensureNotDeleted(); return _getID( Jni.accessors.getStaticMethodID, reference, methodName, signature); } /// Get [JFieldIDPtr] of field [fieldName] with [signature]. JFieldIDPtr getFieldID(String fieldName, String signature) { - ensureNotDeleted(); return _getID( Jni.accessors.getFieldID, reference, fieldName, signature); } /// Get [JMethodIDPtr] of method [methodName] with [signature]. JMethodIDPtr getMethodID(String methodName, String signature) { - ensureNotDeleted(); return _getID( Jni.accessors.getMethodID, reference, methodName, signature); } @@ -396,7 +384,6 @@ class JClass extends JReference { if (callType == JniCallType.voidType) { throw ArgumentError("void is not a valid field type."); } - ensureNotDeleted(); return _getField( callType, (ct) => Jni.accessors.getStaticField(reference, fieldID, ct)); } @@ -415,7 +402,6 @@ class JClass extends JReference { /// about [args] and [callType]. T callStaticMethod(JMethodIDPtr methodID, List args, [int? callType]) { - ensureNotDeleted(); return _callMethod( callType, args, @@ -434,7 +420,6 @@ class JClass extends JReference { /// Create a new instance of this class with [ctor] and [args]. JObject newInstance(JMethodIDPtr ctor, List args) => using((arena) { - ensureNotDeleted(); final jArgs = JValueArgs(args, arena); final res = Jni.accessors.newObject(reference, ctor, jArgs.values).object; diff --git a/pkgs/jni/lib/src/jreference.dart b/pkgs/jni/lib/src/jreference.dart index 94303363c..973b3f3a3 100644 --- a/pkgs/jni/lib/src/jreference.dart +++ b/pkgs/jni/lib/src/jreference.dart @@ -11,28 +11,37 @@ import 'jexceptions.dart'; import 'jni.dart'; extension ProtectedJReference on JReference { - void ensureNotDeleted() { - if (_deleted) throw UseAfterFreeException(this, reference); - } - void setAsDeleted() { if (_deleted) { - throw DoubleFreeException(this, reference); + throw DoubleFreeException(_reference); } _deleted = true; JReference._finalizer.detach(this); } + + void ensureNotNull() { + if (isNull) { + throw const JNullException(); + } + } + + /// Similar to [reference]. + /// + /// Detaches the finalizer so the underlying pointer will not be deleted. + JObjectPtr toPointer() { + setAsDeleted(); + return _reference; + } } /// A class which holds one or more JNI references, and has a `delete` operation /// which disposes the reference(s). abstract class JReference implements Finalizable { - //TODO(PR): Is it safe to cast void *f (void *) to void f (void *)? static final _finalizer = NativeFinalizer(Jni.env.ptr.ref.DeleteGlobalRef.cast()); - JReference.fromRef(this.reference) { - _finalizer.attach(this, reference, detach: this); + JReference.fromRef(this._reference) { + _finalizer.attach(this, _reference, detach: this); } bool _deleted = false; @@ -43,15 +52,26 @@ abstract class JReference implements Finalizable { /// Returns whether this object is deleted. bool get isDeleted => _deleted; - /// Deletes the underlying JNI reference. Further uses will throw - /// [UseAfterFreeException]. + /// Deletes the underlying JNI reference. + /// + /// Further uses will throw [UseAfterFreeException]. void delete() { setAsDeleted(); - Jni.env.DeleteGlobalRef(reference); + Jni.env.DeleteGlobalRef(_reference); } /// The underlying JNI global object reference. - final JObjectPtr reference; + /// + /// Throws [UseAfterFreeException] if the object is previously deleted. + /// + /// Be careful when storing this reference in a variable, since the underlying + /// object might get deleted. + JObjectPtr get reference { + if (_deleted) throw UseAfterFreeException(_reference); + return _reference; + } + + final JObjectPtr _reference; /// Registers this object to be deleted at the end of [arena]'s lifetime. void deletedIn(Arena arena) => arena.onReleaseAll(delete); @@ -61,7 +81,6 @@ extension JReferenceUseExtension on T { /// Applies [callback] on [this] object and then delete the underlying JNI /// reference, returning the result of [callback]. R use(R Function(T) callback) { - ensureNotDeleted(); try { final result = callback(this); delete(); diff --git a/pkgs/jni/lib/src/lang/jboolean.dart b/pkgs/jni/lib/src/lang/jboolean.dart index 03d5304e9..04f4e7cf3 100644 --- a/pkgs/jni/lib/src/lang/jboolean.dart +++ b/pkgs/jni/lib/src/lang/jboolean.dart @@ -4,6 +4,7 @@ import '../accessors.dart'; import '../jobject.dart'; +import '../jreference.dart'; import '../jni.dart'; import '../third_party/generated_bindings.dart'; import '../types.dart'; @@ -56,6 +57,7 @@ class JBoolean extends JObject { Jni.accessors.getMethodIDOf(_class.reference, r"booleanValue", r"()Z"); bool booleanValue({bool deleteOriginal = false}) { + ensureNotNull(); final ret = Jni.accessors.callMethodWithArgs( reference, _booleanValueId, JniCallType.booleanType, []).boolean; if (deleteOriginal) { diff --git a/pkgs/jni/lib/src/lang/jcharacter.dart b/pkgs/jni/lib/src/lang/jcharacter.dart index 6ab76cf7a..067870663 100644 --- a/pkgs/jni/lib/src/lang/jcharacter.dart +++ b/pkgs/jni/lib/src/lang/jcharacter.dart @@ -1,6 +1,7 @@ import '../accessors.dart'; import '../jni.dart'; import '../jobject.dart'; +import '../jreference.dart'; import '../jvalues.dart'; import '../third_party/generated_bindings.dart'; import '../types.dart'; @@ -54,6 +55,7 @@ class JCharacter extends JObject { Jni.accessors.getMethodIDOf(_class.reference, r"charValue", r"()C"); int charValue({bool deleteOriginal = false}) { + ensureNotNull(); final ret = Jni.accessors.callMethodWithArgs( reference, _charValueId, JniCallType.charType, []).char; if (deleteOriginal) { diff --git a/pkgs/jni/lib/src/lang/jnumber.dart b/pkgs/jni/lib/src/lang/jnumber.dart index cab303322..a46814733 100644 --- a/pkgs/jni/lib/src/lang/jnumber.dart +++ b/pkgs/jni/lib/src/lang/jnumber.dart @@ -5,6 +5,7 @@ import '../accessors.dart'; import '../jni.dart'; import '../jobject.dart'; +import '../jreference.dart'; import '../third_party/generated_bindings.dart'; import '../types.dart'; import 'jboolean.dart'; @@ -64,6 +65,7 @@ class JNumber extends JObject { Jni.accessors.getMethodIDOf(_class.reference, r"intValue", r"()I"); int intValue({bool deleteOriginal = false}) { + ensureNotNull(); final ret = Jni.accessors.callMethodWithArgs( reference, _intValueId, JniCallType.intType, []).integer; if (deleteOriginal) { @@ -76,6 +78,7 @@ class JNumber extends JObject { Jni.accessors.getMethodIDOf(_class.reference, r"longValue", r"()J"); int longValue({bool deleteOriginal = false}) { + ensureNotNull(); final ret = Jni.accessors.callMethodWithArgs( reference, _longValueId, JniCallType.longType, []).long; if (deleteOriginal) { @@ -88,6 +91,7 @@ class JNumber extends JObject { Jni.accessors.getMethodIDOf(_class.reference, r"floatValue", r"()F"); double floatValue({bool deleteOriginal = false}) { + ensureNotNull(); final ret = Jni.accessors.callMethodWithArgs( reference, _floatValueId, JniCallType.floatType, []).float; if (deleteOriginal) { @@ -100,6 +104,7 @@ class JNumber extends JObject { Jni.accessors.getMethodIDOf(_class.reference, r"doubleValue", r"()D"); double doubleValue({bool deleteOriginal = false}) { + ensureNotNull(); final ret = Jni.accessors.callMethodWithArgs( reference, _doubleValueId, JniCallType.doubleType, []).doubleFloat; if (deleteOriginal) { @@ -112,6 +117,7 @@ class JNumber extends JObject { Jni.accessors.getMethodIDOf(_class.reference, r"byteValue", r"()B"); int byteValue({bool deleteOriginal = false}) { + ensureNotNull(); final ret = Jni.accessors.callMethodWithArgs( reference, _byteValueId, JniCallType.byteType, []).byte; if (deleteOriginal) { @@ -124,6 +130,7 @@ class JNumber extends JObject { Jni.accessors.getMethodIDOf(_class.reference, r"shortValue", r"()S"); int shortValue({bool deleteOriginal = false}) { + ensureNotNull(); final ret = Jni.accessors.callMethodWithArgs( reference, _shortValueId, JniCallType.shortType, []).short; if (deleteOriginal) { diff --git a/pkgs/jni/lib/src/lang/jstring.dart b/pkgs/jni/lib/src/lang/jstring.dart index fff169c7a..5bfcce5c4 100644 --- a/pkgs/jni/lib/src/lang/jstring.dart +++ b/pkgs/jni/lib/src/lang/jstring.dart @@ -5,11 +5,10 @@ import 'dart:ffi'; import 'package:ffi/ffi.dart'; +import 'package:jni/src/jreference.dart'; -import '../jexceptions.dart'; import '../jni.dart'; import '../jobject.dart'; -import '../jreference.dart'; import '../third_party/generated_bindings.dart'; import '../types.dart'; @@ -68,10 +67,7 @@ class JString extends JObject { /// If [deleteOriginal] is true, the underlying reference is deleted /// after conversion and this object will be marked as deleted. String toDartString({bool deleteOriginal = false}) { - ensureNotDeleted(); - if (reference == nullptr) { - throw NullJStringException(); - } + ensureNotNull(); final length = Jni.env.GetStringLength(reference); final chars = Jni.env.GetStringChars(reference, nullptr); final result = chars.cast().toDartString(length: length); diff --git a/pkgs/jni/pubspec.yaml b/pkgs/jni/pubspec.yaml index d4a8da9ab..2808b3cbd 100644 --- a/pkgs/jni/pubspec.yaml +++ b/pkgs/jni/pubspec.yaml @@ -8,7 +8,7 @@ version: 0.6.0-wip.2 repository: https://github.com/dart-lang/jnigen/tree/main/jni environment: - sdk: '>=3.1.0 <4.0.0' + sdk: '>=3.1.0-262.3.beta <4.0.0' flutter: '>=2.11.0' dependencies: diff --git a/pkgs/jnigen/android_test_runner/pubspec.yaml b/pkgs/jnigen/android_test_runner/pubspec.yaml index fccc86e48..87e47951e 100644 --- a/pkgs/jnigen/android_test_runner/pubspec.yaml +++ b/pkgs/jnigen/android_test_runner/pubspec.yaml @@ -19,7 +19,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: '>=3.1.0 <4.0.0' + sdk: '>=3.1.0-262.3.beta <4.0.0' # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions diff --git a/pkgs/jnigen/example/in_app_java/pubspec.yaml b/pkgs/jnigen/example/in_app_java/pubspec.yaml index 2d97acf42..f99aa5d5c 100644 --- a/pkgs/jnigen/example/in_app_java/pubspec.yaml +++ b/pkgs/jnigen/example/in_app_java/pubspec.yaml @@ -8,7 +8,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: ">=3.1.0 <4.0.0" + sdk: '>=3.1.0-262.3.beta <4.0.0' dependencies: flutter: diff --git a/pkgs/jnigen/example/kotlin_plugin/example/pubspec.yaml b/pkgs/jnigen/example/kotlin_plugin/example/pubspec.yaml index 0f6224e7c..53ef1e322 100644 --- a/pkgs/jnigen/example/kotlin_plugin/example/pubspec.yaml +++ b/pkgs/jnigen/example/kotlin_plugin/example/pubspec.yaml @@ -6,7 +6,7 @@ publish_to: "none" version: 1.0.0+1 environment: - sdk: ">=3.1.0 <4.0.0" + sdk: '>=3.1.0-262.3.beta <4.0.0' dependencies: flutter: diff --git a/pkgs/jnigen/example/kotlin_plugin/pubspec.yaml b/pkgs/jnigen/example/kotlin_plugin/pubspec.yaml index fd89ad6cc..4396ff595 100644 --- a/pkgs/jnigen/example/kotlin_plugin/pubspec.yaml +++ b/pkgs/jnigen/example/kotlin_plugin/pubspec.yaml @@ -8,7 +8,7 @@ version: 0.0.1 publish_to: none environment: - sdk: '>=3.1.0 <4.0.0' + sdk: '>=3.1.0-262.3.beta <4.0.0' flutter: ">=1.17.0" dependencies: diff --git a/pkgs/jnigen/example/notification_plugin/example/pubspec.yaml b/pkgs/jnigen/example/notification_plugin/example/pubspec.yaml index 35f3357f1..10478f0e3 100644 --- a/pkgs/jnigen/example/notification_plugin/example/pubspec.yaml +++ b/pkgs/jnigen/example/notification_plugin/example/pubspec.yaml @@ -20,7 +20,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: '>=3.1.0 <4.0.0' + sdk: '>=3.1.0-262.3.beta <4.0.0' dependencies: flutter: diff --git a/pkgs/jnigen/example/notification_plugin/pubspec.yaml b/pkgs/jnigen/example/notification_plugin/pubspec.yaml index 1f6cf4925..a0e0a6af5 100644 --- a/pkgs/jnigen/example/notification_plugin/pubspec.yaml +++ b/pkgs/jnigen/example/notification_plugin/pubspec.yaml @@ -5,7 +5,7 @@ publish_to: none homepage: https://github.com/dart-lang/jnigen environment: - sdk: '>=3.1.0 <4.0.0' + sdk: '>=3.1.0-262.3.beta <4.0.0' flutter: ">=2.11.0" dependencies: diff --git a/pkgs/jnigen/example/pdfbox_plugin/dart_example/pubspec.yaml b/pkgs/jnigen/example/pdfbox_plugin/dart_example/pubspec.yaml index 4af3cf1fd..8b8a4ef39 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/dart_example/pubspec.yaml +++ b/pkgs/jnigen/example/pdfbox_plugin/dart_example/pubspec.yaml @@ -5,7 +5,7 @@ publish_to: none # homepage: https://www.example.com environment: - sdk: '>=3.1.0 <4.0.0' + sdk: '>=3.1.0-262.3.beta <4.0.0' dependencies: path: ^1.8.0 diff --git a/pkgs/jnigen/example/pdfbox_plugin/example/pubspec.yaml b/pkgs/jnigen/example/pdfbox_plugin/example/pubspec.yaml index af0ea2d28..47993e6ba 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/example/pubspec.yaml +++ b/pkgs/jnigen/example/pdfbox_plugin/example/pubspec.yaml @@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: ">=3.1.0 <4.0.0" + sdk: '>=3.1.0-262.3.beta <4.0.0' # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions diff --git a/pkgs/jnigen/example/pdfbox_plugin/pubspec.yaml b/pkgs/jnigen/example/pdfbox_plugin/pubspec.yaml index fc9c7399f..c6bb9208b 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/pubspec.yaml +++ b/pkgs/jnigen/example/pdfbox_plugin/pubspec.yaml @@ -6,7 +6,7 @@ publish_to: none homepage: https://github.com/dart-lang/jnigen environment: - sdk: ">=3.1.0 <4.0.0" + sdk: '>=3.1.0-262.3.beta <4.0.0' #flutter: ">=2.11.0" dependencies: diff --git a/pkgs/jnigen/lib/src/bindings/dart_generator.dart b/pkgs/jnigen/lib/src/bindings/dart_generator.dart index ab710f626..7f734accc 100644 --- a/pkgs/jnigen/lib/src/bindings/dart_generator.dart +++ b/pkgs/jnigen/lib/src/bindings/dart_generator.dart @@ -1703,10 +1703,10 @@ class _InterfaceParamCast extends Visitor { /// garbage collect it via [NativeFinalizer] thus making it invalid. /// This passes the ownership to Java using [setAsDeleted]. /// -/// `..setAsDeleted` detaches the object from the [NativeFinalizer] and Java +/// `toPointer` detaches the object from the [NativeFinalizer] and Java /// will clean up the global reference afterwards. /// -/// For example `($r.toJInteger()..setAsDeleted()).reference` when the return +/// For example `$r.toJInteger().toPointer()` when the return /// type is `integer`. class _InterfaceReturnBox extends TypeVisitor { const _InterfaceReturnBox(); @@ -1716,8 +1716,7 @@ class _InterfaceReturnBox extends TypeVisitor { // Casting is done to create a new global reference. The user might // use the original reference elsewhere and so the original object // should not be [setAsDeleted]. - return '((\$r as $_jObject).castTo(const ${_jObject}Type())' - '..setAsDeleted()).reference'; + return '(\$r as $_jObject).castTo(const ${_jObject}Type()).toPointer()'; } @override @@ -1725,6 +1724,6 @@ class _InterfaceReturnBox extends TypeVisitor { if (node.name == 'void') { return '$_jni.nullptr'; } - return '($_jni.J${node.boxedName}(\$r)..setAsDeleted()).reference'; + return '$_jni.J${node.boxedName}(\$r).toPointer()'; } } diff --git a/pkgs/jnigen/pubspec.yaml b/pkgs/jnigen/pubspec.yaml index 0bc676466..31019dd0f 100644 --- a/pkgs/jnigen/pubspec.yaml +++ b/pkgs/jnigen/pubspec.yaml @@ -8,7 +8,7 @@ description: Experimental generator for FFI+JNI bindings. repository: https://github.com/dart-lang/jnigen/tree/main/jnigen environment: - sdk: '>=3.1.0 <4.0.0' + sdk: '>=3.1.0-262.3.beta <4.0.0' dependencies: json_annotation: ^4.8.0 diff --git a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart index f32e13eaa..cbc1b2132 100644 --- a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart @@ -2978,17 +2978,13 @@ class MyInterface<$T extends jni.JObject> extends jni.JObject { final $r = _$impls[$p]!.stringCallback( $a[0].castTo(const jni.JStringType(), deleteOriginal: true), ); - return (($r as jni.JObject).castTo(const jni.JObjectType()) - ..setAsDeleted()) - .reference; + return ($r as jni.JObject).castTo(const jni.JObjectType()).toPointer(); } if ($d == r"varCallback(Ljava/lang/Object;)Ljava/lang/Object;") { final $r = _$impls[$p]!.varCallback( $a[0].castTo(_$impls[$p]!.T, deleteOriginal: true), ); - return (($r as jni.JObject).castTo(const jni.JObjectType()) - ..setAsDeleted()) - .reference; + return ($r as jni.JObject).castTo(const jni.JObjectType()).toPointer(); } if ($d == r"manyPrimitives(IZCD)J") { final $r = _$impls[$p]!.manyPrimitives( @@ -3005,7 +3001,7 @@ class MyInterface<$T extends jni.JObject> extends jni.JObject { .castTo(const jni.JDoubleType(), deleteOriginal: true) .doubleValue(deleteOriginal: true), ); - return (jni.JLong($r)..setAsDeleted()).reference; + return jni.JLong($r).toPointer(); } return jni.nullptr; } diff --git a/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart index 9d016f7fe..bfe2a16f0 100644 --- a/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart @@ -2813,17 +2813,13 @@ class MyInterface<$T extends jni.JObject> extends jni.JObject { final $r = _$impls[$p]!.stringCallback( $a[0].castTo(const jni.JStringType(), deleteOriginal: true), ); - return (($r as jni.JObject).castTo(const jni.JObjectType()) - ..setAsDeleted()) - .reference; + return ($r as jni.JObject).castTo(const jni.JObjectType()).toPointer(); } if ($d == r"varCallback(Ljava/lang/Object;)Ljava/lang/Object;") { final $r = _$impls[$p]!.varCallback( $a[0].castTo(_$impls[$p]!.T, deleteOriginal: true), ); - return (($r as jni.JObject).castTo(const jni.JObjectType()) - ..setAsDeleted()) - .reference; + return ($r as jni.JObject).castTo(const jni.JObjectType()).toPointer(); } if ($d == r"manyPrimitives(IZCD)J") { final $r = _$impls[$p]!.manyPrimitives( @@ -2840,7 +2836,7 @@ class MyInterface<$T extends jni.JObject> extends jni.JObject { .castTo(const jni.JDoubleType(), deleteOriginal: true) .doubleValue(deleteOriginal: true), ); - return (jni.JLong($r)..setAsDeleted()).reference; + return jni.JLong($r).toPointer(); } return jni.nullptr; } From 204d869509c7b9c58ec012f9c63f15d61c337b47 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Fri, 18 Aug 2023 11:56:29 +0200 Subject: [PATCH 115/139] [jnigen] Rename ctor to new (https://github.com/dart-lang/jnigen/issues/362) --- pkgs/jnigen/CHANGELOG.md | 5 +- .../in_app_java/lib/android_utils.dart | 96 +++--- pkgs/jnigen/example/in_app_java/lib/main.dart | 2 +- .../src/android_utils/android_utils.c | 150 ++++----- .../kotlin_plugin/lib/kotlin_bindings.dart | 6 +- .../src/kotlin_plugin_bindings.c | 10 +- .../lib/notifications.dart | 6 +- .../src/notification_plugin.c | 10 +- .../org/apache/pdfbox/pdmodel/PDDocument.dart | 38 +-- .../pdfbox/pdmodel/PDDocumentInformation.dart | 14 +- .../apache/pdfbox/text/PDFTextStripper.dart | 6 +- .../src/third_party/pdfbox_plugin.c | 80 ++--- .../lib/src/bindings/dart_generator.dart | 2 +- pkgs/jnigen/lib/src/bindings/renamer.dart | 2 +- pkgs/jnigen/pubspec.yaml | 2 +- .../c_based/c_bindings/jackson_core.c | 70 ++-- .../fasterxml/jackson/core/JsonFactory.dart | 38 +-- .../fasterxml/jackson/core/JsonParser.dart | 14 +- .../fasterxml/jackson/core/JsonFactory.dart | 28 +- .../fasterxml/jackson/core/JsonParser.dart | 10 +- .../kotlin_test/c_based/c_bindings/kotlin.c | 10 +- .../c_based/dart_bindings/kotlin.dart | 6 +- .../dart_only/dart_bindings/kotlin.dart | 4 +- .../c_based/c_bindings/simple_package.c | 306 +++++++++--------- .../c_based/dart_bindings/simple_package.dart | 189 ++++++----- .../dart_bindings/simple_package.dart | 124 +++---- .../runtime_test_registrant.dart | 24 +- 27 files changed, 624 insertions(+), 628 deletions(-) diff --git a/pkgs/jnigen/CHANGELOG.md b/pkgs/jnigen/CHANGELOG.md index 8d2086e44..357435d1b 100644 --- a/pkgs/jnigen/CHANGELOG.md +++ b/pkgs/jnigen/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.6.0-wip.3 +* **Breaking Change** ([#354](https://github.com/dart-lang/jnigen/issues/354)): Renamed constructors from `ctor1`, `ctor2`, ... to `new1`, `new2`, ... + ## 0.6.0-wip.2 * Fixed a bug where the nested classes would be generated incorrectly depending on the backend used for generation. * Fixed a bug where ASM backend would produce the incorrect parent for multi-level nested classes. @@ -6,7 +9,7 @@ * Created an experiment called `interface_implementation` which creates a `.implement` method for interfaces, so you can implement them using Dart. ## 0.6.0-wip.1 -* **Breaking Change** Specifying a class always pulls in nested classes by default. If a nested class is specified in config, it will be an error. +* **Breaking Change**: Specifying a class always pulls in nested classes by default. If a nested class is specified in config, it will be an error. * Save all `jnigen` logs to a file in `.dart_tool/jnigen/logs/`. This is useful for debugging. ## 0.6.0-wip.0 diff --git a/pkgs/jnigen/example/in_app_java/lib/android_utils.dart b/pkgs/jnigen/example/in_app_java/lib/android_utils.dart index c4a8f0456..024059de2 100644 --- a/pkgs/jnigen/example/in_app_java/lib/android_utils.dart +++ b/pkgs/jnigen/example/in_app_java/lib/android_utils.dart @@ -1065,10 +1065,10 @@ class EmojiCompat_Config extends jni.JObject { /// The type which includes information such as the signature of this class. static const type = $EmojiCompat_ConfigType(); - static final _ctor = jniLookup< + static final _new0 = jniLookup< ffi .NativeFunction)>>( - "EmojiCompat_Config__ctor") + "EmojiCompat_Config__new0") .asFunction)>(); /// from: protected void (androidx.emoji2.text.EmojiCompat.MetadataRepoLoader metadataLoader) @@ -1079,7 +1079,7 @@ class EmojiCompat_Config extends jni.JObject { factory EmojiCompat_Config( EmojiCompat_MetadataRepoLoader metadataLoader, ) { - return EmojiCompat_Config.fromRef(_ctor(metadataLoader.reference).object); + return EmojiCompat_Config.fromRef(_new0(metadataLoader.reference).object); } static final _registerInitCallback = jniLookup< @@ -1400,14 +1400,14 @@ class EmojiCompat_MetadataRepoLoaderCallback extends jni.JObject { /// The type which includes information such as the signature of this class. static const type = $EmojiCompat_MetadataRepoLoaderCallbackType(); - static final _ctor = jniLookup>( - "EmojiCompat_MetadataRepoLoaderCallback__ctor") + static final _new0 = jniLookup>( + "EmojiCompat_MetadataRepoLoaderCallback__new0") .asFunction(); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory EmojiCompat_MetadataRepoLoaderCallback() { - return EmojiCompat_MetadataRepoLoaderCallback.fromRef(_ctor().object); + return EmojiCompat_MetadataRepoLoaderCallback.fromRef(_new0().object); } static final _onLoaded = jniLookup< @@ -1653,14 +1653,14 @@ class EmojiCompat_InitCallback extends jni.JObject { /// The type which includes information such as the signature of this class. static const type = $EmojiCompat_InitCallbackType(); - static final _ctor = jniLookup>( - "EmojiCompat_InitCallback__ctor") + static final _new0 = jniLookup>( + "EmojiCompat_InitCallback__new0") .asFunction(); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory EmojiCompat_InitCallback() { - return EmojiCompat_InitCallback.fromRef(_ctor().object); + return EmojiCompat_InitCallback.fromRef(_new0().object); } static final _onInitialized = jniLookup< @@ -1736,14 +1736,14 @@ class EmojiCompat_DefaultSpanFactory extends jni.JObject { /// The type which includes information such as the signature of this class. static const type = $EmojiCompat_DefaultSpanFactoryType(); - static final _ctor = jniLookup>( - "EmojiCompat_DefaultSpanFactory__ctor") + static final _new0 = jniLookup>( + "EmojiCompat_DefaultSpanFactory__new0") .asFunction(); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory EmojiCompat_DefaultSpanFactory() { - return EmojiCompat_DefaultSpanFactory.fromRef(_ctor().object); + return EmojiCompat_DefaultSpanFactory.fromRef(_new0().object); } static final _createSpan = jniLookup< @@ -1983,15 +1983,15 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28 /// The type which includes information such as the signature of this class. static const type = $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28Type(); - static final _ctor = jniLookup>( - "DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__ctor") + static final _new0 = jniLookup>( + "DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__new0") .asFunction(); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28() { return DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28 - .fromRef(_ctor().object); + .fromRef(_new0().object); } static final _getSigningSignatures1 = jniLookup< @@ -2070,15 +2070,15 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19 /// The type which includes information such as the signature of this class. static const type = $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19Type(); - static final _ctor = jniLookup>( - "DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__ctor") + static final _new0 = jniLookup>( + "DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__new0") .asFunction(); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19() { return DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19 - .fromRef(_ctor().object); + .fromRef(_new0().object); } static final _queryIntentContentProviders = jniLookup< @@ -2179,15 +2179,15 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper /// The type which includes information such as the signature of this class. static const type = $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelperType(); - static final _ctor = jniLookup>( - "DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__ctor") + static final _new0 = jniLookup>( + "DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__new0") .asFunction(); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper() { return DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper.fromRef( - _ctor().object); + _new0().object); } static final _getSigningSignatures = jniLookup< @@ -2313,10 +2313,10 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory /// The type which includes information such as the signature of this class. static const type = $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactoryType(); - static final _ctor = jniLookup< + static final _new0 = jniLookup< ffi .NativeFunction)>>( - "DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__ctor") + "DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__new0") .asFunction)>(); /// from: public void (androidx.emoji2.text.DefaultEmojiCompatConfig.DefaultEmojiCompatConfigHelper helper) @@ -2327,7 +2327,7 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper helper, ) { return DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory.fromRef( - _ctor(helper.reference).object); + _new0(helper.reference).object); } static final _create = jniLookup< @@ -2601,14 +2601,14 @@ class Build_VERSION extends jni.JObject { static jni.JString get SECURITY_PATCH => const jni.JStringType().fromRef(_get_SECURITY_PATCH().object); - static final _ctor = jniLookup>( - "Build_VERSION__ctor") + static final _new0 = jniLookup>( + "Build_VERSION__new0") .asFunction(); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory Build_VERSION() { - return Build_VERSION.fromRef(_ctor().object); + return Build_VERSION.fromRef(_new0().object); } } @@ -2751,14 +2751,14 @@ class Build_VERSION_CODES extends jni.JObject { /// from: static public final int TIRAMISU static const TIRAMISU = 33; - static final _ctor = jniLookup>( - "Build_VERSION_CODES__ctor") + static final _new0 = jniLookup>( + "Build_VERSION_CODES__new0") .asFunction(); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory Build_VERSION_CODES() { - return Build_VERSION_CODES.fromRef(_ctor().object); + return Build_VERSION_CODES.fromRef(_new0().object); } } @@ -3066,14 +3066,14 @@ class Build extends jni.JObject { static jni.JString get USER => const jni.JStringType().fromRef(_get_USER().object); - static final _ctor = - jniLookup>("Build__ctor") + static final _new0 = + jniLookup>("Build__new0") .asFunction(); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory Build() { - return Build.fromRef(_ctor().object); + return Build.fromRef(_new0().object); } static final _getSerial = @@ -3162,9 +3162,9 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> ); } - static final _ctor = jniLookup< + static final _new0 = jniLookup< ffi.NativeFunction>( - "HashMap__ctor") + "HashMap__new0") .asFunction(); /// from: public void (int i, float f) @@ -3175,46 +3175,46 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> required jni.JObjType<$K> K, required jni.JObjType<$V> V, }) { - return HashMap.fromRef(K, V, _ctor(i, f).object); + return HashMap.fromRef(K, V, _new0(i, f).object); } - static final _ctor1 = + static final _new1 = jniLookup>( - "HashMap__ctor1") + "HashMap__new1") .asFunction(); /// from: public void (int i) /// The returned object must be deleted after use, by calling the `delete` method. - factory HashMap.ctor1( + factory HashMap.new1( int i, { required jni.JObjType<$K> K, required jni.JObjType<$V> V, }) { - return HashMap.fromRef(K, V, _ctor1(i).object); + return HashMap.fromRef(K, V, _new1(i).object); } - static final _ctor2 = - jniLookup>("HashMap__ctor2") + static final _new2 = + jniLookup>("HashMap__new2") .asFunction(); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. - factory HashMap.ctor2({ + factory HashMap.new2({ required jni.JObjType<$K> K, required jni.JObjType<$V> V, }) { - return HashMap.fromRef(K, V, _ctor2().object); + return HashMap.fromRef(K, V, _new2().object); } - static final _ctor3 = jniLookup< + static final _new3 = jniLookup< ffi .NativeFunction)>>( - "HashMap__ctor3") + "HashMap__new3") .asFunction)>(); /// from: public void (java.util.Map map) /// The returned object must be deleted after use, by calling the `delete` method. - factory HashMap.ctor3( + factory HashMap.new3( jni.JMap<$K, $V> map, { jni.JObjType<$K>? K, jni.JObjType<$V>? V, @@ -3225,7 +3225,7 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> V ??= jni.lowestCommonSuperType([ (map.$type as jni.JMapType).V, ]) as jni.JObjType<$V>; - return HashMap.fromRef(K, V, _ctor3(map.reference).object); + return HashMap.fromRef(K, V, _new3(map.reference).object); } static final _size = jniLookup< diff --git a/pkgs/jnigen/example/in_app_java/lib/main.dart b/pkgs/jnigen/example/in_app_java/lib/main.dart index 7765b9c1a..22575817b 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.dart'; JObject activity = JObject.fromRef(Jni.getCurrentActivity()); JObject context = JObject.fromRef(Jni.getCachedApplicationContext()); -final hashmap = HashMap.ctor2(K: JString.type, V: JString.type); +final hashmap = HashMap.new2(K: JString.type, V: JString.type); final emojiCompat = EmojiCompat.get0(); diff --git a/pkgs/jnigen/example/in_app_java/src/android_utils/android_utils.c b/pkgs/jnigen/example/in_app_java/src/android_utils/android_utils.c index a6e491c9d..983838bc9 100644 --- a/pkgs/jnigen/example/in_app_java/src/android_utils/android_utils.c +++ b/pkgs/jnigen/example/in_app_java/src/android_utils/android_utils.c @@ -520,21 +520,21 @@ JniResult EmojiCompat__updateEditorInfo(jobject self_, jobject outAttrs) { // androidx.emoji2.text.EmojiCompat$Config jclass _c_EmojiCompat_Config = NULL; -jmethodID _m_EmojiCompat_Config__ctor = NULL; +jmethodID _m_EmojiCompat_Config__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult EmojiCompat_Config__ctor(jobject metadataLoader) { +JniResult EmojiCompat_Config__new0(jobject metadataLoader) { load_env(); load_class_global_ref(&_c_EmojiCompat_Config, "androidx/emoji2/text/EmojiCompat$Config"); if (_c_EmojiCompat_Config == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_EmojiCompat_Config, &_m_EmojiCompat_Config__ctor, "", + load_method(_c_EmojiCompat_Config, &_m_EmojiCompat_Config__new0, "", "(Landroidx/emoji2/text/EmojiCompat$MetadataRepoLoader;)V"); - if (_m_EmojiCompat_Config__ctor == NULL) + if (_m_EmojiCompat_Config__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_EmojiCompat_Config, - _m_EmojiCompat_Config__ctor, metadataLoader); + _m_EmojiCompat_Config__new0, metadataLoader); return to_global_ref_result(_result); } @@ -766,9 +766,9 @@ JniResult EmojiCompat_Config__getMetadataRepoLoader(jobject self_) { // androidx.emoji2.text.EmojiCompat$MetadataRepoLoaderCallback jclass _c_EmojiCompat_MetadataRepoLoaderCallback = NULL; -jmethodID _m_EmojiCompat_MetadataRepoLoaderCallback__ctor = NULL; +jmethodID _m_EmojiCompat_MetadataRepoLoaderCallback__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult EmojiCompat_MetadataRepoLoaderCallback__ctor() { +JniResult EmojiCompat_MetadataRepoLoaderCallback__new0() { load_env(); load_class_global_ref( &_c_EmojiCompat_MetadataRepoLoaderCallback, @@ -776,13 +776,13 @@ JniResult EmojiCompat_MetadataRepoLoaderCallback__ctor() { if (_c_EmojiCompat_MetadataRepoLoaderCallback == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat_MetadataRepoLoaderCallback, - &_m_EmojiCompat_MetadataRepoLoaderCallback__ctor, "", + &_m_EmojiCompat_MetadataRepoLoaderCallback__new0, "", "()V"); - if (_m_EmojiCompat_MetadataRepoLoaderCallback__ctor == NULL) + if (_m_EmojiCompat_MetadataRepoLoaderCallback__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_EmojiCompat_MetadataRepoLoaderCallback, - _m_EmojiCompat_MetadataRepoLoaderCallback__ctor); + _m_EmojiCompat_MetadataRepoLoaderCallback__new0); return to_global_ref_result(_result); } @@ -881,20 +881,20 @@ JniResult EmojiCompat_MetadataRepoLoader__load(jobject self_, // androidx.emoji2.text.EmojiCompat$InitCallback jclass _c_EmojiCompat_InitCallback = NULL; -jmethodID _m_EmojiCompat_InitCallback__ctor = NULL; +jmethodID _m_EmojiCompat_InitCallback__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult EmojiCompat_InitCallback__ctor() { +JniResult EmojiCompat_InitCallback__new0() { load_env(); load_class_global_ref(&_c_EmojiCompat_InitCallback, "androidx/emoji2/text/EmojiCompat$InitCallback"); if (_c_EmojiCompat_InitCallback == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_EmojiCompat_InitCallback, &_m_EmojiCompat_InitCallback__ctor, + load_method(_c_EmojiCompat_InitCallback, &_m_EmojiCompat_InitCallback__new0, "", "()V"); - if (_m_EmojiCompat_InitCallback__ctor == NULL) + if (_m_EmojiCompat_InitCallback__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_EmojiCompat_InitCallback, - _m_EmojiCompat_InitCallback__ctor); + _m_EmojiCompat_InitCallback__new0); return to_global_ref_result(_result); } @@ -937,21 +937,21 @@ JniResult EmojiCompat_InitCallback__onFailed(jobject self_, jobject throwable) { // androidx.emoji2.text.EmojiCompat$DefaultSpanFactory jclass _c_EmojiCompat_DefaultSpanFactory = NULL; -jmethodID _m_EmojiCompat_DefaultSpanFactory__ctor = NULL; +jmethodID _m_EmojiCompat_DefaultSpanFactory__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult EmojiCompat_DefaultSpanFactory__ctor() { +JniResult EmojiCompat_DefaultSpanFactory__new0() { load_env(); load_class_global_ref(&_c_EmojiCompat_DefaultSpanFactory, "androidx/emoji2/text/EmojiCompat$DefaultSpanFactory"); if (_c_EmojiCompat_DefaultSpanFactory == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_EmojiCompat_DefaultSpanFactory, - &_m_EmojiCompat_DefaultSpanFactory__ctor, "", "()V"); - if (_m_EmojiCompat_DefaultSpanFactory__ctor == NULL) + &_m_EmojiCompat_DefaultSpanFactory__new0, "", "()V"); + if (_m_EmojiCompat_DefaultSpanFactory__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_EmojiCompat_DefaultSpanFactory, - _m_EmojiCompat_DefaultSpanFactory__ctor); + _m_EmojiCompat_DefaultSpanFactory__new0); return to_global_ref_result(_result); } @@ -1025,11 +1025,11 @@ JniResult DefaultEmojiCompatConfig__create(jobject context) { jclass _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28 = NULL; jmethodID - _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__ctor = + _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__new0 = NULL; FFI_PLUGIN_EXPORT JniResult -DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__ctor() { +DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__new0() { load_env(); load_class_global_ref( &_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28, @@ -1039,14 +1039,14 @@ DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__ctor() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method( _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28, - &_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__ctor, + &_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__new0, "", "()V"); - if (_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__ctor == + if (_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject( jniEnv, _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28, - _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__ctor); + _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__new0); return to_global_ref_result(_result); } @@ -1086,11 +1086,11 @@ DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28__getSigningSignatu jclass _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19 = NULL; jmethodID - _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__ctor = + _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__new0 = NULL; FFI_PLUGIN_EXPORT JniResult -DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__ctor() { +DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__new0() { load_env(); load_class_global_ref( &_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19, @@ -1100,14 +1100,14 @@ DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__ctor() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method( _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19, - &_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__ctor, + &_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__new0, "", "()V"); - if (_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__ctor == + if (_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject( jniEnv, _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19, - _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__ctor); + _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__new0); return to_global_ref_result(_result); } @@ -1177,10 +1177,10 @@ DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19__getProviderInfo( // androidx.emoji2.text.DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper jclass _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper = NULL; -jmethodID _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__ctor = +jmethodID _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__ctor() { +JniResult DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__new0() { load_env(); load_class_global_ref( &_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper, @@ -1189,13 +1189,13 @@ JniResult DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__ctor() { if (_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper, - &_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__ctor, + &_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__new0, "", "()V"); - if (_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__ctor == NULL) + if (_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject( jniEnv, _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper, - _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__ctor); + _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__new0); return to_global_ref_result(_result); } @@ -1297,10 +1297,10 @@ DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper__getProviderInfo( // androidx.emoji2.text.DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory jclass _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory = NULL; -jmethodID _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__ctor = +jmethodID _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__ctor( +JniResult DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__new0( jobject helper) { load_env(); load_class_global_ref( @@ -1311,15 +1311,15 @@ JniResult DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__ctor( return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method( _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory, - &_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__ctor, + &_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__new0, "", "(Landroidx/emoji2/text/" "DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper;)V"); - if (_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__ctor == NULL) + if (_m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject( jniEnv, _c_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory, - _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__ctor, + _m_DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory__new0, helper); return to_global_ref_result(_result); } @@ -1438,18 +1438,18 @@ JniResult Build_Partition__hashCode1(jobject self_) { // android.os.Build$VERSION jclass _c_Build_VERSION = NULL; -jmethodID _m_Build_VERSION__ctor = NULL; +jmethodID _m_Build_VERSION__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult Build_VERSION__ctor() { +JniResult Build_VERSION__new0() { load_env(); load_class_global_ref(&_c_Build_VERSION, "android/os/Build$VERSION"); if (_c_Build_VERSION == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_Build_VERSION, &_m_Build_VERSION__ctor, "", "()V"); - if (_m_Build_VERSION__ctor == NULL) + load_method(_c_Build_VERSION, &_m_Build_VERSION__new0, "", "()V"); + if (_m_Build_VERSION__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = - (*jniEnv)->NewObject(jniEnv, _c_Build_VERSION, _m_Build_VERSION__ctor); + (*jniEnv)->NewObject(jniEnv, _c_Build_VERSION, _m_Build_VERSION__new0); return to_global_ref_result(_result); } @@ -1612,37 +1612,37 @@ JniResult get_Build_VERSION__SECURITY_PATCH() { // android.os.Build$VERSION_CODES jclass _c_Build_VERSION_CODES = NULL; -jmethodID _m_Build_VERSION_CODES__ctor = NULL; +jmethodID _m_Build_VERSION_CODES__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult Build_VERSION_CODES__ctor() { +JniResult Build_VERSION_CODES__new0() { load_env(); load_class_global_ref(&_c_Build_VERSION_CODES, "android/os/Build$VERSION_CODES"); if (_c_Build_VERSION_CODES == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_Build_VERSION_CODES, &_m_Build_VERSION_CODES__ctor, "", + load_method(_c_Build_VERSION_CODES, &_m_Build_VERSION_CODES__new0, "", "()V"); - if (_m_Build_VERSION_CODES__ctor == NULL) + if (_m_Build_VERSION_CODES__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Build_VERSION_CODES, - _m_Build_VERSION_CODES__ctor); + _m_Build_VERSION_CODES__new0); return to_global_ref_result(_result); } // android.os.Build jclass _c_Build = NULL; -jmethodID _m_Build__ctor = NULL; +jmethodID _m_Build__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult Build__ctor() { +JniResult Build__new0() { load_env(); load_class_global_ref(&_c_Build, "android/os/Build"); if (_c_Build == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_Build, &_m_Build__ctor, "", "()V"); - if (_m_Build__ctor == NULL) + load_method(_c_Build, &_m_Build__new0, "", "()V"); + if (_m_Build__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Build, _m_Build__ctor); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Build, _m_Build__new0); return to_global_ref_result(_result); } @@ -2064,62 +2064,62 @@ JniResult get_Build__USER() { // java.util.HashMap jclass _c_HashMap = NULL; -jmethodID _m_HashMap__ctor = NULL; +jmethodID _m_HashMap__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult HashMap__ctor(int32_t i, float f) { +JniResult HashMap__new0(int32_t i, float f) { load_env(); load_class_global_ref(&_c_HashMap, "java/util/HashMap"); if (_c_HashMap == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_HashMap, &_m_HashMap__ctor, "", "(IF)V"); - if (_m_HashMap__ctor == NULL) + load_method(_c_HashMap, &_m_HashMap__new0, "", "(IF)V"); + if (_m_HashMap__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = - (*jniEnv)->NewObject(jniEnv, _c_HashMap, _m_HashMap__ctor, i, f); + (*jniEnv)->NewObject(jniEnv, _c_HashMap, _m_HashMap__new0, i, f); return to_global_ref_result(_result); } -jmethodID _m_HashMap__ctor1 = NULL; +jmethodID _m_HashMap__new1 = NULL; FFI_PLUGIN_EXPORT -JniResult HashMap__ctor1(int32_t i) { +JniResult HashMap__new1(int32_t i) { load_env(); load_class_global_ref(&_c_HashMap, "java/util/HashMap"); if (_c_HashMap == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_HashMap, &_m_HashMap__ctor1, "", "(I)V"); - if (_m_HashMap__ctor1 == NULL) + load_method(_c_HashMap, &_m_HashMap__new1, "", "(I)V"); + if (_m_HashMap__new1 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = - (*jniEnv)->NewObject(jniEnv, _c_HashMap, _m_HashMap__ctor1, i); + (*jniEnv)->NewObject(jniEnv, _c_HashMap, _m_HashMap__new1, i); return to_global_ref_result(_result); } -jmethodID _m_HashMap__ctor2 = NULL; +jmethodID _m_HashMap__new2 = NULL; FFI_PLUGIN_EXPORT -JniResult HashMap__ctor2() { +JniResult HashMap__new2() { load_env(); load_class_global_ref(&_c_HashMap, "java/util/HashMap"); if (_c_HashMap == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_HashMap, &_m_HashMap__ctor2, "", "()V"); - if (_m_HashMap__ctor2 == NULL) + load_method(_c_HashMap, &_m_HashMap__new2, "", "()V"); + if (_m_HashMap__new2 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - jobject _result = (*jniEnv)->NewObject(jniEnv, _c_HashMap, _m_HashMap__ctor2); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_HashMap, _m_HashMap__new2); return to_global_ref_result(_result); } -jmethodID _m_HashMap__ctor3 = NULL; +jmethodID _m_HashMap__new3 = NULL; FFI_PLUGIN_EXPORT -JniResult HashMap__ctor3(jobject map) { +JniResult HashMap__new3(jobject map) { load_env(); load_class_global_ref(&_c_HashMap, "java/util/HashMap"); if (_c_HashMap == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_HashMap, &_m_HashMap__ctor3, "", "(Ljava/util/Map;)V"); - if (_m_HashMap__ctor3 == NULL) + load_method(_c_HashMap, &_m_HashMap__new3, "", "(Ljava/util/Map;)V"); + if (_m_HashMap__new3 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = - (*jniEnv)->NewObject(jniEnv, _c_HashMap, _m_HashMap__ctor3, map); + (*jniEnv)->NewObject(jniEnv, _c_HashMap, _m_HashMap__new3, map); return to_global_ref_result(_result); } diff --git a/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart b/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart index e1002dd9d..75da7fe69 100644 --- a/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart +++ b/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart @@ -36,14 +36,14 @@ class Example extends jni.JObject { /// The type which includes information such as the signature of this class. static const type = $ExampleType(); - static final _ctor = - jniLookup>("Example__ctor") + static final _new0 = + jniLookup>("Example__new0") .asFunction(); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory Example() { - return Example.fromRef(_ctor().object); + return Example.fromRef(_new0().object); } static final _thinkBeforeAnswering = jniLookup< diff --git a/pkgs/jnigen/example/kotlin_plugin/src/kotlin_plugin_bindings.c b/pkgs/jnigen/example/kotlin_plugin/src/kotlin_plugin_bindings.c index fd8b22bf8..28a2af621 100644 --- a/pkgs/jnigen/example/kotlin_plugin/src/kotlin_plugin_bindings.c +++ b/pkgs/jnigen/example/kotlin_plugin/src/kotlin_plugin_bindings.c @@ -18,17 +18,17 @@ void setJniGetters(JniContext* (*cg)(void), JNIEnv* (*eg)(void)) { // Example jclass _c_Example = NULL; -jmethodID _m_Example__ctor = NULL; +jmethodID _m_Example__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult Example__ctor() { +JniResult Example__new0() { load_env(); load_class_global_ref(&_c_Example, "Example"); if (_c_Example == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_Example, &_m_Example__ctor, "", "()V"); - if (_m_Example__ctor == NULL) + load_method(_c_Example, &_m_Example__new0, "", "()V"); + if (_m_Example__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Example, _m_Example__ctor); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Example, _m_Example__new0); return to_global_ref_result(_result); } diff --git a/pkgs/jnigen/example/notification_plugin/lib/notifications.dart b/pkgs/jnigen/example/notification_plugin/lib/notifications.dart index 170c7205d..267d2d363 100644 --- a/pkgs/jnigen/example/notification_plugin/lib/notifications.dart +++ b/pkgs/jnigen/example/notification_plugin/lib/notifications.dart @@ -40,14 +40,14 @@ class Notifications extends jni.JObject { /// The type which includes information such as the signature of this class. static const type = $NotificationsType(); - static final _ctor = jniLookup>( - "Notifications__ctor") + static final _new0 = jniLookup>( + "Notifications__new0") .asFunction(); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory Notifications() { - return Notifications.fromRef(_ctor().object); + return Notifications.fromRef(_new0().object); } static final _showNotification = jniLookup< diff --git a/pkgs/jnigen/example/notification_plugin/src/notification_plugin.c b/pkgs/jnigen/example/notification_plugin/src/notification_plugin.c index 387fe0c54..9f1e57745 100644 --- a/pkgs/jnigen/example/notification_plugin/src/notification_plugin.c +++ b/pkgs/jnigen/example/notification_plugin/src/notification_plugin.c @@ -22,19 +22,19 @@ void setJniGetters(JniContext* (*cg)(void), JNIEnv* (*eg)(void)) { // com.example.notification_plugin.Notifications jclass _c_Notifications = NULL; -jmethodID _m_Notifications__ctor = NULL; +jmethodID _m_Notifications__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult Notifications__ctor() { +JniResult Notifications__new0() { load_env(); load_class_global_ref(&_c_Notifications, "com/example/notification_plugin/Notifications"); if (_c_Notifications == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_Notifications, &_m_Notifications__ctor, "", "()V"); - if (_m_Notifications__ctor == NULL) + load_method(_c_Notifications, &_m_Notifications__new0, "", "()V"); + if (_m_Notifications__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = - (*jniEnv)->NewObject(jniEnv, _c_Notifications, _m_Notifications__ctor); + (*jniEnv)->NewObject(jniEnv, _c_Notifications, _m_Notifications__new0); return to_global_ref_result(_result); } 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 ed3c555c6..6c103dcdf 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 @@ -56,8 +56,8 @@ class PDDocument extends jni.JObject { /// The type which includes information such as the signature of this class. static const type = $PDDocumentType(); - static final _ctor = jniLookup>( - "PDDocument__ctor") + static final _new0 = jniLookup>( + "PDDocument__new0") .asFunction(); /// from: public void () @@ -66,13 +66,13 @@ 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.fromRef(_ctor().object); + return PDDocument.fromRef(_new0().object); } - static final _ctor1 = jniLookup< + static final _new1 = jniLookup< ffi .NativeFunction)>>( - "PDDocument__ctor1") + "PDDocument__new1") .asFunction)>(); /// from: public void (org.apache.pdfbox.io.MemoryUsageSetting memUsageSetting) @@ -81,16 +81,16 @@ class PDDocument extends jni.JObject { /// Creates an empty PDF document. /// You need to add at least one page for the document to be valid. ///@param memUsageSetting defines how memory is used for buffering PDF streams - factory PDDocument.ctor1( + factory PDDocument.new1( jni.JObject memUsageSetting, ) { - return PDDocument.fromRef(_ctor1(memUsageSetting.reference).object); + return PDDocument.fromRef(_new1(memUsageSetting.reference).object); } - static final _ctor2 = jniLookup< + static final _new2 = jniLookup< ffi .NativeFunction)>>( - "PDDocument__ctor2") + "PDDocument__new2") .asFunction)>(); /// from: public void (org.apache.pdfbox.cos.COSDocument doc) @@ -98,16 +98,16 @@ class PDDocument extends jni.JObject { /// /// Constructor that uses an existing document. The COSDocument that is passed in must be valid. ///@param doc The COSDocument that this document wraps. - factory PDDocument.ctor2( + factory PDDocument.new2( jni.JObject doc, ) { - return PDDocument.fromRef(_ctor2(doc.reference).object); + return PDDocument.fromRef(_new2(doc.reference).object); } - static final _ctor3 = jniLookup< + static final _new3 = jniLookup< ffi.NativeFunction< jni.JniResult Function(ffi.Pointer, - ffi.Pointer)>>("PDDocument__ctor3") + ffi.Pointer)>>("PDDocument__new3") .asFunction< jni.JniResult Function( ffi.Pointer, ffi.Pointer)>(); @@ -118,19 +118,19 @@ class PDDocument extends jni.JObject { /// Constructor that uses an existing document. The COSDocument that is passed in must be valid. ///@param doc The COSDocument that this document wraps. ///@param source the parser which is used to read the pdf - factory PDDocument.ctor3( + factory PDDocument.new3( jni.JObject doc, jni.JObject source, ) { - return PDDocument.fromRef(_ctor3(doc.reference, source.reference).object); + return PDDocument.fromRef(_new3(doc.reference, source.reference).object); } - static final _ctor4 = jniLookup< + static final _new4 = jniLookup< ffi.NativeFunction< jni.JniResult Function( ffi.Pointer, ffi.Pointer, - ffi.Pointer)>>("PDDocument__ctor4") + ffi.Pointer)>>("PDDocument__new4") .asFunction< jni.JniResult Function(ffi.Pointer, ffi.Pointer, ffi.Pointer)>(); @@ -142,13 +142,13 @@ class PDDocument extends jni.JObject { ///@param doc The COSDocument that this document wraps. ///@param source the parser which is used to read the pdf ///@param permission he access permissions of the pdf - factory PDDocument.ctor4( + factory PDDocument.new4( jni.JObject doc, jni.JObject source, jni.JObject permission, ) { return PDDocument.fromRef( - _ctor4(doc.reference, source.reference, permission.reference).object); + _new4(doc.reference, source.reference, permission.reference).object); } static final _addPage = jniLookup< 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 5d9a8ff6a..a12b62aa9 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 @@ -57,8 +57,8 @@ class PDDocumentInformation extends jni.JObject { /// The type which includes information such as the signature of this class. static const type = $PDDocumentInformationType(); - static final _ctor = jniLookup>( - "PDDocumentInformation__ctor") + static final _new0 = jniLookup>( + "PDDocumentInformation__new0") .asFunction(); /// from: public void () @@ -66,13 +66,13 @@ class PDDocumentInformation extends jni.JObject { /// /// Default Constructor. factory PDDocumentInformation() { - return PDDocumentInformation.fromRef(_ctor().object); + return PDDocumentInformation.fromRef(_new0().object); } - static final _ctor1 = jniLookup< + static final _new1 = jniLookup< ffi .NativeFunction)>>( - "PDDocumentInformation__ctor1") + "PDDocumentInformation__new1") .asFunction)>(); /// from: public void (org.apache.pdfbox.cos.COSDictionary dic) @@ -80,10 +80,10 @@ class PDDocumentInformation extends jni.JObject { /// /// Constructor that is used for a preexisting dictionary. ///@param dic The underlying dictionary. - factory PDDocumentInformation.ctor1( + factory PDDocumentInformation.new1( jni.JObject dic, ) { - return PDDocumentInformation.fromRef(_ctor1(dic.reference).object); + return PDDocumentInformation.fromRef(_new1(dic.reference).object); } static final _getCOSObject = jniLookup< 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 e2bc49074..7f565b011 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 @@ -185,8 +185,8 @@ class PDFTextStripper extends jni.JObject { set output(jni.JObject value) => _set_output(reference, value.reference).check(); - static final _ctor = jniLookup>( - "PDFTextStripper__ctor") + static final _new0 = jniLookup>( + "PDFTextStripper__new0") .asFunction(); /// from: public void () @@ -195,7 +195,7 @@ class PDFTextStripper extends jni.JObject { /// Instantiate a new PDFTextStripper object. ///@throws IOException If there is an error loading the properties. factory PDFTextStripper() { - return PDFTextStripper.fromRef(_ctor().object); + return PDFTextStripper.fromRef(_new0().object); } static final _getText = jniLookup< diff --git a/pkgs/jnigen/example/pdfbox_plugin/src/third_party/pdfbox_plugin.c b/pkgs/jnigen/example/pdfbox_plugin/src/third_party/pdfbox_plugin.c index 86a8161e8..6b111335c 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/src/third_party/pdfbox_plugin.c +++ b/pkgs/jnigen/example/pdfbox_plugin/src/third_party/pdfbox_plugin.c @@ -36,85 +36,85 @@ void setJniGetters(JniContext* (*cg)(void), JNIEnv* (*eg)(void)) { // org.apache.pdfbox.pdmodel.PDDocument jclass _c_PDDocument = NULL; -jmethodID _m_PDDocument__ctor = NULL; +jmethodID _m_PDDocument__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult PDDocument__ctor() { +JniResult PDDocument__new0() { load_env(); load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_PDDocument, &_m_PDDocument__ctor, "", "()V"); - if (_m_PDDocument__ctor == NULL) + load_method(_c_PDDocument, &_m_PDDocument__new0, "", "()V"); + if (_m_PDDocument__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = - (*jniEnv)->NewObject(jniEnv, _c_PDDocument, _m_PDDocument__ctor); + (*jniEnv)->NewObject(jniEnv, _c_PDDocument, _m_PDDocument__new0); return to_global_ref_result(_result); } -jmethodID _m_PDDocument__ctor1 = NULL; +jmethodID _m_PDDocument__new1 = NULL; FFI_PLUGIN_EXPORT -JniResult PDDocument__ctor1(jobject memUsageSetting) { +JniResult PDDocument__new1(jobject memUsageSetting) { load_env(); load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_PDDocument, &_m_PDDocument__ctor1, "", + load_method(_c_PDDocument, &_m_PDDocument__new1, "", "(Lorg/apache/pdfbox/io/MemoryUsageSetting;)V"); - if (_m_PDDocument__ctor1 == NULL) + if (_m_PDDocument__new1 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_PDDocument, - _m_PDDocument__ctor1, memUsageSetting); + _m_PDDocument__new1, memUsageSetting); return to_global_ref_result(_result); } -jmethodID _m_PDDocument__ctor2 = NULL; +jmethodID _m_PDDocument__new2 = NULL; FFI_PLUGIN_EXPORT -JniResult PDDocument__ctor2(jobject doc) { +JniResult PDDocument__new2(jobject doc) { load_env(); load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_PDDocument, &_m_PDDocument__ctor2, "", + load_method(_c_PDDocument, &_m_PDDocument__new2, "", "(Lorg/apache/pdfbox/cos/COSDocument;)V"); - if (_m_PDDocument__ctor2 == NULL) + if (_m_PDDocument__new2 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = - (*jniEnv)->NewObject(jniEnv, _c_PDDocument, _m_PDDocument__ctor2, doc); + (*jniEnv)->NewObject(jniEnv, _c_PDDocument, _m_PDDocument__new2, doc); return to_global_ref_result(_result); } -jmethodID _m_PDDocument__ctor3 = NULL; +jmethodID _m_PDDocument__new3 = NULL; FFI_PLUGIN_EXPORT -JniResult PDDocument__ctor3(jobject doc, jobject source) { +JniResult PDDocument__new3(jobject doc, jobject source) { load_env(); load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_PDDocument, &_m_PDDocument__ctor3, "", + load_method(_c_PDDocument, &_m_PDDocument__new3, "", "(Lorg/apache/pdfbox/cos/COSDocument;Lorg/apache/pdfbox/io/" "RandomAccessRead;)V"); - if (_m_PDDocument__ctor3 == NULL) + if (_m_PDDocument__new3 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_PDDocument, - _m_PDDocument__ctor3, doc, source); + _m_PDDocument__new3, doc, source); return to_global_ref_result(_result); } -jmethodID _m_PDDocument__ctor4 = NULL; +jmethodID _m_PDDocument__new4 = NULL; FFI_PLUGIN_EXPORT -JniResult PDDocument__ctor4(jobject doc, jobject source, jobject permission) { +JniResult PDDocument__new4(jobject doc, jobject source, jobject permission) { load_env(); load_class_global_ref(&_c_PDDocument, "org/apache/pdfbox/pdmodel/PDDocument"); if (_c_PDDocument == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_PDDocument, &_m_PDDocument__ctor4, "", + load_method(_c_PDDocument, &_m_PDDocument__new4, "", "(Lorg/apache/pdfbox/cos/COSDocument;Lorg/apache/pdfbox/io/" "RandomAccessRead;Lorg/apache/pdfbox/pdmodel/encryption/" "AccessPermission;)V"); - if (_m_PDDocument__ctor4 == NULL) + if (_m_PDDocument__new4 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject( - jniEnv, _c_PDDocument, _m_PDDocument__ctor4, doc, source, permission); + jniEnv, _c_PDDocument, _m_PDDocument__new4, doc, source, permission); return to_global_ref_result(_result); } @@ -1103,37 +1103,37 @@ JniResult PDDocument__setResourceCache(jobject self_, jobject resourceCache) { // org.apache.pdfbox.pdmodel.PDDocumentInformation jclass _c_PDDocumentInformation = NULL; -jmethodID _m_PDDocumentInformation__ctor = NULL; +jmethodID _m_PDDocumentInformation__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult PDDocumentInformation__ctor() { +JniResult PDDocumentInformation__new0() { load_env(); load_class_global_ref(&_c_PDDocumentInformation, "org/apache/pdfbox/pdmodel/PDDocumentInformation"); if (_c_PDDocumentInformation == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_PDDocumentInformation, &_m_PDDocumentInformation__ctor, + load_method(_c_PDDocumentInformation, &_m_PDDocumentInformation__new0, "", "()V"); - if (_m_PDDocumentInformation__ctor == NULL) + if (_m_PDDocumentInformation__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_PDDocumentInformation, - _m_PDDocumentInformation__ctor); + _m_PDDocumentInformation__new0); return to_global_ref_result(_result); } -jmethodID _m_PDDocumentInformation__ctor1 = NULL; +jmethodID _m_PDDocumentInformation__new1 = NULL; FFI_PLUGIN_EXPORT -JniResult PDDocumentInformation__ctor1(jobject dic) { +JniResult PDDocumentInformation__new1(jobject dic) { load_env(); load_class_global_ref(&_c_PDDocumentInformation, "org/apache/pdfbox/pdmodel/PDDocumentInformation"); if (_c_PDDocumentInformation == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_PDDocumentInformation, &_m_PDDocumentInformation__ctor1, + load_method(_c_PDDocumentInformation, &_m_PDDocumentInformation__new1, "", "(Lorg/apache/pdfbox/cos/COSDictionary;)V"); - if (_m_PDDocumentInformation__ctor1 == NULL) + if (_m_PDDocumentInformation__new1 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_PDDocumentInformation, - _m_PDDocumentInformation__ctor1, dic); + _m_PDDocumentInformation__new1, dic); return to_global_ref_result(_result); } @@ -1550,19 +1550,19 @@ JniResult PDDocumentInformation__setTrapped(jobject self_, jobject value) { // org.apache.pdfbox.text.PDFTextStripper jclass _c_PDFTextStripper = NULL; -jmethodID _m_PDFTextStripper__ctor = NULL; +jmethodID _m_PDFTextStripper__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult PDFTextStripper__ctor() { +JniResult PDFTextStripper__new0() { load_env(); load_class_global_ref(&_c_PDFTextStripper, "org/apache/pdfbox/text/PDFTextStripper"); if (_c_PDFTextStripper == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_PDFTextStripper, &_m_PDFTextStripper__ctor, "", "()V"); - if (_m_PDFTextStripper__ctor == NULL) + load_method(_c_PDFTextStripper, &_m_PDFTextStripper__new0, "", "()V"); + if (_m_PDFTextStripper__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_PDFTextStripper, - _m_PDFTextStripper__ctor); + _m_PDFTextStripper__new0); return to_global_ref_result(_result); } diff --git a/pkgs/jnigen/lib/src/bindings/dart_generator.dart b/pkgs/jnigen/lib/src/bindings/dart_generator.dart index 7f734accc..04d095b66 100644 --- a/pkgs/jnigen/lib/src/bindings/dart_generator.dart +++ b/pkgs/jnigen/lib/src/bindings/dart_generator.dart @@ -1242,7 +1242,7 @@ class _MethodGenerator extends Visitor { if (node.isCtor) { final className = node.classDecl.finalName; final name = node.finalName; - final ctorName = name == 'ctor' ? className : '$className.$name'; + final ctorName = name == 'new0' ? className : '$className.$name'; final paramsDef = node.params.accept(_ParamDef(resolver)).delimited(', '); final typeClassDef = _encloseIfNotEmpty( '{', diff --git a/pkgs/jnigen/lib/src/bindings/renamer.dart b/pkgs/jnigen/lib/src/bindings/renamer.dart index 607216ea1..74898fb46 100644 --- a/pkgs/jnigen/lib/src/bindings/renamer.dart +++ b/pkgs/jnigen/lib/src/bindings/renamer.dart @@ -197,7 +197,7 @@ class _MethodRenamer implements Visitor { @override void visit(Method node) { - final name = node.name == '' ? 'ctor' : node.name; + final name = node.name == '' ? 'new' : node.name; final sig = node.javaSig; // If node is in super class, assign its number, overriding it. final superClass = diff --git a/pkgs/jnigen/pubspec.yaml b/pkgs/jnigen/pubspec.yaml index 31019dd0f..c0b3dbfc7 100644 --- a/pkgs/jnigen/pubspec.yaml +++ b/pkgs/jnigen/pubspec.yaml @@ -3,7 +3,7 @@ # BSD-style license that can be found in the LICENSE file. name: jnigen -version: 0.6.0-wip.2 +version: 0.6.0-wip.3 description: Experimental generator for FFI+JNI bindings. repository: https://github.com/dart-lang/jnigen/tree/main/jnigen diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/jackson_core.c b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/jackson_core.c index 0f6b727df..3203612ea 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/jackson_core.c +++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/jackson_core.c @@ -35,88 +35,88 @@ void setJniGetters(JniContext* (*cg)(void), JNIEnv* (*eg)(void)) { // com.fasterxml.jackson.core.JsonFactory jclass _c_JsonFactory = NULL; -jmethodID _m_JsonFactory__ctor = NULL; +jmethodID _m_JsonFactory__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult JsonFactory__ctor() { +JniResult JsonFactory__new0() { load_env(); load_class_global_ref(&_c_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); if (_c_JsonFactory == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_JsonFactory, &_m_JsonFactory__ctor, "", "()V"); - if (_m_JsonFactory__ctor == NULL) + load_method(_c_JsonFactory, &_m_JsonFactory__new0, "", "()V"); + if (_m_JsonFactory__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = - (*jniEnv)->NewObject(jniEnv, _c_JsonFactory, _m_JsonFactory__ctor); + (*jniEnv)->NewObject(jniEnv, _c_JsonFactory, _m_JsonFactory__new0); return to_global_ref_result(_result); } -jmethodID _m_JsonFactory__ctor1 = NULL; +jmethodID _m_JsonFactory__new1 = NULL; FFI_PLUGIN_EXPORT -JniResult JsonFactory__ctor1(jobject oc) { +JniResult JsonFactory__new1(jobject oc) { load_env(); load_class_global_ref(&_c_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); if (_c_JsonFactory == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_JsonFactory, &_m_JsonFactory__ctor1, "", + load_method(_c_JsonFactory, &_m_JsonFactory__new1, "", "(Lcom/fasterxml/jackson/core/ObjectCodec;)V"); - if (_m_JsonFactory__ctor1 == NULL) + if (_m_JsonFactory__new1 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = - (*jniEnv)->NewObject(jniEnv, _c_JsonFactory, _m_JsonFactory__ctor1, oc); + (*jniEnv)->NewObject(jniEnv, _c_JsonFactory, _m_JsonFactory__new1, oc); return to_global_ref_result(_result); } -jmethodID _m_JsonFactory__ctor2 = NULL; +jmethodID _m_JsonFactory__new2 = NULL; FFI_PLUGIN_EXPORT -JniResult JsonFactory__ctor2(jobject src, jobject codec) { +JniResult JsonFactory__new2(jobject src, jobject codec) { load_env(); load_class_global_ref(&_c_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); if (_c_JsonFactory == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_JsonFactory, &_m_JsonFactory__ctor2, "", + load_method(_c_JsonFactory, &_m_JsonFactory__new2, "", "(Lcom/fasterxml/jackson/core/JsonFactory;Lcom/fasterxml/jackson/" "core/ObjectCodec;)V"); - if (_m_JsonFactory__ctor2 == NULL) + if (_m_JsonFactory__new2 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_JsonFactory, - _m_JsonFactory__ctor2, src, codec); + _m_JsonFactory__new2, src, codec); return to_global_ref_result(_result); } -jmethodID _m_JsonFactory__ctor3 = NULL; +jmethodID _m_JsonFactory__new3 = NULL; FFI_PLUGIN_EXPORT -JniResult JsonFactory__ctor3(jobject b) { +JniResult JsonFactory__new3(jobject b) { load_env(); load_class_global_ref(&_c_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); if (_c_JsonFactory == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_JsonFactory, &_m_JsonFactory__ctor3, "", + load_method(_c_JsonFactory, &_m_JsonFactory__new3, "", "(Lcom/fasterxml/jackson/core/JsonFactoryBuilder;)V"); - if (_m_JsonFactory__ctor3 == NULL) + if (_m_JsonFactory__new3 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = - (*jniEnv)->NewObject(jniEnv, _c_JsonFactory, _m_JsonFactory__ctor3, b); + (*jniEnv)->NewObject(jniEnv, _c_JsonFactory, _m_JsonFactory__new3, b); return to_global_ref_result(_result); } -jmethodID _m_JsonFactory__ctor4 = NULL; +jmethodID _m_JsonFactory__new4 = NULL; FFI_PLUGIN_EXPORT -JniResult JsonFactory__ctor4(jobject b, uint8_t bogus) { +JniResult JsonFactory__new4(jobject b, uint8_t bogus) { load_env(); load_class_global_ref(&_c_JsonFactory, "com/fasterxml/jackson/core/JsonFactory"); if (_c_JsonFactory == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_JsonFactory, &_m_JsonFactory__ctor4, "", + load_method(_c_JsonFactory, &_m_JsonFactory__new4, "", "(Lcom/fasterxml/jackson/core/TSFBuilder;Z)V"); - if (_m_JsonFactory__ctor4 == NULL) + if (_m_JsonFactory__new4 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_JsonFactory, - _m_JsonFactory__ctor4, b, bogus); + _m_JsonFactory__new4, b, bogus); return to_global_ref_result(_result); } @@ -1562,35 +1562,35 @@ JniResult JsonFactory_Feature__getMask(jobject self_) { // com.fasterxml.jackson.core.JsonParser jclass _c_JsonParser = NULL; -jmethodID _m_JsonParser__ctor = NULL; +jmethodID _m_JsonParser__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult JsonParser__ctor() { +JniResult JsonParser__new0() { load_env(); load_class_global_ref(&_c_JsonParser, "com/fasterxml/jackson/core/JsonParser"); if (_c_JsonParser == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_JsonParser, &_m_JsonParser__ctor, "", "()V"); - if (_m_JsonParser__ctor == NULL) + load_method(_c_JsonParser, &_m_JsonParser__new0, "", "()V"); + if (_m_JsonParser__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = - (*jniEnv)->NewObject(jniEnv, _c_JsonParser, _m_JsonParser__ctor); + (*jniEnv)->NewObject(jniEnv, _c_JsonParser, _m_JsonParser__new0); return to_global_ref_result(_result); } -jmethodID _m_JsonParser__ctor1 = NULL; +jmethodID _m_JsonParser__new1 = NULL; FFI_PLUGIN_EXPORT -JniResult JsonParser__ctor1(int32_t features) { +JniResult JsonParser__new1(int32_t features) { load_env(); load_class_global_ref(&_c_JsonParser, "com/fasterxml/jackson/core/JsonParser"); if (_c_JsonParser == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_JsonParser, &_m_JsonParser__ctor1, "", "(I)V"); - if (_m_JsonParser__ctor1 == NULL) + load_method(_c_JsonParser, &_m_JsonParser__new1, "", "(I)V"); + if (_m_JsonParser__new1 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_JsonParser, - _m_JsonParser__ctor1, features); + _m_JsonParser__new1, features); return to_global_ref_result(_result); } diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart index 1e60c8a6b..7112fc36b 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart @@ -121,8 +121,8 @@ class JsonFactory extends jni.JObject { static jni.JObject get DEFAULT_ROOT_VALUE_SEPARATOR => const jni.JObjectType() .fromRef(_get_DEFAULT_ROOT_VALUE_SEPARATOR().object); - static final _ctor = jniLookup>( - "JsonFactory__ctor") + static final _new0 = jniLookup>( + "JsonFactory__new0") .asFunction(); /// from: public void () @@ -137,27 +137,27 @@ class JsonFactory extends jni.JObject { /// and this reuse only works within context of a single /// factory instance. factory JsonFactory() { - return JsonFactory.fromRef(_ctor().object); + return JsonFactory.fromRef(_new0().object); } - static final _ctor1 = jniLookup< + static final _new1 = jniLookup< ffi .NativeFunction)>>( - "JsonFactory__ctor1") + "JsonFactory__new1") .asFunction)>(); /// from: public void (com.fasterxml.jackson.core.ObjectCodec oc) /// The returned object must be deleted after use, by calling the `delete` method. - factory JsonFactory.ctor1( + factory JsonFactory.new1( jni.JObject oc, ) { - return JsonFactory.fromRef(_ctor1(oc.reference).object); + return JsonFactory.fromRef(_new1(oc.reference).object); } - static final _ctor2 = jniLookup< + static final _new2 = jniLookup< ffi.NativeFunction< jni.JniResult Function(ffi.Pointer, - ffi.Pointer)>>("JsonFactory__ctor2") + ffi.Pointer)>>("JsonFactory__new2") .asFunction< jni.JniResult Function( ffi.Pointer, ffi.Pointer)>(); @@ -169,17 +169,17 @@ class JsonFactory extends jni.JObject { ///@param src Original factory to copy settings from ///@param codec Databinding-level codec to use, if any ///@since 2.2.1 - factory JsonFactory.ctor2( + factory JsonFactory.new2( JsonFactory src, jni.JObject codec, ) { - return JsonFactory.fromRef(_ctor2(src.reference, codec.reference).object); + return JsonFactory.fromRef(_new2(src.reference, codec.reference).object); } - static final _ctor3 = jniLookup< + static final _new3 = jniLookup< ffi .NativeFunction)>>( - "JsonFactory__ctor3") + "JsonFactory__new3") .asFunction)>(); /// from: public void (com.fasterxml.jackson.core.JsonFactoryBuilder b) @@ -188,16 +188,16 @@ class JsonFactory extends jni.JObject { /// Constructor used by JsonFactoryBuilder for instantiation. ///@param b Builder that contains settings to use ///@since 2.10 - factory JsonFactory.ctor3( + factory JsonFactory.new3( jni.JObject b, ) { - return JsonFactory.fromRef(_ctor3(b.reference).object); + return JsonFactory.fromRef(_new3(b.reference).object); } - static final _ctor4 = jniLookup< + static final _new4 = jniLookup< ffi.NativeFunction< jni.JniResult Function( - ffi.Pointer, ffi.Uint8)>>("JsonFactory__ctor4") + ffi.Pointer, ffi.Uint8)>>("JsonFactory__new4") .asFunction, int)>(); /// from: protected void (com.fasterxml.jackson.core.TSFBuilder b, boolean bogus) @@ -208,11 +208,11 @@ class JsonFactory extends jni.JObject { /// implementation for json. ///@param b Builder that contains settings to use ///@param bogus Argument only needed to separate constructor signature; ignored - factory JsonFactory.ctor4( + factory JsonFactory.new4( jni.JObject b, bool bogus, ) { - return JsonFactory.fromRef(_ctor4(b.reference, bogus ? 1 : 0).object); + return JsonFactory.fromRef(_new4(b.reference, bogus ? 1 : 0).object); } static final _rebuild = jniLookup< diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart index 8790d3c75..7828fd81b 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart @@ -71,27 +71,27 @@ class JsonParser extends jni.JObject { static jni.JObject get DEFAULT_READ_CAPABILITIES => const jni.JObjectType().fromRef(_get_DEFAULT_READ_CAPABILITIES().object); - static final _ctor = jniLookup>( - "JsonParser__ctor") + static final _new0 = jniLookup>( + "JsonParser__new0") .asFunction(); /// from: protected void () /// The returned object must be deleted after use, by calling the `delete` method. factory JsonParser() { - return JsonParser.fromRef(_ctor().object); + return JsonParser.fromRef(_new0().object); } - static final _ctor1 = + static final _new1 = jniLookup>( - "JsonParser__ctor1") + "JsonParser__new1") .asFunction(); /// from: protected void (int features) /// The returned object must be deleted after use, by calling the `delete` method. - factory JsonParser.ctor1( + factory JsonParser.new1( int features, ) { - return JsonParser.fromRef(_ctor1(features).object); + return JsonParser.fromRef(_new1(features).object); } static final _getCodec = jniLookup< diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart index 71a79f1b8..e5045b92a 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart @@ -140,7 +140,7 @@ class JsonFactory extends jni.JObject { jni.JniCallType.objectType) .object); - static final _id_ctor = + static final _id_new0 = jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () @@ -156,22 +156,22 @@ class JsonFactory extends jni.JObject { /// factory instance. factory JsonFactory() { return JsonFactory.fromRef(jni.Jni.accessors - .newObjectWithArgs(_class.reference, _id_ctor, []).object); + .newObjectWithArgs(_class.reference, _id_new0, []).object); } - static final _id_ctor1 = jni.Jni.accessors.getMethodIDOf(_class.reference, + static final _id_new1 = jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"(Lcom/fasterxml/jackson/core/ObjectCodec;)V"); /// from: public void (com.fasterxml.jackson.core.ObjectCodec oc) /// The returned object must be deleted after use, by calling the `delete` method. - factory JsonFactory.ctor1( + factory JsonFactory.new1( jni.JObject oc, ) { return JsonFactory.fromRef(jni.Jni.accessors - .newObjectWithArgs(_class.reference, _id_ctor1, [oc.reference]).object); + .newObjectWithArgs(_class.reference, _id_new1, [oc.reference]).object); } - static final _id_ctor2 = jni.Jni.accessors.getMethodIDOf( + static final _id_new2 = jni.Jni.accessors.getMethodIDOf( _class.reference, r"", r"(Lcom/fasterxml/jackson/core/JsonFactory;Lcom/fasterxml/jackson/core/ObjectCodec;)V"); @@ -183,15 +183,15 @@ class JsonFactory extends jni.JObject { ///@param src Original factory to copy settings from ///@param codec Databinding-level codec to use, if any ///@since 2.2.1 - factory JsonFactory.ctor2( + factory JsonFactory.new2( JsonFactory src, jni.JObject codec, ) { return JsonFactory.fromRef(jni.Jni.accessors.newObjectWithArgs( - _class.reference, _id_ctor2, [src.reference, codec.reference]).object); + _class.reference, _id_new2, [src.reference, codec.reference]).object); } - static final _id_ctor3 = jni.Jni.accessors.getMethodIDOf(_class.reference, + static final _id_new3 = jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"(Lcom/fasterxml/jackson/core/JsonFactoryBuilder;)V"); /// from: public void (com.fasterxml.jackson.core.JsonFactoryBuilder b) @@ -200,14 +200,14 @@ class JsonFactory extends jni.JObject { /// Constructor used by JsonFactoryBuilder for instantiation. ///@param b Builder that contains settings to use ///@since 2.10 - factory JsonFactory.ctor3( + factory JsonFactory.new3( jni.JObject b, ) { return JsonFactory.fromRef(jni.Jni.accessors - .newObjectWithArgs(_class.reference, _id_ctor3, [b.reference]).object); + .newObjectWithArgs(_class.reference, _id_new3, [b.reference]).object); } - static final _id_ctor4 = jni.Jni.accessors.getMethodIDOf(_class.reference, + static final _id_new4 = jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"(Lcom/fasterxml/jackson/core/TSFBuilder;Z)V"); /// from: protected void (com.fasterxml.jackson.core.TSFBuilder b, boolean bogus) @@ -218,12 +218,12 @@ class JsonFactory extends jni.JObject { /// implementation for json. ///@param b Builder that contains settings to use ///@param bogus Argument only needed to separate constructor signature; ignored - factory JsonFactory.ctor4( + factory JsonFactory.new4( jni.JObject b, bool bogus, ) { return JsonFactory.fromRef(jni.Jni.accessors.newObjectWithArgs( - _class.reference, _id_ctor4, [b.reference, bogus ? 1 : 0]).object); + _class.reference, _id_new4, [b.reference, bogus ? 1 : 0]).object); } static final _id_rebuild = jni.Jni.accessors.getMethodIDOf(_class.reference, diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart index f978756ba..115c360c9 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart @@ -78,26 +78,26 @@ class JsonParser extends jni.JObject { jni.JniCallType.objectType) .object); - static final _id_ctor = + static final _id_new0 = jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: protected void () /// The returned object must be deleted after use, by calling the `delete` method. factory JsonParser() { return JsonParser.fromRef(jni.Jni.accessors - .newObjectWithArgs(_class.reference, _id_ctor, []).object); + .newObjectWithArgs(_class.reference, _id_new0, []).object); } - static final _id_ctor1 = + static final _id_new1 = jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"(I)V"); /// from: protected void (int features) /// The returned object must be deleted after use, by calling the `delete` method. - factory JsonParser.ctor1( + factory JsonParser.new1( int features, ) { return JsonParser.fromRef(jni.Jni.accessors.newObjectWithArgs( - _class.reference, _id_ctor1, [jni.JValueInt(features)]).object); + _class.reference, _id_new1, [jni.JValueInt(features)]).object); } static final _id_getCodec = jni.Jni.accessors.getMethodIDOf(_class.reference, diff --git a/pkgs/jnigen/test/kotlin_test/c_based/c_bindings/kotlin.c b/pkgs/jnigen/test/kotlin_test/c_based/c_bindings/kotlin.c index b131ce971..e3c227e6a 100644 --- a/pkgs/jnigen/test/kotlin_test/c_based/c_bindings/kotlin.c +++ b/pkgs/jnigen/test/kotlin_test/c_based/c_bindings/kotlin.c @@ -22,19 +22,19 @@ void setJniGetters(JniContext* (*cg)(void), JNIEnv* (*eg)(void)) { // com.github.dart_lang.jnigen.SuspendFun jclass _c_SuspendFun = NULL; -jmethodID _m_SuspendFun__ctor = NULL; +jmethodID _m_SuspendFun__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult SuspendFun__ctor() { +JniResult SuspendFun__new0() { load_env(); load_class_global_ref(&_c_SuspendFun, "com/github/dart_lang/jnigen/SuspendFun"); if (_c_SuspendFun == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_SuspendFun, &_m_SuspendFun__ctor, "", "()V"); - if (_m_SuspendFun__ctor == NULL) + load_method(_c_SuspendFun, &_m_SuspendFun__new0, "", "()V"); + if (_m_SuspendFun__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = - (*jniEnv)->NewObject(jniEnv, _c_SuspendFun, _m_SuspendFun__ctor); + (*jniEnv)->NewObject(jniEnv, _c_SuspendFun, _m_SuspendFun__new0); return to_global_ref_result(_result); } diff --git a/pkgs/jnigen/test/kotlin_test/c_based/dart_bindings/kotlin.dart b/pkgs/jnigen/test/kotlin_test/c_based/dart_bindings/kotlin.dart index 3e65d3b09..67c1e4d53 100644 --- a/pkgs/jnigen/test/kotlin_test/c_based/dart_bindings/kotlin.dart +++ b/pkgs/jnigen/test/kotlin_test/c_based/dart_bindings/kotlin.dart @@ -40,14 +40,14 @@ class SuspendFun extends jni.JObject { /// The type which includes information such as the signature of this class. static const type = $SuspendFunType(); - static final _ctor = jniLookup>( - "SuspendFun__ctor") + static final _new0 = jniLookup>( + "SuspendFun__new0") .asFunction(); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory SuspendFun() { - return SuspendFun.fromRef(_ctor().object); + return SuspendFun.fromRef(_new0().object); } static final _sayHello = jniLookup< diff --git a/pkgs/jnigen/test/kotlin_test/dart_only/dart_bindings/kotlin.dart b/pkgs/jnigen/test/kotlin_test/dart_only/dart_bindings/kotlin.dart index e4ceec3e6..9b9ce95fa 100644 --- a/pkgs/jnigen/test/kotlin_test/dart_only/dart_bindings/kotlin.dart +++ b/pkgs/jnigen/test/kotlin_test/dart_only/dart_bindings/kotlin.dart @@ -38,14 +38,14 @@ class SuspendFun extends jni.JObject { /// The type which includes information such as the signature of this class. static const type = $SuspendFunType(); - static final _id_ctor = + static final _id_new0 = jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory SuspendFun() { return SuspendFun.fromRef(jni.Jni.accessors - .newObjectWithArgs(_class.reference, _id_ctor, []).object); + .newObjectWithArgs(_class.reference, _id_new0, []).object); } static final _id_sayHello = jni.Jni.accessors.getMethodIDOf(_class.reference, diff --git a/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/simple_package.c b/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/simple_package.c index 9b6e5e10c..18621f8c9 100644 --- a/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/simple_package.c +++ b/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/simple_package.c @@ -402,89 +402,89 @@ JniResult Example__getRandomNumericString(jobject self_, jobject random) { return to_global_ref_result(_result); } -jmethodID _m_Example__ctor = NULL; +jmethodID _m_Example__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult Example__ctor() { +JniResult Example__new0() { load_env(); load_class_global_ref(&_c_Example, "com/github/dart_lang/jnigen/simple_package/Example"); if (_c_Example == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_Example, &_m_Example__ctor, "", "()V"); - if (_m_Example__ctor == NULL) + load_method(_c_Example, &_m_Example__new0, "", "()V"); + if (_m_Example__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Example, _m_Example__ctor); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Example, _m_Example__new0); return to_global_ref_result(_result); } -jmethodID _m_Example__ctor1 = NULL; +jmethodID _m_Example__new1 = NULL; FFI_PLUGIN_EXPORT -JniResult Example__ctor1(int32_t number) { +JniResult Example__new1(int32_t number) { load_env(); load_class_global_ref(&_c_Example, "com/github/dart_lang/jnigen/simple_package/Example"); if (_c_Example == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_Example, &_m_Example__ctor1, "", "(I)V"); - if (_m_Example__ctor1 == NULL) + load_method(_c_Example, &_m_Example__new1, "", "(I)V"); + if (_m_Example__new1 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = - (*jniEnv)->NewObject(jniEnv, _c_Example, _m_Example__ctor1, number); + (*jniEnv)->NewObject(jniEnv, _c_Example, _m_Example__new1, number); return to_global_ref_result(_result); } -jmethodID _m_Example__ctor2 = NULL; +jmethodID _m_Example__new2 = NULL; FFI_PLUGIN_EXPORT -JniResult Example__ctor2(int32_t number, uint8_t isUp) { +JniResult Example__new2(int32_t number, uint8_t isUp) { load_env(); load_class_global_ref(&_c_Example, "com/github/dart_lang/jnigen/simple_package/Example"); if (_c_Example == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_Example, &_m_Example__ctor2, "", "(IZ)V"); - if (_m_Example__ctor2 == NULL) + load_method(_c_Example, &_m_Example__new2, "", "(IZ)V"); + if (_m_Example__new2 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = - (*jniEnv)->NewObject(jniEnv, _c_Example, _m_Example__ctor2, number, isUp); + (*jniEnv)->NewObject(jniEnv, _c_Example, _m_Example__new2, number, isUp); return to_global_ref_result(_result); } -jmethodID _m_Example__ctor3 = NULL; +jmethodID _m_Example__new3 = NULL; FFI_PLUGIN_EXPORT -JniResult Example__ctor3(int32_t number, uint8_t isUp, jobject codename) { +JniResult Example__new3(int32_t number, uint8_t isUp, jobject codename) { load_env(); load_class_global_ref(&_c_Example, "com/github/dart_lang/jnigen/simple_package/Example"); if (_c_Example == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_Example, &_m_Example__ctor3, "", + load_method(_c_Example, &_m_Example__new3, "", "(IZLjava/lang/String;)V"); - if (_m_Example__ctor3 == NULL) + if (_m_Example__new3 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Example, _m_Example__ctor3, + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Example, _m_Example__new3, number, isUp, codename); return to_global_ref_result(_result); } -jmethodID _m_Example__ctor4 = NULL; +jmethodID _m_Example__new4 = NULL; FFI_PLUGIN_EXPORT -JniResult Example__ctor4(int32_t a, - int32_t b, - int32_t c, - int32_t d, - int32_t e, - int32_t f, - int32_t g, - int32_t h) { +JniResult Example__new4(int32_t a, + int32_t b, + int32_t c, + int32_t d, + int32_t e, + int32_t f, + int32_t g, + int32_t h) { load_env(); load_class_global_ref(&_c_Example, "com/github/dart_lang/jnigen/simple_package/Example"); if (_c_Example == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_Example, &_m_Example__ctor4, "", "(IIIIIIII)V"); - if (_m_Example__ctor4 == NULL) + load_method(_c_Example, &_m_Example__new4, "", "(IIIIIIII)V"); + if (_m_Example__new4 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Example, _m_Example__ctor4, + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Example, _m_Example__new4, a, b, c, d, e, f, g, h); return to_global_ref_result(_result); } @@ -590,20 +590,20 @@ JniResult Example__throwException() { // com.github.dart_lang.jnigen.simple_package.Example$Nested jclass _c_Example_Nested = NULL; -jmethodID _m_Example_Nested__ctor = NULL; +jmethodID _m_Example_Nested__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult Example_Nested__ctor(uint8_t value) { +JniResult Example_Nested__new0(uint8_t value) { load_env(); load_class_global_ref( &_c_Example_Nested, "com/github/dart_lang/jnigen/simple_package/Example$Nested"); if (_c_Example_Nested == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_Example_Nested, &_m_Example_Nested__ctor, "", "(Z)V"); - if (_m_Example_Nested__ctor == NULL) + load_method(_c_Example_Nested, &_m_Example_Nested__new0, "", "(Z)V"); + if (_m_Example_Nested__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Example_Nested, - _m_Example_Nested__ctor, value); + _m_Example_Nested__new0, value); return to_global_ref_result(_result); } @@ -663,9 +663,9 @@ JniResult Example_Nested__setValue(jobject self_, uint8_t value) { // com.github.dart_lang.jnigen.simple_package.Example$Nested$NestedTwice jclass _c_Example_Nested_NestedTwice = NULL; -jmethodID _m_Example_Nested_NestedTwice__ctor = NULL; +jmethodID _m_Example_Nested_NestedTwice__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult Example_Nested_NestedTwice__ctor() { +JniResult Example_Nested_NestedTwice__new0() { load_env(); load_class_global_ref( &_c_Example_Nested_NestedTwice, @@ -673,11 +673,11 @@ JniResult Example_Nested_NestedTwice__ctor() { if (_c_Example_Nested_NestedTwice == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method(_c_Example_Nested_NestedTwice, - &_m_Example_Nested_NestedTwice__ctor, "", "()V"); - if (_m_Example_Nested_NestedTwice__ctor == NULL) + &_m_Example_Nested_NestedTwice__new0, "", "()V"); + if (_m_Example_Nested_NestedTwice__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Example_Nested_NestedTwice, - _m_Example_Nested_NestedTwice__ctor); + _m_Example_Nested_NestedTwice__new0); return to_global_ref_result(_result); } @@ -716,56 +716,56 @@ JniResult set_Example_Nested_NestedTwice__ZERO(int32_t value) { // com.github.dart_lang.jnigen.simple_package.Exceptions jclass _c_Exceptions = NULL; -jmethodID _m_Exceptions__ctor = NULL; +jmethodID _m_Exceptions__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult Exceptions__ctor() { +JniResult Exceptions__new0() { load_env(); load_class_global_ref( &_c_Exceptions, "com/github/dart_lang/jnigen/simple_package/Exceptions"); if (_c_Exceptions == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_Exceptions, &_m_Exceptions__ctor, "", "()V"); - if (_m_Exceptions__ctor == NULL) + load_method(_c_Exceptions, &_m_Exceptions__new0, "", "()V"); + if (_m_Exceptions__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = - (*jniEnv)->NewObject(jniEnv, _c_Exceptions, _m_Exceptions__ctor); + (*jniEnv)->NewObject(jniEnv, _c_Exceptions, _m_Exceptions__new0); return to_global_ref_result(_result); } -jmethodID _m_Exceptions__ctor1 = NULL; +jmethodID _m_Exceptions__new1 = NULL; FFI_PLUGIN_EXPORT -JniResult Exceptions__ctor1(float x) { +JniResult Exceptions__new1(float x) { load_env(); load_class_global_ref( &_c_Exceptions, "com/github/dart_lang/jnigen/simple_package/Exceptions"); if (_c_Exceptions == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_Exceptions, &_m_Exceptions__ctor1, "", "(F)V"); - if (_m_Exceptions__ctor1 == NULL) + load_method(_c_Exceptions, &_m_Exceptions__new1, "", "(F)V"); + if (_m_Exceptions__new1 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = - (*jniEnv)->NewObject(jniEnv, _c_Exceptions, _m_Exceptions__ctor1, x); + (*jniEnv)->NewObject(jniEnv, _c_Exceptions, _m_Exceptions__new1, x); return to_global_ref_result(_result); } -jmethodID _m_Exceptions__ctor2 = NULL; +jmethodID _m_Exceptions__new2 = NULL; FFI_PLUGIN_EXPORT -JniResult Exceptions__ctor2(int32_t a, - int32_t b, - int32_t c, - int32_t d, - int32_t e, - int32_t f) { +JniResult Exceptions__new2(int32_t a, + int32_t b, + int32_t c, + int32_t d, + int32_t e, + int32_t f) { load_env(); load_class_global_ref( &_c_Exceptions, "com/github/dart_lang/jnigen/simple_package/Exceptions"); if (_c_Exceptions == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_Exceptions, &_m_Exceptions__ctor2, "", "(IIIIII)V"); - if (_m_Exceptions__ctor2 == NULL) + load_method(_c_Exceptions, &_m_Exceptions__new2, "", "(IIIIII)V"); + if (_m_Exceptions__new2 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - jobject _result = (*jniEnv)->NewObject( - jniEnv, _c_Exceptions, _m_Exceptions__ctor2, a, b, c, d, e, f); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Exceptions, + _m_Exceptions__new2, a, b, c, d, e, f); return to_global_ref_result(_result); } @@ -1009,18 +1009,18 @@ JniResult Exceptions__throwLoremIpsum() { // com.github.dart_lang.jnigen.simple_package.Fields jclass _c_Fields = NULL; -jmethodID _m_Fields__ctor = NULL; +jmethodID _m_Fields__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult Fields__ctor() { +JniResult Fields__new0() { load_env(); load_class_global_ref(&_c_Fields, "com/github/dart_lang/jnigen/simple_package/Fields"); if (_c_Fields == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_Fields, &_m_Fields__ctor, "", "()V"); - if (_m_Fields__ctor == NULL) + load_method(_c_Fields, &_m_Fields__new0, "", "()V"); + if (_m_Fields__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Fields, _m_Fields__ctor); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_Fields, _m_Fields__new0); return to_global_ref_result(_result); } @@ -1288,20 +1288,20 @@ JniResult set_Fields__euroSymbol(uint16_t value) { // com.github.dart_lang.jnigen.simple_package.Fields$Nested jclass _c_Fields_Nested = NULL; -jmethodID _m_Fields_Nested__ctor = NULL; +jmethodID _m_Fields_Nested__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult Fields_Nested__ctor() { +JniResult Fields_Nested__new0() { load_env(); load_class_global_ref( &_c_Fields_Nested, "com/github/dart_lang/jnigen/simple_package/Fields$Nested"); if (_c_Fields_Nested == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_Fields_Nested, &_m_Fields_Nested__ctor, "", "()V"); - if (_m_Fields_Nested__ctor == NULL) + load_method(_c_Fields_Nested, &_m_Fields_Nested__new0, "", "()V"); + if (_m_Fields_Nested__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = - (*jniEnv)->NewObject(jniEnv, _c_Fields_Nested, _m_Fields_Nested__ctor); + (*jniEnv)->NewObject(jniEnv, _c_Fields_Nested, _m_Fields_Nested__new0); return to_global_ref_result(_result); } @@ -1367,17 +1367,17 @@ JniResult set_Fields_Nested__BEST_GOD(jobject value) { // com.github.dart_lang.jnigen.pkg2.C2 jclass _c_C2 = NULL; -jmethodID _m_C2__ctor = NULL; +jmethodID _m_C2__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult C2__ctor() { +JniResult C2__new0() { load_env(); load_class_global_ref(&_c_C2, "com/github/dart_lang/jnigen/pkg2/C2"); if (_c_C2 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_C2, &_m_C2__ctor, "", "()V"); - if (_m_C2__ctor == NULL) + load_method(_c_C2, &_m_C2__new0, "", "()V"); + if (_m_C2__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - jobject _result = (*jniEnv)->NewObject(jniEnv, _c_C2, _m_C2__ctor); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_C2, _m_C2__new0); return to_global_ref_result(_result); } @@ -1408,19 +1408,19 @@ JniResult set_C2__CONSTANT(int32_t value) { // com.github.dart_lang.jnigen.pkg2.Example jclass _c_Example1 = NULL; -jmethodID _m_Example1__ctor = NULL; +jmethodID _m_Example1__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult Example1__ctor() { +JniResult Example1__new0() { load_env(); load_class_global_ref(&_c_Example1, "com/github/dart_lang/jnigen/pkg2/Example"); if (_c_Example1 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_Example1, &_m_Example1__ctor, "", "()V"); - if (_m_Example1__ctor == NULL) + load_method(_c_Example1, &_m_Example1__new0, "", "()V"); + if (_m_Example1__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = - (*jniEnv)->NewObject(jniEnv, _c_Example1, _m_Example1__ctor); + (*jniEnv)->NewObject(jniEnv, _c_Example1, _m_Example1__new0); return to_global_ref_result(_result); } @@ -1443,20 +1443,20 @@ JniResult Example1__whichExample(jobject self_) { // com.github.dart_lang.jnigen.generics.GrandParent jclass _c_GrandParent = NULL; -jmethodID _m_GrandParent__ctor = NULL; +jmethodID _m_GrandParent__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult GrandParent__ctor(jobject value) { +JniResult GrandParent__new0(jobject value) { load_env(); load_class_global_ref(&_c_GrandParent, "com/github/dart_lang/jnigen/generics/GrandParent"); if (_c_GrandParent == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_GrandParent, &_m_GrandParent__ctor, "", + load_method(_c_GrandParent, &_m_GrandParent__new0, "", "(Ljava/lang/Object;)V"); - if (_m_GrandParent__ctor == NULL) + if (_m_GrandParent__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = - (*jniEnv)->NewObject(jniEnv, _c_GrandParent, _m_GrandParent__ctor, value); + (*jniEnv)->NewObject(jniEnv, _c_GrandParent, _m_GrandParent__new0, value); return to_global_ref_result(_result); } @@ -1582,23 +1582,23 @@ JniResult set_GrandParent__value(jobject self_, jobject value) { // com.github.dart_lang.jnigen.generics.GrandParent$Parent jclass _c_GrandParent_Parent = NULL; -jmethodID _m_GrandParent_Parent__ctor = NULL; +jmethodID _m_GrandParent_Parent__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult GrandParent_Parent__ctor(jobject _parent, jobject newValue) { +JniResult GrandParent_Parent__new0(jobject _parent, jobject newValue) { load_env(); load_class_global_ref( &_c_GrandParent_Parent, "com/github/dart_lang/jnigen/generics/GrandParent$Parent"); if (_c_GrandParent_Parent == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_GrandParent_Parent, &_m_GrandParent_Parent__ctor, "", + load_method(_c_GrandParent_Parent, &_m_GrandParent_Parent__new0, "", "(Lcom/github/dart_lang/jnigen/generics/GrandParent;Ljava/lang/" "Object;)V"); - if (_m_GrandParent_Parent__ctor == NULL) + if (_m_GrandParent_Parent__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_GrandParent_Parent, - _m_GrandParent_Parent__ctor, _parent, newValue); + _m_GrandParent_Parent__new0, _parent, newValue); return to_global_ref_result(_result); } @@ -1666,23 +1666,23 @@ JniResult set_GrandParent_Parent__value(jobject self_, jobject value) { // com.github.dart_lang.jnigen.generics.GrandParent$Parent$Child jclass _c_GrandParent_Parent_Child = NULL; -jmethodID _m_GrandParent_Parent_Child__ctor = NULL; +jmethodID _m_GrandParent_Parent_Child__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult GrandParent_Parent_Child__ctor(jobject _parent, jobject newValue) { +JniResult GrandParent_Parent_Child__new0(jobject _parent, jobject newValue) { load_env(); load_class_global_ref( &_c_GrandParent_Parent_Child, "com/github/dart_lang/jnigen/generics/GrandParent$Parent$Child"); if (_c_GrandParent_Parent_Child == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_GrandParent_Parent_Child, &_m_GrandParent_Parent_Child__ctor, + load_method(_c_GrandParent_Parent_Child, &_m_GrandParent_Parent_Child__new0, "", "(Lcom/github/dart_lang/jnigen/generics/GrandParent$Parent;Ljava/" "lang/Object;)V"); - if (_m_GrandParent_Parent_Child__ctor == NULL) + if (_m_GrandParent_Parent_Child__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_GrandParent_Parent_Child, - _m_GrandParent_Parent_Child__ctor, + _m_GrandParent_Parent_Child__new0, _parent, newValue); return to_global_ref_result(_result); } @@ -1789,22 +1789,22 @@ JniResult set_GrandParent_Parent_Child__value(jobject self_, jobject value) { // com.github.dart_lang.jnigen.generics.GrandParent$StaticParent jclass _c_GrandParent_StaticParent = NULL; -jmethodID _m_GrandParent_StaticParent__ctor = NULL; +jmethodID _m_GrandParent_StaticParent__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult GrandParent_StaticParent__ctor(jobject value) { +JniResult GrandParent_StaticParent__new0(jobject value) { load_env(); load_class_global_ref( &_c_GrandParent_StaticParent, "com/github/dart_lang/jnigen/generics/GrandParent$StaticParent"); if (_c_GrandParent_StaticParent == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_GrandParent_StaticParent, &_m_GrandParent_StaticParent__ctor, + load_method(_c_GrandParent_StaticParent, &_m_GrandParent_StaticParent__new0, "", "(Ljava/lang/Object;)V"); - if (_m_GrandParent_StaticParent__ctor == NULL) + if (_m_GrandParent_StaticParent__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_GrandParent_StaticParent, - _m_GrandParent_StaticParent__ctor, value); + _m_GrandParent_StaticParent__new0, value); return to_global_ref_result(_result); } @@ -1842,9 +1842,9 @@ JniResult set_GrandParent_StaticParent__value(jobject self_, jobject value) { // com.github.dart_lang.jnigen.generics.GrandParent$StaticParent$Child jclass _c_GrandParent_StaticParent_Child = NULL; -jmethodID _m_GrandParent_StaticParent_Child__ctor = NULL; +jmethodID _m_GrandParent_StaticParent_Child__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult GrandParent_StaticParent_Child__ctor(jobject _parent, +JniResult GrandParent_StaticParent_Child__new0(jobject _parent, jobject parentValue, jobject value) { load_env(); @@ -1855,14 +1855,14 @@ JniResult GrandParent_StaticParent_Child__ctor(jobject _parent, return (JniResult){.value = {.j = 0}, .exception = check_exception()}; load_method( _c_GrandParent_StaticParent_Child, - &_m_GrandParent_StaticParent_Child__ctor, "", + &_m_GrandParent_StaticParent_Child__new0, "", "(Lcom/github/dart_lang/jnigen/generics/GrandParent$StaticParent;Ljava/" "lang/Object;Ljava/lang/Object;)V"); - if (_m_GrandParent_StaticParent_Child__ctor == NULL) + if (_m_GrandParent_StaticParent_Child__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject( jniEnv, _c_GrandParent_StaticParent_Child, - _m_GrandParent_StaticParent_Child__ctor, _parent, parentValue, value); + _m_GrandParent_StaticParent_Child__new0, _parent, parentValue, value); return to_global_ref_result(_result); } @@ -1937,18 +1937,18 @@ JniResult set_GrandParent_StaticParent_Child__value(jobject self_, // com.github.dart_lang.jnigen.generics.MyMap jclass _c_MyMap = NULL; -jmethodID _m_MyMap__ctor = NULL; +jmethodID _m_MyMap__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult MyMap__ctor() { +JniResult MyMap__new0() { load_env(); load_class_global_ref(&_c_MyMap, "com/github/dart_lang/jnigen/generics/MyMap"); if (_c_MyMap == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_MyMap, &_m_MyMap__ctor, "", "()V"); - if (_m_MyMap__ctor == NULL) + load_method(_c_MyMap, &_m_MyMap__new0, "", "()V"); + if (_m_MyMap__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - jobject _result = (*jniEnv)->NewObject(jniEnv, _c_MyMap, _m_MyMap__ctor); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_MyMap, _m_MyMap__new0); return to_global_ref_result(_result); } @@ -2006,21 +2006,21 @@ JniResult MyMap__entryStack(jobject self_) { // com.github.dart_lang.jnigen.generics.MyMap$MyEntry jclass _c_MyMap_MyEntry = NULL; -jmethodID _m_MyMap_MyEntry__ctor = NULL; +jmethodID _m_MyMap_MyEntry__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult MyMap_MyEntry__ctor(jobject _parent, jobject key, jobject value) { +JniResult MyMap_MyEntry__new0(jobject _parent, jobject key, jobject value) { load_env(); load_class_global_ref(&_c_MyMap_MyEntry, "com/github/dart_lang/jnigen/generics/MyMap$MyEntry"); if (_c_MyMap_MyEntry == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_MyMap_MyEntry, &_m_MyMap_MyEntry__ctor, "", + load_method(_c_MyMap_MyEntry, &_m_MyMap_MyEntry__new0, "", "(Lcom/github/dart_lang/jnigen/generics/MyMap;Ljava/lang/" "Object;Ljava/lang/Object;)V"); - if (_m_MyMap_MyEntry__ctor == NULL) + if (_m_MyMap_MyEntry__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject( - jniEnv, _c_MyMap_MyEntry, _m_MyMap_MyEntry__ctor, _parent, key, value); + jniEnv, _c_MyMap_MyEntry, _m_MyMap_MyEntry__new0, _parent, key, value); return to_global_ref_result(_result); } @@ -2083,18 +2083,18 @@ JniResult set_MyMap_MyEntry__value(jobject self_, jobject value) { // com.github.dart_lang.jnigen.generics.MyStack jclass _c_MyStack = NULL; -jmethodID _m_MyStack__ctor = NULL; +jmethodID _m_MyStack__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult MyStack__ctor() { +JniResult MyStack__new0() { load_env(); load_class_global_ref(&_c_MyStack, "com/github/dart_lang/jnigen/generics/MyStack"); if (_c_MyStack == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_MyStack, &_m_MyStack__ctor, "", "()V"); - if (_m_MyStack__ctor == NULL) + load_method(_c_MyStack, &_m_MyStack__new0, "", "()V"); + if (_m_MyStack__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - jobject _result = (*jniEnv)->NewObject(jniEnv, _c_MyStack, _m_MyStack__ctor); + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_MyStack, _m_MyStack__new0); return to_global_ref_result(_result); } @@ -2237,76 +2237,76 @@ JniResult MyStack__size(jobject self_) { // com.github.dart_lang.jnigen.generics.StringKeyedMap jclass _c_StringKeyedMap = NULL; -jmethodID _m_StringKeyedMap__ctor = NULL; +jmethodID _m_StringKeyedMap__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult StringKeyedMap__ctor() { +JniResult StringKeyedMap__new0() { load_env(); load_class_global_ref(&_c_StringKeyedMap, "com/github/dart_lang/jnigen/generics/StringKeyedMap"); if (_c_StringKeyedMap == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_StringKeyedMap, &_m_StringKeyedMap__ctor, "", "()V"); - if (_m_StringKeyedMap__ctor == NULL) + load_method(_c_StringKeyedMap, &_m_StringKeyedMap__new0, "", "()V"); + if (_m_StringKeyedMap__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = - (*jniEnv)->NewObject(jniEnv, _c_StringKeyedMap, _m_StringKeyedMap__ctor); + (*jniEnv)->NewObject(jniEnv, _c_StringKeyedMap, _m_StringKeyedMap__new0); return to_global_ref_result(_result); } // com.github.dart_lang.jnigen.generics.StringMap jclass _c_StringMap = NULL; -jmethodID _m_StringMap__ctor = NULL; +jmethodID _m_StringMap__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult StringMap__ctor() { +JniResult StringMap__new0() { load_env(); load_class_global_ref(&_c_StringMap, "com/github/dart_lang/jnigen/generics/StringMap"); if (_c_StringMap == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_StringMap, &_m_StringMap__ctor, "", "()V"); - if (_m_StringMap__ctor == NULL) + load_method(_c_StringMap, &_m_StringMap__new0, "", "()V"); + if (_m_StringMap__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = - (*jniEnv)->NewObject(jniEnv, _c_StringMap, _m_StringMap__ctor); + (*jniEnv)->NewObject(jniEnv, _c_StringMap, _m_StringMap__new0); return to_global_ref_result(_result); } // com.github.dart_lang.jnigen.generics.StringStack jclass _c_StringStack = NULL; -jmethodID _m_StringStack__ctor = NULL; +jmethodID _m_StringStack__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult StringStack__ctor() { +JniResult StringStack__new0() { load_env(); load_class_global_ref(&_c_StringStack, "com/github/dart_lang/jnigen/generics/StringStack"); if (_c_StringStack == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_StringStack, &_m_StringStack__ctor, "", "()V"); - if (_m_StringStack__ctor == NULL) + load_method(_c_StringStack, &_m_StringStack__new0, "", "()V"); + if (_m_StringStack__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = - (*jniEnv)->NewObject(jniEnv, _c_StringStack, _m_StringStack__ctor); + (*jniEnv)->NewObject(jniEnv, _c_StringStack, _m_StringStack__new0); return to_global_ref_result(_result); } // com.github.dart_lang.jnigen.generics.StringValuedMap jclass _c_StringValuedMap = NULL; -jmethodID _m_StringValuedMap__ctor = NULL; +jmethodID _m_StringValuedMap__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult StringValuedMap__ctor() { +JniResult StringValuedMap__new0() { load_env(); load_class_global_ref(&_c_StringValuedMap, "com/github/dart_lang/jnigen/generics/StringValuedMap"); if (_c_StringValuedMap == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_StringValuedMap, &_m_StringValuedMap__ctor, "", "()V"); - if (_m_StringValuedMap__ctor == NULL) + load_method(_c_StringValuedMap, &_m_StringValuedMap__new0, "", "()V"); + if (_m_StringValuedMap__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_StringValuedMap, - _m_StringValuedMap__ctor); + _m_StringValuedMap__new0); return to_global_ref_result(_result); } @@ -2387,21 +2387,21 @@ JniResult MyInterface__manyPrimitives(jobject self_, // com.github.dart_lang.jnigen.interfaces.MyInterfaceConsumer jclass _c_MyInterfaceConsumer = NULL; -jmethodID _m_MyInterfaceConsumer__ctor = NULL; +jmethodID _m_MyInterfaceConsumer__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult MyInterfaceConsumer__ctor() { +JniResult MyInterfaceConsumer__new0() { load_env(); load_class_global_ref( &_c_MyInterfaceConsumer, "com/github/dart_lang/jnigen/interfaces/MyInterfaceConsumer"); if (_c_MyInterfaceConsumer == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_MyInterfaceConsumer, &_m_MyInterfaceConsumer__ctor, "", + load_method(_c_MyInterfaceConsumer, &_m_MyInterfaceConsumer__new0, "", "()V"); - if (_m_MyInterfaceConsumer__ctor == NULL) + if (_m_MyInterfaceConsumer__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = (*jniEnv)->NewObject(jniEnv, _c_MyInterfaceConsumer, - _m_MyInterfaceConsumer__ctor); + _m_MyInterfaceConsumer__new0); return to_global_ref_result(_result); } @@ -2508,18 +2508,18 @@ JniResult JsonSerializable_Case__valueOf(jobject name) { // com.github.dart_lang.jnigen.annotations.MyDataClass jclass _c_MyDataClass = NULL; -jmethodID _m_MyDataClass__ctor = NULL; +jmethodID _m_MyDataClass__new0 = NULL; FFI_PLUGIN_EXPORT -JniResult MyDataClass__ctor() { +JniResult MyDataClass__new0() { load_env(); load_class_global_ref(&_c_MyDataClass, "com/github/dart_lang/jnigen/annotations/MyDataClass"); if (_c_MyDataClass == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; - load_method(_c_MyDataClass, &_m_MyDataClass__ctor, "", "()V"); - if (_m_MyDataClass__ctor == NULL) + load_method(_c_MyDataClass, &_m_MyDataClass__new0, "", "()V"); + if (_m_MyDataClass__new0 == NULL) return (JniResult){.value = {.j = 0}, .exception = check_exception()}; jobject _result = - (*jniEnv)->NewObject(jniEnv, _c_MyDataClass, _m_MyDataClass__ctor); + (*jniEnv)->NewObject(jniEnv, _c_MyDataClass, _m_MyDataClass__new0); return to_global_ref_result(_result); } diff --git a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart index cbc1b2132..10e399064 100644 --- a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart @@ -359,77 +359,70 @@ class Example extends jni.JObject { .fromRef(_getRandomNumericString(reference, random.reference).object); } - static final _ctor = - jniLookup>("Example__ctor") + static final _new0 = + jniLookup>("Example__new0") .asFunction(); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory Example() { - return Example.fromRef(_ctor().object); + return Example.fromRef(_new0().object); } - static final _ctor1 = + static final _new1 = jniLookup>( - "Example__ctor1") + "Example__new1") .asFunction(); /// from: public void (int number) /// The returned object must be deleted after use, by calling the `delete` method. - factory Example.ctor1( + factory Example.new1( int number, ) { - return Example.fromRef(_ctor1(number).object); + return Example.fromRef(_new1(number).object); } - static final _ctor2 = jniLookup< + static final _new2 = jniLookup< ffi.NativeFunction>( - "Example__ctor2") + "Example__new2") .asFunction(); /// from: public void (int number, boolean isUp) /// The returned object must be deleted after use, by calling the `delete` method. - factory Example.ctor2( + factory Example.new2( int number, bool isUp, ) { - return Example.fromRef(_ctor2(number, isUp ? 1 : 0).object); + return Example.fromRef(_new2(number, isUp ? 1 : 0).object); } - static final _ctor3 = jniLookup< + static final _new3 = jniLookup< ffi.NativeFunction< jni.JniResult Function(ffi.Int32, ffi.Uint8, - ffi.Pointer)>>("Example__ctor3") + ffi.Pointer)>>("Example__new3") .asFunction)>(); /// from: public void (int number, boolean isUp, java.lang.String codename) /// The returned object must be deleted after use, by calling the `delete` method. - factory Example.ctor3( + factory Example.new3( int number, bool isUp, jni.JString codename, ) { return Example.fromRef( - _ctor3(number, isUp ? 1 : 0, codename.reference).object); + _new3(number, isUp ? 1 : 0, codename.reference).object); } - static final _ctor4 = jniLookup< + static final _new4 = jniLookup< ffi.NativeFunction< - jni.JniResult Function( - ffi.Int32, - ffi.Int32, - ffi.Int32, - ffi.Int32, - ffi.Int32, - ffi.Int32, - ffi.Int32, - ffi.Int32)>>("Example__ctor4") + jni.JniResult Function(ffi.Int32, ffi.Int32, ffi.Int32, ffi.Int32, + ffi.Int32, ffi.Int32, ffi.Int32, ffi.Int32)>>("Example__new4") .asFunction< jni.JniResult Function(int, int, int, int, int, int, int, int)>(); /// from: public void (int a, int b, int c, int d, int e, int f, int g, int h) /// The returned object must be deleted after use, by calling the `delete` method. - factory Example.ctor4( + factory Example.new4( int a, int b, int c, @@ -439,7 +432,7 @@ class Example extends jni.JObject { int g, int h, ) { - return Example.fromRef(_ctor4(a, b, c, d, e, f, g, h).object); + return Example.fromRef(_new4(a, b, c, d, e, f, g, h).object); } static final _whichExample = jniLookup< @@ -548,9 +541,9 @@ class Example_Nested extends jni.JObject { /// The type which includes information such as the signature of this class. static const type = $Example_NestedType(); - static final _ctor = + static final _new0 = jniLookup>( - "Example_Nested__ctor") + "Example_Nested__new0") .asFunction(); /// from: public void (boolean value) @@ -558,7 +551,7 @@ class Example_Nested extends jni.JObject { factory Example_Nested( bool value, ) { - return Example_Nested.fromRef(_ctor(value ? 1 : 0).object); + return Example_Nested.fromRef(_new0(value ? 1 : 0).object); } static final _usesAnonymousInnerClass = jniLookup< @@ -650,14 +643,14 @@ class Example_Nested_NestedTwice extends jni.JObject { /// from: static public int ZERO static set ZERO(int value) => _set_ZERO(value).check(); - static final _ctor = jniLookup>( - "Example_Nested_NestedTwice__ctor") + static final _new0 = jniLookup>( + "Example_Nested_NestedTwice__new0") .asFunction(); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory Example_Nested_NestedTwice() { - return Example_Nested_NestedTwice.fromRef(_ctor().object); + return Example_Nested_NestedTwice.fromRef(_new0().object); } } @@ -700,38 +693,38 @@ class Exceptions extends jni.JObject { /// The type which includes information such as the signature of this class. static const type = $ExceptionsType(); - static final _ctor = jniLookup>( - "Exceptions__ctor") + static final _new0 = jniLookup>( + "Exceptions__new0") .asFunction(); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory Exceptions() { - return Exceptions.fromRef(_ctor().object); + return Exceptions.fromRef(_new0().object); } - static final _ctor1 = + static final _new1 = jniLookup>( - "Exceptions__ctor1") + "Exceptions__new1") .asFunction(); /// from: public void (float x) /// The returned object must be deleted after use, by calling the `delete` method. - factory Exceptions.ctor1( + factory Exceptions.new1( double x, ) { - return Exceptions.fromRef(_ctor1(x).object); + return Exceptions.fromRef(_new1(x).object); } - static final _ctor2 = jniLookup< + static final _new2 = jniLookup< ffi.NativeFunction< jni.JniResult Function(ffi.Int32, ffi.Int32, ffi.Int32, ffi.Int32, - ffi.Int32, ffi.Int32)>>("Exceptions__ctor2") + ffi.Int32, ffi.Int32)>>("Exceptions__new2") .asFunction(); /// from: public void (int a, int b, int c, int d, int e, int f) /// The returned object must be deleted after use, by calling the `delete` method. - factory Exceptions.ctor2( + factory Exceptions.new2( int a, int b, int c, @@ -739,7 +732,7 @@ class Exceptions extends jni.JObject { int e, int f, ) { - return Exceptions.fromRef(_ctor2(a, b, c, d, e, f).object); + return Exceptions.fromRef(_new2(a, b, c, d, e, f).object); } static final _staticObjectMethod = @@ -1150,14 +1143,14 @@ class Fields extends jni.JObject { /// from: static public char euroSymbol static set euroSymbol(int value) => _set_euroSymbol(value).check(); - static final _ctor = - jniLookup>("Fields__ctor") + static final _new0 = + jniLookup>("Fields__new0") .asFunction(); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory Fields() { - return Fields.fromRef(_ctor().object); + return Fields.fromRef(_new0().object); } } @@ -1240,14 +1233,14 @@ class Fields_Nested extends jni.JObject { static set BEST_GOD(jni.JString value) => _set_BEST_GOD(value.reference).check(); - static final _ctor = jniLookup>( - "Fields_Nested__ctor") + static final _new0 = jniLookup>( + "Fields_Nested__new0") .asFunction(); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory Fields_Nested() { - return Fields_Nested.fromRef(_ctor().object); + return Fields_Nested.fromRef(_new0().object); } } @@ -1304,14 +1297,14 @@ class C2 extends jni.JObject { /// from: static public int CONSTANT static set CONSTANT(int value) => _set_CONSTANT(value).check(); - static final _ctor = - jniLookup>("C2__ctor") + static final _new0 = + jniLookup>("C2__new0") .asFunction(); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory C2() { - return C2.fromRef(_ctor().object); + return C2.fromRef(_new0().object); } } @@ -1350,14 +1343,14 @@ class Example1 extends jni.JObject { /// The type which includes information such as the signature of this class. static const type = $Example1Type(); - static final _ctor = - jniLookup>("Example1__ctor") + static final _new0 = + jniLookup>("Example1__new0") .asFunction(); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory Example1() { - return Example1.fromRef(_ctor().object); + return Example1.fromRef(_new0().object); } static final _whichExample = jniLookup< @@ -1442,10 +1435,10 @@ class GrandParent<$T extends jni.JObject> extends jni.JObject { /// The returned object must be deleted after use, by calling the `delete` method. set value($T value) => _set_value(reference, value.reference).check(); - static final _ctor = jniLookup< + static final _new0 = jniLookup< ffi .NativeFunction)>>( - "GrandParent__ctor") + "GrandParent__new0") .asFunction)>(); /// from: public void (T value) @@ -1457,7 +1450,7 @@ class GrandParent<$T extends jni.JObject> extends jni.JObject { T ??= jni.lowestCommonSuperType([ value.$type, ]) as jni.JObjType<$T>; - return GrandParent.fromRef(T, _ctor(value.reference).object); + return GrandParent.fromRef(T, _new0(value.reference).object); } static final _stringParent = jniLookup< @@ -1649,10 +1642,10 @@ class GrandParent_Parent<$T extends jni.JObject, $S extends jni.JObject> /// The returned object must be deleted after use, by calling the `delete` method. set value($S value) => _set_value(reference, value.reference).check(); - static final _ctor = jniLookup< + static final _new0 = jniLookup< ffi.NativeFunction< jni.JniResult Function(ffi.Pointer, - ffi.Pointer)>>("GrandParent_Parent__ctor") + ffi.Pointer)>>("GrandParent_Parent__new0") .asFunction< jni.JniResult Function( ffi.Pointer, ffi.Pointer)>(); @@ -1672,7 +1665,7 @@ class GrandParent_Parent<$T extends jni.JObject, $S extends jni.JObject> newValue.$type, ]) as jni.JObjType<$S>; return GrandParent_Parent.fromRef( - T, S, _ctor($parent.reference, newValue.reference).object); + T, S, _new0($parent.reference, newValue.reference).object); } } @@ -1824,10 +1817,10 @@ class GrandParent_Parent_Child<$T extends jni.JObject, $S extends jni.JObject, /// The returned object must be deleted after use, by calling the `delete` method. set value($U value) => _set_value(reference, value.reference).check(); - static final _ctor = jniLookup< + static final _new0 = jniLookup< ffi.NativeFunction< jni.JniResult Function(ffi.Pointer, - ffi.Pointer)>>("GrandParent_Parent_Child__ctor") + ffi.Pointer)>>("GrandParent_Parent_Child__new0") .asFunction< jni.JniResult Function( ffi.Pointer, ffi.Pointer)>(); @@ -1851,7 +1844,7 @@ class GrandParent_Parent_Child<$T extends jni.JObject, $S extends jni.JObject, newValue.$type, ]) as jni.JObjType<$U>; return GrandParent_Parent_Child.fromRef( - T, S, U, _ctor($parent.reference, newValue.reference).object); + T, S, U, _new0($parent.reference, newValue.reference).object); } } @@ -1942,10 +1935,10 @@ class GrandParent_StaticParent<$S extends jni.JObject> extends jni.JObject { /// The returned object must be deleted after use, by calling the `delete` method. set value($S value) => _set_value(reference, value.reference).check(); - static final _ctor = jniLookup< + static final _new0 = jniLookup< ffi .NativeFunction)>>( - "GrandParent_StaticParent__ctor") + "GrandParent_StaticParent__new0") .asFunction)>(); /// from: public void (S value) @@ -1957,7 +1950,7 @@ class GrandParent_StaticParent<$S extends jni.JObject> extends jni.JObject { S ??= jni.lowestCommonSuperType([ value.$type, ]) as jni.JObjType<$S>; - return GrandParent_StaticParent.fromRef(S, _ctor(value.reference).object); + return GrandParent_StaticParent.fromRef(S, _new0(value.reference).object); } } @@ -2075,11 +2068,11 @@ class GrandParent_StaticParent_Child<$S extends jni.JObject, /// The returned object must be deleted after use, by calling the `delete` method. set value($U value) => _set_value(reference, value.reference).check(); - static final _ctor = jniLookup< + static final _new0 = jniLookup< ffi.NativeFunction< jni.JniResult Function(ffi.Pointer, ffi.Pointer, ffi.Pointer)>>( - "GrandParent_StaticParent_Child__ctor") + "GrandParent_StaticParent_Child__new0") .asFunction< jni.JniResult Function(ffi.Pointer, ffi.Pointer, ffi.Pointer)>(); @@ -2103,7 +2096,7 @@ class GrandParent_StaticParent_Child<$S extends jni.JObject, return GrandParent_StaticParent_Child.fromRef( S, U, - _ctor($parent.reference, parentValue.reference, value.reference) + _new0($parent.reference, parentValue.reference, value.reference) .object); } } @@ -2172,8 +2165,8 @@ class MyMap<$K extends jni.JObject, $V extends jni.JObject> ); } - static final _ctor = - jniLookup>("MyMap__ctor") + static final _new0 = + jniLookup>("MyMap__new0") .asFunction(); /// from: public void () @@ -2182,7 +2175,7 @@ class MyMap<$K extends jni.JObject, $V extends jni.JObject> required jni.JObjType<$K> K, required jni.JObjType<$V> V, }) { - return MyMap.fromRef(K, V, _ctor().object); + return MyMap.fromRef(K, V, _new0().object); } static final _get0 = jniLookup< @@ -2344,12 +2337,12 @@ class MyMap_MyEntry<$K extends jni.JObject, $V extends jni.JObject> /// The returned object must be deleted after use, by calling the `delete` method. set value($V value) => _set_value(reference, value.reference).check(); - static final _ctor = jniLookup< + static final _new0 = jniLookup< ffi.NativeFunction< jni.JniResult Function( ffi.Pointer, ffi.Pointer, - ffi.Pointer)>>("MyMap_MyEntry__ctor") + ffi.Pointer)>>("MyMap_MyEntry__new0") .asFunction< jni.JniResult Function(ffi.Pointer, ffi.Pointer, ffi.Pointer)>(); @@ -2372,7 +2365,7 @@ class MyMap_MyEntry<$K extends jni.JObject, $V extends jni.JObject> ($parent.$type as $MyMapType).V, ]) as jni.JObjType<$V>; return MyMap_MyEntry.fromRef( - K, V, _ctor($parent.reference, key.reference, value.reference).object); + K, V, _new0($parent.reference, key.reference, value.reference).object); } } @@ -2433,8 +2426,8 @@ class MyStack<$T extends jni.JObject> extends jni.JObject { ); } - static final _ctor = - jniLookup>("MyStack__ctor") + static final _new0 = + jniLookup>("MyStack__new0") .asFunction(); /// from: public void () @@ -2442,7 +2435,7 @@ class MyStack<$T extends jni.JObject> extends jni.JObject { factory MyStack({ required jni.JObjType<$T> T, }) { - return MyStack.fromRef(T, _ctor().object); + return MyStack.fromRef(T, _new0().object); } static final _fromArray = jniLookup< @@ -2627,8 +2620,8 @@ class StringKeyedMap<$V extends jni.JObject> extends MyMap { ); } - static final _ctor = jniLookup>( - "StringKeyedMap__ctor") + static final _new0 = jniLookup>( + "StringKeyedMap__new0") .asFunction(); /// from: public void () @@ -2636,7 +2629,7 @@ class StringKeyedMap<$V extends jni.JObject> extends MyMap { factory StringKeyedMap({ required jni.JObjType<$V> V, }) { - return StringKeyedMap.fromRef(V, _ctor().object); + return StringKeyedMap.fromRef(V, _new0().object); } } @@ -2684,14 +2677,14 @@ class StringMap extends StringKeyedMap { /// The type which includes information such as the signature of this class. static const type = $StringMapType(); - static final _ctor = - jniLookup>("StringMap__ctor") + static final _new0 = + jniLookup>("StringMap__new0") .asFunction(); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory StringMap() { - return StringMap.fromRef(_ctor().object); + return StringMap.fromRef(_new0().object); } } @@ -2730,14 +2723,14 @@ class StringStack extends MyStack { /// The type which includes information such as the signature of this class. static const type = $StringStackType(); - static final _ctor = jniLookup>( - "StringStack__ctor") + static final _new0 = jniLookup>( + "StringStack__new0") .asFunction(); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory StringStack() { - return StringStack.fromRef(_ctor().object); + return StringStack.fromRef(_new0().object); } } @@ -2786,8 +2779,8 @@ class StringValuedMap<$K extends jni.JObject> extends MyMap<$K, jni.JString> { ); } - static final _ctor = jniLookup>( - "StringValuedMap__ctor") + static final _new0 = jniLookup>( + "StringValuedMap__new0") .asFunction(); /// from: public void () @@ -2795,7 +2788,7 @@ class StringValuedMap<$K extends jni.JObject> extends MyMap<$K, jni.JString> { factory StringValuedMap({ required jni.JObjType<$K> K, }) { - return StringValuedMap.fromRef(K, _ctor().object); + return StringValuedMap.fromRef(K, _new0().object); } } @@ -3128,14 +3121,14 @@ class MyInterfaceConsumer extends jni.JObject { /// The type which includes information such as the signature of this class. static const type = $MyInterfaceConsumerType(); - static final _ctor = jniLookup>( - "MyInterfaceConsumer__ctor") + static final _new0 = jniLookup>( + "MyInterfaceConsumer__new0") .asFunction(); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory MyInterfaceConsumer() { - return MyInterfaceConsumer.fromRef(_ctor().object); + return MyInterfaceConsumer.fromRef(_new0().object); } static final _consumeOnAnotherThread = jniLookup< @@ -3313,14 +3306,14 @@ class MyDataClass extends jni.JObject { /// The type which includes information such as the signature of this class. static const type = $MyDataClassType(); - static final _ctor = jniLookup>( - "MyDataClass__ctor") + static final _new0 = jniLookup>( + "MyDataClass__new0") .asFunction(); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory MyDataClass() { - return MyDataClass.fromRef(_ctor().object); + return MyDataClass.fromRef(_new0().object); } } diff --git a/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart index bfe2a16f0..e3667c161 100644 --- a/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart @@ -332,63 +332,63 @@ class Example extends jni.JObject { [random.reference]).object); } - static final _id_ctor = + static final _id_new0 = jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory Example() { return Example.fromRef(jni.Jni.accessors - .newObjectWithArgs(_class.reference, _id_ctor, []).object); + .newObjectWithArgs(_class.reference, _id_new0, []).object); } - static final _id_ctor1 = + static final _id_new1 = jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"(I)V"); /// from: public void (int number) /// The returned object must be deleted after use, by calling the `delete` method. - factory Example.ctor1( + factory Example.new1( int number, ) { return Example.fromRef(jni.Jni.accessors.newObjectWithArgs( - _class.reference, _id_ctor1, [jni.JValueInt(number)]).object); + _class.reference, _id_new1, [jni.JValueInt(number)]).object); } - static final _id_ctor2 = + static final _id_new2 = jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"(IZ)V"); /// from: public void (int number, boolean isUp) /// The returned object must be deleted after use, by calling the `delete` method. - factory Example.ctor2( + factory Example.new2( int number, bool isUp, ) { return Example.fromRef(jni.Jni.accessors.newObjectWithArgs(_class.reference, - _id_ctor2, [jni.JValueInt(number), isUp ? 1 : 0]).object); + _id_new2, [jni.JValueInt(number), isUp ? 1 : 0]).object); } - static final _id_ctor3 = jni.Jni.accessors + static final _id_new3 = jni.Jni.accessors .getMethodIDOf(_class.reference, r"", r"(IZLjava/lang/String;)V"); /// from: public void (int number, boolean isUp, java.lang.String codename) /// The returned object must be deleted after use, by calling the `delete` method. - factory Example.ctor3( + factory Example.new3( int number, bool isUp, jni.JString codename, ) { return Example.fromRef(jni.Jni.accessors.newObjectWithArgs( _class.reference, - _id_ctor3, + _id_new3, [jni.JValueInt(number), isUp ? 1 : 0, codename.reference]).object); } - static final _id_ctor4 = jni.Jni.accessors + static final _id_new4 = jni.Jni.accessors .getMethodIDOf(_class.reference, r"", r"(IIIIIIII)V"); /// from: public void (int a, int b, int c, int d, int e, int f, int g, int h) /// The returned object must be deleted after use, by calling the `delete` method. - factory Example.ctor4( + factory Example.new4( int a, int b, int c, @@ -399,7 +399,7 @@ class Example extends jni.JObject { int h, ) { return Example.fromRef( - jni.Jni.accessors.newObjectWithArgs(_class.reference, _id_ctor4, [ + jni.Jni.accessors.newObjectWithArgs(_class.reference, _id_new4, [ jni.JValueInt(a), jni.JValueInt(b), jni.JValueInt(c), @@ -516,7 +516,7 @@ class Example_Nested extends jni.JObject { /// The type which includes information such as the signature of this class. static const type = $Example_NestedType(); - static final _id_ctor = + static final _id_new0 = jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"(Z)V"); /// from: public void (boolean value) @@ -525,7 +525,7 @@ class Example_Nested extends jni.JObject { bool value, ) { return Example_Nested.fromRef(jni.Jni.accessors - .newObjectWithArgs(_class.reference, _id_ctor, [value ? 1 : 0]).object); + .newObjectWithArgs(_class.reference, _id_new0, [value ? 1 : 0]).object); } static final _id_usesAnonymousInnerClass = jni.Jni.accessors @@ -613,14 +613,14 @@ class Example_Nested_NestedTwice extends jni.JObject { static set ZERO(int value) => jni.Jni.env.SetStaticIntField(_class.reference, _id_ZERO, value); - static final _id_ctor = + static final _id_new0 = jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory Example_Nested_NestedTwice() { return Example_Nested_NestedTwice.fromRef(jni.Jni.accessors - .newObjectWithArgs(_class.reference, _id_ctor, []).object); + .newObjectWithArgs(_class.reference, _id_new0, []).object); } } @@ -666,34 +666,34 @@ class Exceptions extends jni.JObject { /// The type which includes information such as the signature of this class. static const type = $ExceptionsType(); - static final _id_ctor = + static final _id_new0 = jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory Exceptions() { return Exceptions.fromRef(jni.Jni.accessors - .newObjectWithArgs(_class.reference, _id_ctor, []).object); + .newObjectWithArgs(_class.reference, _id_new0, []).object); } - static final _id_ctor1 = + static final _id_new1 = jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"(F)V"); /// from: public void (float x) /// The returned object must be deleted after use, by calling the `delete` method. - factory Exceptions.ctor1( + factory Exceptions.new1( double x, ) { return Exceptions.fromRef(jni.Jni.accessors.newObjectWithArgs( - _class.reference, _id_ctor1, [jni.JValueFloat(x)]).object); + _class.reference, _id_new1, [jni.JValueFloat(x)]).object); } - static final _id_ctor2 = jni.Jni.accessors + static final _id_new2 = jni.Jni.accessors .getMethodIDOf(_class.reference, r"", r"(IIIIII)V"); /// from: public void (int a, int b, int c, int d, int e, int f) /// The returned object must be deleted after use, by calling the `delete` method. - factory Exceptions.ctor2( + factory Exceptions.new2( int a, int b, int c, @@ -702,7 +702,7 @@ class Exceptions extends jni.JObject { int f, ) { return Exceptions.fromRef( - jni.Jni.accessors.newObjectWithArgs(_class.reference, _id_ctor2, [ + jni.Jni.accessors.newObjectWithArgs(_class.reference, _id_new2, [ jni.JValueInt(a), jni.JValueInt(b), jni.JValueInt(c), @@ -1061,14 +1061,14 @@ class Fields extends jni.JObject { static set euroSymbol(int value) => jni.Jni.env.SetStaticCharField(_class.reference, _id_euroSymbol, value); - static final _id_ctor = + static final _id_new0 = jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory Fields() { return Fields.fromRef(jni.Jni.accessors - .newObjectWithArgs(_class.reference, _id_ctor, []).object); + .newObjectWithArgs(_class.reference, _id_new0, []).object); } } @@ -1145,14 +1145,14 @@ class Fields_Nested extends jni.JObject { static set BEST_GOD(jni.JString value) => jni.Jni.env .SetStaticObjectField(_class.reference, _id_BEST_GOD, value.reference); - static final _id_ctor = + static final _id_new0 = jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory Fields_Nested() { return Fields_Nested.fromRef(jni.Jni.accessors - .newObjectWithArgs(_class.reference, _id_ctor, []).object); + .newObjectWithArgs(_class.reference, _id_new0, []).object); } } @@ -1211,14 +1211,14 @@ class C2 extends jni.JObject { static set CONSTANT(int value) => jni.Jni.env.SetStaticIntField(_class.reference, _id_CONSTANT, value); - static final _id_ctor = + static final _id_new0 = jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory C2() { return C2.fromRef(jni.Jni.accessors - .newObjectWithArgs(_class.reference, _id_ctor, []).object); + .newObjectWithArgs(_class.reference, _id_new0, []).object); } } @@ -1260,14 +1260,14 @@ class Example1 extends jni.JObject { /// The type which includes information such as the signature of this class. static const type = $Example1Type(); - static final _id_ctor = + static final _id_new0 = jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory Example1() { return Example1.fromRef(jni.Jni.accessors - .newObjectWithArgs(_class.reference, _id_ctor, []).object); + .newObjectWithArgs(_class.reference, _id_new0, []).object); } static final _id_whichExample = jni.Jni.accessors @@ -1345,7 +1345,7 @@ class GrandParent<$T extends jni.JObject> extends jni.JObject { set value($T value) => jni.Jni.env.SetObjectField(reference, _id_value, value.reference); - static final _id_ctor = jni.Jni.accessors + static final _id_new0 = jni.Jni.accessors .getMethodIDOf(_class.reference, r"", r"(Ljava/lang/Object;)V"); /// from: public void (T value) @@ -1360,7 +1360,7 @@ class GrandParent<$T extends jni.JObject> extends jni.JObject { return GrandParent.fromRef( T, jni.Jni.accessors.newObjectWithArgs( - _class.reference, _id_ctor, [value.reference]).object); + _class.reference, _id_new0, [value.reference]).object); } static final _id_stringParent = jni.Jni.accessors.getMethodIDOf( @@ -1536,7 +1536,7 @@ class GrandParent_Parent<$T extends jni.JObject, $S extends jni.JObject> set value($S value) => jni.Jni.env.SetObjectField(reference, _id_value, value.reference); - static final _id_ctor = jni.Jni.accessors.getMethodIDOf( + static final _id_new0 = jni.Jni.accessors.getMethodIDOf( _class.reference, r"", r"(Lcom/github/dart_lang/jnigen/generics/GrandParent;Ljava/lang/Object;)V"); @@ -1558,7 +1558,7 @@ class GrandParent_Parent<$T extends jni.JObject, $S extends jni.JObject> return GrandParent_Parent.fromRef( T, S, - jni.Jni.accessors.newObjectWithArgs(_class.reference, _id_ctor, + jni.Jni.accessors.newObjectWithArgs(_class.reference, _id_new0, [$parent.reference, newValue.reference]).object); } } @@ -1685,7 +1685,7 @@ class GrandParent_Parent_Child<$T extends jni.JObject, $S extends jni.JObject, set value($U value) => jni.Jni.env.SetObjectField(reference, _id_value, value.reference); - static final _id_ctor = jni.Jni.accessors.getMethodIDOf( + static final _id_new0 = jni.Jni.accessors.getMethodIDOf( _class.reference, r"", r"(Lcom/github/dart_lang/jnigen/generics/GrandParent$Parent;Ljava/lang/Object;)V"); @@ -1712,7 +1712,7 @@ class GrandParent_Parent_Child<$T extends jni.JObject, $S extends jni.JObject, T, S, U, - jni.Jni.accessors.newObjectWithArgs(_class.reference, _id_ctor, + jni.Jni.accessors.newObjectWithArgs(_class.reference, _id_new0, [$parent.reference, newValue.reference]).object); } } @@ -1798,7 +1798,7 @@ class GrandParent_StaticParent<$S extends jni.JObject> extends jni.JObject { set value($S value) => jni.Jni.env.SetObjectField(reference, _id_value, value.reference); - static final _id_ctor = jni.Jni.accessors + static final _id_new0 = jni.Jni.accessors .getMethodIDOf(_class.reference, r"", r"(Ljava/lang/Object;)V"); /// from: public void (S value) @@ -1813,7 +1813,7 @@ class GrandParent_StaticParent<$S extends jni.JObject> extends jni.JObject { return GrandParent_StaticParent.fromRef( S, jni.Jni.accessors.newObjectWithArgs( - _class.reference, _id_ctor, [value.reference]).object); + _class.reference, _id_new0, [value.reference]).object); } } @@ -1915,7 +1915,7 @@ class GrandParent_StaticParent_Child<$S extends jni.JObject, set value($U value) => jni.Jni.env.SetObjectField(reference, _id_value, value.reference); - static final _id_ctor = jni.Jni.accessors.getMethodIDOf( + static final _id_new0 = jni.Jni.accessors.getMethodIDOf( _class.reference, r"", r"(Lcom/github/dart_lang/jnigen/generics/GrandParent$StaticParent;Ljava/lang/Object;Ljava/lang/Object;)V"); @@ -1939,7 +1939,7 @@ class GrandParent_StaticParent_Child<$S extends jni.JObject, return GrandParent_StaticParent_Child.fromRef( S, U, - jni.Jni.accessors.newObjectWithArgs(_class.reference, _id_ctor, [ + jni.Jni.accessors.newObjectWithArgs(_class.reference, _id_new0, [ $parent.reference, parentValue.reference, value.reference @@ -2014,7 +2014,7 @@ class MyMap<$K extends jni.JObject, $V extends jni.JObject> ); } - static final _id_ctor = + static final _id_new0 = jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () @@ -2027,7 +2027,7 @@ class MyMap<$K extends jni.JObject, $V extends jni.JObject> K, V, jni.Jni.accessors - .newObjectWithArgs(_class.reference, _id_ctor, []).object); + .newObjectWithArgs(_class.reference, _id_new0, []).object); } static final _id_get0 = jni.Jni.accessors.getMethodIDOf( @@ -2168,7 +2168,7 @@ class MyMap_MyEntry<$K extends jni.JObject, $V extends jni.JObject> set value($V value) => jni.Jni.env.SetObjectField(reference, _id_value, value.reference); - static final _id_ctor = jni.Jni.accessors.getMethodIDOf( + static final _id_new0 = jni.Jni.accessors.getMethodIDOf( _class.reference, r"", r"(Lcom/github/dart_lang/jnigen/generics/MyMap;Ljava/lang/Object;Ljava/lang/Object;)V"); @@ -2193,7 +2193,7 @@ class MyMap_MyEntry<$K extends jni.JObject, $V extends jni.JObject> return MyMap_MyEntry.fromRef( K, V, - jni.Jni.accessors.newObjectWithArgs(_class.reference, _id_ctor, + jni.Jni.accessors.newObjectWithArgs(_class.reference, _id_new0, [$parent.reference, key.reference, value.reference]).object); } } @@ -2258,7 +2258,7 @@ class MyStack<$T extends jni.JObject> extends jni.JObject { ); } - static final _id_ctor = + static final _id_new0 = jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () @@ -2269,7 +2269,7 @@ class MyStack<$T extends jni.JObject> extends jni.JObject { return MyStack.fromRef( T, jni.Jni.accessors - .newObjectWithArgs(_class.reference, _id_ctor, []).object); + .newObjectWithArgs(_class.reference, _id_new0, []).object); } static final _id_fromArray = jni.Jni.accessors.getStaticMethodIDOf( @@ -2457,7 +2457,7 @@ class StringKeyedMap<$V extends jni.JObject> extends MyMap { ); } - static final _id_ctor = + static final _id_new0 = jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () @@ -2468,7 +2468,7 @@ class StringKeyedMap<$V extends jni.JObject> extends MyMap { return StringKeyedMap.fromRef( V, jni.Jni.accessors - .newObjectWithArgs(_class.reference, _id_ctor, []).object); + .newObjectWithArgs(_class.reference, _id_new0, []).object); } } @@ -2519,14 +2519,14 @@ class StringMap extends StringKeyedMap { /// The type which includes information such as the signature of this class. static const type = $StringMapType(); - static final _id_ctor = + static final _id_new0 = jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory StringMap() { return StringMap.fromRef(jni.Jni.accessors - .newObjectWithArgs(_class.reference, _id_ctor, []).object); + .newObjectWithArgs(_class.reference, _id_new0, []).object); } } @@ -2568,14 +2568,14 @@ class StringStack extends MyStack { /// The type which includes information such as the signature of this class. static const type = $StringStackType(); - static final _id_ctor = + static final _id_new0 = jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory StringStack() { return StringStack.fromRef(jni.Jni.accessors - .newObjectWithArgs(_class.reference, _id_ctor, []).object); + .newObjectWithArgs(_class.reference, _id_new0, []).object); } } @@ -2627,7 +2627,7 @@ class StringValuedMap<$K extends jni.JObject> extends MyMap<$K, jni.JString> { ); } - static final _id_ctor = + static final _id_new0 = jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () @@ -2638,7 +2638,7 @@ class StringValuedMap<$K extends jni.JObject> extends MyMap<$K, jni.JString> { return StringValuedMap.fromRef( K, jni.Jni.accessors - .newObjectWithArgs(_class.reference, _id_ctor, []).object); + .newObjectWithArgs(_class.reference, _id_new0, []).object); } } @@ -2966,14 +2966,14 @@ class MyInterfaceConsumer extends jni.JObject { /// The type which includes information such as the signature of this class. static const type = $MyInterfaceConsumerType(); - static final _id_ctor = + static final _id_new0 = jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory MyInterfaceConsumer() { return MyInterfaceConsumer.fromRef(jni.Jni.accessors - .newObjectWithArgs(_class.reference, _id_ctor, []).object); + .newObjectWithArgs(_class.reference, _id_new0, []).object); } static final _id_consumeOnAnotherThread = jni.Jni.accessors.getStaticMethodIDOf( @@ -3152,14 +3152,14 @@ class MyDataClass extends jni.JObject { /// The type which includes information such as the signature of this class. static const type = $MyDataClassType(); - static final _id_ctor = + static final _id_new0 = jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () /// The returned object must be deleted after use, by calling the `delete` method. factory MyDataClass() { return MyDataClass.fromRef(jni.Jni.accessors - .newObjectWithArgs(_class.reference, _id_ctor, []).object); + .newObjectWithArgs(_class.reference, _id_new0, []).object); } } 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 1c4076883..e14dbfbbd 100644 --- a/pkgs/jnigen/test/simple_package_test/runtime_test_registrant.dart +++ b/pkgs/jnigen/test/simple_package_test/runtime_test_registrant.dart @@ -112,15 +112,15 @@ void registerTests(String groupName, TestRunnerCallback test) { expect(e0.getNumber(), 0); expect(e0.getIsUp(), true); expect(e0.getCodename().toDartString(), equals('achilles')); - final e1 = Example.ctor1(111); + final e1 = Example.new1(111); expect(e1.getNumber(), equals(111)); expect(e1.getIsUp(), true); expect(e1.getCodename().toDartString(), "achilles"); - final e2 = Example.ctor2(122, false); + final e2 = Example.new2(122, false); expect(e2.getNumber(), equals(122)); expect(e2.getIsUp(), false); expect(e2.getCodename().toDartString(), "achilles"); - final e3 = Example.ctor3(133, false, "spartan".toJString()); + final e3 = Example.new3(133, false, "spartan".toJString()); expect(e3.getNumber(), equals(133)); expect(e3.getIsUp(), false); expect(e3.getCodename().toDartString(), "spartan"); @@ -227,8 +227,8 @@ void registerTests(String groupName, TestRunnerCallback test) { }); test('Exception from constructor', () { - throwsException(() => Exceptions.ctor1(6.8)); - throwsException(() => Exceptions.ctor2(1, 2, 3, 4, 5, 6)); + throwsException(() => Exceptions.new1(6.8)); + throwsException(() => Exceptions.new2(1, 2, 3, 4, 5, 6)); }); test('Exception contains error message & stack trace', () { @@ -286,8 +286,8 @@ void registerTests(String groupName, TestRunnerCallback test) { test('MyMap', () { using((arena) { final map = MyMap(K: JString.type, V: Example.type)..deletedIn(arena); - final helloExample = Example.ctor1(1)..deletedIn(arena); - final worldExample = Example.ctor1(2)..deletedIn(arena); + final helloExample = Example.new1(1)..deletedIn(arena); + final worldExample = Example.new1(2)..deletedIn(arena); map.put('Hello'.toJString()..deletedIn(arena), helloExample); map.put('World'.toJString()..deletedIn(arena), worldExample); expect( @@ -605,14 +605,14 @@ void registerTests(String groupName, TestRunnerCallback test) { const k256 = 256 * 1024; test('create large number of JNI references without deleting', () { for (int i = 0; i < k4; i++) { - final e = Example.ctor1(i); + final e = Example.new1(i); expect(e.getNumber(), equals(i)); } }); test('Create many JNI refs with scoped deletion', () { for (int i = 0; i < k256; i++) { using((arena) { - final e = Example.ctor1(i)..deletedIn(arena); + final e = Example.new1(i)..deletedIn(arena); expect(e.getNumber(), equals(i)); }); } @@ -621,7 +621,7 @@ void registerTests(String groupName, TestRunnerCallback test) { for (int i = 0; i < 256; i++) { using((arena) { for (int i = 0; i < 1024; i++) { - final e = Example.ctor1(i)..deletedIn(arena); + final e = Example.new1(i)..deletedIn(arena); expect(e.getNumber(), equals(i)); } }); @@ -629,14 +629,14 @@ void registerTests(String groupName, TestRunnerCallback test) { }); test('Create large number of JNI refs with manual delete', () { for (int i = 0; i < k256; i++) { - final e = Example.ctor1(i); + final e = Example.new1(i); expect(e.getNumber(), equals(i)); e.delete(); } }); test('Method returning primitive type does not create references', () { using((arena) { - final e = Example.ctor1(64)..deletedIn(arena); + final e = Example.new1(64)..deletedIn(arena); for (int i = 0; i < k256; i++) { expect(e.getNumber(), equals(64)); } From 4f85cedc6d80dcc11ab7893ed408e74675c1a151 Mon Sep 17 00:00:00 2001 From: Mahesh Hegde <46179734+mahesh-hegde@users.noreply.github.com> Date: Fri, 18 Aug 2023 18:06:38 +0530 Subject: [PATCH 116/139] [jnigen] Add tests on summary content (https://github.com/dart-lang/jnigen/issues/353) * Add tests on summary content * Emit char as integer --- .../apisummarizer/disasm/AsmClassVisitor.java | 6 +- .../apisummarizer/doclet/ElementBuilders.java | 3 + .../apisummarizer/elements/TypeUsage.java | 8 + .../test/resources/exampleClassSummary.json | 1 - .../c_based/c_bindings/simple_package.c | 324 +++++++++++++ .../c_based/dart_bindings/simple_package.dart | 428 +++++++++++++++++- .../dart_bindings/simple_package.dart | 395 +++++++++++++++- .../jnigen/generics/GenericTypeParams.java | 9 + .../jnigen/inheritance/BaseClass.java | 7 + .../inheritance/GenericDerivedClass.java | 7 + .../inheritance/SpecificDerivedClass.java | 7 + .../jnigen/simple_package/Color.java | 14 + .../jnigen/simple_package/Example.java | 36 ++ .../runtime_test_registrant.dart | 2 +- pkgs/jnigen/test/summary_generation_test.dart | 64 +-- pkgs/jnigen/test/summary_test.dart | 323 +++++++++++++ pkgs/jnigen/test/test_util/summary_util.dart | 75 +++ 17 files changed, 1646 insertions(+), 63 deletions(-) create mode 100644 pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/generics/GenericTypeParams.java create mode 100644 pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/BaseClass.java create mode 100644 pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/GenericDerivedClass.java create mode 100644 pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/SpecificDerivedClass.java create mode 100644 pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/simple_package/Color.java create mode 100644 pkgs/jnigen/test/summary_test.dart create mode 100644 pkgs/jnigen/test/test_util/summary_util.dart diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmClassVisitor.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmClassVisitor.java index 33fecbd5b..d5a730b47 100644 --- a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmClassVisitor.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/disasm/AsmClassVisitor.java @@ -4,6 +4,8 @@ package com.github.dart_lang.jnigen.apisummarizer.disasm; +import static org.objectweb.asm.Opcodes.ACC_ENUM; + import com.github.dart_lang.jnigen.apisummarizer.elements.*; import com.github.dart_lang.jnigen.apisummarizer.util.SkipException; import com.github.dart_lang.jnigen.apisummarizer.util.StreamUtil; @@ -45,7 +47,6 @@ public void visit( String[] interfaces) { var current = new ClassDecl(); visiting.push(current); - var type = Type.getObjectType(name); current.binaryName = name.replace('/', '.'); current.modifiers = TypeUtils.access(actualAccess.getOrDefault(current.binaryName, access)); current.declKind = TypeUtils.declKind(access); @@ -86,6 +87,9 @@ public FieldVisitor visitField( field.type = TypeUtils.typeUsage(Type.getType(descriptor), signature); field.defaultValue = value; field.modifiers = TypeUtils.access(access); + if ((access & ACC_ENUM) != 0) { + peekVisiting().values.add(name); + } if (signature != null) { var reader = new SignatureReader(signature); reader.accept(new AsmTypeUsageSignatureVisitor(field.type)); diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/doclet/ElementBuilders.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/doclet/ElementBuilders.java index 7ca8bb62e..675da7b8a 100644 --- a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/doclet/ElementBuilders.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/doclet/ElementBuilders.java @@ -62,6 +62,9 @@ public Field field(VariableElement e) { field.name = e.getSimpleName().toString(); field.modifiers = e.getModifiers().stream().map(Modifier::toString).collect(Collectors.toSet()); field.defaultValue = e.getConstantValue(); + if (field.defaultValue instanceof Character) { + field.defaultValue = (int) (Character) field.defaultValue; + } field.type = typeUsage(e.asType()); field.javadoc = docComment(env.trees.getDocCommentTree(e)); field.annotations = annotations(e.getAnnotationMirrors()); diff --git a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/TypeUsage.java b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/TypeUsage.java index a41b8eabd..a60407caf 100644 --- a/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/TypeUsage.java +++ b/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/elements/TypeUsage.java @@ -7,6 +7,14 @@ import java.util.List; public class TypeUsage { + public TypeUsage(String shorthand, Kind kind, ReferredType type) { + this.shorthand = shorthand; + this.kind = kind; + this.type = type; + } + + public TypeUsage() {} + public enum Kind { DECLARED, TYPE_VARIABLE, diff --git a/pkgs/jnigen/java/src/test/resources/exampleClassSummary.json b/pkgs/jnigen/java/src/test/resources/exampleClassSummary.json index 208e7ae13..6786a269b 100644 --- a/pkgs/jnigen/java/src/test/resources/exampleClassSummary.json +++ b/pkgs/jnigen/java/src/test/resources/exampleClassSummary.json @@ -139,7 +139,6 @@ "declKind" : "CLASS", "modifiers" : [ "static", "public" ], "binaryName" : "com.example.Example$Aux", - "parentName" : "com.example.Example", "methods" : [ { "modifiers" : [ "public" ], "name" : "", diff --git a/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/simple_package.c b/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/simple_package.c index 18621f8c9..62b150ed9 100644 --- a/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/simple_package.c +++ b/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/simple_package.c @@ -19,6 +19,44 @@ void setJniGetters(JniContext* (*cg)(void), JNIEnv* (*eg)(void)) { env_getter = eg; } +// com.github.dart_lang.jnigen.simple_package.Color +jclass _c_Color = NULL; + +jmethodID _m_Color__values = NULL; +FFI_PLUGIN_EXPORT +JniResult Color__values() { + load_env(); + load_class_global_ref(&_c_Color, + "com/github/dart_lang/jnigen/simple_package/Color"); + if (_c_Color == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_method(_c_Color, &_m_Color__values, "values", + "()[Lcom/github/dart_lang/jnigen/simple_package/Color;"); + if (_m_Color__values == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_Color, _m_Color__values); + return to_global_ref_result(_result); +} + +jmethodID _m_Color__valueOf = NULL; +FFI_PLUGIN_EXPORT +JniResult Color__valueOf(jobject name) { + load_env(); + load_class_global_ref(&_c_Color, + "com/github/dart_lang/jnigen/simple_package/Color"); + if (_c_Color == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_method( + _c_Color, &_m_Color__valueOf, "valueOf", + "(Ljava/lang/String;)Lcom/github/dart_lang/jnigen/simple_package/Color;"); + if (_m_Color__valueOf == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallStaticObjectMethod(jniEnv, _c_Color, + _m_Color__valueOf, name); + return to_global_ref_result(_result); +} + // com.github.dart_lang.jnigen.simple_package.Example jclass _c_Example = NULL; @@ -402,6 +440,96 @@ JniResult Example__getRandomNumericString(jobject self_, jobject random) { return to_global_ref_result(_result); } +jmethodID _m_Example__protectedMethod = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__protectedMethod(jobject self_, jobject a, jobject b) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example, &_m_Example__protectedMethod, "protectedMethod", + "(Ljava/lang/String;Ljava/lang/String;)V"); + if (_m_Example__protectedMethod == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_Example__protectedMethod, a, b); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +jmethodID _m_Example__finalMethod = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__finalMethod(jobject self_) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example, &_m_Example__finalMethod, "finalMethod", "()V"); + if (_m_Example__finalMethod == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_Example__finalMethod); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +jmethodID _m_Example__getList = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__getList(jobject self_) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example, &_m_Example__getList, "getList", + "()Ljava/util/List;"); + if (_m_Example__getList == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->CallObjectMethod(jniEnv, self_, _m_Example__getList); + return to_global_ref_result(_result); +} + +jmethodID _m_Example__joinStrings = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__joinStrings(jobject self_, jobject values, jobject delim) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example, &_m_Example__joinStrings, "joinStrings", + "(Ljava/util/List;Ljava/lang/String;)Ljava/lang/String;"); + if (_m_Example__joinStrings == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->CallObjectMethod( + jniEnv, self_, _m_Example__joinStrings, values, delim); + return to_global_ref_result(_result); +} + +jmethodID _m_Example__methodWithSeveralParams = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__methodWithSeveralParams(jobject self_, + uint16_t ch, + jobject s, + jobject a, + jobject t, + jobject lt, + jobject wm) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example, &_m_Example__methodWithSeveralParams, + "methodWithSeveralParams", + "(CLjava/lang/String;[ILjava/lang/CharSequence;Ljava/util/" + "List;Ljava/util/Map;)V"); + if (_m_Example__methodWithSeveralParams == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_Example__methodWithSeveralParams, + ch, s, a, t, lt, wm); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + jmethodID _m_Example__new0 = NULL; FFI_PLUGIN_EXPORT JniResult Example__new0() { @@ -587,6 +715,127 @@ JniResult Example__throwException() { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } +jmethodID _m_Example__overloaded = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__overloaded(jobject self_) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example, &_m_Example__overloaded, "overloaded", "()V"); + if (_m_Example__overloaded == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_Example__overloaded); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +jmethodID _m_Example__overloaded1 = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__overloaded1(jobject self_, int32_t a, jobject b) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example, &_m_Example__overloaded1, "overloaded", + "(ILjava/lang/String;)V"); + if (_m_Example__overloaded1 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_Example__overloaded1, a, b); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +jmethodID _m_Example__overloaded2 = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__overloaded2(jobject self_, int32_t a) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example, &_m_Example__overloaded2, "overloaded", "(I)V"); + if (_m_Example__overloaded2 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_Example__overloaded2, a); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +jmethodID _m_Example__overloaded3 = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__overloaded3(jobject self_, jobject a, jobject b) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example, &_m_Example__overloaded3, "overloaded", + "(Ljava/util/List;Ljava/lang/String;)V"); + if (_m_Example__overloaded3 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_Example__overloaded3, a, b); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +jmethodID _m_Example__overloaded4 = NULL; +FFI_PLUGIN_EXPORT +JniResult Example__overloaded4(jobject self_, jobject a) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example, &_m_Example__overloaded4, "overloaded", + "(Ljava/util/List;)V"); + if (_m_Example__overloaded4 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_Example__overloaded4, a); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +jfieldID _f_Example__unusedRandom = NULL; +FFI_PLUGIN_EXPORT +JniResult get_Example__unusedRandom() { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_static_field(_c_Example, &_f_Example__unusedRandom, "unusedRandom", + "Ljava/util/Random;"); + jobject _result = (*jniEnv)->GetStaticObjectField(jniEnv, _c_Example, + _f_Example__unusedRandom); + return to_global_ref_result(_result); +} + +jfieldID _f_Example__protectedField = NULL; +FFI_PLUGIN_EXPORT +JniResult get_Example__protectedField(jobject self_) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_field(_c_Example, &_f_Example__protectedField, "protectedField", + "Ljava/util/Random;"); + jobject _result = + (*jniEnv)->GetObjectField(jniEnv, self_, _f_Example__protectedField); + return to_global_ref_result(_result); +} + +FFI_PLUGIN_EXPORT +JniResult set_Example__protectedField(jobject self_, jobject value) { + load_env(); + load_class_global_ref(&_c_Example, + "com/github/dart_lang/jnigen/simple_package/Example"); + if (_c_Example == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_field(_c_Example, &_f_Example__protectedField, "protectedField", + "Ljava/util/Random;"); + (*jniEnv)->SetObjectField(jniEnv, self_, _f_Example__protectedField, value); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + // com.github.dart_lang.jnigen.simple_package.Example$Nested jclass _c_Example_Nested = NULL; @@ -713,6 +962,60 @@ JniResult set_Example_Nested_NestedTwice__ZERO(int32_t value) { return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } +// com.github.dart_lang.jnigen.simple_package.Example$NonStaticNested +jclass _c_Example_NonStaticNested = NULL; + +jmethodID _m_Example_NonStaticNested__new0 = NULL; +FFI_PLUGIN_EXPORT +JniResult Example_NonStaticNested__new0(jobject _parent) { + load_env(); + load_class_global_ref( + &_c_Example_NonStaticNested, + "com/github/dart_lang/jnigen/simple_package/Example$NonStaticNested"); + if (_c_Example_NonStaticNested == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_Example_NonStaticNested, &_m_Example_NonStaticNested__new0, + "", + "(Lcom/github/dart_lang/jnigen/simple_package/Example;)V"); + if (_m_Example_NonStaticNested__new0 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = + (*jniEnv)->NewObject(jniEnv, _c_Example_NonStaticNested, + _m_Example_NonStaticNested__new0, _parent); + return to_global_ref_result(_result); +} + +jfieldID _f_Example_NonStaticNested__ok = NULL; +FFI_PLUGIN_EXPORT +JniResult get_Example_NonStaticNested__ok(jobject self_) { + load_env(); + load_class_global_ref( + &_c_Example_NonStaticNested, + "com/github/dart_lang/jnigen/simple_package/Example$NonStaticNested"); + if (_c_Example_NonStaticNested == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_field(_c_Example_NonStaticNested, &_f_Example_NonStaticNested__ok, "ok", + "Z"); + uint8_t _result = + (*jniEnv)->GetBooleanField(jniEnv, self_, _f_Example_NonStaticNested__ok); + return (JniResult){.value = {.z = _result}, .exception = check_exception()}; +} + +FFI_PLUGIN_EXPORT +JniResult set_Example_NonStaticNested__ok(jobject self_, uint8_t value) { + load_env(); + load_class_global_ref( + &_c_Example_NonStaticNested, + "com/github/dart_lang/jnigen/simple_package/Example$NonStaticNested"); + if (_c_Example_NonStaticNested == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_field(_c_Example_NonStaticNested, &_f_Example_NonStaticNested__ok, "ok", + "Z"); + (*jniEnv)->SetBooleanField(jniEnv, self_, _f_Example_NonStaticNested__ok, + value); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + // com.github.dart_lang.jnigen.simple_package.Exceptions jclass _c_Exceptions = NULL; @@ -1440,6 +1743,27 @@ JniResult Example1__whichExample(jobject self_) { return (JniResult){.value = {.i = _result}, .exception = check_exception()}; } +// com.github.dart_lang.jnigen.generics.GenericTypeParams +jclass _c_GenericTypeParams = NULL; + +jmethodID _m_GenericTypeParams__new0 = NULL; +FFI_PLUGIN_EXPORT +JniResult GenericTypeParams__new0() { + load_env(); + load_class_global_ref( + &_c_GenericTypeParams, + "com/github/dart_lang/jnigen/generics/GenericTypeParams"); + if (_c_GenericTypeParams == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_GenericTypeParams, &_m_GenericTypeParams__new0, "", + "()V"); + if (_m_GenericTypeParams__new0 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_GenericTypeParams, + _m_GenericTypeParams__new0); + return to_global_ref_result(_result); +} + // com.github.dart_lang.jnigen.generics.GrandParent jclass _c_GrandParent = NULL; diff --git a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart index 10e399064..06112a1d2 100644 --- a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart @@ -29,6 +29,66 @@ import "package:jni/jni.dart" as jni; final ffi.Pointer Function(String sym) jniLookup = ProtectedJniExtensions.initGeneratedLibrary("simple_package"); +/// from: com.github.dart_lang.jnigen.simple_package.Color +class Color extends jni.JObject { + @override + late final jni.JObjType $type = type; + + Color.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = $ColorType(); + static final _values = + jniLookup>("Color__values") + .asFunction(); + + /// from: static public com.github.dart_lang.jnigen.simple_package.Color[] values() + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JArray values() { + return const jni.JArrayType($ColorType()).fromRef(_values().object); + } + + static final _valueOf = jniLookup< + ffi + .NativeFunction)>>( + "Color__valueOf") + .asFunction)>(); + + /// from: static public com.github.dart_lang.jnigen.simple_package.Color valueOf(java.lang.String name) + /// The returned object must be deleted after use, by calling the `delete` method. + static Color valueOf( + jni.JString name, + ) { + return const $ColorType().fromRef(_valueOf(name.reference).object); + } +} + +class $ColorType extends jni.JObjType { + const $ColorType(); + + @override + String get signature => r"Lcom/github/dart_lang/jnigen/simple_package/Color;"; + + @override + Color fromRef(jni.JObjectPtr ref) => Color.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($ColorType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == ($ColorType) && other is $ColorType; + } +} + /// from: com.github.dart_lang.jnigen.simple_package.Example class Example extends jni.JObject { @override @@ -51,11 +111,48 @@ class Example extends jni.JObject { static const PI = 3.14159; /// from: static public final char SEMICOLON - static const SEMICOLON = r""";"""; + static const SEMICOLON = 59; /// from: static public final java.lang.String SEMICOLON_STRING static const SEMICOLON_STRING = r""";"""; + static final _get_unusedRandom = + jniLookup>( + "get_Example__unusedRandom") + .asFunction(); + + /// from: static public final java.util.Random unusedRandom + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JObject get unusedRandom => + const jni.JObjectType().fromRef(_get_unusedRandom().object); + + static final _get_protectedField = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + jni.JObjectPtr, + )>>("get_Example__protectedField") + .asFunction< + jni.JniResult Function( + jni.JObjectPtr, + )>(); + + static final _set_protectedField = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(jni.JObjectPtr, + ffi.Pointer)>>("set_Example__protectedField") + .asFunction< + jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); + + /// from: protected java.util.Random protectedField + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JObject get protectedField => + const jni.JObjectType().fromRef(_get_protectedField(reference).object); + + /// from: protected java.util.Random protectedField + /// The returned object must be deleted after use, by calling the `delete` method. + set protectedField(jni.JObject value) => + _set_protectedField(reference, value.reference).check(); + static final _getAmount = jniLookup>( "Example__getAmount") @@ -359,6 +456,109 @@ class Example extends jni.JObject { .fromRef(_getRandomNumericString(reference, random.reference).object); } + static final _protectedMethod = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>("Example__protectedMethod") + .asFunction< + jni.JniResult Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + /// from: protected void protectedMethod(java.lang.String a, java.lang.String b) + void protectedMethod( + jni.JString a, + jni.JString b, + ) { + return _protectedMethod(reference, a.reference, b.reference).check(); + } + + static final _finalMethod = jniLookup< + ffi + .NativeFunction)>>( + "Example__finalMethod") + .asFunction)>(); + + /// from: public final void finalMethod() + void finalMethod() { + return _finalMethod(reference).check(); + } + + static final _getList = jniLookup< + ffi + .NativeFunction)>>( + "Example__getList") + .asFunction)>(); + + /// from: public java.util.List getList() + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JList getList() { + return const jni.JListType(jni.JStringType()) + .fromRef(_getList(reference).object); + } + + static final _joinStrings = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>("Example__joinStrings") + .asFunction< + jni.JniResult Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + /// from: public java.lang.String joinStrings(java.util.List values, java.lang.String delim) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Joins the strings in the list using the given delimiter. + jni.JString joinStrings( + jni.JList values, + jni.JString delim, + ) { + return const jni.JStringType().fromRef( + _joinStrings(reference, values.reference, delim.reference).object); + } + + static final _methodWithSeveralParams = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, + ffi.Uint16, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>("Example__methodWithSeveralParams") + .asFunction< + jni.JniResult Function( + ffi.Pointer, + int, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + /// from: public void methodWithSeveralParams(char ch, java.lang.String s, int[] a, T t, java.util.List lt, java.util.Map wm) + void methodWithSeveralParams<$T extends jni.JObject>( + int ch, + jni.JString s, + jni.JArray a, + $T t, + jni.JList<$T> lt, + jni.JMap wm, { + jni.JObjType<$T>? T, + }) { + T ??= jni.lowestCommonSuperType([ + (lt.$type as jni.JListType).E, + t.$type, + ]) as jni.JObjType<$T>; + return _methodWithSeveralParams(reference, ch, s.reference, a.reference, + t.reference, lt.reference, wm.reference) + .check(); + } + static final _new0 = jniLookup>("Example__new0") .asFunction(); @@ -503,6 +703,79 @@ class Example extends jni.JObject { static void throwException() { return _throwException().check(); } + + static final _overloaded = jniLookup< + ffi + .NativeFunction)>>( + "Example__overloaded") + .asFunction)>(); + + /// from: public void overloaded() + void overloaded() { + return _overloaded(reference).check(); + } + + static final _overloaded1 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, ffi.Int32, + ffi.Pointer)>>("Example__overloaded1") + .asFunction< + jni.JniResult Function( + ffi.Pointer, int, ffi.Pointer)>(); + + /// from: public void overloaded(int a, java.lang.String b) + void overloaded1( + int a, + jni.JString b, + ) { + return _overloaded1(reference, a, b.reference).check(); + } + + static final _overloaded2 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Int32)>>("Example__overloaded2") + .asFunction, int)>(); + + /// from: public void overloaded(int a) + void overloaded2( + int a, + ) { + return _overloaded2(reference, a).check(); + } + + static final _overloaded3 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>("Example__overloaded3") + .asFunction< + jni.JniResult Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + /// from: public void overloaded(java.util.List a, java.lang.String b) + void overloaded3( + jni.JList a, + jni.JString b, + ) { + return _overloaded3(reference, a.reference, b.reference).check(); + } + + static final _overloaded4 = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer, + ffi.Pointer)>>("Example__overloaded4") + .asFunction< + jni.JniResult Function( + ffi.Pointer, ffi.Pointer)>(); + + /// from: public void overloaded(java.util.List a) + void overloaded4( + jni.JList a, + ) { + return _overloaded4(reference, a.reference).check(); + } } class $ExampleType extends jni.JObjType { @@ -682,6 +955,82 @@ class $Example_Nested_NestedTwiceType } } +/// from: com.github.dart_lang.jnigen.simple_package.Example$NonStaticNested +class Example_NonStaticNested extends jni.JObject { + @override + late final jni.JObjType $type = type; + + Example_NonStaticNested.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = $Example_NonStaticNestedType(); + static final _get_ok = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + jni.JObjectPtr, + )>>("get_Example_NonStaticNested__ok") + .asFunction< + jni.JniResult Function( + jni.JObjectPtr, + )>(); + + static final _set_ok = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(jni.JObjectPtr, + ffi.Uint8)>>("set_Example_NonStaticNested__ok") + .asFunction(); + + /// from: public boolean ok + bool get ok => _get_ok(reference).boolean; + + /// from: public boolean ok + set ok(bool value) => _set_ok(reference, value ? 1 : 0).check(); + + static final _new0 = jniLookup< + ffi + .NativeFunction)>>( + "Example_NonStaticNested__new0") + .asFunction)>(); + + /// from: public void (com.github.dart_lang.jnigen.simple_package.Example $parent) + /// The returned object must be deleted after use, by calling the `delete` method. + factory Example_NonStaticNested( + Example $parent, + ) { + return Example_NonStaticNested.fromRef(_new0($parent.reference).object); + } +} + +class $Example_NonStaticNestedType + extends jni.JObjType { + const $Example_NonStaticNestedType(); + + @override + String get signature => + r"Lcom/github/dart_lang/jnigen/simple_package/Example$NonStaticNested;"; + + @override + Example_NonStaticNested fromRef(jni.JObjectPtr ref) => + Example_NonStaticNested.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($Example_NonStaticNestedType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == ($Example_NonStaticNestedType) && + other is $Example_NonStaticNestedType; + } +} + /// from: com.github.dart_lang.jnigen.simple_package.Exceptions class Exceptions extends jni.JObject { @override @@ -1389,6 +1738,83 @@ class $Example1Type extends jni.JObjType { } } +/// from: com.github.dart_lang.jnigen.generics.GenericTypeParams +class GenericTypeParams<$S extends jni.JObject, $K extends jni.JObject> + extends jni.JObject { + @override + late final jni.JObjType> $type = type(S, K); + + final jni.JObjType<$S> S; + final jni.JObjType<$K> K; + + GenericTypeParams.fromRef( + this.S, + this.K, + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static $GenericTypeParamsType<$S, $K> + type<$S extends jni.JObject, $K extends jni.JObject>( + jni.JObjType<$S> S, + jni.JObjType<$K> K, + ) { + return $GenericTypeParamsType( + S, + K, + ); + } + + static final _new0 = jniLookup>( + "GenericTypeParams__new0") + .asFunction(); + + /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. + factory GenericTypeParams({ + required jni.JObjType<$S> S, + required jni.JObjType<$K> K, + }) { + return GenericTypeParams.fromRef(S, K, _new0().object); + } +} + +class $GenericTypeParamsType<$S extends jni.JObject, $K extends jni.JObject> + extends jni.JObjType> { + final jni.JObjType<$S> S; + final jni.JObjType<$K> K; + + const $GenericTypeParamsType( + this.S, + this.K, + ); + + @override + String get signature => + r"Lcom/github/dart_lang/jnigen/generics/GenericTypeParams;"; + + @override + GenericTypeParams<$S, $K> fromRef(jni.JObjectPtr ref) => + GenericTypeParams.fromRef(S, K, ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => Object.hash($GenericTypeParamsType, S, K); + + @override + bool operator ==(Object other) { + return other.runtimeType == ($GenericTypeParamsType<$S, $K>) && + other is $GenericTypeParamsType<$S, $K> && + S == other.S && + K == other.K; + } +} + /// from: com.github.dart_lang.jnigen.generics.GrandParent class GrandParent<$T extends jni.JObject> extends jni.JObject { @override diff --git a/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart index e3667c161..73d8b744d 100644 --- a/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart @@ -24,6 +24,73 @@ import "dart:ffi" as ffi; import "package:jni/internal_helpers_for_jnigen.dart"; import "package:jni/jni.dart" as jni; +/// from: com.github.dart_lang.jnigen.simple_package.Color +class Color extends jni.JObject { + @override + late final jni.JObjType $type = type; + + Color.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + static final _class = + jni.Jni.findJClass(r"com/github/dart_lang/jnigen/simple_package/Color"); + + /// The type which includes information such as the signature of this class. + static const type = $ColorType(); + static final _id_values = jni.Jni.accessors.getStaticMethodIDOf( + _class.reference, + r"values", + r"()[Lcom/github/dart_lang/jnigen/simple_package/Color;"); + + /// from: static public com.github.dart_lang.jnigen.simple_package.Color[] values() + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JArray values() { + return const jni.JArrayType($ColorType()).fromRef(jni.Jni.accessors + .callStaticMethodWithArgs(_class.reference, _id_values, + jni.JniCallType.objectType, []).object); + } + + static final _id_valueOf = jni.Jni.accessors.getStaticMethodIDOf( + _class.reference, + r"valueOf", + r"(Ljava/lang/String;)Lcom/github/dart_lang/jnigen/simple_package/Color;"); + + /// from: static public com.github.dart_lang.jnigen.simple_package.Color valueOf(java.lang.String name) + /// The returned object must be deleted after use, by calling the `delete` method. + static Color valueOf( + jni.JString name, + ) { + return const $ColorType().fromRef(jni.Jni.accessors + .callStaticMethodWithArgs(_class.reference, _id_valueOf, + jni.JniCallType.objectType, [name.reference]).object); + } +} + +class $ColorType extends jni.JObjType { + const $ColorType(); + + @override + String get signature => r"Lcom/github/dart_lang/jnigen/simple_package/Color;"; + + @override + Color fromRef(jni.JObjectPtr ref) => Color.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($ColorType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == ($ColorType) && other is $ColorType; + } +} + /// from: com.github.dart_lang.jnigen.simple_package.Example class Example extends jni.JObject { @override @@ -49,11 +116,43 @@ class Example extends jni.JObject { static const PI = 3.14159; /// from: static public final char SEMICOLON - static const SEMICOLON = r""";"""; + static const SEMICOLON = 59; /// from: static public final java.lang.String SEMICOLON_STRING static const SEMICOLON_STRING = r""";"""; + static final _id_unusedRandom = jni.Jni.accessors.getStaticFieldIDOf( + _class.reference, + r"unusedRandom", + r"Ljava/util/Random;", + ); + + /// from: static public final java.util.Random unusedRandom + /// The returned object must be deleted after use, by calling the `delete` method. + static jni.JObject get unusedRandom => + const jni.JObjectType().fromRef(jni.Jni.accessors + .getStaticField( + _class.reference, _id_unusedRandom, jni.JniCallType.objectType) + .object); + + static final _id_protectedField = jni.Jni.accessors.getFieldIDOf( + _class.reference, + r"protectedField", + r"Ljava/util/Random;", + ); + + /// from: protected java.util.Random protectedField + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JObject get protectedField => + const jni.JObjectType().fromRef(jni.Jni.accessors + .getField(reference, _id_protectedField, jni.JniCallType.objectType) + .object); + + /// from: protected java.util.Random protectedField + /// The returned object must be deleted after use, by calling the `delete` method. + set protectedField(jni.JObject value) => jni.Jni.env + .SetObjectField(reference, _id_protectedField, value.reference); + static final _id_getAmount = jni.Jni.accessors .getStaticMethodIDOf(_class.reference, r"getAmount", r"()I"); @@ -332,6 +431,90 @@ class Example extends jni.JObject { [random.reference]).object); } + static final _id_protectedMethod = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"protectedMethod", + r"(Ljava/lang/String;Ljava/lang/String;)V"); + + /// from: protected void protectedMethod(java.lang.String a, java.lang.String b) + void protectedMethod( + jni.JString a, + jni.JString b, + ) { + return jni.Jni.accessors.callMethodWithArgs(reference, _id_protectedMethod, + jni.JniCallType.voidType, [a.reference, b.reference]).check(); + } + + static final _id_finalMethod = + jni.Jni.accessors.getMethodIDOf(_class.reference, r"finalMethod", r"()V"); + + /// from: public final void finalMethod() + void finalMethod() { + return jni.Jni.accessors.callMethodWithArgs( + reference, _id_finalMethod, jni.JniCallType.voidType, []).check(); + } + + static final _id_getList = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"getList", r"()Ljava/util/List;"); + + /// from: public java.util.List getList() + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JList getList() { + return const jni.JListType(jni.JStringType()).fromRef(jni.Jni.accessors + .callMethodWithArgs( + reference, _id_getList, jni.JniCallType.objectType, []).object); + } + + static final _id_joinStrings = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"joinStrings", + r"(Ljava/util/List;Ljava/lang/String;)Ljava/lang/String;"); + + /// from: public java.lang.String joinStrings(java.util.List values, java.lang.String delim) + /// The returned object must be deleted after use, by calling the `delete` method. + /// + /// Joins the strings in the list using the given delimiter. + jni.JString joinStrings( + jni.JList values, + jni.JString delim, + ) { + return const jni.JStringType().fromRef(jni.Jni.accessors.callMethodWithArgs( + reference, + _id_joinStrings, + jni.JniCallType.objectType, + [values.reference, delim.reference]).object); + } + + static final _id_methodWithSeveralParams = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"methodWithSeveralParams", + r"(CLjava/lang/String;[ILjava/lang/CharSequence;Ljava/util/List;Ljava/util/Map;)V"); + + /// from: public void methodWithSeveralParams(char ch, java.lang.String s, int[] a, T t, java.util.List lt, java.util.Map wm) + void methodWithSeveralParams<$T extends jni.JObject>( + int ch, + jni.JString s, + jni.JArray a, + $T t, + jni.JList<$T> lt, + jni.JMap wm, { + jni.JObjType<$T>? T, + }) { + T ??= jni.lowestCommonSuperType([ + (lt.$type as jni.JListType).E, + t.$type, + ]) as jni.JObjType<$T>; + return jni.Jni.accessors.callMethodWithArgs( + reference, _id_methodWithSeveralParams, jni.JniCallType.voidType, [ + jni.JValueChar(ch), + s.reference, + a.reference, + t.reference, + lt.reference, + wm.reference + ]).check(); + } + static final _id_new0 = jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); @@ -475,6 +658,63 @@ class Example extends jni.JObject { return jni.Jni.accessors.callStaticMethodWithArgs(_class.reference, _id_throwException, jni.JniCallType.voidType, []).check(); } + + static final _id_overloaded = + jni.Jni.accessors.getMethodIDOf(_class.reference, r"overloaded", r"()V"); + + /// from: public void overloaded() + void overloaded() { + return jni.Jni.accessors.callMethodWithArgs( + reference, _id_overloaded, jni.JniCallType.voidType, []).check(); + } + + static final _id_overloaded1 = jni.Jni.accessors.getMethodIDOf( + _class.reference, r"overloaded", r"(ILjava/lang/String;)V"); + + /// from: public void overloaded(int a, java.lang.String b) + void overloaded1( + int a, + jni.JString b, + ) { + return jni.Jni.accessors.callMethodWithArgs(reference, _id_overloaded1, + jni.JniCallType.voidType, [jni.JValueInt(a), b.reference]).check(); + } + + static final _id_overloaded2 = + jni.Jni.accessors.getMethodIDOf(_class.reference, r"overloaded", r"(I)V"); + + /// from: public void overloaded(int a) + void overloaded2( + int a, + ) { + return jni.Jni.accessors.callMethodWithArgs(reference, _id_overloaded2, + jni.JniCallType.voidType, [jni.JValueInt(a)]).check(); + } + + static final _id_overloaded3 = jni.Jni.accessors.getMethodIDOf( + _class.reference, + r"overloaded", + r"(Ljava/util/List;Ljava/lang/String;)V"); + + /// from: public void overloaded(java.util.List a, java.lang.String b) + void overloaded3( + jni.JList a, + jni.JString b, + ) { + return jni.Jni.accessors.callMethodWithArgs(reference, _id_overloaded3, + jni.JniCallType.voidType, [a.reference, b.reference]).check(); + } + + static final _id_overloaded4 = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"overloaded", r"(Ljava/util/List;)V"); + + /// from: public void overloaded(java.util.List a) + void overloaded4( + jni.JList a, + ) { + return jni.Jni.accessors.callMethodWithArgs(reference, _id_overloaded4, + jni.JniCallType.voidType, [a.reference]).check(); + } } class $ExampleType extends jni.JObjType { @@ -652,6 +892,76 @@ class $Example_Nested_NestedTwiceType } } +/// from: com.github.dart_lang.jnigen.simple_package.Example$NonStaticNested +class Example_NonStaticNested extends jni.JObject { + @override + late final jni.JObjType $type = type; + + Example_NonStaticNested.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + static final _class = jni.Jni.findJClass( + r"com/github/dart_lang/jnigen/simple_package/Example$NonStaticNested"); + + /// The type which includes information such as the signature of this class. + static const type = $Example_NonStaticNestedType(); + static final _id_ok = jni.Jni.accessors.getFieldIDOf( + _class.reference, + r"ok", + r"Z", + ); + + /// from: public boolean ok + bool get ok => jni.Jni.accessors + .getField(reference, _id_ok, jni.JniCallType.booleanType) + .boolean; + + /// from: public boolean ok + set ok(bool value) => + jni.Jni.env.SetBooleanField(reference, _id_ok, value ? 1 : 0); + + static final _id_new0 = jni.Jni.accessors.getMethodIDOf(_class.reference, + r"", r"(Lcom/github/dart_lang/jnigen/simple_package/Example;)V"); + + /// from: public void (com.github.dart_lang.jnigen.simple_package.Example $parent) + /// The returned object must be deleted after use, by calling the `delete` method. + factory Example_NonStaticNested( + Example $parent, + ) { + return Example_NonStaticNested.fromRef(jni.Jni.accessors.newObjectWithArgs( + _class.reference, _id_new0, [$parent.reference]).object); + } +} + +class $Example_NonStaticNestedType + extends jni.JObjType { + const $Example_NonStaticNestedType(); + + @override + String get signature => + r"Lcom/github/dart_lang/jnigen/simple_package/Example$NonStaticNested;"; + + @override + Example_NonStaticNested fromRef(jni.JObjectPtr ref) => + Example_NonStaticNested.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($Example_NonStaticNestedType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == ($Example_NonStaticNestedType) && + other is $Example_NonStaticNestedType; + } +} + /// from: com.github.dart_lang.jnigen.simple_package.Exceptions class Exceptions extends jni.JObject { @override @@ -1304,6 +1614,89 @@ class $Example1Type extends jni.JObjType { } } +/// from: com.github.dart_lang.jnigen.generics.GenericTypeParams +class GenericTypeParams<$S extends jni.JObject, $K extends jni.JObject> + extends jni.JObject { + @override + late final jni.JObjType> $type = type(S, K); + + final jni.JObjType<$S> S; + final jni.JObjType<$K> K; + + GenericTypeParams.fromRef( + this.S, + this.K, + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + static final _class = jni.Jni.findJClass( + r"com/github/dart_lang/jnigen/generics/GenericTypeParams"); + + /// The type which includes information such as the signature of this class. + static $GenericTypeParamsType<$S, $K> + type<$S extends jni.JObject, $K extends jni.JObject>( + jni.JObjType<$S> S, + jni.JObjType<$K> K, + ) { + return $GenericTypeParamsType( + S, + K, + ); + } + + static final _id_new0 = + jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); + + /// from: public void () + /// The returned object must be deleted after use, by calling the `delete` method. + factory GenericTypeParams({ + required jni.JObjType<$S> S, + required jni.JObjType<$K> K, + }) { + return GenericTypeParams.fromRef( + S, + K, + jni.Jni.accessors + .newObjectWithArgs(_class.reference, _id_new0, []).object); + } +} + +class $GenericTypeParamsType<$S extends jni.JObject, $K extends jni.JObject> + extends jni.JObjType> { + final jni.JObjType<$S> S; + final jni.JObjType<$K> K; + + const $GenericTypeParamsType( + this.S, + this.K, + ); + + @override + String get signature => + r"Lcom/github/dart_lang/jnigen/generics/GenericTypeParams;"; + + @override + GenericTypeParams<$S, $K> fromRef(jni.JObjectPtr ref) => + GenericTypeParams.fromRef(S, K, ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => Object.hash($GenericTypeParamsType, S, K); + + @override + bool operator ==(Object other) { + return other.runtimeType == ($GenericTypeParamsType<$S, $K>) && + other is $GenericTypeParamsType<$S, $K> && + S == other.S && + K == other.K; + } +} + /// from: com.github.dart_lang.jnigen.generics.GrandParent class GrandParent<$T extends jni.JObject> extends jni.JObject { @override diff --git a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/generics/GenericTypeParams.java b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/generics/GenericTypeParams.java new file mode 100644 index 000000000..2a41875c3 --- /dev/null +++ b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/generics/GenericTypeParams.java @@ -0,0 +1,9 @@ +// 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. + +package com.github.dart_lang.jnigen.generics; + +public class GenericTypeParams> {} + +// TODO: Add more cases of generic parameters 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 new file mode 100644 index 000000000..f9157e426 --- /dev/null +++ b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/BaseClass.java @@ -0,0 +1,7 @@ +// 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. + +package com.github.dart_lang.jnigen.inheritance; + +public class BaseClass {} diff --git a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/GenericDerivedClass.java b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/GenericDerivedClass.java new file mode 100644 index 000000000..5829657f7 --- /dev/null +++ b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/GenericDerivedClass.java @@ -0,0 +1,7 @@ +// 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. + +package com.github.dart_lang.jnigen.inheritance; + +public class GenericDerivedClass extends BaseClass {} 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 new file mode 100644 index 000000000..6c33e8315 --- /dev/null +++ b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/SpecificDerivedClass.java @@ -0,0 +1,7 @@ +// 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. + +package com.github.dart_lang.jnigen.inheritance; + +public class SpecificDerivedClass extends BaseClass {} diff --git a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/simple_package/Color.java b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/simple_package/Color.java new file mode 100644 index 000000000..efb96c6e4 --- /dev/null +++ b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/simple_package/Color.java @@ -0,0 +1,14 @@ +// 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. + +package com.github.dart_lang.jnigen.simple_package; + +public enum Color { + RED, + BLUE, + BLACK, + GREEN, + YELLOW, + LIME +} diff --git a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/simple_package/Example.java b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/simple_package/Example.java index 47fab9d24..b96156eba 100644 --- a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/simple_package/Example.java +++ b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/simple_package/Example.java @@ -14,6 +14,8 @@ public class Example { public static final char SEMICOLON = ';'; public static final String SEMICOLON_STRING = ";"; + public static final Random unusedRandom = new Random(); + private static int amount = 500; private static double pi = 3.14159; private static char asterisk = '*'; @@ -123,6 +125,26 @@ public String getRandomNumericString(Random random) { "%d%d%d%d", random.nextInt(10), random.nextInt(10), random.nextInt(10), random.nextInt(10)); } + private void privateMethod(String a, String b) {} + + protected void protectedMethod(String a, String b) {} + + protected Random protectedField; + + public final void finalMethod() {} + + public List getList() { + return null; + } + + /** Joins the strings in the list using the given delimiter. */ + public String joinStrings(List values, String delim) { + return null; + } + + public void methodWithSeveralParams( + char ch, String s, int[] a, T t, List lt, Map wm) {} + public Example() { this(0); } @@ -169,6 +191,20 @@ public static void throwException() { throw new RuntimeException("Hello"); } + public void overloaded() {} + + public void overloaded(int a, String b) {} + + public void overloaded(int a) {} + + public void overloaded(List a, String b) {} + + public void overloaded(List a) {} + + public class NonStaticNested { + public boolean ok; + } + public static class Nested { private boolean value; 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 e14dbfbbd..3e7d657f4 100644 --- a/pkgs/jnigen/test/simple_package_test/runtime_test_registrant.dart +++ b/pkgs/jnigen/test/simple_package_test/runtime_test_registrant.dart @@ -22,7 +22,7 @@ void registerTests(String groupName, TestRunnerCallback test) { expect(Example.ON, equals(1)); expect(Example.OFF, equals(0)); expect(Example.PI, closeTo(pi, fpDelta)); - expect(Example.SEMICOLON, equals(';')); + expect(Example.SEMICOLON, equals(';'.codeUnitAt(0))); expect(Example.SEMICOLON_STRING, equals(';')); }); diff --git a/pkgs/jnigen/test/summary_generation_test.dart b/pkgs/jnigen/test/summary_generation_test.dart index e1657f1a8..62eee3b8a 100644 --- a/pkgs/jnigen/test/summary_generation_test.dart +++ b/pkgs/jnigen/test/summary_generation_test.dart @@ -1,4 +1,4 @@ -// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file +// 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. @@ -7,18 +7,16 @@ @Tags(['summarizer_test']) -import 'dart:io'; import 'dart:math'; import 'package:jnigen/src/config/config.dart'; import 'package:jnigen/src/elements/elements.dart'; -import 'package:jnigen/src/logging/logging.dart'; import 'package:jnigen/src/summary/summary.dart'; -import 'package:logging/logging.dart'; import 'package:path/path.dart' hide equals; import 'package:test/test.dart'; +import 'test_util/summary_util.dart'; import 'test_util/test_util.dart'; const nestedClasses = [ @@ -43,18 +41,6 @@ void expectSummaryHasAllClasses(Classes? classes) { expect(declNames, containsAll(expectedClasses)); } -void deleteTempDir(Directory directory) { - try { - if (Platform.isWindows) { - // This appears to avoid "file used by another process" errors. - sleep(const Duration(seconds: 1)); - } - directory.deleteSync(recursive: true); - } on FileSystemException catch (e) { - log.warning("Cannot delete directory: $e"); - } -} - /// Packs files indicated by [artifacts], each relative to [artifactDir] into /// a JAR file at [jarPath]. Future createJar({ @@ -69,44 +55,6 @@ Future createJar({ ); } -String getClassNameFromPath(String path) { - if (!path.endsWith('.java')) { - throw ArgumentError('Filename must end with java'); - } - return path - .replaceAll('/', '.') - .replaceAll('\\', '.') - .substring(0, path.length - 5); -} - -final simplePackagePath = join('test', 'simple_package_test', 'java'); -final simplePackageDir = Directory(simplePackagePath); -final javaFiles = findFilesWithSuffix(simplePackageDir, '.java'); -final javaClasses = javaFiles.map(getClassNameFromPath).toList(); -// remove individual class listings from one package, -// and add the package name instead, for testing. -const _removalPackage = 'com.github.dart_lang.jnigen.pkg2'; -final summarizerClassesSpec = [ - ...javaClasses.where((e) => !e.startsWith('$_removalPackage.')), - _removalPackage, -]; - -Config getConfig({List? sourcePath, List? classPath}) { - return Config( - outputConfig: OutputConfig( - bindingsType: BindingsType.dartOnly, - dartConfig: DartCodeOutputConfig( - path: Uri.file('unused.dart'), - structure: OutputStructure.singleFile, - ), - ), - classes: summarizerClassesSpec, - sourcePath: sourcePath?.map((e) => Uri.file(e)).toList(), - classPath: classPath?.map((e) => Uri.file(e)).toList(), - logLevel: Level.WARNING, - ); -} - final random = Random.secure(); void testSuccessCase(String description, Config config) { @@ -141,16 +89,16 @@ void testAllCases({ }) { testSuccessCase( '- valid config', - getConfig(sourcePath: sourcePath, classPath: classPath), + getSummaryGenerationConfig(sourcePath: sourcePath, classPath: classPath), ); testFailureCase( '- should fail with non-existing class', - getConfig(sourcePath: sourcePath, classPath: classPath), + getSummaryGenerationConfig(sourcePath: sourcePath, classPath: classPath), 'com.github.dart_lang.jnigen.DoesNotExist', ); testFailureCase( '- should fail with non-existing package', - getConfig(sourcePath: sourcePath, classPath: classPath), + getSummaryGenerationConfig(sourcePath: sourcePath, classPath: classPath), 'com.github.dart_lang.notexist', ); } @@ -222,5 +170,5 @@ void main() async { ); }); - tearDownAll(() => deleteTempDir(tempDir)); + tearDownAll(() => deleteTempDirWithDelay(tempDir)); } diff --git a/pkgs/jnigen/test/summary_test.dart b/pkgs/jnigen/test/summary_test.dart new file mode 100644 index 000000000..c83e798a3 --- /dev/null +++ b/pkgs/jnigen/test/summary_test.dart @@ -0,0 +1,323 @@ +// 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. + +// These tests validate individual characteristics in summary +// For example, the values of methods, arguments, types, generic params etc... +@Tags(['summarizer_test']) + +import 'package:jnigen/src/elements/elements.dart'; +import 'package:jnigen/src/summary/summary.dart'; +import 'package:test/test.dart'; + +import 'test_util/summary_util.dart'; +import 'test_util/test_util.dart'; + +const jnigenPackage = 'com.github.dart_lang.jnigen'; +const simplePackage = "$jnigenPackage.simple_package"; + +extension on Classes { + String _getSimpleName(ClassDecl c) { + return c.binaryName.split(".").last; + } + + ClassDecl getClassBySimpleName(String simpleName) { + return decls.values.firstWhere((c) => _getSimpleName(c) == simpleName); + } + + ClassDecl getClass(String dirName, String className) { + return decls['$jnigenPackage.$dirName.$className']!; + } + + ClassDecl getExampleClass() { + return getClass('simple_package', 'Example'); + } +} + +extension on ClassDecl { + Method getMethod(String name) => methods.firstWhere((m) => m.name == name); + Field getField(String name) => fields.firstWhere((f) => f.name == name); +} + +void registerCommonTests(Classes classes) { + test('static modifier', () { + final example = classes.getExampleClass(); + final containsStatic = contains("static"); + final notContainsStatic = isNot(containsStatic); + expect(example.getMethod("max4").modifiers, containsStatic); + expect(example.getMethod("getCodename").modifiers, notContainsStatic); + expect(example.getField("ON").modifiers, containsStatic); + expect(example.getField("codename").modifiers, notContainsStatic); + final nested = classes.getClassBySimpleName("Example\$Nested"); + expect(nested.modifiers, containsStatic); + final nonStaticNested = + classes.getClassBySimpleName("Example\$NonStaticNested"); + expect(nonStaticNested.modifiers, notContainsStatic); + }); + + test('Public, protected and private modifiers', () { + final example = classes.getExampleClass(); + final hasPrivate = contains("private"); + final hasProtected = contains("protected"); + final hasPublic = contains("public"); + final isPrivate = allOf(hasPrivate, isNot(hasProtected), isNot(hasPublic)); + final isProtected = + allOf(isNot(hasPrivate), hasProtected, isNot(hasPublic)); + final isPublic = allOf(isNot(hasPrivate), isNot(hasProtected), hasPublic); + expect(example.getMethod("getNumber").modifiers, isPublic); + expect(example.getMethod("privateMethod").modifiers, isPrivate); + expect(example.getMethod("protectedMethod").modifiers, isProtected); + expect(example.getField("OFF").modifiers, isPublic); + expect(example.getField("number").modifiers, isPrivate); + expect(example.getField("protectedField").modifiers, isProtected); + }); + + test('final modifier', () { + final example = classes.getExampleClass(); + final isFinal = contains('final'); + expect(example.getField("PI").modifiers, isFinal); + expect(example.getField("unusedRandom").modifiers, isFinal); + expect(example.getField("number").modifiers, isNot(isFinal)); + expect(example.getMethod("finalMethod").modifiers, isFinal); + }); + + void assertToBeStringListType(TypeUsage listType) { + expect(listType.kind, equals(Kind.declared)); + final listClassType = listType.type as DeclaredType; + expect(listClassType.binaryName, equals('java.util.List')); + expect(listClassType.params, hasLength(1)); + final listTypeParam = listClassType.params[0]; + expect(listTypeParam.kind, equals(Kind.declared)); + expect(listTypeParam.type.name, equals('java.lang.String')); + } + + test('return types', () { + final example = classes.getExampleClass(); + expect(example.getMethod("getNumber").returnType.shorthand, equals("int")); + expect(example.getMethod("getName").returnType.shorthand, + equals("java.lang.String")); + expect(example.getMethod("getNestedInstance").returnType.name, + equals("$simplePackage.Example\$Nested")); + final listType = example.getMethod("getList").returnType; + assertToBeStringListType(listType); + }); + + test('parameter types', () { + final example = classes.getExampleClass(); + final joinStrings = example.getMethod('joinStrings'); + final listType = joinStrings.params[0].type; + assertToBeStringListType(listType); + final stringType = joinStrings.params[1].type; + expect(stringType.kind, Kind.declared); + expect((stringType.type as DeclaredType).binaryName, 'java.lang.String'); + }); + + test('Parameters of several types', () { + final example = classes.getExampleClass(); + final method = example.getMethod('methodWithSeveralParams'); + expect(method.typeParams, hasLength(1)); + expect(method.typeParams[0].name, 'T'); + expect(method.typeParams[0].bounds[0].name, 'java.lang.CharSequence'); + + final charParam = method.params[0]; + expect(charParam.type.kind, equals(Kind.primitive)); + expect(charParam.type.name, equals('char')); + + final stringParam = method.params[1]; + expect(stringParam.type.kind, equals(Kind.declared)); + expect((stringParam.type.type as DeclaredType).binaryName, + equals('java.lang.String')); + + final arrayParam = method.params[2]; + expect(arrayParam.type.kind, equals(Kind.array)); + expect((arrayParam.type.type as ArrayType).type.name, equals('int')); + + final typeVarParam = method.params[3]; + expect(typeVarParam.type.kind, equals(Kind.typeVariable)); + expect((typeVarParam.type.type as TypeVar).name, equals('T')); + + final listParam = method.params[4]; + expect(listParam.type.kind, equals(Kind.declared)); + final listType = (listParam.type.type as DeclaredType); + expect(listType.binaryName, equals('java.util.List')); + expect(listType.params, hasLength(1)); + final tType = listType.params[0]; + expect(tType.kind, Kind.typeVariable); + expect((tType.type as TypeVar).name, equals('T')); + + final wildcardMapParam = method.params[5]; + expect(wildcardMapParam.type.kind, equals(Kind.declared)); + final mapType = (wildcardMapParam.type.type as DeclaredType); + expect(mapType.binaryName, equals('java.util.Map')); + expect(mapType.params, hasLength(2)); + final strType = mapType.params[0]; + expect(strType.name, 'java.lang.String'); + // TODO(#141): Wildcard implementation. + /* + final wildcardType = mapType.params[1]; + expect(wildcardType.kind, equals(Kind.wildcard)); + expect((wildcardType.type as Wildcard).extendsBound?.name, + equals('java.lang.CharSequence')); + */ + }); + + test('superclass', () { + final baseClass = classes.getClass('inheritance', 'BaseClass'); + expect(baseClass.typeParams, hasLength(1)); + final typeParam = baseClass.typeParams.single; + expect(typeParam.bounds.map((b) => b.name).toList(), + ['java.lang.CharSequence']); + + final specific = classes.getClass('inheritance', 'SpecificDerivedClass'); + expect(specific.typeParams, hasLength(0)); + expect(specific.superclass, isNotNull); + final specificSuper = specific.superclass!.type as DeclaredType; + expect(specificSuper.params[0].type, isA()); + expect(specificSuper.params[0].type.name, equals('java.lang.String')); + + final generic = classes.getClass('inheritance', 'GenericDerivedClass'); + expect(generic.typeParams, hasLength(1)); + expect(generic.typeParams[0].name, equals('T')); + expect(generic.typeParams[0].bounds.map((b) => b.name).toList(), + ['java.lang.CharSequence']); + expect(generic.superclass, isNotNull); + final genericSuper = generic.superclass!.type as DeclaredType; + expect(genericSuper.params[0].type, isA()); + expect(genericSuper.params[0].type.name, equals('T')); + }); + + test('constructor is included', () { + final example = classes.getExampleClass(); + void assertOneCtorExistsWithArity(List paramTypes) { + final arityCtors = example.methods + .where( + (m) => m.name == '' && m.params.length == paramTypes.length) + .toList(); + expect(arityCtors, hasLength(1)); + final ctor = arityCtors[0]; + expect(ctor.params.map((p) => p.type.name), equals(paramTypes)); + } + + assertOneCtorExistsWithArity([]); + assertOneCtorExistsWithArity(['int']); + assertOneCtorExistsWithArity(['int', 'boolean']); + assertOneCtorExistsWithArity(['int', 'boolean', 'java.lang.String']); + }); + + test('Overloaded methods', () { + final methods = classes + .getExampleClass() + .methods + .where((m) => m.name == 'overloaded') + .toList(); + final signatures = + methods.map((m) => m.params.map((p) => p.type.name).toList()).toSet(); + expect( + signatures, + equals({ + [], + ['int'], + ['int', 'java.lang.String'], + ['java.util.List'], + ['java.util.List', 'java.lang.String'], + }), + ); + }); + + test('Declaration type (class vs interface vs enum)', () { + final example = classes.getExampleClass(); + expect(example.declKind, DeclKind.classKind); + final myInterface = classes.getClass('interfaces', 'MyInterface'); + expect(myInterface.declKind, DeclKind.interfaceKind); + final color = classes.getClass('simple_package', 'Color'); + expect(color.declKind, DeclKind.enumKind); + }); + + test('Enum values', () { + final example = classes.getExampleClass(); + expect(example.values, anyOf(isNull, isEmpty)); + final color = classes.getClass('simple_package', 'Color'); + const expectedEnumValues = { + 'RED', + 'BLUE', + 'BLACK', + 'GREEN', + 'YELLOW', + 'LIME' + }; + expect(color.values?.toSet(), expectedEnumValues); + }); + + test('Static final field values', () { + final example = classes.getExampleClass(); + expect(example.getField("ON").defaultValue, equals(1)); + expect(example.getField("OFF").defaultValue, equals(0)); + expect(example.getField("PI").defaultValue, closeTo(3.14159, 0.001)); + expect( + example.getField("SEMICOLON").defaultValue, equals(';'.codeUnitAt(0))); + expect(example.getField("SEMICOLON_STRING").defaultValue, equals(';')); + }); + + test('self referencing generic parameters', () { + final gp = classes.getClass('generics', 'GenericTypeParams'); + final typeParams = gp.typeParams; + expect(typeParams[0].name, equals('S')); + expect(typeParams[0].bounds.map((e) => e.name), ['java.lang.CharSequence']); + expect(typeParams[1].name, equals('K')); + final selfBound = typeParams[1].bounds[0]; + expect(selfBound.kind, Kind.declared); + expect(selfBound.name, + equals('com.github.dart_lang.jnigen.generics.GenericTypeParams')); + final selfBoundType = selfBound.type as DeclaredType; + expect(selfBoundType.params, hasLength(2)); + expect(selfBoundType.params.map((e) => e.name), ['S', 'K']); + expect(selfBoundType.params.map((e) => e.kind), + [Kind.typeVariable, Kind.typeVariable]); + }); +} + +void main() async { + await checkLocallyBuiltDependencies(); + + final tempDir = getTempDir("jnigen_summary_tests_"); + + final sourceConfig = + getSummaryGenerationConfig(sourcePath: [simplePackagePath]); + final parsedFromSource = await getSummary(sourceConfig); + + final targetDir = tempDir.createTempSync("compiled_classes_test_"); + await compileJavaFiles(simplePackageDir, targetDir); + final classConfig = getSummaryGenerationConfig(classPath: [targetDir.path]); + final parsedFromClasses = await getSummary(classConfig); + + group('source summary', () { + registerCommonTests(parsedFromSource); + }); + + group('compiled summary', () { + registerCommonTests(parsedFromClasses); + }); + + group('source-based summary features', () { + final classes = parsedFromSource; + test('Parameter names', () { + final example = classes.getExampleClass(); + final joinStrings = example.getMethod('joinStrings'); + expect( + joinStrings.params.map((p) => p.name).toList(), ['values', 'delim']); + final methodWithSeveralParams = + example.getMethod("methodWithSeveralParams"); + expect(methodWithSeveralParams.params.map((p) => p.name).toList(), + ['ch', 's', 'a', 't', 'lt', 'wm']); + }); + + test('Javadoc comment', () { + final example = classes.getExampleClass(); + final joinStrings = example.getMethod('joinStrings'); + expect(joinStrings.javadoc?.comment, + contains("Joins the strings in the list using the given delimiter.")); + }); + }); + + tearDownAll(() => tempDir.deleteSync(recursive: true)); +} diff --git a/pkgs/jnigen/test/test_util/summary_util.dart b/pkgs/jnigen/test/test_util/summary_util.dart new file mode 100644 index 000000000..0d445837c --- /dev/null +++ b/pkgs/jnigen/test/test_util/summary_util.dart @@ -0,0 +1,75 @@ +// 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 'dart:io'; + +import 'package:jnigen/src/config/config.dart'; +import 'package:jnigen/src/logging/logging.dart'; +import 'package:logging/logging.dart'; +import 'package:path/path.dart'; + +import 'test_util.dart'; + +String getClassNameFromPath(String path) { + if (!path.endsWith('.java')) { + throw ArgumentError('Filename must end with java'); + } + return path + .replaceAll('/', '.') + .replaceAll('\\', '.') + .substring(0, path.length - 5); +} + +/// test/simple_package_test/java +final simplePackagePath = join('test', 'simple_package_test', 'java'); + +/// Directory(test/simple_package_test/java) +final simplePackageDir = Directory(simplePackagePath); + +/// All Java files in simple_package_test/java +final javaFiles = findFilesWithSuffix(simplePackageDir, '.java'); + +/// All Java classes in simple_package_test/java +final javaClasses = javaFiles.map(getClassNameFromPath).toList(); + +// Remove individual class listings from one package, +// and add the package name instead, for testing. + +const removalPackageForSummaryTests = 'com.github.dart_lang.jnigen.pkg2'; + +/// List of FQNs passed to summarizer for simple_package_test. +final summarizerClassesSpec = [ + ...javaClasses.where((e) => !e.startsWith('$removalPackageForSummaryTests.')), + removalPackageForSummaryTests, +]; + +Config getSummaryGenerationConfig( + {List? sourcePath, List? classPath}) { + return Config( + outputConfig: OutputConfig( + bindingsType: BindingsType.dartOnly, + dartConfig: DartCodeOutputConfig( + path: Uri.file('unused.dart'), + structure: OutputStructure.singleFile, + ), + ), + // Make a defensive copy of class list, if some test mutates the list... + classes: summarizerClassesSpec.toList(), + sourcePath: sourcePath?.map((e) => Uri.file(e)).toList(), + classPath: classPath?.map((e) => Uri.file(e)).toList(), + logLevel: Level.WARNING, + ); +} + +void deleteTempDirWithDelay(Directory directory) { + try { + if (Platform.isWindows) { + // This appears to avoid "file used by another process" errors. + sleep(const Duration(seconds: 1)); + } + directory.deleteSync(recursive: true); + } on FileSystemException catch (e) { + log.warning("Cannot delete directory: $e"); + } +} From 95c8375a7e7817573e949df997a18bba26195852 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Thu, 24 Aug 2023 11:29:43 +0200 Subject: [PATCH 117/139] [jnigen] Finalize interfaces in Java (https://github.com/dart-lang/jnigen/issues/369) --- .../com/github/dart_lang/jni/PortCleaner.java | 88 +++++++++++++++++++ .../com/github/dart_lang/jni/PortProxy.java | 38 ++++---- pkgs/jni/src/dartjni.c | 15 +++- .../lib/src/bindings/dart_generator.dart | 59 ++++++------- pkgs/jnigen/lib/src/config/config_types.dart | 7 ++ .../c_based/dart_bindings/simple_package.dart | 21 ++--- .../dart_bindings/simple_package.dart | 21 ++--- .../test/simple_package_test/generate.dart | 5 ++ .../runtime_test_registrant.dart | 32 +++++-- 9 files changed, 199 insertions(+), 87 deletions(-) create mode 100644 pkgs/jni/java/src/main/java/com/github/dart_lang/jni/PortCleaner.java diff --git a/pkgs/jni/java/src/main/java/com/github/dart_lang/jni/PortCleaner.java b/pkgs/jni/java/src/main/java/com/github/dart_lang/jni/PortCleaner.java new file mode 100644 index 000000000..161ef5ea5 --- /dev/null +++ b/pkgs/jni/java/src/main/java/com/github/dart_lang/jni/PortCleaner.java @@ -0,0 +1,88 @@ +// 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. + +package com.github.dart_lang.jni; + +import java.lang.ref.PhantomReference; +import java.lang.ref.ReferenceQueue; + +/// A registry of Java objects with associated Dart resources that cleans up the +/// resources after they get unreachable and collected by the garbage collector. +/// +/// A simple alternative to [java.lang.ref.Cleaner] which is only available in +/// Android API level 33+. +class PortCleaner { + static { + System.loadLibrary("dartjni"); + } + + private final ReferenceQueue queue = new ReferenceQueue<>(); + private final PortPhantom list = new PortPhantom(); + + private class PortPhantom extends PhantomReference { + final long port; + + /// Form a linked list. + PortPhantom prev = this, next = this; + + PortPhantom(Object referent, long port) { + super(referent, queue); + this.port = port; + insert(); + } + + /// Only used for the head of the list. + PortPhantom() { + super(null, null); + this.port = 0; + } + + void insert() { + synchronized (list) { + prev = list; + next = list.next; + next.prev = this; + list.next = this; + } + } + + private void remove() { + synchronized (list) { + next.prev = prev; + prev.next = next; + prev = this; + next = this; + } + } + } + + PortCleaner() { + // Only a single PortCleaner and therefore thread will be created. + Thread thread = + new Thread( + () -> { + while (true) { + try { + PortPhantom portPhantom = (PortPhantom) queue.remove(); + portPhantom.remove(); + if (portPhantom.port != 0) { + clean(portPhantom.port); + } + } catch (Throwable e) { + // Ignore. + } + } + }, + "PortCleaner"); + thread.setDaemon(true); + thread.start(); + } + + /// Registers [obj] to be cleaned up later by sending a signal through [port]. + void register(Object obj, long port) { + new PortPhantom(obj, port); + } + + private static native void clean(long port); +} diff --git a/pkgs/jni/java/src/main/java/com/github/dart_lang/jni/PortProxy.java b/pkgs/jni/java/src/main/java/com/github/dart_lang/jni/PortProxy.java index 77cff1357..ff9c0766a 100644 --- a/pkgs/jni/java/src/main/java/com/github/dart_lang/jni/PortProxy.java +++ b/pkgs/jni/java/src/main/java/com/github/dart_lang/jni/PortProxy.java @@ -11,6 +11,7 @@ public class PortProxy implements InvocationHandler { System.loadLibrary("dartjni"); } + private static final PortCleaner cleaner = new PortCleaner(); private final long port; private final long isolateId; private final long functionPtr; @@ -23,48 +24,53 @@ private PortProxy(long port, long isolateId, long functionPtr) { private static String getDescriptor(Method method) { StringBuilder descriptor = new StringBuilder(); - descriptor.append(method.getName()).append("("); + descriptor.append(method.getName()).append('('); Class[] parameterTypes = method.getParameterTypes(); for (Class paramType : parameterTypes) { appendType(descriptor, paramType); } - descriptor.append(")"); + descriptor.append(')'); appendType(descriptor, method.getReturnType()); return descriptor.toString(); } private static void appendType(StringBuilder descriptor, Class type) { if (type == void.class) { - descriptor.append("V"); + descriptor.append('V'); } else if (type == boolean.class) { - descriptor.append("Z"); + descriptor.append('Z'); } else if (type == byte.class) { - descriptor.append("B"); + descriptor.append('B'); } else if (type == char.class) { - descriptor.append("C"); + descriptor.append('C'); } else if (type == short.class) { - descriptor.append("S"); + descriptor.append('S'); } else if (type == int.class) { - descriptor.append("I"); + descriptor.append('I'); } else if (type == long.class) { - descriptor.append("J"); + descriptor.append('J'); } else if (type == float.class) { - descriptor.append("F"); + descriptor.append('F'); } else if (type == double.class) { - descriptor.append("D"); + descriptor.append('D'); } else if (type.isArray()) { descriptor.append('['); appendType(descriptor, type.getComponentType()); } else { - descriptor.append("L").append(type.getName().replace('.', '/')).append(";"); + descriptor.append('L').append(type.getName().replace('.', '/')).append(';'); } } public static Object newInstance(String binaryName, long port, long isolateId, long functionPtr) throws ClassNotFoundException { Class clazz = Class.forName(binaryName); - return Proxy.newProxyInstance( - clazz.getClassLoader(), new Class[] {clazz}, new PortProxy(port, isolateId, functionPtr)); + Object obj = + Proxy.newProxyInstance( + clazz.getClassLoader(), + new Class[] {clazz}, + new PortProxy(port, isolateId, functionPtr)); + cleaner.register(obj, port); + return obj; } @Override @@ -77,7 +83,7 @@ public Object invoke(Object proxy, Method method, Object[] args) { /// Returns an array with two objects: /// [0]: The address of the result pointer used for the clean-up. /// [1]: The result of the invocation. - private native Object[] _invoke( + private static native Object[] _invoke( long port, long isolateId, long functionPtr, @@ -85,5 +91,5 @@ private native Object[] _invoke( String methodDescriptor, Object[] args); - private native void _cleanUp(long resultPtr); + private static native void _cleanUp(long resultPtr); } diff --git a/pkgs/jni/src/dartjni.c b/pkgs/jni/src/dartjni.c index 5c34c360e..dc595a9c5 100644 --- a/pkgs/jni/src/dartjni.c +++ b/pkgs/jni/src/dartjni.c @@ -571,7 +571,7 @@ FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data) { JNIEXPORT void JNICALL Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env, - jobject thiz, + jclass clazz, jlong port, jobject result) { attach_thread(); @@ -643,7 +643,7 @@ jmethodID _m_Long_init = NULL; JNIEXPORT jobjectArray JNICALL Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, - jobject thiz, + jclass clazz, jlong port, jlong isolateId, jlong functionPtr, @@ -709,9 +709,18 @@ Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env, JNIEXPORT void JNICALL Java_com_github_dart_1lang_jni_PortProxy__1cleanUp(JNIEnv* env, - jobject thiz, + jclass clazz, jlong resultPtr) { CallbackResult* result = (CallbackResult*)resultPtr; (*env)->DeleteGlobalRef(env, result->object); free(result); } + +JNIEXPORT void JNICALL +Java_com_github_dart_1lang_jni_PortCleaner_clean(JNIEnv* env, + jclass clazz, + jlong port) { + Dart_CObject close_signal; + close_signal.type = Dart_CObject_kNull; + Dart_PostCObject_DL(port, &close_signal); +} diff --git a/pkgs/jnigen/lib/src/bindings/dart_generator.dart b/pkgs/jnigen/lib/src/bindings/dart_generator.dart index 04d095b66..3bc72cc67 100644 --- a/pkgs/jnigen/lib/src/bindings/dart_generator.dart +++ b/pkgs/jnigen/lib/src/bindings/dart_generator.dart @@ -410,30 +410,18 @@ class $name$typeParamsDef extends $superName { s.write(''' /// Maps a specific port to the implemented interface. static final Map _\$impls = {}; +'''); + s.write(r''' + ReceivePort? _$p; - ReceivePort? _\$p; - - static final Finalizer _\$finalizer = Finalizer((\$p) { - _\$impls.remove(\$p.sendPort.nativePort); - \$p.close(); - }); - - @override - void delete() { - _\$impls.remove(_\$p?.sendPort.nativePort); - _\$p?.close(); - _\$finalizer.detach(this); - super.delete(); - } - - static jni.JObjectPtr _\$invoke( + static jni.JObjectPtr _$invoke( int port, jni.JObjectPtr descriptor, jni.JObjectPtr args, ) { - return _\$invokeMethod( + return _$invokeMethod( port, - \$MethodInvocation.fromAddresses( + $MethodInvocation.fromAddresses( 0, descriptor.address, args.address, @@ -445,14 +433,14 @@ class $name$typeParamsDef extends $superName { ffi.NativeFunction< jni.JObjectPtr Function( ffi.Uint64, jni.JObjectPtr, jni.JObjectPtr)>> - _\$invokePointer = ffi.Pointer.fromFunction(_\$invoke); + _$invokePointer = ffi.Pointer.fromFunction(_$invoke); - static ffi.Pointer _\$invokeMethod( - int \$p, - \$MethodInvocation \$i, + static ffi.Pointer _$invokeMethod( + int $p, + $MethodInvocation $i, ) { - final \$d = \$i.methodDescriptor.toDartString(deleteOriginal: true); - final \$a = \$i.args; + final $d = $i.methodDescriptor.toDartString(deleteOriginal: true); + final $a = $i.args; '''); final proxyMethodIf = _InterfaceMethodIf(resolver, s); for (final method in node.methods) { @@ -482,18 +470,27 @@ class $name$typeParamsDef extends $superName { final \$a = \$p.sendPort.nativePort; _\$impls[\$a] = \$impl; '''); - s.write(''' - _\$finalizer.attach(\$x, \$p, detach: \$x); - \$p.listen((\$m) { - final \$i = \$MethodInvocation.fromMessage(\$m); - final \$r = _\$invokeMethod(\$p.sendPort.nativePort, \$i); - ProtectedJniExtensions.returnResult(\$i.result, \$r); + s.write(r''' + $p.listen(($m) { + if ($m == null) { + _$impls.remove($p.sendPort.nativePort); + $p.close(); + return; + } + final $i = $MethodInvocation.fromMessage($m); + final $r = _$invokeMethod($p.sendPort.nativePort, $i); + ProtectedJniExtensions.returnResult($i.result, $r); }); - return \$x; + return $x; } '''); } + // Writing any custom code provided for this class. + if (config.customClassBody?.containsKey(node.binaryName) ?? false) { + s.writeln(config.customClassBody![node.binaryName]); + } + // End of Class definition. s.writeln('}'); diff --git a/pkgs/jnigen/lib/src/config/config_types.dart b/pkgs/jnigen/lib/src/config/config_types.dart index 8004cee46..02dcbc2ea 100644 --- a/pkgs/jnigen/lib/src/config/config_types.dart +++ b/pkgs/jnigen/lib/src/config/config_types.dart @@ -325,6 +325,7 @@ class Config { this.sourcePath, this.classPath, this.preamble, + this.customClassBody, this.androidSdkConfig, this.mavenDownloads, this.summarizerOptions, @@ -386,6 +387,12 @@ class Config { /// Call [importClasses] before using this. late final Map importedClasses; + /// Custom code that is added to the end of the class body with the specified + /// binary name. + /// + /// Used for testing package:jnigen. + final Map? customClassBody; + Future importClasses() async { importedClasses = {}; for (final import in [ diff --git a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart index 06112a1d2..cd47f44cb 100644 --- a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart @@ -3344,22 +3344,8 @@ class MyInterface<$T extends jni.JObject> extends jni.JObject { /// Maps a specific port to the implemented interface. static final Map _$impls = {}; - ReceivePort? _$p; - static final Finalizer _$finalizer = Finalizer(($p) { - _$impls.remove($p.sendPort.nativePort); - $p.close(); - }); - - @override - void delete() { - _$impls.remove(_$p?.sendPort.nativePort); - _$p?.close(); - _$finalizer.detach(this); - super.delete(); - } - static jni.JObjectPtr _$invoke( int port, jni.JObjectPtr descriptor, @@ -3439,14 +3425,19 @@ class MyInterface<$T extends jni.JObject> extends jni.JObject { ).._$p = $p; final $a = $p.sendPort.nativePort; _$impls[$a] = $impl; - _$finalizer.attach($x, $p, detach: $x); $p.listen(($m) { + if ($m == null) { + _$impls.remove($p.sendPort.nativePort); + $p.close(); + return; + } final $i = $MethodInvocation.fromMessage($m); final $r = _$invokeMethod($p.sendPort.nativePort, $i); ProtectedJniExtensions.returnResult($i.result, $r); }); return $x; } + static Map get $impls => _$impls; } abstract class $MyInterfaceImpl<$T extends jni.JObject> { diff --git a/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart index 73d8b744d..9ca08571c 100644 --- a/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart @@ -3153,22 +3153,8 @@ class MyInterface<$T extends jni.JObject> extends jni.JObject { /// Maps a specific port to the implemented interface. static final Map _$impls = {}; - ReceivePort? _$p; - static final Finalizer _$finalizer = Finalizer(($p) { - _$impls.remove($p.sendPort.nativePort); - $p.close(); - }); - - @override - void delete() { - _$impls.remove(_$p?.sendPort.nativePort); - _$p?.close(); - _$finalizer.detach(this); - super.delete(); - } - static jni.JObjectPtr _$invoke( int port, jni.JObjectPtr descriptor, @@ -3248,14 +3234,19 @@ class MyInterface<$T extends jni.JObject> extends jni.JObject { ).._$p = $p; final $a = $p.sendPort.nativePort; _$impls[$a] = $impl; - _$finalizer.attach($x, $p, detach: $x); $p.listen(($m) { + if ($m == null) { + _$impls.remove($p.sendPort.nativePort); + $p.close(); + return; + } final $i = $MethodInvocation.fromMessage($m); final $r = _$invokeMethod($p.sendPort.nativePort, $i); ProtectedJniExtensions.returnResult($i.result, $r); }); return $x; } + static Map get $impls => _$impls; } abstract class $MyInterfaceImpl<$T extends jni.JObject> { diff --git a/pkgs/jnigen/test/simple_package_test/generate.dart b/pkgs/jnigen/test/simple_package_test/generate.dart index ce38009d3..446cfb285 100644 --- a/pkgs/jnigen/test/simple_package_test/generate.dart +++ b/pkgs/jnigen/test/simple_package_test/generate.dart @@ -64,6 +64,11 @@ Config getConfig([BindingsType bindingsType = BindingsType.cBased]) { 'com.github.dart_lang.jnigen.annotations', ], logLevel: Level.INFO, + customClassBody: { + 'com.github.dart_lang.jnigen.interfaces.MyInterface': r''' + static Map get $impls => _$impls; +''' + }, outputConfig: OutputConfig( bindingsType: bindingsType, cConfig: CCodeOutputConfig( 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 3e7d657f4..665a26d50 100644 --- a/pkgs/jnigen/test/simple_package_test/runtime_test_registrant.dart +++ b/pkgs/jnigen/test/simple_package_test/runtime_test_registrant.dart @@ -16,6 +16,11 @@ const pi = 3.14159; const fpDelta = 0.001; const trillion = 1024 * 1024 * 1024 * 1024; +void _runJavaGC() { + final system = Jni.findJClass('java/lang/System'); + system.callStaticMethodByName('gc', '()V', []); +} + void registerTests(String groupName, TestRunnerCallback test) { group(groupName, () { test('static final fields - int', () { @@ -531,11 +536,11 @@ void registerTests(String groupName, TestRunnerCallback test) { }); group('interface implementation', () { - for (final method in { - 'another thread': MyInterfaceConsumer.consumeOnAnotherThread, - 'the same thread': MyInterfaceConsumer.consumeOnSameThread, - }.entries) { - test('MyInterface.implement on ${method.key}', () async { + 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(); @@ -574,7 +579,7 @@ void registerTests(String groupName, TestRunnerCallback test) { // [voidCallback]. // The other two methods will be called individually using the passed // arguments afterwards. - method.value( + consume( myInterface, // For stringCallback: 'hello'.toJString(), @@ -595,7 +600,20 @@ void registerTests(String groupName, TestRunnerCallback test) { final manyPrimitives = await manyPrimitivesResult.future; expect(manyPrimitives, -1 + 3 + 3.14.toInt() + 1); + // Currently we have one implementation of the interface. + expect(MyInterface.$impls, hasLength(1)); myInterface.delete(); + // Running System.gc() and waiting. + _runJavaGC(); + for (var i = 0; i < 8; ++i) { + await Future.delayed(Duration(milliseconds: (1 << i) * 100)); + if (MyInterface.$impls.isEmpty) { + break; + } + } + // Since the interface is now deleted, the cleaner must signal to Dart + // to clean up. + expect(MyInterface.$impls, isEmpty); }); } }); @@ -603,7 +621,7 @@ void registerTests(String groupName, TestRunnerCallback test) { 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', () { + test('Create large number of JNI references without deleting', () { for (int i = 0; i < k4; i++) { final e = Example.new1(i); expect(e.getNumber(), equals(i)); From b7cc04891f68554119cb9133d7a537ba3c72f772 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Thu, 24 Aug 2023 17:03:07 +0200 Subject: [PATCH 118/139] [jnigen] Run Java GC using jcmd in tests (https://github.com/dart-lang/jnigen/issues/371) meta: remove apk builds from windows minimal CI --- .github/workflows/test-package.yml | 6 ------ pkgs/jnigen/test/descriptor_test.dart | 19 +++++++++---------- .../runtime_test_registrant.dart | 12 ++++++++++-- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 7f6bcb331..5846f3c16 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -248,12 +248,6 @@ jobs: - run: Add-Content $env:GITHUB_PATH "$env:JAVA_HOME\bin\server" - run: dart pub get - run: dart run jnigen:setup - - name: build in_app_java APK - run: flutter build apk --target-platform=android-arm64 - working-directory: ./pkgs/jnigen/example/in_app_java - - name: build notification_plugin example APK - run: flutter build apk --target-platform=android-arm64 - working-directory: ./pkgs/jnigen/example/notification_plugin/example - name: Build summarizer run: dart run jnigen:setup - name: Generate runtime tests diff --git a/pkgs/jnigen/test/descriptor_test.dart b/pkgs/jnigen/test/descriptor_test.dart index 41ac58cf5..f1b906034 100644 --- a/pkgs/jnigen/test/descriptor_test.dart +++ b/pkgs/jnigen/test/descriptor_test.dart @@ -16,14 +16,13 @@ import 'test_util/test_util.dart'; void main() { checkLocallyBuiltDependencies(); - test('Method descriptor generation', timeout: const Timeout.factor(3), - () async { - final configGetters = [ - simple_package_test.getConfig, - kotlin_test.getConfig, - jackson_core_test.getConfig - ]; - for (final getConfig in configGetters) { + for (final (name, getConfig) in [ + ('simple_package', simple_package_test.getConfig), + ('kotlin', kotlin_test.getConfig), + ('jackson_core', jackson_core_test.getConfig), + ]) { + test('Method descriptor generation for $name', + timeout: const Timeout.factor(3), () async { final config = getConfig(); config.summarizerOptions = SummarizerOptions(backend: SummarizerBackend.asm); @@ -38,6 +37,6 @@ void main() { expect(method.descriptor, method.accept(methodDescriptor)); } } - } - }); + }); + } } 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 665a26d50..cae97587c 100644 --- a/pkgs/jnigen/test/simple_package_test/runtime_test_registrant.dart +++ b/pkgs/jnigen/test/simple_package_test/runtime_test_registrant.dart @@ -17,8 +17,16 @@ const fpDelta = 0.001; const trillion = 1024 * 1024 * 1024 * 1024; void _runJavaGC() { - final system = Jni.findJClass('java/lang/System'); - system.callStaticMethodByName('gc', '()V', []); + final managementFactory = + Jni.findJClass('java/lang/management/ManagementFactory'); + final bean = managementFactory.callStaticMethodByName( + 'getRuntimeMXBean', '()Ljava/lang/management/RuntimeMXBean;', []); + final pid = bean.callMethodByName('getPid', '()J', []); + ProcessResult result; + do { + sleep(const Duration(milliseconds: 100)); + result = Process.runSync('jcmd', [pid.toString(), 'GC.run']); + } while (result.exitCode != 0); } void registerTests(String groupName, TestRunnerCallback test) { From 244596e939a38995f12523daa32cc4ec1f5d7057 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Tue, 29 Aug 2023 13:04:18 +0200 Subject: [PATCH 119/139] [jnigen] Throw DartExceptions in Java (https://github.com/dart-lang/jnigen/issues/376) --- pkgs/jni/example/android/app/build.gradle | 2 +- .../com/github/dart_lang/jni/PortProxy.java | 11 +- pkgs/jni/lib/src/jni.dart | 27 +- pkgs/jni/lib/src/lang/jstring.dart | 11 +- .../third_party/jni_bindings_generated.dart | 38 ++- pkgs/jni/src/dartjni.c | 23 ++ pkgs/jni/src/dartjni.h | 5 +- .../android/app/build.gradle | 2 +- .../in_app_java/android/app/build.gradle | 2 +- .../in_app_java/src/android_utils/dartjni.h | 5 +- .../example/android/app/build.gradle | 2 +- .../example/kotlin_plugin/src/dartjni.h | 5 +- .../example/android/app/build.gradle | 2 +- .../example/notification_plugin/src/dartjni.h | 5 +- .../example/android/app/build.gradle | 2 +- .../pdfbox_plugin/src/third_party/dartjni.h | 5 +- .../lib/src/bindings/dart_generator.dart | 36 +- pkgs/jnigen/lib/src/config/experiments.dart | 2 +- .../third_party/c_based/c_bindings/dartjni.h | 5 +- .../kotlin_test/c_based/c_bindings/dartjni.h | 5 +- .../jnigen/test/regenerate_examples_test.dart | 2 +- .../c_based/c_bindings/dartjni.h | 5 +- .../c_based/c_bindings/simple_package.c | 105 ++++++ .../c_based/dart_bindings/simple_package.dart | 313 ++++++++++++++++-- .../dart_bindings/simple_package.dart | 301 +++++++++++++++-- .../test/simple_package_test/generate.dart | 2 + .../jnigen/interfaces/MyRunnable.java | 9 + .../jnigen/interfaces/MyRunnableRunner.java | 28 ++ .../runtime_test_registrant.dart | 46 ++- 29 files changed, 868 insertions(+), 138 deletions(-) create mode 100644 pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/interfaces/MyRunnable.java create mode 100644 pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/interfaces/MyRunnableRunner.java diff --git a/pkgs/jni/example/android/app/build.gradle b/pkgs/jni/example/android/app/build.gradle index 3c6742ce1..fbcc35613 100644 --- a/pkgs/jni/example/android/app/build.gradle +++ b/pkgs/jni/example/android/app/build.gradle @@ -8,7 +8,7 @@ if (localPropertiesFile.exists()) { def flutterRoot = localProperties.getProperty('flutter.sdk') if (flutterRoot == null) { - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") + throw new FileNotFoundException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") } def flutterVersionCode = localProperties.getProperty('flutter.versionCode') diff --git a/pkgs/jni/java/src/main/java/com/github/dart_lang/jni/PortProxy.java b/pkgs/jni/java/src/main/java/com/github/dart_lang/jni/PortProxy.java index ff9c0766a..3caf02af1 100644 --- a/pkgs/jni/java/src/main/java/com/github/dart_lang/jni/PortProxy.java +++ b/pkgs/jni/java/src/main/java/com/github/dart_lang/jni/PortProxy.java @@ -73,10 +73,19 @@ public static Object newInstance(String binaryName, long port, long isolateId, l return obj; } + private static final class DartException extends Exception { + private DartException(String message) { + super(message); + } + } + @Override - public Object invoke(Object proxy, Method method, Object[] args) { + public Object invoke(Object proxy, Method method, Object[] args) throws DartException { Object[] result = _invoke(port, isolateId, functionPtr, proxy, getDescriptor(method), args); _cleanUp((Long) result[0]); + if (result[1] instanceof DartException) { + throw (DartException) result[1]; + } return result[1]; } diff --git a/pkgs/jni/lib/src/jni.dart b/pkgs/jni/lib/src/jni.dart index 2957105af..d5495bc72 100644 --- a/pkgs/jni/lib/src/jni.dart +++ b/pkgs/jni/lib/src/jni.dart @@ -299,6 +299,13 @@ extension ProtectedJniExtensions on Jni { return lookup; } + /// Returns a new DartException. + static JObjectPtr newDartException(String message) { + return Jni._bindings + .DartException__ctor(Jni.env.toJStringPtr(message)) + .object; + } + /// Returns a new PortContinuation. static JObjectPtr newPortContinuation(ReceivePort port) { return Jni._bindings @@ -323,7 +330,7 @@ extension ProtectedJniExtensions on Jni { .object; } - /// Return the result of a callback.. + /// Returns the result of a callback.. static void returnResult( Pointer result, JObjectPtr object) async { Jni._bindings.resultFor(result, object); @@ -334,28 +341,30 @@ extension AdditionalEnvMethods on GlobalJniEnv { /// Convenience method for converting a [JStringPtr] /// to dart string. /// if [deleteOriginal] is specified, jstring passed will be deleted using - /// DeleteLocalRef. + /// DeleteGlobalRef. String toDartString(JStringPtr jstringPtr, {bool deleteOriginal = false}) { if (jstringPtr == nullptr) { throw const JNullException(); } - final chars = GetStringUTFChars(jstringPtr, nullptr); + final chars = GetStringChars(jstringPtr, nullptr); if (chars == nullptr) { throw InvalidJStringException(jstringPtr); } - final result = chars.cast().toDartString(); - ReleaseStringUTFChars(jstringPtr, chars); + final result = chars.cast().toDartString(); + ReleaseStringChars(jstringPtr, chars); if (deleteOriginal) { DeleteGlobalRef(jstringPtr); } return result; } - /// Return a new [JStringPtr] from contents of [s]. + /// Returns a new [JStringPtr] from contents of [s]. JStringPtr toJStringPtr(String s) => using((arena) { - final utf = s.toNativeUtf8().cast(); - final result = NewStringUTF(utf); - malloc.free(utf); + final utf = s.toNativeUtf16(allocator: arena).cast(); + final result = NewString(utf, s.length); + if (utf == nullptr) { + throw 'Fatal: cannot convert string to Java string: $s'; + } return result; }); diff --git a/pkgs/jni/lib/src/lang/jstring.dart b/pkgs/jni/lib/src/lang/jstring.dart index 5bfcce5c4..f1df76c4c 100644 --- a/pkgs/jni/lib/src/lang/jstring.dart +++ b/pkgs/jni/lib/src/lang/jstring.dart @@ -47,20 +47,11 @@ class JString extends JObject { /// Construct a new [JString] with [reference] as its underlying reference. JString.fromRef(JStringPtr reference) : super.fromRef(reference); - static JStringPtr _toJavaString(String s) => using((arena) { - final chars = s.toNativeUtf16(allocator: arena).cast(); - final jstr = Jni.env.NewString(chars, s.length); - if (jstr == nullptr) { - throw 'Fatal: cannot convert string to Java string: $s'; - } - return jstr; - }); - /// The number of Unicode characters in this Java string. int get length => Jni.env.GetStringLength(reference); /// Construct a [JString] from the contents of Dart string [s]. - JString.fromString(String s) : super.fromRef(_toJavaString(s)); + JString.fromString(String s) : super.fromRef(Jni.env.toJStringPtr(s)); /// Returns the contents as a Dart String. /// 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 bdd6ab747..892f69e51 100644 --- a/pkgs/jni/lib/src/third_party/jni_bindings_generated.dart +++ b/pkgs/jni/lib/src/third_party/jni_bindings_generated.dart @@ -178,22 +178,19 @@ class JniBindings { late final _InitDartApiDL = _InitDartApiDLPtr.asFunction)>(); - void resultFor( - ffi.Pointer result, - JObjectPtr object, + JniResult DartException__ctor( + JStringPtr message, ) { - return _resultFor( - result, - object, + return _DartException__ctor( + message, ); } - late final _resultForPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, JObjectPtr)>>('resultFor'); - late final _resultFor = _resultForPtr - .asFunction, JObjectPtr)>(); + late final _DartException__ctorPtr = + _lookup>( + 'DartException__ctor'); + late final _DartException__ctor = + _DartException__ctorPtr.asFunction(); JniResult PortContinuation__ctor( int j, @@ -228,6 +225,23 @@ class JniBindings { late final _PortProxy__newInstance = _PortProxy__newInstancePtr.asFunction< JniResult Function(JObjectPtr, int, int)>(); + void resultFor( + ffi.Pointer result, + JObjectPtr object, + ) { + return _resultFor( + result, + object, + ); + } + + late final _resultForPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, JObjectPtr)>>('resultFor'); + late final _resultFor = _resultForPtr + .asFunction, JObjectPtr)>(); + ffi.Pointer GetGlobalEnv() { return _GetGlobalEnv(); } diff --git a/pkgs/jni/src/dartjni.c b/pkgs/jni/src/dartjni.c index dc595a9c5..7c5951bc5 100644 --- a/pkgs/jni/src/dartjni.c +++ b/pkgs/jni/src/dartjni.c @@ -569,6 +569,29 @@ FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data) { return Dart_InitializeApiDL(data); } +// com.github.dart_lang.jni.DartException +jclass _c_DartException = NULL; + +jmethodID _m_DartException__ctor = NULL; +FFI_PLUGIN_EXPORT JniResult DartException__ctor(jstring message) { + attach_thread(); + load_class_global_ref(&_c_DartException, + "com/github/dart_lang/jni/PortProxy$DartException"); + if (_c_DartException == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_DartException, &_m_DartException__ctor, "", + "(Ljava/lang/String;)V"); + if (_m_DartException__ctor == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_DartException, + _m_DartException__ctor, message); + jthrowable exception = check_exception(); + if (exception == NULL) { + _result = to_global_ref(_result); + } + return (JniResult){.value = {.l = _result}, .exception = check_exception()}; +} + JNIEXPORT void JNICALL Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env, jclass clazz, diff --git a/pkgs/jni/src/dartjni.h b/pkgs/jni/src/dartjni.h index 0a7f66914..8f1dc7481 100644 --- a/pkgs/jni/src/dartjni.h +++ b/pkgs/jni/src/dartjni.h @@ -410,7 +410,8 @@ static inline JniResult to_global_ref_result(jobject ref) { FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); -FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object); +FFI_PLUGIN_EXPORT +JniResult DartException__ctor(jstring message); FFI_PLUGIN_EXPORT JniResult PortContinuation__ctor(int64_t j); @@ -419,3 +420,5 @@ FFI_PLUGIN_EXPORT JniResult PortProxy__newInstance(jobject binaryName, int64_t port, int64_t functionPtr); + +FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object); diff --git a/pkgs/jnigen/android_test_runner/android/app/build.gradle b/pkgs/jnigen/android_test_runner/android/app/build.gradle index e0c777fb1..58cd27a4c 100644 --- a/pkgs/jnigen/android_test_runner/android/app/build.gradle +++ b/pkgs/jnigen/android_test_runner/android/app/build.gradle @@ -8,7 +8,7 @@ if (localPropertiesFile.exists()) { def flutterRoot = localProperties.getProperty('flutter.sdk') if (flutterRoot == null) { - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") + throw new FileNotFoundException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") } def flutterVersionCode = localProperties.getProperty('flutter.versionCode') diff --git a/pkgs/jnigen/example/in_app_java/android/app/build.gradle b/pkgs/jnigen/example/in_app_java/android/app/build.gradle index 8f38e430e..59ebf1692 100644 --- a/pkgs/jnigen/example/in_app_java/android/app/build.gradle +++ b/pkgs/jnigen/example/in_app_java/android/app/build.gradle @@ -8,7 +8,7 @@ if (localPropertiesFile.exists()) { def flutterRoot = localProperties.getProperty('flutter.sdk') if (flutterRoot == null) { - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") + throw new FileNotFoundException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") } def flutterVersionCode = localProperties.getProperty('flutter.versionCode') diff --git a/pkgs/jnigen/example/in_app_java/src/android_utils/dartjni.h b/pkgs/jnigen/example/in_app_java/src/android_utils/dartjni.h index 0a7f66914..8f1dc7481 100644 --- a/pkgs/jnigen/example/in_app_java/src/android_utils/dartjni.h +++ b/pkgs/jnigen/example/in_app_java/src/android_utils/dartjni.h @@ -410,7 +410,8 @@ static inline JniResult to_global_ref_result(jobject ref) { FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); -FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object); +FFI_PLUGIN_EXPORT +JniResult DartException__ctor(jstring message); FFI_PLUGIN_EXPORT JniResult PortContinuation__ctor(int64_t j); @@ -419,3 +420,5 @@ FFI_PLUGIN_EXPORT JniResult PortProxy__newInstance(jobject binaryName, int64_t port, int64_t functionPtr); + +FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object); diff --git a/pkgs/jnigen/example/kotlin_plugin/example/android/app/build.gradle b/pkgs/jnigen/example/kotlin_plugin/example/android/app/build.gradle index f371e650f..7f1cb3e67 100644 --- a/pkgs/jnigen/example/kotlin_plugin/example/android/app/build.gradle +++ b/pkgs/jnigen/example/kotlin_plugin/example/android/app/build.gradle @@ -8,7 +8,7 @@ if (localPropertiesFile.exists()) { def flutterRoot = localProperties.getProperty('flutter.sdk') if (flutterRoot == null) { - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") + throw new FileNotFoundException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") } def flutterVersionCode = localProperties.getProperty('flutter.versionCode') diff --git a/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h b/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h index 0a7f66914..8f1dc7481 100644 --- a/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h +++ b/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h @@ -410,7 +410,8 @@ static inline JniResult to_global_ref_result(jobject ref) { FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); -FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object); +FFI_PLUGIN_EXPORT +JniResult DartException__ctor(jstring message); FFI_PLUGIN_EXPORT JniResult PortContinuation__ctor(int64_t j); @@ -419,3 +420,5 @@ FFI_PLUGIN_EXPORT JniResult PortProxy__newInstance(jobject binaryName, int64_t port, int64_t functionPtr); + +FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object); diff --git a/pkgs/jnigen/example/notification_plugin/example/android/app/build.gradle b/pkgs/jnigen/example/notification_plugin/example/android/app/build.gradle index ee3c62fa0..7f66900ca 100644 --- a/pkgs/jnigen/example/notification_plugin/example/android/app/build.gradle +++ b/pkgs/jnigen/example/notification_plugin/example/android/app/build.gradle @@ -8,7 +8,7 @@ if (localPropertiesFile.exists()) { def flutterRoot = localProperties.getProperty('flutter.sdk') if (flutterRoot == null) { - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") + throw new FileNotFoundException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") } def flutterVersionCode = localProperties.getProperty('flutter.versionCode') diff --git a/pkgs/jnigen/example/notification_plugin/src/dartjni.h b/pkgs/jnigen/example/notification_plugin/src/dartjni.h index 0a7f66914..8f1dc7481 100644 --- a/pkgs/jnigen/example/notification_plugin/src/dartjni.h +++ b/pkgs/jnigen/example/notification_plugin/src/dartjni.h @@ -410,7 +410,8 @@ static inline JniResult to_global_ref_result(jobject ref) { FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); -FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object); +FFI_PLUGIN_EXPORT +JniResult DartException__ctor(jstring message); FFI_PLUGIN_EXPORT JniResult PortContinuation__ctor(int64_t j); @@ -419,3 +420,5 @@ FFI_PLUGIN_EXPORT JniResult PortProxy__newInstance(jobject binaryName, int64_t port, int64_t functionPtr); + +FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object); diff --git a/pkgs/jnigen/example/pdfbox_plugin/example/android/app/build.gradle b/pkgs/jnigen/example/pdfbox_plugin/example/android/app/build.gradle index 162ad5b01..c5791ba99 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/example/android/app/build.gradle +++ b/pkgs/jnigen/example/pdfbox_plugin/example/android/app/build.gradle @@ -8,7 +8,7 @@ if (localPropertiesFile.exists()) { def flutterRoot = localProperties.getProperty('flutter.sdk') if (flutterRoot == null) { - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") + throw new FileNotFoundException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") } def flutterVersionCode = localProperties.getProperty('flutter.versionCode') diff --git a/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h b/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h index 0a7f66914..8f1dc7481 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h +++ b/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h @@ -410,7 +410,8 @@ static inline JniResult to_global_ref_result(jobject ref) { FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); -FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object); +FFI_PLUGIN_EXPORT +JniResult DartException__ctor(jstring message); FFI_PLUGIN_EXPORT JniResult PortContinuation__ctor(int64_t j); @@ -419,3 +420,5 @@ FFI_PLUGIN_EXPORT JniResult PortProxy__newInstance(jobject binaryName, int64_t port, int64_t functionPtr); + +FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object); diff --git a/pkgs/jnigen/lib/src/bindings/dart_generator.dart b/pkgs/jnigen/lib/src/bindings/dart_generator.dart index 3bc72cc67..d21665c79 100644 --- a/pkgs/jnigen/lib/src/bindings/dart_generator.dart +++ b/pkgs/jnigen/lib/src/bindings/dart_generator.dart @@ -439,14 +439,18 @@ class $name$typeParamsDef extends $superName { int $p, $MethodInvocation $i, ) { - final $d = $i.methodDescriptor.toDartString(deleteOriginal: true); - final $a = $i.args; + try { + final $d = $i.methodDescriptor.toDartString(deleteOriginal: true); + final $a = $i.args; '''); final proxyMethodIf = _InterfaceMethodIf(resolver, s); for (final method in node.methods) { method.accept(proxyMethodIf); } s.write(''' + } catch (e) { + return $_protectedExtension.newDartException(e.toString()); + } return jni.nullptr; } @@ -469,19 +473,17 @@ class $name$typeParamsDef extends $superName { ).._\$p = \$p; final \$a = \$p.sendPort.nativePort; _\$impls[\$a] = \$impl; -'''); - s.write(r''' - $p.listen(($m) { - if ($m == null) { - _$impls.remove($p.sendPort.nativePort); - $p.close(); + \$p.listen((\$m) { + if (\$m == null) { + _\$impls.remove(\$p.sendPort.nativePort); + \$p.close(); return; } - final $i = $MethodInvocation.fromMessage($m); - final $r = _$invokeMethod($p.sendPort.nativePort, $i); - ProtectedJniExtensions.returnResult($i.result, $r); + final \$i = \$MethodInvocation.fromMessage(\$m); + final \$r = _\$invokeMethod(\$p.sendPort.nativePort, \$i); + $_protectedExtension.returnResult(\$i.result, \$r); }); - return $x; + return \$x; } '''); } @@ -1645,17 +1647,17 @@ class _InterfaceMethodIf extends Visitor { final saveResult = isVoid ? '' : 'final \$r = '; final name = node.finalName; s.write(''' - if (\$d == r"$signature") { - ${saveResult}_\$impls[\$p]!.$name( + if (\$d == r"$signature") { + ${saveResult}_\$impls[\$p]!.$name( '''); for (var i = 0; i < node.params.length; ++i) { node.params[i].accept(_InterfaceParamCast(resolver, s, paramIndex: i)); } const returnBox = _InterfaceReturnBox(); s.write(''' - ); - return ${node.returnType.accept(returnBox)}; - } + ); + return ${node.returnType.accept(returnBox)}; + } '''); } } diff --git a/pkgs/jnigen/lib/src/config/experiments.dart b/pkgs/jnigen/lib/src/config/experiments.dart index d0eb39dd6..6bb65c10f 100644 --- a/pkgs/jnigen/lib/src/config/experiments.dart +++ b/pkgs/jnigen/lib/src/config/experiments.dart @@ -31,7 +31,7 @@ class Experiment { } final result = search.single; if (result.isExpired) { - throw 'The experiment $s can no longer be used in this version. '; + throw 'The experiment $s can no longer be used in this version.'; } return result; } diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/dartjni.h b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/dartjni.h index 0a7f66914..8f1dc7481 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/dartjni.h +++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/dartjni.h @@ -410,7 +410,8 @@ static inline JniResult to_global_ref_result(jobject ref) { FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); -FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object); +FFI_PLUGIN_EXPORT +JniResult DartException__ctor(jstring message); FFI_PLUGIN_EXPORT JniResult PortContinuation__ctor(int64_t j); @@ -419,3 +420,5 @@ FFI_PLUGIN_EXPORT JniResult PortProxy__newInstance(jobject binaryName, int64_t port, int64_t functionPtr); + +FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object); diff --git a/pkgs/jnigen/test/kotlin_test/c_based/c_bindings/dartjni.h b/pkgs/jnigen/test/kotlin_test/c_based/c_bindings/dartjni.h index 0a7f66914..8f1dc7481 100644 --- a/pkgs/jnigen/test/kotlin_test/c_based/c_bindings/dartjni.h +++ b/pkgs/jnigen/test/kotlin_test/c_based/c_bindings/dartjni.h @@ -410,7 +410,8 @@ static inline JniResult to_global_ref_result(jobject ref) { FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); -FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object); +FFI_PLUGIN_EXPORT +JniResult DartException__ctor(jstring message); FFI_PLUGIN_EXPORT JniResult PortContinuation__ctor(int64_t j); @@ -419,3 +420,5 @@ FFI_PLUGIN_EXPORT JniResult PortProxy__newInstance(jobject binaryName, int64_t port, int64_t functionPtr); + +FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object); diff --git a/pkgs/jnigen/test/regenerate_examples_test.dart b/pkgs/jnigen/test/regenerate_examples_test.dart index 5afeebea8..35ab2e05b 100644 --- a/pkgs/jnigen/test/regenerate_examples_test.dart +++ b/pkgs/jnigen/test/regenerate_examples_test.dart @@ -29,7 +29,7 @@ void testExample(String exampleName, String dartOutput, String? cOutput, {bool isLargeTest = false}) { test( 'Generate and compare bindings for $exampleName', - timeout: const Timeout.factor(2), + timeout: const Timeout.factor(3), () async { final examplePath = join('example', exampleName); final configPath = join(examplePath, 'jnigen.yaml'); diff --git a/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/dartjni.h b/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/dartjni.h index 0a7f66914..8f1dc7481 100644 --- a/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/dartjni.h +++ b/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/dartjni.h @@ -410,7 +410,8 @@ static inline JniResult to_global_ref_result(jobject ref) { FFI_PLUGIN_EXPORT intptr_t InitDartApiDL(void* data); -FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object); +FFI_PLUGIN_EXPORT +JniResult DartException__ctor(jstring message); FFI_PLUGIN_EXPORT JniResult PortContinuation__ctor(int64_t j); @@ -419,3 +420,5 @@ FFI_PLUGIN_EXPORT JniResult PortProxy__newInstance(jobject binaryName, int64_t port, int64_t functionPtr); + +FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object); diff --git a/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/simple_package.c b/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/simple_package.c index 62b150ed9..20c7e7e53 100644 --- a/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/simple_package.c +++ b/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/simple_package.c @@ -2786,6 +2786,111 @@ JniResult MyInterfaceConsumer__consumeOnSameThread(jobject myInterface, return (JniResult){.value = {.j = 0}, .exception = check_exception()}; } +// com.github.dart_lang.jnigen.interfaces.MyRunnable +jclass _c_MyRunnable = NULL; + +jmethodID _m_MyRunnable__run = NULL; +FFI_PLUGIN_EXPORT +JniResult MyRunnable__run(jobject self_) { + load_env(); + load_class_global_ref(&_c_MyRunnable, + "com/github/dart_lang/jnigen/interfaces/MyRunnable"); + if (_c_MyRunnable == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_MyRunnable, &_m_MyRunnable__run, "run", "()V"); + if (_m_MyRunnable__run == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod(jniEnv, self_, _m_MyRunnable__run); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +// com.github.dart_lang.jnigen.interfaces.MyRunnableRunner +jclass _c_MyRunnableRunner = NULL; + +jmethodID _m_MyRunnableRunner__new0 = NULL; +FFI_PLUGIN_EXPORT +JniResult MyRunnableRunner__new0(jobject runnable) { + load_env(); + load_class_global_ref( + &_c_MyRunnableRunner, + "com/github/dart_lang/jnigen/interfaces/MyRunnableRunner"); + if (_c_MyRunnableRunner == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_MyRunnableRunner, &_m_MyRunnableRunner__new0, "", + "(Lcom/github/dart_lang/jnigen/interfaces/MyRunnable;)V"); + if (_m_MyRunnableRunner__new0 == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + jobject _result = (*jniEnv)->NewObject(jniEnv, _c_MyRunnableRunner, + _m_MyRunnableRunner__new0, runnable); + return to_global_ref_result(_result); +} + +jmethodID _m_MyRunnableRunner__runOnSameThread = NULL; +FFI_PLUGIN_EXPORT +JniResult MyRunnableRunner__runOnSameThread(jobject self_) { + load_env(); + load_class_global_ref( + &_c_MyRunnableRunner, + "com/github/dart_lang/jnigen/interfaces/MyRunnableRunner"); + if (_c_MyRunnableRunner == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_MyRunnableRunner, &_m_MyRunnableRunner__runOnSameThread, + "runOnSameThread", "()V"); + if (_m_MyRunnableRunner__runOnSameThread == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod(jniEnv, self_, + _m_MyRunnableRunner__runOnSameThread); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +jmethodID _m_MyRunnableRunner__runOnAnotherThread = NULL; +FFI_PLUGIN_EXPORT +JniResult MyRunnableRunner__runOnAnotherThread(jobject self_) { + load_env(); + load_class_global_ref( + &_c_MyRunnableRunner, + "com/github/dart_lang/jnigen/interfaces/MyRunnableRunner"); + if (_c_MyRunnableRunner == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_method(_c_MyRunnableRunner, &_m_MyRunnableRunner__runOnAnotherThread, + "runOnAnotherThread", "()V"); + if (_m_MyRunnableRunner__runOnAnotherThread == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + (*jniEnv)->CallVoidMethod(jniEnv, self_, + _m_MyRunnableRunner__runOnAnotherThread); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + +jfieldID _f_MyRunnableRunner__error = NULL; +FFI_PLUGIN_EXPORT +JniResult get_MyRunnableRunner__error(jobject self_) { + load_env(); + load_class_global_ref( + &_c_MyRunnableRunner, + "com/github/dart_lang/jnigen/interfaces/MyRunnableRunner"); + if (_c_MyRunnableRunner == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_field(_c_MyRunnableRunner, &_f_MyRunnableRunner__error, "error", + "Ljava/lang/Throwable;"); + jobject _result = + (*jniEnv)->GetObjectField(jniEnv, self_, _f_MyRunnableRunner__error); + return to_global_ref_result(_result); +} + +FFI_PLUGIN_EXPORT +JniResult set_MyRunnableRunner__error(jobject self_, jobject value) { + load_env(); + load_class_global_ref( + &_c_MyRunnableRunner, + "com/github/dart_lang/jnigen/interfaces/MyRunnableRunner"); + if (_c_MyRunnableRunner == NULL) + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; + load_field(_c_MyRunnableRunner, &_f_MyRunnableRunner__error, "error", + "Ljava/lang/Throwable;"); + (*jniEnv)->SetObjectField(jniEnv, self_, _f_MyRunnableRunner__error, value); + return (JniResult){.value = {.j = 0}, .exception = check_exception()}; +} + // com.github.dart_lang.jnigen.annotations.JsonSerializable$Case jclass _c_JsonSerializable_Case = NULL; diff --git a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart index cd47f44cb..5154b7591 100644 --- a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart @@ -3371,42 +3371,46 @@ class MyInterface<$T extends jni.JObject> extends jni.JObject { int $p, $MethodInvocation $i, ) { - final $d = $i.methodDescriptor.toDartString(deleteOriginal: true); - final $a = $i.args; - if ($d == r"voidCallback(Ljava/lang/String;)V") { - _$impls[$p]!.voidCallback( - $a[0].castTo(const jni.JStringType(), deleteOriginal: true), - ); - return jni.nullptr; - } - if ($d == r"stringCallback(Ljava/lang/String;)Ljava/lang/String;") { - final $r = _$impls[$p]!.stringCallback( - $a[0].castTo(const jni.JStringType(), deleteOriginal: true), - ); - return ($r as jni.JObject).castTo(const jni.JObjectType()).toPointer(); - } - if ($d == r"varCallback(Ljava/lang/Object;)Ljava/lang/Object;") { - final $r = _$impls[$p]!.varCallback( - $a[0].castTo(_$impls[$p]!.T, deleteOriginal: true), - ); - return ($r as jni.JObject).castTo(const jni.JObjectType()).toPointer(); - } - if ($d == r"manyPrimitives(IZCD)J") { - final $r = _$impls[$p]!.manyPrimitives( - $a[0] - .castTo(const jni.JIntegerType(), deleteOriginal: true) - .intValue(deleteOriginal: true), - $a[1] - .castTo(const jni.JBooleanType(), deleteOriginal: true) - .booleanValue(deleteOriginal: true), - $a[2] - .castTo(const jni.JCharacterType(), deleteOriginal: true) - .charValue(deleteOriginal: true), - $a[3] - .castTo(const jni.JDoubleType(), deleteOriginal: true) - .doubleValue(deleteOriginal: true), - ); - return jni.JLong($r).toPointer(); + try { + final $d = $i.methodDescriptor.toDartString(deleteOriginal: true); + final $a = $i.args; + if ($d == r"voidCallback(Ljava/lang/String;)V") { + _$impls[$p]!.voidCallback( + $a[0].castTo(const jni.JStringType(), deleteOriginal: true), + ); + return jni.nullptr; + } + if ($d == r"stringCallback(Ljava/lang/String;)Ljava/lang/String;") { + final $r = _$impls[$p]!.stringCallback( + $a[0].castTo(const jni.JStringType(), deleteOriginal: true), + ); + return ($r as jni.JObject).castTo(const jni.JObjectType()).toPointer(); + } + if ($d == r"varCallback(Ljava/lang/Object;)Ljava/lang/Object;") { + final $r = _$impls[$p]!.varCallback( + $a[0].castTo(_$impls[$p]!.T, deleteOriginal: true), + ); + return ($r as jni.JObject).castTo(const jni.JObjectType()).toPointer(); + } + if ($d == r"manyPrimitives(IZCD)J") { + final $r = _$impls[$p]!.manyPrimitives( + $a[0] + .castTo(const jni.JIntegerType(), deleteOriginal: true) + .intValue(deleteOriginal: true), + $a[1] + .castTo(const jni.JBooleanType(), deleteOriginal: true) + .booleanValue(deleteOriginal: true), + $a[2] + .castTo(const jni.JCharacterType(), deleteOriginal: true) + .charValue(deleteOriginal: true), + $a[3] + .castTo(const jni.JDoubleType(), deleteOriginal: true) + .doubleValue(deleteOriginal: true), + ); + return jni.JLong($r).toPointer(); + } + } catch (e) { + return ProtectedJniExtensions.newDartException(e.toString()); } return jni.nullptr; } @@ -3646,6 +3650,243 @@ class $MyInterfaceConsumerType extends jni.JObjType { } } +/// from: com.github.dart_lang.jnigen.interfaces.MyRunnable +class MyRunnable extends jni.JObject { + @override + late final jni.JObjType $type = type; + + MyRunnable.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = $MyRunnableType(); + static final _run = jniLookup< + ffi + .NativeFunction)>>( + "MyRunnable__run") + .asFunction)>(); + + /// from: public abstract void run() + void run() { + return _run(reference).check(); + } + + /// Maps a specific port to the implemented interface. + static final Map _$impls = {}; + ReceivePort? _$p; + + static jni.JObjectPtr _$invoke( + int port, + jni.JObjectPtr descriptor, + jni.JObjectPtr args, + ) { + return _$invokeMethod( + port, + $MethodInvocation.fromAddresses( + 0, + descriptor.address, + args.address, + ), + ); + } + + static final ffi.Pointer< + ffi.NativeFunction< + jni.JObjectPtr Function( + ffi.Uint64, jni.JObjectPtr, jni.JObjectPtr)>> + _$invokePointer = ffi.Pointer.fromFunction(_$invoke); + + static ffi.Pointer _$invokeMethod( + int $p, + $MethodInvocation $i, + ) { + try { + final $d = $i.methodDescriptor.toDartString(deleteOriginal: true); + final $a = $i.args; + if ($d == r"run()V") { + _$impls[$p]!.run(); + return jni.nullptr; + } + } catch (e) { + return ProtectedJniExtensions.newDartException(e.toString()); + } + return jni.nullptr; + } + + factory MyRunnable.implement( + $MyRunnableImpl $impl, + ) { + final $p = ReceivePort(); + final $x = MyRunnable.fromRef( + ProtectedJniExtensions.newPortProxy( + r"com.github.dart_lang.jnigen.interfaces.MyRunnable", + $p, + _$invokePointer, + ), + ).._$p = $p; + final $a = $p.sendPort.nativePort; + _$impls[$a] = $impl; + $p.listen(($m) { + if ($m == null) { + _$impls.remove($p.sendPort.nativePort); + $p.close(); + return; + } + final $i = $MethodInvocation.fromMessage($m); + final $r = _$invokeMethod($p.sendPort.nativePort, $i); + ProtectedJniExtensions.returnResult($i.result, $r); + }); + return $x; + } +} + +abstract class $MyRunnableImpl { + factory $MyRunnableImpl({ + required void Function() run, + }) = _$MyRunnableImpl; + + void run(); +} + +class _$MyRunnableImpl implements $MyRunnableImpl { + _$MyRunnableImpl({ + required void Function() run, + }) : _run = run; + + final void Function() _run; + + void run() { + return _run(); + } +} + +class $MyRunnableType extends jni.JObjType { + const $MyRunnableType(); + + @override + String get signature => + r"Lcom/github/dart_lang/jnigen/interfaces/MyRunnable;"; + + @override + MyRunnable fromRef(jni.JObjectPtr ref) => MyRunnable.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($MyRunnableType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == ($MyRunnableType) && other is $MyRunnableType; + } +} + +/// from: com.github.dart_lang.jnigen.interfaces.MyRunnableRunner +class MyRunnableRunner extends jni.JObject { + @override + late final jni.JObjType $type = type; + + MyRunnableRunner.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + /// The type which includes information such as the signature of this class. + static const type = $MyRunnableRunnerType(); + static final _get_error = jniLookup< + ffi.NativeFunction< + jni.JniResult Function( + jni.JObjectPtr, + )>>("get_MyRunnableRunner__error") + .asFunction< + jni.JniResult Function( + jni.JObjectPtr, + )>(); + + static final _set_error = jniLookup< + ffi.NativeFunction< + jni.JniResult Function(jni.JObjectPtr, + ffi.Pointer)>>("set_MyRunnableRunner__error") + .asFunction< + jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); + + /// from: public java.lang.Throwable error + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JObject get error => + const jni.JObjectType().fromRef(_get_error(reference).object); + + /// from: public java.lang.Throwable error + /// The returned object must be deleted after use, by calling the `delete` method. + set error(jni.JObject value) => + _set_error(reference, value.reference).check(); + + static final _new0 = jniLookup< + ffi + .NativeFunction)>>( + "MyRunnableRunner__new0") + .asFunction)>(); + + /// from: public void (com.github.dart_lang.jnigen.interfaces.MyRunnable runnable) + /// The returned object must be deleted after use, by calling the `delete` method. + factory MyRunnableRunner( + MyRunnable runnable, + ) { + return MyRunnableRunner.fromRef(_new0(runnable.reference).object); + } + + static final _runOnSameThread = jniLookup< + ffi + .NativeFunction)>>( + "MyRunnableRunner__runOnSameThread") + .asFunction)>(); + + /// from: public void runOnSameThread() + void runOnSameThread() { + return _runOnSameThread(reference).check(); + } + + static final _runOnAnotherThread = jniLookup< + ffi + .NativeFunction)>>( + "MyRunnableRunner__runOnAnotherThread") + .asFunction)>(); + + /// from: public void runOnAnotherThread() + void runOnAnotherThread() { + return _runOnAnotherThread(reference).check(); + } +} + +class $MyRunnableRunnerType extends jni.JObjType { + const $MyRunnableRunnerType(); + + @override + String get signature => + r"Lcom/github/dart_lang/jnigen/interfaces/MyRunnableRunner;"; + + @override + MyRunnableRunner fromRef(jni.JObjectPtr ref) => MyRunnableRunner.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($MyRunnableRunnerType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == ($MyRunnableRunnerType) && + other is $MyRunnableRunnerType; + } +} + /// from: com.github.dart_lang.jnigen.annotations.JsonSerializable$Case class JsonSerializable_Case extends jni.JObject { @override diff --git a/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart index 9ca08571c..7b36cdd3c 100644 --- a/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart @@ -3180,42 +3180,46 @@ class MyInterface<$T extends jni.JObject> extends jni.JObject { int $p, $MethodInvocation $i, ) { - final $d = $i.methodDescriptor.toDartString(deleteOriginal: true); - final $a = $i.args; - if ($d == r"voidCallback(Ljava/lang/String;)V") { - _$impls[$p]!.voidCallback( - $a[0].castTo(const jni.JStringType(), deleteOriginal: true), - ); - return jni.nullptr; - } - if ($d == r"stringCallback(Ljava/lang/String;)Ljava/lang/String;") { - final $r = _$impls[$p]!.stringCallback( - $a[0].castTo(const jni.JStringType(), deleteOriginal: true), - ); - return ($r as jni.JObject).castTo(const jni.JObjectType()).toPointer(); - } - if ($d == r"varCallback(Ljava/lang/Object;)Ljava/lang/Object;") { - final $r = _$impls[$p]!.varCallback( - $a[0].castTo(_$impls[$p]!.T, deleteOriginal: true), - ); - return ($r as jni.JObject).castTo(const jni.JObjectType()).toPointer(); - } - if ($d == r"manyPrimitives(IZCD)J") { - final $r = _$impls[$p]!.manyPrimitives( - $a[0] - .castTo(const jni.JIntegerType(), deleteOriginal: true) - .intValue(deleteOriginal: true), - $a[1] - .castTo(const jni.JBooleanType(), deleteOriginal: true) - .booleanValue(deleteOriginal: true), - $a[2] - .castTo(const jni.JCharacterType(), deleteOriginal: true) - .charValue(deleteOriginal: true), - $a[3] - .castTo(const jni.JDoubleType(), deleteOriginal: true) - .doubleValue(deleteOriginal: true), - ); - return jni.JLong($r).toPointer(); + try { + final $d = $i.methodDescriptor.toDartString(deleteOriginal: true); + final $a = $i.args; + if ($d == r"voidCallback(Ljava/lang/String;)V") { + _$impls[$p]!.voidCallback( + $a[0].castTo(const jni.JStringType(), deleteOriginal: true), + ); + return jni.nullptr; + } + if ($d == r"stringCallback(Ljava/lang/String;)Ljava/lang/String;") { + final $r = _$impls[$p]!.stringCallback( + $a[0].castTo(const jni.JStringType(), deleteOriginal: true), + ); + return ($r as jni.JObject).castTo(const jni.JObjectType()).toPointer(); + } + if ($d == r"varCallback(Ljava/lang/Object;)Ljava/lang/Object;") { + final $r = _$impls[$p]!.varCallback( + $a[0].castTo(_$impls[$p]!.T, deleteOriginal: true), + ); + return ($r as jni.JObject).castTo(const jni.JObjectType()).toPointer(); + } + if ($d == r"manyPrimitives(IZCD)J") { + final $r = _$impls[$p]!.manyPrimitives( + $a[0] + .castTo(const jni.JIntegerType(), deleteOriginal: true) + .intValue(deleteOriginal: true), + $a[1] + .castTo(const jni.JBooleanType(), deleteOriginal: true) + .booleanValue(deleteOriginal: true), + $a[2] + .castTo(const jni.JCharacterType(), deleteOriginal: true) + .charValue(deleteOriginal: true), + $a[3] + .castTo(const jni.JDoubleType(), deleteOriginal: true) + .doubleValue(deleteOriginal: true), + ); + return jni.JLong($r).toPointer(); + } + } catch (e) { + return ProtectedJniExtensions.newDartException(e.toString()); } return jni.nullptr; } @@ -3452,6 +3456,231 @@ class $MyInterfaceConsumerType extends jni.JObjType { } } +/// from: com.github.dart_lang.jnigen.interfaces.MyRunnable +class MyRunnable extends jni.JObject { + @override + late final jni.JObjType $type = type; + + MyRunnable.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + static final _class = + jni.Jni.findJClass(r"com/github/dart_lang/jnigen/interfaces/MyRunnable"); + + /// The type which includes information such as the signature of this class. + static const type = $MyRunnableType(); + static final _id_run = + jni.Jni.accessors.getMethodIDOf(_class.reference, r"run", r"()V"); + + /// from: public abstract void run() + void run() { + return jni.Jni.accessors.callMethodWithArgs( + reference, _id_run, jni.JniCallType.voidType, []).check(); + } + + /// Maps a specific port to the implemented interface. + static final Map _$impls = {}; + ReceivePort? _$p; + + static jni.JObjectPtr _$invoke( + int port, + jni.JObjectPtr descriptor, + jni.JObjectPtr args, + ) { + return _$invokeMethod( + port, + $MethodInvocation.fromAddresses( + 0, + descriptor.address, + args.address, + ), + ); + } + + static final ffi.Pointer< + ffi.NativeFunction< + jni.JObjectPtr Function( + ffi.Uint64, jni.JObjectPtr, jni.JObjectPtr)>> + _$invokePointer = ffi.Pointer.fromFunction(_$invoke); + + static ffi.Pointer _$invokeMethod( + int $p, + $MethodInvocation $i, + ) { + try { + final $d = $i.methodDescriptor.toDartString(deleteOriginal: true); + final $a = $i.args; + if ($d == r"run()V") { + _$impls[$p]!.run(); + return jni.nullptr; + } + } catch (e) { + return ProtectedJniExtensions.newDartException(e.toString()); + } + return jni.nullptr; + } + + factory MyRunnable.implement( + $MyRunnableImpl $impl, + ) { + final $p = ReceivePort(); + final $x = MyRunnable.fromRef( + ProtectedJniExtensions.newPortProxy( + r"com.github.dart_lang.jnigen.interfaces.MyRunnable", + $p, + _$invokePointer, + ), + ).._$p = $p; + final $a = $p.sendPort.nativePort; + _$impls[$a] = $impl; + $p.listen(($m) { + if ($m == null) { + _$impls.remove($p.sendPort.nativePort); + $p.close(); + return; + } + final $i = $MethodInvocation.fromMessage($m); + final $r = _$invokeMethod($p.sendPort.nativePort, $i); + ProtectedJniExtensions.returnResult($i.result, $r); + }); + return $x; + } +} + +abstract class $MyRunnableImpl { + factory $MyRunnableImpl({ + required void Function() run, + }) = _$MyRunnableImpl; + + void run(); +} + +class _$MyRunnableImpl implements $MyRunnableImpl { + _$MyRunnableImpl({ + required void Function() run, + }) : _run = run; + + final void Function() _run; + + void run() { + return _run(); + } +} + +class $MyRunnableType extends jni.JObjType { + const $MyRunnableType(); + + @override + String get signature => + r"Lcom/github/dart_lang/jnigen/interfaces/MyRunnable;"; + + @override + MyRunnable fromRef(jni.JObjectPtr ref) => MyRunnable.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($MyRunnableType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == ($MyRunnableType) && other is $MyRunnableType; + } +} + +/// from: com.github.dart_lang.jnigen.interfaces.MyRunnableRunner +class MyRunnableRunner extends jni.JObject { + @override + late final jni.JObjType $type = type; + + MyRunnableRunner.fromRef( + jni.JObjectPtr ref, + ) : super.fromRef(ref); + + static final _class = jni.Jni.findJClass( + r"com/github/dart_lang/jnigen/interfaces/MyRunnableRunner"); + + /// The type which includes information such as the signature of this class. + static const type = $MyRunnableRunnerType(); + static final _id_error = jni.Jni.accessors.getFieldIDOf( + _class.reference, + r"error", + r"Ljava/lang/Throwable;", + ); + + /// from: public java.lang.Throwable error + /// The returned object must be deleted after use, by calling the `delete` method. + jni.JObject get error => const jni.JObjectType().fromRef(jni.Jni.accessors + .getField(reference, _id_error, jni.JniCallType.objectType) + .object); + + /// from: public java.lang.Throwable error + /// The returned object must be deleted after use, by calling the `delete` method. + set error(jni.JObject value) => + jni.Jni.env.SetObjectField(reference, _id_error, value.reference); + + static final _id_new0 = jni.Jni.accessors.getMethodIDOf(_class.reference, + r"", r"(Lcom/github/dart_lang/jnigen/interfaces/MyRunnable;)V"); + + /// from: public void (com.github.dart_lang.jnigen.interfaces.MyRunnable runnable) + /// The returned object must be deleted after use, by calling the `delete` method. + factory MyRunnableRunner( + MyRunnable runnable, + ) { + return MyRunnableRunner.fromRef(jni.Jni.accessors.newObjectWithArgs( + _class.reference, _id_new0, [runnable.reference]).object); + } + + static final _id_runOnSameThread = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"runOnSameThread", r"()V"); + + /// from: public void runOnSameThread() + void runOnSameThread() { + return jni.Jni.accessors.callMethodWithArgs( + reference, _id_runOnSameThread, jni.JniCallType.voidType, []).check(); + } + + static final _id_runOnAnotherThread = jni.Jni.accessors + .getMethodIDOf(_class.reference, r"runOnAnotherThread", r"()V"); + + /// from: public void runOnAnotherThread() + void runOnAnotherThread() { + return jni.Jni.accessors.callMethodWithArgs(reference, + _id_runOnAnotherThread, jni.JniCallType.voidType, []).check(); + } +} + +class $MyRunnableRunnerType extends jni.JObjType { + const $MyRunnableRunnerType(); + + @override + String get signature => + r"Lcom/github/dart_lang/jnigen/interfaces/MyRunnableRunner;"; + + @override + MyRunnableRunner fromRef(jni.JObjectPtr ref) => MyRunnableRunner.fromRef(ref); + + @override + jni.JObjType get superType => const jni.JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => ($MyRunnableRunnerType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == ($MyRunnableRunnerType) && + other is $MyRunnableRunnerType; + } +} + /// from: com.github.dart_lang.jnigen.annotations.JsonSerializable$Case class JsonSerializable_Case extends jni.JObject { @override diff --git a/pkgs/jnigen/test/simple_package_test/generate.dart b/pkgs/jnigen/test/simple_package_test/generate.dart index 446cfb285..9f5988880 100644 --- a/pkgs/jnigen/test/simple_package_test/generate.dart +++ b/pkgs/jnigen/test/simple_package_test/generate.dart @@ -32,6 +32,8 @@ var javaFiles = [ join(javaPrefix, 'generics', 'StringStack.java'), join(javaPrefix, 'generics', 'StringValuedMap.java'), join(javaPrefix, 'generics', 'StringKeyedMap.java'), + join(javaPrefix, 'interfaces', 'MyRunnable.java'), + join(javaPrefix, 'interfaces', 'MyRunnableRunner.java'), join(javaPrefix, 'interfaces', 'MyInterface.java'), join(javaPrefix, 'interfaces', 'MyInterfaceConsumer.java'), join(javaPrefix, 'annotations', 'JsonSerializable.java'), diff --git a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/interfaces/MyRunnable.java b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/interfaces/MyRunnable.java new file mode 100644 index 000000000..4a39f8154 --- /dev/null +++ b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/interfaces/MyRunnable.java @@ -0,0 +1,9 @@ +// 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. + +package com.github.dart_lang.jnigen.interfaces; + +public interface MyRunnable { + void run(); +} diff --git a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/interfaces/MyRunnableRunner.java b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/interfaces/MyRunnableRunner.java new file mode 100644 index 000000000..2903f37e0 --- /dev/null +++ b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/interfaces/MyRunnableRunner.java @@ -0,0 +1,28 @@ +// 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. + +package com.github.dart_lang.jnigen.interfaces; + +public class MyRunnableRunner { + final MyRunnable runnable; + + public Throwable error; + + public MyRunnableRunner(MyRunnable runnable) { + this.runnable = runnable; + } + + public void runOnSameThread() { + try { + runnable.run(); + } catch (Throwable e) { + error = e; + } + } + + public void runOnAnotherThread() { + var thread = new Thread(this::runOnSameThread); + thread.start(); + } +} 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 cae97587c..07ed1d3ae 100644 --- a/pkgs/jnigen/test/simple_package_test/runtime_test_registrant.dart +++ b/pkgs/jnigen/test/simple_package_test/runtime_test_registrant.dart @@ -24,8 +24,8 @@ void _runJavaGC() { final pid = bean.callMethodByName('getPid', '()J', []); ProcessResult result; do { - sleep(const Duration(milliseconds: 100)); result = Process.runSync('jcmd', [pid.toString(), 'GC.run']); + sleep(const Duration(milliseconds: 100)); } while (result.exitCode != 0); } @@ -624,6 +624,50 @@ void registerTests(String groupName, TestRunnerCallback test) { expect(MyInterface.$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 { + final runnable = MyRunnable.implement( + $MyRunnableImpl( + run: () { + throw exception; + }, + ), + ); + final runner = MyRunnableRunner(runnable); + if (sameThread) { + runner.runOnSameThread(); + } else { + runner.runOnAnotherThread(); + } + while (runner.error.isNull) { + await Future.delayed(const Duration(milliseconds: 100)); + } + expect( + Jni.env.IsInstanceOf( + runner.error.reference, + Jni.findClass('java/lang/reflect/UndeclaredThrowableException'), + ), + isTrue, + ); + final cause = runner.error.callMethodByName( + 'getCause', '()Ljava/lang/Throwable;', []); + expect( + Jni.env.IsInstanceOf( + cause.reference, + Jni.findClass( + 'com/github/dart_lang/jni/PortProxy\$DartException'), + ), + isTrue, + ); + expect(cause.toString(), contains(exception.toString())); + }); + } + } + }); }); group('$groupName (load tests)', () { From bd8aae49825904249eba01f741423713d5ff603d Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Wed, 30 Aug 2023 15:29:44 +0200 Subject: [PATCH 120/139] [jnigen] Rename `delete` to `release` (https://github.com/dart-lang/jnigen/issues/379) --- pkgs/jni/CHANGELOG.md | 3 +- pkgs/jni/README.md | 6 +- pkgs/jni/example/lib/main.dart | 4 +- pkgs/jni/example/pubspec.lock | 2 +- pkgs/jni/lib/src/jarray.dart | 4 +- pkgs/jni/lib/src/jexceptions.dart | 12 +- pkgs/jni/lib/src/jni.dart | 20 +- pkgs/jni/lib/src/jobject.dart | 29 ++- pkgs/jni/lib/src/jreference.dart | 43 ++-- pkgs/jni/lib/src/lang/jboolean.dart | 6 +- pkgs/jni/lib/src/lang/jcharacter.dart | 6 +- pkgs/jni/lib/src/lang/jnumber.dart | 36 +-- pkgs/jni/lib/src/lang/jstring.dart | 10 +- pkgs/jni/lib/src/util/jlist.dart | 4 +- pkgs/jni/pubspec.yaml | 11 +- pkgs/jni/test/boxed_test.dart | 65 ++--- pkgs/jni/test/exception_test.dart | 8 +- pkgs/jni/test/jarray_test.dart | 110 ++++---- pkgs/jni/test/jlist_test.dart | 68 ++--- pkgs/jni/test/jmap_test.dart | 66 ++--- pkgs/jni/test/jobject_test.dart | 63 ++--- pkgs/jni/test/jset_test.dart | 72 +++--- pkgs/jni/test/jstring_test.dart | 2 +- pkgs/jni/test/load_test.dart | 15 +- pkgs/jnigen/CHANGELOG.md | 13 +- pkgs/jnigen/README.md | 4 +- .../in_app_java/lib/android_utils.dart | 200 +++++++-------- .../kotlin_plugin/example/lib/main.dart | 4 +- .../kotlin_plugin/lib/kotlin_bindings.dart | 4 +- .../notification_plugin/example/lib/main.dart | 4 +- .../lib/notifications.dart | 2 +- .../pdfbox_plugin/example/lib/main.dart | 2 +- .../org/apache/pdfbox/pdmodel/PDDocument.dart | 70 +++--- .../pdfbox/pdmodel/PDDocumentInformation.dart | 30 +-- .../apache/pdfbox/text/PDFTextStripper.dart | 46 ++-- .../lib/src/bindings/dart_generator.dart | 30 +-- pkgs/jnigen/lib/src/bindings/renamer.dart | 5 +- pkgs/jnigen/pubspec.yaml | 14 +- .../runtime_test_registrant.dart | 12 +- .../fasterxml/jackson/core/JsonFactory.dart | 128 +++++----- .../fasterxml/jackson/core/JsonParser.dart | 112 ++++----- .../com/fasterxml/jackson/core/JsonToken.dart | 10 +- .../fasterxml/jackson/core/JsonFactory.dart | 128 +++++----- .../fasterxml/jackson/core/JsonParser.dart | 112 ++++----- .../com/fasterxml/jackson/core/JsonToken.dart | 10 +- .../c_based/dart_bindings/kotlin.dart | 6 +- .../dart_only/dart_bindings/kotlin.dart | 6 +- .../kotlin_test/runtime_test_registrant.dart | 8 +- .../c_based/dart_bindings/simple_package.dart | 236 +++++++++--------- .../dart_bindings/simple_package.dart | 236 +++++++++--------- .../runtime_test_registrant.dart | 222 ++++++++-------- 51 files changed, 1171 insertions(+), 1148 deletions(-) diff --git a/pkgs/jni/CHANGELOG.md b/pkgs/jni/CHANGELOG.md index 35a09db03..1c83295f1 100644 --- a/pkgs/jni/CHANGELOG.md +++ b/pkgs/jni/CHANGELOG.md @@ -1,4 +1,5 @@ -## 0.6.0-wip-2 +## 0.6.0 +* **Breaking Change** ([#131](https://github.com/dart-lang/jnigen/issues/131)): Renamed `delete*` to `release*`. * Added `PortProxy` and related methods used for interface implementation. * Added the missing binding for `java.lang.Character`. diff --git a/pkgs/jni/README.md b/pkgs/jni/README.md index 5195ace95..37f5b367c 100644 --- a/pkgs/jni/README.md +++ b/pkgs/jni/README.md @@ -4,13 +4,11 @@ This is a support library to access JNI from Dart / Flutter code. This provides This library contains: -* functions to access the JNIEnv and JavaVM variables from JNI, and wrapper functions to those provided by JNI. JNIEnv is exposed via `GlobalJniEnv` type which provides a thin abstraction over JNIEnv, so that it can be used from multiple threads. - +* Functions to access the JNIEnv and JavaVM variables from JNI, and wrapper functions to those provided by JNI. JNIEnv is exposed via `GlobalJniEnv` type which provides a thin abstraction over JNIEnv, so that it can be used from multiple threads. * Functions to spawn a JVM on desktop platforms (`Jni.spawn`). - * Some Android-specific helpers (get application context and current activity references). - * `JObject` class, which provides base class for classes generated by jnigen. +* Commonly used Java classes like `JList`, `JMap`, `JInteger`, ... Apart from being the base library for code generated by `jnigen` this can also be used for one-off uses of the JNI and debugging. __To generate type-safe bindings from Java libraries, use `jnigen`.__ diff --git a/pkgs/jni/example/lib/main.dart b/pkgs/jni/example/lib/main.dart index b2ca2b715..4c73693f3 100644 --- a/pkgs/jni/example/lib/main.dart +++ b/pkgs/jni/example/lib/main.dart @@ -44,7 +44,7 @@ int randomUsingEnv(int n) => using((arena) { double randomDouble() { final math = Jni.findJClass("java/lang/Math"); final random = math.callStaticMethodByName("random", "()D", []); - math.delete(); + math.release(); return random; } @@ -57,7 +57,7 @@ int uptime() { String backAndForth() { final jstring = '🪓'.toJString(); - final dartString = jstring.toDartString(deleteOriginal: true); + final dartString = jstring.toDartString(releaseOriginal: true); return dartString; } diff --git a/pkgs/jni/example/pubspec.lock b/pkgs/jni/example/pubspec.lock index eb16370f1..f70135ea1 100644 --- a/pkgs/jni/example/pubspec.lock +++ b/pkgs/jni/example/pubspec.lock @@ -200,7 +200,7 @@ packages: path: ".." relative: true source: path - version: "0.6.0-wip.2" + version: "0.6.0" js: dependency: transitive description: diff --git a/pkgs/jni/lib/src/jarray.dart b/pkgs/jni/lib/src/jarray.dart index b07cee0b8..1b970392b 100644 --- a/pkgs/jni/lib/src/jarray.dart +++ b/pkgs/jni/lib/src/jarray.dart @@ -78,7 +78,7 @@ class JArray extends JObject { type, Jni.accessors.newObjectArray(length, clazz.reference, nullptr).object, ); - clazz.delete(); + clazz.release(); return array; } return JArray.fromRef( @@ -102,7 +102,7 @@ class JArray extends JObject { .newObjectArray(length, clazz.reference, fill.reference) .object, ); - clazz.delete(); + clazz.release(); return array; } diff --git a/pkgs/jni/lib/src/jexceptions.dart b/pkgs/jni/lib/src/jexceptions.dart index 64b95fcd1..5a0d59e93 100644 --- a/pkgs/jni/lib/src/jexceptions.dart +++ b/pkgs/jni/lib/src/jexceptions.dart @@ -8,13 +8,13 @@ import 'package:jni/src/third_party/generated_bindings.dart'; abstract class JException implements Exception {} -class UseAfterFreeException implements JException { +class UseAfterReleaseException implements JException { final Pointer ptr; - UseAfterFreeException(this.ptr); + UseAfterReleaseException(this.ptr); @override String toString() { - return 'Use after free on $ptr.'; + return 'Use after release on $ptr.'; } } @@ -34,13 +34,13 @@ class InvalidJStringException implements JException { '0x${reference.address.toRadixString(16)}.'; } -class DoubleFreeException implements JException { +class DoubleReleaseException implements JException { final Pointer ptr; - DoubleFreeException(this.ptr); + DoubleReleaseException(this.ptr); @override String toString() { - return 'Double free on $ptr.'; + return 'Double release on $ptr.'; } } diff --git a/pkgs/jni/lib/src/jni.dart b/pkgs/jni/lib/src/jni.dart index d5495bc72..1e25151ff 100644 --- a/pkgs/jni/lib/src/jni.dart +++ b/pkgs/jni/lib/src/jni.dart @@ -11,7 +11,6 @@ import 'package:path/path.dart'; import 'jexceptions.dart'; import 'jobject.dart'; -import 'jreference.dart'; import 'third_party/generated_bindings.dart'; import 'jvalues.dart'; import 'accessors.dart'; @@ -230,7 +229,7 @@ abstract class Jni { final cls = findJClass(qualifiedName); final ctor = cls.getCtorID(ctorSignature); final obj = cls.newInstance(ctor, args); - cls.delete(); + cls.release(); return obj; } @@ -252,7 +251,7 @@ abstract class Jni { [int? callType]) { final cls = findJClass(className); final result = cls.getStaticFieldByName(fieldName, signature, callType); - cls.delete(); + cls.release(); return result; } @@ -267,16 +266,9 @@ abstract class Jni { final cls = findJClass(className); final result = cls.callStaticMethodByName(methodName, signature, args, callType); - cls.delete(); + cls.release(); return result; } - - /// Delete all references in [objects]. - static void deleteAll(List objects) { - for (var object in objects) { - object.delete(); - } - } } typedef _SetJniGettersNativeType = Void Function(Pointer, Pointer); @@ -340,9 +332,9 @@ extension ProtectedJniExtensions on Jni { extension AdditionalEnvMethods on GlobalJniEnv { /// Convenience method for converting a [JStringPtr] /// to dart string. - /// if [deleteOriginal] is specified, jstring passed will be deleted using + /// if [releaseOriginal] is specified, jstring passed will be deleted using /// DeleteGlobalRef. - String toDartString(JStringPtr jstringPtr, {bool deleteOriginal = false}) { + String toDartString(JStringPtr jstringPtr, {bool releaseOriginal = false}) { if (jstringPtr == nullptr) { throw const JNullException(); } @@ -352,7 +344,7 @@ extension AdditionalEnvMethods on GlobalJniEnv { } final result = chars.cast().toDartString(); ReleaseStringChars(jstringPtr, chars); - if (deleteOriginal) { + if (releaseOriginal) { DeleteGlobalRef(jstringPtr); } return result; diff --git a/pkgs/jni/lib/src/jobject.dart b/pkgs/jni/lib/src/jobject.dart index c0b077b77..6a2cad207 100644 --- a/pkgs/jni/lib/src/jobject.dart +++ b/pkgs/jni/lib/src/jobject.dart @@ -124,7 +124,7 @@ T _callOrGet(int? callType, JniResult Function(int) function) { callType, JniCallType.objectType, {JniCallType.objectType}); final ref = function(finalCallType).object; final ctor = T == String - ? (ref) => Jni.env.toDartString(ref, deleteOriginal: true) + ? (ref) => Jni.env.toDartString(ref, releaseOriginal: true) : (T == JObject ? JObject.fromRef : JString.fromRef); result = ctor(ref) as T; break; @@ -177,12 +177,12 @@ class JObject extends JReference { return _jClass ??= getClass(); } - /// Deletes the JNI reference and marks this object as deleted. Any further - /// uses will throw [UseAfterFreeException]. + /// Deletes the JNI reference and marks this object as released. Any further + /// uses will throw [UseAfterReleaseException]. @override - void delete() { - _jClass?.delete(); - super.delete(); + void release() { + _jClass?.release(); + super.release(); } /// Returns [JClass] corresponding to concrete class of this object. @@ -304,12 +304,17 @@ class JObject extends JReference { return callStaticMethod(id, args, callType); } - /// Casts this object to another type. - T castTo(JObjType type, {bool deleteOriginal = false}) { - if (deleteOriginal) { - _jClass?.delete(); + /// Casts this object to another [type]. + /// + /// If [releaseOriginal] is `true`, the casted object will be released. + T castTo( + JObjType type, { + bool releaseOriginal = false, + }) { + if (releaseOriginal) { + _jClass?.release(); final ret = type.fromRef(reference); - setAsDeleted(); + setAsReleased(); return ret; } final newRef = Jni.env.NewGlobalRef(reference); @@ -341,7 +346,7 @@ class JObject extends JReference { String toString() { return JString.fromRef(Jni.accessors.callMethodWithArgs( reference, _toStringId, JniCallType.objectType, []).object) - .toDartString(deleteOriginal: true); + .toDartString(releaseOriginal: true); } } diff --git a/pkgs/jni/lib/src/jreference.dart b/pkgs/jni/lib/src/jreference.dart index 973b3f3a3..68c0adaf4 100644 --- a/pkgs/jni/lib/src/jreference.dart +++ b/pkgs/jni/lib/src/jreference.dart @@ -11,11 +11,11 @@ import 'jexceptions.dart'; import 'jni.dart'; extension ProtectedJReference on JReference { - void setAsDeleted() { - if (_deleted) { - throw DoubleFreeException(_reference); + void setAsReleased() { + if (_released) { + throw DoubleReleaseException(_reference); } - _deleted = true; + _released = true; JReference._finalizer.detach(this); } @@ -29,13 +29,14 @@ extension ProtectedJReference on JReference { /// /// Detaches the finalizer so the underlying pointer will not be deleted. JObjectPtr toPointer() { - setAsDeleted(); + setAsReleased(); return _reference; } } -/// A class which holds one or more JNI references, and has a `delete` operation -/// which disposes the reference(s). +/// A managed JNI global reference. +/// +/// Uses a [NativeFinalizer] to delete the JNI global reference when finalized. abstract class JReference implements Finalizable { static final _finalizer = NativeFinalizer(Jni.env.ptr.ref.DeleteGlobalRef.cast()); @@ -44,37 +45,37 @@ abstract class JReference implements Finalizable { _finalizer.attach(this, _reference, detach: this); } - bool _deleted = false; + bool _released = false; /// Check whether the underlying JNI reference is `null`. bool get isNull => reference == nullptr; - /// Returns whether this object is deleted. - bool get isDeleted => _deleted; + /// Returns `true` if the underlying JNI reference is deleted. + bool get isReleased => _released; /// Deletes the underlying JNI reference. /// - /// Further uses will throw [UseAfterFreeException]. - void delete() { - setAsDeleted(); + /// Further uses will throw [UseAfterReleaseException]. + void release() { + setAsReleased(); Jni.env.DeleteGlobalRef(_reference); } /// The underlying JNI global object reference. /// - /// Throws [UseAfterFreeException] if the object is previously deleted. + /// Throws [UseAfterReleaseException] if the object is previously released. /// - /// Be careful when storing this reference in a variable, since the underlying - /// object might get deleted. + /// Be careful when storing this in a variable since it might have gotten + /// released upon use. JObjectPtr get reference { - if (_deleted) throw UseAfterFreeException(_reference); + if (_released) throw UseAfterReleaseException(_reference); return _reference; } final JObjectPtr _reference; - /// Registers this object to be deleted at the end of [arena]'s lifetime. - void deletedIn(Arena arena) => arena.onReleaseAll(delete); + /// Registers this object to be released at the end of [arena]'s lifetime. + void releasedBy(Arena arena) => arena.onReleaseAll(release); } extension JReferenceUseExtension on T { @@ -83,10 +84,10 @@ extension JReferenceUseExtension on T { R use(R Function(T) callback) { try { final result = callback(this); - delete(); + release(); return result; } catch (e) { - delete(); + release(); rethrow; } } diff --git a/pkgs/jni/lib/src/lang/jboolean.dart b/pkgs/jni/lib/src/lang/jboolean.dart index 04f4e7cf3..3dd22b112 100644 --- a/pkgs/jni/lib/src/lang/jboolean.dart +++ b/pkgs/jni/lib/src/lang/jboolean.dart @@ -56,12 +56,12 @@ class JBoolean extends JObject { static final _booleanValueId = Jni.accessors.getMethodIDOf(_class.reference, r"booleanValue", r"()Z"); - bool booleanValue({bool deleteOriginal = false}) { + bool booleanValue({bool releaseOriginal = false}) { ensureNotNull(); final ret = Jni.accessors.callMethodWithArgs( reference, _booleanValueId, JniCallType.booleanType, []).boolean; - if (deleteOriginal) { - delete(); + if (releaseOriginal) { + release(); } return ret; } diff --git a/pkgs/jni/lib/src/lang/jcharacter.dart b/pkgs/jni/lib/src/lang/jcharacter.dart index 067870663..c43d2e0e3 100644 --- a/pkgs/jni/lib/src/lang/jcharacter.dart +++ b/pkgs/jni/lib/src/lang/jcharacter.dart @@ -54,12 +54,12 @@ class JCharacter extends JObject { static final _charValueId = Jni.accessors.getMethodIDOf(_class.reference, r"charValue", r"()C"); - int charValue({bool deleteOriginal = false}) { + int charValue({bool releaseOriginal = false}) { ensureNotNull(); final ret = Jni.accessors.callMethodWithArgs( reference, _charValueId, JniCallType.charType, []).char; - if (deleteOriginal) { - delete(); + if (releaseOriginal) { + release(); } return ret; } diff --git a/pkgs/jni/lib/src/lang/jnumber.dart b/pkgs/jni/lib/src/lang/jnumber.dart index a46814733..43e108568 100644 --- a/pkgs/jni/lib/src/lang/jnumber.dart +++ b/pkgs/jni/lib/src/lang/jnumber.dart @@ -64,12 +64,12 @@ class JNumber extends JObject { static final _intValueId = Jni.accessors.getMethodIDOf(_class.reference, r"intValue", r"()I"); - int intValue({bool deleteOriginal = false}) { + int intValue({bool releaseOriginal = false}) { ensureNotNull(); final ret = Jni.accessors.callMethodWithArgs( reference, _intValueId, JniCallType.intType, []).integer; - if (deleteOriginal) { - delete(); + if (releaseOriginal) { + release(); } return ret; } @@ -77,12 +77,12 @@ class JNumber extends JObject { static final _longValueId = Jni.accessors.getMethodIDOf(_class.reference, r"longValue", r"()J"); - int longValue({bool deleteOriginal = false}) { + int longValue({bool releaseOriginal = false}) { ensureNotNull(); final ret = Jni.accessors.callMethodWithArgs( reference, _longValueId, JniCallType.longType, []).long; - if (deleteOriginal) { - delete(); + if (releaseOriginal) { + release(); } return ret; } @@ -90,12 +90,12 @@ class JNumber extends JObject { static final _floatValueId = Jni.accessors.getMethodIDOf(_class.reference, r"floatValue", r"()F"); - double floatValue({bool deleteOriginal = false}) { + double floatValue({bool releaseOriginal = false}) { ensureNotNull(); final ret = Jni.accessors.callMethodWithArgs( reference, _floatValueId, JniCallType.floatType, []).float; - if (deleteOriginal) { - delete(); + if (releaseOriginal) { + release(); } return ret; } @@ -103,12 +103,12 @@ class JNumber extends JObject { static final _doubleValueId = Jni.accessors.getMethodIDOf(_class.reference, r"doubleValue", r"()D"); - double doubleValue({bool deleteOriginal = false}) { + double doubleValue({bool releaseOriginal = false}) { ensureNotNull(); final ret = Jni.accessors.callMethodWithArgs( reference, _doubleValueId, JniCallType.doubleType, []).doubleFloat; - if (deleteOriginal) { - delete(); + if (releaseOriginal) { + release(); } return ret; } @@ -116,12 +116,12 @@ class JNumber extends JObject { static final _byteValueId = Jni.accessors.getMethodIDOf(_class.reference, r"byteValue", r"()B"); - int byteValue({bool deleteOriginal = false}) { + int byteValue({bool releaseOriginal = false}) { ensureNotNull(); final ret = Jni.accessors.callMethodWithArgs( reference, _byteValueId, JniCallType.byteType, []).byte; - if (deleteOriginal) { - delete(); + if (releaseOriginal) { + release(); } return ret; } @@ -129,12 +129,12 @@ class JNumber extends JObject { static final _shortValueId = Jni.accessors.getMethodIDOf(_class.reference, r"shortValue", r"()S"); - int shortValue({bool deleteOriginal = false}) { + int shortValue({bool releaseOriginal = false}) { ensureNotNull(); final ret = Jni.accessors.callMethodWithArgs( reference, _shortValueId, JniCallType.shortType, []).short; - if (deleteOriginal) { - delete(); + if (releaseOriginal) { + release(); } return ret; } diff --git a/pkgs/jni/lib/src/lang/jstring.dart b/pkgs/jni/lib/src/lang/jstring.dart index f1df76c4c..43bda602d 100644 --- a/pkgs/jni/lib/src/lang/jstring.dart +++ b/pkgs/jni/lib/src/lang/jstring.dart @@ -55,16 +55,16 @@ class JString extends JObject { /// Returns the contents as a Dart String. /// - /// If [deleteOriginal] is true, the underlying reference is deleted - /// after conversion and this object will be marked as deleted. - String toDartString({bool deleteOriginal = false}) { + /// If [releaseOriginal] is true, the underlying reference is deleted + /// after conversion and this object will be marked as released. + String toDartString({bool releaseOriginal = false}) { ensureNotNull(); final length = Jni.env.GetStringLength(reference); final chars = Jni.env.GetStringChars(reference, nullptr); final result = chars.cast().toDartString(length: length); Jni.env.ReleaseStringChars(reference, chars); - if (deleteOriginal) { - delete(); + if (releaseOriginal) { + release(); } return result; } diff --git a/pkgs/jni/lib/src/util/jlist.dart b/pkgs/jni/lib/src/util/jlist.dart index 8087af985..19cb1ed07 100644 --- a/pkgs/jni/lib/src/util/jlist.dart +++ b/pkgs/jni/lib/src/util/jlist.dart @@ -235,7 +235,7 @@ class JList<$E extends JObject> extends JObject with ListMixin<$E> { JniCallType.intType, [element.reference], ).integer; - range.delete(); + range.release(); return res; } @@ -260,7 +260,7 @@ class JList<$E extends JObject> extends JObject with ListMixin<$E> { void removeRange(int start, int end) { final range = getRange(start, end); range.clear(); - range.delete(); + range.release(); } @override diff --git a/pkgs/jni/pubspec.yaml b/pkgs/jni/pubspec.yaml index 2808b3cbd..c26952047 100644 --- a/pkgs/jni/pubspec.yaml +++ b/pkgs/jni/pubspec.yaml @@ -3,10 +3,17 @@ # BSD-style license that can be found in the LICENSE file. name: jni -description: Library to access JNI from Dart and Flutter. -version: 0.6.0-wip.2 +description: A library to access JNI from Dart and Flutter that acts as a support library for package:jnigen. +version: 0.6.0 repository: https://github.com/dart-lang/jnigen/tree/main/jni +topics: + - interop + - ffi + - java + - kotlin + - jni + environment: sdk: '>=3.1.0-262.3.beta <4.0.0' flutter: '>=2.11.0' diff --git a/pkgs/jni/test/boxed_test.dart b/pkgs/jni/test/boxed_test.dart index 88d8686d1..261b1accc 100644 --- a/pkgs/jni/test/boxed_test.dart +++ b/pkgs/jni/test/boxed_test.dart @@ -22,44 +22,44 @@ void run({required TestRunnerCallback testRunner}) { testRunner('JByte', () { const val = 1 << 5; using((arena) { - expect(JByte(val).byteValue(deleteOriginal: true), val); - expect((-val).toJByte().byteValue(deleteOriginal: true), -val); + expect(JByte(val).byteValue(releaseOriginal: true), val); + expect((-val).toJByte().byteValue(releaseOriginal: true), -val); }); }); testRunner('JCharacter', () { const val = 1 << 5; using((arena) { - expect(JCharacter(val).charValue(deleteOriginal: true), val); - expect(JCharacter(0).charValue(deleteOriginal: true), 0); + expect(JCharacter(val).charValue(releaseOriginal: true), val); + expect(JCharacter(0).charValue(releaseOriginal: true), 0); }); }); testRunner('JShort', () { const val = 1 << 10; using((arena) { - expect(JShort(val).shortValue(deleteOriginal: true), val); - expect((-val).toJShort().shortValue(deleteOriginal: true), -val); + expect(JShort(val).shortValue(releaseOriginal: true), val); + expect((-val).toJShort().shortValue(releaseOriginal: true), -val); }); }); testRunner('JInteger', () { const val = 1 << 20; using((arena) { - expect(JInteger(val).intValue(deleteOriginal: true), val); - expect((-val).toJInteger().intValue(deleteOriginal: true), -val); + expect(JInteger(val).intValue(releaseOriginal: true), val); + expect((-val).toJInteger().intValue(releaseOriginal: true), -val); }); }); testRunner('JLong', () { const val = 1 << 40; using((arena) { - expect(JLong(val).longValue(deleteOriginal: true), val); - expect((-val).toJLong().longValue(deleteOriginal: true), -val); + expect(JLong(val).longValue(releaseOriginal: true), val); + expect((-val).toJLong().longValue(releaseOriginal: true), -val); }); }); testRunner('JFloat', () { const val = 3.14; const eps = 1e-6; using((arena) { - expect(JFloat(val).floatValue(deleteOriginal: true), closeTo(val, eps)); - expect((-val).toJFloat().floatValue(deleteOriginal: true), + expect(JFloat(val).floatValue(releaseOriginal: true), closeTo(val, eps)); + expect((-val).toJFloat().floatValue(releaseOriginal: true), closeTo(-val, eps)); }); }); @@ -67,77 +67,78 @@ void run({required TestRunnerCallback testRunner}) { const val = 3.14; const eps = 1e-9; using((arena) { - expect(JDouble(val).doubleValue(deleteOriginal: true), closeTo(val, eps)); - expect((-val).toJDouble().doubleValue(deleteOriginal: true), + expect( + JDouble(val).doubleValue(releaseOriginal: true), closeTo(val, eps)); + expect((-val).toJDouble().doubleValue(releaseOriginal: true), closeTo(-val, eps)); }); }); testRunner('JBoolean', () { using((arena) { - expect(JBoolean(false).booleanValue(deleteOriginal: true), false); - expect(JBoolean(true).booleanValue(deleteOriginal: true), true); + expect(JBoolean(false).booleanValue(releaseOriginal: true), false); + expect(JBoolean(true).booleanValue(releaseOriginal: true), true); }); }); testRunner('JByte.\$type hashCode and ==', () { using((arena) { - final a = JByte(1)..deletedIn(arena); - final b = JByte(2)..deletedIn(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)..deletedIn(arena); - final b = JCharacter(2)..deletedIn(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)..deletedIn(arena); - final b = JShort(2)..deletedIn(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)..deletedIn(arena); - final b = JInteger(2)..deletedIn(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)..deletedIn(arena); - final b = JLong(2)..deletedIn(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)..deletedIn(arena); - final b = JFloat(2.0)..deletedIn(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)..deletedIn(arena); - final b = JDouble(2.0)..deletedIn(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)..deletedIn(arena); - final b = JBoolean(false)..deletedIn(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 d9af2542f..d3c806dc8 100644 --- a/pkgs/jni/test/exception_test.dart +++ b/pkgs/jni/test/exception_test.dart @@ -37,15 +37,15 @@ void main() { void run({required TestRunnerCallback testRunner}) { testRunner("double free throws exception", () { final r = Jni.newInstance("java/util/Random", "()V", []); - r.delete(); - expect(r.delete, throwsA(isA())); + r.release(); + expect(r.release, throwsA(isA())); }); testRunner("Use after free throws exception", () { final r = Jni.newInstance("java/util/Random", "()V", []); - r.delete(); + r.release(); expect(() => r.callMethodByName("nextInt", "(I)I", [JValueInt(256)]), - throwsA(isA())); + throwsA(isA())); }); testRunner("void fieldType throws exception", () { diff --git a/pkgs/jni/test/jarray_test.dart b/pkgs/jni/test/jarray_test.dart index 18550e5e8..3cc7c9885 100644 --- a/pkgs/jni/test/jarray_test.dart +++ b/pkgs/jni/test/jarray_test.dart @@ -21,7 +21,7 @@ void main() { void run({required TestRunnerCallback testRunner}) { testRunner("Java boolean array", () { using((arena) { - final array = JArray(jboolean.type, 3)..deletedIn(arena); + final array = JArray(jboolean.type, 3)..releasedBy(arena); expect(array.length, 3); array[0] = true; array[1] = false; @@ -46,7 +46,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner("Java char array", () { using((arena) { - final array = JArray(jchar.type, 3)..deletedIn(arena); + final array = JArray(jchar.type, 3)..releasedBy(arena); expect(array.length, 3); array[0] = 'ح'; array[1] = '2'; @@ -71,7 +71,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner("Java byte array", () { using((arena) { - final array = JArray(jbyte.type, 3)..deletedIn(arena); + final array = JArray(jbyte.type, 3)..releasedBy(arena); expect(array.length, 3); array[0] = 1; array[1] = 2; @@ -96,7 +96,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner("Java short array", () { using((arena) { - final array = JArray(jshort.type, 3)..deletedIn(arena); + final array = JArray(jshort.type, 3)..releasedBy(arena); expect(array.length, 3); array[0] = 1; array[1] = 2; @@ -121,7 +121,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner("Java int array", () { using((arena) { - final array = JArray(jint.type, 3)..deletedIn(arena); + final array = JArray(jint.type, 3)..releasedBy(arena); expect(array.length, 3); array[0] = 1; array[1] = 2; @@ -146,7 +146,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner("Java long array", () { using((arena) { - final array = JArray(jlong.type, 3)..deletedIn(arena); + final array = JArray(jlong.type, 3)..releasedBy(arena); expect(array.length, 3); array[0] = 1; array[1] = 2; @@ -172,7 +172,7 @@ void run({required TestRunnerCallback testRunner}) { const epsilon = 1e-6; testRunner("Java float array", () { using((arena) { - final array = JArray(jfloat.type, 3)..deletedIn(arena); + final array = JArray(jfloat.type, 3)..releasedBy(arena); expect(array.length, 3); array[0] = 0.5; array[1] = 2; @@ -197,7 +197,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner("Java double array", () { using((arena) { - final array = JArray(jdouble.type, 3)..deletedIn(arena); + final array = JArray(jdouble.type, 3)..releasedBy(arena); expect(array.length, 3); array[0] = 0.5; array[1] = 2; @@ -222,42 +222,42 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner("Java string array", () { using((arena) { - final array = JArray(JString.type, 3)..deletedIn(arena); + final array = JArray(JString.type, 3)..releasedBy(arena); expect(array.length, 3); - array[0] = "حس".toJString()..deletedIn(arena); - array[1] = "\$".toJString()..deletedIn(arena); - array[2] = "33".toJString()..deletedIn(arena); - expect(array[0].toDartString(deleteOriginal: true), "حس"); - expect(array[1].toDartString(deleteOriginal: true), "\$"); - expect(array[2].toDartString(deleteOriginal: true), "33"); + array[0] = "حس".toJString()..releasedBy(arena); + array[1] = "\$".toJString()..releasedBy(arena); + array[2] = "33".toJString()..releasedBy(arena); + expect(array[0].toDartString(releaseOriginal: true), "حس"); + expect(array[1].toDartString(releaseOriginal: true), "\$"); + expect(array[2].toDartString(releaseOriginal: true), "33"); array.setRange( 0, 3, [ - "44".toJString()..deletedIn(arena), - "55".toJString()..deletedIn(arena), - "66".toJString()..deletedIn(arena), - "77".toJString()..deletedIn(arena), + "44".toJString()..releasedBy(arena), + "55".toJString()..releasedBy(arena), + "66".toJString()..releasedBy(arena), + "77".toJString()..releasedBy(arena), ], 1, ); - expect(array[0].toDartString(deleteOriginal: true), "55"); - expect(array[1].toDartString(deleteOriginal: true), "66"); - expect(array[2].toDartString(deleteOriginal: true), "77"); + expect(array[0].toDartString(releaseOriginal: true), "55"); + expect(array[1].toDartString(releaseOriginal: true), "66"); + expect(array[2].toDartString(releaseOriginal: true), "77"); expect(() { final _ = array[-1]; }, throwsRangeError); expect(() { - array[-1] = "44".toJString()..deletedIn(arena); + array[-1] = "44".toJString()..releasedBy(arena); }, throwsRangeError); expect(() { - array[3] = "44".toJString()..deletedIn(arena); + array[3] = "44".toJString()..releasedBy(arena); }, throwsRangeError); }); }); testRunner("Java object array", () { using((arena) { - final array = JArray(JObject.type, 3)..deletedIn(arena); + final array = JArray(JObject.type, 3)..releasedBy(arena); expect(array.length, 3); expect(array[0].reference, nullptr); expect(array[1].reference, nullptr); @@ -266,11 +266,11 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner("Java 2d array", () { using((arena) { - final array = JArray(jint.type, 3)..deletedIn(arena); + final array = JArray(jint.type, 3)..releasedBy(arena); array[0] = 1; array[1] = 2; array[2] = 3; - final twoDimArray = JArray(JArray.type(jint.type), 3)..deletedIn(arena); + final twoDimArray = JArray(JArray.type(jint.type), 3)..releasedBy(arena); expect(twoDimArray.length, 3); twoDimArray[0] = array; twoDimArray[1] = array; @@ -286,86 +286,86 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner("JArray.filled", () { using((arena) { - final string = "abc".toJString()..deletedIn(arena); - final array = JArray.filled(3, string)..deletedIn(arena); + final string = "abc".toJString()..releasedBy(arena); + final array = JArray.filled(3, string)..releasedBy(arena); expect( () { final _ = JArray.filled(3, JString.fromRef(nullptr)) - ..deletedIn(arena); + ..releasedBy(arena); }, throwsA(isA()), ); expect(array.length, 3); - expect(array[0].toDartString(deleteOriginal: true), "abc"); - expect(array[1].toDartString(deleteOriginal: true), "abc"); - expect(array[2].toDartString(deleteOriginal: true), "abc"); + expect(array[0].toDartString(releaseOriginal: true), "abc"); + expect(array[1].toDartString(releaseOriginal: true), "abc"); + expect(array[2].toDartString(releaseOriginal: true), "abc"); }); }); testRunner('JArray of JByte', () { using((arena) { - final arr = JArray(JByte.type, 1)..deletedIn(arena); - expect((arr[0]..deletedIn(arena)).isNull, true); + final arr = JArray(JByte.type, 1)..releasedBy(arena); + expect((arr[0]..releasedBy(arena)).isNull, true); }); }); testRunner('JArray of JShort', () { using((arena) { - final arr = JArray(JShort.type, 1)..deletedIn(arena); - expect((arr[0]..deletedIn(arena)).isNull, true); + final arr = JArray(JShort.type, 1)..releasedBy(arena); + expect((arr[0]..releasedBy(arena)).isNull, true); }); }); testRunner('JArray of JInteger', () { using((arena) { - final arr = JArray(JInteger.type, 1)..deletedIn(arena); - expect((arr[0]..deletedIn(arena)).isNull, true); + final arr = JArray(JInteger.type, 1)..releasedBy(arena); + expect((arr[0]..releasedBy(arena)).isNull, true); }); }); testRunner('JArray of JLong', () { using((arena) { - final arr = JArray(JLong.type, 1)..deletedIn(arena); - expect((arr[0]..deletedIn(arena)).isNull, true); + final arr = JArray(JLong.type, 1)..releasedBy(arena); + expect((arr[0]..releasedBy(arena)).isNull, true); }); }); testRunner('JArray of JFloat', () { using((arena) { - final arr = JArray(JFloat.type, 1)..deletedIn(arena); - expect((arr[0]..deletedIn(arena)).isNull, true); + final arr = JArray(JFloat.type, 1)..releasedBy(arena); + expect((arr[0]..releasedBy(arena)).isNull, true); }); }); testRunner('JArray of JDouble', () { using((arena) { - final arr = JArray(JDouble.type, 1)..deletedIn(arena); - expect((arr[0]..deletedIn(arena)).isNull, true); + final arr = JArray(JDouble.type, 1)..releasedBy(arena); + expect((arr[0]..releasedBy(arena)).isNull, true); }); }); testRunner('JArray of JBoolean', () { using((arena) { - final arr = JArray(JBoolean.type, 1)..deletedIn(arena); - expect((arr[0]..deletedIn(arena)).isNull, true); + final arr = JArray(JBoolean.type, 1)..releasedBy(arena); + expect((arr[0]..releasedBy(arena)).isNull, true); }); }); testRunner('JArray of JSet', () { using((arena) { - final arr = JArray(JSet.type(JString.type), 1)..deletedIn(arena); - expect((arr[0]..deletedIn(arena)).isNull, true); + final arr = JArray(JSet.type(JString.type), 1)..releasedBy(arena); + expect((arr[0]..releasedBy(arena)).isNull, true); }); }); testRunner('JArray of JList', () { using((arena) { - final arr = JArray(JList.type(JString.type), 1)..deletedIn(arena); - expect((arr[0]..deletedIn(arena)).isNull, true); + final arr = JArray(JList.type(JString.type), 1)..releasedBy(arena); + expect((arr[0]..releasedBy(arena)).isNull, true); }); }); testRunner('JArray of JMap', () { using((arena) { final arr = JArray(JMap.type(JString.type, JString.type), 1) - ..deletedIn(arena); - expect((arr[0]..deletedIn(arena)).isNull, true); + ..releasedBy(arena); + expect((arr[0]..releasedBy(arena)).isNull, true); }); }); testRunner('JArray of JIterator', () { using((arena) { - final arr = JArray(JIterator.type(JString.type), 1)..deletedIn(arena); - expect((arr[0]..deletedIn(arena)).isNull, true); + final arr = JArray(JIterator.type(JString.type), 1)..releasedBy(arena); + expect((arr[0]..releasedBy(arena)).isNull, true); }); }); } diff --git a/pkgs/jni/test/jlist_test.dart b/pkgs/jni/test/jlist_test.dart index c483d53d3..b410525be 100644 --- a/pkgs/jni/test/jlist_test.dart +++ b/pkgs/jni/test/jlist_test.dart @@ -21,11 +21,11 @@ void main() { void run({required TestRunnerCallback testRunner}) { JList testDataList(Arena arena) { return [ - "1".toJString()..deletedIn(arena), - "2".toJString()..deletedIn(arena), - "3".toJString()..deletedIn(arena), + "1".toJString()..releasedBy(arena), + "2".toJString()..releasedBy(arena), + "3".toJString()..releasedBy(arena), ].toJList(JString.type) - ..deletedIn(arena); + ..releasedBy(arena); } testRunner('length get', () { @@ -47,25 +47,25 @@ void run({required TestRunnerCallback testRunner}) { testRunner('[]', () { using((arena) { final list = testDataList(arena); - expect(list[0].toDartString(deleteOriginal: true), "1"); - expect(list[1].toDartString(deleteOriginal: true), "2"); - expect(list[2].toDartString(deleteOriginal: true), "3"); + expect(list[0].toDartString(releaseOriginal: true), "1"); + expect(list[1].toDartString(releaseOriginal: true), "2"); + expect(list[2].toDartString(releaseOriginal: true), "3"); }); }); testRunner('[]=', () { using((arena) { final list = testDataList(arena); - expect(list[0].toDartString(deleteOriginal: true), "1"); - list[0] = "2".toJString()..deletedIn(arena); - expect(list[0].toDartString(deleteOriginal: true), "2"); + expect(list[0].toDartString(releaseOriginal: true), "1"); + list[0] = "2".toJString()..releasedBy(arena); + expect(list[0].toDartString(releaseOriginal: true), "2"); }); }); testRunner('add', () { using((arena) { final list = testDataList(arena); - list.add("4".toJString()..deletedIn(arena)); + list.add("4".toJString()..releasedBy(arena)); expect(list.length, 4); - expect(list[3].toDartString(deleteOriginal: true), "4"); + expect(list[3].toDartString(releaseOriginal: true), "4"); }); }); testRunner('addAll', () { @@ -74,7 +74,7 @@ void run({required TestRunnerCallback testRunner}) { final toAppend = testDataList(arena); list.addAll(toAppend); expect(list.length, 6); - list.addAll(["4".toJString()..deletedIn(arena)]); + list.addAll(["4".toJString()..releasedBy(arena)]); expect(list.length, 7); }); }); @@ -93,17 +93,17 @@ void run({required TestRunnerCallback testRunner}) { final list = testDataList(arena); // ignore: iterable_contains_unrelated_type expect(list.contains("1"), false); - expect(list.contains("1".toJString()..deletedIn(arena)), true); - expect(list.contains("4".toJString()..deletedIn(arena)), false); + expect(list.contains("1".toJString()..releasedBy(arena)), true); + expect(list.contains("4".toJString()..releasedBy(arena)), false); }); }); testRunner('getRange', () { using((arena) { final list = testDataList(arena); // ignore: iterable_contains_unrelated_type - final range = list.getRange(1, 2)..deletedIn(arena); + final range = list.getRange(1, 2)..releasedBy(arena); expect(range.length, 1); - expect(range.first.toDartString(deleteOriginal: true), "2"); + expect(range.first.toDartString(releaseOriginal: true), "2"); }); }); testRunner('indexOf', () { @@ -119,9 +119,9 @@ void run({required TestRunnerCallback testRunner}) { testRunner('insert', () { using((arena) { final list = testDataList(arena); - list.insert(1, "0".toJString()..deletedIn(arena)); + list.insert(1, "0".toJString()..releasedBy(arena)); expect(list.length, 4); - expect(list[1].toDartString(deleteOriginal: true), "0"); + expect(list[1].toDartString(releaseOriginal: true), "0"); }); }); testRunner('insertAll', () { @@ -129,11 +129,11 @@ void run({required TestRunnerCallback testRunner}) { final list = testDataList(arena); final toInsert = testDataList(arena); list.insertAll(1, toInsert); - expect(list[1].toDartString(deleteOriginal: true), "1"); + expect(list[1].toDartString(releaseOriginal: true), "1"); expect(list.length, 6); - list.insertAll(1, ["4".toJString()..deletedIn(arena)]); + list.insertAll(1, ["4".toJString()..releasedBy(arena)]); expect(list.length, 7); - expect(list[1].toDartString(deleteOriginal: true), "4"); + expect(list[1].toDartString(releaseOriginal: true), "4"); }); }); testRunner('iterator', () { @@ -141,20 +141,20 @@ void run({required TestRunnerCallback testRunner}) { final list = testDataList(arena); final it = list.iterator; expect(it.moveNext(), true); - expect(it.current.toDartString(deleteOriginal: true), "1"); + expect(it.current.toDartString(releaseOriginal: true), "1"); expect(it.moveNext(), true); - expect(it.current.toDartString(deleteOriginal: true), "2"); + expect(it.current.toDartString(releaseOriginal: true), "2"); expect(it.moveNext(), true); - expect(it.current.toDartString(deleteOriginal: true), "3"); + expect(it.current.toDartString(releaseOriginal: true), "3"); expect(it.moveNext(), false); }); }); testRunner('remove', () { using((arena) { final list = testDataList(arena); - expect(list.remove("3".toJString()..deletedIn(arena)), true); + expect(list.remove("3".toJString()..releasedBy(arena)), true); expect(list.length, 2); - expect(list.remove("4".toJString()..deletedIn(arena)), false); + expect(list.remove("4".toJString()..releasedBy(arena)), false); // ignore: list_remove_unrelated_type expect(list.remove(1), false); }); @@ -162,15 +162,15 @@ void run({required TestRunnerCallback testRunner}) { testRunner('removeAt', () { using((arena) { final list = testDataList(arena); - expect(list.removeAt(0).toDartString(deleteOriginal: true), "1"); - expect(list.removeAt(1).toDartString(deleteOriginal: true), "3"); + expect(list.removeAt(0).toDartString(releaseOriginal: true), "1"); + expect(list.removeAt(1).toDartString(releaseOriginal: true), "3"); }); }); testRunner('removeRange', () { using((arena) { final list = testDataList(arena); list.removeRange(0, 2); - expect(list.single.toDartString(deleteOriginal: true), "3"); + expect(list.single.toDartString(releaseOriginal: true), "3"); }); }); testRunner('==, hashCode', () { @@ -179,7 +179,7 @@ void run({required TestRunnerCallback testRunner}) { final b = testDataList(arena); expect(a.hashCode, b.hashCode); expect(a, b); - b.add("4".toJString()..deletedIn(arena)); + b.add("4".toJString()..releasedBy(arena)); expect(a.hashCode, isNot(b.hashCode)); expect(a, isNot(b)); }); @@ -187,7 +187,7 @@ void run({required TestRunnerCallback testRunner}) { testRunner('toSet', () { using((arena) { final list = testDataList(arena); - final set = list.toSet()..deletedIn(arena); + final set = list.toSet()..releasedBy(arena); expect(set.length, 3); }); }); @@ -197,7 +197,7 @@ void run({required TestRunnerCallback testRunner}) { final b = testDataList(arena); expect(a.$type, b.$type); expect(a.$type.hashCode, b.$type.hashCode); - final c = JList.array(JObject.type)..deletedIn(arena); + final c = JList.array(JObject.type)..releasedBy(arena); expect(a.$type, isNot(c.$type)); expect(a.$type.hashCode, isNot(c.$type.hashCode)); }); @@ -208,7 +208,7 @@ void run({required TestRunnerCallback testRunner}) { 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)..deletedIn(arena); + 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 23edb22d0..4ece7517f 100644 --- a/pkgs/jni/test/jmap_test.dart +++ b/pkgs/jni/test/jmap_test.dart @@ -20,11 +20,12 @@ void main() { void run({required TestRunnerCallback testRunner}) { JMap testDataMap(Arena arena) { return { - "1".toJString()..deletedIn(arena): "One".toJString()..deletedIn(arena), - "2".toJString()..deletedIn(arena): "Two".toJString()..deletedIn(arena), - "3".toJString()..deletedIn(arena): "Three".toJString()..deletedIn(arena), + "1".toJString()..releasedBy(arena): "One".toJString()..releasedBy(arena), + "2".toJString()..releasedBy(arena): "Two".toJString()..releasedBy(arena), + "3".toJString()..releasedBy(arena): "Three".toJString() + ..releasedBy(arena), }.toJMap(JString.type, JString.type) - ..deletedIn(arena); + ..releasedBy(arena); } testRunner('length', () { @@ -39,12 +40,12 @@ void run({required TestRunnerCallback testRunner}) { // ignore: collection_methods_unrelated_type expect(map[1], null); expect( - map["1".toJString()..deletedIn(arena)] - ?.toDartString(deleteOriginal: true), + map["1".toJString()..releasedBy(arena)] + ?.toDartString(releaseOriginal: true), "One", ); expect( - map["4".toJString()..deletedIn(arena)], + map["4".toJString()..releasedBy(arena)], null, ); }); @@ -52,19 +53,19 @@ void run({required TestRunnerCallback testRunner}) { testRunner('[]=', () { using((arena) { final map = testDataMap(arena); - map["0".toJString()..deletedIn(arena)] = "Zero".toJString() - ..deletedIn(arena); + map["0".toJString()..releasedBy(arena)] = "Zero".toJString() + ..releasedBy(arena); expect( - map["0".toJString()..deletedIn(arena)] - ?.toDartString(deleteOriginal: true), + map["0".toJString()..releasedBy(arena)] + ?.toDartString(releaseOriginal: true), "Zero", ); expect(map.length, 4); - map["1".toJString()..deletedIn(arena)] = "one!".toJString() - ..deletedIn(arena); + map["1".toJString()..releasedBy(arena)] = "one!".toJString() + ..releasedBy(arena); expect( - map["1".toJString()..deletedIn(arena)] - ?.toDartString(deleteOriginal: true), + map["1".toJString()..releasedBy(arena)] + ?.toDartString(releaseOriginal: true), "one!", ); expect(map.length, 4); @@ -74,23 +75,26 @@ void run({required TestRunnerCallback testRunner}) { using((arena) { final map = testDataMap(arena); final toAdd = { - "0".toJString()..deletedIn(arena): "Zero".toJString()..deletedIn(arena), - "1".toJString()..deletedIn(arena): "one!".toJString()..deletedIn(arena), + "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( - map["0".toJString()..deletedIn(arena)] - ?.toDartString(deleteOriginal: true), + map["0".toJString()..releasedBy(arena)] + ?.toDartString(releaseOriginal: true), "Zero", ); expect( - map["1".toJString()..deletedIn(arena)] - ?.toDartString(deleteOriginal: true), + map["1".toJString()..releasedBy(arena)] + ?.toDartString(releaseOriginal: true), "one!", ); map.addAll({ - "4".toJString()..deletedIn(arena): "Four".toJString()..deletedIn(arena) + "4".toJString()..releasedBy(arena): "Four".toJString() + ..releasedBy(arena) }); expect(map.length, 5); }); @@ -110,8 +114,8 @@ void run({required TestRunnerCallback testRunner}) { final map = testDataMap(arena); // ignore: iterable_contains_unrelated_type expect(map.containsKey(1), false); - expect(map.containsKey("1".toJString()..deletedIn(arena)), true); - expect(map.containsKey("4".toJString()..deletedIn(arena)), false); + expect(map.containsKey("1".toJString()..releasedBy(arena)), true); + expect(map.containsKey("4".toJString()..releasedBy(arena)), false); }); }); testRunner('containsValue', () { @@ -119,8 +123,8 @@ void run({required TestRunnerCallback testRunner}) { final map = testDataMap(arena); // ignore: iterable_contains_unrelated_type expect(map.containsValue(1), false); - expect(map.containsValue("One".toJString()..deletedIn(arena)), true); - expect(map.containsValue("Four".toJString()..deletedIn(arena)), false); + expect(map.containsValue("One".toJString()..releasedBy(arena)), true); + expect(map.containsValue("Four".toJString()..releasedBy(arena)), false); }); }); testRunner('keys', () { @@ -129,7 +133,7 @@ void run({required TestRunnerCallback testRunner}) { final keys = map.keys; expect( keys - .map((element) => element.toDartString(deleteOriginal: true)) + .map((element) => element.toDartString(releaseOriginal: true)) .toSet(), {"1", "2", "3"}, ); @@ -140,12 +144,12 @@ void run({required TestRunnerCallback testRunner}) { final map = testDataMap(arena); // ignore: collection_methods_unrelated_type expect(map.remove(1), null); - expect(map.remove("4".toJString()..deletedIn(arena)), null); + expect(map.remove("4".toJString()..releasedBy(arena)), null); expect(map.length, 3); expect( map - .remove("3".toJString()..deletedIn(arena)) - ?.toDartString(deleteOriginal: true), + .remove("3".toJString()..releasedBy(arena)) + ?.toDartString(releaseOriginal: true), "Three", ); expect(map.length, 2); @@ -158,7 +162,7 @@ void run({required TestRunnerCallback testRunner}) { 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)..deletedIn(arena); + 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 8478d5aa1..883913cdd 100644 --- a/pkgs/jni/test/jobject_test.dart +++ b/pkgs/jni/test/jobject_test.dart @@ -48,11 +48,11 @@ void run({required TestRunnerCallback testRunner}) { final intValue = long.callMethodByName("intValue", "()I", []); expect(intValue, equals(176)); - // delete any JObject and JClass instances using .delete() after use. - // Deletion is not strictly required since JNI objects / classes have - // a NativeFinalizer. But deleting them after use is a good practice. - long.delete(); - longClass.delete(); + // Release any JObject and JClass instances using `.release()` after use. + // This is not strictly required since JNI objects / classes have + // a [NativeFinalizer]. But deleting them after use is a good practice. + long.release(); + longClass.release(); }); testRunner("call a static method using JClass APIs", () { @@ -60,16 +60,16 @@ void run({required TestRunnerCallback testRunner}) { final result = integerClass.callStaticMethodByName( "toHexString", "(I)Ljava/lang/String;", [JValueInt(31)]); - // if the object is supposed to be a Java string - // you can call toDartString on it. + // If the object is supposed to be a Java string you can call + // [toDartString] on it. final resultString = result.toDartString(); - // Dart string is a copy, original object can be deleted. - result.delete(); + // Dart string is a copy, original object can be released. + result.release(); expect(resultString, equals("1f")); - // Also don't forget to delete the class - integerClass.delete(); + // Also don't forget to release the class. + integerClass.release(); }); testRunner("Call method with null argument, expect exception", () { @@ -78,7 +78,7 @@ void run({required TestRunnerCallback testRunner}) { () => integerClass.callStaticMethodByName( "parseInt", "(Ljava/lang/String;)I", [nullptr]), throwsException); - integerClass.delete(); + integerClass.release(); }); // Skip this test on Android integration test because it fails there, possibly @@ -89,8 +89,8 @@ void run({required TestRunnerCallback testRunner}) { }); } - /// callMethodByName will be expensive if making same call many times - /// Use getMethodID to get a method ID and use it in subsequent calls + // [callMethodByName] will be expensive if making same call many times. + // Use [getMethodID] to get a method ID and use it in subsequent calls. testRunner("Example for using getMethodID", () { final longClass = Jni.findJClass("java/lang/Long"); final bitCountMethod = longClass.getStaticMethodID("bitCount", "(J)I"); @@ -99,7 +99,7 @@ void run({required TestRunnerCallback testRunner}) { // It finds the class, gets constructor ID and constructs an instance. final random = Jni.newInstance("java/util/Random", "()V", []); - // You don't need a JClass reference to get instance method IDs + // You don't need a [JClass] reference to get instance method IDs. final nextIntMethod = random.getMethodID("nextInt", "(I)I"); for (int i = 0; i < 100; i++) { @@ -112,7 +112,8 @@ void run({required TestRunnerCallback testRunner}) { } expect(jbc, equals(bits)); } - Jni.deleteAll([random, longClass]); + random.release(); + longClass.release(); }); // One-off invocation of static method in single call. @@ -135,19 +136,19 @@ void run({required TestRunnerCallback testRunner}) { expect(maxLong, equals(32767)); }); - // Use callStringMethod if all you care about is a string result + // Use [callStringMethod] if all you care about is a string result testRunner("callStaticStringMethod", () { final longClass = Jni.findJClass("java/lang/Long"); const n = 1223334444; final strFromJava = longClass.callStaticMethodByName( "toOctalString", "(J)Ljava/lang/String;", [n]); expect(strFromJava, equals(n.toRadixString(8))); - longClass.delete(); + longClass.release(); }); - // In JObject, JClass, and retrieve_/invoke_ methods + // In [JObject], [JClass], and retrieve_/invoke_ methods // you can also pass Dart strings, apart from range of types - // allowed by Jni.jvalues + // allowed by [Jni.jvalues]. // They will be converted automatically. testRunner( "Passing strings in arguments", @@ -158,7 +159,7 @@ void run({required TestRunnerCallback testRunner}) { // (\n because test runner prints first char at end of the line) //out.callMethodByName( // "println", "(Ljava/lang/Object;)V", ["\nWorks (Apparently)"]); - out.delete(); + out.release(); }, ); @@ -181,14 +182,14 @@ void run({required TestRunnerCallback testRunner}) { testRunner('Using arena', () { final objects = []; using((arena) { - final r = Jni.findJClass('java/util/Random')..deletedIn(arena); + final r = Jni.findJClass('java/util/Random')..releasedBy(arena); final ctor = r.getCtorID("()V"); for (int i = 0; i < 10; i++) { - objects.add(r.newInstance(ctor, [])..deletedIn(arena)); + objects.add(r.newInstance(ctor, [])..releasedBy(arena)); } }); for (var object in objects) { - expect(object.isDeleted, isTrue); + expect(object.isReleased, isTrue); } }); @@ -202,14 +203,14 @@ void run({required TestRunnerCallback testRunner}) { testRunner("casting", () { using((arena) { - final str = "hello".toJString()..deletedIn(arena); - final obj = str.castTo(JObject.type)..deletedIn(arena); + final str = "hello".toJString()..releasedBy(arena); + final obj = str.castTo(JObject.type)..releasedBy(arena); final backToStr = obj.castTo(JString.type); expect(backToStr.toDartString(), str.toDartString()); - final _ = backToStr.castTo(JObject.type, deleteOriginal: true) - ..deletedIn(arena); - expect(backToStr.toDartString, throwsA(isA())); - expect(backToStr.delete, throwsA(isA())); + final _ = backToStr.castTo(JObject.type, releaseOriginal: true) + ..releasedBy(arena); + expect(backToStr.toDartString, throwsA(isA())); + expect(backToStr.release, throwsA(isA())); }); }); @@ -258,5 +259,5 @@ void doSomeWorkInIsolate(Void? _) { // Expect throws an [OutsideTestException] // but you can uncomment below print and see it works // print("\n$r"); - random.delete(); + random.release(); } diff --git a/pkgs/jni/test/jset_test.dart b/pkgs/jni/test/jset_test.dart index 92aaa0c15..2d93e6334 100644 --- a/pkgs/jni/test/jset_test.dart +++ b/pkgs/jni/test/jset_test.dart @@ -21,11 +21,11 @@ void main() { void run({required TestRunnerCallback testRunner}) { JSet testDataSet(Arena arena) { return { - "1".toJString()..deletedIn(arena), - "2".toJString()..deletedIn(arena), - "3".toJString()..deletedIn(arena), + "1".toJString()..releasedBy(arena), + "2".toJString()..releasedBy(arena), + "3".toJString()..releasedBy(arena), }.toJSet(JString.type) - ..deletedIn(arena); + ..releasedBy(arena); } testRunner('length', () { @@ -37,9 +37,9 @@ void run({required TestRunnerCallback testRunner}) { testRunner('add', () { using((arena) { final set = testDataSet(arena); - set.add("1".toJString()..deletedIn(arena)); + set.add("1".toJString()..releasedBy(arena)); expect(set.length, 3); - set.add("4".toJString()..deletedIn(arena)); + set.add("4".toJString()..releasedBy(arena)); expect(set.length, 4); }); }); @@ -47,12 +47,12 @@ void run({required TestRunnerCallback testRunner}) { using((arena) { final set = testDataSet(arena); final toAdd = testDataSet(arena); - toAdd.add("4".toJString()..deletedIn(arena)); + toAdd.add("4".toJString()..releasedBy(arena)); set.addAll(toAdd); expect(set.length, 4); set.addAll([ - "1".toJString()..deletedIn(arena), - "5".toJString()..deletedIn(arena), + "1".toJString()..releasedBy(arena), + "5".toJString()..releasedBy(arena), ]); expect(set.length, 5); }); @@ -70,8 +70,8 @@ void run({required TestRunnerCallback testRunner}) { final set = testDataSet(arena); // ignore: iterable_contains_unrelated_type expect(set.contains(1), false); - expect(set.contains("1".toJString()..deletedIn(arena)), true); - expect(set.contains("4".toJString()..deletedIn(arena)), false); + expect(set.contains("1".toJString()..releasedBy(arena)), true); + expect(set.contains("4".toJString()..releasedBy(arena)), false); }); }); testRunner('containsAll', () { @@ -80,15 +80,15 @@ void run({required TestRunnerCallback testRunner}) { expect(set.containsAll(set), true); expect( set.containsAll([ - "1".toJString()..deletedIn(arena), - "2".toJString()..deletedIn(arena), + "1".toJString()..releasedBy(arena), + "2".toJString()..releasedBy(arena), ]), true, ); final testSet = testDataSet(arena); - testSet.add("4".toJString()..deletedIn(arena)); + testSet.add("4".toJString()..releasedBy(arena)); expect(set.containsAll(testSet), false); - expect(set.containsAll(["4".toJString()..deletedIn(arena)]), false); + expect(set.containsAll(["4".toJString()..releasedBy(arena)]), false); }); }); testRunner('iterator', () { @@ -98,11 +98,11 @@ void run({required TestRunnerCallback testRunner}) { // There are no order guarantees in a hashset. final dartSet = {}; expect(it.moveNext(), true); - dartSet.add(it.current.toDartString(deleteOriginal: true)); + dartSet.add(it.current.toDartString(releaseOriginal: true)); expect(it.moveNext(), true); - dartSet.add(it.current.toDartString(deleteOriginal: true)); + dartSet.add(it.current.toDartString(releaseOriginal: true)); expect(it.moveNext(), true); - dartSet.add(it.current.toDartString(deleteOriginal: true)); + dartSet.add(it.current.toDartString(releaseOriginal: true)); expect(it.moveNext(), false); // So we just check if the elements have appeared in some order. expect(dartSet, {"1", "2", "3"}); @@ -113,28 +113,28 @@ void run({required TestRunnerCallback testRunner}) { final set = testDataSet(arena); // ignore: collection_methods_unrelated_type expect(set.remove(1), false); - expect(set.remove("4".toJString()..deletedIn(arena)), false); + expect(set.remove("4".toJString()..releasedBy(arena)), false); expect(set.length, 3); - expect(set.remove("3".toJString()..deletedIn(arena)), true); + expect(set.remove("3".toJString()..releasedBy(arena)), true); expect(set.length, 2); }); }); testRunner('removeAll', () { using((arena) { final set = testDataSet(arena); - final toRemoveExclusive = {"4".toJString()..deletedIn(arena)} + final toRemoveExclusive = {"4".toJString()..releasedBy(arena)} .toJSet(JString.type) - ..deletedIn(arena); + ..releasedBy(arena); set.removeAll(toRemoveExclusive); expect(set.length, 3); final toRemoveInclusive = { - "1".toJString()..deletedIn(arena), - "4".toJString()..deletedIn(arena), + "1".toJString()..releasedBy(arena), + "4".toJString()..releasedBy(arena), }.toJSet(JString.type) - ..deletedIn(arena); + ..releasedBy(arena); set.removeAll(toRemoveInclusive); expect(set.length, 2); - set.removeAll(["2".toJString()..deletedIn(arena)]); + set.removeAll(["2".toJString()..releasedBy(arena)]); expect(set.length, 1); }); }); @@ -142,15 +142,15 @@ void run({required TestRunnerCallback testRunner}) { using((arena) { final set = testDataSet(arena); final toRetain = { - "1".toJString()..deletedIn(arena), - "3".toJString()..deletedIn(arena), - "4".toJString()..deletedIn(arena), + "1".toJString()..releasedBy(arena), + "3".toJString()..releasedBy(arena), + "4".toJString()..releasedBy(arena), }; set.retainAll(set); expect(set.length, 3); set.retainAll(toRetain); expect(set.length, 2); - final toRetainJSet = toRetain.toJSet(JString.type)..deletedIn(arena); + final toRetainJSet = toRetain.toJSet(JString.type)..releasedBy(arena); set.retainAll(toRetainJSet); expect(set.length, 2); }); @@ -161,7 +161,7 @@ void run({required TestRunnerCallback testRunner}) { final b = testDataSet(arena); expect(a.hashCode, b.hashCode); expect(a, b); - b.add("4".toJString()..deletedIn(arena)); + b.add("4".toJString()..releasedBy(arena)); expect(a.hashCode, isNot(b.hashCode)); expect(a, isNot(b)); }); @@ -172,19 +172,19 @@ void run({required TestRunnerCallback testRunner}) { // ignore: iterable_contains_unrelated_type expect(set.lookup(1), null); expect( - set.lookup("1".toJString())?.toDartString(deleteOriginal: true), + set.lookup("1".toJString())?.toDartString(releaseOriginal: true), "1", ); - expect(set.lookup("4".toJString()..deletedIn(arena)), null); + expect(set.lookup("4".toJString()..releasedBy(arena)), null); }); }); testRunner('toSet', () { using((arena) { // Test if the set gets copied. final set = testDataSet(arena); - final setCopy = set.toSet()..deletedIn(arena); + final setCopy = set.toSet()..releasedBy(arena); expect(set, setCopy); - set.add("4".toJString()..deletedIn(arena)); + set.add("4".toJString()..releasedBy(arena)); expect(set, isNot(setCopy)); }); }); @@ -194,7 +194,7 @@ void run({required TestRunnerCallback testRunner}) { final b = testDataSet(arena); expect(a.$type, b.$type); expect(a.$type.hashCode, b.$type.hashCode); - final c = JSet.hash(JObject.type)..deletedIn(arena); + 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/jstring_test.dart b/pkgs/jni/test/jstring_test.dart index 210c91d6f..c1a968c46 100644 --- a/pkgs/jni/test/jstring_test.dart +++ b/pkgs/jni/test/jstring_test.dart @@ -20,7 +20,7 @@ void main() { void testStringBackAndForth(String str) { final jstring = str.toJString(); - final dartString = jstring.toDartString(deleteOriginal: true); + final dartString = jstring.toDartString(releaseOriginal: true); expect(dartString, str); } diff --git a/pkgs/jni/test/load_test.dart b/pkgs/jni/test/load_test.dart index 162b3e9ec..d74a5fc5a 100644 --- a/pkgs/jni/test/load_test.dart +++ b/pkgs/jni/test/load_test.dart @@ -64,14 +64,14 @@ void run({required TestRunnerCallback testRunner}) { list.add(newRandom()); } for (final jobject in list) { - jobject.delete(); + jobject.release(); } }); - testRunner('Create and delete 256K references in a loop using arena', () { + testRunner('Create and release 256K references in a loop using arena', () { for (int i = 0; i < k256; i++) { using((arena) { - final random = newRandom()..deletedIn(arena); + final random = newRandom()..releasedBy(arena); // The actual expect here does not matter. I am just being paranoid // against assigning to `_` because compiler may optimize it. (It has // side effect of calling FFI but still.) @@ -80,19 +80,20 @@ void run({required TestRunnerCallback testRunner}) { } }); - testRunner('Create & delete 256K references in a loop (explicit delete)', () { + testRunner('Create and release 256K references in a loop (explicit release)', + () { for (int i = 0; i < k256; i++) { final random = newRandom(); expect(random.reference, isNot(nullptr)); - random.delete(); + random.release(); } }); - testRunner('Create and delete 64K references, in batches of 256', () { + testRunner('Create and release 64K references, in batches of 256', () { for (int i = 0; i < 64 * 4; i++) { using((arena) { for (int i = 0; i < 256; i++) { - final r = newRandom()..deletedIn(arena); + final r = newRandom()..releasedBy(arena); expect(r.reference, isNot(nullptr)); } }); diff --git a/pkgs/jnigen/CHANGELOG.md b/pkgs/jnigen/CHANGELOG.md index 357435d1b..5354fc2e6 100644 --- a/pkgs/jnigen/CHANGELOG.md +++ b/pkgs/jnigen/CHANGELOG.md @@ -1,20 +1,15 @@ -## 0.6.0-wip.3 +## 0.6.0 +* **Breaking Change** ([#131](https://github.com/dart-lang/jnigen/issues/131)): Renamed `delete*` to `release*`. * **Breaking Change** ([#354](https://github.com/dart-lang/jnigen/issues/354)): Renamed constructors from `ctor1`, `ctor2`, ... to `new1`, `new2`, ... - -## 0.6.0-wip.2 +* **Breaking Change**: Specifying a class always pulls in nested classes by default. If a nested class is specified in config, it will be an error. +* **Breaking Change**: Removed `suspend_fun_to_async` flag from the config. It's now happening by default since we read the Kotlin's metadata and reliably identify the `suspend fun`s. * Fixed a bug where the nested classes would be generated incorrectly depending on the backend used for generation. * Fixed a bug where ASM backend would produce the incorrect parent for multi-level nested classes. * Fixed a bug where the backends would produce different descriptors for the same method. * Added `enable_experiment` option to config. * Created an experiment called `interface_implementation` which creates a `.implement` method for interfaces, so you can implement them using Dart. - -## 0.6.0-wip.1 -* **Breaking Change**: Specifying a class always pulls in nested classes by default. If a nested class is specified in config, it will be an error. * Save all `jnigen` logs to a file in `.dart_tool/jnigen/logs/`. This is useful for debugging. -## 0.6.0-wip.0 -* **Breaking Change** Removed `suspend_fun_to_async` flag from the config. It's now happening by default since we read the Kotlin's metadata and reliably identify the `suspend fun`s. - ## 0.5.0 * **Breaking Change** ([#72](https://github.com/dart-lang/jnigen/issues/72)): Removed support for `importMap` in favor of the newly added interop mechanism with importing yaml files. * **Breaking Change** ([#72](https://github.com/dart-lang/jnigen/issues/72)): `java.util.Set`, `java.util.Map`, `java.util.List`, `java.util.Iterator` and the boxed types like `java.lang.Integer`, `java.lang.Double`, ... will be generated as their corresponding classes in `package:jni`. diff --git a/pkgs/jnigen/README.md b/pkgs/jnigen/README.md index d524e0e8a..c5850b587 100644 --- a/pkgs/jnigen/README.md +++ b/pkgs/jnigen/README.md @@ -191,10 +191,10 @@ If the errors are similar to `symbol not found`, ensure all dependencies of the #### How are classes mapped into bindings? Each Java class generates a subclass of `JObject` class, which wraps a `jobject` reference in JNI. Nested classes use `_` as separator, `Example.NestedClass` will be mapped to `Example_NestedClass`. -#### Does `JObject` hold a local or global reference? Does it need to be manually deleted? +#### Does `JObject` hold a local or global reference? Does it need to be manually released? Each Java object returned into Dart creates a JNI global reference. Reference deletion is taken care of by `NativeFinalizer` and that's usually sufficient. -It's a good practice to keep the interface between languages sparse. However, if there's a need to create several references (Eg: in a loop), you can use FFI Arena mechanism (`using` function) and `deletedIn` method, or manually delete the object using `delete` method. +It's a good practice to keep the interface between languages sparse. However, if there's a need to create several references (Eg: in a loop), you can use FFI Arena mechanism (`using` function) and `releasedBy` method, or manually release the object using `release` method. #### Should I use `jnigen` over Method channels? This is currently an experimental package. Many features are missing, and it's rough around the edges. You're welcome to try it and give feedback. diff --git a/pkgs/jnigen/example/in_app_java/lib/android_utils.dart b/pkgs/jnigen/example/in_app_java/lib/android_utils.dart index 024059de2..620adec8b 100644 --- a/pkgs/jnigen/example/in_app_java/lib/android_utils.dart +++ b/pkgs/jnigen/example/in_app_java/lib/android_utils.dart @@ -329,7 +329,7 @@ class EmojiCompat extends jni.JObject { .asFunction)>(); /// from: static public androidx.emoji2.text.EmojiCompat init(android.content.Context context) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Initialize the singleton instance with the default system-provided configuration. /// @@ -361,7 +361,7 @@ class EmojiCompat extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: static public androidx.emoji2.text.EmojiCompat init(android.content.Context context, androidx.emoji2.text.DefaultEmojiCompatConfig.DefaultEmojiCompatConfigFactory defaultFactory) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// @hide static EmojiCompat init1( @@ -379,7 +379,7 @@ class EmojiCompat extends jni.JObject { .asFunction)>(); /// from: static public androidx.emoji2.text.EmojiCompat init(androidx.emoji2.text.EmojiCompat.Config config) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Initialize the singleton instance with a configuration. When used on devices running API 18 /// or below, the singleton instance is immediately moved into \#LOAD_STATE_SUCCEEDED @@ -420,7 +420,7 @@ class EmojiCompat extends jni.JObject { .asFunction)>(); /// from: static public androidx.emoji2.text.EmojiCompat reset(androidx.emoji2.text.EmojiCompat.Config config) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Used by the tests to reset EmojiCompat with a new configuration. Every time it is called a /// new instance is created with the new configuration. @@ -438,7 +438,7 @@ class EmojiCompat extends jni.JObject { .asFunction)>(); /// from: static public androidx.emoji2.text.EmojiCompat reset(androidx.emoji2.text.EmojiCompat emojiCompat) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Used by the tests to reset EmojiCompat with a new singleton instance. ///@hide @@ -469,7 +469,7 @@ class EmojiCompat extends jni.JObject { .asFunction(); /// from: static public androidx.emoji2.text.EmojiCompat get() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Return singleton EmojiCompat instance. Should be called after /// \#init(EmojiCompat.Config) is called to initialize the singleton instance. @@ -805,7 +805,7 @@ class EmojiCompat extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public java.lang.CharSequence process(java.lang.CharSequence charSequence) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Checks a given CharSequence for emojis, and adds EmojiSpans if any emojis are found. When /// used on devices running API 18 or below, returns the given {@code charSequence} without @@ -832,7 +832,7 @@ class EmojiCompat extends jni.JObject { ffi.Pointer, ffi.Pointer, int, int)>(); /// from: public java.lang.CharSequence process(java.lang.CharSequence charSequence, int start, int end) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Checks a given CharSequence for emojis, and adds EmojiSpans if any emojis are found. /// @@ -879,7 +879,7 @@ class EmojiCompat extends jni.JObject { ffi.Pointer, ffi.Pointer, int, int, int)>(); /// from: public java.lang.CharSequence process(java.lang.CharSequence charSequence, int start, int end, int maxEmojiCount) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Checks a given CharSequence for emojis, and adds EmojiSpans if any emojis are found. /// @@ -932,7 +932,7 @@ class EmojiCompat extends jni.JObject { int, int, int, int)>(); /// from: public java.lang.CharSequence process(java.lang.CharSequence charSequence, int start, int end, int maxEmojiCount, int replaceStrategy) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Checks a given CharSequence for emojis, and adds EmojiSpans if any emojis are found. /// @@ -983,7 +983,7 @@ class EmojiCompat extends jni.JObject { .asFunction)>(); /// from: public java.lang.String getAssetSignature() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Returns signature for the currently loaded emoji assets. The signature is a SHA that is /// constructed using emoji assets. Can be used to detect if currently loaded asset is different @@ -1072,7 +1072,7 @@ class EmojiCompat_Config extends jni.JObject { .asFunction)>(); /// from: protected void (androidx.emoji2.text.EmojiCompat.MetadataRepoLoader metadataLoader) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Default constructor. ///@param metadataLoader MetadataRepoLoader instance, cannot be {@code null} @@ -1092,7 +1092,7 @@ class EmojiCompat_Config extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public androidx.emoji2.text.EmojiCompat.Config registerInitCallback(androidx.emoji2.text.EmojiCompat.InitCallback initCallback) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Registers an initialization callback. ///@param initCallback the initialization callback to register, cannot be {@code null} @@ -1114,7 +1114,7 @@ class EmojiCompat_Config extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public androidx.emoji2.text.EmojiCompat.Config unregisterInitCallback(androidx.emoji2.text.EmojiCompat.InitCallback initCallback) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Unregisters a callback that was added before. ///@param initCallback the initialization callback to be removed, cannot be {@code null} @@ -1133,7 +1133,7 @@ class EmojiCompat_Config extends jni.JObject { .asFunction, int)>(); /// from: public androidx.emoji2.text.EmojiCompat.Config setReplaceAll(boolean replaceAll) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Determines whether EmojiCompat should replace all the emojis it finds with the /// EmojiSpans. By default EmojiCompat tries its best to understand if the system already @@ -1154,7 +1154,7 @@ class EmojiCompat_Config extends jni.JObject { .asFunction, int)>(); /// from: public androidx.emoji2.text.EmojiCompat.Config setUseEmojiAsDefaultStyle(boolean useEmojiAsDefaultStyle) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Determines whether EmojiCompat should use the emoji presentation style for emojis /// that have text style as default. By default, the text style would be used, unless these @@ -1186,7 +1186,7 @@ class EmojiCompat_Config extends jni.JObject { ffi.Pointer, int, ffi.Pointer)>(); /// from: public androidx.emoji2.text.EmojiCompat.Config setUseEmojiAsDefaultStyle(boolean useEmojiAsDefaultStyle, java.util.List emojiAsDefaultStyleExceptions) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// @see \#setUseEmojiAsDefaultStyle(boolean) ///@param emojiAsDefaultStyleExceptions Contains the exception emojis which will be still @@ -1218,7 +1218,7 @@ class EmojiCompat_Config extends jni.JObject { .asFunction, int)>(); /// from: public androidx.emoji2.text.EmojiCompat.Config setEmojiSpanIndicatorEnabled(boolean emojiSpanIndicatorEnabled) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Determines whether a background will be drawn for the emojis that are found and /// replaced by EmojiCompat. Should be used only for debugging purposes. The indicator color @@ -1241,7 +1241,7 @@ class EmojiCompat_Config extends jni.JObject { .asFunction, int)>(); /// from: public androidx.emoji2.text.EmojiCompat.Config setEmojiSpanIndicatorColor(int color) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Sets the color used as emoji span indicator. The default value is /// Color\#GREEN Color.GREEN. @@ -1260,7 +1260,7 @@ class EmojiCompat_Config extends jni.JObject { .asFunction, int)>(); /// from: public androidx.emoji2.text.EmojiCompat.Config setMetadataLoadStrategy(int strategy) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Determines the strategy to start loading the metadata. By default EmojiCompat /// will start loading the metadata during EmojiCompat\#init(Config). When set to @@ -1310,7 +1310,7 @@ class EmojiCompat_Config extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public androidx.emoji2.text.EmojiCompat.Config setSpanFactory(androidx.emoji2.text.EmojiCompat.SpanFactory factory) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Set the span factory used to actually draw emoji replacements. ///@param factory custum span factory that can draw the emoji replacements @@ -1332,7 +1332,7 @@ class EmojiCompat_Config extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public androidx.emoji2.text.EmojiCompat.Config setGlyphChecker(androidx.emoji2.text.EmojiCompat.GlyphChecker glyphChecker) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// The interface that is used by EmojiCompat in order to check if a given emoji can be /// rendered by the system. @@ -1351,7 +1351,7 @@ class EmojiCompat_Config extends jni.JObject { .asFunction)>(); /// from: protected final androidx.emoji2.text.EmojiCompat.MetadataRepoLoader getMetadataRepoLoader() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Returns the MetadataRepoLoader. EmojiCompat_MetadataRepoLoader getMetadataRepoLoader() { @@ -1405,7 +1405,7 @@ class EmojiCompat_MetadataRepoLoaderCallback extends jni.JObject { .asFunction(); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory EmojiCompat_MetadataRepoLoaderCallback() { return EmojiCompat_MetadataRepoLoaderCallback.fromRef(_new0().object); } @@ -1658,7 +1658,7 @@ class EmojiCompat_InitCallback extends jni.JObject { .asFunction(); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory EmojiCompat_InitCallback() { return EmojiCompat_InitCallback.fromRef(_new0().object); } @@ -1741,7 +1741,7 @@ class EmojiCompat_DefaultSpanFactory extends jni.JObject { .asFunction(); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory EmojiCompat_DefaultSpanFactory() { return EmojiCompat_DefaultSpanFactory.fromRef(_new0().object); } @@ -1756,7 +1756,7 @@ class EmojiCompat_DefaultSpanFactory extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public androidx.emoji2.text.EmojiSpan createSpan(androidx.emoji2.text.TypefaceEmojiRasterizer rasterizer) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Returns a TypefaceEmojiSpan. ///@param rasterizer TypefaceEmojiRasterizer instance, which can draw the emoji onto a @@ -1826,7 +1826,7 @@ class EmojiCompat_SpanFactory extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public abstract androidx.emoji2.text.EmojiSpan createSpan(androidx.emoji2.text.TypefaceEmojiRasterizer rasterizer) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Create EmojiSpan instance. ///@param rasterizer TypefaceEmojiRasterizer instance, which can draw the emoji onto a @@ -1920,7 +1920,7 @@ class DefaultEmojiCompatConfig extends jni.JObject { .asFunction)>(); /// from: static public androidx.emoji2.text.FontRequestEmojiCompatConfig create(android.content.Context context) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Get the default emoji compat config for this device. /// @@ -1988,7 +1988,7 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28 .asFunction(); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28() { return DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28 .fromRef(_new0().object); @@ -2004,7 +2004,7 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28 ffi.Pointer)>(); /// from: public android.content.pm.Signature[] getSigningSignatures(android.content.pm.PackageManager packageManager, java.lang.String providerPackage) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JArray getSigningSignatures1( jni.JObject packageManager, jni.JString providerPackage, @@ -2075,7 +2075,7 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19 .asFunction(); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19() { return DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19 .fromRef(_new0().object); @@ -2094,7 +2094,7 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19 ffi.Pointer, int)>(); /// from: public java.util.List queryIntentContentProviders(android.content.pm.PackageManager packageManager, android.content.Intent intent, int flags) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JList queryIntentContentProviders( jni.JObject packageManager, jni.JObject intent, @@ -2116,7 +2116,7 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19 ffi.Pointer, ffi.Pointer)>(); /// from: public android.content.pm.ProviderInfo getProviderInfo(android.content.pm.ResolveInfo resolveInfo) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JObject getProviderInfo( jni.JObject resolveInfo, ) { @@ -2184,7 +2184,7 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper .asFunction(); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper() { return DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper.fromRef( _new0().object); @@ -2200,7 +2200,7 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper ffi.Pointer)>(); /// from: public android.content.pm.Signature[] getSigningSignatures(android.content.pm.PackageManager packageManager, java.lang.String providerPackage) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Get the signing signatures for a package in package manager. jni.JArray getSigningSignatures( @@ -2226,7 +2226,7 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper ffi.Pointer, int)>(); /// from: public java.util.List queryIntentContentProviders(android.content.pm.PackageManager packageManager, android.content.Intent intent, int flags) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Get the content provider by intent. jni.JList queryIntentContentProviders( @@ -2250,7 +2250,7 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper ffi.Pointer, ffi.Pointer)>(); /// from: public android.content.pm.ProviderInfo getProviderInfo(android.content.pm.ResolveInfo resolveInfo) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Get a ProviderInfo, if present, from a ResolveInfo ///@param resolveInfo the subject @@ -2320,7 +2320,7 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory .asFunction)>(); /// from: public void (androidx.emoji2.text.DefaultEmojiCompatConfig.DefaultEmojiCompatConfigHelper helper) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// @hide factory DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory( @@ -2340,7 +2340,7 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory ffi.Pointer, ffi.Pointer)>(); /// from: public androidx.emoji2.text.EmojiCompat.Config create(android.content.Context context) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// @see DefaultEmojiCompatConfig\#create ///@hide @@ -2405,7 +2405,7 @@ class Build_Partition extends jni.JObject { .asFunction)>(); /// from: public java.lang.String getName() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JString getName() { return const jni.JStringType().fromRef(_getName(reference).object); } @@ -2417,7 +2417,7 @@ class Build_Partition extends jni.JObject { .asFunction)>(); /// from: public java.lang.String getFingerprint() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JString getFingerprint() { return const jni.JStringType().fromRef(_getFingerprint(reference).object); } @@ -2502,7 +2502,7 @@ class Build_VERSION extends jni.JObject { .asFunction(); /// from: static public final java.lang.String BASE_OS - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString get BASE_OS => const jni.JStringType().fromRef(_get_BASE_OS().object); @@ -2512,7 +2512,7 @@ class Build_VERSION extends jni.JObject { .asFunction(); /// from: static public final java.lang.String CODENAME - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString get CODENAME => const jni.JStringType().fromRef(_get_CODENAME().object); @@ -2522,7 +2522,7 @@ class Build_VERSION extends jni.JObject { .asFunction(); /// from: static public final java.lang.String INCREMENTAL - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString get INCREMENTAL => const jni.JStringType().fromRef(_get_INCREMENTAL().object); @@ -2549,7 +2549,7 @@ class Build_VERSION extends jni.JObject { .asFunction(); /// from: static public final java.lang.String RELEASE - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString get RELEASE => const jni.JStringType().fromRef(_get_RELEASE().object); @@ -2559,7 +2559,7 @@ class Build_VERSION extends jni.JObject { .asFunction(); /// from: static public final java.lang.String RELEASE_OR_CODENAME - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString get RELEASE_OR_CODENAME => const jni.JStringType().fromRef(_get_RELEASE_OR_CODENAME().object); @@ -2569,7 +2569,7 @@ class Build_VERSION extends jni.JObject { .asFunction(); /// from: static public final java.lang.String RELEASE_OR_PREVIEW_DISPLAY - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString get RELEASE_OR_PREVIEW_DISPLAY => const jni.JStringType().fromRef(_get_RELEASE_OR_PREVIEW_DISPLAY().object); @@ -2579,7 +2579,7 @@ class Build_VERSION extends jni.JObject { .asFunction(); /// from: static public final java.lang.String SDK - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString get SDK => const jni.JStringType().fromRef(_get_SDK().object); @@ -2597,7 +2597,7 @@ class Build_VERSION extends jni.JObject { .asFunction(); /// from: static public final java.lang.String SECURITY_PATCH - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString get SECURITY_PATCH => const jni.JStringType().fromRef(_get_SECURITY_PATCH().object); @@ -2606,7 +2606,7 @@ class Build_VERSION extends jni.JObject { .asFunction(); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory Build_VERSION() { return Build_VERSION.fromRef(_new0().object); } @@ -2756,7 +2756,7 @@ class Build_VERSION_CODES extends jni.JObject { .asFunction(); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory Build_VERSION_CODES() { return Build_VERSION_CODES.fromRef(_new0().object); } @@ -2805,7 +2805,7 @@ class Build extends jni.JObject { .asFunction(); /// from: static public final java.lang.String BOARD - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString get BOARD => const jni.JStringType().fromRef(_get_BOARD().object); @@ -2815,7 +2815,7 @@ class Build extends jni.JObject { .asFunction(); /// from: static public final java.lang.String BOOTLOADER - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString get BOOTLOADER => const jni.JStringType().fromRef(_get_BOOTLOADER().object); @@ -2825,7 +2825,7 @@ class Build extends jni.JObject { .asFunction(); /// from: static public final java.lang.String BRAND - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString get BRAND => const jni.JStringType().fromRef(_get_BRAND().object); @@ -2835,7 +2835,7 @@ class Build extends jni.JObject { .asFunction(); /// from: static public final java.lang.String CPU_ABI - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString get CPU_ABI => const jni.JStringType().fromRef(_get_CPU_ABI().object); @@ -2845,7 +2845,7 @@ class Build extends jni.JObject { .asFunction(); /// from: static public final java.lang.String CPU_ABI2 - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString get CPU_ABI2 => const jni.JStringType().fromRef(_get_CPU_ABI2().object); @@ -2855,7 +2855,7 @@ class Build extends jni.JObject { .asFunction(); /// from: static public final java.lang.String DEVICE - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString get DEVICE => const jni.JStringType().fromRef(_get_DEVICE().object); @@ -2865,7 +2865,7 @@ class Build extends jni.JObject { .asFunction(); /// from: static public final java.lang.String DISPLAY - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString get DISPLAY => const jni.JStringType().fromRef(_get_DISPLAY().object); @@ -2875,7 +2875,7 @@ class Build extends jni.JObject { .asFunction(); /// from: static public final java.lang.String FINGERPRINT - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString get FINGERPRINT => const jni.JStringType().fromRef(_get_FINGERPRINT().object); @@ -2885,7 +2885,7 @@ class Build extends jni.JObject { .asFunction(); /// from: static public final java.lang.String HARDWARE - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString get HARDWARE => const jni.JStringType().fromRef(_get_HARDWARE().object); @@ -2894,7 +2894,7 @@ class Build extends jni.JObject { .asFunction(); /// from: static public final java.lang.String HOST - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString get HOST => const jni.JStringType().fromRef(_get_HOST().object); @@ -2903,7 +2903,7 @@ class Build extends jni.JObject { .asFunction(); /// from: static public final java.lang.String ID - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString get ID => const jni.JStringType().fromRef(_get_ID().object); @@ -2913,7 +2913,7 @@ class Build extends jni.JObject { .asFunction(); /// from: static public final java.lang.String MANUFACTURER - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString get MANUFACTURER => const jni.JStringType().fromRef(_get_MANUFACTURER().object); @@ -2923,7 +2923,7 @@ class Build extends jni.JObject { .asFunction(); /// from: static public final java.lang.String MODEL - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString get MODEL => const jni.JStringType().fromRef(_get_MODEL().object); @@ -2933,7 +2933,7 @@ class Build extends jni.JObject { .asFunction(); /// from: static public final java.lang.String ODM_SKU - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString get ODM_SKU => const jni.JStringType().fromRef(_get_ODM_SKU().object); @@ -2943,7 +2943,7 @@ class Build extends jni.JObject { .asFunction(); /// from: static public final java.lang.String PRODUCT - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString get PRODUCT => const jni.JStringType().fromRef(_get_PRODUCT().object); @@ -2953,7 +2953,7 @@ class Build extends jni.JObject { .asFunction(); /// from: static public final java.lang.String RADIO - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString get RADIO => const jni.JStringType().fromRef(_get_RADIO().object); @@ -2963,7 +2963,7 @@ class Build extends jni.JObject { .asFunction(); /// from: static public final java.lang.String SERIAL - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString get SERIAL => const jni.JStringType().fromRef(_get_SERIAL().object); @@ -2972,7 +2972,7 @@ class Build extends jni.JObject { .asFunction(); /// from: static public final java.lang.String SKU - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString get SKU => const jni.JStringType().fromRef(_get_SKU().object); @@ -2982,7 +2982,7 @@ class Build extends jni.JObject { .asFunction(); /// from: static public final java.lang.String SOC_MANUFACTURER - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString get SOC_MANUFACTURER => const jni.JStringType().fromRef(_get_SOC_MANUFACTURER().object); @@ -2992,7 +2992,7 @@ class Build extends jni.JObject { .asFunction(); /// from: static public final java.lang.String SOC_MODEL - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString get SOC_MODEL => const jni.JStringType().fromRef(_get_SOC_MODEL().object); @@ -3002,7 +3002,7 @@ class Build extends jni.JObject { .asFunction(); /// from: static public final java.lang.String[] SUPPORTED_32_BIT_ABIS - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JArray get SUPPORTED_32_BIT_ABIS => const jni.JArrayType(jni.JStringType()) .fromRef(_get_SUPPORTED_32_BIT_ABIS().object); @@ -3013,7 +3013,7 @@ class Build extends jni.JObject { .asFunction(); /// from: static public final java.lang.String[] SUPPORTED_64_BIT_ABIS - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JArray get SUPPORTED_64_BIT_ABIS => const jni.JArrayType(jni.JStringType()) .fromRef(_get_SUPPORTED_64_BIT_ABIS().object); @@ -3024,7 +3024,7 @@ class Build extends jni.JObject { .asFunction(); /// from: static public final java.lang.String[] SUPPORTED_ABIS - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JArray get SUPPORTED_ABIS => const jni.JArrayType(jni.JStringType()) .fromRef(_get_SUPPORTED_ABIS().object); @@ -3034,7 +3034,7 @@ class Build extends jni.JObject { .asFunction(); /// from: static public final java.lang.String TAGS - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString get TAGS => const jni.JStringType().fromRef(_get_TAGS().object); @@ -3050,7 +3050,7 @@ class Build extends jni.JObject { .asFunction(); /// from: static public final java.lang.String TYPE - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString get TYPE => const jni.JStringType().fromRef(_get_TYPE().object); @@ -3062,7 +3062,7 @@ class Build extends jni.JObject { .asFunction(); /// from: static public final java.lang.String USER - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString get USER => const jni.JStringType().fromRef(_get_USER().object); @@ -3071,7 +3071,7 @@ class Build extends jni.JObject { .asFunction(); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory Build() { return Build.fromRef(_new0().object); } @@ -3082,7 +3082,7 @@ class Build extends jni.JObject { .asFunction(); /// from: static public java.lang.String getSerial() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString getSerial() { return const jni.JStringType().fromRef(_getSerial().object); } @@ -3093,7 +3093,7 @@ class Build extends jni.JObject { .asFunction(); /// from: static public java.util.List getFingerprintedPartitions() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JList getFingerprintedPartitions() { return const jni.JListType($Build_PartitionType()) .fromRef(_getFingerprintedPartitions().object); @@ -3105,7 +3105,7 @@ class Build extends jni.JObject { .asFunction(); /// from: static public java.lang.String getRadioVersion() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString getRadioVersion() { return const jni.JStringType().fromRef(_getRadioVersion().object); } @@ -3168,7 +3168,7 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> .asFunction(); /// from: public void (int i, float f) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory HashMap( int i, double f, { @@ -3184,7 +3184,7 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> .asFunction(); /// from: public void (int i) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory HashMap.new1( int i, { required jni.JObjType<$K> K, @@ -3198,7 +3198,7 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> .asFunction(); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory HashMap.new2({ required jni.JObjType<$K> K, required jni.JObjType<$V> V, @@ -3213,7 +3213,7 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> .asFunction)>(); /// from: public void (java.util.Map map) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory HashMap.new3( jni.JMap<$K, $V> map, { jni.JObjType<$K>? K, @@ -3259,7 +3259,7 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> ffi.Pointer, ffi.Pointer)>(); /// from: public V get(java.lang.Object object) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $V get0( jni.JObject object, ) { @@ -3292,7 +3292,7 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> ffi.Pointer)>(); /// from: public V put(K object, V object1) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $V put( $K object, $V object1, @@ -3325,7 +3325,7 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> ffi.Pointer, ffi.Pointer)>(); /// from: public V remove(java.lang.Object object) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $V remove( jni.JObject object, ) { @@ -3365,7 +3365,7 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> .asFunction)>(); /// from: public java.util.Set keySet() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JSet<$K> keySet() { return jni.JSetType(K).fromRef(_keySet(reference).object); } @@ -3377,7 +3377,7 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> .asFunction)>(); /// from: public java.util.Collection values() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JObject values() { return const jni.JObjectType().fromRef(_values(reference).object); } @@ -3389,7 +3389,7 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> .asFunction)>(); /// from: public java.util.Set entrySet() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JSet entrySet() { return const jni.JSetType(jni.JObjectType()) .fromRef(_entrySet(reference).object); @@ -3406,7 +3406,7 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> ffi.Pointer)>(); /// from: public V getOrDefault(java.lang.Object object, V object1) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $V getOrDefault( jni.JObject object, $V object1, @@ -3426,7 +3426,7 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> ffi.Pointer)>(); /// from: public V putIfAbsent(K object, V object1) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $V putIfAbsent( $K object, $V object1, @@ -3486,7 +3486,7 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> ffi.Pointer)>(); /// from: public V replace(K object, V object1) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $V replace1( $K object, $V object1, @@ -3506,7 +3506,7 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> ffi.Pointer)>(); /// from: public V computeIfAbsent(K object, java.util.function.Function function) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $V computeIfAbsent( $K object, jni.JObject function, @@ -3527,7 +3527,7 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> ffi.Pointer)>(); /// from: public V computeIfPresent(K object, java.util.function.BiFunction biFunction) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $V computeIfPresent( $K object, jni.JObject biFunction, @@ -3548,7 +3548,7 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> ffi.Pointer)>(); /// from: public V compute(K object, java.util.function.BiFunction biFunction) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $V compute( $K object, jni.JObject biFunction, @@ -3569,7 +3569,7 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> ffi.Pointer, ffi.Pointer)>(); /// from: public V merge(K object, V object1, java.util.function.BiFunction biFunction) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $V merge( $K object, $V object1, @@ -3617,7 +3617,7 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> .asFunction)>(); /// from: public java.lang.Object clone() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JObject clone() { return const jni.JObjectType().fromRef(_clone(reference).object); } diff --git a/pkgs/jnigen/example/kotlin_plugin/example/lib/main.dart b/pkgs/jnigen/example/kotlin_plugin/example/lib/main.dart index df87f6e7a..50d14348b 100644 --- a/pkgs/jnigen/example/kotlin_plugin/example/lib/main.dart +++ b/pkgs/jnigen/example/kotlin_plugin/example/lib/main.dart @@ -44,7 +44,7 @@ class _MyHomePageState extends State { @override void dispose() { - example.delete(); + example.release(); super.dispose(); } @@ -65,7 +65,7 @@ class _MyHomePageState extends State { onPressed: () { setState(() { answer = example.thinkBeforeAnswering().then( - (value) => value.toDartString(deleteOriginal: true)); + (value) => value.toDartString(releaseOriginal: true)); }); }, child: const Text('Think...'), diff --git a/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart b/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart index 75da7fe69..b7120d25a 100644 --- a/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart +++ b/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart @@ -41,7 +41,7 @@ class Example extends jni.JObject { .asFunction(); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory Example() { return Example.fromRef(_new0().object); } @@ -55,7 +55,7 @@ class Example extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public final java.lang.Object thinkBeforeAnswering(kotlin.coroutines.Continuation continuation) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. Future thinkBeforeAnswering() async { final $p = ReceivePort(); final $c = diff --git a/pkgs/jnigen/example/notification_plugin/example/lib/main.dart b/pkgs/jnigen/example/notification_plugin/example/lib/main.dart index 04fb2dc77..c834bcbf2 100644 --- a/pkgs/jnigen/example/notification_plugin/example/lib/main.dart +++ b/pkgs/jnigen/example/notification_plugin/example/lib/main.dart @@ -19,8 +19,8 @@ void showNotification(String title, String text) { var jTitle = JString.fromString(title); var jText = JString.fromString(text); Notifications.showNotification(activity, i, jTitle, jText); - jTitle.delete(); - jText.delete(); + jTitle.release(); + jText.release(); } void main() { diff --git a/pkgs/jnigen/example/notification_plugin/lib/notifications.dart b/pkgs/jnigen/example/notification_plugin/lib/notifications.dart index 267d2d363..30664d566 100644 --- a/pkgs/jnigen/example/notification_plugin/lib/notifications.dart +++ b/pkgs/jnigen/example/notification_plugin/lib/notifications.dart @@ -45,7 +45,7 @@ class Notifications extends jni.JObject { .asFunction(); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory Notifications() { return Notifications.fromRef(_new0().object); } diff --git a/pkgs/jnigen/example/pdfbox_plugin/example/lib/main.dart b/pkgs/jnigen/example/pdfbox_plugin/example/lib/main.dart index 0e74306fa..ccc656335 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/example/lib/main.dart +++ b/pkgs/jnigen/example/pdfbox_plugin/example/lib/main.dart @@ -161,7 +161,7 @@ class PDFFileInfo { if (jstr.reference == nullptr) { return '(null)'; } - return jstr.toDartString(deleteOriginal: true); + return jstr.toDartString(releaseOriginal: true); } PDFFileInfo.usingPDFBox(this.filename) { 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 6c103dcdf..59438087f 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 @@ -61,7 +61,7 @@ class PDDocument extends jni.JObject { .asFunction(); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Creates an empty PDF document. /// You need to add at least one page for the document to be valid. @@ -76,7 +76,7 @@ class PDDocument extends jni.JObject { .asFunction)>(); /// from: public void (org.apache.pdfbox.io.MemoryUsageSetting memUsageSetting) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Creates an empty PDF document. /// You need to add at least one page for the document to be valid. @@ -94,7 +94,7 @@ class PDDocument extends jni.JObject { .asFunction)>(); /// from: public void (org.apache.pdfbox.cos.COSDocument doc) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Constructor that uses an existing document. The COSDocument that is passed in must be valid. ///@param doc The COSDocument that this document wraps. @@ -113,7 +113,7 @@ class PDDocument extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public void (org.apache.pdfbox.cos.COSDocument doc, org.apache.pdfbox.io.RandomAccessRead source) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Constructor that uses an existing document. The COSDocument that is passed in must be valid. ///@param doc The COSDocument that this document wraps. @@ -136,7 +136,7 @@ class PDDocument extends jni.JObject { ffi.Pointer)>(); /// from: public void (org.apache.pdfbox.cos.COSDocument doc, org.apache.pdfbox.io.RandomAccessRead source, org.apache.pdfbox.pdmodel.encryption.AccessPermission permission) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Constructor that uses an existing document. The COSDocument that is passed in must be valid. ///@param doc The COSDocument that this document wraps. @@ -368,7 +368,7 @@ class PDDocument extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public org.apache.pdfbox.pdmodel.PDPage importPage(org.apache.pdfbox.pdmodel.PDPage page) - /// The returned object must be deleted after use, by calling the `delete` method. + /// 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 @@ -405,7 +405,7 @@ class PDDocument extends jni.JObject { .asFunction)>(); /// from: public org.apache.pdfbox.cos.COSDocument getDocument() - /// The returned object must be deleted after use, by calling the `delete` method. + /// 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. @@ -420,7 +420,7 @@ class PDDocument extends jni.JObject { .asFunction)>(); /// from: public org.apache.pdfbox.pdmodel.PDDocumentInformation getDocumentInformation() - /// The returned object must be deleted after use, by calling the `delete` method. + /// 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. @@ -463,7 +463,7 @@ class PDDocument extends jni.JObject { .asFunction)>(); /// from: public org.apache.pdfbox.pdmodel.PDDocumentCatalog getDocumentCatalog() - /// The returned object must be deleted after use, by calling the `delete` method. + /// 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 @@ -493,7 +493,7 @@ class PDDocument extends jni.JObject { .asFunction)>(); /// from: public org.apache.pdfbox.pdmodel.encryption.PDEncryption getEncryption() - /// The returned object must be deleted after use, by calling the `delete` method. + /// 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, @@ -531,7 +531,7 @@ class PDDocument extends jni.JObject { .asFunction)>(); /// from: public org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature getLastSignatureDictionary() - /// The returned object must be deleted after use, by calling the `delete` method. + /// 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. @@ -549,7 +549,7 @@ class PDDocument extends jni.JObject { .asFunction)>(); /// from: public java.util.List getSignatureFields() - /// The returned object must be deleted after use, by calling the `delete` method. + /// 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 @@ -566,7 +566,7 @@ class PDDocument extends jni.JObject { .asFunction)>(); /// from: public java.util.List getSignatureDictionaries() - /// The returned object must be deleted after use, by calling the `delete` method. + /// 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 @@ -604,7 +604,7 @@ class PDDocument extends jni.JObject { .asFunction)>(); /// from: static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.File file) - /// The returned object must be deleted after use, by calling the `delete` method. + /// 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 @@ -626,7 +626,7 @@ class PDDocument extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.File file, org.apache.pdfbox.io.MemoryUsageSetting memUsageSetting) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Parses a PDF. ///@param file file to be loaded @@ -651,7 +651,7 @@ class PDDocument extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.File file, java.lang.String password) - /// The returned object must be deleted after use, by calling the `delete` method. + /// 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 @@ -678,7 +678,7 @@ class PDDocument extends jni.JObject { ffi.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 deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Parses a PDF. ///@param file file to be loaded @@ -709,7 +709,7 @@ class PDDocument extends jni.JObject { ffi.Pointer, ffi.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 deleted after use, by calling the `delete` method. + /// 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 @@ -746,7 +746,7 @@ class PDDocument extends jni.JObject { ffi.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 deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Parses a PDF. ///@param file file to be loaded @@ -779,7 +779,7 @@ class PDDocument extends jni.JObject { .asFunction)>(); /// from: static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.InputStream input) - /// The returned object must be deleted after use, by calling the `delete` method. + /// 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. @@ -802,7 +802,7 @@ class PDDocument extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.InputStream input, org.apache.pdfbox.io.MemoryUsageSetting memUsageSetting) - /// The returned object must be deleted after use, by calling the `delete` method. + /// 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. @@ -828,7 +828,7 @@ class PDDocument extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.InputStream input, java.lang.String password) - /// The returned object must be deleted after use, by calling the `delete` method. + /// 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. @@ -857,7 +857,7 @@ class PDDocument extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// 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 deleted after use, by calling the `delete` method. + /// 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. @@ -889,7 +889,7 @@ class PDDocument extends jni.JObject { ffi.Pointer)>(); /// 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 deleted after use, by calling the `delete` method. + /// 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. @@ -926,7 +926,7 @@ class PDDocument extends jni.JObject { ffi.Pointer)>(); /// 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 deleted after use, by calling the `delete` method. + /// 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. @@ -961,7 +961,7 @@ class PDDocument extends jni.JObject { .asFunction)>(); /// from: static public org.apache.pdfbox.pdmodel.PDDocument load(byte[] input) - /// The returned object must be deleted after use, by calling the `delete` method. + /// 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. @@ -983,7 +983,7 @@ class PDDocument extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: static public org.apache.pdfbox.pdmodel.PDDocument load(byte[] input, java.lang.String password) - /// The returned object must be deleted after use, by calling the `delete` method. + /// 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. @@ -1011,7 +1011,7 @@ class PDDocument extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// 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 deleted after use, by calling the `delete` method. + /// 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. @@ -1049,7 +1049,7 @@ class PDDocument extends jni.JObject { ffi.Pointer)>(); /// 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 deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Parses a PDF. ///@param input byte array that contains the document. @@ -1224,7 +1224,7 @@ class PDDocument extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public org.apache.pdfbox.pdmodel.interactive.digitalsignature.ExternalSigningSupport saveIncrementalForExternalSigning(java.io.OutputStream output) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// /// __(This is a new feature for 2.0.3. The API for external signing might change based on feedback after release!)__ @@ -1277,7 +1277,7 @@ class PDDocument extends jni.JObject { .asFunction, int)>(); /// from: public org.apache.pdfbox.pdmodel.PDPage getPage(int pageIndex) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Returns the page at the given 0-based index. /// @@ -1300,7 +1300,7 @@ class PDDocument extends jni.JObject { .asFunction)>(); /// from: public org.apache.pdfbox.pdmodel.PDPageTree getPages() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Returns the page tree. ///@return the page tree @@ -1369,7 +1369,7 @@ class PDDocument extends jni.JObject { .asFunction)>(); /// from: public org.apache.pdfbox.pdmodel.encryption.AccessPermission getCurrentAccessPermission() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Returns the access permissions granted when the document was decrypted. If the document was not decrypted this /// method returns the access permission for a document owner (ie can do everything). The returned object is in read @@ -1419,7 +1419,7 @@ class PDDocument extends jni.JObject { .asFunction)>(); /// from: public java.lang.Long getDocumentId() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Provides the document ID. ///@return the document ID @@ -1482,7 +1482,7 @@ class PDDocument extends jni.JObject { .asFunction)>(); /// from: public org.apache.pdfbox.pdmodel.ResourceCache getResourceCache() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Returns the resource cache associated with this document, or null if there is none. ///@return the resource cache or null. 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 a12b62aa9..268557214 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 @@ -62,7 +62,7 @@ class PDDocumentInformation extends jni.JObject { .asFunction(); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Default Constructor. factory PDDocumentInformation() { @@ -76,7 +76,7 @@ class PDDocumentInformation extends jni.JObject { .asFunction)>(); /// from: public void (org.apache.pdfbox.cos.COSDictionary dic) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Constructor that is used for a preexisting dictionary. ///@param dic The underlying dictionary. @@ -93,7 +93,7 @@ class PDDocumentInformation extends jni.JObject { .asFunction)>(); /// from: public org.apache.pdfbox.cos.COSDictionary getCOSObject() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// This will get the underlying dictionary that this object wraps. ///@return The underlying info dictionary. @@ -111,7 +111,7 @@ class PDDocumentInformation extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public java.lang.Object getPropertyStringValue(java.lang.String propertyKey) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Return the properties String value. /// @@ -135,7 +135,7 @@ class PDDocumentInformation extends jni.JObject { .asFunction)>(); /// from: public java.lang.String getTitle() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// This will get the title of the document. This will return null if no title exists. ///@return The title of the document. @@ -168,7 +168,7 @@ class PDDocumentInformation extends jni.JObject { .asFunction)>(); /// from: public java.lang.String getAuthor() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// This will get the author of the document. This will return null if no author exists. ///@return The author of the document. @@ -201,7 +201,7 @@ class PDDocumentInformation extends jni.JObject { .asFunction)>(); /// from: public java.lang.String getSubject() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// This will get the subject of the document. This will return null if no subject exists. ///@return The subject of the document. @@ -234,7 +234,7 @@ class PDDocumentInformation extends jni.JObject { .asFunction)>(); /// from: public java.lang.String getKeywords() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// This will get the keywords of the document. This will return null if no keywords exists. ///@return The keywords of the document. @@ -267,7 +267,7 @@ class PDDocumentInformation extends jni.JObject { .asFunction)>(); /// from: public java.lang.String getCreator() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// This will get the creator of the document. This will return null if no creator exists. ///@return The creator of the document. @@ -300,7 +300,7 @@ class PDDocumentInformation extends jni.JObject { .asFunction)>(); /// from: public java.lang.String getProducer() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// This will get the producer of the document. This will return null if no producer exists. ///@return The producer of the document. @@ -333,7 +333,7 @@ class PDDocumentInformation extends jni.JObject { .asFunction)>(); /// from: public java.util.Calendar getCreationDate() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// 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. @@ -367,7 +367,7 @@ class PDDocumentInformation extends jni.JObject { .asFunction)>(); /// from: public java.util.Calendar getModificationDate() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// This will get the modification date of the document. This will return null if no modification date exists. ///@return The modification date of the document. @@ -402,7 +402,7 @@ class PDDocumentInformation extends jni.JObject { .asFunction)>(); /// from: public java.lang.String getTrapped() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// This will get the trapped value for the document. /// This will return null if one is not found. @@ -418,7 +418,7 @@ class PDDocumentInformation extends jni.JObject { .asFunction)>(); /// from: public java.util.Set getMetadataKeys() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// This will get the keys of all metadata information fields for the document. ///@return all metadata key strings. @@ -438,7 +438,7 @@ class PDDocumentInformation extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public java.lang.String getCustomMetadataValue(java.lang.String fieldName) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// This will get the value of a custom metadata information field for the document. /// This will return null if one is not found. 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 7f565b011..556d83a80 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 @@ -71,7 +71,7 @@ class PDFTextStripper extends jni.JObject { )>(); /// from: protected final java.lang.String LINE_SEPARATOR - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// The platform's line separator. jni.JString get LINE_SEPARATOR => @@ -96,7 +96,7 @@ class PDFTextStripper extends jni.JObject { jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); /// from: protected java.util.ArrayList> charactersByArticle - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// The charactersByArticle is used to extract text by article divisions. For example a PDF that has two columns like /// a newspaper, we want to extract the first column and then the second column. In this example the PDF would have 2 @@ -114,7 +114,7 @@ class PDFTextStripper extends jni.JObject { .fromRef(_get_charactersByArticle(reference).object); /// from: protected java.util.ArrayList> charactersByArticle - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// The charactersByArticle is used to extract text by article divisions. For example a PDF that has two columns like /// a newspaper, we want to extract the first column and then the second column. In this example the PDF would have 2 @@ -149,12 +149,12 @@ class PDFTextStripper extends jni.JObject { jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); /// from: protected org.apache.pdfbox.pdmodel.PDDocument document - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. pddocument_.PDDocument get document => const pddocument_.$PDDocumentType() .fromRef(_get_document(reference).object); /// from: protected org.apache.pdfbox.pdmodel.PDDocument document - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. set document(pddocument_.PDDocument value) => _set_document(reference, value.reference).check(); @@ -176,12 +176,12 @@ class PDFTextStripper extends jni.JObject { jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); /// from: protected java.io.Writer output - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JObject get output => const jni.JObjectType().fromRef(_get_output(reference).object); /// from: protected java.io.Writer output - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. set output(jni.JObject value) => _set_output(reference, value.reference).check(); @@ -190,7 +190,7 @@ class PDFTextStripper extends jni.JObject { .asFunction(); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Instantiate a new PDFTextStripper object. ///@throws IOException If there is an error loading the properties. @@ -207,7 +207,7 @@ class PDFTextStripper extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public java.lang.String getText(org.apache.pdfbox.pdmodel.PDDocument doc) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// This will return the text of a document. See writeText.
    /// NOTE: The document must not be encrypted when coming into this method. @@ -629,7 +629,7 @@ class PDFTextStripper extends jni.JObject { .asFunction)>(); /// from: public java.lang.String getLineSeparator() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// This will get the line separator. ///@return The desired line separator string. @@ -644,7 +644,7 @@ class PDFTextStripper extends jni.JObject { .asFunction)>(); /// from: public java.lang.String getWordSeparator() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// This will get the word separator. ///@return The desired word separator string. @@ -707,7 +707,7 @@ class PDFTextStripper extends jni.JObject { .asFunction)>(); /// from: protected java.io.Writer getOutput() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// The output stream that is being written to. ///@return The stream that output is being written to. @@ -722,7 +722,7 @@ class PDFTextStripper extends jni.JObject { .asFunction)>(); /// from: protected java.util.List> getCharactersByArticle() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Character strings are grouped by articles. It is quite common that there will only be a single article. This /// returns a List that contains List objects, the inner lists will contain TextPosition objects. @@ -790,7 +790,7 @@ class PDFTextStripper extends jni.JObject { .asFunction)>(); /// from: public org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem getEndBookmark() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Get the bookmark where text extraction should end, inclusive. Default is null. ///@return The ending bookmark. @@ -823,7 +823,7 @@ class PDFTextStripper extends jni.JObject { .asFunction)>(); /// from: public org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem getStartBookmark() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Get the bookmark where text extraction should start, inclusive. Default is null. ///@return The starting bookmark. @@ -1056,7 +1056,7 @@ class PDFTextStripper extends jni.JObject { .asFunction)>(); /// from: public java.lang.String getParagraphStart() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Returns the string which will be used at the beginning of a paragraph. ///@return the paragraph start string @@ -1090,7 +1090,7 @@ class PDFTextStripper extends jni.JObject { .asFunction)>(); /// from: public java.lang.String getParagraphEnd() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Returns the string which will be used at the end of a paragraph. ///@return the paragraph end string @@ -1123,7 +1123,7 @@ class PDFTextStripper extends jni.JObject { .asFunction)>(); /// from: public java.lang.String getPageStart() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Returns the string which will be used at the beginning of a page. ///@return the page start string @@ -1156,7 +1156,7 @@ class PDFTextStripper extends jni.JObject { .asFunction)>(); /// from: public java.lang.String getPageEnd() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Returns the string which will be used at the end of a page. ///@return the page end string @@ -1189,7 +1189,7 @@ class PDFTextStripper extends jni.JObject { .asFunction)>(); /// from: public java.lang.String getArticleStart() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Returns the string which will be used at the beginning of an article. ///@return the article start string @@ -1222,7 +1222,7 @@ class PDFTextStripper extends jni.JObject { .asFunction)>(); /// from: public java.lang.String getArticleEnd() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Returns the string which will be used at the end of an article. ///@return the article end string @@ -1344,7 +1344,7 @@ class PDFTextStripper extends jni.JObject { .asFunction)>(); /// from: protected java.util.List getListItemPatterns() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// returns a list of regular expression Patterns representing different common list item formats. For example /// numbered items of form: @@ -1376,7 +1376,7 @@ class PDFTextStripper extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: static protected java.util.regex.Pattern matchPattern(java.lang.String string, java.util.List patterns) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// iterates over the specified list of Patterns until it finds one that matches the specified string. Then returns /// the Pattern. diff --git a/pkgs/jnigen/lib/src/bindings/dart_generator.dart b/pkgs/jnigen/lib/src/bindings/dart_generator.dart index d21665c79..689678cab 100644 --- a/pkgs/jnigen/lib/src/bindings/dart_generator.dart +++ b/pkgs/jnigen/lib/src/bindings/dart_generator.dart @@ -42,9 +42,9 @@ const _lookup = 'jniLookup'; const _selfPointer = 'reference'; // Docs. -const _deleteInstruction = - ' /// The returned object must be deleted after use, ' - 'by calling the `delete` method.'; +const _releaseInstruction = + ' /// The returned object must be released after use, ' + 'by calling the [release] method.'; extension on Iterable { /// Similar to [join] but adds the [separator] to the end as well. @@ -440,7 +440,7 @@ class $name$typeParamsDef extends $superName { $MethodInvocation $i, ) { try { - final $d = $i.methodDescriptor.toDartString(deleteOriginal: true); + final $d = $i.methodDescriptor.toDartString(releaseOriginal: true); final $a = $i.args; '''); final proxyMethodIf = _InterfaceMethodIf(resolver, s); @@ -1050,11 +1050,11 @@ class _FieldGenerator extends Visitor { return '$_env.Set$ifStatic${fieldType}Field($self, _id_$name, value$toNativeSuffix)'; } - void writeDocs(Field node, {required bool writeDeleteInstructions}) { + void writeDocs(Field node, {required bool writeReleaseInstructions}) { final originalDecl = '${node.type.shorthand} ${node.name}'; s.writeln(' /// from: ${node.modifiers.join(' ')} $originalDecl'); - if (node.type.kind != Kind.primitive && writeDeleteInstructions) { - s.writeln(_deleteInstruction); + if (node.type.kind != Kind.primitive && writeReleaseInstructions) { + s.writeln(_releaseInstruction); } node.javadoc?.accept(_DocGenerator(s, depth: 1)); } @@ -1069,7 +1069,7 @@ class _FieldGenerator extends Visitor { final value = node.defaultValue!; // TODO(#31): Should we leave String as a normal getter instead? if (value is String || value is num || value is bool) { - writeDocs(node, writeDeleteInstructions: false); + writeDocs(node, writeReleaseInstructions: false); s.write(' static const $name = '); if (value is String) { s.write('r"""$value"""'); @@ -1085,7 +1085,7 @@ class _FieldGenerator extends Visitor { (isCBased ? writeCAccessor : writeDartOnlyAccessor)(node); // Getter docs. - writeDocs(node, writeDeleteInstructions: true); + writeDocs(node, writeReleaseInstructions: true); final name = node.finalName; final ifStatic = node.isStatic ? 'static ' : ''; @@ -1097,7 +1097,7 @@ class _FieldGenerator extends Visitor { s.writeln(';\n'); if (!node.isFinal) { // Setter docs. - writeDocs(node, writeDeleteInstructions: true); + writeDocs(node, writeReleaseInstructions: true); s.write('${ifStatic}set $name($type value) => '); s.write((isCBased ? cSetter : dartOnlySetter)(node)); @@ -1209,7 +1209,7 @@ class _MethodGenerator extends Visitor { s.writeAll(node.params.map((p) => '${p.type.shorthand} ${p.name}'), ', '); s.writeln(')'); if (node.returnType.kind != Kind.primitive || node.isCtor) { - s.writeln(_deleteInstruction); + s.writeln(_releaseInstruction); } node.javadoc?.accept(_DocGenerator(s, depth: 1)); @@ -1684,11 +1684,11 @@ class _InterfaceParamCast extends Visitor { typeVarFromMap: true, )) .name; - s.write('\$a[$paramIndex].castTo($typeClass, deleteOriginal: true)'); + s.write('\$a[$paramIndex].castTo($typeClass, releaseOriginal: true)'); if (node.type.kind == Kind.primitive) { // Convert to Dart type. final name = (node.type.type as PrimitiveType).name; - s.write('.${name}Value(deleteOriginal: true)'); + s.write('.${name}Value(releaseOriginal: true)'); } s.writeln(','); } @@ -1700,7 +1700,7 @@ class _InterfaceParamCast extends Visitor { /// /// Since Dart doesn't know that this global reference is still used, it might /// garbage collect it via [NativeFinalizer] thus making it invalid. -/// This passes the ownership to Java using [setAsDeleted]. +/// This passes the ownership to Java using [setAsReleased]. /// /// `toPointer` detaches the object from the [NativeFinalizer] and Java /// will clean up the global reference afterwards. @@ -1714,7 +1714,7 @@ class _InterfaceReturnBox extends TypeVisitor { String visitNonPrimitiveType(ReferredType node) { // Casting is done to create a new global reference. The user might // use the original reference elsewhere and so the original object - // should not be [setAsDeleted]. + // should not be [setAsReleased]. return '(\$r as $_jObject).castTo(const ${_jObject}Type()).toPointer()'; } diff --git a/pkgs/jnigen/lib/src/bindings/renamer.dart b/pkgs/jnigen/lib/src/bindings/renamer.dart index 74898fb46..56fea0aed 100644 --- a/pkgs/jnigen/lib/src/bindings/renamer.dart +++ b/pkgs/jnigen/lib/src/bindings/renamer.dart @@ -82,10 +82,11 @@ const Map _definedSyms = { 'runtimeType': 1, 'noSuchMethod': 1, 'reference': 1, - 'isDeleted': 1, + 'isReleased': 1, 'isNull': 1, 'use': 1, - 'delete': 1, + 'release': 1, + 'releasedBy': 1, 'getFieldID': 1, 'getStaticFieldID': 1, 'getMethodID': 1, diff --git a/pkgs/jnigen/pubspec.yaml b/pkgs/jnigen/pubspec.yaml index c0b3dbfc7..b68d371a2 100644 --- a/pkgs/jnigen/pubspec.yaml +++ b/pkgs/jnigen/pubspec.yaml @@ -3,12 +3,20 @@ # BSD-style license that can be found in the LICENSE file. name: jnigen -version: 0.6.0-wip.3 -description: Experimental generator for FFI+JNI bindings. +description: A Dart bindings generator for Java and Kotlin that uses JNI under the hood to interop with Java virtual machine. +version: 0.6.0 repository: https://github.com/dart-lang/jnigen/tree/main/jnigen environment: - sdk: '>=3.1.0-262.3.beta <4.0.0' + sdk: ">=3.1.0-262.3.beta <4.0.0" + +topics: + - interop + - ffi + - codegen + - java + - kotlin + - jni dependencies: json_annotation: ^4.8.0 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 32687fba4..28e6c2b6c 100644 --- a/pkgs/jnigen/test/jackson_core_test/runtime_test_registrant.dart +++ b/pkgs/jnigen/test/jackson_core_test/runtime_test_registrant.dart @@ -24,17 +24,19 @@ void registerTests(String groupName, TestRunnerCallback test) { final next = parser.nextToken(); if (next.isNull) continue; values.add(next.isNumeric()); - next.delete(); + next.release(); } expect(values, equals([false, true, false, false, true, true, false])); - Jni.deleteAll([factory, parser, json]); + for (final obj in [factory, parser, json]) { + obj.release(); + } }); test("parsing invalid JSON throws JniException", () { using((arena) { - final factory = JsonFactory()..deletedIn(arena); + final factory = JsonFactory()..releasedBy(arena); final erroneous = factory - .createParser6("".toJString()..deletedIn(arena)) - ..deletedIn(arena); + .createParser6("".toJString()..releasedBy(arena)) + ..releasedBy(arena); expect(() => erroneous.nextToken(), throwsA(isA())); }); }); diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart index 7112fc36b..4ebdfd9cd 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart @@ -117,7 +117,7 @@ class JsonFactory extends jni.JObject { .asFunction(); /// from: static public final com.fasterxml.jackson.core.SerializableString DEFAULT_ROOT_VALUE_SEPARATOR - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JObject get DEFAULT_ROOT_VALUE_SEPARATOR => const jni.JObjectType() .fromRef(_get_DEFAULT_ROOT_VALUE_SEPARATOR().object); @@ -126,7 +126,7 @@ class JsonFactory extends jni.JObject { .asFunction(); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Default constructor used to create factory instances. /// Creation of a factory instance is a light-weight operation, @@ -147,7 +147,7 @@ class JsonFactory extends jni.JObject { .asFunction)>(); /// from: public void (com.fasterxml.jackson.core.ObjectCodec oc) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory JsonFactory.new1( jni.JObject oc, ) { @@ -163,7 +163,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: protected void (com.fasterxml.jackson.core.JsonFactory src, com.fasterxml.jackson.core.ObjectCodec codec) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Constructor used when copy()ing a factory instance. ///@param src Original factory to copy settings from @@ -183,7 +183,7 @@ class JsonFactory extends jni.JObject { .asFunction)>(); /// from: public void (com.fasterxml.jackson.core.JsonFactoryBuilder b) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Constructor used by JsonFactoryBuilder for instantiation. ///@param b Builder that contains settings to use @@ -201,7 +201,7 @@ class JsonFactory extends jni.JObject { .asFunction, int)>(); /// from: protected void (com.fasterxml.jackson.core.TSFBuilder b, boolean bogus) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Constructor for subtypes; needed to work around the fact that before 3.0, /// this factory has cumbersome dual role as generic type as well as actual @@ -222,7 +222,7 @@ class JsonFactory extends jni.JObject { .asFunction)>(); /// from: public com.fasterxml.jackson.core.TSFBuilder rebuild() - /// The returned object must be deleted after use, by calling the `delete` method. + /// 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. @@ -238,7 +238,7 @@ class JsonFactory extends jni.JObject { .asFunction(); /// from: static public com.fasterxml.jackson.core.TSFBuilder builder() - /// The returned object must be deleted after use, by calling the `delete` method. + /// 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 @@ -259,7 +259,7 @@ class JsonFactory extends jni.JObject { .asFunction)>(); /// from: public com.fasterxml.jackson.core.JsonFactory copy() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing a new JsonFactory that has /// the same settings as this instance, but is otherwise @@ -284,7 +284,7 @@ class JsonFactory extends jni.JObject { .asFunction)>(); /// from: protected java.lang.Object readResolve() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that we need to override to actually make restoration go /// through constructors etc: needed to allow JDK serializability of @@ -394,7 +394,7 @@ class JsonFactory extends jni.JObject { .asFunction)>(); /// from: public java.lang.Class getFormatReadFeatureType() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JObject getFormatReadFeatureType() { return const jni.JObjectType() .fromRef(_getFormatReadFeatureType(reference).object); @@ -407,7 +407,7 @@ class JsonFactory extends jni.JObject { .asFunction)>(); /// from: public java.lang.Class getFormatWriteFeatureType() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JObject getFormatWriteFeatureType() { return const jni.JObjectType() .fromRef(_getFormatWriteFeatureType(reference).object); @@ -445,7 +445,7 @@ class JsonFactory extends jni.JObject { .asFunction)>(); /// from: public java.lang.String getFormatName() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that returns short textual id identifying format /// this factory supports. @@ -466,7 +466,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.format.MatchStrength hasFormat(com.fasterxml.jackson.core.format.InputAccessor acc) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JObject hasFormat( jni.JObject acc, ) { @@ -504,7 +504,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: protected com.fasterxml.jackson.core.format.MatchStrength hasJSONFormat(com.fasterxml.jackson.core.format.InputAccessor acc) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JObject hasJSONFormat( jni.JObject acc, ) { @@ -519,7 +519,7 @@ class JsonFactory extends jni.JObject { .asFunction)>(); /// from: public com.fasterxml.jackson.core.Version version() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JObject version() { return const jni.JObjectType().fromRef(_version(reference).object); } @@ -533,7 +533,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer, int)>(); /// from: public final com.fasterxml.jackson.core.JsonFactory configure(com.fasterxml.jackson.core.JsonFactory.Feature f, boolean state) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for enabling or disabling specified parser feature /// (check JsonParser.Feature for list of features) @@ -558,7 +558,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.JsonFactory enable(com.fasterxml.jackson.core.JsonFactory.Feature f) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for enabling specified parser feature /// (check JsonFactory.Feature for list of features) @@ -581,7 +581,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.JsonFactory disable(com.fasterxml.jackson.core.JsonFactory.Feature f) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for disabling specified parser features /// (check JsonFactory.Feature for list of features) @@ -667,7 +667,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer, int)>(); /// from: public final com.fasterxml.jackson.core.JsonFactory configure(com.fasterxml.jackson.core.JsonParser.Feature f, boolean state) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for enabling or disabling specified parser feature /// (check JsonParser.Feature for list of features) @@ -691,7 +691,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.JsonFactory enable(com.fasterxml.jackson.core.JsonParser.Feature f) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for enabling specified parser feature /// (check JsonParser.Feature for list of features) @@ -713,7 +713,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.JsonFactory disable(com.fasterxml.jackson.core.JsonParser.Feature f) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for disabling specified parser features /// (check JsonParser.Feature for list of features) @@ -772,7 +772,7 @@ class JsonFactory extends jni.JObject { .asFunction)>(); /// from: public com.fasterxml.jackson.core.io.InputDecorator getInputDecorator() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for getting currently configured input decorator (if any; /// there is no default decorator). @@ -791,7 +791,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.JsonFactory setInputDecorator(com.fasterxml.jackson.core.io.InputDecorator d) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for overriding currently configured input decorator ///@param d Decorator to configure for this factory, if any ({@code null} if none) @@ -813,7 +813,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer, int)>(); /// from: public final com.fasterxml.jackson.core.JsonFactory configure(com.fasterxml.jackson.core.JsonGenerator.Feature f, boolean state) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for enabling or disabling specified generator feature /// (check JsonGenerator.Feature for list of features) @@ -837,7 +837,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.JsonFactory enable(com.fasterxml.jackson.core.JsonGenerator.Feature f) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for enabling specified generator features /// (check JsonGenerator.Feature for list of features) @@ -859,7 +859,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.JsonFactory disable(com.fasterxml.jackson.core.JsonGenerator.Feature f) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for disabling specified generator feature /// (check JsonGenerator.Feature for list of features) @@ -918,7 +918,7 @@ class JsonFactory extends jni.JObject { .asFunction)>(); /// from: public com.fasterxml.jackson.core.io.CharacterEscapes getCharacterEscapes() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for accessing custom escapes factory uses for JsonGenerators /// it creates. @@ -937,7 +937,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.JsonFactory setCharacterEscapes(com.fasterxml.jackson.core.io.CharacterEscapes esc) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for defining custom escapes factory uses for JsonGenerators /// it creates. @@ -957,7 +957,7 @@ class JsonFactory extends jni.JObject { .asFunction)>(); /// from: public com.fasterxml.jackson.core.io.OutputDecorator getOutputDecorator() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for getting currently configured output decorator (if any; /// there is no default decorator). @@ -977,7 +977,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.JsonFactory setOutputDecorator(com.fasterxml.jackson.core.io.OutputDecorator d) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for overriding currently configured output decorator ///@return This factory instance (to allow call chaining) @@ -999,7 +999,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.JsonFactory setRootValueSeparator(java.lang.String sep) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that allows overriding String used for separating root-level /// JSON values (default is single space character) @@ -1020,7 +1020,7 @@ class JsonFactory extends jni.JObject { .asFunction)>(); /// from: public java.lang.String getRootValueSeparator() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// @return Root value separator configured, if any jni.JString getRootValueSeparator() { @@ -1037,7 +1037,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.JsonFactory setCodec(com.fasterxml.jackson.core.ObjectCodec oc) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for associating a ObjectCodec (typically /// a com.fasterxml.jackson.databind.ObjectMapper) @@ -1060,7 +1060,7 @@ class JsonFactory extends jni.JObject { .asFunction)>(); /// from: public com.fasterxml.jackson.core.ObjectCodec getCodec() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JObject getCodec() { return const jni.JObjectType().fromRef(_getCodec(reference).object); } @@ -1074,7 +1074,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.io.File f) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing JSON parser instance to parse /// contents of specified file. @@ -1108,7 +1108,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.net.URL url) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing JSON parser instance to parse /// contents of resource reference by given URL. @@ -1140,7 +1140,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.io.InputStream in) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing JSON parser instance to parse /// the contents accessed via specified input stream. @@ -1175,7 +1175,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.io.Reader r) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing parser for parsing /// the contents accessed via specified Reader. @@ -1203,7 +1203,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.JsonParser createParser(byte[] data) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing parser for parsing /// the contents of given byte array. @@ -1227,7 +1227,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer, int, int)>(); /// from: public com.fasterxml.jackson.core.JsonParser createParser(byte[] data, int offset, int len) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing parser for parsing /// the contents of given byte array. @@ -1253,7 +1253,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.lang.String content) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing parser for parsing /// contents of given String. @@ -1274,7 +1274,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.JsonParser createParser(char[] content) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing parser for parsing /// contents of given char array. @@ -1298,7 +1298,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer, int, int)>(); /// from: public com.fasterxml.jackson.core.JsonParser createParser(char[] content, int offset, int len) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing parser for parsing contents of given char array. ///@since 2.4 @@ -1320,7 +1320,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.io.DataInput in) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Optional method for constructing parser for reading contents from specified DataInput /// instance. @@ -1342,7 +1342,7 @@ class JsonFactory extends jni.JObject { .asFunction)>(); /// from: public com.fasterxml.jackson.core.JsonParser createNonBlockingByteArrayParser() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Optional method for constructing parser for non-blocking parsing /// via com.fasterxml.jackson.core.async.ByteArrayFeeder @@ -1373,7 +1373,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.OutputStream out, com.fasterxml.jackson.core.JsonEncoding enc) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing JSON generator for writing JSON content /// using specified output stream. @@ -1410,7 +1410,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.OutputStream out) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Convenience method for constructing generator that uses default /// encoding of the format (UTF-8 for JSON and most other data formats). @@ -1433,7 +1433,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.Writer w) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing JSON generator for writing JSON content /// using specified Writer. @@ -1464,7 +1464,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.File f, com.fasterxml.jackson.core.JsonEncoding enc) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing JSON generator for writing JSON content /// to specified file, overwriting contents it might have (or creating @@ -1497,7 +1497,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.DataOutput out, com.fasterxml.jackson.core.JsonEncoding enc) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing generator for writing content using specified /// DataOutput instance. @@ -1519,7 +1519,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.DataOutput out) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Convenience method for constructing generator that uses default /// encoding of the format (UTF-8 for JSON and most other data formats). @@ -1542,7 +1542,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(java.io.File f) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing JSON parser instance to parse /// contents of specified file. @@ -1578,7 +1578,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(java.net.URL url) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing JSON parser instance to parse /// contents of resource reference by given URL. @@ -1613,7 +1613,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(java.io.InputStream in) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing JSON parser instance to parse /// the contents accessed via specified input stream. @@ -1651,7 +1651,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(java.io.Reader r) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing parser for parsing /// the contents accessed via specified Reader. @@ -1682,7 +1682,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(byte[] data) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing parser for parsing the contents of given byte array. ///@param data Input content to parse @@ -1709,7 +1709,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer, int, int)>(); /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(byte[] data, int offset, int len) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing parser for parsing /// the contents of given byte array. @@ -1738,7 +1738,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(java.lang.String content) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing parser for parsing /// contents of given String. @@ -1765,7 +1765,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.JsonGenerator createJsonGenerator(java.io.OutputStream out, com.fasterxml.jackson.core.JsonEncoding enc) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing JSON generator for writing JSON content /// using specified output stream. @@ -1804,7 +1804,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.JsonGenerator createJsonGenerator(java.io.Writer out) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing JSON generator for writing JSON content /// using specified Writer. @@ -1835,7 +1835,7 @@ class JsonFactory extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.JsonGenerator createJsonGenerator(java.io.OutputStream out) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Convenience method for constructing generator that uses default /// encoding of the format (UTF-8 for JSON and most other data formats). @@ -1897,7 +1897,7 @@ class JsonFactory_Feature extends jni.JObject { .asFunction(); /// from: static public com.fasterxml.jackson.core.JsonFactory.Feature[] values() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JArray values() { return const jni.JArrayType($JsonFactory_FeatureType()) .fromRef(_values().object); @@ -1910,7 +1910,7 @@ class JsonFactory_Feature extends jni.JObject { .asFunction)>(); /// from: static public com.fasterxml.jackson.core.JsonFactory.Feature valueOf(java.lang.String name) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static JsonFactory_Feature valueOf( jni.JString name, ) { diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart index 7828fd81b..3ea73b13c 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart @@ -62,7 +62,7 @@ class JsonParser extends jni.JObject { .asFunction(); /// from: static protected final com.fasterxml.jackson.core.util.JacksonFeatureSet DEFAULT_READ_CAPABILITIES - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Default set of StreamReadCapabilityies that may be used as /// basis for format-specific readers (or as bogus instance if non-null @@ -76,7 +76,7 @@ class JsonParser extends jni.JObject { .asFunction(); /// from: protected void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory JsonParser() { return JsonParser.fromRef(_new0().object); } @@ -87,7 +87,7 @@ class JsonParser extends jni.JObject { .asFunction(); /// from: protected void (int features) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory JsonParser.new1( int features, ) { @@ -101,7 +101,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public abstract com.fasterxml.jackson.core.ObjectCodec getCodec() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Accessor for ObjectCodec associated with this /// parser, if any. Codec is used by \#readValueAs(Class) @@ -138,7 +138,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public java.lang.Object getInputSource() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that can be used to get access to object that is used /// to access input being parsed; this is usually either @@ -255,7 +255,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public com.fasterxml.jackson.core.FormatSchema getSchema() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for accessing Schema that this parser uses, if any. /// Default implementation returns null. @@ -335,7 +335,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public com.fasterxml.jackson.core.async.NonBlockingInputFeeder getNonBlockingInputFeeder() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that will either return a feeder instance (if parser uses /// non-blocking, aka asynchronous access); or null for @@ -354,7 +354,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public com.fasterxml.jackson.core.util.JacksonFeatureSet getReadCapabilities() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Accessor for getting metadata on capabilities of this parser, based on /// underlying data format being read (directly or indirectly). @@ -372,7 +372,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public abstract com.fasterxml.jackson.core.Version version() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Accessor for getting version of the core package, given a parser instance. /// Left for sub-classes to implement. @@ -434,7 +434,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public abstract com.fasterxml.jackson.core.JsonStreamContext getParsingContext() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that can be used to access current parsing context reader /// is in. There are 3 different types: root, array and object contexts, @@ -457,7 +457,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public com.fasterxml.jackson.core.JsonLocation currentLocation() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that returns location of the last processed input unit (character /// or byte) from the input; @@ -482,7 +482,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public com.fasterxml.jackson.core.JsonLocation currentTokenLocation() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that return the __starting__ location of the current /// (most recently returned) @@ -508,7 +508,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public abstract com.fasterxml.jackson.core.JsonLocation getCurrentLocation() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Alias for \#currentLocation(), to be deprecated in later /// Jackson 2.x versions (and removed from Jackson 3.0). @@ -525,7 +525,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public abstract com.fasterxml.jackson.core.JsonLocation getTokenLocation() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Alias for \#currentTokenLocation(), to be deprecated in later /// Jackson 2.x versions (and removed from Jackson 3.0). @@ -541,7 +541,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public java.lang.Object currentValue() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Helper method, usually equivalent to: /// @@ -587,7 +587,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public java.lang.Object getCurrentValue() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Alias for \#currentValue(), to be deprecated in later /// Jackson 2.x versions (and removed from Jackson 3.0). @@ -679,7 +679,7 @@ class JsonParser extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.JsonParser enable(com.fasterxml.jackson.core.JsonParser.Feature f) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for enabling specified parser feature /// (check Feature for list of features) @@ -701,7 +701,7 @@ class JsonParser extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public com.fasterxml.jackson.core.JsonParser disable(com.fasterxml.jackson.core.JsonParser.Feature f) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for disabling specified feature /// (check Feature for list of features) @@ -723,7 +723,7 @@ class JsonParser extends jni.JObject { ffi.Pointer, ffi.Pointer, int)>(); /// from: public com.fasterxml.jackson.core.JsonParser configure(com.fasterxml.jackson.core.JsonParser.Feature f, boolean state) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for enabling or disabling specified feature /// (check Feature for list of features) @@ -799,7 +799,7 @@ class JsonParser extends jni.JObject { .asFunction, int)>(); /// from: public com.fasterxml.jackson.core.JsonParser setFeatureMask(int mask) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Bulk set method for (re)setting states of all standard Features ///@param mask Bit mask that defines set of features to enable @@ -820,7 +820,7 @@ class JsonParser extends jni.JObject { .asFunction, int, int)>(); /// from: public com.fasterxml.jackson.core.JsonParser overrideStdFeatures(int values, int mask) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Bulk set method for (re)setting states of features specified by mask. /// Functionally equivalent to @@ -865,7 +865,7 @@ class JsonParser extends jni.JObject { .asFunction, int, int)>(); /// from: public com.fasterxml.jackson.core.JsonParser overrideFormatFeatures(int values, int mask) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Bulk set method for (re)setting states of FormatFeatures, /// by specifying values (set / clear) along with a mask, to determine @@ -892,7 +892,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public abstract com.fasterxml.jackson.core.JsonToken nextToken() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Main iteration method, which will advance stream enough /// to determine type of the next token, if any. If none @@ -914,7 +914,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public abstract com.fasterxml.jackson.core.JsonToken nextValue() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Iteration method that will advance stream enough /// to determine type of the next token that is a value type @@ -975,7 +975,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public java.lang.String nextFieldName() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that fetches next token (as if calling \#nextToken) and /// verifies whether it is JsonToken\#FIELD_NAME; if it is, @@ -996,7 +996,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public java.lang.String nextTextValue() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that fetches next token (as if calling \#nextToken) and /// if it is JsonToken\#VALUE_STRING returns contained String value; @@ -1084,7 +1084,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public java.lang.Boolean nextBooleanValue() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that fetches next token (as if calling \#nextToken) and /// if it is JsonToken\#VALUE_TRUE or JsonToken\#VALUE_FALSE @@ -1114,7 +1114,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public abstract com.fasterxml.jackson.core.JsonParser skipChildren() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that will skip all child tokens of an array or /// object token that the parser currently points to, @@ -1167,7 +1167,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public com.fasterxml.jackson.core.JsonToken currentToken() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Accessor to find which token parser currently points to, if any; /// null will be returned if none. @@ -1211,7 +1211,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public abstract com.fasterxml.jackson.core.JsonToken getCurrentToken() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Alias for \#currentToken(), may be deprecated sometime after /// Jackson 2.13 (will be removed from 3.0). @@ -1431,7 +1431,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public abstract com.fasterxml.jackson.core.JsonToken getLastClearedToken() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that can be called to get the last token that was /// cleared using \#clearCurrentToken. This is not necessarily @@ -1475,7 +1475,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public abstract java.lang.String getCurrentName() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Alias of \#currentName(). ///@return Name of the current field in the parsing context @@ -1492,7 +1492,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public java.lang.String currentName() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that can be called to get the name associated with /// the current token: for JsonToken\#FIELD_NAMEs it will @@ -1514,7 +1514,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public abstract java.lang.String getText() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for accessing textual representation of the current token; /// if no current token (before first call to \#nextToken, or @@ -1566,7 +1566,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public abstract char[] getTextCharacters() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method similar to \#getText, but that will return /// underlying (unmodifiable) character array that contains @@ -1671,7 +1671,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public abstract java.lang.Number getNumberValue() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Generic number value accessor method that will work for /// all kinds of numeric values. It will return the optimal @@ -1694,7 +1694,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public java.lang.Number getNumberValueExact() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method similar to \#getNumberValue with the difference that /// for floating-point numbers value returned may be BigDecimal @@ -1722,7 +1722,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public abstract com.fasterxml.jackson.core.JsonParser.NumberType getNumberType() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// If current token is of type /// JsonToken\#VALUE_NUMBER_INT or @@ -1857,7 +1857,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public abstract java.math.BigInteger getBigIntegerValue() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Numeric accessor that can be called when the current /// token is of type JsonToken\#VALUE_NUMBER_INT and @@ -1936,7 +1936,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public abstract java.math.BigDecimal getDecimalValue() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Numeric accessor that can be called when the current /// token is of type JsonToken\#VALUE_NUMBER_FLOAT or @@ -1980,7 +1980,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public java.lang.Object getEmbeddedObject() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Accessor that can be called if (and only if) the current token /// is JsonToken\#VALUE_EMBEDDED_OBJECT. For other token types, @@ -2010,7 +2010,7 @@ class JsonParser extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public abstract byte[] getBinaryValue(com.fasterxml.jackson.core.Base64Variant bv) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that can be used to read (and consume -- results /// may not be accessible using other methods after the call) @@ -2046,7 +2046,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public byte[] getBinaryValue() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Convenience alternative to \#getBinaryValue(Base64Variant) /// that defaults to using @@ -2328,7 +2328,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public java.lang.String getValueAsString() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that will try to convert value of current token to a /// java.lang.String. @@ -2354,7 +2354,7 @@ class JsonParser extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public abstract java.lang.String getValueAsString(java.lang.String def) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that will try to convert value of current token to a /// java.lang.String. @@ -2428,7 +2428,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public java.lang.Object getObjectId() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that can be called to check whether current token /// (one that was just read) has an associated Object id, and if @@ -2454,7 +2454,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public java.lang.Object getTypeId() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that can be called to check whether current token /// (one that was just read) has an associated type id, and if @@ -2482,7 +2482,7 @@ class JsonParser extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public T readValueAs(java.lang.Class valueType) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method to deserialize JSON content into a non-container /// type (it can be an array type, however): typically a bean, array @@ -2525,7 +2525,7 @@ class JsonParser extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public T readValueAs(com.fasterxml.jackson.core.type.TypeReference valueTypeRef) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method to deserialize JSON content into a Java type, reference /// to which is passed as argument. Type is passed using so-called @@ -2565,7 +2565,7 @@ class JsonParser extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public java.util.Iterator readValuesAs(java.lang.Class valueType) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for reading sequence of Objects from parser stream, /// all with same specified value type. @@ -2592,7 +2592,7 @@ class JsonParser extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public java.util.Iterator readValuesAs(com.fasterxml.jackson.core.type.TypeReference valueTypeRef) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for reading sequence of Objects from parser stream, /// all with same specified value type. @@ -2617,7 +2617,7 @@ class JsonParser extends jni.JObject { .asFunction)>(); /// from: public T readValueAsTree() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method to deserialize JSON content into equivalent "tree model", /// represented by root TreeNode of resulting model. @@ -2678,7 +2678,7 @@ class JsonParser_Feature extends jni.JObject { .asFunction(); /// from: static public com.fasterxml.jackson.core.JsonParser.Feature[] values() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JArray values() { return const jni.JArrayType($JsonParser_FeatureType()) .fromRef(_values().object); @@ -2691,7 +2691,7 @@ class JsonParser_Feature extends jni.JObject { .asFunction)>(); /// from: static public com.fasterxml.jackson.core.JsonParser.Feature valueOf(java.lang.String name) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static JsonParser_Feature valueOf( jni.JString name, ) { @@ -2795,7 +2795,7 @@ class JsonParser_NumberType extends jni.JObject { .asFunction(); /// from: static public com.fasterxml.jackson.core.JsonParser.NumberType[] values() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JArray values() { return const jni.JArrayType($JsonParser_NumberTypeType()) .fromRef(_values().object); @@ -2808,7 +2808,7 @@ class JsonParser_NumberType extends jni.JObject { .asFunction)>(); /// from: static public com.fasterxml.jackson.core.JsonParser.NumberType valueOf(java.lang.String name) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static JsonParser_NumberType valueOf( jni.JString name, ) { diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart index d5c82a594..da95cb6e5 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart @@ -59,7 +59,7 @@ class JsonToken extends jni.JObject { .asFunction(); /// from: static public com.fasterxml.jackson.core.JsonToken[] values() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JArray values() { return const jni.JArrayType($JsonTokenType()).fromRef(_values().object); } @@ -71,7 +71,7 @@ class JsonToken extends jni.JObject { .asFunction)>(); /// from: static public com.fasterxml.jackson.core.JsonToken valueOf(java.lang.String name) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static JsonToken valueOf( jni.JString name, ) { @@ -96,7 +96,7 @@ class JsonToken extends jni.JObject { .asFunction)>(); /// from: public final java.lang.String asString() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JString asString() { return const jni.JStringType().fromRef(_asString(reference).object); } @@ -108,7 +108,7 @@ class JsonToken extends jni.JObject { .asFunction)>(); /// from: public final char[] asCharArray() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JArray asCharArray() { return const jni.JArrayType(jni.jcharType()) .fromRef(_asCharArray(reference).object); @@ -121,7 +121,7 @@ class JsonToken extends jni.JObject { .asFunction)>(); /// from: public final byte[] asByteArray() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JArray asByteArray() { return const jni.JArrayType(jni.jbyteType()) .fromRef(_asByteArray(reference).object); diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart index e5045b92a..3677ba171 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart @@ -133,7 +133,7 @@ class JsonFactory extends jni.JObject { ); /// from: static public final com.fasterxml.jackson.core.SerializableString DEFAULT_ROOT_VALUE_SEPARATOR - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JObject get DEFAULT_ROOT_VALUE_SEPARATOR => const jni.JObjectType().fromRef(jni.Jni.accessors .getStaticField(_class.reference, _id_DEFAULT_ROOT_VALUE_SEPARATOR, @@ -144,7 +144,7 @@ class JsonFactory extends jni.JObject { jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Default constructor used to create factory instances. /// Creation of a factory instance is a light-weight operation, @@ -163,7 +163,7 @@ class JsonFactory extends jni.JObject { r"", r"(Lcom/fasterxml/jackson/core/ObjectCodec;)V"); /// from: public void (com.fasterxml.jackson.core.ObjectCodec oc) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory JsonFactory.new1( jni.JObject oc, ) { @@ -177,7 +177,7 @@ class JsonFactory extends jni.JObject { r"(Lcom/fasterxml/jackson/core/JsonFactory;Lcom/fasterxml/jackson/core/ObjectCodec;)V"); /// from: protected void (com.fasterxml.jackson.core.JsonFactory src, com.fasterxml.jackson.core.ObjectCodec codec) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Constructor used when copy()ing a factory instance. ///@param src Original factory to copy settings from @@ -195,7 +195,7 @@ class JsonFactory extends jni.JObject { r"", r"(Lcom/fasterxml/jackson/core/JsonFactoryBuilder;)V"); /// from: public void (com.fasterxml.jackson.core.JsonFactoryBuilder b) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Constructor used by JsonFactoryBuilder for instantiation. ///@param b Builder that contains settings to use @@ -211,7 +211,7 @@ class JsonFactory extends jni.JObject { r"", r"(Lcom/fasterxml/jackson/core/TSFBuilder;Z)V"); /// from: protected void (com.fasterxml.jackson.core.TSFBuilder b, boolean bogus) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Constructor for subtypes; needed to work around the fact that before 3.0, /// this factory has cumbersome dual role as generic type as well as actual @@ -230,7 +230,7 @@ class JsonFactory extends jni.JObject { r"rebuild", r"()Lcom/fasterxml/jackson/core/TSFBuilder;"); /// from: public com.fasterxml.jackson.core.TSFBuilder rebuild() - /// The returned object must be deleted after use, by calling the `delete` method. + /// 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. @@ -247,7 +247,7 @@ class JsonFactory extends jni.JObject { r"()Lcom/fasterxml/jackson/core/TSFBuilder;"); /// from: static public com.fasterxml.jackson.core.TSFBuilder builder() - /// The returned object must be deleted after use, by calling the `delete` method. + /// 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 @@ -267,7 +267,7 @@ class JsonFactory extends jni.JObject { _class.reference, r"copy", r"()Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public com.fasterxml.jackson.core.JsonFactory copy() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing a new JsonFactory that has /// the same settings as this instance, but is otherwise @@ -291,7 +291,7 @@ class JsonFactory extends jni.JObject { .getMethodIDOf(_class.reference, r"readResolve", r"()Ljava/lang/Object;"); /// from: protected java.lang.Object readResolve() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that we need to override to actually make restoration go /// through constructors etc: needed to allow JDK serializability of @@ -391,7 +391,7 @@ class JsonFactory extends jni.JObject { _class.reference, r"getFormatReadFeatureType", r"()Ljava/lang/Class;"); /// from: public java.lang.Class getFormatReadFeatureType() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JObject getFormatReadFeatureType() { return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, @@ -403,7 +403,7 @@ class JsonFactory extends jni.JObject { _class.reference, r"getFormatWriteFeatureType", r"()Ljava/lang/Class;"); /// from: public java.lang.Class getFormatWriteFeatureType() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JObject getFormatWriteFeatureType() { return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, @@ -438,7 +438,7 @@ class JsonFactory extends jni.JObject { _class.reference, r"getFormatName", r"()Ljava/lang/String;"); /// from: public java.lang.String getFormatName() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that returns short textual id identifying format /// this factory supports. @@ -457,7 +457,7 @@ class JsonFactory extends jni.JObject { r"(Lcom/fasterxml/jackson/core/format/InputAccessor;)Lcom/fasterxml/jackson/core/format/MatchStrength;"); /// from: public com.fasterxml.jackson.core.format.MatchStrength hasFormat(com.fasterxml.jackson.core.format.InputAccessor acc) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JObject hasFormat( jni.JObject acc, ) { @@ -493,7 +493,7 @@ class JsonFactory extends jni.JObject { r"(Lcom/fasterxml/jackson/core/format/InputAccessor;)Lcom/fasterxml/jackson/core/format/MatchStrength;"); /// from: protected com.fasterxml.jackson.core.format.MatchStrength hasJSONFormat(com.fasterxml.jackson.core.format.InputAccessor acc) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JObject hasJSONFormat( jni.JObject acc, ) { @@ -508,7 +508,7 @@ class JsonFactory extends jni.JObject { _class.reference, r"version", r"()Lcom/fasterxml/jackson/core/Version;"); /// from: public com.fasterxml.jackson.core.Version version() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JObject version() { return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_version, jni.JniCallType.objectType, []).object); @@ -520,7 +520,7 @@ class JsonFactory extends jni.JObject { r"(Lcom/fasterxml/jackson/core/JsonFactory$Feature;Z)Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public final com.fasterxml.jackson.core.JsonFactory configure(com.fasterxml.jackson.core.JsonFactory.Feature f, boolean state) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for enabling or disabling specified parser feature /// (check JsonParser.Feature for list of features) @@ -543,7 +543,7 @@ class JsonFactory extends jni.JObject { r"(Lcom/fasterxml/jackson/core/JsonFactory$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public com.fasterxml.jackson.core.JsonFactory enable(com.fasterxml.jackson.core.JsonFactory.Feature f) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for enabling specified parser feature /// (check JsonFactory.Feature for list of features) @@ -564,7 +564,7 @@ class JsonFactory extends jni.JObject { r"(Lcom/fasterxml/jackson/core/JsonFactory$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public com.fasterxml.jackson.core.JsonFactory disable(com.fasterxml.jackson.core.JsonFactory.Feature f) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for disabling specified parser features /// (check JsonFactory.Feature for list of features) @@ -636,7 +636,7 @@ class JsonFactory extends jni.JObject { r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;Z)Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public final com.fasterxml.jackson.core.JsonFactory configure(com.fasterxml.jackson.core.JsonParser.Feature f, boolean state) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for enabling or disabling specified parser feature /// (check JsonParser.Feature for list of features) @@ -658,7 +658,7 @@ class JsonFactory extends jni.JObject { r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public com.fasterxml.jackson.core.JsonFactory enable(com.fasterxml.jackson.core.JsonParser.Feature f) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for enabling specified parser feature /// (check JsonParser.Feature for list of features) @@ -678,7 +678,7 @@ class JsonFactory extends jni.JObject { r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public com.fasterxml.jackson.core.JsonFactory disable(com.fasterxml.jackson.core.JsonParser.Feature f) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for disabling specified parser features /// (check JsonParser.Feature for list of features) @@ -733,7 +733,7 @@ class JsonFactory extends jni.JObject { r"()Lcom/fasterxml/jackson/core/io/InputDecorator;"); /// from: public com.fasterxml.jackson.core.io.InputDecorator getInputDecorator() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for getting currently configured input decorator (if any; /// there is no default decorator). @@ -751,7 +751,7 @@ class JsonFactory extends jni.JObject { r"(Lcom/fasterxml/jackson/core/io/InputDecorator;)Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public com.fasterxml.jackson.core.JsonFactory setInputDecorator(com.fasterxml.jackson.core.io.InputDecorator d) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for overriding currently configured input decorator ///@param d Decorator to configure for this factory, if any ({@code null} if none) @@ -771,7 +771,7 @@ class JsonFactory extends jni.JObject { r"(Lcom/fasterxml/jackson/core/JsonGenerator$Feature;Z)Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public final com.fasterxml.jackson.core.JsonFactory configure(com.fasterxml.jackson.core.JsonGenerator.Feature f, boolean state) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for enabling or disabling specified generator feature /// (check JsonGenerator.Feature for list of features) @@ -793,7 +793,7 @@ class JsonFactory extends jni.JObject { r"(Lcom/fasterxml/jackson/core/JsonGenerator$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public com.fasterxml.jackson.core.JsonFactory enable(com.fasterxml.jackson.core.JsonGenerator.Feature f) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for enabling specified generator features /// (check JsonGenerator.Feature for list of features) @@ -813,7 +813,7 @@ class JsonFactory extends jni.JObject { r"(Lcom/fasterxml/jackson/core/JsonGenerator$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public com.fasterxml.jackson.core.JsonFactory disable(com.fasterxml.jackson.core.JsonGenerator.Feature f) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for disabling specified generator feature /// (check JsonGenerator.Feature for list of features) @@ -868,7 +868,7 @@ class JsonFactory extends jni.JObject { r"()Lcom/fasterxml/jackson/core/io/CharacterEscapes;"); /// from: public com.fasterxml.jackson.core.io.CharacterEscapes getCharacterEscapes() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for accessing custom escapes factory uses for JsonGenerators /// it creates. @@ -886,7 +886,7 @@ class JsonFactory extends jni.JObject { r"(Lcom/fasterxml/jackson/core/io/CharacterEscapes;)Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public com.fasterxml.jackson.core.JsonFactory setCharacterEscapes(com.fasterxml.jackson.core.io.CharacterEscapes esc) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for defining custom escapes factory uses for JsonGenerators /// it creates. @@ -906,7 +906,7 @@ class JsonFactory extends jni.JObject { r"()Lcom/fasterxml/jackson/core/io/OutputDecorator;"); /// from: public com.fasterxml.jackson.core.io.OutputDecorator getOutputDecorator() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for getting currently configured output decorator (if any; /// there is no default decorator). @@ -925,7 +925,7 @@ class JsonFactory extends jni.JObject { r"(Lcom/fasterxml/jackson/core/io/OutputDecorator;)Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public com.fasterxml.jackson.core.JsonFactory setOutputDecorator(com.fasterxml.jackson.core.io.OutputDecorator d) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for overriding currently configured output decorator ///@return This factory instance (to allow call chaining) @@ -945,7 +945,7 @@ class JsonFactory extends jni.JObject { r"(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public com.fasterxml.jackson.core.JsonFactory setRootValueSeparator(java.lang.String sep) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that allows overriding String used for separating root-level /// JSON values (default is single space character) @@ -964,7 +964,7 @@ class JsonFactory extends jni.JObject { _class.reference, r"getRootValueSeparator", r"()Ljava/lang/String;"); /// from: public java.lang.String getRootValueSeparator() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// @return Root value separator configured, if any jni.JString getRootValueSeparator() { @@ -980,7 +980,7 @@ class JsonFactory extends jni.JObject { r"(Lcom/fasterxml/jackson/core/ObjectCodec;)Lcom/fasterxml/jackson/core/JsonFactory;"); /// from: public com.fasterxml.jackson.core.JsonFactory setCodec(com.fasterxml.jackson.core.ObjectCodec oc) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for associating a ObjectCodec (typically /// a com.fasterxml.jackson.databind.ObjectMapper) @@ -1001,7 +1001,7 @@ class JsonFactory extends jni.JObject { r"getCodec", r"()Lcom/fasterxml/jackson/core/ObjectCodec;"); /// from: public com.fasterxml.jackson.core.ObjectCodec getCodec() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JObject getCodec() { return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getCodec, jni.JniCallType.objectType, []).object); @@ -1013,7 +1013,7 @@ class JsonFactory extends jni.JObject { r"(Ljava/io/File;)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.io.File f) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing JSON parser instance to parse /// contents of specified file. @@ -1045,7 +1045,7 @@ class JsonFactory extends jni.JObject { r"(Ljava/net/URL;)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.net.URL url) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing JSON parser instance to parse /// contents of resource reference by given URL. @@ -1075,7 +1075,7 @@ class JsonFactory extends jni.JObject { r"(Ljava/io/InputStream;)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.io.InputStream in) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing JSON parser instance to parse /// the contents accessed via specified input stream. @@ -1108,7 +1108,7 @@ class JsonFactory extends jni.JObject { r"(Ljava/io/Reader;)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.io.Reader r) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing parser for parsing /// the contents accessed via specified Reader. @@ -1134,7 +1134,7 @@ class JsonFactory extends jni.JObject { r"([B)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createParser(byte[] data) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing parser for parsing /// the contents of given byte array. @@ -1153,7 +1153,7 @@ class JsonFactory extends jni.JObject { r"([BII)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createParser(byte[] data, int offset, int len) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing parser for parsing /// the contents of given byte array. @@ -1181,7 +1181,7 @@ class JsonFactory extends jni.JObject { r"(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.lang.String content) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing parser for parsing /// contents of given String. @@ -1200,7 +1200,7 @@ class JsonFactory extends jni.JObject { r"([C)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createParser(char[] content) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing parser for parsing /// contents of given char array. @@ -1219,7 +1219,7 @@ class JsonFactory extends jni.JObject { r"([CII)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createParser(char[] content, int offset, int len) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing parser for parsing contents of given char array. ///@since 2.4 @@ -1243,7 +1243,7 @@ class JsonFactory extends jni.JObject { r"(Ljava/io/DataInput;)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createParser(java.io.DataInput in) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Optional method for constructing parser for reading contents from specified DataInput /// instance. @@ -1264,7 +1264,7 @@ class JsonFactory extends jni.JObject { r"()Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createNonBlockingByteArrayParser() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Optional method for constructing parser for non-blocking parsing /// via com.fasterxml.jackson.core.async.ByteArrayFeeder @@ -1291,7 +1291,7 @@ class JsonFactory extends jni.JObject { r"(Ljava/io/OutputStream;Lcom/fasterxml/jackson/core/JsonEncoding;)Lcom/fasterxml/jackson/core/JsonGenerator;"); /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.OutputStream out, com.fasterxml.jackson.core.JsonEncoding enc) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing JSON generator for writing JSON content /// using specified output stream. @@ -1328,7 +1328,7 @@ class JsonFactory extends jni.JObject { r"(Ljava/io/OutputStream;)Lcom/fasterxml/jackson/core/JsonGenerator;"); /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.OutputStream out) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Convenience method for constructing generator that uses default /// encoding of the format (UTF-8 for JSON and most other data formats). @@ -1351,7 +1351,7 @@ class JsonFactory extends jni.JObject { r"(Ljava/io/Writer;)Lcom/fasterxml/jackson/core/JsonGenerator;"); /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.Writer w) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing JSON generator for writing JSON content /// using specified Writer. @@ -1380,7 +1380,7 @@ class JsonFactory extends jni.JObject { r"(Ljava/io/File;Lcom/fasterxml/jackson/core/JsonEncoding;)Lcom/fasterxml/jackson/core/JsonGenerator;"); /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.File f, com.fasterxml.jackson.core.JsonEncoding enc) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing JSON generator for writing JSON content /// to specified file, overwriting contents it might have (or creating @@ -1411,7 +1411,7 @@ class JsonFactory extends jni.JObject { r"(Ljava/io/DataOutput;Lcom/fasterxml/jackson/core/JsonEncoding;)Lcom/fasterxml/jackson/core/JsonGenerator;"); /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.DataOutput out, com.fasterxml.jackson.core.JsonEncoding enc) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing generator for writing content using specified /// DataOutput instance. @@ -1433,7 +1433,7 @@ class JsonFactory extends jni.JObject { r"(Ljava/io/DataOutput;)Lcom/fasterxml/jackson/core/JsonGenerator;"); /// from: public com.fasterxml.jackson.core.JsonGenerator createGenerator(java.io.DataOutput out) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Convenience method for constructing generator that uses default /// encoding of the format (UTF-8 for JSON and most other data formats). @@ -1456,7 +1456,7 @@ class JsonFactory extends jni.JObject { r"(Ljava/io/File;)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(java.io.File f) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing JSON parser instance to parse /// contents of specified file. @@ -1490,7 +1490,7 @@ class JsonFactory extends jni.JObject { r"(Ljava/net/URL;)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(java.net.URL url) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing JSON parser instance to parse /// contents of resource reference by given URL. @@ -1523,7 +1523,7 @@ class JsonFactory extends jni.JObject { r"(Ljava/io/InputStream;)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(java.io.InputStream in) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing JSON parser instance to parse /// the contents accessed via specified input stream. @@ -1559,7 +1559,7 @@ class JsonFactory extends jni.JObject { r"(Ljava/io/Reader;)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(java.io.Reader r) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing parser for parsing /// the contents accessed via specified Reader. @@ -1588,7 +1588,7 @@ class JsonFactory extends jni.JObject { r"([B)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(byte[] data) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing parser for parsing the contents of given byte array. ///@param data Input content to parse @@ -1610,7 +1610,7 @@ class JsonFactory extends jni.JObject { r"([BII)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(byte[] data, int offset, int len) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing parser for parsing /// the contents of given byte array. @@ -1641,7 +1641,7 @@ class JsonFactory extends jni.JObject { r"(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser createJsonParser(java.lang.String content) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing parser for parsing /// contents of given String. @@ -1664,7 +1664,7 @@ class JsonFactory extends jni.JObject { r"(Ljava/io/OutputStream;Lcom/fasterxml/jackson/core/JsonEncoding;)Lcom/fasterxml/jackson/core/JsonGenerator;"); /// from: public com.fasterxml.jackson.core.JsonGenerator createJsonGenerator(java.io.OutputStream out, com.fasterxml.jackson.core.JsonEncoding enc) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing JSON generator for writing JSON content /// using specified output stream. @@ -1703,7 +1703,7 @@ class JsonFactory extends jni.JObject { r"(Ljava/io/Writer;)Lcom/fasterxml/jackson/core/JsonGenerator;"); /// from: public com.fasterxml.jackson.core.JsonGenerator createJsonGenerator(java.io.Writer out) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for constructing JSON generator for writing JSON content /// using specified Writer. @@ -1734,7 +1734,7 @@ class JsonFactory extends jni.JObject { r"(Ljava/io/OutputStream;)Lcom/fasterxml/jackson/core/JsonGenerator;"); /// from: public com.fasterxml.jackson.core.JsonGenerator createJsonGenerator(java.io.OutputStream out) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Convenience method for constructing generator that uses default /// encoding of the format (UTF-8 for JSON and most other data formats). @@ -1802,7 +1802,7 @@ class JsonFactory_Feature extends jni.JObject { r"()[Lcom/fasterxml/jackson/core/JsonFactory$Feature;"); /// from: static public com.fasterxml.jackson.core.JsonFactory.Feature[] values() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JArray values() { return const jni.JArrayType($JsonFactory_FeatureType()).fromRef( jni.Jni.accessors.callStaticMethodWithArgs(_class.reference, _id_values, @@ -1815,7 +1815,7 @@ class JsonFactory_Feature extends jni.JObject { r"(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonFactory$Feature;"); /// from: static public com.fasterxml.jackson.core.JsonFactory.Feature valueOf(java.lang.String name) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static JsonFactory_Feature valueOf( jni.JString name, ) { diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart index 115c360c9..7d0dceb12 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart @@ -66,7 +66,7 @@ class JsonParser extends jni.JObject { ); /// from: static protected final com.fasterxml.jackson.core.util.JacksonFeatureSet DEFAULT_READ_CAPABILITIES - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Default set of StreamReadCapabilityies that may be used as /// basis for format-specific readers (or as bogus instance if non-null @@ -82,7 +82,7 @@ class JsonParser extends jni.JObject { jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: protected void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory JsonParser() { return JsonParser.fromRef(jni.Jni.accessors .newObjectWithArgs(_class.reference, _id_new0, []).object); @@ -92,7 +92,7 @@ class JsonParser extends jni.JObject { jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"(I)V"); /// from: protected void (int features) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory JsonParser.new1( int features, ) { @@ -104,7 +104,7 @@ class JsonParser extends jni.JObject { r"getCodec", r"()Lcom/fasterxml/jackson/core/ObjectCodec;"); /// from: public abstract com.fasterxml.jackson.core.ObjectCodec getCodec() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Accessor for ObjectCodec associated with this /// parser, if any. Codec is used by \#readValueAs(Class) @@ -135,7 +135,7 @@ class JsonParser extends jni.JObject { _class.reference, r"getInputSource", r"()Ljava/lang/Object;"); /// from: public java.lang.Object getInputSource() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that can be used to get access to object that is used /// to access input being parsed; this is usually either @@ -242,7 +242,7 @@ class JsonParser extends jni.JObject { r"getSchema", r"()Lcom/fasterxml/jackson/core/FormatSchema;"); /// from: public com.fasterxml.jackson.core.FormatSchema getSchema() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for accessing Schema that this parser uses, if any. /// Default implementation returns null. @@ -316,7 +316,7 @@ class JsonParser extends jni.JObject { r"()Lcom/fasterxml/jackson/core/async/NonBlockingInputFeeder;"); /// from: public com.fasterxml.jackson.core.async.NonBlockingInputFeeder getNonBlockingInputFeeder() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that will either return a feeder instance (if parser uses /// non-blocking, aka asynchronous access); or null for @@ -336,7 +336,7 @@ class JsonParser extends jni.JObject { r"()Lcom/fasterxml/jackson/core/util/JacksonFeatureSet;"); /// from: public com.fasterxml.jackson.core.util.JacksonFeatureSet getReadCapabilities() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Accessor for getting metadata on capabilities of this parser, based on /// underlying data format being read (directly or indirectly). @@ -353,7 +353,7 @@ class JsonParser extends jni.JObject { _class.reference, r"version", r"()Lcom/fasterxml/jackson/core/Version;"); /// from: public abstract com.fasterxml.jackson.core.Version version() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Accessor for getting version of the core package, given a parser instance. /// Left for sub-classes to implement. @@ -411,7 +411,7 @@ class JsonParser extends jni.JObject { r"()Lcom/fasterxml/jackson/core/JsonStreamContext;"); /// from: public abstract com.fasterxml.jackson.core.JsonStreamContext getParsingContext() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that can be used to access current parsing context reader /// is in. There are 3 different types: root, array and object contexts, @@ -435,7 +435,7 @@ class JsonParser extends jni.JObject { r"()Lcom/fasterxml/jackson/core/JsonLocation;"); /// from: public com.fasterxml.jackson.core.JsonLocation currentLocation() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that returns location of the last processed input unit (character /// or byte) from the input; @@ -460,7 +460,7 @@ class JsonParser extends jni.JObject { r"()Lcom/fasterxml/jackson/core/JsonLocation;"); /// from: public com.fasterxml.jackson.core.JsonLocation currentTokenLocation() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that return the __starting__ location of the current /// (most recently returned) @@ -487,7 +487,7 @@ class JsonParser extends jni.JObject { r"()Lcom/fasterxml/jackson/core/JsonLocation;"); /// from: public abstract com.fasterxml.jackson.core.JsonLocation getCurrentLocation() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Alias for \#currentLocation(), to be deprecated in later /// Jackson 2.x versions (and removed from Jackson 3.0). @@ -505,7 +505,7 @@ class JsonParser extends jni.JObject { r"()Lcom/fasterxml/jackson/core/JsonLocation;"); /// from: public abstract com.fasterxml.jackson.core.JsonLocation getTokenLocation() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Alias for \#currentTokenLocation(), to be deprecated in later /// Jackson 2.x versions (and removed from Jackson 3.0). @@ -521,7 +521,7 @@ class JsonParser extends jni.JObject { _class.reference, r"currentValue", r"()Ljava/lang/Object;"); /// from: public java.lang.Object currentValue() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Helper method, usually equivalent to: /// @@ -564,7 +564,7 @@ class JsonParser extends jni.JObject { _class.reference, r"getCurrentValue", r"()Ljava/lang/Object;"); /// from: public java.lang.Object getCurrentValue() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Alias for \#currentValue(), to be deprecated in later /// Jackson 2.x versions (and removed from Jackson 3.0). @@ -642,7 +642,7 @@ class JsonParser extends jni.JObject { r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser enable(com.fasterxml.jackson.core.JsonParser.Feature f) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for enabling specified parser feature /// (check Feature for list of features) @@ -664,7 +664,7 @@ class JsonParser extends jni.JObject { r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser disable(com.fasterxml.jackson.core.JsonParser.Feature f) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for disabling specified feature /// (check Feature for list of features) @@ -686,7 +686,7 @@ class JsonParser extends jni.JObject { r"(Lcom/fasterxml/jackson/core/JsonParser$Feature;Z)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser configure(com.fasterxml.jackson.core.JsonParser.Feature f, boolean state) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for enabling or disabling specified feature /// (check Feature for list of features) @@ -756,7 +756,7 @@ class JsonParser extends jni.JObject { r"(I)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser setFeatureMask(int mask) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Bulk set method for (re)setting states of all standard Features ///@param mask Bit mask that defines set of features to enable @@ -779,7 +779,7 @@ class JsonParser extends jni.JObject { r"(II)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser overrideStdFeatures(int values, int mask) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Bulk set method for (re)setting states of features specified by mask. /// Functionally equivalent to @@ -824,7 +824,7 @@ class JsonParser extends jni.JObject { r"(II)Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public com.fasterxml.jackson.core.JsonParser overrideFormatFeatures(int values, int mask) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Bulk set method for (re)setting states of FormatFeatures, /// by specifying values (set / clear) along with a mask, to determine @@ -851,7 +851,7 @@ class JsonParser extends jni.JObject { r"nextToken", r"()Lcom/fasterxml/jackson/core/JsonToken;"); /// from: public abstract com.fasterxml.jackson.core.JsonToken nextToken() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Main iteration method, which will advance stream enough /// to determine type of the next token, if any. If none @@ -871,7 +871,7 @@ class JsonParser extends jni.JObject { r"nextValue", r"()Lcom/fasterxml/jackson/core/JsonToken;"); /// from: public abstract com.fasterxml.jackson.core.JsonToken nextValue() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Iteration method that will advance stream enough /// to determine type of the next token that is a value type @@ -928,7 +928,7 @@ class JsonParser extends jni.JObject { _class.reference, r"nextFieldName", r"()Ljava/lang/String;"); /// from: public java.lang.String nextFieldName() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that fetches next token (as if calling \#nextToken) and /// verifies whether it is JsonToken\#FIELD_NAME; if it is, @@ -947,7 +947,7 @@ class JsonParser extends jni.JObject { _class.reference, r"nextTextValue", r"()Ljava/lang/String;"); /// from: public java.lang.String nextTextValue() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that fetches next token (as if calling \#nextToken) and /// if it is JsonToken\#VALUE_STRING returns contained String value; @@ -1029,7 +1029,7 @@ class JsonParser extends jni.JObject { _class.reference, r"nextBooleanValue", r"()Ljava/lang/Boolean;"); /// from: public java.lang.Boolean nextBooleanValue() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that fetches next token (as if calling \#nextToken) and /// if it is JsonToken\#VALUE_TRUE or JsonToken\#VALUE_FALSE @@ -1059,7 +1059,7 @@ class JsonParser extends jni.JObject { r"()Lcom/fasterxml/jackson/core/JsonParser;"); /// from: public abstract com.fasterxml.jackson.core.JsonParser skipChildren() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that will skip all child tokens of an array or /// object token that the parser currently points to, @@ -1110,7 +1110,7 @@ class JsonParser extends jni.JObject { r"()Lcom/fasterxml/jackson/core/JsonToken;"); /// from: public com.fasterxml.jackson.core.JsonToken currentToken() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Accessor to find which token parser currently points to, if any; /// null will be returned if none. @@ -1152,7 +1152,7 @@ class JsonParser extends jni.JObject { r"()Lcom/fasterxml/jackson/core/JsonToken;"); /// from: public abstract com.fasterxml.jackson.core.JsonToken getCurrentToken() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Alias for \#currentToken(), may be deprecated sometime after /// Jackson 2.13 (will be removed from 3.0). @@ -1354,7 +1354,7 @@ class JsonParser extends jni.JObject { r"()Lcom/fasterxml/jackson/core/JsonToken;"); /// from: public abstract com.fasterxml.jackson.core.JsonToken getLastClearedToken() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that can be called to get the last token that was /// cleared using \#clearCurrentToken. This is not necessarily @@ -1395,7 +1395,7 @@ class JsonParser extends jni.JObject { _class.reference, r"getCurrentName", r"()Ljava/lang/String;"); /// from: public abstract java.lang.String getCurrentName() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Alias of \#currentName(). ///@return Name of the current field in the parsing context @@ -1410,7 +1410,7 @@ class JsonParser extends jni.JObject { .getMethodIDOf(_class.reference, r"currentName", r"()Ljava/lang/String;"); /// from: public java.lang.String currentName() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that can be called to get the name associated with /// the current token: for JsonToken\#FIELD_NAMEs it will @@ -1430,7 +1430,7 @@ class JsonParser extends jni.JObject { .getMethodIDOf(_class.reference, r"getText", r"()Ljava/lang/String;"); /// from: public abstract java.lang.String getText() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for accessing textual representation of the current token; /// if no current token (before first call to \#nextToken, or @@ -1476,7 +1476,7 @@ class JsonParser extends jni.JObject { .getMethodIDOf(_class.reference, r"getTextCharacters", r"()[C"); /// from: public abstract char[] getTextCharacters() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method similar to \#getText, but that will return /// underlying (unmodifiable) character array that contains @@ -1573,7 +1573,7 @@ class JsonParser extends jni.JObject { _class.reference, r"getNumberValue", r"()Ljava/lang/Number;"); /// from: public abstract java.lang.Number getNumberValue() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Generic number value accessor method that will work for /// all kinds of numeric values. It will return the optimal @@ -1594,7 +1594,7 @@ class JsonParser extends jni.JObject { _class.reference, r"getNumberValueExact", r"()Ljava/lang/Number;"); /// from: public java.lang.Number getNumberValueExact() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method similar to \#getNumberValue with the difference that /// for floating-point numbers value returned may be BigDecimal @@ -1623,7 +1623,7 @@ class JsonParser extends jni.JObject { r"()Lcom/fasterxml/jackson/core/JsonParser$NumberType;"); /// from: public abstract com.fasterxml.jackson.core.JsonParser.NumberType getNumberType() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// If current token is of type /// JsonToken\#VALUE_NUMBER_INT or @@ -1748,7 +1748,7 @@ class JsonParser extends jni.JObject { _class.reference, r"getBigIntegerValue", r"()Ljava/math/BigInteger;"); /// from: public abstract java.math.BigInteger getBigIntegerValue() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Numeric accessor that can be called when the current /// token is of type JsonToken\#VALUE_NUMBER_INT and @@ -1822,7 +1822,7 @@ class JsonParser extends jni.JObject { _class.reference, r"getDecimalValue", r"()Ljava/math/BigDecimal;"); /// from: public abstract java.math.BigDecimal getDecimalValue() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Numeric accessor that can be called when the current /// token is of type JsonToken\#VALUE_NUMBER_FLOAT or @@ -1862,7 +1862,7 @@ class JsonParser extends jni.JObject { _class.reference, r"getEmbeddedObject", r"()Ljava/lang/Object;"); /// from: public java.lang.Object getEmbeddedObject() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Accessor that can be called if (and only if) the current token /// is JsonToken\#VALUE_EMBEDDED_OBJECT. For other token types, @@ -1891,7 +1891,7 @@ class JsonParser extends jni.JObject { r"(Lcom/fasterxml/jackson/core/Base64Variant;)[B"); /// from: public abstract byte[] getBinaryValue(com.fasterxml.jackson.core.Base64Variant bv) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that can be used to read (and consume -- results /// may not be accessible using other methods after the call) @@ -1925,7 +1925,7 @@ class JsonParser extends jni.JObject { .getMethodIDOf(_class.reference, r"getBinaryValue", r"()[B"); /// from: public byte[] getBinaryValue() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Convenience alternative to \#getBinaryValue(Base64Variant) /// that defaults to using @@ -2184,7 +2184,7 @@ class JsonParser extends jni.JObject { _class.reference, r"getValueAsString", r"()Ljava/lang/String;"); /// from: public java.lang.String getValueAsString() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that will try to convert value of current token to a /// java.lang.String. @@ -2210,7 +2210,7 @@ class JsonParser extends jni.JObject { r"(Ljava/lang/String;)Ljava/lang/String;"); /// from: public abstract java.lang.String getValueAsString(java.lang.String def) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that will try to convert value of current token to a /// java.lang.String. @@ -2280,7 +2280,7 @@ class JsonParser extends jni.JObject { .getMethodIDOf(_class.reference, r"getObjectId", r"()Ljava/lang/Object;"); /// from: public java.lang.Object getObjectId() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that can be called to check whether current token /// (one that was just read) has an associated Object id, and if @@ -2304,7 +2304,7 @@ class JsonParser extends jni.JObject { .getMethodIDOf(_class.reference, r"getTypeId", r"()Ljava/lang/Object;"); /// from: public java.lang.Object getTypeId() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method that can be called to check whether current token /// (one that was just read) has an associated type id, and if @@ -2330,7 +2330,7 @@ class JsonParser extends jni.JObject { r"(Ljava/lang/Class;)Ljava/lang/Object;"); /// from: public T readValueAs(java.lang.Class valueType) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method to deserialize JSON content into a non-container /// type (it can be an array type, however): typically a bean, array @@ -2374,7 +2374,7 @@ class JsonParser extends jni.JObject { r"(Lcom/fasterxml/jackson/core/type/TypeReference;)Ljava/lang/Object;"); /// from: public T readValueAs(com.fasterxml.jackson.core.type.TypeReference valueTypeRef) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method to deserialize JSON content into a Java type, reference /// to which is passed as argument. Type is passed using so-called @@ -2415,7 +2415,7 @@ class JsonParser extends jni.JObject { r"(Ljava/lang/Class;)Ljava/util/Iterator;"); /// from: public java.util.Iterator readValuesAs(java.lang.Class valueType) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for reading sequence of Objects from parser stream, /// all with same specified value type. @@ -2442,7 +2442,7 @@ class JsonParser extends jni.JObject { r"(Lcom/fasterxml/jackson/core/type/TypeReference;)Ljava/util/Iterator;"); /// from: public java.util.Iterator readValuesAs(com.fasterxml.jackson.core.type.TypeReference valueTypeRef) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method for reading sequence of Objects from parser stream, /// all with same specified value type. @@ -2469,7 +2469,7 @@ class JsonParser extends jni.JObject { r"()Lcom/fasterxml/jackson/core/TreeNode;"); /// from: public T readValueAsTree() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Method to deserialize JSON content into equivalent "tree model", /// represented by root TreeNode of resulting model. @@ -2534,7 +2534,7 @@ class JsonParser_Feature extends jni.JObject { r"()[Lcom/fasterxml/jackson/core/JsonParser$Feature;"); /// from: static public com.fasterxml.jackson.core.JsonParser.Feature[] values() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JArray values() { return const jni.JArrayType($JsonParser_FeatureType()).fromRef( jni.Jni.accessors.callStaticMethodWithArgs(_class.reference, _id_values, @@ -2547,7 +2547,7 @@ class JsonParser_Feature extends jni.JObject { r"(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonParser$Feature;"); /// from: static public com.fasterxml.jackson.core.JsonParser.Feature valueOf(java.lang.String name) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static JsonParser_Feature valueOf( jni.JString name, ) { @@ -2648,7 +2648,7 @@ class JsonParser_NumberType extends jni.JObject { r"()[Lcom/fasterxml/jackson/core/JsonParser$NumberType;"); /// from: static public com.fasterxml.jackson.core.JsonParser.NumberType[] values() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JArray values() { return const jni.JArrayType($JsonParser_NumberTypeType()).fromRef( jni.Jni.accessors.callStaticMethodWithArgs(_class.reference, _id_values, @@ -2661,7 +2661,7 @@ class JsonParser_NumberType extends jni.JObject { r"(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonParser$NumberType;"); /// from: static public com.fasterxml.jackson.core.JsonParser.NumberType valueOf(java.lang.String name) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static JsonParser_NumberType valueOf( jni.JString name, ) { diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart index aac454b68..6b60adb27 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart @@ -60,7 +60,7 @@ class JsonToken extends jni.JObject { r"()[Lcom/fasterxml/jackson/core/JsonToken;"); /// from: static public com.fasterxml.jackson.core.JsonToken[] values() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JArray values() { return const jni.JArrayType($JsonTokenType()).fromRef(jni.Jni.accessors .callStaticMethodWithArgs(_class.reference, _id_values, @@ -73,7 +73,7 @@ class JsonToken extends jni.JObject { r"(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonToken;"); /// from: static public com.fasterxml.jackson.core.JsonToken valueOf(java.lang.String name) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static JsonToken valueOf( jni.JString name, ) { @@ -95,7 +95,7 @@ class JsonToken extends jni.JObject { .getMethodIDOf(_class.reference, r"asString", r"()Ljava/lang/String;"); /// from: public final java.lang.String asString() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JString asString() { return const jni.JStringType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_asString, jni.JniCallType.objectType, []).object); @@ -105,7 +105,7 @@ class JsonToken extends jni.JObject { .getMethodIDOf(_class.reference, r"asCharArray", r"()[C"); /// from: public final char[] asCharArray() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JArray asCharArray() { return const jni.JArrayType(jni.jcharType()).fromRef(jni.Jni.accessors .callMethodWithArgs( @@ -116,7 +116,7 @@ class JsonToken extends jni.JObject { .getMethodIDOf(_class.reference, r"asByteArray", r"()[B"); /// from: public final byte[] asByteArray() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JArray asByteArray() { return const jni.JArrayType(jni.jbyteType()).fromRef(jni.Jni.accessors .callMethodWithArgs( diff --git a/pkgs/jnigen/test/kotlin_test/c_based/dart_bindings/kotlin.dart b/pkgs/jnigen/test/kotlin_test/c_based/dart_bindings/kotlin.dart index 67c1e4d53..1792649fc 100644 --- a/pkgs/jnigen/test/kotlin_test/c_based/dart_bindings/kotlin.dart +++ b/pkgs/jnigen/test/kotlin_test/c_based/dart_bindings/kotlin.dart @@ -45,7 +45,7 @@ class SuspendFun extends jni.JObject { .asFunction(); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory SuspendFun() { return SuspendFun.fromRef(_new0().object); } @@ -59,7 +59,7 @@ class SuspendFun extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public final java.lang.Object sayHello(kotlin.coroutines.Continuation continuation) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. Future sayHello() async { final $p = ReceivePort(); final $c = @@ -84,7 +84,7 @@ class SuspendFun extends jni.JObject { ffi.Pointer)>(); /// from: public final java.lang.Object sayHello(java.lang.String string, kotlin.coroutines.Continuation continuation) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. Future sayHello1( jni.JString string, ) async { diff --git a/pkgs/jnigen/test/kotlin_test/dart_only/dart_bindings/kotlin.dart b/pkgs/jnigen/test/kotlin_test/dart_only/dart_bindings/kotlin.dart index 9b9ce95fa..357e6e51c 100644 --- a/pkgs/jnigen/test/kotlin_test/dart_only/dart_bindings/kotlin.dart +++ b/pkgs/jnigen/test/kotlin_test/dart_only/dart_bindings/kotlin.dart @@ -42,7 +42,7 @@ class SuspendFun extends jni.JObject { jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory SuspendFun() { return SuspendFun.fromRef(jni.Jni.accessors .newObjectWithArgs(_class.reference, _id_new0, []).object); @@ -52,7 +52,7 @@ class SuspendFun extends jni.JObject { r"sayHello", r"(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;"); /// from: public final java.lang.Object sayHello(kotlin.coroutines.Continuation continuation) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. Future sayHello() async { final $p = ReceivePort(); final $c = @@ -73,7 +73,7 @@ class SuspendFun extends jni.JObject { r"(Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;"); /// from: public final java.lang.Object sayHello(java.lang.String string, kotlin.coroutines.Continuation continuation) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. Future sayHello1( jni.JString string, ) async { diff --git a/pkgs/jnigen/test/kotlin_test/runtime_test_registrant.dart b/pkgs/jnigen/test/kotlin_test/runtime_test_registrant.dart index 642622bdb..6a9696b6e 100644 --- a/pkgs/jnigen/test/kotlin_test/runtime_test_registrant.dart +++ b/pkgs/jnigen/test/kotlin_test/runtime_test_registrant.dart @@ -13,13 +13,13 @@ void registerTests(String groupName, TestRunnerCallback test) { group(groupName, () { test('Suspend functions', () async { await using((arena) async { - final suspendFun = SuspendFun()..deletedIn(arena); + final suspendFun = SuspendFun()..releasedBy(arena); final hello = await suspendFun.sayHello(); - expect(hello.toDartString(deleteOriginal: true), "Hello!"); + expect(hello.toDartString(releaseOriginal: true), "Hello!"); const name = "Bob"; final helloBob = - await suspendFun.sayHello1(name.toJString()..deletedIn(arena)); - expect(helloBob.toDartString(deleteOriginal: true), "Hello $name!"); + await suspendFun.sayHello1(name.toJString()..releasedBy(arena)); + expect(helloBob.toDartString(releaseOriginal: true), "Hello $name!"); }); }); }); diff --git a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart index 5154b7591..a91eba6b1 100644 --- a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart @@ -45,7 +45,7 @@ class Color extends jni.JObject { .asFunction(); /// from: static public com.github.dart_lang.jnigen.simple_package.Color[] values() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JArray values() { return const jni.JArrayType($ColorType()).fromRef(_values().object); } @@ -57,7 +57,7 @@ class Color extends jni.JObject { .asFunction)>(); /// from: static public com.github.dart_lang.jnigen.simple_package.Color valueOf(java.lang.String name) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static Color valueOf( jni.JString name, ) { @@ -122,7 +122,7 @@ class Example extends jni.JObject { .asFunction(); /// from: static public final java.util.Random unusedRandom - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JObject get unusedRandom => const jni.JObjectType().fromRef(_get_unusedRandom().object); @@ -144,12 +144,12 @@ class Example extends jni.JObject { jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); /// from: protected java.util.Random protectedField - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JObject get protectedField => const jni.JObjectType().fromRef(_get_protectedField(reference).object); /// from: protected java.util.Random protectedField - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. set protectedField(jni.JObject value) => _set_protectedField(reference, value.reference).check(); @@ -188,7 +188,7 @@ class Example extends jni.JObject { .asFunction(); /// from: static public java.lang.String getName() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString getName() { return const jni.JStringType().fromRef(_getName().object); } @@ -199,7 +199,7 @@ class Example extends jni.JObject { .asFunction(); /// from: static public com.github.dart_lang.jnigen.simple_package.Example.Nested getNestedInstance() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static Example_Nested getNestedInstance() { return const $Example_NestedType().fromRef(_getNestedInstance().object); } @@ -334,7 +334,7 @@ class Example extends jni.JObject { .asFunction)>(); /// from: public java.lang.String getCodename() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JString getCodename() { return const jni.JStringType().fromRef(_getCodename(reference).object); } @@ -361,7 +361,7 @@ class Example extends jni.JObject { .asFunction)>(); /// from: public java.util.Random getRandom() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JObject getRandom() { return const jni.JObjectType().fromRef(_getRandom(reference).object); } @@ -448,7 +448,7 @@ class Example extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public java.lang.String getRandomNumericString(java.util.Random random) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JString getRandomNumericString( jni.JObject random, ) { @@ -492,7 +492,7 @@ class Example extends jni.JObject { .asFunction)>(); /// from: public java.util.List getList() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JList getList() { return const jni.JListType(jni.JStringType()) .fromRef(_getList(reference).object); @@ -509,7 +509,7 @@ class Example extends jni.JObject { ffi.Pointer)>(); /// from: public java.lang.String joinStrings(java.util.List values, java.lang.String delim) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Joins the strings in the list using the given delimiter. jni.JString joinStrings( @@ -564,7 +564,7 @@ class Example extends jni.JObject { .asFunction(); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory Example() { return Example.fromRef(_new0().object); } @@ -575,7 +575,7 @@ class Example extends jni.JObject { .asFunction(); /// from: public void (int number) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory Example.new1( int number, ) { @@ -588,7 +588,7 @@ class Example extends jni.JObject { .asFunction(); /// from: public void (int number, boolean isUp) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory Example.new2( int number, bool isUp, @@ -603,7 +603,7 @@ class Example extends jni.JObject { .asFunction)>(); /// from: public void (int number, boolean isUp, java.lang.String codename) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory Example.new3( int number, bool isUp, @@ -621,7 +621,7 @@ class Example extends jni.JObject { jni.JniResult Function(int, int, int, int, int, int, int, int)>(); /// from: public void (int a, int b, int c, int d, int e, int f, int g, int h) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory Example.new4( int a, int b, @@ -664,7 +664,7 @@ class Example extends jni.JObject { .asFunction(); /// from: static public int[] getArr() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JArray getArr() { return const jni.JArrayType(jni.jintType()).fromRef(_getArr().object); } @@ -689,7 +689,7 @@ class Example extends jni.JObject { .asFunction)>(); /// from: public com.github.dart_lang.jnigen.simple_package.Example getSelf() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. Example getSelf() { return const $ExampleType().fromRef(_getSelf(reference).object); } @@ -820,7 +820,7 @@ class Example_Nested extends jni.JObject { .asFunction(); /// from: public void (boolean value) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory Example_Nested( bool value, ) { @@ -921,7 +921,7 @@ class Example_Nested_NestedTwice extends jni.JObject { .asFunction(); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory Example_Nested_NestedTwice() { return Example_Nested_NestedTwice.fromRef(_new0().object); } @@ -995,7 +995,7 @@ class Example_NonStaticNested extends jni.JObject { .asFunction)>(); /// from: public void (com.github.dart_lang.jnigen.simple_package.Example $parent) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory Example_NonStaticNested( Example $parent, ) { @@ -1047,7 +1047,7 @@ class Exceptions extends jni.JObject { .asFunction(); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory Exceptions() { return Exceptions.fromRef(_new0().object); } @@ -1058,7 +1058,7 @@ class Exceptions extends jni.JObject { .asFunction(); /// from: public void (float x) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory Exceptions.new1( double x, ) { @@ -1072,7 +1072,7 @@ class Exceptions extends jni.JObject { .asFunction(); /// from: public void (int a, int b, int c, int d, int e, int f) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory Exceptions.new2( int a, int b, @@ -1090,7 +1090,7 @@ class Exceptions extends jni.JObject { .asFunction(); /// from: static public java.lang.Object staticObjectMethod() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JObject staticObjectMethod() { return const jni.JObjectType().fromRef(_staticObjectMethod().object); } @@ -1111,7 +1111,7 @@ class Exceptions extends jni.JObject { .asFunction(); /// from: static public java.lang.Object[] staticObjectArrayMethod() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JArray staticObjectArrayMethod() { return const jni.JArrayType(jni.JObjectType()) .fromRef(_staticObjectArrayMethod().object); @@ -1123,7 +1123,7 @@ class Exceptions extends jni.JObject { .asFunction(); /// from: static public int[] staticIntArrayMethod() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JArray staticIntArrayMethod() { return const jni.JArrayType(jni.jintType()) .fromRef(_staticIntArrayMethod().object); @@ -1136,7 +1136,7 @@ class Exceptions extends jni.JObject { .asFunction)>(); /// from: public java.lang.Object objectMethod() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JObject objectMethod() { return const jni.JObjectType().fromRef(_objectMethod(reference).object); } @@ -1159,7 +1159,7 @@ class Exceptions extends jni.JObject { .asFunction)>(); /// from: public java.lang.Object[] objectArrayMethod() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JArray objectArrayMethod() { return const jni.JArrayType(jni.JObjectType()) .fromRef(_objectArrayMethod(reference).object); @@ -1172,7 +1172,7 @@ class Exceptions extends jni.JObject { .asFunction)>(); /// from: public int[] intArrayMethod() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JArray intArrayMethod() { return const jni.JArrayType(jni.jintType()) .fromRef(_intArrayMethod(reference).object); @@ -1196,7 +1196,7 @@ class Exceptions extends jni.JObject { .asFunction)>(); /// from: public java.io.InputStream throwFileNotFoundException() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JObject throwFileNotFoundException() { return const jni.JObjectType() .fromRef(_throwFileNotFoundException(reference).object); @@ -1209,7 +1209,7 @@ class Exceptions extends jni.JObject { .asFunction)>(); /// from: public java.io.FileInputStream throwClassCastException() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JObject throwClassCastException() { return const jni.JObjectType() .fromRef(_throwClassCastException(reference).object); @@ -1343,12 +1343,12 @@ class Fields extends jni.JObject { .asFunction)>(); /// from: static public java.lang.String name - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString get name => const jni.JStringType().fromRef(_get_name().object); /// from: static public java.lang.String name - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static set name(jni.JString value) => _set_name(value.reference).check(); static final _get_i = jniLookup< @@ -1369,12 +1369,12 @@ class Fields extends jni.JObject { jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); /// from: public java.lang.Integer i - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JInteger get i => const jni.JIntegerType().fromRef(_get_i(reference).object); /// from: public java.lang.Integer i - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. set i(jni.JInteger value) => _set_i(reference, value.reference).check(); static final _get_trillion = jniLookup< @@ -1440,12 +1440,12 @@ class Fields extends jni.JObject { jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); /// from: public java.lang.String bestFighterInGreece - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JString get bestFighterInGreece => const jni.JStringType() .fromRef(_get_bestFighterInGreece(reference).object); /// from: public java.lang.String bestFighterInGreece - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. set bestFighterInGreece(jni.JString value) => _set_bestFighterInGreece(reference, value.reference).check(); @@ -1467,12 +1467,12 @@ class Fields extends jni.JObject { jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); /// from: public java.util.Random random - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JObject get random => const jni.JObjectType().fromRef(_get_random(reference).object); /// from: public java.util.Random random - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. set random(jni.JObject value) => _set_random(reference, value.reference).check(); @@ -1497,7 +1497,7 @@ class Fields extends jni.JObject { .asFunction(); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory Fields() { return Fields.fromRef(_new0().object); } @@ -1573,12 +1573,12 @@ class Fields_Nested extends jni.JObject { .asFunction)>(); /// from: static public java.lang.String BEST_GOD - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString get BEST_GOD => const jni.JStringType().fromRef(_get_BEST_GOD().object); /// from: static public java.lang.String BEST_GOD - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static set BEST_GOD(jni.JString value) => _set_BEST_GOD(value.reference).check(); @@ -1587,7 +1587,7 @@ class Fields_Nested extends jni.JObject { .asFunction(); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory Fields_Nested() { return Fields_Nested.fromRef(_new0().object); } @@ -1651,7 +1651,7 @@ class C2 extends jni.JObject { .asFunction(); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory C2() { return C2.fromRef(_new0().object); } @@ -1697,7 +1697,7 @@ class Example1 extends jni.JObject { .asFunction(); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory Example1() { return Example1.fromRef(_new0().object); } @@ -1770,7 +1770,7 @@ class GenericTypeParams<$S extends jni.JObject, $K extends jni.JObject> .asFunction(); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory GenericTypeParams({ required jni.JObjType<$S> S, required jni.JObjType<$K> K, @@ -1854,11 +1854,11 @@ class GrandParent<$T extends jni.JObject> extends jni.JObject { jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); /// from: public T value - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $T get value => T.fromRef(_get_value(reference).object); /// from: public T value - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. set value($T value) => _set_value(reference, value.reference).check(); static final _new0 = jniLookup< @@ -1868,7 +1868,7 @@ class GrandParent<$T extends jni.JObject> extends jni.JObject { .asFunction)>(); /// from: public void (T value) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory GrandParent( $T value, { jni.JObjType<$T>? T, @@ -1886,7 +1886,7 @@ class GrandParent<$T extends jni.JObject> extends jni.JObject { .asFunction)>(); /// from: public com.github.dart_lang.jnigen.generics.GrandParent.Parent stringParent() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. GrandParent_Parent stringParent() { return const $GrandParent_ParentType(jni.JObjectType(), jni.JStringType()) .fromRef(_stringParent(reference).object); @@ -1901,7 +1901,7 @@ class GrandParent<$T extends jni.JObject> extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public com.github.dart_lang.jnigen.generics.GrandParent.Parent varParent(S nestedValue) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. GrandParent_Parent varParent<$S extends jni.JObject>( $S nestedValue, { jni.JObjType<$S>? S, @@ -1919,7 +1919,7 @@ class GrandParent<$T extends jni.JObject> extends jni.JObject { .asFunction(); /// from: static public com.github.dart_lang.jnigen.generics.GrandParent.StaticParent stringStaticParent() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static GrandParent_StaticParent stringStaticParent() { return const $GrandParent_StaticParentType(jni.JStringType()) .fromRef(_stringStaticParent().object); @@ -1932,7 +1932,7 @@ class GrandParent<$T extends jni.JObject> extends jni.JObject { .asFunction)>(); /// from: static public com.github.dart_lang.jnigen.generics.GrandParent.StaticParent varStaticParent(S value) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static GrandParent_StaticParent<$S> varStaticParent<$S extends jni.JObject>( $S value, { jni.JObjType<$S>? S, @@ -1951,7 +1951,7 @@ class GrandParent<$T extends jni.JObject> extends jni.JObject { .asFunction)>(); /// from: public com.github.dart_lang.jnigen.generics.GrandParent.StaticParent staticParentWithSameType() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. GrandParent_StaticParent<$T> staticParentWithSameType() { return $GrandParent_StaticParentType(T) .fromRef(_staticParentWithSameType(reference).object); @@ -2035,11 +2035,11 @@ class GrandParent_Parent<$T extends jni.JObject, $S extends jni.JObject> jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); /// from: public T parentValue - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $T get parentValue => T.fromRef(_get_parentValue(reference).object); /// from: public T parentValue - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. set parentValue($T value) => _set_parentValue(reference, value.reference).check(); @@ -2061,11 +2061,11 @@ class GrandParent_Parent<$T extends jni.JObject, $S extends jni.JObject> jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); /// from: public S value - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $S get value => S.fromRef(_get_value(reference).object); /// from: public S value - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. set value($S value) => _set_value(reference, value.reference).check(); static final _new0 = jniLookup< @@ -2077,7 +2077,7 @@ class GrandParent_Parent<$T extends jni.JObject, $S extends jni.JObject> ffi.Pointer, ffi.Pointer)>(); /// from: public void (com.github.dart_lang.jnigen.generics.GrandParent $parent, S newValue) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory GrandParent_Parent( GrandParent<$T> $parent, $S newValue, { @@ -2182,11 +2182,11 @@ class GrandParent_Parent_Child<$T extends jni.JObject, $S extends jni.JObject, jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); /// from: public T grandParentValue - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $T get grandParentValue => T.fromRef(_get_grandParentValue(reference).object); /// from: public T grandParentValue - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. set grandParentValue($T value) => _set_grandParentValue(reference, value.reference).check(); @@ -2209,11 +2209,11 @@ class GrandParent_Parent_Child<$T extends jni.JObject, $S extends jni.JObject, jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); /// from: public S parentValue - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $S get parentValue => S.fromRef(_get_parentValue(reference).object); /// from: public S parentValue - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. set parentValue($S value) => _set_parentValue(reference, value.reference).check(); @@ -2236,11 +2236,11 @@ class GrandParent_Parent_Child<$T extends jni.JObject, $S extends jni.JObject, jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); /// from: public U value - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $U get value => U.fromRef(_get_value(reference).object); /// from: public U value - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. set value($U value) => _set_value(reference, value.reference).check(); static final _new0 = jniLookup< @@ -2252,7 +2252,7 @@ class GrandParent_Parent_Child<$T extends jni.JObject, $S extends jni.JObject, ffi.Pointer, ffi.Pointer)>(); /// from: public void (com.github.dart_lang.jnigen.generics.GrandParent$Parent $parent, U newValue) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory GrandParent_Parent_Child( GrandParent_Parent<$T, $S> $parent, $U newValue, { @@ -2354,11 +2354,11 @@ class GrandParent_StaticParent<$S extends jni.JObject> extends jni.JObject { jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); /// from: public S value - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $S get value => S.fromRef(_get_value(reference).object); /// from: public S value - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. set value($S value) => _set_value(reference, value.reference).check(); static final _new0 = jniLookup< @@ -2368,7 +2368,7 @@ class GrandParent_StaticParent<$S extends jni.JObject> extends jni.JObject { .asFunction)>(); /// from: public void (S value) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory GrandParent_StaticParent( $S value, { jni.JObjType<$S>? S, @@ -2460,11 +2460,11 @@ class GrandParent_StaticParent_Child<$S extends jni.JObject, jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); /// from: public S parentValue - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $S get parentValue => S.fromRef(_get_parentValue(reference).object); /// from: public S parentValue - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. set parentValue($S value) => _set_parentValue(reference, value.reference).check(); @@ -2487,11 +2487,11 @@ class GrandParent_StaticParent_Child<$S extends jni.JObject, jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); /// from: public U value - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $U get value => U.fromRef(_get_value(reference).object); /// from: public U value - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. set value($U value) => _set_value(reference, value.reference).check(); static final _new0 = jniLookup< @@ -2504,7 +2504,7 @@ class GrandParent_StaticParent_Child<$S extends jni.JObject, ffi.Pointer)>(); /// from: public void (com.github.dart_lang.jnigen.generics.GrandParent$StaticParent $parent, S parentValue, U value) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory GrandParent_StaticParent_Child( GrandParent_StaticParent<$S> $parent, $S parentValue, @@ -2596,7 +2596,7 @@ class MyMap<$K extends jni.JObject, $V extends jni.JObject> .asFunction(); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory MyMap({ required jni.JObjType<$K> K, required jni.JObjType<$V> V, @@ -2613,7 +2613,7 @@ class MyMap<$K extends jni.JObject, $V extends jni.JObject> ffi.Pointer, ffi.Pointer)>(); /// from: public V get(K key) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $V get0( $K key, ) { @@ -2629,7 +2629,7 @@ class MyMap<$K extends jni.JObject, $V extends jni.JObject> ffi.Pointer)>(); /// from: public V put(K key, V value) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $V put( $K key, $V value, @@ -2644,7 +2644,7 @@ class MyMap<$K extends jni.JObject, $V extends jni.JObject> .asFunction)>(); /// from: public com.github.dart_lang.jnigen.generics.MyStack.MyEntry> entryStack() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. MyStack> entryStack() { return const $MyStackType( $MyMap_MyEntryType(jni.JObjectType(), jni.JObjectType())) @@ -2731,11 +2731,11 @@ class MyMap_MyEntry<$K extends jni.JObject, $V extends jni.JObject> jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); /// from: public K key - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $K get key => K.fromRef(_get_key(reference).object); /// from: public K key - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. set key($K value) => _set_key(reference, value.reference).check(); static final _get_value = jniLookup< @@ -2756,11 +2756,11 @@ class MyMap_MyEntry<$K extends jni.JObject, $V extends jni.JObject> jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); /// from: public V value - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $V get value => V.fromRef(_get_value(reference).object); /// from: public V value - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. set value($V value) => _set_value(reference, value.reference).check(); static final _new0 = jniLookup< @@ -2774,7 +2774,7 @@ class MyMap_MyEntry<$K extends jni.JObject, $V extends jni.JObject> ffi.Pointer)>(); /// from: public void (com.github.dart_lang.jnigen.generics.MyMap $parent, K key, V value) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory MyMap_MyEntry( MyMap<$K, $V> $parent, $K key, @@ -2857,7 +2857,7 @@ class MyStack<$T extends jni.JObject> extends jni.JObject { .asFunction(); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory MyStack({ required jni.JObjType<$T> T, }) { @@ -2871,7 +2871,7 @@ class MyStack<$T extends jni.JObject> extends jni.JObject { .asFunction)>(); /// from: static public com.github.dart_lang.jnigen.generics.MyStack fromArray(T[] arr) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static MyStack<$T> fromArray<$T extends jni.JObject>( jni.JArray<$T> arr, { jni.JObjType<$T>? T, @@ -2889,7 +2889,7 @@ class MyStack<$T extends jni.JObject> extends jni.JObject { .asFunction)>(); /// from: static public com.github.dart_lang.jnigen.generics.MyStack fromArrayOfArrayOfGrandParents(com.github.dart_lang.jnigen.generics.GrandParent[][] arr) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static MyStack<$S> fromArrayOfArrayOfGrandParents<$S extends jni.JObject>( jni.JArray>> arr, { jni.JObjType<$S>? S, @@ -2909,7 +2909,7 @@ class MyStack<$T extends jni.JObject> extends jni.JObject { .asFunction(); /// from: static public com.github.dart_lang.jnigen.generics.MyStack of() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static MyStack<$T> of<$T extends jni.JObject>({ required jni.JObjType<$T> T, }) { @@ -2923,7 +2923,7 @@ class MyStack<$T extends jni.JObject> extends jni.JObject { .asFunction)>(); /// from: static public com.github.dart_lang.jnigen.generics.MyStack of(T obj) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static MyStack<$T> of1<$T extends jni.JObject>( $T obj, { jni.JObjType<$T>? T, @@ -2943,7 +2943,7 @@ class MyStack<$T extends jni.JObject> extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: static public com.github.dart_lang.jnigen.generics.MyStack of(T obj, T obj2) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static MyStack<$T> of2<$T extends jni.JObject>( $T obj, $T obj2, { @@ -2978,7 +2978,7 @@ class MyStack<$T extends jni.JObject> extends jni.JObject { .asFunction)>(); /// from: public T pop() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $T pop() { return T.fromRef(_pop(reference).object); } @@ -3051,7 +3051,7 @@ class StringKeyedMap<$V extends jni.JObject> extends MyMap { .asFunction(); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory StringKeyedMap({ required jni.JObjType<$V> V, }) { @@ -3108,7 +3108,7 @@ class StringMap extends StringKeyedMap { .asFunction(); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory StringMap() { return StringMap.fromRef(_new0().object); } @@ -3154,7 +3154,7 @@ class StringStack extends MyStack { .asFunction(); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory StringStack() { return StringStack.fromRef(_new0().object); } @@ -3210,7 +3210,7 @@ class StringValuedMap<$K extends jni.JObject> extends MyMap<$K, jni.JString> { .asFunction(); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory StringValuedMap({ required jni.JObjType<$K> K, }) { @@ -3296,7 +3296,7 @@ class MyInterface<$T extends jni.JObject> extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public abstract java.lang.String stringCallback(java.lang.String s) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JString stringCallback( jni.JString s, ) { @@ -3313,7 +3313,7 @@ class MyInterface<$T extends jni.JObject> extends jni.JObject { ffi.Pointer, ffi.Pointer)>(); /// from: public abstract T varCallback(T t) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $T varCallback( $T t, ) { @@ -3372,40 +3372,40 @@ class MyInterface<$T extends jni.JObject> extends jni.JObject { $MethodInvocation $i, ) { try { - final $d = $i.methodDescriptor.toDartString(deleteOriginal: true); + final $d = $i.methodDescriptor.toDartString(releaseOriginal: true); final $a = $i.args; if ($d == r"voidCallback(Ljava/lang/String;)V") { _$impls[$p]!.voidCallback( - $a[0].castTo(const jni.JStringType(), deleteOriginal: true), + $a[0].castTo(const jni.JStringType(), releaseOriginal: true), ); return jni.nullptr; } if ($d == r"stringCallback(Ljava/lang/String;)Ljava/lang/String;") { final $r = _$impls[$p]!.stringCallback( - $a[0].castTo(const jni.JStringType(), deleteOriginal: true), + $a[0].castTo(const jni.JStringType(), releaseOriginal: true), ); return ($r as jni.JObject).castTo(const jni.JObjectType()).toPointer(); } if ($d == r"varCallback(Ljava/lang/Object;)Ljava/lang/Object;") { final $r = _$impls[$p]!.varCallback( - $a[0].castTo(_$impls[$p]!.T, deleteOriginal: true), + $a[0].castTo(_$impls[$p]!.T, releaseOriginal: true), ); return ($r as jni.JObject).castTo(const jni.JObjectType()).toPointer(); } if ($d == r"manyPrimitives(IZCD)J") { final $r = _$impls[$p]!.manyPrimitives( $a[0] - .castTo(const jni.JIntegerType(), deleteOriginal: true) - .intValue(deleteOriginal: true), + .castTo(const jni.JIntegerType(), releaseOriginal: true) + .intValue(releaseOriginal: true), $a[1] - .castTo(const jni.JBooleanType(), deleteOriginal: true) - .booleanValue(deleteOriginal: true), + .castTo(const jni.JBooleanType(), releaseOriginal: true) + .booleanValue(releaseOriginal: true), $a[2] - .castTo(const jni.JCharacterType(), deleteOriginal: true) - .charValue(deleteOriginal: true), + .castTo(const jni.JCharacterType(), releaseOriginal: true) + .charValue(releaseOriginal: true), $a[3] - .castTo(const jni.JDoubleType(), deleteOriginal: true) - .doubleValue(deleteOriginal: true), + .castTo(const jni.JDoubleType(), releaseOriginal: true) + .doubleValue(releaseOriginal: true), ); return jni.JLong($r).toPointer(); } @@ -3547,7 +3547,7 @@ class MyInterfaceConsumer extends jni.JObject { .asFunction(); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory MyInterfaceConsumer() { return MyInterfaceConsumer.fromRef(_new0().object); } @@ -3702,7 +3702,7 @@ class MyRunnable extends jni.JObject { $MethodInvocation $i, ) { try { - final $d = $i.methodDescriptor.toDartString(deleteOriginal: true); + final $d = $i.methodDescriptor.toDartString(releaseOriginal: true); final $a = $i.args; if ($d == r"run()V") { _$impls[$p]!.run(); @@ -3815,12 +3815,12 @@ class MyRunnableRunner extends jni.JObject { jni.JniResult Function(jni.JObjectPtr, ffi.Pointer)>(); /// from: public java.lang.Throwable error - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JObject get error => const jni.JObjectType().fromRef(_get_error(reference).object); /// from: public java.lang.Throwable error - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. set error(jni.JObject value) => _set_error(reference, value.reference).check(); @@ -3831,7 +3831,7 @@ class MyRunnableRunner extends jni.JObject { .asFunction)>(); /// from: public void (com.github.dart_lang.jnigen.interfaces.MyRunnable runnable) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory MyRunnableRunner( MyRunnable runnable, ) { @@ -3904,7 +3904,7 @@ class JsonSerializable_Case extends jni.JObject { .asFunction(); /// from: static public com.github.dart_lang.jnigen.annotations.JsonSerializable.Case[] values() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JArray values() { return const jni.JArrayType($JsonSerializable_CaseType()) .fromRef(_values().object); @@ -3917,7 +3917,7 @@ class JsonSerializable_Case extends jni.JObject { .asFunction)>(); /// from: static public com.github.dart_lang.jnigen.annotations.JsonSerializable.Case valueOf(java.lang.String name) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static JsonSerializable_Case valueOf( jni.JString name, ) { @@ -3969,7 +3969,7 @@ class MyDataClass extends jni.JObject { .asFunction(); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory MyDataClass() { return MyDataClass.fromRef(_new0().object); } diff --git a/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart index 7b36cdd3c..3c6d41bd7 100644 --- a/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart @@ -44,7 +44,7 @@ class Color extends jni.JObject { r"()[Lcom/github/dart_lang/jnigen/simple_package/Color;"); /// from: static public com.github.dart_lang.jnigen.simple_package.Color[] values() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JArray values() { return const jni.JArrayType($ColorType()).fromRef(jni.Jni.accessors .callStaticMethodWithArgs(_class.reference, _id_values, @@ -57,7 +57,7 @@ class Color extends jni.JObject { r"(Ljava/lang/String;)Lcom/github/dart_lang/jnigen/simple_package/Color;"); /// from: static public com.github.dart_lang.jnigen.simple_package.Color valueOf(java.lang.String name) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static Color valueOf( jni.JString name, ) { @@ -128,7 +128,7 @@ class Example extends jni.JObject { ); /// from: static public final java.util.Random unusedRandom - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JObject get unusedRandom => const jni.JObjectType().fromRef(jni.Jni.accessors .getStaticField( @@ -142,14 +142,14 @@ class Example extends jni.JObject { ); /// from: protected java.util.Random protectedField - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JObject get protectedField => const jni.JObjectType().fromRef(jni.Jni.accessors .getField(reference, _id_protectedField, jni.JniCallType.objectType) .object); /// from: protected java.util.Random protectedField - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. set protectedField(jni.JObject value) => jni.Jni.env .SetObjectField(reference, _id_protectedField, value.reference); @@ -184,7 +184,7 @@ class Example extends jni.JObject { _class.reference, r"getName", r"()Ljava/lang/String;"); /// from: static public java.lang.String getName() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString getName() { return const jni.JStringType().fromRef(jni.Jni.accessors .callStaticMethodWithArgs(_class.reference, _id_getName, @@ -197,7 +197,7 @@ class Example extends jni.JObject { r"()Lcom/github/dart_lang/jnigen/simple_package/Example$Nested;"); /// from: static public com.github.dart_lang.jnigen.simple_package.Example.Nested getNestedInstance() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static Example_Nested getNestedInstance() { return const $Example_NestedType().fromRef(jni.Jni.accessors .callStaticMethodWithArgs(_class.reference, _id_getNestedInstance, @@ -335,7 +335,7 @@ class Example extends jni.JObject { .getMethodIDOf(_class.reference, r"getCodename", r"()Ljava/lang/String;"); /// from: public java.lang.String getCodename() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JString getCodename() { return const jni.JStringType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getCodename, jni.JniCallType.objectType, []).object); @@ -356,7 +356,7 @@ class Example extends jni.JObject { .getMethodIDOf(_class.reference, r"getRandom", r"()Ljava/util/Random;"); /// from: public java.util.Random getRandom() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JObject getRandom() { return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getRandom, jni.JniCallType.objectType, []).object); @@ -420,7 +420,7 @@ class Example extends jni.JObject { r"(Ljava/util/Random;)Ljava/lang/String;"); /// from: public java.lang.String getRandomNumericString(java.util.Random random) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JString getRandomNumericString( jni.JObject random, ) { @@ -458,7 +458,7 @@ class Example extends jni.JObject { .getMethodIDOf(_class.reference, r"getList", r"()Ljava/util/List;"); /// from: public java.util.List getList() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JList getList() { return const jni.JListType(jni.JStringType()).fromRef(jni.Jni.accessors .callMethodWithArgs( @@ -471,7 +471,7 @@ class Example extends jni.JObject { r"(Ljava/util/List;Ljava/lang/String;)Ljava/lang/String;"); /// from: public java.lang.String joinStrings(java.util.List values, java.lang.String delim) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. /// /// Joins the strings in the list using the given delimiter. jni.JString joinStrings( @@ -519,7 +519,7 @@ class Example extends jni.JObject { jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory Example() { return Example.fromRef(jni.Jni.accessors .newObjectWithArgs(_class.reference, _id_new0, []).object); @@ -529,7 +529,7 @@ class Example extends jni.JObject { jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"(I)V"); /// from: public void (int number) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory Example.new1( int number, ) { @@ -541,7 +541,7 @@ class Example extends jni.JObject { jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"(IZ)V"); /// from: public void (int number, boolean isUp) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory Example.new2( int number, bool isUp, @@ -554,7 +554,7 @@ class Example extends jni.JObject { .getMethodIDOf(_class.reference, r"", r"(IZLjava/lang/String;)V"); /// from: public void (int number, boolean isUp, java.lang.String codename) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory Example.new3( int number, bool isUp, @@ -570,7 +570,7 @@ class Example extends jni.JObject { .getMethodIDOf(_class.reference, r"", r"(IIIIIIII)V"); /// from: public void (int a, int b, int c, int d, int e, int f, int g, int h) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory Example.new4( int a, int b, @@ -622,7 +622,7 @@ class Example extends jni.JObject { .getStaticMethodIDOf(_class.reference, r"getArr", r"()[I"); /// from: static public int[] getArr() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JArray getArr() { return const jni.JArrayType(jni.jintType()).fromRef(jni.Jni.accessors .callStaticMethodWithArgs(_class.reference, _id_getArr, @@ -644,7 +644,7 @@ class Example extends jni.JObject { r"getSelf", r"()Lcom/github/dart_lang/jnigen/simple_package/Example;"); /// from: public com.github.dart_lang.jnigen.simple_package.Example getSelf() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. Example getSelf() { return const $ExampleType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_getSelf, jni.JniCallType.objectType, []).object); @@ -760,7 +760,7 @@ class Example_Nested extends jni.JObject { jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"(Z)V"); /// from: public void (boolean value) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory Example_Nested( bool value, ) { @@ -857,7 +857,7 @@ class Example_Nested_NestedTwice extends jni.JObject { jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory Example_Nested_NestedTwice() { return Example_Nested_NestedTwice.fromRef(jni.Jni.accessors .newObjectWithArgs(_class.reference, _id_new0, []).object); @@ -925,7 +925,7 @@ class Example_NonStaticNested extends jni.JObject { r"", r"(Lcom/github/dart_lang/jnigen/simple_package/Example;)V"); /// from: public void (com.github.dart_lang.jnigen.simple_package.Example $parent) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory Example_NonStaticNested( Example $parent, ) { @@ -980,7 +980,7 @@ class Exceptions extends jni.JObject { jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory Exceptions() { return Exceptions.fromRef(jni.Jni.accessors .newObjectWithArgs(_class.reference, _id_new0, []).object); @@ -990,7 +990,7 @@ class Exceptions extends jni.JObject { jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"(F)V"); /// from: public void (float x) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory Exceptions.new1( double x, ) { @@ -1002,7 +1002,7 @@ class Exceptions extends jni.JObject { .getMethodIDOf(_class.reference, r"", r"(IIIIII)V"); /// from: public void (int a, int b, int c, int d, int e, int f) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory Exceptions.new2( int a, int b, @@ -1026,7 +1026,7 @@ class Exceptions extends jni.JObject { _class.reference, r"staticObjectMethod", r"()Ljava/lang/Object;"); /// from: static public java.lang.Object staticObjectMethod() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JObject staticObjectMethod() { return const jni.JObjectType().fromRef(jni.Jni.accessors .callStaticMethodWithArgs(_class.reference, _id_staticObjectMethod, @@ -1047,7 +1047,7 @@ class Exceptions extends jni.JObject { r"()[Ljava/lang/Object;"); /// from: static public java.lang.Object[] staticObjectArrayMethod() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JArray staticObjectArrayMethod() { return const jni.JArrayType(jni.JObjectType()).fromRef(jni.Jni.accessors .callStaticMethodWithArgs(_class.reference, _id_staticObjectArrayMethod, @@ -1058,7 +1058,7 @@ class Exceptions extends jni.JObject { .getStaticMethodIDOf(_class.reference, r"staticIntArrayMethod", r"()[I"); /// from: static public int[] staticIntArrayMethod() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JArray staticIntArrayMethod() { return const jni.JArrayType(jni.jintType()).fromRef(jni.Jni.accessors .callStaticMethodWithArgs(_class.reference, _id_staticIntArrayMethod, @@ -1069,7 +1069,7 @@ class Exceptions extends jni.JObject { _class.reference, r"objectMethod", r"()Ljava/lang/Object;"); /// from: public java.lang.Object objectMethod() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JObject objectMethod() { return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_objectMethod, jni.JniCallType.objectType, []).object); @@ -1088,7 +1088,7 @@ class Exceptions extends jni.JObject { _class.reference, r"objectArrayMethod", r"()[Ljava/lang/Object;"); /// from: public java.lang.Object[] objectArrayMethod() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JArray objectArrayMethod() { return const jni.JArrayType(jni.JObjectType()).fromRef(jni.Jni.accessors .callMethodWithArgs(reference, _id_objectArrayMethod, @@ -1099,7 +1099,7 @@ class Exceptions extends jni.JObject { .getMethodIDOf(_class.reference, r"intArrayMethod", r"()[I"); /// from: public int[] intArrayMethod() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JArray intArrayMethod() { return const jni.JArrayType(jni.jintType()).fromRef(jni.Jni.accessors .callMethodWithArgs(reference, _id_intArrayMethod, @@ -1121,7 +1121,7 @@ class Exceptions extends jni.JObject { r"()Ljava/io/InputStream;"); /// from: public java.io.InputStream throwFileNotFoundException() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JObject throwFileNotFoundException() { return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, @@ -1135,7 +1135,7 @@ class Exceptions extends jni.JObject { r"()Ljava/io/FileInputStream;"); /// from: public java.io.FileInputStream throwClassCastException() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JObject throwClassCastException() { return const jni.JObjectType().fromRef(jni.Jni.accessors.callMethodWithArgs( reference, @@ -1262,14 +1262,14 @@ class Fields extends jni.JObject { ); /// from: static public java.lang.String name - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString get name => const jni.JStringType().fromRef(jni .Jni.accessors .getStaticField(_class.reference, _id_name, jni.JniCallType.objectType) .object); /// from: static public java.lang.String name - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static set name(jni.JString value) => jni.Jni.env .SetStaticObjectField(_class.reference, _id_name, value.reference); @@ -1280,13 +1280,13 @@ class Fields extends jni.JObject { ); /// from: public java.lang.Integer i - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JInteger get i => const jni.JIntegerType().fromRef(jni.Jni.accessors .getField(reference, _id_i, jni.JniCallType.objectType) .object); /// from: public java.lang.Integer i - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. set i(jni.JInteger value) => jni.Jni.env.SetObjectField(reference, _id_i, value.reference); @@ -1327,14 +1327,14 @@ class Fields extends jni.JObject { ); /// from: public java.lang.String bestFighterInGreece - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JString get bestFighterInGreece => const jni.JStringType().fromRef(jni .Jni.accessors .getField(reference, _id_bestFighterInGreece, jni.JniCallType.objectType) .object); /// from: public java.lang.String bestFighterInGreece - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. set bestFighterInGreece(jni.JString value) => jni.Jni.env .SetObjectField(reference, _id_bestFighterInGreece, value.reference); @@ -1345,13 +1345,13 @@ class Fields extends jni.JObject { ); /// from: public java.util.Random random - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JObject get random => const jni.JObjectType().fromRef(jni.Jni.accessors .getField(reference, _id_random, jni.JniCallType.objectType) .object); /// from: public java.util.Random random - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. set random(jni.JObject value) => jni.Jni.env.SetObjectField(reference, _id_random, value.reference); @@ -1375,7 +1375,7 @@ class Fields extends jni.JObject { jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory Fields() { return Fields.fromRef(jni.Jni.accessors .newObjectWithArgs(_class.reference, _id_new0, []).object); @@ -1443,7 +1443,7 @@ class Fields_Nested extends jni.JObject { ); /// from: static public java.lang.String BEST_GOD - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JString get BEST_GOD => const jni.JStringType().fromRef(jni.Jni.accessors .getStaticField( @@ -1451,7 +1451,7 @@ class Fields_Nested extends jni.JObject { .object); /// from: static public java.lang.String BEST_GOD - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static set BEST_GOD(jni.JString value) => jni.Jni.env .SetStaticObjectField(_class.reference, _id_BEST_GOD, value.reference); @@ -1459,7 +1459,7 @@ class Fields_Nested extends jni.JObject { jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory Fields_Nested() { return Fields_Nested.fromRef(jni.Jni.accessors .newObjectWithArgs(_class.reference, _id_new0, []).object); @@ -1525,7 +1525,7 @@ class C2 extends jni.JObject { jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory C2() { return C2.fromRef(jni.Jni.accessors .newObjectWithArgs(_class.reference, _id_new0, []).object); @@ -1574,7 +1574,7 @@ class Example1 extends jni.JObject { jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory Example1() { return Example1.fromRef(jni.Jni.accessors .newObjectWithArgs(_class.reference, _id_new0, []).object); @@ -1648,7 +1648,7 @@ class GenericTypeParams<$S extends jni.JObject, $K extends jni.JObject> jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory GenericTypeParams({ required jni.JObjType<$S> S, required jni.JObjType<$K> K, @@ -1728,13 +1728,13 @@ class GrandParent<$T extends jni.JObject> extends jni.JObject { ); /// from: public T value - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $T get value => T.fromRef(jni.Jni.accessors .getField(reference, _id_value, jni.JniCallType.objectType) .object); /// from: public T value - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. set value($T value) => jni.Jni.env.SetObjectField(reference, _id_value, value.reference); @@ -1742,7 +1742,7 @@ class GrandParent<$T extends jni.JObject> extends jni.JObject { .getMethodIDOf(_class.reference, r"", r"(Ljava/lang/Object;)V"); /// from: public void (T value) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory GrandParent( $T value, { jni.JObjType<$T>? T, @@ -1762,7 +1762,7 @@ class GrandParent<$T extends jni.JObject> extends jni.JObject { r"()Lcom/github/dart_lang/jnigen/generics/GrandParent$Parent;"); /// from: public com.github.dart_lang.jnigen.generics.GrandParent.Parent stringParent() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. GrandParent_Parent stringParent() { return const $GrandParent_ParentType(jni.JObjectType(), jni.JStringType()) .fromRef(jni.Jni.accessors.callMethodWithArgs(reference, @@ -1775,7 +1775,7 @@ class GrandParent<$T extends jni.JObject> extends jni.JObject { r"(Ljava/lang/Object;)Lcom/github/dart_lang/jnigen/generics/GrandParent$Parent;"); /// from: public com.github.dart_lang.jnigen.generics.GrandParent.Parent varParent(S nestedValue) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. GrandParent_Parent varParent<$S extends jni.JObject>( $S nestedValue, { jni.JObjType<$S>? S, @@ -1794,7 +1794,7 @@ class GrandParent<$T extends jni.JObject> extends jni.JObject { r"()Lcom/github/dart_lang/jnigen/generics/GrandParent$StaticParent;"); /// from: static public com.github.dart_lang.jnigen.generics.GrandParent.StaticParent stringStaticParent() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static GrandParent_StaticParent stringStaticParent() { return const $GrandParent_StaticParentType(jni.JStringType()).fromRef( jni.Jni.accessors.callStaticMethodWithArgs(_class.reference, @@ -1807,7 +1807,7 @@ class GrandParent<$T extends jni.JObject> extends jni.JObject { r"(Ljava/lang/Object;)Lcom/github/dart_lang/jnigen/generics/GrandParent$StaticParent;"); /// from: static public com.github.dart_lang.jnigen.generics.GrandParent.StaticParent varStaticParent(S value) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static GrandParent_StaticParent<$S> varStaticParent<$S extends jni.JObject>( $S value, { jni.JObjType<$S>? S, @@ -1826,7 +1826,7 @@ class GrandParent<$T extends jni.JObject> extends jni.JObject { r"()Lcom/github/dart_lang/jnigen/generics/GrandParent$StaticParent;"); /// from: public com.github.dart_lang.jnigen.generics.GrandParent.StaticParent staticParentWithSameType() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. GrandParent_StaticParent<$T> staticParentWithSameType() { return $GrandParent_StaticParentType(T).fromRef(jni.Jni.accessors .callMethodWithArgs(reference, _id_staticParentWithSameType, @@ -1902,13 +1902,13 @@ class GrandParent_Parent<$T extends jni.JObject, $S extends jni.JObject> ); /// from: public T parentValue - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $T get parentValue => T.fromRef(jni.Jni.accessors .getField(reference, _id_parentValue, jni.JniCallType.objectType) .object); /// from: public T parentValue - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. set parentValue($T value) => jni.Jni.env.SetObjectField(reference, _id_parentValue, value.reference); @@ -1919,13 +1919,13 @@ class GrandParent_Parent<$T extends jni.JObject, $S extends jni.JObject> ); /// from: public S value - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $S get value => S.fromRef(jni.Jni.accessors .getField(reference, _id_value, jni.JniCallType.objectType) .object); /// from: public S value - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. set value($S value) => jni.Jni.env.SetObjectField(reference, _id_value, value.reference); @@ -1935,7 +1935,7 @@ class GrandParent_Parent<$T extends jni.JObject, $S extends jni.JObject> r"(Lcom/github/dart_lang/jnigen/generics/GrandParent;Ljava/lang/Object;)V"); /// from: public void (com.github.dart_lang.jnigen.generics.GrandParent $parent, S newValue) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory GrandParent_Parent( GrandParent<$T> $parent, $S newValue, { @@ -2034,13 +2034,13 @@ class GrandParent_Parent_Child<$T extends jni.JObject, $S extends jni.JObject, ); /// from: public T grandParentValue - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $T get grandParentValue => T.fromRef(jni.Jni.accessors .getField(reference, _id_grandParentValue, jni.JniCallType.objectType) .object); /// from: public T grandParentValue - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. set grandParentValue($T value) => jni.Jni.env .SetObjectField(reference, _id_grandParentValue, value.reference); @@ -2051,13 +2051,13 @@ class GrandParent_Parent_Child<$T extends jni.JObject, $S extends jni.JObject, ); /// from: public S parentValue - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $S get parentValue => S.fromRef(jni.Jni.accessors .getField(reference, _id_parentValue, jni.JniCallType.objectType) .object); /// from: public S parentValue - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. set parentValue($S value) => jni.Jni.env.SetObjectField(reference, _id_parentValue, value.reference); @@ -2068,13 +2068,13 @@ class GrandParent_Parent_Child<$T extends jni.JObject, $S extends jni.JObject, ); /// from: public U value - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $U get value => U.fromRef(jni.Jni.accessors .getField(reference, _id_value, jni.JniCallType.objectType) .object); /// from: public U value - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. set value($U value) => jni.Jni.env.SetObjectField(reference, _id_value, value.reference); @@ -2084,7 +2084,7 @@ class GrandParent_Parent_Child<$T extends jni.JObject, $S extends jni.JObject, r"(Lcom/github/dart_lang/jnigen/generics/GrandParent$Parent;Ljava/lang/Object;)V"); /// from: public void (com.github.dart_lang.jnigen.generics.GrandParent$Parent $parent, U newValue) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory GrandParent_Parent_Child( GrandParent_Parent<$T, $S> $parent, $U newValue, { @@ -2181,13 +2181,13 @@ class GrandParent_StaticParent<$S extends jni.JObject> extends jni.JObject { ); /// from: public S value - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $S get value => S.fromRef(jni.Jni.accessors .getField(reference, _id_value, jni.JniCallType.objectType) .object); /// from: public S value - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. set value($S value) => jni.Jni.env.SetObjectField(reference, _id_value, value.reference); @@ -2195,7 +2195,7 @@ class GrandParent_StaticParent<$S extends jni.JObject> extends jni.JObject { .getMethodIDOf(_class.reference, r"", r"(Ljava/lang/Object;)V"); /// from: public void (S value) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory GrandParent_StaticParent( $S value, { jni.JObjType<$S>? S, @@ -2281,13 +2281,13 @@ class GrandParent_StaticParent_Child<$S extends jni.JObject, ); /// from: public S parentValue - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $S get parentValue => S.fromRef(jni.Jni.accessors .getField(reference, _id_parentValue, jni.JniCallType.objectType) .object); /// from: public S parentValue - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. set parentValue($S value) => jni.Jni.env.SetObjectField(reference, _id_parentValue, value.reference); @@ -2298,13 +2298,13 @@ class GrandParent_StaticParent_Child<$S extends jni.JObject, ); /// from: public U value - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $U get value => U.fromRef(jni.Jni.accessors .getField(reference, _id_value, jni.JniCallType.objectType) .object); /// from: public U value - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. set value($U value) => jni.Jni.env.SetObjectField(reference, _id_value, value.reference); @@ -2314,7 +2314,7 @@ class GrandParent_StaticParent_Child<$S extends jni.JObject, r"(Lcom/github/dart_lang/jnigen/generics/GrandParent$StaticParent;Ljava/lang/Object;Ljava/lang/Object;)V"); /// from: public void (com.github.dart_lang.jnigen.generics.GrandParent$StaticParent $parent, S parentValue, U value) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory GrandParent_StaticParent_Child( GrandParent_StaticParent<$S> $parent, $S parentValue, @@ -2411,7 +2411,7 @@ class MyMap<$K extends jni.JObject, $V extends jni.JObject> jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory MyMap({ required jni.JObjType<$K> K, required jni.JObjType<$V> V, @@ -2427,7 +2427,7 @@ class MyMap<$K extends jni.JObject, $V extends jni.JObject> _class.reference, r"get", r"(Ljava/lang/Object;)Ljava/lang/Object;"); /// from: public V get(K key) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $V get0( $K key, ) { @@ -2439,7 +2439,7 @@ class MyMap<$K extends jni.JObject, $V extends jni.JObject> r"put", r"(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); /// from: public V put(K key, V value) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $V put( $K key, $V value, @@ -2454,7 +2454,7 @@ class MyMap<$K extends jni.JObject, $V extends jni.JObject> r"()Lcom/github/dart_lang/jnigen/generics/MyStack;"); /// from: public com.github.dart_lang.jnigen.generics.MyStack.MyEntry> entryStack() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. MyStack> entryStack() { return const $MyStackType( $MyMap_MyEntryType(jni.JObjectType(), jni.JObjectType())) @@ -2534,13 +2534,13 @@ class MyMap_MyEntry<$K extends jni.JObject, $V extends jni.JObject> ); /// from: public K key - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $K get key => K.fromRef(jni.Jni.accessors .getField(reference, _id_key, jni.JniCallType.objectType) .object); /// from: public K key - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. set key($K value) => jni.Jni.env.SetObjectField(reference, _id_key, value.reference); @@ -2551,13 +2551,13 @@ class MyMap_MyEntry<$K extends jni.JObject, $V extends jni.JObject> ); /// from: public V value - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $V get value => V.fromRef(jni.Jni.accessors .getField(reference, _id_value, jni.JniCallType.objectType) .object); /// from: public V value - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. set value($V value) => jni.Jni.env.SetObjectField(reference, _id_value, value.reference); @@ -2567,7 +2567,7 @@ class MyMap_MyEntry<$K extends jni.JObject, $V extends jni.JObject> r"(Lcom/github/dart_lang/jnigen/generics/MyMap;Ljava/lang/Object;Ljava/lang/Object;)V"); /// from: public void (com.github.dart_lang.jnigen.generics.MyMap $parent, K key, V value) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory MyMap_MyEntry( MyMap<$K, $V> $parent, $K key, @@ -2655,7 +2655,7 @@ class MyStack<$T extends jni.JObject> extends jni.JObject { jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory MyStack({ required jni.JObjType<$T> T, }) { @@ -2671,7 +2671,7 @@ class MyStack<$T extends jni.JObject> extends jni.JObject { r"([Ljava/lang/Object;)Lcom/github/dart_lang/jnigen/generics/MyStack;"); /// from: static public com.github.dart_lang.jnigen.generics.MyStack fromArray(T[] arr) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static MyStack<$T> fromArray<$T extends jni.JObject>( jni.JArray<$T> arr, { jni.JObjType<$T>? T, @@ -2691,7 +2691,7 @@ class MyStack<$T extends jni.JObject> extends jni.JObject { r"([[Lcom/github/dart_lang/jnigen/generics/GrandParent;)Lcom/github/dart_lang/jnigen/generics/MyStack;"); /// from: static public com.github.dart_lang.jnigen.generics.MyStack fromArrayOfArrayOfGrandParents(com.github.dart_lang.jnigen.generics.GrandParent[][] arr) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static MyStack<$S> fromArrayOfArrayOfGrandParents<$S extends jni.JObject>( jni.JArray>> arr, { jni.JObjType<$S>? S, @@ -2713,7 +2713,7 @@ class MyStack<$T extends jni.JObject> extends jni.JObject { r"of", r"()Lcom/github/dart_lang/jnigen/generics/MyStack;"); /// from: static public com.github.dart_lang.jnigen.generics.MyStack of() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static MyStack<$T> of<$T extends jni.JObject>({ required jni.JObjType<$T> T, }) { @@ -2727,7 +2727,7 @@ class MyStack<$T extends jni.JObject> extends jni.JObject { r"(Ljava/lang/Object;)Lcom/github/dart_lang/jnigen/generics/MyStack;"); /// from: static public com.github.dart_lang.jnigen.generics.MyStack of(T obj) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static MyStack<$T> of1<$T extends jni.JObject>( $T obj, { jni.JObjType<$T>? T, @@ -2748,7 +2748,7 @@ class MyStack<$T extends jni.JObject> extends jni.JObject { r"(Ljava/lang/Object;Ljava/lang/Object;)Lcom/github/dart_lang/jnigen/generics/MyStack;"); /// from: static public com.github.dart_lang.jnigen.generics.MyStack of(T obj, T obj2) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static MyStack<$T> of2<$T extends jni.JObject>( $T obj, $T obj2, { @@ -2780,7 +2780,7 @@ class MyStack<$T extends jni.JObject> extends jni.JObject { .getMethodIDOf(_class.reference, r"pop", r"()Ljava/lang/Object;"); /// from: public T pop() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $T pop() { return T.fromRef(jni.Jni.accessors.callMethodWithArgs( reference, _id_pop, jni.JniCallType.objectType, []).object); @@ -2854,7 +2854,7 @@ class StringKeyedMap<$V extends jni.JObject> extends MyMap { jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory StringKeyedMap({ required jni.JObjType<$V> V, }) { @@ -2916,7 +2916,7 @@ class StringMap extends StringKeyedMap { jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory StringMap() { return StringMap.fromRef(jni.Jni.accessors .newObjectWithArgs(_class.reference, _id_new0, []).object); @@ -2965,7 +2965,7 @@ class StringStack extends MyStack { jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory StringStack() { return StringStack.fromRef(jni.Jni.accessors .newObjectWithArgs(_class.reference, _id_new0, []).object); @@ -3024,7 +3024,7 @@ class StringValuedMap<$K extends jni.JObject> extends MyMap<$K, jni.JString> { jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory StringValuedMap({ required jni.JObjType<$K> K, }) { @@ -3109,7 +3109,7 @@ class MyInterface<$T extends jni.JObject> extends jni.JObject { r"(Ljava/lang/String;)Ljava/lang/String;"); /// from: public abstract java.lang.String stringCallback(java.lang.String s) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JString stringCallback( jni.JString s, ) { @@ -3126,7 +3126,7 @@ class MyInterface<$T extends jni.JObject> extends jni.JObject { r"(Ljava/lang/Object;)Ljava/lang/Object;"); /// from: public abstract T varCallback(T t) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. $T varCallback( $T t, ) { @@ -3181,40 +3181,40 @@ class MyInterface<$T extends jni.JObject> extends jni.JObject { $MethodInvocation $i, ) { try { - final $d = $i.methodDescriptor.toDartString(deleteOriginal: true); + final $d = $i.methodDescriptor.toDartString(releaseOriginal: true); final $a = $i.args; if ($d == r"voidCallback(Ljava/lang/String;)V") { _$impls[$p]!.voidCallback( - $a[0].castTo(const jni.JStringType(), deleteOriginal: true), + $a[0].castTo(const jni.JStringType(), releaseOriginal: true), ); return jni.nullptr; } if ($d == r"stringCallback(Ljava/lang/String;)Ljava/lang/String;") { final $r = _$impls[$p]!.stringCallback( - $a[0].castTo(const jni.JStringType(), deleteOriginal: true), + $a[0].castTo(const jni.JStringType(), releaseOriginal: true), ); return ($r as jni.JObject).castTo(const jni.JObjectType()).toPointer(); } if ($d == r"varCallback(Ljava/lang/Object;)Ljava/lang/Object;") { final $r = _$impls[$p]!.varCallback( - $a[0].castTo(_$impls[$p]!.T, deleteOriginal: true), + $a[0].castTo(_$impls[$p]!.T, releaseOriginal: true), ); return ($r as jni.JObject).castTo(const jni.JObjectType()).toPointer(); } if ($d == r"manyPrimitives(IZCD)J") { final $r = _$impls[$p]!.manyPrimitives( $a[0] - .castTo(const jni.JIntegerType(), deleteOriginal: true) - .intValue(deleteOriginal: true), + .castTo(const jni.JIntegerType(), releaseOriginal: true) + .intValue(releaseOriginal: true), $a[1] - .castTo(const jni.JBooleanType(), deleteOriginal: true) - .booleanValue(deleteOriginal: true), + .castTo(const jni.JBooleanType(), releaseOriginal: true) + .booleanValue(releaseOriginal: true), $a[2] - .castTo(const jni.JCharacterType(), deleteOriginal: true) - .charValue(deleteOriginal: true), + .castTo(const jni.JCharacterType(), releaseOriginal: true) + .charValue(releaseOriginal: true), $a[3] - .castTo(const jni.JDoubleType(), deleteOriginal: true) - .doubleValue(deleteOriginal: true), + .castTo(const jni.JDoubleType(), releaseOriginal: true) + .doubleValue(releaseOriginal: true), ); return jni.JLong($r).toPointer(); } @@ -3358,7 +3358,7 @@ class MyInterfaceConsumer extends jni.JObject { jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory MyInterfaceConsumer() { return MyInterfaceConsumer.fromRef(jni.Jni.accessors .newObjectWithArgs(_class.reference, _id_new0, []).object); @@ -3509,7 +3509,7 @@ class MyRunnable extends jni.JObject { $MethodInvocation $i, ) { try { - final $d = $i.methodDescriptor.toDartString(deleteOriginal: true); + final $d = $i.methodDescriptor.toDartString(releaseOriginal: true); final $a = $i.args; if ($d == r"run()V") { _$impls[$p]!.run(); @@ -3614,13 +3614,13 @@ class MyRunnableRunner extends jni.JObject { ); /// from: public java.lang.Throwable error - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. jni.JObject get error => const jni.JObjectType().fromRef(jni.Jni.accessors .getField(reference, _id_error, jni.JniCallType.objectType) .object); /// from: public java.lang.Throwable error - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. set error(jni.JObject value) => jni.Jni.env.SetObjectField(reference, _id_error, value.reference); @@ -3628,7 +3628,7 @@ class MyRunnableRunner extends jni.JObject { r"", r"(Lcom/github/dart_lang/jnigen/interfaces/MyRunnable;)V"); /// from: public void (com.github.dart_lang.jnigen.interfaces.MyRunnable runnable) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory MyRunnableRunner( MyRunnable runnable, ) { @@ -3701,7 +3701,7 @@ class JsonSerializable_Case extends jni.JObject { r"()[Lcom/github/dart_lang/jnigen/annotations/JsonSerializable$Case;"); /// from: static public com.github.dart_lang.jnigen.annotations.JsonSerializable.Case[] values() - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static jni.JArray values() { return const jni.JArrayType($JsonSerializable_CaseType()).fromRef( jni.Jni.accessors.callStaticMethodWithArgs(_class.reference, _id_values, @@ -3714,7 +3714,7 @@ class JsonSerializable_Case extends jni.JObject { r"(Ljava/lang/String;)Lcom/github/dart_lang/jnigen/annotations/JsonSerializable$Case;"); /// from: static public com.github.dart_lang.jnigen.annotations.JsonSerializable.Case valueOf(java.lang.String name) - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. static JsonSerializable_Case valueOf( jni.JString name, ) { @@ -3769,7 +3769,7 @@ class MyDataClass extends jni.JObject { jni.Jni.accessors.getMethodIDOf(_class.reference, r"", r"()V"); /// from: public void () - /// The returned object must be deleted after use, by calling the `delete` method. + /// The returned object must be released after use, by calling the [release] method. factory MyDataClass() { return MyDataClass.fromRef(jni.Jni.accessors .newObjectWithArgs(_class.reference, _id_new0, []).object); 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 07ed1d3ae..3791f9e45 100644 --- a/pkgs/jnigen/test/simple_package_test/runtime_test_registrant.dart +++ b/pkgs/jnigen/test/simple_package_test/runtime_test_registrant.dart @@ -51,12 +51,12 @@ void registerTests(String groupName, TestRunnerCallback test) { test('Static fields & methods - string', () { expect( - Example.getName().toDartString(deleteOriginal: true), + Example.getName().toDartString(releaseOriginal: true), isIn(["Ragnar Lothbrok", "Theseus"]), ); Example.setName("Theseus".toJString()); expect( - Example.getName().toDartString(deleteOriginal: true), + Example.getName().toDartString(releaseOriginal: true), equals("Theseus"), ); }); @@ -85,7 +85,7 @@ void registerTests(String groupName, TestRunnerCallback test) { expect(e.getIsUp(), false); expect(e.getNumber(), 1); expect(e.getCodename().toDartString(), equals("spartan")); - e.delete(); + e.release(); }); test('Instance methods with several arguments', () { @@ -101,7 +101,7 @@ void registerTests(String groupName, TestRunnerCallback test) { -trillion, -trillion, -trillion), equals(2 * -trillion), ); - e.delete(); + e.release(); }); test('Misc. instance methods', () { @@ -110,14 +110,14 @@ void registerTests(String groupName, TestRunnerCallback test) { expect(rand.isNull, isFalse); final _ = e.getRandomLong(); final id = - e.getRandomNumericString(rand).toDartString(deleteOriginal: true); + e.getRandomNumericString(rand).toDartString(releaseOriginal: true); expect(int.parse(id), lessThan(10000)); e.setNumber(145); expect( e.getSelf().getSelf().getSelf().getSelf().getNumber(), equals(145), ); - e.delete(); + e.release(); }); test('Constructors', () { @@ -200,9 +200,9 @@ void registerTests(String groupName, TestRunnerCallback test) { array[1] = ex2; expect(array[0].getNumber(), 1); expect(array[1].getNumber(), 2); - array.delete(); - ex1.delete(); - ex2.delete(); + array.release(); + ex1.release(); + ex2.release(); }); test("Check bindings for same-named classes", () { @@ -262,28 +262,31 @@ void registerTests(String groupName, TestRunnerCallback test) { group('generics', () { test('GrandParent constructor', () { using((arena) { - final grandParent = GrandParent('Hello'.toJString()..deletedIn(arena)) - ..deletedIn(arena); + final grandParent = + GrandParent('Hello'.toJString()..releasedBy(arena)) + ..releasedBy(arena); expect(grandParent, isA>()); expect(grandParent.$type, isA<$GrandParentType>()); - expect(grandParent.value.toDartString(deleteOriginal: true), 'Hello'); + expect( + grandParent.value.toDartString(releaseOriginal: true), 'Hello'); }); }); test('MyStack', () { using((arena) { - final stack = MyStack(T: JString.type)..deletedIn(arena); - stack.push('Hello'.toJString()..deletedIn(arena)); - stack.push('World'.toJString()..deletedIn(arena)); - expect(stack.pop().toDartString(deleteOriginal: true), 'World'); - expect(stack.pop().toDartString(deleteOriginal: true), 'Hello'); + final stack = MyStack(T: JString.type)..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)..deletedIn(arena); - final anotherStringStack = MyStack(T: JString.type)..deletedIn(arena); - final anObjectStack = MyStack(T: JObject.type)..deletedIn(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, @@ -298,26 +301,29 @@ void registerTests(String groupName, TestRunnerCallback test) { }); test('MyMap', () { using((arena) { - final map = MyMap(K: JString.type, V: Example.type)..deletedIn(arena); - final helloExample = Example.new1(1)..deletedIn(arena); - final worldExample = Example.new1(2)..deletedIn(arena); - map.put('Hello'.toJString()..deletedIn(arena), helloExample); - map.put('World'.toJString()..deletedIn(arena), worldExample); + final map = MyMap(K: JString.type, V: Example.type) + ..releasedBy(arena); + final helloExample = Example.new1(1)..releasedBy(arena); + final worldExample = Example.new1(2)..releasedBy(arena); + map.put('Hello'.toJString()..releasedBy(arena), helloExample); + map.put('World'.toJString()..releasedBy(arena), worldExample); expect( - (map.get0('Hello'.toJString()..deletedIn(arena))..deletedIn(arena)) + (map.get0('Hello'.toJString()..releasedBy(arena)) + ..releasedBy(arena)) .getNumber(), 1, ); expect( - (map.get0('World'.toJString()..deletedIn(arena))..deletedIn(arena)) + (map.get0('World'.toJString()..releasedBy(arena)) + ..releasedBy(arena)) .getNumber(), 2, ); expect( - ((map.entryStack()..deletedIn(arena)).pop()..deletedIn(arena)) + ((map.entryStack()..releasedBy(arena)).pop()..releasedBy(arena)) .key - .castTo(JString.type, deleteOriginal: true) - .toDartString(deleteOriginal: true), + .castTo(JString.type, releaseOriginal: true) + .toDartString(releaseOriginal: true), anyOf('Hello', 'World'), ); }); @@ -325,20 +331,20 @@ void registerTests(String groupName, TestRunnerCallback test) { group('classes extending generics', () { test('StringStack', () { using((arena) { - final stringStack = StringStack()..deletedIn(arena); - stringStack.push('Hello'.toJString()..deletedIn(arena)); + final stringStack = StringStack()..releasedBy(arena); + stringStack.push('Hello'.toJString()..releasedBy(arena)); expect( - stringStack.pop().toDartString(deleteOriginal: true), 'Hello'); + stringStack.pop().toDartString(releaseOriginal: true), 'Hello'); }); }); test('StringKeyedMap', () { using((arena) { - final map = StringKeyedMap(V: Example.type)..deletedIn(arena); - final example = Example()..deletedIn(arena); - map.put('Hello'.toJString()..deletedIn(arena), example); + final map = StringKeyedMap(V: Example.type)..releasedBy(arena); + final example = Example()..releasedBy(arena); + map.put('Hello'.toJString()..releasedBy(arena), example); expect( - (map.get0('Hello'.toJString()..deletedIn(arena)) - ..deletedIn(arena)) + (map.get0('Hello'.toJString()..releasedBy(arena)) + ..releasedBy(arena)) .getNumber(), 0, ); @@ -346,24 +352,24 @@ void registerTests(String groupName, TestRunnerCallback test) { }); test('StringValuedMap', () { using((arena) { - final map = StringValuedMap(K: Example.type)..deletedIn(arena); - final example = Example()..deletedIn(arena); - map.put(example, 'Hello'.toJString()..deletedIn(arena)); + final map = StringValuedMap(K: Example.type)..releasedBy(arena); + final example = Example()..releasedBy(arena); + map.put(example, 'Hello'.toJString()..releasedBy(arena)); expect( - map.get0(example).toDartString(deleteOriginal: true), + map.get0(example).toDartString(releaseOriginal: true), 'Hello', ); }); }); test('StringMap', () { using((arena) { - final map = StringMap()..deletedIn(arena); - map.put('hello'.toJString()..deletedIn(arena), - 'world'.toJString()..deletedIn(arena)); + final map = StringMap()..releasedBy(arena); + map.put('hello'.toJString()..releasedBy(arena), + 'world'.toJString()..releasedBy(arena)); expect( map - .get0('hello'.toJString()..deletedIn(arena)) - .toDartString(deleteOriginal: true), + .get0('hello'.toJString()..releasedBy(arena)) + .toDartString(releaseOriginal: true), 'world', ); }); @@ -379,51 +385,51 @@ void registerTests(String groupName, TestRunnerCallback test) { test('nested generics', () { using((arena) { final grandParent = - GrandParent(T: JString.type, "!".toJString()..deletedIn(arena)) - ..deletedIn(arena); + GrandParent(T: JString.type, "!".toJString()..releasedBy(arena)) + ..releasedBy(arena); expect( - grandParent.value.toDartString(deleteOriginal: true), + grandParent.value.toDartString(releaseOriginal: true), "!", ); final strStaticParent = GrandParent.stringStaticParent() - ..deletedIn(arena); + ..releasedBy(arena); expect( - strStaticParent.value.toDartString(deleteOriginal: true), + strStaticParent.value.toDartString(releaseOriginal: true), "Hello", ); final exampleStaticParent = GrandParent.varStaticParent( - S: Example.type, Example()..deletedIn(arena)) - ..deletedIn(arena); + S: Example.type, Example()..releasedBy(arena)) + ..releasedBy(arena); expect( - (exampleStaticParent.value..deletedIn(arena)).getNumber(), + (exampleStaticParent.value..releasedBy(arena)).getNumber(), 0, ); - final strParent = grandParent.stringParent()..deletedIn(arena); + final strParent = grandParent.stringParent()..releasedBy(arena); expect( strParent.parentValue - .castTo(JString.type, deleteOriginal: true) - .toDartString(deleteOriginal: true), + .castTo(JString.type, releaseOriginal: true) + .toDartString(releaseOriginal: true), "!", ); expect( - strParent.value.toDartString(deleteOriginal: true), + strParent.value.toDartString(releaseOriginal: true), "Hello", ); final exampleParent = grandParent.varParent( - S: Example.type, Example()..deletedIn(arena)) - ..deletedIn(arena); + S: Example.type, Example()..releasedBy(arena)) + ..releasedBy(arena); expect( exampleParent.parentValue - .castTo(JString.type, deleteOriginal: true) - .toDartString(deleteOriginal: true), + .castTo(JString.type, releaseOriginal: true) + .toDartString(releaseOriginal: true), "!", ); expect( - (exampleParent.value..deletedIn(arena)).getNumber(), + (exampleParent.value..releasedBy(arena)).getNumber(), 0, ); // TODO(#139): test constructing Child, currently does not work due @@ -433,32 +439,32 @@ void registerTests(String groupName, TestRunnerCallback test) { }); test('Constructing non-static nested classes', () { using((arena) { - final grandParent = GrandParent(1.toJInteger())..deletedIn(arena); + final grandParent = GrandParent(1.toJInteger())..releasedBy(arena); final parent = GrandParent_Parent(grandParent, 2.toJInteger()) - ..deletedIn(arena); + ..releasedBy(arena); final child = GrandParent_Parent_Child(parent, 3.toJInteger()) - ..deletedIn(arena); - expect(grandParent.value.intValue(deleteOriginal: true), 1); - expect(parent.parentValue.intValue(deleteOriginal: true), 1); - expect(parent.value.intValue(deleteOriginal: true), 2); - expect(child.grandParentValue.intValue(deleteOriginal: true), 1); - expect(child.parentValue.intValue(deleteOriginal: true), 2); - expect(child.value.intValue(deleteOriginal: true), 3); + ..releasedBy(arena); + expect(grandParent.value.intValue(releaseOriginal: true), 1); + expect(parent.parentValue.intValue(releaseOriginal: true), 1); + expect(parent.value.intValue(releaseOriginal: true), 2); + expect(child.grandParentValue.intValue(releaseOriginal: true), 1); + expect(child.parentValue.intValue(releaseOriginal: true), 2); + expect(child.value.intValue(releaseOriginal: true), 3); }); }); group('Generic type inference', () { test('MyStack.of1', () { using((arena) { - final emptyStack = MyStack(T: JString.type)..deletedIn(arena); + final emptyStack = MyStack(T: JString.type)..releasedBy(arena); expect(emptyStack.size(), 0); final stack = MyStack.of1( - "Hello".toJString()..deletedIn(arena), - )..deletedIn(arena); + "Hello".toJString()..releasedBy(arena), + )..releasedBy(arena); expect(stack, isA>()); expect(stack.$type, isA<$MyStackType>()); expect( - stack.pop().toDartString(deleteOriginal: true), + stack.pop().toDartString(releaseOriginal: true), "Hello", ); }); @@ -466,56 +472,56 @@ void registerTests(String groupName, TestRunnerCallback test) { test('MyStack.of 2 strings', () { using((arena) { final stack = MyStack.of2( - "Hello".toJString()..deletedIn(arena), - "World".toJString()..deletedIn(arena), - )..deletedIn(arena); + "Hello".toJString()..releasedBy(arena), + "World".toJString()..releasedBy(arena), + )..releasedBy(arena); expect(stack, isA>()); expect(stack.$type, isA<$MyStackType>()); expect( - stack.pop().toDartString(deleteOriginal: true), + stack.pop().toDartString(releaseOriginal: true), "World", ); expect( - stack.pop().toDartString(deleteOriginal: true), + stack.pop().toDartString(releaseOriginal: true), "Hello", ); }); }); test('MyStack.of a string and an array', () { using((arena) { - final array = JArray.filled(1, "World".toJString()..deletedIn(arena)) - ..deletedIn(arena); + final array = JArray.filled(1, "World".toJString()..releasedBy(arena)) + ..releasedBy(arena); final stack = MyStack.of2( - "Hello".toJString()..deletedIn(arena), + "Hello".toJString()..releasedBy(arena), array, - )..deletedIn(arena); + )..releasedBy(arena); expect(stack, isA>()); expect(stack.$type, isA<$MyStackType>()); expect( stack .pop() - .castTo(JArray.type(JString.type), deleteOriginal: true)[0] - .toDartString(deleteOriginal: true), + .castTo(JArray.type(JString.type), releaseOriginal: true)[0] + .toDartString(releaseOriginal: true), "World", ); expect( stack .pop() - .castTo(JString.type, deleteOriginal: true) - .toDartString(deleteOriginal: true), + .castTo(JString.type, releaseOriginal: true) + .toDartString(releaseOriginal: true), "Hello", ); }); }); test('MyStack.from array of string', () { using((arena) { - final array = JArray.filled(1, "Hello".toJString()..deletedIn(arena)) - ..deletedIn(arena); - final stack = MyStack.fromArray(array)..deletedIn(arena); + final array = JArray.filled(1, "Hello".toJString()..releasedBy(arena)) + ..releasedBy(arena); + final stack = MyStack.fromArray(array)..releasedBy(arena); expect(stack, isA>()); expect(stack.$type, isA<$MyStackType>()); expect( - stack.pop().toDartString(deleteOriginal: true), + stack.pop().toDartString(releaseOriginal: true), "Hello", ); }); @@ -524,18 +530,18 @@ void registerTests(String groupName, TestRunnerCallback test) { using((arena) { final firstDimention = JArray.filled( 1, - GrandParent("Hello".toJString()..deletedIn(arena)) - ..deletedIn(arena), - )..deletedIn(arena); + GrandParent("Hello".toJString()..releasedBy(arena)) + ..releasedBy(arena), + )..releasedBy(arena); final twoDimentionalArray = JArray.filled(1, firstDimention) - ..deletedIn(arena); + ..releasedBy(arena); final stack = MyStack.fromArrayOfArrayOfGrandParents(twoDimentionalArray) - ..deletedIn(arena); + ..releasedBy(arena); expect(stack, isA>()); expect(stack.$type, isA<$MyStackType>()); expect( - stack.pop().toDartString(deleteOriginal: true), + stack.pop().toDartString(releaseOriginal: true), "Hello", ); }); @@ -561,11 +567,11 @@ void registerTests(String groupName, TestRunnerCallback test) { voidCallbackResult.complete(s); }, stringCallback: (s) { - return (s.toDartString(deleteOriginal: true) * 2).toJString(); + return (s.toDartString(releaseOriginal: true) * 2).toJString(); }, varCallback: (JInteger t) { final result = - (t.intValue(deleteOriginal: true) * 2).toJInteger(); + (t.intValue(releaseOriginal: true) * 2).toJInteger(); varCallbackResult.complete(result); return result; }, @@ -600,7 +606,7 @@ void registerTests(String groupName, TestRunnerCallback test) { 7.toJInteger(), ); final voidCallback = await voidCallbackResult.future; - expect(voidCallback.toDartString(deleteOriginal: true), 'hellohello'); + expect(voidCallback.toDartString(releaseOriginal: true), 'hellohello'); final varCallback = await varCallbackResult.future; expect(varCallback.intValue(), 14); @@ -610,7 +616,7 @@ void registerTests(String groupName, TestRunnerCallback test) { // Currently we have one implementation of the interface. expect(MyInterface.$impls, hasLength(1)); - myInterface.delete(); + myInterface.release(); // Running System.gc() and waiting. _runJavaGC(); for (var i = 0; i < 8; ++i) { @@ -682,7 +688,7 @@ void registerTests(String groupName, TestRunnerCallback test) { test('Create many JNI refs with scoped deletion', () { for (int i = 0; i < k256; i++) { using((arena) { - final e = Example.new1(i)..deletedIn(arena); + final e = Example.new1(i)..releasedBy(arena); expect(e.getNumber(), equals(i)); }); } @@ -691,7 +697,7 @@ void registerTests(String groupName, TestRunnerCallback test) { for (int i = 0; i < 256; i++) { using((arena) { for (int i = 0; i < 1024; i++) { - final e = Example.new1(i)..deletedIn(arena); + final e = Example.new1(i)..releasedBy(arena); expect(e.getNumber(), equals(i)); } }); @@ -701,12 +707,12 @@ void registerTests(String groupName, TestRunnerCallback test) { for (int i = 0; i < k256; i++) { final e = Example.new1(i); expect(e.getNumber(), equals(i)); - e.delete(); + e.release(); } }); test('Method returning primitive type does not create references', () { using((arena) { - final e = Example.new1(64)..deletedIn(arena); + final e = Example.new1(64)..releasedBy(arena); for (int i = 0; i < k256; i++) { expect(e.getNumber(), equals(64)); } From 7684bdb87232a30f9dcaa12efca4c7558dcd7b98 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Fri, 1 Sep 2023 13:33:07 +0200 Subject: [PATCH 121/139] [jnigen] Configure autopublishing (https://github.com/dart-lang/jnigen/issues/380) --- .github/dependabot.yml | 11 ----------- .github/workflows/{test-package.yml => jnigen.yaml} | 0 pkgs/jni/example/pubspec.lock | 2 +- pkgs/jni/example/pubspec.yaml | 2 +- pkgs/jni/pubspec.yaml | 2 +- pkgs/jnigen/android_test_runner/pubspec.yaml | 2 +- pkgs/jnigen/example/in_app_java/pubspec.yaml | 2 +- .../jnigen/example/kotlin_plugin/example/pubspec.yaml | 2 +- pkgs/jnigen/example/kotlin_plugin/pubspec.yaml | 2 +- .../example/notification_plugin/example/pubspec.yaml | 2 +- pkgs/jnigen/example/notification_plugin/pubspec.yaml | 2 +- .../example/pdfbox_plugin/dart_example/pubspec.yaml | 2 +- .../jnigen/example/pdfbox_plugin/example/pubspec.yaml | 2 +- pkgs/jnigen/example/pdfbox_plugin/pubspec.yaml | 2 +- pkgs/jnigen/pubspec.yaml | 2 +- 15 files changed, 13 insertions(+), 24 deletions(-) delete mode 100644 .github/dependabot.yml rename .github/workflows/{test-package.yml => jnigen.yaml} (100%) diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index fb01db0e6..000000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,11 +0,0 @@ -# Dependabot configuration file. -# See https://docs.github.com/en/code-security/dependabot/dependabot-version-updates - -version: 2 -updates: - - package-ecosystem: github-actions - directory: / - schedule: - interval: monthly - labels: - - autosubmit diff --git a/.github/workflows/test-package.yml b/.github/workflows/jnigen.yaml similarity index 100% rename from .github/workflows/test-package.yml rename to .github/workflows/jnigen.yaml diff --git a/pkgs/jni/example/pubspec.lock b/pkgs/jni/example/pubspec.lock index f70135ea1..1df31a673 100644 --- a/pkgs/jni/example/pubspec.lock +++ b/pkgs/jni/example/pubspec.lock @@ -519,5 +519,5 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.1.0-262.3.beta <4.0.0" + dart: ">=3.1.0 <4.0.0" flutter: ">=2.11.0" diff --git a/pkgs/jni/example/pubspec.yaml b/pkgs/jni/example/pubspec.yaml index 7972e84f3..ce0646488 100644 --- a/pkgs/jni/example/pubspec.yaml +++ b/pkgs/jni/example/pubspec.yaml @@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: '>=3.1.0-262.3.beta <4.0.0' + sdk: '>=3.1.0 <4.0.0' # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions diff --git a/pkgs/jni/pubspec.yaml b/pkgs/jni/pubspec.yaml index c26952047..e161103ad 100644 --- a/pkgs/jni/pubspec.yaml +++ b/pkgs/jni/pubspec.yaml @@ -15,7 +15,7 @@ topics: - jni environment: - sdk: '>=3.1.0-262.3.beta <4.0.0' + sdk: '>=3.1.0 <4.0.0' flutter: '>=2.11.0' dependencies: diff --git a/pkgs/jnigen/android_test_runner/pubspec.yaml b/pkgs/jnigen/android_test_runner/pubspec.yaml index 87e47951e..fccc86e48 100644 --- a/pkgs/jnigen/android_test_runner/pubspec.yaml +++ b/pkgs/jnigen/android_test_runner/pubspec.yaml @@ -19,7 +19,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: '>=3.1.0-262.3.beta <4.0.0' + sdk: '>=3.1.0 <4.0.0' # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions diff --git a/pkgs/jnigen/example/in_app_java/pubspec.yaml b/pkgs/jnigen/example/in_app_java/pubspec.yaml index f99aa5d5c..321cc99bc 100644 --- a/pkgs/jnigen/example/in_app_java/pubspec.yaml +++ b/pkgs/jnigen/example/in_app_java/pubspec.yaml @@ -8,7 +8,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: '>=3.1.0-262.3.beta <4.0.0' + sdk: '>=3.1.0 <4.0.0' dependencies: flutter: diff --git a/pkgs/jnigen/example/kotlin_plugin/example/pubspec.yaml b/pkgs/jnigen/example/kotlin_plugin/example/pubspec.yaml index 53ef1e322..4c1c79651 100644 --- a/pkgs/jnigen/example/kotlin_plugin/example/pubspec.yaml +++ b/pkgs/jnigen/example/kotlin_plugin/example/pubspec.yaml @@ -6,7 +6,7 @@ publish_to: "none" version: 1.0.0+1 environment: - sdk: '>=3.1.0-262.3.beta <4.0.0' + sdk: '>=3.1.0 <4.0.0' dependencies: flutter: diff --git a/pkgs/jnigen/example/kotlin_plugin/pubspec.yaml b/pkgs/jnigen/example/kotlin_plugin/pubspec.yaml index 4396ff595..fd89ad6cc 100644 --- a/pkgs/jnigen/example/kotlin_plugin/pubspec.yaml +++ b/pkgs/jnigen/example/kotlin_plugin/pubspec.yaml @@ -8,7 +8,7 @@ version: 0.0.1 publish_to: none environment: - sdk: '>=3.1.0-262.3.beta <4.0.0' + sdk: '>=3.1.0 <4.0.0' flutter: ">=1.17.0" dependencies: diff --git a/pkgs/jnigen/example/notification_plugin/example/pubspec.yaml b/pkgs/jnigen/example/notification_plugin/example/pubspec.yaml index 10478f0e3..35f3357f1 100644 --- a/pkgs/jnigen/example/notification_plugin/example/pubspec.yaml +++ b/pkgs/jnigen/example/notification_plugin/example/pubspec.yaml @@ -20,7 +20,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: '>=3.1.0-262.3.beta <4.0.0' + sdk: '>=3.1.0 <4.0.0' dependencies: flutter: diff --git a/pkgs/jnigen/example/notification_plugin/pubspec.yaml b/pkgs/jnigen/example/notification_plugin/pubspec.yaml index a0e0a6af5..1f6cf4925 100644 --- a/pkgs/jnigen/example/notification_plugin/pubspec.yaml +++ b/pkgs/jnigen/example/notification_plugin/pubspec.yaml @@ -5,7 +5,7 @@ publish_to: none homepage: https://github.com/dart-lang/jnigen environment: - sdk: '>=3.1.0-262.3.beta <4.0.0' + sdk: '>=3.1.0 <4.0.0' flutter: ">=2.11.0" dependencies: diff --git a/pkgs/jnigen/example/pdfbox_plugin/dart_example/pubspec.yaml b/pkgs/jnigen/example/pdfbox_plugin/dart_example/pubspec.yaml index 8b8a4ef39..4af3cf1fd 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/dart_example/pubspec.yaml +++ b/pkgs/jnigen/example/pdfbox_plugin/dart_example/pubspec.yaml @@ -5,7 +5,7 @@ publish_to: none # homepage: https://www.example.com environment: - sdk: '>=3.1.0-262.3.beta <4.0.0' + sdk: '>=3.1.0 <4.0.0' dependencies: path: ^1.8.0 diff --git a/pkgs/jnigen/example/pdfbox_plugin/example/pubspec.yaml b/pkgs/jnigen/example/pdfbox_plugin/example/pubspec.yaml index 47993e6ba..13d0df00f 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/example/pubspec.yaml +++ b/pkgs/jnigen/example/pdfbox_plugin/example/pubspec.yaml @@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: '>=3.1.0-262.3.beta <4.0.0' + sdk: '>=3.1.0 <4.0.0' # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions diff --git a/pkgs/jnigen/example/pdfbox_plugin/pubspec.yaml b/pkgs/jnigen/example/pdfbox_plugin/pubspec.yaml index c6bb9208b..a269d5a6f 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/pubspec.yaml +++ b/pkgs/jnigen/example/pdfbox_plugin/pubspec.yaml @@ -6,7 +6,7 @@ publish_to: none homepage: https://github.com/dart-lang/jnigen environment: - sdk: '>=3.1.0-262.3.beta <4.0.0' + sdk: '>=3.1.0 <4.0.0' #flutter: ">=2.11.0" dependencies: diff --git a/pkgs/jnigen/pubspec.yaml b/pkgs/jnigen/pubspec.yaml index b68d371a2..62fbc9372 100644 --- a/pkgs/jnigen/pubspec.yaml +++ b/pkgs/jnigen/pubspec.yaml @@ -8,7 +8,7 @@ version: 0.6.0 repository: https://github.com/dart-lang/jnigen/tree/main/jnigen environment: - sdk: ">=3.1.0-262.3.beta <4.0.0" + sdk: ">=3.1.0 <4.0.0" topics: - interop From 35d752216c4b38cbbd8af01c2945526414d23c4c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Sep 2023 11:53:26 +0000 Subject: [PATCH 122/139] [jnigen] Bump actions/checkout from 3.5.3 to 3.6.0 (https://github.com/dart-lang/jnigen/issues/381) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.3 to 3.6.0.
    Release notes

    Sourced from actions/checkout's releases.

    v3.6.0

    What's Changed

    New Contributors

    Full Changelog: https://github.com/actions/checkout/compare/v3.5.3...v3.6.0

    Changelog

    Sourced from actions/checkout's changelog.

    Changelog

    v3.6.0

    v3.5.3

    v3.5.2

    v3.5.1

    v3.5.0

    v3.4.0

    v3.3.0

    v3.2.0

    v3.1.0

    v3.0.2

    v3.0.1

    v3.0.0

    ... (truncated)

    Commits

    [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=3.5.3&new-version=3.6.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
    Dependabot commands and options
    You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    --- .github/workflows/jnigen.yaml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/jnigen.yaml b/.github/workflows/jnigen.yaml index 5846f3c16..b9842e00b 100644 --- a/.github/workflows/jnigen.yaml +++ b/.github/workflows/jnigen.yaml @@ -32,7 +32,7 @@ jobs: matrix: sdk: [stable] steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: ${{ matrix.sdk }} @@ -67,7 +67,7 @@ jobs: os: [ubuntu-latest] sdk: [stable, beta] steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: ${{ matrix.sdk }} @@ -120,7 +120,7 @@ jobs: run: working-directory: ./pkgs/jni steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' @@ -158,7 +158,7 @@ jobs: run: working-directory: ./pkgs/jni steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' @@ -207,7 +207,7 @@ jobs: run: working-directory: ./pkgs/jni steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' @@ -229,7 +229,7 @@ jobs: run: working-directory: ./pkgs/jnigen steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - name: Setup clang uses: egor-tensin/setup-clang@ef434b41eb33a70396fb336b1bae39c76d740c3d with: @@ -262,7 +262,7 @@ jobs: run: working-directory: ./pkgs/jni steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' @@ -283,7 +283,7 @@ jobs: run: working-directory: ./pkgs/jnigen steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - name: Setup clang format uses: ConorMacBride/install-package@3e7ad059e07782ee54fa35f827df52aae0626f30 with: @@ -312,7 +312,7 @@ jobs: run: working-directory: ./pkgs/jni/example steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' @@ -336,7 +336,7 @@ jobs: run: working-directory: ./pkgs/jni/example steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' @@ -356,7 +356,7 @@ jobs: run: working-directory: ./pkgs/jni/example steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 with: distribution: 'zulu' @@ -375,7 +375,7 @@ jobs: run: working-directory: ./pkgs/jnigen/example/pdfbox_plugin steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' From 6606892f0ce7684e4f7c9d76b125d53591800e33 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Fri, 1 Sep 2023 17:01:39 +0200 Subject: [PATCH 123/139] [jnigen] jni-0.6.1 fix number of topics (https://github.com/dart-lang/jnigen/issues/382) --- pkgs/jni/CHANGELOG.md | 3 +++ pkgs/jni/example/pubspec.lock | 2 +- pkgs/jni/pubspec.yaml | 2 +- pkgs/jnigen/pubspec.yaml | 1 - 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/jni/CHANGELOG.md b/pkgs/jni/CHANGELOG.md index 1c83295f1..f9975313f 100644 --- a/pkgs/jni/CHANGELOG.md +++ b/pkgs/jni/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.6.1 +* Depend on the stable version of Dart 3.1. + ## 0.6.0 * **Breaking Change** ([#131](https://github.com/dart-lang/jnigen/issues/131)): Renamed `delete*` to `release*`. * Added `PortProxy` and related methods used for interface implementation. diff --git a/pkgs/jni/example/pubspec.lock b/pkgs/jni/example/pubspec.lock index 1df31a673..0da0519cb 100644 --- a/pkgs/jni/example/pubspec.lock +++ b/pkgs/jni/example/pubspec.lock @@ -200,7 +200,7 @@ packages: path: ".." relative: true source: path - version: "0.6.0" + version: "0.6.1" js: dependency: transitive description: diff --git a/pkgs/jni/pubspec.yaml b/pkgs/jni/pubspec.yaml index e161103ad..62ba94d4f 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.6.0 +version: 0.6.1 repository: https://github.com/dart-lang/jnigen/tree/main/jni topics: diff --git a/pkgs/jnigen/pubspec.yaml b/pkgs/jnigen/pubspec.yaml index 62fbc9372..28a103b4d 100644 --- a/pkgs/jnigen/pubspec.yaml +++ b/pkgs/jnigen/pubspec.yaml @@ -15,7 +15,6 @@ topics: - ffi - codegen - java - - kotlin - jni dependencies: From 1d4698560184bae7c6fdde129630a0f55e4c0294 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Mon, 4 Sep 2023 19:45:03 +0200 Subject: [PATCH 124/139] [jnigen] Specify JDK min and max version in README (https://github.com/dart-lang/jnigen/issues/384) --- pkgs/jnigen/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/jnigen/README.md b/pkgs/jnigen/README.md index c5850b587..eaffeaa4e 100644 --- a/pkgs/jnigen/README.md +++ b/pkgs/jnigen/README.md @@ -154,6 +154,9 @@ Flutter SDK is required. Dart standalone target is supported, but due to some problems with pubspec format, the `dart` command must be from Flutter SDK and not Dart SDK. See [dart-lang/pub#3563](https://github.com/dart-lang/pub/issues/3563). ### Java tooling + +**Use JDK versions 11 to 17. The newer versions will not work because of their lack of [compatibility](https://docs.gradle.org/current/userguide/compatibility.html) with Gradle.** + Along with JDK, maven (`mvn` command) is required. On windows, it can be installed using a package manager such as [chocolatey](https://community.chocolatey.org/packages/maven) or [scoop](https://scoop.sh/#/apps?q=maven). __On windows, append the path of `jvm.dll` in your JDK installation to PATH.__ From 619b5023003d0f777a72e28e198acf341b5de007 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Sun, 10 Sep 2023 00:06:32 -0700 Subject: [PATCH 125/139] [jnigen] Add correct cast to interface method invocation (https://github.com/dart-lang/jnigen/issues/385) --- pkgs/jnigen/CHANGELOG.md | 3 +++ pkgs/jnigen/lib/src/bindings/dart_generator.dart | 2 +- pkgs/jnigen/pubspec.yaml | 2 +- .../c_based/dart_bindings/simple_package.dart | 4 ++-- .../dart_only/dart_bindings/simple_package.dart | 4 ++-- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/pkgs/jnigen/CHANGELOG.md b/pkgs/jnigen/CHANGELOG.md index 5354fc2e6..76430af98 100644 --- a/pkgs/jnigen/CHANGELOG.md +++ b/pkgs/jnigen/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.6.1-wip +* Added an explicit cast in generated `.implement` code to allow `dart analyze` to pass when `strict-casts` is set. + ## 0.6.0 * **Breaking Change** ([#131](https://github.com/dart-lang/jnigen/issues/131)): Renamed `delete*` to `release*`. * **Breaking Change** ([#354](https://github.com/dart-lang/jnigen/issues/354)): Renamed constructors from `ctor1`, `ctor2`, ... to `new1`, `new2`, ... diff --git a/pkgs/jnigen/lib/src/bindings/dart_generator.dart b/pkgs/jnigen/lib/src/bindings/dart_generator.dart index 689678cab..ead431f2e 100644 --- a/pkgs/jnigen/lib/src/bindings/dart_generator.dart +++ b/pkgs/jnigen/lib/src/bindings/dart_generator.dart @@ -479,7 +479,7 @@ class $name$typeParamsDef extends $superName { \$p.close(); return; } - final \$i = \$MethodInvocation.fromMessage(\$m); + final \$i = \$MethodInvocation.fromMessage(\$m as List); final \$r = _\$invokeMethod(\$p.sendPort.nativePort, \$i); $_protectedExtension.returnResult(\$i.result, \$r); }); diff --git a/pkgs/jnigen/pubspec.yaml b/pkgs/jnigen/pubspec.yaml index 28a103b4d..d8d08f726 100644 --- a/pkgs/jnigen/pubspec.yaml +++ b/pkgs/jnigen/pubspec.yaml @@ -4,7 +4,7 @@ name: jnigen description: A Dart bindings generator for Java and Kotlin that uses JNI under the hood to interop with Java virtual machine. -version: 0.6.0 +version: 0.6.1-wip repository: https://github.com/dart-lang/jnigen/tree/main/jnigen environment: diff --git a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart index a91eba6b1..345a1c2b5 100644 --- a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart @@ -3435,7 +3435,7 @@ class MyInterface<$T extends jni.JObject> extends jni.JObject { $p.close(); return; } - final $i = $MethodInvocation.fromMessage($m); + final $i = $MethodInvocation.fromMessage($m as List); final $r = _$invokeMethod($p.sendPort.nativePort, $i); ProtectedJniExtensions.returnResult($i.result, $r); }); @@ -3733,7 +3733,7 @@ class MyRunnable extends jni.JObject { $p.close(); return; } - final $i = $MethodInvocation.fromMessage($m); + final $i = $MethodInvocation.fromMessage($m as List); final $r = _$invokeMethod($p.sendPort.nativePort, $i); ProtectedJniExtensions.returnResult($i.result, $r); }); diff --git a/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart index 3c6d41bd7..e534bf517 100644 --- a/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart @@ -3244,7 +3244,7 @@ class MyInterface<$T extends jni.JObject> extends jni.JObject { $p.close(); return; } - final $i = $MethodInvocation.fromMessage($m); + final $i = $MethodInvocation.fromMessage($m as List); final $r = _$invokeMethod($p.sendPort.nativePort, $i); ProtectedJniExtensions.returnResult($i.result, $r); }); @@ -3540,7 +3540,7 @@ class MyRunnable extends jni.JObject { $p.close(); return; } - final $i = $MethodInvocation.fromMessage($m); + final $i = $MethodInvocation.fromMessage($m as List); final $r = _$invokeMethod($p.sendPort.nativePort, $i); ProtectedJniExtensions.returnResult($i.result, $r); }); From eb49cbab81d54eb1c8552d5a591f906f822ada21 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Mon, 11 Sep 2023 08:43:09 -0700 Subject: [PATCH 126/139] [jnigen] Add `ignore_for_file: lines_longer_than_80_chars` to generated files (https://github.com/dart-lang/jnigen/issues/386) --- pkgs/jnigen/CHANGELOG.md | 1 + pkgs/jnigen/example/in_app_java/lib/android_utils.dart | 1 + pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart | 1 + pkgs/jnigen/example/notification_plugin/lib/notifications.dart | 1 + .../src/third_party/org/apache/pdfbox/pdmodel/PDDocument.dart | 1 + .../org/apache/pdfbox/pdmodel/PDDocumentInformation.dart | 1 + .../third_party/org/apache/pdfbox/text/PDFTextStripper.dart | 1 + pkgs/jnigen/lib/src/bindings/dart_generator.dart | 3 +++ .../dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart | 1 + .../dart_bindings/com/fasterxml/jackson/core/JsonParser.dart | 1 + .../dart_bindings/com/fasterxml/jackson/core/JsonToken.dart | 1 + .../dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart | 1 + .../dart_bindings/com/fasterxml/jackson/core/JsonParser.dart | 1 + .../dart_bindings/com/fasterxml/jackson/core/JsonToken.dart | 1 + pkgs/jnigen/test/kotlin_test/c_based/dart_bindings/kotlin.dart | 1 + .../test/kotlin_test/dart_only/dart_bindings/kotlin.dart | 1 + .../c_based/dart_bindings/simple_package.dart | 1 + .../dart_only/dart_bindings/simple_package.dart | 1 + 18 files changed, 20 insertions(+) diff --git a/pkgs/jnigen/CHANGELOG.md b/pkgs/jnigen/CHANGELOG.md index 76430af98..7e18e4020 100644 --- a/pkgs/jnigen/CHANGELOG.md +++ b/pkgs/jnigen/CHANGELOG.md @@ -1,4 +1,5 @@ ## 0.6.1-wip +* Add `ignore_for_file: lines_longer_than_80_chars` to the generated file preamble. * Added an explicit cast in generated `.implement` code to allow `dart analyze` to pass when `strict-casts` is set. ## 0.6.0 diff --git a/pkgs/jnigen/example/in_app_java/lib/android_utils.dart b/pkgs/jnigen/example/in_app_java/lib/android_utils.dart index 620adec8b..ec722865a 100644 --- a/pkgs/jnigen/example/in_app_java/lib/android_utils.dart +++ b/pkgs/jnigen/example/in_app_java/lib/android_utils.dart @@ -5,6 +5,7 @@ // ignore_for_file: camel_case_types // ignore_for_file: constant_identifier_names // ignore_for_file: file_names +// ignore_for_file: lines_longer_than_80_chars // ignore_for_file: no_leading_underscores_for_local_identifiers // ignore_for_file: non_constant_identifier_names // ignore_for_file: overridden_fields diff --git a/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart b/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart index b7120d25a..ed2d034c0 100644 --- a/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart +++ b/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart @@ -5,6 +5,7 @@ // ignore_for_file: camel_case_types // ignore_for_file: constant_identifier_names // ignore_for_file: file_names +// ignore_for_file: lines_longer_than_80_chars // ignore_for_file: no_leading_underscores_for_local_identifiers // ignore_for_file: non_constant_identifier_names // ignore_for_file: overridden_fields diff --git a/pkgs/jnigen/example/notification_plugin/lib/notifications.dart b/pkgs/jnigen/example/notification_plugin/lib/notifications.dart index 30664d566..ebb2f59ef 100644 --- a/pkgs/jnigen/example/notification_plugin/lib/notifications.dart +++ b/pkgs/jnigen/example/notification_plugin/lib/notifications.dart @@ -9,6 +9,7 @@ // ignore_for_file: camel_case_types // ignore_for_file: constant_identifier_names // ignore_for_file: file_names +// ignore_for_file: lines_longer_than_80_chars // ignore_for_file: no_leading_underscores_for_local_identifiers // ignore_for_file: non_constant_identifier_names // ignore_for_file: overridden_fields 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 59438087f..03a9da2a3 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 @@ -23,6 +23,7 @@ // ignore_for_file: camel_case_types // ignore_for_file: constant_identifier_names // ignore_for_file: file_names +// ignore_for_file: lines_longer_than_80_chars // ignore_for_file: no_leading_underscores_for_local_identifiers // ignore_for_file: non_constant_identifier_names // ignore_for_file: overridden_fields 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 268557214..d928d2137 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 @@ -23,6 +23,7 @@ // ignore_for_file: camel_case_types // ignore_for_file: constant_identifier_names // ignore_for_file: file_names +// ignore_for_file: lines_longer_than_80_chars // ignore_for_file: no_leading_underscores_for_local_identifiers // ignore_for_file: non_constant_identifier_names // ignore_for_file: overridden_fields 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 556d83a80..b42cd9a60 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 @@ -23,6 +23,7 @@ // ignore_for_file: camel_case_types // ignore_for_file: constant_identifier_names // ignore_for_file: file_names +// ignore_for_file: lines_longer_than_80_chars // ignore_for_file: no_leading_underscores_for_local_identifiers // ignore_for_file: non_constant_identifier_names // ignore_for_file: overridden_fields diff --git a/pkgs/jnigen/lib/src/bindings/dart_generator.dart b/pkgs/jnigen/lib/src/bindings/dart_generator.dart index ead431f2e..d8fb60d03 100644 --- a/pkgs/jnigen/lib/src/bindings/dart_generator.dart +++ b/pkgs/jnigen/lib/src/bindings/dart_generator.dart @@ -144,12 +144,15 @@ import "package:jni/internal_helpers_for_jnigen.dart"; import "package:jni/jni.dart" as jni; '''; + + // Sort alphabetically. static const defaultLintSuppressions = ''' // ignore_for_file: annotate_overrides // ignore_for_file: camel_case_extensions // ignore_for_file: camel_case_types // ignore_for_file: constant_identifier_names // ignore_for_file: file_names +// ignore_for_file: lines_longer_than_80_chars // ignore_for_file: no_leading_underscores_for_local_identifiers // ignore_for_file: non_constant_identifier_names // ignore_for_file: overridden_fields diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart index 4ebdfd9cd..e1f19fe50 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart @@ -22,6 +22,7 @@ // ignore_for_file: camel_case_types // ignore_for_file: constant_identifier_names // ignore_for_file: file_names +// ignore_for_file: lines_longer_than_80_chars // ignore_for_file: no_leading_underscores_for_local_identifiers // ignore_for_file: non_constant_identifier_names // ignore_for_file: overridden_fields diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart index 3ea73b13c..1dac51cc5 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart @@ -22,6 +22,7 @@ // ignore_for_file: camel_case_types // ignore_for_file: constant_identifier_names // ignore_for_file: file_names +// ignore_for_file: lines_longer_than_80_chars // ignore_for_file: no_leading_underscores_for_local_identifiers // ignore_for_file: non_constant_identifier_names // ignore_for_file: overridden_fields diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart index da95cb6e5..fdbd542ad 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart @@ -22,6 +22,7 @@ // ignore_for_file: camel_case_types // ignore_for_file: constant_identifier_names // ignore_for_file: file_names +// ignore_for_file: lines_longer_than_80_chars // ignore_for_file: no_leading_underscores_for_local_identifiers // ignore_for_file: non_constant_identifier_names // ignore_for_file: overridden_fields diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart index 3677ba171..f9f363166 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart @@ -22,6 +22,7 @@ // ignore_for_file: camel_case_types // ignore_for_file: constant_identifier_names // ignore_for_file: file_names +// ignore_for_file: lines_longer_than_80_chars // ignore_for_file: no_leading_underscores_for_local_identifiers // ignore_for_file: non_constant_identifier_names // ignore_for_file: overridden_fields diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart index 7d0dceb12..ae607a98f 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart @@ -22,6 +22,7 @@ // ignore_for_file: camel_case_types // ignore_for_file: constant_identifier_names // ignore_for_file: file_names +// ignore_for_file: lines_longer_than_80_chars // ignore_for_file: no_leading_underscores_for_local_identifiers // ignore_for_file: non_constant_identifier_names // ignore_for_file: overridden_fields diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart index 6b60adb27..da0a49e5c 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart @@ -22,6 +22,7 @@ // ignore_for_file: camel_case_types // ignore_for_file: constant_identifier_names // ignore_for_file: file_names +// ignore_for_file: lines_longer_than_80_chars // ignore_for_file: no_leading_underscores_for_local_identifiers // ignore_for_file: non_constant_identifier_names // ignore_for_file: overridden_fields diff --git a/pkgs/jnigen/test/kotlin_test/c_based/dart_bindings/kotlin.dart b/pkgs/jnigen/test/kotlin_test/c_based/dart_bindings/kotlin.dart index 1792649fc..5b80bb881 100644 --- a/pkgs/jnigen/test/kotlin_test/c_based/dart_bindings/kotlin.dart +++ b/pkgs/jnigen/test/kotlin_test/c_based/dart_bindings/kotlin.dart @@ -9,6 +9,7 @@ // ignore_for_file: camel_case_types // ignore_for_file: constant_identifier_names // ignore_for_file: file_names +// ignore_for_file: lines_longer_than_80_chars // ignore_for_file: no_leading_underscores_for_local_identifiers // ignore_for_file: non_constant_identifier_names // ignore_for_file: overridden_fields diff --git a/pkgs/jnigen/test/kotlin_test/dart_only/dart_bindings/kotlin.dart b/pkgs/jnigen/test/kotlin_test/dart_only/dart_bindings/kotlin.dart index 357e6e51c..c352dfb02 100644 --- a/pkgs/jnigen/test/kotlin_test/dart_only/dart_bindings/kotlin.dart +++ b/pkgs/jnigen/test/kotlin_test/dart_only/dart_bindings/kotlin.dart @@ -9,6 +9,7 @@ // ignore_for_file: camel_case_types // ignore_for_file: constant_identifier_names // ignore_for_file: file_names +// ignore_for_file: lines_longer_than_80_chars // ignore_for_file: no_leading_underscores_for_local_identifiers // ignore_for_file: non_constant_identifier_names // ignore_for_file: overridden_fields diff --git a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart index 345a1c2b5..2879e351c 100644 --- a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart @@ -9,6 +9,7 @@ // ignore_for_file: camel_case_types // ignore_for_file: constant_identifier_names // ignore_for_file: file_names +// ignore_for_file: lines_longer_than_80_chars // ignore_for_file: no_leading_underscores_for_local_identifiers // ignore_for_file: non_constant_identifier_names // ignore_for_file: overridden_fields diff --git a/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart index e534bf517..b549cc89a 100644 --- a/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart @@ -9,6 +9,7 @@ // ignore_for_file: camel_case_types // ignore_for_file: constant_identifier_names // ignore_for_file: file_names +// ignore_for_file: lines_longer_than_80_chars // ignore_for_file: no_leading_underscores_for_local_identifiers // ignore_for_file: non_constant_identifier_names // ignore_for_file: overridden_fields From e8e0a98e50434883ef08979d4f78c2230a9b09a9 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Wed, 13 Sep 2023 14:39:12 +0200 Subject: [PATCH 127/139] [jnigen] Add `JBuffer`, `JByteBuffer` to enable fast copying to and from `Uint8List` (https://github.com/dart-lang/jnigen/issues/390) `JBuffer` is now the default binding for `java.nio.Buffer` and `JByteBuffer` for `java.nio.ByteBuffer`. --- pkgs/jni/CHANGELOG.md | 54 ++- pkgs/jni/lib/jni.dart | 1 + pkgs/jni/lib/jni_symbols.yaml | 8 + pkgs/jni/lib/src/jarray.dart | 2 +- pkgs/jni/lib/src/jobject.dart | 2 +- pkgs/jni/lib/src/lang/jboolean.dart | 2 +- pkgs/jni/lib/src/lang/jbyte.dart | 2 +- pkgs/jni/lib/src/lang/jcharacter.dart | 2 +- pkgs/jni/lib/src/lang/jdouble.dart | 2 +- pkgs/jni/lib/src/lang/jfloat.dart | 2 +- pkgs/jni/lib/src/lang/jinteger.dart | 2 +- pkgs/jni/lib/src/lang/jlong.dart | 2 +- pkgs/jni/lib/src/lang/jnumber.dart | 2 +- pkgs/jni/lib/src/lang/jshort.dart | 2 +- pkgs/jni/lib/src/lang/jstring.dart | 2 +- pkgs/jni/lib/src/nio/jbuffer.dart | 255 ++++++++++++++ pkgs/jni/lib/src/nio/jbyte_buffer.dart | 316 ++++++++++++++++++ pkgs/jni/lib/src/nio/nio.dart | 6 + pkgs/jni/lib/src/util/jiterator.dart | 2 +- pkgs/jni/lib/src/util/jlist.dart | 11 +- pkgs/jni/lib/src/util/jmap.dart | 8 +- pkgs/jni/lib/src/util/jset.dart | 5 +- pkgs/jni/pubspec.yaml | 2 +- pkgs/jni/test/jarray_test.dart | 6 + pkgs/jni/test/jbyte_buffer_test.dart | 229 +++++++++++++ pkgs/jni/test/type_test.dart | 19 +- pkgs/jnigen/CHANGELOG.md | 87 +++-- .../in_app_java/lib/android_utils.dart | 40 +-- .../kotlin_plugin/lib/kotlin_bindings.dart | 2 +- .../lib/notifications.dart | 2 +- .../org/apache/pdfbox/pdmodel/PDDocument.dart | 2 +- .../pdfbox/pdmodel/PDDocumentInformation.dart | 3 +- .../apache/pdfbox/text/PDFTextStripper.dart | 2 +- .../lib/src/bindings/dart_generator.dart | 2 +- pkgs/jnigen/pubspec.yaml | 2 +- .../fasterxml/jackson/core/JsonFactory.dart | 4 +- .../fasterxml/jackson/core/JsonParser.dart | 7 +- .../com/fasterxml/jackson/core/JsonToken.dart | 2 +- .../fasterxml/jackson/core/JsonFactory.dart | 4 +- .../fasterxml/jackson/core/JsonParser.dart | 7 +- .../com/fasterxml/jackson/core/JsonToken.dart | 2 +- .../c_based/dart_bindings/kotlin.dart | 2 +- .../dart_only/dart_bindings/kotlin.dart | 2 +- .../c_based/dart_bindings/simple_package.dart | 64 ++-- .../dart_bindings/simple_package.dart | 64 ++-- 45 files changed, 1071 insertions(+), 175 deletions(-) create mode 100644 pkgs/jni/lib/src/nio/jbuffer.dart create mode 100644 pkgs/jni/lib/src/nio/jbyte_buffer.dart create mode 100644 pkgs/jni/lib/src/nio/nio.dart create mode 100644 pkgs/jni/test/jbyte_buffer_test.dart diff --git a/pkgs/jni/CHANGELOG.md b/pkgs/jni/CHANGELOG.md index f9975313f..64ddb4d71 100644 --- a/pkgs/jni/CHANGELOG.md +++ b/pkgs/jni/CHANGELOG.md @@ -1,33 +1,57 @@ +## 0.7.0 + +- **Breaking Change** ([#387](https://github.com/dart-lang/jnigen/issues/387)): + Added `JBuffer` and `JByteBuffer` classes as default classes for + `java.nio.Buffer` and `java.nio.ByteBuffer` respectively. +- **Breaking Change**: Made the type classes `final`. +- Fixed a bug where `addAll`, `removeAll` and `retainAll` in `JSet` would run + their respective operation twice. +- Fixed a bug where `JList.insertAll` would not throw the potentially thrown + Java exception. + ## 0.6.1 -* Depend on the stable version of Dart 3.1. + +- Depend on the stable version of Dart 3.1. ## 0.6.0 -* **Breaking Change** ([#131](https://github.com/dart-lang/jnigen/issues/131)): Renamed `delete*` to `release*`. -* Added `PortProxy` and related methods used for interface implementation. -* Added the missing binding for `java.lang.Character`. + +- **Breaking Change** ([#131](https://github.com/dart-lang/jnigen/issues/131)): + Renamed `delete*` to `release*`. +- Added `PortProxy` and related methods used for interface implementation. +- Added the missing binding for `java.lang.Character`. ## 0.5.0 -* **Breaking Change** ([#137](https://github.com/dart-lang/jnigen/issues/137)): Java primitive types are now all lowercase like `jint`, `jshort`, ... -* The bindings for `java.util.Set`, `java.util.Map`, `java.util.List` and the numeric types like `java.lang.Integer`, `java.lang.Boolean`, ... are now included in `package:jni`. + +- **Breaking Change** ([#137](https://github.com/dart-lang/jnigen/issues/137)): + Java primitive types are now all lowercase like `jint`, `jshort`, ... +- The bindings for `java.util.Set`, `java.util.Map`, `java.util.List` and the + numeric types like `java.lang.Integer`, `java.lang.Boolean`, ... are now + included in `package:jni`. ## 0.4.0 -* Type classes now have `superCount` and `superType` getters used for type inference. + +- Type classes now have `superCount` and `superType` getters used for type + inference. ## 0.3.0 -* Added `PortContinuation` used for `suspend fun` in Kotlin. -* `dartjni` now depends on `dart_api_dl.h`. + +- Added `PortContinuation` used for `suspend fun` in Kotlin. +- `dartjni` now depends on `dart_api_dl.h`. ## 0.2.1 -* Added `.clang-format` to pub. + +- Added `.clang-format` to pub. ## 0.2.0 -* Added array support -* Added generic support -* `JniX` turned into `JX` for a more terse code. + +- Added array support +- Added generic support +- `JniX` turned into `JX` for a more terse code. ## 0.1.1 -* Windows support for running tests and examples on development machines. + +- Windows support for running tests and examples on development machines. ## 0.1.0 -* Initial version: Android and Linux support, JObject API +- Initial version: Android and Linux support, JObject API diff --git a/pkgs/jni/lib/jni.dart b/pkgs/jni/lib/jni.dart index d63fc73a9..85f99fa32 100644 --- a/pkgs/jni/lib/jni.dart +++ b/pkgs/jni/lib/jni.dart @@ -71,6 +71,7 @@ export 'src/jobject.dart'; export 'src/jprimitives.dart'; export 'src/jreference.dart' show JReferenceUseExtension; export 'src/lang/lang.dart'; +export 'src/nio/nio.dart'; export 'src/util/util.dart'; export 'package:ffi/ffi.dart' show using, Arena; diff --git a/pkgs/jni/lib/jni_symbols.yaml b/pkgs/jni/lib/jni_symbols.yaml index 5159dc9cc..ac4a74c0c 100644 --- a/pkgs/jni/lib/jni_symbols.yaml +++ b/pkgs/jni/lib/jni_symbols.yaml @@ -75,3 +75,11 @@ files: 'java.lang.Object': DECLARED V: 'java.lang.Object': DECLARED + 'java.nio.Buffer': + name: JBuffer + type_class: JBufferType + super_count: 1 + 'java.nio.ByteBuffer': + name: JByteBuffer + type_class: JByteBufferType + super_count: 2 diff --git a/pkgs/jni/lib/src/jarray.dart b/pkgs/jni/lib/src/jarray.dart index 1b970392b..fac1d85c9 100644 --- a/pkgs/jni/lib/src/jarray.dart +++ b/pkgs/jni/lib/src/jarray.dart @@ -16,7 +16,7 @@ import 'jobject.dart'; import 'jprimitives.dart'; import 'types.dart'; -class JArrayType extends JObjType> { +final class JArrayType extends JObjType> { final JType elementType; const JArrayType(this.elementType); diff --git a/pkgs/jni/lib/src/jobject.dart b/pkgs/jni/lib/src/jobject.dart index 6a2cad207..a7e659ce9 100644 --- a/pkgs/jni/lib/src/jobject.dart +++ b/pkgs/jni/lib/src/jobject.dart @@ -19,7 +19,7 @@ import 'types.dart'; // type switch like a regular type. typedef _VoidType = void; -class JObjectType extends JObjType { +final class JObjectType extends JObjType { const JObjectType(); @override diff --git a/pkgs/jni/lib/src/lang/jboolean.dart b/pkgs/jni/lib/src/lang/jboolean.dart index 3dd22b112..9ea92b436 100644 --- a/pkgs/jni/lib/src/lang/jboolean.dart +++ b/pkgs/jni/lib/src/lang/jboolean.dart @@ -9,7 +9,7 @@ import '../jni.dart'; import '../third_party/generated_bindings.dart'; import '../types.dart'; -class JBooleanType extends JObjType { +final class JBooleanType extends JObjType { const JBooleanType(); @override diff --git a/pkgs/jni/lib/src/lang/jbyte.dart b/pkgs/jni/lib/src/lang/jbyte.dart index 3cb9e96d6..6b5aa9808 100644 --- a/pkgs/jni/lib/src/lang/jbyte.dart +++ b/pkgs/jni/lib/src/lang/jbyte.dart @@ -9,7 +9,7 @@ import '../third_party/generated_bindings.dart'; import '../types.dart'; import 'jnumber.dart'; -class JByteType extends JObjType { +final class JByteType extends JObjType { const JByteType(); @override diff --git a/pkgs/jni/lib/src/lang/jcharacter.dart b/pkgs/jni/lib/src/lang/jcharacter.dart index c43d2e0e3..b50f67f45 100644 --- a/pkgs/jni/lib/src/lang/jcharacter.dart +++ b/pkgs/jni/lib/src/lang/jcharacter.dart @@ -6,7 +6,7 @@ import '../jvalues.dart'; import '../third_party/generated_bindings.dart'; import '../types.dart'; -class JCharacterType extends JObjType { +final class JCharacterType extends JObjType { const JCharacterType(); @override diff --git a/pkgs/jni/lib/src/lang/jdouble.dart b/pkgs/jni/lib/src/lang/jdouble.dart index c6852a1e9..6db163e4e 100644 --- a/pkgs/jni/lib/src/lang/jdouble.dart +++ b/pkgs/jni/lib/src/lang/jdouble.dart @@ -8,7 +8,7 @@ import '../third_party/generated_bindings.dart'; import '../types.dart'; import 'jnumber.dart'; -class JDoubleType extends JObjType { +final class JDoubleType extends JObjType { const JDoubleType(); @override diff --git a/pkgs/jni/lib/src/lang/jfloat.dart b/pkgs/jni/lib/src/lang/jfloat.dart index f23c23738..a352659ea 100644 --- a/pkgs/jni/lib/src/lang/jfloat.dart +++ b/pkgs/jni/lib/src/lang/jfloat.dart @@ -9,7 +9,7 @@ import '../third_party/generated_bindings.dart'; import '../types.dart'; import 'jnumber.dart'; -class JFloatType extends JObjType { +final class JFloatType extends JObjType { const JFloatType(); @override diff --git a/pkgs/jni/lib/src/lang/jinteger.dart b/pkgs/jni/lib/src/lang/jinteger.dart index 907d7ba9f..8ece46679 100644 --- a/pkgs/jni/lib/src/lang/jinteger.dart +++ b/pkgs/jni/lib/src/lang/jinteger.dart @@ -9,7 +9,7 @@ import '../third_party/generated_bindings.dart'; import '../types.dart'; import 'jnumber.dart'; -class JIntegerType extends JObjType { +final class JIntegerType extends JObjType { const JIntegerType(); @override diff --git a/pkgs/jni/lib/src/lang/jlong.dart b/pkgs/jni/lib/src/lang/jlong.dart index fb2ee8011..66d054b98 100644 --- a/pkgs/jni/lib/src/lang/jlong.dart +++ b/pkgs/jni/lib/src/lang/jlong.dart @@ -8,7 +8,7 @@ import '../third_party/generated_bindings.dart'; import '../types.dart'; import 'jnumber.dart'; -class JLongType extends JObjType { +final class JLongType extends JObjType { const JLongType(); @override diff --git a/pkgs/jni/lib/src/lang/jnumber.dart b/pkgs/jni/lib/src/lang/jnumber.dart index 43e108568..45d86dc0b 100644 --- a/pkgs/jni/lib/src/lang/jnumber.dart +++ b/pkgs/jni/lib/src/lang/jnumber.dart @@ -17,7 +17,7 @@ import 'jinteger.dart'; import 'jlong.dart'; import 'jshort.dart'; -class JNumberType extends JObjType { +final class JNumberType extends JObjType { const JNumberType(); @override diff --git a/pkgs/jni/lib/src/lang/jshort.dart b/pkgs/jni/lib/src/lang/jshort.dart index a07ea4e40..39d3c1d54 100644 --- a/pkgs/jni/lib/src/lang/jshort.dart +++ b/pkgs/jni/lib/src/lang/jshort.dart @@ -9,7 +9,7 @@ import '../third_party/generated_bindings.dart'; import '../types.dart'; import 'jnumber.dart'; -class JShortType extends JObjType { +final class JShortType extends JObjType { const JShortType(); @override diff --git a/pkgs/jni/lib/src/lang/jstring.dart b/pkgs/jni/lib/src/lang/jstring.dart index 43bda602d..9e542ff9b 100644 --- a/pkgs/jni/lib/src/lang/jstring.dart +++ b/pkgs/jni/lib/src/lang/jstring.dart @@ -12,7 +12,7 @@ import '../jobject.dart'; import '../third_party/generated_bindings.dart'; import '../types.dart'; -class JStringType extends JObjType { +final class JStringType extends JObjType { const JStringType(); @override diff --git a/pkgs/jni/lib/src/nio/jbuffer.dart b/pkgs/jni/lib/src/nio/jbuffer.dart new file mode 100644 index 000000000..cae6bc973 --- /dev/null +++ b/pkgs/jni/lib/src/nio/jbuffer.dart @@ -0,0 +1,255 @@ +// 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 '../accessors.dart'; +import '../jni.dart'; +import '../jobject.dart'; +import '../jvalues.dart'; +import '../third_party/generated_bindings.dart'; +import '../types.dart'; + +final class JBufferType extends JObjType { + const JBufferType(); + + @override + String get signature => r"Ljava/nio/Buffer;"; + + @override + JBuffer fromRef(JObjectPtr ref) => JBuffer.fromRef(ref); + + @override + JObjType get superType => const JObjectType(); + + @override + final superCount = 1; + + @override + int get hashCode => (JBufferType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == (JBufferType) && other is JBufferType; + } +} + +/// A container for data of a specific primitive type. +/// +/// The bindings for `java.nio.Buffer`. +/// +/// A buffer is a linear, finite sequence of elements of a specific primitive +/// type. Aside from its content, the essential properties of a buffer are its +/// [capacity], [limit], and [position]. +/// +/// 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 { + @override + // ignore: overridden_fields + late final JObjType $type = type; + + JBuffer.fromRef( + JObjectPtr ref, + ) : super.fromRef(ref); + + static final _class = Jni.findJClass(r"java/nio/Buffer"); + + /// The type which includes information such as the signature of this class. + static const type = JBufferType(); + + static final _capacityId = + Jni.accessors.getMethodIDOf(_class.reference, r"capacity", r"()I"); + + /// The number of elements this buffer contains. + /// + /// It is never negative and never changes. + int get capacity { + return Jni.accessors.callMethodWithArgs( + reference, _capacityId, JniCallType.intType, []).integer; + } + + static final _positionId = + Jni.accessors.getMethodIDOf(_class.reference, r"position", r"()I"); + + /// The index of the next element to be read or written. + /// + /// It is never negative and is never greater than its [limit]. + int get position { + return Jni.accessors.callMethodWithArgs( + reference, _positionId, JniCallType.intType, []).integer; + } + + static final _setPositionId = Jni.accessors + .getMethodIDOf(_class.reference, r"position", r"(I)Ljava/nio/Buffer;"); + + /// Throws: + /// * [IllegalArgumentException] - If the preconditions on [newPosition] do + /// not hold. + set position(int position) { + Jni.env.DeleteGlobalRef(Jni.accessors.callMethodWithArgs(reference, + _setPositionId, JniCallType.objectType, [JValueInt(position)]).object); + } + + static final _limitId = + Jni.accessors.getMethodIDOf(_class.reference, r"limit", r"()I"); + + /// The index of the first element that should not be read or written. + /// + /// It is never negative and is never greater than its [capacity]. + int get limit { + return Jni.accessors.callMethodWithArgs( + reference, _limitId, JniCallType.intType, []).integer; + } + + static final _setLimitId = Jni.accessors + .getMethodIDOf(_class.reference, r"limit", r"(I)Ljava/nio/Buffer;"); + + /// Throws: + /// * [IllegalArgumentException] - If the preconditions on [newLimit] do not + /// hold. + set limit(int newLimit) { + Jni.env.DeleteGlobalRef(Jni.accessors.callMethodWithArgs(reference, + _setLimitId, JniCallType.objectType, [JValueInt(newLimit)]).object); + } + + static final _markId = Jni.accessors + .getMethodIDOf(_class.reference, r"mark", r"()Ljava/nio/Buffer;"); + + /// Sets this buffer's mark at its [position]. + /// + /// Mark is the index to which its [position] will be reset when the [reset] + /// method is invoked. + void mark() { + Jni.env.DeleteGlobalRef(Jni.accessors.callMethodWithArgs( + reference, _markId, JniCallType.objectType, []).object); + } + + static final _resetId = Jni.accessors + .getMethodIDOf(_class.reference, r"reset", r"()Ljava/nio/Buffer;"); + + /// Resets this buffer's [position] to the previously-marked position. + /// + /// Throws: + /// * [InvalidMarkException] - If the mark has not been set + void reset() { + Jni.env.DeleteGlobalRef(Jni.accessors.callMethodWithArgs( + reference, _resetId, JniCallType.objectType, []).object); + } + + static final _clearId = Jni.accessors + .getMethodIDOf(_class.reference, r"clear", r"()Ljava/nio/Buffer;"); + + /// Clears this buffer. + /// + /// The [position] is set to zero, the [limit] is set to + /// the [capacity], and the mark is discarded. + void clear() { + Jni.env.DeleteGlobalRef(Jni.accessors.callMethodWithArgs( + reference, _clearId, JniCallType.objectType, []).object); + } + + static final _flipId = Jni.accessors + .getMethodIDOf(_class.reference, r"flip", r"()Ljava/nio/Buffer;"); + + /// Flips this buffer. + /// + /// The limit is set to the current [position] and then the [position] is set + /// to zero. If the mark is defined then it is discarded. + void flip() { + Jni.env.DeleteGlobalRef(Jni.accessors.callMethodWithArgs( + reference, _flipId, JniCallType.objectType, []).object); + } + + static final _rewindId = Jni.accessors + .getMethodIDOf(_class.reference, r"rewind", r"()Ljava/nio/Buffer;"); + + /// Rewinds this buffer. + /// + /// The [position] is set to zero and the mark is discarded. + void rewind() { + Jni.env.DeleteGlobalRef(Jni.accessors.callMethodWithArgs( + reference, _rewindId, JniCallType.objectType, []).object); + } + + static final _remainingId = + Jni.accessors.getMethodIDOf(_class.reference, r"remaining", r"()I"); + + /// The number of elements between the current [position] and the + /// [limit]. + int get remaining { + return Jni.accessors.callMethodWithArgs( + reference, _remainingId, JniCallType.intType, []).integer; + } + + static final _hasRemainingId = + Jni.accessors.getMethodIDOf(_class.reference, r"hasRemaining", r"()Z"); + + /// Whether there are any elements between the current [position] and + /// the [limit]. + bool get hasRemaining { + return Jni.accessors.callMethodWithArgs( + reference, _hasRemainingId, JniCallType.booleanType, []).boolean; + } + + static final _isReadOnlyId = + Jni.accessors.getMethodIDOf(_class.reference, r"isReadOnly", r"()Z"); + + /// Whether or not this buffer is read-only. + bool get isReadOnly { + return Jni.accessors.callMethodWithArgs( + reference, _isReadOnlyId, JniCallType.booleanType, []).boolean; + } + + static final _hasArrayId = + Jni.accessors.getMethodIDOf(_class.reference, r"hasArray", r"()Z"); + + /// Whether or not this buffer is backed by an accessible array. + bool get hasArray { + return Jni.accessors.callMethodWithArgs( + reference, _hasArrayId, JniCallType.booleanType, []).boolean; + } + + static final _arrayId = Jni.accessors + .getMethodIDOf(_class.reference, r"array", r"()Ljava/lang/Object;"); + + /// The array that backs this buffer. + /// + /// Concrete subclasses like [JByteBuffer] provide more strongly-typed return + /// values for this method. + /// + /// Throws: + /// * [ReadOnlyBufferException] - If this buffer is backed by an array but is + /// read-only + /// * [UnsupportedOperationException] - If this buffer is not backed by an + /// accessible array + JObject get array { + return const JObjectType().fromRef(Jni.accessors.callMethodWithArgs( + reference, _arrayId, JniCallType.objectType, []).object); + } + + static final _arrayOffsetId = + Jni.accessors.getMethodIDOf(_class.reference, r"arrayOffset", r"()I"); + + /// The offset within this buffer's backing array of the first element + /// of the buffer. + /// + /// Throws: + /// * [ReadOnlyBufferException] - If this buffer is backed by an array but is + /// read-only + /// * [UnsupportedOperationException] - If this buffer is not backed by an + /// accessible array + int get arrayOffset { + return Jni.accessors.callMethodWithArgs( + reference, _arrayOffsetId, JniCallType.intType, []).integer; + } + + static final _isDirectId = + Jni.accessors.getMethodIDOf(_class.reference, r"isDirect", r"()Z"); + + /// Whether or not this buffer is direct. + bool get isDirect { + return Jni.accessors.callMethodWithArgs( + reference, _isDirectId, JniCallType.booleanType, []).boolean; + } +} diff --git a/pkgs/jni/lib/src/nio/jbyte_buffer.dart b/pkgs/jni/lib/src/nio/jbyte_buffer.dart new file mode 100644 index 000000000..1b0acb2b3 --- /dev/null +++ b/pkgs/jni/lib/src/nio/jbyte_buffer.dart @@ -0,0 +1,316 @@ +// 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 'dart:ffi'; +import 'dart:typed_data'; + +import '../accessors.dart'; +import '../jarray.dart'; +import '../jni.dart'; +import '../jprimitives.dart'; +import '../jreference.dart'; +import '../jvalues.dart'; +import '../third_party/generated_bindings.dart'; +import '../types.dart'; +import 'jbuffer.dart'; + +final class JByteBufferType extends JObjType { + const JByteBufferType(); + + @override + String get signature => r"Ljava/nio/ByteBuffer;"; + + @override + JByteBuffer fromRef(JObjectPtr ref) => JByteBuffer.fromRef(ref); + + @override + JObjType get superType => const JBufferType(); + + @override + final superCount = 2; + + @override + int get hashCode => (JByteBufferType).hashCode; + + @override + bool operator ==(Object other) { + return other.runtimeType == (JByteBufferType) && other is JByteBufferType; + } +} + +/// A byte [JBuffer]. +/// +/// The bindings for `java.nio.ByteBuffer`. +/// +/// This enables fast memory copying between Java and Dart when directly +/// allocated (See [JByteBuffer.allocateDirect]). +/// +/// To create a [JByteBuffer] from the content of a [Uint8List], +/// use [JByteBuffer.fromList]. This uses direct allocation to enable fast +/// copying. +/// +/// [asUint8List] provides a direct access to the underlying [Uint8List] that +/// this buffer uses. This means any changes to it will change the content of +/// the buffer and vice versa. This can be used to access to [Uint8List] methods +/// such as [Uint8List.setRange]. +/// +/// Example: +/// ```dart +/// final directBuffer = JByteBuffer.allocateDirect(3); +/// directBuffer.asUint8List().setAll(0, [1, 2, 3]); +/// // The buffer is now 1, 2, 3. +/// ``` +/// +/// Both the original buffer and the [Uint8List] keep the underlying Java buffer +/// alive. Once all the instances of the original buffer and the lists produced +/// from [asUint8List] are inaccessible both in Java and Dart, Java will +/// correctly garbage collects the buffer and frees its underlying memory. +/// +/// Example: +/// ```dart +/// final directBuffer = JByteBuffer.allocateDirect(3); +/// final data = directBuffer.asUint8List(); +/// directBuffer.release(); // Releasing the original buffer. +/// data.setAll(0, [1, 2, 3]); // Works! [data] is still accessible. +/// ``` +/// +/// The original buffer can be [release]d when calling [asUint8List] +/// by setting the `releaseOriginal` parameter to `true`. +/// +/// Example: +/// ```dart +/// final directBuffer = JByteBuffer.allocateDirect(3); +/// // [releaseOriginal] is `false` by default. +/// final data1 = directBuffer.asUint8List(); +/// directBuffer.nextByte = 42; // No problem! +/// print(data1[0]); // prints 42! +/// final data2 = directBuffer.asUint8List(releaseOriginal: true); +/// // directBuffer.nextByte = 42; // throws [UseAfterReleaseException]! +/// ``` +class JByteBuffer extends JBuffer { + @override + // ignore: overridden_fields + late final JObjType $type = type; + + JByteBuffer.fromRef( + JObjectPtr ref, + ) : super.fromRef(ref); + + static final _class = Jni.findJClass(r"java/nio/ByteBuffer"); + + /// The type which includes information such as the signature of this class. + static const type = JByteBufferType(); + + static final _allocateDirectId = Jni.accessors.getStaticMethodIDOf( + _class.reference, r"allocateDirect", r"(I)Ljava/nio/ByteBuffer;"); + + /// Allocates a new direct byte buffer. + /// + /// Throws: + /// * [IllegalArgumentException] - If the capacity is a negative integer + factory JByteBuffer.allocateDirect(int capacity) { + return JByteBuffer.fromRef( + Jni.accessors.callStaticMethodWithArgs( + _class.reference, + _allocateDirectId, + JniCallType.objectType, + [JValueInt(capacity)]).object, + ); + } + + static final _allocateId = Jni.accessors.getStaticMethodIDOf( + _class.reference, r"allocate", r"(I)Ljava/nio/ByteBuffer;"); + + /// Allocates a new byte buffer. + /// + /// Throws: + /// * [IllegalArgumentException] - If the capacity is a negative integer + factory JByteBuffer.allocate(int capacity) { + return const JByteBufferType().fromRef(Jni.accessors + .callStaticMethodWithArgs(_class.reference, _allocateId, + JniCallType.objectType, [JValueInt(capacity)]).object); + } + + static final _wrapWholeId = Jni.accessors.getStaticMethodIDOf( + _class.reference, r"wrap", r"([B)Ljava/nio/ByteBuffer;"); + static final _wrapId = Jni.accessors.getStaticMethodIDOf( + _class.reference, r"wrap", r"([BII)Ljava/nio/ByteBuffer;"); + + /// Wraps a byte array into a buffer. + /// + /// The new buffer will be backed by the given byte array; that is, + /// modifications to the buffer will cause the array to be modified + /// and vice versa. + static JByteBuffer wrap( + JArray array, [ + int? offset, + int? length, + ]) { + if (offset == null && length == null) { + return const JByteBufferType().fromRef( + Jni.accessors.callStaticMethodWithArgs( + _class.reference, + _wrapWholeId, + JniCallType.objectType, + [array.reference], + ).object, + ); + } + offset ??= 0; + length ??= array.length - offset; + return const JByteBufferType().fromRef( + Jni.accessors.callStaticMethodWithArgs( + _class.reference, + _wrapId, + JniCallType.objectType, + [array.reference, JValueInt(offset), JValueInt(length)], + ).object, + ); + } + + /// Creates a [JByteBuffer] from the content of [list]. + /// + /// The [JByteBuffer] will be allocated using [JByteBuffer.allocateDirect]. + factory JByteBuffer.fromList(Uint8List list) { + final buffer = JByteBuffer.allocateDirect(list.length); + buffer._asUint8ListUnsafe().setAll(0, list); + return buffer; + } + + static final _sliceId = Jni.accessors + .getMethodIDOf(_class.reference, r"slice", r"()Ljava/nio/ByteBuffer;"); + + /// Creates a new byte buffer whose content is a shared subsequence of this + /// buffer's content. + JByteBuffer slice() { + return const JByteBufferType().fromRef(Jni.accessors.callMethodWithArgs( + reference, _sliceId, JniCallType.objectType, []).object); + } + + static final _duplicateId = Jni.accessors.getMethodIDOf( + _class.reference, r"duplicate", r"()Ljava/nio/ByteBuffer;"); + + /// Creates a new byte buffer that shares this buffer's content. + JByteBuffer duplicate() { + return const JByteBufferType().fromRef(Jni.accessors.callMethodWithArgs( + reference, _duplicateId, JniCallType.objectType, []).object); + } + + static final _asReadOnlyBufferId = Jni.accessors.getMethodIDOf( + _class.reference, r"asReadOnlyBuffer", r"()Ljava/nio/ByteBuffer;"); + + /// Creates a new, read-only byte buffer that shares this buffer's content. + JByteBuffer asReadOnlyBuffer() { + return const JByteBufferType().fromRef(Jni.accessors.callMethodWithArgs( + reference, _asReadOnlyBufferId, JniCallType.objectType, []).object); + } + + static final _getId = + Jni.accessors.getMethodIDOf(_class.reference, r"get", r"()B"); + + /// Reads the byte at this buffer's current [position], and then increments the + /// [position]. + /// + /// Throws: + /// * [BufferOverflowException] - If the buffer's current [position] is not + /// smaller than its [limit] + int get nextByte { + return Jni.accessors + .callMethodWithArgs(reference, _getId, JniCallType.byteType, []).byte; + } + + static final _putId = Jni.accessors + .getMethodIDOf(_class.reference, r"put", r"(B)Ljava/nio/ByteBuffer;"); + + /// Writes the given byte into this buffer at the current [position], and then + /// increments the [position]. + /// + /// Throws: + /// * [BufferOverflowException] - If this buffer's current [position] is not + /// smaller than its [limit] + /// * [ReadOnlyBufferException] - If this buffer is read-only + set nextByte(int b) { + Jni.env.DeleteGlobalRef(Jni.accessors.callMethodWithArgs( + reference, _putId, JniCallType.objectType, [JValueByte(b)]).object); + } + + static final _arrayId = + Jni.accessors.getMethodIDOf(_class.reference, r"array", r"()[B"); + + @override + JArray get array { + return const JArrayType(jbyteType()).fromRef(Jni.accessors + .callMethodWithArgs( + reference, _arrayId, JniCallType.objectType, []).object); + } + + void _ensureIsDirect() { + if (!isDirect) { + throw StateError( + 'The buffer must be created with `JByteBuffer.allocateDirect`.', + ); + } + } + + Pointer _directBufferAddress() { + final address = Jni.env.GetDirectBufferAddress(reference); + if (address == nullptr) { + throw StateError( + 'The memory region is undefined or ' + 'direct buffer access is not supported by this JVM.', + ); + } + return address; + } + + int _directBufferCapacity() { + final capacity = Jni.env.GetDirectBufferCapacity(reference); + if (capacity == -1) { + throw StateError( + 'The object is an unaligned view buffer and the processor ' + 'architecture does not support unaligned access.', + ); + } + return capacity; + } + + Uint8List _asUint8ListUnsafe() { + _ensureIsDirect(); + final address = _directBufferAddress(); + final capacity = _directBufferCapacity(); + return address.cast().asTypedList(capacity); + } + + /// Returns this byte buffer as a [Uint8List]. + /// + /// If [releaseOriginal] is `true`, this byte buffer will be released. + /// + /// Throws [StateError] if the buffer is not direct + /// (see [JByteBuffer.allocateDirect]) or the JVM does not support the direct + /// buffer operations or the object is an unaligned view buffer and + /// the processor does not support unaligned access. + Uint8List asUint8List({bool releaseOriginal = false}) { + _ensureIsDirect(); + final address = _directBufferAddress(); + final capacity = _directBufferCapacity(); + final token = releaseOriginal ? reference : Jni.env.NewGlobalRef(reference); + if (releaseOriginal) { + setAsReleased(); + } + return address.cast().asTypedList( + capacity, + token: token, + finalizer: Jni.env.ptr.ref.DeleteGlobalRef.cast(), + ); + } +} + +extension Uint8ListToJava on Uint8List { + /// Creates a [JByteBuffer] from the content of this list. + /// + /// The [JByteBuffer] will be allocated using [JByteBuffer.allocateDirect]. + JByteBuffer toJByteBuffer() { + return JByteBuffer.fromList(this); + } +} diff --git a/pkgs/jni/lib/src/nio/nio.dart b/pkgs/jni/lib/src/nio/nio.dart new file mode 100644 index 000000000..3092870fa --- /dev/null +++ b/pkgs/jni/lib/src/nio/nio.dart @@ -0,0 +1,6 @@ +// 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. + +export 'jbuffer.dart'; +export 'jbyte_buffer.dart'; diff --git a/pkgs/jni/lib/src/util/jiterator.dart b/pkgs/jni/lib/src/util/jiterator.dart index eab305d00..0d0122ff1 100644 --- a/pkgs/jni/lib/src/util/jiterator.dart +++ b/pkgs/jni/lib/src/util/jiterator.dart @@ -8,7 +8,7 @@ import '../jobject.dart'; import '../third_party/generated_bindings.dart'; import '../types.dart'; -class JIteratorType<$E extends JObject> extends JObjType> { +final class JIteratorType<$E extends JObject> extends JObjType> { final JObjType<$E> E; const JIteratorType( diff --git a/pkgs/jni/lib/src/util/jlist.dart b/pkgs/jni/lib/src/util/jlist.dart index 19cb1ed07..9779032a7 100644 --- a/pkgs/jni/lib/src/util/jlist.dart +++ b/pkgs/jni/lib/src/util/jlist.dart @@ -15,7 +15,7 @@ import '../third_party/generated_bindings.dart'; import '../types.dart'; import 'jiterator.dart'; -class JListType<$E extends JObject> extends JObjType> { +final class JListType<$E extends JObject> extends JObjType> { final JObjType<$E> E; const JListType( @@ -193,10 +193,11 @@ class JList<$E extends JObject> extends JObject with ListMixin<$E> { Jni.env.IsInstanceOf( (iterable as JObject).reference, _collectionClass.reference)) { Jni.accessors.callMethodWithArgs( - reference, - _insertAllId, - JniCallType.booleanType, - [JValueInt(index), (iterable as JObject).reference]); + reference, + _insertAllId, + JniCallType.booleanType, + [JValueInt(index), (iterable as JObject).reference], + ).boolean; return; } super.insertAll(index, iterable); diff --git a/pkgs/jni/lib/src/util/jmap.dart b/pkgs/jni/lib/src/util/jmap.dart index 015fea859..73a6d6237 100644 --- a/pkgs/jni/lib/src/util/jmap.dart +++ b/pkgs/jni/lib/src/util/jmap.dart @@ -11,7 +11,7 @@ import '../third_party/jni_bindings_generated.dart'; import '../types.dart'; import 'jset.dart'; -class JMapType<$K extends JObject, $V extends JObject> +final class JMapType<$K extends JObject, $V extends JObject> extends JObjType> { final JObjType<$K> K; final JObjType<$V> V; @@ -107,11 +107,9 @@ class JMap<$K extends JObject, $V extends JObject> extends JObject if (other is JMap<$K, $V>) { Jni.accessors.callMethodWithArgs(reference, _addAllId, JniCallType.voidType, [other.reference]).check(); - } else { - for (final entry in other.entries) { - this[entry.key] = entry.value; - } + return; } + super.addAll(other); } static final _clearId = diff --git a/pkgs/jni/lib/src/util/jset.dart b/pkgs/jni/lib/src/util/jset.dart index 367c1213c..df5100361 100644 --- a/pkgs/jni/lib/src/util/jset.dart +++ b/pkgs/jni/lib/src/util/jset.dart @@ -12,7 +12,7 @@ import '../jobject.dart'; import '../types.dart'; import 'jiterator.dart'; -class JSetType<$E extends JObject> extends JObjType> { +final class JSetType<$E extends JObject> extends JObjType> { final JObjType<$E> E; const JSetType( @@ -93,6 +93,7 @@ class JSet<$E extends JObject> extends JObject with SetMixin<$E> { JniCallType.booleanType, [(elements as JObject).reference], ).boolean; + return; } return super.addAll(elements); } @@ -173,6 +174,7 @@ class JSet<$E extends JObject> extends JObject with SetMixin<$E> { (elements as JObject).reference, _collectionClass.reference)) { Jni.accessors.callMethodWithArgs(reference, _removeAllId, JniCallType.booleanType, [(elements as JObject).reference]).boolean; + return; } return super.removeAll(elements); } @@ -186,6 +188,7 @@ class JSet<$E extends JObject> extends JObject with SetMixin<$E> { (elements as JObject).reference, _collectionClass.reference)) { Jni.accessors.callMethodWithArgs(reference, _retainAllId, JniCallType.booleanType, [(elements as JObject).reference]).boolean; + return; } return super.retainAll(elements); } diff --git a/pkgs/jni/pubspec.yaml b/pkgs/jni/pubspec.yaml index 62ba94d4f..46bedce2f 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.6.1 +version: 0.7.0 repository: https://github.com/dart-lang/jnigen/tree/main/jni topics: diff --git a/pkgs/jni/test/jarray_test.dart b/pkgs/jni/test/jarray_test.dart index 3cc7c9885..9a9f59cc3 100644 --- a/pkgs/jni/test/jarray_test.dart +++ b/pkgs/jni/test/jarray_test.dart @@ -319,6 +319,12 @@ void run({required TestRunnerCallback testRunner}) { expect((arr[0]..releasedBy(arena)).isNull, true); }); }); + testRunner('JArray of JCharacter', () { + using((arena) { + final arr = JArray(JCharacter.type, 1)..releasedBy(arena); + expect((arr[0]..releasedBy(arena)).isNull, true); + }); + }); testRunner('JArray of JLong', () { using((arena) { final arr = JArray(JLong.type, 1)..releasedBy(arena); diff --git a/pkgs/jni/test/jbyte_buffer_test.dart b/pkgs/jni/test/jbyte_buffer_test.dart new file mode 100644 index 000000000..f68c47b0d --- /dev/null +++ b/pkgs/jni/test/jbyte_buffer_test.dart @@ -0,0 +1,229 @@ +// 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 'dart:io'; +import 'dart:typed_data'; + +import 'package:jni/jni.dart'; +import 'package:test/test.dart'; + +import 'test_util/test_util.dart'; + +void main() { + // Don't forget to initialize JNI. + if (!Platform.isAndroid) { + checkDylibIsUpToDate(); + Jni.spawnIfNotExists(dylibDir: "build/jni_libs", jvmOptions: ["-Xmx128m"]); + } + run(testRunner: test); +} + +void run({required TestRunnerCallback testRunner}) { + final throwsAJniException = throwsA(isA()); + JByteBuffer testDataBuffer(Arena arena) { + final buffer = JByteBuffer.allocate(3)..releasedBy(arena); + buffer.nextByte = 1; + buffer.nextByte = 2; + buffer.nextByte = 3; + buffer.position = 0; + return buffer; + } + + testRunner('wrap whole array', () { + using((arena) { + final array = JArray(jbyte.type, 3)..releasedBy(arena); + array[0] = 1; + array[1] = 2; + array[2] = 3; + final buffer = JByteBuffer.wrap(array)..releasedBy(arena); + expect(buffer, testDataBuffer(arena)); + }); + }); + + testRunner('wrap partial array', () { + using((arena) { + final array = JArray(jbyte.type, 3)..releasedBy(arena); + array[0] = 1; + array[1] = 2; + array[2] = 3; + final buffer = JByteBuffer.wrap(array, 1, 1)..releasedBy(arena); + expect(buffer.nextByte, 2); + expect(() => buffer.nextByte, throwsAJniException); + }); + }); + + testRunner('capacity', () { + using((arena) { + final buffer = testDataBuffer(arena); + expect(buffer.capacity, 3); + }); + }); + + testRunner('position', () { + using((arena) { + final buffer = testDataBuffer(arena); + expect(buffer.position, 0); + buffer.position = 2; + expect(buffer.position, 2); + }); + }); + + testRunner('limit', () { + using((arena) { + final buffer = testDataBuffer(arena); + expect(buffer.limit, 3); + buffer.limit = 2; + expect(buffer.limit, 2); + }); + }); + + testRunner('mark and reset', () { + using((arena) { + final buffer = testDataBuffer(arena); + buffer.position = 1; + buffer.mark(); + buffer.position = 2; + buffer.reset(); + expect(buffer.position, 1); + }); + }); + + testRunner('clear', () { + using((arena) { + final buffer = testDataBuffer(arena); + buffer.position = 2; + buffer.limit = 2; + buffer.clear(); + expect(buffer.limit, 3); + expect(buffer.position, 0); + }); + }); + + testRunner('flip', () { + using((arena) { + final buffer = testDataBuffer(arena); + buffer.position = 2; + buffer.flip(); + expect(buffer.limit, 2); + expect(buffer.position, 0); + }); + }); + + testRunner('rewind', () { + using((arena) { + final buffer = testDataBuffer(arena); + buffer.mark(); + buffer.position = 2; + buffer.rewind(); + expect(buffer.position, 0); + expect(buffer.reset, throwsAJniException); + }); + }); + + testRunner('remaining and hasRemaining', () { + using((arena) { + final buffer = testDataBuffer(arena); + buffer.position = 2; + expect(buffer.remaining, 1); + expect(buffer.hasRemaining, true); + buffer.position = 3; + expect(buffer.remaining, 0); + expect(buffer.hasRemaining, false); + }); + }); + + testRunner('isReadOnly and asReadOnlyBuffer', () { + using((arena) { + final buffer = testDataBuffer(arena); + expect(buffer.isReadOnly, false); + final readOnly = buffer.asReadOnlyBuffer()..releasedBy(arena); + expect(readOnly.isReadOnly, true); + }); + }); + + testRunner('hasArray, array and arrayOffset', () { + using((arena) { + final buffer = testDataBuffer(arena); + expect(buffer.hasArray, true); + expect(buffer.arrayOffset, 0); + expect(buffer.array.length, 3); + final directBuffer = JByteBuffer.allocateDirect(3)..releasedBy(arena); + expect(directBuffer.hasArray, false); + }); + }); + + testRunner('isDirect', () { + using((arena) { + final buffer = testDataBuffer(arena); + expect(buffer.isDirect, false); + final directBuffer = JByteBuffer.allocateDirect(3)..releasedBy(arena); + expect(directBuffer.isDirect, true); + }); + }); + + testRunner('slice', () { + using((arena) { + final buffer = testDataBuffer(arena); + buffer.position = 1; + buffer.limit = 2; + final sliced = buffer.slice()..releasedBy(arena); + expect(sliced.capacity, 1); + expect(sliced.nextByte, 2); + }); + }); + + testRunner('duplicate', () { + using((arena) { + final buffer = testDataBuffer(arena); + buffer.position = 1; + buffer.limit = 2; + final duplicate = buffer.duplicate()..releasedBy(arena); + expect(duplicate.capacity, 3); + expect(duplicate.position, 1); + expect(duplicate.limit, 2); + }); + }); + + testRunner('asUint8List', () { + using((arena) { + final buffer = testDataBuffer(arena); + expect(buffer.asUint8List, throwsA(isA())); + final list = Uint8List.fromList([1, 2, 3]); + final directBuffer = list.toJByteBuffer()..releasedBy(arena); + expect(directBuffer.asUint8List(), list); + }); + }); + + 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.fromRef(nullptr); + final d = JBuffer.fromRef(nullptr); + 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]. + final directBuffer = JByteBuffer.allocateDirect(3); + final data1 = directBuffer.asUint8List(); + directBuffer.nextByte = 42; // No problem! + expect(data1[0], 42); + final data2 = directBuffer.asUint8List(releaseOriginal: true); + expect( + () => directBuffer.nextByte = 42, + throwsA(isA()), + ); + expect(data2[0], 42); + }); + }); +} diff --git a/pkgs/jni/test/type_test.dart b/pkgs/jni/test/type_test.dart index f0f3caaab..0ad8490af 100644 --- a/pkgs/jni/test/type_test.dart +++ b/pkgs/jni/test/type_test.dart @@ -25,7 +25,7 @@ class A extends JObject { JObjType get $type => $AType(); } -class $AType extends JObjType { +final class $AType extends JObjType { @override A fromRef(Pointer ref) { return A.fromRef(ref); @@ -55,7 +55,7 @@ class B extends JObject { JObjType get $type => $BType(); } -class $BType extends JObjType { +final class $BType extends JObjType { @override B fromRef(Pointer ref) { return B.fromRef(ref); @@ -86,7 +86,7 @@ class C extends A { JObjType get $type => $CType(); } -class $CType extends JObjType { +final class $CType extends JObjType { @override C fromRef(Pointer ref) { return C.fromRef(ref); @@ -117,7 +117,7 @@ class D extends A { JObjType get $type => $DType(); } -class $DType extends JObjType { +final class $DType extends JObjType { @override D fromRef(Pointer ref) { return D.fromRef(ref); @@ -148,7 +148,7 @@ class E extends B { JObjType get $type => $EType(); } -class $EType extends JObjType { +final class $EType extends JObjType { @override E fromRef(Pointer ref) { return E.fromRef(ref); @@ -179,7 +179,7 @@ class F extends C { JObjType get $type => $FType(); } -class $FType extends JObjType { +final class $FType extends JObjType { @override F fromRef(Pointer ref) { return F.fromRef(ref); @@ -292,6 +292,13 @@ void run({required TestRunnerCallback testRunner}) { ]), JObject.type, ); + expect( + lowestCommonSuperType([ + JByteBuffer.type, + JBuffer.type, + ]), + JBuffer.type, + ); }); }); diff --git a/pkgs/jnigen/CHANGELOG.md b/pkgs/jnigen/CHANGELOG.md index 7e18e4020..00b2fc18e 100644 --- a/pkgs/jnigen/CHANGELOG.md +++ b/pkgs/jnigen/CHANGELOG.md @@ -1,41 +1,74 @@ -## 0.6.1-wip -* Add `ignore_for_file: lines_longer_than_80_chars` to the generated file preamble. -* Added an explicit cast in generated `.implement` code to allow `dart analyze` to pass when `strict-casts` is set. +## 0.7.0 + +- **Breaking Change** ([#387](https://github.com/dart-lang/jnigen/issues/387)): + Added `JBuffer` and `JByteBuffer` classes as default classes for + `java.nio.Buffer` and `java.nio.ByteBuffer` respectively. +- **Breaking Change**: Made the type classes `final`. +- Added `ignore_for_file: lines_longer_than_80_chars` to the generated file + preamble. +- Added an explicit cast in generated `.implement` code to allow + `dart analyze` to pass when `strict-casts` is set. ## 0.6.0 -* **Breaking Change** ([#131](https://github.com/dart-lang/jnigen/issues/131)): Renamed `delete*` to `release*`. -* **Breaking Change** ([#354](https://github.com/dart-lang/jnigen/issues/354)): Renamed constructors from `ctor1`, `ctor2`, ... to `new1`, `new2`, ... -* **Breaking Change**: Specifying a class always pulls in nested classes by default. If a nested class is specified in config, it will be an error. -* **Breaking Change**: Removed `suspend_fun_to_async` flag from the config. It's now happening by default since we read the Kotlin's metadata and reliably identify the `suspend fun`s. -* Fixed a bug where the nested classes would be generated incorrectly depending on the backend used for generation. -* Fixed a bug where ASM backend would produce the incorrect parent for multi-level nested classes. -* Fixed a bug where the backends would produce different descriptors for the same method. -* Added `enable_experiment` option to config. -* Created an experiment called `interface_implementation` which creates a `.implement` method for interfaces, so you can implement them using Dart. -* Save all `jnigen` logs to a file in `.dart_tool/jnigen/logs/`. This is useful for debugging. + +- **Breaking Change** ([#131](https://github.com/dart-lang/jnigen/issues/131)): + Renamed `delete*` to `release*`. +- **Breaking Change** ([#354](https://github.com/dart-lang/jnigen/issues/354)): + Renamed constructors from `ctor1`, `ctor2`, ... to `new1`, `new2`, ... +- **Breaking Change**: Specifying a class always pulls in nested classes by + default. If a nested class is specified in config, it will be an error. +- **Breaking Change**: Removed `suspend_fun_to_async` flag from the config. It's + now happening by default since we read the Kotlin's metadata and reliably + identify the `suspend fun`s. +- Fixed a bug where the nested classes would be generated incorrectly depending + on the backend used for generation. +- Fixed a bug where ASM backend would produce the incorrect parent for + multi-level nested classes. +- Fixed a bug where the backends would produce different descriptors for the + same method. +- Added `enable_experiment` option to config. +- Created an experiment called `interface_implementation` which creates a + `.implement` method for interfaces, so you can implement them using Dart. +- Save all `jnigen` logs to a file in `.dart_tool/jnigen/logs/`. This is useful + for debugging. ## 0.5.0 -* **Breaking Change** ([#72](https://github.com/dart-lang/jnigen/issues/72)): Removed support for `importMap` in favor of the newly added interop mechanism with importing yaml files. -* **Breaking Change** ([#72](https://github.com/dart-lang/jnigen/issues/72)): `java.util.Set`, `java.util.Map`, `java.util.List`, `java.util.Iterator` and the boxed types like `java.lang.Integer`, `java.lang.Double`, ... will be generated as their corresponding classes in `package:jni`. -* Strings now use UTF16. + +- **Breaking Change** ([#72](https://github.com/dart-lang/jnigen/issues/72)): + Removed support for `importMap` in favor of the newly added interop mechanism + with importing yaml files. +- **Breaking Change** ([#72](https://github.com/dart-lang/jnigen/issues/72)): + `java.util.Set`, `java.util.Map`, `java.util.List`, `java.util.Iterator` and + the boxed types like `java.lang.Integer`, `java.lang.Double`, ... will be + generated as their corresponding classes in `package:jni`. +- Strings now use UTF16. ## 0.4.0 -* **Breaking Change** ([#145](https://github.com/dart-lang/jnigen/issues/145)): Type arguments are now named instead of positional. -* Type parameters can now be inferred when possible. -* Fixed a bug where passing a `long` argument truncated it to `int` in pure dart bindings. -* Removed array extensions from the generated code. -* Added the ability to use source dependencies from Gradle. -* Fixed an issue with the field setter. -* Fixed an issue where exceptions were not properly thrown in pure Dart bindings. + +- **Breaking Change** ([#145](https://github.com/dart-lang/jnigen/issues/145)): + Type arguments are now named instead of positional. +- Type parameters can now be inferred when possible. +- Fixed a bug where passing a `long` argument truncated it to `int` in pure dart + bindings. +- Removed array extensions from the generated code. +- Added the ability to use source dependencies from Gradle. +- Fixed an issue with the field setter. +- Fixed an issue where exceptions were not properly thrown in pure Dart + bindings. ## 0.3.0 -* Added the option to convert Kotlin `suspend fun` to Dart async methods. Add `suspend_fun_to_async: true` to `jnigen.yaml`. + +- Added the option to convert Kotlin `suspend fun` to Dart async methods. Add + `suspend_fun_to_async: true` to `jnigen.yaml`. ## 0.2.0 -* Support generating bindings for generics. + +- Support generating bindings for generics. ## 0.1.1 -* Windows support for running tests and examples on development machines. + +- Windows support for running tests and examples on development machines. ## 0.1.0 -* Initial version: Basic bindings generation, maven and android utilities + +- Initial version: Basic bindings generation, maven and android utilities diff --git a/pkgs/jnigen/example/in_app_java/lib/android_utils.dart b/pkgs/jnigen/example/in_app_java/lib/android_utils.dart index ec722865a..8a0e58a87 100644 --- a/pkgs/jnigen/example/in_app_java/lib/android_utils.dart +++ b/pkgs/jnigen/example/in_app_java/lib/android_utils.dart @@ -55,7 +55,7 @@ class AndroidUtils extends jni.JObject { } } -class $AndroidUtilsType extends jni.JObjType { +final class $AndroidUtilsType extends jni.JObjType { const $AndroidUtilsType(); @override @@ -1027,7 +1027,7 @@ class EmojiCompat extends jni.JObject { } } -class $EmojiCompatType extends jni.JObjType { +final class $EmojiCompatType extends jni.JObjType { const $EmojiCompatType(); @override @@ -1361,7 +1361,7 @@ class EmojiCompat_Config extends jni.JObject { } } -class $EmojiCompat_ConfigType extends jni.JObjType { +final class $EmojiCompat_ConfigType extends jni.JObjType { const $EmojiCompat_ConfigType(); @override @@ -1450,7 +1450,7 @@ class EmojiCompat_MetadataRepoLoaderCallback extends jni.JObject { } } -class $EmojiCompat_MetadataRepoLoaderCallbackType +final class $EmojiCompat_MetadataRepoLoaderCallbackType extends jni.JObjType { const $EmojiCompat_MetadataRepoLoaderCallbackType(); @@ -1551,7 +1551,7 @@ class EmojiCompat_GlyphChecker extends jni.JObject { } } -class $EmojiCompat_GlyphCheckerType +final class $EmojiCompat_GlyphCheckerType extends jni.JObjType { const $EmojiCompat_GlyphCheckerType(); @@ -1613,7 +1613,7 @@ class EmojiCompat_MetadataRepoLoader extends jni.JObject { } } -class $EmojiCompat_MetadataRepoLoaderType +final class $EmojiCompat_MetadataRepoLoaderType extends jni.JObjType { const $EmojiCompat_MetadataRepoLoaderType(); @@ -1697,7 +1697,7 @@ class EmojiCompat_InitCallback extends jni.JObject { } } -class $EmojiCompat_InitCallbackType +final class $EmojiCompat_InitCallbackType extends jni.JObjType { const $EmojiCompat_InitCallbackType(); @@ -1771,7 +1771,7 @@ class EmojiCompat_DefaultSpanFactory extends jni.JObject { } } -class $EmojiCompat_DefaultSpanFactoryType +final class $EmojiCompat_DefaultSpanFactoryType extends jni.JObjType { const $EmojiCompat_DefaultSpanFactoryType(); @@ -1841,7 +1841,7 @@ class EmojiCompat_SpanFactory extends jni.JObject { } } -class $EmojiCompat_SpanFactoryType +final class $EmojiCompat_SpanFactoryType extends jni.JObjType { const $EmojiCompat_SpanFactoryType(); @@ -1939,7 +1939,7 @@ class DefaultEmojiCompatConfig extends jni.JObject { } } -class $DefaultEmojiCompatConfigType +final class $DefaultEmojiCompatConfigType extends jni.JObjType { const $DefaultEmojiCompatConfigType(); @@ -2017,7 +2017,7 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28 } } -class $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28Type +final class $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28Type extends jni .JObjType { const $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API28Type(); @@ -2126,7 +2126,7 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19 } } -class $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19Type +final class $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19Type extends jni .JObjType { const $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper_API19Type(); @@ -2264,7 +2264,8 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelper } } -class $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelperType extends jni +final class $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelperType + extends jni .JObjType { const $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigHelperType(); @@ -2353,7 +2354,8 @@ class DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactory } } -class $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactoryType extends jni +final class $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactoryType + extends jni .JObjType { const $DefaultEmojiCompatConfig_DefaultEmojiCompatConfigFactoryType(); @@ -2461,7 +2463,7 @@ class Build_Partition extends jni.JObject { } } -class $Build_PartitionType extends jni.JObjType { +final class $Build_PartitionType extends jni.JObjType { const $Build_PartitionType(); @override @@ -2613,7 +2615,7 @@ class Build_VERSION extends jni.JObject { } } -class $Build_VERSIONType extends jni.JObjType { +final class $Build_VERSIONType extends jni.JObjType { const $Build_VERSIONType(); @override @@ -2763,7 +2765,7 @@ class Build_VERSION_CODES extends jni.JObject { } } -class $Build_VERSION_CODESType extends jni.JObjType { +final class $Build_VERSION_CODESType extends jni.JObjType { const $Build_VERSION_CODESType(); @override @@ -3112,7 +3114,7 @@ class Build extends jni.JObject { } } -class $BuildType extends jni.JObjType { +final class $BuildType extends jni.JObjType { const $BuildType(); @override @@ -3624,7 +3626,7 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> } } -class $HashMapType<$K extends jni.JObject, $V extends jni.JObject> +final class $HashMapType<$K extends jni.JObject, $V extends jni.JObject> extends jni.JObjType> { final jni.JObjType<$K> K; final jni.JObjType<$V> V; diff --git a/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart b/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart index ed2d034c0..efd0351f8 100644 --- a/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart +++ b/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart @@ -71,7 +71,7 @@ class Example extends jni.JObject { } } -class $ExampleType extends jni.JObjType { +final class $ExampleType extends jni.JObjType { const $ExampleType(); @override diff --git a/pkgs/jnigen/example/notification_plugin/lib/notifications.dart b/pkgs/jnigen/example/notification_plugin/lib/notifications.dart index ebb2f59ef..9855d16ae 100644 --- a/pkgs/jnigen/example/notification_plugin/lib/notifications.dart +++ b/pkgs/jnigen/example/notification_plugin/lib/notifications.dart @@ -75,7 +75,7 @@ class Notifications extends jni.JObject { } } -class $NotificationsType extends jni.JObjType { +final class $NotificationsType extends jni.JObjType { const $NotificationsType(); @override 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 03a9da2a3..b2c40a284 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 @@ -1510,7 +1510,7 @@ class PDDocument extends jni.JObject { } } -class $PDDocumentType extends jni.JObjType { +final class $PDDocumentType extends jni.JObjType { const $PDDocumentType(); @override 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 d928d2137..3c959e764 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 @@ -496,7 +496,8 @@ class PDDocumentInformation extends jni.JObject { } } -class $PDDocumentInformationType extends jni.JObjType { +final class $PDDocumentInformationType + extends jni.JObjType { const $PDDocumentInformationType(); @override 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 b42cd9a60..930240b70 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 @@ -1398,7 +1398,7 @@ class PDFTextStripper extends jni.JObject { } } -class $PDFTextStripperType extends jni.JObjType { +final class $PDFTextStripperType extends jni.JObjType { const $PDFTextStripperType(); @override diff --git a/pkgs/jnigen/lib/src/bindings/dart_generator.dart b/pkgs/jnigen/lib/src/bindings/dart_generator.dart index d8fb60d03..ed523736c 100644 --- a/pkgs/jnigen/lib/src/bindings/dart_generator.dart +++ b/pkgs/jnigen/lib/src/bindings/dart_generator.dart @@ -589,7 +589,7 @@ class _$implClassName$typeParamsDef implements $implClassName$typeParamsCall { ? '($typeClassName).hashCode' : 'Object.hash($typeClassName, $hashCodeTypeClasses)'; s.write(''' -class $typeClassName$typeParamsDef extends $_jType<$name$typeParamsCall> { +final class $typeClassName$typeParamsDef extends $_jType<$name$typeParamsCall> { $typeClassesDef const $typeClassName( diff --git a/pkgs/jnigen/pubspec.yaml b/pkgs/jnigen/pubspec.yaml index d8d08f726..3fbd456ba 100644 --- a/pkgs/jnigen/pubspec.yaml +++ b/pkgs/jnigen/pubspec.yaml @@ -4,7 +4,7 @@ name: jnigen description: A Dart bindings generator for Java and Kotlin that uses JNI under the hood to interop with Java virtual machine. -version: 0.6.1-wip +version: 0.7.0 repository: https://github.com/dart-lang/jnigen/tree/main/jnigen environment: diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart index e1f19fe50..95ddfd579 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart @@ -1854,7 +1854,7 @@ class JsonFactory extends jni.JObject { } } -class $JsonFactoryType extends jni.JObjType { +final class $JsonFactoryType extends jni.JObjType { const $JsonFactoryType(); @override @@ -1969,7 +1969,7 @@ class JsonFactory_Feature extends jni.JObject { } } -class $JsonFactory_FeatureType extends jni.JObjType { +final class $JsonFactory_FeatureType extends jni.JObjType { const $JsonFactory_FeatureType(); @override diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart index 1dac51cc5..5775da71b 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart @@ -2636,7 +2636,7 @@ class JsonParser extends jni.JObject { } } -class $JsonParserType extends jni.JObjType { +final class $JsonParserType extends jni.JObjType { const $JsonParserType(); @override @@ -2750,7 +2750,7 @@ class JsonParser_Feature extends jni.JObject { } } -class $JsonParser_FeatureType extends jni.JObjType { +final class $JsonParser_FeatureType extends jni.JObjType { const $JsonParser_FeatureType(); @override @@ -2818,7 +2818,8 @@ class JsonParser_NumberType extends jni.JObject { } } -class $JsonParser_NumberTypeType extends jni.JObjType { +final class $JsonParser_NumberTypeType + extends jni.JObjType { const $JsonParser_NumberTypeType(); @override diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart index fdbd542ad..bab355e9a 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart @@ -213,7 +213,7 @@ class JsonToken extends jni.JObject { } } -class $JsonTokenType extends jni.JObjType { +final class $JsonTokenType extends jni.JObjType { const $JsonTokenType(); @override diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart index f9f363166..3cdf2ff86 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonFactory.dart @@ -1756,7 +1756,7 @@ class JsonFactory extends jni.JObject { } } -class $JsonFactoryType extends jni.JObjType { +final class $JsonFactoryType extends jni.JObjType { const $JsonFactoryType(); @override @@ -1868,7 +1868,7 @@ class JsonFactory_Feature extends jni.JObject { } } -class $JsonFactory_FeatureType extends jni.JObjType { +final class $JsonFactory_FeatureType extends jni.JObjType { const $JsonFactory_FeatureType(); @override diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart index ae607a98f..d94c22059 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonParser.dart @@ -2489,7 +2489,7 @@ class JsonParser extends jni.JObject { } } -class $JsonParserType extends jni.JObjType { +final class $JsonParserType extends jni.JObjType { const $JsonParserType(); @override @@ -2600,7 +2600,7 @@ class JsonParser_Feature extends jni.JObject { } } -class $JsonParser_FeatureType extends jni.JObjType { +final class $JsonParser_FeatureType extends jni.JObjType { const $JsonParser_FeatureType(); @override @@ -2672,7 +2672,8 @@ class JsonParser_NumberType extends jni.JObject { } } -class $JsonParser_NumberTypeType extends jni.JObjType { +final class $JsonParser_NumberTypeType + extends jni.JObjType { const $JsonParser_NumberTypeType(); @override diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart index da0a49e5c..573a815ac 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/dart_only/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart @@ -199,7 +199,7 @@ class JsonToken extends jni.JObject { } } -class $JsonTokenType extends jni.JObjType { +final class $JsonTokenType extends jni.JObjType { const $JsonTokenType(); @override diff --git a/pkgs/jnigen/test/kotlin_test/c_based/dart_bindings/kotlin.dart b/pkgs/jnigen/test/kotlin_test/c_based/dart_bindings/kotlin.dart index 5b80bb881..3e264274c 100644 --- a/pkgs/jnigen/test/kotlin_test/c_based/dart_bindings/kotlin.dart +++ b/pkgs/jnigen/test/kotlin_test/c_based/dart_bindings/kotlin.dart @@ -102,7 +102,7 @@ class SuspendFun extends jni.JObject { } } -class $SuspendFunType extends jni.JObjType { +final class $SuspendFunType extends jni.JObjType { const $SuspendFunType(); @override diff --git a/pkgs/jnigen/test/kotlin_test/dart_only/dart_bindings/kotlin.dart b/pkgs/jnigen/test/kotlin_test/dart_only/dart_bindings/kotlin.dart index c352dfb02..bd4441f36 100644 --- a/pkgs/jnigen/test/kotlin_test/dart_only/dart_bindings/kotlin.dart +++ b/pkgs/jnigen/test/kotlin_test/dart_only/dart_bindings/kotlin.dart @@ -92,7 +92,7 @@ class SuspendFun extends jni.JObject { } } -class $SuspendFunType extends jni.JObjType { +final class $SuspendFunType extends jni.JObjType { const $SuspendFunType(); @override diff --git a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart index 2879e351c..1142fd675 100644 --- a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart @@ -66,7 +66,7 @@ class Color extends jni.JObject { } } -class $ColorType extends jni.JObjType { +final class $ColorType extends jni.JObjType { const $ColorType(); @override @@ -779,7 +779,7 @@ class Example extends jni.JObject { } } -class $ExampleType extends jni.JObjType { +final class $ExampleType extends jni.JObjType { const $ExampleType(); @override @@ -864,7 +864,7 @@ class Example_Nested extends jni.JObject { } } -class $Example_NestedType extends jni.JObjType { +final class $Example_NestedType extends jni.JObjType { const $Example_NestedType(); @override @@ -928,7 +928,7 @@ class Example_Nested_NestedTwice extends jni.JObject { } } -class $Example_Nested_NestedTwiceType +final class $Example_Nested_NestedTwiceType extends jni.JObjType { const $Example_Nested_NestedTwiceType(); @@ -1004,7 +1004,7 @@ class Example_NonStaticNested extends jni.JObject { } } -class $Example_NonStaticNestedType +final class $Example_NonStaticNestedType extends jni.JObjType { const $Example_NonStaticNestedType(); @@ -1249,7 +1249,7 @@ class Exceptions extends jni.JObject { } } -class $ExceptionsType extends jni.JObjType { +final class $ExceptionsType extends jni.JObjType { const $ExceptionsType(); @override @@ -1504,7 +1504,7 @@ class Fields extends jni.JObject { } } -class $FieldsType extends jni.JObjType { +final class $FieldsType extends jni.JObjType { const $FieldsType(); @override @@ -1594,7 +1594,7 @@ class Fields_Nested extends jni.JObject { } } -class $Fields_NestedType extends jni.JObjType { +final class $Fields_NestedType extends jni.JObjType { const $Fields_NestedType(); @override @@ -1658,7 +1658,7 @@ class C2 extends jni.JObject { } } -class $C2Type extends jni.JObjType { +final class $C2Type extends jni.JObjType { const $C2Type(); @override @@ -1715,7 +1715,7 @@ class Example1 extends jni.JObject { } } -class $Example1Type extends jni.JObjType { +final class $Example1Type extends jni.JObjType { const $Example1Type(); @override @@ -1780,8 +1780,8 @@ class GenericTypeParams<$S extends jni.JObject, $K extends jni.JObject> } } -class $GenericTypeParamsType<$S extends jni.JObject, $K extends jni.JObject> - extends jni.JObjType> { +final class $GenericTypeParamsType<$S extends jni.JObject, + $K extends jni.JObject> extends jni.JObjType> { final jni.JObjType<$S> S; final jni.JObjType<$K> K; @@ -1959,7 +1959,7 @@ class GrandParent<$T extends jni.JObject> extends jni.JObject { } } -class $GrandParentType<$T extends jni.JObject> +final class $GrandParentType<$T extends jni.JObject> extends jni.JObjType> { final jni.JObjType<$T> T; @@ -2096,8 +2096,8 @@ class GrandParent_Parent<$T extends jni.JObject, $S extends jni.JObject> } } -class $GrandParent_ParentType<$T extends jni.JObject, $S extends jni.JObject> - extends jni.JObjType> { +final class $GrandParent_ParentType<$T extends jni.JObject, + $S extends jni.JObject> extends jni.JObjType> { final jni.JObjType<$T> T; final jni.JObjType<$S> S; @@ -2275,7 +2275,7 @@ class GrandParent_Parent_Child<$T extends jni.JObject, $S extends jni.JObject, } } -class $GrandParent_Parent_ChildType<$T extends jni.JObject, +final class $GrandParent_Parent_ChildType<$T extends jni.JObject, $S extends jni.JObject, $U extends jni.JObject> extends jni.JObjType> { final jni.JObjType<$T> T; @@ -2381,7 +2381,7 @@ class GrandParent_StaticParent<$S extends jni.JObject> extends jni.JObject { } } -class $GrandParent_StaticParentType<$S extends jni.JObject> +final class $GrandParent_StaticParentType<$S extends jni.JObject> extends jni.JObjType> { final jni.JObjType<$S> S; @@ -2528,7 +2528,7 @@ class GrandParent_StaticParent_Child<$S extends jni.JObject, } } -class $GrandParent_StaticParent_ChildType<$S extends jni.JObject, +final class $GrandParent_StaticParent_ChildType<$S extends jni.JObject, $U extends jni.JObject> extends jni.JObjType> { final jni.JObjType<$S> S; @@ -2653,7 +2653,7 @@ class MyMap<$K extends jni.JObject, $V extends jni.JObject> } } -class $MyMapType<$K extends jni.JObject, $V extends jni.JObject> +final class $MyMapType<$K extends jni.JObject, $V extends jni.JObject> extends jni.JObjType> { final jni.JObjType<$K> K; final jni.JObjType<$V> V; @@ -2796,7 +2796,7 @@ class MyMap_MyEntry<$K extends jni.JObject, $V extends jni.JObject> } } -class $MyMap_MyEntryType<$K extends jni.JObject, $V extends jni.JObject> +final class $MyMap_MyEntryType<$K extends jni.JObject, $V extends jni.JObject> extends jni.JObjType> { final jni.JObjType<$K> K; final jni.JObjType<$V> V; @@ -2996,7 +2996,8 @@ class MyStack<$T extends jni.JObject> extends jni.JObject { } } -class $MyStackType<$T extends jni.JObject> extends jni.JObjType> { +final class $MyStackType<$T extends jni.JObject> + extends jni.JObjType> { final jni.JObjType<$T> T; const $MyStackType( @@ -3060,7 +3061,7 @@ class StringKeyedMap<$V extends jni.JObject> extends MyMap { } } -class $StringKeyedMapType<$V extends jni.JObject> +final class $StringKeyedMapType<$V extends jni.JObject> extends jni.JObjType> { final jni.JObjType<$V> V; @@ -3115,7 +3116,7 @@ class StringMap extends StringKeyedMap { } } -class $StringMapType extends jni.JObjType { +final class $StringMapType extends jni.JObjType { const $StringMapType(); @override @@ -3161,7 +3162,7 @@ class StringStack extends MyStack { } } -class $StringStackType extends jni.JObjType { +final class $StringStackType extends jni.JObjType { const $StringStackType(); @override @@ -3219,7 +3220,7 @@ class StringValuedMap<$K extends jni.JObject> extends MyMap<$K, jni.JString> { } } -class $StringValuedMapType<$K extends jni.JObject> +final class $StringValuedMapType<$K extends jni.JObject> extends jni.JObjType> { final jni.JObjType<$K> K; @@ -3500,7 +3501,7 @@ class _$MyInterfaceImpl<$T extends jni.JObject> } } -class $MyInterfaceType<$T extends jni.JObject> +final class $MyInterfaceType<$T extends jni.JObject> extends jni.JObjType> { final jni.JObjType<$T> T; @@ -3624,7 +3625,7 @@ class MyInterfaceConsumer extends jni.JObject { } } -class $MyInterfaceConsumerType extends jni.JObjType { +final class $MyInterfaceConsumerType extends jni.JObjType { const $MyInterfaceConsumerType(); @override @@ -3762,7 +3763,7 @@ class _$MyRunnableImpl implements $MyRunnableImpl { } } -class $MyRunnableType extends jni.JObjType { +final class $MyRunnableType extends jni.JObjType { const $MyRunnableType(); @override @@ -3862,7 +3863,7 @@ class MyRunnableRunner extends jni.JObject { } } -class $MyRunnableRunnerType extends jni.JObjType { +final class $MyRunnableRunnerType extends jni.JObjType { const $MyRunnableRunnerType(); @override @@ -3927,7 +3928,8 @@ class JsonSerializable_Case extends jni.JObject { } } -class $JsonSerializable_CaseType extends jni.JObjType { +final class $JsonSerializable_CaseType + extends jni.JObjType { const $JsonSerializable_CaseType(); @override @@ -3976,7 +3978,7 @@ class MyDataClass extends jni.JObject { } } -class $MyDataClassType extends jni.JObjType { +final class $MyDataClassType extends jni.JObjType { const $MyDataClassType(); @override diff --git a/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart index b549cc89a..7ac848d05 100644 --- a/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart @@ -68,7 +68,7 @@ class Color extends jni.JObject { } } -class $ColorType extends jni.JObjType { +final class $ColorType extends jni.JObjType { const $ColorType(); @override @@ -718,7 +718,7 @@ class Example extends jni.JObject { } } -class $ExampleType extends jni.JObjType { +final class $ExampleType extends jni.JObjType { const $ExampleType(); @override @@ -799,7 +799,7 @@ class Example_Nested extends jni.JObject { } } -class $Example_NestedType extends jni.JObjType { +final class $Example_NestedType extends jni.JObjType { const $Example_NestedType(); @override @@ -865,7 +865,7 @@ class Example_Nested_NestedTwice extends jni.JObject { } } -class $Example_Nested_NestedTwiceType +final class $Example_Nested_NestedTwiceType extends jni.JObjType { const $Example_Nested_NestedTwiceType(); @@ -935,7 +935,7 @@ class Example_NonStaticNested extends jni.JObject { } } -class $Example_NonStaticNestedType +final class $Example_NonStaticNestedType extends jni.JObjType { const $Example_NonStaticNestedType(); @@ -1172,7 +1172,7 @@ class Exceptions extends jni.JObject { } } -class $ExceptionsType extends jni.JObjType { +final class $ExceptionsType extends jni.JObjType { const $ExceptionsType(); @override @@ -1383,7 +1383,7 @@ class Fields extends jni.JObject { } } -class $FieldsType extends jni.JObjType { +final class $FieldsType extends jni.JObjType { const $FieldsType(); @override @@ -1467,7 +1467,7 @@ class Fields_Nested extends jni.JObject { } } -class $Fields_NestedType extends jni.JObjType { +final class $Fields_NestedType extends jni.JObjType { const $Fields_NestedType(); @override @@ -1533,7 +1533,7 @@ class C2 extends jni.JObject { } } -class $C2Type extends jni.JObjType { +final class $C2Type extends jni.JObjType { const $C2Type(); @override @@ -1591,7 +1591,7 @@ class Example1 extends jni.JObject { } } -class $Example1Type extends jni.JObjType { +final class $Example1Type extends jni.JObjType { const $Example1Type(); @override @@ -1662,8 +1662,8 @@ class GenericTypeParams<$S extends jni.JObject, $K extends jni.JObject> } } -class $GenericTypeParamsType<$S extends jni.JObject, $K extends jni.JObject> - extends jni.JObjType> { +final class $GenericTypeParamsType<$S extends jni.JObject, + $K extends jni.JObject> extends jni.JObjType> { final jni.JObjType<$S> S; final jni.JObjType<$K> K; @@ -1835,7 +1835,7 @@ class GrandParent<$T extends jni.JObject> extends jni.JObject { } } -class $GrandParentType<$T extends jni.JObject> +final class $GrandParentType<$T extends jni.JObject> extends jni.JObjType> { final jni.JObjType<$T> T; @@ -1957,8 +1957,8 @@ class GrandParent_Parent<$T extends jni.JObject, $S extends jni.JObject> } } -class $GrandParent_ParentType<$T extends jni.JObject, $S extends jni.JObject> - extends jni.JObjType> { +final class $GrandParent_ParentType<$T extends jni.JObject, + $S extends jni.JObject> extends jni.JObjType> { final jni.JObjType<$T> T; final jni.JObjType<$S> S; @@ -2111,7 +2111,7 @@ class GrandParent_Parent_Child<$T extends jni.JObject, $S extends jni.JObject, } } -class $GrandParent_Parent_ChildType<$T extends jni.JObject, +final class $GrandParent_Parent_ChildType<$T extends jni.JObject, $S extends jni.JObject, $U extends jni.JObject> extends jni.JObjType> { final jni.JObjType<$T> T; @@ -2211,7 +2211,7 @@ class GrandParent_StaticParent<$S extends jni.JObject> extends jni.JObject { } } -class $GrandParent_StaticParentType<$S extends jni.JObject> +final class $GrandParent_StaticParentType<$S extends jni.JObject> extends jni.JObjType> { final jni.JObjType<$S> S; @@ -2341,7 +2341,7 @@ class GrandParent_StaticParent_Child<$S extends jni.JObject, } } -class $GrandParent_StaticParent_ChildType<$S extends jni.JObject, +final class $GrandParent_StaticParent_ChildType<$S extends jni.JObject, $U extends jni.JObject> extends jni.JObjType> { final jni.JObjType<$S> S; @@ -2464,7 +2464,7 @@ class MyMap<$K extends jni.JObject, $V extends jni.JObject> } } -class $MyMapType<$K extends jni.JObject, $V extends jni.JObject> +final class $MyMapType<$K extends jni.JObject, $V extends jni.JObject> extends jni.JObjType> { final jni.JObjType<$K> K; final jni.JObjType<$V> V; @@ -2592,7 +2592,7 @@ class MyMap_MyEntry<$K extends jni.JObject, $V extends jni.JObject> } } -class $MyMap_MyEntryType<$K extends jni.JObject, $V extends jni.JObject> +final class $MyMap_MyEntryType<$K extends jni.JObject, $V extends jni.JObject> extends jni.JObjType> { final jni.JObjType<$K> K; final jni.JObjType<$V> V; @@ -2797,7 +2797,8 @@ class MyStack<$T extends jni.JObject> extends jni.JObject { } } -class $MyStackType<$T extends jni.JObject> extends jni.JObjType> { +final class $MyStackType<$T extends jni.JObject> + extends jni.JObjType> { final jni.JObjType<$T> T; const $MyStackType( @@ -2866,7 +2867,7 @@ class StringKeyedMap<$V extends jni.JObject> extends MyMap { } } -class $StringKeyedMapType<$V extends jni.JObject> +final class $StringKeyedMapType<$V extends jni.JObject> extends jni.JObjType> { final jni.JObjType<$V> V; @@ -2924,7 +2925,7 @@ class StringMap extends StringKeyedMap { } } -class $StringMapType extends jni.JObjType { +final class $StringMapType extends jni.JObjType { const $StringMapType(); @override @@ -2973,7 +2974,7 @@ class StringStack extends MyStack { } } -class $StringStackType extends jni.JObjType { +final class $StringStackType extends jni.JObjType { const $StringStackType(); @override @@ -3036,7 +3037,7 @@ class StringValuedMap<$K extends jni.JObject> extends MyMap<$K, jni.JString> { } } -class $StringValuedMapType<$K extends jni.JObject> +final class $StringValuedMapType<$K extends jni.JObject> extends jni.JObjType> { final jni.JObjType<$K> K; @@ -3309,7 +3310,7 @@ class _$MyInterfaceImpl<$T extends jni.JObject> } } -class $MyInterfaceType<$T extends jni.JObject> +final class $MyInterfaceType<$T extends jni.JObject> extends jni.JObjType> { final jni.JObjType<$T> T; @@ -3430,7 +3431,7 @@ class MyInterfaceConsumer extends jni.JObject { } } -class $MyInterfaceConsumerType extends jni.JObjType { +final class $MyInterfaceConsumerType extends jni.JObjType { const $MyInterfaceConsumerType(); @override @@ -3569,7 +3570,7 @@ class _$MyRunnableImpl implements $MyRunnableImpl { } } -class $MyRunnableType extends jni.JObjType { +final class $MyRunnableType extends jni.JObjType { const $MyRunnableType(); @override @@ -3656,7 +3657,7 @@ class MyRunnableRunner extends jni.JObject { } } -class $MyRunnableRunnerType extends jni.JObjType { +final class $MyRunnableRunnerType extends jni.JObjType { const $MyRunnableRunnerType(); @override @@ -3725,7 +3726,8 @@ class JsonSerializable_Case extends jni.JObject { } } -class $JsonSerializable_CaseType extends jni.JObjType { +final class $JsonSerializable_CaseType + extends jni.JObjType { const $JsonSerializable_CaseType(); @override @@ -3777,7 +3779,7 @@ class MyDataClass extends jni.JObject { } } -class $MyDataClassType extends jni.JObjType { +final class $MyDataClassType extends jni.JObjType { const $MyDataClassType(); @override From 9fafeacbb9c3ae8072267235be9bc72ccc16d322 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Tue, 19 Sep 2023 15:59:22 +0200 Subject: [PATCH 128/139] [jnigen] Convert incorrect exceptions into errors (https://github.com/dart-lang/jnigen/issues/397) Closes https://github.com/dart-lang/jnigen/issues/394. --- pkgs/jni/CHANGELOG.md | 17 ++++ pkgs/jni/lib/jni.dart | 8 +- pkgs/jni/lib/src/accessors.dart | 2 +- pkgs/jni/lib/src/errors.dart | 144 +++++++++++++++++++++++++++ pkgs/jni/lib/src/jexceptions.dart | 123 ----------------------- pkgs/jni/lib/src/jni.dart | 20 ++-- pkgs/jni/lib/src/jobject.dart | 8 +- pkgs/jni/lib/src/jreference.dart | 24 ++--- pkgs/jni/pubspec.yaml | 2 +- pkgs/jni/test/exception_test.dart | 20 ++-- pkgs/jni/test/jbyte_buffer_test.dart | 2 +- pkgs/jni/test/jobject_test.dart | 50 ++++++++-- 12 files changed, 244 insertions(+), 176 deletions(-) create mode 100644 pkgs/jni/lib/src/errors.dart delete mode 100644 pkgs/jni/lib/src/jexceptions.dart diff --git a/pkgs/jni/CHANGELOG.md b/pkgs/jni/CHANGELOG.md index 64ddb4d71..15e7e9ec3 100644 --- a/pkgs/jni/CHANGELOG.md +++ b/pkgs/jni/CHANGELOG.md @@ -1,3 +1,20 @@ +## 0.8.0-wip + +- **Breaking Change** ([#394](https://github.com/dart-lang/jnigen/issues/394)): + Converted various `Exception`s into `Error`s: + - `UseAfterReleaseException` -> `UseAfterReleaseError` + - `DoubleReleaseException` -> `DoubleReleaseError` + - `SpawnException` -> `JniError` (It's now a `sealed class`) + - `JNullException` -> `JNullError` + - `InvalidCallTypeException` -> `InvalidCallTypeError` + - `HelperNotFoundException` -> `HelperNotFoundError` + - `JvmExistsException` -> `JniVmExistsError` + - `NoJvmInstanceException` -> `NoJvmInstanceError` +- **Breaking Change**: Removed `InvalidJStringException`. +- **Breaking Change**: The default return `callType` of type parameter `int` for + methods such as `JObject.callMethodByName` is now Java's `long` instead + of `int` to be consistent with the way arguments work. + ## 0.7.0 - **Breaking Change** ([#387](https://github.com/dart-lang/jnigen/issues/387)): diff --git a/pkgs/jni/lib/jni.dart b/pkgs/jni/lib/jni.dart index 85f99fa32..ce372fffd 100644 --- a/pkgs/jni/lib/jni.dart +++ b/pkgs/jni/lib/jni.dart @@ -60,19 +60,21 @@ /// This library provides classes and functions for JNI interop from Dart. library jni; -export 'src/third_party/generated_bindings.dart' - hide JniBindings, JniEnv, JniEnv1, JniExceptionDetails; +export 'src/errors.dart'; export 'src/jni.dart' hide ProtectedJniExtensions; export 'src/jvalues.dart' hide JValueArgs, toJValues; export 'src/types.dart'; export 'src/jarray.dart'; -export 'src/jexceptions.dart'; export 'src/jobject.dart'; export 'src/jprimitives.dart'; export 'src/jreference.dart' show JReferenceUseExtension; + export 'src/lang/lang.dart'; export 'src/nio/nio.dart'; export 'src/util/util.dart'; +export 'src/third_party/generated_bindings.dart' + hide JniBindings, JniEnv, JniEnv1, JniExceptionDetails; + export 'package:ffi/ffi.dart' show using, Arena; export 'dart:ffi' show nullptr; diff --git a/pkgs/jni/lib/src/accessors.dart b/pkgs/jni/lib/src/accessors.dart index b5e843c2a..e505b9470 100644 --- a/pkgs/jni/lib/src/accessors.dart +++ b/pkgs/jni/lib/src/accessors.dart @@ -7,7 +7,7 @@ import 'package:ffi/ffi.dart' show using; import 'package:jni/src/jvalues.dart'; -import 'jexceptions.dart'; +import 'errors.dart'; import 'third_party/generated_bindings.dart'; import 'jni.dart'; diff --git a/pkgs/jni/lib/src/errors.dart b/pkgs/jni/lib/src/errors.dart new file mode 100644 index 000000000..848d93eaa --- /dev/null +++ b/pkgs/jni/lib/src/errors.dart @@ -0,0 +1,144 @@ +// 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/src/third_party/generated_bindings.dart'; + +// TODO(#393): Add the fact that [JException] is now a [JObject] to the +// CHANGELOG. + +final class UseAfterReleaseError extends Error { + @override + String toString() { + return 'Use after release error'; + } +} + +// TODO(#393): Use NullPointerError once it's available. +final class JNullError extends Error { + @override + String toString() => 'The reference was null'; +} + +final class DoubleReleaseError extends Error { + @override + String toString() { + return 'Double release error'; + } +} + +/// Represents JNI errors that might be returned by methods like +/// `JNI_CreateJavaVM`. +sealed class JniError extends Error { + static const _errors = { + JniErrorCode.JNI_ERR: JniGenericError.new, + JniErrorCode.JNI_EDETACHED: JniThreadDetachedError.new, + JniErrorCode.JNI_EVERSION: JniVersionError.new, + JniErrorCode.JNI_ENOMEM: JniOutOfMemoryError.new, + JniErrorCode.JNI_EEXIST: JniVmExistsError.new, + JniErrorCode.JNI_EINVAL: JniArgumentError.new, + }; + + final String message; + + JniError(this.message); + + factory JniError.of(int status) { + if (!_errors.containsKey(status)) { + status = JniErrorCode.JNI_ERR; + } + return _errors[status]!(); + } + + @override + String toString() { + return 'JniError: $message'; + } +} + +final class JniGenericError extends JniError { + JniGenericError() : super('Generic JNI error'); +} + +final class JniThreadDetachedError extends JniError { + JniThreadDetachedError() : super('Thread detached from VM'); +} + +final class JniVersionError extends JniError { + JniVersionError() : super('JNI version error'); +} + +final class JniOutOfMemoryError extends JniError { + JniOutOfMemoryError() : super('Out of memory'); +} + +final class JniVmExistsError extends JniError { + JniVmExistsError() : super('VM Already created'); +} + +final class JniArgumentError extends JniError { + JniArgumentError() : super('Invalid arguments'); +} + +final class NoJvmInstanceError extends Error { + @override + String toString() => 'No JNI instance is available'; +} + +// TODO(#395): Remove this when calltypes are removed. +extension on int { + static const _names = { + JniCallType.booleanType: 'bool', + JniCallType.byteType: 'byte', + JniCallType.shortType: 'short', + JniCallType.charType: 'char', + JniCallType.intType: 'int', + JniCallType.longType: 'long', + JniCallType.floatType: 'float', + JniCallType.doubleType: 'double', + JniCallType.objectType: 'object', + JniCallType.voidType: 'void', + }; + String str() => _names[this]!; +} + +// TODO(#395): Remove this when `JniCallType`s are removed. +final class InvalidCallTypeError extends Error { + final int type; + final Set allowed; + + InvalidCallTypeError(this.type, this.allowed); + + @override + String toString() => 'Invalid type for call ${type.str()}. ' + 'Allowed types are ${allowed.map((t) => t.str()).toSet()}'; +} + +// TODO(#393): 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; + + HelperNotFoundError(this.path); + + @override + String toString() => ''' +Lookup for helper library $path failed. +Please ensure that `dartjni` shared library is built. +Provided jni:setup script can be used to build the shared library. +If the library is already built, ensure that the JVM libraries can be +loaded from Dart.'''; +} diff --git a/pkgs/jni/lib/src/jexceptions.dart b/pkgs/jni/lib/src/jexceptions.dart deleted file mode 100644 index 5a0d59e93..000000000 --- a/pkgs/jni/lib/src/jexceptions.dart +++ /dev/null @@ -1,123 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -import 'dart:ffi'; - -import 'package:jni/src/third_party/generated_bindings.dart'; - -abstract class JException implements Exception {} - -class UseAfterReleaseException implements JException { - final Pointer ptr; - UseAfterReleaseException(this.ptr); - - @override - String toString() { - return 'Use after release on $ptr.'; - } -} - -class JNullException implements JException { - const JNullException(); - - @override - String toString() => 'The reference was null.'; -} - -class InvalidJStringException implements JException { - final Pointer reference; - InvalidJStringException(this.reference); - - @override - String toString() => 'Not a valid Java String: ' - '0x${reference.address.toRadixString(16)}.'; -} - -class DoubleReleaseException implements JException { - final Pointer ptr; - DoubleReleaseException(this.ptr); - - @override - String toString() { - return 'Double release on $ptr.'; - } -} - -class JvmExistsException implements JException { - @override - String toString() => 'A JVM is already spawned'; -} - -/// Represents spawn errors that might be returned by JNI_CreateJavaVM -class SpawnException implements JException { - static const _errors = { - JniErrorCode.JNI_ERR: 'Generic JNI error', - JniErrorCode.JNI_EDETACHED: 'Thread detached from VM', - JniErrorCode.JNI_EVERSION: 'JNI version error', - JniErrorCode.JNI_ENOMEM: 'Out of memory', - JniErrorCode.JNI_EEXIST: 'VM Already created', - JniErrorCode.JNI_EINVAL: 'Invalid arguments', - }; - int status; - SpawnException.of(this.status); - - @override - String toString() => _errors[status] ?? 'Unknown status code: $status'; -} - -class NoJvmInstanceException implements JException { - @override - String toString() => 'No JNI instance is available'; -} - -extension JniTypeNames on int { - static const _names = { - JniCallType.booleanType: 'bool', - JniCallType.byteType: 'byte', - JniCallType.shortType: 'short', - JniCallType.charType: 'char', - JniCallType.intType: 'int', - JniCallType.longType: 'long', - JniCallType.floatType: 'float', - JniCallType.doubleType: 'double', - JniCallType.objectType: 'object', - JniCallType.voidType: 'void', - }; - String str() => _names[this]!; -} - -class InvalidCallTypeException implements JException { - int type; - Set allowed; - InvalidCallTypeException(this.type, this.allowed); - @override - String toString() => 'Invalid type for call ${type.str()}. ' - 'Allowed types are ${allowed.map((t) => t.str()).toSet()}'; -} - -class JniException implements JException { - /// 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'; -} - -class HelperNotFoundException implements JException { - HelperNotFoundException(this.path); - final String path; - - @override - String toString() => ''' -Lookup for helper library $path failed. -Please ensure that `dartjni` shared library is built. -Provided jni:setup script can be used to build the shared library. -If the library is already built, ensure that the JVM libraries can be -loaded from Dart.'''; -} diff --git a/pkgs/jni/lib/src/jni.dart b/pkgs/jni/lib/src/jni.dart index 1e25151ff..0bc154b9c 100644 --- a/pkgs/jni/lib/src/jni.dart +++ b/pkgs/jni/lib/src/jni.dart @@ -9,7 +9,7 @@ import 'dart:isolate'; import 'package:ffi/ffi.dart'; import 'package:path/path.dart'; -import 'jexceptions.dart'; +import 'errors.dart'; import 'jobject.dart'; import 'third_party/generated_bindings.dart'; import 'jvalues.dart'; @@ -38,7 +38,7 @@ DynamicLibrary _loadDartJniLibrary({String? dir, String baseName = "dartjni"}) { final dylib = DynamicLibrary.open(libPath); return dylib; } on Error { - throw HelperNotFoundException(libPath); + throw HelperNotFoundError(libPath); } } @@ -97,12 +97,12 @@ abstract class Jni { jniVersion: jniVersion, ); if (status == false) { - throw JvmExistsException(); + throw JniVmExistsError(); } } /// Same as [spawn] but if a JVM exists, returns silently instead of - /// throwing [JvmExistsException]. + /// throwing [JvmExistsError]. /// /// If the options are different than that of existing VM, the existing VM's /// options will remain in effect. @@ -129,7 +129,7 @@ abstract class Jni { } else if (status == DART_JNI_SINGLETON_EXISTS) { return false; } else { - throw SpawnException.of(status); + throw JniError.of(status); } }); @@ -176,12 +176,12 @@ abstract class Jni { return _bindings.GetJavaVM(); } - /// Returns the instance of [GlobalJniEnvStruct], which is an abstraction over JNIEnv - /// without the same-thread restriction. + /// Returns the instance of [GlobalJniEnvStruct], which is an abstraction over + /// JNIEnv without the same-thread restriction. static Pointer _fetchGlobalEnv() { final env = _bindings.GetGlobalEnv(); if (env == nullptr) { - throw NoJvmInstanceException(); + throw NoJvmInstanceError(); } return env; } @@ -336,11 +336,11 @@ extension AdditionalEnvMethods on GlobalJniEnv { /// DeleteGlobalRef. String toDartString(JStringPtr jstringPtr, {bool releaseOriginal = false}) { if (jstringPtr == nullptr) { - throw const JNullException(); + throw JNullError(); } final chars = GetStringChars(jstringPtr, nullptr); if (chars == nullptr) { - throw InvalidJStringException(jstringPtr); + throw ArgumentError('Not a valid jstring pointer.'); } final result = chars.cast().toDartString(); ReleaseStringChars(jstringPtr, chars); diff --git a/pkgs/jni/lib/src/jobject.dart b/pkgs/jni/lib/src/jobject.dart index a7e659ce9..15c69727e 100644 --- a/pkgs/jni/lib/src/jobject.dart +++ b/pkgs/jni/lib/src/jobject.dart @@ -7,7 +7,7 @@ import 'dart:ffi'; import 'package:ffi/ffi.dart'; import 'package:jni/src/accessors.dart'; -import 'jexceptions.dart'; +import 'errors.dart'; import 'jni.dart'; import 'jreference.dart'; import 'lang/jstring.dart'; @@ -65,7 +65,7 @@ Pointer _getID( int _getCallType(int? callType, int defaultType, Set allowed) { if (callType == null) return defaultType; if (allowed.contains(callType)) return callType; - throw InvalidCallTypeException(callType, allowed); + throw InvalidCallTypeError(callType, allowed); } T _callOrGet(int? callType, JniResult Function(int) function) { @@ -78,7 +78,7 @@ T _callOrGet(int? callType, JniResult Function(int) function) { result = function(finalCallType).boolean as T; break; case int: - finalCallType = _getCallType(callType, JniCallType.intType, { + finalCallType = _getCallType(callType, JniCallType.longType, { JniCallType.byteType, JniCallType.charType, JniCallType.shortType, @@ -177,8 +177,6 @@ class JObject extends JReference { return _jClass ??= getClass(); } - /// Deletes the JNI reference and marks this object as released. Any further - /// uses will throw [UseAfterReleaseException]. @override void release() { _jClass?.release(); diff --git a/pkgs/jni/lib/src/jreference.dart b/pkgs/jni/lib/src/jreference.dart index 68c0adaf4..8d8b71dcd 100644 --- a/pkgs/jni/lib/src/jreference.dart +++ b/pkgs/jni/lib/src/jreference.dart @@ -7,13 +7,13 @@ import 'dart:ffi'; import 'package:ffi/ffi.dart'; import 'package:jni/src/third_party/generated_bindings.dart'; -import 'jexceptions.dart'; +import 'errors.dart'; import 'jni.dart'; extension ProtectedJReference on JReference { void setAsReleased() { if (_released) { - throw DoubleReleaseException(_reference); + throw DoubleReleaseError(); } _released = true; JReference._finalizer.detach(this); @@ -21,7 +21,7 @@ extension ProtectedJReference on JReference { void ensureNotNull() { if (isNull) { - throw const JNullException(); + throw JNullError(); } } @@ -47,15 +47,17 @@ abstract class JReference implements Finalizable { bool _released = false; - /// Check whether the underlying JNI reference is `null`. + /// Whether the underlying JNI reference is `null` or not. bool get isNull => reference == nullptr; - /// Returns `true` if the underlying JNI reference is deleted. + /// Whether the underlying JNI reference is deleted or not. bool get isReleased => _released; - /// Deletes the underlying JNI reference. + /// Deletes the underlying JNI reference and marks this as released. /// - /// Further uses will throw [UseAfterReleaseException]. + /// Throws [DoubleReleaseError] if this is already released. + /// + /// Further uses of this object will throw [UseAfterReleaseError]. void release() { setAsReleased(); Jni.env.DeleteGlobalRef(_reference); @@ -63,12 +65,12 @@ abstract class JReference implements Finalizable { /// The underlying JNI global object reference. /// - /// Throws [UseAfterReleaseException] if the object is previously released. + /// Throws [UseAfterReleaseError] if the object is previously released. /// /// Be careful when storing this in a variable since it might have gotten /// released upon use. JObjectPtr get reference { - if (_released) throw UseAfterReleaseException(_reference); + if (_released) throw UseAfterReleaseError(); return _reference; } @@ -84,11 +86,9 @@ extension JReferenceUseExtension on T { R use(R Function(T) callback) { try { final result = callback(this); - release(); return result; - } catch (e) { + } finally { release(); - rethrow; } } } diff --git a/pkgs/jni/pubspec.yaml b/pkgs/jni/pubspec.yaml index 46bedce2f..1d99a4016 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.7.0 +version: 0.8.0-wip repository: https://github.com/dart-lang/jnigen/tree/main/jni topics: diff --git a/pkgs/jni/test/exception_test.dart b/pkgs/jni/test/exception_test.dart index d3c806dc8..42d229764 100644 --- a/pkgs/jni/test/exception_test.dart +++ b/pkgs/jni/test/exception_test.dart @@ -14,17 +14,17 @@ void main() { checkDylibIsUpToDate(); bool caught = false; try { - // If library does not exist, a helpful exception should be thrown. - // we can't test this directly because - // `test` schedules functions asynchronously + // If library does not exist, a helpful error should be thrown. + // we can't test this directly because `test` schedules functions + // asynchronously. Jni.spawn(dylibDir: "wrong_dir"); - } on HelperNotFoundException catch (_) { + } on HelperNotFoundError catch (_) { // stderr.write("\n$_\n"); Jni.spawnIfNotExists( dylibDir: "build/jni_libs", jvmOptions: ["-Xmx128m"]); caught = true; - } on JvmExistsException { - stderr.writeln('cannot verify: HelperNotFoundException thrown'); + } on JniVmExistsError { + stderr.writeln('cannot verify: HelperNotFoundError thrown'); } if (!caught) { throw "Expected HelperNotFoundException\n" @@ -38,14 +38,14 @@ void run({required TestRunnerCallback testRunner}) { testRunner("double free throws exception", () { final r = Jni.newInstance("java/util/Random", "()V", []); r.release(); - expect(r.release, throwsA(isA())); + expect(r.release, throwsA(isA())); }); testRunner("Use after free throws exception", () { final r = Jni.newInstance("java/util/Random", "()V", []); r.release(); expect(() => r.callMethodByName("nextInt", "(I)I", [JValueInt(256)]), - throwsA(isA())); + throwsA(isA())); }); testRunner("void fieldType throws exception", () { @@ -56,12 +56,12 @@ void run({required TestRunnerCallback testRunner}) { throwsArgumentError); }); - testRunner("Wrong callType throws exception", () { + testRunner("Wrong callType throws error", () { final r = Jni.newInstance("java/util/Random", "()V", []); expect( () => r.callMethodByName( "nextInt", "(I)I", [JValueInt(256)], JniCallType.doubleType), - throwsA(isA())); + throwsA(isA())); }); testRunner("An exception in JNI throws JniException in Dart", () { diff --git a/pkgs/jni/test/jbyte_buffer_test.dart b/pkgs/jni/test/jbyte_buffer_test.dart index f68c47b0d..48f9eaf45 100644 --- a/pkgs/jni/test/jbyte_buffer_test.dart +++ b/pkgs/jni/test/jbyte_buffer_test.dart @@ -221,7 +221,7 @@ void run({required TestRunnerCallback testRunner}) { final data2 = directBuffer.asUint8List(releaseOriginal: true); expect( () => directBuffer.nextByte = 42, - throwsA(isA()), + throwsA(isA()), ); expect(data2[0], 42); }); diff --git a/pkgs/jni/test/jobject_test.dart b/pkgs/jni/test/jobject_test.dart index 883913cdd..a63828cfb 100644 --- a/pkgs/jni/test/jobject_test.dart +++ b/pkgs/jni/test/jobject_test.dart @@ -45,7 +45,12 @@ void run({required TestRunnerCallback testRunner}) { // to JNI strings. final long = longClass.newInstance(longCtor, [176]); - final intValue = long.callMethodByName("intValue", "()I", []); + final intValue = long.callMethodByName( + "intValue", + "()I", + [], + JniCallType.intType, + ); expect(intValue, equals(176)); // Release any JObject and JClass instances using `.release()` after use. @@ -103,9 +108,17 @@ void run({required TestRunnerCallback testRunner}) { final nextIntMethod = random.getMethodID("nextInt", "(I)I"); for (int i = 0; i < 100; i++) { - int r = random.callMethod(nextIntMethod, [JValueInt(256 * 256)]); + int r = random.callMethod( + nextIntMethod, + [JValueInt(256 * 256)], + JniCallType.intType, + ); int bits = 0; - final jbc = longClass.callStaticMethod(bitCountMethod, [r]); + final jbc = longClass.callStaticMethod( + bitCountMethod, + [r], + JniCallType.intType, + ); while (r != 0) { bits += r % 2; r = (r / 2).floor(); @@ -118,8 +131,13 @@ void run({required TestRunnerCallback testRunner}) { // One-off invocation of static method in single call. testRunner("invoke_", () { - final m = Jni.invokeStaticMethod("java/lang/Short", "compare", "(SS)I", - [JValueShort(1234), JValueShort(1324)]); + final m = Jni.invokeStaticMethod( + "java/lang/Short", + "compare", + "(SS)I", + [JValueShort(1234), JValueShort(1324)], + JniCallType.intType, + ); expect(m, equals(1234 - 1324)); }); @@ -172,8 +190,13 @@ void run({required TestRunnerCallback testRunner}) { // You can use() method on JObject for using once and deleting. testRunner("use() method", () { final randomInt = Jni.newInstance("java/util/Random", "()V", []).use( - (random) => - random.callMethodByName("nextInt", "(I)I", [JValueInt(15)])); + (random) => random.callMethodByName( + "nextInt", + "(I)I", + [JValueInt(15)], + JniCallType.intType, + ), + ); expect(randomInt, lessThan(15)); }); @@ -197,7 +220,14 @@ void run({required TestRunnerCallback testRunner}) { // Don't forget to escape $ in nested type names final ordinal = Jni.retrieveStaticField( "java/net/Proxy\$Type", "HTTP", "Ljava/net/Proxy\$Type;") - .use((f) => f.callMethodByName("ordinal", "()I", [])); + .use( + (f) => f.callMethodByName( + "ordinal", + "()I", + [], + JniCallType.intType, + ), + ); expect(ordinal, equals(1)); }); @@ -209,8 +239,8 @@ void run({required TestRunnerCallback testRunner}) { expect(backToStr.toDartString(), str.toDartString()); final _ = backToStr.castTo(JObject.type, releaseOriginal: true) ..releasedBy(arena); - expect(backToStr.toDartString, throwsA(isA())); - expect(backToStr.release, throwsA(isA())); + expect(backToStr.toDartString, throwsA(isA())); + expect(backToStr.release, throwsA(isA())); }); }); From 266ab71cfd5454e03a406270f7453852b3efd665 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Wed, 20 Sep 2023 13:18:25 +0200 Subject: [PATCH 129/139] [jnigen] Use Dart 3 class modifiers in `package:jni` (https://github.com/dart-lang/jnigen/issues/398) --- pkgs/jni/CHANGELOG.md | 4 +++ pkgs/jni/lib/jni.dart | 1 - pkgs/jni/lib/src/jarray.dart | 6 ++-- pkgs/jni/lib/src/jni.dart | 2 +- pkgs/jni/lib/src/jprimitives.dart | 36 +++++++++---------- pkgs/jni/lib/src/jvalues.dart | 12 +++---- pkgs/jni/lib/src/nio/jbyte_buffer.dart | 1 - pkgs/jni/lib/src/types.dart | 4 ++- pkgs/jni/test/jarray_test.dart | 7 ++-- pkgs/jnigen/CHANGELOG.md | 5 +++ .../lib/src/bindings/dart_generator.dart | 2 +- pkgs/jnigen/pubspec.yaml | 2 +- .../c_based/dart_bindings/simple_package.dart | 4 +-- .../dart_bindings/simple_package.dart | 4 +-- 14 files changed, 47 insertions(+), 43 deletions(-) diff --git a/pkgs/jni/CHANGELOG.md b/pkgs/jni/CHANGELOG.md index 15e7e9ec3..982f626e0 100644 --- a/pkgs/jni/CHANGELOG.md +++ b/pkgs/jni/CHANGELOG.md @@ -14,6 +14,10 @@ - **Breaking Change**: The default return `callType` of type parameter `int` for methods such as `JObject.callMethodByName` is now Java's `long` instead of `int` to be consistent with the way arguments work. +- **Breaking Change**: `JType` is now `sealed`. +- **Breaking Change**: Primitive types and their type classes are now `final`. +- **Breaking Change**: `JArray.filled` now uses the generated type class of the + `fill` object and not its Java runtime type. ## 0.7.0 diff --git a/pkgs/jni/lib/jni.dart b/pkgs/jni/lib/jni.dart index ce372fffd..5f0f34cdb 100644 --- a/pkgs/jni/lib/jni.dart +++ b/pkgs/jni/lib/jni.dart @@ -66,7 +66,6 @@ export 'src/jvalues.dart' hide JValueArgs, toJValues; export 'src/types.dart'; export 'src/jarray.dart'; export 'src/jobject.dart'; -export 'src/jprimitives.dart'; export 'src/jreference.dart' show JReferenceUseExtension; export 'src/lang/lang.dart'; diff --git a/pkgs/jni/lib/src/jarray.dart b/pkgs/jni/lib/src/jarray.dart index fac1d85c9..23643127c 100644 --- a/pkgs/jni/lib/src/jarray.dart +++ b/pkgs/jni/lib/src/jarray.dart @@ -13,7 +13,6 @@ import 'package:jni/src/third_party/generated_bindings.dart'; import 'jni.dart'; import 'jobject.dart'; -import 'jprimitives.dart'; import 'types.dart'; final class JArrayType extends JObjType> { @@ -92,10 +91,9 @@ class JArray extends JObject { /// Creates a [JArray] of the given length with [fill] at each position. /// /// The [length] must be a non-negative integer. - /// The [fill] must be a non-null [JObject]. static JArray filled(int length, E fill) { - assert(!fill.isNull, "fill must not be null."); - final clazz = fill.getClass(); + RangeError.checkNotNegative(length); + final clazz = fill.$type.getClass(); final array = JArray.fromRef( fill.$type as JObjType, Jni.accessors diff --git a/pkgs/jni/lib/src/jni.dart b/pkgs/jni/lib/src/jni.dart index 0bc154b9c..2554041d6 100644 --- a/pkgs/jni/lib/src/jni.dart +++ b/pkgs/jni/lib/src/jni.dart @@ -43,7 +43,7 @@ DynamicLibrary _loadDartJniLibrary({String? dir, String baseName = "dartjni"}) { } /// Utilities to spawn and manage JNI. -abstract class Jni { +abstract final class Jni { static final DynamicLibrary _dylib = _loadDartJniLibrary(dir: _dylibDir); static final JniBindings _bindings = JniBindings(_dylib); static final _getJniEnvFn = _dylib.lookup('GetJniEnv'); diff --git a/pkgs/jni/lib/src/jprimitives.dart b/pkgs/jni/lib/src/jprimitives.dart index 672255726..04448da2c 100644 --- a/pkgs/jni/lib/src/jprimitives.dart +++ b/pkgs/jni/lib/src/jprimitives.dart @@ -6,92 +6,92 @@ // lowercase. // ignore_for_file: camel_case_types -import 'types.dart'; +part of 'types.dart'; -abstract class JPrimitive {} +abstract final class JPrimitive {} -abstract class jbyte extends JPrimitive { +abstract final class jbyte extends JPrimitive { static const type = jbyteType(); } -class jbyteType extends JType { +final class jbyteType extends JType { const jbyteType(); @override final signature = 'B'; } -abstract class jboolean extends JPrimitive { +abstract final class jboolean extends JPrimitive { static const type = jbooleanType(); } -class jbooleanType extends JType { +final class jbooleanType extends JType { const jbooleanType(); @override final signature = 'Z'; } -abstract class jchar extends JPrimitive { +abstract final class jchar extends JPrimitive { static const type = jcharType(); } -class jcharType extends JType { +final class jcharType extends JType { const jcharType(); @override final signature = 'C'; } -abstract class jshort extends JPrimitive { +abstract final class jshort extends JPrimitive { static const type = jshortType(); } -class jshortType extends JType { +final class jshortType extends JType { const jshortType(); @override final signature = 'S'; } -abstract class jint extends JPrimitive { +abstract final class jint extends JPrimitive { static const type = jintType(); } -class jintType extends JType { +final class jintType extends JType { const jintType(); @override final signature = 'I'; } -abstract class jlong extends JPrimitive { +abstract final class jlong extends JPrimitive { static const type = jlongType(); } -class jlongType extends JType { +final class jlongType extends JType { const jlongType(); @override final signature = 'J'; } -abstract class jfloat extends JPrimitive { +abstract final class jfloat extends JPrimitive { static const type = jfloatType(); } -class jfloatType extends JType { +final class jfloatType extends JType { const jfloatType(); @override final signature = 'F'; } -abstract class jdouble extends JPrimitive { +abstract final class jdouble extends JPrimitive { static const type = jdoubleType(); } -class jdoubleType extends JType { +final class jdoubleType extends JType { const jdoubleType(); @override diff --git a/pkgs/jni/lib/src/jvalues.dart b/pkgs/jni/lib/src/jvalues.dart index 84439bf42..dc1773617 100644 --- a/pkgs/jni/lib/src/jvalues.dart +++ b/pkgs/jni/lib/src/jvalues.dart @@ -67,35 +67,35 @@ Pointer toJValues(List args, {Allocator allocator = calloc}) { /// Use this class as wrapper to convert an integer /// to Java `int` in jvalues method. -class JValueInt { +final class JValueInt { int value; JValueInt(this.value); } /// Use this class as wrapper to convert an integer /// to Java `short` in jvalues method. -class JValueShort { +final class JValueShort { int value; JValueShort(this.value); } /// Use this class as wrapper to convert an integer /// to Java `byte` in jvalues method. -class JValueByte { +final class JValueByte { int value; JValueByte(this.value); } /// Use this class as wrapper to convert an double /// to Java `float` in jvalues method. -class JValueFloat { +final class JValueFloat { double value; JValueFloat(this.value); } /// Use this class as wrapper to convert an integer /// to Java `char` in jvalues method. -class JValueChar { +final class JValueChar { int value; JValueChar(this.value); JValueChar.fromString(String s) : value = 0 { @@ -115,7 +115,7 @@ class JValueChar { /// /// Returned value is allocated using provided allocator. /// But default allocator may be used for string conversions. -class JValueArgs { +final class JValueArgs { late Pointer values; final List createdRefs = []; diff --git a/pkgs/jni/lib/src/nio/jbyte_buffer.dart b/pkgs/jni/lib/src/nio/jbyte_buffer.dart index 1b0acb2b3..d5f548851 100644 --- a/pkgs/jni/lib/src/nio/jbyte_buffer.dart +++ b/pkgs/jni/lib/src/nio/jbyte_buffer.dart @@ -8,7 +8,6 @@ import 'dart:typed_data'; import '../accessors.dart'; import '../jarray.dart'; import '../jni.dart'; -import '../jprimitives.dart'; import '../jreference.dart'; import '../jvalues.dart'; import '../third_party/generated_bindings.dart'; diff --git a/pkgs/jni/lib/src/types.dart b/pkgs/jni/lib/src/types.dart index c6f44b65b..d560b2da6 100644 --- a/pkgs/jni/lib/src/types.dart +++ b/pkgs/jni/lib/src/types.dart @@ -7,7 +7,9 @@ import 'dart:ffi'; import 'jni.dart'; import 'jobject.dart'; -abstract class JType { +part 'jprimitives.dart'; + +sealed class JType { const JType(); String get signature; diff --git a/pkgs/jni/test/jarray_test.dart b/pkgs/jni/test/jarray_test.dart index 9a9f59cc3..064bc84ef 100644 --- a/pkgs/jni/test/jarray_test.dart +++ b/pkgs/jni/test/jarray_test.dart @@ -289,11 +289,8 @@ void run({required TestRunnerCallback testRunner}) { final string = "abc".toJString()..releasedBy(arena); final array = JArray.filled(3, string)..releasedBy(arena); expect( - () { - final _ = JArray.filled(3, JString.fromRef(nullptr)) - ..releasedBy(arena); - }, - throwsA(isA()), + () => JArray.filled(-3, JString.fromRef(nullptr)), + throwsA(isA()), ); expect(array.length, 3); expect(array[0].toDartString(releaseOriginal: true), "abc"); diff --git a/pkgs/jnigen/CHANGELOG.md b/pkgs/jnigen/CHANGELOG.md index 00b2fc18e..0056f41dc 100644 --- a/pkgs/jnigen/CHANGELOG.md +++ b/pkgs/jnigen/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.8.0-wip + +- **Breaking Change**: The generated impl class for interfaces is now an + `interface`. + ## 0.7.0 - **Breaking Change** ([#387](https://github.com/dart-lang/jnigen/issues/387)): diff --git a/pkgs/jnigen/lib/src/bindings/dart_generator.dart b/pkgs/jnigen/lib/src/bindings/dart_generator.dart index ed523736c..9c2069299 100644 --- a/pkgs/jnigen/lib/src/bindings/dart_generator.dart +++ b/pkgs/jnigen/lib/src/bindings/dart_generator.dart @@ -520,7 +520,7 @@ class $name$typeParamsDef extends $superName { '}', ); s.write(''' -abstract class $implClassName$typeParamsDef { +abstract interface class $implClassName$typeParamsDef { factory $implClassName( $abstractFactoryArgs ) = _$implClassName; diff --git a/pkgs/jnigen/pubspec.yaml b/pkgs/jnigen/pubspec.yaml index 3fbd456ba..35e01bc2e 100644 --- a/pkgs/jnigen/pubspec.yaml +++ b/pkgs/jnigen/pubspec.yaml @@ -4,7 +4,7 @@ name: jnigen description: A Dart bindings generator for Java and Kotlin that uses JNI under the hood to interop with Java virtual machine. -version: 0.7.0 +version: 0.8.0-wip repository: https://github.com/dart-lang/jnigen/tree/main/jnigen environment: diff --git a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart index 1142fd675..7327fcfbf 100644 --- a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart @@ -3446,7 +3446,7 @@ class MyInterface<$T extends jni.JObject> extends jni.JObject { static Map get $impls => _$impls; } -abstract class $MyInterfaceImpl<$T extends jni.JObject> { +abstract interface class $MyInterfaceImpl<$T extends jni.JObject> { factory $MyInterfaceImpl({ required jni.JObjType<$T> T, required void Function(jni.JString s) voidCallback, @@ -3743,7 +3743,7 @@ class MyRunnable extends jni.JObject { } } -abstract class $MyRunnableImpl { +abstract interface class $MyRunnableImpl { factory $MyRunnableImpl({ required void Function() run, }) = _$MyRunnableImpl; diff --git a/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart index 7ac848d05..ba022690f 100644 --- a/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/dart_only/dart_bindings/simple_package.dart @@ -3255,7 +3255,7 @@ class MyInterface<$T extends jni.JObject> extends jni.JObject { static Map get $impls => _$impls; } -abstract class $MyInterfaceImpl<$T extends jni.JObject> { +abstract interface class $MyInterfaceImpl<$T extends jni.JObject> { factory $MyInterfaceImpl({ required jni.JObjType<$T> T, required void Function(jni.JString s) voidCallback, @@ -3550,7 +3550,7 @@ class MyRunnable extends jni.JObject { } } -abstract class $MyRunnableImpl { +abstract interface class $MyRunnableImpl { factory $MyRunnableImpl({ required void Function() run, }) = _$MyRunnableImpl; From 8456a7c3bab88472dac5dc97f352e9f187646ec6 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Tue, 26 Sep 2023 13:50:40 +0200 Subject: [PATCH 130/139] [jnigen] Add `JLazyReference` and `JFinalString` (https://github.com/dart-lang/jnigen/issues/400) --- pkgs/jni/lib/src/jfinal_string.dart | 31 ++++++++++++++++++ pkgs/jni/lib/src/jreference.dart | 46 +++++++++++++++++++++++++-- pkgs/jni/test/jfinal_string_test.dart | 43 +++++++++++++++++++++++++ 3 files changed, 118 insertions(+), 2 deletions(-) create mode 100644 pkgs/jni/lib/src/jfinal_string.dart create mode 100644 pkgs/jni/test/jfinal_string_test.dart diff --git a/pkgs/jni/lib/src/jfinal_string.dart b/pkgs/jni/lib/src/jfinal_string.dart new file mode 100644 index 000000000..ce3279981 --- /dev/null +++ b/pkgs/jni/lib/src/jfinal_string.dart @@ -0,0 +1,31 @@ +// 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 'dart:ffi'; + +import 'jreference.dart'; +import 'lang/jstring.dart'; +import 'third_party/generated_bindings.dart'; + +/// Used for `static final` Java strings, where the constant string is +/// available. +/// +/// If only its value is used using [toDartString], the [reference] is never +/// populated, saving a method call. +class JFinalString extends JString with JLazyReference { + @override + final JObjectPtr Function() lazyReference; + + final String string; + + JFinalString(this.lazyReference, this.string) : super.fromRef(nullptr); + + @override + String toDartString({bool releaseOriginal = false}) { + if (releaseOriginal) { + release(); + } + return string; + } +} diff --git a/pkgs/jni/lib/src/jreference.dart b/pkgs/jni/lib/src/jreference.dart index 8d8b71dcd..093e297df 100644 --- a/pkgs/jni/lib/src/jreference.dart +++ b/pkgs/jni/lib/src/jreference.dart @@ -29,8 +29,9 @@ extension ProtectedJReference on JReference { /// /// Detaches the finalizer so the underlying pointer will not be deleted. JObjectPtr toPointer() { + final ref = reference; setAsReleased(); - return _reference; + return ref; } } @@ -42,7 +43,9 @@ abstract class JReference implements Finalizable { NativeFinalizer(Jni.env.ptr.ref.DeleteGlobalRef.cast()); JReference.fromRef(this._reference) { - _finalizer.attach(this, _reference, detach: this); + if (_reference != nullptr) { + _finalizer.attach(this, _reference, detach: this); + } } bool _released = false; @@ -80,6 +83,45 @@ abstract class JReference implements Finalizable { void releasedBy(Arena arena) => arena.onReleaseAll(release); } +/// Creates a "lazy" [JReference]. +/// +/// The first use of [reference] will call [lazyReference]. +/// +/// This is useful when the Java object is not necessarily used directly, and +/// there are alternative ways to get a Dart representation of the Object. +/// +/// Object mixed in with this must call their super.[fromRef] constructor +/// with [nullptr]. +/// +/// Also see [JFinalString]. +mixin JLazyReference on JReference { + JObjectPtr? _lazyReference; + + JObjectPtr Function() get lazyReference; + + @override + JObjectPtr get reference { + if (_lazyReference == null) { + _lazyReference = lazyReference(); + JReference._finalizer.attach(this, _lazyReference!, detach: this); + return _lazyReference!; + } + if (_released) { + throw UseAfterReleaseError(); + } + return _lazyReference!; + } + + @override + void release() { + setAsReleased(); + if (_lazyReference == null) { + return; + } + Jni.env.DeleteGlobalRef(_lazyReference!); + } +} + extension JReferenceUseExtension on T { /// Applies [callback] on [this] object and then delete the underlying JNI /// reference, returning the result of [callback]. diff --git a/pkgs/jni/test/jfinal_string_test.dart b/pkgs/jni/test/jfinal_string_test.dart new file mode 100644 index 000000000..c8a998001 --- /dev/null +++ b/pkgs/jni/test/jfinal_string_test.dart @@ -0,0 +1,43 @@ +// 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 'dart:io'; + +import 'package:jni/jni.dart'; +import 'package:jni/src/jfinal_string.dart'; +import 'package:test/test.dart'; + +import 'test_util/test_util.dart'; + +void main() { + // Don't forget to initialize JNI. + if (!Platform.isAndroid) { + checkDylibIsUpToDate(); + Jni.spawnIfNotExists(dylibDir: "build/jni_libs", jvmOptions: ["-Xmx128m"]); + } + run(testRunner: test); +} + +void run({required TestRunnerCallback testRunner}) { + testRunner('JFinalString', () { + const string = 'abc'; + var referenceFetchedCount = 0; + final finalString = JFinalString( + () { + ++referenceFetchedCount; + return string.toJString().reference; + }, + string, + ); + expect(finalString.toDartString(), string); + expect(referenceFetchedCount, 0); + expect(finalString.reference, isNot(nullptr)); + expect(referenceFetchedCount, 1); + finalString.reference; + expect(referenceFetchedCount, 1); + expect(finalString.toDartString(releaseOriginal: true), string); + expect(() => finalString.reference, throwsA(isA())); + expect(finalString.release, throwsA(isA())); + }); +} From 917ed4d27271b2c60188cda7a4002cf7cec17cab Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 Oct 2023 19:41:20 +0000 Subject: [PATCH 131/139] [jnigen] Bump actions/setup-java from 3.12.0 to 3.13.0 (https://github.com/dart-lang/jnigen/issues/402) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/setup-java](https://github.com/actions/setup-java) from 3.12.0 to 3.13.0.
    Commits

    [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/setup-java&package-manager=github_actions&previous-version=3.12.0&new-version=3.13.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
    Dependabot commands and options
    You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    --- .github/workflows/jnigen.yaml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/jnigen.yaml b/.github/workflows/jnigen.yaml index b9842e00b..df0a79799 100644 --- a/.github/workflows/jnigen.yaml +++ b/.github/workflows/jnigen.yaml @@ -73,7 +73,7 @@ jobs: channel: ${{ matrix.sdk }} cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 + - uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 with: distribution: 'zulu' java-version: '11' @@ -126,7 +126,7 @@ jobs: channel: 'stable' cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 + - uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 with: distribution: 'zulu' java-version: '11' @@ -164,7 +164,7 @@ jobs: channel: 'stable' cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 + - uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 with: distribution: 'zulu' java-version: '11' @@ -213,7 +213,7 @@ jobs: channel: 'stable' cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 + - uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 with: distribution: 'zulu' java-version: '11' @@ -240,7 +240,7 @@ jobs: channel: 'stable' cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 + - uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 with: distribution: 'zulu' java-version: '11' @@ -268,7 +268,7 @@ jobs: channel: 'stable' cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 + - uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 with: distribution: 'temurin' java-version: '11' @@ -293,7 +293,7 @@ jobs: channel: 'stable' cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 + - uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 with: distribution: 'temurin' java-version: '11' @@ -318,7 +318,7 @@ jobs: channel: 'stable' cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 + - uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 with: distribution: 'zulu' java-version: '11' @@ -342,7 +342,7 @@ jobs: channel: 'stable' cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 + - uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 with: distribution: 'zulu' java-version: '11' @@ -357,7 +357,7 @@ jobs: working-directory: ./pkgs/jni/example steps: - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - - uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 + - uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 with: distribution: 'zulu' java-version: '11' @@ -381,7 +381,7 @@ jobs: channel: 'stable' cache: true cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' - - uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 + - uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 with: distribution: 'zulu' java-version: '11' From abcebe005dd95628e35e9e9cfd3aa4d0ee477c36 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 Oct 2023 19:42:30 +0000 Subject: [PATCH 132/139] [jnigen] Bump coverallsapp/github-action from 2.2.1 to 2.2.3 (https://github.com/dart-lang/jnigen/issues/403) Bumps [coverallsapp/github-action](https://github.com/coverallsapp/github-action) from 2.2.1 to 2.2.3.
    Commits

    [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=coverallsapp/github-action&package-manager=github_actions&previous-version=2.2.1&new-version=2.2.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
    Dependabot commands and options
    You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    --- .github/workflows/jnigen.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/jnigen.yaml b/.github/workflows/jnigen.yaml index df0a79799..b3bc11c3d 100644 --- a/.github/workflows/jnigen.yaml +++ b/.github/workflows/jnigen.yaml @@ -106,7 +106,7 @@ jobs: - name: Collect coverage run: dart pub global run coverage:test_with_coverage - name: Upload coverage - uses: coverallsapp/github-action@95b1a2355bd0e526ad2fd62da9fd386ad4c98474 + uses: coverallsapp/github-action@3dfc5567390f6fa9267c0ee9c251e4c8c3f18949 with: github-token: ${{ secrets.GITHUB_TOKEN }} flag-name: jnigen_tests @@ -182,7 +182,7 @@ jobs: - name: Collect coverage run: dart pub global run coverage:test_with_coverage - name: Upload coverage - uses: coverallsapp/github-action@95b1a2355bd0e526ad2fd62da9fd386ad4c98474 + uses: coverallsapp/github-action@3dfc5567390f6fa9267c0ee9c251e4c8c3f18949 with: github-token: ${{ secrets.GITHUB_TOKEN }} flag-name: jni_tests @@ -414,7 +414,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Coveralls finished - uses: coverallsapp/github-action@95b1a2355bd0e526ad2fd62da9fd386ad4c98474 + uses: coverallsapp/github-action@3dfc5567390f6fa9267c0ee9c251e4c8c3f18949 with: github-token: ${{ secrets.github_token }} parallel-finished: true From f2a82d87ae2ac40e20a76877d3c5778262b9472c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 14 Oct 2023 09:54:22 +0200 Subject: [PATCH 133/139] [jnigen] Bump actions/checkout from 3.6.0 to 4.1.0 (https://github.com/dart-lang/jnigen/issues/404) Bumps [actions/checkout](https://github.com/actions/checkout) from 3.6.0 to 4.1.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/f43a0e5ff2bd294095638e18286ca9a3d1956744...8ade135a41bc03ea155e62e844d188df1ea18608) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/jnigen.yaml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/jnigen.yaml b/.github/workflows/jnigen.yaml index b3bc11c3d..c732e2760 100644 --- a/.github/workflows/jnigen.yaml +++ b/.github/workflows/jnigen.yaml @@ -32,7 +32,7 @@ jobs: matrix: sdk: [stable] steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: ${{ matrix.sdk }} @@ -67,7 +67,7 @@ jobs: os: [ubuntu-latest] sdk: [stable, beta] steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: ${{ matrix.sdk }} @@ -120,7 +120,7 @@ jobs: run: working-directory: ./pkgs/jni steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' @@ -158,7 +158,7 @@ jobs: run: working-directory: ./pkgs/jni steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' @@ -207,7 +207,7 @@ jobs: run: working-directory: ./pkgs/jni steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' @@ -229,7 +229,7 @@ jobs: run: working-directory: ./pkgs/jnigen steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - name: Setup clang uses: egor-tensin/setup-clang@ef434b41eb33a70396fb336b1bae39c76d740c3d with: @@ -262,7 +262,7 @@ jobs: run: working-directory: ./pkgs/jni steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' @@ -283,7 +283,7 @@ jobs: run: working-directory: ./pkgs/jnigen steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - name: Setup clang format uses: ConorMacBride/install-package@3e7ad059e07782ee54fa35f827df52aae0626f30 with: @@ -312,7 +312,7 @@ jobs: run: working-directory: ./pkgs/jni/example steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' @@ -336,7 +336,7 @@ jobs: run: working-directory: ./pkgs/jni/example steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' @@ -356,7 +356,7 @@ jobs: run: working-directory: ./pkgs/jni/example steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 with: distribution: 'zulu' @@ -375,7 +375,7 @@ jobs: run: working-directory: ./pkgs/jnigen/example/pdfbox_plugin steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa with: channel: 'stable' From 039040ec369bda79cea184ee851c28951e7573ac Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Nov 2023 20:14:31 +0000 Subject: [PATCH 134/139] [jnigen] Bump subosito/flutter-action from 2.10.0 to 2.12.0 (https://github.com/dart-lang/jnigen/issues/411) Bumps [subosito/flutter-action](https://github.com/subosito/flutter-action) from 2.10.0 to 2.12.0.
    Release notes

    Sourced from subosito/flutter-action's releases.

    v2.12.0

    No release notes provided.

    v2.11.0

    Allow git ref as version for master channel:

    steps:
    - uses: actions/checkout@v3
    - uses: subosito/flutter-action@v2
      with:
        flutter-version: '5b12b74' # tag, commit or branch
        channel: 'master'
    - run: flutter --version
    
    Commits

    [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=subosito/flutter-action&package-manager=github_actions&previous-version=2.10.0&new-version=2.12.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
    Dependabot commands and options
    You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    --- .github/workflows/jnigen.yaml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/jnigen.yaml b/.github/workflows/jnigen.yaml index c732e2760..82b4a4722 100644 --- a/.github/workflows/jnigen.yaml +++ b/.github/workflows/jnigen.yaml @@ -33,7 +33,7 @@ jobs: sdk: [stable] steps: - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa + - uses: subosito/flutter-action@2783a3f08e1baf891508463f8c6653c258246225 with: channel: ${{ matrix.sdk }} cache: true @@ -68,7 +68,7 @@ jobs: sdk: [stable, beta] steps: - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa + - uses: subosito/flutter-action@2783a3f08e1baf891508463f8c6653c258246225 with: channel: ${{ matrix.sdk }} cache: true @@ -121,7 +121,7 @@ jobs: working-directory: ./pkgs/jni steps: - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa + - uses: subosito/flutter-action@2783a3f08e1baf891508463f8c6653c258246225 with: channel: 'stable' cache: true @@ -159,7 +159,7 @@ jobs: working-directory: ./pkgs/jni steps: - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa + - uses: subosito/flutter-action@2783a3f08e1baf891508463f8c6653c258246225 with: channel: 'stable' cache: true @@ -208,7 +208,7 @@ jobs: working-directory: ./pkgs/jni steps: - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa + - uses: subosito/flutter-action@2783a3f08e1baf891508463f8c6653c258246225 with: channel: 'stable' cache: true @@ -235,7 +235,7 @@ jobs: with: version: latest platform: x64 - - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa + - uses: subosito/flutter-action@2783a3f08e1baf891508463f8c6653c258246225 with: channel: 'stable' cache: true @@ -263,7 +263,7 @@ jobs: working-directory: ./pkgs/jni steps: - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa + - uses: subosito/flutter-action@2783a3f08e1baf891508463f8c6653c258246225 with: channel: 'stable' cache: true @@ -288,7 +288,7 @@ jobs: uses: ConorMacBride/install-package@3e7ad059e07782ee54fa35f827df52aae0626f30 with: brew: clang-format - - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa + - uses: subosito/flutter-action@2783a3f08e1baf891508463f8c6653c258246225 with: channel: 'stable' cache: true @@ -313,7 +313,7 @@ jobs: working-directory: ./pkgs/jni/example steps: - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa + - uses: subosito/flutter-action@2783a3f08e1baf891508463f8c6653c258246225 with: channel: 'stable' cache: true @@ -337,7 +337,7 @@ jobs: working-directory: ./pkgs/jni/example steps: - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa + - uses: subosito/flutter-action@2783a3f08e1baf891508463f8c6653c258246225 with: channel: 'stable' cache: true @@ -361,7 +361,7 @@ jobs: with: distribution: 'zulu' java-version: '11' - - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa + - uses: subosito/flutter-action@2783a3f08e1baf891508463f8c6653c258246225 with: channel: 'stable' cache: true @@ -376,7 +376,7 @@ jobs: working-directory: ./pkgs/jnigen/example/pdfbox_plugin steps: - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa + - uses: subosito/flutter-action@2783a3f08e1baf891508463f8c6653c258246225 with: channel: 'stable' cache: true From 8974cb0bec544c9295efe561f0c360b02c7eba6e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 2 Nov 2023 12:05:54 +0100 Subject: [PATCH 135/139] [jnigen] Bump actions/checkout from 4.1.0 to 4.1.1 (https://github.com/dart-lang/jnigen/issues/412) Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.0 to 4.1.1. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/8ade135a41bc03ea155e62e844d188df1ea18608...b4ffde65f46336ab88eb53be808477a3936bae11) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/jnigen.yaml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/jnigen.yaml b/.github/workflows/jnigen.yaml index 82b4a4722..deba348b8 100644 --- a/.github/workflows/jnigen.yaml +++ b/.github/workflows/jnigen.yaml @@ -32,7 +32,7 @@ jobs: matrix: sdk: [stable] steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - uses: subosito/flutter-action@2783a3f08e1baf891508463f8c6653c258246225 with: channel: ${{ matrix.sdk }} @@ -67,7 +67,7 @@ jobs: os: [ubuntu-latest] sdk: [stable, beta] steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - uses: subosito/flutter-action@2783a3f08e1baf891508463f8c6653c258246225 with: channel: ${{ matrix.sdk }} @@ -120,7 +120,7 @@ jobs: run: working-directory: ./pkgs/jni steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - uses: subosito/flutter-action@2783a3f08e1baf891508463f8c6653c258246225 with: channel: 'stable' @@ -158,7 +158,7 @@ jobs: run: working-directory: ./pkgs/jni steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - uses: subosito/flutter-action@2783a3f08e1baf891508463f8c6653c258246225 with: channel: 'stable' @@ -207,7 +207,7 @@ jobs: run: working-directory: ./pkgs/jni steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - uses: subosito/flutter-action@2783a3f08e1baf891508463f8c6653c258246225 with: channel: 'stable' @@ -229,7 +229,7 @@ jobs: run: working-directory: ./pkgs/jnigen steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - name: Setup clang uses: egor-tensin/setup-clang@ef434b41eb33a70396fb336b1bae39c76d740c3d with: @@ -262,7 +262,7 @@ jobs: run: working-directory: ./pkgs/jni steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - uses: subosito/flutter-action@2783a3f08e1baf891508463f8c6653c258246225 with: channel: 'stable' @@ -283,7 +283,7 @@ jobs: run: working-directory: ./pkgs/jnigen steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - name: Setup clang format uses: ConorMacBride/install-package@3e7ad059e07782ee54fa35f827df52aae0626f30 with: @@ -312,7 +312,7 @@ jobs: run: working-directory: ./pkgs/jni/example steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - uses: subosito/flutter-action@2783a3f08e1baf891508463f8c6653c258246225 with: channel: 'stable' @@ -336,7 +336,7 @@ jobs: run: working-directory: ./pkgs/jni/example steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - uses: subosito/flutter-action@2783a3f08e1baf891508463f8c6653c258246225 with: channel: 'stable' @@ -356,7 +356,7 @@ jobs: run: working-directory: ./pkgs/jni/example steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 with: distribution: 'zulu' @@ -375,7 +375,7 @@ jobs: run: working-directory: ./pkgs/jnigen/example/pdfbox_plugin steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - uses: subosito/flutter-action@2783a3f08e1baf891508463f8c6653c258246225 with: channel: 'stable' From b4a59e2e69fbb43c65f561e95a7ea97c06988978 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Thu, 2 Nov 2023 20:25:19 +0100 Subject: [PATCH 136/139] [jnigen] Remove macos plugin from package:jni (https://github.com/dart-lang/jnigen/issues/415) --- pkgs/jni/CHANGELOG.md | 3 +++ pkgs/jni/pubspec.yaml | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/jni/CHANGELOG.md b/pkgs/jni/CHANGELOG.md index 982f626e0..e4f919c53 100644 --- a/pkgs/jni/CHANGELOG.md +++ b/pkgs/jni/CHANGELOG.md @@ -19,6 +19,9 @@ - **Breaking Change**: `JArray.filled` now uses the generated type class of the `fill` object and not its Java runtime type. +## 0.7.1 +- Removed macOS Flutter plugin until package:jni supports it ([#41](https://github.com/dart-lang/jnigen/issues/41)). + ## 0.7.0 - **Breaking Change** ([#387](https://github.com/dart-lang/jnigen/issues/387)): diff --git a/pkgs/jni/pubspec.yaml b/pkgs/jni/pubspec.yaml index 1d99a4016..6efae3d66 100644 --- a/pkgs/jni/pubspec.yaml +++ b/pkgs/jni/pubspec.yaml @@ -41,8 +41,6 @@ flutter: ffiPlugin: true windows: ffiPlugin: true - macos: - ffiPlugin: true android: ffiPlugin: true package: com.github.dart_lang.jni From 69c3e21ec8a32eb74d86f5aea98a0a7daa43fbc1 Mon Sep 17 00:00:00 2001 From: Simon Lightfoot Date: Fri, 3 Nov 2023 09:24:03 +0000 Subject: [PATCH 137/139] [jnigen] Fix buffer overflow issue when converting strings from JNI to Dart (https://github.com/dart-lang/jnigen/issues/416) --- pkgs/jni/CHANGELOG.md | 3 +++ pkgs/jni/lib/src/jni.dart | 10 +++++----- pkgs/jni/lib/src/lang/jstring.dart | 6 +----- pkgs/jni/test/global_env_test.dart | 20 +++++++++++++++++--- 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/pkgs/jni/CHANGELOG.md b/pkgs/jni/CHANGELOG.md index e4f919c53..2065bb14b 100644 --- a/pkgs/jni/CHANGELOG.md +++ b/pkgs/jni/CHANGELOG.md @@ -19,6 +19,9 @@ - **Breaking Change**: `JArray.filled` now uses the generated type class of the `fill` object and not its Java runtime type. +## 0.7.2 +- Fixed a bug where reading non-null terminated strings would overflow. + ## 0.7.1 - Removed macOS Flutter plugin until package:jni supports it ([#41](https://github.com/dart-lang/jnigen/issues/41)). diff --git a/pkgs/jni/lib/src/jni.dart b/pkgs/jni/lib/src/jni.dart index 2554041d6..4993aee9d 100644 --- a/pkgs/jni/lib/src/jni.dart +++ b/pkgs/jni/lib/src/jni.dart @@ -330,8 +330,7 @@ extension ProtectedJniExtensions on Jni { } extension AdditionalEnvMethods on GlobalJniEnv { - /// Convenience method for converting a [JStringPtr] - /// to dart string. + /// Convenience method for converting a [JStringPtr] to dart string. /// if [releaseOriginal] is specified, jstring passed will be deleted using /// DeleteGlobalRef. String toDartString(JStringPtr jstringPtr, {bool releaseOriginal = false}) { @@ -342,7 +341,8 @@ extension AdditionalEnvMethods on GlobalJniEnv { if (chars == nullptr) { throw ArgumentError('Not a valid jstring pointer.'); } - final result = chars.cast().toDartString(); + final length = GetStringLength(jstringPtr); + final result = chars.cast().toDartString(length: length); ReleaseStringChars(jstringPtr, chars); if (releaseOriginal) { DeleteGlobalRef(jstringPtr); @@ -377,7 +377,7 @@ extension StringMethodsForJni on String { extension CharPtrMethodsForJni on Pointer { /// Same as calling `cast` followed by `toDartString`. - String toDartString() { - return cast().toDartString(); + String toDartString({int? length}) { + return cast().toDartString(length: length); } } diff --git a/pkgs/jni/lib/src/lang/jstring.dart b/pkgs/jni/lib/src/lang/jstring.dart index 9e542ff9b..9b8fbbb61 100644 --- a/pkgs/jni/lib/src/lang/jstring.dart +++ b/pkgs/jni/lib/src/lang/jstring.dart @@ -4,7 +4,6 @@ import 'dart:ffi'; -import 'package:ffi/ffi.dart'; import 'package:jni/src/jreference.dart'; import '../jni.dart'; @@ -59,10 +58,7 @@ class JString extends JObject { /// after conversion and this object will be marked as released. String toDartString({bool releaseOriginal = false}) { ensureNotNull(); - final length = Jni.env.GetStringLength(reference); - final chars = Jni.env.GetStringChars(reference, nullptr); - final result = chars.cast().toDartString(length: length); - Jni.env.ReleaseStringChars(reference, chars); + final result = Jni.env.toDartString(reference); if (releaseOriginal) { release(); } diff --git a/pkgs/jni/test/global_env_test.dart b/pkgs/jni/test/global_env_test.dart index 9b6a8b210..a5588cd96 100644 --- a/pkgs/jni/test/global_env_test.dart +++ b/pkgs/jni/test/global_env_test.dart @@ -4,6 +4,7 @@ import 'dart:io'; +import 'package:ffi/ffi.dart'; import 'package:jni/jni.dart'; import 'package:jni/src/jvalues.dart'; import 'package:test/test.dart'; @@ -118,18 +119,31 @@ void run({required TestRunnerCallback testRunner}) { })); testRunner( - "Convert back & forth between Dart & Java strings", + "Convert back & forth between Dart & Java strings (UTF-8)", () => using((arena) { const str = "ABCD EFGH"; - // This is what asJString and asDartString do internally final jstr = env.NewStringUTF(str.toNativeChars(arena)); final jchars = env.GetStringUTFChars(jstr, nullptr); - final dstr = jchars.toDartString(); + final jlen = env.GetStringUTFLength(jstr); + final dstr = jchars.toDartString(length: jlen); env.ReleaseStringUTFChars(jstr, jchars); expect(str, equals(dstr)); env.DeleteGlobalRef(jstr); })); + testRunner( + "Convert back & forth between Dart & Java strings (UTF-16)", + () => using((arena) { + const str = "ABCD EFGH"; + final jstr = env.NewString(str.toNativeUtf16().cast(), str.length); + final jchars = env.GetStringChars(jstr, nullptr); + final jlen = env.GetStringLength(jstr); + final dstr = jchars.cast().toDartString(length: jlen); + env.ReleaseStringChars(jstr, jchars); + expect(str, equals(dstr)); + env.DeleteGlobalRef(jstr); + })); + testRunner( "Print something from Java", () => using((arena) { From 3f34c6cd2baa34131f1ccddcef848872e5c13c92 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Thu, 16 Nov 2023 13:56:04 +0100 Subject: [PATCH 138/139] [jnigen] Reformat with the latest version of dart format (https://github.com/dart-lang/jnigen/issues/417) --- .../in_app_java/lib/android_utils.dart | 30 ++++++++----------- .../com/fasterxml/jackson/core/JsonToken.dart | 5 ++-- .../c_based/dart_bindings/simple_package.dart | 30 ++++++++----------- 3 files changed, 26 insertions(+), 39 deletions(-) diff --git a/pkgs/jnigen/example/in_app_java/lib/android_utils.dart b/pkgs/jnigen/example/in_app_java/lib/android_utils.dart index 8a0e58a87..8eba9cc8e 100644 --- a/pkgs/jnigen/example/in_app_java/lib/android_utils.dart +++ b/pkgs/jnigen/example/in_app_java/lib/android_utils.dart @@ -3210,9 +3210,8 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> } static final _new3 = jniLookup< - ffi - .NativeFunction)>>( - "HashMap__new3") + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>("HashMap__new3") .asFunction)>(); /// from: public void (java.util.Map map) @@ -3232,9 +3231,8 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> } static final _size = jniLookup< - ffi - .NativeFunction)>>( - "HashMap__size") + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>("HashMap__size") .asFunction)>(); /// from: public int size() @@ -3336,9 +3334,8 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> } static final _clear = jniLookup< - ffi - .NativeFunction)>>( - "HashMap__clear") + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>("HashMap__clear") .asFunction)>(); /// from: public void clear() @@ -3362,9 +3359,8 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> } static final _keySet = jniLookup< - ffi - .NativeFunction)>>( - "HashMap__keySet") + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>("HashMap__keySet") .asFunction)>(); /// from: public java.util.Set keySet() @@ -3374,9 +3370,8 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> } static final _values = jniLookup< - ffi - .NativeFunction)>>( - "HashMap__values") + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>("HashMap__values") .asFunction)>(); /// from: public java.util.Collection values() @@ -3614,9 +3609,8 @@ class HashMap<$K extends jni.JObject, $V extends jni.JObject> } static final _clone = jniLookup< - ffi - .NativeFunction)>>( - "HashMap__clone") + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>("HashMap__clone") .asFunction)>(); /// from: public java.lang.Object clone() diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart index bab355e9a..4d80a8f75 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/dart_bindings/com/fasterxml/jackson/core/JsonToken.dart @@ -80,9 +80,8 @@ class JsonToken extends jni.JObject { } static final _id = jniLookup< - ffi - .NativeFunction)>>( - "JsonToken__id") + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>("JsonToken__id") .asFunction)>(); /// from: public final int id() diff --git a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart index 7327fcfbf..c4f64a18c 100644 --- a/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/c_based/dart_bindings/simple_package.dart @@ -52,9 +52,8 @@ class Color extends jni.JObject { } static final _valueOf = jniLookup< - ffi - .NativeFunction)>>( - "Color__valueOf") + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>("Color__valueOf") .asFunction)>(); /// from: static public com.github.dart_lang.jnigen.simple_package.Color valueOf(java.lang.String name) @@ -671,9 +670,8 @@ class Example extends jni.JObject { } static final _addAll = jniLookup< - ffi - .NativeFunction)>>( - "Example__addAll") + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>("Example__addAll") .asFunction)>(); /// from: static public int addAll(int[] arr) @@ -2918,9 +2916,8 @@ class MyStack<$T extends jni.JObject> extends jni.JObject { } static final _of1 = jniLookup< - ffi - .NativeFunction)>>( - "MyStack__of1") + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>("MyStack__of1") .asFunction)>(); /// from: static public com.github.dart_lang.jnigen.generics.MyStack of(T obj) @@ -2973,9 +2970,8 @@ class MyStack<$T extends jni.JObject> extends jni.JObject { } static final _pop = jniLookup< - ffi - .NativeFunction)>>( - "MyStack__pop") + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>("MyStack__pop") .asFunction)>(); /// from: public T pop() @@ -2985,9 +2981,8 @@ class MyStack<$T extends jni.JObject> extends jni.JObject { } static final _size = jniLookup< - ffi - .NativeFunction)>>( - "MyStack__size") + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>("MyStack__size") .asFunction)>(); /// from: public int size() @@ -3664,9 +3659,8 @@ class MyRunnable extends jni.JObject { /// The type which includes information such as the signature of this class. static const type = $MyRunnableType(); static final _run = jniLookup< - ffi - .NativeFunction)>>( - "MyRunnable__run") + ffi.NativeFunction< + jni.JniResult Function(ffi.Pointer)>>("MyRunnable__run") .asFunction)>(); /// from: public abstract void run() From a063c401c4eeb9e58cc218e743137ca6882ac405 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Thu, 16 Nov 2023 14:13:18 +0100 Subject: [PATCH 139/139] [jnigen] Add paths to github workflow --- .github/workflows/jnigen.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/jnigen.yaml b/.github/workflows/jnigen.yaml index deba348b8..2deae7f80 100644 --- a/.github/workflows/jnigen.yaml +++ b/.github/workflows/jnigen.yaml @@ -13,8 +13,16 @@ on: # Run on PRs and pushes to the default branch. push: branches: [main] + paths: + - '.github/workflows/jnigen.yaml' + - 'pkgs/jnigen/**' + - 'pkgs/jni/**' pull_request: branches: [main] + paths: + - '.github/workflows/jnigen.yaml' + - 'pkgs/jnigen/**' + - 'pkgs/jni/**' schedule: - cron: '0 0 * * 0'
    Release notes

    Sourced from actions/setup-java's releases.

    v3.13.0

    What's changed

    In the scope of this release, support for Dragonwell JDK was added by @​Accelerator1996 in actions/setup-javahttps://github.com/dart-lang/jnigen/issues/532

    steps:
     - name: Checkout
       uses: actions/checkout@v3
     - name: Setup-java
       uses: actions/setup-java@v3
       with:
         distribution: 'dragonwell'
         java-version: '17'
    

    Several inaccuracies were also fixed:

    New Contributors

    Full Changelog: https://github.com/actions/setup-java/compare/v3...v3.13.0

    Commits