mirror of
https://gitlab.cern.ch/wotsubo/endcap-sl-software-ri-generator.git
synced 2025-06-30 00:30:09 +09:00
finish: impl CodeGen for Register
This commit is contained in:
parent
48215049e8
commit
1ed3843508
2 changed files with 41 additions and 27 deletions
36
src/generator/codegen_registerspec_impl.rs
Normal file
36
src/generator/codegen_registerspec_impl.rs
Normal file
|
@ -0,0 +1,36 @@
|
|||
use proc_macro2::{Ident, TokenStream};
|
||||
use quote::quote;
|
||||
|
||||
use crate::types::RwSpecifier;
|
||||
|
||||
pub(super) fn gen_registerspec_impl(
|
||||
reg_name: Ident,
|
||||
modf: RwSpecifier,
|
||||
type_t: Ident,
|
||||
type_ux: Ident,
|
||||
) -> TokenStream {
|
||||
let impl_rw = match modf {
|
||||
RwSpecifier::R => quote! {
|
||||
impl Readable for #reg_name<'_> {}
|
||||
},
|
||||
RwSpecifier::W => quote! {
|
||||
impl Writable for #reg_name<'_> {}
|
||||
},
|
||||
RwSpecifier::RW => quote! {
|
||||
impl Readable for #reg_name<'_> {}
|
||||
impl Writable for #reg_name<'_> {}
|
||||
impl Modifiable for #reg_name<'_> {}
|
||||
},
|
||||
};
|
||||
quote! {
|
||||
impl RegisterSpec for #reg_name<'_> {
|
||||
type Ux = #type_ux;
|
||||
type T = #type_t;
|
||||
|
||||
fn as_ptr(&self) -> *mut Self::Ux {
|
||||
self.mem_ptr
|
||||
}
|
||||
}
|
||||
#impl_rw
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue