fx: implement value conversion interface
This commit is contained in:
@@ -1,18 +1,85 @@
|
|||||||
|
#include "int/convert.h"
|
||||||
|
|
||||||
#include <fx/bool.h>
|
#include <fx/bool.h>
|
||||||
#include <fx/macros.h>
|
#include <fx/macros.h>
|
||||||
#include <fx/value-type.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 *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_BEGIN(fx_bool)
|
FX_TYPE_CLASS_BEGIN(fx_bool)
|
||||||
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
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_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_CLASS_END(fx_bool)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_bool)
|
FX_TYPE_DEFINITION_BEGIN(fx_bool)
|
||||||
__FX_VALUE_TYPE_ID(BOOL);
|
__FX_VALUE_TYPE_ID(BOOL);
|
||||||
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
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_NAME("fx.bool");
|
||||||
FX_TYPE_CLASS(fx_bool_class);
|
FX_TYPE_CLASS(fx_bool_class);
|
||||||
FX_TYPE_INSTANCE_PRIVATE(bool);
|
FX_TYPE_INSTANCE_PRIVATE(bool);
|
||||||
|
|||||||
@@ -1,18 +1,498 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <fx/comparable.h>
|
||||||
|
#include <fx/convertible.h>
|
||||||
#include <fx/cstr.h>
|
#include <fx/cstr.h>
|
||||||
|
#include <fx/hash.h>
|
||||||
|
#include <fx/operable.h>
|
||||||
|
#include <fx/stream.h>
|
||||||
#include <fx/value-type.h>
|
#include <fx/value-type.h>
|
||||||
|
#include <fx/value.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
|
static fx_status to_string(
|
||||||
|
const fx_value *v,
|
||||||
|
fx_stream *out,
|
||||||
|
const char *format)
|
||||||
|
{
|
||||||
|
if (!v->v_cstr) {
|
||||||
|
return FX_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return fx_stream_write_fmt(out, NULL, "%s", v->v_cstr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static i32 compare(const fx_value *left, const fx_value *right)
|
||||||
|
{
|
||||||
|
const char *s;
|
||||||
|
if (!FX_OK(fx_value_get_cstr(right, &s))) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return strcmp(left->v_cstr, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
static fx_status hash(const fx_value *v, uint64_t *out_hash)
|
||||||
|
{
|
||||||
|
*out_hash = fx_hash_cstr(v->v_cstr);
|
||||||
|
return FX_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
fx_status cstr_to_char(const char *in, fx_wchar *out)
|
||||||
|
{
|
||||||
|
if (in[0] == '\0' || in[1] == '\0') {
|
||||||
|
*out = in[0];
|
||||||
|
return FX_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
fx_status cstr_to_bool(const char *in, bool *out)
|
||||||
|
{
|
||||||
|
if (!strcmp(in, "1") || !strcmp(in, "true") || strcmp(in, "True")) {
|
||||||
|
*out = true;
|
||||||
|
return FX_SUCCESS;
|
||||||
|
} else if (
|
||||||
|
!strcmp(in, "0") || !strcmp(in, "false")
|
||||||
|
|| strcmp(in, "False")) {
|
||||||
|
*out = false;
|
||||||
|
return FX_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
fx_status cstr_to_i16(const char *in, i16 *out)
|
||||||
|
{
|
||||||
|
char *ep;
|
||||||
|
long v = strtol(in, &ep, 0);
|
||||||
|
if (*ep) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (v < INT16_MIN || v > INT16_MAX) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*out = (i16)v;
|
||||||
|
return FX_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
fx_status cstr_to_u16(const char *in, u16 *out)
|
||||||
|
{
|
||||||
|
char *ep;
|
||||||
|
unsigned long v = strtoul(in, &ep, 0);
|
||||||
|
if (*ep) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (v > UINT16_MAX) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*out = (u16)v;
|
||||||
|
return FX_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
fx_status cstr_to_i32(const char *in, i32 *out)
|
||||||
|
{
|
||||||
|
char *ep;
|
||||||
|
long long v = strtoll(in, &ep, 0);
|
||||||
|
if (*ep) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (v < INT32_MIN || v > INT32_MAX) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*out = (i32)v;
|
||||||
|
return FX_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
fx_status cstr_to_u32(const char *in, u32 *out)
|
||||||
|
{
|
||||||
|
char *ep;
|
||||||
|
unsigned long long v = strtoull(in, &ep, 0);
|
||||||
|
if (*ep) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (v > UINT32_MAX) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*out = (u32)v;
|
||||||
|
return FX_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
fx_status cstr_to_i64(const char *in, i64 *out)
|
||||||
|
{
|
||||||
|
char *ep;
|
||||||
|
long long v = strtoll(in, &ep, 0);
|
||||||
|
if (*ep) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (v < INT64_MIN || v > INT64_MAX) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*out = (i64)v;
|
||||||
|
return FX_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
fx_status cstr_to_u64(const char *in, u64 *out)
|
||||||
|
{
|
||||||
|
char *ep;
|
||||||
|
unsigned long long v = strtoull(in, &ep, 0);
|
||||||
|
if (*ep) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (v > UINT64_MAX) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*out = (u16)v;
|
||||||
|
return FX_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
fx_status cstr_to_iptr(const char *in, iptr *out)
|
||||||
|
{
|
||||||
|
char *ep;
|
||||||
|
intptr_t v = strtoimax(in, &ep, 0);
|
||||||
|
if (*ep) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (v < INTPTR_MIN || v > INTPTR_MAX) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*out = (iptr)v;
|
||||||
|
return FX_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
fx_status cstr_to_uptr(const char *in, uptr *out)
|
||||||
|
{
|
||||||
|
char *ep;
|
||||||
|
uintptr_t v = strtoumax(in, &ep, 0);
|
||||||
|
if (*ep) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (v > UINTPTR_MAX) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*out = (uptr)v;
|
||||||
|
return FX_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
fx_status cstr_to_sbyte(const char *in, sbyte *out)
|
||||||
|
{
|
||||||
|
char *ep;
|
||||||
|
long v = strtol(in, &ep, 0);
|
||||||
|
if (*ep) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (v > INT8_MAX) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*out = (sbyte)v;
|
||||||
|
return FX_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
fx_status cstr_to_byte(const char *in, byte *out)
|
||||||
|
{
|
||||||
|
char *ep;
|
||||||
|
unsigned long v = strtoul(in, &ep, 0);
|
||||||
|
if (*ep) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (v > UINT8_MAX) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*out = (byte)v;
|
||||||
|
return FX_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
fx_status cstr_to_short(const char *in, short *out)
|
||||||
|
{
|
||||||
|
char *ep;
|
||||||
|
long v = strtol(in, &ep, 0);
|
||||||
|
if (*ep) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (v < SHRT_MIN || v > SHRT_MAX) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*out = (short)v;
|
||||||
|
return FX_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
fx_status cstr_to_ushort(const char *in, unsigned short *out)
|
||||||
|
{
|
||||||
|
char *ep;
|
||||||
|
unsigned long v = strtoul(in, &ep, 0);
|
||||||
|
if (*ep) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (v > USHRT_MAX) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*out = (unsigned short)v;
|
||||||
|
return FX_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
fx_status cstr_to_int(const char *in, int *out)
|
||||||
|
{
|
||||||
|
char *ep;
|
||||||
|
long v = strtol(in, &ep, 0);
|
||||||
|
if (*ep) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (v < INT_MIN || v > INT_MAX) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*out = (int)v;
|
||||||
|
return FX_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
fx_status cstr_to_uint(const char *in, unsigned int *out)
|
||||||
|
{
|
||||||
|
char *ep;
|
||||||
|
unsigned long v = strtoul(in, &ep, 0);
|
||||||
|
if (*ep) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (v > UINT_MAX) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*out = (unsigned int)v;
|
||||||
|
return FX_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
fx_status cstr_to_long(const char *in, long *out)
|
||||||
|
{
|
||||||
|
char *ep;
|
||||||
|
long long v = strtoll(in, &ep, 0);
|
||||||
|
if (*ep) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (v < LONG_MIN || v > LONG_MAX) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*out = (long)v;
|
||||||
|
return FX_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
fx_status cstr_to_ulong(const char *in, unsigned long *out)
|
||||||
|
{
|
||||||
|
char *ep;
|
||||||
|
unsigned long long v = strtoull(in, &ep, 0);
|
||||||
|
if (*ep) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (v > ULONG_MAX) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*out = (unsigned long)v;
|
||||||
|
return FX_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
fx_status cstr_to_longlong(const char *in, long long *out)
|
||||||
|
{
|
||||||
|
char *ep;
|
||||||
|
long long v = strtoll(in, &ep, 0);
|
||||||
|
if (*ep) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (v < LLONG_MIN || v > LLONG_MAX) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*out = (long long)v;
|
||||||
|
return FX_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
fx_status cstr_to_ulonglong(const char *in, unsigned long long *out)
|
||||||
|
{
|
||||||
|
char *ep;
|
||||||
|
unsigned long long v = strtoull(in, &ep, 0);
|
||||||
|
if (*ep) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (v > ULLONG_MAX) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*out = (unsigned long long)v;
|
||||||
|
return FX_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
fx_status cstr_to_size(const char *in, size_t *out)
|
||||||
|
{
|
||||||
|
char *ep;
|
||||||
|
unsigned long long v = strtoull(in, &ep, 0);
|
||||||
|
if (*ep) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (v > SIZE_T_MAX) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*out = (size_t)v;
|
||||||
|
return FX_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
fx_status cstr_to_float(const char *in, float *out)
|
||||||
|
{
|
||||||
|
char *ep;
|
||||||
|
float v = strtof(in, &ep);
|
||||||
|
if (*ep) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*out = v;
|
||||||
|
return FX_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
fx_status cstr_to_double(const char *in, double *out)
|
||||||
|
{
|
||||||
|
char *ep;
|
||||||
|
double v = strtod(in, &ep);
|
||||||
|
if (*ep) {
|
||||||
|
return FX_ERR_BAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*out = v;
|
||||||
|
return FX_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
fx_status cstr_to_cstr(const char *in, const char **out)
|
||||||
|
{
|
||||||
|
*out = in;
|
||||||
|
return FX_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define CSTR_CONVERTER(fx_type, c_type) \
|
||||||
|
static fx_status to_##fx_type(const fx_value *in, c_type *out) \
|
||||||
|
{ \
|
||||||
|
const char *s = NULL; \
|
||||||
|
fx_value_get_cstr(in, &s); \
|
||||||
|
return cstr_to_##fx_type(s, out); \
|
||||||
|
}
|
||||||
|
|
||||||
|
CSTR_CONVERTER(bool, bool)
|
||||||
|
CSTR_CONVERTER(i16, i16)
|
||||||
|
CSTR_CONVERTER(u16, u16)
|
||||||
|
CSTR_CONVERTER(i32, i32)
|
||||||
|
CSTR_CONVERTER(u32, u32)
|
||||||
|
CSTR_CONVERTER(i64, i64)
|
||||||
|
CSTR_CONVERTER(u64, u64)
|
||||||
|
CSTR_CONVERTER(iptr, iptr)
|
||||||
|
CSTR_CONVERTER(uptr, uptr)
|
||||||
|
CSTR_CONVERTER(sbyte, sbyte)
|
||||||
|
CSTR_CONVERTER(byte, byte)
|
||||||
|
CSTR_CONVERTER(short, short)
|
||||||
|
CSTR_CONVERTER(ushort, unsigned short)
|
||||||
|
CSTR_CONVERTER(int, int)
|
||||||
|
CSTR_CONVERTER(uint, unsigned int)
|
||||||
|
CSTR_CONVERTER(long, long)
|
||||||
|
CSTR_CONVERTER(ulong, unsigned long)
|
||||||
|
CSTR_CONVERTER(longlong, long long)
|
||||||
|
CSTR_CONVERTER(ulonglong, unsigned long long)
|
||||||
|
CSTR_CONVERTER(size, size_t)
|
||||||
|
CSTR_CONVERTER(float, float)
|
||||||
|
CSTR_CONVERTER(double, double)
|
||||||
|
CSTR_CONVERTER(cstr, const char *)
|
||||||
|
|
||||||
|
static fx_status add(const fx_value *l, const fx_value *r, fx_value *out)
|
||||||
|
{
|
||||||
|
const char *left = l->v_cstr;
|
||||||
|
const char *right = r->v_cstr;
|
||||||
|
fx_string *result = fx_string_create_from_cstr(left);
|
||||||
|
if (!result) {
|
||||||
|
return FX_ERR_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
fx_string_append_cstr(result, right);
|
||||||
|
*out = FX_VALUE_OBJECT(result);
|
||||||
|
|
||||||
|
return FX_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_BEGIN(fx_cstr)
|
FX_TYPE_CLASS_BEGIN(fx_cstr)
|
||||||
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
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_END(fx_object, FX_TYPE_OBJECT)
|
||||||
|
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_operable, FX_TYPE_OPERABLE)
|
||||||
|
FX_INTERFACE_ENTRY(op_add) = add;
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_END(fx_operable, FX_TYPE_OPERABLE)
|
||||||
|
|
||||||
|
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_bool) = to_bool;
|
||||||
|
FX_INTERFACE_ENTRY(c_to_bool) = to_bool;
|
||||||
|
FX_INTERFACE_ENTRY(c_to_i16) = to_i16;
|
||||||
|
FX_INTERFACE_ENTRY(c_to_u16) = to_u16;
|
||||||
|
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_INTERFACE_ENTRY(c_to_cstr) = to_cstr;
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_END(fx_convertible, FX_TYPE_CONVERTIBLE)
|
||||||
FX_TYPE_CLASS_END(fx_cstr)
|
FX_TYPE_CLASS_END(fx_cstr)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_cstr)
|
FX_TYPE_DEFINITION_BEGIN(fx_cstr)
|
||||||
__FX_VALUE_TYPE_ID(CSTR);
|
__FX_VALUE_TYPE_ID(CSTR);
|
||||||
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_CONVERTIBLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_OPERABLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_COMPARABLE);
|
||||||
FX_TYPE_NAME("fx.cstr");
|
FX_TYPE_NAME("fx.cstr");
|
||||||
FX_TYPE_CLASS(fx_cstr_class);
|
FX_TYPE_CLASS(fx_cstr_class);
|
||||||
FX_TYPE_INSTANCE_PRIVATE(char *);
|
FX_TYPE_INSTANCE_PRIVATE(char *);
|
||||||
@@ -70,64 +550,23 @@ size_t fx_strlen(const char *s, fx_strlen_flags flags)
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fx_wstrcmp(const fx_wchar *a, const fx_wchar *b)
|
size_t fx_strcmp_nocase(const char *a, const char *b)
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for (i = 0; a[i] == b[i]; i++)
|
|
||||||
if (a[i] == '\0')
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return a[i] - b[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
int fx_wastrcmp(const char *a, const fx_wchar *b)
|
|
||||||
{
|
{
|
||||||
while (1) {
|
while (1) {
|
||||||
fx_wchar ch_a = fx_wchar_utf8_codepoint_decode(a);
|
char ch_a = tolower(*a);
|
||||||
fx_wchar ch_b = *b;
|
char ch_b = tolower(*b);
|
||||||
|
|
||||||
|
if (!ch_a && !ch_b) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (ch_a != ch_b) {
|
if (ch_a != ch_b) {
|
||||||
return ch_a - ch_b;
|
return ch_a - ch_b;
|
||||||
}
|
}
|
||||||
|
|
||||||
a += fx_wchar_utf8_codepoint_stride(a);
|
a++;
|
||||||
b++;
|
b++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
fx_wchar *fx_wstrdup(const fx_wchar *s)
|
|
||||||
{
|
|
||||||
size_t len = fx_wstrlen(s);
|
|
||||||
fx_wchar *buf = calloc(len + 1, sizeof(fx_wchar));
|
|
||||||
if (!buf) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(buf, s, len * sizeof(fx_wchar));
|
|
||||||
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t fx_wstrlen(const fx_wchar *s)
|
|
||||||
{
|
|
||||||
size_t len;
|
|
||||||
for (len = 0; s[len] != 0; len++)
|
|
||||||
;
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t fx_wstrcspn(const fx_wchar *dest, const fx_wchar *src)
|
|
||||||
{
|
|
||||||
size_t i = 0;
|
|
||||||
for (i = 0; dest[i]; i++) {
|
|
||||||
for (size_t ii = 0; src[ii]; ii++) {
|
|
||||||
if (dest[i] == src[ii]) {
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|||||||
+83
-1
@@ -1,17 +1,99 @@
|
|||||||
|
#include "../int/convert.h"
|
||||||
|
|
||||||
#include <fx/float.h>
|
#include <fx/float.h>
|
||||||
#include <fx/value-type.h>
|
#include <fx/value-type.h>
|
||||||
|
|
||||||
|
BOOL_CONVERT(double)
|
||||||
|
GENERIC_CONVERT(double, i16, i16)
|
||||||
|
GENERIC_CONVERT(double, u16, u16)
|
||||||
|
GENERIC_CONVERT(double, i32, i32)
|
||||||
|
GENERIC_CONVERT(double, u32, u32)
|
||||||
|
GENERIC_CONVERT(double, i64, i64)
|
||||||
|
GENERIC_CONVERT(double, u64, u64)
|
||||||
|
GENERIC_CONVERT(double, iptr, iptr)
|
||||||
|
GENERIC_CONVERT(double, uptr, uptr)
|
||||||
|
GENERIC_CONVERT(double, sbyte, sbyte)
|
||||||
|
GENERIC_CONVERT(double, byte, byte)
|
||||||
|
GENERIC_CONVERT(double, short, short)
|
||||||
|
GENERIC_CONVERT(double, ushort, unsigned short)
|
||||||
|
GENERIC_CONVERT(double, int, int)
|
||||||
|
GENERIC_CONVERT(double, uint, unsigned int)
|
||||||
|
GENERIC_CONVERT(double, long, long)
|
||||||
|
GENERIC_CONVERT(double, ulong, unsigned long)
|
||||||
|
GENERIC_CONVERT(double, longlong, long long)
|
||||||
|
GENERIC_CONVERT(double, ulonglong, unsigned long long)
|
||||||
|
GENERIC_CONVERT(double, size, size_t)
|
||||||
|
GENERIC_CONVERT(double, float, float)
|
||||||
|
|
||||||
|
TO_STRING(double, "%g")
|
||||||
|
|
||||||
|
BINARY_OP(add, +, double)
|
||||||
|
BINARY_OP(subtract, -, double)
|
||||||
|
BINARY_OP(multiply, *, double)
|
||||||
|
BINARY_OP(divide, /, double)
|
||||||
|
PREFIX_OP(increment, ++, double)
|
||||||
|
PREFIX_OP(decrement, --, double)
|
||||||
|
IN_PLACE_OP(add_in_place, +=, double)
|
||||||
|
IN_PLACE_OP(subtract_in_place, -=, double)
|
||||||
|
IN_PLACE_OP(multiply_in_place, *=, double)
|
||||||
|
IN_PLACE_OP(divide_in_place, /=, double)
|
||||||
|
|
||||||
|
COMPARE(double, double)
|
||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_BEGIN(fx_double)
|
FX_TYPE_CLASS_BEGIN(fx_double)
|
||||||
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
FX_INTERFACE_ENTRY(to_string) = to_string;
|
||||||
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
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_operable, FX_TYPE_OPERABLE)
|
||||||
|
FX_INTERFACE_ENTRY(op_add) = add;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract) = subtract;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply) = multiply;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide) = divide;
|
||||||
|
FX_INTERFACE_ENTRY(op_increment) = increment;
|
||||||
|
FX_INTERFACE_ENTRY(op_decrement) = decrement;
|
||||||
|
FX_INTERFACE_ENTRY(op_add_in_place) = add_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract_in_place) = subtract_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply_in_place) = multiply_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide_in_place) = divide_in_place;
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_END(fx_operable, FX_TYPE_OPERABLE)
|
||||||
|
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_convertible, FX_TYPE_CONVERTIBLE)
|
||||||
|
FX_INTERFACE_ENTRY(c_to_bool) = to_bool;
|
||||||
|
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_TYPE_VTABLE_INTERFACE_END(fx_convertible, FX_TYPE_CONVERTIBLE)
|
||||||
FX_TYPE_CLASS_END(fx_double)
|
FX_TYPE_CLASS_END(fx_double)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_double)
|
FX_TYPE_DEFINITION_BEGIN(fx_double)
|
||||||
__FX_VALUE_TYPE_ID(DOUBLE);
|
__FX_VALUE_TYPE_ID(DOUBLE);
|
||||||
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_CONVERTIBLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_OPERABLE);
|
||||||
FX_TYPE_NAME("fx.double");
|
FX_TYPE_NAME("fx.double");
|
||||||
FX_TYPE_CLASS(fx_double_class);
|
FX_TYPE_CLASS(fx_double_class);
|
||||||
FX_TYPE_INSTANCE_PRIVATE(double);
|
FX_TYPE_INSTANCE_PRIVATE(double);
|
||||||
|
|||||||
+83
-1
@@ -1,17 +1,99 @@
|
|||||||
|
#include "../int/convert.h"
|
||||||
|
|
||||||
#include <fx/float.h>
|
#include <fx/float.h>
|
||||||
#include <fx/value-type.h>
|
#include <fx/value-type.h>
|
||||||
|
|
||||||
|
TO_STRING(float, "%g")
|
||||||
|
|
||||||
|
BOOL_CONVERT(float)
|
||||||
|
GENERIC_CONVERT(float, i16, i16)
|
||||||
|
GENERIC_CONVERT(float, u16, u16)
|
||||||
|
GENERIC_CONVERT(float, i32, i32)
|
||||||
|
GENERIC_CONVERT(float, u32, u32)
|
||||||
|
GENERIC_CONVERT(float, i64, i64)
|
||||||
|
GENERIC_CONVERT(float, u64, u64)
|
||||||
|
GENERIC_CONVERT(float, iptr, iptr)
|
||||||
|
GENERIC_CONVERT(float, uptr, uptr)
|
||||||
|
GENERIC_CONVERT(float, sbyte, sbyte)
|
||||||
|
GENERIC_CONVERT(float, byte, byte)
|
||||||
|
GENERIC_CONVERT(float, short, short)
|
||||||
|
GENERIC_CONVERT(float, ushort, unsigned short)
|
||||||
|
GENERIC_CONVERT(float, int, int)
|
||||||
|
GENERIC_CONVERT(float, uint, unsigned int)
|
||||||
|
GENERIC_CONVERT(float, long, long)
|
||||||
|
GENERIC_CONVERT(float, ulong, unsigned long)
|
||||||
|
GENERIC_CONVERT(float, longlong, long long)
|
||||||
|
GENERIC_CONVERT(float, ulonglong, unsigned long long)
|
||||||
|
GENERIC_CONVERT(float, size, size_t)
|
||||||
|
GENERIC_CONVERT(float, double, double)
|
||||||
|
|
||||||
|
BINARY_OP(add, +, float)
|
||||||
|
BINARY_OP(subtract, -, float)
|
||||||
|
BINARY_OP(multiply, *, float)
|
||||||
|
BINARY_OP(divide, /, float)
|
||||||
|
PREFIX_OP(increment, ++, float)
|
||||||
|
PREFIX_OP(decrement, --, float)
|
||||||
|
IN_PLACE_OP(add_in_place, +=, float)
|
||||||
|
IN_PLACE_OP(subtract_in_place, -=, float)
|
||||||
|
IN_PLACE_OP(multiply_in_place, *=, float)
|
||||||
|
IN_PLACE_OP(divide_in_place, /=, float)
|
||||||
|
|
||||||
|
COMPARE(float, float)
|
||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_BEGIN(fx_float)
|
FX_TYPE_CLASS_BEGIN(fx_float)
|
||||||
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
FX_INTERFACE_ENTRY(to_string) = to_string;
|
||||||
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
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_operable, FX_TYPE_OPERABLE)
|
||||||
|
FX_INTERFACE_ENTRY(op_add) = add;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract) = subtract;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply) = multiply;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide) = divide;
|
||||||
|
FX_INTERFACE_ENTRY(op_increment) = increment;
|
||||||
|
FX_INTERFACE_ENTRY(op_decrement) = decrement;
|
||||||
|
FX_INTERFACE_ENTRY(op_add_in_place) = add_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract_in_place) = subtract_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply_in_place) = multiply_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide_in_place) = divide_in_place;
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_END(fx_operable, FX_TYPE_OPERABLE)
|
||||||
|
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_convertible, FX_TYPE_CONVERTIBLE)
|
||||||
|
FX_INTERFACE_ENTRY(c_to_bool) = to_bool;
|
||||||
|
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_double) = to_double;
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_END(fx_convertible, FX_TYPE_CONVERTIBLE)
|
||||||
FX_TYPE_CLASS_END(fx_float)
|
FX_TYPE_CLASS_END(fx_float)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_float)
|
FX_TYPE_DEFINITION_BEGIN(fx_float)
|
||||||
__FX_VALUE_TYPE_ID(FLOAT);
|
__FX_VALUE_TYPE_ID(FLOAT);
|
||||||
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_CONVERTIBLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_OPERABLE);
|
||||||
FX_TYPE_NAME("fx.float");
|
FX_TYPE_NAME("fx.float");
|
||||||
FX_TYPE_CLASS(fx_float_class);
|
FX_TYPE_CLASS(fx_float_class);
|
||||||
FX_TYPE_INSTANCE_PRIVATE(float);
|
FX_TYPE_INSTANCE_PRIVATE(float);
|
||||||
|
|||||||
@@ -24,11 +24,7 @@ FX_API fx_type_id fx_cstr_get_type(void);
|
|||||||
|
|
||||||
FX_API char *fx_strdup(const char *s);
|
FX_API char *fx_strdup(const char *s);
|
||||||
FX_API size_t fx_strlen(const char *s, fx_strlen_flags flags);
|
FX_API size_t fx_strlen(const char *s, fx_strlen_flags flags);
|
||||||
FX_API int fx_wstrcmp(const fx_wchar *a, const fx_wchar *b);
|
FX_API size_t fx_strcmp_nocase(const char *a, const char *b);
|
||||||
FX_API int fx_wastrcmp(const char *a, const fx_wchar *b);
|
|
||||||
FX_API fx_wchar *fx_wstrdup(const fx_wchar *s);
|
|
||||||
FX_API size_t fx_wstrlen(const fx_wchar *s);
|
|
||||||
FX_API size_t fx_wstrcspn(const fx_wchar *dest, const fx_wchar *src);
|
|
||||||
|
|
||||||
FX_DECLS_END;
|
FX_DECLS_END;
|
||||||
|
|
||||||
|
|||||||
+86
-1
@@ -1,17 +1,102 @@
|
|||||||
|
#include "convert.h"
|
||||||
|
|
||||||
#include <fx/int.h>
|
#include <fx/int.h>
|
||||||
#include <fx/value-type.h>
|
#include <fx/value-type.h>
|
||||||
|
|
||||||
|
HASH(byte)
|
||||||
|
TO_STRING(byte, "%u")
|
||||||
|
|
||||||
|
BOOL_CONVERT(byte)
|
||||||
|
GENERIC_CONVERT(byte, i16, i16)
|
||||||
|
GENERIC_CONVERT(byte, u16, u16)
|
||||||
|
GENERIC_CONVERT(byte, i32, i32)
|
||||||
|
GENERIC_CONVERT(byte, u32, u32)
|
||||||
|
GENERIC_CONVERT(byte, i64, i64)
|
||||||
|
GENERIC_CONVERT(byte, u64, u64)
|
||||||
|
GENERIC_CONVERT(byte, iptr, iptr)
|
||||||
|
GENERIC_CONVERT(byte, uptr, uptr)
|
||||||
|
GENERIC_CONVERT(byte, sbyte, sbyte)
|
||||||
|
GENERIC_CONVERT(byte, short, short)
|
||||||
|
GENERIC_CONVERT(byte, ushort, unsigned short)
|
||||||
|
GENERIC_CONVERT(byte, int, int)
|
||||||
|
GENERIC_CONVERT(byte, uint, unsigned int)
|
||||||
|
GENERIC_CONVERT(byte, long, long)
|
||||||
|
GENERIC_CONVERT(byte, ulong, unsigned long)
|
||||||
|
GENERIC_CONVERT(byte, longlong, long long)
|
||||||
|
GENERIC_CONVERT(byte, ulonglong, unsigned long long)
|
||||||
|
GENERIC_CONVERT(byte, size, size_t)
|
||||||
|
GENERIC_CONVERT(byte, float, float)
|
||||||
|
GENERIC_CONVERT(byte, double, double)
|
||||||
|
|
||||||
|
BINARY_OP(add, +, byte)
|
||||||
|
BINARY_OP(subtract, -, byte)
|
||||||
|
BINARY_OP(multiply, *, byte)
|
||||||
|
BINARY_OP(divide, /, byte)
|
||||||
|
PREFIX_OP(increment, ++, byte)
|
||||||
|
PREFIX_OP(decrement, --, byte)
|
||||||
|
IN_PLACE_OP(add_in_place, +=, byte)
|
||||||
|
IN_PLACE_OP(subtract_in_place, -=, byte)
|
||||||
|
IN_PLACE_OP(multiply_in_place, *=, byte)
|
||||||
|
IN_PLACE_OP(divide_in_place, /=, byte)
|
||||||
|
|
||||||
|
COMPARE(byte, byte)
|
||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_BEGIN(fx_byte)
|
FX_TYPE_CLASS_BEGIN(fx_byte)
|
||||||
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
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_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_operable, FX_TYPE_OPERABLE)
|
||||||
|
FX_INTERFACE_ENTRY(op_add) = add;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract) = subtract;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply) = multiply;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide) = divide;
|
||||||
|
FX_INTERFACE_ENTRY(op_increment) = increment;
|
||||||
|
FX_INTERFACE_ENTRY(op_decrement) = decrement;
|
||||||
|
FX_INTERFACE_ENTRY(op_add_in_place) = add_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract_in_place) = subtract_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply_in_place) = multiply_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide_in_place) = divide_in_place;
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_END(fx_operable, FX_TYPE_OPERABLE)
|
||||||
|
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_convertible, FX_TYPE_CONVERTIBLE)
|
||||||
|
FX_INTERFACE_ENTRY(c_to_bool) = to_bool;
|
||||||
|
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_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_byte)
|
FX_TYPE_CLASS_END(fx_byte)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_byte)
|
FX_TYPE_DEFINITION_BEGIN(fx_byte)
|
||||||
__FX_VALUE_TYPE_ID(BYTE);
|
__FX_VALUE_TYPE_ID(BYTE);
|
||||||
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_CONVERTIBLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_OPERABLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_COMPARABLE);
|
||||||
FX_TYPE_NAME("fx.byte");
|
FX_TYPE_NAME("fx.byte");
|
||||||
FX_TYPE_CLASS(fx_byte_class);
|
FX_TYPE_CLASS(fx_byte_class);
|
||||||
FX_TYPE_INSTANCE_PRIVATE(byte);
|
FX_TYPE_INSTANCE_PRIVATE(byte);
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
#ifndef INT_CONVERT_H_
|
||||||
|
#define INT_CONVERT_H_
|
||||||
|
|
||||||
|
#include <fx/comparable.h>
|
||||||
|
#include <fx/convertible.h>
|
||||||
|
#include <fx/operable.h>
|
||||||
|
#include <fx/value.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
#define HASH(type_name) \
|
||||||
|
static fx_status hash(const fx_value *v, uint64_t *out_hash) \
|
||||||
|
{ \
|
||||||
|
*out_hash = v->v_##type_name; \
|
||||||
|
return FX_SUCCESS; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define TO_STRING(type_name, fmt) \
|
||||||
|
static fx_status to_string( \
|
||||||
|
const fx_value *v, \
|
||||||
|
fx_stream *out, \
|
||||||
|
const char *format) \
|
||||||
|
{ \
|
||||||
|
return fx_stream_write_fmt(out, NULL, fmt, v->v_##type_name); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define BINARY_OP(op_name, op_sym, type_name) \
|
||||||
|
static fx_status op_name( \
|
||||||
|
const fx_value *left, \
|
||||||
|
const fx_value *right, \
|
||||||
|
fx_value *out) \
|
||||||
|
{ \
|
||||||
|
out->v_type = left->v_type; \
|
||||||
|
out->v_##type_name = left->v_##type_name op_sym \
|
||||||
|
right->v_##type_name; \
|
||||||
|
return FX_SUCCESS; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define PREFIX_OP(op_name, op_sym, type_name) \
|
||||||
|
static fx_status op_name(fx_value *value) \
|
||||||
|
{ \
|
||||||
|
value->v_##type_name op_sym; \
|
||||||
|
return FX_SUCCESS; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define IN_PLACE_OP(op_name, op_sym, type_name) \
|
||||||
|
static fx_status op_name(fx_value *left, const fx_value *right) \
|
||||||
|
{ \
|
||||||
|
left->v_##type_name op_sym right->v_##type_name; \
|
||||||
|
return FX_SUCCESS; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define BOOL_CONVERT(fx_from) \
|
||||||
|
static fx_status to_bool(const fx_value *in, bool *out) \
|
||||||
|
{ \
|
||||||
|
*out = in->v_##fx_from != 0 ? true : false; \
|
||||||
|
return FX_SUCCESS; \
|
||||||
|
}
|
||||||
|
#define GENERIC_CONVERT(fx_from, fx_to, c_to) \
|
||||||
|
static fx_status to_##fx_to(const fx_value *in, c_to *out) \
|
||||||
|
{ \
|
||||||
|
*out = (c_to)in->v_##fx_from; \
|
||||||
|
return FX_SUCCESS; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define COMPARE(fx_type, c_type) \
|
||||||
|
static i32 compare(const fx_value *left, const fx_value *right) \
|
||||||
|
{ \
|
||||||
|
c_type right_v = 0; \
|
||||||
|
if (!FX_OK(fx_value_get_##fx_type(right, &right_v))) { \
|
||||||
|
return -1; \
|
||||||
|
} \
|
||||||
|
if (left->v_##fx_type < right_v) { \
|
||||||
|
return -1; \
|
||||||
|
} else if (left->v_##fx_type > right_v) { \
|
||||||
|
return 1; \
|
||||||
|
} else { \
|
||||||
|
return 0; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
+89
-1
@@ -1,5 +1,9 @@
|
|||||||
|
#include "convert.h"
|
||||||
|
|
||||||
|
#include <fx/convertible.h>
|
||||||
#include <fx/int.h>
|
#include <fx/int.h>
|
||||||
#include <fx/value-type.h>
|
#include <fx/value-type.h>
|
||||||
|
#include <fx/value.h>
|
||||||
|
|
||||||
#define SWAP16(v) (((v << 8) & 0xFF00) | ((v >> 8) & 0x00FF))
|
#define SWAP16(v) (((v << 8) & 0xFF00) | ((v >> 8) & 0x00FF))
|
||||||
|
|
||||||
@@ -38,17 +42,101 @@ i16 fx_i16_stoh(i16 v)
|
|||||||
return SWAP16(v);
|
return SWAP16(v);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HASH(i16)
|
||||||
|
TO_STRING(i16, "%" PRId16)
|
||||||
|
|
||||||
|
BOOL_CONVERT(i16)
|
||||||
|
GENERIC_CONVERT(i16, u16, u16)
|
||||||
|
GENERIC_CONVERT(i16, i32, i32)
|
||||||
|
GENERIC_CONVERT(i16, u32, u32)
|
||||||
|
GENERIC_CONVERT(i16, i64, i64)
|
||||||
|
GENERIC_CONVERT(i16, u64, u64)
|
||||||
|
GENERIC_CONVERT(i16, iptr, iptr)
|
||||||
|
GENERIC_CONVERT(i16, uptr, uptr)
|
||||||
|
GENERIC_CONVERT(i16, sbyte, sbyte)
|
||||||
|
GENERIC_CONVERT(i16, byte, byte)
|
||||||
|
GENERIC_CONVERT(i16, short, short)
|
||||||
|
GENERIC_CONVERT(i16, ushort, unsigned short)
|
||||||
|
GENERIC_CONVERT(i16, int, int)
|
||||||
|
GENERIC_CONVERT(i16, uint, unsigned int)
|
||||||
|
GENERIC_CONVERT(i16, long, long)
|
||||||
|
GENERIC_CONVERT(i16, ulong, unsigned long)
|
||||||
|
GENERIC_CONVERT(i16, longlong, long long)
|
||||||
|
GENERIC_CONVERT(i16, ulonglong, unsigned long long)
|
||||||
|
GENERIC_CONVERT(i16, size, size_t)
|
||||||
|
GENERIC_CONVERT(i16, float, float)
|
||||||
|
GENERIC_CONVERT(i16, double, double)
|
||||||
|
|
||||||
|
BINARY_OP(add, +, i16)
|
||||||
|
BINARY_OP(subtract, -, i16)
|
||||||
|
BINARY_OP(multiply, *, i16)
|
||||||
|
BINARY_OP(divide, /, i16)
|
||||||
|
PREFIX_OP(increment, ++, i16)
|
||||||
|
PREFIX_OP(decrement, --, i16)
|
||||||
|
IN_PLACE_OP(add_in_place, +=, i16)
|
||||||
|
IN_PLACE_OP(subtract_in_place, -=, i16)
|
||||||
|
IN_PLACE_OP(multiply_in_place, *=, i16)
|
||||||
|
IN_PLACE_OP(divide_in_place, /=, i16)
|
||||||
|
|
||||||
|
COMPARE(i16, i16)
|
||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_BEGIN(fx_i16)
|
FX_TYPE_CLASS_BEGIN(fx_i16)
|
||||||
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
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_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_operable, FX_TYPE_OPERABLE)
|
||||||
|
FX_INTERFACE_ENTRY(op_add) = add;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract) = subtract;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply) = multiply;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide) = divide;
|
||||||
|
FX_INTERFACE_ENTRY(op_increment) = increment;
|
||||||
|
FX_INTERFACE_ENTRY(op_decrement) = decrement;
|
||||||
|
FX_INTERFACE_ENTRY(op_add_in_place) = add_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract_in_place) = subtract_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply_in_place) = multiply_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide_in_place) = divide_in_place;
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_END(fx_operable, FX_TYPE_OPERABLE)
|
||||||
|
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_convertible, FX_TYPE_CONVERTIBLE)
|
||||||
|
FX_INTERFACE_ENTRY(c_to_bool) = to_bool;
|
||||||
|
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_i16)
|
FX_TYPE_CLASS_END(fx_i16)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_i16)
|
FX_TYPE_DEFINITION_BEGIN(fx_i16)
|
||||||
__FX_VALUE_TYPE_ID(I16);
|
__FX_VALUE_TYPE_ID(I16);
|
||||||
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_CONVERTIBLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_OPERABLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_COMPARABLE);
|
||||||
FX_TYPE_NAME("fx.i16");
|
FX_TYPE_NAME("fx.i16");
|
||||||
FX_TYPE_CLASS(fx_i16_class);
|
FX_TYPE_CLASS(fx_i16_class);
|
||||||
FX_TYPE_INSTANCE_PRIVATE(i16);
|
FX_TYPE_INSTANCE_PRIVATE(i16);
|
||||||
|
|||||||
+87
-1
@@ -1,3 +1,6 @@
|
|||||||
|
#include "convert.h"
|
||||||
|
|
||||||
|
#include <fx/convertible.h>
|
||||||
#include <fx/int.h>
|
#include <fx/int.h>
|
||||||
#include <fx/value-type.h>
|
#include <fx/value-type.h>
|
||||||
|
|
||||||
@@ -41,17 +44,100 @@ i32 fx_i32_stoh(i32 v)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HASH(i32)
|
||||||
|
TO_STRING(i32, "%" PRId32)
|
||||||
|
|
||||||
|
BOOL_CONVERT(i32)
|
||||||
|
GENERIC_CONVERT(i32, i16, i16)
|
||||||
|
GENERIC_CONVERT(i32, u16, u16)
|
||||||
|
GENERIC_CONVERT(i32, u32, u32)
|
||||||
|
GENERIC_CONVERT(i32, i64, i64)
|
||||||
|
GENERIC_CONVERT(i32, u64, u64)
|
||||||
|
GENERIC_CONVERT(i32, iptr, iptr)
|
||||||
|
GENERIC_CONVERT(i32, uptr, uptr)
|
||||||
|
GENERIC_CONVERT(i32, sbyte, sbyte)
|
||||||
|
GENERIC_CONVERT(i32, byte, byte)
|
||||||
|
GENERIC_CONVERT(i32, short, short)
|
||||||
|
GENERIC_CONVERT(i32, ushort, unsigned short)
|
||||||
|
GENERIC_CONVERT(i32, int, int)
|
||||||
|
GENERIC_CONVERT(i32, uint, unsigned int)
|
||||||
|
GENERIC_CONVERT(i32, long, long)
|
||||||
|
GENERIC_CONVERT(i32, ulong, unsigned long)
|
||||||
|
GENERIC_CONVERT(i32, longlong, long long)
|
||||||
|
GENERIC_CONVERT(i32, ulonglong, unsigned long long)
|
||||||
|
GENERIC_CONVERT(i32, size, size_t)
|
||||||
|
GENERIC_CONVERT(i32, float, float)
|
||||||
|
GENERIC_CONVERT(i32, double, double)
|
||||||
|
|
||||||
|
BINARY_OP(add, +, i32)
|
||||||
|
BINARY_OP(subtract, -, i32)
|
||||||
|
BINARY_OP(multiply, *, i32)
|
||||||
|
BINARY_OP(divide, /, i32)
|
||||||
|
PREFIX_OP(increment, ++, i32)
|
||||||
|
PREFIX_OP(decrement, --, i32)
|
||||||
|
IN_PLACE_OP(add_in_place, +=, i32)
|
||||||
|
IN_PLACE_OP(subtract_in_place, -=, i32)
|
||||||
|
IN_PLACE_OP(multiply_in_place, *=, i32)
|
||||||
|
IN_PLACE_OP(divide_in_place, /=, i32)
|
||||||
|
|
||||||
|
COMPARE(i32, i32)
|
||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_BEGIN(fx_i32)
|
FX_TYPE_CLASS_BEGIN(fx_i32)
|
||||||
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
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_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_operable, FX_TYPE_OPERABLE)
|
||||||
|
FX_INTERFACE_ENTRY(op_add) = add;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract) = subtract;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply) = multiply;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide) = divide;
|
||||||
|
FX_INTERFACE_ENTRY(op_increment) = increment;
|
||||||
|
FX_INTERFACE_ENTRY(op_decrement) = decrement;
|
||||||
|
FX_INTERFACE_ENTRY(op_add_in_place) = add_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract_in_place) = subtract_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply_in_place) = multiply_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide_in_place) = divide_in_place;
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_END(fx_operable, FX_TYPE_OPERABLE)
|
||||||
|
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_convertible, FX_TYPE_CONVERTIBLE)
|
||||||
|
FX_INTERFACE_ENTRY(c_to_bool) = to_bool;
|
||||||
|
FX_INTERFACE_ENTRY(c_to_i16) = to_i16;
|
||||||
|
FX_INTERFACE_ENTRY(c_to_u16) = to_u16;
|
||||||
|
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_i32)
|
FX_TYPE_CLASS_END(fx_i32)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_i32)
|
FX_TYPE_DEFINITION_BEGIN(fx_i32)
|
||||||
__FX_VALUE_TYPE_ID(I32);
|
__FX_VALUE_TYPE_ID(I32);
|
||||||
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_CONVERTIBLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_OPERABLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_COMPARABLE);
|
||||||
FX_TYPE_NAME("fx.i32");
|
FX_TYPE_NAME("fx.i32");
|
||||||
FX_TYPE_CLASS(fx_i32_class);
|
FX_TYPE_CLASS(fx_i32_class);
|
||||||
FX_TYPE_INSTANCE_PRIVATE(i32);
|
FX_TYPE_INSTANCE_PRIVATE(i32);
|
||||||
|
|||||||
+88
-1
@@ -1,5 +1,9 @@
|
|||||||
|
#include "convert.h"
|
||||||
|
|
||||||
|
#include <fx/convertible.h>
|
||||||
#include <fx/int.h>
|
#include <fx/int.h>
|
||||||
#include <fx/value-type.h>
|
#include <fx/value-type.h>
|
||||||
|
#include <fx/value.h>
|
||||||
|
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
#define SWAP64(v) \
|
#define SWAP64(v) \
|
||||||
@@ -45,17 +49,100 @@ i64 fx_i64_stoh(i64 v)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HASH(i64)
|
||||||
|
TO_STRING(i64, "%" PRId64)
|
||||||
|
|
||||||
|
BOOL_CONVERT(i64)
|
||||||
|
GENERIC_CONVERT(i64, i16, i16)
|
||||||
|
GENERIC_CONVERT(i64, u16, u16)
|
||||||
|
GENERIC_CONVERT(i64, i32, i32)
|
||||||
|
GENERIC_CONVERT(i64, u32, u32)
|
||||||
|
GENERIC_CONVERT(i64, u64, u64)
|
||||||
|
GENERIC_CONVERT(i64, iptr, iptr)
|
||||||
|
GENERIC_CONVERT(i64, uptr, uptr)
|
||||||
|
GENERIC_CONVERT(i64, sbyte, sbyte)
|
||||||
|
GENERIC_CONVERT(i64, byte, byte)
|
||||||
|
GENERIC_CONVERT(i64, short, short)
|
||||||
|
GENERIC_CONVERT(i64, ushort, unsigned short)
|
||||||
|
GENERIC_CONVERT(i64, int, int)
|
||||||
|
GENERIC_CONVERT(i64, uint, unsigned int)
|
||||||
|
GENERIC_CONVERT(i64, long, long)
|
||||||
|
GENERIC_CONVERT(i64, ulong, unsigned long)
|
||||||
|
GENERIC_CONVERT(i64, longlong, long long)
|
||||||
|
GENERIC_CONVERT(i64, ulonglong, unsigned long long)
|
||||||
|
GENERIC_CONVERT(i64, size, size_t)
|
||||||
|
GENERIC_CONVERT(i64, float, float)
|
||||||
|
GENERIC_CONVERT(i64, double, double)
|
||||||
|
|
||||||
|
BINARY_OP(add, +, i64)
|
||||||
|
BINARY_OP(subtract, -, i64)
|
||||||
|
BINARY_OP(multiply, *, i64)
|
||||||
|
BINARY_OP(divide, /, i64)
|
||||||
|
PREFIX_OP(increment, ++, i64)
|
||||||
|
PREFIX_OP(decrement, --, i64)
|
||||||
|
IN_PLACE_OP(add_in_place, +=, i64)
|
||||||
|
IN_PLACE_OP(subtract_in_place, -=, i64)
|
||||||
|
IN_PLACE_OP(multiply_in_place, *=, i64)
|
||||||
|
IN_PLACE_OP(divide_in_place, /=, i64)
|
||||||
|
|
||||||
|
COMPARE(i64, i64)
|
||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_BEGIN(fx_i64)
|
FX_TYPE_CLASS_BEGIN(fx_i64)
|
||||||
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
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_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_operable, FX_TYPE_OPERABLE)
|
||||||
|
FX_INTERFACE_ENTRY(op_add) = add;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract) = subtract;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply) = multiply;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide) = divide;
|
||||||
|
FX_INTERFACE_ENTRY(op_increment) = increment;
|
||||||
|
FX_INTERFACE_ENTRY(op_decrement) = decrement;
|
||||||
|
FX_INTERFACE_ENTRY(op_add_in_place) = add_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract_in_place) = subtract_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply_in_place) = multiply_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide_in_place) = divide_in_place;
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_END(fx_operable, FX_TYPE_OPERABLE)
|
||||||
|
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_convertible, FX_TYPE_CONVERTIBLE)
|
||||||
|
FX_INTERFACE_ENTRY(c_to_bool) = to_bool;
|
||||||
|
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_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_i64)
|
FX_TYPE_CLASS_END(fx_i64)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_i64)
|
FX_TYPE_DEFINITION_BEGIN(fx_i64)
|
||||||
__FX_VALUE_TYPE_ID(I64);
|
__FX_VALUE_TYPE_ID(I64);
|
||||||
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_CONVERTIBLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_OPERABLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_COMPARABLE);
|
||||||
FX_TYPE_NAME("fx.i64");
|
FX_TYPE_NAME("fx.i64");
|
||||||
FX_TYPE_CLASS(fx_i64_class);
|
FX_TYPE_CLASS(fx_i64_class);
|
||||||
FX_TYPE_INSTANCE_PRIVATE(i64);
|
FX_TYPE_INSTANCE_PRIVATE(i64);
|
||||||
|
|||||||
+86
-1
@@ -1,17 +1,102 @@
|
|||||||
|
#include "convert.h"
|
||||||
|
|
||||||
#include <fx/int.h>
|
#include <fx/int.h>
|
||||||
#include <fx/value-type.h>
|
#include <fx/value-type.h>
|
||||||
|
|
||||||
|
HASH(int)
|
||||||
|
TO_STRING(int, "%d")
|
||||||
|
|
||||||
|
BOOL_CONVERT(int)
|
||||||
|
GENERIC_CONVERT(int, i16, i16)
|
||||||
|
GENERIC_CONVERT(int, u16, u16)
|
||||||
|
GENERIC_CONVERT(int, i32, i32)
|
||||||
|
GENERIC_CONVERT(int, u32, u32)
|
||||||
|
GENERIC_CONVERT(int, i64, i64)
|
||||||
|
GENERIC_CONVERT(int, u64, u64)
|
||||||
|
GENERIC_CONVERT(int, iptr, iptr)
|
||||||
|
GENERIC_CONVERT(int, uptr, uptr)
|
||||||
|
GENERIC_CONVERT(int, sbyte, sbyte)
|
||||||
|
GENERIC_CONVERT(int, byte, byte)
|
||||||
|
GENERIC_CONVERT(int, short, short)
|
||||||
|
GENERIC_CONVERT(int, ushort, unsigned short)
|
||||||
|
GENERIC_CONVERT(int, uint, unsigned int)
|
||||||
|
GENERIC_CONVERT(int, long, long)
|
||||||
|
GENERIC_CONVERT(int, ulong, unsigned long)
|
||||||
|
GENERIC_CONVERT(int, longlong, long long)
|
||||||
|
GENERIC_CONVERT(int, ulonglong, unsigned long long)
|
||||||
|
GENERIC_CONVERT(int, size, size_t)
|
||||||
|
GENERIC_CONVERT(int, float, float)
|
||||||
|
GENERIC_CONVERT(int, double, double)
|
||||||
|
|
||||||
|
BINARY_OP(add, +, int)
|
||||||
|
BINARY_OP(subtract, -, int)
|
||||||
|
BINARY_OP(multiply, *, int)
|
||||||
|
BINARY_OP(divide, /, int)
|
||||||
|
PREFIX_OP(increment, ++, int)
|
||||||
|
PREFIX_OP(decrement, --, int)
|
||||||
|
IN_PLACE_OP(add_in_place, +=, int)
|
||||||
|
IN_PLACE_OP(subtract_in_place, -=, int)
|
||||||
|
IN_PLACE_OP(multiply_in_place, *=, int)
|
||||||
|
IN_PLACE_OP(divide_in_place, /=, int)
|
||||||
|
|
||||||
|
COMPARE(int, int)
|
||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_BEGIN(fx_int)
|
FX_TYPE_CLASS_BEGIN(fx_int)
|
||||||
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
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_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_operable, FX_TYPE_OPERABLE)
|
||||||
|
FX_INTERFACE_ENTRY(op_add) = add;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract) = subtract;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply) = multiply;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide) = divide;
|
||||||
|
FX_INTERFACE_ENTRY(op_increment) = increment;
|
||||||
|
FX_INTERFACE_ENTRY(op_decrement) = decrement;
|
||||||
|
FX_INTERFACE_ENTRY(op_add_in_place) = add_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract_in_place) = subtract_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply_in_place) = multiply_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide_in_place) = divide_in_place;
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_END(fx_operable, FX_TYPE_OPERABLE)
|
||||||
|
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_convertible, FX_TYPE_CONVERTIBLE)
|
||||||
|
FX_INTERFACE_ENTRY(c_to_bool) = to_bool;
|
||||||
|
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_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_int)
|
FX_TYPE_CLASS_END(fx_int)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_int)
|
FX_TYPE_DEFINITION_BEGIN(fx_int)
|
||||||
__FX_VALUE_TYPE_ID(INT);
|
__FX_VALUE_TYPE_ID(INT);
|
||||||
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_CONVERTIBLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_OPERABLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_COMPARABLE);
|
||||||
FX_TYPE_NAME("fx.int");
|
FX_TYPE_NAME("fx.int");
|
||||||
FX_TYPE_CLASS(fx_int_class);
|
FX_TYPE_CLASS(fx_int_class);
|
||||||
FX_TYPE_INSTANCE_PRIVATE(int);
|
FX_TYPE_INSTANCE_PRIVATE(int);
|
||||||
|
|||||||
+86
-1
@@ -1,17 +1,102 @@
|
|||||||
|
#include "convert.h"
|
||||||
|
|
||||||
#include <fx/int.h>
|
#include <fx/int.h>
|
||||||
#include <fx/value-type.h>
|
#include <fx/value-type.h>
|
||||||
|
|
||||||
|
HASH(iptr)
|
||||||
|
TO_STRING(iptr, "%" PRIdPTR)
|
||||||
|
|
||||||
|
BOOL_CONVERT(iptr)
|
||||||
|
GENERIC_CONVERT(iptr, i16, i16)
|
||||||
|
GENERIC_CONVERT(iptr, u16, u16)
|
||||||
|
GENERIC_CONVERT(iptr, i32, i32)
|
||||||
|
GENERIC_CONVERT(iptr, u32, u32)
|
||||||
|
GENERIC_CONVERT(iptr, i64, i64)
|
||||||
|
GENERIC_CONVERT(iptr, u64, u64)
|
||||||
|
GENERIC_CONVERT(iptr, uptr, uptr)
|
||||||
|
GENERIC_CONVERT(iptr, sbyte, sbyte)
|
||||||
|
GENERIC_CONVERT(iptr, byte, byte)
|
||||||
|
GENERIC_CONVERT(iptr, short, short)
|
||||||
|
GENERIC_CONVERT(iptr, ushort, unsigned short)
|
||||||
|
GENERIC_CONVERT(iptr, int, int)
|
||||||
|
GENERIC_CONVERT(iptr, uint, unsigned int)
|
||||||
|
GENERIC_CONVERT(iptr, long, long)
|
||||||
|
GENERIC_CONVERT(iptr, ulong, unsigned long)
|
||||||
|
GENERIC_CONVERT(iptr, longlong, long long)
|
||||||
|
GENERIC_CONVERT(iptr, ulonglong, unsigned long long)
|
||||||
|
GENERIC_CONVERT(iptr, size, size_t)
|
||||||
|
GENERIC_CONVERT(iptr, float, float)
|
||||||
|
GENERIC_CONVERT(iptr, double, double)
|
||||||
|
|
||||||
|
BINARY_OP(add, +, iptr)
|
||||||
|
BINARY_OP(subtract, -, iptr)
|
||||||
|
BINARY_OP(multiply, *, iptr)
|
||||||
|
BINARY_OP(divide, /, iptr)
|
||||||
|
PREFIX_OP(increment, ++, iptr)
|
||||||
|
PREFIX_OP(decrement, --, iptr)
|
||||||
|
IN_PLACE_OP(add_in_place, +=, iptr)
|
||||||
|
IN_PLACE_OP(subtract_in_place, -=, iptr)
|
||||||
|
IN_PLACE_OP(multiply_in_place, *=, iptr)
|
||||||
|
IN_PLACE_OP(divide_in_place, /=, iptr)
|
||||||
|
|
||||||
|
COMPARE(iptr, iptr)
|
||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_BEGIN(fx_iptr)
|
FX_TYPE_CLASS_BEGIN(fx_iptr)
|
||||||
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
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_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_operable, FX_TYPE_OPERABLE)
|
||||||
|
FX_INTERFACE_ENTRY(op_add) = add;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract) = subtract;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply) = multiply;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide) = divide;
|
||||||
|
FX_INTERFACE_ENTRY(op_increment) = increment;
|
||||||
|
FX_INTERFACE_ENTRY(op_decrement) = decrement;
|
||||||
|
FX_INTERFACE_ENTRY(op_add_in_place) = add_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract_in_place) = subtract_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply_in_place) = multiply_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide_in_place) = divide_in_place;
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_END(fx_operable, FX_TYPE_OPERABLE)
|
||||||
|
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_convertible, FX_TYPE_CONVERTIBLE)
|
||||||
|
FX_INTERFACE_ENTRY(c_to_bool) = to_bool;
|
||||||
|
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_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_iptr)
|
FX_TYPE_CLASS_END(fx_iptr)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_iptr)
|
FX_TYPE_DEFINITION_BEGIN(fx_iptr)
|
||||||
__FX_VALUE_TYPE_ID(IPTR);
|
__FX_VALUE_TYPE_ID(IPTR);
|
||||||
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_CONVERTIBLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_OPERABLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_COMPARABLE);
|
||||||
FX_TYPE_NAME("fx.iptr");
|
FX_TYPE_NAME("fx.iptr");
|
||||||
FX_TYPE_CLASS(fx_iptr_class);
|
FX_TYPE_CLASS(fx_iptr_class);
|
||||||
FX_TYPE_INSTANCE_PRIVATE(iptr);
|
FX_TYPE_INSTANCE_PRIVATE(iptr);
|
||||||
|
|||||||
+86
-1
@@ -1,17 +1,102 @@
|
|||||||
|
#include "convert.h"
|
||||||
|
|
||||||
#include <fx/int.h>
|
#include <fx/int.h>
|
||||||
#include <fx/value-type.h>
|
#include <fx/value-type.h>
|
||||||
|
|
||||||
|
HASH(long)
|
||||||
|
TO_STRING(long, "%ld")
|
||||||
|
|
||||||
|
BOOL_CONVERT(long)
|
||||||
|
GENERIC_CONVERT(long, i16, i16)
|
||||||
|
GENERIC_CONVERT(long, u16, u16)
|
||||||
|
GENERIC_CONVERT(long, i32, i32)
|
||||||
|
GENERIC_CONVERT(long, u32, u32)
|
||||||
|
GENERIC_CONVERT(long, i64, i64)
|
||||||
|
GENERIC_CONVERT(long, u64, u64)
|
||||||
|
GENERIC_CONVERT(long, iptr, iptr)
|
||||||
|
GENERIC_CONVERT(long, uptr, uptr)
|
||||||
|
GENERIC_CONVERT(long, sbyte, sbyte)
|
||||||
|
GENERIC_CONVERT(long, byte, byte)
|
||||||
|
GENERIC_CONVERT(long, short, short)
|
||||||
|
GENERIC_CONVERT(long, ushort, unsigned short)
|
||||||
|
GENERIC_CONVERT(long, int, int)
|
||||||
|
GENERIC_CONVERT(long, uint, unsigned int)
|
||||||
|
GENERIC_CONVERT(long, ulong, unsigned long)
|
||||||
|
GENERIC_CONVERT(long, longlong, long long)
|
||||||
|
GENERIC_CONVERT(long, ulonglong, unsigned long long)
|
||||||
|
GENERIC_CONVERT(long, size, size_t)
|
||||||
|
GENERIC_CONVERT(long, float, float)
|
||||||
|
GENERIC_CONVERT(long, double, double)
|
||||||
|
|
||||||
|
BINARY_OP(add, +, long)
|
||||||
|
BINARY_OP(subtract, -, long)
|
||||||
|
BINARY_OP(multiply, *, long)
|
||||||
|
BINARY_OP(divide, /, long)
|
||||||
|
PREFIX_OP(increment, ++, long)
|
||||||
|
PREFIX_OP(decrement, --, long)
|
||||||
|
IN_PLACE_OP(add_in_place, +=, long)
|
||||||
|
IN_PLACE_OP(subtract_in_place, -=, long)
|
||||||
|
IN_PLACE_OP(multiply_in_place, *=, long)
|
||||||
|
IN_PLACE_OP(divide_in_place, /=, long)
|
||||||
|
|
||||||
|
COMPARE(long, long)
|
||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_BEGIN(fx_long)
|
FX_TYPE_CLASS_BEGIN(fx_long)
|
||||||
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
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_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_operable, FX_TYPE_OPERABLE)
|
||||||
|
FX_INTERFACE_ENTRY(op_add) = add;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract) = subtract;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply) = multiply;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide) = divide;
|
||||||
|
FX_INTERFACE_ENTRY(op_increment) = increment;
|
||||||
|
FX_INTERFACE_ENTRY(op_decrement) = decrement;
|
||||||
|
FX_INTERFACE_ENTRY(op_add_in_place) = add_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract_in_place) = subtract_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply_in_place) = multiply_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide_in_place) = divide_in_place;
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_END(fx_operable, FX_TYPE_OPERABLE)
|
||||||
|
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_convertible, FX_TYPE_CONVERTIBLE)
|
||||||
|
FX_INTERFACE_ENTRY(c_to_bool) = to_bool;
|
||||||
|
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_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_long)
|
FX_TYPE_CLASS_END(fx_long)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_long)
|
FX_TYPE_DEFINITION_BEGIN(fx_long)
|
||||||
__FX_VALUE_TYPE_ID(LONG);
|
__FX_VALUE_TYPE_ID(LONG);
|
||||||
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_CONVERTIBLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_OPERABLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_COMPARABLE);
|
||||||
FX_TYPE_NAME("fx.long");
|
FX_TYPE_NAME("fx.long");
|
||||||
FX_TYPE_CLASS(fx_long_class);
|
FX_TYPE_CLASS(fx_long_class);
|
||||||
FX_TYPE_INSTANCE_PRIVATE(long);
|
FX_TYPE_INSTANCE_PRIVATE(long);
|
||||||
|
|||||||
+86
-1
@@ -1,17 +1,102 @@
|
|||||||
|
#include "convert.h"
|
||||||
|
|
||||||
#include <fx/int.h>
|
#include <fx/int.h>
|
||||||
#include <fx/value-type.h>
|
#include <fx/value-type.h>
|
||||||
|
|
||||||
|
HASH(longlong)
|
||||||
|
TO_STRING(longlong, "%lld")
|
||||||
|
|
||||||
|
BOOL_CONVERT(longlong)
|
||||||
|
GENERIC_CONVERT(longlong, i16, i16)
|
||||||
|
GENERIC_CONVERT(longlong, u16, u16)
|
||||||
|
GENERIC_CONVERT(longlong, i32, i32)
|
||||||
|
GENERIC_CONVERT(longlong, u32, u32)
|
||||||
|
GENERIC_CONVERT(longlong, i64, i64)
|
||||||
|
GENERIC_CONVERT(longlong, u64, u64)
|
||||||
|
GENERIC_CONVERT(longlong, iptr, iptr)
|
||||||
|
GENERIC_CONVERT(longlong, uptr, uptr)
|
||||||
|
GENERIC_CONVERT(longlong, sbyte, sbyte)
|
||||||
|
GENERIC_CONVERT(longlong, byte, byte)
|
||||||
|
GENERIC_CONVERT(longlong, short, short)
|
||||||
|
GENERIC_CONVERT(longlong, ushort, unsigned short)
|
||||||
|
GENERIC_CONVERT(longlong, int, int)
|
||||||
|
GENERIC_CONVERT(longlong, uint, unsigned int)
|
||||||
|
GENERIC_CONVERT(longlong, long, long)
|
||||||
|
GENERIC_CONVERT(longlong, ulong, unsigned long)
|
||||||
|
GENERIC_CONVERT(longlong, ulonglong, unsigned long long)
|
||||||
|
GENERIC_CONVERT(longlong, size, size_t)
|
||||||
|
GENERIC_CONVERT(longlong, float, float)
|
||||||
|
GENERIC_CONVERT(longlong, double, double)
|
||||||
|
|
||||||
|
BINARY_OP(add, +, longlong)
|
||||||
|
BINARY_OP(subtract, -, longlong)
|
||||||
|
BINARY_OP(multiply, *, longlong)
|
||||||
|
BINARY_OP(divide, /, longlong)
|
||||||
|
PREFIX_OP(increment, ++, longlong)
|
||||||
|
PREFIX_OP(decrement, --, longlong)
|
||||||
|
IN_PLACE_OP(add_in_place, +=, longlong)
|
||||||
|
IN_PLACE_OP(subtract_in_place, -=, longlong)
|
||||||
|
IN_PLACE_OP(multiply_in_place, *=, longlong)
|
||||||
|
IN_PLACE_OP(divide_in_place, /=, longlong)
|
||||||
|
|
||||||
|
COMPARE(longlong, long long)
|
||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_BEGIN(fx_longlong)
|
FX_TYPE_CLASS_BEGIN(fx_longlong)
|
||||||
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
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_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_operable, FX_TYPE_OPERABLE)
|
||||||
|
FX_INTERFACE_ENTRY(op_add) = add;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract) = subtract;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply) = multiply;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide) = divide;
|
||||||
|
FX_INTERFACE_ENTRY(op_increment) = increment;
|
||||||
|
FX_INTERFACE_ENTRY(op_decrement) = decrement;
|
||||||
|
FX_INTERFACE_ENTRY(op_add_in_place) = add_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract_in_place) = subtract_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply_in_place) = multiply_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide_in_place) = divide_in_place;
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_END(fx_operable, FX_TYPE_OPERABLE)
|
||||||
|
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_convertible, FX_TYPE_CONVERTIBLE)
|
||||||
|
FX_INTERFACE_ENTRY(c_to_bool) = to_bool;
|
||||||
|
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_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_longlong)
|
FX_TYPE_CLASS_END(fx_longlong)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_longlong)
|
FX_TYPE_DEFINITION_BEGIN(fx_longlong)
|
||||||
__FX_VALUE_TYPE_ID(LONGLONG);
|
__FX_VALUE_TYPE_ID(LONGLONG);
|
||||||
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_CONVERTIBLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_OPERABLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_COMPARABLE);
|
||||||
FX_TYPE_NAME("fx.longlong");
|
FX_TYPE_NAME("fx.longlong");
|
||||||
FX_TYPE_CLASS(fx_longlong_class);
|
FX_TYPE_CLASS(fx_longlong_class);
|
||||||
FX_TYPE_INSTANCE_PRIVATE(long long);
|
FX_TYPE_INSTANCE_PRIVATE(long long);
|
||||||
|
|||||||
+86
-1
@@ -1,17 +1,102 @@
|
|||||||
|
#include "convert.h"
|
||||||
|
|
||||||
#include <fx/int.h>
|
#include <fx/int.h>
|
||||||
#include <fx/value-type.h>
|
#include <fx/value-type.h>
|
||||||
|
|
||||||
|
HASH(sbyte)
|
||||||
|
TO_STRING(sbyte, "%d")
|
||||||
|
|
||||||
|
BOOL_CONVERT(sbyte)
|
||||||
|
GENERIC_CONVERT(sbyte, i16, i16)
|
||||||
|
GENERIC_CONVERT(sbyte, u16, u16)
|
||||||
|
GENERIC_CONVERT(sbyte, i32, i32)
|
||||||
|
GENERIC_CONVERT(sbyte, u32, u32)
|
||||||
|
GENERIC_CONVERT(sbyte, i64, i64)
|
||||||
|
GENERIC_CONVERT(sbyte, u64, u64)
|
||||||
|
GENERIC_CONVERT(sbyte, iptr, iptr)
|
||||||
|
GENERIC_CONVERT(sbyte, uptr, uptr)
|
||||||
|
GENERIC_CONVERT(sbyte, byte, byte)
|
||||||
|
GENERIC_CONVERT(sbyte, short, short)
|
||||||
|
GENERIC_CONVERT(sbyte, ushort, unsigned short)
|
||||||
|
GENERIC_CONVERT(sbyte, int, int)
|
||||||
|
GENERIC_CONVERT(sbyte, uint, unsigned int)
|
||||||
|
GENERIC_CONVERT(sbyte, long, long)
|
||||||
|
GENERIC_CONVERT(sbyte, ulong, unsigned long)
|
||||||
|
GENERIC_CONVERT(sbyte, longlong, long long)
|
||||||
|
GENERIC_CONVERT(sbyte, ulonglong, unsigned long long)
|
||||||
|
GENERIC_CONVERT(sbyte, size, size_t)
|
||||||
|
GENERIC_CONVERT(sbyte, float, float)
|
||||||
|
GENERIC_CONVERT(sbyte, double, double)
|
||||||
|
|
||||||
|
BINARY_OP(add, +, sbyte)
|
||||||
|
BINARY_OP(subtract, -, sbyte)
|
||||||
|
BINARY_OP(multiply, *, sbyte)
|
||||||
|
BINARY_OP(divide, /, sbyte)
|
||||||
|
PREFIX_OP(increment, ++, sbyte)
|
||||||
|
PREFIX_OP(decrement, --, sbyte)
|
||||||
|
IN_PLACE_OP(add_in_place, +=, sbyte)
|
||||||
|
IN_PLACE_OP(subtract_in_place, -=, sbyte)
|
||||||
|
IN_PLACE_OP(multiply_in_place, *=, sbyte)
|
||||||
|
IN_PLACE_OP(divide_in_place, /=, sbyte)
|
||||||
|
|
||||||
|
COMPARE(sbyte, sbyte)
|
||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_BEGIN(fx_sbyte)
|
FX_TYPE_CLASS_BEGIN(fx_sbyte)
|
||||||
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
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_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_operable, FX_TYPE_OPERABLE)
|
||||||
|
FX_INTERFACE_ENTRY(op_add) = add;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract) = subtract;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply) = multiply;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide) = divide;
|
||||||
|
FX_INTERFACE_ENTRY(op_increment) = increment;
|
||||||
|
FX_INTERFACE_ENTRY(op_decrement) = decrement;
|
||||||
|
FX_INTERFACE_ENTRY(op_add_in_place) = add_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract_in_place) = subtract_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply_in_place) = multiply_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide_in_place) = divide_in_place;
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_END(fx_operable, FX_TYPE_OPERABLE)
|
||||||
|
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_convertible, FX_TYPE_CONVERTIBLE)
|
||||||
|
FX_INTERFACE_ENTRY(c_to_bool) = to_bool;
|
||||||
|
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_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_sbyte)
|
FX_TYPE_CLASS_END(fx_sbyte)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_sbyte)
|
FX_TYPE_DEFINITION_BEGIN(fx_sbyte)
|
||||||
__FX_VALUE_TYPE_ID(SBYTE);
|
__FX_VALUE_TYPE_ID(SBYTE);
|
||||||
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_CONVERTIBLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_OPERABLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_COMPARABLE);
|
||||||
FX_TYPE_NAME("fx.sbyte");
|
FX_TYPE_NAME("fx.sbyte");
|
||||||
FX_TYPE_CLASS(fx_sbyte_class);
|
FX_TYPE_CLASS(fx_sbyte_class);
|
||||||
FX_TYPE_INSTANCE_PRIVATE(sbyte);
|
FX_TYPE_INSTANCE_PRIVATE(sbyte);
|
||||||
|
|||||||
+85
-1
@@ -1,18 +1,102 @@
|
|||||||
|
#include "convert.h"
|
||||||
|
|
||||||
#include <fx/int.h>
|
#include <fx/int.h>
|
||||||
#include <fx/value-type.h>
|
#include <fx/value-type.h>
|
||||||
|
|
||||||
|
HASH(short)
|
||||||
|
TO_STRING(short, "%d")
|
||||||
|
|
||||||
|
BOOL_CONVERT(short)
|
||||||
|
GENERIC_CONVERT(short, i16, i16)
|
||||||
|
GENERIC_CONVERT(short, u16, u16)
|
||||||
|
GENERIC_CONVERT(short, i32, i32)
|
||||||
|
GENERIC_CONVERT(short, u32, u32)
|
||||||
|
GENERIC_CONVERT(short, i64, i64)
|
||||||
|
GENERIC_CONVERT(short, u64, u64)
|
||||||
|
GENERIC_CONVERT(short, iptr, iptr)
|
||||||
|
GENERIC_CONVERT(short, uptr, uptr)
|
||||||
|
GENERIC_CONVERT(short, sbyte, sbyte)
|
||||||
|
GENERIC_CONVERT(short, byte, byte)
|
||||||
|
GENERIC_CONVERT(short, ushort, unsigned short)
|
||||||
|
GENERIC_CONVERT(short, int, int)
|
||||||
|
GENERIC_CONVERT(short, uint, unsigned int)
|
||||||
|
GENERIC_CONVERT(short, long, long)
|
||||||
|
GENERIC_CONVERT(short, ulong, unsigned long)
|
||||||
|
GENERIC_CONVERT(short, longlong, long long)
|
||||||
|
GENERIC_CONVERT(short, ulonglong, unsigned long long)
|
||||||
|
GENERIC_CONVERT(short, size, size_t)
|
||||||
|
GENERIC_CONVERT(short, float, float)
|
||||||
|
GENERIC_CONVERT(short, double, double)
|
||||||
|
|
||||||
|
BINARY_OP(add, +, short)
|
||||||
|
BINARY_OP(subtract, -, short)
|
||||||
|
BINARY_OP(multiply, *, short)
|
||||||
|
BINARY_OP(divide, /, short)
|
||||||
|
PREFIX_OP(increment, ++, short)
|
||||||
|
PREFIX_OP(decrement, --, short)
|
||||||
|
IN_PLACE_OP(add_in_place, +=, short)
|
||||||
|
IN_PLACE_OP(subtract_in_place, -=, short)
|
||||||
|
IN_PLACE_OP(multiply_in_place, *=, short)
|
||||||
|
IN_PLACE_OP(divide_in_place, /=, short)
|
||||||
|
|
||||||
|
COMPARE(short, short)
|
||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_BEGIN(fx_short)
|
FX_TYPE_CLASS_BEGIN(fx_short)
|
||||||
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
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_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_operable, FX_TYPE_OPERABLE)
|
||||||
|
FX_INTERFACE_ENTRY(op_add) = add;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract) = subtract;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply) = multiply;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide) = divide;
|
||||||
|
FX_INTERFACE_ENTRY(op_increment) = increment;
|
||||||
|
FX_INTERFACE_ENTRY(op_decrement) = decrement;
|
||||||
|
FX_INTERFACE_ENTRY(op_add_in_place) = add_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract_in_place) = subtract_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply_in_place) = multiply_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide_in_place) = divide_in_place;
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_END(fx_operable, FX_TYPE_OPERABLE)
|
||||||
|
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_convertible, FX_TYPE_CONVERTIBLE)
|
||||||
|
FX_INTERFACE_ENTRY(c_to_bool) = to_bool;
|
||||||
|
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_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_short)
|
FX_TYPE_CLASS_END(fx_short)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_short)
|
FX_TYPE_DEFINITION_BEGIN(fx_short)
|
||||||
__FX_VALUE_TYPE_ID(SHORT);
|
__FX_VALUE_TYPE_ID(SHORT);
|
||||||
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_CONVERTIBLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_OPERABLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_COMPARABLE);
|
||||||
FX_TYPE_NAME("fx.short");
|
FX_TYPE_NAME("fx.short");
|
||||||
FX_TYPE_CLASS(fx_short_class);
|
FX_TYPE_CLASS(fx_short_class);
|
||||||
FX_TYPE_INSTANCE_PRIVATE(short);
|
FX_TYPE_INSTANCE_PRIVATE(short);
|
||||||
|
|||||||
+86
-1
@@ -1,17 +1,102 @@
|
|||||||
|
#include "convert.h"
|
||||||
|
|
||||||
#include <fx/int.h>
|
#include <fx/int.h>
|
||||||
#include <fx/value-type.h>
|
#include <fx/value-type.h>
|
||||||
|
|
||||||
|
HASH(size)
|
||||||
|
TO_STRING(size, "%zu")
|
||||||
|
|
||||||
|
BOOL_CONVERT(size)
|
||||||
|
GENERIC_CONVERT(size, i16, i16)
|
||||||
|
GENERIC_CONVERT(size, u16, u16)
|
||||||
|
GENERIC_CONVERT(size, i32, i32)
|
||||||
|
GENERIC_CONVERT(size, u32, u32)
|
||||||
|
GENERIC_CONVERT(size, i64, i64)
|
||||||
|
GENERIC_CONVERT(size, u64, u64)
|
||||||
|
GENERIC_CONVERT(size, iptr, iptr)
|
||||||
|
GENERIC_CONVERT(size, uptr, uptr)
|
||||||
|
GENERIC_CONVERT(size, sbyte, sbyte)
|
||||||
|
GENERIC_CONVERT(size, byte, byte)
|
||||||
|
GENERIC_CONVERT(size, short, short)
|
||||||
|
GENERIC_CONVERT(size, ushort, unsigned short)
|
||||||
|
GENERIC_CONVERT(size, int, int)
|
||||||
|
GENERIC_CONVERT(size, uint, unsigned int)
|
||||||
|
GENERIC_CONVERT(size, long, long)
|
||||||
|
GENERIC_CONVERT(size, ulong, unsigned long)
|
||||||
|
GENERIC_CONVERT(size, longlong, long long)
|
||||||
|
GENERIC_CONVERT(size, ulonglong, unsigned long long)
|
||||||
|
GENERIC_CONVERT(size, float, float)
|
||||||
|
GENERIC_CONVERT(size, double, double)
|
||||||
|
|
||||||
|
BINARY_OP(add, +, size)
|
||||||
|
BINARY_OP(subtract, -, size)
|
||||||
|
BINARY_OP(multiply, *, size)
|
||||||
|
BINARY_OP(divide, /, size)
|
||||||
|
PREFIX_OP(increment, ++, size)
|
||||||
|
PREFIX_OP(decrement, --, size)
|
||||||
|
IN_PLACE_OP(add_in_place, +=, size)
|
||||||
|
IN_PLACE_OP(subtract_in_place, -=, size)
|
||||||
|
IN_PLACE_OP(multiply_in_place, *=, size)
|
||||||
|
IN_PLACE_OP(divide_in_place, /=, size)
|
||||||
|
|
||||||
|
COMPARE(size, size_t)
|
||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_BEGIN(fx_size)
|
FX_TYPE_CLASS_BEGIN(fx_size)
|
||||||
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
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_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_operable, FX_TYPE_OPERABLE)
|
||||||
|
FX_INTERFACE_ENTRY(op_add) = add;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract) = subtract;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply) = multiply;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide) = divide;
|
||||||
|
FX_INTERFACE_ENTRY(op_increment) = increment;
|
||||||
|
FX_INTERFACE_ENTRY(op_decrement) = decrement;
|
||||||
|
FX_INTERFACE_ENTRY(op_add_in_place) = add_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract_in_place) = subtract_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply_in_place) = multiply_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide_in_place) = divide_in_place;
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_END(fx_operable, FX_TYPE_OPERABLE)
|
||||||
|
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_convertible, FX_TYPE_CONVERTIBLE)
|
||||||
|
FX_INTERFACE_ENTRY(c_to_bool) = to_bool;
|
||||||
|
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_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_size)
|
FX_TYPE_CLASS_END(fx_size)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_size)
|
FX_TYPE_DEFINITION_BEGIN(fx_size)
|
||||||
__FX_VALUE_TYPE_ID(SIZE);
|
__FX_VALUE_TYPE_ID(SIZE);
|
||||||
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_CONVERTIBLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_COMPARABLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_OPERABLE);
|
||||||
FX_TYPE_NAME("fx.size");
|
FX_TYPE_NAME("fx.size");
|
||||||
FX_TYPE_CLASS(fx_size_class);
|
FX_TYPE_CLASS(fx_size_class);
|
||||||
FX_TYPE_INSTANCE_PRIVATE(size_t);
|
FX_TYPE_INSTANCE_PRIVATE(size_t);
|
||||||
|
|||||||
+88
-1
@@ -1,5 +1,9 @@
|
|||||||
|
#include "convert.h"
|
||||||
|
|
||||||
|
#include <fx/convertible.h>
|
||||||
#include <fx/int.h>
|
#include <fx/int.h>
|
||||||
#include <fx/value-type.h>
|
#include <fx/value-type.h>
|
||||||
|
#include <fx/value.h>
|
||||||
|
|
||||||
#define SWAP16(v) (((v << 8) & 0xFF00) | ((v >> 8) & 0x00FF))
|
#define SWAP16(v) (((v << 8) & 0xFF00) | ((v >> 8) & 0x00FF))
|
||||||
|
|
||||||
@@ -39,17 +43,100 @@ u16 fx_u16_stoh(u16 v)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HASH(u16)
|
||||||
|
TO_STRING(u16, "%" PRIu16)
|
||||||
|
|
||||||
|
BOOL_CONVERT(u16)
|
||||||
|
GENERIC_CONVERT(u16, i16, i16)
|
||||||
|
GENERIC_CONVERT(u16, i32, i32)
|
||||||
|
GENERIC_CONVERT(u16, u32, u32)
|
||||||
|
GENERIC_CONVERT(u16, i64, i64)
|
||||||
|
GENERIC_CONVERT(u16, u64, u64)
|
||||||
|
GENERIC_CONVERT(u16, iptr, iptr)
|
||||||
|
GENERIC_CONVERT(u16, uptr, uptr)
|
||||||
|
GENERIC_CONVERT(u16, sbyte, sbyte)
|
||||||
|
GENERIC_CONVERT(u16, byte, byte)
|
||||||
|
GENERIC_CONVERT(u16, short, short)
|
||||||
|
GENERIC_CONVERT(u16, ushort, unsigned short)
|
||||||
|
GENERIC_CONVERT(u16, int, int)
|
||||||
|
GENERIC_CONVERT(u16, uint, unsigned int)
|
||||||
|
GENERIC_CONVERT(u16, long, long)
|
||||||
|
GENERIC_CONVERT(u16, ulong, unsigned long)
|
||||||
|
GENERIC_CONVERT(u16, longlong, long long)
|
||||||
|
GENERIC_CONVERT(u16, ulonglong, unsigned long long)
|
||||||
|
GENERIC_CONVERT(u16, size, size_t)
|
||||||
|
GENERIC_CONVERT(u16, float, float)
|
||||||
|
GENERIC_CONVERT(u16, double, double)
|
||||||
|
|
||||||
|
BINARY_OP(add, +, u16)
|
||||||
|
BINARY_OP(subtract, -, u16)
|
||||||
|
BINARY_OP(multiply, *, u16)
|
||||||
|
BINARY_OP(divide, /, u16)
|
||||||
|
PREFIX_OP(increment, ++, u16)
|
||||||
|
PREFIX_OP(decrement, --, u16)
|
||||||
|
IN_PLACE_OP(add_in_place, +=, u16)
|
||||||
|
IN_PLACE_OP(subtract_in_place, -=, u16)
|
||||||
|
IN_PLACE_OP(multiply_in_place, *=, u16)
|
||||||
|
IN_PLACE_OP(divide_in_place, /=, u16)
|
||||||
|
|
||||||
|
COMPARE(u16, u16)
|
||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_BEGIN(fx_u16)
|
FX_TYPE_CLASS_BEGIN(fx_u16)
|
||||||
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
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_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_operable, FX_TYPE_OPERABLE)
|
||||||
|
FX_INTERFACE_ENTRY(op_add) = add;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract) = subtract;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply) = multiply;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide) = divide;
|
||||||
|
FX_INTERFACE_ENTRY(op_increment) = increment;
|
||||||
|
FX_INTERFACE_ENTRY(op_decrement) = decrement;
|
||||||
|
FX_INTERFACE_ENTRY(op_add_in_place) = add_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract_in_place) = subtract_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply_in_place) = multiply_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide_in_place) = divide_in_place;
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_END(fx_operable, FX_TYPE_OPERABLE)
|
||||||
|
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_convertible, FX_TYPE_CONVERTIBLE)
|
||||||
|
FX_INTERFACE_ENTRY(c_to_bool) = to_bool;
|
||||||
|
FX_INTERFACE_ENTRY(c_to_i16) = to_i16;
|
||||||
|
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_u16)
|
FX_TYPE_CLASS_END(fx_u16)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_u16)
|
FX_TYPE_DEFINITION_BEGIN(fx_u16)
|
||||||
__FX_VALUE_TYPE_ID(U16);
|
__FX_VALUE_TYPE_ID(U16);
|
||||||
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_CONVERTIBLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_OPERABLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_COMPARABLE);
|
||||||
FX_TYPE_NAME("fx.u16");
|
FX_TYPE_NAME("fx.u16");
|
||||||
FX_TYPE_CLASS(fx_u16_class);
|
FX_TYPE_CLASS(fx_u16_class);
|
||||||
FX_TYPE_INSTANCE_PRIVATE(u16);
|
FX_TYPE_INSTANCE_PRIVATE(u16);
|
||||||
|
|||||||
+88
-1
@@ -1,5 +1,9 @@
|
|||||||
|
#include "convert.h"
|
||||||
|
|
||||||
|
#include <fx/convertible.h>
|
||||||
#include <fx/int.h>
|
#include <fx/int.h>
|
||||||
#include <fx/value-type.h>
|
#include <fx/value-type.h>
|
||||||
|
#include <fx/value.h>
|
||||||
|
|
||||||
#define SWAP32(v) \
|
#define SWAP32(v) \
|
||||||
(((v << 24) & 0xFF000000) | ((v << 8) & 0x00FF0000) \
|
(((v << 24) & 0xFF000000) | ((v << 8) & 0x00FF0000) \
|
||||||
@@ -41,17 +45,100 @@ u32 fx_u32_stoh(u32 v)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HASH(u32)
|
||||||
|
TO_STRING(u32, "%" PRIu32)
|
||||||
|
|
||||||
|
BOOL_CONVERT(u32)
|
||||||
|
GENERIC_CONVERT(u32, i16, i16)
|
||||||
|
GENERIC_CONVERT(u32, u16, u16)
|
||||||
|
GENERIC_CONVERT(u32, i32, i32)
|
||||||
|
GENERIC_CONVERT(u32, i64, i64)
|
||||||
|
GENERIC_CONVERT(u32, u64, u64)
|
||||||
|
GENERIC_CONVERT(u32, iptr, iptr)
|
||||||
|
GENERIC_CONVERT(u32, uptr, uptr)
|
||||||
|
GENERIC_CONVERT(u32, sbyte, sbyte)
|
||||||
|
GENERIC_CONVERT(u32, byte, byte)
|
||||||
|
GENERIC_CONVERT(u32, short, short)
|
||||||
|
GENERIC_CONVERT(u32, ushort, unsigned short)
|
||||||
|
GENERIC_CONVERT(u32, int, int)
|
||||||
|
GENERIC_CONVERT(u32, uint, unsigned int)
|
||||||
|
GENERIC_CONVERT(u32, long, long)
|
||||||
|
GENERIC_CONVERT(u32, ulong, unsigned long)
|
||||||
|
GENERIC_CONVERT(u32, longlong, long long)
|
||||||
|
GENERIC_CONVERT(u32, ulonglong, unsigned long long)
|
||||||
|
GENERIC_CONVERT(u32, size, size_t)
|
||||||
|
GENERIC_CONVERT(u32, float, float)
|
||||||
|
GENERIC_CONVERT(u32, double, double)
|
||||||
|
|
||||||
|
BINARY_OP(add, +, u32)
|
||||||
|
BINARY_OP(subtract, -, u32)
|
||||||
|
BINARY_OP(multiply, *, u32)
|
||||||
|
BINARY_OP(divide, /, u32)
|
||||||
|
PREFIX_OP(increment, ++, u32)
|
||||||
|
PREFIX_OP(decrement, --, u32)
|
||||||
|
IN_PLACE_OP(add_in_place, +=, u32)
|
||||||
|
IN_PLACE_OP(subtract_in_place, -=, u32)
|
||||||
|
IN_PLACE_OP(multiply_in_place, *=, u32)
|
||||||
|
IN_PLACE_OP(divide_in_place, /=, u32)
|
||||||
|
|
||||||
|
COMPARE(u32, u32)
|
||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_BEGIN(fx_u32)
|
FX_TYPE_CLASS_BEGIN(fx_u32)
|
||||||
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
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_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_operable, FX_TYPE_OPERABLE)
|
||||||
|
FX_INTERFACE_ENTRY(op_add) = add;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract) = subtract;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply) = multiply;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide) = divide;
|
||||||
|
FX_INTERFACE_ENTRY(op_increment) = increment;
|
||||||
|
FX_INTERFACE_ENTRY(op_decrement) = decrement;
|
||||||
|
FX_INTERFACE_ENTRY(op_add_in_place) = add_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract_in_place) = subtract_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply_in_place) = multiply_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide_in_place) = divide_in_place;
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_END(fx_operable, FX_TYPE_OPERABLE)
|
||||||
|
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_convertible, FX_TYPE_CONVERTIBLE)
|
||||||
|
FX_INTERFACE_ENTRY(c_to_bool) = to_bool;
|
||||||
|
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_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_u32)
|
FX_TYPE_CLASS_END(fx_u32)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_u32)
|
FX_TYPE_DEFINITION_BEGIN(fx_u32)
|
||||||
__FX_VALUE_TYPE_ID(U32);
|
__FX_VALUE_TYPE_ID(U32);
|
||||||
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_CONVERTIBLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_OPERABLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_COMPARABLE);
|
||||||
FX_TYPE_NAME("fx.u32");
|
FX_TYPE_NAME("fx.u32");
|
||||||
FX_TYPE_CLASS(fx_u32_class);
|
FX_TYPE_CLASS(fx_u32_class);
|
||||||
FX_TYPE_INSTANCE_PRIVATE(u32);
|
FX_TYPE_INSTANCE_PRIVATE(u32);
|
||||||
|
|||||||
+88
-1
@@ -1,5 +1,9 @@
|
|||||||
|
#include "convert.h"
|
||||||
|
|
||||||
|
#include <fx/convertible.h>
|
||||||
#include <fx/int.h>
|
#include <fx/int.h>
|
||||||
#include <fx/value-type.h>
|
#include <fx/value-type.h>
|
||||||
|
#include <fx/value.h>
|
||||||
|
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
#define SWAP64(v) \
|
#define SWAP64(v) \
|
||||||
@@ -45,17 +49,100 @@ u64 fx_u64_stoh(u64 v)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HASH(u64)
|
||||||
|
TO_STRING(u64, "%" PRIu64)
|
||||||
|
|
||||||
|
BOOL_CONVERT(u64)
|
||||||
|
GENERIC_CONVERT(u64, i16, i16)
|
||||||
|
GENERIC_CONVERT(u64, u16, u16)
|
||||||
|
GENERIC_CONVERT(u64, i32, i32)
|
||||||
|
GENERIC_CONVERT(u64, u32, u32)
|
||||||
|
GENERIC_CONVERT(u64, i64, i64)
|
||||||
|
GENERIC_CONVERT(u64, iptr, iptr)
|
||||||
|
GENERIC_CONVERT(u64, uptr, uptr)
|
||||||
|
GENERIC_CONVERT(u64, sbyte, sbyte)
|
||||||
|
GENERIC_CONVERT(u64, byte, byte)
|
||||||
|
GENERIC_CONVERT(u64, short, short)
|
||||||
|
GENERIC_CONVERT(u64, ushort, unsigned short)
|
||||||
|
GENERIC_CONVERT(u64, int, int)
|
||||||
|
GENERIC_CONVERT(u64, uint, unsigned int)
|
||||||
|
GENERIC_CONVERT(u64, long, long)
|
||||||
|
GENERIC_CONVERT(u64, ulong, unsigned long)
|
||||||
|
GENERIC_CONVERT(u64, longlong, long long)
|
||||||
|
GENERIC_CONVERT(u64, ulonglong, unsigned long long)
|
||||||
|
GENERIC_CONVERT(u64, size, size_t)
|
||||||
|
GENERIC_CONVERT(u64, float, float)
|
||||||
|
GENERIC_CONVERT(u64, double, double)
|
||||||
|
|
||||||
|
BINARY_OP(add, +, u64)
|
||||||
|
BINARY_OP(subtract, -, u64)
|
||||||
|
BINARY_OP(multiply, *, u64)
|
||||||
|
BINARY_OP(divide, /, u64)
|
||||||
|
PREFIX_OP(increment, ++, u64)
|
||||||
|
PREFIX_OP(decrement, --, u64)
|
||||||
|
IN_PLACE_OP(add_in_place, +=, u64)
|
||||||
|
IN_PLACE_OP(subtract_in_place, -=, u64)
|
||||||
|
IN_PLACE_OP(multiply_in_place, *=, u64)
|
||||||
|
IN_PLACE_OP(divide_in_place, /=, u64)
|
||||||
|
|
||||||
|
COMPARE(u64, u64)
|
||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_BEGIN(fx_u64)
|
FX_TYPE_CLASS_BEGIN(fx_u64)
|
||||||
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
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_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_operable, FX_TYPE_OPERABLE)
|
||||||
|
FX_INTERFACE_ENTRY(op_add) = add;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract) = subtract;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply) = multiply;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide) = divide;
|
||||||
|
FX_INTERFACE_ENTRY(op_increment) = increment;
|
||||||
|
FX_INTERFACE_ENTRY(op_decrement) = decrement;
|
||||||
|
FX_INTERFACE_ENTRY(op_add_in_place) = add_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract_in_place) = subtract_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply_in_place) = multiply_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide_in_place) = divide_in_place;
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_END(fx_operable, FX_TYPE_OPERABLE)
|
||||||
|
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_convertible, FX_TYPE_CONVERTIBLE)
|
||||||
|
FX_INTERFACE_ENTRY(c_to_bool) = to_bool;
|
||||||
|
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_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_u64)
|
FX_TYPE_CLASS_END(fx_u64)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_u64)
|
FX_TYPE_DEFINITION_BEGIN(fx_u64)
|
||||||
__FX_VALUE_TYPE_ID(U64);
|
__FX_VALUE_TYPE_ID(U64);
|
||||||
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_CONVERTIBLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_OPERABLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_COMPARABLE);
|
||||||
FX_TYPE_NAME("fx.u64");
|
FX_TYPE_NAME("fx.u64");
|
||||||
FX_TYPE_CLASS(fx_u64_class);
|
FX_TYPE_CLASS(fx_u64_class);
|
||||||
FX_TYPE_INSTANCE_PRIVATE(u64);
|
FX_TYPE_INSTANCE_PRIVATE(u64);
|
||||||
|
|||||||
+86
-1
@@ -1,17 +1,102 @@
|
|||||||
|
#include "convert.h"
|
||||||
|
|
||||||
#include <fx/int.h>
|
#include <fx/int.h>
|
||||||
#include <fx/value-type.h>
|
#include <fx/value-type.h>
|
||||||
|
|
||||||
|
HASH(uint)
|
||||||
|
TO_STRING(uint, "%u")
|
||||||
|
|
||||||
|
BOOL_CONVERT(uint)
|
||||||
|
GENERIC_CONVERT(uint, i16, i16)
|
||||||
|
GENERIC_CONVERT(uint, u16, u16)
|
||||||
|
GENERIC_CONVERT(uint, i32, i32)
|
||||||
|
GENERIC_CONVERT(uint, u32, u32)
|
||||||
|
GENERIC_CONVERT(uint, i64, i64)
|
||||||
|
GENERIC_CONVERT(uint, u64, u64)
|
||||||
|
GENERIC_CONVERT(uint, iptr, iptr)
|
||||||
|
GENERIC_CONVERT(uint, uptr, uptr)
|
||||||
|
GENERIC_CONVERT(uint, sbyte, sbyte)
|
||||||
|
GENERIC_CONVERT(uint, byte, byte)
|
||||||
|
GENERIC_CONVERT(uint, short, short)
|
||||||
|
GENERIC_CONVERT(uint, ushort, unsigned short)
|
||||||
|
GENERIC_CONVERT(uint, int, int)
|
||||||
|
GENERIC_CONVERT(uint, long, long)
|
||||||
|
GENERIC_CONVERT(uint, ulong, unsigned long)
|
||||||
|
GENERIC_CONVERT(uint, longlong, long long)
|
||||||
|
GENERIC_CONVERT(uint, ulonglong, unsigned long long)
|
||||||
|
GENERIC_CONVERT(uint, size, size_t)
|
||||||
|
GENERIC_CONVERT(uint, float, float)
|
||||||
|
GENERIC_CONVERT(uint, double, double)
|
||||||
|
|
||||||
|
BINARY_OP(add, +, uint)
|
||||||
|
BINARY_OP(subtract, -, uint)
|
||||||
|
BINARY_OP(multiply, *, uint)
|
||||||
|
BINARY_OP(divide, /, uint)
|
||||||
|
PREFIX_OP(increment, ++, uint)
|
||||||
|
PREFIX_OP(decrement, --, uint)
|
||||||
|
IN_PLACE_OP(add_in_place, +=, uint)
|
||||||
|
IN_PLACE_OP(subtract_in_place, -=, uint)
|
||||||
|
IN_PLACE_OP(multiply_in_place, *=, uint)
|
||||||
|
IN_PLACE_OP(divide_in_place, /=, uint)
|
||||||
|
|
||||||
|
COMPARE(uint, unsigned int)
|
||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_BEGIN(fx_uint)
|
FX_TYPE_CLASS_BEGIN(fx_uint)
|
||||||
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
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_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_operable, FX_TYPE_OPERABLE)
|
||||||
|
FX_INTERFACE_ENTRY(op_add) = add;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract) = subtract;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply) = multiply;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide) = divide;
|
||||||
|
FX_INTERFACE_ENTRY(op_increment) = increment;
|
||||||
|
FX_INTERFACE_ENTRY(op_decrement) = decrement;
|
||||||
|
FX_INTERFACE_ENTRY(op_add_in_place) = add_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract_in_place) = subtract_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply_in_place) = multiply_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide_in_place) = divide_in_place;
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_END(fx_operable, FX_TYPE_OPERABLE)
|
||||||
|
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_convertible, FX_TYPE_CONVERTIBLE)
|
||||||
|
FX_INTERFACE_ENTRY(c_to_bool) = to_bool;
|
||||||
|
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_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_uint)
|
FX_TYPE_CLASS_END(fx_uint)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_uint)
|
FX_TYPE_DEFINITION_BEGIN(fx_uint)
|
||||||
__FX_VALUE_TYPE_ID(UINT);
|
__FX_VALUE_TYPE_ID(UINT);
|
||||||
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_CONVERTIBLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_OPERABLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_COMPARABLE);
|
||||||
FX_TYPE_NAME("fx.uint");
|
FX_TYPE_NAME("fx.uint");
|
||||||
FX_TYPE_CLASS(fx_uint_class);
|
FX_TYPE_CLASS(fx_uint_class);
|
||||||
FX_TYPE_INSTANCE_PRIVATE(unsigned int);
|
FX_TYPE_INSTANCE_PRIVATE(unsigned int);
|
||||||
|
|||||||
+86
-1
@@ -1,17 +1,102 @@
|
|||||||
|
#include "convert.h"
|
||||||
|
|
||||||
#include <fx/int.h>
|
#include <fx/int.h>
|
||||||
#include <fx/value-type.h>
|
#include <fx/value-type.h>
|
||||||
|
|
||||||
|
HASH(ulong)
|
||||||
|
TO_STRING(ulong, "%lu")
|
||||||
|
|
||||||
|
BOOL_CONVERT(ulong)
|
||||||
|
GENERIC_CONVERT(ulong, i16, i16)
|
||||||
|
GENERIC_CONVERT(ulong, u16, u16)
|
||||||
|
GENERIC_CONVERT(ulong, i32, i32)
|
||||||
|
GENERIC_CONVERT(ulong, u32, u32)
|
||||||
|
GENERIC_CONVERT(ulong, i64, i64)
|
||||||
|
GENERIC_CONVERT(ulong, u64, u64)
|
||||||
|
GENERIC_CONVERT(ulong, iptr, iptr)
|
||||||
|
GENERIC_CONVERT(ulong, uptr, uptr)
|
||||||
|
GENERIC_CONVERT(ulong, sbyte, sbyte)
|
||||||
|
GENERIC_CONVERT(ulong, byte, byte)
|
||||||
|
GENERIC_CONVERT(ulong, short, short)
|
||||||
|
GENERIC_CONVERT(ulong, ushort, unsigned short)
|
||||||
|
GENERIC_CONVERT(ulong, int, int)
|
||||||
|
GENERIC_CONVERT(ulong, uint, unsigned int)
|
||||||
|
GENERIC_CONVERT(ulong, long, long)
|
||||||
|
GENERIC_CONVERT(ulong, longlong, long long)
|
||||||
|
GENERIC_CONVERT(ulong, ulonglong, unsigned long long)
|
||||||
|
GENERIC_CONVERT(ulong, size, size_t)
|
||||||
|
GENERIC_CONVERT(ulong, float, float)
|
||||||
|
GENERIC_CONVERT(ulong, double, double)
|
||||||
|
|
||||||
|
BINARY_OP(add, +, ulong)
|
||||||
|
BINARY_OP(subtract, -, ulong)
|
||||||
|
BINARY_OP(multiply, *, ulong)
|
||||||
|
BINARY_OP(divide, /, ulong)
|
||||||
|
PREFIX_OP(increment, ++, ulong)
|
||||||
|
PREFIX_OP(decrement, --, ulong)
|
||||||
|
IN_PLACE_OP(add_in_place, +=, ulong)
|
||||||
|
IN_PLACE_OP(subtract_in_place, -=, ulong)
|
||||||
|
IN_PLACE_OP(multiply_in_place, *=, ulong)
|
||||||
|
IN_PLACE_OP(divide_in_place, /=, ulong)
|
||||||
|
|
||||||
|
COMPARE(ulong, unsigned long)
|
||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_BEGIN(fx_ulong)
|
FX_TYPE_CLASS_BEGIN(fx_ulong)
|
||||||
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
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_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_operable, FX_TYPE_OPERABLE)
|
||||||
|
FX_INTERFACE_ENTRY(op_add) = add;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract) = subtract;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply) = multiply;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide) = divide;
|
||||||
|
FX_INTERFACE_ENTRY(op_increment) = increment;
|
||||||
|
FX_INTERFACE_ENTRY(op_decrement) = decrement;
|
||||||
|
FX_INTERFACE_ENTRY(op_add_in_place) = add_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract_in_place) = subtract_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply_in_place) = multiply_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide_in_place) = divide_in_place;
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_END(fx_operable, FX_TYPE_OPERABLE)
|
||||||
|
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_convertible, FX_TYPE_CONVERTIBLE)
|
||||||
|
FX_INTERFACE_ENTRY(c_to_bool) = to_bool;
|
||||||
|
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_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_ulong)
|
FX_TYPE_CLASS_END(fx_ulong)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_ulong)
|
FX_TYPE_DEFINITION_BEGIN(fx_ulong)
|
||||||
__FX_VALUE_TYPE_ID(ULONG);
|
__FX_VALUE_TYPE_ID(ULONG);
|
||||||
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_CONVERTIBLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_OPERABLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_COMPARABLE);
|
||||||
FX_TYPE_NAME("fx.ulong");
|
FX_TYPE_NAME("fx.ulong");
|
||||||
FX_TYPE_CLASS(fx_ulong_class);
|
FX_TYPE_CLASS(fx_ulong_class);
|
||||||
FX_TYPE_INSTANCE_PRIVATE(unsigned long);
|
FX_TYPE_INSTANCE_PRIVATE(unsigned long);
|
||||||
|
|||||||
+86
-1
@@ -1,17 +1,102 @@
|
|||||||
|
#include "convert.h"
|
||||||
|
|
||||||
#include <fx/int.h>
|
#include <fx/int.h>
|
||||||
#include <fx/value-type.h>
|
#include <fx/value-type.h>
|
||||||
|
|
||||||
|
HASH(ulonglong)
|
||||||
|
TO_STRING(ulonglong, "%llu")
|
||||||
|
|
||||||
|
BOOL_CONVERT(ulonglong)
|
||||||
|
GENERIC_CONVERT(ulonglong, i16, i16)
|
||||||
|
GENERIC_CONVERT(ulonglong, u16, u16)
|
||||||
|
GENERIC_CONVERT(ulonglong, i32, i32)
|
||||||
|
GENERIC_CONVERT(ulonglong, u32, u32)
|
||||||
|
GENERIC_CONVERT(ulonglong, i64, i64)
|
||||||
|
GENERIC_CONVERT(ulonglong, u64, u64)
|
||||||
|
GENERIC_CONVERT(ulonglong, iptr, iptr)
|
||||||
|
GENERIC_CONVERT(ulonglong, uptr, uptr)
|
||||||
|
GENERIC_CONVERT(ulonglong, sbyte, sbyte)
|
||||||
|
GENERIC_CONVERT(ulonglong, byte, byte)
|
||||||
|
GENERIC_CONVERT(ulonglong, short, short)
|
||||||
|
GENERIC_CONVERT(ulonglong, ushort, unsigned short)
|
||||||
|
GENERIC_CONVERT(ulonglong, int, int)
|
||||||
|
GENERIC_CONVERT(ulonglong, uint, unsigned int)
|
||||||
|
GENERIC_CONVERT(ulonglong, long, long)
|
||||||
|
GENERIC_CONVERT(ulonglong, ulong, unsigned long)
|
||||||
|
GENERIC_CONVERT(ulonglong, longlong, long long)
|
||||||
|
GENERIC_CONVERT(ulonglong, size, size_t)
|
||||||
|
GENERIC_CONVERT(ulonglong, float, float)
|
||||||
|
GENERIC_CONVERT(ulonglong, double, double)
|
||||||
|
|
||||||
|
BINARY_OP(add, +, ulonglong)
|
||||||
|
BINARY_OP(subtract, -, ulonglong)
|
||||||
|
BINARY_OP(multiply, *, ulonglong)
|
||||||
|
BINARY_OP(divide, /, ulonglong)
|
||||||
|
PREFIX_OP(increment, ++, ulonglong)
|
||||||
|
PREFIX_OP(decrement, --, ulonglong)
|
||||||
|
IN_PLACE_OP(add_in_place, +=, ulonglong)
|
||||||
|
IN_PLACE_OP(subtract_in_place, -=, ulonglong)
|
||||||
|
IN_PLACE_OP(multiply_in_place, *=, ulonglong)
|
||||||
|
IN_PLACE_OP(divide_in_place, /=, ulonglong)
|
||||||
|
|
||||||
|
COMPARE(ulonglong, unsigned long long)
|
||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_BEGIN(fx_ulonglong)
|
FX_TYPE_CLASS_BEGIN(fx_ulonglong)
|
||||||
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
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_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_operable, FX_TYPE_OPERABLE)
|
||||||
|
FX_INTERFACE_ENTRY(op_add) = add;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract) = subtract;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply) = multiply;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide) = divide;
|
||||||
|
FX_INTERFACE_ENTRY(op_increment) = increment;
|
||||||
|
FX_INTERFACE_ENTRY(op_decrement) = decrement;
|
||||||
|
FX_INTERFACE_ENTRY(op_add_in_place) = add_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract_in_place) = subtract_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply_in_place) = multiply_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide_in_place) = divide_in_place;
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_END(fx_operable, FX_TYPE_OPERABLE)
|
||||||
|
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_convertible, FX_TYPE_CONVERTIBLE)
|
||||||
|
FX_INTERFACE_ENTRY(c_to_bool) = to_bool;
|
||||||
|
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_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_ulonglong)
|
FX_TYPE_CLASS_END(fx_ulonglong)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_ulonglong)
|
FX_TYPE_DEFINITION_BEGIN(fx_ulonglong)
|
||||||
__FX_VALUE_TYPE_ID(ULONGLONG);
|
__FX_VALUE_TYPE_ID(ULONGLONG);
|
||||||
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_CONVERTIBLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_OPERABLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_COMPARABLE);
|
||||||
FX_TYPE_NAME("fx.ulonglong");
|
FX_TYPE_NAME("fx.ulonglong");
|
||||||
FX_TYPE_CLASS(fx_ulonglong_class);
|
FX_TYPE_CLASS(fx_ulonglong_class);
|
||||||
FX_TYPE_INSTANCE_PRIVATE(unsigned long long);
|
FX_TYPE_INSTANCE_PRIVATE(unsigned long long);
|
||||||
|
|||||||
+86
-1
@@ -1,17 +1,102 @@
|
|||||||
|
#include "convert.h"
|
||||||
|
|
||||||
#include <fx/int.h>
|
#include <fx/int.h>
|
||||||
#include <fx/value-type.h>
|
#include <fx/value-type.h>
|
||||||
|
|
||||||
|
HASH(uptr)
|
||||||
|
TO_STRING(uptr, "%" PRIuPTR)
|
||||||
|
|
||||||
|
BOOL_CONVERT(uptr)
|
||||||
|
GENERIC_CONVERT(uptr, i16, i16)
|
||||||
|
GENERIC_CONVERT(uptr, u16, u16)
|
||||||
|
GENERIC_CONVERT(uptr, i32, i32)
|
||||||
|
GENERIC_CONVERT(uptr, u32, u32)
|
||||||
|
GENERIC_CONVERT(uptr, i64, i64)
|
||||||
|
GENERIC_CONVERT(uptr, u64, u64)
|
||||||
|
GENERIC_CONVERT(uptr, iptr, iptr)
|
||||||
|
GENERIC_CONVERT(uptr, sbyte, sbyte)
|
||||||
|
GENERIC_CONVERT(uptr, byte, byte)
|
||||||
|
GENERIC_CONVERT(uptr, short, short)
|
||||||
|
GENERIC_CONVERT(uptr, ushort, unsigned short)
|
||||||
|
GENERIC_CONVERT(uptr, int, int)
|
||||||
|
GENERIC_CONVERT(uptr, uint, unsigned int)
|
||||||
|
GENERIC_CONVERT(uptr, long, long)
|
||||||
|
GENERIC_CONVERT(uptr, ulong, unsigned long)
|
||||||
|
GENERIC_CONVERT(uptr, longlong, long long)
|
||||||
|
GENERIC_CONVERT(uptr, ulonglong, unsigned long long)
|
||||||
|
GENERIC_CONVERT(uptr, size, size_t)
|
||||||
|
GENERIC_CONVERT(uptr, float, float)
|
||||||
|
GENERIC_CONVERT(uptr, double, double)
|
||||||
|
|
||||||
|
BINARY_OP(add, +, uptr)
|
||||||
|
BINARY_OP(subtract, -, uptr)
|
||||||
|
BINARY_OP(multiply, *, uptr)
|
||||||
|
BINARY_OP(divide, /, uptr)
|
||||||
|
PREFIX_OP(increment, ++, uptr)
|
||||||
|
PREFIX_OP(decrement, --, uptr)
|
||||||
|
IN_PLACE_OP(add_in_place, +=, uptr)
|
||||||
|
IN_PLACE_OP(subtract_in_place, -=, uptr)
|
||||||
|
IN_PLACE_OP(multiply_in_place, *=, uptr)
|
||||||
|
IN_PLACE_OP(divide_in_place, /=, uptr)
|
||||||
|
|
||||||
|
COMPARE(uptr, uptr)
|
||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_BEGIN(fx_uptr)
|
FX_TYPE_CLASS_BEGIN(fx_uptr)
|
||||||
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
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_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_operable, FX_TYPE_OPERABLE)
|
||||||
|
FX_INTERFACE_ENTRY(op_add) = add;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract) = subtract;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply) = multiply;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide) = divide;
|
||||||
|
FX_INTERFACE_ENTRY(op_increment) = increment;
|
||||||
|
FX_INTERFACE_ENTRY(op_decrement) = decrement;
|
||||||
|
FX_INTERFACE_ENTRY(op_add_in_place) = add_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract_in_place) = subtract_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply_in_place) = multiply_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide_in_place) = divide_in_place;
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_END(fx_operable, FX_TYPE_OPERABLE)
|
||||||
|
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_convertible, FX_TYPE_CONVERTIBLE)
|
||||||
|
FX_INTERFACE_ENTRY(c_to_bool) = to_bool;
|
||||||
|
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_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_uptr)
|
FX_TYPE_CLASS_END(fx_uptr)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_uptr)
|
FX_TYPE_DEFINITION_BEGIN(fx_uptr)
|
||||||
__FX_VALUE_TYPE_ID(UPTR);
|
__FX_VALUE_TYPE_ID(UPTR);
|
||||||
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_CONVERTIBLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_OPERABLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_COMPARABLE);
|
||||||
FX_TYPE_NAME("fx.uptr");
|
FX_TYPE_NAME("fx.uptr");
|
||||||
FX_TYPE_CLASS(fx_uptr_class);
|
FX_TYPE_CLASS(fx_uptr_class);
|
||||||
FX_TYPE_INSTANCE_PRIVATE(uptr);
|
FX_TYPE_INSTANCE_PRIVATE(uptr);
|
||||||
|
|||||||
+86
-1
@@ -1,17 +1,102 @@
|
|||||||
|
#include "convert.h"
|
||||||
|
|
||||||
#include <fx/int.h>
|
#include <fx/int.h>
|
||||||
#include <fx/value-type.h>
|
#include <fx/value-type.h>
|
||||||
|
|
||||||
|
HASH(ushort)
|
||||||
|
TO_STRING(ushort, "%u")
|
||||||
|
|
||||||
|
BOOL_CONVERT(ushort)
|
||||||
|
GENERIC_CONVERT(ushort, i16, i16)
|
||||||
|
GENERIC_CONVERT(ushort, u16, u16)
|
||||||
|
GENERIC_CONVERT(ushort, i32, i32)
|
||||||
|
GENERIC_CONVERT(ushort, u32, u32)
|
||||||
|
GENERIC_CONVERT(ushort, i64, i64)
|
||||||
|
GENERIC_CONVERT(ushort, u64, u64)
|
||||||
|
GENERIC_CONVERT(ushort, iptr, iptr)
|
||||||
|
GENERIC_CONVERT(ushort, uptr, uptr)
|
||||||
|
GENERIC_CONVERT(ushort, sbyte, sbyte)
|
||||||
|
GENERIC_CONVERT(ushort, byte, byte)
|
||||||
|
GENERIC_CONVERT(ushort, short, short)
|
||||||
|
GENERIC_CONVERT(ushort, int, int)
|
||||||
|
GENERIC_CONVERT(ushort, uint, unsigned int)
|
||||||
|
GENERIC_CONVERT(ushort, long, long)
|
||||||
|
GENERIC_CONVERT(ushort, ulong, unsigned long)
|
||||||
|
GENERIC_CONVERT(ushort, longlong, long long)
|
||||||
|
GENERIC_CONVERT(ushort, ulonglong, unsigned long long)
|
||||||
|
GENERIC_CONVERT(ushort, size, size_t)
|
||||||
|
GENERIC_CONVERT(ushort, float, float)
|
||||||
|
GENERIC_CONVERT(ushort, double, double)
|
||||||
|
|
||||||
|
BINARY_OP(add, +, ushort)
|
||||||
|
BINARY_OP(subtract, -, ushort)
|
||||||
|
BINARY_OP(multiply, *, ushort)
|
||||||
|
BINARY_OP(divide, /, ushort)
|
||||||
|
PREFIX_OP(increment, ++, ushort)
|
||||||
|
PREFIX_OP(decrement, --, ushort)
|
||||||
|
IN_PLACE_OP(add_in_place, +=, ushort)
|
||||||
|
IN_PLACE_OP(subtract_in_place, -=, ushort)
|
||||||
|
IN_PLACE_OP(multiply_in_place, *=, ushort)
|
||||||
|
IN_PLACE_OP(divide_in_place, /=, ushort)
|
||||||
|
|
||||||
|
COMPARE(ushort, unsigned short)
|
||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_BEGIN(fx_ushort)
|
FX_TYPE_CLASS_BEGIN(fx_ushort)
|
||||||
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
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_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_operable, FX_TYPE_OPERABLE)
|
||||||
|
FX_INTERFACE_ENTRY(op_add) = add;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract) = subtract;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply) = multiply;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide) = divide;
|
||||||
|
FX_INTERFACE_ENTRY(op_increment) = increment;
|
||||||
|
FX_INTERFACE_ENTRY(op_decrement) = decrement;
|
||||||
|
FX_INTERFACE_ENTRY(op_add_in_place) = add_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_subtract_in_place) = subtract_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_multiply_in_place) = multiply_in_place;
|
||||||
|
FX_INTERFACE_ENTRY(op_divide_in_place) = divide_in_place;
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_END(fx_operable, FX_TYPE_OPERABLE)
|
||||||
|
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_convertible, FX_TYPE_CONVERTIBLE)
|
||||||
|
FX_INTERFACE_ENTRY(c_to_bool) = to_bool;
|
||||||
|
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_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_ushort)
|
FX_TYPE_CLASS_END(fx_ushort)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_ushort)
|
FX_TYPE_DEFINITION_BEGIN(fx_ushort)
|
||||||
__FX_VALUE_TYPE_ID(USHORT);
|
__FX_VALUE_TYPE_ID(USHORT);
|
||||||
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
FX_TYPE_EXTENDS(FX_TYPE_VALUE_TYPE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_CONVERTIBLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_OPERABLE);
|
||||||
|
FX_TYPE_IMPLEMENTS(FX_TYPE_COMPARABLE);
|
||||||
FX_TYPE_NAME("fx.ushort");
|
FX_TYPE_NAME("fx.ushort");
|
||||||
FX_TYPE_CLASS(fx_ushort_class);
|
FX_TYPE_CLASS(fx_ushort_class);
|
||||||
FX_TYPE_INSTANCE_PRIVATE(unsigned short);
|
FX_TYPE_INSTANCE_PRIVATE(unsigned short);
|
||||||
|
|||||||
Reference in New Issue
Block a user