Skip to content

Rename bit read/write methods. #109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 6, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/generate.rs
Original file line number Diff line number Diff line change
@@ -889,13 +889,13 @@ pub fn fields(
enum_items.push(quote! {
/// Returns `true` if the bit is clear (0)
#[inline(always)]
pub fn is_clear(&self) -> bool {
pub fn is_bit_clear(&self) -> bool {
!self.#bits()
}

/// Returns `true` if the bit is set (1)
#[inline(always)]
pub fn is_set(&self) -> bool {
pub fn is_bit_set(&self) -> bool {
self.#bits()
}
});
@@ -1014,13 +1014,13 @@ pub fn fields(
pc_r_impl_items.push(quote! {
/// Returns `true` if the bit is clear (0)
#[inline(always)]
pub fn is_clear(&self) -> bool {
pub fn is_bit_clear(&self) -> bool {
!self.#bits()
}

/// Returns `true` if the bit is set (1)
#[inline(always)]
pub fn is_set(&self) -> bool {
pub fn is_bit_set(&self) -> bool {
self.#bits()
}
});
@@ -1246,16 +1246,18 @@ pub fn fields(
);
}
}
} else if width == 1 {
}

if width == 1 {
proxy_items.push(
quote! {
/// Sets the field bit
pub fn set(self) -> &'a mut W {
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}

/// Clears the field bit
pub fn clear(self) -> &'a mut W {
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
}
6 changes: 6 additions & 0 deletions src/util.rs
Original file line number Diff line number Diff line change
@@ -96,6 +96,12 @@ impl ToSanitizedSnakeCase for str {
where,
while,
yield,
bit_set,
bit_clear,
set_bit,
clear_bit,
bit,
bits,
}
}
}