Commit b8e31724 authored by Andreas Rottmann's avatar Andreas Rottmann

Bug 573332 - Allow annotation of enums as bitfields

Add support for a `(type bitfield)' annotation for enums.
Signed-off-by: default avatarAndreas Rottmann <a.rottmann@gmx.at>
parent 5b4df314
......@@ -19,4 +19,6 @@
* @context: (allow-none):
*/
/**
* GIOCondition: (type bitfield)
**/
......@@ -59,6 +59,9 @@ OPT_SCOPE = 'scope'
OPT_TRANSFER = 'transfer'
OPT_TYPE = 'type'
# Specific option values
OPT_VAL_BITFIELD = 'bitfield'
# Array options - array specific annotations
OPT_ARRAY_FIXED_SIZE = 'fixed-size'
OPT_ARRAY_LENGTH = 'length'
......@@ -344,6 +347,10 @@ class AnnotationApplier(object):
self._parse_node_common(enum, block)
if block:
enum.doc = block.comment
type_opt = block.options.get(OPT_TYPE)
if type_opt and type_opt.one() == OPT_VAL_BITFIELD:
# This is hack, but hey, it works :-)
enum.__class__ = Bitfield
def _parse_bitfield(self, bitfield):
block = self._blocks.get(bitfield.symbol)
......
......@@ -42,11 +42,11 @@ and/or use gtk-doc annotations. -->
</parameter>
</parameters>
</callback>
<enumeration name="FlagType" c:type="UtilityFlagType">
<member name="a" value="0" c:identifier="UTILITY_FLAG_A"/>
<member name="b" value="1" c:identifier="UTILITY_FLAG_B"/>
<member name="c" value="2" c:identifier="UTILITY_FLAG_C"/>
</enumeration>
<bitfield name="FlagType" c:type="UtilityFlagType">
<member name="a" value="1" c:identifier="UTILITY_FLAG_A"/>
<member name="b" value="2" c:identifier="UTILITY_FLAG_B"/>
<member name="c" value="4" c:identifier="UTILITY_FLAG_C"/>
</bitfield>
<class name="Object"
c:type="UtilityObject"
parent="GObject.Object"
......
......@@ -29,11 +29,11 @@
</parameter>
</parameters>
</callback>
<enumeration name="FlagType">
<member name="a" value="0"/>
<member name="b" value="1"/>
<member name="c" value="2"/>
</enumeration>
<bitfield name="FlagType">
<member name="a" value="1"/>
<member name="b" value="2"/>
<member name="c" value="4"/>
</bitfield>
<class name="Object" parent="GObject.Object" glib:type-struct="ObjectClass" glib:type-name="UtilityObject" glib:get-type="utility_object_get_type">
<field name="parent_instance">
<type name="GObject.Object"/>
......
......@@ -2,6 +2,10 @@
G_DEFINE_TYPE (UtilityObject, utility_object, G_TYPE_OBJECT);
/**
* UtilityFlagType: (type bitfield)
**/
static void
utility_object_class_init (UtilityObjectClass *klass)
{
......
......@@ -62,9 +62,9 @@ typedef enum
typedef enum
{
UTILITY_FLAG_A,
UTILITY_FLAG_B,
UTILITY_FLAG_C
UTILITY_FLAG_A = 1,
UTILITY_FLAG_B = 2,
UTILITY_FLAG_C = 4
} UtilityFlagType;
typedef struct
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment