From bf56f6c80068f6ce51a9505a9762274e642f9013 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Sat, 30 Oct 2021 23:13:11 +0200 Subject: [PATCH] Remove objc2_foundation_derive See reasoning in https://github.com/madsmtm/objc2/issues/55 --- Cargo.toml | 1 - objc2_foundation_derive/Cargo.toml | 24 --------- objc2_foundation_derive/README.md | 12 ----- objc2_foundation_derive/src/lib.rs | 79 ------------------------------ 4 files changed, 116 deletions(-) delete mode 100644 objc2_foundation_derive/Cargo.toml delete mode 100644 objc2_foundation_derive/README.md delete mode 100644 objc2_foundation_derive/src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index e5e47d14f..b41ffca9c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,6 @@ members = [ "objc2_encode", "objc2_exception", "objc2_foundation", - "objc2_foundation_derive", "objc2_sys", "objc2_test_utils", ] diff --git a/objc2_foundation_derive/Cargo.toml b/objc2_foundation_derive/Cargo.toml deleted file mode 100644 index e5b69c028..000000000 --- a/objc2_foundation_derive/Cargo.toml +++ /dev/null @@ -1,24 +0,0 @@ -[package] -name = "objc2_foundation_derive" -version = "0.0.1" # Remember to update html_root_url in lib.rs -authors = ["Steven Sheldon", "Mads Marquart "] -edition = "2018" - -description = "Procedural macros for deriving traits from objc2_foundation" -keywords = ["objective-c", "macos", "ios", "cocoa", "uikit"] -categories = [ - "api-bindings", - "development-tools::ffi", - "os::macos-apis", -] -readme = "README.md" -repository = "https://github.com/madsmtm/objc2" -documentation = "https://docs.rs/objc2_foundation_derive/" -license = "MIT" - -[lib] -proc-macro = true - -[dependencies] -syn = "0.10" -quote = "0.3.8" diff --git a/objc2_foundation_derive/README.md b/objc2_foundation_derive/README.md deleted file mode 100644 index 4390301a2..000000000 --- a/objc2_foundation_derive/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# `objc2_foundation_derive` - -[![Latest version](https://badgen.net/crates/v/objc2_foundation_derive)](https://crates.io/crates/objc2_foundation_derive) -[![License](https://badgen.net/badge/license/MIT/blue)](../LICENSE.txt) -[![Documentation](https://docs.rs/objc2_foundation_derive/badge.svg)](https://docs.rs/objc2_foundation_derive/) -[![Apple CI](https://github.com/madsmtm/objc2/actions/workflows/apple.yml/badge.svg)](https://github.com/madsmtm/objc2/actions/workflows/apple.yml) -[![GNUStep CI](https://github.com/madsmtm/objc2/actions/workflows/gnustep.yml/badge.svg)](https://github.com/madsmtm/objc2/actions/workflows/gnustep.yml) - -WIP! - -This crate will be exposed under a `derive` flag in `objc2_foundation`, and so -should not need to be used directly. diff --git a/objc2_foundation_derive/src/lib.rs b/objc2_foundation_derive/src/lib.rs deleted file mode 100644 index 6ed5f23c0..000000000 --- a/objc2_foundation_derive/src/lib.rs +++ /dev/null @@ -1,79 +0,0 @@ -// Update in Cargo.toml as well. -#![doc(html_root_url = "https://docs.rs/objc2_foundation_derive/0.0.1")] - -#[cfg(doctest)] -#[doc = include_str!("../README.md")] -extern "C" {} - -#[macro_use] -extern crate quote; -use syn; - -use proc_macro::TokenStream; -use quote::{ToTokens, Tokens}; - -#[proc_macro_derive(INSObject)] -pub fn impl_object(input: TokenStream) -> TokenStream { - // Construct a string representation of the type definition - let s = input.to_string(); - - // Parse the string representation - let ast = syn::parse_macro_input(&s).unwrap(); - - // Build the impl - let name = &ast.ident; - let link_name = format!("OBJC_CLASS_$_{}", name); - let (impl_generics, ty_generics, where_clause) = ast.generics.split_for_impl(); - - let mut gen = Tokens::new(); - quote!( - unsafe impl #impl_generics ::objc2::Message for #name #ty_generics #where_clause { } - ) - .to_tokens(&mut gen); - - quote!( - impl #impl_generics INSObject for #name #ty_generics #where_clause { - fn class() -> &'static ::objc2::runtime::Class { - extern { - #[link_name = #link_name] - static OBJC_CLASS: ::objc2::runtime::Class; - } - unsafe { - &OBJC_CLASS - } - } - } - ) - .to_tokens(&mut gen); - - quote!( - impl #impl_generics ::core::cmp::PartialEq for #name #ty_generics #where_clause { - fn eq(&self, other: &Self) -> bool { - INSObject::is_equal(self, other) - } - } - ) - .to_tokens(&mut gen); - - quote!( - impl #impl_generics ::core::hash::Hash for #name #ty_generics #where_clause { - fn hash(&self, state: &mut H) where H: ::core::hash::Hasher { - INSObject::hash_code(self).hash(state); - } - } - ) - .to_tokens(&mut gen); - - quote!( - impl #impl_generics ::core::fmt::Debug for #name #ty_generics #where_clause { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - let s = INSObject::description(self); - ::core::fmt::Display::fmt(&*s, f) - } - } - ) - .to_tokens(&mut gen); - - // Return the generated impl - gen.parse().unwrap() -}