Browse Source

Merge pull request #56 from grpc/internal_access

Change access level for generated classes and methods to "internal"
Tim Burks 8 years ago
parent
commit
27334787ed

+ 0 - 2
Examples/Datastore/PackageManager/RUNME

@@ -16,8 +16,6 @@ protoc \
 	googleapis/google/type/latlng.proto \
  	-Igoogleapis \
 	--swift_out=googleapis \
-	--swift_opt=Visibility=Public \
-	--plugin=$HOME/local/bin/protoc-gen-swift \
 	--swiftgrpc_out=Sources
 
 # move swift files to this directory

+ 25 - 25
Examples/Echo/Generated/echo.client.pb.swift

@@ -44,14 +44,14 @@ import Dispatch
 import gRPC
 
 /// Type for errors thrown from generated client code.
-public enum Echo_EchoClientError : Error {
+internal enum Echo_EchoClientError : Error {
   case endOfStream
   case invalidMessageReceived
   case error(c: CallResult)
 }
 
 /// Get (Unary)
-public class Echo_EchoGetCall {
+internal class Echo_EchoGetCall {
   private var call : Call
 
   /// Create a call.
@@ -101,7 +101,7 @@ public class Echo_EchoGetCall {
 }
 
 /// Expand (Server Streaming)
-public class Echo_EchoExpandCall {
+internal class Echo_EchoExpandCall {
   private var call : Call
 
   /// Create a call.
@@ -123,7 +123,7 @@ public class Echo_EchoExpandCall {
   }
 
   /// Call this to wait for a result. Blocking.
-  public func receive() throws -> Echo_EchoResponse {
+  internal func receive() throws -> Echo_EchoResponse {
     var returnError : Echo_EchoClientError?
     var returnResponse : Echo_EchoResponse!
     let sem = DispatchSemaphore(value: 0)
@@ -142,7 +142,7 @@ public class Echo_EchoExpandCall {
   }
 
   /// Call this to wait for a result. Nonblocking.
-  public func receive(completion:@escaping (Echo_EchoResponse?, Echo_EchoClientError?)->()) throws {
+  internal func receive(completion:@escaping (Echo_EchoResponse?, Echo_EchoClientError?)->()) throws {
     do {
       try call.receiveMessage() {(responseData) in
         if let responseData = responseData {
@@ -160,7 +160,7 @@ public class Echo_EchoExpandCall {
 }
 
 /// Collect (Client Streaming)
-public class Echo_EchoCollectCall {
+internal class Echo_EchoCollectCall {
   private var call : Call
 
   /// Create a call.
@@ -176,13 +176,13 @@ public class Echo_EchoCollectCall {
   }
 
   /// Call this to send each message in the request stream. Nonblocking.
-  public func send(_ message:Echo_EchoRequest, errorHandler:@escaping (Error)->()) throws {
+  internal func send(_ message:Echo_EchoRequest, errorHandler:@escaping (Error)->()) throws {
     let messageData = try message.serializedData()
     try call.sendMessage(data:messageData, errorHandler:errorHandler)
   }
 
   /// Call this to close the connection and wait for a response. Blocking.
-  public func closeAndReceive() throws -> Echo_EchoResponse {
+  internal func closeAndReceive() throws -> Echo_EchoResponse {
     var returnError : Echo_EchoClientError?
     var returnResponse : Echo_EchoResponse!
     let sem = DispatchSemaphore(value: 0)
@@ -203,7 +203,7 @@ public class Echo_EchoCollectCall {
   }
 
   /// Call this to close the connection and wait for a response. Nonblocking.
-  public func closeAndReceive(completion:@escaping (Echo_EchoResponse?, Echo_EchoClientError?)->())
+  internal func closeAndReceive(completion:@escaping (Echo_EchoResponse?, Echo_EchoClientError?)->())
     throws {
       do {
         try call.receiveMessage() {(responseData) in
@@ -222,7 +222,7 @@ public class Echo_EchoCollectCall {
 }
 
 /// Update (Bidirectional Streaming)
-public class Echo_EchoUpdateCall {
+internal class Echo_EchoUpdateCall {
   private var call : Call
 
   /// Create a call.
@@ -238,7 +238,7 @@ public class Echo_EchoUpdateCall {
   }
 
   /// Call this to wait for a result. Blocking.
-  public func receive() throws -> Echo_EchoResponse {
+  internal func receive() throws -> Echo_EchoResponse {
     var returnError : Echo_EchoClientError?
     var returnMessage : Echo_EchoResponse!
     let sem = DispatchSemaphore(value: 0)
@@ -257,7 +257,7 @@ public class Echo_EchoUpdateCall {
   }
 
   /// Call this to wait for a result. Nonblocking.
-  public func receive(completion:@escaping (Echo_EchoResponse?, Echo_EchoClientError?)->()) throws {
+  internal func receive(completion:@escaping (Echo_EchoResponse?, Echo_EchoClientError?)->()) throws {
     do {
       try call.receiveMessage() {(data) in
         if let data = data {
@@ -274,13 +274,13 @@ public class Echo_EchoUpdateCall {
   }
 
   /// Call this to send each message in the request stream.
-  public func send(_ message:Echo_EchoRequest, errorHandler:@escaping (Error)->()) throws {
+  internal func send(_ message:Echo_EchoRequest, errorHandler:@escaping (Error)->()) throws {
     let messageData = try message.serializedData()
     try call.sendMessage(data:messageData, errorHandler:errorHandler)
   }
 
   /// Call this to close the sending connection. Blocking.
-  public func closeSend() throws {
+  internal func closeSend() throws {
     let sem = DispatchSemaphore(value: 0)
     try closeSend() {
       sem.signal()
@@ -289,7 +289,7 @@ public class Echo_EchoUpdateCall {
   }
 
   /// Call this to close the sending connection. Nonblocking.
-  public func closeSend(completion:@escaping ()->()) throws {
+  internal func closeSend(completion:@escaping ()->()) throws {
     try call.close() {
       completion()
     }
@@ -297,16 +297,16 @@ public class Echo_EchoUpdateCall {
 }
 
 /// Call methods of this class to make API calls.
-public class Echo_EchoService {
+internal class Echo_EchoService {
   private var channel: Channel
 
   /// This metadata will be sent with all requests.
-  public var metadata : Metadata
+  internal var metadata : Metadata
 
   /// This property allows the service host name to be overridden.
   /// For example, it can be used to make calls to "localhost:8080"
   /// appear to be to "example.com".
-  public var host : String {
+  internal var host : String {
     get {
       return self.channel.host
     }
@@ -316,27 +316,27 @@ public class Echo_EchoService {
   }
 
   /// Create a client that makes insecure connections.
-  public init(address: String) {
+  internal init(address: String) {
     gRPC.initialize()
     channel = Channel(address:address)
     metadata = Metadata()
   }
 
   /// Create a client that makes secure connections.
-  public init(address: String, certificates: String?, host: String?) {
+  internal init(address: String, certificates: String?, host: String?) {
     gRPC.initialize()
     channel = Channel(address:address, certificates:certificates, host:host)
     metadata = Metadata()
   }
 
   /// Synchronous. Unary.
-  public func get(_ request: Echo_EchoRequest)
+  internal func get(_ request: Echo_EchoRequest)
     throws
     -> Echo_EchoResponse {
       return try Echo_EchoGetCall(channel).run(request:request, metadata:metadata)
   }
   /// Asynchronous. Unary.
-  public func get(_ request: Echo_EchoRequest,
+  internal func get(_ request: Echo_EchoRequest,
                   completion: @escaping (Echo_EchoResponse?, CallResult)->())
     throws
     -> Echo_EchoGetCall {
@@ -347,7 +347,7 @@ public class Echo_EchoService {
   /// Asynchronous. Server-streaming.
   /// Send the initial message.
   /// Use methods on the returned object to get streamed responses.
-  public func expand(_ request: Echo_EchoRequest, completion: @escaping (CallResult)->())
+  internal func expand(_ request: Echo_EchoRequest, completion: @escaping (CallResult)->())
     throws
     -> Echo_EchoExpandCall {
       return try Echo_EchoExpandCall(channel).start(request:request, metadata:metadata, completion:completion)
@@ -355,7 +355,7 @@ public class Echo_EchoService {
   /// Asynchronous. Client-streaming.
   /// Use methods on the returned object to stream messages and
   /// to close the connection and wait for a final response.
-  public func collect(completion: @escaping (CallResult)->())
+  internal func collect(completion: @escaping (CallResult)->())
     throws
     -> Echo_EchoCollectCall {
       return try Echo_EchoCollectCall(channel).start(metadata:metadata, completion:completion)
@@ -363,7 +363,7 @@ public class Echo_EchoService {
   /// Asynchronous. Bidirectional-streaming.
   /// Use methods on the returned object to stream messages,
   /// to wait for replies, and to close the connection.
-  public func update(completion: @escaping (CallResult)->())
+  internal func update(completion: @escaping (CallResult)->())
     throws
     -> Echo_EchoUpdateCall {
       return try Echo_EchoUpdateCall(channel).start(metadata:metadata, completion:completion)

+ 18 - 18
Examples/Echo/Generated/echo.pb.swift

@@ -33,17 +33,17 @@ fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAP
   typealias Version = _1
 }
 
-public struct Echo_EchoRequest: SwiftProtobuf.Message {
-  public static let protoMessageName: String = _protobuf_package + ".EchoRequest"
+struct Echo_EchoRequest: SwiftProtobuf.Message {
+  static let protoMessageName: String = _protobuf_package + ".EchoRequest"
 
   /// The text of a message to be echoed.
-  public var text: String = String()
+  var text: String = String()
 
-  public var unknownFields = SwiftProtobuf.UnknownStorage()
+  var unknownFields = SwiftProtobuf.UnknownStorage()
 
-  public init() {}
+  init() {}
 
-  public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
+  mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
     while let fieldNumber = try decoder.nextFieldNumber() {
       switch fieldNumber {
       case 1: try decoder.decodeSingularStringField(value: &self.text)
@@ -52,7 +52,7 @@ public struct Echo_EchoRequest: SwiftProtobuf.Message {
     }
   }
 
-  public func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
+  func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
     if !self.text.isEmpty {
       try visitor.visitSingularStringField(value: self.text, fieldNumber: 1)
     }
@@ -60,17 +60,17 @@ public struct Echo_EchoRequest: SwiftProtobuf.Message {
   }
 }
 
-public struct Echo_EchoResponse: SwiftProtobuf.Message {
-  public static let protoMessageName: String = _protobuf_package + ".EchoResponse"
+struct Echo_EchoResponse: SwiftProtobuf.Message {
+  static let protoMessageName: String = _protobuf_package + ".EchoResponse"
 
   /// The text of an echo response.
-  public var text: String = String()
+  var text: String = String()
 
-  public var unknownFields = SwiftProtobuf.UnknownStorage()
+  var unknownFields = SwiftProtobuf.UnknownStorage()
 
-  public init() {}
+  init() {}
 
-  public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
+  mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
     while let fieldNumber = try decoder.nextFieldNumber() {
       switch fieldNumber {
       case 1: try decoder.decodeSingularStringField(value: &self.text)
@@ -79,7 +79,7 @@ public struct Echo_EchoResponse: SwiftProtobuf.Message {
     }
   }
 
-  public func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
+  func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
     if !self.text.isEmpty {
       try visitor.visitSingularStringField(value: self.text, fieldNumber: 1)
     }
@@ -92,11 +92,11 @@ public struct Echo_EchoResponse: SwiftProtobuf.Message {
 fileprivate let _protobuf_package = "echo"
 
 extension Echo_EchoRequest: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
-  public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+  static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
     1: .same(proto: "text"),
   ]
 
-  public func _protobuf_generated_isEqualTo(other: Echo_EchoRequest) -> Bool {
+  func _protobuf_generated_isEqualTo(other: Echo_EchoRequest) -> Bool {
     if self.text != other.text {return false}
     if unknownFields != other.unknownFields {return false}
     return true
@@ -104,11 +104,11 @@ extension Echo_EchoRequest: SwiftProtobuf._MessageImplementationBase, SwiftProto
 }
 
 extension Echo_EchoResponse: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
-  public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+  static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
     1: .same(proto: "text"),
   ]
 
-  public func _protobuf_generated_isEqualTo(other: Echo_EchoResponse) -> Bool {
+  func _protobuf_generated_isEqualTo(other: Echo_EchoResponse) -> Bool {
     if self.text != other.text {return false}
     if unknownFields != other.unknownFields {return false}
     return true

+ 22 - 22
Examples/Echo/Generated/echo.server.pb.swift

@@ -44,12 +44,12 @@ import Dispatch
 import gRPC
 
 /// Type for errors thrown from generated server code.
-public enum Echo_EchoServerError : Error {
+internal enum Echo_EchoServerError : Error {
   case endOfStream
 }
 
 /// To build a server, implement a class that conforms to this protocol.
-public protocol Echo_EchoProvider {
+internal protocol Echo_EchoProvider {
   func get(request : Echo_EchoRequest, session : Echo_EchoGetSession) throws -> Echo_EchoResponse
   func expand(request : Echo_EchoRequest, session : Echo_EchoExpandSession) throws
   func collect(session : Echo_EchoCollectSession) throws
@@ -57,14 +57,14 @@ public protocol Echo_EchoProvider {
 }
 
 /// Common properties available in each service session.
-public class Echo_EchoSession {
+internal class Echo_EchoSession {
   fileprivate var handler : gRPC.Handler
-  public var requestMetadata : Metadata { return handler.requestMetadata }
+  internal var requestMetadata : Metadata { return handler.requestMetadata }
 
-  public var statusCode : Int = 0
-  public var statusMessage : String = "OK"
-  public var initialMetadata : Metadata = Metadata()
-  public var trailingMetadata : Metadata = Metadata()
+  internal var statusCode : Int = 0
+  internal var statusMessage : String = "OK"
+  internal var initialMetadata : Metadata = Metadata()
+  internal var trailingMetadata : Metadata = Metadata()
 
   fileprivate init(handler:gRPC.Handler) {
     self.handler = handler
@@ -72,7 +72,7 @@ public class Echo_EchoSession {
 }
 
 // Get (Unary)
-public class Echo_EchoGetSession : Echo_EchoSession {
+internal class Echo_EchoGetSession : Echo_EchoSession {
   private var provider : Echo_EchoProvider
 
   /// Create a session.
@@ -97,7 +97,7 @@ public class Echo_EchoGetSession : Echo_EchoSession {
 }
 
 // Expand (Server Streaming)
-public class Echo_EchoExpandSession : Echo_EchoSession {
+internal class Echo_EchoExpandSession : Echo_EchoSession {
   private var provider : Echo_EchoProvider
 
   /// Create a session.
@@ -107,7 +107,7 @@ public class Echo_EchoExpandSession : Echo_EchoSession {
   }
 
   /// Send a message. Nonblocking.
-  public func send(_ response: Echo_EchoResponse) throws {
+  internal func send(_ response: Echo_EchoResponse) throws {
     try handler.sendResponse(message:response.serializedData()) {}
   }
 
@@ -139,7 +139,7 @@ public class Echo_EchoExpandSession : Echo_EchoSession {
 }
 
 // Collect (Client Streaming)
-public class Echo_EchoCollectSession : Echo_EchoSession {
+internal class Echo_EchoCollectSession : Echo_EchoSession {
   private var provider : Echo_EchoProvider
 
   /// Create a session.
@@ -149,7 +149,7 @@ public class Echo_EchoCollectSession : Echo_EchoSession {
   }
 
   /// Receive a message. Blocks until a message is received or the client closes the connection.
-  public func receive() throws -> Echo_EchoRequest {
+  internal func receive() throws -> Echo_EchoRequest {
     let sem = DispatchSemaphore(value: 0)
     var requestMessage : Echo_EchoRequest?
     try self.handler.receiveMessage() {(requestData) in
@@ -166,7 +166,7 @@ public class Echo_EchoCollectSession : Echo_EchoSession {
   }
 
   /// Send a response and close the connection.
-  public func sendAndClose(_ response: Echo_EchoResponse) throws {
+  internal func sendAndClose(_ response: Echo_EchoResponse) throws {
     try self.handler.sendResponse(message:response.serializedData(),
                                   statusCode:self.statusCode,
                                   statusMessage:self.statusMessage,
@@ -188,7 +188,7 @@ public class Echo_EchoCollectSession : Echo_EchoSession {
 }
 
 // Update (Bidirectional Streaming)
-public class Echo_EchoUpdateSession : Echo_EchoSession {
+internal class Echo_EchoUpdateSession : Echo_EchoSession {
   private var provider : Echo_EchoProvider
 
   /// Create a session.
@@ -198,7 +198,7 @@ public class Echo_EchoUpdateSession : Echo_EchoSession {
   }
 
   /// Receive a message. Blocks until a message is received or the client closes the connection.
-  public func receive() throws -> Echo_EchoRequest {
+  internal func receive() throws -> Echo_EchoRequest {
     let sem = DispatchSemaphore(value: 0)
     var requestMessage : Echo_EchoRequest?
     try self.handler.receiveMessage() {(requestData) in
@@ -220,12 +220,12 @@ public class Echo_EchoUpdateSession : Echo_EchoSession {
   }
 
   /// Send a message. Nonblocking.
-  public func send(_ response: Echo_EchoResponse) throws {
+  internal func send(_ response: Echo_EchoResponse) throws {
     try handler.sendResponse(message:response.serializedData()) {}
   }
 
   /// Close a connection. Blocks until the connection is closed.
-  public func close() throws {
+  internal func close() throws {
     let sem = DispatchSemaphore(value: 0)
     try self.handler.sendStatus(statusCode:self.statusCode,
                                 statusMessage:self.statusMessage,
@@ -251,13 +251,13 @@ public class Echo_EchoUpdateSession : Echo_EchoSession {
 
 
 /// Main server for generated service
-public class Echo_EchoServer {
+internal class Echo_EchoServer {
   private var address: String
   private var server: gRPC.Server
   private var provider: Echo_EchoProvider?
 
   /// Create a server that accepts insecure connections.
-  public init(address:String,
+  internal init(address:String,
               provider:Echo_EchoProvider) {
     gRPC.initialize()
     self.address = address
@@ -266,7 +266,7 @@ public class Echo_EchoServer {
   }
 
   /// Create a server that accepts secure connections.
-  public init?(address:String,
+  internal init?(address:String,
                certificateURL:URL,
                keyURL:URL,
                provider:Echo_EchoProvider) {
@@ -283,7 +283,7 @@ public class Echo_EchoServer {
   }
 
   /// Start the server.
-  public func start(queue:DispatchQueue = DispatchQueue.global()) {
+  internal func start(queue:DispatchQueue = DispatchQueue.global()) {
     guard let provider = self.provider else {
       assert(false) // the server requires a provider
     }

+ 1 - 1
Examples/Echo/RUNME

@@ -2,4 +2,4 @@
 #
 # Use this to run the swift-proto generator
 #
-protoc echo.proto --swift_out=. --swift_opt=Visibility=Public --plugin=$HOME/local/bin/protoc-gen-swift
+protoc echo.proto --swift_out=./Generated

+ 1 - 1
Plugin/Sources/protoc-gen-swiftgrpc/main.swift

@@ -105,7 +105,7 @@ func main() throws {
     if file.service.count > 0 {
 
       // generate separate implementation files for client and server
-      let context : [String:Any] = ["file": file]
+      let context : [String:Any] = ["file": file, "access": "internal"]
 
       do {
         let clientFileName = package + ".client.pb.swift"

File diff suppressed because it is too large
+ 0 - 0
Plugin/Sources/protoc-gen-swiftgrpc/templates.swift


+ 6 - 6
Plugin/Templates/client-call-bidistreaming.swift

@@ -1,5 +1,5 @@
 /// {{ method.name }} (Bidirectional Streaming)
-public class {{ .|call:file,service,method }} {
+{{ access }} class {{ .|call:file,service,method }} {
   private var call : Call
 
   /// Create a call.
@@ -15,7 +15,7 @@ public class {{ .|call:file,service,method }} {
   }
 
   /// Call this to wait for a result. Blocking.
-  public func receive() throws -> {{ method|output }} {
+  {{ access }} func receive() throws -> {{ method|output }} {
     var returnError : {{ .|clienterror:file,service }}?
     var returnMessage : {{ method|output }}!
     let sem = DispatchSemaphore(value: 0)
@@ -34,7 +34,7 @@ public class {{ .|call:file,service,method }} {
   }
 
   /// Call this to wait for a result. Nonblocking.
-  public func receive(completion:@escaping ({{ method|output }}?, {{ .|clienterror:file,service }}?)->()) throws {
+  {{ access }} func receive(completion:@escaping ({{ method|output }}?, {{ .|clienterror:file,service }}?)->()) throws {
     do {
       try call.receiveMessage() {(data) in
         if let data = data {
@@ -51,13 +51,13 @@ public class {{ .|call:file,service,method }} {
   }
 
   /// Call this to send each message in the request stream.
-  public func send(_ message:{{ method|input }}, errorHandler:@escaping (Error)->()) throws {
+  {{ access }} func send(_ message:{{ method|input }}, errorHandler:@escaping (Error)->()) throws {
     let messageData = try message.serializedData()
     try call.sendMessage(data:messageData, errorHandler:errorHandler)
   }
 
   /// Call this to close the sending connection. Blocking.
-  public func closeSend() throws {
+  {{ access }} func closeSend() throws {
     let sem = DispatchSemaphore(value: 0)
     try closeSend() {
       sem.signal()
@@ -66,7 +66,7 @@ public class {{ .|call:file,service,method }} {
   }
 
   /// Call this to close the sending connection. Nonblocking.
-  public func closeSend(completion:@escaping ()->()) throws {
+  {{ access }} func closeSend(completion:@escaping ()->()) throws {
     try call.close() {
       completion()
     }

+ 4 - 4
Plugin/Templates/client-call-clientstreaming.swift

@@ -1,5 +1,5 @@
 /// {{ method.name }} (Client Streaming)
-public class {{ .|call:file,service,method }} {
+{{ access }} class {{ .|call:file,service,method }} {
   private var call : Call
 
   /// Create a call.
@@ -15,13 +15,13 @@ public class {{ .|call:file,service,method }} {
   }
 
   /// Call this to send each message in the request stream. Nonblocking.
-  public func send(_ message:{{ method|input }}, errorHandler:@escaping (Error)->()) throws {
+  {{ access }} func send(_ message:{{ method|input }}, errorHandler:@escaping (Error)->()) throws {
     let messageData = try message.serializedData()
     try call.sendMessage(data:messageData, errorHandler:errorHandler)
   }
 
   /// Call this to close the connection and wait for a response. Blocking.
-  public func closeAndReceive() throws -> {{ method|output }} {
+  {{ access }} func closeAndReceive() throws -> {{ method|output }} {
     var returnError : {{ .|clienterror:file,service }}?
     var returnResponse : {{ method|output }}!
     let sem = DispatchSemaphore(value: 0)
@@ -42,7 +42,7 @@ public class {{ .|call:file,service,method }} {
   }
 
   /// Call this to close the connection and wait for a response. Nonblocking.
-  public func closeAndReceive(completion:@escaping ({{ method|output }}?, {{ .|clienterror:file,service }}?)->())
+  {{ access }} func closeAndReceive(completion:@escaping ({{ method|output }}?, {{ .|clienterror:file,service }}?)->())
     throws {
       do {
         try call.receiveMessage() {(responseData) in

+ 3 - 3
Plugin/Templates/client-call-serverstreaming.swift

@@ -1,5 +1,5 @@
 /// {{ method.name }} (Server Streaming)
-public class {{ .|call:file,service,method }} {
+{{ access }} class {{ .|call:file,service,method }} {
   private var call : Call
 
   /// Create a call.
@@ -21,7 +21,7 @@ public class {{ .|call:file,service,method }} {
   }
 
   /// Call this to wait for a result. Blocking.
-  public func receive() throws -> {{ method|output }} {
+  {{ access }} func receive() throws -> {{ method|output }} {
     var returnError : {{ .|clienterror:file,service }}?
     var returnResponse : {{ method|output }}!
     let sem = DispatchSemaphore(value: 0)
@@ -40,7 +40,7 @@ public class {{ .|call:file,service,method }} {
   }
 
   /// Call this to wait for a result. Nonblocking.
-  public func receive(completion:@escaping ({{ method|output }}?, {{ .|clienterror:file,service }}?)->()) throws {
+  {{ access }} func receive(completion:@escaping ({{ method|output }}?, {{ .|clienterror:file,service }}?)->()) throws {
     do {
       try call.receiveMessage() {(responseData) in
         if let responseData = responseData {

+ 1 - 1
Plugin/Templates/client-call-unary.swift

@@ -1,5 +1,5 @@
 /// {{ method.name }} (Unary)
-public class {{ .|call:file,service,method }} {
+{{ access }} class {{ .|call:file,service,method }} {
   private var call : Call
 
   /// Create a call.

+ 11 - 11
Plugin/Templates/client.pb.swift

@@ -45,7 +45,7 @@ import gRPC
 //-{% for service in file.service %}
 
 /// Type for errors thrown from generated client code.
-public enum {{ .|clienterror:file,service }} : Error {
+{{ access }} enum {{ .|clienterror:file,service }} : Error {
   case endOfStream
   case invalidMessageReceived
   case error(c: CallResult)
@@ -66,16 +66,16 @@ public enum {{ .|clienterror:file,service }} : Error {
 //-{% endif %}
 //-{% endfor %}
 /// Call methods of this class to make API calls.
-public class {{ .|serviceclass:file,service }} {
+{{ access }} class {{ .|serviceclass:file,service }} {
   private var channel: Channel
 
   /// This metadata will be sent with all requests.
-  public var metadata : Metadata
+  {{ access }} var metadata : Metadata
 
   /// This property allows the service host name to be overridden.
   /// For example, it can be used to make calls to "localhost:8080"
   /// appear to be to "example.com".
-  public var host : String {
+  {{ access }} var host : String {
     get {
       return self.channel.host
     }
@@ -85,14 +85,14 @@ public class {{ .|serviceclass:file,service }} {
   }
 
   /// Create a client that makes insecure connections.
-  public init(address: String) {
+  {{ access }} init(address: String) {
     gRPC.initialize()
     channel = Channel(address:address)
     metadata = Metadata()
   }
 
   /// Create a client that makes secure connections.
-  public init(address: String, certificates: String?, host: String?) {
+  {{ access }} init(address: String, certificates: String?, host: String?) {
     gRPC.initialize()
     channel = Channel(address:address, certificates:certificates, host:host)
     metadata = Metadata()
@@ -101,13 +101,13 @@ public class {{ .|serviceclass:file,service }} {
   //-{% for method in service.method %}
   //-{% if not method.clientStreaming and not method.serverStreaming %}
   /// Synchronous. Unary.
-  public func {{ method.name|lowercase }}(_ request: {{ method|input }})
+  {{ access }} func {{ method.name|lowercase }}(_ request: {{ method|input }})
     throws
     -> {{ method|output }} {
       return try {{ .|call:file,service,method }}(channel).run(request:request, metadata:metadata)
   }
   /// Asynchronous. Unary.
-  public func {{ method.name|lowercase }}(_ request: {{ method|input }},
+  {{ access }} func {{ method.name|lowercase }}(_ request: {{ method|input }},
                   completion: @escaping ({{ method|output }}?, CallResult)->())
     throws
     -> {{ .|call:file,service,method }} {
@@ -120,7 +120,7 @@ public class {{ .|serviceclass:file,service }} {
   /// Asynchronous. Server-streaming.
   /// Send the initial message.
   /// Use methods on the returned object to get streamed responses.
-  public func {{ method.name|lowercase }}(_ request: {{ method|input }}, completion: @escaping (CallResult)->())
+  {{ access }} func {{ method.name|lowercase }}(_ request: {{ method|input }}, completion: @escaping (CallResult)->())
     throws
     -> {{ .|call:file,service,method }} {
       return try {{ .|call:file,service,method }}(channel).start(request:request, metadata:metadata, completion:completion)
@@ -130,7 +130,7 @@ public class {{ .|serviceclass:file,service }} {
   /// Asynchronous. Client-streaming.
   /// Use methods on the returned object to stream messages and
   /// to close the connection and wait for a final response.
-  public func {{ method.name|lowercase }}(completion: @escaping (CallResult)->())
+  {{ access }} func {{ method.name|lowercase }}(completion: @escaping (CallResult)->())
     throws
     -> {{ .|call:file,service,method }} {
       return try {{ .|call:file,service,method }}(channel).start(metadata:metadata, completion:completion)
@@ -140,7 +140,7 @@ public class {{ .|serviceclass:file,service }} {
   /// Asynchronous. Bidirectional-streaming.
   /// Use methods on the returned object to stream messages,
   /// to wait for replies, and to close the connection.
-  public func {{ method.name|lowercase }}(completion: @escaping (CallResult)->())
+  {{ access }} func {{ method.name|lowercase }}(completion: @escaping (CallResult)->())
     throws
     -> {{ .|call:file,service,method }} {
       return try {{ .|call:file,service,method }}(channel).start(metadata:metadata, completion:completion)

+ 4 - 4
Plugin/Templates/server-session-bidistreaming.swift

@@ -1,5 +1,5 @@
 // {{ method.name }} (Bidirectional Streaming)
-public class {{ .|session:file,service,method }} : {{ .|service:file,service }}Session {
+{{ access }} class {{ .|session:file,service,method }} : {{ .|service:file,service }}Session {
   private var provider : {{ .|provider:file,service }}
 
   /// Create a session.
@@ -9,7 +9,7 @@ public class {{ .|session:file,service,method }} : {{ .|service:file,service }}S
   }
 
   /// Receive a message. Blocks until a message is received or the client closes the connection.
-  public func receive() throws -> {{ method|input }} {
+  {{ access }} func receive() throws -> {{ method|input }} {
     let sem = DispatchSemaphore(value: 0)
     var requestMessage : {{ method|input }}?
     try self.handler.receiveMessage() {(requestData) in
@@ -31,12 +31,12 @@ public class {{ .|session:file,service,method }} : {{ .|service:file,service }}S
   }
 
   /// Send a message. Nonblocking.
-  public func send(_ response: {{ method|output }}) throws {
+  {{ access }} func send(_ response: {{ method|output }}) throws {
     try handler.sendResponse(message:response.serializedData()) {}
   }
 
   /// Close a connection. Blocks until the connection is closed.
-  public func close() throws {
+  {{ access }} func close() throws {
     let sem = DispatchSemaphore(value: 0)
     try self.handler.sendStatus(statusCode:self.statusCode,
                                 statusMessage:self.statusMessage,

+ 3 - 3
Plugin/Templates/server-session-clientstreaming.swift

@@ -1,5 +1,5 @@
 // {{ method.name }} (Client Streaming)
-public class {{ .|session:file,service,method }} : {{ .|service:file,service }}Session {
+{{ access }} class {{ .|session:file,service,method }} : {{ .|service:file,service }}Session {
   private var provider : {{ .|provider:file,service }}
 
   /// Create a session.
@@ -9,7 +9,7 @@ public class {{ .|session:file,service,method }} : {{ .|service:file,service }}S
   }
 
   /// Receive a message. Blocks until a message is received or the client closes the connection.
-  public func receive() throws -> {{ method|input }} {
+  {{ access }} func receive() throws -> {{ method|input }} {
     let sem = DispatchSemaphore(value: 0)
     var requestMessage : {{ method|input }}?
     try self.handler.receiveMessage() {(requestData) in
@@ -26,7 +26,7 @@ public class {{ .|session:file,service,method }} : {{ .|service:file,service }}S
   }
 
   /// Send a response and close the connection.
-  public func sendAndClose(_ response: {{ method|output }}) throws {
+  {{ access }} func sendAndClose(_ response: {{ method|output }}) throws {
     try self.handler.sendResponse(message:response.serializedData(),
                                   statusCode:self.statusCode,
                                   statusMessage:self.statusMessage,

+ 2 - 2
Plugin/Templates/server-session-serverstreaming.swift

@@ -1,5 +1,5 @@
 // {{ method.name }} (Server Streaming)
-public class {{ .|session:file,service,method }} : {{ .|service:file,service }}Session {
+{{ access }} class {{ .|session:file,service,method }} : {{ .|service:file,service }}Session {
   private var provider : {{ .|provider:file,service }}
 
   /// Create a session.
@@ -9,7 +9,7 @@ public class {{ .|session:file,service,method }} : {{ .|service:file,service }}S
   }
 
   /// Send a message. Nonblocking.
-  public func send(_ response: {{ method|output }}) throws {
+  {{ access }} func send(_ response: {{ method|output }}) throws {
     try handler.sendResponse(message:response.serializedData()) {}
   }
 

+ 1 - 1
Plugin/Templates/server-session-unary.swift

@@ -1,5 +1,5 @@
 // {{ method.name }} (Unary)
-public class {{ .|session:file,service,method }} : {{ .|service:file,service }}Session {
+{{ access }} class {{ .|session:file,service,method }} : {{ .|service:file,service }}Session {
   private var provider : {{ .|provider:file,service }}
 
   /// Create a session.

+ 12 - 12
Plugin/Templates/server.pb.swift

@@ -45,12 +45,12 @@ import gRPC
 //-{% for service in file.service %}
 
 /// Type for errors thrown from generated server code.
-public enum {{ .|servererror:file,service }} : Error {
+{{ access }} enum {{ .|servererror:file,service }} : Error {
   case endOfStream
 }
 
 /// To build a server, implement a class that conforms to this protocol.
-public protocol {{ .|provider:file,service }} {
+{{ access }} protocol {{ .|provider:file,service }} {
   //-{% for method in service.method %}
   //-{% if not method.clientStreaming and not method.serverStreaming %}
   func {{ method.name|lowercase }}(request : {{ method|input }}, session : {{ .|session:file,service,method }}) throws -> {{ method|output }}
@@ -68,14 +68,14 @@ public protocol {{ .|provider:file,service }} {
 }
 
 /// Common properties available in each service session.
-public class {{ .|service:file,service }}Session {
+{{ access }} class {{ .|service:file,service }}Session {
   fileprivate var handler : gRPC.Handler
-  public var requestMetadata : Metadata { return handler.requestMetadata }
+  {{ access }} var requestMetadata : Metadata { return handler.requestMetadata }
 
-  public var statusCode : Int = 0
-  public var statusMessage : String = "OK"
-  public var initialMetadata : Metadata = Metadata()
-  public var trailingMetadata : Metadata = Metadata()
+  {{ access }} var statusCode : Int = 0
+  {{ access }} var statusMessage : String = "OK"
+  {{ access }} var initialMetadata : Metadata = Metadata()
+  {{ access }} var trailingMetadata : Metadata = Metadata()
 
   fileprivate init(handler:gRPC.Handler) {
     self.handler = handler
@@ -98,13 +98,13 @@ public class {{ .|service:file,service }}Session {
 //-{% endfor %}
 
 /// Main server for generated service
-public class {{ .|server:file,service }} {
+{{ access }} class {{ .|server:file,service }} {
   private var address: String
   private var server: gRPC.Server
   private var provider: {{ .|provider:file,service }}?
 
   /// Create a server that accepts insecure connections.
-  public init(address:String,
+  {{ access }} init(address:String,
               provider:{{ .|provider:file,service }}) {
     gRPC.initialize()
     self.address = address
@@ -113,7 +113,7 @@ public class {{ .|server:file,service }} {
   }
 
   /// Create a server that accepts secure connections.
-  public init?(address:String,
+  {{ access }} init?(address:String,
                certificateURL:URL,
                keyURL:URL,
                provider:{{ .|provider:file,service }}) {
@@ -130,7 +130,7 @@ public class {{ .|server:file,service }} {
   }
 
   /// Start the server.
-  public func start(queue:DispatchQueue = DispatchQueue.global()) {
+  {{ access }} func start(queue:DispatchQueue = DispatchQueue.global()) {
     guard let provider = self.provider else {
       assert(false) // the server requires a provider
     }

+ 0 - 24
README.md

@@ -61,21 +61,11 @@ search path. Invoke them with commands like the following:
 
     protoc <your proto files> \
         --swift_out=. \
-        --swift_opt=Visibility=Public \
-        --plugin=<path to protoc-gen-swift>`
-
-    protoc <your proto files> \
         --swiftgrpc_out=.
 
 By convention the `--swift_out` option invokes the `protoc-gen-swift`
 plugin and `--swiftgrpc_out` invokes `protoc-gen-swiftgrpc`.
 
-The `--swift_opt` flag passes an option to `protoc-gen-swift` that
-makes message classes public, which is necessary to use them with
-gRPC. The `--plugin` option is only needed by older versions of
-`protoc` that are unable to find the plugin binaries when options
-are specified.
-
 ### Building your project
 
 Most `grpc-swift` development is done with the Swift Package Manager.
@@ -124,20 +114,6 @@ testing with the following versions:
 - Swift 3.1 (swiftlang-802.0.53 clang-802.0.42)
 - swift-protobuf 0.9.901 
 
-Also, please note that recent changes to swift-proto cause generated structs
-to have the "internal" access level. To allow them to be used in the
-public interfaces generated by the grpc-swift plugin, please generate 
-your proto structs with the following protoc options:
-
-	protoc <your proto files> \
-    	--swift_out=. \
-    	--swift_opt=Visibility=Public \
-    	--plugin=<path to protoc-gen-swift>`
-
-More details on the `Visibility` option are [here](https://github.com/apple/swift-protobuf/blob/master/Documentation/PLUGIN.md#generation-option-visibility---visibility-of-generated-types).
-Due to limitations in `protoc`, the `--plugin` option must be used to 
-specify the path to `protoc-gen-swift` whever the `--swift_opt` flag is used.
-
 ## License
 
 grpc-swift is released under the same license as 

Some files were not shown because too many files changed in this diff