} 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,
EOLIAN_EXPR_UINT,
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);
ALIAS = 4
}
+M.c_type_type = {
+ DEFAULT = 0,
+ PARAM = 1,
+ RETURN = 2
+}
+
ffi.metatype("Eolian_Struct_Type_Field", {
__index = {
name_get = function(self)
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,
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
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 = {}
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
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 = {}
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)
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 }
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)