dub 0.2.2 → 1.0.0
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/History.txt +92 -0
- data/LICENSE +20 -0
- data/README.rdoc +115 -0
- data/Rakefile +59 -0
- data/dub.gemspec +197 -0
- data/lib/dub/argument.rb +286 -0
- data/lib/dub/entities_unescape.rb +9 -0
- data/lib/dub/function.rb +177 -0
- data/lib/dub/function_group.rb +72 -0
- data/lib/dub/generator.rb +15 -0
- data/lib/dub/group.rb +20 -0
- data/lib/dub/klass.rb +338 -0
- data/lib/dub/lua/class.cpp.erb +114 -0
- data/lib/dub/lua/class_gen.rb +96 -0
- data/lib/dub/lua/function.cpp.erb +15 -0
- data/lib/dub/lua/function_gen.rb +329 -0
- data/lib/dub/lua/group.cpp.erb +9 -0
- data/lib/dub/lua/lua_cpp_helper.cpp +259 -0
- data/lib/dub/lua/lua_cpp_helper.h +219 -0
- data/lib/dub/lua/lua_object.cpp +158 -0
- data/lib/dub/lua/lua_object.h +69 -0
- data/lib/dub/lua/namespace.cpp.erb +42 -0
- data/lib/dub/lua/namespace_gen.rb +69 -0
- data/lib/dub/lua.rb +24 -0
- data/lib/dub/member_extraction.rb +128 -0
- data/lib/dub/namespace.rb +295 -0
- data/lib/dub/opts_parser.rb +30 -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 +24 -20
- data/test/argument_test.rb +581 -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 +283 -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_base.xml +85 -0
- data/test/fixtures/app/xml/classdub_1_1_custom_destructor.xml +67 -0
- data/test/fixtures/app/xml/classdub_1_1_deletable_out_of_lua.xml +43 -0
- data/test/fixtures/app/xml/classdub_1_1_matrix.xml +482 -0
- data/test/fixtures/app/xml/classdub_1_1_no_destructor.xml +49 -0
- data/test/fixtures/app/xml/classdub_1_1_priv_sub_base.xml +89 -0
- data/test/fixtures/app/xml/classdub_1_1_private_constr.xml +68 -0
- data/test/fixtures/app/xml/classdub_1_1_static_constr.xml +69 -0
- data/test/fixtures/app/xml/classdub_1_1_sub_base.xml +89 -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 +91 -0
- data/test/fixtures/app/xml/index.xsd +66 -0
- data/test/fixtures/app/xml/matrix_8h.xml +310 -0
- data/test/fixtures/app/xml/namespacedub.xml +48 -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 +43 -0
- data/test/function_test.rb +405 -0
- data/test/group_test.rb +241 -0
- data/test/helper.rb +34 -0
- data/test/klass_test.rb +551 -0
- data/test/lua_function_gen_test.rb +242 -0
- data/test/namespace_test.rb +220 -0
- data/test/parser_test.rb +36 -0
- metadata +229 -272
- 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/test/helper.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'shoulda'
|
4
|
+
|
5
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
6
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
7
|
+
require 'dub'
|
8
|
+
|
9
|
+
class Test::Unit::TestCase
|
10
|
+
|
11
|
+
def self.fixture(path)
|
12
|
+
File.join(File.dirname(__FILE__), 'fixtures', path)
|
13
|
+
end
|
14
|
+
|
15
|
+
@@namespacecv_xml = nil
|
16
|
+
|
17
|
+
Dub.logger.level = Logger::FATAL
|
18
|
+
|
19
|
+
def fixture(path)
|
20
|
+
self.class.fixture(path)
|
21
|
+
end
|
22
|
+
|
23
|
+
def namespacecv_xml
|
24
|
+
@@namespacecv_xml ||= Dub.parse(fixture('namespacecv.xml'))
|
25
|
+
end
|
26
|
+
|
27
|
+
def namespacedub_xml
|
28
|
+
@@namespacedub_xml ||= Dub.parse(fixture('app/xml/namespacedub.xml'))
|
29
|
+
end
|
30
|
+
|
31
|
+
def groupmagic_xml
|
32
|
+
@@groupmagic_xml ||= Dub.parse(fixture('group___magic_type.xml'))
|
33
|
+
end
|
34
|
+
end
|
data/test/klass_test.rb
ADDED
@@ -0,0 +1,551 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'dub/lua'
|
3
|
+
|
4
|
+
class KlassTest < Test::Unit::TestCase
|
5
|
+
def assert_include(x, list)
|
6
|
+
assert list.include?(x)
|
7
|
+
end
|
8
|
+
|
9
|
+
context 'A Klass' do
|
10
|
+
setup do
|
11
|
+
# namespacecv_xml = Dub.parse(fixture('app/xml/namespacedub.xml'))
|
12
|
+
@class = namespacedub_xml[:dub][:Matrix]
|
13
|
+
end
|
14
|
+
|
15
|
+
should 'return a list of Functions with members' do
|
16
|
+
assert_kind_of Array, @class.members
|
17
|
+
assert_kind_of Dub::Function, @class.members.first
|
18
|
+
end
|
19
|
+
|
20
|
+
should 'return name with name' do
|
21
|
+
assert_equal 'Matrix', @class.name
|
22
|
+
end
|
23
|
+
|
24
|
+
should 'have namespace prefix' do
|
25
|
+
assert_equal 'dub', @class.prefix
|
26
|
+
end
|
27
|
+
|
28
|
+
should 'accept any attribute' do
|
29
|
+
assert_nothing_raised do
|
30
|
+
@class.foo = 'bar'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
should 'store special attributes in opts' do
|
35
|
+
@class.foo = 'bar'
|
36
|
+
assert_equal 'bar', @class.opts[:foo]
|
37
|
+
end
|
38
|
+
|
39
|
+
should 'return value from opts on method missing' do
|
40
|
+
@class.foo = 'bar'
|
41
|
+
assert_equal 'bar', @class.foo
|
42
|
+
end
|
43
|
+
|
44
|
+
should 'use name as default in lib_name' do
|
45
|
+
@class.opts.delete(:lib_name)
|
46
|
+
assert_equal 'Matrix', @class.lib_name
|
47
|
+
end
|
48
|
+
|
49
|
+
should 'use lib_name if set in lib_name' do
|
50
|
+
@class.opts[:lib_name] = "dooMat"
|
51
|
+
assert_equal 'dooMat', @class.lib_name
|
52
|
+
end
|
53
|
+
|
54
|
+
should 'get @dub options from header' do
|
55
|
+
assert_equal 'dummy value', @class.var_from_dub
|
56
|
+
assert_equal 'some other value', @class.other_from_dub
|
57
|
+
end
|
58
|
+
|
59
|
+
should 'use ignore @dub option from header' do
|
60
|
+
list = @class.members.map(&:name)
|
61
|
+
assert !list.include?('bad_method')
|
62
|
+
end
|
63
|
+
|
64
|
+
should 'combine prefix and name in id_name' do
|
65
|
+
assert_equal 'dub.Matrix', @class.id_name
|
66
|
+
end
|
67
|
+
|
68
|
+
should 'combine prefix and provided name in id_name' do
|
69
|
+
assert_equal 'dub.Foobar', @class.id_name('Foobar')
|
70
|
+
end
|
71
|
+
|
72
|
+
should 'use parent namespace in full_type' do
|
73
|
+
assert_equal 'dub::Matrix', @class.full_type
|
74
|
+
end
|
75
|
+
|
76
|
+
should 'return file and line on source' do
|
77
|
+
assert_match %r{app/include/matrix\.h:\d+}, @class.source
|
78
|
+
end
|
79
|
+
|
80
|
+
should 'return a list of class methods' do
|
81
|
+
assert_kind_of Array, @class.class_methods
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'with a bound member list' do
|
85
|
+
setup do
|
86
|
+
Dub::Lua.bind(@class)
|
87
|
+
@list = @class.members.map(&:name)
|
88
|
+
end
|
89
|
+
|
90
|
+
should 'remove destructor from member list' do
|
91
|
+
assert !@list.include?("~Matrix")
|
92
|
+
end
|
93
|
+
|
94
|
+
should 'remove constructor from member list' do
|
95
|
+
assert !@list.include?("Matrix")
|
96
|
+
end
|
97
|
+
|
98
|
+
should 'ignore template methods in member list' do
|
99
|
+
assert !@list.include?("give_me_tea")
|
100
|
+
end
|
101
|
+
|
102
|
+
should 'ignore members with templated arguments' do
|
103
|
+
# at least for now
|
104
|
+
assert_nil @class[:mul]
|
105
|
+
assert !@list.include?("mul")
|
106
|
+
assert_no_match %r{Matrix_mul}, @class.to_s
|
107
|
+
end
|
108
|
+
|
109
|
+
should 'ignore private members' do
|
110
|
+
assert !@list.include?("private_method")
|
111
|
+
end
|
112
|
+
|
113
|
+
should 'ignore property members' do
|
114
|
+
assert !@list.include?("foo_prop")
|
115
|
+
end
|
116
|
+
|
117
|
+
should 'not count property with same name as overloaded functions' do
|
118
|
+
assert_kind_of Dub::Function, @class[:size]
|
119
|
+
end
|
120
|
+
|
121
|
+
should 'ignore protected members' do
|
122
|
+
assert !@list.include?("protected_method")
|
123
|
+
end
|
124
|
+
|
125
|
+
should 'ignore operator methods in member list' do
|
126
|
+
assert !@list.include?("operator size_t")
|
127
|
+
end
|
128
|
+
|
129
|
+
should 'ignore members returning native pointers' do
|
130
|
+
assert !@list.include?("ptr")
|
131
|
+
end
|
132
|
+
|
133
|
+
should 'accept members returning const char pointers' do
|
134
|
+
assert @list.include?("name")
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
should 'return constructor with constructor' do
|
139
|
+
const = @class.constructor
|
140
|
+
assert_kind_of Dub::Function, const.first
|
141
|
+
end
|
142
|
+
|
143
|
+
should 'respond to destructor_name' do
|
144
|
+
assert_equal 'Matrix_destructor', @class.destructor_name
|
145
|
+
end
|
146
|
+
|
147
|
+
should 'respond to tostring_name' do
|
148
|
+
assert_equal 'Matrix__tostring', @class.tostring_name
|
149
|
+
end
|
150
|
+
|
151
|
+
should 'respond to constructor.method_name' do
|
152
|
+
assert_equal 'Matrix_Matrix', @class.constructor.method_name(0)
|
153
|
+
end
|
154
|
+
|
155
|
+
should 'find method with array index' do
|
156
|
+
assert_kind_of Dub::Function, @class[:rows]
|
157
|
+
end
|
158
|
+
|
159
|
+
should 'find static methods with array index' do
|
160
|
+
assert_kind_of Dub::Function, @class[:MakeMatrix]
|
161
|
+
end
|
162
|
+
|
163
|
+
should 'return header name on header' do
|
164
|
+
assert_equal 'matrix.h', @class.header
|
165
|
+
end
|
166
|
+
|
167
|
+
should 'return defined header if changed' do
|
168
|
+
klass = Dub.parse(fixture('app/xml/namespacedub.xml'))[:dub][:Matrix]
|
169
|
+
klass.header = 'opencv/cv.h'
|
170
|
+
assert_equal 'opencv/cv.h', klass.header
|
171
|
+
end
|
172
|
+
|
173
|
+
should 'know that it is not a template' do
|
174
|
+
assert !@class.template?
|
175
|
+
end
|
176
|
+
|
177
|
+
context 'bound to a generator' do
|
178
|
+
setup do
|
179
|
+
Dub::Lua.bind(@class)
|
180
|
+
end
|
181
|
+
|
182
|
+
should 'bind each member' do
|
183
|
+
assert_equal Dub::Lua.function_generator, @class.members.first.gen
|
184
|
+
end
|
185
|
+
|
186
|
+
should 'register constructor' do
|
187
|
+
assert_match %r{\{\s*\"Matrix\"\s*,\s*Matrix_Matrix\s*\}}, @class.to_s
|
188
|
+
end
|
189
|
+
|
190
|
+
should 'build constructor' do
|
191
|
+
result = @class.to_s
|
192
|
+
assert_match %r{static int Matrix_Matrix1\s*\(}, result
|
193
|
+
assert_match %r{static int Matrix_Matrix2\s*\(}, result
|
194
|
+
assert_match %r{static int Matrix_Matrix\s*\(}, result
|
195
|
+
end
|
196
|
+
|
197
|
+
should 'build destructor' do
|
198
|
+
result = @class.to_s
|
199
|
+
assert_match %r{static int Matrix_Matrix1\s*\(}, result
|
200
|
+
assert_match %r{static int Matrix_Matrix2\s*\(}, result
|
201
|
+
assert_match %r{static int Matrix_Matrix\s*\(}, result
|
202
|
+
assert_match %r{if \(\*userdata\) delete \*userdata;}, result
|
203
|
+
end
|
204
|
+
|
205
|
+
context 'with a custom destructor' do
|
206
|
+
subject do
|
207
|
+
namespacedub_xml[:dub][:CustomDestructor]
|
208
|
+
end
|
209
|
+
|
210
|
+
should 'respond true to custom_destructor?' do
|
211
|
+
assert subject.custom_destructor?
|
212
|
+
end
|
213
|
+
|
214
|
+
should 'use custom destructor' do
|
215
|
+
Dub::Lua.bind(subject)
|
216
|
+
assert_match %r{if \(\*userdata\) \(\*userdata\)->dub_destroy\(\);}, subject.to_s
|
217
|
+
end
|
218
|
+
|
219
|
+
should 'secure calls' do
|
220
|
+
function = subject[:do_this]
|
221
|
+
Dub::Lua.bind(function)
|
222
|
+
assert_match %r{if \(!self__\) return luaL_error\(L, "Using deleted dub\.CustomDestructor in do_this"\);}, function.to_s
|
223
|
+
end
|
224
|
+
|
225
|
+
should 'specialize to_string' do
|
226
|
+
Dub::Lua.bind(subject)
|
227
|
+
assert_match %r{if \(!\*userdata\) \{.*lua_pushstring\(L, "<dub.CustomDestructor: NULL>"\);}m, subject.to_s
|
228
|
+
end
|
229
|
+
|
230
|
+
should 'add deleted method' do
|
231
|
+
Dub::Lua.bind(subject)
|
232
|
+
assert_match %r{CustomDestructor_deleted.*lua_pushboolean\(L, \*userdata == NULL\);}m, subject.to_s
|
233
|
+
end
|
234
|
+
|
235
|
+
should 'not insert destructor in members' do
|
236
|
+
assert !subject.members.map(&:name).include?('destroy')
|
237
|
+
end
|
238
|
+
|
239
|
+
should 'ignore set_userdata_ptr' do
|
240
|
+
assert !subject.members.map(&:name).include?('set_userdata_ptr')
|
241
|
+
end
|
242
|
+
|
243
|
+
should 'set pointer to userdata on create' do
|
244
|
+
function = subject[:CustomDestructor]
|
245
|
+
Dub::Lua.bind(function)
|
246
|
+
assert_match %r{lua_pushclass2}, function.to_s
|
247
|
+
end
|
248
|
+
end # with a custom destructor
|
249
|
+
|
250
|
+
context 'with a custom destructor set to nothing' do
|
251
|
+
subject do
|
252
|
+
@klass = namespacedub_xml[:dub][:NoDestructor]
|
253
|
+
Dub::Lua.bind(@klass)
|
254
|
+
@klass.to_s
|
255
|
+
end
|
256
|
+
|
257
|
+
should 'not create destructor' do
|
258
|
+
subject
|
259
|
+
assert_no_match %r{#{@klass.destructor_name}}, subject
|
260
|
+
end
|
261
|
+
|
262
|
+
should 'not declare __gc' do
|
263
|
+
assert_no_match %r{__gc}m, subject
|
264
|
+
end
|
265
|
+
end # with a custom destructor
|
266
|
+
|
267
|
+
should 'return new objects in constructors' do
|
268
|
+
@class = namespacecv_xml[:cv][:Mat]
|
269
|
+
Dub::Lua.bind(@class)
|
270
|
+
assert_match %r{lua_pushclass<Mat>.*"cv.Mat"}, @class.constructor.first.to_s
|
271
|
+
end
|
272
|
+
|
273
|
+
context 'with a custom constructor' do
|
274
|
+
subject do
|
275
|
+
@klass = namespacedub_xml[:dub][:StaticConstr]
|
276
|
+
Dub::Lua.bind(@klass)
|
277
|
+
@klass
|
278
|
+
end
|
279
|
+
|
280
|
+
should 'respond true to custom_constructor?' do
|
281
|
+
assert subject.custom_constructor?
|
282
|
+
end
|
283
|
+
|
284
|
+
should 'not create normal constructor' do
|
285
|
+
assert_no_match %r{StaticConstr_StaticConstr}, subject.to_s
|
286
|
+
end
|
287
|
+
|
288
|
+
should 'declare static method as constructor' do
|
289
|
+
assert_match %r{\{"StaticConstr"\s*,\s*StaticConstr_MakeStaticConstr\},}, subject.to_s
|
290
|
+
end
|
291
|
+
|
292
|
+
should 'not declare static method as method' do
|
293
|
+
assert_no_match %r{\{"StaticConstr_MakeStaticConstr",\s+StaticConstr_MakeStaticConstr\},}, subject.to_s
|
294
|
+
end
|
295
|
+
end # with a custom destructor
|
296
|
+
|
297
|
+
should 'include class header' do
|
298
|
+
assert_match %r{#include\s+"matrix.h"}, @class.to_s
|
299
|
+
end
|
300
|
+
|
301
|
+
should 'include helper header' do
|
302
|
+
assert_match %r{#include\s+"lua_cpp_helper.h"}, @class.to_s
|
303
|
+
end
|
304
|
+
|
305
|
+
should 'create Lua metatable with class name' do
|
306
|
+
assert_match %r{luaL_newmetatable\(L,\s*"dub.Matrix"\)}, @class.to_s
|
307
|
+
end
|
308
|
+
|
309
|
+
should 'not build template methods' do
|
310
|
+
assert_no_match %r{give_me_tea}, @class.to_s
|
311
|
+
end
|
312
|
+
|
313
|
+
should 'declare tostring' do
|
314
|
+
assert_match %r{__tostring}, @class.to_s
|
315
|
+
end
|
316
|
+
|
317
|
+
should 'use custom format if provided for tostring' do
|
318
|
+
@class.string_format = "%dx%d"
|
319
|
+
@class.string_args = "(*userdata)->rows, (*userdata)->cols"
|
320
|
+
assert_match %r{\(\*userdata\)->rows, \(\*userdata\)->cols}, @class.to_s
|
321
|
+
end
|
322
|
+
|
323
|
+
should 'use a default method for tostring if no custom string_format is provided' do
|
324
|
+
@class.string_format = nil
|
325
|
+
assert_match %r{<dub.Matrix: %p>}, @class.to_s
|
326
|
+
end
|
327
|
+
|
328
|
+
should 'implement tostring' do
|
329
|
+
assert_match %r{Matrix__tostring\(lua_State}, @class.to_s
|
330
|
+
end
|
331
|
+
|
332
|
+
context 'using a custom template' do
|
333
|
+
setup do
|
334
|
+
@class.gen.template_path = fixture('dummy_class.cpp.erb')
|
335
|
+
end
|
336
|
+
|
337
|
+
teardown do
|
338
|
+
@class.gen.template_path = nil
|
339
|
+
end
|
340
|
+
|
341
|
+
should 'use custom template to render function' do
|
342
|
+
assert_equal 'CLASS: Matrix', @class.to_s
|
343
|
+
end
|
344
|
+
end
|
345
|
+
end
|
346
|
+
end
|
347
|
+
|
348
|
+
context 'A sub class' do
|
349
|
+
subject do
|
350
|
+
# namespacecv_xml = Dub.parse(fixture('app/xml/namespacedub.xml'))
|
351
|
+
namespacedub_xml[:dub][:SubBase]
|
352
|
+
end
|
353
|
+
|
354
|
+
should 'know the list of the public super classes' do
|
355
|
+
assert_include namespacedub_xml[:dub][:Base], subject.superclasses
|
356
|
+
end
|
357
|
+
|
358
|
+
should 'include public methods from super class' do
|
359
|
+
assert_include 'method_in_base', subject.members.map(&:name)
|
360
|
+
end
|
361
|
+
end
|
362
|
+
|
363
|
+
context 'A template class' do
|
364
|
+
setup do
|
365
|
+
# namespacecv_xml = Dub.parse(fixture('app/xml/namespacedub.xml'))
|
366
|
+
@class = namespacedub_xml[:dub].template_class(:TMat)
|
367
|
+
end
|
368
|
+
|
369
|
+
should 'know that it is a template' do
|
370
|
+
assert @class.template?
|
371
|
+
end
|
372
|
+
|
373
|
+
should 'return template parameters' do
|
374
|
+
assert_equal ['T'], @class.template_params
|
375
|
+
end
|
376
|
+
end
|
377
|
+
|
378
|
+
context 'A class defined from a template' do
|
379
|
+
setup do
|
380
|
+
@class = namespacecv_xml[:cv][:Size]
|
381
|
+
end
|
382
|
+
|
383
|
+
should 'replace template parameter in method arguments' do
|
384
|
+
Dub::Lua.bind(@class)
|
385
|
+
assert_match %r{int *_width}, @class.to_s
|
386
|
+
end
|
387
|
+
|
388
|
+
should 'register in the template for these types' do
|
389
|
+
@tclass = namespacecv_xml[:cv].template_class(:Size_)
|
390
|
+
assert_equal @class, @tclass.instanciations[['int']]
|
391
|
+
end
|
392
|
+
|
393
|
+
context 'with a bound member list' do
|
394
|
+
setup do
|
395
|
+
@class = namespacedub_xml[:dub][:FMatrix]
|
396
|
+
Dub::Lua.bind(@class)
|
397
|
+
@list = @class.members.map(&:name)
|
398
|
+
end
|
399
|
+
|
400
|
+
should 'ignore template methods in member list' do
|
401
|
+
assert !@list.include?("give_me_tea")
|
402
|
+
end
|
403
|
+
|
404
|
+
should 'ignore template methods in member registration' do
|
405
|
+
assert_no_match %r{give_me_tea}, @class.gen.method_registration(@class)
|
406
|
+
end
|
407
|
+
|
408
|
+
should 'ignore template methods in method istanciation' do
|
409
|
+
assert_no_match %r{give_me_tea}, @class.to_s
|
410
|
+
end
|
411
|
+
end
|
412
|
+
end
|
413
|
+
|
414
|
+
# strangely, the bug does not show up with "FMatrix"
|
415
|
+
context 'Another class defined from a template' do
|
416
|
+
setup do
|
417
|
+
@class = namespacecv_xml[:cv][:Scalar]
|
418
|
+
end
|
419
|
+
|
420
|
+
context 'with a bound member list' do
|
421
|
+
setup do
|
422
|
+
Dub::Lua.bind(@class)
|
423
|
+
@list = @class.members.map(&:name)
|
424
|
+
end
|
425
|
+
|
426
|
+
should 'ignore template methods in member list' do
|
427
|
+
assert !@list.include?("convertTo")
|
428
|
+
end
|
429
|
+
|
430
|
+
should 'ignore template methods in member registration' do
|
431
|
+
assert_no_match %r{convertTo}, @class.gen.method_registration(@class)
|
432
|
+
end
|
433
|
+
|
434
|
+
should 'ignore template methods in method istanciation' do
|
435
|
+
assert_no_match %r{convertTo}, @class.to_s
|
436
|
+
end
|
437
|
+
end
|
438
|
+
end
|
439
|
+
|
440
|
+
context 'A class with alias names' do
|
441
|
+
setup do
|
442
|
+
# namespacecv_xml = Dub.parse(fixture('app/xml/namespacedub.xml'))
|
443
|
+
@class = namespacedub_xml[:dub][:FloatMat]
|
444
|
+
end
|
445
|
+
|
446
|
+
should 'return a list of these alias on alias_names' do
|
447
|
+
assert_equal ['FloatMat'], @class.alias_names
|
448
|
+
assert_equal 'FMatrix', @class.name
|
449
|
+
end
|
450
|
+
|
451
|
+
should 'find class from alias in namespace' do
|
452
|
+
assert_equal @class, namespacedub_xml[:dub][:FMatrix]
|
453
|
+
end
|
454
|
+
|
455
|
+
should 'use the shortest alias as main name' do
|
456
|
+
assert_equal 'Size', namespacecv_xml[:cv][:Size2i].name
|
457
|
+
end
|
458
|
+
|
459
|
+
should 'rename constructors to shortest name' do
|
460
|
+
assert_equal 'Size', namespacecv_xml[:cv][:Size].constructor.name
|
461
|
+
end
|
462
|
+
|
463
|
+
should 'parse arguments and evaluate types by resolving template params' do
|
464
|
+
size_class = namespacecv_xml[:cv][:Size]
|
465
|
+
Dub::Lua.bind(size_class)
|
466
|
+
assert_match %r{const Point \*pt}, size_class.constructor[5].to_s
|
467
|
+
end
|
468
|
+
|
469
|
+
context 'bound to a generator' do
|
470
|
+
setup do
|
471
|
+
Dub::Lua.bind(@class)
|
472
|
+
end
|
473
|
+
|
474
|
+
should 'register all alias_names' do
|
475
|
+
result = @class.to_s
|
476
|
+
assert_match %r{"FloatMat"\s*,\s*FMatrix_FMatrix}, result
|
477
|
+
assert_match %r{"FMatrix"\s*,\s*FMatrix_FMatrix}, result
|
478
|
+
assert_match %r{luaL_register\(L,\s*"dub".*FMatrix_namespace_methods}, result
|
479
|
+
end
|
480
|
+
|
481
|
+
should 'use the smallest name in method definition' do
|
482
|
+
assert_match %r{int FMatrix_FMatrix}, @class.to_s
|
483
|
+
end
|
484
|
+
end
|
485
|
+
end
|
486
|
+
|
487
|
+
context 'A class with overloaded methods' do
|
488
|
+
setup do
|
489
|
+
# namespacecv_xml = Dub.parse(fixture('app/xml/namespacedub.xml'))
|
490
|
+
@class = namespacecv_xml[:cv][:Mat]
|
491
|
+
Dub::Lua.bind(@class)
|
492
|
+
end
|
493
|
+
|
494
|
+
should 'declare chooser' do
|
495
|
+
result = @class.gen.method_registration(@class)
|
496
|
+
assert_match %r{"diag"\s*,\s*Mat_diag\}}, result
|
497
|
+
assert_no_match %r{diag1}, result
|
498
|
+
end
|
499
|
+
end
|
500
|
+
|
501
|
+
context 'A class with overloaded static methods' do
|
502
|
+
setup do
|
503
|
+
# namespacecv_xml = Dub.parse(fixture('app/xml/namespacedub.xml'))
|
504
|
+
@class = namespacecv_xml[:cv][:Mat]
|
505
|
+
Dub::Lua.bind(@class)
|
506
|
+
end
|
507
|
+
|
508
|
+
should 'declare chooser' do
|
509
|
+
result = @class.gen.namespace_methods_registration(@class)
|
510
|
+
assert_match %r{"Mat_zeros"\s*,\s*Mat_zeros\}}, result
|
511
|
+
assert_no_match %r{zeros1}, result
|
512
|
+
end
|
513
|
+
end
|
514
|
+
|
515
|
+
context 'A complex class' do
|
516
|
+
setup do
|
517
|
+
# namespacecv_xml = Dub.parse(fixture('app/xml/namespacedub.xml'))
|
518
|
+
@class = namespacecv_xml[:cv][:Mat]
|
519
|
+
end
|
520
|
+
|
521
|
+
context 'bound to a generator' do
|
522
|
+
setup do
|
523
|
+
Dub::Lua.bind(@class)
|
524
|
+
end
|
525
|
+
|
526
|
+
should 'list all members on members' do
|
527
|
+
assert_equal %w{addref adjustROI assignTo channels clone col colRange convertTo copyTo create cross depth diag dot elemSize elemSize1 empty eye isContinuous locateROI ones release reshape row rowRange setTo size step1 type zeros}, @class.members.map(&:name)
|
528
|
+
end
|
529
|
+
end
|
530
|
+
end
|
531
|
+
|
532
|
+
context 'A class with enums' do
|
533
|
+
setup do
|
534
|
+
# namespacecv_xml = Dub.parse(fixture('app/xml/namespacedub.xml'))
|
535
|
+
@class = namespacecv_xml[:cv][:Mat]
|
536
|
+
end
|
537
|
+
|
538
|
+
should 'respond true to has_enums' do
|
539
|
+
assert @class.has_constants?
|
540
|
+
end
|
541
|
+
|
542
|
+
should 'produce namespaced declarations' do
|
543
|
+
assert_match %r{\{"AUTO_STEP"\s*,\s*cv::Mat::AUTO_STEP\}}, Dub::Lua.class_generator.constants_registration(@class)
|
544
|
+
end
|
545
|
+
|
546
|
+
should 'find a list of enums' do
|
547
|
+
assert_equal %w{MAGIC_VAL AUTO_STEP CONTINUOUS_FLAG}, @class.enums
|
548
|
+
end
|
549
|
+
end
|
550
|
+
|
551
|
+
end
|