Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5BE41104E7 for ; Wed, 26 Aug 2015 01:06:24 +0000 (UTC) Received: (qmail 33919 invoked by uid 500); 26 Aug 2015 01:06:24 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 33895 invoked by uid 500); 26 Aug 2015 01:06:24 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 33886 invoked by uid 99); 26 Aug 2015 01:06:24 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Aug 2015 01:06:24 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 223BCE01CA; Wed, 26 Aug 2015 01:06:24 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: shazron@apache.org To: commits@cordova.apache.org Date: Wed, 26 Aug 2015 01:06:24 -0000 Message-Id: <931bb24a852540cdb820e52784a8b029@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/4] mac commit: @trivial reformat code - clean whitespaces Repository: cordova-osx Updated Branches: refs/heads/master 3722eac36 -> 05c4d55ef @trivial reformat code - clean whitespaces Project: http://git-wip-us.apache.org/repos/asf/cordova-osx/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-osx/commit/192b60ae Tree: http://git-wip-us.apache.org/repos/asf/cordova-osx/tree/192b60ae Diff: http://git-wip-us.apache.org/repos/asf/cordova-osx/diff/192b60ae Branch: refs/heads/master Commit: 192b60aea417825a09e98b5a1ad2bdadf186c5ef Parents: 3722eac Author: Tobias Bocanegra Authored: Tue Aug 25 17:07:57 2015 -0700 Committer: Tobias Bocanegra Committed: Tue Aug 25 17:07:57 2015 -0700 ---------------------------------------------------------------------- CordovaLib/CordovaLib/Classes/CDVBridge.h | 20 ++-- CordovaLib/CordovaLib/Classes/CDVBridge.m | 115 ++++++++----------- .../Classes/Commands/CDVConfigParser.m | 2 +- 3 files changed, 59 insertions(+), 78 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/192b60ae/CordovaLib/CordovaLib/Classes/CDVBridge.h ---------------------------------------------------------------------- diff --git a/CordovaLib/CordovaLib/Classes/CDVBridge.h b/CordovaLib/CordovaLib/Classes/CDVBridge.h index 5d15064..62ef8cb 100644 --- a/CordovaLib/CordovaLib/Classes/CDVBridge.h +++ b/CordovaLib/CordovaLib/Classes/CDVBridge.h @@ -6,9 +6,9 @@ to you 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 @@ -18,25 +18,19 @@ */ #import + @class WebView; @class CDVViewController; @interface CDVBridge : NSObject { - } -@property (nonatomic, weak) WebView* webView; -@property (nonatomic, -#ifdef __MAC_10_8 - weak -#else - assign -#endif - ) CDVViewController* viewController; +@property(nonatomic, weak) WebView* webView; +@property(nonatomic,assign) CDVViewController* viewController; +- (id) initWithWebView:(WebView*) webView andViewController:(CDVViewController*) viewController; -- (id) initWithWebView:(WebView*)webView andViewController:(CDVViewController*)viewController; -- (void) exec:(NSString*)callbackId withService:(NSString*)service andAction:(NSString*)action andArguments:(NSArray*)arguments; +- (void) exec:(NSString*) callbackId withService:(NSString*) service andAction:(NSString*) action andArguments:(NSArray*) arguments; @end http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/192b60ae/CordovaLib/CordovaLib/Classes/CDVBridge.m ---------------------------------------------------------------------- diff --git a/CordovaLib/CordovaLib/Classes/CDVBridge.m b/CordovaLib/CordovaLib/Classes/CDVBridge.m index 6e4d147..1610083 100644 --- a/CordovaLib/CordovaLib/Classes/CDVBridge.m +++ b/CordovaLib/CordovaLib/Classes/CDVBridge.m @@ -6,9 +6,9 @@ to you 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 @@ -18,8 +18,6 @@ */ #import -#import -#import #include #import "CDVBridge.h" @@ -27,8 +25,7 @@ @implementation CDVBridge -- (BOOL) isArray:(id)item -{ +- (BOOL) isArray:(id) item { id win = [self.webView windowScriptObject]; WebScriptObject* bridgeUtil = [win evaluateWebScript:@"CordovaBridgeUtil"]; NSNumber* result = [bridgeUtil callWebScriptMethod:@"isArray" withArguments:[NSArray arrayWithObject:item]]; @@ -36,21 +33,19 @@ return [result boolValue]; } -- (BOOL) isDictionary:(id)item -{ +- (BOOL) isDictionary:(id) item { id win = [self.webView windowScriptObject]; WebScriptObject* bridgeUtil = [win evaluateWebScript:@"CordovaBridgeUtil"]; NSNumber* result = [bridgeUtil callWebScriptMethod:@"isObject" withArguments:[NSArray arrayWithObject:item]]; return [result boolValue]; } -- (NSDictionary*) convertWebScriptObjectToNSDictionary:(WebScriptObject*)webScriptObject -{ +- (NSDictionary*) convertWebScriptObjectToNSDictionary:(WebScriptObject*) webScriptObject { // Assumption: webScriptObject has already been tested using isDictionary: id win = [self.webView windowScriptObject]; - - WebScriptObject *util = [win valueForKey:@"CordovaBridgeUtil"]; + + WebScriptObject* util = [win valueForKey:@"CordovaBridgeUtil"]; WebScriptObject* keysObject = [util callWebScriptMethod:@"getDictionaryKeys" withArguments:[NSArray arrayWithObject:webScriptObject]]; NSArray* keys = [self convertWebScriptObjectToNSArray:keysObject]; NSMutableDictionary* dict = [NSMutableDictionary dictionaryWithCapacity:[keys count]]; @@ -60,16 +55,15 @@ while (key = [enumerator nextObject]) { [dict setObject:[webScriptObject valueForKey:key] forKey:key]; } - + return dict; } -- (NSArray*) convertWebScriptObjectToNSArray:(WebScriptObject*)webScriptObject -{ +- (NSArray*) convertWebScriptObjectToNSArray:(WebScriptObject*) webScriptObject { // Assumption: webScriptObject has already been tested using isArray: - + NSUInteger count = [[webScriptObject valueForKey:@"length"] integerValue]; - NSMutableArray *a = [NSMutableArray array]; + NSMutableArray* a = [NSMutableArray array]; for (unsigned i = 0; i < count; i++) { id item = [webScriptObject webScriptValueAtIndex:i]; if ([item isKindOfClass:[WebScriptObject class]]) { @@ -82,17 +76,16 @@ [a addObject:item]; } } - + return a; } -- (void) registerJavaScriptHelpers -{ +- (void) registerJavaScriptHelpers { NSString* cordovaBridgeUtil = @"var CordovaBridgeUtil = {};"; NSString* isArray = [NSString stringWithFormat:@"CordovaBridgeUtil.isArray = function(obj) { return obj.constructor == Array; };"]; NSString* isObject = [NSString stringWithFormat:@"CordovaBridgeUtil.isObject = function(obj) { return obj.constructor == Object; };"]; NSString* dictionaryKeys = [NSString stringWithFormat:@"CordovaBridgeUtil.getDictionaryKeys = function(obj) { return Object.keys(obj);};"]; - + id win = [self.webView windowScriptObject]; [win evaluateWebScript:cordovaBridgeUtil]; [win evaluateWebScript:isArray]; @@ -100,37 +93,35 @@ [win evaluateWebScript:dictionaryKeys]; } -- (id) initWithWebView:(WebView *)webView andViewController:(CDVViewController*)viewController -{ +- (id) initWithWebView:(WebView*) webView andViewController:(CDVViewController*) viewController { if ((self = [super init]) != nil) { self.webView = webView; self.viewController = viewController; [self registerJavaScriptHelpers]; } - + return self; } -- (void) exec:(NSString*)callbackId withService:(NSString*)service andAction:(NSString*)action andArguments:(WebScriptObject*)webScriptObject -{ +- (void) exec:(NSString*) callbackId withService:(NSString*) service andAction:(NSString*) action andArguments:(WebScriptObject*) webScriptObject { // We are going with the iOS method of passing in a callbackId. // Note that we can use the JavaScriptCore C API to pass in the JavaScript function references // and context and call them directly, but this is done this way for possible plugin sharing // between iOS and OS X. Also we are going async as well. - + // we're just going to assume the webScriptObject passed in is an NSArray NSArray* arguments = [self convertWebScriptObjectToNSArray:webScriptObject]; - + CDVInvokedUrlCommand* command = [[CDVInvokedUrlCommand alloc] initWithArguments:arguments callbackId:callbackId className:service methodName:action]; - + if ((command.className == nil) || (command.methodName == nil)) { NSLog(@"ERROR: Classname and/or methodName not found for command."); return; } - + // Fetch an instance of this class CDVPlugin* obj = [_viewController.commandDelegate getCommandInstance:command.className]; - + if (!([obj isKindOfClass:[CDVPlugin class]])) { NSLog(@"ERROR: Plugin '%@' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.", command.className); return; @@ -151,45 +142,41 @@ #pragma mark WebScripting Protocol /* checks whether a selector is acceptable to be called from JavaScript */ -+ (BOOL) isSelectorExcludedFromWebScript:(SEL)selector -{ - BOOL result = YES; - - int i = 0; - static SEL * acceptableList = NULL; - SEL currentSelector; - - if (acceptableList == NULL && (acceptableList = calloc(256, sizeof(SEL)))) // up to 256 selectors - { - acceptableList[i++] = @selector(exec:withService:andAction:andArguments:); - } - - i = 0; - while (result == YES && (currentSelector = acceptableList[i++])) - { - //checking for exclusions - result = !(selector == currentSelector); - } - - return result; ++ (BOOL) isSelectorExcludedFromWebScript:(SEL) selector { + BOOL result = YES; + + int i = 0; + static SEL* acceptableList = NULL; + SEL currentSelector; + + if (acceptableList == NULL && (acceptableList = calloc(256, sizeof(SEL)))) // up to 256 selectors + { + acceptableList[i++] = @selector(exec:withService:andAction:andArguments:); + } + + i = 0; + while (result == YES && (currentSelector = acceptableList[i++])) { + //checking for exclusions + result = !(selector == currentSelector); + } + + return result; } /* helper function so we don't have to have underscores and stuff in js to refer to the right method */ -+ (NSString*) webScriptNameForSelector:(SEL)aSelector -{ - id result = nil; - - if (aSelector == @selector(exec:withService:andAction:andArguments:)) { - result = @"exec"; - } - - return result; ++ (NSString*) webScriptNameForSelector:(SEL) aSelector { + id result = nil; + + if (aSelector == @selector(exec:withService:andAction:andArguments:)) { + result = @"exec"; + } + + return result; } // right now exclude all properties (eg keys) -+ (BOOL) isKeyExcludedFromWebScript:(const char*)name -{ - return YES; ++ (BOOL) isKeyExcludedFromWebScript:(const char*) name { + return YES; } @end http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/192b60ae/CordovaLib/CordovaLib/Classes/Commands/CDVConfigParser.m ---------------------------------------------------------------------- diff --git a/CordovaLib/CordovaLib/Classes/Commands/CDVConfigParser.m b/CordovaLib/CordovaLib/Classes/Commands/CDVConfigParser.m index ba71066..a345cdc 100644 --- a/CordovaLib/CordovaLib/Classes/Commands/CDVConfigParser.m +++ b/CordovaLib/CordovaLib/Classes/Commands/CDVConfigParser.m @@ -100,7 +100,7 @@ - (void)parser:(NSXMLParser*)parser parseErrorOccurred:(NSError*)parseError { - NSAssert(NO, @"config.xml parse error line %d col %d", [parser lineNumber], [parser columnNumber]); + NSAssert(NO, @"config.xml parse error line %ld col %ld", [parser lineNumber], [parser columnNumber]); } @end --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org For additional commands, e-mail: commits-help@cordova.apache.org