summaryrefslogtreecommitdiff
path: root/src/bin/elua/modules
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2014-11-19 11:40:49 +0000
committerDaniel Kolesa <d.kolesa@samsung.com>2014-11-19 11:40:49 +0000
commitb1009770ef8e71e2787d59b2fad9be4b105f82cf (patch)
tree5d1b9b6b0353ae2f06f1f8b1032e4bedd7d46212 /src/bin/elua/modules
parentf902de616e948b7ab5e88b9547b8302d2bb131a1 (diff)
elua: simplify lualian typeconv
Diffstat (limited to 'src/bin/elua/modules')
-rw-r--r--src/bin/elua/modules/lualian.lua34
1 files changed, 5 insertions, 29 deletions
diff --git a/src/bin/elua/modules/lualian.lua b/src/bin/elua/modules/lualian.lua
index c28f3496cd..ccf30dff34 100644
--- a/src/bin/elua/modules/lualian.lua
+++ b/src/bin/elua/modules/lualian.lua
@@ -80,50 +80,26 @@ local build_calln = function(tps, expr, isin)
80 return expr 80 return expr
81end 81end
82 82
83local typeconv_in = function(tps, expr)
84 if tps:type_get() == eolian.type_type.POINTER then
85 local base = tps:base_type_get()
86 local f = known_ptr_in[base:c_type_get()]
87 if f then return f(expr) end
88 return build_calln(tps, expr, true)
89 end
90
91 local tp = tps:name_get()
92
93 if is_num(tp) then return expr end
94
95 local f = known_in[tp]
96 if f then
97 return f(expr)
98 end
99
100 return build_calln(tps, expr, true)
101end
102
103local typeconv = function(tps, expr, isin) 83local typeconv = function(tps, expr, isin)
104 if isin then
105 return typeconv_in(tps, expr)
106 end
107
108 if tps:type_get() == eolian.type_type.POINTER then 84 if tps:type_get() == eolian.type_type.POINTER then
109 local base = tps:base_type_get() 85 local base = tps:base_type_get()
110 local f = known_ptr_out[base:c_type_get()] 86 local f = (isin and known_ptr_in or known_ptr_out)[base:c_type_get()]
111 if f then return f(expr) end 87 if f then return f(expr) end
112 return build_calln(tps, expr, false) 88 return build_calln(tps, expr, isin)
113 end 89 end
114 90
115 local tp = tps:name_get() 91 local tp = tps:name_get()
116 92
117 if is_num(tp) then 93 if is_num(tp) then
118 return ("tonumber(%s)"):format(expr) 94 return isin and expr or ("tonumber(%s)"):format(expr)
119 end 95 end
120 96
121 local f = known_out[tp] 97 local f = (isin and known_in or known_out)[tp]
122 if f then 98 if f then
123 return f(expr) 99 return f(expr)
124 end 100 end
125 101
126 return build_calln(tps, expr, false) 102 return build_calln(tps, expr, isin)
127end 103end
128 104
129local Node = util.Object:clone { 105local Node = util.Object:clone {