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

Allow strings in DefaultContext's api_buffer #232

Merged
merged 1 commit into from
Aug 8, 2019

Conversation

visr
Copy link
Contributor

@visr visr commented Aug 8, 2019

In the common case, dump_to_buffer creates a Vector{Any} buffer:

buffer = []

Which is then used to mix Expr and String, using the latter for comments in print_buffer:
state = (isa(e, AbstractString) ? :string :

Unfortunately I cannot use this in api_buffer since it is set to Vector{Expr} only. With this tweak, I can let my rewriter function insert docstrings that will look the way I want. I know I can put docstr + function together in an expression, but that prints ugly with the at-doc macro.

If you prefer I can also just make it Vector{Union{Expr, String}}

In the `common` case, `dump_to_buffer` creates a `Vector{Any}` buffer: https://github.com/JuliaInterop/Clang.jl/blob/c2c0ea3a6068fe2de40957d31a189691e7cfb4bf/src/expr_unit.jl#L66
Which is then used to mix `Expr` and `String`, using the latter for comments in `print_buffer`: https://github.com/JuliaInterop/Clang.jl/blob/c2c0ea3a6068fe2de40957d31a189691e7cfb4bf/src/expr_unit.jl#L27

Unfortunately I cannot use this in `api_buffer` since it is set to `Vector{Expr}` only. With this tweak, I can let my rewriter function insert docstrings that will look the way I want. I know I can put docstr + function together in an expression, but that prints ugly with the at-doc macro.

If you prefer I can also just make it `Vector{Union{Expr, String}}`
@Gnimuc
Copy link
Member

Gnimuc commented Aug 8, 2019

Thanks. I think Vector{Any} is better since there is no reason to constrain its type.

@Gnimuc Gnimuc merged commit d597d6b into JuliaInterop:master Aug 8, 2019
@visr visr deleted the expr branch August 9, 2019 06:02
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