update(generator): return error when block has multiple

This commit is contained in:
testuser 2025-02-03 19:55:05 +09:00
parent ae01a30cb0
commit 472723016c

View file

@ -15,7 +15,6 @@ use crate::{
types::{Block, Module, ModuleBlockElements, Register},
};
use heck::{ToSnakeCase, ToUpperCamelCase};
use proc_macro2::TokenStream;
use quote::quote;
use thiserror::Error;
@ -27,6 +26,8 @@ pub enum CodeGenError {
FilePathError(String),
#[error("parent is required for {module}")]
ParentMissing { module: &'static str },
#[error("Unsupported structure: {}", name)]
UnsupportedStructure { name: &'static str },
}
mod util {
@ -200,6 +201,12 @@ impl CodeGen for Block {
parent_path: Option<path::PathBuf>,
mut files: HashMap<path::PathBuf, proc_macro2::TokenStream>,
) -> 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_path = parent_path.ok_or(CodeGenError::ParentMissing { module: "Block" })?;