mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-01 09:02:01 +00:00
Simplify by removng unnecessary argument in new callback
This commit is contained in:
parent
88720adbb1
commit
2882d8c812
3 changed files with 14 additions and 15 deletions
|
@ -69,7 +69,7 @@ static const NSMatchingOptions NSMatchingWithoutAnchoringBounds = 1<<4;
|
||||||
#if GS_API_VERSION( 13100, GS_API_LATEST)
|
#if GS_API_VERSION( 13100, GS_API_LATEST)
|
||||||
/** Enumeration with a C function callback uses this prototype
|
/** Enumeration with a C function callback uses this prototype
|
||||||
*/
|
*/
|
||||||
typedef void (*GSRegexEnumerationCallback)(NSRegularExpression *regex,
|
typedef void (*GSRegexEnumerationCallback)(
|
||||||
void *context, NSTextCheckingResult *match,
|
void *context, NSTextCheckingResult *match,
|
||||||
NSMatchingFlags flags, BOOL *shouldStop);
|
NSMatchingFlags flags, BOOL *shouldStop);
|
||||||
#endif
|
#endif
|
||||||
|
@ -135,7 +135,7 @@ GS_EXPORT_CLASS
|
||||||
* Its behavior is like that of the
|
* Its behavior is like that of the
|
||||||
* -enumerateMatchesInString:options:range:usingBlock: method, except that
|
* -enumerateMatchesInString:options:range:usingBlock: method, except that
|
||||||
* it uses a callback rather than a block, and the callback is supplied with
|
* it uses a callback rather than a block, and the callback is supplied with
|
||||||
* both the NSRegularExpression instance being used and the context value.
|
* the context value specified as an argument to this method.
|
||||||
* <br />
|
* <br />
|
||||||
* The operation of the method is basically to call the supplied callback
|
* The operation of the method is basically to call the supplied callback
|
||||||
* function for each match of the expression in the string.
|
* function for each match of the expression in the string.
|
||||||
|
|
|
@ -65,7 +65,6 @@
|
||||||
#import "Foundation/NSError.h"
|
#import "Foundation/NSError.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
NSRegularExpression *e; // The RE being used
|
|
||||||
GSRegexEnumerationCallback h; // The handler callback function
|
GSRegexEnumerationCallback h; // The handler callback function
|
||||||
void *c; // Context for this enumeration
|
void *c; // Context for this enumeration
|
||||||
} GSRegexContext;
|
} GSRegexContext;
|
||||||
|
@ -119,7 +118,7 @@ NSRegularExpressionOptionsToURegexpFlags(NSRegularExpressionOptions opts)
|
||||||
/* Callback method to invoke a block
|
/* Callback method to invoke a block
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
blockCallback(NSRegularExpression *regex,
|
blockCallback(
|
||||||
void *context, NSTextCheckingResult *match,
|
void *context, NSTextCheckingResult *match,
|
||||||
NSMatchingFlags flags, BOOL *shouldStop)
|
NSMatchingFlags flags, BOOL *shouldStop)
|
||||||
{
|
{
|
||||||
|
@ -401,7 +400,7 @@ callback(const void *context, int32_t steps)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
(*c->h)(c->e, c->c, nil, NSMatchingProgress, &stop);
|
(*c->h)(c->c, nil, NSMatchingProgress, &stop);
|
||||||
|
|
||||||
return (stop ? FALSE : TRUE);
|
return (stop ? FALSE : TRUE);
|
||||||
}
|
}
|
||||||
|
@ -594,7 +593,7 @@ prepareResult(NSRegularExpression *regex,
|
||||||
UErrorCode s = 0;
|
UErrorCode s = 0;
|
||||||
UText txt = UTEXT_INITIALIZER;
|
UText txt = UTEXT_INITIALIZER;
|
||||||
BOOL stop = NO;
|
BOOL stop = NO;
|
||||||
GSRegexContext ctx = { self, handler, context };
|
GSRegexContext ctx = { handler, context };
|
||||||
URegularExpression *r = setupRegex(regex, string, &txt, opts, range, &ctx);
|
URegularExpression *r = setupRegex(regex, string, &txt, opts, range, &ctx);
|
||||||
NSUInteger groups = [self numberOfCaptureGroups] + 1;
|
NSUInteger groups = [self numberOfCaptureGroups] + 1;
|
||||||
NSRange ranges[groups];
|
NSRange ranges[groups];
|
||||||
|
@ -618,7 +617,7 @@ prepareResult(NSRegularExpression *regex,
|
||||||
regularExpressionCheckingResultWithRanges: ranges
|
regularExpressionCheckingResultWithRanges: ranges
|
||||||
count: groups
|
count: groups
|
||||||
regularExpression: self];
|
regularExpression: self];
|
||||||
(*handler)(self, context, result, flags, &stop);
|
(*handler)(context, result, flags, &stop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -634,12 +633,12 @@ prepareResult(NSRegularExpression *regex,
|
||||||
regularExpressionCheckingResultWithRanges: ranges
|
regularExpressionCheckingResultWithRanges: ranges
|
||||||
count: groups
|
count: groups
|
||||||
regularExpression: self];
|
regularExpression: self];
|
||||||
(*handler)(self, context, result, flags, &stop);
|
(*handler)(context, result, flags, &stop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (opts & NSMatchingCompleted)
|
if (opts & NSMatchingCompleted)
|
||||||
{
|
{
|
||||||
(*handler)(self, context, nil, NSMatchingCompleted, &stop);
|
(*handler)(context, nil, NSMatchingCompleted, &stop);
|
||||||
}
|
}
|
||||||
utext_close(&txt);
|
utext_close(&txt);
|
||||||
uregex_close(r);
|
uregex_close(r);
|
||||||
|
@ -657,7 +656,7 @@ prepareResult(NSRegularExpression *regex,
|
||||||
URegularExpression *r;
|
URegularExpression *r;
|
||||||
NSUInteger groups = [self numberOfCaptureGroups] + 1;
|
NSUInteger groups = [self numberOfCaptureGroups] + 1;
|
||||||
NSRange ranges[groups];
|
NSRange ranges[groups];
|
||||||
GSRegexContext ctx = { self, handler, context };
|
GSRegexContext ctx = { handler, context };
|
||||||
TEMP_BUFFER(buffer, length);
|
TEMP_BUFFER(buffer, length);
|
||||||
|
|
||||||
r = setupRegex(regex, string, buffer, length, opts, range, &ctx);
|
r = setupRegex(regex, string, buffer, length, opts, range, &ctx);
|
||||||
|
@ -681,7 +680,7 @@ prepareResult(NSRegularExpression *regex,
|
||||||
regularExpressionCheckingResultWithRanges: ranges
|
regularExpressionCheckingResultWithRanges: ranges
|
||||||
count: groups
|
count: groups
|
||||||
regularExpression: self];
|
regularExpression: self];
|
||||||
(*handler)(self, context, result, flags, &stop);
|
(*handler)(context, result, flags, &stop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -697,12 +696,12 @@ prepareResult(NSRegularExpression *regex,
|
||||||
regularExpressionCheckingResultWithRanges: ranges
|
regularExpressionCheckingResultWithRanges: ranges
|
||||||
count: groups
|
count: groups
|
||||||
regularExpression: self];
|
regularExpression: self];
|
||||||
(*handler)(self, context, result, flags, &stop);
|
(*handler)(context, result, flags, &stop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (opts & NSMatchingCompleted)
|
if (opts & NSMatchingCompleted)
|
||||||
{
|
{
|
||||||
(*handler)(self, context, nil, NSMatchingCompleted, &stop);
|
(*handler)(context, nil, NSMatchingCompleted, &stop);
|
||||||
}
|
}
|
||||||
uregex_close(r);
|
uregex_close(r);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import "ObjectTesting.h"
|
#import "ObjectTesting.h"
|
||||||
|
|
||||||
static void callback(NSRegularExpression *re, void *context,
|
static void callback(void *context, NSTextCheckingResult *match,
|
||||||
NSTextCheckingResult *match, NSMatchingFlags flags, BOOL *stop)
|
NSMatchingFlags flags, BOOL *stop)
|
||||||
{
|
{
|
||||||
if (match)
|
if (match)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue