fixed building problems with old compilers
This commit is contained in:
parent
682cefde1b
commit
7706db354e
@ -587,6 +587,13 @@ for (i = 0; i < QSE_COUNTOF(defs); i++) qse_xli_definepair (xli, defs[i].name, &
|
||||
qse_printf (QSE_T("#LIST\n"));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if (g_value)
|
||||
{
|
||||
TODO: ... set value...
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
@ -34,12 +34,58 @@
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
|
||||
/// The QSE_ENABLE_CPP11_MOVE macro enables C++11 move semantics
|
||||
/// in various classes.
|
||||
#if (__cplusplus >= 201103L) // C++11
|
||||
# define QSE_ENABLE_CPP11_MOVE 1
|
||||
#endif
|
||||
// The QSE_CPP_CALL_DESTRUCTOR() macro calls a destructor explicitly.
|
||||
// The QSE_CPP_CALL_PLACEMENT_DELETE1() macro calls the global operator delete
|
||||
// with 1 extra argument given.
|
||||
|
||||
#if (__cplusplus >= 201103L) // C++11
|
||||
|
||||
/// The QSE_ENABLE_CPP11_MOVE macro enables C++11 move semantics
|
||||
/// in various classes.
|
||||
#define QSE_ENABLE_CPP11_MOVE 1
|
||||
|
||||
#define QSE_CPP_CALL_DESTRUCTOR(ptr, class_name) ((ptr)->~class_name())
|
||||
#define QSE_CPP_CALL_PLACEMENT_DELETE1(ptr, arg1) (::operator delete ((ptr), (arg1)))
|
||||
|
||||
#elif (__cplusplus >= 199711L) // C++98
|
||||
|
||||
#define QSE_CPP_CALL_DESTRUCTOR(ptr, class_name) ((ptr)->~class_name())
|
||||
#define QSE_CPP_CALL_PLACEMENT_DELETE1(ptr, arg1) (::operator delete ((ptr), (arg1)))
|
||||
|
||||
#else
|
||||
|
||||
#if defined(__BORLANDC__)
|
||||
|
||||
// Explicit destructor call requires a class name depending on the
|
||||
// C++ standard/compiler.
|
||||
//
|
||||
// Node* x;
|
||||
// x->~Node ();
|
||||
//
|
||||
// While x->~Node() is ok with modern compilers, some old compilers
|
||||
// like BCC55 required the class name in the call as shown below.
|
||||
//
|
||||
// x->Node::~Node ();
|
||||
|
||||
#define QSE_CPP_CALL_DESTRUCTOR(ptr, class_name) ((ptr)->class_name::~class_name())
|
||||
#define QSE_CPP_CALL_PLACEMENT_DELETE1(ptr, arg1) (::operator delete ((ptr), (arg1)))
|
||||
|
||||
#elif defined(__WATCOMC__)
|
||||
// WATCOM has a problem with this syntax.
|
||||
// Node* x; x->Node::~Node().
|
||||
// But it doesn't support operator delete overloading.
|
||||
|
||||
#define QSE_CPP_CALL_DESTRUCTOR(ptr, class_name) ((ptr)->~class_name())
|
||||
#define QSE_CPP_CALL_PLACEMENT_DELETE1(ptr, arg1) (::operator_delete ((ptr), (arg1)))
|
||||
|
||||
#else
|
||||
|
||||
#define QSE_CPP_CALL_DESTRUCTOR(ptr, class_name) ((ptr)->~class_name())
|
||||
#define QSE_CPP_CALL_PLACEMENT_DELETE1(ptr, arg1) (::operator delete ((ptr), (arg1)))
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(QSE_ENABLE_CPP11_MOVE)
|
||||
|
||||
|
@ -198,7 +198,8 @@ protected:
|
||||
qse_size_t index;
|
||||
|
||||
//T* tmp = new T[capa];
|
||||
T* tmp = (T*)::operator new (capa * QSE_SIZEOF(*tmp), this->getMmgr());
|
||||
//T* tmp = (T*)::operator new (capa * QSE_SIZEOF(*tmp), this->getMmgr());
|
||||
T* tmp = (T*)this->getMmgr()->allocate (capa * QSE_SIZEOF(*tmp));
|
||||
|
||||
try
|
||||
{
|
||||
@ -217,9 +218,11 @@ protected:
|
||||
{
|
||||
--index;
|
||||
this->_positioner (tmp[index], INVALID_INDEX);
|
||||
tmp[index].~T ();
|
||||
tmp[index].T::~T ();
|
||||
}
|
||||
::operator delete (tmp, this->getMmgr());
|
||||
|
||||
//::operator delete (tmp, this->getMmgr());
|
||||
this->getMmgr()->dispose (tmp);
|
||||
|
||||
throw;
|
||||
}
|
||||
@ -236,7 +239,8 @@ protected:
|
||||
qse_size_t index;
|
||||
|
||||
//T* tmp = new T[capa];
|
||||
T* tmp = (T*)::operator new (capa * QSE_SIZEOF(*tmp), this->getMmgr());
|
||||
//T* tmp = (T*)::operator new (capa * QSE_SIZEOF(*tmp), this->getMmgr());
|
||||
T* tmp = (T*)this->getMmgr()->allocate (capa * QSE_SIZEOF(*tmp));
|
||||
|
||||
try
|
||||
{
|
||||
@ -265,9 +269,11 @@ protected:
|
||||
//catch (...) {}
|
||||
|
||||
this->_positioner (tmp[index], INVALID_INDEX);
|
||||
tmp[index].~T ();
|
||||
tmp[index].T::~T ();
|
||||
}
|
||||
::operator delete (tmp, this->getMmgr());
|
||||
|
||||
//::operator delete (tmp, this->getMmgr());
|
||||
this->getMmgr()->dispose (tmp);
|
||||
|
||||
throw;
|
||||
}
|
||||
@ -320,7 +326,7 @@ protected:
|
||||
{
|
||||
--i;
|
||||
this->_positioner (this->buffer[i], INVALID_INDEX);
|
||||
this->buffer[i].~T ();
|
||||
this->buffer[i].T::~T ();
|
||||
}
|
||||
|
||||
this->count = 0;
|
||||
@ -587,7 +593,7 @@ public:
|
||||
|
||||
// 1. destruct followed by copy construct
|
||||
//this->_positioner (this->buffer[j], INVALID_INDEX);
|
||||
//this->buffer[j].~T();
|
||||
//this->buffer[j].T::~T();
|
||||
//new((QSE::Mmgr*)QSE_NULL, &this->buffer[j]) T(this->buffer[i]);
|
||||
//this->_positioner (this->buffer[j], j);
|
||||
|
||||
@ -602,7 +608,7 @@ public:
|
||||
while (j < this->count)
|
||||
{
|
||||
this->_positioner (this->buffer[j], INVALID_INDEX);
|
||||
this->buffer[j].~T ();
|
||||
this->buffer[j].T::~T ();
|
||||
j++;
|
||||
}
|
||||
|
||||
@ -638,11 +644,10 @@ public:
|
||||
QSE_ASSERT (this->count <= 0);
|
||||
QSE_ASSERT (this->capacity > 0);
|
||||
|
||||
::operator delete (this->buffer, this->getMmgr());
|
||||
this->capacity = 0;
|
||||
//::operator delete (this->buffer, this->getMmgr());
|
||||
this->getMmgr()->dispose (this->buffer);
|
||||
this->buffer = QSE_NULL;
|
||||
|
||||
QSE_ASSERT (this->capacity == 0);
|
||||
this->capacity = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -654,7 +659,7 @@ public:
|
||||
{
|
||||
// call the destructor of the items
|
||||
this->_positioner (this->buffer[i], INVALID_INDEX);
|
||||
this->buffer[i].~T ();
|
||||
this->buffer[i].T::~T ();
|
||||
}
|
||||
|
||||
this->count = size;
|
||||
@ -703,7 +708,8 @@ public:
|
||||
QSE_ASSERT (this->capacity <= 0);
|
||||
QSE_ASSERT (this->count <= 0);
|
||||
|
||||
this->buffer = (T*)::operator new (capa * QSE_SIZEOF(*this->buffer), this->getMmgr());
|
||||
//this->buffer = (T*)::operator new (capa * QSE_SIZEOF(*this->buffer), this->getMmgr());
|
||||
this->buffer = (T*)this->getMmgr()->allocate (capa * QSE_SIZEOF(*this->buffer));
|
||||
this->capacity = capa;
|
||||
}
|
||||
}
|
||||
|
@ -763,17 +763,8 @@ private:
|
||||
void free_datum_list ()
|
||||
{
|
||||
// destruction in response to 'placement new'
|
||||
|
||||
#if defined(__BORLANDC__)
|
||||
// BCC55 doesn't support the explicit destructor call.
|
||||
// instead, call shatter() which is actually called by ~DatumList().
|
||||
this->datum_list->shatter ();
|
||||
#else
|
||||
// call the destructor for completeness
|
||||
this->datum_list->~DatumList ();
|
||||
#endif
|
||||
// free the memory
|
||||
::operator delete (this->datum_list, this->getMmgr());
|
||||
QSE_CPP_CALL_DESTRUCTOR (this->datum_list, DatumList);
|
||||
QSE_CPP_CALL_PLACEMENT_DELETE1 (this->datum_list, this->getMmgr());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -248,8 +248,12 @@ public:
|
||||
|
||||
Pair* search (const K& key)
|
||||
{
|
||||
//PairNode* node = this->pair_list.update (Pair(key));
|
||||
//PairNode* node = this->pair_list.search (Pair(key));
|
||||
#if defined(__WATCOMC__)
|
||||
PairNode* node = this->pair_list.heterofindNode<K,HASHER,PairHeteroEqualer> (key);
|
||||
#else
|
||||
PairNode* node = this->pair_list.template heterofindNode<K,HASHER,PairHeteroEqualer> (key);
|
||||
#endif
|
||||
if (!node) return QSE_NULL;
|
||||
return &node->value;
|
||||
}
|
||||
@ -257,14 +261,22 @@ public:
|
||||
int remove (const K& key)
|
||||
{
|
||||
//return this->pair_list.remove (Pair(key));
|
||||
#if defined(__WATCOMC__)
|
||||
return this->pair_list.heteroremove<K,HASHER,PairHeteroEqualer> (key);
|
||||
#else
|
||||
return this->pair_list.template heteroremove<K,HASHER,PairHeteroEqualer> (key);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename MK, typename MHASHER, typename MEQUALER>
|
||||
Pair* heterosearch (const MK& key)
|
||||
{
|
||||
typedef MHeteroEqualer<MK,MEQUALER> MEqualer;
|
||||
#if defined(__WATCOMC__)
|
||||
PairNode* node = this->pair_list.heterosearch<MK,MHASHER,MEqualer> (key);
|
||||
#else
|
||||
PairNode* node = this->pair_list.template heterosearch<MK,MHASHER,MEqualer> (key);
|
||||
#endif
|
||||
if (!node) return QSE_NULL;
|
||||
return &node->value;
|
||||
}
|
||||
|
@ -207,11 +207,6 @@ public:
|
||||
};
|
||||
|
||||
~LinkedList ()
|
||||
{
|
||||
this->shatter ();
|
||||
}
|
||||
|
||||
void shatter ()
|
||||
{
|
||||
this->clear (true);
|
||||
}
|
||||
@ -441,11 +436,8 @@ public:
|
||||
void remove (Node* node)
|
||||
{
|
||||
this->yield (node, false);
|
||||
|
||||
//call the destructor
|
||||
node->~Node ();
|
||||
// free the memory
|
||||
::operator delete (node, &this->mp);
|
||||
QSE_CPP_CALL_DESTRUCTOR (node, Node);
|
||||
QSE_CPP_CALL_PLACEMENT_DELETE1 (node, &this->mp);
|
||||
}
|
||||
|
||||
Node* yieldByValue (const T& value, bool clear_links = true)
|
||||
@ -659,8 +651,8 @@ public:
|
||||
saved = p->next;
|
||||
|
||||
// placement new/delete handling
|
||||
p->~Node (); // call the destructor
|
||||
::operator delete (p, &this->mp); // free the memory
|
||||
QSE_CPP_CALL_DESTRUCTOR (p, Node);
|
||||
QSE_CPP_CALL_PLACEMENT_DELETE1 (p, &this->mp);
|
||||
|
||||
this->node_count--;
|
||||
p = saved;
|
||||
|
@ -174,10 +174,11 @@ protected:
|
||||
QSE_END_NAMESPACE(QSE)
|
||||
/////////////////////////////////
|
||||
|
||||
void* operator new (qse_size_t size, QSE::Mmgr* mmgr);
|
||||
void operator delete (void* ptr, QSE::Mmgr* mmgr);
|
||||
QSE_EXPORT void* operator new (qse_size_t size, QSE::Mmgr* mmgr);
|
||||
|
||||
void* operator new (qse_size_t size, QSE::Mmgr* mmgr, void* existing_ptr);
|
||||
QSE_EXPORT void operator delete (void* ptr, QSE::Mmgr* mmgr);
|
||||
|
||||
QSE_EXPORT void* operator new (qse_size_t size, QSE::Mmgr* mmgr, void* existing_ptr);
|
||||
|
||||
#if 0
|
||||
// i found no way to delete an array allocated with
|
||||
|
@ -124,9 +124,10 @@ protected:
|
||||
QSE_END_NAMESPACE(QSE)
|
||||
////////////////////////////////
|
||||
|
||||
void* operator new (qse_size_t size, QSE::Mpool* mp);
|
||||
void operator delete (void* ptr, QSE::Mpool* mp);
|
||||
QSE_EXPORT void* operator new (qse_size_t size, QSE::Mpool* mp);
|
||||
|
||||
void* operator new (qse_size_t size, QSE::Mpool* mp, void* existing_ptr);
|
||||
QSE_EXPORT void operator delete (void* ptr, QSE::Mpool* mp);
|
||||
|
||||
QSE_EXPORT void* operator new (qse_size_t size, QSE::Mpool* mp, void* existing_ptr);
|
||||
#endif
|
||||
|
||||
|
@ -387,8 +387,8 @@ public:
|
||||
|
||||
#if defined(QSE_REDBLACKTREE_ALLOCATE_NIL)
|
||||
// destroy the nil node.
|
||||
this->nil->~Node ();
|
||||
::operator delete (this->nil, this->getMmgr());
|
||||
QSE_CPP_CALL_DESTRUCTOR (this->nil, Node);
|
||||
QSE_CPP_CALL_PLACEMENT_DELETE1 (this->nil, this->getMmgr());
|
||||
#else
|
||||
// do nothing
|
||||
#endif
|
||||
@ -447,10 +447,8 @@ public:
|
||||
protected:
|
||||
void dispose_node (Node* node)
|
||||
{
|
||||
//call the destructor
|
||||
node->~Node ();
|
||||
// free the memory
|
||||
::operator delete (node, &this->mp);
|
||||
QSE_CPP_CALL_DESTRUCTOR (node, Node);
|
||||
QSE_CPP_CALL_PLACEMENT_DELETE1 (node, &this->mp);
|
||||
}
|
||||
|
||||
Node* find_node (const T& datum) const
|
||||
|
@ -60,8 +60,8 @@ struct ScopedPtrMmgrDeleter
|
||||
{
|
||||
void operator() (T* ptr, void* arg)
|
||||
{
|
||||
ptr->~T ();
|
||||
::operator delete (ptr, (QSE::Mmgr*)arg);
|
||||
QSE_CPP_CALL_DESTRUCTOR (ptr, T);
|
||||
QSE_CPP_CALL_PLACEMENT_DELETE1 (ptr, (QSE::Mmgr*)arg);
|
||||
}
|
||||
};
|
||||
|
||||
@ -184,8 +184,8 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
T* _ptr;
|
||||
void* _darg;
|
||||
T* _ptr;
|
||||
void* _darg;
|
||||
DELETER _deleter;
|
||||
};
|
||||
|
||||
|
@ -60,8 +60,8 @@ struct SharedPtrMmgrDeleter
|
||||
{
|
||||
void operator() (T* ptr, void* arg)
|
||||
{
|
||||
ptr->~T ();
|
||||
::operator delete (ptr, (QSE::Mmgr*)arg);
|
||||
QSE_CPP_CALL_DESTRUCTOR (ptr, T);
|
||||
QSE_CPP_CALL_PLACEMENT_DELETE1 (ptr, (QSE::Mmgr*)arg);
|
||||
}
|
||||
};
|
||||
|
||||
@ -79,7 +79,7 @@ public:
|
||||
|
||||
SharedPtr (T* ptr = (T*)QSE_NULL, void* darg = (void*)QSE_NULL): Mmged(QSE_NULL)
|
||||
{
|
||||
this->_item = new (this->getMmgr()) item_t;
|
||||
this->_item = new(this->getMmgr()) item_t;
|
||||
this->_item->ptr = ptr;
|
||||
this->_item->darg = darg;
|
||||
|
||||
@ -88,7 +88,7 @@ public:
|
||||
|
||||
SharedPtr (Mmgr* mmgr, T* ptr = (T*)QSE_NULL, void* darg = (void*)QSE_NULL): Mmged(mmgr)
|
||||
{
|
||||
this->_item = new (this->getMmgr()) item_t;
|
||||
this->_item = new(this->getMmgr()) item_t;
|
||||
this->_item->ptr = ptr;
|
||||
this->_item->darg = darg;
|
||||
|
||||
@ -104,9 +104,11 @@ public:
|
||||
{
|
||||
if (this->_item->deref() <= 0)
|
||||
{
|
||||
// reference count reached 0.
|
||||
if (this->_item->ptr) this->_item->deleter (this->_item->ptr, this->_item->darg);
|
||||
// no destructor as *this->_ref is a plain type.
|
||||
::operator delete (this->_item, this->getMmgr());
|
||||
|
||||
QSE_CPP_CALL_DESTRUCTOR (this->_item, item_t);
|
||||
QSE_CPP_CALL_PLACEMENT_DELETE1 (this->_item, this->getMmgr());
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,8 +119,9 @@ public:
|
||||
if (this->_item->deref() <= 0)
|
||||
{
|
||||
if (this->_item->ptr) this->_item->deleter (this->_item->ptr, this->_item->darg);
|
||||
// no destructor as *this->_ref is a plain type.
|
||||
::operator delete (this->_item, this->getMmgr());
|
||||
|
||||
QSE_CPP_CALL_DESTRUCTOR (this->_item, item_t);
|
||||
QSE_CPP_CALL_PLACEMENT_DELETE1 (this->_item, this->getMmgr());
|
||||
}
|
||||
|
||||
// must copy the memory manager pointer as the item
|
||||
|
@ -53,7 +53,8 @@ protected:
|
||||
if (capacity < size) capacity = size;
|
||||
|
||||
// I assume that CHAR_TYPE is a plain type.
|
||||
this->buffer = (CHAR_TYPE*)::operator new ((capacity + 1) * QSE_SIZEOF(CHAR_TYPE), mmgr);
|
||||
//this->buffer = (CHAR_TYPE*)::operator new ((capacity + 1) * QSE_SIZEOF(CHAR_TYPE), mmgr);
|
||||
this->buffer = (CHAR_TYPE*)mmgr->allocate((capacity + 1) * QSE_SIZEOF(CHAR_TYPE));
|
||||
// So no constructor calling is needed.
|
||||
//for (qse_size_t i = 0; i < capacity + 1; i++)
|
||||
//{
|
||||
@ -69,7 +70,8 @@ protected:
|
||||
buffer (QSE_NULL) // set buffer to QSE_NULL here in case operator new rasises an exception
|
||||
{
|
||||
if (capacity < size) capacity = size;
|
||||
this->buffer = (CHAR_TYPE*)::operator new ((capacity + 1) * QSE_SIZEOF(CHAR_TYPE), mmgr);
|
||||
//this->buffer = (CHAR_TYPE*)::operator new ((capacity + 1) * QSE_SIZEOF(CHAR_TYPE), mmgr);
|
||||
this->buffer = (CHAR_TYPE*)mmgr->allocate((capacity + 1) * QSE_SIZEOF(CHAR_TYPE));
|
||||
|
||||
this->capacity = capacity;
|
||||
this->buffer[size] = NULL_CHAR;
|
||||
@ -80,7 +82,7 @@ protected:
|
||||
void shatter (Mmgr* mmgr)
|
||||
{
|
||||
QSE_ASSERT (this->buffer != QSE_NULL);
|
||||
::operator delete (this->buffer, mmgr);
|
||||
mmgr->dispose (this->buffer); //::operator_delete (this->buffer, mmgr);
|
||||
this->buffer = QSE_NULL;
|
||||
}
|
||||
|
||||
@ -107,13 +109,15 @@ protected:
|
||||
if (inc > 0)
|
||||
{
|
||||
qse_size_t newcapa = this->capacity + inc;
|
||||
CHAR_TYPE* tmp = ::operator new ((newcapa + 1) * QSE_SIZEOF(CHAR_TYPE), mmgr);
|
||||
//CHAR_TYPE* tmp = ::operator new ((newcapa + 1) * QSE_SIZEOF(CHAR_TYPE), mmgr);
|
||||
CHAR_TYPE* tmp = (CHAR_TYPE*)mmgr->allocate((newcapa + 1) * QSE_SIZEOF(CHAR_TYPE));
|
||||
|
||||
qse_size_t cursize = this->size;
|
||||
this->size = this->opset.copy (tmp, this->buffer, cursize);
|
||||
QSE_ASSERT (this->size == cursize);
|
||||
|
||||
::operator delete (this->buffer, mmgr);
|
||||
//::operator_delete (this->buffer, mmgr);
|
||||
mmgr->dispose (this->buffer);
|
||||
|
||||
this->buffer = tmp;
|
||||
this->capacity = newcapa;
|
||||
@ -287,18 +291,10 @@ protected:
|
||||
// destroy the actual contents via the shatter() funtion
|
||||
// call the destructor for completeness only
|
||||
sd->shatter (this->getMmgr());
|
||||
#if defined(__BORLANDC__)
|
||||
// BCC55 doesn't support calling the destructor explicitly.
|
||||
// anyway, it's safe not to call it for the way i destroy
|
||||
// the object using the shatter() call above
|
||||
//
|
||||
// DO NOTHING
|
||||
//
|
||||
#else
|
||||
// call the destructor
|
||||
sd->~StringItem ();
|
||||
#endif
|
||||
::operator delete (sd, this->getMmgr());
|
||||
|
||||
// delete the object allocated using the place new
|
||||
QSE_CPP_CALL_DESTRUCTOR (sd, StringItem);
|
||||
QSE_CPP_CALL_PLACEMENT_DELETE1 (sd, this->getMmgr());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,7 @@
|
||||
* }
|
||||
* key3 = "12345";
|
||||
* \endcode
|
||||
*
|
||||
*/
|
||||
|
||||
#include <qse/types.h>
|
||||
@ -145,16 +146,16 @@ enum qse_xli_trait_t
|
||||
};
|
||||
typedef enum qse_xli_trait_t qse_xli_trait_t;
|
||||
|
||||
typedef struct qse_xli_val_t qse_xli_val_t;
|
||||
typedef struct qse_xli_nil_t qse_xli_nil_t;
|
||||
typedef struct qse_xli_str_t qse_xli_str_t;
|
||||
typedef struct qse_xli_val_t qse_xli_val_t;
|
||||
typedef struct qse_xli_nil_t qse_xli_nil_t;
|
||||
typedef struct qse_xli_str_t qse_xli_str_t;
|
||||
typedef struct qse_xli_list_t qse_xli_list_t;
|
||||
|
||||
typedef struct qse_xli_atom_t qse_xli_atom_t;
|
||||
typedef struct qse_xli_pair_t qse_xli_pair_t;
|
||||
typedef struct qse_xli_text_t qse_xli_text_t;
|
||||
typedef struct qse_xli_file_t qse_xli_file_t;
|
||||
typedef struct qse_xli_eof_t qse_xli_eof_t;
|
||||
typedef struct qse_xli_eof_t qse_xli_eof_t;
|
||||
|
||||
enum qse_xli_val_type_t
|
||||
{
|
||||
@ -581,6 +582,13 @@ QSE_EXPORT qse_xli_pair_t* qse_xli_insertpair (
|
||||
qse_xli_val_t* val
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_xli_insertpairwithemptylist() function inserts a new pair
|
||||
* with an empty list as a value. You should call this function for adding
|
||||
* a new pair holding a list.
|
||||
*
|
||||
* \return pointer to an inserted pair on success, #QSE_NULL on failure.
|
||||
*/
|
||||
QSE_EXPORT qse_xli_pair_t* qse_xli_insertpairwithemptylist (
|
||||
qse_xli_t* xli,
|
||||
qse_xli_list_t* list,
|
||||
@ -590,6 +598,10 @@ QSE_EXPORT qse_xli_pair_t* qse_xli_insertpairwithemptylist (
|
||||
const qse_char_t* keytag
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_xli_insertpairwithstr() function inserts a new pair with a key
|
||||
* named \a key with a string value \a value.
|
||||
*/
|
||||
QSE_EXPORT qse_xli_pair_t* qse_xli_insertpairwithstr (
|
||||
qse_xli_t* xli,
|
||||
qse_xli_list_t* list,
|
||||
@ -644,6 +656,7 @@ QSE_EXPORT qse_size_t qse_xli_countpairs (
|
||||
const qse_char_t* fqpn
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* The qse_xli_addsegtostr() function creates a new string segment made of
|
||||
* the character string pointed to by \a value and chains it to the XLI string
|
||||
|
@ -1452,7 +1452,11 @@ int Awk::dispatch_function (Run* run, const fnc_info_t* fi)
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
try { args = (Value*)::operator new (QSE_SIZEOF(Value) * nargs, this->getMmgr()); }
|
||||
try
|
||||
{
|
||||
//args = (Value*)::operator new (QSE_SIZEOF(Value) * nargs, this->getMmgr());
|
||||
args = (Value*)this->getMmgr()->allocate (QSE_SIZEOF(Value) * nargs);
|
||||
}
|
||||
catch (...) { args = QSE_NULL; }
|
||||
if (args == QSE_NULL)
|
||||
{
|
||||
@ -1564,9 +1568,11 @@ int Awk::dispatch_function (Run* run, const fnc_info_t* fi)
|
||||
for (i = nargs; i > 0; )
|
||||
{
|
||||
--i;
|
||||
args[i].~Value ();
|
||||
args[i].Value::~Value ();
|
||||
}
|
||||
::operator delete (args, this->getMmgr());
|
||||
|
||||
//::operator delete (args, this->getMmgr());
|
||||
this->getMmgr()->dispose (args);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -490,6 +490,14 @@ static void free_val (qse_xli_root_list_t* root, qse_xli_val_t* val)
|
||||
|
||||
static void free_atom (qse_xli_root_list_t* root, qse_xli_atom_t* atom)
|
||||
{
|
||||
/* Among all atom type, QSE_XLI_PAIR has a value to dispose of specially.
|
||||
* A tag and an alise are inlined to the atom itself. see insert_atom()
|
||||
* above for details.
|
||||
*
|
||||
* for QSE_XLI_TEXT, QSE_XLI_FILE, QSE_XLI_EOF, data are inlined to
|
||||
* the atom itself as well.
|
||||
*/
|
||||
|
||||
if (atom->type == QSE_XLI_PAIR) free_val (root, ((qse_xli_pair_t*)atom)->val);
|
||||
QSE_MMGR_FREE (root->mmgr, atom);
|
||||
}
|
||||
@ -947,15 +955,58 @@ void qse_xli_undefinepairs (qse_xli_t* xli)
|
||||
qse_rbt_clear (xli->schema);
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
/*
|
||||
qse_xli_pair_t* qse_xli_getpair (qse_xli_t* xli, const qse_char_t* fqpn)
|
||||
{
|
||||
return qse_xli_findpair (xli, &xli->root->list, fqpn);
|
||||
}
|
||||
*/
|
||||
|
||||
qse_xli_pair_t* qse_xli_setpair (qse_xli_t* xli, const qse_char_t* fqpn, const qse_xli_val_t* val) -> str, val, nil
|
||||
#if 0
|
||||
/* val is str , list or nil */
|
||||
qse_xli_pair_t* qse_xli_updatepair (qse_xli_t* xli, const qse_char_t* fqpn, const qse_xli_val_t* val)
|
||||
{
|
||||
qse_xli_pair_t* pair;
|
||||
|
||||
pair = qse_xli_findpair (xli, fqpn);
|
||||
if (pair)
|
||||
{
|
||||
/* update the value of an existing pair */
|
||||
qse_xli_val_t* old_val;
|
||||
qse_xli_scm_t* scm;
|
||||
|
||||
if (xli->opt.trait & QSE_XLI_VALIDATE)
|
||||
{
|
||||
qse_rbt_pair_t* scm_pair;
|
||||
|
||||
scm_pair = qse_rbt_search (xli->schema, fqpn, qse_strlen(fqpn));
|
||||
if (!scm_pair)
|
||||
{
|
||||
/*qse_xli_seterror (xli, QSE_XLI_EUDKEY, (const qse_cstr_t*)&key, &kloc);*/
|
||||
goto oops;
|
||||
}
|
||||
|
||||
scm = (qse_xli_scm_t*)QSE_RBT_VPTR(pair);
|
||||
}
|
||||
|
||||
if (scm->flags & QSE_XLI_SCM_KEYNODUP) key_nodup = 2;
|
||||
if (scm->flags & QSE_XLI_SCM_KEYALIAS) key_alias = 2;
|
||||
if (scm->flags & QSE_XLI_SCM_VALIFFY) val_iffy = 1;
|
||||
|
||||
/* TODO: alias, tag??
|
||||
* when alias and tags are to changed, it can't just update the value only
|
||||
* the whole pair may have to get reallocated and update must be made to the rbt data array.
|
||||
*/
|
||||
|
||||
old_val = pair->val;
|
||||
pair->val = val;
|
||||
free_val (old_val);
|
||||
|
||||
}
|
||||
|
||||
return pair;
|
||||
|
||||
#if 0
|
||||
const qse_char_t* ptr;
|
||||
const qse_xli_list_t* curlist;
|
||||
fqpn_seg_t seg;
|
||||
@ -1035,7 +1086,10 @@ qse_xli_pair_t* qse_xli_setpair (qse_xli_t* xli, const qse_char_t* fqpn, const q
|
||||
noent:
|
||||
qse_xli_seterrnum (xli, QSE_XLI_ENOENT, &seg.ki);
|
||||
return QSE_NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
void* qse_getxlipairxtn (qse_xli_pair_t* pair)
|
||||
|
Loading…
x
Reference in New Issue
Block a user