LCOV - code coverage report
Current view: top level - source/ps - LoaderThunks.h (source / functions) Hit Total Coverage
Test: 0 A.D. test coverage report Lines: 0 10 0.0 %
Date: 2023-01-19 00:18:29 Functions: 0 22 0.0 %

          Line data    Source code
       1             : /* Copyright (C) 2021 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             : #ifndef INCLUDED_LOADERTHUNKS
      19             : #define INCLUDED_LOADERTHUNKS
      20             : 
      21             : // does this return code indicate the coroutine yielded and
      22             : // wasn't yet finished?
      23           0 : static inline bool ldr_was_interrupted(int ret)
      24             : {
      25           0 :     return (0 < ret && ret <= 100);
      26             : }
      27             : 
      28             : template<class T> struct MemFun_t
      29             : {
      30             :     NONCOPYABLE(MemFun_t);
      31             : public:
      32             :     T* const this_;
      33             :     int (T::*func)(void);
      34           0 :     MemFun_t(T* this__, int(T::*func_)(void))
      35           0 :         : this_(this__), func(func_) {}
      36             : };
      37             : 
      38           0 : template<class T> static int MemFunThunk(std::shared_ptr<void> param, double UNUSED(time_left))
      39             : {
      40           0 :     MemFun_t<T>* const mf = static_cast<MemFun_t<T>*>(param.get());
      41           0 :     return (mf->this_->*mf->func)();
      42             : }
      43             : 
      44           0 : template<class T> void RegMemFun(T* this_, int(T::*func)(void),
      45             :     const wchar_t* description, int estimated_duration_ms)
      46             : {
      47           0 :     LDR_Register(MemFunThunk<T>, std::make_shared<MemFun_t<T>>(this_, func), description, estimated_duration_ms);
      48           0 : }
      49             : 
      50             : 
      51             : ////////////////////////////////////////////////////////
      52             : 
      53             : 
      54             : template<class T, class Arg> struct MemFun1_t
      55             : {
      56             :     NONCOPYABLE(MemFun1_t);
      57             : public:
      58             :     T* const this_;
      59             :     Arg arg;
      60             :     int (T::*func)(Arg);
      61             :     MemFun1_t(T* this__, int(T::*func_)(Arg), Arg arg_)
      62             :         : this_(this__), func(func_), arg(arg_) {}
      63             : };
      64             : 
      65             : template<class T, class Arg> static int MemFun1Thunk(std::shared_ptr<void> param, double UNUSED(time_left))
      66             : {
      67             :     MemFun1_t<T, Arg>* const mf = static_cast<MemFun1_t<T, Arg>*>(param.get());
      68             :     return (mf->this_->*mf->func)(mf->arg);
      69             : }
      70             : 
      71             : template<class T, class Arg> void RegMemFun1(T* this_, int(T::*func)(Arg), Arg arg,
      72             :     const wchar_t* description, int estimated_duration_ms)
      73             : {
      74             :     LDR_Register(MemFun1Thunk<T, Arg>, std::make_shared<MemFun1_t<T, Arg> >(this_, func, arg), description, estimated_duration_ms);
      75             : }
      76             : 
      77             : #endif // INCLUDED_LOADERTHUNKS

Generated by: LCOV version 1.13