Skip to content
Open
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
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.0
6.4.0
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ docs/_site
.bazel/
bazel-out/
bazel-out
.vscode
8 changes: 7 additions & 1 deletion Examples/Cocoa/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ import PackageDescription

let package = Package(
name: "Objective_C",
dependencies: [
.package(path: "../MyCustomPackage")
],
targets: [
.target(name: "Objective_C"),
.target(
name: "Objective_C",
dependencies: ["MyCustomPackage"]
),
.testTarget(name: "Objective_CTests", dependencies: ["Objective_C"]),
]
)
6 changes: 3 additions & 3 deletions Examples/Cocoa/Sources/Objective_C/Board.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ - (instancetype)initWithModelDictionary:(NS_VALID_UNTIL_END_OF_SCOPE NSDictionar
self->_boardDirtyProperties.BoardDirtyPropertyContributors = 1;
if (value != (id)kCFNull) {
if (!error || [value isKindOfClass:[NSArray class]]) {
NSArray *items = value;
NSMutableSet *result0 = [NSMutableSet setWithCapacity:items.count];
for (id obj0 in items) {
NSArray *items0 = value;
NSMutableSet *result0 = [NSMutableSet setWithCapacity:items0.count];
for (id obj0 in items0) {
if (obj0 != (id)kCFNull) {
id tmp0 = nil;
if (!error || [obj0 isKindOfClass:[NSDictionary class]]) {
Expand Down
285 changes: 285 additions & 0 deletions Examples/Cocoa/Sources/Objective_C/Decorated.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,285 @@
//
// Decorated.m
// Autogenerated by Plank (https://pinterest.github.io/plank/)
//
// DO NOT EDIT - EDITS WILL BE OVERWRITTEN
// @generated
//

#import "Decorated.h"

@import MyCustomPackage;

struct DecoratedDirtyProperties {
unsigned int DecoratedDirtyPropertyExternalType:1;
unsigned int DecoratedDirtyPropertyName:1;
};

@interface Decorated ()
@property (nonatomic, assign, readwrite) struct DecoratedDirtyProperties decoratedDirtyProperties;
@end

@interface DecoratedBuilder ()
@property (nonatomic, assign, readwrite) struct DecoratedDirtyProperties decoratedDirtyProperties;
@end

@implementation Decorated
+ (NSString *)className
{
return @"Decorated";
}
+ (NSString *)polymorphicTypeIdentifier
{
return @"decorated";
}
+ (instancetype)modelObjectWithDictionary:(NSDictionary *)dictionary
{
return [[self alloc] initWithModelDictionary:dictionary];
}
+ (instancetype)modelObjectWithDictionary:(NSDictionary *)dictionary error:(NSError *__autoreleasing *)error
{
return [[self alloc] initWithModelDictionary:dictionary error:error];
}
- (instancetype)init
{
return [self initWithModelDictionary:@{} error:NULL];
}
- (instancetype)initWithModelDictionary:(NSDictionary *)modelDictionary
{
return [self initWithModelDictionary:modelDictionary error:NULL];
}
- (instancetype)initWithModelDictionary:(NS_VALID_UNTIL_END_OF_SCOPE NSDictionary *)modelDictionary error:(NSError *__autoreleasing *)error
{
NSParameterAssert(modelDictionary);
NSParameterAssert([modelDictionary isKindOfClass:[NSDictionary class]]);
if (!(self = [super init])) {
return self;
}
if (!modelDictionary) {
return self;
}
{
__unsafe_unretained id value = modelDictionary[@"externalType"];
if (value != nil) {
self->_decoratedDirtyProperties.DecoratedDirtyPropertyExternalType = 1;
if (value != (id)kCFNull) {
if (!error || [value isKindOfClass:[NSDictionary class]]) {
self->_externalType = [MyCustomClass modelObjectWithDictionary:value error:error];
} else {
self->_decoratedDirtyProperties.DecoratedDirtyPropertyExternalType = 0;
*error = PlankTypeError(@"externalType", [NSDictionary class], [value class]);
}
}
}
}
{
__unsafe_unretained id value = modelDictionary[@"name"];
if (value != nil) {
self->_decoratedDirtyProperties.DecoratedDirtyPropertyName = 1;
if (value != (id)kCFNull) {
if (!error || [value isKindOfClass:[NSString class]]) {
self->_name = [value copy];
} else {
self->_decoratedDirtyProperties.DecoratedDirtyPropertyName = 0;
*error = PlankTypeError(@"name", [NSString class], [value class]);
}
}
}
}
if ([self class] == [Decorated class]) {
[[NSNotificationCenter defaultCenter] postNotificationName:kPlankDidInitializeNotification object:self userInfo:@{ kPlankInitTypeKey : @(PlankModelInitTypeDefault) }];
}
return self;
}
- (instancetype)initWithBuilder:(DecoratedBuilder *)builder
{
NSParameterAssert(builder);
return [self initWithBuilder:builder initType:PlankModelInitTypeDefault];
}
- (instancetype)initWithBuilder:(DecoratedBuilder *)builder initType:(PlankModelInitType)initType
{
NSParameterAssert(builder);
if (!(self = [super init])) {
return self;
}
_externalType = builder.externalType;
_name = builder.name;
_decoratedDirtyProperties = builder.decoratedDirtyProperties;
if ([self class] == [Decorated class]) {
[[NSNotificationCenter defaultCenter] postNotificationName:kPlankDidInitializeNotification object:self userInfo:@{ kPlankInitTypeKey : @(initType) }];
}
return self;
}
#if DEBUG
- (NSString *)debugDescription
{
NSArray<NSString *> *parentDebugDescription = [[super debugDescription] componentsSeparatedByString:@"\n"];
NSMutableArray *descriptionFields = [NSMutableArray arrayWithCapacity:2];
[descriptionFields addObject:parentDebugDescription];
struct DecoratedDirtyProperties props = _decoratedDirtyProperties;
if (props.DecoratedDirtyPropertyExternalType) {
[descriptionFields addObject:[NSString stringWithFormat:@"_externalType = %@", _externalType]];
}
if (props.DecoratedDirtyPropertyName) {
[descriptionFields addObject:[NSString stringWithFormat:@"_name = %@", _name]];
}
return [NSString stringWithFormat:@"Decorated = {\n%@\n}", debugDescriptionForFields(descriptionFields)];
}
#endif
- (instancetype)copyWithBlock:(PLANK_NOESCAPE void (^)(DecoratedBuilder *builder))block
{
NSParameterAssert(block);
DecoratedBuilder *builder = [[DecoratedBuilder alloc] initWithModel:self];
block(builder);
return [builder build];
}
- (BOOL)isEqual:(id)anObject
{
if (self == anObject) {
return YES;
}
if ([anObject isKindOfClass:[Decorated class]] == NO) {
return NO;
}
return [self isEqualToDecorated:anObject];
}
- (BOOL)isEqualToDecorated:(Decorated *)anObject
{
return (
(anObject != nil) &&
(_externalType == anObject.externalType || [_externalType isEqual:anObject.externalType]) &&
(_name == anObject.name || [_name isEqualToString:anObject.name])
);
}
- (NSUInteger)hash
{
NSUInteger subhashes[] = {
17,
[_externalType hash],
[_name hash]
};
return PINIntegerArrayHash(subhashes, sizeof(subhashes) / sizeof(subhashes[0]));
}
- (instancetype)mergeWithModel:(Decorated *)modelObject
{
return [self mergeWithModel:modelObject initType:PlankModelInitTypeFromMerge];
}
- (instancetype)mergeWithModel:(Decorated *)modelObject initType:(PlankModelInitType)initType
{
NSParameterAssert(modelObject);
DecoratedBuilder *builder = [[DecoratedBuilder alloc] initWithModel:self];
[builder mergeWithModel:modelObject];
return [[Decorated alloc] initWithBuilder:builder initType:initType];
}
- (NSDictionary *)dictionaryObjectRepresentation
{
NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithCapacity:2];
if (_decoratedDirtyProperties.DecoratedDirtyPropertyExternalType) {
if (_externalType != nil) {
[dict setObject:[_externalType dictionaryObjectRepresentation] forKey:@"externalType"];
} else {
[dict setObject:[NSNull null] forKey:@"externalType"];
}
}
if (_decoratedDirtyProperties.DecoratedDirtyPropertyName) {
if (_name != nil) {
[dict setObject:_name forKey:@"name"];
} else {
[dict setObject:[NSNull null] forKey:@"name"];
}
}
return dict;
}
- (BOOL)isExternalTypeSet
{
return _decoratedDirtyProperties.DecoratedDirtyPropertyExternalType == 1;
}
- (BOOL)isNameSet
{
return _decoratedDirtyProperties.DecoratedDirtyPropertyName == 1;
}
#pragma mark - NSCopying
- (id)copyWithZone:(NSZone *)zone
{
return self;
}
#pragma mark - NSSecureCoding
+ (BOOL)supportsSecureCoding
{
return YES;
}
- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
if (!(self = [super init])) {
return self;
}
_externalType = [aDecoder decodeObjectOfClass:[MyCustomClass class] forKey:@"externalType"];
_name = [aDecoder decodeObjectOfClass:[NSString class] forKey:@"name"];
_decoratedDirtyProperties.DecoratedDirtyPropertyExternalType = [aDecoder decodeIntForKey:@"externalType_dirty_property"] & 0x1;
_decoratedDirtyProperties.DecoratedDirtyPropertyName = [aDecoder decodeIntForKey:@"name_dirty_property"] & 0x1;
if ([self class] == [Decorated class]) {
[[NSNotificationCenter defaultCenter] postNotificationName:kPlankDidInitializeNotification object:self userInfo:@{ kPlankInitTypeKey : @(PlankModelInitTypeDefault) }];
}
return self;
}
- (void)encodeWithCoder:(NSCoder *)aCoder
{
[aCoder encodeObject:self.externalType forKey:@"externalType"];
[aCoder encodeObject:self.name forKey:@"name"];
[aCoder encodeInt:_decoratedDirtyProperties.DecoratedDirtyPropertyExternalType forKey:@"externalType_dirty_property"];
[aCoder encodeInt:_decoratedDirtyProperties.DecoratedDirtyPropertyName forKey:@"name_dirty_property"];
}
@end

@implementation DecoratedBuilder
- (instancetype)initWithModel:(Decorated *)modelObject
{
NSParameterAssert(modelObject);
if (!(self = [super init])) {
return self;
}
struct DecoratedDirtyProperties decoratedDirtyProperties = modelObject.decoratedDirtyProperties;
if (decoratedDirtyProperties.DecoratedDirtyPropertyExternalType) {
_externalType = modelObject.externalType;
}
if (decoratedDirtyProperties.DecoratedDirtyPropertyName) {
_name = modelObject.name;
}
_decoratedDirtyProperties = decoratedDirtyProperties;
return self;
}
- (Decorated *)build
{
return [[Decorated alloc] initWithBuilder:self];
}
- (void)mergeWithModel:(Decorated *)modelObject
{
NSParameterAssert(modelObject);
DecoratedBuilder *builder = self;
if (modelObject.decoratedDirtyProperties.DecoratedDirtyPropertyExternalType) {
id value = modelObject.externalType;
if (value != nil) {
if (builder.externalType) {
builder.externalType = [builder.externalType mergeWithModel:value initType:PlankModelInitTypeFromSubmerge];
} else {
builder.externalType = value;
}
} else {
builder.externalType = nil;
}
}
if (modelObject.decoratedDirtyProperties.DecoratedDirtyPropertyName) {
builder.name = modelObject.name;
}
}
- (void)setExternalType:(MyCustomClass *)externalType
{
_externalType = externalType;
_decoratedDirtyProperties.DecoratedDirtyPropertyExternalType = 1;
}
- (void)setName:(NSString *)name
{
_name = [name copy];
_decoratedDirtyProperties.DecoratedDirtyPropertyName = 1;
}
@end
Loading