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

Split up TypeRefExt::cs_type_string #3893

Merged

Conversation

InsertCreativityHere
Copy link
Member

This PR is a first step towards refactoring our cs_type_string functions:

Currently, TypeRefExt::cs_type_string takes a TypeContext, and has 3 different behaviors depending the type-context.
This PR splits this function into 3: field_type_string, incoming_parameter_type_string, and outgoing_parameter_type_string.
The behavior is identical to before, I've just split each context's match case into a standalone function.

Note that ParameterExt has it's own function also named cs_type_string.
I will deal with this in my next PR, but wanted to split it up to keep these easy to review.
ParameterExt::cs_type_string took a bool: ignore_optional, but this was always false, so I removed the parameter and hard-coded false. Otherwise this function was left alone.

@externl
Copy link
Member

externl commented Jan 30, 2024

Looks good, but it fails, so there's a bug somewhere

@InsertCreativityHere
Copy link
Member Author

I forgot an exclamation point...

@@ -75,7 +73,7 @@ pub fn default_activator(encoding: Encoding) -> &'static str {
fn decode_member(member: &impl Member, namespace: &str, encoding: Encoding) -> CodeBlock {
let mut code = CodeBlock::default();
let data_type = member.data_type();
let type_string = data_type.cs_type_string(namespace, TypeContext::IncomingParam, true);
let type_string = data_type.incoming_parameter_type_string(namespace, true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we rename this function "decode_parameter"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this function is used for both fields and parameters.
But the fact we were passing IncomingParam is actually bogus.
We only use the type_string variable for structs and classes... which don't have a special mapping as parameters.

@InsertCreativityHere InsertCreativityHere merged commit 725eb3f into icerpc:main Jan 30, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants