rufus-lua-win 5.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 @@
|
|
|
1
|
+
package.loaded["oil.component"] = require "loop.component.base"
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
--------------------------------------------------------------------------------
|
|
2
|
+
------------------------------ ##### ## ------------------------------
|
|
3
|
+
------------------------------ ## ## # ## ------------------------------
|
|
4
|
+
------------------------------ ## ## ## ## ------------------------------
|
|
5
|
+
------------------------------ ## ## # ## ------------------------------
|
|
6
|
+
------------------------------ ##### ### ###### ------------------------------
|
|
7
|
+
-------------------------------- --------------------------------
|
|
8
|
+
----------------------- An Object Request Broker in Lua ------------------------
|
|
9
|
+
--------------------------------------------------------------------------------
|
|
10
|
+
-- Project: OiL - ORB in Lua: An Object Request Broker in Lua --
|
|
11
|
+
-- Release: 0.5 --
|
|
12
|
+
-- Title : General Inter-ORB Protocol (GIOP) IDL specifications --
|
|
13
|
+
-- Authors: Renato Maia <maia@inf.puc-rio.br> --
|
|
14
|
+
--------------------------------------------------------------------------------
|
|
15
|
+
-- Notes: --
|
|
16
|
+
-- See in section 15.4 of CORBA 3.0 specification. --
|
|
17
|
+
--------------------------------------------------------------------------------
|
|
18
|
+
|
|
19
|
+
--------------------------------------------------------------------------------
|
|
20
|
+
-- Dependencies ----------------------------------------------------------------
|
|
21
|
+
|
|
22
|
+
local require = require
|
|
23
|
+
|
|
24
|
+
local idl = require "oil.corba.idl"
|
|
25
|
+
|
|
26
|
+
--------------------------------------------------------------------------------
|
|
27
|
+
-- Module Declaration ----------------------------------------------------------
|
|
28
|
+
|
|
29
|
+
module "oil.corba.giop"
|
|
30
|
+
|
|
31
|
+
--------------------------------------------------------------------------------
|
|
32
|
+
-- Interoperable Object Reference ----------------------------------------------
|
|
33
|
+
|
|
34
|
+
TaggedProfile = idl.struct{
|
|
35
|
+
{name = "tag" , type = idl.ulong },
|
|
36
|
+
{name = "profile_data", type = idl.OctetSeq},
|
|
37
|
+
}
|
|
38
|
+
-- underscore character allows using IOR as proxy objects
|
|
39
|
+
IOR = idl.struct{ -- because it avoids name clashes with object members.
|
|
40
|
+
{name = "type_id" , type = idl.string },
|
|
41
|
+
{name = "profiles", type = idl.sequence{TaggedProfile}},
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
--------------------------------------------------------------------------------
|
|
45
|
+
-- Object basic operations -----------------------------------------------------
|
|
46
|
+
|
|
47
|
+
ObjectOperations = {
|
|
48
|
+
_interface = idl.operation{
|
|
49
|
+
name = "_interface",
|
|
50
|
+
result = idl.Object{
|
|
51
|
+
repID = "IDL:omg.org/CORBA/InterfaceDef:1.0",
|
|
52
|
+
name = "InterfaceDef",
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
_component = idl.operation{
|
|
56
|
+
name = "_component",
|
|
57
|
+
result = idl.object,
|
|
58
|
+
},
|
|
59
|
+
_is_a = idl.operation{
|
|
60
|
+
name = "_is_a",
|
|
61
|
+
result = idl.boolean,
|
|
62
|
+
parameters = {{ type = idl.string, name = "interface" }},
|
|
63
|
+
},
|
|
64
|
+
_non_existent = idl.operation{
|
|
65
|
+
name = "_non_existent",
|
|
66
|
+
result = idl.boolean,
|
|
67
|
+
},
|
|
68
|
+
_is_equivalent = idl.operation{
|
|
69
|
+
name = "_is_equivalent",
|
|
70
|
+
parameters = {{ type = idl.object, name = "reference" }},
|
|
71
|
+
result = idl.boolean,
|
|
72
|
+
},
|
|
73
|
+
-- TODO:[maia] add other basic operations
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
--------------------------------------------------------------------------------
|
|
77
|
+
-- System Exception Structure --------------------------------------------------
|
|
78
|
+
|
|
79
|
+
SystemExceptionIDL = idl.struct{
|
|
80
|
+
{name = "exception_id" , type = idl.string},
|
|
81
|
+
{name = "minor_code_value" , type = idl.ulong },
|
|
82
|
+
{name = "completion_status", type = idl.ulong },
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
SystemExceptionIDs = {
|
|
86
|
+
UNKNOWN = "IDL:omg.org/CORBA/UNKNOWN:1.0" , -- the unknown exception
|
|
87
|
+
BAD_PARAM = "IDL:omg.org/CORBA/BAD_PARAM:1.0" , -- an invalid parameter was passed
|
|
88
|
+
NO_MEMORY = "IDL:omg.org/CORBA/NO_MEMORY:1.0" , -- dynamic memory allocation failure
|
|
89
|
+
IMP_LIMIT = "IDL:omg.org/CORBA/IMP_LIMIT:1.0" , -- violated implementation limit
|
|
90
|
+
COMM_FAILURE = "IDL:omg.org/CORBA/COMM_FAILURE:1.0" , -- communication failure
|
|
91
|
+
INV_OBJREF = "IDL:omg.org/CORBA/INV_OBJREF:1.0" , -- invalid object reference
|
|
92
|
+
NO_PERMISSION = "IDL:omg.org/CORBA/NO_PERMISSION:1.0" , -- no permission for attempted op.
|
|
93
|
+
INTERNAL = "IDL:omg.org/CORBA/INTERNAL:1.0" , -- ORB internal error
|
|
94
|
+
MARSHAL = "IDL:omg.org/CORBA/MARSHAL:1.0" , -- error marshaling param/result
|
|
95
|
+
INITIALIZE = "IDL:omg.org/CORBA/INITIALIZE:1.0" , -- ORB initialization failure
|
|
96
|
+
NO_IMPLEMENT = "IDL:omg.org/CORBA/NO_IMPLEMENT:1.0" , -- operation implementation unavailable
|
|
97
|
+
BAD_TYPECODE = "IDL:omg.org/CORBA/BAD_TYPECODE:1.0" , -- bad typecode
|
|
98
|
+
BAD_OPERATION = "IDL:omg.org/CORBA/BAD_OPERATION:1.0" , -- invalid operation
|
|
99
|
+
NO_RESOURCES = "IDL:omg.org/CORBA/NO_RESOURCES:1.0" , -- insufficient resources for req.
|
|
100
|
+
NO_RESPONSE = "IDL:omg.org/CORBA/NO_RESPONSE:1.0" , -- response to req. not yet available
|
|
101
|
+
PERSIST_STORE = "IDL:omg.org/CORBA/PERSIST_STORE:1.0" , -- persistent storage failure
|
|
102
|
+
BAD_INV_ORDER = "IDL:omg.org/CORBA/BAD_INV_ORDER:1.0" , -- routine invocations out of order
|
|
103
|
+
TRANSIENT = "IDL:omg.org/CORBA/TRANSIENT:1.0" , -- transient failure - reissue request
|
|
104
|
+
FREE_MEM = "IDL:omg.org/CORBA/FREE_MEM:1.0" , -- cannot free memory
|
|
105
|
+
INV_IDENT = "IDL:omg.org/CORBA/INV_IDENT:1.0" , -- invalid identifier syntax
|
|
106
|
+
INV_FLAG = "IDL:omg.org/CORBA/INV_FLAG:1.0" , -- invalid flag was specified
|
|
107
|
+
INTF_REPOS = "IDL:omg.org/CORBA/INTF_REPOS:1.0" , -- error accessing interface repository
|
|
108
|
+
BAD_CONTEXT = "IDL:omg.org/CORBA/BAD_CONTEXT:1.0" , -- error processing context object
|
|
109
|
+
OBJ_ADAPTER = "IDL:omg.org/CORBA/OBJ_ADAPTER:1.0" , -- failure detected by object adapter
|
|
110
|
+
DATA_CONVERSION = "IDL:omg.org/CORBA/DATA_CONVERSION:1.0" , -- data conversion error
|
|
111
|
+
OBJECT_NOT_EXIST = "IDL:omg.org/CORBA/OBJECT_NOT_EXIST:1.0" , -- non-existent object, delete reference
|
|
112
|
+
TRANSACTION_REQUIRED = "IDL:omg.org/CORBA/TRANSACTION_REQUIRED:1.0" , -- transaction required
|
|
113
|
+
TRANSACTION_ROLLEDBACK = "IDL:omg.org/CORBA/TRANSACTION_ROLLEDBACK:1.0" , -- transaction rolled back
|
|
114
|
+
INVALID_TRANSACTION = "IDL:omg.org/CORBA/INVALID_TRANSACTION:1.0" , -- invalid transaction
|
|
115
|
+
INV_POLICY = "IDL:omg.org/CORBA/INV_POLICY:1.0" , -- invalid policy
|
|
116
|
+
CODESET_INCOMPATIBLE = "IDL:omg.org/CORBA/CODESET_INCOMPATIBLE:1.0" , -- incompatible code set
|
|
117
|
+
REBIND = "IDL:omg.org/CORBA/REBIND:1.0" , -- rebind needed
|
|
118
|
+
TIMEOUT = "IDL:omg.org/CORBA/TIMEOUT:1.0" , -- operation timed out
|
|
119
|
+
TRANSACTION_UNAVAILABLE = "IDL:omg.org/CORBA/TRANSACTION_UNAVAILABLE:1.0", -- no transaction
|
|
120
|
+
TRANSACTION_MODE = "IDL:omg.org/CORBA/TRANSACTION_MODE:1.0" , -- invalid transaction mode
|
|
121
|
+
BAD_QOS = "IDL:omg.org/CORBA/BAD_QOS:1.0" , -- bad quality of service
|
|
122
|
+
INVALID_ACTIVITY = "IDL:omg.org/CORBA/INVALID_ACTIVITY:1.0" , -- bad quality of service
|
|
123
|
+
ACTIVITY_COMPLETED = "IDL:omg.org/CORBA/ACTIVITY_COMPLETED:1.0" , -- bad quality of service
|
|
124
|
+
ACTIVITY_REQUIRED = "IDL:omg.org/CORBA/ACTIVITY_REQUIRED:1.0" , -- bad quality of service
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
--------------------------------------------------------------------------------
|
|
128
|
+
-- Message Header Commom to All GIOP Messages ----------------------------------
|
|
129
|
+
|
|
130
|
+
HeaderSize = 12 -- TODO:[maia] Calculate from IDL specification
|
|
131
|
+
MagicTag = "GIOP" -- TODO:[maia] Garantee that the string "GIOP" is
|
|
132
|
+
-- encoded in ISO Latin-1 (8859.1).
|
|
133
|
+
-- How can I do this in Lua?!
|
|
134
|
+
|
|
135
|
+
Header_v1_ = { -- Common message header for each GIOP version
|
|
136
|
+
[0] = idl.struct{ -- GIOP 1.0
|
|
137
|
+
{name = "magic" , type = idl.array{idl.char; length = 4}},
|
|
138
|
+
{name = "GIOP_version", type = idl.Version },
|
|
139
|
+
{name = "byte_order" , type = idl.boolean },
|
|
140
|
+
{name = "message_type", type = idl.octet },
|
|
141
|
+
{name = "message_size", type = idl.ulong },
|
|
142
|
+
},
|
|
143
|
+
[1] = idl.struct{ -- GIOP 1.1
|
|
144
|
+
{name = "magic" , type = idl.array{idl.char; length = 4}},
|
|
145
|
+
{name = "GIOP_version", type = idl.Version },
|
|
146
|
+
{name = "flags" , type = idl.octet },
|
|
147
|
+
{name = "message_type", type = idl.octet },
|
|
148
|
+
{name = "message_size", type = idl.ulong },
|
|
149
|
+
},
|
|
150
|
+
}
|
|
151
|
+
Header_v1_[2] = Header_v1_[1] -- GIOP 1.2, same as GIOP 1.1
|
|
152
|
+
Header_v1_[3] = Header_v1_[1] -- GIOP 1.3, same as GIOP 1.1
|
|
153
|
+
|
|
154
|
+
--------------------------------------------------------------------------------
|
|
155
|
+
-- Message Header of GIOP Messages ---------------------------------------------
|
|
156
|
+
|
|
157
|
+
RequestID = 0
|
|
158
|
+
ReplyID = 1
|
|
159
|
+
CancelRequestID = 2
|
|
160
|
+
LocateRequestID = 3
|
|
161
|
+
LocateReplyID = 4
|
|
162
|
+
CloseConnectionID = 5
|
|
163
|
+
MessageErrorID = 6
|
|
164
|
+
FragmentID = 7
|
|
165
|
+
|
|
166
|
+
--------------------------------------------------------------------------------
|
|
167
|
+
|
|
168
|
+
MessageType = {
|
|
169
|
+
[RequestID ] = "Request" ,
|
|
170
|
+
[ReplyID ] = "Reply" ,
|
|
171
|
+
[CancelRequestID ] = "CancelRequest" ,
|
|
172
|
+
[LocateRequestID ] = "LocateRequest" ,
|
|
173
|
+
[LocateReplyID ] = "LocateReply" ,
|
|
174
|
+
[CloseConnectionID] = "CloseConnection",
|
|
175
|
+
[MessageErrorID ] = "MessageError" ,
|
|
176
|
+
[FragmentID ] = "Fragment" ,
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
--------------------------------------------------------------------------------
|
|
180
|
+
|
|
181
|
+
local ServiceContextList = idl.sequence{idl.struct{
|
|
182
|
+
{name = "context_id" , type = idl.ulong },
|
|
183
|
+
{name = "context_data", type = idl.OctetSeq},
|
|
184
|
+
}}
|
|
185
|
+
|
|
186
|
+
MessageHeader_v1_ = {} -- Message headers for each GIOP version
|
|
187
|
+
|
|
188
|
+
--------------------------------------------------------------------------------
|
|
189
|
+
|
|
190
|
+
local ReplyStatusType_1_0 = idl.enum{
|
|
191
|
+
"NO_EXCEPTION", "USER_EXCEPTION", "SYSTEM_EXCEPTION", "LOCATION_FORWARD",
|
|
192
|
+
}
|
|
193
|
+
local LocateStatusType_1_0 = idl.enum{
|
|
194
|
+
"UNKNOWN_OBJECT", "OBJECT_HERE", "OBJECT_FORWARD",
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
MessageHeader_v1_[0] = { -- GIOP 1.0
|
|
198
|
+
[RequestID] = idl.struct{
|
|
199
|
+
{name = "service_context" , type = ServiceContextList},
|
|
200
|
+
{name = "request_id" , type = idl.ulong },
|
|
201
|
+
{name = "response_expected" , type = idl.boolean },
|
|
202
|
+
{name = "object_key" , type = idl.OctetSeq },
|
|
203
|
+
{name = "operation" , type = idl.string },
|
|
204
|
+
{name = "requesting_principal", type = idl.OctetSeq },
|
|
205
|
+
},
|
|
206
|
+
[ReplyID] = idl.struct{
|
|
207
|
+
{name = "service_context", type = ServiceContextList },
|
|
208
|
+
{name = "request_id" , type = idl.ulong },
|
|
209
|
+
{name = "reply_status" , type = ReplyStatusType_1_0},
|
|
210
|
+
},
|
|
211
|
+
[CancelRequestID] = idl.struct{
|
|
212
|
+
{name = "request_id", type = idl.ulong},
|
|
213
|
+
},
|
|
214
|
+
[LocateRequestID] = idl.struct{
|
|
215
|
+
{name = "request_id", type = idl.ulong },
|
|
216
|
+
{name = "object_key", type = idl.OctetSeq},
|
|
217
|
+
},
|
|
218
|
+
[LocateReplyID] = idl.struct{
|
|
219
|
+
{name = "request_id" , type = idl.ulong },
|
|
220
|
+
{name = "locate_status", type = LocateStatusType_1_0},
|
|
221
|
+
},
|
|
222
|
+
[CloseConnectionID] = false, -- empty header
|
|
223
|
+
[MessageErrorID ] = false, -- empty header
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
--------------------------------------------------------------------------------
|
|
227
|
+
|
|
228
|
+
MessageHeader_v1_[1] = { -- GIOP 1.1
|
|
229
|
+
[RequestID] = idl.struct{
|
|
230
|
+
{name = "service_context" , type = ServiceContextList },
|
|
231
|
+
{name = "request_id" , type = idl.ulong },
|
|
232
|
+
{name = "response_expected" , type = idl.boolean },
|
|
233
|
+
{name = "reserved" , type = idl.array{idl.octet; length = 3}},
|
|
234
|
+
{name = "object_key" , type = idl.OctetSeq },
|
|
235
|
+
{name = "operation" , type = idl.string },
|
|
236
|
+
{name = "requesting_principal", type = idl.OctetSeq },
|
|
237
|
+
},
|
|
238
|
+
[ReplyID ] = MessageHeader_v1_[0][ReplyID ],
|
|
239
|
+
[CancelRequestID ] = MessageHeader_v1_[0][CancelRequestID ],
|
|
240
|
+
[LocateRequestID ] = MessageHeader_v1_[0][LocateRequestID ],
|
|
241
|
+
[LocateReplyID ] = MessageHeader_v1_[0][LocateReplyID ],
|
|
242
|
+
[CloseConnectionID] = MessageHeader_v1_[0][CloseConnectionID],
|
|
243
|
+
[MessageErrorID ] = MessageHeader_v1_[0][MessageErrorID ],
|
|
244
|
+
[FragmentID ] = false, -- empty header, introduced in GIOP 1.1
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
--------------------------------------------------------------------------------
|
|
248
|
+
|
|
249
|
+
local ReplyStatusType_1_2 = idl.enum{
|
|
250
|
+
"NO_EXCEPTION", "USER_EXCEPTION", "SYSTEM_EXCEPTION", "LOCATION_FORWARD",
|
|
251
|
+
"LOCATION_FORWARD_PERM", "NEEDS_ADDRESSING_MODE",
|
|
252
|
+
}
|
|
253
|
+
local LocateStatusType_1_2 = idl.enum{
|
|
254
|
+
"UNKNOWN_OBJECT", "OBJECT_HERE", "OBJECT_FORWARD",
|
|
255
|
+
"OBJECT_FORWARD_PERM", "LOC_SYSTEM_EXCEPTION", "LOC_NEEDS_ADDRESSING_MODE",
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
local IORAddressingInfo = idl.struct{
|
|
259
|
+
{type = idl.ulong, name = "selected_profile_index"},
|
|
260
|
+
{type = IOR , name = "ior" },
|
|
261
|
+
}
|
|
262
|
+
local TargetAddress = idl.union{
|
|
263
|
+
switch = idl.short,
|
|
264
|
+
options = {
|
|
265
|
+
{label = 0, name = "object_key", type = idl.OctetSeq },
|
|
266
|
+
{label = 1, name = "profile" , type = TaggedProfile },
|
|
267
|
+
{label = 2, name = "ior" , type = IORAddressingInfo},
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
MessageHeader_v1_[2] = { -- GIOP 1.2
|
|
272
|
+
[RequestID] = idl.struct{
|
|
273
|
+
{name = "request_id" , type = idl.ulong },
|
|
274
|
+
{name = "response_flags" , type = idl.octet },
|
|
275
|
+
{name = "reserved" , type = idl.array{idl.octet; length = 3}},
|
|
276
|
+
{name = "target" , type = TargetAddress },
|
|
277
|
+
{name = "operation" , type = idl.string },
|
|
278
|
+
{name = "service_context", type = ServiceContextList },
|
|
279
|
+
},
|
|
280
|
+
[ReplyID] = idl.struct{
|
|
281
|
+
{name = "request_id" , type = idl.ulong },
|
|
282
|
+
{name = "reply_status" , type = ReplyStatusType_1_2},
|
|
283
|
+
{name = "service_context", type = ServiceContextList },
|
|
284
|
+
},
|
|
285
|
+
[CancelRequestID] = MessageHeader_v1_[1][CancelRequestID],
|
|
286
|
+
[LocateRequestID] = idl.struct{
|
|
287
|
+
{name = "request_id", type = idl.ulong },
|
|
288
|
+
{name = "target" , type = TargetAddress},
|
|
289
|
+
},
|
|
290
|
+
[LocateReplyID] = idl.struct{
|
|
291
|
+
{name = "request_id" , type = idl.ulong },
|
|
292
|
+
{name = "locate_status", type = LocateStatusType_1_2},
|
|
293
|
+
},
|
|
294
|
+
[CloseConnectionID] = MessageHeader_v1_[1][CloseConnectionID],
|
|
295
|
+
[MessageErrorID ] = MessageHeader_v1_[1][MessageErrorID ],
|
|
296
|
+
[FragmentID ] = MessageHeader_v1_[1][FragmentID ],
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
--------------------------------------------------------------------------------
|
|
300
|
+
|
|
301
|
+
MessageHeader_v1_[3] = MessageHeader_v1_[2] -- GIOP 1.3, same as GIOP 1.2
|
|
@@ -0,0 +1,1568 @@
|
|
|
1
|
+
--------------------------------------------------------------------------------
|
|
2
|
+
------------------------------ ##### ## ------------------------------
|
|
3
|
+
------------------------------ ## ## # ## ------------------------------
|
|
4
|
+
------------------------------ ## ## ## ## ------------------------------
|
|
5
|
+
------------------------------ ## ## # ## ------------------------------
|
|
6
|
+
------------------------------ ##### ### ###### ------------------------------
|
|
7
|
+
-------------------------------- --------------------------------
|
|
8
|
+
----------------------- An Object Request Broker in Lua ------------------------
|
|
9
|
+
--------------------------------------------------------------------------------
|
|
10
|
+
-- Project: OiL - ORB in Lua: An Object Request Broker in Lua --
|
|
11
|
+
-- Release: 0.5 --
|
|
12
|
+
-- Title : Mapping of Lua values into Common Data Representation (CDR) --
|
|
13
|
+
-- Authors: Renato Maia <maia@inf.puc-rio.br> --
|
|
14
|
+
--------------------------------------------------------------------------------
|
|
15
|
+
-- decoder interface: --
|
|
16
|
+
-- order(value) Change or return the endianess of the buffer --
|
|
17
|
+
-- jump(shift) Places an empty space in the data of the buffer --
|
|
18
|
+
-- getdata() Returns the raw data stream of marshalled data --
|
|
19
|
+
-- get(type) Unmarhsall a value of the given type --
|
|
20
|
+
-- --
|
|
21
|
+
-- void() Unmarshal a void type value --
|
|
22
|
+
-- short() Unmarshal an integer type short value --
|
|
23
|
+
-- long() Unmarshal an integer type long value --
|
|
24
|
+
-- ushort() Unmarshal an integer type unsigned short value --
|
|
25
|
+
-- ulong() Unmarshal an integer type unsigned long value --
|
|
26
|
+
-- float() Unmarshal a floating-point numeric type value --
|
|
27
|
+
-- double() Unmarshal a double-precision floating-point num. value --
|
|
28
|
+
-- boolean() Unmarshal a boolean type value --
|
|
29
|
+
-- char() Unmarshal a character type value --
|
|
30
|
+
-- octet() Unmarshal a raw byte type value --
|
|
31
|
+
-- any() Unmarshal a generic type value --
|
|
32
|
+
-- TypeCode() Unmarshal a meta-type value --
|
|
33
|
+
-- string() Unmarshal a string type value --
|
|
34
|
+
-- --
|
|
35
|
+
-- Object(type) Unmarhsal an Object type value, given its type --
|
|
36
|
+
-- struct(type) Unmarhsal a struct type value, given its type --
|
|
37
|
+
-- union(type) Unmarhsal a union type value, given its type --
|
|
38
|
+
-- enum(type) Unmarhsal an enumeration type value, given its type --
|
|
39
|
+
-- sequence(type) Unmarhsal a sequence type value, given its type --
|
|
40
|
+
-- array(type) Unmarhsal an array type value, given its type --
|
|
41
|
+
-- typedef(type) Unmarhsal a type definition value, given its type --
|
|
42
|
+
-- except(type) Unmarhsal an expection value, given its type --
|
|
43
|
+
-- --
|
|
44
|
+
-- interface(type) Unmarshall an object reference of a given interface --
|
|
45
|
+
-- --
|
|
46
|
+
-- encoder interface: --
|
|
47
|
+
-- order(value) Change or return the endianess of the buffer --
|
|
48
|
+
-- jump(shift) Jump an empty space in the data of the buffer --
|
|
49
|
+
-- getdata() Returns the raw data stream of marshalled data --
|
|
50
|
+
-- put(type) Marhsall a value of the given type --
|
|
51
|
+
-- --
|
|
52
|
+
-- void(value) Marshal a void type value --
|
|
53
|
+
-- short(value) Marshal an integer type short value --
|
|
54
|
+
-- long(value) Marshal an integer type long value --
|
|
55
|
+
-- ushort(value) Marshal an integer type unsigned short value --
|
|
56
|
+
-- ulong(value) Marshal an integer type unsigned long value --
|
|
57
|
+
-- float(value) Marshal a floating-point numeric type value --
|
|
58
|
+
-- double(value) Marshal a double-prec. floating-point num. value --
|
|
59
|
+
-- boolean(value) Marshal a boolean type value --
|
|
60
|
+
-- char(value) Marshal a character type value --
|
|
61
|
+
-- octet(value) Marshal a raw byte type value --
|
|
62
|
+
-- any(value) Marshal a generic type value --
|
|
63
|
+
-- TypeCode(value) Marshal a meta-type value --
|
|
64
|
+
-- string(value) Marshal a string type value --
|
|
65
|
+
-- --
|
|
66
|
+
-- Object(value, type) Marhsal an Object type value, given its type --
|
|
67
|
+
-- struct(value, type) Marhsal a struct type value, given its type --
|
|
68
|
+
-- union(value, type) Marhsal an union type value, given its type --
|
|
69
|
+
-- enum(value, type) Marhsal an enumeration type value, given its type --
|
|
70
|
+
-- sequence(value, type)Marhsal a sequence type value, given its type --
|
|
71
|
+
-- array(value, type) Marhsal an array type value, given its type --
|
|
72
|
+
-- typedef(value, type) Marhsal a type definition value, given its type --
|
|
73
|
+
-- except(value, type) Marhsal an expection value, given its type --
|
|
74
|
+
-- --
|
|
75
|
+
-- interface(value,type)Marshall an object reference of a given interface --
|
|
76
|
+
--------------------------------------------------------------------------------
|
|
77
|
+
-- Notes: --
|
|
78
|
+
-- See section 15.3 of CORBA 3.0 specification. --
|
|
79
|
+
--------------------------------------------------------------------------------
|
|
80
|
+
-- codec:Facet
|
|
81
|
+
-- encoder:object encoder()
|
|
82
|
+
-- decoder:object decoder(stream:string)
|
|
83
|
+
--
|
|
84
|
+
-- proxies:Receptacle
|
|
85
|
+
-- proxy:object proxyto(ior:table, iface:table|string)
|
|
86
|
+
--
|
|
87
|
+
-- servants:Receptacle
|
|
88
|
+
-- proxy:object register(implementation:object, iface:table|string)
|
|
89
|
+
--------------------------------------------------------------------------------
|
|
90
|
+
|
|
91
|
+
local getmetatable = getmetatable
|
|
92
|
+
local ipairs = ipairs
|
|
93
|
+
local pairs = pairs
|
|
94
|
+
local pcall = pcall
|
|
95
|
+
local rawget = rawget
|
|
96
|
+
local setmetatable = setmetatable
|
|
97
|
+
local tonumber = tonumber
|
|
98
|
+
local type = type
|
|
99
|
+
|
|
100
|
+
local math = require "math"
|
|
101
|
+
local string = require "string"
|
|
102
|
+
local table = require "table"
|
|
103
|
+
|
|
104
|
+
local oo = require "oil.oo"
|
|
105
|
+
local assert = require "oil.assert"
|
|
106
|
+
local bit = require "oil.bit"
|
|
107
|
+
local idl = require "oil.corba.idl"
|
|
108
|
+
local giop = require "oil.corba.giop" --[[VERBOSE]] local verbose = require "oil.verbose"; local CURSOR, CODEC, PREFIXSHIFT, SIZEINDEXPOS, verbose_marshal, verbose_unmarshal = {}
|
|
109
|
+
|
|
110
|
+
module("oil.corba.giop.Codec", oo.class)
|
|
111
|
+
|
|
112
|
+
local IndirectionTag = 0xffffffff
|
|
113
|
+
|
|
114
|
+
--------------------------------------------------------------------------------
|
|
115
|
+
--------------------------------------------------------------------------------
|
|
116
|
+
|
|
117
|
+
UnionLabelInfo = { name = "label", type = idl.void }
|
|
118
|
+
|
|
119
|
+
--------------------------------------------------------------------------------
|
|
120
|
+
-- TypeCode information --------------------------------------------------------
|
|
121
|
+
|
|
122
|
+
-- NOTE: Description of type code categories, which is defined by field type
|
|
123
|
+
-- empty : no further parameters are necessary to specify the associated
|
|
124
|
+
-- type.
|
|
125
|
+
-- simple : parameters that specify the associated type are defined as a
|
|
126
|
+
-- sequence of values.
|
|
127
|
+
-- complex: parameters that specify the associated type are defined as a
|
|
128
|
+
-- structure defined in idl that is stored in a encapsulated octet
|
|
129
|
+
-- sequence (i.e. which endianess may differ).
|
|
130
|
+
|
|
131
|
+
TypeCodeInfo = {
|
|
132
|
+
[0] = {name = "null" , type = "empty", idl = idl.null },
|
|
133
|
+
[1] = {name = "void" , type = "empty", idl = idl.void },
|
|
134
|
+
[2] = {name = "short" , type = "empty", idl = idl.short },
|
|
135
|
+
[3] = {name = "long" , type = "empty", idl = idl.long },
|
|
136
|
+
[4] = {name = "ushort" , type = "empty", idl = idl.ushort },
|
|
137
|
+
[5] = {name = "ulong" , type = "empty", idl = idl.ulong },
|
|
138
|
+
[6] = {name = "float" , type = "empty", idl = idl.float },
|
|
139
|
+
[7] = {name = "double" , type = "empty", idl = idl.double },
|
|
140
|
+
[8] = {name = "boolean" , type = "empty", idl = idl.boolean },
|
|
141
|
+
[9] = {name = "char" , type = "empty", idl = idl.char },
|
|
142
|
+
[10] = {name = "octet" , type = "empty", idl = idl.octet },
|
|
143
|
+
[11] = {name = "any" , type = "empty", idl = idl.any },
|
|
144
|
+
[12] = {name = "TypeCode" , type = "empty", idl = idl.TypeCode },
|
|
145
|
+
[13] = {name = "Principal", type = "empty", idl = idl.Principal, unhandled = true},
|
|
146
|
+
|
|
147
|
+
[14] = {name = "Object", type = "complex",
|
|
148
|
+
parameters = idl.struct{
|
|
149
|
+
{name = "repID", type = idl.string},
|
|
150
|
+
{name = "name" , type = idl.string},
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
[15] = {name = "struct", type = "complex",
|
|
154
|
+
parameters = idl.struct{
|
|
155
|
+
{name = "repID" , type = idl.string},
|
|
156
|
+
{name = "name" , type = idl.string},
|
|
157
|
+
{name = "fields", type = idl.sequence{
|
|
158
|
+
idl.struct{
|
|
159
|
+
{name = "name", type = idl.string},
|
|
160
|
+
{name = "type", type = idl.TypeCode}
|
|
161
|
+
},
|
|
162
|
+
}},
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
[16] = {name = "union", type = "complex",
|
|
166
|
+
parameters = idl.struct{
|
|
167
|
+
{name = "repID" , type = idl.string },
|
|
168
|
+
{name = "name" , type = idl.string },
|
|
169
|
+
{name = "switch" , type = idl.TypeCode},
|
|
170
|
+
{name = "default", type = idl.long },
|
|
171
|
+
},
|
|
172
|
+
mutable = {
|
|
173
|
+
{name = "options", type = idl.sequence{
|
|
174
|
+
idl.struct{
|
|
175
|
+
UnionLabelInfo, -- NOTE: depends on field 'switch'.
|
|
176
|
+
{name = "name" , type = idl.string },
|
|
177
|
+
{name = "type" , type = idl.TypeCode},
|
|
178
|
+
},
|
|
179
|
+
}},
|
|
180
|
+
setup = function(self, union)
|
|
181
|
+
UnionLabelInfo.type = union.switch
|
|
182
|
+
return self
|
|
183
|
+
end,
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
[17] = {name = "enum", type = "complex",
|
|
187
|
+
parameters = idl.struct{
|
|
188
|
+
{name = "repID" , type = idl.string },
|
|
189
|
+
{name = "name" , type = idl.string },
|
|
190
|
+
{name = "enumvalues", type = idl.sequence{idl.string}},
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
[18] = {name = "string", type = "simple", idl = idl.string,
|
|
194
|
+
parameters = idl.struct{
|
|
195
|
+
{name = "maxlength", type = idl.ulong}
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
[19] = {name = "sequence", type = "complex",
|
|
199
|
+
parameters = idl.struct{
|
|
200
|
+
{name = "elementtype", type = idl.TypeCode},
|
|
201
|
+
{name = "maxlength" , type = idl.ulong },
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
[20] = {name = "array", type = "complex",
|
|
205
|
+
parameters = idl.struct{
|
|
206
|
+
{name = "elementtype", type = idl.TypeCode},
|
|
207
|
+
{name = "length" , type = idl.ulong },
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
[21] = {name = "typedef", type = "complex",
|
|
211
|
+
parameters = idl.struct{
|
|
212
|
+
{name = "repID" , type = idl.string },
|
|
213
|
+
{name = "name" , type = idl.string },
|
|
214
|
+
{name = "original_type", type = idl.TypeCode},
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
[22] = {name = "except", type = "complex",
|
|
218
|
+
parameters = idl.struct{
|
|
219
|
+
{name = "repID", type = idl.string},
|
|
220
|
+
{name = "name", type = idl.string},
|
|
221
|
+
{name = "members", type = idl.sequence{
|
|
222
|
+
idl.struct{
|
|
223
|
+
{name = "name", type = idl.string },
|
|
224
|
+
{name = "type", type = idl.TypeCode},
|
|
225
|
+
},
|
|
226
|
+
}},
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
|
|
230
|
+
[23] = {name = "longlong" , type = "empty", idl = idl.longlong },
|
|
231
|
+
[24] = {name = "ulonglong" , type = "empty", idl = idl.ulonglong },
|
|
232
|
+
[25] = {name = "longdouble", type = "empty", idl = idl.longdouble},
|
|
233
|
+
[26] = {name = "wchar" , type = "empty", unhandled = true},
|
|
234
|
+
|
|
235
|
+
[27] = {name = "wstring", type = "simple", unhandled = true,
|
|
236
|
+
parameters = idl.struct{
|
|
237
|
+
{name = "maxlength", type = idl.ulong},
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
[28] = {name = "fixed", type = "simple", unhandled = true,
|
|
241
|
+
parameters = idl.struct{
|
|
242
|
+
{name = "digits", type = idl.ushort},
|
|
243
|
+
{name = "scale" , type = idl.short },
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
|
|
247
|
+
[29] = {name = "valuetype", type = "complex",
|
|
248
|
+
parameters = idl.struct{
|
|
249
|
+
{name = "repID" , type = idl.string },
|
|
250
|
+
{name = "name" , type = idl.string },
|
|
251
|
+
{name = "kind" , type = idl.short },
|
|
252
|
+
{name = "base_value", type = idl.TypeCode},
|
|
253
|
+
{name = "members" , type = idl.sequence{
|
|
254
|
+
idl.struct{
|
|
255
|
+
{name = "name" , type = idl.string },
|
|
256
|
+
{name = "type" , type = idl.TypeCode},
|
|
257
|
+
{name = "access", type = idl.short },
|
|
258
|
+
},
|
|
259
|
+
}},
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
[30] = {name = "valuebox", type = "complex",
|
|
263
|
+
parameters = idl.struct{
|
|
264
|
+
{name = "repID" , type = idl.string },
|
|
265
|
+
{name = "name" , type = idl.string },
|
|
266
|
+
{name = "original_type", type = idl.TypeCode},
|
|
267
|
+
},
|
|
268
|
+
},
|
|
269
|
+
[31] = {name = "native", type = "complex", unhandled = true,
|
|
270
|
+
parameters = idl.struct{
|
|
271
|
+
{name = "repID", type = idl.string },
|
|
272
|
+
{name = "name" , type = idl.string },
|
|
273
|
+
},
|
|
274
|
+
},
|
|
275
|
+
[32] = {name = "abstract_interface", type = "complex",
|
|
276
|
+
parameters = idl.struct{
|
|
277
|
+
{name = "repID", type = idl.string },
|
|
278
|
+
{name = "name" , type = idl.string },
|
|
279
|
+
},
|
|
280
|
+
},
|
|
281
|
+
[33] = {name = "local_interface", type = "complex",
|
|
282
|
+
parameters = idl.struct{
|
|
283
|
+
{name = "repID", type = idl.string },
|
|
284
|
+
{name = "name" , type = idl.string },
|
|
285
|
+
},
|
|
286
|
+
},
|
|
287
|
+
|
|
288
|
+
[IndirectionTag] = {name = "indirection marker", type = "fake"},
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
local PrimitiveSizes = {
|
|
292
|
+
boolean = 1,
|
|
293
|
+
char = 1,
|
|
294
|
+
octet = 1,
|
|
295
|
+
short = 2,
|
|
296
|
+
long = 4,
|
|
297
|
+
longlong = 8,
|
|
298
|
+
ushort = 2,
|
|
299
|
+
ulong = 4,
|
|
300
|
+
ulonglong = 8,
|
|
301
|
+
float = 4,
|
|
302
|
+
double = 8,
|
|
303
|
+
longdouble = 16,
|
|
304
|
+
enum = 4,
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
--------------------------------------------------------------------------------
|
|
308
|
+
-- Local module functions ------------------------------------------------------
|
|
309
|
+
|
|
310
|
+
local function alignment(self, size)
|
|
311
|
+
local extra = (self.cursor-1)%size
|
|
312
|
+
if extra > 0 then return size-extra end
|
|
313
|
+
return 0
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
NativeEndianess = (bit.endianess() == "little")
|
|
317
|
+
|
|
318
|
+
--------------------------------------------------------------------------------
|
|
319
|
+
-- ## ## ##### ###### ###### ## ## ##### ## ## --
|
|
320
|
+
-- ### ### ## ## ## ## ## ## ## ## ## ## ## --
|
|
321
|
+
-- ####### ####### ###### ##### ####### ####### ## ## --
|
|
322
|
+
-- ## # ## ## ## ## ## ## ## ## ## ## ## ## --
|
|
323
|
+
-- ## ## ## ## ## ## ###### ## ## ## ## ####### ####### --
|
|
324
|
+
--------------------------------------------------------------------------------
|
|
325
|
+
|
|
326
|
+
--------------------------------------------------------------------------------
|
|
327
|
+
-- Unmarshalling buffer class --------------------------------------------------
|
|
328
|
+
|
|
329
|
+
Encoder = oo.class {
|
|
330
|
+
previousend = 0,
|
|
331
|
+
index = 1,
|
|
332
|
+
cursor = 1,
|
|
333
|
+
emptychar = '\255', -- character used in buffer alignment
|
|
334
|
+
pack = bit.pack, -- use current platform native endianess
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
local function newhistory(history)
|
|
338
|
+
return setmetatable(history or {}, { __index = function(self, field)
|
|
339
|
+
local value = {}
|
|
340
|
+
self[field] = value
|
|
341
|
+
return value
|
|
342
|
+
end })
|
|
343
|
+
end
|
|
344
|
+
|
|
345
|
+
function Encoder:__init(object)
|
|
346
|
+
self = oo.rawnew(self, object)
|
|
347
|
+
if self.history == nil then self.history = newhistory() end
|
|
348
|
+
if self.format == nil then self.format = {} end
|
|
349
|
+
return self
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
function Encoder:shift(shift) --[[VERBOSE]] PREFIXSHIFT = shift
|
|
353
|
+
self.cursor = self.cursor + shift
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
function Encoder:jump(shift)
|
|
357
|
+
if shift > 0 then self:rawput('"', self.emptychar:rep(shift), shift) end
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
function Encoder:align(size)
|
|
361
|
+
local shift = alignment(self, size)
|
|
362
|
+
if shift > 0 then self:jump(shift) end
|
|
363
|
+
end
|
|
364
|
+
|
|
365
|
+
function Encoder:rawput(format, data, size) --[[VERBOSE]] CURSOR[self.cursor] = true; if CODEC == nil then CODEC = self end
|
|
366
|
+
local index = self.index
|
|
367
|
+
self.format[index] = format
|
|
368
|
+
self[index] = data
|
|
369
|
+
self.index = index+1
|
|
370
|
+
self.cursor = self.cursor + size
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
function Encoder:put(value, idltype)
|
|
374
|
+
local marshal = self[idltype._type]
|
|
375
|
+
if not marshal then
|
|
376
|
+
assert.illegal(idltype._type, "supported type", "MARSHAL")
|
|
377
|
+
end
|
|
378
|
+
return marshal(self, value, idltype)
|
|
379
|
+
end
|
|
380
|
+
|
|
381
|
+
function Encoder:indirection(marshal, value, ...)
|
|
382
|
+
local history = self.history
|
|
383
|
+
local previous = history[marshal][value]
|
|
384
|
+
if previous then
|
|
385
|
+
self:ulong(IndirectionTag)
|
|
386
|
+
self:long(previous - (self.previousend+self.cursor)) --[[VERBOSE]] verbose_marshal("indirection to "..((self.previousend+self.cursor)-previous).." bytes away (",(self.previousend+self.cursor),"-",previous,").")
|
|
387
|
+
else
|
|
388
|
+
local shift = alignment(self, PrimitiveSizes.ulong)
|
|
389
|
+
history[marshal][value] = (self.previousend+self.cursor+shift) --[[VERBOSE]] verbose_marshal("registering position at ",history[marshal][value]," for future indirection")
|
|
390
|
+
marshal(self, value, ...)
|
|
391
|
+
end
|
|
392
|
+
end
|
|
393
|
+
|
|
394
|
+
function Encoder:getdata()
|
|
395
|
+
return self.pack(table.concat(self.format), self)
|
|
396
|
+
end
|
|
397
|
+
|
|
398
|
+
function Encoder:getlength()
|
|
399
|
+
return self.cursor - 1
|
|
400
|
+
end
|
|
401
|
+
|
|
402
|
+
local NilEnabledTypes = {
|
|
403
|
+
any = true,
|
|
404
|
+
boolean = true,
|
|
405
|
+
Object = true,
|
|
406
|
+
interface = true,
|
|
407
|
+
valuetype = true,
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
--------------------------------------------------------------------------------
|
|
411
|
+
-- Marshalling functions -------------------------------------------------------
|
|
412
|
+
|
|
413
|
+
local function numbermarshaller(size, format)
|
|
414
|
+
return function (self, value)
|
|
415
|
+
assert.type(value, "number", "numeric value", "MARSHAL")
|
|
416
|
+
self:align(size)
|
|
417
|
+
self:rawput(format, value, size) --[[VERBOSE]] verbose_marshal(self, format, value)
|
|
418
|
+
end
|
|
419
|
+
end
|
|
420
|
+
|
|
421
|
+
Encoder.null = function() end
|
|
422
|
+
Encoder.void = Encoder.null
|
|
423
|
+
Encoder.short = numbermarshaller(PrimitiveSizes.short , "s")
|
|
424
|
+
Encoder.long = numbermarshaller(PrimitiveSizes.long , "l")
|
|
425
|
+
Encoder.longlong = numbermarshaller(PrimitiveSizes.longlong , "g")
|
|
426
|
+
Encoder.ushort = numbermarshaller(PrimitiveSizes.ushort , "S")
|
|
427
|
+
Encoder.ulong = numbermarshaller(PrimitiveSizes.ulong , "L")
|
|
428
|
+
Encoder.ulonglong = numbermarshaller(PrimitiveSizes.ulonglong , "G")
|
|
429
|
+
Encoder.float = numbermarshaller(PrimitiveSizes.float , "f")
|
|
430
|
+
Encoder.double = numbermarshaller(PrimitiveSizes.double , "d")
|
|
431
|
+
Encoder.longdouble = numbermarshaller(PrimitiveSizes.longdouble, "D")
|
|
432
|
+
|
|
433
|
+
function Encoder:boolean(value) --[[VERBOSE]] verbose_marshal(true, self, idl.boolean)
|
|
434
|
+
if value
|
|
435
|
+
then self:octet(1)
|
|
436
|
+
else self:octet(0)
|
|
437
|
+
end --[[VERBOSE]] verbose_marshal(false)
|
|
438
|
+
end
|
|
439
|
+
|
|
440
|
+
function Encoder:char(value)
|
|
441
|
+
assert.type(value, "string", "character", "MARSHAL")
|
|
442
|
+
if #value ~= 1 then
|
|
443
|
+
assert.illegal(value, "character", "MARSHAL")
|
|
444
|
+
end
|
|
445
|
+
self:rawput('"', value, 1) --[[VERBOSE]] verbose_marshal(self, idl.char, value)
|
|
446
|
+
end
|
|
447
|
+
|
|
448
|
+
function Encoder:octet(value)
|
|
449
|
+
assert.type(value, "number", "octet value", "MARSHAL")
|
|
450
|
+
self:rawput("B", value, 1) --[[VERBOSE]] verbose_marshal(self, idl.octet, value)
|
|
451
|
+
end
|
|
452
|
+
|
|
453
|
+
local DefaultMapping = {
|
|
454
|
+
number = idl.double,
|
|
455
|
+
string = idl.string,
|
|
456
|
+
boolean = idl.boolean,
|
|
457
|
+
["nil"] = idl.null,
|
|
458
|
+
}
|
|
459
|
+
function Encoder:any(value) --[[VERBOSE]] verbose_marshal(true, self, idl.any)
|
|
460
|
+
local luatype = type(value)
|
|
461
|
+
local idltype = DefaultMapping[luatype]
|
|
462
|
+
if not idltype then
|
|
463
|
+
local metatable = getmetatable(value)
|
|
464
|
+
if metatable then
|
|
465
|
+
if idl.istype(metatable) then
|
|
466
|
+
idltype = metatable
|
|
467
|
+
elseif idl.istype(metatable.__type) then
|
|
468
|
+
idltype = metatable.__type
|
|
469
|
+
end
|
|
470
|
+
end
|
|
471
|
+
if luatype == "table" then
|
|
472
|
+
if not idltype then
|
|
473
|
+
idltype = value._anytype
|
|
474
|
+
if not idl.istype(idltype) then
|
|
475
|
+
idltype = nil
|
|
476
|
+
end
|
|
477
|
+
end
|
|
478
|
+
if idltype then
|
|
479
|
+
if (value._anyval ~= nil or NilEnabledTypes[idltype._type]) then
|
|
480
|
+
value = value._anyval
|
|
481
|
+
end
|
|
482
|
+
end
|
|
483
|
+
end
|
|
484
|
+
end
|
|
485
|
+
if not idltype then
|
|
486
|
+
assert.illegal(value, "any, unable to map to an idl type", "MARSHAL")
|
|
487
|
+
end --[[VERBOSE]] verbose_marshal "[type of any]"
|
|
488
|
+
self:TypeCode(idltype) --[[VERBOSE]] verbose_marshal "[value of any]"
|
|
489
|
+
self:put(value, idltype) --[[VERBOSE]] verbose_marshal(false)
|
|
490
|
+
end
|
|
491
|
+
|
|
492
|
+
local NullReference = { type_id = "", profiles = { n=0 } }
|
|
493
|
+
function Encoder:Object(value, idltype) --[[VERBOSE]] verbose_marshal(true, self, idltype, value)
|
|
494
|
+
local reference
|
|
495
|
+
if value == nil then
|
|
496
|
+
reference = NullReference
|
|
497
|
+
else
|
|
498
|
+
local metatable = getmetatable(value)
|
|
499
|
+
if metatable == giop.IOR
|
|
500
|
+
or metatable and metatable.__type == giop.IOR
|
|
501
|
+
then
|
|
502
|
+
reference = value
|
|
503
|
+
else
|
|
504
|
+
assert.type(value, "table", "object reference", "MARSHAL")
|
|
505
|
+
reference = value.__reference
|
|
506
|
+
if not reference or reference == value then
|
|
507
|
+
local servants = self.context.servants
|
|
508
|
+
if servants then --[[VERBOSE]] verbose_marshal(true, "implicit servant creation")
|
|
509
|
+
local objtype = servants:resolvetype(value) or idltype
|
|
510
|
+
if not objtype:is_a(idltype.repID) then
|
|
511
|
+
assert.illegal(value,
|
|
512
|
+
idltype.repID..", got a "..objtype.repID, "BAD_PARAM")
|
|
513
|
+
end
|
|
514
|
+
value = assert.results(servants:register(value, nil, objtype)) --[[VERBOSE]] verbose_marshal(false)
|
|
515
|
+
reference = value.__reference
|
|
516
|
+
else
|
|
517
|
+
assert.illegal(value, "Object, unable to create from value", "MARHSALL")
|
|
518
|
+
end
|
|
519
|
+
end
|
|
520
|
+
end
|
|
521
|
+
end
|
|
522
|
+
self:struct(reference, giop.IOR) --[[VERBOSE]] verbose_marshal(false)
|
|
523
|
+
end
|
|
524
|
+
|
|
525
|
+
function Encoder:struct(value, idltype) --[[VERBOSE]] verbose_marshal(true, self, idltype)
|
|
526
|
+
for _, field in ipairs(idltype.fields) do
|
|
527
|
+
local val = value[field.name] --[[VERBOSE]] verbose_marshal("[field ",field.name,"]")
|
|
528
|
+
if val == nil and not NilEnabledTypes[field.type._type] then
|
|
529
|
+
assert.illegal(value,
|
|
530
|
+
"struct value (no value for field "..field.name..")",
|
|
531
|
+
"MARSHAL")
|
|
532
|
+
end
|
|
533
|
+
self:put(val, field.type)
|
|
534
|
+
end --[[VERBOSE]] verbose_marshal(false)
|
|
535
|
+
end
|
|
536
|
+
|
|
537
|
+
function Encoder:union(value, idltype) --[[VERBOSE]] verbose_marshal(true, self, idltype)
|
|
538
|
+
assert.type(value, "table", "union value", "MARSHAL")
|
|
539
|
+
local switch = value._switch
|
|
540
|
+
|
|
541
|
+
-- Marshal discriminator
|
|
542
|
+
if switch == nil then
|
|
543
|
+
switch = idltype.selector[value._field]
|
|
544
|
+
if switch == nil then
|
|
545
|
+
for _, option in ipairs(idltype.options) do
|
|
546
|
+
if value[option.name] ~= nil then
|
|
547
|
+
switch = option.label
|
|
548
|
+
break
|
|
549
|
+
end
|
|
550
|
+
end
|
|
551
|
+
if switch == nil then
|
|
552
|
+
switch = idltype.options[idltype.default+1]
|
|
553
|
+
if switch == nil then
|
|
554
|
+
assert.illegal(value, "union value (no discriminator)", "MARSHAL")
|
|
555
|
+
end
|
|
556
|
+
end
|
|
557
|
+
end
|
|
558
|
+
end --[[VERBOSE]] verbose_marshal "[union switch]"
|
|
559
|
+
self:put(switch, idltype.switch)
|
|
560
|
+
|
|
561
|
+
local selection = idltype.selection[switch]
|
|
562
|
+
if selection then
|
|
563
|
+
-- Marshal union value
|
|
564
|
+
local unionvalue = value._value
|
|
565
|
+
if unionvalue == nil then
|
|
566
|
+
unionvalue = value[selection.name]
|
|
567
|
+
if unionvalue == nil then
|
|
568
|
+
assert.illegal(value, "union value (none contents)", "MARSHAL")
|
|
569
|
+
end
|
|
570
|
+
end --[[VERBOSE]] verbose_marshal("[field ",selection.name,"]")
|
|
571
|
+
self:put(unionvalue, selection.type)
|
|
572
|
+
end --[[VERBOSE]] verbose_marshal(false)
|
|
573
|
+
end
|
|
574
|
+
|
|
575
|
+
function Encoder:enum(value, idltype) --[[VERBOSE]] verbose_marshal(true, self, idltype, value)
|
|
576
|
+
value = idltype.labelvalue[value] or tonumber(value)
|
|
577
|
+
if not value then assert.illegal(value, "enum value", "MARSHAL") end
|
|
578
|
+
self:ulong(value) --[[VERBOSE]] verbose_marshal(false)
|
|
579
|
+
end
|
|
580
|
+
|
|
581
|
+
function Encoder:string(value) --[[VERBOSE]] verbose_marshal(true, self, idl.string, value)
|
|
582
|
+
assert.type(value, "string", "string value", "MARSHAL")
|
|
583
|
+
local length = #value
|
|
584
|
+
self:ulong(length + 1)
|
|
585
|
+
self:rawput('"', value, length)
|
|
586
|
+
self:rawput('"', '\0', 1) --[[VERBOSE]] verbose_marshal(false)
|
|
587
|
+
end
|
|
588
|
+
|
|
589
|
+
function Encoder:sequence(value, idltype) --[[VERBOSE]] verbose_marshal(true, self, idltype, value)
|
|
590
|
+
local elementtype = idltype.elementtype
|
|
591
|
+
if type(value) == "string" then
|
|
592
|
+
local length = #value
|
|
593
|
+
self:ulong(length)
|
|
594
|
+
while elementtype._type == "typedef" do
|
|
595
|
+
elementtype = elementtype.original_type
|
|
596
|
+
end
|
|
597
|
+
if elementtype == idl.octet or elementtype == idl.char then
|
|
598
|
+
self:rawput('"', value, length)
|
|
599
|
+
else
|
|
600
|
+
assert.illegal(value, "sequence value (table expected, got string)",
|
|
601
|
+
"MARSHAL")
|
|
602
|
+
end
|
|
603
|
+
else
|
|
604
|
+
assert.type(value, "table", "sequence value", "MARSHAL")
|
|
605
|
+
local length = value.n or #value
|
|
606
|
+
self:ulong(length)
|
|
607
|
+
for i = 1, length do --[[VERBOSE]] verbose_marshal("[element ",i,"]")
|
|
608
|
+
self:put(value[i], elementtype)
|
|
609
|
+
end
|
|
610
|
+
end --[[VERBOSE]] verbose_marshal(false)
|
|
611
|
+
end
|
|
612
|
+
|
|
613
|
+
function Encoder:array(value, idltype) --[[VERBOSE]] verbose_marshal(true, self, idltype, value)
|
|
614
|
+
local elementtype = idltype.elementtype
|
|
615
|
+
if type(value) == "string" then
|
|
616
|
+
while elementtype._type == "typedef" do
|
|
617
|
+
elementtype = elementtype.original_type
|
|
618
|
+
end
|
|
619
|
+
if elementtype == idl.octet or elementtype == idl.char then
|
|
620
|
+
local length = #value
|
|
621
|
+
if length ~= idltype.length then
|
|
622
|
+
assert.illegal(value, "array value (wrong length)", "MARSHAL")
|
|
623
|
+
end
|
|
624
|
+
self:rawput('"', value, length)
|
|
625
|
+
else
|
|
626
|
+
assert.illegal(value, "array value (table expected, got string)",
|
|
627
|
+
"MARSHAL")
|
|
628
|
+
end
|
|
629
|
+
else
|
|
630
|
+
assert.type(value, "table", "array value", "MARSHAL")
|
|
631
|
+
for i = 1, idltype.length do --[[VERBOSE]] verbose_marshal("[element ",i,"]")
|
|
632
|
+
self:put(value[i], elementtype)
|
|
633
|
+
end
|
|
634
|
+
end --[[VERBOSE]] verbose_marshal(false)
|
|
635
|
+
end
|
|
636
|
+
|
|
637
|
+
function Encoder:typedef(value, idltype) --[[VERBOSE]] verbose_marshal(true, self, idltype, value)
|
|
638
|
+
self:put(value, idltype.original_type) --[[VERBOSE]] verbose_marshal(false)
|
|
639
|
+
end
|
|
640
|
+
|
|
641
|
+
function Encoder:except(value, idltype) --[[VERBOSE]] verbose_marshal(true, self, idltype, value)
|
|
642
|
+
assert.type(value, "table", "except value", "MARSHAL")
|
|
643
|
+
for _, member in ipairs(idltype.members) do --[[VERBOSE]] verbose_marshal("[member ", member.name, "]")
|
|
644
|
+
local val = value[member.name]
|
|
645
|
+
if val == nil and not NilEnabledTypes[member.type._type] then
|
|
646
|
+
assert.illegal(value,
|
|
647
|
+
"except value (no value for member "..member.name..")",
|
|
648
|
+
"MARSHAL")
|
|
649
|
+
end
|
|
650
|
+
self:put(val, member.type)
|
|
651
|
+
end --[[VERBOSE]] verbose_marshal(false)
|
|
652
|
+
end
|
|
653
|
+
|
|
654
|
+
Encoder.interface = Encoder.Object
|
|
655
|
+
|
|
656
|
+
-- Abstract Interfaces ---------------------------------------------------------
|
|
657
|
+
|
|
658
|
+
local function index(indexable, field)
|
|
659
|
+
return indexable[field]
|
|
660
|
+
end
|
|
661
|
+
local function pindex(indexable, field)
|
|
662
|
+
local ok, value = pcall(index, indexable, field)
|
|
663
|
+
if ok then return value end
|
|
664
|
+
end
|
|
665
|
+
|
|
666
|
+
function Encoder:abstract_interface(value, idltype) --[[VERBOSE]] verbose_marshal(true, self, idltype, value)
|
|
667
|
+
-- get type of the value
|
|
668
|
+
local actualtype = getmetatable(value)
|
|
669
|
+
if not idl.istype(actualtype) then
|
|
670
|
+
actualtype = pindex(actualtype, "__type")
|
|
671
|
+
or pindex(value, "__type")
|
|
672
|
+
end
|
|
673
|
+
local isvalue = (value == nil)
|
|
674
|
+
or (actualtype and actualtype._type == "valuetype")
|
|
675
|
+
self:boolean(not isvalue)
|
|
676
|
+
if isvalue then --[[VERBOSE]] verbose_marshal("value encoded as copied value")
|
|
677
|
+
self:valuetype(value, idl.ValueBase)
|
|
678
|
+
else --[[VERBOSE]] verbose_marshal("value encoded as object reference")
|
|
679
|
+
self:interface(value, idltype)
|
|
680
|
+
end --[[VERBOSE]] verbose_marshal(false)
|
|
681
|
+
end
|
|
682
|
+
|
|
683
|
+
-- ValueTypes ------------------------------------------------------------------
|
|
684
|
+
|
|
685
|
+
local MinValueTag = 0x7fffff00
|
|
686
|
+
local MaxValueTag = 0x7fffffff
|
|
687
|
+
local HasCodeBase = 0x00000001
|
|
688
|
+
local SingleRepID = 0x00000002
|
|
689
|
+
local ListOfRepID = 0x00000006
|
|
690
|
+
local ChunkedFlag = 0x00000008
|
|
691
|
+
|
|
692
|
+
local function reserve(self, size, noupdate)
|
|
693
|
+
local sizeindex = self.ChunkSizeIndex
|
|
694
|
+
if sizeindex then
|
|
695
|
+
local newsize = size + (self[sizeindex] or MinValueTag)
|
|
696
|
+
if newsize >= MinValueTag then -- update current chunk size
|
|
697
|
+
if size >= MinValueTag then
|
|
698
|
+
assert.illegal(data, "value too large", "MARSHAL")
|
|
699
|
+
end --[[VERBOSE]] verbose_marshal("[new encoding chunk]")
|
|
700
|
+
self.ChunkSizeIndex = nil -- disable chunk encoding
|
|
701
|
+
self:long(0) --[[start a new chunk (size is initially 0)]]
|
|
702
|
+
sizeindex = self.index-1
|
|
703
|
+
newsize = size
|
|
704
|
+
self.ChunkSizeIndex = sizeindex --[[VERBOSE]] SIZEINDEXPOS = self.cursor-PrimitiveSizes.long
|
|
705
|
+
end
|
|
706
|
+
if not noupdate then
|
|
707
|
+
self[sizeindex] = newsize --[[VERBOSE]] CURSOR[SIZEINDEXPOS] = true
|
|
708
|
+
end
|
|
709
|
+
end
|
|
710
|
+
end
|
|
711
|
+
|
|
712
|
+
local function reservedalign(self, size)
|
|
713
|
+
reserve(self, 0)
|
|
714
|
+
return Encoder.align(self, size)
|
|
715
|
+
end
|
|
716
|
+
|
|
717
|
+
local function reservedrawput(self, format, data, size)
|
|
718
|
+
reserve(self, size)
|
|
719
|
+
return Encoder.rawput(self, format, data, size)
|
|
720
|
+
end
|
|
721
|
+
|
|
722
|
+
local ulongsize = PrimitiveSizes.ulong
|
|
723
|
+
local function reservedstring(self, value)
|
|
724
|
+
reserve(self, alignment(self, ulongsize) -- alignment for the stating ulong
|
|
725
|
+
+ ulongsize -- size of ulong with the string size
|
|
726
|
+
+ #value -- number of bytes in the string
|
|
727
|
+
+ 1, -- terminating '\0' of the string
|
|
728
|
+
"no update")
|
|
729
|
+
return Encoder.string(self, value)
|
|
730
|
+
end
|
|
731
|
+
|
|
732
|
+
local function reservedsequence(self, value, idltype)
|
|
733
|
+
local itemsize = PrimitiveSizes[idltype.elementtype._type]
|
|
734
|
+
if itemsize then
|
|
735
|
+
local count = (type(value) == "string") and #value or (value.n or #value)
|
|
736
|
+
reserve(self, alignment(self, ulongsize) -- alignment for the ulong
|
|
737
|
+
+ ulongsize -- size of ulong with item count
|
|
738
|
+
+ count * itemsize, -- size of the contents
|
|
739
|
+
"no update")
|
|
740
|
+
end
|
|
741
|
+
return Encoder.sequence(self, value, idltype)
|
|
742
|
+
end
|
|
743
|
+
|
|
744
|
+
local function reservedarray(self, value, idltype)
|
|
745
|
+
local itemsize = PrimitiveSizes[idltype.elementtype._type]
|
|
746
|
+
if itemsize then
|
|
747
|
+
local count = (type(value) == "string") and #value or (value.n or #value)
|
|
748
|
+
reserve(self, count * itemsize, "no update") -- size of the contents
|
|
749
|
+
end
|
|
750
|
+
return Encoder.array(self, value, idltype)
|
|
751
|
+
end
|
|
752
|
+
|
|
753
|
+
Encoder.ValueTypeNesting = 0
|
|
754
|
+
|
|
755
|
+
local abstract = idl.ValueKind.abstract
|
|
756
|
+
local truncatable = idl.ValueKind.truncatable
|
|
757
|
+
local function encodevaluetype(self, value, idltype)
|
|
758
|
+
-- get type of the value
|
|
759
|
+
local actualtype = getmetatable(value)
|
|
760
|
+
if not idl.istype(actualtype) then
|
|
761
|
+
actualtype = pindex(actualtype, "__type")
|
|
762
|
+
or pindex(value, "__type")
|
|
763
|
+
or (idltype.kind ~= abstract and idltype or nil)
|
|
764
|
+
end
|
|
765
|
+
assert.type(actualtype, "idl valuetype", "value type", "MARSHAL")
|
|
766
|
+
-- collect typing information and check the type of the value
|
|
767
|
+
local types = {}
|
|
768
|
+
local type = actualtype
|
|
769
|
+
local argidx -- index of the formal pararameter type
|
|
770
|
+
local lstidx -- index of the last truncatable type
|
|
771
|
+
for i = 1, math.huge do
|
|
772
|
+
types[i] = type
|
|
773
|
+
if type == idltype then argidx = i end
|
|
774
|
+
if type.kind ~= truncatable then lstidx = i end
|
|
775
|
+
type = type.base_value
|
|
776
|
+
if type == idl.null then break end
|
|
777
|
+
end
|
|
778
|
+
local truncatable = (lstidx > 1)
|
|
779
|
+
if argidx == nil then
|
|
780
|
+
if idltype ~= idl.ValueBase then
|
|
781
|
+
local found
|
|
782
|
+
-- check whether it inherits from an abstract value
|
|
783
|
+
if idltype.is_abstract then
|
|
784
|
+
for _, type in ipairs(types) do
|
|
785
|
+
if type:is_a(idltype.repID) then
|
|
786
|
+
found = true
|
|
787
|
+
break
|
|
788
|
+
end
|
|
789
|
+
end
|
|
790
|
+
end
|
|
791
|
+
if not found then
|
|
792
|
+
assert.illegal(value, "value of type "..idltype.repID, "MARSHAL")
|
|
793
|
+
end
|
|
794
|
+
end
|
|
795
|
+
elseif argidx < lstidx then
|
|
796
|
+
lstidx = argidx -- can terminate the repID list at a well known type (param)
|
|
797
|
+
end
|
|
798
|
+
-- encode tag and typing information
|
|
799
|
+
local nesting = self.ValueTypeNesting
|
|
800
|
+
self.ChunkSizeIndex = nil -- end current chunk, if any
|
|
801
|
+
local chunked = nesting > 0 or truncatable
|
|
802
|
+
local tag = MinValueTag + (chunked and ChunkedFlag or 0)
|
|
803
|
+
if actualtype == idltype and nesting == 0 then --[[VERBOSE]] verbose_marshal("[value tag: no truncatable bases]")
|
|
804
|
+
self:ulong(tag)
|
|
805
|
+
elseif chunked then --[[nesting > 0 or truncatable]] --[[VERBOSE]] verbose_marshal("[value tag: lists of ",lstidx," truncatable bases]")
|
|
806
|
+
self:ulong(tag+ListOfRepID)
|
|
807
|
+
self:long(lstidx)
|
|
808
|
+
for i = 1, lstidx do --[[VERBOSE]] verbose_marshal("[repID of truncatable base ",i,"]")
|
|
809
|
+
self:indirection(self.string, types[i].repID)
|
|
810
|
+
end
|
|
811
|
+
else -- non-truncatable
|
|
812
|
+
self:ulong(tag+SingleRepID) --[[VERBOSE]] verbose_marshal("[value tag: single truncatable base]")
|
|
813
|
+
self:indirection(self.string, types[1].repID)
|
|
814
|
+
end
|
|
815
|
+
-- check if chunked encoding is necessary
|
|
816
|
+
if chunked then
|
|
817
|
+
self.ValueTypeNesting = nesting+1 -- increase value nesting level
|
|
818
|
+
if nesting == 0 then -- enable chunked encoding if not nested
|
|
819
|
+
self.history[reservedstring] = self.history[self.string]
|
|
820
|
+
self.align = reservedalign
|
|
821
|
+
self.rawput = reservedrawput
|
|
822
|
+
self.string = reservedstring
|
|
823
|
+
self.sequence = reservedsequence
|
|
824
|
+
self.array = reservedarray
|
|
825
|
+
end
|
|
826
|
+
self.ChunkSizeIndex = "fake" -- get prepared to start a new chunk
|
|
827
|
+
end
|
|
828
|
+
-- encode value state
|
|
829
|
+
local membertype, membervalue
|
|
830
|
+
for i = #types, 1, -1 do --[[VERBOSE]] verbose_marshal("[base value ",types[i].name,"]")
|
|
831
|
+
local members = types[i].members
|
|
832
|
+
local count = #members
|
|
833
|
+
for j = 1, count do
|
|
834
|
+
local member = members[j] --[[VERBOSE]] verbose_marshal("[field ",member.name,"]")
|
|
835
|
+
membertype = member.type -- used in optimization below
|
|
836
|
+
membervalue = value[member.name]
|
|
837
|
+
self:put(membervalue, membertype)
|
|
838
|
+
end
|
|
839
|
+
end
|
|
840
|
+
-- finalize encoding of value
|
|
841
|
+
if chunked then
|
|
842
|
+
-- encode chunk end tag
|
|
843
|
+
local endtag = -(nesting+1)
|
|
844
|
+
if membertype
|
|
845
|
+
and membertype._type == "valuetype"
|
|
846
|
+
and membervalue ~= nil
|
|
847
|
+
and self.ChunkSizeIndex == nil then
|
|
848
|
+
self[self.index-1] = endtag --[[last member was a ValueType]] --[[VERBOSE]] verbose_marshal("[end tag of nested value updated to ",endtag,"] (optimized encoding)")
|
|
849
|
+
else --[[VERBOSE]] verbose_marshal("[end tag of encoded value]")
|
|
850
|
+
self.ChunkSizeIndex = nil -- terminate current chunk
|
|
851
|
+
self:long(endtag)
|
|
852
|
+
end
|
|
853
|
+
self.ValueTypeNesting = nesting -- restore value nesting level
|
|
854
|
+
if nesting == 0 then -- disable chunked encoding if not nested
|
|
855
|
+
self.align = nil
|
|
856
|
+
self.rawput = nil
|
|
857
|
+
self.string = nil
|
|
858
|
+
self.sequence = nil
|
|
859
|
+
self.array = nil
|
|
860
|
+
self.ChunkSizeIndex = nil
|
|
861
|
+
else
|
|
862
|
+
self.ChunkSizeIndex = "fake" -- get prepared to start a new chunk
|
|
863
|
+
end
|
|
864
|
+
end
|
|
865
|
+
end
|
|
866
|
+
|
|
867
|
+
function Encoder:valuetype(value, idltype) --[[VERBOSE]] verbose_marshal(true, self, idltype, value)
|
|
868
|
+
if value == nil then
|
|
869
|
+
self:ulong(0) -- null tag
|
|
870
|
+
else
|
|
871
|
+
assert.type(value, "table", "value", "MARSHAL")
|
|
872
|
+
self:indirection(encodevaluetype, value, idltype)
|
|
873
|
+
end --[[VERBOSE]] verbose_marshal(false)
|
|
874
|
+
end
|
|
875
|
+
|
|
876
|
+
-- ValueBox --------------------------------------------------------------------
|
|
877
|
+
|
|
878
|
+
local function encodevaluebox(self, value, idltype) --[[VERBOSE]] verbose_marshal("[value tag: boxed]")
|
|
879
|
+
local nesting = self.ValueTypeNesting
|
|
880
|
+
-- encode tag
|
|
881
|
+
self.ChunkSizeIndex = nil -- end current chunk, if any
|
|
882
|
+
self:ulong(MinValueTag + (nesting==0 and 0 or ChunkedFlag))
|
|
883
|
+
-- check if chunked encoding is necessary
|
|
884
|
+
if nesting > 0 then
|
|
885
|
+
self.ValueTypeNesting = nesting+1 -- increase value nesting level
|
|
886
|
+
self.ChunkSizeIndex = "fake" -- get prepared to start a new chunk
|
|
887
|
+
end
|
|
888
|
+
-- encode value
|
|
889
|
+
self:put(value, idltype.original_type)
|
|
890
|
+
-- finalize encoding of value
|
|
891
|
+
if nesting > 0 then --[[VERBOSE]] verbose_marshal("[end tag of encoded value]")
|
|
892
|
+
self.ChunkSizeIndex = nil -- terminate current chunk
|
|
893
|
+
self:long(-(nesting+1)) -- encode chunk end tag
|
|
894
|
+
self.ValueTypeNesting = nesting-1 -- decrease value nesting level
|
|
895
|
+
self.ChunkSizeIndex = "fake" -- get prepared to start a new chunk
|
|
896
|
+
end
|
|
897
|
+
end
|
|
898
|
+
|
|
899
|
+
function Encoder:valuebox(value, idltype) --[[VERBOSE]] verbose_marshal(true, self, idltype, value)
|
|
900
|
+
if value == nil then
|
|
901
|
+
self:ulong(0) -- null tag
|
|
902
|
+
else
|
|
903
|
+
self:indirection(encodevaluebox, value, idltype)
|
|
904
|
+
end --[[VERBOSE]] verbose_marshal(false)
|
|
905
|
+
end
|
|
906
|
+
|
|
907
|
+
-- TypeCodes -------------------------------------------------------------------
|
|
908
|
+
|
|
909
|
+
local function encodetypeinfo(self, value, kind, tcinfo)
|
|
910
|
+
self:ulong(kind)
|
|
911
|
+
local tcparams = value.tcparams
|
|
912
|
+
if tcparams == nil then --[[VERBOSE]] verbose_marshal "[parameters values]"
|
|
913
|
+
-- create encoder for encapsulated stream
|
|
914
|
+
local cursor = self.previousend+self.cursor
|
|
915
|
+
local history
|
|
916
|
+
if self.encodingTypeCode then
|
|
917
|
+
history = self.history
|
|
918
|
+
else
|
|
919
|
+
history = newhistory()
|
|
920
|
+
history[encodetypeinfo][value] = self.history[encodetypeinfo][value]
|
|
921
|
+
end
|
|
922
|
+
local encoder = Encoder{
|
|
923
|
+
context = self.context,
|
|
924
|
+
history = history,
|
|
925
|
+
previousend = cursor-1 + 4, -- adds the size of the OctetSeq count
|
|
926
|
+
encodingTypeCode = true,
|
|
927
|
+
}
|
|
928
|
+
encoder:boolean(NativeEndianess) -- encapsulated stream includes endianess
|
|
929
|
+
-- encode parameters using the encapsulated encoder
|
|
930
|
+
encoder:struct(value, tcinfo.parameters)
|
|
931
|
+
if tcinfo.mutable then --[[VERBOSE]] verbose_marshal "[mutable parameters values]"
|
|
932
|
+
for _, param in ipairs(tcinfo.mutable:setup(value)) do
|
|
933
|
+
encoder:put(value[param.name], param.type)
|
|
934
|
+
end
|
|
935
|
+
end --[[VERBOSE]] verbose_marshal(true, "[parameters encapsulation]")
|
|
936
|
+
-- get encapsulated stream and save for future reuse
|
|
937
|
+
tcparams = encoder:getdata()
|
|
938
|
+
if not self.encodingTypeCode then
|
|
939
|
+
value.tcparams = tcparams
|
|
940
|
+
end --[[VERBOSE]] verbose_marshal(false)
|
|
941
|
+
end
|
|
942
|
+
self:sequence(tcparams, idl.OctetSeq)
|
|
943
|
+
end
|
|
944
|
+
|
|
945
|
+
local TypeCodes = { interface = 14 }
|
|
946
|
+
for tcode, info in pairs(TypeCodeInfo) do TypeCodes[info.name] = tcode end
|
|
947
|
+
|
|
948
|
+
function Encoder:TypeCode(value) --[[VERBOSE]] verbose_marshal(true, self, idl.TypeCode, value)
|
|
949
|
+
assert.type(value, "idl type", "TypeCode value", "MARSHAL")
|
|
950
|
+
local kind = TypeCodes[value._type]
|
|
951
|
+
local tcinfo = TypeCodeInfo[kind]
|
|
952
|
+
|
|
953
|
+
if not kind then assert.illegal(value, "idl type", "MARSHAL") end
|
|
954
|
+
|
|
955
|
+
if tcinfo.type == "empty" then
|
|
956
|
+
self:ulong(kind)
|
|
957
|
+
elseif tcinfo.type == "simple" then
|
|
958
|
+
self:ulong(kind)
|
|
959
|
+
for _, param in ipairs(tcinfo.parameters) do --[[VERBOSE]] verbose_marshal("[parameter ",param.name,"]")
|
|
960
|
+
self:put(value[param.name], param.type)
|
|
961
|
+
end
|
|
962
|
+
else
|
|
963
|
+
self:indirection(encodetypeinfo, value, kind, tcinfo)
|
|
964
|
+
end --[[VERBOSE]] verbose_marshal(false)
|
|
965
|
+
end
|
|
966
|
+
|
|
967
|
+
--------------------------------------------------------------------------------
|
|
968
|
+
--## ## ## ## ## ## #### ##### #### ## ## #### ## ## --
|
|
969
|
+
--## ## ### ## ### ### ## ## ## ## ## ## ## ## ## ## ## --
|
|
970
|
+
--## ## ###### ####### ###### ##### ### ###### ###### ## ## --
|
|
971
|
+
--## ## ## ### ## # ## ## ## ## ## ## ## ## ## ## ## ## --
|
|
972
|
+
-- #### ## ## ## ## ## ## ## ## #### ## ## ## ## ##### #####--
|
|
973
|
+
--------------------------------------------------------------------------------
|
|
974
|
+
|
|
975
|
+
--------------------------------------------------------------------------------
|
|
976
|
+
-- Unmarshalling buffer class --------------------------------------------------
|
|
977
|
+
|
|
978
|
+
Decoder = oo.class{
|
|
979
|
+
previousend = 0,
|
|
980
|
+
cursor = 1,
|
|
981
|
+
align = Encoder.align,
|
|
982
|
+
unpack = bit.unpack, -- use current platform native endianess
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
function Decoder:__init(object)
|
|
986
|
+
self = oo.rawnew(self, object)
|
|
987
|
+
if self.history == nil then self.history = {} end
|
|
988
|
+
return self
|
|
989
|
+
end
|
|
990
|
+
|
|
991
|
+
function Decoder:order(value)
|
|
992
|
+
if value ~= NativeEndianess then
|
|
993
|
+
self.unpack = bit.invunpack
|
|
994
|
+
end
|
|
995
|
+
end
|
|
996
|
+
|
|
997
|
+
function Decoder:jump(shift)
|
|
998
|
+
local cursor = self.cursor
|
|
999
|
+
if shift > 0 then --[[VERBOSE]] CURSOR[self.cursor] = true; if CODEC == nil then CODEC = self end
|
|
1000
|
+
self.cursor = cursor + shift --[[VERBOSE]] CURSOR[self.cursor] = false
|
|
1001
|
+
if self.cursor - 1 > #self.data then
|
|
1002
|
+
assert.illegal(self.data, "data stream, insufficient data", "MARSHAL")
|
|
1003
|
+
end
|
|
1004
|
+
end
|
|
1005
|
+
return cursor
|
|
1006
|
+
end
|
|
1007
|
+
|
|
1008
|
+
function Decoder:indirection(unmarshal, ...)
|
|
1009
|
+
local value
|
|
1010
|
+
local tag = self:ulong()
|
|
1011
|
+
if tag == IndirectionTag then --[[VERBOSE]] verbose_unmarshal("indirection tag found")
|
|
1012
|
+
local pos = self.previousend+self.cursor
|
|
1013
|
+
local offset = self:long()
|
|
1014
|
+
value = self.history[pos+offset] --[[VERBOSE]] verbose_unmarshal(value == nil and "no " or "","previous value found at position ",pos+offset," (current: ",pos,")")
|
|
1015
|
+
if value == nil then
|
|
1016
|
+
assert.illegal(offset, "indirection offset", "MARSHAL")
|
|
1017
|
+
end
|
|
1018
|
+
else
|
|
1019
|
+
local pos = self.previousend+self.cursor - PrimitiveSizes.ulong --[[VERBOSE]] verbose_unmarshal("calculating position of value for indirections, got ",pos)
|
|
1020
|
+
value = unmarshal(self, pos, tag, ...)
|
|
1021
|
+
end
|
|
1022
|
+
return value
|
|
1023
|
+
end
|
|
1024
|
+
|
|
1025
|
+
function Decoder:get(idltype)
|
|
1026
|
+
local unmarshal = self[idltype._type]
|
|
1027
|
+
if not unmarshal then
|
|
1028
|
+
assert.illegal(idltype._type, "supported type", "MARSHAL")
|
|
1029
|
+
end
|
|
1030
|
+
return unmarshal(self, idltype)
|
|
1031
|
+
end
|
|
1032
|
+
|
|
1033
|
+
function Decoder:append(data)
|
|
1034
|
+
self.data = self.data..data
|
|
1035
|
+
end
|
|
1036
|
+
|
|
1037
|
+
function Decoder:getdata()
|
|
1038
|
+
return self.data
|
|
1039
|
+
end
|
|
1040
|
+
|
|
1041
|
+
--------------------------------------------------------------------------------
|
|
1042
|
+
-- Unmarshalling functions -----------------------------------------------------
|
|
1043
|
+
|
|
1044
|
+
local function numberunmarshaller(size, format)
|
|
1045
|
+
return function(self)
|
|
1046
|
+
self:align(size)
|
|
1047
|
+
local cursor = self:jump(size) --[[VERBOSE]] verbose_unmarshal(self, format, self.unpack(format, self.data, nil, nil, cursor))
|
|
1048
|
+
return self.unpack(format, self.data, nil, nil, cursor)
|
|
1049
|
+
end
|
|
1050
|
+
end
|
|
1051
|
+
|
|
1052
|
+
Decoder.null = function() end
|
|
1053
|
+
Decoder.void = Decoder.null
|
|
1054
|
+
Decoder.short = numberunmarshaller(PrimitiveSizes.short , "s")
|
|
1055
|
+
Decoder.long = numberunmarshaller(PrimitiveSizes.long , "l")
|
|
1056
|
+
Decoder.longlong = numberunmarshaller(PrimitiveSizes.longlong , "g")
|
|
1057
|
+
Decoder.ushort = numberunmarshaller(PrimitiveSizes.ushort , "S")
|
|
1058
|
+
Decoder.ulong = numberunmarshaller(PrimitiveSizes.ulong , "L")
|
|
1059
|
+
Decoder.ulonglong = numberunmarshaller(PrimitiveSizes.ulonglong , "G")
|
|
1060
|
+
Decoder.float = numberunmarshaller(PrimitiveSizes.float , "f")
|
|
1061
|
+
Decoder.double = numberunmarshaller(PrimitiveSizes.double , "d")
|
|
1062
|
+
Decoder.longdouble = numberunmarshaller(PrimitiveSizes.longdouble, "D")
|
|
1063
|
+
|
|
1064
|
+
function Decoder:boolean() --[[VERBOSE]] verbose_unmarshal(true, self, idl.boolean)
|
|
1065
|
+
return (self:octet() ~= 0) --[[VERBOSE]],verbose_unmarshal(false)
|
|
1066
|
+
end
|
|
1067
|
+
|
|
1068
|
+
function Decoder:char()
|
|
1069
|
+
local cursor = self:jump(1) --[[check if there is enougth bytes]] --[[VERBOSE]] verbose_unmarshal(self, idl.char, self.data:sub(cursor, cursor))
|
|
1070
|
+
return self.data:sub(cursor, cursor)
|
|
1071
|
+
end
|
|
1072
|
+
|
|
1073
|
+
function Decoder:octet()
|
|
1074
|
+
local cursor = self:jump(1) --[[check if there is enougth bytes]] --[[VERBOSE]] verbose_unmarshal(self, idl.octet, self.unpack("B", self.data, nil, nil, cursor))
|
|
1075
|
+
return self.unpack("B", self.data, nil, nil, cursor)
|
|
1076
|
+
end
|
|
1077
|
+
|
|
1078
|
+
function Decoder:any() --[[VERBOSE]] verbose_unmarshal(true, self, idl.any) verbose:unmarshal "[type of any]"
|
|
1079
|
+
local idltype = self:TypeCode() --[[VERBOSE]] verbose_unmarshal "[value of any]"
|
|
1080
|
+
local value = self:get(idltype)
|
|
1081
|
+
if type(value) == "table" then
|
|
1082
|
+
value._anyval = value
|
|
1083
|
+
value._anytype = idltype
|
|
1084
|
+
else
|
|
1085
|
+
value = setmetatable({
|
|
1086
|
+
_anyval = value,
|
|
1087
|
+
_anytype = idltype,
|
|
1088
|
+
}, idltype)
|
|
1089
|
+
end --[[VERBOSE]] verbose_unmarshal(false)
|
|
1090
|
+
return value
|
|
1091
|
+
end
|
|
1092
|
+
|
|
1093
|
+
function Decoder:Object(idltype) --[[VERBOSE]] verbose_unmarshal(true, self, idltype)
|
|
1094
|
+
local ior = self:struct(giop.IOR)
|
|
1095
|
+
if ior.type_id == "" then --[[VERBOSE]] verbose_unmarshal "got a null reference"
|
|
1096
|
+
ior = nil
|
|
1097
|
+
else
|
|
1098
|
+
local proxies = self.context.proxies
|
|
1099
|
+
if proxies then --[[VERBOSE]] verbose_unmarshal(true, "retrieve proxy for referenced object")
|
|
1100
|
+
if idltype._type == "Object" then idltype = idltype.repID end
|
|
1101
|
+
ior = assert.results(proxies:resolve(ior, idltype)) --[[VERBOSE]] verbose_unmarshal(false)
|
|
1102
|
+
end
|
|
1103
|
+
end --[[VERBOSE]] verbose_unmarshal(false)
|
|
1104
|
+
return ior
|
|
1105
|
+
end
|
|
1106
|
+
|
|
1107
|
+
function Decoder:struct(idltype) --[[VERBOSE]] verbose_unmarshal(true, self, idltype)
|
|
1108
|
+
local value = {}
|
|
1109
|
+
for _, field in ipairs(idltype.fields) do --[[VERBOSE]] verbose_unmarshal("[field ",field.name,"]")
|
|
1110
|
+
value[field.name] = self:get(field.type)
|
|
1111
|
+
end --[[VERBOSE]] verbose_unmarshal(false)
|
|
1112
|
+
return setmetatable(value, idltype)
|
|
1113
|
+
end
|
|
1114
|
+
|
|
1115
|
+
function Decoder:union(idltype) --[[VERBOSE]] verbose_unmarshal(true, self, idltype) verbose:unmarshal "[union switch]"
|
|
1116
|
+
local switch = self:get(idltype.switch)
|
|
1117
|
+
local value = { _switch = switch }
|
|
1118
|
+
local option = idltype.selection[switch] or
|
|
1119
|
+
idltype.options[idltype.default+1]
|
|
1120
|
+
if option then --[[VERBOSE]] verbose_unmarshal("[field ",option.name,"]")
|
|
1121
|
+
value._field = option.name
|
|
1122
|
+
value._value = self:get(option.type)
|
|
1123
|
+
end --[[VERBOSE]] verbose_unmarshal(false)
|
|
1124
|
+
return setmetatable(value, idltype)
|
|
1125
|
+
end
|
|
1126
|
+
|
|
1127
|
+
function Decoder:enum(idltype) --[[VERBOSE]] verbose_unmarshal(true, self, idltype)
|
|
1128
|
+
local value = self:ulong() + 1
|
|
1129
|
+
if value > #idltype.enumvalues then
|
|
1130
|
+
assert.illegal(value, "enumeration value", "MARSHAL")
|
|
1131
|
+
end --[[VERBOSE]] verbose_unmarshal(false, "got ",idltype.enumvalues[value])
|
|
1132
|
+
return idltype.enumvalues[value]
|
|
1133
|
+
end
|
|
1134
|
+
|
|
1135
|
+
function Decoder:indirectstring(pos, length)
|
|
1136
|
+
local cursor = self:jump(length) -- check if there is enougth bytes
|
|
1137
|
+
local value = self.data:sub(cursor, cursor + length - 2)
|
|
1138
|
+
if pos then self.history[pos] = value end --[[VERBOSE]] verbose_unmarshal("got ",verbose.viewer:tostring(value))
|
|
1139
|
+
return value
|
|
1140
|
+
end
|
|
1141
|
+
|
|
1142
|
+
function Decoder:string() --[[VERBOSE]] verbose_unmarshal(true, self, idl.string)
|
|
1143
|
+
return self:indirectstring(nil, self:ulong()) --[[VERBOSE]],verbose_unmarshal(false)
|
|
1144
|
+
end
|
|
1145
|
+
|
|
1146
|
+
function Decoder:sequence(idltype) --[[VERBOSE]] verbose_unmarshal(true, self, idltype)
|
|
1147
|
+
local length = self:ulong()
|
|
1148
|
+
local elementtype = idltype.elementtype
|
|
1149
|
+
local value
|
|
1150
|
+
while elementtype._type == "typecode" do elementtype = elementtype.type end
|
|
1151
|
+
if elementtype == idl.octet or elementtype == idl.char then
|
|
1152
|
+
local cursor = self:jump(length) -- check if there is enougth bytes
|
|
1153
|
+
value = self.data:sub(cursor, cursor + length - 1) --[[VERBOSE]] verbose_unmarshal("got ", verbose.viewer:tostring(value))
|
|
1154
|
+
else
|
|
1155
|
+
value = setmetatable({ n = length }, idltype)
|
|
1156
|
+
for i = 1, length do --[[VERBOSE]] verbose_unmarshal("[element ",i,"]")
|
|
1157
|
+
value[i] = self:get(elementtype)
|
|
1158
|
+
end
|
|
1159
|
+
end --[[VERBOSE]] verbose_unmarshal(false)
|
|
1160
|
+
return value
|
|
1161
|
+
end
|
|
1162
|
+
|
|
1163
|
+
function Decoder:array(idltype) --[[VERBOSE]] verbose_unmarshal(true, self, idltype)
|
|
1164
|
+
local length = idltype.length
|
|
1165
|
+
local elementtype = idltype.elementtype
|
|
1166
|
+
local value
|
|
1167
|
+
while elementtype._type == "typecode" do elementtype = elementtype.type end
|
|
1168
|
+
if elementtype == idl.octet or elementtype == idl.char then
|
|
1169
|
+
local cursor = self:jump(length) -- check if there is enougth bytes
|
|
1170
|
+
value = self.data:sub(cursor, cursor + length - 1) --[[VERBOSE]] verbose_unmarshal("got ",verbose.viewer:tostring(value))
|
|
1171
|
+
else
|
|
1172
|
+
value = setmetatable({}, idltype)
|
|
1173
|
+
for i = 1, length do --[[VERBOSE]] verbose_unmarshal("[element ",i,"]")
|
|
1174
|
+
value[i] = self:get(elementtype)
|
|
1175
|
+
end
|
|
1176
|
+
end --[[VERBOSE]] verbose_unmarshal(false)
|
|
1177
|
+
return value
|
|
1178
|
+
end
|
|
1179
|
+
|
|
1180
|
+
function Decoder:typedef(idltype) --[[VERBOSE]] verbose_unmarshal(true, self, idltype)
|
|
1181
|
+
return self:get(idltype.original_type) --[[VERBOSE]],verbose_unmarshal(false)
|
|
1182
|
+
end
|
|
1183
|
+
|
|
1184
|
+
function Decoder:except(idltype) --[[VERBOSE]] verbose_unmarshal(true, self, idltype)
|
|
1185
|
+
local value = {}
|
|
1186
|
+
for _, member in ipairs(idltype.members) do --[[VERBOSE]] verbose_unmarshal("[member ",member.name,"]")
|
|
1187
|
+
value[member.name] = self:get(member.type)
|
|
1188
|
+
end --[[VERBOSE]] verbose_unmarshal(false)
|
|
1189
|
+
return setmetatable(value, idltype)
|
|
1190
|
+
end
|
|
1191
|
+
|
|
1192
|
+
Decoder.interface = Decoder.Object
|
|
1193
|
+
|
|
1194
|
+
function Decoder:abstract_interface(idltype) --[[VERBOSE]] verbose_unmarshal(true, self, idltype)
|
|
1195
|
+
local value
|
|
1196
|
+
if self:boolean() then --[[VERBOSE]] verbose_unmarshal("value is a copied value")
|
|
1197
|
+
value = self:interface(idltype)
|
|
1198
|
+
else --[[VERBOSE]] verbose_unmarshal("value is an object reference")
|
|
1199
|
+
value = self:valuetype(idl.ValueBase)
|
|
1200
|
+
end --[[VERBOSE]] verbose_unmarshal(false)
|
|
1201
|
+
return value
|
|
1202
|
+
end
|
|
1203
|
+
|
|
1204
|
+
-- ValueTypes ------------------------------------------------------------------
|
|
1205
|
+
|
|
1206
|
+
Decoder.ValueTypeNesting = 0
|
|
1207
|
+
|
|
1208
|
+
local decodevaluetype
|
|
1209
|
+
|
|
1210
|
+
local function reservedjump(self, shift)
|
|
1211
|
+
self.jump = nil -- disable chunk decoding
|
|
1212
|
+
local chunkend = self.ChunkEnd
|
|
1213
|
+
if chunkend == nil then
|
|
1214
|
+
local cursor = self.cursor
|
|
1215
|
+
local value = self:long()
|
|
1216
|
+
if value >= MinValueTag then --[[VERBOSE]] verbose_unmarshal("found nested value in chunked encoding")
|
|
1217
|
+
self.cursor = cursor+shift -- rollback the cursor
|
|
1218
|
+
return cursor -- return with chunk decoding disabled
|
|
1219
|
+
elseif value > 0 then
|
|
1220
|
+
chunkend = self.cursor + value -- calculate new chunk end
|
|
1221
|
+
self.ChunkEnd = chunkend --[[VERBOSE]] verbose_unmarshal("value encoding chunk started (end at ",chunkend,")")
|
|
1222
|
+
else -- end tag
|
|
1223
|
+
assert.illegal(self.data,
|
|
1224
|
+
"data stream, chunked value encoding ended prematurely", "MARSHAL")
|
|
1225
|
+
end
|
|
1226
|
+
end
|
|
1227
|
+
local result = self:jump(shift)
|
|
1228
|
+
if self.cursor == chunkend then --[[VERBOSE]] verbose_unmarshal("value encoding chunk finished")
|
|
1229
|
+
self.ChunkEnd = nil
|
|
1230
|
+
elseif chunkend and self.cursor > chunkend then
|
|
1231
|
+
assert.illegal(self.data,
|
|
1232
|
+
"data stream, value chunk ended prematurely", "MARSHAL")
|
|
1233
|
+
end
|
|
1234
|
+
self.jump = reservedjump -- re-enable chunk decoding
|
|
1235
|
+
return result
|
|
1236
|
+
end
|
|
1237
|
+
|
|
1238
|
+
local function skipchunks(self, nesting)
|
|
1239
|
+
self.jump = nil
|
|
1240
|
+
local chunkend = self.ChunkEnd
|
|
1241
|
+
if chunkend then --[[VERBOSE]] verbose_unmarshal("skipping the remains of current chunk")
|
|
1242
|
+
self:jump(chunkend - self.cursor)
|
|
1243
|
+
self.ChunkEnd = nil
|
|
1244
|
+
end
|
|
1245
|
+
repeat
|
|
1246
|
+
local value = self:long()
|
|
1247
|
+
if value >= MinValueTag then --[[VERBOSE]] verbose_unmarshal(true, "skipping nested value")
|
|
1248
|
+
local pos = self.previousend+self.cursor - PrimitiveSizes.ulong --[[VERBOSE]] verbose_unmarshal("calculating position of value for indirections, got ",pos)
|
|
1249
|
+
value = decodevaluetype(self, pos, value) --[[VERBOSE]] verbose_unmarshal(false)
|
|
1250
|
+
self.jump = nil
|
|
1251
|
+
elseif value > 0 then --[[VERBOSE]] verbose_unmarshal("skipping an entire chunk")
|
|
1252
|
+
self:jump(value)
|
|
1253
|
+
else -- end tag
|
|
1254
|
+
self.ValueTypeNesting = -(value+1) --[[VERBOSE]] verbose_unmarshal("found the end tag of a nested value, restoring to nesting level ",self.ValueTypeNesting)
|
|
1255
|
+
end
|
|
1256
|
+
until self.ValueTypeNesting <= nesting
|
|
1257
|
+
if self.ValueTypeNesting > 0 then self.jump = reservedjump end
|
|
1258
|
+
end
|
|
1259
|
+
|
|
1260
|
+
local truncatable = idl.ValueKind.truncatable
|
|
1261
|
+
local function decodevaluestate(self, value, idltype, repidlist, chunked)
|
|
1262
|
+
-- check if chunked decoding is necessary
|
|
1263
|
+
local nesting
|
|
1264
|
+
if chunked then
|
|
1265
|
+
-- increase value nesting level
|
|
1266
|
+
nesting = self.ValueTypeNesting
|
|
1267
|
+
self.ValueTypeNesting = nesting+1
|
|
1268
|
+
-- enable chunked decoding
|
|
1269
|
+
self:align(PrimitiveSizes.long)
|
|
1270
|
+
self.jump = reservedjump
|
|
1271
|
+
end
|
|
1272
|
+
-- find value's type description
|
|
1273
|
+
local type
|
|
1274
|
+
if repidlist == 0 then
|
|
1275
|
+
type = idltype
|
|
1276
|
+
else
|
|
1277
|
+
local types = self.context.types
|
|
1278
|
+
if types then
|
|
1279
|
+
for i = 1, #repidlist do
|
|
1280
|
+
local repID = repidlist[i]
|
|
1281
|
+
type = types:resolve(repID)
|
|
1282
|
+
if type ~= nil then break end --[[VERBOSE]] verbose_unmarshal("skipping unknown truncatable base ",repID)
|
|
1283
|
+
end
|
|
1284
|
+
end
|
|
1285
|
+
if type == nil then
|
|
1286
|
+
assert.illegal(value,
|
|
1287
|
+
"value, all truncatable bases are unknown", "MARSHAL")
|
|
1288
|
+
end
|
|
1289
|
+
assert.type(type, "idl valuetype", "type of received value", "MARSHAL")
|
|
1290
|
+
end --[[VERBOSE]] verbose_unmarshal("decoding value as a ",type.name)
|
|
1291
|
+
setmetatable(value, type)
|
|
1292
|
+
-- collect all base types
|
|
1293
|
+
local types = {}
|
|
1294
|
+
for i = 1, math.huge do
|
|
1295
|
+
types[i] = type
|
|
1296
|
+
type = type.base_value
|
|
1297
|
+
if type == idl.null then break end
|
|
1298
|
+
end
|
|
1299
|
+
-- decode value state
|
|
1300
|
+
for i = #types, 1, -1 do --[[VERBOSE]] verbose_unmarshal("[base value ",types[i].name,"]")
|
|
1301
|
+
local members = types[i].members
|
|
1302
|
+
for j = 1, #members do
|
|
1303
|
+
local member = members[j] --[[VERBOSE]] verbose_unmarshal("[field ",member.name,"]")
|
|
1304
|
+
value[member.name] = self:get(member.type)
|
|
1305
|
+
end
|
|
1306
|
+
end
|
|
1307
|
+
-- finalize decoding of value
|
|
1308
|
+
if chunked then
|
|
1309
|
+
skipchunks(self, nesting) -- skip the remains of this value
|
|
1310
|
+
end
|
|
1311
|
+
-- construct the value using the factory
|
|
1312
|
+
local factory = self.context.factories
|
|
1313
|
+
if factory then
|
|
1314
|
+
factory = factory[types[1].repID]
|
|
1315
|
+
if factory then --[[VERBOSE]] verbose_unmarshal(true, "building value using factory of ",types[1].repID)
|
|
1316
|
+
factory(value) --[[VERBOSE]] verbose_unmarshal(false) else verbose_unmarshal("no factory found for ",types[1].repID)
|
|
1317
|
+
end
|
|
1318
|
+
end
|
|
1319
|
+
end
|
|
1320
|
+
|
|
1321
|
+
function decodevaluetype(self, pos, tag, idltype)
|
|
1322
|
+
-- check for null tag
|
|
1323
|
+
if tag == 0 then
|
|
1324
|
+
return nil --[[VERBOSE]],verbose_unmarshal("got a null")
|
|
1325
|
+
end
|
|
1326
|
+
-- check tag value
|
|
1327
|
+
if tag < MinValueTag or tag > MaxValueTag then
|
|
1328
|
+
assert.illegal(tag, "value tag", "MARSHAL")
|
|
1329
|
+
end
|
|
1330
|
+
-- decode flags contained in the tag
|
|
1331
|
+
local codebase = tag%2
|
|
1332
|
+
tag = tag-codebase
|
|
1333
|
+
local repidlist = tag%8
|
|
1334
|
+
tag = tag-repidlist
|
|
1335
|
+
local chunked = (tag%16 == ChunkedFlag)
|
|
1336
|
+
-- ignore CodeBaseURL string if present
|
|
1337
|
+
if codebase == HasCodeBase then --[[VERBOSE]] verbose_unmarshal("[CodeBaseURL: ignored]")
|
|
1338
|
+
self:indirection(self.indirectstring)
|
|
1339
|
+
end
|
|
1340
|
+
-- decode typing information
|
|
1341
|
+
if repidlist == SingleRepID then --[[VERBOSE]] verbose_unmarshal("[single truncatable base]")
|
|
1342
|
+
repidlist = { self:indirection(self.indirectstring) }
|
|
1343
|
+
elseif repidlist == ListOfRepID then --[[VERBOSE]] verbose_unmarshal("[list of truncatable bases]")
|
|
1344
|
+
repidlist = {}
|
|
1345
|
+
for i = 1, self:long() do
|
|
1346
|
+
repidlist[i] = self:indirection(self.indirectstring)
|
|
1347
|
+
end
|
|
1348
|
+
elseif repidlist ~= 0 then
|
|
1349
|
+
assert.illegal(repidlist,
|
|
1350
|
+
"type information bit pattern in value tag (only 0, "
|
|
1351
|
+
..SingleRepID.." and "..ListOfRepID.." are valid)", "MARSHAL")
|
|
1352
|
+
end
|
|
1353
|
+
-- create value
|
|
1354
|
+
local value = {}
|
|
1355
|
+
self.history[pos] = value
|
|
1356
|
+
if idltype == nil then --[[VERBOSE]] verbose_unmarshal(true, "skipping chunks of a nested value inside a chunked value")
|
|
1357
|
+
-- skipping chunks of a nested value
|
|
1358
|
+
local cursor = self.cursor
|
|
1359
|
+
local nesting = self.ValueTypeNesting
|
|
1360
|
+
function value._complete(_, idltype) --[[VERBOSE]] verbose_unmarshal(true, "resuming decoding of previously skipped nested value")
|
|
1361
|
+
value._complete = nil
|
|
1362
|
+
local cursor_back = self.cursor
|
|
1363
|
+
local nesting_back = self.ValueTypeNesting
|
|
1364
|
+
local chunkend_back = self.ChunkEnd
|
|
1365
|
+
local jump_back = rawget(self, "jump")
|
|
1366
|
+
self.cursor = cursor
|
|
1367
|
+
self.ValueTypeNesting = nesting
|
|
1368
|
+
self.ChunkEnd = nil
|
|
1369
|
+
self.jump = nil
|
|
1370
|
+
decodevaluestate(self, value, idltype, repidlist, chunked)
|
|
1371
|
+
self.cursor = cursor_back
|
|
1372
|
+
self.ValueTypeNesting = nesting_back --[[VERBOSE]] verbose_unmarshal(false)
|
|
1373
|
+
self.ChunkEnd = chunkend_back
|
|
1374
|
+
self.jump = jump_back
|
|
1375
|
+
end
|
|
1376
|
+
self.ValueTypeNesting = nesting+1
|
|
1377
|
+
skipchunks(self, nesting) --[[VERBOSE]] verbose_unmarshal(false)
|
|
1378
|
+
else
|
|
1379
|
+
decodevaluestate(self, value, idltype, repidlist, chunked)
|
|
1380
|
+
end
|
|
1381
|
+
return value
|
|
1382
|
+
end
|
|
1383
|
+
|
|
1384
|
+
function Decoder:valuetype(idltype) --[[VERBOSE]] verbose_unmarshal(true, self, idltype)
|
|
1385
|
+
local value = self:indirection(decodevaluetype, idltype)
|
|
1386
|
+
if value and value._complete then value:_complete() end --[[VERBOSE]] verbose_unmarshal(false)
|
|
1387
|
+
return value
|
|
1388
|
+
end
|
|
1389
|
+
|
|
1390
|
+
-- ValueBox --------------------------------------------------------------------
|
|
1391
|
+
|
|
1392
|
+
local function decodevaluebox(self, pos, tag, idltype)
|
|
1393
|
+
-- check for null tag
|
|
1394
|
+
if tag == 0 then
|
|
1395
|
+
return nil --[[VERBOSE]],verbose_unmarshal("got a null")
|
|
1396
|
+
end
|
|
1397
|
+
-- check tag value
|
|
1398
|
+
local chunked = (tag == MinValueTag+ChunkedFlag)
|
|
1399
|
+
if not chunked and tag ~= MinValueTag then
|
|
1400
|
+
assert.illegal(tag, "value box tag", "MARSHAL")
|
|
1401
|
+
end
|
|
1402
|
+
-- check if chunked decoding is necessary
|
|
1403
|
+
local nesting
|
|
1404
|
+
if chunked then
|
|
1405
|
+
-- increase value nesting level
|
|
1406
|
+
nesting = self.ValueTypeNesting
|
|
1407
|
+
self.ValueTypeNesting = nesting+1
|
|
1408
|
+
-- enable chunked decoding
|
|
1409
|
+
self:align(PrimitiveSizes.long)
|
|
1410
|
+
self.jump = reservedjump
|
|
1411
|
+
end
|
|
1412
|
+
-- decode value state
|
|
1413
|
+
local value = self:get(idltype.original_type)
|
|
1414
|
+
self.history[pos] = value
|
|
1415
|
+
-- finalize decoding of value
|
|
1416
|
+
if chunked then
|
|
1417
|
+
skipchunks(self, nesting) -- skip the remains of this value
|
|
1418
|
+
end
|
|
1419
|
+
return value
|
|
1420
|
+
end
|
|
1421
|
+
|
|
1422
|
+
function Decoder:valuebox(idltype) --[[VERBOSE]] verbose_unmarshal(true, self, idltype)
|
|
1423
|
+
return self:indirection(decodevaluebox, idltype) --[[VERBOSE]],verbose_unmarshal(false)
|
|
1424
|
+
end
|
|
1425
|
+
|
|
1426
|
+
--------------------------------------------------------------------------------
|
|
1427
|
+
|
|
1428
|
+
local function decodetypeinfo(self, pos, kind)
|
|
1429
|
+
local tcinfo = TypeCodeInfo[kind]
|
|
1430
|
+
if tcinfo == nil then assert.illegal(kind, "type code", "MARSHAL") end --[[VERBOSE]] verbose_unmarshal("TypeCode defines a ",tcinfo.name)
|
|
1431
|
+
if tcinfo.unhandled then
|
|
1432
|
+
assert.illegal(tcinfo.name, "supported type code", "MARSHAL")
|
|
1433
|
+
end
|
|
1434
|
+
if tcinfo.type == "empty" then
|
|
1435
|
+
return tcinfo.idl
|
|
1436
|
+
elseif tcinfo.type == "simple" then
|
|
1437
|
+
-- NOTE: The string type is the only simple type being handled,
|
|
1438
|
+
-- therefore parameters are ignored.
|
|
1439
|
+
for _, param in ipairs(tcinfo.parameters) do --[[VERBOSE]] verbose_unmarshal("[parameter ",param.name,"]")
|
|
1440
|
+
self:get(param.type)
|
|
1441
|
+
end
|
|
1442
|
+
return tcinfo.idl
|
|
1443
|
+
elseif tcinfo.type == "complex" then --[[VERBOSE]] verbose_unmarshal(true, "[parameters encapsulation]")
|
|
1444
|
+
local tcparams = self:sequence(idl.OctetSeq)
|
|
1445
|
+
local value = { _type = tcinfo.name }
|
|
1446
|
+
local history = self.history
|
|
1447
|
+
history[pos] = value
|
|
1448
|
+
if not self.encodingTypeCode then
|
|
1449
|
+
history = { [pos] = value } -- do not inherit history, as it is standalone
|
|
1450
|
+
value.tcparams = tcparams
|
|
1451
|
+
end
|
|
1452
|
+
-- create decoder for encapsulated stream
|
|
1453
|
+
local cursor = self.previousend+self.cursor
|
|
1454
|
+
local decoder = Decoder{
|
|
1455
|
+
data = tcparams,
|
|
1456
|
+
context = self.context,
|
|
1457
|
+
history = history,
|
|
1458
|
+
previousend = cursor-1 - #tcparams, -- rolls back before the OctetSeq read
|
|
1459
|
+
encodingTypeCode = true,
|
|
1460
|
+
}
|
|
1461
|
+
decoder:order(decoder:boolean()) -- encapsulated stream includes endianess
|
|
1462
|
+
-- encode parameters using the encapsulated encoder
|
|
1463
|
+
for _, field in ipairs(tcinfo.parameters.fields) do --[[VERBOSE]] verbose_unmarshal("[field ",field.name,"]")
|
|
1464
|
+
value[field.name] = decoder:get(field.type)
|
|
1465
|
+
end
|
|
1466
|
+
if tcinfo.mutable then --[[VERBOSE]] verbose_unmarshal "[mutable parameters values]"
|
|
1467
|
+
for _, param in ipairs(tcinfo.mutable:setup(value)) do
|
|
1468
|
+
value[param.name] = decoder:get(param.type)
|
|
1469
|
+
end
|
|
1470
|
+
end --[[VERBOSE]] verbose_unmarshal(false)
|
|
1471
|
+
-- build local TypeCode value
|
|
1472
|
+
return idl[tcinfo.name](value)
|
|
1473
|
+
end
|
|
1474
|
+
end
|
|
1475
|
+
|
|
1476
|
+
function Decoder:TypeCode() --[[VERBOSE]] verbose_unmarshal(true, self, idl.TypeCode)
|
|
1477
|
+
return self:indirection(decodetypeinfo) --[[VERBOSE]],verbose_unmarshal(false)
|
|
1478
|
+
end
|
|
1479
|
+
|
|
1480
|
+
--------------------------------------------------------------------------------
|
|
1481
|
+
--------------------------------------------------------------------------------
|
|
1482
|
+
|
|
1483
|
+
-- NOTE: second parameter indicates an encasulated octet-stream, therefore
|
|
1484
|
+
-- endianess must be read from stream.
|
|
1485
|
+
function decoder(self, octets, getorder)
|
|
1486
|
+
local decoder = self.Decoder{
|
|
1487
|
+
data = octets,
|
|
1488
|
+
context = self,
|
|
1489
|
+
}
|
|
1490
|
+
if getorder then decoder:order(decoder:boolean()) end
|
|
1491
|
+
return decoder
|
|
1492
|
+
end
|
|
1493
|
+
|
|
1494
|
+
-- NOTE: Presence of a parameter indicates an encapsulated octet-stream.
|
|
1495
|
+
function encoder(self, putorder)
|
|
1496
|
+
local encoder = self.Encoder{ context = self }
|
|
1497
|
+
if putorder then encoder:boolean(NativeEndianess) end
|
|
1498
|
+
return encoder
|
|
1499
|
+
end
|
|
1500
|
+
|
|
1501
|
+
--------------------------------------------------------------------------------
|
|
1502
|
+
--------------------------------------------------------------------------------
|
|
1503
|
+
|
|
1504
|
+
--[[VERBOSE]] local numtype = {
|
|
1505
|
+
--[[VERBOSE]] s = idl.short,
|
|
1506
|
+
--[[VERBOSE]] l = idl.long,
|
|
1507
|
+
--[[VERBOSE]] g = idl.longlong,
|
|
1508
|
+
--[[VERBOSE]] S = idl.ushort,
|
|
1509
|
+
--[[VERBOSE]] L = idl.ulong,
|
|
1510
|
+
--[[VERBOSE]] G = idl.ulonglong,
|
|
1511
|
+
--[[VERBOSE]] f = idl.float,
|
|
1512
|
+
--[[VERBOSE]] d = idl.double,
|
|
1513
|
+
--[[VERBOSE]] D = idl.longdouble,
|
|
1514
|
+
--[[VERBOSE]] }
|
|
1515
|
+
--[[VERBOSE]] verbose.codecop = {
|
|
1516
|
+
--[[VERBOSE]] [Encoder] = "marshal",
|
|
1517
|
+
--[[VERBOSE]] [Decoder] = "unmarshal",
|
|
1518
|
+
--[[VERBOSE]] }
|
|
1519
|
+
--[[VERBOSE]] local luatype = type
|
|
1520
|
+
--[[VERBOSE]] function verbose.custom:marshal(codec, type, value)
|
|
1521
|
+
-- [[VERBOSE]] if CODEC and self.flags.hexastream then
|
|
1522
|
+
-- [[VERBOSE]] self.hexastream(self, CODEC, CURSOR)
|
|
1523
|
+
-- [[VERBOSE]] CURSOR, CODEC = {}, nil
|
|
1524
|
+
-- [[VERBOSE]] end
|
|
1525
|
+
--[[VERBOSE]] local viewer = self.viewer
|
|
1526
|
+
--[[VERBOSE]] local output = viewer.output
|
|
1527
|
+
--[[VERBOSE]] local op = self.codecop[oo.classof(codec)]
|
|
1528
|
+
--[[VERBOSE]] if op then
|
|
1529
|
+
--[[VERBOSE]] type = numtype[type] or type
|
|
1530
|
+
--[[VERBOSE]] output:write(op," of ",type._type)
|
|
1531
|
+
--[[VERBOSE]] type = type.name or type.repID
|
|
1532
|
+
--[[VERBOSE]] if type then
|
|
1533
|
+
--[[VERBOSE]] output:write(" ",type)
|
|
1534
|
+
--[[VERBOSE]] end
|
|
1535
|
+
--[[VERBOSE]] if value ~= nil then
|
|
1536
|
+
--[[VERBOSE]] if luatype(value) == "string" then
|
|
1537
|
+
--[[VERBOSE]] value = value:gsub("[^%w%p%s]", "?")
|
|
1538
|
+
--[[VERBOSE]] end
|
|
1539
|
+
--[[VERBOSE]] output:write(" (got ")
|
|
1540
|
+
--[[VERBOSE]] viewer:write(value)
|
|
1541
|
+
--[[VERBOSE]] output:write(")")
|
|
1542
|
+
--[[VERBOSE]] end
|
|
1543
|
+
--[[VERBOSE]] else
|
|
1544
|
+
--[[VERBOSE]] return true -- cancel custom message
|
|
1545
|
+
--[[VERBOSE]] end
|
|
1546
|
+
--[[VERBOSE]] end
|
|
1547
|
+
--[[VERBOSE]] verbose.custom.unmarshal = verbose.custom.marshal
|
|
1548
|
+
--[[VERBOSE]]
|
|
1549
|
+
--[[VERBOSE]] function verbose_marshal(...)
|
|
1550
|
+
--[[VERBOSE]] verbose:marshal(...)
|
|
1551
|
+
--[[VERBOSE]] if CODEC and verbose.flags.hexastream then
|
|
1552
|
+
--[[VERBOSE]] if CURSOR[SIZEINDEXPOS] and CODEC.ChunkSizeIndex then
|
|
1553
|
+
--[[VERBOSE]] verbose:marshal("[chunk size updated to ",CODEC[CODEC.ChunkSizeIndex],"]")
|
|
1554
|
+
--[[VERBOSE]] end
|
|
1555
|
+
--[[VERBOSE]] verbose:hexastream(CODEC, CURSOR, PREFIXSHIFT)
|
|
1556
|
+
--[[VERBOSE]] CURSOR, CODEC = {}, nil
|
|
1557
|
+
--[[VERBOSE]] end
|
|
1558
|
+
--[[VERBOSE]] end
|
|
1559
|
+
--[[VERBOSE]] function verbose_unmarshal(...)
|
|
1560
|
+
--[[VERBOSE]] verbose:unmarshal(...)
|
|
1561
|
+
--[[VERBOSE]] if CODEC and verbose.flags.hexastream then
|
|
1562
|
+
--[[VERBOSE]] if CURSOR[SIZEINDEXPOS] and CODEC.ChunkSizeIndex then
|
|
1563
|
+
--[[VERBOSE]] verbose:marshal("[chunk size updated to ",CODEC[CODEC.ChunkSizeIndex],"]")
|
|
1564
|
+
--[[VERBOSE]] end
|
|
1565
|
+
--[[VERBOSE]] verbose:hexastream(CODEC, CURSOR)
|
|
1566
|
+
--[[VERBOSE]] CURSOR, CODEC = {}, nil
|
|
1567
|
+
--[[VERBOSE]] end
|
|
1568
|
+
--[[VERBOSE]] end
|