summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrzesimir Nowak <qdlacz@gmail.com>2012-07-04 22:52:02 +0200
committerColin Walters <walters@verbum.org>2012-07-07 17:13:40 -0400
commit3943988d5addbea4603f9b4ee5103c604d03e8f4 (patch)
treee5ca09e5c92ad4b1215d8e37ebaa071064cd60e6
parent09fe4ca9b3e816f87698761f4b66bc2d0c25e4e0 (diff)
downloadgobject-introspection-3943988d5addbea4603f9b4ee5103c604d03e8f4.tar.gz
giscanner: Write detailed information in "type" tag's "c:type" attribute.
That is - write also type qualifiers (const and volatile here). Update existing tests and add a new struct to regress.h having members with type qualifiers. https://bugzilla.gnome.org/show_bug.cgi?id=656445
-rw-r--r--giscanner/ast.py4
-rw-r--r--giscanner/girwriter.py4
-rw-r--r--giscanner/transformer.py84
-rw-r--r--tests/scanner/Annotation-1.0-expected.gir10
-rw-r--r--tests/scanner/Foo-1.0-expected.gir18
-rw-r--r--tests/scanner/Regress-1.0-expected.gir90
-rw-r--r--tests/scanner/Utility-1.0-expected.gir6
-rw-r--r--tests/scanner/regress.h14
8 files changed, 163 insertions, 67 deletions
diff --git a/giscanner/ast.py b/giscanner/ast.py
index 456f921a..6945d60d 100644
--- a/giscanner/ast.py
+++ b/giscanner/ast.py
@@ -45,7 +45,8 @@ from a C type string, or a gtype_name (from g_type_name()).
target_foreign=None,
_target_unknown=False,
is_const=False,
- origin_symbol=None):
+ origin_symbol=None,
+ complete_ctype=None):
self.ctype = ctype
self.gtype_name = gtype_name
self.origin_symbol = origin_symbol
@@ -68,6 +69,7 @@ from a C type string, or a gtype_name (from g_type_name()).
self.target_giname = target_giname
self.target_foreign = target_foreign
self.is_const = is_const
+ self.complete_ctype = complete_ctype
@property
def resolved(self):
diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py
index bfe82a85..cb13d21f 100644
--- a/giscanner/girwriter.py
+++ b/giscanner/girwriter.py
@@ -272,7 +272,9 @@ and/or use gtk-doc annotations. ''')
def _write_type(self, ntype, relation=None, function=None):
assert isinstance(ntype, ast.Type), ntype
attrs = []
- if ntype.ctype:
+ if ntype.complete_ctype:
+ attrs.append(('c:type', ntype.complete_ctype))
+ elif ntype.ctype:
attrs.append(('c:type', ntype.ctype))
if isinstance(ntype, ast.Varargs):
with self.tagcontext('varargs', []):
diff --git a/giscanner/transformer.py b/giscanner/transformer.py
index cf284d8a..91d00afc 100644
--- a/giscanner/transformer.py
+++ b/giscanner/transformer.py
@@ -32,7 +32,7 @@ from .sourcescanner import (
CSYMBOL_TYPE_FUNCTION, CSYMBOL_TYPE_TYPEDEF, CSYMBOL_TYPE_STRUCT,
CSYMBOL_TYPE_ENUM, CSYMBOL_TYPE_UNION, CSYMBOL_TYPE_OBJECT,
CSYMBOL_TYPE_MEMBER, CSYMBOL_TYPE_ELLIPSIS, CSYMBOL_TYPE_CONST,
- TYPE_QUALIFIER_CONST)
+ TYPE_QUALIFIER_CONST, TYPE_QUALIFIER_VOLATILE)
class TransformerException(Exception):
pass
@@ -435,6 +435,45 @@ raise ValueError."""
value = 'gpointer'
return value
+ def _create_complete_source_type(self, source_type):
+ assert source_type is not None
+
+ const = (source_type.type_qualifier & TYPE_QUALIFIER_CONST)
+ volatile = (source_type.type_qualifier & TYPE_QUALIFIER_VOLATILE)
+
+ if source_type.type == CTYPE_VOID:
+ return 'void'
+ elif source_type.type in [CTYPE_BASIC_TYPE,
+ CTYPE_TYPEDEF,
+ CTYPE_STRUCT,
+ CTYPE_UNION,
+ CTYPE_ENUM]:
+ value = source_type.name
+ if const:
+ value = 'const ' + value
+ if volatile:
+ value = 'volatile ' + value
+ elif source_type.type == CTYPE_ARRAY:
+ return self._create_complete_source_type(source_type.base_type)
+ elif source_type.type == CTYPE_POINTER:
+ value = self._create_complete_source_type(source_type.base_type) + '*'
+ # TODO: handle pointer to function as a special case?
+ if const:
+ value += ' const'
+ if volatile:
+ value += ' volatile'
+
+ else:
+ if const:
+ value = 'gconstpointer'
+ else:
+ value = 'gpointer'
+ if volatile:
+ value = 'volatile ' + value
+ return value
+
+ return value
+
def _create_parameters(self, base_type):
# warn if we see annotations for unknown parameters
param_names = set(child.ident for child in base_type.child_list)
@@ -476,6 +515,7 @@ raise ValueError."""
# Special handling for fields; we don't have annotations on them
# to apply later, yet.
if source_type.type == CTYPE_ARRAY:
+ complete_ctype = self._create_complete_source_type(source_type)
# If the array contains anonymous unions, like in the GValue
# struct, we need to handle this specially. This is necessary
# to be able to properly calculate the size of the compound
@@ -484,7 +524,7 @@ raise ValueError."""
if (source_type.base_type.type == CTYPE_UNION and
source_type.base_type.name is None):
synthesized_type = self._synthesize_union_type(symbol, parent_symbol)
- ftype = ast.Array(None, synthesized_type)
+ ftype = ast.Array(None, synthesized_type, complete_ctype=complete_ctype)
else:
ctype = self._create_source_type(source_type)
canonical_ctype = self._canonicalize_ctype(ctype)
@@ -492,8 +532,15 @@ raise ValueError."""
derefed_name = canonical_ctype[:-1]
else:
derefed_name = canonical_ctype
- ftype = ast.Array(None, self.create_type_from_ctype_string(ctype),
- ctype=derefed_name)
+ if complete_ctype[-1] == '*':
+ derefed_complete_ctype = complete_ctype[:-1]
+ else:
+ derefed_complete_ctype = complete_ctype
+ from_ctype = self.create_type_from_ctype_string(ctype,
+ complete_ctype=complete_ctype)
+ ftype = ast.Array(None, from_ctype,
+ ctype=derefed_name,
+ complete_ctype=derefed_complete_ctype)
child_list = list(symbol.base_type.child_list)
ftype.zeroterminated = False
if child_list:
@@ -535,7 +582,9 @@ raise ValueError."""
message.warn(e)
return None
if symbol.base_type.name:
- target = self.create_type_from_ctype_string(symbol.base_type.name)
+ complete_ctype = self._create_complete_source_type(symbol.base_type)
+ target = self.create_type_from_ctype_string(symbol.base_type.name,
+ complete_ctype=complete_ctype)
else:
target = ast.TYPE_ANY
if name in ast.type_names:
@@ -588,20 +637,22 @@ raise ValueError."""
def _create_type_from_base(self, source_type, is_parameter=False, is_return=False):
ctype = self._create_source_type(source_type)
+ complete_ctype = self._create_complete_source_type(source_type)
const = ((source_type.type == CTYPE_POINTER) and
(source_type.base_type.type_qualifier & TYPE_QUALIFIER_CONST))
return self.create_type_from_ctype_string(ctype, is_const=const,
- is_parameter=is_parameter, is_return=is_return)
+ is_parameter=is_parameter, is_return=is_return,
+ complete_ctype=complete_ctype)
def _create_bare_container_type(self, base, ctype=None,
- is_const=False):
+ is_const=False, complete_ctype=None):
if base in ('GList', 'GSList', 'GLib.List', 'GLib.SList'):
if base in ('GList', 'GSList'):
name = 'GLib.' + base[1:]
else:
name = base
return ast.List(name, ast.TYPE_ANY, ctype=ctype,
- is_const=is_const)
+ is_const=is_const, complete_ctype=complete_ctype)
elif base in ('GArray', 'GPtrArray', 'GByteArray',
'GLib.Array', 'GLib.PtrArray', 'GLib.ByteArray',
'GObject.Array', 'GObject.PtrArray', 'GObject.ByteArray'):
@@ -610,13 +661,15 @@ raise ValueError."""
else:
name = 'GLib.' + base[1:]
return ast.Array(name, ast.TYPE_ANY, ctype=ctype,
- is_const=is_const)
+ is_const=is_const, complete_ctype=complete_ctype)
elif base in ('GHashTable', 'GLib.HashTable', 'GObject.HashTable'):
- return ast.Map(ast.TYPE_ANY, ast.TYPE_ANY, ctype=ctype, is_const=is_const)
+ return ast.Map(ast.TYPE_ANY, ast.TYPE_ANY, ctype=ctype, is_const=is_const,
+ complete_ctype=complete_ctype)
return None
def create_type_from_ctype_string(self, ctype, is_const=False,
- is_parameter=False, is_return=False):
+ is_parameter=False, is_return=False,
+ complete_ctype=None):
canonical = self._canonicalize_ctype(ctype)
base = canonical.replace('*', '')
@@ -625,17 +678,18 @@ raise ValueError."""
bare_utf8 = ast.TYPE_STRING.clone()
bare_utf8.ctype = None
return ast.Array(None, bare_utf8, ctype=ctype,
- is_const=is_const)
+ is_const=is_const, complete_ctype=complete_ctype)
fundamental = ast.type_names.get(base)
if fundamental is not None:
return ast.Type(target_fundamental=fundamental.target_fundamental,
ctype=ctype,
- is_const=is_const)
- container = self._create_bare_container_type(base, ctype=ctype, is_const=is_const)
+ is_const=is_const, complete_ctype=complete_ctype)
+ container = self._create_bare_container_type(base, ctype=ctype, is_const=is_const,
+ complete_ctype=complete_ctype)
if container:
return container
- return ast.Type(ctype=ctype, is_const=is_const)
+ return ast.Type(ctype=ctype, is_const=is_const, complete_ctype=complete_ctype)
def _create_parameter(self, symbol):
if symbol.type == CSYMBOL_TYPE_ELLIPSIS:
diff --git a/tests/scanner/Annotation-1.0-expected.gir b/tests/scanner/Annotation-1.0-expected.gir
index ce43b36d..2ea6c544 100644
--- a/tests/scanner/Annotation-1.0-expected.gir
+++ b/tests/scanner/Annotation-1.0-expected.gir
@@ -39,12 +39,12 @@ and/or use gtk-doc annotations. -->
<doc xml:whitespace="preserve">This is a callback.</doc>
<return-value transfer-ownership="none">
<doc xml:whitespace="preserve">array of ints</doc>
- <type name="gint" c:type="gint*"/>
+ <type name="gint" c:type="const gint*"/>
</return-value>
<parameters>
<parameter name="in" transfer-ownership="none">
<doc xml:whitespace="preserve">array of ints</doc>
- <type name="gint" c:type="gint*"/>
+ <type name="gint" c:type="const gint*"/>
</parameter>
</parameters>
</callback>
@@ -57,7 +57,7 @@ and/or use gtk-doc annotations. -->
<type name="Object" c:type="AnnotationObject*"/>
</parameter>
<parameter name="item" transfer-ownership="none">
- <type name="utf8" c:type="char*"/>
+ <type name="utf8" c:type="const char*"/>
</parameter>
<parameter name="user_data" transfer-ownership="none" closure="2">
<type name="gpointer" c:type="gpointer"/>
@@ -110,7 +110,7 @@ and/or use gtk-doc annotations. -->
</return-value>
<parameters>
<parameter name="somearg" transfer-ownership="none" allow-none="1">
- <type name="utf8" c:type="gchar*"/>
+ <type name="utf8" c:type="const gchar*"/>
</parameter>
</parameters>
</method>
@@ -659,7 +659,7 @@ it says it's pointer but it's actually a string.</doc>
<attribute name="some.annotation" value="value"/>
<attribute name="another.annotation" value="blahvalue"/>
<doc xml:whitespace="preserve">Some data.</doc>
- <type name="utf8" c:type="gchar*"/>
+ <type name="utf8" c:type="const gchar*"/>
</parameter>
</parameters>
</function>
diff --git a/tests/scanner/Foo-1.0-expected.gir b/tests/scanner/Foo-1.0-expected.gir
index b18375a1..b0c36340 100644
--- a/tests/scanner/Foo-1.0-expected.gir
+++ b/tests/scanner/Foo-1.0-expected.gir
@@ -446,7 +446,7 @@ uses a C sugar return type.</doc>
</method>
<method name="get_name" c:identifier="foo_object_get_name">
<return-value transfer-ownership="none">
- <type name="utf8" c:type="char*"/>
+ <type name="utf8" c:type="const char*"/>
</return-value>
</method>
<method name="handle_glyph" c:identifier="foo_object_handle_glyph">
@@ -478,7 +478,7 @@ uses a C sugar return type.</doc>
</return-value>
<parameters>
<parameter name="target" transfer-ownership="none">
- <type name="utf8" c:type="char*"/>
+ <type name="utf8" c:type="const char*"/>
</parameter>
</parameters>
</method>
@@ -661,7 +661,7 @@ uses a C sugar return type.</doc>
<parameters>
<parameter name="r2" transfer-ownership="none">
<doc xml:whitespace="preserve">source rectangle</doc>
- <type name="Rectangle" c:type="FooRectangle*"/>
+ <type name="Rectangle" c:type="const FooRectangle*"/>
</parameter>
</parameters>
</method>
@@ -910,7 +910,7 @@ exposed to language bindings.</doc>
<type name="gint" c:type="int"/>
</field>
<field name="lines" writable="1">
- <array zero-terminated="0" c:type="gchar" fixed-size="80">
+ <array zero-terminated="0" c:type="char" fixed-size="80">
<type name="gchar" c:type="char"/>
</array>
</field>
@@ -936,7 +936,7 @@ exposed to language bindings.</doc>
</return-value>
<parameters>
<parameter name="param" transfer-ownership="none">
- <type name="utf8" c:type="char*"/>
+ <type name="utf8" c:type="const char*"/>
</parameter>
<parameter transfer-ownership="none">
<varargs>
@@ -1143,14 +1143,14 @@ exposed to language bindings.</doc>
</return-value>
<parameters>
<parameter name="param" transfer-ownership="none">
- <type name="utf8" c:type="char*"/>
+ <type name="utf8" c:type="const char*"/>
</parameter>
</parameters>
</function>
<function name="test_const_char_retval"
c:identifier="foo_test_const_char_retval">
<return-value transfer-ownership="none">
- <type name="utf8" c:type="char*"/>
+ <type name="utf8" c:type="const char*"/>
</return-value>
</function>
<function name="test_const_struct_param"
@@ -1160,14 +1160,14 @@ exposed to language bindings.</doc>
</return-value>
<parameters>
<parameter name="param" transfer-ownership="none">
- <type name="Struct" c:type="FooStruct*"/>
+ <type name="Struct" c:type="const FooStruct*"/>
</parameter>
</parameters>
</function>
<function name="test_const_struct_retval"
c:identifier="foo_test_const_struct_retval">
<return-value transfer-ownership="none">
- <type name="Struct" c:type="FooStruct*"/>
+ <type name="Struct" c:type="const FooStruct*"/>
</return-value>
</function>
<function name="test_string_array" c:identifier="foo_test_string_array">
diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir
index 3f2b6ddf..0b39bff8 100644
--- a/tests/scanner/Regress-1.0-expected.gir
+++ b/tests/scanner/Regress-1.0-expected.gir
@@ -275,7 +275,7 @@ use it should be.</doc>
</return-value>
<parameters>
<parameter name="error" transfer-ownership="none">
- <type name="GLib.Error" c:type="GError*"/>
+ <type name="GLib.Error" c:type="const GError*"/>
</parameter>
</parameters>
</callback>
@@ -351,7 +351,7 @@ use it should be.</doc>
glib:nick="value4"/>
<function name="param" c:identifier="regress_test_enum_param">
<return-value transfer-ownership="none">
- <type name="utf8" c:type="gchar*"/>
+ <type name="utf8" c:type="const gchar*"/>
</return-value>
<parameters>
<parameter name="e" transfer-ownership="none">
@@ -502,7 +502,7 @@ use it should be.</doc>
<parameters>
<parameter name="obj" transfer-ownership="none">
<type name="TestFundamentalObject"
- c:type="RegressTestFundamentalObject*"/>
+ c:type="const RegressTestFundamentalObject*"/>
</parameter>
</parameters>
</callback>
@@ -534,7 +534,7 @@ use it should be.</doc>
</return-value>
<parameters>
<parameter name="data" transfer-ownership="none">
- <type name="utf8" c:type="char*"/>
+ <type name="utf8" c:type="const char*"/>
</parameter>
</parameters>
</constructor>
@@ -621,7 +621,7 @@ use it should be.</doc>
</return-value>
<parameters>
<parameter name="x" transfer-ownership="none">
- <type name="utf8" c:type="char*"/>
+ <type name="utf8" c:type="const char*"/>
</parameter>
</parameters>
</constructor>
@@ -686,7 +686,7 @@ case.</doc>
<parameters>
<parameter name="somestr" transfer-ownership="none">
<doc xml:whitespace="preserve">Meaningless string</doc>
- <type name="utf8" c:type="char*"/>
+ <type name="utf8" c:type="const char*"/>
</parameter>
</parameters>
</virtual-method>
@@ -700,7 +700,7 @@ case.</doc>
<parameters>
<parameter name="somestr" transfer-ownership="none">
<doc xml:whitespace="preserve">Meaningless string</doc>
- <type name="utf8" c:type="char*"/>
+ <type name="utf8" c:type="const char*"/>
</parameter>
</parameters>
</method>
@@ -983,7 +983,7 @@ raise an error.</doc>
<type name="gint" c:type="int*"/>
</parameter>
<parameter name="foo" transfer-ownership="none">
- <type name="utf8" c:type="char*"/>
+ <type name="utf8" c:type="const char*"/>
</parameter>
<parameter name="q"
direction="out"
@@ -1020,7 +1020,7 @@ raise an error.</doc>
<type name="gint" c:type="int*"/>
</parameter>
<parameter name="foo" transfer-ownership="none">
- <type name="utf8" c:type="char*"/>
+ <type name="utf8" c:type="const char*"/>
</parameter>
<parameter name="q"
direction="out"
@@ -1237,7 +1237,7 @@ Use with regress_test_obj_emit_sig_with_obj</doc>
</parameter>
<parameter name="somestr" transfer-ownership="none">
<doc xml:whitespace="preserve">Meaningless string</doc>
- <type name="utf8" c:type="char*"/>
+ <type name="utf8" c:type="const char*"/>
</parameter>
</parameters>
</callback>
@@ -1357,7 +1357,8 @@ Use with regress_test_obj_emit_sig_with_obj</doc>
<function name="const_return"
c:identifier="regress_test_simple_boxed_a_const_return">
<return-value transfer-ownership="none">
- <type name="TestSimpleBoxedA" c:type="RegressTestSimpleBoxedA*"/>
+ <type name="TestSimpleBoxedA"
+ c:type="const RegressTestSimpleBoxedA*"/>
</return-value>
</function>
</record>
@@ -1507,6 +1508,29 @@ Use with regress_test_obj_emit_sig_with_obj</doc>
<type name="gpointer" c:type="gpointer"/>
</field>
</union>
+ <record name="TestStructF" c:type="RegressTestStructF">
+ <field name="ref_count" writable="1">
+ <type name="gint" c:type="volatile gint"/>
+ </field>
+ <field name="data1" writable="1">
+ <type name="gint" c:type="const gint*"/>
+ </field>
+ <field name="data2" writable="1">
+ <type name="gint" c:type="const gint* const"/>
+ </field>
+ <field name="data3" writable="1">
+ <type name="gint" c:type="const gint* const* const"/>
+ </field>
+ <field name="data4" writable="1">
+ <type name="gint" c:type="const gint** const*"/>
+ </field>
+ <field name="data5" writable="1">
+ <type name="gint" c:type="volatile gint* const"/>
+ </field>
+ <field name="data6" writable="1">
+ <type name="gint" c:type="const gint* volatile"/>
+ </field>
+ </record>
<record name="TestStructFixedArray" c:type="RegressTestStructFixedArray">
<field name="just_int" writable="1">
<type name="gint" c:type="gint"/>
@@ -2298,7 +2322,7 @@ call and can be released on return.</doc>
c:identifier="regress_test_enum_param"
moved-to="TestEnum.param">
<return-value transfer-ownership="none">
- <type name="utf8" c:type="gchar*"/>
+ <type name="utf8" c:type="const gchar*"/>
</return-value>
<parameters>
<parameter name="e" transfer-ownership="none">
@@ -2435,7 +2459,7 @@ element-type annotation.</doc>
</return-value>
<parameters>
<parameter name="in" transfer-ownership="none">
- <type name="GLib.HashTable" c:type="GHashTable*">
+ <type name="GLib.HashTable" c:type="const GHashTable*">
<type name="utf8"/>
<type name="utf8"/>
</type>
@@ -2459,7 +2483,7 @@ element-type annotation.</doc>
<function name="test_ghash_nothing_return"
c:identifier="regress_test_ghash_nothing_return">
<return-value transfer-ownership="none">
- <type name="GLib.HashTable" c:type="GHashTable*">
+ <type name="GLib.HashTable" c:type="const GHashTable*">
<type name="utf8"/>
<type name="utf8"/>
</type>
@@ -2481,7 +2505,7 @@ element-type annotation.</doc>
</return-value>
<parameters>
<parameter name="in" transfer-ownership="none" allow-none="1">
- <type name="GLib.HashTable" c:type="GHashTable*">
+ <type name="GLib.HashTable" c:type="const GHashTable*">
<type name="utf8"/>
<type name="utf8"/>
</type>
@@ -2499,7 +2523,7 @@ element-type annotation.</doc>
caller-allocates="0"
transfer-ownership="full"
allow-none="1">
- <type name="GLib.HashTable" c:type="GHashTable**">
+ <type name="GLib.HashTable" c:type="const GHashTable**">
<type name="utf8"/>
<type name="utf8"/>
</type>
@@ -2509,7 +2533,7 @@ element-type annotation.</doc>
<function name="test_ghash_null_return"
c:identifier="regress_test_ghash_null_return">
<return-value transfer-ownership="none">
- <type name="GLib.HashTable" c:type="GHashTable*">
+ <type name="GLib.HashTable" c:type="const GHashTable*">
<type name="utf8"/>
<type name="utf8"/>
</type>
@@ -2538,7 +2562,7 @@ element-type annotation.</doc>
</return-value>
<parameters>
<parameter name="in" transfer-ownership="none">
- <type name="GLib.List" c:type="GList*">
+ <type name="GLib.List" c:type="const GList*">
<type name="utf8"/>
</type>
</parameter>
@@ -2560,7 +2584,7 @@ element-type annotation.</doc>
<function name="test_glist_nothing_return"
c:identifier="regress_test_glist_nothing_return">
<return-value transfer-ownership="none">
- <type name="GLib.List" c:type="GList*">
+ <type name="GLib.List" c:type="const GList*">
<type name="utf8"/>
</type>
</return-value>
@@ -2626,7 +2650,7 @@ element-type annotation.</doc>
</return-value>
<parameters>
<parameter name="in" transfer-ownership="none">
- <type name="GLib.SList" c:type="GSList*">
+ <type name="GLib.SList" c:type="const GSList*">
<type name="utf8"/>
</type>
</parameter>
@@ -2648,7 +2672,7 @@ element-type annotation.</doc>
<function name="test_gslist_nothing_return"
c:identifier="regress_test_gslist_nothing_return">
<return-value transfer-ownership="none">
- <type name="GLib.SList" c:type="GSList*">
+ <type name="GLib.SList" c:type="const GSList*">
<type name="utf8"/>
</type>
</return-value>
@@ -2814,7 +2838,7 @@ element-type annotation.</doc>
<type name="gint" c:type="int*"/>
</parameter>
<parameter name="in" transfer-ownership="none">
- <type name="utf8" c:type="char*"/>
+ <type name="utf8" c:type="const char*"/>
</parameter>
</parameters>
</function>
@@ -2825,7 +2849,7 @@ element-type annotation.</doc>
</return-value>
<parameters>
<parameter name="v" transfer-ownership="none">
- <type name="GObject.Value" c:type="GValue*"/>
+ <type name="GObject.Value" c:type="const GValue*"/>
</parameter>
</parameters>
</function>
@@ -2966,7 +2990,7 @@ What we're testing here is that the scanner ignores the @a nested inside XML.</d
c:identifier="regress_test_simple_boxed_a_const_return"
moved-to="TestSimpleBoxedA.const_return">
<return-value transfer-ownership="none">
- <type name="TestSimpleBoxedA" c:type="RegressTestSimpleBoxedA*"/>
+ <type name="TestSimpleBoxedA" c:type="const RegressTestSimpleBoxedA*"/>
</return-value>
</function>
<function name="test_simple_callback"
@@ -3030,7 +3054,7 @@ What we're testing here is that the scanner ignores the @a nested inside XML.</d
</function>
<function name="test_strv_out_c" c:identifier="regress_test_strv_out_c">
<return-value transfer-ownership="none">
- <array c:type="char**">
+ <array c:type="const char* const*">
<type name="utf8"/>
</array>
</return-value>
@@ -3090,7 +3114,7 @@ What we're testing here is that the scanner ignores the @a nested inside XML.</d
<type name="gint" c:type="int*"/>
</parameter>
<parameter name="foo" transfer-ownership="none">
- <type name="utf8" c:type="char*"/>
+ <type name="utf8" c:type="const char*"/>
</parameter>
<parameter name="q"
direction="out"
@@ -3127,7 +3151,7 @@ What we're testing here is that the scanner ignores the @a nested inside XML.</d
<type name="gint" c:type="int*"/>
</parameter>
<parameter name="foo" transfer-ownership="none">
- <type name="utf8" c:type="char*"/>
+ <type name="utf8" c:type="const char*"/>
</parameter>
<parameter name="q"
direction="out"
@@ -3176,7 +3200,7 @@ What we're testing here is that the scanner ignores the @a nested inside XML.</d
<type name="gint" c:type="int*"/>
</parameter>
<parameter name="foo" transfer-ownership="none">
- <type name="utf8" c:type="char*"/>
+ <type name="utf8" c:type="const char*"/>
</parameter>
<parameter name="q"
direction="out"
@@ -3269,7 +3293,7 @@ What we're testing here is that the scanner ignores the @a nested inside XML.</d
<function name="test_unsigned_enum_param"
c:identifier="regress_test_unsigned_enum_param">
<return-value transfer-ownership="none">
- <type name="utf8" c:type="gchar*"/>
+ <type name="utf8" c:type="const gchar*"/>
</return-value>
<parameters>
<parameter name="e" transfer-ownership="none">
@@ -3294,7 +3318,7 @@ What we're testing here is that the scanner ignores the @a nested inside XML.</d
</return-value>
<parameters>
<parameter name="in" transfer-ownership="none">
- <type name="utf8" c:type="char*"/>
+ <type name="utf8" c:type="const char*"/>
</parameter>
</parameters>
</function>
@@ -3302,7 +3326,7 @@ What we're testing here is that the scanner ignores the @a nested inside XML.</d
c:identifier="regress_test_utf8_const_return">
<return-value transfer-ownership="none">
<doc xml:whitespace="preserve">UTF-8 string</doc>
- <type name="utf8" c:type="char*"/>
+ <type name="utf8" c:type="const char*"/>
</return-value>
</function>
<function name="test_utf8_inout" c:identifier="regress_test_utf8_inout">
@@ -3411,7 +3435,7 @@ What we're testing here is that the scanner ignores the @a nested inside XML.</d
</return-value>
<parameters>
<parameter name="value" transfer-ownership="none">
- <type name="GObject.Value" c:type="GValue*"/>
+ <type name="GObject.Value" c:type="const GValue*"/>
</parameter>
</parameters>
</function>
@@ -3419,7 +3443,7 @@ What we're testing here is that the scanner ignores the @a nested inside XML.</d
c:identifier="regress_test_value_return">
<return-value transfer-ownership="none">
<doc xml:whitespace="preserve">the int wrapped in a GValue.</doc>
- <type name="GObject.Value" c:type="GValue*"/>
+ <type name="GObject.Value" c:type="const GValue*"/>
</return-value>
<parameters>
<parameter name="i" transfer-ownership="none">
diff --git a/tests/scanner/Utility-1.0-expected.gir b/tests/scanner/Utility-1.0-expected.gir
index dec79840..747f99c1 100644
--- a/tests/scanner/Utility-1.0-expected.gir
+++ b/tests/scanner/Utility-1.0-expected.gir
@@ -50,7 +50,7 @@ and/or use gtk-doc annotations. -->
</return-value>
<parameters>
<parameter name="path" transfer-ownership="none">
- <type name="utf8" c:type="char*"/>
+ <type name="utf8" c:type="const char*"/>
</parameter>
<parameter name="user_data" transfer-ownership="none" closure="1">
<type name="gpointer" c:type="gpointer"/>
@@ -75,7 +75,7 @@ and/or use gtk-doc annotations. -->
</return-value>
<parameters>
<parameter name="path" transfer-ownership="none">
- <type name="utf8" c:type="char*"/>
+ <type name="utf8" c:type="const char*"/>
</parameter>
<parameter name="func"
transfer-ownership="none"
@@ -152,7 +152,7 @@ and/or use gtk-doc annotations. -->
</return-value>
<parameters>
<parameter name="path" transfer-ownership="none">
- <type name="utf8" c:type="char*"/>
+ <type name="utf8" c:type="const char*"/>
</parameter>
<parameter name="func"
transfer-ownership="none"
diff --git a/tests/scanner/regress.h b/tests/scanner/regress.h
index 13916374..97b9135b 100644
--- a/tests/scanner/regress.h
+++ b/tests/scanner/regress.h
@@ -262,6 +262,7 @@ typedef struct _RegressTestStructA RegressTestStructA;
typedef struct _RegressTestStructB RegressTestStructB;
typedef struct _RegressTestStructC RegressTestStructC;
typedef struct _RegressTestStructD RegressTestStructD;
+typedef struct _RegressTestStructF RegressTestStructF;
struct _RegressTestStructA
{
@@ -298,6 +299,7 @@ struct _RegressTestStructC
* @field: (type RegressTestObj):
* @list: (element-type RegressTestObj):
* @garray: (element-type RegressTestObj):
+ * @ref_count:
*/
struct _RegressTestStructD
{
@@ -325,6 +327,18 @@ struct RegressTestStructE
} some_union[2];
};
+/* This one has members with const or volatile modifiers. */
+struct _RegressTestStructF
+{
+ volatile gint ref_count;
+ const gint *data1;
+ const gint *const data2;
+ const gint *const *const data3;
+ const gint **const* data4;
+ volatile gint *const data5;
+ const gint *volatile data6;
+};
+
/* plain-old-data boxed types */
typedef struct _RegressTestSimpleBoxedA RegressTestSimpleBoxedA;
typedef struct _RegressTestSimpleBoxedB RegressTestSimpleBoxedB;