Skip to content

Commit

Permalink
Got rid of more warnings (Trailing ; in function imps)
Browse files Browse the repository at this point in the history
  • Loading branch information
parmanoir committed Aug 19, 2010
1 parent 9c0ff35 commit 520300c
Show file tree
Hide file tree
Showing 12 changed files with 1,876 additions and 1,217 deletions.
2 changes: 1 addition & 1 deletion JSCocoa/BridgeSupportController.m
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ - (BOOL)loadBridgeSupport:(NSString*)path

c0 = tagStart;
id value = [[NSString alloc] initWithBytes:c0 length:c-c0 encoding:NSUTF8StringEncoding];

[hash setValue:value forKey:name];
[value release];
[name release];
Expand Down
2 changes: 1 addition & 1 deletion JSCocoa/JSCocoaController.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ typedef struct JSValueRefAndContextRef JSValueRefAndContextRef;
id NSStringFromJSValue(JSValueRef value, JSContextRef ctx);
//void* malloc_autorelease(size_t size);

id JSLocalizedString(id stringName, id firstArg, ...) NS_REQUIRES_NIL_TERMINATION;
// Convert values between contexts (eg user context and webkit page context)
JSValueRef valueToExternalContext(JSContextRef ctx, JSValueRef value, JSContextRef externalCtx);

// valueOf() is called by Javascript on objects, eg someObject + ' someString'
Expand Down
64 changes: 16 additions & 48 deletions JSCocoa/JSCocoaController.m
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,6 @@ - (id)initWithGlobalContext:(JSGlobalContextRef)_ctx
[self accomodateWebKitInspector];
}

// Create a reference to ourselves, and make it read only, don't enum, don't delete
[self setObject:self withName:@"__jsc__" attributes:kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontEnum|kJSPropertyAttributeDontDelete];

#if !TARGET_IPHONE_SIMULATOR && !TARGET_OS_IPHONE
[self loadFrameworkWithName:@"AppKit"];
[self loadFrameworkWithName:@"CoreFoundation"];
Expand All @@ -259,6 +256,10 @@ - (id)initWithGlobalContext:(JSGlobalContextRef)_ctx
[BurksPool setJSFunctionHash:jsFunctionHash];
#endif

// Create a reference to ourselves, and make it read only, don't enum, don't delete
[self setObject:self withName:@"__jsc__" attributes:kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontEnum|kJSPropertyAttributeDontDelete];


// Load class kit
if (!_ctx)
{
Expand Down Expand Up @@ -694,7 +695,8 @@ - (JSValueRef)callJSFunctionNamed:(NSString*)name withArguments:(id)firstArg, ..
{
va_list args;
va_start(args, firstArg);
while (arg = va_arg(args, id)) [arguments addObject:arg];
while ((arg = va_arg(args, id)))
[arguments addObject:arg];
va_end(args);
}

Expand Down Expand Up @@ -759,7 +761,7 @@ - (BOOL)hasJSFunctionNamed:(NSString*)name
//
// Expand macros
//
- (NSString*)expandJSMacros:(NSString*)script url:(NSString*)url errors:(NSMutableArray*)array;
- (NSString*)expandJSMacros:(NSString*)script url:(NSString*)url errors:(NSMutableArray*)array
{
// Normal path, with macro expansion for class definitions
// OR
Expand Down Expand Up @@ -1061,7 +1063,7 @@ - (id)instanceStats
// * in property get (NSString.instance.count, getting 'count')
// * in valueOf (handled automatically as JavascriptCore will request 'valueOf' through property get)
//
+ (void)ensureJSValueIsObjectAfterInstanceAutocall:(JSValueRef)jsValue inContext:(JSContextRef)ctx;
+ (void)ensureJSValueIsObjectAfterInstanceAutocall:(JSValueRef)jsValue inContext:(JSContextRef)ctx
{
NSLog(@"***For zero arg instance, use obj.instance() instead of obj.instance***");
}
Expand Down Expand Up @@ -2122,7 +2124,7 @@ + (id)explainMethodEncoding:(id)encoding
// ->
// [object setWidth:100]
//
- (BOOL)JSCocoa:(JSCocoaController*)controller setProperty:(NSString*)propertyName ofObject:(id)object toValue:(JSValueRef)value inContext:(JSContextRef)localCtx exception:(JSValueRef*)exception;
- (BOOL)JSCocoa:(JSCocoaController*)controller setProperty:(NSString*)propertyName ofObject:(id)object toValue:(JSValueRef)value inContext:(JSContextRef)localCtx 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.
Expand Down Expand Up @@ -4729,6 +4731,13 @@ static bool jsCocoaObject_hasInstance(JSContextRef ctx, JSObjectRef constructor,
return NO;
}








//
//
#pragma mark JavascriptCore __info object (ObjCInstanceOrClass._info returns runtime info
Expand Down Expand Up @@ -4884,47 +4893,6 @@ static void throwException(JSContextRef ctx, JSValueRef* exception, NSString* re
}
*/

//
// JSLocalizedString
//
id JSLocalizedString(id stringName, id firstArg, ...)
{
// Convert args to array
id arg, arguments = [NSMutableArray array];
[arguments addObject:stringName];
if (firstArg) [arguments addObject:firstArg];

if (firstArg)
{
va_list args;
va_start(args, firstArg);
while (arg = va_arg(args, id)) [arguments addObject:arg];
va_end(args);
}

// Get global object
id jsc = [JSCocoaController sharedController];
JSContextRef ctx = [jsc ctx];
JSObjectRef globalObject= JSContextGetGlobalObject(ctx);
JSValueRef exception = NULL;

// Get function as property of global object
JSStringRef jsFunctionName = JSStringCreateWithUTF8CString([@"localizedString" UTF8String]);
JSValueRef jsFunctionValue = JSObjectGetProperty(ctx, globalObject, jsFunctionName, &exception);
JSStringRelease(jsFunctionName);
if (exception) return NSLog(@"localizedString failed"), NULL;

JSObjectRef jsFunction = JSValueToObject(ctx, jsFunctionValue, NULL);
// Return if function is not of function type
if (!jsFunction) return NSLog(@"localizedString is not a function"), NULL;

// Call !
JSValueRef jsRes = [jsc callJSFunction:jsFunction withArguments:arguments];
id res = [jsc unboxJSValueRef:jsRes];

return res;
}



//
Expand Down
2 changes: 1 addition & 1 deletion JSCocoa/JSCocoaFFIArgument.m
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ - (BOOL)fromJSValueRef:(JSValueRef)value inContext:(JSContextRef)ctx
return r;
}

+ (BOOL)fromJSValueRef:(JSValueRef)value inContext:(JSContextRef)ctx typeEncoding:(char)typeEncoding fullTypeEncoding:(NSString*)fullTypeEncoding fromStorage:(void*)ptr;
+ (BOOL)fromJSValueRef:(JSValueRef)value inContext:(JSContextRef)ctx typeEncoding:(char)typeEncoding fullTypeEncoding:(NSString*)fullTypeEncoding fromStorage:(void*)ptr
{
if (!typeEncoding) return NO;

Expand Down
2 changes: 1 addition & 1 deletion JSCocoa/JSCocoaLib.m
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ - (JSValueRef)valueAtIndex:(NSUInteger)idx inContext:(JSContextRef)ctx
return returnValue;
}

- (BOOL)setValue:(JSValueRef)jsValue atIndex:(NSUInteger)idx inContext:(JSContextRef)ctx;
- (BOOL)setValue:(JSValueRef)jsValue atIndex:(NSUInteger)idx inContext:(JSContextRef)ctx
{
char typeEncoding = [self typeAtIndex:idx];
void* pointedValue = [self pointerForIndex:idx];
Expand Down
2 changes: 1 addition & 1 deletion JSCocoa/JSCocoaPrivateObject.m
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ - (Method)method
return method;
}

- (void)setJSValueRef:(JSValueRef)v ctx:(JSContextRef)c;
- (void)setJSValueRef:(JSValueRef)v ctx:(JSContextRef)c
{
// While autocalling we'll get a NULL value when boxing a void return type - just skip JSValueProtect
if (!v)
Expand Down
24 changes: 0 additions & 24 deletions JSCocoa/class.js
Original file line number Diff line number Diff line change
Expand Up @@ -1067,30 +1067,6 @@
return transformed
}

//
// Localization
//
var localizedStrings = {}
function localizedString(stringName)
{
var r = localizedStrings[stringName]
if (!r)
{
var str = '*** Localization for \'' + stringName + '\' not found ***'
log(str)
return str
}
if (typeof r != 'function') return r

// Arguments are function arguments minus the first one (stringName)
var args = []; for (var i=1; i<arguments.length; i++) args.push(arguments[i])
return r.apply(null, args)
}
function registerLocalizedStrings(strings)
{
for (var i in strings) __localizedStrings[i] = strings[i]
}

function allKeysInHash(o)
{
var r = []
Expand Down
8 changes: 4 additions & 4 deletions TestsRunner/ApplicationController.m
Original file line number Diff line number Diff line change
Expand Up @@ -653,22 +653,22 @@ - (void) JSCocoa:(JSCocoaController*)controller hadError:(NSString*)error onLine
}


- (BOOL) JSCocoa:(JSCocoaController*)controller canGetProperty:(NSString*)_propertyName ofObject:(id)_object inContext:(JSContextRef)ctx exception:(JSValueRef*)exception;
- (BOOL) JSCocoa:(JSCocoaController*)controller canGetProperty:(NSString*)_propertyName ofObject:(id)_object inContext:(JSContextRef)ctx exception:(JSValueRef*)exception
{
// NSLog(@"delegate canGet %@(%@).%@ canGet=%d", _object, [_object class], _propertyName, canGet);
object = _object;
propertyName = _propertyName;
return canGet;
}
- (JSValueRef) JSCocoa:(JSCocoaController*)controller getProperty:(NSString*)_propertyName ofObject:(id)_object inContext:(JSContextRef)ctx exception:(JSValueRef*)exception;
- (JSValueRef) JSCocoa:(JSCocoaController*)controller getProperty:(NSString*)_propertyName ofObject:(id)_object inContext:(JSContextRef)ctx exception:(JSValueRef*)exception
{
// NSLog(@"delegate get %@(%@).%@ customValueGet=%x", _object, [_object class], _propertyName, customValueGet);
object = _object;
propertyName = _propertyName;
return customValueGet;
}

- (BOOL) JSCocoa:(JSCocoaController*)controller canSetProperty:(NSString*)_propertyName ofObject:(id)_object toValue:(JSValueRef)_jsValue inContext:(JSContextRef)ctx exception:(JSValueRef*)exception;
- (BOOL) JSCocoa:(JSCocoaController*)controller canSetProperty:(NSString*)_propertyName ofObject:(id)_object toValue:(JSValueRef)_jsValue inContext:(JSContextRef)ctx exception:(JSValueRef*)exception
{
// NSLog(@"delegate canSet %@(%@).%@", _object, [_object class], _propertyName);
object = _object;
Expand All @@ -680,7 +680,7 @@ - (BOOL) JSCocoa:(JSCocoaController*)controller canSetProperty:(NSString*)_prope
equalsBezelStyle = [_propertyName isEqualToString:@"bezelStyle"];
return canSet;
}
- (BOOL) JSCocoa:(JSCocoaController*)controller setProperty:(NSString*)_propertyName ofObject:(id)_object toValue:(JSValueRef)_jsValue inContext:(JSContextRef)ctx exception:(JSValueRef*)exception;
- (BOOL) JSCocoa:(JSCocoaController*)controller setProperty:(NSString*)_propertyName ofObject:(id)_object toValue:(JSValueRef)_jsValue inContext:(JSContextRef)ctx exception:(JSValueRef*)exception
{
// NSLog(@"delegate set");
object = _object;
Expand Down
Loading

0 comments on commit 520300c

Please sign in to comment.