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,165 @@
|
|
1
|
+
--- Application support functions.
|
2
|
+
-- See @{01-introduction.md.Application_Support|the Guide}
|
3
|
+
--
|
4
|
+
-- Dependencies: `pl.utils`, `pl.path`, `lfs`
|
5
|
+
-- @module pl.app
|
6
|
+
|
7
|
+
local io,package,require = _G.io, _G.package, _G.require
|
8
|
+
local utils = require 'pl.utils'
|
9
|
+
local path = require 'pl.path'
|
10
|
+
local lfs = require 'lfs'
|
11
|
+
|
12
|
+
|
13
|
+
local app = {}
|
14
|
+
|
15
|
+
local function check_script_name ()
|
16
|
+
if _G.arg == nil then error('no command line args available\nWas this run from a main script?') end
|
17
|
+
return _G.arg[0]
|
18
|
+
end
|
19
|
+
|
20
|
+
--- add the current script's path to the Lua module path.
|
21
|
+
-- Applies to both the source and the binary module paths. It makes it easy for
|
22
|
+
-- the main file of a multi-file program to access its modules in the same directory.
|
23
|
+
-- `base` allows these modules to be put in a specified subdirectory, to allow for
|
24
|
+
-- cleaner deployment and resolve potential conflicts between a script name and its
|
25
|
+
-- library directory.
|
26
|
+
-- @param base optional base directory.
|
27
|
+
-- @return the current script's path with a trailing slash
|
28
|
+
function app.require_here (base)
|
29
|
+
local p = path.dirname(check_script_name())
|
30
|
+
if not path.isabs(p) then
|
31
|
+
p = path.join(lfs.currentdir(),p)
|
32
|
+
end
|
33
|
+
if p:sub(-1,-1) ~= path.sep then
|
34
|
+
p = p..path.sep
|
35
|
+
end
|
36
|
+
if base then
|
37
|
+
p = p..base..path.sep
|
38
|
+
end
|
39
|
+
local so_ext = path.is_windows and 'dll' or 'so'
|
40
|
+
local lsep = package.path:find '^;' and '' or ';'
|
41
|
+
local csep = package.cpath:find '^;' and '' or ';'
|
42
|
+
package.path = ('%s?.lua;%s?%sinit.lua%s%s'):format(p,p,path.sep,lsep,package.path)
|
43
|
+
package.cpath = ('%s?.%s%s%s'):format(p,so_ext,csep,package.cpath)
|
44
|
+
return p
|
45
|
+
end
|
46
|
+
|
47
|
+
--- return a suitable path for files private to this application.
|
48
|
+
-- These will look like '~/.SNAME/file', with '~' as with expanduser and
|
49
|
+
-- SNAME is the name of the script without .lua extension.
|
50
|
+
-- @param file a filename (w/out path)
|
51
|
+
-- @return a full pathname, or nil
|
52
|
+
-- @return 'cannot create' error
|
53
|
+
function app.appfile (file)
|
54
|
+
local sname = path.basename(check_script_name())
|
55
|
+
local name,ext = path.splitext(sname)
|
56
|
+
local dir = path.join(path.expanduser('~'),'.'..name)
|
57
|
+
if not path.isdir(dir) then
|
58
|
+
local ret = lfs.mkdir(dir)
|
59
|
+
if not ret then return utils.raise ('cannot create '..dir) end
|
60
|
+
end
|
61
|
+
return path.join(dir,file)
|
62
|
+
end
|
63
|
+
|
64
|
+
--- return string indicating operating system.
|
65
|
+
-- @return 'Windows','OSX' or whatever uname returns (e.g. 'Linux')
|
66
|
+
function app.platform()
|
67
|
+
if path.is_windows then
|
68
|
+
return 'Windows'
|
69
|
+
else
|
70
|
+
local f = io.popen('uname')
|
71
|
+
local res = f:read()
|
72
|
+
if res == 'Darwin' then res = 'OSX' end
|
73
|
+
f:close()
|
74
|
+
return res
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
--- return the full command-line used to invoke this script
|
79
|
+
-- any extra flags occupy slots, so that 'lua -lpl' gives us {[-2]='lua',[-1]='-lpl')
|
80
|
+
-- @return command-line
|
81
|
+
-- @return name of Lua program used
|
82
|
+
function app.lua ()
|
83
|
+
local args = _G.arg or error "not in a main program"
|
84
|
+
local imin = 0
|
85
|
+
for i in pairs(args) do
|
86
|
+
if i < imin then imin = i end
|
87
|
+
end
|
88
|
+
local cmd, append = {}, table.insert
|
89
|
+
for i = imin,-1 do
|
90
|
+
local a = args[i]
|
91
|
+
if a:match '%s' then
|
92
|
+
a = '"'..a..'"'
|
93
|
+
end
|
94
|
+
append(cmd,a)
|
95
|
+
end
|
96
|
+
return table.concat(cmd,' '),args[imin]
|
97
|
+
end
|
98
|
+
|
99
|
+
--- parse command-line arguments into flags and parameters.
|
100
|
+
-- Understands GNU-style command-line flags; short (-f) and long (--flag).
|
101
|
+
-- These may be given a value with either '=' or ':' (-k:2,--alpha=3.2,-n2);
|
102
|
+
-- note that a number value can be given without a space.
|
103
|
+
-- Multiple short args can be combined like so: (-abcd).
|
104
|
+
-- @param args an array of strings (default is the global 'arg')
|
105
|
+
-- @param flags_with_values any flags that take values, e.g. <code>{out=true}</code>
|
106
|
+
-- @return a table of flags (flag=value pairs)
|
107
|
+
-- @return an array of parameters
|
108
|
+
-- @raise if args is nil, then the global `args` must be available!
|
109
|
+
function app.parse_args (args,flags_with_values)
|
110
|
+
if not args then
|
111
|
+
args = _G.arg
|
112
|
+
if not args then error "Not in a main program: 'arg' not found" end
|
113
|
+
end
|
114
|
+
flags_with_values = flags_with_values or {}
|
115
|
+
local _args = {}
|
116
|
+
local flags = {}
|
117
|
+
local i = 1
|
118
|
+
while i <= #args do
|
119
|
+
local a = args[i]
|
120
|
+
local v = a:match('^-(.+)')
|
121
|
+
local is_long
|
122
|
+
if v then -- we have a flag
|
123
|
+
if v:find '^-' then
|
124
|
+
is_long = true
|
125
|
+
v = v:sub(2)
|
126
|
+
end
|
127
|
+
if flags_with_values[v] then
|
128
|
+
if i == #_args or args[i+1]:find '^-' then
|
129
|
+
return utils.raise ("no value for '"..v.."'")
|
130
|
+
end
|
131
|
+
flags[v] = args[i+1]
|
132
|
+
i = i + 1
|
133
|
+
else
|
134
|
+
-- a value can be indicated with = or :
|
135
|
+
local var,val = utils.splitv (v,'[=:]')
|
136
|
+
var = var or v
|
137
|
+
val = val or true
|
138
|
+
if not is_long then
|
139
|
+
if #var > 1 then
|
140
|
+
if var:find '.%d+' then -- short flag, number value
|
141
|
+
val = var:sub(2)
|
142
|
+
var = var:sub(1,1)
|
143
|
+
else -- multiple short flags
|
144
|
+
for i = 1,#var do
|
145
|
+
flags[var:sub(i,i)] = true
|
146
|
+
end
|
147
|
+
val = nil -- prevents use of var as a flag below
|
148
|
+
end
|
149
|
+
else -- single short flag (can have value, defaults to true)
|
150
|
+
val = val or true
|
151
|
+
end
|
152
|
+
end
|
153
|
+
if val then
|
154
|
+
flags[var] = val
|
155
|
+
end
|
156
|
+
end
|
157
|
+
else
|
158
|
+
_args[#_args+1] = a
|
159
|
+
end
|
160
|
+
i = i + 1
|
161
|
+
end
|
162
|
+
return flags,_args
|
163
|
+
end
|
164
|
+
|
165
|
+
return app
|
@@ -0,0 +1,501 @@
|
|
1
|
+
--- Operations on two-dimensional arrays.
|
2
|
+
-- See @{02-arrays.md.Operations_on_two_dimensional_tables|The Guide}
|
3
|
+
--
|
4
|
+
-- Dependencies: `pl.utils`, `pl.tablex`
|
5
|
+
-- @module pl.array2d
|
6
|
+
|
7
|
+
local require, type,tonumber,assert,tostring,io,ipairs,string,table =
|
8
|
+
_G.require, _G.type,_G.tonumber,_G.assert,_G.tostring,_G.io,_G.ipairs,_G.string,_G.table
|
9
|
+
local setmetatable,getmetatable = setmetatable,getmetatable
|
10
|
+
|
11
|
+
local tablex = require 'pl.tablex'
|
12
|
+
local utils = require 'pl.utils'
|
13
|
+
|
14
|
+
local imap,tmap,reduce,keys,tmap2,tset,index_by = tablex.imap,tablex.map,tablex.reduce,tablex.keys,tablex.map2,tablex.set,tablex.index_by
|
15
|
+
local remove = table.remove
|
16
|
+
local splitv,fprintf,assert_arg = utils.splitv,utils.fprintf,utils.assert_arg
|
17
|
+
local byte = string.byte
|
18
|
+
local stdout = io.stdout
|
19
|
+
|
20
|
+
local array2d = {}
|
21
|
+
|
22
|
+
local function obj (int,out)
|
23
|
+
local mt = getmetatable(int)
|
24
|
+
if mt then
|
25
|
+
setmetatable(out,mt)
|
26
|
+
end
|
27
|
+
return out
|
28
|
+
end
|
29
|
+
|
30
|
+
local function makelist (res)
|
31
|
+
return setmetatable(res,utils.stdmt.List)
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
local function index (t,k)
|
36
|
+
return t[k]
|
37
|
+
end
|
38
|
+
|
39
|
+
--- return the row and column size.
|
40
|
+
-- @param t a 2d array
|
41
|
+
-- @return number of rows
|
42
|
+
-- @return number of cols
|
43
|
+
function array2d.size (t)
|
44
|
+
assert_arg(1,t,'table')
|
45
|
+
return #t,#t[1]
|
46
|
+
end
|
47
|
+
|
48
|
+
--- extract a column from the 2D array.
|
49
|
+
-- @param a 2d array
|
50
|
+
-- @param key an index or key
|
51
|
+
-- @return 1d array
|
52
|
+
function array2d.column (a,key)
|
53
|
+
assert_arg(1,a,'table')
|
54
|
+
return makelist(imap(index,a,key))
|
55
|
+
end
|
56
|
+
local column = array2d.column
|
57
|
+
|
58
|
+
--- map a function over a 2D array
|
59
|
+
-- @param f a function of at least one argument
|
60
|
+
-- @param a 2d array
|
61
|
+
-- @param arg an optional extra argument to be passed to the function.
|
62
|
+
-- @return 2d array
|
63
|
+
function array2d.map (f,a,arg)
|
64
|
+
assert_arg(1,a,'table')
|
65
|
+
f = utils.function_arg(1,f)
|
66
|
+
return obj(a,imap(function(row) return imap(f,row,arg) end, a))
|
67
|
+
end
|
68
|
+
|
69
|
+
--- reduce the rows using a function.
|
70
|
+
-- @param f a binary function
|
71
|
+
-- @param a 2d array
|
72
|
+
-- @return 1d array
|
73
|
+
-- @see pl.tablex.reduce
|
74
|
+
function array2d.reduce_rows (f,a)
|
75
|
+
assert_arg(1,a,'table')
|
76
|
+
return tmap(function(row) return reduce(f,row) end, a)
|
77
|
+
end
|
78
|
+
|
79
|
+
--- reduce the columns using a function.
|
80
|
+
-- @param f a binary function
|
81
|
+
-- @param a 2d array
|
82
|
+
-- @return 1d array
|
83
|
+
-- @see pl.tablex.reduce
|
84
|
+
function array2d.reduce_cols (f,a)
|
85
|
+
assert_arg(1,a,'table')
|
86
|
+
return tmap(function(c) return reduce(f,column(a,c)) end, keys(a[1]))
|
87
|
+
end
|
88
|
+
|
89
|
+
--- reduce a 2D array into a scalar, using two operations.
|
90
|
+
-- @param opc operation to reduce the final result
|
91
|
+
-- @param opr operation to reduce the rows
|
92
|
+
-- @param a 2D array
|
93
|
+
function array2d.reduce2 (opc,opr,a)
|
94
|
+
assert_arg(3,a,'table')
|
95
|
+
local tmp = array2d.reduce_rows(opr,a)
|
96
|
+
return reduce(opc,tmp)
|
97
|
+
end
|
98
|
+
|
99
|
+
local function dimension (t)
|
100
|
+
return type(t[1])=='table' and 2 or 1
|
101
|
+
end
|
102
|
+
|
103
|
+
--- map a function over two arrays.
|
104
|
+
-- They can be both or either 2D arrays
|
105
|
+
-- @param f function of at least two arguments
|
106
|
+
-- @param ad order of first array
|
107
|
+
-- @param bd order of second array
|
108
|
+
-- @param a 1d or 2d array
|
109
|
+
-- @param b 1d or 2d array
|
110
|
+
-- @param arg optional extra argument to pass to function
|
111
|
+
-- @return 2D array, unless both arrays are 1D
|
112
|
+
function array2d.map2 (f,ad,bd,a,b,arg)
|
113
|
+
assert_arg(1,a,'table')
|
114
|
+
assert_arg(2,b,'table')
|
115
|
+
f = utils.function_arg(1,f)
|
116
|
+
--local ad,bd = dimension(a),dimension(b)
|
117
|
+
if ad == 1 and bd == 2 then
|
118
|
+
return imap(function(row)
|
119
|
+
return tmap2(f,a,row,arg)
|
120
|
+
end, b)
|
121
|
+
elseif ad == 2 and bd == 1 then
|
122
|
+
return imap(function(row)
|
123
|
+
return tmap2(f,row,b,arg)
|
124
|
+
end, a)
|
125
|
+
elseif ad == 1 and bd == 1 then
|
126
|
+
return tmap2(f,a,b)
|
127
|
+
elseif ad == 2 and bd == 2 then
|
128
|
+
return tmap2(function(rowa,rowb)
|
129
|
+
return tmap2(f,rowa,rowb,arg)
|
130
|
+
end, a,b)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
--- cartesian product of two 1d arrays.
|
135
|
+
-- @param f a function of 2 arguments
|
136
|
+
-- @param t1 a 1d table
|
137
|
+
-- @param t2 a 1d table
|
138
|
+
-- @return 2d table
|
139
|
+
-- @usage product('..',{1,2},{'a','b'}) == {{'1a','2a'},{'1b','2b'}}
|
140
|
+
function array2d.product (f,t1,t2)
|
141
|
+
f = utils.function_arg(1,f)
|
142
|
+
assert_arg(2,t1,'table')
|
143
|
+
assert_arg(3,t2,'table')
|
144
|
+
local res, map = {}, tablex.map
|
145
|
+
for i,v in ipairs(t2) do
|
146
|
+
res[i] = map(f,t1,v)
|
147
|
+
end
|
148
|
+
return res
|
149
|
+
end
|
150
|
+
|
151
|
+
--- flatten a 2D array.
|
152
|
+
-- (this goes over columns first.)
|
153
|
+
-- @param t 2d table
|
154
|
+
-- @return a 1d table
|
155
|
+
-- @usage flatten {{1,2},{3,4},{5,6}} == {1,2,3,4,5,6}
|
156
|
+
function array2d.flatten (t)
|
157
|
+
local res = {}
|
158
|
+
local k = 1
|
159
|
+
for _,a in ipairs(t) do -- for all rows
|
160
|
+
for i = 1,#a do
|
161
|
+
res[k] = a[i]
|
162
|
+
k = k + 1
|
163
|
+
end
|
164
|
+
end
|
165
|
+
return makelist(res)
|
166
|
+
end
|
167
|
+
|
168
|
+
--- reshape a 2D array.
|
169
|
+
-- @param t 2d array
|
170
|
+
-- @param nrows new number of rows
|
171
|
+
-- @param co column-order (Fortran-style) (default false)
|
172
|
+
-- @return a new 2d array
|
173
|
+
function array2d.reshape (t,nrows,co)
|
174
|
+
local nr,nc = array2d.size(t)
|
175
|
+
local ncols = nr*nc / nrows
|
176
|
+
local res = {}
|
177
|
+
local ir,ic = 1,1
|
178
|
+
for i = 1,nrows do
|
179
|
+
local row = {}
|
180
|
+
for j = 1,ncols do
|
181
|
+
row[j] = t[ir][ic]
|
182
|
+
if not co then
|
183
|
+
ic = ic + 1
|
184
|
+
if ic > nc then
|
185
|
+
ir = ir + 1
|
186
|
+
ic = 1
|
187
|
+
end
|
188
|
+
else
|
189
|
+
ir = ir + 1
|
190
|
+
if ir > nr then
|
191
|
+
ic = ic + 1
|
192
|
+
ir = 1
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
res[i] = row
|
197
|
+
end
|
198
|
+
return obj(t,res)
|
199
|
+
end
|
200
|
+
|
201
|
+
--- swap two rows of an array.
|
202
|
+
-- @param t a 2d array
|
203
|
+
-- @param i1 a row index
|
204
|
+
-- @param i2 a row index
|
205
|
+
function array2d.swap_rows (t,i1,i2)
|
206
|
+
assert_arg(1,t,'table')
|
207
|
+
t[i1],t[i2] = t[i2],t[i1]
|
208
|
+
end
|
209
|
+
|
210
|
+
--- swap two columns of an array.
|
211
|
+
-- @param t a 2d array
|
212
|
+
-- @param j1 a column index
|
213
|
+
-- @param j2 a column index
|
214
|
+
function array2d.swap_cols (t,j1,j2)
|
215
|
+
assert_arg(1,t,'table')
|
216
|
+
for i = 1,#t do
|
217
|
+
local row = t[i]
|
218
|
+
row[j1],row[j2] = row[j2],row[j1]
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
--- extract the specified rows.
|
223
|
+
-- @param t 2d array
|
224
|
+
-- @param ridx a table of row indices
|
225
|
+
function array2d.extract_rows (t,ridx)
|
226
|
+
return obj(t,index_by(t,ridx))
|
227
|
+
end
|
228
|
+
|
229
|
+
--- extract the specified columns.
|
230
|
+
-- @param t 2d array
|
231
|
+
-- @param cidx a table of column indices
|
232
|
+
function array2d.extract_cols (t,cidx)
|
233
|
+
assert_arg(1,t,'table')
|
234
|
+
local res = {}
|
235
|
+
for i = 1,#t do
|
236
|
+
res[i] = index_by(t[i],cidx)
|
237
|
+
end
|
238
|
+
return obj(t,res)
|
239
|
+
end
|
240
|
+
|
241
|
+
--- remove a row from an array.
|
242
|
+
-- @class function
|
243
|
+
-- @name array2d.remove_row
|
244
|
+
-- @param t a 2d array
|
245
|
+
-- @param i a row index
|
246
|
+
array2d.remove_row = remove
|
247
|
+
|
248
|
+
--- remove a column from an array.
|
249
|
+
-- @param t a 2d array
|
250
|
+
-- @param j a column index
|
251
|
+
function array2d.remove_col (t,j)
|
252
|
+
assert_arg(1,t,'table')
|
253
|
+
for i = 1,#t do
|
254
|
+
remove(t[i],j)
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
local Ai = byte 'A'
|
259
|
+
|
260
|
+
local function _parse (s)
|
261
|
+
local c,r
|
262
|
+
if s:sub(1,1) == 'R' then
|
263
|
+
r,c = s:match 'R(%d+)C(%d+)'
|
264
|
+
r,c = tonumber(r),tonumber(c)
|
265
|
+
else
|
266
|
+
c,r = s:match '(.)(.)'
|
267
|
+
c = byte(c) - byte 'A' + 1
|
268
|
+
r = tonumber(r)
|
269
|
+
end
|
270
|
+
assert(c ~= nil and r ~= nil,'bad cell specifier: '..s)
|
271
|
+
return r,c
|
272
|
+
end
|
273
|
+
|
274
|
+
--- parse a spreadsheet range.
|
275
|
+
-- The range can be specified either as 'A1:B2' or 'R1C1:R2C2';
|
276
|
+
-- a special case is a single element (e.g 'A1' or 'R1C1')
|
277
|
+
-- @param s a range.
|
278
|
+
-- @return start col
|
279
|
+
-- @return start row
|
280
|
+
-- @return end col
|
281
|
+
-- @return end row
|
282
|
+
function array2d.parse_range (s)
|
283
|
+
if s:find ':' then
|
284
|
+
local start,finish = splitv(s,':')
|
285
|
+
local i1,j1 = _parse(start)
|
286
|
+
local i2,j2 = _parse(finish)
|
287
|
+
return i1,j1,i2,j2
|
288
|
+
else -- single value
|
289
|
+
local i,j = _parse(s)
|
290
|
+
return i,j
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
--- get a slice of a 2D array using spreadsheet range notation. @see parse_range
|
295
|
+
-- @param t a 2D array
|
296
|
+
-- @param rstr range expression
|
297
|
+
-- @return a slice
|
298
|
+
-- @see array2d.parse_range
|
299
|
+
-- @see array2d.slice
|
300
|
+
function array2d.range (t,rstr)
|
301
|
+
assert_arg(1,t,'table')
|
302
|
+
local i1,j1,i2,j2 = array2d.parse_range(rstr)
|
303
|
+
if i2 then
|
304
|
+
return array2d.slice(t,i1,j1,i2,j2)
|
305
|
+
else -- single value
|
306
|
+
return t[i1][j1]
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
local function default_range (t,i1,j1,i2,j2)
|
311
|
+
local nr, nc = array2d.size(t)
|
312
|
+
i1,j1 = i1 or 1, j1 or 1
|
313
|
+
i2,j2 = i2 or nr, j2 or nc
|
314
|
+
if i2 < 0 then i2 = nr + i2 + 1 end
|
315
|
+
if j2 < 0 then j2 = nc + j2 + 1 end
|
316
|
+
return i1,j1,i2,j2
|
317
|
+
end
|
318
|
+
|
319
|
+
--- get a slice of a 2D array. Note that if the specified range has
|
320
|
+
-- a 1D result, the rank of the result will be 1.
|
321
|
+
-- @param t a 2D array
|
322
|
+
-- @param i1 start row (default 1)
|
323
|
+
-- @param j1 start col (default 1)
|
324
|
+
-- @param i2 end row (default N)
|
325
|
+
-- @param j2 end col (default M)
|
326
|
+
-- @return an array, 2D in general but 1D in special cases.
|
327
|
+
function array2d.slice (t,i1,j1,i2,j2)
|
328
|
+
assert_arg(1,t,'table')
|
329
|
+
i1,j1,i2,j2 = default_range(t,i1,j1,i2,j2)
|
330
|
+
local res = {}
|
331
|
+
for i = i1,i2 do
|
332
|
+
local val
|
333
|
+
local row = t[i]
|
334
|
+
if j1 == j2 then
|
335
|
+
val = row[j1]
|
336
|
+
else
|
337
|
+
val = {}
|
338
|
+
for j = j1,j2 do
|
339
|
+
val[#val+1] = row[j]
|
340
|
+
end
|
341
|
+
end
|
342
|
+
res[#res+1] = val
|
343
|
+
end
|
344
|
+
if i1 == i2 then res = res[1] end
|
345
|
+
return obj(t,res)
|
346
|
+
end
|
347
|
+
|
348
|
+
--- set a specified range of an array to a value.
|
349
|
+
-- @param t a 2D array
|
350
|
+
-- @param value the value (may be a function)
|
351
|
+
-- @param i1 start row (default 1)
|
352
|
+
-- @param j1 start col (default 1)
|
353
|
+
-- @param i2 end row (default N)
|
354
|
+
-- @param j2 end col (default M)
|
355
|
+
-- @see tablex.set
|
356
|
+
function array2d.set (t,value,i1,j1,i2,j2)
|
357
|
+
i1,j1,i2,j2 = default_range(t,i1,j1,i2,j2)
|
358
|
+
for i = i1,i2 do
|
359
|
+
tset(t[i],value,j1,j2)
|
360
|
+
end
|
361
|
+
end
|
362
|
+
|
363
|
+
--- write a 2D array to a file.
|
364
|
+
-- @param t a 2D array
|
365
|
+
-- @param f a file object (default stdout)
|
366
|
+
-- @param fmt a format string (default is just to use tostring)
|
367
|
+
-- @param i1 start row (default 1)
|
368
|
+
-- @param j1 start col (default 1)
|
369
|
+
-- @param i2 end row (default N)
|
370
|
+
-- @param j2 end col (default M)
|
371
|
+
function array2d.write (t,f,fmt,i1,j1,i2,j2)
|
372
|
+
assert_arg(1,t,'table')
|
373
|
+
f = f or stdout
|
374
|
+
local rowop
|
375
|
+
if fmt then
|
376
|
+
rowop = function(row,j) fprintf(f,fmt,row[j]) end
|
377
|
+
else
|
378
|
+
rowop = function(row,j) f:write(tostring(row[j]),' ') end
|
379
|
+
end
|
380
|
+
local function newline()
|
381
|
+
f:write '\n'
|
382
|
+
end
|
383
|
+
array2d.forall(t,rowop,newline,i1,j1,i2,j2)
|
384
|
+
end
|
385
|
+
|
386
|
+
--- perform an operation for all values in a 2D array.
|
387
|
+
-- @param t 2D array
|
388
|
+
-- @param row_op function to call on each value
|
389
|
+
-- @param end_row_op function to call at end of each row
|
390
|
+
-- @param i1 start row (default 1)
|
391
|
+
-- @param j1 start col (default 1)
|
392
|
+
-- @param i2 end row (default N)
|
393
|
+
-- @param j2 end col (default M)
|
394
|
+
function array2d.forall (t,row_op,end_row_op,i1,j1,i2,j2)
|
395
|
+
assert_arg(1,t,'table')
|
396
|
+
i1,j1,i2,j2 = default_range(t,i1,j1,i2,j2)
|
397
|
+
for i = i1,i2 do
|
398
|
+
local row = t[i]
|
399
|
+
for j = j1,j2 do
|
400
|
+
row_op(row,j)
|
401
|
+
end
|
402
|
+
if end_row_op then end_row_op(i) end
|
403
|
+
end
|
404
|
+
end
|
405
|
+
|
406
|
+
local min, max = math.min, math.max
|
407
|
+
|
408
|
+
---- move a block from the destination to the source.
|
409
|
+
-- @param dest a 2D array
|
410
|
+
-- @param di start row in dest
|
411
|
+
-- @param dj start col in dest
|
412
|
+
-- @param src a 2D array
|
413
|
+
-- @param i1 start row (default 1)
|
414
|
+
-- @param j1 start col (default 1)
|
415
|
+
-- @param i2 end row (default N)
|
416
|
+
-- @param j2 end col (default M)
|
417
|
+
function array2d.move (dest,di,dj,src,i1,j1,i2,j2)
|
418
|
+
assert_arg(1,dest,'table')
|
419
|
+
assert_arg(4,src,'table')
|
420
|
+
i1,j1,i2,j2 = default_range(src,i1,j1,i2,j2)
|
421
|
+
local nr,nc = array2d.size(dest)
|
422
|
+
i2, j2 = min(nr,i2), min(nc,j2)
|
423
|
+
--i1, j1 = max(1,i1), max(1,j1)
|
424
|
+
dj = dj - 1
|
425
|
+
for i = i1,i2 do
|
426
|
+
local drow, srow = dest[i+di-1], src[i]
|
427
|
+
for j = j1,j2 do
|
428
|
+
drow[j+dj] = srow[j]
|
429
|
+
end
|
430
|
+
end
|
431
|
+
end
|
432
|
+
|
433
|
+
--- iterate over all elements in a 2D array, with optional indices.
|
434
|
+
-- @param a 2D array
|
435
|
+
-- @param indices with indices (default false)
|
436
|
+
-- @param i1 start row (default 1)
|
437
|
+
-- @param j1 start col (default 1)
|
438
|
+
-- @param i2 end row (default N)
|
439
|
+
-- @param j2 end col (default M)
|
440
|
+
-- @return either value or i,j,value depending on indices
|
441
|
+
function array2d.iter (a,indices,i1,j1,i2,j2)
|
442
|
+
assert_arg(1,a,'table')
|
443
|
+
local norowset = not (i2 and j2)
|
444
|
+
i1,j1,i2,j2 = default_range(a,i1,j1,i2,j2)
|
445
|
+
local n,i,j = i2-i1+1,i1-1,j1-1
|
446
|
+
local row,nr = nil,0
|
447
|
+
local onr = j2 - j1 + 1
|
448
|
+
return function()
|
449
|
+
j = j + 1
|
450
|
+
if j > nr then
|
451
|
+
j = j1
|
452
|
+
i = i + 1
|
453
|
+
if i > i2 then return nil end
|
454
|
+
row = a[i]
|
455
|
+
nr = norowset and #row or onr
|
456
|
+
end
|
457
|
+
if indices then
|
458
|
+
return i,j,row[j]
|
459
|
+
else
|
460
|
+
return row[j]
|
461
|
+
end
|
462
|
+
end
|
463
|
+
end
|
464
|
+
|
465
|
+
--- iterate over all columns.
|
466
|
+
-- @param a a 2D array
|
467
|
+
-- @return each column in turn
|
468
|
+
function array2d.columns (a)
|
469
|
+
assert_arg(1,a,'table')
|
470
|
+
local n = a[1][1]
|
471
|
+
local i = 0
|
472
|
+
return function()
|
473
|
+
i = i + 1
|
474
|
+
if i > n then return nil end
|
475
|
+
return column(a,i)
|
476
|
+
end
|
477
|
+
end
|
478
|
+
|
479
|
+
--- new array of specified dimensions
|
480
|
+
-- @param rows number of rows
|
481
|
+
-- @param cols number of cols
|
482
|
+
-- @param val initial value; if it's a function then use `val(i,j)`
|
483
|
+
-- @return new 2d array
|
484
|
+
function array2d.new(rows,cols,val)
|
485
|
+
local res = {}
|
486
|
+
local fun = utils.is_callable(val)
|
487
|
+
for i = 1,rows do
|
488
|
+
local row = {}
|
489
|
+
if fun then
|
490
|
+
for j = 1,cols do row[j] = val(i,j) end
|
491
|
+
else
|
492
|
+
for j = 1,cols do row[j] = val end
|
493
|
+
end
|
494
|
+
res[i] = row
|
495
|
+
end
|
496
|
+
return res
|
497
|
+
end
|
498
|
+
|
499
|
+
return array2d
|
500
|
+
|
501
|
+
|