From 019c2f2920fbe9051691c35e61e2717935fe61de Mon Sep 17 00:00:00 2001 From: August Mueller Date: Thu, 9 Apr 2009 16:02:33 -0700 Subject: [PATCH] [FIXORS] Little bit o' code cleanup. --- example_scripts/Sketch.jstalk | 3 +- res/English.lproj/JSTDocument.xib | 70 +++++++++++------ src/JSTDocument.m | 120 ------------------------------ 3 files changed, 50 insertions(+), 143 deletions(-) diff --git a/example_scripts/Sketch.jstalk b/example_scripts/Sketch.jstalk index 9a64844..9a7e004 100644 --- a/example_scripts/Sketch.jstalk +++ b/example_scripts/Sketch.jstalk @@ -4,8 +4,7 @@ var sketch = [JSTalk application:"Sketch"]; var doc = [sketch orderedDocuments][0] var rectangle = [doc makeNewBox]; -[rectangle setWidth:100]; -[rectangle setHeight:100]; +[rectangle setSize:NSMakeSize(100, 100)]; [rectangle setXPosition:100]; [rectangle setYPosition:100]; diff --git a/res/English.lproj/JSTDocument.xib b/res/English.lproj/JSTDocument.xib index bbd687c..a46bb42 100644 --- a/res/English.lproj/JSTDocument.xib +++ b/res/English.lproj/JSTDocument.xib @@ -8,7 +8,7 @@ 353.00 YES - + YES @@ -123,20 +123,14 @@ WebURLsWithTitlesPboardType - {584, 238} + {584, 42} - dmFyIHNrZXRjaCA9IFtKU1RhbGsgYXBwbGljYXRpb246IlNrZXRjaCJdOwp2YXIgZG9jID0gW3NrZXRj -aCBvcmRlcmVkRG9jdW1lbnRzXVswXQp2YXIgcmVjdGFuZ2xlID0gW2RvYyBtYWtlTmV3Qm94XTsKClty -ZWN0YW5nbGUgc2V0V2lkdGg6MTAwXTsKW3JlY3RhbmdsZSBzZXRIZWlnaHQ6MTAwXTsKW3JlY3Rhbmds -ZSBzZXRYUG9zaXRpb246MTAwXTsKW3JlY3RhbmdsZSBzZXRZUG9zaXRpb246MTAwXTsKcmVjdGFuZ2xl -LndpZHRoID0gMjAwCnByaW50KHJlY3RhbmdsZS53aWR0aCgpKQpyZWN0YW5nbGUuc2l6ZSA9IG5ldyBO -U1NpemUoMjUwLCAxNTApCnZhciB3ID0gc2tldGNoLndpbmRvd3MoKVswXQpwcmludCgndz0nICsgdy5m -cmFtZSgpKQp3LmZyYW1lT3JpZ2luID0gbmV3IE5TUG9pbnQoMTAwLCAxMDApCnByaW50KCd3PScgKyB3 -LmZyYW1lKCkpCgo + dmFyIG1lc3NhZ2UgPSAiSGVsbG8gV29ybGQhIjsKCltbSlNUYWxrIGFwcGxpY2F0aW9uOiJKU1RhbGsg +RWRpdG9yIl0gZGlzcGxheURpYWxvZzptZXNzYWdlXTs YES @@ -147,14 +141,52 @@ LmZyYW1lKCkpCgo YES - - Helvetica - 1.200000e+01 + + Monaco + 1.000000e+01 16 4 - + + YES + + 2.800000e+01 + + + 5.600000e+01 + + + 8.400000e+01 + + + 1.120000e+02 + + + 1.400000e+02 + + + 1.680000e+02 + + + 1.960000e+02 + + + 2.240000e+02 + + + 2.520000e+02 + + + 2.800000e+02 + + + 3.080000e+02 + + + 3.360000e+02 + + @@ -322,11 +354,7 @@ LmZyYW1lKCkpCgo YES - - Monaco - 1.000000e+01 - 16 - + 4 @@ -700,8 +728,8 @@ LmZyYW1lKCkpCgo JSTTextView com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{391, 292}, {584, 452}} - {{391, 292}, {584, 452}} + {{485, 378}, {584, 452}} + {{485, 378}, {584, 452}} {{201, 387}, {507, 413}} diff --git a/src/JSTDocument.m b/src/JSTDocument.m index 76e68d0..58640d1 100644 --- a/src/JSTDocument.m +++ b/src/JSTDocument.m @@ -195,126 +195,6 @@ - (void) JSCocoa:(JSCocoaController*)controller hadError:(NSString*)error onLine } -/* -// -// JSCocoa : handle setting with callMethod -// object.width = 100 -// -> -// [object setWidth:100] -// -- (BOOL) JSCocoa:(JSCocoaController*)controller setProperty:(NSString*)propertyName ofObject:(id)object toValue:(JSValueRef)value inContext:(JSContextRef)ctx exception:(JSValueRef*)exception; -{ - // FIXME: this doesn't actually work with objc properties, and we can't always rely that this method will exist either... - // it should probably be moved up into the JSCocoa layer. - - NSString* setterName = [NSString stringWithFormat:@"set%@%@:", - [[propertyName substringWithRange:NSMakeRange(0,1)] capitalizedString], - [propertyName substringWithRange:NSMakeRange(1, [propertyName length]-1)]]; - - if ([self JSCocoa:controller callMethod:setterName ofObject:object argumentCount:1 arguments:&value inContext:ctx exception:exception]) { - return YES; - } - - return NO; -} - -// -// NSDistantObject call using NSInvocation -// -- (JSValueRef) JSCocoa:(JSCocoaController*)controller callMethod:(NSString*)methodName ofObject:(id)callee argumentCount:(int)argumentCount arguments:(JSValueRef*)arguments inContext:(JSContextRef)ctx exception:(JSValueRef*)exception -{ - SEL selector = NSSelectorFromString(methodName); - if (class_getInstanceMethod([callee class], selector) || class_getClassMethod([callee class], selector)) { - return nil; - } - - NSMethodSignature *signature = [callee methodSignatureForSelector:selector]; - - if (!signature) { - return nil; - } - - // we need to do all this for NSDistantObject , since JSCocoa doesn't handle it natively. - - NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; - [invocation setSelector:selector]; - - NSUInteger argIndex = 0; - while (argIndex < argumentCount) { - - id arg = 0x00; - - [JSCocoaFFIArgument unboxJSValueRef:arguments[argIndex] toObject:&arg inContext:ctx]; - - if ([arg isKindOfClass:[NSNumber class]]) { - - const char *type = [signature getArgumentTypeAtIndex:argIndex + 2]; - - if (strcmp(type, @encode(BOOL)) == 0) { - BOOL b = [arg boolValue]; - [invocation setArgument:&b atIndex:argIndex + 2]; - } - else if (strcmp(type, @encode(unsigned int)) == 0) { - unsigned int i = [arg unsignedIntValue]; - [invocation setArgument:&i atIndex:argIndex + 2]; - } - else if (strcmp(type, @encode(int)) == 0) { - int i = [arg intValue]; - [invocation setArgument:&i atIndex:argIndex + 2]; - } - else if (strcmp(type, @encode(unsigned long)) == 0) { - unsigned long l = [arg unsignedLongValue]; - [invocation setArgument:&l atIndex:argIndex + 2]; - } - else if (strcmp(type, @encode(long)) == 0) { - long l = [arg longValue]; - [invocation setArgument:&l atIndex:argIndex + 2]; - } - else if (strcmp(type, @encode(float)) == 0) { - float f = [arg floatValue]; - [invocation setArgument:&f atIndex:argIndex + 2]; - } - else if (strcmp(type, @encode(double)) == 0) { - double d = [arg doubleValue]; - [invocation setArgument:&d atIndex:argIndex + 2]; - } - else { // just do int for all else. - int i = [arg intValue]; - [invocation setArgument:&i atIndex:argIndex + 2]; - } - - } - else { - [invocation setArgument:&arg atIndex:argIndex + 2]; - } - - argIndex++; - } - - - [invocation invokeWithTarget:callee]; - - id result = 0x00; - - const char *type = [signature methodReturnType]; - - if (strcmp(type, @encode(id)) == 0) { - [invocation getReturnValue:&result]; - } - - if (!result) { - return JSValueMakeNull(ctx); - } - - JSValueRef jsReturnValue = NULL; - - [JSCocoaFFIArgument boxObject:result toJSValueRef:&jsReturnValue inContext:ctx]; - - return jsReturnValue; -} -*/ - - - (void) runScript:(NSString*)s { JSTalk *jstalk = [[[JSTalk alloc] init] autorelease];