💥 Major Handle's improvement

This commit is contained in:
Manuel Cillero 2023-11-03 22:37:55 +01:00
parent c3c5e46508
commit 5b8c249785
34 changed files with 114 additions and 263 deletions

View file

@ -1,9 +1,5 @@
use crate::prelude::*;
new_handle!(COMPONENT_BASE_BLOCK);
actions_for_component!(Block);
#[rustfmt::skip]
#[derive(Default)]
pub struct Block {
@ -16,15 +12,13 @@ pub struct Block {
template : String,
}
impl_handle!(COMPONENT_BASE_BLOCK for Block);
impl ComponentTrait for Block {
fn new() -> Self {
Block::default().with_classes(ClassesOp::Add, "block")
}
fn handle(&self) -> Handle {
COMPONENT_BASE_BLOCK
}
fn id(&self) -> Option<String> {
self.id.get()
}
@ -37,10 +31,6 @@ impl ComponentTrait for Block {
(self.renderable.check)(cx)
}
fn before_prepare_component(&mut self, cx: &mut Context) {
run_actions_before_prepare_block(self, cx);
}
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
let id = cx.required_id::<Block>(self.id());
PrepareMarkup::With(html! {
@ -54,10 +44,6 @@ impl ComponentTrait for Block {
}
})
}
fn after_prepare_component(&mut self, cx: &mut Context) {
run_actions_after_prepare_block(self, cx);
}
}
impl Block {

View file

@ -1,7 +1,5 @@
use crate::prelude::*;
new_handle!(COMPONENT_BASE_BRANDING);
type SiteLogo = TypedComponent<Image>;
#[rustfmt::skip]
@ -28,15 +26,13 @@ impl Default for Branding {
}
}
impl_handle!(COMPONENT_BASE_BRANDING for Branding);
impl ComponentTrait for Branding {
fn new() -> Self {
Branding::default()
}
fn handle(&self) -> Handle {
COMPONENT_BASE_BRANDING
}
fn id(&self) -> Option<String> {
Some("pt-branding".to_owned())
}

View file

@ -1,9 +1,5 @@
use crate::prelude::*;
new_handle!(COMPONENT_BASE_FLEX_CONTAINER);
actions_for_component!(Container);
#[rustfmt::skip]
#[derive(Default)]
pub struct Container {
@ -19,15 +15,13 @@ pub struct Container {
gap : flex::Gap,
}
impl_handle!(COMPONENT_BASE_FLEX_CONTAINER for Container);
impl ComponentTrait for Container {
fn new() -> Self {
Container::default().with_classes(ClassesOp::Add, flex::Direction::Default.to_string())
}
fn handle(&self) -> Handle {
COMPONENT_BASE_FLEX_CONTAINER
}
fn id(&self) -> Option<String> {
self.id.get()
}
@ -40,10 +34,6 @@ impl ComponentTrait for Container {
(self.renderable.check)(cx)
}
fn before_prepare_component(&mut self, cx: &mut Context) {
run_actions_before_prepare_container(self, cx);
}
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
cx.set_param::<bool>(PARAM_BASE_INCLUDE_FLEX_ASSETS, true);
@ -58,10 +48,6 @@ impl ComponentTrait for Container {
}
})
}
fn after_prepare_component(&mut self, cx: &mut Context) {
run_actions_after_prepare_container(self, cx);
}
}
impl Container {

View file

@ -1,9 +1,5 @@
use crate::prelude::*;
new_handle!(COMPONENT_BASE_FLEX_ITEM);
actions_for_component!(Item);
#[rustfmt::skip]
#[derive(Default)]
pub struct Item {
@ -20,6 +16,8 @@ pub struct Item {
stuff : ArcComponents,
}
impl_handle!(COMPONENT_BASE_FLEX_ITEM for Item);
impl ComponentTrait for Item {
fn new() -> Self {
Item::default()
@ -27,10 +25,6 @@ impl ComponentTrait for Item {
.with_inner_classes(ClassesOp::Add, "pt-flex__item-inner")
}
fn handle(&self) -> Handle {
COMPONENT_BASE_FLEX_ITEM
}
fn id(&self) -> Option<String> {
self.id.get()
}
@ -43,10 +37,6 @@ impl ComponentTrait for Item {
(self.renderable.check)(cx)
}
fn before_prepare_component(&mut self, cx: &mut Context) {
run_actions_before_prepare_item(self, cx);
}
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
let order = match self.weight() {
0 => None,
@ -60,10 +50,6 @@ impl ComponentTrait for Item {
}
})
}
fn after_prepare_component(&mut self, cx: &mut Context) {
run_actions_after_prepare_item(self, cx);
}
}
impl Item {

View file

@ -1,7 +1,5 @@
use crate::prelude::*;
new_handle!(COMPONENT_BASE_BUTTON);
#[derive(Default)]
pub enum ButtonType {
#[default]
@ -24,15 +22,13 @@ pub struct Button {
template : String,
}
impl_handle!(COMPONENT_BASE_BUTTON for Button);
impl ComponentTrait for Button {
fn new() -> Self {
Button::default().with_classes(ClassesOp::Add, "btn btn-primary form-button")
}
fn handle(&self) -> Handle {
COMPONENT_BASE_BUTTON
}
fn weight(&self) -> Weight {
self.weight
}

View file

@ -1,7 +1,5 @@
use crate::prelude::*;
new_handle!(COMPONENT_BASE_DATE);
#[rustfmt::skip]
#[derive(Default)]
pub struct Date {
@ -21,15 +19,13 @@ pub struct Date {
template : String,
}
impl_handle!(COMPONENT_BASE_DATE for Date);
impl ComponentTrait for Date {
fn new() -> Self {
Date::default().with_classes(ClassesOp::Add, "form-item form-type-date")
}
fn handle(&self) -> Handle {
COMPONENT_BASE_DATE
}
fn weight(&self) -> Weight {
self.weight
}

View file

@ -1,9 +1,5 @@
use crate::prelude::*;
new_handle!(COMPONENT_BASE_FORM);
actions_for_component!(Form);
#[derive(Default)]
pub enum FormMethod {
#[default]
@ -25,6 +21,8 @@ pub struct Form {
template : String,
}
impl_handle!(COMPONENT_BASE_FORM for Form);
impl ComponentTrait for Form {
fn new() -> Self {
Form::default()
@ -32,10 +30,6 @@ impl ComponentTrait for Form {
.with_charset("UTF-8")
}
fn handle(&self) -> Handle {
COMPONENT_BASE_FORM
}
fn id(&self) -> Option<String> {
self.id.get()
}
@ -48,10 +42,6 @@ impl ComponentTrait for Form {
(self.renderable.check)(cx)
}
fn before_prepare_component(&mut self, cx: &mut Context) {
run_actions_before_prepare_form(self, cx);
}
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
let method = match self.method() {
FormMethod::Post => Some("post".to_owned()),
@ -69,10 +59,6 @@ impl ComponentTrait for Form {
}
})
}
fn after_prepare_component(&mut self, cx: &mut Context) {
run_actions_after_prepare_form(self, cx);
}
}
impl Form {

View file

@ -1,7 +1,5 @@
use crate::prelude::*;
new_handle!(COMPONENT_BASE_HIDDEN);
#[rustfmt::skip]
#[derive(Default)]
pub struct Hidden {
@ -10,15 +8,13 @@ pub struct Hidden {
value : OptionString,
}
impl_handle!(COMPONENT_BASE_HIDDEN for Hidden);
impl ComponentTrait for Hidden {
fn new() -> Self {
Hidden::default()
}
fn handle(&self) -> Handle {
COMPONENT_BASE_HIDDEN
}
fn weight(&self) -> Weight {
self.weight
}

View file

@ -1,7 +1,5 @@
use crate::prelude::*;
new_handle!(COMPONENT_BASE_INPUT);
#[derive(Default)]
pub enum InputType {
#[default]
@ -36,6 +34,8 @@ pub struct Input {
template : String,
}
impl_handle!(COMPONENT_BASE_INPUT for Input);
impl ComponentTrait for Input {
fn new() -> Self {
Input::default()
@ -44,10 +44,6 @@ impl ComponentTrait for Input {
.with_maxlength(Some(128))
}
fn handle(&self) -> Handle {
COMPONENT_BASE_INPUT
}
fn weight(&self) -> Weight {
self.weight
}

View file

@ -1,7 +1,5 @@
use crate::prelude::*;
new_handle!(COMPONENT_BASE_HEADING);
#[derive(Default)]
pub enum HeadingType {
#[default]
@ -52,15 +50,13 @@ pub struct Heading {
display : HeadingDisplay,
}
impl_handle!(COMPONENT_BASE_HEADING for Heading);
impl ComponentTrait for Heading {
fn new() -> Self {
Heading::default()
}
fn handle(&self) -> Handle {
COMPONENT_BASE_HEADING
}
fn id(&self) -> Option<String> {
self.id.get()
}

View file

@ -1,19 +1,15 @@
use crate::prelude::*;
new_handle!(COMPONENT_BASE_HTML);
#[derive(Default)]
pub struct Html(Markup);
impl_handle!(COMPONENT_BASE_HTML for Html);
impl ComponentTrait for Html {
fn new() -> Self {
Html::default()
}
fn handle(&self) -> Handle {
COMPONENT_BASE_HTML
}
fn prepare_component(&self, _cx: &mut Context) -> PrepareMarkup {
PrepareMarkup::With(html! { (self.html()) })
}

View file

@ -1,7 +1,5 @@
use crate::prelude::*;
new_handle!(COMPONENT_BASE_ICON);
#[rustfmt::skip]
#[derive(Default)]
pub struct Icon {
@ -12,15 +10,13 @@ pub struct Icon {
icon_name : String,
}
impl_handle!(COMPONENT_BASE_ICON for Icon);
impl ComponentTrait for Icon {
fn new() -> Self {
Icon::default()
}
fn handle(&self) -> Handle {
COMPONENT_BASE_ICON
}
fn weight(&self) -> Weight {
self.weight
}

View file

@ -1,7 +1,5 @@
use crate::prelude::*;
new_handle!(COMPONENT_BASE_IMAGE);
const IMG_FLUID: &str = "pt-img__fluid";
const IMG_FIXED: &str = "pt-img__fixed";
@ -26,15 +24,13 @@ pub struct Image {
size : ImageSize,
}
impl_handle!(COMPONENT_BASE_IMAGE for Image);
impl ComponentTrait for Image {
fn new() -> Self {
Image::default().with_classes(ClassesOp::Add, IMG_FLUID)
}
fn handle(&self) -> Handle {
COMPONENT_BASE_IMAGE
}
fn id(&self) -> Option<String> {
self.id.get()
}

View file

@ -2,8 +2,6 @@ use crate::prelude::*;
use super::Submenu;
new_handle!(COMPONENT_BASE_MENU_ELEMENT);
type Content = TypedComponent<Html>;
type SubmenuItems = TypedComponent<Submenu>;
@ -25,15 +23,13 @@ pub struct Element {
element_type: ElementType,
}
impl_handle!(COMPONENT_BASE_MENU_ELEMENT for Element);
impl ComponentTrait for Element {
fn new() -> Self {
Element::default()
}
fn handle(&self) -> Handle {
COMPONENT_BASE_MENU_ELEMENT
}
fn weight(&self) -> Weight {
self.weight
}

View file

@ -2,8 +2,6 @@ use crate::prelude::*;
use super::Element;
new_handle!(COMPONENT_BASE_MENU_GROUP);
type Elements = TypedComponents<Element>;
#[rustfmt::skip]
@ -15,15 +13,13 @@ pub struct Group {
elements : Elements,
}
impl_handle!(COMPONENT_BASE_MENU_GROUP for Group);
impl ComponentTrait for Group {
fn new() -> Self {
Group::default()
}
fn handle(&self) -> Handle {
COMPONENT_BASE_MENU_GROUP
}
fn id(&self) -> Option<String> {
self.id.get()
}

View file

@ -2,8 +2,6 @@ use crate::prelude::*;
use super::{Megamenu, Submenu};
new_handle!(COMPONENT_BASE_MENU_ITEM);
type Label = L10n;
type Content = TypedComponent<Html>;
type SubmenuItems = TypedComponent<Submenu>;
@ -32,15 +30,13 @@ pub struct Item {
description: OptionTranslated,
}
impl_handle!(COMPONENT_BASE_MENU_ITEM for Item);
impl ComponentTrait for Item {
fn new() -> Self {
Item::default()
}
fn handle(&self) -> Handle {
COMPONENT_BASE_MENU_ITEM
}
fn weight(&self) -> Weight {
self.weight
}

View file

@ -2,8 +2,6 @@ use crate::prelude::*;
use super::Group;
new_handle!(COMPONENT_BASE_MENU_MEGAMENU);
type Groups = TypedComponents<Group>;
#[rustfmt::skip]
@ -15,15 +13,13 @@ pub struct Megamenu {
groups : Groups,
}
impl_handle!(COMPONENT_BASE_MENU_MEGAMENU for Megamenu);
impl ComponentTrait for Megamenu {
fn new() -> Self {
Megamenu::default()
}
fn handle(&self) -> Handle {
COMPONENT_BASE_MENU_MEGAMENU
}
fn id(&self) -> Option<String> {
self.id.get()
}

View file

@ -2,10 +2,6 @@ use crate::prelude::*;
use super::Item;
new_handle!(COMPONENT_BASE_MENU);
actions_for_component!(Menu);
#[rustfmt::skip]
#[derive(Default)]
pub struct Menu {
@ -15,15 +11,13 @@ pub struct Menu {
items : TypedComponents<Item>,
}
impl_handle!(COMPONENT_BASE_MENU for Menu);
impl ComponentTrait for Menu {
fn new() -> Self {
Menu::default()
}
fn handle(&self) -> Handle {
COMPONENT_BASE_MENU
}
fn id(&self) -> Option<String> {
self.id.get()
}
@ -36,10 +30,6 @@ impl ComponentTrait for Menu {
(self.renderable.check)(cx)
}
fn before_prepare_component(&mut self, cx: &mut Context) {
run_actions_before_prepare_menu(self, cx);
}
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
cx.set_param::<bool>(PARAM_BASE_INCLUDE_MENU_ASSETS, true);
cx.set_param::<bool>(PARAM_BASE_INCLUDE_ICONS, true);
@ -75,10 +65,6 @@ impl ComponentTrait for Menu {
}
})
}
fn after_prepare_component(&mut self, cx: &mut Context) {
run_actions_after_prepare_menu(self, cx);
}
}
impl Menu {

View file

@ -2,8 +2,6 @@ use crate::prelude::*;
use super::Item;
new_handle!(COMPONENT_BASE_MENU_SUBMENU);
type Items = TypedComponents<Item>;
#[rustfmt::skip]
@ -16,15 +14,13 @@ pub struct Submenu {
items : Items,
}
impl_handle!(COMPONENT_BASE_MENU_SUBMENU for Submenu);
impl ComponentTrait for Submenu {
fn new() -> Self {
Submenu::default()
}
fn handle(&self) -> Handle {
COMPONENT_BASE_MENU_SUBMENU
}
fn id(&self) -> Option<String> {
self.id.get()
}

View file

@ -1,7 +1,5 @@
use crate::prelude::*;
new_handle!(COMPONENT_BASE_PARAGRAPH);
#[rustfmt::skip]
#[derive(Default)]
pub struct Paragraph {
@ -13,15 +11,13 @@ pub struct Paragraph {
stuff : ArcComponents,
}
impl_handle!(COMPONENT_BASE_PARAGRAPH for Paragraph);
impl ComponentTrait for Paragraph {
fn new() -> Self {
Paragraph::default()
}
fn handle(&self) -> Handle {
COMPONENT_BASE_PARAGRAPH
}
fn id(&self) -> Option<String> {
self.id.get()
}

View file

@ -1,7 +1,5 @@
use crate::prelude::*;
new_handle!(COMPONENT_BASE_POWEREDBY);
#[derive(Default, Eq, PartialEq)]
pub enum PoweredByLogo {
#[default]
@ -21,6 +19,8 @@ pub struct PoweredBy {
logo : PoweredByLogo,
}
impl_handle!(COMPONENT_BASE_POWEREDBY for PoweredBy);
impl ComponentTrait for PoweredBy {
fn new() -> Self {
let year = Utc::now().format("%Y").to_string();
@ -31,10 +31,6 @@ impl ComponentTrait for PoweredBy {
}
}
fn handle(&self) -> Handle {
COMPONENT_BASE_POWEREDBY
}
fn id(&self) -> Option<String> {
Some("pt-poweredby".to_owned())
}

View file

@ -1,19 +1,15 @@
use crate::prelude::*;
new_handle!(COMPONENT_BASE_TRANSLATE);
#[derive(Default)]
pub struct Translate(L10n);
impl_handle!(COMPONENT_BASE_TRANSLATE for Translate);
impl ComponentTrait for Translate {
fn new() -> Self {
Translate::default()
}
fn handle(&self) -> Handle {
COMPONENT_BASE_TRANSLATE
}
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
PrepareMarkup::With(self.l10n().escaped(cx.langid()))
}

View file

@ -1,9 +1,5 @@
use crate::prelude::*;
new_handle!(COMPONENT_BASE_WRAPPER);
actions_for_component!(Wrapper);
#[derive(Default)]
pub enum WrapperType {
#[default]
@ -27,6 +23,8 @@ pub struct Wrapper {
template : String,
}
impl_handle!(COMPONENT_BASE_WRAPPER for Wrapper);
impl ComponentTrait for Wrapper {
fn new() -> Self {
Wrapper::default()
@ -34,10 +32,6 @@ impl ComponentTrait for Wrapper {
.with_inner_classes(ClassesOp::Add, "container")
}
fn handle(&self) -> Handle {
COMPONENT_BASE_WRAPPER
}
fn id(&self) -> Option<String> {
self.id.get()
}
@ -50,10 +44,6 @@ impl ComponentTrait for Wrapper {
(self.renderable.check)(cx)
}
fn before_prepare_component(&mut self, cx: &mut Context) {
run_actions_before_prepare_wrapper(self, cx);
}
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
match self.wrapper_type() {
WrapperType::Header => PrepareMarkup::With(html! {
@ -91,10 +81,6 @@ impl ComponentTrait for Wrapper {
}),
}
}
fn after_prepare_component(&mut self, cx: &mut Context) {
run_actions_after_prepare_wrapper(self, cx);
}
}
impl Wrapper {

View file

@ -1,14 +1,10 @@
use crate::prelude::*;
new_handle!(THEME_BASIC);
pub struct Basic;
impl ModuleTrait for Basic {
fn handle(&self) -> Handle {
THEME_BASIC
}
impl_handle!(THEME_BASIC for Basic);
impl ModuleTrait for Basic {
fn name(&self) -> L10n {
L10n::n("Basic")
}

View file

@ -1,14 +1,10 @@
use crate::prelude::*;
new_handle!(THEME_CHASSIS);
pub struct Chassis;
impl ModuleTrait for Chassis {
fn handle(&self) -> Handle {
THEME_CHASSIS
}
impl_handle!(THEME_CHASSIS for Chassis);
impl ModuleTrait for Chassis {
fn name(&self) -> L10n {
L10n::n("Chassis")
}

View file

@ -1,14 +1,10 @@
use crate::prelude::*;
new_handle!(THEME_INCEPTION);
pub struct Inception;
impl ModuleTrait for Inception {
fn handle(&self) -> Handle {
THEME_INCEPTION
}
impl_handle!(THEME_INCEPTION for Inception);
impl ModuleTrait for Inception {
fn name(&self) -> L10n {
L10n::n("Inception")
}

View file

@ -1,22 +1,18 @@
use crate::core::component::{ComponentTrait, Context};
use crate::html::{html, Markup};
use crate::{new_handle, Handle, Weight};
use crate::{impl_handle, Handle, Weight};
use std::sync::{Arc, RwLock, RwLockReadGuard};
new_handle!(COMPONENT_NULL for Crate);
#[derive(Default)]
struct ComponentNull;
impl_handle!(COMPONENT_NULL for ComponentNull);
impl ComponentTrait for ComponentNull {
fn new() -> Self {
ComponentNull::default()
}
fn handle(&self) -> Handle {
COMPONENT_NULL
}
}
#[derive(Clone)]

View file

@ -1,6 +1,6 @@
use crate::core::component::Context;
use crate::html::{html, Markup, PrepareMarkup};
use crate::{util, Handle, Weight};
use crate::{util, HasHandle, Weight};
use std::any::Any;
@ -12,13 +12,11 @@ pub trait ComponentBase: Any {
fn as_mut_any(&mut self) -> &mut dyn Any;
}
pub trait ComponentTrait: ComponentBase + Send + Sync {
pub trait ComponentTrait: ComponentBase + HasHandle + Send + Sync {
fn new() -> Self
where
Self: Sized;
fn handle(&self) -> Handle;
fn name(&self) -> String {
util::single_type_name::<Self>().to_owned()
}

View file

@ -1,7 +1,7 @@
use crate::core::action::Action;
use crate::core::theme::ThemeRef;
use crate::locale::L10n;
use crate::{actions, service, util, Handle};
use crate::{actions, service, util, HasHandle};
#[cfg(feature = "database")]
use crate::{db::MigrationItem, migrations};
@ -13,9 +13,7 @@ pub trait ModuleBase {
}
/// Los módulos deben implementar este *trait*.
pub trait ModuleTrait: ModuleBase + Send + Sync {
fn handle(&self) -> Handle;
pub trait ModuleTrait: HasHandle + ModuleBase + Send + Sync {
fn name(&self) -> L10n {
L10n::n(self.single_name())
}

View file

@ -44,7 +44,7 @@
//! ```rust
//! use pagetop::prelude::*;
//!
//! new_handle!(APP_HELLO_WORLD);
//! impl_handle!(APP_HELLO_WORLD for HelloWorld);
//!
//! struct HelloWorld;
//!
@ -119,6 +119,15 @@ pub use once_cell::sync::Lazy as LazyStatic;
pub use static_files::Resource as StaticResource;
pub type Handle = u64;
pub trait HasHandle {
fn static_handle() -> Handle
where
Self: Sized;
fn handle(&self) -> Handle;
}
pub type Weight = i8;
pub type HashMapResources = std::collections::HashMap<&'static str, StaticResource>;

View file

@ -8,7 +8,7 @@ pub use crate::{Handle, HashMapResources, LazyStatic, Weight};
// Functions and macro helpers.
pub use crate::util;
pub use crate::{kv, new_handle};
pub use crate::{impl_handle, kv};
// MACROS.
@ -20,8 +20,6 @@ pub use crate::new_static_locales;
pub use crate::{new_static_files, service_for_static_files};
// crate::core::actions
pub use crate::actions;
// crate::base::action::component
pub use crate::actions_for_component;
// API.

View file

@ -1,20 +1,16 @@
use crate::core::component::{ComponentTrait, Context};
use crate::html::{html, PrepareMarkup};
use crate::{new_handle, Handle};
new_handle!(ERROR_403);
use crate::impl_handle;
pub struct Error403;
impl_handle!(ERROR_403 for Error403);
impl ComponentTrait for Error403 {
fn new() -> Self {
Self
}
fn handle(&self) -> Handle {
ERROR_403
}
fn prepare_component(&self, _cx: &mut Context) -> PrepareMarkup {
PrepareMarkup::With(html! {
div {

View file

@ -1,20 +1,16 @@
use crate::core::component::{ComponentTrait, Context};
use crate::html::{html, PrepareMarkup};
use crate::{new_handle, Handle};
new_handle!(ERROR_404);
use crate::impl_handle;
pub struct Error404;
impl_handle!(ERROR_404 for Error404);
impl ComponentTrait for Error404 {
fn new() -> Self {
Self
}
fn handle(&self) -> Handle {
ERROR_404
}
fn prepare_component(&self, _cx: &mut Context) -> PrepareMarkup {
PrepareMarkup::With(html! {
div {

View file

@ -92,6 +92,44 @@ pub fn absolute_dir(
// MACRO HELPERS.
// *************************************************************************************************
#[macro_export]
macro_rules! impl_handle {
( $HANDLE:ident for $Element:ident ) => {
/// Constant handle to represent a unique PageTop building element.
pub const $HANDLE: $crate::Handle =
$crate::util::handle(module_path!(), file!(), line!(), column!());
impl $crate::HasHandle for $Element {
#[inline]
fn static_handle() -> $crate::Handle {
$HANDLE
}
#[inline]
fn handle(&self) -> $crate::Handle {
$HANDLE
}
}
};
( $HANDLE:ident for $Element:ident<$Implement:ident> ) => {
/// Constant handle to represent a unique PageTop building element.
pub const $HANDLE: $crate::Handle =
$crate::util::handle(module_path!(), file!(), line!(), column!());
impl<I: $Implement> $crate::HasHandle for $Element<I> {
#[inline]
fn static_handle() -> $crate::Handle {
$HANDLE
}
#[inline]
fn handle(&self) -> $crate::Handle {
$HANDLE
}
}
};
}
#[macro_export]
/// Macro para construir grupos de pares clave-valor.
///
@ -111,17 +149,3 @@ macro_rules! kv {
a
}};
}
#[macro_export]
macro_rules! new_handle {
( $HANDLE:ident ) => {
/// Public constant handle to represent a unique PageTop building element.
pub const $HANDLE: $crate::Handle =
$crate::util::handle(module_path!(), file!(), line!(), column!());
};
( $HANDLE:ident for Crate ) => {
/// Local constant handle to represent a unique PageTop building element.
pub(crate) const $HANDLE: $crate::Handle =
$crate::util::handle(module_path!(), file!(), line!(), column!());
};
}