[swift-users] Rebind tuple to its destructured base type

2018-01-12 Thread Kelvin Ma via swift-users
I have an array of matrices where the matrix type is defined as typealias Vec4 = (Float, Float, Float, Float) typealias Mat4 = (Vec4, Vec4, Vec4, Vec4) let matrices:[Mat4] I need to send them to an OpenGL API that accepts a buffer of Floats. How do I do this? withMemoryRebound(to:_:) requires

Re: [swift-users] appending packed bytes to [UInt8]

2018-01-10 Thread Kelvin Ma via swift-users
Swift-structs is not guaranteed to >> remain like this and is thus not future-proof, although I think that >> if/when things changes, there will be some way to tell the compiler that >> you want the memory to be this "expected" "C-like" layout. >> >&

Re: [swift-users] appending packed bytes to [UInt8]

2018-01-10 Thread Kelvin Ma via swift-users
ever that the memory layout of Swift-structs is not guaranteed to > remain like this and is thus not future-proof, although I think that > if/when things changes, there will be some way to tell the compiler that > you want the memory to be this "expected" "C-like" layout

[swift-users] appending packed bytes to [UInt8]

2018-01-10 Thread Kelvin Ma via swift-users
I want to create a buffer with the layout 0 4 8 12 13 14 15 16 [ x:Float | y:Float | z:Float | r:UInt8 | g:UInt8 | b:UInt8 | _:UInt8 ] Normally, I’d use UnsafeRawBufferPointer for this, but I need the buffer to be a vector (i.e. with

Re: [swift-users] Clarification about the Swift API Design Guide - Initializer and factory methods calls

2018-01-09 Thread Kelvin Ma via swift-users
I didn’t write the guidelines but i never really felt Array(repeating:count:) was weird, you have two arguments, they need to be distinguished, and repeating is actually shorter than repeatedValue. On Tue, Jan 9, 2018 at 12:09 PM, Gaétan Zanella via swift-users < swift-users@swift.org> wrote: >

Re: [swift-users] Happy new year Swift community.

2018-01-01 Thread Kelvin Ma via swift-users
Happy new year from klossyland! On Mon, Jan 1, 2018 at 11:23 AM, Georgios Moschovitis via swift-users < swift-users@swift.org> wrote: > Happy new year! Greetings from Cyprus :) > > George. > > On 1 Jan 2018, at 1:42 AM, Adrian Zubarev via swift-users < > swift-users@swift.org> wrote: > > Well

Re: [swift-users] abs() Bug?

2017-12-12 Thread Kelvin Ma via swift-users
this is correct behavior. −Int.min can’t be represented in signed 2’s complement because the range of Int is 2^(bitWidth - 1) ..< 2^(bitWidth - 1) so it correctly traps on SIGILL. what i’m more worried about is why abs(Int32.min) is returning a value for you,, but mine traps as it should. On Tue,

Re: [swift-users] status of SR-755

2017-11-23 Thread Kelvin Ma via swift-users
mywsherman.com/ > > On Nov 16, 2017, at 18:32, Kelvin Ma via swift-users < > swift-users@swift.org> wrote: > > It’s been like a year since SR-755 <https://bugs.swift.org/browse/SR-755> > was filed and linux crash logs still look like this. > > Cur

[swift-users] status of SR-755

2017-11-16 Thread Kelvin Ma via swift-users
It’s been like a year since SR-755 was filed and linux crash logs still look like this. Current stack trace: 0libswiftCore.so0x7f39facaf0f0 _swift_stdlib_reportFatalError + 171 1libswiftCore.so

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

2017-11-09 Thread Kelvin Ma via swift-users
On Thu, Nov 9, 2017 at 10:37 AM, Johannes Weiß wrote: > 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

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

2017-11-09 Thread Kelvin Ma via swift-users
On Thu, Nov 9, 2017 at 10:37 AM, Johannes Weiß wrote: > 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

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

2017-11-09 Thread Kelvin Ma via swift-users
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. For example, a frame header chunk looks like this: 0 1

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

2017-11-08 Thread Kelvin Ma via swift-users
Nov 2017, at 4:54 pm, Kelvin Ma via swift-users < > swift-users@swift.org> 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 > &

[swift-users] raw buffer pointer load alignment

2017-11-08 Thread Kelvin Ma via swift-users
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 6

Re: [swift-users] Optimal String conversion to/from UTF-8 w/o null-termination?

2017-11-06 Thread Kelvin Ma via swift-users
doesn’t the compiler like to optimize the loop out of the benchmarking code? i’ve always had a hard time writing benchmarks in Swift On Fri, Nov 3, 2017 at 7:10 PM, Ryan Walklin via swift-users < swift-users@swift.org> wrote: > Why not just profile it? Set up a loop of 100,000 or so with each

Re: [swift-users] Swift Documentation question

2017-07-01 Thread Kelvin Ma via swift-users
i agree. it would also be a lot better if the docs lived on the actual swift website instead of the apple website. > On Jul 1, 2017, at 4:36 PM, Jon Shier via swift-users > wrote: > > swiftdoc.org should be integrated into swift.org and be kept officially > up to

[swift-users] A procedural noise library

2017-06-11 Thread Kelvin Ma via swift-users
Hi everyone, Thought you’d like to know that Swift now has a native procedural noise generation library, which I released today at https://github.com/kelvin13/noise . The Noise library supports several types of gradient noise (“Perlin noise”), cell noise (“Worley noise” or “Voronoi noise”),

Re: [swift-users] X11/Xlib linker error

2017-05-22 Thread Kelvin Ma via swift-users
Tried that, doesn’t help On Mon, May 22, 2017 at 4:23 AM, Alex Blewitt <alb...@apple.com> wrote: > > On 21 May 2017, at 20:48, Kelvin Ma via swift-users <swift-users@swift.org> > wrote: > > I’m trying to get Swift working with X11, and I keep getting this linker &g

Re: [swift-users] passing command line arguments to `swift test`

2017-05-19 Thread Kelvin Ma via swift-users
i want to be able to run a single test case at a time instead of my whole test suite and i’m currently invoking the test binary directly after doing `swift test` On May 19, 2017, at 4:56 PM, Brent Royal-Gordon <br...@architechies.com> wrote: >> On May 18, 2017, at 8:16 AM, Kelvin

[swift-users] passing command line arguments to `swift test`

2017-05-18 Thread Kelvin Ma via swift-users
Is there a way I can pass command line arguments along to the testing program with `swift test` so that they are visible in `CommandLine.arguments`? ___ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users

Re: [swift-users] Help! Slicing an array is very expensive

2017-05-08 Thread Kelvin Ma via swift-users
Depending on what you’re trying to do with the data, you might be better off using an UnsafeBufferPointer and allocating and reallocating that, C-style. On Mon, May 8, 2017 at 7:01 PM, Philippe Hausler via swift-users < swift-users@swift.org> wrote: > I wonder if Data might be a better tool for

Re: [swift-users] Passing value types or members of value types?

2017-05-07 Thread Kelvin Ma via swift-users
i’m also curious as to whether this would be faster as a member function on the struct itself, since member functions get `self` as a pointer, right? > On May 7, 2017, at 11:21 AM, Kelvin Ma wrote: > > So if I am passing the large struct to a large function, or a function

Re: [swift-users] Passing value types or members of value types?

2017-05-07 Thread Kelvin Ma via swift-users
gt; Zhaoxin > > > > On Mon, May 8, 2017 at 12:21 AM, Kelvin Ma via swift-users < > swift-users@swift.org> wrote: > >> So if I am passing the large struct to a large function, or a function >> that lives in a different module (as my project is currently split into

Re: [swift-users] Passing value types or members of value types?

2017-05-07 Thread Kelvin Ma via swift-users
So if I am passing the large struct to a large function, or a function that lives in a different module (as my project is currently split into 8 or 9 modules — is that too many?), am I better off passing the members individually instead of passing the entire struct? It seems kind of tedious to

Re: [swift-users] Passing value types or members of value types?

2017-05-06 Thread Kelvin Ma via swift-users
gmail.com> wrote: >> >> Oddly, until it's *written* you will be working with a pointer. >> >> Sent from my iPhone, please excuse brevity and errors >> >>> On May 6, 2017, at 9:33 PM, Kelvin Ma via swift-users >>> <swift-users@swift.org>

[swift-users] Passing value types or members of value types?

2017-05-06 Thread Kelvin Ma via swift-users
If I have a “large” struct like struct Vertex { let x:Double, y:Double var r:Int, g:Int, b:Int let s:Double, t:Double var selected:Bool } and I want to pass it to a function without modifying it like func taxicab_distance(_ v1:Vertex, _ v2:Vertex) -> Double { return v2.x -

Re: [swift-users] Why does String.CharacterView have reserveCapacity(:)?

2017-05-06 Thread Kelvin Ma via swift-users
at least be removed from `CharacterView` and `UnicodeScalarView` and only live in the parent `String` type. On Thu, May 4, 2017 at 6:33 AM, Brent Royal-Gordon <br...@architechies.com> wrote: > On May 2, 2017, at 12:35 PM, Kelvin Ma via swift-users < > swift-users@swift.org> wrote:

Re: [swift-users] Swift can’t compile code with OpenGL function pointers

2017-03-30 Thread Kelvin Ma via swift-users
ignatures for > all of them?? > > On Thu, Mar 30, 2017 at 11:31 AM, Joe Groff <jgr...@apple.com> wrote: > >> >> > On Mar 30, 2017, at 7:47 AM, Kelvin Ma via swift-users < >> swift-users@swift.org> wrote: >> > >> > OpenGL functions ar

Re: [swift-users] Swift can’t compile code with OpenGL function pointers

2017-03-30 Thread Kelvin Ma via swift-users
There are hundreds of gl functions… I have to rewrite the signatures for all of them?? On Thu, Mar 30, 2017 at 11:31 AM, Joe Groff <jgr...@apple.com> wrote: > > > On Mar 30, 2017, at 7:47 AM, Kelvin Ma via swift-users < > swift-users@swift.org> wrote: > > &

[swift-users] Swift can’t compile code with OpenGL function pointers

2017-03-30 Thread Kelvin Ma via swift-users
OpenGL functions are loaded at runtime by a function loader (like GLFW). They’re defined in a header but obviously they don’t have definitions at compile time so it causes a slew of linker errors when I try to build error: undefined reference to 'glEnable' error: undefined reference to

Re: [swift-users] [swift-build-dev] Importing C system libraries

2017-03-29 Thread Kelvin Ma via swift-users
t-build-dev can help you >>>>>> out. >>>>>> >>>>>> CC-ing Ankit >>>>>> >>>>>> >>>>>> On Mar 28, 2017, at 5:09 PM, Kelvin Ma <kelvinsthirt...@gmail.com> >>>>>> wrote: &g

Re: [swift-users] [swift-build-dev] Importing C system libraries

2017-03-29 Thread Kelvin Ma via swift-users
oks like this: >>>>> >>>>> >>>>> ​ >>>>> >>>>> On Tue, Mar 28, 2017 at 12:47 PM, Michael Ilseman <milse...@apple.com> >>>>> wrote: >>>>> >>>>>> Sure! In this example, I

Re: [swift-users] [swift-build-dev] Importing C system libraries

2017-03-28 Thread Kelvin Ma via swift-users
t Git >>>> // … use libGit2 >>>> >>>> >>>> Read more about how to write a more appropriate module.map file for >>>> your purposes at https://clang.llvm.org/docs/Modules.html. For >>>> example, you might be able to de

Re: [swift-users] Importing C system libraries

2017-03-28 Thread Kelvin Ma via swift-users
lags in your invocation of Swift. If you want to do so at a higher level, >> then perhaps SwiftPM can. CCing swift-build-dev for the SwiftPM part. >> >> >> > On Mar 26, 2017, at 3:20 PM, Kelvin Ma via swift-users < >> swift-users@swift.org> wrote: >> > &g

Re: [swift-users] [swift-build-dev] Importing C system libraries

2017-03-28 Thread Kelvin Ma via swift-users
I can only fit one monitor in my dorm and it’s honestly tragic… On Tue, Mar 28, 2017 at 2:58 PM, David Sweeris wrote: > > On Mar 28, 2017, at 1:58 AM, Rien via swift-build-dev < > swift-build-...@swift.org> wrote: > > I feel your pain ;-) > > Just embrace the dark side, it

Re: [swift-users] Importing C system libraries

2017-03-28 Thread Kelvin Ma via swift-users
ing swift-build-dev for the SwiftPM part. > > > > On Mar 26, 2017, at 3:20 PM, Kelvin Ma via swift-users < > swift-users@swift.org> wrote: > > > > Idk if this has been asked before, but is there a way to import C > libraries into a Swift project without creating a

Re: [swift-users] Importing C system libraries

2017-03-28 Thread Kelvin Ma via swift-users
to do so at a higher level, > then perhaps SwiftPM can. CCing swift-build-dev for the SwiftPM part. > >> > >> > >>> On Mar 26, 2017, at 3:20 PM, Kelvin Ma via swift-users < > swift-users@swift.org> wrote: > >>> > >>> Idk if this has been asked before

[swift-users] Importing C system libraries

2017-03-26 Thread Kelvin Ma via swift-users
Idk if this has been asked before, but is there a way to import C libraries into a Swift project without creating a local git repo? Preferably something similar to C where you can just `#include` headers and then specify the link flags (in Package.swift?) It’s getting very cumbersome to make a