mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
Revert "Userland: static vs non-static constexpr variables"
This reverts commit 800ea8ea96
.
Booting the system no longer worked after these changes.
This commit is contained in:
parent
68f76b9e37
commit
d60ebbbba6
Notes:
sideshowbarker
2024-07-18 17:38:20 +09:00
38 changed files with 184 additions and 192 deletions
|
@ -7,7 +7,6 @@
|
|||
#include "CookieJar.h"
|
||||
#include <AK/IPv4Address.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/URL.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibWeb/Cookie/ParsedCookie.h>
|
||||
|
@ -49,9 +48,9 @@ void CookieJar::set_cookie(const URL& url, const Web::Cookie::ParsedCookie& pars
|
|||
|
||||
void CookieJar::dump_cookies() const
|
||||
{
|
||||
constexpr StringView key_color = "\033[34;1m";
|
||||
constexpr StringView attribute_color = "\033[33m";
|
||||
constexpr StringView no_color = "\033[0m";
|
||||
static const char* key_color = "\033[34;1m";
|
||||
static const char* attribute_color = "\033[33m";
|
||||
static const char* no_color = "\033[0m";
|
||||
|
||||
StringBuilder builder;
|
||||
builder.appendff("{} cookies stored\n", m_cookies.size());
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
|
||||
#include "AddEventDialog.h"
|
||||
#include <AK/StringView.h>
|
||||
#include <LibCore/DateTime.h>
|
||||
#include <LibGUI/BoxLayout.h>
|
||||
#include <LibGUI/Button.h>
|
||||
|
@ -21,6 +20,11 @@
|
|||
#include <LibGfx/Font.h>
|
||||
#include <LibGfx/FontDatabase.h>
|
||||
|
||||
static const char* short_month_names[] = {
|
||||
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
|
||||
};
|
||||
|
||||
AddEventDialog::AddEventDialog(Core::DateTime date_time, Window* parent_window)
|
||||
: Dialog(parent_window)
|
||||
, m_date_time(date_time)
|
||||
|
@ -117,11 +121,6 @@ String AddEventDialog::MonthListModel::column_name(int column) const
|
|||
|
||||
GUI::Variant AddEventDialog::MonthListModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) const
|
||||
{
|
||||
constexpr StringView short_month_names[] = {
|
||||
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
|
||||
};
|
||||
|
||||
auto& month = short_month_names[index.row()];
|
||||
if (role == GUI::ModelRole::Display) {
|
||||
switch (index.column()) {
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include "GlyphMapWidget.h"
|
||||
#include "NewFontDialog.h"
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/UnicodeUtils.h>
|
||||
#include <Applications/FontEditor/FontEditorWindowGML.h>
|
||||
#include <LibDesktop/Launcher.h>
|
||||
|
@ -38,10 +37,8 @@
|
|||
#include <LibGfx/TextDirection.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static RefPtr<GUI::Window> create_font_preview_window(FontEditorWidget& editor)
|
||||
{
|
||||
constexpr int pangram_count = 7;
|
||||
constexpr StringView pangrams[pangram_count] = {
|
||||
static constexpr int s_pangram_count = 7;
|
||||
static const char* pangrams[s_pangram_count] = {
|
||||
"quick fox jumps nightly above wizard",
|
||||
"five quacking zephyrs jolt my wax bed",
|
||||
"pack my box with five dozen liquor jugs",
|
||||
|
@ -49,8 +46,10 @@ static RefPtr<GUI::Window> create_font_preview_window(FontEditorWidget& editor)
|
|||
"waxy and quivering jocks fumble the pizza",
|
||||
"~#:[@_1%]*{$2.3}/4^(5'6\")-&|7+8!=<9,0\\>?;",
|
||||
"byxfjärmat föl gick på duvshowen"
|
||||
};
|
||||
};
|
||||
|
||||
static RefPtr<GUI::Window> create_font_preview_window(FontEditorWidget& editor)
|
||||
{
|
||||
auto window = GUI::Window::construct();
|
||||
window->set_window_type(GUI::WindowType::ToolWindow);
|
||||
window->set_title("Font preview");
|
||||
|
@ -95,7 +94,7 @@ static RefPtr<GUI::Window> create_font_preview_window(FontEditorWidget& editor)
|
|||
reload_button.set_fixed_width(22);
|
||||
reload_button.on_click = [&] {
|
||||
static int i = 1;
|
||||
if (i >= pangram_count)
|
||||
if (i >= s_pangram_count)
|
||||
i = 0;
|
||||
preview_textbox.set_text(pangrams[i]);
|
||||
i++;
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
*/
|
||||
|
||||
#include "FindDialog.h"
|
||||
#include <AK/Array.h>
|
||||
#include <AK/Hex.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibGUI/BoxLayout.h>
|
||||
#include <LibGUI/Button.h>
|
||||
#include <LibGUI/Label.h>
|
||||
|
@ -19,12 +19,17 @@
|
|||
#include <LibGfx/FontDatabase.h>
|
||||
|
||||
struct Option {
|
||||
StringView title;
|
||||
String title;
|
||||
OptionId opt;
|
||||
bool enabled;
|
||||
bool default_action;
|
||||
};
|
||||
|
||||
static const Vector<Option> options = {
|
||||
{ "ACII String", OPTION_ASCII_STRING, true, true },
|
||||
{ "Hex value", OPTION_HEX_VALUE, true, false },
|
||||
};
|
||||
|
||||
int FindDialog::show(GUI::Window* parent_window, String& out_text, ByteBuffer& out_buffer)
|
||||
{
|
||||
auto dialog = FindDialog::construct();
|
||||
|
@ -83,11 +88,6 @@ Result<ByteBuffer, String> FindDialog::process_input(String text_value, OptionId
|
|||
FindDialog::FindDialog()
|
||||
: Dialog(nullptr)
|
||||
{
|
||||
constexpr Array options = {
|
||||
Option { "ACII String", OPTION_ASCII_STRING, true, true },
|
||||
Option { "Hex value", OPTION_HEX_VALUE, true, false },
|
||||
};
|
||||
|
||||
resize(280, 180 + ((static_cast<int>(options.size()) - 3) * 16));
|
||||
center_on_screen();
|
||||
set_resizable(false);
|
||||
|
@ -113,7 +113,7 @@ FindDialog::FindDialog()
|
|||
radio.set_enabled(action.enabled);
|
||||
radio.set_text(action.title);
|
||||
|
||||
radio.on_checked = [&](auto) {
|
||||
radio.on_checked = [this, i](auto) {
|
||||
m_selected_option = options[i].opt;
|
||||
};
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
|
||||
#include "TreeMapWidget.h"
|
||||
#include <AK/Array.h>
|
||||
#include <AK/NumberFormat.h>
|
||||
#include <LibGUI/Painter.h>
|
||||
#include <LibGUI/WindowServerConnection.h>
|
||||
|
@ -25,7 +24,7 @@ TreeMapWidget::~TreeMapWidget()
|
|||
{
|
||||
}
|
||||
|
||||
static constexpr Array colors = {
|
||||
static const Color colors[] = {
|
||||
Color(253, 231, 37),
|
||||
Color(148, 216, 64),
|
||||
Color(60, 188, 117),
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include <AK/Queue.h>
|
||||
#include <AK/QuickSort.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/URL.h>
|
||||
#include <Applications/SpaceAnalyzer/SpaceAnalyzerGML.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
|
@ -28,6 +27,8 @@
|
|||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static const char* APP_NAME = "Space Analyzer";
|
||||
|
||||
struct TreeNode : public SpaceAnalyzer::TreeMapNode {
|
||||
TreeNode(String name)
|
||||
: m_name(move(name)) {};
|
||||
|
@ -252,8 +253,6 @@ static String get_absolute_path_to_selected_node(const SpaceAnalyzer::TreeMapWid
|
|||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
constexpr StringView APP_NAME = "Space Analyzer";
|
||||
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
RefPtr<Tree> tree = adopt_ref(*new Tree(""));
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
* [ ] handle fire bitmap edges better
|
||||
*/
|
||||
|
||||
#include <AK/Array.h>
|
||||
#include <LibCore/ElapsedTimer.h>
|
||||
#include <LibGUI/Action.h>
|
||||
#include <LibGUI/Application.h>
|
||||
|
@ -39,9 +38,22 @@
|
|||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static constexpr auto FIRE_WIDTH = 320;
|
||||
static constexpr auto FIRE_HEIGHT = 168;
|
||||
static constexpr auto FIRE_MAX = 29;
|
||||
#define FIRE_WIDTH 320
|
||||
#define FIRE_HEIGHT 168
|
||||
#define FIRE_MAX 29
|
||||
|
||||
static const Color s_palette[] = {
|
||||
Color(0x07, 0x07, 0x07), Color(0x1F, 0x07, 0x07), Color(0x2F, 0x0F, 0x07),
|
||||
Color(0x47, 0x0F, 0x07), Color(0x57, 0x17, 0x07), Color(0x67, 0x1F, 0x07),
|
||||
Color(0x77, 0x1F, 0x07), Color(0x9F, 0x2F, 0x07), Color(0xAF, 0x3F, 0x07),
|
||||
Color(0xBF, 0x47, 0x07), Color(0xC7, 0x47, 0x07), Color(0xDF, 0x4F, 0x07),
|
||||
Color(0xDF, 0x57, 0x07), Color(0xD7, 0x5F, 0x07), Color(0xD7, 0x5F, 0x07),
|
||||
Color(0xD7, 0x67, 0x0F), Color(0xCF, 0x6F, 0x0F), Color(0xCF, 0x7F, 0x0F),
|
||||
Color(0xCF, 0x87, 0x17), Color(0xC7, 0x87, 0x17), Color(0xC7, 0x8F, 0x17),
|
||||
Color(0xC7, 0x97, 0x1F), Color(0xBF, 0x9F, 0x1F), Color(0xBF, 0xA7, 0x27),
|
||||
Color(0xBF, 0xAF, 0x2F), Color(0xB7, 0xAF, 0x2F), Color(0xB7, 0xB7, 0x37),
|
||||
Color(0xCF, 0xCF, 0x6F), Color(0xEF, 0xEF, 0xC7), Color(0xFF, 0xFF, 0xFF)
|
||||
};
|
||||
|
||||
class Fire : public GUI::Widget {
|
||||
C_OBJECT(Fire)
|
||||
|
@ -68,24 +80,11 @@ private:
|
|||
|
||||
Fire::Fire()
|
||||
{
|
||||
constexpr Array palette = {
|
||||
Color(0x07, 0x07, 0x07), Color(0x1F, 0x07, 0x07), Color(0x2F, 0x0F, 0x07),
|
||||
Color(0x47, 0x0F, 0x07), Color(0x57, 0x17, 0x07), Color(0x67, 0x1F, 0x07),
|
||||
Color(0x77, 0x1F, 0x07), Color(0x9F, 0x2F, 0x07), Color(0xAF, 0x3F, 0x07),
|
||||
Color(0xBF, 0x47, 0x07), Color(0xC7, 0x47, 0x07), Color(0xDF, 0x4F, 0x07),
|
||||
Color(0xDF, 0x57, 0x07), Color(0xD7, 0x5F, 0x07), Color(0xD7, 0x5F, 0x07),
|
||||
Color(0xD7, 0x67, 0x0F), Color(0xCF, 0x6F, 0x0F), Color(0xCF, 0x7F, 0x0F),
|
||||
Color(0xCF, 0x87, 0x17), Color(0xC7, 0x87, 0x17), Color(0xC7, 0x8F, 0x17),
|
||||
Color(0xC7, 0x97, 0x1F), Color(0xBF, 0x9F, 0x1F), Color(0xBF, 0xA7, 0x27),
|
||||
Color(0xBF, 0xAF, 0x2F), Color(0xB7, 0xAF, 0x2F), Color(0xB7, 0xB7, 0x37),
|
||||
Color(0xCF, 0xCF, 0x6F), Color(0xEF, 0xEF, 0xC7), Color(0xFF, 0xFF, 0xFF)
|
||||
};
|
||||
|
||||
bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::Indexed8, { 320, 200 });
|
||||
|
||||
/* Initialize fire palette */
|
||||
for (int i = 0; i < 30; i++)
|
||||
bitmap->set_palette_color(i, palette[i]);
|
||||
bitmap->set_palette_color(i, s_palette[i]);
|
||||
|
||||
/* Set remaining entries to white */
|
||||
for (int i = 30; i < 256; i++)
|
||||
|
|
|
@ -14,8 +14,8 @@ class Game final : public GUI::Widget {
|
|||
C_OBJECT(Game);
|
||||
|
||||
public:
|
||||
static constexpr int game_width = 480;
|
||||
static constexpr int game_height = 500;
|
||||
static const int game_width = 480;
|
||||
static const int game_height = 500;
|
||||
|
||||
virtual ~Game() override;
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@ class Game final : public GUI::Widget {
|
|||
C_OBJECT(Game);
|
||||
|
||||
public:
|
||||
static constexpr int game_width = 560;
|
||||
static constexpr int game_height = 480;
|
||||
static const int game_width = 560;
|
||||
static const int game_height = 480;
|
||||
|
||||
virtual ~Game() override;
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ static constexpr i32 lookup_server_endpoint_magic = 9001;
|
|||
|
||||
// Get service entry buffers and file information for the getservent() family of functions.
|
||||
static FILE* services_file = nullptr;
|
||||
static constexpr char services_path[] = "/etc/services";
|
||||
static const char* services_path = "/etc/services";
|
||||
|
||||
static bool fill_getserv_buffers(const char* line, ssize_t read);
|
||||
static servent __getserv_buffer;
|
||||
|
@ -50,7 +50,7 @@ static ssize_t service_file_offset = 0;
|
|||
|
||||
// Get protocol entry buffers and file information for the getprotent() family of functions.
|
||||
static FILE* protocols_file = nullptr;
|
||||
static constexpr char protocols_path[] = "/etc/protocols";
|
||||
static const char* protocols_path = "/etc/protocols";
|
||||
|
||||
static bool fill_getproto_buffers(const char* line, ssize_t read);
|
||||
static protoent __getproto_buffer;
|
||||
|
|
|
@ -70,9 +70,10 @@ char* ctime_r(const time_t* t, char* buf)
|
|||
return asctime_r(localtime_r(t, &tm_buf), buf);
|
||||
}
|
||||
|
||||
static const int __seconds_per_day = 60 * 60 * 24;
|
||||
|
||||
static void time_to_tm(struct tm* tm, time_t t)
|
||||
{
|
||||
constexpr int __seconds_per_day = 60 * 60 * 24;
|
||||
int year = 1970;
|
||||
for (; t >= days_in_year(year) * __seconds_per_day; ++year)
|
||||
t -= days_in_year(year) * __seconds_per_day;
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/Array.h>
|
||||
#include <LibCore/DateTime.h>
|
||||
#include <LibGUI/Calendar.h>
|
||||
#include <LibGUI/Painter.h>
|
||||
|
@ -17,21 +16,21 @@ REGISTER_WIDGET(GUI, Calendar);
|
|||
|
||||
namespace GUI {
|
||||
|
||||
static constexpr Array long_day_names = {
|
||||
static const char* long_day_names[] = {
|
||||
"Sunday", "Monday", "Tuesday", "Wednesday",
|
||||
"Thursday", "Friday", "Saturday"
|
||||
};
|
||||
|
||||
static constexpr Array short_day_names = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
|
||||
static constexpr Array mini_day_names = { "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" };
|
||||
static constexpr Array micro_day_names = { "S", "M", "T", "W", "T", "F", "S" };
|
||||
static const char* short_day_names[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
|
||||
static const char* mini_day_names[] = { "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" };
|
||||
static const char* micro_day_names[] = { "S", "M", "T", "W", "T", "F", "S" };
|
||||
|
||||
static constexpr Array long_month_names = {
|
||||
static const char* long_month_names[] = {
|
||||
"January", "February", "March", "April", "May", "June",
|
||||
"July", "August", "September", "October", "November", "December"
|
||||
};
|
||||
|
||||
static constexpr Array short_month_names = {
|
||||
static const char* short_month_names[] = {
|
||||
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
|
||||
};
|
||||
|
|
|
@ -15,9 +15,9 @@ REGISTER_WIDGET(GUI, CheckBox)
|
|||
|
||||
namespace GUI {
|
||||
|
||||
static constexpr int s_box_width = 13;
|
||||
static constexpr int s_box_height = 13;
|
||||
static constexpr int s_horizontal_padding = 6;
|
||||
static const int s_box_width = 13;
|
||||
static const int s_box_height = 13;
|
||||
static const int s_horizontal_padding = 6;
|
||||
|
||||
CheckBox::CheckBox(String text)
|
||||
: AbstractButton(move(text))
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
namespace GUI {
|
||||
|
||||
static constexpr char s_arrow_bitmap_data[] = {
|
||||
static const char* s_arrow_bitmap_data = {
|
||||
" "
|
||||
" # "
|
||||
" ## "
|
||||
|
@ -24,8 +24,8 @@ static constexpr char s_arrow_bitmap_data[] = {
|
|||
" # "
|
||||
" "
|
||||
};
|
||||
static constexpr int s_arrow_bitmap_width = 9;
|
||||
static constexpr int s_arrow_bitmap_height = 9;
|
||||
static const int s_arrow_bitmap_width = 9;
|
||||
static const int s_arrow_bitmap_height = 9;
|
||||
|
||||
ColumnsView::ColumnsView()
|
||||
{
|
||||
|
|
|
@ -169,10 +169,7 @@ Icon FileIconProvider::icon_for_executable(const String& path)
|
|||
int image_size;
|
||||
};
|
||||
|
||||
constexpr Array icon_sections = {
|
||||
IconSection { .section_name = "serenity_icon_s", .image_size = 16 },
|
||||
IconSection { .section_name = "serenity_icon_m", .image_size = 32 }
|
||||
};
|
||||
static const IconSection icon_sections[] = { { .section_name = "serenity_icon_s", .image_size = 16 }, { .section_name = "serenity_icon_m", .image_size = 32 } };
|
||||
|
||||
bool had_error = false;
|
||||
for (const auto& icon_section : icon_sections) {
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
namespace GUI {
|
||||
|
||||
static constexpr char s_resize_corner_shadows_data[] = {
|
||||
static const char* s_resize_corner_shadows_data = {
|
||||
" "
|
||||
" ## "
|
||||
" # "
|
||||
|
@ -31,7 +31,7 @@ static constexpr char s_resize_corner_shadows_data[] = {
|
|||
" "
|
||||
};
|
||||
|
||||
static constexpr char s_resize_corner_highlights_data[] = {
|
||||
static const char* s_resize_corner_highlights_data = {
|
||||
" "
|
||||
" "
|
||||
" # "
|
||||
|
@ -52,8 +52,8 @@ static constexpr char s_resize_corner_highlights_data[] = {
|
|||
|
||||
static Gfx::CharacterBitmap* s_resize_corner_shadows_bitmap;
|
||||
static Gfx::CharacterBitmap* s_resize_corner_highlights_bitmap;
|
||||
static constexpr int s_resize_corner_bitmap_width = 16;
|
||||
static constexpr int s_resize_corner_bitmap_height = 16;
|
||||
static const int s_resize_corner_bitmap_width = 16;
|
||||
static const int s_resize_corner_bitmap_height = 16;
|
||||
|
||||
ResizeCorner::ResizeCorner()
|
||||
{
|
||||
|
|
|
@ -15,7 +15,7 @@ REGISTER_WIDGET(GUI, Scrollbar)
|
|||
|
||||
namespace GUI {
|
||||
|
||||
static constexpr char s_up_arrow_bitmap_data[] = {
|
||||
static const char* s_up_arrow_bitmap_data = {
|
||||
" "
|
||||
" # "
|
||||
" ### "
|
||||
|
@ -27,7 +27,7 @@ static constexpr char s_up_arrow_bitmap_data[] = {
|
|||
" "
|
||||
};
|
||||
|
||||
static constexpr char s_down_arrow_bitmap_data[] = {
|
||||
static const char* s_down_arrow_bitmap_data = {
|
||||
" "
|
||||
" ### "
|
||||
" ### "
|
||||
|
@ -39,7 +39,7 @@ static constexpr char s_down_arrow_bitmap_data[] = {
|
|||
" "
|
||||
};
|
||||
|
||||
static constexpr char s_left_arrow_bitmap_data[] = {
|
||||
static const char* s_left_arrow_bitmap_data = {
|
||||
" "
|
||||
" # "
|
||||
" ## "
|
||||
|
@ -51,7 +51,7 @@ static constexpr char s_left_arrow_bitmap_data[] = {
|
|||
" "
|
||||
};
|
||||
|
||||
static constexpr char s_right_arrow_bitmap_data[] = {
|
||||
static const char* s_right_arrow_bitmap_data = {
|
||||
" "
|
||||
" # "
|
||||
" ## "
|
||||
|
|
|
@ -354,7 +354,7 @@ void ClassicStylePainter::paint_radio_button(Painter& painter, const IntRect& re
|
|||
painter.blit(rect.location(), bitmap, bitmap.rect());
|
||||
}
|
||||
|
||||
static constexpr char s_checked_bitmap_data[] = {
|
||||
static const char* s_checked_bitmap_data = {
|
||||
" "
|
||||
" # "
|
||||
" ## "
|
||||
|
@ -367,8 +367,8 @@ static constexpr char s_checked_bitmap_data[] = {
|
|||
};
|
||||
|
||||
static Gfx::CharacterBitmap* s_checked_bitmap;
|
||||
static constexpr int s_checked_bitmap_width = 9;
|
||||
static constexpr int s_checked_bitmap_height = 9;
|
||||
static const int s_checked_bitmap_width = 9;
|
||||
static const int s_checked_bitmap_height = 9;
|
||||
|
||||
void ClassicStylePainter::paint_check_box(Painter& painter, const IntRect& rect, const Palette& palette, bool is_enabled, bool is_checked, bool is_being_pressed)
|
||||
{
|
||||
|
|
|
@ -140,7 +140,7 @@ public:
|
|||
#endif
|
||||
}
|
||||
|
||||
Color interpolate(const Color& other, float weight) const
|
||||
constexpr Color interpolate(const Color& other, float weight) const
|
||||
{
|
||||
u8 r = red() + roundf(static_cast<float>(other.red() - red()) * weight);
|
||||
u8 g = green() + roundf(static_cast<float>(other.green() - green()) * weight);
|
||||
|
|
|
@ -19,6 +19,10 @@
|
|||
|
||||
namespace Gfx {
|
||||
|
||||
// Row strides and offsets for each interlace pass.
|
||||
static const int INTERLACE_ROW_STRIDES[] = { 8, 8, 4, 2 };
|
||||
static const int INTERLACE_ROW_OFFSETS[] = { 0, 4, 2, 1 };
|
||||
|
||||
struct ImageDescriptor {
|
||||
u16 x { 0 };
|
||||
u16 y { 0 };
|
||||
|
@ -108,8 +112,8 @@ enum class GIFFormat {
|
|||
|
||||
static Optional<GIFFormat> decode_gif_header(InputMemoryStream& stream)
|
||||
{
|
||||
constexpr char valid_header_87[] = "GIF87a";
|
||||
constexpr char valid_header_89[] = "GIF89a";
|
||||
static const char valid_header_87[] = "GIF87a";
|
||||
static const char valid_header_89[] = "GIF89a";
|
||||
|
||||
Array<u8, 6> header;
|
||||
stream >> header;
|
||||
|
@ -374,8 +378,6 @@ static bool decode_frame(GIFLoadingContext& context, size_t frame_index)
|
|||
if (pixel_index % image.width == 0) {
|
||||
if (image.interlaced) {
|
||||
if (interlace_pass < 4) {
|
||||
constexpr Array INTERLACE_ROW_STRIDES = { 8, 8, 4, 2 };
|
||||
constexpr Array INTERLACE_ROW_OFFSETS = { 0, 4, 2, 1 };
|
||||
if (row + INTERLACE_ROW_STRIDES[interlace_pass] >= image.height) {
|
||||
++interlace_pass;
|
||||
if (interlace_pass < 4)
|
||||
|
|
|
@ -861,20 +861,20 @@ static void dequantize(JPGLoadingContext& context, Vector<Macroblock>& macrobloc
|
|||
|
||||
static void inverse_dct(const JPGLoadingContext& context, Vector<Macroblock>& macroblocks)
|
||||
{
|
||||
const float m0 = 2.0 * cos(1.0 / 16.0 * 2.0 * M_PI);
|
||||
const float m1 = 2.0 * cos(2.0 / 16.0 * 2.0 * M_PI);
|
||||
const float m3 = 2.0 * cos(2.0 / 16.0 * 2.0 * M_PI);
|
||||
const float m5 = 2.0 * cos(3.0 / 16.0 * 2.0 * M_PI);
|
||||
const float m2 = m0 - m5;
|
||||
const float m4 = m0 + m5;
|
||||
const float s0 = cos(0.0 / 16.0 * M_PI) / sqrt(8);
|
||||
const float s1 = cos(1.0 / 16.0 * M_PI) / 2.0;
|
||||
const float s2 = cos(2.0 / 16.0 * M_PI) / 2.0;
|
||||
const float s3 = cos(3.0 / 16.0 * M_PI) / 2.0;
|
||||
const float s4 = cos(4.0 / 16.0 * M_PI) / 2.0;
|
||||
const float s5 = cos(5.0 / 16.0 * M_PI) / 2.0;
|
||||
const float s6 = cos(6.0 / 16.0 * M_PI) / 2.0;
|
||||
const float s7 = cos(7.0 / 16.0 * M_PI) / 2.0;
|
||||
static const float m0 = 2.0 * cos(1.0 / 16.0 * 2.0 * M_PI);
|
||||
static const float m1 = 2.0 * cos(2.0 / 16.0 * 2.0 * M_PI);
|
||||
static const float m3 = 2.0 * cos(2.0 / 16.0 * 2.0 * M_PI);
|
||||
static const float m5 = 2.0 * cos(3.0 / 16.0 * 2.0 * M_PI);
|
||||
static const float m2 = m0 - m5;
|
||||
static const float m4 = m0 + m5;
|
||||
static const float s0 = cos(0.0 / 16.0 * M_PI) / sqrt(8);
|
||||
static const float s1 = cos(1.0 / 16.0 * M_PI) / 2.0;
|
||||
static const float s2 = cos(2.0 / 16.0 * M_PI) / 2.0;
|
||||
static const float s3 = cos(3.0 / 16.0 * M_PI) / 2.0;
|
||||
static const float s4 = cos(4.0 / 16.0 * M_PI) / 2.0;
|
||||
static const float s5 = cos(5.0 / 16.0 * M_PI) / 2.0;
|
||||
static const float s6 = cos(6.0 / 16.0 * M_PI) / 2.0;
|
||||
static const float s7 = cos(7.0 / 16.0 * M_PI) / 2.0;
|
||||
|
||||
for (u32 vcursor = 0; vcursor < context.mblock_meta.vcount; vcursor += context.vsample_factor) {
|
||||
for (u32 hcursor = 0; hcursor < context.mblock_meta.hcount; hcursor += context.hsample_factor) {
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
namespace Gfx {
|
||||
|
||||
static constexpr Array png_header = { 0x89, 'P', 'N', 'G', 13, 10, 26, 10 };
|
||||
static const u8 png_header[8] = { 0x89, 'P', 'N', 'G', 13, 10, 26, 10 };
|
||||
|
||||
struct PNG_IHDR {
|
||||
NetworkOrdered<u32> width;
|
||||
|
@ -512,7 +512,7 @@ static bool decode_png_header(PNGLoadingContext& context)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (memcmp(context.data, png_header.data(), sizeof(png_header)) != 0) {
|
||||
if (memcmp(context.data, png_header, sizeof(png_header)) != 0) {
|
||||
dbgln_if(PNG_DEBUG, "Invalid PNG header");
|
||||
context.state = PNGLoadingContext::State::Error;
|
||||
return false;
|
||||
|
@ -661,14 +661,14 @@ static int adam7_width(PNGLoadingContext& context, int pass)
|
|||
}
|
||||
}
|
||||
|
||||
// Index 0 unused (non-interlaced case)
|
||||
static int adam7_starty[8] = { 0, 0, 0, 4, 0, 2, 0, 1 };
|
||||
static int adam7_startx[8] = { 0, 0, 4, 0, 2, 0, 1, 0 };
|
||||
static int adam7_stepy[8] = { 1, 8, 8, 8, 4, 4, 2, 2 };
|
||||
static int adam7_stepx[8] = { 1, 8, 8, 4, 4, 2, 2, 1 };
|
||||
|
||||
static bool decode_adam7_pass(PNGLoadingContext& context, Streamer& streamer, int pass)
|
||||
{
|
||||
// Index 0 unused (non-interlaced case)
|
||||
constexpr Array adam7_starty = { 0, 0, 0, 4, 0, 2, 0, 1 };
|
||||
constexpr Array adam7_startx = { 0, 0, 4, 0, 2, 0, 1, 0 };
|
||||
constexpr Array adam7_stepy = { 1, 8, 8, 8, 4, 4, 2, 2 };
|
||||
constexpr Array adam7_stepx = { 1, 8, 8, 4, 4, 2, 2, 1 };
|
||||
|
||||
PNGLoadingContext subimage_context;
|
||||
subimage_context.width = adam7_width(context, pass);
|
||||
subimage_context.height = adam7_height(context, pass);
|
||||
|
|
|
@ -1476,7 +1476,7 @@ void do_draw_text(const IntRect& rect, const TextType& text, const Font& font, T
|
|||
lines.append(line);
|
||||
}
|
||||
|
||||
constexpr int line_spacing = 4;
|
||||
static const int line_spacing = 4;
|
||||
int line_height = font.glyph_height() + line_spacing;
|
||||
IntRect bounding_rect { 0, 0, 0, (static_cast<int>(lines.size()) * line_height) - line_spacing };
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
|
||||
#include <AK/Function.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <LibJS/Runtime/Error.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibJS/Runtime/NumberObject.h>
|
||||
|
@ -13,6 +12,17 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
static const u8 max_precision_for_radix[37] = {
|
||||
// clang-format off
|
||||
0, 0, 52, 32, 26, 22, 20, 18, 17, 16,
|
||||
15, 15, 14, 14, 13, 13, 13, 12, 12, 12,
|
||||
12, 11, 11, 11, 11, 11, 11, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10,
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static char digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
|
||||
NumberPrototype::NumberPrototype(GlobalObject& global_object)
|
||||
: NumberObject(0, *global_object.object_prototype())
|
||||
{
|
||||
|
@ -31,8 +41,6 @@ NumberPrototype::~NumberPrototype()
|
|||
|
||||
JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_string)
|
||||
{
|
||||
constexpr StringView digits = "0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
|
||||
Value number_value;
|
||||
|
||||
auto this_value = vm.this_value(global_object);
|
||||
|
@ -99,14 +107,6 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_string)
|
|||
if (decimal_part != 0.0) {
|
||||
characters.append('.');
|
||||
|
||||
constexpr u8 max_precision_for_radix[37] = {
|
||||
// clang-format off
|
||||
0, 0, 52, 32, 26, 22, 20, 18, 17, 16,
|
||||
15, 15, 14, 14, 13, 13, 13, 12, 12, 12,
|
||||
12, 11, 11, 11, 11, 11, 11, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10,
|
||||
// clang-format on
|
||||
};
|
||||
u8 precision = max_precision_for_radix[radix];
|
||||
|
||||
for (u8 i = 0; i < precision; ++i) {
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
namespace JS {
|
||||
|
||||
// Used in various abstract operations to make it obvious when a non-optional return value must be discarded.
|
||||
static constexpr double INVALID { 0 };
|
||||
static const double INVALID { 0 };
|
||||
|
||||
static inline bool same_type_for_equality(const Value& lhs, const Value& rhs)
|
||||
{
|
||||
|
|
|
@ -56,11 +56,11 @@ union FloatExtractor;
|
|||
// This assumes long double is 80 bits, which is true with GCC on Intel platforms
|
||||
template<>
|
||||
union FloatExtractor<long double> {
|
||||
static constexpr int mantissa_bits = 64;
|
||||
static constexpr unsigned long long mantissa_max = ~0u;
|
||||
static constexpr int exponent_bias = 16383;
|
||||
static constexpr int exponent_bits = 15;
|
||||
static constexpr unsigned exponent_max = 32767;
|
||||
static const int mantissa_bits = 64;
|
||||
static const unsigned long long mantissa_max = ~0u;
|
||||
static const int exponent_bias = 16383;
|
||||
static const int exponent_bits = 15;
|
||||
static const unsigned exponent_max = 32767;
|
||||
struct {
|
||||
unsigned long long mantissa;
|
||||
unsigned exponent : 15;
|
||||
|
@ -72,11 +72,11 @@ union FloatExtractor<long double> {
|
|||
|
||||
template<>
|
||||
union FloatExtractor<double> {
|
||||
static constexpr int mantissa_bits = 52;
|
||||
static constexpr unsigned long long mantissa_max = (1ull << 52) - 1;
|
||||
static constexpr int exponent_bias = 1023;
|
||||
static constexpr int exponent_bits = 11;
|
||||
static constexpr unsigned exponent_max = 2047;
|
||||
static const int mantissa_bits = 52;
|
||||
static const unsigned long long mantissa_max = (1ull << 52) - 1;
|
||||
static const int exponent_bias = 1023;
|
||||
static const int exponent_bits = 11;
|
||||
static const unsigned exponent_max = 2047;
|
||||
struct {
|
||||
unsigned long long mantissa : 52;
|
||||
unsigned exponent : 11;
|
||||
|
@ -87,11 +87,11 @@ union FloatExtractor<double> {
|
|||
|
||||
template<>
|
||||
union FloatExtractor<float> {
|
||||
static constexpr int mantissa_bits = 23;
|
||||
static constexpr unsigned mantissa_max = (1 << 23) - 1;
|
||||
static constexpr int exponent_bias = 127;
|
||||
static constexpr int exponent_bits = 8;
|
||||
static constexpr unsigned exponent_max = 255;
|
||||
static const int mantissa_bits = 23;
|
||||
static const unsigned mantissa_max = (1 << 23) - 1;
|
||||
static const int exponent_bias = 127;
|
||||
static const int exponent_bits = 8;
|
||||
static const unsigned exponent_max = 255;
|
||||
struct {
|
||||
unsigned long long mantissa : 23;
|
||||
unsigned exponent : 8;
|
||||
|
|
|
@ -6,9 +6,7 @@
|
|||
|
||||
#include <LibC/bits/pthread_forward.h>
|
||||
|
||||
[[gnu::constructor]] static void forward_pthread_functions()
|
||||
{
|
||||
constexpr PthreadFunctions s_functions = {
|
||||
static const PthreadFunctions s_functions = {
|
||||
.pthread_mutex_trylock = pthread_mutex_trylock,
|
||||
.pthread_mutex_destroy = pthread_mutex_destroy,
|
||||
|
||||
|
@ -24,6 +22,9 @@
|
|||
.pthread_cond_wait = pthread_cond_wait,
|
||||
.pthread_cond_destroy = pthread_cond_destroy,
|
||||
.pthread_cond_timedwait = pthread_cond_timedwait,
|
||||
};
|
||||
};
|
||||
|
||||
[[gnu::constructor]] static void forward_pthread_functions()
|
||||
{
|
||||
__init_pthread_forward(s_functions);
|
||||
}
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
|
||||
namespace regex {
|
||||
|
||||
static constexpr size_t c_max_recursion = 5000;
|
||||
static constexpr size_t c_match_preallocation_count = 0;
|
||||
static const constexpr size_t c_max_recursion = 5000;
|
||||
static const constexpr size_t c_match_preallocation_count = 0;
|
||||
|
||||
struct RegexResult final {
|
||||
bool success { false };
|
||||
|
|
|
@ -16,8 +16,8 @@ namespace VT {
|
|||
struct Attribute {
|
||||
Attribute() { reset(); }
|
||||
|
||||
static constexpr u32 default_foreground_color = xterm_colors[7];
|
||||
static constexpr u32 default_background_color = xterm_colors[0];
|
||||
static const u32 default_foreground_color = xterm_colors[7];
|
||||
static const u32 default_background_color = xterm_colors[0];
|
||||
|
||||
void reset()
|
||||
{
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
|
||||
#include "ParsedCookie.h"
|
||||
#include <AK/Array.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibIPC/Decoder.h>
|
||||
|
@ -265,7 +264,7 @@ Optional<Core::DateTime> parse_date_time(StringView date_string)
|
|||
};
|
||||
|
||||
auto parse_month = [&](StringView token) {
|
||||
constexpr Array months { "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec" };
|
||||
static const char* months[] { "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec" };
|
||||
|
||||
for (unsigned i = 0; i < 12; ++i) {
|
||||
if (token.equals_ignoring_case(months[i])) {
|
||||
|
|
|
@ -100,7 +100,7 @@ static void build(InstructionDescriptor* table, u8 op, const char* mnemonic, Ins
|
|||
case OP_AX_moff16:
|
||||
case OP_EAX_moff32:
|
||||
case OP_NEAR_imm:
|
||||
d.imm1_bytes = InstructionDescriptor::CurrentAddressSize;
|
||||
d.imm1_bytes = CurrentAddressSize;
|
||||
break;
|
||||
//default:
|
||||
case InvalidFormat:
|
||||
|
|
|
@ -28,9 +28,9 @@ protected:
|
|||
|
||||
template<typename T>
|
||||
struct TypeTrivia {
|
||||
static constexpr size_t bits = sizeof(T) * 8;
|
||||
static constexpr T sign_bit = 1 << (bits - 1);
|
||||
static constexpr T mask = MakeUnsigned<T>(-1);
|
||||
static const size_t bits = sizeof(T) * 8;
|
||||
static const T sign_bit = 1 << (bits - 1);
|
||||
static const T mask = MakeUnsigned<T>(-1);
|
||||
};
|
||||
|
||||
template<typename T, typename U>
|
||||
|
@ -159,9 +159,9 @@ enum InstructionFormat {
|
|||
OP_NEAR_imm,
|
||||
};
|
||||
|
||||
struct InstructionDescriptor {
|
||||
static constexpr unsigned CurrentAddressSize = 0xB33FBABE;
|
||||
static const unsigned CurrentAddressSize = 0xB33FBABE;
|
||||
|
||||
struct InstructionDescriptor {
|
||||
InstructionHandler handler { nullptr };
|
||||
bool opcode_has_register_index { false };
|
||||
const char* mnemonic { nullptr };
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
#include "ShutdownDialog.h"
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibGUI/BoxLayout.h>
|
||||
#include <LibGUI/Button.h>
|
||||
|
@ -17,7 +17,7 @@
|
|||
#include <LibGfx/FontDatabase.h>
|
||||
|
||||
struct Option {
|
||||
StringView title;
|
||||
String title;
|
||||
Vector<char const*> cmd;
|
||||
bool enabled;
|
||||
bool default_action;
|
||||
|
|
|
@ -634,7 +634,7 @@ void Compositor::flip_buffers()
|
|||
|
||||
void Compositor::run_animations(Gfx::DisjointRectSet& flush_rects)
|
||||
{
|
||||
constexpr int minimize_animation_steps = 10;
|
||||
static const int minimize_animation_steps = 10;
|
||||
auto& painter = *m_back_painter;
|
||||
Gfx::PainterStateSaver saver(painter);
|
||||
painter.set_draw_op(Gfx::Painter::DrawOp::Invert);
|
||||
|
|
|
@ -55,7 +55,7 @@ const Gfx::Font& Menu::font() const
|
|||
return Gfx::FontDatabase::default_font();
|
||||
}
|
||||
|
||||
static constexpr char s_checked_bitmap_data[] = {
|
||||
static const char* s_checked_bitmap_data = {
|
||||
" "
|
||||
" # "
|
||||
" ## "
|
||||
|
@ -67,7 +67,7 @@ static constexpr char s_checked_bitmap_data[] = {
|
|||
" "
|
||||
};
|
||||
|
||||
static constexpr char s_submenu_arrow_bitmap_data[] = {
|
||||
static const char* s_submenu_arrow_bitmap_data = {
|
||||
" "
|
||||
" # "
|
||||
" ## "
|
||||
|
@ -80,12 +80,12 @@ static constexpr char s_submenu_arrow_bitmap_data[] = {
|
|||
};
|
||||
|
||||
static Gfx::CharacterBitmap* s_checked_bitmap;
|
||||
static constexpr int s_checked_bitmap_width = 9;
|
||||
static constexpr int s_checked_bitmap_height = 9;
|
||||
static constexpr int s_submenu_arrow_bitmap_width = 9;
|
||||
static constexpr int s_submenu_arrow_bitmap_height = 9;
|
||||
static constexpr int s_item_icon_width = 16;
|
||||
static constexpr int s_stripe_width = 24;
|
||||
static const int s_checked_bitmap_width = 9;
|
||||
static const int s_checked_bitmap_height = 9;
|
||||
static const int s_submenu_arrow_bitmap_width = 9;
|
||||
static const int s_submenu_arrow_bitmap_height = 9;
|
||||
static const int s_item_icon_width = 16;
|
||||
static const int s_stripe_width = 24;
|
||||
|
||||
int Menu::content_width() const
|
||||
{
|
||||
|
|
|
@ -59,7 +59,7 @@ WindowManager::~WindowManager()
|
|||
|
||||
NonnullRefPtr<Cursor> WindowManager::get_cursor(const String& name)
|
||||
{
|
||||
constexpr auto s_default_cursor_path = "/res/cursors/arrow.x2y2.png";
|
||||
static const auto s_default_cursor_path = "/res/cursors/arrow.x2y2.png";
|
||||
auto path = m_config->read_entry("Cursor", name, s_default_cursor_path);
|
||||
auto gb = Gfx::Bitmap::load_from_file(path, compositor_icon_scale());
|
||||
if (gb)
|
||||
|
|
|
@ -42,9 +42,9 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
static constexpr int m_days_in_week = 5;
|
||||
static constexpr int m_days_in_season = 73;
|
||||
static constexpr int m_st_tibs_day_of_yold = 60;
|
||||
static const int m_days_in_week = 5;
|
||||
static const int m_days_in_season = 73;
|
||||
static const int m_st_tibs_day_of_yold = 60;
|
||||
Core::DateTime m_gregorian_date;
|
||||
String m_day_of_week;
|
||||
String m_season;
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <AK/JsonArray.h>
|
||||
#include <AK/JsonObject.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibPCIDB/Database.h>
|
||||
|
@ -17,8 +16,8 @@
|
|||
|
||||
static bool flag_show_numerical = false;
|
||||
|
||||
static constexpr StringView format_numerical = "{:04x}:{:02x}:{:02x}.{} {}: {}:{} (rev {:02x})";
|
||||
static constexpr StringView format_textual = "{:04x}:{:02x}:{:02x}.{} {}: {} {} (rev {:02x})";
|
||||
static const char* format_numerical = "{:04x}:{:02x}:{:02x}.{} {}: {}:{} (rev {:02x})";
|
||||
static const char* format_textual = "{:04x}:{:02x}:{:02x}.{} {}: {} {} (rev {:02x})";
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
@ -44,7 +43,7 @@ int main(int argc, char** argv)
|
|||
args_parser.add_option(flag_show_numerical, "Show numerical IDs", "numerical", 'n');
|
||||
args_parser.parse(argc, argv);
|
||||
|
||||
const auto format = flag_show_numerical ? format_numerical : format_textual;
|
||||
const char* format = flag_show_numerical ? format_numerical : format_textual;
|
||||
|
||||
RefPtr<PCIDB::Database> db;
|
||||
if (!flag_show_numerical) {
|
||||
|
|
Loading…
Reference in a new issue