Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding additional cdefs #102

Closed
wants to merge 2 commits into from
Closed
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
127 changes: 127 additions & 0 deletions cffi/cdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,25 @@ typedef enum {

char* lysc_path(const struct lysc_node *, LYSC_PATH_TYPE, char *, size_t);

struct lysp_when {
const char *cond;
...;
};

struct lysp_refine {
const char *nodeid;
const char *dsc;
const char *ref;
struct lysp_qname *iffeatures;
struct lysp_restr *musts;
const char *presence;
struct lysp_qname *dflts;
uint32_t min;
uint32_t max;
struct lysp_ext_instance *exts;
uint16_t flags;
};

struct lysp_node_container {
struct lysp_restr *musts;
struct lysp_when *when;
Expand Down Expand Up @@ -615,6 +634,101 @@ struct lysp_node_list {
...;
};

struct lysp_node_choice {
struct lysp_node *child;
struct lysp_when *when;
struct lysp_qname dflt;
...;
};

struct lysp_node_case {
struct lysp_node *child;
struct lysp_when *when;
...;
};

struct lysp_node_anydata {
struct lysp_restr *musts;
struct lysp_when *when;
...;
};

struct lysp_node_uses {
struct lysp_refine *refines;
struct lysp_node_augment *augments;
struct lysp_when *when;
...;
};

struct lysp_node_action_inout {
struct lysp_restr *musts;
struct lysp_tpdf *typedefs;
struct lysp_node_grp *groupings;
struct lysp_node *child;
...;
};

struct lysp_node_action {
union {
struct lysp_node node;
struct {
struct lysp_node_action *next;
...;
};
};
struct lysp_tpdf *typedefs;
struct lysp_node_grp *groupings;
struct lysp_node_action_inout input;
struct lysp_node_action_inout output;
...;
};

struct lysp_node_notif {
union {
struct lysp_node node;
struct {
struct lysp_node_notif *next;
...;
};
};
struct lysp_restr *musts;
struct lysp_tpdf *typedefs;
struct lysp_node_grp *groupings;
struct lysp_node *child;
...;
};

struct lysp_node_grp {
union {
struct lysp_node node;
struct {
struct lysp_node_grp *next;
...;
};
};
struct lysp_tpdf *typedefs;
struct lysp_node_grp *groupings;
struct lysp_node *child;
struct lysp_node_action *actions;
struct lysp_node_notif *notifs;
...;
};

struct lysp_node_augment {
union {
struct lysp_node node;
struct {
struct lysp_node_augment *next;
...;
};
};
struct lysp_node *child;
struct lysp_when *when;
struct lysp_node_action *actions;
struct lysp_node_notif *notifs;
...;
};

struct lysc_type {
const char *name;
struct lysc_ext_instance *exts;
Expand All @@ -623,6 +737,16 @@ struct lysc_type {
uint32_t refcount;
};

struct lysp_type_enum {
const char *name;
const char *dsc;
const char *ref;
int64_t value;
struct lysp_qname *iffeatures;
struct lysp_ext_instance *exts;
uint16_t flags;
};

struct lysp_type {
const char *name;
struct lysp_restr *range;
Expand Down Expand Up @@ -947,6 +1071,9 @@ LY_ERR lys_parse(struct ly_ctx *, struct ly_in *, LYS_INFORMAT, const char **, s
LY_ERR ly_ctx_new_ylpath(const char *, const char *, LYD_FORMAT, int, struct ly_ctx **);
LY_ERR ly_ctx_get_yanglib_data(const struct ly_ctx *, struct lyd_node **, const char *, ...);

LY_ERR lydict_insert(const struct ly_ctx *, const char *, size_t, const char **);
LY_ERR lydict_remove(const struct ly_ctx *, const char *);

struct lyd_meta {
struct lyd_node *parent;
struct lyd_meta *next;
Expand Down
35 changes: 35 additions & 0 deletions libyang/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,26 @@
IfOrFeatures,
Module,
Must,
PAction,
PActionInOut,
PAnydata,
Pattern,
PAugment,
PCase,
PChoice,
PContainer,
PEnum,
PGrouping,
PLeaf,
PLeafList,
PList,
PNode,
PNotif,
PRefine,
PType,
PUses,
Revision,
SAnydata,
SCase,
SChoice,
SContainer,
Expand Down Expand Up @@ -150,6 +168,23 @@
"NodeTypeRemoved",
"OrderedByUserAdded",
"OrderedByUserRemoved",
"PAction",
"PActionInOut",
"PAnydata",
"PAugment",
"PCase",
"PChoice",
"PContainer",
"PEnum",
"PGrouping",
"PLeaf",
"PLeafList",
"PList",
"PNode",
"PNotif",
"PRefine",
"PType",
"PUses",
"Pattern",
"PatternAdded",
"PatternRemoved",
Expand Down
10 changes: 10 additions & 0 deletions libyang/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,3 +465,13 @@ def __iter__(self) -> Iterator[Module]:
while mod:
yield Module(self, mod)
mod = lib.ly_ctx_get_module_iter(self.cdata, idx)

def add_to_dict(self, orig_str: str) -> Any:
cstr = ffi.new("char **")
ret = lib.lydict_insert(self.cdata, str2c(orig_str), 0, cstr)
if ret != lib.LY_SUCCESS:
raise LibyangError("Unable to insert string into context dictionary")
return cstr[0]

def remove_from_dict(self, orig_str: str) -> None:
lib.lydict_remove(self.cdata, str2c(orig_str))
Loading
Loading