Create a macros module

This commit is contained in:
David Tolnay 2022-07-20 18:58:59 -07:00
parent 758da1eb9e
commit 7b30e560c9
No known key found for this signature in database
GPG key ID: F9BA143B95FF6D82
3 changed files with 26 additions and 24 deletions

View file

@ -21,30 +21,6 @@ use crate::{
};
use core::ptr::{self, addr_of_mut};
macro_rules! MOVE {
($string:expr) => {
$string.pointer = $string.pointer.wrapping_offset(
(if *$string.pointer.wrapping_offset(0_isize) as libc::c_int & 0x80_i32 == 0_i32 {
1_i32
} else if *$string.pointer.wrapping_offset(0_isize) as libc::c_int & 0xe0_i32
== 0xc0_i32
{
2_i32
} else if *$string.pointer.wrapping_offset(0_isize) as libc::c_int & 0xf0_i32
== 0xe0_i32
{
3_i32
} else if *$string.pointer.wrapping_offset(0_isize) as libc::c_int & 0xf8_i32
== 0xf0_i32
{
4_i32
} else {
0_i32
}) as isize,
)
};
}
unsafe fn yaml_emitter_set_emitter_error(
mut emitter: *mut yaml_emitter_t,
problem: *const libc::c_char,

View file

@ -244,6 +244,9 @@ impl<T> PointerExt for *mut T {
}
}
#[macro_use]
mod macros;
mod api;
mod dumper;
mod emitter;

23
src/macros.rs Normal file
View file

@ -0,0 +1,23 @@
macro_rules! MOVE {
($string:expr) => {
$string.pointer = $string.pointer.wrapping_offset(
(if *$string.pointer.wrapping_offset(0_isize) as libc::c_int & 0x80_i32 == 0_i32 {
1_i32
} else if *$string.pointer.wrapping_offset(0_isize) as libc::c_int & 0xe0_i32
== 0xc0_i32
{
2_i32
} else if *$string.pointer.wrapping_offset(0_isize) as libc::c_int & 0xf0_i32
== 0xe0_i32
{
3_i32
} else if *$string.pointer.wrapping_offset(0_isize) as libc::c_int & 0xf8_i32
== 0xf0_i32
{
4_i32
} else {
0_i32
}) as isize,
)
};
}