-
Notifications
You must be signed in to change notification settings - Fork 68
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
ParseError("invalid interpolation syntax: \"\$&\"") #196
Comments
This same error also occurs on Ubuntu 16.04 with julia 0.6.4. Is there something else that anyone could suggest? |
Working with Martijn Visser on Slack, I managed to move slightly forward... In https://github.com/GNOME/glib/blob/master/glib/gurifuncs.h#L44, you can see the following string: By deleting the Is there a way I can tell Clang.jl not to wrap anything from Glib? The warning message seems to suggest that it's skipping a lot of symbols, but it's not skipping all of them. |
Is there a way I can tell Clang.jl not to wrap anything from Glib?
Yes, `init` takes a kwarg `header_wrapped = (path::String) -> Bool` which
you can use to control whether a given header (path) is wrapped.
…On Mon, Jun 18, 2018 at 2:04 PM Randy Zwitch ***@***.***> wrote:
Working with Martijn Visser on Slack, I managed to move slightly forward...
In https://github.com/GNOME/glib/blob/master/glib/gurifuncs.h#L44, you
can see the following string:
#define G_URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS "!$&'()*+,;="
By deleting the $ from gurifuncs.h or putting a \ in front of it,
Clang.jl will move forward (to unfortunately, more errors)
Is there a way I can tell Clang.jl not to wrap anything from Glib? The
warning message seems to suggest that it's skipping a lot of symbols, but
it's not skipping all of them.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#196 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAUAGl9QgvKL-CnJwQHi68n-7h2AKxNbks5t9-upgaJpZM4UmAfi>
.
|
Thanks @ihnorton . So are you saying if I'm getting errors from |
You probably want something more sophisticated -- to exclude all the glib
functions, for example -- but the idea is that you pass a function as
`header_wrapped` which will look at the name of a given header and return
true (wrap) or false (don't wrap) based on some criteria such as file name,
path, or something in the path.
e.g. for just that one include, you could use:
init(; header_wrapped = x -> !endswith("gurifuncs.h"))
or to exclude all glib:
init(... ; header_wrapped = x-> !contains("glib"))
…On Mon, Jun 18, 2018 at 2:10 PM Randy Zwitch ***@***.***> wrote:
Thanks @ihnorton <https://github.com/ihnorton> . So are you saying if I'm
getting errors from /usr/include/glib-2.0/glib/gurifuncs.h, I can add
that to header_wrapped and it will skip that header?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#196 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAUAGvqZTJfla6wRYRP8HvBiifjtMoKDks5t9-0ngaJpZM4UmAfi>
.
|
When I run your suggestions, I get:
|
Ah, sorry, forgot that it takes two arguments. try:
header_wrapped = (x,_) -> !endswith("gurifuncs.h")
…On Mon, Jun 18, 2018 at 2:36 PM Randy Zwitch ***@***.***> wrote:
When I run your suggestions, I get:
julia> using Clang
julia> context = wrap_c.init(; output_file="mapdwrapper.jl",
common_file="mapdwrapper_h.jl",
clang_diagnostics=true,
header_wrapped = x -> !endswith("gurifuncs.h"),
clang_includes = ["/usr/local/include",
"/usr/include/glib-2.0",
"/usr/lib/x86_64-linux-gnu/glib-2.0/include",
"/home/rzwitch/julia/usr/lib/clang/3.9.1/include/"
]
)
Clang.wrap_c.WrapContext(Ptr{Void} @0x0000000002d853c0, String[], "mapdwrapper.jl", "mapdwrapper_h.jl", String["/usr/local/include", "/usr/include/glib-2.0", "/usr/lib/x86_64-linux-gnu/glib-2.0/include", "/home/rzwitch/julia/usr/lib/clang/3.9.1/include/"], String[], #1, Clang.wrap_c.#8, Clang.wrap_c.#10, Clang.wrap_c.#13, DataStructures.OrderedDict{Symbol,Clang.wrap_c.ExprUnit}(), Set{String}(), DataStructures.DefaultOrderedDict{String,Array{Any,N} where N,Clang.wrap_c.##11#22}(), Clang.wrap_c.InternalOptions(true, false), 0, Clang.wrap_c.#14)
julia> context.options.wrap_structs = true
true
julia> begin
context.headers = ["/home/rzwitch/.julia/v0.6/MapD/gen-c_glib/map_d.h",
"/home/rzwitch/.julia/v0.6/MapD/gen-c_glib/mapd_types.h",
"/home/rzwitch/.julia/v0.6/MapD/gen-c_glib/completion_hints_types.h"]
run(context)
end
WRAPPING HEADER: /home/rzwitch/.julia/v0.6/MapD/gen-c_glib/mapd_types.h
ERROR: MethodError: no method matching (::##1#2)(::String, ::String)
Closest candidates are:
#1(::Any) at REPL[2]:4
Stacktrace:
[1] wrap_header(::Clang.wrap_c.WrapContext, ::Clang.cindex.TranslationUnit, ::String, ::Array{Any,1}) at /home/rzwitch/.julia/v0.6/Clang/src/wrap_c.jl:675
[2] run(::Clang.wrap_c.WrapContext) at /home/rzwitch/.julia/v0.6/Clang/src/wrap_c.jl:806
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#196 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAUAGpVXffK85Y2GybjOAAi61AmmE2Boks5t9_MagaJpZM4UmAfi>
.
|
One more time (missing the argument to `endswith`):
header_wrapped = (x,_) -> !endswith(x, "gurifuncs.h")
On Mon, Jun 18, 2018 at 2:43 PM Isaiah Norton <[email protected]>
wrote:
… Ah, sorry, forgot that it takes two arguments. try:
header_wrapped = (x,_) -> !endswith("gurifuncs.h")
On Mon, Jun 18, 2018 at 2:36 PM Randy Zwitch ***@***.***>
wrote:
> When I run your suggestions, I get:
>
> julia> using Clang
>
> julia> context = wrap_c.init(; output_file="mapdwrapper.jl",
> common_file="mapdwrapper_h.jl",
> clang_diagnostics=true,
> header_wrapped = x -> !endswith("gurifuncs.h"),
> clang_includes = ["/usr/local/include",
> "/usr/include/glib-2.0",
> "/usr/lib/x86_64-linux-gnu/glib-2.0/include",
> "/home/rzwitch/julia/usr/lib/clang/3.9.1/include/"
> ]
>
> )
> Clang.wrap_c.WrapContext(Ptr{Void} @0x0000000002d853c0, String[], "mapdwrapper.jl", "mapdwrapper_h.jl", String["/usr/local/include", "/usr/include/glib-2.0", "/usr/lib/x86_64-linux-gnu/glib-2.0/include", "/home/rzwitch/julia/usr/lib/clang/3.9.1/include/"], String[], #1, Clang.wrap_c.#8, Clang.wrap_c.#10, Clang.wrap_c.#13, DataStructures.OrderedDict{Symbol,Clang.wrap_c.ExprUnit}(), Set{String}(), DataStructures.DefaultOrderedDict{String,Array{Any,N} where N,Clang.wrap_c.##11#22}(), Clang.wrap_c.InternalOptions(true, false), 0, Clang.wrap_c.#14)
>
> julia> context.options.wrap_structs = true
> true
>
> julia> begin
> context.headers = ["/home/rzwitch/.julia/v0.6/MapD/gen-c_glib/map_d.h",
> "/home/rzwitch/.julia/v0.6/MapD/gen-c_glib/mapd_types.h",
> "/home/rzwitch/.julia/v0.6/MapD/gen-c_glib/completion_hints_types.h"]
> run(context)
> end
>
> WRAPPING HEADER: /home/rzwitch/.julia/v0.6/MapD/gen-c_glib/mapd_types.h
> ERROR: MethodError: no method matching (::##1#2)(::String, ::String)
> Closest candidates are:
> #1(::Any) at REPL[2]:4
> Stacktrace:
> [1] wrap_header(::Clang.wrap_c.WrapContext, ::Clang.cindex.TranslationUnit, ::String, ::Array{Any,1}) at /home/rzwitch/.julia/v0.6/Clang/src/wrap_c.jl:675
> [2] run(::Clang.wrap_c.WrapContext) at /home/rzwitch/.julia/v0.6/Clang/src/wrap_c.jl:806
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#196 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AAUAGpVXffK85Y2GybjOAAi61AmmE2Boks5t9_MagaJpZM4UmAfi>
> .
>
|
This appears to be the winner, stealing a bit from Chris R: using Clang
context = wrap_c.init(; output_file="mapdwrapper.jl",
common_file="mapdwrapper_h.jl",
clang_diagnostics=true,
header_wrapped = (x,_) -> !contains(x, "gurifuncs.h") && (x == _),
clang_includes = ["/usr/local/include",
"/usr/include/glib-2.0",
"/usr/lib/x86_64-linux-gnu/glib-2.0/include",
"/home/rzwitch/julia/usr/lib/clang/3.9.1/include/"
]
)
context.options.wrap_structs = true
begin
context.headers = ["/home/rzwitch/.julia/v0.6/MapD/gen-c_glib/map_d.h",
"/home/rzwitch/.julia/v0.6/MapD/gen-c_glib/mapd_types.h",
"/home/rzwitch/.julia/v0.6/MapD/gen-c_glib/completion_hints_types.h"]
run(context)
end Which is just to say that Clang.jl went through the entire process without throwing an error. We shall see how well this actually worked. Thanks for the help @ihnorton ! |
Perhaps this (or a new) issue should stay open because there is something going on with escaping interpolated strings in MacroDeclaration values. This was only avoided by not wrapping it. |
Probably the simplest solution is to wrap this line in a |
I'm trying to create a Julia wrapper for auto-generated Thrift bindings. The following code successfully creates a shared library:
When trying to generate Julia bindings, the following occurs (julia 0.6.4)
The text was updated successfully, but these errors were encountered: