added QSE_AWK_VAL_MAP_ITR_KEY() and deleted QSE_AWK_VAL_MAP_ITR_KEY_PTR()/QSE_AWK_VAL_MAP_ITR_KEY_LEN()

added QSE_HTB_KPTL()/QSE_HTB_VPTL()/QSE_RBT_KPTL()/QSE_RBT_VPTL()
This commit is contained in:
hyung-hwan 2011-05-24 22:22:40 +00:00
parent 5577499bfb
commit 948f5de1cb
7 changed files with 55 additions and 21 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: Awk.hpp 474 2011-05-23 16:52:37Z hyunghwan.chung $ * $Id: Awk.hpp 477 2011-05-24 04:22:40Z hyunghwan.chung $
* *
Copyright 2006-2011 Chung, Hyung-Hwan. Copyright 2006-2011 Chung, Hyung-Hwan.
This file is part of QSE. This file is part of QSE.
@ -412,20 +412,48 @@ public:
/// ///
/// The Index class encapsulates an index of an arrayed value. /// The Index class encapsulates an index of an arrayed value.
/// ///
class Index class Index: protected qse_cstr_t
{ {
public: public:
friend class Value; friend class Value;
/// The Index() function creates an empty array index. /// The Index() function creates an empty array index.
Index (): ptr (EMPTY_STRING), len (0) {} Index ()
{
this->ptr = EMPTY_STRING;
this->len = 0;
}
/// The Index() function creates a string array index. /// The Index() function creates a string array index.
Index (const char_t* ptr, size_t len): Index (const char_t* ptr, size_t len)
ptr (ptr), len (len) {} {
this->ptr = ptr;
this->len = len;
}
const char_t* ptr; void set (const qse_cstr_t* x)
size_t len; {
this->ptr = x->ptr;
this->len = x->len;
}
void set (const qse_xstr_t* x)
{
this->ptr = x->ptr;
this->len = x->len;
}
Index& operator= (const qse_cstr_t* x)
{
this->set (x);
return *this;
}
Index& operator= (const qse_xstr_t* x)
{
this->set (x);
return *this;
}
}; };
/// ///

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk.h 474 2011-05-23 16:52:37Z hyunghwan.chung $ * $Id: awk.h 477 2011-05-24 04:22:40Z hyunghwan.chung $
* *
Copyright 2006-2011 Chung, Hyung-Hwan. Copyright 2006-2011 Chung, Hyung-Hwan.
This file is part of QSE. This file is part of QSE.
@ -274,10 +274,8 @@ struct qse_awk_val_map_itr_t
}; };
typedef struct qse_awk_val_map_itr_t qse_awk_val_map_itr_t; typedef struct qse_awk_val_map_itr_t qse_awk_val_map_itr_t;
#define QSE_AWK_VAL_MAP_ITR_KEY_PTR(itr) \ #define QSE_AWK_VAL_MAP_ITR_KEY(itr) \
((const qse_char_t*)QSE_HTB_KPTR((itr)->pair)) ((const qse_cstr_t*)QSE_HTB_KPTL((itr)->pair))
#define QSE_AWK_VAL_MAP_ITR_KEY_LEN(itr) \
(*(const qse_size_t*)&QSE_HTB_KLEN((itr)->pair))
#define QSE_AWK_VAL_MAP_ITR_VAL(itr) \ #define QSE_AWK_VAL_MAP_ITR_VAL(itr) \
((const qse_awk_val_t*)QSE_HTB_VPTR((itr)->pair)) ((const qse_awk_val_t*)QSE_HTB_VPTR((itr)->pair))

View File

@ -1,5 +1,5 @@
/* /*
* $Id: htb.h 474 2011-05-23 16:52:37Z hyunghwan.chung $ * $Id: htb.h 477 2011-05-24 04:22:40Z hyunghwan.chung $
* *
Copyright 2006-2011 Chung, Hyung-Hwan. Copyright 2006-2011 Chung, Hyung-Hwan.
This file is part of QSE. This file is part of QSE.
@ -285,6 +285,9 @@ struct qse_htb_t
#define QSE_HTB_KSCALE(m) (*(const int*)&(m)->scale[QSE_HTB_KEY]) #define QSE_HTB_KSCALE(m) (*(const int*)&(m)->scale[QSE_HTB_KEY])
#define QSE_HTB_VSCALE(m) (*(const int*)&(m)->scale[QSE_HTB_VAL]) #define QSE_HTB_VSCALE(m) (*(const int*)&(m)->scale[QSE_HTB_VAL])
#define QSE_HTB_KPTL(p) (&(p)->key)
#define QSE_HTB_VPTL(p) (&(p)->val)
#define QSE_HTB_KPTR(p) ((p)->key.ptr) #define QSE_HTB_KPTR(p) ((p)->key.ptr)
#define QSE_HTB_KLEN(p) ((p)->key.len) #define QSE_HTB_KLEN(p) ((p)->key.len)
#define QSE_HTB_VPTR(p) ((p)->val.ptr) #define QSE_HTB_VPTR(p) ((p)->val.ptr)

View File

@ -79,6 +79,8 @@
# define QSE_MAP_KEEPER(map) QSE_HTB_KEEPER(map) # define QSE_MAP_KEEPER(map) QSE_HTB_KEEPER(map)
# define QSE_MAP_KSCALE(map) QSE_HTB_KSCALE(map) # define QSE_MAP_KSCALE(map) QSE_HTB_KSCALE(map)
# define QSE_MAP_VSCALE(map) QSE_HTB_VSCALE(map) # define QSE_MAP_VSCALE(map) QSE_HTB_VSCALE(map)
# define QSE_MAP_KPTL(p) QSE_HTB_KPTL(p)
# define QSE_MAP_VPTL(p) QSE_HTB_VPTL(p)
# define QSE_MAP_KPTR(p) QSE_HTB_KPTR(p) # define QSE_MAP_KPTR(p) QSE_HTB_KPTR(p)
# define QSE_MAP_KLEN(p) QSE_HTB_KLEN(p) # define QSE_MAP_KLEN(p) QSE_HTB_KLEN(p)
# define QSE_MAP_VPTR(p) QSE_HTB_VPTR(p) # define QSE_MAP_VPTR(p) QSE_HTB_VPTR(p)
@ -135,6 +137,8 @@
# define QSE_MAP_KEEPER(map) QSE_RBT_KEEPER(map) # define QSE_MAP_KEEPER(map) QSE_RBT_KEEPER(map)
# define QSE_MAP_KSCALE(map) QSE_RBT_KSCALE(map) # define QSE_MAP_KSCALE(map) QSE_RBT_KSCALE(map)
# define QSE_MAP_VSCALE(map) QSE_RBT_VSCALE(map) # define QSE_MAP_VSCALE(map) QSE_RBT_VSCALE(map)
# define QSE_MAP_KPTL(p) QSE_RBT_KPTL(p)
# define QSE_MAP_VPTL(p) QSE_RBT_VPTL(p)
# define QSE_MAP_KPTR(p) QSE_RBT_KPTR(p) # define QSE_MAP_KPTR(p) QSE_RBT_KPTR(p)
# define QSE_MAP_KLEN(p) QSE_RBT_KLEN(p) # define QSE_MAP_KLEN(p) QSE_RBT_KLEN(p)
# define QSE_MAP_VPTR(p) QSE_RBT_VPTR(p) # define QSE_MAP_VPTR(p) QSE_RBT_VPTR(p)

View File

@ -256,6 +256,9 @@ struct qse_rbt_t
#define QSE_RBT_KSCALE(m) ((const int)(m)->scale[QSE_RBT_KEY]) #define QSE_RBT_KSCALE(m) ((const int)(m)->scale[QSE_RBT_KEY])
#define QSE_RBT_VSCALE(m) ((const int)(m)->scale[QSE_RBT_VAL]) #define QSE_RBT_VSCALE(m) ((const int)(m)->scale[QSE_RBT_VAL])
#define QSE_RBT_KPTL(p) (&(p)->key)
#define QSE_RBT_VPTL(p) (&(p)->val)
#define QSE_RBT_KPTR(p) ((p)->key.ptr) #define QSE_RBT_KPTR(p) ((p)->key.ptr)
#define QSE_RBT_KLEN(p) ((p)->key.len) #define QSE_RBT_KLEN(p) ((p)->key.len)
#define QSE_RBT_VPTR(p) ((p)->val.ptr) #define QSE_RBT_VPTR(p) ((p)->val.ptr)

View File

@ -1,5 +1,5 @@
/* /*
* $Id: Awk.cpp 476 2011-05-23 17:07:13Z hyunghwan.chung $ * $Id: Awk.cpp 477 2011-05-24 04:22:40Z hyunghwan.chung $
* *
Copyright 2006-2011 Chung, Hyung-Hwan. Copyright 2006-2011 Chung, Hyung-Hwan.
This file is part of QSE. This file is part of QSE.
@ -806,8 +806,7 @@ Awk::Value::IndexIterator Awk::Value::getFirstIndex (Index* idx) const
iptr = qse_awk_rtx_getfirstmapvalitr (this->run->rtx, this->val, &itr); iptr = qse_awk_rtx_getfirstmapvalitr (this->run->rtx, this->val, &itr);
if (iptr == QSE_NULL) return IndexIterator::END; // no more key if (iptr == QSE_NULL) return IndexIterator::END; // no more key
idx->ptr = QSE_AWK_VAL_MAP_ITR_KEY_PTR(iptr); idx->set (QSE_AWK_VAL_MAP_ITR_KEY(iptr));
idx->len = QSE_AWK_VAL_MAP_ITR_KEY_LEN(iptr);
return itr; return itr;
} }
@ -827,8 +826,7 @@ Awk::Value::IndexIterator Awk::Value::getNextIndex (
iptr = qse_awk_rtx_getnextmapvalitr (this->run->rtx, this->val, &itr); iptr = qse_awk_rtx_getnextmapvalitr (this->run->rtx, this->val, &itr);
if (iptr == QSE_NULL) return IndexIterator::END; // no more key if (iptr == QSE_NULL) return IndexIterator::END; // no more key
idx->ptr = QSE_AWK_VAL_MAP_ITR_KEY_PTR(iptr); idx->set (QSE_AWK_VAL_MAP_ITR_KEY(iptr));
idx->len = QSE_AWK_VAL_MAP_ITR_KEY_LEN(iptr);
return itr; return itr;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: run.c 469 2011-05-21 16:16:18Z hyunghwan.chung $ * $Id: run.c 477 2011-05-24 04:22:40Z hyunghwan.chung $
* *
Copyright 2006-2011 Chung, Hyung-Hwan. Copyright 2006-2011 Chung, Hyung-Hwan.
This file is part of QSE. This file is part of QSE.
@ -260,9 +260,9 @@ typedef qse_awk_val_t* (*binop_func_t) (
typedef qse_awk_val_t* (*eval_expr_t) (qse_awk_rtx_t* run, qse_awk_nde_t* nde); typedef qse_awk_val_t* (*eval_expr_t) (qse_awk_rtx_t* run, qse_awk_nde_t* nde);
#ifdef NDEBUG #ifdef NDEBUG
#define xstr_to_cstr(x) ((qse_cstr_t*)x) # define xstr_to_cstr(xstr) ((qse_cstr_t*)xstr)
#else #else
static qse_cstr_t* xstr_to_cstr (qse_xstr_t* xstr) static QSE_INLINE qse_cstr_t* xstr_to_cstr (qse_xstr_t* xstr)
{ {
/* i use this function to typecast qse_cstr_t* to /* i use this function to typecast qse_cstr_t* to
* qse_xstr_t* instead of direct typecasting. * qse_xstr_t* instead of direct typecasting.