Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,14 @@ On a Debian/Ubuntu system::
Compatibility
-------------

The current version requires at least C `libyang 2.25`__.
The current version requires at least C `libyang 4.0`__ (devel branch).

For C `libyang 3.x`__, use an earlier version of these bindings.

The last version of the bindings that works with C `libyang 1.x`__ is v1.7.0__.

__ https://github.com/CESNET/libyang/commit/d2f1608b348f
__ https://github.com/CESNET/libyang/tree/devel
__ https://github.com/CESNET/libyang/tree/master
__ https://github.com/CESNET/libyang/tree/libyang1
__ https://pypi.org/project/libyang/1.7.0/

Expand Down
1 change: 1 addition & 0 deletions _codeql_detected_source_root
50 changes: 26 additions & 24 deletions cffi/cdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ typedef enum {
LY_EPLUGIN = 128
} LY_ERR;

LY_ERR ly_ctx_new(const char *, uint16_t, struct ly_ctx **);
LY_ERR ly_ctx_new(const char *, uint32_t, struct ly_ctx **);
void ly_ctx_destroy(struct ly_ctx *);
int ly_ctx_set_searchdir(struct ly_ctx *, const char *);

Expand Down Expand Up @@ -350,7 +350,7 @@ LY_ERR ly_out_new_file(FILE *, struct ly_out **);
LY_ERR ly_out_new_fd(int, struct ly_out **);

LY_ERR lyd_parse_data(const struct ly_ctx *, struct lyd_node *, struct ly_in *, LYD_FORMAT, uint32_t, uint32_t, struct lyd_node **);
LY_ERR lyd_parse_op(const struct ly_ctx *, struct lyd_node *, struct ly_in *, LYD_FORMAT, enum lyd_type, struct lyd_node **, struct lyd_node **);
LY_ERR lyd_parse_op(const struct ly_ctx *, struct lyd_node *, struct ly_in *, LYD_FORMAT, enum lyd_type, uint32_t, struct lyd_node **, struct lyd_node **);

typedef enum {
LYS_OUT_UNKNOWN,
Expand Down Expand Up @@ -392,7 +392,6 @@ struct lys_module {
struct lys_module **deviated_by;
ly_bool implemented;
ly_bool to_compile;
uint8_t latest_revision;
...;
};

Expand Down Expand Up @@ -466,12 +465,11 @@ struct lysp_ext_instance {
const char *argument;
LY_VALUE_FORMAT format;
void *prefix_data;
struct lysp_ext *def;
uintptr_t plugin_ref;
void *parent;
enum ly_stmt parent_stmt;
uint64_t parent_stmt_index;
uint16_t flags;
const struct lyplg_ext_record *record;
struct lysp_ext_substmt *substmts;
void *parsed;
struct lysp_stmt *child;
Expand Down Expand Up @@ -609,6 +607,13 @@ struct lysp_node_container {
...;
};

struct lysc_prefix;

struct lysc_value {
const char *str;
struct lysc_prefix *prefixes;
};

struct lysc_node_leaf {
union {
struct lysc_node node;
Expand All @@ -622,7 +627,7 @@ struct lysc_node_leaf {
struct lysc_when **when;
struct lysc_type *type;
const char *units;
struct lyd_value *dflt;
struct lysc_value dflt;
...;
};

Expand Down Expand Up @@ -652,7 +657,7 @@ struct lysc_node_leaflist {
struct lysc_when **when;
struct lysc_type *type;
const char *units;
struct lyd_value **dflts;
struct lysc_value *dflts;
uint32_t min;
uint32_t max;
...;
Expand Down Expand Up @@ -782,7 +787,7 @@ struct lysp_node_augment {
struct lysc_type {
const char *name;
struct lysc_ext_instance *exts;
struct lyplg_type *plugin;
uintptr_t plugin_ref;
LY_DATA_TYPE basetype;
uint32_t refcount;
};
Expand Down Expand Up @@ -858,7 +863,7 @@ struct lysc_ext {
const char *name;
const char *argname;
struct lysc_ext_instance *exts;
struct lyplg_ext *plugin;
uintptr_t plugin_ref;
struct lys_module *module;
uint16_t flags;
};
Expand Down Expand Up @@ -981,7 +986,6 @@ typedef struct pcre2_real_code pcre2_code;

struct lysc_pattern {
const char *expr;
pcre2_code *code;
const char *dsc;
const char *ref;
const char *emsg;
Expand Down Expand Up @@ -1016,7 +1020,7 @@ struct lysc_ident {
struct lysc_type_num {
const char *name;
struct lysc_ext_instance *exts;
struct lyplg_type *plugin;
uintptr_t plugin_ref;
LY_DATA_TYPE basetype;
uint32_t refcount;
struct lysc_range *range;
Expand All @@ -1025,7 +1029,7 @@ struct lysc_type_num {
struct lysc_type_dec {
const char *name;
struct lysc_ext_instance *exts;
struct lyplg_type *plugin;
uintptr_t plugin_ref;
LY_DATA_TYPE basetype;
uint32_t refcount;
uint8_t fraction_digits;
Expand All @@ -1035,7 +1039,7 @@ struct lysc_type_dec {
struct lysc_type_str {
const char *name;
struct lysc_ext_instance *exts;
struct lyplg_type *plugin;
uintptr_t plugin_ref;
LY_DATA_TYPE basetype;
uint32_t refcount;
struct lysc_range *length;
Expand All @@ -1057,7 +1061,7 @@ struct lysc_type_bitenum_item {
struct lysc_type_enum {
const char *name;
struct lysc_ext_instance *exts;
struct lyplg_type *plugin;
uintptr_t plugin_ref;
LY_DATA_TYPE basetype;
uint32_t refcount;
struct lysc_type_bitenum_item *enums;
Expand All @@ -1066,7 +1070,7 @@ struct lysc_type_enum {
struct lysc_type_bits {
const char *name;
struct lysc_ext_instance *exts;
struct lyplg_type *plugin;
uintptr_t plugin_ref;
LY_DATA_TYPE basetype;
uint32_t refcount;
struct lysc_type_bitenum_item *bits;
Expand All @@ -1075,7 +1079,7 @@ struct lysc_type_bits {
struct lysc_type_leafref {
const char *name;
struct lysc_ext_instance *exts;
struct lyplg_type *plugin;
uintptr_t plugin_ref;
LY_DATA_TYPE basetype;
uint32_t refcount;
struct lyxp_expr *path;
Expand All @@ -1087,7 +1091,7 @@ struct lysc_type_leafref {
struct lysc_type_identityref {
const char *name;
struct lysc_ext_instance *exts;
struct lyplg_type *plugin;
uintptr_t plugin_ref;
LY_DATA_TYPE basetype;
uint32_t refcount;
struct lysc_ident **bases;
Expand All @@ -1096,7 +1100,7 @@ struct lysc_type_identityref {
struct lysc_type_instanceid {
const char *name;
struct lysc_ext_instance *exts;
struct lyplg_type *plugin;
uintptr_t plugin_ref;
LY_DATA_TYPE basetype;
uint32_t refcount;
uint8_t require_instance;
Expand All @@ -1105,7 +1109,7 @@ struct lysc_type_instanceid {
struct lysc_type_union {
const char *name;
struct lysc_ext_instance *exts;
struct lyplg_type *plugin;
uintptr_t plugin_ref;
LY_DATA_TYPE basetype;
uint32_t refcount;
struct lysc_type **types;
Expand All @@ -1114,7 +1118,7 @@ struct lysc_type_union {
struct lysc_type_bin {
const char *name;
struct lysc_ext_instance *exts;
struct lyplg_type *plugin;
uintptr_t plugin_ref;
LY_DATA_TYPE basetype;
uint32_t refcount;
struct lysc_range *length;
Expand Down Expand Up @@ -1158,16 +1162,14 @@ typedef enum {
LYD_ANYDATA_DATATREE,
LYD_ANYDATA_STRING,
LYD_ANYDATA_XML,
LYD_ANYDATA_JSON,
LYD_ANYDATA_LYB
LYD_ANYDATA_JSON
} LYD_ANYDATA_VALUETYPE;

union lyd_any_value {
struct lyd_node *tree;
const char *str;
const char *xml;
const char *json;
char *mem;
};

struct lyd_node_any {
Expand Down Expand Up @@ -1333,7 +1335,7 @@ struct ly_ctx *lyplg_ext_compile_get_ctx(const struct lysc_ctx *);
void lyplg_ext_parse_log(const struct lysp_ctx *, const struct lysp_ext_instance *, LY_LOG_LEVEL, LY_ERR, const char *, ...);
void lyplg_ext_compile_log(const struct lysc_ctx *, const struct lysc_ext_instance *, LY_LOG_LEVEL, LY_ERR, const char *, ...);
LY_ERR lyplg_ext_parse_extension_instance(struct lysp_ctx *, struct lysp_ext_instance *);
LY_ERR lyplg_ext_compile_extension_instance(struct lysc_ctx *, const struct lysp_ext_instance *, struct lysc_ext_instance *);
LY_ERR lyplg_ext_compile_extension_instance(struct lysc_ctx *, const struct lysp_ext_instance *, struct lysc_ext_instance *, struct lysc_node *);
void lyplg_ext_pfree_instance_substatements(const struct ly_ctx *ctx, struct lysp_ext_substmt *substmts);
void lyplg_ext_cfree_instance_substatements(const struct ly_ctx *ctx, struct lysc_ext_substmt *substmts);
typedef LY_ERR (*lyplg_ext_parse_clb)(struct lysp_ctx *, struct lysp_ext_instance *);
Expand Down
4 changes: 2 additions & 2 deletions cffi/source.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
#include <libyang/libyang.h>
#include <libyang/version.h>

#if LY_VERSION_MAJOR * 10000 + LY_VERSION_MINOR * 100 + LY_VERSION_MICRO < 30801
#error "This version of libyang bindings only works with libyang soversion 3.8.1+"
#if LY_VERSION_MAJOR * 10000 + LY_VERSION_MINOR * 100 + LY_VERSION_MICRO < 40000
#error "This version of libyang bindings only works with libyang soversion 4.0.0+"
#endif
8 changes: 4 additions & 4 deletions libyang/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, message: str, ret: int, log_level: int) -> None:

@ffi.def_extern(name="lypy_lyplg_ext_parse_clb")
def libyang_c_lyplg_ext_parse_clb(pctx, pext):
plugin = extensions_plugins[pext.record.plugin]
plugin = extensions_plugins[pext.plugin_ref]
module_cdata = lib.lyplg_ext_parse_get_cur_pmod(pctx).mod
context = Context(cdata=module_cdata.ctx)
module = Module(context, module_cdata)
Expand All @@ -46,7 +46,7 @@ def libyang_c_lyplg_ext_parse_clb(pctx, pext):

@ffi.def_extern(name="lypy_lyplg_ext_compile_clb")
def libyang_c_lyplg_ext_compile_clb(cctx, pext, cext):
plugin = extensions_plugins[pext.record.plugin]
plugin = extensions_plugins[pext.plugin_ref]
context = Context(cdata=lib.lyplg_ext_compile_get_ctx(cctx))
module = Module(context, cext.module)
parsed_ext = ExtensionParsed(context, pext, module)
Expand All @@ -67,15 +67,15 @@ def libyang_c_lyplg_ext_compile_clb(cctx, pext, cext):

@ffi.def_extern(name="lypy_lyplg_ext_parse_free_clb")
def libyang_c_lyplg_ext_parse_free_clb(ctx, pext):
plugin = extensions_plugins[pext.record.plugin]
plugin = extensions_plugins[pext.plugin_ref]
context = Context(cdata=ctx)
parsed_ext = ExtensionParsed(context, pext, None)
plugin.parse_free_clb(parsed_ext)


@ffi.def_extern(name="lypy_lyplg_ext_compile_free_clb")
def libyang_c_lyplg_ext_compile_free_clb(ctx, cext):
plugin = extensions_plugins[getattr(cext, "def").plugin]
plugin = extensions_plugins[getattr(cext, "def").plugin_ref]
context = Context(cdata=ctx)
compiled_ext = ExtensionCompiled(context, cext)
plugin.compile_free_clb(compiled_ext)
Expand Down
Loading