elua: prepare for compatibility with cffi-lua (use ffi.nullptr)

This is necessary because the LuaJIT FFI implements the null
pointer to nil equality behavior, which is not possible to
do in standard Lua (as equality metamethod needs identical types
to trigger).

So replace it with ffi.nullptr as cffi-lua implements; in luajit
ffi.nullptr will just become nil and it'll work like before.
This commit is contained in:
Daniel Kolesa 2020-05-21 17:45:43 +02:00
parent a7d475be47
commit a928dba502
8 changed files with 128 additions and 122 deletions

View File

@ -46,12 +46,12 @@ ffi.metatype("Eina_Accessor", {
unlock = function(self) return eina.eina_accessor_unlock(self) ~= 0 end, unlock = function(self) return eina.eina_accessor_unlock(self) ~= 0 end,
clone = function(self) clone = function(self)
local v = eina.eina_accessor_clone(self) local v = eina.eina_accessor_clone(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
container_get = function(self) container_get = function(self)
local v = eina.eina_accessor_container_get(self) local v = eina.eina_accessor_container_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end end
} }
@ -64,7 +64,7 @@ local dgetmt = debug.getmetatable
M.Accessor = util.Readonly_Object:clone { M.Accessor = util.Readonly_Object:clone {
__ctor = function(self, selfmt, acc) __ctor = function(self, selfmt, acc)
-- prevent null stuff -- prevent null stuff
if acc == nil then acc = nil end if acc == ffi.nullptr then acc = nil end
if acc then ffi.gc(acc, acc.free) end if acc then ffi.gc(acc, acc.free) end
selfmt.__eq = function(self, other) selfmt.__eq = function(self, other)
return selfmt.__accessor == dgetmt(other).__accessor return selfmt.__accessor == dgetmt(other).__accessor

View File

@ -51,7 +51,7 @@ M.Counter = ffi.metatype("Eina_Counter", {
dump = function(self) dump = function(self)
local v = eina.eina_counter_dump(self) local v = eina.eina_counter_dump(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
local r = ffi.string(v) local r = ffi.string(v)
C.free(v) C.free(v)
return r return r

View File

@ -236,7 +236,7 @@ M.direct_ls = function(dir) return Direct_Ls_Iterator(dir) end
M.path_sanitize = function(path) M.path_sanitize = function(path)
local v = eina.eina_file_path_sanitize(path) local v = eina.eina_file_path_sanitize(path)
if v == nil then return nil end if v == ffi.nullptr then return nil end
local r = ffi.string(v) local r = ffi.string(v)
C.free(v) C.free(v)
return r return r
@ -358,7 +358,7 @@ M.File = ffi.metatype("Eina_File", {
map_all = function(self, rule, raw) map_all = function(self, rule, raw)
local v = ffi.cast("char*", eina.eina_file_map_all(self, rule or 0)) local v = ffi.cast("char*", eina.eina_file_map_all(self, rule or 0))
if v == nil then return nil end if v == ffi.nullptr then return nil end
if not raw then if not raw then
local r = ffi.string(v) local r = ffi.string(v)
self:map_free(v) self:map_free(v)
@ -370,7 +370,7 @@ M.File = ffi.metatype("Eina_File", {
map_new = function(self, rule, offset, length, raw) map_new = function(self, rule, offset, length, raw)
local v = ffi.cast("char*", eina.eina_file_map_new(self, rule or 0, local v = ffi.cast("char*", eina.eina_file_map_new(self, rule or 0,
offset or 0, length)) offset or 0, length))
if v == nil then return nil end if v == ffi.nullptr then return nil end
if not raw then if not raw then
local r = ffi.string(v, length) local r = ffi.string(v, length)
self:map_free(v) self:map_free(v)

View File

@ -43,7 +43,7 @@ ffi.metatype("Eina_Iterator", {
unlock = function(self) return eina.eina_iterator_unlock(self) ~= 0 end, unlock = function(self) return eina.eina_iterator_unlock(self) ~= 0 end,
container_get = function(self) container_get = function(self)
local v = eina.eina_iterator_container_get(self) local v = eina.eina_iterator_container_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end end
} }
@ -56,7 +56,7 @@ local dgetmt = debug.getmetatable
M.Iterator = util.Readonly_Object:clone { M.Iterator = util.Readonly_Object:clone {
__ctor = function(self, selfmt, iter) __ctor = function(self, selfmt, iter)
-- prevent null stuff -- prevent null stuff
if iter == nil then iter = nil end if iter == ffi.nullptr then iter = nil end
if iter then ffi.gc(iter, iter.free) end if iter then ffi.gc(iter, iter.free) end
selfmt.__eq = function(self, other) selfmt.__eq = function(self, other)
return selfmt.__iterator == dgetmt(other).__iterator return selfmt.__iterator == dgetmt(other).__iterator

View File

@ -83,7 +83,9 @@ local dgetmt = debug.getmetatable
local List_Iterator = Iterator:clone { local List_Iterator = Iterator:clone {
__ctor = function(self, selfmt, list) __ctor = function(self, selfmt, list)
if list == nil then return Iterator.__ctor(self, selfmt, nil) end if not list or list == ffi.nullptr then
return Iterator.__ctor(self, selfmt, nil)
end
selfmt.__list = list selfmt.__list = list
return Iterator.__ctor(self, selfmt, return Iterator.__ctor(self, selfmt,
eina.eina_list_iterator_new(dgetmt(list).__list)) eina.eina_list_iterator_new(dgetmt(list).__list))
@ -98,7 +100,9 @@ local List_Iterator = Iterator:clone {
local List_Reverse_Iterator = Iterator:clone { local List_Reverse_Iterator = Iterator:clone {
__ctor = function(self, selfmt, list) __ctor = function(self, selfmt, list)
if list == nil then return Iterator.__ctor(self, selfmt, nil) end if not list or list == ffi.nullptr then
return Iterator.__ctor(self, selfmt, nil)
end
selfmt.__list = list selfmt.__list = list
return Iterator.__ctor(self, selfmt, return Iterator.__ctor(self, selfmt,
eina.eina_list_iterator_reversed_new(dgetmt(list).__list)) eina.eina_list_iterator_reversed_new(dgetmt(list).__list))
@ -115,7 +119,9 @@ local Accessor = accessor.Accessor
local List_Accessor = Accessor:clone { local List_Accessor = Accessor:clone {
__ctor = function(self, selfmt, list) __ctor = function(self, selfmt, list)
if list == nil then return Accessor.__ctor(self, selfmt, nil) end if not list or list == ffi.nullptr then
return Accessor.__ctor(self, selfmt, nil)
end
selfmt.__list = list selfmt.__list = list
return Accessor.__ctor(self, selfmt, return Accessor.__ctor(self, selfmt,
eina.eina_list_accessor_new(dgetmt(list).__list)) eina.eina_list_accessor_new(dgetmt(list).__list))
@ -141,37 +147,37 @@ local List = ffi.metatype("Eina_List", {
data_get = function(self, ptr) data_get = function(self, ptr)
if ptr ~= nil then return ptr end if ptr ~= nil then return ptr end
local v = get_list_t(self).data local v = get_list_t(self).data
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
nth = function(self, n) nth = function(self, n)
local v = eina.eina_list_nth(self, n - 1) local v = eina.eina_list_nth(self, n - 1)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return self:data_get(v) return self:data_get(v)
end, end,
nth_list = function(self, n) nth_list = function(self, n)
local v = eina.eina_list_nth_list(self, n - 1) local v = eina.eina_list_nth_list(self, n - 1)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
last = function(self) last = function(self)
local v = get_list_t(self).accounting.last local v = get_list_t(self).accounting.last
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
next = function(self) next = function(self)
local v = get_list_t(self).next local v = get_list_t(self).next
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
prev = function(self) prev = function(self)
local v = get_list_t(self).prev local v = get_list_t(self).prev
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end end
} }
@ -183,7 +189,7 @@ local List_Base = util.Readonly_Object:clone {
list = ffi.gc(list, freefunc) list = ffi.gc(list, freefunc)
selfmt.__free = freefunc selfmt.__free = freefunc
end end
if list == nil then return end if not list or list == ffi.nullptr then return end
selfmt.__eq = function(self, other) selfmt.__eq = function(self, other)
return selfmt.__list == dgetmt(other).__list return selfmt.__list == dgetmt(other).__list
end end
@ -194,62 +200,62 @@ local List_Base = util.Readonly_Object:clone {
free = function(self) free = function(self)
self = dgetmt(self) self = dgetmt(self)
local ffunc, l = self.__free, self.__list local ffunc, l = self.__free, self.__list
if not ffunc or l == nil then return end if not ffunc or not l or l == ffi.nullptr then return end
ffunc(ffi.gc(self.__list, nil)) ffunc(ffi.gc(self.__list, nil))
end, end,
count = function(self) count = function(self)
self = dgetmt(self) self = dgetmt(self)
local l = self.__list local l = self.__list
if l == nil then return 0 end if not l or l == ffi.nullptr then return 0 end
return #l return #l
end, end,
nth = function(self, n) nth = function(self, n)
self = dgetmt(self) self = dgetmt(self)
local l = self.__list local l = self.__list
if l == nil then return nil end if not l or l == ffi.nullptr then return nil end
return l:nth() return l:nth()
end, end,
nth_list = function(self, n) nth_list = function(self, n)
self = dgetmt(self) self = dgetmt(self)
local l = self.__list local l = self.__list
if l == nil then return nil end if not l or l == ffi.nullptr then return nil end
return self.__index(l:nth_list()) return self.__index(l:nth_list())
end, end,
last = function(self, n) last = function(self, n)
self = dgetmt(self) self = dgetmt(self)
local l = self.__list local l = self.__list
if l == nil then return nil end if not l or l == ffi.nullptr then return nil end
return self.__index(l:last()) return self.__index(l:last())
end, end,
next = function(self, n) next = function(self, n)
self = dgetmt(self) self = dgetmt(self)
local l = self.__list local l = self.__list
if l == nil then return nil end if not l or l == ffi.nullptr then return nil end
return self.__index(l:next()) return self.__index(l:next())
end, end,
prev = function(self, n) prev = function(self, n)
self = dgetmt(self) self = dgetmt(self)
local l = self.__list local l = self.__list
if l == nil then return nil end if not l or l == ffi.nullptr then return nil end
return self.__index(l:prev()) return self.__index(l:prev())
end, end,
data_get = function(self, ptr) data_get = function(self, ptr)
self = dgetmt(self) self = dgetmt(self)
local l = self.__list local l = self.__list
if l == nil then return nil end if not l or l == ffi.nullptr then return nil end
return l:data_get(ptr) return l:data_get(ptr)
end, end,
to_array = function(self) to_array = function(self)
local l = dgetmt(self).__list local l = dgetmt(self).__list
if l == nil then return {}, 0 end if not l or l == ffi.nullptr then return {}, 0 end
local n = 0 local n = 0
local r = {} local r = {}
while l ~= nil do while l ~= nil do
@ -293,7 +299,7 @@ M.Ptr_List = List_Base:clone {
M.String_List = List_Base:clone { M.String_List = List_Base:clone {
data_get = function(self, ptr) data_get = function(self, ptr)
ptr = List_Base.data_get(self, ptr) ptr = List_Base.data_get(self, ptr)
if ptr == nil then return nil end if not ptr or ptr == ffi.nullptr then return nil end
return ffi.string(ptr) return ffi.string(ptr)
end end
} }

View File

@ -98,7 +98,7 @@ end
M.get = function(file, attribute) M.get = function(file, attribute)
local size = ffi.new("size_t[1]") local size = ffi.new("size_t[1]")
local v = eina.eina_xattr_get(file, attribute, size) local v = eina.eina_xattr_get(file, attribute, size)
if v == nil then return nil end if v == ffi.nullptr then return nil end
local r = ffi.string(v, size[0]) local r = ffi.string(v, size[0])
C.free(v) C.free(v)
return r return r
@ -126,7 +126,7 @@ end
M.string_get = function(file, attribute) M.string_get = function(file, attribute)
local v = eina.eina_xattr_string_get(file, attribute) local v = eina.eina_xattr_string_get(file, attribute)
if v == nil then return nil end if v == ffi.nullptr then return nil end
local r = ffi.string(v) local r = ffi.string(v)
C.free(v) C.free(v)
return r return r

View File

@ -337,7 +337,7 @@ end
local get_obj_mt = function(obj) local get_obj_mt = function(obj)
local cl = eo.eo_class_get(obj) local cl = eo.eo_class_get(obj)
if cl == nil then return nil end if cl == ffi.nullptr then return nil end
return classes[eo_obj_addr_get(cl)] return classes[eo_obj_addr_get(cl)]
end end
@ -416,7 +416,7 @@ ffi.metatype("Eo", {
-- handles property getting with no keys and also properties with keys -- handles property getting with no keys and also properties with keys
__index = function(self, key) __index = function(self, key)
local mt = get_obj_mt(self) local mt = get_obj_mt(self)
if mt == nil then return nil end if not mt then return nil end
local pt = mt.__properties local pt = mt.__properties
local pp = pt[key] local pp = pt[key]
if not pp then if not pp then
@ -444,7 +444,7 @@ ffi.metatype("Eo", {
-- handles property setting with no keys -- handles property setting with no keys
__newindex = function(self, key, val) __newindex = function(self, key, val)
local mt = get_obj_mt(self) local mt = get_obj_mt(self)
if mt == nil then return nil end if not mt then return nil end
local pt = mt.__properties local pt = mt.__properties
local pp = pt[key] local pp = pt[key]
if not pp then if not pp then

View File

@ -556,7 +556,7 @@ local object_idx, wrap_object = gen_wrap {
unit_get = function(self) unit_get = function(self)
local v = eolian.eolian_object_unit_get(cast_obj(self)) local v = eolian.eolian_object_unit_get(cast_obj(self))
if v == nil then if v == ffi.nullptr then
return nil return nil
end end
return v return v
@ -572,7 +572,7 @@ local object_idx, wrap_object = gen_wrap {
file_get = function(self) file_get = function(self)
local v = eolian.eolian_object_file_get(cast_obj(self)) local v = eolian.eolian_object_file_get(cast_obj(self))
if v == nil then if v == ffi.nullptr then
return nil return nil
end end
return ffi.string(v) return ffi.string(v)
@ -580,7 +580,7 @@ local object_idx, wrap_object = gen_wrap {
name_get = function(self) name_get = function(self)
local v = eolian.eolian_object_name_get(cast_obj(self)) local v = eolian.eolian_object_name_get(cast_obj(self))
if v == nil then if v == ffi.nullptr then
return nil return nil
end end
return ffi.string(v) return ffi.string(v)
@ -588,7 +588,7 @@ local object_idx, wrap_object = gen_wrap {
c_name_get = function(self) c_name_get = function(self)
local v = eolian.eolian_object_c_name_get(cast_obj(self)) local v = eolian.eolian_object_c_name_get(cast_obj(self))
if v == nil then if v == ffi.nullptr then
return nil return nil
end end
return ffi.string(v) return ffi.string(v)
@ -596,7 +596,7 @@ local object_idx, wrap_object = gen_wrap {
short_name_get = function(self) short_name_get = function(self)
local v = eolian.eolian_object_short_name_get(cast_obj(self)) local v = eolian.eolian_object_short_name_get(cast_obj(self))
if v == nil then if v == ffi.nullptr then
return nil return nil
end end
return ffi.string(v) return ffi.string(v)
@ -617,7 +617,7 @@ ffi.metatype("Eolian_Object", { __index = object_idx })
local unit_idx, wrap_unit = gen_wrap { local unit_idx, wrap_unit = gen_wrap {
state_get = function(self) state_get = function(self)
local v = eolian.eolian_unit_state_get(cast_unit(self)) local v = eolian.eolian_unit_state_get(cast_unit(self))
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
@ -628,13 +628,13 @@ local unit_idx, wrap_unit = gen_wrap {
file_get = function(self) file_get = function(self)
local v = eolian.eolian_unit_file_get(cast_unit(self)) local v = eolian.eolian_unit_file_get(cast_unit(self))
if v == nil then return nil end if v == ffi.nullptr then return nil end
return ffi.string(v) return ffi.string(v)
end, end,
file_path_get = function(self) file_path_get = function(self)
local v = eolian.eolian_unit_file_path_get(cast_unit(self)) local v = eolian.eolian_unit_file_path_get(cast_unit(self))
if v == nil then return nil end if v == ffi.nullptr then return nil end
return ffi.string(v) return ffi.string(v)
end, end,
@ -644,7 +644,7 @@ local unit_idx, wrap_unit = gen_wrap {
object_by_name_get = function(self, name) object_by_name_get = function(self, name)
local v = eolian.eolian_unit_object_by_name_get(cast_unit(self), name) local v = eolian.eolian_unit_object_by_name_get(cast_unit(self), name)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
@ -655,7 +655,7 @@ local unit_idx, wrap_unit = gen_wrap {
class_by_name_get = function(self, cname) class_by_name_get = function(self, cname)
local v = eolian.eolian_unit_class_by_name_get(cast_unit(self), cname) local v = eolian.eolian_unit_class_by_name_get(cast_unit(self), cname)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
@ -666,13 +666,13 @@ local unit_idx, wrap_unit = gen_wrap {
constant_by_name_get = function(self, name) constant_by_name_get = function(self, name)
local v = eolian.eolian_unit_constant_by_name_get(cast_unit(self), name) local v = eolian.eolian_unit_constant_by_name_get(cast_unit(self), name)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
error_by_name_get = function(self, name) error_by_name_get = function(self, name)
local v = eolian.eolian_unit_error_by_name_get(cast_unit(self), name) local v = eolian.eolian_unit_error_by_name_get(cast_unit(self), name)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
@ -688,19 +688,19 @@ local unit_idx, wrap_unit = gen_wrap {
alias_by_name_get = function(self, name) alias_by_name_get = function(self, name)
local v = eolian.eolian_unit_alias_by_name_get(cast_unit(self), name) local v = eolian.eolian_unit_alias_by_name_get(cast_unit(self), name)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
struct_by_name_get = function(self, name) struct_by_name_get = function(self, name)
local v = eolian.eolian_unit_struct_by_name_get(cast_unit(self), name) local v = eolian.eolian_unit_struct_by_name_get(cast_unit(self), name)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
enum_by_name_get = function(self, name) enum_by_name_get = function(self, name)
local v = eolian.eolian_unit_enum_by_name_get(cast_unit(self), name) local v = eolian.eolian_unit_enum_by_name_get(cast_unit(self), name)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
@ -769,7 +769,7 @@ ffi.metatype("Eolian_State", {
file_parse = function(self, fname) file_parse = function(self, fname)
local v = eolian.eolian_state_file_parse(self, fname) local v = eolian.eolian_state_file_parse(self, fname)
if v == nil then if v == ffi.nullptr then
return nil return nil
end end
return v return v
@ -777,7 +777,7 @@ ffi.metatype("Eolian_State", {
file_path_parse = function(self, fpath) file_path_parse = function(self, fpath)
local v = eolian.eolian_state_file_path_parse(self, fpath) local v = eolian.eolian_state_file_path_parse(self, fpath)
if v == nil then if v == ffi.nullptr then
return nil return nil
end end
return v return v
@ -817,7 +817,7 @@ ffi.metatype("Eolian_State", {
unit_by_file_get = function(self, fname) unit_by_file_get = function(self, fname)
local v = eolian.eolian_state_unit_by_file_get(state, fname) local v = eolian.eolian_state_unit_by_file_get(state, fname)
if v == nil then if v == ffi.nullptr then
return nil return nil
end end
return v return v
@ -835,7 +835,7 @@ ffi.metatype("Eolian_State", {
class_by_file_get = function(self, fname) class_by_file_get = function(self, fname)
local v = eolian.eolian_state_class_by_file_get(self, fname) local v = eolian.eolian_state_class_by_file_get(self, fname)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
@ -961,13 +961,13 @@ ffi.metatype("Eolian_Struct_Type_Field", {
__index = wrap_object { __index = wrap_object {
documentation_get = function(self) documentation_get = function(self)
local v = eolian.eolian_typedecl_struct_field_documentation_get(self) local v = eolian.eolian_typedecl_struct_field_documentation_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
type_get = function(self) type_get = function(self)
local v = eolian.eolian_typedecl_struct_field_type_get(self) local v = eolian.eolian_typedecl_struct_field_type_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
@ -985,19 +985,19 @@ ffi.metatype("Eolian_Enum_Type_Field", {
__index = wrap_object { __index = wrap_object {
c_name_get = function(self) c_name_get = function(self)
local v = eolian.eolian_typedecl_enum_field_c_constant_get(self) local v = eolian.eolian_typedecl_enum_field_c_constant_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return ffi_stringshare(v) return ffi_stringshare(v)
end, end,
documentation_get = function(self) documentation_get = function(self)
local v = eolian.eolian_typedecl_enum_field_documentation_get(self) local v = eolian.eolian_typedecl_enum_field_documentation_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
value_get = function(self, force) value_get = function(self, force)
local v = eolian.eolian_typedecl_enum_field_value_get(self, force and 1 or 0) local v = eolian.eolian_typedecl_enum_field_value_get(self, force and 1 or 0)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end end
} }
@ -1016,7 +1016,7 @@ M.Typedecl = ffi.metatype("Eolian_Typedecl", {
struct_field_get = function(self, name) struct_field_get = function(self, name)
local v = eolian.eolian_typedecl_struct_field_get(self, name) local v = eolian.eolian_typedecl_struct_field_get(self, name)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
@ -1027,31 +1027,31 @@ M.Typedecl = ffi.metatype("Eolian_Typedecl", {
enum_field_get = function(self, field) enum_field_get = function(self, field)
local v = eolian.eolian_typedecl_enum_field_get(self, field) local v = eolian.eolian_typedecl_enum_field_get(self, field)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
enum_legacy_prefix_get = function(self) enum_legacy_prefix_get = function(self)
local v = eolian.eolian_typedecl_enum_legacy_prefix_get(self) local v = eolian.eolian_typedecl_enum_legacy_prefix_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return ffi.string(v) return ffi.string(v)
end, end,
documentation_get = function(self, name) documentation_get = function(self, name)
local v = eolian.eolian_typedecl_documentation_get(self) local v = eolian.eolian_typedecl_documentation_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
base_type_get = function(self) base_type_get = function(self)
local v = eolian.eolian_typedecl_base_type_get(self) local v = eolian.eolian_typedecl_base_type_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
aliased_base_get = function(self) aliased_base_get = function(self)
local v = eolian.eolian_typedecl_aliased_byse_get(self) local v = eolian.eolian_typedecl_aliased_byse_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
@ -1061,19 +1061,19 @@ M.Typedecl = ffi.metatype("Eolian_Typedecl", {
c_type_get = function(self) c_type_get = function(self)
local v = eolian.eolian_typedecl_c_type_get(self) local v = eolian.eolian_typedecl_c_type_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return ffi_stringshare(v) return ffi_stringshare(v)
end, end,
free_func_get = function(self) free_func_get = function(self)
local v = eolian.eolian_typedecl_free_func_get(self) local v = eolian.eolian_typedecl_free_func_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return ffi.string(v) return ffi.string(v)
end, end,
function_pointer_get = function(self) function_pointer_get = function(self)
local v = eolian.eolian_typedecl_function_pointer_get(self) local v = eolian.eolian_typedecl_function_pointer_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end end
} }
@ -1091,37 +1091,37 @@ M.Type = ffi.metatype("Eolian_Type", {
base_type_get = function(self) base_type_get = function(self)
local v = eolian.eolian_type_base_type_get(self) local v = eolian.eolian_type_base_type_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
next_type_get = function(self) next_type_get = function(self)
local v = eolian.eolian_type_next_type_get(self) local v = eolian.eolian_type_next_type_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
typedecl_get = function(self) typedecl_get = function(self)
local v = eolian.eolian_type_typedecl_get(self) local v = eolian.eolian_type_typedecl_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
aliased_base_get = function(self) aliased_base_get = function(self)
local v = eolian.eolian_type_aliased_byse_get(self) local v = eolian.eolian_type_aliased_byse_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
class_get = function(self) class_get = function(self)
local v = eolian.eolian_type_class_get(self) local v = eolian.eolian_type_class_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
error_get = function(self) error_get = function(self)
local v = eolian.eolian_type_error_get(self) local v = eolian.eolian_type_error_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
@ -1139,7 +1139,7 @@ M.Type = ffi.metatype("Eolian_Type", {
c_type_get = function(self) c_type_get = function(self)
local v = eolian.eolian_type_c_type_get(self) local v = eolian.eolian_type_c_type_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return ffi_stringshare(v) return ffi_stringshare(v)
end end
} }
@ -1166,13 +1166,13 @@ M.Function = ffi.metatype("Eolian_Function", {
full_c_name_get = function(self, ftype) full_c_name_get = function(self, ftype)
local v = eolian.eolian_function_full_c_name_get(self, ftype) local v = eolian.eolian_function_full_c_name_get(self, ftype)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return ffi_stringshare(v) return ffi_stringshare(v)
end, end,
implement_get = function(self) implement_get = function(self)
local v = eolian.eolian_function_implement_get(self) local v = eolian.eolian_function_implement_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
@ -1205,19 +1205,19 @@ M.Function = ffi.metatype("Eolian_Function", {
return_type_get = function(self, ftype) return_type_get = function(self, ftype)
local v = eolian.eolian_function_return_type_get(self, ftype) local v = eolian.eolian_function_return_type_get(self, ftype)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
return_default_value_get = function(self, ftype) return_default_value_get = function(self, ftype)
local v = eolian.eolian_function_return_default_value_get(self, ftype) local v = eolian.eolian_function_return_default_value_get(self, ftype)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
return_documentation_get = function(self, ftype) return_documentation_get = function(self, ftype)
local v = eolian.eolian_function_return_documentation_get(self, ftype) local v = eolian.eolian_function_return_documentation_get(self, ftype)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
@ -1240,7 +1240,7 @@ M.Function = ffi.metatype("Eolian_Function", {
class_get = function(self) class_get = function(self)
local v = eolian.eolian_function_class_get(self) local v = eolian.eolian_function_class_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end end
} }
@ -1261,19 +1261,19 @@ ffi.metatype("Eolian_Function_Parameter", {
type_get = function(self) type_get = function(self)
local v = eolian.eolian_parameter_type_get(self) local v = eolian.eolian_parameter_type_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
default_value_get = function(self) default_value_get = function(self)
local v = eolian.eolian_parameter_default_value_get(self) local v = eolian.eolian_parameter_default_value_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
documentation_get = function(self) documentation_get = function(self)
local v = eolian.eolian_parameter_documentation_get(self) local v = eolian.eolian_parameter_documentation_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
@ -1295,26 +1295,26 @@ ffi.metatype("Eolian_Implement", {
__index = wrap_object { __index = wrap_object {
class_get = function(self) class_get = function(self)
local v = eolian.eolian_implement_class_get(self) local v = eolian.eolian_implement_class_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
implementing_class_get = function(self) implementing_class_get = function(self)
local v = eolian.eolian_implement_implementing_class_get(self) local v = eolian.eolian_implement_implementing_class_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
function_get = function(self) function_get = function(self)
local tp = ffi.new("Eolian_Function_Type[1]") local tp = ffi.new("Eolian_Function_Type[1]")
local v = eolian.eolian_implement_function_get(self, tp) local v = eolian.eolian_implement_function_get(self, tp)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v, tp[0] return v, tp[0]
end, end,
documentation_get = function(self, ftype) documentation_get = function(self, ftype)
local v = eolian.eolian_implement_documentation_get(self, ftype) local v = eolian.eolian_implement_documentation_get(self, ftype)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
@ -1344,13 +1344,13 @@ ffi.metatype("Eolian_Constructor", {
__index = wrap_object { __index = wrap_object {
class_get = function(self) class_get = function(self)
local v = eolian.eolian_constructor_class_get(self) local v = eolian.eolian_constructor_class_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
function_get = function(self) function_get = function(self)
local v = eolian.eolian_constructor_function_get(self) local v = eolian.eolian_constructor_function_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
@ -1364,19 +1364,19 @@ ffi.metatype("Eolian_Event", {
__index = wrap_object { __index = wrap_object {
type_get = function(self) type_get = function(self)
local v = eolian.eolian_event_type_get(self) local v = eolian.eolian_event_type_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
class_get = function(self) class_get = function(self)
local v = eolian.eolian_event_class_get(self) local v = eolian.eolian_event_class_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
documentation_get = function(self) documentation_get = function(self)
local v = eolian.eolian_event_documentation_get(self) local v = eolian.eolian_event_documentation_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
@ -1386,7 +1386,7 @@ ffi.metatype("Eolian_Event", {
c_macro_get = function(self) c_macro_get = function(self)
local v = eolian.eolian_event_c_macro_get(self) local v = eolian.eolian_event_c_macro_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return ffi_stringshare(v) return ffi_stringshare(v)
end, end,
@ -1404,13 +1404,13 @@ ffi.metatype("Eolian_Part", {
__index = wrap_object { __index = wrap_object {
class_get = function(self) class_get = function(self)
local v = eolian.eolian_part_class_get(self) local v = eolian.eolian_part_class_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
documentation_get = function(self) documentation_get = function(self)
local v = eolian.eolian_part_documentation_get(self) local v = eolian.eolian_part_documentation_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end end
} }
@ -1432,13 +1432,13 @@ M.Class = ffi.metatype("Eolian_Class", {
documentation_get = function(self) documentation_get = function(self)
local v = eolian.eolian_class_documentation_get(self) local v = eolian.eolian_class_documentation_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
c_prefix_get = function(self) c_prefix_get = function(self)
local v = eolian.eolian_class_c_prefix_get(self) local v = eolian.eolian_class_c_prefix_get(self)
if v == nil then if v == ffi.nullptr then
local buf = self:namespaces_get() local buf = self:namespaces_get()
buf[#buf + 1] = self:short_name_get() buf[#buf + 1] = self:short_name_get()
return table.concat(buf, "_"):lower() return table.concat(buf, "_"):lower()
@ -1448,7 +1448,7 @@ M.Class = ffi.metatype("Eolian_Class", {
event_c_prefix_get = function(self) event_c_prefix_get = function(self)
local v = eolian.eolian_class_event_c_prefix_get(self) local v = eolian.eolian_class_event_c_prefix_get(self)
if v == nil then if v == ffi.nullptr then
return self:c_prefix_get() return self:c_prefix_get()
end end
return ffi.string(v) return ffi.string(v)
@ -1456,13 +1456,13 @@ M.Class = ffi.metatype("Eolian_Class", {
data_type_get = function(self) data_type_get = function(self)
local v = eolian.eolian_class_data_type_get(self) local v = eolian.eolian_class_data_type_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return ffi.string(v) return ffi.string(v)
end, end,
parent_get = function(self) parent_get = function(self)
local v = eolian.eolian_class_parent_get(self) local v = eolian.eolian_class_parent_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
@ -1484,7 +1484,7 @@ M.Class = ffi.metatype("Eolian_Class", {
function_by_name_get = function(self, fname, ftype) function_by_name_get = function(self, fname, ftype)
local v = eolian.eolian_class_function_by_name_get(self, fname, local v = eolian.eolian_class_function_by_name_get(self, fname,
ftype) ftype)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
@ -1505,7 +1505,7 @@ M.Class = ffi.metatype("Eolian_Class", {
event_by_name_get = function(self, name) event_by_name_get = function(self, name)
local v = eolian.eolian_class_event_by_name_get(self, name) local v = eolian.eolian_class_event_by_name_get(self, name)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
@ -1524,19 +1524,19 @@ M.Class = ffi.metatype("Eolian_Class", {
c_get_function_name_get = function(self) c_get_function_name_get = function(self)
local v = eolian.eolian_class_c_get_function_name_get(self) local v = eolian.eolian_class_c_get_function_name_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return ffi_stringshare(v) return ffi_stringshare(v)
end, end,
c_macro_get = function(self) c_macro_get = function(self)
local v = eolian.eolian_class_c_macro_get(self) local v = eolian.eolian_class_c_macro_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return ffi_stringshare(v) return ffi_stringshare(v)
end, end,
c_data_type_get = function(self) c_data_type_get = function(self)
local v = eolian.eolian_class_c_data_type_get(self) local v = eolian.eolian_class_c_data_type_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return ffi_stringshare(v) return ffi_stringshare(v)
end end
} }
@ -1611,7 +1611,7 @@ M.Value = ffi.metatype("Eolian_Value", {
to_literal = function(self) to_literal = function(self)
local v = eolian.eolian_expression_value_to_literal(self) local v = eolian.eolian_expression_value_to_literal(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return ffi_stringshare(v) return ffi_stringshare(v)
end end
} }
@ -1658,13 +1658,13 @@ M.Expression = ffi.metatype("Eolian_Expression", {
eval = function(self, mask) eval = function(self, mask)
mask = mask or emask.ALL mask = mask or emask.ALL
local v = eolian.eolian_expression_eval(self, mask) local v = eolian.eolian_expression_eval(self, mask)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return ffi.cast("Eolian_Value*", v) return ffi.cast("Eolian_Value*", v)
end, end,
serialize = function(self) serialize = function(self)
local v = eolian.eolian_expression_serialize(self) local v = eolian.eolian_expression_serialize(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return ffi_stringshare(v) return ffi_stringshare(v)
end, end,
@ -1678,13 +1678,13 @@ M.Expression = ffi.metatype("Eolian_Expression", {
binary_lhs_get = function(self) binary_lhs_get = function(self)
local v = eolian.eolian_expression_binary_lhs_get(self) local v = eolian.eolian_expression_binary_lhs_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
binary_rhs_get = function(self) binary_rhs_get = function(self)
local v = eolian.eolian_expression_binary_rhs_get(self) local v = eolian.eolian_expression_binary_rhs_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
@ -1694,13 +1694,13 @@ M.Expression = ffi.metatype("Eolian_Expression", {
unary_expression_get = function(self) unary_expression_get = function(self)
local v = eolian.eolian_expression_unary_expression_get(self) local v = eolian.eolian_expression_unary_expression_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
value_get = function(self) value_get = function(self)
local v = eolian.eolian_expression_value_get(self) local v = eolian.eolian_expression_value_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return ffi.cast("Eolian_Value*", v) return ffi.cast("Eolian_Value*", v)
end end
} }
@ -1710,19 +1710,19 @@ M.Constant = ffi.metatype("Eolian_Constant", {
__index = wrap_object { __index = wrap_object {
documentation_get = function(self) documentation_get = function(self)
local v = eolian.eolian_constant_documentation_get(self) local v = eolian.eolian_constant_documentation_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
type_get = function(self) type_get = function(self)
local v = eolian.eolian_constant_type_get(self) local v = eolian.eolian_constant_type_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
value_get = function(self) value_get = function(self)
local v = eolian.eolian_constant_value_get(self) local v = eolian.eolian_constant_value_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
@ -1736,13 +1736,13 @@ M.Error = ffi.metatype("Eolian_Error", {
__index = wrap_object { __index = wrap_object {
documentation_get = function(self) documentation_get = function(self)
local v = eolian.eolian_error_documentation_get(self) local v = eolian.eolian_error_documentation_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return v return v
end, end,
message_get = function(self) message_get = function(self)
local v = eolian.eolian_error_message_get(self) local v = eolian.eolian_error_message_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return ffi.string(v) return ffi.string(v)
end, end,
@ -1756,19 +1756,19 @@ M.Documentation = ffi.metatype("Eolian_Documentation", {
__index = wrap_object { __index = wrap_object {
summary_get = function(self) summary_get = function(self)
local v = eolian.eolian_documentation_summary_get(self) local v = eolian.eolian_documentation_summary_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return ffi.string(v) return ffi.string(v)
end, end,
description_get = function(self) description_get = function(self)
local v = eolian.eolian_documentation_description_get(self) local v = eolian.eolian_documentation_description_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return ffi.string(v) return ffi.string(v)
end, end,
since_get = function(self) since_get = function(self)
local v = eolian.eolian_documentation_since_get(self) local v = eolian.eolian_documentation_since_get(self)
if v == nil then return nil end if v == ffi.nullptr then return nil end
return ffi.string(v) return ffi.string(v)
end end
} }
@ -1807,7 +1807,7 @@ end
M.documentation_tokenize = function(doc, ret) M.documentation_tokenize = function(doc, ret)
local ret = eolian.eolian_documentation_tokenize(doc, ret) local ret = eolian.eolian_documentation_tokenize(doc, ret)
if ret == nil then if ret == ffi.nullptr then
return nil return nil
end end
return ffi.string(ret) return ffi.string(ret)
@ -1827,7 +1827,7 @@ M.Eolian_Doc_Token = ffi.metatype("Eolian_Doc_Token", {
text_get = function(self) text_get = function(self)
local str = eolian.eolian_doc_token_text_get(self) local str = eolian.eolian_doc_token_text_get(self)
if str == nil then if str == ffi.nullptr then
return nil return nil
end end
local ret = ffi.string(str) local ret = ffi.string(str)