mirror of
https://github.com/griffi-gh/hUI.git
synced 2024-11-29 10:18:56 -06:00
add derive macro for Signal
This commit is contained in:
parent
9f3d2c7def
commit
5755613e90
|
@ -1,3 +1,3 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
resolver = "2"
|
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]
|
[dependencies]
|
||||||
|
hui-derive = { version = "0.1.0-alpha.4", path = "../hui-derive", optional = true }
|
||||||
hashbrown = "0.14"
|
hashbrown = "0.14"
|
||||||
nohash-hasher = "0.2"
|
nohash-hasher = "0.2"
|
||||||
glam = "0.27"
|
glam = "0.27"
|
||||||
|
@ -29,15 +30,14 @@ tinyset = "0.4"
|
||||||
image = { version = "0.25", default-features = false, optional = true }
|
image = { version = "0.25", default-features = false, optional = true }
|
||||||
|
|
||||||
[features]
|
[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
|
## Enable image loading support using the `image` crate
|
||||||
image = ["dep:image"]
|
image = ["dep:image"]
|
||||||
|
|
||||||
#! #### Built-in font:
|
|
||||||
|
|
||||||
## Enable the built-in font (ProggyTiny, adds *35kb* to the executable)
|
## Enable the built-in font (ProggyTiny, adds *35kb* to the executable)
|
||||||
builtin_font = []
|
builtin_font = []
|
||||||
|
|
||||||
|
|
|
@ -101,6 +101,8 @@ pub enum KeyboardKey {
|
||||||
macro_rules! impl_fits64_for_keyboard_key {
|
macro_rules! impl_fits64_for_keyboard_key {
|
||||||
($($i:ident = $v:literal),*) => {
|
($($i:ident = $v:literal),*) => {
|
||||||
impl Fits64 for KeyboardKey {
|
impl Fits64 for KeyboardKey {
|
||||||
|
// SAFETY: not actually doing anything unsafe
|
||||||
|
#[allow(unsafe_code)]
|
||||||
unsafe fn from_u64(x: u64) -> Self {
|
unsafe fn from_u64(x: u64) -> Self {
|
||||||
match x {
|
match x {
|
||||||
$( $v => KeyboardKey::$i, )*
|
$( $v => KeyboardKey::$i, )*
|
||||||
|
|
|
@ -5,9 +5,12 @@
|
||||||
//! # Features
|
//! # Features
|
||||||
#![doc = document_features::document_features!()]
|
#![doc = document_features::document_features!()]
|
||||||
|
|
||||||
#![allow(unused_parens)]
|
#![deny(unsafe_code)]
|
||||||
//#![forbid(unsafe_code)]
|
|
||||||
#![forbid(unsafe_op_in_unsafe_fn)]
|
#![forbid(unsafe_op_in_unsafe_fn)]
|
||||||
|
#![allow(unused_parens)]
|
||||||
|
|
||||||
|
#[cfg(feature = "derive")]
|
||||||
|
pub use hui_derive::*;
|
||||||
|
|
||||||
mod instance;
|
mod instance;
|
||||||
mod macros;
|
mod macros;
|
||||||
|
|
Loading…
Reference in a new issue