Permalink
Browse files

'no context' in finalize is no problem as the context is only used to…

… remove the box from the box hash. Context is null because we're being deleted
  • Loading branch information...
1 parent ebee9c2 commit 0c45a77425120bcf9a93ee393128754f05b1ca63 @parmanoir committed Aug 3, 2011
Showing with 11,322 additions and 38,247 deletions.
  1. +28 −34 JSCocoa/JSCocoaController.m
  2. 0 Tests/{! stock → }/1 C and ObjC calls.js
  3. 0 Tests/{! stock → }/10 shorthand overload.js
  4. 0 Tests/{! stock → }/11 retain test 2.js
  5. 0 Tests/{! stock → }/12 instance variables.js
  6. 0 Tests/{! stock → }/13 instance.js
  7. 0 Tests/{! stock → }/14 class.js
  8. 0 Tests/{! stock → }/16 NSArray NSDictionary easy access.js
  9. 0 Tests/{! stock → }/17 struct instance.js
  10. 0 Tests/{! stock → }/18 structure args.js
  11. 0 Tests/{! stock → }/19 pure js methods.js
  12. 0 Tests/{! stock → }/2 structure arguments.js
  13. 0 Tests/{! stock → }/20 pointer to function.js
  14. 0 Tests/{! stock → }/21 new class definition.js
  15. 0 Tests/{! stock → }/22 instance valueOf.js
  16. 0 Tests/{! stock → }/23 NSString bridging.js
  17. 0 Tests/{! stock → }/24 structure set.js
  18. 0 Tests/{! stock → }/25 variadic.js
  19. 0 Tests/{! stock → }/26 full NSArray bridge.js
  20. 0 Tests/{! stock → }/27 type modifier o.js
  21. 0 Tests/{! stock → }/28 struct description.js
  22. 0 Tests/{! stock → }/29 pointer handling.js
  23. 0 Tests/{! stock → }/3 derivation.js
  24. 0 Tests/{! stock → }/30 obj1 == obj2.js
  25. 0 Tests/{! stock → }/31 bridgeSupport bench.js
  26. 0 Tests/{! stock → }/32 new class syntax.js
  27. 0 Tests/{! stock → }/33 class syntax swizzle.js
  28. 0 Tests/{! stock → }/34 object keys.js
  29. 0 Tests/{! stock → }/35 webview.js
  30. 0 Tests/{! stock → }/36 safe dealloc.js
  31. 0 Tests/{! stock → }/37 init from webview.js
  32. 0 Tests/{! stock → }/38 class walker.js
  33. 0 Tests/{! stock → }/39 NSArray js functions.js
  34. 0 Tests/{! stock → }/4 js load.js
  35. 0 Tests/{! stock → }/40 ObjJ syntax.js
  36. 0 Tests/{! stock → }/41 class inner js functions.js
  37. 0 Tests/{! stock → }/42 return if.js
  38. 0 Tests/{! stock → }/43 @ string and selector.js
  39. 0 Tests/{! stock → }/44 instanceWith.js
  40. 0 Tests/{! stock → }/45 ƒ function shortcut.js
  41. 0 Tests/{! stock → }/46 exceptions.js
  42. 0 Tests/{! stock → }/47 ObjJ syntax super.js
  43. 0 Tests/{! stock → }/48 ObjJ syntax compatibility.js
  44. 0 Tests/{! stock → }/49 out pointer.js
  45. 0 Tests/{! stock → }/50 setValueForKey op.js
  46. 0 Tests/{! stock → }/51 ObjC blocks.js
  47. 0 Tests/{! stock → }/52 line and sourceURL.js
  48. 0 Tests/{! stock → }/53 Unicode ObjC classes.js
  49. 0 Tests/{! stock → }/54 custom indexed access.js
  50. 0 Tests/{! stock → }/55 javascript method override.js
  51. 0 Tests/{! stock → }/56 whitespace.js
  52. 0 Tests/{! stock → }/6 basic arguments.js
  53. 0 Tests/{! stock → }/7 split call.js
  54. 0 Tests/{! stock → }/8 zero arg autocall.js
  55. 0 Tests/{! stock → }/9 auto setter.js
  56. +6 −6 TestsRunner/ApplicationController.m
  57. +11,288 −38,207 ...tsRunner.xcodeproj/project.xcworkspace/xcuserdata/mini.xcuserdatad/UserInterfaceState.xcuserstate
@@ -345,12 +345,10 @@ - (void)cleanUp
[self unlinkAllReferences];
JSGarbageCollect(ctx);
}
- [self logBoxedObjects];
controllerCount--;
if (controllerCount == 0)
{
- NSLog(@"OUT");
if (OSXObjectClass) {
JSClassRelease(OSXObjectClass);
JSClassRelease(jsCocoaObjectClass);
@@ -390,25 +388,14 @@ - (void)cleanUp
// Remove classes : go backwards to remove child classes first
for (id class in [jsClasses reverseObjectEnumerator])
objc_disposeClassPair([class pointerValue]);
-/*
- NSInteger c = [jsClasses count]-1;
- NSLog(@"CLASSCOUNT %d", c);
- while (c >= 0)
- {
- id class = [[jsClasses objectAtIndex:c] pointerValue];
- NSLog(@"DEALLOC CLASS %@", class);
- objc_disposeClassPair(class);
- c--;
- }
-*/
+
[jsClasses release];
jsClasses = nil;
}
-NSLog(@"DESTROY context");
+
if (ownsContext)
JSGlobalContextRelease(ctx);
-NSLog(@"DESTROY boxedObjects");
[boxedObjects release];
}
@@ -951,7 +938,11 @@ - (BOOL)removeObjectWithName:(id)name
return YES;
}
+//
+//
#pragma mark Loading Frameworks
+//
+//
- (BOOL)loadFrameworkWithName:(NSString*)name
{
// Only check /System/Library/Frameworks for now
@@ -1156,10 +1147,12 @@ + (id)parentObjCClassOfClassName:(NSString*)className
return [jsClassParents objectForKey:className];
}
+//
+//
#pragma mark Common encoding parsing
//
-// This is parsed from method_getTypeEncoding
//
+// This is parsed from method_getTypeEncoding
// Later : Use method_copyArgumentType ?
+ (NSMutableArray*)parseObjCMethodEncoding:(const char*)typeEncoding
{
@@ -1315,9 +1308,11 @@ + (NSMutableArray*)parseCFunctionEncoding:(NSString*)xml functionName:(NSString*
-
+//
+//
#pragma mark Class Creation
-
+//
+//
+ (Class)createClass:(char*)className parentClass:(char*)parentClass
{
Class class = objc_getClass(className);
@@ -1804,6 +1799,8 @@ - (BOOL)isFunctionVariadic:(id)functionName
return isVariadic;
}
+
+
#pragma mark Boxed object hash
//+ (JSObjectRef)boxedJSObject:(id)o inContext:(JSContextRef)ctx
@@ -2002,18 +1999,14 @@ - (int)runTests:(NSString*)path withSelector:(SEL)sel {
id files = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:nil];
id predicate= [NSPredicate predicateWithFormat:@"SELF ENDSWITH[c] '.js'"];
files = [files filteredArrayUsingPredicate:predicate];
-
- // Execute in test order, not finder order
- files = [files sortedArrayUsingSelector:@selector(localizedStandardCompare:)];
-// NSLog(@"files=%@", files);
-
if ([files count] == 0)
return [JSCocoaController log:@"no test files found"], 0;
+ // Execute in test order, not finder order
+ files = [files sortedArrayUsingSelector:@selector(localizedStandardCompare:)];
for (id file in files) {
id filePath = [NSString stringWithFormat:@"%@/%@", path, file];
- NSLog(@">>>evaling %@", filePath);
-// BOOL evaled = [self evalJSFile:filePath];
+// NSLog(@">>>evaling %@", filePath);
id evaled = nil;
@try {
@@ -3281,14 +3274,12 @@ static void jsCocoaObject_finalize(JSObjectRef object)
id jsc = nil;
JSContextRef ctx = [private ctx];
- if (!ctx) {
- NSLog(@"+++++++NO CONTEXT, NO DELETE");
- } else {
+ if (ctx)
jsc = [JSCocoa controllerFromContext:ctx];
- }
- if (!jsc) {
- NSLog(@"*******NO CONTEXT+++++++++++");
- }
+ // We will be called during garbage collection before dealloc occurs.
+ // The __jsc__ variable will be gone, therefore controllerFromContext will yield 0.
+ // Not a problem since it's only used to remove the object from the boxedObjects hash,
+ // and dealloc will occur soon after.
//
// If a boxed object is being destroyed, remove it from the cache
@@ -4996,8 +4987,11 @@ static void jsCocoaInfo_getPropertyNames(JSContextRef ctx, JSObjectRef object, J
}
-
-#pragma mark Helpers
+//
+//
+#pragma mark Global helpers
+//
+//
id NSStringFromJSValue(JSContextRef ctx, JSValueRef value)
{
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.
@@ -22,7 +22,6 @@ - (id)init {
return nil;
test_unit = test_delegate = test_webview = test_autocall = YES;
- test_webview = NO;
return self;
}
@@ -149,7 +148,7 @@ - (IBAction)runJSTests:(id)sender
[jsc loadFrameworkWithName:@"WebKit"];
webViewClass = objc_getClass("WebView");
}
- if (webViewClass && test_webview)
+ if (webViewClass)
{
// NSLog(@"Testing initing from a WebView");
// Load nib
@@ -188,7 +187,8 @@ - (IBAction)runJSTests:(id)sender
}
else
{
- NSLog(@"WebKit not loaded - cannot test JSCocoa inited from a WebView");
+ if (test_webview)
+ NSLog(@"WebKit not loaded - cannot test JSCocoa inited from a WebView");
}
@@ -240,8 +240,6 @@ - (IBAction)runJSTests:(id)sender
id r = [o performSelector:[@"だけを追加する:" UTF8String] withObject:[NSNumber numberWithInt:7]];
NSLog(@"r=%@", r);
*/
- NSLog(@"DOUBLE CYCLE");
-// [self cycleContext];
}
@@ -956,9 +954,11 @@ - (void)finishTest37:(BOOL)b
NSLog(@"JSC2 not deallocated");
-
+ NSLog(@"unlinking...");
[jsc2 unlinkAllReferences];
+ NSLog(@"collecting...");
[jsc2 garbageCollect];
+ NSLog(@"releasing...");
[jsc2 release];
jsc2 = nil;
Oops, something went wrong. Retry.

0 comments on commit 0c45a77

Please sign in to comment.