Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PONSO - Type-safe, in-memory Plain Old NSObjects with relationships #60

Merged
merged 35 commits into from
Jun 4, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
2288475
- "Modernized" Xcode project a bit:
nikita-zhuk Jun 4, 2011
39e563c
- Fixed a compiler warning
nikita-zhuk Jun 4, 2011
34697d0
- Specified explicit source file encoding - we assume it's UTF-8. Thi…
nikita-zhuk Jun 4, 2011
a6556ec
- Fixed deprecation warnings - assume UTf-8
nikita-zhuk Jun 4, 2011
abaceea
- Deprecation warning fixes
nikita-zhuk Jun 4, 2011
d0c95f8
- Added parenthesis for logical "!= 0" comparison
nikita-zhuk Jun 4, 2011
2c5b8e7
- Deprecation warning fix
nikita-zhuk Jun 4, 2011
e231d33
- Added extra parenthesis for truth comparison
nikita-zhuk Jun 4, 2011
6040c2b
- Make sure that correct encoding is used when defining default start…
nikita-zhuk Jun 4, 2011
028ac58
- Added -Wall flag to enable the most important warnings
nikita-zhuk Jun 4, 2011
d2b6ff9
- Replaced CFUUID with NSProcessInfo's globallyUniqueString, - Fixed …
nikita-zhuk Jun 4, 2011
4716a9c
- Fixed memory leaks in MiscMerge
nikita-zhuk Jun 4, 2011
96786d4
Added support for the following momc options:
nikita-zhuk Jun 4, 2011
2cc83ab
- Fixed a bug which caused out-of-bounds index exception when code wa…
nikita-zhuk Jun 4, 2011
a4aa3b9
- Fixed a lot of NS(U)Integer issues which caused potential 64-bit in…
nikita-zhuk Jun 4, 2011
1f3a116
- Removed extra semicolons
nikita-zhuk Jun 4, 2011
eed19de
- Initial PONSO commit
nikita-zhuk Jun 4, 2011
0762a3e
- Added some Xcode4 user-specific stuff to .gitignore
nikita-zhuk Jun 4, 2011
8c6804e
- Include DAG support classes in mogenerator itself
nikita-zhuk Jun 4, 2011
7515cf3
- Removed xcuserstate
nikita-zhuk Jun 4, 2011
7104d99
- Ignore Xcode4 user-specific files
nikita-zhuk Jun 4, 2011
7d458b1
- Added the source for PONSO support classes
nikita-zhuk Jun 4, 2011
6145072
- Return all properties in arrays sorted by property name.
nikita-zhuk Jun 4, 2011
43579a2
- Moved generate.sh script
nikita-zhuk Jun 4, 2011
7f666c0
- Regenerated source files with mogenerator which maintains order
nikita-zhuk Jun 4, 2011
feb6ce5
- Fixed ponso's generate.sh script path
nikita-zhuk Jun 4, 2011
1b5673c
- Removed old sources
nikita-zhuk Jun 4, 2011
2f85dc5
- New sample data model
nikita-zhuk Jun 4, 2011
da7b182
- Ignore Xcode4 debugger metadata
nikita-zhuk Jun 4, 2011
db71df4
- Added a comment
nikita-zhuk Jun 4, 2011
ca39de1
- Added compiled binary of mogenerator for convenience
nikita-zhuk Jun 4, 2011
7b22234
- Added README about PONSO idea
nikita-zhuk Jun 4, 2011
f2687bd
- Added some details
nikita-zhuk Jun 4, 2011
1c8739b
- Removed userdata
nikita-zhuk Jun 4, 2011
63ed418
- Tweaked .gitignore file
nikita-zhuk Jun 4, 2011
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ dist
*.xcodeproj/*.mode*
*.xcodeproj/*.pbxuser
**/*.xcodeproj/*
!**/*.xcodeproj/project.pbxproj
!**/*.xcodeproj/project.pbxproj
/mogenerator.xcodeproj/project.xcworkspace/
/mogenerator.xcodeproj/xcuserdata/
/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/PonsoTest.xcodeproj/project.xcworkspace/xcuserdata/
/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/PonsoTest.xcodeproj/xcuserdata/
1 change: 0 additions & 1 deletion FoundationAdditions.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,5 @@ extern void Printf(NSString *format, ...);
- (BOOL)regularFileExistsAtPath:(NSString *)path;
- (NSString *)findFile:(NSString *)filename inSearchPath:(NSArray *)paths;
- (void)touchPath:(NSString *)filePath;
- (BOOL)deepCreateDirectoryAtPath:(NSString *)path attributes:(NSDictionary *)attributes;

@end
26 changes: 6 additions & 20 deletions FoundationAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
void ErrVPrintf(NSString *format, va_list arguments)
{
NSString *logString = [[NSString alloc] initWithFormat:format arguments:arguments];
fwrite([logString cString], 1, [logString cStringLength], stderr);
fwrite([logString cStringUsingEncoding:NSUTF8StringEncoding], 1, [logString lengthOfBytesUsingEncoding:NSUTF8StringEncoding], stderr);
if (![logString hasSuffix:@"\n"]) fputc('\n', stdout);
[logString release];
}
Expand All @@ -55,7 +55,7 @@ void ErrPrintf(NSString *format, ...)
void VPrintf(NSString *format, va_list arguments)
{
NSString *logString = [[NSString alloc] initWithFormat:format arguments:arguments];
fwrite([logString cString], 1, [logString cStringLength], stdout);
fwrite([logString cStringUsingEncoding:NSUTF8StringEncoding], 1, [logString lengthOfBytesUsingEncoding:NSUTF8StringEncoding], stdout);
if (![logString hasSuffix:@"\n"]) fputc('\n', stdout);
[logString release];
}
Expand Down Expand Up @@ -92,7 +92,7 @@ - (id)computeReversedArrayForKey:(NSString *) key
return [[self reversedArray] valueForKeyPath:key];
}

static int sortByName(id obj1, id obj2, void *context)
static NSInteger sortByName(id obj1, id obj2, void *context)
{
return [(NSString *)[obj1 valueForKey:@"name"] compare:[obj2 valueForKey:@"name"]];
}
Expand Down Expand Up @@ -143,7 +143,7 @@ - (NSArray *)arrayByMakingObjectsPerformSelector:(SEL)aSelector withObject:anObj
- (NSArray *)arrayByMakingObjectsPerformSelector:(SEL)aSelector withObject:anObject
withObject:anObject2
{
unsigned i, count = [self count];
NSUInteger i, count = [self count];
NSMutableArray *array = [NSMutableArray arrayWithCapacity:count];

for(i=0; i<count; i++)
Expand Down Expand Up @@ -223,7 +223,7 @@ - (BOOL)regularFileExistsAtPath:(NSString *)path

- (NSString *)findFile:(NSString *)filename inSearchPath:(NSArray *)paths
{
int i, count = [paths count];
NSInteger i, count = [paths count];

for (i=0; i<count; i++)
{
Expand All @@ -243,22 +243,8 @@ - (void)touchPath:(NSString *)filePath

attributes = [[NSMutableDictionary alloc] initWithCapacity:1];
[attributes setObject:[NSDate date] forKey:NSFileModificationDate];
[self changeFileAttributes:attributes atPath:filePath];
[self setAttributes:attributes ofItemAtPath:filePath error:nil];
[attributes release];
}

- (BOOL)deepCreateDirectoryAtPath:(NSString *)path attributes:(NSDictionary *)attributes
{
NSString *parent = [path stringByDeletingLastPathComponent];

if ([parent length] > 0 && ![self directoryExistsAtPath:parent])
{
// May want to ensure owner write permissions here...
if (![self deepCreateDirectoryAtPath:parent attributes:attributes])
return NO;
}

return [self createDirectoryAtPath:path attributes:attributes];
}

@end
4 changes: 2 additions & 2 deletions MiscMerge/KeyValue+MiscMerge.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ - (BOOL)hasMiscMergeKey:(NSString *)key

return (keySelector != NULL && [self respondsToSelector:keySelector]) ||
([[self class] accessInstanceVariablesDirectly] &&
class_getInstanceVariable([self class], [key cString]));
class_getInstanceVariable([self class], [key cStringUsingEncoding:NSUTF8StringEncoding]));
}

@end
Expand Down Expand Up @@ -117,4 +117,4 @@ static Ivar_t class_getInstanceVariable(Class aClass, const char *name)
return NULL;
}

#endif GNU_RUNTIME
#endif
4 changes: 2 additions & 2 deletions MiscMerge/MiscMergeCommand.m
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ - (BOOL)eatKeyWord:(NSString *)aKeyWord fromScanner:(NSScanner *)scanner
isOptional:(BOOL)optional
{
NSCharacterSet *letterSet = [NSCharacterSet letterCharacterSet];
int origLocation = [scanner scanLocation];
NSUInteger origLocation = [scanner scanLocation];
BOOL isAlphaKeyword = [aKeyWord length] > 0 && [letterSet characterIsMember:[aKeyWord characterAtIndex:0]];
BOOL wasCaseSensitive = [scanner caseSensitive];
BOOL foundKeyword;
Expand All @@ -124,7 +124,7 @@ - (BOOL)eatKeyWord:(NSString *)aKeyWord fromScanner:(NSScanner *)scanner
if (foundKeyword && isAlphaKeyword)
{
NSString *string = [scanner string];
int currLocation = [scanner scanLocation];
NSUInteger currLocation = [scanner scanLocation];

/* If we're at the end of the string, or the next char is not a letter, we're good. Otherwise abort. */
if (currLocation < [string length] &&
Expand Down
8 changes: 4 additions & 4 deletions MiscMerge/MiscMergeEngine.m
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ - (void)removeContextObject:(id)anObject
[contextStack removeObjectIdenticalTo:anObject];

if ( anObject == localSymbols ) {
int i;
NSInteger i;

localSymbols = nil;

Expand Down Expand Up @@ -466,7 +466,7 @@ - (MiscMergeTemplate *)template
"*/
- (void)setMainObject:(id)anObject
{
unsigned oldIndex = NSNotFound;
NSUInteger oldIndex = NSNotFound;

if (currentObject != nil)
{
Expand Down Expand Up @@ -569,7 +569,7 @@ - (MiscMergeCommandExitType)executeCommandBlock:(MiscMergeCommandBlock *)block
{
NSAutoreleasePool *localPool = [[NSAutoreleasePool alloc] init];
NSArray *commandArray = [block commandArray];
int i, count = [commandArray count];
NSInteger i, count = [commandArray count];
MiscMergeCommandExitType exitCode = MiscMergeCommandExitNormal;
/*
* Maintain the execution stack. This stack isn't being used at the
Expand Down Expand Up @@ -603,7 +603,7 @@ - (MiscMergeCommandExitType)executeCommandBlock:(MiscMergeCommandBlock *)block
"*/
- (id)valueForField:(NSString *)fieldName quoted:(int)quoted
{
int i;
NSInteger i;
id value = nil;
id prevValue = nil;
id returnValue = nil;
Expand Down
4 changes: 2 additions & 2 deletions MiscMerge/MiscMergeExpression.m
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ - (NSString *)nameDescription

- (NSString *)description
{
int index, count = [expressions count];
NSInteger index, count = [expressions count];
NSMutableString *string = [NSMutableString stringWithFormat:@"%@(", [self nameDescription]];

for ( index = 0; index < count; index++ ) {
Expand Down Expand Up @@ -525,7 +525,7 @@ - (NSArray *)evaluateAsListWithEngine:(MiscMergeEngine *)anEngine
NSEnumerator *enumerator = [expressions objectEnumerator];
MiscMergeExpression *expression;

while ( expression = (MiscMergeExpression *)[enumerator nextObject] ) {
while (( expression = (MiscMergeExpression *)[enumerator nextObject] )) {
[array addObject:[expression evaluateWithEngine:anEngine]];
}

Expand Down
4 changes: 2 additions & 2 deletions MiscMerge/MiscMergeFunctions.m
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ Class MMCommonAnscestorClass(id obj1, id obj2)
else {
NSCharacterSet *whitespaceSet = [NSCharacterSet whitespaceCharacterSet];
NSCharacterSet *newlineSet = [NSCharacterSet newlineCharacterSet];
int start = 0, end = [string length]-1;
int i;
NSInteger start = 0, end = [string length]-1;
NSInteger i;

for ( i = 0; i <= end; i++ ) {
unichar character = [string characterAtIndex:i];
Expand Down
6 changes: 3 additions & 3 deletions MiscMerge/MiscMergeTemplate.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ + (NSString *)defaultStartDelimiter
/* This works better for whatever reason. Due to some unknown pecularities,
a constant NSString doesn't work under Windows with Apple's
implementation. */
return [NSString stringWithCString:"�"];
return [NSString stringWithCString:"�" encoding:NSUTF8StringEncoding];
}

/*"
Expand All @@ -87,7 +87,7 @@ + (NSString *)defaultEndDelimiter
// return @")";
// return @"�";
/* This works better than a constant NSString for whatever reason. See above. */
return [NSString stringWithCString:"�"];
return [NSString stringWithCString:"�" encoding:NSUTF8StringEncoding];
}

/*" Creates a new, autoreleased MiscMergeTemplate. "*/
Expand Down Expand Up @@ -444,9 +444,9 @@ - (void)parseContentsOfFile:(NSString *)filename
"*/
- (void)parseString:(NSString *)string
{
NSMutableString *accumString = [[[NSMutableString alloc] init] autorelease];
NSAutoreleasePool *localPool = [[NSAutoreleasePool alloc] init];
NSScanner *scanner = [NSScanner scannerWithString:string];
NSMutableString *accumString = [[NSMutableString alloc] init];
NSString *currString;
int nestingLevel = 0;
int maxNestingLevel = 0;
Expand Down
6 changes: 3 additions & 3 deletions MiscMerge/NSScanner+MiscMerge.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ - (BOOL)scanString:(NSString *)aString
"*/
- (NSRange)remainingRange
{
unsigned location = [self scanLocation];
NSUInteger location = [self scanLocation];
return NSMakeRange(location, [[self string] length] - location);
}

Expand Down Expand Up @@ -84,7 +84,7 @@ - (void)skipPastSkipCharacters

- (BOOL)scanCharacter:(unichar)targetCharacter
{
unsigned scanLocation = [self scanLocation];
NSUInteger scanLocation = [self scanLocation];
NSString *myString = [self string];

[self skipPastSkipCharacters];
Expand All @@ -104,7 +104,7 @@ - (BOOL)scanCharacter:(unichar)targetCharacter

- (unichar)peekNextCharacter
{
unsigned scanLocation;
NSUInteger scanLocation;
NSString *myString;

[self skipPastSkipCharacters];
Expand Down
2 changes: 1 addition & 1 deletion MiscMerge/NSString+MiscAdditions.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ enum
/*" "Letter" manipulation "*/
- (NSString *)letterAtIndex:(unsigned)anIndex;
- (NSString *)firstLetter;
- (unsigned)letterCount;
- (NSUInteger)letterCount;

/*" Getting "words" "*/
- (NSArray *)wordArray;
Expand Down
26 changes: 13 additions & 13 deletions MiscMerge/NSString+MiscAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ - (NSString *)firstLetter
return [self letterAtIndex:0];
}

- (unsigned)letterCount
- (NSUInteger)letterCount
{
unsigned count = 0;
unsigned selfLength = [self length];
unsigned currIndex = 0;
NSUInteger count = 0;
NSUInteger selfLength = [self length];
NSUInteger currIndex = 0;
NSRange letterRange;

while (currIndex < selfLength)
Expand Down Expand Up @@ -227,7 +227,7 @@ - (NSString *)firstWord
}

static NSRange _nextSearchRange(NSString *string, unsigned mask,
NSRange *foundRange, unsigned lastIndex, unsigned firstIndex)
NSRange *foundRange, NSUInteger lastIndex, NSUInteger firstIndex)
{
/*
* The char range stuff is if we want to use
Expand All @@ -241,7 +241,7 @@ static NSRange _nextSearchRange(NSString *string, unsigned mask,

if (mask & NSBackwardsSearch)
{
unsigned endLocation;
NSUInteger endLocation;

if (mask & MiscOverlappingSearch)
{
Expand Down Expand Up @@ -282,7 +282,7 @@ static NSRange _nextSearchRange(NSString *string, unsigned mask,
NSRange foundRange;
NSRange betweenRange;
unsigned searchOptions = (mask & (NSCaseInsensitiveSearch|NSLiteralSearch));
unsigned selfLength = [self length];
NSUInteger selfLength = [self length];
NSMutableString *newString = [NSMutableString stringWithCapacity:selfLength];

mask &= ~NSBackwardsSearch;
Expand Down Expand Up @@ -347,7 +347,7 @@ static NSRange _nextSearchRange(NSString *string, unsigned mask,

if ([scanner scanCharactersFromSet:aSet intoString:&betweenString])
{
int i, count = [betweenString length];
NSInteger i, count = [betweenString length];
// int i, count = [betweenString letterCount];

for (i=0;i<count;i++)
Expand Down Expand Up @@ -376,7 +376,7 @@ static NSRange _nextSearchRange(NSString *string, unsigned mask,
if ([scanner scanCharactersFromSet:aSet intoString:&betweenString])
{
// int i, count = [betweenString length];
int i, count = [betweenString letterCount];
NSInteger i, count = [betweenString letterCount];

for (i=0;i<count;i++)
[stringArray addObject:replaceString];
Expand All @@ -403,7 +403,7 @@ - (unsigned)numOfString:(NSString *)aString range:(NSRange)range

- (unsigned)numOfString:(NSString *)aString options:(unsigned)mask range:(NSRange)range
{
unsigned lastIndex = NSMaxRange(range);
NSUInteger lastIndex = NSMaxRange(range);
unsigned stringCount = 0;
unsigned searchOptions = (mask & (NSCaseInsensitiveSearch|NSLiteralSearch));
NSRange searchRange;
Expand Down Expand Up @@ -441,7 +441,7 @@ - (NSRange)rangeOfString:(NSString *)aString occurrenceNum:(int)n range:(NSRange
- (NSRange)rangeOfString:(NSString *)aString options:(unsigned)mask
occurrenceNum:(int)n range:(NSRange)range
{
unsigned lastIndex = NSMaxRange(range);
NSUInteger lastIndex = NSMaxRange(range);
unsigned count = 0;
unsigned searchOptions = (mask & (~NSAnchoredSearch));
NSRange searchRange;
Expand All @@ -467,7 +467,7 @@ - (unsigned)numOfCharactersFromSet:(NSCharacterSet *)aSet

- (unsigned)numOfCharactersFromSet:(NSCharacterSet *)aSet range:(NSRange)range
{
unsigned lastIndex = NSMaxRange(range);
NSUInteger lastIndex = NSMaxRange(range);
NSRange searchRange = {range.location, lastIndex};
NSRange foundRange;
unsigned characterCount = 0;
Expand All @@ -487,7 +487,7 @@ - (unsigned)numOfCharactersFromSet:(NSCharacterSet *)aSet range:(NSRange)range

- (NSArray *)componentsSeparatedByCharactersFromSet:(NSCharacterSet *)aSet
{
unsigned selfLength = [self length];
NSUInteger selfLength = [self length];
NSRange searchRange = {0, selfLength};
NSRange betweenRange = {0, 0};
NSRange foundRange;
Expand Down
4 changes: 2 additions & 2 deletions MiscMerge/_MiscMergeCallCommand.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ - (BOOL)parseFromScanner:(NSScanner *)aScanner template:(MiscMergeTemplate *)tem
[self eatKeyWord:@"call" fromScanner:aScanner isOptional:NO];
procedureName = [[self getArgumentStringFromScanner:aScanner toEnd:NO] retain];

while (argName = [self getArgumentStringFromScanner:aScanner toEnd:NO quotes:&quotes])
while ((argName = [self getArgumentStringFromScanner:aScanner toEnd:NO quotes:&quotes]))
{
[argumentArray addObject:argName];
[quotedArray addObject:[NSNumber numberWithInt:quotes]];
Expand All @@ -63,7 +63,7 @@ - (MiscMergeCommandExitType)executeForMerge:(MiscMergeEngine *)aMerger
{
NSString *symbolName = [NSString stringWithFormat:@"_MiscMergeProcedure%@", procedureName];
_MiscMergeProcedureCommand *procCommand = [[aMerger userInfo] objectForKey:symbolName];
int i, count = [argumentArray count];
NSInteger i, count = [argumentArray count];
NSMutableArray *realArgArray = [NSMutableArray arrayWithCapacity:count];

if (procCommand == nil)
Expand Down
2 changes: 1 addition & 1 deletion MiscMerge/_MiscMergeDebugCommand.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ - (BOOL)parseFromScanner:(NSScanner *)aScanner template:(MiscMergeTemplate *)tem

- (MiscMergeCommandExitType)executeForMerge:(MiscMergeEngine *)aMerger
{
fwrite([theText cString], 1, [theText cStringLength], stderr);
fwrite([theText cStringUsingEncoding:NSUTF8StringEncoding], 1, [theText lengthOfBytesUsingEncoding:NSUTF8StringEncoding], stderr);
if (![theText hasSuffix:@"\n"])
fputc('\n', stderr);

Expand Down
2 changes: 1 addition & 1 deletion MiscMerge/_MiscMergeIncludeCommand.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ - (BOOL)parseFromScanner:(NSScanner *)aScanner template:(MiscMergeTemplate *)tem
resolvedFilename = [template resolveTemplateFilename:filename];

if ([resolvedFilename length] > 0)
fileString = [[NSString alloc] initWithContentsOfFile:resolvedFilename];
fileString = [[[NSString alloc] initWithContentsOfFile:resolvedFilename] autorelease];

if (fileString)
{
Expand Down
Loading