|
From: John M M. <jo...@us...> - 2003-12-02 05:02:07
|
Update of /cvsroot/squeak/squeak/platforms/Mac OS/vm
In directory sc8-pr-cvs1:/tmp/cvs-serv14526/squeak/platforms/Mac OS/vm
Modified Files:
sqMacMain.c
Log Message:
3.7.0b2 Changes for file name encoding. Ensure we use current encoding when working with file names. Change logic in vmPath, imageName, shortImageName, documentName to support CFString which we convert to desired encoding at read time.
Index: sqMacMain.c
===================================================================
RCS file: /cvsroot/squeak/squeak/platforms/Mac OS/vm/sqMacMain.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** sqMacMain.c 3 Oct 2003 19:06:27 -0000 1.18
--- sqMacMain.c 2 Dec 2003 04:52:46 -0000 1.19
***************
*** 64,67 ****
--- 64,68 ----
* 3.5.1b3 June 7th, 2003 JMM fix up full screen pthread issue.
* 3.6.x Sept 1st, 2003 JMM per note from Bert Freudenberg <be...@is...> changed 1003 parm to lowercase.
+ * 3.7.0bx Nov 24th, 2003 JMM gCurrentVMEncoding
*/
***************
*** 83,86 ****
--- 84,88 ----
#include "sqMacUIEvents.h"
#include "sqMacMemory.h"
+ #include "sqMacEncoding.h"
#ifdef __MPW__
***************
*** 99,105 ****
#include "aio.h"
#endif
! extern char shortImageName[];
! extern char documentName[];
! extern char vmPath[];
extern int getFullScreenFlag();
extern unsigned char *memory;
--- 101,105 ----
#include "aio.h"
#endif
!
extern int getFullScreenFlag();
extern unsigned char *memory;
***************
*** 112,116 ****
OSErr gSqueakFileLastError;
Boolean gSqueakWindowIsFloating,gSqueakWindowHasTitle=true,gSqueakFloatingWindowGetsFocus=false;
! UInt32 gMaxHeapSize=512*1024*1024;
#ifdef BROWSERPLUGIN
--- 112,116 ----
OSErr gSqueakFileLastError;
Boolean gSqueakWindowIsFloating,gSqueakWindowHasTitle=true,gSqueakFloatingWindowGetsFocus=false;
! UInt32 gMaxHeapSize=512*1024*1024,gSqueakWindowType,gSqueakWindowAttributes;
#ifdef BROWSERPLUGIN
***************
*** 129,132 ****
--- 129,133 ----
static pascal void* squeakThread(void *threadParm);
void SetUpCarbonEvent();
+ void fetchPrefrences();
/*** Main ***/
***************
*** 147,150 ****
--- 148,152 ----
OSErr err;
long threadGestaltInfo;
+ char shortImageName[256];
/* check the interpreter's size assumptions for basic data types */
***************
*** 171,174 ****
--- 173,177 ----
SetUpMenus();
SetUpClipboard();
+ fetchPrefrences();
SetUpWindow();
***************
*** 177,183 ****
#endif
/* install apple event handlers and wait for open event */
- imageName[0] = shortImageName[0] = documentName[0] = vmPath[0] = 0;
InstallAppleEventHandlers();
! while (shortImageName[0] == 0) {
GetNextEvent(everyEvent, &theEvent);
if (theEvent.what == kHighLevelEvent) {
--- 180,185 ----
#endif
/* install apple event handlers and wait for open event */
InstallAppleEventHandlers();
! while (ShortImageNameIsEmpty()) {
GetNextEvent(everyEvent, &theEvent);
if (theEvent.what == kHighLevelEvent) {
***************
*** 186,190 ****
}
! if (imageName[0] == 0) {
FSSpec workingDirectory;
#if TARGET_API_MAC_CARBON && !defined(__MWERKS__)
--- 188,194 ----
}
! getShortImageNameWithEncoding(shortImageName,gCurrentVMEncoding);
!
! if (ImageNameIsEmpty()) {
FSSpec workingDirectory;
#if TARGET_API_MAC_CARBON && !defined(__MWERKS__)
***************
*** 197,201 ****
if (imageURL != NULL) {
imagePath = CFURLCopyFileSystemPath (imageURL, kCFURLHFSPathStyle);
! CFStringGetCString (imagePath, imageName, IMAGE_NAME_SIZE, CFStringGetSystemEncoding());
} else {
#endif
--- 201,207 ----
if (imageURL != NULL) {
imagePath = CFURLCopyFileSystemPath (imageURL, kCFURLHFSPathStyle);
! SetImageNameViaCFString(imagePath);
! CFRelease(imageURL);
! CFRelease(imagePath);
} else {
#endif
***************
*** 204,209 ****
if (err != noErr)
error("Could not obtain default directory");
! CopyCStringToPascal("squeak.image",workingDirectory.name);
! PathToFile(imageName, IMAGE_NAME_SIZE, &workingDirectory);
#if TARGET_API_MAC_CARBON && !defined(__MWERKS__)
}
--- 210,215 ----
if (err != noErr)
error("Could not obtain default directory");
! CopyCStringToPascal("Squeak.image",workingDirectory.name);
! SetImageName(&workingDirectory);
#if TARGET_API_MAC_CARBON && !defined(__MWERKS__)
}
***************
*** 215,219 ****
/* read the image file and allocate memory for Squeak heap */
! f = sqImageFileOpen(imageName, "rb");
while (f == NULL) {
//Failure attempt to ask the user to find the image file
--- 221,225 ----
/* read the image file and allocate memory for Squeak heap */
! f = sqImageFileOpen(getImageName(), "rb");
while (f == NULL) {
//Failure attempt to ask the user to find the image file
***************
*** 221,226 ****
FSSpec vmfsSpec,imageFsSpec;
WDPBRec wdPB;
!
! err = makeFSSpec(vmPath,vmPathSize(),&vmfsSpec);
if (err)
ioExit();
--- 227,235 ----
FSSpec vmfsSpec,imageFsSpec;
WDPBRec wdPB;
! char path[VMPATH_SIZE + 1];
!
! getVMPathWithEncoding(path,gCurrentVMEncoding);
!
! err = makeFSSpec(path,strlen(path),&vmfsSpec);
if (err)
ioExit();
***************
*** 229,233 ****
ioExit();
CopyPascalStringToC(imageFsSpec.name,shortImageName);
! PathToFile(imageName, IMAGE_NAME_SIZE, &imageFsSpec);
/* make the image or document directory the working directory */
--- 238,243 ----
ioExit();
CopyPascalStringToC(imageFsSpec.name,shortImageName);
! SetShortImageNameViaString(shortImageName,gCurrentVMEncoding);
! SetImageName(&imageFsSpec);
/* make the image or document directory the working directory */
***************
*** 236,240 ****
wdPB.ioWDDirID = imageFsSpec.parID;
PBHSetVolSync(&wdPB);
! f = sqImageFileOpen(imageName, "rb");
}
--- 246,250 ----
wdPB.ioWDDirID = imageFsSpec.parID;
PBHSetVolSync(&wdPB);
! f = sqImageFileOpen(getImageName(), "rb");
}
***************
*** 451,460 ****
// id #0 should return the full name of VM; for now it just returns its path
! if (id == 0) return vmPath;
/* Note: 1.3x images will try to read the image as a document because they
expect attribute #1 to be the document name. A 1.3x image can be patched
using a VM of 2.6 or earlier. */
! if (id == 1) return imageName;
! if (id == 2) return documentName;
#ifdef BROWSERPLUGIN
--- 461,483 ----
// id #0 should return the full name of VM; for now it just returns its path
! if (id == 0) {
! static char path[VMPATH_SIZE + 1];
! getVMPathWithEncoding(path,gCurrentVMEncoding);
! return path;
! }
/* Note: 1.3x images will try to read the image as a document because they
expect attribute #1 to be the document name. A 1.3x image can be patched
using a VM of 2.6 or earlier. */
! if (id == 1) {
! static char path[IMAGE_NAME_SIZE + 1];
! getImageNameWithEncoding(path,gCurrentVMEncoding);
! return path;
! }
!
! if (id == 2) {
! static char path[DOCUMENT_NAME_SIZE + 1];
! getDocumentNameWithEncoding(path,gCurrentVMEncoding);
! return path;
! }
#ifdef BROWSERPLUGIN
***************
*** 500,504 ****
strcat(data,interpreterVersion);
strcat(data," ");
! CFStringGetCString (versionString, data+strlen(data), 255-strlen(data), CFStringGetSystemEncoding());
return data;
}
--- 523,527 ----
strcat(data,interpreterVersion);
strcat(data," ");
! CFStringGetCString (versionString, data+strlen(data), 255-strlen(data), gCurrentVMEncoding);
return data;
}
***************
*** 564,570 ****
}
- /* clear all path and file names */
- imageName[0] = shortImageName[0] = documentName[0] = vmPath[0] = 0;
-
SetUpTimers();
PowerMgrCheck();
--- 587,590 ----
***************
*** 598,601 ****
--- 618,685 ----
#endif
+
+ #if TARGET_API_MAC_CARBON
+ void fetchPrefrences() {
+ CFBundleRef myBundle;
+ CFDictionaryRef myDictionary;
+ CFNumberRef SqueakWindowType,SqueakMaxHeapSizeType;
+ CFBooleanRef SqueakWindowHasTitleType,SqueakFloatingWindowGetsFocusType;
+ CFDataRef SqueakWindowAttributeType;
+ CFStringRef SqueakVMEncodingType;
+ char encoding[256];
+
+ myBundle = CFBundleGetMainBundle();
+ myDictionary = CFBundleGetInfoDictionary(myBundle);
+ SqueakWindowType = CFDictionaryGetValue(myDictionary, CFSTR("SqueakWindowType"));
+ SqueakWindowAttributeType = CFDictionaryGetValue(myDictionary, CFSTR("SqueakWindowAttribute"));
+ SqueakWindowHasTitleType = CFDictionaryGetValue(myDictionary, CFSTR("SqueakWindowHasTitle"));
+ SqueakFloatingWindowGetsFocusType = CFDictionaryGetValue(myDictionary, CFSTR("SqueakFloatingWindowGetsFocus"));
+ SqueakMaxHeapSizeType = CFDictionaryGetValue(myDictionary, CFSTR("SqueakMaxHeapSize"));
+ SqueakVMEncodingType = CFDictionaryGetValue(myDictionary, CFSTR("SqueakEncodingType"));
+
+
+ if (SqueakVMEncodingType)
+ CFStringGetCString (SqueakVMEncodingType, encoding, 255, kCFStringEncodingMacRoman);
+ else
+ *encoding = 0x00;
+
+ setEncodingType(encoding);
+
+ if (SqueakWindowType)
+ CFNumberGetValue(SqueakWindowType,kCFNumberLongType,&gSqueakWindowType);
+ else
+ gSqueakWindowType = kDocumentWindowClass;
+
+ gSqueakWindowIsFloating = gSqueakWindowType == kUtilityWindowClass;
+
+ if (SqueakWindowAttributeType && CFDataGetLength(SqueakWindowAttributeType) == 4) {
+ const UInt8 *where;
+ where = CFDataGetBytePtr(SqueakWindowAttributeType);
+ memmove(&gSqueakWindowAttributes,where,4);
+ } else {
+ gSqueakWindowAttributes = kWindowStandardDocumentAttributes
+ +kWindowStandardHandlerAttribute
+ +kWindowNoConstrainAttribute
+ -kWindowCloseBoxAttribute;
+ }
+
+ if (SqueakWindowHasTitleType)
+ gSqueakWindowHasTitle = CFBooleanGetValue(SqueakWindowHasTitleType);
+ else
+ gSqueakWindowHasTitle = true;
+
+ if (SqueakFloatingWindowGetsFocusType)
+ gSqueakFloatingWindowGetsFocus = CFBooleanGetValue(SqueakFloatingWindowGetsFocusType);
+ else
+ gSqueakFloatingWindowGetsFocus = false;
+
+ if (SqueakMaxHeapSizeType)
+ CFNumberGetValue(SqueakMaxHeapSizeType,kCFNumberLongType,(long *) &gMaxHeapSize);
+
+ }
+ #else
+ void fetchPrefrences() {}
+ #endif
+
/*** Profiling Stubs ***/
|