Modifica tipos numéricos por isize/usize

This commit is contained in:
Manuel Cillero 2022-05-04 18:21:36 +02:00
parent d0e566aede
commit 7c8f51ba86
20 changed files with 77 additions and 78 deletions

View file

@ -7,13 +7,13 @@ pub trait BaseAction {
fn single_name(&self) -> &'static str;
fn qualified_name(&self, last: u8) -> &'static str;
fn qualified_name(&self, last: usize) -> &'static str;
}
pub trait ActionTrait: AnyAction + BaseAction + Send + Sync {
fn new() -> Self where Self: Sized;
fn weight(&self) -> i8 {
fn weight(&self) -> isize {
0
}
@ -29,7 +29,7 @@ impl<C: ?Sized + ActionTrait> BaseAction for C {
util::partial_type_name(std::any::type_name::<Self>(), 1)
}
fn qualified_name(&self, last: u8) -> &'static str {
fn qualified_name(&self, last: usize) -> &'static str {
util::partial_type_name(std::any::type_name::<Self>(), last)
}
}

View file

@ -8,7 +8,7 @@ pub enum TypeAction {
pub struct ComponentAction {
action: TypeAction,
weight: i8,
weight: isize,
}
impl ActionTrait for ComponentAction {
@ -19,7 +19,7 @@ impl ActionTrait for ComponentAction {
}
}
fn weight(&self) -> i8 {
fn weight(&self) -> isize {
self.weight
}
@ -36,7 +36,7 @@ impl ComponentAction {
}
}
pub fn new_with_weight(action: TypeAction, weight: i8) -> Self {
pub fn new_with_weight(action: TypeAction, weight: isize) -> Self {
ComponentAction {
action,
weight,

View file

@ -101,7 +101,7 @@ impl Favicon {
pub struct StyleSheet {
source: &'static str,
weight: i8,
weight: isize,
}
impl StyleSheet {
pub fn source(s: &'static str) -> Self {
@ -111,12 +111,12 @@ impl StyleSheet {
}
}
pub fn with_weight(mut self, weight: i8) -> Self {
pub fn with_weight(mut self, weight: isize) -> Self {
self.weight = weight;
self
}
pub fn weight(self) -> i8 {
pub fn weight(self) -> isize {
self.weight
}
@ -134,7 +134,7 @@ pub enum JSMode { Async, Defer, Normal }
pub struct JavaScript {
source: &'static str,
weight: i8,
weight: isize,
mode : JSMode,
}
impl JavaScript {
@ -146,7 +146,7 @@ impl JavaScript {
}
}
pub fn with_weight(mut self, weight: i8) -> Self {
pub fn with_weight(mut self, weight: isize) -> Self {
self.weight = weight;
self
}
@ -156,7 +156,7 @@ impl JavaScript {
self
}
pub fn weight(self) -> i8 {
pub fn weight(self) -> isize {
self.weight
}
@ -180,7 +180,7 @@ pub struct PageAssets {
stylesheets: Vec<StyleSheet>,
javascripts: Vec<JavaScript>,
with_jquery: bool,
id_counter : u32,
id_counter : usize,
}
impl PageAssets {
@ -239,7 +239,7 @@ impl PageAssets {
JavaScript::source(
"/theme/js/jquery.min.js?ver=3.6.0"
)
.with_weight(i8::MIN)
.with_weight(isize::MIN)
.with_mode(JSMode::Normal)
);
self.with_jquery = true;

View file

@ -11,7 +11,7 @@ pub trait BaseComponent {
fn single_name(&self) -> &'static str;
fn qualified_name(&self, last: u8) -> &'static str;
fn qualified_name(&self, last: usize) -> &'static str;
}
pub trait ComponentTrait: AnyComponent + BaseComponent + Send + Sync {
@ -30,7 +30,7 @@ pub trait ComponentTrait: AnyComponent + BaseComponent + Send + Sync {
true
}
fn weight(&self) -> i8 {
fn weight(&self) -> isize {
0
}
@ -57,7 +57,7 @@ impl<C: ?Sized + ComponentTrait> BaseComponent for C {
util::partial_type_name(std::any::type_name::<Self>(), 1)
}
fn qualified_name(&self, last: u8) -> &'static str {
fn qualified_name(&self, last: usize) -> &'static str {
util::partial_type_name(std::any::type_name::<Self>(), last)
}
}

View file

@ -8,7 +8,7 @@ pub trait BaseModule {
fn single_name(&self) -> &'static str;
fn qualified_name(&self, last: u8) -> &'static str;
fn qualified_name(&self, last: usize) -> &'static str;
}
/// Los módulos deben implementar este *trait*.
@ -45,7 +45,7 @@ impl<M: ?Sized + ModuleTrait> BaseModule for M {
util::partial_type_name(std::any::type_name::<Self>(), 1)
}
fn qualified_name(&self, last: u8) -> &'static str {
fn qualified_name(&self, last: usize) -> &'static str {
util::partial_type_name(std::any::type_name::<Self>(), last)
}
}

View file

@ -11,7 +11,7 @@ pub trait BaseTheme {
fn single_name(&self) -> &'static str;
fn qualified_name(&self, last: u8) -> &'static str;
fn qualified_name(&self, last: usize) -> &'static str;
}
/// Los temas deben implementar este "trait".
@ -147,7 +147,7 @@ impl<T: ?Sized + ThemeTrait> BaseTheme for T {
util::partial_type_name(std::any::type_name::<Self>(), 1)
}
fn qualified_name(&self, last: u8) -> &'static str {
fn qualified_name(&self, last: usize) -> &'static str {
util::partial_type_name(std::any::type_name::<Self>(), last)
}
}

View file

@ -4,7 +4,7 @@ pub const TYPENAME_BLOCK: &str = "pagetop::base::component::block::Block";
pub struct Block {
renderable: fn() -> bool,
weight : i8,
weight : isize,
components: PageContainer,
title : OptAttr,
id : OptIden,
@ -29,7 +29,7 @@ impl ComponentTrait for Block {
(self.renderable)()
}
fn weight(&self) -> i8 {
fn weight(&self) -> isize {
self.weight
}
@ -77,7 +77,7 @@ impl Block {
self
}
pub fn with_weight(mut self, weight: i8) -> Self {
pub fn with_weight(mut self, weight: isize) -> Self {
self.alter_weight(weight);
self
}
@ -109,7 +109,7 @@ impl Block {
self
}
pub fn alter_weight(&mut self, weight: i8) -> &mut Self {
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
self.weight = weight;
self
}

View file

@ -4,7 +4,7 @@ pub const TYPENAME_CHUNCK: &str = "pagetop::base::component::chunck::Chunck";
pub struct Chunck {
renderable: fn() -> bool,
weight : i8,
weight : isize,
html : Markup,
template : String,
}
@ -23,7 +23,7 @@ impl ComponentTrait for Chunck {
(self.renderable)()
}
fn weight(&self) -> i8 {
fn weight(&self) -> isize {
self.weight
}
@ -52,7 +52,7 @@ impl Chunck {
self
}
pub fn with_weight(mut self, weight: i8) -> Self {
pub fn with_weight(mut self, weight: isize) -> Self {
self.alter_weight(weight);
self
}
@ -74,7 +74,7 @@ impl Chunck {
self
}
pub fn alter_weight(&mut self, weight: i8) -> &mut Self {
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
self.weight = weight;
self
}

View file

@ -6,7 +6,7 @@ pub enum ContainerType { Header, Footer, Main, Section, Wrapper }
pub struct Container {
renderable : fn() -> bool,
weight : i8,
weight : isize,
components : PageContainer,
container : ContainerType,
id : OptIden,
@ -33,7 +33,7 @@ impl ComponentTrait for Container {
(self.renderable)()
}
fn weight(&self) -> i8 {
fn weight(&self) -> isize {
self.weight
}
@ -127,7 +127,7 @@ impl Container {
self
}
pub fn with_weight(mut self, weight: i8) -> Self {
pub fn with_weight(mut self, weight: isize) -> Self {
self.alter_weight(weight);
self
}
@ -159,7 +159,7 @@ impl Container {
self
}
pub fn alter_weight(&mut self, weight: i8) -> &mut Self {
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
self.weight = weight;
self
}

View file

@ -6,7 +6,7 @@ pub enum ButtonType {Button, Reset, Submit}
pub struct Button {
renderable : fn() -> bool,
weight : i8,
weight : isize,
button_type: ButtonType,
name : OptAttr,
value : OptAttr,
@ -36,7 +36,7 @@ impl ComponentTrait for Button {
(self.renderable)()
}
fn weight(&self) -> i8 {
fn weight(&self) -> isize {
self.weight
}
@ -105,7 +105,7 @@ impl Button {
self
}
pub fn with_weight(mut self, weight: i8) -> Self {
pub fn with_weight(mut self, weight: isize) -> Self {
self.alter_weight(weight);
self
}
@ -147,7 +147,7 @@ impl Button {
self
}
pub fn alter_weight(&mut self, weight: i8) -> &mut Self {
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
self.weight = weight;
self
}

View file

@ -4,7 +4,7 @@ pub const TYPENAME_DATE: &str = "pagetop::base::component::form::date::Date";
pub struct Date {
renderable : fn() -> bool,
weight : i8,
weight : isize,
name : OptAttr,
value : OptAttr,
label : OptAttr,
@ -44,7 +44,7 @@ impl ComponentTrait for Date {
(self.renderable)()
}
fn weight(&self) -> i8 {
fn weight(&self) -> isize {
self.weight
}
@ -105,7 +105,7 @@ impl Date {
self
}
pub fn with_weight(mut self, weight: i8) -> Self {
pub fn with_weight(mut self, weight: isize) -> Self {
self.alter_weight(weight);
self
}
@ -177,7 +177,7 @@ impl Date {
self
}
pub fn alter_weight(&mut self, weight: i8) -> &mut Self {
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
self.weight = weight;
self
}

View file

@ -6,7 +6,7 @@ pub enum FormMethod {Get, Post}
pub struct Form {
renderable: fn() -> bool,
weight : i8,
weight : isize,
elements : PageContainer,
action : OptAttr,
charset : OptAttr,
@ -35,7 +35,7 @@ impl ComponentTrait for Form {
(self.renderable)()
}
fn weight(&self) -> i8 {
fn weight(&self) -> isize {
self.weight
}
@ -86,7 +86,7 @@ impl Form {
self
}
pub fn with_weight(mut self, weight: i8) -> Self {
pub fn with_weight(mut self, weight: isize) -> Self {
self.alter_weight(weight);
self
}
@ -128,7 +128,7 @@ impl Form {
self
}
pub fn alter_weight(&mut self, weight: i8) -> &mut Self {
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
self.weight = weight;
self
}

View file

@ -3,7 +3,7 @@ use crate::prelude::*;
pub const TYPENAME_HIDDEN: &str = "pagetop::base::component::form::hidden::Hidden";
pub struct Hidden {
weight: i8,
weight: isize,
name : OptIden,
value : OptAttr,
}
@ -17,7 +17,7 @@ impl ComponentTrait for Hidden {
}
}
fn weight(&self) -> i8 {
fn weight(&self) -> isize {
self.weight
}
@ -47,7 +47,7 @@ impl Hidden {
// Hidden BUILDER.
pub fn with_weight(mut self, weight: i8) -> Self {
pub fn with_weight(mut self, weight: isize) -> Self {
self.alter_weight(weight);
self
}
@ -64,7 +64,7 @@ impl Hidden {
// Hidden ALTER.
pub fn alter_weight(&mut self, weight: i8) -> &mut Self {
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
self.weight = weight;
self
}

View file

@ -6,7 +6,7 @@ pub enum InputType {Email, Password, Search, Telephone, Textfield, Url}
pub struct Input {
renderable : fn() -> bool,
weight : i8,
weight : isize,
input_type : InputType,
name : OptIden,
value : OptAttr,
@ -54,7 +54,7 @@ impl ComponentTrait for Input {
(self.renderable)()
}
fn weight(&self) -> i8 {
fn weight(&self) -> isize {
self.weight
}
@ -171,7 +171,7 @@ impl Input {
self
}
pub fn with_weight(mut self, weight: i8) -> Self {
pub fn with_weight(mut self, weight: isize) -> Self {
self.alter_weight(weight);
self
}
@ -258,7 +258,7 @@ impl Input {
self
}
pub fn alter_weight(&mut self, weight: i8) -> &mut Self {
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
self.weight = weight;
self
}

View file

@ -4,7 +4,7 @@ pub const TYPENAME_COLUMN: &str = "pagetop::base::component::grid::column::Colum
pub struct Column {
renderable: fn() -> bool,
weight : i8,
weight : isize,
components: PageContainer,
id : OptIden,
classes : Classes,
@ -27,7 +27,7 @@ impl ComponentTrait for Column {
(self.renderable)()
}
fn weight(&self) -> i8 {
fn weight(&self) -> isize {
self.weight
}
@ -68,7 +68,7 @@ impl Column {
self
}
pub fn with_weight(mut self, weight: i8) -> Self {
pub fn with_weight(mut self, weight: isize) -> Self {
self.alter_weight(weight);
self
}
@ -95,7 +95,7 @@ impl Column {
self
}
pub fn alter_weight(&mut self, weight: i8) -> &mut Self {
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
self.weight = weight;
self
}

View file

@ -4,7 +4,7 @@ pub const TYPENAME_ROW: &str = "pagetop::base::component::grid::row::Row";
pub struct Row {
renderable: fn() -> bool,
weight : i8,
weight : isize,
columns : PageContainer,
id : OptIden,
classes : Classes,
@ -27,7 +27,7 @@ impl ComponentTrait for Row {
(self.renderable)()
}
fn weight(&self) -> i8 {
fn weight(&self) -> isize {
self.weight
}
@ -68,7 +68,7 @@ impl Row {
self
}
pub fn with_weight(mut self, weight: i8) -> Self {
pub fn with_weight(mut self, weight: isize) -> Self {
self.alter_weight(weight);
self
}
@ -95,7 +95,7 @@ impl Row {
self
}
pub fn alter_weight(&mut self, weight: i8) -> &mut Self {
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
self.weight = weight;
self
}

View file

@ -4,7 +4,7 @@ pub const TYPENAME_IMAGE: &str = "pagetop::base::component::image::Image";
pub struct Image {
renderable: fn() -> bool,
weight : i8,
weight : isize,
source : OptAttr,
id : OptIden,
classes : Classes,
@ -27,7 +27,7 @@ impl ComponentTrait for Image {
(self.renderable)()
}
fn weight(&self) -> i8 {
fn weight(&self) -> isize {
self.weight
}
@ -61,7 +61,7 @@ impl Image {
self
}
pub fn with_weight(mut self, weight: i8) -> Self {
pub fn with_weight(mut self, weight: isize) -> Self {
self.alter_weight(weight);
self
}
@ -93,7 +93,7 @@ impl Image {
self
}
pub fn alter_weight(&mut self, weight: i8) -> &mut Self {
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
self.weight = weight;
self
}

View file

@ -17,7 +17,7 @@ pub enum MenuItemType {
pub struct MenuItem {
renderable: fn() -> bool,
weight : i8,
weight : isize,
item_type : MenuItemType,
}
@ -34,7 +34,7 @@ impl ComponentTrait for MenuItem {
(self.renderable)()
}
fn weight(&self) -> i8 {
fn weight(&self) -> isize {
self.weight
}
@ -143,7 +143,7 @@ impl MenuItem {
self
}
pub fn with_weight(mut self, weight: i8) -> Self {
pub fn with_weight(mut self, weight: isize) -> Self {
self.alter_weight(weight);
self
}
@ -155,7 +155,7 @@ impl MenuItem {
self
}
pub fn alter_weight(&mut self, weight: i8) -> &mut Self {
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
self.weight = weight;
self
}
@ -171,7 +171,7 @@ impl MenuItem {
pub struct Menu {
renderable: fn() -> bool,
weight : i8,
weight : isize,
items : PageContainer,
id : OptIden,
classes : Classes,
@ -194,7 +194,7 @@ impl ComponentTrait for Menu {
(self.renderable)()
}
fn weight(&self) -> i8 {
fn weight(&self) -> isize {
self.weight
}
@ -254,7 +254,7 @@ impl Menu {
self
}
pub fn with_weight(mut self, weight: i8) -> Self {
pub fn with_weight(mut self, weight: isize) -> Self {
self.alter_weight(weight);
self
}
@ -281,7 +281,7 @@ impl Menu {
self
}
pub fn alter_weight(&mut self, weight: i8) -> &mut Self {
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
self.weight = weight;
self
}

View file

@ -10,7 +10,7 @@ pub enum TypeAction {
pub struct PageAction {
action: TypeAction,
weight: i8,
weight: isize,
}
impl ActionTrait for PageAction {
@ -21,7 +21,7 @@ impl ActionTrait for PageAction {
}
}
fn weight(&self) -> i8 {
fn weight(&self) -> isize {
self.weight
}
@ -38,7 +38,7 @@ impl PageAction {
}
}
pub fn new_with_weight(action: TypeAction, weight: i8) -> Self {
pub fn new_with_weight(action: TypeAction, weight: isize) -> Self {
PageAction {
action,
weight,

View file

@ -47,12 +47,11 @@ macro_rules! theme_static_files {
}};
}
pub(crate) fn partial_type_name(type_name: &'static str, last: u8) -> &'static str {
pub(crate) fn partial_type_name(type_name: &'static str, last: usize) -> &'static str {
if last == 0 {
return type_name;
}
let positions: Vec<_> = type_name.rmatch_indices("::").collect();
let last: usize = last as usize;
if positions.len() < last {
return type_name;
}