models.swift 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright 2017, gRPC Authors All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. import Foundation
  17. import SwiftProtobuf
  18. import SwiftProtobufPluginLibrary
  19. import Stencil
  20. import PathKit
  21. struct FileDescriptor {
  22. var name : String
  23. var package : String
  24. var service: [ServiceDescriptor] = []
  25. init(proto: Google_Protobuf_FileDescriptorProto) {
  26. name = proto.name
  27. package = proto.package
  28. for service in proto.service {
  29. self.service.append(ServiceDescriptor(proto:service))
  30. }
  31. }
  32. }
  33. struct ServiceDescriptor {
  34. var name : String
  35. var method : [MethodDescriptor] = []
  36. init(proto: Google_Protobuf_ServiceDescriptorProto) {
  37. name = proto.name
  38. for method in proto.method {
  39. self.method.append(MethodDescriptor(proto:method))
  40. }
  41. }
  42. }
  43. struct MethodDescriptor {
  44. var name : String
  45. var inputType : String
  46. var outputType : String
  47. var clientStreaming : Bool
  48. var serverStreaming : Bool
  49. init(proto: Google_Protobuf_MethodDescriptorProto) {
  50. name = proto.name
  51. inputType = proto.inputType
  52. outputType = proto.outputType
  53. clientStreaming = proto.clientStreaming
  54. serverStreaming = proto.serverStreaming
  55. }
  56. }