@@ -36,33 +36,33 @@ @implementation OFOptionsParser @synthesize lastOption = _lastOption, lastLongOption = _lastLongOption; @synthesize argument = _argument; -+ (instancetype)parserWithOptions: (const of_options_parser_option_t *)options ++ (instancetype)parserWithOptions: (const OFOptionsParserOption *)options { return [[[self alloc] initWithOptions: options] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } -- (instancetype)initWithOptions: (const of_options_parser_option_t *)options +- (instancetype)initWithOptions: (const OFOptionsParserOption *)options { self = [super init]; @try { size_t count = 0; - const of_options_parser_option_t *iter; - of_options_parser_option_t *iter2; - const of_map_table_functions_t keyFunctions = { + const OFOptionsParserOption *iter; + OFOptionsParserOption *iter2; + const OFMapTableFunctions keyFunctions = { .hash = stringHash, .equal = stringEqual }; - const of_map_table_functions_t objectFunctions = { NULL }; + const OFMapTableFunctions objectFunctions = { NULL }; /* Count, sanity check, initialize pointers */ for (iter = options; iter->shortOption != '\0' || iter->longOption != nil; iter++) { @@ -82,11 +82,11 @@ *iter->argumentPtr = nil; count++; } - _options = of_alloc(count + 1, sizeof(*_options)); + _options = OFAllocMemory(count + 1, sizeof(*_options)); _longOptions = [[OFMapTable alloc] initWithKeyFunctions: keyFunctions objectFunctions: objectFunctions]; for (iter = options, iter2 = _options; @@ -139,27 +139,27 @@ } - (void)dealloc { if (_options != NULL) - for (of_options_parser_option_t *iter = _options; + for (OFOptionsParserOption *iter = _options; iter->shortOption != '\0' || iter->longOption != nil; iter++) [iter->longOption release]; - free(_options); + OFFreeMemory(_options); [_longOptions release]; [_arguments release]; [_argument release]; [super dealloc]; } -- (of_unichar_t)nextOption +- (OFUnichar)nextOption { - of_options_parser_option_t *iter; + OFOptionsParserOption *iter; OFString *argument; if (_done || _index >= _arguments.count) return '\0'; @@ -184,24 +184,24 @@ } if ([argument hasPrefix: @"--"]) { void *pool = objc_autoreleasePoolPush(); size_t pos; - of_options_parser_option_t *option; + OFOptionsParserOption *option; _lastOption = '-'; _index++; if ((pos = [argument rangeOfString: @"="].location) != - OF_NOT_FOUND) + OFNotFound) _argument = [[argument substringFromIndex: pos + 1] copy]; else pos = argument.length; _lastLongOption = [[argument substringWithRange: - of_range(2, pos - 2)] copy]; + OFRangeMake(2, pos - 2)] copy]; objc_autoreleasePoolPop(pool); option = [_longOptions objectForKey: _lastLongOption]; if (option == NULL) @@ -269,8 +269,8 @@ } - (OFArray *)remainingArguments { return [_arguments objectsInRange: - of_range(_index, _arguments.count - _index)]; + OFRangeMake(_index, _arguments.count - _index)]; } @end