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

[DO NOT MERGE] Lib changes needed #3

Closed
wants to merge 1 commit into from
Closed

[DO NOT MERGE] Lib changes needed #3

wants to merge 1 commit into from

Conversation

quinnj
Copy link
Member

@quinnj quinnj commented May 24, 2024

@Octogonapus, do you happen to know what we need to tweak in the generated bindings to get these examples to work? To spell out the problem as clearly as possible:

  • I'm creating a struct like resolver_options = aws_host_resolver_default_options(8, el_group, C_NULL, C_NULL)
  • Then trying to call host_resolver = aws_host_resolver_new_default(allocator, resolver_options)

But getting an unsafe_convert error because an instance of aws_host_resolver_default_options can't be convert to Ptr{aws_host_resolver_default_options}. The correct ccall pattern here is to specify the struct pointer type as Ref{aws_host_resolver_default_options} and this fixes my usage.

If you happen to know what we need to tweak in the bindings generation, I can make the changes, just wanted to check since you know the generation process much better than I do.

@Octogonapus
Copy link
Member

Your code should be changed to pass resolver_options as a Ref. Complete example:

resolver_options = Ref(aws_host_resolver_default_options(8, el_group, C_NULL, C_NULL))
host_resolver = aws_host_resolver_new_default(allocator, resolver_options)

You'll likely want to do this anyway so that you can properly GC preserve these values as aws_host_resolver_default_options is not mutable.

@quinnj
Copy link
Member Author

quinnj commented May 24, 2024

Aha! Thanks! Makes sense. I'm trying to switch over code where a lot of the structs were just treated as opaque Ptr{Cvoid}.

@quinnj quinnj closed this May 24, 2024
@Octogonapus Octogonapus deleted the jq-need-changes branch May 24, 2024 14:31
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