Posts

When I'm fixing windows

Image
Our house dates from the turn of the century and has been redeveloped several times, at some point it had metal "Crittall" windows installed. These were single glazed, and in poor state of repair so when we had rebuilding work done we had to find similar/matching designs and settled on some new metal windows called "heritage" windows from a company called "Duration Windows". They looked great, almost perfectly matching the original design. They also had matching "window catches" internally, rather than your typical upvc style handles. Window with one of the opening arms: Picture showing the window latch, siamese cats assist. Unfortunately, just a few years later these started to fail one at a time, close inspection revealed that they had been manufactured with some cheap poor quality cast alloy.  (one of) the broken hinge parts  Naturally I contacted the supplier for assistance but was simply advised that: "oh we don't do those any mor...

Psion 5mx case repair

Image
I picked up a water damaged Psion 5x to have some spare parts available to repair the first Psion 5x I bought. Psion in pieces with screens being repaired The first Psion had a broken screen and was sold as "fixable, complete with spare screen" the "spare screen" however had clearly been poorly removed from somewhere and had missing PCB pads and traces. The currently installed screen had a cracked cable. A cracked screen cable Sigh. My "donor" machine took ages to arrive, so instead I thought I'd see how I got on with some repairs instead. First I tried repairing the cracked flex cable, with no success, so ordered some new ones from JLCPCB... Second course of action, I decided to repair the spare screen, first cleaning up the contacts then carefully adding a new PCB pad, and connecting it up. and yes, I wished I'd taken some pictures of the PCB repair before I soldered the ribbon cable back on, but after connecting the cable and firing it up... it ...

Sharp Objects

Image
Step 10 - Sharp Objects So someone asked, can you dynamically load the library in csharp just like python? Hmm. Probably.... That would be nice, and I'm pretty sure we can do a lot of manipulation on the go with C#, like we can in python, there's a comprehensive reflection and invocation interface. How hard can it be? Can we build a c# interface on the fly instead of outputting source code to be compiled? so, significant rummaging later and the answer is a definite "sort of". 👍😁 Emit emit emit Initially, I used Reflection.Emit to generate CLR code at runtime... this worked and provided a fully dynamic binding doing the same as Python, loading the C++ library, calling our C API to interrogate it and building matching C# CLR objects at runtime. yay great success, move on.... but, developing with it is "challenging" you need to know all the available functions and types, write all the code wire up a command line build and crank the handle. So poss...

62++C (C++26 Reflection)

Image
Preamble I've always been better at the 'doing' rather than the explaining, so as part of my “what can we do with C++26” exercise I thought this would be a good opportunity to attempt to practice the 'explain it' bit. (In other words this might not be great! let me know if I can improve or change this) C++26 has now introduced reflection capabilities ( https://learnmoderncpp.com/2025/07/31/reflection-in-c26-p2996/ ) as a standard language feature, previously this is something you'd need to build yourself using various template and macro trickery. I find the only way I can learn how to use new features is to actually try to use them to do something useful. So my plan was - can I use the new C++26 reflection features to create a dynamic language binding system, and if so, can I do so step by step to make it easy/obvious how it could be improved or extended rather than just write a completed final "ta da" here's a C++ reflection system. Since th...

But what about Java

Step 9 - But what about Java This is the final step, adding a Java generator - each step adds or improves a small feature, this text is just highlighting a few details along the way, the best way to work through is to build and run each one, reading through the code with this description alongside. Similarly reading this alongside the diff for each step will also mean more than either just reading the text or just reading the code alone. That's what works for me anyway, YMMV. Now the swan song. We used and stuck with Python bindings from the start, partly because it's just so simple to prototype/test/debug/develop with against a C library.... but the whole point of this idea is to be language agnostic, we have a C API so we should be able to interface with any language that provies a C calling mechanism. Java is an attractive target. How hard can it be? :) Python built its binding dynamically at runtime, query the registry, create callable stub objects, profit. Java howeve...

Not remotely funny

Step 8 - Not remotely funny This is the eighth step, adding out-of-process calling - each step adds or improves a small feature, this text is just highlighting a few details along the way, the best way to work through is to build and run each one, reading through the code with this description alongside. Similarly reading this alongside the diff for each step will also mean more than either just reading the text or just reading the code alone. So far we're sticking to loading the marked up libdemo.so into the same process as the python interpreter. Now it gets interesting, what if we have multiple C++ libraries with clashing dependencies? Or the simple fact that if the C++ libary crashes our python interpreter will terminate. Since we have a simple clear C API at the interface, we could pipe that over an inter process comms (IPC) system into a separate process, and if we've got the plumbing right it should "just work" without needing any additional work to ou...

gnioG kcaB nI emiT

Step 7 - gnioG kcaB nI emiT This is the seventh step, adding c++20 compatability - each step adds or improves a small feature, this text is just highlighting a few details along the way, the best way to work through is to build and run each one, reading through the code with this description alongside. Similarly reading this alongside the diff for each step will also mean more than either just reading the text or just reading the code alone. All the steps so far have required a C++26-compliant compiler with -freflection support. However, we might still want to be able to run this on slightly older compilers. We won't need to change the API, runtime logic or Python binding, all we need to do is use the old style meta-template expansion and populate our now well defined metadata dictionary and type structures. The build change Drop the freflection flag and switch to C++20: CXXFLAGS = -O0 -g -Wall -Wextra -std=c++20 -fPIC -Ixplat -Idemo We'll define and use XPLAT_HAS...

Turtles all the way down

Step 6 - Turtles all the way down This is the sixth step, adding recursive structures - each step adds or improves a small feature, this text is just highlighting a few details along the way, the best way to work through is to build and run each one, reading through the code with this description alongside. Similarly reading this alongside the diff for each step will also mean more than either just reading the text or just reading the code alone. That's what works for me anyway, YMMV. Previously on the show (aka Step 3) we added struct support, but with a limitation, struct fields had to be scalars, you couldn't have a struct that contained another struct. So now we'll remove that limitation with a minor tweak. The problem When registerFieldConverter registers a setter/getter for a struct field it uses a chain of if constexpr branches - one per supported type. Before this step that chain ended with std::chrono::year_month_day , any field with an aggregate type ...