summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Matthew <jonathan@d14n.org>2010-11-06 19:45:29 +1000
committerJonathan Matthew <jonathan@d14n.org>2010-11-16 10:41:40 +1000
commit52d002019620a50bfd5dfa4e455fb0f9432c3799 (patch)
treee6a986d7957e0111583308037481e71b86cc522f
parent7ac5f0c8ded33e061cd00066a594774ef9b453c7 (diff)
downloadgobject-introspection-52d002019620a50bfd5dfa4e455fb0f9432c3799.tar.gz
scanner: use c-symbol-prefix for method pairing where possible
If we have a C symbol prefix for the target type, then use that to identify methods that should be paired with it. The C symbol prefix is derived from the name of the _get_type() function, so it's likely that this is also the prefix given to methods for the type. https://bugzilla.gnome.org/show_bug.cgi?id=634153
-rw-r--r--giscanner/maintransformer.py5
-rw-r--r--tests/scanner/Regress-1.0-expected.gir54
2 files changed, 27 insertions, 32 deletions
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index 89f7ff65..af98a14c 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -915,7 +915,10 @@ method or constructor of some type."""
if first.type.ctype.count('*') != 1:
return False
- uscored = self._uscored_identifier_for_type(first.type)
+ if hasattr(target, 'c_symbol_prefix') and target.c_symbol_prefix is not None:
+ uscored = target.c_symbol_prefix
+ else:
+ uscored = self._uscored_identifier_for_type(first.type)
if not subsymbol.startswith(uscored):
return False
func.instance_parameter = func.parameters.pop(0)
diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir
index 9f112f49..515853b4 100644
--- a/tests/scanner/Regress-1.0-expected.gir
+++ b/tests/scanner/Regress-1.0-expected.gir
@@ -898,42 +898,34 @@ TpAccount::status-changed</doc>
<type name="TestWi8021x" c:type="RegressTestWi8021x*"/>
</return-value>
</constructor>
- <function name="get_testbool"
- c:identifier="regress_test_wi_802_1x_get_testbool">
+ <function name="static_method"
+ c:identifier="regress_test_wi_802_1x_static_method">
<return-value transfer-ownership="none">
- <type name="gboolean" c:type="gboolean"/>
+ <type name="gint" c:type="int"/>
</return-value>
<parameters>
- <parameter name="obj" transfer-ownership="none">
- <type name="TestWi8021x" c:type="RegressTestWi8021x*"/>
+ <parameter name="x" transfer-ownership="none">
+ <type name="gint" c:type="int"/>
</parameter>
</parameters>
</function>
- <function name="set_testbool"
- c:identifier="regress_test_wi_802_1x_set_testbool">
+ <method name="get_testbool"
+ c:identifier="regress_test_wi_802_1x_get_testbool">
+ <return-value transfer-ownership="none">
+ <type name="gboolean" c:type="gboolean"/>
+ </return-value>
+ </method>
+ <method name="set_testbool"
+ c:identifier="regress_test_wi_802_1x_set_testbool">
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
- <parameter name="obj" transfer-ownership="none">
- <type name="TestWi8021x" c:type="RegressTestWi8021x*"/>
- </parameter>
<parameter name="v" transfer-ownership="none">
<type name="gboolean" c:type="gboolean"/>
</parameter>
</parameters>
- </function>
- <function name="static_method"
- c:identifier="regress_test_wi_802_1x_static_method">
- <return-value transfer-ownership="none">
- <type name="gint" c:type="int"/>
- </return-value>
- <parameters>
- <parameter name="x" transfer-ownership="none">
- <type name="gint" c:type="int"/>
- </parameter>
- </parameters>
- </function>
+ </method>
<property name="testbool" writable="1" transfer-ownership="none">
<type name="gboolean"/>
</property>
@@ -2263,24 +2255,24 @@ call and can be released on return.</doc>
</parameter>
</parameters>
</function>
- <function name="test_unsigned_enum_param"
- c:identifier="regress_test_unsigned_enum_param">
+ <function name="test_unichar" c:identifier="regress_test_unichar">
<return-value transfer-ownership="none">
- <type name="utf8" c:type="gchar*"/>
+ <type name="gunichar" c:type="gunichar"/>
</return-value>
<parameters>
- <parameter name="e" transfer-ownership="none">
- <type name="TestEnumUnsigned" c:type="RegressTestEnumUnsigned"/>
+ <parameter name="in" transfer-ownership="none">
+ <type name="gunichar" c:type="gunichar"/>
</parameter>
</parameters>
</function>
- <function name="test_unichar" c:identifier="regress_test_unichar">
+ <function name="test_unsigned_enum_param"
+ c:identifier="regress_test_unsigned_enum_param">
<return-value transfer-ownership="none">
- <type name="gunichar" c:type="gunichar"/>
+ <type name="utf8" c:type="gchar*"/>
</return-value>
<parameters>
- <parameter name="in" transfer-ownership="none">
- <type name="gunichar" c:type="gunichar"/>
+ <parameter name="e" transfer-ownership="none">
+ <type name="TestEnumUnsigned" c:type="RegressTestEnumUnsigned"/>
</parameter>
</parameters>
</function>