added qse_awk_rtx_pushrcb() and qse_awk_rtx_poprcb().
deleted qse_awk_rtx_setrcb() and qse_awk_rtx_getrcb(). added 'close' to qse_awk_rcb_t added builtin functions 'setenc' and 'unsetenc' to awk/std.c added qse_getcmgrbyname() added builtin functions 'setenc' and 'unsetenc' to awk/StdAwk.cpp
This commit is contained in:
@ -1026,10 +1026,11 @@ public:
|
||||
/// function.
|
||||
///
|
||||
int addFunction (
|
||||
const char_t* name, ///< function name
|
||||
size_t minArgs, ///< minimum numbers of arguments
|
||||
size_t maxArgs, ///< maximum numbers of arguments
|
||||
FunctionHandler handler ///< function handler
|
||||
const char_t* name, ///< function name
|
||||
size_t minArgs, ///< minimum numbers of arguments
|
||||
size_t maxArgs, ///< maximum numbers of arguments
|
||||
FunctionHandler handler, ///< function handler
|
||||
int validOpts = 0 ///< valid if these options are set
|
||||
);
|
||||
|
||||
///
|
||||
|
@ -98,6 +98,7 @@ public:
|
||||
|
||||
int open ();
|
||||
void close ();
|
||||
Run* parse (Source& in, Source& out);
|
||||
|
||||
int addConsoleOutput (const char_t* arg, size_t len);
|
||||
int addConsoleOutput (const char_t* arg);
|
||||
@ -112,6 +113,14 @@ protected:
|
||||
int system (Run& run, Value& ret, const Value* args, size_t nargs,
|
||||
const char_t* name, size_t len);
|
||||
|
||||
#if defined(QSE_CHAR_IS_WCHAR)
|
||||
qse_cmgr_t* getcmgr (const char_t* ioname);
|
||||
int setenc (Run& run, Value& ret, const Value* args, size_t nargs,
|
||||
const char_t* name, size_t len);
|
||||
int unsetenc (Run& run, Value& ret, const Value* args, size_t nargs,
|
||||
const char_t* name, size_t len);
|
||||
#endif
|
||||
|
||||
// pipe io handlers
|
||||
int openPipe (Pipe& io);
|
||||
int closePipe (Pipe& io);
|
||||
@ -140,8 +149,8 @@ protected:
|
||||
void freeMem (void* ptr);
|
||||
|
||||
|
||||
int vsprintf (char_t* buf, size_t size,
|
||||
const char_t* fmt, va_list arg);
|
||||
int vsprintf (char_t* buf, size_t size,
|
||||
const char_t* fmt, va_list arg);
|
||||
|
||||
flt_t pow (flt_t x, flt_t y);
|
||||
flt_t mod (flt_t x, flt_t y);
|
||||
@ -156,6 +165,8 @@ protected:
|
||||
|
||||
protected:
|
||||
unsigned int seed;
|
||||
qse_htb_t cmgrtab;
|
||||
bool cmgrtab_inited;
|
||||
|
||||
/* standard input console - reuse runarg */
|
||||
size_t runarg_index;
|
||||
|
@ -672,35 +672,54 @@ struct qse_awk_rio_t
|
||||
typedef struct qse_awk_rio_t qse_awk_rio_t;
|
||||
|
||||
/**
|
||||
* The qse_awk_rcb_stm_t type defines the callback function for each
|
||||
* The qse_awk_rcb_close_t type defines the callback function
|
||||
* called when the runtime context is closed.
|
||||
*/
|
||||
typedef void (*qse_awk_rcb_close_t) (
|
||||
qse_awk_rtx_t* rtx, /**< runtime context */
|
||||
void* ctx /**< user-defined data */
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* The qse_awk_rcb_stmt_t type defines the callback function for each
|
||||
* statement.
|
||||
*/
|
||||
typedef void (*qse_awk_rcb_stm_t) (
|
||||
typedef void (*qse_awk_rcb_stmt_t) (
|
||||
qse_awk_rtx_t* rtx, /**< runtime context */
|
||||
qse_awk_nde_t* nde, /**< node */
|
||||
void* ctx /**< user-defined data */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_awk_rcb_t type defines runtime callbacks. You can specify callback
|
||||
* functions with qse_awk_rtx_setrcb() to be informed of important events
|
||||
* during runtime.
|
||||
* The qse_awk_rcb_t type defines a runtime callback set. You can
|
||||
* register a callback function set with qse_awk_rtx_pushrcb().
|
||||
* The callback functions in the set registered are called in a
|
||||
* proper context in the reverse order of registeration.
|
||||
*/
|
||||
typedef struct qse_awk_rcb_t qse_awk_rcb_t;
|
||||
struct qse_awk_rcb_t
|
||||
{
|
||||
/**
|
||||
* called by qse_awk_rtx_close().
|
||||
*/
|
||||
qse_awk_rcb_close_t close;
|
||||
|
||||
/**
|
||||
* called by qse_awk_rtx_loop() and qse_awk_rtx_call() for
|
||||
* each statement executed.
|
||||
*/
|
||||
qse_awk_rcb_stm_t stm;
|
||||
qse_awk_rcb_stmt_t stmt;
|
||||
|
||||
/**
|
||||
* A caller may store a user-defined data pointer into this field. This
|
||||
* is passed to the actual callback.
|
||||
* is passed to an actual callback.
|
||||
*/
|
||||
void* ctx;
|
||||
void* ctx;
|
||||
|
||||
/* internal use only. don't touch this field */
|
||||
qse_awk_rcb_t* next;
|
||||
};
|
||||
typedef struct qse_awk_rcb_t qse_awk_rcb_t;
|
||||
|
||||
/**
|
||||
* The qse_awk_option_t type defines various options to change the behavior
|
||||
@ -1655,18 +1674,18 @@ void qse_awk_rtx_stop (
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_awk_rtx_setrcb() function gets runtime callbacks.
|
||||
* @return #QSE_NULL if no callback is set. Otherwise, the pointer to a
|
||||
* callback set.
|
||||
* The qse_awk_rtx_poprcb() function pops a runtime callback set
|
||||
* and returns the pointer to it. If no callback set can be popped,
|
||||
* it returns #QSE_NULL.
|
||||
*/
|
||||
qse_awk_rcb_t* qse_awk_rtx_getrcb (
|
||||
qse_awk_rcb_t* qse_awk_rtx_poprcb (
|
||||
qse_awk_rtx_t* rtx /**< runtime context */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_awk_rtx_setrcb() function sets runtime callbacks.
|
||||
* The qse_awk_rtx_pushrcb() function register a runtime callback set.
|
||||
*/
|
||||
void qse_awk_rtx_setrcb (
|
||||
void qse_awk_rtx_pushrcb (
|
||||
qse_awk_rtx_t* rtx, /**< runtime context */
|
||||
qse_awk_rcb_t* rcb /**< callback set */
|
||||
);
|
||||
|
@ -49,7 +49,7 @@
|
||||
* int i;
|
||||
*
|
||||
* s1 = qse_htb_open (QSE_MMGR_GETDFL(), 0, 30, 75, 1, 1); // error handling skipped
|
||||
* qse_htb_setmancbs (s1, qse_htb_mancbs(QSE_HTB_MANCBS_INLINE_COPIERS));
|
||||
* qse_htb_setmancbs (s1, qse_gethtbmancbs(QSE_HTB_MANCBS_INLINE_COPIERS));
|
||||
*
|
||||
* for (i = 0; i < 20; i++)
|
||||
* {
|
||||
@ -302,10 +302,10 @@ extern "C" {
|
||||
QSE_DEFINE_COMMON_FUNCTIONS (htb)
|
||||
|
||||
/**
|
||||
* The qse_htb_mancbs() functions returns a predefined callback set for
|
||||
* The qse_gethtbmancbs() functions returns a predefined callback set for
|
||||
* pair manipulation.
|
||||
*/
|
||||
const qse_htb_mancbs_t* qse_htb_mancbs (
|
||||
const qse_htb_mancbs_t* qse_gethtbmancbs (
|
||||
qse_htb_mancbs_kind_t kind
|
||||
);
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
# define QSE_MAP_MANCBS_INLINE_COPIERS QSE_HTB_MANCBS_INLINE_COPIERS
|
||||
# define QSE_MAP_MANCBS_INLINE_KEY_COPIER QSE_HTB_MANCBS_INLINE_KEY_COPIER
|
||||
# define QSE_MAP_MANCBS_INLINE_VALUE_COPIER QSE_HTB_MANCBS_INLINE_VALUE_COPIER
|
||||
# define qse_map_mancbs(kind) qse_htb_mancbs(kind)
|
||||
# define qse_getmapmancbs(kind) qse_gethtbmancbs(kind)
|
||||
# define qse_map_open(mmgr,ext,capa,factor,ks,vs) qse_htb_open(mmgr,ext,capa,factor,ks,vs)
|
||||
# define qse_map_close(map) qse_htb_close(map)
|
||||
# define qse_map_init(map,mmgr,capa,factor,ks,vs) qse_htb_init(map,mmgr,capa,factor,ks,vs)
|
||||
@ -91,7 +91,7 @@
|
||||
# define QSE_MAP_MANCBS_INLINE_COPIERS QSE_RBT_MANCBS_INLINE_COPIERS
|
||||
# define QSE_MAP_MANCBS_INLINE_KEY_COPIER QSE_RBT_MANCBS_INLINE_KEY_COPIER
|
||||
# define QSE_MAP_MANCBS_INLINE_VALUE_COPIER QSE_RBT_MANCBS_INLINE_VALUE_COPIER
|
||||
# define qse_map_mancbs(kind) qse_rbt_mancbs(kind)
|
||||
# define qse_getmapmancbs(kind) qse_getrbtmancbs(kind)
|
||||
# define qse_map_open(mmgr,ext,capa,factor,ks,vs) qse_rbt_open(mmgr,ext,ks,vs)
|
||||
# define qse_map_close(map) qse_rbt_close(map)
|
||||
# define qse_map_init(map,mmgr,capa,factor,ks,vs) qse_rbt_init(map,mmgr,ks,vs)
|
||||
|
@ -21,6 +21,10 @@
|
||||
#ifndef _QSE_CMN_MBWC_H_
|
||||
#define _QSE_CMN_MBWC_H_
|
||||
|
||||
/** @file
|
||||
* This file provides functions and definitions needed for
|
||||
* multibyte/wide-characer conversion.
|
||||
*/
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
|
||||
@ -28,9 +32,25 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* --------------------------------------------------- */
|
||||
/* BUILTIN CMGR */
|
||||
/* --------------------------------------------------- */
|
||||
extern qse_cmgr_t* qse_utf8cmgr;
|
||||
extern qse_cmgr_t* qse_slmbcmgr;
|
||||
|
||||
/**
|
||||
* The qse_getcmgrbyname() function find a builtin cmgr matching a given
|
||||
* @a name and returns it. It returns #QSE_NULL if no match is found.
|
||||
* The @a name can be one of "utf8", "slmb", and an empty string. Calling this
|
||||
* function with an empty string is the same as calling qse_getdflcmgr().
|
||||
*/
|
||||
qse_cmgr_t* qse_getcmgrbyname (
|
||||
const qse_char_t* name
|
||||
);
|
||||
|
||||
/* --------------------------------------------------- */
|
||||
/* DEFAULT GLOBAL CMGR */
|
||||
/* --------------------------------------------------- */
|
||||
qse_cmgr_t* qse_getdflcmgr (
|
||||
void
|
||||
);
|
||||
@ -39,7 +59,6 @@ void qse_setdflcmgr (
|
||||
qse_cmgr_t* cmgr
|
||||
);
|
||||
|
||||
|
||||
/* --------------------------------------------------- */
|
||||
/* STRING CONVERSION USING CMGR */
|
||||
/* --------------------------------------------------- */
|
||||
@ -142,7 +161,7 @@ qse_mchar_t* qse_wcsatombsdupwithcmgr (
|
||||
|
||||
|
||||
/* --------------------------------------------------- */
|
||||
/* STRING CONVERSION */
|
||||
/* STRING CONVERSION WITH DEFAULT GLOBAL CMGR */
|
||||
/* --------------------------------------------------- */
|
||||
|
||||
/**
|
||||
|
@ -49,7 +49,7 @@
|
||||
* int i;
|
||||
*
|
||||
* s1 = qse_rbt_open (QSE_MMGR_GETDFL(), 0, 1, 1); // error handling skipped
|
||||
* qse_rbt_setmancbs (s1, qse_rbt_mancbs(QSE_RBT_MANCBS_INLINE_COPIERS));
|
||||
* qse_rbt_setmancbs (s1, qse_getrbtmancbs(QSE_RBT_MANCBS_INLINE_COPIERS));
|
||||
*
|
||||
* for (i = 0; i < 20; i++)
|
||||
* {
|
||||
@ -273,10 +273,10 @@ extern "C" {
|
||||
QSE_DEFINE_COMMON_FUNCTIONS (rbt)
|
||||
|
||||
/**
|
||||
* The qse_rbt_mancbs() functions returns a predefined callback set for
|
||||
* The qse_getrbtmancbs() functions returns a predefined callback set for
|
||||
* pair manipulation.
|
||||
*/
|
||||
const qse_rbt_mancbs_t* qse_rbt_mancbs (
|
||||
const qse_rbt_mancbs_t* qse_getrbtmancbs (
|
||||
qse_rbt_mancbs_kind_t kind
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user