1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
|
// sol2
// The MIT License (MIT)
// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef SOL_TESTS_COMMON_CLASSES_HPP
#define SOL_TESTS_COMMON_CLASSES_HPP
#include <iostream>
struct woof {
int var;
int func(int x) {
return var + x;
}
double func2(int x, int y) {
return var + x + y + 0.5;
}
std::string func2s(int x, std::string y) {
return y + " " + std::to_string(x);
}
};
struct thing {
int v = 100;
thing() {
}
thing(int x) : v(x) {
}
};
struct non_copyable {
non_copyable() = default;
non_copyable(non_copyable&& other) noexcept = default;
non_copyable& operator=(non_copyable&& other) noexcept = default;
non_copyable(const non_copyable& other) noexcept = delete;
non_copyable& operator=(const non_copyable& other) noexcept = delete;
};
struct vars {
vars() {
}
int boop = 0;
~vars() {
}
};
struct fuser {
int x;
fuser() : x(0) {
}
fuser(int x) : x(x) {
}
int add(int y) {
return x + y;
}
int add2(int y) {
return x + y + 2;
}
};
namespace crapola {
struct fuser {
int x;
fuser() : x(0) {
}
fuser(int x) : x(x) {
}
fuser(int x, int x2) : x(x * x2) {
}
int add(int y) {
return x + y;
}
int add2(int y) {
return x + y + 2;
}
};
} // namespace crapola
class Base {
public:
Base(int a_num) : m_num(a_num) {
}
int get_num() {
return m_num;
}
protected:
int m_num;
};
class Derived : public Base {
public:
Derived(int a_num) : Base(a_num) {
}
int get_num_10() {
return 10 * m_num;
}
};
class abstract_A {
public:
virtual void a() = 0;
virtual ~abstract_A() {
}
};
class abstract_B : public abstract_A {
public:
virtual void a() override {
std::cout << "overridden a() in B : public A - BARK" << std::endl;
}
};
struct Vec {
float x, y, z;
Vec(float x, float y, float z) : x { x }, y { y }, z { z } {
}
float length() {
return sqrtf(x * x + y * y + z * z);
}
Vec normalized() {
float invS = 1 / length();
return { x * invS, y * invS, z * invS };
}
};
struct giver {
int a = 0;
giver() {
}
void gief() {
a = 1;
}
static int stuff() {
std::cout << "stuff" << std::endl;
return 97;
}
static void gief_stuff(giver& t, int a) {
t.a = a;
}
~giver() {
}
};
struct lua_object {
#define MAX_INFO_STRING 64
char info[MAX_INFO_STRING];
const char stuck_info[MAX_INFO_STRING];
lua_object() : info("blah"), stuck_info("solid") {
}
};
#endif // SOL_TESTS_COMMON_CLASSES_HPP
|