torsdag 9 augusti 2012

Compile Time Hashes pt2

While waiting for Visual C++ to implement the C++11 features I wrote about in the previous entry, I wanted a solution that worked on windows. This time I needed to implement the hashlittle function found in lookup3.c.

I used template programming to get the size of the string at compile time and I also relied on the compilers to optimize the code into the final result.

You can download the final code here: hashlittle.zip
Update (2012-08-20): Fixed bug in function for edge cases where the string was a multiple of 12 (doh!)

torsdag 12 juli 2012

Compile time hashes

C++11

Recently I’ve seen more and more of the C++11 features in the code reviews I oversee, so I needed to read up on the details. Some of the features were already featured in the C++0X standard, which has been semi-supported for some time now.


The second link will give you a hint of what’s supported for various compilers. Unfortunately, no current compiler supports C++11 entirely. And as usual it’s that MSVS is the farthest behind the standard.

The resulting files have been zipped together for your convenience: mm3hash.zip

fredag 25 maj 2012

ctypes + 64 bit windows + libclang.dll

This post is mostly for my own reference for the future.

I ran into trouble when using clang with 64 bit ctypes on a windows machine. Apparently there's a bug reported on the issue.

On windows, the compiler will convert arguments larger than 8 bytes into references automatically, whereas ctypes just happily allocates memory for the stack, ignoring the this fact. That leads to crashes.

I tried recompiling the _ctypes.pyd file, but that only caused my Python to hang. So, until that bug is fixed, I have to use the POINTER construct in ctypes instead.

The guys implementing the Sublime autocompletion plugin has solved it this way: cindex.py

måndag 30 januari 2012

Python remote debugging with PyDev

Sometimes you wonder why you didn't do something a lot sooner. Like googling for "python remote debugging". I've been a python addict for ca 2 years now and we use a lot of python tools at my work, and being able to remotely debug the tool chain would have saved me/us tons of work.

PyDev is a set of tools developed by Appcelerator and is available as an Eclipse plugin. It supports syntax highlighting, code completion, etc. And also remote debugging!