Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ambrop72/badvpn.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmbroz Bizjak <ambrop7@gmail.com>2014-04-05 16:27:38 +0400
committerAmbroz Bizjak <ambrop7@gmail.com>2014-10-28 01:08:00 +0300
commit670282f01472438cd8a013b2aecf26221116e348 (patch)
treef5fd878e4bd7b6db84a39ff532e7db0eb545bac3
parent1ed046a784056c1eea8e3b450cbe1dc7ac3da8b5 (diff)
ncd: NCDVal: Move lots of implementation details out of the header.
-rw-r--r--ncd/NCDVal.c93
-rw-r--r--ncd/NCDVal.h92
2 files changed, 94 insertions, 91 deletions
diff --git a/ncd/NCDVal.c b/ncd/NCDVal.c
index a849897..aae194f 100644
--- a/ncd/NCDVal.c
+++ b/ncd/NCDVal.c
@@ -36,12 +36,16 @@
#include <misc/balloc.h>
#include <misc/strdup.h>
#include <misc/offset.h>
+#include <structure/CAvl.h>
#include <base/BLog.h>
#include "NCDVal.h"
#include <generated/blog_channel_NCDVal.h>
+#define NCDVAL_FIRST_SIZE 256
+#define NCDVAL_MAX_DEPTH 32
+
#define TYPE_MASK_EXTERNAL_TYPE ((1 << 3) - 1)
#define TYPE_MASK_INTERNAL_TYPE ((1 << 5) - 1)
#define TYPE_SHIFT_DEPTH 5
@@ -51,6 +55,95 @@
#define EXTERNALSTRING_TYPE (NCDVAL_STRING | (2 << 3))
#define COMPOSEDSTRING_TYPE (NCDVAL_STRING | (3 << 3))
+#define NCDVAL_INSTR_PLACEHOLDER 0
+#define NCDVAL_INSTR_REINSERT 1
+#define NCDVAL_INSTR_BUMPDEPTH 2
+
+struct NCDVal__ref {
+ NCDVal__idx next;
+ BRefTarget *target;
+};
+
+struct NCDVal__string {
+ int type;
+ NCDVal__idx length;
+ char data[];
+};
+
+struct NCDVal__list {
+ int type;
+ NCDVal__idx maxcount;
+ NCDVal__idx count;
+ NCDVal__idx elem_indices[];
+};
+
+struct NCDVal__mapelem {
+ NCDVal__idx key_idx;
+ NCDVal__idx val_idx;
+ NCDVal__idx tree_child[2];
+ NCDVal__idx tree_parent;
+ int8_t tree_balance;
+};
+
+struct NCDVal__idstring {
+ int type;
+ NCD_string_id_t string_id;
+ NCDStringIndex *string_index;
+};
+
+struct NCDVal__externalstring {
+ int type;
+ const char *data;
+ size_t length;
+ struct NCDVal__ref ref;
+};
+
+struct NCDVal__composedstring {
+ int type;
+ size_t offset;
+ size_t length;
+ void (*func_getptr) (void *, size_t, const char **, size_t *);
+ void *user;
+ struct NCDVal__ref ref;
+};
+
+struct NCDVal__cms_link {
+ NCDVal__idx link_idx;
+ NCDVal__idx next_cms_link;
+};
+
+typedef struct NCDVal__mapelem NCDVal__maptree_entry;
+typedef NCDValMem *NCDVal__maptree_arg;
+
+#include "NCDVal_maptree.h"
+#include <structure/CAvl_decl.h>
+
+struct NCDVal__map {
+ int type;
+ NCDVal__idx maxcount;
+ NCDVal__idx count;
+ NCDVal__MapTree tree;
+ struct NCDVal__mapelem elems[];
+};
+
+struct NCDVal__instr {
+ int type;
+ union {
+ struct {
+ NCDVal__idx plid;
+ NCDVal__idx plidx;
+ } placeholder;
+ struct {
+ NCDVal__idx mapidx;
+ NCDVal__idx elempos;
+ } reinsert;
+ struct {
+ NCDVal__idx parent_idx;
+ NCDVal__idx child_idx_idx;
+ } bumpdepth;
+ };
+};
+
static int make_type (int internal_type, int depth)
{
ASSERT(internal_type == NCDVAL_LIST ||
diff --git a/ncd/NCDVal.h b/ncd/NCDVal.h
index f801485..17d7291 100644
--- a/ncd/NCDVal.h
+++ b/ncd/NCDVal.h
@@ -37,73 +37,17 @@
#include <misc/maxalign.h>
#include <misc/cstring.h>
#include <misc/BRefTarget.h>
-#include <structure/CAvl.h>
#include <ncd/NCDStringIndex.h>
// these are implementation details. The interface is defined below.
#define NCDVAL_FASTBUF_SIZE 64
-#define NCDVAL_FIRST_SIZE 256
-#define NCDVAL_MAX_DEPTH 32
#define NCDVAL_MAXIDX INT_MAX
#define NCDVAL_MINIDX INT_MIN
typedef int NCDVal__idx;
-struct NCDVal__ref {
- NCDVal__idx next;
- BRefTarget *target;
-};
-
-struct NCDVal__string {
- int type;
- NCDVal__idx length;
- char data[];
-};
-
-struct NCDVal__list {
- int type;
- NCDVal__idx maxcount;
- NCDVal__idx count;
- NCDVal__idx elem_indices[];
-};
-
-struct NCDVal__mapelem {
- NCDVal__idx key_idx;
- NCDVal__idx val_idx;
- NCDVal__idx tree_child[2];
- NCDVal__idx tree_parent;
- int8_t tree_balance;
-};
-
-struct NCDVal__idstring {
- int type;
- NCD_string_id_t string_id;
- NCDStringIndex *string_index;
-};
-
-struct NCDVal__externalstring {
- int type;
- const char *data;
- size_t length;
- struct NCDVal__ref ref;
-};
-
-struct NCDVal__composedstring {
- int type;
- size_t offset;
- size_t length;
- void (*func_getptr) (void *, size_t, const char **, size_t *);
- void *user;
- struct NCDVal__ref ref;
-};
-
-struct NCDVal__cms_link {
- NCDVal__idx link_idx;
- NCDVal__idx next_cms_link;
-};
-
typedef struct {
char *buf;
NCDVal__idx size;
@@ -125,45 +69,11 @@ typedef struct {
NCDVal__idx idx;
} NCDValSafeRef;
-typedef struct NCDVal__mapelem NCDVal__maptree_entry;
-typedef NCDValMem *NCDVal__maptree_arg;
-
-#include "NCDVal_maptree.h"
-#include <structure/CAvl_decl.h>
-
-struct NCDVal__map {
- int type;
- NCDVal__idx maxcount;
- NCDVal__idx count;
- NCDVal__MapTree tree;
- struct NCDVal__mapelem elems[];
-};
-
typedef struct {
NCDVal__idx elemidx;
} NCDValMapElem;
-#define NCDVAL_INSTR_PLACEHOLDER 0
-#define NCDVAL_INSTR_REINSERT 1
-#define NCDVAL_INSTR_BUMPDEPTH 2
-
-struct NCDVal__instr {
- int type;
- union {
- struct {
- NCDVal__idx plid;
- NCDVal__idx plidx;
- } placeholder;
- struct {
- NCDVal__idx mapidx;
- NCDVal__idx elempos;
- } reinsert;
- struct {
- NCDVal__idx parent_idx;
- NCDVal__idx child_idx_idx;
- } bumpdepth;
- };
-};
+struct NCDVal__instr;
typedef struct {
struct NCDVal__instr *instrs;