1
0
Fork 0
LithOS3/lithos_c/lithos3/inc/Lth_types.h

87 lines
1.8 KiB
C
Raw Normal View History

2016-10-17 08:57:44 -07:00
//-----------------------------------------------------------------------------
//
// Copyright © 2016 Project Golan
//
// See "LICENSE" for more information.
//
//-----------------------------------------------------------------------------
//
// Basic type handling.
//
//-----------------------------------------------------------------------------
#ifndef lithos3__Lth_types_h
#define lithos3__Lth_types_h
#define Lth_ScriptCall [[__call("ScriptS")]]
2016-10-23 18:24:40 -07:00
#define Lth_OptArgs(n) [[__optional_args(n)]]
2016-10-17 08:57:44 -07:00
#define Lth_Inherits(name) [[__anonymous]] name _super
#define Lth_Mixin(name) [[__anonymous]] name _##name
#define Lth_Vector(type) struct { type *data; size_t size, bufsz; }
#define Lth_VectorForEach(type, vec) \
for(type itr = (vec).data; itr != (vec).data + (vec).size; itr++)
#define Lth_VectorAlloc(type, vec) \
(vec).data = calloc((vec).size, sizeof(type))
#define Lth_Pair(typef, types) struct { typef first; types second; }
2016-10-19 07:00:41 -07:00
#define Lth_WithMbState() \
__with(mbstate_t state; memset(&state, 0, sizeof(state));)
#define Lth_pfor(cond, expr) while((cond) && ((expr), true))
2016-10-17 08:57:44 -07:00
2016-10-18 14:20:32 -07:00
// Type Definitions ----------------------------------------------------------|
2016-10-17 08:57:44 -07:00
typedef int Lth_HID;
typedef char __str_ars const Lth__strchar;
2016-10-17 08:57:44 -07:00
//
// Lth_Signal
//
typedef enum Lth_Signal
{
#define Lth_X(sig, name, ret, ...) \
Lth_##sig,
#include "Lth_callback.h"
Lth_SIGMAX
} Lth_Signal;
//
// Lth_Rect
//
typedef struct Lth_Rect
{
int x, y;
int w, h;
} Lth_Rect;
//
// Lth_IVec2
//
typedef struct Lth_IVec2
{
int x, y;
} Lth_IVec2;
//
// Lth_HIDRange
//
// read-only
// base: beginning of HID range (must be more than end)
// end: end of HID range (must be less than base)
//
// read-write
// cur: current HID
//
typedef struct Lth_HIDRange
{
Lth_HID base;
Lth_HID end;
Lth_HID cur;
} Lth_HIDRange;
2016-10-17 08:57:44 -07:00
#endif//lithos3__Lth_types_h