It was using an clang extension for tuples<>

Instead of converting it to pairs<>, which is compatible with gcc,
I converted it to C structs.
This commit is contained in:
Ricardo Quesada 2013-06-04 10:03:32 -07:00
parent f22092c7fc
commit 337f966d0f
1 changed files with 8 additions and 8 deletions

View File

@ -9,7 +9,11 @@
#include "testResource.h" #include "testResource.h"
#include "tests.h" #include "tests.h"
static std::vector< std::tuple<std::string, std::function<TestScene*()>>> g_aTestNames = {
struct {
const char *test_name;
std::function<TestScene*()> callback;
} g_aTestNames[] = {
{ "Accelerometer", []() { return new AccelerometerTestScene(); } }, { "Accelerometer", []() { return new AccelerometerTestScene(); } },
{ "ActionManagerTest", [](){return new ActionManagerTestScene(); } }, { "ActionManagerTest", [](){return new ActionManagerTestScene(); } },
@ -75,7 +79,7 @@ static std::vector< std::tuple<std::string, std::function<TestScene*()>>> g_aTes
{ "ZwoptexTest", []() { return new ZwoptexTestScene(); } }, { "ZwoptexTest", []() { return new ZwoptexTestScene(); } },
}; };
static int g_testCount = g_aTestNames.size(); static int g_testCount = sizeof(g_aTestNames) / sizeof(g_aTestNames[0]);
#define LINE_SPACE 40 #define LINE_SPACE 40
@ -98,10 +102,7 @@ TestController::TestController()
// #if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE) // #if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE)
// CCLabelBMFont* label = CCLabelBMFont::create(g_aTestNames[i].c_str(), "fonts/arial16.fnt"); // CCLabelBMFont* label = CCLabelBMFont::create(g_aTestNames[i].c_str(), "fonts/arial16.fnt");
// #else // #else
std::pair<std::string, std::function<TestScene*()>> e = g_aTestNames[i]; CCLabelTTF* label = CCLabelTTF::create( g_aTestNames[i].test_name, "Arial", 24);
std::string str( std::get<0>(e) );
const char *cp = str.c_str();
CCLabelTTF* label = CCLabelTTF::create( cp , "Arial", 24);
// #endif // #endif
CCMenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, this, menu_selector(TestController::menuCallback)); CCMenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, this, menu_selector(TestController::menuCallback));
@ -133,8 +134,7 @@ void TestController::menuCallback(CCObject * pSender)
int idx = pMenuItem->getZOrder() - 10000; int idx = pMenuItem->getZOrder() - 10000;
// create the test scene and run it // create the test scene and run it
auto functor = std::get<1>( g_aTestNames[idx] ); TestScene* pScene = g_aTestNames[idx].callback();
TestScene* pScene = functor();
if (pScene) if (pScene)
{ {