You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2013/03/06 20:45:06 UTC
[2/3] mac commit: Namespaced CDVBridge JavaScript functions.
Namespaced CDVBridge JavaScript functions.
Project: http://git-wip-us.apache.org/repos/asf/cordova-osx/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-osx/commit/aa6c0bf4
Tree: http://git-wip-us.apache.org/repos/asf/cordova-osx/tree/aa6c0bf4
Diff: http://git-wip-us.apache.org/repos/asf/cordova-osx/diff/aa6c0bf4
Branch: refs/heads/plugin-enable
Commit: aa6c0bf4ddf64e3c2d573aab88731b8703b243d3
Parents: 142d254
Author: Shazron Abdullah <sh...@apache.org>
Authored: Wed Mar 6 11:39:30 2013 -0800
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Wed Mar 6 11:39:30 2013 -0800
----------------------------------------------------------------------
CordovaMac/CordovaMac/CDVBridge.m | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/aa6c0bf4/CordovaMac/CordovaMac/CDVBridge.m
----------------------------------------------------------------------
diff --git a/CordovaMac/CordovaMac/CDVBridge.m b/CordovaMac/CordovaMac/CDVBridge.m
index e0ce358..4cbdf4b 100644
--- a/CordovaMac/CordovaMac/CDVBridge.m
+++ b/CordovaMac/CordovaMac/CDVBridge.m
@@ -27,7 +27,7 @@
- (BOOL) isArray:(id)item
{
id win = [self.webView windowScriptObject];
- NSNumber* result = [win callWebScriptMethod:@"__isArray__" withArguments:[NSArray arrayWithObject:item]];
+ NSNumber* result = [win callWebScriptMethod:@"CordovaBridgeUtil.isArray" withArguments:[NSArray arrayWithObject:item]];
return [result boolValue];
}
@@ -35,7 +35,7 @@
- (BOOL) isDictionary:(id)item
{
id win = [self.webView windowScriptObject];
- NSNumber* result = [win callWebScriptMethod:@"__isObject__" withArguments:[NSArray arrayWithObject:item]];
+ NSNumber* result = [win callWebScriptMethod:@"CordovaBridgeUtil.isObject" withArguments:[NSArray arrayWithObject:item]];
return [result boolValue];
}
@@ -45,7 +45,7 @@
id win = [self.webView windowScriptObject];
- WebScriptObject* keysObject = [win callWebScriptMethod:@"__dictionaryKeys__" withArguments:[NSArray arrayWithObject:webScriptObject]];
+ WebScriptObject* keysObject = [win callWebScriptMethod:@"CordovaBridgeUtil.getDictionaryKeys" withArguments:[NSArray arrayWithObject:webScriptObject]];
NSArray* keys = [self convertWebScriptObjectToNSArray:keysObject];
NSMutableDictionary* dict = [NSMutableDictionary dictionaryWithCapacity:[keys count]];
@@ -82,11 +82,12 @@
- (void) registerJavaScriptHelpers
{
- NSString* isArray = [NSString stringWithFormat:@"function __isArray__(obj) { return obj.constructor == Array; };"];
- NSString* isObject = [NSString stringWithFormat:@"function __isObject__(obj) { return obj.constructor == Object; };"];
+ NSString* cordovaBridgeUtil = @"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:
@" \
- function __dictionaryKeys__(obj) { \
+ CordovaBridgeUtil.getDictionaryKeys = function(obj) { \
var a = []; \
for (var key in obj) { \
if (!obj.hasOwnProperty(key)) { \
@@ -99,6 +100,7 @@
];
id win = [self.webView windowScriptObject];
+ [win evaluateWebScript:cordovaBridgeUtil];
[win evaluateWebScript:isArray];
[win evaluateWebScript:isObject];
[win evaluateWebScript:dictionaryKeys];