Re: [swift-users] How to malloc in Swift 3

2016-09-23 Thread Andrew Trick via swift-users
> On Sep 23, 2016, at 2:23 PM, Joe Groff wrote: > > >> On Sep 23, 2016, at 2:20 PM, Jens Persson wrote: >> >> What is the difference between: >> ptr.storeBytes(of: x, toByteOffset: offset, as: type(of: x)) >> ptr.advanced(by:

Re: [swift-users] How to malloc in Swift 3

2016-09-23 Thread Joe Groff via swift-users
> On Sep 23, 2016, at 2:20 PM, Jens Persson wrote: > > What is the difference between: > ptr.storeBytes(of: x, toByteOffset: offset, as: type(of: x)) > ptr.advanced(by: offset).assumingMemoryBound(to: type(of: x)).pointee = x > ? > I noticed that the former traps if storing

Re: [swift-users] How to malloc in Swift 3

2016-09-23 Thread Jens Persson via swift-users
What is the difference between: ptr.storeBytes(of: x, toByteOffset: offset, as: type(of: x)) ptr.advanced(by: offset).assumingMemoryBound(to: type(of: x)).pointee = x ? I noticed that the former traps if storing to a misaligned offset while the latter is happy to do that, and I saw it mentioned as

Re: [swift-users] How to malloc in Swift 3

2016-09-23 Thread Joe Groff via swift-users
> On Sep 23, 2016, at 1:55 AM, Gerriet M. Denkmann via swift-users > wrote: > > >> On 23 Sep 2016, at 15:47, Gerriet M. Denkmann via swift-users >> wrote: >> >> This used to work in Swift 2.2: >> >> var bitfield: UnsafeMutablePointer? >>

Re: [swift-users] Swift 3 likes to tease me

2016-09-23 Thread Joe Groff via swift-users
> On Sep 22, 2016, at 9:51 PM, Gerriet M. Denkmann via swift-users > wrote: > > This line (Swift 3): > if a.responds(to: Selector(“viewControllers") ) > creates this warning: Use '#selector' instead of explicitly constructing a > 'Selector' > > Ok. Following this

[swift-users] IOKit and USB devices with swift 3

2016-09-23 Thread Jérôme Duquennoy via swift-users
Hi swift community, I am trying to access an USB device in a swift project, with quite limited knowledge of IOKit and not a log of experience using unsafe pointers with swift. My goal is to create a class that will listen to connections and disconnections of a device matching a productID and

Re: [swift-users] How to malloc in Swift 3

2016-09-23 Thread Gerriet M. Denkmann via swift-users
> On 23 Sep 2016, at 15:47, Gerriet M. Denkmann via swift-users > wrote: > > This used to work in Swift 2.2: > > var bitfield: UnsafeMutablePointer? > bitfield = UnsafeMutablePointer( malloc( 888 ) ) > > How is this written in Swift 3.0? To answer my own question:

[swift-users] Mutex/queue access in Swift 3

2016-09-23 Thread Ron Olson via swift-users
Hey all- I used Erica's queue example (http://ericasadun.com/2016/03/08/swift-queue-fun/) to implement a queue in a multi-threaded Swift app (quick aside, is it 'correct' to say multithreaded when using DispatchQueue?). I spawn a number of objects on a .concurrent DispatchQueue and they all

[swift-users] How to 'import' 3rd-party frameworks and files when using the /usr/bin/swift REPL

2016-09-23 Thread has via swift-users
Hi folks, I'm working on a new "AppleScript" (Apple event) bridge, SwiftAutomation , and while the code's done bar cleaning and testing, I've gotten stuck on how to write a step-by-step tutorial for it. As I understand it, the recommended way to provide

Re: [swift-users] How to malloc in Swift 3

2016-09-23 Thread Quinn "The Eskimo!" via swift-users
On 23 Sep 2016, at 11:29, Gerriet M. Denkmann via swift-users wrote: > What about calloc then? Or use allocate and do a memset afterwards? For trivial data types (like UInt8) this will work, but if you want to follow the rules I recommend reading the following: *

Re: [swift-users] How to malloc in Swift 3

2016-09-23 Thread Gerriet M. Denkmann via swift-users
> On 23 Sep 2016, at 17:08, Svein Halvor Halvorsen via swift-users > wrote: > > var bitfield: UnsafeMutablePointer? > bitfield = UnsafeMutablePointer.allocate(capacity: 888) > Excellent! I see that “- Postcondition: The pointee is allocated, but not initialized.”

Re: [swift-users] How to malloc in Swift 3

2016-09-23 Thread Svein Halvor Halvorsen via swift-users
var bitfield: UnsafeMutablePointer? bitfield = UnsafeMutablePointer.allocate(capacity: 888) > 23. sep. 2016 kl. 10.47 skrev Gerriet M. Denkmann via swift-users > : > > This used to work in Swift 2.2: > > var bitfield: UnsafeMutablePointer? > bitfield =

[swift-users] How to malloc in Swift 3

2016-09-23 Thread Gerriet M. Denkmann via swift-users
This used to work in Swift 2.2: var bitfield: UnsafeMutablePointer? bitfield = UnsafeMutablePointer( malloc( 888 ) ) How is this written in Swift 3.0? Gerriet. ___ swift-users mailing list swift-users@swift.org

Re: [swift-users] Swift 3 likes to tease me

2016-09-23 Thread Jacob Bandes-Storch via swift-users
Once you've determined this object responds to the selector, how do you intend to use it? It's probably best to define your own protocol that has the requirement, and then you can access it via the protocol. In fact, at that point you might even be able to use "as?" rather than

Re: [swift-users] Swift 3 likes to tease me

2016-09-23 Thread Gerriet M. Denkmann via swift-users
> On 23 Sep 2016, at 12:09, Marco S Hyman wrote: > > On Sep 22, 2016, at 9:51 PM, Gerriet M. Denkmann via swift-users > wrote: >> >> This line (Swift 3): >> if a.responds(to: Selector(“viewControllers") ) >> creates this warning: Use '#selector'

Re: [swift-users] [swift-lldb-dev] Ubuntu 16.04 Bots on ci.swift.org

2016-09-23 Thread mishal_shah via swift-users
Master next: 0. OSS - LLDB Incremental - Ubuntu 16.04 (master-next) 0. OSS - Swift Incremental RA - Ubuntu 16.04 (master-next)

Re: [swift-users] Swift 3 likes to tease me

2016-09-23 Thread Jacob Bandes-Storch via swift-users
#selector is not used with a string, but with an actual reference to a method. If, for instance, you have a protocol MyVC which declares `var viewControllers: ...` then you can use something like #selector(MyVC.viewControllers). On Thu, Sep 22, 2016 at 9:51 PM, Gerriet M. Denkmann via swift-users