aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--find-modules/sip_generator.py20
-rw-r--r--tests/GenerateSipBindings/cpplib.h10
-rw-r--r--tests/GenerateSipBindings/testscript.py9
3 files changed, 30 insertions, 9 deletions
diff --git a/find-modules/sip_generator.py b/find-modules/sip_generator.py
index ca5f550b..5311e8c5 100644
--- a/find-modules/sip_generator.py
+++ b/find-modules/sip_generator.py
@@ -159,11 +159,8 @@ class SipGenerator(object):
return body, self.tu.get_includes
CONTAINER_SKIPPABLE_UNEXPOSED_DECL = re.compile("_DECLARE_PRIVATE|friend|;")
- FN_SKIPPABLE_ATTR = re.compile("_EXPORT|Q_REQUIRED_RESULT|format\(printf")
- VAR_SKIPPABLE_ATTR = re.compile("_EXPORT")
- TYPEDEF_SKIPPABLE_ATTR = re.compile("_EXPORT")
- def skippable_attribute(self, parent, member, text, skippable_re):
+ def skippable_attribute(self, parent, member, text, sip):
"""
We don't seem to have access to the __attribute__(())s, but at least we can look for stuff we care about.
@@ -172,7 +169,10 @@ class SipGenerator(object):
"""
if member.kind != CursorKind.VISIBILITY_ATTR:
return False
- if skippable_re.search(text):
+ if member.spelling == "hidden":
+ if self.dump_privates:
+ logger.debug("Ignoring private {}".format(SipGenerator.describe(parent)))
+ sip["name"] = ""
return True
return False
@@ -488,8 +488,9 @@ class SipGenerator(object):
template_parameters.append(child.type.spelling + " " + child.displayname)
else:
text = self._read_source(child.extent)
- if self.skippable_attribute(function, child, text, SipGenerator.FN_SKIPPABLE_ATTR):
- pass
+ if self.skippable_attribute(function, child, text, sip):
+ if not sip["name"]:
+ return ""
else:
SipGenerator._report_ignoring(function, child)
#
@@ -697,8 +698,9 @@ class SipGenerator(object):
pass
else:
text = self._read_source(child.extent)
- if self.skippable_attribute(variable, child, text, SipGenerator.VAR_SKIPPABLE_ATTR):
- pass
+ if self.skippable_attribute(variable, child, text, sip):
+ if not sip["name"]:
+ return ""
else:
SipGenerator._report_ignoring(variable, child)
#
diff --git a/tests/GenerateSipBindings/cpplib.h b/tests/GenerateSipBindings/cpplib.h
index a91b5486..b3ea22a8 100644
--- a/tests/GenerateSipBindings/cpplib.h
+++ b/tests/GenerateSipBindings/cpplib.h
@@ -203,3 +203,13 @@ enum __attribute__((visibility("default"))) EnumWithAttributes {
Foo,
Bar = 2
};
+
+#define EXPORT __attribute__((visibility("default")))
+#define NO_EXPORT __attribute__((visibility("hidden")))
+
+class EXPORT Visible
+{
+public:
+ EXPORT int visible_fn() { return 1; }
+ NO_EXPORT int invisible_fn() { return 1; }
+};
diff --git a/tests/GenerateSipBindings/testscript.py b/tests/GenerateSipBindings/testscript.py
index e79706bc..98443d53 100644
--- a/tests/GenerateSipBindings/testscript.py
+++ b/tests/GenerateSipBindings/testscript.py
@@ -121,3 +121,12 @@ assert(PyTest.CppLib.anotherCustomMethod([2, 3, 5]) == 52)
sdo = PyTest.CppLib.SubdirObject()
assert(sdo.mul(5, 6) == 30)
+
+visible = PyTest.CppLib.Visible()
+assert visible.visible_fn()
+
+try:
+ assert visible.invisible_fn()
+ assert False
+except AttributeError as e:
+ assert str(e) == "'Visible' object has no attribute 'invisible_fn'"