Re: [Vala] Generating vapi file for a simple struct



Matías De la Puente <mfpuente ar gmail com> wrote:

Is there any need for the cprefix and clower_case_prefix in
this case? I get the impression that they are not used as long
as I specify the cname itself.

There's no need to add cprefix in this case. cprefix and
lower_case_cprefix (this is the real name) is used to give to the
members some prefix and they only needed when there's some common
prefix between the members. In this case you can make
lower_case_cprefix="err" and define the members as num and mess.
Try both i use cprefix in enums and lower_case_cprefix in classes
and namespaces..

I understand.

I am trying to find out what the best way is to "vapify" this
library. There are some naming conventions which are OK within C,
but I would like to go for a more CamelCase style within Vala.

There are some enum-type things defined like this:

typedef bits wimp_error_box_flags;

#define wimp_ERROR_BOX_OK_ICON          ((wimp_error_box_flags) 0x1u)
#define wimp_ERROR_BOX_CANCEL_ICON      ((wimp_error_box_flags) 0x2u)
#define wimp_ERROR_BOX_HIGHLIGHT_CANCEL ((wimp_error_box_flags) 0x4u)

I made these into an enum like this:

public enum ErrorBoxFlags
{
  [CCode (cname = "wimp_ERROR_BOX_OK_ICON")]
  OKIcon = 0x01,
  [CCode (cname = "wimp_ERROR_BOX_CANCEL_ICON")]
  CancelIcon = 0x02,
  [CCode (cname = "wimp_ERROR_BOX_HIGHLIGHT_CANCEL")]
  HighlightCancel = 0x04,
}

Would it be possible to do this somewhat more like this?

[CCode (cprefix = "wimp_ERROR_BOX_")]
public enum ErrorBoxFlags
{
  [CCode (member = "OK_ICON")]
  OKIcon = 0x01,
  [CCode (member = "CANCEL_ICON")]
  CancelIcon = 0x02,
  [CCode (member = "HIGHLIGHT_CANCEL")]
  HighlightCancel = 0x04,
}

(where "member" is something I invented)

Is something like this possible? It would make it a bit more
readable. But maybe there is no point in that for a vapi-file?

Cheers,
Jan-Jaap



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