This is likely to be the last of my tumblelog entries as I recently made the move to microblogging using twitter. This blog will of course remain and I will go on producing classic blog entries. If you have appreciated my tumblelog please follow dholmcom on Twitter.

Introduction to OpenCL, seeing how OpenCL has already picked up a lot of traction already this introduction might be posted a bit late but to the uninitiated it might prove useful.

Throwing Destructors, throwing from a C++ destructor is generally thought of as a big no-no and this article discusses all the issues related to it and suggests a couple of solutions. An interesting read!

Silhouette: The Story, of this highly mysterious almost perfect SNES emulator (during a time when the competition was still struggling to run homebrew).

Open64, is a open source compiler originally from SGI based on their MIPSPro compiler.

SGI Developer Books, an archive of different books on subjects relating to developing for different SGI technologies.

Mechanical Keyboard Guide, this is a guide to all the different kinds of computer keyboards that you will find including details on actuation, materials and virtually anything else that goes into defining the quality of the device.

Part 3 of my Lua C++ binding series has been 95% ready for several months now and I finally got around to finished the last five percent.

In this part I will add code which enables us to return a class instance usable from Lua as a value from a method or function call. By calling the static member push we can put objects onto Lua’s stack (see section 3.1 – The Stack in the Lua reference manual).

First we need to rewrite our garbage collection code so that it is able to differentiate between objects that are managed by Lua and objects that are deleted elsewhere. We will control this by adding a new field to our class instance metatable called “unmanaged“. If the metatable has the unmanaged field we will not delete the C++ object instance when Lua is executing its garbage collector.

The allocUserdata allocates room for a light userdata item in the specified table of the specified size and returns a pointer to the data region. Light userdata is a pointer to a C object stored in Lua and we use it to store the pointer to our object instance.

Weak tables are tables who reference data that is not to be garbace collected by Lua and they are explained in section 2.10.2 of the reference manual. The mode of the weak table defines whether the key, value or both are to be considered weak and protected from collection.

If we push the object instance with garbage collection disabled we have to add the “unmanaged” subtable that we talked about when we implemented the new garbage collector which acts as a tag to inform it that the object instance should not be automatically garbage collected (i.e. someone has to call delete on it from C++).

Finally we replace the old metatable with our modified one containing the object instance, reset the stack and then returns the index of our metatable so that Lua knows where we put the object instance.