Skip to content

Commit

Permalink
Generated single header files.
Browse files Browse the repository at this point in the history
  • Loading branch information
FranckRJ committed Apr 11, 2021
1 parent 04780d6 commit 1e27ddb
Show file tree
Hide file tree
Showing 10 changed files with 694 additions and 512 deletions.
120 changes: 69 additions & 51 deletions single_header/boost/fakeit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
* FakeIt - A Simplified C++ Mocking Framework
* Copyright (c) Eran Pe'er 2013
* Generated: 2021-03-21 11:36:29.705658
* Generated: 2021-04-11 20:16:42.931992
* Distributed under the MIT License. Please refer to the LICENSE file at:
* https://github.com/eranpeer/FakeIt
*/
Expand Down Expand Up @@ -5244,10 +5244,16 @@ namespace fakeit {

};
}
#if defined(__GNUG__) && !defined(__clang__)
#define FAKEIT_NO_DEVIRTUALIZE_ATTR [[gnu::optimize("no-devirtualize")]]
#else
#define FAKEIT_NO_DEVIRTUALIZE_ATTR
#endif

namespace fakeit {

template<typename TARGET, typename SOURCE>
[[gnu::optimize("no-devirtualize")]]
FAKEIT_NO_DEVIRTUALIZE_ATTR
TARGET union_cast(SOURCE source) {

union {
Expand All @@ -5269,15 +5275,23 @@ namespace fakeit {
class VTUtils {
public:

#ifdef __GNUG__
#ifndef __clang__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-function-type"
#endif
#endif
template<typename C, typename R, typename ... arglist>
static unsigned int getOffset(R (C::*vMethod)(arglist...)) {
auto sMethod = reinterpret_cast<unsigned int (VirtualOffsetSelector::*)(int)>(vMethod);
VirtualOffsetSelector offsetSelctor;
return (offsetSelctor.*sMethod)(0);
}
#ifdef __GNUG__
#ifndef __clang__
#pragma GCC diagnostic pop
#endif
#endif

template<typename C>
static typename std::enable_if<std::has_virtual_destructor<C>::value, unsigned int>::type
Expand Down Expand Up @@ -5766,74 +5780,78 @@ namespace fakeit {
}
#include <new>

namespace fakeit {

#ifdef __GNUG__
#ifndef __clang__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
#endif
#endif


#ifdef _MSC_VER
#pragma warning( push )
#pragma warning( disable : 4200 )
#endif

namespace fakeit
{
namespace details
{
template <int instanceAreaSize, typename C, typename... BaseClasses>
class FakeObjectImpl
{
public:
void initializeDataMembersArea()
{
for (size_t i = 0; i < instanceAreaSize; ++i)
{
instanceArea[i] = (char) 0;
}
}

template<typename C, typename ... baseclasses>
class FakeObject {
protected:
VirtualTable<C, BaseClasses...> vtable;
char instanceArea[instanceAreaSize];
};

VirtualTable<C, baseclasses...> vtable;
template <typename C, typename... BaseClasses>
class FakeObjectImpl<0, C, BaseClasses...>
{
public:
void initializeDataMembersArea()
{}

static const size_t SIZE = sizeof(C) - sizeof(VirtualTable<C, baseclasses...>);
char instanceArea[SIZE ? SIZE : 0];
protected:
VirtualTable<C, BaseClasses...> vtable;
};
}

FakeObject(FakeObject const &) = delete;
FakeObject &operator=(FakeObject const &) = delete;
template <typename C, typename... BaseClasses>
class FakeObject
: public details::FakeObjectImpl<sizeof(C) - sizeof(VirtualTable<C, BaseClasses...>), C, BaseClasses...>
{
FakeObject(FakeObject const&) = delete;
FakeObject& operator=(FakeObject const&) = delete;

public:

FakeObject() : vtable() {
initializeDataMembersArea();
}

~FakeObject() {
vtable.dispose();
FakeObject()
{
this->initializeDataMembersArea();
}

void initializeDataMembersArea() {
for (size_t i = 0; i < SIZE; ++i) instanceArea[i] = (char) 0;
~FakeObject()
{
this->vtable.dispose();
}

void setMethod(unsigned int index, void *method) {
vtable.setMethod(index, method);
void setMethod(unsigned int index, void* method)
{
this->vtable.setMethod(index, method);
}

VirtualTable<C, baseclasses...> &getVirtualTable() {
return vtable;
VirtualTable<C, BaseClasses...>& getVirtualTable()
{
return this->vtable;
}

void setVirtualTable(VirtualTable<C, baseclasses...> &t) {
vtable = t;
void setVirtualTable(VirtualTable<C, BaseClasses...>& t)
{
this->vtable = t;
}

void setDtor(void *dtor) {
vtable.setDtor(dtor);
void setDtor(void* dtor)
{
this->vtable.setDtor(dtor);
}
};

#ifdef _MSC_VER
#pragma warning( pop )
#endif

#ifdef __GNUG__
#ifndef __clang__
#pragma GCC diagnostic pop
#endif
#endif

}
namespace fakeit {

Expand Down
124 changes: 71 additions & 53 deletions single_header/catch/fakeit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
* FakeIt - A Simplified C++ Mocking Framework
* Copyright (c) Eran Pe'er 2013
* Generated: 2021-03-21 11:36:29.821157
* Generated: 2021-04-11 20:16:43.013491
* Distributed under the MIT License. Please refer to the LICENSE file at:
* https://github.com/eranpeer/FakeIt
*/
Expand Down Expand Up @@ -1132,9 +1132,9 @@ namespace fakeit {

}
#if __has_include("catch2/catch.hpp")
# include "catch2/catch.hpp"
# include <catch2/catch.hpp>
#else
# include "catch.hpp"
# include <catch.hpp>
#endif

namespace fakeit {
Expand Down Expand Up @@ -5318,10 +5318,16 @@ namespace fakeit {

};
}
#if defined(__GNUG__) && !defined(__clang__)
#define FAKEIT_NO_DEVIRTUALIZE_ATTR [[gnu::optimize("no-devirtualize")]]
#else
#define FAKEIT_NO_DEVIRTUALIZE_ATTR
#endif

namespace fakeit {

template<typename TARGET, typename SOURCE>
[[gnu::optimize("no-devirtualize")]]
FAKEIT_NO_DEVIRTUALIZE_ATTR
TARGET union_cast(SOURCE source) {

union {
Expand All @@ -5343,15 +5349,23 @@ namespace fakeit {
class VTUtils {
public:

#ifdef __GNUG__
#ifndef __clang__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-function-type"
#endif
#endif
template<typename C, typename R, typename ... arglist>
static unsigned int getOffset(R (C::*vMethod)(arglist...)) {
auto sMethod = reinterpret_cast<unsigned int (VirtualOffsetSelector::*)(int)>(vMethod);
VirtualOffsetSelector offsetSelctor;
return (offsetSelctor.*sMethod)(0);
}
#ifdef __GNUG__
#ifndef __clang__
#pragma GCC diagnostic pop
#endif
#endif

template<typename C>
static typename std::enable_if<std::has_virtual_destructor<C>::value, unsigned int>::type
Expand Down Expand Up @@ -5840,74 +5854,78 @@ namespace fakeit {
}
#include <new>

namespace fakeit {

#ifdef __GNUG__
#ifndef __clang__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
#endif
#endif


#ifdef _MSC_VER
#pragma warning( push )
#pragma warning( disable : 4200 )
#endif

namespace fakeit
{
namespace details
{
template <int instanceAreaSize, typename C, typename... BaseClasses>
class FakeObjectImpl
{
public:
void initializeDataMembersArea()
{
for (size_t i = 0; i < instanceAreaSize; ++i)
{
instanceArea[i] = (char) 0;
}
}

template<typename C, typename ... baseclasses>
class FakeObject {
protected:
VirtualTable<C, BaseClasses...> vtable;
char instanceArea[instanceAreaSize];
};

VirtualTable<C, baseclasses...> vtable;
template <typename C, typename... BaseClasses>
class FakeObjectImpl<0, C, BaseClasses...>
{
public:
void initializeDataMembersArea()
{}

static const size_t SIZE = sizeof(C) - sizeof(VirtualTable<C, baseclasses...>);
char instanceArea[SIZE ? SIZE : 0];
protected:
VirtualTable<C, BaseClasses...> vtable;
};
}

FakeObject(FakeObject const &) = delete;
FakeObject &operator=(FakeObject const &) = delete;
template <typename C, typename... BaseClasses>
class FakeObject
: public details::FakeObjectImpl<sizeof(C) - sizeof(VirtualTable<C, BaseClasses...>), C, BaseClasses...>
{
FakeObject(FakeObject const&) = delete;
FakeObject& operator=(FakeObject const&) = delete;

public:

FakeObject() : vtable() {
initializeDataMembersArea();
}

~FakeObject() {
vtable.dispose();
FakeObject()
{
this->initializeDataMembersArea();
}

void initializeDataMembersArea() {
for (size_t i = 0; i < SIZE; ++i) instanceArea[i] = (char) 0;
~FakeObject()
{
this->vtable.dispose();
}

void setMethod(unsigned int index, void *method) {
vtable.setMethod(index, method);
void setMethod(unsigned int index, void* method)
{
this->vtable.setMethod(index, method);
}

VirtualTable<C, baseclasses...> &getVirtualTable() {
return vtable;
VirtualTable<C, BaseClasses...>& getVirtualTable()
{
return this->vtable;
}

void setVirtualTable(VirtualTable<C, baseclasses...> &t) {
vtable = t;
void setVirtualTable(VirtualTable<C, BaseClasses...>& t)
{
this->vtable = t;
}

void setDtor(void *dtor) {
vtable.setDtor(dtor);
void setDtor(void* dtor)
{
this->vtable.setDtor(dtor);
}
};

#ifdef _MSC_VER
#pragma warning( pop )
#endif

#ifdef __GNUG__
#ifndef __clang__
#pragma GCC diagnostic pop
#endif
#endif

}
namespace fakeit {

Expand Down
Loading

0 comments on commit 1e27ddb

Please sign in to comment.