Skip to content

Commit

Permalink
The full interface of ISSPropertyDefinition is now exposed in ISSProp…
Browse files Browse the repository at this point in the history
…ertyDefinition.h (removed ISSPropertyDefinition+Private.h). Added method to register a ISSPropertyDefinition directly to ISSPropertyRegistry.
  • Loading branch information
tolo committed Nov 14, 2014
1 parent 1b69da4 commit 0162ed5
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 40 deletions.
4 changes: 0 additions & 4 deletions InterfaCSS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
CC3C810682FFE4A76574711B /* ISSPropertyRegistry.m in Sources */ = {isa = PBXBuildFile; fileRef = CC3C82B417030D3C0260D40E /* ISSPropertyRegistry.m */; };
CC3C81248BA91E147E8A0ACC /* Parcoa+ISSAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = CC3C87B7069CA9BDCD00825F /* Parcoa+ISSAdditions.h */; };
CC3C81614BE09A047EFEB70D /* ISSRuntimeIntrospectionUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = CC3C88A5E82BB7AA01B2859B /* ISSRuntimeIntrospectionUtils.h */; };
CC3C818095B53A512E176587 /* ISSPropertyDefinition+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = CC3C8092A63334B4B978B42B /* ISSPropertyDefinition+Private.h */; };
CC3C82264586100F4F287DC8 /* ISSPropertyDefinition.m in Sources */ = {isa = PBXBuildFile; fileRef = CC3C8CC1BB8A2B2FAF7113DA /* ISSPropertyDefinition.m */; };
CC3C830B6FC858F906CC2223 /* NSDictionary+ISSDictionaryAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = CC3C86B36E1E4AE2D2E09402 /* NSDictionary+ISSDictionaryAdditions.m */; };
CC3C8353C4EBE1A513D6D751 /* ISSPointValue.m in Sources */ = {isa = PBXBuildFile; fileRef = CC3C8E8AC3C55159B33BCE4B /* ISSPointValue.m */; };
Expand Down Expand Up @@ -140,7 +139,6 @@
CC3C7CAF67F354EE1D3A74E9 /* ISSDateUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ISSDateUtils.h; sourceTree = "<group>"; };
CC3C8034BF39A0926CD62891 /* ISSRectValue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ISSRectValue.m; sourceTree = "<group>"; };
CC3C803DD954E495E1789FFB /* UIView+ISSPrototypeReusableView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+ISSPrototypeReusableView.m"; sourceTree = "<group>"; };
CC3C8092A63334B4B978B42B /* ISSPropertyDefinition+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ISSPropertyDefinition+Private.h"; sourceTree = "<group>"; };
CC3C8133205B709D492A7ED4 /* NSAttributedString+ISSAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSAttributedString+ISSAdditions.h"; sourceTree = "<group>"; };
CC3C816E089F9508ACDCA38E /* ISSViewPrototype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ISSViewPrototype.h; sourceTree = "<group>"; };
CC3C81A3D5E7700AF520BADE /* ISSPropertyDeclaration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ISSPropertyDeclaration.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -310,7 +308,6 @@
CC3C8D883AC61B4BA8763604 /* ISSUIElementDetails.h */,
CC3C82B417030D3C0260D40E /* ISSPropertyRegistry.m */,
CC3C88928B0760180BFAB41B /* ISSPropertyRegistry.h */,
CC3C8092A63334B4B978B42B /* ISSPropertyDefinition+Private.h */,
);
path = Model;
sourceTree = "<group>";
Expand Down Expand Up @@ -473,7 +470,6 @@
CC3C8DDB0631BA9C70A66260 /* NSMutableArray+ISSAdditions.h in Headers */,
CC3C8B4BBAEA07A6DFF3A07A /* NSAttributedString+ISSAdditions.h in Headers */,
CC3C89FB978EC04E5A439018 /* ISSPropertyRegistry.h in Headers */,
CC3C818095B53A512E176587 /* ISSPropertyDefinition+Private.h in Headers */,
CC3C81614BE09A047EFEB70D /* ISSRuntimeIntrospectionUtils.h in Headers */,
CC3C803B99218B157D6EC836 /* UIView+ISSPrototypeReusableView.h in Headers */,
CC3C8B47FF48205404047254 /* UICollectionView+InterfaCSS.h in Headers */,
Expand Down
28 changes: 0 additions & 28 deletions InterfaCSS/Model/ISSPropertyDefinition+Private.h

This file was deleted.

46 changes: 45 additions & 1 deletion InterfaCSS/Model/ISSPropertyDefinition.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
// License: MIT (http://www.github.com/tolo/InterfaCSS/LICENSE)
//


@class ISSPropertyDefinition;

typedef void (^PropertySetterBlock)(ISSPropertyDefinition* property, id viewObject, id value, NSArray* parameters);


typedef NS_ENUM(NSInteger, ISSPropertyType) {
ISSPropertyTypeString,
ISSPropertyTypeAttributedString,
Expand Down Expand Up @@ -38,16 +44,54 @@ typedef NS_ENUM(NSInteger, ISSPropertyType) {
@property (nonatomic, readonly) ISSPropertyType type;
@property (nonatomic, readonly) NSString* typeDescription;
@property (nonatomic, readonly) NSString* uniqueTypeDescription;

@property (nonatomic, readonly) NSDictionary* parameterEnumValues;
@property (nonatomic, readonly) NSDictionary* enumValues;
@property (nonatomic, readonly) BOOL enumBitMaskType;

@property (nonatomic, copy, readonly) PropertySetterBlock propertySetterBlock;

@property (nonatomic, readonly) BOOL isParameterizedProperty;

@property (nonatomic, readonly) NSString* displayDescription;

- (void) setValue:(id)value onTarget:(id)target andParameters:(NSArray*)params withPrefixKeyPath:(NSString*)prefixKeyPath;

/**
* Creates a temporary, anonymous, property definition.
*/
- (id) initAnonymousPropertyDefinitionWithType:(ISSPropertyType)type;

/**
* Creates a simple property definition.
*/
- (id) initWithName:(NSString*)name type:(ISSPropertyType)type;

/**
* Creates a property definition with an optional number of aliases.
*/
- (id) initWithName:(NSString*)name aliases:(NSArray*)aliases type:(ISSPropertyType)type;

/**
* Creates a property definition with an optional number of aliases.
* If this is an enum property, specify the enum values in the `enumValues` parameter. If the enum values are of a bit mask type, specify `YES` in the `enumBitMaskType` parameter.
*/
- (id) initWithName:(NSString*)name aliases:(NSArray*)aliases type:(ISSPropertyType)type enumValues:(NSDictionary*)enumValues enumBitMaskType:(BOOL)enumBitMaskType;

/**
* Creates a property definition with an optional number of aliases.
* If this is an enum property, specify the enum values in the `enumValues` parameter. If the enum values are of a bit mask type, specify `YES` in the `enumBitMaskType` parameter.
* If this is a parameterized property, specify the parameter value transformation dictionary in `parameterEnumValues`.
* To use a custom handling for setting the property value - specify a property setter block in the `setterBlock` parameter.
*/
- (id) initWithName:(NSString*)name aliases:(NSArray*)aliases type:(ISSPropertyType)type enumValues:(NSDictionary*)enumValues
enumBitMaskType:(BOOL)enumBitMaskType setterBlock:(PropertySetterBlock)setterBlock parameterEnumValues:(NSDictionary*)parameterEnumValues;


/**
* Sets the value of the property represented by this object, on the specified target.
*/
- (void) setValue:(id)value onTarget:(id)target andParameters:(NSArray*)params withPrefixKeyPath:(NSString*)prefixKeyPath;

- (NSComparisonResult) compareByName:(ISSPropertyDefinition*)other;

@end
10 changes: 6 additions & 4 deletions InterfaCSS/Model/ISSPropertyDefinition.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
// License: MIT (http://www.github.com/tolo/InterfaCSS/LICENSE)
//

#import "ISSPropertyDefinition+Private.h"
#import "ISSPropertyDefinition.h"

#import "ISSPropertyDeclaration.h"

#import <objc/runtime.h>

Expand Down Expand Up @@ -40,15 +42,15 @@ - (id) initWithName:(NSString *)name type:(ISSPropertyType)type {
}

- (id) initWithName:(NSString *)name aliases:(NSArray*)aliases type:(ISSPropertyType)type {
return [self initWithName:name aliases:aliases type:type enumBlock:nil enumBitMaskType:NO];
return [self initWithName:name aliases:aliases type:type enumValues:nil enumBitMaskType:NO];
}

- (id) initWithName:(NSString *)name aliases:(NSArray*)aliases type:(ISSPropertyType)type enumBlock:(NSDictionary*)enumValues enumBitMaskType:(BOOL)enumBitMaskType {
- (id) initWithName:(NSString *)name aliases:(NSArray*)aliases type:(ISSPropertyType)type enumValues:(NSDictionary*)enumValues enumBitMaskType:(BOOL)enumBitMaskType {
return [self initWithName:name aliases:aliases type:type enumValues:enumValues enumBitMaskType:enumBitMaskType setterBlock:nil parameterEnumValues:nil];
}

- (id) initWithName:(NSString *)name aliases:(NSArray*)aliases type:(ISSPropertyType)type enumValues:(NSDictionary*)enumValues
enumBitMaskType:(BOOL)enumBitMaskType setterBlock:(void (^)(ISSPropertyDefinition*, id, id, NSArray*))setterBlock parameterEnumValues:(NSDictionary*)parameterEnumValues {
enumBitMaskType:(BOOL)enumBitMaskType setterBlock:(PropertySetterBlock)setterBlock parameterEnumValues:(NSDictionary*)parameterEnumValues {
if (self = [super init]) {
_name = name;

Expand Down
5 changes: 5 additions & 0 deletions InterfaCSS/Model/ISSPropertyRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
*/
- (ISSPropertyDefinition*) registerCustomProperty:(NSString*)propertyName propertyType:(ISSPropertyType)propertyType;

/**
* Registers a custom property definition.
*/
- (void) registerCustomProperty:(ISSPropertyDefinition*)propertyDefinition;

/**
* Registers a valid property prefix (i.e. nested property name).
*/
Expand Down
11 changes: 8 additions & 3 deletions InterfaCSS/Model/ISSPropertyRegistry.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#import "ISSPropertyRegistry.h"

#import "NSString+ISSStringAdditions.h"
#import "ISSPropertyDefinition+Private.h"
#import "NSObject+ISSLogSupport.h"
#import "InterfaCSS.h"
#import "NSAttributedString+ISSAdditions.h"
Expand Down Expand Up @@ -43,11 +42,11 @@
}

static ISSPropertyDefinition* pe(NSString* name, NSDictionary* enumValues) {
return [[ISSPropertyDefinition alloc] initWithName:name aliases:nil type:ISSPropertyTypeEnumType enumBlock:enumValues enumBitMaskType:NO];
return [[ISSPropertyDefinition alloc] initWithName:name aliases:nil type:ISSPropertyTypeEnumType enumValues:enumValues enumBitMaskType:NO];
}

static ISSPropertyDefinition* pea(NSString* name, NSArray* aliases, NSDictionary* enumValues) {
return [[ISSPropertyDefinition alloc] initWithName:name aliases:aliases type:ISSPropertyTypeEnumType enumBlock:enumValues enumBitMaskType:NO];
return [[ISSPropertyDefinition alloc] initWithName:name aliases:aliases type:ISSPropertyTypeEnumType enumValues:enumValues enumBitMaskType:NO];
}

static ISSPropertyDefinition* peo(NSString* name, NSDictionary* enumValues) {
Expand Down Expand Up @@ -158,6 +157,12 @@ - (ISSPropertyDefinition*) registerCustomProperty:(NSString*)propertyName proper
return propertyDefinition;
}

- (void) registerCustomProperty:(ISSPropertyDefinition*)propertyDefinition {
if( propertyDefinition ) {
self.propertyDefinitions = [self.propertyDefinitions setByAddingObject:propertyDefinition];
}
}

- (void) registerValidPrefixKeyPath:(NSString*)prefix {
if( ![prefix iss_hasData] ) return;
NSMutableDictionary* temp = [NSMutableDictionary dictionaryWithDictionary:self.validPrefixKeyPaths];
Expand Down

0 comments on commit 0162ed5

Please sign in to comment.