10
['unsigned'] = 'number',
12
['double'] = 'number',
13
['_cstring'] = 'string',
14
['_userdata'] = 'userdata',
16
['void*'] = 'userdata',
18
['lua_State*'] = 'state',
19
['_lstate'] = 'state',
20
['lua_Object'] = 'value',
21
['lua_Function'] = 'function',
22
['LUA_VALUE'] = 'value', -- for compatibility with tolua 4.0
26
number = "lua_Number",
27
string = "const char*",
39
function appendrenaming (s)
40
local b,e,old,new = strfind(s,"%s*(.-)%s*@%s*(.-)%s*$")
42
error("#Invalid renaming syntax; it should be of the form: pattern@pattern")
44
tinsert(_renaming,{old=old, new=new})
47
function applyrenaming (s)
48
for i=1,getn(_renaming) do
49
local m,n = gsub(s,_renaming[i].old,_renaming[i].new)
57
function tolua_error (s,f)
60
if strsub(s,1,1) == '#' then
61
write("\n** tolua: "..strsub(s,2)..".\n\n")
63
local _,_,s = strfind(_curr_code,"^%s*(.-\n)") -- extract first line
64
if s==nil then s = _curr_code end
65
s = gsub(s,"_userdata","void*") -- return with 'void*'
66
s = gsub(s,"_cstring","char*") -- return with 'char*'
67
s = gsub(s,"_lstate","lua_State*") -- return with 'lua_State*'
68
write("Code being processed:\n"..s.."\n")
71
print(debug.traceback("\n** tolua internal error: "..f..s..".\n\n"))
77
function warning (msg)
80
write("\n** tolua warning: "..msg..".\n\n")
85
local ft = findtype(t)
90
return appendusertype(t)
94
function typevar(type)
95
if type == '' or type == 'void' then
98
local ft = findtype(type)
102
_usertype[type] = type
107
function isbasic (type)
108
local t = gsub(type,'const ','')
109
local m,t = applytypedef(t)
112
return b,_basic_ctype[b]
119
local f = function (s)
123
local p = "%s*(.-)%s*"..t.."%s*"
124
s = gsub(s,"^%s+","")
125
s = gsub(s,"%s+$","")
128
l[l.n] = gsub(s,"(%s%s*)$","")
133
function concat (t,f,l)
139
if i <= l then s = s..' ' end
144
function concatparam (line, ...)
147
if _cont and not strfind(_cont,'[%(,"]') and
148
strfind(arg[i],"^[%a_~]") then
151
line = line .. arg[i]
153
_cont = strsub(arg[i],-1,-1)
157
if strfind(arg[arg.n],"[%/%)%;%{%}]$") then
158
_cont=nil line = line .. '\n'
163
function output (...)
166
if _cont and not strfind(_cont,'[%(,"]') and
167
strfind(arg[i],"^[%a_~]") then
172
_cont = strsub(arg[i],-1,-1)
176
if strfind(arg[arg.n],"[%/%)%;%{%}]$") then
177
_cont=nil write('\n')