[Vala] Unions in Vala
- From: Nadir Sampaoli <nadirsampaoli gmail com>
- To: vala-list gnome org
- Subject: [Vala] Unions in Vala
- Date: Wed, 18 Jul 2012 20:19:29 +0200
I'm porting some code I wrote from procedural C to objective Vala and I'm
looking for the Vala-way to implement a union. I'm using a union in C
because I need a structure where one uin16_t and two uint8_t are aligned:
typedef struct {
uint8_t lo;
uint8_t hi;
} WORD;
typedef union {
uint16_t reg16;
WORD reg8;
} REG;
This way if I change reg8.hi's (or .lo's, for what matters) value,
reg16changes automatically.Now, in Vala, as far as I have been able to
find in
the documentation (I just started studying Vala, coming from a C#
background) there's no union keyword, and pointers are missing too.
If there's no union-like thing in Vala, is there at least some way to make
a built-in type referenceable (something like .NET's Int vs int)?
I have a last resort solution, but it's rather inefficient, so I'd like to
know if I can reproduce the original C code behaviour.
--
nadir
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]