Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICU4X CI Fixes #633

Merged
merged 5 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions core/src/hir/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub struct Method {

pub trait CallbackInstantiationFunctionality {
#[allow(clippy::result_unit_err)]
fn get_input_types(&self) -> Result<impl Iterator<Item = &Type<OutputOnly>>, ()>; // the types of the parameters
fn get_inputs(&self) -> Result<&[CallbackParam], ()>; // the types of the parameters
#[allow(clippy::result_unit_err)]
fn get_output_type(&self) -> Result<&Option<Type>, ()>;
}
Expand All @@ -60,17 +60,17 @@ pub struct Callback {
pub enum NoCallback {}

impl CallbackInstantiationFunctionality for Callback {
fn get_input_types(&self) -> Result<impl Iterator<Item = &Type<OutputOnly>>, ()> {
Ok(self.params.iter().map(|p| &p.ty))
fn get_inputs(&self) -> Result<&[CallbackParam], ()> {
Ok(&self.params)
}
fn get_output_type(&self) -> Result<&Option<Type>, ()> {
Ok(&self.output)
}
}

impl CallbackInstantiationFunctionality for NoCallback {
fn get_input_types(&self) -> Result<impl Iterator<Item = &Type<OutputOnly>>, ()> {
Err::<std::array::IntoIter<&Type<OutputOnly>, 0>, ()>(())
fn get_inputs(&self) -> Result<&[CallbackParam], ()> {
Err(())
}
fn get_output_type(&self) -> Result<&Option<Type>, ()> {
Err(())
Expand Down
26 changes: 11 additions & 15 deletions tool/src/c/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use crate::ErrorStore;
use askama::Template;
use diplomat_core::hir::TypeContext;
use diplomat_core::hir::{
self, CallbackInstantiationFunctionality, OpaqueOwner, OutputOnly, ReturnableStructDef,
StructPathLike, TyPosition, Type, TypeDef, TypeId,
self, CallbackInstantiationFunctionality, OpaqueOwner, ReturnableStructDef, StructPathLike,
TyPosition, Type, TypeDef, TypeId,
};
use std::borrow::Cow;
use std::fmt::Write;
Expand Down Expand Up @@ -334,12 +334,12 @@ impl<'cx, 'tcx> TyGenContext<'cx, 'tcx> {
+ method_abi_name.unwrap().as_str()
+ "_"
+ ident;
let input_types = some_cb.get_input_types().unwrap().collect();
let params = some_cb.get_inputs().unwrap();
let output_type = Box::new(some_cb.get_output_type().unwrap().clone());
// this call generates any imports needed for param + output type(s)
cb_structs_and_defs.push(self.gen_cb_param_wrapper_struct(
&cb_wrapper_type,
input_types,
params,
&output_type,
header,
));
Expand All @@ -358,7 +358,7 @@ impl<'cx, 'tcx> TyGenContext<'cx, 'tcx> {
fn gen_cb_param_wrapper_struct(
&self,
cb_wrapper_type: &str,
input_types: Vec<&Type<OutputOnly>>,
params: &[hir::CallbackParam],
output_type: &Option<Type>,
header: &mut Header,
) -> CallbackAndStructDef {
Expand All @@ -368,16 +368,12 @@ impl<'cx, 'tcx> TyGenContext<'cx, 'tcx> {
} else {
"void".into()
};
let mut params_types = Vec::<String>::new();
for in_ty in input_types.iter() {
let cur_type = self.gen_ty_name(in_ty, header);
params_types.push(cur_type.to_string().clone());
}
let params_types = if params_types.is_empty() {
"".into()
} else {
params_types.join(", ")
};
let params_types = params
.iter()
.map(|p| self.gen_ty_name(&p.ty, header).to_string())
.collect::<Vec<String>>()
.join(", ");

CallbackAndStructDef {
name: cb_wrapper_type.into(),
params_types,
Expand Down
2 changes: 1 addition & 1 deletion tool/src/demo_gen/terminus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct MethodDependency {
params: Vec<ParamInfo>,
}

pub struct RenderTerminusContext<'ctx, 'tcx> {
pub(super) struct RenderTerminusContext<'ctx, 'tcx> {
pub tcx: &'tcx TypeContext,
pub formatter: &'ctx JSFormatter<'tcx>,
pub errors: &'ctx ErrorStore<'tcx, String>,
Expand Down
Loading