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

Add request box descriptions #342

Merged
merged 2 commits into from
Jul 24, 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
2 changes: 2 additions & 0 deletions stone/backends/swift_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
fmt_func,
fmt_var,
fmt_type,
fmt_route_name,
fmt_objc_type,
mapped_list_info,
datatype_has_subtypes,
Expand Down Expand Up @@ -282,6 +283,7 @@ def _generate_reconnection_helpers(self, api):
return_type = '{}RequestBox'.format(self.args.class_name)

template = self._jinja_template("SwiftReconnectionHelpers.jinja")
template.globals['fmt_route_name'] = fmt_route_name
template.globals['fmt_func'] = fmt_func
template.globals['fmt_class'] = fmt_class
template.globals['class_name'] = class_name
Expand Down
2 changes: 1 addition & 1 deletion stone/backends/swift_rsrc/SwiftReconnectionHelpers.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ enum {{ class_name }}: ReconnectionHelpersShared {

switch info.routeName {
{% for namespace, route in background_compatible_namespace_route_pairs %}
case "{{ fmt_func(route.name, route.version) }}":
case "{{ fmt_route_name(route) }}":
return .{{ fmt_func(route.name, route.version) }}(
rebuildRequest(
apiRequest: apiRequest,
Expand Down
12 changes: 10 additions & 2 deletions stone/backends/swift_rsrc/SwiftRequestBox.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,17 @@
import Foundation

/// Allows for heterogenous collections of typed requests
public enum {{ class_name }} {
public enum {{ class_name }}: CustomStringConvertible {
{% for route in background_compatible_routes %}
case {{ fmt_func(route.name, route.version) }}({{ request_type_signature(route) }})
{% endfor %}
}

public var description: String {
switch self {
{% for route in background_compatible_routes %}
case .{{ fmt_func(route.name, route.version) }}(_):
return "{{ fmt_func(route.name, route.version) }}"
{% endfor %}
}
}
}
Loading