Re: [swift-users] [swift-corelibs-dev] DateFormatter crash on second usage (new instance) on Linux (swift 3.0.1)

2017-01-26 Thread Philippe Hausler via swift-users
You are probably missing the package libblocksruntime-dev. That would cause that failure. Sent from my iPhone > On Jan 26, 2017, at 6:33 AM, Dennis Schafroth wrote: > > Thanks for the suggestions. > > It works with 3.0.2 but won't compile with 3.1 beta for Ubuntu

Re: [swift-users] [swift-corelibs-dev] DateFormatter crash on second usage (new instance) on Linux (swift 3.0.1)

2017-01-25 Thread Philippe Hausler via swift-users
We should run those tests with ASAN, I thought I had fixed that with the Sierra merge. Sent from my iPhone > On Jan 25, 2017, at 6:11 PM, Will Stanton via swift-corelibs-dev > wrote: > > Based on the backtrace, I think the code is running into a memory issue

Re: [swift-users] Identity based object hash?

2016-10-05 Thread Philippe Hausler via swift-users
ObjectIdentifier(self).hashValue is a decent approach; it hashes based upon the pointer address. That is how swift-corelibs-foundation does it for the swift implementation of NSObject: https://github.com/apple/swift-corelibs-foundation/blob/master/Foundation/NSObject.swift#L94 > On Oct 5,

Re: [swift-users] How to bridge between CoreFoundation and SwiftFoundation on Linux?

2016-09-21 Thread Philippe Hausler via swift-users
I would suggest that the way to do it is to follow the NSString/NSNumber approach used in swift-corelibs-foundation where the structural size is equivalent. the layout would roughly look like: open class InputStream : Stream { typealias CFType = CFReadStream // This layout MUST be the

Re: [swift-users] Something you might be able to answer

2016-09-22 Thread Philippe Hausler via swift-users
So there are a couple of ways objects can be bridged: 1) has-a style bridges - RunLoop and CFRunLoop for example. The only association is where RunLoop contains a CFRunLoop and there is a method to fetch the CFRunLoop out of the RunLoop. Some times this relationship is not public. 2) is-a

Re: [swift-users] why NSTask is Process on Apple platforms but it's Task on Linux?

2016-11-27 Thread Philippe Hausler via swift-users
Looks like that renaming didn’t get updated correctly on swift-corelibs-foundation. I filed - https://bugs.swift.org/browse/SR-3279 > On Nov 26, 2016, at 9:42 PM, Mr Bee via swift-users > wrote: > > Hi all, > > It took me a few hours to find out why Process is unknown

Re: [swift-users] Decimal to Double?

2016-11-28 Thread Philippe Hausler via swift-users
This might be a bit nicer since that is relying on NSNumber bridges. You can bridge to NSDecimalNumber directly like this: (Decimal(1.0) as NSDecimalNumber).doubleValue (but perhaps we should consider adding initializers that follow the same pattern as Double that don’t have to bridge to

Re: [swift-users] Decimal imported as NSDecimal not NSDecimalNumber in Swift 3 to Objective C

2016-11-11 Thread Philippe Hausler via swift-users
NSDecimal is not toll free bridged, but it does have a bridge to NSDecimalNumber. So take this for example: @objc class Exam: NSObject { var grade: Double = 90.0 } It would be reasonable to expect that is exposed in objc as: @interface Exam : NSObject @property double grade; @end

Re: [swift-users] Autoreleasepool for Ubuntu

2016-11-02 Thread Philippe Hausler via swift-users
See: https://github.com/apple/swift-corelibs-foundation/blob/d015466450b2675037c6f1ace8e17e73050ccfb9/Foundation/NSURL.swift#L561 This is far and few between of cases

Re: [swift-users] Counting in Threads

2016-10-12 Thread Philippe Hausler via swift-users
attempt to grab it. Sent from my iPhone > On Oct 12, 2016, at 4:45 PM, Shawn Erickson <shaw...@gmail.com> wrote: > > So we would have to drop down to C code, etc. to safely leverage OSAtomic? > >> On Wed, Oct 12, 2016 at 8:32 AM Philippe Hausler via swift-users >>

Re: [swift-users] [swift-corelibs-dev] Building swift with xctest and foundation fails

2017-03-29 Thread Philippe Hausler via swift-users
You need to also pass --libdispatch but I am not quite sure that will fully fix the problem at hand. Sent from my iPhone > On Mar 29, 2017, at 6:29 PM, Mohit Athwani via swift-corelibs-dev > wrote: > > I'm trying to get back to work starting from scratch on

Re: [swift-users] Foundation: build.ninja No such file or directory

2017-03-28 Thread Philippe Hausler via swift-users
What host os are you attempting to build on? For linux you need to have a configured Foundation initially to run ninja. This means that you need to build swift with the build-script including --foundation and --libdispatch and --xctest After one successful build you can run ninja in the

Re: [swift-users] Still having trouble with C interop (passing buffers)

2017-04-25 Thread Philippe Hausler via swift-users
> On Apr 25, 2017, at 2:57 PM, Rick Mann via swift-users > wrote: > > I'm trying to pass a Data of allocated size to a C function for it to fill in: > > > lib_example_call(_ params: UnsafePointer!, _ data: > UnsafeMutableRawPointer!) > > ... > { >self.dataBuffer

Re: [swift-users] Extracting arbitrary types (e.g. UInt16) out of Data

2017-06-26 Thread Philippe Hausler via swift-users
Data.copyBytes will do that under the hood var crc: UInt16 = 0 let amountCopied = withUnsafeMutablePointer(to: ) { data.copyBytes(to: UnsafeMutableBufferPointer(start: $0, count: 1)) } if amountCopied == MemoryLayout.size { // we have a full crc } That will probably do what you want; plus

Re: [swift-users] Extracting arbitrary types (e.g. UInt16) out of Data

2017-06-26 Thread Philippe Hausler via swift-users
u are guard where the bytes were not fully initialized. > > (or the reverse, depending on the endianness of the source data) > > Charles > >> On Jun 26, 2017, at 12:05 PM, Philippe Hausler via swift-users >> <swift-users@swift.org <mailto:swift-users@swift.or

Re: [swift-users] Extracting arbitrary types (e.g. UInt16) out of Data

2017-06-26 Thread Philippe Hausler via swift-users
If the data was sliced. e.g. let d = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) let slice = d[2..<4] slice.endIndex != slice.count > >> >> (or the reverse, depending on the endianness of the source data) >> >> Charles >> >>> On Jun 26, 2017, at 12

Re: [swift-users] Extracting arbitrary types (e.g. UInt16) out of Data

2017-06-25 Thread Philippe Hausler via swift-users
There are probably a number of ways that would do what you need. I would need a bit more context or examples of what you are doing already to comment. But if I had those parameters to work with I would use copyBytes into the address of the target you are wanting to read. There are some cases

Re: [swift-users] arc4random_uniform on Linux is missing from Foundation??

2017-05-22 Thread Philippe Hausler via swift-users
arc4random_uniform is from Darwin not Foundation - it just happens to be in a header we import when you import Foundation. > On May 22, 2017, at 8:44 AM, Edward Connell via swift-users > wrote: > > Any ideas when Foundation on Linux will support arc4random_uniform? This

Re: [swift-users] Slicing a [UInt8] into a Data without copying?

2017-05-04 Thread Philippe Hausler via swift-users
Not sure on exactly how you are wanting to use this but you could approach this like: let bytes: [UInt8] = [ 0xC0, 0xC0, 0xA1, 0x00, 0xC0, 0xC0, 0xA1, 0x00] let slice = bytes[0..<4] slice.withUnsafeBytes { buffer in let d = Data(bytesNoCopy: UnsafeMutableRawPointer(mutating:

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

2017-05-08 Thread Philippe Hausler via swift-users
I wonder if Data might be a better tool for the job here since it is it’s own slice type and would avoid copying large amounts of data into temporary buffers. > On May 8, 2017, at 16:47, Rick Mann via swift-users > wrote: > > I have this C library that interacts with