Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
yury committed Dec 18, 2023
1 parent 0650b08 commit 8fc4300
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions cidre/src/cf/date.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{arc, cf, define_cf_type};
use std::ffi::{c_double, c_void};
use std::ffi::c_void;

pub type TimeInterval = c_double;
pub type TimeInterval = std::ffi::c_double;
pub type AbsTime = TimeInterval;

/// The current absolute time.
Expand Down
18 changes: 13 additions & 5 deletions cidre/src/cf/url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::{arc, cf, define_cf_type};
#[cfg(feature = "ns")]
use crate::ns;

#[doc(alias = "CFURLPathStyle")]
#[derive(Debug, PartialEq, Eq)]
#[repr(isize)]
pub enum PathStyle {
Expand Down Expand Up @@ -80,7 +81,6 @@ impl Url {
/// let url = cf::Url::from_str("http://google.com").unwrap();
///
/// let scheme = url.scheme().unwrap();
///
/// ```
#[inline]
pub fn from_str(str: &str) -> Option<arc::R<Url>> {
Expand All @@ -100,7 +100,6 @@ impl Url {
/// let url = cf::Url::from_cf_string(&s1).unwrap();
///
/// assert!(url.can_be_decomposed());
///
/// ```
#[inline]
pub fn from_cf_string(str: &cf::String) -> Option<arc::R<Url>> {
Expand All @@ -121,16 +120,19 @@ impl Url {
/// assert!(s1.equal(s2));
///
/// ```
#[doc(alias = "CFURLGetString")]
#[inline]
pub fn cf_string(&self) -> &cf::String {
unsafe { CFURLGetString(self) }
}

#[doc(alias = "CFURLGetBaseURL")]
#[inline]
pub fn base_url(&self) -> Option<&Url> {
unsafe { CFURLGetBaseURL(self) }
}

#[doc(alias = "CFURLCanBeDecomposed")]
#[inline]
pub fn can_be_decomposed(&self) -> bool {
unsafe { CFURLCanBeDecomposed(self) }
Expand All @@ -157,7 +159,6 @@ impl Url {
/// let url1 = cf::Url::from_str("https://localhost:3000").unwrap();
///
/// assert_eq!(3000, url1.port());
/// let url2 = cf::Url::from_str("https://localhost").unwrap();
///
/// assert_eq!(-1, url2.port());
Expand All @@ -174,18 +175,26 @@ impl Url {
pub fn as_ns(&self) -> &ns::Url {
unsafe { std::mem::transmute(self) }
}

#[doc(alias = "CFURLCopyAbsoluteURL")]
#[inline]
pub fn abs_url(&self) -> Option<arc::R<Self>> {
unsafe { CFURLCopyAbsoluteURL(self) }
}
}

#[link(name = "CoreFoundation", kind = "framework")]
extern "C" {
fn CFURLGetTypeID() -> cf::TypeId;

fn CFURLCreateWithBytes(
allocator: Option<&cf::Allocator>,
url_bytes: *const u8,
length: cf::Index,
encoding: cf::StringEncoding,
base_url: Option<&Url>,
) -> Option<arc::R<Url>>;

fn CFURLCreateWithString(
allocator: Option<&cf::Allocator>,
url_string: &cf::String,
Expand All @@ -201,9 +210,8 @@ extern "C" {

fn CFURLGetString(anURL: &Url) -> &cf::String;
fn CFURLGetBaseURL(anURL: &Url) -> Option<&Url>;

fn CFURLCanBeDecomposed(anURL: &Url) -> bool;
fn CFURLCopyScheme(anURL: &Url) -> Option<arc::R<cf::String>>;

fn CFURLGetPortNumber(anURL: &Url) -> i32;
fn CFURLCopyAbsoluteURL(relativeURL: &Url) -> Option<arc::R<cf::Url>>;
}

0 comments on commit 8fc4300

Please # to comment.