self.writable = writable
self.bits = bits
self.anonymous_node = anonymous_node
+ self.private = False
def __cmp__(self, other):
return cmp(self.name, other.name)
node.attrib.get('writable') == '1',
node.attrib.get('bits'),
anonymous_node=anonymous_node)
+ field.private = node.attrib.get('private') == '1'
self._parse_generic_attribs(node, field)
return field
attrs.append(('writable', '1'))
if field.bits:
attrs.append(('bits', str(field.bits)))
+ if field.private:
+ attrs.append(('private', '1'))
with self.tagcontext('field', attrs):
self._write_generic(field)
self._write_type(field.type)
}
static PyObject *
+symbol_get_private (PyGISourceSymbol *self,
+ void *context)
+{
+ return PyBool_FromLong (self->symbol->private);
+}
+
+static PyObject *
symbol_get_ident (PyGISourceSymbol *self,
void *context)
{
{ "const_string", (getter)symbol_get_const_string, NULL, NULL},
{ "source_filename", (getter)symbol_get_source_filename, NULL, NULL},
{ "line", (getter)symbol_get_line, NULL, NULL},
+ { "private", (getter)symbol_get_private, NULL, NULL},
{ 0 }
};
fracconst ([0-9]*\.[0-9]+)|([0-9]+\.)
exppart [eE][-+]?[0-9]+
floatsuffix [fFlL]
-chartext ([^\\\'])|(\\.)
+chartext ([^\\\'])|(\\.)
stringtext ([^\\\"])|(\\.)
%%
[\t\f\v\r ]+ { /* Ignore whitespace. */ }
"/*" { parse_comment(scanner); }
+"/*"[\t ]*<[\t ]*"private"[\t ]*>" */" { scanner->private = TRUE; }
+"/*"[\t ]*<[\t ]*"public"[\t ]*>" */" { scanner->private = FALSE; }
"//".* { }
"#define "[a-zA-Z_][a-zA-Z_0-9]*"(" { yyless (yyleng - 1); return FUNCTION_MACRO; }
struct_or_union
: STRUCT
{
+ scanner->private = FALSE;
$$ = gi_source_struct_new (NULL);
}
| UNION
{
+ scanner->private = FALSE;
$$ = gi_source_union_new (NULL);
}
;
else
sym->type = CSYMBOL_TYPE_MEMBER;
gi_source_symbol_merge_type (sym, gi_source_type_copy ($1));
- $$ = g_list_append ($$, sym);
+ sym->private = scanner->private;
+ $$ = g_list_append ($$, sym);
}
ctype_free ($1);
}
enum_specifier
: ENUM identifier_or_typedef_name '{' enumerator_list '}'
{
+ scanner->private = FALSE;
$$ = gi_source_enum_new ($2);
$$->child_list = $4;
$$->is_bitfield = is_bitfield;
}
| ENUM '{' enumerator_list '}'
{
+ scanner->private = FALSE;
$$ = gi_source_enum_new (NULL);
$$->child_list = $3;
$$->is_bitfield = is_bitfield;
}
| ENUM identifier_or_typedef_name '{' enumerator_list ',' '}'
{
+ scanner->private = FALSE;
$$ = gi_source_enum_new ($2);
$$->child_list = $4;
$$->is_bitfield = is_bitfield;
}
| ENUM '{' enumerator_list ',' '}'
{
+ scanner->private = FALSE;
$$ = gi_source_enum_new (NULL);
$$->child_list = $3;
$$->is_bitfield = is_bitfield;
}
| ENUM identifier_or_typedef_name
{
+ scanner->private = FALSE;
$$ = gi_source_enum_new ($2);
}
;
}
enumerator
{
- $$ = g_list_append (NULL, $2);
+ if (!scanner->private)
+ {
+ $$ = g_list_append (NULL, $2);
+ }
}
| enumerator_list ',' enumerator
{
- $$ = g_list_append ($1, $3);
+ if (!scanner->private)
+ {
+ $$ = g_list_append ($1, $3);
+ }
}
;
{
char *current_filename;
gboolean macro_scan;
+ gboolean private; /* set by gtk-doc comment <private>/<public> */
GSList *symbols;
GList *filenames;
GSList *comments; /* _GIComment */
char *ident;
GISourceType *base_type;
gboolean const_int_set;
+ gboolean private;
int const_int;
char *const_string;
gboolean const_double_set;
return self._symbol.line
@property
+ def private(self):
+ return self._symbol.private
+
+ @property
def position(self):
return Position(self._symbol.source_filename,
self._symbol.line)
if prefixlen > 0:
name = child.ident[prefixlen:]
else:
+ if child.ident is None:
+ continue
# Ok, the enum members don't have a consistent prefix
# among them, so let's just remove the global namespace
# prefix.
# ast.Fields are assumed to be read-write
# (except for Objects, see also glibtransformer.py)
node = ast.Field(symbol.ident, ftype,
- readable=True, writable=True, bits=symbol.const_int)
+ readable=True, writable=True,
+ bits=symbol.const_int)
+ if symbol.private:
+ node.readable = False
+ node.writable = False
+ node.private = True
return node
def _create_typedef(self, symbol):
</callback>
</field>
</record>
+ <bitfield name="TestPrivateEnum" c:type="RegressTestPrivateEnum">
+ <member name="before"
+ value="1"
+ c:identifier="REGRESS_TEST_PUBLIC_ENUM_BEFORE"/>
+ <member name="after"
+ value="4"
+ c:identifier="REGRESS_TEST_PUBLIC_ENUM_AFTER"/>
+ </bitfield>
+ <record name="TestPrivateStruct" c:type="RegressTestPrivateStruct">
+ <field name="this_is_public_before" writable="1">
+ <type name="gint" c:type="gint"/>
+ </field>
+ <field name="this_is_private" readable="0" private="1">
+ <type name="gint" c:type="gint"/>
+ </field>
+ <field name="this_is_public_after" writable="1">
+ <type name="gint" c:type="gint"/>
+ </field>
+ </record>
<record name="TestSimpleBoxedA"
c:type="RegressTestSimpleBoxedA"
glib:type-name="RegressTestSimpleBoxedA"
*/
typedef RegressIntset RegressIntSet;
+/* private testing */
+
+typedef struct {
+ gint this_is_public_before;
+ /* < private > */
+ gint this_is_private;
+ /* < public > */
+ gint this_is_public_after;
+} RegressTestPrivateStruct;
+
+typedef enum {
+ REGRESS_TEST_PUBLIC_ENUM_BEFORE = 1 << 0,
+ /* <private> */
+ REGRESS_TEST_PRIVATE_ENUM = 1 << 1,
+ /* <public> */
+ REGRESS_TEST_PUBLIC_ENUM_AFTER = 1 << 2,
+} RegressTestPrivateEnum;
+
#endif /* __GITESTTYPES_H__ */