Skip to content

Commit

Permalink
Merge branch 'feature/Indent' into develop
Browse files Browse the repository at this point in the history
* feature/Indent:
  Made indent style universal
  Reordered project layout
  • Loading branch information
schwa committed Feb 11, 2011
2 parents aead1e1 + cfe1f37 commit 2c53d73
Show file tree
Hide file tree
Showing 11 changed files with 1,548 additions and 1,511 deletions.
460 changes: 230 additions & 230 deletions Source/CDataScanner.m

Large diffs are not rendered by default.

82 changes: 41 additions & 41 deletions Source/Experimental/CFilteringJSONSerializer.m
Expand Up @@ -14,57 +14,57 @@ @implementation CFilteringJSONSerializer
@synthesize convertersByName;

- (void)dealloc
{
[tests release];
tests = NULL;
//
[convertersByName release];
convertersByName = NULL;
//
[super dealloc];
}
{
[tests release];
tests = NULL;
//
[convertersByName release];
convertersByName = NULL;
//
[super dealloc];
}

- (NSData *)serializeObject:(id)inObject error:(NSError **)outError
{
NSData *theData = NULL;
for (JSONConversionTest theTest in self.tests)
{
NSString *theName = theTest(inObject);
if (theName != NULL)
{
id theObject = NULL;
JSONConversionConverter theConverter = [self.convertersByName objectForKey:theName];
if (theConverter)
{
NSData *theData = NULL;
for (JSONConversionTest theTest in self.tests)
{
NSString *theName = theTest(inObject);
if (theName != NULL)
{
theObject = theConverter(inObject);
}

if (theObject)
{
if ([theObject isKindOfClass:[NSData class]])
id theObject = NULL;
JSONConversionConverter theConverter = [self.convertersByName objectForKey:theName];
if (theConverter)
{
theData = theObject;
break;
theObject = theConverter(inObject);
}
else

if (theObject)
{
NSError *theError = NULL;
theData = [super serializeObject:theObject error:&theError];
if (theData != NULL)
if ([theObject isKindOfClass:[NSData class]])
{
theData = theObject;
break;
}
else
{
NSError *theError = NULL;
theData = [super serializeObject:theObject error:&theError];
if (theData != NULL)
{
break;
}
}
}
}
}
}

if (theData == NULL)
{
theData = [super serializeObject:inObject error:outError];
}
}

if (theData == NULL)
{
theData = [super serializeObject:inObject error:outError];
}

return(theData);
}

return(theData);
}

@end
96 changes: 48 additions & 48 deletions Source/Extensions/CDataScanner_Extensions.m
Expand Up @@ -64,72 +64,72 @@ - (BOOL)scanCStyleComment:(NSString **)outComment
}

- (BOOL)scanCPlusPlusStyleComment:(NSString **)outComment
{
if ([self scanString:@"//" intoString:NULL] == YES)
{
unichar theCharacters[] = { LF, FF, CR, NEL, LS, PS, };
NSCharacterSet *theLineBreaksCharacterSet = [NSCharacterSet characterSetWithCharactersInString:[NSString stringWithCharacters:theCharacters length:sizeof(theCharacters) / sizeof(*theCharacters)]];
{
if ([self scanString:@"//" intoString:NULL] == YES)
{
unichar theCharacters[] = { LF, FF, CR, NEL, LS, PS, };
NSCharacterSet *theLineBreaksCharacterSet = [NSCharacterSet characterSetWithCharactersInString:[NSString stringWithCharacters:theCharacters length:sizeof(theCharacters) / sizeof(*theCharacters)]];

NSString *theComment = NULL;
[self scanUpToCharactersFromSet:theLineBreaksCharacterSet intoString:&theComment];
[self scanCharactersFromSet:theLineBreaksCharacterSet intoString:NULL];
NSString *theComment = NULL;
[self scanUpToCharactersFromSet:theLineBreaksCharacterSet intoString:&theComment];
[self scanCharactersFromSet:theLineBreaksCharacterSet intoString:NULL];

if (outComment != NULL)
*outComment = theComment;
if (outComment != NULL)
*outComment = theComment;

return(YES);
}
else
{
return(NO);
}
}
return(YES);
}
else
{
return(NO);
}
}

- (NSUInteger)lineOfScanLocation
{
NSUInteger theLine = 0;
for (const u_int8_t *C = start; C < current; ++C)
{
// TODO: JIW What about MS-DOS line endings you bastard! (Also other unicode line endings)
if (*C == '\n' || *C == '\r')
NSUInteger theLine = 0;
for (const u_int8_t *C = start; C < current; ++C)
{
++theLine;
// TODO: JIW What about MS-DOS line endings you bastard! (Also other unicode line endings)
if (*C == '\n' || *C == '\r')
{
++theLine;
}
}
return(theLine);
}
return(theLine);
}

- (NSDictionary *)userInfoForScanLocation
{
NSUInteger theLine = 0;
const u_int8_t *theLineStart = start;
for (const u_int8_t *C = start; C < current; ++C)
{
if (*C == '\n' || *C == '\r')
NSUInteger theLine = 0;
const u_int8_t *theLineStart = start;
for (const u_int8_t *C = start; C < current; ++C)
{
theLineStart = C - 1;
++theLine;
if (*C == '\n' || *C == '\r')
{
theLineStart = C - 1;
++theLine;
}
}
}

NSUInteger theCharacter = current - theLineStart;
NSUInteger theCharacter = current - theLineStart;

NSRange theStartRange = NSIntersectionRange((NSRange){ .location = MAX((NSInteger)self.scanLocation - 20, 0), .length = 20 + (NSInteger)self.scanLocation - 20 }, (NSRange){ .location = 0, .length = self.data.length });
NSRange theEndRange = NSIntersectionRange((NSRange){ .location = self.scanLocation, .length = 20 }, (NSRange){ .location = 0, .length = self.data.length });
NSRange theStartRange = NSIntersectionRange((NSRange){ .location = MAX((NSInteger)self.scanLocation - 20, 0), .length = 20 + (NSInteger)self.scanLocation - 20 }, (NSRange){ .location = 0, .length = self.data.length });
NSRange theEndRange = NSIntersectionRange((NSRange){ .location = self.scanLocation, .length = 20 }, (NSRange){ .location = 0, .length = self.data.length });


NSString *theSnippet = [NSString stringWithFormat:@"%@!HERE>!%@",
[[[NSString alloc] initWithData:[self.data subdataWithRange:theStartRange] encoding:NSUTF8StringEncoding] autorelease],
[[[NSString alloc] initWithData:[self.data subdataWithRange:theEndRange] encoding:NSUTF8StringEncoding] autorelease]
];
NSString *theSnippet = [NSString stringWithFormat:@"%@!HERE>!%@",
[[[NSString alloc] initWithData:[self.data subdataWithRange:theStartRange] encoding:NSUTF8StringEncoding] autorelease],
[[[NSString alloc] initWithData:[self.data subdataWithRange:theEndRange] encoding:NSUTF8StringEncoding] autorelease]
];

NSDictionary *theUserInfo = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithUnsignedInteger:theLine], @"line",
[NSNumber numberWithUnsignedInteger:theCharacter], @"character",
[NSNumber numberWithUnsignedInteger:self.scanLocation], @"location",
theSnippet, @"snippet",
NULL];
return(theUserInfo);
}
NSDictionary *theUserInfo = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithUnsignedInteger:theLine], @"line",
[NSNumber numberWithUnsignedInteger:theCharacter], @"character",
[NSNumber numberWithUnsignedInteger:self.scanLocation], @"location",
theSnippet, @"snippet",
NULL];
return(theUserInfo);
}

@end

0 comments on commit 2c53d73

Please sign in to comment.