[Vm-dev] [commit][3324] JMM - integrate Pyonkee & Pharo changes to cocoa os-x and iPhone code base

commits at squeakvm.org commits at squeakvm.org
Thu May 7 18:23:30 UTC 2015


Revision: 3324
Author:   johnmci
Date:     2015-05-07 11:23:28 -0700 (Thu, 07 May 2015)
Log Message:
-----------
JMM - integrate Pyonkee & Pharo changes to cocoa os-x and iPhone code base 

Modified Paths:
--------------
    trunk/platforms/iOS/plugins/ClipboardExtended/sqMacExtendedClipboard.m
    trunk/platforms/iOS/vm/Common/Classes/sqSqueakAppDelegate.h
    trunk/platforms/iOS/vm/Common/Classes/sqSqueakAttributesAPI.m
    trunk/platforms/iOS/vm/Common/Classes/sqSqueakEventsAPI.m
    trunk/platforms/iOS/vm/Common/Classes/sqSqueakFileDirectoryAPI.m
    trunk/platforms/iOS/vm/Common/Classes/sqSqueakFileDirectoryInterface.h
    trunk/platforms/iOS/vm/Common/Classes/sqSqueakFileDirectoryInterface.m
    trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApp.h
    trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApp.m
    trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+attributes.m
    trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+events.h
    trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+events.m
    trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+imageReadWrite.m
    trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+sound.m
    trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+vmAndImagePath.m
    trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication.h
    trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication.m
    trunk/platforms/iOS/vm/Common/Classes/sqSqueakScreenAPI.m
    trunk/platforms/iOS/vm/Common/Classes/sqSqueakScreenAndWindow.m
    trunk/platforms/iOS/vm/Common/main.m
    trunk/platforms/iOS/vm/English.lproj/MainMenu.xib
    trunk/platforms/iOS/vm/OSX/BitMapConversionLogicFromX11.h
    trunk/platforms/iOS/vm/OSX/SqViewBitmapConversion.h
    trunk/platforms/iOS/vm/OSX/SqViewBitmapConversion.m
    trunk/platforms/iOS/vm/OSX/SqViewClut.h
    trunk/platforms/iOS/vm/OSX/SqViewClut.m
    trunk/platforms/iOS/vm/OSX/SqueakOSXAppDelegate.h
    trunk/platforms/iOS/vm/OSX/SqueakOSXAppDelegate.m
    trunk/platforms/iOS/vm/OSX/SqueakOSXApplication.m
    trunk/platforms/iOS/vm/OSX/plugins/HostWindowPlugin/sqMacHostWindow.m
    trunk/platforms/iOS/vm/OSX/sqMacUnixExternalPrims.m
    trunk/platforms/iOS/vm/OSX/sqSqueakOSXApplication+attributes.m
    trunk/platforms/iOS/vm/OSX/sqSqueakOSXApplication+events.h
    trunk/platforms/iOS/vm/OSX/sqSqueakOSXApplication+events.m
    trunk/platforms/iOS/vm/OSX/sqSqueakOSXApplication+imageReadWrite.m
    trunk/platforms/iOS/vm/OSX/sqSqueakOSXApplication.m
    trunk/platforms/iOS/vm/OSX/sqSqueakOSXDropAPI.m
    trunk/platforms/iOS/vm/OSX/sqSqueakOSXFileDirectoryInterface.m
    trunk/platforms/iOS/vm/OSX/sqSqueakOSXInfoPlistInterface.m
    trunk/platforms/iOS/vm/OSX/sqSqueakOSXScreenAndWindow.h
    trunk/platforms/iOS/vm/OSX/sqSqueakOSXScreenAndWindow.m
    trunk/platforms/iOS/vm/SqueakPureObjc-Info 64x64.plist
    trunk/platforms/iOS/vm/SqueakPureObjc-Info.plist
    trunk/platforms/iOS/vm/SqueakPureObjc.xcodeproj/project.pbxproj
    trunk/platforms/iOS/vm/SqueakPureObjc.xcodeproj/project.xcworkspace/xcuserdata/johnmci.xcuserdatad/UserInterfaceState.xcuserstate
    trunk/platforms/iOS/vm/SqueakPureObjc.xcodeproj/xcuserdata/johnmci.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
    trunk/platforms/iOS/vm/SqueakPureObjc.xcodeproj/xcuserdata/johnmci.xcuserdatad/xcschemes/SqueakPureObjc64*64.xcscheme
    trunk/platforms/iOS/vm/iPhone/Classes/SqueakNoOGLIPhoneAppDelegate.m
    trunk/platforms/iOS/vm/iPhone/Classes/SqueakUIView.m
    trunk/platforms/iOS/vm/iPhone/Classes/SqueakUIViewCALayer.m
    trunk/platforms/iOS/vm/iPhone/Classes/SqueakUIViewOpenGL.m
    trunk/platforms/iOS/vm/iPhone/Classes/sqSqueakIPhoneApplication+events.m
    trunk/platforms/iOS/vm/iPhone/Classes/sqSqueakIPhoneApplication+imageReadWrite.m
    trunk/platforms/iOS/vm/iPhone/Classes/sqSqueakIPhoneInfoPlistInterface.h
    trunk/platforms/iOS/vm/iPhone/Classes/sqSqueakIPhoneInfoPlistInterface.m
    trunk/platforms/iOS/vm/iPhone/plugins/ClipboardExtended/sqMacExtendedClipboard.m
    trunk/platforms/iOS/vm/iPhone/plugins/HostWindowPlugin/sqMacHostWindow.c
    trunk/platforms/iOS/vm/iPhone/sqDummyaio.c
    trunk/platforms/iOS/vm/iPhone/sqMacV2Memory.c

Added Paths:
-----------
    trunk/platforms/iOS/vm/OSX/sqSqueakOSXOpenGLView.h
    trunk/platforms/iOS/vm/OSX/sqSqueakOSXOpenGLView.m

Removed Paths:
-------------
    trunk/platforms/iOS/vm/OSX/sqSqueakOSXNSView.h
    trunk/platforms/iOS/vm/OSX/sqSqueakOSXNSView.m

Modified: trunk/platforms/iOS/plugins/ClipboardExtended/sqMacExtendedClipboard.m
===================================================================
--- trunk/platforms/iOS/plugins/ClipboardExtended/sqMacExtendedClipboard.m	2015-05-07 01:47:30 UTC (rev 3323)
+++ trunk/platforms/iOS/plugins/ClipboardExtended/sqMacExtendedClipboard.m	2015-05-07 18:23:28 UTC (rev 3324)
@@ -35,7 +35,7 @@
 
 void sqPasteboardClear(CLIPBOARDTYPE inPasteboard )
 {
-	NSArray *arrayOfTypes = [[NSArray alloc] init];
+	NSArray *arrayOfTypes = [NSArray array];
 	
 	[inPasteboard declareTypes: arrayOfTypes owner: nil];
 
@@ -77,7 +77,7 @@
 {	
 	NSString *formatType = [[NSString alloc] initWithBytes: format length: formatLength encoding:  NSUTF8StringEncoding];
 	NSData* data = [[NSData alloc ] initWithBytes: inData length: dataLength];
-	NSArray *arrayOfTypes = [[NSArray alloc] initWithObjects: formatType,nil];
+	NSArray *arrayOfTypes = @[formatType];
 
 	[inPasteboard declareTypes: arrayOfTypes owner: nil];
 	[inPasteboard setData: data forType: formatType];
@@ -87,7 +87,7 @@
 sqInt sqPasteboardCopyItemFlavorDataformatformatLength ( CLIPBOARDTYPE inPasteboard, char* format, sqInt formatLength)
 {
 	NSString *formatType = [[NSString alloc] initWithBytes: format length: formatLength encoding:  NSUTF8StringEncoding];
-	NSArray *arrayOfTypes = [[NSArray alloc] initWithObjects: formatType,nil];
+	NSArray *arrayOfTypes = @[formatType];
 	NSString     *type= [inPasteboard availableTypeFromArray: arrayOfTypes];
 														
 	if (type == NULL) {

Modified: trunk/platforms/iOS/vm/Common/Classes/sqSqueakAppDelegate.h
===================================================================
--- trunk/platforms/iOS/vm/Common/Classes/sqSqueakAppDelegate.h	2015-05-07 01:47:30 UTC (rev 3323)
+++ trunk/platforms/iOS/vm/Common/Classes/sqSqueakAppDelegate.h	2015-05-07 18:23:28 UTC (rev 3324)
@@ -55,4 +55,5 @@
 - (void) workerThreadStart;
 - (void) singleThreadStart;
 - (NSTimeInterval) squeakUIFlushPrimaryDeferNMilliseconds;
+- (sqSqueakMainApplication *) makeApplicationInstance;
 @end

Modified: trunk/platforms/iOS/vm/Common/Classes/sqSqueakAttributesAPI.m
===================================================================
--- trunk/platforms/iOS/vm/Common/Classes/sqSqueakAttributesAPI.m	2015-05-07 01:47:30 UTC (rev 3323)
+++ trunk/platforms/iOS/vm/Common/Classes/sqSqueakAttributesAPI.m	2015-05-07 18:23:28 UTC (rev 3324)
@@ -48,11 +48,16 @@
 
 sqInt attributeSize(sqInt indexNumber)  {
 	//API Documented
-	return  (sqInt) strlen([gDelegateApp.squeakApplication getAttribute: indexNumber]);
+    const char *arg = [gDelegateApp.squeakApplication getAttribute: indexNumber];
+    if (arg != NULL) {
+        return  (sqInt) strlen(arg);
+    } else {
+        return 0;
+    }
 }
 
 sqInt getAttributeIntoLength(sqInt indexNumber, sqInt byteArrayIndex, sqInt length)  {
 	//API Documented
 	[gDelegateApp.squeakApplication getAttribute: indexNumber into: pointerForOop((usqInt) byteArrayIndex) length: length];
 	return 0;
-}
\ No newline at end of file
+}

Modified: trunk/platforms/iOS/vm/Common/Classes/sqSqueakEventsAPI.m
===================================================================
--- trunk/platforms/iOS/vm/Common/Classes/sqSqueakEventsAPI.m	2015-05-07 01:47:30 UTC (rev 3323)
+++ trunk/platforms/iOS/vm/Common/Classes/sqSqueakEventsAPI.m	2015-05-07 18:23:28 UTC (rev 3324)
@@ -48,31 +48,43 @@
 extern BOOL gQuitNowRightNow;
 extern sqSqueakScreenAndWindow *getMainWindowDelegate();
 
-sqInt ioProcessEvents(void) {
+void nativeIoProcessEvents(void) {
+
 	//API Documented
-	
-	aioPoll(0);		
-	
-	if ([[NSThread currentThread] isCancelled]) {
-		gQuitNowRightNow = YES;
-		return 0;
-	}
-	
+		
+    if ([[NSThread currentThread] isCancelled]) {
+        gQuitNowRightNow = YES;
+        ioExit();  //This might not return, might call exittoshell
+    }
+
 	if ([getMainWindowDelegate() forceUpdateFlush]) {
 		[getMainWindowDelegate() ioForceDisplayUpdate];
 	}
 
-	if (interpreterProxy->methodPrimitiveIndex() != 0) {
+	if (interpreterProxy->methodPrimitiveIndex() == 0) {
+		[gDelegateApp.squeakApplication pumpRunLoopEventSendAndSignal:YES];
+    } else {
 		[gDelegateApp.squeakApplication pumpRunLoop];
 	}
 	
 	if (gQuitNowRightNow) {
 		ioExit();  //This might not return, might call exittoshell
 	}
-	
-	return 0;
 }
 
+void (*ioProcessEventsHandler) (void) = nativeIoProcessEvents;
+
+extern void setIoProcessEventsHandler(void * handler) {
+    ioProcessEventsHandler = (void(*)()) handler;
+}
+
+sqInt ioProcessEvents(void) {
+    aioPoll(0);
+    if(ioProcessEventsHandler)
+        ioProcessEventsHandler();
+    return 0;
+}
+
 sqInt ioSetInputSemaphore(sqInt semaIndex) {
 	//API Documented
 	

Modified: trunk/platforms/iOS/vm/Common/Classes/sqSqueakFileDirectoryAPI.m
===================================================================
--- trunk/platforms/iOS/vm/Common/Classes/sqSqueakFileDirectoryAPI.m	2015-05-07 01:47:30 UTC (rev 3323)
+++ trunk/platforms/iOS/vm/Common/Classes/sqSqueakFileDirectoryAPI.m	2015-05-07 18:23:28 UTC (rev 3324)
@@ -82,10 +82,25 @@
 	//API Documented
 	return DELIMITERInt;
 }
+sqInt dir_Lookup2(char *pathString, sqInt pathStringLength, sqInt index,
+                  /* outputs */
+                  char *name, sqInt *nameLength, sqInt *creationDate, sqInt *modificationDate,
+                  sqInt *isDirectory, squeakFileOffsetType *sizeIfFile, sqInt *posixPermissions, sqInt *isSymlink);
 
 sqInt dir_Lookup(char *pathString, sqInt pathStringLength, sqInt index,
 /* outputs: */  char *name, sqInt *nameLength, sqInt *creationDate, sqInt *modificationDate,
-				 sqInt *isDirectory, squeakFileOffsetType *sizeIfFile)
+                 sqInt *isDirectory, squeakFileOffsetType *sizeIfFile) {
+    sqInt posixPermissions;
+    sqInt isSymlink;
+    sqInt status = dir_Lookup2(pathString, pathStringLength, index, name, nameLength, creationDate, modificationDate, isDirectory, sizeIfFile,&posixPermissions,&isSymlink);
+    return status;
+}
+
+
+sqInt dir_Lookup2(char *pathString, sqInt pathStringLength, sqInt index,
+                 /* outputs */
+                 char *name, sqInt *nameLength, sqInt *creationDate, sqInt *modificationDate,
+				 sqInt *isDirectory, squeakFileOffsetType *sizeIfFile, sqInt *posixPermissions, sqInt *isSymlink)
 {
 	//API Documented
 	/* Lookup the index-th entry of the directory with the given path, starting
@@ -107,26 +122,34 @@
 			length: nameLength 
 			creationDate: creationDate 
 			modificationDate: modificationDate
-			isDirectory: isDirectory 
-			sizeIfFile: sizeIfFile];
+			isDirectory: isDirectory
+			sizeIfFile: sizeIfFile
+            posixPermissions: posixPermissions
+            isSymlink: isSymlink];
 	return status;
 }
 
 sqInt dir_EntryLookup(char *pathString, sqInt pathStringLength, char* nameString, sqInt nameStringLength,
 /* outputs: */  char *name, sqInt *nameLength, sqInt *creationDate, sqInt *modificationDate,
-					  sqInt *isDirectory, squeakFileOffsetType *sizeIfFile)
+					  sqInt *isDirectory, squeakFileOffsetType *sizeIfFile, sqInt *posixPermissions, sqInt *isSymlink)
 {
+	
+	/*Implementation notes
+	 if pathStringLength = 0 then we use the current working directory
+	 if pathStringLength > 0 then we resolve the pathString and alias */
 	sqInt status =
 	[gDelegateApp.squeakApplication.fileDirectoryLogic dir_EntryLookup: pathString 
 														   length: pathStringLength 
 															returnName: nameString
 													  returnNameLength: nameStringLength	
-															 name:  name
+															 name: name
 														   length: nameLength 
 													 creationDate: creationDate 
 												 modificationDate: modificationDate
-													  isDirectory: isDirectory 
-													   sizeIfFile: sizeIfFile];
+													  isDirectory: isDirectory
+													   sizeIfFile: sizeIfFile
+                                                 posixPermissions: posixPermissions
+                                                        isSymlink: isSymlink];
 	return status;
 }
 

Modified: trunk/platforms/iOS/vm/Common/Classes/sqSqueakFileDirectoryInterface.h
===================================================================
--- trunk/platforms/iOS/vm/Common/Classes/sqSqueakFileDirectoryInterface.h	2015-05-07 01:47:30 UTC (rev 3323)
+++ trunk/platforms/iOS/vm/Common/Classes/sqSqueakFileDirectoryInterface.h	2015-05-07 18:23:28 UTC (rev 3324)
@@ -54,18 +54,23 @@
 			  length: (sqInt *) nameLength 
 		creationDate: (sqInt *) creationDate 
 	modificationDate: (sqInt *) modificationDate
-		 isDirectory: (sqInt *) isDirectory 
-		  sizeIfFile: (squeakFileOffsetType *) sizeIfFile;
+		 isDirectory: (sqInt *) isDirectory
+		  sizeIfFile: (squeakFileOffsetType *) sizeIfFile
+    posixPermissions: (sqInt *)posix
+           isSymlink: (sqInt *) isSymlink;
 
-- (sqInt) dir_Lookup: (const char *) pathString 
+- (sqInt) dir_Lookup: (const char *) pathString
 			  length: (sqInt) pathStringLength 
 			   index: (sqInt) index 
 				name: (char *) name
 			  length: (sqInt *) nameLength 
 		creationDate: (sqInt *) creationDate 
 	modificationDate: (sqInt *) modificationDate
-		 isDirectory: (sqInt *) isDirectory 
-		  sizeIfFile: (squeakFileOffsetType *) sizeIfFile;
+		 isDirectory: (sqInt *) isDirectory
+		  sizeIfFile: (squeakFileOffsetType *) sizeIfFile
+    posixPermissions: (sqInt *)posixPermissions
+           isSymlink: (sqInt *) isSymlink;
+
 - (sqInt) dir_Create: (char *) pathString
 			  length: (sqInt) pathStringLength;
 - (sqInt) dir_Delete: (char *) pathString

Modified: trunk/platforms/iOS/vm/Common/Classes/sqSqueakFileDirectoryInterface.m
===================================================================
--- trunk/platforms/iOS/vm/Common/Classes/sqSqueakFileDirectoryInterface.m	2015-05-07 01:47:30 UTC (rev 3323)
+++ trunk/platforms/iOS/vm/Common/Classes/sqSqueakFileDirectoryInterface.m	2015-05-07 18:23:28 UTC (rev 3324)
@@ -2,9 +2,10 @@
 //  sqSqueakFileDirectoryInterface.m
 //  
 //
-//  Created by John M McIntosh on 6/14/08.
+//  Author: John M McIntosh
+//  Author: Esteban Lorenzano
+//  Author: Camillo Bruni
 //
-//
 /*
  Some of this code was funded via a grant from the European Smalltalk User Group (ESUG)
  Copyright (c) 2008 Corporate Smalltalk Consulting Ltd. All rights reserved.
@@ -40,6 +41,7 @@
 
 #import "sqSqueakFileDirectoryInterface.h"
 #import "sqSqueakFileDirectoryAPI.h"
+#include <sys/stat.h>
 
 @implementation sqSqueakFileDirectoryInterface
 @synthesize lastPathForDirLookup;
@@ -51,45 +53,129 @@
 	return YES;
 }
 
-- (sqInt) dir_EntryLookup: (const char *) pathString 
-			  length: (sqInt) pathStringLength 
-		  returnName: (char *) nameString
-	returnNameLength: (sqInt) nameStringLength	
-				name: (char *) name
-			  length: (sqInt *) nameLength 
-		creationDate: (sqInt *) creationDate 
-	modificationDate: (sqInt *) modificationDate
-		 isDirectory: (sqInt *) isDirectory 
-		  sizeIfFile: (squeakFileOffsetType *) sizeIfFile {
-#warning this is not implementation
-	return 0;
+
+/*** Constants ***/
+	
+#define ENTRY_FOUND     0
+#define NO_MORE_ENTRIES 1
+#define BAD_PATH        2
+
+- (sqInt)linkIsDirectory:(NSString *)filePath fileManager:(NSFileManager *)fileManager {
+    NSString *resolvedPath = [self resolvedAliasFiles: filePath];
+	NSDictionary *fileAttributes;
+    NSError *error;
+    
+	fileAttributes = [fileManager attributesOfItemAtPath:resolvedPath error: &error];
+    return [[fileAttributes objectForKey: NSFileType] isEqualToString: NSFileTypeDirectory] ? 1 : 0;
 }
 
+- (sqInt)attributesForPath:(NSString *)filePath 
+                   fileMgr:(NSFileManager *)fileMgr 
+               isDirectory:(sqInt *)isDirectory
+              creationDate:(sqInt *)creationDate
+          modificationDate:(sqInt *)modificationDate
+                sizeIfFile:(off_t *)sizeIfFile
+          posixPermissions:(sqInt *)posixPermissions
+                 isSymlink:(sqInt *)isSymlink {
+    
+	//This minics the unix port where we resolve the file name, but the symbolic file lookup can fail. 
+	//The unix port says, oh file was there, but stat/lstat fails, so mmm kinda continue
+	//However to deal with Finder Aliases we have to be more clever.
+	
+	NSDictionary *fileAttributes;
+    NSError *error;
+    
+	fileAttributes        = [fileMgr attributesOfItemAtPath: filePath error: &error];
+    if (!fileAttributes) {
+        return BAD_PATH;
+    }
+    
+    *isSymlink        = [[fileAttributes objectForKey: NSFileType] isEqualToString: NSFileTypeSymbolicLink] ? 1 : 0;
+    if(*isSymlink) {
+        //I need to check if symlink points to a directory
+        *isDirectory  = [self linkIsDirectory:filePath fileManager:fileMgr];
+    } else {
+        *isDirectory  = [[fileAttributes objectForKey: NSFileType] isEqualToString: NSFileTypeDirectory] ? 1 : 0;
+	}
+    *creationDate     = convertToSqueakTime([fileAttributes objectForKey: NSFileCreationDate ]);
+	*modificationDate = convertToSqueakTime([fileAttributes objectForKey: NSFileModificationDate]);
+	*sizeIfFile       = [[fileAttributes objectForKey: NSFileSize] integerValue];
+	*posixPermissions = [[fileAttributes objectForKey: NSFilePosixPermissions] shortValue];
+	
+	/* POSSIBLE IPHONE BUG CHECK */
+	if (*creationDate == 0) 
+		*creationDate = *modificationDate;
+	
+	return ENTRY_FOUND;
+}
 
-- (sqInt) dir_Lookup: (const char *) pathString 
-			  length: (sqInt) pathStringLength 
-			   index: (sqInt) index 
-				name: (char *) name
-			  length: (sqInt *) nameLength 
-		creationDate: (sqInt *) creationDate 
-	modificationDate: (sqInt *) modificationDate
-		 isDirectory: (sqInt *) isDirectory 
-		  sizeIfFile: (squeakFileOffsetType *) sizeIfFile {
+- (sqInt) dir_EntryLookup:(const char *) pathString
+			  length:(sqInt) pathStringLength
+		  returnName:(char *) nameString
+	returnNameLength:(sqInt) nameStringLength
+				name:(char *) name
+			  length:(sqInt *) nameLength
+		creationDate:(sqInt *) creationDate
+	modificationDate:(sqInt *) modificationDate
+		 isDirectory:(sqInt *) isDirectory
+		  sizeIfFile:(squeakFileOffsetType *) sizeIfFile
+    posixPermissions:(sqInt *)posixPermissions
+           isSymlink:(sqInt *) isSymlink {
 	
+   	NSFileManager * fileMgr = [NSFileManager defaultManager];
+    NSString*	directoryPath = NULL;
+	NSString*	filePath;
+	NSString*	fileName;
+
+    *sizeIfFile       = 0;
+
+    if (nameStringLength <= 0 || pathStringLength <= 0)
+        return BAD_PATH;
+        
+	directoryPath = [[NSString alloc] initWithBytes: pathString length: (NSUInteger) pathStringLength encoding: NSUTF8StringEncoding];
+    fileName      = [[NSString alloc] initWithBytes: nameString length: (NSUInteger) nameStringLength encoding: NSUTF8StringEncoding];
+	
+    if (![directoryPath hasSuffix: @"/"]) {
+        directoryPath = [directoryPath stringByAppendingString: @"/"];
+    }
+	filePath      = [directoryPath stringByAppendingString: fileName];
+	
+	strlcpy(name,[fileName UTF8String], 256);
+    
+    *name         = *nameString;
+	*nameLength   = nameStringLength;
+
+    return [self
+        attributesForPath: filePath
+        fileMgr: fileMgr
+        isDirectory: isDirectory
+        creationDate: creationDate
+        modificationDate: modificationDate
+        sizeIfFile: sizeIfFile
+        posixPermissions: posixPermissions
+        isSymlink: isSymlink];
+}
+
+
+- (sqInt) dir_Lookup:(const char *) pathString
+			  length:(sqInt) pathStringLength
+			   index:(sqInt) index
+				name:(char *) name
+			  length:(sqInt *) nameLength
+		creationDate:(sqInt *) creationDate
+	modificationDate:(sqInt *) modificationDate
+		 isDirectory:(sqInt *) isDirectory
+		  sizeIfFile:(squeakFileOffsetType *) sizeIfFile
+    posixPermissions:(sqInt *) posixPermissions
+           isSymlink:(sqInt *) isSymlink {
+	
 	NSFileManager * fileMgr = [NSFileManager defaultManager];
 	NSString*	directoryPath = NULL;
 	NSString*	filePath;
 	NSString*	fileName;
-	NSDictionary * fileAttributes;
 	BOOL		readDirectory = false;
 	
-	/*** Constants ***/
 	
-#define ENTRY_FOUND     0
-#define NO_MORE_ENTRIES 1
-#define BAD_PATH        2
-	
-	
 	/* default return values */
 	*name             = 0;
 	*nameLength       = 0;
@@ -102,10 +188,12 @@
 		self.lastPathForDirLookup =[fileMgr currentDirectoryPath];
 	}
 	
-	if (pathStringLength > 0) 
+	if (pathStringLength > 0) {
 		directoryPath = [[NSString alloc] initWithBytes: pathString length: (NSUInteger) pathStringLength encoding: NSUTF8StringEncoding];
-	if (directoryPath == NULL)
+    }
+	if (directoryPath == NULL) {
 		return BAD_PATH;
+    }
 	
 	if ([self.lastPathForDirLookup isEqualToString: directoryPath]) {
 		if (lastIndexForDirLookup >= index)
@@ -138,43 +226,18 @@
 	filePath = directoryContentsForDirLookup[(NSUInteger) (index-1)];
 	filePath = [[ lastPathForDirLookup stringByAppendingString: @"/"] stringByAppendingString: filePath] ;
 	fileName = [[filePath lastPathComponent] precomposedStringWithCanonicalMapping];
-	strlcpy(name,[fileName UTF8String],256);
+	strlcpy(name,[fileName UTF8String], 256);
 	*nameLength = (sqInt) strlen(name);
-
-	//This minics the unix port where we resolve the file name, but the symbolic file lookup can fail. 
-	//The unix port says, oh file was there, but stat/lstat fails, so mmm kinda continue
-	//However to deal with Finder Aliases we have to be more clever.
-	
-	NSError *error;
-	NSString *fileType;
-	NSString *newFilePath = [self resolvedAliasFiles: filePath];
-	
-	fileAttributes = [fileMgr attributesOfItemAtPath: filePath error: &error];  
-
-	if ([filePath isEqualToString: newFilePath]) {
-		if (!fileAttributes) {
-			return ENTRY_FOUND;
-		}
-		fileType = fileAttributes[NSFileType];
-		*isDirectory = [fileType isEqualToString: NSFileTypeDirectory] ? 1 : 0;
-	} else {
-		NSDictionary *fileAttributesPossibleAlias = [fileMgr attributesOfItemAtPath: newFilePath error: &error];  // do symbolic link
-		if (!fileAttributes) 
-			fileAttributes = fileAttributesPossibleAlias;
-		
-		fileType = fileAttributesPossibleAlias[NSFileType];
-		*isDirectory = [fileType isEqualToString: NSFileTypeDirectory] ? 1 : 0;
-	}
-
-	*creationDate = convertToSqueakTime(fileAttributes[NSFileCreationDate]);
-	*modificationDate = convertToSqueakTime(fileAttributes[NSFileModificationDate]);
-	*sizeIfFile = [fileAttributes[NSFileSize] integerValue];
-	
-	/* POSSIBLE IPHONE BUG CHECK */
-	if (*creationDate == 0) 
-		*creationDate = *modificationDate;
-	
-	return ENTRY_FOUND;
+    
+    return [self 
+        attributesForPath: filePath
+        fileMgr: fileMgr
+        isDirectory: isDirectory
+        creationDate: creationDate
+        modificationDate: modificationDate
+        sizeIfFile: sizeIfFile
+        posixPermissions: posixPermissions
+        isSymlink: isSymlink];
 }
 
 - (sqInt) dir_Create: (char *) pathString

Modified: trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApp.h
===================================================================
--- trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApp.h	2015-05-07 01:47:30 UTC (rev 3323)
+++ trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApp.h	2015-05-07 18:23:28 UTC (rev 3324)
@@ -38,6 +38,8 @@
 */
 //
 
-void sigsegv(int ignore);
+void attachToSignals();
+
+void sigsegv(int sig, siginfo_t *info, void *uap);
 void mtfsfi(unsigned long long fpscr);
-void fldcw(unsigned int cw);
\ No newline at end of file
+void fldcw(unsigned int cw);

Modified: trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApp.m
===================================================================
--- trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApp.m	2015-05-07 01:47:30 UTC (rev 3323)
+++ trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApp.m	2015-05-07 18:23:28 UTC (rev 3324)
@@ -43,34 +43,46 @@
 //
 
 #import "sqSqueakAppDelegate.h"
-
 #import "sq.h"
 #import "sqSqueakMainApp.h"
 #import "sqMacV2Memory.h"
 #import <limits.h>
+#import "sqPlatformSpecific.h"
 
+#if COGVM
+#import "sqSCCSVersion.h"
+#else
+#endif
+
+#if !defined(NOEXECINFO)
+# include <execinfo.h>
+# define BACKTRACE_DEPTH 64
+#endif
+
+
 #warning what about these guyes?
 /*** Variables -- globals for access from pluggable primitives ***/
-int		argCnt= 0;
-char	**argVec= 0;
-char	**envVec= 0;
+EXPORT(int)		argCnt= 0;
+EXPORT(char**)	argVec= 0;
+EXPORT(char**)	envVec= 0;
 
 extern sqSqueakAppDelegate *gDelegateApp;
 
-BOOL			gQuitNowRightNow=false,gSqueakHeadless=false;
+BOOL			gQuitNowRightNow=NO;
+BOOL            gSqueakHeadless=NO;
 int				gSqueakUseFileMappedMMAP=0;
 char            gSqueakUntrustedDirectoryName[PATH_MAX];
 char            gSqueakTrustedDirectoryName[PATH_MAX];
 
-sqInt printAllStacks(void);
-sqInt printCallStack(void);
+extern sqInt printAllStacks(void);
+extern sqInt printCallStack(void);
 extern void dumpPrimTraceLog(void);
 extern BOOL NSApplicationLoad(void);
 
-#if COGVM || STACKVM 
 /* Print an error message, possibly a stack trace, and exit. */
 /* Disable Intel compiler inlining of error which is used for breakpoints */
 #pragma auto_inline off
+#if COGVM || STACKVM
 void
 error(char *msg)
 {
@@ -79,7 +91,7 @@
 	
 	printf("\n%s\n\n", msg);
 	
-	if (ioOSThreadsEqual(ioCurrentOSThread(),getVMThread())) {
+	if (ioOSThreadsEqual(ioCurrentOSThread(),getVMOSThread())) {
 		if (!printingStack) {
 			printingStack = true;
 			printf("\n\nSmalltalk stack dump:\n");
@@ -89,35 +101,185 @@
 	else
 		printf("\nCan't dump Smalltalk stack. Not in VM thread\n");
 	printf("\nMost recent primitives\n");
-	dumpPrimTraceLog();
+#if COGVM
+    dumpPrimTraceLog();
+#endif
 	abort();
 }
 #pragma auto_inline on
 
-void sigsegv(int ignore)
+/*
+ * Signal handlers
+ *
+ */
+
+/* Print an error message, possibly a stack trace, do /not/ exit.
+ * Allows e.g. writing to a log file and stderr.
+ */
+static void
+reportStackState(char *msg, char *date, int printAll, ucontext_t *uap)
 {
-#pragma unused(ignore)
-	
-	error("Segmentation fault");
+#if !defined(NOEXECINFO)
+	void *addrs[BACKTRACE_DEPTH];
+	int depth;
+#endif
+	/* flag prevents recursive error when trying to print a broken stack */
+	static sqInt printingStack = false;
+    
+	printf("\n%s%s%s\n\n", msg, date ? " " : "", date ? date : "");
+#if COGVM
+    printf("%s\n\n", sourceVersionString());
+#endif
+    
+#if !defined(NOEXECINFO)
+	printf("C stack backtrace:\n");
+	fflush(stdout); /* backtrace_symbols_fd uses unbuffered i/o */
+	depth = backtrace(addrs, BACKTRACE_DEPTH);
+	backtrace_symbols_fd(addrs, depth, fileno(stdout));
+#endif
+    
+	if (ioOSThreadsEqual(ioCurrentOSThread(),getVMOSThread())) {
+		if (!printingStack) {
+#if COGVM
+			/* If we're in generated machine code then the only way the stack
+			 * dump machinery has of giving us an accurate report is if we set
+			 * stackPointer & framePointer to the native stack & frame pointers.
+			 */
+# if __APPLE__ && __MACH__ && __i386__
+            /* see sys/ucontext.h; two different namings */
+#	if __GNUC__ && !__INTEL_COMPILER /* icc pretends to be gcc */
+			void *fp = (void *)(uap ? uap->uc_mcontext->__ss.__ebp: 0);
+			void *sp = (void *)(uap ? uap->uc_mcontext->__ss.__esp: 0);
+#	else
+			void *fp = (void *)(uap ? uap->uc_mcontext->ss.ebp: 0);
+			void *sp = (void *)(uap ? uap->uc_mcontext->ss.esp: 0);
+#	endif
+# elif __linux__ && __i386__
+			void *fp = (void *)(uap ? uap->uc_mcontext.gregs[REG_EBP]: 0);
+			void *sp = (void *)(uap ? uap->uc_mcontext.gregs[REG_ESP]: 0);
+# else
+#	error need to implement extracting pc from a ucontext_t on this system
+# endif
+			char *savedSP, *savedFP;
+            
+			ifValidWriteBackStackPointersSaveTo(fp,sp,&savedFP,&savedSP);
+#endif
+            
+			printingStack = true;
+			if (printAll) {
+				printf("\n\nAll Smalltalk process stacks (active first):\n");
+				printAllStacks();
+			}
+			else {
+				printf("\n\nSmalltalk stack dump:\n");
+				printCallStack();
+			}
+			printingStack = false;
+#if COGVM
+			/* Now restore framePointer and stackPointer via same function */
+			ifValidWriteBackStackPointersSaveTo(savedFP,savedSP,0,0);
+#endif
+		}
+	}
+	else
+		printf("\nCan't dump Smalltalk stack(s). Not in VM thread\n");
+#if STACKVM
+	printf("\nMost recent primitives\n");
+	dumpPrimTraceLog();
+#endif
+	printf("\n\t(%s)\n", msg);
+	fflush(stdout);
 }
-#else
-void sigsegv(int ignore)
+
+static void
+getCrashDumpFilenameInto(char *buf)
 {
-#pragma unused(ignore)
-	
-	/* error("Segmentation fault"); */
-	static int printingStack= 0;
-	
-	printf("\nSegmentation fault\n\ns");
-	if (!printingStack)
-	{
-		printingStack= 1;
-		printAllStacks();
+    char *slash;
+    
+    strcpy(buf,imageName);
+    slash = strrchr(buf,'/');
+    strcpy(slash ? slash + 1 : buf, "crash.dmp");
+}
+
+void
+sigusr1(int sig, siginfo_t *info, void *uap)
+{
+	int saved_errno = errno;
+	time_t now = time(NULL);
+	char ctimebuf[32];
+	char crashdump[imageNameSize()+1];
+	unsigned long pc;
+    
+	if (!ioOSThreadsEqual(ioCurrentOSThread(),getVMOSThread())) {
+		pthread_kill(getVMOSThread(),sig);
+		errno = saved_errno;
+		return;
 	}
+    
+	getCrashDumpFilenameInto(crashdump);
+	ctime_r(&now,ctimebuf);
+	pushOutputFile(crashdump);
+	reportStackState("SIGUSR1", ctimebuf, 1, uap);
+	popOutputFile();
+	reportStackState("SIGUSR1", ctimebuf, 1, uap);
+    
+	errno = saved_errno;
+}
+
+void
+sigsegv(int sig, siginfo_t *info, void *uap)
+{
+	time_t now = time(NULL);
+	char ctimebuf[32];
+	char crashdump[imageNameSize()+1];
+    
+	getCrashDumpFilenameInto(crashdump);
+	ctime_r(&now,ctimebuf);
+	pushOutputFile(crashdump);
+	reportStackState("Segmentation fault", ctimebuf, 0, uap);
+	popOutputFile();
+	reportStackState("Segmentation fault", ctimebuf, 0, uap);
 	abort();
 }
+#else
+
+void sigsegv(int sig, siginfo_t *info, void *uap)
+{
+    
+    /* error("Segmentation fault"); */
+    static int printingStack= 0;
+    
+    printf("\nSegmentation fault\n\ns");
+    if (!printingStack)
+    {
+        printingStack= 1;
+        printAllStacks();
+    }
+    abort();
+}
 #endif
 
+/*
+ * End of signal handlers
+ *
+ */
+
+void attachToSignals() {
+#if COGVM
+	struct sigaction sigusr1_handler_action, sigsegv_handler_action;
+        
+    sigsegv_handler_action.sa_sigaction = sigsegv;
+    sigsegv_handler_action.sa_flags = SA_NODEFER | SA_SIGINFO;
+    sigemptyset(&sigsegv_handler_action.sa_mask);
+    (void)sigaction(SIGSEGV, &sigsegv_handler_action, 0);
+        
+    sigusr1_handler_action.sa_sigaction = sigusr1;
+    sigusr1_handler_action.sa_flags = SA_NODEFER | SA_SIGINFO;
+    sigemptyset(&sigusr1_handler_action.sa_mask);
+    (void)sigaction(SIGUSR1, &sigusr1_handler_action, 0);
+#endif
+}
+
 sqInt ioExit(void) {
 	//API Documented
  	[gDelegateApp.squeakApplication ioExit];
@@ -164,14 +326,55 @@
 # endif /* defined(i386) || defined(__i386) || defined(__i386__) */
 
 
-#endif /* COGVM */
+/* Answer an approximation of the size of the redzone (if any).  Do so by
+ * sending a signal to the process and computing the difference between the
+ * stack pointer in the signal handler and that in the caller. Assumes stacks
+ * descend.
+ */
 
-#if !COGVM && STACKVM 
-void
-dumpPrimTraceLog(void) {};
+#if !defined(min)
+# define min(x,y) (((x)>(y))?(y):(x))
 #endif
+static char *p = 0;
 
+static void
+sighandler(int sig) { p = (char *)&sig; }
+
+static int
+getRedzoneSize()
+{
+	struct sigaction handler_action, old;
+	handler_action.sa_sigaction = sighandler;
+	handler_action.sa_flags = SA_NODEFER | SA_SIGINFO;
+	sigemptyset(&handler_action.sa_mask);
+	(void)sigaction(SIGPROF, &handler_action, &old);
+
+	do kill(getpid(),SIGPROF); while (!p);
+	(void)sigaction(SIGPROF, &old, 0);
+	return (char *)min(&old,&handler_action) - sizeof(struct sigaction) - p;
+}
+
+sqInt reportStackHeadroom;
+static int stackPageHeadroom;
+
+/* Answer the redzone size plus space for any signal handlers to run in.
+ * N.B. Space for signal handers may include space for the dynamic linker to
+ * run in since signal handlers may reference other functions, and linking may
+ * be lazy.  The reportheadroom switch can be used to check empirically that
+ * there is sufficient headroom.  At least on Mac OS X we see no large stack
+ * usage that would indicate e.g. dynamic linking in signal handlers.
+ * So answer only the redzone size and likely get small (2048 byte) pages.
+ */
+int
+osCogStackPageHeadroom()
+{
+	if (!stackPageHeadroom)
+		stackPageHeadroom = getRedzoneSize();
+	return stackPageHeadroom;
+}
+
+#endif /* COGVM */
+
 /* Andreas' stubs */
 char* ioGetLogDirectory(void) { return ""; };
 sqInt ioSetLogDirectoryOfSize(void* lblIndex, sqInt sz){ return 1; }
-

Modified: trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+attributes.m
===================================================================
--- trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+attributes.m	2015-05-07 01:47:30 UTC (rev 3323)
+++ trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+attributes.m	2015-05-07 18:23:28 UTC (rev 3324)
@@ -39,6 +39,9 @@
 
 #import "sqSqueakMainApplication+attributes.h"
 #import "sqSqueakMainApplication+vmAndImagePath.h"
+#if COGVM
+#include "sqSCCSVersion.h"
+#endif
 
 extern struct VirtualMachine* interpreterProxy;
 
@@ -55,46 +58,74 @@
 		strncpy(byteArrayIndex, [self getAttribute: indexNumber], (size_t) length); //This does not need to be strlcpy
 }
 
+- (char *) interpreterVersionString {
+	static char data[255];
+	bzero(data,sizeof(data));
+	strlcat(data,interpreterVersion,sizeof(data));
+	strlcat(data," ",sizeof(data));
+	NSString *versionString =[[NSBundle mainBundle] objectForInfoDictionaryKey: @"CFBundleVersion"];
+	
+	if (versionString == nil)
+		return data;
+	const char *versonStringAsCString =  [versionString cStringUsingEncoding: [self currentVMEncoding]];
+	
+	if (versonStringAsCString == nil)
+		return data;
+	
+	strlcat(data,versonStringAsCString,sizeof(data));
+	
+	return data;
+}
+
 - (const char *) getAttribute:(sqInt)indexNumber {
-	//indexNumber is a postive/negative number
-	
-	if (indexNumber < 0)	/* VM argument */ {
-		if (-indexNumber <= [self.argsArguments count])
-            return (char *) [(self.argsArguments)[(NSUInteger) (indexNumber - 1)] cStringUsingEncoding: [self currentVMEncoding]];
-	}
-	else {
+	//indexNumber is a postive/negative number	
+	if (indexNumber < 0) /* VM argument */ {
+#ifndef TARGET_OS_IS_IPHONE        
+        if (-indexNumber < ([self.commandLineArguments count] - 1)) {
+			return (char *) [[self.commandLineArguments objectAtIndex: -indexNumber] cStringUsingEncoding:[self currentVMEncoding]];
+		}
+#endif
+	} else {
 		switch (indexNumber) {
 			case 0: 
-				return (char *) [self getVMPath];
+                return [[[[NSBundle mainBundle] executablePath] precomposedStringWithCanonicalMapping] UTF8String];
 
-			case 1: 
-				return (char *) [self getImageName];
-				
-			case 1004:  { /* Interpreter version string */
-				
-				static char data[255];
-				bzero(data,sizeof(data));
-				strlcat(data,interpreterVersion,sizeof(data));
-				strlcat(data," ",sizeof(data));
-				NSString *versionString =[[NSBundle mainBundle] objectForInfoDictionaryKey: @"CFBundleVersion"];
-				if (versionString == nil)
-					return data;
-				const char *versonStringAsCString =  [ versionString cStringUsingEncoding: [self currentVMEncoding]];
-				if (versonStringAsCString == nil)
-					return data;
-				strlcat(data,versonStringAsCString,sizeof(data));
-				return data;
-			}
+			case 1:
+				return [self getImageName];
 
+            case 1004:  /* Interpreter version string */
+				return [self interpreterVersionString];
+			
+            case 1009: {/* source tree version info */
+#if COGVM
+				return sourceVersionString();
+#else
+                static char data[255];
+                bzero(data,sizeof(data));
+                strlcat(data,interpreterVersion,sizeof(data));
+                strlcat(data," ",sizeof(data));
+                NSString *versionString =[[NSBundle mainBundle] objectForInfoDictionaryKey: @"CFBundleVersion"];
+                if (versionString == nil)
+                    return data;
+                const char *versonStringAsCString =  [ versionString cStringUsingEncoding: [self currentVMEncoding]];
+                if (versonStringAsCString == nil)
+                    return data;
+                strlcat(data,versonStringAsCString,sizeof(data));
+                return data;
+#endif
+            }
 			case 1201: /* macintosh file name size */
 				return "255";
 
 			case 1202: /* macintosh file error peek */
 				return "0";
-				
-			default: 
-				if ((indexNumber - 2) > 0 && ((indexNumber - 2) < [self.argsArguments count]))
-					return (char *) [(self.argsArguments)[(NSUInteger) (indexNumber - 2)] cStringUsingEncoding: [self currentVMEncoding]];
+			
+			default: {
+				int indexOfArg = indexNumber - 1;
+				if (indexOfArg < [self.argsArguments count]) {
+					return (char *) [[self.argsArguments objectAtIndex: (NSUInteger) indexOfArg] cStringUsingEncoding:[self currentVMEncoding]];			
+				}
+			}
 		}
 	}
 	interpreterProxy->success(false);

Modified: trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+events.h
===================================================================
--- trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+events.h	2015-05-07 01:47:30 UTC (rev 3323)
+++ trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+events.h	2015-05-07 18:23:28 UTC (rev 3324)
@@ -41,5 +41,6 @@
 @interface sqSqueakMainApplication (events)
 - (void) ioGetNextEvent: (sqInputEvent *) evt;
 - (void) processAsOldEventOrComplexEvent: (id) event placeIn: (sqInputEvent *) evt;
+- (void) pumpRunLoopEventSendAndSignal:(BOOL)signal;
 - (void) pumpRunLoop;
 @end

Modified: trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+events.m
===================================================================
--- trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+events.m	2015-05-07 01:47:30 UTC (rev 3323)
+++ trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+events.m	2015-05-07 18:23:28 UTC (rev 3324)
@@ -40,6 +40,10 @@
 
 @implementation sqSqueakMainApplication  (events) 
 
+- (void) pumpRunLoopEventSendAndSignal:(BOOL)signal {
+    //It should be redefined by my children
+}
+
 - (void) pumpRunLoop {
 /*	static NSTimeInterval old = 0.0;
 	
@@ -54,8 +58,9 @@
 	 described by http://developer.apple.com/qa/qa2001/qa1061.html
 	 but fails on device, bug tracking number  5971848 */
 
-	NSRunLoop *theRL = [NSRunLoop mainRunLoop];
-	BOOL result = [theRL runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantPast]];
+	BOOL result = [[NSRunLoop mainRunLoop] 
+            runMode:NSDefaultRunLoopMode 
+            beforeDate:[NSDate distantPast]];
 	
 	//		while(CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, TRUE) == kCFRunLoopRunHandledSource);
 	

Modified: trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+imageReadWrite.m
===================================================================
--- trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+imageReadWrite.m	2015-05-07 01:47:30 UTC (rev 3323)
+++ trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+imageReadWrite.m	2015-05-07 18:23:28 UTC (rev 3324)
@@ -38,6 +38,9 @@
 
 #import "sqSqueakMainApplication+imageReadWrite.h"
 #import "sqMacV2Memory.h"
+#ifdef SPURVM
+#  include <sys/stat.h>
+#endif
 
 @implementation sqSqueakMainApplication (imageReadWrite) 
 - (void) findImageViaBundleOrPreferences {
@@ -51,9 +54,29 @@
 		return NO;
 	}
 	f = sqImageFileOpen(characterPathForImage, "rb");
-	readImageFromFileHeapSizeStartingAt(f, sqGetAvailableMemory(), (squeakFileOffsetType) 0);  //This is a VM Callback
+	if (f == 0) {
+		fprintf(stderr, "Failed to open image named %s", characterPathForImage);
+		exit(-1);
+	}
+
+#ifdef SPURVM
+    extern sqInt highBit(usqInt);
+    usqInt memory = 0;
+    {
+        struct stat sb;
+        stat(characterPathForImage, &sb);
+
+        off_t size = (long)sb.st_size;
+        size = 1 << highBit(size-1);
+        size = size + size / 4;
+        memory =  size + size / 4;
+    }
+#else
+    usqInt memory = sqGetAvailableMemory();
+#endif
+	readImageFromFileHeapSizeStartingAt(f, memory, (squeakFileOffsetType) 0);  //This is a VM Callback
 	sqImageFileClose(f);
+            }
 	return YES;
-            }
 }
 @end

Modified: trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+sound.m
===================================================================
--- trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+sound.m	2015-05-07 01:47:30 UTC (rev 3323)
+++ trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+sound.m	2015-05-07 18:23:28 UTC (rev 3324)
@@ -38,6 +38,10 @@
 #import "sqSqueakMainApplication+sound.h"
 
 @implementation sqSqueakMainApplication (sound)
+
 - (void) ioBeep {
+#ifdef BUILD_FOR_OSX
+    NSBeep();
+#endif
 }
- at end
\ No newline at end of file
+ at end

Modified: trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+vmAndImagePath.m
===================================================================
--- trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+vmAndImagePath.m	2015-05-07 01:47:30 UTC (rev 3323)
+++ trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+vmAndImagePath.m	2015-05-07 18:23:28 UTC (rev 3324)
@@ -47,13 +47,14 @@
 @implementation sqSqueakMainApplication (vmAndImagePath) 
 
 - (void) setVMPathFromApplicationDirectory {
+    // in the default case return /Applications otherwise the path the .app is contained in
 	self.vmPathStringURL = [NSURL fileURLWithPath: [[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent]];
 }
 
 - (BOOL) ImageNameIsEmpty {
 	if (self.imageNameURL) 
-		return false;
-	return true;
+		return NO;
+	return YES;
 }
 
 - (const char *) getImageName {
@@ -63,7 +64,6 @@
 - (void) imageNameGet:(char *) sqImageName length:(sqInt)length {
 	//sqImageName is actually the address of where to put the data
 	//length is how many bytes the target can hold
-	
 	if (!sqImageName) 
 		return;
 	
@@ -84,7 +84,7 @@
 }
 
 - (const char *) getVMPath {
-	return [[[[self vmPathStringURL] path] precomposedStringWithCanonicalMapping] UTF8String];
+    return [[[[self vmPathStringURL] path] precomposedStringWithCanonicalMapping] UTF8String];
 }
 
 - (void) vmPathGet:(char *) sqVMPath length:(sqInt)length {

Modified: trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication.h
===================================================================
--- trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication.h	2015-05-07 01:47:30 UTC (rev 3323)
+++ trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication.h	2015-05-07 18:23:28 UTC (rev 3324)
@@ -51,11 +51,13 @@
 	NSURL*		imageNameURL;
 	NSStringEncoding	currentVMEncoding;
 	NSMutableArray *argsArguments;
+	NSMutableArray                  *commandLineArguments;
 	sqSqueakFileDirectoryInterface* fileDirectoryLogic;
 	sqSqueakInfoPlistInterface*		infoPlistInterfaceLogic;
 	sqSqueakSoundCoreAudio*			soundInterfaceLogic;
 	sqInt	inputSemaphoreIndex;		//event semaphore for VM thread
 	Queue* eventQueue;						//event queue for user events from UI thread
+    BOOL                            noHandlers;
 }
 - (void) setupFloat;
 - (void) setupErrorRecovery;
@@ -64,6 +66,7 @@
 - (void) doHeadlessSetup;
 - (void) doMemorySetup;
 - (void) parseUnixArgs;
+- (void) attachToSignals;
 - (void) setupMenus;
 - (void) setupTimers;
 - (void) setupAIO;
@@ -71,13 +74,12 @@
 - (void) setupBrowserLogic;
 - (void) setupSoundLogic;
 - (void) runSqueak;
-- (void) tearDown;
 - (void) MenuBarRestore;
 - (void) ioExit;
 - (void) ioExitWithErrorCode: (int) ec;
 - (sqSqueakFileDirectoryInterface *) newFileDirectoryInterfaceInstance;
-- (void) imageNamePut:(const char *) sqImageName;
 
+ at property BOOL noHandlers;
 @property (nonatomic,strong) NSURL* vmPathStringURL;
 @property (nonatomic,strong) sqSqueakInfoPlistInterface* infoPlistInterfaceLogic;
 @property (nonatomic,strong) sqSqueakSoundCoreAudio* soundInterfaceLogic;
@@ -87,5 +89,6 @@
 @property (nonatomic,strong) Queue* eventQueue;
 @property (nonatomic,strong) sqSqueakFileDirectoryInterface * fileDirectoryLogic;
 @property (nonatomic,strong) NSMutableArray* argsArguments;
+ at property (nonatomic,strong) NSMutableArray*commandLineArguments;
 @end
 

Modified: trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication.m
===================================================================
--- trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication.m	2015-05-07 01:47:30 UTC (rev 3323)
+++ trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication.m	2015-05-07 18:23:28 UTC (rev 3324)
@@ -64,9 +64,19 @@
 @synthesize infoPlistInterfaceLogic;
 @synthesize soundInterfaceLogic;
 @synthesize argsArguments;
+ at synthesize commandLineArguments;
+ at synthesize noHandlers;
 
 extern sqInt interpret(void);  //This is a VM Callback
 
+- (id) init {
+    self = [super init];
+    if (self) {
+        [self setNoHandlers: NO];
+    }
+    return self;
+}
+
 - (void) setupFloat {
 }
 
@@ -74,12 +84,24 @@
 	signal(SIGSEGV, sigsegv);
 }
 
+- (void) setInfoPlistInterfaceLogic:(sqSqueakInfoPlistInterface *)anObject {
+    infoPlistInterfaceLogic = anObject;
+}
+
+- (sqSqueakInfoPlistInterface *) infoPlistInterfaceLogic {
+    if (!infoPlistInterfaceLogic) {
+        [self fetchPreferences];
+    }
+    
+    return infoPlistInterfaceLogic;
+}
+
 - (sqSqueakInfoPlistInterface *) newSqSqueakInfoPlistInterfaceCreation {
 	return [[sqSqueakInfoPlistInterface alloc] init];
 }
 
 - (void) fetchPreferences {
-	infoPlistInterfaceLogic = [self newSqSqueakInfoPlistInterfaceCreation];
+	self.infoPlistInterfaceLogic = [self newSqSqueakInfoPlistInterfaceCreation];
 	[infoPlistInterfaceLogic parseInfoPlist]; 
 	currentVMEncoding = NSUTF8StringEncoding;
 }
@@ -95,6 +117,7 @@
 }
 
 - (void) setupMenus {
+//    nothing to do so far since the menu is setup in the MainMenu.nib file
 }
 
 - (void) setupTimers {
@@ -114,6 +137,10 @@
 	eventQueue = [[Queue alloc] init];
 }
 
+- (void) attachToSignals {
+//  Override in subclasses
+}
+
 - (void) setupBrowserLogic {
 }
 
@@ -141,18 +168,17 @@
 	}
 	
 	[self parseUnixArgs];
-	
+	[self attachToSignals];
+    
 	//JMM here we parse the unixArgs
 	//JMM now we wait for the open document apple events (normally)
-	
-	[self doHeadlessSetup];
-	//JMM after wait normally if headless and no imageName then exit -42
-	
+	   
 	[self doMemorySetup];
 	
-	if ([self ImageNameIsEmpty]) 
+	if ([self ImageNameIsEmpty]) {
 		[self findImageViaBundleOrPreferences];
-	
+	}
+
 	if ([self ImageNameIsEmpty]) {
 		return;
 	}
@@ -161,7 +187,12 @@
 		return;
 	}
 	
-	[self setupMenus];
+    // The headless setup is now after the image setup on purpose. This is in order to be
+    // able to select an image with the popup even when running headless
+	[self doHeadlessSetup];
+
+    
+    [self setupMenus];
 	[self setupTimers];
 	[self setupAIO];
 	[self setupBrowserLogic];
@@ -169,16 +200,13 @@
 	[gDelegateApp makeMainWindow];
 	
 	interpret();
-    [self tearDown];
     }
-	[NSThread exit];
 }
 
-- (void) tearDown{
-    
-}
 
 - (void) MenuBarRestore {
+    //    nothing to do so far since the menu is setup in the MainMenu.nib file
+    
 }
 
 void sqMacMemoryFree(void);
@@ -194,12 +222,6 @@
 }
 
 - (void)dealloc {
-//	[infoPlistInterfaceLogic release];
-//	[soundInterfaceLogic release];
-//	[vmPathStringURL release];
-//	[imageNameURL release];
-//	[fileDirectoryLogic release];
-//	[eventQueue release];
 	sqMacMemoryFree();
 }
 

Modified: trunk/platforms/iOS/vm/Common/Classes/sqSqueakScreenAPI.m
===================================================================
--- trunk/platforms/iOS/vm/Common/Classes/sqSqueakScreenAPI.m	2015-05-07 01:47:30 UTC (rev 3323)
+++ trunk/platforms/iOS/vm/Common/Classes/sqSqueakScreenAPI.m	2015-05-07 18:23:28 UTC (rev 3324)
@@ -53,7 +53,7 @@
 
 sqSqueakScreenAndWindow *getMainWindowDelegate() {
 #ifdef BUILD_FOR_OSX
-	return (windowHandleFromIndex(1)).delegate;
+	return ((NSWindow *) windowHandleFromIndex(1)).delegate;
 #else
 	return [gDelegateApp screenAndWindow];
 #endif

Modified: trunk/platforms/iOS/vm/Common/Classes/sqSqueakScreenAndWindow.m
===================================================================
--- trunk/platforms/iOS/vm/Common/Classes/sqSqueakScreenAndWindow.m	2015-05-07 01:47:30 UTC (rev 3323)
+++ trunk/platforms/iOS/vm/Common/Classes/sqSqueakScreenAndWindow.m	2015-05-07 18:23:28 UTC (rev 3324)
@@ -71,6 +71,7 @@
         // Initialization code here.
 		squeakUIFlushPrimaryDeferNMilliseconds = 0.0f;
 		forceUpdateFlush = NO;
+#warning why is this YES in Pharo?
 		displayIsDirty = NO;
 	}
     return self;
@@ -104,9 +105,12 @@
 }
 
 - (sqInt) ioHasDisplayDepth: (sqInt) depth {
-	if (depth == 32) 
+	if (depth == 2 || depth ==  4 || depth == 8 || depth == 16 || depth == 32 ||
+        depth == -2 || depth ==  -4 || depth == -8 || depth == -16 || depth == -32) { 
 		return true;
-	return false;
+    } else {
+        return false;
+    }
 }
 
 - (void) ioForceDisplayUpdateActual {
@@ -137,7 +141,6 @@
 					windowIndex: (int) passedWindowIndex {
 	
 	static CGColorSpaceRef colorspace = NULL;
-	sqInt 		pitch;
 	windowDescriptorBlock *targetWindowBlock = windowBlockFromIndex(passedWindowIndex);	
 	
 	if (colorspace == NULL) {
@@ -157,9 +160,6 @@
 		return 0;
 	}
 	
-	
-	pitch = ((((width)*(depth) + 31) >> 5) << 2);
-		
 	CGRect clip = CGRectMake((CGFloat)affectedL,(CGFloat)(height-affectedB), (CGFloat)(affectedR-affectedL), (CGFloat)(affectedB-affectedT));
 	[gDelegateApp.mainView drawImageUsingClip: clip];
 

Modified: trunk/platforms/iOS/vm/Common/main.m
===================================================================
--- trunk/platforms/iOS/vm/Common/main.m	2015-05-07 01:47:30 UTC (rev 3323)
+++ trunk/platforms/iOS/vm/Common/main.m	2015-05-07 18:23:28 UTC (rev 3324)
@@ -39,8 +39,16 @@
 #ifdef BUILD_FOR_OSX
 #import <Cocoa/Cocoa.h>
 
-int main(int argc, char *argv[])
+int main(int argc, char **argv, char **envp)
 {	
+	extern int argCnt;
+	extern char **argVec;
+	extern char **envVec;
+	
+	argCnt = argc;
+	argVec= argv;
+	envVec = envp;
+	
     return NSApplicationMain(argc,  (const char **) argv);
 }
 #else
@@ -53,4 +61,4 @@
 		return retVal;
 	}
 }
-#endif 
\ No newline at end of file
+#endif 

Modified: trunk/platforms/iOS/vm/English.lproj/MainMenu.xib
===================================================================
--- trunk/platforms/iOS/vm/English.lproj/MainMenu.xib	2015-05-07 01:47:30 UTC (rev 3323)
+++ trunk/platforms/iOS/vm/English.lproj/MainMenu.xib	2015-05-07 18:23:28 UTC (rev 3324)
@@ -1,29 +1,30 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
+<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
 	<data>
-		<int key="IBDocument.SystemTarget">1060</int>
-		<string key="IBDocument.SystemVersion">10F569</string>
-		<string key="IBDocument.InterfaceBuilderVersion">804</string>
-		<string key="IBDocument.AppKitVersion">1038.29</string>
-		<string key="IBDocument.HIToolboxVersion">461.00</string>
+		<int key="IBDocument.SystemTarget">1070</int>
+		<string key="IBDocument.SystemVersion">14D136</string>
+		<string key="IBDocument.InterfaceBuilderVersion">7702</string>
+		<string key="IBDocument.AppKitVersion">1347.57</string>
+		<string key="IBDocument.HIToolboxVersion">758.70</string>
 		<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
 			<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
-			<string key="NS.object.0">804</string>
+			<string key="NS.object.0">7702</string>
 		</object>
-		<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
-			<bool key="EncodedWithXMLCoder">YES</bool>
-			<integer value="371"/>
-		</object>
-		<object class="NSArray" key="IBDocument.PluginDependencies">
-			<bool key="EncodedWithXMLCoder">YES</bool>
+		<array key="IBDocument.IntegratedClassDependencies">
+			<string>NSCustomObject</string>
+			<string>NSMenu</string>
+			<string>NSMenuItem</string>
+			<string>NSView</string>
+			<string>NSWindowTemplate</string>
+		</array>
+		<array key="IBDocument.PluginDependencies">
 			<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-		</object>
+		</array>
 		<object class="NSMutableDictionary" key="IBDocument.Metadata">
 			<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
 			<integer value="1" key="NS.object.0"/>
 		</object>
-		<object class="NSMutableArray" key="IBDocument.RootObjects" id="1048">
-			<bool key="EncodedWithXMLCoder">YES</bool>
+		<array class="NSMutableArray" key="IBDocument.RootObjects" id="1048">
 			<object class="NSCustomObject" id="1021">
 				<string key="NSClassName">NSApplication</string>
 			</object>
@@ -35,8 +36,7 @@
 			</object>
 			<object class="NSMenu" id="649796088">
 				<string key="NSTitle">AMainMenu</string>
-				<object class="NSMutableArray" key="NSMenuItems">
-					<bool key="EncodedWithXMLCoder">YES</bool>
+				<array class="NSMutableArray" key="NSMenuItems">
 					<object class="NSMenuItem" id="694149608">
 						<reference key="NSMenu" ref="649796088"/>
 						<string key="NSTitle">SqueakOSXApp</string>
@@ -52,10 +52,10 @@
 							<string key="NSResourceName">NSMenuMixedState</string>
 						</object>
 						<string key="NSAction">submenuAction:</string>
+						<reference key="NSTarget" ref="110575045"/>
 						<object class="NSMenu" key="NSSubmenu" id="110575045">
 							<string key="NSTitle">SqueakOSXApp</string>
-							<object class="NSMutableArray" key="NSMenuItems">
-								<bool key="EncodedWithXMLCoder">YES</bool>
+							<array class="NSMutableArray" key="NSMenuItems">
 								<object class="NSMenuItem" id="238522557">
 									<reference key="NSMenu" ref="110575045"/>
 									<string key="NSTitle">About SqueakOSXApp</string>
@@ -104,11 +104,10 @@
 									<reference key="NSOnImage" ref="35465992"/>
 									<reference key="NSMixedImage" ref="502551668"/>
 									<string key="NSAction">submenuAction:</string>
+									<reference key="NSTarget" ref="752062318"/>
 									<object class="NSMenu" key="NSSubmenu" id="752062318">
 										<string key="NSTitle">Services</string>
-										<object class="NSMutableArray" key="NSMenuItems">
-											<bool key="EncodedWithXMLCoder">YES</bool>
-										</object>
+										<array class="NSMutableArray" key="NSMenuItems"/>
 										<string key="NSName">_NSServicesMenu</string>
 									</object>
 								</object>
@@ -173,7 +172,7 @@
 									<reference key="NSOnImage" ref="35465992"/>
 									<reference key="NSMixedImage" ref="502551668"/>
 								</object>
-							</object>
+							</array>
 							<string key="NSName">_NSAppleMenu</string>
 						</object>
 					</object>
@@ -188,10 +187,10 @@
 						<reference key="NSOnImage" ref="35465992"/>
 						<reference key="NSMixedImage" ref="502551668"/>
 						<string key="NSAction">submenuAction:</string>
+						<reference key="NSTarget" ref="720053764"/>
 						<object class="NSMenu" key="NSSubmenu" id="720053764">
 							<string key="NSTitle">File</string>
-							<object class="NSMutableArray" key="NSMenuItems">
-								<bool key="EncodedWithXMLCoder">YES</bool>
+							<array class="NSMutableArray" key="NSMenuItems">
 								<object class="NSMenuItem" id="705341025">
 									<reference key="NSMenu" ref="720053764"/>
 									<string key="NSTitle">New</string>
@@ -219,10 +218,10 @@

@@ Diff output truncated at 50000 characters. @@


More information about the Vm-dev mailing list