dub 0.2.2 → 0.6.3

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.

Potentially problematic release.


This version of dub might be problematic. Click here for more details.

Files changed (266) hide show
  1. data/.gitignore +8 -0
  2. data/History.txt +37 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +48 -0
  5. data/Rakefile +58 -0
  6. data/dub.gemspec +197 -0
  7. data/lib/dub/argument.rb +275 -0
  8. data/lib/dub/entities_unescape.rb +16 -0
  9. data/lib/dub/function.rb +163 -0
  10. data/lib/dub/function_group.rb +72 -0
  11. data/lib/dub/generator.rb +15 -0
  12. data/lib/dub/group.rb +24 -0
  13. data/lib/dub/klass.rb +232 -0
  14. data/lib/dub/lua/class.cpp.erb +83 -0
  15. data/lib/dub/lua/class_gen.rb +97 -0
  16. data/lib/dub/lua/function.cpp.erb +18 -0
  17. data/lib/dub/lua/function_gen.rb +258 -0
  18. data/lib/dub/lua/group.cpp.erb +9 -0
  19. data/lib/dub/lua/lua_cpp_helper.h +141 -0
  20. data/lib/dub/lua/namespace.cpp.erb +40 -0
  21. data/lib/dub/lua/namespace_gen.rb +88 -0
  22. data/lib/dub/lua.rb +24 -0
  23. data/lib/dub/member_extraction.rb +92 -0
  24. data/lib/dub/namespace.rb +277 -0
  25. data/lib/dub/parser.rb +46 -0
  26. data/lib/dub/templates/lua_template.erb +21 -0
  27. data/lib/dub/version.rb +3 -0
  28. data/lib/dub.rb +23 -20
  29. data/test/argument_test.rb +547 -0
  30. data/test/fixtures/app/CMakeLists.txt +54 -0
  31. data/test/fixtures/app/Doxyfile +1600 -0
  32. data/test/fixtures/app/bindings/all_lua.cpp +299 -0
  33. data/test/fixtures/app/include/matrix.h +153 -0
  34. data/test/fixtures/app/make_lua_bindings.rb +13 -0
  35. data/test/fixtures/app/vendor/lua/CMakeLists.txt +25 -0
  36. data/test/fixtures/app/vendor/lua/COPYRIGHT +34 -0
  37. data/test/fixtures/app/vendor/lua/HISTORY +183 -0
  38. data/test/fixtures/app/vendor/lua/INSTALL +99 -0
  39. data/test/fixtures/app/vendor/lua/Makefile +183 -0
  40. data/test/fixtures/app/vendor/lua/README +37 -0
  41. data/test/fixtures/app/vendor/lua/lapi.c +1080 -0
  42. data/test/fixtures/app/vendor/lua/lapi.h +16 -0
  43. data/test/fixtures/app/vendor/lua/lauxlib.c +653 -0
  44. data/test/fixtures/app/vendor/lua/lauxlib.h +174 -0
  45. data/test/fixtures/app/vendor/lua/lbaselib.c +643 -0
  46. data/test/fixtures/app/vendor/lua/lcode.c +839 -0
  47. data/test/fixtures/app/vendor/lua/lcode.h +76 -0
  48. data/test/fixtures/app/vendor/lua/ldblib.c +397 -0
  49. data/test/fixtures/app/vendor/lua/ldebug.c +622 -0
  50. data/test/fixtures/app/vendor/lua/ldebug.h +33 -0
  51. data/test/fixtures/app/vendor/lua/ldo.c +516 -0
  52. data/test/fixtures/app/vendor/lua/ldo.h +57 -0
  53. data/test/fixtures/app/vendor/lua/ldump.c +164 -0
  54. data/test/fixtures/app/vendor/lua/lfunc.c +174 -0
  55. data/test/fixtures/app/vendor/lua/lfunc.h +34 -0
  56. data/test/fixtures/app/vendor/lua/lgc.c +711 -0
  57. data/test/fixtures/app/vendor/lua/lgc.h +110 -0
  58. data/test/fixtures/app/vendor/lua/liblua.a +0 -0
  59. data/test/fixtures/app/vendor/lua/linit.c +38 -0
  60. data/test/fixtures/app/vendor/lua/liolib.c +532 -0
  61. data/test/fixtures/app/vendor/lua/llex.c +461 -0
  62. data/test/fixtures/app/vendor/lua/llex.h +81 -0
  63. data/test/fixtures/app/vendor/lua/llimits.h +128 -0
  64. data/test/fixtures/app/vendor/lua/lmathlib.c +263 -0
  65. data/test/fixtures/app/vendor/lua/lmem.c +86 -0
  66. data/test/fixtures/app/vendor/lua/lmem.h +49 -0
  67. data/test/fixtures/app/vendor/lua/loadlib.c +664 -0
  68. data/test/fixtures/app/vendor/lua/lobject.c +214 -0
  69. data/test/fixtures/app/vendor/lua/lobject.h +381 -0
  70. data/test/fixtures/app/vendor/lua/lopcodes.c +102 -0
  71. data/test/fixtures/app/vendor/lua/lopcodes.h +268 -0
  72. data/test/fixtures/app/vendor/lua/loslib.c +244 -0
  73. data/test/fixtures/app/vendor/lua/lparser.c +1337 -0
  74. data/test/fixtures/app/vendor/lua/lparser.h +82 -0
  75. data/test/fixtures/app/vendor/lua/lstate.c +214 -0
  76. data/test/fixtures/app/vendor/lua/lstate.h +168 -0
  77. data/test/fixtures/app/vendor/lua/lstring.c +111 -0
  78. data/test/fixtures/app/vendor/lua/lstring.h +31 -0
  79. data/test/fixtures/app/vendor/lua/lstrlib.c +868 -0
  80. data/test/fixtures/app/vendor/lua/ltable.c +588 -0
  81. data/test/fixtures/app/vendor/lua/ltable.h +40 -0
  82. data/test/fixtures/app/vendor/lua/ltablib.c +278 -0
  83. data/test/fixtures/app/vendor/lua/ltm.c +75 -0
  84. data/test/fixtures/app/vendor/lua/ltm.h +54 -0
  85. data/test/fixtures/app/vendor/lua/lua.c +695 -0
  86. data/test/fixtures/app/vendor/lua/lua.h +385 -0
  87. data/test/fixtures/app/vendor/lua/lua_dub_helper.h +77 -0
  88. data/test/fixtures/app/vendor/lua/luac +0 -0
  89. data/test/fixtures/app/vendor/lua/luac.c +200 -0
  90. data/test/fixtures/app/vendor/lua/luaconf.h +762 -0
  91. data/test/fixtures/app/vendor/lua/lualib.h +53 -0
  92. data/test/fixtures/app/vendor/lua/lundump.c +223 -0
  93. data/test/fixtures/app/vendor/lua/lundump.h +36 -0
  94. data/test/fixtures/app/vendor/lua/lvm.c +765 -0
  95. data/test/fixtures/app/vendor/lua/lvm.h +36 -0
  96. data/test/fixtures/app/vendor/lua/lzio.c +82 -0
  97. data/test/fixtures/app/vendor/lua/lzio.h +67 -0
  98. data/test/fixtures/app/vendor/lua/matrix.h +102 -0
  99. data/test/fixtures/app/vendor/lua/print.c +227 -0
  100. data/test/fixtures/app/vendor/lua/test/README +26 -0
  101. data/test/fixtures/app/vendor/lua/test/bisect.lua +27 -0
  102. data/test/fixtures/app/vendor/lua/test/cf.lua +16 -0
  103. data/test/fixtures/app/vendor/lua/test/echo.lua +5 -0
  104. data/test/fixtures/app/vendor/lua/test/env.lua +7 -0
  105. data/test/fixtures/app/vendor/lua/test/factorial.lua +32 -0
  106. data/test/fixtures/app/vendor/lua/test/fib.lua +40 -0
  107. data/test/fixtures/app/vendor/lua/test/fibfor.lua +13 -0
  108. data/test/fixtures/app/vendor/lua/test/globals.lua +13 -0
  109. data/test/fixtures/app/vendor/lua/test/hello.lua +3 -0
  110. data/test/fixtures/app/vendor/lua/test/life.lua +111 -0
  111. data/test/fixtures/app/vendor/lua/test/luac.lua +7 -0
  112. data/test/fixtures/app/vendor/lua/test/printf.lua +7 -0
  113. data/test/fixtures/app/vendor/lua/test/readonly.lua +12 -0
  114. data/test/fixtures/app/vendor/lua/test/sieve.lua +29 -0
  115. data/test/fixtures/app/vendor/lua/test/sort.lua +66 -0
  116. data/test/fixtures/app/vendor/lua/test/table.lua +12 -0
  117. data/test/fixtures/app/vendor/lua/test/trace-calls.lua +32 -0
  118. data/test/fixtures/app/vendor/lua/test/trace-globals.lua +38 -0
  119. data/test/fixtures/app/vendor/lua/test/xd.lua +14 -0
  120. data/test/fixtures/app/xml/classdub_1_1_matrix.xml +313 -0
  121. data/test/fixtures/app/xml/classdub_1_1_t_mat.xml +252 -0
  122. data/test/fixtures/app/xml/combine.xslt +15 -0
  123. data/test/fixtures/app/xml/compound.xsd +814 -0
  124. data/test/fixtures/app/xml/dir_53661a2bdeb1d55e60581a7e15deb763.xml +12 -0
  125. data/test/fixtures/app/xml/index.xml +47 -0
  126. data/test/fixtures/app/xml/index.xsd +66 -0
  127. data/test/fixtures/app/xml/matrix_8h.xml +175 -0
  128. data/test/fixtures/app/xml/namespacedub.xml +41 -0
  129. data/test/fixtures/classcv_1_1_mat.xml +1996 -0
  130. data/test/fixtures/classcv_1_1_point__.xml +341 -0
  131. data/test/fixtures/classcv_1_1_scalar__.xml +269 -0
  132. data/test/fixtures/classcv_1_1_size__.xml +270 -0
  133. data/test/fixtures/dummy_class.cpp.erb +1 -0
  134. data/test/fixtures/dummy_function.cpp.erb +1 -0
  135. data/test/fixtures/group___magic_type.xml +406 -0
  136. data/test/fixtures/namespacecv.xml +12659 -0
  137. data/test/function_group_test.rb +24 -0
  138. data/test/function_test.rb +395 -0
  139. data/test/group_test.rb +155 -0
  140. data/test/helper.rb +34 -0
  141. data/test/klass_test.rb +395 -0
  142. data/test/lua_function_gen_test.rb +195 -0
  143. data/test/namespace_test.rb +220 -0
  144. data/test/parser_test.rb +36 -0
  145. metadata +211 -275
  146. checksums.yaml +0 -7
  147. data/lib/open_api_sdk/analytics.rb +0 -99
  148. data/lib/open_api_sdk/domains.rb +0 -353
  149. data/lib/open_api_sdk/dub.rb +0 -88
  150. data/lib/open_api_sdk/links.rb +0 -766
  151. data/lib/open_api_sdk/metatags.rb +0 -54
  152. data/lib/open_api_sdk/models/operations/bulkcreatelinks_response.rb +0 -60
  153. data/lib/open_api_sdk/models/operations/bulkupdatelinks_requestbody.rb +0 -27
  154. data/lib/open_api_sdk/models/operations/bulkupdatelinks_response.rb +0 -60
  155. data/lib/open_api_sdk/models/operations/color.rb +0 -24
  156. data/lib/open_api_sdk/models/operations/createdomain_requestbody.rb +0 -33
  157. data/lib/open_api_sdk/models/operations/createdomain_response.rb +0 -60
  158. data/lib/open_api_sdk/models/operations/createlink_requestbody.rb +0 -95
  159. data/lib/open_api_sdk/models/operations/createlink_response.rb +0 -60
  160. data/lib/open_api_sdk/models/operations/createtag_requestbody.rb +0 -32
  161. data/lib/open_api_sdk/models/operations/createtag_response.rb +0 -60
  162. data/lib/open_api_sdk/models/operations/data.rb +0 -83
  163. data/lib/open_api_sdk/models/operations/deletedomain_request.rb +0 -24
  164. data/lib/open_api_sdk/models/operations/deletedomain_response.rb +0 -60
  165. data/lib/open_api_sdk/models/operations/deletedomain_responsebody.rb +0 -24
  166. data/lib/open_api_sdk/models/operations/deletelink_request.rb +0 -24
  167. data/lib/open_api_sdk/models/operations/deletelink_response.rb +0 -60
  168. data/lib/open_api_sdk/models/operations/deletelink_responsebody.rb +0 -24
  169. data/lib/open_api_sdk/models/operations/event.rb +0 -21
  170. data/lib/open_api_sdk/models/operations/getlinkinfo_request.rb +0 -33
  171. data/lib/open_api_sdk/models/operations/getlinkinfo_response.rb +0 -60
  172. data/lib/open_api_sdk/models/operations/getlinks_request.rb +0 -51
  173. data/lib/open_api_sdk/models/operations/getlinks_response.rb +0 -60
  174. data/lib/open_api_sdk/models/operations/getlinkscount_request.rb +0 -48
  175. data/lib/open_api_sdk/models/operations/getlinkscount_response.rb +0 -60
  176. data/lib/open_api_sdk/models/operations/getmetatags_request.rb +0 -24
  177. data/lib/open_api_sdk/models/operations/getmetatags_response.rb +0 -33
  178. data/lib/open_api_sdk/models/operations/getmetatags_responsebody.rb +0 -30
  179. data/lib/open_api_sdk/models/operations/getqrcode_request.rb +0 -39
  180. data/lib/open_api_sdk/models/operations/getqrcode_response.rb +0 -60
  181. data/lib/open_api_sdk/models/operations/gettags_response.rb +0 -60
  182. data/lib/open_api_sdk/models/operations/getworkspace_request.rb +0 -24
  183. data/lib/open_api_sdk/models/operations/getworkspace_response.rb +0 -60
  184. data/lib/open_api_sdk/models/operations/groupby.rb +0 -28
  185. data/lib/open_api_sdk/models/operations/interval.rb +0 -25
  186. data/lib/open_api_sdk/models/operations/level.rb +0 -21
  187. data/lib/open_api_sdk/models/operations/listdomains_response.rb +0 -60
  188. data/lib/open_api_sdk/models/operations/paymentprocessor.rb +0 -20
  189. data/lib/open_api_sdk/models/operations/requestbody.rb +0 -95
  190. data/lib/open_api_sdk/models/operations/retrieveanalytics_request.rb +0 -81
  191. data/lib/open_api_sdk/models/operations/retrieveanalytics_response.rb +0 -60
  192. data/lib/open_api_sdk/models/operations/sort.rb +0 -20
  193. data/lib/open_api_sdk/models/operations/trackcustomer_requestbody.rb +0 -33
  194. data/lib/open_api_sdk/models/operations/trackcustomer_response.rb +0 -60
  195. data/lib/open_api_sdk/models/operations/trackcustomer_responsebody.rb +0 -33
  196. data/lib/open_api_sdk/models/operations/tracklead_requestbody.rb +0 -42
  197. data/lib/open_api_sdk/models/operations/tracklead_response.rb +0 -60
  198. data/lib/open_api_sdk/models/operations/tracklead_responsebody.rb +0 -42
  199. data/lib/open_api_sdk/models/operations/tracksale_requestbody.rb +0 -42
  200. data/lib/open_api_sdk/models/operations/tracksale_response.rb +0 -60
  201. data/lib/open_api_sdk/models/operations/tracksale_responsebody.rb +0 -42
  202. data/lib/open_api_sdk/models/operations/updatedomain_request.rb +0 -27
  203. data/lib/open_api_sdk/models/operations/updatedomain_requestbody.rb +0 -33
  204. data/lib/open_api_sdk/models/operations/updatedomain_response.rb +0 -60
  205. data/lib/open_api_sdk/models/operations/updatelink_request.rb +0 -27
  206. data/lib/open_api_sdk/models/operations/updatelink_requestbody.rb +0 -95
  207. data/lib/open_api_sdk/models/operations/updatelink_response.rb +0 -60
  208. data/lib/open_api_sdk/models/operations/updatetag_color.rb +0 -24
  209. data/lib/open_api_sdk/models/operations/updatetag_request.rb +0 -27
  210. data/lib/open_api_sdk/models/operations/updatetag_requestbody.rb +0 -32
  211. data/lib/open_api_sdk/models/operations/updatetag_response.rb +0 -60
  212. data/lib/open_api_sdk/models/operations/updateworkspace_request.rb +0 -27
  213. data/lib/open_api_sdk/models/operations/updateworkspace_requestbody.rb +0 -27
  214. data/lib/open_api_sdk/models/operations/updateworkspace_response.rb +0 -60
  215. data/lib/open_api_sdk/models/operations/upsertlink_requestbody.rb +0 -95
  216. data/lib/open_api_sdk/models/operations/upsertlink_response.rb +0 -60
  217. data/lib/open_api_sdk/models/operations.rb +0 -74
  218. data/lib/open_api_sdk/models/shared/badrequest.rb +0 -24
  219. data/lib/open_api_sdk/models/shared/code.rb +0 -18
  220. data/lib/open_api_sdk/models/shared/color.rb +0 -24
  221. data/lib/open_api_sdk/models/shared/conflict.rb +0 -24
  222. data/lib/open_api_sdk/models/shared/conflict_code.rb +0 -18
  223. data/lib/open_api_sdk/models/shared/conflict_error.rb +0 -30
  224. data/lib/open_api_sdk/models/shared/countrycode.rb +0 -267
  225. data/lib/open_api_sdk/models/shared/domains.rb +0 -27
  226. data/lib/open_api_sdk/models/shared/domainschema.rb +0 -48
  227. data/lib/open_api_sdk/models/shared/error.rb +0 -30
  228. data/lib/open_api_sdk/models/shared/forbidden.rb +0 -24
  229. data/lib/open_api_sdk/models/shared/forbidden_code.rb +0 -18
  230. data/lib/open_api_sdk/models/shared/forbidden_error.rb +0 -30
  231. data/lib/open_api_sdk/models/shared/geo.rb +0 -771
  232. data/lib/open_api_sdk/models/shared/internalservererror.rb +0 -24
  233. data/lib/open_api_sdk/models/shared/internalservererror_code.rb +0 -18
  234. data/lib/open_api_sdk/models/shared/internalservererror_error.rb +0 -30
  235. data/lib/open_api_sdk/models/shared/inviteexpired.rb +0 -24
  236. data/lib/open_api_sdk/models/shared/inviteexpired_code.rb +0 -18
  237. data/lib/open_api_sdk/models/shared/inviteexpired_error.rb +0 -30
  238. data/lib/open_api_sdk/models/shared/linkgeotargeting.rb +0 -771
  239. data/lib/open_api_sdk/models/shared/linkschema.rb +0 -142
  240. data/lib/open_api_sdk/models/shared/notfound.rb +0 -24
  241. data/lib/open_api_sdk/models/shared/notfound_code.rb +0 -18
  242. data/lib/open_api_sdk/models/shared/notfound_error.rb +0 -30
  243. data/lib/open_api_sdk/models/shared/plan.rb +0 -24
  244. data/lib/open_api_sdk/models/shared/ratelimitexceeded.rb +0 -24
  245. data/lib/open_api_sdk/models/shared/ratelimitexceeded_code.rb +0 -18
  246. data/lib/open_api_sdk/models/shared/ratelimitexceeded_error.rb +0 -30
  247. data/lib/open_api_sdk/models/shared/role.rb +0 -19
  248. data/lib/open_api_sdk/models/shared/security.rb +0 -24
  249. data/lib/open_api_sdk/models/shared/tagschema.rb +0 -30
  250. data/lib/open_api_sdk/models/shared/unauthorized.rb +0 -24
  251. data/lib/open_api_sdk/models/shared/unauthorized_code.rb +0 -18
  252. data/lib/open_api_sdk/models/shared/unauthorized_error.rb +0 -30
  253. data/lib/open_api_sdk/models/shared/unprocessableentity.rb +0 -24
  254. data/lib/open_api_sdk/models/shared/unprocessableentity_code.rb +0 -18
  255. data/lib/open_api_sdk/models/shared/unprocessableentity_error.rb +0 -30
  256. data/lib/open_api_sdk/models/shared/users.rb +0 -24
  257. data/lib/open_api_sdk/models/shared/workspaceschema.rb +0 -81
  258. data/lib/open_api_sdk/models/shared.rb +0 -49
  259. data/lib/open_api_sdk/qr_codes.rb +0 -97
  260. data/lib/open_api_sdk/sdkconfiguration.rb +0 -52
  261. data/lib/open_api_sdk/tags.rb +0 -272
  262. data/lib/open_api_sdk/track.rb +0 -276
  263. data/lib/open_api_sdk/utils/metadata_fields.rb +0 -150
  264. data/lib/open_api_sdk/utils/t.rb +0 -59
  265. data/lib/open_api_sdk/utils/utils.rb +0 -772
  266. data/lib/open_api_sdk/workspaces.rb +0 -192
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ .DS_Store
2
+ *.o
3
+ *.a
4
+ *.so
5
+ build
6
+ test/fixtures/app/vendor/lua/lua
7
+ *.gem
8
+ test/fixtures/app/html
data/History.txt ADDED
@@ -0,0 +1,37 @@
1
+ == 0.6.3 2010-07-07
2
+
3
+ * 1 enhancement
4
+ * Should ignore non-public member methods.
5
+
6
+ == 0.6.2 2010-07-07
7
+
8
+ * 1 enhancement
9
+ * Added an option define (DUB_LUA_NO_OPEN) to prevent replaxe luaopen_xx by luaload_xx
10
+ * Added char in the list of 'int' types.
11
+
12
+ == 0.6.1 2010-03-12
13
+
14
+ * 2 enhancements
15
+ * Wrapping all function calls in try.. catch blocks
16
+ * Added support for custome templates (customize exception handling for example)
17
+
18
+ == 0.6.0 2010-03-11
19
+
20
+ * 4 enhancements
21
+ * added support for custom tostring methods for classes
22
+ * fixed parsing of templated return types
23
+ * static class methods are now registered in the namespace as Klass_method
24
+ * removing functions and methods with class pointer arguments (could use lists later on)
25
+ * better parsing of complex types (including nested template arguments)
26
+
27
+ == 0.5.1 2010-03-05
28
+
29
+ * 2 minor enhancements
30
+ * if an argument is fully specified, should not append namespace
31
+ * better handling of boolean values
32
+
33
+ == 0.5.0 2010-03-03
34
+
35
+ * 1 major enhancement
36
+ * initial release and tested with OpenCV bindings for Lua
37
+
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 by Gaspard Bucher - Buma (http://teti.ch).
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,48 @@
1
+ = Dub (Doxygen based Ubiquitous Binder)
2
+
3
+ This is a tool to ease the creation of scripting language bindings for a C++ library.
4
+ It is currently developed to crete the OpenCV bindings for Lua in Rubyk (http://rubyk.org).
5
+
6
+ The generator uses the xml output from Doxygen to avoid parsing C++ code by itself.
7
+
8
+ = Features
9
+
10
+ Currently, the parser supports:
11
+
12
+ * class methods
13
+ * overloaded class constructors
14
+ * overloaded class methods
15
+ * class instantiation from templates through typedefs
16
+ * class alias through typedefs
17
+ * automatic resolution of template parameters
18
+ * automatic handling of default values
19
+ * class enums
20
+ * namespace enums
21
+ * group constant defines
22
+ * well tested
23
+
24
+ If you are not good at reading lists, here is an example of the kind of tricks Dub plays with types:
25
+
26
+ template<class T>
27
+ class Point_ {
28
+ ...
29
+ };
30
+
31
+ template<class T>
32
+ class Size_ {
33
+ Size_(const Point_<T>);
34
+ };
35
+ typedef Size_<int> Size2i;
36
+ typedef Size2i Size;
37
+
38
+ typedef Point_<int> Point2i;
39
+ typedef Point2i Point;
40
+
41
+
42
+ All these typedefs and templates will generate two class bindings with some aliases:
43
+
44
+ * <tt>Size</tt>, aliased as <tt>Size2i</tt>
45
+ * <tt>Point</tt>, aliased as <tt>Point2i</tt>
46
+
47
+ And what's really good is that in the definition for the <tt>Size</tt> constructor, <tt>Point_<T></tt> is
48
+ recognized as <tt>Point</tt> !
data/Rakefile ADDED
@@ -0,0 +1,58 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'lib'))
5
+ require 'dub/version'
6
+
7
+ begin
8
+ require 'jeweler'
9
+ Jeweler::Tasks.new do |gem|
10
+ gem.name = "dub"
11
+ gem.version = Dub::VERSION
12
+ gem.summary = %Q{A tool to ease the creation of scripting language bindings for a C++ library.}
13
+ gem.description = %Q{This is a tool to ease the creation of scripting language bindings for a C++ library.
14
+ It is currently developed to crete the OpenCV bindings for Lua in Rubyk (http://rubyk.org). The generator uses the xml output from Doxygen to avoid parsing C++ code by itself.}
15
+ gem.email = "gaspard@teti.ch"
16
+ gem.homepage = "http://github.com/ruby/dub"
17
+ gem.authors = ["Gaspard Bucher"]
18
+ gem.add_development_dependency "shoulda", ">= 0"
19
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
20
+ end
21
+ Jeweler::GemcutterTasks.new
22
+ rescue LoadError
23
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
24
+ end
25
+
26
+ require 'rake/testtask'
27
+ Rake::TestTask.new(:test) do |test|
28
+ test.libs << 'lib' << 'test'
29
+ test.pattern = 'test/**/*_test.rb'
30
+ test.verbose = true
31
+ end
32
+
33
+ begin
34
+ require 'rcov/rcovtask'
35
+ Rcov::RcovTask.new do |test|
36
+ test.libs << 'test'
37
+ test.pattern = 'test/**/*_test.rb'
38
+ test.verbose = true
39
+ end
40
+ rescue LoadError
41
+ task :rcov do
42
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
43
+ end
44
+ end
45
+
46
+ task :test => :check_dependencies
47
+
48
+ task :default => :test
49
+
50
+ require 'rake/rdoctask'
51
+ Rake::RDocTask.new do |rdoc|
52
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
53
+
54
+ rdoc.rdoc_dir = 'rdoc'
55
+ rdoc.title = "Dub #{version}"
56
+ rdoc.rdoc_files.include('README*')
57
+ rdoc.rdoc_files.include('lib/**/*.rb')
58
+ end
data/dub.gemspec ADDED
@@ -0,0 +1,197 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{dub}
8
+ s.version = "0.6.3"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Gaspard Bucher"]
12
+ s.date = %q{2010-07-07}
13
+ s.description = %q{This is a tool to ease the creation of scripting language bindings for a C++ library.
14
+ It is currently developed to crete the OpenCV bindings for Lua in Rubyk (http://rubyk.org). The generator uses the xml output from Doxygen to avoid parsing C++ code by itself.}
15
+ s.email = %q{gaspard@teti.ch}
16
+ s.extra_rdoc_files = [
17
+ "LICENSE",
18
+ "README.rdoc"
19
+ ]
20
+ s.files = [
21
+ ".gitignore",
22
+ "History.txt",
23
+ "LICENSE",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "dub.gemspec",
27
+ "lib/dub.rb",
28
+ "lib/dub/argument.rb",
29
+ "lib/dub/entities_unescape.rb",
30
+ "lib/dub/function.rb",
31
+ "lib/dub/function_group.rb",
32
+ "lib/dub/generator.rb",
33
+ "lib/dub/group.rb",
34
+ "lib/dub/klass.rb",
35
+ "lib/dub/lua.rb",
36
+ "lib/dub/lua/class.cpp.erb",
37
+ "lib/dub/lua/class_gen.rb",
38
+ "lib/dub/lua/function.cpp.erb",
39
+ "lib/dub/lua/function_gen.rb",
40
+ "lib/dub/lua/group.cpp.erb",
41
+ "lib/dub/lua/lua_cpp_helper.h",
42
+ "lib/dub/lua/namespace.cpp.erb",
43
+ "lib/dub/lua/namespace_gen.rb",
44
+ "lib/dub/member_extraction.rb",
45
+ "lib/dub/namespace.rb",
46
+ "lib/dub/parser.rb",
47
+ "lib/dub/templates/lua_template.erb",
48
+ "lib/dub/version.rb",
49
+ "test/argument_test.rb",
50
+ "test/fixtures/app/CMakeLists.txt",
51
+ "test/fixtures/app/Doxyfile",
52
+ "test/fixtures/app/bindings/all_lua.cpp",
53
+ "test/fixtures/app/include/matrix.h",
54
+ "test/fixtures/app/make_lua_bindings.rb",
55
+ "test/fixtures/app/vendor/lua/CMakeLists.txt",
56
+ "test/fixtures/app/vendor/lua/COPYRIGHT",
57
+ "test/fixtures/app/vendor/lua/HISTORY",
58
+ "test/fixtures/app/vendor/lua/INSTALL",
59
+ "test/fixtures/app/vendor/lua/Makefile",
60
+ "test/fixtures/app/vendor/lua/README",
61
+ "test/fixtures/app/vendor/lua/lapi.c",
62
+ "test/fixtures/app/vendor/lua/lapi.h",
63
+ "test/fixtures/app/vendor/lua/lauxlib.c",
64
+ "test/fixtures/app/vendor/lua/lauxlib.h",
65
+ "test/fixtures/app/vendor/lua/lbaselib.c",
66
+ "test/fixtures/app/vendor/lua/lcode.c",
67
+ "test/fixtures/app/vendor/lua/lcode.h",
68
+ "test/fixtures/app/vendor/lua/ldblib.c",
69
+ "test/fixtures/app/vendor/lua/ldebug.c",
70
+ "test/fixtures/app/vendor/lua/ldebug.h",
71
+ "test/fixtures/app/vendor/lua/ldo.c",
72
+ "test/fixtures/app/vendor/lua/ldo.h",
73
+ "test/fixtures/app/vendor/lua/ldump.c",
74
+ "test/fixtures/app/vendor/lua/lfunc.c",
75
+ "test/fixtures/app/vendor/lua/lfunc.h",
76
+ "test/fixtures/app/vendor/lua/lgc.c",
77
+ "test/fixtures/app/vendor/lua/lgc.h",
78
+ "test/fixtures/app/vendor/lua/liblua.a",
79
+ "test/fixtures/app/vendor/lua/linit.c",
80
+ "test/fixtures/app/vendor/lua/liolib.c",
81
+ "test/fixtures/app/vendor/lua/llex.c",
82
+ "test/fixtures/app/vendor/lua/llex.h",
83
+ "test/fixtures/app/vendor/lua/llimits.h",
84
+ "test/fixtures/app/vendor/lua/lmathlib.c",
85
+ "test/fixtures/app/vendor/lua/lmem.c",
86
+ "test/fixtures/app/vendor/lua/lmem.h",
87
+ "test/fixtures/app/vendor/lua/loadlib.c",
88
+ "test/fixtures/app/vendor/lua/lobject.c",
89
+ "test/fixtures/app/vendor/lua/lobject.h",
90
+ "test/fixtures/app/vendor/lua/lopcodes.c",
91
+ "test/fixtures/app/vendor/lua/lopcodes.h",
92
+ "test/fixtures/app/vendor/lua/loslib.c",
93
+ "test/fixtures/app/vendor/lua/lparser.c",
94
+ "test/fixtures/app/vendor/lua/lparser.h",
95
+ "test/fixtures/app/vendor/lua/lstate.c",
96
+ "test/fixtures/app/vendor/lua/lstate.h",
97
+ "test/fixtures/app/vendor/lua/lstring.c",
98
+ "test/fixtures/app/vendor/lua/lstring.h",
99
+ "test/fixtures/app/vendor/lua/lstrlib.c",
100
+ "test/fixtures/app/vendor/lua/ltable.c",
101
+ "test/fixtures/app/vendor/lua/ltable.h",
102
+ "test/fixtures/app/vendor/lua/ltablib.c",
103
+ "test/fixtures/app/vendor/lua/ltm.c",
104
+ "test/fixtures/app/vendor/lua/ltm.h",
105
+ "test/fixtures/app/vendor/lua/lua.c",
106
+ "test/fixtures/app/vendor/lua/lua.h",
107
+ "test/fixtures/app/vendor/lua/lua_dub_helper.h",
108
+ "test/fixtures/app/vendor/lua/luac",
109
+ "test/fixtures/app/vendor/lua/luac.c",
110
+ "test/fixtures/app/vendor/lua/luaconf.h",
111
+ "test/fixtures/app/vendor/lua/lualib.h",
112
+ "test/fixtures/app/vendor/lua/lundump.c",
113
+ "test/fixtures/app/vendor/lua/lundump.h",
114
+ "test/fixtures/app/vendor/lua/lvm.c",
115
+ "test/fixtures/app/vendor/lua/lvm.h",
116
+ "test/fixtures/app/vendor/lua/lzio.c",
117
+ "test/fixtures/app/vendor/lua/lzio.h",
118
+ "test/fixtures/app/vendor/lua/matrix.h",
119
+ "test/fixtures/app/vendor/lua/print.c",
120
+ "test/fixtures/app/vendor/lua/test/README",
121
+ "test/fixtures/app/vendor/lua/test/bisect.lua",
122
+ "test/fixtures/app/vendor/lua/test/cf.lua",
123
+ "test/fixtures/app/vendor/lua/test/echo.lua",
124
+ "test/fixtures/app/vendor/lua/test/env.lua",
125
+ "test/fixtures/app/vendor/lua/test/factorial.lua",
126
+ "test/fixtures/app/vendor/lua/test/fib.lua",
127
+ "test/fixtures/app/vendor/lua/test/fibfor.lua",
128
+ "test/fixtures/app/vendor/lua/test/globals.lua",
129
+ "test/fixtures/app/vendor/lua/test/hello.lua",
130
+ "test/fixtures/app/vendor/lua/test/life.lua",
131
+ "test/fixtures/app/vendor/lua/test/luac.lua",
132
+ "test/fixtures/app/vendor/lua/test/printf.lua",
133
+ "test/fixtures/app/vendor/lua/test/readonly.lua",
134
+ "test/fixtures/app/vendor/lua/test/sieve.lua",
135
+ "test/fixtures/app/vendor/lua/test/sort.lua",
136
+ "test/fixtures/app/vendor/lua/test/table.lua",
137
+ "test/fixtures/app/vendor/lua/test/trace-calls.lua",
138
+ "test/fixtures/app/vendor/lua/test/trace-globals.lua",
139
+ "test/fixtures/app/vendor/lua/test/xd.lua",
140
+ "test/fixtures/app/xml/classdub_1_1_matrix.xml",
141
+ "test/fixtures/app/xml/classdub_1_1_t_mat.xml",
142
+ "test/fixtures/app/xml/combine.xslt",
143
+ "test/fixtures/app/xml/compound.xsd",
144
+ "test/fixtures/app/xml/dir_53661a2bdeb1d55e60581a7e15deb763.xml",
145
+ "test/fixtures/app/xml/index.xml",
146
+ "test/fixtures/app/xml/index.xsd",
147
+ "test/fixtures/app/xml/matrix_8h.xml",
148
+ "test/fixtures/app/xml/namespacedub.xml",
149
+ "test/fixtures/classcv_1_1_mat.xml",
150
+ "test/fixtures/classcv_1_1_point__.xml",
151
+ "test/fixtures/classcv_1_1_scalar__.xml",
152
+ "test/fixtures/classcv_1_1_size__.xml",
153
+ "test/fixtures/dummy_class.cpp.erb",
154
+ "test/fixtures/dummy_function.cpp.erb",
155
+ "test/fixtures/group___magic_type.xml",
156
+ "test/fixtures/namespacecv.xml",
157
+ "test/function_group_test.rb",
158
+ "test/function_test.rb",
159
+ "test/group_test.rb",
160
+ "test/helper.rb",
161
+ "test/klass_test.rb",
162
+ "test/lua_function_gen_test.rb",
163
+ "test/namespace_test.rb",
164
+ "test/parser_test.rb"
165
+ ]
166
+ s.homepage = %q{http://github.com/ruby/dub}
167
+ s.rdoc_options = ["--charset=UTF-8"]
168
+ s.require_paths = ["lib"]
169
+ s.rubygems_version = %q{1.3.6}
170
+ s.summary = %q{A tool to ease the creation of scripting language bindings for a C++ library.}
171
+ s.test_files = [
172
+ "test/argument_test.rb",
173
+ "test/fixtures/app/make_lua_bindings.rb",
174
+ "test/function_group_test.rb",
175
+ "test/function_test.rb",
176
+ "test/group_test.rb",
177
+ "test/helper.rb",
178
+ "test/klass_test.rb",
179
+ "test/lua_function_gen_test.rb",
180
+ "test/namespace_test.rb",
181
+ "test/parser_test.rb"
182
+ ]
183
+
184
+ if s.respond_to? :specification_version then
185
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
186
+ s.specification_version = 3
187
+
188
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
189
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
190
+ else
191
+ s.add_dependency(%q<shoulda>, [">= 0"])
192
+ end
193
+ else
194
+ s.add_dependency(%q<shoulda>, [">= 0"])
195
+ end
196
+ end
197
+
@@ -0,0 +1,275 @@
1
+ require 'dub/entities_unescape'
2
+
3
+ module Dub
4
+ class Argument
5
+ include Dub::EntitiesUnescape
6
+ attr_reader :name, :default, :function, :xml
7
+ attr_accessor :type, :is_list, :is_list_count
8
+ TYPE_REGEXP = %r{^\s*(\w+\s+|)(const\s+|)([\w\:]+|\.\.\.)(\s*<(.+)>|)(\s*\*+|\s*&|)$}
9
+ NUMBER_TYPES = [
10
+ 'float',
11
+ 'double',
12
+ 'size_t',
13
+ 'unsigned int',
14
+ 'uint',
15
+ 'int',
16
+ 'size_t',
17
+ 'time_t',
18
+ 'unsigned int',
19
+ 'uint',
20
+ 'bool',
21
+ 'uchar',
22
+ 'char',
23
+ 'void',
24
+ 'int64'
25
+ ]
26
+
27
+ STRING_TYPES = [
28
+ 'char',
29
+ ]
30
+
31
+ NATIVE_C_TYPES = NUMBER_TYPES + STRING_TYPES
32
+
33
+ class << self
34
+
35
+ # This is used to resolve overloaded functions
36
+ def type_group(arg)
37
+ # exact same type
38
+ if NATIVE_C_TYPES.include?(arg.type)
39
+ if NUMBER_TYPES.include?(arg.type)
40
+ # number synonym
41
+ arg.is_pointer? ? :number_ptr : :number
42
+ else
43
+ # string synonym
44
+ raise "Not implemented yet"
45
+ # :string
46
+ end
47
+ else
48
+ # custom class / type
49
+ arg.id_name
50
+ end
51
+ end
52
+
53
+ # group is a list of functions, index = argument index
54
+ def decision_tree(group)
55
+ hash = {}
56
+ group.each do |function|
57
+ insert_by_type(hash, function)
58
+ end
59
+ hash
60
+ end
61
+
62
+ # Insert a function into the hash, using the argument at the given
63
+ # index to filter
64
+ def insert_by_type(hash, function, index = 0)
65
+ arg = function.arguments[index]
66
+ type = arg ? type_group(arg) : nil
67
+ slot = hash[type]
68
+ if slot.nil?
69
+ hash[type] = function
70
+ elsif slot.kind_of?(Hash)
71
+ insert_by_type(slot, function, index + 1)
72
+ elsif type.nil?
73
+ # ignore
74
+
75
+ # TODO: log level
76
+ # puts "Cannot filter functions #{function.source}"
77
+ else
78
+ h = {}
79
+ insert_by_type(h, slot, index + 1)
80
+ insert_by_type(h, function, index + 1)
81
+ hash[type] = h
82
+ end
83
+ end
84
+ end
85
+
86
+ def initialize(function, xml, arg_pos = nil)
87
+ @function, @xml, @argument_position = function, xml, arg_pos
88
+ parse_xml
89
+ end
90
+
91
+ def signature
92
+ "#{is_const? ? 'const ' : ''}#{type}#{is_ref? ? '&' : ''}"
93
+ end
94
+
95
+ def full_type
96
+ if type =~ /::/
97
+ type
98
+ else
99
+ container = function.parent
100
+ if container.kind_of?(Klass)
101
+ container = container.parent
102
+ end
103
+ container ? "#{container.name}::#{type}" : type
104
+ end
105
+ end
106
+
107
+ def id_name
108
+ full_type.gsub('::', '.')
109
+ end
110
+
111
+ alias inspect signature
112
+
113
+ def is_ref?
114
+ @ref
115
+ end
116
+
117
+ def is_pointer?
118
+ !@pointer.nil?
119
+ end
120
+
121
+ def is_const?
122
+ @const
123
+ end
124
+
125
+ def has_default?
126
+ !@default.nil?
127
+ end
128
+
129
+ def is_return_value?
130
+ @is_return_value
131
+ end
132
+
133
+ def is_native?
134
+ NATIVE_C_TYPES.include?(type)
135
+ end
136
+
137
+ def type
138
+ resolve_type if @template_params
139
+ @type
140
+ end
141
+
142
+ def vararg?
143
+ @type == '...'
144
+ end
145
+
146
+ def complex?
147
+ resolve_type if @template_params
148
+ @is_complex
149
+ end
150
+
151
+ def is_list?
152
+ @is_list
153
+ end
154
+
155
+ def is_list_count?
156
+ @is_list_count
157
+ end
158
+
159
+ def create_type
160
+ resolve_type if @template_params
161
+ (is_const? ? 'const ' : '') +
162
+ if (is_return_value? && !is_pointer?) || (is_native? && !is_pointer?)
163
+ "#{type} "
164
+ else
165
+ "#{type} *"
166
+ end
167
+ end
168
+
169
+ # this is for the cases where we have signatures like
170
+ # HuMoments(double moments[7])
171
+ def array_suffix
172
+ @array_suffix
173
+ end
174
+
175
+ def in_call_type
176
+ (is_native? || is_pointer?) ? name : "*#{name}"
177
+ end
178
+
179
+ private
180
+ def parse_xml
181
+ if type = (@xml/'type').first
182
+ # param
183
+ set_type(type)
184
+
185
+ @name = unescape((@xml/'declname').innerHTML)
186
+ if @name == ''
187
+ @name = "arg#{@argument_position}"
188
+ elsif @name == @function.name
189
+ @name = "arg_#{@name}"
190
+ end
191
+
192
+ if ref = (@xml/'defval/ref').first
193
+ ref.swap(ref.innerHTML)
194
+ end
195
+ @default = (@xml/'defval') ? unescape((@xml/'defval').innerHTML) : nil
196
+ @default = nil if @default == ''
197
+ expand_default_type if @default
198
+ else
199
+ # return value
200
+ @is_return_value = true
201
+ set_type(@xml/'')
202
+ end
203
+
204
+ if array = (@xml/'array').first
205
+ @array_suffix = array.innerHTML
206
+ end
207
+ end
208
+
209
+ def set_type(type)
210
+ # <type>const <ref refid="classcv_1_1_point__" kindref="compound">Point_</ref>&lt; int &gt; &amp;</type>
211
+ if ref = (type/'ref').first
212
+ @refid = ref[:refid]
213
+ ref.swap(ref.innerHTML)
214
+ end
215
+
216
+ type = type.innerHTML
217
+ type = unescape(type).strip
218
+
219
+ if type =~ TYPE_REGEXP
220
+ res = $~.to_a
221
+
222
+ if res[1].strip == 'const'
223
+ res[2] = res[1]
224
+ res[1] = ""
225
+ end
226
+
227
+ @const = res[2].strip == 'const'
228
+ @type = res[3]
229
+
230
+ if res[6] == ''
231
+ @pointer = nil
232
+ @res = nil
233
+ elsif res[6] =~ /^\s*(\*+)\s*$/
234
+ @pointer = $1
235
+ else
236
+ @ref = res[6].strip
237
+ end
238
+
239
+ @template_params = res[5] ? res[5].split(',').map(&:strip) : nil
240
+ else
241
+ # ERROR
242
+ end
243
+ end
244
+
245
+ # Replace something like AUTO_STEP by cv::Mat::AUTO_STEP
246
+ def expand_default_type
247
+ container = @function.parent
248
+ if container && container.enums.include?(@default)
249
+ @default = "#{container.full_type}::#{@default}"
250
+ elsif container = container.parent && container.enums.include?(@default)
251
+ @default = "#{container.full_type}::#{@default}"
252
+ end
253
+ end
254
+
255
+ def resolve_type
256
+ params = @template_params
257
+ @template_params = nil
258
+ if container = @function.parent
259
+ if container.kind_of?(Klass)
260
+ container = container.parent
261
+ end
262
+ if container && tclass = container.template_class(@type)
263
+ if instanciation = tclass.instanciations[params]
264
+ @type = instanciation.name
265
+ return
266
+ end
267
+ end
268
+ end
269
+
270
+ @type = "#{@type}< #{params.join(', ')} >"
271
+ Dub.logger.warn "Could not resolve templated type #{@type}"
272
+ @is_complex = true
273
+ end
274
+ end
275
+ end # Namespace
@@ -0,0 +1,16 @@
1
+ module Dub
2
+ module EntitiesUnescape
3
+ ENTITIES = {
4
+ '&amp;' => '&',
5
+ '&lt;' => '<',
6
+ '&gt;' => '>'
7
+ }
8
+
9
+ def unescape(str)
10
+ ENTITIES.each do |k,v|
11
+ str.gsub!(k, v)
12
+ end
13
+ str
14
+ end
15
+ end
16
+ end