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 32 0.0 %
Date: 2022-06-14 00:41:00 Functions: 0 14 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             : 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           0 : 
      44           0 : template<class T> void RegMemFun(T* this_, int(T::*func)(void),
      45           0 :     const wchar_t* description, int estimated_duration_ms)
      46           0 : {
      47           0 :     LDR_Register(MemFunThunk<T>, std::make_shared<MemFun_t<T>>(this_, func), description, estimated_duration_ms);
      48           0 : }
      49             : 
      50           0 : 
      51           0 : ////////////////////////////////////////////////////////
      52             : 
      53           0 : 
      54           0 : template<class T, class Arg> struct MemFun1_t
      55           0 : {
      56           0 :     NONCOPYABLE(MemFun1_t);
      57           0 : public:
      58           0 :     T* const this_;
      59           0 :     Arg arg;
      60             :     int (T::*func)(Arg);
      61             :     MemFun1_t(T* this__, int(T::*func_)(Arg), Arg arg_)
      62           0 :         : this_(this__), func(func_), arg(arg_) {}
      63           0 : };
      64           0 : 
      65             : template<class T, class Arg> static int MemFun1Thunk(std::shared_ptr<void> param, double UNUSED(time_left))
      66             : {
      67           0 :     MemFun1_t<T, Arg>* const mf = static_cast<MemFun1_t<T, Arg>*>(param.get());
      68           0 :     return (mf->this_->*mf->func)(mf->arg);
      69           0 : }
      70             : 
      71             : template<class T, class Arg> void RegMemFun1(T* this_, int(T::*func)(Arg), Arg arg,
      72           0 :     const wchar_t* description, int estimated_duration_ms)
      73           0 : {
      74           0 :     LDR_Register(MemFun1Thunk<T, Arg>, std::make_shared<MemFun1_t<T, Arg> >(this_, func, arg), description, estimated_duration_ms);
      75             : }
      76             : 
      77           0 : #endif // INCLUDED_LOADERTHUNKS

Generated by: LCOV version 1.13