Bug 1552695 - Part 1: Deduplicate syn and quote. r=froydnj

Differential Revision: https://phabricator.services.mozilla.com/D31737

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Bastien Orivel 2019-05-20 12:21:20 +00:00
Родитель 7029c5b0f8
Коммит e661e801af
4 изменённых файлов: 60 добавлений и 97 удалений

96
Cargo.lock сгенерированный
Просмотреть файл

@ -736,10 +736,10 @@ dependencies = [
[[package]]
name = "cssparser"
version = "0.25.3"
version = "0.25.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cssparser-macros 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser-macros 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"dtoa-short 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"itoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -753,14 +753,14 @@ dependencies = [
[[package]]
name = "cssparser-macros"
version = "0.3.3"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"phf_codegen 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
"procedural-masquerade 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -768,17 +768,17 @@ name = "cstr"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cstr-macros 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"cstr-macros 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"procedural-masquerade 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "cstr-macros"
version = "0.1.3"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"procedural-masquerade 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -1204,7 +1204,7 @@ name = "geckoservo"
version = "0.0.1"
dependencies = [
"atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.25.3 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.25.5 (registry+https://github.com/rust-lang/crates.io-index)",
"cstr 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1681,7 +1681,7 @@ name = "malloc_size_of"
version = "0.0.1"
dependencies = [
"app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.25.3 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.25.5 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.19.5 (registry+https://github.com/rust-lang/crates.io-index)",
"hashglobe 0.1.0",
"selectors 0.21.0",
@ -1846,8 +1846,8 @@ name = "mozilla-central-workspace-hack"
version = "0.1.0"
dependencies = [
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.88 (git+https://github.com/servo/serde?branch=deserialize_from_enums10)",
"syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2018,13 +2018,12 @@ dependencies = [
[[package]]
name = "num-derive"
version = "0.2.2"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -2249,14 +2248,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
name = "prefs_parser"
version = "0.0.1"
[[package]]
name = "proc-macro2"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "proc-macro2"
version = "0.4.27"
@ -2300,14 +2291,6 @@ name = "quick-error"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "quote"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "quote"
version = "0.6.11"
@ -2667,7 +2650,7 @@ name = "selectors"
version = "0.21.0"
dependencies = [
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.25.3 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.25.5 (registry+https://github.com/rust-lang/crates.io-index)",
"derive_more 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
"fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2884,7 +2867,7 @@ dependencies = [
"bindgen 0.49.1 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.25.3 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.25.5 (registry+https://github.com/rust-lang/crates.io-index)",
"derive_more 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.19.5 (registry+https://github.com/rust-lang/crates.io-index)",
"fallible 0.0.1",
@ -2900,7 +2883,7 @@ dependencies = [
"matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"new_debug_unreachable 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"nsstring 0.1.0",
"num-derive 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"num-derive 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2946,7 +2929,7 @@ version = "0.0.1"
dependencies = [
"app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.25.3 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.25.5 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.19.5 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"malloc_size_of 0.0.1",
@ -2962,7 +2945,7 @@ name = "stylo_tests"
version = "0.0.1"
dependencies = [
"atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.25.3 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.25.5 (registry+https://github.com/rust-lang/crates.io-index)",
"cstr 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
"geckoservo 0.0.1",
@ -2983,26 +2966,6 @@ name = "svg_fmt"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "syn"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "syn"
version = "0.14.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "syn"
version = "0.15.30"
@ -3137,7 +3100,7 @@ dependencies = [
name = "to_shmem"
version = "0.0.1"
dependencies = [
"cssparser 0.25.3 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.25.5 (registry+https://github.com/rust-lang/crates.io-index)",
"servo_arc 0.1.1",
"smallbitvec 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3696,8 +3659,9 @@ name = "xpcom_macros"
version = "0.1.0"
dependencies = [
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -3807,10 +3771,10 @@ dependencies = [
"checksum crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2760899e32a1d58d5abb31129f8fae5de75220bc2176e77ff7c627ae45c918d9"
"checksum crossbeam-utils 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d636a8b3bcc1b409d7ffd3facef8f21dcb4009626adbd0c5e6c4305c07253c7b"
"checksum crossbeam-utils 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "41ee4864f4797060e52044376f7d107429ce1fb43460021b126424b7180ee21a"
"checksum cssparser 0.25.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ba1ab4e1814be64bf6b6064ff532db0e34087f11b37706d6c96a21d32478761d"
"checksum cssparser-macros 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f3a5383ae18dbfdeb569ed62019f5bddb2a95cd2d3833313c475a0d014777805"
"checksum cssparser 0.25.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e06795910fc2f585a75bdc9690fbcc51e83519f07b6eb981db43944643c04933"
"checksum cssparser-macros 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "b16e382d9b983fdb9ac6a36b37fdeb84ce3ea81f749febfee3463cfa7f24275e"
"checksum cstr 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b6557bdb1dc9647eae1cf7f5601b14cd45fc3c7ccf2df618387416fe542da6ea"
"checksum cstr-macros 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0472c17c83d3ec1af32fb6ee2b3ad56ae0b6e69355d63d1d30602055c34324a8"
"checksum cstr-macros 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0f12dd847ec773fc98d75edba5394cb87d0f35e7ee548a4c81849ca6374b3d48"
"checksum cubeb 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "db3f0df2ad5cb453126364a77921466ba6c1034e8bd9247f326cdb31430dbc2a"
"checksum cubeb-backend 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "442cd5cfb980ff62730525278ce320d9b2ff635b725857ad3176832664262fec"
"checksum cubeb-core 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0161f9327864922ba7a172c90bd86bc9094938433eca415e2c75629954045022"
@ -3914,7 +3878,7 @@ dependencies = [
"checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2"
"checksum nom 3.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05aec50c70fd288702bcd93284a8444607f3292dbdf2a30de5ea5dcdbe72287b"
"checksum nom 4.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9c349f68f25f596b9f44cf0e7c69752a5c633b0550c3ff849518bfba0233774a"
"checksum num-derive 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0d2c31b75c36a993d30c7a13d70513cb93f02acafdd5b7ba250f9b0e18615de7"
"checksum num-derive 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "eafd0b45c5537c3ba526f79d3e75120036502bebacbb3f3220914067ce39dbf2"
"checksum num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "e83d528d2677f0518c570baf2b7abdcf0cd2d248860b68507bdcb3e91d4c0cea"
"checksum num-iter 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)" = "af3fdbbc3291a5464dc57b03860ec37ca6bf915ed6ee385e7c6c052c422b2124"
"checksum num-rational 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4e96f040177bb3da242b5b1ecf3f54b5d5af3efbbfb18608977a5d2767b22f10"
@ -3943,11 +3907,9 @@ dependencies = [
"checksum png 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9adebf7fb91ccf5eac9da1a8e00e83cb8ae882c3e8d8e4ad59da73cb8c82a2c9"
"checksum podio 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e5422a1ee1bc57cc47ae717b0137314258138f38fd5f3cea083f43a9725383a0"
"checksum precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
"checksum proc-macro2 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "77997c53ae6edd6d187fec07ec41b207063b5ee6f33680e9fa86d405cdd313d4"
"checksum proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)" = "4d317f9caece796be1980837fd5cb3dfec5613ebdb04ad0956deea83ce168915"
"checksum procedural-masquerade 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9f566249236c6ca4340f7ca78968271f0ed2b0f234007a61b66f9ecd0af09260"
"checksum quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eda5fe9b71976e62bc81b781206aaa076401769b2143379d3eb2118388babac4"
"checksum quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9949cfe66888ffe1d53e6ec9d9f3b70714083854be20fd5e271b232a017401e8"
"checksum quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1"
"checksum rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "15a732abf9d20f0ad8eeb6f909bf6868722d9a06e1e50802b6a70351f40b4eb1"
"checksum rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8356f47b32624fef5b3301c1be97e5944ecdd595409cc5da11d05f211db6cfbd"
@ -4009,8 +3971,6 @@ dependencies = [
"checksum string_cache_shared 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b1884d1bc09741d466d9b14e6d37ac89d6909cbcac41dd9ae982d4d063bbedfc"
"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550"
"checksum svg_fmt 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c666f0fed8e1e20e057af770af9077d72f3d5a33157b8537c1475dd8ffd6d32b"
"checksum syn 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "91b52877572087400e83d24b9178488541e3d535259e04ff17a63df1e5ceff59"
"checksum syn 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)" = "4e4b5274d4a0a3d2749d5c158dc64d3403e60554dc61194648787ada5212473d"
"checksum syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)" = "66c8865bf5a7cbb662d8b011950060b3c8743dca141b054bf7195b20d314d8e2"
"checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015"
"checksum target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b0ab4982b8945c35cc1c46a83a9094c414f6828a099ce5dcaa8ee2b04642dcb"

Просмотреть файл

@ -19,8 +19,8 @@ syn = { features = ["clone-impls", "default", "derive", "extra-traits", "full",
log = { features = ["release_max_level_info", "release_max_level_warn", "std"], version = "0.4.6" }
serde = { features = ["default", "rc", "serde_derive", "std"], version = "1.0.66" }
serde_derive = { features = ["default", "deserialize_in_place"], version = "1.0.66" }
quote = { features = ["default", "proc-macro"], version = "0.5.2" }
proc-macro2 = { features = ["default", "proc-macro"], version = "0.3.5" }
quote = { features = ["default", "proc-macro"], version = "0.6.11" }
proc-macro2 = { features = ["default", "proc-macro"], version = "0.4.27" }
[target."cfg(windows)".dependencies.winapi]
version = "0.3.6"

Просмотреть файл

@ -7,6 +7,7 @@ authors = ["Michael Layzell <michael@thelayzells.com>"]
proc-macro = true
[dependencies]
syn = "0.13"
quote = "0.5"
syn = "0.15"
quote = "0.6"
proc-macro2 = "0.4"
lazy_static = "1.0"

Просмотреть файл

@ -150,15 +150,17 @@ extern crate quote;
extern crate syn;
extern crate proc_macro;
extern crate proc_macro2;
#[macro_use]
extern crate lazy_static;
use proc_macro::TokenStream;
use quote::{ToTokens, Tokens};
use quote::ToTokens;
use proc_macro2::{Span, TokenStream as TokenStream2};
use syn::*;
use syn::{parse, parse_quote, Attribute, Data, DataStruct, DeriveInput, Field, Fields, Ident, Lit, Meta, NestedMeta, Token, Type};
use syn::punctuated::Punctuated;
@ -229,7 +231,7 @@ enum RefcntKind {
/// Produces the tokens for the type representation.
impl ToTokens for RefcntKind {
fn to_tokens(&self, tokens: &mut Tokens) {
fn to_tokens(&self, tokens: &mut TokenStream2) {
match *self {
RefcntKind::NonAtomic => quote!(xpcom::Refcnt).to_tokens(tokens),
RefcntKind::Atomic => quote!(xpcom::AtomicRefcnt).to_tokens(tokens),
@ -241,7 +243,7 @@ impl ToTokens for RefcntKind {
fn get_refcnt_kind(attrs: &[Attribute]) -> Result<RefcntKind, Box<Error>> {
for attr in attrs {
if let Some(Meta::NameValue(ref attr)) = attr.interpret_meta() {
if attr.ident.as_ref() != "refcnt" {
if attr.ident != "refcnt" {
continue;
}
@ -272,13 +274,13 @@ fn get_bases(attrs: &[Attribute]) -> Result<Vec<&'static Interface>, Box<Error>>
let mut inherits = Vec::new();
for attr in attrs {
if let Some(Meta::List(ref attr)) = attr.interpret_meta() {
if attr.ident.as_ref() != "xpimplements" {
if attr.ident != "xpimplements" {
continue;
}
for item in &attr.nested {
if let NestedMeta::Meta(Meta::Word(ref iface)) = *item {
if let Some(&iface) = IFACES.get(iface.as_ref()) {
if let Some(&iface) = IFACES.get(iface.to_string().as_str()) {
inherits.push(iface);
} else {
Err(format!("Unexpected invalid base interface `{}` in \
@ -308,15 +310,15 @@ fn get_fields(di: &DeriveInput) -> Result<&Punctuated<Field, Token![,]>, Box<Err
fn gen_real_struct(init: &DeriveInput, bases: &[&Interface], refcnt_ty: RefcntKind) -> Result<DeriveInput, Box<Error>> {
// Determine the name for the real struct based on the name of the
// initializer struct's name.
if !init.ident.as_ref().starts_with("Init") {
if !init.ident.to_string().starts_with("Init") {
Err("The target struct's name must begin with Init")?
}
let name: Ident = init.ident.as_ref()[4..].into();
let name: Ident = Ident::new(&init.ident.to_string()[4..], Span::call_site());
let vis = &init.vis;
let bases = bases.iter().map(|base| {
let ident = Ident::from(format!("__base_{}", base.name));
let vtable = Ident::from(format!("{}VTable", base.name));
let ident = Ident::new(&format!("__base_{}", base.name), Span::call_site());
let vtable = Ident::new(&format!("{}VTable", base.name), Span::call_site());
quote!(#ident : *const xpcom::interfaces::#vtable)
});
@ -337,8 +339,8 @@ fn gen_real_struct(init: &DeriveInput, bases: &[&Interface], refcnt_ty: RefcntKi
/// These methods attempt to invoke the `recover_self` method to translate from
/// the passed-in raw pointer to the actual `&self` value, and it is expected to
/// be in scope.
fn gen_vtable_methods(iface: &Interface) -> Result<Tokens, Box<Error>> {
let base_ty = Ident::from(iface.name);
fn gen_vtable_methods(iface: &Interface) -> Result<TokenStream2, Box<Error>> {
let base_ty = Ident::new(iface.name, Span::call_site());
let base_methods = if let Some(base) = iface.base()? {
gen_vtable_methods(base)?
@ -352,13 +354,13 @@ fn gen_vtable_methods(iface: &Interface) -> Result<Tokens, Box<Error>> {
let mut method_defs = Vec::new();
for method in methods {
let name = Ident::from(method.name);
let name = Ident::new(method.name, Span::call_site());
let ret = syn::parse_str::<Type>(method.ret)?;
let mut params = Vec::new();
let mut args = Vec::new();
for param in method.params {
let name = Ident::from(param.name);
let name = Ident::new(param.name, Span::call_site());
let ty = syn::parse_str::<Type>(param.ty)?;
params.push(quote!{#name : #ty,});
@ -381,8 +383,8 @@ fn gen_vtable_methods(iface: &Interface) -> Result<Tokens, Box<Error>> {
/// Generates the VTable for a given base interface. This assumes that the
/// implementations of each of the `extern "system"` methods are in scope.
fn gen_inner_vtable(iface: &Interface) -> Result<Tokens, Box<Error>> {
let vtable_ty = Ident::from(format!("{}VTable", iface.name));
fn gen_inner_vtable(iface: &Interface) -> Result<TokenStream2, Box<Error>> {
let vtable_ty = Ident::new(&format!("{}VTable", iface.name), Span::call_site());
let methods = iface.methods
.map_err(|reason| format!("Interface {} cannot be implemented in rust \
@ -398,7 +400,7 @@ fn gen_inner_vtable(iface: &Interface) -> Result<Tokens, Box<Error>> {
// Include each of the method definitions for this interface.
let vtable_init = methods.into_iter().map(|method| {
let name = Ident::from(method.name);
let name = Ident::new(method.name, Span::call_site());
quote!{ #name : #name , }
}).collect::<Vec<_>>();
@ -408,9 +410,9 @@ fn gen_inner_vtable(iface: &Interface) -> Result<Tokens, Box<Error>> {
}))
}
fn gen_root_vtable(name: &Ident, base: &Interface) -> Result<Tokens, Box<Error>> {
let field = Ident::from(format!("__base_{}", base.name));
let vtable_ty = Ident::from(format!("{}VTable", base.name));
fn gen_root_vtable(name: &Ident, base: &Interface) -> Result<TokenStream2, Box<Error>> {
let field = Ident::new(&format!("__base_{}", base.name), Span::call_site());
let vtable_ty = Ident::new(&format!("{}VTable", base.name), Span::call_site());
let methods = gen_vtable_methods(base)?;
let value = gen_inner_vtable(base)?;
@ -455,7 +457,7 @@ fn gen_casts(
name: &Ident,
coerce_name: &Ident,
vtable_field: &Ident,
) -> Result<(Tokens, Tokens), Box<Error>> {
) -> Result<(TokenStream2, TokenStream2), Box<Error>> {
if !seen.insert(iface.name) {
return Ok((quote!{}, quote!{}));
}
@ -474,7 +476,7 @@ fn gen_casts(
};
// Add the if statment to QueryInterface for the base class.
let base_name = Ident::from(iface.name);
let base_name = Ident::new(iface.name, Span::call_site());
let qi = quote! {
#base_qi
@ -511,7 +513,7 @@ fn gen_casts(
}
/// The root xpcom procedural macro definition.
fn xpcom(init: DeriveInput) -> Result<Tokens, Box<Error>> {
fn xpcom(init: DeriveInput) -> Result<TokenStream2, Box<Error>> {
if !init.generics.params.is_empty() || !init.generics.where_clause.is_none() {
return Err("Cannot #[derive(xpcom)] on a generic type, due to \
rust limitations. It is not possible to instantiate \
@ -534,7 +536,7 @@ fn xpcom(init: DeriveInput) -> Result<Tokens, Box<Error>> {
let name_init = &init.ident;
let name = &real.ident;
let coerce_name = Ident::from(format!("{}Coerce", name.as_ref()));
let coerce_name = Ident::new(&format!("{}Coerce", name.to_string()), Span::call_site());
// Generate a VTable for each of the base interfaces.
let mut vtables = Vec::new();
@ -561,7 +563,7 @@ fn xpcom(init: DeriveInput) -> Result<Tokens, Box<Error>> {
base,
name,
&coerce_name,
&Ident::from(format!("__base_{}", base.name)),
&Ident::new(&format!("__base_{}", base.name), Span::call_site()),
)?;
qi_impl.push(qi);
coerce_impl.push(coerce);