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: offset).assumingMemoryBound(to: type(of: x)).pointee = x >> ? >> I

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 to a misaligned offse

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? >> bitfield = UnsafeMutablePointer( malloc( 888 ) ) >>

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 advice I change it to:

Re: [swift-users] Ubuntu 16.04 support?

2016-09-23 Thread Todd Fiala via swift-users
Hi Lane, We’re going to be following the plan we proposed here: https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20160418/001778.html Our intent is to continue building packages for the versions of Ubuntu wher

[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 ve

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

2016-09-23 Thread Adrian Zubarev via swift-users
Whops sry wrong receiver mail. :/ My bad. --  Adrian Zubarev Sent with Airmail Am 23. September 2016 um 17:51:44, Adrian Zubarev (adrian.zuba...@devandartist.com) schrieb: Do you care about the order in which your queue is filled? Do you have multiple queues - I’m asking because your serial q

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: This works: var bitfield: U

[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 t

[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 u

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: * UnsafeRawPointer Migration

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.” What about calloc then? Or

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 = UnsafeMutablePointer( malloc( 888 ) ) >

[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 https://lists.swift.org/mailman/listinfo

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

2016-09-23 Thread Gerriet M. Denkmann via swift-users
> On 23 Sep 2016, at 14:19, Jacob Bandes-Storch via swift-users > wrote: > > Once you’ve determined this object responds to the selector, how do you > intend to use it? The function containing “ if a.responds…” is helping me to understand the layout of views in iOS. The input is some object,

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 "respondsToSelector