Skip to content

Commit

Permalink
schema: adds PNode and its exact variants
Browse files Browse the repository at this point in the history
This patch introduces PNode alternative to SNode, which allows to
travers parsed module tree including groupings, uses and other special
nodes

Signed-off-by: Stefan Gula <[email protected]>
  • Loading branch information
steweg committed Apr 12, 2024
1 parent 25be575 commit 7c451a5
Show file tree
Hide file tree
Showing 6 changed files with 1,168 additions and 13 deletions.
96 changes: 96 additions & 0 deletions cffi/cdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,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 @@ -636,6 +655,73 @@ 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 {
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 {
struct lysp_restr *musts;
struct lysp_tpdf *typedefs;
struct lysp_node_grp *groupings;
struct lysp_node *child;
...;
};

struct lysp_node_grp {
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 {
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 @@ -644,6 +730,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
35 changes: 35 additions & 0 deletions libyang/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,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 @@ -156,6 +174,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
Loading

0 comments on commit 7c451a5

Please sign in to comment.