This commit is contained in:
hyung-hwan 2008-09-01 04:57:24 +00:00
parent 5958ddccef
commit 8a219e1548
6 changed files with 114 additions and 84 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.h 349 2008-08-28 14:21:25Z baconevi $
* $Id: awk.h 354 2008-08-31 10:57:24Z baconevi $
*
* {License}
*/
@ -592,9 +592,7 @@ extern ase_awk_val_t* ase_awk_val_one;
*/
ase_awk_t* ase_awk_open (
ase_mmgr_t* mmgr /* memory manager */,
ase_size_t ext /* size of extension area in bytes */,
void (*init) (ase_awk_t*, void*) /* extension initializer */,
void* init_data /* the second argument to the extension initializer */
ase_size_t ext /* size of extension area in bytes */
);
/*
@ -696,20 +694,36 @@ void ase_awk_setoption (ase_awk_t* awk, int opt);
ase_size_t ase_awk_getmaxdepth (ase_awk_t* awk, int type);
void ase_awk_setmaxdepth (ase_awk_t* awk, int types, ase_size_t depth);
int ase_awk_getword (ase_awk_t* awk,
const ase_char_t* okw, ase_size_t olen,
const ase_char_t** nkw, ase_size_t* nlen);
int ase_awk_getword (
ase_awk_t* awk,
const ase_char_t* okw,
ase_size_t olen,
const ase_char_t** nkw,
ase_size_t* nlen
);
int ase_awk_unsetword (
ase_awk_t* awk,
const ase_char_t* kw,
ase_size_t len
);
void ase_awk_unsetallwords (
ase_awk_t* awk
);
/*
* enable replacement of a name of a keyword, intrinsic global variables,
* and intrinsic functions.
* NAME:
* enable replacement of a name of a keyword, intrinsic global variables,
* and intrinsic functions.
*
* If nkw is ASE_NULL or nlen is zero and okw is ASE_NULL or olen is zero,
* it unsets all word replacements. If nkw is ASE_NULL or nlen is zero,
* it unsets the replacement for okw and olen. If all of them are valid,
* it sets the word replace for okw and olen to nkw and nlen.
* DESCRIPTION:
* If nkw is ASE_NULL or nlen is zero and okw is ASE_NULL or olen is zero,
* it unsets all word replacements. If nkw is ASE_NULL or nlen is zero,
* it unsets the replacement for okw and olen. If all of them are valid,
* it sets the word replace for okw and olen to nkw and nlen.
*
* RETURNS 0 on success, -1 on failure
* RETURNS: 0 on success, -1 on failure
*/
int ase_awk_setword (
/* the pointer to an ase_awk_t instance */
@ -732,11 +746,11 @@ int ase_awk_setword (
int ase_awk_setrexfns (ase_awk_t* awk, ase_awk_rexfns_t* rexfns);
/**
* Adds an intrinsic global variable.
* NAME: add an intrinsic global variable.
*
* @return
* On success, the ID of the global variable added is returned.
* On failure, -1 is returned.
* RETURNS:
* On success, the ID of the global variable added is returned.
* On failure, -1 is returned.
*/
int ase_awk_addglobal (ase_awk_t* awk, const ase_char_t* name, ase_size_t len);

View File

@ -92,9 +92,7 @@ extern "C" {
ase_dll_t* ase_dll_open (
ase_mmgr_t* mmgr /* memory manager */ ,
ase_size_t ext /* size of extension area in bytes */,
void (*init) (ase_dll_t*, void*) /* extension initializer */,
void* init_data /* the second argument to the extension initializer */
ase_size_t ext /* size of extension area in bytes */
);
/*

View File

@ -1,5 +1,5 @@
/*
* $Id: map.h 349 2008-08-28 14:21:25Z baconevi $
* $Id: map.h 354 2008-08-31 10:57:24Z baconevi $
*
* {License}
*/
@ -74,6 +74,10 @@ struct ase_map_t
ase_size_t size;
ase_size_t capa;
ase_uint_t factor;
ase_size_t threshold;
ase_map_pair_t** bucket;
void (*sameval) (void* owner, void* vptr, ase_size_t vlen);
};
@ -92,7 +96,6 @@ enum ase_map_walk_t
#define ASE_MAP_COPIER_INLINE ase_map_copyinline
#define ASE_MAP_SIZE(m) ((m)->size)
#define ASE_MAP_CAPA(m) ((m)->capa)
@ -114,12 +117,10 @@ extern "C" {
* bucket and a list of values linked.
*/
ase_map_t* ase_map_open (
ase_mmgr_t* mmgr,
ase_size_t ext,
void (*init) (ase_map_t*, void*),
void* init_arg,
ase_mmgr_t* mmgr /* memory manager */,
ase_size_t ext /* size of extension area in bytes */,
ase_size_t capa /* initial capacity */,
unsigned int load_factor /* load factor */
ase_uint_t factor /* load factor */
);
/* destroy a map */
@ -127,6 +128,17 @@ void ase_map_close (
ase_map_t* map /* a map */
);
ase_map_t* ase_map_init (
ase_map_t* map,
ase_mmgr_t* mmgr,
ase_size_t capa,
ase_uint_t factor
);
void ase_map_fini (
ase_map_t* map
);
/* clear a map */
void ase_map_clear (
ase_map_t* map /* a map */
@ -211,25 +223,8 @@ ase_size_t ase_map_getcapa (
ase_map_t* map /* a map */
);
/* get the pointer to the pair with a matching key */
ase_map_pair_t* ase_map_get (
ase_map_t* map /* a map */,
const void* kptr,
ase_size_t klen
);
/* insert or update a pair with a matching key */
ase_map_pair_t* ase_map_put (
ase_map_t* map /* a map */,
void* kptr /* the pointer to the beginning of a key */,
ase_size_t klen /* the length of the key in bytes */,
void* vptr /* the pointer to the beginning of a value */,
ase_size_t vlen /* the length of the value in bytes */
);
int ase_map_putx (
ase_map_t* map /* a map */,
int ase_map_put (
ase_map_t* map,
void* kptr,
ase_size_t klen,
void* vptr,
@ -237,6 +232,45 @@ int ase_map_putx (
ase_map_pair_t** px
);
/*
* NAME: find a pair with a matching key
*
* DESCRIPTION:
* The ase_map_search() functions searches a map to find a pair with a
* matching key. It returns the pointer to the pair found. If it fails
* to find one, it returns ASE_NULL.
*
* RETURNS:
* The pointer to the pair with a maching key.
* ASE_NULL if no match is found.
*/
ase_map_pair_t* ase_map_search (
ase_map_t* map /* a map */,
const void* kptr /* the pointer to a key */,
ase_size_t klen /* the size of the key in bytes */
);
/*
* NAME: update an existing pair with a matching or inesrt a new pair
*
* DESCRIPTION:
* The ase_map_upsert() function searches a map for the pair with a matching
* key. If one is found, it updates the pair. Otherwise, it inserts a new
* pair with a key and a value. It returns the pointer to the pair updated
* or inserted.
*
* RETURNS:
* a pointer to the updated or inserted pair.
* ASE_NULL on failure.
*/
ase_map_pair_t* ase_map_upsert (
ase_map_t* map /* a map */,
void* kptr /* the pointer to a key */,
ase_size_t klen /* the length of the key in bytes */,
void* vptr /* the pointer to a value */,
ase_size_t vlen /* the length of the value in bytes */
);
/*
* NAME: insert a new pair with a key and a value
*
@ -250,34 +284,34 @@ int ase_map_putx (
* ASE_NULL on failure.
*/
ase_map_pair_t* ase_map_insert (
ase_map_t* map /* a map */,
void* kptr,
ase_size_t klen,
void* vptr,
ase_size_t vlen
ase_map_t* map /* a map */,
void* kptr /* the pointer to a key */,
ase_size_t klen /* the length of the key in bytes */,
void* vptr /* the pointer to a value */,
ase_size_t vlen /* the length of the value in bytes */
);
/* update the value of a existing pair with a matching key */
ase_map_pair_t* ase_map_update (
ase_map_t* map /* a map */,
void* kptr,
ase_size_t klen,
void* vptr,
ase_size_t vlen
ase_map_t* map /* a map */,
void* kptr /* the pointer to a key */,
ase_size_t klen /* the length of the key in bytes */,
void* vptr /* the pointer to a value */,
ase_size_t vlen /* the length of the value in bytes */
);
/* delete a pair with a matching key */
int ase_map_delete (
ase_map_t* map /* a map */,
const void* kptr,
ase_size_t klen
ase_map_t* map /* a map */,
const void* kptr /* the pointer to a key */,
ase_size_t klen /* the size of the key in bytes */
);
/* traverse a map */
void ase_map_walk (
ase_map_t* map /* a map */,
ase_map_t* map /* a map */,
ase_map_walker_t walker /* the pointer to the function for each pair */,
void* arg /* a pointer to user-specific data */
void* arg /* a pointer to user-specific data */
);
/* get the pointer to the first pair in the map. */

View File

@ -91,9 +91,7 @@ extern "C" {
ase_sll_t* ase_sll_open (
ase_mmgr_t* mmgr /* memory manager */ ,
ase_size_t ext /* size of extension area in bytes */,
void (*init) (ase_sll_t*, void*) /* extension initializer */,
void* init_data /* the second argument to the extension initializer */
ase_size_t ext /* size of extension area in bytes */
);
/*

View File

@ -1,5 +1,5 @@
/*
* $Id: macros.h 334 2008-08-19 11:00:26Z baconevi $
* $Id: macros.h 354 2008-08-31 10:57:24Z baconevi $
*
* {License}
*/
@ -7,14 +7,6 @@
#ifndef _ASE_MACROS_H_
#define _ASE_MACROS_H_
/**
* @file macros.h
* @brief Define common macros
*
* This file defines various macros for assertion, memory allocation,
* data type manipulation, etc.
*/
#include <ase/types.h>
#ifdef __cplusplus
@ -41,10 +33,6 @@
((type)((type)1 << (ASE_SIZEOF(type) * 8 - 1)))
#define ASE_TYPE_UNSIGNED_MIN(type) ((type)0)
/**
* @define ASE_TYPE_MAX(type)
* @brief Get the maximum value \a type can hold
*/
#define ASE_TYPE_MAX(type) \
((ASE_TYPE_IS_SIGNED(type)? ASE_TYPE_SIGNED_MAX(type): ASE_TYPE_UNSIGNED_MAX(type)))
#define ASE_TYPE_MIN(type) \
@ -78,6 +66,9 @@
} \
} while (0);
#define ASE_NCHARS_TO_NBYTES(x) ((x)*sizeof(ase_char_t))
#define ASE_NBYTES_TO_NCHARS(x) ((x)/sizeof(ase_char_t))
#define ASE_MQ_I(val) #val
#define ASE_MQ(val) ASE_MQ_I(val)
#define ASE_MC(ch) ((ase_mchar_t)ch)

View File

@ -1,5 +1,5 @@
/*
* $Id: types.h 337 2008-08-20 09:17:25Z baconevi $
* $Id: types.h 354 2008-08-31 10:57:24Z baconevi $
*
* {License}
*/
@ -320,11 +320,6 @@ typedef int ase_mcint_t;
#endif
#endif
/* ase_fuser_t is an abstract function type that can be used to
* fuse(copy and combine) the orginal data into the given space
* and return the pointer to its new location in the space */
typedef void* (*ase_fuser_t) (void* org, void* space);
typedef struct ase_cstr_t ase_cstr_t;
typedef struct ase_mmgr_t ase_mmgr_t;
typedef struct ase_ccls_t ase_ccls_t;