LCOV - code coverage report
Current view: top level - source/gui/Scripting - JSInterface_GUIProxy.cpp (source / functions) Hit Total Coverage
Test: 0 A.D. test coverage report Lines: 28 34 82.4 %
Date: 2026-12-03 01:19:39 Functions: 8 14 57.1 %

          Line data    Source code
       1             : /* Copyright (C) 2026 Wildfire Games.
       2             :  * This file is part of 0 A.D.
       3             :  *
       4             :  * 0 A.D. is free software: you can redistribute it and/or modify
       5             :  * it under the terms of the GNU General Public License as published by
       6             :  * the Free Software Foundation, either version 2 of the License, or
       7             :  * (at your option) any later version.
       8             :  *
       9             :  * 0 A.D. is distributed in the hope that it will be useful,
      10             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      12             :  * GNU General Public License for more details.
      13             :  *
      14             :  * You should have received a copy of the GNU General Public License
      15             :  * along with 0 A.D.  If not, see <http://www.gnu.org/licenses/>.
      16             :  */
      17             : 
      18             : #include "precompiled.h"
      19             : 
      20             : #include "JSInterface_GUIProxy.h"
      21             : #include "JSInterface_GUIProxy_impl.h"
      22             : 
      23             : #include "gui/ObjectBases/IGUIObject.h"
      24             : #include "gui/ObjectTypes/CButton.h"
      25             : #include "gui/ObjectTypes/CDropDown.h"
      26             : #include "gui/ObjectTypes/CList.h"
      27             : #include "gui/ObjectTypes/CMiniMap.h"
      28             : #include "gui/ObjectTypes/CScrollPanel.h"
      29             : #include "gui/ObjectTypes/CText.h"
      30             : 
      31             : #include <string>
      32             : 
      33             : class CGUIString;
      34             : namespace Script { class Request; }
      35             : 
      36             : // Called for every specialization - adds the common interface.
      37             : template<>
      38         133 : void JSI_GUIProxy<IGUIObject>::CreateFunctions(const Script::Request& rq, GUIProxyProps* cache)
      39             : {
      40         133 :     CreateFunction<&IGUIObject::GetName>(rq, cache, "toString");
      41         133 :     CreateFunction<&IGUIObject::GetName>(rq, cache, "toSource");
      42         133 :     CreateFunction<&IGUIObject::SetFocus>(rq, cache, "focus");
      43         133 :     CreateFunction<&IGUIObject::ReleaseFocus>(rq, cache, "blur");
      44         133 :     CreateFunction<&IGUIObject::GetActualSize>(rq, cache, "getComputedSize");
      45         133 : }
      46          10 : DECLARE_GUIPROXY(IGUIObject);
      47             : 
      48             : // Implement derived types below.
      49             : 
      50             : // CButton
      51          19 : template<> void JSI_GUIProxy<CButton>::CreateFunctions(const Script::Request& rq, GUIProxyProps* cache)
      52             : {
      53          19 :     CreateFunction<&CButton::GetTextSize>(rq, cache, "getTextSize");
      54          19 :     CreateFunction<&CButton::GetPreferredTextSize>(rq, cache, "getPreferredTextSize");
      55          19 : }
      56           0 : DECLARE_GUIPROXY(CButton);
      57             : 
      58             : // CText
      59          19 : template<> void JSI_GUIProxy<CText>::CreateFunctions(const Script::Request& rq, GUIProxyProps* cache)
      60             : {
      61          19 :     CreateFunction<&CText::GetTextSize>(rq, cache, "getTextSize");
      62          19 :     CreateFunction<&CText::GetPreferredTextSize>(rq, cache, "getPreferredTextSize");
      63          19 : }
      64           0 : DECLARE_GUIPROXY(CText);
      65             : 
      66             : // CList
      67          19 : template<> void JSI_GUIProxy<CList>::CreateFunctions(const Script::Request& rq, GUIProxyProps* cache)
      68             : {
      69          19 :     CreateFunction<static_cast<void(CList::*)(const CGUIString&)>(&CList::AddItem)>(rq, cache, "addItem");
      70          19 : }
      71           0 : DECLARE_GUIPROXY(CList);
      72             : 
      73             : // CDropDown
      74          19 : template<> void JSI_GUIProxy<CDropDown>::CreateFunctions(const Script::Request& rq, GUIProxyProps* cache)
      75             : {
      76          19 :     CreateFunction<&CDropDown::GetPreferredHeaderTextSize>(rq, cache, "getPreferredHeaderTextSize");
      77          19 : }
      78           0 : DECLARE_GUIPROXY(CDropDown);
      79             : 
      80             : // CMiniMap
      81          19 : template<> void JSI_GUIProxy<CMiniMap>::CreateFunctions(const Script::Request& rq, GUIProxyProps* cache)
      82             : {
      83          19 :     CreateFunction<&CMiniMap::Flare>(rq, cache, "flare");
      84          19 : }
      85           0 : DECLARE_GUIPROXY(CMiniMap);
      86             : 
      87             : // CScrollPanel
      88          19 : template<> void JSI_GUIProxy<CScrollPanel>::CreateFunctions(const Script::Request& rq, GUIProxyProps* cache)
      89             : {
      90          19 :     CreateFunction<&CScrollPanel::ResetScrollPosition>(rq, cache, "resetScrollPosition");
      91          19 : }
      92           0 : DECLARE_GUIPROXY(CScrollPanel);

Generated by: LCOV version 1.16