Re: [swift-users] raw buffer pointer load alignment

2017-11-09 Thread Johannes Weiß via swift-users
Hi Kelvin, > On 9 Nov 2017, at 12:30 am, Kelvin Ma wrote: > > For context, the problem I’m trying to solve is efficiently parsing JPEG > chunks. This means reading each chunk of the JPEG from a file into a raw > buffer pointer, and then parsing the chunk according to its expected layout. > Fo

Re: [swift-users] raw buffer pointer load alignment

2017-11-08 Thread Johannes Weiß via swift-users
Hi Kelvin, > On 8 Nov 2017, at 5:40 pm, Kelvin Ma wrote: > > yikes there’s no less verbose way to do that? and if the type isn’t an > integer there’s no way to avoid the default initialization? Can this be done > with opaques or something? well, it's 5 lines for the generic case to rule all t

Re: [swift-users] raw buffer pointer load alignment

2017-11-08 Thread Johannes Weiß via swift-users
Hi Kelvin, > On 8 Nov 2017, at 4:54 pm, Kelvin Ma via swift-users > wrote: > > According to the docs, the load(fromByteOffset:as:) method requires the > instance to be “properly aligned” Does that mean if I have raw data meant to > be interpreted as > > 0 1 2 3 4 5

Re: [swift-users] About Swift Package Manager and LLDB

2017-11-06 Thread Johannes Weiß via swift-users
Hi Fadi, Just two questions: - did you compile & run this program on the same machine or not? (the .swiftmodule files and others are needed for LLDB) - did you use your Linux distro's lldb or the one that comes with the Swift toolchain? (you'll need the very LLDB that comes with the Swift compil

Re: [swift-users] Swift-C array interop with Swift 4/Xcode 9

2017-09-21 Thread Johannes Weiß via swift-users
go through the same steps, > going two levels of closure deeper, before he has access to both struct > members? > > This doesn’t seem to scale very well. What about a struct with 5 arrays? > -- > Chris McIntyre > > > > >> On Sep 21, 2017, at 6:05 AM, Joha

Re: [swift-users] Swift-C array interop with Swift 4/Xcode 9

2017-09-21 Thread Johannes Weiß via swift-users
Hi Rick, > On 21 Sep 2017, at 1:03 am, Rick Mann via swift-users > wrote: > > I've got Swift code wrapping a C API. One of the C structs the API uses looks > like this: > > typedef struct { >size_t size; >float transformation[16]; >float projection[16]; >uint32_t width; >u

Re: [swift-users] Can I use a tuple to force a certain memory layout?

2017-07-21 Thread Johannes Weiß via swift-users
> On 21 Jul 2017, at 1:45 am, Taylor Swift wrote: > > Okay, apparently layout is only guaranteed if the reference is to the tuple > itself, not a member of the tuple. Don’t know if this is a bug or intended > behavior. The above code works when written as > > var buffers:(VBO:GL.UIn

Re: [swift-users] Can I use a tuple to force a certain memory layout?

2017-07-21 Thread Johannes Weiß via swift-users
Hi, > On 20 Jul 2017, at 7:54 pm, Taylor Swift wrote: > > This does not seem to be the case… > > var buffers:(VBO:GL.UInt, EBO:GL.UInt) = (0, 0) > glGenBuffers(n: 2, buffers: &buffers.VBO) this is definitely illegal as you're writing 2 GL.UInts and you're giving it a pointer to only o

Re: [swift-users] Can I use a tuple to force a certain memory layout?

2017-07-20 Thread Johannes Weiß via swift-users
Hi, > On 20 Jul 2017, at 5:41 pm, Taylor Swift wrote: > > Does addressof count as legally observing it? > > var buffers:(GL.UInt, GL.UInt) = (0, 0) > glGenBuffers(n: 2, buffers: &buffers.0) > > Also, I assume Swift performs a swizzle if the tuple is defined in a separate > mod

Re: [swift-users] Can I use a tuple to force a certain memory layout?

2017-07-20 Thread Johannes Weiß via swift-users
When you can (legally) observe it, tuples in Swift have guaranteed standard C-style layout. John McCall confirms this here: https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20170424/004481.html > On 20 Jul 2017, at 4:33 am, Taylor Swift via swift-users > wrote: > > Many APIs like Open

Re: [swift-users] Bool type and reading and writing operation atomicity

2017-01-17 Thread Johannes Weiß via swift-users
Hi, > Put simply, are reading and writing to Bools both atomic operations in Swift > (3)? you don't get a guarantee for that as Swift at the moment lacks both, a memory and a concurrency model. > Obviously, something reading and then assigning assuming the value doesn't > change between is n