Use #pragma once for include guards, use #import exclusively on Obj-C files

This commit is contained in:
Lior Halphon 2023-06-09 14:44:57 +03:00
parent bed26daf73
commit fef175dcc6
50 changed files with 63 additions and 158 deletions

View File

@ -1,5 +1,5 @@
#include <TargetConditionals.h>
#include <Core/gb.h>
#import <TargetConditionals.h>
#import <Core/gb.h>
#if TARGET_OS_IPHONE
#define NSView UIView

View File

@ -1,4 +1,4 @@
#include <TargetConditionals.h>
#import <TargetConditionals.h>
#import <MetalKit/MetalKit.h>
#if TARGET_OS_IPHONE
#import "../iOS/GBView.h"

View File

@ -1,6 +1,4 @@
#import <Cocoa/Cocoa.h>
#ifndef BigSurToolbar_h
#define BigSurToolbar_h
/* Backport the toolbarStyle property to allow compilation with older SDKs*/
#ifndef __MAC_10_16
@ -26,5 +24,3 @@ typedef NS_ENUM(NSInteger, NSWindowToolbarStyle) {
@end
#endif
#endif

View File

@ -1,6 +1,3 @@
#ifndef GBButtons_h
#define GBButtons_h
typedef enum : NSUInteger {
GBRight,
GBLeft,
@ -37,5 +34,3 @@ static inline NSString *button_to_preference_name(GBButton button, unsigned play
}
return [NSString stringWithFormat:@"GB%@", GBButtonNames[button]];
}
#endif

View File

@ -1,6 +1,6 @@
#import "GBOpenGLView.h"
#import "GBView.h"
#include <OpenGL/gl.h>
#import <OpenGL/gl.h>
@implementation GBOpenGLView

View File

@ -1,5 +1,5 @@
#import <Cocoa/Cocoa.h>
#include <Core/gb.h>
#import <Core/gb.h>
@interface GBTerminalTextFieldCell : NSTextFieldCell
@property (nonatomic) GB_gameboy_t *gb;

View File

@ -1,5 +1,5 @@
#import <Cocoa/Cocoa.h>
#include <Core/gb.h>
#import <Core/gb.h>
@interface GBVisualizerView : NSView
- (void)addSample:(GB_sample_t *)sample;

View File

@ -1,6 +1,6 @@
#import "GBVisualizerView.h"
#import "GBPaletteEditorController.h"
#include <Core/gb.h>
#import <Core/gb.h>
#define SAMPLE_COUNT 1024

View File

@ -1,6 +1,3 @@
#ifndef KeyboardShortcutPrivateAPIs_h
#define KeyboardShortcutPrivateAPIs_h
/* These are private APIs, but they are a very simple and comprehensive way
to convert a key equivalent to its display name. */
@ -22,5 +19,3 @@
@interface NSPrefPaneUtils : NSObject
+ (id)stringForVirtualKey:(unsigned int)key modifiers:(unsigned int)flags;
@end
#endif

View File

@ -1,5 +1,4 @@
#ifndef apu_h
#define apu_h
#pragma once
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
@ -197,6 +196,3 @@ internal void GB_apu_div_secondary_event(GB_gameboy_t *gb);
internal void GB_apu_init(GB_gameboy_t *gb);
internal void GB_apu_run(GB_gameboy_t *gb, bool force);
#endif
#endif

View File

@ -1,5 +1,4 @@
#ifndef camera_h
#define camera_h
#pragma once
#include <stdint.h>
#include "defs.h"
@ -25,5 +24,3 @@ enum {
GB_CAMERA_DITHERING_PATTERN_END = 0x35,
};
#endif
#endif

View File

@ -1,5 +1,4 @@
#ifndef cheats_h
#define cheats_h
#pragma once
#ifndef GB_DISABLE_CHEATS
#include "defs.h"
@ -40,4 +39,3 @@ struct GB_cheat_s {
#define GB_apply_cheat(...)
#endif // GB_INTERNAL
#endif // GB_DISABLE_CHEATS
#endif

View File

@ -1,5 +1,4 @@
#ifndef debugger_h
#define debugger_h
#pragma once
#ifndef GB_DISABLE_DEBUGGER
#include <stdbool.h>
#include <stdint.h>
@ -45,5 +44,3 @@ internal void GB_debugger_add_symbol(GB_gameboy_t *gb, uint16_t bank, uint16_t a
#endif // GB_INTERNAL
#endif // GB_DISABLE_DEBUGGER
#endif

View File

@ -1,5 +1,4 @@
#ifndef defs_h
#define defs_h
#pragma once
#define GB_likely(x) __builtin_expect((bool)(x), 1)
#define GB_unlikely(x) __builtin_expect((bool)(x), 0)
@ -59,4 +58,3 @@
struct GB_gameboy_s;
typedef struct GB_gameboy_s GB_gameboy_t;
#endif

View File

@ -1,5 +1,4 @@
#ifndef display_h
#define display_h
#pragma once
#include "gb.h"
#include <stdbool.h>
@ -78,6 +77,3 @@ void GB_set_object_rendering_disabled(GB_gameboy_t *gb, bool disabled);
void GB_set_background_rendering_disabled(GB_gameboy_t *gb, bool disabled);
bool GB_is_object_rendering_disabled(GB_gameboy_t *gb);
bool GB_is_background_rendering_disabled(GB_gameboy_t *gb);
#endif

View File

@ -1,5 +1,4 @@
#ifndef GB_h
#define GB_h
#pragma once
#include <stdbool.h>
#include <stdint.h>
#include <stdalign.h>
@ -1016,4 +1015,3 @@ internal void GB_clear_running_thread(GB_gameboy_t *gb);
#endif
#endif
#endif

View File

@ -1,5 +1,4 @@
#ifndef joypad_h
#define joypad_h
#pragma once
#include "defs.h"
#include <stdbool.h>
@ -43,4 +42,3 @@ void GB_set_emulate_joypad_bouncing(GB_gameboy_t *gb, bool emulate);
internal void GB_update_joyp(GB_gameboy_t *gb);
internal void GB_joypad_run(GB_gameboy_t *gb, unsigned cycles);
#endif
#endif

View File

@ -1,5 +1,4 @@
#ifndef mbc_h
#define mbc_h
#pragma once
#include "defs.h"
#include <stdbool.h>
@ -29,5 +28,3 @@ internal void GB_update_mbc_mappings(GB_gameboy_t *gb);
internal void GB_configure_cart(GB_gameboy_t *gb);
internal void GB_reset_mbc(GB_gameboy_t *gb);
#endif
#endif

View File

@ -1,5 +1,4 @@
#ifndef memory_h
#define memory_h
#pragma once
#include "defs.h"
#include <stdint.h>
@ -18,5 +17,3 @@ internal void GB_hdma_run(GB_gameboy_t *gb);
internal void GB_trigger_oam_bug(GB_gameboy_t *gb, uint16_t address);
internal uint8_t GB_read_oam(GB_gameboy_t *gb, uint8_t addr);
#endif
#endif

View File

@ -1,5 +1,4 @@
#ifndef model_h
#define model_h
#pragma once
#define GB_MODEL_FAMILY_MASK 0xF00
#define GB_MODEL_DMG_FAMILY 0x000
@ -38,6 +37,3 @@ typedef enum {
//GB_MODEL_AGB_E = 0x209
//GB_MODEL_GBP_E = GB_MODEL_AGB_E | GB_MODEL_GBP_BIT, // AGB-E inside a Game Boy Player
} GB_model_t;
#endif

View File

@ -1,5 +1,5 @@
#ifndef printer_h
#define printer_h
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include "defs.h"
@ -62,4 +62,3 @@ typedef struct
void GB_connect_printer(GB_gameboy_t *gb, GB_print_image_callback_t callback, GB_printer_done_callback_t done_callback);
#endif

View File

@ -1,5 +1,4 @@
#ifndef random_h
#define random_h
#pragma once
#include <stdint.h>
#include <stdbool.h>
@ -8,5 +7,3 @@ uint8_t GB_random(void);
uint32_t GB_random32(void);
void GB_random_seed(uint64_t seed);
void GB_random_set_enabled(bool enable);
#endif

View File

@ -1,5 +1,5 @@
#ifndef rewind_h
#define rewind_h
#pragma once
#ifndef GB_DISABLE_REWIND
#include <stdbool.h>
#include "defs.h"
@ -12,4 +12,3 @@ void GB_set_rewind_length(GB_gameboy_t *gb, double seconds);
void GB_rewind_reset(GB_gameboy_t *gb);
#endif
#endif

View File

@ -1,5 +1,4 @@
#ifndef rumble_h
#define rumble_h
#pragma once
#include "defs.h"
@ -13,5 +12,3 @@ typedef enum {
internal void GB_handle_rumble(GB_gameboy_t *gb);
#endif
void GB_set_rumble_mode(GB_gameboy_t *gb, GB_rumble_mode_t mode);
#endif

View File

@ -1,6 +1,6 @@
#pragma once
/* Macros to make the GB_gameboy_t struct more future compatible when state saving */
#ifndef save_state_h
#define save_state_h
#include <stddef.h>
#define GB_PADDING(type, old_usage) type old_usage##__do_not_use
@ -54,5 +54,3 @@ static inline uint32_t GB_state_magic(void)
internal size_t GB_get_save_state_size_no_bess(GB_gameboy_t *gb);
internal void GB_save_state_to_buffer_no_bess(GB_gameboy_t *gb, uint8_t *buffer);
#endif
#endif

View File

@ -1,5 +1,5 @@
#ifndef sgb_h
#define sgb_h
#pragma once
#include "defs.h"
#include <stdint.h>
#include <stdbool.h>
@ -67,5 +67,3 @@ internal void GB_sgb_render(GB_gameboy_t *gb);
internal void GB_sgb_load_default_data(GB_gameboy_t *gb);
#endif
#endif

View File

@ -1,5 +1,4 @@
#ifndef sm83_cpu_h
#define sm83_cpu_h
#pragma once
#include "defs.h"
#include <stdint.h>
@ -9,5 +8,3 @@ void GB_cpu_disassemble(GB_gameboy_t *gb, uint16_t pc, uint16_t count);
#ifdef GB_INTERNAL
internal void GB_cpu_run(GB_gameboy_t *gb);
#endif
#endif

View File

@ -1,5 +1,5 @@
#ifndef symbol_hash_h
#define symbol_hash_h
#pragma once
#ifndef GB_DISABLE_DEBUGGER
#include <stdlib.h>
#include <string.h>
@ -35,4 +35,3 @@ internal GB_symbol_map_t *GB_map_alloc(void);
internal void GB_map_free(GB_symbol_map_t *map);
#endif
#endif
#endif

View File

@ -1,5 +1,5 @@
#ifndef timing_h
#define timing_h
#pragma once
#include "defs.h"
typedef enum {
@ -57,5 +57,3 @@ GB_STATE_MACHINE(gb, unit, cycles, divisor)
#endif
#define GB_UNIT(unit) int32_t unit##_cycles, unit##_state
#endif

View File

@ -1,5 +1,5 @@
#ifndef workboy_h
#define workboy_h
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include <time.h>
@ -114,5 +114,3 @@ void GB_connect_workboy(GB_gameboy_t *gb,
GB_workboy_get_time_callback get_time_callback);
bool GB_workboy_is_enabled(GB_gameboy_t *gb);
void GB_workboy_set_key(GB_gameboy_t *gb, uint8_t key);
#endif

View File

@ -5,9 +5,9 @@
#import "JOYFullReportElement.h"
#import "JOYButton.h"
#import "JOYEmulatedButton.h"
#include <IOKit/hid/IOHIDLib.h>
#import <IOKit/hid/IOHIDLib.h>
#include <AppKit/AppKit.h>
#import <AppKit/AppKit.h>
extern NSTextField *globalDebugField;
#define PWM_RESOLUTION 16
@ -1199,7 +1199,7 @@ typedef union {
+ (void)load
{
#include "ControllerConfiguration.inc"
#import "ControllerConfiguration.inc"
}
+(void)registerListener:(id<JOYListener>)listener

View File

@ -1,5 +1,5 @@
#import <Foundation/Foundation.h>
#include <IOKit/hid/IOHIDLib.h>
#import <IOKit/hid/IOHIDLib.h>
@interface JOYElement : NSObject<NSCopying>
- (instancetype)initWithElement:(IOHIDElementRef)element;

View File

@ -1,6 +1,6 @@
#import "JOYElement.h"
#include <IOKit/hid/IOHIDLib.h>
#include <objc/runtime.h>
#import <IOKit/hid/IOHIDLib.h>
#import <objc/runtime.h>
@implementation JOYElement
{

View File

@ -1,6 +1,6 @@
#import <Foundation/Foundation.h>
#include <IOKit/hid/IOHIDLib.h>
#include "JOYElement.h"
#import <IOKit/hid/IOHIDLib.h>
#import "JOYElement.h"
@interface JOYFullReportElement : JOYElement<NSCopying>
- (instancetype)initWithDevice:(IOHIDDeviceRef) device reportID:(unsigned)reportID;

View File

@ -1,5 +1,5 @@
#import "JOYFullReportElement.h"
#include <IOKit/hid/IOHIDLib.h>
#import <IOKit/hid/IOHIDLib.h>
@implementation JOYFullReportElement
{

View File

@ -1,5 +1,5 @@
#import "JOYController.h"
#include <IOKit/hid/IOHIDLib.h>
#import <IOKit/hid/IOHIDLib.h>
@interface JOYMultiplayerController : JOYController
- (instancetype)initWithDevice:(IOHIDDeviceRef) device reportIDFilters:(NSArray <NSArray <NSNumber *> *>*) reportIDFilters hacks:hacks;

View File

@ -1,6 +1,3 @@
#ifndef JoyKit_h
#define JoyKit_h
#pragma once
#include "JOYController.h"
#endif
#import "JOYController.h"

View File

@ -1,7 +1,5 @@
#ifndef open_rom_h
#define open_rom_h
#pragma once
char *do_open_rom_dialog(void);
char *do_open_folder_dialog(void);
char *do_save_recording_dialog(unsigned frequency);
#endif

View File

@ -1,10 +1,6 @@
#ifndef get_image_for_rom_h
#define get_image_for_rom_h
#pragma once
#include <stdint.h>
typedef bool (*cancel_callback_t)(void*);
int get_image_for_rom(const char *filename, const char *boot_path, uint32_t *output, uint8_t *cgb_flag);
#endif

View File

@ -1,5 +1,4 @@
#ifndef sdl_audio_h
#define sdl_audio_h
#pragma once
#include <stdbool.h>
#include <stddef.h>
@ -41,5 +40,3 @@ typedef struct {
}
#define GB_AUDIO_DRIVER_REF(name) ({extern const GB_audio_driver_t name##driver; &name##driver;})
#endif

View File

@ -1,5 +1,4 @@
#ifndef configuration_h
#define configuration_h
#pragma once
#include <SDL.h>
#include <Core/gb.h>
@ -136,5 +135,3 @@ typedef struct {
} configuration_t;
extern configuration_t configuration;
#endif

View File

@ -1,5 +1,4 @@
#ifndef font_h
#define font_h
#pragma once
#include <stdint.h>
extern uint8_t font[];
@ -20,6 +19,3 @@ extern const uint8_t font_max;
#define COPYRIGHT_STRING "\x90"
#define CHECKBOX_OFF_STRING "\x93"
#define CHECKBOX_ON_STRING "\x94"
#endif

View File

@ -1,5 +1,4 @@
#ifndef gui_h
#define gui_h
#pragma once
#include <SDL.h>
#include <Core/gb.h>
@ -66,5 +65,3 @@ extern unsigned osd_countdown;
extern unsigned osd_text_lines;
void convert_mouse_coordinates(signed *x, signed *y);
const GB_palette_t *current_dmg_palette(void);
#endif

View File

@ -1,5 +1,4 @@
#ifndef opengl_compat_h
#define opengl_compat_h
#pragma once
#define GL_GLEXT_PROTOTYPES
#include <SDL_opengl.h>
@ -41,5 +40,3 @@ if (!GL_COMPAT_NAME(func)) GL_COMPAT_NAME(func) = SDL_GL_GetProcAddress(#func);
#define glGetShaderiv GL_COMPAT_WRAPPER(glGetShaderiv)
#define glGetShaderInfoLog GL_COMPAT_WRAPPER(glGetShaderInfoLog)
#endif
#endif

View File

@ -1,5 +1,5 @@
#ifndef shader_h
#define shader_h
#pragma once
#include "opengl_compat.h"
#include <stdbool.h>
@ -30,5 +30,3 @@ void render_bitmap_with_shader(shader_t *shader, void *bitmap, void *previous,
unsigned x, unsigned y, unsigned w, unsigned h,
GB_frame_blending_mode_t blending_mode);
void free_shader(struct shader_s *shader);
#endif

View File

@ -1,8 +1,6 @@
#ifndef utils_h
#define utils_h
#pragma once
#include <stddef.h>
char *resource_path(const char *filename);
void replace_extension(const char *src, size_t length, char *dest, const char *ext);
#endif

View File

@ -1,5 +1,5 @@
#import "GBROMManager.h"
#include <copyfile.h>
#import <copyfile.h>
@implementation GBROMManager
{

View File

@ -1,5 +1,5 @@
#import <UIKit/UIKit.h>
#include <Core/gb.h>
#import <Core/gb.h>
@interface GBSettingsViewController : UITableViewController
+ (UIViewController *)settingsViewControllerWithLeftButton:(UIBarButtonItem *)button;

View File

@ -13,7 +13,7 @@
#import "GBSettingsViewController.h"
#import "GBStatesViewController.h"
#import <CoreMotion/CoreMotion.h>
#include <Core/gb.h>
#import <Core/gb.h>
@implementation GBViewController
{

View File

@ -1,5 +1,5 @@
#import <UIKit/UIKit.h>
#include <Core/gb.h>
#import <Core/gb.h>
#import "GBViewController.h"
#import "GBView.h"