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
@@ -0,0 +1,128 @@
|
|
1
|
+
require 'dub/function'
|
2
|
+
require 'dub/function_group'
|
3
|
+
require 'dub/klass'
|
4
|
+
|
5
|
+
module Dub
|
6
|
+
class Klass
|
7
|
+
end
|
8
|
+
|
9
|
+
# This module is used by Namespace and Klass to extract member functions
|
10
|
+
module MemberExtraction
|
11
|
+
def members_prefix
|
12
|
+
@name
|
13
|
+
end
|
14
|
+
|
15
|
+
def parse_members
|
16
|
+
@members_hash = {}
|
17
|
+
@t_members_hash = {}
|
18
|
+
# TODO: template functions
|
19
|
+
(@xml/'memberdef').each do |member|
|
20
|
+
Dub.logger.info "Parsing #{(member/'name').innerHTML}"
|
21
|
+
name = (member/"name").innerHTML
|
22
|
+
if (member/'templateparamlist').first
|
23
|
+
insert_member(member, name, @t_members_hash)
|
24
|
+
else
|
25
|
+
insert_member(member, name, @members_hash)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def insert_member(member, name, destination)
|
31
|
+
if destination[name].kind_of?(Array)
|
32
|
+
destination[name] << member
|
33
|
+
elsif first_member = destination[name]
|
34
|
+
destination[name] = [first_member, member]
|
35
|
+
else
|
36
|
+
destination[name] = member
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def member(name)
|
41
|
+
get_member(name.to_s, @members_hash)
|
42
|
+
end
|
43
|
+
|
44
|
+
def members(ignore_list = [])
|
45
|
+
@members ||= begin
|
46
|
+
list = []
|
47
|
+
@members_hash.each do |name, member|
|
48
|
+
next if ignore_list.include?(name)
|
49
|
+
list << get_member(name)
|
50
|
+
end
|
51
|
+
list.compact!
|
52
|
+
list.sort
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def template_method(name)
|
57
|
+
get_member(name.to_s, @t_members_hash)
|
58
|
+
end
|
59
|
+
|
60
|
+
# Lazy construction of members
|
61
|
+
def get_member(name, source = @members_hash)
|
62
|
+
if member_or_group = source[name]
|
63
|
+
if member_or_group.kind_of?(Array)
|
64
|
+
if member_or_group.first.kind_of?(Hpricot::Elem)
|
65
|
+
list = []
|
66
|
+
member_or_group.each do |m|
|
67
|
+
list << make_member(name, m)
|
68
|
+
end
|
69
|
+
list.compact!
|
70
|
+
if list == []
|
71
|
+
member_or_group = nil
|
72
|
+
elsif list.size == 1
|
73
|
+
member_or_group = list.first
|
74
|
+
else
|
75
|
+
member_or_group = Dub::FunctionGroup.new(self)
|
76
|
+
# set overloaded_index
|
77
|
+
list.each_with_index do |m, i|
|
78
|
+
m.overloaded_index = i + 1
|
79
|
+
member_or_group << m
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
elsif member_or_group.kind_of?(Hpricot::Elem)
|
84
|
+
source[name] = member_or_group = make_member(name, member_or_group)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
member_or_group
|
88
|
+
end
|
89
|
+
|
90
|
+
def make_member(name, member)
|
91
|
+
member = case member[:kind]
|
92
|
+
when 'function', 'slot'
|
93
|
+
Dub.logger.info "Building #{members_prefix}::#{name}"
|
94
|
+
Function.new(self, name, member, members_prefix)
|
95
|
+
when 'class'
|
96
|
+
Dub.logger.info "Building #{members_prefix}::#{name}"
|
97
|
+
Klass.new(self, name, member, members_prefix)
|
98
|
+
else
|
99
|
+
# not supported: ignore
|
100
|
+
return nil
|
101
|
+
end
|
102
|
+
|
103
|
+
ignore_member?(member) ? nil : member
|
104
|
+
end
|
105
|
+
|
106
|
+
def ignore_member?(member)
|
107
|
+
return false if member.kind_of?(Klass)
|
108
|
+
|
109
|
+
if !member.public? ||
|
110
|
+
member.name =~ /^~/ || # do not build constructor
|
111
|
+
member.name =~ /^operator/ || # no conversion operators
|
112
|
+
member.has_complex_arguments? || # no complex arguments or return values
|
113
|
+
member.has_array_arguments? ||
|
114
|
+
member.vararg? ||
|
115
|
+
member.original_signature =~ /void\s+\*/ # used to detect return value and parameters
|
116
|
+
true # ignore
|
117
|
+
elsif return_value = member.return_value
|
118
|
+
if return_value.create_type == 'const char *'
|
119
|
+
return false # do not ignore
|
120
|
+
end
|
121
|
+
return_value.type =~ />$/ || # no complex return types
|
122
|
+
(return_value.is_native? && member.return_value.is_pointer?)
|
123
|
+
else
|
124
|
+
false # ok, do not ignore
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end # Dub
|
@@ -0,0 +1,295 @@
|
|
1
|
+
require 'dub/member_extraction'
|
2
|
+
|
3
|
+
module Dub
|
4
|
+
|
5
|
+
class Namespace
|
6
|
+
@@namespaces = {}
|
7
|
+
|
8
|
+
def self.find(name)
|
9
|
+
@@namespaces[name]
|
10
|
+
end
|
11
|
+
|
12
|
+
include MemberExtraction
|
13
|
+
attr_accessor :name, :gen, :xml, :enums, :parent, :header, :prefix, :defines
|
14
|
+
|
15
|
+
def initialize(name, xml, current_dir)
|
16
|
+
@@namespaces[name] = self
|
17
|
+
@name, @xml, @current_dir = name, xml, current_dir
|
18
|
+
@class_alias = {}
|
19
|
+
@alias_names = []
|
20
|
+
@enums = []
|
21
|
+
@defines = []
|
22
|
+
@ignores = []
|
23
|
+
parse_xml
|
24
|
+
end
|
25
|
+
|
26
|
+
def bind(generator)
|
27
|
+
self.gen = generator.namespace_generator
|
28
|
+
end
|
29
|
+
|
30
|
+
def gen=(generator)
|
31
|
+
@gen = generator
|
32
|
+
@gen_members = nil
|
33
|
+
end
|
34
|
+
|
35
|
+
def generator
|
36
|
+
@gen
|
37
|
+
end
|
38
|
+
|
39
|
+
def class_generator
|
40
|
+
@gen && @gen.class_generator
|
41
|
+
end
|
42
|
+
|
43
|
+
def function_generator
|
44
|
+
@gen && @gen.function_generator
|
45
|
+
end
|
46
|
+
|
47
|
+
alias gen generator
|
48
|
+
|
49
|
+
def to_s
|
50
|
+
@gen.namespace(self)
|
51
|
+
end
|
52
|
+
|
53
|
+
def merge!(group)
|
54
|
+
raise "Can only merge with a Group" unless group.kind_of?(Group)
|
55
|
+
@defines += group.defines
|
56
|
+
@enums += group.enums
|
57
|
+
|
58
|
+
# TODO: do we need to merge classes and members ? I don't think so (they should be in namespace).
|
59
|
+
end
|
60
|
+
|
61
|
+
def ignore(list)
|
62
|
+
list = [list].flatten
|
63
|
+
@ignores += list
|
64
|
+
self.classes.reject! {|k| list.include?(k.name) }
|
65
|
+
@ignores.uniq!
|
66
|
+
@gen_members = nil
|
67
|
+
end
|
68
|
+
|
69
|
+
def full_type
|
70
|
+
@parent ? "#{@parent.full_type}::#{name}" : name
|
71
|
+
end
|
72
|
+
|
73
|
+
def lib_name
|
74
|
+
@lib_name || (prefix ? "#{prefix}_#{name}" : name)
|
75
|
+
end
|
76
|
+
|
77
|
+
# FIXME: test
|
78
|
+
def lib_name=(name)
|
79
|
+
@lib_name = name
|
80
|
+
end
|
81
|
+
|
82
|
+
def id_name(name = self.name)
|
83
|
+
prefix ? "#{prefix}.#{name}" : name
|
84
|
+
end
|
85
|
+
|
86
|
+
def header
|
87
|
+
@header ||= (@xml/'location').first.attributes['file'].split('/').last
|
88
|
+
end
|
89
|
+
|
90
|
+
def [](name)
|
91
|
+
get_member(name.to_s) || klass(name.to_s)
|
92
|
+
end
|
93
|
+
|
94
|
+
def function(name)
|
95
|
+
member = get_member(name.to_s)
|
96
|
+
member.kind_of?(Function) ? member : nil
|
97
|
+
end
|
98
|
+
|
99
|
+
def klass(name)
|
100
|
+
get_class(name.to_s, @classes_hash) || get_alias(name.to_s)
|
101
|
+
end
|
102
|
+
|
103
|
+
def template_class(name)
|
104
|
+
get_class(name.to_s, @t_classes_hash)
|
105
|
+
end
|
106
|
+
|
107
|
+
def classes
|
108
|
+
@classes ||= begin
|
109
|
+
list = []
|
110
|
+
@classes_hash.each do |name, member|
|
111
|
+
list << get_class(name, @classes_hash)
|
112
|
+
end
|
113
|
+
list.compact!
|
114
|
+
list.sort
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def members
|
119
|
+
list = super(@ignores)
|
120
|
+
if self.generator
|
121
|
+
@gen_members ||= self.generator.members_list(list)
|
122
|
+
else
|
123
|
+
list
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def has_constants?
|
128
|
+
has_enums? || has_defines?
|
129
|
+
end
|
130
|
+
|
131
|
+
# FIXME: test
|
132
|
+
def has_functions?
|
133
|
+
members && members != []
|
134
|
+
end
|
135
|
+
|
136
|
+
def has_enums?
|
137
|
+
!@enums.empty?
|
138
|
+
end
|
139
|
+
|
140
|
+
def has_defines?
|
141
|
+
!@defines.empty?
|
142
|
+
end
|
143
|
+
|
144
|
+
def register_alias(name, klass)
|
145
|
+
@class_alias[name] = klass
|
146
|
+
end
|
147
|
+
|
148
|
+
private
|
149
|
+
def parse_xml
|
150
|
+
parse_enums
|
151
|
+
parse_members
|
152
|
+
parse_classes
|
153
|
+
end
|
154
|
+
|
155
|
+
def parse_enums
|
156
|
+
@enums = (@xml/"enumvalue/name").map{|e| e.innerHTML}
|
157
|
+
end
|
158
|
+
|
159
|
+
# We do not run this by default but use groups to make sure we do
|
160
|
+
# not cluter namespace
|
161
|
+
def parse_defines
|
162
|
+
@defines = (@xml/"memberdef[@kind=define]").map do |e|
|
163
|
+
if (e/'param').first
|
164
|
+
nil
|
165
|
+
else
|
166
|
+
(e/'name').innerHTML
|
167
|
+
end
|
168
|
+
end.compact
|
169
|
+
end
|
170
|
+
|
171
|
+
def parse_classes
|
172
|
+
@classes_hash = {}
|
173
|
+
@t_classes_hash = {}
|
174
|
+
@classes_by_ref = {}
|
175
|
+
(@xml/'innerclass').each do |klass|
|
176
|
+
name = klass.innerHTML
|
177
|
+
Dub.logger.info "Parsing #{name}"
|
178
|
+
if name =~ /^#{@name}::(.+)$/
|
179
|
+
name = $1
|
180
|
+
end
|
181
|
+
filename = klass.attributes['refid']
|
182
|
+
filepath = File.join(@current_dir, "#{filename}.xml")
|
183
|
+
if File.exist?(filepath)
|
184
|
+
class_xml = (Hpricot::XML(File.read(filepath))/'compounddef').first
|
185
|
+
if (class_xml/'/templateparamlist/param').innerHTML != ''
|
186
|
+
@t_classes_hash[name] = class_xml
|
187
|
+
else
|
188
|
+
@classes_hash[name] = class_xml
|
189
|
+
end
|
190
|
+
@classes_by_ref[class_xml[:id]] = class_xml
|
191
|
+
else
|
192
|
+
Dub.logger.warn "Could not open #{filepath}"
|
193
|
+
nil
|
194
|
+
end
|
195
|
+
end
|
196
|
+
parse_template_class_typedefs
|
197
|
+
end
|
198
|
+
|
199
|
+
def parse_template_class_typedefs
|
200
|
+
(@xml/'memberdef[@kind=typedef]').each do |typedef_xml|
|
201
|
+
# <type><ref refid="classdoxy_1_1_t_mat" kindref="compound">TMat</ref>< float ></type>
|
202
|
+
if id = (typedef_xml/'/type/ref').first
|
203
|
+
id = id[:refid]
|
204
|
+
end
|
205
|
+
|
206
|
+
new_name = (typedef_xml/'name').innerHTML
|
207
|
+
|
208
|
+
if ref_class = @classes_by_ref[id]
|
209
|
+
if (typedef_xml/'/type').innerHTML =~ />$/
|
210
|
+
|
211
|
+
# nested template types, too hard for us, ignore
|
212
|
+
next if (typedef_xml/'/type').innerHTML =~ />\s+>/
|
213
|
+
|
214
|
+
# template typedef
|
215
|
+
old_name = (ref_class/'/compoundname').first.innerHTML.gsub(/^.*::/,'')
|
216
|
+
|
217
|
+
# replace class name
|
218
|
+
# <type><ref refid="classcv_1_1_scalar__" kindref="compound">Scalar_</ref>< _Tp ></type>
|
219
|
+
class_def = ref_class.to_s.gsub(/<ref .*>#{old_name}<\/ref><.*?>/, new_name)
|
220
|
+
class_def = class_def.gsub(/#{old_name}/, new_name)
|
221
|
+
|
222
|
+
# replace template types
|
223
|
+
# get template parameters
|
224
|
+
ttypes = (ref_class/'/templateparamlist/param').map do |param|
|
225
|
+
if type = (param/'declname').first
|
226
|
+
type.innerHTML
|
227
|
+
else
|
228
|
+
(param/'type').innerHTML.gsub(/^\s*(typename|class)\s+/,'')
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
types_map = {}
|
233
|
+
instanciations_params = []
|
234
|
+
(typedef_xml/'/type').innerHTML[/<\s*(.+?)\s*>$/,1].split(',').map(&:strip).each_with_index do |type, i|
|
235
|
+
instanciations_params << type
|
236
|
+
types_map[ttypes[i]] = type
|
237
|
+
end
|
238
|
+
|
239
|
+
class_xml = (Hpricot::XML(class_def)/'compounddef').first
|
240
|
+
|
241
|
+
(class_xml/'*[@prot=private]').remove
|
242
|
+
(class_xml/'/templateparamlist').remove
|
243
|
+
(class_xml/'').append("<originaltemplate>#{old_name}</originaltemplate>")
|
244
|
+
(ref_class/'').append("<instanciation><name>#{new_name}</name><param>#{instanciations_params.join('</param><param>')}</param></instanciation>")
|
245
|
+
|
246
|
+
types_map.each do |template_type, real_type|
|
247
|
+
(class_xml/'type').each do |t|
|
248
|
+
t.swap(t.to_s.gsub(template_type, real_type))
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
@classes_hash[new_name] = class_xml
|
253
|
+
else
|
254
|
+
# alias
|
255
|
+
original_name = (typedef_xml/'/type/ref').innerHTML
|
256
|
+
if class_xml = @classes_hash[original_name]
|
257
|
+
@alias_names << new_name
|
258
|
+
if (class_xml/'/aliases').first
|
259
|
+
(class_xml/'/aliases').append("<name>#{new_name}</name>")
|
260
|
+
else
|
261
|
+
(class_xml/'').append("<aliases><name>#{new_name}</name></aliases>")
|
262
|
+
end
|
263
|
+
else
|
264
|
+
Dub.logger.warn "Could not find original class #{original_name}"
|
265
|
+
end
|
266
|
+
end
|
267
|
+
else
|
268
|
+
Dub.logger.warn "Could not find reference class #{id}"
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
def get_class(name, source)
|
274
|
+
if klass = source[name]
|
275
|
+
if klass.kind_of?(Hpricot::Elem)
|
276
|
+
klass = source[name] = make_member(name, klass)
|
277
|
+
end
|
278
|
+
end
|
279
|
+
klass
|
280
|
+
end
|
281
|
+
|
282
|
+
def get_alias(name)
|
283
|
+
if klass = @class_alias[name]
|
284
|
+
return klass
|
285
|
+
elsif @classes || !@alias_names.include?(name)
|
286
|
+
# classes parsed, alias does not exist
|
287
|
+
nil
|
288
|
+
else
|
289
|
+
# we need to parse all classes so they register the alias
|
290
|
+
self.classes
|
291
|
+
@class_alias[name]
|
292
|
+
end
|
293
|
+
end
|
294
|
+
end
|
295
|
+
end # Namespace
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Dub
|
2
|
+
module OptsParser
|
3
|
+
ENTRY_REGEXP = %r{^\s*([^:]+):\s*('[^']*'|"[^"]*")\s*,?\s*}m
|
4
|
+
def self.extract_hash(xml)
|
5
|
+
(xml/'simplesect').each do |x|
|
6
|
+
if (x/'title').inner_html == 'Bindings info:'
|
7
|
+
(x/'title').remove()
|
8
|
+
(x/'ref').each do |r|
|
9
|
+
r.swap(r.inner_html)
|
10
|
+
end
|
11
|
+
code = EntitiesUnescape::Decoder.decode((x/'para').inner_html)
|
12
|
+
return self.parse(code)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
nil
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.parse(src)
|
19
|
+
res = {}
|
20
|
+
while !src.empty? && src =~ ENTRY_REGEXP
|
21
|
+
src = src.sub(ENTRY_REGEXP) do
|
22
|
+
res[$1.to_sym] = $2[1..-2]
|
23
|
+
''
|
24
|
+
end
|
25
|
+
end
|
26
|
+
res
|
27
|
+
end
|
28
|
+
end # OptsParser
|
29
|
+
end # Dub
|
30
|
+
|
data/lib/dub/parser.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'hpricot'
|
3
|
+
require 'dub/namespace'
|
4
|
+
|
5
|
+
module Dub
|
6
|
+
class Parser
|
7
|
+
def initialize(filepath)
|
8
|
+
@current_dir = File.dirname(filepath)
|
9
|
+
@xml = Hpricot::XML(File.read(filepath))
|
10
|
+
end
|
11
|
+
|
12
|
+
def [](name)
|
13
|
+
namespaces[name.to_s] || groups[name.to_s]
|
14
|
+
end
|
15
|
+
|
16
|
+
def namespace(name)
|
17
|
+
namespaces[name.to_s]
|
18
|
+
end
|
19
|
+
|
20
|
+
def group(name)
|
21
|
+
groups[name.to_s]
|
22
|
+
end
|
23
|
+
|
24
|
+
def namespaces
|
25
|
+
@namespaces ||= begin
|
26
|
+
ns = {}
|
27
|
+
(@xml/'compounddef[@kind=namespace]').each do |namespace|
|
28
|
+
name = (namespace/"compoundname").innerHTML
|
29
|
+
ns[name] = Dub::Namespace.new(name, namespace, @current_dir)
|
30
|
+
end
|
31
|
+
ns
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def groups
|
36
|
+
@groups ||= begin
|
37
|
+
groups = {}
|
38
|
+
(@xml/'compounddef[@kind=group]').each do |namespace|
|
39
|
+
name = (namespace/"compoundname").innerHTML
|
40
|
+
groups[name] = Dub::Group.new(name, namespace, @current_dir)
|
41
|
+
end
|
42
|
+
groups
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end # Parser
|
46
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
static bool is_userdata(lua_State *L, int index, const char *tname) {
|
3
|
+
void *p = lua_touserdata(L, index);
|
4
|
+
if (p != NULL) { /* value is a userdata? */
|
5
|
+
if (lua_getmetatable(L, index)) { /* does it have a metatable? */
|
6
|
+
lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */
|
7
|
+
if (lua_rawequal(L, -1, -2)) { /* does it have the correct mt? */
|
8
|
+
lua_pop(L, 2); /* remove both metatables */
|
9
|
+
// type match
|
10
|
+
return true;
|
11
|
+
}
|
12
|
+
}
|
13
|
+
}
|
14
|
+
// type does not match
|
15
|
+
return false;
|
16
|
+
}
|
17
|
+
|
18
|
+
<%= @bindings %>
|
19
|
+
|
20
|
+
<%= @init_code %>
|
21
|
+
|
data/lib/dub/version.rb
ADDED
data/lib/dub.rb
CHANGED
@@ -1,23 +1,27 @@
|
|
1
|
-
|
1
|
+
require 'dub/entities_unescape'
|
2
|
+
require 'dub/parser'
|
3
|
+
require 'dub/namespace'
|
4
|
+
require 'dub/group'
|
5
|
+
require 'dub/klass'
|
6
|
+
require 'dub/function'
|
7
|
+
require 'dub/argument'
|
8
|
+
require 'logger'
|
9
|
+
require 'dub/opts_parser'
|
2
10
|
|
3
|
-
|
4
|
-
|
11
|
+
module Dub
|
12
|
+
def self.logger=(logger)
|
13
|
+
@@logger = logger
|
14
|
+
end
|
5
15
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
autoload :Workspaces, 'open_api_sdk/workspaces'
|
14
|
-
autoload :Tags, 'open_api_sdk/tags'
|
15
|
-
autoload :Domains, 'open_api_sdk/domains'
|
16
|
-
autoload :Track, 'open_api_sdk/track'
|
17
|
-
autoload :Metatags, 'open_api_sdk/metatags'
|
18
|
-
end
|
16
|
+
def self.logger
|
17
|
+
@@logger ||= begin
|
18
|
+
logger = Logger.new(STDERR)
|
19
|
+
logger.level == Logger::INFO
|
20
|
+
logger
|
21
|
+
end
|
22
|
+
end
|
19
23
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
+
def self.parse(filename)
|
25
|
+
Dub::Parser.new(filename)
|
26
|
+
end
|
27
|
+
end
|