rufus-lua-win 5.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (459) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +69 -0
  6. data/Rakefile +1 -0
  7. data/lib/rufus/lua/win.rb +18 -0
  8. data/lib/rufus/lua/win/version.rb +7 -0
  9. data/rufus-lua-win.gemspec +23 -0
  10. data/vendor/lua/bin/liblua.dll +0 -0
  11. data/vendor/lua/lib/lua/LuaXml.lua +119 -0
  12. data/vendor/lua/lib/lua/alien.lua +250 -0
  13. data/vendor/lua/lib/lua/alien/core.dll +0 -0
  14. data/vendor/lua/lib/lua/alien/struct.dll +0 -0
  15. data/vendor/lua/lib/lua/base.lua +536 -0
  16. data/vendor/lua/lib/lua/bin.lua +20 -0
  17. data/vendor/lua/lib/lua/bit.dll +0 -0
  18. data/vendor/lua/lib/lua/cdlua.dll +0 -0
  19. data/vendor/lua/lib/lua/cdluacontextplus.dll +0 -0
  20. data/vendor/lua/lib/lua/cdluagl.dll +0 -0
  21. data/vendor/lua/lib/lua/cdluaim.dll +0 -0
  22. data/vendor/lua/lib/lua/cdluapdf.dll +0 -0
  23. data/vendor/lua/lib/lua/copas.lua +543 -0
  24. data/vendor/lua/lib/lua/coxpcall.lua +57 -0
  25. data/vendor/lua/lib/lua/date.lua +745 -0
  26. data/vendor/lua/lib/lua/debug_ext.lua +84 -0
  27. data/vendor/lua/lib/lua/debug_init.lua +2 -0
  28. data/vendor/lua/lib/lua/des56.dll +0 -0
  29. data/vendor/lua/lib/lua/dist/config.lua +109 -0
  30. data/vendor/lua/lib/lua/dist/constraints.lua +271 -0
  31. data/vendor/lua/lib/lua/dist/depends.lua +601 -0
  32. data/vendor/lua/lib/lua/dist/git.lua +307 -0
  33. data/vendor/lua/lib/lua/dist/init.lua +278 -0
  34. data/vendor/lua/lib/lua/dist/manifest.lua +225 -0
  35. data/vendor/lua/lib/lua/dist/package.lua +583 -0
  36. data/vendor/lua/lib/lua/dist/sys.lua +367 -0
  37. data/vendor/lua/lib/lua/dist/utils.lua +130 -0
  38. data/vendor/lua/lib/lua/ex.dll +0 -0
  39. data/vendor/lua/lib/lua/fstable.lua +116 -0
  40. data/vendor/lua/lib/lua/getopt.lua +273 -0
  41. data/vendor/lua/lib/lua/git.lua +5 -0
  42. data/vendor/lua/lib/lua/git/core.dll +0 -0
  43. data/vendor/lua/lib/lua/git/objects.lua +121 -0
  44. data/vendor/lua/lib/lua/git/pack.lua +316 -0
  45. data/vendor/lua/lib/lua/git/protocol.lua +188 -0
  46. data/vendor/lua/lib/lua/git/repo.lua +283 -0
  47. data/vendor/lua/lib/lua/git/util.lua +233 -0
  48. data/vendor/lua/lib/lua/gzio.dll +0 -0
  49. data/vendor/lua/lib/lua/gzip.lua +81 -0
  50. data/vendor/lua/lib/lua/iconv.dll +0 -0
  51. data/vendor/lua/lib/lua/imlua.dll +0 -0
  52. data/vendor/lua/lib/lua/imlua_fftw.dll +0 -0
  53. data/vendor/lua/lib/lua/imlua_jp2.dll +0 -0
  54. data/vendor/lua/lib/lua/imlua_process.dll +0 -0
  55. data/vendor/lua/lib/lua/imlua_process_omp.dll +0 -0
  56. data/vendor/lua/lib/lua/io_ext.lua +115 -0
  57. data/vendor/lua/lib/lua/iuplua.dll +0 -0
  58. data/vendor/lua/lib/lua/iuplua_mglplot.dll +0 -0
  59. data/vendor/lua/lib/lua/iuplua_pplot.dll +0 -0
  60. data/vendor/lua/lib/lua/iupluacd.dll +0 -0
  61. data/vendor/lua/lib/lua/iupluacontrols.dll +0 -0
  62. data/vendor/lua/lib/lua/iupluagl.dll +0 -0
  63. data/vendor/lua/lib/lua/iupluaim.dll +0 -0
  64. data/vendor/lua/lib/lua/iupluaimglib.dll +0 -0
  65. data/vendor/lua/lib/lua/iupluatuio.dll +0 -0
  66. data/vendor/lua/lib/lua/lanes-keeper.lua +302 -0
  67. data/vendor/lua/lib/lua/lanes.lua +591 -0
  68. data/vendor/lua/lib/lua/lanes/core.dll +0 -0
  69. data/vendor/lua/lib/lua/lcs.lua +55 -0
  70. data/vendor/lua/lib/lua/lemock.lua +659 -0
  71. data/vendor/lua/lib/lua/lfs.dll +0 -0
  72. data/vendor/lua/lib/lua/list.lua +375 -0
  73. data/vendor/lua/lib/lua/logging.lua +189 -0
  74. data/vendor/lua/lib/lua/logging/console.lua +22 -0
  75. data/vendor/lua/lib/lua/logging/email.lua +44 -0
  76. data/vendor/lua/lib/lua/logging/file.lua +55 -0
  77. data/vendor/lua/lib/lua/logging/rolling_file.lua +81 -0
  78. data/vendor/lua/lib/lua/logging/socket.lua +35 -0
  79. data/vendor/lua/lib/lua/logging/sql.lua +64 -0
  80. data/vendor/lua/lib/lua/loop/base.lua +68 -0
  81. data/vendor/lua/lib/lua/loop/cached.lua +312 -0
  82. data/vendor/lua/lib/lua/loop/collection/MapWithArrayOfKeys.lua +64 -0
  83. data/vendor/lua/lib/lua/loop/collection/ObjectCache.lua +39 -0
  84. data/vendor/lua/lib/lua/loop/collection/OrderedSet.lua +164 -0
  85. data/vendor/lua/lib/lua/loop/collection/PriorityQueue.lua +86 -0
  86. data/vendor/lua/lib/lua/loop/collection/UnorderedArray.lua +32 -0
  87. data/vendor/lua/lib/lua/loop/collection/UnorderedArraySet.lua +56 -0
  88. data/vendor/lua/lib/lua/loop/compiler/Arguments.lua +108 -0
  89. data/vendor/lua/lib/lua/loop/compiler/Conditional.lua +50 -0
  90. data/vendor/lua/lib/lua/loop/compiler/Expression.lua +215 -0
  91. data/vendor/lua/lib/lua/loop/component/base.lua +221 -0
  92. data/vendor/lua/lib/lua/loop/component/contained.lua +71 -0
  93. data/vendor/lua/lib/lua/loop/component/dynamic.lua +223 -0
  94. data/vendor/lua/lib/lua/loop/component/intercepted.lua +354 -0
  95. data/vendor/lua/lib/lua/loop/component/wrapped.lua +195 -0
  96. data/vendor/lua/lib/lua/loop/debug/Inspector.lua +521 -0
  97. data/vendor/lua/lib/lua/loop/debug/Matcher.lua +192 -0
  98. data/vendor/lua/lib/lua/loop/debug/Verbose.lua +266 -0
  99. data/vendor/lua/lib/lua/loop/debug/Viewer.lua +200 -0
  100. data/vendor/lua/lib/lua/loop/multiple.lua +105 -0
  101. data/vendor/lua/lib/lua/loop/object/Exception.lua +57 -0
  102. data/vendor/lua/lib/lua/loop/object/Publisher.lua +43 -0
  103. data/vendor/lua/lib/lua/loop/object/Wrapper.lua +39 -0
  104. data/vendor/lua/lib/lua/loop/scoped.lua +585 -0
  105. data/vendor/lua/lib/lua/loop/serial/FileStream.lua +48 -0
  106. data/vendor/lua/lib/lua/loop/serial/Serializer.lua +291 -0
  107. data/vendor/lua/lib/lua/loop/serial/SocketStream.lua +51 -0
  108. data/vendor/lua/lib/lua/loop/serial/StringStream.lua +47 -0
  109. data/vendor/lua/lib/lua/loop/simple.lua +75 -0
  110. data/vendor/lua/lib/lua/loop/table.lua +71 -0
  111. data/vendor/lua/lib/lua/loop/thread/CoSocket.lua +416 -0
  112. data/vendor/lua/lib/lua/loop/thread/IOScheduler.lua +170 -0
  113. data/vendor/lua/lib/lua/loop/thread/Scheduler.lua +327 -0
  114. data/vendor/lua/lib/lua/loop/thread/SocketScheduler.lua +88 -0
  115. data/vendor/lua/lib/lua/loop/thread/Timer.lua +54 -0
  116. data/vendor/lua/lib/lua/lpeg.dll +0 -0
  117. data/vendor/lua/lib/lua/ltn12.lua +292 -0
  118. data/vendor/lua/lib/lua/luaXML_lib.dll +0 -0
  119. data/vendor/lua/lib/lua/luacurl.dll +0 -0
  120. data/vendor/lua/lib/lua/luadoc/config.lua +34 -0
  121. data/vendor/lua/lib/lua/luadoc/doclet/debug.lua +46 -0
  122. data/vendor/lua/lib/lua/luadoc/doclet/formatter.lua +84 -0
  123. data/vendor/lua/lib/lua/luadoc/doclet/html.lua +289 -0
  124. data/vendor/lua/lib/lua/luadoc/doclet/html/file.lp +113 -0
  125. data/vendor/lua/lib/lua/luadoc/doclet/html/function.lp +64 -0
  126. data/vendor/lua/lib/lua/luadoc/doclet/html/index.lp +70 -0
  127. data/vendor/lua/lib/lua/luadoc/doclet/html/luadoc.css +286 -0
  128. data/vendor/lua/lib/lua/luadoc/doclet/html/menu.lp +55 -0
  129. data/vendor/lua/lib/lua/luadoc/doclet/html/module.lp +109 -0
  130. data/vendor/lua/lib/lua/luadoc/doclet/html/table.lp +15 -0
  131. data/vendor/lua/lib/lua/luadoc/doclet/raw.lua +12 -0
  132. data/vendor/lua/lib/lua/luadoc/init.lua +58 -0
  133. data/vendor/lua/lib/lua/luadoc/lp.lua +130 -0
  134. data/vendor/lua/lib/lua/luadoc/taglet/standard.lua +495 -0
  135. data/vendor/lua/lib/lua/luadoc/taglet/standard/tags.lua +171 -0
  136. data/vendor/lua/lib/lua/luadoc/util.lua +233 -0
  137. data/vendor/lua/lib/lua/luagl.dll +0 -0
  138. data/vendor/lua/lib/lua/luaglu.dll +0 -0
  139. data/vendor/lua/lib/lua/luaidl.lua +113 -0
  140. data/vendor/lua/lib/lua/luaidl/lex.lua +793 -0
  141. data/vendor/lua/lib/lua/luaidl/pre.lua +149 -0
  142. data/vendor/lua/lib/lua/luaidl/sin.lua +3631 -0
  143. data/vendor/lua/lib/lua/luarocks/add.lua +108 -0
  144. data/vendor/lua/lib/lua/luarocks/admin_remove.lua +87 -0
  145. data/vendor/lua/lib/lua/luarocks/build.lua +330 -0
  146. data/vendor/lua/lib/lua/luarocks/build/builtin.lua +253 -0
  147. data/vendor/lua/lib/lua/luarocks/build/cmake.lua +54 -0
  148. data/vendor/lua/lib/lua/luarocks/build/command.lua +32 -0
  149. data/vendor/lua/lib/lua/luarocks/build/make.lua +92 -0
  150. data/vendor/lua/lib/lua/luarocks/cache.lua +85 -0
  151. data/vendor/lua/lib/lua/luarocks/cfg.lua +449 -0
  152. data/vendor/lua/lib/lua/luarocks/command_line.lua +163 -0
  153. data/vendor/lua/lib/lua/luarocks/deps.lua +654 -0
  154. data/vendor/lua/lib/lua/luarocks/dir.lua +69 -0
  155. data/vendor/lua/lib/lua/luarocks/download.lua +90 -0
  156. data/vendor/lua/lib/lua/luarocks/fetch.lua +321 -0
  157. data/vendor/lua/lib/lua/luarocks/fetch/cvs.lua +44 -0
  158. data/vendor/lua/lib/lua/luarocks/fetch/git.lua +81 -0
  159. data/vendor/lua/lib/lua/luarocks/fetch/git_file.lua +17 -0
  160. data/vendor/lua/lib/lua/luarocks/fetch/hg.lua +54 -0
  161. data/vendor/lua/lib/lua/luarocks/fetch/sscm.lua +42 -0
  162. data/vendor/lua/lib/lua/luarocks/fetch/svn.lua +53 -0
  163. data/vendor/lua/lib/lua/luarocks/fs.lua +40 -0
  164. data/vendor/lua/lib/lua/luarocks/fs/lua.lua +676 -0
  165. data/vendor/lua/lib/lua/luarocks/fs/unix.lua +88 -0
  166. data/vendor/lua/lib/lua/luarocks/fs/unix/tools.lua +325 -0
  167. data/vendor/lua/lib/lua/luarocks/fs/win32.lua +107 -0
  168. data/vendor/lua/lib/lua/luarocks/fs/win32/tools.lua +334 -0
  169. data/vendor/lua/lib/lua/luarocks/help.lua +101 -0
  170. data/vendor/lua/lib/lua/luarocks/index.lua +172 -0
  171. data/vendor/lua/lib/lua/luarocks/install.lua +151 -0
  172. data/vendor/lua/lib/lua/luarocks/list.lua +35 -0
  173. data/vendor/lua/lib/lua/luarocks/loader.lua +228 -0
  174. data/vendor/lua/lib/lua/luarocks/make.lua +71 -0
  175. data/vendor/lua/lib/lua/luarocks/make_manifest.lua +34 -0
  176. data/vendor/lua/lib/lua/luarocks/manif.lua +360 -0
  177. data/vendor/lua/lib/lua/luarocks/manif_core.lua +75 -0
  178. data/vendor/lua/lib/lua/luarocks/new_version.lua +141 -0
  179. data/vendor/lua/lib/lua/luarocks/pack.lua +205 -0
  180. data/vendor/lua/lib/lua/luarocks/path.lua +315 -0
  181. data/vendor/lua/lib/lua/luarocks/persist.lua +173 -0
  182. data/vendor/lua/lib/lua/luarocks/refresh_cache.lua +30 -0
  183. data/vendor/lua/lib/lua/luarocks/remove.lua +135 -0
  184. data/vendor/lua/lib/lua/luarocks/rep.lua +313 -0
  185. data/vendor/lua/lib/lua/luarocks/require.lua +6 -0
  186. data/vendor/lua/lib/lua/luarocks/search.lua +399 -0
  187. data/vendor/lua/lib/lua/luarocks/show.lua +138 -0
  188. data/vendor/lua/lib/lua/luarocks/site_config.lua +23 -0
  189. data/vendor/lua/lib/lua/luarocks/tools/patch.lua +712 -0
  190. data/vendor/lua/lib/lua/luarocks/tools/tar.lua +144 -0
  191. data/vendor/lua/lib/lua/luarocks/tools/zip.lua +245 -0
  192. data/vendor/lua/lib/lua/luarocks/type_check.lua +267 -0
  193. data/vendor/lua/lib/lua/luarocks/unpack.lua +151 -0
  194. data/vendor/lua/lib/lua/luarocks/util.lua +420 -0
  195. data/vendor/lua/lib/lua/luarocks/validate.lua +164 -0
  196. data/vendor/lua/lib/lua/luars232.dll +0 -0
  197. data/vendor/lua/lib/lua/luasql/mysql.dll +0 -0
  198. data/vendor/lua/lib/lua/luasql/postgres.dll +0 -0
  199. data/vendor/lua/lib/lua/luasql/sqlite3.dll +0 -0
  200. data/vendor/lua/lib/lua/luaunit.lua +601 -0
  201. data/vendor/lua/lib/lua/lxp.dll +0 -0
  202. data/vendor/lua/lib/lua/lxp/lom.lua +60 -0
  203. data/vendor/lua/lib/lua/math_ext.lua +27 -0
  204. data/vendor/lua/lib/lua/mbox.lua +53 -0
  205. data/vendor/lua/lib/lua/md5.lua +19 -0
  206. data/vendor/lua/lib/lua/md5/core.dll +0 -0
  207. data/vendor/lua/lib/lua/metalua.lua +0 -0
  208. data/vendor/lua/lib/lua/metalua/ast_to_string.mlua +553 -0
  209. data/vendor/lua/lib/lua/metalua/base.lua +104 -0
  210. data/vendor/lua/lib/lua/metalua/bytecode.lua +0 -0
  211. data/vendor/lua/lib/lua/metalua/clopts.mlua +204 -0
  212. data/vendor/lua/lib/lua/metalua/compiler.lua +3 -0
  213. data/vendor/lua/lib/lua/metalua/dollar.mlua +24 -0
  214. data/vendor/lua/lib/lua/metalua/extension/H-runtime.mlua +216 -0
  215. data/vendor/lua/lib/lua/metalua/extension/H.mlua +22 -0
  216. data/vendor/lua/lib/lua/metalua/extension/anaphoric.mlua +54 -0
  217. data/vendor/lua/lib/lua/metalua/extension/clist.mlua +149 -0
  218. data/vendor/lua/lib/lua/metalua/extension/continue.mlua +53 -0
  219. data/vendor/lua/lib/lua/metalua/extension/localin.mlua +2 -0
  220. data/vendor/lua/lib/lua/metalua/extension/log.mlua +39 -0
  221. data/vendor/lua/lib/lua/metalua/extension/match.mlua +374 -0
  222. data/vendor/lua/lib/lua/metalua/extension/ternary.mlua +10 -0
  223. data/vendor/lua/lib/lua/metalua/extension/trycatch.mlua +189 -0
  224. data/vendor/lua/lib/lua/metalua/extension/types-runtime.mlua +159 -0
  225. data/vendor/lua/lib/lua/metalua/extension/types.mlua +352 -0
  226. data/vendor/lua/lib/lua/metalua/extension/withdo.mlua +30 -0
  227. data/vendor/lua/lib/lua/metalua/extension/xglobal-runtime.lua +41 -0
  228. data/vendor/lua/lib/lua/metalua/extension/xglobal.mlua +20 -0
  229. data/vendor/lua/lib/lua/metalua/extension/xloop.mlua +100 -0
  230. data/vendor/lua/lib/lua/metalua/extension/xmatch.mlua +216 -0
  231. data/vendor/lua/lib/lua/metalua/metaloop.mlua +76 -0
  232. data/vendor/lua/lib/lua/metalua/mlc.lua +0 -0
  233. data/vendor/lua/lib/lua/metalua/mlc_xcall.lua +119 -0
  234. data/vendor/lua/lib/lua/metalua/mlp.lua +0 -0
  235. data/vendor/lua/lib/lua/metalua/package2.lua +101 -0
  236. data/vendor/lua/lib/lua/metalua/runtime.lua +3 -0
  237. data/vendor/lua/lib/lua/metalua/string2.lua +44 -0
  238. data/vendor/lua/lib/lua/metalua/table2.lua +372 -0
  239. data/vendor/lua/lib/lua/metalua/walk.mlua +304 -0
  240. data/vendor/lua/lib/lua/metalua/walk/bindings.mlua +41 -0
  241. data/vendor/lua/lib/lua/metalua/walk/id.mlua +186 -0
  242. data/vendor/lua/lib/lua/metalua/walk/scope.lua +54 -0
  243. data/vendor/lua/lib/lua/mime.lua +87 -0
  244. data/vendor/lua/lib/lua/mime/core.dll +0 -0
  245. data/vendor/lua/lib/lua/mobdebug.lua +1484 -0
  246. data/vendor/lua/lib/lua/modules.lua +16 -0
  247. data/vendor/lua/lib/lua/object.lua +56 -0
  248. data/vendor/lua/lib/lua/oil/Exception.lua +26 -0
  249. data/vendor/lua/lib/lua/oil/arch.lua +27 -0
  250. data/vendor/lua/lib/lua/oil/arch/basic/client.lua +29 -0
  251. data/vendor/lua/lib/lua/oil/arch/basic/common.lua +13 -0
  252. data/vendor/lua/lib/lua/oil/arch/basic/server.lua +27 -0
  253. data/vendor/lua/lib/lua/oil/arch/cooperative/common.lua +10 -0
  254. data/vendor/lua/lib/lua/oil/arch/cooperative/server.lua +16 -0
  255. data/vendor/lua/lib/lua/oil/arch/corba/client.lua +39 -0
  256. data/vendor/lua/lib/lua/oil/arch/corba/common.lua +58 -0
  257. data/vendor/lua/lib/lua/oil/arch/corba/intercepted/client.lua +9 -0
  258. data/vendor/lua/lib/lua/oil/arch/corba/intercepted/server.lua +9 -0
  259. data/vendor/lua/lib/lua/oil/arch/corba/server.lua +35 -0
  260. data/vendor/lua/lib/lua/oil/arch/ludo/byref.lua +18 -0
  261. data/vendor/lua/lib/lua/oil/arch/ludo/client.lua +19 -0
  262. data/vendor/lua/lib/lua/oil/arch/ludo/common.lua +18 -0
  263. data/vendor/lua/lib/lua/oil/arch/ludo/server.lua +19 -0
  264. data/vendor/lua/lib/lua/oil/arch/typed/client.lua +27 -0
  265. data/vendor/lua/lib/lua/oil/arch/typed/common.lua +9 -0
  266. data/vendor/lua/lib/lua/oil/arch/typed/server.lua +18 -0
  267. data/vendor/lua/lib/lua/oil/assert.lua +87 -0
  268. data/vendor/lua/lib/lua/oil/builder.lua +45 -0
  269. data/vendor/lua/lib/lua/oil/builder/basic/client.lua +31 -0
  270. data/vendor/lua/lib/lua/oil/builder/basic/common.lua +11 -0
  271. data/vendor/lua/lib/lua/oil/builder/basic/server.lua +13 -0
  272. data/vendor/lua/lib/lua/oil/builder/cooperative/common.lua +11 -0
  273. data/vendor/lua/lib/lua/oil/builder/cooperative/server.lua +11 -0
  274. data/vendor/lua/lib/lua/oil/builder/corba/client.lua +13 -0
  275. data/vendor/lua/lib/lua/oil/builder/corba/common.lua +24 -0
  276. data/vendor/lua/lib/lua/oil/builder/corba/gencode.lua +13 -0
  277. data/vendor/lua/lib/lua/oil/builder/corba/intercepted/client.lua +11 -0
  278. data/vendor/lua/lib/lua/oil/builder/corba/intercepted/server.lua +11 -0
  279. data/vendor/lua/lib/lua/oil/builder/corba/server.lua +13 -0
  280. data/vendor/lua/lib/lua/oil/builder/lua/client.lua +11 -0
  281. data/vendor/lua/lib/lua/oil/builder/lua/server.lua +12 -0
  282. data/vendor/lua/lib/lua/oil/builder/ludo/byref.lua +13 -0
  283. data/vendor/lua/lib/lua/oil/builder/ludo/client.lua +13 -0
  284. data/vendor/lua/lib/lua/oil/builder/ludo/common.lua +14 -0
  285. data/vendor/lua/lib/lua/oil/builder/ludo/server.lua +13 -0
  286. data/vendor/lua/lib/lua/oil/builder/typed/client.lua +16 -0
  287. data/vendor/lua/lib/lua/oil/builder/typed/server.lua +12 -0
  288. data/vendor/lua/lib/lua/oil/compat.lua +846 -0
  289. data/vendor/lua/lib/lua/oil/component.lua +1 -0
  290. data/vendor/lua/lib/lua/oil/corba/giop.lua +301 -0
  291. data/vendor/lua/lib/lua/oil/corba/giop/Codec.lua +1568 -0
  292. data/vendor/lua/lib/lua/oil/corba/giop/CodecGen.lua +589 -0
  293. data/vendor/lua/lib/lua/oil/corba/giop/Exception.lua +25 -0
  294. data/vendor/lua/lib/lua/oil/corba/giop/Indexer.lua +63 -0
  295. data/vendor/lua/lib/lua/oil/corba/giop/Listener.lua +343 -0
  296. data/vendor/lua/lib/lua/oil/corba/giop/Messenger.lua +228 -0
  297. data/vendor/lua/lib/lua/oil/corba/giop/Referrer.lua +180 -0
  298. data/vendor/lua/lib/lua/oil/corba/giop/Requester.lua +462 -0
  299. data/vendor/lua/lib/lua/oil/corba/idl.lua +597 -0
  300. data/vendor/lua/lib/lua/oil/corba/idl/Compiler.lua +133 -0
  301. data/vendor/lua/lib/lua/oil/corba/idl/Importer.lua +235 -0
  302. data/vendor/lua/lib/lua/oil/corba/idl/Indexer.lua +95 -0
  303. data/vendor/lua/lib/lua/oil/corba/idl/Registry.lua +1821 -0
  304. data/vendor/lua/lib/lua/oil/corba/idl/ir.lua +847 -0
  305. data/vendor/lua/lib/lua/oil/corba/idl/sysex.lua +21 -0
  306. data/vendor/lua/lib/lua/oil/corba/iiop/Profiler.lua +200 -0
  307. data/vendor/lua/lib/lua/oil/corba/intercepted/Listener.lua +158 -0
  308. data/vendor/lua/lib/lua/oil/corba/intercepted/Requester.lua +181 -0
  309. data/vendor/lua/lib/lua/oil/corba/services/event.lua +126 -0
  310. data/vendor/lua/lib/lua/oil/corba/services/event/ConsumerAdmin.lua +50 -0
  311. data/vendor/lua/lib/lua/oil/corba/services/event/EventFactory.lua +15 -0
  312. data/vendor/lua/lib/lua/oil/corba/services/event/EventQueue.lua +37 -0
  313. data/vendor/lua/lib/lua/oil/corba/services/event/ProxyPushConsumer.lua +75 -0
  314. data/vendor/lua/lib/lua/oil/corba/services/event/ProxyPushSupplier.lua +62 -0
  315. data/vendor/lua/lib/lua/oil/corba/services/event/SingleDeferredDispatcher.lua +60 -0
  316. data/vendor/lua/lib/lua/oil/corba/services/event/SingleSynchronousDispatcher.lua +39 -0
  317. data/vendor/lua/lib/lua/oil/corba/services/event/SupplierAdmin.lua +50 -0
  318. data/vendor/lua/lib/lua/oil/corba/services/naming.lua +436 -0
  319. data/vendor/lua/lib/lua/oil/kernel/base/Acceptor.lua +268 -0
  320. data/vendor/lua/lib/lua/oil/kernel/base/Channels.lua +121 -0
  321. data/vendor/lua/lib/lua/oil/kernel/base/Connector.lua +147 -0
  322. data/vendor/lua/lib/lua/oil/kernel/base/Dispatcher.lua +99 -0
  323. data/vendor/lua/lib/lua/oil/kernel/base/Proxies.lua +86 -0
  324. data/vendor/lua/lib/lua/oil/kernel/base/Proxies/asynchronous.lua +56 -0
  325. data/vendor/lua/lib/lua/oil/kernel/base/Proxies/protected.lua +17 -0
  326. data/vendor/lua/lib/lua/oil/kernel/base/Proxies/synchronous.lua +17 -0
  327. data/vendor/lua/lib/lua/oil/kernel/base/Proxies/utils.lua +29 -0
  328. data/vendor/lua/lib/lua/oil/kernel/base/Receiver.lua +110 -0
  329. data/vendor/lua/lib/lua/oil/kernel/base/Servants.lua +207 -0
  330. data/vendor/lua/lib/lua/oil/kernel/base/Sockets.lua +44 -0
  331. data/vendor/lua/lib/lua/oil/kernel/cooperative/Receiver.lua +139 -0
  332. data/vendor/lua/lib/lua/oil/kernel/intercepted/Listener.lua +47 -0
  333. data/vendor/lua/lib/lua/oil/kernel/intercepted/Requester.lua +58 -0
  334. data/vendor/lua/lib/lua/oil/kernel/lua/Dispatcher.lua +76 -0
  335. data/vendor/lua/lib/lua/oil/kernel/lua/Proxies.lua +69 -0
  336. data/vendor/lua/lib/lua/oil/kernel/typed/Dispatcher.lua +91 -0
  337. data/vendor/lua/lib/lua/oil/kernel/typed/Proxies.lua +153 -0
  338. data/vendor/lua/lib/lua/oil/kernel/typed/Servants.lua +137 -0
  339. data/vendor/lua/lib/lua/oil/ludo/Codec.lua +66 -0
  340. data/vendor/lua/lib/lua/oil/ludo/CodecByRef.lua +103 -0
  341. data/vendor/lua/lib/lua/oil/ludo/Listener.lua +151 -0
  342. data/vendor/lua/lib/lua/oil/ludo/Referrer.lua +72 -0
  343. data/vendor/lua/lib/lua/oil/ludo/Requester.lua +107 -0
  344. data/vendor/lua/lib/lua/oil/oo.lua +1 -0
  345. data/vendor/lua/lib/lua/oil/port.lua +1 -0
  346. data/vendor/lua/lib/lua/oil/properties.lua +57 -0
  347. data/vendor/lua/lib/lua/oil/verbose.lua +133 -0
  348. data/vendor/lua/lib/lua/package_ext.lua +15 -0
  349. data/vendor/lua/lib/lua/parser.lua +268 -0
  350. data/vendor/lua/lib/lua/pl/Date.lua +555 -0
  351. data/vendor/lua/lib/lua/pl/List.lua +613 -0
  352. data/vendor/lua/lib/lua/pl/Map.lua +113 -0
  353. data/vendor/lua/lib/lua/pl/MultiMap.lua +62 -0
  354. data/vendor/lua/lib/lua/pl/OrderedMap.lua +151 -0
  355. data/vendor/lua/lib/lua/pl/Set.lua +153 -0
  356. data/vendor/lua/lib/lua/pl/app.lua +165 -0
  357. data/vendor/lua/lib/lua/pl/array2d.lua +501 -0
  358. data/vendor/lua/lib/lua/pl/class.lua +180 -0
  359. data/vendor/lua/lib/lua/pl/comprehension.lua +286 -0
  360. data/vendor/lua/lib/lua/pl/config.lua +176 -0
  361. data/vendor/lua/lib/lua/pl/data.lua +606 -0
  362. data/vendor/lua/lib/lua/pl/dir.lua +475 -0
  363. data/vendor/lua/lib/lua/pl/file.lua +70 -0
  364. data/vendor/lua/lib/lua/pl/func.lua +376 -0
  365. data/vendor/lua/lib/lua/pl/init.lua +68 -0
  366. data/vendor/lua/lib/lua/pl/input.lua +173 -0
  367. data/vendor/lua/lib/lua/pl/lapp.lua +407 -0
  368. data/vendor/lua/lib/lua/pl/lexer.lua +456 -0
  369. data/vendor/lua/lib/lua/pl/luabalanced.lua +264 -0
  370. data/vendor/lua/lib/lua/pl/operator.lua +201 -0
  371. data/vendor/lua/lib/lua/pl/path.lua +398 -0
  372. data/vendor/lua/lib/lua/pl/permute.lua +63 -0
  373. data/vendor/lua/lib/lua/pl/platf/luajava.lua +101 -0
  374. data/vendor/lua/lib/lua/pl/pretty.lua +285 -0
  375. data/vendor/lua/lib/lua/pl/seq.lua +551 -0
  376. data/vendor/lua/lib/lua/pl/sip.lua +344 -0
  377. data/vendor/lua/lib/lua/pl/strict.lua +70 -0
  378. data/vendor/lua/lib/lua/pl/stringio.lua +158 -0
  379. data/vendor/lua/lib/lua/pl/stringx.lua +440 -0
  380. data/vendor/lua/lib/lua/pl/tablex.lua +817 -0
  381. data/vendor/lua/lib/lua/pl/template.lua +103 -0
  382. data/vendor/lua/lib/lua/pl/test.lua +135 -0
  383. data/vendor/lua/lib/lua/pl/text.lua +243 -0
  384. data/vendor/lua/lib/lua/pl/utils.lua +550 -0
  385. data/vendor/lua/lib/lua/pl/xml.lua +689 -0
  386. data/vendor/lua/lib/lua/profiler.dll +0 -0
  387. data/vendor/lua/lib/lua/re.lua +248 -0
  388. data/vendor/lua/lib/lua/rex_onig.dll +0 -0
  389. data/vendor/lua/lib/lua/rex_pcre.dll +0 -0
  390. data/vendor/lua/lib/lua/rex_posix.dll +0 -0
  391. data/vendor/lua/lib/lua/rings.dll +0 -0
  392. data/vendor/lua/lib/lua/serialize.lua +193 -0
  393. data/vendor/lua/lib/lua/set.lua +149 -0
  394. data/vendor/lua/lib/lua/socket.lua +133 -0
  395. data/vendor/lua/lib/lua/socket/core.dll +0 -0
  396. data/vendor/lua/lib/lua/socket/ftp.lua +281 -0
  397. data/vendor/lua/lib/lua/socket/http.lua +350 -0
  398. data/vendor/lua/lib/lua/socket/smtp.lua +251 -0
  399. data/vendor/lua/lib/lua/socket/tp.lua +123 -0
  400. data/vendor/lua/lib/lua/socket/url.lua +297 -0
  401. data/vendor/lua/lib/lua/ssl.dll +0 -0
  402. data/vendor/lua/lib/lua/ssl.lua +93 -0
  403. data/vendor/lua/lib/lua/ssl/https.lua +138 -0
  404. data/vendor/lua/lib/lua/stable.lua +28 -0
  405. data/vendor/lua/lib/lua/std.lua +16 -0
  406. data/vendor/lua/lib/lua/strbuf.lua +32 -0
  407. data/vendor/lua/lib/lua/strict.lua +45 -0
  408. data/vendor/lua/lib/lua/string_ext.lua +274 -0
  409. data/vendor/lua/lib/lua/table_ext.lua +117 -0
  410. data/vendor/lua/lib/lua/tar.lua +262 -0
  411. data/vendor/lua/lib/lua/task.dll +0 -0
  412. data/vendor/lua/lib/lua/tree.lua +81 -0
  413. data/vendor/lua/lib/lua/unicode.dll +0 -0
  414. data/vendor/lua/lib/lua/verbose_require.lua +11 -0
  415. data/vendor/lua/lib/lua/vstruct.lua +86 -0
  416. data/vendor/lua/lib/lua/vstruct/ast.lua +192 -0
  417. data/vendor/lua/lib/lua/vstruct/ast/Bitpack.lua +33 -0
  418. data/vendor/lua/lib/lua/vstruct/ast/Generator.lua +174 -0
  419. data/vendor/lua/lib/lua/vstruct/ast/IO.lua +45 -0
  420. data/vendor/lua/lib/lua/vstruct/ast/List.lua +56 -0
  421. data/vendor/lua/lib/lua/vstruct/ast/Name.lua +20 -0
  422. data/vendor/lua/lib/lua/vstruct/ast/Repeat.lua +23 -0
  423. data/vendor/lua/lib/lua/vstruct/ast/Root.lua +19 -0
  424. data/vendor/lua/lib/lua/vstruct/ast/Table.lua +65 -0
  425. data/vendor/lua/lib/lua/vstruct/cursor.lua +81 -0
  426. data/vendor/lua/lib/lua/vstruct/io.lua +45 -0
  427. data/vendor/lua/lib/lua/vstruct/io/a.lua +24 -0
  428. data/vendor/lua/lib/lua/vstruct/io/b.lua +28 -0
  429. data/vendor/lua/lib/lua/vstruct/io/bigendian.lua +21 -0
  430. data/vendor/lua/lib/lua/vstruct/io/c.lua +25 -0
  431. data/vendor/lua/lib/lua/vstruct/io/defaults.lua +24 -0
  432. data/vendor/lua/lib/lua/vstruct/io/endianness.lua +41 -0
  433. data/vendor/lua/lib/lua/vstruct/io/f.lua +129 -0
  434. data/vendor/lua/lib/lua/vstruct/io/hostendian.lua +21 -0
  435. data/vendor/lua/lib/lua/vstruct/io/i.lua +42 -0
  436. data/vendor/lua/lib/lua/vstruct/io/littleendian.lua +21 -0
  437. data/vendor/lua/lib/lua/vstruct/io/m.lua +62 -0
  438. data/vendor/lua/lib/lua/vstruct/io/p.lua +23 -0
  439. data/vendor/lua/lib/lua/vstruct/io/s.lua +27 -0
  440. data/vendor/lua/lib/lua/vstruct/io/seekb.lua +18 -0
  441. data/vendor/lua/lib/lua/vstruct/io/seekf.lua +18 -0
  442. data/vendor/lua/lib/lua/vstruct/io/seekto.lua +18 -0
  443. data/vendor/lua/lib/lua/vstruct/io/u.lua +54 -0
  444. data/vendor/lua/lib/lua/vstruct/io/x.lua +34 -0
  445. data/vendor/lua/lib/lua/vstruct/io/z.lua +63 -0
  446. data/vendor/lua/lib/lua/vstruct/lexer.lua +100 -0
  447. data/vendor/lua/lib/lua/vstruct/pack.lua +142 -0
  448. data/vendor/lua/lib/lua/vstruct/test.lua +47 -0
  449. data/vendor/lua/lib/lua/vstruct/test/basic.lua +73 -0
  450. data/vendor/lua/lib/lua/vstruct/test/common.lua +100 -0
  451. data/vendor/lua/lib/lua/vstruct/test/fp-bigendian.lua +56 -0
  452. data/vendor/lua/lib/lua/vstruct/test/fp-littleendian.lua +56 -0
  453. data/vendor/lua/lib/lua/vstruct/test/struct-test-gen.lua +1230 -0
  454. data/vendor/lua/lib/lua/vstruct/unpack.lua +126 -0
  455. data/vendor/lua/lib/lua/wx.dll +0 -0
  456. data/vendor/lua/lib/lua/xml.lua +75 -0
  457. data/vendor/lua/lib/lua/zip.dll +0 -0
  458. data/vendor/lua/lib/lua/zlib.dll +0 -0
  459. metadata +529 -0
@@ -0,0 +1,1821 @@
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 : IDL Definition Registry --
13
+ -- Authors: Renato Maia <maia@inf.puc-rio.br> --
14
+ --------------------------------------------------------------------------------
15
+ -- interfaces:Facet
16
+ -- interface:table register(definition:table)
17
+ -- interface:table resolve(id:string)
18
+ -- [interface:table] lookup(name:string)
19
+ -- [interface:table] lookup_id(repid:string)
20
+ --------------------------------------------------------------------------------
21
+
22
+ local error = error
23
+ local getmetatable = getmetatable
24
+ local ipairs = ipairs
25
+ local next = next
26
+ local pairs = pairs
27
+ local rawget = rawget
28
+ local select = select
29
+ local setmetatable = setmetatable
30
+ local type = type
31
+ local unpack = unpack
32
+
33
+ local string = require "string"
34
+ local table = require "table"
35
+
36
+ local OrderedSet = require "loop.collection.OrderedSet"
37
+ local Publisher = require "loop.object.Publisher"
38
+
39
+ local oo = require "oil.oo"
40
+ local assert = require "oil.assert"
41
+ local idl = require "oil.corba.idl"
42
+ local iridl = require("oil.corba.idl.ir").definitions
43
+ local Exception = require "oil.corba.giop.Exception" --[[VERBOSE]] local verbose = require "oil.verbose"
44
+
45
+ module "oil.corba.idl.Registry"
46
+
47
+ --------------------------------------------------------------------------------
48
+ -- Internal classes ------------------------------------------------------------
49
+
50
+ IRObject = oo.class()
51
+ Contained = oo.class({}, IRObject)
52
+ Container = oo.class({}, IRObject)
53
+ IDLType = oo.class({}, IRObject)
54
+
55
+ PrimitiveDef = oo.class({ __type = "IDL:omg.org/CORBA/PrimitiveDef:1.0" }, IDLType)
56
+ ArrayDef = oo.class({ __type = "IDL:omg.org/CORBA/ArrayDef:1.0" }, IDLType)
57
+ SequenceDef = oo.class({ __type = "IDL:omg.org/CORBA/SequenceDef:1.0" }, IDLType)
58
+ StringDef = oo.class({ __type = "IDL:omg.org/CORBA/StringDef:1.0" }, IDLType)
59
+ --WstringDef = oo.class({ __type = "IDL:omg.org/CORBA/WstringDef:1.0" }, IDLType)
60
+ --FixedDef = oo.class({ __type = "IDL:omg.org/CORBA/FixedDef:1.0" }, IDLType)
61
+
62
+ MemberDef = oo.class(nil , Contained)
63
+
64
+ AttributeDef = oo.class({ __type = "IDL:omg.org/CORBA/AttributeDef:1.0" }, MemberDef)
65
+ OperationDef = oo.class({ __type = "IDL:omg.org/CORBA/OperationDef:1.0" }, MemberDef)
66
+ ValueMemberDef = oo.class({ __type = "IDL:omg.org/CORBA/ValueMemberDef:1.0" }, MemberDef)
67
+ --ConstantDef = oo.class({ __type = "IDL:omg.org/CORBA/ConstantDef:1.0" }, Contained)
68
+ TypedefDef = oo.class({ __type = "IDL:omg.org/CORBA/TypedefDef:1.0" }, IDLType, Contained)
69
+
70
+ StructDef = oo.class({ __type = "IDL:omg.org/CORBA/StructDef:1.0" }, TypedefDef , Container)
71
+ UnionDef = oo.class({ __type = "IDL:omg.org/CORBA/UnionDef:1.0" }, TypedefDef , Container)
72
+ EnumDef = oo.class({ __type = "IDL:omg.org/CORBA/EnumDef:1.0" }, TypedefDef)
73
+ AliasDef = oo.class({ __type = "IDL:omg.org/CORBA/AliasDef:1.0" }, TypedefDef)
74
+ --NativeDef = oo.class({ __type = "IDL:omg.org/CORBA/NativeDef:1.0" }, TypedefDef)
75
+ ValueBoxDef = oo.class({ __type = "IDL:omg.org/CORBA/ValueBoxDef:1.0" }, TypedefDef)
76
+
77
+ Repository = oo.class({ __type = "IDL:omg.org/CORBA/Repository:1.0" }, Container)
78
+ ModuleDef = oo.class({ __type = "IDL:omg.org/CORBA/ModuleDef:1.0" }, Contained, Container)
79
+ ExceptionDef = oo.class({ __type = "IDL:omg.org/CORBA/ExceptionDef:1.0" }, Contained, Container)
80
+ InterfaceDef = oo.class({ __type = "IDL:omg.org/CORBA/InterfaceDef:1.0" }, IDLType, Contained, Container)
81
+ ValueDef = oo.class({ __type = "IDL:omg.org/CORBA/ValueDef:1.0" }, Container, Contained, IDLType)
82
+
83
+ AbstractInterfaceDef = oo.class({ __type = "IDL:omg.org/CORBA/AbstractInterfaceDef:1.0" }, InterfaceDef)
84
+ LocalInterfaceDef = oo.class({ __type = "IDL:omg.org/CORBA/LocalInterfaceDef:1.0" }, InterfaceDef)
85
+
86
+ --ExtAttributeDef = oo.class({ __type = "IDL:omg.org/CORBA/ExtAttributeDef:1.0" }, AttributeDef)
87
+ --ExtValueDef = oo.class({ __type = "IDL:omg.org/CORBA/ExtValueDef:1.0" }, ValueDef)
88
+ --ExtInterfaceDef = oo.class({ __type = "IDL:omg.org/CORBA/ExtInterfaceDef:1.0" }, InterfaceDef, InterfaceAttrExtension)
89
+ --ExtAbstractInterfaceDef = oo.class({ __type = "IDL:omg.org/CORBA/ExtAbstractInterfaceDef:1.0" }, AbstractInterfaceDef, InterfaceAttrExtension)
90
+ --ExtLocalInterfaceDef = oo.class({ __type = "IDL:omg.org/CORBA/ExtLocalInterfaceDef:1.0" }, LocalInterfaceDef, InterfaceAttrExtension)
91
+
92
+ ObjectRef = oo.class() -- fake class
93
+
94
+ --[[VERBOSE]] local ClassName = {}
95
+ --[[VERBOSE]] for name, class in pairs(_M) do
96
+ --[[VERBOSE]] if oo.isclass(class) then
97
+ --[[VERBOSE]] ClassName[class] = name
98
+ --[[VERBOSE]] end
99
+ --[[VERBOSE]] end
100
+
101
+ --------------------------------------------------------------------------------
102
+ --------------------------------------------------------------------------------
103
+
104
+ local Empty = setmetatable({}, { __newindex = function(_, field) verbose:debug("attempt to set table 'Empty'") end })
105
+
106
+ --------------------------------------------------------------------------------
107
+ --------------------------------------------------------------------------------
108
+
109
+ --
110
+ -- Implementation
111
+ --
112
+
113
+ function IRObject:__init(...)
114
+ self = oo.rawnew(self, ...)
115
+ self.references = self.references or {}
116
+ self.observer = self.observer or Publisher()
117
+ return self
118
+ end
119
+
120
+ function IRObject:watch(object, field)
121
+ local references = object.references
122
+ if references then
123
+ if not references[self] then
124
+ references[self] = {}
125
+ end
126
+ references[self][field] = true
127
+ end
128
+ return object
129
+ end
130
+
131
+ function IRObject:nowatch(object, field)
132
+ local references = object.references
133
+ if references then
134
+ references[self][field] = nil
135
+ if next(references[self]) == nil then
136
+ references[self] = nil
137
+ end
138
+ end
139
+ end
140
+
141
+ function IRObject:notify(...)
142
+ local queue = OrderedSet()
143
+ queue:enqueue(self)
144
+ repeat
145
+ if self.observer then self.observer:notify(...) end
146
+ if self.references then
147
+ for ref in pairs(self.references) do queue:enqueue(ref) end
148
+ end
149
+ self = queue[self]
150
+ until self == nil
151
+ end
152
+
153
+ --
154
+ -- Operations
155
+ --
156
+ function IRObject:destroy()
157
+ if self.observer == nil or next(self.references) ~= nil then
158
+ assert.exception{ "BAD_INV_ORDER", minor_error_code = 1,
159
+ message = "attempt to destroy IR definition in use",
160
+ reason = "irdestroy",
161
+ object = self,
162
+ }
163
+ end
164
+ if self.defined_in then
165
+ self.defined_in.definitions:_remove(self)
166
+ end
167
+ self.containing_repository.definition_map[self.repID] = nil
168
+ end
169
+
170
+ --------------------------------------------------------------------------------
171
+
172
+ --
173
+ -- Implementation
174
+ --
175
+ Contained.version = "1.0"
176
+ Contained.definition_fields = {
177
+ defined_in = { type = Container, optional = true },
178
+ repID = { type = "string" , optional = true },
179
+ version = { type = "string" , optional = true },
180
+ name = { type = "string" },
181
+ }
182
+
183
+ function Contained:update(new)
184
+ new.defined_in = new.defined_in or self.containing_repository
185
+ if new.defined_in.containing_repository ~= self.containing_repository then
186
+ assert.illegal(defined_in,
187
+ "container, repository does not match",
188
+ "BAD_PARAM")
189
+ end
190
+ if new.repID then
191
+ self:_set_id(new.repID)
192
+ end
193
+ self:move(new.defined_in, new.name, new.version)
194
+ end
195
+
196
+ local RepIDFormat = "IDL:%s:%s"
197
+ function Contained:updatename()
198
+ local old = self.absolute_name
199
+ self.absolute_name = self.defined_in.absolute_name.."::"..self.name
200
+ if not self.repID then
201
+ self:_set_id(RepIDFormat:format(self.absolute_name:gsub("::", "/"):sub(2),
202
+ self.version))
203
+ end
204
+ if self.definitions then
205
+ for _, contained in ipairs(self.definitions) do
206
+ contained:updatename()
207
+ end
208
+ end
209
+ if self.absolute_name ~= old then self:notify("absolute_name") end
210
+ end
211
+
212
+ --
213
+ -- Attributes
214
+ --
215
+ function Contained:_set_id(id)
216
+ local definitions = self.containing_repository.definition_map
217
+ if definitions[id] and definitions[id] ~= self then
218
+ assert.illegal(id, "repository ID, already exists", "BAD_PARAM", 2)
219
+ end
220
+ if self.repID then
221
+ definitions[self.repID] = nil
222
+ end
223
+ local old = self.repID
224
+ self.repID = id
225
+ self.id = id
226
+ definitions[id] = self
227
+ if self.repID ~= old then self:notify("repID") end
228
+ end
229
+
230
+ function Contained:_set_name(name)
231
+ local contents = self.defined_in.definitions
232
+ if contents[name] and contents[name] ~= self then
233
+ assert.illegal(name, "contained name, name clash", "BAD_PARAM", 1)
234
+ end
235
+ local old = self.name
236
+ contents:_remove(self)
237
+ self.name = name
238
+ contents:_add(self)
239
+ self:updatename()
240
+ if self.name ~= old then self:notify("name") end
241
+ end
242
+
243
+ --
244
+ -- Operations
245
+ --
246
+ local ContainedDescription = iridl.Contained.definitions.Description
247
+ function Contained:describe()
248
+ local description = self:get_description()
249
+ description.name = self.name
250
+ description.id = self.repID
251
+ description.defined_in = self.defined_in.repID
252
+ description.version = self.version
253
+ return setmetatable({
254
+ kind = self.def_kind,
255
+ value = description,
256
+ }, ContainedDescription)
257
+ end
258
+
259
+ --function Contained:within() -- TODO:[maia] This op is described in specs but
260
+ --end -- is not listed in IR IDL!
261
+
262
+ function Contained:move(new_container, new_name, new_version)
263
+ if new_container.containing_repository ~= self.containing_repository then
264
+ assert.illegal(new_container, "container", "BAD_PARAM", 4)
265
+ end
266
+
267
+ local new = new_container.definitions
268
+ if new[new_name] and new[new_name] ~= self then
269
+ assert.illegal(new_name, "contained name, already exists", "BAD_PARAM", 3)
270
+ end
271
+
272
+ if self.defined_in then
273
+ self.defined_in.definitions:_remove(self)
274
+ end
275
+
276
+ local old = self.defined_in
277
+ self.defined_in = new_container
278
+ self.version = new_version
279
+ self:_set_name(new_name)
280
+ if self.defined_in ~= old then
281
+ if old then old:notify("contents") end
282
+ self.defined_in:notify("contents")
283
+ self:notify("defined_in")
284
+ end
285
+ end
286
+
287
+ --------------------------------------------------------------------------------
288
+
289
+ --
290
+ -- Implementation
291
+ --
292
+ function Container:update()
293
+ if not self.expandable then self.definitions = nil end
294
+ idl.Container(self)
295
+ end
296
+
297
+ local function isingle(self, ended)
298
+ if not ended then return self end
299
+ end
300
+ function Container:hierarchy()
301
+ return isingle, self
302
+ end
303
+
304
+ --
305
+ -- Read interface
306
+ --
307
+
308
+ function Container:lookup(search_name)
309
+ local scope
310
+ if search_name:find("^::") then
311
+ scope = self.containing_repository
312
+ else
313
+ scope = self
314
+ search_name = "::"..search_name
315
+ end
316
+ for nextscope in string.gmatch(search_name, "::([^:]+)") do
317
+ if not scope or not scope.definitions then return nil end
318
+ scope = scope.definitions[nextscope]
319
+ end
320
+ return scope
321
+ end
322
+
323
+ function Container:contents(limit_type, exclude_inherited, max_returned_objs)
324
+ max_returned_objs = max_returned_objs or -1
325
+ local contents = {}
326
+ for container in self:hierarchy() do
327
+ for _, contained in ipairs(container.definitions) do
328
+ if limit_type == "dk_all" or contained.def_kind == limit_type then
329
+ if max_returned_objs == 0 then break end
330
+ contents[#contents+1] = contained
331
+ max_returned_objs = max_returned_objs - 1
332
+ end
333
+ end
334
+ if exclude_inherited then break end
335
+ end
336
+ return contents, max_returned_objs
337
+ end
338
+
339
+ function Container:lookup_name(search_name, levels_to_search,
340
+ limit_type, exclude_inherited)
341
+ local results = {}
342
+ for container in self:hierarchy() do
343
+ for _, contained in ipairs(container.definitions) do
344
+ if
345
+ contained.name == search_name and
346
+ (limit_type == "dk_all" or contained.def_kind == limit_type)
347
+ then
348
+ results[#results+1] = contained
349
+ end
350
+ end
351
+ if exclude_inherited then break end
352
+ end
353
+ return results
354
+ end
355
+
356
+ local ContainerDescription = iridl.Container.definitions.Description
357
+ function Container:describe_contents(limit_type, exclude_inherited,
358
+ max_returned_objs)
359
+ local contents = self:contents(limit_type,
360
+ exclude_inherited,
361
+ max_returned_objs)
362
+ for index, content in ipairs(contents) do
363
+ contents[index] = setmetatable({
364
+ contained_object = content,
365
+ kind = content.def_kind,
366
+ value = content:describe(),
367
+ }, ContainerDescription)
368
+ end
369
+ return contents
370
+ end
371
+
372
+ --
373
+ -- Write interface
374
+ --
375
+
376
+ function Container:create_module(id, name, version)
377
+ local created = ModuleDef{ containing_repository=self.containing_repository }
378
+ created:update{
379
+ defined_in = self,
380
+
381
+ repID = id,
382
+ name = name,
383
+ version = version,
384
+ }
385
+ return created
386
+ end
387
+
388
+ --function Container:create_constant(id, name, version, type, value)
389
+ --end
390
+
391
+ function Container:create_struct(id, name, version, members)
392
+ local created = StructDef{ containing_repository=self.containing_repository }
393
+ created:update{
394
+ defined_in = self,
395
+
396
+ repID = id,
397
+ name = name,
398
+ version = version,
399
+
400
+ fields = members,
401
+ }
402
+ return created
403
+ end
404
+
405
+ function Container:create_union(id, name, version, discriminator_type, members)
406
+ local created = UnionDef{ containing_repository=self.containing_repository }
407
+ created:update{
408
+ defined_in = self,
409
+
410
+ repID = id,
411
+ name = name,
412
+ version = version,
413
+
414
+ switch = discriminator_type.type,
415
+ members = members,
416
+ }
417
+ return created
418
+ end
419
+
420
+ function Container:create_enum(id, name, version, members)
421
+ local created = EnumDef{ containing_repository=self.containing_repository }
422
+ created:update{
423
+ defined_in = self,
424
+
425
+ repID = id,
426
+ name = name,
427
+ version = version,
428
+
429
+ enumvalues = members,
430
+ }
431
+ return created
432
+ end
433
+
434
+ function Container:create_alias(id, name, version, original_type)
435
+ local created = AliasDef{ containing_repository=self.containing_repository }
436
+ created:update{
437
+ defined_in = self,
438
+
439
+ repID = id,
440
+ name = name,
441
+ version = version,
442
+
443
+ original_type = original_type.type
444
+ }
445
+ return created
446
+ end
447
+
448
+ function Container:create_interface(id, name, version, base_interfaces)
449
+ local created = InterfaceDef{ containing_repository=self.containing_repository }
450
+ created:update{
451
+ defined_in = self,
452
+
453
+ repID = id,
454
+ name = name,
455
+ version = version,
456
+
457
+ base_interfaces = base_interfaces,
458
+ }
459
+ return created
460
+ end
461
+
462
+ function Container:create_value(id, name, version,
463
+ is_custom,
464
+ is_abstract,
465
+ base_value,
466
+ is_truncatable,
467
+ abstract_base_values,
468
+ supported_interfaces,
469
+ initializers)
470
+ local created = ValueDef{ containing_repository=self.containing_repository }
471
+ created:update{
472
+ defined_in = self,
473
+
474
+ repID = id,
475
+ name = name,
476
+ version = version,
477
+
478
+ is_custom = is_custom,
479
+ is_abstract = is_abstract,
480
+ is_truncatable = is_truncatable,
481
+
482
+ base_value = base_value,
483
+ abstract_base_values = abstract_base_values,
484
+ supported_interfaces = supported_interfaces,
485
+
486
+ initializers = initializers,
487
+ }
488
+ return created
489
+ end
490
+
491
+ function Container:create_value_box(id, name, version, original_type)
492
+ local created = ValueBoxDef{ containing_repository=self.containing_repository }
493
+ created:update{
494
+ defined_in = self,
495
+
496
+ repID = id,
497
+ name = name,
498
+ version = version,
499
+
500
+ original_type = original_type.type
501
+ }
502
+ return created
503
+ end
504
+
505
+ function Container:create_exception(id, name, version, members)
506
+ local created = ExceptionDef{ containing_repository=self.containing_repository }
507
+ created:update{
508
+ defined_in = self,
509
+
510
+ repID = id,
511
+ name = name,
512
+ version = version,
513
+
514
+ members = members,
515
+ }
516
+ return created
517
+ end
518
+
519
+ --function Container:create_native(id, name, version)
520
+ --end
521
+
522
+ function Container:create_abstract_interface(id, name, version, base_interfaces)
523
+ local created = AbstractInterfaceDef{ containing_repository=self.containing_repository }
524
+ created:update{
525
+ defined_in = self,
526
+
527
+ repID = id,
528
+ name = name,
529
+ version = version,
530
+
531
+ base_interfaces = base_interfaces,
532
+ }
533
+ return created
534
+ end
535
+
536
+ function Container:create_local_interface(id, name, version, base_interfaces)
537
+ local created = LocalInterfaceDef{ containing_repository=self.containing_repository }
538
+ created:update{
539
+ defined_in = self,
540
+
541
+ repID = id,
542
+ name = name,
543
+ version = version,
544
+
545
+ base_interfaces = base_interfaces,
546
+ }
547
+ return created
548
+ end
549
+
550
+ --function Container:create_ext_value(id, name, version,
551
+ -- is_custom,
552
+ -- is_abstract,
553
+ -- base_value,
554
+ -- is_truncatable,
555
+ -- abstract_base_values,
556
+ -- supported_interfaces,
557
+ -- initializers)
558
+ --end
559
+
560
+ --------------------------------------------------------------------------------
561
+
562
+ function IDLType:update()
563
+ self.type = self
564
+ end
565
+
566
+ --------------------------------------------------------------------------------
567
+
568
+ local PrimitiveTypes = {
569
+ pk_null = idl.null,
570
+ pk_void = idl.void,
571
+ pk_short = idl.short,
572
+ pk_long = idl.long,
573
+ pk_longlong = idl.longlong,
574
+ pk_ushort = idl.ushort,
575
+ pk_ulong = idl.ulong,
576
+ pk_ulonglong = idl.ulonglong,
577
+ pk_float = idl.float,
578
+ pk_double = idl.double,
579
+ pk_longdouble = idl.double,
580
+ pk_boolean = idl.boolean,
581
+ pk_char = idl.char,
582
+ pk_octet = idl.octet,
583
+ pk_any = idl.any,
584
+ pk_TypeCode = idl.TypeCode,
585
+ pk_string = idl.string,
586
+ pk_objref = idl.object,
587
+ }
588
+
589
+ PrimitiveDef.def_kind = "dk_Primitive"
590
+
591
+ function PrimitiveDef:__init(object)
592
+ self = oo.rawnew(self, object)
593
+ IDLType.update(self)
594
+ return self
595
+ end
596
+
597
+ for kind, type in pairs(PrimitiveTypes) do
598
+ PrimitiveDef(type).kind = kind
599
+ end
600
+
601
+ --------------------------------------------------------------------------------
602
+
603
+ function ObjectRef:__init(object, registry)
604
+ if object.repID ~= PrimitiveTypes.pk_objref.repID then
605
+ return registry.repository:lookup_id(object.repID) or
606
+ assert.illegal(new, "Object type, use interface definition instead")
607
+ end
608
+ return PrimitiveTypes.pk_objref
609
+ end
610
+
611
+ --------------------------------------------------------------------------------
612
+
613
+ ArrayDef._type = "array"
614
+ ArrayDef.def_kind = "dk_Array"
615
+ ArrayDef.definition_fields = {
616
+ length = { type = "number" },
617
+ elementtype = { type = IDLType },
618
+ }
619
+
620
+ function ArrayDef:update(new, registry)
621
+ self.length = new.length
622
+ self:_set_element_type_def(new.elementtype, registry)
623
+ end
624
+
625
+ function ArrayDef:_get_element_type() return self.elementtype end
626
+
627
+ function ArrayDef:_set_element_type_def(type_def, registry)
628
+ local old = self.elementtype
629
+ type_def = self.containing_repository:put(type_def.type, registry)
630
+ if self.element_type_def then
631
+ self:nowatch(self.element_type_def, "elementtype")
632
+ end
633
+ self.element_type_def = type_def
634
+ self.elementtype = type_def.type
635
+ self:watch(self.element_type_def, "elementtype")
636
+ if self.elementtype ~= old then self:notify("elementtype") end
637
+ end
638
+
639
+ --------------------------------------------------------------------------------
640
+
641
+ SequenceDef._type = "sequence"
642
+ SequenceDef.def_kind = "dk_Sequence"
643
+ SequenceDef.maxlength = 0
644
+ SequenceDef.definition_fields = {
645
+ maxlength = { type = "number", optional = true },
646
+ elementtype = { type = IDLType },
647
+ }
648
+
649
+ function SequenceDef:update(new, registry)
650
+ self.maxlength = new.maxlength
651
+ self:_set_element_type_def(new.elementtype, registry)
652
+ end
653
+
654
+ SequenceDef._get_element_type = ArrayDef._get_element_type
655
+ SequenceDef._set_element_type_def = ArrayDef._set_element_type_def
656
+ function SequenceDef:_set_bound(value) self.maxlength = value end
657
+ function SequenceDef:_get_bound() return self.maxlength end
658
+
659
+ --------------------------------------------------------------------------------
660
+
661
+ StringDef._type = "string"
662
+ StringDef.def_kind = "dk_String"
663
+ StringDef.maxlength = 0
664
+ StringDef.definition_fields = {
665
+ maxlength = { type = "number", optional = true },
666
+ }
667
+ StringDef._set_bound = SequenceDef._set_bound
668
+ StringDef._get_bound = SequenceDef._get_bound
669
+
670
+ function StringDef:update(new)
671
+ self.maxlength = new.maxlength
672
+ end
673
+
674
+ --------------------------------------------------------------------------------
675
+
676
+ function MemberDef:move(new_container, new_name, new_version)
677
+ local name = self.name
678
+ local container = self.defined_in
679
+ Contained.move(self, new_container, new_name, new_version)
680
+ if container then container:nowatch(self, name) end
681
+ self.defined_in:watch(self, self.name)
682
+ end
683
+
684
+ --------------------------------------------------------------------------------
685
+
686
+ AttributeDef._type = "attribute"
687
+ AttributeDef.def_kind = "dk_Attribute"
688
+ AttributeDef.definition_fields = {
689
+ defined_in = { type = Container, optional = true },
690
+ readonly = { type = "boolean", optional = true },
691
+ type = { type = IDLType },
692
+ }
693
+
694
+ function AttributeDef:update(new, registry)
695
+ self:_set_mode(new.readonly and "ATTR_READONLY" or "ATTR_NORMAL")
696
+ self:_set_type_def(new.type, registry)
697
+ end
698
+
699
+ function AttributeDef:_set_mode(value)
700
+ local old = self.readonly
701
+ self.mode = value
702
+ self.readonly = (value == "ATTR_READONLY")
703
+ if self.readonly ~= old then self:notify("readonly") end
704
+ end
705
+
706
+ function AttributeDef:_set_type_def(type_def, registry)
707
+ local old = self.type
708
+ type_def = self.containing_repository:put(type_def.type, registry)
709
+ if self.type_def then
710
+ self:nowatch(self.type_def, "type")
711
+ end
712
+ self.type_def = type_def
713
+ self.type = type_def.type
714
+ self:watch(self.type_def, "type")
715
+ if self.type ~= old then self:notify("type") end
716
+ end
717
+
718
+ function AttributeDef:get_description()
719
+ return setmetatable({
720
+ type = self.type,
721
+ mode = self.mode,
722
+ }, iridl.AttributeDescription)
723
+ end
724
+
725
+ --------------------------------------------------------------------------------
726
+
727
+ OperationDef._type = "operation"
728
+ OperationDef.def_kind = "dk_Operation"
729
+ OperationDef.contexts = Empty
730
+ OperationDef.parameters = Empty
731
+ OperationDef.inputs = Empty
732
+ OperationDef.outputs = Empty
733
+ OperationDef.exceptions = Empty
734
+ OperationDef.result = idl.void
735
+ OperationDef.result_def = idl.void
736
+ OperationDef.definition_fields = {
737
+ defined_in = { type = Container , optional = true },
738
+ oneway = { type = "boolean" , optional = true },
739
+ contexts = { type = "table" , optional = true },
740
+ exceptions = { type = ExceptionDef, optional = true, list = true },
741
+ result = { type = IDLType , optional = true },
742
+ parameters = { type = {
743
+ name = { type = "string" },
744
+ type = { type = IDLType },
745
+ mode = { type = "string", optional = true },
746
+ }, optional = true, list = true },
747
+ }
748
+
749
+ function OperationDef:update(new, registry)
750
+ self:_set_mode(new.oneway and "OP_ONEWAY" or "OP_NORMAL")
751
+ if new.exceptions then self:_set_exceptions(new.exceptions, registry) end
752
+ if new.result then self:_set_result_def(new.result, registry) end
753
+ if new.parameters then self:_set_params(new.parameters, registry) end
754
+ self.contexts = new.contexts
755
+ end
756
+
757
+ function OperationDef:_set_mode(value)
758
+ local old = self.oneway
759
+ self.mode = value
760
+ self.oneway = (value == "OP_ONEWAY")
761
+ if self.oneway ~= old then self:notify("oneway") end
762
+ end
763
+
764
+ function OperationDef:_set_result_def(type_def, registry)
765
+ type_def = self.containing_repository:put(type_def.type, registry)
766
+ local current = self.result
767
+ local newval = type_def.type
768
+ if current ~= newval then
769
+ if self.result_def then
770
+ self:nowatch(self.result_def, "result")
771
+ end
772
+ self.result_def = type_def
773
+ self.result = newval
774
+ self:watch(self.result_def, "result")
775
+ if current == idl.void then
776
+ if self.outputs == Empty then
777
+ self.outputs = { newval }
778
+ else
779
+ self.outputs = { newval, unpack(self.outputs) }
780
+ end
781
+ elseif newval == idl.void then
782
+ self.outputs = { unpack(self.outputs, 2) }
783
+ else
784
+ self.outputs = { newval, unpack(self.outputs, 2) }
785
+ end
786
+ self:notify("result")
787
+ end
788
+ end
789
+
790
+ function OperationDef:_get_params() return self.parameters end
791
+ function OperationDef:_set_params(parameters, registry)
792
+ local inputs = {}
793
+ local outputs = {}
794
+ if self.result ~= idl.void then
795
+ outputs[#outputs+1] = self.result
796
+ end
797
+ for index, param in ipairs(parameters) do
798
+ param.type_def = self.containing_repository:put(param.type, registry)
799
+ param.type = param.type_def.type
800
+ param.mode = param.mode or "PARAM_IN"
801
+ if param.mode == "PARAM_IN" then
802
+ inputs[#inputs+1] = param.type
803
+ elseif param.mode == "PARAM_OUT" then
804
+ outputs[#outputs+1] = param.type
805
+ elseif param.mode == "PARAM_INOUT" then
806
+ inputs[#inputs+1] = param.type
807
+ outputs[#outputs+1] = param.type
808
+ else
809
+ assert.illegal(mode, "operation parameter mode")
810
+ end
811
+ end
812
+ for index, param in ipairs(self.parameters) do
813
+ self:nowatch(param.type_def, "parameter "..index)
814
+ end
815
+ self.parameters = parameters
816
+ self.inputs = inputs
817
+ self.outputs = outputs
818
+ for index, param in ipairs(self.parameters) do
819
+ self:watch(param.type_def, "parameter "..index)
820
+ end
821
+ self:notify("parameters")
822
+ end
823
+
824
+ function OperationDef:_set_exceptions(exceptions, registry)
825
+ for index, except in ipairs(exceptions) do
826
+ except = self.containing_repository:put(except:get_description().type, registry)
827
+ exceptions[index] = except
828
+ exceptions[except.repID] = except
829
+ end
830
+ for index, except in ipairs(self.exceptions) do
831
+ self:nowatch(except, "exception "..index)
832
+ end
833
+ self.exceptions = exceptions
834
+ for index, except in ipairs(self.exceptions) do
835
+ self:watch(except, "exception "..index)
836
+ end
837
+ self:notify("exceptions")
838
+ end
839
+
840
+ function OperationDef:get_description()
841
+ local exceptions = {}
842
+ for _, except in ipairs(self.exceptions) do
843
+ exceptions[#exceptions+1] = except:describe().value
844
+ end
845
+ return setmetatable({
846
+ result = self.result,
847
+ mode = self.mode,
848
+ contexts = self.contexts,
849
+ parameters = self.parameters,
850
+ exceptions = exceptions,
851
+ }, iridl.OperationDescription)
852
+ end
853
+
854
+ --------------------------------------------------------------------------------
855
+
856
+ ValueMemberDef._type = "valuemember"
857
+ ValueMemberDef.def_kind = "dk_ValueMember"
858
+ ValueMemberDef.access = 0
859
+ ValueMemberDef.definition_fields = {
860
+ defined_in = { type = ValueDef, optional = true },
861
+ type = { type = IDLType },
862
+ access = { type = "number" },
863
+ }
864
+
865
+ function ValueMemberDef:update(new, registry)
866
+ self.access = new.access
867
+ self:_set_type_def(new.type, registry)
868
+ end
869
+
870
+ function ValueMemberDef:move(new_container, new_name, new_version)
871
+ local old_container = self.defined_in
872
+ if old_container and old_container ~= self.containing_repository then
873
+ local members = old_container.members
874
+ for index, member in ipairs(members) do
875
+ if member == self then
876
+ table.remove(members, index)
877
+ break
878
+ end
879
+ end
880
+ end
881
+ MemberDef.move(self, new_container, new_name, new_version)
882
+ if new_container._type == "valuetype" then
883
+ local members = new_container.members
884
+ members[#members+1] = self
885
+ elseif new_container ~= self.containing_repository then
886
+ assert.illegal(new_container, "ValueMemberDef container", "BAD_PARAM", 4)
887
+ end
888
+ end
889
+
890
+ function ValueMemberDef:get_description()
891
+ return setmetatable({
892
+ type = self.type,
893
+ type_def = self.type_def,
894
+ access = self.access,
895
+ }, iridl.ValueMember)
896
+ end
897
+
898
+ function ValueMemberDef:_set_type_def(type_def, registry)
899
+ local old = self.type
900
+ type_def = self.containing_repository:put(type_def.type, registry)
901
+ self.type_def = type_def
902
+ self.type = type_def.type
903
+ if self.type ~= old then self:notify("type") end
904
+ end
905
+
906
+ --------------------------------------------------------------------------------
907
+
908
+ TypedefDef._type = "typedef"
909
+ TypedefDef.def_kind = "dk_Typedef"
910
+
911
+ function TypedefDef:get_description()
912
+ return setmetatable({ type = self.type }, iridl.TypeDescription)
913
+ end
914
+
915
+ --------------------------------------------------------------------------------
916
+
917
+ StructDef._type = "struct"
918
+ StructDef.def_kind = "dk_Struct"
919
+ StructDef.fields = Empty
920
+ StructDef.definition_fields = {
921
+ fields = {
922
+ type = {
923
+ name = { type = "string" },
924
+ type = { type = IDLType },
925
+ },
926
+ optional = true,
927
+ list = true,
928
+ },
929
+ }
930
+
931
+ function StructDef:update(new, registry)
932
+ if new.fields then self:_set_members(new.fields, registry) end
933
+ end
934
+
935
+ function StructDef:_get_members() return self.fields end
936
+ function StructDef:_set_members(members, registry)
937
+ for index, field in ipairs(members) do
938
+ field.type_def = self.containing_repository:put(field.type, registry)
939
+ field.type = field.type_def.type
940
+ end
941
+ for index, field in ipairs(self.fields) do
942
+ self:nowatch(field.type_def, "field "..field.name)
943
+ end
944
+ self.fields = members
945
+ for index, field in ipairs(self.fields) do
946
+ self:watch(field.type_def, "field "..field.name)
947
+ end
948
+ self:notify("fields")
949
+ end
950
+
951
+ --------------------------------------------------------------------------------
952
+
953
+ UnionDef._type = "union"
954
+ UnionDef.def_kind = "dk_Union"
955
+ UnionDef.default = -1
956
+ UnionDef.options = Empty
957
+ UnionDef.members = Empty
958
+ UnionDef.definition_fields = {
959
+ switch = { type = IDLType },
960
+ default = { type = "number", optional = true },
961
+ options = { type = {
962
+ label = { type = nil },
963
+ name = { type = "string" },
964
+ type = { type = IDLType },
965
+ }, optional = true, list = true },
966
+ }
967
+
968
+ function UnionDef:update(new, registry)
969
+ self:_set_discriminator_type_def(new.switch, registry)
970
+
971
+ if new.options then
972
+ for _, option in ipairs(new.options) do
973
+ option.label = {
974
+ _anyval = option.label,
975
+ _anytype = self.switch,
976
+ }
977
+ end
978
+ self:_set_members(new.options)
979
+ end
980
+
981
+ function self.__index(union, field)
982
+ if rawget(union, "_switch") == self.selector[field] then
983
+ return rawget(union, "_value")
984
+ end
985
+ end
986
+ function self.__newindex(union, field, value)
987
+ local label = self.selector[field]
988
+ if label then
989
+ rawset(union, "_switch", label)
990
+ rawset(union, "_value", value)
991
+ rawset(union, "_field", field)
992
+ end
993
+ end
994
+ end
995
+
996
+ function UnionDef:_get_discriminator_type() return self.switch end
997
+
998
+ function UnionDef:_set_discriminator_type_def(type_def, registry)
999
+ local old = self.switch
1000
+ type_def = self.containing_repository:put(type_def.type, registry)
1001
+ if self.discriminator_type_def then
1002
+ self:nowatch(self.discriminator_type_def, "switch")
1003
+ end
1004
+ self.discriminator_type_def = type_def
1005
+ self.switch = type_def.type
1006
+ self:watch(self.discriminator_type_def, "switch")
1007
+ if self.switch ~= old then self:notify("switch") end
1008
+ end
1009
+
1010
+ function UnionDef:_set_members(members, registry)
1011
+ local options = {}
1012
+ local selector = {}
1013
+ local selection = {}
1014
+ for index, member in ipairs(members) do
1015
+ member.type_def = self.containing_repository:put(member.type, registry)
1016
+ member.type = member.type_def.type
1017
+ local option = {
1018
+ label = member.label._anyval,
1019
+ name = member.name,
1020
+ type = member.type,
1021
+ type_def = member.type_def,
1022
+ }
1023
+ options[index] = option
1024
+ selector[option.name] = option.label
1025
+ selection[option.label] = option
1026
+ end
1027
+ for index, member in ipairs(self.members) do
1028
+ self:nowatch(member.type_def, "option "..index)
1029
+ end
1030
+ self.options = options
1031
+ self.selector = selector
1032
+ self.selection = selection
1033
+ self.members = members
1034
+ for index, member in ipairs(self.members) do
1035
+ self:watch(member.type_def, "option "..index)
1036
+ end
1037
+ self:notify("options")
1038
+ end
1039
+
1040
+ --------------------------------------------------------------------------------
1041
+
1042
+ EnumDef._type = "enum"
1043
+ EnumDef.def_kind = "dk_Enum"
1044
+ EnumDef.definition_fields = {
1045
+ enumvalues = { type = "string", list = true },
1046
+ }
1047
+
1048
+ function EnumDef:update(new)
1049
+ self:_set_members(new.enumvalues)
1050
+ end
1051
+
1052
+ function EnumDef:_get_members() return self.enumvalues end
1053
+ function EnumDef:_set_members(members)
1054
+ local labelvalue = {}
1055
+ for index, label in ipairs(members) do
1056
+ labelvalue[label] = index - 1
1057
+ end
1058
+ self.enumvalues = members
1059
+ self.labelvalue = labelvalue
1060
+ self:notify("enumvalues")
1061
+ end
1062
+
1063
+ --------------------------------------------------------------------------------
1064
+
1065
+ AliasDef._type = "typedef"
1066
+ AliasDef.def_kind = "dk_Alias"
1067
+ AliasDef.definition_fields = {
1068
+ original_type = { type = IDLType },
1069
+ }
1070
+
1071
+ function AliasDef:update(new, registry)
1072
+ self:_set_original_type_def(new.original_type, registry)
1073
+ end
1074
+
1075
+ function AliasDef:_set_original_type_def(type_def, registry)
1076
+ local old = self.type
1077
+ type_def = self.containing_repository:put(type_def.type, registry)
1078
+ self.original_type_def = type_def
1079
+ self.original_type = type_def.type
1080
+ if self.type ~= old then self:notify("type") end
1081
+ end
1082
+
1083
+ --------------------------------------------------------------------------------
1084
+
1085
+ ValueBoxDef._type = "valuebox"
1086
+ ValueBoxDef.def_kind = "dk_ValueBox"
1087
+ ValueBoxDef.definition_fields = AliasDef.definition_fields
1088
+ ValueBoxDef.update = AliasDef.update
1089
+ ValueBoxDef._set_original_type_def = AliasDef._set_original_type_def
1090
+
1091
+ --------------------------------------------------------------------------------
1092
+
1093
+ Repository.def_kind = "dk_Repository"
1094
+ Repository.repID = ""
1095
+ Repository.absolute_name = ""
1096
+
1097
+ function Repository:__init(object)
1098
+ self = oo.rawnew(self, object)
1099
+ self.containing_repository = self
1100
+ self.definition_map = self.definition_map or {}
1101
+ Container.update(self, self)
1102
+ return self
1103
+ end
1104
+
1105
+ --
1106
+ -- Read interface
1107
+ --
1108
+
1109
+ function Repository:lookup_id(search_id)
1110
+ return self.definition_map[search_id]
1111
+ end
1112
+
1113
+ --function Repository:get_canonical_typecode(tc)
1114
+ --end
1115
+
1116
+ function Repository:get_primitive(kind)
1117
+ return PrimitiveTypes[kind]
1118
+ end
1119
+
1120
+ --
1121
+ -- Write interface
1122
+ --
1123
+ --
1124
+ --function Repository:create_string(bound)
1125
+ --end
1126
+ --
1127
+ --function Repository:create_wstring(bound)
1128
+ --end
1129
+
1130
+ function Repository:create_sequence(bound, element_type)
1131
+ local created = SequenceDef{ containing_repository=self.containing_repository }
1132
+ created:update{
1133
+ elementtype = element_type.type,
1134
+ maxlength = bound,
1135
+ }
1136
+ return created
1137
+ end
1138
+
1139
+ function Repository:create_array(length, element_type)
1140
+ local created = ArrayDef{ containing_repository=self.containing_repository }
1141
+ created:update{
1142
+ elementtype = element_type.type,
1143
+ length = length,
1144
+ }
1145
+ return created
1146
+ end
1147
+
1148
+ --function Repository:create_fixed(digits, scale)
1149
+ --end
1150
+
1151
+ --------------------------------------------------------------------------------
1152
+
1153
+ --function ExtAttributeDef:describe_attribute()
1154
+ --end
1155
+
1156
+ --------------------------------------------------------------------------------
1157
+
1158
+ ModuleDef._type = "module"
1159
+ ModuleDef.def_kind = "dk_Module"
1160
+ ModuleDef.expandable = true
1161
+
1162
+ function ModuleDef:get_description()
1163
+ return setmetatable({}, iridl.ModuleDescription)
1164
+ end
1165
+
1166
+ --------------------------------------------------------------------------------
1167
+
1168
+ ExceptionDef._type = "except"
1169
+ ExceptionDef.def_kind = "dk_Exception"
1170
+ ExceptionDef.members = Empty
1171
+ ExceptionDef.definition_fields = {
1172
+ members = { type = {
1173
+ name = { type = "string" },
1174
+ type = { type = IDLType },
1175
+ }, optional = true, list = true },
1176
+ }
1177
+
1178
+ function ExceptionDef:update(new, registry)
1179
+ self.type = self
1180
+ if new.members then self:_set_members(new.members, registry) end
1181
+ end
1182
+
1183
+ function ExceptionDef:_set_members(members, registry)
1184
+ for index, member in ipairs(members) do
1185
+ member.type_def = self.containing_repository:put(member.type, registry)
1186
+ member.type = member.type_def.type
1187
+ end
1188
+ for index, member in ipairs(self.members) do
1189
+ self:nowatch(member.type_def, "member "..member.name)
1190
+ end
1191
+ self.members = members
1192
+ for index, member in ipairs(self.members) do
1193
+ self:watch(member.type_def, "member "..member.name)
1194
+ end
1195
+ self:notify("members")
1196
+ end
1197
+
1198
+ function ExceptionDef:get_description()
1199
+ return setmetatable({ type = self }, iridl.ExceptionDescription)
1200
+ end
1201
+
1202
+ --------------------------------------------------------------------------------
1203
+
1204
+ local function changeinheritance(container, old, new, type)
1205
+ for _, base in ipairs(new) do
1206
+ if type then
1207
+ assert.type(base, type, "inherited definition", "BAD_PARAM", 4)
1208
+ end
1209
+ for _, contained in ipairs(container.definitions) do
1210
+ if #base:lookup_name(contained.name, -1, "dk_All", false) > 0 then
1211
+ assert.illegal(ifaces,
1212
+ "inheritance, member '"..
1213
+ member.name..
1214
+ "' override not allowed",
1215
+ "BAD_PARAM", 5)
1216
+ end
1217
+ end
1218
+ end
1219
+ for index, base in ipairs(old) do
1220
+ container:nowatch(base, "base "..index)
1221
+ end
1222
+ for index, base in ipairs(new) do
1223
+ container:watch(base, "base "..index)
1224
+ end
1225
+ container:notify("inheritance", type)
1226
+ return new
1227
+ end
1228
+
1229
+ --------------------------------------------------------------------------------
1230
+
1231
+ InterfaceDef._type = "interface"
1232
+ InterfaceDef.def_kind = "dk_Interface"
1233
+ InterfaceDef.base_interfaces = Empty
1234
+ InterfaceDef.definition_fields = {
1235
+ base_interfaces = { type = InterfaceDef, optional = true, list = true },
1236
+ }
1237
+
1238
+ InterfaceDef.hierarchy = idl.basesof
1239
+
1240
+ function InterfaceDef:update(new)
1241
+ if new.base_interfaces then
1242
+ self:_set_base_interfaces(new.base_interfaces)
1243
+ end
1244
+ end
1245
+
1246
+ function InterfaceDef:get_description()
1247
+ local base_interfaces = {}
1248
+ for index, base in ipairs(self.base_interfaces) do
1249
+ base_interfaces[index] = base.repID
1250
+ end
1251
+ return setmetatable({ base_interfaces = base_interfaces },
1252
+ iridl.InterfaceDescription)
1253
+ end
1254
+
1255
+ --
1256
+ -- Read interface
1257
+ --
1258
+
1259
+ function InterfaceDef:is_a(interface_id)
1260
+ if interface_id == self.repID then return true end
1261
+ for _, base in ipairs(self.base_interfaces) do
1262
+ if base:is_a(interface_id) then return true end
1263
+ end
1264
+ return false
1265
+ end
1266
+
1267
+ local FullIfaceDescription = iridl.InterfaceDef.definitions.FullInterfaceDescription
1268
+ function InterfaceDef:describe_interface()
1269
+ local operations = {}
1270
+ local attributes = {}
1271
+ local base_interfaces = {}
1272
+ for index, base in ipairs(self.base_interfaces) do
1273
+ base_interfaces[index] = base.repID
1274
+ end
1275
+ for base in self:hierarchy() do
1276
+ for _, contained in ipairs(base.definitions) do
1277
+ if contained._type == "attribute" then
1278
+ attributes[#attributes+1] = contained:describe().value
1279
+ elseif contained._type == "operation" then
1280
+ operations[#operations+1] = contained:describe().value
1281
+ end
1282
+ end
1283
+ end
1284
+ return setmetatable({
1285
+ name = self.name,
1286
+ id = self.id,
1287
+ defined_in = self.defined_in.repID,
1288
+ version = self.version,
1289
+ base_interfaces = base_interfaces,
1290
+ type = self,
1291
+ operations = operations,
1292
+ attributes = attributes,
1293
+ }, FullIfaceDescription)
1294
+ end
1295
+
1296
+ --
1297
+ -- Write interface
1298
+ --
1299
+
1300
+ function InterfaceDef:_set_base_interfaces(bases)
1301
+ for _, base in ipairs(bases) do
1302
+ if base._type ~= "interface" and base._type ~= "abstract_interface" then
1303
+ assert.illegal(base, "inherited definition", "BAD_PARAM", 4)
1304
+ end
1305
+ end
1306
+ self.base_interfaces = changeinheritance(self,
1307
+ self.base_interfaces,
1308
+ bases)
1309
+ end
1310
+
1311
+ function InterfaceDef:create_attribute(id, name, version, type, mode)
1312
+ local created = AttributeDef{ containing_repository=self.containing_repository }
1313
+ created:update{
1314
+ defined_in = self,
1315
+
1316
+ repID = id,
1317
+ name = name,
1318
+ version = version,
1319
+
1320
+ type = type.type,
1321
+ readonly = (mode == "ATTR_READONLY"),
1322
+ }
1323
+ return created
1324
+ end
1325
+
1326
+ function InterfaceDef:create_operation(id, name, version,
1327
+ result, mode, params,
1328
+ exceptions, contexts)
1329
+ local created = OperationDef{ containing_repository=self.containing_repository }
1330
+ created:update{
1331
+ defined_in = self,
1332
+
1333
+ repID = id,
1334
+ name = name,
1335
+ version = version,
1336
+
1337
+ result = result.type,
1338
+
1339
+ parameters = params,
1340
+ exceptions = exceptions,
1341
+ contexts = contexts,
1342
+
1343
+ oneway = (mode == "OP_ONEWAY"),
1344
+ }
1345
+ return created
1346
+ end
1347
+
1348
+ --------------------------------------------------------------------------------
1349
+
1350
+ --
1351
+ -- Write interface
1352
+ --
1353
+
1354
+ AbstractInterfaceDef._type = "abstract_interface"
1355
+ AbstractInterfaceDef.def_kind = "dk_AbstractInterface"
1356
+ AbstractInterfaceDef.definition_fields = {
1357
+ base_interfaces = { type = AbstractInterfaceDef, optional = true, list = true },
1358
+ }
1359
+ function AbstractInterfaceDef:_set_base_interfaces(bases)
1360
+ self.base_interfaces = changeinheritance(self,
1361
+ self.base_interfaces,
1362
+ bases,
1363
+ "idl abstract_interface")
1364
+ end
1365
+
1366
+ --------------------------------------------------------------------------------
1367
+
1368
+ --
1369
+ -- Write interface
1370
+ --
1371
+
1372
+ LocalInterfaceDef._type = "local_interface"
1373
+ LocalInterfaceDef.def_kind = "dk_LocalInterface"
1374
+ function LocalInterfaceDef:_set_base_interfaces(bases)
1375
+ for _, base in ipairs(bases) do
1376
+ if base._type ~= "interface" and base._type ~= "local_interface" then
1377
+ assert.illegal(base, "inherited definition", "BAD_PARAM", 4)
1378
+ end
1379
+ end
1380
+ self.base_interfaces = changeinheritance(self,
1381
+ self.base_interfaces,
1382
+ bases)
1383
+ end
1384
+
1385
+ --------------------------------------------------------------------------------
1386
+
1387
+ --
1388
+ -- Read interface
1389
+ --
1390
+ --
1391
+ --function InterfaceAttrExtension:describe_ext_interface()
1392
+ --end
1393
+
1394
+ --
1395
+ -- Write interface
1396
+ --
1397
+ --
1398
+ --function InterfaceAttrExtension:create_ext_attribute()
1399
+ --end
1400
+
1401
+ --------------------------------------------------------------------------------
1402
+
1403
+ ValueDef._type = "valuetype"
1404
+ ValueDef.def_kind = "dk_Value"
1405
+ ValueDef.supported_interfaces = Empty
1406
+ ValueDef.abstract_base_values = Empty
1407
+ ValueDef.initializers = Empty
1408
+ ValueDef.kind = 0
1409
+ ValueDef.definition_fields = {
1410
+ kind = { type = "number", optional = true },
1411
+ is_abstract = { type = "boolean", optional = true },
1412
+ is_custom = { type = "boolean", optional = true },
1413
+ is_truncatable = { type = "boolean", optional = true },
1414
+ base_value = { type = IDLType, optional = true },
1415
+ abstract_base_values = { type = ValueDef, optional = true, list = true },
1416
+ supported_interfaces = { type = InterfaceDef, optional = true, list = true },
1417
+ initializers = {
1418
+ type = {
1419
+ name = { type = "string" },
1420
+ members = {
1421
+ type = {
1422
+ name = { type = "string" },
1423
+ type = { type = IDLType },
1424
+ },
1425
+ list = true,
1426
+ },
1427
+ },
1428
+ optional = true,
1429
+ list = true,
1430
+ },
1431
+ }
1432
+
1433
+ function ValueDef:update(new)
1434
+ self.members = {}
1435
+ if new.kind then
1436
+ self:_set_is_custom(new.kind==1)
1437
+ self:_set_is_abstract(new.kind==2)
1438
+ self:_set_is_truncatable(new.kind==3)
1439
+ else
1440
+ self:_set_is_custom(new.is_custom)
1441
+ self:_set_is_abstract(new.is_abstract)
1442
+ self:_set_is_truncatable(new.is_truncatable)
1443
+ end
1444
+ if new.base_value == idl.null then
1445
+ self:_set_base_value(nil)
1446
+ else
1447
+ assert.type(new.base_value, "idl valuetype", "base value", "BAD_PARAM", 4)
1448
+ self:_set_base_value(new.base_value)
1449
+ end
1450
+ if new.abstract_base_values then
1451
+ self:_set_abstract_base_values(new.abstract_base_values)
1452
+ end
1453
+ if new.supported_interfaces then
1454
+ self:_set_supported_interfaces(new.supported_interfaces)
1455
+ end
1456
+ end
1457
+
1458
+ function ValueDef:get_description()
1459
+ local base_value = self.base_value
1460
+ if base_value == idl.null then
1461
+ base_value = idl.ValueBase
1462
+ end
1463
+ local abstract_base_values = {}
1464
+ for index, base in ipairs(self.abstract_base_values) do
1465
+ abstract_base_values[index] = base.repID
1466
+ end
1467
+ local supported_interfaces = {}
1468
+ for index, iface in ipairs(self.supported_interfaces) do
1469
+ supported_interfaces[index] = iface.repID
1470
+ end
1471
+ return setmetatable({
1472
+ is_abstract = self.is_abstract,
1473
+ is_custom = self.is_custom,
1474
+ is_truncatable = self.is_truncatable,
1475
+ base_value = base_value.repID,
1476
+ abstract_base_values = abstract_base_values,
1477
+ supported_interfaces = supported_interfaces,
1478
+ }, iridl.ValueDescription)
1479
+ end
1480
+
1481
+ --
1482
+ -- Read interface
1483
+ --
1484
+
1485
+ function ValueDef:is_a(id)
1486
+ if id == self.repID then return true end
1487
+ local base = self.base_value
1488
+ if base ~= idl.null and base:is_a(id) then return true end
1489
+ for _, base in ipairs(self.abstract_base_values) do
1490
+ if base:is_a(id) then return true end
1491
+ end
1492
+ for _, iface in ipairs(self.supported_interfaces) do
1493
+ if iface:is_a(id) then return true end
1494
+ end
1495
+ return false
1496
+ end
1497
+
1498
+ local FullValueDescription = iridl.ValueDef.definitions.FullValueDescription
1499
+ function ValueDef:describe_value()
1500
+ local operations = {}
1501
+ local attributes = {}
1502
+ local members = {}
1503
+ for base in self:hierarchy() do
1504
+ for _, contained in ipairs(base.definitions) do
1505
+ if contained._type == "attribute" then
1506
+ attributes[#attributes+1] = contained:describe().value
1507
+ elseif contained._type == "operation" then
1508
+ operations[#operations+1] = contained:describe().value
1509
+ elseif contained._type == "valuemember" then
1510
+ members[#members+1] = contained:describe().value
1511
+ end
1512
+ end
1513
+ end
1514
+ local desc = self:get_description()
1515
+ desc.name = self.name
1516
+ desc.id = self.id
1517
+ desc.defined_in = self.defined_in.repID
1518
+ desc.version = self.version
1519
+ desc.type = self
1520
+ desc.operations = operations
1521
+ desc.attributes = attributes
1522
+ desc.members = members
1523
+ desc.initializers = self.initializers
1524
+ return setmetatable(desc, FullValueDescription)
1525
+ end
1526
+
1527
+ --
1528
+ -- Write interface
1529
+ --
1530
+
1531
+ function ValueDef:_set_is_custom(value)
1532
+ self.is_custom = value
1533
+ if value then self.kind = 1 end
1534
+ end
1535
+
1536
+ function ValueDef:_set_is_abstract(value)
1537
+ self.is_abstract = value
1538
+ if value then self.kind = 2 end
1539
+ end
1540
+
1541
+ function ValueDef:_set_is_truncatable(value)
1542
+ self.is_truncatable = value
1543
+ if value then self.kind = 3 end
1544
+ end
1545
+
1546
+ function ValueDef:_set_supported_interfaces(ifaces)
1547
+ self.supported_interfaces = changeinheritance(self,
1548
+ self.supported_interfaces,
1549
+ ifaces,
1550
+ "idl interface")
1551
+ end
1552
+
1553
+ function ValueDef:_set_base_value(base)
1554
+ if base then
1555
+ if base.is_abstract then
1556
+ assert.illegal(base, "invalid base value", "BAD_PARAM", 4)
1557
+ end
1558
+ local list = changeinheritance(self, {self.base_value}, {base}, "idl valuetype")
1559
+ base = list[1]
1560
+ else
1561
+ base = idl.null
1562
+ end
1563
+ self.base_value = base
1564
+ end
1565
+
1566
+ function ValueDef:_get_base_value()
1567
+ local base = self.base_value
1568
+ if base == idl.null then base = nil end
1569
+ return base
1570
+ end
1571
+
1572
+ function ValueDef:_set_abstract_base_values(bases)
1573
+ for i = 1, #bases do
1574
+ local base = bases[i]
1575
+ if not base.is_abstract then
1576
+ assert.illegal(base, "invalid abstract base value", "BAD_PARAM", 4)
1577
+ end
1578
+ end
1579
+ self.abstract_base_values = changeinheritance(self,
1580
+ self.abstract_base_values,
1581
+ bases,
1582
+ "idl valuetype")
1583
+ end
1584
+
1585
+ function ValueDef:create_value_member(id, name, version, type, access)
1586
+ local created = ValueMemberDef{ containing_repository=self.containing_repository }
1587
+ created:update{
1588
+ defined_in = self,
1589
+
1590
+ repID = id,
1591
+ name = name,
1592
+ version = version,
1593
+
1594
+ type = type.type,
1595
+ access = access,
1596
+ }
1597
+ return created
1598
+ end
1599
+
1600
+ ValueDef.create_attribute = InterfaceDef.create_attribute
1601
+ ValueDef.create_operation = InterfaceDef.create_operation
1602
+
1603
+ --------------------------------------------------------------------------------
1604
+
1605
+ --
1606
+ -- Read interface
1607
+ --
1608
+ --
1609
+ --function ExtValueDef:describe_ext_value()
1610
+ --end
1611
+
1612
+ --
1613
+ -- Write interface
1614
+ --
1615
+ --
1616
+ --function ExtValueDef:create_ext_attribute(id, name, version, type, mode,
1617
+ -- get_exceptions, set_exceptions)
1618
+ --end
1619
+
1620
+
1621
+ --------------------------------------------------------------------------------
1622
+ -- Implementation --------------------------------------------------------------
1623
+
1624
+ oo.class(_M, Repository)
1625
+
1626
+ Classes = {
1627
+ struct = StructDef,
1628
+ union = UnionDef,
1629
+ enum = EnumDef,
1630
+ sequence = SequenceDef,
1631
+ array = ArrayDef,
1632
+ string = StringDef,
1633
+ typedef = AliasDef,
1634
+ except = ExceptionDef,
1635
+ module = ModuleDef,
1636
+ interface = InterfaceDef,
1637
+ abstract_interface = AbstractInterfaceDef,
1638
+ local_interface = LocalInterfaceDef,
1639
+ attribute = AttributeDef,
1640
+ operation = OperationDef,
1641
+ valuetype = ValueDef,
1642
+ valuemember = ValueMemberDef,
1643
+ valuebox = ValueBoxDef,
1644
+ Object = ObjectRef,
1645
+ }
1646
+
1647
+ --------------------------------------------------------------------------------
1648
+
1649
+ local function topdown(stack, class)
1650
+ while stack[class] do
1651
+ local ready = true
1652
+ for _, super in oo.supers(stack[class]) do
1653
+ if stack:insert(super, class) then
1654
+ ready = false
1655
+ break
1656
+ end
1657
+ end
1658
+ if ready then return stack[class] end
1659
+ end
1660
+ end
1661
+ local function iconstruct(class)
1662
+ local stack = OrderedSet()
1663
+ stack:push(class)
1664
+ return topdown, stack, OrderedSet.firstkey
1665
+ end
1666
+
1667
+ local function getupdate(self, value, name, typespec) --[[VERBOSE]] verbose:repository("[attribute ",name,"]")
1668
+ if type(typespec) == "string" then
1669
+ assert.type(value, typespec, name)
1670
+ elseif type(typespec) == "table" then
1671
+ if oo.isclass(typespec) then
1672
+ value = self[value]
1673
+ if not oo.instanceof(value, typespec) then
1674
+ assert.illegal(value, name)
1675
+ end
1676
+ else
1677
+ local new = {}
1678
+ for name, field in pairs(typespec) do
1679
+ local result = value[name]
1680
+ if result ~= nil or not field.optional then
1681
+ if field.list then
1682
+ local new = {}
1683
+ for index, value in ipairs(result) do
1684
+ new[index] = getupdate(self, value, name, field.type)
1685
+ end
1686
+ result = new
1687
+ else
1688
+ result = getupdate(self, result, name, field.type)
1689
+ end
1690
+ end
1691
+ new[name] = result
1692
+ end
1693
+ value = new
1694
+ end
1695
+ end
1696
+ return value
1697
+ end
1698
+
1699
+ Registry = oo.class()
1700
+
1701
+ function Registry:__init(object)
1702
+ self = oo.rawnew(self, object)
1703
+ self[PrimitiveTypes.pk_null ] = PrimitiveTypes.pk_null
1704
+ self[PrimitiveTypes.pk_void ] = PrimitiveTypes.pk_void
1705
+ self[PrimitiveTypes.pk_short ] = PrimitiveTypes.pk_short
1706
+ self[PrimitiveTypes.pk_long ] = PrimitiveTypes.pk_long
1707
+ self[PrimitiveTypes.pk_longlong ] = PrimitiveTypes.pk_longlong
1708
+ self[PrimitiveTypes.pk_ushort ] = PrimitiveTypes.pk_ushort
1709
+ self[PrimitiveTypes.pk_ulong ] = PrimitiveTypes.pk_ulong
1710
+ self[PrimitiveTypes.pk_ulonglong ] = PrimitiveTypes.pk_ulonglong
1711
+ self[PrimitiveTypes.pk_float ] = PrimitiveTypes.pk_float
1712
+ self[PrimitiveTypes.pk_double ] = PrimitiveTypes.pk_double
1713
+ self[PrimitiveTypes.pk_longdouble] = PrimitiveTypes.pk_longdouble
1714
+ self[PrimitiveTypes.pk_boolean ] = PrimitiveTypes.pk_boolean
1715
+ self[PrimitiveTypes.pk_char ] = PrimitiveTypes.pk_char
1716
+ self[PrimitiveTypes.pk_octet ] = PrimitiveTypes.pk_octet
1717
+ self[PrimitiveTypes.pk_any ] = PrimitiveTypes.pk_any
1718
+ self[PrimitiveTypes.pk_TypeCode ] = PrimitiveTypes.pk_TypeCode
1719
+ self[PrimitiveTypes.pk_string ] = PrimitiveTypes.pk_string
1720
+ self[PrimitiveTypes.pk_objref ] = PrimitiveTypes.pk_objref
1721
+ self[self.repository ] = self.repository
1722
+ return self
1723
+ end
1724
+
1725
+ function Registry:__index(definition)
1726
+ if definition then
1727
+ local repository = self.repository
1728
+ local class = repository.Classes[definition._type]
1729
+
1730
+ --<PROBLEM WITH LUAIDL>
1731
+ if class == InterfaceDef then
1732
+ if definition.abstract then
1733
+ class = AbstractInterfaceDef
1734
+ elseif definition["local"] then
1735
+ class = LocalInterfaceDef
1736
+ end
1737
+ end
1738
+ --<\PROBLEM WITH LUAIDL>
1739
+
1740
+ local result
1741
+ if class then
1742
+ result = repository:lookup_id(definition.repID)
1743
+ if definition ~= result then --[[VERBOSE]] verbose:repository(true, definition._type," ",definition.repID or definition.name)
1744
+ result = class(result)
1745
+ result.containing_repository = repository
1746
+ self[definition] = result -- to avoid loops in cycles during 'getupdate'
1747
+ self[result] = result
1748
+ for class in iconstruct(class) do --[[VERBOSE]] verbose:repository("[",ClassName[class],"]")
1749
+ local update = oo.memberof(class, "update")
1750
+ if update then
1751
+ local fields = oo.memberof(class, "definition_fields")
1752
+ local new = fields and getupdate(self, definition, "object", fields)
1753
+ update(result, new, self)
1754
+ end
1755
+ end --[[VERBOSE]] verbose:repository(false)
1756
+ if oo.instanceof(result, Container) then
1757
+ for _, contained in ipairs(definition.definitions) do
1758
+ getupdate(self, contained, "contained", Contained)
1759
+ end
1760
+ end
1761
+ end
1762
+ elseif oo.classof(definition) == _M then
1763
+ result = self.repository
1764
+ end
1765
+ self[definition] = result
1766
+ self[result] = result
1767
+ return result
1768
+ end
1769
+ end
1770
+
1771
+ --------------------------------------------------------------------------------
1772
+
1773
+ function put(self, definition, registry)
1774
+ registry = registry or self.Registry{ repository = self }
1775
+ return registry[definition]
1776
+ end
1777
+
1778
+ function register(self, ...)
1779
+ local registry = self.Registry{ repository = self }
1780
+ local results = {}
1781
+ local count = select("#", ...)
1782
+ for i = 1, count do
1783
+ local definition = select(i, ...)
1784
+ assert.type(definition, "table", "IR object definition")
1785
+ results[i] = registry[definition]
1786
+ end
1787
+ return unpack(results, 1, count)
1788
+ end
1789
+
1790
+ local TypeCodesOfInterface = {
1791
+ Object = true,
1792
+ abstract_interface = true,
1793
+ }
1794
+ function resolve(self, typeref)
1795
+ local luatype = type(typeref)
1796
+ local result, errmsg
1797
+ if luatype == "table" then
1798
+ if typeref._type == "interface" then
1799
+ result, errmsg = self:register(typeref)
1800
+ elseif TypeCodesOfInterface[typeref._type] then
1801
+ typeref, luatype = typeref.repID, "string"
1802
+ end
1803
+ end
1804
+ if luatype == "string" then
1805
+ result = self:lookup(typeref) or self:lookup_id(typeref)
1806
+ if not result then
1807
+ errmsg = Exception{ "INTERNAL", minor_code_value = 0,
1808
+ reason = "interface",
1809
+ message = "unknown interface",
1810
+ interface = typeref,
1811
+ }
1812
+ end
1813
+ elseif result == nil then
1814
+ result, errmsg = nil, Exception{ "INTERNAL", minor_code_value = 0,
1815
+ reason = "interface",
1816
+ message = "illegal IDL type",
1817
+ type = typeref,
1818
+ }
1819
+ end
1820
+ return result, errmsg
1821
+ end