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

Initial Dart backend #355

Merged
merged 11 commits into from
Nov 2, 2023
Merged

Initial Dart backend #355

merged 11 commits into from
Nov 2, 2023

Conversation

robertbastian
Copy link
Collaborator

@robertbastian robertbastian commented Nov 2, 2023

Part of #439

tool/src/dart/init.dart Show resolved Hide resolved
{%- endif %}
{{ m.declaration -}} { {##}
{%- for slice_conversion in m.slice_conversions %}
{%- if loop.first %}
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: I know it would get ugly to indent the actual code this way, but can we indent the jinja bits?

ffi_cast_type_name: Cow<'a, str>,
dart_type_name: Cow<'a, str>,
get_expression: Cow<'a, str>,
set_cleanups: Vec<String>,
Copy link
Contributor

Choose a reason for hiding this comment

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

thought: hm, i'm not sure if we should lazy-convert these structs as opposed to eagerly converting them into pure dart structs. especially for things like string conversions. thoughts?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm, it's a tradeoff because for argument structs, this is the lazy conversion

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

wait no, other way around, for return structs this is the lazy conversion

tool/src/dart/class.rs Show resolved Hide resolved
} else {
format!("static {return_ty} {method_name}({params})")
}
// } else if method.params.is_empty() && return_ty != "void" && method_name != "toString" {
Copy link
Contributor

Choose a reason for hiding this comment

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

question: what's this about? to be deleted, or to be readded later?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

to be readded. I need a better way to figure out if a method is actually a pure getter

let method_name = self.cx.formatter.fmt_method_name(method);
let declaration = if method.param_self.is_none() {
if return_ty == type_name {
format!("factory {type_name}.{method_name}({params})")
Copy link
Contributor

Choose a reason for hiding this comment

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

thought: this is the kind of logic Shane likes to have in the template but I'm not so sure

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a single line and too complex to handle in the template

@robertbastian robertbastian merged commit 72bbae4 into main Nov 2, 2023
5 checks passed
@Manishearth Manishearth deleted the dart branch November 2, 2023 20:32
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.

2 participants