- Improve the runtime type sytesm

- Update all languages to new type system
- Add DohSortList function
- Fix mzscheme Examples/Makefile


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@6930 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
John Lenz 2005-02-01 00:08:24 +00:00
commit f6964f285f
48 changed files with 1383 additions and 1021 deletions

View file

@ -292,6 +292,7 @@ extern int DohCopyto(DOHFile *input, DOHFile *output);
* ----------------------------------------------------------------------------- */
extern DOHList *DohNewList();
extern void DohSortList(DOH *lo, int (*cmp)(DOH *, DOH *));
/* -----------------------------------------------------------------------------
* Hash
@ -388,6 +389,7 @@ extern void DohMemoryDebug(void);
#define First DohFirst
#define Next DohNext
#define Iterator DohIterator
#define SortList DohSortList
#endif
#ifdef NIL

View file

@ -361,3 +361,18 @@ DohNewList() {
return DohObjMalloc(&DohListType,l);
}
static int (*List_sort_compare_func)(DOH *, DOH *);
static int List_qsort_compare(const void *a, const void *b) {
return List_sort_compare_func(*((DOH **)a), *((DOH **)b));
}
/* Sort a list */
void DohSortList(DOH *lo, int (*cmp)(DOH *, DOH *)) {
List *l = (List *) ObjData(lo);
if (cmp) {
List_sort_compare_func = cmp;
} else {
List_sort_compare_func = DohCmp;
}
qsort(l->items, l->nitems, sizeof(DOH *), List_qsort_compare);
}