<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Mardy (Articoli su informatica)</title><link>http://mardy.it/</link><description></description><atom:link href="http://mardy.it/it/categories/informatica.xml" rel="self" type="application/rss+xml"></atom:link><language>it</language><copyright>Contents © 2026 &lt;a href="mailto:info@mardy.it"&gt;Alberto Mardegan&lt;/a&gt; </copyright><lastBuildDate>Sat, 11 Apr 2026 13:54:07 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Teaser: connecting Nintendo Switch controllers to the Wii</title><link>http://mardy.it/it/blog/2026/04/teaser-connecting-nintendo-switch-controllers-to-the-wii.html</link><dc:creator>Alberto Mardegan</dc:creator><description>&lt;p&gt;A few months ago I started playing with the Bluetooth controller embedded in
the Nintendo Wii, to see if it was possible to get it to connect to other
devices than just the Wii remotes. If you ask internet forums, you might fall
into the impression that the Wii is not using a standard Bluetooth controller,
or that it has been somehow "crippled" in order to restrict it to connect to
the Wiimotes only, but that's not the case: it's an ordinary controller from
its era, it's just that the Wii software (both the official SDK and the
homebrew libogc) only uses it for the Wiimotes.&lt;/p&gt;
&lt;p&gt;I first started looking into
&lt;a href="https://github.com/devkitPro/libogc/tree/master/lwbt"&gt;&lt;code&gt;lwBT&lt;/code&gt;&lt;/a&gt;, the bluetooth
stack used in libogc, but I quickly realized that it was impossible to get full
control over the controller via this library: it has been adapted to work with
the subset of the HID protocol used by the Wiimotes, and even if you can issue
bluetooth commands to the controller via the HCI layer, you cannot receive the
replies, since they are already intercepted by lwBT and there's no way to hook
into them.&lt;/p&gt;
&lt;p&gt;So I started writing my own little bluetooth stack,
&lt;a href="https://github.com/embedded-game-controller/bt-embedded"&gt;&lt;code&gt;bt-embedded&lt;/code&gt;&lt;/a&gt; which
from the ground up has been designed to be used by embedded devices and
covering the use case of serving different clients running in a single process,
and I've integrated it into
&lt;a href="https://github.com/embedded-game-controller/embedded-game-controller"&gt;&lt;code&gt;embedded-game-controller&lt;/code&gt;&lt;/a&gt;
(though this is not merged into the &lt;code&gt;master&lt;/code&gt; branch yet) in order to allow
connecting to bluetooth controllers. And in the last couple of days I've
written a little ugly program to visualize the controllers in a 3D scene, in
order to better test them:&lt;/p&gt;
&lt;iframe src="https://vkvideo.ru/video_ext.php?oid=-230221529&amp;amp;id=456239018&amp;amp;hash=7f8047b16af7164f&amp;amp;hd=1" width="640" height="360" allow="autoplay; encrypted-media; fullscreen; picture-in-picture; screen-wake-lock;" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;

&lt;p&gt;Yes, the 3D model sucks, it was a nice model when I downloaded it from a free
site, but then heavily reduced the number of polygons using Blender and went a
bit too far; I'll do a better model later. The accelerometer information is not
shown yet (I'd like to use it to actually tilt the controller, instead of using
the joystick), but that will not be hard.&lt;/p&gt;
&lt;p&gt;At the moment, the only supported controllers are the Nintendo Switch Pro
controller (I'm using a clone here) and the Joy-cons, so there's still quite
some work to do to add more.&lt;/p&gt;
&lt;p&gt;It's been a journey in which I learned a lot about Bluetooth and USB and, who
knows, maybe this will come handy in the future too.&lt;/p&gt;</description><guid>http://mardy.it/it/blog/2026/04/teaser-connecting-nintendo-switch-controllers-to-the-wii.html</guid><pubDate>Sat, 11 Apr 2026 13:13:06 GMT</pubDate></item><item><title>Choreograph is still alive</title><link>http://mardy.it/it/blog/2025/09/choreograph-is-still-alive.html</link><dc:creator>Alberto Mardegan</dc:creator><description>&lt;p&gt;Back in 2023 I started writing a game -- which is still under development as
I'm dedicating very little time to it -- and at a certain point I found myself
in need of animating the movement of a few rectangles on the screen. Having
decided to code the game in C++ and to use just libSDL as a base (in order to
keep the game as portable as possible), I started looking around for existing
solutions which would do just what I need: animating points between two values,
while being display and platform agnostic.&lt;/p&gt;
&lt;h3&gt;Choreograph&lt;/h3&gt;
&lt;p&gt;I was happy to find the &lt;a href="https://github.com/sansumbrella/Choreograph"&gt;Choreograph
library&lt;/a&gt;, which promised to do
exactly what I needed, without bringing in any more dependencies. Integrating
it in my project proved to be extremely easy, and it took me a few minutes to
implement the animation.&lt;/p&gt;
&lt;p&gt;All was perfect, except one thing: the last commit to the repository happened
in 2016. I submitted a couple of minor fixes, and there was no reaction. Even
though I was very happy with the library, I decided not to get tied to a
project that was apparently dead, so I dropped this integration and instead
wrote my own implementation -- which was just enough to fill my immediate need,
but was unlikely to be reusable as a generic animation framework.&lt;/p&gt;
&lt;p&gt;Over time, though, several times I happened to bump into a situation where I
would have liked to add some animation, but given that I was not really happy
with my home-brew solution, I always held myself back from this desire and
focused on more substantial issues: so, no animations. In March this year I
decided to write to the author of Choreograph to check whether he was still
interested in maintaining the project, but got no answer.&lt;/p&gt;
&lt;h3&gt;A maintained fork&lt;/h3&gt;
&lt;p&gt;Well, one cannot certainly accuse me of being impatient in this case, since I
waited a few more months before finally deciding that I find Choreograph to be
too convenient to let it just rot. Here is my &lt;a href="https://github.com/mardy/Choreograph"&gt;&lt;em&gt;maintained&lt;/em&gt; (for how long,
we'll see!) fork of the Choreograph
project&lt;/a&gt;; so far I've added:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A few commits to fix compilation warnings&lt;/li&gt;
&lt;li&gt;Recipes for the &lt;a href="https://mesonbuild.com/"&gt;Meson build system&lt;/a&gt;, to make it
  easier to build the project in Linux&lt;/li&gt;
&lt;li&gt;CI via GitHub actions&lt;/li&gt;
&lt;li&gt;Updated the tests and the samples to build without libCinder&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I'm not yet able to announce what I'm going to work on next in Choreograph;
this will become clear as I'll be using it more. For the time being, it's
enough for you to know that such a project exists, and I'll be happy to accept
contributions in the form of code and ideas.&lt;/p&gt;</description><guid>http://mardy.it/it/blog/2025/09/choreograph-is-still-alive.html</guid><pubDate>Fri, 26 Sep 2025 15:42:31 GMT</pubDate></item><item><title>No, libogc did not steal RTEMS code</title><link>http://mardy.it/it/blog/2025/04/no-libogc-did-not-steal-rtems-code.html</link><dc:creator>Alberto Mardegan</dc:creator><description>&lt;p&gt;&lt;em&gt;Update 09/05/2025:&lt;/em&gt; while the text below addresses a couple of specific blocks of code,
after publishing this article I've been contacted by some people providing more
evidence pointing that the similarity of the code goes beyond what one might
interpret as “inspiration”. There are also a couple of other bits on
information that the reader might want to take into account: first, a
&lt;a href="https://mas.to/@davejmurphy/114414723608693881"&gt;screenshot of an email&lt;/a&gt; in
which Shagkur tells his version of how the code came about (which seems to
point that, if a copyright infringement actually happened, this was done
without the knowledge of devkitPro's maintainers) and a &lt;a href="https://www.rtems.org/news/2025-05-06-rtems-devkit-libogc-response/"&gt;public statement by
RTEMS&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;All of a sudden the Wii homebrew community is in flames after Hector Martin
(&lt;a href="https://github.com/marcan"&gt;marcan&lt;/a&gt;, also known in the Linux Kernel
 community), co-author of “The Homebrew Channel” application, &lt;a href="https://github.com/fail0verflow/hbc"&gt;decided to close
the project&lt;/a&gt; and denounce libogc for its
“theft” of RTEMS's code:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;It has recently been revealed that the threading/OS implementation in libogc is, in fact, stolen from RTEMS. The authors of libogc didn't just steal proprietary Nintendo code, but also saw it fit to steal an open source RTOS and remove all attribution and copyright information. This goes far beyond ignorance about the copyright implications of reverse engineering Nintendo binaries, and goes straight into outright deliberate, malicious code theft and copyright infringement.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;A little below, Hector Martin provides this “proof”: &lt;em&gt;you can compare
&lt;a href="https://github.com/devkitPro/libogc/blob/52c525a13fd1762c10395c78875e3260f94368b5/libogc/lwp_threads.c#L580"&gt;this&lt;/a&gt;
function in libogc to
&lt;a href="https://github.com/atgreen/RTEMS/blob/2f200c7e642c214accb7cc6bd7f0f1784deec833/c/src/exec/score/src/thread.c#L385"&gt;this&lt;/a&gt;
function in a really old version of RTEMS&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;While I don't know the truth about libogc's history (I've started contributing
to it only in the last couple of years), and I'd welcome a first-hand
explanation from shagkur (Michael Wiedenbauer), I can confidently say that the
accusation is unfounded, by just looking at the code. To be more precise: I
cannot vouch for the whole of libogc, I can only say that this function, that
Hector Martin offers as example, actually hints that the code was not stolen.&lt;/p&gt;
&lt;p&gt;While it's obvious that the developer of libogc's code did have a look at
RTEMS's code, and this can be assumed because the variable names are very
similar (and in some cases they are so badly named, that they cannot be this
similar by accident!), the code only looks vaguely similar. Furthermore, for
some reason Hector Martin decided to pick a rather recent version of libogc's
code, but if we look at the &lt;a href="https://github.com/devkitPro/libogc/blob/e550333e6f2fc413fd42d6af9a9aaf036d9de9f6/libogc/lwp_threads.c#L469"&gt;first version that was
committed&lt;/a&gt;
(well, to git, at least), we see that similarities are much less striking.
Let's look at a small snippet of the function, where the thread object's
members are being initialized:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;RTEMS from 1996:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;the_thread&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;Start&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;is_preemptible&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;is_preemptible&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;the_thread&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;Start&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;is_timeslice&lt;/span&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;is_timeslice&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;the_thread&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;Start&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isr_level&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;isr_level&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;the_thread&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;current_state&lt;/span&gt;&lt;span class="w"&gt;          &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;STATES_DORMANT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;the_thread&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;resource_count&lt;/span&gt;&lt;span class="w"&gt;         &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;the_thread&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;real_priority&lt;/span&gt;&lt;span class="w"&gt;          &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;priority&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;the_thread&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;Start&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;initial_priority&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;priority&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;libogc from 2023:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;thethread&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;budget_algo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prio&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="mi"&gt;128&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;LWP_CPU_BUDGET_ALGO_NONE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;LWP_CPU_BUDGET_ALGO_TIMESLICE&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;thethread&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;is_preemptible&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;is_preemtible&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;thethread&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;isr_level&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;isr_level&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;thethread&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;real_prio&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;prio&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;thethread&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;cur_state&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;LWP_STATES_DORMANT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;thethread&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;cpu_time_budget&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;_lwp_ticks_per_timeslice&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;thethread&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;suspendcnt&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;thethread&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;res_cnt&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;libogc from before 2004:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;thethread&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;isr_level&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;isr_level&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;thethread&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;real_prio&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;prio&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;thethread&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;cur_state&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;LWP_STATES_DORMANT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;thethread&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;suspendcnt&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;thethread&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;res_cnt&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Let's pay attention to the &lt;code&gt;is_preemtible&lt;/code&gt; variable, which is present in
current's libogc and in RTEMS, but not in the old libogc: it was added later.
Now, RTEMS has it since at least 1996, so, if libogc was actually copied from
it, how come this variable was not copied, too, but added at a later time?
Note, the accusation against libogc has been formulated in clear-cut terms:
&lt;em&gt;...steal an open source RTOS and remove all attribution and copyright
information...&lt;/em&gt;; it's clear that this is not what happened. It's much more
likely that libogc's developers did look at RTEMS code (which at that time
&lt;a href="https://github.com/atgreen/RTEMS/blob/2f200c7e642c214accb7cc6bd7f0f1784deec833/LICENSE"&gt;had another
license&lt;/a&gt;
and was known as the &lt;em&gt;Real Time Executive for Missile Systems&lt;/em&gt; or &lt;em&gt;Real Time
Executive for Military Systems&lt;/em&gt;) as a model and source of information, but
since the code was heavily adapted for libogc, they didn't feel they were
creating a “derivative work”. It's a grey area, but even myself, if I took a
project written in C++ and translated it into Rust or C#, for example, I'm
rather sure I wouldn't consider my work to be a derivative of the original; I'm
not a lawyer, so I might be plain wrong here, but I would be in good faith.&lt;/p&gt;
&lt;p&gt;At most, libogc could be accused of plagiarism, but in my humble opinion even
that would be a stretch: since we are not talking of some artistic work, but of
work of science/ingeneering, it's normal to build upon others' work. Yes,
credit should generally be given, but given that we are talking of a US
military-related project, I can see that there could be ethical reasons for not
wanting to do so.&lt;/p&gt;
&lt;h4&gt;Summing up&lt;/h4&gt;
&lt;p&gt;I'm consciously omitting the other old accusations about “stealing” Nintendo's
code, first because they are not new, and secondly because I don't consider
reverse-engineering as stealing. What I found most disturbing about this story
is that it smells hatred from far away, since I have a hard time to understand
why someone felt the need to look into libogc's origin and publicly smearing
the project and ultimately harming the whole of the Wii homebrew community.&lt;/p&gt;</description><guid>http://mardy.it/it/blog/2025/04/no-libogc-did-not-steal-rtems-code.html</guid><pubDate>Mon, 28 Apr 2025 13:56:49 GMT</pubDate></item><item><title>Porting OpenGL games to the Nintendo Wii: chro.mono</title><link>http://mardy.it/it/blog/2025/04/porting-opengl-games-to-the-nintendo-wii-chomono.html</link><dc:creator>Alberto Mardegan</dc:creator><description>&lt;p&gt;More than one year has passed since my last blog post, and I'm a bit ashamed to
confess that today's post is again about porting games to the Nintendo Wii — I
always tell to myself that I'm soon going to move to something else, possibly
less geeky than this (by the way, there &lt;em&gt;is&lt;/em&gt; something else I could write
about, but I'll leave it for another post!), but the problems posed by porting
games to an old console are just way too stimulating, and my brain gets
attracted to them in a way that I cannot resist.&lt;/p&gt;
&lt;p&gt;Anyway, have you ever heard of &lt;a href="https://github.com/devkitPro/opengx"&gt;OpenGX&lt;/a&gt;?
It's a project aiming to write an OpenGL driver for the Nintendo GameCube and
Wii's GX API: while these consoles have good (at the time, at least) 3D
capabilities, they were programmed via an API not even remotely close to
OpenGL, so back in 2013 one developer by the name of David Guillen Fandos
started a project to investigate the possibility of wrapping the GX API in
OpenGL. The project was abandoned after reaching a very basic state, but it's
author was diligent enough to write a &lt;a href="https://github.com/davidgfnet/opengx/blob/master/doc/opengx.pdf"&gt;PDF
file&lt;/a&gt;
describing its design and some implementation details. Having bumped into this
document, I was inspired by it and felt it was a pity that such a project had
died -- especially given the fact that this didn't happen because of some
technical infeasibility. So exactly one year ago, in the spring of 2024, I
picked it up and tried porting the game BillardGL to the Wii; I had to add
quite a few things to OpenGX, and adjusting the lighting pipeline, but after
less than one month &lt;a href="https://github.com/mardy/billardgl/tree/wii-port"&gt;the port of BillardGL was
ready&lt;/a&gt;. In the following
months, I ported several other OpenGL 1.x games, gradually enhancing and
expanding OpenGX, until I got most of OpenGL 1.4 supported.&lt;/p&gt;
&lt;center&gt;
&lt;figure&gt;
  &lt;a href="http://mardy.it/archivos/imagines/blog/billardgl.png"&gt;&lt;img src="http://mardy.it/archivos/imagines/blog/billardgl.png" width="80%"&gt;&lt;/a&gt;
  &lt;figcaption&gt;A 23 year old game was just ported to a 19 year old console.&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/center&gt;

&lt;p&gt;Should I have stopped there? Probably. Because indeed the Wii's GPU, despite
allowing a good degree of complexity in setting up its shading engine (called
TEV, Texture Environment), does not support the modern GL shading language, and
trying to have the CPU compile the shaders into something that GX could
understand is a task doomed to fail, in part because this would eat up all the
computing power, but especially because there simply isn't an algorithm that
could translate GLSL into GX commands. Is this the end of the journey then?&lt;/p&gt;
&lt;p&gt;Well, the fact that OpenGL 2.0+ shaders can not be machine-translated into GX
commands does not mean that this task is impossible: we've still got the human
brain to use! The idea is the following: let the deveoper who is porting the
game write the GX code corresponding to the GLSL code by hand. Saying it like
this might feel like this is no better than saying “Just port the whole
rendering backend to GX!” but as a matter of facts, there's a big difference:
with this approach all the rest of the OpenGL code stays untouched, and the way
I have design this &lt;em&gt;shader substitution&lt;/em&gt; to work in OpenGX allows one to keep
the GX code isolated in its own source file, without having to change a single
line of the program, save from adding a line near the beginning (in &lt;code&gt;main()&lt;/code&gt;,
typically) to install the GX hooks. This means that your program will still
call &lt;code&gt;glUniform*()&lt;/code&gt;, &lt;code&gt;glVertexAttribPointer()&lt;/code&gt; and so on to setup the rendering
pipeline, but when the program will get to execute &lt;code&gt;glDrawArrays()&lt;/code&gt; OpenGX will
pass control to the hooks previously installed, which will receive the uniforms
and the attributes, and setup the pipeline using GX commands. It might seem
complicated, but &lt;a href="https://github.com/devkitPro/opengx/commit/f837fe9bd6b363bb6a33f298eae99f15e0cd8bfe"&gt;it really
isn't&lt;/a&gt;
(well, if you can deal with the GX API), and it's even more efficient than the
fixed pipeline of OpenGL 1.x, since here the GX commands are reduced to the
bare minimum required by the shader, whereas in the fixed pipeline we have to
follow predefined steps.&lt;/p&gt;
&lt;center&gt;
&lt;figure&gt;
&lt;iframe src="https://vkvideo.ru/video_ext.php?oid=-230221529&amp;amp;id=456239017&amp;amp;hd=1" width="640" height="360" allow="autoplay; encrypted-media; fullscreen; picture-in-picture; screen-wake-lock;" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;
  &lt;figcaption&gt;chro.mono running on a Nintendo Wii.&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/center&gt;

&lt;p&gt;The first (and for the time being, the last) OpenGL 2.0+ game I've ported to
the Wii is &lt;a href="https://thp.io/2013/chromono/"&gt;chro.mono&lt;/a&gt;, a nice puzzle game from
2013 whose source code has been released in 2021. It uses the FBO feature from
OpenGL 3.0, so I had to implement it in OpenGX as well. I'm quite satisfied
with the result, not only because the game runs at 60 FPS, but because it shows
how rather complex shaders (the game has more than a dozen of them) can be
realized in GX; to tell the truth, in couple of cases I had to implement the
fragment shader by converting its code to C and drawing to a temporary texture,
but luckily these shaders are used only during program startup to draw to an
FBO and don't negatively affect the game performance. You can download it &lt;a href="https://github.com/mardy/chromono/releases"&gt;from
here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Summing up, if you get really bored and would like to engage in something
unusual (read: useless), porting games to older consoles would definitely keep
you active for some time. Unfortunately there aren't that many OpenGL games
which are open source, so the candidates for porting are not that many (by the
way, feel free to suggest in the comments — well, not for me, but maybe
&lt;em&gt;someone else&lt;/em&gt; will do it).&lt;/p&gt;</description><guid>http://mardy.it/it/blog/2025/04/porting-opengl-games-to-the-nintendo-wii-chomono.html</guid><pubDate>Tue, 22 Apr 2025 15:35:25 GMT</pubDate></item><item><title>libSDL2 and VVVVVV for the Wii</title><link>http://mardy.it/it/blog/2024/02/libsdl2-and-vvvvvv-for-the-wii.html</link><dc:creator>Alberto Mardegan</dc:creator><description>&lt;p&gt;Just a quick update on something that I've been working on in my free time.&lt;/p&gt;
&lt;p&gt;I recently refurbished my old Nintendo Wii, and for some reason I cannot yet
explain (not even to myself) I got into homebrew programming and decided to
port libSDL (the 2.x version -- a 1.x port already existed) to it. The result
of this work is already available via the &lt;a href="https://devkitpro.org/"&gt;devkitPro&lt;/a&gt;
distribution, and although I'm sure there are still many bugs, it's overall
quite usable.&lt;/p&gt;
&lt;p&gt;In order to prove it, I ported the game &lt;a href="https://thelettervsixtim.es/"&gt;VVVVVV&lt;/a&gt;
to the Wii:&lt;/p&gt;
&lt;iframe src="https://vk.com/video_ext.php?oid=7200355&amp;amp;id=456239302&amp;amp;hd=1" width="640" height="360" allow="autoplay; encrypted-media; fullscreen;
picture-in-picture;" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;

&lt;p&gt;During the process I had to fix quite a few bugs in my libSDL port and in a
couple of other libraries used by VVVVVV, which will hopefully will make it
easier to port more games. There's still an issue that bothers me, where the
screen resolution seems to be not totally supported by my TV (or is it the HDMI
adaptor's fault?), resulting in a few pixels being cut at the top and at the
bottom of the screen. But unless you are a perfectionist, it's a minor issue.&lt;/p&gt;
&lt;p&gt;In case you have a Wii to spare, or wouldn't mind playing on the Dolphin
emulator, &lt;a href="https://github.com/mardy/VVVVVV/releases/tag/v2.4.1_wii1"&gt;here's the link to the VVVVVV
release&lt;/a&gt;. Have fun! :-)&lt;/p&gt;</description><guid>http://mardy.it/it/blog/2024/02/libsdl2-and-vvvvvv-for-the-wii.html</guid><pubDate>Fri, 02 Feb 2024 17:50:44 GMT</pubDate></item><item><title>Will the internet forget russophobia?</title><link>http://mardy.it/it/blog/2023/06/will-the-internet-forget-russophobia.html</link><dc:creator>Alberto Mardegan</dc:creator><description>&lt;p&gt;I've often wondering what will happen when this horrific war in Europe will
finally be over. I won't be discussing politics here, but what is mostly
interesting to me is how (and if) all the companies who made high proclaims
about not doing business with Russia will justify their getting back into the
Russian market. They will probably count on the fact that the war will be long,
and that people will forget what these companies' stance was. After all, the
world has forget about all the companies who collaborated with the Nazi regime,
so we can expect the same to happen with this war.&lt;/p&gt;
&lt;p&gt;But I don't think that's right: if you made a mistake, you should be held
accountable for it. You might be wondering what is the “mistake” I'm talking
about: that's &lt;strong&gt;russophobia&lt;/strong&gt;, indeed. To put it simply, and make a concrete
example: if The Qt Company stops doing business with Russian companies and
blocks its downloads page to Russian IP addresses because of the war, &lt;em&gt;without
being forced by the government to do so&lt;/em&gt;, but does not take similar measures
against other countries who wage wars which have caused way more deaths and
displacement of individuals, well, that's what I call “russophobia”. Of course,
I'm aware that there's way more than that, and that the hatred for all what is
Russian (including culture and sport competitions) is an even bigger issue, but
in this blog post I'm especially focused on the IT world, so please forgive my
semi-intentional narrow-mindness on this topic.&lt;/p&gt;
&lt;p&gt;Now, I'm fully aware that we live in a mediatic bubble that directs our
decisions in a way that is almost automatic, and I'm sure that most people
working for companies who took russophobic decisions are not themselves
russophobic at all (and I'm not dismissing the possibility that even the very
same people who took these decisions might not be russophobic) and that these
decisions were taken on impulse, because “everyone else is doing the same” and
due to the media pressure that if you don't do that, you might get accused of
supporting the “wrong” side of the war.&lt;/p&gt;
&lt;p&gt;But that's not an excuse, especially for “smart” people like IT engineers (and
I put the adjective between quotes &lt;a href="http://mardy.it/it/blog/2022/11/the-idiotism-of-software-developers.html"&gt;for a
reason&lt;/a&gt;), and especially after
the initial heat has passed and when, after more than one year of war, we
should have been exposed to different point of views and be able to evaluate
the situation more rationally. It has been therefore especially stunning for me
to learn that the Linux Kernel community, and hence The Linux Foundation, has
recently given room to russophobic behaviours, refusing a patch coming from the
Russian company Baikal (a CPU maker). For the record, the incriminated patch
was not related to supporting hardware produced by this company (not that this
would make the deed less serious, but at least one could have argued that there
could be some spot of logic in it):&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;From: Jakub Kicinski &amp;lt;kuba@kernel.org&amp;gt;
To: Serge Semin &amp;lt;Sergey.Semin@baikalelectronics.ru&amp;gt;
[...]

On Tue, 14 Mar 2023 01:42:24 +0300 Serge Semin wrote:
&amp;gt; From: Serge Semin &amp;lt;Sergey.Semin@baikalelectronics.ru&amp;gt;

We don't feel comfortable accepting patches from or relating 
to hardware produced by your organization.

Please withhold networking contributions until further notice.
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;(&lt;a href="https://lore.kernel.org/all/20230314103316.313e5f61@kernel.org/"&gt;here&lt;/a&gt; the
link to the original discussion). One week later, someone denounced this as a
violation to the Code of Conduct committee (unfortunately the only link I could
find to this is coming from a &lt;a href="https://www.opennet.ru/openforum/vsluhforumID3/129994.html#529"&gt;Russian IT
forum&lt;/a&gt;, and any
other references seem to have been removed from DuckDuckGo and Google), only to
receive a reply that it was all fine.&lt;/p&gt;
&lt;p&gt;To me this is not fine. The war will end, sooner or later, but it bothers me
that we never learn from the past and repeat the same mistakes over and over.
We apparently know a lot about propaganda, yet we fail to recognize it when it
influences our own mind and actions. My humble contribution is the creation of
a page where I list the companies who have taken russophobic actions, and, on
the opposite side, companies (like Flickr and Zorin OS) who have stood out for
positive messages and helpful actions. My hope is that some of the listed
companies will find the courage to review their actions, and either correct
their stance, or at least clarify their reasons. So, I hereby present&lt;/p&gt;
&lt;p style="text-align: center; font-size: 130%"&gt;
  &lt;a href="https://github.com/mardy/russophobia"&gt;Denouncing russophobia&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;where you'll find some of the good and some of the bad companies. I'm sure I'm
missing plenty of them: I just started recollecting my memories and searching
online a couple of days ago. I created this as a GitHub project, because indeed
I'm looking forward for contributions, to help me make the lists more complete.
I need to stress that the fact that a company has announced the suspension of
its business in Russia does not automatically make it russophobic: what we need
to look at is the &lt;em&gt;reason&lt;/em&gt; for that decision: companies like LEGO and Nintendo,
for example, have suspended their operations citing logistic and financial
reasons; no judgement involved.&lt;/p&gt;
&lt;p&gt;Let me repeat it once more, just to make sure there are no misunderstandings:
it's perfectly fine for businesses to take a stance on politics, and sometimes
it might be even praiseworthy; but if a company is international, and does not
apply the same reasoning to other armed conflicts, or seem to care only about
certain human rights violations and not others, then it's a case of double
standards which we need to be aware of, and make the company think twice about
it. And that's also the reason why you won't find any Ukrainian company among
the “bad” ones, because in their case the reaction is perfectly understandable
and they can hardly be accused of adopting double standards (well, technically
speaking, they are adopting double standards, but when you are so directly
impacted I think it does not deserve a blame): if it's your house which burns,
you should definitely scream about it, even if you previously have been silent
about your neighbour house's burning.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;I'm especially looking forward for more “good” companies&lt;/strong&gt;, who have shown empathy
towards the people affected by the war (and maybe even collected money to help
them) while refraining from taking the judging role and forgetting about all
the injustice and suffering that other wars have caused (including on that very
same piece of land that suddenly appeared on all newspapers' front pages on
February 24th, 2022). I hope that these companies can serve as an example of
positive action, humanity, and love.&lt;/p&gt;</description><guid>http://mardy.it/it/blog/2023/06/will-the-internet-forget-russophobia.html</guid><pubDate>Sun, 04 Jun 2023 07:41:02 GMT</pubDate></item><item><title>Back to Maemo!</title><link>http://mardy.it/it/blog/2023/01/back-to-maemo.html</link><dc:creator>Alberto Mardegan</dc:creator><description>&lt;p&gt;New year, new job. After &lt;a href="http://mardy.it/it/blog/2022/12/leaving-canonical-again.html"&gt;leaving
Canonical&lt;/a&gt; I'm back to working on the same
software platform on which I started working back in 2006: &lt;a href="http://mardy.it/it/blog/2023/01/maemo.org"&gt;Maemo&lt;/a&gt;.
Well, not exactly the vanilla Maemo, but rather its evolution known as &lt;a href="https://en.wikipedia.org/wiki/Aurora_OS_(Russian_Open_mobile_platform)"&gt;Aurora
OS&lt;/a&gt;,
which is based on &lt;a href="https://sailfishos.org/"&gt;Sailfish OS&lt;/a&gt;. This means I'm
actually back to fixing the very same bugs I introduced back then when I was
working in Nokia, since a lot of the middleware has remained the same.&lt;/p&gt;
&lt;p&gt;At the moment OMP (the company developing Aurora OS) is mostly (or even
&lt;em&gt;exclusively&lt;/em&gt;, AFAIK) targeting business customers, meaning corporations such
as the Russian posts and the railway company, whereas the consumer market is
seen as something in the far away future. Just in case you were curious whether
there were any devices on sale with Aurora OS.&lt;/p&gt;
&lt;p&gt;I should also explain why I've refused several very well paying job
opportunities from Western companies: it's actually for a reason that has been
bothering me since last March, and it's a very simple one. The fact is that
because of the sanctions against Russia I already had to change bank once (as
the one I was using fell under sanctions), and in these months I've always been
working with the fear of not being able to receive my salary, since new
sanctions are introduced every month and more and more banks are being added to
the blacklist. That's why I've restricted my job search to companies having an
official presence in Russia; and to my surprise (and from some point of view, I
could even say &lt;em&gt;disappointment&lt;/em&gt;) the selection and hiring processes were so
quick that I received three concrete offers while I was still working my last
weeks at Canonical, and I joined OMP on that very Monday after my last Friday
at Canonical.&lt;/p&gt;
&lt;p&gt;I mean, I could have rested a bit, at least until the Christmas holidays, but
no. ☺  Anyway, I'm so far very happy with my new job, and speaking Russian at
work is something totally new for me, both challenging and rewarding at the
same time.&lt;/p&gt;</description><guid>http://mardy.it/it/blog/2023/01/back-to-maemo.html</guid><pubDate>Sun, 08 Jan 2023 19:48:52 GMT</pubDate></item><item><title>Leaving Canonical, again</title><link>http://mardy.it/it/blog/2022/12/leaving-canonical-again.html</link><dc:creator>Alberto Mardegan</dc:creator><description>&lt;p&gt;For the &lt;a href="http://mardy.it/it/blog/2017/04/looking-for-new-adventures.html"&gt;second time&lt;/a&gt;, I'm being shown
the door at Canonical. Well, technically, this time it was me who handed over my
resignation, but that was only after I was told in very clear terms that I
would eventually be fired. No timeframe was given, but since I don't
particularly enjoy the feeling of checking my e-mail every morning to find out
whether this is the day when I'm being fired, I decided to take the initiative
and leave myself.&lt;/p&gt;
&lt;p&gt;The reason? Those who know me well might suspect that it's related to some
complications with that fact that I'm living in Russia, or maybe with some
remarks I might have made about the war in Ukraine or about other current
events, since &lt;a href="http://mardy.it/it/blog/2019/09/principles-and-privileges.html"&gt;I tent to be quite outspoken and
provocative&lt;/a&gt;. Nothing of all that: it's about my
&lt;strong&gt;refusal to get vaccinated&lt;/strong&gt; against COVID-19; unfortunately, it has now
become apparent that I'm not the only one leaving, and other employees who have
refused either to get vaccinated or to disclose their vaccination status are
also being shown the door (including people who have been in the company for
more than 10 years). This has sparked some internal discussions in the company, and
several different point of views have been voiced: from those who welcome this
policy and would like to see it extended to flu vaccinations (which makes a lot
of sense, since once you've accepted to renounce your freedom in order to
protect the weak, you should accept it for all transmissible diseases), to
those who voiced concerns about the legality of this move, or would have found
this reasonable one year ago but not in the current situation as restrictions
are getting lifted and the current variants are less scary than the previous
ones; those who pointed out that being vaccinated has little impact on
transmissibility of the virus; that we are mostly a remote company and we could
instead have exceptions to allow unvaccinated people (or people with a weak
immune system) to remotely attend the few in-person meetings we have;
that as long as there are no vaccination mandates for plane flights and other
guests attending the same hotel premises where we meet, mandating employees to
get vaccinated might not help a lot; and whether this is a decision that a
company should make, or shouldn't it rather lobby the politics to have it
mandated at state level. I think there's merit to all these arguments, but I'm
personally not particularly interested in discussing any of them, since my
point is another.&lt;/p&gt;
&lt;p&gt;Before talking about that, though, let me clearly set one thing straight: I
hate lies, and &lt;strong&gt;Canonical's management is lying&lt;/strong&gt; about this matter. The
vaccination mandate measure is being justified on the grounds that it allows
employees to travel (something that I've been able to do as unvaccinated
throughout the last two years, even when restrictions were at their peak) and,
most importantly, to protect our weaker colleagues. This is what I find most
disgusting: using genuine feelings like love and compassion to justify
repressive measures. No, dear Canonical, this has nothing to do with protecting
the weak; not only because a vaccinated person can still spread the virus (and
our employees know this from first-hand experience), but also because, if this
was the real reason, then you'd accept people who have recently recovered from
COVID-19, since &lt;a href="https://academic.oup.com/cid/article/75/1/e545/6563799"&gt;immunisation after recovery is not worse than that of
vaccination&lt;/a&gt;; but you
don't, as I was explicitly told by HR that any previous infection is irrelevant.
It's also significant that you didn't establish clear rules about how often
one needs to get vaccinated, since all recent scientific literature on vaccine
efficacy shows that this is not a minor detail. Why not just be honest with
ourselves, and admit it's &lt;a href="https://www.enr.com/articles/52481-us-announces-revised-vaccine-mandate-rules-for-federal-contractors"&gt;just for
business&lt;/a&gt;?
Being open about the fact that having a fully vaccinated workforce can grant us
access to more business deals would not change a lot in the practical life of
the (ex-)employees, but at least we won't feel that the company is treating us
as fools while embellishing its image with fake care and compassion. Or, if
there are other reasons, state them, because these ones don't stand up to logic
scrutiny.&lt;/p&gt;
&lt;p&gt;Another thing that doesn't match (though maybe this is a timing issue, so I
cannot for sure call it out as a lie) is the fact that HR claims to have an
exemption process through which one could opt-out of the vaccination for
religious beliefs. Well, I was explicitly told in very clear terms by HR that
no exceptions would be made on either moral or religious grounds.  But maybe
this has changed since the time I was told this (mid October) and now?&lt;/p&gt;
&lt;p&gt;Here, finally, let me state why I believe that such a mandate is wrong. The
first thing I want to put on the table is that even though I see very little
reason for this mandate (given all what we know about the virus mutability and
infectiousness, the shortcomings of the vaccines, etc. — by the way, if you are
into science I suggest reading &lt;a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC9062939/"&gt;this
article&lt;/a&gt; which raises
some questions you won't hear in mainstream media and has a comprehensive
bibliography for further study), I recognize that in principle there are very
solid reasons for vaccination mandates, for example in the case where a virus
is extremely lethal, its symptoms otherwise uncurable and the vaccine is 100%
safe and highly effective. But even in that case, while getting vaccinated
myself, I would still oppose a mandate. Why?  Because of freedom, which trumps
everything. The choice is never between a healthy life and freedom: if there's
no freedom, there's no life worth living.  Even if some decision has very solid
reasons behind it, this doesn't automatically make it a good decision.&lt;/p&gt;
&lt;p&gt;Let me make a few examples: if a company (I'm talking about companies here, but
the reasoning could be extended to states as well) decided that smokers will be
fired, or that those who drink alcoholics will be fired, or that you cannot eat
meat, or that you must take a pill whenever your head aches, or that
transgender people must undergo gender reassignment surgery, or that
everyone should wear a black band on their arm whenever a relative of a
colleague dies, or that employees' households must use the product made by the
employer, or that they have to excercise sports for at least two hours per
week, etc.; I would be categorically opposed to every single of these
impositions, despite recognising that there are reasons behind each of them,
and that I even dream of a world in which some of their goals are attained
(could we just all be fit and healthy?!). Because I think that personal freedom
is more important. You can always find good reasons to justify this or that
action; surely, if we think back at the fascist and totalitarian regimes of the
first half of last century, we must acknowledge that they were supported by the
(overwhelming?) majority of the population. An effective propaganda machine
could convince the population on this and that matter, but ultimately it's the
population who &lt;em&gt;reasoned&lt;/em&gt; and accepted that storytelling. Nowadays the
situation is different, but the mechanisms are the same, except that propaganda
has become way more effective (&lt;a href="http://mardy.it/it/blog/2022/11/the-idiotism-of-software-developers.html"&gt;or have we become
dumber?&lt;/a&gt;) and aligned over the
same direction, thanks to the globalisation process.&lt;/p&gt;
&lt;p&gt;I'm well aware that societies are made of rules and therefore inevitably
restrict personal freedom: Western societies, for example, forbid nudity in
public places, and that's something I accept because it's part of my culture;
it's a rule deeply entrenched in our history, and I don't feel it as a burden.
I'm convinced, however, that the evolution of human society should be that, as
we become more conscious, we should be moving towards more free societies, with
fewer rules and more tolerant for diversity.&lt;/p&gt;</description><guid>http://mardy.it/it/blog/2022/12/leaving-canonical-again.html</guid><pubDate>Sat, 03 Dec 2022 07:03:58 GMT</pubDate></item><item><title>The “idiotism” of software developers</title><link>http://mardy.it/it/blog/2022/11/the-idiotism-of-software-developers.html</link><dc:creator>Alberto Mardegan</dc:creator><description>&lt;p&gt;Before you get angry at me for this title, please let me state that I count
myself in the number of the “idiots” and, secondly, that what I mean by
“idiotism” here is not to be intended as an offence, but as some traits of
mindset which are typical of very logical brains.&lt;/p&gt;
&lt;p&gt;Some months ago I finished reading Dostoevskiy's “The Idiot”, a book about an
exceedingly good-hearted man, prince Lev Mishkin, whose behaviour was puzzling
the people around him so much that they thought of him as an idiot. Sure, the
fact that he was suffering from epilepsy didn't help, but it was far from being
the primary reason for their thinking, since his epileptic seizures were very
rare (if I remember correctly, only two occurred during the time of the story)
and everybody's opinion had already formed well ahead of witnessing him in such
a state.&lt;/p&gt;
&lt;p&gt;He was an idiot because he was open, trustful, and especially because he could
not “read between the lines” of what was been said to him: his social conduct
was straight, and although he was following at his best the customs that he had
been taught, he was supposedly awkward and unable to perceive and parse all the
messages that are implicitly conveyed by social behaviours and human
interactions. I added the word “supposedly” because, as a matter of fact, his
behaviours were all perfectly normal for me: I only noticed their awkwardness
when it was pointed out by the other characters, at which point I couldn't help
smiling and acknowledging that, indeed, that thing he did was weird.&lt;/p&gt;
&lt;p&gt;However, he was a good and caring person, and not without talents: he had an
interest in calligraphy, and everybody liked to listen to him, as his speech
was insightful and his thoughts were original. I wonder how many of my readers
can identify themselves in such a character?&lt;/p&gt;
&lt;p&gt;I definitely can. I won't get into the details, but I've felt many times on me
the amused or puzzled glance of people (like that time in high school when I
could not open a door in front of dozens of people, and I heard them say “So,
that guy is the genius of mathematics?” — I'll never forget that!), often
without understanding the reason for their reactions. Still, generally people
seem to like my company and be genuinely interested in talking to me.&lt;/p&gt;
&lt;p&gt;So, what's wrong with prince Lev Mishkin, me, and maybe with you too? Well, a few
things, I would say. I'm not going to claim any scientific truth on what I'm
going to say, these are just my own impressions and deductions, which seem
to be shared by other people in the interwebs too, judging from a quick search
I did; take them for what they are.&lt;/p&gt;
&lt;p&gt;The first thing I notice is some common traits between us and autistic people:
we tend to work better with things, rather than with people; we can focus on
a certain thing (work, a mathematical problem, a game) and forget about the
world around us; we have our unique hobbies, like solving puzzles, arguing
about a specific and very narrow topic, learning artificial (both human and
programming) languages; it's as if we needed to build a small, better world
where we would feel safe and at ease.&lt;/p&gt;
&lt;p&gt;The other thing, which I actually consider harmful and which I put efforts to
change in my own life, is the fact that it's extremely easy to get us
interested into a specific aspect of a problem, and make us forget (or just not
notice) the big picture. That small part that we are looking at is stimulating
and challenging, and we are led to think that it's core of the issue, and maybe
of all the issues that affect our world. What is often missing is the ability
to take one step back and try to look at the issue from a different angle, and
especially the ability to listen for counter arguments; I mean, we do listen to
them, but since we have, in a way, “gamified” the issue, even when we think
that we are open to listen to the other side, we are in reality trying to win
the counter-arguments, rather than genuinely trying to understand them.&lt;/p&gt;
&lt;p&gt;Another thing which we have, is faith. Yes, you read it right: even though the
IT world is probably the one with the highest percentage of atheists, men
always need something to believe in. We just don't realize it, but we do hold a
blind trust in certain persons and authorities. This does not mean that this
trust lives forever and cannot be broken, but this generally does not occur
because of a conscious realization of ours. Much more often than we'd like to
admit, the reason why we lose faith in a certain person or authority is because
&lt;em&gt;the rest of the persons and authorities that we trust has told us so&lt;/em&gt;. In
other words, even if there's undoubtedly a reasoning of our own, the full
realisation and conviction occurs after having collected and compared the
opinions (or statements) of those we trust. The net result is that the IT
population is the one most trustful of the mainstream media, because it's the
mainstream media who has more “voice”: that's where the most &lt;em&gt;reputable&lt;/em&gt;
journalists, scientists, activists are (and “reputable” is the key word here,
since this reputation is recursively created by the mainstream media
themselves or by their sponsors).&lt;/p&gt;
&lt;p&gt;I might be biased by my own experience here, but it seems to me that there
isn't a group of people more homogenous in their political (and generally,
world) views than that of IT workers. When, in 2018, I saw the leaked video of
Google's co-founder Sergei Brin and other executives' reaction at Trump's
presidential victory, what I found most surprising was not the contents of the
speech, as they were mostly mainstream opinions, but rather the fact that all
this could be said in a company meeting. Something like this, I though, could
never happen in an European company, as political matters are a conventional
tabu in the work environment. But the point is that Brin and others could say
those words only because &lt;em&gt;they knew&lt;/em&gt; that the overwhelming majority of the
audience shared the same opinion. I don't think you could find the same
homogeneity of thought among shop assistants or philosophy professors.&lt;/p&gt;
&lt;p&gt;Assuming that you have followed me this far into my rambling, and that you
recognize that there might be some truth in what I wrote, you might now be
wondering if there's a way to counterbalance our “idiotic” traits.
Unfortunately I don't have a full answer, as myself am only halfway there (but
maybe I'm too optimistic here? and does this road even ever end?), but there
are a few things that I think are absolutely worth trying:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Talk with people. Better if face to face, or at least in a video call; just
  1-on-1, avoid groups, or you'll get on the defensive and try to defend your
  position for the sake of not losing the argument in front of an audience. But
  it's not a fight. Your goal when talking should not be that of convincing or
  getting convinced, but rather just to &lt;em&gt;understand&lt;/em&gt; the other points of view.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Read both sides of the narrative. Try to see the other party's argument as
  they themselves present it, and not how it is presented in the media you
  usually read. Media often use this trick, to either invite “clown
  representatives” of the other point of view just to ridicule it, or they give them
  too little time, or extrapolate their answer out of context, just to make
  them appear unsensible.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Always assume that other people are smart, and that no one is bad.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Whatever the argument, try to answer the key question: “Cui bono?” (who
  profits?) to be at least aware of all the hidden interests behind this and
  that. They don't necessarily invalidate a position, but they must be
  considered.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Lose faith. The only faith you are allowed to keep is the faith in God (or
  Gods), if you have it: but men, theories, institutions, authorities
  (including religious ones!), these must always be assumed to be imperfect and
  not blindly trusted.  People serve their interests or can be manipulated. Try
  always to start from a clean table and an empty mind, and see if they have
  enough arguments to convince you. &lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Do never assume “They can not &lt;em&gt;all&lt;/em&gt; be wrong” or “If this were wrong, at
  least some media would report it”. It just doesn't work this way, this is
  again a matter of having faith in the majority. Think of how many times in
  (recent) history you were presented an unambiguous truth, which later came
  out to be a scam (Iraq war being a famous one).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Defocus. You might be spending a lot of energy into something that's not
  worth it. I mean, feel free to pursue whatever hobbies you like, as long as
  they make you feel better. But if you think you have a &lt;em&gt;mission&lt;/em&gt;, think twice
  about it. Think about the world you'd like to live in, and whether/how this
  mission contributes to it.&lt;sup id="fnref:saudi"&gt;&lt;a class="footnote-ref" href="http://mardy.it/it/blog/2022/11/the-idiotism-of-software-developers.html#fn:saudi"&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Ask questions. Be curious. Be challenging. For any topic, there are questions
  that have not been answered in mainstream media&lt;sup id="fnref:refugees"&gt;&lt;a class="footnote-ref" href="http://mardy.it/it/blog/2022/11/the-idiotism-of-software-developers.html#fn:refugees"&gt;2&lt;/a&gt;&lt;/sup&gt;. Find the answer,
  then find explanations, never stopping at the first satisfactory one, but
  always get at least two competing answers. From here, ask more questions,
  rinse and repeat. And at every step ask yourself this: why didn't I know
  about this? Is someone trying to hide the truth from me?&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Aim at improving. Whenever you read something or talk to people, keep a
  humble attitude and try to be challenged. Your goal should be that every
  reading and every dialog should make you wiser, even if what you initially
  read and heard sounded like garbage. There are always reasons for all these
  thoughts you disagree with.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Reach out to the people nearby. Try not just to be sympathetic to the needs of
  some population living far away from you, which the media has singled out as
  being those needing your compassion, and try instead (or in addition to that)
  to be sympathetic and helpful to the people around you. To your neighbours,
  to those you see in the public transport and, first and foremost, to your
  relatives.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Summing up, what I want you to realize is that we IT workers are easily
exploitable. All those thought manipulation techniques represent a problem to
everyone, but it's particularly with us that they tend to be especially
effective; as a matter of fact, I've found that awareness of how the power
controls us is higher among uneducated people, because they are more
distrustful of the media and just tend to consume less of it. We, on the other
hand, are not only well educated to respect the authority (see &lt;a href="https://www.youtube.com/watch?v=wv6TyJ1AbRM"&gt;Noam Chomsky on
education&lt;/a&gt;), but our logical,
detail-focused mind can be easily externally controlled by continuously
stimulating it to focus on specific things and not others.&lt;/p&gt;
&lt;p&gt;How would Dostoevskiy call us?&lt;/p&gt;
&lt;div class="footnote"&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id="fn:saudi"&gt;
&lt;p&gt;I was recently surprised when I read people in a forum who were
discussing avoiding doing business with Saudi Arabia because of their human
rights record. Seriously? We are talking about a government who has indirectly
caused the death of more than 300 thousands people in Yemen, and your main
reason to criticize them is human rights? It's like asking the police to arrest
a killer because before the assassination he misgendered his victim! Yet the
elephant in the room continues to go unseen. &lt;a class="footnote-backref" href="http://mardy.it/it/blog/2022/11/the-idiotism-of-software-developers.html#fnref:saudi" title="Jump back to footnote 1 in the text"&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id="fn:refugees"&gt;
&lt;p&gt;My favourite one is: which country hosts more refugees from Ukraine? &lt;a class="footnote-backref" href="http://mardy.it/it/blog/2022/11/the-idiotism-of-software-developers.html#fnref:refugees" title="Jump back to footnote 2 in the text"&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;</description><guid>http://mardy.it/it/blog/2022/11/the-idiotism-of-software-developers.html</guid><pubDate>Tue, 08 Nov 2022 17:11:55 GMT</pubDate></item><item><title>Deride, a generator of mock objects for unit testing</title><link>http://mardy.it/it/blog/2022/11/deride-a-generator-of-mock-objects-for-unit-testing.html</link><dc:creator>Alberto Mardegan</dc:creator><description>&lt;p&gt;If you have been writing C++ classes for mocking out your C or C++
dependencies, you know how tedious it is. I generally write small classes with
just a handful of methods, so it's generally bearable, but when using
third-party code I'm usually not that lucky. If the dependency is a C library
this becomes especially tricky, both because they might be larger than what you
can handle, and both because the lack of an object-oriented design might not
offer you an easy solution to store the mock object data.&lt;/p&gt;
&lt;p&gt;But fear no more, &lt;a href="https://pypi.org/project/deride/"&gt;Deride&lt;/a&gt; is here!&lt;/p&gt;
&lt;p&gt;I won't spend too many words describing it, since you can read its description
from the link above, where you will also find some example code. More examples,
by the way, can be found in the &lt;code&gt;example/&lt;/code&gt; folder in the &lt;a href="https://gitlab.com/mardy/deride"&gt;code
repository&lt;/a&gt;, where you can see how it can be
used to mock both pure C++ and &lt;code&gt;QObject&lt;/code&gt;-based classes, and C libraries.&lt;/p&gt;
&lt;p&gt;What is most important for me to say now, is that the project is in alpha
state, meaning that I've tried it on a handful of header files only; it's
highly likely that it will not work on many real-life scenarios, and if that
happens I warmly invite you to &lt;a href="https://gitlab.com/mardy/deride/-/issues"&gt;inform me by filing a bug
report&lt;/a&gt; providing the include file
that was not properly processed.&lt;/p&gt;
&lt;p&gt;I leave you with a short example of a unit test, written using Deride. The
class under test is called &lt;code&gt;Stable&lt;/code&gt;, and internally it uses objects of type
&lt;code&gt;Horse&lt;/code&gt;, that we decided to mock. We used Deride to generate the mocked
implementation and a &lt;code&gt;MockHorse&lt;/code&gt; class which can be used to control the mocked
objects. When building the test, we won't link against the original
&lt;code&gt;horse.cpp&lt;/code&gt;, but we'll only use the original &lt;code&gt;horse.h&lt;/code&gt;; the implementation will
be found in &lt;code&gt;mock_horse.cpp&lt;/code&gt;, generated by Deride. And in the corresponding
&lt;code&gt;mock_horse.h&lt;/code&gt; file we'll find the &lt;code&gt;MockHorse&lt;/code&gt; class with all the
&lt;code&gt;on&amp;lt;method&amp;gt;Called()&lt;/code&gt; hooks which we can use to install our callbacks (either to
reimplement the object behaviour, or to just be notified on when its methods
are called).&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="cm"&gt;/* This MockHorse is the object created by Deride&lt;/span&gt;
&lt;span class="cm"&gt;     *                   |&lt;/span&gt;
&lt;span class="cm"&gt;     *                   |&lt;/span&gt;
&lt;span class="cm"&gt;     *                  \|/&lt;/span&gt;
&lt;span class="cm"&gt;     *                   V&lt;/span&gt;
&lt;span class="cm"&gt;     */&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;using&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Mock&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Animals&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;MockHorse&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;list&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;horseNames&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="s"&gt;"Tom"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="s"&gt;"Dick"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="s"&gt;"Harry"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="cm"&gt;/* We could use a vector, but let's be explicit */&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;Mock&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;mockTom&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;Mock&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;mockDick&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;Mock&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;mockHarry&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;createdHorses&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c1"&gt;// onConstructorCalled() is created by Deride and called when the mocked&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c1"&gt;// Horse object is created&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;Animals&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;MockHorse&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;onConstructorCalled&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="p"&gt;](&lt;/span&gt;&lt;span class="k"&gt;const&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;cout&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"Horse instantiated: "&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;endl&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="n"&gt;createdHorses&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"Tom"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="n"&gt;mockTom&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Mock&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;latestInstance&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"Dick"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="n"&gt;mockDick&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Mock&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;latestInstance&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"Harry"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="n"&gt;mockHarry&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Mock&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;latestInstance&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="c1"&gt;// should not be reached&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;Stable&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;stable&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;stable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;createHorses&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;horseNames&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="cm"&gt;/* It's at this point that the contructor callbacks we defined above will&lt;/span&gt;
&lt;span class="cm"&gt;     * have been called. Let's double-check that indeed that's the case.&lt;/span&gt;
&lt;span class="cm"&gt;     */&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;createdHorses&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;stable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mockTom&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;!=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;nullptr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mockDick&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;!=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;nullptr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mockHarry&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;!=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;nullptr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="cm"&gt;/* Prepare for mocking the jump; these methods are generated by Deride and&lt;/span&gt;
&lt;span class="cm"&gt;     * allow setting the return value for the corresponding jumpHeight() method&lt;/span&gt;
&lt;span class="cm"&gt;     * from the original Horse class. */&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;mockTom&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;setJumpHeightResult&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;1.5&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;mockDick&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;setJumpHeightResult&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;1.7&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;mockHarry&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;setJumpHeightResult&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;1.3&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;highestJumper&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;stable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;findHighestJumper&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;highestJumper&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"Dick"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;In my closing words I'd like to thank the &lt;a href="https://clang.llvm.org/"&gt;Clang
project&lt;/a&gt;, which Deride is using to parse and interpret
the input files, and &lt;a href="https://pypi.org/project/Jinja2/"&gt;Jinja2&lt;/a&gt;, the templating
engine used to generate the mock code.&lt;/p&gt;</description><guid>http://mardy.it/it/blog/2022/11/deride-a-generator-of-mock-objects-for-unit-testing.html</guid><pubDate>Sat, 05 Nov 2022 06:51:41 GMT</pubDate></item></channel></rss>