diff options
-rw-r--r-- | giscanner/ast.py | 1 | ||||
-rw-r--r-- | giscanner/girparser.py | 1 | ||||
-rw-r--r-- | giscanner/girwriter.py | 2 | ||||
-rw-r--r-- | giscanner/giscannermodule.c | 8 | ||||
-rw-r--r-- | giscanner/scannerlexer.l | 4 | ||||
-rw-r--r-- | giscanner/scannerparser.y | 20 | ||||
-rw-r--r-- | giscanner/sourcescanner.h | 2 | ||||
-rw-r--r-- | giscanner/sourcescanner.py | 4 | ||||
-rw-r--r-- | giscanner/transformer.py | 9 | ||||
-rw-r--r-- | tests/scanner/Regress-1.0-expected.gir | 19 | ||||
-rw-r--r-- | tests/scanner/regress.h | 18 |
11 files changed, 83 insertions, 5 deletions
diff --git a/giscanner/ast.py b/giscanner/ast.py index 08129cb1..1b1de5ca 100644 --- a/giscanner/ast.py +++ b/giscanner/ast.py @@ -766,6 +766,7 @@ class Field(Annotated): self.writable = writable self.bits = bits self.anonymous_node = anonymous_node + self.private = False def __cmp__(self, other): return cmp(self.name, other.name) diff --git a/giscanner/girparser.py b/giscanner/girparser.py index 8b638bf1..06901dcb 100644 --- a/giscanner/girparser.py +++ b/giscanner/girparser.py @@ -490,6 +490,7 @@ class GIRParser(object): 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 diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py index 80e1719a..43dbd26c 100644 --- a/giscanner/girwriter.py +++ b/giscanner/girwriter.py @@ -513,6 +513,8 @@ and/or use gtk-doc annotations. ''') 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) diff --git a/giscanner/giscannermodule.c b/giscanner/giscannermodule.c index b4aae792..de65d6f3 100644 --- a/giscanner/giscannermodule.c +++ b/giscanner/giscannermodule.c @@ -119,6 +119,13 @@ symbol_get_line (PyGISourceSymbol *self, } static PyObject * +symbol_get_private (PyGISourceSymbol *self, + void *context) +{ + return PyBool_FromLong (self->symbol->private); +} + +static PyObject * symbol_get_ident (PyGISourceSymbol *self, void *context) { @@ -202,6 +209,7 @@ static const PyGetSetDef _PyGISourceSymbol_getsets[] = { { "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 } }; diff --git a/giscanner/scannerlexer.l b/giscanner/scannerlexer.l index 5a5058bb..5b68ca05 100644 --- a/giscanner/scannerlexer.l +++ b/giscanner/scannerlexer.l @@ -57,7 +57,7 @@ intsuffix ([uU][lL]?[lL]?)|([lL][lL]?[uU]?) fracconst ([0-9]*\.[0-9]+)|([0-9]+\.) exppart [eE][-+]?[0-9]+ floatsuffix [fFlL] -chartext ([^\\\'])|(\\.) +chartext ([^\\\'])|(\\.) stringtext ([^\\\"])|(\\.) %% @@ -72,6 +72,8 @@ 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; } diff --git a/giscanner/scannerparser.y b/giscanner/scannerparser.y index b4df11cc..d5f9a65c 100644 --- a/giscanner/scannerparser.y +++ b/giscanner/scannerparser.y @@ -742,10 +742,12 @@ struct_or_union_specifier struct_or_union : STRUCT { + scanner->private = FALSE; $$ = gi_source_struct_new (NULL); } | UNION { + scanner->private = FALSE; $$ = gi_source_union_new (NULL); } ; @@ -771,7 +773,8 @@ struct_declaration 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); } @@ -830,6 +833,7 @@ struct_declarator enum_specifier : ENUM identifier_or_typedef_name '{' enumerator_list '}' { + scanner->private = FALSE; $$ = gi_source_enum_new ($2); $$->child_list = $4; $$->is_bitfield = is_bitfield; @@ -837,6 +841,7 @@ enum_specifier } | ENUM '{' enumerator_list '}' { + scanner->private = FALSE; $$ = gi_source_enum_new (NULL); $$->child_list = $3; $$->is_bitfield = is_bitfield; @@ -844,6 +849,7 @@ enum_specifier } | ENUM identifier_or_typedef_name '{' enumerator_list ',' '}' { + scanner->private = FALSE; $$ = gi_source_enum_new ($2); $$->child_list = $4; $$->is_bitfield = is_bitfield; @@ -851,6 +857,7 @@ enum_specifier } | ENUM '{' enumerator_list ',' '}' { + scanner->private = FALSE; $$ = gi_source_enum_new (NULL); $$->child_list = $3; $$->is_bitfield = is_bitfield; @@ -858,6 +865,7 @@ enum_specifier } | ENUM identifier_or_typedef_name { + scanner->private = FALSE; $$ = gi_source_enum_new ($2); } ; @@ -870,11 +878,17 @@ enumerator_list } 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); + } } ; diff --git a/giscanner/sourcescanner.h b/giscanner/sourcescanner.h index a7bc176c..500d84c3 100644 --- a/giscanner/sourcescanner.h +++ b/giscanner/sourcescanner.h @@ -107,6 +107,7 @@ struct _GISourceScanner { char *current_filename; gboolean macro_scan; + gboolean private; /* set by gtk-doc comment <private>/<public> */ GSList *symbols; GList *filenames; GSList *comments; /* _GIComment */ @@ -122,6 +123,7 @@ struct _GISourceSymbol char *ident; GISourceType *base_type; gboolean const_int_set; + gboolean private; int const_int; char *const_string; gboolean const_double_set; diff --git a/giscanner/sourcescanner.py b/giscanner/sourcescanner.py index e4c670b0..e449f504 100644 --- a/giscanner/sourcescanner.py +++ b/giscanner/sourcescanner.py @@ -199,6 +199,10 @@ class SourceSymbol(object): 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) diff --git a/giscanner/transformer.py b/giscanner/transformer.py index 70addb26..9f2bc153 100644 --- a/giscanner/transformer.py +++ b/giscanner/transformer.py @@ -354,6 +354,8 @@ raise ValueError.""" 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. @@ -448,7 +450,12 @@ raise ValueError.""" # 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): diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir index ebbcb0a5..15029d22 100644 --- a/tests/scanner/Regress-1.0-expected.gir +++ b/tests/scanner/Regress-1.0-expected.gir @@ -699,6 +699,25 @@ TpAccount::status-changed</doc> </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" diff --git a/tests/scanner/regress.h b/tests/scanner/regress.h index ac713070..1e68cfac 100644 --- a/tests/scanner/regress.h +++ b/tests/scanner/regress.h @@ -562,4 +562,22 @@ typedef struct _RegressIntset RegressIntset; */ 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__ */ |