* @argv: (array length=argc) (inout) (allow-none):
*/
-/**
- * GIOCondition: (type bitfield)
- **/
-
/**
* GSourceFunc:
* @data: (closure data):
*
* Copyright (c) 1997 Sandro Sigala <ssigala@globalnet.it>
* Copyright (c) 2007-2008 Jürg Billeter <j@bitron.ch>
+ * Copyright (c) 2010 Andreas Rottmann <a.rottmann@gmx.at>
*
* All rights reserved.
*
#define YY_DECL int yylex (GISourceScanner *scanner)
static int yywrap (void);
static void parse_comment (GISourceScanner *scanner);
+static void parse_trigraph (GISourceScanner *scanner);
static void process_linemarks (GISourceScanner *scanner);
static int check_identifier (GISourceScanner *scanner, const char *);
static int parse_ignored_macro (void);
[\t\f\v\r ]+ { /* Ignore whitespace. */ }
"/*" { parse_comment(scanner); }
-"/*"[\t ]*<[\t ]*"private"[\t ]*>" */" { scanner->private = TRUE; }
-"/*"[\t ]*<[\t ]*"public"[\t ]*>" */" { scanner->private = FALSE; }
+"/*"[\t ]?<[\t ,=A-Za-z0-9_]+>[\t ]?"*/" { parse_trigraph(scanner); }
"//".* { }
"#define "[a-zA-Z_][a-zA-Z_0-9]*"(" { yyless (yyleng - 1); return FUNCTION_MACRO; }
return TRUE;
}
+
+static void
+parse_trigraph (GISourceScanner *scanner)
+{
+ char **items;
+ char *start, *end;
+ int i;
+
+ start = g_strstr_len (yytext, yyleng, "<");
+ g_assert (start != NULL);
+ end = g_strstr_len (yytext, yyleng, ">");
+ g_assert (end != NULL);
+ *end = '\0';
+ items = g_strsplit (start + 1, ",", 0);
+ for (i = 0; items[i] != NULL; i++) {
+ char *item = items[i];
+ g_strstrip (item);
+ if (strcmp (item, "public") == 0)
+ scanner->private = FALSE;
+ else if (strcmp (item, "private") == 0)
+ scanner->private = TRUE;
+ else if (strcmp (item, "flags") == 0)
+ scanner->flags = TRUE;
+ }
+ g_strfreev (items);
+}
;
enum_specifier
- : ENUM identifier_or_typedef_name '{' enumerator_list '}'
+ : enum_keyword identifier_or_typedef_name '{' enumerator_list '}'
{
- scanner->private = FALSE;
$$ = gi_source_enum_new ($2);
$$->child_list = $4;
- $$->is_bitfield = is_bitfield;
+ $$->is_bitfield = is_bitfield || scanner->flags;
last_enum_value = -1;
}
- | ENUM '{' enumerator_list '}'
+ | enum_keyword '{' enumerator_list '}'
{
- scanner->private = FALSE;
$$ = gi_source_enum_new (NULL);
$$->child_list = $3;
- $$->is_bitfield = is_bitfield;
+ $$->is_bitfield = is_bitfield || scanner->flags;
last_enum_value = -1;
}
- | ENUM identifier_or_typedef_name '{' enumerator_list ',' '}'
+ | enum_keyword identifier_or_typedef_name '{' enumerator_list ',' '}'
{
- scanner->private = FALSE;
$$ = gi_source_enum_new ($2);
$$->child_list = $4;
- $$->is_bitfield = is_bitfield;
+ $$->is_bitfield = is_bitfield || scanner->flags;
last_enum_value = -1;
}
- | ENUM '{' enumerator_list ',' '}'
+ | enum_keyword '{' enumerator_list ',' '}'
{
- scanner->private = FALSE;
$$ = gi_source_enum_new (NULL);
$$->child_list = $3;
- $$->is_bitfield = is_bitfield;
+ $$->is_bitfield = is_bitfield || scanner->flags;
last_enum_value = -1;
}
- | ENUM identifier_or_typedef_name
+ | enum_keyword identifier_or_typedef_name
{
- scanner->private = FALSE;
$$ = gi_source_enum_new ($2);
}
;
+enum_keyword
+ : ENUM
+ {
+ scanner->flags = FALSE;
+ scanner->private = FALSE;
+ }
+ ;
+
enumerator_list
:
{
char *current_filename;
gboolean macro_scan;
gboolean private; /* set by gtk-doc comment <private>/<public> */
+ gboolean flags; /* set by gtk-doc comment <flags> */
GSList *symbols;
GList *filenames;
GSList *comments; /* _GIComment */
shared-library="libannotation.so"
c:identifier-prefixes="Annotation"
c:symbol-prefixes="annotation">
+ <bitfield name="Bitfield" c:type="AnnotationBitfield">
+ <member name="foo" value="1" c:identifier="ANN_FLAG_FOO"/>
+ <member name="bar" value="2" c:identifier="ANN_FLAG_BAR"/>
+ </bitfield>
<callback name="Callback" c:type="AnnotationCallback">
<doc xml:whitespace="preserve">This is a callback.</doc>
<return-value transfer-ownership="none">
#include <glib-object.h>
+typedef enum /*< flags,prefix=ANN >*/
+{
+ ANN_FLAG_FOO = 1,
+ ANN_FLAG_BAR = 2
+} AnnotationBitfield;
+
/**
* AnnotationCallback:
* @in: (in) (transfer none): array of ints