Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed crash in -cleanup during setObjectNoRetain

  • Loading branch information...
commit 5148f5c2d2fcac9e3063f4cbb2e2c7d000e580d4 1 parent 7adae75
@parmanoir authored
View
6 JSCocoa/JSCocoaController.h
@@ -121,9 +121,9 @@ typedef struct JSValueRefAndContextRef JSValueRefAndContextRef;
- (NSString*)expandJSMacros:(NSString*)script path:(NSString*)path;
- (NSString*)expandJSMacros:(NSString*)script path:(NSString*)path errors:(NSMutableArray*)array;
-- (BOOL)setObject:(id)object withName:(NSString*)name;
-- (BOOL)setObject:(id)object withName:(NSString*)name attributes:(JSPropertyAttributes)attributes;
-- (BOOL)setObjectNoRetain:(id)object withName:(NSString*)name attributes:(JSPropertyAttributes)attributes;
+- (JSObjectRef)setObject:(id)object withName:(NSString*)name;
+- (JSObjectRef)setObject:(id)object withName:(NSString*)name attributes:(JSPropertyAttributes)attributes;
+- (JSObjectRef)setObjectNoRetain:(id)object withName:(NSString*)name attributes:(JSPropertyAttributes)attributes;
- (id)objectWithName:(NSString*)name;
- (BOOL)removeObjectWithName:(NSString*)name;
View
25 JSCocoa/JSCocoaController.m
@@ -304,6 +304,7 @@ - (void)cleanUp
{
// NSLog(@"JSCocoa : %p dying (ownsContext=%d)", self, ownsContext);
[self setUseSafeDealloc:NO];
+ [self setUseJSLint:NO];
// Cleanup if we created the JavascriptCore context.
// If not, let user do it. In a WebView, this method will be called during JS GC,
@@ -787,7 +788,7 @@ - (NSString*)expandJSMacros:(NSString*)script path:(NSString*)path errors:(NSMut
// Lintex path
id functionName = @"expandJSMacros";
// Expand macros
- BOOL hasFunction = [self hasJSFunctionNamed:functionName];
+ BOOL hasFunction = useJSLint ? [self hasJSFunctionNamed:functionName] : NO;
if (hasFunction && useJSLint)
{
JSValueRef v = [self callJSFunctionNamed:functionName withArguments:script, path?path:@"null", array, nil];
@@ -895,7 +896,7 @@ - (id)toObject:(JSValueRef)value
//
// Add/Remove an ObjC object variable to the global context
//
-- (BOOL)setObject:(id)object withName:(NSString*)name attributes:(JSPropertyAttributes)attributes {
+- (JSObjectRef)setObject:(id)object withName:(NSString*)name attributes:(JSPropertyAttributes)attributes {
JSObjectRef o = [self boxObject:object];
// Set
JSValueRef exception = NULL;
@@ -905,27 +906,29 @@ - (BOOL)setObject:(id)object withName:(NSString*)name attributes:(JSPropertyAttr
if (exception) {
[self callDelegateForException:exception];
- return NO;
+ return NULL;
}
- return YES;
+ return o;
}
-- (BOOL)setObject:(id)object withName:(NSString*)name {
+- (JSObjectRef)setObject:(id)object withName:(NSString*)name {
return [self setObject:object withName:name attributes:kJSPropertyAttributeNone];
}
-- (BOOL)setObjectNoRetain:(id)object withName:(NSString*)name attributes:(JSPropertyAttributes)attributes {
- if (![self setObject:self withName:name attributes:attributes])
- return NO;
+- (JSObjectRef)setObjectNoRetain:(id)object withName:(NSString*)name attributes:(JSPropertyAttributes)attributes {
+ JSObjectRef o = [self setObject:self withName:name attributes:attributes];
+ if (!o)
+ return NULL;
// Get reference back and set it to no retain
- JSValueRef jsSelf = [self evalJSString:name];
- JSCocoaPrivateObject* private = JSObjectGetPrivate(JSValueToObject(ctx, jsSelf, NULL));
+// JSValueRef jsSelf = [self evalJSString:name];
+// JSCocoaPrivateObject* private = JSObjectGetPrivate(JSValueToObject(ctx, jsSelf, NULL));
+ JSCocoaPrivateObject* private = JSObjectGetPrivate(o);
// Overwrite settings
[private setObjectNoRetain:self];
// And discard private's retain
[self release];
- return YES;
+ return o;
}
- (id)objectWithName:(NSString*)name {
View
45 JSCocoa/jslint-jscocoa.js
@@ -1083,7 +1083,7 @@ members)?
t.line = line;
t.character = character;
t.from = from;
-//alert('NEWTOKEN\ntype=' + type + '\nvalue=' + value + '\nfrom=' + t.from + '\ncharacter=' + t.character)
+
i = t.id;
if (i !== '(endline)') {
prereg = i &&
@@ -1374,14 +1374,15 @@ members)?
var c = lines[line].length-1
if (!s.match(/\n/))
c++
- if (!logTokenLock)
- {
+ if (!logTokenLock) {
var t = { type : '(comment)', line : line, from : from, value : v, character : c }
t.rawValue = lines[t.line] ? lines[t.line].substr(t.from, t.character-t.from) : ''
- logToken(t)
+ s = '';
+ return t
+// logToken(t)
}
- s = '';
- token.comment = true;
+// s = '';
+// token.comment = true;
break;
// /* comment
@@ -1396,6 +1397,7 @@ members)?
var commentLineIndex = 0
var firstCommentPrefix = '/*'
// First line misses '*' in '/*'
+ var commentTokens = []
for (;;) {
i = s.search(lx);
if (i >= 0) {
@@ -1407,7 +1409,8 @@ members)?
{
var t = { type : '(comment)', line : line, from : from, value : v, character: from+v.length }
t.rawValue = lines[t.line] ? lines[t.line].substr(t.from, t.character-t.from) : ''
- logToken(t)
+// logToken(t)
+ commentTokens.push(t)
}
break;
}
@@ -1421,8 +1424,10 @@ members)?
{
var t = { type : '(comment)', line : line, from : from, value : firstCommentPrefix + s, character : c+from }
t.rawValue = lines[t.line] ? lines[t.line].substr(t.from, t.character-t.from) : ''
- logToken(t)
- logToken( { id : '(endline)' } )
+// logToken(t)
+// logToken( { id : '(endline)' } )
+ commentTokens.push(t)
+ commentTokens.push({ id : '(endline)', line : line })
}
from = 0
}
@@ -1442,6 +1447,10 @@ members)?
}
s = s.substr(i + 2);
token.comment = true;
+
+ var t = { type : '(comment)', tokenArray : commentTokens }
+ return t
+
break;
// /*global /*extern /*members /*jslint */
@@ -1771,6 +1780,7 @@ members)?
function doOption() {
+
var b, obj, filter, o = nexttoken.value, t, v;
switch (o) {
case '*/':
@@ -1917,14 +1927,23 @@ members)?
if (!logTokenLock)
{
nexttoken.rawValue = lines[nexttoken.line] ? lines[nexttoken.line].substr(nexttoken.from, nexttoken.character-nexttoken.from) : ''
- logToken(nexttoken)
+ if (!nexttoken.tokenArray)
+ logToken(nexttoken)
+ else {
+ // Multiline tokens, like /*...*/ tokens
+ for (var i=0; i<nexttoken.tokenArray.length; i++)
+ logToken(nexttoken.tokenArray[i])
+ }
}
if (nexttoken.id === '(end)' || nexttoken.id === '(error)') {
return;
}
- if (nexttoken.type === 'special') {
+ if (nexttoken.type === '(comment)') {
+
+ } else {
+/* if (nexttoken.type === 'special') {
doOption();
- } else {
+ } else {*/
if (nexttoken.id !== '(endline)') {
break;
}
@@ -2397,7 +2416,7 @@ members)?
if (t.reach) {
return;
}
- if (t.id !== '(endline)') {
+ if (t.id !== '(endline)' && t.type != '(comment)') {
if (t.id === 'function') {
warning(
"Inner functions should be listed at the top of the outer function.", t);
View
4 TestsRunner/ApplicationController.m
@@ -102,9 +102,7 @@ - (void)cycleContext
- (IBAction)_runJSTests:(id)sender {
[self cycleContext];
-
-
-
+
[textField setStringValue:@"Running Tests ..."];
// Clean up notifications registered by previously run tests
View
3  TestsRunner/TestsRunner.xcodeproj/project.pbxproj
@@ -201,6 +201,9 @@
/* Begin PBXProject section */
29B97313FDCFA39411CA2CEA /* Project object */ = {
isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0420;
+ };
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "TestsRunner" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
View
BIN  ....xcodeproj/project.xcworkspace/xcuserdata/mini.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.