From 06c47f82ab66f4ef477c3e31f931ee9717566455 Mon Sep 17 00:00:00 2001
From: Ryan Hunt <rhunt@eqrion.net>
Date: Thu, 13 Apr 2017 00:40:17 -0400
Subject: [PATCH] Remove prebuilts and ignores

---
 src/bindgen/items.rs   |  7 -------
 src/bindgen/library.rs | 43 +-----------------------------------------
 src/bindgen/mod.rs     |  2 +-
 src/main.rs            |  6 +-----
 4 files changed, 3 insertions(+), 55 deletions(-)

diff --git a/src/bindgen/items.rs b/src/bindgen/items.rs
index 0508e21..1b22bc4 100644
--- a/src/bindgen/items.rs
+++ b/src/bindgen/items.rs
@@ -499,13 +499,6 @@ impl Specialization {
                             values: aliased.values.clone(),
                         }))
                     }
-                    PathValue::Prebuilt(aliased) => {
-                        Ok(PathValue::Prebuilt(Prebuilt {
-                            // assume that the prebuilt has the right name
-                            name: aliased.name,
-                            source: aliased.source,
-                        }))
-                    }
                     _ => Err(format!("unknown type to specialize"))
                 }
             }
diff --git a/src/bindgen/library.rs b/src/bindgen/library.rs
index bfe4413..dd12d84 100644
--- a/src/bindgen/library.rs
+++ b/src/bindgen/library.rs
@@ -1,7 +1,6 @@
 use std::io;
 use std::io::Write;
 use std::collections::BTreeMap;
-use std::collections::HashSet;
 use std::cmp::Ordering;
 
 use syn::*;
@@ -22,7 +21,6 @@ pub enum PathValue {
     OpaqueStruct(OpaqueStruct),
     Typedef(Typedef),
     Specialization(Specialization),
-    Prebuilt(Prebuilt),
 }
 impl PathValue {
     pub fn name(&self) -> &String {
@@ -32,7 +30,6 @@ impl PathValue {
             &PathValue::OpaqueStruct(ref x) => { &x.name },
             &PathValue::Typedef(ref x) => { &x.name },
             &PathValue::Specialization(ref x) => { &x.name },
-            &PathValue::Prebuilt(ref x) => { &x.name },
         }
     }
 
@@ -43,29 +40,10 @@ impl PathValue {
             &PathValue::OpaqueStruct(_) => { },
             &PathValue::Typedef(ref x) => { x.add_deps(library, out); },
             &PathValue::Specialization(ref x) => { x.add_deps(library, out); },
-            &PathValue::Prebuilt(_) => { },
         }
     }
 }
 
-#[derive(Debug, Clone)]
-pub struct Prebuilt {
-    pub name: String,
-    pub source: String,
-}
-impl Prebuilt {
-    pub fn new(name: String, source: String) -> Prebuilt {
-        Prebuilt {
-            name: name,
-            source: source,
-        }
-    }
-
-    fn write<F: Write>(&self, out: &mut F) {
-        write!(out, "{}", self.source).unwrap();
-    }
-}
-
 /// A library collects all of the information needed to generate
 /// bindings for a specified rust library. It is turned into a
 /// BuiltLibrary, and in the process filters out unneeded information
@@ -77,7 +55,6 @@ pub struct Library {
     opaque_structs: BTreeMap<String, OpaqueStruct>,
     typedefs: BTreeMap<String, Typedef>,
     specializations: BTreeMap<String, Specialization>,
-    prebuilts: BTreeMap<String, Prebuilt>,
     functions: BTreeMap<String, Function>,
 }
 
@@ -89,24 +66,16 @@ impl Library {
             opaque_structs: BTreeMap::new(),
             typedefs: BTreeMap::new(),
             specializations: BTreeMap::new(),
-            prebuilts: BTreeMap::new(),
             functions: BTreeMap::new(),
         }
     }
 
-    pub fn load(crate_or_src: &str,
-                _config: &Config,
-                prebuilts: Vec<Prebuilt>,
-                ignore: HashSet<String>) -> Library
+    pub fn load(crate_or_src: &str, _config: &Config) -> Library
     {
         let mut library = Library::blank();
 
         rust_lib::parse(crate_or_src, &mut |mod_name, items| {
             for item in items {
-                if ignore.contains(&item.ident.to_string()) {
-                    continue;
-                }
-
                 match item.node {
                     ItemKind::Fn(ref decl,
                                  ref _unsafe,
@@ -207,19 +176,10 @@ impl Library {
             }
         });
 
-        for prebuilt in prebuilts {
-            library.prebuilts.insert(prebuilt.name.clone(), prebuilt);
-        }
-
         library
     }
 
     pub fn resolve_path(&self, p: &PathRef) -> Option<PathValue> {
-        // Search the prebuilts first, allow them to override
-        if let Some(x) = self.prebuilts.get(p) {
-            return Some(PathValue::Prebuilt(x.clone()));
-        }
-
         if let Some(x) = self.enums.get(p) {
             return Some(PathValue::Enum(x.clone()));
         }
@@ -348,7 +308,6 @@ impl BuiltLibrary {
                 &PathValue::Specialization(_) => {
                     panic!("should not encounter a specialization in a built library")
                 }
-                &PathValue::Prebuilt(ref x) => x.write(out),
             }
             write!(out, "\n").unwrap();
         }
diff --git a/src/bindgen/mod.rs b/src/bindgen/mod.rs
index 0101e6d..afe6b76 100644
--- a/src/bindgen/mod.rs
+++ b/src/bindgen/mod.rs
@@ -2,4 +2,4 @@ mod syn_helpers;
 mod items;
 mod library;
 
-pub use self::library::{Prebuilt, Library, BuiltLibrary};
+pub use self::library::{Library, BuiltLibrary};
diff --git a/src/main.rs b/src/main.rs
index 5d26f69..cc38605 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,6 +1,5 @@
 use std::io;
 use std::fs::File;
-use std::collections::HashSet;
 
 extern crate syn;
 extern crate clap;
@@ -38,10 +37,7 @@ fn main() {
         None => Config::default(),
     };
 
-    let lib = bindgen::Library::load(input,
-                                     &config,
-                                     vec![],
-                                     HashSet::new());
+    let lib = bindgen::Library::load(input, &config);
 
     let built = lib.build(&config).unwrap();
 
-- 
GitLab