From 21e389bca01794aeca1e79c92a86fc060549b835 Mon Sep 17 00:00:00 2001 From: Jonathan Beck Date: Wed, 15 Apr 2009 22:35:56 +0200 Subject: Add special accessor for structured types in API. --- swig/plist.i | 54 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 10 deletions(-) (limited to 'swig/plist.i') diff --git a/swig/plist.i b/swig/plist.i index 41ff7cc..a56592e 100644 --- a/swig/plist.i +++ b/swig/plist.i @@ -180,21 +180,55 @@ typedef struct { } PListNode* find_node_by_key(char *s) { - PListNode* plist = allocate_wrapper(); - if (plist) { - plist->node = plist_find_node_by_key($self->node, s); - plist->should_keep_plist = 1; + plist_t node = plist_find_node_by_key($self->node, s); + if (node) { + PListNode* plist = allocate_wrapper(); + if (plist) { + plist->node = node; + plist->should_keep_plist = 1; + } + return plist; } - return plist; + return NULL; } PListNode* find_node_by_string(char* s) { - PListNode* plist = allocate_wrapper(); - if (plist) { - plist->node = plist_find_node_by_string($self->node, s); - plist->should_keep_plist = 1; + plist_t node = plist_find_node_by_string($self->node, s); + if (node) { + PListNode* plist = allocate_wrapper(); + if (plist) { + plist->node = node; + plist->should_keep_plist = 1; + } + return plist; + } + return NULL; + } + + PListNode* get_array_nth_el(unsigned int n) { + plist_t node = plist_get_array_nth_el($self->node, n); + if (node) { + PListNode* plist = allocate_wrapper(); + if (plist) { + plist->node = node; + plist->should_keep_plist = 1; + } + return plist; } - return plist; + return NULL; + } + + PListNode* get_dict_el_from_key(char *key) { + plist_t node = plist_get_dict_el_from_key($self->node, key); + if (node) { + PListNode* plist = allocate_wrapper(); + if (plist) { + plist->node = node; + plist->should_keep_plist = 1; + } + return plist; + } + return NULL; } char* to_xml () { -- cgit v1.1-32-gdbae