Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 38c4a8de authored by Jooyung Han's avatar Jooyung Han Committed by Automerger Merge Worker
Browse files

Merge "libbinder_rs: Add support for attributes to declare_binder_enum" am: 7ad74670

Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1869740

Change-Id: Ie506bf4067969ececcad6b588e430fccf286d01d
parents 6ef53252 7ad74670
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -1027,16 +1027,20 @@ macro_rules! declare_binder_interface {
#[macro_export]
macro_rules! declare_binder_enum {
    {
        $( #[$attr:meta] )*
        $enum:ident : [$backing:ty; $size:expr] {
            $( $name:ident = $value:expr, )*
        }
    } => {
        $( #[$attr] )*
        #[derive(Debug, Default, Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Hash)]
        #[allow(missing_docs)]
        pub struct $enum(pub $backing);
        impl $enum {
            $( pub const $name: Self = Self($value); )*
            $( #[allow(missing_docs)] pub const $name: Self = Self($value); )*

            #[inline(always)]
            #[allow(missing_docs)]
            pub const fn enum_values() -> [Self; $size] {
                [$(Self::$name),*]
            }
+18 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

//! Rust Binder crate integration tests

use binder::declare_binder_interface;
use binder::{declare_binder_enum, declare_binder_interface};
use binder::parcel::BorrowedParcel;
use binder::{
    Binder, BinderFeatures, IBinderInternal, Interface, StatusCode, ThreadState, TransactionCode,
@@ -294,6 +294,23 @@ impl ITestSameDescriptor for BpTestSameDescriptor {}

impl ITestSameDescriptor for Binder<BnTestSameDescriptor> {}

declare_binder_enum! {
    TestEnum : [i32; 3] {
        FOO = 1,
        BAR = 2,
        BAZ = 3,
    }
}

declare_binder_enum! {
    #[deprecated(since = "1.0.0")]
    TestDeprecatedEnum : [i32; 3] {
        FOO = 1,
        BAR = 2,
        BAZ = 3,
    }
}

#[cfg(test)]
mod tests {
    use selinux_bindgen as selinux_sys;