rufus-lua-win 5.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +69 -0
- data/Rakefile +1 -0
- data/lib/rufus/lua/win.rb +18 -0
- data/lib/rufus/lua/win/version.rb +7 -0
- data/rufus-lua-win.gemspec +23 -0
- data/vendor/lua/bin/liblua.dll +0 -0
- data/vendor/lua/lib/lua/LuaXml.lua +119 -0
- data/vendor/lua/lib/lua/alien.lua +250 -0
- data/vendor/lua/lib/lua/alien/core.dll +0 -0
- data/vendor/lua/lib/lua/alien/struct.dll +0 -0
- data/vendor/lua/lib/lua/base.lua +536 -0
- data/vendor/lua/lib/lua/bin.lua +20 -0
- data/vendor/lua/lib/lua/bit.dll +0 -0
- data/vendor/lua/lib/lua/cdlua.dll +0 -0
- data/vendor/lua/lib/lua/cdluacontextplus.dll +0 -0
- data/vendor/lua/lib/lua/cdluagl.dll +0 -0
- data/vendor/lua/lib/lua/cdluaim.dll +0 -0
- data/vendor/lua/lib/lua/cdluapdf.dll +0 -0
- data/vendor/lua/lib/lua/copas.lua +543 -0
- data/vendor/lua/lib/lua/coxpcall.lua +57 -0
- data/vendor/lua/lib/lua/date.lua +745 -0
- data/vendor/lua/lib/lua/debug_ext.lua +84 -0
- data/vendor/lua/lib/lua/debug_init.lua +2 -0
- data/vendor/lua/lib/lua/des56.dll +0 -0
- data/vendor/lua/lib/lua/dist/config.lua +109 -0
- data/vendor/lua/lib/lua/dist/constraints.lua +271 -0
- data/vendor/lua/lib/lua/dist/depends.lua +601 -0
- data/vendor/lua/lib/lua/dist/git.lua +307 -0
- data/vendor/lua/lib/lua/dist/init.lua +278 -0
- data/vendor/lua/lib/lua/dist/manifest.lua +225 -0
- data/vendor/lua/lib/lua/dist/package.lua +583 -0
- data/vendor/lua/lib/lua/dist/sys.lua +367 -0
- data/vendor/lua/lib/lua/dist/utils.lua +130 -0
- data/vendor/lua/lib/lua/ex.dll +0 -0
- data/vendor/lua/lib/lua/fstable.lua +116 -0
- data/vendor/lua/lib/lua/getopt.lua +273 -0
- data/vendor/lua/lib/lua/git.lua +5 -0
- data/vendor/lua/lib/lua/git/core.dll +0 -0
- data/vendor/lua/lib/lua/git/objects.lua +121 -0
- data/vendor/lua/lib/lua/git/pack.lua +316 -0
- data/vendor/lua/lib/lua/git/protocol.lua +188 -0
- data/vendor/lua/lib/lua/git/repo.lua +283 -0
- data/vendor/lua/lib/lua/git/util.lua +233 -0
- data/vendor/lua/lib/lua/gzio.dll +0 -0
- data/vendor/lua/lib/lua/gzip.lua +81 -0
- data/vendor/lua/lib/lua/iconv.dll +0 -0
- data/vendor/lua/lib/lua/imlua.dll +0 -0
- data/vendor/lua/lib/lua/imlua_fftw.dll +0 -0
- data/vendor/lua/lib/lua/imlua_jp2.dll +0 -0
- data/vendor/lua/lib/lua/imlua_process.dll +0 -0
- data/vendor/lua/lib/lua/imlua_process_omp.dll +0 -0
- data/vendor/lua/lib/lua/io_ext.lua +115 -0
- data/vendor/lua/lib/lua/iuplua.dll +0 -0
- data/vendor/lua/lib/lua/iuplua_mglplot.dll +0 -0
- data/vendor/lua/lib/lua/iuplua_pplot.dll +0 -0
- data/vendor/lua/lib/lua/iupluacd.dll +0 -0
- data/vendor/lua/lib/lua/iupluacontrols.dll +0 -0
- data/vendor/lua/lib/lua/iupluagl.dll +0 -0
- data/vendor/lua/lib/lua/iupluaim.dll +0 -0
- data/vendor/lua/lib/lua/iupluaimglib.dll +0 -0
- data/vendor/lua/lib/lua/iupluatuio.dll +0 -0
- data/vendor/lua/lib/lua/lanes-keeper.lua +302 -0
- data/vendor/lua/lib/lua/lanes.lua +591 -0
- data/vendor/lua/lib/lua/lanes/core.dll +0 -0
- data/vendor/lua/lib/lua/lcs.lua +55 -0
- data/vendor/lua/lib/lua/lemock.lua +659 -0
- data/vendor/lua/lib/lua/lfs.dll +0 -0
- data/vendor/lua/lib/lua/list.lua +375 -0
- data/vendor/lua/lib/lua/logging.lua +189 -0
- data/vendor/lua/lib/lua/logging/console.lua +22 -0
- data/vendor/lua/lib/lua/logging/email.lua +44 -0
- data/vendor/lua/lib/lua/logging/file.lua +55 -0
- data/vendor/lua/lib/lua/logging/rolling_file.lua +81 -0
- data/vendor/lua/lib/lua/logging/socket.lua +35 -0
- data/vendor/lua/lib/lua/logging/sql.lua +64 -0
- data/vendor/lua/lib/lua/loop/base.lua +68 -0
- data/vendor/lua/lib/lua/loop/cached.lua +312 -0
- data/vendor/lua/lib/lua/loop/collection/MapWithArrayOfKeys.lua +64 -0
- data/vendor/lua/lib/lua/loop/collection/ObjectCache.lua +39 -0
- data/vendor/lua/lib/lua/loop/collection/OrderedSet.lua +164 -0
- data/vendor/lua/lib/lua/loop/collection/PriorityQueue.lua +86 -0
- data/vendor/lua/lib/lua/loop/collection/UnorderedArray.lua +32 -0
- data/vendor/lua/lib/lua/loop/collection/UnorderedArraySet.lua +56 -0
- data/vendor/lua/lib/lua/loop/compiler/Arguments.lua +108 -0
- data/vendor/lua/lib/lua/loop/compiler/Conditional.lua +50 -0
- data/vendor/lua/lib/lua/loop/compiler/Expression.lua +215 -0
- data/vendor/lua/lib/lua/loop/component/base.lua +221 -0
- data/vendor/lua/lib/lua/loop/component/contained.lua +71 -0
- data/vendor/lua/lib/lua/loop/component/dynamic.lua +223 -0
- data/vendor/lua/lib/lua/loop/component/intercepted.lua +354 -0
- data/vendor/lua/lib/lua/loop/component/wrapped.lua +195 -0
- data/vendor/lua/lib/lua/loop/debug/Inspector.lua +521 -0
- data/vendor/lua/lib/lua/loop/debug/Matcher.lua +192 -0
- data/vendor/lua/lib/lua/loop/debug/Verbose.lua +266 -0
- data/vendor/lua/lib/lua/loop/debug/Viewer.lua +200 -0
- data/vendor/lua/lib/lua/loop/multiple.lua +105 -0
- data/vendor/lua/lib/lua/loop/object/Exception.lua +57 -0
- data/vendor/lua/lib/lua/loop/object/Publisher.lua +43 -0
- data/vendor/lua/lib/lua/loop/object/Wrapper.lua +39 -0
- data/vendor/lua/lib/lua/loop/scoped.lua +585 -0
- data/vendor/lua/lib/lua/loop/serial/FileStream.lua +48 -0
- data/vendor/lua/lib/lua/loop/serial/Serializer.lua +291 -0
- data/vendor/lua/lib/lua/loop/serial/SocketStream.lua +51 -0
- data/vendor/lua/lib/lua/loop/serial/StringStream.lua +47 -0
- data/vendor/lua/lib/lua/loop/simple.lua +75 -0
- data/vendor/lua/lib/lua/loop/table.lua +71 -0
- data/vendor/lua/lib/lua/loop/thread/CoSocket.lua +416 -0
- data/vendor/lua/lib/lua/loop/thread/IOScheduler.lua +170 -0
- data/vendor/lua/lib/lua/loop/thread/Scheduler.lua +327 -0
- data/vendor/lua/lib/lua/loop/thread/SocketScheduler.lua +88 -0
- data/vendor/lua/lib/lua/loop/thread/Timer.lua +54 -0
- data/vendor/lua/lib/lua/lpeg.dll +0 -0
- data/vendor/lua/lib/lua/ltn12.lua +292 -0
- data/vendor/lua/lib/lua/luaXML_lib.dll +0 -0
- data/vendor/lua/lib/lua/luacurl.dll +0 -0
- data/vendor/lua/lib/lua/luadoc/config.lua +34 -0
- data/vendor/lua/lib/lua/luadoc/doclet/debug.lua +46 -0
- data/vendor/lua/lib/lua/luadoc/doclet/formatter.lua +84 -0
- data/vendor/lua/lib/lua/luadoc/doclet/html.lua +289 -0
- data/vendor/lua/lib/lua/luadoc/doclet/html/file.lp +113 -0
- data/vendor/lua/lib/lua/luadoc/doclet/html/function.lp +64 -0
- data/vendor/lua/lib/lua/luadoc/doclet/html/index.lp +70 -0
- data/vendor/lua/lib/lua/luadoc/doclet/html/luadoc.css +286 -0
- data/vendor/lua/lib/lua/luadoc/doclet/html/menu.lp +55 -0
- data/vendor/lua/lib/lua/luadoc/doclet/html/module.lp +109 -0
- data/vendor/lua/lib/lua/luadoc/doclet/html/table.lp +15 -0
- data/vendor/lua/lib/lua/luadoc/doclet/raw.lua +12 -0
- data/vendor/lua/lib/lua/luadoc/init.lua +58 -0
- data/vendor/lua/lib/lua/luadoc/lp.lua +130 -0
- data/vendor/lua/lib/lua/luadoc/taglet/standard.lua +495 -0
- data/vendor/lua/lib/lua/luadoc/taglet/standard/tags.lua +171 -0
- data/vendor/lua/lib/lua/luadoc/util.lua +233 -0
- data/vendor/lua/lib/lua/luagl.dll +0 -0
- data/vendor/lua/lib/lua/luaglu.dll +0 -0
- data/vendor/lua/lib/lua/luaidl.lua +113 -0
- data/vendor/lua/lib/lua/luaidl/lex.lua +793 -0
- data/vendor/lua/lib/lua/luaidl/pre.lua +149 -0
- data/vendor/lua/lib/lua/luaidl/sin.lua +3631 -0
- data/vendor/lua/lib/lua/luarocks/add.lua +108 -0
- data/vendor/lua/lib/lua/luarocks/admin_remove.lua +87 -0
- data/vendor/lua/lib/lua/luarocks/build.lua +330 -0
- data/vendor/lua/lib/lua/luarocks/build/builtin.lua +253 -0
- data/vendor/lua/lib/lua/luarocks/build/cmake.lua +54 -0
- data/vendor/lua/lib/lua/luarocks/build/command.lua +32 -0
- data/vendor/lua/lib/lua/luarocks/build/make.lua +92 -0
- data/vendor/lua/lib/lua/luarocks/cache.lua +85 -0
- data/vendor/lua/lib/lua/luarocks/cfg.lua +449 -0
- data/vendor/lua/lib/lua/luarocks/command_line.lua +163 -0
- data/vendor/lua/lib/lua/luarocks/deps.lua +654 -0
- data/vendor/lua/lib/lua/luarocks/dir.lua +69 -0
- data/vendor/lua/lib/lua/luarocks/download.lua +90 -0
- data/vendor/lua/lib/lua/luarocks/fetch.lua +321 -0
- data/vendor/lua/lib/lua/luarocks/fetch/cvs.lua +44 -0
- data/vendor/lua/lib/lua/luarocks/fetch/git.lua +81 -0
- data/vendor/lua/lib/lua/luarocks/fetch/git_file.lua +17 -0
- data/vendor/lua/lib/lua/luarocks/fetch/hg.lua +54 -0
- data/vendor/lua/lib/lua/luarocks/fetch/sscm.lua +42 -0
- data/vendor/lua/lib/lua/luarocks/fetch/svn.lua +53 -0
- data/vendor/lua/lib/lua/luarocks/fs.lua +40 -0
- data/vendor/lua/lib/lua/luarocks/fs/lua.lua +676 -0
- data/vendor/lua/lib/lua/luarocks/fs/unix.lua +88 -0
- data/vendor/lua/lib/lua/luarocks/fs/unix/tools.lua +325 -0
- data/vendor/lua/lib/lua/luarocks/fs/win32.lua +107 -0
- data/vendor/lua/lib/lua/luarocks/fs/win32/tools.lua +334 -0
- data/vendor/lua/lib/lua/luarocks/help.lua +101 -0
- data/vendor/lua/lib/lua/luarocks/index.lua +172 -0
- data/vendor/lua/lib/lua/luarocks/install.lua +151 -0
- data/vendor/lua/lib/lua/luarocks/list.lua +35 -0
- data/vendor/lua/lib/lua/luarocks/loader.lua +228 -0
- data/vendor/lua/lib/lua/luarocks/make.lua +71 -0
- data/vendor/lua/lib/lua/luarocks/make_manifest.lua +34 -0
- data/vendor/lua/lib/lua/luarocks/manif.lua +360 -0
- data/vendor/lua/lib/lua/luarocks/manif_core.lua +75 -0
- data/vendor/lua/lib/lua/luarocks/new_version.lua +141 -0
- data/vendor/lua/lib/lua/luarocks/pack.lua +205 -0
- data/vendor/lua/lib/lua/luarocks/path.lua +315 -0
- data/vendor/lua/lib/lua/luarocks/persist.lua +173 -0
- data/vendor/lua/lib/lua/luarocks/refresh_cache.lua +30 -0
- data/vendor/lua/lib/lua/luarocks/remove.lua +135 -0
- data/vendor/lua/lib/lua/luarocks/rep.lua +313 -0
- data/vendor/lua/lib/lua/luarocks/require.lua +6 -0
- data/vendor/lua/lib/lua/luarocks/search.lua +399 -0
- data/vendor/lua/lib/lua/luarocks/show.lua +138 -0
- data/vendor/lua/lib/lua/luarocks/site_config.lua +23 -0
- data/vendor/lua/lib/lua/luarocks/tools/patch.lua +712 -0
- data/vendor/lua/lib/lua/luarocks/tools/tar.lua +144 -0
- data/vendor/lua/lib/lua/luarocks/tools/zip.lua +245 -0
- data/vendor/lua/lib/lua/luarocks/type_check.lua +267 -0
- data/vendor/lua/lib/lua/luarocks/unpack.lua +151 -0
- data/vendor/lua/lib/lua/luarocks/util.lua +420 -0
- data/vendor/lua/lib/lua/luarocks/validate.lua +164 -0
- data/vendor/lua/lib/lua/luars232.dll +0 -0
- data/vendor/lua/lib/lua/luasql/mysql.dll +0 -0
- data/vendor/lua/lib/lua/luasql/postgres.dll +0 -0
- data/vendor/lua/lib/lua/luasql/sqlite3.dll +0 -0
- data/vendor/lua/lib/lua/luaunit.lua +601 -0
- data/vendor/lua/lib/lua/lxp.dll +0 -0
- data/vendor/lua/lib/lua/lxp/lom.lua +60 -0
- data/vendor/lua/lib/lua/math_ext.lua +27 -0
- data/vendor/lua/lib/lua/mbox.lua +53 -0
- data/vendor/lua/lib/lua/md5.lua +19 -0
- data/vendor/lua/lib/lua/md5/core.dll +0 -0
- data/vendor/lua/lib/lua/metalua.lua +0 -0
- data/vendor/lua/lib/lua/metalua/ast_to_string.mlua +553 -0
- data/vendor/lua/lib/lua/metalua/base.lua +104 -0
- data/vendor/lua/lib/lua/metalua/bytecode.lua +0 -0
- data/vendor/lua/lib/lua/metalua/clopts.mlua +204 -0
- data/vendor/lua/lib/lua/metalua/compiler.lua +3 -0
- data/vendor/lua/lib/lua/metalua/dollar.mlua +24 -0
- data/vendor/lua/lib/lua/metalua/extension/H-runtime.mlua +216 -0
- data/vendor/lua/lib/lua/metalua/extension/H.mlua +22 -0
- data/vendor/lua/lib/lua/metalua/extension/anaphoric.mlua +54 -0
- data/vendor/lua/lib/lua/metalua/extension/clist.mlua +149 -0
- data/vendor/lua/lib/lua/metalua/extension/continue.mlua +53 -0
- data/vendor/lua/lib/lua/metalua/extension/localin.mlua +2 -0
- data/vendor/lua/lib/lua/metalua/extension/log.mlua +39 -0
- data/vendor/lua/lib/lua/metalua/extension/match.mlua +374 -0
- data/vendor/lua/lib/lua/metalua/extension/ternary.mlua +10 -0
- data/vendor/lua/lib/lua/metalua/extension/trycatch.mlua +189 -0
- data/vendor/lua/lib/lua/metalua/extension/types-runtime.mlua +159 -0
- data/vendor/lua/lib/lua/metalua/extension/types.mlua +352 -0
- data/vendor/lua/lib/lua/metalua/extension/withdo.mlua +30 -0
- data/vendor/lua/lib/lua/metalua/extension/xglobal-runtime.lua +41 -0
- data/vendor/lua/lib/lua/metalua/extension/xglobal.mlua +20 -0
- data/vendor/lua/lib/lua/metalua/extension/xloop.mlua +100 -0
- data/vendor/lua/lib/lua/metalua/extension/xmatch.mlua +216 -0
- data/vendor/lua/lib/lua/metalua/metaloop.mlua +76 -0
- data/vendor/lua/lib/lua/metalua/mlc.lua +0 -0
- data/vendor/lua/lib/lua/metalua/mlc_xcall.lua +119 -0
- data/vendor/lua/lib/lua/metalua/mlp.lua +0 -0
- data/vendor/lua/lib/lua/metalua/package2.lua +101 -0
- data/vendor/lua/lib/lua/metalua/runtime.lua +3 -0
- data/vendor/lua/lib/lua/metalua/string2.lua +44 -0
- data/vendor/lua/lib/lua/metalua/table2.lua +372 -0
- data/vendor/lua/lib/lua/metalua/walk.mlua +304 -0
- data/vendor/lua/lib/lua/metalua/walk/bindings.mlua +41 -0
- data/vendor/lua/lib/lua/metalua/walk/id.mlua +186 -0
- data/vendor/lua/lib/lua/metalua/walk/scope.lua +54 -0
- data/vendor/lua/lib/lua/mime.lua +87 -0
- data/vendor/lua/lib/lua/mime/core.dll +0 -0
- data/vendor/lua/lib/lua/mobdebug.lua +1484 -0
- data/vendor/lua/lib/lua/modules.lua +16 -0
- data/vendor/lua/lib/lua/object.lua +56 -0
- data/vendor/lua/lib/lua/oil/Exception.lua +26 -0
- data/vendor/lua/lib/lua/oil/arch.lua +27 -0
- data/vendor/lua/lib/lua/oil/arch/basic/client.lua +29 -0
- data/vendor/lua/lib/lua/oil/arch/basic/common.lua +13 -0
- data/vendor/lua/lib/lua/oil/arch/basic/server.lua +27 -0
- data/vendor/lua/lib/lua/oil/arch/cooperative/common.lua +10 -0
- data/vendor/lua/lib/lua/oil/arch/cooperative/server.lua +16 -0
- data/vendor/lua/lib/lua/oil/arch/corba/client.lua +39 -0
- data/vendor/lua/lib/lua/oil/arch/corba/common.lua +58 -0
- data/vendor/lua/lib/lua/oil/arch/corba/intercepted/client.lua +9 -0
- data/vendor/lua/lib/lua/oil/arch/corba/intercepted/server.lua +9 -0
- data/vendor/lua/lib/lua/oil/arch/corba/server.lua +35 -0
- data/vendor/lua/lib/lua/oil/arch/ludo/byref.lua +18 -0
- data/vendor/lua/lib/lua/oil/arch/ludo/client.lua +19 -0
- data/vendor/lua/lib/lua/oil/arch/ludo/common.lua +18 -0
- data/vendor/lua/lib/lua/oil/arch/ludo/server.lua +19 -0
- data/vendor/lua/lib/lua/oil/arch/typed/client.lua +27 -0
- data/vendor/lua/lib/lua/oil/arch/typed/common.lua +9 -0
- data/vendor/lua/lib/lua/oil/arch/typed/server.lua +18 -0
- data/vendor/lua/lib/lua/oil/assert.lua +87 -0
- data/vendor/lua/lib/lua/oil/builder.lua +45 -0
- data/vendor/lua/lib/lua/oil/builder/basic/client.lua +31 -0
- data/vendor/lua/lib/lua/oil/builder/basic/common.lua +11 -0
- data/vendor/lua/lib/lua/oil/builder/basic/server.lua +13 -0
- data/vendor/lua/lib/lua/oil/builder/cooperative/common.lua +11 -0
- data/vendor/lua/lib/lua/oil/builder/cooperative/server.lua +11 -0
- data/vendor/lua/lib/lua/oil/builder/corba/client.lua +13 -0
- data/vendor/lua/lib/lua/oil/builder/corba/common.lua +24 -0
- data/vendor/lua/lib/lua/oil/builder/corba/gencode.lua +13 -0
- data/vendor/lua/lib/lua/oil/builder/corba/intercepted/client.lua +11 -0
- data/vendor/lua/lib/lua/oil/builder/corba/intercepted/server.lua +11 -0
- data/vendor/lua/lib/lua/oil/builder/corba/server.lua +13 -0
- data/vendor/lua/lib/lua/oil/builder/lua/client.lua +11 -0
- data/vendor/lua/lib/lua/oil/builder/lua/server.lua +12 -0
- data/vendor/lua/lib/lua/oil/builder/ludo/byref.lua +13 -0
- data/vendor/lua/lib/lua/oil/builder/ludo/client.lua +13 -0
- data/vendor/lua/lib/lua/oil/builder/ludo/common.lua +14 -0
- data/vendor/lua/lib/lua/oil/builder/ludo/server.lua +13 -0
- data/vendor/lua/lib/lua/oil/builder/typed/client.lua +16 -0
- data/vendor/lua/lib/lua/oil/builder/typed/server.lua +12 -0
- data/vendor/lua/lib/lua/oil/compat.lua +846 -0
- data/vendor/lua/lib/lua/oil/component.lua +1 -0
- data/vendor/lua/lib/lua/oil/corba/giop.lua +301 -0
- data/vendor/lua/lib/lua/oil/corba/giop/Codec.lua +1568 -0
- data/vendor/lua/lib/lua/oil/corba/giop/CodecGen.lua +589 -0
- data/vendor/lua/lib/lua/oil/corba/giop/Exception.lua +25 -0
- data/vendor/lua/lib/lua/oil/corba/giop/Indexer.lua +63 -0
- data/vendor/lua/lib/lua/oil/corba/giop/Listener.lua +343 -0
- data/vendor/lua/lib/lua/oil/corba/giop/Messenger.lua +228 -0
- data/vendor/lua/lib/lua/oil/corba/giop/Referrer.lua +180 -0
- data/vendor/lua/lib/lua/oil/corba/giop/Requester.lua +462 -0
- data/vendor/lua/lib/lua/oil/corba/idl.lua +597 -0
- data/vendor/lua/lib/lua/oil/corba/idl/Compiler.lua +133 -0
- data/vendor/lua/lib/lua/oil/corba/idl/Importer.lua +235 -0
- data/vendor/lua/lib/lua/oil/corba/idl/Indexer.lua +95 -0
- data/vendor/lua/lib/lua/oil/corba/idl/Registry.lua +1821 -0
- data/vendor/lua/lib/lua/oil/corba/idl/ir.lua +847 -0
- data/vendor/lua/lib/lua/oil/corba/idl/sysex.lua +21 -0
- data/vendor/lua/lib/lua/oil/corba/iiop/Profiler.lua +200 -0
- data/vendor/lua/lib/lua/oil/corba/intercepted/Listener.lua +158 -0
- data/vendor/lua/lib/lua/oil/corba/intercepted/Requester.lua +181 -0
- data/vendor/lua/lib/lua/oil/corba/services/event.lua +126 -0
- data/vendor/lua/lib/lua/oil/corba/services/event/ConsumerAdmin.lua +50 -0
- data/vendor/lua/lib/lua/oil/corba/services/event/EventFactory.lua +15 -0
- data/vendor/lua/lib/lua/oil/corba/services/event/EventQueue.lua +37 -0
- data/vendor/lua/lib/lua/oil/corba/services/event/ProxyPushConsumer.lua +75 -0
- data/vendor/lua/lib/lua/oil/corba/services/event/ProxyPushSupplier.lua +62 -0
- data/vendor/lua/lib/lua/oil/corba/services/event/SingleDeferredDispatcher.lua +60 -0
- data/vendor/lua/lib/lua/oil/corba/services/event/SingleSynchronousDispatcher.lua +39 -0
- data/vendor/lua/lib/lua/oil/corba/services/event/SupplierAdmin.lua +50 -0
- data/vendor/lua/lib/lua/oil/corba/services/naming.lua +436 -0
- data/vendor/lua/lib/lua/oil/kernel/base/Acceptor.lua +268 -0
- data/vendor/lua/lib/lua/oil/kernel/base/Channels.lua +121 -0
- data/vendor/lua/lib/lua/oil/kernel/base/Connector.lua +147 -0
- data/vendor/lua/lib/lua/oil/kernel/base/Dispatcher.lua +99 -0
- data/vendor/lua/lib/lua/oil/kernel/base/Proxies.lua +86 -0
- data/vendor/lua/lib/lua/oil/kernel/base/Proxies/asynchronous.lua +56 -0
- data/vendor/lua/lib/lua/oil/kernel/base/Proxies/protected.lua +17 -0
- data/vendor/lua/lib/lua/oil/kernel/base/Proxies/synchronous.lua +17 -0
- data/vendor/lua/lib/lua/oil/kernel/base/Proxies/utils.lua +29 -0
- data/vendor/lua/lib/lua/oil/kernel/base/Receiver.lua +110 -0
- data/vendor/lua/lib/lua/oil/kernel/base/Servants.lua +207 -0
- data/vendor/lua/lib/lua/oil/kernel/base/Sockets.lua +44 -0
- data/vendor/lua/lib/lua/oil/kernel/cooperative/Receiver.lua +139 -0
- data/vendor/lua/lib/lua/oil/kernel/intercepted/Listener.lua +47 -0
- data/vendor/lua/lib/lua/oil/kernel/intercepted/Requester.lua +58 -0
- data/vendor/lua/lib/lua/oil/kernel/lua/Dispatcher.lua +76 -0
- data/vendor/lua/lib/lua/oil/kernel/lua/Proxies.lua +69 -0
- data/vendor/lua/lib/lua/oil/kernel/typed/Dispatcher.lua +91 -0
- data/vendor/lua/lib/lua/oil/kernel/typed/Proxies.lua +153 -0
- data/vendor/lua/lib/lua/oil/kernel/typed/Servants.lua +137 -0
- data/vendor/lua/lib/lua/oil/ludo/Codec.lua +66 -0
- data/vendor/lua/lib/lua/oil/ludo/CodecByRef.lua +103 -0
- data/vendor/lua/lib/lua/oil/ludo/Listener.lua +151 -0
- data/vendor/lua/lib/lua/oil/ludo/Referrer.lua +72 -0
- data/vendor/lua/lib/lua/oil/ludo/Requester.lua +107 -0
- data/vendor/lua/lib/lua/oil/oo.lua +1 -0
- data/vendor/lua/lib/lua/oil/port.lua +1 -0
- data/vendor/lua/lib/lua/oil/properties.lua +57 -0
- data/vendor/lua/lib/lua/oil/verbose.lua +133 -0
- data/vendor/lua/lib/lua/package_ext.lua +15 -0
- data/vendor/lua/lib/lua/parser.lua +268 -0
- data/vendor/lua/lib/lua/pl/Date.lua +555 -0
- data/vendor/lua/lib/lua/pl/List.lua +613 -0
- data/vendor/lua/lib/lua/pl/Map.lua +113 -0
- data/vendor/lua/lib/lua/pl/MultiMap.lua +62 -0
- data/vendor/lua/lib/lua/pl/OrderedMap.lua +151 -0
- data/vendor/lua/lib/lua/pl/Set.lua +153 -0
- data/vendor/lua/lib/lua/pl/app.lua +165 -0
- data/vendor/lua/lib/lua/pl/array2d.lua +501 -0
- data/vendor/lua/lib/lua/pl/class.lua +180 -0
- data/vendor/lua/lib/lua/pl/comprehension.lua +286 -0
- data/vendor/lua/lib/lua/pl/config.lua +176 -0
- data/vendor/lua/lib/lua/pl/data.lua +606 -0
- data/vendor/lua/lib/lua/pl/dir.lua +475 -0
- data/vendor/lua/lib/lua/pl/file.lua +70 -0
- data/vendor/lua/lib/lua/pl/func.lua +376 -0
- data/vendor/lua/lib/lua/pl/init.lua +68 -0
- data/vendor/lua/lib/lua/pl/input.lua +173 -0
- data/vendor/lua/lib/lua/pl/lapp.lua +407 -0
- data/vendor/lua/lib/lua/pl/lexer.lua +456 -0
- data/vendor/lua/lib/lua/pl/luabalanced.lua +264 -0
- data/vendor/lua/lib/lua/pl/operator.lua +201 -0
- data/vendor/lua/lib/lua/pl/path.lua +398 -0
- data/vendor/lua/lib/lua/pl/permute.lua +63 -0
- data/vendor/lua/lib/lua/pl/platf/luajava.lua +101 -0
- data/vendor/lua/lib/lua/pl/pretty.lua +285 -0
- data/vendor/lua/lib/lua/pl/seq.lua +551 -0
- data/vendor/lua/lib/lua/pl/sip.lua +344 -0
- data/vendor/lua/lib/lua/pl/strict.lua +70 -0
- data/vendor/lua/lib/lua/pl/stringio.lua +158 -0
- data/vendor/lua/lib/lua/pl/stringx.lua +440 -0
- data/vendor/lua/lib/lua/pl/tablex.lua +817 -0
- data/vendor/lua/lib/lua/pl/template.lua +103 -0
- data/vendor/lua/lib/lua/pl/test.lua +135 -0
- data/vendor/lua/lib/lua/pl/text.lua +243 -0
- data/vendor/lua/lib/lua/pl/utils.lua +550 -0
- data/vendor/lua/lib/lua/pl/xml.lua +689 -0
- data/vendor/lua/lib/lua/profiler.dll +0 -0
- data/vendor/lua/lib/lua/re.lua +248 -0
- data/vendor/lua/lib/lua/rex_onig.dll +0 -0
- data/vendor/lua/lib/lua/rex_pcre.dll +0 -0
- data/vendor/lua/lib/lua/rex_posix.dll +0 -0
- data/vendor/lua/lib/lua/rings.dll +0 -0
- data/vendor/lua/lib/lua/serialize.lua +193 -0
- data/vendor/lua/lib/lua/set.lua +149 -0
- data/vendor/lua/lib/lua/socket.lua +133 -0
- data/vendor/lua/lib/lua/socket/core.dll +0 -0
- data/vendor/lua/lib/lua/socket/ftp.lua +281 -0
- data/vendor/lua/lib/lua/socket/http.lua +350 -0
- data/vendor/lua/lib/lua/socket/smtp.lua +251 -0
- data/vendor/lua/lib/lua/socket/tp.lua +123 -0
- data/vendor/lua/lib/lua/socket/url.lua +297 -0
- data/vendor/lua/lib/lua/ssl.dll +0 -0
- data/vendor/lua/lib/lua/ssl.lua +93 -0
- data/vendor/lua/lib/lua/ssl/https.lua +138 -0
- data/vendor/lua/lib/lua/stable.lua +28 -0
- data/vendor/lua/lib/lua/std.lua +16 -0
- data/vendor/lua/lib/lua/strbuf.lua +32 -0
- data/vendor/lua/lib/lua/strict.lua +45 -0
- data/vendor/lua/lib/lua/string_ext.lua +274 -0
- data/vendor/lua/lib/lua/table_ext.lua +117 -0
- data/vendor/lua/lib/lua/tar.lua +262 -0
- data/vendor/lua/lib/lua/task.dll +0 -0
- data/vendor/lua/lib/lua/tree.lua +81 -0
- data/vendor/lua/lib/lua/unicode.dll +0 -0
- data/vendor/lua/lib/lua/verbose_require.lua +11 -0
- data/vendor/lua/lib/lua/vstruct.lua +86 -0
- data/vendor/lua/lib/lua/vstruct/ast.lua +192 -0
- data/vendor/lua/lib/lua/vstruct/ast/Bitpack.lua +33 -0
- data/vendor/lua/lib/lua/vstruct/ast/Generator.lua +174 -0
- data/vendor/lua/lib/lua/vstruct/ast/IO.lua +45 -0
- data/vendor/lua/lib/lua/vstruct/ast/List.lua +56 -0
- data/vendor/lua/lib/lua/vstruct/ast/Name.lua +20 -0
- data/vendor/lua/lib/lua/vstruct/ast/Repeat.lua +23 -0
- data/vendor/lua/lib/lua/vstruct/ast/Root.lua +19 -0
- data/vendor/lua/lib/lua/vstruct/ast/Table.lua +65 -0
- data/vendor/lua/lib/lua/vstruct/cursor.lua +81 -0
- data/vendor/lua/lib/lua/vstruct/io.lua +45 -0
- data/vendor/lua/lib/lua/vstruct/io/a.lua +24 -0
- data/vendor/lua/lib/lua/vstruct/io/b.lua +28 -0
- data/vendor/lua/lib/lua/vstruct/io/bigendian.lua +21 -0
- data/vendor/lua/lib/lua/vstruct/io/c.lua +25 -0
- data/vendor/lua/lib/lua/vstruct/io/defaults.lua +24 -0
- data/vendor/lua/lib/lua/vstruct/io/endianness.lua +41 -0
- data/vendor/lua/lib/lua/vstruct/io/f.lua +129 -0
- data/vendor/lua/lib/lua/vstruct/io/hostendian.lua +21 -0
- data/vendor/lua/lib/lua/vstruct/io/i.lua +42 -0
- data/vendor/lua/lib/lua/vstruct/io/littleendian.lua +21 -0
- data/vendor/lua/lib/lua/vstruct/io/m.lua +62 -0
- data/vendor/lua/lib/lua/vstruct/io/p.lua +23 -0
- data/vendor/lua/lib/lua/vstruct/io/s.lua +27 -0
- data/vendor/lua/lib/lua/vstruct/io/seekb.lua +18 -0
- data/vendor/lua/lib/lua/vstruct/io/seekf.lua +18 -0
- data/vendor/lua/lib/lua/vstruct/io/seekto.lua +18 -0
- data/vendor/lua/lib/lua/vstruct/io/u.lua +54 -0
- data/vendor/lua/lib/lua/vstruct/io/x.lua +34 -0
- data/vendor/lua/lib/lua/vstruct/io/z.lua +63 -0
- data/vendor/lua/lib/lua/vstruct/lexer.lua +100 -0
- data/vendor/lua/lib/lua/vstruct/pack.lua +142 -0
- data/vendor/lua/lib/lua/vstruct/test.lua +47 -0
- data/vendor/lua/lib/lua/vstruct/test/basic.lua +73 -0
- data/vendor/lua/lib/lua/vstruct/test/common.lua +100 -0
- data/vendor/lua/lib/lua/vstruct/test/fp-bigendian.lua +56 -0
- data/vendor/lua/lib/lua/vstruct/test/fp-littleendian.lua +56 -0
- data/vendor/lua/lib/lua/vstruct/test/struct-test-gen.lua +1230 -0
- data/vendor/lua/lib/lua/vstruct/unpack.lua +126 -0
- data/vendor/lua/lib/lua/wx.dll +0 -0
- data/vendor/lua/lib/lua/xml.lua +75 -0
- data/vendor/lua/lib/lua/zip.dll +0 -0
- data/vendor/lua/lib/lua/zlib.dll +0 -0
- metadata +529 -0
@@ -0,0 +1,101 @@
|
|
1
|
+
-- experimental support for LuaJava
|
2
|
+
--
|
3
|
+
local path = {}
|
4
|
+
|
5
|
+
|
6
|
+
path.link_attrib = nil
|
7
|
+
|
8
|
+
local File = luajava.bindClass("java.io.File")
|
9
|
+
local Array = luajava.bindClass('java.lang.reflect.Array')
|
10
|
+
|
11
|
+
local function file(s)
|
12
|
+
return luajava.new(File,s)
|
13
|
+
end
|
14
|
+
|
15
|
+
function path.dir(P)
|
16
|
+
local ls = file(P):list()
|
17
|
+
print(ls)
|
18
|
+
local idx,n = -1,Array:getLength(ls)
|
19
|
+
return function ()
|
20
|
+
idx = idx + 1
|
21
|
+
if idx == n then return nil
|
22
|
+
else
|
23
|
+
return Array:get(ls,idx)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
function path.mkdir(P)
|
29
|
+
return file(P):mkdir()
|
30
|
+
end
|
31
|
+
|
32
|
+
function path.rmdir(P)
|
33
|
+
return file(P):delete()
|
34
|
+
end
|
35
|
+
|
36
|
+
--- is this a directory?
|
37
|
+
-- @param P A file path
|
38
|
+
function path.isdir(P)
|
39
|
+
if P:match("\\$") then
|
40
|
+
P = P:sub(1,-2)
|
41
|
+
end
|
42
|
+
return file(P):isDirectory()
|
43
|
+
end
|
44
|
+
|
45
|
+
--- is this a file?.
|
46
|
+
-- @param P A file path
|
47
|
+
function path.isfile(P)
|
48
|
+
return file(P):isFile()
|
49
|
+
end
|
50
|
+
|
51
|
+
-- is this a symbolic link?
|
52
|
+
-- Direct support for symbolic links is not provided.
|
53
|
+
-- see http://stackoverflow.com/questions/813710/java-1-6-determine-symbolic-links
|
54
|
+
-- and the caveats therein.
|
55
|
+
-- @param P A file path
|
56
|
+
function path.islink(P)
|
57
|
+
local f = file(P)
|
58
|
+
local canon
|
59
|
+
local parent = f:getParent()
|
60
|
+
if not parent then
|
61
|
+
canon = f
|
62
|
+
else
|
63
|
+
parent = f.getParentFile():getCanonicalFile()
|
64
|
+
canon = luajava.new(File,parent,f:getName())
|
65
|
+
end
|
66
|
+
return canon:getCanonicalFile() ~= canon:getAbsoluteFile()
|
67
|
+
end
|
68
|
+
|
69
|
+
--- return size of a file.
|
70
|
+
-- @param P A file path
|
71
|
+
function path.getsize(P)
|
72
|
+
return file(P):length()
|
73
|
+
end
|
74
|
+
|
75
|
+
--- does a path exist?.
|
76
|
+
-- @param P A file path
|
77
|
+
-- @return the file path if it exists, nil otherwise
|
78
|
+
function path.exists(P)
|
79
|
+
return file(P):exists() and P
|
80
|
+
end
|
81
|
+
|
82
|
+
--- Return the time of last access as the number of seconds since the epoch.
|
83
|
+
-- @param P A file path
|
84
|
+
function path.getatime(P)
|
85
|
+
return path.getmtime(P)
|
86
|
+
end
|
87
|
+
|
88
|
+
--- Return the time of last modification
|
89
|
+
-- @param P A file path
|
90
|
+
function path.getmtime(P)
|
91
|
+
-- Java time is no. of millisec since the epoch
|
92
|
+
return file(P):lastModified()/1000
|
93
|
+
end
|
94
|
+
|
95
|
+
---Return the system's ctime.
|
96
|
+
-- @param P A file path
|
97
|
+
function path.getctime(P)
|
98
|
+
return path.getmtime(P)
|
99
|
+
end
|
100
|
+
|
101
|
+
return path
|
@@ -0,0 +1,285 @@
|
|
1
|
+
--- Pretty-printing Lua tables.
|
2
|
+
-- Also provides a sandboxed Lua table reader and
|
3
|
+
-- a function to present large numbers in human-friendly format.
|
4
|
+
--
|
5
|
+
-- Dependencies: `pl.utils`, `pl.lexer`
|
6
|
+
-- @module pl.pretty
|
7
|
+
|
8
|
+
local append = table.insert
|
9
|
+
local concat = table.concat
|
10
|
+
local utils = require 'pl.utils'
|
11
|
+
local lexer = require 'pl.lexer'
|
12
|
+
local assert_arg = utils.assert_arg
|
13
|
+
|
14
|
+
local pretty = {}
|
15
|
+
|
16
|
+
local function save_string_index ()
|
17
|
+
local SMT = getmetatable ''
|
18
|
+
if SMT then
|
19
|
+
SMT.old__index = SMT.__index
|
20
|
+
SMT.__index = nil
|
21
|
+
end
|
22
|
+
return SMT
|
23
|
+
end
|
24
|
+
|
25
|
+
local function restore_string_index (SMT)
|
26
|
+
if SMT then
|
27
|
+
SMT.__index = SMT.old__index
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
--- read a string representation of a Lua table.
|
32
|
+
-- Uses load(), but tries to be cautious about loading arbitrary code!
|
33
|
+
-- It is expecting a string of the form '{...}', with perhaps some whitespace
|
34
|
+
-- before or after the curly braces. A comment may occur beforehand.
|
35
|
+
-- An empty environment is used, and
|
36
|
+
-- any occurance of the keyword 'function' will be considered a problem.
|
37
|
+
-- in the given environment - the return value may be `nil`.
|
38
|
+
-- @param s {string} string of the form '{...}', with perhaps some whitespace
|
39
|
+
-- before or after the curly braces.
|
40
|
+
-- @return a table
|
41
|
+
function pretty.read(s)
|
42
|
+
assert_arg(1,s,'string')
|
43
|
+
if s:find '^%s*%-%-' then -- may start with a comment..
|
44
|
+
s = s:gsub('%-%-.-\n','')
|
45
|
+
end
|
46
|
+
if not s:find '^%s*%b{}%s*$' then return nil,"not a Lua table" end
|
47
|
+
if s:find '[^\'"%w_]function[^\'"%w_]' then
|
48
|
+
local tok = lexer.lua(s)
|
49
|
+
for t,v in tok do
|
50
|
+
if t == 'keyword' then
|
51
|
+
return nil,"cannot have functions in table definition"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
s = 'return '..s
|
56
|
+
local chunk,err = utils.load(s,'tbl','t',{})
|
57
|
+
if not chunk then return nil,err end
|
58
|
+
local SMT = save_string_index()
|
59
|
+
local ok,ret = pcall(chunk)
|
60
|
+
restore_string_index(SMT)
|
61
|
+
if ok then return ret
|
62
|
+
else
|
63
|
+
return nil,ret
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
--- read a Lua chunk.
|
68
|
+
-- @param s Lua code
|
69
|
+
-- @param env optional environment
|
70
|
+
-- @param paranoid prevent any looping constructs and disable string methods
|
71
|
+
-- @return the environment
|
72
|
+
function pretty.load (s, env, paranoid)
|
73
|
+
env = env or {}
|
74
|
+
if paranoid then
|
75
|
+
local tok = lexer.lua(s)
|
76
|
+
for t,v in tok do
|
77
|
+
if t == 'keyword'
|
78
|
+
and (v == 'for' or v == 'repeat' or v == 'function' or v == 'goto')
|
79
|
+
then
|
80
|
+
return nil,"looping not allowed"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
local chunk,err = utils.load(s,'tbl','t',env)
|
85
|
+
if not chunk then return nil,err end
|
86
|
+
local SMT = paranoid and save_string_index()
|
87
|
+
local ok,err = pcall(chunk)
|
88
|
+
restore_string_index(SMT)
|
89
|
+
if not ok then return nil,err end
|
90
|
+
return env
|
91
|
+
end
|
92
|
+
|
93
|
+
local function quote_if_necessary (v)
|
94
|
+
if not v then return ''
|
95
|
+
else
|
96
|
+
if v:find ' ' then v = '"'..v..'"' end
|
97
|
+
end
|
98
|
+
return v
|
99
|
+
end
|
100
|
+
|
101
|
+
local keywords
|
102
|
+
|
103
|
+
local function is_identifier (s)
|
104
|
+
return type(s) == 'string' and s:find('^[%a_][%w_]*$') and not keywords[s]
|
105
|
+
end
|
106
|
+
|
107
|
+
local function quote (s)
|
108
|
+
if type(s) == 'table' then
|
109
|
+
return pretty.write(s,'')
|
110
|
+
else
|
111
|
+
return ('%q'):format(tostring(s))
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
local function index (numkey,key)
|
116
|
+
if not numkey then key = quote(key) end
|
117
|
+
return '['..key..']'
|
118
|
+
end
|
119
|
+
|
120
|
+
|
121
|
+
--- Create a string representation of a Lua table.
|
122
|
+
-- This function never fails, but may complain by returning an
|
123
|
+
-- extra value. Normally puts out one item per line, using
|
124
|
+
-- the provided indent; set the second parameter to '' if
|
125
|
+
-- you want output on one line.
|
126
|
+
-- @param tbl {table} Table to serialize to a string.
|
127
|
+
-- @param space {string} (optional) The indent to use.
|
128
|
+
-- Defaults to two spaces; make it the empty string for no indentation
|
129
|
+
-- @param not_clever {bool} (optional) Use for plain output, e.g {['key']=1}.
|
130
|
+
-- Defaults to false.
|
131
|
+
-- @return a string
|
132
|
+
-- @return a possible error message
|
133
|
+
function pretty.write (tbl,space,not_clever)
|
134
|
+
if type(tbl) ~= 'table' then
|
135
|
+
local res = tostring(tbl)
|
136
|
+
if type(tbl) == 'string' then res = '"'..res..'"' end
|
137
|
+
return res, 'not a table'
|
138
|
+
end
|
139
|
+
if not keywords then
|
140
|
+
keywords = lexer.get_keywords()
|
141
|
+
end
|
142
|
+
local set = ' = '
|
143
|
+
if space == '' then set = '=' end
|
144
|
+
space = space or ' '
|
145
|
+
local lines = {}
|
146
|
+
local line = ''
|
147
|
+
local tables = {}
|
148
|
+
|
149
|
+
|
150
|
+
local function put(s)
|
151
|
+
if #s > 0 then
|
152
|
+
line = line..s
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
local function putln (s)
|
157
|
+
if #line > 0 then
|
158
|
+
line = line..s
|
159
|
+
append(lines,line)
|
160
|
+
line = ''
|
161
|
+
else
|
162
|
+
append(lines,s)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
local function eat_last_comma ()
|
167
|
+
local n,lastch = #lines
|
168
|
+
local lastch = lines[n]:sub(-1,-1)
|
169
|
+
if lastch == ',' then
|
170
|
+
lines[n] = lines[n]:sub(1,-2)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
|
175
|
+
local writeit
|
176
|
+
writeit = function (t,oldindent,indent)
|
177
|
+
local tp = type(t)
|
178
|
+
if tp ~= 'string' and tp ~= 'table' then
|
179
|
+
putln(quote_if_necessary(tostring(t))..',')
|
180
|
+
elseif tp == 'string' then
|
181
|
+
if t:find('\n') then
|
182
|
+
putln('[[\n'..t..']],')
|
183
|
+
else
|
184
|
+
putln(quote(t)..',')
|
185
|
+
end
|
186
|
+
elseif tp == 'table' then
|
187
|
+
if tables[t] then
|
188
|
+
putln('<cycle>,')
|
189
|
+
return
|
190
|
+
end
|
191
|
+
tables[t] = true
|
192
|
+
local newindent = indent..space
|
193
|
+
putln('{')
|
194
|
+
local used = {}
|
195
|
+
if not not_clever then
|
196
|
+
for i,val in ipairs(t) do
|
197
|
+
put(indent)
|
198
|
+
writeit(val,indent,newindent)
|
199
|
+
used[i] = true
|
200
|
+
end
|
201
|
+
end
|
202
|
+
for key,val in pairs(t) do
|
203
|
+
local numkey = type(key) == 'number'
|
204
|
+
if not_clever then
|
205
|
+
key = tostring(key)
|
206
|
+
put(indent..index(numkey,key)..set)
|
207
|
+
writeit(val,indent,newindent)
|
208
|
+
else
|
209
|
+
if not numkey or not used[key] then -- non-array indices
|
210
|
+
if numkey or not is_identifier(key) then
|
211
|
+
key = index(numkey,key)
|
212
|
+
end
|
213
|
+
put(indent..key..set)
|
214
|
+
writeit(val,indent,newindent)
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
eat_last_comma()
|
219
|
+
putln(oldindent..'},')
|
220
|
+
else
|
221
|
+
putln(tostring(t)..',')
|
222
|
+
end
|
223
|
+
end
|
224
|
+
writeit(tbl,'',space)
|
225
|
+
eat_last_comma()
|
226
|
+
return concat(lines,#space > 0 and '\n' or '')
|
227
|
+
end
|
228
|
+
|
229
|
+
--- Dump a Lua table out to a file or stdout.
|
230
|
+
-- @param t {table} The table to write to a file or stdout.
|
231
|
+
-- @param ... {string} (optional) File name to write too. Defaults to writing
|
232
|
+
-- to stdout.
|
233
|
+
function pretty.dump (t,...)
|
234
|
+
if select('#',...)==0 then
|
235
|
+
print(pretty.write(t))
|
236
|
+
return true
|
237
|
+
else
|
238
|
+
return utils.writefile(...,pretty.write(t))
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
local memp,nump = {'B','KiB','MiB','GiB'},{'','K','M','B'}
|
243
|
+
|
244
|
+
local comma
|
245
|
+
function comma (val)
|
246
|
+
local thou = math.floor(val/1000)
|
247
|
+
if thou > 0 then return comma(thou)..','..(val % 1000)
|
248
|
+
else return tostring(val) end
|
249
|
+
end
|
250
|
+
|
251
|
+
--- format large numbers nicely for human consumption.
|
252
|
+
-- @param num a number
|
253
|
+
-- @param kind one of 'M' (memory in KiB etc), 'N' (postfixes are 'K','M' and 'B')
|
254
|
+
-- and 'T' (use commas as thousands separator)
|
255
|
+
-- @param prec number of digits to use for 'M' and 'N' (default 1)
|
256
|
+
function pretty.number (num,kind,prec)
|
257
|
+
local fmt = '%.'..(prec or 1)..'f%s'
|
258
|
+
if kind == 'T' then
|
259
|
+
return comma(num)
|
260
|
+
else
|
261
|
+
local postfixes, fact
|
262
|
+
if kind == 'M' then
|
263
|
+
fact = 1024
|
264
|
+
postfixes = memp
|
265
|
+
else
|
266
|
+
fact = 1000
|
267
|
+
postfixes = nump
|
268
|
+
end
|
269
|
+
local div = fact
|
270
|
+
local k = 1
|
271
|
+
while num >= div and k <= #postfixes do
|
272
|
+
div = div * fact
|
273
|
+
k = k + 1
|
274
|
+
end
|
275
|
+
div = div / fact
|
276
|
+
if k > #postfixes then k = k - 1; div = div/fact end
|
277
|
+
if k > 1 then
|
278
|
+
return fmt:format(num/div,postfixes[k] or 'duh')
|
279
|
+
else
|
280
|
+
return num..postfixes[1]
|
281
|
+
end
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
return pretty
|
@@ -0,0 +1,551 @@
|
|
1
|
+
--- Manipulating iterators as sequences.
|
2
|
+
-- See @{07-functional.md.Sequences|The Guide}
|
3
|
+
--
|
4
|
+
-- Dependencies: `pl.utils`, `debug`
|
5
|
+
-- @module pl.seq
|
6
|
+
|
7
|
+
local next,assert,type,pairs,tonumber,type,setmetatable,getmetatable,_G = next,assert,type,pairs,tonumber,type,setmetatable,getmetatable,_G
|
8
|
+
local strfind,strmatch,format = string.find,string.match,string.format
|
9
|
+
local mrandom = math.random
|
10
|
+
local remove,tsort,tappend = table.remove,table.sort,table.insert
|
11
|
+
local io = io
|
12
|
+
local utils = require 'pl.utils'
|
13
|
+
local function_arg = utils.function_arg
|
14
|
+
local _List = utils.stdmt.List
|
15
|
+
local _Map = utils.stdmt.Map
|
16
|
+
local assert_arg = utils.assert_arg
|
17
|
+
local debug = require 'debug'
|
18
|
+
|
19
|
+
local seq = {}
|
20
|
+
|
21
|
+
-- given a number, return a function(y) which returns true if y > x
|
22
|
+
-- @param x a number
|
23
|
+
function seq.greater_than(x)
|
24
|
+
return function(v)
|
25
|
+
return tonumber(v) > x
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
-- given a number, returns a function(y) which returns true if y < x
|
30
|
+
-- @param x a number
|
31
|
+
function seq.less_than(x)
|
32
|
+
return function(v)
|
33
|
+
return tonumber(v) < x
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
-- given any value, return a function(y) which returns true if y == x
|
38
|
+
-- @param x a value
|
39
|
+
function seq.equal_to(x)
|
40
|
+
if type(x) == "number" then
|
41
|
+
return function(v)
|
42
|
+
return tonumber(v) == x
|
43
|
+
end
|
44
|
+
else
|
45
|
+
return function(v)
|
46
|
+
return v == x
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
--- given a string, return a function(y) which matches y against the string.
|
52
|
+
-- @param s a string
|
53
|
+
function seq.matching(s)
|
54
|
+
return function(v)
|
55
|
+
return strfind(v,s)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
local nexti
|
60
|
+
|
61
|
+
--- sequence adaptor for a table. Note that if any generic function is
|
62
|
+
-- passed a table, it will automatically use seq.list()
|
63
|
+
-- @param t a list-like table
|
64
|
+
-- @usage sum(list(t)) is the sum of all elements of t
|
65
|
+
-- @usage for x in list(t) do...end
|
66
|
+
function seq.list(t)
|
67
|
+
assert_arg(1,t,'table')
|
68
|
+
if not nexti then
|
69
|
+
nexti = ipairs{}
|
70
|
+
end
|
71
|
+
local key,value = 0
|
72
|
+
return function()
|
73
|
+
key,value = nexti(t,key)
|
74
|
+
return value
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
--- return the keys of the table.
|
79
|
+
-- @param t an arbitrary table
|
80
|
+
-- @return iterator over keys
|
81
|
+
function seq.keys(t)
|
82
|
+
assert_arg(1,t,'table')
|
83
|
+
local key,value
|
84
|
+
return function()
|
85
|
+
key,value = next(t,key)
|
86
|
+
return key
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
local list = seq.list
|
91
|
+
local function default_iter(iter)
|
92
|
+
if type(iter) == 'table' then return list(iter)
|
93
|
+
else return iter end
|
94
|
+
end
|
95
|
+
|
96
|
+
seq.iter = default_iter
|
97
|
+
|
98
|
+
--- create an iterator over a numerical range. Like the standard Python function xrange.
|
99
|
+
-- @param start a number
|
100
|
+
-- @param finish a number greater than start
|
101
|
+
function seq.range(start,finish)
|
102
|
+
local i = start - 1
|
103
|
+
return function()
|
104
|
+
i = i + 1
|
105
|
+
if i > finish then return nil
|
106
|
+
else return i end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
-- count the number of elements in the sequence which satisfy the predicate
|
111
|
+
-- @param iter a sequence
|
112
|
+
-- @param condn a predicate function (must return either true or false)
|
113
|
+
-- @param optional argument to be passed to predicate as second argument.
|
114
|
+
-- @return count
|
115
|
+
function seq.count(iter,condn,arg)
|
116
|
+
local i = 0
|
117
|
+
seq.foreach(iter,function(val)
|
118
|
+
if condn(val,arg) then i = i + 1 end
|
119
|
+
end)
|
120
|
+
return i
|
121
|
+
end
|
122
|
+
|
123
|
+
--- return the minimum and the maximum value of the sequence.
|
124
|
+
-- @param iter a sequence
|
125
|
+
-- @return minimum value
|
126
|
+
-- @return maximum value
|
127
|
+
function seq.minmax(iter)
|
128
|
+
local vmin,vmax = 1e70,-1e70
|
129
|
+
for v in default_iter(iter) do
|
130
|
+
v = tonumber(v)
|
131
|
+
if v < vmin then vmin = v end
|
132
|
+
if v > vmax then vmax = v end
|
133
|
+
end
|
134
|
+
return vmin,vmax
|
135
|
+
end
|
136
|
+
|
137
|
+
--- return the sum and element count of the sequence.
|
138
|
+
-- @param iter a sequence
|
139
|
+
-- @param fn an optional function to apply to the values
|
140
|
+
function seq.sum(iter,fn)
|
141
|
+
local s = 0
|
142
|
+
local i = 0
|
143
|
+
for v in default_iter(iter) do
|
144
|
+
if fn then v = fn(v) end
|
145
|
+
s = s + v
|
146
|
+
i = i + 1
|
147
|
+
end
|
148
|
+
return s,i
|
149
|
+
end
|
150
|
+
|
151
|
+
--- create a table from the sequence. (This will make the result a List.)
|
152
|
+
-- @param iter a sequence
|
153
|
+
-- @return a List
|
154
|
+
-- @usage copy(list(ls)) is equal to ls
|
155
|
+
-- @usage copy(list {1,2,3}) == List{1,2,3}
|
156
|
+
function seq.copy(iter)
|
157
|
+
local res,k = {},1
|
158
|
+
for v in default_iter(iter) do
|
159
|
+
res[k] = v
|
160
|
+
k = k + 1
|
161
|
+
end
|
162
|
+
setmetatable(res,_List)
|
163
|
+
return res
|
164
|
+
end
|
165
|
+
|
166
|
+
--- create a table of pairs from the double-valued sequence.
|
167
|
+
-- @param iter a double-valued sequence
|
168
|
+
-- @param i1 used to capture extra iterator values
|
169
|
+
-- @param i2 as with pairs & ipairs
|
170
|
+
-- @usage copy2(ipairs{10,20,30}) == {{1,10},{2,20},{3,30}}
|
171
|
+
-- @return a list-like table
|
172
|
+
function seq.copy2 (iter,i1,i2)
|
173
|
+
local res,k = {},1
|
174
|
+
for v1,v2 in iter,i1,i2 do
|
175
|
+
res[k] = {v1,v2}
|
176
|
+
k = k + 1
|
177
|
+
end
|
178
|
+
return res
|
179
|
+
end
|
180
|
+
|
181
|
+
--- create a table of 'tuples' from a multi-valued sequence.
|
182
|
+
-- A generalization of copy2 above
|
183
|
+
-- @param iter a multiple-valued sequence
|
184
|
+
-- @return a list-like table
|
185
|
+
function seq.copy_tuples (iter)
|
186
|
+
iter = default_iter(iter)
|
187
|
+
local res = {}
|
188
|
+
local row = {iter()}
|
189
|
+
while #row > 0 do
|
190
|
+
tappend(res,row)
|
191
|
+
row = {iter()}
|
192
|
+
end
|
193
|
+
return res
|
194
|
+
end
|
195
|
+
|
196
|
+
--- return an iterator of random numbers.
|
197
|
+
-- @param n the length of the sequence
|
198
|
+
-- @param l same as the first optional argument to math.random
|
199
|
+
-- @param u same as the second optional argument to math.random
|
200
|
+
-- @return a sequnce
|
201
|
+
function seq.random(n,l,u)
|
202
|
+
local rand
|
203
|
+
assert(type(n) == 'number')
|
204
|
+
if u then
|
205
|
+
rand = function() return mrandom(l,u) end
|
206
|
+
elseif l then
|
207
|
+
rand = function() return mrandom(l) end
|
208
|
+
else
|
209
|
+
rand = mrandom
|
210
|
+
end
|
211
|
+
|
212
|
+
return function()
|
213
|
+
if n == 0 then return nil
|
214
|
+
else
|
215
|
+
n = n - 1
|
216
|
+
return rand()
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
--- return an iterator to the sorted elements of a sequence.
|
222
|
+
-- @param iter a sequence
|
223
|
+
-- @param comp an optional comparison function (comp(x,y) is true if x < y)
|
224
|
+
function seq.sort(iter,comp)
|
225
|
+
local t = seq.copy(iter)
|
226
|
+
tsort(t,comp)
|
227
|
+
return list(t)
|
228
|
+
end
|
229
|
+
|
230
|
+
--- return an iterator which returns elements of two sequences.
|
231
|
+
-- @param iter1 a sequence
|
232
|
+
-- @param iter2 a sequence
|
233
|
+
-- @usage for x,y in seq.zip(ls1,ls2) do....end
|
234
|
+
function seq.zip(iter1,iter2)
|
235
|
+
iter1 = default_iter(iter1)
|
236
|
+
iter2 = default_iter(iter2)
|
237
|
+
return function()
|
238
|
+
return iter1(),iter2()
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
--- Makes a table where the key/values are the values and value counts of the sequence.
|
243
|
+
-- This version works with 'hashable' values like strings and numbers.
|
244
|
+
-- `pl.tablex.count_map` is more general.
|
245
|
+
-- @param iter a sequence
|
246
|
+
-- @return a map-like table
|
247
|
+
-- @return a table
|
248
|
+
-- @see pl.tablex.count_map
|
249
|
+
function seq.count_map(iter)
|
250
|
+
local t = {}
|
251
|
+
local v
|
252
|
+
for s in default_iter(iter) do
|
253
|
+
v = t[s]
|
254
|
+
if v then t[s] = v + 1
|
255
|
+
else t[s] = 1 end
|
256
|
+
end
|
257
|
+
return setmetatable(t,_Map)
|
258
|
+
end
|
259
|
+
|
260
|
+
-- given a sequence, return all the unique values in that sequence.
|
261
|
+
-- @param iter a sequence
|
262
|
+
-- @param returns_table true if we return a table, not a sequence
|
263
|
+
-- @return a sequence or a table; defaults to a sequence.
|
264
|
+
function seq.unique(iter,returns_table)
|
265
|
+
local t = seq.count_map(iter)
|
266
|
+
local res,k = {},1
|
267
|
+
for key in pairs(t) do res[k] = key; k = k + 1 end
|
268
|
+
table.sort(res)
|
269
|
+
if returns_table then
|
270
|
+
return res
|
271
|
+
else
|
272
|
+
return list(res)
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
--- print out a sequence iter with a separator.
|
277
|
+
-- @param iter a sequence
|
278
|
+
-- @param sep the separator (default space)
|
279
|
+
-- @param nfields maximum number of values per line (default 7)
|
280
|
+
-- @param fmt optional format function for each value
|
281
|
+
function seq.printall(iter,sep,nfields,fmt)
|
282
|
+
local write = io.write
|
283
|
+
if not sep then sep = ' ' end
|
284
|
+
if not nfields then
|
285
|
+
if sep == '\n' then nfields = 1e30
|
286
|
+
else nfields = 7 end
|
287
|
+
end
|
288
|
+
if fmt then
|
289
|
+
local fstr = fmt
|
290
|
+
fmt = function(v) return format(fstr,v) end
|
291
|
+
end
|
292
|
+
local k = 1
|
293
|
+
for v in default_iter(iter) do
|
294
|
+
if fmt then v = fmt(v) end
|
295
|
+
if k < nfields then
|
296
|
+
write(v,sep)
|
297
|
+
k = k + 1
|
298
|
+
else
|
299
|
+
write(v,'\n')
|
300
|
+
k = 1
|
301
|
+
end
|
302
|
+
end
|
303
|
+
write '\n'
|
304
|
+
end
|
305
|
+
|
306
|
+
-- return an iterator running over every element of two sequences (concatenation).
|
307
|
+
-- @param iter1 a sequence
|
308
|
+
-- @param iter2 a sequence
|
309
|
+
function seq.splice(iter1,iter2)
|
310
|
+
iter1 = default_iter(iter1)
|
311
|
+
iter2 = default_iter(iter2)
|
312
|
+
local iter = iter1
|
313
|
+
return function()
|
314
|
+
local ret = iter()
|
315
|
+
if ret == nil then
|
316
|
+
if iter == iter1 then
|
317
|
+
iter = iter2
|
318
|
+
return iter()
|
319
|
+
else return nil end
|
320
|
+
else
|
321
|
+
return ret
|
322
|
+
end
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
--- return a sequence where every element of a sequence has been transformed
|
327
|
+
-- by a function. If you don't supply an argument, then the function will
|
328
|
+
-- receive both values of a double-valued sequence, otherwise behaves rather like
|
329
|
+
-- tablex.map.
|
330
|
+
-- @param fn a function to apply to elements; may take two arguments
|
331
|
+
-- @param iter a sequence of one or two values
|
332
|
+
-- @param arg optional argument to pass to function.
|
333
|
+
function seq.map(fn,iter,arg)
|
334
|
+
fn = function_arg(1,fn)
|
335
|
+
iter = default_iter(iter)
|
336
|
+
return function()
|
337
|
+
local v1,v2 = iter()
|
338
|
+
if v1 == nil then return nil end
|
339
|
+
if arg then return fn(v1,arg) or false
|
340
|
+
else return fn(v1,v2) or false
|
341
|
+
end
|
342
|
+
end
|
343
|
+
end
|
344
|
+
|
345
|
+
--- filter a sequence using a predicate function.
|
346
|
+
-- @param iter a sequence of one or two values
|
347
|
+
-- @param pred a boolean function; may take two arguments
|
348
|
+
-- @param arg optional argument to pass to function.
|
349
|
+
function seq.filter (iter,pred,arg)
|
350
|
+
pred = function_arg(2,pred)
|
351
|
+
return function ()
|
352
|
+
local v1,v2
|
353
|
+
while true do
|
354
|
+
v1,v2 = iter()
|
355
|
+
if v1 == nil then return nil end
|
356
|
+
if arg then
|
357
|
+
if pred(v1,arg) then return v1,v2 end
|
358
|
+
else
|
359
|
+
if pred(v1,v2) then return v1,v2 end
|
360
|
+
end
|
361
|
+
end
|
362
|
+
end
|
363
|
+
end
|
364
|
+
|
365
|
+
--- 'reduce' a sequence using a binary function.
|
366
|
+
-- @param fun a function of two arguments
|
367
|
+
-- @param iter a sequence
|
368
|
+
-- @param oldval optional initial value
|
369
|
+
-- @usage seq.reduce(operator.add,seq.list{1,2,3,4}) == 10
|
370
|
+
-- @usage seq.reduce('-',{1,2,3,4,5}) == -13
|
371
|
+
function seq.reduce (fun,iter,oldval)
|
372
|
+
fun = function_arg(1,fun)
|
373
|
+
iter = default_iter(iter)
|
374
|
+
if not oldval then
|
375
|
+
oldval = iter()
|
376
|
+
end
|
377
|
+
local val = oldval
|
378
|
+
for v in iter do
|
379
|
+
val = fun(val,v)
|
380
|
+
end
|
381
|
+
return val
|
382
|
+
end
|
383
|
+
|
384
|
+
--- take the first n values from the sequence.
|
385
|
+
-- @param iter a sequence of one or two values
|
386
|
+
-- @param n number of items to take
|
387
|
+
-- @return a sequence of at most n items
|
388
|
+
function seq.take (iter,n)
|
389
|
+
local i = 1
|
390
|
+
iter = default_iter(iter)
|
391
|
+
return function()
|
392
|
+
if i > n then return end
|
393
|
+
local val1,val2 = iter()
|
394
|
+
if not val1 then return end
|
395
|
+
i = i + 1
|
396
|
+
return val1,val2
|
397
|
+
end
|
398
|
+
end
|
399
|
+
|
400
|
+
--- skip the first n values of a sequence
|
401
|
+
-- @param iter a sequence of one or more values
|
402
|
+
-- @param n number of items to skip
|
403
|
+
function seq.skip (iter,n)
|
404
|
+
n = n or 1
|
405
|
+
for i = 1,n do iter() end
|
406
|
+
return iter
|
407
|
+
end
|
408
|
+
|
409
|
+
--- a sequence with a sequence count and the original value.
|
410
|
+
-- enum(copy(ls)) is a roundabout way of saying ipairs(ls).
|
411
|
+
-- @param iter a single or double valued sequence
|
412
|
+
-- @return sequence of (i,v), i = 1..n and v is from iter.
|
413
|
+
function seq.enum (iter)
|
414
|
+
local i = 0
|
415
|
+
iter = default_iter(iter)
|
416
|
+
return function ()
|
417
|
+
local val1,val2 = iter()
|
418
|
+
if not val1 then return end
|
419
|
+
i = i + 1
|
420
|
+
return i,val1,val2
|
421
|
+
end
|
422
|
+
end
|
423
|
+
|
424
|
+
--- map using a named method over a sequence.
|
425
|
+
-- @param iter a sequence
|
426
|
+
-- @param name the method name
|
427
|
+
-- @param arg1 optional first extra argument
|
428
|
+
-- @param arg2 optional second extra argument
|
429
|
+
function seq.mapmethod (iter,name,arg1,arg2)
|
430
|
+
iter = default_iter(iter)
|
431
|
+
return function()
|
432
|
+
local val = iter()
|
433
|
+
if not val then return end
|
434
|
+
local fn = val[name]
|
435
|
+
if not fn then error(type(val).." does not have method "..name) end
|
436
|
+
return fn(val,arg1,arg2)
|
437
|
+
end
|
438
|
+
end
|
439
|
+
|
440
|
+
--- a sequence of (last,current) values from another sequence.
|
441
|
+
-- This will return S(i-1),S(i) if given S(i)
|
442
|
+
-- @param iter a sequence
|
443
|
+
function seq.last (iter)
|
444
|
+
iter = default_iter(iter)
|
445
|
+
local l = iter()
|
446
|
+
if l == nil then return nil end
|
447
|
+
return function ()
|
448
|
+
local val,ll
|
449
|
+
val = iter()
|
450
|
+
if val == nil then return nil end
|
451
|
+
ll = l
|
452
|
+
l = val
|
453
|
+
return val,ll
|
454
|
+
end
|
455
|
+
end
|
456
|
+
|
457
|
+
--- call the function on each element of the sequence.
|
458
|
+
-- @param iter a sequence with up to 3 values
|
459
|
+
-- @param fn a function
|
460
|
+
function seq.foreach(iter,fn)
|
461
|
+
fn = function_arg(2,fn)
|
462
|
+
for i1,i2,i3 in default_iter(iter) do fn(i1,i2,i3) end
|
463
|
+
end
|
464
|
+
|
465
|
+
---------------------- Sequence Adapters ---------------------
|
466
|
+
|
467
|
+
local SMT
|
468
|
+
local callable = utils.is_callable
|
469
|
+
|
470
|
+
local function SW (iter,...)
|
471
|
+
if callable(iter) then
|
472
|
+
return setmetatable({iter=iter},SMT)
|
473
|
+
else
|
474
|
+
return iter,...
|
475
|
+
end
|
476
|
+
end
|
477
|
+
|
478
|
+
|
479
|
+
-- can't directly look these up in seq because of the wrong argument order...
|
480
|
+
local map,reduce,mapmethod = seq.map, seq.reduce, seq.mapmethod
|
481
|
+
local overrides = {
|
482
|
+
map = function(self,fun,arg)
|
483
|
+
return map(fun,self,arg)
|
484
|
+
end,
|
485
|
+
reduce = function(self,fun)
|
486
|
+
return reduce(fun,self)
|
487
|
+
end
|
488
|
+
}
|
489
|
+
|
490
|
+
SMT = {
|
491
|
+
__index = function (tbl,key)
|
492
|
+
local fn = overrides[key] or seq[key]
|
493
|
+
if fn then
|
494
|
+
return function(sw,...) return SW(fn(sw.iter,...)) end
|
495
|
+
else
|
496
|
+
return function(sw,...) return SW(mapmethod(sw.iter,key,...)) end
|
497
|
+
end
|
498
|
+
end,
|
499
|
+
__call = function (sw)
|
500
|
+
return sw.iter()
|
501
|
+
end,
|
502
|
+
}
|
503
|
+
|
504
|
+
setmetatable(seq,{
|
505
|
+
__call = function(tbl,iter)
|
506
|
+
if not callable(iter) then
|
507
|
+
if type(iter) == 'table' then iter = seq.list(iter)
|
508
|
+
else return iter
|
509
|
+
end
|
510
|
+
end
|
511
|
+
return setmetatable({iter=iter},SMT)
|
512
|
+
end
|
513
|
+
})
|
514
|
+
|
515
|
+
--- create a wrapped iterator over all lines in the file.
|
516
|
+
-- @param f either a filename, file-like object, or 'STDIN' (for standard input)
|
517
|
+
-- @param ... for Lua 5.2 only, optional format specifiers, as in `io.read`.
|
518
|
+
-- @return a sequence wrapper
|
519
|
+
function seq.lines (f,...)
|
520
|
+
local n = select('#',...)
|
521
|
+
local iter,obj
|
522
|
+
if f == 'STDIN' then
|
523
|
+
f = io.stdin
|
524
|
+
elseif type(f) == 'string' then
|
525
|
+
iter,obj = io.lines(f,...)
|
526
|
+
elseif not f.read then
|
527
|
+
error("Pass either a string or a file-like object",2)
|
528
|
+
end
|
529
|
+
if not iter then
|
530
|
+
iter,obj = f:lines(...)
|
531
|
+
end
|
532
|
+
if obj then -- LuaJIT version returns a function operating on a file
|
533
|
+
local lines,file = iter,obj
|
534
|
+
iter = function() return lines(file) end
|
535
|
+
end
|
536
|
+
return SW(iter)
|
537
|
+
end
|
538
|
+
|
539
|
+
function seq.import ()
|
540
|
+
_G.debug.setmetatable(function() end,{
|
541
|
+
__index = function(tbl,key)
|
542
|
+
local s = overrides[key] or seq[key]
|
543
|
+
if s then return s
|
544
|
+
else
|
545
|
+
return function(s,...) return seq.mapmethod(s,key,...) end
|
546
|
+
end
|
547
|
+
end
|
548
|
+
})
|
549
|
+
end
|
550
|
+
|
551
|
+
return seq
|