Commit Graph

184 Commits

Author SHA1 Message Date
Bruce Mitchener f23baea603 Fix clippy::needless_lifetimes lints (#717)
* Fix `clippy::needless_lifetimes` lints

* Fix `clippy::doc_markdown` lints
2025-01-08 05:20:49 +00:00
Tyler Mandry 9d8c74ea34 Fix TCFType macros for generic types (#652)
* Improve TCFType macros

This adds the following new features:

* `declare_TCFType!`: Generics are accepted.
* `impl_TCFType!`: Non-defaulted generics are accepted, and impls are
  fixed to be for all generics.

In addition, some warnings are silenced and the macros no longer depend
on any traits being in scope in the caller.

* Support generics in impl_CFComparison

* Add generic test for macros
2024-08-13 11:13:17 +00:00
Bruce Mitchener fb71d45b30 Enable clippy, suppress lots, fix a couple. (#703)
This enables clippy in CI and suppresses most of the existing
warnings. We can drill down and fix those later, but this will
help start getting things under control.
2024-08-13 04:25:49 +00:00
Bruce Mitchener 84b8365425 Use CFIndex::MAX rather than CFIndex::max_value() (#699)
Since `CFIndex` is just `isize`, we can use the `CFIndex::MAX`
constant. The `max_value` and other functions are pending
deprecation and cause a clippy lint warning.
2024-08-12 02:42:23 +00:00
Bruce Mitchener 9f33b121fb Use core::ffi over std::os::raw and libc::c_* (#692)
`core::ffi` is the preferred way to access these type definitions.
Begin removing uses of the versions from `libc`.

`libc::c_void` is not exactly the same as `core::ffi::c_void` but
some code has tried using them interchangeably (like in io-surface).

`libc::size_t` is `usize` on all current platforms.
2024-08-11 20:24:22 +00:00
Bruce Mitchener 31a92cd2fc Fix typos. (#689) 2024-07-20 10:26:35 +00:00
Kornel 3570256ecc Avoid UB if the CFData pointer is NULL (#688) 2024-07-14 17:50:44 +00:00
Bruce Mitchener 6940925635 Remove remaining chrono code. (#682)
In 9721646053, the `with-chrono`
feature was removed, but this dead code lingered.
2024-05-27 07:01:47 +00:00
Bruce Mitchener 8d2b732db5 Remove usages of extern crate. (#672) 2024-05-27 06:40:54 +00:00
Bruce Mitchener 48d6bdf9be Update uuid dep to 1.x (#228)
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2024-04-09 11:00:07 +00:00
Dirkjan Ochtman 9721646053 foundation: remove optional chrono dependency (#666)
* foundation: remove optional chrono dependency

* Bump version numbers for semver-incompatible changes
2024-04-08 10:20:45 +00:00
Bruce Mitchener 58972aef0a Update to 2018 edition. (#642)
This is the minimum fix required. It updates to use crate-relative
imports.
2023-10-24 00:30:22 +00:00
Bruce Mitchener 3ff7cc2795 docs: Fix various markdown issues. (#639) 2023-10-10 15:22:46 +00:00
Bruce Mitchener 18df9aafe7 Some clippy fixes. (#624) 2023-08-03 14:20:26 +00:00
micolous b009c87f2d Auto-format code with "cargo fmt" and check in CI (#615)
* add rustfmt check to CI

* Run "cargo fmt" (rustfmt) over core-foundation-rs
2023-07-25 02:22:25 +00:00
Jeff Muizelaar 127f2be94c Revert "mach_port: Removed redundant pub use" (#620)
This reverts commit 6d00383baf.

It broke semver because it removed the export of CFIndex which
which older versions of the core-foundation crate are depending on.

Fixes #619
2023-07-24 17:00:42 +00:00
Michael Farrell a1df3385f7 mark CFRunLoop as Send+Sync, and test it 2023-07-11 11:42:29 +10:00
Jeff Muizelaar d10ad8dead Get tests passing on macOS 13
macOS 13 uses NSTaggedPointerString for short CFStrings
which means the retain counts aren't meaningful. Increasing the length
of the strings avoids this.

Empty arrays also seem to refer to a shared constant object that
doesn't have meaningful retain counts either.

Fixes #597
2023-06-20 09:49:19 -04:00
michaelwright235 6d00383baf mach_port: Removed redundant pub use 2023-05-29 22:31:11 +03:00
Jeff Muizelaar 91ff2cb513 Remove filedescriptor test_consumed
This test was failing intermittently on github actions.

There's no safe way to check that a file descriptor has been closed,
because a new file could have been reopened with the same number. We'd
then end up closing that new file instead of having close() fail.
2021-10-28 10:22:43 -04:00
Marco Mastropaolo d83794c3ab Adds run_in_mode wrapper over CFRunLoopRunInMode 2021-08-16 10:28:04 +02:00
bors-servo f7e0b97e0b Auto merge of #436 - AsafFisher:master, r=jrmuizel
Add CGEventTap

https://github.com/servo/core-graphics-rs/issues/111
2021-05-26 13:18:34 -04:00
Jeff Muizelaar ce17c9aa59 Add CFData::from_arc
This allows creating a zero-copy CFData wrapping existing data.
2021-02-14 11:52:04 -05:00
Asaf Fisher edb187a17c core-foundation: Add basic CFMachPort 2021-01-23 03:24:30 +02:00
Jeff Muizelaar d30dd87bbd Implement Debug on the generic CFArray
This is the same kind of thing as #423
2020-12-21 16:45:49 -05:00
Jeff Muizelaar e7c5320639 Increase the threshold of acceptible values.
This test sometimes fails on github actions.
2020-11-03 09:20:04 -05:00
bors-servo 29588625c7 Auto merge of #423 - jrmuizel:dict-debug, r=emilio
Implement Debug on the generic CFDictionary
2020-10-29 20:48:32 -04:00
Jeff Muizelaar 2ee8facbd6 Implement Debug on the generic CFDictionary 2020-10-27 17:22:26 -04:00
Jeff Muizelaar faf0d7c0ff Implement Debug on CFPropertyList 2020-10-26 23:11:12 -04:00
Yu Shimura 437be24cdb CFBundleCopyResourcesDirectoryURL 2020-10-14 11:10:39 +09:00
Bryan Burgers a4e2983219 Add CFTimeZone::name
Add a `name` method to `CFTimeZone` to get the time zone ID (e.g.,
"America/Los_Angeles") of the current time zone.

Core Foundation calls this "name" instead of "id" in its method
signatures, but acknowledges it in the closely-related NSTimeZone
related docs. Since most of the other methods in this library match
closely with CF naming, also use `name` here.

> Time zone database entries such as “America/Los_Angeles” are IDs, not
> names. An example of a time zone name is “Pacific Daylight Time”.
> Although many NSTimeZone symbols include the word “name”, they
> actually refer to IDs.
2020-06-29 07:18:58 -05:00
bors-servo 01d6921340 Auto merge of #363 - roblabla:fix-missing-null-checks, r=jdm
Assert when creating a CFType from null

What's the reason behind IOSurface not using `impl_TCFType`? It feels dangerous not to use it.

Fixes #361
2020-05-17 13:01:30 -04:00
bors-servo 14ee94aef7 Auto merge of #359 - roblabla:cfset-missing-methods, r=jdm
CFSet: Add missing methods in -sys

Adds a handful of missing methods from the CFSet family.
2020-05-17 12:50:08 -04:00
bors-servo 4b765df60c Auto merge of #378 - kornelski:compstr, r=jdm
Make CFString comparable

Fixes #104

The `PartialEq` has to be on `CFString`, not `CFStringRef` due to orphan rules.
2020-05-08 11:56:31 -04:00
Kornel be0c03033b Test 64-bit NSNumbers 2020-05-08 14:07:03 +01:00
Kornel 977d4bbebd Make CFString comparable 2020-05-08 13:03:14 +01:00
Kornel 6ded5c360f CFBundleCopyBundleURL 2020-05-08 11:38:31 +01:00
brunohgouveia b68e9c782a Change CFMutableAttributedString::set_attribute argument type 2020-04-17 20:35:11 +01:00
roblabla 63a8dc37c3 CFSet: Add missing methods in -sys 2020-03-21 18:34:08 +00:00
roblabla bf5977f007 Assert when creating a CFType from null 2020-03-21 18:33:22 +00:00
Vasiliy Badanov aa6d1cd4c1 Fix for link error "Undefined symbols for architecture x86_64: _CFMutableAttributedStringGetTypeID" 2020-02-21 23:40:36 +03:00
Max Brunsfeld d95d3fa743 Fix miscellaneous compile warnings 2020-01-08 20:47:41 -08:00
bors-servo 0a3ac83c1b Auto merge of #349 - wez:timertypes, r=jdm
Fix CFRunLoop types to avoid UB

A number of callback functions associated with the CFRunLoop types are
allowed to be NULL to evoke default behavior.

Prior to this commit the definition of those structs prevented passing
in null which meant resorting to transmute or other tricks to
effectively set null, but with recent compiler versions the compiler
emits `ud2` instructions and triggers a fault at runtime.

The correct resolution for this is to define these fields as `Option`al
callbacks and that is what this commit does.

I've used this approach successfully here in another project:
Refs: https://github.com/wez/wezterm/commit/398f333c32fb1ff4ccd9cc001a66ae22522eb60c

I've bumped up the version for the crate as part of this commit
because it effectively changes the API around these structs.
2019-11-12 18:08:51 -05:00
Qifan Lu 83b6f5d20a Use zero-initialized array in CFURL::to_path 2019-11-12 12:37:41 -08:00
Wez Furlong 3126f15fd6 adjust test 2019-11-11 22:46:10 -08:00
Qifan Lu 727837f12e Use MaybeUninit instead of mem::uninitialized 2019-11-11 20:55:59 -08:00
Wesley Moore ad416b4890 Add CFCharacterSet to core-foundation 2019-10-10 15:35:21 +11:00
Eike Siewertsen 1a0e69872a add shared_support_url to CFBundle 2019-08-05 10:50:58 +02:00
Jeff Muizelaar 87bd8a4d1a Add an unsafe method to convert CFDictionary to CFMutableDictionary 2019-03-28 18:02:12 -04:00
Bruce Mitchener 0fbabb35e9 Use assert_eq! when possible instead of assert! 2019-03-21 21:55:00 +07:00