Re: [Vala] Read only members for wrapped libraries




On Tue, 2008-02-26 at 17:39 +0100, Andreas Sliwka wrote:
Greetings,
  is it possible decorate a struct or class member in a vapi file so
that vala only allows read access to it?

For example take this excerpt from the SDL/SDL.h file (SDL being a
gamers library):

/* This structure should be treated as read-only, except for 'pixels',
   which, if not NULL, contains the raw pixel data for the surface.
*/
typedef struct SDL_Surface {
    Uint32 flags;               /* Read-only */
    SDL_PixelFormat *format;        /* Read-only */
    int w, h;               /* Read-only */
    /* etc */
}

I'd like to have vala issue a warning when a new value would be
assigned to any of these attributes.
That is not possible for fields atm.
It would be possible to add attributes to fields on which the compiler
would warn/abort on certain actions to that field.

cheers,

Raffaele




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