Skip to content

Commit

Permalink
project and folder name change
Browse files Browse the repository at this point in the history
  • Loading branch information
guidosabatini-sysdata committed May 31, 2017
1 parent 3b48146 commit 0aabf52
Show file tree
Hide file tree
Showing 43 changed files with 3,042 additions and 295 deletions.
4 changes: 2 additions & 2 deletions Podfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'ResourceObjC' do
target 'R.objc' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!

# Pods for ResourceObjC
# Pods for R.objc
pod 'XMLDictionary'

end
2 changes: 1 addition & 1 deletion Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ DEPENDENCIES:
SPEC CHECKSUMS:
XMLDictionary: fa07b6ff422b3a91d47a5de9bc82e3fc04fbd167

PODFILE CHECKSUM: 974fdd34494953b5c4ed7ab0789b6a631f97e468
PODFILE CHECKSUM: a2f119c83e594032e0be99619217b618ed280f32

COCOAPODS: 1.2.1
2 changes: 1 addition & 1 deletion Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

298 changes: 149 additions & 149 deletions Pods/Pods.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions Pods/Target Support Files/Pods-R.objc/Pods-R.objc-dummy.m

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
BuildableIdentifier = "primary"
BlueprintIdentifier = "06803EAC1ED5BDED0006208A"
BuildableName = "Robjc"
BlueprintName = "ResourceObjC"
ReferencedContainer = "container:ResourceObjC.xcodeproj">
BlueprintName = "R.objc"
ReferencedContainer = "container:R.objc.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
Expand All @@ -34,8 +34,8 @@
BuildableIdentifier = "primary"
BlueprintIdentifier = "06803EAC1ED5BDED0006208A"
BuildableName = "Robjc"
BlueprintName = "ResourceObjC"
ReferencedContainer = "container:ResourceObjC.xcodeproj">
BlueprintName = "R.objc"
ReferencedContainer = "container:R.objc.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
Expand All @@ -57,24 +57,10 @@
BuildableIdentifier = "primary"
BlueprintIdentifier = "06803EAC1ED5BDED0006208A"
BuildableName = "Robjc"
BlueprintName = "ResourceObjC"
ReferencedContainer = "container:ResourceObjC.xcodeproj">
BlueprintName = "R.objc"
ReferencedContainer = "container:R.objc.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<CommandLineArguments>
<CommandLineArgument
argument = "--sysdata"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "-p"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "~/Documents/R.objc/ResourceObjCTest/ResourceObjCTest"
isEnabled = "YES">
</CommandLineArgument>
</CommandLineArguments>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
Expand All @@ -90,8 +76,8 @@
BuildableIdentifier = "primary"
BlueprintIdentifier = "06803EAC1ED5BDED0006208A"
BuildableName = "Robjc"
BlueprintName = "ResourceObjC"
ReferencedContainer = "container:ResourceObjC.xcodeproj">
BlueprintName = "R.objc"
ReferencedContainer = "container:R.objc.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
Expand Down
10 changes: 10 additions & 0 deletions R.objc.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions R.objc/Sources/BaseGenerator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2016 Sysdata Digital
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#import <Foundation/Foundation.h>
#import "ResourceFinder.h"
#import "Placeholders.h"
#import "CommonUtils.h"
#import "GeneratedStructures.h"

#define END_CONTEXT @"@end\n\n"

@protocol GeneratorProtocol <NSObject>

- (NSString*) className;
- (NSString*) propertyName;
- (BOOL)generateResourceFileWithError:(NSError**)error;

@end

@interface BaseGenerator : NSObject <GeneratorProtocol>

@property (nonatomic, readonly) ResourceFinder *finder;
@property (nonatomic, strong) RClass *clazz;
@property (nonatomic, strong) NSMutableArray<RClass*>* otherClasses;


- (instancetype)initWithResourceFinder:(ResourceFinder*)finder;

- (NSString*)resourceFileHeaderPath;
- (NSString*)resourceFileImplementationPath;

- (BOOL)writeStringInRFilesWithError:(NSError *__autoreleasing *)error;
@end
108 changes: 108 additions & 0 deletions R.objc/Sources/BaseGenerator.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// Copyright 2016 Sysdata Digital
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#import "BaseGenerator.h"

@implementation BaseGenerator

- (instancetype)initWithResourceFinder:(ResourceFinder *)finder
{
self = [super init];
if (self)
{
_finder = finder;
_clazz = [[RClass alloc] initWithName:self.className];
_otherClasses = [NSMutableArray new];
}
return self;
}

-(NSString *)className
{
return nil;
}

- (NSString *)propertyName
{
return nil;
}

- (BOOL)generateResourceFileWithError:(NSError *__autoreleasing *)error
{
return YES;
}

- (NSString *)resourceFileHeaderPath
{
return [self.finder.outputURL.path stringByAppendingPathComponent:@"R.h"];
}

- (NSString *)resourceFileImplementationPath
{
return [self.finder.outputURL.path stringByAppendingPathComponent:@"R.m"];
}

- (BOOL)writeStringInRFilesWithError:(NSError *__autoreleasing *)error
{
BOOL hResult = [self writeStringInInterfaceWithError:error];
BOOL mResult = [self writeStringInImplementationWithError:error];

return hResult && mResult;
}

- (BOOL)writeStringInInterfaceWithError:(NSError *__autoreleasing *)error
{
NSMutableString* content = [NSMutableString stringWithContentsOfFile:self.resourceFileHeaderPath encoding:NSUTF8StringEncoding error:error];
if (!content)
{
[CommonUtils log:@"Unable to read %@", self.resourceFileHeaderPath.lastPathComponent];
return NO;
}

NSMutableString* interface = [NSMutableString new];
for (RClass* c in self.otherClasses)
{
[interface appendString:[c generateInterfaceString]];
}

[interface appendString:[self.clazz generateInterfaceString]];

[content appendString:interface];

return [content writeToFile:self.resourceFileHeaderPath atomically:YES encoding:NSUTF8StringEncoding error:error];
}

- (BOOL)writeStringInImplementationWithError:(NSError *__autoreleasing *)error
{
NSMutableString* content = [NSMutableString stringWithContentsOfFile:self.resourceFileImplementationPath encoding:NSUTF8StringEncoding error:error];
if (!content)
{
[CommonUtils log:@"Unable to read %@", self.resourceFileImplementationPath.lastPathComponent];
return NO;
}

NSMutableString* implementation = [NSMutableString new];
for (RClass* c in self.otherClasses)
{
[implementation appendString:[c generateImplementationString]];
}

[implementation appendString:[self.clazz generateImplementationString]];

[content appendString:implementation];

return [content writeToFile:self.resourceFileImplementationPath atomically:YES encoding:NSUTF8StringEncoding error:error];
}

@end
25 changes: 25 additions & 0 deletions R.objc/Sources/CommonUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2016 Sysdata Digital
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#import <Foundation/Foundation.h>

@interface CommonUtils : NSObject

+ (void) logVerbose:(NSString *)format, ...;
+ (void) log:(NSString *)format, ...;
+ (NSString*)codableNameFromString:(NSString*)string;
+ (NSString*)classNameFromFilename:(NSString*)filename removingExtension:(NSString*)extension;
+ (NSString*)methodNameFromFilename:(NSString*)filename removingExtension:(NSString*)extension;

@end
104 changes: 104 additions & 0 deletions R.objc/Sources/CommonUtils.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
// Copyright 2016 Sysdata Digital
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#import "CommonUtils.h"
#import "Session.h"

@implementation CommonUtils

+ (void) logVerbose:(NSString *)format, ...
{
if ([[Session shared] isVerboseLoggingEnabled])
{
[self log:format];
}
}

+ (void) log:(NSString *)format, ...
{
va_list args;
if (format)
{
va_start(args, format);

[self log:format args:args];

va_end(args);
}
}

+ (void) log:(NSString *)format args:(va_list)args
{
if (format)
{
NSLogv(format, args);;
}
}

+ (NSString*)codableNameFromString:(NSString*)string
{
NSMutableCharacterSet* charactersEligible = [NSMutableCharacterSet alphanumericCharacterSet];
NSCharacterSet* charactersToRemove = [charactersEligible invertedSet];
NSArray* components = [string componentsSeparatedByCharactersInSet:charactersToRemove];
NSMutableArray* newComponents = [NSMutableArray new];
for (NSString* comp in components)
{
NSString* newComp = comp;
if (comp.length >= 2)
{
newComp = [NSString stringWithFormat:@"%@%@", [comp substringToIndex:1].uppercaseString, [comp substringFromIndex:1]];
}
[newComponents addObject:newComp];
}
NSString *strippedString = [newComponents componentsJoinedByString:@""];
if (strippedString.length >= 2)
{
strippedString = [NSString stringWithFormat:@"%@%@", [strippedString substringToIndex:1].lowercaseString, [strippedString substringFromIndex:1]];
}

NSRegularExpression* regExpression = [NSRegularExpression
regularExpressionWithPattern:@"^[0-9].*"
options:0
error:nil];

if ([regExpression numberOfMatchesInString:strippedString options:0 range:[strippedString rangeOfString:strippedString]] > 0)
{
strippedString = [NSString stringWithFormat:@"_%@", strippedString];
}
return strippedString;
}

+ (NSString *)classNameFromFilename:(NSString *)filename removingExtension:(NSString *)extension
{
NSString* retval = [NSString stringWithFormat:@"%@%@", [filename substringToIndex:1].uppercaseString, [filename substringFromIndex:1]];
if (extension.length > 0)
{
retval = [retval stringByReplacingOccurrencesOfString:extension withString:@""];
}
retval = [retval stringByReplacingOccurrencesOfString:@" " withString:@""];
return retval;
}

+ (NSString *)methodNameFromFilename:(NSString *)filename removingExtension:(NSString *)extension
{
NSString* retval = [NSString stringWithFormat:@"%@%@", [filename substringToIndex:1].lowercaseString, [filename substringFromIndex:1]];
if (extension.length > 0)
{
retval = [retval stringByReplacingOccurrencesOfString:extension withString:@""];
}
retval = [retval stringByReplacingOccurrencesOfString:@" " withString:@""];
return retval;
}

@end
Loading

0 comments on commit 0aabf52

Please sign in to comment.