Changeset 40
- Timestamp:
- 05/01/2011 11:41:27 PM (2 years ago)
- File:
-
- 1 edited
-
trunk/lua/chdku.lua (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lua/chdku.lua
r39 r40 51 51 libs={}, 52 52 } 53 54 53 --[[ 55 54 register{ 56 55 name='libname' 57 depend= {'lib1','lib2'...}, -- already registered rlibs this one requires (cyclic deps not allowed)56 depend='lib'|{'lib1','lib2'...}, -- already registered rlibs this one requires (cyclic deps not allowed) 58 57 code='', -- main lib code. 59 58 } 60 59 ]] 61 60 function rlibs:register(t) 62 if type(t.depend) == 'nil' then 61 -- for convenience, single lib may be given as string 62 if type(t.depend) == 'string' then 63 t.depend = {t.depend} 64 elseif type(t.depend) == 'nil' then 63 65 t.depend = {} 64 66 elseif type(t.depend) ~= 'table' then 65 error('expected dependency table ')67 error('expected dependency table or string') 66 68 end 67 69 if type(t.code) ~= 'string' then … … 108 110 --[[ 109 111 return a list of rlibs in dependency order 112 t=rlibs:build_list('name'|{'name1','name2',...}) 110 113 ]] 111 114 function rlibs:build_list(libnames) 115 -- single can be given as string 116 if type(libnames) == 'string' then 117 libnames={libnames} 118 elseif type(libnames) ~= 'table' then 119 error('rlibs:build_list expected string or table for libnames') 120 end 112 121 local build={ 113 122 list={}, … … 121 130 --[[ 122 131 return a string containing all the required rlib code 132 code=rlibs:build('name'|{'name1','name2',...}) 123 133 ]] 124 134 function rlibs:build(names) … … 187 197 end 188 198 end 189 190 199 serialize_defaults = { 191 200 maxdepth=10, … … 194 203 pretty=false, 195 204 } 196 197 205 function serialize(v,opts) 198 206 if opts then … … 212 220 { 213 221 name='serialize_msgs', 214 depend= {'serialize'},222 depend='serialize', 215 223 code=[[ 216 224 usb_msg_table_to_string=serialize … … 258 266 { 259 267 name='msg_batcher', 260 depend= {'serialize_msgs'},268 depend='serialize_msgs', 261 269 code=[[ 262 270 function msg_batcher(opts_in) … … 299 307 { 300 308 name='ls_simple', 301 depend= {'msg_batcher'},309 depend='msg_batcher', 302 310 code=[[ 303 311 function ls_simple(path) … … 347 355 { 348 356 name='ls', 349 depend= {'serialize_msgs'},357 depend='serialize_msgs', 350 358 code=[[ 351 359 function ls(path,opts_in) … … 418 426 { 419 427 wait=true, 420 libs= {'ls'},428 libs='ls', 421 429 msgs=function(msg) 422 430 if msg.subtype ~= 'table' then … … 482 490 -- syntax error, try to fetch the error message 483 491 if err == 'syntax' then 492 -- TODO extract error line and match with code 484 493 local msg = chdku.get_error_msg() 485 494 if msg then … … 531 540 else 532 541 -- if serialize_msgs is not selected, table return values will be strings 542 -- TODO not updated for new rlib yet 533 543 if msg.subtype == 'table' and in_table(opts.libs,'serialize_msgs') then 534 544 results[i] = unserialize(msg.value)
Note: See TracChangeset
for help on using the changeset viewer.