From 050f15ef6a0c44dc6a7abbbe0f1954ea1925f473 Mon Sep 17 00:00:00 2001 From: Shaheed Haque Date: Sat, 4 Feb 2017 11:00:16 +0000 Subject: 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. --- tests/GenerateSipBindings/cpplib.h | 10 ++++++++++ tests/GenerateSipBindings/testscript.py | 9 +++++++++ 2 files changed, 19 insertions(+) (limited to 'tests/GenerateSipBindings') 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'" -- cgit v1.2.1