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 = :
build_triplet = @build@
host_triplet = @host@
@ENABLE_CXX_TRUE@am__append_1 = Mmgr.hpp
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
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
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 \
installcheck-recursive installdirs-recursive pdf-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 = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
@ -194,7 +197,8 @@ top_srcdir = @top_srcdir@
# EXTRA_DIST = README
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
all: config.h
$(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.
@ -24,22 +24,23 @@
#include <qse/cmn/map.h>
#include <qse/cmn/str.h>
/****o* AWK/Interpreter
* DESCRIPTION
* The library includes an AWK interpreter that can be embedded into other
* applications or can run stand-alone.
/** @file
* An embeddable AWK interpreter is defined in this header files.
*
* #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
* NAME
* qse_awk_t - define an AWK type
* SYNOPSIS
/** @class qse_awk_t
* The qse_awk_t type defines an AWK interpreter.
*/
typedef struct qse_awk_t qse_awk_t;
/******/
/****t* AWK/qse_awk_rtx_t
* NAME
@ -700,19 +701,17 @@ enum qse_awk_val_ref_id_t
QSE_AWK_VAL_REF_POS
};
/****e* AWK/qse_awk_rtx_valtostr_type_t
* NAME
* qse_awk_rtx_valtostr_type_t - define a value-to-string conversion type
* DESCRIPTION
* 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
* following values:
* * QSE_AWK_RTX_VALTOSTR_CPL
* * QSE_AWK_RTX_VALTOSTR_CPLDUP
* * QSE_AWK_RTX_VALTOSTR_STRP
* * QSE_AWK_RTX_VALTOSTR_STRPCAT
* and it can optionally be ORed with QSE_AWK_RTX_VALTOSTR_PRINT.
* SYNOPSIS
/**
* 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
* following values:
*
* - QSE_AWK_RTX_VALTOSTR_CPL
* - QSE_AWK_RTX_VALTOSTR_CPLDUP
* - QSE_AWK_RTX_VALTOSTR_STRP
* - QSE_AWK_RTX_VALTOSTR_STRPCAT
*
* and it can optionally be ORed with QSE_AWK_RTX_VALTOSTR_PRINT.
*/
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_PRINT = 0x10
};
/******/
/****s* AWK/qse_awk_rtx_valtostr_out_t
* NAME
* qse_awk_rtx_valtostr_out_t - define a output structure for value-to-string
* 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
/**
* 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.
*/
struct qse_awk_rtx_valtostr_out_t
{
@ -746,13 +739,14 @@ struct qse_awk_rtx_valtostr_out_t
} u;
};
typedef struct qse_awk_rtx_valtostr_out_t qse_awk_rtx_valtostr_out_t;
/******/
#ifdef __cplusplus
extern "C" {
#endif
/** represents the nil value */
QSE_DEFINE_COMMON_FUNCTIONS (awk)
/** represents a nil value */
extern qse_awk_val_t* qse_awk_val_nil;
/** represents an empty string */
@ -767,58 +761,45 @@ extern qse_awk_val_t* qse_awk_val_zero;
/** represents a numeric value 1 */
extern qse_awk_val_t* qse_awk_val_one;
/****f* AWK/qse_awk_open
* NAME
* qse_awk_open - create an awk object
* DESCRIPTION
* The qse_awk_open() function creates a new qse_awk_t object.
* The instance created can be passed to other qse_awk_xxx() functions and
* is valid until it is successfully destroyed using the qse_qse_close()
* 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.
/**
* The qse_awk_open() function creates a new qse_awk_t object. The object
* created can be passed to other qse_awk_xxx() functions and is valid until
* it is destroyed iwth the qse_qse_close() function. The function saves 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()
* {
* qse_mmgr_t mmgr;
* qse_awk_prm_t prm;
* return qse_awk_open (
* &mmgr, // NOT OK because the contents of mmgr is
* // invalidated when dummy() returns.
* 0,
* &prm // OK
* );
* }
* @code
* qse_awk_t* dummy()
* {
* qse_mmgr_t mmgr;
* qse_awk_prm_t prm;
* return qse_awk_open (
* &mmgr, // NOT OK because the contents of mmgr is
* // invalidated when dummy() returns.
* 0,
* &prm // OK
* );
* }
* @endcode
*
* RETURN
* The qse_awk_open() function returns the pointer to a qse_awk_t object
* on success and QSE_NULL on failure.
* SYNOPSIS
* @return a pointer to a qse_awk_t object on success, QSE_NULL on failure.
*/
qse_awk_t* qse_awk_open (
qse_mmgr_t* mmgr /* a memory manager */,
qse_size_t xtn /* the size of extension in bytes */,
qse_awk_prm_t* prm /* primitive functoins */
qse_mmgr_t* mmgr, /**< a memory manager */
qse_size_t xtn, /**< extension size in bytes */
qse_awk_prm_t* prm /**< a pointer to a primitive function structure */
);
/******/
/****f* AWK/qse_awk_close
* NAME
* qse_awk_close - destroy an awk object
* 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
/**
* The qse_awk_close() function destroys a qse_awk_t object.
* @return 0 on success, -1 on failure
*/
int qse_awk_close (
qse_awk_t* awk
qse_awk_t* awk /**< an awk object */
);
/******/
#if 0
/****f* AWK/qse_awk_getmmgr
* NAME
* qse_awk_getmmgr - get the memory manager
@ -860,6 +841,7 @@ void* qse_awk_getxtn (
qse_awk_t* awk /* an awk object */
);
/******/
#endif
/****f* AWK/qse_awk_getprm
* NAME

View File

@ -55,6 +55,10 @@ HEADERS = $(pkginclude_HEADERS)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
#if ENABLE_CXX
#pkginclude_HEADERS +=
#endif
pkgincludedir = $(includedir)/qse/cmn
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
@ -181,7 +185,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
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
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.
@ -374,35 +374,27 @@ typedef int qse_mcint_t;
# endif
#endif
/****t* Base/qse_xstr_t
* NAME
* qse_xstr_t - combine a pointer and length
* SEE ALSO
* qse_cstr_t
* SYNOPSIS
/**
* The qse_xstr_t type defines a structure combining a pointer to a character
* string and the number of characters.
*/
struct qse_xstr_t
{
qse_char_t* ptr; /* this is not a const pointer */
qse_size_t len; /* the number of characters */
qse_char_t* ptr; /**< a pointer to a character string */
qse_size_t len; /**< the number of characters */
};
typedef struct qse_xstr_t qse_xstr_t;
/******/
/****t* Base/qse_cstr_t
* NAME
* qse_cstr_t - combine a constant pointer and length
* SEE ALSO
* qse_xstr_t
* SYNOPSIS
/**
* The qse_cstr_t type defines a structure combining a pointer to
* a constant character string and the number of characters.
*/
struct qse_cstr_t
{
const qse_char_t* ptr; /* this is a const pointer */
qse_size_t len; /* the number of characters */
const qse_char_t* ptr; /**< a pointer to a const character string */
qse_size_t len; /**< the number of characters */
};
typedef struct qse_cstr_t qse_cstr_t;
/******/
/**
* 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.
@ -23,6 +23,8 @@
#include "awk.h"
QSE_IMPLEMENT_COMMON_FUNCTIONS (awk)
#define SETERR(awk,code) qse_awk_seterrnum(awk,code)
#define SETERRARG(awk,code,line,arg,leng) \
@ -221,7 +223,6 @@ oops:
return QSE_NULL;
}
int qse_awk_close (qse_awk_t* awk)
{
qse_size_t i;
@ -329,21 +330,6 @@ int qse_awk_clear (qse_awk_t* awk)
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)
{
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.
@ -86,8 +86,7 @@ struct qse_awk_tree_t
struct qse_awk_t
{
/* memory manager */
qse_mmgr_t* mmgr;
QSE_DEFINE_COMMON_FIELDS (sed)
/* primitive functions */
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.
@ -16,12 +16,6 @@
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/std.h>
#include <qse/utl/stdio.h>
@ -88,4 +82,3 @@ oops:
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.
@ -16,12 +16,6 @@
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/std.h>
#include <qse/cmn/mem.h>
@ -103,4 +97,3 @@ oops:
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.
@ -16,14 +16,6 @@
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/std.h>
#include <qse/utl/stdio.h>
@ -125,4 +117,3 @@ oops:
if (awk != QSE_NULL) qse_awk_close (awk);
return ret;
}
/******/