Skip to content

Commit

Permalink
Nits
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhenrymantilla committed Jun 28, 2022
1 parent cc68905 commit 64cd908
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 275 deletions.
29 changes: 0 additions & 29 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ inventory.version = "0.1.6"
inventory.optional = true
scopeguard.version = "1.1.0"
unwind_safe.version = "0.1.0"
fstrings = "0.2.3"
with_builtin_macros.version = "0.0.3"
macro_rules_attribute = "0.1.0"

Expand Down
29 changes: 0 additions & 29 deletions js_tests/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/_lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@
#![doc = include_str!("../README.md")]
#![cfg(not(rustfmt))]

#![feature(rustc_attrs)] #![allow(warnings)]

#[macro_use]
extern crate fstrings;

#[macro_use]
extern crate macro_rules_attribute;

Expand Down
17 changes: 3 additions & 14 deletions src/headers/languages/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use {
},
super::{
Definer,
Language,
},
};

Expand Down Expand Up @@ -110,9 +109,9 @@ trait HeaderLanguage : UpcastAny {

fn emit_docs (
self: &'_ Self,
ctx: &'_ mut dyn Definer,
docs: Docs<'_>,
indentation: &'_ Indentation,
_ctx: &'_ mut dyn Definer,
_docs: Docs<'_>,
_indentation: &'_ Indentation,
) -> io::Result<()>
{
// This function is just offered as a convenience helper;
Expand Down Expand Up @@ -145,16 +144,6 @@ struct StructField<'lt> {
ty: &'lt dyn PhantomCType,
}

pub
struct TypeMethods {
short_name: fn() -> String,

name_wrapping_var: fn(
language: &'_ dyn HeaderLanguage,
var_name: &'_ str,
) -> String,
}

pub
struct FunctionArg<'lt> {
// pub
Expand Down
5 changes: 2 additions & 3 deletions src/layout/_mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ impl<T : LegacyCType> CType for T {

#[inline]
fn define_self__impl (
language: &'_ dyn HeaderLanguage,
definer: &'_ mut dyn Definer,
_: &'_ dyn HeaderLanguage,
_: &'_ mut dyn Definer,
) -> io::Result<()>
{
unimplemented!()
Expand Down Expand Up @@ -380,7 +380,6 @@ unsafe trait LegacyCType
/// // ...
/// }
/// ```
#[inline]
fn c_define_self (definer: &'_ mut dyn Definer)
-> io::Result<()>
;
Expand Down
194 changes: 0 additions & 194 deletions src/layout/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,6 @@ macro_rules! __cfg_csharp__ {(
// Nothing
)}

#[macro_export] #[doc(hidden)]
macro_rules! __with_doc__ {(
#[doc = $doc:expr]
$(#[$meta:meta])*
$pub:vis
struct
$($rest:tt)*
) => (
$(#[$meta])*
#[doc = $doc]
$pub
struct
$($rest)*
)}
/// Safely implement [`CType`][`trait@crate::layout::LegacyCType`]
/// for a `#[repr(C)]` struct **when all its fields are `CType`**.
///
Expand Down Expand Up @@ -87,24 +73,6 @@ macro_rules! CType {(
),+ $(,)?
}
) => (
// CASE: struct (CType)
// #[repr(C)]
// $(#[$($meta)*])*
// $pub
// struct $StructName
// $(<$($lt ,)* $($($generics),+)?> $(where $($bounds)* )?)?
// {
// $(
// $(#[$($field_meta)*])*
// $field_pub
// $field_name : $field_ty,
// )*
// }

// #[cfg(any(
// $(all($($nodejs)?),)?
// ))]
// $crate::__cfg_node_js__! {
impl $(<$($lt ,)* $($($generics),+)?>)?
$crate::node_js::ReprNapi
for
Expand Down Expand Up @@ -216,168 +184,6 @@ macro_rules! CType {(
})
}
}
// }

// unsafe // Safety: struct is `#[repr(C)]` and contains `CType` fields
// impl $(<$($lt ,)* $($($generics),+)?>)? $crate::layout::LegacyCType
// for $StructName$(<$($lt ,)* $($($generics),+)?>)?
// where
// $(
// $field_ty : $crate::layout::CType,
// )*
// $(
// $($(
// $generics : $crate::layout::ReprC,
// )+)?
// $($($bounds)*)?
// )?
// { $crate::__cfg_headers__! {
// fn c_short_name_fmt (fmt: &'_ mut $crate::ඞ::fmt::Formatter<'_>)
// -> $crate::ඞ::fmt::Result
// {
// fmt.write_str($crate::ඞ::stringify!($StructName))?;
// $($(
// $(
// $crate::ඞ::write!(fmt, "_{}",
// <
// <$generics as $crate::layout::ReprC>::CLayout
// as
// $crate::layout::CType
// >::short_name()
// )?;
// )+
// )?)?
// Ok(())
// }

// fn c_define_self (definer: &'_ mut dyn $crate::headers::Definer)
// -> $crate::ඞ::io::Result<()>
// {
// assert_ne!(
// $crate::ඞ::mem::size_of::<Self>(), 0,
// "C does not support zero-sized structs!",
// );
// let ref me =
// <Self as $crate::layout::CType>::name(&$crate::headers::languages::C)
// .to_string()
// ;
// definer.define_once(
// me,
// &mut |definer| {
// $(
// <$field_ty as $crate::layout::CType>::define_self(&$crate::headers::languages::C, definer)?;
// )*
// let out = definer.out();
// $(
// $crate::__output_docs__!(out, "", $($doc_meta)*);
// )?
// $crate::__output_docs__!(out, "", $(#[$($meta)*])*);
// $crate::ඞ::writeln!(out, "typedef struct {{\n")?;
// $(
// if $crate::ඞ::mem::size_of::<$field_ty>() > 0 {
// // $crate::ඞ::writeln!(out, "")?;
// $crate::__output_docs__!(out, " ",
// $(#[$($field_meta)*])*
// );
// $crate::ඞ::writeln!(out, " {};\n",
// <$field_ty as $crate::layout::CType>::name_wrapping_var(
// &$crate::headers::languages::C,
// $crate::ඞ::stringify!($field_name),
// ),
// )?;
// } else {
// assert_eq!(
// $crate::ඞ::mem::align_of::<$field_ty>(),
// 1,
// $crate::ඞ::concat!(
// "Zero-sized fields must have an ",
// "alignment of `1`."
// ),
// );
// }
// )+
// $crate::ඞ::writeln!(out, "}} {};\n", me)
// },
// )
// }

// fn c_var_fmt (
// fmt: &'_ mut $crate::ඞ::fmt::Formatter<'_>,
// var_name: &'_ str,
// ) -> $crate::ඞ::fmt::Result
// {
// $crate::ඞ::write!(fmt,
// "{}_t{sep}{}",
// <Self as $crate::layout::CType>::short_name(),
// var_name,
// sep = if var_name.is_empty() { "" } else { " " },
// )
// }

// $crate::__cfg_csharp__! {
// fn csharp_define_self (definer: &'_ mut dyn $crate::headers::Definer)
// -> $crate::ඞ::io::Result<()>
// {
// assert_ne!(
// $crate::ඞ::mem::size_of::<Self>(), 0,
// "C# does not support zero-sized structs!",
// );
// let ref me = <Self as $crate::layout::CType>::name(&$crate::headers::languages::CSharp).to_string();
// $(
// <$field_ty as $crate::layout::CType>::define_self(&$crate::headers::languages::CSharp, definer)?;
// )*
// definer.define_once(me, &mut |definer| $crate::ඞ::writeln!(definer.out(),
// $crate::ඞ::concat!(
// "[StructLayout(LayoutKind.Sequential, Size = {size})]\n",
// "public unsafe struct {me} {{\n",
// $(
// "{}{", stringify!($field_name), "}",
// )*
// "}}\n",
// ),
// $(
// <$field_ty as $crate::layout::CType>::csharp_marshaler()
// .map(|m| $crate::ඞ::format!(" [MarshalAs({})]\n", m))
// .as_deref()
// .unwrap_or("")
// ,
// )*
// size = $crate::ඞ::mem::size_of::<Self>(),
// me = me, $(
// $field_name = {
// if $crate::ඞ::mem::size_of::<$field_ty>() > 0 {
// format!(
// " public {};\n",
// <$field_ty as $crate::layout::CType>::name_wrapping_var(
// &$crate::headers::languages::CSharp,
// $crate::ඞ::stringify!($field_name),
// ),
// )
// } else {
// assert_eq!(
// $crate::ඞ::mem::align_of::<$field_ty>(),
// 1,
// $crate::ඞ::concat!(
// "Zero-sized fields must have an ",
// "alignment of `1`."
// ),
// );
// "".into() // FIXME: remove heap allocation
// }
// }, )*
// ))
// }
// }
// } type OPAQUE_KIND = $crate::layout::OpaqueKind::Concrete; }

// $crate::layout::from_CType_impl_ReprC! {
// $(@for [$($lt ,)* $($($generics),+)?])?
// $StructName
// $(<$($lt ,)* $($($generics),+)?>
// where
// $($($bounds)*)?
// )?
// }
); (
@node_js_enum
$Enum_Layout:ident {
Expand Down

0 comments on commit 64cd908

Please sign in to comment.