Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion examples/apple/objc_interop/OIPrintStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
#import <Foundation/Foundation.h>

/** A very contrived interface for writing strings to a file handle. */
@interface OIPrintStream : NSObject
@interface OIPrintStream<PrintType> : NSObject

- (nonnull instancetype)initWithFileHandle:(nonnull NSFileHandle *)fileHandle;

- (void)print:(nonnull PrintType)message;

- (void)printString:(nonnull NSString *)message;

@end
3 changes: 3 additions & 0 deletions examples/apple/objc_interop/OIPrintStream.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ - (instancetype)initWithFileHandle:(nonnull NSFileHandle *)fileHandle {
return self;
}

- (void)print:(nonnull id)message {
}

- (void)printString:(nonnull NSString *)message {
NSData *data = [message dataUsingEncoding:NSUTF8StringEncoding];
[_fileHandle writeData:data];
Expand Down
9 changes: 8 additions & 1 deletion examples/apple/objc_interop/Printer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,24 @@
import Foundation
import examples_apple_objc_interop_PrintStream

@objc public protocol MyStupid {
}

@objc(OIPrinter)
public class Printer: NSObject {

private let stream: OIPrintStream
private let stream: OIPrintStream<MyStupid>
private let prefix: String

@objc public init(prefix: NSString) {
self.stream = OIPrintStream(fileHandle: .standardOutput)
self.prefix = prefix as String
}

@objc public func stream(_ thing: MyStupid) -> OIPrintStream<MyStupid> {
return stream
}

@objc public func print(_ message: NSString) {
stream.print("\(prefix)\(message)")
}
Expand Down
4 changes: 3 additions & 1 deletion examples/apple/objc_interop_modulemap/OIPrintStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
#import <Foundation/Foundation.h>

/** A very contrived interface for writing strings to a file handle. */
@interface OIPrintStream : NSObject
@interface OIPrintStream<PrintType> : NSObject

- (nonnull instancetype)initWithFileHandle:(nonnull NSFileHandle *)fileHandle;

- (void)print:(nonnull PrintType)message;

- (void)printString:(nonnull NSString *)message;

@end
3 changes: 3 additions & 0 deletions examples/apple/objc_interop_modulemap/OIPrintStream.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ - (instancetype)initWithFileHandle:(nonnull NSFileHandle *)fileHandle {
return self;
}

- (void)print:(nonnull id)message {
}

- (void)printString:(nonnull NSString *)message {
NSData *data = [message dataUsingEncoding:NSUTF8StringEncoding];
[_fileHandle writeData:data];
Expand Down
9 changes: 8 additions & 1 deletion examples/apple/objc_interop_modulemap/Printer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,24 @@
import Foundation
import examples_apple_objc_interop_modulemap_PrintStream

@objc public protocol MyStupid {
}

@objc(OIPrinter)
public class Printer: NSObject {

private let stream: OIPrintStream
private let stream: OIPrintStream<MyStupid>
private let prefix: String

@objc public init(prefix: NSString) {
self.stream = OIPrintStream(fileHandle: .standardOutput)
self.prefix = prefix as String
}

@objc public func stream(_ thing: MyStupid) -> OIPrintStream<MyStupid> {
return stream
}

@objc public func print(_ message: NSString) {
stream.print("\(prefix)\(message)")
}
Expand Down