mirror of
https://gitlab.cern.ch/wotsubo/endcap-sl-software-ri-generator.git
synced 2025-02-23 17:17:08 +09:00
update(generator): return error when block has multiple
This commit is contained in:
parent
ae01a30cb0
commit
472723016c
1 changed files with 8 additions and 1 deletions
|
@ -15,7 +15,6 @@ use crate::{
|
||||||
types::{Block, Module, ModuleBlockElements, Register},
|
types::{Block, Module, ModuleBlockElements, Register},
|
||||||
};
|
};
|
||||||
use heck::{ToSnakeCase, ToUpperCamelCase};
|
use heck::{ToSnakeCase, ToUpperCamelCase};
|
||||||
use proc_macro2::TokenStream;
|
|
||||||
use quote::quote;
|
use quote::quote;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
|
@ -27,6 +26,8 @@ pub enum CodeGenError {
|
||||||
FilePathError(String),
|
FilePathError(String),
|
||||||
#[error("parent is required for {module}")]
|
#[error("parent is required for {module}")]
|
||||||
ParentMissing { module: &'static str },
|
ParentMissing { module: &'static str },
|
||||||
|
#[error("Unsupported structure: {}", name)]
|
||||||
|
UnsupportedStructure { name: &'static str },
|
||||||
}
|
}
|
||||||
|
|
||||||
mod util {
|
mod util {
|
||||||
|
@ -200,6 +201,12 @@ impl CodeGen for Block {
|
||||||
parent_path: Option<path::PathBuf>,
|
parent_path: Option<path::PathBuf>,
|
||||||
mut files: HashMap<path::PathBuf, proc_macro2::TokenStream>,
|
mut files: HashMap<path::PathBuf, proc_macro2::TokenStream>,
|
||||||
) -> Result<HashMap<path::PathBuf, proc_macro2::TokenStream>, CodeGenError> {
|
) -> Result<HashMap<path::PathBuf, proc_macro2::TokenStream>, CodeGenError> {
|
||||||
|
if self.multiple.is_some() {
|
||||||
|
// Plan: expand automatically, or same as register?
|
||||||
|
return Err(CodeGenError::UnsupportedStructure {
|
||||||
|
name: "multiple in block",
|
||||||
|
});
|
||||||
|
}
|
||||||
let parent_name = parent_name.ok_or(CodeGenError::ParentMissing { module: "Block" })?;
|
let parent_name = parent_name.ok_or(CodeGenError::ParentMissing { module: "Block" })?;
|
||||||
let parent_path = parent_path.ok_or(CodeGenError::ParentMissing { module: "Block" })?;
|
let parent_path = parent_path.ok_or(CodeGenError::ParentMissing { module: "Block" })?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue