For a project I'm working on, I'm trying to maintain a cache of X atoms.
(The x11 bindings define atoms as [SimpleType] [IntegerType].) The
rather simple code I've got looks like this:
class AtomManager : GLib.Object
{
private unowned X.Display? _display;
private Gee.HashMap<string, X.Atom?> _atoms;
public AtomManager(ref X.Display? display)
{
_atoms = new Gee.HashMap<string, X.Atom?>();
_display = display;
}
public X.Atom find(string name)
{
X.Atom? atom = _atoms[name];
if (atom == null)
{
atom = display.intern_atom(name, false);
_atoms[name] = atom;
}
return atom;
}
}
Vala's completely happy with this, but when I try to compile it I get
the C error:
error: ‘TYPE_ATOM’ undeclared (first use in this function)
The bit of C that's generating the error occurs when the _atoms object
is being constructed:
_tmp0_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup,
g_free, TYPE_ATOM, (GBoxedCopyFunc) _atom_dup, g_free, NULL, NULL, NULL);
_g_object_unref0 (self->priv->_atoms);
self->priv->_atoms = _tmp0_;
I don't know glib from my elbow, but this looks slightly as if Gee
generics can only handle GType-registered types. Is this the case?
What's the most idiomatic way of solving this kind of problem in Vala?
--
┌─── dg@cowlark.com ───── http://www.cowlark.com ─────
│
│ "I have a mind like a steel trap. It's rusty and full of dead mice."
│ --- Anonymous, on rasfc
Attachment:
signature.asc
Description: OpenPGP digital signature