From f98d6e718ba1da5d961ce9d77153f1dfd2991d9f Mon Sep 17 00:00:00 2001 From: Kees Bakker Date: Tue, 27 Sep 2011 22:51:26 +0200 Subject: [PATCH] Use a consistent source code format in src/video/uikit For example: * Opening bracket of a method/function on a new line at column 0 * space after "if", "while", etc --- src/video/uikit/SDL_uikitappdelegate.h | 6 +- src/video/uikit/SDL_uikitappdelegate.m | 32 +++-- src/video/uikit/SDL_uikitevents.m | 2 +- src/video/uikit/SDL_uikitopengles.m | 19 ++- src/video/uikit/SDL_uikitopenglview.h | 12 +- src/video/uikit/SDL_uikitopenglview.m | 41 +++--- src/video/uikit/SDL_uikitvideo.m | 2 +- src/video/uikit/SDL_uikitview.m | 163 +++++++++++----------- src/video/uikit/SDL_uikitviewcontroller.m | 12 +- src/video/uikit/SDL_uikitwindow.m | 3 +- 10 files changed, 157 insertions(+), 135 deletions(-) diff --git a/src/video/uikit/SDL_uikitappdelegate.h b/src/video/uikit/SDL_uikitappdelegate.h index 63cc98114..5632794e7 100644 --- a/src/video/uikit/SDL_uikitappdelegate.h +++ b/src/video/uikit/SDL_uikitappdelegate.h @@ -22,11 +22,11 @@ #import #import "SDL_uikitopenglview.h" -@interface SDLUIKitDelegate:NSObject { +@interface SDLUIKitDelegate : NSObject { } -+(SDLUIKitDelegate *)sharedAppDelegate; -+(NSString *)getAppDelegateClassName; ++ (SDLUIKitDelegate *)sharedAppDelegate; ++ (NSString *)getAppDelegateClassName; @end diff --git a/src/video/uikit/SDL_uikitappdelegate.m b/src/video/uikit/SDL_uikitappdelegate.m index 4f1af3995..4042d7901 100644 --- a/src/video/uikit/SDL_uikitappdelegate.m +++ b/src/video/uikit/SDL_uikitappdelegate.m @@ -37,15 +37,15 @@ static int forward_argc; static char **forward_argv; -int main(int argc, char **argv) { - +int main(int argc, char **argv) +{ int i; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; /* store arguments */ forward_argc = argc; forward_argv = (char **)malloc((argc+1) * sizeof(char *)); - for (i=0; idriverdata; [data->view setCurrentContext]; @@ -78,10 +77,10 @@ int UIKit_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) void UIKit_GL_SwapWindow(_THIS, SDL_Window * window) { - #ifdef SDL_POWER_UIKIT +#ifdef SDL_POWER_UIKIT // Check once a frame to see if we should turn off the battery monitor. SDL_UIKit_UpdateBatteryMonitoring(); - #endif +#endif SDL_WindowData *data = (SDL_WindowData *)window->driverdata; @@ -106,13 +105,13 @@ SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window) UIWindow *uiwindow = data->uiwindow; /* construct our view, passing in SDL's OpenGL configuration data */ - view = [[SDL_uikitopenglview alloc] initWithFrame: [uiwindow bounds] \ - retainBacking: _this->gl_config.retained_backing \ - rBits: _this->gl_config.red_size \ - gBits: _this->gl_config.green_size \ - bBits: _this->gl_config.blue_size \ - aBits: _this->gl_config.alpha_size \ - depthBits: _this->gl_config.depth_size \ + view = [[SDL_uikitopenglview alloc] initWithFrame: [uiwindow bounds] + retainBacking: _this->gl_config.retained_backing + rBits: _this->gl_config.red_size + gBits: _this->gl_config.green_size + bBits: _this->gl_config.blue_size + aBits: _this->gl_config.alpha_size + depthBits: _this->gl_config.depth_size majorVersion: _this->gl_config.major_version]; data->view = view; diff --git a/src/video/uikit/SDL_uikitopenglview.h b/src/video/uikit/SDL_uikitopenglview.h index ed288be89..eb04c1e4d 100644 --- a/src/video/uikit/SDL_uikitopenglview.h +++ b/src/video/uikit/SDL_uikitopenglview.h @@ -54,12 +54,12 @@ - (void)setCurrentContext; - (id)initWithFrame:(CGRect)frame - retainBacking:(BOOL)retained \ - rBits:(int)rBits \ - gBits:(int)gBits \ - bBits:(int)bBits \ - aBits:(int)aBits \ - depthBits:(int)depthBits \ + retainBacking:(BOOL)retained + rBits:(int)rBits + gBits:(int)gBits + bBits:(int)bBits + aBits:(int)aBits + depthBits:(int)depthBits majorVersion:(int)majorVersion; - (void)updateFrame; diff --git a/src/video/uikit/SDL_uikitopenglview.m b/src/video/uikit/SDL_uikitopenglview.m index 75b54c1a8..fb5a47274 100644 --- a/src/video/uikit/SDL_uikitopenglview.m +++ b/src/video/uikit/SDL_uikitopenglview.m @@ -35,20 +35,21 @@ @implementation SDL_uikitopenglview @synthesize context; -+ (Class)layerClass { ++ (Class)layerClass +{ return [CAEAGLLayer class]; } -- (id)initWithFrame:(CGRect)frame \ - retainBacking:(BOOL)retained \ - rBits:(int)rBits \ - gBits:(int)gBits \ - bBits:(int)bBits \ - aBits:(int)aBits \ - depthBits:(int)depthBits \ - majorVersion:(int)majorVersion \ +- (id)initWithFrame:(CGRect)frame + retainBacking:(BOOL)retained + rBits:(int)rBits + gBits:(int)gBits + bBits:(int)bBits + aBits:(int)aBits + depthBits:(int)depthBits + majorVersion:(int)majorVersion { - NSString *colorFormat=nil; + NSString *colorFormat = nil; BOOL useDepthBuffer; if (rBits == 8 && gBits == 8 && bBits == 8) { @@ -116,7 +117,7 @@ - (id)initWithFrame:(CGRect)frame \ glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer); } - if(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) { + if (glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) { return NO; } /* end create buffers */ @@ -131,7 +132,8 @@ - (id)initWithFrame:(CGRect)frame \ return self; } -- (void)updateFrame { +- (void)updateFrame +{ glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer); glBindRenderbufferOES(GL_RENDERBUFFER_OES, 0); glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, 0); @@ -156,22 +158,26 @@ - (void)updateFrame { self.contentScaleFactor = [UIScreen mainScreen].scale; } -- (void)setCurrentContext { +- (void)setCurrentContext +{ [EAGLContext setCurrentContext:context]; } -- (void)swapBuffers { +- (void)swapBuffers +{ glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); [context presentRenderbuffer:GL_RENDERBUFFER_OES]; } -- (void)layoutSubviews { +- (void)layoutSubviews +{ [EAGLContext setCurrentContext:context]; } -- (void)destroyFramebuffer { +- (void)destroyFramebuffer +{ glDeleteFramebuffersOES(1, &viewFramebuffer); viewFramebuffer = 0; glDeleteRenderbuffersOES(1, &viewRenderbuffer); @@ -184,7 +190,8 @@ - (void)destroyFramebuffer { } -- (void)dealloc { +- (void)dealloc +{ [self destroyFramebuffer]; if ([EAGLContext currentContext] == context) { [EAGLContext setCurrentContext:nil]; diff --git a/src/video/uikit/SDL_uikitvideo.m b/src/video/uikit/SDL_uikitvideo.m index 634aa47d5..2862b2347 100644 --- a/src/video/uikit/SDL_uikitvideo.m +++ b/src/video/uikit/SDL_uikitvideo.m @@ -52,7 +52,7 @@ static int UIKit_SetDisplayMode(_THIS, SDL_VideoDisplay * display, static int UIKit_Available(void) { - return (1); + return 1; } static void UIKit_DeleteDevice(SDL_VideoDevice * device) diff --git a/src/video/uikit/SDL_uikitview.m b/src/video/uikit/SDL_uikitview.m index 8b427b2ae..58888afb1 100644 --- a/src/video/uikit/SDL_uikitview.m +++ b/src/video/uikit/SDL_uikitview.m @@ -33,12 +33,13 @@ @implementation SDL_uikitview -- (void)dealloc { +- (void)dealloc +{ [super dealloc]; } -- (id)initWithFrame:(CGRect)frame { - +- (id)initWithFrame:(CGRect)frame +{ self = [super initWithFrame: frame]; #if SDL_IPHONE_KEYBOARD @@ -72,8 +73,8 @@ - (id)initWithFrame:(CGRect)frame { } -- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { - +- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event +{ NSEnumerator *enumerator = [touches objectEnumerator]; UITouch *touch = (UITouch*)[enumerator nextObject]; @@ -89,36 +90,35 @@ - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { #ifdef FIXED_MULTITOUCH while(touch) { - CGPoint locationInView = [touch locationInView: self]; - + CGPoint locationInView = [touch locationInView: self]; #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS - //FIXME: TODO: Using touch as the fingerId is potentially dangerous - //It is also much more efficient than storing the UITouch pointer - //and comparing it to the incoming event. - SDL_SendFingerDown(touchId,(long)touch, - SDL_TRUE,locationInView.x,locationInView.y, - 1); + //FIXME: TODO: Using touch as the fingerId is potentially dangerous + //It is also much more efficient than storing the UITouch pointer + //and comparing it to the incoming event. + SDL_SendFingerDown(touchId, (long)touch, + SDL_TRUE, locationInView.x, locationInView.y, + 1); #else - int i; - for(i = 0;i < MAX_SIMULTANEOUS_TOUCHES;i++) { - if(finger[i] == NULL) { - finger[i] = touch; - SDL_SendFingerDown(touchId,i, - SDL_TRUE,locationInView.x,locationInView.y, - 1); - break; + int i; + for(i = 0; i < MAX_SIMULTANEOUS_TOUCHES; i++) { + if (finger[i] == NULL) { + finger[i] = touch; + SDL_SendFingerDown(touchId, i, + SDL_TRUE, locationInView.x, locationInView.y, + 1); + break; + } } - } #endif - touch = (UITouch*)[enumerator nextObject]; + touch = (UITouch*)[enumerator nextObject]; } #endif } -- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { - +- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event +{ NSEnumerator *enumerator = [touches objectEnumerator]; UITouch *touch = (UITouch*)[enumerator nextObject]; @@ -129,32 +129,32 @@ - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { #ifdef FIXED_MULTITOUCH while(touch) { - CGPoint locationInView = [touch locationInView: self]; - + CGPoint locationInView = [touch locationInView: self]; #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS - SDL_SendFingerDown(touchId,(long)touch, - SDL_FALSE,locationInView.x,locationInView.y, - 1); + SDL_SendFingerDown(touchId, (long)touch, + SDL_FALSE, locationInView.x, locationInView.y, + 1); #else - int i; - for(i = 0;i < MAX_SIMULTANEOUS_TOUCHES;i++) { - if(finger[i] == touch) { - SDL_SendFingerDown(touchId,i, - SDL_FALSE,locationInView.x,locationInView.y, - 1); - finger[i] = NULL; - break; + int i; + for (i = 0; i < MAX_SIMULTANEOUS_TOUCHES; i++) { + if (finger[i] == touch) { + SDL_SendFingerDown(touchId, i, + SDL_FALSE, locationInView.x, locationInView.y, + 1); + finger[i] = NULL; + break; + } } - } #endif - touch = (UITouch*)[enumerator nextObject]; + touch = (UITouch*)[enumerator nextObject]; } #endif } -- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { +- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event +{ /* this can happen if the user puts more than 5 touches on the screen at once, or perhaps in other circumstances. Usually (it seems) @@ -163,8 +163,8 @@ - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { [self touchesEnded: touches withEvent: event]; } -- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { - +- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event +{ NSEnumerator *enumerator = [touches objectEnumerator]; UITouch *touch = (UITouch*)[enumerator nextObject]; @@ -177,26 +177,25 @@ - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { #ifdef FIXED_MULTITOUCH while(touch) { - CGPoint locationInView = [touch locationInView: self]; - + CGPoint locationInView = [touch locationInView: self]; #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS - SDL_SendTouchMotion(touchId,(long)touch, - SDL_FALSE,locationInView.x,locationInView.y, - 1); + SDL_SendTouchMotion(touchId, (long)touch, + SDL_FALSE, locationInView.x, locationInView.y, + 1); #else - int i; - for(i = 0;i < MAX_SIMULTANEOUS_TOUCHES;i++) { - if(finger[i] == touch) { - SDL_SendTouchMotion(touchId,i, - SDL_FALSE,locationInView.x,locationInView.y, - 1); - break; + int i; + for (i = 0; i < MAX_SIMULTANEOUS_TOUCHES; i++) { + if (finger[i] == touch) { + SDL_SendTouchMotion(touchId, i, + SDL_FALSE, locationInView.x, locationInView.y, + 1); + break; + } } - } #endif - touch = (UITouch*)[enumerator nextObject]; + touch = (UITouch*)[enumerator nextObject]; } #endif } @@ -207,13 +206,14 @@ - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { #if SDL_IPHONE_KEYBOARD /* Is the iPhone virtual keyboard visible onscreen? */ -- (BOOL)keyboardVisible { +- (BOOL)keyboardVisible +{ return keyboardVisible; } /* Set ourselves up as a UITextFieldDelegate */ -- (void)initializeKeyboard { - +- (void)initializeKeyboard +{ textField = [[UITextField alloc] initWithFrame: CGRectZero]; textField.delegate = self; /* placeholder so there is something to delete! */ @@ -236,20 +236,22 @@ - (void)initializeKeyboard { } /* reveal onscreen virtual keyboard */ -- (void)showKeyboard { +- (void)showKeyboard +{ keyboardVisible = YES; [textField becomeFirstResponder]; } /* hide onscreen virtual keyboard */ -- (void)hideKeyboard { +- (void)hideKeyboard +{ keyboardVisible = NO; [textField resignFirstResponder]; } /* UITextFieldDelegate method. Invoked when user types something. */ -- (BOOL)textField:(UITextField *)_textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { - +- (BOOL)textField:(UITextField *)_textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string +{ if ([string length] == 0) { /* it wants to replace text with nothing, ie a delete */ SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_DELETE); @@ -259,7 +261,7 @@ - (BOOL)textField:(UITextField *)_textField shouldChangeCharactersInRange:(NSRan /* go through all the characters in the string we've been sent and convert them to key presses */ int i; - for (i=0; i<[string length]; i++) { + for (i = 0; i < [string length]; i++) { unichar c = [string characterAtIndex: i]; @@ -295,7 +297,8 @@ - (BOOL)textField:(UITextField *)_textField shouldChangeCharactersInRange:(NSRan } /* Terminates the editing session */ -- (BOOL)textFieldShouldReturn:(UITextField*)_textField { +- (BOOL)textFieldShouldReturn:(UITextField*)_textField +{ SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RETURN); [self hideKeyboard]; return YES; @@ -308,8 +311,8 @@ - (BOOL)textFieldShouldReturn:(UITextField*)_textField { /* iPhone keyboard addition functions */ #if SDL_IPHONE_KEYBOARD -int SDL_iPhoneKeyboardShow(SDL_Window * window) { - +int SDL_iPhoneKeyboardShow(SDL_Window * window) +{ SDL_WindowData *data; SDL_uikitview *view; @@ -331,8 +334,8 @@ int SDL_iPhoneKeyboardShow(SDL_Window * window) { } } -int SDL_iPhoneKeyboardHide(SDL_Window * window) { - +int SDL_iPhoneKeyboardHide(SDL_Window * window) +{ SDL_WindowData *data; SDL_uikitview *view; @@ -354,8 +357,8 @@ int SDL_iPhoneKeyboardHide(SDL_Window * window) { } } -SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window * window) { - +SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window * window) +{ SDL_WindowData *data; SDL_uikitview *view; @@ -376,8 +379,8 @@ SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window * window) { } } -int SDL_iPhoneKeyboardToggle(SDL_Window * window) { - +int SDL_iPhoneKeyboardToggle(SDL_Window * window) +{ SDL_WindowData *data; SDL_uikitview *view; @@ -408,21 +411,25 @@ int SDL_iPhoneKeyboardToggle(SDL_Window * window) { /* stubs, used if compiled without keyboard support */ -int SDL_iPhoneKeyboardShow(SDL_Window * window) { +int SDL_iPhoneKeyboardShow(SDL_Window * window) +{ SDL_SetError("Not compiled with keyboard support"); return -1; } -int SDL_iPhoneKeyboardHide(SDL_Window * window) { +int SDL_iPhoneKeyboardHide(SDL_Window * window) +{ SDL_SetError("Not compiled with keyboard support"); return -1; } -SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window * window) { +SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window * window) +{ return 0; } -int SDL_iPhoneKeyboardToggle(SDL_Window * window) { +int SDL_iPhoneKeyboardToggle(SDL_Window * window) +{ SDL_SetError("Not compiled with keyboard support"); return -1; } diff --git a/src/video/uikit/SDL_uikitviewcontroller.m b/src/video/uikit/SDL_uikitviewcontroller.m index ded8387de..46ec2865f 100644 --- a/src/video/uikit/SDL_uikitviewcontroller.m +++ b/src/video/uikit/SDL_uikitviewcontroller.m @@ -33,7 +33,8 @@ @implementation SDL_uikitviewcontroller -- (id)initWithSDLWindow:(SDL_Window *)_window { +- (id)initWithSDLWindow:(SDL_Window *)_window +{ if ((self = [self init]) == nil) { return nil; } @@ -41,7 +42,8 @@ - (id)initWithSDLWindow:(SDL_Window *)_window { return self; } -- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orient { +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orient +{ const char *orientationsCString; if ((orientationsCString = SDL_GetHint(SDL_HINT_ORIENTATIONS)) != NULL) { BOOL rotate = NO; @@ -96,12 +98,14 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orient { return NO; // Nothing else is acceptable. } -- (void)loadView { +- (void)loadView +{ // do nothing. } // Send a resized event when the orientation changes. -- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { +- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation +{ if ((self->window->flags & SDL_WINDOW_RESIZABLE) == 0) { return; // don't care, we're just flipping over in this case. } diff --git a/src/video/uikit/SDL_uikitwindow.m b/src/video/uikit/SDL_uikitwindow.m index a47f0b690..b6ca48295 100644 --- a/src/video/uikit/SDL_uikitwindow.m +++ b/src/video/uikit/SDL_uikitwindow.m @@ -183,7 +183,8 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo } void -UIKit_DestroyWindow(_THIS, SDL_Window * window) { +UIKit_DestroyWindow(_THIS, SDL_Window * window) +{ SDL_WindowData *data = (SDL_WindowData *)window->driverdata; if (data) { [data->viewcontroller release];