Skip to content

Commit 13b20f9

Browse files
committed
Merge branch 'devel'
2 parents 85d09f3 + 8e690c2 commit 13b20f9

File tree

136 files changed

+22072
-2968
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+22072
-2968
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ before_install:
3535
- cmake .. && make -j2 && sudo make install
3636
- cd ../..
3737
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew update; fi
38-
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get update -qq; sudo apt-get install -y valgrind osc; sudo dpkg -i ./swig/swig3.0_3.0.8-0ubuntu3_amd64.deb; fi
38+
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get update -qq; sudo apt-get install -y valgrind osc; sudo dpkg -i ./swig/swig3.0_3.0.12-1.2_amd64.deb; sudo dpkg -i ./swig/swig_3.0.12-1_amd64.deb; fi
3939
- if [ "$TRAVIS_OS_NAME" = "linux" -a "$CC" = "gcc-7" ]; then pip install --user codecov; export CFLAGS="-coverage"; fi
4040

4141
script:

CMakeLists.txt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ set(CMAKE_MACOSX_RPATH TRUE)
1111

1212
# set version
1313
set(LIBYANG_MAJOR_VERSION 0)
14-
set(LIBYANG_MINOR_VERSION 15)
15-
set(LIBYANG_MICRO_VERSION 166)
14+
set(LIBYANG_MINOR_VERSION 16)
15+
set(LIBYANG_MICRO_VERSION 41)
1616
set(LIBYANG_VERSION ${LIBYANG_MAJOR_VERSION}.${LIBYANG_MINOR_VERSION}.${LIBYANG_MICRO_VERSION})
1717
set(LIBYANG_SOVERSION ${LIBYANG_MAJOR_VERSION}.${LIBYANG_MINOR_VERSION})
1818

@@ -88,6 +88,7 @@ set(GEN_CPP_BINDINGS 1 CACHE BOOL "Enable C++ bindings.")
8888
set(GEN_PYTHON_BINDINGS 1 CACHE BOOL "Enable Python bindings.")
8989
set(GEN_PYTHON_VERSION "3" CACHE STRING "Python version")
9090
set(GEN_JAVASCRIPT_BINDINGS 0 CACHE BOOL "Enable JavaScript bindings.")
91+
set(GEN_JAVA_BINDINGS 1 CACHE BOOL "Enable Java bindings.")
9192

9293
find_package(FLEX)
9394
find_package(BISON)
@@ -195,6 +196,7 @@ set(libsrc
195196
src/parser_yin.c
196197
src/parser_xml.c
197198
src/parser_json.c
199+
src/parser_lyb.c
198200
src/parser_yang_bis.c
199201
src/parser_yang_lex.c
200202
src/parser_yang.c
@@ -205,10 +207,12 @@ set(libsrc
205207
src/xpath.c
206208
src/printer_yang.c
207209
src/printer_yin.c
210+
src/printer_json_schema.c
208211
src/printer_xml.c
209212
src/printer_tree.c
210213
src/printer_info.c
211214
src/printer_json.c
215+
src/printer_lyb.c
212216
src/yang_types.c)
213217

214218
set(lintsrc
@@ -300,7 +304,13 @@ endif()
300304
# generate doxygen documentation for libyang API
301305
find_package(Doxygen)
302306
if(DOXYGEN_FOUND)
303-
set(DOXYGEN_SKIP_DOT TRUE)
307+
find_program(DOT_PATH dot PATH_SUFFIXES graphviz2.38/bin graphviz/bin)
308+
if(DOT_PATH)
309+
set(HAVE_DOT "YES")
310+
else()
311+
set(HAVE_DOT "NO")
312+
message(AUTHOR_WARNING "Doxygen: to generate UML diagrams please install graphviz")
313+
endif()
304314
add_custom_target(doc
305315
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile
306316
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

CMakeModules/FindCMocka.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ find_path(CMOCKA_INCLUDE_DIR
3030

3131
find_library(CMOCKA_LIBRARY
3232
NAMES
33-
cmocka
33+
cmocka cmocka_shared
3434
PATHS
3535
${CMOCKA_ROOT_DIR}/include
3636
)

Doxyfile.in

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,15 @@ INPUT = @CMAKE_BINARY_DIR@/src/libyang.h \
787787
./src/extensions.h \
788788
./src/user_types.h \
789789
./src/xml.h \
790-
./src/dict.h
790+
./src/dict.h \
791+
./swig/cpp/src/Libyang.hpp \
792+
./swig/cpp/src/Tree_Data.hpp \
793+
./swig/cpp/src/Tree_Schema.hpp \
794+
./swig/cpp/src/Xml.hpp \
795+
./swig/cpp/src/Libyang.cpp \
796+
./swig/cpp/src/Tree_Data.cpp \
797+
./swig/cpp/src/Tree_Schema.cpp \
798+
./swig/cpp/src/Xml.cpp
791799

792800
# This tag can be used to specify the character encoding of the source files
793801
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
@@ -2035,7 +2043,7 @@ ENABLE_PREPROCESSING = YES
20352043
# The default value is: NO.
20362044
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
20372045

2038-
MACRO_EXPANSION = NO
2046+
MACRO_EXPANSION = YES
20392047

20402048
# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then
20412049
# the macro expansion is limited to the macros specified with the PREDEFINED and
@@ -2159,7 +2167,7 @@ PERL_PATH = /usr/bin/perl
21592167
# powerful graphs.
21602168
# The default value is: YES.
21612169

2162-
CLASS_DIAGRAMS = YES
2170+
CLASS_DIAGRAMS = NO
21632171

21642172
# You can define message sequence charts within doxygen comments using the \msc
21652173
# command. Doxygen will then run the mscgen tool (see:
@@ -2190,7 +2198,7 @@ HIDE_UNDOC_RELATIONS = YES
21902198
# set to NO
21912199
# The default value is: NO.
21922200

2193-
HAVE_DOT = NO
2201+
HAVE_DOT = @HAVE_DOT@
21942202

21952203
# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed
21962204
# to run in parallel. When set to 0 doxygen will base this on the number of
@@ -2241,7 +2249,7 @@ CLASS_GRAPH = YES
22412249
# The default value is: YES.
22422250
# This tag requires that the tag HAVE_DOT is set to YES.
22432251

2244-
COLLABORATION_GRAPH = YES
2252+
COLLABORATION_GRAPH = NO
22452253

22462254
# If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for
22472255
# groups, showing the direct groups dependencies.
@@ -2256,7 +2264,7 @@ GROUP_GRAPHS = YES
22562264
# The default value is: NO.
22572265
# This tag requires that the tag HAVE_DOT is set to YES.
22582266

2259-
UML_LOOK = NO
2267+
UML_LOOK = YES
22602268

22612269
# If the UML_LOOK tag is enabled, the fields and methods are shown inside the
22622270
# class node. If there are many fields or methods and many nodes the graph may
@@ -2269,15 +2277,15 @@ UML_LOOK = NO
22692277
# Minimum value: 0, maximum value: 100, default value: 10.
22702278
# This tag requires that the tag HAVE_DOT is set to YES.
22712279

2272-
UML_LIMIT_NUM_FIELDS = 10
2280+
UML_LIMIT_NUM_FIELDS = 50
22732281

22742282
# If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and
22752283
# collaboration graphs will show the relations between templates and their
22762284
# instances.
22772285
# The default value is: NO.
22782286
# This tag requires that the tag HAVE_DOT is set to YES.
22792287

2280-
TEMPLATE_RELATIONS = NO
2288+
TEMPLATE_RELATIONS = YES
22812289

22822290
# If the INCLUDE_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are set to
22832291
# YES then doxygen will generate a graph for each documented file showing the
@@ -2350,7 +2358,7 @@ DIRECTORY_GRAPH = YES
23502358
# The default value is: png.
23512359
# This tag requires that the tag HAVE_DOT is set to YES.
23522360

2353-
DOT_IMAGE_FORMAT = png
2361+
DOT_IMAGE_FORMAT = svg
23542362

23552363
# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to
23562364
# enable generation of interactive SVG images that allow zooming and panning.
@@ -2362,7 +2370,7 @@ DOT_IMAGE_FORMAT = png
23622370
# The default value is: NO.
23632371
# This tag requires that the tag HAVE_DOT is set to YES.
23642372

2365-
INTERACTIVE_SVG = NO
2373+
INTERACTIVE_SVG = YES
23662374

23672375
# The DOT_PATH tag can be used to specify the path where the dot tool can be
23682376
# found. If left blank, it is assumed the dot tool can be found in the path.
@@ -2412,7 +2420,7 @@ PLANTUML_INCLUDE_PATH =
24122420
# Minimum value: 0, maximum value: 10000, default value: 50.
24132421
# This tag requires that the tag HAVE_DOT is set to YES.
24142422

2415-
DOT_GRAPH_MAX_NODES = 50
2423+
DOT_GRAPH_MAX_NODES = 100
24162424

24172425
# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the graphs
24182426
# generated by dot. A depth value of 3 means that only nodes reachable from the
@@ -2436,7 +2444,7 @@ MAX_DOT_GRAPH_DEPTH = 0
24362444
# The default value is: NO.
24372445
# This tag requires that the tag HAVE_DOT is set to YES.
24382446

2439-
DOT_TRANSPARENT = NO
2447+
DOT_TRANSPARENT = YES
24402448

24412449
# Set the DOT_MULTI_TARGETS tag to YES to allow dot to generate multiple output
24422450
# files in one run (i.e. multiple -o and -T options on the command line). This

KNOWNISSUES.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Known Issues
22

3+
## Printer crash
4+
5+
There is a bug in Clang 3.4.2 that causes wrong data tree traversal, which results in a crash.
6+
It can occur during any traversal but it was observed in XML printer while printing default
7+
values. The solution is to compile using either GCC or newer version of Clang. Starting
8+
from which version it works we do not exactly know. Clang 5.0.0 works fine.
9+
310
## XPath Expressions
411

512
### Axes

src/common.c

Lines changed: 73 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -737,9 +737,9 @@ transform_iffeat_schema2json(const struct lys_module *module, const char *expr)
737737
assert(out_size == out_used);
738738
return lydict_insert_zc(ctx, out);
739739
}
740-
id = strpbrk_backwards(col - 1, "/ [\'\"\f\n\r\t\v", (col - in) - 1);
741-
if ((id[0] == '/') || (id[0] == ' ') || (id[0] == '[') || (id[0] == '\'') || (id[0] == '\"') || (id[0] == '\f') ||
742-
(id[0] == '\n') || (id[0] == '\r') || (id[0] == '\t') || (id[0] == '\v')) {
740+
id = strpbrk_backwards(col - 1, " \f\n\r\t\v(", (col - in) - 1);
741+
if ((id[0] == ' ') || (id[0] == '\f') || (id[0] == '\n') || (id[0] == '\r') ||
742+
(id[0] == '\t') || (id[0] == '\v') || (id[0] == '(')) {
743743
++id;
744744
}
745745
id_len = col - id;
@@ -1286,27 +1286,24 @@ ly_new_node_validity(const struct lys_node *schema)
12861286
int validity;
12871287

12881288
validity = LYD_VAL_OK;
1289-
switch (schema->nodetype) {
1290-
case LYS_LEAF:
1291-
case LYS_LEAFLIST:
1289+
1290+
if (schema->nodetype & (LYS_LEAF | LYS_LEAFLIST)) {
12921291
if (((struct lys_node_leaf *)schema)->type.base == LY_TYPE_LEAFREF) {
1292+
/* leafref target validation */
12931293
validity |= LYD_VAL_LEAFREF;
12941294
}
1295-
validity |= LYD_VAL_MAND;
1296-
break;
1297-
case LYS_LIST:
1295+
}
1296+
if (schema->nodetype & (LYS_LEAFLIST | LYS_LIST)) {
1297+
/* duplicit instance check */
1298+
validity |= LYD_VAL_DUP;
1299+
}
1300+
if ((schema->nodetype == LYS_LIST) && ((struct lys_node_list *)schema)->unique_size) {
1301+
/* unique check */
12981302
validity |= LYD_VAL_UNIQUE;
1299-
/* fallthrough */
1300-
case LYS_CONTAINER:
1301-
case LYS_NOTIF:
1302-
case LYS_RPC:
1303-
case LYS_ACTION:
1304-
case LYS_ANYXML:
1305-
case LYS_ANYDATA:
1303+
}
1304+
if (schema->nodetype & (LYS_LEAF | LYS_LEAFLIST | LYS_LIST | LYS_CONTAINER | LYS_NOTIF | LYS_RPC | LYS_ACTION | LYS_ANYDATA)) {
1305+
/* mandatory children check */
13061306
validity |= LYD_VAL_MAND;
1307-
break;
1308-
default:
1309-
break;
13101307
}
13111308

13121309
return validity;
@@ -1369,3 +1366,60 @@ dec64cmp(int64_t num1, uint8_t dig1, int64_t num2, uint8_t dig2)
13691366
}
13701367
return (num1 > num2 ? 1 : -1);
13711368
}
1369+
1370+
LYB_HASH
1371+
lyb_hash(struct lys_node *sibling, uint8_t collision_id)
1372+
{
1373+
struct lys_module *mod;
1374+
uint32_t full_hash;
1375+
LYB_HASH hash;
1376+
1377+
#ifdef LY_ENABLED_CACHE
1378+
if ((collision_id < LYS_NODE_HASH_COUNT) && sibling->hash[collision_id]) {
1379+
return sibling->hash[collision_id];
1380+
}
1381+
#endif
1382+
1383+
mod = lys_node_module(sibling);
1384+
1385+
full_hash = dict_hash_multi(0, mod->name, strlen(mod->name));
1386+
full_hash = dict_hash_multi(full_hash, sibling->name, strlen(sibling->name));
1387+
if (collision_id) {
1388+
if (collision_id > strlen(mod->name)) {
1389+
/* wow */
1390+
LOGINT(sibling->module->ctx);
1391+
return 0;
1392+
}
1393+
full_hash = dict_hash_multi(full_hash, mod->name, collision_id);
1394+
}
1395+
full_hash = dict_hash_multi(full_hash, NULL, 0);
1396+
1397+
/* use the shortened hash */
1398+
hash = full_hash & (LYB_HASH_MASK >> collision_id);
1399+
/* add colision identificator */
1400+
hash |= LYB_HASH_COLLISION_ID >> collision_id;
1401+
1402+
/* save this hash */
1403+
#ifdef LY_ENABLED_CACHE
1404+
if (collision_id < LYS_NODE_HASH_COUNT) {
1405+
sibling->hash[collision_id] = hash;
1406+
}
1407+
#endif
1408+
1409+
return hash;
1410+
}
1411+
1412+
int
1413+
lyb_has_schema_model(struct lys_node *sibling, const struct lys_module **models, int mod_count)
1414+
{
1415+
int i;
1416+
const struct lys_module *mod = lys_node_module(sibling);
1417+
1418+
for (i = 0; i < mod_count; ++i) {
1419+
if (mod == models[i]) {
1420+
return 1;
1421+
}
1422+
}
1423+
1424+
return 0;
1425+
}

src/common.h.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,10 @@ void ly_vlog(const struct ly_ctx *ctx, LY_ECODE code, enum LY_VLOG_ELEM elem_typ
249249
* @param[in] elem Element to print.
250250
* @param[in,out] path Resulting path printed.
251251
* @param[in] schema_all_prefixes Whether to include prefixes for all the nodes (only for schema paths).
252+
* @param[in] data_no_predicates Whether to skip generating predicates for all the nodes (only for data paths).
252253
* @return 0 on success, -1 on error.
253254
*/
254-
int ly_vlog_build_path(enum LY_VLOG_ELEM elem_type, const void *elem, char **path, int schema_all_prefixes);
255+
int ly_vlog_build_path(enum LY_VLOG_ELEM elem_type, const void *elem, char **path, int schema_all_prefixes, int data_no_predicates);
255256

256257
/**
257258
* @brief Get module from a context based on its name and revision.

0 commit comments

Comments
 (0)