aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Wilm <joe@jwilm.com>2017-06-27 09:29:09 -0700
committerJoe Wilm <joe@jwilm.com>2017-06-27 09:29:09 -0700
commit63787d0bf0bcf18422b97aa7f8dea2024948c176 (patch)
tree2923904db81f6d90637120f9a3853daf701de344
parente675044cfc7e7348afe103ea44329b22a9a4427d (diff)
downloadalacritty-63787d0bf0bcf18422b97aa7f8dea2024948c176.tar.gz
alacritty-63787d0bf0bcf18422b97aa7f8dea2024948c176.zip
Use foreign-types from crates.io
We had previously vendored a very early version of this package before it was ever published.
-rw-r--r--Cargo.lock12
-rw-r--r--ffi-util/Cargo.toml6
-rw-r--r--ffi-util/src/lib.rs102
-rw-r--r--font/Cargo.lock26
-rw-r--r--font/Cargo.toml2
-rw-r--r--font/src/ft/list_fonts.rs41
-rw-r--r--font/src/lib.rs2
7 files changed, 58 insertions, 133 deletions
diff --git a/Cargo.lock b/Cargo.lock
index bc39a88c..86a34f14 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -305,10 +305,6 @@ dependencies = [
]
[[package]]
-name = "ffi-util"
-version = "0.1.0"
-
-[[package]]
name = "filetime"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -330,7 +326,7 @@ dependencies = [
"core-graphics 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
"core-text 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "ffi-util 0.1.0",
+ "foreign-types 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"freetype-rs 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -338,6 +334,11 @@ dependencies = [
]
[[package]]
+name = "foreign-types"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
name = "freetype-rs"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1279,6 +1280,7 @@ dependencies = [
"checksum expat-sys 2.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cef36cd1a8a02d28b91d97347c63247b9e4cb8a8e36df36f8201dc87a1c0859c"
"checksum filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "5363ab8e4139b8568a6237db5248646e5a8a2f89bd5ccb02092182b11fd3e922"
"checksum fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6cc484842f1e2884faf56f529f960cc12ad8c71ce96cc7abba0a067c98fee344"
+"checksum foreign-types 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3e4056b9bd47f8ac5ba12be771f77a0dae796d1bbaaf5fd0b9c2d38b69b8a29d"
"checksum freetype-rs 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a1418e2a055fec8efe18c1a90a54b2cf5e649e583830dd4c71226c4e3bc920c6"
"checksum freetype-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eccfb6d96cac99921f0c2142a91765f6c219868a2c45bdfe7d65a08775f18127"
"checksum fs2 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "bcd414e5a1a979b931bb92f41b7a54106d3f6d2e6c253e9ce943b7cd468251ef"
diff --git a/ffi-util/Cargo.toml b/ffi-util/Cargo.toml
deleted file mode 100644
index 740a3b95..00000000
--- a/ffi-util/Cargo.toml
+++ /dev/null
@@ -1,6 +0,0 @@
-[package]
-name = "ffi-util"
-version = "0.1.0"
-authors = ["Joe Wilm <joe@jwilm.com>"]
-
-[dependencies]
diff --git a/ffi-util/src/lib.rs b/ffi-util/src/lib.rs
deleted file mode 100644
index be82e560..00000000
--- a/ffi-util/src/lib.rs
+++ /dev/null
@@ -1,102 +0,0 @@
-// Copyright 2011 Google Inc.
-// 2013 Jack Lloyd
-// 2013-2014 Steven Fackler
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-use std::cell::UnsafeCell;
-
-/// This is intended to be used as the inner type for `FooRef` types converted from raw C pointers.
-/// It has an `UnsafeCell` internally to inform the compiler about aliasability and doesn't
-/// implement `Copy`, so it can't be dereferenced.
-pub struct Opaque(UnsafeCell<()>);
-
-/// A type implemented by wrappers over foreign types.
-///
-/// This should not be implemented by anything outside of this crate; new methods may be added at
-/// any time.
-pub trait ForeignType: Sized {
- /// The raw C type.
- type CType;
-
- /// The type representing a reference to this type.
- type Ref: ForeignTypeRef<CType = Self::CType>;
-
- /// Constructs an instance of this type from its raw type.
- unsafe fn from_ptr(ptr: *mut Self::CType) -> Self;
-}
-
-/// A trait implemented by types which reference borrowed foreign types.
-///
-/// This should not be implemented by anything outside of this crate; new methods may be added at
-/// any time.
-pub trait ForeignTypeRef: Sized {
- /// The raw C type.
- type CType;
-
- /// Constructs a shared instance of this type from its raw type.
- unsafe fn from_ptr<'a>(ptr: *mut Self::CType) -> &'a Self {
- &*(ptr as *mut _)
- }
-
- /// Constructs a mutable reference of this type from its raw type.
- unsafe fn from_ptr_mut<'a>(ptr: *mut Self::CType) -> &'a mut Self {
- &mut *(ptr as *mut _)
- }
-
- /// Returns a raw pointer to the wrapped value.
- fn as_ptr(&self) -> *mut Self::CType {
- self as *const _ as *mut _
- }
-}
-
-#[macro_export]
-macro_rules! ffi_type {
- ($n:ident, $r:ident, $c:path, $d:path) => {
- pub struct $n(*mut $c);
-
- impl $crate::ForeignType for $n {
- type CType = $c;
- type Ref = $r;
-
- unsafe fn from_ptr(ptr: *mut $c) -> $n {
- $n(ptr)
- }
- }
-
- impl Drop for $n {
- fn drop(&mut self) {
- unsafe { $d(self.0) }
- }
- }
-
- impl ::std::ops::Deref for $n {
- type Target = $r;
-
- fn deref(&self) -> &$r {
- unsafe { $crate::ForeignTypeRef::from_ptr(self.0) }
- }
- }
-
- impl ::std::ops::DerefMut for $n {
- fn deref_mut(&mut self) -> &mut $r {
- unsafe { $crate::ForeignTypeRef::from_ptr_mut(self.0) }
- }
- }
-
- pub struct $r($crate::Opaque);
-
- impl $crate::ForeignTypeRef for $r {
- type CType = $c;
- }
- }
-}
diff --git a/font/Cargo.lock b/font/Cargo.lock
index 68d6bb87..28434a2e 100644
--- a/font/Cargo.lock
+++ b/font/Cargo.lock
@@ -4,10 +4,10 @@ version = "0.1.0"
dependencies = [
"core-foundation 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "core-graphics 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "core-text 4.0.0 (git+https://github.com/servo/core-text-rs?rev=7a267bc8f6c098f5370583333a5fd00a0d12fb83)",
+ "core-graphics 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "core-text 5.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "ffi-util 0.1.0",
+ "foreign-types 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"freetype-rs 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -38,21 +38,21 @@ dependencies = [
[[package]]
name = "core-graphics"
-version = "0.7.0"
+version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
+ "bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde 0.9.15 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "core-text"
-version = "4.0.0"
-source = "git+https://github.com/servo/core-text-rs?rev=7a267bc8f6c098f5370583333a5fd00a0d12fb83#7a267bc8f6c098f5370583333a5fd00a0d12fb83"
+version = "5.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"core-foundation 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "core-graphics 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "core-graphics 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -78,8 +78,9 @@ dependencies = [
]
[[package]]
-name = "ffi-util"
-version = "0.1.0"
+name = "foreign-types"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "freetype-rs"
@@ -201,10 +202,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1370e9fc2a6ae53aea8b7a5110edbd08836ed87c88736dfabccade1c2b44bff4"
"checksum core-foundation 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f51ce3b8ebe311c56de14231eb57572c15abebd2d32b3bcb99bcdb9c101f5ac3"
"checksum core-foundation-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "41115a6aa5d3e1e5ef98148373f25971d1fad53818553f216495f9e67e90a624"
-"checksum core-graphics 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ead017dcf77f503dc991f6b52de6084eeea60a94b0a652baa9bf88654a28e83f"
-"checksum core-text 4.0.0 (git+https://github.com/servo/core-text-rs?rev=7a267bc8f6c098f5370583333a5fd00a0d12fb83)" = "<none>"
+"checksum core-graphics 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a9f841e9637adec70838c537cae52cb4c751cc6514ad05669b51d107c2021c79"
+"checksum core-text 5.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7c42ae17408d6b881992268f638257e67303fc7c6c88723dbc0fe5889b22c0bc"
"checksum euclid 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba6ab6f0e63a602978f4b8cf8a43f87a1a475ddf32407f087d579a13cf06b114"
"checksum expat-sys 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4ccf6f838594c1571f176f0afdbeb9cfa9f83b478f269d3f0390939b1df4323e"
+"checksum foreign-types 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3e4056b9bd47f8ac5ba12be771f77a0dae796d1bbaaf5fd0b9c2d38b69b8a29d"
"checksum freetype-rs 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a1418e2a055fec8efe18c1a90a54b2cf5e649e583830dd4c71226c4e3bc920c6"
"checksum freetype-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eccfb6d96cac99921f0c2142a91765f6c219868a2c45bdfe7d65a08775f18127"
"checksum gcc 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)" = "3da3a2cbaeb01363c8e3704fd9fd0eb2ceb17c6f27abd4c1ef040fb57d20dc79"
diff --git a/font/Cargo.toml b/font/Cargo.toml
index 17ba78ed..98c7eaad 100644
--- a/font/Cargo.toml
+++ b/font/Cargo.toml
@@ -8,7 +8,7 @@ license = "Apache-2.0"
[dependencies]
euclid = "0.12.0"
libc = "0.2"
-ffi-util = { path = "../ffi-util" }
+foreign-types = "0.2.0"
log = "0.3"
[target.'cfg(not(target_os = "macos"))'.dependencies]
diff --git a/font/src/ft/list_fonts.rs b/font/src/ft/list_fonts.rs
index 5fa40ac8..7fdf6250 100644
--- a/font/src/ft/list_fonts.rs
+++ b/font/src/ft/list_fonts.rs
@@ -19,7 +19,7 @@ pub mod fc {
use std::ops::Deref;
use std::path::PathBuf;
- use ffi_util::{ForeignType, ForeignTypeRef};
+ use foreign_types::{ForeignType, ForeignTypeRef};
use libc::{c_char, c_int};
use fontconfig::fontconfig as ffi;
@@ -47,11 +47,40 @@ pub mod fc {
current: usize,
}
- ffi_type!(Pattern, PatternRef, FcPattern, FcPatternDestroy);
- ffi_type!(Config, ConfigRef, FcConfig, FcConfigDestroy);
- ffi_type!(ObjectSet, ObjectSetRef, FcObjectSet, FcObjectSetDestroy);
- ffi_type!(FontSet, FontSetRef, FcFontSet, FcFontSetDestroy);
- ffi_type!(CharSet, CharSetRef, FcCharSet, FcCharSetDestroy);
+ foreign_type! {
+ type CType = FcPattern;
+ fn drop = FcPatternDestroy;
+ pub struct Pattern;
+ pub struct PatternRef;
+ }
+
+ foreign_type! {
+ type CType = FcConfig;
+ fn drop = FcConfigDestroy;
+ pub struct Config;
+ pub struct ConfigRef;
+ }
+
+ foreign_type! {
+ type CType = FcObjectSet;
+ fn drop = FcObjectSetDestroy;
+ pub struct ObjectSet;
+ pub struct ObjectSetRef;
+ }
+
+ foreign_type! {
+ type CType = FcFontSet;
+ fn drop = FcFontSetDestroy;
+ pub struct FontSet;
+ pub struct FontSetRef;
+ }
+
+ foreign_type! {
+ type CType = FcCharSet;
+ fn drop = FcCharSetDestroy;
+ pub struct CharSet;
+ pub struct CharSetRef;
+ }
impl ObjectSet {
#[allow(dead_code)]
diff --git a/font/src/lib.rs b/font/src/lib.rs
index f04f00d8..4d63c7f3 100644
--- a/font/src/lib.rs
+++ b/font/src/lib.rs
@@ -36,7 +36,7 @@ extern crate libc;
#[cfg(not(target_os = "macos"))]
#[macro_use]
-extern crate ffi_util;
+extern crate foreign_types;
#[macro_use]
extern crate log;