Skip to content

Commit

Permalink
[ObjC] Stop tracking the syntax within GPBFileDescriptor.
Browse files Browse the repository at this point in the history
There is no longer any public api to access it, so stop tracking it.

PiperOrigin-RevId: 684835061
  • Loading branch information
thomasvl authored and copybara-github committed Oct 11, 2024
1 parent b751b81 commit f64d63c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
23 changes: 10 additions & 13 deletions objectivec/GPBDescriptor.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
#import "GPBUtilities_PackagePrivate.h"
#import "GPBWireFormat.h"

@interface GPBFileDescriptor ()
- (instancetype)initWithPackage:(NSString *)package objcPrefix:(NSString *)objcPrefix;
- (instancetype)initWithPackage:(NSString *)package;
@end

@interface GPBDescriptor ()
- (instancetype)initWithClass:(Class)messageClass
messageName:(NSString *)messageName
Expand Down Expand Up @@ -243,12 +248,10 @@ - (GPBFileDescriptor *)file {
NSString *package = fileDescription_->package ? @(fileDescription_->package) : @"";
if (fileDescription_->prefix) {
result = [[GPBFileDescriptor alloc] initWithPackage:package
objcPrefix:@(fileDescription_->prefix)
syntax:fileDescription_->syntax];
objcPrefix:@(fileDescription_->prefix)];

} else {
result = [[GPBFileDescriptor alloc] initWithPackage:package
syntax:fileDescription_->syntax];
result = [[GPBFileDescriptor alloc] initWithPackage:package];
}
objc_setAssociatedObject(result, &kFileDescriptorCacheKey, result,
OBJC_ASSOCIATION_RETAIN_NONATOMIC);
Expand Down Expand Up @@ -312,29 +315,24 @@ - (GPBOneofDescriptor *)oneofWithName:(NSString *)name {
@implementation GPBFileDescriptor {
NSString *package_;
NSString *objcPrefix_;
GPBFileSyntax syntax_;
}

@synthesize package = package_;
@synthesize objcPrefix = objcPrefix_;

- (instancetype)initWithPackage:(NSString *)package
objcPrefix:(NSString *)objcPrefix
syntax:(GPBFileSyntax)syntax {
- (instancetype)initWithPackage:(NSString *)package objcPrefix:(NSString *)objcPrefix {
self = [super init];
if (self) {
package_ = [package copy];
objcPrefix_ = [objcPrefix copy];
syntax_ = syntax;
}
return self;
}

- (instancetype)initWithPackage:(NSString *)package syntax:(GPBFileSyntax)syntax {
- (instancetype)initWithPackage:(NSString *)package {
self = [super init];
if (self) {
package_ = [package copy];
syntax_ = syntax;
}
return self;
}
Expand All @@ -354,7 +352,7 @@ - (BOOL)isEqual:(id)other {
}
GPBFileDescriptor *otherFile = other;
// objcPrefix can be nil, otherwise, straight up compare.
return (syntax_ == otherFile->syntax_ && [package_ isEqual:otherFile->package_] &&
return ([package_ isEqual:otherFile->package_] &&
(objcPrefix_ == otherFile->objcPrefix_ ||
(otherFile->objcPrefix_ && [objcPrefix_ isEqual:otherFile->objcPrefix_])));
}
Expand Down Expand Up @@ -488,7 +486,6 @@ - (instancetype)initWithFieldDescription:(void *)description
#endif // DEBUG
}

// Non map<>/repeated fields can have defaults in proto2 syntax.
BOOL isMapOrArray = GPBFieldIsMapOrArray(self);
if (!isMapOrArray && includesDefault) {
defaultValue_ = ((GPBMessageFieldDescriptionWithDefault *)description)->defaultValue;
Expand Down
7 changes: 0 additions & 7 deletions objectivec/GPBDescriptor_PackagePrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,6 @@ typedef NS_OPTIONS(uint32_t, GPBDescriptorInitializationFlags) {

@end

@interface GPBFileDescriptor ()
- (instancetype)initWithPackage:(NSString *)package
objcPrefix:(NSString *)objcPrefix
syntax:(GPBFileSyntax)syntax;
- (instancetype)initWithPackage:(NSString *)package syntax:(GPBFileSyntax)syntax;
@end

@interface GPBOneofDescriptor () {
@package
const char *name_;
Expand Down

0 comments on commit f64d63c

Please sign in to comment.