Add a number implementation struct to libab.
This commit is contained in:
parent
596e1419b4
commit
b12f6d7a31
|
@ -7,6 +7,7 @@
|
|||
#include "parser.h"
|
||||
#include "result.h"
|
||||
#include "table.h"
|
||||
#include "number.h"
|
||||
|
||||
/**
|
||||
* The main struct of libabacus,
|
||||
|
@ -29,6 +30,10 @@ struct libab_s {
|
|||
* things like functions and operators.
|
||||
*/
|
||||
libab_table table;
|
||||
/**
|
||||
* The number implementation used by this instance.
|
||||
*/
|
||||
libab_number_impl impl;
|
||||
};
|
||||
|
||||
typedef struct libab_s libab;
|
||||
|
|
37
include/number.h
Normal file
37
include/number.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
#ifndef LIBABACUS_NUMBER_H
|
||||
#define LIBABACUS_NUMBER_H
|
||||
|
||||
typedef void (*libab_num_function)(void*, void*, void*);
|
||||
typedef void (*libab_num_function_unary)(void*, void*);
|
||||
|
||||
/**
|
||||
* Struct that holds information
|
||||
* about the implementation of numbers
|
||||
* that is being used by libab. This is not
|
||||
* assumed or inferred, and it's necessary to
|
||||
* provide all of these definitions.
|
||||
*/
|
||||
struct libab_number_impl_s {
|
||||
/**
|
||||
* The function used to allocate a number.
|
||||
*/
|
||||
void* (*allocate)();
|
||||
/**
|
||||
* The function used to free a number.
|
||||
*/
|
||||
void (*free)(void*);
|
||||
/**
|
||||
* The function used to construct a number
|
||||
* out of a string.
|
||||
*/
|
||||
void* (*parse)(const char*);
|
||||
/**
|
||||
* A function to copy the value of one number
|
||||
* into the value of another.
|
||||
*/
|
||||
void (*copy)(void*, void*);
|
||||
};
|
||||
|
||||
typedef struct libab_number_impl_s libab_number_impl;
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user