87 lines
2.9 KiB
C
87 lines
2.9 KiB
C
#include "int/convert.h"
|
|
|
|
#include <fx/bool.h>
|
|
#include <fx/macros.h>
|
|
#include <fx/value-type.h>
|
|
|
|
HASH(bool)
|
|
|
|
GENERIC_CONVERT(bool, i16, i16)
|
|
GENERIC_CONVERT(bool, u16, u16)
|
|
GENERIC_CONVERT(bool, i32, i32)
|
|
GENERIC_CONVERT(bool, u32, u32)
|
|
GENERIC_CONVERT(bool, i64, i64)
|
|
GENERIC_CONVERT(bool, u64, u64)
|
|
GENERIC_CONVERT(bool, iptr, iptr)
|
|
GENERIC_CONVERT(bool, uptr, uptr)
|
|
GENERIC_CONVERT(bool, sbyte, sbyte)
|
|
GENERIC_CONVERT(bool, byte, byte)
|
|
GENERIC_CONVERT(bool, short, short)
|
|
GENERIC_CONVERT(bool, ushort, unsigned short)
|
|
GENERIC_CONVERT(bool, int, int)
|
|
GENERIC_CONVERT(bool, uint, unsigned int)
|
|
GENERIC_CONVERT(bool, long, long)
|
|
GENERIC_CONVERT(bool, ulong, unsigned long)
|
|
GENERIC_CONVERT(bool, longlong, long long)
|
|
GENERIC_CONVERT(bool, ulonglong, unsigned long long)
|
|
GENERIC_CONVERT(bool, size, size_t)
|
|
GENERIC_CONVERT(bool, float, float)
|
|
GENERIC_CONVERT(bool, double, double)
|
|
|
|
COMPARE(bool, bool)
|
|
|
|
static fx_status to_string(
|
|
const fx_value *v,
|
|
fx_stream *out,
|
|
const char *format)
|
|
{
|
|
return fx_stream_write_cstr(out, v->v_bool ? "true" : "false", NULL);
|
|
}
|
|
|
|
/*** CLASS DEFINITION *********************************************************/
|
|
|
|
FX_TYPE_CLASS_BEGIN(fx_bool)
|
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
|
FX_INTERFACE_ENTRY(to_string) = to_string;
|
|
FX_INTERFACE_ENTRY(hash) = hash;
|
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
|
|
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_comparable, FX_TYPE_COMPARABLE)
|
|
FX_INTERFACE_ENTRY(c_compare) = compare;
|
|
FX_TYPE_VTABLE_INTERFACE_END(fx_comparable, FX_TYPE_COMPARABLE)
|
|
|
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_convertible, FX_TYPE_CONVERTIBLE)
|
|
FX_INTERFACE_ENTRY(c_to_i16) = to_i16;
|
|
FX_INTERFACE_ENTRY(c_to_u16) = to_u16;
|
|
FX_INTERFACE_ENTRY(c_to_i32) = to_i32;
|
|
FX_INTERFACE_ENTRY(c_to_u32) = to_u32;
|
|
FX_INTERFACE_ENTRY(c_to_i64) = to_i64;
|
|
FX_INTERFACE_ENTRY(c_to_u64) = to_u64;
|
|
FX_INTERFACE_ENTRY(c_to_iptr) = to_iptr;
|
|
FX_INTERFACE_ENTRY(c_to_uptr) = to_uptr;
|
|
FX_INTERFACE_ENTRY(c_to_sbyte) = to_sbyte;
|
|
FX_INTERFACE_ENTRY(c_to_byte) = to_byte;
|
|
FX_INTERFACE_ENTRY(c_to_short) = to_short;
|
|
FX_INTERFACE_ENTRY(c_to_ushort) = to_ushort;
|
|
FX_INTERFACE_ENTRY(c_to_int) = to_int;
|
|
FX_INTERFACE_ENTRY(c_to_uint) = to_uint;
|
|
FX_INTERFACE_ENTRY(c_to_long) = to_long;
|
|
FX_INTERFACE_ENTRY(c_to_ulong) = to_ulong;
|
|
FX_INTERFACE_ENTRY(c_to_longlong) = to_longlong;
|
|
FX_INTERFACE_ENTRY(c_to_ulonglong) = to_ulonglong;
|
|
FX_INTERFACE_ENTRY(c_to_size) = to_size;
|
|
FX_INTERFACE_ENTRY(c_to_float) = to_float;
|
|
FX_INTERFACE_ENTRY(c_to_double) = to_double;
|
|
FX_TYPE_VTABLE_INTERFACE_END(fx_convertible, FX_TYPE_CONVERTIBLE)
|
|
FX_TYPE_CLASS_END(fx_bool)
|
|
|
|
FX_TYPE_DEFINITION_BEGIN(fx_bool)
|
|
__FX_VALUE_TYPE_ID(BOOL);
|
|
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
|
FX_TYPE_IMPLEMENTS(FX_TYPE_CONVERTIBLE);
|
|
FX_TYPE_IMPLEMENTS(FX_TYPE_COMPARABLE);
|
|
FX_TYPE_NAME("fx.bool");
|
|
FX_TYPE_CLASS(fx_bool_class);
|
|
FX_TYPE_INSTANCE_PRIVATE(bool);
|
|
FX_TYPE_DEFINITION_END(fx_bool)
|