<commit_before>#import "GSKWindow.h"
#import "GSKTouch.h"
#import <Gosu/Gosu.hpp>
#import <map>
#import <memory>


namespace
{
    class CallbackForwardingWindow : public Gosu::Window
    {
        GSKWindow *const _window;
        std::map<void *, GSKTouch *> _touchesMap;
        NSMutableArray<GSKTouch *> *_touchesArray = [NSMutableArray new];
        
    public:
        CallbackForwardingWindow(GSKWindow *window, unsigned width, unsigned height, bool fullscreen, double updateInterval)
        : Gosu::Window(width, height, fullscreen, updateInterval), _window(window)
        {
        }
        
        void buttonDown(Gosu::Button btn) override
        {
            [_window buttonDown:btn.id()];
        }
        
        void buttonUp(Gosu::Button btn) override
        {
            [_window buttonUp:btn.id()];
        }
        
        void draw() override
        {
            [_window draw];
        }
        
        bool needsCursor() const override
        {
            return [_window needsCursor];
        }
        
        bool needsRedraw() const override
        {
            return [_window needsRedraw];
        }
        
        void update() override
        {
            [_window update];
        }
        
        void touchBegan(Gosu::Touch touch) override
        {
            GSKTouch *touchObject = [GSKTouch new];
            touchObject.x = touch.x;
            touchObject.y = touch.y;
            _touchesMap[touch.id] = touchObject;
            [_touchesArray addObject:touchObject];
            [_window touchBegan:touchObject];
        }
        
        void touchMoved(Gosu::Touch touch) override
        {
            if (GSKTouch *touchObject = _touchesMap[touch.id]) {
                touchObject.x = touch.x;
                touchObject.y = touch.y;
                [_window touchMoved:touchObject];
            }
        }
        
        void touchEnded(Gosu::Touch touch) override
        {
            if (GSKTouch *touchObject = _touchesMap[touch.id]) {
                _touchesMap.erase(touch.id);
                [_touchesArray removeObject:touchObject];
                touchObject.x = touch.x;
                touchObject.y = touch.y;
                [_window touchEnded:touchObject];
            }
        }
        
        void touchCancelled(Gosu::Touch touch) override
        {
            if (GSKTouch *touchObject = _touchesMap[touch.id]) {
                _touchesMap.erase(touch.id);
                [_touchesArray removeObject:touchObject];
                touchObject.x = touch.x;
                touchObject.y = touch.y;
                [_window touchCancelled:touchObject];
            }
        }
        
        NSArray<GSKTouch *> *touches() const
        {
            return _touchesArray;
        }
    };
}


@implementation GSKWindow
{
    std::unique_ptr<CallbackForwardingWindow> _window;
}

#pragma mark - Properties

- (NSString *)caption
{
    return [NSString stringWithUTF8String:Gosu::wstringToUTF8(_window->caption()).c_str()];
}

- (void)setCaption:(NSString *)caption
{
    _window->setCaption(Gosu::utf8ToWstring([caption UTF8String]));
}

- (BOOL)isFullscreen
{
    return _window->graphics().fullscreen();
}

- (NSInteger)height
{
    return _window->graphics().height();
}
<commit_msg>Use Gosu::Window::fullscreen from gosu/master<commit_after>#import "GSKWindow.h"
#import "GSKTouch.h"
#import <Gosu/Gosu.hpp>
#import <map>
#import <memory>


namespace
{
    class CallbackForwardingWindow : public Gosu::Window
    {
        GSKWindow *const _window;
        std::map<void *, GSKTouch *> _touchesMap;
        NSMutableArray<GSKTouch *> *_touchesArray = [NSMutableArray new];
        
    public:
        CallbackForwardingWindow(GSKWindow *window, unsigned width, unsigned height, bool fullscreen, double updateInterval)
        : Gosu::Window(width, height, fullscreen, updateInterval), _window(window)
        {
        }
        
        void buttonDown(Gosu::Button btn) override
        {
            [_window buttonDown:btn.id()];
        }
        
        void buttonUp(Gosu::Button btn) override
        {
            [_window buttonUp:btn.id()];
        }
        
        void draw() override
        {
            [_window draw];
        }
        
        bool needsCursor() const override
        {
            return [_window needsCursor];
        }
        
        bool needsRedraw() const override
        {
            return [_window needsRedraw];
        }
        
        void update() override
        {
            [_window update];
        }
        
        void touchBegan(Gosu::Touch touch) override
        {
            GSKTouch *touchObject = [GSKTouch new];
            touchObject.x = touch.x;
            touchObject.y = touch.y;
            _touchesMap[touch.id] = touchObject;
            [_touchesArray addObject:touchObject];
            [_window touchBegan:touchObject];
        }
        
        void touchMoved(Gosu::Touch touch) override
        {
            if (GSKTouch *touchObject = _touchesMap[touch.id]) {
                touchObject.x = touch.x;
                touchObject.y = touch.y;
                [_window touchMoved:touchObject];
            }
        }
        
        void touchEnded(Gosu::Touch touch) override
        {
            if (GSKTouch *touchObject = _touchesMap[touch.id]) {
                _touchesMap.erase(touch.id);
                [_touchesArray removeObject:touchObject];
                touchObject.x = touch.x;
                touchObject.y = touch.y;
                [_window touchEnded:touchObject];
            }
        }
        
        void touchCancelled(Gosu::Touch touch) override
        {
            if (GSKTouch *touchObject = _touchesMap[touch.id]) {
                _touchesMap.erase(touch.id);
                [_touchesArray removeObject:touchObject];
                touchObject.x = touch.x;
                touchObject.y = touch.y;
                [_window touchCancelled:touchObject];
            }
        }
        
        NSArray<GSKTouch *> *touches() const
        {
            return _touchesArray;
        }
    };
}


@implementation GSKWindow
{
    std::unique_ptr<CallbackForwardingWindow> _window;
}

#pragma mark - Properties

- (NSString *)caption
{
    return [NSString stringWithUTF8String:Gosu::wstringToUTF8(_window->caption()).c_str()];
}

- (void)setCaption:(NSString *)caption
{
    _window->setCaption(Gosu::utf8ToWstring([caption UTF8String]));
}

- (BOOL)isFullscreen
{
    return _window->fullscreen();
}

- (NSInteger)height
{
    return _window->graphics().height();
}

{'fraction_non_alphanumeric': 0.10316139767054909, 'fraction_numerical': 0.001210104371502042, 'mean_word_length': 1.773489932885906, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6159123', 'n_tokens_mistral': 1993, 'n_tokens_neox': 1905, 'n_words': 343}