Re: [swift-users] [swift-evolution] Low efficiency multidimensional array problem

2017-04-18 Thread Saagar Jha via swift-users
It might be helpful if you showed a bit more of the code you’re working on, so that we can better see what you’re trying to do. Is there any operation in particular that is slow? Also, CC’ing swift-users since I think it belongs there. Saagar Jha > On Apr 18, 2017, at 22:57, Hbucius Smith via

Re: [swift-users] Designable Protocols

2017-04-18 Thread Dennis Weissmann via swift-users
Are you sure that's because it's defined in a protocol and not because it's a `CGColor`. Can you try it with `UIColor`? I don't think CG types are supported with `@IBInspectable`. - Dennis Sent from my iPhone > On 19. Apr 2017, at 4:43 AM, Cavelle Benjamin via swift-users > wrote: > > I don

Re: [swift-users] odd `==` `!=` behavior with class that inherits `NSObject`

2017-04-18 Thread Nate Birkholz via swift-users
I'm not sure exactly how class declarations interact with the scope of a do{ } statement. I declare a new static function inside your do{ } scope and it works fine, but something about the mapping of `==` and `!=` to `isEqual` in NSObject seems to be confused by the scope of the do{ } block. I'm n

Re: [swift-users] odd `==` `!=` behavior with class that inherits `NSObject`

2017-04-18 Thread Zhao Xin via swift-users
Everyone should notice that in the do-block (Sample 2). The result is just opposite of the code out of it (Sample 1). Or say, out the do-block, Swift calls `==` directly. In the do-block, Swift just call `isEqual(_)` instead of `==`. That is the inconsistency I am confused. Zhaoxin On Wed, Apr 1

Re: [swift-users] odd `==` `!=` behavior with class that inherits `NSObject`

2017-04-18 Thread Nate Birkholz via swift-users
Your issue seems to be that you created a custom implementation for the `==` operator but not one for the `!=` operator. If I add a custom implementation for `!=` I get the results you expected. Tthe default implementation of NSObject's `isEqual` is a test for identity, like the `===` in Swift. So

[swift-users] Designable Protocols

2017-04-18 Thread Cavelle Benjamin via swift-users
I don’t post to this mailing list very often. Working on updating my app to have a base set of code that cuts across macOS, iOS, tvOS, watchOS I’m writing a protocol to use across all the platforms that would be “designable” inside Interface Builder, but I cannot make protocol variables Inspec

[swift-users] odd `==` `!=` behavior with class that inherits `NSObject`

2017-04-18 Thread Zhao Xin via swift-users
Sample 1: both `==` and `!=` is true. import Foundation class Foo:NSObject { let name:String init(name:String) { self.name = name } public static func ==(lhs: Foo, rhs: Foo) -> Bool { guard type(of:lhs) == type(of:rhs) else { return false } return

[swift-users] String init from Int8 tuple?

2017-04-18 Thread Rick Mann via swift-users
In my C-interop, I have a need to do this a lot: typedef struct { char message[LGS_MAX_MESSAGE_SIZE]; ...other stuff... } lgs_result_info_t; func callbackFailed(info inInfo: lgs_result_info_t) { var m = inInfo.message // *See note below let message: String = withUnsafePointer

Re: [swift-users] Having a hard time with C interop (callbacks)

2017-04-18 Thread Rick Mann via swift-users
Ah, turns out the passed-in type is UnsafePointer, and I can just call .pointee on that. That seems to have fixed my issues. Not sure if I'm doing the rest of it wrong, but it's not crashing now, at least. > On Apr 18, 2017, at 16:18 , Rick Mann via swift-users > wrote: > > I'm trying to use

[swift-users] Having a hard time with C interop (callbacks)

2017-04-18 Thread Rick Mann via swift-users
I'm trying to use an API with a complicated callback structure. You pass a struct with a set of pointers to callbacks to a function, along with a pointer to a buffer it fills out. Here's an elided version of the C and Swift code: https://pastebin.com/k3VYJTjB This compiles, but I get a

Re: [swift-users] Importing empty C structs

2017-04-18 Thread Rick Mann via swift-users
> On Apr 18, 2017, at 09:11 , Joe Groff wrote: > > >> On Apr 17, 2017, at 6:19 PM, Rick Mann via swift-users >> wrote: >> >> I'm trying to make a module out of a C library and header file. It has at >> least one empty struct: >> >> struct lgs_context_t {}; >> >> and a function: >> >> LGS

Re: [swift-users] Can't access Swift class from Objective-C

2017-04-18 Thread Rick Mann via swift-users
Oh goodness, I'm an idiot. I did not subclass NSObject. BTW, once I've inherited from NSObject, is it still necessary to apply @objc? And related, the ModuleName-Swift.h header that's generated isn't automatically including the C header that's used by my Swift code (my Swift code wraps a C API

Re: [swift-users] Can't access Swift class from Objective-C

2017-04-18 Thread Jordan Rose via swift-users
Hey, Rick. I think we'd need a bit more information to really diagnose this—in particular, the class declaration in Swift—but here are some possibilities: - Classes that don't inherit from NSObject are not exposed to Objective-C - Classes with any generic ancesters are not exposed to Objective-C,

Re: [swift-users] Cannot subclass a class with objc_subclassing_restricted attribute

2017-04-18 Thread Joe Groff via swift-users
> On Apr 17, 2017, at 10:11 PM, Rick Mann wrote: > >> >> On Apr 17, 2017, at 08:54 , Joe Groff wrote: >> >> >>> On Apr 14, 2017, at 7:41 PM, Rick Mann via swift-users >>> wrote: >>> >>> I'm refactoring some Objective-C code to inherit from a new Swift super >>> class. This has been going

Re: [swift-users] Importing empty C structs

2017-04-18 Thread Joe Groff via swift-users
> On Apr 17, 2017, at 6:19 PM, Rick Mann via swift-users > wrote: > > I'm trying to make a module out of a C library and header file. It has at > least one empty struct: > > struct lgs_context_t {}; > > and a function: > > LGS_EXPORT struct lgs_context_t* lgs_init(const lgs_context_params_t

Re: [swift-users] Build swift on FreeBSD

2017-04-18 Thread Alex Blewitt via swift-users
The error may be because of the missing symbol you saw earlier. The build has a setting SWIFT_LINK_OBJC_RUNTIME which should default to NO on non-Darwin systems, but I don't know how the detection works on FreeBSD. The symbol is being emitted by the clang compiler and it seems to think there's