Mercurial > prosody-hg
comparison util/xmlrpc.lua @ 888:1059230969c3
util/xmlrpc: Added <nil/> extension to RPC functions (allowing nil parameters and return values)
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Sun, 08 Mar 2009 01:06:37 +0500 |
| parents | a554bf5057a0 |
| children | 2c0b9e3c11c3 |
comparison
equal
deleted
inserted
replaced
| 881:c508fb40552a | 888:1059230969c3 |
|---|---|
| 38 string=function(stanza, object) | 38 string=function(stanza, object) |
| 39 stanza:tag("string"):text(object):up(); | 39 stanza:tag("string"):text(object):up(); |
| 40 end; | 40 end; |
| 41 number=function(stanza, object) | 41 number=function(stanza, object) |
| 42 stanza:tag("int"):text(tostring(object)):up(); | 42 stanza:tag("int"):text(tostring(object)):up(); |
| 43 end; | |
| 44 ["nil"]=function(stanza, object) -- nil extension | |
| 45 stanza:tag("nil"):up(); | |
| 43 end; | 46 end; |
| 44 }; | 47 }; |
| 45 _lua_to_xmlrpc = function(stanza, object) | 48 _lua_to_xmlrpc = function(stanza, object) |
| 46 local h = map[type(object)]; | 49 local h = map[type(object)]; |
| 47 if h then | 50 if h then |
| 144 if #stanza.tags ~= 0 then error("<name> must have a single text child"); end | 147 if #stanza.tags ~= 0 then error("<name> must have a single text child"); end |
| 145 local n = t_concat(stanza) | 148 local n = t_concat(stanza) |
| 146 if tostring(tonumber(n)) == n then n = tonumber(n); end | 149 if tostring(tonumber(n)) == n then n = tonumber(n); end |
| 147 return n; | 150 return n; |
| 148 end; | 151 end; |
| 152 ["nil"]=function(stanza) -- nil extension | |
| 153 return nil; | |
| 154 end; | |
| 149 } | 155 } |
| 150 _xmlrpc_to_lua = function(stanza) | 156 _xmlrpc_to_lua = function(stanza) |
| 151 local h = rmap[stanza.name]; | 157 local h = rmap[stanza.name]; |
| 152 if h then | 158 if h then |
| 153 return h(stanza); | 159 return h(stanza); |
