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

Merge "three" branch to master #83

Merged
merged 28 commits into from
Apr 15, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
76ed3e7
Fix missing rootViewController in iOS demo app.
timburks Apr 24, 2016
29d5c13
Expand major classes and categories into separate files.
timburks Apr 25, 2016
f01d0bb
Expand bridging classes into separate files.
timburks Apr 25, 2016
9806965
Restructure some includes.
timburks Apr 25, 2016
4d37d30
Modernization
ksjogo Jul 13, 2016
6423eb0
arm64 checks
ksjogo Jul 14, 2016
a5f8592
add B return type
ksjogo Jul 14, 2016
0d8c3b3
fix types B l q
ksjogo Jul 14, 2016
d42b605
ignore system operator on iOS for the moment
ksjogo Jul 15, 2016
a85b01b
fix init warning
ksjogo Jul 15, 2016
b054146
xcode proj setup
ksjogo Jul 15, 2016
ddfca81
newer ffi
ksjogo Jul 15, 2016
68e1e3c
added shieds for quasiquote nesting
ksjogo Jul 15, 2016
7b1bd28
fallback for synthesized _ivars
ksjogo Jul 15, 2016
455cd81
move inheriitedByClass to later stage
ksjogo Jul 18, 2016
69fbcff
disabe nuhandlers and add simple cblock test in nuapp
ksjogo Jul 18, 2016
52e5c71
fix os x
ksjogo Jul 21, 2016
30946e5
set ios deployment target to 7.0
ksjogo Jul 24, 2016
2b56f23
updated libffi
ksjogo Mar 30, 2017
9c149fb
Fixed all compile time warnigns as of Xcode 8.3.1
Apr 13, 2017
8a487f6
Used more modern NSNumber literals to make code less verbose.
Apr 13, 2017
7a2dc39
Used -UTF8String to make the code less verbose.
Apr 13, 2017
56d2f79
Replaced all occurrences of (id)[NSNull null] with Nu__null for brevi…
Apr 13, 2017
c32f271
Merge pull request #82 from ksjogo/three
timburks Apr 13, 2017
be0d367
Set Nu__null = [NSNull null]
timburks Apr 13, 2017
ce824cd
Fix compiler warnings about array type and a self-assigned variable.
timburks Apr 13, 2017
caa19df
remove ios readline include
ksjogo Apr 14, 2017
5e54206
Merge pull request #84 from ksjogo/three
timburks Apr 14, 2017
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
Prev Previous commit
Next Next commit
Used -UTF8String to make the code less verbose.
  • Loading branch information
Dirk Theisen authored and ksjogo committed Apr 13, 2017
commit 7a2dc39c46dfe94f9a6cb5914d332a2836a081e9
2 changes: 1 addition & 1 deletion objc/NSBundle+Nu.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ - (id) loadNuFile:(NSString *) nuFileName withContext:(NSMutableDictionary *) co
if (string) {
NuSymbolTable *symbolTable = [context objectForKey:SYMBOLS_KEY];
id parser = [context lookupObjectForKey:[symbolTable symbolWithString:@"_parser"]];
id body = [parser parse:string asIfFromFilename:[fileName cStringUsingEncoding:NSUTF8StringEncoding]];
id body = [parser parse:string asIfFromFilename:[fileName UTF8String]];
[body evalWithContext:context];
return [symbolTable symbolWithString:@"t"];
}
Expand Down
4 changes: 2 additions & 2 deletions objc/NSData+Nu.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ + (NSData *) dataWithShellCommand:(NSString *) command standardInput:(id) input
else {
fullCommand = [NSString stringWithFormat:@"%@ > %@", command, outputFileName];
}
const char *commandString = [fullCommand cStringUsingEncoding:NSUTF8StringEncoding];
const char *commandString = [fullCommand UTF8String];
int result = system(commandString) >> 8; // this needs an explanation
if (!result)
returnValue = [NSData dataWithContentsOfFile:outputFileName];
system([[NSString stringWithFormat:@"rm -f %@ %@", inputFileName, outputFileName] cStringUsingEncoding:NSUTF8StringEncoding]);
system([[NSString stringWithFormat:@"rm -f %@ %@", inputFileName, outputFileName] UTF8String]);
}
free(input_template);
free(output_template);
Expand Down
8 changes: 4 additions & 4 deletions objc/NSFileManager+Nu.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ + (id) creationTimeForFileNamed:(NSString *) filename
{
if (!filename)
return nil;
const char *path = [[filename stringByExpandingTildeInPath] cStringUsingEncoding:NSUTF8StringEncoding];
const char *path = [[filename stringByExpandingTildeInPath] UTF8String];
struct stat sb;
int result = stat(path, &sb);
if (result == -1) {
Expand All @@ -41,7 +41,7 @@ + (id) modificationTimeForFileNamed:(NSString *) filename
{
if (!filename)
return nil;
const char *path = [[filename stringByExpandingTildeInPath] cStringUsingEncoding:NSUTF8StringEncoding];
const char *path = [[filename stringByExpandingTildeInPath] UTF8String];
struct stat sb;
int result = stat(path, &sb);
if (result == -1) {
Expand All @@ -54,7 +54,7 @@ + (int) directoryExistsNamed:(NSString *) filename
{
if (!filename)
return NO;
const char *path = [[filename stringByExpandingTildeInPath] cStringUsingEncoding:NSUTF8StringEncoding];
const char *path = [[filename stringByExpandingTildeInPath] UTF8String];
struct stat sb;
int result = stat(path, &sb);
if (result == -1) {
Expand All @@ -67,7 +67,7 @@ + (int) fileExistsNamed:(NSString *) filename
{
if (!filename)
return NO;
const char *path = [[filename stringByExpandingTildeInPath] cStringUsingEncoding:NSUTF8StringEncoding];
const char *path = [[filename stringByExpandingTildeInPath] UTF8String];
struct stat sb;
int result = stat(path, &sb);
if (result == -1) {
Expand Down
28 changes: 14 additions & 14 deletions objc/NSObject+Nu.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ - (NuSelectorCache *) lookupSymbol:(NuSymbol *)childSymbol
if (!child) {
child = [[[NuSelectorCache alloc] initWithSymbol:childSymbol parent:self] autorelease];
NSString *selectorString = [child selectorName];
[child setSelector:sel_registerName([selectorString cStringUsingEncoding:NSUTF8StringEncoding])];
[child setSelector:sel_registerName([selectorString UTF8String])];
[children setValue:child forKey:(id)childSymbol];
}
return child;
Expand Down Expand Up @@ -176,7 +176,7 @@ - (id) sendMessage:(id)cdr withContext:(NSMutableDictionary *)context
cursor = [cursor cdr];
}
}
// sel = sel_getUid([selectorString cStringUsingEncoding:NSUTF8StringEncoding]);
// sel = sel_getUid([selectorString UTF8String]);
sel = [selectorCache selector];
}

Expand Down Expand Up @@ -298,7 +298,7 @@ - (id) handleUnknownMessage:(id) message withContext:(NSMutableDictionary *) con
cursor = [cursor cdr];
}
}
// sel = sel_getUid([selectorString cStringUsingEncoding:NSUTF8StringEncoding]);
// sel = sel_getUid([selectorString UTF8String]);
sel = [selectorCache selector];
}

Expand Down Expand Up @@ -380,11 +380,11 @@ - (id) handleUnknownMessage:(id) message withContext:(NSMutableDictionary *) con

- (id) valueForIvar:(NSString *) name
{
Ivar v = class_getInstanceVariable([self class], [name cStringUsingEncoding:NSUTF8StringEncoding]);
Ivar v = class_getInstanceVariable([self class], [name UTF8String]);

if (!v) {
//check if a _variable was synthesized
v = class_getInstanceVariable([self class], [[@"_" stringByAppendingString:name] cStringUsingEncoding:NSUTF8StringEncoding]);
v = class_getInstanceVariable([self class], [[@"_" stringByAppendingString:name] UTF8String]);
}

if (!v) {
Expand All @@ -408,11 +408,11 @@ - (id) valueForIvar:(NSString *) name

- (BOOL) hasValueForIvar:(NSString *) name
{
Ivar v = class_getInstanceVariable([self class], [name cStringUsingEncoding:NSUTF8StringEncoding]);
Ivar v = class_getInstanceVariable([self class], [name UTF8String]);

if (!v) {
//check if a _variable was synthesized
v = class_getInstanceVariable([self class], [[@"_" stringByAppendingString:name] cStringUsingEncoding:NSUTF8StringEncoding]);
v = class_getInstanceVariable([self class], [[@"_" stringByAppendingString:name] UTF8String]);
}

if (!v) {
Expand All @@ -437,10 +437,10 @@ - (BOOL) hasValueForIvar:(NSString *) name

- (void) setValue:(id) value forIvar:(NSString *)name
{
Ivar v = class_getInstanceVariable([self class], [name cStringUsingEncoding:NSUTF8StringEncoding]);
Ivar v = class_getInstanceVariable([self class], [name UTF8String]);
if (!v) {
//check if a _variable was synthesized
v = class_getInstanceVariable([self class], [[@"_" stringByAppendingString:name] cStringUsingEncoding:NSUTF8StringEncoding]);
v = class_getInstanceVariable([self class], [[@"_" stringByAppendingString:name] UTF8String]);
}
if (!v) {
NSMutableDictionary *sparseIvars = [self associatedObjectForKey:@"__nuivars"];
Expand Down Expand Up @@ -524,10 +524,10 @@ + (NSArray *) instanceVariableNames

+ (NSString *) signatureForIvar:(NSString *)name
{
Ivar v = class_getInstanceVariable([self class], [name cStringUsingEncoding:NSUTF8StringEncoding]);
Ivar v = class_getInstanceVariable([self class], [name UTF8String]);
if (!v) {
//check if a _variable was synthesized
v = class_getInstanceVariable([self class], [[@"_" stringByAppendingString:name] cStringUsingEncoding:NSUTF8StringEncoding]);
v = class_getInstanceVariable([self class], [[@"_" stringByAppendingString:name] UTF8String]);
}
return [NSString stringWithCString:ivar_getTypeEncoding(v) encoding:NSUTF8StringEncoding];
}
Expand All @@ -540,7 +540,7 @@ + (id) inheritedByClass:(NuClass *) newClass
+ (id) createSubclassNamed:(NSString *) subclassName
{
Class c = [self class];
const char *name = [subclassName cStringUsingEncoding:NSUTF8StringEncoding];
const char *name = [subclassName UTF8String];

// does the class already exist?
Class s = objc_getClass(name);
Expand Down Expand Up @@ -580,7 +580,7 @@ + (BOOL) copyInstanceMethod:(NSString *) methodName fromClass:(NuClass *)prototy
{
Class thisClass = [self class];
Class otherClass = [prototypeClass wrappedClass];
const char *method_name_str = [methodName cStringUsingEncoding:NSUTF8StringEncoding];
const char *method_name_str = [methodName UTF8String];
SEL selector = sel_registerName(method_name_str);
BOOL result = nu_copyInstanceMethod(thisClass, otherClass, selector);
return result;
Expand Down Expand Up @@ -665,7 +665,7 @@ - (id) set:(NuCell *) propertyList
id value = [[cursor cdr] car];
id label = ([key isKindOfClass:[NuSymbol class]] && [key isLabel]) ? [key labelName] : key;
if ([label isEqualToString:@"action"] && [self respondsToSelector:@selector(setAction:)]) {
SEL selector = sel_registerName([value cStringUsingEncoding:NSUTF8StringEncoding]);
SEL selector = sel_registerName([value UTF8String]);
[(id<NuCanSetAction>) self setAction:selector];
}
else {
Expand Down
6 changes: 3 additions & 3 deletions objc/Nu.m
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ int NuMain(int argc, const char *argv[])
NSString *main_nu = [NSString stringWithContentsOfFile:main_path encoding:NSUTF8StringEncoding error:NULL];
if (main_nu) {
NuParser *parser = [Nu sharedParser];
id script = [parser parse:main_nu asIfFromFilename:[main_nu cStringUsingEncoding:NSUTF8StringEncoding]];
id script = [parser parse:main_nu asIfFromFilename:[main_nu UTF8String]];
[parser eval:script];
[parser release];
return 0;
Expand Down Expand Up @@ -214,7 +214,7 @@ int NuMain(int argc, const char *argv[])
}
@catch (NuException* nuException)
{
printf("%s\n", [[nuException dump] cStringUsingEncoding:NSUTF8StringEncoding]);
printf("%s\n", [[nuException dump] UTF8String]);
}
@catch (id exception)
{
Expand Down Expand Up @@ -402,7 +402,7 @@ + (BOOL) loadNuFile:(NSString *) fileName fromBundleWithIdentifier:(NSString *)
NSString *fileNu = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:NULL];
if (fileNu) {
NuParser *parser = [Nu sharedParser];
id script = [parser parse:fileNu asIfFromFilename:[filePath cStringUsingEncoding:NSUTF8StringEncoding]];
id script = [parser parse:fileNu asIfFromFilename:[filePath UTF8String]];
if (!context) context = [parser context];
[script evalWithContext:context];
success = YES;
Expand Down
12 changes: 6 additions & 6 deletions objc/NuBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ int set_objc_value_from_nu_value(void *objc_value, id nu_value, const char *type
*((SEL *) objc_value) = 0;
return NO;
}
const char *selectorName = [nu_value cStringUsingEncoding:NSUTF8StringEncoding];
const char *selectorName = [nu_value UTF8String];
if (selectorName) {
*((SEL *) objc_value) = sel_registerName(selectorName);
return NO;
Expand Down Expand Up @@ -659,7 +659,7 @@ int set_objc_value_from_nu_value(void *objc_value, id nu_value, const char *type
char **array = (char **) malloc (array_size * sizeof(char *));
int i;
for (i = 0; i < array_size; i++) {
array[i] = strdup([[nu_value objectAtIndex:i] cStringUsingEncoding:NSUTF8StringEncoding]);
array[i] = strdup([[nu_value objectAtIndex:i] UTF8String]);
}
*((char ***) objc_value) = array;
return NO;
Expand Down Expand Up @@ -690,7 +690,7 @@ int set_objc_value_from_nu_value(void *objc_value, id nu_value, const char *type

case '*':
{
*((char **) objc_value) = (char*)[[nu_value stringValue] cStringUsingEncoding:NSUTF8StringEncoding];
*((char **) objc_value) = (char*)[[nu_value stringValue] UTF8String];
return NO;
}

Expand Down Expand Up @@ -1257,8 +1257,8 @@ static IMP construct_method_handler(SEL sel, NuBlock *block, const char *signatu

id add_method_to_class(Class c, NSString *methodName, NSString *signature, NuBlock *block)
{
const char *method_name_str = [methodName cStringUsingEncoding:NSUTF8StringEncoding];
const char *signature_str = [signature cStringUsingEncoding:NSUTF8StringEncoding];
const char *method_name_str = [methodName UTF8String];
const char *signature_str = [signature UTF8String];
SEL selector = sel_registerName(method_name_str);

//NuSymbolTable *symbolTable = [[block context] objectForKey:SYMBOLS_KEY];
Expand Down Expand Up @@ -1568,7 +1568,7 @@ id help_add_method_to_class(Class classToExtend, id cdr, NSMutableDictionary *co

if ((returnType == Nu__null) || ([argumentTypes length] < [argumentNames length])) {
// look up the signature
SEL selector = sel_registerName([methodName cStringUsingEncoding:NSUTF8StringEncoding]);
SEL selector = sel_registerName([methodName UTF8String]);
NSMethodSignature *methodSignature = [classToExtend instanceMethodSignatureForSelector:selector];

if (!methodSignature)
Expand Down
2 changes: 1 addition & 1 deletion objc/NuBridgeSupport.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ @implementation NuBridgeSupport
+ (void)importLibrary:(NSString *) libraryPath
{
//NSLog(@"importing library %@", libraryPath);
dlopen([libraryPath cStringUsingEncoding:NSUTF8StringEncoding], RTLD_LAZY | RTLD_GLOBAL);
dlopen([libraryPath UTF8String], RTLD_LAZY | RTLD_GLOBAL);
}

+ (void)importFramework:(NSString *) framework fromPath:(NSString *) path intoDictionary:(NSMutableDictionary *) BridgeSupport
Expand Down
4 changes: 2 additions & 2 deletions objc/NuBridgedConstant.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ @implementation NuBridgedConstant

+ (id) constantWithName:(NSString *) name signature:(NSString *) signature
{
const char *constant_name = [name cStringUsingEncoding:NSUTF8StringEncoding];
const char *constant_name = [name UTF8String];
void *constant = dlsym(RTLD_DEFAULT, constant_name);
if (!constant) {
NSLog(@"%s", dlerror());
NSLog(@"If you are using a release build, try rebuilding with the KEEP_PRIVATE_EXTERNS variable set.");
NSLog(@"In Xcode, check the 'Preserve Private External Symbols' checkbox.");
return nil;
}
return get_nu_value_from_objc_value(constant, [signature cStringUsingEncoding:NSUTF8StringEncoding]);
return get_nu_value_from_objc_value(constant, [signature UTF8String]);
}

@end
6 changes: 3 additions & 3 deletions objc/NuBridgedFunction.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ - (void) dealloc

- (NuBridgedFunction *) initWithName:(NSString *)n signature:(NSString *)s
{
name = strdup([n cStringUsingEncoding:NSUTF8StringEncoding]);
signature = strdup([s cStringUsingEncoding:NSUTF8StringEncoding]);
name = strdup([n UTF8String]);
signature = strdup([s UTF8String]);
function = dlsym(RTLD_DEFAULT, name);
if (!function) {
[NSException raise:@"NuCantFindBridgedFunction"
Expand All @@ -43,7 +43,7 @@ - (NuBridgedFunction *) initWithName:(NSString *)n signature:(NSString *)s

+ (NuBridgedFunction *) functionWithName:(NSString *)name signature:(NSString *)signature
{
const char *function_name = [name cStringUsingEncoding:NSUTF8StringEncoding];
const char *function_name = [name UTF8String];
void *function = dlsym(RTLD_DEFAULT, function_name);
if (!function) {
[NSException raise:@"NuCantFindBridgedFunction"
Expand Down
14 changes: 7 additions & 7 deletions objc/NuClass.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ @implementation NuClass

+ (NuClass *) classWithName:(NSString *)string
{
const char *name = [string cStringUsingEncoding:NSUTF8StringEncoding];
const char *name = [string UTF8String];
Class class = objc_getClass(name);
if (class) {
return [[[self alloc] initWithClass:class] autorelease];
Expand All @@ -51,7 +51,7 @@ + (NuClass *) classWithClass:(Class) class

- (id) initWithClassNamed:(NSString *) string
{
const char *name = [string cStringUsingEncoding:NSUTF8StringEncoding];
const char *name = [string UTF8String];
Class class = objc_getClass(name);
return [self initWithClass: class];
}
Expand Down Expand Up @@ -159,7 +159,7 @@ - (NSComparisonResult) compare:(NuClass *) anotherClass

- (NuMethod *) classMethodWithName:(NSString *) methodName
{
const char *methodNameString = [methodName cStringUsingEncoding:NSUTF8StringEncoding];
const char *methodNameString = [methodName UTF8String];
NuMethod *method = Nu__null;
unsigned int method_count;
Method *method_list = class_copyMethodList(object_getClass([self wrappedClass]), &method_count);
Expand All @@ -175,7 +175,7 @@ - (NuMethod *) classMethodWithName:(NSString *) methodName

- (NuMethod *) instanceMethodWithName:(NSString *) methodName
{
const char *methodNameString = [methodName cStringUsingEncoding:NSUTF8StringEncoding];
const char *methodNameString = [methodName UTF8String];
NuMethod *method = Nu__null;
unsigned int method_count;
Method *method_list = class_copyMethodList([self wrappedClass], &method_count);
Expand Down Expand Up @@ -204,7 +204,7 @@ - (id) addClassMethod:(NSString *)methodName signature:(NSString *)signature bod
- (id) addInstanceVariable:(NSString *)variableName signature:(NSString *)signature
{
//NSLog(@"adding instance variable %@", variableName);
nu_class_addInstanceVariable_withSignature(c, [variableName cStringUsingEncoding:NSUTF8StringEncoding], [signature cStringUsingEncoding:NSUTF8StringEncoding]);
nu_class_addInstanceVariable_withSignature(c, [variableName UTF8String], [signature UTF8String]);
return Nu__null;
}

Expand Down Expand Up @@ -263,13 +263,13 @@ - (NSArray *) instanceVariableNames {
- (BOOL) addPropertyWithName:(NSString *) name {
const objc_property_attribute_t attributes[10];
unsigned int attributeCount = 0;
return class_addProperty(c, [name cStringUsingEncoding:NSUTF8StringEncoding],
return class_addProperty(c, [name UTF8String],
attributes,
attributeCount);
}

- (NuProperty *) propertyWithName:(NSString *) name {
objc_property_t property = class_getProperty(c, [name cStringUsingEncoding:NSUTF8StringEncoding]);
objc_property_t property = class_getProperty(c, [name UTF8String]);

return [NuProperty propertyWithProperty:(objc_property_t) property];
}
Expand Down
Loading