Re: [julia-users] Re: Reconstruct a string from a Clang.jl generated looong type

2016-06-07 Thread J Luis
Just to tell that the NTuples way works beautifully, specially because we no longer are tied to an immutable that made the communication Julia -> C quite painfull. Thanks Joaquim segunda-feira, 6 de Junho de 2016 às 21:09:32 UTC+1, Steven G. Johnson escreveu: > > On Monday, June 6, 2016 at

Re: [julia-users] Re: Reconstruct a string from a Clang.jl generated looong type

2016-06-06 Thread Steven G. Johnson
On Monday, June 6, 2016 at 1:11:53 PM UTC-4, Milan Bouchet-Valat wrote: > > > tuples yes, but when I search for ``NTuples`` in the docs there is > > barely any hit and all that come show it being used as a type > > dfinition but found no mention of what it is. Yes, a ``ntuple`` > > function is

Re: [julia-users] Re: Reconstruct a string from a Clang.jl generated looong type

2016-06-06 Thread J Luis
Ah, simple than. Thanks segunda-feira, 6 de Junho de 2016 às 18:11:53 UTC+1, Milan Bouchet-Valat escreveu: > > Le lundi 06 juin 2016 à 09:56 -0700, J Luis a écrit : > > > > > What exactly are you after? > > > > > What I'm after is simple. To be able to access the members > > ``x_units``

Re: [julia-users] Re: Reconstruct a string from a Clang.jl generated looong type

2016-06-06 Thread Milan Bouchet-Valat
Le lundi 06 juin 2016 à 09:56 -0700, J Luis a écrit : > > > What exactly are you after?  > > >  What I'm after is simple. To be able to access the members > ``x_units`` and so on of > > http://gmt.soest.hawaii.edu/doc/latest/GMT_API.html#gmt-grids > > with the wrapper  > >

[julia-users] Re: Reconstruct a string from a Clang.jl generated looong type

2016-06-06 Thread J Luis
segunda-feira, 6 de Junho de 2016 às 17:19:08 UTC+1, Simon Danisch escreveu: > > What exactly are you after? > What I'm after is simple. To be able to access the members ``x_units`` and so on of http://gmt.soest.hawaii.edu/doc/latest/GMT_API.html#gmt-grids with the wrapper

[julia-users] Re: Reconstruct a string from a Clang.jl generated looong type

2016-06-06 Thread Simon Danisch
What exactly are you after? There's not much more to it than using tuples, which should be well documented. We wrapped Vulkan with this Clang version: https://github.com/JuliaGPU/VulkanCore.jl/blob/master/gen/api/vk_common_1.0.0.jl#L1367 Best, Simon Am Montag, 6. Juni 2016 01:41:34 UTC+2

[julia-users] Re: Reconstruct a string from a Clang.jl generated looong type

2016-06-06 Thread J Luis
Thanks Simon, some progress but I never worked with NTuples. Is there any example wrapper that uses this technique that I can read/study? segunda-feira, 6 de Junho de 2016 às 15:23:17 UTC+1, Simon Danisch escreveu: > > On master, Clang will emit NTuples, which is a bit nicer at least! > >

[julia-users] Re: Reconstruct a string from a Clang.jl generated looong type

2016-06-06 Thread Simon Danisch
On master, Clang will emit NTuples, which is a bit nicer at least! bytestring(UInt8[a...]) a = map(UInt8, ("abcd"...,)) Am Montag, 6. Juni 2016 01:41:34 UTC+2 schrieb J Luis: > > Hi, > > I have one of those types generated from a C struct with Clang.jl that > turns a stack variable into a

[julia-users] Re: Reconstruct a string from a Clang.jl generated looong type

2016-06-06 Thread Kristoffer Carlsson
Why wouldn't wrapping a simple NTuple work?

[julia-users] Re: Reconstruct a string from a Clang.jl generated looong type

2016-06-06 Thread J Luis
The problem is that the text is inside one of those immutables generated by Clang (see: https://github.com/joa-quim/GMT.jl/blob/master/src/libgmt_h.jl#L371) so no simple bytestring(data) works because it complains that no method exists to convert from GMT.Array_80_Uint8 type And worst,

[julia-users] Re: Reconstruct a string from a Clang.jl generated looong type

2016-06-06 Thread Steven G. Johnson
For nul-terminated ASCII or UTF-8 data, which is what it looks like you have here, use bytestring(data), where data is either a Cstring, a Ptr{UInt8}, or a Vector{UInt8}. If you know the length of the string (in bytes), do bytestring(data, len). (This allows embedded nul characters.) In

[julia-users] Re: Reconstruct a string from a Clang.jl generated looong type

2016-06-06 Thread Steven G. Johnson
Slight correction: if you pass bytestring(data) a Vector{UInt8}, it assumes the length of the data is the length of the string (in bytes), and does not assume nul-terminated data.

[julia-users] Re: Reconstruct a string from a Clang.jl generated looong type

2016-06-06 Thread J Luis
Thanks but the string encoding is not an issue. This julia code is a wrapper to a library that I know it uses only ASCII in the variables being accessed. segunda-feira, 6 de Junho de 2016 às 10:57:29 UTC+1, Páll Haraldsson escreveu: > > On Sunday, June 5, 2016 at 11:41:34 PM UTC, J Luis wrote:

[julia-users] Re: Reconstruct a string from a Clang.jl generated looong type

2016-06-06 Thread Páll Haraldsson
On Sunday, June 5, 2016 at 11:41:34 PM UTC, J Luis wrote: > > Hi, > > I have one of those types generated from a C struct with Clang.jl that > turns a stack variable into a lng list of members (for example (but I > have longer ones)) > >