--- a/lm_message_node.c Sat Feb 21 12:43:51 2009 +0200
+++ b/lm_message_node.c Sat Feb 21 16:10:28 2009 +0200
@@ -191,6 +191,27 @@
return 1;
}
+/// message_node:path
+/// Returns node with specified path to it.
+/// If any element in a path cannot be found, it returns nil.
+/// A: string (node name), ...
+/// R: lm message node object or nil
+int llm_message_node_path (lua_State *L)
+{
+ LmMessageNode *node = luaL_checkLmMessageNode (L, 1);
+ int i = 1;
+ while (i++ < lua_gettop (L)) {
+ node = lm_message_node_get_child (node, luaL_checkstring (L, i));
+ if (node == NULL) {
+ lua_pushnil (L);
+ return 1;
+ }
+ }
+ llm_message_node_bless (L, node);
+ // XXX lm_message_node_unref (child);
+ return 1;
+}
+
/// message_node:pointer
/// Returns pointer to underlying C structure.
/// R: lightuserdata
@@ -226,6 +247,7 @@
{ "attribute", llm_message_node_attribute },
{ "raw", llm_message_node_raw },
{ "xml", llm_message_node_xml },
+ { "path", llm_message_node_path },
{ "pointer", llm_message_node_pointer },
{ "__gc", llm_message_node_gc },
{ NULL, NULL },