Monday, January 27, 2020

GWindow ported!

Surprise surprise surprise...GWindow got ported, I was able to find a way around Mac's objective-c issue. The solution for that is making the main.cpp into a mainOBJC.mm, this is because XCode needs at least 1 .mm file so that it can compile the file with objective-c and c++, mainOBJC.mm only contains 1 line:
#import main.cpp

doing this enables gateware developers to port those gateware libraries that require objective-c code to put the code in the _mac.hpp file itself. Example:
GWindow_mac.hpp:
#ifdef __OBJC__
@import Foundation;
@import Cocoa;
#endif

namespace GW
{
namespace I
{
class GWindowImplementation;
}
}

// The GWDelegate will be the delegate of the main window which will receive window events
@interface GWDelegate : NSObject <NSWindowDelegate>
{
@public GW::I::GWindowImplementation* pWindow;
    @public GW::I::GWindowInterface::EVENT_DATA eventData;
@public GW::GEvent gevent;
}
+(void)doNothing : (id)threadID;
-(NSSize)windowWillResize:(NSWindow*)sender
toSize : (NSSize)frameSize;
-(void)windowDidResize:(NSNotification*)notification;
-(void)windowDidMove:(NSNotification*)notification;
-(void)windowDidMiniaturize:(NSNotification*)notification;
-(void)windowDidDeminiaturize:(NSNotification*)notification;
-(void)windowDidEnterFullScreen:(NSNotification*)notification;
-(void)windowWillClose:(NSNotification*)notification;
@end

// The GWResponder is our interpretation of the NSResponder that will propagate window messages to other responders
@interface GWResponder : NSResponder
-(bool)acceptFirstResponder;
-(bool)acceptsFirstMouse:(NSEvent*)event;
@end

@interface GWAppDelegate : NSObject <NSApplicationDelegate>
-(void)applicationDidFinishLaunching : (NSNotification*)notification;
@end

Above code is valid syntax and is able to be compiled in XCode, XCode compiles this hpp as both c++ code and objective-c code.

Now I am working on porting GOpenGLSurface while keeping an eye on my tool making sure nothing breaks when the tool generates the single header

No comments:

Post a Comment