Skip to content

Commit c5912f9

Browse files
committed
Publish on cartes.io
1 parent b6edafb commit c5912f9

File tree

9 files changed

+47
-19
lines changed

9 files changed

+47
-19
lines changed

Cargo.toml

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
[package]
22

33
name = "string_cache"
4-
version = "0.0.0"
4+
version = "0.1.0"
55
authors = [ "The Servo Project Developers" ]
6+
description = "A string interning library for Rust, developed as part of the Servo project."
7+
license = "MIT / Apache-2.0"
8+
repository = "https://github.com/servo/string-cache"
69

710
[lib]
811
name = "string_cache"
@@ -28,3 +31,8 @@ optional = true
2831

2932
[dependencies.string_cache_plugin]
3033
path = "plugin"
34+
version = "0.1.1"
35+
36+
[dependencies.string_cache_shared]
37+
path = "shared"
38+
version = "0.1.0"

plugin/Cargo.toml

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
[package]
22

33
name = "string_cache_plugin"
4-
version = "0.0.0"
4+
version = "0.1.1"
55
authors = [ "The Servo Project Developers" ]
6+
description = "A string interning library for Rust, developed as part of the Servo project − compiler plugin."
7+
license = "MIT / Apache-2.0"
8+
repository = "https://github.com/servo/string-cache"
69

710
[lib]
811

912
name = "string_cache_plugin"
1013
plugin = true
1114

15+
[dependencies.string_cache_shared]
16+
path = "../shared"
17+
version = "0.1.0"
18+
1219
[dependencies]
1320
lazy_static = "0.1.10"
1421
mac = "0.0.2"

plugin/src/atom/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ use std::ascii::AsciiExt;
2020

2121
mod data;
2222

23-
#[path="../../../shared/repr.rs"]
24-
mod repr;
25-
2623
// Build a PhfOrderedSet of static atoms.
2724
// Takes no arguments.
2825
pub fn expand_static_atom_set(cx: &mut ExtCtxt, sp: Span, tt: &[TokenTree]) -> Box<MacResult+'static> {
@@ -74,7 +71,7 @@ fn make_atom_result(cx: &mut ExtCtxt, name: &str) -> Option<AtomResult> {
7471
None => return None,
7572
};
7673

77-
let data = repr::pack_static(*i as u32);
74+
let data = ::string_cache_shared::pack_static(*i as u32);
7875

7976
Some(AtomResult {
8077
expr: quote_expr!(&mut *cx, ::string_cache::atom::Atom { data: $data }),

plugin/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#![crate_type="dylib"]
1212

1313
#![feature(plugin_registrar, quote, box_syntax, static_assert)]
14-
#![feature(rustc_private, core, slice_patterns)]
14+
#![feature(rustc_private, slice_patterns)]
1515
#![deny(warnings)]
1616
#![allow(unused_imports)] // for quotes
1717

@@ -24,6 +24,8 @@ extern crate lazy_static;
2424
#[macro_use]
2525
extern crate mac;
2626

27+
extern crate string_cache_shared;
28+
2729
use rustc::plugin::Registry;
2830

2931
mod atom;

shared/Cargo.toml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
3+
name = "string_cache_shared"
4+
version = "0.1.0"
5+
authors = [ "The Servo Project Developers" ]
6+
description = "A string interning library for Rust, developed as part of the Servo project − shared code between the compiler plugin and main crate."
7+
license = "MIT / Apache-2.0"
8+
repository = "https://github.com/servo/string-cache"
9+
10+
[lib]
11+
12+
name = "string_cache_shared"
13+
path = "lib.rs"

shared/repr.rs renamed to shared/lib.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
//! the macros crate and the run-time library, in order to guarantee
1212
//! consistency.
1313
14-
#![allow(dead_code, unused_imports)]
14+
#![feature(core, static_assert)]
15+
#![deny(warnings)]
1516

1617
use std::{mem, raw, intrinsics};
1718
use std::slice::bytes;
@@ -44,7 +45,7 @@ const STATIC_SHIFT_BITS: usize = 32;
4445
#[inline(always)]
4546
unsafe fn inline_atom_slice(x: &u64) -> raw::Slice<u8> {
4647
#[static_assert]
47-
const IS_LITTLE_ENDIAN: bool = cfg!(target_endian = "little");
48+
const _IS_LITTLE_ENDIAN: bool = cfg!(target_endian = "little");
4849

4950
let x: *const u64 = x;
5051
raw::Slice {
@@ -82,7 +83,7 @@ impl UnpackedAtom {
8283
#[inline(always)]
8384
pub unsafe fn from_packed(data: u64) -> UnpackedAtom {
8485
#[static_assert]
85-
const DYNAMIC_IS_UNTAGGED: bool = DYNAMIC_TAG == 0;
86+
const _DYNAMIC_IS_UNTAGGED: bool = DYNAMIC_TAG == 0;
8687

8788
match (data & 0xf) as u8 {
8889
DYNAMIC_TAG => Dynamic(data as *mut ()),

src/atom/bench.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ macro_rules! bench_all (
135135
use std::iter::repeat;
136136

137137
use atom::Atom;
138-
use atom::repr::{Static, Inline, Dynamic};
138+
use string_cache_shared::{Static, Inline, Dynamic};
139139

140140
use super::mk;
141141

src/atom/mod.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,14 @@ use std::sync::Mutex;
2424
use std::sync::atomic::AtomicIsize;
2525
use std::sync::atomic::Ordering::SeqCst;
2626

27-
use self::repr::{UnpackedAtom, Static, Inline, Dynamic};
27+
use string_cache_shared::{self, UnpackedAtom, Static, Inline, Dynamic};
2828

2929
#[cfg(feature = "log-events")]
3030
use event::Event;
3131

3232
#[cfg(not(feature = "log-events"))]
3333
macro_rules! log (($e:expr) => (()));
3434

35-
#[path="../../shared/repr.rs"]
36-
pub mod repr;
3735

3836
// Needed for memory safety of the tagging scheme!
3937
const ENTRY_ALIGNMENT: usize = 16;
@@ -178,7 +176,7 @@ impl Atom {
178176
Some(id) => Static(id as u32),
179177
None => {
180178
let len = string_to_add.len();
181-
if len <= repr::MAX_INLINE_LEN {
179+
if len <= string_cache_shared::MAX_INLINE_LEN {
182180
let mut buf: [u8; 7] = [0; 7];
183181
bytes::copy_memory(string_to_add.as_bytes(), &mut buf);
184182
Inline(len as u8, buf)
@@ -198,7 +196,7 @@ impl Atom {
198196
unsafe {
199197
match self.unpack() {
200198
Inline(..) => {
201-
let buf = repr::inline_orig_bytes(&self.data);
199+
let buf = string_cache_shared::inline_orig_bytes(&self.data);
202200
str::from_utf8(buf).unwrap()
203201
},
204202
Static(idx) => *static_atom_set.index(idx as usize).expect("bad static atom"),
@@ -215,7 +213,7 @@ impl Clone for Atom {
215213
#[inline(always)]
216214
fn clone(&self) -> Atom {
217215
unsafe {
218-
match repr::from_packed_dynamic(self.data) {
216+
match string_cache_shared::from_packed_dynamic(self.data) {
219217
Some(entry) => {
220218
let entry = entry as *mut StringCacheEntry;
221219
(*entry).ref_count.fetch_add(1, SeqCst);
@@ -238,7 +236,7 @@ impl Drop for Atom {
238236
}
239237

240238
unsafe {
241-
match repr::from_packed_dynamic(self.data) {
239+
match string_cache_shared::from_packed_dynamic(self.data) {
242240
// We use #[unsafe_no_drop_flag] so that Atom will be only 64
243241
// bits. That means we need to ignore a NULL pointer here,
244242
// which represents a value that was moved out.
@@ -312,7 +310,7 @@ mod bench;
312310
mod tests {
313311
use std::thread;
314312
use super::Atom;
315-
use super::repr::{Static, Inline, Dynamic};
313+
use string_cache_shared::{Static, Inline, Dynamic};
316314

317315
#[test]
318316
fn test_as_slice() {

src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ extern crate rand;
3030
#[cfg(feature = "log-events")]
3131
extern crate rustc_serialize;
3232

33+
extern crate string_cache_shared;
34+
3335
pub use atom::Atom;
3436
pub use namespace::{Namespace, QualName};
3537

0 commit comments

Comments
 (0)