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 
> 
> https://github.com/joa-quim/GMT.jl/blob/master/src/libgmt_h.jl#L1236
> 
> (note, the thing is working in its bulk but I'm having issues with
> those strings as I mentioned before)
> 
> 
> > There's not much more to it than using tuples, which should be well
> > documented.
> > 
> 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 documented but I guess it's not the same thing.
The codes could be improved, but basically NTuple is a standard tuple
with all elements being of the same type:
julia> NTuple{3,UInt8}
Tuple{UInt8,UInt8,UInt8}

julia> isa((1,2), NTuple{2,Int})
true


Regards

> > We wrapped Vulkan with this Clang version: https://github.com/Julia
> > GPU/VulkanCore.jl/blob/master/gen/api/vk_common_1.0.0.jl#L1367
> > 
> Thanks. I will look.
> 
> Joaquim
>  
> > 
> > Best,
> > Simon
> > 
> > > Hi,
> > > 
> > > I have one of those types generated from a C struct with Clang.jl
> > > that turns a stack variable into a loooong list of members (for
> > > example (but I have longer ones))
> > > 
> > > https://github.com/joa-quim/GMT.jl/blob/master/src/libgmt_h.jl#L1
> > > 246
> > > 
> > > (an in interlude: isn't yet any better way of representing a C
> > > "char str[256];"?)
> > > 
> > > when executed I get (example)
> > > 
> > > julia> hdr.x_units
> > > GMT.Array_80_Uint8(0x6c,0x6f,0x6e,0x67,0x69,0x74,0x75,0x64,0x65,0
> > > x20,0x5b,0x64,0x65,0x67,0x72,0x65,0x65,0x73,0x5f,0x65,0x61,0x73,0
> > > x74,0x5d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0
> > > x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0
> > > x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0
> > > x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0
> > > x00,0x00,0x00,0x00,0x00,0x00)
> > > 
> > > but I need to transform it into a string. After some suffering I
> > > came out with this solution
> > > 
> > > julia> join([Char(hdr.x_units.(n)) for n=1:sizeof(hdr.x_units)])
> > > "longitude
> > > [degrees_east]\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
> > > 0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
> > > 
> > > well, it works but it's kind or ugly. Is there a better way of
> > > achieving this? Namely, how could I avoid creating a string with
> > > all of those \0's? I know I can remove them after, but what about
> > > not copying them on first place?
> > > 
> > > Thanks
> > > 
> > > 

Reply via email to