Copied weakref implementation from Denis Shelomovskij.

Unfortunately it segfaults like any other weakref implementation in D.