コード例 #1
0
    //____________________________________________________________
    BaseEngine::WidgetList WidgetStateEngine::registeredWidgets( AnimationModes mode ) const
    {

        WidgetList out;

        // the typedef is needed to make Krazy happy
        typedef DataMap<WidgetStateData>::Value Value;

        if( mode&AnimationHover )
        {
            foreach( const Value& value, hoverData_ )
            { if( value ) out.insert( value.data()->target().data() ); }
        }
コード例 #2
0
ファイル: stdlist.cpp プロジェクト: merlinblack/LuaBridgeTest
void test( lua_State* L )
{
    getGlobalNamespace( L )
        .beginClass<Widget>("Widget")
        .addData("something", &Widget::something )
        .endClass()
        .addFunction( "getWidgets", &getWidgetList );

    gWidgets.insert( std::pair<int, Widget::Ptr>( 1, new Widget(10) ) );
    gWidgets.insert( std::pair<int, Widget::Ptr>( 2, new Widget(20) ) );
    gWidgets.insert( std::pair<int, Widget::Ptr>( 3, new Widget(30) ) );

    const char *source =
        "print( _VERSION )\n"
        "function dump(t)\n"
        "  print( 'Dump:' )\n"
        "  for k,v in pairs(t) do\n"
        "    print( k, v.something )\n"
        "  end\n"
        "end\n";

    cout << source << endl;

    if( luaL_dostring( L, source ) )
    {
        cout << lua_tostring( L, -1 ) << endl;
        lua_pop( L, 1 );
        return;
    }

    for( int i=0; i <= 500; i++ )
    {
        luaL_dostring( L, "dump( getWidgets() )" );
        lua_gc( L, LUA_GCCOLLECT, 0 );
    }

    return;
}