mirror of
https://github.com/griffi-gh/hUI.git
synced 2024-11-21 14:48:42 -06:00
add derive macro for Signal
This commit is contained in:
parent
66ef58a131
commit
72ff23ac0b
|
@ -1,3 +1,3 @@
|
|||
[workspace]
|
||||
resolver = "2"
|
||||
members = ["hui", "hui-examples", "hui-glium", "hui-winit"]
|
||||
members = ["hui", "hui-derive", "hui-examples", "hui-glium", "hui-winit"]
|
||||
|
|
23
hui-derive/Cargo.toml
Normal file
23
hui-derive/Cargo.toml
Normal file
|
@ -0,0 +1,23 @@
|
|||
[package]
|
||||
name = "hui-derive"
|
||||
description = "Derive macros for hUI"
|
||||
repository = "https://github.com/griffi-gh/hui"
|
||||
readme = "../README.md"
|
||||
authors = ["griffi-gh <prasol258@gmail.com>"]
|
||||
rust-version = "1.75"
|
||||
version = "0.1.0-alpha.4"
|
||||
edition = "2021"
|
||||
license = "GPL-3.0-or-later"
|
||||
publish = true
|
||||
include = [
|
||||
"assets/**/*",
|
||||
"src/**/*.rs",
|
||||
"Cargo.toml",
|
||||
]
|
||||
|
||||
[lib]
|
||||
proc-macro = true
|
||||
|
||||
[dependencies]
|
||||
quote = "1.0"
|
||||
syn = "2.0"
|
12
hui-derive/src/lib.rs
Normal file
12
hui-derive/src/lib.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
extern crate proc_macro;
|
||||
|
||||
use proc_macro::TokenStream;
|
||||
use quote::quote;
|
||||
use syn::{parse_macro_input, DeriveInput};
|
||||
|
||||
#[proc_macro_derive(Signal)]
|
||||
pub fn signal(input: TokenStream) -> TokenStream {
|
||||
let input = parse_macro_input!(input as DeriveInput);
|
||||
let name = input.ident;
|
||||
quote!(impl ::hui::signal::Signal for #name {}).into()
|
||||
}
|
|
@ -16,6 +16,7 @@ include = [
|
|||
]
|
||||
|
||||
[dependencies]
|
||||
hui-derive = { version = "0.1.0-alpha.4", path = "../hui-derive", optional = true }
|
||||
hashbrown = "0.14"
|
||||
nohash-hasher = "0.2"
|
||||
glam = "0.27"
|
||||
|
@ -29,15 +30,14 @@ tinyset = "0.4"
|
|||
image = { version = "0.25", default-features = false, optional = true }
|
||||
|
||||
[features]
|
||||
default = ["el_all", "image", "builtin_font", "pixel_perfect_text"]
|
||||
default = ["el_all", "image", "builtin_font", "pixel_perfect_text", "derive"]
|
||||
|
||||
#! Image loading support:
|
||||
## Enable derive macros
|
||||
derive = ["dep:hui-derive"]
|
||||
|
||||
## Enable image loading support using the `image` crate
|
||||
image = ["dep:image"]
|
||||
|
||||
#! #### Built-in font:
|
||||
|
||||
## Enable the built-in font (ProggyTiny, adds *35kb* to the executable)
|
||||
builtin_font = []
|
||||
|
||||
|
|
|
@ -101,6 +101,8 @@ pub enum KeyboardKey {
|
|||
macro_rules! impl_fits64_for_keyboard_key {
|
||||
($($i:ident = $v:literal),*) => {
|
||||
impl Fits64 for KeyboardKey {
|
||||
// SAFETY: not actually doing anything unsafe
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn from_u64(x: u64) -> Self {
|
||||
match x {
|
||||
$( $v => KeyboardKey::$i, )*
|
||||
|
|
|
@ -5,9 +5,12 @@
|
|||
//! # Features
|
||||
#![doc = document_features::document_features!()]
|
||||
|
||||
#![allow(unused_parens)]
|
||||
//#![forbid(unsafe_code)]
|
||||
#![deny(unsafe_code)]
|
||||
#![forbid(unsafe_op_in_unsafe_fn)]
|
||||
#![allow(unused_parens)]
|
||||
|
||||
#[cfg(feature = "derive")]
|
||||
pub use hui_derive::*;
|
||||
|
||||
mod instance;
|
||||
mod macros;
|
||||
|
|
Loading…
Reference in a new issue