From 5676ced82539d9e40bde6196d2aa3b2e4c7b3fdb Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 22 Feb 2017 16:39:20 +0200 Subject: make UNO enums scoped for internal LO code this modifies codemaker so that, for an UNO enum, we generate code that effectively looks like: #ifdef LIBO_INTERNAL_ONLY && HAVE_CX11_CONSTEXPR enum class XXX { ONE = 1 }; constexpr auto ONE = XXX_ONE; #else ...the old normal way.. #endif which means that for LO internal code, the enums are scoped. The "constexpr auto" trick acts like an alias so we don't have to use scoped naming everywhere. Change-Id: I3054ecb230e8666ce98b4a9cb87b384df5f64fb4 Reviewed-on: https://gerrit.libreoffice.org/34546 Tested-by: Jenkins Reviewed-by: Noel Grandin --- cppu/qa/cppumaker/test_cppumaker.cxx | 9 ++--- cppu/qa/test_unotype.cxx | 65 ++++++++++++++++++++---------------- 2 files changed, 39 insertions(+), 35 deletions(-) (limited to 'cppu/qa') diff --git a/cppu/qa/cppumaker/test_cppumaker.cxx b/cppu/qa/cppumaker/test_cppumaker.cxx index 580cb0b8c271..65db58e4b1e8 100644 --- a/cppu/qa/cppumaker/test_cppumaker.cxx +++ b/cppu/qa/cppumaker/test_cppumaker.cxx @@ -441,18 +441,15 @@ void Test::testBigStruct() { CPPUNIT_ASSERT_EQUAL(guard.p->m10, 0.0); CPPUNIT_ASSERT_EQUAL(guard.p->m11, static_cast< sal_Unicode >(0)); CPPUNIT_ASSERT_EQUAL(guard.p->m12.getLength(), static_cast< sal_Int32 >(0)); - CPPUNIT_ASSERT_EQUAL( - +guard.p->m13.getTypeClass(), +css::uno::TypeClass_VOID); + CPPUNIT_ASSERT_EQUAL((sal_Int32)guard.p->m13.getTypeClass(), (sal_Int32)css::uno::TypeClass_VOID); CPPUNIT_ASSERT_EQUAL(guard.p->m14.hasValue(), false); CPPUNIT_ASSERT_EQUAL(guard.p->m15.getLength(), static_cast< sal_Int32 >(0)); - CPPUNIT_ASSERT_EQUAL( - +guard.p->m16, +test::codemaker::cppumaker::HelperEnum_ZERO); + CPPUNIT_ASSERT_EQUAL((int)guard.p->m16, (int)test::codemaker::cppumaker::HelperEnum_ZERO); CPPUNIT_ASSERT_EQUAL(guard.p->m17.m1, sal_False); CPPUNIT_ASSERT_EQUAL(guard.p->m17.m2.is(), false); CPPUNIT_ASSERT_EQUAL(guard.p->m18.is(), false); CPPUNIT_ASSERT_EQUAL(guard.p->m19, static_cast< sal_Int8 >(0)); - CPPUNIT_ASSERT_EQUAL( - +guard.p->m20, +test::codemaker::cppumaker::HelperEnum_ZERO); + CPPUNIT_ASSERT_EQUAL((sal_Int32)guard.p->m20, (sal_Int32)test::codemaker::cppumaker::HelperEnum_ZERO); CPPUNIT_ASSERT_EQUAL(guard.p->m21.getLength(), static_cast< sal_Int32 >(0)); CPPUNIT_ASSERT_EQUAL(guard.p->m22.getLength(), static_cast< sal_Int32 >(0)); CPPUNIT_ASSERT_EQUAL(guard.p->m23.getLength(), static_cast< sal_Int32 >(0)); diff --git a/cppu/qa/test_unotype.cxx b/cppu/qa/test_unotype.cxx index 47274580c329..6269ff2cfa86 100644 --- a/cppu/qa/test_unotype.cxx +++ b/cppu/qa/test_unotype.cxx @@ -53,8 +53,15 @@ operator <<(std::basic_ostream & stream, Type const & type) { return stream << type.getTypeName(); } +std::ostream& operator<< (std::ostream& aStream, const css::uno::TypeClass& aTypeClass) +{ + aStream << (sal_Int32)aTypeClass; + return aStream; +} + } } } } + namespace { struct DerivedStruct1: css::lang::EventObject {}; @@ -111,67 +118,67 @@ void Test::testUnoType() { css::uno::Type t; t = cppu::UnoType::get(); - CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_VOID, +t.getTypeClass()); + CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_VOID, t.getTypeClass()); CPPUNIT_ASSERT_EQUAL(OUString("void"), t.getTypeName()); CPPUNIT_ASSERT(bool(cppu::UnoType::get() == t)); t = cppu::UnoType::get(); - CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_BOOLEAN, +t.getTypeClass()); + CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_BOOLEAN, t.getTypeClass()); CPPUNIT_ASSERT_EQUAL(OUString("boolean"), t.getTypeName()); CPPUNIT_ASSERT(bool(cppu::UnoType::get() == t)); t = cppu::UnoType::get(); - CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_BYTE, +t.getTypeClass()); + CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_BYTE, t.getTypeClass()); CPPUNIT_ASSERT_EQUAL(OUString("byte"), t.getTypeName()); t = cppu::UnoType::get(); - CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_SHORT, +t.getTypeClass()); + CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_SHORT, t.getTypeClass()); CPPUNIT_ASSERT_EQUAL(OUString("short"), t.getTypeName()); t = cppu::UnoType::get(); CPPUNIT_ASSERT_EQUAL( - +css::uno::TypeClass_UNSIGNED_SHORT, +t.getTypeClass()); + css::uno::TypeClass_UNSIGNED_SHORT, t.getTypeClass()); CPPUNIT_ASSERT_EQUAL(OUString("unsigned short"), t.getTypeName()); t = cppu::UnoType::get(); - CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_LONG, +t.getTypeClass()); + CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_LONG, t.getTypeClass()); CPPUNIT_ASSERT_EQUAL(OUString("long"), t.getTypeName()); t = cppu::UnoType::get(); - CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_UNSIGNED_LONG, +t.getTypeClass()); + CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_UNSIGNED_LONG, t.getTypeClass()); CPPUNIT_ASSERT_EQUAL(OUString("unsigned long"), t.getTypeName()); t = cppu::UnoType::get(); - CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_HYPER, +t.getTypeClass()); + CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_HYPER, t.getTypeClass()); CPPUNIT_ASSERT_EQUAL(OUString("hyper"), t.getTypeName()); t = cppu::UnoType::get(); CPPUNIT_ASSERT_EQUAL( - +css::uno::TypeClass_UNSIGNED_HYPER, +t.getTypeClass()); + css::uno::TypeClass_UNSIGNED_HYPER, t.getTypeClass()); CPPUNIT_ASSERT_EQUAL(OUString("unsigned hyper"), t.getTypeName()); t = cppu::UnoType::get(); - CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_FLOAT, +t.getTypeClass()); + CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_FLOAT, t.getTypeClass()); CPPUNIT_ASSERT_EQUAL(OUString("float"), t.getTypeName()); t = cppu::UnoType::get(); - CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_DOUBLE, +t.getTypeClass()); + CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_DOUBLE, t.getTypeClass()); CPPUNIT_ASSERT_EQUAL(OUString("double"), t.getTypeName()); t = cppu::UnoType::get(); - CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_CHAR, +t.getTypeClass()); + CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_CHAR, t.getTypeClass()); CPPUNIT_ASSERT_EQUAL(OUString("char"), t.getTypeName()); t = cppu::UnoType::get(); - CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_STRING, +t.getTypeClass()); + CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_STRING, t.getTypeClass()); CPPUNIT_ASSERT_EQUAL(OUString("string"), t.getTypeName()); t = cppu::UnoType::get(); - CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_TYPE, +t.getTypeClass()); + CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_TYPE, t.getTypeClass()); CPPUNIT_ASSERT_EQUAL(OUString("type"), t.getTypeName()); t = cppu::UnoType::get(); - CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_ANY, +t.getTypeClass()); + CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_ANY, t.getTypeClass()); CPPUNIT_ASSERT_EQUAL(OUString("any"), t.getTypeName()); t = cppu::UnoType>::get(); - CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_SEQUENCE, +t.getTypeClass()); + CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_SEQUENCE, t.getTypeClass()); CPPUNIT_ASSERT_EQUAL(OUString("[]byte"), t.getTypeName()); CPPUNIT_ASSERT(bool(cppu::UnoType>::get() == t)); t = cppu::UnoType>::get(); - CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_SEQUENCE, +t.getTypeClass()); + CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_SEQUENCE, t.getTypeClass()); CPPUNIT_ASSERT_EQUAL(OUString("[]unsigned short"), t.getTypeName()); t = cppu::UnoType>::get(); - CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_SEQUENCE, +t.getTypeClass()); + CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_SEQUENCE, t.getTypeClass()); CPPUNIT_ASSERT_EQUAL(OUString("[]char"), t.getTypeName()); t = cppu::UnoType< cppu::UnoSequenceType>>::get(); - CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_SEQUENCE, +t.getTypeClass()); + CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_SEQUENCE, t.getTypeClass()); CPPUNIT_ASSERT_EQUAL(OUString("[][]byte"), t.getTypeName()); CPPUNIT_ASSERT_EQUAL( cppu::UnoType>>::get(), @@ -179,42 +186,42 @@ void Test::testUnoType() { t = cppu::UnoType< cppu::UnoSequenceType< cppu::UnoSequenceType>>::get(); - CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_SEQUENCE, +t.getTypeClass()); + CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_SEQUENCE, t.getTypeClass()); CPPUNIT_ASSERT_EQUAL(OUString("[][]unsigned short"), t.getTypeName()); t = cppu::UnoType< cppu::UnoSequenceType>>::get(); - CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_SEQUENCE, +t.getTypeClass()); + CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_SEQUENCE, t.getTypeClass()); CPPUNIT_ASSERT_EQUAL(OUString("[][]char"), t.getTypeName()); t = cppu::UnoType::get(); - CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_ENUM, +t.getTypeClass()); + CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_ENUM, t.getTypeClass()); CPPUNIT_ASSERT_EQUAL( OUString("com.sun.star.uno.TypeClass"), t.getTypeName()); t = cppu::UnoType::get(); - CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_STRUCT, +t.getTypeClass()); + CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_STRUCT, t.getTypeClass()); CPPUNIT_ASSERT_EQUAL( OUString("com.sun.star.lang.EventObject"), t.getTypeName()); CPPUNIT_ASSERT_EQUAL(cppu::UnoType::get(), t); t = cppu::UnoType::get(); - CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_STRUCT, +t.getTypeClass()); + CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_STRUCT, t.getTypeClass()); CPPUNIT_ASSERT_EQUAL( OUString("com.sun.star.beans.PropertyChangeEvent"), t.getTypeName()); CPPUNIT_ASSERT_EQUAL(cppu::UnoType::get(), t); t = cppu::UnoType>::get(); - CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_STRUCT, +t.getTypeClass()); + CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_STRUCT, t.getTypeClass()); CPPUNIT_ASSERT_EQUAL( OUString("com.sun.star.beans.Optional"), t.getTypeName()); t = cppu::UnoType::get(); - CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_EXCEPTION, +t.getTypeClass()); + CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_EXCEPTION, t.getTypeClass()); CPPUNIT_ASSERT_EQUAL( OUString("com.sun.star.uno.Exception"), t.getTypeName()); CPPUNIT_ASSERT_EQUAL(cppu::UnoType::get(), t); t = cppu::UnoType::get(); - CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_EXCEPTION, +t.getTypeClass()); + CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_EXCEPTION, t.getTypeClass()); CPPUNIT_ASSERT_EQUAL( OUString("com.sun.star.uno.RuntimeException"), t.getTypeName()); CPPUNIT_ASSERT_EQUAL(cppu::UnoType::get(), t); t = cppu::UnoType::get(); - CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_INTERFACE, +t.getTypeClass()); + CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_INTERFACE, t.getTypeClass()); CPPUNIT_ASSERT_EQUAL( OUString("com.sun.star.uno.XInterface"), t.getTypeName()); CPPUNIT_ASSERT_EQUAL( @@ -223,7 +230,7 @@ void Test::testUnoType() { CPPUNIT_ASSERT_EQUAL( cppu::UnoType>::get(), t); t = cppu::UnoType::get(); - CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_INTERFACE, +t.getTypeClass()); + CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_INTERFACE, t.getTypeClass()); CPPUNIT_ASSERT_EQUAL( OUString("com.sun.star.uno.XComponentContext"), t.getTypeName()); CPPUNIT_ASSERT_EQUAL( -- cgit