Style: Apply clang-format (3.9.1) to Obj-C++ files

This commit is contained in:
Rémi Verschelde 2017-04-09 13:38:42 +02:00
parent fb4e9962ea
commit a27876d5ac
14 changed files with 638 additions and 689 deletions

View file

@ -31,7 +31,7 @@ PARSE_EXTS=true
# File types to parse. Only effective when PARSE_EXTS is true.
# FILE_EXTS=".c .h .cpp .hpp"
FILE_EXTS=".c .h .cpp .hpp .cc .hh .cxx .m"
FILE_EXTS=".c .h .cpp .hpp .cc .hh .cxx .m .mm .inc"
# Use pygmentize instead of cat to parse diff with highlighting.
# Install it with `pip install pygments` (Linux) or `easy_install Pygments` (Mac)

View file

@ -11,7 +11,7 @@ else
RANGE=HEAD
fi
FILES=$(git diff-tree --no-commit-id --name-only -r $RANGE | grep -v thirdparty/ | grep -e "\.cpp$" -e "\.h$" -e "\.inc$")
FILES=$(git diff-tree --no-commit-id --name-only -r $RANGE | grep -v thirdparty/ | grep -E "\.(c|h|cpp|hpp|cc|hh|cxx|m|mm|inc)$")
echo "Checking files:\n$FILES"
# create a random filename to store our generated patch

View file

@ -28,11 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#import "app_delegate.h"
#import "gl_view.h"
#include "os_iphone.h"
#include "core/globals.h"
#import "gl_view.h"
#include "main/main.h"
#include "os_iphone.h"
#ifdef MODULE_FACEBOOKSCORER_IOS_ENABLED
#include "modules/FacebookScorer_ios/FacebookScorer.h"
@ -45,8 +45,8 @@
#endif
#ifdef MODULE_PARSE_ENABLED
#import <Parse/Parse.h>
#import "FBSDKCoreKit/FBSDKCoreKit.h"
#import <Parse/Parse.h>
#endif
#define kFilteringFactor 0.1
@ -90,7 +90,8 @@ static ViewController* mainViewController = nil;
}
static int frame_count = 0;
- (void)drawView:(GLView*)view; {
- (void)drawView:(GLView *)view;
{
switch (frame_count) {
case 0: {
@ -399,13 +400,13 @@ static int frame_count = 0;
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
#ifdef MODULE_PARSE_ENABLED
NSLog(@"Handling application openURL");
return [[FBSDKApplicationDelegate sharedInstance] application:application
return [[FBSDKApplicationDelegate sharedInstance]
application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation];
#endif
#ifdef MODULE_FACEBOOKSCORER_IOS_ENABLED
return [[[FacebookScorer sharedInstance] facebook] handleOpenURL:url];
#else

View file

@ -28,19 +28,15 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifdef GAME_CENTER_ENABLED
#include "game_center.h"
#ifdef __IPHONE_9_0
#import <GameKit/GameKit.h>
extern "C" {
#else
extern "C" {
#import <GameKit/GameKit.h>
#endif
#import "app_delegate.h"
@ -63,7 +59,6 @@ void GameCenter::_bind_methods() {
ObjectTypeDB::bind_method(_MD("pop_pending_event"), &GameCenter::pop_pending_event);
};
Error GameCenter::connect() {
//if this class isn't available, game center isn't implemented
@ -119,7 +114,8 @@ Error GameCenter::post_score(Variant p_score) {
ERR_FAIL_COND_V([GKScore respondsToSelector:@selector(reportScores)], ERR_UNAVAILABLE);
[GKScore reportScores:@[reporter] withCompletionHandler:^(NSError* error) {
[GKScore reportScores:@[ reporter ]
withCompletionHandler:^(NSError *error) {
Dictionary ret;
ret["type"] = "post_score";
if (error == nil) {
@ -155,7 +151,8 @@ Error GameCenter::award_achievement(Variant p_params) {
achievement.showsCompletionBanner = params["show_completion_banner"] ? YES : NO;
}
[GKAchievement reportAchievements:@[achievement] withCompletionHandler:^(NSError *error) {
[GKAchievement reportAchievements:@[ achievement ]
withCompletionHandler:^(NSError *error) {
Dictionary ret;
ret["type"] = "award_achievement";
@ -228,7 +225,6 @@ void GameCenter::request_achievement_descriptions() {
}];
};
void GameCenter::request_achievements() {
[GKAchievement loadAchievementsWithCompletionHandler:^(NSArray *achievements, NSError *error) {
@ -263,8 +259,7 @@ void GameCenter::request_achievements() {
void GameCenter::reset_achievements() {
[GKAchievement resetAchievementsWithCompletionHandler:^(NSError *error)
{
[GKAchievement resetAchievementsWithCompletionHandler:^(NSError *error) {
Dictionary ret;
ret["type"] = "reset_achievements";
if (error == nil) {
@ -289,17 +284,13 @@ Error GameCenter::show_game_center(Variant p_params) {
String view_name = params["view"];
if (view_name == "default") {
view_state = GKGameCenterViewControllerStateDefault;
}
else if (view_name == "leaderboards") {
} else if (view_name == "leaderboards") {
view_state = GKGameCenterViewControllerStateLeaderboards;
}
else if (view_name == "achievements") {
} else if (view_name == "achievements") {
view_state = GKGameCenterViewControllerStateAchievements;
}
else if (view_name == "challenges") {
} else if (view_name == "challenges") {
view_state = GKGameCenterViewControllerStateChallenges;
}
else {
} else {
return ERR_INVALID_PARAMETER;
}
}
@ -358,7 +349,6 @@ GameCenter::GameCenter() {
connected = false;
};
GameCenter::~GameCenter(){
};

38
platform/iphone/gl_view.mm Executable file → Normal file
View file

@ -27,15 +27,15 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#import "gl_view.h"
#import <QuartzCore/QuartzCore.h>
#import <OpenGLES/EAGLDrawable.h>
#include "os_iphone.h"
#include "core/os/keyboard.h"
#include "core/globals.h"
#include "core/os/keyboard.h"
#include "os_iphone.h"
#include "servers/audio_server.h"
#import "gl_view.h"
#import <OpenGLES/EAGLDrawable.h>
#import <QuartzCore/QuartzCore.h>
/*
@interface GLView (private)
@ -90,7 +90,8 @@ bool _play_video(String p_path, float p_volume, String p_audio_track, String p_s
_instance.avPlayerLayer = [AVPlayerLayer playerLayerWithPlayer:_instance.avPlayer];
[_instance.avPlayer addObserver:_instance forKeyPath:@"status" options:0 context:nil];
[[NSNotificationCenter defaultCenter] addObserver:_instance
[[NSNotificationCenter defaultCenter]
addObserver:_instance
selector:@selector(playerItemDidReachEnd:)
name:AVPlayerItemDidPlayToEndTimeNotification
object:[_instance.avPlayer currentItem]];
@ -261,9 +262,11 @@ static void clear_touches() {
// Configure it so that it is opaque, does not retain the contents of the backbuffer when displayed, and uses RGBA8888 color.
eaglLayer.opaque = YES;
eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking,
kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat,
eaglLayer.drawableProperties = [NSDictionary
dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:FALSE],
kEAGLDrawablePropertyRetainedBacking,
kEAGLColorFormatRGBA8,
kEAGLDrawablePropertyColorFormat,
nil];
// Create our EAGLContext, and if successful make it current and create our framebuffer.
@ -302,7 +305,6 @@ static void clear_touches() {
[self createFramebuffer];
[self drawView];
[self drawView];
}
- (BOOL)createFramebuffer {
@ -427,7 +429,8 @@ static void clear_touches() {
[displayLink setPaused:YES];
// Process all input events
while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, TRUE) == kCFRunLoopRunHandledSource);
while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, TRUE) == kCFRunLoopRunHandledSource) {
}
// We are good to go, resume the CADisplayLink
[displayLink setPaused:NO];
@ -497,7 +500,6 @@ static void clear_touches() {
OSIPhone::get_singleton()->mouse_move(tid, prev_point.x * self.contentScaleFactor, prev_point.y * self.contentScaleFactor, touchPoint.x * self.contentScaleFactor, touchPoint.y * self.contentScaleFactor, first == tid);
};
};
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
@ -529,7 +531,6 @@ static void clear_touches() {
return YES;
};
- (void)open_keyboard {
//keyboard_text = p_existing;
[self becomeFirstResponder];
@ -559,8 +560,7 @@ static void clear_touches() {
printf("inserting text with character %i\n", character[0]);
};
- (void)audioRouteChangeListenerCallback:(NSNotification*)notification
{
- (void)audioRouteChangeListenerCallback:(NSNotification *)notification {
printf("*********** route changed!\n");
NSDictionary *interuptionDict = notification.userInfo;
@ -592,7 +592,6 @@ static void clear_touches() {
}
}
// When created via code however, we get initWithFrame
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
@ -606,7 +605,9 @@ static void clear_touches() {
self.multipleTouchEnabled = YES;
printf("******** adding observer for sound routing changes\n");
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(audioRouteChangeListenerCallback:)
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(audioRouteChangeListenerCallback:)
name:AVAudioSessionRouteChangeNotification
object:nil];
@ -639,7 +640,8 @@ static void clear_touches() {
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
change:(NSDictionary *)change context:(void *)context {
change:(NSDictionary *)change
context:(void *)context {
if (object == _instance.avPlayerItem && [keyPath isEqualToString:@"status"]) {
if (_instance.avPlayerItem.status == AVPlayerStatusFailed || _instance.avPlayer.status == AVPlayerStatusFailed) {

View file

@ -28,16 +28,16 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifdef ICLOUD_ENABLED
#include "icloud.h"
#ifndef __IPHONE_9_0
extern "C" {
#endif
#import <Foundation/Foundation.h>
#import "app_delegate.h"
#import <Foundation/Foundation.h>
#ifndef __IPHONE_9_0
};
#endif
@ -100,7 +100,6 @@ Variant nsobject_to_variant(NSObject* object) {
Dictionary result;
NSDictionary *dic = (NSDictionary *)object;
NSArray *keys = [dic allKeys];
int count = [keys count];
for (int i = 0; i < count; ++i) {
@ -191,7 +190,6 @@ NSObject* variant_to_nsobject(Variant v) {
return NULL;
}
Error ICloud::remove_key(Variant p_param) {
String param = p_param;
NSString *key = [[[NSString alloc] initWithUTF8String:param.utf8().get_data()] autorelease];
@ -304,7 +302,8 @@ ICloud::ICloud() {
[
//[NSNotificationCenter defaultCenter] addObserverForName: @"notify"
[NSNotificationCenter defaultCenter] addObserverForName: NSUbiquitousKeyValueStoreDidChangeExternallyNotification
[NSNotificationCenter defaultCenter]
addObserverForName:NSUbiquitousKeyValueStoreDidChangeExternallyNotification
object:[NSUbiquitousKeyValueStore defaultStore]
queue:nil
usingBlock:^(NSNotification *notification) {
@ -331,7 +330,6 @@ ICloud::ICloud() {
ret["reason"] = reason;
NSUbiquitousKeyValueStore *store = [NSUbiquitousKeyValueStore defaultStore];
NSArray *keys = [userInfo objectForKey:NSUbiquitousKeyValueStoreChangedKeysKey];
@ -351,13 +349,9 @@ ICloud::ICloud() {
ret["changed_values"] = keyValues;
pending_events.push_back(ret);
}
];
}];
}
ICloud::~ICloud() {
};
ICloud::~ICloud(){};
#endif

View file

@ -28,16 +28,15 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifdef STOREKIT_ENABLED
#include "in_app_store.h"
#ifdef MODULE_FUSEBOXX_ENABLED
#import "modules/fuseboxx/ios/FuseSDK.h"
#endif
#include "in_app_store.h"
extern "C" {
#import <StoreKit/StoreKit.h>
#import <Foundation/Foundation.h>
#import <StoreKit/StoreKit.h>
};
bool auto_finish_transactions = true;
@ -62,7 +61,6 @@ NSMutableDictionary* pending_transactions = [NSMutableDictionary dictionary];
}
@end
InAppStore *InAppStore::instance = NULL;
void InAppStore::_bind_methods() {
@ -76,7 +74,6 @@ void InAppStore::_bind_methods() {
};
@interface ProductsDelegate : NSObject <SKProductsRequestDelegate> {
};
@end
@ -156,7 +153,6 @@ Error InAppStore::request_product_info(Variant p_params) {
};
@interface TransObserver : NSObject <SKPaymentTransactionObserver> {
};
@end
@ -255,7 +251,6 @@ Error InAppStore::request_product_info(Variant p_params) {
@end
Error InAppStore::purchase(Variant p_params) {
ERR_FAIL_COND_V(![SKPaymentQueue canMakePayments], ERR_UNAVAILABLE);
@ -275,7 +270,6 @@ Error InAppStore::purchase(Variant p_params) {
return OK;
};
int InAppStore::get_pending_event_count() {
return pending_events.size();
};
@ -333,5 +327,4 @@ InAppStore::~InAppStore() {
};
#endif

View file

@ -27,8 +27,8 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#import <UIKit/UIKit.h>
#import "app_delegate.h"
#import <UIKit/UIKit.h>
#include <stdio.h>
int gargc;
@ -47,4 +47,3 @@ int main(int argc, char *argv[]) {
[pool release];
return 0;
}

View file

@ -69,8 +69,7 @@ extern "C" {
return p_argc;
};
};
}; // extern "C"
@interface ViewController ()

View file

@ -35,7 +35,6 @@
#include <Foundation/NSString.h>
String DirAccessOSX::fix_unicode_name(const char *p_name) const {
String fname;
@ -46,6 +45,4 @@ String DirAccessOSX::fix_unicode_name(const char* p_name) const {
return fname;
}
#endif //posix_enabled

View file

@ -27,14 +27,13 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "os_osx.h"
#include "main/main.h"
#include "os_osx.h"
#include <string.h>
#include <unistd.h>
//#define main godot_main
int main(int argc, char **argv) {
int first_arg = 1;
@ -46,7 +45,6 @@ int main(int argc, char** argv) {
printf("%i: %s\n", i, argv[i]);
};
if (argc >= 1 && argv[0][0] == '/') {
//potentially launched from finder
int len = strlen(argv[0]);
@ -69,7 +67,6 @@ int main(int argc, char** argv) {
fclose(f);
chdir(path);
chdir("../Resources"); //data.pck, or just the files are here
}
free(path);
@ -79,7 +76,6 @@ int main(int argc, char** argv) {
OS_OSX os;
Error err = Main::setup(argv[0], argc - first_arg, &argv[first_arg]);
if (err != OK)
return 255;

View file

@ -27,9 +27,10 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "godot_osx.h"
#include <sys/param.h> /* for MAXPATHLEN */
#include <unistd.h>
#include "godot_osx.h"
/* For some reaon, Apple removed setAppleMenu from the headers in 10.4,
but the method still is there and works. To avoid warnings, we declare
@ -42,8 +43,7 @@ static int global_argc;
static char **global_argv;
static BOOL gCalledAppMainline = FALSE;
static NSString *getApplicationName(void)
{
static NSString *getApplicationName(void) {
const NSDictionary *dict;
NSString *appName = 0;
@ -61,8 +61,7 @@ static NSString *getApplicationName(void)
/* The main class of the application, the application's delegate */
@implementation GodotMain
static void setApplicationMenu(void)
{
static void setApplicationMenu(void) {
/* warning: this code is very odd */
NSMenu *appleMenu;
NSMenuItem *menuItem;
@ -91,7 +90,6 @@ static void setApplicationMenu(void)
title = [@"Quit " stringByAppendingString:appName];
[appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
/* Put menu into the menubar */
menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
[menuItem setSubmenu:appleMenu];
@ -106,8 +104,7 @@ static void setApplicationMenu(void)
}
/* Create a window menu */
static void setupWindowMenu(void)
{
static void setupWindowMenu(void) {
NSMenu *windowMenu;
NSMenuItem *windowMenuItem;
NSMenuItem *menuItem;
@ -133,8 +130,7 @@ static void setupWindowMenu(void)
}
/* Replacement for NSApplicationMain */
static void CustomApplicationMain (int argc, char **argv)
{
static void CustomApplicationMain(int argc, char **argv) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
GodotMain *main;
@ -159,8 +155,7 @@ static void CustomApplicationMain (int argc, char **argv)
extern int godot_main(int argc, char **argv);
/* Called when the internal event loop has just started running */
- (void) applicationDidFinishLaunching: (NSNotification *) note
{
- (void)applicationDidFinishLaunching:(NSNotification *)note {
int status;
/* Hand off to main application code */
@ -176,8 +171,7 @@ extern int godot_main(int argc, char** argv);
#undef main
#endif
int main (int argc, char **argv)
{
int main(int argc, char **argv) {
/* Copy the arguments into a global variable */
/* This is passed if we are launched by double-clicking */
if (argc >= 2 && strncmp(argv[1], "-psn", 4) == 0) {
@ -212,4 +206,3 @@ int main (int argc, char **argv)
CustomApplicationMain(argc, argv);
return 0;
}

View file

@ -27,34 +27,33 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#import <Cocoa/Cocoa.h>
#include <Carbon/Carbon.h>
#include <IOKit/IOKitLib.h>
#include <IOKit/IOCFPlugIn.h>
#include <IOKit/hid/IOHIDLib.h>
#include <IOKit/hid/IOHIDKeys.h>
#include "sem_osx.h"
#include "servers/visual/visual_server_raster.h"
//#include "drivers/opengl/rasterizer_gl.h"
//#include "drivers/gles2/rasterizer_gles2.h"
#include "os_osx.h"
#include <stdio.h>
#include <stdlib.h>
#include "print_string.h"
#include "servers/physics/physics_server_sw.h"
#include "dir_access_osx.h"
#include "drivers/gles2/rasterizer_instance_gles2.h"
#include "servers/visual/visual_server_wrap_mt.h"
#include "main/main.h"
#include "os/keyboard.h"
#include "dir_access_osx.h"
#include "print_string.h"
#include "sem_osx.h"
#include "servers/physics/physics_server_sw.h"
#include "servers/visual/visual_server_raster.h"
#include "servers/visual/visual_server_wrap_mt.h"
#include <Carbon/Carbon.h>
#import <Cocoa/Cocoa.h>
#include <IOKit/IOCFPlugIn.h>
#include <IOKit/IOKitLib.h>
#include <IOKit/hid/IOHIDKeys.h>
#include <IOKit/hid/IOHIDLib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <libproc.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
//uses portions of glfw
//========================================================================
@ -92,7 +91,6 @@ static NSRect convertRectToBacking(NSRect contentRect) {
else
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
return contentRect;
}
static InputModifierState translateFlags(NSUInteger flags) {
@ -112,7 +110,6 @@ static int prev_mouse_x = 0;
static int prev_mouse_y = 0;
static int button_mask = 0;
@interface GodotApplication : NSApplication
@end
@ -303,7 +300,6 @@ static int button_mask = 0;
return NO;
}
- (BOOL)isOpaque {
return YES;
}
@ -533,7 +529,6 @@ static int button_mask = 0;
if (OS_OSX::singleton->input)
OS_OSX::singleton->input->set_mouse_in_window(true);
}
- (void)viewDidChangeBackingProperties {
@ -551,12 +546,14 @@ static int button_mask = 0;
[trackingArea release];
}
NSTrackingAreaOptions options = NSTrackingMouseEnteredAndExited |
NSTrackingAreaOptions options =
NSTrackingMouseEnteredAndExited |
NSTrackingActiveInKeyWindow |
NSTrackingCursorUpdate |
NSTrackingInVisibleRect;
trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds]
trackingArea = [[NSTrackingArea alloc]
initWithRect:[self bounds]
options:options
owner:self
userInfo:nil];
@ -845,7 +842,8 @@ static int translateKey(unsigned int key) {
@end
@interface GodotWindow : NSWindow {}
@interface GodotWindow : NSWindow {
}
@end
@implementation GodotWindow
@ -857,7 +855,6 @@ static int translateKey(unsigned int key) {
@end
int OS_OSX::get_video_driver_count() const {
return 1;
}
@ -885,7 +882,6 @@ void OS_OSX::initialize_core() {
DirAccess::make_default<DirAccessOSX>(DirAccess::ACCESS_FILESYSTEM);
SemaphoreOSX::make_default();
}
static bool keyboard_layout_dirty = true;
@ -961,8 +957,13 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
int colorBits = 32;
// Fail if a robustness strategy was requested
#define ADD_ATTR(x) { attributes[attributeCount++] = x; }
#define ADD_ATTR2(x, y) { ADD_ATTR(x); ADD_ATTR(y); }
#define ADD_ATTR(x) \
{ attributes[attributeCount++] = x; }
#define ADD_ATTR2(x, y) \
{ \
ADD_ATTR(x); \
ADD_ATTR(y); \
}
// Arbitrary array size here
NSOpenGLPixelFormatAttribute attributes[40];
@ -1098,7 +1099,6 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
int dpi = (displayPixelSize.width * 25.4f / displayPhysicalSize.width) * displayScale;
screen_dpi.push_back(dpi);
};
restore_rect = Rect2(get_window_position(), get_window_size());
}
@ -1138,7 +1138,6 @@ void OS_OSX::set_main_loop( MainLoop * p_main_loop ) {
main_loop = p_main_loop;
input->set_main_loop(p_main_loop);
}
void OS_OSX::delete_main_loop() {
@ -1150,7 +1149,6 @@ void OS_OSX::delete_main_loop() {
main_loop = NULL;
}
String OS_OSX::get_name() {
return "OSX";
@ -1202,11 +1200,9 @@ void OS_OSX::set_cursor_shape(CursorShape p_shape) {
}
void OS_OSX::set_mouse_show(bool p_show) {
}
void OS_OSX::set_mouse_grab(bool p_grab) {
}
bool OS_OSX::is_mouse_grab_enabled() const {
@ -1257,14 +1253,14 @@ int OS_OSX::get_mouse_button_state() const {
void OS_OSX::set_window_title(const String &p_title) {
[window_object setTitle:[NSString stringWithUTF8String:p_title.utf8().get_data()]];
}
void OS_OSX::set_icon(const Image &p_icon) {
Image img = p_icon;
img.convert(Image::FORMAT_RGBA);
NSBitmapImageRep *imgrep= [[[NSBitmapImageRep alloc] initWithBitmapDataPlanes: NULL
NSBitmapImageRep *imgrep = [[[NSBitmapImageRep alloc]
initWithBitmapDataPlanes:NULL
pixelsWide:p_icon.get_width()
pixelsHigh:p_icon.get_height()
bitsPerSample:8
@ -1288,7 +1284,6 @@ void OS_OSX::set_icon(const Image& p_icon) {
pixels[i * 4 + 1] = (uint8_t)(((uint16_t)r[i * 4 + 1] * alpha) / 255);
pixels[i * 4 + 2] = (uint8_t)(((uint16_t)r[i * 4 + 2] * alpha) / 255);
pixels[i * 4 + 3] = alpha;
}
NSImage *nsimg = [[[NSImage alloc] initWithSize:NSMakeSize(img.get_width(), img.get_height())] autorelease];
@ -1296,7 +1291,6 @@ void OS_OSX::set_icon(const Image& p_icon) {
[nsimg addRepresentation:imgrep];
[NSApp setApplicationIconImage:nsimg];
}
MainLoop *OS_OSX::get_main_loop() const {
@ -1343,13 +1337,11 @@ String OS_OSX::get_clipboard() const {
void OS_OSX::release_rendering_thread() {
[NSOpenGLContext clearCurrentContext];
}
void OS_OSX::make_rendering_thread() {
[context makeCurrentContext];
}
Error OS_OSX::shell_open(String p_uri) {
@ -1366,7 +1358,6 @@ String OS_OSX::get_locale() const {
void OS_OSX::swap_buffers() {
[context flushBuffer];
}
void OS_OSX::wm_minimized(bool p_minimized) {
@ -1375,7 +1366,6 @@ void OS_OSX::wm_minimized(bool p_minimized) {
};
void OS_OSX::set_video_mode(const VideoMode &p_video_mode, int p_screen) {
}
OS::VideoMode OS_OSX::get_video_mode(int p_screen) const {
@ -1388,7 +1378,6 @@ OS::VideoMode OS_OSX::get_video_mode(int p_screen) const {
}
void OS_OSX::get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen) const {
}
int OS_OSX::get_screen_count() const {
@ -1431,7 +1420,6 @@ Point2 OS_OSX::get_window_position() const {
return wp;
};
void OS_OSX::set_window_position(const Point2 &p_position) {
Point2 size = p_position;
@ -1442,7 +1430,6 @@ void OS_OSX::set_window_position(const Point2& p_position) {
Size2 OS_OSX::get_window_size() const {
return window_size;
};
void OS_OSX::set_window_size(const Size2 p_size) {
@ -1514,7 +1501,6 @@ bool OS_OSX::is_window_minimized() const {
return minimized;
};
void OS_OSX::set_window_maximized(bool p_enabled) {
if (p_enabled) {
@ -1533,7 +1519,6 @@ bool OS_OSX::is_window_maximized() const {
return maximized;
};
void OS_OSX::move_window_to_foreground() {
[window_object orderFrontRegardless];
@ -1560,7 +1545,6 @@ String OS_OSX::get_executable_path() const {
return path;
}
}
// Returns string representation of keys, if they are printable.
@ -1645,7 +1629,8 @@ OS::LatinKeyboardVariant OS_OSX::get_latin_keyboard_variant() const {
void OS_OSX::process_events() {
while (true) {
NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask
NSEvent *event = [NSApp
nextEventMatchingMask:NSAnyEventMask
untilDate:[NSDate distantPast]
inMode:NSDefaultRunLoopMode
dequeue:YES];