mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 12:08:47 +02:00
Removed need for -Wnocast-qual on modern Clang/Xcode as a token of good behavior. Unfortunately the old stb_ decompress code is a little const clunky. + warning fix in stb_textedit which is already in master afaik.
This commit is contained in:
@ -41,7 +41,6 @@
|
||||
#pragma clang diagnostic ignored "-Wfloat-equal" // warning : comparing floating point with == or != is unsafe // storing and comparing against same constants ok.
|
||||
#pragma clang diagnostic ignored "-Wglobal-constructors" // warning : declaration requires a global destructor // similar to above, not sure what the exact difference it.
|
||||
#pragma clang diagnostic ignored "-Wsign-conversion" // warning : implicit conversion changes signedness //
|
||||
#pragma clang diagnostic ignored "-Wcast-qual" // warning : cast from 'const xxxx *' to 'xxx *' drops const qualifier //
|
||||
#if __has_warning("-Wcomma")
|
||||
#pragma clang diagnostic ignored "-Wcomma" // warning : possible misuse of comma operator here //
|
||||
#endif
|
||||
@ -55,7 +54,6 @@
|
||||
#pragma GCC diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used
|
||||
#pragma GCC diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function
|
||||
#pragma GCC diagnostic ignored "-Wconversion" // warning: conversion to 'xxxx' from 'xxxx' may alter its value
|
||||
#pragma GCC diagnostic ignored "-Wcast-qual" // warning: cast from type 'const xxxx *' to type 'xxxx *' casts away qualifiers
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
@ -84,11 +82,13 @@ namespace IMGUI_STB_NAMESPACE
|
||||
#pragma clang diagnostic ignored "-Wunused-function"
|
||||
#pragma clang diagnostic ignored "-Wmissing-prototypes"
|
||||
#pragma clang diagnostic ignored "-Wimplicit-fallthrough"
|
||||
#pragma clang diagnostic ignored "-Wcast-qual" // warning : cast from 'const xxxx *' to 'xxx *' drops const qualifier //
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wtype-limits" // warning: comparison is always true due to limited range of data type [-Wtype-limits]
|
||||
#pragma GCC diagnostic ignored "-Wcast-qual" // warning: cast from type 'const xxxx *' to type 'xxxx *' casts away qualifiers
|
||||
#endif
|
||||
|
||||
#ifndef IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION
|
||||
@ -1508,8 +1508,8 @@ ImFont* ImFontAtlas::AddFont(const ImFontConfig* font_cfg)
|
||||
}
|
||||
|
||||
// Default font TTF is compressed with stb_compress then base85 encoded (see misc/fonts/binary_to_compressed_c.cpp for encoder)
|
||||
static unsigned int stb_decompress_length(unsigned char *input);
|
||||
static unsigned int stb_decompress(unsigned char *output, unsigned char *i, unsigned int length);
|
||||
static unsigned int stb_decompress_length(const unsigned char *input);
|
||||
static unsigned int stb_decompress(unsigned char *output, const unsigned char *input, unsigned int length);
|
||||
static const char* GetDefaultCompressedFontDataTTFBase85();
|
||||
static unsigned int Decode85Byte(char c) { return c >= '\\' ? c-36 : c-35; }
|
||||
static void Decode85(const unsigned char* src, unsigned char* dst)
|
||||
@ -1576,9 +1576,9 @@ ImFont* ImFontAtlas::AddFontFromMemoryTTF(void* ttf_data, int ttf_size, float si
|
||||
|
||||
ImFont* ImFontAtlas::AddFontFromMemoryCompressedTTF(const void* compressed_ttf_data, int compressed_ttf_size, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges)
|
||||
{
|
||||
const unsigned int buf_decompressed_size = stb_decompress_length((unsigned char*)compressed_ttf_data);
|
||||
const unsigned int buf_decompressed_size = stb_decompress_length((const unsigned char*)compressed_ttf_data);
|
||||
unsigned char* buf_decompressed_data = (unsigned char *)ImGui::MemAlloc(buf_decompressed_size);
|
||||
stb_decompress(buf_decompressed_data, (unsigned char*)compressed_ttf_data, (unsigned int)compressed_ttf_size);
|
||||
stb_decompress(buf_decompressed_data, (const unsigned char*)compressed_ttf_data, (unsigned int)compressed_ttf_size);
|
||||
|
||||
ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
|
||||
IM_ASSERT(font_cfg.FontData == NULL);
|
||||
@ -2756,27 +2756,28 @@ void ImGui::RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, Im
|
||||
// Decompression from stb.h (public domain) by Sean Barrett https://github.com/nothings/stb/blob/master/stb.h
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static unsigned int stb_decompress_length(unsigned char *input)
|
||||
static unsigned int stb_decompress_length(const unsigned char *input)
|
||||
{
|
||||
return (input[8] << 24) + (input[9] << 16) + (input[10] << 8) + input[11];
|
||||
}
|
||||
|
||||
static unsigned char *stb__barrier, *stb__barrier2, *stb__barrier3, *stb__barrier4;
|
||||
static unsigned char *stb__barrier_out_e, *stb__barrier_out_b;
|
||||
static const unsigned char *stb__barrier_in_b;
|
||||
static unsigned char *stb__dout;
|
||||
static void stb__match(unsigned char *data, unsigned int length)
|
||||
static void stb__match(const unsigned char *data, unsigned int length)
|
||||
{
|
||||
// INVERSE of memmove... write each byte before copying the next...
|
||||
IM_ASSERT (stb__dout + length <= stb__barrier);
|
||||
if (stb__dout + length > stb__barrier) { stb__dout += length; return; }
|
||||
if (data < stb__barrier4) { stb__dout = stb__barrier+1; return; }
|
||||
IM_ASSERT(stb__dout + length <= stb__barrier_out_e);
|
||||
if (stb__dout + length > stb__barrier_out_e) { stb__dout += length; return; }
|
||||
if (data < stb__barrier_out_b) { stb__dout = stb__barrier_out_e+1; return; }
|
||||
while (length--) *stb__dout++ = *data++;
|
||||
}
|
||||
|
||||
static void stb__lit(unsigned char *data, unsigned int length)
|
||||
static void stb__lit(const unsigned char *data, unsigned int length)
|
||||
{
|
||||
IM_ASSERT (stb__dout + length <= stb__barrier);
|
||||
if (stb__dout + length > stb__barrier) { stb__dout += length; return; }
|
||||
if (data < stb__barrier2) { stb__dout = stb__barrier+1; return; }
|
||||
IM_ASSERT(stb__dout + length <= stb__barrier_out_e);
|
||||
if (stb__dout + length > stb__barrier_out_e) { stb__dout += length; return; }
|
||||
if (data < stb__barrier_in_b) { stb__dout = stb__barrier_out_e+1; return; }
|
||||
memcpy(stb__dout, data, length);
|
||||
stb__dout += length;
|
||||
}
|
||||
@ -2785,7 +2786,7 @@ static void stb__lit(unsigned char *data, unsigned int length)
|
||||
#define stb__in3(x) ((i[x] << 16) + stb__in2((x)+1))
|
||||
#define stb__in4(x) ((i[x] << 24) + stb__in3((x)+1))
|
||||
|
||||
static unsigned char *stb_decompress_token(unsigned char *i)
|
||||
static const unsigned char *stb_decompress_token(const unsigned char *i)
|
||||
{
|
||||
if (*i >= 0x20) { // use fewer if's for cases that expand small
|
||||
if (*i >= 0x80) stb__match(stb__dout-i[1]-1, i[0] - 0x80 + 1), i += 2;
|
||||
@ -2833,21 +2834,20 @@ static unsigned int stb_adler32(unsigned int adler32, unsigned char *buffer, uns
|
||||
return (unsigned int)(s2 << 16) + (unsigned int)s1;
|
||||
}
|
||||
|
||||
static unsigned int stb_decompress(unsigned char *output, unsigned char *i, unsigned int length)
|
||||
static unsigned int stb_decompress(unsigned char *output, const unsigned char *i, unsigned int /*length*/)
|
||||
{
|
||||
unsigned int olen;
|
||||
if (stb__in4(0) != 0x57bC0000) return 0;
|
||||
if (stb__in4(4) != 0) return 0; // error! stream is > 4GB
|
||||
olen = stb_decompress_length(i);
|
||||
stb__barrier2 = i;
|
||||
stb__barrier3 = i+length;
|
||||
stb__barrier = output + olen;
|
||||
stb__barrier4 = output;
|
||||
stb__barrier_in_b = i;
|
||||
stb__barrier_out_e = output + olen;
|
||||
stb__barrier_out_b = output;
|
||||
i += 16;
|
||||
|
||||
stb__dout = output;
|
||||
for (;;) {
|
||||
unsigned char *old_i = i;
|
||||
const unsigned char *old_i = i;
|
||||
i = stb_decompress_token(i);
|
||||
if (i == old_i) {
|
||||
if (*i == 0x05 && i[1] == 0xfa) {
|
||||
|
Reference in New Issue
Block a user