// Generated by the protocol buffer compiler.  DO NOT EDIT!
// clang-format off
// source: google/protobuf/api.proto

#import "GPBProtocolBuffers_RuntimeSupport.h"
#import "GPBApi.pbobjc.h"

#if GOOGLE_PROTOBUF_OBJC_VERSION < 30007
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
#if 30007 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
#endif

// @@protoc_insertion_point(imports)

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#pragma clang diagnostic ignored "-Wdollar-in-identifier-extension"

#pragma mark - Objective-C Class declarations
// Forward declarations of Objective-C classes that we can use as
// static values in struct initializers.
// We don't use [Foo class] because it is not a static value.
GPBObjCClassDeclaration(GPBApi);
GPBObjCClassDeclaration(GPBMethod);
GPBObjCClassDeclaration(GPBMixin);
GPBObjCClassDeclaration(GPBOption);
GPBObjCClassDeclaration(GPBSourceContext);

#pragma mark - GPBApiRoot

@implementation GPBApiRoot

// No extensions in the file and no imports or none of the imports (direct or
// indirect) defined extensions, so no need to generate +extensionRegistry.

@end

static GPBFileDescription GPBApiRoot_FileDescription = {
  .package = "google.protobuf",
  .prefix = "GPB",
  .syntax = GPBFileSyntaxProto3
};

#pragma mark - GPBApi

@implementation GPBApi

@dynamic name;
@dynamic methodsArray, methodsArray_Count;
@dynamic optionsArray, optionsArray_Count;
@dynamic version;
@dynamic hasSourceContext, sourceContext;
@dynamic mixinsArray, mixinsArray_Count;
@dynamic syntax;

typedef struct GPBApi__storage_ {
  uint32_t _has_storage_[1];
  GPBSyntax syntax;
  NSString *name;
  NSMutableArray *methodsArray;
  NSMutableArray *optionsArray;
  NSString *version;
  GPBSourceContext *sourceContext;
  NSMutableArray *mixinsArray;
} GPBApi__storage_;

// This method is threadsafe because it is initially called
// in +initialize for each subclass.
+ (GPBDescriptor *)descriptor {
  static GPBDescriptor *descriptor = nil;
  if (!descriptor) {
    GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
    static GPBMessageFieldDescription fields[] = {
      {
        .name = "name",
        .dataTypeSpecific.clazz = Nil,
        .number = GPBApi_FieldNumber_Name,
        .hasIndex = 0,
        .offset = (uint32_t)offsetof(GPBApi__storage_, name),
        .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
        .dataType = GPBDataTypeString,
      },
      {
        .name = "methodsArray",
        .dataTypeSpecific.clazz = GPBObjCClass(GPBMethod),
        .number = GPBApi_FieldNumber_MethodsArray,
        .hasIndex = GPBNoHasBit,
        .offset = (uint32_t)offsetof(GPBApi__storage_, methodsArray),
        .flags = GPBFieldRepeated,
        .dataType = GPBDataTypeMessage,
      },
      {
        .name = "optionsArray",
        .dataTypeSpecific.clazz = GPBObjCClass(GPBOption),
        .number = GPBApi_FieldNumber_OptionsArray,
        .hasIndex = GPBNoHasBit,
        .offset = (uint32_t)offsetof(GPBApi__storage_, optionsArray),
        .flags = GPBFieldRepeated,
        .dataType = GPBDataTypeMessage,
      },
      {
        .name = "version",
        .dataTypeSpecific.clazz = Nil,
        .number = GPBApi_FieldNumber_Version,
        .hasIndex = 1,
        .offset = (uint32_t)offsetof(GPBApi__storage_, version),
        .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
        .dataType = GPBDataTypeString,
      },
      {
        .name = "sourceContext",
        .dataTypeSpecific.clazz = GPBObjCClass(GPBSourceContext),
        .number = GPBApi_FieldNumber_SourceContext,
        .hasIndex = 2,
        .offset = (uint32_t)offsetof(GPBApi__storage_, sourceContext),
        .flags = GPBFieldOptional,
        .dataType = GPBDataTypeMessage,
      },
      {
        .name = "mixinsArray",
        .dataTypeSpecific.clazz = GPBObjCClass(GPBMixin),
        .number = GPBApi_FieldNumber_MixinsArray,
        .hasIndex = GPBNoHasBit,
        .offset = (uint32_t)offsetof(GPBApi__storage_, mixinsArray),
        .flags = GPBFieldRepeated,
        .dataType = GPBDataTypeMessage,
      },
      {
        .name = "syntax",
        .dataTypeSpecific.enumDescFunc = GPBSyntax_EnumDescriptor,
        .number = GPBApi_FieldNumber_Syntax,
        .hasIndex = 3,
        .offset = (uint32_t)offsetof(GPBApi__storage_, syntax),
        .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldHasEnumDescriptor | GPBFieldClearHasIvarOnZero),
        .dataType = GPBDataTypeEnum,
      },
    };
    GPBDescriptor *localDescriptor =
        [GPBDescriptor allocDescriptorForClass:GPBObjCClass(GPBApi)
                                   messageName:@"Api"
                               fileDescription:&GPBApiRoot_FileDescription
                                        fields:fields
                                    fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
                                   storageSize:sizeof(GPBApi__storage_)
                                         flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)];
    #if defined(DEBUG) && DEBUG
      NSAssert(descriptor == nil, @"Startup recursed!");
    #endif  // DEBUG
    descriptor = localDescriptor;
  }
  return descriptor;
}

@end

int32_t GPBApi_Syntax_RawValue(GPBApi *message) {
  GPBDescriptor *descriptor = [GPBApi descriptor];
  GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBApi_FieldNumber_Syntax];
  return GPBGetMessageRawEnumField(message, field);
}

void SetGPBApi_Syntax_RawValue(GPBApi *message, int32_t value) {
  GPBDescriptor *descriptor = [GPBApi descriptor];
  GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBApi_FieldNumber_Syntax];
  GPBSetMessageRawEnumField(message, field, value);
}

#pragma mark - GPBMethod

@implementation GPBMethod

@dynamic name;
@dynamic requestTypeURL;
@dynamic requestStreaming;
@dynamic responseTypeURL;
@dynamic responseStreaming;
@dynamic optionsArray, optionsArray_Count;
@dynamic syntax;

typedef struct GPBMethod__storage_ {
  uint32_t _has_storage_[1];
  GPBSyntax syntax;
  NSString *name;
  NSString *requestTypeURL;
  NSString *responseTypeURL;
  NSMutableArray *optionsArray;
} GPBMethod__storage_;

// This method is threadsafe because it is initially called
// in +initialize for each subclass.
+ (GPBDescriptor *)descriptor {
  static GPBDescriptor *descriptor = nil;
  if (!descriptor) {
    GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
    static GPBMessageFieldDescription fields[] = {
      {
        .name = "name",
        .dataTypeSpecific.clazz = Nil,
        .number = GPBMethod_FieldNumber_Name,
        .hasIndex = 0,
        .offset = (uint32_t)offsetof(GPBMethod__storage_, name),
        .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
        .dataType = GPBDataTypeString,
      },
      {
        .name = "requestTypeURL",
        .dataTypeSpecific.clazz = Nil,
        .number = GPBMethod_FieldNumber_RequestTypeURL,
        .hasIndex = 1,
        .offset = (uint32_t)offsetof(GPBMethod__storage_, requestTypeURL),
        .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero),
        .dataType = GPBDataTypeString,
      },
      {
        .name = "requestStreaming",
        .dataTypeSpecific.clazz = Nil,
        .number = GPBMethod_FieldNumber_RequestStreaming,
        .hasIndex = 2,
        .offset = 3,  // Stored in _has_storage_ to save space.
        .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
        .dataType = GPBDataTypeBool,
      },
      {
        .name = "responseTypeURL",
        .dataTypeSpecific.clazz = Nil,
        .number = GPBMethod_FieldNumber_ResponseTypeURL,
        .hasIndex = 4,
        .offset = (uint32_t)offsetof(GPBMethod__storage_, responseTypeURL),
        .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero),
        .dataType = GPBDataTypeString,
      },
      {
        .name = "responseStreaming",
        .dataTypeSpecific.clazz = Nil,
        .number = GPBMethod_FieldNumber_ResponseStreaming,
        .hasIndex = 5,
        .offset = 6,  // Stored in _has_storage_ to save space.
        .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
        .dataType = GPBDataTypeBool,
      },
      {
        .name = "optionsArray",
        .dataTypeSpecific.clazz = GPBObjCClass(GPBOption),
        .number = GPBMethod_FieldNumber_OptionsArray,
        .hasIndex = GPBNoHasBit,
        .offset = (uint32_t)offsetof(GPBMethod__storage_, optionsArray),
        .flags = GPBFieldRepeated,
        .dataType = GPBDataTypeMessage,
      },
      {
        .name = "syntax",
        .dataTypeSpecific.enumDescFunc = GPBSyntax_EnumDescriptor,
        .number = GPBMethod_FieldNumber_Syntax,
        .hasIndex = 7,
        .offset = (uint32_t)offsetof(GPBMethod__storage_, syntax),
        .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldHasEnumDescriptor | GPBFieldClearHasIvarOnZero),
        .dataType = GPBDataTypeEnum,
      },
    };
    GPBDescriptor *localDescriptor =
        [GPBDescriptor allocDescriptorForClass:GPBObjCClass(GPBMethod)
                                   messageName:@"Method"
                               fileDescription:&GPBApiRoot_FileDescription
                                        fields:fields
                                    fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
                                   storageSize:sizeof(GPBMethod__storage_)
                                         flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)];
    #if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS
      static const char *extraTextFormatInfo =
        "\002\002\007\244\241!!\000\004\010\244\241!!\000";
      [localDescriptor setupExtraTextInfo:extraTextFormatInfo];
    #endif  // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS
    #if defined(DEBUG) && DEBUG
      NSAssert(descriptor == nil, @"Startup recursed!");
    #endif  // DEBUG
    descriptor = localDescriptor;
  }
  return descriptor;
}

@end

int32_t GPBMethod_Syntax_RawValue(GPBMethod *message) {
  GPBDescriptor *descriptor = [GPBMethod descriptor];
  GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBMethod_FieldNumber_Syntax];
  return GPBGetMessageRawEnumField(message, field);
}

void SetGPBMethod_Syntax_RawValue(GPBMethod *message, int32_t value) {
  GPBDescriptor *descriptor = [GPBMethod descriptor];
  GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBMethod_FieldNumber_Syntax];
  GPBSetMessageRawEnumField(message, field, value);
}

#pragma mark - GPBMixin

@implementation GPBMixin

@dynamic name;
@dynamic root;

typedef struct GPBMixin__storage_ {
  uint32_t _has_storage_[1];
  NSString *name;
  NSString *root;
} GPBMixin__storage_;

// This method is threadsafe because it is initially called
// in +initialize for each subclass.
+ (GPBDescriptor *)descriptor {
  static GPBDescriptor *descriptor = nil;
  if (!descriptor) {
    GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
    static GPBMessageFieldDescription fields[] = {
      {
        .name = "name",
        .dataTypeSpecific.clazz = Nil,
        .number = GPBMixin_FieldNumber_Name,
        .hasIndex = 0,
        .offset = (uint32_t)offsetof(GPBMixin__storage_, name),
        .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
        .dataType = GPBDataTypeString,
      },
      {
        .name = "root",
        .dataTypeSpecific.clazz = Nil,
        .number = GPBMixin_FieldNumber_Root,
        .hasIndex = 1,
        .offset = (uint32_t)offsetof(GPBMixin__storage_, root),
        .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
        .dataType = GPBDataTypeString,
      },
    };
    GPBDescriptor *localDescriptor =
        [GPBDescriptor allocDescriptorForClass:GPBObjCClass(GPBMixin)
                                   messageName:@"Mixin"
                               fileDescription:&GPBApiRoot_FileDescription
                                        fields:fields
                                    fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
                                   storageSize:sizeof(GPBMixin__storage_)
                                         flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)];
    #if defined(DEBUG) && DEBUG
      NSAssert(descriptor == nil, @"Startup recursed!");
    #endif  // DEBUG
    descriptor = localDescriptor;
  }
  return descriptor;
}

@end


#pragma clang diagnostic pop

// @@protoc_insertion_point(global_scope)

// clang-format on
