sweet/sweet_macro.h
2019-04-11 03:17:26 +02:00

45 lines
1.7 KiB
C
Executable File

/*
* Sweet is a small library for basic math and small matrix operations.
* Copyright 2014 Luc Girod.
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SWEET_MACRO
#define SWEET_MACRO
#define _OVERLOAD_2_(_1, _2, NAME, ...) NAME
#define _OVERLOAD_3_(_1, _2, _3, NAME, ...) NAME
#define _OVERLOAD_4_(_1, _2, _3, _4, NAME, ...) NAME
#define vec2_new(...) _OVERLOAD_2_(__VA_ARGS__, vec2_new_2f, vec2_new_v3, NULL)(__VA_ARGS__)
#define vec3_new(...) _OVERLOAD_3_(__VA_ARGS__, vec3_new_3f, vec3_new_v2_1f, vec3_new_v4, NULL)(__VA_ARGS__)
#define vec4_new(...) _OVERLOAD_4_(__VA_ARGS__, vec4_new_4f, vec4_new_v2_2f, vec4_new_v3_1f, vec4_new_v4, NULL)(__VA_ARGS__)
#define mat2_new(...) _OVERLOAD_4_(__VA_ARGS__, mat2_new_4f, mat2_new_3f, mat2_new_2v, mat2_new_m3, NULL)(__VA_ARGS__)
#define mat3_new(...) _OVERLOAD_3_(__VA_ARGS__, mat3_new_3v, mat3_new_2v, mat3_new_m4, NULL)(__VA_ARGS__)
#define mat4_new(...) _OVERLOAD_4_(__VA_ARGS__, mat4_new_4v, mat4_new_3v, mat4_new_2v, mat4_new_m4, NULL)(__VA_ARGS__)
#define swap(a, b, type) \
{\
type t;\
t = a;\
a = b;\
b = t;\
\
}
#endif