elua: update eolian bindings with c type serialization change

This commit is contained in:
Daniel Kolesa 2017-08-10 12:17:10 +02:00
parent e288f5160b
commit e38418dd9d
3 changed files with 24 additions and 12 deletions

View File

@ -84,6 +84,12 @@ ffi.cdef [[
EOLIAN_TYPE_UNDEFINED
} Eolian_Type_Type;
typedef enum {
EOLIAN_C_TYPE_DEFAULT = 0,
EOLIAN_C_TYPE_PARAM,
EOLIAN_C_TYPE_RETURN
} Eolian_C_Type_Type;
typedef enum {
EOLIAN_EXPR_UNKNOWN = 0,
EOLIAN_EXPR_INT,
@ -341,7 +347,7 @@ ffi.cdef [[
Eina_Bool eolian_typedecl_is_extern(const Eolian_Typedecl *tp);
const char *eolian_type_c_type_get(const Eolian_Type *tp);
const char *eolian_type_c_type_get(const Eolian_Type *tp, Eolian_C_Type_Type ctype);
const char *eolian_typedecl_c_type_get(const Eolian_Unit *unit, const Eolian_Typedecl *tp);
const char *eolian_type_name_get(const Eolian_Type *tp);
@ -512,6 +518,12 @@ M.typedecl_type = {
ALIAS = 4
}
M.c_type_type = {
DEFAULT = 0,
PARAM = 1,
RETURN = 2
}
ffi.metatype("Eolian_Struct_Type_Field", {
__index = {
name_get = function(self)
@ -713,8 +725,8 @@ M.Type = ffi.metatype("Eolian_Type", {
return eolian.eolian_type_is_ptr(self) ~= 0
end,
c_type_get = function(self)
local v = eolian.eolian_type_c_type_get(self)
c_type_get = function(self, ctype)
local v = eolian.eolian_type_c_type_get(self, ctype)
if v == nil then return nil end
return ffi_stringshare(v)
end,

View File

@ -729,7 +729,7 @@ M.Type = Node:clone {
end,
c_type_get = function(self)
return self.type:c_type_get()
return self.type:c_type_get(eolian.c_type_type.DEFAULT)
end,
name_get = function(self)

View File

@ -94,7 +94,7 @@ end
local typeconv = function(tps, expr, isin)
if tps:type_get() == type_type.POINTER then
local base = tps:base_type_get()
local f = (isin and known_ptr_in or known_ptr_out)[base:c_type_get()]
local f = (isin and known_ptr_in or known_ptr_out)[base:c_type_get(eolian.c_type_type.DEFAULT)]
if f then return f(expr) end
return build_calln(tps, expr, isin)
end
@ -180,7 +180,7 @@ local Method = Node:clone {
local proto = {
name = meth:name_get()
}
proto.ret_type = rett and rett:c_type_get() or "void"
proto.ret_type = rett and rett:c_type_get(eolian.c_type_type.RETURN) or "void"
local args, cargs, vargs = { "self" }, {}, {}
proto.args, proto.cargs, proto.vargs = args, cargs, vargs
local rets = {}
@ -198,7 +198,7 @@ local Method = Node:clone {
for v in pars do
local dir, tps, nm = v:direction_get(), v:type_get(), kw_t(v:name_get())
local tp = tps:c_type_get()
local tp = tps:c_type_get(eolian.c_type_type.PARAM)
if dir == param_dir.OUT or dir == param_dir.INOUT then
if dir == param_dir.INOUT then
args[#args + 1] = nm
@ -275,7 +275,7 @@ local Property = Method:clone {
nkeys = #keys,
nvals = #vals
}
proto.ret_type = rett and rett:c_type_get() or "void"
proto.ret_type = rett and rett:c_type_get(eolian.c_type_type.RETURN) or "void"
local args, cargs, vargs = { "self" }, {}, {}
proto.args, proto.cargs, proto.vargs = args, cargs, vargs
local rets = {}
@ -290,7 +290,7 @@ local Property = Method:clone {
for i, v in ipairs(keys) do
local nm = kw_t(v:name_get())
local tps = v:type_get()
local tp = tps:c_type_get()
local tp = tps:c_type_get(eolian.c_type_type.PARAM)
args [#args + 1] = nm
cargs[#cargs + 1] = tp .. " " .. nm
vargs[#vargs + 1] = typeconv(tps, nm, true)
@ -302,13 +302,13 @@ local Property = Method:clone {
if self.isget then
if #vals == 1 and not rett then
local tps = vals[1]:type_get()
proto.ret_type = tps:c_type_get()
proto.ret_type = tps:c_type_get(eolian.c_type_type.PARAM)
rets[#rets + 1] = typeconv(tps, "v", false)
else
for i, v in ipairs(vals) do
local dir, tps, nm = v:direction_get(), v:type_get(),
kw_t(v:name_get())
local tp = tps:c_type_get()
local tp = tps:c_type_get(eolian.c_type_type.PARAM)
cargs [#cargs + 1] = tp .. " *" .. nm
vargs [#vargs + 1] = nm
allocs[#allocs + 1] = { tp, nm }
@ -319,7 +319,7 @@ local Property = Method:clone {
for i, v in ipairs(vals) do
local dir, tps, nm = v:direction_get(), v:type_get(),
kw_t(v:name_get())
local tp = tps:c_type_get()
local tp = tps:c_type_get(eolian.c_type_type.PARAM)
args [#args + 1] = nm
cargs[#cargs + 1] = tp .. " " .. nm
vargs[#vargs + 1] = typeconv(tps, nm, true)