fx: add interface for performing arithmetic operations on values
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
#ifndef FX_OPERABLE_H_
|
||||
#define FX_OPERABLE_H_
|
||||
|
||||
#include <fx/int-primitives.h>
|
||||
#include <fx/macros.h>
|
||||
#include <fx/value.h>
|
||||
|
||||
FX_DECLS_BEGIN;
|
||||
|
||||
#define FX_TYPE_OPERABLE (fx_operable_get_type())
|
||||
|
||||
FX_DECLARE_TYPE(fx_operable);
|
||||
|
||||
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_operable)
|
||||
fx_status (*op_add)(
|
||||
const fx_value *left,
|
||||
const fx_value *right,
|
||||
fx_value *out);
|
||||
fx_status (*op_subtract)(
|
||||
const fx_value *left,
|
||||
const fx_value *right,
|
||||
fx_value *out);
|
||||
fx_status (*op_multiply)(
|
||||
const fx_value *left,
|
||||
const fx_value *right,
|
||||
fx_value *out);
|
||||
fx_status (*op_divide)(
|
||||
const fx_value *left,
|
||||
const fx_value *right,
|
||||
fx_value *out);
|
||||
fx_status (*op_increment)(fx_value *value);
|
||||
fx_status (*op_decrement)(fx_value *value);
|
||||
fx_status (*op_add_in_place)(fx_value *left, const fx_value *right);
|
||||
fx_status (
|
||||
*op_subtract_in_place)(fx_value *left, const fx_value *right);
|
||||
fx_status (
|
||||
*op_multiply_in_place)(fx_value *left, const fx_value *right);
|
||||
fx_status (*op_divide_in_place)(fx_value *left, const fx_value *right);
|
||||
FX_TYPE_CLASS_DECLARATION_END(fx_operable)
|
||||
|
||||
FX_API fx_type_id fx_operable_get_type(void);
|
||||
|
||||
FX_DECLS_END;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,15 @@
|
||||
#include <fx/macros.h>
|
||||
#include <fx/operable.h>
|
||||
|
||||
FX_TYPE_CLASS_BEGIN(fx_operable)
|
||||
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_operable)
|
||||
|
||||
FX_TYPE_DEFINITION_BEGIN(fx_operable)
|
||||
FX_TYPE_FLAGS(FX_TYPE_F_ABSTRACT);
|
||||
FX_TYPE_ID(0x90a346c8, 0x0c34, 0x4189, 0xbc05, 0xf778637d8015);
|
||||
FX_TYPE_NAME("fx.operable");
|
||||
FX_TYPE_CLASS(fx_operable_class);
|
||||
FX_TYPE_DEFINITION_END(fx_operable)
|
||||
Reference in New Issue
Block a user