├── .changes ├── config.json └── readme.md ├── .github ├── CODEOWNERS ├── CODE_OF_CONDUCT.md ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── build.yml │ ├── covector-status.yml │ └── covector-version-or-publish.yml ├── .gitignore ├── .gitmodules ├── .license_template ├── CHANGELOG.md ├── Cargo.toml ├── Gir.toml ├── LICENSE ├── README.md ├── rustfmt.toml ├── src ├── auto │ ├── class.rs │ ├── context.rs │ ├── enums.rs │ ├── exception.rs │ ├── flags.rs │ ├── mod.rs │ ├── value.rs │ ├── versions.txt │ ├── virtual_machine.rs │ └── weak_value.rs ├── lib.rs └── value.rs └── sys ├── CHANGELOG.md ├── Cargo.toml ├── Gir.toml ├── LICENSE ├── build.rs ├── src └── lib.rs └── tests ├── abi.rs ├── constant.c ├── layout.c └── manual.h /.changes/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "gitSiteUrl": "https://github.com/tauri-apps/javascriptcore-rs/", 3 | "timeout": 3600000, 4 | "additionalBumpTypes": ["housekeeping"], 5 | "pkgManagers": { 6 | "rust": { 7 | "version": true, 8 | "getPublishedVersion": "cargo search ${ pkg.pkg } --limit 1 | sed -nE 's/^[^\"]*\"//; s/\".*//1p'", 9 | "prepublish": [ 10 | "sudo apt-get update", 11 | "sudo apt-get install -y libgtk-3-dev webkit2gtk-4.1", 12 | "cargo install cargo-audit --features=fix", 13 | { 14 | "command": "cargo generate-lockfile", 15 | "dryRunCommand": true, 16 | "runFromRoot": true, 17 | "pipe": true 18 | }, 19 | { 20 | "command": "echo \"# Cargo Audit\"", 21 | "dryRunCommand": true, 22 | "pipe": true 23 | }, 24 | { 25 | "command": "echo \"\\`\\`\\`\"", 26 | "dryRunCommand": true, 27 | "pipe": true 28 | }, 29 | { 30 | "command": "cargo audit ${ process.env.CARGO_AUDIT_OPTIONS || '' }", 31 | "dryRunCommand": true, 32 | "runFromRoot": true, 33 | "pipe": true 34 | }, 35 | { 36 | "command": "echo \"\\`\\`\\`\"", 37 | "dryRunCommand": true, 38 | "pipe": true 39 | } 40 | ], 41 | "publish": [ 42 | { 43 | "command": "cargo package --allow-dirty", 44 | "dryRunCommand": true 45 | }, 46 | { 47 | "command": "echo \"# Cargo Publish\"", 48 | "dryRunCommand": true, 49 | "pipe": true 50 | }, 51 | { 52 | "command": "echo \"\\`\\`\\`\"", 53 | "dryRunCommand": true, 54 | "pipe": true 55 | }, 56 | { 57 | "command": "cargo publish --no-verify", 58 | "dryRunCommand": "cargo publish --no-verify --dry-run --allow-dirty", 59 | "pipe": true 60 | }, 61 | { 62 | "command": "echo \"\\`\\`\\`\"", 63 | "dryRunCommand": true, 64 | "pipe": true 65 | } 66 | ], 67 | "postpublish": [ 68 | "git tag ${ pkg.pkg }-v${ pkgFile.versionMajor } -f", 69 | "git tag ${ pkg.pkg }-v${ pkgFile.versionMajor }.${ pkgFile.versionMinor } -f", 70 | "git push --tags -f" 71 | ], 72 | "assets": [ 73 | { 74 | "path": "${ pkg.path }/${ pkg.pkg }-${ pkgFile.version }.crate", 75 | "name": "${ pkg.pkg }-${ pkgFile.version }.crate" 76 | } 77 | ] 78 | } 79 | }, 80 | "packages": { 81 | "javascriptcore-rs-sys": { 82 | "path": "./sys", 83 | "manager": "rust" 84 | }, 85 | "javascriptcore-rs": { 86 | "path": "./", 87 | "manager": "rust" 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /.changes/readme.md: -------------------------------------------------------------------------------- 1 | # Changes 2 | 3 | ##### via https://github.com/jbolda/covector 4 | 5 | As you create PRs and make changes that require a version bump, please add a new markdown file in this folder. You do not note the version _number_, but rather the type of bump that you expect: major, minor, or patch. The filename is not important, as long as it is a `.md`, but we recommend that it represents the overall change for organizational purposes. 6 | 7 | When you select the version bump required, you do _not_ need to consider dependencies. Only note the package with the actual change, and any packages that depend on that package will be bumped automatically in the process. 8 | 9 | Use the following format: 10 | 11 | ```md 12 | --- 13 | "package-a": patch 14 | "package-b": minor 15 | --- 16 | 17 | Change summary goes here 18 | 19 | ``` 20 | 21 | Summaries do not have a specific character limit, but are text only. These summaries are used within the (future implementation of) changelogs. They will give context to the change and also point back to the original PR if more details and context are needed. 22 | 23 | Changes will be designated as a `major`, `minor` or `patch` as further described in [semver](https://semver.org/). 24 | 25 | Given a version number MAJOR.MINOR.PATCH, increment the: 26 | 27 | - MAJOR version when you make incompatible API changes, 28 | - MINOR version when you add functionality in a backwards compatible manner, and 29 | - PATCH version when you make backwards compatible bug fixes. 30 | 31 | Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format, but will be discussed prior to usage (as extra steps will be necessary in consideration of merging and publishing). 32 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Current WG Code Sub Teams: 2 | # @tauri-apps/admins 3 | # @tauri-apps/core 4 | # @tauri-apps/testing 5 | 6 | # admins default to review 7 | # Order is important; the last matching pattern takes the most precedence. 8 | * @tauri-apps/admins 9 | 10 | .github @tauri-apps/admins @tauri-apps/testing 11 | 12 | /examples/ @tauri-apps/testing 13 | 14 | /src/ @tauri-apps/core 15 | -------------------------------------------------------------------------------- /.github/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities. 4 | 5 | We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion. 6 | 7 | Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct. 8 | 9 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team. 10 | 11 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers. 12 | 13 | This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/) 14 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # 4 | patreon: # 5 | open_collective: tauri 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | custom: # Replace with a single custom sponsorship URL 9 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve Tauri 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **Steps To Reproduce** 14 | Steps to reproduce the behavior: 15 | 16 | **Expected behavior** 17 | A clear and concise description of what you expected to happen. 18 | 19 | **Screenshots** 20 | If applicable, add screenshots to help explain your problem. 21 | 22 | **Platform and Versions (please complete the following information):** 23 | OS: 24 | Rustc: 25 | 26 | **Additional context** 27 | Add any other context about the problem here. 28 | 29 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for Tauri 4 | title: '' 5 | labels: feature request 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | 22 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 22 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: test 2 | 3 | on: [pull_request] 4 | 5 | jobs: 6 | test: 7 | strategy: 8 | fail-fast: false 9 | matrix: 10 | rust_version: [stable] 11 | platform: 12 | - { target: x86_64-unknown-linux-gnu, os: ubuntu-latest } 13 | 14 | runs-on: ${{ matrix.platform.os }} 15 | 16 | steps: 17 | - uses: actions/checkout@v2 18 | - name: install stable 19 | uses: actions-rs/toolchain@v1 20 | with: 21 | toolchain: stable 22 | target: ${{ matrix.platform.target }} 23 | 24 | - name: install webkit2gtk (ubuntu only) 25 | if: matrix.platform.os == 'ubuntu-latest' 26 | run: | 27 | sudo apt-get update 28 | sudo apt-get install -y webkit2gtk-4.1 29 | 30 | - name: Get current date 31 | run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV 32 | 33 | - name: Cache cargo registry 34 | uses: actions/cache@v2.1.4 35 | with: 36 | path: ~/.cargo/registry 37 | # Add date to the cache to keep it up to date 38 | key: ${{ matrix.platform }}-stable-cargo-registry-${{ hashFiles('Cargo.toml') }}-${{ env.CURRENT_DATE }} 39 | # Restore from outdated cache for speed 40 | restore-keys: | 41 | ${{ matrix.platform }}-stable-cargo-registry-${{ hashFiles('Cargo.toml') }} 42 | ${{ matrix.platform }}-stable-cargo-registry- 43 | 44 | - name: Cache cargo index 45 | uses: actions/cache@v2.1.4 46 | with: 47 | path: ~/.cargo/git 48 | # Add date to the cache to keep it up to date 49 | key: ${{ matrix.platform }}-stable-cargo-index-${{ hashFiles('Cargo.toml') }}-${{ env.CURRENT_DATE }} 50 | # Restore from outdated cache for speed 51 | restore-keys: | 52 | ${{ matrix.platform }}-stable-cargo-index-${{ hashFiles('Cargo.toml') }} 53 | ${{ matrix.platform }}-stable-cargo-index- 54 | 55 | - name: Cache cargo target 56 | uses: actions/cache@v2 57 | with: 58 | path: target 59 | # Add date to the cache to keep it up to date 60 | key: ${{ matrix.platform }}-stable-cargo-core-${{ hashFiles('Cargo.toml') }}-${{ env.CURRENT_DATE }} 61 | # Restore from outdated cache for speed 62 | restore-keys: | 63 | ${{ matrix.platform }}-stable-cargo-core-${{ hashFiles('Cargo.toml') }} 64 | ${{ matrix.platform }}-stable-cargo-core- 65 | 66 | - name: Cargo fmt 67 | uses: actions-rs/cargo@v1 68 | with: 69 | command: fmt 70 | args: --all -- --check 71 | 72 | - name: build javascriptcore 73 | run: cargo build --target ${{ matrix.platform.target }} 74 | 75 | - name: build and run tests 76 | run: cargo test --verbose --target ${{ matrix.platform.target }} 77 | 78 | -------------------------------------------------------------------------------- /.github/workflows/covector-status.yml: -------------------------------------------------------------------------------- 1 | name: covector status 2 | on: [pull_request] 3 | 4 | jobs: 5 | covector: 6 | runs-on: ubuntu-latest 7 | 8 | steps: 9 | - uses: actions/checkout@v2 10 | with: 11 | fetch-depth: 0 12 | - name: covector status 13 | uses: jbolda/covector/packages/action@covector-v0 14 | id: covector 15 | with: 16 | command: 'status' 17 | -------------------------------------------------------------------------------- /.github/workflows/covector-version-or-publish.yml: -------------------------------------------------------------------------------- 1 | name: version or publish 2 | 3 | on: 4 | push: 5 | branches: 6 | - crate 7 | 8 | jobs: 9 | version-or-publish: 10 | runs-on: ubuntu-latest 11 | timeout-minutes: 65 12 | outputs: 13 | change: ${{ steps.covector.outputs.change }} 14 | commandRan: ${{ steps.covector.outputs.commandRan }} 15 | successfulPublish: ${{ steps.covector.outputs.successfulPublish }} 16 | 17 | steps: 18 | - uses: actions/checkout@v2 19 | with: 20 | fetch-depth: 0 21 | - name: cargo login 22 | run: cargo login ${{ secrets.ORG_CRATES_IO_TOKEN }} 23 | - name: git config 24 | run: | 25 | git config --global user.name "${{ github.event.pusher.name }}" 26 | git config --global user.email "${{ github.event.pusher.email }}" 27 | - name: covector version or publish (publish when no change files present) 28 | uses: jbolda/covector/packages/action@covector-v0 29 | id: covector 30 | env: 31 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} 32 | CARGO_AUDIT_OPTIONS: ${{ secrets.CARGO_AUDIT_OPTIONS }} 33 | with: 34 | token: ${{ secrets.GITHUB_TOKEN }} 35 | command: 'version-or-publish' 36 | createRelease: true 37 | - name: Create Pull Request With Versions Bumped 38 | id: cpr 39 | uses: tauri-apps/create-pull-request@v3 40 | if: steps.covector.outputs.commandRan == 'version' 41 | with: 42 | token: ${{ secrets.GITHUB_TOKEN }} 43 | title: "Publish New Versions" 44 | commit-message: "publish new versions" 45 | labels: "version updates" 46 | branch: "release" 47 | body: ${{ steps.covector.outputs.change }} 48 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | Cargo.lock 3 | .vscode/ -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "gir-files"] 2 | path = gir-files 3 | url = https://github.com/tauri-apps/gir-files 4 | [submodule "gir"] 5 | path = gir 6 | url = https://github.com/gtk-rs/gir 7 | -------------------------------------------------------------------------------- /.license_template: -------------------------------------------------------------------------------- 1 | // Copyright {20\d{2}(-20\d{2})?} The Gtk-rs Project Developers 2 | // Copyright {20\d{2}(-20\d{2})?} Tauri Programme within The Commons Conservancy 3 | // SPDX-License-Identifier: MIT -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## \[1.1.2] 4 | 5 | - [`4e6b9f4`](https://github.com/tauri-apps/javascriptcore-rs/commit/4e6b9f41121a2b6cbcda6f320e50921829232dc1) Properly replace dox with docsrs to fix docs.rs building. 6 | 7 | ## \[1.1.1] 8 | 9 | - [`92bf665`](https://github.com/tauri-apps/javascriptcore-rs/commit/92bf66509d773a704a24f228a7157a41d608bd80) Update dependency of javascriptcore-rs-sys to 1.1. 10 | 11 | ## \[1.1.0] 12 | 13 | - [`0ed9caf`](https://github.com/tauri-apps/javascriptcore-rs/commit/0ed9caf1da825bfe25fe9d7e1be7dd1f87422982) Update to gtk 0.18. 14 | Increase MSRV to 1.70.0 15 | 16 | ## \[1.0.0] 17 | 18 | - Cleanup codebase and bump to major. 19 | - [ae6b74e](https://github.com/tauri-apps/javascriptcore-rs/commit/ae6b74eb8161d46739334b8b4e25719c563a8da9) Add change file on 2023-04-03 20 | 21 | ## \[0.17.0] 22 | 23 | - Update gtk crates to 0.16 and update to 2021 edition. 24 | - [1674d07](https://github.com/tauri-apps/javascriptcore-rs/commit/1674d0716c4e76705ce958fc8c464bb9cb4e9320) Add change file on 2022-11-26 25 | 26 | ## \[0.16.0] 27 | 28 | - Update to gtk 0.15 29 | - [4aa6f17](https://github.com/tauri-apps/javascriptcore-rs/commit/4aa6f1758343f50cc7f7af42ac903077349b8051) Update to gtk 0.15 on 2022-01-18 30 | 31 | ## \[0.15.5] 32 | 33 | - Regenerate with latest gir-files 34 | - [68fa7e5](https://github.com/tauri-apps/javascriptcore-rs/commit/68fa7e5f12110ac47c07afaaeebfeb7067dfca21) Add change file on 2021-11-04 35 | 36 | ## \[0.15.1] 37 | 38 | - Enable cfg_doc to fix build doc error on docs.rs 39 | - [dd6730a](https://github.com/tauri-apps/javascriptcore-rs/commit/dd6730a7e478cf9a33b02f9fc8509f70330e861f) Fix docs.rs build error on 2021-10-05 40 | 41 | ## \[0.15.0] 42 | 43 | - Update Gir files 44 | - [3262e96](https://github.com/tauri-apps/javascriptcore-rs/commit/3262e96efc1cd6a640b81368255f3ae9325b2170) Bump version on 2021-10-04 45 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | description = "Rust bindings for the javacriptcore library" 3 | edition = "2021" 4 | keywords = [ "javascript", "gtk-rs", "gnome" ] 5 | license = "MIT" 6 | name = "javascriptcore-rs" 7 | repository = "https://github.com/tauri-apps/javascriptcore-rs" 8 | version = "1.1.2" 9 | 10 | [package.metadata.docs.rs] 11 | all-features = true 12 | rustc-args = [ "--cfg", "docsrs" ] 13 | rustdoc-args = [ "--cfg", "docsrs" ] 14 | 15 | [lib] 16 | name = "javascriptcore" 17 | 18 | [dependencies] 19 | bitflags = "^1.0" 20 | glib = "^0.18.0" 21 | 22 | [dependencies.ffi] 23 | package = "javascriptcore-rs-sys" 24 | path = "./sys" 25 | version = "1.1" 26 | 27 | [features] 28 | default = [ "v2_38" ] 29 | v2_28 = [ "ffi/v2_28" ] 30 | v2_38 = [ "ffi/v2_38", "v2_28" ] 31 | -------------------------------------------------------------------------------- /Gir.toml: -------------------------------------------------------------------------------- 1 | [options] 2 | deprecate_by_min_version = true 3 | girs_directories = ["gir-files/"] 4 | library = "JavaScriptCore" 5 | min_cfg_version = "2.24" 6 | single_version_file = true 7 | target_path = "." 8 | version = "4.1" 9 | work_mode = "normal" 10 | 11 | external_libraries = ["GLib", "GObject"] 12 | 13 | generate = [ 14 | "JavaScriptCore.CheckSyntaxMode", 15 | "JavaScriptCore.CheckSyntaxResult", 16 | "JavaScriptCore.Class", 17 | "JavaScriptCore.ClassDeletePropertyFunction", 18 | "JavaScriptCore.ClassEnumeratePropertiesFunction", 19 | "JavaScriptCore.ClassGetPropertyFunction", 20 | "JavaScriptCore.ClassHasPropertyFunction", 21 | "JavaScriptCore.ClassSetPropertyFunction", 22 | # "JavaScriptCore.ClassVTable", 23 | "JavaScriptCore.Exception", 24 | "JavaScriptCore.ExceptionHandler", 25 | "JavaScriptCore.OptionsFunc", 26 | "JavaScriptCore.OptionType", 27 | "JavaScriptCore.TypedArrayType", 28 | "JavaScriptCore.ValuePropertyFlags", 29 | "JavaScriptCore.VirtualMachine", 30 | ] 31 | 32 | manual = [ 33 | "GLib.Bytes", 34 | "GLib.DestroyNotify", 35 | "GLib.OptionGroup", 36 | "GObject.Callback", 37 | ] 38 | 39 | [[object]] 40 | generate_builder = true 41 | name = "JavaScriptCore.Context" 42 | status = "generate" 43 | 44 | [[object]] 45 | generate_builder = true 46 | name = "JavaScriptCore.Value" 47 | status = "generate" 48 | [[object.function]] 49 | name = "new_array" 50 | ignore = true 51 | [[object.function]] 52 | name = "new_array_buffer" 53 | manual = true 54 | [[object.function]] 55 | name = "array_buffer_get_data" 56 | manual = true 57 | [[object.function]] 58 | name = "typed_array_get_data" 59 | manual = true 60 | 61 | # [[object.function]] 62 | # ignore = true 63 | # name = "object_define_property_accessor" 64 | 65 | [[object]] 66 | generate_builder = true 67 | name = "JavaScriptCore.WeakValue" 68 | status = "generate" 69 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013-2021, The Gtk-rs Project Developers. 4 | Copyright (c) 2021, Tauri Programme within The Commons Conservancy. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # javascriptcore 2 | 3 | __Rust__ bindings and wrappers for __javascriptcore__. 4 | 5 | ## Using 6 | 7 | ```toml 8 | [dependencies] 9 | javascriptcore-rs = "0.16" 10 | ``` 11 | 12 | ## License 13 | 14 | __javascriptcore-rs__ is available under the MIT License, please refer to it. 15 | -------------------------------------------------------------------------------- /rustfmt.toml: -------------------------------------------------------------------------------- 1 | max_width = 100 2 | hard_tabs = false 3 | tab_spaces = 2 4 | newline_style = "Unix" 5 | use_small_heuristics = "Default" 6 | reorder_imports = true 7 | reorder_modules = true 8 | remove_nested_parens = true 9 | edition = "2018" 10 | merge_derives = true 11 | use_try_shorthand = false 12 | use_field_init_shorthand = false 13 | force_explicit_abi = true 14 | imports_granularity = "Crate" 15 | #license_template_path = ".license_template" -------------------------------------------------------------------------------- /src/auto/class.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/tauri-apps/gir-files) 3 | // DO NOT EDIT 4 | 5 | use glib::translate::*; 6 | 7 | glib::wrapper! { 8 | #[doc(alias = "JSCClass")] 9 | pub struct Class(Object); 10 | 11 | match fn { 12 | type_ => || ffi::jsc_class_get_type(), 13 | } 14 | } 15 | 16 | impl Class { 17 | //#[doc(alias = "jsc_class_add_constructor")] 18 | //pub fn add_constructor(&self, name: Option<&str>, callback: P, user_data: /*Unimplemented*/Option, return_type: glib::types::Type, n_params: u32, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> Option { 19 | // unsafe { TODO: call ffi:jsc_class_add_constructor() } 20 | //} 21 | 22 | //#[doc(alias = "jsc_class_add_constructor_variadic")] 23 | //pub fn add_constructor_variadic(&self, name: Option<&str>, callback: P, user_data: /*Unimplemented*/Option, return_type: glib::types::Type) -> Option { 24 | // unsafe { TODO: call ffi:jsc_class_add_constructor_variadic() } 25 | //} 26 | 27 | //#[doc(alias = "jsc_class_add_constructorv")] 28 | //pub fn add_constructorv(&self, name: Option<&str>, callback: P, user_data: /*Unimplemented*/Option, return_type: glib::types::Type, n_parameters: u32) -> Option { 29 | // unsafe { TODO: call ffi:jsc_class_add_constructorv() } 30 | //} 31 | 32 | //#[doc(alias = "jsc_class_add_method")] 33 | //pub fn add_method(&self, name: &str, callback: P, user_data: /*Unimplemented*/Option, return_type: glib::types::Type, n_params: u32, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) { 34 | // unsafe { TODO: call ffi:jsc_class_add_method() } 35 | //} 36 | 37 | //#[doc(alias = "jsc_class_add_method_variadic")] 38 | //pub fn add_method_variadic(&self, name: &str, callback: P, user_data: /*Unimplemented*/Option, return_type: glib::types::Type) { 39 | // unsafe { TODO: call ffi:jsc_class_add_method_variadic() } 40 | //} 41 | 42 | //#[doc(alias = "jsc_class_add_methodv")] 43 | //pub fn add_methodv(&self, name: &str, callback: P, user_data: /*Unimplemented*/Option, return_type: glib::types::Type, n_parameters: u32) { 44 | // unsafe { TODO: call ffi:jsc_class_add_methodv() } 45 | //} 46 | 47 | //#[doc(alias = "jsc_class_add_property")] 48 | //pub fn add_property(&self, name: &str, property_type: glib::types::Type, getter: Option>, setter: Option>, user_data: /*Unimplemented*/Option) { 49 | // unsafe { TODO: call ffi:jsc_class_add_property() } 50 | //} 51 | 52 | #[doc(alias = "jsc_class_get_name")] 53 | #[doc(alias = "get_name")] 54 | pub fn name(&self) -> Option { 55 | unsafe { from_glib_none(ffi::jsc_class_get_name(self.to_glib_none().0)) } 56 | } 57 | 58 | #[doc(alias = "jsc_class_get_parent")] 59 | #[doc(alias = "get_parent")] 60 | #[must_use] 61 | pub fn parent(&self) -> Option { 62 | unsafe { from_glib_none(ffi::jsc_class_get_parent(self.to_glib_none().0)) } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/auto/context.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/tauri-apps/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::{CheckSyntaxMode, CheckSyntaxResult, Exception, Value, VirtualMachine}; 6 | use glib::{prelude::*, translate::*}; 7 | use std::boxed::Box as Box_; 8 | 9 | glib::wrapper! { 10 | #[doc(alias = "JSCContext")] 11 | pub struct Context(Object); 12 | 13 | match fn { 14 | type_ => || ffi::jsc_context_get_type(), 15 | } 16 | } 17 | 18 | impl Context { 19 | pub const NONE: Option<&'static Context> = None; 20 | 21 | #[doc(alias = "jsc_context_new")] 22 | pub fn new() -> Context { 23 | unsafe { from_glib_full(ffi::jsc_context_new()) } 24 | } 25 | 26 | #[doc(alias = "jsc_context_new_with_virtual_machine")] 27 | #[doc(alias = "new_with_virtual_machine")] 28 | pub fn with_virtual_machine(vm: &impl IsA) -> Context { 29 | unsafe { 30 | from_glib_full(ffi::jsc_context_new_with_virtual_machine( 31 | vm.as_ref().to_glib_none().0, 32 | )) 33 | } 34 | } 35 | 36 | // rustdoc-stripper-ignore-next 37 | /// Creates a new builder-pattern struct instance to construct [`Context`] objects. 38 | /// 39 | /// This method returns an instance of [`ContextBuilder`](crate::builders::ContextBuilder) which can be used to create [`Context`] objects. 40 | pub fn builder() -> ContextBuilder { 41 | ContextBuilder::new() 42 | } 43 | 44 | #[doc(alias = "jsc_context_get_current")] 45 | #[doc(alias = "get_current")] 46 | pub fn current() -> Option { 47 | unsafe { from_glib_none(ffi::jsc_context_get_current()) } 48 | } 49 | } 50 | 51 | impl Default for Context { 52 | fn default() -> Self { 53 | Self::new() 54 | } 55 | } 56 | 57 | // rustdoc-stripper-ignore-next 58 | /// A [builder-pattern] type to construct [`Context`] objects. 59 | /// 60 | /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html 61 | #[must_use = "The builder must be built to be used"] 62 | pub struct ContextBuilder { 63 | builder: glib::object::ObjectBuilder<'static, Context>, 64 | } 65 | 66 | impl ContextBuilder { 67 | fn new() -> Self { 68 | Self { 69 | builder: glib::object::Object::builder(), 70 | } 71 | } 72 | 73 | pub fn virtual_machine(self, virtual_machine: &impl IsA) -> Self { 74 | Self { 75 | builder: self 76 | .builder 77 | .property("virtual-machine", virtual_machine.clone().upcast()), 78 | } 79 | } 80 | 81 | // rustdoc-stripper-ignore-next 82 | /// Build the [`Context`]. 83 | #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] 84 | pub fn build(self) -> Context { 85 | self.builder.build() 86 | } 87 | } 88 | 89 | mod sealed { 90 | pub trait Sealed {} 91 | impl> Sealed for T {} 92 | } 93 | 94 | pub trait ContextExt: IsA + sealed::Sealed + 'static { 95 | #[doc(alias = "jsc_context_check_syntax")] 96 | fn check_syntax( 97 | &self, 98 | code: &str, 99 | mode: CheckSyntaxMode, 100 | uri: &str, 101 | line_number: u32, 102 | ) -> (CheckSyntaxResult, Exception) { 103 | let length = code.len() as _; 104 | unsafe { 105 | let mut exception = std::ptr::null_mut(); 106 | let ret = from_glib(ffi::jsc_context_check_syntax( 107 | self.as_ref().to_glib_none().0, 108 | code.to_glib_none().0, 109 | length, 110 | mode.into_glib(), 111 | uri.to_glib_none().0, 112 | line_number, 113 | &mut exception, 114 | )); 115 | (ret, from_glib_full(exception)) 116 | } 117 | } 118 | 119 | #[doc(alias = "jsc_context_clear_exception")] 120 | fn clear_exception(&self) { 121 | unsafe { 122 | ffi::jsc_context_clear_exception(self.as_ref().to_glib_none().0); 123 | } 124 | } 125 | 126 | #[doc(alias = "jsc_context_evaluate")] 127 | fn evaluate(&self, code: &str) -> Option { 128 | let length = code.len() as _; 129 | unsafe { 130 | from_glib_full(ffi::jsc_context_evaluate( 131 | self.as_ref().to_glib_none().0, 132 | code.to_glib_none().0, 133 | length, 134 | )) 135 | } 136 | } 137 | 138 | //#[doc(alias = "jsc_context_evaluate_in_object")] 139 | //fn evaluate_in_object(&self, code: &str, object_instance: /*Unimplemented*/Option, object_class: Option<&Class>, uri: &str, line_number: u32) -> (Value, Value) { 140 | // unsafe { TODO: call ffi:jsc_context_evaluate_in_object() } 141 | //} 142 | 143 | #[doc(alias = "jsc_context_evaluate_with_source_uri")] 144 | fn evaluate_with_source_uri(&self, code: &str, uri: &str, line_number: u32) -> Option { 145 | let length = code.len() as _; 146 | unsafe { 147 | from_glib_full(ffi::jsc_context_evaluate_with_source_uri( 148 | self.as_ref().to_glib_none().0, 149 | code.to_glib_none().0, 150 | length, 151 | uri.to_glib_none().0, 152 | line_number, 153 | )) 154 | } 155 | } 156 | 157 | #[doc(alias = "jsc_context_get_exception")] 158 | #[doc(alias = "get_exception")] 159 | fn exception(&self) -> Option { 160 | unsafe { 161 | from_glib_none(ffi::jsc_context_get_exception( 162 | self.as_ref().to_glib_none().0, 163 | )) 164 | } 165 | } 166 | 167 | #[doc(alias = "jsc_context_get_global_object")] 168 | #[doc(alias = "get_global_object")] 169 | fn global_object(&self) -> Option { 170 | unsafe { 171 | from_glib_full(ffi::jsc_context_get_global_object( 172 | self.as_ref().to_glib_none().0, 173 | )) 174 | } 175 | } 176 | 177 | #[doc(alias = "jsc_context_get_value")] 178 | #[doc(alias = "get_value")] 179 | fn value(&self, name: &str) -> Option { 180 | unsafe { 181 | from_glib_full(ffi::jsc_context_get_value( 182 | self.as_ref().to_glib_none().0, 183 | name.to_glib_none().0, 184 | )) 185 | } 186 | } 187 | 188 | #[doc(alias = "jsc_context_get_virtual_machine")] 189 | #[doc(alias = "get_virtual_machine")] 190 | fn virtual_machine(&self) -> Option { 191 | unsafe { 192 | from_glib_none(ffi::jsc_context_get_virtual_machine( 193 | self.as_ref().to_glib_none().0, 194 | )) 195 | } 196 | } 197 | 198 | #[doc(alias = "jsc_context_pop_exception_handler")] 199 | fn pop_exception_handler(&self) { 200 | unsafe { 201 | ffi::jsc_context_pop_exception_handler(self.as_ref().to_glib_none().0); 202 | } 203 | } 204 | 205 | #[doc(alias = "jsc_context_push_exception_handler")] 206 | fn push_exception_handler(&self, handler: P) { 207 | let handler_data: Box_

= Box_::new(handler); 208 | unsafe extern "C" fn handler_func( 209 | context: *mut ffi::JSCContext, 210 | exception: *mut ffi::JSCException, 211 | user_data: glib::ffi::gpointer, 212 | ) { 213 | let context = from_glib_borrow(context); 214 | let exception = from_glib_borrow(exception); 215 | let callback: &P = &*(user_data as *mut _); 216 | (*callback)(&context, &exception) 217 | } 218 | let handler = Some(handler_func::

as _); 219 | unsafe extern "C" fn destroy_notify_func( 220 | data: glib::ffi::gpointer, 221 | ) { 222 | let _callback: Box_

= Box_::from_raw(data as *mut _); 223 | } 224 | let destroy_call3 = Some(destroy_notify_func::

as _); 225 | let super_callback0: Box_

= handler_data; 226 | unsafe { 227 | ffi::jsc_context_push_exception_handler( 228 | self.as_ref().to_glib_none().0, 229 | handler, 230 | Box_::into_raw(super_callback0) as *mut _, 231 | destroy_call3, 232 | ); 233 | } 234 | } 235 | 236 | //#[doc(alias = "jsc_context_register_class")] 237 | //fn register_class(&self, name: &str, parent_class: Option<&Class>, vtable: /*Ignored*/Option<&mut ClassVTable>) -> Option { 238 | // unsafe { TODO: call ffi:jsc_context_register_class() } 239 | //} 240 | 241 | #[doc(alias = "jsc_context_set_value")] 242 | fn set_value(&self, name: &str, value: &impl IsA) { 243 | unsafe { 244 | ffi::jsc_context_set_value( 245 | self.as_ref().to_glib_none().0, 246 | name.to_glib_none().0, 247 | value.as_ref().to_glib_none().0, 248 | ); 249 | } 250 | } 251 | 252 | #[doc(alias = "jsc_context_throw")] 253 | fn throw(&self, error_message: &str) { 254 | unsafe { 255 | ffi::jsc_context_throw( 256 | self.as_ref().to_glib_none().0, 257 | error_message.to_glib_none().0, 258 | ); 259 | } 260 | } 261 | 262 | #[doc(alias = "jsc_context_throw_exception")] 263 | fn throw_exception(&self, exception: &impl IsA) { 264 | unsafe { 265 | ffi::jsc_context_throw_exception( 266 | self.as_ref().to_glib_none().0, 267 | exception.as_ref().to_glib_none().0, 268 | ); 269 | } 270 | } 271 | 272 | //#[doc(alias = "jsc_context_throw_printf")] 273 | //fn throw_printf(&self, format: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) { 274 | // unsafe { TODO: call ffi:jsc_context_throw_printf() } 275 | //} 276 | 277 | #[doc(alias = "jsc_context_throw_with_name")] 278 | fn throw_with_name(&self, error_name: &str, error_message: &str) { 279 | unsafe { 280 | ffi::jsc_context_throw_with_name( 281 | self.as_ref().to_glib_none().0, 282 | error_name.to_glib_none().0, 283 | error_message.to_glib_none().0, 284 | ); 285 | } 286 | } 287 | 288 | //#[doc(alias = "jsc_context_throw_with_name_printf")] 289 | //fn throw_with_name_printf(&self, error_name: &str, format: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) { 290 | // unsafe { TODO: call ffi:jsc_context_throw_with_name_printf() } 291 | //} 292 | } 293 | 294 | impl> ContextExt for O {} 295 | -------------------------------------------------------------------------------- /src/auto/enums.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/tauri-apps/gir-files) 3 | // DO NOT EDIT 4 | 5 | use glib::translate::*; 6 | 7 | #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] 8 | #[non_exhaustive] 9 | #[doc(alias = "JSCCheckSyntaxMode")] 10 | pub enum CheckSyntaxMode { 11 | #[doc(alias = "JSC_CHECK_SYNTAX_MODE_SCRIPT")] 12 | Script, 13 | #[doc(alias = "JSC_CHECK_SYNTAX_MODE_MODULE")] 14 | Module, 15 | #[doc(hidden)] 16 | __Unknown(i32), 17 | } 18 | 19 | #[doc(hidden)] 20 | impl IntoGlib for CheckSyntaxMode { 21 | type GlibType = ffi::JSCCheckSyntaxMode; 22 | 23 | #[inline] 24 | fn into_glib(self) -> ffi::JSCCheckSyntaxMode { 25 | match self { 26 | Self::Script => ffi::JSC_CHECK_SYNTAX_MODE_SCRIPT, 27 | Self::Module => ffi::JSC_CHECK_SYNTAX_MODE_MODULE, 28 | Self::__Unknown(value) => value, 29 | } 30 | } 31 | } 32 | 33 | #[doc(hidden)] 34 | impl FromGlib for CheckSyntaxMode { 35 | #[inline] 36 | unsafe fn from_glib(value: ffi::JSCCheckSyntaxMode) -> Self { 37 | match value { 38 | ffi::JSC_CHECK_SYNTAX_MODE_SCRIPT => Self::Script, 39 | ffi::JSC_CHECK_SYNTAX_MODE_MODULE => Self::Module, 40 | value => Self::__Unknown(value), 41 | } 42 | } 43 | } 44 | 45 | #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] 46 | #[non_exhaustive] 47 | #[doc(alias = "JSCCheckSyntaxResult")] 48 | pub enum CheckSyntaxResult { 49 | #[doc(alias = "JSC_CHECK_SYNTAX_RESULT_SUCCESS")] 50 | Success, 51 | #[doc(alias = "JSC_CHECK_SYNTAX_RESULT_RECOVERABLE_ERROR")] 52 | RecoverableError, 53 | #[doc(alias = "JSC_CHECK_SYNTAX_RESULT_IRRECOVERABLE_ERROR")] 54 | IrrecoverableError, 55 | #[doc(alias = "JSC_CHECK_SYNTAX_RESULT_UNTERMINATED_LITERAL_ERROR")] 56 | UnterminatedLiteralError, 57 | #[doc(alias = "JSC_CHECK_SYNTAX_RESULT_OUT_OF_MEMORY_ERROR")] 58 | OutOfMemoryError, 59 | #[doc(alias = "JSC_CHECK_SYNTAX_RESULT_STACK_OVERFLOW_ERROR")] 60 | StackOverflowError, 61 | #[doc(hidden)] 62 | __Unknown(i32), 63 | } 64 | 65 | #[doc(hidden)] 66 | impl IntoGlib for CheckSyntaxResult { 67 | type GlibType = ffi::JSCCheckSyntaxResult; 68 | 69 | #[inline] 70 | fn into_glib(self) -> ffi::JSCCheckSyntaxResult { 71 | match self { 72 | Self::Success => ffi::JSC_CHECK_SYNTAX_RESULT_SUCCESS, 73 | Self::RecoverableError => ffi::JSC_CHECK_SYNTAX_RESULT_RECOVERABLE_ERROR, 74 | Self::IrrecoverableError => ffi::JSC_CHECK_SYNTAX_RESULT_IRRECOVERABLE_ERROR, 75 | Self::UnterminatedLiteralError => ffi::JSC_CHECK_SYNTAX_RESULT_UNTERMINATED_LITERAL_ERROR, 76 | Self::OutOfMemoryError => ffi::JSC_CHECK_SYNTAX_RESULT_OUT_OF_MEMORY_ERROR, 77 | Self::StackOverflowError => ffi::JSC_CHECK_SYNTAX_RESULT_STACK_OVERFLOW_ERROR, 78 | Self::__Unknown(value) => value, 79 | } 80 | } 81 | } 82 | 83 | #[doc(hidden)] 84 | impl FromGlib for CheckSyntaxResult { 85 | #[inline] 86 | unsafe fn from_glib(value: ffi::JSCCheckSyntaxResult) -> Self { 87 | match value { 88 | ffi::JSC_CHECK_SYNTAX_RESULT_SUCCESS => Self::Success, 89 | ffi::JSC_CHECK_SYNTAX_RESULT_RECOVERABLE_ERROR => Self::RecoverableError, 90 | ffi::JSC_CHECK_SYNTAX_RESULT_IRRECOVERABLE_ERROR => Self::IrrecoverableError, 91 | ffi::JSC_CHECK_SYNTAX_RESULT_UNTERMINATED_LITERAL_ERROR => Self::UnterminatedLiteralError, 92 | ffi::JSC_CHECK_SYNTAX_RESULT_OUT_OF_MEMORY_ERROR => Self::OutOfMemoryError, 93 | ffi::JSC_CHECK_SYNTAX_RESULT_STACK_OVERFLOW_ERROR => Self::StackOverflowError, 94 | value => Self::__Unknown(value), 95 | } 96 | } 97 | } 98 | 99 | #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] 100 | #[non_exhaustive] 101 | #[doc(alias = "JSCOptionType")] 102 | pub enum OptionType { 103 | #[doc(alias = "JSC_OPTION_BOOLEAN")] 104 | Boolean, 105 | #[doc(alias = "JSC_OPTION_INT")] 106 | Int, 107 | #[doc(alias = "JSC_OPTION_UINT")] 108 | Uint, 109 | #[doc(alias = "JSC_OPTION_SIZE")] 110 | Size, 111 | #[doc(alias = "JSC_OPTION_DOUBLE")] 112 | Double, 113 | #[doc(alias = "JSC_OPTION_STRING")] 114 | String, 115 | #[doc(alias = "JSC_OPTION_RANGE_STRING")] 116 | RangeString, 117 | #[doc(hidden)] 118 | __Unknown(i32), 119 | } 120 | 121 | #[doc(hidden)] 122 | impl IntoGlib for OptionType { 123 | type GlibType = ffi::JSCOptionType; 124 | 125 | #[inline] 126 | fn into_glib(self) -> ffi::JSCOptionType { 127 | match self { 128 | Self::Boolean => ffi::JSC_OPTION_BOOLEAN, 129 | Self::Int => ffi::JSC_OPTION_INT, 130 | Self::Uint => ffi::JSC_OPTION_UINT, 131 | Self::Size => ffi::JSC_OPTION_SIZE, 132 | Self::Double => ffi::JSC_OPTION_DOUBLE, 133 | Self::String => ffi::JSC_OPTION_STRING, 134 | Self::RangeString => ffi::JSC_OPTION_RANGE_STRING, 135 | Self::__Unknown(value) => value, 136 | } 137 | } 138 | } 139 | 140 | #[doc(hidden)] 141 | impl FromGlib for OptionType { 142 | #[inline] 143 | unsafe fn from_glib(value: ffi::JSCOptionType) -> Self { 144 | match value { 145 | ffi::JSC_OPTION_BOOLEAN => Self::Boolean, 146 | ffi::JSC_OPTION_INT => Self::Int, 147 | ffi::JSC_OPTION_UINT => Self::Uint, 148 | ffi::JSC_OPTION_SIZE => Self::Size, 149 | ffi::JSC_OPTION_DOUBLE => Self::Double, 150 | ffi::JSC_OPTION_STRING => Self::String, 151 | ffi::JSC_OPTION_RANGE_STRING => Self::RangeString, 152 | value => Self::__Unknown(value), 153 | } 154 | } 155 | } 156 | 157 | #[cfg(feature = "v2_38")] 158 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] 159 | #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] 160 | #[non_exhaustive] 161 | #[doc(alias = "JSCTypedArrayType")] 162 | pub enum TypedArrayType { 163 | #[doc(alias = "JSC_TYPED_ARRAY_NONE")] 164 | None, 165 | #[doc(alias = "JSC_TYPED_ARRAY_INT8")] 166 | Int8, 167 | #[doc(alias = "JSC_TYPED_ARRAY_INT16")] 168 | Int16, 169 | #[doc(alias = "JSC_TYPED_ARRAY_INT32")] 170 | Int32, 171 | #[doc(alias = "JSC_TYPED_ARRAY_INT64")] 172 | Int64, 173 | #[doc(alias = "JSC_TYPED_ARRAY_UINT8")] 174 | Uint8, 175 | #[doc(alias = "JSC_TYPED_ARRAY_UINT8_CLAMPED")] 176 | Uint8Clamped, 177 | #[doc(alias = "JSC_TYPED_ARRAY_UINT16")] 178 | Uint16, 179 | #[doc(alias = "JSC_TYPED_ARRAY_UINT32")] 180 | Uint32, 181 | #[doc(alias = "JSC_TYPED_ARRAY_UINT64")] 182 | Uint64, 183 | #[doc(alias = "JSC_TYPED_ARRAY_FLOAT32")] 184 | Float32, 185 | #[doc(alias = "JSC_TYPED_ARRAY_FLOAT64")] 186 | Float64, 187 | #[doc(hidden)] 188 | __Unknown(i32), 189 | } 190 | 191 | #[cfg(feature = "v2_38")] 192 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] 193 | #[doc(hidden)] 194 | impl IntoGlib for TypedArrayType { 195 | type GlibType = ffi::JSCTypedArrayType; 196 | 197 | #[inline] 198 | fn into_glib(self) -> ffi::JSCTypedArrayType { 199 | match self { 200 | Self::None => ffi::JSC_TYPED_ARRAY_NONE, 201 | Self::Int8 => ffi::JSC_TYPED_ARRAY_INT8, 202 | Self::Int16 => ffi::JSC_TYPED_ARRAY_INT16, 203 | Self::Int32 => ffi::JSC_TYPED_ARRAY_INT32, 204 | Self::Int64 => ffi::JSC_TYPED_ARRAY_INT64, 205 | Self::Uint8 => ffi::JSC_TYPED_ARRAY_UINT8, 206 | Self::Uint8Clamped => ffi::JSC_TYPED_ARRAY_UINT8_CLAMPED, 207 | Self::Uint16 => ffi::JSC_TYPED_ARRAY_UINT16, 208 | Self::Uint32 => ffi::JSC_TYPED_ARRAY_UINT32, 209 | Self::Uint64 => ffi::JSC_TYPED_ARRAY_UINT64, 210 | Self::Float32 => ffi::JSC_TYPED_ARRAY_FLOAT32, 211 | Self::Float64 => ffi::JSC_TYPED_ARRAY_FLOAT64, 212 | Self::__Unknown(value) => value, 213 | } 214 | } 215 | } 216 | 217 | #[cfg(feature = "v2_38")] 218 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] 219 | #[doc(hidden)] 220 | impl FromGlib for TypedArrayType { 221 | #[inline] 222 | unsafe fn from_glib(value: ffi::JSCTypedArrayType) -> Self { 223 | match value { 224 | ffi::JSC_TYPED_ARRAY_NONE => Self::None, 225 | ffi::JSC_TYPED_ARRAY_INT8 => Self::Int8, 226 | ffi::JSC_TYPED_ARRAY_INT16 => Self::Int16, 227 | ffi::JSC_TYPED_ARRAY_INT32 => Self::Int32, 228 | ffi::JSC_TYPED_ARRAY_INT64 => Self::Int64, 229 | ffi::JSC_TYPED_ARRAY_UINT8 => Self::Uint8, 230 | ffi::JSC_TYPED_ARRAY_UINT8_CLAMPED => Self::Uint8Clamped, 231 | ffi::JSC_TYPED_ARRAY_UINT16 => Self::Uint16, 232 | ffi::JSC_TYPED_ARRAY_UINT32 => Self::Uint32, 233 | ffi::JSC_TYPED_ARRAY_UINT64 => Self::Uint64, 234 | ffi::JSC_TYPED_ARRAY_FLOAT32 => Self::Float32, 235 | ffi::JSC_TYPED_ARRAY_FLOAT64 => Self::Float64, 236 | value => Self::__Unknown(value), 237 | } 238 | } 239 | } 240 | -------------------------------------------------------------------------------- /src/auto/exception.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/tauri-apps/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::Context; 6 | use glib::{prelude::*, translate::*}; 7 | 8 | glib::wrapper! { 9 | #[doc(alias = "JSCException")] 10 | pub struct Exception(Object); 11 | 12 | match fn { 13 | type_ => || ffi::jsc_exception_get_type(), 14 | } 15 | } 16 | 17 | impl Exception { 18 | pub const NONE: Option<&'static Exception> = None; 19 | 20 | #[doc(alias = "jsc_exception_new")] 21 | pub fn new(context: &impl IsA, message: &str) -> Exception { 22 | unsafe { 23 | from_glib_full(ffi::jsc_exception_new( 24 | context.as_ref().to_glib_none().0, 25 | message.to_glib_none().0, 26 | )) 27 | } 28 | } 29 | 30 | //#[doc(alias = "jsc_exception_new_printf")] 31 | //pub fn new_printf(context: &impl IsA, format: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> Exception { 32 | // unsafe { TODO: call ffi:jsc_exception_new_printf() } 33 | //} 34 | 35 | //#[doc(alias = "jsc_exception_new_vprintf")] 36 | //pub fn new_vprintf(context: &impl IsA, format: &str, args: /*Unknown conversion*//*Unimplemented*/Unsupported) -> Exception { 37 | // unsafe { TODO: call ffi:jsc_exception_new_vprintf() } 38 | //} 39 | 40 | #[doc(alias = "jsc_exception_new_with_name")] 41 | #[doc(alias = "new_with_name")] 42 | pub fn with_name(context: &impl IsA, name: &str, message: &str) -> Exception { 43 | unsafe { 44 | from_glib_full(ffi::jsc_exception_new_with_name( 45 | context.as_ref().to_glib_none().0, 46 | name.to_glib_none().0, 47 | message.to_glib_none().0, 48 | )) 49 | } 50 | } 51 | 52 | //#[doc(alias = "jsc_exception_new_with_name_printf")] 53 | //#[doc(alias = "new_with_name_printf")] 54 | //pub fn with_name_printf(context: &impl IsA, name: &str, format: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> Exception { 55 | // unsafe { TODO: call ffi:jsc_exception_new_with_name_printf() } 56 | //} 57 | 58 | //#[doc(alias = "jsc_exception_new_with_name_vprintf")] 59 | //#[doc(alias = "new_with_name_vprintf")] 60 | //pub fn with_name_vprintf(context: &impl IsA, name: &str, format: &str, args: /*Unknown conversion*//*Unimplemented*/Unsupported) -> Exception { 61 | // unsafe { TODO: call ffi:jsc_exception_new_with_name_vprintf() } 62 | //} 63 | } 64 | 65 | impl std::fmt::Display for Exception { 66 | #[inline] 67 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 68 | f.write_str(&ExceptionExt::to_str(self)) 69 | } 70 | } 71 | 72 | mod sealed { 73 | pub trait Sealed {} 74 | impl> Sealed for T {} 75 | } 76 | 77 | pub trait ExceptionExt: IsA + sealed::Sealed + 'static { 78 | #[doc(alias = "jsc_exception_get_backtrace_string")] 79 | #[doc(alias = "get_backtrace_string")] 80 | fn backtrace_string(&self) -> Option { 81 | unsafe { 82 | from_glib_none(ffi::jsc_exception_get_backtrace_string( 83 | self.as_ref().to_glib_none().0, 84 | )) 85 | } 86 | } 87 | 88 | #[doc(alias = "jsc_exception_get_column_number")] 89 | #[doc(alias = "get_column_number")] 90 | fn column_number(&self) -> u32 { 91 | unsafe { ffi::jsc_exception_get_column_number(self.as_ref().to_glib_none().0) } 92 | } 93 | 94 | #[doc(alias = "jsc_exception_get_line_number")] 95 | #[doc(alias = "get_line_number")] 96 | fn line_number(&self) -> u32 { 97 | unsafe { ffi::jsc_exception_get_line_number(self.as_ref().to_glib_none().0) } 98 | } 99 | 100 | #[doc(alias = "jsc_exception_get_message")] 101 | #[doc(alias = "get_message")] 102 | fn message(&self) -> Option { 103 | unsafe { 104 | from_glib_none(ffi::jsc_exception_get_message( 105 | self.as_ref().to_glib_none().0, 106 | )) 107 | } 108 | } 109 | 110 | #[doc(alias = "jsc_exception_get_name")] 111 | #[doc(alias = "get_name")] 112 | fn name(&self) -> Option { 113 | unsafe { from_glib_none(ffi::jsc_exception_get_name(self.as_ref().to_glib_none().0)) } 114 | } 115 | 116 | #[doc(alias = "jsc_exception_get_source_uri")] 117 | #[doc(alias = "get_source_uri")] 118 | fn source_uri(&self) -> Option { 119 | unsafe { 120 | from_glib_none(ffi::jsc_exception_get_source_uri( 121 | self.as_ref().to_glib_none().0, 122 | )) 123 | } 124 | } 125 | 126 | #[doc(alias = "jsc_exception_report")] 127 | fn report(&self) -> Option { 128 | unsafe { from_glib_full(ffi::jsc_exception_report(self.as_ref().to_glib_none().0)) } 129 | } 130 | 131 | #[doc(alias = "jsc_exception_to_string")] 132 | #[doc(alias = "to_string")] 133 | fn to_str(&self) -> glib::GString { 134 | unsafe { from_glib_full(ffi::jsc_exception_to_string(self.as_ref().to_glib_none().0)) } 135 | } 136 | } 137 | 138 | impl> ExceptionExt for O {} 139 | -------------------------------------------------------------------------------- /src/auto/flags.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/tauri-apps/gir-files) 3 | // DO NOT EDIT 4 | 5 | use glib::{bitflags::bitflags, translate::*}; 6 | 7 | bitflags! { 8 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] 9 | #[doc(alias = "JSCValuePropertyFlags")] 10 | pub struct ValuePropertyFlags: u32 { 11 | #[doc(alias = "JSC_VALUE_PROPERTY_CONFIGURABLE")] 12 | const CONFIGURABLE = ffi::JSC_VALUE_PROPERTY_CONFIGURABLE as _; 13 | #[doc(alias = "JSC_VALUE_PROPERTY_ENUMERABLE")] 14 | const ENUMERABLE = ffi::JSC_VALUE_PROPERTY_ENUMERABLE as _; 15 | #[doc(alias = "JSC_VALUE_PROPERTY_WRITABLE")] 16 | const WRITABLE = ffi::JSC_VALUE_PROPERTY_WRITABLE as _; 17 | } 18 | } 19 | 20 | #[doc(hidden)] 21 | impl IntoGlib for ValuePropertyFlags { 22 | type GlibType = ffi::JSCValuePropertyFlags; 23 | 24 | #[inline] 25 | fn into_glib(self) -> ffi::JSCValuePropertyFlags { 26 | self.bits() 27 | } 28 | } 29 | 30 | #[doc(hidden)] 31 | impl FromGlib for ValuePropertyFlags { 32 | #[inline] 33 | unsafe fn from_glib(value: ffi::JSCValuePropertyFlags) -> Self { 34 | Self::from_bits_truncate(value) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/auto/mod.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/tauri-apps/gir-files) 3 | // DO NOT EDIT 4 | 5 | mod class; 6 | pub use self::class::Class; 7 | 8 | mod context; 9 | pub use self::context::Context; 10 | 11 | mod exception; 12 | pub use self::exception::Exception; 13 | 14 | mod value; 15 | pub use self::value::Value; 16 | 17 | mod virtual_machine; 18 | pub use self::virtual_machine::VirtualMachine; 19 | 20 | mod weak_value; 21 | pub use self::weak_value::WeakValue; 22 | 23 | mod enums; 24 | pub use self::enums::CheckSyntaxMode; 25 | pub use self::enums::CheckSyntaxResult; 26 | pub use self::enums::OptionType; 27 | #[cfg(feature = "v2_38")] 28 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] 29 | pub use self::enums::TypedArrayType; 30 | 31 | mod flags; 32 | pub use self::flags::ValuePropertyFlags; 33 | 34 | pub(crate) mod traits { 35 | pub use super::context::ContextExt; 36 | pub use super::exception::ExceptionExt; 37 | pub use super::value::ValueExt; 38 | pub use super::weak_value::WeakValueExt; 39 | } 40 | pub(crate) mod builders { 41 | pub use super::context::ContextBuilder; 42 | pub use super::value::ValueBuilder; 43 | pub use super::weak_value::WeakValueBuilder; 44 | } 45 | -------------------------------------------------------------------------------- /src/auto/value.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/tauri-apps/gir-files) 3 | // DO NOT EDIT 4 | 5 | #[cfg(feature = "v2_38")] 6 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] 7 | use crate::TypedArrayType; 8 | use crate::{Context, ValuePropertyFlags}; 9 | use glib::{prelude::*, translate::*}; 10 | 11 | glib::wrapper! { 12 | #[doc(alias = "JSCValue")] 13 | pub struct Value(Object); 14 | 15 | match fn { 16 | type_ => || ffi::jsc_value_get_type(), 17 | } 18 | } 19 | 20 | impl Value { 21 | pub const NONE: Option<&'static Value> = None; 22 | 23 | #[doc(alias = "jsc_value_new_array_from_garray")] 24 | pub fn new_array_from_garray(context: &impl IsA, array: &[Value]) -> Value { 25 | unsafe { 26 | from_glib_full(ffi::jsc_value_new_array_from_garray( 27 | context.as_ref().to_glib_none().0, 28 | array.to_glib_none().0, 29 | )) 30 | } 31 | } 32 | 33 | #[doc(alias = "jsc_value_new_array_from_strv")] 34 | pub fn new_array_from_strv(context: &impl IsA, strv: &[&str]) -> Value { 35 | unsafe { 36 | from_glib_full(ffi::jsc_value_new_array_from_strv( 37 | context.as_ref().to_glib_none().0, 38 | strv.to_glib_none().0, 39 | )) 40 | } 41 | } 42 | 43 | #[doc(alias = "jsc_value_new_boolean")] 44 | pub fn new_boolean(context: &impl IsA, value: bool) -> Value { 45 | unsafe { 46 | from_glib_full(ffi::jsc_value_new_boolean( 47 | context.as_ref().to_glib_none().0, 48 | value.into_glib(), 49 | )) 50 | } 51 | } 52 | 53 | #[cfg(feature = "v2_28")] 54 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_28")))] 55 | #[doc(alias = "jsc_value_new_from_json")] 56 | #[doc(alias = "new_from_json")] 57 | pub fn from_json(context: &impl IsA, json: &str) -> Value { 58 | unsafe { 59 | from_glib_full(ffi::jsc_value_new_from_json( 60 | context.as_ref().to_glib_none().0, 61 | json.to_glib_none().0, 62 | )) 63 | } 64 | } 65 | 66 | //#[doc(alias = "jsc_value_new_function")] 67 | //pub fn new_function(context: &impl IsA, name: Option<&str>, callback: P, user_data: /*Unimplemented*/Option, return_type: glib::types::Type, n_params: u32, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> Value { 68 | // unsafe { TODO: call ffi:jsc_value_new_function() } 69 | //} 70 | 71 | //#[doc(alias = "jsc_value_new_function_variadic")] 72 | //pub fn new_function_variadic(context: &impl IsA, name: Option<&str>, callback: P, user_data: /*Unimplemented*/Option, return_type: glib::types::Type) -> Value { 73 | // unsafe { TODO: call ffi:jsc_value_new_function_variadic() } 74 | //} 75 | 76 | //#[doc(alias = "jsc_value_new_functionv")] 77 | //pub fn new_functionv(context: &impl IsA, name: Option<&str>, callback: P, user_data: /*Unimplemented*/Option, return_type: glib::types::Type, n_parameters: u32) -> Value { 78 | // unsafe { TODO: call ffi:jsc_value_new_functionv() } 79 | //} 80 | 81 | #[doc(alias = "jsc_value_new_null")] 82 | pub fn new_null(context: &impl IsA) -> Value { 83 | unsafe { from_glib_full(ffi::jsc_value_new_null(context.as_ref().to_glib_none().0)) } 84 | } 85 | 86 | #[doc(alias = "jsc_value_new_number")] 87 | pub fn new_number(context: &impl IsA, number: f64) -> Value { 88 | unsafe { 89 | from_glib_full(ffi::jsc_value_new_number( 90 | context.as_ref().to_glib_none().0, 91 | number, 92 | )) 93 | } 94 | } 95 | 96 | //#[doc(alias = "jsc_value_new_object")] 97 | //pub fn new_object(context: &impl IsA, instance: /*Unimplemented*/Option, jsc_class: Option<&Class>) -> Value { 98 | // unsafe { TODO: call ffi:jsc_value_new_object() } 99 | //} 100 | 101 | #[doc(alias = "jsc_value_new_string")] 102 | pub fn new_string(context: &impl IsA, string: Option<&str>) -> Value { 103 | unsafe { 104 | from_glib_full(ffi::jsc_value_new_string( 105 | context.as_ref().to_glib_none().0, 106 | string.to_glib_none().0, 107 | )) 108 | } 109 | } 110 | 111 | #[doc(alias = "jsc_value_new_string_from_bytes")] 112 | pub fn new_string_from_bytes(context: &impl IsA, bytes: Option<&glib::Bytes>) -> Value { 113 | unsafe { 114 | from_glib_full(ffi::jsc_value_new_string_from_bytes( 115 | context.as_ref().to_glib_none().0, 116 | bytes.to_glib_none().0, 117 | )) 118 | } 119 | } 120 | 121 | #[cfg(feature = "v2_38")] 122 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] 123 | #[doc(alias = "jsc_value_new_typed_array")] 124 | pub fn new_typed_array( 125 | context: &impl IsA, 126 | type_: TypedArrayType, 127 | length: usize, 128 | ) -> Value { 129 | unsafe { 130 | from_glib_full(ffi::jsc_value_new_typed_array( 131 | context.as_ref().to_glib_none().0, 132 | type_.into_glib(), 133 | length, 134 | )) 135 | } 136 | } 137 | 138 | #[doc(alias = "jsc_value_new_undefined")] 139 | pub fn new_undefined(context: &impl IsA) -> Value { 140 | unsafe { 141 | from_glib_full(ffi::jsc_value_new_undefined( 142 | context.as_ref().to_glib_none().0, 143 | )) 144 | } 145 | } 146 | 147 | // rustdoc-stripper-ignore-next 148 | /// Creates a new builder-pattern struct instance to construct [`Value`] objects. 149 | /// 150 | /// This method returns an instance of [`ValueBuilder`](crate::builders::ValueBuilder) which can be used to create [`Value`] objects. 151 | pub fn builder() -> ValueBuilder { 152 | ValueBuilder::new() 153 | } 154 | } 155 | 156 | impl std::fmt::Display for Value { 157 | #[inline] 158 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 159 | f.write_str(&ValueExt::to_str(self)) 160 | } 161 | } 162 | 163 | // rustdoc-stripper-ignore-next 164 | /// A [builder-pattern] type to construct [`Value`] objects. 165 | /// 166 | /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html 167 | #[must_use = "The builder must be built to be used"] 168 | pub struct ValueBuilder { 169 | builder: glib::object::ObjectBuilder<'static, Value>, 170 | } 171 | 172 | impl ValueBuilder { 173 | fn new() -> Self { 174 | Self { 175 | builder: glib::object::Object::builder(), 176 | } 177 | } 178 | 179 | pub fn context(self, context: &impl IsA) -> Self { 180 | Self { 181 | builder: self.builder.property("context", context.clone().upcast()), 182 | } 183 | } 184 | 185 | // rustdoc-stripper-ignore-next 186 | /// Build the [`Value`]. 187 | #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] 188 | pub fn build(self) -> Value { 189 | self.builder.build() 190 | } 191 | } 192 | 193 | mod sealed { 194 | pub trait Sealed {} 195 | impl> Sealed for T {} 196 | } 197 | 198 | pub trait ValueExt: IsA + sealed::Sealed + 'static { 199 | #[cfg(feature = "v2_38")] 200 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] 201 | #[doc(alias = "jsc_value_array_buffer_get_size")] 202 | fn array_buffer_get_size(&self) -> usize { 203 | unsafe { ffi::jsc_value_array_buffer_get_size(self.as_ref().to_glib_none().0) } 204 | } 205 | 206 | //#[doc(alias = "jsc_value_constructor_call")] 207 | //#[must_use] 208 | //fn constructor_call(&self, first_parameter_type: glib::types::Type, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> Option { 209 | // unsafe { TODO: call ffi:jsc_value_constructor_call() } 210 | //} 211 | 212 | #[doc(alias = "jsc_value_constructor_callv")] 213 | #[must_use] 214 | fn constructor_callv(&self, parameters: &[Value]) -> Option { 215 | let n_parameters = parameters.len() as _; 216 | unsafe { 217 | from_glib_full(ffi::jsc_value_constructor_callv( 218 | self.as_ref().to_glib_none().0, 219 | n_parameters, 220 | parameters.to_glib_none().0, 221 | )) 222 | } 223 | } 224 | 225 | //#[doc(alias = "jsc_value_function_call")] 226 | //#[must_use] 227 | //fn function_call(&self, first_parameter_type: glib::types::Type, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> Option { 228 | // unsafe { TODO: call ffi:jsc_value_function_call() } 229 | //} 230 | 231 | #[doc(alias = "jsc_value_function_callv")] 232 | #[must_use] 233 | fn function_callv(&self, parameters: &[Value]) -> Option { 234 | let n_parameters = parameters.len() as _; 235 | unsafe { 236 | from_glib_full(ffi::jsc_value_function_callv( 237 | self.as_ref().to_glib_none().0, 238 | n_parameters, 239 | parameters.to_glib_none().0, 240 | )) 241 | } 242 | } 243 | 244 | #[doc(alias = "jsc_value_get_context")] 245 | #[doc(alias = "get_context")] 246 | fn context(&self) -> Option { 247 | unsafe { from_glib_none(ffi::jsc_value_get_context(self.as_ref().to_glib_none().0)) } 248 | } 249 | 250 | #[doc(alias = "jsc_value_is_array")] 251 | fn is_array(&self) -> bool { 252 | unsafe { from_glib(ffi::jsc_value_is_array(self.as_ref().to_glib_none().0)) } 253 | } 254 | 255 | #[cfg(feature = "v2_38")] 256 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] 257 | #[doc(alias = "jsc_value_is_array_buffer")] 258 | fn is_array_buffer(&self) -> bool { 259 | unsafe { 260 | from_glib(ffi::jsc_value_is_array_buffer( 261 | self.as_ref().to_glib_none().0, 262 | )) 263 | } 264 | } 265 | 266 | #[doc(alias = "jsc_value_is_boolean")] 267 | fn is_boolean(&self) -> bool { 268 | unsafe { from_glib(ffi::jsc_value_is_boolean(self.as_ref().to_glib_none().0)) } 269 | } 270 | 271 | #[doc(alias = "jsc_value_is_constructor")] 272 | fn is_constructor(&self) -> bool { 273 | unsafe { 274 | from_glib(ffi::jsc_value_is_constructor( 275 | self.as_ref().to_glib_none().0, 276 | )) 277 | } 278 | } 279 | 280 | #[doc(alias = "jsc_value_is_function")] 281 | fn is_function(&self) -> bool { 282 | unsafe { from_glib(ffi::jsc_value_is_function(self.as_ref().to_glib_none().0)) } 283 | } 284 | 285 | #[doc(alias = "jsc_value_is_null")] 286 | fn is_null(&self) -> bool { 287 | unsafe { from_glib(ffi::jsc_value_is_null(self.as_ref().to_glib_none().0)) } 288 | } 289 | 290 | #[doc(alias = "jsc_value_is_number")] 291 | fn is_number(&self) -> bool { 292 | unsafe { from_glib(ffi::jsc_value_is_number(self.as_ref().to_glib_none().0)) } 293 | } 294 | 295 | #[doc(alias = "jsc_value_is_object")] 296 | fn is_object(&self) -> bool { 297 | unsafe { from_glib(ffi::jsc_value_is_object(self.as_ref().to_glib_none().0)) } 298 | } 299 | 300 | #[doc(alias = "jsc_value_is_string")] 301 | fn is_string(&self) -> bool { 302 | unsafe { from_glib(ffi::jsc_value_is_string(self.as_ref().to_glib_none().0)) } 303 | } 304 | 305 | #[cfg(feature = "v2_38")] 306 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] 307 | #[doc(alias = "jsc_value_is_typed_array")] 308 | fn is_typed_array(&self) -> bool { 309 | unsafe { 310 | from_glib(ffi::jsc_value_is_typed_array( 311 | self.as_ref().to_glib_none().0, 312 | )) 313 | } 314 | } 315 | 316 | #[doc(alias = "jsc_value_is_undefined")] 317 | fn is_undefined(&self) -> bool { 318 | unsafe { from_glib(ffi::jsc_value_is_undefined(self.as_ref().to_glib_none().0)) } 319 | } 320 | 321 | #[cfg(feature = "v2_38")] 322 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] 323 | #[doc(alias = "jsc_value_new_typed_array_with_buffer")] 324 | #[must_use] 325 | fn new_typed_array_with_buffer( 326 | &self, 327 | type_: TypedArrayType, 328 | offset: usize, 329 | length: isize, 330 | ) -> Option { 331 | unsafe { 332 | from_glib_full(ffi::jsc_value_new_typed_array_with_buffer( 333 | self.as_ref().to_glib_none().0, 334 | type_.into_glib(), 335 | offset, 336 | length, 337 | )) 338 | } 339 | } 340 | 341 | //#[doc(alias = "jsc_value_object_define_property_accessor")] 342 | //fn object_define_property_accessor(&self, property_name: &str, flags: ValuePropertyFlags, property_type: glib::types::Type, getter: Option>, setter: Option>, user_data: /*Unimplemented*/Option) { 343 | // unsafe { TODO: call ffi:jsc_value_object_define_property_accessor() } 344 | //} 345 | 346 | #[doc(alias = "jsc_value_object_define_property_data")] 347 | fn object_define_property_data( 348 | &self, 349 | property_name: &str, 350 | flags: ValuePropertyFlags, 351 | property_value: Option<&impl IsA>, 352 | ) { 353 | unsafe { 354 | ffi::jsc_value_object_define_property_data( 355 | self.as_ref().to_glib_none().0, 356 | property_name.to_glib_none().0, 357 | flags.into_glib(), 358 | property_value.map(|p| p.as_ref()).to_glib_none().0, 359 | ); 360 | } 361 | } 362 | 363 | #[doc(alias = "jsc_value_object_delete_property")] 364 | fn object_delete_property(&self, name: &str) -> bool { 365 | unsafe { 366 | from_glib(ffi::jsc_value_object_delete_property( 367 | self.as_ref().to_glib_none().0, 368 | name.to_glib_none().0, 369 | )) 370 | } 371 | } 372 | 373 | #[doc(alias = "jsc_value_object_enumerate_properties")] 374 | fn object_enumerate_properties(&self) -> Vec { 375 | unsafe { 376 | FromGlibPtrContainer::from_glib_full(ffi::jsc_value_object_enumerate_properties( 377 | self.as_ref().to_glib_none().0, 378 | )) 379 | } 380 | } 381 | 382 | #[doc(alias = "jsc_value_object_get_property")] 383 | #[must_use] 384 | fn object_get_property(&self, name: &str) -> Option { 385 | unsafe { 386 | from_glib_full(ffi::jsc_value_object_get_property( 387 | self.as_ref().to_glib_none().0, 388 | name.to_glib_none().0, 389 | )) 390 | } 391 | } 392 | 393 | #[doc(alias = "jsc_value_object_get_property_at_index")] 394 | #[must_use] 395 | fn object_get_property_at_index(&self, index: u32) -> Option { 396 | unsafe { 397 | from_glib_full(ffi::jsc_value_object_get_property_at_index( 398 | self.as_ref().to_glib_none().0, 399 | index, 400 | )) 401 | } 402 | } 403 | 404 | #[doc(alias = "jsc_value_object_has_property")] 405 | fn object_has_property(&self, name: &str) -> bool { 406 | unsafe { 407 | from_glib(ffi::jsc_value_object_has_property( 408 | self.as_ref().to_glib_none().0, 409 | name.to_glib_none().0, 410 | )) 411 | } 412 | } 413 | 414 | //#[doc(alias = "jsc_value_object_invoke_method")] 415 | //#[must_use] 416 | //fn object_invoke_method(&self, name: &str, first_parameter_type: glib::types::Type, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> Option { 417 | // unsafe { TODO: call ffi:jsc_value_object_invoke_method() } 418 | //} 419 | 420 | #[doc(alias = "jsc_value_object_invoke_methodv")] 421 | #[must_use] 422 | fn object_invoke_methodv(&self, name: &str, parameters: &[Value]) -> Option { 423 | let n_parameters = parameters.len() as _; 424 | unsafe { 425 | from_glib_full(ffi::jsc_value_object_invoke_methodv( 426 | self.as_ref().to_glib_none().0, 427 | name.to_glib_none().0, 428 | n_parameters, 429 | parameters.to_glib_none().0, 430 | )) 431 | } 432 | } 433 | 434 | #[doc(alias = "jsc_value_object_is_instance_of")] 435 | fn object_is_instance_of(&self, name: &str) -> bool { 436 | unsafe { 437 | from_glib(ffi::jsc_value_object_is_instance_of( 438 | self.as_ref().to_glib_none().0, 439 | name.to_glib_none().0, 440 | )) 441 | } 442 | } 443 | 444 | #[doc(alias = "jsc_value_object_set_property")] 445 | fn object_set_property(&self, name: &str, property: &impl IsA) { 446 | unsafe { 447 | ffi::jsc_value_object_set_property( 448 | self.as_ref().to_glib_none().0, 449 | name.to_glib_none().0, 450 | property.as_ref().to_glib_none().0, 451 | ); 452 | } 453 | } 454 | 455 | #[doc(alias = "jsc_value_object_set_property_at_index")] 456 | fn object_set_property_at_index(&self, index: u32, property: &impl IsA) { 457 | unsafe { 458 | ffi::jsc_value_object_set_property_at_index( 459 | self.as_ref().to_glib_none().0, 460 | index, 461 | property.as_ref().to_glib_none().0, 462 | ); 463 | } 464 | } 465 | 466 | #[doc(alias = "jsc_value_to_boolean")] 467 | fn to_boolean(&self) -> bool { 468 | unsafe { from_glib(ffi::jsc_value_to_boolean(self.as_ref().to_glib_none().0)) } 469 | } 470 | 471 | #[doc(alias = "jsc_value_to_double")] 472 | fn to_double(&self) -> f64 { 473 | unsafe { ffi::jsc_value_to_double(self.as_ref().to_glib_none().0) } 474 | } 475 | 476 | #[doc(alias = "jsc_value_to_int32")] 477 | fn to_int32(&self) -> i32 { 478 | unsafe { ffi::jsc_value_to_int32(self.as_ref().to_glib_none().0) } 479 | } 480 | 481 | #[cfg(feature = "v2_28")] 482 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_28")))] 483 | #[doc(alias = "jsc_value_to_json")] 484 | fn to_json(&self, indent: u32) -> Option { 485 | unsafe { 486 | from_glib_full(ffi::jsc_value_to_json( 487 | self.as_ref().to_glib_none().0, 488 | indent, 489 | )) 490 | } 491 | } 492 | 493 | #[doc(alias = "jsc_value_to_string")] 494 | #[doc(alias = "to_string")] 495 | fn to_str(&self) -> glib::GString { 496 | unsafe { from_glib_full(ffi::jsc_value_to_string(self.as_ref().to_glib_none().0)) } 497 | } 498 | 499 | #[doc(alias = "jsc_value_to_string_as_bytes")] 500 | fn to_string_as_bytes(&self) -> Option { 501 | unsafe { 502 | from_glib_full(ffi::jsc_value_to_string_as_bytes( 503 | self.as_ref().to_glib_none().0, 504 | )) 505 | } 506 | } 507 | 508 | #[cfg(feature = "v2_38")] 509 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] 510 | #[doc(alias = "jsc_value_typed_array_get_buffer")] 511 | #[must_use] 512 | fn typed_array_get_buffer(&self) -> Option { 513 | unsafe { 514 | from_glib_full(ffi::jsc_value_typed_array_get_buffer( 515 | self.as_ref().to_glib_none().0, 516 | )) 517 | } 518 | } 519 | 520 | #[cfg(feature = "v2_38")] 521 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] 522 | #[doc(alias = "jsc_value_typed_array_get_length")] 523 | fn typed_array_get_length(&self) -> usize { 524 | unsafe { ffi::jsc_value_typed_array_get_length(self.as_ref().to_glib_none().0) } 525 | } 526 | 527 | #[cfg(feature = "v2_38")] 528 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] 529 | #[doc(alias = "jsc_value_typed_array_get_offset")] 530 | fn typed_array_get_offset(&self) -> usize { 531 | unsafe { ffi::jsc_value_typed_array_get_offset(self.as_ref().to_glib_none().0) } 532 | } 533 | 534 | #[cfg(feature = "v2_38")] 535 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] 536 | #[doc(alias = "jsc_value_typed_array_get_size")] 537 | fn typed_array_get_size(&self) -> usize { 538 | unsafe { ffi::jsc_value_typed_array_get_size(self.as_ref().to_glib_none().0) } 539 | } 540 | 541 | #[cfg(feature = "v2_38")] 542 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] 543 | #[doc(alias = "jsc_value_typed_array_get_type")] 544 | fn typed_array_get_type(&self) -> TypedArrayType { 545 | unsafe { 546 | from_glib(ffi::jsc_value_typed_array_get_type( 547 | self.as_ref().to_glib_none().0, 548 | )) 549 | } 550 | } 551 | } 552 | 553 | impl> ValueExt for O {} 554 | -------------------------------------------------------------------------------- /src/auto/versions.txt: -------------------------------------------------------------------------------- 1 | Generated by gir (https://github.com/gtk-rs/gir @ 73df75128d55) 2 | from gir-files (https://github.com/tauri-apps/gir-files @ 8be196040235) 3 | -------------------------------------------------------------------------------- /src/auto/virtual_machine.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/tauri-apps/gir-files) 3 | // DO NOT EDIT 4 | 5 | use glib::translate::*; 6 | 7 | glib::wrapper! { 8 | #[doc(alias = "JSCVirtualMachine")] 9 | pub struct VirtualMachine(Object); 10 | 11 | match fn { 12 | type_ => || ffi::jsc_virtual_machine_get_type(), 13 | } 14 | } 15 | 16 | impl VirtualMachine { 17 | pub const NONE: Option<&'static VirtualMachine> = None; 18 | 19 | #[doc(alias = "jsc_virtual_machine_new")] 20 | pub fn new() -> VirtualMachine { 21 | unsafe { from_glib_full(ffi::jsc_virtual_machine_new()) } 22 | } 23 | } 24 | 25 | impl Default for VirtualMachine { 26 | fn default() -> Self { 27 | Self::new() 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/auto/weak_value.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/tauri-apps/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::Value; 6 | use glib::{ 7 | prelude::*, 8 | signal::{connect_raw, SignalHandlerId}, 9 | translate::*, 10 | }; 11 | use std::boxed::Box as Box_; 12 | 13 | glib::wrapper! { 14 | #[doc(alias = "JSCWeakValue")] 15 | pub struct WeakValue(Object); 16 | 17 | match fn { 18 | type_ => || ffi::jsc_weak_value_get_type(), 19 | } 20 | } 21 | 22 | impl WeakValue { 23 | pub const NONE: Option<&'static WeakValue> = None; 24 | 25 | #[doc(alias = "jsc_weak_value_new")] 26 | pub fn new(value: &impl IsA) -> WeakValue { 27 | unsafe { from_glib_full(ffi::jsc_weak_value_new(value.as_ref().to_glib_none().0)) } 28 | } 29 | 30 | // rustdoc-stripper-ignore-next 31 | /// Creates a new builder-pattern struct instance to construct [`WeakValue`] objects. 32 | /// 33 | /// This method returns an instance of [`WeakValueBuilder`](crate::builders::WeakValueBuilder) which can be used to create [`WeakValue`] objects. 34 | pub fn builder() -> WeakValueBuilder { 35 | WeakValueBuilder::new() 36 | } 37 | } 38 | 39 | impl Default for WeakValue { 40 | fn default() -> Self { 41 | glib::object::Object::new::() 42 | } 43 | } 44 | 45 | // rustdoc-stripper-ignore-next 46 | /// A [builder-pattern] type to construct [`WeakValue`] objects. 47 | /// 48 | /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html 49 | #[must_use = "The builder must be built to be used"] 50 | pub struct WeakValueBuilder { 51 | builder: glib::object::ObjectBuilder<'static, WeakValue>, 52 | } 53 | 54 | impl WeakValueBuilder { 55 | fn new() -> Self { 56 | Self { 57 | builder: glib::object::Object::builder(), 58 | } 59 | } 60 | 61 | pub fn value(self, value: &impl IsA) -> Self { 62 | Self { 63 | builder: self.builder.property("value", value.clone().upcast()), 64 | } 65 | } 66 | 67 | // rustdoc-stripper-ignore-next 68 | /// Build the [`WeakValue`]. 69 | #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] 70 | pub fn build(self) -> WeakValue { 71 | self.builder.build() 72 | } 73 | } 74 | 75 | mod sealed { 76 | pub trait Sealed {} 77 | impl> Sealed for T {} 78 | } 79 | 80 | pub trait WeakValueExt: IsA + sealed::Sealed + 'static { 81 | #[doc(alias = "jsc_weak_value_get_value")] 82 | #[doc(alias = "get_value")] 83 | fn value(&self) -> Option { 84 | unsafe { 85 | from_glib_full(ffi::jsc_weak_value_get_value( 86 | self.as_ref().to_glib_none().0, 87 | )) 88 | } 89 | } 90 | 91 | #[doc(alias = "cleared")] 92 | fn connect_cleared(&self, f: F) -> SignalHandlerId { 93 | unsafe extern "C" fn cleared_trampoline, F: Fn(&P) + 'static>( 94 | this: *mut ffi::JSCWeakValue, 95 | f: glib::ffi::gpointer, 96 | ) { 97 | let f: &F = &*(f as *const F); 98 | f(WeakValue::from_glib_borrow(this).unsafe_cast_ref()) 99 | } 100 | unsafe { 101 | let f: Box_ = Box_::new(f); 102 | connect_raw( 103 | self.as_ptr() as *mut _, 104 | b"cleared\0".as_ptr() as *const _, 105 | Some(std::mem::transmute::<_, unsafe extern "C" fn()>( 106 | cleared_trampoline:: as *const (), 107 | )), 108 | Box_::into_raw(f), 109 | ) 110 | } 111 | } 112 | } 113 | 114 | impl> WeakValueExt for O {} 115 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | // // Copyright 2013-2017, The Gtk-rs Project Developers. 2 | // // See the COPYRIGHT file at the top-level directory of this distribution. 3 | // // Licensed under the MIT license, see the LICENSE file or 4 | #![cfg_attr(docsrs, feature(doc_cfg))] 5 | 6 | mod auto; 7 | pub use auto::{traits::*, *}; 8 | 9 | mod value; 10 | pub use value::*; 11 | -------------------------------------------------------------------------------- /src/value.rs: -------------------------------------------------------------------------------- 1 | use crate::Context; 2 | use crate::Value; 3 | use crate::ValueExt; 4 | use glib::ffi::GBytes; 5 | use glib::object::IsA; 6 | use glib::translate::*; 7 | use std::ffi::c_void; 8 | use std::slice; 9 | 10 | impl Value { 11 | #[cfg(any(feature = "v2_38", docsrs))] 12 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] 13 | #[doc(alias = "jsc_value_new_array_buffer")] 14 | pub fn new_array_buffer(context: &impl IsA, data: glib::Bytes) -> Option { 15 | let len = data.len(); 16 | let ptr: *mut GBytes = data.to_glib_full(); 17 | 18 | unsafe extern "C" fn destroy_notify(user_data: *mut c_void) { 19 | let data: glib::Bytes = from_glib_full(user_data as *mut GBytes); 20 | drop(data); 21 | } 22 | 23 | unsafe { 24 | from_glib_full(ffi::jsc_value_new_array_buffer( 25 | context.as_ref().to_glib_none().0, 26 | ptr as _, 27 | len, 28 | Some(destroy_notify), 29 | ptr as _, 30 | )) 31 | } 32 | } 33 | } 34 | 35 | pub trait ValueExtManual: 'static { 36 | #[cfg(any(feature = "v2_38", docsrs))] 37 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] 38 | #[doc(alias = "jsc_value_array_buffer_get_data")] 39 | fn array_buffer_get_data(&self) -> &[u8]; 40 | 41 | #[cfg(any(feature = "v2_38", docsrs))] 42 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] 43 | #[doc(alias = "jsc_value_typed_array_get_data")] 44 | fn typed_array_get_data(&self) -> TypedArrayData; 45 | } 46 | 47 | impl> ValueExtManual for O { 48 | #[cfg(any(feature = "v2_38", docsrs))] 49 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] 50 | fn array_buffer_get_data(&self) -> &[u8] { 51 | unsafe { 52 | let mut len = 0; 53 | let ptr = ffi::jsc_value_array_buffer_get_data(self.as_ref().to_glib_none().0, &mut len); 54 | if ptr.is_null() || len == 0 { 55 | &[] 56 | } else { 57 | slice::from_raw_parts(ptr as *const u8, len) 58 | } 59 | } 60 | } 61 | 62 | #[cfg(any(feature = "v2_38", docsrs))] 63 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] 64 | fn typed_array_get_data(&self) -> TypedArrayData { 65 | use crate::TypedArrayType::*; 66 | unsafe { 67 | let mut len = 0; 68 | let ptr = ffi::jsc_value_typed_array_get_data(self.as_ref().to_glib_none().0, &mut len); 69 | if ptr.is_null() || len == 0 { 70 | TypedArrayData::None 71 | } else { 72 | match self.typed_array_get_type() { 73 | None => TypedArrayData::None, 74 | Int8 => TypedArrayData::Int8(slice::from_raw_parts(ptr as *const i8, len)), 75 | Int16 => TypedArrayData::Int16(slice::from_raw_parts(ptr as *const i16, len)), 76 | Int32 => TypedArrayData::Int32(slice::from_raw_parts(ptr as *const i32, len)), 77 | Int64 => TypedArrayData::Int64(slice::from_raw_parts(ptr as *const i64, len)), 78 | Uint8 => TypedArrayData::Uint8(slice::from_raw_parts(ptr as *const u8, len)), 79 | Uint8Clamped => { 80 | TypedArrayData::Uint8Clamped(slice::from_raw_parts(ptr as *const u8, len)) 81 | } 82 | Uint16 => TypedArrayData::Uint16(slice::from_raw_parts(ptr as *const u16, len)), 83 | Uint32 => TypedArrayData::Uint32(slice::from_raw_parts(ptr as *const u32, len)), 84 | Uint64 => TypedArrayData::Uint64(slice::from_raw_parts(ptr as *const u64, len)), 85 | Float32 => TypedArrayData::Float32(slice::from_raw_parts(ptr as *const f32, len)), 86 | Float64 => TypedArrayData::Float64(slice::from_raw_parts(ptr as *const f64, len)), 87 | __Unknown(_) => TypedArrayData::None, 88 | } 89 | } 90 | } 91 | } 92 | } 93 | 94 | #[cfg(any(feature = "v2_38", docsrs))] 95 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] 96 | #[derive(Debug, Clone, Copy)] 97 | #[non_exhaustive] 98 | pub enum TypedArrayData<'a> { 99 | #[doc(alias = "JSC_TYPED_ARRAY_NONE")] 100 | None, 101 | #[doc(alias = "JSC_TYPED_ARRAY_INT8")] 102 | Int8(&'a [i8]), 103 | #[doc(alias = "JSC_TYPED_ARRAY_INT16")] 104 | Int16(&'a [i16]), 105 | #[doc(alias = "JSC_TYPED_ARRAY_INT32")] 106 | Int32(&'a [i32]), 107 | #[doc(alias = "JSC_TYPED_ARRAY_INT64")] 108 | Int64(&'a [i64]), 109 | #[doc(alias = "JSC_TYPED_ARRAY_UINT8")] 110 | Uint8(&'a [u8]), 111 | #[doc(alias = "JSC_TYPED_ARRAY_UINT8_CLAMPED")] 112 | Uint8Clamped(&'a [u8]), 113 | #[doc(alias = "JSC_TYPED_ARRAY_UINT16")] 114 | Uint16(&'a [u16]), 115 | #[doc(alias = "JSC_TYPED_ARRAY_UINT32")] 116 | Uint32(&'a [u32]), 117 | #[doc(alias = "JSC_TYPED_ARRAY_UINT64")] 118 | Uint64(&'a [u64]), 119 | #[doc(alias = "JSC_TYPED_ARRAY_FLOAT32")] 120 | Float32(&'a [f32]), 121 | #[doc(alias = "JSC_TYPED_ARRAY_FLOAT64")] 122 | Float64(&'a [f64]), 123 | } 124 | -------------------------------------------------------------------------------- /sys/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## \[1.1.1] 4 | 5 | - [`4e6b9f4`](https://github.com/tauri-apps/javascriptcore-rs/commit/4e6b9f41121a2b6cbcda6f320e50921829232dc1) Properly replace dox with docsrs to fix docs.rs building. 6 | 7 | ## \[1.1.0] 8 | 9 | - [`0ed9caf`](https://github.com/tauri-apps/javascriptcore-rs/commit/0ed9caf1da825bfe25fe9d7e1be7dd1f87422982) Update to gtk 0.18. 10 | Increase MSRV to 1.70.0 11 | 12 | ## \[1.0.0] 13 | 14 | - Cleanup codebase and bump to major. 15 | - [ae6b74e](https://github.com/tauri-apps/javascriptcore-rs/commit/ae6b74eb8161d46739334b8b4e25719c563a8da9) Add change file on 2023-04-03 16 | 17 | ## \[0.5.1] 18 | 19 | - Update link library to javascriptcoregtk-4.1. 20 | - [371ffa6](https://github.com/tauri-apps/javascriptcore-rs/commit/371ffa6a9946a4ff7903a4896bf68a0c7fe91bdc) Update link to javascriptcoregtk-4.1 on 2023-01-26 21 | 22 | ## \[0.5.0] 23 | 24 | - Update gtk crates to 0.16 and update to 2021 edition. 25 | - [1674d07](https://github.com/tauri-apps/javascriptcore-rs/commit/1674d0716c4e76705ce958fc8c464bb9cb4e9320) Add change file on 2022-11-26 26 | 27 | ## \[0.4.0] 28 | 29 | - Update to gtk 0.15 30 | - [4aa6f17](https://github.com/tauri-apps/javascriptcore-rs/commit/4aa6f1758343f50cc7f7af42ac903077349b8051) Update to gtk 0.15 on 2022-01-18 31 | 32 | ## \[0.3.3] 33 | 34 | - Regenerate with latest gir-files 35 | - [68fa7e5](https://github.com/tauri-apps/javascriptcore-rs/commit/68fa7e5f12110ac47c07afaaeebfeb7067dfca21) Add change file on 2021-11-04 36 | 37 | ## \[0.3.1] 38 | 39 | - Update url in Cargo.toml. 40 | - [02b8c18](https://github.com/tauri-apps/javascriptcore-rs/commit/02b8c1829ca828866df8965b0c904372ba335960) Update url in Cargo.toml of sys crate on 2021-10-25 41 | 42 | ## \[0.3.0] 43 | 44 | - Update Gir files 45 | - [3262e96](https://github.com/tauri-apps/javascriptcore-rs/commit/3262e96efc1cd6a640b81368255f3ae9325b2170) Bump version on 2021-10-04 46 | -------------------------------------------------------------------------------- /sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = [ "The Gtk-rs Project Developers" ] 3 | build = "build.rs" 4 | description = "Sys functions for the Rust bindings of the javacriptcore library" 5 | edition = "2021" 6 | keywords = [ "javascript", "gtk-rs", "gnome" ] 7 | license = "MIT" 8 | name = "javascriptcore-rs-sys" 9 | repository = "https://github.com/tauri-apps/javascriptcore-rs" 10 | version = "1.1.1" 11 | 12 | [package.metadata.system-deps.javascriptcoregtk_4_1] 13 | name = "javascriptcoregtk-4.1" 14 | version = "2.24" 15 | 16 | [package.metadata.system-deps.javascriptcoregtk_4_1.v2_28] 17 | version = "2.28" 18 | 19 | [package.metadata.system-deps.javascriptcoregtk_4_1.v2_38] 20 | version = "2.38" 21 | 22 | [package.metadata.docs.rs] 23 | rustc-args = [ "--cfg", "docsrs" ] 24 | rustdoc-args = [ "--cfg", "docsrs", "--generate-link-to-definition" ] 25 | all-features = true 26 | 27 | [lib] 28 | name = "javascriptcore_rs_sys" 29 | 30 | [dependencies] 31 | libc = "0.2" 32 | 33 | [dependencies.glib] 34 | package = "glib-sys" 35 | version = "^0.18" 36 | 37 | [dependencies.gobject] 38 | package = "gobject-sys" 39 | version = "^0.18" 40 | 41 | [build-dependencies] 42 | system-deps = "6" 43 | 44 | [dev-dependencies] 45 | shell-words = "1.0.0" 46 | tempfile = "3" 47 | 48 | [features] 49 | v2_28 = [ ] 50 | v2_38 = [ "v2_28" ] 51 | -------------------------------------------------------------------------------- /sys/Gir.toml: -------------------------------------------------------------------------------- 1 | [options] 2 | library = "JavaScriptCore" 3 | version = "4.1" 4 | target_path = "." 5 | min_cfg_version = "2.24" 6 | work_mode = "sys" 7 | girs_directories = [ "../gir-files/" ] 8 | 9 | external_libraries = [ 10 | "GLib", 11 | "GObject", 12 | ] 13 | -------------------------------------------------------------------------------- /sys/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013-2017, The Gtk-rs Project Developers. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /sys/build.rs: -------------------------------------------------------------------------------- 1 | // Generated by gir (https://github.com/gtk-rs/gir @ 73df75128d55) 2 | // from ../gir-files (@ 8be196040235) 3 | // DO NOT EDIT 4 | 5 | #[cfg(not(docsrs))] 6 | use std::process; 7 | 8 | #[cfg(docsrs)] 9 | fn main() {} // prevent linking libraries to avoid documentation failure 10 | 11 | #[cfg(not(docsrs))] 12 | fn main() { 13 | if let Err(s) = system_deps::Config::new().probe() { 14 | println!("cargo:warning={s}"); 15 | process::exit(1); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /sys/src/lib.rs: -------------------------------------------------------------------------------- 1 | // Generated by gir (https://github.com/gtk-rs/gir @ 73df75128d55) 2 | // from ../gir-files (@ 8be196040235) 3 | // DO NOT EDIT 4 | 5 | #![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)] 6 | #![allow( 7 | clippy::approx_constant, 8 | clippy::type_complexity, 9 | clippy::unreadable_literal, 10 | clippy::upper_case_acronyms 11 | )] 12 | #![cfg_attr(docsrs, feature(doc_cfg))] 13 | 14 | #[allow(unused_imports)] 15 | use libc::{ 16 | c_char, c_double, c_float, c_int, c_long, c_short, c_uchar, c_uint, c_ulong, c_ushort, c_void, 17 | intptr_t, size_t, ssize_t, uintptr_t, FILE, 18 | }; 19 | 20 | #[allow(unused_imports)] 21 | use glib::{gboolean, gconstpointer, gpointer, GType}; 22 | 23 | // Enums 24 | pub type JSCCheckSyntaxMode = c_int; 25 | pub const JSC_CHECK_SYNTAX_MODE_SCRIPT: JSCCheckSyntaxMode = 0; 26 | pub const JSC_CHECK_SYNTAX_MODE_MODULE: JSCCheckSyntaxMode = 1; 27 | 28 | pub type JSCCheckSyntaxResult = c_int; 29 | pub const JSC_CHECK_SYNTAX_RESULT_SUCCESS: JSCCheckSyntaxResult = 0; 30 | pub const JSC_CHECK_SYNTAX_RESULT_RECOVERABLE_ERROR: JSCCheckSyntaxResult = 1; 31 | pub const JSC_CHECK_SYNTAX_RESULT_IRRECOVERABLE_ERROR: JSCCheckSyntaxResult = 2; 32 | pub const JSC_CHECK_SYNTAX_RESULT_UNTERMINATED_LITERAL_ERROR: JSCCheckSyntaxResult = 3; 33 | pub const JSC_CHECK_SYNTAX_RESULT_OUT_OF_MEMORY_ERROR: JSCCheckSyntaxResult = 4; 34 | pub const JSC_CHECK_SYNTAX_RESULT_STACK_OVERFLOW_ERROR: JSCCheckSyntaxResult = 5; 35 | 36 | pub type JSCOptionType = c_int; 37 | pub const JSC_OPTION_BOOLEAN: JSCOptionType = 0; 38 | pub const JSC_OPTION_INT: JSCOptionType = 1; 39 | pub const JSC_OPTION_UINT: JSCOptionType = 2; 40 | pub const JSC_OPTION_SIZE: JSCOptionType = 3; 41 | pub const JSC_OPTION_DOUBLE: JSCOptionType = 4; 42 | pub const JSC_OPTION_STRING: JSCOptionType = 5; 43 | pub const JSC_OPTION_RANGE_STRING: JSCOptionType = 6; 44 | 45 | pub type JSCTypedArrayType = c_int; 46 | pub const JSC_TYPED_ARRAY_NONE: JSCTypedArrayType = 0; 47 | pub const JSC_TYPED_ARRAY_INT8: JSCTypedArrayType = 1; 48 | pub const JSC_TYPED_ARRAY_INT16: JSCTypedArrayType = 2; 49 | pub const JSC_TYPED_ARRAY_INT32: JSCTypedArrayType = 3; 50 | pub const JSC_TYPED_ARRAY_INT64: JSCTypedArrayType = 4; 51 | pub const JSC_TYPED_ARRAY_UINT8: JSCTypedArrayType = 5; 52 | pub const JSC_TYPED_ARRAY_UINT8_CLAMPED: JSCTypedArrayType = 6; 53 | pub const JSC_TYPED_ARRAY_UINT16: JSCTypedArrayType = 7; 54 | pub const JSC_TYPED_ARRAY_UINT32: JSCTypedArrayType = 8; 55 | pub const JSC_TYPED_ARRAY_UINT64: JSCTypedArrayType = 9; 56 | pub const JSC_TYPED_ARRAY_FLOAT32: JSCTypedArrayType = 10; 57 | pub const JSC_TYPED_ARRAY_FLOAT64: JSCTypedArrayType = 11; 58 | 59 | // Constants 60 | pub const JSC_MAJOR_VERSION: c_int = 2; 61 | pub const JSC_MICRO_VERSION: c_int = 1; 62 | pub const JSC_MINOR_VERSION: c_int = 38; 63 | pub const JSC_OPTIONS_USE_DFG: &[u8] = b"useDFGJIT\0"; 64 | pub const JSC_OPTIONS_USE_FTL: &[u8] = b"useFTLJIT\0"; 65 | pub const JSC_OPTIONS_USE_JIT: &[u8] = b"useJIT\0"; 66 | pub const JSC_OPTIONS_USE_LLINT: &[u8] = b"useLLInt\0"; 67 | 68 | // Flags 69 | pub type JSCValuePropertyFlags = c_uint; 70 | pub const JSC_VALUE_PROPERTY_CONFIGURABLE: JSCValuePropertyFlags = 1; 71 | pub const JSC_VALUE_PROPERTY_ENUMERABLE: JSCValuePropertyFlags = 2; 72 | pub const JSC_VALUE_PROPERTY_WRITABLE: JSCValuePropertyFlags = 4; 73 | 74 | // Callbacks 75 | pub type JSCClassDeletePropertyFunction = 76 | Option gboolean>; 77 | pub type JSCClassEnumeratePropertiesFunction = 78 | Option *mut *mut c_char>; 79 | pub type JSCClassGetPropertyFunction = Option< 80 | unsafe extern "C" fn(*mut JSCClass, *mut JSCContext, gpointer, *const c_char) -> *mut JSCValue, 81 | >; 82 | pub type JSCClassHasPropertyFunction = 83 | Option gboolean>; 84 | pub type JSCClassSetPropertyFunction = Option< 85 | unsafe extern "C" fn( 86 | *mut JSCClass, 87 | *mut JSCContext, 88 | gpointer, 89 | *const c_char, 90 | *mut JSCValue, 91 | ) -> gboolean, 92 | >; 93 | pub type JSCExceptionHandler = 94 | Option; 95 | pub type JSCOptionsFunc = 96 | Option gboolean>; 97 | 98 | // Records 99 | #[repr(C)] 100 | pub struct _JSCClassClass { 101 | _data: [u8; 0], 102 | _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, 103 | } 104 | 105 | pub type JSCClassClass = *mut _JSCClassClass; 106 | 107 | #[derive(Copy, Clone)] 108 | #[repr(C)] 109 | pub struct JSCClassVTable { 110 | pub get_property: JSCClassGetPropertyFunction, 111 | pub set_property: JSCClassSetPropertyFunction, 112 | pub has_property: JSCClassHasPropertyFunction, 113 | pub delete_property: JSCClassDeletePropertyFunction, 114 | pub enumerate_properties: JSCClassEnumeratePropertiesFunction, 115 | pub _jsc_reserved0: Option, 116 | pub _jsc_reserved1: Option, 117 | pub _jsc_reserved2: Option, 118 | pub _jsc_reserved3: Option, 119 | } 120 | 121 | impl ::std::fmt::Debug for JSCClassVTable { 122 | fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { 123 | f.debug_struct(&format!("JSCClassVTable @ {self:p}")) 124 | .field("get_property", &self.get_property) 125 | .field("set_property", &self.set_property) 126 | .field("has_property", &self.has_property) 127 | .field("delete_property", &self.delete_property) 128 | .field("enumerate_properties", &self.enumerate_properties) 129 | .field("_jsc_reserved0", &self._jsc_reserved0) 130 | .field("_jsc_reserved1", &self._jsc_reserved1) 131 | .field("_jsc_reserved2", &self._jsc_reserved2) 132 | .field("_jsc_reserved3", &self._jsc_reserved3) 133 | .finish() 134 | } 135 | } 136 | 137 | #[derive(Copy, Clone)] 138 | #[repr(C)] 139 | pub struct JSCContextClass { 140 | pub parent_class: gobject::GObjectClass, 141 | pub _jsc_reserved0: Option, 142 | pub _jsc_reserved1: Option, 143 | pub _jsc_reserved2: Option, 144 | pub _jsc_reserved3: Option, 145 | } 146 | 147 | impl ::std::fmt::Debug for JSCContextClass { 148 | fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { 149 | f.debug_struct(&format!("JSCContextClass @ {self:p}")) 150 | .field("parent_class", &self.parent_class) 151 | .field("_jsc_reserved0", &self._jsc_reserved0) 152 | .field("_jsc_reserved1", &self._jsc_reserved1) 153 | .field("_jsc_reserved2", &self._jsc_reserved2) 154 | .field("_jsc_reserved3", &self._jsc_reserved3) 155 | .finish() 156 | } 157 | } 158 | 159 | #[repr(C)] 160 | pub struct _JSCContextPrivate { 161 | _data: [u8; 0], 162 | _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, 163 | } 164 | 165 | pub type JSCContextPrivate = *mut _JSCContextPrivate; 166 | 167 | #[derive(Copy, Clone)] 168 | #[repr(C)] 169 | pub struct JSCExceptionClass { 170 | pub parent_class: gobject::GObjectClass, 171 | pub _jsc_reserved0: Option, 172 | pub _jsc_reserved1: Option, 173 | pub _jsc_reserved2: Option, 174 | pub _jsc_reserved3: Option, 175 | } 176 | 177 | impl ::std::fmt::Debug for JSCExceptionClass { 178 | fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { 179 | f.debug_struct(&format!("JSCExceptionClass @ {self:p}")) 180 | .field("parent_class", &self.parent_class) 181 | .field("_jsc_reserved0", &self._jsc_reserved0) 182 | .field("_jsc_reserved1", &self._jsc_reserved1) 183 | .field("_jsc_reserved2", &self._jsc_reserved2) 184 | .field("_jsc_reserved3", &self._jsc_reserved3) 185 | .finish() 186 | } 187 | } 188 | 189 | #[repr(C)] 190 | pub struct _JSCExceptionPrivate { 191 | _data: [u8; 0], 192 | _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, 193 | } 194 | 195 | pub type JSCExceptionPrivate = *mut _JSCExceptionPrivate; 196 | 197 | #[derive(Copy, Clone)] 198 | #[repr(C)] 199 | pub struct JSCValueClass { 200 | pub parent_class: gobject::GObjectClass, 201 | pub _jsc_reserved0: Option, 202 | pub _jsc_reserved1: Option, 203 | pub _jsc_reserved2: Option, 204 | pub _jsc_reserved3: Option, 205 | } 206 | 207 | impl ::std::fmt::Debug for JSCValueClass { 208 | fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { 209 | f.debug_struct(&format!("JSCValueClass @ {self:p}")) 210 | .field("parent_class", &self.parent_class) 211 | .field("_jsc_reserved0", &self._jsc_reserved0) 212 | .field("_jsc_reserved1", &self._jsc_reserved1) 213 | .field("_jsc_reserved2", &self._jsc_reserved2) 214 | .field("_jsc_reserved3", &self._jsc_reserved3) 215 | .finish() 216 | } 217 | } 218 | 219 | #[repr(C)] 220 | pub struct _JSCValuePrivate { 221 | _data: [u8; 0], 222 | _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, 223 | } 224 | 225 | pub type JSCValuePrivate = *mut _JSCValuePrivate; 226 | 227 | #[derive(Copy, Clone)] 228 | #[repr(C)] 229 | pub struct JSCVirtualMachineClass { 230 | pub parent_class: gobject::GObjectClass, 231 | pub _jsc_reserved0: Option, 232 | pub _jsc_reserved1: Option, 233 | pub _jsc_reserved2: Option, 234 | pub _jsc_reserved3: Option, 235 | } 236 | 237 | impl ::std::fmt::Debug for JSCVirtualMachineClass { 238 | fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { 239 | f.debug_struct(&format!("JSCVirtualMachineClass @ {self:p}")) 240 | .field("parent_class", &self.parent_class) 241 | .field("_jsc_reserved0", &self._jsc_reserved0) 242 | .field("_jsc_reserved1", &self._jsc_reserved1) 243 | .field("_jsc_reserved2", &self._jsc_reserved2) 244 | .field("_jsc_reserved3", &self._jsc_reserved3) 245 | .finish() 246 | } 247 | } 248 | 249 | #[repr(C)] 250 | pub struct _JSCVirtualMachinePrivate { 251 | _data: [u8; 0], 252 | _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, 253 | } 254 | 255 | pub type JSCVirtualMachinePrivate = *mut _JSCVirtualMachinePrivate; 256 | 257 | #[derive(Copy, Clone)] 258 | #[repr(C)] 259 | pub struct JSCWeakValueClass { 260 | pub parent_class: gobject::GObjectClass, 261 | pub _jsc_reserved0: Option, 262 | pub _jsc_reserved1: Option, 263 | pub _jsc_reserved2: Option, 264 | pub _jsc_reserved3: Option, 265 | } 266 | 267 | impl ::std::fmt::Debug for JSCWeakValueClass { 268 | fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { 269 | f.debug_struct(&format!("JSCWeakValueClass @ {self:p}")) 270 | .field("parent_class", &self.parent_class) 271 | .field("_jsc_reserved0", &self._jsc_reserved0) 272 | .field("_jsc_reserved1", &self._jsc_reserved1) 273 | .field("_jsc_reserved2", &self._jsc_reserved2) 274 | .field("_jsc_reserved3", &self._jsc_reserved3) 275 | .finish() 276 | } 277 | } 278 | 279 | #[repr(C)] 280 | pub struct _JSCWeakValuePrivate { 281 | _data: [u8; 0], 282 | _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, 283 | } 284 | 285 | pub type JSCWeakValuePrivate = *mut _JSCWeakValuePrivate; 286 | 287 | // Classes 288 | #[repr(C)] 289 | pub struct JSCClass { 290 | _data: [u8; 0], 291 | _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, 292 | } 293 | 294 | impl ::std::fmt::Debug for JSCClass { 295 | fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { 296 | f.debug_struct(&format!("JSCClass @ {self:p}")).finish() 297 | } 298 | } 299 | 300 | #[derive(Copy, Clone)] 301 | #[repr(C)] 302 | pub struct JSCContext { 303 | pub parent: gobject::GObject, 304 | pub priv_: *mut JSCContextPrivate, 305 | } 306 | 307 | impl ::std::fmt::Debug for JSCContext { 308 | fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { 309 | f.debug_struct(&format!("JSCContext @ {self:p}")) 310 | .field("parent", &self.parent) 311 | .finish() 312 | } 313 | } 314 | 315 | #[derive(Copy, Clone)] 316 | #[repr(C)] 317 | pub struct JSCException { 318 | pub parent: gobject::GObject, 319 | pub priv_: *mut JSCExceptionPrivate, 320 | } 321 | 322 | impl ::std::fmt::Debug for JSCException { 323 | fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { 324 | f.debug_struct(&format!("JSCException @ {self:p}")) 325 | .field("parent", &self.parent) 326 | .finish() 327 | } 328 | } 329 | 330 | #[derive(Copy, Clone)] 331 | #[repr(C)] 332 | pub struct JSCValue { 333 | pub parent: gobject::GObject, 334 | pub priv_: *mut JSCValuePrivate, 335 | } 336 | 337 | impl ::std::fmt::Debug for JSCValue { 338 | fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { 339 | f.debug_struct(&format!("JSCValue @ {self:p}")) 340 | .field("parent", &self.parent) 341 | .finish() 342 | } 343 | } 344 | 345 | #[derive(Copy, Clone)] 346 | #[repr(C)] 347 | pub struct JSCVirtualMachine { 348 | pub parent: gobject::GObject, 349 | pub priv_: *mut JSCVirtualMachinePrivate, 350 | } 351 | 352 | impl ::std::fmt::Debug for JSCVirtualMachine { 353 | fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { 354 | f.debug_struct(&format!("JSCVirtualMachine @ {self:p}")) 355 | .field("parent", &self.parent) 356 | .finish() 357 | } 358 | } 359 | 360 | #[derive(Copy, Clone)] 361 | #[repr(C)] 362 | pub struct JSCWeakValue { 363 | pub parent: gobject::GObject, 364 | pub priv_: *mut JSCWeakValuePrivate, 365 | } 366 | 367 | impl ::std::fmt::Debug for JSCWeakValue { 368 | fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { 369 | f.debug_struct(&format!("JSCWeakValue @ {self:p}")) 370 | .field("parent", &self.parent) 371 | .finish() 372 | } 373 | } 374 | 375 | #[link(name = "javascriptcoregtk-4.1")] 376 | extern "C" { 377 | 378 | //========================================================================= 379 | // JSCClass 380 | //========================================================================= 381 | pub fn jsc_class_get_type() -> GType; 382 | pub fn jsc_class_add_constructor( 383 | jsc_class: *mut JSCClass, 384 | name: *const c_char, 385 | callback: gobject::GCallback, 386 | user_data: gpointer, 387 | destroy_notify: glib::GDestroyNotify, 388 | return_type: GType, 389 | n_params: c_uint, 390 | ... 391 | ) -> *mut JSCValue; 392 | pub fn jsc_class_add_constructor_variadic( 393 | jsc_class: *mut JSCClass, 394 | name: *const c_char, 395 | callback: gobject::GCallback, 396 | user_data: gpointer, 397 | destroy_notify: glib::GDestroyNotify, 398 | return_type: GType, 399 | ) -> *mut JSCValue; 400 | pub fn jsc_class_add_constructorv( 401 | jsc_class: *mut JSCClass, 402 | name: *const c_char, 403 | callback: gobject::GCallback, 404 | user_data: gpointer, 405 | destroy_notify: glib::GDestroyNotify, 406 | return_type: GType, 407 | n_parameters: c_uint, 408 | parameter_types: *mut GType, 409 | ) -> *mut JSCValue; 410 | pub fn jsc_class_add_method( 411 | jsc_class: *mut JSCClass, 412 | name: *const c_char, 413 | callback: gobject::GCallback, 414 | user_data: gpointer, 415 | destroy_notify: glib::GDestroyNotify, 416 | return_type: GType, 417 | n_params: c_uint, 418 | ... 419 | ); 420 | pub fn jsc_class_add_method_variadic( 421 | jsc_class: *mut JSCClass, 422 | name: *const c_char, 423 | callback: gobject::GCallback, 424 | user_data: gpointer, 425 | destroy_notify: glib::GDestroyNotify, 426 | return_type: GType, 427 | ); 428 | pub fn jsc_class_add_methodv( 429 | jsc_class: *mut JSCClass, 430 | name: *const c_char, 431 | callback: gobject::GCallback, 432 | user_data: gpointer, 433 | destroy_notify: glib::GDestroyNotify, 434 | return_type: GType, 435 | n_parameters: c_uint, 436 | parameter_types: *mut GType, 437 | ); 438 | pub fn jsc_class_add_property( 439 | jsc_class: *mut JSCClass, 440 | name: *const c_char, 441 | property_type: GType, 442 | getter: gobject::GCallback, 443 | setter: gobject::GCallback, 444 | user_data: gpointer, 445 | destroy_notify: glib::GDestroyNotify, 446 | ); 447 | pub fn jsc_class_get_name(jsc_class: *mut JSCClass) -> *const c_char; 448 | pub fn jsc_class_get_parent(jsc_class: *mut JSCClass) -> *mut JSCClass; 449 | 450 | //========================================================================= 451 | // JSCContext 452 | //========================================================================= 453 | pub fn jsc_context_get_type() -> GType; 454 | pub fn jsc_context_new() -> *mut JSCContext; 455 | pub fn jsc_context_new_with_virtual_machine(vm: *mut JSCVirtualMachine) -> *mut JSCContext; 456 | pub fn jsc_context_get_current() -> *mut JSCContext; 457 | pub fn jsc_context_check_syntax( 458 | context: *mut JSCContext, 459 | code: *const c_char, 460 | length: ssize_t, 461 | mode: JSCCheckSyntaxMode, 462 | uri: *const c_char, 463 | line_number: c_uint, 464 | exception: *mut *mut JSCException, 465 | ) -> JSCCheckSyntaxResult; 466 | pub fn jsc_context_clear_exception(context: *mut JSCContext); 467 | pub fn jsc_context_evaluate( 468 | context: *mut JSCContext, 469 | code: *const c_char, 470 | length: ssize_t, 471 | ) -> *mut JSCValue; 472 | pub fn jsc_context_evaluate_in_object( 473 | context: *mut JSCContext, 474 | code: *const c_char, 475 | length: ssize_t, 476 | object_instance: gpointer, 477 | object_class: *mut JSCClass, 478 | uri: *const c_char, 479 | line_number: c_uint, 480 | object: *mut *mut JSCValue, 481 | ) -> *mut JSCValue; 482 | pub fn jsc_context_evaluate_with_source_uri( 483 | context: *mut JSCContext, 484 | code: *const c_char, 485 | length: ssize_t, 486 | uri: *const c_char, 487 | line_number: c_uint, 488 | ) -> *mut JSCValue; 489 | pub fn jsc_context_get_exception(context: *mut JSCContext) -> *mut JSCException; 490 | pub fn jsc_context_get_global_object(context: *mut JSCContext) -> *mut JSCValue; 491 | pub fn jsc_context_get_value(context: *mut JSCContext, name: *const c_char) -> *mut JSCValue; 492 | pub fn jsc_context_get_virtual_machine(context: *mut JSCContext) -> *mut JSCVirtualMachine; 493 | pub fn jsc_context_pop_exception_handler(context: *mut JSCContext); 494 | pub fn jsc_context_push_exception_handler( 495 | context: *mut JSCContext, 496 | handler: JSCExceptionHandler, 497 | user_data: gpointer, 498 | destroy_notify: glib::GDestroyNotify, 499 | ); 500 | pub fn jsc_context_register_class( 501 | context: *mut JSCContext, 502 | name: *const c_char, 503 | parent_class: *mut JSCClass, 504 | vtable: *mut JSCClassVTable, 505 | destroy_notify: glib::GDestroyNotify, 506 | ) -> *mut JSCClass; 507 | pub fn jsc_context_set_value(context: *mut JSCContext, name: *const c_char, value: *mut JSCValue); 508 | pub fn jsc_context_throw(context: *mut JSCContext, error_message: *const c_char); 509 | pub fn jsc_context_throw_exception(context: *mut JSCContext, exception: *mut JSCException); 510 | pub fn jsc_context_throw_printf(context: *mut JSCContext, format: *const c_char, ...); 511 | pub fn jsc_context_throw_with_name( 512 | context: *mut JSCContext, 513 | error_name: *const c_char, 514 | error_message: *const c_char, 515 | ); 516 | pub fn jsc_context_throw_with_name_printf( 517 | context: *mut JSCContext, 518 | error_name: *const c_char, 519 | format: *const c_char, 520 | ... 521 | ); 522 | 523 | //========================================================================= 524 | // JSCException 525 | //========================================================================= 526 | pub fn jsc_exception_get_type() -> GType; 527 | pub fn jsc_exception_new(context: *mut JSCContext, message: *const c_char) -> *mut JSCException; 528 | pub fn jsc_exception_new_printf( 529 | context: *mut JSCContext, 530 | format: *const c_char, 531 | ... 532 | ) -> *mut JSCException; 533 | //pub fn jsc_exception_new_vprintf(context: *mut JSCContext, format: *const c_char, args: /*Unimplemented*/va_list) -> *mut JSCException; 534 | pub fn jsc_exception_new_with_name( 535 | context: *mut JSCContext, 536 | name: *const c_char, 537 | message: *const c_char, 538 | ) -> *mut JSCException; 539 | pub fn jsc_exception_new_with_name_printf( 540 | context: *mut JSCContext, 541 | name: *const c_char, 542 | format: *const c_char, 543 | ... 544 | ) -> *mut JSCException; 545 | //pub fn jsc_exception_new_with_name_vprintf(context: *mut JSCContext, name: *const c_char, format: *const c_char, args: /*Unimplemented*/va_list) -> *mut JSCException; 546 | pub fn jsc_exception_get_backtrace_string(exception: *mut JSCException) -> *const c_char; 547 | pub fn jsc_exception_get_column_number(exception: *mut JSCException) -> c_uint; 548 | pub fn jsc_exception_get_line_number(exception: *mut JSCException) -> c_uint; 549 | pub fn jsc_exception_get_message(exception: *mut JSCException) -> *const c_char; 550 | pub fn jsc_exception_get_name(exception: *mut JSCException) -> *const c_char; 551 | pub fn jsc_exception_get_source_uri(exception: *mut JSCException) -> *const c_char; 552 | pub fn jsc_exception_report(exception: *mut JSCException) -> *mut c_char; 553 | pub fn jsc_exception_to_string(exception: *mut JSCException) -> *mut c_char; 554 | 555 | //========================================================================= 556 | // JSCValue 557 | //========================================================================= 558 | pub fn jsc_value_get_type() -> GType; 559 | pub fn jsc_value_new_array( 560 | context: *mut JSCContext, 561 | first_item_type: GType, 562 | ... 563 | ) -> *mut JSCValue; 564 | #[cfg(feature = "v2_38")] 565 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] 566 | pub fn jsc_value_new_array_buffer( 567 | context: *mut JSCContext, 568 | data: gpointer, 569 | size: size_t, 570 | destroy_notify: glib::GDestroyNotify, 571 | user_data: gpointer, 572 | ) -> *mut JSCValue; 573 | pub fn jsc_value_new_array_from_garray( 574 | context: *mut JSCContext, 575 | array: *mut glib::GPtrArray, 576 | ) -> *mut JSCValue; 577 | pub fn jsc_value_new_array_from_strv( 578 | context: *mut JSCContext, 579 | strv: *const *const c_char, 580 | ) -> *mut JSCValue; 581 | pub fn jsc_value_new_boolean(context: *mut JSCContext, value: gboolean) -> *mut JSCValue; 582 | #[cfg(feature = "v2_28")] 583 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_28")))] 584 | pub fn jsc_value_new_from_json(context: *mut JSCContext, json: *const c_char) -> *mut JSCValue; 585 | pub fn jsc_value_new_function( 586 | context: *mut JSCContext, 587 | name: *const c_char, 588 | callback: gobject::GCallback, 589 | user_data: gpointer, 590 | destroy_notify: glib::GDestroyNotify, 591 | return_type: GType, 592 | n_params: c_uint, 593 | ... 594 | ) -> *mut JSCValue; 595 | pub fn jsc_value_new_function_variadic( 596 | context: *mut JSCContext, 597 | name: *const c_char, 598 | callback: gobject::GCallback, 599 | user_data: gpointer, 600 | destroy_notify: glib::GDestroyNotify, 601 | return_type: GType, 602 | ) -> *mut JSCValue; 603 | pub fn jsc_value_new_functionv( 604 | context: *mut JSCContext, 605 | name: *const c_char, 606 | callback: gobject::GCallback, 607 | user_data: gpointer, 608 | destroy_notify: glib::GDestroyNotify, 609 | return_type: GType, 610 | n_parameters: c_uint, 611 | parameter_types: *mut GType, 612 | ) -> *mut JSCValue; 613 | pub fn jsc_value_new_null(context: *mut JSCContext) -> *mut JSCValue; 614 | pub fn jsc_value_new_number(context: *mut JSCContext, number: c_double) -> *mut JSCValue; 615 | pub fn jsc_value_new_object( 616 | context: *mut JSCContext, 617 | instance: gpointer, 618 | jsc_class: *mut JSCClass, 619 | ) -> *mut JSCValue; 620 | pub fn jsc_value_new_string(context: *mut JSCContext, string: *const c_char) -> *mut JSCValue; 621 | pub fn jsc_value_new_string_from_bytes( 622 | context: *mut JSCContext, 623 | bytes: *mut glib::GBytes, 624 | ) -> *mut JSCValue; 625 | #[cfg(feature = "v2_38")] 626 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] 627 | pub fn jsc_value_new_typed_array( 628 | context: *mut JSCContext, 629 | type_: JSCTypedArrayType, 630 | length: size_t, 631 | ) -> *mut JSCValue; 632 | pub fn jsc_value_new_undefined(context: *mut JSCContext) -> *mut JSCValue; 633 | #[cfg(feature = "v2_38")] 634 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] 635 | pub fn jsc_value_array_buffer_get_data(value: *mut JSCValue, size: *mut size_t) -> gpointer; 636 | #[cfg(feature = "v2_38")] 637 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] 638 | pub fn jsc_value_array_buffer_get_size(value: *mut JSCValue) -> size_t; 639 | pub fn jsc_value_constructor_call( 640 | value: *mut JSCValue, 641 | first_parameter_type: GType, 642 | ... 643 | ) -> *mut JSCValue; 644 | pub fn jsc_value_constructor_callv( 645 | value: *mut JSCValue, 646 | n_parameters: c_uint, 647 | parameters: *mut *mut JSCValue, 648 | ) -> *mut JSCValue; 649 | pub fn jsc_value_function_call( 650 | value: *mut JSCValue, 651 | first_parameter_type: GType, 652 | ... 653 | ) -> *mut JSCValue; 654 | pub fn jsc_value_function_callv( 655 | value: *mut JSCValue, 656 | n_parameters: c_uint, 657 | parameters: *mut *mut JSCValue, 658 | ) -> *mut JSCValue; 659 | pub fn jsc_value_get_context(value: *mut JSCValue) -> *mut JSCContext; 660 | pub fn jsc_value_is_array(value: *mut JSCValue) -> gboolean; 661 | #[cfg(feature = "v2_38")] 662 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] 663 | pub fn jsc_value_is_array_buffer(value: *mut JSCValue) -> gboolean; 664 | pub fn jsc_value_is_boolean(value: *mut JSCValue) -> gboolean; 665 | pub fn jsc_value_is_constructor(value: *mut JSCValue) -> gboolean; 666 | pub fn jsc_value_is_function(value: *mut JSCValue) -> gboolean; 667 | pub fn jsc_value_is_null(value: *mut JSCValue) -> gboolean; 668 | pub fn jsc_value_is_number(value: *mut JSCValue) -> gboolean; 669 | pub fn jsc_value_is_object(value: *mut JSCValue) -> gboolean; 670 | pub fn jsc_value_is_string(value: *mut JSCValue) -> gboolean; 671 | #[cfg(feature = "v2_38")] 672 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] 673 | pub fn jsc_value_is_typed_array(value: *mut JSCValue) -> gboolean; 674 | pub fn jsc_value_is_undefined(value: *mut JSCValue) -> gboolean; 675 | #[cfg(feature = "v2_38")] 676 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] 677 | pub fn jsc_value_new_typed_array_with_buffer( 678 | array_buffer: *mut JSCValue, 679 | type_: JSCTypedArrayType, 680 | offset: size_t, 681 | length: ssize_t, 682 | ) -> *mut JSCValue; 683 | pub fn jsc_value_object_define_property_accessor( 684 | value: *mut JSCValue, 685 | property_name: *const c_char, 686 | flags: JSCValuePropertyFlags, 687 | property_type: GType, 688 | getter: gobject::GCallback, 689 | setter: gobject::GCallback, 690 | user_data: gpointer, 691 | destroy_notify: glib::GDestroyNotify, 692 | ); 693 | pub fn jsc_value_object_define_property_data( 694 | value: *mut JSCValue, 695 | property_name: *const c_char, 696 | flags: JSCValuePropertyFlags, 697 | property_value: *mut JSCValue, 698 | ); 699 | pub fn jsc_value_object_delete_property(value: *mut JSCValue, name: *const c_char) -> gboolean; 700 | pub fn jsc_value_object_enumerate_properties(value: *mut JSCValue) -> *mut *mut c_char; 701 | pub fn jsc_value_object_get_property(value: *mut JSCValue, name: *const c_char) -> *mut JSCValue; 702 | pub fn jsc_value_object_get_property_at_index( 703 | value: *mut JSCValue, 704 | index: c_uint, 705 | ) -> *mut JSCValue; 706 | pub fn jsc_value_object_has_property(value: *mut JSCValue, name: *const c_char) -> gboolean; 707 | pub fn jsc_value_object_invoke_method( 708 | value: *mut JSCValue, 709 | name: *const c_char, 710 | first_parameter_type: GType, 711 | ... 712 | ) -> *mut JSCValue; 713 | pub fn jsc_value_object_invoke_methodv( 714 | value: *mut JSCValue, 715 | name: *const c_char, 716 | n_parameters: c_uint, 717 | parameters: *mut *mut JSCValue, 718 | ) -> *mut JSCValue; 719 | pub fn jsc_value_object_is_instance_of(value: *mut JSCValue, name: *const c_char) -> gboolean; 720 | pub fn jsc_value_object_set_property( 721 | value: *mut JSCValue, 722 | name: *const c_char, 723 | property: *mut JSCValue, 724 | ); 725 | pub fn jsc_value_object_set_property_at_index( 726 | value: *mut JSCValue, 727 | index: c_uint, 728 | property: *mut JSCValue, 729 | ); 730 | pub fn jsc_value_to_boolean(value: *mut JSCValue) -> gboolean; 731 | pub fn jsc_value_to_double(value: *mut JSCValue) -> c_double; 732 | pub fn jsc_value_to_int32(value: *mut JSCValue) -> i32; 733 | #[cfg(feature = "v2_28")] 734 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_28")))] 735 | pub fn jsc_value_to_json(value: *mut JSCValue, indent: c_uint) -> *mut c_char; 736 | pub fn jsc_value_to_string(value: *mut JSCValue) -> *mut c_char; 737 | pub fn jsc_value_to_string_as_bytes(value: *mut JSCValue) -> *mut glib::GBytes; 738 | #[cfg(feature = "v2_38")] 739 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] 740 | pub fn jsc_value_typed_array_get_buffer(value: *mut JSCValue) -> *mut JSCValue; 741 | #[cfg(feature = "v2_38")] 742 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] 743 | pub fn jsc_value_typed_array_get_data(value: *mut JSCValue, length: *mut size_t) -> gpointer; 744 | #[cfg(feature = "v2_38")] 745 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] 746 | pub fn jsc_value_typed_array_get_length(value: *mut JSCValue) -> size_t; 747 | #[cfg(feature = "v2_38")] 748 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] 749 | pub fn jsc_value_typed_array_get_offset(value: *mut JSCValue) -> size_t; 750 | #[cfg(feature = "v2_38")] 751 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] 752 | pub fn jsc_value_typed_array_get_size(value: *mut JSCValue) -> size_t; 753 | #[cfg(feature = "v2_38")] 754 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] 755 | pub fn jsc_value_typed_array_get_type(value: *mut JSCValue) -> JSCTypedArrayType; 756 | 757 | //========================================================================= 758 | // JSCVirtualMachine 759 | //========================================================================= 760 | pub fn jsc_virtual_machine_get_type() -> GType; 761 | pub fn jsc_virtual_machine_new() -> *mut JSCVirtualMachine; 762 | 763 | //========================================================================= 764 | // JSCWeakValue 765 | //========================================================================= 766 | pub fn jsc_weak_value_get_type() -> GType; 767 | pub fn jsc_weak_value_new(value: *mut JSCValue) -> *mut JSCWeakValue; 768 | pub fn jsc_weak_value_get_value(weak_value: *mut JSCWeakValue) -> *mut JSCValue; 769 | 770 | //========================================================================= 771 | // Other functions 772 | //========================================================================= 773 | pub fn jsc_get_major_version() -> c_uint; 774 | pub fn jsc_get_micro_version() -> c_uint; 775 | pub fn jsc_get_minor_version() -> c_uint; 776 | pub fn jsc_options_foreach(function: JSCOptionsFunc, user_data: gpointer); 777 | pub fn jsc_options_get_boolean(option: *const c_char, value: *mut gboolean) -> gboolean; 778 | pub fn jsc_options_get_double(option: *const c_char, value: *mut c_double) -> gboolean; 779 | pub fn jsc_options_get_int(option: *const c_char, value: *mut c_int) -> gboolean; 780 | pub fn jsc_options_get_option_group() -> *mut glib::GOptionGroup; 781 | pub fn jsc_options_get_range_string(option: *const c_char, value: *mut *mut c_char) -> gboolean; 782 | pub fn jsc_options_get_size(option: *const c_char, value: *mut size_t) -> gboolean; 783 | pub fn jsc_options_get_string(option: *const c_char, value: *mut *mut c_char) -> gboolean; 784 | pub fn jsc_options_get_uint(option: *const c_char, value: *mut c_uint) -> gboolean; 785 | pub fn jsc_options_set_boolean(option: *const c_char, value: gboolean) -> gboolean; 786 | pub fn jsc_options_set_double(option: *const c_char, value: c_double) -> gboolean; 787 | pub fn jsc_options_set_int(option: *const c_char, value: c_int) -> gboolean; 788 | pub fn jsc_options_set_range_string(option: *const c_char, value: *const c_char) -> gboolean; 789 | pub fn jsc_options_set_size(option: *const c_char, value: size_t) -> gboolean; 790 | pub fn jsc_options_set_string(option: *const c_char, value: *const c_char) -> gboolean; 791 | pub fn jsc_options_set_uint(option: *const c_char, value: c_uint) -> gboolean; 792 | 793 | } 794 | -------------------------------------------------------------------------------- /sys/tests/abi.rs: -------------------------------------------------------------------------------- 1 | // Generated by gir (https://github.com/gtk-rs/gir @ 73df75128d55) 2 | // from ../gir-files (@ 8be196040235) 3 | // DO NOT EDIT 4 | 5 | #![cfg(unix)] 6 | 7 | use javascriptcore_rs_sys::*; 8 | use std::env; 9 | use std::error::Error; 10 | use std::ffi::OsString; 11 | use std::mem::{align_of, size_of}; 12 | use std::path::Path; 13 | use std::process::{Command, Stdio}; 14 | use std::str; 15 | use tempfile::Builder; 16 | 17 | static PACKAGES: &[&str] = &["javascriptcoregtk-4.1"]; 18 | 19 | #[derive(Clone, Debug)] 20 | struct Compiler { 21 | pub args: Vec, 22 | } 23 | 24 | impl Compiler { 25 | pub fn new() -> Result> { 26 | let mut args = get_var("CC", "cc")?; 27 | args.push("-Wno-deprecated-declarations".to_owned()); 28 | // For _Generic 29 | args.push("-std=c11".to_owned()); 30 | // For %z support in printf when using MinGW. 31 | args.push("-D__USE_MINGW_ANSI_STDIO".to_owned()); 32 | args.extend(get_var("CFLAGS", "")?); 33 | args.extend(get_var("CPPFLAGS", "")?); 34 | args.extend(pkg_config_cflags(PACKAGES)?); 35 | Ok(Self { args }) 36 | } 37 | 38 | pub fn compile(&self, src: &Path, out: &Path) -> Result<(), Box> { 39 | let mut cmd = self.to_command(); 40 | cmd.arg(src); 41 | cmd.arg("-o"); 42 | cmd.arg(out); 43 | let status = cmd.spawn()?.wait()?; 44 | if !status.success() { 45 | return Err(format!("compilation command {cmd:?} failed, {status}").into()); 46 | } 47 | Ok(()) 48 | } 49 | 50 | fn to_command(&self) -> Command { 51 | let mut cmd = Command::new(&self.args[0]); 52 | cmd.args(&self.args[1..]); 53 | cmd 54 | } 55 | } 56 | 57 | fn get_var(name: &str, default: &str) -> Result, Box> { 58 | match env::var(name) { 59 | Ok(value) => Ok(shell_words::split(&value)?), 60 | Err(env::VarError::NotPresent) => Ok(shell_words::split(default)?), 61 | Err(err) => Err(format!("{name} {err}").into()), 62 | } 63 | } 64 | 65 | fn pkg_config_cflags(packages: &[&str]) -> Result, Box> { 66 | if packages.is_empty() { 67 | return Ok(Vec::new()); 68 | } 69 | let pkg_config = env::var_os("PKG_CONFIG").unwrap_or_else(|| OsString::from("pkg-config")); 70 | let mut cmd = Command::new(pkg_config); 71 | cmd.arg("--cflags"); 72 | cmd.args(packages); 73 | cmd.stderr(Stdio::inherit()); 74 | let out = cmd.output()?; 75 | if !out.status.success() { 76 | let (status, stdout) = (out.status, String::from_utf8_lossy(&out.stdout)); 77 | return Err(format!("command {cmd:?} failed, {status:?}\nstdout: {stdout}").into()); 78 | } 79 | let stdout = str::from_utf8(&out.stdout)?; 80 | Ok(shell_words::split(stdout.trim())?) 81 | } 82 | 83 | #[derive(Copy, Clone, Debug, Eq, PartialEq)] 84 | struct Layout { 85 | size: usize, 86 | alignment: usize, 87 | } 88 | 89 | #[derive(Copy, Clone, Debug, Default, Eq, PartialEq)] 90 | struct Results { 91 | /// Number of successfully completed tests. 92 | passed: usize, 93 | /// Total number of failed tests (including those that failed to compile). 94 | failed: usize, 95 | } 96 | 97 | impl Results { 98 | fn record_passed(&mut self) { 99 | self.passed += 1; 100 | } 101 | fn record_failed(&mut self) { 102 | self.failed += 1; 103 | } 104 | fn summary(&self) -> String { 105 | format!("{} passed; {} failed", self.passed, self.failed) 106 | } 107 | fn expect_total_success(&self) { 108 | if self.failed == 0 { 109 | println!("OK: {}", self.summary()); 110 | } else { 111 | panic!("FAILED: {}", self.summary()); 112 | }; 113 | } 114 | } 115 | 116 | #[test] 117 | fn cross_validate_constants_with_c() { 118 | let mut c_constants: Vec<(String, String)> = Vec::new(); 119 | 120 | for l in get_c_output("constant").unwrap().lines() { 121 | let (name, value) = l.split_once(';').expect("Missing ';' separator"); 122 | c_constants.push((name.to_owned(), value.to_owned())); 123 | } 124 | 125 | let mut results = Results::default(); 126 | 127 | for ((rust_name, rust_value), (c_name, c_value)) in RUST_CONSTANTS.iter().zip(c_constants.iter()) 128 | { 129 | if rust_name != c_name { 130 | results.record_failed(); 131 | eprintln!("Name mismatch:\nRust: {rust_name:?}\nC: {c_name:?}"); 132 | continue; 133 | } 134 | 135 | if rust_value != c_value { 136 | results.record_failed(); 137 | eprintln!("Constant value mismatch for {rust_name}\nRust: {rust_value:?}\nC: {c_value:?}",); 138 | continue; 139 | } 140 | 141 | results.record_passed(); 142 | } 143 | 144 | results.expect_total_success(); 145 | } 146 | 147 | #[test] 148 | fn cross_validate_layout_with_c() { 149 | let mut c_layouts = Vec::new(); 150 | 151 | for l in get_c_output("layout").unwrap().lines() { 152 | let (name, value) = l.split_once(';').expect("Missing first ';' separator"); 153 | let (size, alignment) = value.split_once(';').expect("Missing second ';' separator"); 154 | let size = size.parse().expect("Failed to parse size"); 155 | let alignment = alignment.parse().expect("Failed to parse alignment"); 156 | c_layouts.push((name.to_owned(), Layout { size, alignment })); 157 | } 158 | 159 | let mut results = Results::default(); 160 | 161 | for ((rust_name, rust_layout), (c_name, c_layout)) in RUST_LAYOUTS.iter().zip(c_layouts.iter()) { 162 | if rust_name != c_name { 163 | results.record_failed(); 164 | eprintln!("Name mismatch:\nRust: {rust_name:?}\nC: {c_name:?}"); 165 | continue; 166 | } 167 | 168 | if rust_layout != c_layout { 169 | results.record_failed(); 170 | eprintln!("Layout mismatch for {rust_name}\nRust: {rust_layout:?}\nC: {c_layout:?}",); 171 | continue; 172 | } 173 | 174 | results.record_passed(); 175 | } 176 | 177 | results.expect_total_success(); 178 | } 179 | 180 | fn get_c_output(name: &str) -> Result> { 181 | let tmpdir = Builder::new().prefix("abi").tempdir()?; 182 | let exe = tmpdir.path().join(name); 183 | let c_file = Path::new("tests").join(name).with_extension("c"); 184 | 185 | let cc = Compiler::new().expect("configured compiler"); 186 | cc.compile(&c_file, &exe)?; 187 | 188 | let mut cmd = Command::new(exe); 189 | cmd.stderr(Stdio::inherit()); 190 | let out = cmd.output()?; 191 | if !out.status.success() { 192 | let (status, stdout) = (out.status, String::from_utf8_lossy(&out.stdout)); 193 | return Err(format!("command {cmd:?} failed, {status:?}\nstdout: {stdout}").into()); 194 | } 195 | 196 | Ok(String::from_utf8(out.stdout)?) 197 | } 198 | 199 | const RUST_LAYOUTS: &[(&str, Layout)] = &[ 200 | ( 201 | "JSCCheckSyntaxMode", 202 | Layout { 203 | size: size_of::(), 204 | alignment: align_of::(), 205 | }, 206 | ), 207 | ( 208 | "JSCCheckSyntaxResult", 209 | Layout { 210 | size: size_of::(), 211 | alignment: align_of::(), 212 | }, 213 | ), 214 | ( 215 | "JSCClassVTable", 216 | Layout { 217 | size: size_of::(), 218 | alignment: align_of::(), 219 | }, 220 | ), 221 | ( 222 | "JSCContext", 223 | Layout { 224 | size: size_of::(), 225 | alignment: align_of::(), 226 | }, 227 | ), 228 | ( 229 | "JSCContextClass", 230 | Layout { 231 | size: size_of::(), 232 | alignment: align_of::(), 233 | }, 234 | ), 235 | ( 236 | "JSCException", 237 | Layout { 238 | size: size_of::(), 239 | alignment: align_of::(), 240 | }, 241 | ), 242 | ( 243 | "JSCExceptionClass", 244 | Layout { 245 | size: size_of::(), 246 | alignment: align_of::(), 247 | }, 248 | ), 249 | ( 250 | "JSCOptionType", 251 | Layout { 252 | size: size_of::(), 253 | alignment: align_of::(), 254 | }, 255 | ), 256 | ( 257 | "JSCTypedArrayType", 258 | Layout { 259 | size: size_of::(), 260 | alignment: align_of::(), 261 | }, 262 | ), 263 | ( 264 | "JSCValue", 265 | Layout { 266 | size: size_of::(), 267 | alignment: align_of::(), 268 | }, 269 | ), 270 | ( 271 | "JSCValueClass", 272 | Layout { 273 | size: size_of::(), 274 | alignment: align_of::(), 275 | }, 276 | ), 277 | ( 278 | "JSCValuePropertyFlags", 279 | Layout { 280 | size: size_of::(), 281 | alignment: align_of::(), 282 | }, 283 | ), 284 | ( 285 | "JSCVirtualMachine", 286 | Layout { 287 | size: size_of::(), 288 | alignment: align_of::(), 289 | }, 290 | ), 291 | ( 292 | "JSCVirtualMachineClass", 293 | Layout { 294 | size: size_of::(), 295 | alignment: align_of::(), 296 | }, 297 | ), 298 | ( 299 | "JSCWeakValue", 300 | Layout { 301 | size: size_of::(), 302 | alignment: align_of::(), 303 | }, 304 | ), 305 | ( 306 | "JSCWeakValueClass", 307 | Layout { 308 | size: size_of::(), 309 | alignment: align_of::(), 310 | }, 311 | ), 312 | ]; 313 | 314 | const RUST_CONSTANTS: &[(&str, &str)] = &[ 315 | ("(gint) JSC_CHECK_SYNTAX_MODE_MODULE", "1"), 316 | ("(gint) JSC_CHECK_SYNTAX_MODE_SCRIPT", "0"), 317 | ("(gint) JSC_CHECK_SYNTAX_RESULT_IRRECOVERABLE_ERROR", "2"), 318 | ("(gint) JSC_CHECK_SYNTAX_RESULT_OUT_OF_MEMORY_ERROR", "4"), 319 | ("(gint) JSC_CHECK_SYNTAX_RESULT_RECOVERABLE_ERROR", "1"), 320 | ("(gint) JSC_CHECK_SYNTAX_RESULT_STACK_OVERFLOW_ERROR", "5"), 321 | ("(gint) JSC_CHECK_SYNTAX_RESULT_SUCCESS", "0"), 322 | ( 323 | "(gint) JSC_CHECK_SYNTAX_RESULT_UNTERMINATED_LITERAL_ERROR", 324 | "3", 325 | ), 326 | ("JSC_MAJOR_VERSION", "2"), 327 | ("JSC_MICRO_VERSION", "1"), 328 | ("JSC_MINOR_VERSION", "38"), 329 | ("JSC_OPTIONS_USE_DFG", "useDFGJIT"), 330 | ("JSC_OPTIONS_USE_FTL", "useFTLJIT"), 331 | ("JSC_OPTIONS_USE_JIT", "useJIT"), 332 | ("JSC_OPTIONS_USE_LLINT", "useLLInt"), 333 | ("(gint) JSC_OPTION_BOOLEAN", "0"), 334 | ("(gint) JSC_OPTION_DOUBLE", "4"), 335 | ("(gint) JSC_OPTION_INT", "1"), 336 | ("(gint) JSC_OPTION_RANGE_STRING", "6"), 337 | ("(gint) JSC_OPTION_SIZE", "3"), 338 | ("(gint) JSC_OPTION_STRING", "5"), 339 | ("(gint) JSC_OPTION_UINT", "2"), 340 | ("(gint) JSC_TYPED_ARRAY_FLOAT32", "10"), 341 | ("(gint) JSC_TYPED_ARRAY_FLOAT64", "11"), 342 | ("(gint) JSC_TYPED_ARRAY_INT16", "2"), 343 | ("(gint) JSC_TYPED_ARRAY_INT32", "3"), 344 | ("(gint) JSC_TYPED_ARRAY_INT64", "4"), 345 | ("(gint) JSC_TYPED_ARRAY_INT8", "1"), 346 | ("(gint) JSC_TYPED_ARRAY_NONE", "0"), 347 | ("(gint) JSC_TYPED_ARRAY_UINT16", "7"), 348 | ("(gint) JSC_TYPED_ARRAY_UINT32", "8"), 349 | ("(gint) JSC_TYPED_ARRAY_UINT64", "9"), 350 | ("(gint) JSC_TYPED_ARRAY_UINT8", "5"), 351 | ("(gint) JSC_TYPED_ARRAY_UINT8_CLAMPED", "6"), 352 | ("(guint) JSC_VALUE_PROPERTY_CONFIGURABLE", "1"), 353 | ("(guint) JSC_VALUE_PROPERTY_ENUMERABLE", "2"), 354 | ("(guint) JSC_VALUE_PROPERTY_WRITABLE", "4"), 355 | ]; 356 | -------------------------------------------------------------------------------- /sys/tests/constant.c: -------------------------------------------------------------------------------- 1 | // Generated by gir (https://github.com/gtk-rs/gir @ 73df75128d55) 2 | // from ../gir-files (@ 8be196040235) 3 | // DO NOT EDIT 4 | 5 | #include "manual.h" 6 | #include 7 | 8 | #define PRINT_CONSTANT(CONSTANT_NAME) \ 9 | printf("%s;", #CONSTANT_NAME); \ 10 | printf(_Generic((CONSTANT_NAME), \ 11 | char *: "%s", \ 12 | const char *: "%s", \ 13 | char: "%c", \ 14 | signed char: "%hhd", \ 15 | unsigned char: "%hhu", \ 16 | short int: "%hd", \ 17 | unsigned short int: "%hu", \ 18 | int: "%d", \ 19 | unsigned int: "%u", \ 20 | long: "%ld", \ 21 | unsigned long: "%lu", \ 22 | long long: "%lld", \ 23 | unsigned long long: "%llu", \ 24 | float: "%f", \ 25 | double: "%f", \ 26 | long double: "%ld"), \ 27 | CONSTANT_NAME); \ 28 | printf("\n"); 29 | 30 | int main() { 31 | PRINT_CONSTANT((gint) JSC_CHECK_SYNTAX_MODE_MODULE); 32 | PRINT_CONSTANT((gint) JSC_CHECK_SYNTAX_MODE_SCRIPT); 33 | PRINT_CONSTANT((gint) JSC_CHECK_SYNTAX_RESULT_IRRECOVERABLE_ERROR); 34 | PRINT_CONSTANT((gint) JSC_CHECK_SYNTAX_RESULT_OUT_OF_MEMORY_ERROR); 35 | PRINT_CONSTANT((gint) JSC_CHECK_SYNTAX_RESULT_RECOVERABLE_ERROR); 36 | PRINT_CONSTANT((gint) JSC_CHECK_SYNTAX_RESULT_STACK_OVERFLOW_ERROR); 37 | PRINT_CONSTANT((gint) JSC_CHECK_SYNTAX_RESULT_SUCCESS); 38 | PRINT_CONSTANT((gint) JSC_CHECK_SYNTAX_RESULT_UNTERMINATED_LITERAL_ERROR); 39 | PRINT_CONSTANT(JSC_MAJOR_VERSION); 40 | PRINT_CONSTANT(JSC_MICRO_VERSION); 41 | PRINT_CONSTANT(JSC_MINOR_VERSION); 42 | PRINT_CONSTANT(JSC_OPTIONS_USE_DFG); 43 | PRINT_CONSTANT(JSC_OPTIONS_USE_FTL); 44 | PRINT_CONSTANT(JSC_OPTIONS_USE_JIT); 45 | PRINT_CONSTANT(JSC_OPTIONS_USE_LLINT); 46 | PRINT_CONSTANT((gint) JSC_OPTION_BOOLEAN); 47 | PRINT_CONSTANT((gint) JSC_OPTION_DOUBLE); 48 | PRINT_CONSTANT((gint) JSC_OPTION_INT); 49 | PRINT_CONSTANT((gint) JSC_OPTION_RANGE_STRING); 50 | PRINT_CONSTANT((gint) JSC_OPTION_SIZE); 51 | PRINT_CONSTANT((gint) JSC_OPTION_STRING); 52 | PRINT_CONSTANT((gint) JSC_OPTION_UINT); 53 | PRINT_CONSTANT((gint) JSC_TYPED_ARRAY_FLOAT32); 54 | PRINT_CONSTANT((gint) JSC_TYPED_ARRAY_FLOAT64); 55 | PRINT_CONSTANT((gint) JSC_TYPED_ARRAY_INT16); 56 | PRINT_CONSTANT((gint) JSC_TYPED_ARRAY_INT32); 57 | PRINT_CONSTANT((gint) JSC_TYPED_ARRAY_INT64); 58 | PRINT_CONSTANT((gint) JSC_TYPED_ARRAY_INT8); 59 | PRINT_CONSTANT((gint) JSC_TYPED_ARRAY_NONE); 60 | PRINT_CONSTANT((gint) JSC_TYPED_ARRAY_UINT16); 61 | PRINT_CONSTANT((gint) JSC_TYPED_ARRAY_UINT32); 62 | PRINT_CONSTANT((gint) JSC_TYPED_ARRAY_UINT64); 63 | PRINT_CONSTANT((gint) JSC_TYPED_ARRAY_UINT8); 64 | PRINT_CONSTANT((gint) JSC_TYPED_ARRAY_UINT8_CLAMPED); 65 | PRINT_CONSTANT((guint) JSC_VALUE_PROPERTY_CONFIGURABLE); 66 | PRINT_CONSTANT((guint) JSC_VALUE_PROPERTY_ENUMERABLE); 67 | PRINT_CONSTANT((guint) JSC_VALUE_PROPERTY_WRITABLE); 68 | return 0; 69 | } 70 | -------------------------------------------------------------------------------- /sys/tests/layout.c: -------------------------------------------------------------------------------- 1 | // Generated by gir (https://github.com/gtk-rs/gir @ 73df75128d55) 2 | // from ../gir-files (@ 8be196040235) 3 | // DO NOT EDIT 4 | 5 | #include "manual.h" 6 | #include 7 | #include 8 | 9 | int main() { 10 | printf("%s;%zu;%zu\n", "JSCCheckSyntaxMode", sizeof(JSCCheckSyntaxMode), alignof(JSCCheckSyntaxMode)); 11 | printf("%s;%zu;%zu\n", "JSCCheckSyntaxResult", sizeof(JSCCheckSyntaxResult), alignof(JSCCheckSyntaxResult)); 12 | printf("%s;%zu;%zu\n", "JSCClassVTable", sizeof(JSCClassVTable), alignof(JSCClassVTable)); 13 | printf("%s;%zu;%zu\n", "JSCContext", sizeof(JSCContext), alignof(JSCContext)); 14 | printf("%s;%zu;%zu\n", "JSCContextClass", sizeof(JSCContextClass), alignof(JSCContextClass)); 15 | printf("%s;%zu;%zu\n", "JSCException", sizeof(JSCException), alignof(JSCException)); 16 | printf("%s;%zu;%zu\n", "JSCExceptionClass", sizeof(JSCExceptionClass), alignof(JSCExceptionClass)); 17 | printf("%s;%zu;%zu\n", "JSCOptionType", sizeof(JSCOptionType), alignof(JSCOptionType)); 18 | printf("%s;%zu;%zu\n", "JSCTypedArrayType", sizeof(JSCTypedArrayType), alignof(JSCTypedArrayType)); 19 | printf("%s;%zu;%zu\n", "JSCValue", sizeof(JSCValue), alignof(JSCValue)); 20 | printf("%s;%zu;%zu\n", "JSCValueClass", sizeof(JSCValueClass), alignof(JSCValueClass)); 21 | printf("%s;%zu;%zu\n", "JSCValuePropertyFlags", sizeof(JSCValuePropertyFlags), alignof(JSCValuePropertyFlags)); 22 | printf("%s;%zu;%zu\n", "JSCVirtualMachine", sizeof(JSCVirtualMachine), alignof(JSCVirtualMachine)); 23 | printf("%s;%zu;%zu\n", "JSCVirtualMachineClass", sizeof(JSCVirtualMachineClass), alignof(JSCVirtualMachineClass)); 24 | printf("%s;%zu;%zu\n", "JSCWeakValue", sizeof(JSCWeakValue), alignof(JSCWeakValue)); 25 | printf("%s;%zu;%zu\n", "JSCWeakValueClass", sizeof(JSCWeakValueClass), alignof(JSCWeakValueClass)); 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /sys/tests/manual.h: -------------------------------------------------------------------------------- 1 | // Feel free to edit this file, it won't be regenerated by gir generator unless removed. 2 | 3 | #include 4 | --------------------------------------------------------------------------------