Bug 1403213 - Move nsstring into servo/support/gecko/nsstring, r=froydnj
☠☠ backed out by becff95c9e4c ☠ ☠
authorNika Layzell <nika@thelayzells.com>
Fri, 20 Oct 2017 12:04:30 -0700
changeset 440664 74c58b336d30628e14b8ed735ae2d6dbe6cf6bbd
parent 440663 a550fea9a6cd8b479aba174826b19b401161ad8d
child 440665 75fc6292ea459d1baa3ba8b229fb996b83c53ec7
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1403213
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1403213 - Move nsstring into servo/support/gecko/nsstring, r=froydnj MozReview-Commit-ID: FmKtJxSCdYc
intl/encoding_glue/Cargo.toml
netwerk/base/rust-url-capi/Cargo.toml
toolkit/library/gtest/rust/Cargo.lock
toolkit/library/gtest/rust/Cargo.toml
toolkit/library/rust/Cargo.lock
toolkit/library/rust/shared/Cargo.toml
xpcom/moz.build
xpcom/rust/nserror/Cargo.toml
xpcom/rust/nsstring/Cargo.toml
xpcom/rust/nsstring/gtest/Cargo.toml
xpcom/rust/nsstring/gtest/moz.build
xpcom/rust/nsstring/src/lib.rs
--- a/intl/encoding_glue/Cargo.toml
+++ b/intl/encoding_glue/Cargo.toml
@@ -7,10 +7,10 @@ license = "MIT/Apache-2.0"
 
 [features]
 simd-accel = ["encoding_rs/simd-accel"]
 no-static-ideograph-encoder-tables = ["encoding_rs/no-static-ideograph-encoder-tables"]
 parallel-utf8 = ["encoding_rs/parallel-utf8"]
 
 [dependencies]
 encoding_rs = "0.7.0"
-nsstring = { path = "../../xpcom/rust/nsstring" }
+nsstring = { path = "../../servo/support/gecko/nsstring" }
 nserror = { path = "../../xpcom/rust/nserror" }
--- a/netwerk/base/rust-url-capi/Cargo.toml
+++ b/netwerk/base/rust-url-capi/Cargo.toml
@@ -4,10 +4,10 @@ version = "0.0.1"
 authors = ["Valentin Gosu <valentin.gosu@gmail.com>"]
 
 [lib]
 name = "rust_url_capi"
 
 [dependencies]
 libc = "0.2.0"
 url = "1.5.1"
-nsstring = { path = "../../../xpcom/rust/nsstring" }
+nsstring = { path = "../../../servo/support/gecko/nsstring" }
 nserror = { path = "../../../xpcom/rust/nserror" }
--- a/toolkit/library/gtest/rust/Cargo.lock
+++ b/toolkit/library/gtest/rust/Cargo.lock
@@ -534,17 +534,17 @@ name = "geckoservo"
 version = "0.0.1"
 dependencies = [
  "atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "cssparser 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "malloc_size_of 0.0.1",
- "nsstring_vendor 0.1.0",
+ "nsstring 0.1.0",
  "parking_lot 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "selectors 0.19.0",
  "servo_arc 0.0.1",
  "smallvec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "style 0.0.1",
  "style_traits 0.0.1",
 ]
 
@@ -879,23 +879,16 @@ dependencies = [
 [[package]]
 name = "nsstring-gtest"
 version = "0.1.0"
 dependencies = [
  "nsstring 0.1.0",
 ]
 
 [[package]]
-name = "nsstring_vendor"
-version = "0.1.0"
-dependencies = [
- "bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
 name = "num-integer"
 version = "0.1.33"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "num-traits 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -1271,17 +1264,17 @@ dependencies = [
  "itoa 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "lru_cache 0.0.1",
  "malloc_size_of 0.0.1",
  "malloc_size_of_derive 0.0.1",
  "matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "nsstring_vendor 0.1.0",
+ "nsstring 0.1.0",
  "num-integer 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)",
  "num-traits 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
  "num_cpus 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "ordered-float 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "parking_lot 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "rayon 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
--- a/toolkit/library/gtest/rust/Cargo.toml
+++ b/toolkit/library/gtest/rust/Cargo.toml
@@ -12,17 +12,17 @@ quantum_render = ["gkrust-shared/quantum
 cubeb-remoting = ["gkrust-shared/cubeb-remoting"]
 cubeb_pulse_rust = ["gkrust-shared/cubeb_pulse_rust"]
 gecko_debug = ["gkrust-shared/gecko_debug"]
 simd-accel = ["gkrust-shared/simd-accel"]
 no-static-ideograph-encoder-tables = ["gkrust-shared/no-static-ideograph-encoder-tables"]
 
 [dependencies]
 mp4parse-gtest = { path = "../../../../dom/media/gtest" }
-nsstring-gtest = { path = "../../../../xpcom/rust/nsstring/gtest" }
+nsstring-gtest = { path = "../../../../xpcom/rust/gtest/nsstring" }
 gkrust-shared = { path = "../../rust/shared" }
 
 [lib]
 path = "lib.rs"
 crate-type = ["staticlib"]
 test = false
 doctest = false
 bench = false
--- a/toolkit/library/rust/Cargo.lock
+++ b/toolkit/library/rust/Cargo.lock
@@ -533,17 +533,17 @@ name = "geckoservo"
 version = "0.0.1"
 dependencies = [
  "atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "cssparser 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "malloc_size_of 0.0.1",
- "nsstring_vendor 0.1.0",
+ "nsstring 0.1.0",
  "parking_lot 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "selectors 0.19.0",
  "servo_arc 0.0.1",
  "smallvec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "style 0.0.1",
  "style_traits 0.0.1",
 ]
 
@@ -867,23 +867,16 @@ dependencies = [
 [[package]]
 name = "nsstring"
 version = "0.1.0"
 dependencies = [
  "bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
-name = "nsstring_vendor"
-version = "0.1.0"
-dependencies = [
- "bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
 name = "num-integer"
 version = "0.1.33"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "num-traits 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -1263,17 +1256,17 @@ dependencies = [
  "itoa 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "lru_cache 0.0.1",
  "malloc_size_of 0.0.1",
  "malloc_size_of_derive 0.0.1",
  "matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "nsstring_vendor 0.1.0",
+ "nsstring 0.1.0",
  "num-integer 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)",
  "num-traits 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
  "num_cpus 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "ordered-float 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "parking_lot 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "rayon 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
--- a/toolkit/library/rust/shared/Cargo.toml
+++ b/toolkit/library/rust/shared/Cargo.toml
@@ -3,17 +3,17 @@ name = "gkrust-shared"
 version = "0.1.0"
 authors = ["nobody@mozilla.org"]
 license = "MPL-2.0"
 description = "Shared Rust code for libxul"
 
 [dependencies]
 geckoservo = { path = "../../../../servo/ports/geckolib", optional = true }
 mp4parse_capi = { path = "../../../../media/libstagefright/binding/mp4parse_capi" }
-nsstring = { path = "../../../../xpcom/rust/nsstring" }
+nsstring = { path = "../../../../servo/support/gecko/nsstring" }
 nserror = { path = "../../../../xpcom/rust/nserror" }
 rust_url_capi = { path = "../../../../netwerk/base/rust-url-capi" }
 webrender_bindings = { path = "../../../../gfx/webrender_bindings", optional = true }
 cubeb-pulse = { path = "../../../../media/libcubeb/cubeb-pulse-rs", optional = true, features=["pulse-dlopen"] }
 cubeb-core = { path = "../../../../media/cubeb-rs/cubeb-core", optional = true }
 cubeb = { path = "../../../../media/cubeb-rs/cubeb-api", optional = true }
 cubeb-backend = { path = "../../../../media/cubeb-rs/cubeb-backend", optional = true }
 encoding_c = "0.8.0"
@@ -27,17 +27,17 @@ syn = { version = "0.11", features = ["f
 
 [features]
 default = []
 bindgen = ["geckoservo/bindgen"]
 servo = ["geckoservo"]
 quantum_render = ["webrender_bindings"]
 cubeb-remoting = ["cubeb-core", "cubeb", "cubeb-backend", "audioipc-client", "audioipc-server"]
 cubeb_pulse_rust = ["cubeb-pulse"]
-gecko_debug = ["geckoservo/gecko_debug"]
+gecko_debug = ["geckoservo/gecko_debug", "nsstring/gecko_debug"]
 simd-accel = ["encoding_c/simd-accel", "encoding_glue/simd-accel"]
 no-static-ideograph-encoder-tables = ["encoding_c/no-static-ideograph-encoder-tables", "encoding_glue/no-static-ideograph-encoder-tables"]
 
 [lib]
 path = "lib.rs"
 test = false
 doctest = false
 bench = false
--- a/xpcom/moz.build
+++ b/xpcom/moz.build
@@ -25,18 +25,18 @@ DIRS += [
     '../chrome',
     'build',
 ]
 
 if CONFIG['OS_ARCH'] == 'WINNT' and CONFIG['MOZ_DEBUG']:
     DIRS += ['windbgdlg']
 
 TEST_DIRS += [
+    'rust/gtest',
     'tests',
-    'rust/nsstring/gtest',
 ]
 
 #  Can't build internal xptcall tests that use symbols which are not exported.
 #TEST_DIRS += [
 #    'reflect/xptinfo/tests',
 #    'reflect/xptcall/tests,
 #]
 
--- a/xpcom/rust/nserror/Cargo.toml
+++ b/xpcom/rust/nserror/Cargo.toml
@@ -1,9 +1,9 @@
 [package]
 name = "nserror"
 version = "0.1.0"
 authors = ["Michael Layzell <michael@thelayzells.com>"]
 license = "MPL-2.0"
 description = "Rust bindings to xpcom nsresult and NS_ERROR_ values"
 
 [dependencies]
-nsstring = { path = "../nsstring" }
+nsstring = { path = "../../../servo/support/gecko/nsstring" }
--- a/xpcom/rust/nsstring/Cargo.toml
+++ b/xpcom/rust/nsstring/Cargo.toml
@@ -1,9 +1,12 @@
 [package]
 name = "nsstring"
 version = "0.1.0"
 authors = ["nobody@mozilla.com"]
 license = "MPL-2.0"
 description = "Rust bindings to xpcom string types"
 
+[features]
+gecko_debug = []
+
 [dependencies]
 bitflags = "0.8"
--- a/xpcom/rust/nsstring/gtest/Cargo.toml
+++ b/xpcom/rust/nsstring/gtest/Cargo.toml
@@ -1,12 +1,12 @@
 [package]
 name = "nsstring-gtest"
 version = "0.1.0"
 authors = ["nobody@mozilla.com"]
 license = "MPL-2.0"
 description = "Tests for rust bindings to xpcom string types"
 
 [dependencies]
-nsstring = { path = "../" }
+nsstring = { path = "../../../../servo/support/gecko/nsstring" }
 
 [lib]
 path = "test.rs"
--- a/xpcom/rust/nsstring/gtest/moz.build
+++ b/xpcom/rust/nsstring/gtest/moz.build
@@ -1,11 +1,11 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 UNIFIED_SOURCES += [
-    'Test.cpp'
+    'nsstring/Test.cpp',
 ]
 
 FINAL_LIBRARY = 'xul-gtest'
--- a/xpcom/rust/nsstring/src/lib.rs
+++ b/xpcom/rust/nsstring/src/lib.rs
@@ -1,8 +1,12 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
 //! This module provides rust bindings for the XPCOM string types.
 //!
 //! # TL;DR (what types should I use)
 //!
 //! Use `&{mut,} nsA[C]String` for functions in rust which wish to take or
 //! mutate XPCOM strings. The other string types `Deref` to this type.
 //!
 //! Use `ns[C]String` (`ns[C]String` in C++) for string struct members, and as
@@ -109,61 +113,61 @@
 //! which invoke their member's destructors through C++ code.
 
 #![allow(non_camel_case_types)]
 #![deny(warnings)]
 
 #[macro_use]
 extern crate bitflags;
 
-use std::ops::{Deref, DerefMut};
+use std::borrow;
+use std::cmp;
+use std::fmt;
 use std::marker::PhantomData;
-use std::borrow;
+use std::mem;
+use std::ops::{Deref, DerefMut};
+use std::os::raw::c_void;
 use std::slice;
-use std::mem;
-use std::fmt;
-use std::cmp;
 use std::str;
 use std::u32;
-use std::os::raw::c_void;
 
 ///////////////////////////////////
 // Internal Implementation Flags //
 ///////////////////////////////////
 
 mod data_flags {
     bitflags! {
         // While this has the same layout as u16, it cannot be passed
         // over FFI safely as a u16.
         #[repr(C)]
-        pub flags DataFlags : u16 {
+        pub flags DataFlags: u16 {
             const TERMINATED = 1 << 0, // IsTerminated returns true
             const VOIDED = 1 << 1, // IsVoid returns true
             const SHARED = 1 << 2, // mData points to a heap-allocated, shared buffer
             const OWNED = 1 << 3, // mData points to a heap-allocated, raw buffer
             const INLINE = 1 << 4, // mData points to a writable, inline buffer
             const LITERAL = 1 << 5, // mData points to a string literal; TERMINATED will also be set
         }
     }
 }
 
 mod class_flags {
     bitflags! {
         // While this has the same layout as u16, it cannot be passed
         // over FFI safely as a u16.
         #[repr(C)]
-        pub flags ClassFlags : u16 {
+        pub flags ClassFlags: u16 {
             const INLINE = 1 << 0, // |this|'s buffer is inline
             const NULL_TERMINATED = 1 << 1, // |this| requires its buffer is null-terminated
         }
     }
 }
 
+use class_flags::ClassFlags;
 use data_flags::DataFlags;
-use class_flags::ClassFlags;
 
 ////////////////////////////////////
 // Generic String Bindings Macros //
 ////////////////////////////////////
 
 macro_rules! define_string_types {
     {
         char_t = $char_t: ty;
@@ -999,22 +1003,22 @@ impl fmt::Debug for nsAString {
 }
 
 impl cmp::PartialEq<str> for nsAString {
     fn eq(&self, other: &str) -> bool {
         other.encode_utf16().eq(self.iter().cloned())
     }
 }
 
-#[cfg(not(debug_assertions))]
+#[cfg(not(feature = "gecko_debug"))]
 #[allow(non_snake_case)]
 unsafe fn Gecko_IncrementStringAdoptCount(_: *mut c_void) {}
 
 extern "C" {
-    #[cfg(debug_assertions)]
+    #[cfg(feature = "gecko_debug")]
     fn Gecko_IncrementStringAdoptCount(data: *mut c_void);
 
     // Gecko implementation in nsSubstring.cpp
     fn Gecko_FinalizeCString(this: *mut nsACString);
 
     fn Gecko_AssignCString(this: *mut nsACString, other: *const nsACString);
     fn Gecko_TakeFromCString(this: *mut nsACString, other: *mut nsACString);
     fn Gecko_AppendCString(this: *mut nsACString, other: *const nsACString);
@@ -1052,27 +1056,20 @@ extern "C" {
 
 pub mod test_helpers {
     //! This module only exists to help with ensuring that the layout of the
     //! structs inside of rust and C++ are identical.
     //!
     //! It is public to ensure that these testing functions are avaliable to
     //! gtest code.
 
-    use super::{
-        nsCString,
-        nsString,
-        nsCStr,
-        nsStr,
-        nsCStringRepr,
-        nsStringRepr,
-        data_flags,
-        class_flags,
-    };
     use std::mem;
+    use super::{class_flags, data_flags};
+    use super::{nsCStr, nsCString, nsCStringRepr};
+    use super::{nsStr, nsString, nsStringRepr};
 
     /// Generates an #[no_mangle] extern "C" function which returns the size and
     /// alignment of the given type with the given name.
     macro_rules! size_align_check {
         ($T:ty, $fname:ident) => {
             #[no_mangle]
             #[allow(non_snake_case)]
             pub extern fn $fname(size: *mut usize, align: *mut usize) {