-
Notifications
You must be signed in to change notification settings - Fork 14
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
Split up TypeRefExt::cs_type_string
#3893
Conversation
Looks good, but it fails, so there's a bug somewhere |
I forgot an exclamation point... |
tools/slicec-cs/src/decoding.rs
Outdated
@@ -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); |
There was a problem hiding this comment.
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"?
There was a problem hiding this comment.
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.
This PR is a first step towards refactoring our
cs_type_string
functions:Currently,
TypeRefExt::cs_type_string
takes aTypeContext
, and has 3 different behaviors depending the type-context.This PR splits this function into 3:
field_type_string
,incoming_parameter_type_string
, andoutgoing_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 namedcs_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 abool: ignore_optional
, but this was always false, so I removed the parameter and hard-coded false. Otherwise this function was left alone.