Coverage Report

Created: 2025-08-29 06:48

/src/libxmlb/src/xb-silo-node.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright 2021 Richard Hughes <richard@hughsie.com>
3
 *
4
 * SPDX-License-Identifier: LGPL-2.1-or-later
5
 */
6
7
#pragma once
8
9
#include "xb-compile.h"
10
11
3.90M
#define XB_SILO_UNSET 0xffffffff
12
13
typedef enum {
14
  XB_SILO_NODE_FLAG_NONE = 0,
15
  XB_SILO_NODE_FLAG_IS_ELEMENT = 1 << 0,
16
  XB_SILO_NODE_FLAG_IS_TOKENIZED = 1 << 1,
17
} XbSiloNodeFlag;
18
19
typedef struct __attribute__((packed)) {
20
  guint8 flags : 2;
21
  guint8 attr_count : 6;
22
  guint8 token_count;   /* ONLY when is_element */
23
  guint32 element_name; /* ONLY when is_element: from strtab */
24
  guint32 parent;       /* ONLY when is_element: from 0 */
25
  guint32 next;       /* ONLY when is_element: from 0 */
26
  guint32 text;       /* ONLY when is_element: from strtab */
27
  guint32 tail;       /* ONLY when is_element: from strtab */
28
            /*
29
            guint32   attrs[attr_count];
30
            guint32   tokens[token_count];
31
            */
32
} XbSiloNode;
33
34
typedef struct __attribute__((packed)) {
35
  guint32 attr_name;  /* from strtab */
36
  guint32 attr_value; /* from strtab */
37
} XbSiloNodeAttr;
38
39
gchar *
40
xb_silo_node_to_string(const XbSiloNode *self) G_GNUC_NON_NULL(1);
41
42
/* private */
43
static inline gboolean
44
xb_silo_node_has_flag(const XbSiloNode *self, XbSiloNodeFlag flag)
45
0
{
46
0
  return (self->flags & flag) > 0;
47
0
}
Unexecuted instantiation: xb-builder.c:xb_silo_node_has_flag
Unexecuted instantiation: xb-builder-node.c:xb_silo_node_has_flag
Unexecuted instantiation: xb-node.c:xb_silo_node_has_flag
Unexecuted instantiation: xb-node-query.c:xb_silo_node_has_flag
Unexecuted instantiation: xb-query.c:xb_silo_node_has_flag
Unexecuted instantiation: xb-silo.c:xb_silo_node_has_flag
Unexecuted instantiation: xb-silo-export.c:xb_silo_node_has_flag
Unexecuted instantiation: xb-silo-query.c:xb_silo_node_has_flag
Unexecuted instantiation: xb-value-bindings.c:xb_silo_node_has_flag
Unexecuted instantiation: xb-machine.c:xb_silo_node_has_flag
48
49
static inline guint32
50
xb_silo_node_get_size(const XbSiloNode *self)
51
0
{
52
0
  if (xb_silo_node_has_flag(self, XB_SILO_NODE_FLAG_IS_ELEMENT)) {
53
0
    guint8 sz = sizeof(XbSiloNode);
54
0
    sz += self->attr_count * sizeof(XbSiloNodeAttr);
55
0
    sz += self->token_count * sizeof(guint32);
56
0
    return sz;
57
0
  }
58
59
  /* sentinel */
60
0
  return sizeof(guint8);
61
0
}
Unexecuted instantiation: xb-builder.c:xb_silo_node_get_size
Unexecuted instantiation: xb-builder-node.c:xb_silo_node_get_size
Unexecuted instantiation: xb-node.c:xb_silo_node_get_size
Unexecuted instantiation: xb-node-query.c:xb_silo_node_get_size
Unexecuted instantiation: xb-query.c:xb_silo_node_get_size
Unexecuted instantiation: xb-silo.c:xb_silo_node_get_size
Unexecuted instantiation: xb-silo-export.c:xb_silo_node_get_size
Unexecuted instantiation: xb-silo-query.c:xb_silo_node_get_size
Unexecuted instantiation: xb-value-bindings.c:xb_silo_node_get_size
Unexecuted instantiation: xb-machine.c:xb_silo_node_get_size
62
63
/* private */
64
static inline guint8
65
xb_silo_node_get_flags(const XbSiloNode *self)
66
0
{
67
0
  return self->flags;
68
0
}
Unexecuted instantiation: xb-builder.c:xb_silo_node_get_flags
Unexecuted instantiation: xb-builder-node.c:xb_silo_node_get_flags
Unexecuted instantiation: xb-node.c:xb_silo_node_get_flags
Unexecuted instantiation: xb-node-query.c:xb_silo_node_get_flags
Unexecuted instantiation: xb-query.c:xb_silo_node_get_flags
Unexecuted instantiation: xb-silo.c:xb_silo_node_get_flags
Unexecuted instantiation: xb-silo-export.c:xb_silo_node_get_flags
Unexecuted instantiation: xb-silo-query.c:xb_silo_node_get_flags
Unexecuted instantiation: xb-value-bindings.c:xb_silo_node_get_flags
Unexecuted instantiation: xb-machine.c:xb_silo_node_get_flags
69
70
/* private */
71
static inline guint32
72
xb_silo_node_get_text_idx(const XbSiloNode *self)
73
0
{
74
0
  return self->text;
75
0
}
Unexecuted instantiation: xb-builder.c:xb_silo_node_get_text_idx
Unexecuted instantiation: xb-builder-node.c:xb_silo_node_get_text_idx
Unexecuted instantiation: xb-node.c:xb_silo_node_get_text_idx
Unexecuted instantiation: xb-node-query.c:xb_silo_node_get_text_idx
Unexecuted instantiation: xb-query.c:xb_silo_node_get_text_idx
Unexecuted instantiation: xb-silo.c:xb_silo_node_get_text_idx
Unexecuted instantiation: xb-silo-export.c:xb_silo_node_get_text_idx
Unexecuted instantiation: xb-silo-query.c:xb_silo_node_get_text_idx
Unexecuted instantiation: xb-value-bindings.c:xb_silo_node_get_text_idx
Unexecuted instantiation: xb-machine.c:xb_silo_node_get_text_idx
76
77
/* private */
78
static inline guint32
79
xb_silo_node_get_tail_idx(const XbSiloNode *self)
80
0
{
81
0
  return self->tail;
82
0
}
Unexecuted instantiation: xb-builder.c:xb_silo_node_get_tail_idx
Unexecuted instantiation: xb-builder-node.c:xb_silo_node_get_tail_idx
Unexecuted instantiation: xb-node.c:xb_silo_node_get_tail_idx
Unexecuted instantiation: xb-node-query.c:xb_silo_node_get_tail_idx
Unexecuted instantiation: xb-query.c:xb_silo_node_get_tail_idx
Unexecuted instantiation: xb-silo.c:xb_silo_node_get_tail_idx
Unexecuted instantiation: xb-silo-export.c:xb_silo_node_get_tail_idx
Unexecuted instantiation: xb-silo-query.c:xb_silo_node_get_tail_idx
Unexecuted instantiation: xb-value-bindings.c:xb_silo_node_get_tail_idx
Unexecuted instantiation: xb-machine.c:xb_silo_node_get_tail_idx
83
84
/* private */
85
static inline guint8
86
xb_silo_node_get_attr_count(const XbSiloNode *self)
87
0
{
88
0
  return self->attr_count;
89
0
}
Unexecuted instantiation: xb-builder.c:xb_silo_node_get_attr_count
Unexecuted instantiation: xb-builder-node.c:xb_silo_node_get_attr_count
Unexecuted instantiation: xb-node.c:xb_silo_node_get_attr_count
Unexecuted instantiation: xb-node-query.c:xb_silo_node_get_attr_count
Unexecuted instantiation: xb-query.c:xb_silo_node_get_attr_count
Unexecuted instantiation: xb-silo.c:xb_silo_node_get_attr_count
Unexecuted instantiation: xb-silo-export.c:xb_silo_node_get_attr_count
Unexecuted instantiation: xb-silo-query.c:xb_silo_node_get_attr_count
Unexecuted instantiation: xb-value-bindings.c:xb_silo_node_get_attr_count
Unexecuted instantiation: xb-machine.c:xb_silo_node_get_attr_count
90
91
/* private */
92
static inline XbSiloNodeAttr *
93
xb_silo_node_get_attr(const XbSiloNode *self, guint8 idx)
94
0
{
95
0
  guint32 off = sizeof(XbSiloNode);
96
0
  off += sizeof(XbSiloNodeAttr) * idx;
97
0
  return (XbSiloNodeAttr *)(((guint8 *)self) + off);
98
0
}
Unexecuted instantiation: xb-builder.c:xb_silo_node_get_attr
Unexecuted instantiation: xb-builder-node.c:xb_silo_node_get_attr
Unexecuted instantiation: xb-node.c:xb_silo_node_get_attr
Unexecuted instantiation: xb-node-query.c:xb_silo_node_get_attr
Unexecuted instantiation: xb-query.c:xb_silo_node_get_attr
Unexecuted instantiation: xb-silo.c:xb_silo_node_get_attr
Unexecuted instantiation: xb-silo-export.c:xb_silo_node_get_attr
Unexecuted instantiation: xb-silo-query.c:xb_silo_node_get_attr
Unexecuted instantiation: xb-value-bindings.c:xb_silo_node_get_attr
Unexecuted instantiation: xb-machine.c:xb_silo_node_get_attr
99
100
/* private */
101
static inline guint8
102
xb_silo_node_get_token_count(const XbSiloNode *self)
103
0
{
104
0
  return self->token_count;
105
0
}
Unexecuted instantiation: xb-builder.c:xb_silo_node_get_token_count
Unexecuted instantiation: xb-builder-node.c:xb_silo_node_get_token_count
Unexecuted instantiation: xb-node.c:xb_silo_node_get_token_count
Unexecuted instantiation: xb-node-query.c:xb_silo_node_get_token_count
Unexecuted instantiation: xb-query.c:xb_silo_node_get_token_count
Unexecuted instantiation: xb-silo.c:xb_silo_node_get_token_count
Unexecuted instantiation: xb-silo-export.c:xb_silo_node_get_token_count
Unexecuted instantiation: xb-silo-query.c:xb_silo_node_get_token_count
Unexecuted instantiation: xb-value-bindings.c:xb_silo_node_get_token_count
Unexecuted instantiation: xb-machine.c:xb_silo_node_get_token_count
106
107
/* private */
108
static inline guint32
109
xb_silo_node_get_token_idx(const XbSiloNode *self, guint idx)
110
0
{
111
0
  guint32 off = 0;
112
0
  guint32 stridx;
113
114
  /* not valid */
115
0
  if (!xb_silo_node_has_flag(self, XB_SILO_NODE_FLAG_IS_ELEMENT))
116
0
    return XB_SILO_UNSET;
117
0
  if (!xb_silo_node_has_flag(self, XB_SILO_NODE_FLAG_IS_TOKENIZED))
118
0
    return XB_SILO_UNSET;
119
120
  /* calculate offset to token */
121
0
  off += sizeof(XbSiloNode);
122
0
  off += self->attr_count * sizeof(XbSiloNodeAttr);
123
0
  off += idx * sizeof(guint32);
124
0
  memcpy(&stridx, (guint8 *)self + off, sizeof(stridx));
125
0
  return stridx;
126
0
}
Unexecuted instantiation: xb-builder.c:xb_silo_node_get_token_idx
Unexecuted instantiation: xb-builder-node.c:xb_silo_node_get_token_idx
Unexecuted instantiation: xb-node.c:xb_silo_node_get_token_idx
Unexecuted instantiation: xb-node-query.c:xb_silo_node_get_token_idx
Unexecuted instantiation: xb-query.c:xb_silo_node_get_token_idx
Unexecuted instantiation: xb-silo.c:xb_silo_node_get_token_idx
Unexecuted instantiation: xb-silo-export.c:xb_silo_node_get_token_idx
Unexecuted instantiation: xb-silo-query.c:xb_silo_node_get_token_idx
Unexecuted instantiation: xb-value-bindings.c:xb_silo_node_get_token_idx
Unexecuted instantiation: xb-machine.c:xb_silo_node_get_token_idx