Skip to content

Commit

Permalink
Issue #39: Added nullability annotations to remaining code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Madsen committed Nov 10, 2015
1 parent 37df9f4 commit d12cdf8
Show file tree
Hide file tree
Showing 87 changed files with 587 additions and 212 deletions.
6 changes: 6 additions & 0 deletions Framework/MIKMIDI.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@
9DB366F71A964D4A001D1CF3 /* MIKMIDISynthesizerInstrument.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DB366F41A964D4A001D1CF3 /* MIKMIDISynthesizerInstrument.h */; settings = {ATTRIBUTES = (Public, ); }; };
9DB366F81A964D4A001D1CF3 /* MIKMIDISynthesizerInstrument.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DB366F51A964D4A001D1CF3 /* MIKMIDISynthesizerInstrument.m */; };
9DB366F91A964D4A001D1CF3 /* MIKMIDISynthesizerInstrument.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DB366F51A964D4A001D1CF3 /* MIKMIDISynthesizerInstrument.m */; };
9DB8CD421BF266FE00F6388D /* MIKMIDIMetaEvent_SubclassMethods.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DB8CD401BF266FE00F6388D /* MIKMIDIMetaEvent_SubclassMethods.h */; };
9DB8CD431BF266FE00F6388D /* MIKMIDIMetaEvent_SubclassMethods.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DB8CD401BF266FE00F6388D /* MIKMIDIMetaEvent_SubclassMethods.h */; };
9DBEBD581AAA21BE00E59734 /* MIKMIDICommand_SubclassMethods.h in Headers */ = {isa = PBXBuildFile; fileRef = 9D74EF3517A713A100BEE89F /* MIKMIDICommand_SubclassMethods.h */; settings = {ATTRIBUTES = (Public, ); }; };
9DBEBD591AAA21BE00E59734 /* MIKMIDICommand_SubclassMethods.h in Headers */ = {isa = PBXBuildFile; fileRef = 9D74EF3517A713A100BEE89F /* MIKMIDICommand_SubclassMethods.h */; settings = {ATTRIBUTES = (Public, ); }; };
9DBEBD5A1AAA21C400E59734 /* MIKMIDIEvent_SubclassMethods.h in Headers */ = {isa = PBXBuildFile; fileRef = 839D932D19C3A2C9007589C3 /* MIKMIDIEvent_SubclassMethods.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -446,6 +448,7 @@
9DB366EF1A964C55001D1CF3 /* MIKMIDISynthesizer.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = MIKMIDISynthesizer.m; sourceTree = "<group>"; tabWidth = 4; usesTabs = 1; wrapsLines = 1; };
9DB366F41A964D4A001D1CF3 /* MIKMIDISynthesizerInstrument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MIKMIDISynthesizerInstrument.h; sourceTree = "<group>"; };
9DB366F51A964D4A001D1CF3 /* MIKMIDISynthesizerInstrument.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MIKMIDISynthesizerInstrument.m; sourceTree = "<group>"; };
9DB8CD401BF266FE00F6388D /* MIKMIDIMetaEvent_SubclassMethods.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MIKMIDIMetaEvent_SubclassMethods.h; sourceTree = "<group>"; };
9DBEBD5C1AAA27D100E59734 /* module.modulemap */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = "sourcecode.module-map"; path = module.modulemap; sourceTree = SOURCE_ROOT; };
9DBEBD651AAA303700E59734 /* MIKMIDIChannelPressureEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MIKMIDIChannelPressureEvent.h; sourceTree = "<group>"; };
9DBEBD661AAA303700E59734 /* MIKMIDIChannelPressureEvent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MIKMIDIChannelPressureEvent.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -700,6 +703,7 @@
isa = PBXGroup;
children = (
839D933B19C3A2F5007589C3 /* MIKMIDIMetaEvent.h */,
9DB8CD401BF266FE00F6388D /* MIKMIDIMetaEvent_SubclassMethods.h */,
839D933C19C3A2F5007589C3 /* MIKMIDIMetaEvent.m */,
839D933719C3A2F5007589C3 /* MIKMIDIMetaCopyrightEvent.h */,
839D933819C3A2F5007589C3 /* MIKMIDIMetaCopyrightEvent.m */,
Expand Down Expand Up @@ -861,6 +865,7 @@
9D74EF7117A713A100BEE89F /* MIKMIDIEndpoint.h in Headers */,
83FB360E1B42D58000F91DCD /* MIKMIDISequence+MIKMIDIPrivate.h in Headers */,
9D74EF7317A713A100BEE89F /* MIKMIDIEntity.h in Headers */,
9DB8CD421BF266FE00F6388D /* MIKMIDIMetaEvent_SubclassMethods.h in Headers */,
9D74EF7517A713A100BEE89F /* MIKMIDIErrors.h in Headers */,
9D74EF7717A713A100BEE89F /* MIKMIDIInputPort.h in Headers */,
9D74EF7917A713A100BEE89F /* MIKMIDIMapping.h in Headers */,
Expand Down Expand Up @@ -948,6 +953,7 @@
9DAF8B631A7B008A00F46528 /* MIKMIDINoteOnCommand.h in Headers */,
9D84951D1AA7678700C52475 /* MIKMIDIProgramChangeEvent.h in Headers */,
9DAF8B5E1A7B007300F46528 /* MIKMIDIDestinationEndpoint.h in Headers */,
9DB8CD431BF266FE00F6388D /* MIKMIDIMetaEvent_SubclassMethods.h in Headers */,
9D3781561AA407A7007A61BE /* MIKMIDIResponder.h in Headers */,
9DAF8B7B1A7B00A700F46528 /* MIKMIDIPlayer.h in Headers */,
9DAF8B781A7B00A700F46528 /* MIKMIDIMetaTimeSignatureEvent.h in Headers */,
Expand Down
17 changes: 13 additions & 4 deletions Source/MIKMIDIChannelEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
//

#import <MIKMIDI/MIKMIDIEvent.h>
#import "MIKMIDICompilerCompatibility.h"

NS_ASSUME_NONNULL_BEGIN

@interface MIKMIDIChannelEvent : MIKMIDIEvent

Expand All @@ -18,7 +21,7 @@
*
* @return A new instance of a subclass of MIKMIDIChannelEvent, or nil if there is an error.
*/
+ (instancetype)channelEventWithTimeStamp:(MusicTimeStamp)timeStamp message:(MIDIChannelMessage)message;
+ (nullable instancetype)channelEventWithTimeStamp:(MusicTimeStamp)timeStamp message:(MIDIChannelMessage)message;

// Properties

Expand All @@ -45,21 +48,27 @@
@interface MIKMutableMIDIChannelEvent : MIKMIDIChannelEvent

@property (nonatomic, readwrite) MusicTimeStamp timeStamp;
@property (nonatomic, strong, readwrite) NSMutableData *data;
@property (nonatomic, strong, readwrite, null_resettable) NSMutableData *data;
@property (nonatomic, readwrite) UInt8 channel;
@property (nonatomic, readwrite) UInt8 dataByte1;
@property (nonatomic, readwrite) UInt8 dataByte2;

@end

NS_ASSUME_NONNULL_END

#pragma mark -

#import <MIKMIDI/MIKMIDICommand.h>

@class MIKMIDIClock;

NS_ASSUME_NONNULL_BEGIN

@interface MIKMIDICommand (MIKMIDIChannelEventToCommands)

+ (instancetype)commandFromChannelEvent:(MIKMIDIChannelEvent *)event clock:(MIKMIDIClock *)clock;
+ (nullable instancetype)commandFromChannelEvent:(MIKMIDIChannelEvent *)event clock:(MIKMIDIClock *)clock;

@end

@end
NS_ASSUME_NONNULL_END
9 changes: 7 additions & 2 deletions Source/MIKMIDIChannelPressureEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
//

#import "MIKMIDIChannelEvent.h"
#import "MIKMIDICompilerCompatibility.h"

NS_ASSUME_NONNULL_BEGIN

/**
* A channel pressure (aftertouch) event.
Expand All @@ -32,9 +35,11 @@
@property (nonatomic, readwrite) UInt8 pressure;

@property (nonatomic, readwrite) MusicTimeStamp timeStamp;
@property (nonatomic, strong, readwrite) NSMutableData *data;
@property (nonatomic, strong, readwrite, null_resettable) NSMutableData *data;
@property (nonatomic, readwrite) UInt8 channel;
@property (nonatomic, readwrite) UInt8 dataByte1;
@property (nonatomic, readwrite) UInt8 dataByte2;

@end
@end

NS_ASSUME_NONNULL_END
7 changes: 6 additions & 1 deletion Source/MIKMIDIChannelVoiceCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
//

#import "MIKMIDICommand.h"
#import "MIKMIDICompilerCompatibility.h"

NS_ASSUME_NONNULL_BEGIN

/**
* MIKMIDIChannelVoiceCommand is used to represent MIDI messages whose type is
Expand Down Expand Up @@ -46,6 +49,8 @@
@property (nonatomic, readwrite) UInt8 dataByte2;

@property (nonatomic, readwrite) MIDITimeStamp midiTimestamp;
@property (nonatomic, copy, readwrite) NSData *data;
@property (nonatomic, copy, readwrite, null_resettable) NSData *data;

@end

NS_ASSUME_NONNULL_END
5 changes: 5 additions & 0 deletions Source/MIKMIDIChannelVoiceCommand_SubclassMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@

#import "MIKMIDIChannelVoiceCommand.h"
#import "MIKMIDICommand_SubclassMethods.h"
#import "MIKMIDICompilerCompatibility.h"

NS_ASSUME_NONNULL_BEGIN

@interface MIKMIDIChannelVoiceCommand ()

@property (nonatomic, readwrite) NSUInteger value;

@end

NS_ASSUME_NONNULL_END
9 changes: 7 additions & 2 deletions Source/MIKMIDIClientDestinationEndpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
//

#import "MIKMIDIDestinationEndpoint.h"
#import "MIKMIDICompilerCompatibility.h"

@class MIKMIDIClientDestinationEndpoint;

NS_ASSUME_NONNULL_BEGIN

typedef void(^MIKMIDIClientDestinationEndpointEventHandler)(MIKMIDIClientDestinationEndpoint *destination, NSArray *commands);

/**
Expand Down Expand Up @@ -37,11 +40,13 @@ typedef void(^MIKMIDIClientDestinationEndpointEventHandler)(MIKMIDIClientDestina
*
* @return An instance of MIKMIDIClientDestinationEndpoint, or nil if an error occurs.
*/
- (instancetype)initWithName:(NSString *)name receivedMessagesHandler:(MIKMIDIClientDestinationEndpointEventHandler)handler;
- (nullable instancetype)initWithName:(NSString *)name receivedMessagesHandler:(nullable MIKMIDIClientDestinationEndpointEventHandler)handler;

/**
* A block to be called when the receiver receives new incoming MIDI messages.
*/
@property (nonatomic, strong) MIKMIDIClientDestinationEndpointEventHandler receivedMessagesHandler;
@property (nonatomic, strong, nullable) MIKMIDIClientDestinationEndpointEventHandler receivedMessagesHandler;

@end

NS_ASSUME_NONNULL_END
7 changes: 6 additions & 1 deletion Source/MIKMIDIClientSourceEndpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
//

#import "MIKMIDISourceEndpoint.h"
#import "MIKMIDICompilerCompatibility.h"

NS_ASSUME_NONNULL_BEGIN

/**
* MIKMIDIClientSourceEndpoint represents a virtual endpoint created by your application to send MIDI
Expand All @@ -27,7 +30,7 @@
*
* @return An instance of MIKMIDIClientSourceEndpoint, or nil if an error occurs.
*/
- (instancetype)initWithName:(NSString*)name;
- (nullable instancetype)initWithName:(NSString *)name;

/**
* Used to send MIDI messages/commands from your application to a MIDI output endpoint.
Expand All @@ -41,3 +44,5 @@
- (BOOL)sendCommands:(NSArray *)commands error:(NSError **)error;

@end

NS_ASSUME_NONNULL_END
4 changes: 3 additions & 1 deletion Source/MIKMIDIClock.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#import <Foundation/Foundation.h>
#import <AudioToolbox/AudioToolbox.h>
#import "MIKMIDICompilerCompatibility.h"

/**
* Returns the number of MIDITimeStamps that would occur during a specified time interval.
Expand All @@ -25,6 +26,7 @@ Float64 MIKMIDIClockMIDITimeStampsPerTimeInterval(NSTimeInterval timeInterval);
*/
Float64 MIKMIDIClockSecondsPerMIDITimeStamp();

NS_ASSUME_NONNULL_BEGIN

/**
* MIKMIDIClock provides the number of seconds per MIDITimeStamp, as well as the
Expand Down Expand Up @@ -213,6 +215,6 @@ Float64 MIKMIDIClockSecondsPerMIDITimeStamp();
*/
+ (Float64)midiTimeStampsPerTimeInterval:(NSTimeInterval)timeInterval DEPRECATED_ATTRIBUTE;


@end

NS_ASSUME_NONNULL_END
12 changes: 8 additions & 4 deletions Source/MIKMIDICommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#import <Foundation/Foundation.h>
#import <CoreMIDI/CoreMIDI.h>
#import "MIKMIDICompilerCompatibility.h"

/**
* Types of MIDI messages. These values correspond directly to the MIDI command type values
Expand Down Expand Up @@ -56,6 +57,8 @@ typedef NS_ENUM(NSUInteger, MIKMIDICommandType) {

@class MIKMIDIMappingItem;

NS_ASSUME_NONNULL_BEGIN

/**
* In MIKMIDI, MIDI messages are objects. Specifically, they are instances of MIKMIDICommand or one of its
* subclasses. MIKMIDICommand's subclasses each represent a specific type of MIDI message, for example,
Expand Down Expand Up @@ -193,14 +196,14 @@ typedef NS_ENUM(NSUInteger, MIKMIDICommandType) {
/**
* The raw data that makes up the receiver.
*/
@property (nonatomic, copy, readonly) NSData *data;
@property (nonatomic, copy, readonly, null_resettable) NSData *data;

/**
* Optional mapping item used to route the command. This must be set by client code that handles
* receiving MIDI commands. Allows responders to understand how a command was mapped, especially
* useful to determine interaction type so that responders can interpret the command correctly.
*/
@property (nonatomic, strong) MIKMIDIMappingItem *mappingItem;
@property (nonatomic, strong, nullable) MIKMIDIMappingItem *mappingItem;

@end

Expand All @@ -225,11 +228,12 @@ typedef NS_ENUM(NSUInteger, MIKMIDICommandType) {
* transfered to the caller which becomes responsible for freeing the allocated memory.
* Used by MIKMIDI when sending commands. Typically, this is not needed by clients of MIKMIDI.
*
* @param outPacketList A pointer pointer to a MIDIPacketList structure which will point to the created MIDIPacketList
* @param outPacketList A pointer to a pointer to a MIDIPacketList structure which will point to the created MIDIPacketList
* upon success.
* @param commands An array of MIKMIDICommand instances.
*
* @return YES if creating the packet list was successful, NO if an error occurred.
*/
BOOL MIKCreateMIDIPacketListFromCommands(MIDIPacketList **outPacketList, NSArray *commands);
BOOL MIKCreateMIDIPacketListFromCommands(MIDIPacketList * _Nonnull * _Nonnull outPacketList, NSArray *commands);

NS_ASSUME_NONNULL_END
2 changes: 1 addition & 1 deletion Source/MIKMIDICommand.m
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ - (void)setData:(NSData *)data
{
if (![[self class] isMutable]) return MIKMIDI_RAISE_MUTATION_ATTEMPT_EXCEPTION;

self.internalData = [data mutableCopy];
self.internalData = data ? [data mutableCopy] : [NSMutableData data];
}

@end
Expand Down
4 changes: 4 additions & 0 deletions Source/MIKMIDICommandScheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
//

#import <Foundation/Foundation.h>
#import "MIKMIDICompilerCompatibility.h"

NS_ASSUME_NONNULL_BEGIN

/**
* Objects that conform to this protocol can be used as a destination for MIDI commands to
Expand All @@ -20,3 +22,5 @@
- (void)scheduleMIDICommands:(NSArray *)commands;

@end

NS_ASSUME_NONNULL_END
6 changes: 5 additions & 1 deletion Source/MIKMIDICommandThrottler.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
//

#import <Foundation/Foundation.h>
#import "MIKMIDICompilerCompatibility.h"

@class MIKMIDIChannelVoiceCommand;

NS_ASSUME_NONNULL_BEGIN

/**
* MIKMIDICommandThrottler is a simple utility class useful for throttling e.g. jog wheel/turntable controls,
* which otherwise send many messages per revolution.
*/

@interface MIKMIDICommandThrottler : NSObject

/**
Expand All @@ -35,3 +37,5 @@
- (void)resetThrottlingCountForCommand:(MIKMIDIChannelVoiceCommand *)command;

@end

NS_ASSUME_NONNULL_END
11 changes: 8 additions & 3 deletions Source/MIKMIDIControlChangeCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
//

#import "MIKMIDIChannelVoiceCommand.h"
#import "MIKMIDICompilerCompatibility.h"

NS_ASSUME_NONNULL_BEGIN

/**
* A MIDI control change message.
Expand All @@ -33,7 +36,7 @@
* @return A new, single MIKMIDIControlChangeCommand instance containing 14-bit value data, and whose
* fourteenBitCommand property is set to YES.
*/
+ (instancetype)commandByCoalescingMSBCommand:(MIKMIDIControlChangeCommand *)msbCommand andLSBCommand:(MIKMIDIControlChangeCommand *)lsbCommand;
+ (nullable instancetype)commandByCoalescingMSBCommand:(MIKMIDIControlChangeCommand *)msbCommand andLSBCommand:(MIKMIDIControlChangeCommand *)lsbCommand;

/**
* The MIDI control number for the command.
Expand Down Expand Up @@ -101,6 +104,8 @@
@property (nonatomic, readwrite) UInt8 dataByte2;

@property (nonatomic, readwrite) MIDITimeStamp midiTimestamp;
@property (nonatomic, copy, readwrite) NSData *data;
@property (nonatomic, copy, readwrite, null_resettable) NSData *data;

@end

@end
NS_ASSUME_NONNULL_END
9 changes: 7 additions & 2 deletions Source/MIKMIDIControlChangeEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
//

#import "MIKMIDIChannelEvent.h"
#import "MIKMIDICompilerCompatibility.h"

NS_ASSUME_NONNULL_BEGIN

/**
* Control change events are typically sent when a controller value changes.
Expand Down Expand Up @@ -40,9 +43,11 @@
@property (nonatomic, readwrite) NSUInteger controllerValue;

@property (nonatomic, readwrite) MusicTimeStamp timeStamp;
@property (nonatomic, strong, readwrite) NSMutableData *data;
@property (nonatomic, strong, readwrite, null_resettable) NSMutableData *data;
@property (nonatomic, readwrite) UInt8 channel;
@property (nonatomic, readwrite) UInt8 dataByte1;
@property (nonatomic, readwrite) UInt8 dataByte2;

@end
@end

NS_ASSUME_NONNULL_END
Loading

0 comments on commit d12cdf8

Please sign in to comment.