Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/vsg/core/Array.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace vsg
{

template<typename T>
class Array : public Data
class VSG_DECLSPEC Array : public Data
{
public:
using value_type = T;
Expand Down Expand Up @@ -101,7 +101,7 @@ namespace vsg
_data(nullptr),
_size(0)
{
assign(data, offset, stride, l.size());
assign(data, offset, stride, static_cast<uint32_t>(l.size()));

iterator itr = begin();
for (const value_type& v : l) { (*itr++) = v; }
Expand Down
6 changes: 5 additions & 1 deletion include/vsg/core/Export.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
# define VSG_DECLSPEC
# endif
#else
# define VSG_DECLSPEC
# if defined(VSG_SHARED_LIBRARY) || defined(VSG_EXPORTS)
# define VSG_DECLSPEC __attribute__((visibility("default")))
# else
# define VSG_DECLSPEC
# endif
#endif
22 changes: 18 additions & 4 deletions include/vsg/core/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#include <vsg/core/ref_ptr.h>
#include <vsg/core/type_name.h>

#ifdef VSG_USE_DYNAMIC_CAST
#define VSG_CAST_DYNAMIC
#else
#undef VSG_CAST_DYNAMIC
#endif

namespace vsg
{

Expand Down Expand Up @@ -85,11 +91,19 @@ namespace vsg
virtual const std::type_info& type_info() const noexcept { return typeid(Object); }
virtual bool is_compatible(const std::type_info& type) const noexcept { return typeid(Object) == type; }

template<class T>
T* cast() { return is_compatible(typeid(T)) ? static_cast<T*>(this) : nullptr; }
#ifdef VSG_CAST_DYNAMIC
template<class T>
T* cast() { return dynamic_cast<T*>(this); }

template<class T>
const T* cast() const { return is_compatible(typeid(T)) ? static_cast<const T*>(this) : nullptr; }
template<class T>
const T* cast() const { return dynamic_cast<const T*>(this); }
#else
template<class T>
T* cast() { return is_compatible(typeid(T)) ? static_cast<T*>(this) : nullptr; }

template<class T>
const T* cast() const { return is_compatible(typeid(T)) ? static_cast<const T*>(this) : nullptr; }
#endif

/// clone this object using CopyOp's duplicates map to decide whether to clone or to return the original object.
/// The default clone(CopyOp&) implementation simply returns ref_ptr<> to this object rather attempt to clone.
Expand Down
8 changes: 8 additions & 0 deletions src/vsg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,14 @@ target_link_libraries(vsg ${LIBRARIES})

if (BUILD_SHARED_LIBS)
target_compile_definitions(vsg INTERFACE VSG_SHARED_LIBRARY)
else()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if (VSG_USE_DYNAMIC_CAST)
target_compile_definitions(vsg PRIVATE VSG_USE_DYNAMIC_CAST)
else ()
target_compile_definitions(vsg PRIVATE VSG_EXPORTS)
endif ()
endif()
endif()

# install headers
Expand Down
Loading