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

feat: make generated code more idiomatic to zig users #3

Merged
merged 5 commits into from
Sep 9, 2024

Conversation

nilslice
Copy link
Member

@nilslice nilslice commented Sep 5, 2024

Convert any end-user facing identifier to a more Zig-friendly option, using the latest helpers in xtp-bindgen. e.g.:

For this schema portion:

snake_case_func_name:
    description: This is a function that uses snake case in the name
    input:
      type: string
      contentType: text/plain; charset=utf-8
      description: A string passed into plugin input
    output:
      $ref: "#/components/schemas/some_value"
      contentType: application/json
#...
components:
  schemas:
    some_value:
      properties:
        a_string:
          type: string
          description: a string

We now produce:

/// This is a function that uses snake case in the name
/// It takes []const u8 as input (A string passed into plugin input)
/// And returns SomeValue ()
pub fn snakeCaseFuncName(input: []const u8) !schema.SomeValue {
    // TODO: fill out your implementation here
    _ = input;
    return error.PluginFunctionNotImplemented;
}

@nilslice nilslice marked this pull request as draft September 5, 2024 17:40
@nilslice nilslice marked this pull request as ready for review September 9, 2024 17:07
Copy link

@zshipko zshipko left a comment

Choose a reason for hiding this comment

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

LGTM - i like the zig*Name wrappers, makes it much easier to tell what's going on

@nilslice nilslice merged commit e106bf5 into main Sep 9, 2024
1 check passed
@nilslice nilslice deleted the ident-conversions branch September 9, 2024 21:49
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