Browse Source

Animation: more MSVC fun!

pull/191/head
Vladimír Vondruš 8 years ago
parent
commit
fc454334ab
  1. 2
      doc/snippets/MagnumAnimation.cpp
  2. 12
      src/Magnum/Animation/Test/PlayerTest.cpp

2
doc/snippets/MagnumAnimation.cpp

@ -162,6 +162,7 @@ timer.advance(timeline.previousFrameTime());
} }
{ {
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* Can't call + on lambdas */
/* [Player-addRawCallback] */ /* [Player-addRawCallback] */
Animation::Track<Float, Int> track; Animation::Track<Float, Int> track;
@ -183,6 +184,7 @@ player.addRawCallback(track,
(*static_cast<std::vector<Int>*>(userData), value); (*static_cast<std::vector<Int>*>(userData), value);
}, &result, reinterpret_cast<void(*)()>(+callback), &data); }, &result, reinterpret_cast<void(*)()>(+callback), &data);
/* [Player-addRawCallback] */ /* [Player-addRawCallback] */
#endif
} }
{ {

12
src/Magnum/Animation/Test/PlayerTest.cpp

@ -759,14 +759,18 @@ void PlayerTest::addWithCallbackOnChangeTemplate() {
CORRADE_COMPARE(data.called, 2); CORRADE_COMPARE(data.called, 2);
} }
namespace {
/* Can't use raw lambdas because MSVC 2015 */
void callback(std::vector<Int>& data, Int value) {
data.push_back(value);
}
}
void PlayerTest::addRawCallback() { void PlayerTest::addRawCallback() {
Animation::Track<Float, Int> track; Animation::Track<Float, Int> track;
Int result = -1; Int result = -1;
std::vector<Int> data; std::vector<Int> data;
auto callback = [](std::vector<Int>& data, Int value) {
data.push_back(value);
};
Animation::Player<Float> player; Animation::Player<Float> player;
player.addRawCallback(track, player.addRawCallback(track,
@ -776,7 +780,7 @@ void PlayerTest::addRawCallback() {
if(value == *static_cast<Int*>(destination)) return; if(value == *static_cast<Int*>(destination)) return;
*static_cast<Int*>(destination) = value; *static_cast<Int*>(destination) = value;
reinterpret_cast<void(*)(std::vector<Int>&, Int)>(callback)(*static_cast<std::vector<Int>*>(userData), value); reinterpret_cast<void(*)(std::vector<Int>&, Int)>(callback)(*static_cast<std::vector<Int>*>(userData), value);
}, &result, reinterpret_cast<void(*)()>(+callback), &data) }, &result, reinterpret_cast<void(*)()>(callback), &data)
.play({}); .play({});
/* Should add the default-constructed value into the vector, but only once */ /* Should add the default-constructed value into the vector, but only once */

Loading…
Cancel
Save