From b00bbb3be7f18be985d6c88e0fdc0f046993586c Mon Sep 17 00:00:00 2001 From: Boris Chiou Date: Wed, 31 Oct 2018 06:19:52 +0000 Subject: [PATCH] style: Add a special list for cbindgen types to avoid generating redundant rust types. We will blacklist this type and add a module raw line to map the gecko type to its rust type (as an alias). Differential Revision: https://phabricator.services.mozilla.com/D10303 --- components/style/build_gecko.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/style/build_gecko.rs b/components/style/build_gecko.rs index bee061fcc21d..3e4200d28d0b 100644 --- a/components/style/build_gecko.rs +++ b/components/style/build_gecko.rs @@ -392,6 +392,12 @@ mod bindings { .handle_str_items("whitelist-vars", |b, item| b.whitelist_var(item)) .handle_str_items("whitelist-types", |b, item| b.whitelist_type(item)) .handle_str_items("opaque-types", |b, item| b.opaque_type(item)) + .handle_table_items("cbindgen-types", |b, item| { + let gecko = item["gecko"].as_str().unwrap(); + let servo = item["servo"].as_str().unwrap(); + let line = format!("pub use {} as {};", servo, gecko.rsplit("::").next().unwrap()); + b.blacklist_type(gecko).module_raw_line("root::mozilla", line) + }) .handle_table_items("mapped-generic-types", |builder, item| { let generic = item["generic"].as_bool().unwrap(); let gecko = item["gecko"].as_str().unwrap();