Skip to content

Commit

Permalink
OSCogVM source as per VMMaker-oscog.54.
Browse files Browse the repository at this point in the history
- Fix FFI by fixing includesbehaviorThatOf so classes no longer inherit from nil
- Adopt the squeakvm HostWindowPlugin and SoundPlugin.
- Including support for weak finalizers.


git-svn-id: http://squeakvm.org/svn/squeak/branches/Cog@2376 fa1542d4-bde8-0310-ad64-8ed1123d492a

Former-commit-id: de055033770efcdf13ed28e4f37a38e98ab2a4e6
  • Loading branch information
eliotmiranda committed Apr 1, 2011
1 parent 33ec7cb commit a4a7841
Show file tree
Hide file tree
Showing 47 changed files with 4,626 additions and 9,313 deletions.
1 change: 1 addition & 0 deletions cygwinbuild/plugins.int
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ SerialPlugin \
SocketPlugin \
SoundCodecPrims \
SoundGenerationPlugin \
SoundPlugin \
StarSqueakPlugin \
SurfacePlugin \
UUIDPlugin
2 changes: 0 additions & 2 deletions image/VMMaker-Squeak4.1.changes

This file was deleted.

1 change: 1 addition & 0 deletions image/VMMaker-Squeak4.1.changes.REMOVED.git-id
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5ce7d315b52bee2ca6e8265b2107407336cc8ef1
2 changes: 1 addition & 1 deletion image/VMMaker-Squeak4.1.image.REMOVED.git-id
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6ef85dd743b6c7ae82a48f925cd959502e4c0e0f
79f8806a40b2cb94ea858fb4f104aeeece228463
4 changes: 0 additions & 4 deletions macbuild/CoreVM.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@
A27729A80CE7AFBE00ABAFCA /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A27729A70CE7AFBE00ABAFCA /* SystemConfiguration.framework */; };
A2835CFF0E07A13300308978 /* sqHeapMap.c in Sources */ = {isa = PBXBuildFile; fileRef = A2835CFE0E07A13300308978 /* sqHeapMap.c */; };
A2C08F430EA3E0FD0036416C /* dispdbg.h in Headers */ = {isa = PBXBuildFile; fileRef = A2C08F420EA3E0FD0036416C /* dispdbg.h */; };
A2C843B9108A614E00E438C0 /* sqMacAudioDeviceList.c in Sources */ = {isa = PBXBuildFile; fileRef = A2C843B8108A614E00E438C0 /* sqMacAudioDeviceList.c */; };
A2F27E691087169800F905FB /* nsPoolManagement.h in Headers */ = {isa = PBXBuildFile; fileRef = A2F27E671087169800F905FB /* nsPoolManagement.h */; };
A2F27E6A1087169800F905FB /* nsPoolManagement.m in Sources */ = {isa = PBXBuildFile; fileRef = A2F27E681087169800F905FB /* nsPoolManagement.m */; };
A2FB6B590CCD71B000A29088 /* sqMacLocaleCarbon.c in Sources */ = {isa = PBXBuildFile; fileRef = A2FB6B570CCD71B000A29088 /* sqMacLocaleCarbon.c */; };
Expand Down Expand Up @@ -398,7 +397,6 @@
A27729A70CE7AFBE00ABAFCA /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = /System/Library/Frameworks/SystemConfiguration.framework; sourceTree = "<absolute>"; };
A2835CFE0E07A13300308978 /* sqHeapMap.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sqHeapMap.c; sourceTree = "<group>"; };
A2C08F420EA3E0FD0036416C /* dispdbg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dispdbg.h; sourceTree = "<group>"; };
A2C843B8108A614E00E438C0 /* sqMacAudioDeviceList.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sqMacAudioDeviceList.c; sourceTree = "<group>"; };
A2F27E671087169800F905FB /* nsPoolManagement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = nsPoolManagement.h; sourceTree = "<group>"; };
A2F27E681087169800F905FB /* nsPoolManagement.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = nsPoolManagement.m; sourceTree = "<group>"; };
A2FB6B570CCD71B000A29088 /* sqMacLocaleCarbon.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = sqMacLocaleCarbon.c; path = LocalePlugin/sqMacLocaleCarbon.c; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1289,7 +1287,6 @@
F5F8AE5D02EB4E0A0100013C /* SoundPlugin */ = {
isa = PBXGroup;
children = (
A2C843B8108A614E00E438C0 /* sqMacAudioDeviceList.c */,
94D42B2B07B2C8DC001CCA37 /* sqMacUnixInterfaceSound.h */,
94D42B2C07B2C8DC001CCA37 /* sqMacUnixInterfaceSound.c */,
94FD7EC807B8491B002F2291 /* sqUnixSoundMacOSXJMM.c */,
Expand Down Expand Up @@ -1960,7 +1957,6 @@
7351A09B100963670035A878 /* sqUnixThreads.c in Sources */,
733B2C37106AB74B004652BE /* sqExternalSemaphores.c in Sources */,
A2F27E6A1087169800F905FB /* nsPoolManagement.m in Sources */,
A2C843B9108A614E00E438C0 /* sqMacAudioDeviceList.c in Sources */,
739C6ED6112DCBB00049B7D3 /* sqTicker.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
79 changes: 28 additions & 51 deletions platforms/Cross/plugins/HostWindowPlugin/HostWindowPlugin.h
Original file line number Diff line number Diff line change
@@ -1,79 +1,56 @@
/* Host windows plugin header file
* tim@sumeru.stanford.edu
* All sizes are in pixels; convert from OS abstract units as needed
* windowHandles etc are expected to be SmallInteger valid values */
* windowHandles etc are expected to be SmallInteger valid values
* windowHandle 1 is the traditional main window */

/* closeWindow: arg is int windowIndex. Fail (return 0) if anything goes wrong
/* closeWindow: arg is sqInt windowIndex. Fail (return 0) if anything goes wrong
* - typically the windowIndex invalid or similar */
extern int closeWindow(int index);
extern sqInt closeWindow(sqInt index);

/* createWindow: takes int width, height and origin x/y plus a char* list of
* as yet undefined attributes. Returns an int window index or 0 for failure
/* createWindow: takes sqInt width, height and origin x/y plus a char* list of
* as yet undefined attributes. Returns an sqInt window index or 0 for failure
* Failure may occur because of an inability to add the window, too many
* windows already extant (platform dependant), the specified size being
* unreasonable etc. */
extern int createWindowWidthheightoriginXyattrlength(int w, int h, int x, int y,
char * list, int attributeListLength);
extern sqInt createWindowWidthheightoriginXyattrlength(sqInt w, sqInt h, sqInt x, sqInt y,
char * list, sqInt attributeListLength);

/* ioShowDisplayOnWindow: similar to ioShowDisplay but adds the int windowIndex
/* ioShowDisplayOnWindow: similar to ioShowDisplay but adds the sqInt windowIndex
* Return true if ok, false if not, but not currently checked */
extern int ioShowDisplayOnWindow( unsigned char *dispBitsIndex, int width, int
height, int depth, int affectedL, int affectedR, int affectedT, int affectedB,
int windowIndex);
extern sqInt ioShowDisplayOnWindow( unsigned char* dispBitsIndex, sqInt width, sqInt
height, sqInt depth, sqInt affectedL, sqInt affectedR, sqInt affectedT, sqInt affectedB,
sqInt windowIndex);

/* ioSizeOfWindow: arg is int windowIndex. Return the size of the specified
/* ioSizeOfWindow: arg is sqInt windowIndex. Return the size of the specified
* window in (width<<16 || height) format like ioScreenSize.
* Return -1 for failure - typically invalid windowIndex
* -1 is chosen since it would correspond to a window size of +/-32k@+/-32k
* which it is hoped is unlikely for some time to come */
extern int ioSizeOfWindow(int windowIndex);
* -1 is chosen since itwould correspond to a window size of 64k@64k which
* I hope is unlikely for some time to come */
extern sqInt ioSizeOfWindow(sqInt windowIndex);

/* ioSizeOfNativeWindow: arg is void* windowHandle, defined as unsigned long
* for convenience. Return the size of the specified native window in
* (width<<16 || height) format like ioScreenSize.
* Return -1 for failure - typically invalid windowHandle
* -1 is chosen since it would correspond to a window size of +/-32k@+/-32k
* which it is hoped is unlikely for some time to come */
extern int ioSizeOfNativeWindow(unsigned long windowHandle);

/* as per ioSizeOfNativeWindow, but answers the size of the drawing
* surface (the inside) of the window.
*/
extern int ioSizeOfNativeDisplay(unsigned long windowHandle);

/* ioSizeOfWindowSetxy: args are int windowIndex, int w & h for the
/* ioSizeOfWindowSetxy: args are sqInt windowIndex, sqInt w & h for the
* width / height to make the window. Return the actual size the OS
* produced in (width<<16 || height) format or -1 for failure as above. */
extern int ioSizeOfWindowSetxy(int windowIndex, int w, int h);
extern sqInt ioSizeOfWindowSetxy(sqInt windowIndex, sqInt w, sqInt h);

/* ioPositionOfWindow: arg is int windowIndex. Return the pos of the specified
/* ioPositionOfWindow: arg is sqInt windowIndex. Return the pos of the specified
* window in (left<<16 || top) format like ioScreenSize.
* Return -1 (as above) for failure - typically invalid windowIndex */
extern int ioPositionOfWindow(int windowIndex);

/* ioPositionOfNativeWindow: arg is void* windowHandle, defined as unsigned long
* for convenience. Return the pos of the specified native window in
* (left<<16 || top) format like ioScreenSize.
* Return -1 (as above) for failure - typically invalid windowHandle */
extern int ioPositionOfNativeWindow(unsigned long windowHandle);

/* as per ioPositionOfNativeWindow, but answers the position of the drawing
* surface (the inside) of the window.
*/
extern int ioPositionOfNativeDisplay(unsigned long windowHandle);
* Return -1 (as above) for failure - tpyically invalid windowIndex */
extern sqInt ioPositionOfWindow(sqInt windowIndex);

/* ioPositionOfWindowSetxy: args are int windowIndex, int x & y for the
/* ioPositionOfWindowSetxy: args are sqInt windowIndex, sqInt x & y for the
* origin x/y for the window. Return the actual origin the OS
* produced in (left<<16 || top) format or -1 for failure, as above */
extern int ioPositionOfWindowSetxy(int windowIndex, int x, int y);
extern sqInt ioPositionOfWindowSetxy(sqInt windowIndex, sqInt x, sqInt y);

/* ioSetTitleOfWindow: args are int windowIndex, char* newTitle and
* int size of new title. Fail with -1 if windowIndex is invalid, string is too
/* ioSetTitleOfWindow: args are sqInt windowIndex, char* newTitle and
* sqInt size of new title. Fail with -1 if windowIndex is invalid, string is too
long for platform etc. Leave previous title in place on failure */
int ioSetTitleOfWindow(int windowIndex, char * newTitle, int sizeOfTitle);
sqInt ioSetTitleOfWindow(sqInt windowIndex, char * newTitle, sqInt sizeOfTitle);

/* ioCloseAllWindows: intended for VM shutdown.
/* ioCloseAllWindows: sqIntended for VM shutdown.
* Close all the windows that appear to be open.
* No useful return value since we're getting out of Dodge anyway.
*/
extern int ioCloseAllWindows(void);
extern sqInt ioCloseAllWindows(void);
132 changes: 10 additions & 122 deletions platforms/Mac OS/plugins/HostWindowPlugin/sqMacHostWindow.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
July 15th 2005 add logic to flush QD buffers for os-x 10.4
3.8.15b3 Feb 19th, 2007 JMM add cursor set logic
4.1.0b2 set window title via cfstring
*/

#include "sqVirtualMachine.h"
Expand Down Expand Up @@ -103,7 +103,6 @@ int closeWindow(int windowIndex) {
int ioPositionOfWindow(wIndexType windowIndex)
{
Rect portRect;

if (windowHandleFromIndex(windowIndex) == nil)
return -1;

Expand All @@ -112,42 +111,6 @@ int ioPositionOfWindow(wIndexType windowIndex)
return (portRect.left << 16) | (portRect.top & 0xFFFF); /* left is high 16 bits; top is low 16 bits */
}

int ioPositionOfNativeWindow(unsigned long windowHandle)
{
Rect portRect, titleRect;
CGrafPtr windowPortPtr = GetWindowPort((WindowPtr)windowHandle);

if (!windowPortPtr)
return -1;

GetWindowBounds((WindowPtr)windowHandle,kWindowTitleBarRgn,&titleRect);
GetPortBounds(windowPortPtr,&portRect);
QDLocalToGlobalRect(windowPortPtr, &portRect);
#if 0
printf("titleRect %d@%d corner: %d@%d\n",
titleRect.left, titleRect.top,
titleRect.right, titleRect.bottom);
printf("portRect %d@%d corner: %d@%d\n",
portRect.left, portRect.top,
portRect.right, portRect.bottom);
#endif
return (portRect.left << 16) /* x is high 16 bits; y is low 16 bits */
| (portRect.top - (titleRect.bottom - titleRect.top) & 0xFFFF);
}

int ioPositionOfNativeDisplay(unsigned long windowHandle)
{
Rect portRect;
CGrafPtr windowPortPtr = GetWindowPort((WindowPtr)windowHandle);

if (!windowPortPtr)
return -1;

GetPortBounds(windowPortPtr,&portRect);
QDLocalToGlobalRect(windowPortPtr, &portRect);
return (portRect.left << 16) | (portRect.top & 0xFFFF); /* left is high 16 bits; top is low 16 bits */
}

int ioPositionOfWindowSetxy(wIndexType windowIndex, int x, int y)
{
void *giLocker;
Expand Down Expand Up @@ -181,79 +144,8 @@ int ioSizeOfWindow(wIndexType windowIndex)
if (windowHandleFromIndex(windowIndex) == nil)
return -1;

GetPortBounds(GetWindowPort(windowHandleFromIndex(windowIndex)),&portRect);
w = portRect.right - portRect.left;
h = portRect.bottom - portRect.top;
return (w << 16) | (h & 0xFFFF); /* w is high 16 bits; h is low 16 bits */
}

/** Upper-left of the sanctioned portion of the screen. **/
int ioPositionOfScreenWorkArea (wIndexType windowIndex)
{
GDHandle device=NULL;
WindowRef window;
Rect workArea;

if ( (window = windowHandleFromIndex(windowIndex)) == nil)
return -1;

GetWindowGreatestAreaDevice((WindowRef) window,kWindowContentRgn,&device,NULL);
if (! device)
return -1;
if (GetAvailableWindowPositioningBounds (device, &workArea) != 0)
return -1;

return ((workArea.left << 16) | (workArea.top & (0xFFFF)));
}

/** Extent of the sanctioned portion of the screen. **/
int ioSizeOfScreenWorkArea (wIndexType windowIndex)
{
GDHandle device=NULL;
WindowRef window;
Rect workArea;

if ( (window = windowHandleFromIndex(windowIndex)) == nil)
return -1;

GetWindowGreatestAreaDevice((WindowRef) window,kWindowContentRgn,&device,NULL);
if (! device)
return -1;
if (GetAvailableWindowPositioningBounds (device, &workArea) != 0)
return -1;

return ((workArea.right - workArea.left) << 16) | ((workArea.bottom - workArea.top) & (0xFFFF));
}


int ioSizeOfNativeWindow(unsigned long windowHandle)
{
Rect portRect, titleRect;
int w, h;
CGrafPtr windowPortPtr = GetWindowPort((WindowPtr)windowHandle);

if (!windowPortPtr)
return -1;

GetWindowBounds((WindowPtr)windowHandle,kWindowTitleBarRgn,&titleRect);
GetPortBounds(windowPortPtr,&portRect);
QDLocalToGlobalRect(windowPortPtr, &portRect);
w = portRect.right - portRect.left;
h = portRect.bottom - portRect.top + titleRect.bottom - titleRect.top;
return (w << 16) | (h & 0xFFFF); /* w is high 16 bits; h is low 16 bits */
}

int ioSizeOfNativeDisplay(unsigned long windowHandle)
{
Rect portRect;
int w, h;
CGrafPtr windowPortPtr = GetWindowPort((WindowPtr)windowHandle);

if (!windowPortPtr)
return -1;

GetPortBounds(windowPortPtr,&portRect);
QDLocalToGlobalRect(windowPortPtr, &portRect);
GetPortBounds(GetWindowPort(windowHandleFromIndex(windowIndex)),&portRect);
w = portRect.right - portRect.left;
h = portRect.bottom - portRect.top;
return (w << 16) | (h & 0xFFFF); /* w is high 16 bits; h is low 16 bits */
Expand Down Expand Up @@ -288,27 +180,23 @@ int ioSetTitleOfWindow(int windowIndex, char * newTitle, int sizeOfTitle) {
char string[256];
if (sizeOfTitle > 255)
return -1;

memcpy(string,newTitle,sizeOfTitle);
string[sizeOfTitle] = 0x00;
SetWindowTitle(windowIndex,string);
return 1;

CFStringRef windowTitleCFString = CFStringCreateWithCString (nil,string,kCFStringEncodingUTF8);

SetWindowTitleWithCFString (windowHandleFromIndex(windowIndex),windowTitleCFString);

CFRelease(windowTitleCFString);
return 1;
}

int ioCloseAllWindows(void) {
return 1;
}


sqInt ioSetCursorPositionXY(sqInt x, sqInt y)
{
CGPoint p;

p.x = x;
p.y = y;
return CGWarpMouseCursorPosition(p)
? -1
: 0;
}

/* addendum to sqPlatformSpecific.h */
/* multiple host windows stuff */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

#include <Carbon/Carbon.h>
#include <Carbon/Carbon.h>
#include "HostWindowPlugin.h"

/* window handle type */
Expand Down
Loading

0 comments on commit a4a7841

Please sign in to comment.