#define APPLE_GCC
#endif
+#define __private_extern__
+#include <mach-o/dyld.h>
+
#include "POSIX.cc"
#include "OpenGL.cc"
#include <org/xwt/plat/Darwin.h>
#include <org/xwt/plat/Darwin$CarbonSurface.h>
#include <org/xwt/plat/Darwin$GLCarbonSurface.h>
-#include <org/xwt/plat/Darwin$GLCarbonDoubleBuffer.h>
+#include <org/xwt/plat/Darwin$GLCarbonPixelBuffer.h>
#include <org/xwt/plat/Darwin$CarbonMessage.h>
#include <org/xwt/plat/Darwin$CarbonOpenGL.h>
#include <org/xwt/plat/Darwin$FileDialogHelper.h>
#include <org/xwt/plat/GCJ$Retainer.h>
-#include <org/xwt/Proxy.h>
+#include <org/xwt/HTTP$Proxy.h>
#include <org/xwt/util/Semaphore.h>
-#include <Carbon/Carbon.h>
-#include <CoreFoundation/CoreFoundation.h>
-// For proxy stuff
-#include <SystemConfiguration/SystemConfiguration.h>
-// For LSOpenURLRef
-#include <ApplicationServices/ApplicationServices.h>
+#include <stdlib.h>
+#include <objc/objc.h>
-#include <AGL/agl.h>
+#include "DarwinCarbonHeaders.h"
-#include <stdlib.h>
+#define XWT_CARBON_NO_BUNDLE_HACK
+#ifdef XWT_CARBON_NO_BUNDLE_HACK
+extern "C" {
+ OSErr CPSEnableForegroundOperation(ProcessSerialNumber *psn);
+ OSErr CPSSetFrontProcess(ProcessSerialNumber *psn);
+}
+#endif
+
+#include "DarwinWeakSymbols.h"
using namespace org::xwt::plat;
using gnu::gcj::RawData;
namespace darwin { }
using namespace darwin;
-#pragma mark ------ Carbon Namespace ------
-namespace darwin {
+#pragma mark ------ Darwin Namespace ------
+
// We put everything that isn't in org.xwt.plat.Darwin in
// org.xwt.plat.darwin to prevent namespace conflicts
const static UInt32 kEventCarbonMessage = 'xwtb';
const static UInt32 kEventParamCarbonMessage = 'xwtc';
- pascal OSStatus darwin::carbonMessageEventHandler(EventHandlerCallRef handler, EventRef e, void *userData);
+ OSStatus our_carbonMessageEventHandler(EventHandlerCallRef handler, EventRef e, void *userData);
void fileDialogEventHandler(NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, void *userData);
-} // end namespace
+
jboolean Darwin::isJaguar() {
SInt32 version;
return version >= 0x1020;
}
+void Darwin::linkMe() {
+ load_weak_symbols();
+}
+
void Darwin$CarbonMessage::natInit() {
OSStatus r;
- EventHandlerUPP upp = NewEventHandlerUPP(carbonMessageEventHandler);
+ EventHandlerUPP upp = NewEventHandlerUPP(our_carbonMessageEventHandler);
EventTypeSpec eventTypes = { kEventClassCarbonMessage, kEventCarbonMessage };
r = InstallEventHandler(GetApplicationEventTarget(),upp,1,&eventTypes,NULL,NULL);
checkStatus(r,"InstallEventHandler");
}
-pascal OSStatus darwin::carbonMessageEventHandler(EventHandlerCallRef handler, EventRef e, void *userData) {
+OSStatus our_carbonMessageEventHandler(EventHandlerCallRef handler, EventRef e, void *userData) {
UInt32 eKind = GetEventKind(e);
UInt32 eClass = GetEventClass(e);
OSStatus r;
#pragma mark ------ Utility Functions ------
-void darwin::funcFailed(char *func,int r){
+void funcFailed(char *func,int r){
fprintf(stderr,"%s() failed (%d)\n",func,r);
exit(EXIT_FAILURE);
}
{ kEventClassMouse, kEventMouseWheelMoved },
};
-pascal OSStatus windowEventHandler(EventHandlerCallRef handler, EventRef e, void *userData) {
+OSStatus our_windowEventHandler(EventHandlerCallRef handler, EventRef e, void *userData) {
Darwin$CarbonSurface *surface = (Darwin$CarbonSurface*) userData;
UInt32 eKind = GetEventKind(e);
UInt32 eClass = GetEventClass(e);
rect.top = 0; rect.left = 0; rect.bottom = 10; rect.right=10;
r = CreateNewWindow(wc,attr,&rect,&window);
checkStatus(r,"CreateNewWindow");
+
+ id NSWindowClass = objc_getClass("NSWindow");
+ printf("nswindowclass is %x\n", NSWindowClass);
+ SEL selector = sel_registerName("initWithWindowRef");
+ printf("selector is %s\n", selector);
+ objc_method method = class_getClassMethod(NSWindowClass, selector);
+ printf("method is %x\n", method);
+ id windowInstance = objc_msgSend(NSWindowClass, selector, window);
+ printf("instance is %x\n", windowInstance);
GCJ$Retainer::retain(this); // Need to account for the EventHandlers pointer to us
- EventHandlerUPP upp = NewEventHandlerUPP(windowEventHandler);
+ EventHandlerUPP upp = NewEventHandlerUPP(our_windowEventHandler);
r = InstallWindowEventHandler(window,upp,sizeof(eventTypeSpecs)/sizeof(EventTypeSpec),eventTypeSpecs,this,NULL);
checkStatus(r,"InstallWindowEventHandler");
#pragma mark ------ Carbon Methods ------
-void darwin::fileDialogEventHandler(NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, void *userData) {
+void fileDialogEventHandler(NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, void *userData) {
Darwin$FileDialogHelper *helper = (Darwin$FileDialogHelper*) userData;
NavDialogRef dialog = callBackParms->context;
OSStatus r;
WindowRef window = FrontWindow();
NavDialogCreationOptions options;
- NavEventUPP handler = NewNavEventUPP(darwin::fileDialogEventHandler);
+ NavEventUPP handler = NewNavEventUPP(fileDialogEventHandler);
NavGetDefaultDialogCreationOptions(&options);
options.optionFlags =
checkStatus(r,"PutScrapFlavor");
}
-Proxy *Darwin::natDetectProxy() {
- using org::xwt::Proxy;
- Proxy *p=0;
+HTTP$Proxy *Darwin::natDetectProxy() {
+ using org::xwt::HTTP$Proxy;
+ HTTP$Proxy *p=0;
CFStringRef string;
CFNumberRef number;
SmartCFString smartString;
number = (CFNumberRef) CFDictionaryGetValue(proxyInfo, kSCPropNetProxies ## proto ## Port); \
if(number != NULL && CFGetTypeID(number) != CFNumberGetTypeID()) number = NULL; \
if(string && number && CFNumberGetValue(number,kCFNumberIntType,&i) && i) { \
- if(!p) p = new Proxy(); \
+ if(!p) p = new HTTP$Proxy(); \
p->var ## ProxyHost = cfStringToJString(string); \
p->var ## ProxyPort = i; \
} \
}
jint Darwin::cgScreenWidth() {
- return CGDisplayPixelsWide(kCGDirectMainDisplay);
+ return CGDisplayPixelsWide(((CGDirectDisplayID)0));
}
jint Darwin::cgScreenHeight() {
- return CGDisplayPixelsHigh(kCGDirectMainDisplay);
+ return CGDisplayPixelsHigh(((CGDirectDisplayID)0));
}
void Darwin::_newBrowserWindow(jstring js) {
QuitApplicationEventLoop();
}
-#define XWT_CARBON_NO_BUNDLE_HACK
-#ifdef XWT_CARBON_NO_BUNDLE_HACK
-extern "C" {
- OSErr CPSEnableForegroundOperation(ProcessSerialNumber *psn);
- OSErr CPSSetFrontProcess(ProcessSerialNumber *psn);
-}
-#endif
void Darwin::natInit() {
OSStatus r;
#ifdef XWT_CARBON_NO_BUNDLE_HACK
checkStatus(rawSharedContext,"aglCreateContext");
}
-void Darwin$GLCarbonDoubleBuffer::natInit() {
+void Darwin$GLCarbonPixelBuffer::natInit() {
WindowClass wc = kPlainWindowClass;
WindowAttributes attr = 0;
WindowRef window;
rawCTX = (RawData*) ctx;
}
-void Darwin$GLCarbonDoubleBuffer::activateContext() {
+void Darwin$GLCarbonPixelBuffer::activateContext() {
AGLContext ctx = (AGLContext) rawCTX;
aglSetCurrentContext(ctx);
}
-void Darwin$GLCarbonDoubleBuffer::natCleanup(RawData* rawWindowRef, RawData* rawCTX) {
+void Darwin$GLCarbonPixelBuffer::natCleanup(RawData* rawWindowRef, RawData* rawCTX) {
WindowRef window = (WindowRef) rawWindowRef;
AGLContext ctx = (AGLContext) rawCTX;
aglDestroyContext(ctx);
DisposeWindow(window);
}
-void Darwin$GLCarbonSurface::natBlit(Darwin$GLCarbonDoubleBuffer *db, jint sx1, jint sy1, jint dx1, jint dy1, jint dx2, jint dy2) {
+void Darwin$GLCarbonSurface::natBlit(Darwin$GLCarbonPixelBuffer *db, jint sx1, jint sy1, jint dx1, jint dy1, jint dx2, jint dy2) {
AGLContext ctx = (AGLContext) rawCTX;
int sx2 = sx1 + (dx2-dx1);
int sy2 = sy1 + (dy2-dy1);
}
} } } // end namepsace org::xwt::plat
+
+
+