added qse_awk_fnc_spec_t.

renamed qse_awk_mod_info_t to qse_awk_mod_spec_t
This commit is contained in:
2012-11-03 17:44:23 +00:00
parent 7557b22cb8
commit 3f99d7ac3d
17 changed files with 355 additions and 325 deletions

View File

@ -82,9 +82,11 @@ public:
typedef qse_awk_sio_cmd_t sio_cmd_t;
typedef qse_awk_fnc_spec_t fnc_spec_t;
typedef qse_awk_fnc_info_t fnc_info_t;
typedef qse_awk_mod_info_t mod_info_t;
typedef qse_awk_mod_spec_t mod_spec_t;
class Run;
friend class Run;
@ -1226,7 +1228,7 @@ protected:
virtual flt_t exp (flt_t x) = 0;
virtual flt_t sqrt (flt_t x) = 0;
virtual void* modopen (const mod_info_t* info) = 0;
virtual void* modopen (const mod_spec_t* spec) = 0;
virtual void modclose (void* handle) = 0;
virtual void* modsym (void* handle, const char_t* name) = 0;
@ -1265,7 +1267,7 @@ protected:
static flt_t exp (awk_t* awk, flt_t x);
static flt_t sqrt (awk_t* awk, flt_t x);
static void* modopen (awk_t* awk, const mod_info_t* info);
static void* modopen (awk_t* awk, const mod_spec_t* spec);
static void modclose (awk_t* awk, void* handle);
static void* modsym (awk_t* awk, void* handle, const char_t* name);

View File

@ -200,7 +200,7 @@ protected:
flt_t exp (flt_t x);
flt_t sqrt (flt_t x);
void* modopen (const mod_info_t* info);
void* modopen (const mod_spec_t* spec);
void modclose (void* handle);
void* modsym (void* handle, const char_t* name);

View File

@ -303,6 +303,8 @@ struct qse_awk_val_map_data_t
};
typedef struct qse_awk_val_map_data_t qse_awk_val_map_data_t;
/* ------------------------------------------------------------------------ */
/**
* The qse_awk_nde_type_t defines the node types.
*/
@ -378,6 +380,8 @@ struct qse_awk_nde_t
QSE_AWK_NDE_HDR;
};
/* ------------------------------------------------------------------------ */
/**
* The qse_awk_fun_t type defines a structure to maintain functions
* defined with the keyword 'function'.
@ -390,10 +394,7 @@ struct qse_awk_fun_t
};
typedef struct qse_awk_fun_t qse_awk_fun_t;
#define QSE_AWK_FUN_NAME(fun) ((const qse_xstr_t*)&(fun)->name)
#define QSE_AWK_FUN_NAME_PTR(fun) ((const qse_char_t*)(fun)->name.ptr)
#define QSE_AWK_FUN_NAME_LEN(fun) (*(const qse_size_t*)&(fun)->name.len)
#define QSE_AWK_FUN_NARGS(fun) (*(const qse_size_t*)&(fun)->nargs)
/* ------------------------------------------------------------------------ */
typedef int (*qse_awk_sprintf_t) (
qse_awk_t* awk,
@ -414,9 +415,11 @@ typedef qse_flt_t (*qse_awk_math2_t) (
qse_flt_t y
);
typedef struct qse_awk_mod_info_t qse_awk_mod_info_t;
/* ------------------------------------------------------------------------ */
struct qse_awk_mod_info_t
typedef struct qse_awk_mod_spec_t qse_awk_mod_spec_t;
struct qse_awk_mod_spec_t
{
const qse_char_t* prefix;
const qse_char_t* postfix;
@ -425,7 +428,7 @@ struct qse_awk_mod_info_t
typedef void* (*qse_awk_modopen_t) (
qse_awk_t* awk,
const qse_awk_mod_info_t* info
const qse_awk_mod_spec_t* spec
);
typedef void* (*qse_awk_modsym_t) (
@ -439,6 +442,8 @@ typedef void (*qse_awk_modclose_t) (
void* handle
);
/* ------------------------------------------------------------------------ */
#if 0
typedef void* (*qse_awk_buildrex_t) (
qse_awk_t* awk,
@ -728,8 +733,7 @@ typedef struct qse_awk_rio_t qse_awk_rio_t;
/* ------------------------------------------------------------------------ */
typedef struct qse_awk_mod_t qse_awk_mod_t;
typedef struct qse_awk_mod_sym_t qse_awk_mod_sym_t;
typedef struct qse_awk_fnc_spec_t qse_awk_fnc_spec_t;
typedef struct qse_awk_fnc_info_t qse_awk_fnc_info_t;
/**
@ -740,12 +744,48 @@ typedef int (*qse_awk_fnc_impl_t) (
const qse_awk_fnc_info_t* fi /**< function information */
);
/**
* The qse_awk_fnc_spec_t type defines a structure to hold the specification
* of an intrinsic function or a module function.
*/
struct qse_awk_fnc_spec_t
{
/** parameter specification */
struct
{
int min; /**< min. numbers of argument for a function */
int max; /**< max. numbers of argument for a function */
const qse_char_t* spec;
} arg;
/** pointer to the function implementing this function */
qse_awk_fnc_impl_t impl;
/**
* when this field is set to a non-zero value bitwise-ORed of
* #qse_awk_trait_t enumerators, the function is available if
* this field bitwise-ANDed the global trait option produces
* this field itself.
*
* this field doesn't take effect for a module function.
*/
int trait;
};
/* ------------------------------------------------------------------------ */
typedef struct qse_awk_mod_t qse_awk_mod_t;
typedef struct qse_awk_mod_sym_t qse_awk_mod_sym_t;
struct qse_awk_fnc_info_t
{
qse_xstr_t name;
qse_awk_mod_t* mod;
/** #QSE_NULL if the function is not registered from module */
qse_awk_mod_t* mod;
};
typedef int (*qse_awk_mod_load_t) (
qse_awk_mod_t* mod,
qse_awk_t* awk
@ -794,20 +834,10 @@ enum qse_awk_mod_sym_type_t
*/
};
typedef enum qse_awk_mod_sym_type_t qse_awk_mod_sym_type_t;
typedef struct qse_awk_mod_sym_fnc_t qse_awk_mod_sym_fnc_t;
typedef qse_awk_fnc_spec_t qse_awk_mod_sym_fnc_t;
typedef struct qse_awk_mod_sym_int_t qse_awk_mod_sym_int_t;
typedef struct qse_awk_mod_sym_flt_t qse_awk_mod_sym_flt_t;
struct qse_awk_mod_sym_fnc_t
{
struct
{
int min; /* min. numbers of argument for a function */
int max; /* max. numbers of argument for a function */
} arg;
qse_awk_fnc_impl_t impl;
};
struct qse_awk_mod_sym_int_t
{
qse_long_t val;
@ -1057,6 +1087,7 @@ enum qse_awk_trait_t
QSE_AWK_CLASSIC | QSE_AWK_EXTRAKWS | QSE_AWK_MAPTOVAR |
QSE_AWK_RWPIPE | QSE_AWK_TOLERANT
};
typedef enum qse_awk_trait_t qse_awk_trait_t;
/* ------------------------------------------------------------------------ */
@ -1581,8 +1612,7 @@ QSE_EXPORT void qse_awk_pushecb (
*/
QSE_EXPORT int qse_awk_addgbl (
qse_awk_t* awk, /**< awk */
const qse_char_t* name, /**< variable name */
qse_size_t len /**< name length */
const qse_cstr_t* name /**< variable name */
);
/**
@ -1591,8 +1621,7 @@ QSE_EXPORT int qse_awk_addgbl (
*/
QSE_EXPORT int qse_awk_delgbl (
qse_awk_t* awk, /**< awk */
const qse_char_t* name, /**< variable name */
qse_size_t len /**< name length */
const qse_cstr_t* name /**< variable name */
);
/**
@ -1602,22 +1631,16 @@ QSE_EXPORT int qse_awk_delgbl (
*/
QSE_EXPORT int qse_awk_findgbl (
qse_awk_t* awk, /**< awk */
const qse_char_t* name, /**< variable name */
qse_size_t len /**< name length */
const qse_cstr_t* name /**< variable name */
);
/**
* The qse_awk_addfnc() function adds an intrinsic function.
*/
QSE_EXPORT void* qse_awk_addfnc (
qse_awk_t* awk,
const qse_char_t* name,
qse_size_t name_len,
int when_valid,
qse_size_t min_args,
qse_size_t max_args,
const qse_char_t* arg_spec,
qse_awk_fnc_impl_t handler
qse_awk_t* awk,
const qse_cstr_t* name,
const qse_awk_fnc_spec_t* spec
);
/**
@ -1626,8 +1649,7 @@ QSE_EXPORT void* qse_awk_addfnc (
*/
QSE_EXPORT int qse_awk_delfnc (
qse_awk_t* awk, /**< awk */
const qse_char_t* name, /**< function name */
qse_size_t len /**< name length */
const qse_cstr_t* name /**< function name */
);
/**

View File

@ -194,6 +194,9 @@
/* Define if libdlloader will be built on this platform */
#undef HAVE_LIBDLLOADER
/* Define to 1 if you have the `ltdl' library (-lltdl). */
#undef HAVE_LIBLTDL
/* Define to 1 if you have the `log' function. */
#undef HAVE_LOG