From 298c0b409ac01f17968ed3ff5dd6e2e901627e04 Mon Sep 17 00:00:00 2001 From: Tycho Date: Wed, 2 Apr 2014 06:04:17 -0700 Subject: Fixed tolua++ override support --- lib/tolua++/src/bin/lua/container.lua | 21 +++++++++++++-------- lib/tolua++/src/bin/lua/function.lua | 4 +--- 2 files changed, 14 insertions(+), 11 deletions(-) (limited to 'lib/tolua++/src/bin/lua') diff --git a/lib/tolua++/src/bin/lua/container.lua b/lib/tolua++/src/bin/lua/container.lua index 97e7b58fd..99488479e 100644 --- a/lib/tolua++/src/bin/lua/container.lua +++ b/lib/tolua++/src/bin/lua/container.lua @@ -58,7 +58,7 @@ function classContainer:hasvar () while self[i] do if self[i]:isvariable() then return 1 - end + end i = i+1 end return 0 @@ -568,7 +568,7 @@ function classContainer:doparse (s) -- Enumerate(name,body) -- return strsub(s,e+1) -- end --- end +-- end do local b,e,body,name = strfind(s,"^%s*typedef%s+enum[^{]*(%b{})%s*([%w_][^%s]*)%s*;%s*") @@ -606,15 +606,14 @@ function classContainer:doparse (s) -- try function do --local b,e,decl,arg,const = strfind(s,"^%s*([~_%w][_@%w%s%*&:<>]*[_%w])%s*(%b())%s*(c?o?n?s?t?)%s*=?%s*0?%s*;%s*") - local b,e,decl,arg,const,virt = strfind(s,"^%s*([^%(\n]+)%s*(%b())%s*(c?o?n?s?t?)%s*o?v?e?r?i?d?e?%s*(=?%s*0?)%s*;%s*") - warning("trace" .. b .. "," .. e "," .. decl) + local b,e,decl,arg,const,virt = strfind(s,"^%s*([^%(\n]+)%s*(%b())%s*(c?o?n?s?t?)v?e?r?r?i?d?e?%s*o?v?e?r?r?i?d?e?%s*(=?%s*0?)%s*;%s*") if not b then -- try function with template - b,e,decl,arg,const = strfind(s,"^%s*([~_%w][_@%w%s%*&:<>]*[_%w]%b<>)%s*(%b())%s*(c?o?n?s?t?)%s*o?v?e?r?i?d?e?%s*=?%s*0?%s*;%s*") + b,e,decl,arg,const = strfind(s,"^%s*([~_%w][_@%w%s%*&:<>]*[_%w]%b<>)%s*(%b())%s*(c?o?n?s?t?)v?e?r?r?i?d?e?%s*o?v?e?r?r?i?d?e?%s*=?%s*0?%s*;%s*") end if not b then -- try a single letter function name - b,e,decl,arg,const = strfind(s,"^%s*([_%w])%s*(%b())%s*(c?o?n?s?t?)%s*o?v?e?r?i?d?e?%s*;%s*") + b,e,decl,arg,const = strfind(s,"^%s*([_%w])%s*(%b())%s*(c?o?n?s?t?)v?e?r?r?i?d?e?%s*o?v?e?r?r?i?d?e?%s*;%s*") end if not b then -- try function pointer @@ -630,6 +629,9 @@ function classContainer:doparse (s) end end _curr_code = strsub(s,b,e) + if const == 'o' then + const = '' + end Function(decl,arg,const) return strsub(s,e+1) end @@ -637,14 +639,17 @@ function classContainer:doparse (s) -- try inline function do - local b,e,decl,arg,const = strfind(s,"^%s*([^%(\n]+)%s*(%b())%s*(c?o?n?s?t?)%s*o?v?e?r?i?d?e?[^;{]*%b{}%s*;?%s*") + local b,e,decl,arg,const = strfind(s,"^%s*([^%(\n]+)%s*(%b())%s*(c?o?n?s?t?)v?e?r?r?i?d?e?%s*o?v?e?r?r?i?d?e?[^;{]*%b{}%s*;?%s*") --local b,e,decl,arg,const = strfind(s,"^%s*([~_%w][_@%w%s%*&:<>]*[_%w>])%s*(%b())%s*(c?o?n?s?t?)[^;]*%b{}%s*;?%s*") if not b then -- try a single letter function name - b,e,decl,arg,const = strfind(s,"^%s*([_%w])%s*(%b())%s*(c?o?n?s?t?)%s*o?v?e?r?i?d?e?.-%b{}%s*;?%s*") + b,e,decl,arg,const = strfind(s,"^%s*([_%w])%s*(%b())%s*(c?o?n?s?t?)v?e?r?r?i?d?e?%s*o?v?e?r?r?i?d?e?.-%b{}%s*;?%s*") end if b then _curr_code = strsub(s,b,e) + if const == 'o' then + const = '' + end Function(decl,arg,const) return strsub(s,e+1) end diff --git a/lib/tolua++/src/bin/lua/function.lua b/lib/tolua++/src/bin/lua/function.lua index 3b6b53c5e..9338e0fbc 100644 --- a/lib/tolua++/src/bin/lua/function.lua +++ b/lib/tolua++/src/bin/lua/function.lua @@ -458,9 +458,8 @@ end -- Internal constructor function _Function (t) setmetatable(t,classFunction) - if t.const ~= 'const' and t.const ~= '' then - error("#invalid 'const' specification") + error("#invalid 'const' specification: " .. t.const) end append(t) @@ -489,7 +488,6 @@ end function Function (d,a,c) --local t = split(strsub(a,2,-2),',') -- eliminate braces --local t = split_params(strsub(a,2,-2)) - if not flags['W'] and string.find(a, "%.%.%.%s*%)") then warning("Functions with variable arguments (`...') are not supported. Ignoring "..d..a..c) -- cgit v1.2.3