summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomasz Miąsko <tomasz.miasko@gmail.com>2019-01-06 00:00:00 +0000
committerTomasz Miąsko <tomasz.miasko@gmail.com>2019-01-06 21:05:15 +0100
commit1f0965e379035be51ae96d5761358ec088fb3421 (patch)
tree454e0c58f273dd0f4cba002bfc3cdfb88e267942
parent90121df20ddf18afdb1c25212035748ff54519c5 (diff)
downloadgobject-introspection-1f0965e379035be51ae96d5761358ec088fb3421.tar.gz
scanner: Remove incorrect c:type from fields with array type
Neither `_create_source_type` nor `_create_complete_source_type` actually support fixed size arrays, so previously generated C types were incorrect. Remove C types from array fields instead of producing incorrect ones. Fixes issue #145.
-rw-r--r--giscanner/transformer.py13
-rw-r--r--tests/scanner/Regress-1.0-expected.gir22
-rw-r--r--tests/scanner/Utility-1.0-expected.gir2
3 files changed, 11 insertions, 26 deletions
diff --git a/giscanner/transformer.py b/giscanner/transformer.py
index a74cb6ba..1b5c80eb 100644
--- a/giscanner/transformer.py
+++ b/giscanner/transformer.py
@@ -565,20 +565,9 @@ raise ValueError."""
ftype = ast.Array(None, synthesized_type, complete_ctype=complete_ctype)
else:
ctype = self._create_source_type(source_type)
- canonical_ctype = self._canonicalize_ctype(ctype)
- if canonical_ctype[-1] == '*':
- derefed_name = canonical_ctype[:-1]
- else:
- derefed_name = canonical_ctype
- 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)
+ ftype = ast.Array(None, from_ctype)
child_list = list(symbol.base_type.child_list)
ftype.zeroterminated = False
if child_list:
diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir
index 5f303a4e..0ee763f1 100644
--- a/tests/scanner/Regress-1.0-expected.gir
+++ b/tests/scanner/Regress-1.0-expected.gir
@@ -99,15 +99,13 @@ and/or use gtk-doc annotations. -->
<union>
<source-position filename="regress.h" line="1480"/>
<field name="a" writable="1">
- <array zero-terminated="0"
- c:type="RegressLikeGnomeKeyringPasswordSchema"
- fixed-size="2">
+ <array zero-terminated="0" fixed-size="2">
<type name="LikeGnomeKeyringPasswordSchema"
c:type="RegressLikeGnomeKeyringPasswordSchema*"/>
</array>
</field>
<field name="padding" writable="1">
- <array zero-terminated="0" c:type="guint" fixed-size="4">
+ <array zero-terminated="0" fixed-size="4">
<type name="guint" c:type="guint"/>
</array>
</field>
@@ -1209,9 +1207,7 @@ it says it's pointer but it's actually a string.</doc>
line="236">This is a test of an array of object in an field of a struct.</doc>
<source-position filename="annotation.h" line="244"/>
<field name="objects" writable="1">
- <array zero-terminated="0"
- c:type="RegressAnnotationObject"
- fixed-size="10">
+ <array zero-terminated="0" fixed-size="10">
<type name="AnnotationObject" c:type="RegressAnnotationObject*"/>
</array>
</field>
@@ -1235,7 +1231,7 @@ it says it's pointer but it's actually a string.</doc>
</field>
</record>
<field name="padding" writable="1">
- <array zero-terminated="0" c:type="guint" fixed-size="4">
+ <array zero-terminated="0" fixed-size="4">
<type name="guint" c:type="guint"/>
</array>
</field>
@@ -2084,7 +2080,7 @@ uses a C sugar return type.</doc>
</callback>
</field>
<field name="_reserved">
- <array zero-terminated="0" c:type="GCallback" fixed-size="4">
+ <array zero-terminated="0" fixed-size="4">
<type name="GObject.Callback" c:type="GCallback"/>
</array>
</field>
@@ -2421,7 +2417,7 @@ exposed to language bindings.</doc>
<type name="gint" c:type="int"/>
</field>
<field name="lines" writable="1">
- <array zero-terminated="0" c:type="char" fixed-size="80">
+ <array zero-terminated="0" fixed-size="80">
<type name="gchar" c:type="char"/>
</array>
</field>
@@ -2510,7 +2506,7 @@ exposed to language bindings.</doc>
<type name="gint" c:type="int"/>
</field>
<field name="attributes" writable="1">
- <array zero-terminated="0" c:type="gpointer" fixed-size="32">
+ <array zero-terminated="0" fixed-size="32">
<type name="gpointer" c:type="gpointer"/>
</array>
</field>
@@ -2521,7 +2517,7 @@ exposed to language bindings.</doc>
<record name="LikeXklConfigItem" c:type="RegressLikeXklConfigItem">
<source-position filename="regress.h" line="1415"/>
<field name="name" writable="1">
- <array zero-terminated="0" c:type="gchar" fixed-size="32">
+ <array zero-terminated="0" fixed-size="32">
<type name="gchar" c:type="gchar"/>
</array>
</field>
@@ -5090,7 +5086,7 @@ the introspection client langage.</doc>
<type name="gint" c:type="gint"/>
</field>
<field name="array" writable="1">
- <array zero-terminated="0" c:type="gint" fixed-size="10">
+ <array zero-terminated="0" fixed-size="10">
<type name="gint" c:type="gint"/>
</array>
</field>
diff --git a/tests/scanner/Utility-1.0-expected.gir b/tests/scanner/Utility-1.0-expected.gir
index 2521efbb..010bd45b 100644
--- a/tests/scanner/Utility-1.0-expected.gir
+++ b/tests/scanner/Utility-1.0-expected.gir
@@ -141,7 +141,7 @@ and/or use gtk-doc annotations. -->
<type name="guint" c:type="guint"/>
</field>
<field name="data" writable="1">
- <array zero-terminated="0" c:type="guint8" fixed-size="16">
+ <array zero-terminated="0" fixed-size="16">
<type name="guint8" c:type="guint8"/>
</array>
</field>