From 238f212373aaf06b2c4642cbfe65fc5ad671ff6e Mon Sep 17 00:00:00 2001 From: Lee Morgan Date: Tue, 17 Dec 2013 18:10:26 +0000 Subject: [PATCH] Emscripten workarounds and llvm syntax fixes [Issue] N/A [Problem] N/A [Cause] N/A [Solution] N/A --- .../dali-internal-test-suite/master-makefile.mk | 2 +- .../dali-test-suite-utils/test-application.cpp | 21 +++ .../dali-test-suite-utils/test-application.h | 4 +- .../dali-test-suite-utils/test-gl-abstraction.h | 38 ++--- .../test-platform-abstraction.h | 4 +- automated-tests/dali-test-suite/master-makefile.mk | 3 +- build/slp/configure.ac | 11 ++ build/slp/dali-core/Makefile.am | 2 +- capi/dali/public-api/common/dali-common.h | 15 ++ capi/dali/public-api/events/pan-gesture-detector.h | 2 +- .../public-api/events/pinch-gesture-detector.h | 2 +- capi/dali/public-api/events/tap-gesture-detector.h | 2 +- capi/dali/public-api/math/compile-time-math.h | 1 + capi/dali/public-api/math/vector3.h | 2 +- dali/integration-api/common/lockless-buffer.cpp | 8 +- dali/integration-api/debug.cpp | 10 +- dali/integration-api/debug.h | 6 +- dali/integration-api/dynamics/dynamics-body-intf.h | 2 +- .../dynamics/dynamics-collision-data.h | 2 +- .../integration-api/dynamics/dynamics-world-intf.h | 4 +- dali/internal/event/actors/layer-impl.cpp | 1 - dali/internal/event/actors/layer-impl.h | 3 +- .../event/animation/constraint-source-impl.h | 2 +- dali/internal/event/common/demangler.cpp | 165 +++++++++++++++++++++ dali/internal/event/common/demangler.h | 51 +++++++ .../internal/event/common/notification-manager.cpp | 11 ++ .../internal/event/common/thread-local-storage.cpp | 7 +- dali/internal/event/common/type-registry-impl.cpp | 58 +------- dali/internal/event/events/event-processor.cpp | 5 +- dali/internal/event/events/event-processor.h | 1 - dali/internal/event/events/gesture-detector-impl.h | 2 +- .../internal/event/modeling/animatable-mesh-impl.h | 1 + dali/internal/event/modeling/model-archive.h | 2 +- dali/internal/event/modeling/model-factory.cpp | 6 +- dali/internal/event/modeling/model-impl.cpp | 5 + dali/internal/event/resources/resource-client.cpp | 20 ++- dali/internal/event/text/font-impl.h | 2 +- dali/internal/event/text/font-metrics.cpp | 7 +- dali/internal/event/text/font-metrics.h | 1 - dali/internal/file.list | 1 + dali/internal/render/common/render-debug.h | 2 +- .../scene-graph-dynamics-debug-renderer.cpp | 3 +- .../dynamics/scene-graph-dynamics-debug-renderer.h | 2 - dali/internal/render/gl-resources/context.cpp | 2 + .../render/renderers/scene-graph-mesh-renderer.h | 2 +- .../render/renderers/scene-graph-text-renderer.cpp | 2 +- .../internal/update/common/scene-graph-buffers.cpp | 2 - .../update/dynamics/scene-graph-dynamics-body.h | 2 +- .../scene-graph-light-attachment.h | 16 +- .../internal/update/queue/update-message-queue.cpp | 7 + dali/internal/update/touch/history.h | 2 +- dali/public-api/common/dali-common.cpp | 22 ++- dali/public-api/geometry/mesh.cpp | 10 -- dali/public-api/modeling/bone.h | 2 +- 54 files changed, 410 insertions(+), 158 deletions(-) create mode 100644 automated-tests/dali-test-suite-utils/test-application.cpp create mode 100644 dali/internal/event/common/demangler.cpp create mode 100644 dali/internal/event/common/demangler.h diff --git a/automated-tests/dali-internal-test-suite/master-makefile.mk b/automated-tests/dali-internal-test-suite/master-makefile.mk index 52b14d1..3bb53d5 100644 --- a/automated-tests/dali-internal-test-suite/master-makefile.mk +++ b/automated-tests/dali-internal-test-suite/master-makefile.mk @@ -27,7 +27,7 @@ include ../../coverage.mk all: $(TARGETS) %: %.cpp - $(CC) -o $@ $< $(CXXFLAGS) $(LDFLAGS) + $(CC) -o $@ $< ../../dali-test-suite-utils/test-application.cpp $(CXXFLAGS) $(LDFLAGS) clean: @rm -f $(notdir $(TARGETS)) diff --git a/automated-tests/dali-test-suite-utils/test-application.cpp b/automated-tests/dali-test-suite-utils/test-application.cpp new file mode 100644 index 0000000..fe27b07 --- /dev/null +++ b/automated-tests/dali-test-suite-utils/test-application.cpp @@ -0,0 +1,21 @@ +#define tet_infoline printf +#define tet_printf printf +#include "test-application.h" + +bool BlendEnabled(const TraceCallStack& callStack) +{ + std::stringstream out; + out << GL_BLEND; + bool blendEnabled = callStack.FindMethodAndParams("Enable", out.str()); + return blendEnabled; +} + +bool BlendDisabled(const TraceCallStack& callStack) +{ + std::stringstream out; + out << GL_BLEND; + bool blendEnabled = callStack.FindMethodAndParams("Disable", out.str()); + return blendEnabled; +} + + diff --git a/automated-tests/dali-test-suite-utils/test-application.h b/automated-tests/dali-test-suite-utils/test-application.h index 8859b78..192c6be 100644 --- a/automated-tests/dali-test-suite-utils/test-application.h +++ b/automated-tests/dali-test-suite-utils/test-application.h @@ -41,8 +41,8 @@ public: static constexpr float DEFAULT_HORIZONTAL_DPI = 220.0f; static constexpr float DEFAULT_VERTICAL_DPI = 217.0f; #else - static const float DEFAULT_HORIZONTAL_DPI = 220.0f; - static const float DEFAULT_VERTICAL_DPI = 217.0f; + static const float DEFAULT_HORIZONTAL_DPI = 220.0f; + static const float DEFAULT_VERTICAL_DPI = 217.0f; #endif static const unsigned int DEFAULT_RENDER_INTERVAL = 1; diff --git a/automated-tests/dali-test-suite-utils/test-gl-abstraction.h b/automated-tests/dali-test-suite-utils/test-gl-abstraction.h index 7f9a76c..04f4a35 100644 --- a/automated-tests/dali-test-suite-utils/test-gl-abstraction.h +++ b/automated-tests/dali-test-suite-utils/test-gl-abstraction.h @@ -359,11 +359,11 @@ public: void DeleteTextures(GLsizei n, const GLuint* textures) { std::stringstream out; - out << n << ", " << textures << " = [" ; + out << n << ", " << textures << " = ["; for(GLsizei i=0; i -int TestGlAbstraction::ProgramUniformValue::GetZero() const +inline int TestGlAbstraction::ProgramUniformValue::GetZero() const { return 0; } template <> -float TestGlAbstraction::ProgramUniformValue::GetZero() const +inline float TestGlAbstraction::ProgramUniformValue::GetZero() const { return 0.0f; } template <> -Vector2 TestGlAbstraction::ProgramUniformValue::GetZero() const +inline Vector2 TestGlAbstraction::ProgramUniformValue::GetZero() const { return Vector2::ZERO; } template <> -Vector3 TestGlAbstraction::ProgramUniformValue::GetZero() const +inline Vector3 TestGlAbstraction::ProgramUniformValue::GetZero() const { return Vector3::ZERO; } template <> -Vector4 TestGlAbstraction::ProgramUniformValue::GetZero() const +inline Vector4 TestGlAbstraction::ProgramUniformValue::GetZero() const { return Vector4::ZERO; } template <> -Matrix TestGlAbstraction::ProgramUniformValue::GetZero() const +inline Matrix TestGlAbstraction::ProgramUniformValue::GetZero() const { return Matrix(); } template <> -Matrix3 TestGlAbstraction::ProgramUniformValue::GetZero() const +inline Matrix3 TestGlAbstraction::ProgramUniformValue::GetZero() const { return Matrix3( Matrix() ); } } // namespace Dali -bool BlendEnabled(const TraceCallStack& callStack) -{ - std::stringstream out; - out << GL_BLEND; - bool blendEnabled = callStack.FindMethodAndParams("Enable", out.str()); - return blendEnabled; -} - -bool BlendDisabled(const TraceCallStack& callStack) -{ - std::stringstream out; - out << GL_BLEND; - bool blendEnabled = callStack.FindMethodAndParams("Disable", out.str()); - return blendEnabled; -} - +extern bool BlendEnabled(const TraceCallStack& callStack); +extern bool BlendDisabled(const TraceCallStack& callStack); -#endif // __TEST_GL_ES_H__ +#endif // header diff --git a/automated-tests/dali-test-suite-utils/test-platform-abstraction.h b/automated-tests/dali-test-suite-utils/test-platform-abstraction.h index 5c8536a..6ae2627 100644 --- a/automated-tests/dali-test-suite-utils/test-platform-abstraction.h +++ b/automated-tests/dali-test-suite-utils/test-platform-abstraction.h @@ -260,7 +260,7 @@ public: { bitmapData = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, true); bitmapData->GetPackedPixelsProfile()->ReserveBuffer(Pixel::A8, 64, 64); - PixelBuffer* pixelBuffer = bitmapData->GetBuffer(); + Integration::PixelBuffer* pixelBuffer = bitmapData->GetBuffer(); memset( pixelBuffer, it->character, 64*64 ); } @@ -301,7 +301,7 @@ public: bitmapData = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, true); bitmapData->GetPackedPixelsProfile()->ReserveBuffer(Pixel::A8, 64, 64); - PixelBuffer* pixelBuffer = bitmapData->GetBuffer(); + Integration::PixelBuffer* pixelBuffer = bitmapData->GetBuffer(); memset( pixelBuffer, it->character, 64*64 ); set->AddCharacter(bitmapData, character); } diff --git a/automated-tests/dali-test-suite/master-makefile.mk b/automated-tests/dali-test-suite/master-makefile.mk index 52b14d1..41064f7 100644 --- a/automated-tests/dali-test-suite/master-makefile.mk +++ b/automated-tests/dali-test-suite/master-makefile.mk @@ -27,7 +27,8 @@ include ../../coverage.mk all: $(TARGETS) %: %.cpp - $(CC) -o $@ $< $(CXXFLAGS) $(LDFLAGS) + $(CC) -o $@ $< ../../dali-test-suite-utils/test-application.cpp $(CXXFLAGS) $(LDFLAGS) + clean: @rm -f $(notdir $(TARGETS)) diff --git a/build/slp/configure.ac b/build/slp/configure.ac index 3d6102d..d91962b 100644 --- a/build/slp/configure.ac +++ b/build/slp/configure.ac @@ -46,6 +46,12 @@ AC_ARG_ENABLE([debug], [enable_debug=$enableval], [enable_debug=no]) +AC_ARG_ENABLE([emscripten], + [AC_HELP_STRING([--enable-emscripten], + [Emscripten builds])], + [enable_emscripten=$enableval], + [enable_emscripten=no]) + if test "x$enable_debug" = "xyes"; then DALI_CFLAGS="$DALI_CFLAGS -DDEBUG_ENABLED -DDEBUG_BACKTRACE" fi @@ -54,6 +60,10 @@ if test "x$enable_debug" = "xno" -a "x$enable_exportall" = "xno"; then DALI_CFLAGS="$DALI_CFLAGS -fvisibility=hidden -DHIDE_DALI_INTERNALS" fi +if test "x$enable_emscripten" = "xyes"; then + DALI_CFLAGS="$DALI_CFLAGS -DEMSCRIPTEN -std=c++11" +fi + AC_ARG_ENABLE([performance-monitor], [AC_HELP_STRING([--enable-performance-monitor], [Enables the performance monitor output])], @@ -102,4 +112,5 @@ Configuration Performance Monitor: $enable_performance_monitor Data Dir (Read/Write): $dataReadWriteDir Data Dir (Read Only): $dataReadOnlyDir + Emscripten: $enable_emscripten " diff --git a/build/slp/dali-core/Makefile.am b/build/slp/dali-core/Makefile.am index d2d3a60..602081b 100644 --- a/build/slp/dali-core/Makefile.am +++ b/build/slp/dali-core/Makefile.am @@ -176,7 +176,7 @@ CLEANFILES = dali-shaders.cpp \ noinst_PROGRAMS = linker.test -linker_test_SOURCES = linker-test.cpp +linker_test_SOURCES = linker-test.cpp ../../../automated-tests/dali-test-suite-utils/test-application.cpp linker_test_CXXFLAGS = \ -Werror -Wall -Wfloat-equal \ diff --git a/capi/dali/public-api/common/dali-common.h b/capi/dali/public-api/common/dali-common.h index d3f6057..a3eaf75 100644 --- a/capi/dali/public-api/common/dali-common.h +++ b/capi/dali/public-api/common/dali-common.h @@ -60,6 +60,21 @@ // C++0x not supported #endif +#ifdef EMSCRIPTEN + +#ifndef __clang__ +# error not clang? +#endif + +// clang cpp11 check is per feature +#if !__has_feature(cxx_constexpr) +# error constexpr needed for compile-time-math. Use --std=c11 +#endif + +#define _CPP11 + +#endif + namespace Dali { diff --git a/capi/dali/public-api/events/pan-gesture-detector.h b/capi/dali/public-api/events/pan-gesture-detector.h index 0692259..a8369e2 100644 --- a/capi/dali/public-api/events/pan-gesture-detector.h +++ b/capi/dali/public-api/events/pan-gesture-detector.h @@ -36,7 +36,7 @@ namespace Internal DALI_INTERNAL class PanGestureDetector; } -class PanGesture; +struct PanGesture; /** * This class looks for panning (or dragging) gestures. The user will be pressing one or more fingers on diff --git a/capi/dali/public-api/events/pinch-gesture-detector.h b/capi/dali/public-api/events/pinch-gesture-detector.h index 0c8b644..3d1fc5f 100644 --- a/capi/dali/public-api/events/pinch-gesture-detector.h +++ b/capi/dali/public-api/events/pinch-gesture-detector.h @@ -34,7 +34,7 @@ namespace Internal DALI_INTERNAL class PinchGestureDetector; } -class PinchGesture; +struct PinchGesture; /** * This class looks for pinching gestures involving two touches. It tries to detect when the user moves two diff --git a/capi/dali/public-api/events/tap-gesture-detector.h b/capi/dali/public-api/events/tap-gesture-detector.h index ba99f9b..ec42325 100644 --- a/capi/dali/public-api/events/tap-gesture-detector.h +++ b/capi/dali/public-api/events/tap-gesture-detector.h @@ -34,7 +34,7 @@ namespace Internal DALI_INTERNAL class TapGestureDetector; } -class TapGesture; +struct TapGesture; /** * This class emits a signal when a tap gesture occurs that meets the requirements set by the diff --git a/capi/dali/public-api/math/compile-time-math.h b/capi/dali/public-api/math/compile-time-math.h index 6d71076..a03449d 100644 --- a/capi/dali/public-api/math/compile-time-math.h +++ b/capi/dali/public-api/math/compile-time-math.h @@ -100,6 +100,7 @@ struct Log< 0, base > enum { value = 0 }; }; + /** * Compile time template to calculate the machine epsilon for a given floating point number * Note! value needs to be compile time constant diff --git a/capi/dali/public-api/math/vector3.h b/capi/dali/public-api/math/vector3.h index 8b81750..d4cdef6 100644 --- a/capi/dali/public-api/math/vector3.h +++ b/capi/dali/public-api/math/vector3.h @@ -35,7 +35,7 @@ namespace Dali DALI_IMPORT_API struct Vector2; struct Vector4; -struct Quaternion; +class Quaternion; /** * 3d Vector diff --git a/dali/integration-api/common/lockless-buffer.cpp b/dali/integration-api/common/lockless-buffer.cpp index 3f362ae..3f36c78 100644 --- a/dali/integration-api/common/lockless-buffer.cpp +++ b/dali/integration-api/common/lockless-buffer.cpp @@ -57,7 +57,9 @@ void LocklessBuffer::Write( const unsigned char *src, size_t size ) memcpy( mBuffer[index], src, size ); // unset WRITING bit, set UPDATED bit - BufferState checkState = __sync_val_compare_and_swap( &mState, (currentState | WRITING), (index | UPDATED) ); + BufferState checkState = __sync_val_compare_and_swap( &mState, + static_cast(currentState | WRITING), + static_cast(index | UPDATED) ); DALI_ASSERT_DEBUG( checkState & WRITING ); (void)checkState; // Avoid unused variable warning @@ -73,7 +75,9 @@ const unsigned char* LocklessBuffer::Read() { // Try to swap buffers. // This will set mState to 1 if readbuffer 0 was updated, 0 if readbuffer 1 was updated and fail if WRITING is set - if( __sync_bool_compare_and_swap( &mState, currentWriteBuf | UPDATED, !currentWriteBuf ) ) + if( __sync_bool_compare_and_swap( &mState, + static_cast(currentWriteBuf | UPDATED), + static_cast(!currentWriteBuf) ) ) { // swap successful return mBuffer[currentWriteBuf]; diff --git a/dali/integration-api/debug.cpp b/dali/integration-api/debug.cpp index 4260201..0cfb179 100644 --- a/dali/integration-api/debug.cpp +++ b/dali/integration-api/debug.cpp @@ -23,7 +23,10 @@ #include #include #include -#include + +#ifndef EMSCRIPTEN +# include +#endif // INTERNAL INCLUDES #include @@ -100,7 +103,11 @@ struct ThreadLocalLogging unsigned int logOptions; }; +#ifndef EMSCRIPTEN // single threaded boost::thread_specific_ptr threadLocal; +#else +std::auto_ptr threadLocal; +#endif /* Forward declarations */ std::string FormatToString(const char *format, ...); @@ -178,7 +185,6 @@ void LogMessage(DebugPriority priority, const char* format, ...) { return; } - va_list arg; va_start(arg, format); std::string message = ArgListToString(format, arg); diff --git a/dali/integration-api/debug.h b/dali/integration-api/debug.h index b9d0019..5d50e18 100644 --- a/dali/integration-api/debug.h +++ b/dali/integration-api/debug.h @@ -34,9 +34,9 @@ namespace Dali struct Vector2; struct Vector3; struct Vector4; -struct Matrix3; -struct Matrix; -struct Quaternion; +class Matrix3; +class Matrix; +class Quaternion; namespace Integration { diff --git a/dali/integration-api/dynamics/dynamics-body-intf.h b/dali/integration-api/dynamics/dynamics-body-intf.h index 14f295b..83856af 100644 --- a/dali/integration-api/dynamics/dynamics-body-intf.h +++ b/dali/integration-api/dynamics/dynamics-body-intf.h @@ -30,7 +30,7 @@ struct Vector3; namespace Integration { -class DynamicsBodySettings; +struct DynamicsBodySettings; class DynamicsShape; class DynamicsWorld; diff --git a/dali/integration-api/dynamics/dynamics-collision-data.h b/dali/integration-api/dynamics/dynamics-collision-data.h index 64707d0..3d77fc7 100644 --- a/dali/integration-api/dynamics/dynamics-collision-data.h +++ b/dali/integration-api/dynamics/dynamics-collision-data.h @@ -23,7 +23,7 @@ namespace Dali { -class Vector3; +struct Vector3; namespace Integration { diff --git a/dali/integration-api/dynamics/dynamics-world-intf.h b/dali/integration-api/dynamics/dynamics-world-intf.h index 85382b2..16311f0 100644 --- a/dali/integration-api/dynamics/dynamics-world-intf.h +++ b/dali/integration-api/dynamics/dynamics-world-intf.h @@ -29,11 +29,11 @@ struct Vector3; namespace Integration { -class DynamicsCollisionData; +struct DynamicsCollisionData; class DynamicsBody; class DynamicsJoint; class DynamicsWorld; -class DynamicsWorldSettings; +struct DynamicsWorldSettings; typedef std::map CollisionDataContainer; DynamicsWorld* InitializeDynamics( DynamicsWorldSettings* settings ); diff --git a/dali/internal/event/actors/layer-impl.cpp b/dali/internal/event/actors/layer-impl.cpp index 52e10e4..563106c 100644 --- a/dali/internal/event/actors/layer-impl.cpp +++ b/dali/internal/event/actors/layer-impl.cpp @@ -109,7 +109,6 @@ Layer::Layer( Actor::DerivedType type ) mLayerList(NULL), mClippingBox(0,0,0,0), mSortFunction(Dali::Layer::ZValue), - mRenderOffscreen(false), mIsClipping(false), mDepthTestDisabled(false) { diff --git a/dali/internal/event/actors/layer-impl.h b/dali/internal/event/actors/layer-impl.h index e2b7baa..caff89d 100644 --- a/dali/internal/event/actors/layer-impl.h +++ b/dali/internal/event/actors/layer-impl.h @@ -248,11 +248,10 @@ private: ClippingBox mClippingBox; ///< The clipping box, in window coordinates Dali::Layer::SortFunctionType mSortFunction; ///< Used to sort semi-transparent geometry - bool mRenderOffscreen:1; ///< true when rendering to a FBO bool mIsClipping:1; ///< True when clipping is enabled bool mDepthTestDisabled:1; ///< Whether depth test is disabled. - static bool mFirstInstance ; + static bool mFirstInstance; static DefaultPropertyLookup* mDefaultLayerPropertyLookup; ///< Default properties }; diff --git a/dali/internal/event/animation/constraint-source-impl.h b/dali/internal/event/animation/constraint-source-impl.h index efa981e..4043e1b 100644 --- a/dali/internal/event/animation/constraint-source-impl.h +++ b/dali/internal/event/animation/constraint-source-impl.h @@ -28,7 +28,7 @@ namespace Dali namespace Internal { -class Source; +struct Source; typedef std::vector SourceContainer; typedef SourceContainer::iterator SourceIter; diff --git a/dali/internal/event/common/demangler.cpp b/dali/internal/event/common/demangler.cpp new file mode 100644 index 0000000..673972e --- /dev/null +++ b/dali/internal/event/common/demangler.cpp @@ -0,0 +1,165 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// +// gcc and clang minimal demangling +// Both follow Itanium C++ ABI +// +// We only decode namespaces and class typeid names for simplicity as its all we need. +// +// From http://mentorembedded.github.io/cxx-abi/abi.html#mangling-structure +// +// ::= N [] E +// ::= N [] E +// +// ::= +// ::= +// ::= +// ::= +// ::= # empty +// ::= +// ::= +// +// ::=