Codechange: automatic adding of _t to (u)int types, and WChar to char32_t

for i in `find src -type f|grep -v 3rdparty/fmt|grep -v 3rdparty/catch2|grep -v 3rdparty/opengl|grep -v stdafx.h`; do sed 's/uint16& /uint16 \&/g;s/int8\([ >*),;[]\)/int8_t\1/g;s/int16\([ >*),;[]\)/int16_t\1/g;s/int32\([ >*),;[]\)/int32_t\1/g;s/int64\([ >*),;[]\)/int64_t\1/g;s/ uint32(/ uint32_t(/g;s/_uint8_t/_uint8/;s/Uint8_t/Uint8/;s/ft_int64_t/ft_int64/g;s/uint64$/uint64_t/;s/WChar/char32_t/g;s/char32_t char32_t/char32_t WChar/' -i $i; done
This commit is contained in:
Rubidium
2023-05-08 19:01:06 +02:00
committed by rubidium42
parent 4f4810dc28
commit eaae0bb5e7
564 changed files with 4561 additions and 4561 deletions

View File

@@ -17,7 +17,7 @@
class VideoDriver_CocoaOpenGL : public VideoDriver_Cocoa {
CGLContextObj gl_context;
uint8 *anim_buffer; ///< Animation buffer from OpenGL back-end.
uint8_t *anim_buffer; ///< Animation buffer from OpenGL back-end.
std::string driver_info; ///< Information string about selected driver.
const char *AllocateContext(bool allow_software);
@@ -37,7 +37,7 @@ public:
void PopulateSystemSprites() override;
bool HasAnimBuffer() override { return true; }
uint8 *GetAnimBuffer() override { return this->anim_buffer; }
uint8_t *GetAnimBuffer() override { return this->anim_buffer; }
/** Return driver name */
const char *GetName() const override { return "cocoa-opengl"; }

View File

@@ -99,7 +99,7 @@ private:
int window_height; ///< Current window height in pixel
int window_pitch;
uint32 palette[256]; ///< Colour Palette
uint32_t palette[256]; ///< Colour Palette
void BlitIndexedToView32(int left, int top, int right, int bottom);
void UpdatePalette(uint first_color, uint num_colors);

View File

@@ -573,11 +573,11 @@ void VideoDriver_Cocoa::MainLoopReal()
static FVideoDriver_CocoaQuartz iFVideoDriver_CocoaQuartz;
/** Clear buffer to opaque black. */
static void ClearWindowBuffer(uint32 *buffer, uint32 pitch, uint32 height)
static void ClearWindowBuffer(uint32_t *buffer, uint32_t pitch, uint32_t height)
{
uint32 fill = Colour(0, 0, 0).data;
for (uint32 y = 0; y < height; y++) {
for (uint32 x = 0; x < pitch; x++) {
uint32_t fill = Colour(0, 0, 0).data;
for (uint32_t y = 0; y < height; y++) {
for (uint32_t x = 0; x < pitch; x++) {
buffer[y * pitch + x] = fill;
}
}
@@ -651,14 +651,14 @@ void VideoDriver_CocoaQuartz::AllocateBackingStore(bool force)
this->window_width = (int)newframe.size.width;
this->window_height = (int)newframe.size.height;
this->window_pitch = Align(this->window_width, 16 / sizeof(uint32)); // Quartz likes lines that are multiple of 16-byte.
this->window_pitch = Align(this->window_width, 16 / sizeof(uint32_t)); // Quartz likes lines that are multiple of 16-byte.
this->buffer_depth = BlitterFactory::GetCurrentBlitter()->GetScreenDepth();
/* Create Core Graphics Context */
free(this->window_buffer);
this->window_buffer = malloc(this->window_pitch * this->window_height * sizeof(uint32));
this->window_buffer = malloc(this->window_pitch * this->window_height * sizeof(uint32_t));
/* Initialize with opaque black. */
ClearWindowBuffer((uint32 *)this->window_buffer, this->window_pitch, this->window_height);
ClearWindowBuffer((uint32_t *)this->window_buffer, this->window_pitch, this->window_height);
CGContextRelease(this->cgcontext);
this->cgcontext = CGBitmapContextCreate(
@@ -706,9 +706,9 @@ void VideoDriver_CocoaQuartz::AllocateBackingStore(bool force)
*/
void VideoDriver_CocoaQuartz::BlitIndexedToView32(int left, int top, int right, int bottom)
{
const uint32 *pal = this->palette;
const uint8 *src = (uint8*)this->pixel_buffer;
uint32 *dst = (uint32*)this->window_buffer;
const uint32_t *pal = this->palette;
const uint8_t *src = (uint8_t*)this->pixel_buffer;
uint32_t *dst = (uint32_t*)this->window_buffer;
uint width = this->window_width;
uint pitch = this->window_pitch;
@@ -725,10 +725,10 @@ void VideoDriver_CocoaQuartz::UpdatePalette(uint first_color, uint num_colors)
if (this->buffer_depth != 8) return;
for (uint i = first_color; i < first_color + num_colors; i++) {
uint32 clr = 0xff000000;
clr |= (uint32)_local_palette.palette[i].r << 16;
clr |= (uint32)_local_palette.palette[i].g << 8;
clr |= (uint32)_local_palette.palette[i].b;
uint32_t clr = 0xff000000;
clr |= (uint32_t)_local_palette.palette[i].r << 16;
clr |= (uint32_t)_local_palette.palette[i].g << 8;
clr |= (uint32_t)_local_palette.palette[i].b;
this->palette[i] = clr;
}

View File

@@ -107,7 +107,7 @@ static NSUInteger CountUtf16Units(const char *from, const char *to)
NSUInteger i = 0;
while (from < to) {
WChar c;
char32_t c;
size_t len = Utf8Decode(&c, from);
i += len < 4 ? 1 : 2; // Watch for surrogate pairs.
from += len;
@@ -125,7 +125,7 @@ static NSUInteger CountUtf16Units(const char *from, const char *to)
static const char *Utf8AdvanceByUtf16Units(const char *str, NSUInteger count)
{
for (NSUInteger i = 0; i < count && *str != '\0'; ) {
WChar c;
char32_t c;
size_t len = Utf8Decode(&c, str);
i += len < 4 ? 1 : 2; // Watch for surrogates.
str += len;
@@ -139,9 +139,9 @@ static const char *Utf8AdvanceByUtf16Units(const char *str, NSUInteger count)
* @param s String to convert.
* @return Vector of UTF-32 characters.
*/
static std::vector<WChar> NSStringToUTF32(NSString *s)
static std::vector<char32_t> NSStringToUTF32(NSString *s)
{
std::vector<WChar> unicode_str;
std::vector<char32_t> unicode_str;
unichar lead = 0;
for (NSUInteger i = 0; i < s.length; i++) {
@@ -161,7 +161,7 @@ static std::vector<WChar> NSStringToUTF32(NSString *s)
static void CGDataFreeCallback(void *, const void *data, size_t)
{
delete[] (const uint32 *)data;
delete[] (const uint32_t *)data;
}
/**
@@ -176,7 +176,7 @@ static NSImage *NSImageFromSprite(SpriteID sprite_id, ZoomLevel zoom)
/* Fetch the sprite and create a new bitmap */
Dimension dim = GetSpriteSize(sprite_id, nullptr, zoom);
std::unique_ptr<uint32[]> buffer = DrawSpriteToRgbaBuffer(sprite_id, zoom);
std::unique_ptr<uint32_t[]> buffer = DrawSpriteToRgbaBuffer(sprite_id, zoom);
if (!buffer) return nullptr; // Failed to blit sprite for some reason.
CFAutoRelease<CGDataProvider> data(CGDataProviderCreateWithData(nullptr, buffer.release(), dim.width * dim.height * 4, &CGDataFreeCallback));
@@ -674,7 +674,7 @@ void CocoaDialog(const char *title, const char *message, const char *buttonLabel
- (BOOL)emulateRightButton:(NSEvent *)event
{
uint32 keymask = 0;
uint32_t keymask = 0;
if (_settings_client.gui.right_mouse_btn_emulation == RMBE_COMMAND) keymask |= NSEventModifierFlagCommand;
if (_settings_client.gui.right_mouse_btn_emulation == RMBE_CONTROL) keymask |= NSEventModifierFlagControl;
@@ -780,7 +780,7 @@ void CocoaDialog(const char *title, const char *message, const char *buttonLabel
}
- (BOOL)internalHandleKeycode:(unsigned short)keycode unicode:(WChar)unicode pressed:(BOOL)down modifiers:(NSUInteger)modifiers
- (BOOL)internalHandleKeycode:(unsigned short)keycode unicode:(char32_t)unicode pressed:(BOOL)down modifiers:(NSUInteger)modifiers
{
switch (keycode) {
case QZ_UP: SB(_dirkeys, 1, 1, down); break;
@@ -813,7 +813,7 @@ void CocoaDialog(const char *title, const char *message, const char *buttonLabel
if (down) {
/* Map keycode to OTTD code. */
auto vk = std::find_if(std::begin(_vk_mapping), std::end(_vk_mapping), [=](const CocoaVkMapping &m) { return m.vk_from == keycode; });
uint32 pressed_key = vk != std::end(_vk_mapping) ? vk->map_to : 0;
uint32_t pressed_key = vk != std::end(_vk_mapping) ? vk->map_to : 0;
if (modifiers & NSEventModifierFlagShift) pressed_key |= WKC_SHIFT;
if (modifiers & NSEventModifierFlagControl) pressed_key |= (_settings_client.gui.right_mouse_btn_emulation != RMBE_CONTROL ? WKC_CTRL : WKC_META);
@@ -861,7 +861,7 @@ void CocoaDialog(const char *title, const char *message, const char *buttonLabel
}
/* Convert UTF-16 characters to UCS-4 chars. */
std::vector<WChar> unicode_str = NSStringToUTF32([ event characters ]);
std::vector<char32_t> unicode_str = NSStringToUTF32([ event characters ]);
if (unicode_str.empty()) unicode_str.push_back(0);
if (EditBoxInGlobalFocus()) {
@@ -890,7 +890,7 @@ void CocoaDialog(const char *title, const char *message, const char *buttonLabel
}
/* Convert UTF-16 characters to UCS-4 chars. */
std::vector<WChar> unicode_str = NSStringToUTF32([ event characters ]);
std::vector<char32_t> unicode_str = NSStringToUTF32([ event characters ]);
if (unicode_str.empty()) unicode_str.push_back(0);
[ self internalHandleKeycode:event.keyCode unicode:unicode_str[0] pressed:NO modifiers:event.modifierFlags ];