<feed xmlns='http://www.w3.org/2005/Atom'>
<title>puzzles/windows.c, branch rockbox</title>
<subtitle>My sgt-puzzles tree</subtitle>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/'/>
<entry>
<title>Replace fe-&gt;preset_menu when we change midend.</title>
<updated>2018-12-12T22:18:00+00:00</updated>
<author>
<name>Simon Tatham</name>
<email>anakin@pobox.com</email>
</author>
<published>2018-12-12T22:18:00+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=ced51ada363d895eee796dd03923042f97f95321'/>
<id>ced51ada363d895eee796dd03923042f97f95321</id>
<content type='text'>
Thanks to Rocco Matano for reporting that in the -DCOMBINED version of
the Windows front end, switching games causes a crash because the
presets menu from the old midend is still left over in fe, and its
presence inhibits the setup code from making a new one. Now we throw
it out at the same time as we throw out the old midend itself.

Also, the condition 'if (!fe-&gt;preset_menu)' was misguided. I think the
point of that was to avoid pointlessly tearing down and rebuilding the
preset menu when we're _not_ changing game - but that's a cost too
small to worry about if it causes the slightest trouble. Now
fe-&gt;preset_menu should always be NULL at that point in the function,
so I've replaced the if with an assert.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Thanks to Rocco Matano for reporting that in the -DCOMBINED version of
the Windows front end, switching games causes a crash because the
presets menu from the old midend is still left over in fe, and its
presence inhibits the setup code from making a new one. Now we throw
it out at the same time as we throw out the old midend itself.

Also, the condition 'if (!fe-&gt;preset_menu)' was misguided. I think the
point of that was to avoid pointlessly tearing down and rebuilding the
preset menu when we're _not_ changing game - but that's a cost too
small to worry about if it causes the slightest trouble. Now
fe-&gt;preset_menu should always be NULL at that point in the function,
so I've replaced the if with an assert.
</pre>
</div>
</content>
</entry>
<entry>
<title>Use C99 bool within source modules.</title>
<updated>2018-11-13T21:48:24+00:00</updated>
<author>
<name>Simon Tatham</name>
<email>anakin@pobox.com</email>
</author>
<published>2018-11-13T21:45:44+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=5f5b284c0bddbe67de14b2d2bfb596bc7ba1298a'/>
<id>5f5b284c0bddbe67de14b2d2bfb596bc7ba1298a</id>
<content type='text'>
This is the main bulk of this boolification work, but although it's
making the largest actual change, it should also be the least
disruptive to anyone interacting with this code base downstream of me,
because it doesn't modify any interface between modules: all the
inter-module APIs were updated one by one in the previous commits.
This just cleans up the code within each individual source file to use
bool in place of int where I think that makes things clearer.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This is the main bulk of this boolification work, but although it's
making the largest actual change, it should also be the least
disruptive to anyone interacting with this code base downstream of me,
because it doesn't modify any interface between modules: all the
inter-module APIs were updated one by one in the previous commits.
This just cleans up the code within each individual source file to use
bool in place of int where I think that makes things clearer.
</pre>
</div>
</content>
</entry>
<entry>
<title>Replace TRUE/FALSE with C99 true/false throughout.</title>
<updated>2018-11-13T21:48:24+00:00</updated>
<author>
<name>Simon Tatham</name>
<email>anakin@pobox.com</email>
</author>
<published>2018-11-13T21:44:02+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=a550ea0a47374705a37f36b0f05ffe9e4c8161fb'/>
<id>a550ea0a47374705a37f36b0f05ffe9e4c8161fb</id>
<content type='text'>
This commit removes the old #defines of TRUE and FALSE from puzzles.h,
and does a mechanical search-and-replace throughout the code to
replace them with the C99 standard lowercase spellings.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This commit removes the old #defines of TRUE and FALSE from puzzles.h,
and does a mechanical search-and-replace throughout the code to
replace them with the C99 standard lowercase spellings.
</pre>
</div>
</content>
</entry>
<entry>
<title>Adopt C99 bool in the printing API.</title>
<updated>2018-11-13T21:48:24+00:00</updated>
<author>
<name>Simon Tatham</name>
<email>anakin@pobox.com</email>
</author>
<published>2018-11-13T21:38:53+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=f6965b92e1915c9f49fafbadf603b4fd0da735bd'/>
<id>f6965b92e1915c9f49fafbadf603b4fd0da735bd</id>
<content type='text'>
Not many changes here: the 'dotted' flag passed to print_line_dotted
is bool, and so is the printing_in_colour flag passed to
print_get_colour. Also ps_init() takes a bool.

line_dotted is also a method in the drawing API structure, but it's
not actually filled in for any non-print-oriented implementation of
that API. So only front ends that do platform-specific _printing_
should need to make a corresponding change. In-tree, for example,
windows.c needed a fix because it prints via Windows GDI, but gtk.c
didn't have to do anything, because its CLI-based printing facility
just delegates to ps.c.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Not many changes here: the 'dotted' flag passed to print_line_dotted
is bool, and so is the printing_in_colour flag passed to
print_get_colour. Also ps_init() takes a bool.

line_dotted is also a method in the drawing API structure, but it's
not actually filled in for any non-print-oriented implementation of
that API. So only front ends that do platform-specific _printing_
should need to make a corresponding change. In-tree, for example,
windows.c needed a fix because it prints via Windows GDI, but gtk.c
didn't have to do anything, because its CLI-based printing facility
just delegates to ps.c.
</pre>
</div>
</content>
</entry>
<entry>
<title>Adopt C99 bool in the midend API.</title>
<updated>2018-11-13T21:46:39+00:00</updated>
<author>
<name>Simon Tatham</name>
<email>anakin@pobox.com</email>
</author>
<published>2018-11-13T21:37:09+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=cd6cadbecf245b2916350939343db14e2978f782'/>
<id>cd6cadbecf245b2916350939343db14e2978f782</id>
<content type='text'>
This changes parameters of midend_size and midend_print_puzzle, the
return types of midend_process_key, midend_wants_statusbar,
midend_can_format_as_text_now and midend_can_{undo,redo}, the 'bval'
field in struct config_item, and finally the return type of the
function pointer passed to midend_deserialise and identify_game.

The last of those changes requires a corresponding fix in clients of
midend_deserialise and identify_game, so in this commit I've also
updated all the in-tree front ends to match. I expect downstream front
ends will need to do the same when they merge this change.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This changes parameters of midend_size and midend_print_puzzle, the
return types of midend_process_key, midend_wants_statusbar,
midend_can_format_as_text_now and midend_can_{undo,redo}, the 'bval'
field in struct config_item, and finally the return type of the
function pointer passed to midend_deserialise and identify_game.

The last of those changes requires a corresponding fix in clients of
midend_deserialise and identify_game, so in this commit I've also
updated all the in-tree front ends to match. I expect downstream front
ends will need to do the same when they merge this change.
</pre>
</div>
</content>
</entry>
<entry>
<title>Make the code base clean under -Wwrite-strings.</title>
<updated>2017-10-01T15:35:40+00:00</updated>
<author>
<name>Simon Tatham</name>
<email>anakin@pobox.com</email>
</author>
<published>2017-10-01T13:45:12+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=a58c1b216bb1d4547f7b2ef2703fe2d0cd3b5cac'/>
<id>a58c1b216bb1d4547f7b2ef2703fe2d0cd3b5cac</id>
<content type='text'>
I've also added that warning option and -Werror to the build script,
so that I'll find out if I break this property in future.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
I've also added that warning option and -Werror to the build script,
so that I'll find out if I break this property in future.
</pre>
</div>
</content>
</entry>
<entry>
<title>Assorted char * -&gt; const char * API changes.</title>
<updated>2017-10-01T15:35:00+00:00</updated>
<author>
<name>Simon Tatham</name>
<email>anakin@pobox.com</email>
</author>
<published>2017-10-01T13:04:47+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=3276376d1be74b66970b88c3e941dcedf8d22474'/>
<id>3276376d1be74b66970b88c3e941dcedf8d22474</id>
<content type='text'>
I went through all the char * parameters and return values I could see
in puzzles.h by eye and spotted ones that surely ought to have been
const all along.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
I went through all the char * parameters and return values I could see
in puzzles.h by eye and spotted ones that surely ought to have been
const all along.
</pre>
</div>
</content>
</entry>
<entry>
<title>Return error messages as 'const char *', not 'char *'.</title>
<updated>2017-10-01T15:34:41+00:00</updated>
<author>
<name>Simon Tatham</name>
<email>anakin@pobox.com</email>
</author>
<published>2017-10-01T12:53:24+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=b3243d75043cf1d70beb88d2a36eaebfe85c2c3f'/>
<id>b3243d75043cf1d70beb88d2a36eaebfe85c2c3f</id>
<content type='text'>
They're never dynamically allocated, and are almost always string
literals, so const is more appropriate.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
They're never dynamically allocated, and are almost always string
literals, so const is more appropriate.
</pre>
</div>
</content>
</entry>
<entry>
<title>Use a proper union in struct config_item.</title>
<updated>2017-10-01T15:34:41+00:00</updated>
<author>
<name>Simon Tatham</name>
<email>anakin@pobox.com</email>
</author>
<published>2017-10-01T12:38:35+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=de67801b0fd3dfa11777c1ef86cd617baf376b7b'/>
<id>de67801b0fd3dfa11777c1ef86cd617baf376b7b</id>
<content type='text'>
This allows me to use different types for the mutable, dynamically
allocated string value in a C_STRING control and the fixed constant
list of option names in a C_CHOICES.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This allows me to use different types for the mutable, dynamically
allocated string value in a C_STRING control and the fixed constant
list of option names in a C_CHOICES.
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix an int-&gt;pointer cast warning in windows.c.</title>
<updated>2017-10-01T14:18:14+00:00</updated>
<author>
<name>Simon Tatham</name>
<email>anakin@pobox.com</email>
</author>
<published>2017-10-01T13:50:58+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=edcf839d4c557c3993d681665829390697353344'/>
<id>edcf839d4c557c3993d681665829390697353344</id>
<content type='text'>
If I increase clang-cl's warning pickiness, it starts objecting to my
cast to HMENU from a (potentially, in 64 bits) smaller integer type.

Actually I don't think there's a problem there - all the integer ids I
cast to HMENU are nice small numbers and a widening cast is just fine.
But I can suppress the warning by using INT_PTR instead of int in the
prototype for mkctrl, so it's easiest just to do that.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If I increase clang-cl's warning pickiness, it starts objecting to my
cast to HMENU from a (potentially, in 64 bits) smaller integer type.

Actually I don't think there's a problem there - all the integer ids I
cast to HMENU are nice small numbers and a widening cast is just fine.
But I can suppress the warning by using INT_PTR instead of int in the
prototype for mkctrl, so it's easiest just to do that.
</pre>
</div>
</content>
</entry>
</feed>
