Skip to content

Commit

Permalink
Named arguments for encoder macros
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski committed Nov 12, 2024
1 parent f85c995 commit 93d0577
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 30 deletions.
20 changes: 10 additions & 10 deletions src/iso_2022_jp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ impl Iso2022JpEncoder {
}

encoder_functions!(
{
eof = {
match self.state {
Iso2022JpEncoderState::Ascii => {}
_ => match dest.check_space_three() {
Expand All @@ -531,7 +531,7 @@ impl Iso2022JpEncoder {
},
}
},
{
body = {
match self.state {
Iso2022JpEncoderState::Ascii => {
if c == '\u{0E}' || c == '\u{0F}' || c == '\u{1B}' {
Expand Down Expand Up @@ -734,14 +734,14 @@ impl Iso2022JpEncoder {
}
}
},
self,
src_consumed,
source,
dest,
c,
destination_handle,
unread_handle,
check_space_three
self = self,
src_consumed = src_consumed,
source = source,
dest = dest,
c = c,
destination_handle = destination_handle,
unread_handle = unread_handle,
destination_check = check_space_three
);
}

Expand Down
20 changes: 10 additions & 10 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1010,16 +1010,16 @@ macro_rules! encoder_function {

macro_rules! encoder_functions {
(
$eof:block,
$body:block,
$slf:ident,
$src_consumed:ident,
$source:ident,
$dest:ident,
$c:ident,
$destination_handle:ident,
$unread_handle:ident,
$destination_check:ident
eof = $eof:block,
body = $body:block,
self = $slf:ident,
src_consumed = $src_consumed:ident,
source = $source:ident,
dest = $dest:ident,
c = $c:ident,
destination_handle = $destination_handle:ident,
unread_handle = $unread_handle:ident,
destination_check = $destination_check:ident
) => {
encoder_function!(
$eof,
Expand Down
20 changes: 10 additions & 10 deletions src/x_user_defined.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ impl UserDefinedEncoder {
}

encoder_functions!(
{},
{
eof = {},
body = {
if c <= '\u{7F}' {
// TODO optimize ASCII run
destination_handle.write_one(c as u8);
Expand All @@ -188,14 +188,14 @@ impl UserDefinedEncoder {
destination_handle.write_one((u32::from(c) - 0xF700) as u8);
continue;
},
self,
src_consumed,
source,
dest,
c,
destination_handle,
unread_handle,
check_space_one
self = self,
src_consumed = src_consumed,
source = source,
dest = dest,
c = c,
destination_handle = destination_handle,
unread_handle = unread_handle,
destination_check = check_space_one
);
}

Expand Down

0 comments on commit 93d0577

Please sign in to comment.