📄 interpreter.cpp
字号:
else { TopWindow *pWin = pTheme->getWindowById( windowId ); if( pWin ) { pCommand = new CmdShowWindow( getIntf(), pTheme->getWindowManager(), *pWin ); } else { // It was maybe the id of a popup Popup *pPopup = pTheme->getPopupById( windowId ); if( pPopup ) { pCommand = new CmdShowPopup( getIntf(), *pPopup ); } else { msg_Err( getIntf(), "unknown window or popup (%s)", windowId.c_str() ); } } } } else if( rAction.find( ".hide()" ) != string::npos ) { int leftPos = rAction.find( ".hide()" ); string windowId = rAction.substr( 0, leftPos ); if( windowId == "playlist_window" && ! config_GetInt( getIntf(), "skinned-playlist") ) { list<CmdGeneric *> list; list.push_back( new CmdDlgPlaylist( getIntf() ) ); TopWindow *pWin = pTheme->getWindowById( windowId ); if( pWin ) list.push_back( new CmdHideWindow( getIntf(), pTheme->getWindowManager(), *pWin ) ); pCommand = new CmdMuxer( getIntf(), list ); } else { TopWindow *pWin = pTheme->getWindowById( windowId ); if( pWin ) { pCommand = new CmdHideWindow( getIntf(), pTheme->getWindowManager(), *pWin ); } else { msg_Err( getIntf(), "unknown window (%s)", windowId.c_str() ); } } } if( pCommand ) { // Add the command in the pool pTheme->m_commands.push_back( CmdGenericPtr( pCommand ) ); } else { msg_Warn( getIntf(), "unknown action: %s", rAction.c_str() ); } return pCommand;}VarBool *Interpreter::getVarBool( const string &rName, Theme *pTheme ){ VarManager *pVarManager = VarManager::instance( getIntf() ); // Convert the expression into Reverse Polish Notation ExprEvaluator evaluator( getIntf() ); evaluator.parse( rName ); list<VarBool*> varStack; // Get the first token from the RPN stack string token = evaluator.getToken(); while( !token.empty() ) { if( token == "and" ) { // Get the 2 last variables on the stack if( varStack.empty() ) { msg_Err( getIntf(), "invalid boolean expression: %s", rName.c_str()); return NULL; } VarBool *pVar1 = varStack.back(); varStack.pop_back(); if( varStack.empty() ) { msg_Err( getIntf(), "invalid boolean expression: %s", rName.c_str()); return NULL; } VarBool *pVar2 = varStack.back(); varStack.pop_back(); // Create a composite boolean variable VarBool *pNewVar = new VarBoolAndBool( getIntf(), *pVar1, *pVar2 ); varStack.push_back( pNewVar ); // Register this variable in the manager pVarManager->registerVar( VariablePtr( pNewVar ) ); } else if( token == "or" ) { // Get the 2 last variables on the stack if( varStack.empty() ) { msg_Err( getIntf(), "invalid boolean expression: %s", rName.c_str()); return NULL; } VarBool *pVar1 = varStack.back(); varStack.pop_back(); if( varStack.empty() ) { msg_Err( getIntf(), "invalid boolean expression: %s", rName.c_str()); return NULL; } VarBool *pVar2 = varStack.back(); varStack.pop_back(); // Create a composite boolean variable VarBool *pNewVar = new VarBoolOrBool( getIntf(), *pVar1, *pVar2 ); varStack.push_back( pNewVar ); // Register this variable in the manager pVarManager->registerVar( VariablePtr( pNewVar ) ); } else if( token == "not" ) { // Get the last variable on the stack if( varStack.empty() ) { msg_Err( getIntf(), "invalid boolean expression: %s", rName.c_str()); return NULL; } VarBool *pVar = varStack.back(); varStack.pop_back(); // Create a composite boolean variable VarBool *pNewVar = new VarNotBool( getIntf(), *pVar ); varStack.push_back( pNewVar ); // Register this variable in the manager pVarManager->registerVar( VariablePtr( pNewVar ) ); } else { // Try first to get the variable from the variable manager // Indeed, if the skin designer is stupid enough to call a layout // "dvd", we want "dvd.isActive" to resolve as the built-in action // and not as the "layoutId.isActive" one. VarBool *pVar = (VarBool*)pVarManager->getVar( token, "bool" ); if( pVar ) { varStack.push_back( pVar ); } else if( token.find( ".isVisible" ) != string::npos ) { int leftPos = token.find( ".isVisible" ); string windowId = token.substr( 0, leftPos ); TopWindow *pWin = pTheme->getWindowById( windowId ); if( pWin ) { // Push the visibility variable onto the stack varStack.push_back( &pWin->getVisibleVar() ); } else { msg_Err( getIntf(), "unknown window (%s)", windowId.c_str() ); return NULL; } } else if( token.find( ".isMaximized" ) != string::npos ) { int leftPos = token.find( ".isMaximized" ); string windowId = token.substr( 0, leftPos ); TopWindow *pWin = pTheme->getWindowById( windowId ); if( pWin ) { // Push the "maximized" variable onto the stack varStack.push_back( &pWin->getMaximizedVar() ); } else { msg_Err( getIntf(), "unknown window (%s)", windowId.c_str() ); return NULL; } } else if( token.find( ".isActive" ) != string::npos ) { int leftPos = token.find( ".isActive" ); string layoutId = token.substr( 0, leftPos ); GenericLayout *pLayout = pTheme->getLayoutById( layoutId ); if( pLayout ) { // Push the isActive variable onto the stack varStack.push_back( &pLayout->getActiveVar() ); } else { msg_Err( getIntf(), "unknown layout (%s)", layoutId.c_str() ); return NULL; } } else { msg_Err( getIntf(), "cannot resolve boolean variable: %s", token.c_str()); return NULL; } } // Get the first token from the RPN stack token = evaluator.getToken(); } // The stack should contain a single variable if( varStack.size() != 1 ) { msg_Err( getIntf(), "invalid boolean expression: %s", rName.c_str() ); return NULL; } return varStack.back();}VarPercent *Interpreter::getVarPercent( const string &rName, Theme *pTheme ){ // Try to get the variable from the variable manager VarManager *pVarManager = VarManager::instance( getIntf() ); VarPercent *pVar = (VarPercent*)pVarManager->getVar( rName, "percent" ); return pVar;}VarList *Interpreter::getVarList( const string &rName, Theme *pTheme ){ // Try to get the variable from the variable manager VarManager *pVarManager = VarManager::instance( getIntf() ); VarList *pVar = (VarList*)pVarManager->getVar( rName, "list" ); return pVar;}VarTree *Interpreter::getVarTree( const string &rName, Theme *pTheme ){ // Try to get the variable from the variable manager VarManager *pVarManager = VarManager::instance( getIntf() ); VarTree *pVar = (VarTree*)pVarManager->getVar( rName, "tree" ); return pVar;}string Interpreter::getConstant( const string &rValue ){ // Check if the value is a registered constant string val = VarManager::instance( getIntf() )->getConst( rValue ); if( val.empty() ) { // if not, keep the value as is val = rValue; } return val;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -