Граф коммитов

1732 Коммитов

Автор SHA1 Сообщение Дата
Arjen 2c003b16d1
Change doc-comments in templates to comments (#2338) 2024-11-29 21:51:00 +01:00
Arjen 5642c06cbd
Fix comments in generated Rust code (#2337) 2024-11-29 10:56:41 -05:00
尹吉峰 a31d4f8aa2
docs: `[External]` argument is required (#2336) 2024-11-28 10:38:46 -05:00
jhugman 9d2b55dba4
Make all extern C functions public (#2329) 2024-11-28 10:22:36 -05:00
Mark Hammond aa200a689a
uniffi::use_remote_type uses 'crate::name' form to specify types. (#2325) 2024-11-22 22:58:43 -05:00
Mark Hammond e0fd13ffbf
Tests to show that #1865 fixes #1854 (#2326) 2024-11-21 15:50:29 -05:00
Mark Hammond 68701de080
Consistently use `uniffi::use_remote_type!()` and have the crate name before the type name (#2323) 2024-11-19 13:52:53 -05:00
bendk 119061559e
Merge pull request #2322 from bendk/push-xutoqvokqwzy
Clippy fix
2024-11-19 09:13:39 -05:00
Ben Dean-Kawamura 8055fd0abb Clippy fix
Fixing clippy error from #2320.
2024-11-19 08:44:45 -05:00
bendk f8671d19d7
Merge pull request #2320 from crazytonyli/swift/try-multiple-swift-format-commands
Try different commands to run `swift-format`
2024-11-18 16:57:22 -05:00
Tony Li a791a6b788
Remove the '--find' argument 2024-11-19 10:35:20 +13:00
Tony Li 8128e47aba
Only print error messages if all swift-format commands fail 2024-11-19 10:31:29 +13:00
bendk 9c796dcc6c
Merge pull request #2317 from bendk/push-mrsmomxnyrru
Common system for remote type handling (#1865)
2024-11-18 10:08:56 -05:00
Ben Dean-Kawamura 10ac4b5541 Common system for remote type handling (#1865)
Remote types present an issue because we can't implement FFI traits like
`Lower` and `Lift` on them directly.  The workaround is to only
implement the FFI trait for the current crate.  If another crate
wants to use that impl, we need to implement it again by forwarding to
the initial implementation.

Historically, UDL and proc-macros have approached this differently which
has lead to a lot of extra complexity and confusion.  This change aligns
them on a common system:  By default, we implement traits for all crates
(a "blanket impl").  However, users can opt-in to only implementing it
for the current crate ("a local impl`)

See the doc changes for a description of the new system.

This required a bunch of changes:

- UDL now creates a blanket impl by default. The [Remote] attribute can
  be used to switch to a local impl.
- Proc-macros get the `#[remote]` attribute macro, which allows users to
  create a local impl.
- Custom types now create a blanket impl by default.  The `remote`
  parameter can be used to create a local impl.
- Added the `remote_type!` macro to which handles the case where you
  want to use a remote type and another crate has already created a
  local impl.  This creates a local impl for your crate by forwarding to
  the other impl.  Removed the `use_udl_*` macros, which were a kludge
  for doing the same thing.

Added a motivating example where `anyhow::Error` is used as an error
type.  Changed the error type bound to `Display + Debug` rather than
`Error`. For some reason `anyhow::Error` doesn't actually implement
error.

One feature that we've lost in defining callback/trait interfaces using
traits defined in a remote crate.  I think this is okay because I doubt
anyone is using that feature.
2024-11-18 10:07:21 -05:00
Tony Li e183fee105
Try different commands to run `swift-format` 2024-11-18 22:19:46 +13:00
bendk e796e00ad1
Merge pull request #2314 from bendk/push-npxvlyzoqklk
Merging changes from 0.28.3 back into main
2024-11-15 10:49:20 -05:00
Mark Hammond 761ff60ffb
Clean up filters and error handling in the bindings. (#2316)
* Using anyhow in templates works fine, so start doing that for literals,
  replacing a number of panics with errors.

* Filters can't return anyhow, so add better helpers for converting &str
  and anyhow::Error to rinja::Error.

* Other shared filters weren't used consistently and add no value so are removed.
2024-11-15 10:24:14 -05:00
Ben Dean-Kawamura 7c37987742 Merging changes from 0.28.3 back into main 2024-11-14 18:45:21 -05:00
bendk de6eef9dba
Merge pull request #2294 from bendk/push-wsnlxtoqmvxy
Fix some more Swift concurrency issues
2024-11-14 17:40:30 -05:00
bendk 245063790f
Merge pull request #2304 from bendk/push-yxxssqtkvpqv
Fix logging entry in CHANGELOG (#2301)
2024-11-13 09:59:21 -05:00
bendk 901eb9c5b6
Merge pull request #2306 from bendk/push-yrmpkppoxmot
More FFI tracing
2024-11-12 14:33:08 -05:00
Mark Hammond d6303d30af Typo in tutorial markdown caused 404 on docs site 2024-11-11 11:31:54 +01:00
Ben Dean-Kawamura 32e6a737b9 More FFI tracing
I added these while trying to figure out the swift tests were failing on
my machine.  It seems like it might actually be a swift issue (see
#2305), but I still think these are useful.
2024-11-09 20:04:16 -05:00
Ben Dean-Kawamura 8f7c2f5dba Fix logging entry in CHANGELOG (#2301)
This wasn't released in 0.28.2.
2024-11-09 12:45:46 -05:00
bendk 1a4a949da1
Merge pull request #2298 from bendk/push-qpwmlrronqry
Add couple methods to Constructor/Method
2024-11-08 10:03:29 -05:00
Ben Dean-Kawamura fbe4c16d00 Add couple methods to Constructor/Method
These are useful, but we've never exposed them.
2024-11-07 17:02:59 -05:00
Mark Hammond b7b3880675
Kotlin classes can inherit from traits. (#2297)
Builds on #2204 which landed the metadata and Python support.

Also fixes minor issues with `CallbackInterface` types.
2024-11-06 23:04:27 -05:00
Martin Geisler fc336df13c
Make panic section more precise for `RustBuffer::len` (#2167)
The panic condition seems to be a mismatch between the foregin code and the size of `usize` on the platform.
2024-11-06 22:33:34 -05:00
jhugman 97553d0d5b
Add React Native to README.md (#2289) 2024-11-06 22:30:34 -05:00
Ben Dean-Kawamura 2b05c3d14f Fix some more Swift concurrency issues
Converted some more vars to lets.  Swift still complains about async
calls.  I believe the next step would be to make all UniFFI objects
conform to `Sendable`.

Split the `FfiType::Reference` variant into `Reference` and
`MutReference`.  This allows us to define some more variables using
`let` in swift.

See #2279.
2024-11-01 09:46:20 -04:00
bendk 1c8dd50de3
Merge pull request #2293 from bendk/push-kxytlxwywyuo
Add `Callable::ffi_func`
2024-10-31 15:02:10 -04:00
Ben Dean-Kawamura 231bf9af01 Add `Callable::ffi_func`
All the callable types implement this, so let's add it to the trait.  I
want to use this eventually for the Gecko JS bindings.
2024-10-31 14:28:29 -04:00
Joseph Heck b42812f489
render swift global variable as a constant (#2290)
more correctly handles swift6 data race concerns
2024-10-31 09:37:12 -04:00
Mark Hammond 09bc9e9084
Remove unused uniffi_bindgen::backend::types module. (#2288)
We said we'd probably kill it after 0.26.x, so here we are.
2024-10-29 09:22:00 -04:00
bendk 1279b4739e
Merge pull request #2150 from bendk/custom-type-only-rework
New custom type system
2024-10-25 14:39:31 -04:00
Ben Dean-Kawamura 4de0a3a047 New custom type system
Implemented a new custom type system described in the new docs.  This
system is easier to use and also allows us to do some extra tricks
behind the scene.  For example, I hope to add a flag that will toggle
between implementing `FfiConverter` for the local tag vs a blanket impl.
It's not possible to do that with the current system and adding support
would be awkward.

I wanted to keep backwards compatibility for a bit, but couldn't figure
out a good way to do it.  The main issue is that for the old system, if
a custom type is declared in the UDL then we generate the `FfiConverter`
implementation, while the new system expects the user to call
`custom_type!` to create the impl.  I tried to get things working by
creating a blanket impl of `FfiConverter` for types that implemented
`UniffiCustomTypeConverter`, but ran into issues -- the first blocker I
found was that there's no way to generate `TYPE_ID_META` since we don't
know the name of the custom type.

Removed the nested-module-import fixture.  The custom type code will no
longer test it once we remove the old code, since it's not using
`UniffiCustomTypeConverter`.  I couldn't think of a way to make it work
again.
2024-10-25 14:15:57 -04:00
bendk 279a587c95
Merge pull request #2286 from bendk/push-nmmotszxnykz
Fix metadata extraction for large ELF files (#2285)
2024-10-25 11:21:39 -04:00
Ben Dean-Kawamura 111aa07456 Fix metadata extraction for large ELF files (#2285)
Symbol table entries store a 16-bit index for their section header.  If
the index overflows 16-bits then it's stored in a separate section
instead.

References:

- https://refspecs.linuxbase.org/elf/gabi4+/ch4.symtab.html
- https://docs.oracle.com/cd/E19683-01/817-3677/chapter6-94076/index.html
2024-10-25 09:26:01 -04:00
bendk 5a60a28813
Merge pull request #2284 from Tuurlijk/patch-1
Update Prerequisites.md
2024-10-24 14:04:59 -04:00
Michiel Roos 46ba1cda47
Update Prerequisites.md
uniffi dependency needs cli feature
2024-10-24 11:00:15 +02:00
Mark Hammond 881d57cf9c
Update template pattern matching to leverage rinja. (#2280)
Mostly using `{ .. }`, `if let`, and `when Some with (x)` -> `when Some(x)`
2024-10-22 09:58:57 -04:00
Guillaume Gomez bd14951187
Switch from askama to rinja (#2222) 2024-10-18 20:20:26 -04:00
bendk a8da0375b6
Merge pull request #2275 from bendk/push-nyotxxtlunrt
Remove log crate dependency
2024-10-17 12:02:59 -04:00
Tim Boudreau 4e106e191d Remove log crate dependency
Instead we can use the `trace!` macro to log details about FFI calls. By
default, it's compiled out but the `ffi-trace` feature can be used to
enable it. These tracing printouts are only really useful for debugging
failures when writing scaffolding/bindings code.

Addresses #2224 - even disabled logging can have overhead depending with some backends, and
in very high frequency calls, generates unacceptable overhead and log-spam.
2024-10-16 15:14:45 -04:00
bendk 9e1b120e32
Merge pull request #2211 from bendk/push-oynonqnuxvxp
2210: Tracing printouts for FFI calls
2024-10-16 14:56:52 -04:00
Mark Hammond 7f41fd8056
Tutorial tweaks making procmacro docs a little clearer (#2271) 2024-10-15 21:15:36 -04:00
Mark Hammond 8a14c06aee
Remove Python var_name and class_name filters (#2270) 2024-10-15 17:04:55 -04:00
Mark Hammond c4963eccd0
Record metadata for a struct implementing a trait. (#2204)
```
#[uniffi::export]
impl MyTrait for MyObject { ... }
```

Previously worked as it ignored `MyTrait`. This adds new metadata to record it,
allowing foreign bindings to implement things like inheritance.

Includes Python generating an inheritance chain to reflect this relationship.

This will not generate correct code if a struct declares more than 1 trait,
and there's some undesirable re-wrapping when traits from these objects gets
passed back and forward, but seems to work surprisingly well.

Fixes #2196.
2024-10-15 15:31:14 -04:00
Mark Hammond 82d11879fc
Move old and dated authors entries from Cargo.tomls (#2272) 2024-10-15 09:38:09 -04:00
Herman c344737d7c Fix broken links in callbacks example 2024-10-15 11:00:21 +02:00