[Vala] Type parameter not stored as expected



Greetings,

I have a data type used to store parser state declared as:
  class ReaderState {
    public Object obj;
    public bool in_array;
    public Type type;
    public TypeClass kl;

    public ReaderState (Object o, bool a, Type t, TypeClass k) {
      this.obj = o;
      this.in_array = a;
      this.type = t;
      this.klass = k;
    }
  }

When creating a new element, obj, in_array and type are all stored
correctly, while klass is never stored.  The parameter value is correct,
but the stored value is always 0.  Instances of ReaderState are stored in a
stack, and if the stored TypeClass is used on retrieval, it is always 0,
but if regenerated from the type element, it is correct, so I do have a
workaround for the issue.

My concern is that I'm failing to understand something about the language
semantics that will bite me elsewhere, so does anyone have any idea as to
why this behaviour is demonstrated?  Or is it just a bug?

From the calling perspective, type and klass are instance variables and are
assigned as:

      type = current.get_type ();
      klass = type.class_ref ();

The C generated for the klass assignment internally to ReaderState is:
_tmp4_ = k;
_tmp5_ = _g_type_class_ref0 (_tmp4_);
_g_type_class_unref0 (self->klass);
self->klass = _tmp5_;

Does that suggest what is happening?

Regards,

Andrew Lees.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]