Skip to content

Commit

Permalink
Allow inlining generated methods
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Oct 10, 2023
1 parent fef6e60 commit 4d972b9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
7 changes: 7 additions & 0 deletions macros/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
0.3.1 (2023-10-10)
==================

## Changed

* Allow inlining generated methods

0.3.0 (2023-10-10)
==================

Expand Down
2 changes: 1 addition & 1 deletion macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "embedded-layout-macros"
version = "0.3.0"
version = "0.3.1"
license = "MIT"
description = "Procedural macros for embedded-layout"
repository = "https://github.com/bugadani/embedded-layout"
Expand Down
9 changes: 9 additions & 0 deletions macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,41 +442,49 @@ pub fn derive_viewgroup(input: TokenStream) -> TokenStream {

let gen_view_group = quote! {
impl #impl_generics embedded_layout::view_group::ViewGroup for #name #ty_generics #where_clause {
#[inline]
fn len(&self) -> usize {
#field_count_impl
}

#[inline]
fn at(&self, index: usize) -> &dyn embedded_layout::View {
#index_impl
}

#[inline]
fn at_mut(&mut self, index: usize) -> &mut dyn embedded_layout::View {
#index_mut_impl
}

#[inline]
fn bounds_of(&self, index: usize) -> embedded_graphics::primitives::Rectangle {
use embedded_layout::View;
#bounds_of_impl
}

#[inline]
fn translate_child(&mut self, index: usize, by: Point) {
use embedded_layout::View;
#translate_child_impl
}
}

impl #impl_generics embedded_graphics::transform::Transform for #name #ty_generics #where_clause {
#[inline]
fn translate(&self, by: Point) -> Self {
#translate_impl
}

#[inline]
fn translate_mut(&mut self, by: Point) -> &mut Self {
embedded_layout::view_group::ViewGroupHelper::translate(self, by);
self
}
}

impl #impl_generics embedded_graphics::geometry::Dimensions for #name #ty_generics #where_clause {
#[inline]
fn bounding_box(&self) -> embedded_graphics::primitives::Rectangle {
embedded_layout::view_group::ViewGroupHelper::bounds(self)
}
Expand All @@ -501,6 +509,7 @@ pub fn derive_viewgroup(input: TokenStream) -> TokenStream {
type Color = #pixelcolor;
type Output = ();

#[inline]
fn draw<D: embedded_graphics::draw_target::DrawTarget<Color = #pixelcolor>>(&self, display: &mut D) -> Result<(), D::Error> {
#draw_impl

Expand Down

0 comments on commit 4d972b9

Please sign in to comment.