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.
- data/.gitignore +8 -0
- data/History.txt +37 -0
- data/LICENSE +20 -0
- data/README.rdoc +48 -0
- data/Rakefile +58 -0
- data/dub.gemspec +197 -0
- data/lib/dub/argument.rb +275 -0
- data/lib/dub/entities_unescape.rb +16 -0
- data/lib/dub/function.rb +163 -0
- data/lib/dub/function_group.rb +72 -0
- data/lib/dub/generator.rb +15 -0
- data/lib/dub/group.rb +24 -0
- data/lib/dub/klass.rb +232 -0
- data/lib/dub/lua/class.cpp.erb +83 -0
- data/lib/dub/lua/class_gen.rb +97 -0
- data/lib/dub/lua/function.cpp.erb +18 -0
- data/lib/dub/lua/function_gen.rb +258 -0
- data/lib/dub/lua/group.cpp.erb +9 -0
- data/lib/dub/lua/lua_cpp_helper.h +141 -0
- data/lib/dub/lua/namespace.cpp.erb +40 -0
- data/lib/dub/lua/namespace_gen.rb +88 -0
- data/lib/dub/lua.rb +24 -0
- data/lib/dub/member_extraction.rb +92 -0
- data/lib/dub/namespace.rb +277 -0
- data/lib/dub/parser.rb +46 -0
- data/lib/dub/templates/lua_template.erb +21 -0
- data/lib/dub/version.rb +3 -0
- data/lib/dub.rb +23 -20
- data/test/argument_test.rb +547 -0
- data/test/fixtures/app/CMakeLists.txt +54 -0
- data/test/fixtures/app/Doxyfile +1600 -0
- data/test/fixtures/app/bindings/all_lua.cpp +299 -0
- data/test/fixtures/app/include/matrix.h +153 -0
- data/test/fixtures/app/make_lua_bindings.rb +13 -0
- data/test/fixtures/app/vendor/lua/CMakeLists.txt +25 -0
- data/test/fixtures/app/vendor/lua/COPYRIGHT +34 -0
- data/test/fixtures/app/vendor/lua/HISTORY +183 -0
- data/test/fixtures/app/vendor/lua/INSTALL +99 -0
- data/test/fixtures/app/vendor/lua/Makefile +183 -0
- data/test/fixtures/app/vendor/lua/README +37 -0
- data/test/fixtures/app/vendor/lua/lapi.c +1080 -0
- data/test/fixtures/app/vendor/lua/lapi.h +16 -0
- data/test/fixtures/app/vendor/lua/lauxlib.c +653 -0
- data/test/fixtures/app/vendor/lua/lauxlib.h +174 -0
- data/test/fixtures/app/vendor/lua/lbaselib.c +643 -0
- data/test/fixtures/app/vendor/lua/lcode.c +839 -0
- data/test/fixtures/app/vendor/lua/lcode.h +76 -0
- data/test/fixtures/app/vendor/lua/ldblib.c +397 -0
- data/test/fixtures/app/vendor/lua/ldebug.c +622 -0
- data/test/fixtures/app/vendor/lua/ldebug.h +33 -0
- data/test/fixtures/app/vendor/lua/ldo.c +516 -0
- data/test/fixtures/app/vendor/lua/ldo.h +57 -0
- data/test/fixtures/app/vendor/lua/ldump.c +164 -0
- data/test/fixtures/app/vendor/lua/lfunc.c +174 -0
- data/test/fixtures/app/vendor/lua/lfunc.h +34 -0
- data/test/fixtures/app/vendor/lua/lgc.c +711 -0
- data/test/fixtures/app/vendor/lua/lgc.h +110 -0
- data/test/fixtures/app/vendor/lua/liblua.a +0 -0
- data/test/fixtures/app/vendor/lua/linit.c +38 -0
- data/test/fixtures/app/vendor/lua/liolib.c +532 -0
- data/test/fixtures/app/vendor/lua/llex.c +461 -0
- data/test/fixtures/app/vendor/lua/llex.h +81 -0
- data/test/fixtures/app/vendor/lua/llimits.h +128 -0
- data/test/fixtures/app/vendor/lua/lmathlib.c +263 -0
- data/test/fixtures/app/vendor/lua/lmem.c +86 -0
- data/test/fixtures/app/vendor/lua/lmem.h +49 -0
- data/test/fixtures/app/vendor/lua/loadlib.c +664 -0
- data/test/fixtures/app/vendor/lua/lobject.c +214 -0
- data/test/fixtures/app/vendor/lua/lobject.h +381 -0
- data/test/fixtures/app/vendor/lua/lopcodes.c +102 -0
- data/test/fixtures/app/vendor/lua/lopcodes.h +268 -0
- data/test/fixtures/app/vendor/lua/loslib.c +244 -0
- data/test/fixtures/app/vendor/lua/lparser.c +1337 -0
- data/test/fixtures/app/vendor/lua/lparser.h +82 -0
- data/test/fixtures/app/vendor/lua/lstate.c +214 -0
- data/test/fixtures/app/vendor/lua/lstate.h +168 -0
- data/test/fixtures/app/vendor/lua/lstring.c +111 -0
- data/test/fixtures/app/vendor/lua/lstring.h +31 -0
- data/test/fixtures/app/vendor/lua/lstrlib.c +868 -0
- data/test/fixtures/app/vendor/lua/ltable.c +588 -0
- data/test/fixtures/app/vendor/lua/ltable.h +40 -0
- data/test/fixtures/app/vendor/lua/ltablib.c +278 -0
- data/test/fixtures/app/vendor/lua/ltm.c +75 -0
- data/test/fixtures/app/vendor/lua/ltm.h +54 -0
- data/test/fixtures/app/vendor/lua/lua.c +695 -0
- data/test/fixtures/app/vendor/lua/lua.h +385 -0
- data/test/fixtures/app/vendor/lua/lua_dub_helper.h +77 -0
- data/test/fixtures/app/vendor/lua/luac +0 -0
- data/test/fixtures/app/vendor/lua/luac.c +200 -0
- data/test/fixtures/app/vendor/lua/luaconf.h +762 -0
- data/test/fixtures/app/vendor/lua/lualib.h +53 -0
- data/test/fixtures/app/vendor/lua/lundump.c +223 -0
- data/test/fixtures/app/vendor/lua/lundump.h +36 -0
- data/test/fixtures/app/vendor/lua/lvm.c +765 -0
- data/test/fixtures/app/vendor/lua/lvm.h +36 -0
- data/test/fixtures/app/vendor/lua/lzio.c +82 -0
- data/test/fixtures/app/vendor/lua/lzio.h +67 -0
- data/test/fixtures/app/vendor/lua/matrix.h +102 -0
- data/test/fixtures/app/vendor/lua/print.c +227 -0
- data/test/fixtures/app/vendor/lua/test/README +26 -0
- data/test/fixtures/app/vendor/lua/test/bisect.lua +27 -0
- data/test/fixtures/app/vendor/lua/test/cf.lua +16 -0
- data/test/fixtures/app/vendor/lua/test/echo.lua +5 -0
- data/test/fixtures/app/vendor/lua/test/env.lua +7 -0
- data/test/fixtures/app/vendor/lua/test/factorial.lua +32 -0
- data/test/fixtures/app/vendor/lua/test/fib.lua +40 -0
- data/test/fixtures/app/vendor/lua/test/fibfor.lua +13 -0
- data/test/fixtures/app/vendor/lua/test/globals.lua +13 -0
- data/test/fixtures/app/vendor/lua/test/hello.lua +3 -0
- data/test/fixtures/app/vendor/lua/test/life.lua +111 -0
- data/test/fixtures/app/vendor/lua/test/luac.lua +7 -0
- data/test/fixtures/app/vendor/lua/test/printf.lua +7 -0
- data/test/fixtures/app/vendor/lua/test/readonly.lua +12 -0
- data/test/fixtures/app/vendor/lua/test/sieve.lua +29 -0
- data/test/fixtures/app/vendor/lua/test/sort.lua +66 -0
- data/test/fixtures/app/vendor/lua/test/table.lua +12 -0
- data/test/fixtures/app/vendor/lua/test/trace-calls.lua +32 -0
- data/test/fixtures/app/vendor/lua/test/trace-globals.lua +38 -0
- data/test/fixtures/app/vendor/lua/test/xd.lua +14 -0
- data/test/fixtures/app/xml/classdub_1_1_matrix.xml +313 -0
- data/test/fixtures/app/xml/classdub_1_1_t_mat.xml +252 -0
- data/test/fixtures/app/xml/combine.xslt +15 -0
- data/test/fixtures/app/xml/compound.xsd +814 -0
- data/test/fixtures/app/xml/dir_53661a2bdeb1d55e60581a7e15deb763.xml +12 -0
- data/test/fixtures/app/xml/index.xml +47 -0
- data/test/fixtures/app/xml/index.xsd +66 -0
- data/test/fixtures/app/xml/matrix_8h.xml +175 -0
- data/test/fixtures/app/xml/namespacedub.xml +41 -0
- data/test/fixtures/classcv_1_1_mat.xml +1996 -0
- data/test/fixtures/classcv_1_1_point__.xml +341 -0
- data/test/fixtures/classcv_1_1_scalar__.xml +269 -0
- data/test/fixtures/classcv_1_1_size__.xml +270 -0
- data/test/fixtures/dummy_class.cpp.erb +1 -0
- data/test/fixtures/dummy_function.cpp.erb +1 -0
- data/test/fixtures/group___magic_type.xml +406 -0
- data/test/fixtures/namespacecv.xml +12659 -0
- data/test/function_group_test.rb +24 -0
- data/test/function_test.rb +395 -0
- data/test/group_test.rb +155 -0
- data/test/helper.rb +34 -0
- data/test/klass_test.rb +395 -0
- data/test/lua_function_gen_test.rb +195 -0
- data/test/namespace_test.rb +220 -0
- data/test/parser_test.rb +36 -0
- metadata +211 -275
- checksums.yaml +0 -7
- data/lib/open_api_sdk/analytics.rb +0 -99
- data/lib/open_api_sdk/domains.rb +0 -353
- data/lib/open_api_sdk/dub.rb +0 -88
- data/lib/open_api_sdk/links.rb +0 -766
- data/lib/open_api_sdk/metatags.rb +0 -54
- data/lib/open_api_sdk/models/operations/bulkcreatelinks_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/bulkupdatelinks_requestbody.rb +0 -27
- data/lib/open_api_sdk/models/operations/bulkupdatelinks_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/color.rb +0 -24
- data/lib/open_api_sdk/models/operations/createdomain_requestbody.rb +0 -33
- data/lib/open_api_sdk/models/operations/createdomain_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/createlink_requestbody.rb +0 -95
- data/lib/open_api_sdk/models/operations/createlink_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/createtag_requestbody.rb +0 -32
- data/lib/open_api_sdk/models/operations/createtag_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/data.rb +0 -83
- data/lib/open_api_sdk/models/operations/deletedomain_request.rb +0 -24
- data/lib/open_api_sdk/models/operations/deletedomain_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/deletedomain_responsebody.rb +0 -24
- data/lib/open_api_sdk/models/operations/deletelink_request.rb +0 -24
- data/lib/open_api_sdk/models/operations/deletelink_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/deletelink_responsebody.rb +0 -24
- data/lib/open_api_sdk/models/operations/event.rb +0 -21
- data/lib/open_api_sdk/models/operations/getlinkinfo_request.rb +0 -33
- data/lib/open_api_sdk/models/operations/getlinkinfo_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/getlinks_request.rb +0 -51
- data/lib/open_api_sdk/models/operations/getlinks_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/getlinkscount_request.rb +0 -48
- data/lib/open_api_sdk/models/operations/getlinkscount_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/getmetatags_request.rb +0 -24
- data/lib/open_api_sdk/models/operations/getmetatags_response.rb +0 -33
- data/lib/open_api_sdk/models/operations/getmetatags_responsebody.rb +0 -30
- data/lib/open_api_sdk/models/operations/getqrcode_request.rb +0 -39
- data/lib/open_api_sdk/models/operations/getqrcode_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/gettags_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/getworkspace_request.rb +0 -24
- data/lib/open_api_sdk/models/operations/getworkspace_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/groupby.rb +0 -28
- data/lib/open_api_sdk/models/operations/interval.rb +0 -25
- data/lib/open_api_sdk/models/operations/level.rb +0 -21
- data/lib/open_api_sdk/models/operations/listdomains_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/paymentprocessor.rb +0 -20
- data/lib/open_api_sdk/models/operations/requestbody.rb +0 -95
- data/lib/open_api_sdk/models/operations/retrieveanalytics_request.rb +0 -81
- data/lib/open_api_sdk/models/operations/retrieveanalytics_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/sort.rb +0 -20
- data/lib/open_api_sdk/models/operations/trackcustomer_requestbody.rb +0 -33
- data/lib/open_api_sdk/models/operations/trackcustomer_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/trackcustomer_responsebody.rb +0 -33
- data/lib/open_api_sdk/models/operations/tracklead_requestbody.rb +0 -42
- data/lib/open_api_sdk/models/operations/tracklead_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/tracklead_responsebody.rb +0 -42
- data/lib/open_api_sdk/models/operations/tracksale_requestbody.rb +0 -42
- data/lib/open_api_sdk/models/operations/tracksale_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/tracksale_responsebody.rb +0 -42
- data/lib/open_api_sdk/models/operations/updatedomain_request.rb +0 -27
- data/lib/open_api_sdk/models/operations/updatedomain_requestbody.rb +0 -33
- data/lib/open_api_sdk/models/operations/updatedomain_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/updatelink_request.rb +0 -27
- data/lib/open_api_sdk/models/operations/updatelink_requestbody.rb +0 -95
- data/lib/open_api_sdk/models/operations/updatelink_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/updatetag_color.rb +0 -24
- data/lib/open_api_sdk/models/operations/updatetag_request.rb +0 -27
- data/lib/open_api_sdk/models/operations/updatetag_requestbody.rb +0 -32
- data/lib/open_api_sdk/models/operations/updatetag_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/updateworkspace_request.rb +0 -27
- data/lib/open_api_sdk/models/operations/updateworkspace_requestbody.rb +0 -27
- data/lib/open_api_sdk/models/operations/updateworkspace_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/upsertlink_requestbody.rb +0 -95
- data/lib/open_api_sdk/models/operations/upsertlink_response.rb +0 -60
- data/lib/open_api_sdk/models/operations.rb +0 -74
- data/lib/open_api_sdk/models/shared/badrequest.rb +0 -24
- data/lib/open_api_sdk/models/shared/code.rb +0 -18
- data/lib/open_api_sdk/models/shared/color.rb +0 -24
- data/lib/open_api_sdk/models/shared/conflict.rb +0 -24
- data/lib/open_api_sdk/models/shared/conflict_code.rb +0 -18
- data/lib/open_api_sdk/models/shared/conflict_error.rb +0 -30
- data/lib/open_api_sdk/models/shared/countrycode.rb +0 -267
- data/lib/open_api_sdk/models/shared/domains.rb +0 -27
- data/lib/open_api_sdk/models/shared/domainschema.rb +0 -48
- data/lib/open_api_sdk/models/shared/error.rb +0 -30
- data/lib/open_api_sdk/models/shared/forbidden.rb +0 -24
- data/lib/open_api_sdk/models/shared/forbidden_code.rb +0 -18
- data/lib/open_api_sdk/models/shared/forbidden_error.rb +0 -30
- data/lib/open_api_sdk/models/shared/geo.rb +0 -771
- data/lib/open_api_sdk/models/shared/internalservererror.rb +0 -24
- data/lib/open_api_sdk/models/shared/internalservererror_code.rb +0 -18
- data/lib/open_api_sdk/models/shared/internalservererror_error.rb +0 -30
- data/lib/open_api_sdk/models/shared/inviteexpired.rb +0 -24
- data/lib/open_api_sdk/models/shared/inviteexpired_code.rb +0 -18
- data/lib/open_api_sdk/models/shared/inviteexpired_error.rb +0 -30
- data/lib/open_api_sdk/models/shared/linkgeotargeting.rb +0 -771
- data/lib/open_api_sdk/models/shared/linkschema.rb +0 -142
- data/lib/open_api_sdk/models/shared/notfound.rb +0 -24
- data/lib/open_api_sdk/models/shared/notfound_code.rb +0 -18
- data/lib/open_api_sdk/models/shared/notfound_error.rb +0 -30
- data/lib/open_api_sdk/models/shared/plan.rb +0 -24
- data/lib/open_api_sdk/models/shared/ratelimitexceeded.rb +0 -24
- data/lib/open_api_sdk/models/shared/ratelimitexceeded_code.rb +0 -18
- data/lib/open_api_sdk/models/shared/ratelimitexceeded_error.rb +0 -30
- data/lib/open_api_sdk/models/shared/role.rb +0 -19
- data/lib/open_api_sdk/models/shared/security.rb +0 -24
- data/lib/open_api_sdk/models/shared/tagschema.rb +0 -30
- data/lib/open_api_sdk/models/shared/unauthorized.rb +0 -24
- data/lib/open_api_sdk/models/shared/unauthorized_code.rb +0 -18
- data/lib/open_api_sdk/models/shared/unauthorized_error.rb +0 -30
- data/lib/open_api_sdk/models/shared/unprocessableentity.rb +0 -24
- data/lib/open_api_sdk/models/shared/unprocessableentity_code.rb +0 -18
- data/lib/open_api_sdk/models/shared/unprocessableentity_error.rb +0 -30
- data/lib/open_api_sdk/models/shared/users.rb +0 -24
- data/lib/open_api_sdk/models/shared/workspaceschema.rb +0 -81
- data/lib/open_api_sdk/models/shared.rb +0 -49
- data/lib/open_api_sdk/qr_codes.rb +0 -97
- data/lib/open_api_sdk/sdkconfiguration.rb +0 -52
- data/lib/open_api_sdk/tags.rb +0 -272
- data/lib/open_api_sdk/track.rb +0 -276
- data/lib/open_api_sdk/utils/metadata_fields.rb +0 -150
- data/lib/open_api_sdk/utils/t.rb +0 -59
- data/lib/open_api_sdk/utils/utils.rb +0 -772
- data/lib/open_api_sdk/workspaces.rb +0 -192
data/.gitignore
ADDED
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
|
+
|
data/lib/dub/argument.rb
ADDED
@@ -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>< int > &</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
|