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)
|
||||
/** Enumeration with a C function callback uses this prototype
|
||||
*/
|
||||
typedef void (*GSRegexEnumerationCallback)(NSRegularExpression *regex,
|
||||
typedef void (*GSRegexEnumerationCallback)(
|
||||
void *context, NSTextCheckingResult *match,
|
||||
NSMatchingFlags flags, BOOL *shouldStop);
|
||||
#endif
|
||||
|
@ -135,7 +135,7 @@ GS_EXPORT_CLASS
|
|||
* Its behavior is like that of the
|
||||
* -enumerateMatchesInString:options:range:usingBlock: method, except that
|
||||
* 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 />
|
||||
* The operation of the method is basically to call the supplied callback
|
||||
* function for each match of the expression in the string.
|
||||
|
|
|
@ -65,7 +65,6 @@
|
|||
#import "Foundation/NSError.h"
|
||||
|
||||
typedef struct {
|
||||
NSRegularExpression *e; // The RE being used
|
||||
GSRegexEnumerationCallback h; // The handler callback function
|
||||
void *c; // Context for this enumeration
|
||||
} GSRegexContext;
|
||||
|
@ -119,7 +118,7 @@ NSRegularExpressionOptionsToURegexpFlags(NSRegularExpressionOptions opts)
|
|||
/* Callback method to invoke a block
|
||||
*/
|
||||
static void
|
||||
blockCallback(NSRegularExpression *regex,
|
||||
blockCallback(
|
||||
void *context, NSTextCheckingResult *match,
|
||||
NSMatchingFlags flags, BOOL *shouldStop)
|
||||
{
|
||||
|
@ -401,7 +400,7 @@ callback(const void *context, int32_t steps)
|
|||
{
|
||||
return FALSE;
|
||||
}
|
||||
(*c->h)(c->e, c->c, nil, NSMatchingProgress, &stop);
|
||||
(*c->h)(c->c, nil, NSMatchingProgress, &stop);
|
||||
|
||||
return (stop ? FALSE : TRUE);
|
||||
}
|
||||
|
@ -594,7 +593,7 @@ prepareResult(NSRegularExpression *regex,
|
|||
UErrorCode s = 0;
|
||||
UText txt = UTEXT_INITIALIZER;
|
||||
BOOL stop = NO;
|
||||
GSRegexContext ctx = { self, handler, context };
|
||||
GSRegexContext ctx = { handler, context };
|
||||
URegularExpression *r = setupRegex(regex, string, &txt, opts, range, &ctx);
|
||||
NSUInteger groups = [self numberOfCaptureGroups] + 1;
|
||||
NSRange ranges[groups];
|
||||
|
@ -618,7 +617,7 @@ prepareResult(NSRegularExpression *regex,
|
|||
regularExpressionCheckingResultWithRanges: ranges
|
||||
count: groups
|
||||
regularExpression: self];
|
||||
(*handler)(self, context, result, flags, &stop);
|
||||
(*handler)(context, result, flags, &stop);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -634,12 +633,12 @@ prepareResult(NSRegularExpression *regex,
|
|||
regularExpressionCheckingResultWithRanges: ranges
|
||||
count: groups
|
||||
regularExpression: self];
|
||||
(*handler)(self, context, result, flags, &stop);
|
||||
(*handler)(context, result, flags, &stop);
|
||||
}
|
||||
}
|
||||
if (opts & NSMatchingCompleted)
|
||||
{
|
||||
(*handler)(self, context, nil, NSMatchingCompleted, &stop);
|
||||
(*handler)(context, nil, NSMatchingCompleted, &stop);
|
||||
}
|
||||
utext_close(&txt);
|
||||
uregex_close(r);
|
||||
|
@ -657,7 +656,7 @@ prepareResult(NSRegularExpression *regex,
|
|||
URegularExpression *r;
|
||||
NSUInteger groups = [self numberOfCaptureGroups] + 1;
|
||||
NSRange ranges[groups];
|
||||
GSRegexContext ctx = { self, handler, context };
|
||||
GSRegexContext ctx = { handler, context };
|
||||
TEMP_BUFFER(buffer, length);
|
||||
|
||||
r = setupRegex(regex, string, buffer, length, opts, range, &ctx);
|
||||
|
@ -681,7 +680,7 @@ prepareResult(NSRegularExpression *regex,
|
|||
regularExpressionCheckingResultWithRanges: ranges
|
||||
count: groups
|
||||
regularExpression: self];
|
||||
(*handler)(self, context, result, flags, &stop);
|
||||
(*handler)(context, result, flags, &stop);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -697,12 +696,12 @@ prepareResult(NSRegularExpression *regex,
|
|||
regularExpressionCheckingResultWithRanges: ranges
|
||||
count: groups
|
||||
regularExpression: self];
|
||||
(*handler)(self, context, result, flags, &stop);
|
||||
(*handler)(context, result, flags, &stop);
|
||||
}
|
||||
}
|
||||
if (opts & NSMatchingCompleted)
|
||||
{
|
||||
(*handler)(self, context, nil, NSMatchingCompleted, &stop);
|
||||
(*handler)(context, nil, NSMatchingCompleted, &stop);
|
||||
}
|
||||
uregex_close(r);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
#import "ObjectTesting.h"
|
||||
|
||||
static void callback(NSRegularExpression *re, void *context,
|
||||
NSTextCheckingResult *match, NSMatchingFlags flags, BOOL *stop)
|
||||
static void callback(void *context, NSTextCheckingResult *match,
|
||||
NSMatchingFlags flags, BOOL *stop)
|
||||
{
|
||||
if (match)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue