Re: [swift-users] Referencing Swift Functions from the Objective-C Runtime

2016-11-23 Thread Jeff Kelley via swift-users
Hi Brian! Thanks for the replies. I haven’t been able to hack on this for a few days but hopefully I can over the holiday break this weekend. I’ve been experimenting with building XCTest for watchOS and constructing a test harness. I’ve gotten it to the point where I can execute the same test cla

Re: [swift-users] Referencing Swift Functions from the Objective-C Runtime

2016-11-21 Thread Brian Gesiak via swift-users
I'm curious: what are you hoping to accomplish with corelibs-xctest? If we can help you by modifying corelibs-xctest itself, that could be another option here. :) - Brian Gesiak On Mon, Nov 21, 2016 at 10:46 AM, Jeff Kelley via swift-users < swift-users@swift.org> wrote: > The type comes from X

Re: [swift-users] Referencing Swift Functions from the Objective-C Runtime

2016-11-21 Thread Jeff Kelley via swift-users
The type comes from XCTest. I’m trying to enumerate Objective-C methods in order to use them with XCTest in the open-source Swift version of XCTest, which needs the tests to be supplied as this type: /// This is a compound type used by `XCTMain` to represent tests to run. It combines an /// `XC

Re: [swift-users] Referencing Swift Functions from the Objective-C Runtime

2016-11-20 Thread Jacob Bandes-Storch via swift-users
"throws" is the part that's not representable in Obj-C. Why are you using it? If you're interacting with method_getImplementation, you need to think like the Obj-C runtime. https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtHowMessagingWorks.ht

Re: [swift-users] Referencing Swift Functions from the Objective-C Runtime

2016-11-20 Thread Jeff Kelley via swift-users
Still trying on this (copied the code directly, Foo is actually XCTestCase): typealias TestMethod = @convention(c) (XCTestCase) throws -> Void This seagulls the compiler with “error: '(XCTestCase) throws -> Void' is not representable in Objective-C, so it cannot be used with '@convention(c)’”. I

Re: [swift-users] Referencing Swift Functions from the Objective-C Runtime

2016-11-20 Thread Jacob Bandes-Storch via swift-users
For a function such as bar() above, the type you want to cast the IMP to would probably be "@convention(c) (Foo, Selector) -> ()". On Sun, Nov 20, 2016 at 9:05 PM, Jeff Kelley wrote: > Thanks Jacob! I tried using unsafeBitCast, but it fails with the > following: “fatal error: can't unsafeBitCast

Re: [swift-users] Referencing Swift Functions from the Objective-C Runtime

2016-11-20 Thread Jeff Kelley via swift-users
Thanks Jacob! I tried using unsafeBitCast, but it fails with the following: “fatal error: can't unsafeBitCast between types of different sizes”. I considered wrapping every call in a closure that calls objc_msgSend(), but alas, that’s not exposed to Swift. I have another approach in mind, so I’l

Re: [swift-users] Referencing Swift Functions from the Objective-C Runtime

2016-11-18 Thread Jacob Bandes-Storch via swift-users
I imagine unsafeBitCast would be the way to go here. But are you assuming that all of the instance methods have type "(Foo) throws -> Void" ? Or do you somehow want to dynamically use the type information? Jacob On Fri, Nov 18, 2016 at 10:37 PM, Jeff Kelley via swift-users < swift-users@swift.org