Skip to content

Commit 1730335

Browse files
livecodefraserlivecodeali
authored andcommitted
Constify a large number of in-engine data tables
1 parent de24422 commit 1730335

26 files changed

+324
-410
lines changed

engine/src/aclip.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ uint4 MCAudioClip::curindex;
5959
Boolean MCAudioClip::looping;
6060
real8 MCAudioClip::endtime;
6161

62-
static int2 ulaw_table[256] = {
62+
static const int2 ulaw_table[256] = {
6363
-32124, -31100, -30076, -29052, -28028, -27004, -25980, -24956,
6464
-23932, -22908, -21884, -20860, -19836, -18812, -17788, -16764,
6565
-15996, -15484, -14972, -14460, -13948, -13436, -12924, -12412,

engine/src/button.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ uint2 MCButton::focusedtab = MAXUINT2;
6868

6969
bool MCmenupoppedup = false;
7070

71-
Keynames MCButton::button_keys[] =
71+
const Keynames MCButton::button_keys[] =
7272
{
7373
{XK_F1, "f1"},
7474
{XK_F2, "f2"},

engine/src/button.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class MCButton : public MCControl, public MCMixinObjectHandle<MCButton>
147147
static uint2 focusedtab;
148148
static uint2 mnemonicoffset;
149149
static MCRectangle optionrect;
150-
static Keynames button_keys[];
150+
static const Keynames button_keys[];
151151
static uint4 clicktime;
152152
static uint2 menubuttonheight;
153153
static Boolean starthilite;

engine/src/combiners.cpp

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,81 +1388,3 @@ surface_combiner_t s_surface_combiners_nda[] =
13881388
surface_combine<OPERATION_BLEND_DIFFERENCE, false, true>,
13891389
surface_combine<OPERATION_BLEND_EXCLUSION, false, true>,
13901390
};
1391-
1392-
uint16_t g_sqrt_table[1024] =
1393-
{
1394-
0,
1395-
2048,2896,3547,4096,4579,5017,5418,5793,6144,6476,6792,7094,7384,7663,7932,8192,8444,
1396-
8689,8927,9159,9385,9606,9822,10033,10240,10443,10642,10837,11029,11217,11403,11585,
1397-
11765,11942,12116,12288,12457,12625,12790,12953,13114,13273,13430,13585,13738,13890,
1398-
14040,14189,14336,14482,14626,14768,14910,15050,15188,15326,15462,15597,15731,15864,
1399-
15995,16126,16255,16384,16512,16638,16764,16888,17012,17135,17257,17378,17498,17618,
1400-
17736,17854,17971,18087,18203,18318,18432,18545,18658,18770,18882,18992,19102,19212,
1401-
19321,19429,19537,19644,19750,19856,19961,20066,20170,20274,20377,20480,20582,20684,
1402-
20785,20886,20986,21085,21185,21283,21382,21480,21577,21674,21771,21867,21962,22058,
1403-
22153,22247,22341,22435,22528,22621,22713,22806,22897,22989,23080,23170,23261,23351,
1404-
23440,23530,23619,23707,23796,23884,23971,24059,24146,24232,24319,24405,24491,24576,
1405-
24661,24746,24831,24915,24999,25083,25166,25249,25332,25415,25497,25580,25661,25743,
1406-
25824,25905,25986,26067,26147,26227,26307,26387,26466,26545,26624,26703,26781,26859,
1407-
26937,27015,27092,27170,27247,27324,27400,27477,27553,27629,27705,27780,27856,27931,
1408-
28006,28081,28155,28230,28304,28378,28452,28525,28599,28672,28745,28818,28891,28963,
1409-
29035,29108,29180,29251,29323,29394,29466,29537,29608,29678,29749,29819,29890,29960,
1410-
30030,30099,30169,30238,30308,30377,30446,30515,30583,30652,30720,30788,30856,30924,
1411-
30992,31059,31127,31194,31261,31328,31395,31462,31529,31595,31661,31727,31794,31859,
1412-
31925,31991,32056,32122,32187,32252,32317,32382,32446,32511,32575,32640,32704,32768,
1413-
32832,32896,32959,33023,33086,33150,33213,33276,33339,33402,33465,33527,33590,33652,
1414-
33714,33776,33839,33900,33962,34024,34086,34147,34208,34270,34331,34392,34453,34514,
1415-
34574,34635,34695,34756,34816,34876,34936,34996,35056,35116,35176,35235,35295,35354,
1416-
35413,35472,35531,35590,35649,35708,35767,35825,35884,35942,36001,36059,36117,36175,
1417-
36233,36291,36348,36406,36464,36521,36578,36636,36693,36750,36807,36864,36921,36978,
1418-
37034,37091,37147,37204,37260,37316,37372,37429,37485,37540,37596,37652,37708,37763,
1419-
37819,37874,37929,37985,38040,38095,38150,38205,38260,38315,38369,38424,38478,38533,
1420-
38587,38642,38696,38750,38804,38858,38912,38966,39020,39073,39127,39181,39234,39287,
1421-
39341,39394,39447,39500,39553,39606,39659,39712,39765,39818,39870,39923,39975,40028,
1422-
40080,40132,40185,40237,40289,40341,40393,40445,40497,40548,40600,40652,40703,40755,
1423-
40806,40857,40909,40960,41011,41062,41113,41164,41215,41266,41317,41368,41418,41469,
1424-
41519,41570,41620,41671,41721,41771,41821,41871,41922,41972,42021,42071,42121,42171,
1425-
42221,42270,42320,42369,42419,42468,42518,42567,42616,42665,42714,42763,42813,42861,
1426-
42910,42959,43008,43057,43105,43154,43203,43251,43300,43348,43396,43445,43493,43541,
1427-
43589,43637,43685,43733,43781,43829,43877,43925,43972,44020,44068,44115,44163,44210,
1428-
44258,44305,44352,44400,44447,44494,44541,44588,44635,44682,44729,44776,44823,44869,
1429-
44916,44963,45009,45056,45103,45149,45195,45242,45288,45334,45381,45427,45473,45519,
1430-
45565,45611,45657,45703,45749,45795,45840,45886,45932,45977,46023,46069,46114,46160,
1431-
46205,46250,46296,46341,46386,46431,46477,46522,46567,46612,46657,46702,46746,46791,
1432-
46836,46881,46926,46970,47015,47059,47104,47149,47193,47237,47282,47326,47370,47415,
1433-
47459,47503,47547,47591,47635,47679,47723,47767,47811,47855,47899,47942,47986,48030,
1434-
48074,48117,48161,48204,48248,48291,48335,48378,48421,48465,48508,48551,48594,48637,
1435-
48680,48723,48766,48809,48852,48895,48938,48981,49024,49067,49109,49152,49195,49237,
1436-
49280,49322,49365,49407,49450,49492,49535,49577,49619,49661,49704,49746,49788,49830,
1437-
49872,49914,49956,49998,50040,50082,50124,50166,50207,50249,50291,50332,50374,50416,
1438-
50457,50499,50540,50582,50623,50665,50706,50747,50789,50830,50871,50912,50954,50995,
1439-
51036,51077,51118,51159,51200,51241,51282,51323,51364,51404,51445,51486,51527,51567,
1440-
51608,51649,51689,51730,51770,51811,51851,51892,51932,51972,52013,52053,52093,52134,
1441-
52174,52214,52254,52294,52334,52374,52414,52454,52494,52534,52574,52614,52654,52694,
1442-
52734,52773,52813,52853,52892,52932,52972,53011,53051,53090,53130,53169,53209,53248,
1443-
53287,53327,53366,53405,53445,53484,53523,53562,53601,53640,53679,53719,53758,53797,
1444-
53836,53874,53913,53952,53991,54030,54069,54108,54146,54185,54224,54262,54301,54340,
1445-
54378,54417,54455,54494,54532,54571,54609,54647,54686,54724,54762,54801,54839,54877,
1446-
54915,54954,54992,55030,55068,55106,55144,55182,55220,55258,55296,55334,55372,55410,
1447-
55447,55485,55523,55561,55599,55636,55674,55712,55749,55787,55824,55862,55900,55937,
1448-
55975,56012,56049,56087,56124,56162,56199,56236,56273,56311,56348,56385,56422,56459,
1449-
56497,56534,56571,56608,56645,56682,56719,56756,56793,56830,56867,56903,56940,56977,
1450-
57014,57051,57087,57124,57161,57198,57234,57271,57307,57344,57381,57417,57454,57490,
1451-
57527,57563,57599,57636,57672,57709,57745,57781,57817,57854,57890,57926,57962,57999,
1452-
58035,58071,58107,58143,58179,58215,58251,58287,58323,58359,58395,58431,58467,58503,
1453-
58538,58574,58610,58646,58682,58717,58753,58789,58824,58860,58896,58931,58967,59002,
1454-
59038,59073,59109,59144,59180,59215,59251,59286,59321,59357,59392,59427,59463,59498,
1455-
59533,59568,59603,59639,59674,59709,59744,59779,59814,59849,59884,59919,59954,59989,
1456-
60024,60059,60094,60129,60164,60199,60233,60268,60303,60338,60373,60407,60442,60477,
1457-
60511,60546,60581,60615,60650,60684,60719,60753,60788,60822,60857,60891,60926,60960,
1458-
60995,61029,61063,61098,61132,61166,61201,61235,61269,61303,61338,61372,61406,61440,
1459-
61474,61508,61542,61576,61610,61644,61678,61712,61746,61780,61814,61848,61882,61916,
1460-
61950,61984,62018,62051,62085,62119,62153,62186,62220,62254,62287,62321,62355,62388,
1461-
62422,62456,62489,62523,62556,62590,62623,62657,62690,62724,62757,62790,62824,62857,
1462-
62891,62924,62957,62991,63024,63057,63090,63124,63157,63190,63223,63256,63289,63323,
1463-
63356,63389,63422,63455,63488,63521,63554,63587,63620,63653,63686,63719,63752,63785,
1464-
63817,63850,63883,63916,63949,63982,64014,64047,64080,64113,64145,64178,64211,64243,
1465-
64276,64309,64341,64374,64406,64439,64471,64504,64536,64569,64601,64634,64666,64699,
1466-
64731,64763,64796,64828,64861,64893,64925,64957,64990,65022,65054,65086,65119,65151,
1467-
65183,65215,65247,65279,65312,65344,65376,65408,65440,65472,65504
1468-
};

engine/src/exec-filters.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ bool MCFiltersMacToIso(MCDataRef p_source, MCDataRef &r_result)
9191

9292
////////////////////////////////////////////////////////////////////////////////
9393

94-
static const char *url_table[256] =
94+
static const char * const url_table[256] =
9595
{
9696
"%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07", "%08", "%09",
9797
"%0D%0A", "%0B", "%0C", "%0D", "%0E", "%0F", "%10", "%11", "%12",

engine/src/exec-interface-object.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ typedef struct _PropList
6161
}
6262
PropList;
6363

64-
static PropList stackprops[] =
64+
static const PropList stackprops[] =
6565
{
6666
{"altId", P_ALT_ID},
6767
{"alwaysBuffer", P_ALWAYS_BUFFER},
@@ -131,7 +131,7 @@ static PropList stackprops[] =
131131
{"windowShape", P_WINDOW_SHAPE}
132132
};
133133

134-
static PropList cardprops[] =
134+
static const PropList cardprops[] =
135135
{
136136
{"altId", P_ALT_ID},
137137
{"backColor", P_BACK_COLOR},
@@ -169,7 +169,7 @@ static PropList cardprops[] =
169169
{"topPattern", P_TOP_PATTERN}
170170
};
171171

172-
static PropList groupprops[] =
172+
static const PropList groupprops[] =
173173
{
174174
{"altId", P_ALT_ID},
175175
{"backColor", P_BACK_COLOR},
@@ -239,7 +239,7 @@ static PropList groupprops[] =
239239
{"vScrollbar", P_VSCROLLBAR}
240240
};
241241

242-
static PropList buttonprops[] =
242+
static const PropList buttonprops[] =
243243
{
244244
{"accelKey", P_ACCELERATOR_KEY},
245245
{"accelMods", P_ACCELERATOR_MODIFIERS},
@@ -327,7 +327,7 @@ static PropList buttonprops[] =
327327
{"visitedIcon", P_VISITED_ICON}
328328
};
329329

330-
static PropList fieldprops[] =
330+
static const PropList fieldprops[] =
331331
{
332332
{"altId", P_ALT_ID},
333333
{"autoHilite", P_AUTO_HILITE},
@@ -407,7 +407,7 @@ static PropList fieldprops[] =
407407
{"vScrollbar", P_VSCROLLBAR}
408408
};
409409

410-
static PropList imageprops[] =
410+
static const PropList imageprops[] =
411411
{
412412
{"altId", P_ALT_ID},
413413
{"angle", P_ANGLE},
@@ -468,7 +468,7 @@ static PropList imageprops[] =
468468
{"yHot", P_YHOT}
469469
};
470470

471-
static PropList graphicprops[] =
471+
static const PropList graphicprops[] =
472472
{
473473
{"altId", P_ALT_ID},
474474
{"angle", P_ANGLE},
@@ -547,7 +547,7 @@ static PropList graphicprops[] =
547547
{"miterLimit", P_MITER_LIMIT},
548548
};
549549

550-
static PropList scrollbarprops[] =
550+
static const PropList scrollbarprops[] =
551551
{
552552
{"altId", P_ALT_ID},
553553
{"backColor", P_BACK_COLOR},
@@ -605,7 +605,7 @@ static PropList scrollbarprops[] =
605605
{"thumbSize", P_THUMB_SIZE}
606606
};
607607

608-
static PropList playerprops[] =
608+
static const PropList playerprops[] =
609609
{
610610
{"altId", P_ALT_ID},
611611
{"alwaysBuffer", P_ALWAYS_BUFFER},
@@ -666,7 +666,7 @@ static PropList playerprops[] =
666666
{"visible", P_VISIBLE},
667667
};
668668

669-
static PropList epsprops[] =
669+
static const PropList epsprops[] =
670670
{
671671
{"altId", P_ALT_ID},
672672
{"backColor", P_BACK_COLOR},
@@ -721,23 +721,23 @@ static PropList epsprops[] =
721721
{"yScale", P_Y_SCALE}
722722
};
723723

724-
static PropList colorpaletteprops[] =
724+
static const PropList colorpaletteprops[] =
725725
{
726726
{"name", P_SHORT_NAME},
727727
{"id", P_ID},
728728
{"selectedColor", P_SELECTED_COLOR},
729729
{"rect", P_RECTANGLE}
730730
};
731731

732-
static PropList audioclipprops[] =
732+
static const PropList audioclipprops[] =
733733
{
734734
{"altID", P_ALT_ID},
735735
{"id", P_ID},
736736
{"name", P_NAME},
737737
{"playLoudness", P_PLAY_LOUDNESS},
738738
};
739739

740-
static PropList videoclipprops[] =
740+
static const PropList videoclipprops[] =
741741
{
742742
{"altID", P_ALT_ID},
743743
{"dontRefresh", P_DONT_REFRESH},
@@ -3294,7 +3294,7 @@ void MCObject::GetLongOwner(MCExecContext& ctxt, uint32_t p_part_id, MCStringRef
32943294

32953295
void MCObject::DoGetProperties(MCExecContext& ctxt, uint32_t part, bool p_effective, MCArrayRef& r_props)
32963296
{
3297-
PropList *table;
3297+
const PropList *table;
32983298
uint2 tablesize;
32993299

33003300
switch (gettype())

engine/src/exec-legacy.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ typedef struct
304304
}
305305
DT;
306306

307-
static DT domenu_table[] = {
307+
static const DT domenu_table[] = {
308308
{"new stack...", "create stack\n\
309309
set the mainStack of the topStack to \"Home\"\n\
310310
modal \"Stack Properties\""},

engine/src/field.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,8 @@ class MCField : public MCControl, public MCMixinObjectHandle<MCField>
258258
static Boolean contiguous;
259259
static int2 narrowmargin;
260260
static int2 widemargin;
261-
static Keytranslations emacs_keys[];
262-
static Keytranslations std_keys[];
261+
static const Keytranslations emacs_keys[];
262+
static const Keytranslations std_keys[];
263263
static MCRectangle linkrect;
264264
static MCBlock *linkstart;
265265
static MCBlock *linkend;
@@ -342,7 +342,7 @@ class MCField : public MCControl, public MCMixinObjectHandle<MCField>
342342
virtual void unlink(MCControl *p_control);
343343

344344
// MCField functions in fieldf.cc
345-
static Field_translations trans_lookup(Keytranslations table[], KeySym key, uint2 modifiers);
345+
static Field_translations trans_lookup(const Keytranslations table[], KeySym key, uint2 modifiers);
346346
static Field_translations lookup_mac_keybinding(KeySym key, uint32_t modifiers);
347347

348348
void do_recompute(bool p_force_layout);

engine/src/fieldf.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
4545

4646
#ifndef _MACOSX
4747
//normal, control, alt, alt-control
48-
Keytranslations MCField::emacs_keys[] =
48+
const Keytranslations MCField::emacs_keys[] =
4949
{
5050
{XK_Home, {FT_HOME, FT_FOCUSFIRST, FT_HOME, FT_FOCUSFIRST}},
5151
{XK_Left, {FT_LEFTCHAR, FT_LEFTWORD, FT_LEFTCHAR, FT_FOCUSPREV}},
@@ -107,7 +107,7 @@ Keytranslations MCField::emacs_keys[] =
107107
{0x0000, {FT_UNDEFINED, FT_UNDEFINED, FT_UNDEFINED, FT_UNDEFINED}},
108108
};
109109

110-
Keytranslations MCField::std_keys[] =
110+
const Keytranslations MCField::std_keys[] =
111111
{
112112
{XK_Home, {FT_BOL, FT_BOF, FT_BOF, FT_FOCUSFIRST}},
113113
{XK_Left, {FT_LEFTCHAR, FT_LEFTWORD, FT_LEFTCHAR, FT_FOCUSPREV}},
@@ -152,7 +152,7 @@ Keytranslations MCField::std_keys[] =
152152
{0x0000, {FT_UNDEFINED, FT_UNDEFINED, FT_UNDEFINED, FT_UNDEFINED}},
153153
};
154154

155-
Field_translations MCField::trans_lookup(Keytranslations table[], KeySym key,
155+
Field_translations MCField::trans_lookup(const Keytranslations table[], KeySym key,
156156
uint2 modifiers)
157157
{
158158
uint2 i = 0;

engine/src/fieldhtml.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ struct export_html_t
105105

106106
////////////////////////////////////////////////////////////////////////////////
107107

108-
static const char *s_export_html_tag_strings[] =
108+
static const char * const s_export_html_tag_strings[] =
109109
{
110110
"a",
111111
"span",
@@ -122,7 +122,7 @@ static const char *s_export_html_tag_strings[] =
122122
"font"
123123
};
124124

125-
static const char *s_export_html_list_types[] =
125+
static const char * const s_export_html_list_types[] =
126126
{
127127
"",
128128
"disc",
@@ -138,7 +138,7 @@ static const char *s_export_html_list_types[] =
138138

139139
// This is the list of HTML entities for ISO8859-1 (unicode) codepoints in the range
140140
// 0x00A0 to 0x00FF inclusive.
141-
static const char *s_export_html_native_entities[] =
141+
static const char * const s_export_html_native_entities[] =
142142
{
143143
"nbsp", "iexcl", "cent", "pound", "curren", "yen", "brvbar", "sect",
144144
"uml", "copy", "ordf", "laquo", "not", "shy", "reg", "macr",
@@ -154,7 +154,7 @@ static const char *s_export_html_native_entities[] =
154154
"oslash", "ugrave", "uacute", "ucirc", "uuml", "yacute", "thorn", "yuml",
155155
};
156156

157-
static struct { const char *entity; uint32_t codepoint; } s_export_html_unicode_entities[] =
157+
static const struct { const char *entity; uint32_t codepoint; } s_export_html_unicode_entities[] =
158158
{
159159
{ "OElig", 0x0152 }, { "oelig", 0x0153 }, { "Scaron", 0x0160 },
160160
{ "scaron", 0x0161 }, { "Yuml", 0x0178 }, { "fnof", 0x0192 }, { "circ", 0x02C6 },
@@ -902,7 +902,7 @@ static struct { const char *attr; import_html_attr_type_t type; } s_import_html_
902902
{ "start", kImportHtmlAttrStart },
903903
};
904904

905-
static struct { const char *entity; uint32_t codepoint; } s_import_html_entities[] =
905+
static const struct { const char *entity; uint32_t codepoint; } s_import_html_entities[] =
906906
{
907907
{ "AElig", 0x00C6 }, { "Aacute", 0x00C1 }, { "Acirc", 0x00C2 }, { "Agrave", 0x00C0 },
908908
{ "Alpha", 0x0391 }, { "Aring", 0x00C5 }, { "Atilde", 0x00C3 }, { "Auml", 0x00C4 },

0 commit comments

Comments
 (0)