touched up code

This commit is contained in:
hyung-hwan 2009-05-22 00:50:02 +00:00
parent 1893905652
commit 4005bd68e8
9 changed files with 90 additions and 146 deletions

View File

@ -31,8 +31,9 @@ PRE_UNINSTALL = :
POST_UNINSTALL = : POST_UNINSTALL = :
build_triplet = @build@ build_triplet = @build@
host_triplet = @host@ host_triplet = @host@
@ENABLE_CXX_TRUE@am__append_1 = Mmgr.hpp
subdir = include/qse subdir = include/qse
DIST_COMMON = $(pkginclude_HEADERS) $(srcdir)/Makefile.am \ DIST_COMMON = $(am__pkginclude_HEADERS_DIST) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(srcdir)/config.h.in $(srcdir)/Makefile.in $(srcdir)/config.h.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__aclocal_m4_deps = $(top_srcdir)/configure.ac
@ -50,6 +51,8 @@ RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
install-pdf-recursive install-ps-recursive install-recursive \ install-pdf-recursive install-ps-recursive install-recursive \
installcheck-recursive installdirs-recursive pdf-recursive \ installcheck-recursive installdirs-recursive pdf-recursive \
ps-recursive uninstall-recursive ps-recursive uninstall-recursive
am__pkginclude_HEADERS_DIST = config.h.in conf_msw.h conf_vms.h \
types.h macros.h pack1.h unpack.h Mmgr.hpp
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \ am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
@ -194,7 +197,8 @@ top_srcdir = @top_srcdir@
# EXTRA_DIST = README # EXTRA_DIST = README
SUBDIRS = cmn utl awk lsp SUBDIRS = cmn utl awk lsp
pkginclude_HEADERS = config.h.in conf_msw.h conf_vms.h types.h macros.h pack1.h unpack.h pkginclude_HEADERS = config.h.in conf_msw.h conf_vms.h types.h \
macros.h pack1.h unpack.h $(am__append_1)
CLEANFILES = *dist CLEANFILES = *dist
all: config.h all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive $(MAKE) $(AM_MAKEFLAGS) all-recursive

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk.h 127 2009-05-07 13:15:04Z hyunghwan.chung $ * $Id: awk.h 151 2009-05-21 06:50:02Z hyunghwan.chung $
* *
Copyright 2006-2009 Chung, Hyung-Hwan. Copyright 2006-2009 Chung, Hyung-Hwan.
@ -24,22 +24,23 @@
#include <qse/cmn/map.h> #include <qse/cmn/map.h>
#include <qse/cmn/str.h> #include <qse/cmn/str.h>
/****o* AWK/Interpreter /** @file
* DESCRIPTION * An embeddable AWK interpreter is defined in this header files.
* The library includes an AWK interpreter that can be embedded into other
* applications or can run stand-alone.
* *
* #include <qse/awk/awk.h> * @example awk01.c
****** * This program demonstrates how to use qse_awk_rtx_loop().
* @example awk02.c
* The program deparses the source code and prints it before executing it.
* @example awk03.c
* This program demonstrates how to use qse_awk_rtx_call().
* It parses the program stored in the string src and calls the functions
* stated in the array fnc. If no errors occur, it should print 24.
*/ */
/****t* AWK/qse_awk_t /** @class qse_awk_t
* NAME * The qse_awk_t type defines an AWK interpreter.
* qse_awk_t - define an AWK type
* SYNOPSIS
*/ */
typedef struct qse_awk_t qse_awk_t; typedef struct qse_awk_t qse_awk_t;
/******/
/****t* AWK/qse_awk_rtx_t /****t* AWK/qse_awk_rtx_t
* NAME * NAME
@ -700,19 +701,17 @@ enum qse_awk_val_ref_id_t
QSE_AWK_VAL_REF_POS QSE_AWK_VAL_REF_POS
}; };
/****e* AWK/qse_awk_rtx_valtostr_type_t /**
* NAME * The values defined are used to set the type field of the
* qse_awk_rtx_valtostr_type_t - define a value-to-string conversion type * qse_awk_rtx_valtostr_out_t structure. The field should be one of the
* DESCRIPTION * following values:
* The values defined are used to set the type field of the *
* qse_awk_rtx_valtostr_out_t structure. The field should be one of the * - QSE_AWK_RTX_VALTOSTR_CPL
* following values: * - QSE_AWK_RTX_VALTOSTR_CPLDUP
* * QSE_AWK_RTX_VALTOSTR_CPL * - QSE_AWK_RTX_VALTOSTR_STRP
* * QSE_AWK_RTX_VALTOSTR_CPLDUP * - QSE_AWK_RTX_VALTOSTR_STRPCAT
* * QSE_AWK_RTX_VALTOSTR_STRP *
* * QSE_AWK_RTX_VALTOSTR_STRPCAT * and it can optionally be ORed with QSE_AWK_RTX_VALTOSTR_PRINT.
* and it can optionally be ORed with QSE_AWK_RTX_VALTOSTR_PRINT.
* SYNOPSIS
*/ */
enum qse_awk_rtx_valtostr_type_t enum qse_awk_rtx_valtostr_type_t
{ {
@ -722,16 +721,10 @@ enum qse_awk_rtx_valtostr_type_t
QSE_AWK_RTX_VALTOSTR_STRPCAT = 0x03, QSE_AWK_RTX_VALTOSTR_STRPCAT = 0x03,
QSE_AWK_RTX_VALTOSTR_PRINT = 0x10 QSE_AWK_RTX_VALTOSTR_PRINT = 0x10
}; };
/******/
/****s* AWK/qse_awk_rtx_valtostr_out_t /**
* NAME * The qse_awk_rtx_valtostr() function converts a value to a string as
* qse_awk_rtx_valtostr_out_t - define a output structure for value-to-string * indicated in a parameter of the qse_awk_rtx_valtostr_out_t type.
* conversion
* DESCRIPTION
* The qse_awk_rtx_valtostr() function converts a value to a string as
* indicated in a parameter of the qse_awk_rtx_valtostr_out_t type.
* SYNOPSIS
*/ */
struct qse_awk_rtx_valtostr_out_t struct qse_awk_rtx_valtostr_out_t
{ {
@ -746,13 +739,14 @@ struct qse_awk_rtx_valtostr_out_t
} u; } u;
}; };
typedef struct qse_awk_rtx_valtostr_out_t qse_awk_rtx_valtostr_out_t; typedef struct qse_awk_rtx_valtostr_out_t qse_awk_rtx_valtostr_out_t;
/******/
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/** represents the nil value */ QSE_DEFINE_COMMON_FUNCTIONS (awk)
/** represents a nil value */
extern qse_awk_val_t* qse_awk_val_nil; extern qse_awk_val_t* qse_awk_val_nil;
/** represents an empty string */ /** represents an empty string */
@ -767,58 +761,45 @@ extern qse_awk_val_t* qse_awk_val_zero;
/** represents a numeric value 1 */ /** represents a numeric value 1 */
extern qse_awk_val_t* qse_awk_val_one; extern qse_awk_val_t* qse_awk_val_one;
/****f* AWK/qse_awk_open /**
* NAME * The qse_awk_open() function creates a new qse_awk_t object. The object
* qse_awk_open - create an awk object * created can be passed to other qse_awk_xxx() functions and is valid until
* DESCRIPTION * it is destroyed iwth the qse_qse_close() function. The function saves the
* The qse_awk_open() function creates a new qse_awk_t object. * memory manager pointer while it copies the contents of the primitive
* The instance created can be passed to other qse_awk_xxx() functions and * function structures. Therefore, you should keep the memory manager valid
* is valid until it is successfully destroyed using the qse_qse_close() * during the whole life cycle of an qse_awk_t object.
* function. The function save the memory manager pointer while it copies
* the contents of the primitive function structures. Therefore, you should
* keep the memory manager valid during the whole life cycle of an qse_awk_t
* object.
* *
* qse_awk_t* dummy() * @code
* { * qse_awk_t* dummy()
* qse_mmgr_t mmgr; * {
* qse_awk_prm_t prm; * qse_mmgr_t mmgr;
* return qse_awk_open ( * qse_awk_prm_t prm;
* &mmgr, // NOT OK because the contents of mmgr is * return qse_awk_open (
* // invalidated when dummy() returns. * &mmgr, // NOT OK because the contents of mmgr is
* 0, * // invalidated when dummy() returns.
* &prm // OK * 0,
* ); * &prm // OK
* } * );
* }
* @endcode
* *
* RETURN * @return a pointer to a qse_awk_t object on success, QSE_NULL on failure.
* The qse_awk_open() function returns the pointer to a qse_awk_t object
* on success and QSE_NULL on failure.
* SYNOPSIS
*/ */
qse_awk_t* qse_awk_open ( qse_awk_t* qse_awk_open (
qse_mmgr_t* mmgr /* a memory manager */, qse_mmgr_t* mmgr, /**< a memory manager */
qse_size_t xtn /* the size of extension in bytes */, qse_size_t xtn, /**< extension size in bytes */
qse_awk_prm_t* prm /* primitive functoins */ qse_awk_prm_t* prm /**< a pointer to a primitive function structure */
); );
/******/
/****f* AWK/qse_awk_close /**
* NAME * The qse_awk_close() function destroys a qse_awk_t object.
* qse_awk_close - destroy an awk object * @return 0 on success, -1 on failure
* DESCRIPTION
* A qse_awk_t instance must be destroyed using the qse_awk_close() function
* when finished being used. The instance passed is not valid any more once
* the function returns success.
* RETURN
* 0 on success, -1 on failure
* SYNOPSIS
*/ */
int qse_awk_close ( int qse_awk_close (
qse_awk_t* awk qse_awk_t* awk /**< an awk object */
); );
/******/
#if 0
/****f* AWK/qse_awk_getmmgr /****f* AWK/qse_awk_getmmgr
* NAME * NAME
* qse_awk_getmmgr - get the memory manager * qse_awk_getmmgr - get the memory manager
@ -860,6 +841,7 @@ void* qse_awk_getxtn (
qse_awk_t* awk /* an awk object */ qse_awk_t* awk /* an awk object */
); );
/******/ /******/
#endif
/****f* AWK/qse_awk_getprm /****f* AWK/qse_awk_getprm
* NAME * NAME

View File

@ -55,6 +55,10 @@ HEADERS = $(pkginclude_HEADERS)
ETAGS = etags ETAGS = etags
CTAGS = ctags CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
#if ENABLE_CXX
#pkginclude_HEADERS +=
#endif
pkgincludedir = $(includedir)/qse/cmn pkgincludedir = $(includedir)/qse/cmn
ACLOCAL = @ACLOCAL@ ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@ AMTAR = @AMTAR@
@ -181,7 +185,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@ top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@ top_srcdir = @top_srcdir@
pkginclude_HEADERS = mem.h chr.h str.h lda.h map.h rex.h sll.h dll.h opt.h tio.h fio.h pio.h sio.h time.h pkginclude_HEADERS = mem.h chr.h str.h lda.h map.h rex.h sll.h dll.h opt.h tio.h fio.h pio.h sio.h time.h
CLEANFILES = *dist CLEANFILES = *dist
all: all-am all: all-am

View File

@ -1,5 +1,5 @@
/* /*
* $Id: types.h 150 2009-05-21 06:17:17Z hyunghwan.chung $ * $Id: types.h 151 2009-05-21 06:50:02Z hyunghwan.chung $
* *
Copyright 2006-2009 Chung, Hyung-Hwan. Copyright 2006-2009 Chung, Hyung-Hwan.
@ -374,35 +374,27 @@ typedef int qse_mcint_t;
# endif # endif
#endif #endif
/****t* Base/qse_xstr_t /**
* NAME * The qse_xstr_t type defines a structure combining a pointer to a character
* qse_xstr_t - combine a pointer and length * string and the number of characters.
* SEE ALSO
* qse_cstr_t
* SYNOPSIS
*/ */
struct qse_xstr_t struct qse_xstr_t
{ {
qse_char_t* ptr; /* this is not a const pointer */ qse_char_t* ptr; /**< a pointer to a character string */
qse_size_t len; /* the number of characters */ qse_size_t len; /**< the number of characters */
}; };
typedef struct qse_xstr_t qse_xstr_t; typedef struct qse_xstr_t qse_xstr_t;
/******/
/****t* Base/qse_cstr_t /**
* NAME * The qse_cstr_t type defines a structure combining a pointer to
* qse_cstr_t - combine a constant pointer and length * a constant character string and the number of characters.
* SEE ALSO
* qse_xstr_t
* SYNOPSIS
*/ */
struct qse_cstr_t struct qse_cstr_t
{ {
const qse_char_t* ptr; /* this is a const pointer */ const qse_char_t* ptr; /**< a pointer to a const character string */
qse_size_t len; /* the number of characters */ qse_size_t len; /**< the number of characters */
}; };
typedef struct qse_cstr_t qse_cstr_t; typedef struct qse_cstr_t qse_cstr_t;
/******/
/** /**
* The qse_mmgr_t type defines a set type of functions for memory management. * The qse_mmgr_t type defines a set type of functions for memory management.

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk.c 127 2009-05-07 13:15:04Z hyunghwan.chung $ * $Id: awk.c 151 2009-05-21 06:50:02Z hyunghwan.chung $
* *
Copyright 2006-2009 Chung, Hyung-Hwan. Copyright 2006-2009 Chung, Hyung-Hwan.
@ -23,6 +23,8 @@
#include "awk.h" #include "awk.h"
QSE_IMPLEMENT_COMMON_FUNCTIONS (awk)
#define SETERR(awk,code) qse_awk_seterrnum(awk,code) #define SETERR(awk,code) qse_awk_seterrnum(awk,code)
#define SETERRARG(awk,code,line,arg,leng) \ #define SETERRARG(awk,code,line,arg,leng) \
@ -221,7 +223,6 @@ oops:
return QSE_NULL; return QSE_NULL;
} }
int qse_awk_close (qse_awk_t* awk) int qse_awk_close (qse_awk_t* awk)
{ {
qse_size_t i; qse_size_t i;
@ -329,21 +330,6 @@ int qse_awk_clear (qse_awk_t* awk)
return 0; return 0;
} }
void* qse_awk_getxtn (qse_awk_t* awk)
{
return (void*)(awk + 1);
}
qse_mmgr_t* qse_awk_getmmgr (qse_awk_t* awk)
{
return awk->mmgr;
}
void qse_awk_setmmgr (qse_awk_t* awk, qse_mmgr_t* mmgr)
{
awk->mmgr = mmgr;
}
qse_awk_prm_t* qse_awk_getprm (qse_awk_t* awk) qse_awk_prm_t* qse_awk_getprm (qse_awk_t* awk)
{ {
return &awk->prm; return &awk->prm;

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk.h 135 2009-05-15 13:31:43Z hyunghwan.chung $ * $Id: awk.h 151 2009-05-21 06:50:02Z hyunghwan.chung $
* *
Copyright 2006-2009 Chung, Hyung-Hwan. Copyright 2006-2009 Chung, Hyung-Hwan.
@ -86,8 +86,7 @@ struct qse_awk_tree_t
struct qse_awk_t struct qse_awk_t
{ {
/* memory manager */ QSE_DEFINE_COMMON_FIELDS (sed)
qse_mmgr_t* mmgr;
/* primitive functions */ /* primitive functions */
qse_awk_prm_t prm; qse_awk_prm_t prm;

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk01.c 86 2009-02-26 12:55:05Z hyunghwan.chung $ * $Id: awk01.c 151 2009-05-21 06:50:02Z hyunghwan.chung $
* *
Copyright 2006-2009 Chung, Hyung-Hwan. Copyright 2006-2009 Chung, Hyung-Hwan.
@ -16,12 +16,6 @@
limitations under the License. limitations under the License.
*/ */
/****S* AWK/Basic Loop
* DESCRIPTION
* This program demonstrates how to use qse_awk_rtx_loop().
* SOURCE
*/
#include <qse/awk/awk.h> #include <qse/awk/awk.h>
#include <qse/awk/std.h> #include <qse/awk/std.h>
#include <qse/utl/stdio.h> #include <qse/utl/stdio.h>
@ -88,4 +82,3 @@ oops:
return -1; return -1;
} }
/******/

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk02.c 90 2009-03-01 09:58:19Z hyunghwan.chung $ * $Id: awk02.c 151 2009-05-21 06:50:02Z hyunghwan.chung $
* *
Copyright 2006-2009 Chung, Hyung-Hwan. Copyright 2006-2009 Chung, Hyung-Hwan.
@ -16,12 +16,6 @@
limitations under the License. limitations under the License.
*/ */
/****S* AWK/Basic Loop With Deparsing
* DESCRIPTION
* The program deparses the source code and prints it before executing it.
* SOURCE
*/
#include <qse/awk/awk.h> #include <qse/awk/awk.h>
#include <qse/awk/std.h> #include <qse/awk/std.h>
#include <qse/cmn/mem.h> #include <qse/cmn/mem.h>
@ -103,4 +97,3 @@ oops:
return -1; return -1;
} }
/******/

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk03.c 90 2009-03-01 09:58:19Z hyunghwan.chung $ * $Id: awk03.c 151 2009-05-21 06:50:02Z hyunghwan.chung $
* *
Copyright 2006-2009 Chung, Hyung-Hwan. Copyright 2006-2009 Chung, Hyung-Hwan.
@ -16,14 +16,6 @@
limitations under the License. limitations under the License.
*/ */
/****S* AWK/Calling Functions
* DESCRIPTION
* This program demonstrates how to use qse_awk_rtx_call().
* It parses the program stored in the string src and calls the functions
* stated in the array fnc. If no errors occur, it should print 24.
* SOURCE
*/
#include <qse/awk/awk.h> #include <qse/awk/awk.h>
#include <qse/awk/std.h> #include <qse/awk/std.h>
#include <qse/utl/stdio.h> #include <qse/utl/stdio.h>
@ -125,4 +117,3 @@ oops:
if (awk != QSE_NULL) qse_awk_close (awk); if (awk != QSE_NULL) qse_awk_close (awk);
return ret; return ret;
} }
/******/