fx: add interface for converting a value to a different type
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
#include <fx/convertible.h>
|
||||
#include <fx/macros.h>
|
||||
|
||||
FX_TYPE_CLASS_BEGIN(fx_convertible)
|
||||
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
||||
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||
FX_TYPE_CLASS_END(fx_convertible)
|
||||
|
||||
FX_TYPE_DEFINITION_BEGIN(fx_convertible)
|
||||
FX_TYPE_FLAGS(FX_TYPE_F_ABSTRACT);
|
||||
FX_TYPE_ID(0x8443b648, 0x83ea, 0x4a65, 0x85ef, 0x5570b0157d0e);
|
||||
FX_TYPE_NAME("fx.convertible");
|
||||
FX_TYPE_CLASS(fx_convertible_class);
|
||||
FX_TYPE_DEFINITION_END(fx_convertible)
|
||||
@@ -0,0 +1,59 @@
|
||||
#ifndef FX_CONVERTIBLE_H_
|
||||
#define FX_CONVERTIBLE_H_
|
||||
|
||||
#include <fx/encoding.h>
|
||||
#include <fx/int-primitives.h>
|
||||
#include <fx/macros.h>
|
||||
#include <fx/string.h>
|
||||
#include <fx/value.h>
|
||||
|
||||
FX_DECLS_BEGIN;
|
||||
|
||||
#define FX_TYPE_CONVERTIBLE (fx_convertible_get_type())
|
||||
|
||||
FX_DECLARE_TYPE(fx_convertible);
|
||||
|
||||
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_convertible)
|
||||
fx_status (*c_to_char)(const fx_value *in, fx_wchar *out);
|
||||
|
||||
fx_status (*c_to_bool)(const fx_value *in, bool *out);
|
||||
fx_status (*c_to_i16)(const fx_value *in, i16 *out);
|
||||
fx_status (*c_to_u16)(const fx_value *in, u16 *out);
|
||||
fx_status (*c_to_i32)(const fx_value *in, i32 *out);
|
||||
fx_status (*c_to_u32)(const fx_value *in, u32 *out);
|
||||
fx_status (*c_to_i64)(const fx_value *in, i64 *out);
|
||||
fx_status (*c_to_u64)(const fx_value *in, u64 *out);
|
||||
fx_status (*c_to_iptr)(const fx_value *in, iptr *out);
|
||||
fx_status (*c_to_uptr)(const fx_value *in, uptr *out);
|
||||
|
||||
fx_status (*c_to_sbyte)(const fx_value *in, sbyte *out);
|
||||
fx_status (*c_to_byte)(const fx_value *in, byte *out);
|
||||
fx_status (*c_to_short)(const fx_value *in, short *out);
|
||||
fx_status (*c_to_ushort)(const fx_value *in, unsigned short *out);
|
||||
fx_status (*c_to_int)(const fx_value *in, int *out);
|
||||
fx_status (*c_to_uint)(const fx_value *in, unsigned int *out);
|
||||
fx_status (*c_to_long)(const fx_value *in, long *out);
|
||||
fx_status (*c_to_ulong)(const fx_value *in, unsigned long *out);
|
||||
fx_status (*c_to_longlong)(const fx_value *in, long long *out);
|
||||
fx_status (
|
||||
*c_to_ulonglong)(const fx_value *in, unsigned long long *out);
|
||||
fx_status (*c_to_size)(const fx_value *in, size_t *out);
|
||||
|
||||
fx_status (*c_to_float)(const fx_value *in, float *out);
|
||||
fx_status (*c_to_double)(const fx_value *in, double *out);
|
||||
|
||||
fx_status (*c_to_cstr)(const fx_value *in, const char **out);
|
||||
fx_status (*c_to_wchar)(const fx_value *in, fx_wchar *out);
|
||||
fx_status (*c_to_wstr)(const fx_value *in, const fx_wchar **out);
|
||||
|
||||
fx_status (*c_to_object)(
|
||||
const fx_value *in,
|
||||
fx_value *out,
|
||||
fx_type_id convert_to);
|
||||
FX_TYPE_CLASS_DECLARATION_END(fx_convertible)
|
||||
|
||||
FX_API fx_type_id fx_convertible_get_type(void);
|
||||
|
||||
FX_DECLS_END;
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user