dub 0.3.0 → 0.6.6
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 +53 -0
- data/LICENSE +20 -0
- data/README.rdoc +67 -0
- data/Rakefile +59 -0
- data/dub.gemspec +201 -0
- data/lib/dub/argument.rb +275 -0
- data/lib/dub/entities_unescape.rb +9 -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 +255 -0
- data/lib/dub/lua/class.cpp.erb +84 -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 +265 -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/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 -24
- 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 +162 -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 +341 -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 +48 -0
- data/test/fixtures/app/xml/index.xsd +66 -0
- data/test/fixtures/app/xml/matrix_8h.xml +179 -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 +422 -0
- data/test/lua_function_gen_test.rb +215 -0
- data/test/namespace_test.rb +220 -0
- data/test/parser_test.rb +36 -0
- metadata +232 -457
- checksums.yaml +0 -7
- data/lib/crystalline/metadata_fields.rb +0 -163
- data/lib/crystalline/t.rb +0 -59
- data/lib/crystalline/utils.rb +0 -65
- data/lib/crystalline.rb +0 -12
- data/lib/open_api_sdk/analytics.rb +0 -154
- data/lib/open_api_sdk/commissions.rb +0 -298
- data/lib/open_api_sdk/customers.rb +0 -709
- data/lib/open_api_sdk/domains.rb +0 -839
- data/lib/open_api_sdk/dub.rb +0 -99
- data/lib/open_api_sdk/embed_tokens.rb +0 -163
- data/lib/open_api_sdk/events.rb +0 -154
- data/lib/open_api_sdk/folders.rb +0 -570
- data/lib/open_api_sdk/links.rb +0 -1377
- data/lib/open_api_sdk/models/operations/accesslevel.rb +0 -18
- data/lib/open_api_sdk/models/operations/bulkcreatelinks_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/bulkcreatelinks_testvariants.rb +0 -27
- data/lib/open_api_sdk/models/operations/bulkdeletelinks_request.rb +0 -24
- data/lib/open_api_sdk/models/operations/bulkdeletelinks_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/bulkdeletelinks_responsebody.rb +0 -24
- data/lib/open_api_sdk/models/operations/bulkupdatelinks_requestbody.rb +0 -30
- data/lib/open_api_sdk/models/operations/bulkupdatelinks_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/bulkupdatelinks_testvariants.rb +0 -27
- data/lib/open_api_sdk/models/operations/checkdomainstatus_request.rb +0 -24
- data/lib/open_api_sdk/models/operations/checkdomainstatus_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/click.rb +0 -24
- data/lib/open_api_sdk/models/operations/color.rb +0 -23
- data/lib/open_api_sdk/models/operations/country.rb +0 -266
- data/lib/open_api_sdk/models/operations/createcustomer_discount.rb +0 -48
- data/lib/open_api_sdk/models/operations/createcustomer_link.rb +0 -39
- data/lib/open_api_sdk/models/operations/createcustomer_partner.rb +0 -33
- data/lib/open_api_sdk/models/operations/createcustomer_requestbody.rb +0 -33
- data/lib/open_api_sdk/models/operations/createcustomer_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/createcustomer_responsebody.rb +0 -60
- data/lib/open_api_sdk/models/operations/createcustomer_type.rb +0 -18
- data/lib/open_api_sdk/models/operations/createdomain_requestbody.rb +0 -45
- data/lib/open_api_sdk/models/operations/createdomain_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/createfolder_requestbody.rb +0 -27
- data/lib/open_api_sdk/models/operations/createfolder_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/createlink_requestbody.rb +0 -145
- data/lib/open_api_sdk/models/operations/createlink_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/createpartner_link.rb +0 -48
- data/lib/open_api_sdk/models/operations/createpartner_requestbody.rb +0 -45
- data/lib/open_api_sdk/models/operations/createpartner_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/createpartner_responsebody.rb +0 -104
- data/lib/open_api_sdk/models/operations/createpartner_status.rb +0 -23
- data/lib/open_api_sdk/models/operations/createpartner_testvariants.rb +0 -27
- data/lib/open_api_sdk/models/operations/createpartnerlink_linkprops.rb +0 -111
- data/lib/open_api_sdk/models/operations/createpartnerlink_requestbody.rb +0 -39
- data/lib/open_api_sdk/models/operations/createpartnerlink_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/createpartnerlink_testvariants.rb +0 -27
- data/lib/open_api_sdk/models/operations/createreferralsembedtoken_country.rb +0 -266
- data/lib/open_api_sdk/models/operations/createreferralsembedtoken_linkprops.rb +0 -111
- data/lib/open_api_sdk/models/operations/createreferralsembedtoken_requestbody.rb +0 -30
- data/lib/open_api_sdk/models/operations/createreferralsembedtoken_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/createreferralsembedtoken_responsebody.rb +0 -27
- data/lib/open_api_sdk/models/operations/createreferralsembedtoken_testvariants.rb +0 -27
- 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/customer.rb +0 -33
- data/lib/open_api_sdk/models/operations/data.rb +0 -130
- data/lib/open_api_sdk/models/operations/deletecustomer_request.rb +0 -24
- data/lib/open_api_sdk/models/operations/deletecustomer_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/deletecustomer_responsebody.rb +0 -24
- 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/deletefolder_request.rb +0 -24
- data/lib/open_api_sdk/models/operations/deletefolder_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/deletefolder_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/deletetag_request.rb +0 -24
- data/lib/open_api_sdk/models/operations/deletetag_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/deletetag_responsebody.rb +0 -24
- data/lib/open_api_sdk/models/operations/discount.rb +0 -48
- data/lib/open_api_sdk/models/operations/event.rb +0 -20
- data/lib/open_api_sdk/models/operations/getcustomer_discount.rb +0 -48
- data/lib/open_api_sdk/models/operations/getcustomer_link.rb +0 -39
- data/lib/open_api_sdk/models/operations/getcustomer_partner.rb +0 -33
- data/lib/open_api_sdk/models/operations/getcustomer_request.rb +0 -27
- data/lib/open_api_sdk/models/operations/getcustomer_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/getcustomer_responsebody.rb +0 -60
- data/lib/open_api_sdk/models/operations/getcustomer_type.rb +0 -18
- data/lib/open_api_sdk/models/operations/getcustomers_link.rb +0 -39
- data/lib/open_api_sdk/models/operations/getcustomers_partner.rb +0 -33
- data/lib/open_api_sdk/models/operations/getcustomers_queryparam_sortby.rb +0 -18
- data/lib/open_api_sdk/models/operations/getcustomers_queryparam_sortorder.rb +0 -18
- data/lib/open_api_sdk/models/operations/getcustomers_request.rb +0 -51
- data/lib/open_api_sdk/models/operations/getcustomers_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/getcustomers_responsebody.rb +0 -60
- data/lib/open_api_sdk/models/operations/getcustomers_type.rb +0 -18
- 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 -66
- data/lib/open_api_sdk/models/operations/getlinks_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/getlinkscount_request.rb +0 -54
- data/lib/open_api_sdk/models/operations/getlinkscount_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/getqrcode_request.rb +0 -48
- data/lib/open_api_sdk/models/operations/getqrcode_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/gettags_queryparam_sortby.rb +0 -18
- data/lib/open_api_sdk/models/operations/gettags_queryparam_sortorder.rb +0 -18
- data/lib/open_api_sdk/models/operations/gettags_request.rb +0 -39
- 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 -37
- data/lib/open_api_sdk/models/operations/interval.rb +0 -25
- data/lib/open_api_sdk/models/operations/level.rb +0 -20
- data/lib/open_api_sdk/models/operations/link.rb +0 -48
- data/lib/open_api_sdk/models/operations/linkprops.rb +0 -111
- data/lib/open_api_sdk/models/operations/listcommissions_queryparam_interval.rb +0 -25
- data/lib/open_api_sdk/models/operations/listcommissions_queryparam_sortby.rb +0 -18
- data/lib/open_api_sdk/models/operations/listcommissions_queryparam_sortorder.rb +0 -18
- data/lib/open_api_sdk/models/operations/listcommissions_request.rb +0 -60
- data/lib/open_api_sdk/models/operations/listcommissions_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/listcommissions_responsebody.rb +0 -51
- data/lib/open_api_sdk/models/operations/listcommissions_status.rb +0 -23
- data/lib/open_api_sdk/models/operations/listcommissions_type.rb +0 -20
- data/lib/open_api_sdk/models/operations/listdomains_request.rb +0 -33
- data/lib/open_api_sdk/models/operations/listdomains_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/listevents_request.rb +0 -138
- data/lib/open_api_sdk/models/operations/listevents_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/listfolders_request.rb +0 -30
- data/lib/open_api_sdk/models/operations/listfolders_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/mode.rb +0 -18
- data/lib/open_api_sdk/models/operations/order.rb +0 -20
- data/lib/open_api_sdk/models/operations/partner.rb +0 -45
- data/lib/open_api_sdk/models/operations/paymentprocessor.rb +0 -21
- data/lib/open_api_sdk/models/operations/queryparam_event.rb +0 -19
- data/lib/open_api_sdk/models/operations/queryparam_groupby.rb +0 -19
- data/lib/open_api_sdk/models/operations/queryparam_interval.rb +0 -25
- data/lib/open_api_sdk/models/operations/queryparam_sortby.rb +0 -17
- data/lib/open_api_sdk/models/operations/queryparam_sortorder.rb +0 -18
- data/lib/open_api_sdk/models/operations/queryparam_status.rb +0 -23
- data/lib/open_api_sdk/models/operations/queryparam_trigger.rb +0 -18
- data/lib/open_api_sdk/models/operations/registerdomain_requestbody.rb +0 -24
- data/lib/open_api_sdk/models/operations/registerdomain_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/registerdomain_responsebody.rb +0 -30
- data/lib/open_api_sdk/models/operations/requestbody.rb +0 -145
- data/lib/open_api_sdk/models/operations/responsebody.rb +0 -33
- data/lib/open_api_sdk/models/operations/retrieveanalytics_request.rb +0 -126
- data/lib/open_api_sdk/models/operations/retrieveanalytics_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/retrievelinks_request.rb +0 -27
- data/lib/open_api_sdk/models/operations/retrievelinks_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/retrievepartneranalytics_queryparam_interval.rb +0 -25
- data/lib/open_api_sdk/models/operations/retrievepartneranalytics_request.rb +0 -42
- data/lib/open_api_sdk/models/operations/retrievepartneranalytics_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/sale.rb +0 -36
- data/lib/open_api_sdk/models/operations/sort.rb +0 -22
- data/lib/open_api_sdk/models/operations/sortby.rb +0 -20
- data/lib/open_api_sdk/models/operations/sortorder.rb +0 -18
- data/lib/open_api_sdk/models/operations/status.rb +0 -20
- data/lib/open_api_sdk/models/operations/testvariants.rb +0 -27
- data/lib/open_api_sdk/models/operations/tracklead_requestbody.rb +0 -48
- data/lib/open_api_sdk/models/operations/tracklead_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/tracklead_responsebody.rb +0 -27
- data/lib/open_api_sdk/models/operations/tracksale_customer.rb +0 -36
- data/lib/open_api_sdk/models/operations/tracksale_requestbody.rb +0 -45
- data/lib/open_api_sdk/models/operations/tracksale_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/tracksale_responsebody.rb +0 -30
- data/lib/open_api_sdk/models/operations/trigger.rb +0 -18
- data/lib/open_api_sdk/models/operations/type.rb +0 -20
- data/lib/open_api_sdk/models/operations/updatecommission_request.rb +0 -27
- data/lib/open_api_sdk/models/operations/updatecommission_requestbody.rb +0 -33
- data/lib/open_api_sdk/models/operations/updatecommission_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/updatecommission_responsebody.rb +0 -51
- data/lib/open_api_sdk/models/operations/updatecommission_status.rb +0 -23
- data/lib/open_api_sdk/models/operations/updatecommission_type.rb +0 -20
- data/lib/open_api_sdk/models/operations/updatecustomer_discount.rb +0 -48
- data/lib/open_api_sdk/models/operations/updatecustomer_link.rb +0 -39
- data/lib/open_api_sdk/models/operations/updatecustomer_partner.rb +0 -33
- data/lib/open_api_sdk/models/operations/updatecustomer_request.rb +0 -30
- data/lib/open_api_sdk/models/operations/updatecustomer_requestbody.rb +0 -33
- data/lib/open_api_sdk/models/operations/updatecustomer_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/updatecustomer_responsebody.rb +0 -60
- data/lib/open_api_sdk/models/operations/updatecustomer_type.rb +0 -18
- data/lib/open_api_sdk/models/operations/updatedomain_request.rb +0 -27
- data/lib/open_api_sdk/models/operations/updatedomain_requestbody.rb +0 -45
- data/lib/open_api_sdk/models/operations/updatedomain_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/updatefolder_accesslevel.rb +0 -18
- data/lib/open_api_sdk/models/operations/updatefolder_request.rb +0 -27
- data/lib/open_api_sdk/models/operations/updatefolder_requestbody.rb +0 -27
- data/lib/open_api_sdk/models/operations/updatefolder_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 -139
- data/lib/open_api_sdk/models/operations/updatelink_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/updatelink_testvariants.rb +0 -27
- data/lib/open_api_sdk/models/operations/updatetag_color.rb +0 -23
- 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 -36
- data/lib/open_api_sdk/models/operations/updateworkspace_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/upsertlink_requestbody.rb +0 -145
- data/lib/open_api_sdk/models/operations/upsertlink_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/upsertlink_testvariants.rb +0 -27
- data/lib/open_api_sdk/models/operations/upsertpartnerlink_linkprops.rb +0 -111
- data/lib/open_api_sdk/models/operations/upsertpartnerlink_requestbody.rb +0 -39
- data/lib/open_api_sdk/models/operations/upsertpartnerlink_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/upsertpartnerlink_testvariants.rb +0 -27
- data/lib/open_api_sdk/models/operations.rb +0 -198
- data/lib/open_api_sdk/models/shared/accesslevel.rb +0 -18
- data/lib/open_api_sdk/models/shared/badrequest.rb +0 -24
- data/lib/open_api_sdk/models/shared/code.rb +0 -17
- data/lib/open_api_sdk/models/shared/color.rb +0 -23
- data/lib/open_api_sdk/models/shared/conflict.rb +0 -24
- data/lib/open_api_sdk/models/shared/conflict_code.rb +0 -17
- data/lib/open_api_sdk/models/shared/conflict_error.rb +0 -30
- data/lib/open_api_sdk/models/shared/continentcode.rb +0 -23
- data/lib/open_api_sdk/models/shared/countrycode.rb +0 -266
- data/lib/open_api_sdk/models/shared/domains.rb +0 -30
- data/lib/open_api_sdk/models/shared/domainschema.rb +0 -63
- data/lib/open_api_sdk/models/shared/error.rb +0 -30
- data/lib/open_api_sdk/models/shared/folderschema.rb +0 -39
- data/lib/open_api_sdk/models/shared/forbidden.rb +0 -24
- data/lib/open_api_sdk/models/shared/forbidden_code.rb +0 -17
- 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 -17
- 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 -17
- 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 -172
- data/lib/open_api_sdk/models/shared/notfound.rb +0 -24
- data/lib/open_api_sdk/models/shared/notfound_code.rb +0 -17
- 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 -17
- data/lib/open_api_sdk/models/shared/ratelimitexceeded_error.rb +0 -30
- data/lib/open_api_sdk/models/shared/registereddomain.rb +0 -30
- data/lib/open_api_sdk/models/shared/role.rb +0 -18
- 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/testvariants.rb +0 -27
- data/lib/open_api_sdk/models/shared/type.rb +0 -18
- data/lib/open_api_sdk/models/shared/unauthorized.rb +0 -24
- data/lib/open_api_sdk/models/shared/unauthorized_code.rb +0 -17
- 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 -17
- data/lib/open_api_sdk/models/shared/unprocessableentity_error.rb +0 -30
- data/lib/open_api_sdk/models/shared/users.rb +0 -27
- data/lib/open_api_sdk/models/shared/workspaceschema.rb +0 -123
- data/lib/open_api_sdk/models/shared.rb +0 -55
- data/lib/open_api_sdk/partners.rb +0 -701
- data/lib/open_api_sdk/qr_codes.rb +0 -151
- data/lib/open_api_sdk/sdk_hooks/hooks.rb +0 -103
- data/lib/open_api_sdk/sdk_hooks/registration.rb +0 -35
- data/lib/open_api_sdk/sdk_hooks/types.rb +0 -152
- data/lib/open_api_sdk/sdkconfiguration.rb +0 -75
- data/lib/open_api_sdk/tags.rb +0 -570
- data/lib/open_api_sdk/track.rb +0 -302
- data/lib/open_api_sdk/utils/retries.rb +0 -95
- data/lib/open_api_sdk/utils/utils.rb +0 -738
- data/lib/open_api_sdk/workspaces.rb +0 -301
@@ -0,0 +1,711 @@
|
|
1
|
+
/*
|
2
|
+
** $Id: lgc.c,v 2.38 2006/05/24 14:34:06 roberto Exp $
|
3
|
+
** Garbage Collector
|
4
|
+
** See Copyright Notice in lua.h
|
5
|
+
*/
|
6
|
+
|
7
|
+
#include <string.h>
|
8
|
+
|
9
|
+
#define lgc_c
|
10
|
+
#define LUA_CORE
|
11
|
+
|
12
|
+
#include "lua.h"
|
13
|
+
|
14
|
+
#include "ldebug.h"
|
15
|
+
#include "ldo.h"
|
16
|
+
#include "lfunc.h"
|
17
|
+
#include "lgc.h"
|
18
|
+
#include "lmem.h"
|
19
|
+
#include "lobject.h"
|
20
|
+
#include "lstate.h"
|
21
|
+
#include "lstring.h"
|
22
|
+
#include "ltable.h"
|
23
|
+
#include "ltm.h"
|
24
|
+
|
25
|
+
|
26
|
+
#define GCSTEPSIZE 1024u
|
27
|
+
#define GCSWEEPMAX 40
|
28
|
+
#define GCSWEEPCOST 10
|
29
|
+
#define GCFINALIZECOST 100
|
30
|
+
|
31
|
+
|
32
|
+
#define maskmarks cast_byte(~(bitmask(BLACKBIT)|WHITEBITS))
|
33
|
+
|
34
|
+
#define makewhite(g,x) \
|
35
|
+
((x)->gch.marked = cast_byte(((x)->gch.marked & maskmarks) | luaC_white(g)))
|
36
|
+
|
37
|
+
#define white2gray(x) reset2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT)
|
38
|
+
#define black2gray(x) resetbit((x)->gch.marked, BLACKBIT)
|
39
|
+
|
40
|
+
#define stringmark(s) reset2bits((s)->tsv.marked, WHITE0BIT, WHITE1BIT)
|
41
|
+
|
42
|
+
|
43
|
+
#define isfinalized(u) testbit((u)->marked, FINALIZEDBIT)
|
44
|
+
#define markfinalized(u) l_setbit((u)->marked, FINALIZEDBIT)
|
45
|
+
|
46
|
+
|
47
|
+
#define KEYWEAK bitmask(KEYWEAKBIT)
|
48
|
+
#define VALUEWEAK bitmask(VALUEWEAKBIT)
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
#define markvalue(g,o) { checkconsistency(o); \
|
53
|
+
if (iscollectable(o) && iswhite(gcvalue(o))) reallymarkobject(g,gcvalue(o)); }
|
54
|
+
|
55
|
+
#define markobject(g,t) { if (iswhite(obj2gco(t))) \
|
56
|
+
reallymarkobject(g, obj2gco(t)); }
|
57
|
+
|
58
|
+
|
59
|
+
#define setthreshold(g) (g->GCthreshold = (g->estimate/100) * g->gcpause)
|
60
|
+
|
61
|
+
|
62
|
+
static void removeentry (Node *n) {
|
63
|
+
lua_assert(ttisnil(gval(n)));
|
64
|
+
if (iscollectable(gkey(n)))
|
65
|
+
setttype(gkey(n), LUA_TDEADKEY); /* dead key; remove it */
|
66
|
+
}
|
67
|
+
|
68
|
+
|
69
|
+
static void reallymarkobject (global_State *g, GCObject *o) {
|
70
|
+
lua_assert(iswhite(o) && !isdead(g, o));
|
71
|
+
white2gray(o);
|
72
|
+
switch (o->gch.tt) {
|
73
|
+
case LUA_TSTRING: {
|
74
|
+
return;
|
75
|
+
}
|
76
|
+
case LUA_TUSERDATA: {
|
77
|
+
Table *mt = gco2u(o)->metatable;
|
78
|
+
gray2black(o); /* udata are never gray */
|
79
|
+
if (mt) markobject(g, mt);
|
80
|
+
markobject(g, gco2u(o)->env);
|
81
|
+
return;
|
82
|
+
}
|
83
|
+
case LUA_TUPVAL: {
|
84
|
+
UpVal *uv = gco2uv(o);
|
85
|
+
markvalue(g, uv->v);
|
86
|
+
if (uv->v == &uv->u.value) /* closed? */
|
87
|
+
gray2black(o); /* open upvalues are never black */
|
88
|
+
return;
|
89
|
+
}
|
90
|
+
case LUA_TFUNCTION: {
|
91
|
+
gco2cl(o)->c.gclist = g->gray;
|
92
|
+
g->gray = o;
|
93
|
+
break;
|
94
|
+
}
|
95
|
+
case LUA_TTABLE: {
|
96
|
+
gco2h(o)->gclist = g->gray;
|
97
|
+
g->gray = o;
|
98
|
+
break;
|
99
|
+
}
|
100
|
+
case LUA_TTHREAD: {
|
101
|
+
gco2th(o)->gclist = g->gray;
|
102
|
+
g->gray = o;
|
103
|
+
break;
|
104
|
+
}
|
105
|
+
case LUA_TPROTO: {
|
106
|
+
gco2p(o)->gclist = g->gray;
|
107
|
+
g->gray = o;
|
108
|
+
break;
|
109
|
+
}
|
110
|
+
default: lua_assert(0);
|
111
|
+
}
|
112
|
+
}
|
113
|
+
|
114
|
+
|
115
|
+
static void marktmu (global_State *g) {
|
116
|
+
GCObject *u = g->tmudata;
|
117
|
+
if (u) {
|
118
|
+
do {
|
119
|
+
u = u->gch.next;
|
120
|
+
makewhite(g, u); /* may be marked, if left from previous GC */
|
121
|
+
reallymarkobject(g, u);
|
122
|
+
} while (u != g->tmudata);
|
123
|
+
}
|
124
|
+
}
|
125
|
+
|
126
|
+
|
127
|
+
/* move `dead' udata that need finalization to list `tmudata' */
|
128
|
+
size_t luaC_separateudata (lua_State *L, int all) {
|
129
|
+
global_State *g = G(L);
|
130
|
+
size_t deadmem = 0;
|
131
|
+
GCObject **p = &g->mainthread->next;
|
132
|
+
GCObject *curr;
|
133
|
+
while ((curr = *p) != NULL) {
|
134
|
+
if (!(iswhite(curr) || all) || isfinalized(gco2u(curr)))
|
135
|
+
p = &curr->gch.next; /* don't bother with them */
|
136
|
+
else if (fasttm(L, gco2u(curr)->metatable, TM_GC) == NULL) {
|
137
|
+
markfinalized(gco2u(curr)); /* don't need finalization */
|
138
|
+
p = &curr->gch.next;
|
139
|
+
}
|
140
|
+
else { /* must call its gc method */
|
141
|
+
deadmem += sizeudata(gco2u(curr));
|
142
|
+
markfinalized(gco2u(curr));
|
143
|
+
*p = curr->gch.next;
|
144
|
+
/* link `curr' at the end of `tmudata' list */
|
145
|
+
if (g->tmudata == NULL) /* list is empty? */
|
146
|
+
g->tmudata = curr->gch.next = curr; /* creates a circular list */
|
147
|
+
else {
|
148
|
+
curr->gch.next = g->tmudata->gch.next;
|
149
|
+
g->tmudata->gch.next = curr;
|
150
|
+
g->tmudata = curr;
|
151
|
+
}
|
152
|
+
}
|
153
|
+
}
|
154
|
+
return deadmem;
|
155
|
+
}
|
156
|
+
|
157
|
+
|
158
|
+
static int traversetable (global_State *g, Table *h) {
|
159
|
+
int i;
|
160
|
+
int weakkey = 0;
|
161
|
+
int weakvalue = 0;
|
162
|
+
const TValue *mode;
|
163
|
+
if (h->metatable)
|
164
|
+
markobject(g, h->metatable);
|
165
|
+
mode = gfasttm(g, h->metatable, TM_MODE);
|
166
|
+
if (mode && ttisstring(mode)) { /* is there a weak mode? */
|
167
|
+
weakkey = (strchr(svalue(mode), 'k') != NULL);
|
168
|
+
weakvalue = (strchr(svalue(mode), 'v') != NULL);
|
169
|
+
if (weakkey || weakvalue) { /* is really weak? */
|
170
|
+
h->marked &= ~(KEYWEAK | VALUEWEAK); /* clear bits */
|
171
|
+
h->marked |= cast_byte((weakkey << KEYWEAKBIT) |
|
172
|
+
(weakvalue << VALUEWEAKBIT));
|
173
|
+
h->gclist = g->weak; /* must be cleared after GC, ... */
|
174
|
+
g->weak = obj2gco(h); /* ... so put in the appropriate list */
|
175
|
+
}
|
176
|
+
}
|
177
|
+
if (weakkey && weakvalue) return 1;
|
178
|
+
if (!weakvalue) {
|
179
|
+
i = h->sizearray;
|
180
|
+
while (i--)
|
181
|
+
markvalue(g, &h->array[i]);
|
182
|
+
}
|
183
|
+
i = sizenode(h);
|
184
|
+
while (i--) {
|
185
|
+
Node *n = gnode(h, i);
|
186
|
+
lua_assert(ttype(gkey(n)) != LUA_TDEADKEY || ttisnil(gval(n)));
|
187
|
+
if (ttisnil(gval(n)))
|
188
|
+
removeentry(n); /* remove empty entries */
|
189
|
+
else {
|
190
|
+
lua_assert(!ttisnil(gkey(n)));
|
191
|
+
if (!weakkey) markvalue(g, gkey(n));
|
192
|
+
if (!weakvalue) markvalue(g, gval(n));
|
193
|
+
}
|
194
|
+
}
|
195
|
+
return weakkey || weakvalue;
|
196
|
+
}
|
197
|
+
|
198
|
+
|
199
|
+
/*
|
200
|
+
** All marks are conditional because a GC may happen while the
|
201
|
+
** prototype is still being created
|
202
|
+
*/
|
203
|
+
static void traverseproto (global_State *g, Proto *f) {
|
204
|
+
int i;
|
205
|
+
if (f->source) stringmark(f->source);
|
206
|
+
for (i=0; i<f->sizek; i++) /* mark literals */
|
207
|
+
markvalue(g, &f->k[i]);
|
208
|
+
for (i=0; i<f->sizeupvalues; i++) { /* mark upvalue names */
|
209
|
+
if (f->upvalues[i])
|
210
|
+
stringmark(f->upvalues[i]);
|
211
|
+
}
|
212
|
+
for (i=0; i<f->sizep; i++) { /* mark nested protos */
|
213
|
+
if (f->p[i])
|
214
|
+
markobject(g, f->p[i]);
|
215
|
+
}
|
216
|
+
for (i=0; i<f->sizelocvars; i++) { /* mark local-variable names */
|
217
|
+
if (f->locvars[i].varname)
|
218
|
+
stringmark(f->locvars[i].varname);
|
219
|
+
}
|
220
|
+
}
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
static void traverseclosure (global_State *g, Closure *cl) {
|
225
|
+
markobject(g, cl->c.env);
|
226
|
+
if (cl->c.isC) {
|
227
|
+
int i;
|
228
|
+
for (i=0; i<cl->c.nupvalues; i++) /* mark its upvalues */
|
229
|
+
markvalue(g, &cl->c.upvalue[i]);
|
230
|
+
}
|
231
|
+
else {
|
232
|
+
int i;
|
233
|
+
lua_assert(cl->l.nupvalues == cl->l.p->nups);
|
234
|
+
markobject(g, cl->l.p);
|
235
|
+
for (i=0; i<cl->l.nupvalues; i++) /* mark its upvalues */
|
236
|
+
markobject(g, cl->l.upvals[i]);
|
237
|
+
}
|
238
|
+
}
|
239
|
+
|
240
|
+
|
241
|
+
static void checkstacksizes (lua_State *L, StkId max) {
|
242
|
+
int ci_used = cast_int(L->ci - L->base_ci); /* number of `ci' in use */
|
243
|
+
int s_used = cast_int(max - L->stack); /* part of stack in use */
|
244
|
+
if (L->size_ci > LUAI_MAXCALLS) /* handling overflow? */
|
245
|
+
return; /* do not touch the stacks */
|
246
|
+
if (4*ci_used < L->size_ci && 2*BASIC_CI_SIZE < L->size_ci)
|
247
|
+
luaD_reallocCI(L, L->size_ci/2); /* still big enough... */
|
248
|
+
condhardstacktests(luaD_reallocCI(L, ci_used + 1));
|
249
|
+
if (4*s_used < L->stacksize &&
|
250
|
+
2*(BASIC_STACK_SIZE+EXTRA_STACK) < L->stacksize)
|
251
|
+
luaD_reallocstack(L, L->stacksize/2); /* still big enough... */
|
252
|
+
condhardstacktests(luaD_reallocstack(L, s_used));
|
253
|
+
}
|
254
|
+
|
255
|
+
|
256
|
+
static void traversestack (global_State *g, lua_State *l) {
|
257
|
+
StkId o, lim;
|
258
|
+
CallInfo *ci;
|
259
|
+
markvalue(g, gt(l));
|
260
|
+
lim = l->top;
|
261
|
+
for (ci = l->base_ci; ci <= l->ci; ci++) {
|
262
|
+
lua_assert(ci->top <= l->stack_last);
|
263
|
+
if (lim < ci->top) lim = ci->top;
|
264
|
+
}
|
265
|
+
for (o = l->stack; o < l->top; o++)
|
266
|
+
markvalue(g, o);
|
267
|
+
for (; o <= lim; o++)
|
268
|
+
setnilvalue(o);
|
269
|
+
checkstacksizes(l, lim);
|
270
|
+
}
|
271
|
+
|
272
|
+
|
273
|
+
/*
|
274
|
+
** traverse one gray object, turning it to black.
|
275
|
+
** Returns `quantity' traversed.
|
276
|
+
*/
|
277
|
+
static l_mem propagatemark (global_State *g) {
|
278
|
+
GCObject *o = g->gray;
|
279
|
+
lua_assert(isgray(o));
|
280
|
+
gray2black(o);
|
281
|
+
switch (o->gch.tt) {
|
282
|
+
case LUA_TTABLE: {
|
283
|
+
Table *h = gco2h(o);
|
284
|
+
g->gray = h->gclist;
|
285
|
+
if (traversetable(g, h)) /* table is weak? */
|
286
|
+
black2gray(o); /* keep it gray */
|
287
|
+
return sizeof(Table) + sizeof(TValue) * h->sizearray +
|
288
|
+
sizeof(Node) * sizenode(h);
|
289
|
+
}
|
290
|
+
case LUA_TFUNCTION: {
|
291
|
+
Closure *cl = gco2cl(o);
|
292
|
+
g->gray = cl->c.gclist;
|
293
|
+
traverseclosure(g, cl);
|
294
|
+
return (cl->c.isC) ? sizeCclosure(cl->c.nupvalues) :
|
295
|
+
sizeLclosure(cl->l.nupvalues);
|
296
|
+
}
|
297
|
+
case LUA_TTHREAD: {
|
298
|
+
lua_State *th = gco2th(o);
|
299
|
+
g->gray = th->gclist;
|
300
|
+
th->gclist = g->grayagain;
|
301
|
+
g->grayagain = o;
|
302
|
+
black2gray(o);
|
303
|
+
traversestack(g, th);
|
304
|
+
return sizeof(lua_State) + sizeof(TValue) * th->stacksize +
|
305
|
+
sizeof(CallInfo) * th->size_ci;
|
306
|
+
}
|
307
|
+
case LUA_TPROTO: {
|
308
|
+
Proto *p = gco2p(o);
|
309
|
+
g->gray = p->gclist;
|
310
|
+
traverseproto(g, p);
|
311
|
+
return sizeof(Proto) + sizeof(Instruction) * p->sizecode +
|
312
|
+
sizeof(Proto *) * p->sizep +
|
313
|
+
sizeof(TValue) * p->sizek +
|
314
|
+
sizeof(int) * p->sizelineinfo +
|
315
|
+
sizeof(LocVar) * p->sizelocvars +
|
316
|
+
sizeof(TString *) * p->sizeupvalues;
|
317
|
+
}
|
318
|
+
default: lua_assert(0); return 0;
|
319
|
+
}
|
320
|
+
}
|
321
|
+
|
322
|
+
|
323
|
+
static size_t propagateall (global_State *g) {
|
324
|
+
size_t m = 0;
|
325
|
+
while (g->gray) m += propagatemark(g);
|
326
|
+
return m;
|
327
|
+
}
|
328
|
+
|
329
|
+
|
330
|
+
/*
|
331
|
+
** The next function tells whether a key or value can be cleared from
|
332
|
+
** a weak table. Non-collectable objects are never removed from weak
|
333
|
+
** tables. Strings behave as `values', so are never removed too. for
|
334
|
+
** other objects: if really collected, cannot keep them; for userdata
|
335
|
+
** being finalized, keep them in keys, but not in values
|
336
|
+
*/
|
337
|
+
static int iscleared (const TValue *o, int iskey) {
|
338
|
+
if (!iscollectable(o)) return 0;
|
339
|
+
if (ttisstring(o)) {
|
340
|
+
stringmark(rawtsvalue(o)); /* strings are `values', so are never weak */
|
341
|
+
return 0;
|
342
|
+
}
|
343
|
+
return iswhite(gcvalue(o)) ||
|
344
|
+
(ttisuserdata(o) && (!iskey && isfinalized(uvalue(o))));
|
345
|
+
}
|
346
|
+
|
347
|
+
|
348
|
+
/*
|
349
|
+
** clear collected entries from weaktables
|
350
|
+
*/
|
351
|
+
static void cleartable (GCObject *l) {
|
352
|
+
while (l) {
|
353
|
+
Table *h = gco2h(l);
|
354
|
+
int i = h->sizearray;
|
355
|
+
lua_assert(testbit(h->marked, VALUEWEAKBIT) ||
|
356
|
+
testbit(h->marked, KEYWEAKBIT));
|
357
|
+
if (testbit(h->marked, VALUEWEAKBIT)) {
|
358
|
+
while (i--) {
|
359
|
+
TValue *o = &h->array[i];
|
360
|
+
if (iscleared(o, 0)) /* value was collected? */
|
361
|
+
setnilvalue(o); /* remove value */
|
362
|
+
}
|
363
|
+
}
|
364
|
+
i = sizenode(h);
|
365
|
+
while (i--) {
|
366
|
+
Node *n = gnode(h, i);
|
367
|
+
if (!ttisnil(gval(n)) && /* non-empty entry? */
|
368
|
+
(iscleared(key2tval(n), 1) || iscleared(gval(n), 0))) {
|
369
|
+
setnilvalue(gval(n)); /* remove value ... */
|
370
|
+
removeentry(n); /* remove entry from table */
|
371
|
+
}
|
372
|
+
}
|
373
|
+
l = h->gclist;
|
374
|
+
}
|
375
|
+
}
|
376
|
+
|
377
|
+
|
378
|
+
static void freeobj (lua_State *L, GCObject *o) {
|
379
|
+
switch (o->gch.tt) {
|
380
|
+
case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break;
|
381
|
+
case LUA_TFUNCTION: luaF_freeclosure(L, gco2cl(o)); break;
|
382
|
+
case LUA_TUPVAL: luaF_freeupval(L, gco2uv(o)); break;
|
383
|
+
case LUA_TTABLE: luaH_free(L, gco2h(o)); break;
|
384
|
+
case LUA_TTHREAD: {
|
385
|
+
lua_assert(gco2th(o) != L && gco2th(o) != G(L)->mainthread);
|
386
|
+
luaE_freethread(L, gco2th(o));
|
387
|
+
break;
|
388
|
+
}
|
389
|
+
case LUA_TSTRING: {
|
390
|
+
G(L)->strt.nuse--;
|
391
|
+
luaM_freemem(L, o, sizestring(gco2ts(o)));
|
392
|
+
break;
|
393
|
+
}
|
394
|
+
case LUA_TUSERDATA: {
|
395
|
+
luaM_freemem(L, o, sizeudata(gco2u(o)));
|
396
|
+
break;
|
397
|
+
}
|
398
|
+
default: lua_assert(0);
|
399
|
+
}
|
400
|
+
}
|
401
|
+
|
402
|
+
|
403
|
+
|
404
|
+
#define sweepwholelist(L,p) sweeplist(L,p,MAX_LUMEM)
|
405
|
+
|
406
|
+
|
407
|
+
static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) {
|
408
|
+
GCObject *curr;
|
409
|
+
global_State *g = G(L);
|
410
|
+
int deadmask = otherwhite(g);
|
411
|
+
while ((curr = *p) != NULL && count-- > 0) {
|
412
|
+
if (curr->gch.tt == LUA_TTHREAD) /* sweep open upvalues of each thread */
|
413
|
+
sweepwholelist(L, &gco2th(curr)->openupval);
|
414
|
+
if ((curr->gch.marked ^ WHITEBITS) & deadmask) { /* not dead? */
|
415
|
+
lua_assert(!isdead(g, curr) || testbit(curr->gch.marked, FIXEDBIT));
|
416
|
+
makewhite(g, curr); /* make it white (for next cycle) */
|
417
|
+
p = &curr->gch.next;
|
418
|
+
}
|
419
|
+
else { /* must erase `curr' */
|
420
|
+
lua_assert(isdead(g, curr) || deadmask == bitmask(SFIXEDBIT));
|
421
|
+
*p = curr->gch.next;
|
422
|
+
if (curr == g->rootgc) /* is the first element of the list? */
|
423
|
+
g->rootgc = curr->gch.next; /* adjust first */
|
424
|
+
freeobj(L, curr);
|
425
|
+
}
|
426
|
+
}
|
427
|
+
return p;
|
428
|
+
}
|
429
|
+
|
430
|
+
|
431
|
+
static void checkSizes (lua_State *L) {
|
432
|
+
global_State *g = G(L);
|
433
|
+
/* check size of string hash */
|
434
|
+
if (g->strt.nuse < cast(lu_int32, g->strt.size/4) &&
|
435
|
+
g->strt.size > MINSTRTABSIZE*2)
|
436
|
+
luaS_resize(L, g->strt.size/2); /* table is too big */
|
437
|
+
/* check size of buffer */
|
438
|
+
if (luaZ_sizebuffer(&g->buff) > LUA_MINBUFFER*2) { /* buffer too big? */
|
439
|
+
size_t newsize = luaZ_sizebuffer(&g->buff) / 2;
|
440
|
+
luaZ_resizebuffer(L, &g->buff, newsize);
|
441
|
+
}
|
442
|
+
}
|
443
|
+
|
444
|
+
|
445
|
+
static void GCTM (lua_State *L) {
|
446
|
+
global_State *g = G(L);
|
447
|
+
GCObject *o = g->tmudata->gch.next; /* get first element */
|
448
|
+
Udata *udata = rawgco2u(o);
|
449
|
+
const TValue *tm;
|
450
|
+
/* remove udata from `tmudata' */
|
451
|
+
if (o == g->tmudata) /* last element? */
|
452
|
+
g->tmudata = NULL;
|
453
|
+
else
|
454
|
+
g->tmudata->gch.next = udata->uv.next;
|
455
|
+
udata->uv.next = g->mainthread->next; /* return it to `root' list */
|
456
|
+
g->mainthread->next = o;
|
457
|
+
makewhite(g, o);
|
458
|
+
tm = fasttm(L, udata->uv.metatable, TM_GC);
|
459
|
+
if (tm != NULL) {
|
460
|
+
lu_byte oldah = L->allowhook;
|
461
|
+
lu_mem oldt = g->GCthreshold;
|
462
|
+
L->allowhook = 0; /* stop debug hooks during GC tag method */
|
463
|
+
g->GCthreshold = 2*g->totalbytes; /* avoid GC steps */
|
464
|
+
setobj2s(L, L->top, tm);
|
465
|
+
setuvalue(L, L->top+1, udata);
|
466
|
+
L->top += 2;
|
467
|
+
luaD_call(L, L->top - 2, 0);
|
468
|
+
L->allowhook = oldah; /* restore hooks */
|
469
|
+
g->GCthreshold = oldt; /* restore threshold */
|
470
|
+
}
|
471
|
+
}
|
472
|
+
|
473
|
+
|
474
|
+
/*
|
475
|
+
** Call all GC tag methods
|
476
|
+
*/
|
477
|
+
void luaC_callGCTM (lua_State *L) {
|
478
|
+
while (G(L)->tmudata)
|
479
|
+
GCTM(L);
|
480
|
+
}
|
481
|
+
|
482
|
+
|
483
|
+
void luaC_freeall (lua_State *L) {
|
484
|
+
global_State *g = G(L);
|
485
|
+
int i;
|
486
|
+
g->currentwhite = WHITEBITS | bitmask(SFIXEDBIT); /* mask to collect all elements */
|
487
|
+
sweepwholelist(L, &g->rootgc);
|
488
|
+
for (i = 0; i < g->strt.size; i++) /* free all string lists */
|
489
|
+
sweepwholelist(L, &g->strt.hash[i]);
|
490
|
+
}
|
491
|
+
|
492
|
+
|
493
|
+
static void markmt (global_State *g) {
|
494
|
+
int i;
|
495
|
+
for (i=0; i<NUM_TAGS; i++)
|
496
|
+
if (g->mt[i]) markobject(g, g->mt[i]);
|
497
|
+
}
|
498
|
+
|
499
|
+
|
500
|
+
/* mark root set */
|
501
|
+
static void markroot (lua_State *L) {
|
502
|
+
global_State *g = G(L);
|
503
|
+
g->gray = NULL;
|
504
|
+
g->grayagain = NULL;
|
505
|
+
g->weak = NULL;
|
506
|
+
markobject(g, g->mainthread);
|
507
|
+
/* make global table be traversed before main stack */
|
508
|
+
markvalue(g, gt(g->mainthread));
|
509
|
+
markvalue(g, registry(L));
|
510
|
+
markmt(g);
|
511
|
+
g->gcstate = GCSpropagate;
|
512
|
+
}
|
513
|
+
|
514
|
+
|
515
|
+
static void remarkupvals (global_State *g) {
|
516
|
+
UpVal *uv;
|
517
|
+
for (uv = g->uvhead.u.l.next; uv != &g->uvhead; uv = uv->u.l.next) {
|
518
|
+
lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv);
|
519
|
+
if (isgray(obj2gco(uv)))
|
520
|
+
markvalue(g, uv->v);
|
521
|
+
}
|
522
|
+
}
|
523
|
+
|
524
|
+
|
525
|
+
static void atomic (lua_State *L) {
|
526
|
+
global_State *g = G(L);
|
527
|
+
size_t udsize; /* total size of userdata to be finalized */
|
528
|
+
/* remark occasional upvalues of (maybe) dead threads */
|
529
|
+
remarkupvals(g);
|
530
|
+
/* traverse objects cautch by write barrier and by 'remarkupvals' */
|
531
|
+
propagateall(g);
|
532
|
+
/* remark weak tables */
|
533
|
+
g->gray = g->weak;
|
534
|
+
g->weak = NULL;
|
535
|
+
lua_assert(!iswhite(obj2gco(g->mainthread)));
|
536
|
+
markobject(g, L); /* mark running thread */
|
537
|
+
markmt(g); /* mark basic metatables (again) */
|
538
|
+
propagateall(g);
|
539
|
+
/* remark gray again */
|
540
|
+
g->gray = g->grayagain;
|
541
|
+
g->grayagain = NULL;
|
542
|
+
propagateall(g);
|
543
|
+
udsize = luaC_separateudata(L, 0); /* separate userdata to be finalized */
|
544
|
+
marktmu(g); /* mark `preserved' userdata */
|
545
|
+
udsize += propagateall(g); /* remark, to propagate `preserveness' */
|
546
|
+
cleartable(g->weak); /* remove collected objects from weak tables */
|
547
|
+
/* flip current white */
|
548
|
+
g->currentwhite = cast_byte(otherwhite(g));
|
549
|
+
g->sweepstrgc = 0;
|
550
|
+
g->sweepgc = &g->rootgc;
|
551
|
+
g->gcstate = GCSsweepstring;
|
552
|
+
g->estimate = g->totalbytes - udsize; /* first estimate */
|
553
|
+
}
|
554
|
+
|
555
|
+
|
556
|
+
static l_mem singlestep (lua_State *L) {
|
557
|
+
global_State *g = G(L);
|
558
|
+
/*lua_checkmemory(L);*/
|
559
|
+
switch (g->gcstate) {
|
560
|
+
case GCSpause: {
|
561
|
+
markroot(L); /* start a new collection */
|
562
|
+
return 0;
|
563
|
+
}
|
564
|
+
case GCSpropagate: {
|
565
|
+
if (g->gray)
|
566
|
+
return propagatemark(g);
|
567
|
+
else { /* no more `gray' objects */
|
568
|
+
atomic(L); /* finish mark phase */
|
569
|
+
return 0;
|
570
|
+
}
|
571
|
+
}
|
572
|
+
case GCSsweepstring: {
|
573
|
+
lu_mem old = g->totalbytes;
|
574
|
+
sweepwholelist(L, &g->strt.hash[g->sweepstrgc++]);
|
575
|
+
if (g->sweepstrgc >= g->strt.size) /* nothing more to sweep? */
|
576
|
+
g->gcstate = GCSsweep; /* end sweep-string phase */
|
577
|
+
lua_assert(old >= g->totalbytes);
|
578
|
+
g->estimate -= old - g->totalbytes;
|
579
|
+
return GCSWEEPCOST;
|
580
|
+
}
|
581
|
+
case GCSsweep: {
|
582
|
+
lu_mem old = g->totalbytes;
|
583
|
+
g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX);
|
584
|
+
if (*g->sweepgc == NULL) { /* nothing more to sweep? */
|
585
|
+
checkSizes(L);
|
586
|
+
g->gcstate = GCSfinalize; /* end sweep phase */
|
587
|
+
}
|
588
|
+
lua_assert(old >= g->totalbytes);
|
589
|
+
g->estimate -= old - g->totalbytes;
|
590
|
+
return GCSWEEPMAX*GCSWEEPCOST;
|
591
|
+
}
|
592
|
+
case GCSfinalize: {
|
593
|
+
if (g->tmudata) {
|
594
|
+
GCTM(L);
|
595
|
+
if (g->estimate > GCFINALIZECOST)
|
596
|
+
g->estimate -= GCFINALIZECOST;
|
597
|
+
return GCFINALIZECOST;
|
598
|
+
}
|
599
|
+
else {
|
600
|
+
g->gcstate = GCSpause; /* end collection */
|
601
|
+
g->gcdept = 0;
|
602
|
+
return 0;
|
603
|
+
}
|
604
|
+
}
|
605
|
+
default: lua_assert(0); return 0;
|
606
|
+
}
|
607
|
+
}
|
608
|
+
|
609
|
+
|
610
|
+
void luaC_step (lua_State *L) {
|
611
|
+
global_State *g = G(L);
|
612
|
+
l_mem lim = (GCSTEPSIZE/100) * g->gcstepmul;
|
613
|
+
if (lim == 0)
|
614
|
+
lim = (MAX_LUMEM-1)/2; /* no limit */
|
615
|
+
g->gcdept += g->totalbytes - g->GCthreshold;
|
616
|
+
do {
|
617
|
+
lim -= singlestep(L);
|
618
|
+
if (g->gcstate == GCSpause)
|
619
|
+
break;
|
620
|
+
} while (lim > 0);
|
621
|
+
if (g->gcstate != GCSpause) {
|
622
|
+
if (g->gcdept < GCSTEPSIZE)
|
623
|
+
g->GCthreshold = g->totalbytes + GCSTEPSIZE; /* - lim/g->gcstepmul;*/
|
624
|
+
else {
|
625
|
+
g->gcdept -= GCSTEPSIZE;
|
626
|
+
g->GCthreshold = g->totalbytes;
|
627
|
+
}
|
628
|
+
}
|
629
|
+
else {
|
630
|
+
lua_assert(g->totalbytes >= g->estimate);
|
631
|
+
setthreshold(g);
|
632
|
+
}
|
633
|
+
}
|
634
|
+
|
635
|
+
|
636
|
+
void luaC_fullgc (lua_State *L) {
|
637
|
+
global_State *g = G(L);
|
638
|
+
if (g->gcstate <= GCSpropagate) {
|
639
|
+
/* reset sweep marks to sweep all elements (returning them to white) */
|
640
|
+
g->sweepstrgc = 0;
|
641
|
+
g->sweepgc = &g->rootgc;
|
642
|
+
/* reset other collector lists */
|
643
|
+
g->gray = NULL;
|
644
|
+
g->grayagain = NULL;
|
645
|
+
g->weak = NULL;
|
646
|
+
g->gcstate = GCSsweepstring;
|
647
|
+
}
|
648
|
+
lua_assert(g->gcstate != GCSpause && g->gcstate != GCSpropagate);
|
649
|
+
/* finish any pending sweep phase */
|
650
|
+
while (g->gcstate != GCSfinalize) {
|
651
|
+
lua_assert(g->gcstate == GCSsweepstring || g->gcstate == GCSsweep);
|
652
|
+
singlestep(L);
|
653
|
+
}
|
654
|
+
markroot(L);
|
655
|
+
while (g->gcstate != GCSpause) {
|
656
|
+
singlestep(L);
|
657
|
+
}
|
658
|
+
setthreshold(g);
|
659
|
+
}
|
660
|
+
|
661
|
+
|
662
|
+
void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v) {
|
663
|
+
global_State *g = G(L);
|
664
|
+
lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o));
|
665
|
+
lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause);
|
666
|
+
lua_assert(ttype(&o->gch) != LUA_TTABLE);
|
667
|
+
/* must keep invariant? */
|
668
|
+
if (g->gcstate == GCSpropagate)
|
669
|
+
reallymarkobject(g, v); /* restore invariant */
|
670
|
+
else /* don't mind */
|
671
|
+
makewhite(g, o); /* mark as white just to avoid other barriers */
|
672
|
+
}
|
673
|
+
|
674
|
+
|
675
|
+
void luaC_barrierback (lua_State *L, Table *t) {
|
676
|
+
global_State *g = G(L);
|
677
|
+
GCObject *o = obj2gco(t);
|
678
|
+
lua_assert(isblack(o) && !isdead(g, o));
|
679
|
+
lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause);
|
680
|
+
black2gray(o); /* make table gray (again) */
|
681
|
+
t->gclist = g->grayagain;
|
682
|
+
g->grayagain = o;
|
683
|
+
}
|
684
|
+
|
685
|
+
|
686
|
+
void luaC_link (lua_State *L, GCObject *o, lu_byte tt) {
|
687
|
+
global_State *g = G(L);
|
688
|
+
o->gch.next = g->rootgc;
|
689
|
+
g->rootgc = o;
|
690
|
+
o->gch.marked = luaC_white(g);
|
691
|
+
o->gch.tt = tt;
|
692
|
+
}
|
693
|
+
|
694
|
+
|
695
|
+
void luaC_linkupval (lua_State *L, UpVal *uv) {
|
696
|
+
global_State *g = G(L);
|
697
|
+
GCObject *o = obj2gco(uv);
|
698
|
+
o->gch.next = g->rootgc; /* link upvalue into `rootgc' list */
|
699
|
+
g->rootgc = o;
|
700
|
+
if (isgray(o)) {
|
701
|
+
if (g->gcstate == GCSpropagate) {
|
702
|
+
gray2black(o); /* closed upvalues need barrier */
|
703
|
+
luaC_barrier(L, uv, uv->v);
|
704
|
+
}
|
705
|
+
else { /* sweep phase: sweep it (turning it into white) */
|
706
|
+
makewhite(g, o);
|
707
|
+
lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause);
|
708
|
+
}
|
709
|
+
}
|
710
|
+
}
|
711
|
+
|