aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorShaheed Haque <srhaque@theiet.org>2017-02-04 11:00:16 +0000
committerStephen Kelly <steveire@gmail.com>2017-02-04 11:27:15 +0000
commit050f15ef6a0c44dc6a7abbbe0f1954ea1925f473 (patch)
tree2e28042d4fd929d863a7c1e48d0a32d54ff9eb55 /tests
parent4e17330a4520b1994a6488993a2a887f1f051d72 (diff)
downloadextra-cmake-modules-050f15ef6a0c44dc6a7abbbe0f1954ea1925f473.tar.gz
extra-cmake-modules-050f15ef6a0c44dc6a7abbbe0f1954ea1925f473.tar.bz2
Bindings: Take account of visibility attribute on APIs
Don't export API which has visibility "hidden". Visibility attributes on variables are ignored, but call the generic method anyway. Remove checks for macros which obscure the attributes. Processing the attribute directly means that is not needed.
Diffstat (limited to 'tests')
-rw-r--r--tests/GenerateSipBindings/cpplib.h10
-rw-r--r--tests/GenerateSipBindings/testscript.py9
2 files changed, 19 insertions, 0 deletions
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'"