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

Commit 8c81ced6 authored by Zach Johnson's avatar Zach Johnson
Browse files

rusty-gd: Allow paths and not just idents in submodules for GDDI

cleans up some boilerplate a bit

Bug: 171749953
Tag: #gd-refactor
Test: gd/cert/run --rhost
Change-Id: Ia521f76e19beb61da621ec80e85c2d4b54523148
parent 2f00f52a
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ use proc_macro::TokenStream;
use quote::{format_ident, quote};
use syn::parse::{Parse, ParseStream, Result};
use syn::punctuated::Punctuated;
use syn::{braced, parse, parse_macro_input, FnArg, Ident, ItemFn, Token, Type, DeriveInput};
use syn::{braced, parse, parse_macro_input, FnArg, Ident, ItemFn, Token, Type, DeriveInput, Path};

/// Defines a provider function, with generated helper that implicitly fetches argument instances from the registry
#[proc_macro_attribute]
@@ -46,12 +46,12 @@ pub fn provides(_attr: TokenStream, item: TokenStream) -> TokenStream {
struct ModuleDef {
    name: Ident,
    providers: Punctuated<ProviderDef, Token![,]>,
    submodules: Punctuated<Ident, Token![,]>,
    submodules: Punctuated<Path, Token![,]>,
}

enum ModuleEntry {
    Providers(Punctuated<ProviderDef, Token![,]>),
    Submodules(Punctuated<Ident, Token![,]>),
    Submodules(Punctuated<Path, Token![,]>),
}

struct ProviderDef {
@@ -116,7 +116,7 @@ impl Parse for ModuleEntry {
                let entries;
                braced!(entries in input);
                Ok(ModuleEntry::Submodules(
                    entries.parse_terminated(Ident::parse)?,
                    entries.parse_terminated(Path::parse)?,
                ))
            }
            keyword => {
+4 −9
Original line number Diff line number Diff line
@@ -7,16 +7,11 @@ extern crate lazy_static;

pub mod facade;
pub mod rootcanal_hal;
#[cfg(not(target_os = "android"))]
use rootcanal_hal::rootcanal_hal_module;

#[cfg(target_os = "android")]
mod hidl_hal;
#[cfg(target_os = "android")]
use hidl_hal::hidl_hal_module;

use bt_packet::{HciCommand, HciEvent, RawPacket};
use facade::hal_facade_module;
use gddi::{module, Stoppable};
use std::sync::Arc;
use thiserror::Error;
@@ -26,8 +21,8 @@ use tokio::sync::{mpsc, Mutex};
module! {
    hal_module,
    submodules {
        hal_facade_module,
        hidl_hal_module
        facade::hal_facade_module,
        hidl_hal::hidl_hal_module
    },
}

@@ -35,8 +30,8 @@ module! {
module! {
    hal_module,
    submodules {
        hal_facade_module,
        rootcanal_hal_module
        facade::hal_facade_module,
        rootcanal_hal::rootcanal_hal_module
    },
}
/// H4 packet header size
+1 −2
Original line number Diff line number Diff line
@@ -9,7 +9,6 @@ pub mod facade;
use bt_hal::HalExports;
use bt_packet::{HciCommand, HciEvent, RawPacket};
use error::Result;
use facade::facade_module;
use gddi::{module, provides, Stoppable};
use std::collections::HashMap;
use std::sync::Arc;
@@ -21,7 +20,7 @@ use tokio::sync::{oneshot, Mutex};
module! {
    hci_module,
    submodules {
        facade_module,
        facade::facade_module,
    },
    providers {
        HciExports => provide_hci,
+2 −4
Original line number Diff line number Diff line
//! Main BT lifecycle support

use bt_hal::hal_module;
use bt_hci::hci_module;
use gddi::{module, Registry, RegistryBuilder, Stoppable};
use bt_hal::rootcanal_hal::RootcanalConfig;
use std::sync::Arc;
@@ -11,8 +9,8 @@ use bt_common::GrpcFacade;
module! {
    stack_module,
    submodules {
        hal_module,
        hci_module,
        bt_hal::hal_module,
        bt_hci::hci_module,
    }
}