Skip to content

Commit

Permalink
Removed javascript allKeys method, now uses HTML5 Object.keys()
Browse files Browse the repository at this point in the history
  • Loading branch information
parmanoir committed Aug 7, 2011
1 parent 735de68 commit 7b62389
Show file tree
Hide file tree
Showing 59 changed files with 2,449 additions and 2,400 deletions.
23 changes: 1 addition & 22 deletions JSCocoa/JSCocoaController.m
Original file line number Diff line number Diff line change
Expand Up @@ -274,30 +274,9 @@ - (id)initWithGlobalContext:(JSGlobalContextRef)_ctx
if ([[NSFileManager defaultManager] fileExistsAtPath:classKitPath]) [self evalJSFile:classKitPath];
}

// Add allKeys method to Javascript hash : { a : 1, b : 2, c : 3 }.allKeys() = ['a', 'b', 'c']

// Retrieve Javascript function from class.js
JSStringRef jsName = JSStringCreateWithUTF8CString("allKeysInHash");
JSValueRef fn = JSObjectGetProperty(ctx, JSContextGetGlobalObject(ctx), jsName, NULL);
JSStringRelease(jsName);

if (fn)
{
// Add it to Object.prototype with dont enum property
JSStringRef scriptJS = JSStringCreateWithUTF8CString("return Object.prototype");
JSObjectRef fn2 = JSObjectMakeFunction(ctx, NULL, 0, NULL, scriptJS, NULL, 1, NULL);
JSValueRef jsValue = JSObjectCallAsFunction(ctx, fn2, NULL, 0, NULL, NULL);
JSObjectRef jsObject = JSValueToObject(ctx, jsValue, NULL);
JSStringRelease(scriptJS);

jsName = JSStringCreateWithUTF8CString("allKeys");
JSObjectSetProperty(ctx, jsObject, jsName, fn, kJSPropertyAttributeDontEnum, NULL);
JSStringRelease(jsName);
}

// Objects can use their own dealloc, normally used up by JSCocoa
// JSCocoa registers 'safeDealloc' in place of 'dealloc' and calls it in the next run loop cycle.
// (If called during dealloc, this would mean executing JS code during JS GC, which is not possible)
// (Dealloc might be called by JS GC, and running JS fails at this time)
// useSafeDealloc will be turned to NO upon JSCocoaController dealloc
useSafeDealloc = YES;
// Yep !
Expand Down
7 changes: 0 additions & 7 deletions JSCocoa/class.js
Original file line number Diff line number Diff line change
Expand Up @@ -1053,10 +1053,3 @@
// log('Transformed' + script + '->' + transformed)
return transformed
}

function allKeysInHash(o)
{
var r = []
for (var i in this) r.push(i)
return r
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
var hasName = false
var hasSurname = false
var hasSomeVariable = false
var allKeys = o.allKeys()
var allKeys = Object.keys(o)
for (var i=0; i<allKeys.length; i++)
{
var key = allKeys[i]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion TestsRunner/ApplicationController.m
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,13 @@ - (IBAction)stopContinuousJSTestsRun:(id)sender
}

- (BOOL)validateMenuItem:(NSMenuItem *) menuItem {
NSLog(@"%@", menuItem);
SEL itemAction = [menuItem action];
if (itemAction == @selector(displayTestsWindow:))
return YES;
return NO;
}

// ## debug, to dump an object from an address (Sometimes debugging does not work when breaking in code called from JavascriptCore)
- (void)dumpObjectAtAddress:(NSUInteger)address {
void* p = (void*)address;
NSLog(@"object at %p=", p);
Expand Down
Loading

0 comments on commit 7b62389

Please sign in to comment.