1
0
Fork 0

Refactoring, part 2

Now with conditional compilation macros.
master
an 2017-03-12 16:55:50 -04:00
parent 844919016c
commit 0446080176
11 changed files with 66 additions and 115 deletions

View File

@ -12,7 +12,9 @@
//
//-----------------------------------------------------------------------------
#ifndef lithos3__Lth_hashmap_h
#include "Lth_libinfo.h"
#if !defined(lithos3__Lth_hashmap_h) && !LITHOS3_NO_HASHMAP
#define lithos3__Lth_hashmap_h
#include "Lth_stdlib.h"

View File

@ -0,0 +1,32 @@
//-----------------------------------------------------------------------------
//
// Copyright © 2017 Project Golan
//
// See "LICENSE.lithos3" for more information.
//
//-----------------------------------------------------------------------------
//
// Library setup.
//
//-----------------------------------------------------------------------------
#if LITHOS3_NO_STDLIB
# define LITHOS3_NO_HASHMAP 1
# define LITHOS3_NO_TOKEN 1
# define LITHOS3_NO_TOKENSTREAM 1
# define LITHOS3_NO_MANIFEST 1
#endif
#if LITHOS3_NO_HASHMAP
# define LITHOS3_NO_MANIFEST 1
#endif
#if LITHOS3_NO_TOKEN
# define LITHOS3_NO_TOKENSTREAM 1
#endif
#if LITHOS3_NO_TOKENSTREAM
# define LITHOS3_NO_MANIFEST 1
#endif
// EOF

View File

@ -1,106 +0,0 @@
//-----------------------------------------------------------------------------
//
// Copyright © 2016-2017 Project Golan
//
// See "LICENSE.lithos3" for more information.
//
//-----------------------------------------------------------------------------
//
// Doubly linked list structure.
//
//-----------------------------------------------------------------------------
#ifndef lithos3__Lth_linklist_h
#define lithos3__Lth_linklist_h
#define Lth_ListForEach(tmpv, lst) \
for(Lth_LinkList *list = (lst); list; list = list->next) \
__with(tmpv = list->owner;)
#define Lth_ListFor(tmpv, lst) \
for(Lth_LinkList *list = (lst); list;) \
__with(Lth_LinkList *next = list->next, **prev = list->prev; \
tmpv = list->owner;)
#define Lth_ListInsert(list, object, head) \
(void) \
( \
Lth_ListLink((list), (head)), \
(list)->owner = object \
)
#define Lth_ListInsertTail(list, object, head, tail) \
(void) \
( \
Lth_ListLinkTail((list), (head), (tail)), \
(list)->owner = object \
)
#define Lth_ListMove(list, head) \
(void) \
( \
Lth_ListRemove((list)), \
Lth_ListLink((list), (head)) \
)
// Type Definitions ----------------------------------------------------------|
//
// Lth_LinkList
//
typedef struct Lth_LinkList
{
struct Lth_LinkList *next, **prev;
void *owner;
} Lth_LinkList;
// Static Functions ----------------------------------------------------------|
//
// Lth_ListLink
//
static inline void Lth_ListLink(Lth_LinkList *list, Lth_LinkList **head)
{
Lth_LinkList *next = *head;
if((list->next = next))
next->prev = &list->next;
list->prev = head;
*head = list;
}
//
// Lth_ListLinkTail
//
static inline void Lth_ListLinkTail(Lth_LinkList *list, Lth_LinkList **head,
Lth_LinkList **tail)
{
Lth_LinkList *prev = *tail;
if(*(list->prev = head))
list->prev = &prev->next;
else
*head = list;
prev->next = list;
*tail = list;
}
//
// Lth_ListRemove
//
static inline void Lth_ListRemove(Lth_LinkList *list)
{
Lth_LinkList *next = list->next, **prev = list->prev;
if(prev && (*prev = next))
next->prev = prev;
list->next = NULL;
list->prev = NULL;
}
#endif//lithos3__Lth_linklist_h

View File

@ -10,7 +10,9 @@
//
//-----------------------------------------------------------------------------
#ifndef lithos3__Lth_manifest_h
#include "Lth_libinfo.h"
#if !defined(lithos3__Lth_manifest_h) && !LITHOS3_NO_MANIFEST
#define lithos3__Lth_manifest_h
#include "Lth_types.h"

View File

@ -10,7 +10,9 @@
//
//-----------------------------------------------------------------------------
#ifndef lithos3__Lth_stdlib_h
#include "Lth_libinfo.h"
#if !defined(lithos3__Lth_stdlib_h) && !LITHOS3_NO_STDLIB
#define lithos3__Lth_stdlib_h
#include "Lth_types.h"

View File

@ -14,6 +14,8 @@
//
//-----------------------------------------------------------------------------
#include "Lth_libinfo.h"
#if defined(Lth_X)
Lth_X(ChrSeq)
@ -34,7 +36,7 @@ Lth_X(LnEnd ) // \n
#undef Lth_X
#elif !defined(lithos3__Lth_token_h)
#elif !defined(lithos3__Lth_token_h) && !LITHOS3_NO_TOKEN
#define lithos3__Lth_token_h
#include <stdio.h>

View File

@ -10,7 +10,9 @@
//
//-----------------------------------------------------------------------------
#ifndef lithos3__Lth_tokenstream_h
#include "Lth_libinfo.h"
#if !defined(lithos3__Lth_tokenstream_h) && !LITHOS3_NO_TOKENSTREAM
#define lithos3__Lth_tokenstream_h
#include "Lth_token.h"

View File

@ -10,6 +10,9 @@
//
//-----------------------------------------------------------------------------
#include "Lth_libinfo.h"
#if !LITHOS3_NO_MANIFEST
#include "Lth.h"
#include <stdbool.h>
@ -448,4 +451,4 @@ Lth_Manifest Lth_ManifestNew_Strng(char const *key, char const *value)
return GenManifestValue(Strng, strng, Lth_strdup(value));
}
// EOF
#endif//LITHOS3_NO_MANIFEST

View File

@ -10,6 +10,10 @@
//
//-----------------------------------------------------------------------------
#include "Lth_libinfo.h"
#if !LITHOS3_NO_STDLIB
#include "Lth.h"
#include <GDCC.h>
@ -253,4 +257,4 @@ size_t Lth_Hash_wchar(wchar_t const *s)
return ret;
}
// EOF
#endif//LITHOS3_NO_STDLIB

View File

@ -12,6 +12,10 @@
//
//-----------------------------------------------------------------------------
#include "Lth_libinfo.h"
#if !LITHOS3_NO_TOKEN
#define _GNU_SOURCE
#include "Lth.h"
@ -149,4 +153,4 @@ char const *Lth_TokenName(Lth_TokenType type)
return names[type];
}
// EOF
#endif//LITHOS3_NO_TOKEN

View File

@ -12,6 +12,10 @@
//
//-----------------------------------------------------------------------------
#include "Lth_libinfo.h"
#if !LITHOS3_NO_TOKENSTREAM
#define _GNU_SOURCE
#include "Lth.h"
@ -215,4 +219,4 @@ bool Lth_TokenStreamDrop(Lth_TokenStream *stream, Lth_TokenType tt)
return false;
}
// EOF
#endif//LITHOS3_NO_TOKENSTREAM